Repository navigation
fix: keep large Git reads and cancellation responsive - #146499
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 September 12, 2026, 8:40 PM ET / September 13, 2026, 00:40 UTC (Revision 6). ClawSweeper reviewWhat this changesThe PR makes queued Git cancellation responsive, moves stored repository inspection into existing background workers, reduces diff copying, and adds private worker profiling. Merge readiness⛔ Blocked before merge - 2 items remain This remains a useful follow-up that current main and the latest release do not implement. No actionable introduced defect was found, and the previous review's tradeoff has an explicit disposition in the PR body. Priority: P2 Review scores
Verification
How this fits togetherGateway repository requests read Git checkouts and stored cloud-session artifacts to produce diffs and file previews. Background workers process large inventories while the Gateway retains subprocess execution, ownership checks, and cleanup. flowchart TD
A[Repository requests] --> B[Gateway ownership checks]
B --> C[Bounded Git workers]
C --> D[Gateway Git subprocesses]
D --> E[Git checkouts and stored artifacts]
E --> C
C --> F[Diffs and bounded previews]
G[Cancellation] --> D
Before merge
Agent review detailsSecurityNone. PR surfaceSource +157, Tests +346, Docs 0, Other +279. Total +782 across 28 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the existing bounded worker and subprocess owners, preserve checkpoint compatibility, and retain the documented acceptance of the measured memory cost. Do we have a high-confidence way to reproduce the issue? Yes: current main's ref queue cannot settle a canceled waiting caller until its predecessor finishes; the PR records paired real-Git reproduction. This read-only review did not execute that scenario. Is this the best way to solve the issue? Yes: the patch extends existing queue, worker, and checkpoint owners while preserving ordering, active cleanup, mutable response isolation, and stored formats. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b78d651e03ce. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
660bfd2 to
c241f63
Compare
Release queued callers without waiting for unrelated ref writers while keeping active execution joined. Share immutable diff text and project stored artifacts in the existing Git content pool with parent-owned validation and subprocesses. Extend private benchmark profiling to worker isolates and remove retired reader/parser facades. Preserve checkpoint formats and current recovery contracts.
c241f63 to
2745c49
Compare
|
Merged via squash.
|
* fix: keep large Git reads and cancellation responsive Release queued callers without waiting for unrelated ref writers while keeping active execution joined. Share immutable diff text and project stored artifacts in the existing Git content pool with parent-owned validation and subprocesses. Extend private benchmark profiling to worker isolates and remove retired reader/parser facades. Preserve checkpoint formats and current recovery contracts. * fix: preserve Git cancellation results and worker profile identity
Related: #146252, #146273
What Problem This Solves
Fixes delayed Git cancellation and avoidable memory/latency spikes when concurrent diffs or stopped cloud-session artifacts inspect large repositories.
User Impact
Canceled work waiting for a ref writer settles promptly, and large repository inspections keep the Gateway responsive. Existing preview limits, checkpoint validation, snapshot formats and active-process cleanup are preserved. No configuration, database schema or migration change is required.
Why This Change Was Made
Pending ref admission releases its callback and inputs on cancellation while preserving queue order. Once a writer starts, cancellation still joins its cleanup. All three low-level Git transports preserve their structured canceled-result contract; started authority errors are neither swallowed nor replayed.
Concurrent diff callers receive independent mutable containers while sharing immutable patch strings. Stopped-session diff/list/get requests inspect manifests in the existing Git content pool and return changed metadata and an optional bounded preview. The Gateway retains subprocess custody, checkpoint binding and current ownership checks. Retired full-reader/parser facades are removed.
Private benchmark IPC captures main/worker CPU and allocation profiles, periodic CPU/heap samples, and incomplete segments on retirement. Native thread IDs are queried inside inspector targets rather than inferred from their separate target IDs. These outputs are explicit benchmark artifacts, not runtime persistent state.
Evidence
The paired targeted Blacksmith Testbox run passed 14/14 jobs at
bf235b8d688d83983aef30a63b20c369e5aa5cc8, againstfdf2853f4860e65f7b1a44096647e8adfd89c13d(which already contains #146273). It includes both pinned builds, all three cancellation transports, all four CPU/heap identity/retirement cases, 143-response live Gateway parity, paired real Git cancellation, six 250k-artifact response sequences and 5,000-cancellation GC. All 123 original evidence files were independently checksum-verified; the lease is stopped.For twelve operations over a 250,000-entry, 71 MB artifact manifest:
The inventory worker accounts for 8.342 GB of sampled allocation traffic: the expensive work moves off the main thread; total artifact allocation is approximately unchanged. This is the real SQLite/checkpoint, Git worker, authority and artifact owner boundary, not live cloud-runner or full artifact RPC dispatch.
The earlier 21/21-job broad run tested
73b11dbff81e9200e8a89f7ccdf61440750cc345, including four B/C/C/B 60-second soaks, idle retirement/restart and snapshot restoration. It completed 28,514 unprofiled Gateway requests; all 16,753 non-outage readiness probes returned 200. Gateway heap profiles showed main allocation traffic 1069 → 868 MiB and all-isolate traffic 1218 → 1024 MiB. An actual-cache 20-caller probe reduced retained diff allocation 30.34 MB → 0.19–0.44 MB while preserving independent mutations.No throughput improvement is claimed. The two baseline soaks ran at 112.96/110.36 requests per second and candidate at 110.86/107.10; candidate process CPU was somewhat higher. Main-side Git subprocess creation remains the largest sampled stack. The approximately 131–141 MiB higher peak RSS on the extreme artifact fixture is accepted for the responsiveness gain within the existing bounded pool; idle retirement is verified, while memory-constrained production hosts remain unmeasured. Canceled caller objects collect promptly, but ordered queue bookkeeping remains until drain: about 9.57 MB per 5,000 slots.
Revision and Validation Notes
Current head
2745c491940d47239658f07cf43d3ea4c6afe150is refreshed onto mainbf95f2b23c63. All 27 Git/profiling source and test files match the targetedbf235b8proof byte for byte; documentation retains newer main content. Broad measurements remain attributed to73b11db. That older profiler mislabeled inspector target IDs as native thread IDs; only raw stacks/aggregates and main/process counters are used from it. The corrected targeted profiles independently map all fourteen worker captures to native statistics.The refreshed toolchain passed the full private-QA artifact build, core/UI types, targeted lint, 143 Git/worker tests with two platform skips, and six real-Gateway tests covering delegation, partial refresh, catalog publication and agent-file saves. Independent review through P2 found no actionable source defect. Final PR CI is green on the published head. Its initial attempt had two unchanged Discord recording-backlog timeouts; all 272 files / 3,820 tests then passed in an unchanged Linux/Node 24 Testbox replay, and one exact failed-job retry passed. Assertions and deadlines were unchanged. The original timeout remains unreproduced; a controlled minimized Vitest mock-factory race is a separate supported follow-up, not a claimed fix. The diagnostic lease is stopped and verified completed.
Earlier CI exposed inherited main budget failures and outdated synchronous-discovery fixture assumptions. Current main owns those repairs; duplicate branch fixes were dropped during refresh. An older instrumented run reproduced an unrelated passive desktop disconnect without recovering its close reason. It remains a separate unresolved follow-up; this PR changes no desktop implementation, and subsequent published-head CI passed the unchanged node and SSH desktop proof.
Persistent compatibility is unchanged: v1/v2 checkpoint recovery, bounds, checksum rejection and current-owner validation are covered. The automated serialized-state warning refers to explicit benchmark outputs, not a Gateway store. No deployment is included in this PR.