Skip to content

A package install, a prose-looking test fixture or a Codex shell call under another name does not let a session end untested - #1709

Merged
zlareb1 merged 3 commits into
mainfrom
fix/test-gate-run-detection-gaps
Nov 28, 2026
Merged

zlareb1 merged 3 commits into
mainfrom
fix/test-gate-run-detection-gaps

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Related: #1696

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

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 no longer takes a package install, removal or update (npm install --save-dev jest, pip install -U pytest, yarn remove jest) or an excluded task (gradle build -x test) for a test run, and it counts make testall, npm run testci and Gradle tasks such as integrationTest as runs. A changed .txt file is code unless it is a changelog, README or licence file or lies under docs/, so a requirements file or a test fixture written after the last run holds the stop, and a Codex session that changed files through shell_command or container.exec is held like any other.

Why

The default test gate holds the end of a session only when the session ran no test since its last code change (#1696). It reads three things for that: which shell commands start a test runner (RUNNER), which changed files are code (isProse), and which files the session changed (sessionScope). A review of #1696 after it merged listed inputs each reading gets wrong. I ran every one through the gate's functions on main before editing.

Failing cases (testedSince, lastCodeChange and sessionScope on main):

Input main Should be Effect on main
npm install @playwright/test, npm install -D node-test, npm install --save-dev jest, yarn add -D jest, pnpm add -D vitest, pip install -U pytest, pip install 'pytest>=8', uv add --dev pytest, npm i -D @types/jest a test run not a run a session that installed a package and ran nothing ends unheld
npm rm jest, yarn remove jest, pnpm remove vitest, npm update jest, yarn upgrade jest, poetry update pytest, pip download pytest, composer require --dev phpunit/phpunit, pip install \ with pytest on the next line a test run not a run the same
gradle build -x test, mvn package -Dmaven.test.skip=true a test run not a run the same
make testacc, make testall, npm run testci, ./gradlew integrationTest, gradle connectedAndroidTest not a run a test run a session that ran its tests is held once
requirements/dev.txt, constraints.txt, tests/fixtures/expected.txt, testdata/golden.txt written after the last run prose, left out code the stop passes on a run that never saw the file
guide.markdown, manual.asciidoc written after the last run code prose a note holds the stop
A Codex rollout that changes src/b.py with a function call named shell_command or container.exec no file in scope src/b.py in scope that session is never held, in either mode

Pattern. Each rule reads one neighbouring word or one name where the fact lies elsewhere.

  • An install is recognised only when install is the word right before the runner's name, and never in the build-tool branch. A flag, a scope or another verb between them gets through.
  • The lookahead (?![a-z]) stood in for the missing verb: it rejects go get …/testify and npm install @testing-library/react by the letters after test, and with them every target whose name goes on after test.
  • .txt is prose by extension, with a two-name exception list for the .txt files that are code.
  • The scope and the run check each carry their own list of the names of the Codex shell tool, and the lists differ.
  • Gradle's camel-case task names and its exclusion flag are not read.

Hypothesis. Read the fact where it lies.

  • A runner's name or a test argument that follows install, uninstall, add, i, ci, get, remove, rm, update, upgrade, download or require in the same simple command is a package, in every branch of RUNNER. The verb is a word after whitespace, so sed -i, npx --no-install jest, docker run --rm app pytest and git config --get hold none. A backslash at a line's end is removed before the command is read, as the shell removes it.
  • With the verb read, the lookahead stays where test is part of a path or a package (./internal/testutil, //pkg:testlib, -p testcontainers) and is lifted only for make, npm, pnpm, yarn, bun and rake, which run a target or a script by its name, where test starts a word.
  • For gradle and gradlew, a task that ends in Test after a lower-case letter is a run. The word after -x is not, and neither is test.skip.
  • A .txt file is code unless it is named as a changelog, README, LICENSE, NOTICE or AUTHORS file, or lies under a docs or doc directory with no requirements or constraints in its path below it. .markdown and .asciidoc join PROSE.
  • sessionScope uses rolloutShell, the function the run check uses, plus apply_patch.

Predicted before running: every input of the table flips, the tests added for them fail on main's library and pass on this branch's, and the replay of the 29 recorded sessions does not move, because none of their 95 shell commands holds one of the verbs before a runner, a Gradle task or a .txt file. All three held; the numbers are under Tests.

What the second commit takes back. The first commit of this pull request widened three of these readings past the table, and a review of it found the inputs. On that commit, and not on main:

Input First commit Now, as on main
go vet ./internal/testutil/..., go build ./cmd/testserver, go generate ./testdata/..., bazel build //testing/..., bazel build //pkg:testlib, node scripts/testbed.js, cargo build -p testcontainers a test run not a run
./gradlew compileTestJava, ./gradlew :app:compileDebugUnitTestKotlin, ./gradlew processTestResources, gradle build -PskipTests, gradle assemble -DskipTests a test run not a run
docs/releases/5.2.txt, CHANGES.txt, CHANGELOG.txt, NEWS.txt, README.txt, LICENSE.txt, doc/guide.txt written after the last run code, the stop is held prose

The lifted lookahead applied to every build tool and to a path as well as to a target; the Gradle rule read Test anywhere in a task; every .txt file was code. Each is now bound to the place the table's inputs have in common: a target of a tool that runs targets by name, the end of a task, a .txt file outside the documentation.

The wording fix: a test run between git stash and git stash pop counts only when the three are one command. A pop in a later command rewrites the changed files after the run, so that stop is held. HOOKS.md, the README and the docstring of testedSince say so. The README's runner list names gradlew, which the pattern already held.

Scope and risk

  • Files. lib/test-gate.mjs (the RUNNER pattern, a one-line startsRunner that removes line continuations, isProse, one condition of sessionScope, comments), its test file, the README, HOOKS.md, the docs page, both manifests and the Codex copy of the library. No hook script, no wiring, no server code.
  • LOOM_TEST_GATE=block. RUNNER and isProse are read only in the default mode. sessionScope is shared: with block, a Codex rollout that changes a file through a function call named shell_command or container.exec is now in scope and held, as one through exec, exec_command or shell already is. The hook test shows that stop held in both modes and not held on main's library; the README and HOOKS.md say it. Claude Code sessions are unchanged in that mode: the replay's 29 are byte-identical.
  • The Codex names are not all seen in a rollout. In 1,559 recorded rollouts of Codex 0.136.0 to 0.172.0 the shell tool is exec (193,551 custom_tool_call rows) or exec_command (2,053 function_call rows), and the patch tool is apply_patch; both shell names are in scope on main already. No row is named shell, shell_command, local_shell or container.exec, and none has the type local_shell_call. shell_command and container.exec are the names normalizeToolName folds onto Bash, built by hand in the test. A local_shell_call row, which carries no name, is read by neither function, as on main; the test no longer builds a function call of that name.
  • Where the run check is now wrong, and in which direction.
    • Holds one stop it should not, once per distinct change: a build tool's target that has a verb's name before the run in one simple command (make install test, make ci test, mvn clean install test, make update test), which main counts; a .txt note outside docs/ under another name (notes.txt, TODO.txt), and a document under docs/ whose path holds requirements or constraints (docs/ref/models/constraints.txt); a Gradle task named in the plural (integrationTests), as on main. The first is pinned by the test and listed in the README.
    • Passes where it should hold: a target that only builds and whose name reads as a run (gradlew assembleAndroidTest, make testdata, yarn workspace testbed build), listed in the README; Gradle's long form --exclude-task test; mvn test -Dmaven.test.skip=true, whose first test counts. The last two are as on main.
    • A PowerShell line that ends in a backslash is joined to the next one, which that shell does not do: pip install -t C:\lib\ followed by a line that starts a runner reads as no run.
  • Cost of the pattern. The verb is looked for only after a runner's name matched, back to the start of its simple command: linear in the command for one name. A simple command with a verb and thousands of runner names is quadratic. Measured on this head: a 20 KB pip install line with one runner name, 0.07 ms; a 2 KB line with 300 runner names, 0.20 ms; 200 KB of pytest words after one pip install, 2.0 s, the same as the first commit; 200 KB of testa words after npm install, 2.0 s. Reading a line continuation inside the pattern doubled that worst case, so the continuation is removed from the command first, which costs 2.9 ms on 200 KB of continued lines. No recorded command has that shape, and main's pattern has no such case.
  • Not changed. No new runner.

Compatibility, rollout and rollback

Tests

  • The table's inputs, before and after. A script that calls testedSince, lastCodeChange and sessionScope with every input of the first table as 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's review listed them: on main all 25 answer as its column says, on this head all 25 answer as they should.

  • The reviewed inputs, on three libraries. A second script with 40 commands and 16 files, the ones the review of the first commit named and the neighbours I checked them against, with the answer each should have: main answers 21 of the 56 wrongly, the first commit 29, this head none. The 29 are the inputs of the second table plus the eight verbs and the two continued installs, which main gets wrong too.

  • node --test integrations/claude-code-plugin/tests/test-gate.test.mjs: 48 tests, 47 pass, 1 skipped (Windows only), 0 fail. Every input of both tables is in the test's list of runs or of non-runs, with npm ci && npm test, pip install -e . && pytest, yarn add -D jest; yarn jest, docker run --rm app pytest and make \ continued by test as runs, and make install test, make ci test and mvn clean install test as none. The prose test holds docs/releases/5.2.txt, CHANGES.txt and README.txt as prose and docs/requirements.txt as code. The rollout test asserts the scope for each of five shell tool names and none for another tool; the hook test holds a rollout's shell_command change in the default mode and with block.

  • The same test file on the earlier libraries. On main's: four tests fail (shell_command out of scope, make testacc not a run, notes.markdown taken for code, the rollout's stop not held). On the first commit's: two fail (make \ continued by test not a run, docs/releases/5.2.txt taken for code); the run list stops at its first wrong answer, so the script above is the count.

  • Every recorded shell command. The 95 Bash commands of the 29 recorded sessions through both libraries' testedSince: 46 are runs on main and the same 46 on this head.

  • Replay of the 29 recorded sessions (two recorded benchmark runs of one coding task, the sessions with the plugin installed), with the driver and method of 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 unchanged: each recorded tool call's file changes applied to a fresh checkout, one call after another, with the recorded times, the plugin's own hook scripts started as the client starts them, a local stub for code.test_gate, the Stop gate on the transcript as it stood at the first Stop. main is f863640, whose plugin files equal those of today's main; the branch is this pull request's head, replayed again after the second commit.

    Sessions held at their first Stop main This head
    Default 0 of 29 0 of 29
    LOOM_TEST_GATE=block 6 of 29 6 of 29, the same six, the same messages
    Default, every test run taken out 29 of 29 29 of 29, the same messages

    In all three modes the Stop output and the edit-time lines are byte-identical per session between main and the head, the replayed source file equals the file the run kept in all 29 sessions, no session was replayed twice and no Stop needed a third trial. The replay shows that the change moves no recorded session. It does not exercise the fixed inputs: every recorded session ran pytest under Claude Code, installed nothing, and changed .py files and one .rst file.

  • Gates. ruff format --check ., ruff check, the function-length gate, check_no_secrets.py and every generator's --check (agent_plugin_sync included) pass. Biome's format check passes on integrations/ and Prettier's on the three changed Markdown files. node --check passes on the library, its Codex copy and the test file. claude plugin validate integrations/claude-code-plugin --profile directory --strict passes. The mypy gate reports 5 errors, all in server/llm/vertex_auth.py, from type stubs missing in the local environment; this change holds no Python.

  • Not run locally. No pytest suite. I called the 24 argument-free test functions of tests/unit/test_codex_plugin.py, test_public_copy.py, test_doc_links.py and test_published_links.py directly and none failed; the 4 that take arguments were not called. Of the other plugin test files only hooks-doc.test.mjs was run. Nothing was run under Codex: the survey above read recorded rollouts for their row types and tool names, and the rollout rows of the tests are built by hand.

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 ran each reported input through the functions before and after the edit, ran the changed test file against the three libraries, replayed the recorded sessions in three modes against main, and ran the gates listed above.

  • 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.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

🤖 Generated with Claude Code


Note

Medium Risk
Changes default Stop-hook behavior for which shell commands count as test runs and which file edits matter; Codex rollouts using alternate shell tool names are newly subject to holds.

Overview
Tightens the default Loom test gate so package installs/removals/updates and excluded build tasks no longer count as “ran tests,” while targets like make testall, npm run testci, and Gradle *Test tasks do. Runner detection uses a richer RUNNER regex, startsRunner (line continuations), and ignores verbs like install/add/remove and -x / test.skip shapes.

Prose vs code: .txt is treated as code unless it’s a changelog/README-style name or lives under docs/ (requirements/constraints paths still count as code), with .markdown and .asciidoc counted as prose—so doc-only edits after a run don’t block the stop when real code files would.

Codex: sessionScope follows the same shell-tool naming as run detection (rolloutShell), so edits via shell_command, container.exec, etc. enter the changed-file set and can trigger holds (including LOOM_TEST_GATE=block). A git stash pop after a test command (not in the same command) no longer lets the stop pass.

Docs (README, HOOKS.md, Claude Code integration page) and both plugin manifests are bumped to 1.2.71, with matching logic synced to the Codex plugin copy and expanded test-gate tests.

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

… under another name does not let a session end untested

The stop check of the test gate asks whether a shell command that starts a
test runner finished since the session's last code change. Four of its
readings were wrong.

A package install counted as a test run unless `install` stood right before
the runner's name: `npm install --save-dev jest`, `pip install -U pytest`,
`npm install @playwright/test`, `uv add --dev pytest`. A runner's name or a
`test` argument after `install`, `uninstall`, `add`, `i`, `ci` or `get` in
the same simple command is a package. That verb replaces the lookahead that
rejected `testify` by its suffix and with it `make testall` and `npm run
testci`, which count again.

Gradle's camel-case tasks (`integrationTest`, `connectedAndroidTest`) count
as runs. The task after `-x` and Maven's `test.skip` do not.

A changed `.txt` file is code: a requirements or constraints file or a test
fixture written after the last run holds the stop. `.markdown` and
`.asciidoc` are prose.

A Codex rollout's file change through `shell_command`, `local_shell` or
`container.exec` is the session's change, as one through `exec`,
`exec_command` or `shell` is: the scope reads the names the run check reads.

The docs say that a run between `git stash` and `git stash pop` counts only
when the three are one command.

Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.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 1:36pm UTC
loom-telemetry Ready Ready Preview Nov 28, 2026 1:36pm UTC

Request Review

zlareb1 and others added 2 commits November 28, 2026 18:52
…st` and a docs `.txt` file as what they are

The previous commit of this branch widened three readings of the stop check
past what it meant to fix.

A build tool's argument counted as a test run wherever `test` followed no
letter, so `go vet ./internal/testutil/...`, `bazel build //testing/...` and
`cargo build -p testcontainers` let a session end untested. The lower-case
suffix is read again only for a tool that runs a target or a script by its
name (`make testall`, `npm run testci`), where the name starts a word.

A Gradle task counted wherever `Test` followed a lower-case letter, so
`compileTestJava`, `processTestResources` and `-PskipTests` counted. The
task has to end in `Test`.

Every `.txt` file was code, so a release note written after the run
(`docs/releases/5.2.txt`, `CHANGES.txt`) held a session that had run its
tests. A `.txt` file named as a changelog, README, LICENSE, NOTICE or
AUTHORS file is prose, and so is one under a `docs` or `doc` directory
unless its path there holds `requirements` or `constraints`.

A name after `remove`, `rm`, `update`, `upgrade`, `download` or `require`
is a package too, and a backslash at a line's end joins the next line
before the command is read, so `pip install \` with `pytest` on the next
line is no run and `make \` with `test` on the next line is one.

With `LOOM_TEST_GATE=block` a Codex rollout that changed a file through
`shell_command` or `container.exec` is now held, as in the default mode:
the hook test shows both. Recorded rollouts name the shell tool `exec` and
`exec_command` only, so the test no longer builds a `local_shell` function
call, a shape no rollout holds.

The README lists the two shapes still misread: a build tool's target with a
verb's name hides the run after it (`make install test`), and a target that
only builds counts when its name reads as a run (`gradlew
assembleAndroidTest`).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Brings the branch up to main; no file of this change conflicts.

Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@zlareb1
zlareb1 merged commit 83220cc into main Nov 28, 2026
76 of 81 checks passed
@zlareb1
zlareb1 deleted the fix/test-gate-run-detection-gaps branch November 28, 2026 13:39
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