Repository navigation
perf(reply): attribute startup and avoid redundant workspace scans - #169307
Conversation
Report nested reply and runtime preparation spans in slow chat-send diagnostics. Preserve the existing initialization boundary and identify fresh reads, mutations, history, and actor preparation. Avoid full expiry inventories for recently attested workspaces while preserving disappearance guards.
|
🦞👀 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 maintainer review before merge. What this changesThis PR adds detailed chat startup timings and avoids redundant skill inventories for recently attested workspaces. Example: Twenty concurrent first turns on an isolated Linux Gateway with 128 workspace skills.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it provides useful startup attribution and a measured workspace improvement absent from main, with no actionable introduced defect found; the updated inherited-failure evidence addresses the previous CI attribution request. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway chat dispatch prepares workspace and session state before agent execution, while existing preparation spans feed request-owned startup diagnostics. flowchart TD
A[Chat send] --> B[Detached dispatch]
B --> C[Workspace preparation]
C --> D[Session initialization]
D --> E[Agent preparation]
E --> F[Model execution]
C --> G[Startup diagnostics]
D --> G
E --> G
Technical reviewBest possible solution: Retain the scoped attribution and scan removal, preserving workspace safety and using the recorded inherited-failure disposition during native landing. Do we have a high-confidence way to reproduce the issue? Current main captures full skill inventories twice even when recent attestation prevents expiry, and the supplied regression reports eight synchronous skill-stat calls for one skill before the fix. Is this the best way to solve the issue? Reusing existing span helpers and the filesystem guard’s directory-only mode removes unnecessary work without adding another cache or weakening expiry decisions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 670ad6a9b0fc. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +102, Tests +88, Docs +18. Total +208 across 12 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 11, 2026, 5:45 PM ET / 21:45 UTC (Revision 4). |
|
Merged with the operator-authorized inherited-failure exception, pinning reviewed head The only root failure in CI run 38172968600 was The relevant ACP event/admission files are unchanged by this PR. A controlled replay on unchanged current-main production The lane passed 273 focused tests, 20 closure tests, export-collision checking, all 28 test-type groups, production types, lint, dead exports, import-cycle checking, and the remaining changed-code guards. Synthetic Gateway proof completed all 21 turns. Fresh independent review was clean through P2. The native merge helper stopped before mutation because its shared |
…penclaw#169307) * perf(reply): attribute startup and avoid redundant workspace scans Report nested reply and runtime preparation spans in slow chat-send diagnostics. Preserve the existing initialization boundary and identify fresh reads, mutations, history, and actor preparation. Avoid full expiry inventories for recently attested workspaces while preserving disappearance guards. * fix(diagnostics): avoid shadowing the phase iterator * fix(diagnostics): preserve binding and satisfy lint contracts
What Problem This Solves
First-message startup reported several seconds as
replyInitializationwithout identifying which owner was waiting or working. Add subphase attribution to the existing slow chat-send diagnostics and remove repeated workspace preparation scans.User Impact
Operators can distinguish workspace setup, session hydration, fresh snapshots, commit work, admission, prompt/skills assembly, tool catalogs, and model/auth preparation. Recently attested workspaces no longer synchronously inventory every skill to prepare expiry evidence.
Why This Change Was Made
Keep the existing
replyInitializationboundary (dispatch through session preparation); prompt/tool/model assembly remains inpreparation. Request-scoped observers reuse existing timeline spans, capture open spans at startup completion, and work with timeline file logging disabled. Nested measurements overlap and must not be added together.Workspace expiry cannot proceed while an attestation is recent. That path needs directory identity checks, not full content inventories. Expired or unattested workspaces retain their content evidence and disappearance checks. There are no schema, configuration, or persisted format changes. The session-context resolver and title-listener lifecycle move to their existing preparation/background owners to keep oversized dispatch modules from growing.
Evidence
Isolated Linux Gateway, synthetic state only: 2,000 workspace source files, 128 skills, 513 configured models, 128 existing sessions with 32 KiB transcripts, Code Mode enabled. Existing activity-summary work settled through its owner before each measured wave. Real
sessions.create→chat.send→agent.wait, synthetic HTTP model endpoint. Both runs completed all 21 turns.The <1 s initialization p95 target was missed. The consistent measured win is workspace preparation: average 30.5% lower and p95 24.7% lower. Final initialization average improved 4.3%, while p95 was essentially flat. Final send-to-first-model timing was 15,667 ms average / 16,876 ms p95 versus 13,990 / 15,217 before; whole-startup improvement is not established. A prior candidate run measured a larger startup improvement, which was not reproduced on the final shared-host run. P95 follows the repository convention and is the maximum for this 20-sample wave.
History, actor, history-boundary, commit-fresh-read, and commit-mutation splits were added after the baseline; their before values are unavailable. Session persistence and later runtime preparation remain substantial. Parent and child spans overlap.
Final Gateway RSS was 788 MiB at readiness and 2,120 MiB after the burst. Baseline RSS was not captured, so no allocation improvement is claimed. Timings measure pre-provider work, not external provider latency.
Independent review is clean through P2 on the implementation and final lint corrections. The rig passed 273 focused tests across 17 files (six existing skips), the export-collision guard, and all 20 closure tests. The broader changed-code gate completed: production types, all 28 test-type groups, lint, dead exports, import cycles, and guards passed. Exact-head CI has one independently reproduced pre-existing failure, detailed below.
The workspace regression failed before the fix (eight synchronous skill-stat calls for one skill), then passed afterward. Per-file single-worker commands on the rig were
pnpm test src/gateway/server-methods/chat-send-diagnostics.test.ts --maxWorkers=1(18.28 s wall) andpnpm test src/agents/workspace-attestation.worker.test.ts --maxWorkers=1(94.16 s wall, including cold worker setup). The new test bodies measured 4 ms each for the two diagnostics cases and 2.015 s for the workspace case; no test files or CI shards were added.Initial prestart-steering runs timed out. Later baseline runs exposed SQLite FULL during teardown; after recovering disk space, the accepted case passed on current main and all three cases passed on the candidate. These are environment-affected failures, not a claimed product repair. The closure suite also first hit ENOSPC, then passed all 20 tests after cleanup. The first CI run exposed lint issues in this diff; the final corrections pass the targeted lint checks.
Blacksmith
tbx_01m4p1m9hav2wvmqdwb0qe0p3wpassed the initial diagnostics/timeline tests; later sync timed out. A fresh Blacksmith lease remained queued, and AWScbx_9eaf42790ab4and Hetznercbx_32a4d24fb27cstalled in sync, so validation uses the authorized Linux rig fallback. All cloud leases are stopped. No test result is claimed for failed synchronization.Production source is +102 lines net; tests are +88 and docs +18. The explicitly requested attribution contract accounts for the growth. No cache or alternate workspace-preparation implementation was added; full-content scanning is removed from the recent-attestation path.
CI disposition
Exact-head CI run 38172968600 failed only
checks-node-changed-compact-small-4-1:Gateway ACP completion ownership > completes persistence failure after explicit abort oncereceived lifecycleendwithoutstart. Its failure triggered the existing fail-fast cancellation monitor; cancelled siblings are not claimed as green.The ACP lifecycle files are unchanged by this PR. On unchanged current-main production
072f977edd46c7134dbdb05ec00fac03f6cf8069, a controlled replay of that same test reproduced the identical assertion in both cold and warm iterations. The test wrapper held the real start-recovery read result until the original public abort emitted its real terminal event; it did not replace rows, authority, event values, or assertions. An ordinary baseline run passed, so this is explicitly a timing-sensitive reproduction. The existing delayed-start admission is rejected once abort reserves terminal publication.Landing uses the operator-authorized inherited-failure exception. No CI rerun, update-branch, or workflow dispatch was used to chase green.