Skip to content

feat(tests): stub in turn, double inherited methods, and own the game tree - #10

Merged
jerryshell merged 3 commits into
mainfrom
feat/test-maturity
Nov 4, 2026
Merged

jerryshell merged 3 commits into
mainfrom
feat/test-maturity

Conversation

@jerryshell

@jerryshell jerryshell commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

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-codeowners failed on every file under game/, 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 when args is given.
  • double_script walks 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.
  • CODEOWNERS covers /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 test runs 17 game tests green; bin/gai check green; pre-commit passes over every touched file, including validate-codeowners on game/.

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`.
@jerryshell
jerryshell merged commit fcaa8b6 into main Nov 4, 2026
20 checks passed
@jerryshell
jerryshell deleted the feat/test-maturity branch November 4, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant