Repository navigation
The plugin notes the cost of a pytest run that follows other commands in its shell call, and of a data-driven test file - #2286
Merged
Merged
Conversation
…d a data-driven report, are not noted The cost tests gain the cases the test cost note misses: a run of one test file that follows an inline edit, a git or a sed command in the same shell call, and a result file whose first case names a data file and whose class is under the run's test file. They fail here. Two more hold before and after the change that follows: a command that names a test runner, pytest or || before the run stays no file run, and a result file that an earlier run wrote is not the run's of a later command that printed that run's last line. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… in its shell call, and of a data-driven file A session that edits and then checks in one shell call (an inline script, git diff --stat, sed, then pytest on one file) had its run refused by fileRun, which allowed only cd, export, source and . before the run. And a suite whose cases come from data files names the data file in each testcase, so the report of its whole run was taken for another file's. Neither run reached the session's state, so no row was stored for the files this note is for. fileRun now also takes a run whose text before it names no test runner, no pytest and no ||, with ; or a line's end before the run's own command. ofFile counts a report whose first case names a file that is no Python file when the case's class is under the run file's module. A command before the run can print an earlier run's last line (tail -5 out.txt; pytest <file>), and where its own run outlives the call the report read with it is that earlier run's. The state now keeps the time a hook last read the report, and a report is the command's own only when its run began after that time. The text before the run is read once, backwards from the run, and CD reads only spaces and tabs between a separator and cd: a long run of blank lines cost quadratic time. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…d-run Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…nged files Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…in a quoted argument is no file run Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ument is no file run The rule for a run that follows other commands in its shell call read only the separator before the run. A run that never starts was then kept as one that outlives its call: where the shell ends at a failed command, where the run stands in a group that waits on an earlier command, and where the run is the text of a quoted argument. The text before the run now names nothing that ends the shell, and the run with what follows it closes no parenthesis and no quote it did not open. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e run `set -u -e` and `set -o pipefail -e` before the run end the shell at a failed command as `set -e` does. A `set` with no `-e`, and the word in a script's text, do not. `aged` drops a branch no test takes: every noted command writes the cost state. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…file run `set -u -e` and `set -o pipefail -e` end the shell at a failed command, and the run after them may never start. The flag is read in any word of the `set` command, within 64 characters of it, so a long line is still read in linear time. The limit for a command that starts pytest under no runner's name names the case the rule reaches: the run after it outlives its call. After `;` or a line's end the run always starts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…` list before a run is no refusal Three cases fail here. A command that names no test runner starts the suite and saves its output; the report's hook is not loaded for it. The next command prints the saved last line and starts a run of one file that outlives the call: the suite's report is counted as that file's whole run. `git stash pop -q || true; pytest <file>` is refused, though the run starts whatever the list returned. `git diff --stat &&` at a line's end, a comment line, then the run is taken for a run that always starts. The linear-time case puts each filler after a command that is no set-up, so the text is read as commands that start no run. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
7 of 10 tasks
…l call, and an `||` list before a run is no refusal The cost state kept the time the report's hook last ran, and that hook is loaded only for a command that names a test runner. A recipe that starts the suite under no runner's name left its report unread, with no time noted: a later command that printed the saved last line before a run of one file that outlived the call got the suite's cases and seconds stored as that file's whole run. The launcher notes the time of each shell call the report's hook is not loaded for (`noteCall`), in a session that has the report and hands to memory, so the state holds the return of the session's last shell call (`returned`). `startsNoRun` refused `||` anywhere before the run. What decides whether the run starts is the operator that ends the command before it: `git stash pop -q || true; pytest <file>` always starts the run. The operator is read at the end of the last line before the run that is no comment, with a comment after it aside, so `git diff --stat &&`, a comment line, then the run is no file run, as the shell reads it. Two comment paragraphs in lib/test-cost.mjs are rewrapped. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…d-run Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> # Conflicts: # integrations/claude-code-plugin/.claude-plugin/plugin.json # integrations/codex-plugin/.codex-plugin/plugin.json
… its own, and the session's end removes it The cost tests read the time a session's last shell call returned from a state file of its own (`shell-return`), not from the runs state, and gain four cases. A launcher call that loads no test report writes that file and leaves the runs state unwritten, so it cannot write back runs another agent's hook noted meanwhile. A session with no credential has the file after a shell call and not after its end. A call of another tool writes nothing. A run during which a shell call of another agent returned is not counted, which pins the limit of a time kept for the whole session. They fail here: the time is still in the runs state, which the launcher writes after every shell call and only a session with a credential removes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…the launcher removes at the session's end The launcher wrote that time into the runs state after every shell call. The agents of one session run their hooks side by side, so a launcher's write could put back the state it read, without the run another agent's hook noted meanwhile. And only the script a session with a credential starts at its end removed the state, so a session with none kept it until the day-old sweep. The time is now one state file (`noteReturn` in lib/test-report.mjs) that every shell call's hook writes whole and that `endReport` removes with the result file, in every session. The runs state is written as on main: for a file run, or with a run pending. The launcher takes the rows wired for a call's tool, mode and switches once (`wiredRows`) and reads both the scripts to start and the shell call to note from them, in place of a second copy of the test report's filters. The switch of the cost note (`testCostOn`) is shared by the report's hook and the launcher; each still names the memory plane itself, as every hook script does. The time stays the session's, since the result file is: a run is not counted where a shell call of another agent of the session returns while the run is in its call. The docs and HOOKS.md name that limit, and a test pins it. The Codex plugin has the copy of the changed files. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…perator on a heredoc's opening line joins the run The cost tests no longer read or set a time of the session's last shell call. They state four things the code does not do yet. A run of two paths that is put in the background begins after its call returned. The next command prints its saved last line and starts a run of one file that outlives the call: the report read with it was written 127 s before the hook, and it is stored as a whole run of the file. A command that is the run alone is counted whatever shell call of the session returned while the run was in its call, and however long before the hook its report was written. `fileRun` says which runs those are (`first`). `git apply <<'P' &&`, the patch, `P`, then the run on the next line waits on `git apply`: the operator is on the line that opens the heredoc, and the last line before the run is the heredoc's end. A run after other commands is counted with a report written up to 10 s before the hook. They fail here, 12 of 46: the tests that note two commands in a row also fail, since each has the other's hook between its run's begin and its own hook. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…f its hook, and an operator on a heredoc's opening line joins the run A command before the run can print the last line of an earlier run (`tail -5 out.txt; pytest <file>`), and where its own run outlives the call, the report read with it is that earlier run's. The guard against it compared the begin of the report's run with the return of the session's previous shell call. A run put in the background begins after its own call returned, so its report passed as a later command's: a run of two paths was stored as a whole run of one file. The time was also the session's, so a command that is the run alone was not counted where a shell call of another agent returned during it, which main counts. The bound is now on the report itself. A run that ended in its call writes the report as the call returns, and a stale one was written before the command's own run began. For a run that a command which is no set-up stands before (`first` is false in `fileRun`), the report is the command's only when it was written no more than 10 s before the hook read it (`OWN_REPORT_MS`). A command that is the run alone prints no line but its own and keeps main's rule. No time of a shell call is kept: `noteReturn`, its state file, the launcher's note after every shell call and `testCostOn` are gone, and `hooks/loom-record.mjs`, `hooks/loom-test-report.mjs` and `endReport` are as on main. `startsNoRun` refuses a head in which a line that holds `<<` ends in `&&`, `||`, `&` or a pipe, with or without a comment after it: `git apply <<'P' &&` joins the run after the patch to `git apply`, and the last line before the run is the heredoc's end. Where a heredoc ends is not read, so such a line in an inline script's text is refused too. The Codex plugin has the copy of the changed files. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…file run, and the last of two summary lines is the run's The shell starts no run where the `;` before it is in a comment on the run's line or follows a backslash: `fileRun` gives a run for both, so the two new refusals fail. The other assertions pin what the code already does: the run's own summary is the last one where a command before the run printed an earlier run's, a run after set-up alone counts with a report of any age, and a comment line alone above the run is read as a command that is no set-up. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
`startsNoRun` took `git diff --stat # then; pytest <file>` and `echo done\; pytest <file>` as runs: the split on `;` reads a separator where the shell reads a comment's text or a word. Such a run never starts, shows no summary and was kept as the session's pending run. It is refused now: no backslash stands before the run's `;`, and no `#` that starts a word stands before the run on its line. Quotes are not read, so the line is read up to its first one: a `#` after a quote may be an argument's, as in an edit that inserts a comment (`sed -i '5a\ # note' <file>; pytest <file>`), and a comment that starts there is named among the limits. The pages say what the code does for the bound on a report's age: a comment line above the run is read as a command that is no set-up, and the report of a run after `cd`, `export`, `source` and `.` alone is taken as the command's own, whatever a sourced file printed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…like any other, and each clause of startsNoRun carries its reason `sed -i 's/a/b/' src/parser.py; cd pkg && pytest <file>` is no file run: where `cd` fails the run does not start, and a command before it may have printed a summary. The README read as if `cd`, `export`, `source` and `.` were aside from the join rule anywhere. They are for a run with nothing else before it, and two commands of that shape join the refusal test. The rule of `startsNoRun` stood in one paragraph above three constants. Each clause has its reason beside it, the doc comment of `fileRun` names the function in place of repeating its rule, and the expression for a shell comment is `SHELL_COMMENT`, apart from `COMMENTED`, which reads a repository's files. No behaviour changes. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ame is no file run's head `make install test; pytest <file>`, `make install testall; pytest <file>` and `gradle install test; pytest <file>` are no file runs: the command before the run starts a test runner. `make install; pytest <file>` is one. Fails 1 of 46 here: the three are taken for file runs. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…re a file run, and the pages name what `&`, a pipe and a late report do `make install test; pytest <file>` was a file run: `startsRunner` reads a test target after a target of a verb's name as a package's, so the head passed for commands that start no run. `startsNoRun` refuses a head in which a build tool is followed by a word that starts with `test`, whatever stands before the word. A package of such a name is refused with it (`npm install test-utils; pytest <file>`). A run after `&` or a pipe always starts. It is refused because the command before it runs beside it, and may print and write after it; the comments and the pages gave "the run may not start" as the reason, which holds of `&&` and `||` alone. A command put in the background earlier in the call is not read, and the limits list says so. The limits list also names the report of a pytest that a command before the run started and that ended after the call returned (`./check.sh; pytest <file>`, where the call times out in the script). The run is pending, that pytest began before the call returned too, and the 10 s bound is on a report read with its command: read later, the report is counted as the run's. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…er cannot follow after a command that is no set-up The text before a run may hold a heredoc or a quoted argument, and a `cd` in one is not the shell's. Fails on the head before it: `cat > run.sh <<'E'`, `cd pkg`, `E`, then the run is read as a run in `pkg`, and so is a run after `bash -c 'make build; cd pkg; ls'` and one after `export NOTE="built; cd pkg; ran"`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…rts the command The text before a run may hold a heredoc or a quoted argument, which `fileRun` does not read: a `cd pkg` line under `cat > run.sh <<'E'` was followed as the shell's own, and the run's cost could be noted for `pkg/<file>` where the checkout holds that path too. A `cd` that starts the command is the shell's own. One further on is a move the reader cannot follow, and the run is no file run. A run with only set-up before it reads its `cd` as before. The comment in `startsNoRun` gives the background case with the example the pages use, `./check.sh & sleep 1; pytest <file>`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…lowed cd is not read for a parenthesis Three cases fail: `cd; pytest <file>` and `cd` on a line above the run are read as runs in the session's folder, though the shell ran them in the home folder, by the cost reader and by the test gate; and a run after `cd pkg &&` and an edit whose own text closes a parenthesis is no file run, while the same command without the `cd` is one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
`MOVE` reads `cd`, `pushd` and `popd` before a blank wherever the word stands, as on `main`, and a `cd` straight before `;`, `&`, `|` or `)` only after the text's start or a separator. The word at the end of an argument (`export OUT=/media/cd; pytest <file>`, `ls /media/cd; pytest tests -q`) is no move again, and `cd; pytest <file>` still is one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…he run `first` read as the first run of the command at its one use in `noteCommand`. It is true where nothing but `cd`, `export`, `source` and `.` stands before the run, so it is `afterSetUpOnly`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…d, before the summary pytest writes the report in its session-finish hook and prints the summary after it, so a run that ended in its call wrote the file before it printed the last line, not as the call returned. The comment on `OWN_REPORT_MS`, the hooks page and the feature page say so, and the feature page's limit names what takes the time after the file is written: printing the summary and ending. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
`cd&& pytest tests -q`, `cd|| pytest tests -q` and `(make build; cd); pytest tests -q` answer no gate. Taking `&`, `|` or `)` out of the separators `MOVE` reads after such a `cd` fails the test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…he run does The comment above the two assertions said a comment before the run is no command, and the next one says a comment line alone above the run is read as a command that is no set-up, which is what `onlySetsUp` does. The two assertions check that a comment between a command and the run joins the two in no way, so the comment says that. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
… a line's end `ls /media/cd` and `export OUT=/media/cd` on the line above the run are no move, as the same commands joined to the run by `;` are none. The two tests of `fileRun` and the gate test fail: `MOVE` counts the word before a line's end wherever it stands. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
`MOVE` counted `cd` before any blank wherever the word stood, a line's end included, so `ls /media/cd` on the line above the run held a move with no folder: the run was no file run and did not answer the gate, and the same commands joined by `;` did both. `MOVE` now reads `cd` before a line's end as it reads it before `;`, `&`, `|` and `)`: a move only where it starts a command. Before a space or a tab the word counts as a move wherever it stands, as before, and `pushd` and `popd` are read as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
… a move
`if [ -d pkg ]; then cd` above `fi` and the run, `{ cd` at a line's end,
`builtin cd; pytest <file>` and `command cd` on the line above the run
go to the home folder. `MOVE` reads a `cd` before a separator or a line's
end only after the text's start or a separator, so each is taken for a
run in the session's folder: one test of `fileRun` and the gate test fail.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
`MOVE` read a `cd` before a separator or a line's end only after the
text's start or a separator. A `cd` after a shell keyword or a word the
shell runs it under (`then cd`, `{ cd`, `builtin cd`, `command cd`) goes
to the home folder like any other, and the run under it was taken for
one in the session's folder. `MOVE` now reads the word where no character
but a blank or a separator stands before it. The end of a longer argument
is still none (`ls /media/cd; pytest <file>`).
`startsNoRun` reads the character before the run's command without a
default: it is called only where a separator stands in the text before
the run.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…ytest writes the report when its run ends A run that outlives its shell call is counted with the first report of its file whose run began before the call returned. A run of two paths, a node id or a mark that an earlier call left going began before that too, and is no file run, so it left no state: where its first case is in the file, the pending run is counted with its cases and seconds. `settle` reads this as it does for a command that is the run alone; a run after other commands now reaches it as well. The comment on `settle`, the hooks page, the README and the feature page's limits list say so. "The session's end" is the Claude Code session's in this module and its pages. The four sentences that used it for the end of pytest's run name that end and its hook (`pytest_sessionfinish`). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…file run A command that reads the output an earlier run saved and then puts its own run in the background returns at once: `tail -5 out.txt; pytest <file> > out2.txt 2>&1 &`. Its output shows the earlier run's last line, and the report read with it is that run's, written moments before. `fileRun` takes the line for the command's run, and the report is counted as a whole run of the named file. `./check.sh; pytest <file> &` does the same with the suite of the script. The cases fail here: four command shapes that `fileRun` returns a run for, and two that leave the earlier run's cases and seconds in the session's state. `&>`, `|&` and `&&` after the run put nothing in the background, and a background run after set-up alone stays a file run: those cases pass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
`startsNoRun` lets commands that start no pytest stand before a run, and one of them may print the last line of an earlier run. Where a `&` then puts the command's own run in the background, the call does not wait for it: `tail -5 out.txt; pytest <file> > out2.txt 2>&1 &` returns at once with the earlier run's last line, and a report that run wrote moments before is within `OWN_REPORT_MS`. The cases and seconds of a run of two paths, or of the suite of a script, were stored as a whole run of the named file. `startsNoRun` now refuses a run whose side of the command holds a `&` that is no part of `&&`, `&>`, `>&` or `|&` (`BACKGROUND`). `fileRun` returns nothing for such a command, as before other commands could stand before a run. A background run after set-up alone is a file run as it was: no command before it prints a last line. Six comment paragraphs that broke in the middle of a line are wrapped again, in `lib/test-cost.mjs` and `lib/test-gate.mjs`. The hooks page, the README and the feature page name the new case. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…stem is not the file's pytest builds a case's class from its node id's path with `/` turned into `.`. A case it collects from a data file itself has that file's path as its class: `tests.test_big.cases.yaml` for `tests/test_big/cases.yaml`, and `tests.test_big.yaml` for `tests/test_big.yaml`. Both start with the module of `tests/test_big.py`, so `ofFile` takes the report for one a run of that file wrote. The cases fail here: three such reports read with a whole run of the file, which are counted as that run, and one read while a run of the file is pending, which settles it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…e file's `ofFile` takes a report whose first case names a data file for the run's when the case's class is under the module of the run's file. pytest builds the class from the node id's path with `/` turned into `.`, so a case it collects from a data file itself has that file's path as its class: `tests.test_big.cases.yaml` for `tests/test_big/cases.yaml`. That class is under the module of `tests/test_big.py`, and a suite run whose first case came from such a file settled a pending run of the test file with the suite's cases and seconds. `ofFile` refuses a data file whose path starts with the matched module's path followed by `/` or `.`. A data-driven suite that keeps its data files under a folder named after its test file is not counted; the limits list says so. The limits list and the hooks page also name a run that outlives its call after a command that printed an earlier run's summary line: its output shows a summary, so it is not kept as the pending run. The feature page lists what may stand before a run as one sub-bullet for each refusal, and the passages of both pages that broke in the middle of a line are wrapped again. `tests/unit/session_content_senders.json` pins the bytes of `lib/test-cost.mjs` for its reviewed `memory.get` read. The pin is renewed: `costLine` and `identity`, which build that read, are as on `main`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…ile with the test file's path is not the file's `MOVE` reads `cd` before a line's end only where no character but a blank or a separator stands before it, so `\cd` on the line above a run is no move: the run answers the gate as one in the session's folder, and `fileRun` returns it with no folder. `main` reads `cd` before any blank wherever the word stands. After a command that is no set-up, `fileRun` also returns a run under `"cd";` or `'cd'`, which move to the home folder too. `ofFile` refuses a data file whose path is the test file's, less `.py`, followed by `.` or `/`, and not one whose path is exactly that: a file `tests/test_big` that pytest collects has the class `tests.test_big`. The cases fail here: `\cd` above a run in both readers, the quoted spellings in `fileRun`, and a report whose first case is in `tests/test_big`, read with a whole run of `tests/test_big.py`. `ls /media/cd` and `export OUT=/media/cd` on the line above a run move to the refused lists, where `main` has them, and so does `ls /media/cd;` before a file run, which `main` refuses as a command that is no set-up. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…est file's path is not the file's `MOVE` reads `cd`, `pushd` and `popd` before a blank wherever the word stands, a line's end included, as on `main`: `\cd` on the line above a run is a move again, in the test gate and in `fileRun`. A `cd` straight before `;`, `&`, `|` or `)` is still one where it is a word of its own, and after a backslash too. `ls /media/cd` on the line above a run is a move with no folder again, as on `main`. After a command that is no set-up, `fileRun` refuses a run where the word `cd`, `pushd` or `popd` stands anywhere before it but as the one `cd` that starts the command (`MOVE_WORD`): `"cd"; pytest <file>` moves to the home folder by a spelling `MOVE` does not read. `ls /media/cd; pytest <file>` is no file run either. What stands after set-up alone is read as before. `ofFile` refuses a data file whose path starts with the test file's, less `.py`, whatever follows: `tests/test_big`, which pytest gives the class `tests.test_big`, was taken for a file `tests/test_big.py` read. A data-driven suite whose data files are under `tests/test_big_cases/` is not counted; the limits list says so. `tests/unit/session_content_senders.json` pins the bytes of `lib/test-cost.mjs` for its reviewed `memory.get` read. The pin is renewed: `costLine` and `identity`, which build that read, are as on `main`. 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 default effort and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
❌ 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 e05dc2b. Configure here.
The two tests that hold the clock used the options form of the test runner's mock timers, which Node 18 does not accept, so both failed there. They now replace Date.now, the one clock call the cost module makes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…the file's With a folder `tests/test_big/` beside `tests/test_big.py`, a data-driven test file in the folder gives its cases a class under `tests.test_big` too. The test notes such a report with a run of `tests/test_big.py`, and while that run is pending: it fails, the report is stored as a whole run of the file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
`ofFile` took a data-driven report for the run's where the first case's class is under the module of the run's file. A test file in a folder of that name (`tests/test_big/test_inner.py` beside `tests/test_big.py`) has its classes under the same module, so its report was stored as a whole run of `tests/test_big.py`. No report whose first case names a data file is the run's now where that folder stands beside the test file. A data-driven suite with such a folder is not counted; the limits list says so. `BACKGROUND` no longer reads a `>` before the `&`: `fileRun` takes a redirect between descriptors out before the test, and `onlyRuns` refuses every other `>&`. No result changes. The gate test holds `echo cd; pytest tests -q`, and the `fileRun` docstring is rewrapped. `tests/unit/session_content_senders.json` pins the bytes of `lib/test-cost.mjs` for its reviewed `memory.get` read. The pin is renewed: `costLine` and `identity`, which build that read, are as on `main`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…d cd `CD` reads only spaces and tabs between a separator and `cd`, and the shell reads no carriage return as a blank: `make build;\r cd sub && pytest tests -q` moves nowhere, and answers no ask. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…, not by the path's start A suite whose data folder's name starts with its test file's (tests/test_big_cases for tests/test_big.py) was refused though its cases' classes tell them apart, and a data file under a folder with a dot in its name was counted. The class of a case pytest collects from a data file is that file's path with / turned into ., so that is what is refused. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…is no file run Such a line was dropped as a comment, and the operator at its end with it. It may be the end of a quoted argument that spans lines, so the run under it waits on the command before it. The pages also name the quoted run that a count of quotes does not tell, and the plugin page names the folder beside the test file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…r set-up alone is not read for The word that names another machine refuses a run only with a blank after it. A run in a comment, after an escaped separator or in a quoted argument is kept where only set-up stands before it. A test holds the lone & at the end of the line above the run. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
A run after other commands is refused where it and what follows hold an odd number of either quote, which one apostrophe after the run is too. The pages said a quote opened before the run. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…hon file A case that names another Python file is that file's, whatever its class. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.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 plugin's test cost line now covers the two shapes it was written for and missed: a pytest run of one test file that follows an edit in the same shell call (
sed -i ...; git diff --stat; pytest tests/test_big.py), and a test file whose cases come from data files.Why
The plugin notes what a whole run of one slow pytest file costs, stores it in one memory row at the session's end, and a later bug report in the repository carries the line. Two rules kept a session from noting the runs the line is for.
fileRun(lib/test-gate.mjs) took a run only where nothing stood before it in its command butcd,export,sourceand.. A session that edits and then checks does both in one shell call: an inline script orsed,git diff --stat, thenpython -m pytest -q <file> | tail -5. Every such run was refused, so it was neither counted in its call nor kept as the pending run when it outlived the call.ofFile(lib/test-cost.mjs) took a report for the file's when its firsttestcasenames the file in itsfileattribute. A suite that reads its cases from data files names the data file there, since pytest writes the place each item reports for itself. Its whole run was taken for another file's and dropped. Theclassnameattribute of the same case starts with the module of the test file that collected it. To see both attributes, run one case of such a suite with the plugin's options and read the firsttestcaseof the result file:Such a suite prints a
classnameunder the test file's module with afilethat names the data file, asclassname="tests.test_big.Suite.parse.test" file="tests/data/parse.test"fortests/test_big.py. mypy'smypy/test/testcheck.pyis one.The change:
fileRunalso takes a run whose text before it names no test runner (startsRunner) and nopytest, with;or a line's end before the run's own command (startsNoRun). A build tool withtestafter no letter further on in its command counts as a test runner there, inside a word too and whatever stands before it:startsRunnerreadsmake install testas an install, and it runs the tests. A package, a target or a path of such a name is refused with it (npm install test-utils; pytest <file>,make run-testsuite; pytest <file>,go build ./internal/testutil/...; pytest <file>). The wordssh,docker,podmanorkubectlwith a blank after it, anywhere before the run, is refused as onmain(ranHere), where only a set-up command's argument could hold it:docker compose up -d db; pytest <file>is no file run.&&,||,&, a pipe and a parenthesis before the run are still refused. After&&or||the run waits on what an earlier command returned. After&or a pipe it always starts, and that command runs beside it: what it prints and writes may come after the run's. They are refused on the run's line, and at the end of the last line before it that is no comment (git diff --stat &&, a# checkline, then the run). A list that ended before the run decides nothing, sogit stash pop -q || true; pytest <file>is a run.cd,export,sourceand.keep their rule for a run with nothing else before it. After another command, one of them joined to the run by&&is refused like any other command (tail -5 out.txt; cd pkg && pytest <file>): wherecdfails the run does not start. After another command acdis followed only where it starts the command, outside a group (cd pkg && sed -i 's/a/b/' src/parser.py; pytest <file>). The wordcd,pushdorpopdanywhere else before the run is refused (MOVE_WORD): it may be the text of a heredoc, acdthe shell ran further on (sed -i 's/a/b/' src/parser.py; cd pkg; pytest <file>), or a move by a spelling the reader does not know ("cd"; pytest <file>). The text after acdthat is followed is not read for a closing parenthesis: it is the edit's own, as incd pkg && sed -i 's/)$/, None)/' src/parser.py; pytest <file>. Acdwith no folder is a move the hook does not follow:cd; pytest <file>runs in the home folder, and so does a run under acdon a line of its own. Five more refusals keep a run that never starts out of the new rule:exit,errexitor asetwith-ein any of its flag words (set -e,set -u -e,set -o pipefail -e): the shell may end at a failed command before the run;<<and ends in&&,||,&or a pipe, with or without a comment after it:git apply <<'P' &&, the patch,P, then the run on the next line waits ongit apply. The operator is on the line that opens the heredoc, and the last line before the run is the heredoc's end. Where a heredoc ends is not read, so such a line in an inline script's text is refused too. A line that starts with#and ends in one of them is refused the same way: it may be the end of a quoted argument that spans lines;;before the run that the shell does not read: one after a backslash (echo done\; pytest <file>prints its words), or one on a line where a#that starts a word stands before the run, ahead of the line's first quote (git diff --stat # then; pytest <file>holds a comment and no run). Quotes are not read, so a#after a quote may be an argument's, as in an edit that inserts a comment (sed -i '5a\ # note' src/parser.py; pytest <file>), and decides nothing;python edit.py && (git diff --stat; pytest <file>);"or of': it is the text of a quoted argument, as ingit commit -m "fix; pytest <file>".The last two read the run's side and not the text before it, because an inline script before the run holds quotes and parentheses of its own (an apostrophe in a string,
print("(")).ofFilecounts a report whose first case names a file that is no Python file when the case'sclassnameis under the module of the run's file. A case in a Python file is that file's, as before. A case pytest collects from a data file itself has that file's path as its class, with/turned into.:tests.test_big.cases.yamlfortests/test_big/cases.yaml, which is under the module oftests/test_big.py. So a case whose class is its data file's own path is refused. So is any data file where a folder of the test file's name, less.py, stands beside it: a test file intests/test_big/has its classes undertests.test_bigtoo.For a run that other commands stand before, a report is the command's own only when it was written no more than 10 s before the hook read it (
OWN_REPORT_MSinlib/test-cost.mjs).fileRunsays which runs those are:afterSetUpOnlyis false where a command that is no set-up stands before the run. A comment line above the run is read as such a command.The third part is what makes the first one correct. A command before the run can print an earlier run's summary:
tail -5 out.txt; python -m pytest -q <file> | tail -5, whereout.txtis what a run that went to the background saved. Where the command's own run outlives the call, the output shows the earlier run's last line and the report the hook reads is the earlier run's too, so the summary and the report agree and the earlier run would be counted as a whole run of<file>. That report was written before the command's own run began, and that run has been going since. A run that ended in its call wrote its report moments before the call returned: pytest writes the file when its run ends (pytest_sessionfinish), before it prints the summary, and the hook starts when the call returns.The bound does not cover a command that puts its own run in the background.
tail -5 out.txt; pytest <file> > out2.txt 2>&1 &returns at once: a report the earlier run wrote moments before is within the 10 s, and that run's summary is the one the output shows. SostartsNoRunrefuses a run that a&puts in the background after such commands, alone or with what reads its output (| tail -5 &,& echo started). The&of&&,&>and|&puts nothing in the background. Such a command is no file run, as onmain. A background run after set-up alone is a file run, as onmain: no command before it prints a summary.The bound is on the report and needs no state. An earlier head of this pull request compared the begin of the report's run with the return of the session's previous shell call, kept in a state file that the launcher wrote after every shell call. That bound was wrong in two ways, and it is gone with the file,
noteReturn, the launcher's note andtestCostOn:maincounts that run.hooks/loom-record.mjs,hooks/loom-test-report.mjsandendReportare as onmain. The same bound covers a suite that a recipe ran under no runner's name (just check 2>&1 | tee out.txt), whose report no hook reads: read with the next command, it was written before that command began.The bound applies only where a command before the run could have printed the summary. A command that is the run alone prints no line but its own. The report of a run with only
cd,export,sourceand.before it is taken as the command's own, whatever a file thatsourceor.read printed. Both are counted as onmain, however long before the hook the report was written. A run with a comment line above it has the bound.I weighed a narrower head rule in place of the bound: refuse a head that reads a file (
tail,cat,head,grep). It does not close the case, because a session prints a saved summary in more ways than a rule can list (sed -n,awk, an inline script), and it refuses heads that are harmless.The text before the run is read once backwards from the run and once line by line, because a head can be long (an inline script) and an expression such as
/[;\s]+$/costs quadratic time on a run of blank lines. The existingCDexpression had the same cost: it read\s*after a separator, seconds of CPU for 80,000 blank lines. It now reads only spaces and tabs between a separator andcd, which changes no match of acdthe shell runs, since a line's end is a separator itself. The-eof asetis read within 64 characters of the word and in its own simple command, so a long line that repeatssetcosts linear time too. Comment lines are taken out in one pass before the walk back.Scope and risk
Touches the note of a run's cost:
fileRun, which also returnsafterSetUpOnly;ofFile;noteCommand; andrunCost, which returns the first case'sclassnamebeside itsfile. The digest of a failing run, the stored sentence, the prompt's line, the launcher and the rule for what a session's end stores are as onmain. No state file is added.What a wrong result costs. A run that is refused stores nothing: the row stays as it was, and a session runs the file once more without the line. A run that is counted wrongly stores a number that every later bug report in the repository prints. So where the command's text does not decide, the run is refused.
A run after a command that is no set-up is no file run where:
pytest: that command may write the report itself;&&,||,&or a pipe joins the run to the command before it, on the run's line, at the end of the line before it or at the end of a line that opens a heredoc: the run may not start, or runs beside that command;exit,errexitor asetwith-e: the shell may end before the run;;before the run, which is escaped or in a comment, or the run is in a quoted argument or in a parenthesised group;&puts the run in the background: the summary the output shows may be an earlier run's;cd,pushdorpopdstands before the run anywhere but as onecdto a plainly written folder that starts the command;ssh,docker,podmanorkubectl, with a blank after it, stands before the run, as onmain.The test
a command with two pytest runs, two paths, another selection or no run of its own is no file runholds commands of each kind, under a comment that names the kind. The refusalsmainhas for the run's own words and for what follows the run are unchanged, and are in the same test. A run after set-up alone is read as onmain, except throughCDandMOVE, whose changes are under the Stop gate below.The report of a run after a command that is no set-up is the command's own only when it was written no more than 10 s before the hook read it. A run alone or after set-up has no such bound, as on
main.ofFiletakes a report whose first case names a data file where the case's class is under the module of the run's file. It refuses a case whose class is its data file's own path with/turned into., and any data file where a folder of the test file's name, less.py, stands beside it. The second is onestatof the folder.The Stop gate.
CDandMOVEhave a second reader,wholeRuns, which decides whether a test run answers the Stop gate's ask: among its conditions,MOVEfinds as many moves asCDfindscds with a folder.CDhere reads fewer blanks than onmainand is otherwise the same, andMOVEreads every move it reads there. So a result changes only from an answer to none, which costs one more run of the tests, and acdthat is followed gives the folder it gives onmain. The commands whose result changes, each in the refused list of the testa run's paths are read from the directory its command moved to(integrations/claude-code-plugin/tests/test-gate.test.mjs):cdwith no folder. Onmain,cd; pytest tests -qheld no move and answered for the session's folder, andcdon a line abovepython -m pytest tests -qwas read as a move to a folder namedpython. Both are fixes;cdalone straight before;,&,|or), as an argument too:echo cd; pytest tests -qanswered the ask onmainand answers none here.MOVEdoes not tell that argument from the command;cdafter a separator and a blank that is no space or tab, such as a carriage return, which the shell does not read as a blank.The word at the end of a longer argument is no move before a separator, as on
main:ls /media/cd; pytest tests -qanswers the ask.A hook runs in the user's session, and reading the text before the run takes time linear in its length. The test
a run that follows commands which name no test runner is a file runends with long texts before the run and asserts a bound on the CPU time of reading them.tests/unit/session_content_senders.jsonpins the bytes oflib/test-cost.mjsand of its Codex copy for the reviewedmemory.getread of the row. The two pins are renewed:costLineandidentity, which build that read, are as onmain.What the change does not tell apart, and the runs it does not count, are in the list under "What it does not do" in the section "What a whole run costs" of
docs/features/integrations/claude-code.md. A wrong number can still be stored for a command before the run that starts pytest under no runner's name, for a report an earlier run wrote within 10 s of the call's return, for a command put in the background earlier in the call, for a run of two paths that an earlier call left going, for a shell that ends before the run in a way the text does not name, for a run in a comment that starts after a quote on its line (echo 'done' # then; pytest <file>), and for a run in a quoted argument where a quote of the same kind stands inside a later one (git commit -m 'fix; pytest <file>' && echo "it's in"): quotes are counted, not paired. A run after set-up alone is read as onmain, so a run in a comment, after\;or in a quoted argument is kept there too (export NOTE="built; pytest <file>").Compatibility, rollout and rollback
Tests
Run the test files of the changed modules:
No test fails on the head. The whole folder has no failure either, run two files at a time (
node --test --test-concurrency=2 integrations/claude-code-plugin/tests/*.test.mjs). At the default concurrency, on a machine under other load, tests that wait on a bounded lookup failed infile-context-read.test.mjs,file-context-scope.test.mjsandplugin-modes.test.mjs; those files pass when run alone.The tests of the change, by name, in
integrations/claude-code-plugin/tests/test-cost.test.mjs:a run that follows commands which name no test runner is a file run: the commandsfileRuntakes after an edit, and the bound on the CPU time of reading a long text before the run;a command with two pytest runs, two paths, another selection or no run of its own is no file run: the refusals of Scope;a report whose first case names a data file is the run's when the case's class is under the run's file: the classesofFiletakes and refuses, read with the run's command and while the run is pending, and with a folder of the test file's name beside the file;a run after other commands in its shell call is counted with the report it wrote in that call: the 10 s bound at its edge, with the clock held;a report written before a command's own run could end is not the command's, where a command before the run may have printed its summary: an earlier run's report read with a later command, a run put in the background, and a run alone or after set-up with an older report;a command that is no file run, or names a file that is not there, leaves no state;a whole run of a data-driven file that follows an edit in its shell call is stored at the session's endandthe report of a run that a command naming no test runner started is not a later command's.The Stop gate's changes are in
a run's paths are read from the directory its command moved toinintegrations/claude-code-plugin/tests/test-gate.test.mjs.The test of a class under a package of the test file's name was written first: commit
864c685e20holds it alone and fails it, with the report stored as a whole run of the file, and1dc1d0c8a2passes it.The 10 s bound against what a run does: pytest writes the result file in its session-finish hook and prints the summary after it (
pytest_sessionfinishandpytest_terminal_summaryin_pytest/junitxml.py). What follows the write is the summary, the end of the process and whatever the command runs after it. For a run of 400 cases, with and without xdist workers, this prints under 0.2 s, and 1.3 s once with a test suite running beside it:python -m scripts.codegen.agent_plugin_sync --check,standalone_skills --check,served_skills --check, Biome and Prettier on the changed files,node --checkon the changed modules,make lint, andpytest tests/unit/test_codex_plugin.py tests/unit/test_agent_plugin.py tests/unit/test_public_copy.py tests/unit/test_doc_links.py tests/unit/test_plugin_memory_contract.py tests/unit/test_session_content_senders.pypass.make typecheckreads Python only and this branch changes none: it is left to CI, since the mypy ratchet counts errors above its baseline in a local virtualenv whose dependency versions differ from CI's.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 two attributes on a real result file of a data-driven suite, each new refusal case against
fileRun, the timing of the head reading before and after, the time between a run's report and its command's end, and the state the tests read after each hook.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), the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py) and the standalone skill bundles (python3 scripts/codegen/standalone_skills.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