Repository navigation
The test gate names an edited file's tests when it is edited, and holds the end of a session only when the session ran no test since its last code change - #1696
Merged
Conversation
…en it edits it, and no longer blocks the end of a session by default
The Stop test gate decided from a transcript's shell text whether the
tests it names had run, and blocked the stop when it could not tell. In
two recorded benchmark runs of one task it blocked 8 of 29 sessions with
the plugin installed, and each of the 8 had run the named tests: with a
whole-suite run that had failures, between `git stash` and `git stash
pop`, before a `git checkout` of another file, behind `grep FAILED`, or
beside a quoted `\|` in a grep pattern. A block costs one more model
request and reply. The run after the last round of parsing rules blocked
5 of 15 sessions, against 3 of 14 before it.
The gate no longer reads shell text by default. When a session first
changes a file in an indexed checkout, the tool call that changed it
comes back with one line of additional context naming the command of the
tests `code.test_gate` links to that file:
Loom: tests the index links to src/a.py: .venv/bin/python -m pytest tests/test_a.py
The line is attached once per file per session and costs no model
request. After a Bash or PowerShell command it comes from
`loom-test-gate.mjs`, for each dirty file the command names that was
written since the session began. After Edit, Write or MultiEdit it comes
from `loom-blast-radius.mjs`, the one hook wired for those tools, where
it replaces the radius's own count of tests, so an edit gets one line.
An edited test file names nothing, and neither does a comment-only
change. The stop is not held.
`LOOM_TEST_GATE=block` keeps the blocking gate as it was and prints
nothing at edit time. `LOOM_TEST_GATE=off` turns both off. No parsing
rule became unused: the blocking gate still reads them all.
The Codex plugin wires the same hook after its shell tool. Both plugin
manifests move to 1.2.65.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
… each test once per session The line named only the tests the index links to a changed file, so an index that links a source file to no test said nothing about a change to that file and its test: the blocking gate's ask for such a change is the changed test itself. That is the case in the recorded runs, whose index holds no test-map row. A changed test file with a known runner names its own command, as the blocking gate does. A test is named once per session, so a session that edits a source file and then the test the index links to it gets one line, not two with the same command. A file under a tests directory that no runner takes names nothing. The line reads `Loom tests for <file>: <command>`, which holds for both cases. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…to, and not a test the command itself ran A changed source file the index links to no test got no line, and the stop is no longer held, so a session that changed source and added or ran no test was told nothing. The line now names the changed functions for a file that has no test to run in the checkout: `Loom tests for <file>: the index links no test to <functions>`, worded as the index's view, once per file. A test whose command the call's own command holds is not named: the line arrived on the result of that very run. Only the tests a line printed count as named, so one folded into "(+N more)" is still named when its own file changes. The blast radius leaves its count of tests out only where the line names tests for the edited file, not for another file of the same call. After a shell command, a checkout the shared cache says is not indexed costs no git call: the root is found by its `.git` entry. The docs say that a file is asked about at its first change only, the hook tables name each row's off switch again, and both manifests take 1.2.69. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
9 of 10 tasks
…e and ran no test since The default no longer held any stop, so a session that edited source and ran no test ended unasked: with every test run taken out of the 29 recorded sessions, none was held. The measured fault was narrower: the gate read from shell text which tests ran and how they went, and held sessions that had run them. At Stop the default now runs the blocking gate's steps with one earlier exit: any shell command that starts a test runner and finished no earlier than the oldest write among the session's changed files lets the stop pass, before anything is asked of the server (`testedSince`, `oldestChange`). The command is read for a runner's name only, in a Claude Code transcript or a Codex rollout; its output is not read. A session that ran none is held once per distinct change with the gate's reason. With no transcript the default holds no stop. `LOOM_TEST_GATE=block` keeps the stricter reading and names nothing at edit time. At edit time: - A file the server gave no answer for stays unasked for one more call that names it; it was marked as asked before the request, so one timeout silenced it for the session. - A test is left out of the line only when the call's command runs its whole command in this checkout. A substring match also dropped it for `pytest tests/test_a.py::test_one`, `docker exec app pytest tests/test_a.py` and `echo "pytest tests/test_a.py"`. The malformed-input test starts the gate after a shell command and in both Stop modes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
… since its last code change The default Stop compared the last test run with the oldest write among the session's changed files, so a session that edited one file, ran a test and then edited a second code file was not held. - The run is compared with the newest write among the changed code files (`lastCodeChange`). A file that is documentation or prose by its name (`.md`, `.mdx`, `.rst`, `.adoc`, `.txt` other than `CMakeLists.txt` and a requirements file, or a `CHANGELOG`, `CHANGES`, `HISTORY` or `NEWS` file) is left out, so a note written after the run holds nothing. A deleted file is left out too, as before. - A build tool counts as a test run only when `test` follows no letter in one of its arguments: `npm install x@latest`, `go install y@latest`, `make latest` and `node scripts/attest.js` no longer count, and `make test-unit`, `npm run test`, `node --test`, `go test ./...` and `gradle :app:test` still do. `nextest` is named as a runner, so `cargo nextest run` still counts. - A Codex rollout's shell call is read as its command text. Its `arguments` JSON can hold an argv such as `["go","test","./..."]`, whose words no space joins, so a build tool's run was not seen there. `LOOM_TEST_GATE=block` is unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…rows beside the test gate's The plugin README, HOOKS.md and the Claude Code page take main's rows for the prompt's one process and the detached namespace audit, and this branch's rows for the test gate. Both manifests stay at 1.2.69; main holds 1.2.67. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ae450f1. Configure here.
Merged
8 of 10 tasks
…ecide the default Stop wrongly - A build tool counts as a test run when `test` or `tests` follows no letter and no lower-case letter follows it. `npm install @testing-library/react` and `go get github.com/stretchr/testify` do not count; `make test-unit`, `make unit-tests`, `gradle :app:test` and `gradlew testDebugUnitTest` do. - `testedSince` takes a Codex rollout's shell call under each name `normalizeToolName` folds onto Bash (`shell_command`, `local_shell`, `container.exec`), not only `exec`, `exec_command` and `shell`: a session that ran its tests through one of those was held. - The Claude Code page's paragraph on what the hooks run locally says what the plugin README says of the test gate; a unit test keeps the two equal. - The sender census pins `lib/repo-scope.mjs` of both plugins at its current content. The file gained `cachedUnindexed`, which reads the shared cache and sends nothing; its three reviewed call sites are unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
zlareb1
added a commit
that referenced
this pull request
Nov 30, 2026
* The adoption page passes the format check Wrap the directory refresh condition as the pinned formatter expects. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> * The plugin's code shunt never refuses a compound shell command, and a refusal names the scope it would have shown (#1689) * The plugin's code shunt never refuses a compound shell command, and a refusal names the scope it would have shown A refusal costs the agent a model request and withholds what the call would have printed. The shunt refused a three-part command for one of its parts, a grep for a local variable the index holds no definition of, and its read refusals named an op to call instead of carrying that op's answer. - A Bash command of several parts (a `;`, `&&`, `||` or newline list, or a pipeline) is never refused. Its reads and greps are still counted as passes (`compound_command`), with no lookup and no denial budget spent. A `gh` issue search inside such a command runs. - A refusal is given only with the index's answer in full. A symbol grep is refused when `code.symbol` returns exactly one definition and the caller's lines from modified files fit; a read when `code.outline` returns every declaration of the lines asked for within its budget. Otherwise the call runs (`index_unanswered`). - A read refusal lists those declarations: lines, qualified name, header. `code.outline` is now sent by a hook with a session-derived path, so it joins the session-content class like `code.symbol` and `code.enclosing`, and its reach gains the plugin hook. Both plugin manifests are 1.2.65. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The code shunt refuses a whole-file read with an outline of up to 4,000 tokens The outline behind a read refusal is asked for with a 4,000-token budget. Against a running index of a large C++ repository, the hook's own request for 301 files over 800 lines returned the whole outline of 52 files at 1,500 tokens and of 187 at 4,000, in at most 8,351 characters of declarations; an outline costs a median 2.2 budgeted tokens per file line. A whole file the index did not outline is asked about once per session: the miss is kept beside the denial budgets, so a repeated read of it makes no second lookup. A `gh` issue search followed by `&` is not judged. Inside a command of several parts, a grep that alone would be a symbol lookup is counted as compound_command, as a read is. The tokens_saved of a hit is net of the refusal's own text. Both plugin manifests are 1.2.67. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * The reviewed digest of the code shunt hook matches its source The hook sends the same ops with the same session-derived fields as before: `code.outline` with a path and a larger constant budget, `code.symbol` with a name, `code.outcome` with counts. The pinned digests of both plugins' copies are renewed. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * A refused tail slice lists the declarations of the file's last lines, and a read refusal says which kinds it lists `tail -n N file` carries a length and no start, and the hook read the missing start as line 1: over the read cap, `tail -n 300` of a 900-line file was refused with the declarations of lines 1-300. The hook now counts the slice back from the file's last line, so the refusal names lines 601-900 and lists what is declared there. A budget spend another hook of the session records while this one waits for `code.outline` is kept: the counts file is read again for the write, for the miss record and for the read cap's spend. The refusal's list holds the kinds `code.outline` lists by default. A TypeScript interface, type alias, enum or constant is not among them, so the refusal now says what it lists instead of calling the list the file's declarations. Text only: the 8,400-character refusal is stated as the longest measured, not as a limit of the 4,000-token budget; a whole file whose lookup was not answered is also asked about once per session, which the comments and docs now say; and the docs no longer list a grep over a directory as denied. The hook sends the same ops with the same fields, so its reviewed digest is renewed for both plugins' copies. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * A memory hit that names code says which revision it was made against, when it was written and whether it was checked against this checkout (#1691) * A memory hit that names code says which revision and date it was made against and whether it was checked against this checkout A search hit that names a file and holds no code link read exactly like one whose code is current: `code_state` was empty for both, the commit a linked hit was anchored at was served nowhere, and a hit's date reached only the context pack line. Line numbers written into a memory were served as written whatever its link state. `code_change` now gives each reader the same facts. A hit read from a memory's own row that holds no link and whose text names a file by a path with a directory is `unlinked`. A linked hit carries `code_rev`, the commit its worst link was anchored at. Every line that renders a memory with a code state carries `code_state=<state>`, `rev=<commit>` when it holds a link, and its date where the line shows none: the reader block, loom_search's plain lines, context.pack memory and decision lines, memory.for_file rows and code-answer lessons. A reply that serves an unlinked or changed memory says once that those memories were not checked against the caller's checkout (`code_note` on memory.search and the first line of each rendered block); a reply whose memories are all fresh says nothing. A memory that is not fresh is shown without the line numbers its text gives: the stored value is untouched. A hit that names no code renders byte for byte as before, and `unlinked` moves no hit in the ranking. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> * A parked search page stores no unlinked label, and a read says what Loom compared and serves a memory's text as stored `unlinked` is a value the previous build's hit model refuses, and the tail a search parks was annotated with it: a later page answered by that build during a rolling upgrade dropped every such hit. A page now stores a link state or none, and the page that serves a hit labels it again with the predicate the search uses. No read rewrites a memory's text. The line numbers a memory gives were removed for every state but `fresh`, `unlinked` included, which is the state of every path-naming memory where no repository is indexed, where its link is pending, and where its link is in a repository the caller may not read. Every surface serves the stored text again; the patterns that removed the numbers also took words a sentence needs and ran in more than quadratic time on a long run of spaces. The sentence a reply carries says what was compared instead of naming a checkout no read sees: no comparison is shown for an unlinked memory, and `code_state` and `rev` describe the repository as indexed. It is served for any code state, a fresh one included, one clause per state present. The day printed beside a code state is the write day on every surface, as `written=`: a search hit's `created_at`, a row's `updated_at`. `context.pack` keeps `date=` for the date its text is about. Symbol lessons read `updated_at` and carry `written` too, and a `loom_search` structured hit that names code keeps its `created_at`. `MemorySearchOutput.code_note` is set when the output is built, so the model and its dump agree and a dump that leaves `code_state` out of its hits no longer raises. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> * The day beside a code state is the row's creation day, which an unpin, a lock or a label does not move memory.for_file lines, path and symbol lessons and the startup recall printed `updated_at` as `written=`. Unpin, lock, unlock, restore and label stamp that column without writing the text, so an old claim could read as written yesterday. Those reads now print `created_at`, as a search hit does; the docs say what that day is on each read. - A search whose link read fails still labels a hit that names a file `unlinked`, as its later pages do. - A decision found on several paths carries the anchor commit of the link in its worst state, and a review brief's rationale section says once what its rows' code states were compared with. - `names_file` reads the path pattern alone, and only in a text with a slash. - A block takes the room for the sentence from the row that prints with it, so a row left out no longer keeps that room from the rows after it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> * A read of a memory's row labels its day first_written, and written is the day of a search hit's text A search hit's day is its search document's, which a write of the text and a restore stamp again, while memory.for_file, a lesson and the startup recall read the row's creation day, which no later write moves. Both printed as `written`, so the label had two meanings for a memory whose text was written again. The row reads print `first_written=<day>`, and a lesson carries the field `first_written`; a search hit keeps `written=<day>`. No column and no read is added. A test builds the revision of a row and asserts the day and its label on the memory.for_file line, the lesson and the search hit. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> * The memory.for_file ceiling check charges a decision or constraint the sentence it prints with render_block charges a row that names code what the sentence on what was compared grows by, and the check that decides whether a "… more" line needs room measured a decision or constraint by its line alone. One within that sentence of the ceiling was counted as printed and then left out; the older row it supersedes went with it, and the "… more" line counting that row was added to a block that had reserved no room for it, past token_budget. _ceiling_hides charges each such row as the loop does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> --------- Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The test gate names an edited file's tests when it is edited, and holds the end of a session only when the session ran no test since its last code change (#1696) * The test gate tells the agent which tests constrain an edited file when it edits it, and no longer blocks the end of a session by default The Stop test gate decided from a transcript's shell text whether the tests it names had run, and blocked the stop when it could not tell. In two recorded benchmark runs of one task it blocked 8 of 29 sessions with the plugin installed, and each of the 8 had run the named tests: with a whole-suite run that had failures, between `git stash` and `git stash pop`, before a `git checkout` of another file, behind `grep FAILED`, or beside a quoted `\|` in a grep pattern. A block costs one more model request and reply. The run after the last round of parsing rules blocked 5 of 15 sessions, against 3 of 14 before it. The gate no longer reads shell text by default. When a session first changes a file in an indexed checkout, the tool call that changed it comes back with one line of additional context naming the command of the tests `code.test_gate` links to that file: Loom: tests the index links to src/a.py: .venv/bin/python -m pytest tests/test_a.py The line is attached once per file per session and costs no model request. After a Bash or PowerShell command it comes from `loom-test-gate.mjs`, for each dirty file the command names that was written since the session began. After Edit, Write or MultiEdit it comes from `loom-blast-radius.mjs`, the one hook wired for those tools, where it replaces the radius's own count of tests, so an edit gets one line. An edited test file names nothing, and neither does a comment-only change. The stop is not held. `LOOM_TEST_GATE=block` keeps the blocking gate as it was and prints nothing at edit time. `LOOM_TEST_GATE=off` turns both off. No parsing rule became unused: the blocking gate still reads them all. The Codex plugin wires the same hook after its shell tool. Both plugin manifests move to 1.2.65. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> * The edit-time tests line names a changed test's own command and names each test once per session The line named only the tests the index links to a changed file, so an index that links a source file to no test said nothing about a change to that file and its test: the blocking gate's ask for such a change is the changed test itself. That is the case in the recorded runs, whose index holds no test-map row. A changed test file with a known runner names its own command, as the blocking gate does. A test is named once per session, so a session that edits a source file and then the test the index links to it gets one line, not two with the same command. A file under a tests directory that no runner takes names nothing. The line reads `Loom tests for <file>: <command>`, which holds for both cases. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> * The test gate's docs example names no particular project Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> * The edit-time tests line names the functions the index links no test to, and not a test the command itself ran A changed source file the index links to no test got no line, and the stop is no longer held, so a session that changed source and added or ran no test was told nothing. The line now names the changed functions for a file that has no test to run in the checkout: `Loom tests for <file>: the index links no test to <functions>`, worded as the index's view, once per file. A test whose command the call's own command holds is not named: the line arrived on the result of that very run. Only the tests a line printed count as named, so one folded into "(+N more)" is still named when its own file changes. The blast radius leaves its count of tests out only where the line names tests for the edited file, not for another file of the same call. After a shell command, a checkout the shared cache says is not indexed costs no git call: the root is found by its `.git` entry. The docs say that a file is asked about at its first change only, the hook tables name each row's off switch again, and both manifests take 1.2.69. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> * By default the test gate holds the stop of a session that changed code and ran no test since The default no longer held any stop, so a session that edited source and ran no test ended unasked: with every test run taken out of the 29 recorded sessions, none was held. The measured fault was narrower: the gate read from shell text which tests ran and how they went, and held sessions that had run them. At Stop the default now runs the blocking gate's steps with one earlier exit: any shell command that starts a test runner and finished no earlier than the oldest write among the session's changed files lets the stop pass, before anything is asked of the server (`testedSince`, `oldestChange`). The command is read for a runner's name only, in a Claude Code transcript or a Codex rollout; its output is not read. A session that ran none is held once per distinct change with the gate's reason. With no transcript the default holds no stop. `LOOM_TEST_GATE=block` keeps the stricter reading and names nothing at edit time. At edit time: - A file the server gave no answer for stays unasked for one more call that names it; it was marked as asked before the request, so one timeout silenced it for the session. - A test is left out of the line only when the call's command runs its whole command in this checkout. A substring match also dropped it for `pytest tests/test_a.py::test_one`, `docker exec app pytest tests/test_a.py` and `echo "pytest tests/test_a.py"`. The malformed-input test starts the gate after a shell command and in both Stop modes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> * By default the test gate holds the stop of a session that ran no test since its last code change The default Stop compared the last test run with the oldest write among the session's changed files, so a session that edited one file, ran a test and then edited a second code file was not held. - The run is compared with the newest write among the changed code files (`lastCodeChange`). A file that is documentation or prose by its name (`.md`, `.mdx`, `.rst`, `.adoc`, `.txt` other than `CMakeLists.txt` and a requirements file, or a `CHANGELOG`, `CHANGES`, `HISTORY` or `NEWS` file) is left out, so a note written after the run holds nothing. A deleted file is left out too, as before. - A build tool counts as a test run only when `test` follows no letter in one of its arguments: `npm install x@latest`, `go install y@latest`, `make latest` and `node scripts/attest.js` no longer count, and `make test-unit`, `npm run test`, `node --test`, `go test ./...` and `gradle :app:test` still do. `nextest` is named as a runner, so `cargo nextest run` still counts. - A Codex rollout's shell call is read as its command text. Its `arguments` JSON can hold an argv such as `["go","test","./..."]`, whose words no space joins, so a build tool's run was not seen there. `LOOM_TEST_GATE=block` is unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> * A package install or a Codex shell call under another name does not decide the default Stop wrongly - A build tool counts as a test run when `test` or `tests` follows no letter and no lower-case letter follows it. `npm install @testing-library/react` and `go get github.com/stretchr/testify` do not count; `make test-unit`, `make unit-tests`, `gradle :app:test` and `gradlew testDebugUnitTest` do. - `testedSince` takes a Codex rollout's shell call under each name `normalizeToolName` folds onto Bash (`shell_command`, `local_shell`, `container.exec`), not only `exec`, `exec_command` and `shell`: a session that ran its tests through one of those was held. - The Claude Code page's paragraph on what the hooks run locally says what the plugin README says of the test gate; a unit test keeps the two equal. - The sender census pins `lib/repo-scope.mjs` of both plugins at its current content. The file gained `cachedUnindexed`, which reads the shared cache and sends nothing; its three reviewed call sites are unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> --------- Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> * The grep budget and CI snapshots match their inputs Derive the grep header budget from the fixed excerpt size. Refresh the reviewed SDK sender fingerprint after the response parser change and regenerate the memory.for_file statement shape for its creation timestamp. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> --------- Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
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.

Changelog category (leave one):
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 Claude Code and Codex plugins' test gate names a changed file's tests, or the changed functions the index links no test to, on the tool call that first changes the file, as one line of context that costs no model request. At the end of a session it holds the stop only when the session ran no test since its last code change; any test run since then lets the stop pass. Set
LOOM_TEST_GATE=blockto keep the gate that passes only on a run of the named tests.Why
The Stop test gate blocked sessions that had run the tests it named.
git stashandgit stash pop, agit checkoutof another file after the run, the summary line hidden behindgrep FAILED, and a\|inside a quoted grep pattern in the same command.It names the tests when the file changes. The first tool call that changes a file in an indexed checkout comes back with one line:
A file with no test to name gets the functions it changed instead:
Loom tests for src/app/router.py: the index links no test to Router::match.At Stop it asks one question of the transcript that needs no reading of a run: did a shell command that starts a test runner finish since the session's last code change? If one did, the stop passes and nothing is asked of the server. If none did, the stop is held once per distinct change with the reason
maingives. Which tests ran and how they went stays the agent's judgement and CI's.The default changes. A session that ran some test after its last code change is no longer held, whatever the test was and however it went. A session that changed code and ran no test since is still held, as on
main. A team that wants a stop to pass only on a run of the named tests on the final tree setsLOOM_TEST_GATE=block, which keeps the blocking gate exactly as it is onmainand prints nothing at edit time.Scope and risk
main's steps (the session's changed files from the transcript, the index lookup, the diff, once per distinct change,code.test_gate, the reason) with one earlier exit:testedSince. The stop passes when the transcript holds a Bash or PowerShell call, or a Codex rollout shell call, whose command starts a test runner and whose result row is dated no earlier than the newest modification time among the session's changed code files (lastCodeChange). So a stop is held when a changed code file was written after the last such command finished, or when there was none..md,.mdx,.rst,.adoc,.txtother thanCMakeLists.txtand a requirements file, or a file namedCHANGELOG,CHANGES,HISTORYorNEWS. A note or a changelog entry written after the run holds nothing. A deleted file has no time and is left out too.pytest,py.test,unittest,tox,nox,jest,vitest,mocha,nextest,rspec,phpunit,ctestorclickhouse-testas a word, orgo,cargo,npm,pnpm,yarn,bun,deno,make,mvn,gradle,gradlew,dotnet,swift,bazel,mix,rakeornodewith a later argument of the same simple command in whichtestortestsfollows no letter and no lower-case letter follows it (make test-unit,make unit-tests,npm run test,node --test,go test ./...,gradle :app:test,gradlew testDebugUnitTest).import pytest,pip install pytest,pytest.raises,npm install x@latest,npm install @testing-library/react,go get github.com/stretchr/testify,go install y@latest,make latestandnode scripts/attest.jsdo not count. A Codex rollout's shell call counts under each name the plugin folds onto its shell tool (exec,exec_command,shell,shell_command,local_shell,container.exec). The command's output is not read.grep -rn pytest .,npm install -D vitest,npm install @vue/test-utils), a run in a container, a run of unrelated tests, a failed run, a file deleted after the run, and a code file whose name reads as prose (expected.txt) written after the run. It holds one stop it should not, once per distinct change: for a harness the list does not name (a deployment's own script,make check,make testall), asmaindoes for every runner but pytest, and for a code file written after the last run with no change a test could see (a formatter, a comment added to a file that already holds a code change, agit stash popin a later command than the run).main. No transcript path: nothing shows that the session ran no test, so the default holds no stop (mainandblocktake the whole dirty tree as the change).PostToolUseadditional context on the call that changed the file: a dirty path that the call's edit tool targeted or its shell command named, written since the session began. That is the rule the Stop gate applies to the whole transcript (sessionScope,writtenSince), applied to one call.code.test_gatelinks to it that the checkout has; for a test file, the file's own command. A test is named once per session, so a session that edits a source file and then its test gets one line. Only the tests a line printed count as named: one folded into(+N more)is still named when its own file changes.;,|,&,)or the end, and before it stand only what launches it (runsHere, which reuses the Stop gate'sranHere).pytest tests/test_a.py::test_one,docker exec app pytest tests/test_a.pyandecho "pytest tests/test_a.py"therefore still get the line.the index links no test to <functions>, worded as the index's view.Edit,WriteandMultiEdit. It stays the only hook wired for those tools and carries the gate's line beside its own, and leaves its test count out where that line names tests for the edited file. AfterBashandPowerShell, where no hook printed anything,loom-test-gate.mjsprints the line.tests/hooks-json.test.mjsasserts that no tool starts both.loom-test-gate.mjs PostToolUseruns besideloom-record.mjs. A call that names no dirty file it has not asked about costs onegit diff --name-onlyand no request. In a checkout the shared cache already says is not indexed it exits before any git call. What it costs is under Hook time below.code.test_gateis asked once per changed file at edit time, and at Stop only when the session ran no test since its last code change. Onmainit is asked at the Stop of every session that changed files in an indexed checkout.code.test_gate,code.impact, the server, the blocking gate's rules and its reason text. No parsing rule became unused, becauseLOOM_TEST_GATE=blockreads them all.argumentswhether they hold one string, a shell wrapper's script or an argv such as["go","test","./..."];tests/test-gate.test.mjscovers those shapes. I have not run it under Codex.Compatibility, rollout and rollback
LOOM_TEST_GATEunset, the tests are named at edit time, and a stop passes on any test run since the session's last code change.LOOM_TEST_GATE=blockismain's behaviour.LOOM_TEST_GATE=offturns the gate off, as before. Any other on-word (on,1,true) means the default.LOOM_TEST_GATE=blockin the environment the client starts in.mainholds 1.2.68. At this push the other open pull requests that touch the manifest hold 1.2.70 (The test gate touches only the edited definitions and labels every test with its evidence #1707), 1.2.55 (Loom traces record invocation origin, outcome and benchmark context #1112), 1.2.47 (Automatic hooks retain bound session privacy #948) and 1.2.46 (Claude Code plugin hooks use the configured complete MCP endpoint #770); none holds 1.2.69.main's gate. The per-session state fileloom-testadvice-*in the temp directory is left behind and unread.Tests
Replay of the 29 recorded sessions through the plugin's own hook scripts, started as the client starts them (one
node <script> <event>per hook thathooks/hooks.jsonwires for the tool, the payload on stdin). All four replays below were run on an earlier commit of this branch, which holds themainit merged; themaincolumn is thatmain. The commits since then mergemainonce more, with no change to the test gate's files, and change the build-tool branch of the runner pattern and the Codex call names, which no recorded session reaches: all 29 ranpytestunder Claude Code.PostToolUsehooks after each call; the Stop gate on the transcript as it stood at the session's first Stop. The server is a local stub that answerscode.test_gateas the recorded index did, as far as the recorded block messages and the run's table counts show it.main's plugin, the replay blocks the same 5 sessions the second run recorded as blocked, with byte-identical messages, and none of the other 10.mainLOOM_TEST_GATE=blockcode.test_gaterequests at edit timecode.test_gaterequests at a Stopgit stashandgit stash pop, which rewrites the changed files. In the other 2 a later call ran the tests. No Stop asks the server anything. The one documentation file a session changed (CHANGES.rst, in one session) was restored before its Stop, so the rule that leaves prose out decided no session here. The edit-time lines are the ones the push before this one reported:Loom tests for src/flask/blueprints.py: the index links no test to Blueprint::__init__(86 bytes) in 28 sessions, the test commands in the one session whose change the graph links to tests, and the test file's own command (83 bytes) in 7.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.(224 bytes), one with the four test files its change reaches (375 bytes).mainin all 29 sessions: the same 6 held with the same messages, and nothing printed at edit time.mainblocks 6, not 8, because the first run was recorded on an older gate:mainalready lets two of its three blocked sessions stop.blockreplay repeated one session and took one Stop on two trials of three; themainreplay repeated two sessions and took four Stops on two trials of three.Hook time, measured on the push before this one; this push adds no process and no git call. The new process runs after every shell command, so its cost is per shell call. Both tables alternate between
main's plugin and this branch's against a stub server, in a checkout with a two-file change whose files the session has already been told about.Wall time of one hook pass as the client runs it: every hook
hooks/hooks.jsonwires for the event started at once, timed until the last one exits; median of 41 rounds and the median of the paired differences. The machine was shared and not idle (load average 38 to 54), butnode -e 0took 55 to 57 ms of wall time against 50 ms of CPU, so this sample is close to an unloaded one.maincode.test_gaterequest)Two earlier samples of the same measurement, taken while
node -e 0took 77 to 373 ms, gave +91 to +165 ms after a shell command in an indexed checkout, +22 to +42 ms in one that is not indexed, and -109 to -351 ms at that Stop: under load the difference grows with the time a Node start takes.CPU time (user plus system, child processes included, from
/usr/bin/time -p, 10 ms resolution, each hook started alone, 21 rounds):mainmainwould not have blocked pays about 40 ms at every shell call and saves 77 ms once, at its Stop, so from its third shell call on it is slower than onmain. A checkout with no index pays about 10 ms of wall time and 70 ms of CPU per shell call for nothing.Plugin tests,
node --teston the files this push touches and the ones the merge ofmaintouched beside them, one file at a time:tests/test-gate.test.mjs(48 tests: 47 pass, 1 skipped, Windows only),code-hooks-failopen.test.mjs(15),hooks-json.test.mjs(6),hooks-doc.test.mjs(2): 0 fail. On its first run, with the machine at a load average of 85,tests/test-gate.test.mjsfailed two hook cases whose Stop came back empty, one of them aLOOM_TEST_GATE=blockcase this push does not touch: a hook's bounded git call timed out and the hook let the stop through, as it is built to. The file passed on each of the six runs after that, the last one on this head. The cases this push adds or changes:lastCodeChange: the newest write among the code files;README.md,notes.txt,guide.rstandCHANGELOGare left out,CMakeLists.txtanddev-requirements.txtare not, and a deleted file is skipped.testedSince:go test ./...,npm run test,node --test,gradle :app:test,./gradlew testDebugUnitTest,make unit-testsandcargo nextest runcount;npm install x@latest,go install y@latest,make latest,node scripts/attest.js,npm install @testing-library/reactandgo get github.com/stretchr/testifydo not. A Codex rollout's call counts when itsargumentshold["go","test","./..."],["npm","test"],["bash","-lc","make test-unit"],{"cmd":"npm run test"}or a plain string, and not for["npm","install","x@latest"]; it counts under each of the six shell tool names, and anapply_patchcall that names a runner does not.From the push before this one:
testedSince: a run that failed, was piped, ran other tests, ran betweengit stashandgit stash popor under PowerShell counts; a command that reads or writes a test or installs a runner does not; a run that finished before the change does not; a sidechain's run and a row of another type that copies the call do not; a Codex rollout's shell call counts by its output row's time.LOOM_TEST_GATE=blockcases are unchanged.sed … && pytest tests/test_g.py::test_g,docker exec app pytest tests/test_h.pyandecho "pytest tests/test_i.py", and still left out afterpython -m pytest tests/test_e.py -q.LOOM_TEST_GATE=blockand after a shell command, and prints nothing in each.main.From the earlier pushes: the mode switch; the line's wording, its cap and the cases that name nothing; the functions named for a file with no test; which tests a capped line printed; the hooks end to end; the shared cache's "not indexed" answer found without git.
Gates on this head:
ruff format --check,ruff checkandagent_plugin_sync.py --checkpass;node --checkon every hook and helper of both plugins; Biome and Prettier report no change on the files this pull request changes. Two unit tests that failed in CI on the earlier heads pass when called directly:test_plugin_readme_and_docs_page_name_the_same_local_commands(the page's paragraph now says what the README says of the test gate) andtest_shipped_automatic_senders_have_an_admission_class_or_reviewed_exception(the census pinslib/repo-scope.mjsof both plugins at its content withcachedUnindexed, which sends nothing). CI's format job fails ondocs/pages/adoption.astro, and its unit job onserver/code/domain/definition_header.py::DOCSTRING_MAX_LINESintest_no_new_tunable_constant: two files this pull request does not change, andmainfails on both. This push changes no Python, so the other generator checks, the function-length gate, the mypy gate andclaude plugin validatewere last run on the push before it.Not run: the Python unit suite (CI runs it; on the push before this one I called the bodies of
tests/unit/test_codex_plugin.py,test_agent_plugin.py,test_public_copy.pyand, for the two changed pages it covers,test_doc_links.pydirectly, and they passed; not again on this head), the integration suite, the plugin's othernode --testfiles, a live session with either client, a live server, and a paid benchmark. Whether a model runs the named tests more or less often than it did when blocked is not measured, and neither is what a model does with the line that names functions.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. I read the recorded transcripts and both runs' analyses, checked the replay against the recorded blocks, and ran the tests and gates listed above.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.mdand thedocs/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).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code
Note
Medium Risk
Changes default session-end gating and adds per-shell-hook work; teams relying on strict “named tests must pass” behavior must set
LOOM_TEST_GATE=block.Overview
Test gate behavior is reworked in the Claude Code and Codex plugins (v 1.2.69).
By default (
LOOM_TEST_GATEunset), the gate names linked tests when a file changes: after Bash/PowerShell via newPostToolUsewiring, and on the first edit of a file vialoom-blast-radius(one combined line; blast radius drops duplicate test counts when the gate names commands).LOOM_TEST_GATE=blockkeeps edit-time silence andmain’s Stop rules (pytest transcript parsing viarunAnswered);offdisables both.At Stop, the default no longer blocks sessions that ran any recognized test runner since the last code file change (
testedSince/lastCodeChange, output not parsed). Sessions with no such run still get a one-time block withcode.test_gateobligations. Prose/doc paths are excluded from the “last code change” clock.Shared helpers add
gateMode,adviceFiles/adviceLines,cachedUnindexed(skip git on known non-indexed checkouts), and expanded tests/docs (README,HOOKS.md,claude-code.md).Reviewed by Cursor Bugbot for commit b90d636. Bugbot is set up for automated code reviews on this repo. Configure here.