Repository navigation
feat(tests): stub in turn, double inherited methods, and own the game tree - #10
Merged
Merged
Conversation
A lock with a fixed TTL expires under a long edit, and a claim whose owner died had no way back but to wait. `lock.renew` resets the timer, and any request that carries `holder` renews every lock that holder owns, so a working agent keeps its claim without a timer of its own. An admin token may release or renew a lock it does not hold. That is the recovery path, and the docs say to use it only when the holder is gone. A write token that tries gets a refusal that names the holder. MCP could not name a holder, so an MCP session could never write inside its own lock. `bin/gai mcp --holder agent-a` puts one on every request, and `--ceiling` caps the whole session below its token. Both go through a `bridge_request` builder that the tests can read. The agent skill gains a lock section: claim the node, pass the same holder on every write, know that `object.call` is blocked by a covering lock even for a read, and that an admin can break a stale claim. Tests: a holder keeps its lock past its TTL, an explicit renew reports the new time, a write token cannot renew another holder's lock, and an admin can release it.
… tree Three leftovers from the roadmap's own list, all of them things an agent hits on its first real test file. `stub_once(object, method, values, args)` answers with each value in turn and keeps returning the last one, which is how a fixed dice, a once-only failure, or a retry gets tested without a hand-written class. `double_script` only overrode methods declared in the script itself, so a double of a subclass could not stub what its base declared and every fixture needed a wrapper. It now walks the base chain and overrides an inherited method from the ancestor that declares it. A method inherited from a native class is still out of reach, and the docs say so. `CODEOWNERS` listed gai's test files one by one but never `game/`, so `validate-codeowners` failed on every game edit, which is most edits here. It now covers `/game/` and `/tests/*.py`, and the ten individual lines are gone. Tests: a subclass double stubs an inherited method, a sequence answers in order and repeats, and an argument-scoped sequence leaves other calls alone.
`test_clean_project_exits_zero` looked for the literal `lint: 8 scripts`. Adding one fixture script made it read 9 and the CI game job failed with a clean lint result, which is exactly the kind of assertion that teaches nothing and breaks weekly. It now matches `lint: <n> scripts, 0 problems`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Three leftovers that an agent hits on its first real test file, all from the roadmap's own list.
A fixed dice, a once-only failure, and a retry all need a stub that answers differently on the second call, and the harness could only answer the same value forever.
A double of a subclass could not stub a method its base script declared, so every fixture needed a wrapper script that redeclared it.
And
validate-codeownersfailed on every file undergame/, which is most edits in this repository, because CODEOWNERS never covered it.What changed
stub_once(object, method, values, args)answers with each value in turn and keeps returning the last one, scoped to one argument list whenargsis given.double_scriptwalks the base script chain and overrides a method the base declares, using the ancestor's signature. A method inherited from a native class is still out of reach, and the docs say so.CODEOWNERScovers/game/and/tests/*.py, replacing ten individual test-file lines.Verification
test_double_inherited_method:double("res://tests/fixtures/combat_child.gd", ["take_damage"])answers the real value, then a stub of the inherited method answers 42.test_stub_once_answers_in_turn: 10, then 20, then 20 again, with three recorded calls.test_stub_once_matches_arguments: a sequence scoped to[1]leaves a call with[2]at the real value.bin/gai testruns 17 game tests green;bin/gai checkgreen; pre-commit passes over every touched file, includingvalidate-codeownersongame/.