Repository navigation
The plugin's code shunt never refuses a compound shell command, and a refusal names the scope it would have shown - #1689
Conversation
… 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 latest updates on your projects. Learn more about Vercel for GitHub.
|
…00 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 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>
… 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>
HOOKS.md keeps main's UserPromptSubmit rows (loom-record, its in-process and detached scripts) and this branch's loom-code-shunt row, which names the one index lookup a denial makes. Both plugin manifests move to 1.2.68, one patch above main's 1.2.67. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 707f248. Configure here.
| const answer = symbolAnswerText(res, { asOf: repo.asOf, namespace: repo.namespace, localGrep, dirtyFiles }); | ||
| if (answer) verdict.deny = denySymbolGrepWithAnswer({ ...ctx, symbol: verdict.symbol }, answer); | ||
| } catch { | ||
| /* the plain redirect stands */ |
There was a problem hiding this comment.
Cap denials ignore concurrent budget spends
Medium Severity
After the new code.outline wait, settleRead re-classifies the over-cap read with the capCounts snapshot from before the lookup, then spends from a fresh read without checking whether this file's two denials are already used. A parallel over-cap read of the same file that finishes during that wait can exhaust the budget, and this call still denies and increments the count past the limit instead of passing as cap_spent.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 707f248. Configure here.


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' code shunt no longer refuses a shell command made of several parts, and refuses a read or a symbol grep only when it can put the index's answer in the refusal: the functions, methods, classes and structs of the lines asked for, with their lines and headers, or the symbol's one definition. A
ghissue search inside a chained command now runs without the tracker answer.Why
A refusal costs the agent one model request and withholds whatever the call would have printed. In a measured agent session on a public Python repository, the shipped hook refused this command:
The grep in the middle looked like a symbol lookup, so the hook asked the index.
self_nameis a local variable, the index held no definition, and the hook refused anyway with "callloom_code_symbol". The 11-line read and the test-name grep, which had nothing to do with that word, were withheld with it. The agent did not make the suggested call. It repeated the read and the greps in its next request, which is one request and a few seconds a session without the plugin does not pay.Reading the hook showed the same two faults on every refusal path:
cd repo; wc -l a; cat small; cat bigwas refused for the last part).code.outline" or "callcode.enclosing", and the symbol refusal stood when the index had nothing to say.What is now true:
;,&&,||, a newline or a pipe outside quotes. Its reads and greps are still counted for the pass counters. One the hook would have asked the index about as a command of its own (a large file, an over-cap slice, a symbol grep) carries the new pass reasoncompound_command; the others keep their own reason. No lookup is made and no denial budget is spent for it. Aghissue search followed by&is not judged either.code.symbolreturns exactly one definition and the caller's own lines from modified files fit in the refusal. No definition, several definitions, no reply within 2.5 s, or more local lines than the refusal carries: the grep runs, with pass reasonindex_unanswered.code.outlinecall (4,000-token budget) returns every declaration that overlaps the lines asked for. A list the budget cut before the end of those lines, a file with no declarations there, or no reply: the read runs. A whole file whose lookup gave no declarations is asked about once per session, whether the index answered with an empty or cut outline or did not answer, so an unreachable server costs each file one wait of 2.5 s and not one per read.LOOM_SHUNT_READ_CAPit is the enclosing class and the functions in the range. A refusal that cannot carry this is not given, and spends none of the file's two denials.tail -n N fileis judged as the file's last N lines: over the cap,tail -n 300of a 900-line file is refused with the declarations of lines 601-900.code.outlinelists by default, and the refusal says so: functions, methods, classes, structs and the units of tests, build files and SQL. An interface, type alias, enum or constant is not among them. The refusal's heading reads "The index's outline of it (lines, qualified name, header; it lists functions, methods, classes and structs, not interfaces, type aliases, enums or constants)".Design choices a reviewer may question:
cd dir && cat big.pyalso passes. A narrower rule (exempt a leadingcd) would keep more refusals, but the agent could not predict it, and the measured cost of a wrong refusal is higher than the cost of a read.git remote get-url origin && gh auth status && gh issue list --search …was answered from the tracker record before; refusing it withholds the first two outputs.ghIssueSearchInCommandnow judges only a command that is oneghcall, and its chain scan is deleted.loom_code_symbolfor all") was a cut answer.mainrefuses on that index, where thecode.outlinedefault of 1,500 refuses 17%.interface,type,enumandconst(and Rust'straitandimpl), and a request takes at most 16 kinds, fewer than the default 15 plus those. Listing them needs a server change tocode.outline, which is not in this pull request. Until then a file that is mostly types is refused with a short list, and the refusal says what the list leaves out and that a ranged read passes. Measured with the extractor on this repository:frontend/src/api.ts(1,682 lines) has 80 of its 128 declarations in the default kinds, and the generatedsdk/typescript/src/generated/ops.ts(11,821 lines) has 1 of 4,403.Scope and risk
hooks/loom-code-shunt.mjs,lib/code-shunt.mjs,lib/shell-command.mjs) in the Claude Code plugin, with the Codex copies regenerated, their tests and docs.symbolAnswerText, and edits, test runs and git commands, which the hook never judged.code.outlinereply, bounded at 2.5 s, before it is refused or passed. Before, that decision was local. A call the local rules pass costs no network call, as before. A call the index does not answer waits for that lookup and then runs: once per symbol and once per whole file in a session, and at each over-cap read. With the server unreachable the read now runs; before, a cached repository entry was enough to refuse it.cd repo && cat big-fileor a large file with a long outline will see those reads run. On the measured index 114 of 301 files over 800 lines are now read whole wheremainrefused them, 50 of them among the 71 files over 2,000 lines.tokens_savedon ashunt_hitrow is now the file's or the span's tokens less the refusal's own text (characters ÷ 4), because a refusal now carries up to a few thousand tokens of declarations.code.outlinejoins the session-content class, because a hook now sends it with a path taken from the session, as it doescode.symbolandcode.enclosing. On a deployment with mirrored document sources on, a client that does not declare session protection is refused oncode.outlineas it already is on the other code reads. The op's reach manifest entry gains the plugin hook.Compatibility, rollout and rollback
code.outlineis nowsession_content.code.outcomerows withaction=shunt_passmay carry two newsourcevalues,compound_commandandindex_unanswered. A server before this change stores them and reads them asunattributed.shunt_passrows with the two new reasons, which the older vocabulary reads asunattributed.Tests
Unit tests were not run locally; CI runs them. What I ran:
node --test --test-concurrency=1ontests/code-shunt.test.mjs,tests/code-shunt-hook.test.mjs,tests/code-hooks-failopen.test.mjs,tests/hooks-doc.test.mjs,tests/hook-contract.test.mjs,tests/prompt-pack.test.mjsandtests/prompt-pack-hook.test.mjsinintegrations/claude-code-plugin: 144 pass, 0 fail. An earlier run, while the machine was under heavy load, failed timing-bound tests in these files, among them tests this change does not touch; the hook's git calls are bounded at 1.5 s.declarationsInSpan,wholeSymbolAnswer,isCompoundCommandand the one-commandghsearch shape; a second whole-file read of a file the index did not outline makes no second lookup, and another session asks for itself; inside a command of several parts a symbol grep is logged ascompound_commandand a grep for a plain word assingle_file_grep; aghsearch followed by&is not judged; a hit logs the file's tokens less the refusal's text;tail -n 300of a 900-line file over a 200-line cap is refused as lines 601-900 with the one declaration there and logged with that span; a whole file whose lookup reached no server is not asked about again in the session; a symbol budget written to the counts file whilecode.outlineis being answered survives both the miss record and the read-cap spend. The tail case and the kept-budget case failed on the previous head: the refusal read "lines 1-300" with the declaration at line 1, and the counts file lost the concurrent key.test_outcome_pass_reason_is_the_source_from_a_fixed_vocabulary,test_shipped_automatic_senders_have_an_admission_class_or_reviewed_exception(again after the hook's reviewed digest was renewed),test_independent_delivery_roots_are_present_in_the_actual_census, six checks oftests/unit/test_codex_plugin.py(copies current, manifests agree, one version, minimum server version, hook wiring, every hook script wired), the three checks oftests/unit/test_environment_reference.py,test_outline_is_registered_and_listed_with_the_code_tools, and the four source-tree checks oftests/unit/test_public_copy.py. A snippet also confirmed the admission gate refuses an undeclared client oncode.outlinewhen session protection is on and admits it when it is off.bench/acceptance/fixtures/shunt_decisions.jsonagainstclassifyReadandclassifyGrep: 0 mismatches.ruff format --check .,ruff check, the function-length gate, the secrets gate, every generator--checkinmake lint(the reach manifest was regenerated, thencensus: ok),agent_plugin_sync --check,node --checkon the changed.mjsfiles, Biome and Prettier checks on the changed files,claude plugin validateon the plugin and the marketplace listing. The mypy gate reports errors only inserver/llm/vertex_auth.py, from an untyped dependency in the local environment.The outline budget, measured. A refusal needs the file's whole outline inside the budget, so the budget decides how many whole-file reads are still refused. I sent the hook's own
code.outlinerequest, with its 2.5 s bound, to a running Loom index of a large public C++ repository, for every third (by length) of the source files over 800 lines at the indexed commit: 300 files under the indexed paths (231.cpp, 44.py, 22.h, 3.c).mainrefuses a whole-file read of each of them.index_unanswered)main's refusal text quoted, deleted here, does not describe this index.DEFAULT_OUTLINE_BUDGET.Replay of recorded sessions. I took every tool call recorded in 60 agent sessions on two benchmark tasks in one public Python repository (281 calls: 210 Bash, 19 Read, 35 Edit, 17 others; 206 of the Bash commands have several parts) and ran each through the hook as the host runs it, once with
main's plugin and once with this branch, against a clean checkout of the repository. The 57 calls of the second task were also replayed against that task's own revision, with no refusal on either side. A local stand-in answeredcode.symbolandcode.outlinefrom the checkout's own declarations. For this push I replayed this branch again;main's column is the earlier run, becausemain's plugin files have not changed since. The machine was loaded, and a hook whose bounded git calls run out of time judges nothing, so a call that logged no decision was run again until it did: in each configuration the hook logged 192 decisions for 112 of the 281 calls.mainmain's one refusal is the measured one, reproduced byte for byte. It is the only decision that changed.mainand 0 here.compound_command. As first pushed, this change logged them assingle_file_grep.LOOM_SHUNT_READ_CAP=5andLOOM_SHUNT_MAX_LINES=100.mainrefused 44 calls, 26 of them commands of several parts (including one test run, two git commands and two edits). This branch refuses 18, the same 18 single Read callsmainrefuses, each carrying the declarations in its lines, for example254-256 test_dotted_name_not_allowed def test_dotted_name_not_allowed(app, client):and259-273 test_dotted_names_from_app def test_dotted_names_from_app(app, client):for a read of lines 252-259 of a test file. Six of the 18 read that file: its outline of 157 declarations does not fit 4,000 tokens either, but the part that fits ends after the lines they ask for, where the part 1,500 tokens returned ended before them. The hook made 18 lookups, one per refusal, and logged 46 reads and greps ascompound_command.Not verified: which kinds a running index returns for a TypeScript or Rust file (the kinds above come from running the extractor on the files, not from an index); the hook end to end against a running Loom server (the outline measurement above sent the hook's request, not a session's tool calls); the effect on an agent's cost in a live session; what the reads that now pass cost; and the host's limit on the length of a refusal reason. The replay used a clean checkout, so reads that followed an edit in the recorded sessions were judged as unmodified files, which can only add refusals.
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 checked the recorded refusal against the transcript, replayed every recorded call through both versions of the hook, and read the full diff of the hook and its libraries.
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 PreToolUse hook behavior and session-content classification for
code.outline, affecting how agents read code in mirrored deployments; fewer refusals by design but more server lookups on deny paths.Overview
The Claude Code and Codex code shunt now embeds Loom index answers in deny reasons instead of telling the agent to call
code.outline,code.enclosing, orcode.symbol. Whole-file and over-cap reads are denied only after a boundedcode.outline(4,000-token budget) returns declarations for the requested lines; symbol greps are denied only whencode.symbolreturns a single whole definition. Otherwise the tool call runs (index_unanswered).Compound shell commands (
;,&&,||, pipes, newlines) are never denied, so chained reads/greps are not blocked by one segment;ghissue-search shunt applies only to a singleghcommand. Session budgets addmiss:keys for failed whole-file outlines;tail -n Nis treated as the last N lines;tokens_savedsubtracts the denial text size.Server-side
code.outlineis classified as session content (like other code reads), with newshunt_passsourcescompound_commandandindex_unanswered. Plugins bump to 1.2.68 with matching docs and expanded tests.Reviewed by Cursor Bugbot for commit 707f248. Bugbot is set up for automated code reviews on this repo. Configure here.