Repository navigation
fix(context_for_task): detect each directory's project once per call - #665
Merged
Merged
Conversation
…(PLAN-548) After #663's per-file memo, a pack still asked the daemon's sensitive-path decision about each of its 100-250 distinct files, and each ask resolved the file's project with workspacePool.Detect, globbing for markers on disk. On the live daemon the slowest arm R pack ran at 1.6-1.9 s of its 2 s graph deadline, and another was cut in 2 of 5 reps. Collect now attaches a tools.CallMemo to the call's context. historyRootFor reads it and detects each directory once for that call. The memo is fresh per call, so a marker created between two calls is seen by the second, and writes, which never carry one, detect on every ask as before. changeSensitive stays the one decision; workspaceFromArgs is split into detectStartDir and detectedRoot with identical behaviour. Tests: - one memo per call, and a fresh one for the next call; - a marker created mid-call is not re-detected, but the next call and an ask outside a call both see it; - changeSensitive gives the same verdict with and without the memo, including a source in another project that is sensitive only by that project's glob. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Plumb-Session: scarlet-badger
Review NIT on #665: a second kind of lookup through the same memo would share its key space with directories. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Plumb-Session: scarlet-badger
golimpio
approved these changes
Oct 14, 2026
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.
What
After #663 a pack asks the sensitive-path decision once per distinct file, which is 100 to 250 files. Each ask still resolves the file's project with
workspacePool.Detect, which globs for markers on disk. On the live daemon the slowest arm R pack (R05) still runs at 1.6–1.9 s of its 2 s graph deadline. In a baseline taken today on fa1fd85, a second pack (R08) was cut in 2 of 5 reps, losing its affected tests.The files of one directory resolve to the same project, so within one call this PR detects each directory once.
tools.CallMemo: a small lookup memo carried on the call's context.Collectattaches a fresh one on every call; a nil memo runs every lookup.historyRootFor(cli): detects through the memo. Outside acontext_for_taskcall, which covers every write, there is no memo, so detection runs on every ask exactly as before.changeSensitivestays the one decision. History and the response gate still share it.workspaceFromArgsis split intodetectStartDiranddetectedRoot, with identical behaviour; its existing tests pin it.Because the memo lives on the call's context, it can't outlive a call, and a marker created between two calls is seen by the second.
Tests
TestCallMemo_RemembersPerKeyAndNilRemembersNothing: one lookup per key, and a nil memo looks up on every ask.TestContextForTask_SensitiveAsksShareOneMemoPerCall: every ask in one call carries the same memo, and the next call gets a fresh one.TestHistoryRootFor_DetectsEachDirectoryOncePerContextCall:TestChangeSensitive_CallMemoKeepsEveryVerdict: each case is asked twice in a call and must give the same verdict as without the memo. Cases cover an ordinary file, a default glob, a project's own glob, the same name where no glob applies, and a move out of another project's file that is sensitive only by that project's glob. Controls require both verdicts to appear and the cross-project case to be sensitive.Mutation (
plumb mutation_test): all 7 valid mutants are killed:Collectattaches no memo;Oncenever stores;historyRootForignores the memo;detectStartDiralways takes the parent (killed by the existingworkspaceFromArgsand attribution tests);historyRootForbypasses the memo by passing a context with none.Measure
A live replay on the installed build after merge, with per-pack latency, to show R05 well under 1.5 s and no cuts under
sample. Baseline on fa1fd85 (5 reps): R01 0.36–0.42 s, R03 0.64–0.75 s, R05 1.58–1.66 s, R08 1.05–2.09 s with 2 of 5 cut.Verification
make verify-full-container: result to follow in a comment. Review: a peer agent (warm-cobra), who filed PLAN-548.🤖 Generated with Claude Code