Skip to content

The Stop test gate takes a failed pytest run, or the last run of a command, as an answer and words untested functions as the index's view - #1675

Merged
zlareb1 merged 3 commits into
mainfrom
fix/test-gate-counts-a-covering-run
Nov 28, 2026
Merged

zlareb1 merged 3 commits into
mainfrom
fix/test-gate-counts-a-covering-run

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

The Stop test gate of the Claude Code plugin no longer blocks a session that ran pytest over the named tests after its last change and read failures in the result. Beside tests to run, its reason lists a function with no linked test as the index's view (the index links no test to: …), not as a fact about those tests.

Why

In 14 recorded coding sessions with the plugin, on one issue of one repository whose suite fails 8 tests with or without the change, the gate blocked 3. Each of the 3 had run python -m pytest tests -q on the changed tree, read 8 failed, 467 passed, 10 skipped, shown that the same 8 tests fail without the change and said so in its reply. The gate then told each to run the one test file the change obliges, which that suite run had covered. Each block cost one more model request that ran the file (60 passed) and one more reply: 4.7 to 5.7 seconds and 173 to 222 output tokens per blocked session. The 11 sessions that ran the one file alone were not blocked.

Three rules caused it:

  • allPassed took only a summary line that starts at N passed. A run with a failure answered nothing, although the session had read the failures and the gate's ask is "run the tests, or say why not".
  • onlyRuns was applied from a command's first pytest. Two of the three sessions ran git stash -q; python -m pytest tests -q | tail; git stash pop -q; python -m pytest tests -q | tail: the last run tested the tree as it stands, and the git stash pop between the runs discarded the whole command.
  • The reason listed the constructor of the edited class under no test reaches, beside the test file to run. Every test of that file builds the object. The index's graph held no edge from a test to the constructor, and counts_floor already says the graph is a floor. Two of the three replies told the user the claim was wrong.

The change:

  • A summary line that counts tests failed or passed and none deselected answers (WHOLE), when the run reached its end:
    • A line that counts a failure or an error does not answer when a pytest in the command has --exitfirst, --maxfail or a short flag holding x. Two of the recorded sessions first ran pytest tests -q -x, which stopped 39 tests in, before the named file.
    • No output answers that holds the line pytest prints above the summary of a run it ended early (stopping after 1 failures, Interrupted: …). That line also shows a failure limit or --sw set in PYTEST_ADDOPTS or a configuration file, which the command's flags do not.
    • A command with --continue-on-collection-errors does not answer: a named file that failed to import is one error among the tests that ran (1 failed, 2 passed, 1 error).
    • A collection that stopped at an error (1 error in 0.12s) counts no test and does not answer.
  • A command's runs count from the first pytest after which it runs only pytest, tail, head, grep and echo. What stands before that run forgets every earlier run, as a command's lead did before.
  • renderGate still names every untested function. Beside tests to run that the checkout has, it words them the index links no test to: X (the tests named here may still reach it). With no such test the reason reads no test reaches: X and asks for a test, as on main.

The three behaviours are one pull request because they are the one recorded block: the first two decide that the three sessions are not blocked, and the third corrects the sentence the same three sessions were shown and two of them disputed. The wording change is one branch in renderGate; it changes no block decision.

Alternatives not taken:

  • Dropping the untested functions from a reason that names tests. A change to a tested function and an untested one would then be told only to run the tests, and nothing would report the untested one. The recorded defect was the sentence stated as a fact, not the name.
  • Reading git stash … git stash pop as a round trip that leaves the tree unchanged. The third recorded session ran pytest tests | grep FAILED; git stash -q; pytest tests | tail -1; git stash pop -q. Its run on the changed tree printed no summary line, and the pop rewrote the files after the last run. Accepting it needs the gate to trust that a pop restores the tree and to accept a run with no summary. That session still blocks, with the reworded reason.

Scope and risk

  • Touches lib/test-gate.mjs (the Codex copy is regenerated), its tests, two paragraphs of the plugin README, one row of docs/features/integrations/claude-code.md and both plugin manifests (1.2.63). The hook file hooks/loom-test-gate.mjs, hooks/HOOKS.md and the README's hook table are unchanged: the reason names the tests and the untested functions, as they say.
  • The gate is silent in more cases: a session whose named tests failed in a full run it has read stops without the block.
  • A run that pytest ended early under a limit set outside the command still answers when the command cut pytest's line from the output (| tail -1); the README says so. --ignore or --lf set in a configuration file were not seen before and are not seen now.
  • The reason is 11 words longer when it names both tests and untested functions.
  • Unchanged: the block for a change with no run after its last change, a run of another file or a subset, a run in another directory or on another machine, a command that changes the tree after its last pytest, a missing test, a test of another runner, and every Codex stop.
  • The hook stays fail-open and makes the same single code.test_gate request.

Compatibility, rollout and rollback

  • Wire: none. No op or field is added, changed or removed.
  • Operator steps: none. Clients get the change with plugin 1.2.63.
  • Rollback: reverting restores the earlier rules; nothing is stored.

Tests

Run locally:

  • node --test integrations/claude-code-plugin/tests/test-gate.test.mjs: 39 tests, 38 pass, 1 skipped (Windows only). The new cases are a suite that fails 8 tests with or without the change, a run that stopped at its first failure, the same with the limit in PYTEST_ADDOPTS, a --sw stop, and --continue-on-collection-errors.
  • node --test on hooks-doc.test.mjs, hooks-json.test.mjs, code-hooks-failopen.test.mjs and path-under.test.mjs: 25 tests, 23 pass, 2 skipped.
  • The test file of main, with every assertion recorded instead of thrown, against both versions of the lib: 242 checks. Against main's lib 0 differ. Against this branch 4 differ, all intended: the two failed-summary cases (answered([edit(), bash(SUITE, FAILED)]) and the same after a passed run) flip from blocked to answered, and two render cases that name tests read the index links no test to: … where they read no test reaches: ….
  • Output that pytest 9.1.1 printed on a three-file scratch project, through runAnswered:
Command, and the last line of its output main This branch
python -m pytest tests -q | tail -3, 1 failed, 2 passed in 0.02s asks answers
PYTEST_ADDOPTS=-x python -m pytest tests -q | tail -3, stopping after 1 failures above 1 failed, 2 passed in 0.02s asks asks
python -m pytest tests -q | tail -3 with --sw set outside the command, Interrupted: Test failed, continuing from this test next run. above 1 failed in 0.06s asks asks
python -m pytest tests -q --continue-on-collection-errors | tail -3, 1 failed, 2 passed, 1 error in 0.02s asks asks
  • Offline replay of the 14 recorded sessions through the hook process. Each replay is a scratch git checkout holding the two changed paths, the recorded transcript cut at its first stop with its paths moved to the scratch checkout, file times set to the latest moment the record allows for the session's last write, and a local stub that answers code.test_gate with the response the recorded reason implies. The replay script and the transcripts are not in the repository.
Replay main This branch
11 sessions that ran the named file alone no block (as recorded) no block
2 sessions: git stash; pytest tests; git stash pop; pytest tests, 8 failed, 467 passed block, reason byte-identical to the recorded one no block
1 session: pytest tests | grep FAILED; git stash; pytest tests; git stash pop block, reason byte-identical to the recorded one block, reworded reason
A blocked record cut after its two edits, before any run block block, reworded reason
Two blocked records cut after pytest tests -q -x stopped at the first failure block block, reworded reason
A blocked record cut after <edit>; pytest tests | tail -3; git diff --stat block block, reworded reason

The reworded reason, in each of those rows: Loom test gate (graph is a floor): run: python3 -m pytest tests/test_blueprints.py · the index links no test to: Blueprint::__init__ (the tests named here may still reach it). Run the tests before finishing, or say why not.

  • Gates: ruff format --check ., ruff check, the function-length and secret gates, every generator --check in make lint including agent_plugin_sync.py --check, biome format on both plugin directories, prettier --check on the three changed Markdown files, node --check on every hooks/ and lib/ file of both plugins, and claude plugin validate integrations/claude-code-plugin --profile directory --strict pass. The mypy gate reports 5 errors, all in server/llm/vertex_auth.py, from missing type stubs of an optional dependency in the local environment; this diff changes no Python.
  • The test functions of tests/unit/test_public_copy.py (5) and tests/unit/test_codex_plugin.py (16) that take no fixture were called directly and pass.

Not run locally: the pytest unit and integration suites, the rest of the plugin's node tests, and a live session. No session has run with the changed gate; the replay shows the hook's decision on recorded transcripts, not the seconds or tokens a live session saves.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Checked by hand: the three blocked transcripts and the eleven unblocked ones, the replay results above against the recorded outcomes, and each rule against the recorded commands.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code


Note

Medium Risk
Changes Stop-hook blocking logic for indexed repos—more sessions skip the gate, but mis-parsed transcripts could still pass incorrectly; scope is limited to client-side transcript parsing, not server auth or data handling.

Overview
The Stop test gate in the Claude Code and Codex plugins (1.2.63) no longer treats a full pytest run as unanswered just because the summary shows failures—sessions that already ran the obligated tests and saw a complete summary line can finish without an extra block.

Answered-stop detection now accepts a whole pytest summary (failed or passed, no deselected-only subsets), while still rejecting early exits (-x, --maxfail, PYTEST_ADDOPTS, --sw interruption lines) and --continue-on-collection-errors. wholeRuns replaces the old “clean pass only” scan and counts pytest invocations from the first run in a command whose tail is only pytest/tail/head/grep/echo, so patterns like git stash; pytest; stash pop; pytest credit the final run on the current tree.

Gate messaging beside named tests reframes untested symbols as the index links no test to: … (the tests named here may still reach it) instead of stating no test reaches as fact about those tests; the stricter phrase remains when no tests are listed.

Docs (claude-code.md, plugin README) and test-gate.test.mjs align with the new rules; Codex lib/test-gate.mjs mirrors Claude Code.

Reviewed by Cursor Bugbot for commit 99f4185. Bugbot is set up for automated code reviews on this repo. Configure here.

…mes no untested function beside tests the checkout has

The gate blocked a stop whose transcript showed pytest over the named
test after the last change whenever that run's summary counted a
failure. In a checkout where some tests fail with or without the change,
a session that ran the whole suite, read the failures and reported them
was told to run one file of that suite again: one more model request and
one more reply. The reason also said "no test reaches" a constructor
that every test of the named file calls by building the object, because
the index's graph held no edge to it.

A summary line that counts tests failed or passed and none deselected
answers. A line that counts a failure or an error does not when the run
has -x, --exitfirst or --maxfail, since it stopped before the files
after it, and a collection that stopped at an error does not.

A command's runs count from the first pytest after which it only runs
pytest and prints output, so the second run of `git stash; pytest tests;
git stash pop; pytest tests` answers. A command that changes the tree
after its last pytest answers nothing, as before.

A reason that names tests, each of them in the checkout, names no
untested function. The functions are named when the gate names no test,
or one the checkout lacks.

Both plugin manifests move to 1.2.63.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
@vercel

vercel Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 28, 2026 2:41am UTC
loom-telemetry Ready Ready Preview Nov 28, 2026 2:41am UTC

Request Review

…the tests to run, and refuses a run pytest ended early

A reason that named a test the checkout has dropped every untested
function, so a change to a tested function and an untested one was
told only to run the tests. The functions are named again. Beside
tests to run they read as the index's view, "the index links no test
to: X (the tests named here may still reach it)": the graph is a
floor, and a test that builds an object reaches a constructor the
graph holds no edge to. With no test to run the reason reads "no test
reaches: X" and asks for a test, as before.

A failed run answers the gate only when it ran to its end:

- Output that holds the line pytest prints above the summary of a run
  it ended early ("stopping after N failures", "Interrupted: ...")
  does not answer. That line shows a failure limit or --sw set in
  PYTEST_ADDOPTS or a configuration file, which the command's flags
  do not.
- A command with --continue-on-collection-errors does not answer: a
  named file that failed to import is one error among the tests that
  ran.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
@zlareb1 zlareb1 changed the title The Stop test gate takes a pytest run that failed as an answer and names no untested function beside tests the checkout has The Stop test gate takes a failed pytest run, or the last run of a command, as an answer and words untested functions as the index's view Nov 28, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…a-covering-run

Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@zlareb1
zlareb1 merged commit e0c7bef into main Nov 28, 2026
78 of 81 checks passed
@zlareb1
zlareb1 deleted the fix/test-gate-counts-a-covering-run branch November 28, 2026 02:44

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 99f4185. Configure here.

return (
!all.some((l) => ENDED.test(l)) &&
lines.length >= runs.length &&
lines.every((l) => WHOLE.test(l) && !(stops && /\d (?:failed|error)/.test(l)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stop check treats reportchars as exitfirst

Medium Severity

STOPS treats any short flag that contains x as --exitfirst, so a finished suite that used pytest -rx (or -rfx, -rxX) with failures still does not answer. In pytest, -r takes report chars: -rx only adds xfailed lines to the extra summary, and it does not stop the run. The gate then still blocks after the session already ran the named tests and read the failures.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 99f4185. Configure here.

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