Repository navigation
improve: reduce eager imports during Gateway workspace discovery - #154115
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: needs changes before merge. Reviewed September 20, 2026, 7:34 PM ET / 23:34 UTC (Revision 5). ClawSweeper reviewWhat this changesGateway workspace discovery uses lightweight helpers and loads session storage, sandbox classification, and Doctor inspection only when needed. Merge readiness⛔ Needs changes before merge - 1 item remains This remains a useful performance improvement absent from current main. No introduced correctness defect was found, and the updated evidence addresses the earlier build and performance-proof gaps. Priority: P2 Review scores
Verification
How this fits togetherGateway startup and Doctor enumerate configured workspaces and persisted sandbox copies before checking their readiness. This change reduces the code loaded during that discovery while retaining the existing configuration, storage, and migration owners. flowchart TD
A[Gateway startup or Doctor] --> B[Configured agent workspaces]
B --> C{Eligible sandbox workspace?}
C -->|Yes| D[Load session keys and sandbox classifier]
C -->|No| E[Selected workspace paths]
D --> E
E --> F[Doctor inspection when requested]
F --> G[Migration readiness check]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +5. Total +5 across 5 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain the existing discovery and storage owners behind conditional imports, preserving workspace selection and read-only readiness semantics. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug report; current-main source confirms the eager imports, and the supplied compiled probe measures their reduction. Is this the best way to solve the issue? Yes. Reusing existing narrow definitions and deferring their heavier consumers preserves one implementation of workspace selection without adding configuration or storage contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 21f3d71a09d4. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
509d867 to
854a939
Compare
|
Merged via squash.
|
…nclaw#154115) * improve: reduce eager imports during Gateway workspace discovery * fix: remove unused agent session-key re-export * perf: defer workspace session and Doctor storage imports
What Problem This Solves
Gateway workspace discovery eagerly loads session storage, Doctor workspace inspection, and sandbox runtime code even when the configured workspaces do not need it.
User Impact
Default sandbox-off and writable-workspace paths load less code. Workspace selection, persisted sandbox requirements, read-only Doctor checks, and migration readiness keep their existing owners and behavior. No configuration or migration action is required.
Why This Change Was Made
Use the existing narrow helper definitions, load the batched sandbox classifier only for eligible workspaces, and load the storage-neutral session accessor only when a session-scoped sandbox needs its keys. Reuse that accessor within the scan. Workspace state inspection loads only for Doctor work. Remove the internal session-key re-export left unused by the caller cutover; canonical routing and SDK exports remain.
Evidence
0b615218, Node 24.19.0, pnpm 12.4.0, and fs-safe 0.16.0. The five affected originals are byte-identical at publication basec0e1456f; current main uses fs-safe 0.17.0, so current-head CI remains required.The final formatted candidate passed a full build and the compiled import-boundary probe. Importing the workspace-discovery owner loads 343 modules / 2,279,059 source bytes, versus 2,281 / 15,577,691 in the original build. Sandbox-off and writable-workspace scans keep sandbox runtime, the SQLite session entry, and Doctor workspace storage unloaded. Missing-store and 32 session-scoped-agent cases still load the required owners and pass. These counts describe this isolated import probe, not the entire Gateway.
The final candidate's measured readiness and sampled peak RSS are below, alongside both original blocks from the earlier comparison:
Readiness is parent spawn to both HTTP readiness and sidecar readiness. Each block has two measured samples after warmup. The final candidate is a later standalone block, not a fresh interleaved comparison; the original A2 drift prevents a stable percentage speedup claim. Startup below five seconds is not established, and no RSS reduction is claimed. RSS is sampled throughout each harness sample; restart samples include the first RPC checks, so the two columns are different measurement windows.
First boot uses newly seeded 10,000 modern plus two legacy retained-session rows, not an empty install. Restart uses that same state after a real boot and graceful shutdown, without reseeding or rewriting configuration. All 10,002 rows remained byte-equivalent. Both agents returned the expected retained session identities through real
chat.historyrequests; the two-request sequence including connection took 752.0 and 734.9 ms after readiness. Graceful shutdown passed. The full proof completed without memory-limit or OOM events and restored source, index, and dependency manifests.CI Status
Head
26a1ff4cintegrates the verified main repair from PR #154138. All five reviewed source files are byte-identical toc7e9a615; current-head CI runs against the repaired main context.The original
c7e9a615CI (run 35543018959) passed formatting and the Doctor custody shard, but exposed the Claw close-failure test contamination. The owning repair has an ordered failing/passing reproduction and preserves the Claw assertions. The earlier854a9392Doctor custody timeout did not recur onc7e9a615; its cause remains unproven, and no timeout or assertion was changed. Green current-head CI remains a landing requirement.