Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed October 6, 2026, 3:34 PM ET / 19:34 UTC (Revision 3). ClawSweeper reviewWhat this changesManaged-worktree cleanup batches small session-owner records instead of decoding complete session entries, while retaining fresh checks before removal. Merge readiness⛔ Blocked before merge - 1 item remains The optimization remains useful and absent from current main. The rebase resolves the previous conflict blocker, and this review found no introduced correctness defects. Priority: P2 Review scores
Verification
How this fits togetherManaged worktrees provide isolated repository checkouts for agent sessions. Cleanup combines checkout records, session activity, and live custody checks to decide which checkouts to preserve or remove. flowchart TD
A[Checkout records] --> C[Cleanup classification]
B[Session reader worker] --> C
C --> D[Preserve protected checkout]
C --> E[Fresh owner and custody checks]
E --> D
E --> F[Guarded checkout removal]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +294, Tests +260, Docs +2, Other -1. Total +555 across 17 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep classification within the existing session-reader owner and preserve fresh custody checks at every destructive mutation. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction: the source establishes repeated full-entry decoding, and the PR supplies before/after performance measurements; this reviewer executed no runtime checks. Is this the best way to solve the issue? Yes. The patch extends the existing reader and selection owners, limits cached facts to one cleanup pass, and retains live removal checks without changing configuration or persisted data. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 76beb5685887. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
3607a76 to
22e4aca
Compare
Batch narrow session owner facts for each GC pass while preserving fresh reads at destructive mutation guards. Share canonical store selection with single-entry worker reads and defer cleanup for uncertain metadata.
Capture logical identities before yielding and share each agent's selected stores. Preserve bound incognito roots through the logical reader and cover that composition with the existing actor test.
22e4aca to
b72bb5f
Compare
* commit 'c39d9b0692dbaafa5b1bfe02514c9f6411ab5546': (30 commits) fix(ci): clear MCP audit and service-worker test blockers (#166217) test(gateway): wait for steering admission in FIFO fixtures fix(llama-cpp): managed setup crashes and loops on macOS below 13.3 (#163358) perf(worktrees): avoid full session parsing during GC (#166072) fix(update): recover stopped legacy managed services (#166232) perf(gateway): stream bounded link preview metadata (#166195) perf(diagnostics): release completed Git operation state (#166214) chore(deps): update fs-safe to 0.24.1 and clone plugin source captures (#166189) feat(clients): adopt worker-local inference placement (#163647) test: serialize PowerShell completion process suites (#166229) test: stabilize release timing boundaries (#166218) refactor(sessions): persist run outcomes only; liveness comes from the run registry (#165733) test(gateway): prove mention refresh after config retargeting fix(team-reports): keep the missed closed day when catch-up runs after midnight (#165780) test(gateway): join WebChat queue admission and drain completion fix(logging): reject blank diagnostic stability query fields (#145532) fix(agents): report unparseable serialized edit arguments (#163577) improve(anthropic): log Claude Code version probe failures (#157697) fix(agents): clarify prompt-size provider failures (#159712) fix(memory): re-throw non-ENOENT/ENOTDIR errors in root memory file lookup (#107921) ...
* commit 'c39d9b0692dbaafa5b1bfe02514c9f6411ab5546': fix(ci): clear MCP audit and service-worker test blockers (#166217) test(gateway): wait for steering admission in FIFO fixtures fix(llama-cpp): managed setup crashes and loops on macOS below 13.3 (#163358) perf(worktrees): avoid full session parsing during GC (#166072)
* perf(worktrees): avoid full session parsing during GC Batch narrow session owner facts for each GC pass while preserving fresh reads at destructive mutation guards. Share canonical store selection with single-entry worker reads and defer cleanup for uncertain metadata. * test(worktrees): align CLI fixture with owner census * perf(worktrees): simplify batched owner selection Capture logical identities before yielding and share each agent's selected stores. Preserve bound incognito roots through the logical reader and cover that composition with the existing actor test.
What Problem This Solves
Worktree cleanup repeatedly parses complete owner session entries, including saved prompts, merely to classify each checkout. A 1,000-owner GC pass previously resolved every active owner twice.
User Impact
Cleanup uses substantially less allocation and CPU while retaining fresh checks before destructive mutations. Unknown owner state still preserves the checkout. No schema, configuration, migration, or upgrade action is required.
Why This Change Was Made
The session accessor batches narrow activity and custody facts through its existing reader owner. GC shares those facts for one pass; mutation guards still reread one owner. The scalar accessor delegates to the same selection owner, and redundant per-request store/ID maps are removed. Logical identities and default paths are captured before yielding.
The rebase onto
cc7e664dfe34preserves main's board-presence fact in the same row query, admitted-revision row cache, per-key native error isolation, participant projection, and bound incognito actor. An omitted environment continues to use the captured actor's state root. Existing worktree diagnostics, budgets, removal backoff, shutdown settlement, and runtime-preparation changes remain in the base.Production scope is +293 lines (+462/−169), including a one-line generated mock-allowance shrink; production source alone is +294. The narrow worker/storage projection must coexist with the full-entry APIs used by other session/SDK consumers, preserve shared/recovered stores and incognito ownership, and retain live destructive-mutation checks. The old GC full-payload path and duplicate row-selection/bookkeeping are removed. No persistent owner cache is added.
Evidence
Original allocation proof on base
355655951c77: 575.213 → 15.404 MB/pass (−97.32%), with full-entry/saved-prompt parses 2,000/2,000 → 0/0 and identical classifications. This is historical main-isolate allocation evidence; worker heaps were excluded. The RSS/CPU measurements below were made before the latest rebase, on base614d42bc76b1; they do not measure allocation bytes. The rebase tocc7e664dfe34preserves this lane’s GC algorithm and narrow projection while retaining upstream reader changes. These are historical measurements, not a new rig run on the rebased head.Each fresh process has 1,000 managed rows, active owners, stale checkout timestamps, ordinary directories, matching worktree bindings/revisions, and a synthetic 53,217-byte saved prompt per session. Two warmups precede twenty measured passes. Baseline cells were reused at the identical base with unchanged fixture bytes when the candidate was simplified; every classification matched. Commands ran on an isolated Linux rig (8 cores, Node 26.8.1), with
nice -n 10 ionice -c3and task-owned TMPDIR. This is source/tsx proof, not an installed-dist or production Gateway measurement.The prior +18.54% RSS number conflated reader readiness and process capacity. The candidate starts one existing history worker when cold; it does not create one per pass. Gateway startup, recovery, and non-ephemeral operator connect already prewarm this shared lane best effort. Matching readiness matters: the candidate has substantially less transient main heap from full-entry decoding. Bootstrap RSS also changed direction before any classification, so no static-import cause or exact attribution of every native byte is claimed.
A 100-pass final-candidate run held five tracked workers and one history worker. RSS at passes 20/50/100 was 1012.527/1045.062/1069.859 MB, while main used heap fell 135.141 → 130.849 MB. The same SQLite writer reclaimed heap capacity between passes 50 and 100 without restarting. After confirmed history-worker retirement, the next ordinary pass reduced RSS by 67.723 MB while recreating the reader. This demonstrates reclaimable capacity; it does not establish a total-RSS plateau or rule out all small retention. No worker-lifetime change is proposed merely to improve a synthetic metric.
Final validation on the rebased candidate passed on Blacksmith Testbox (
blacksmith-testbox, profileopenclaw-check), leasetbx_01m498z24mhz1xrdcq4jq7xp5j:node scripts/run-vitest.mjs <12 focused files> --maxWorkers=1: 186 tests passed, covering owner classification and mutation guards, GC lifecycle/CLI/progress, Gateway maintenance, narrow facts, board-presence batching, canonical/readonly/revalidation reads, and incognito actor composition. The Vitest groups reported 138.81 seconds total, excluding cold wrapper preparation.node scripts/check-changed.mjs --staged: passed completely, including all 27 test-typecheck shards, core types, dead-export scans, lint, and structural/architecture guards. No skipped deadcode scan or inherited-error exception was needed.The combined install, early checks, focused tests, and staged-gate remote command completed in 31m52.658s with exit 0. It used an exact-base worktree with the complete candidate patch staged and SHA256-verified (
91ca1a2077ad0309a2738f5f15f987107f53b17ed1a15e662db829e264f94546).Fresh detached direct-route Codex review is clean through P2 against base
cc7e664dfe34fd3b0bd53473dc10d033dc5c0e29. No suites, typechecks, or builds ran on the Mac.Current-head CI at
b72bb5f4dbabcompleted: run 37519222926, 52 successful jobs, 23 skipped, no pending jobs. The only failures aresecurity-fastand its aggregate gate, caused by the inherited MCP dependency advisory GHSA-6qxp-vccf-f47h in@modelcontextprotocol/clientand@modelcontextprotocol/sdk. This lane changes no dependencies; that inherited failure is explicitly excepted for this update. All other CI jobs passed. GitHub confirmed the pushed head is MERGEABLE.