Repository navigation
fix(gateway): expose recovery startup timing breakdown - #174357
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Include bounded reader, delivery, blocked-notice, retry-wait, exec, registry-load and activation durations in the normal recovery completion line. Preserve recovery ordering and reader readiness while making production startup waits attributable without verbose tracing.
c26c030 to
e62b412
Compare
|
Codex review: needs maintainer review before merge. What this changesAdds seven recovery-stage timing totals and an outcome to the normal Gateway startup completion log. Example: Recovery takes 1790 ms, including 500 ms recording blocked notices and 1000 ms waiting before retries.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it provides useful, owner-directed recovery diagnostics that current main lacks, with no actionable correctness or security findings. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway startup observers join reader preparation, recover saved deliveries and exec notifications, and activate the subagent registry; the existing startup trace owner turns those measurements into operator logs. flowchart TD
A[Post-ready startup observers] --> B[Reader preparation]
B --> C[Saved delivery recovery]
C --> D[Exec recovery]
D --> E[Registry loading and activation]
C --> F[Startup trace owner]
B --> F
E --> F
F --> G[Recovery completion log]
Technical reviewBest possible solution: Keep the bounded summary in the existing startup trace owner while preserving recovery ordering, cancellation, and delivery authority checks. Do we have a high-confidence way to reproduce the issue? Current-main source confirms that normal logs expose only the outer recovery duration; the individual stages require verbose tracing, and no target code was executed during this review. Is this the best way to solve the issue? The implementation fits the problem: it extends the existing measurement owner, accumulates repeated spans, and documents that nested totals must not be added to the outer duration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9151847f12e0. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +42, Tests +97, Docs +7. Total +146 across 6 files. Added test files: 0. View PR surface stats
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 Reviewed October 16, 2026, 11:33 AM ET / 15:33 UTC. |
Include bounded reader, delivery, blocked-notice, retry-wait, exec, registry-load and activation durations in the normal recovery completion line. Preserve recovery ordering and reader readiness while making production startup waits attributable without verbose tracing.
What Problem This Solves
Restart recovery can spend seconds waiting after Gateway readiness, but normal startup logs show only the total
sidecars.subagent-recoveryduration. The existing child spans require enabling verbose startup tracing, so an ordinary production boot cannot identify the slow stage.User Impact
Operators get one bounded completion summary at normal info level, with reader preparation, delivery recovery, blocked-notice work, retry backoff, exec recovery, registry loading, and registry activation timings. The line includes no session identities, message content, paths, or error payloads.
Why This Change Was Made
Reuse the startup trace owner and existing spans. Include dynamic imports in their stage timing, accumulate repeated notice/backoff spans, and retain the existing recovery order, reader-readiness barrier, cancellation, and shutdown custody. Nested notice and retry durations belong within delivery duration and must not be added to the outer total.
Current main now includes #174278, which saves a blocked-delivery notice and cancels replay of replaced-endpoint inputs. This branch is rebased onto that fix, preserving its durable second-restart regression. The production measurements below predate that change; repeated stale-input work is already addressed by that owner.
The prior reader barrier protects restored admission budgets; moving activation earlier would not remove a shared database queue stall. This PR supplies the missing attribution before changing that ordering. Related: #174134.
Evidence
Read-only analysis of five consecutive production boots found recovery durations of 21.683 / 13.562 / 24.360 / 10.508 / 23.753 seconds. Authenticated connections in the first 30 seconds were 15 / 15 / 12 / 15 / 19, so connection count alone does not explain variance. Named sidecar startup spans had already completed, although background work could continue.
In the two slow recent boots, 16.611 / 16.134-second gaps between delivery rejections coincide with
board.getcalls taking 16.540 / 16.657 seconds. Both paths use agent-database FIFO admission. All eleven retained deliveries on those boots failed once with replaced endpoints; no retry-backoff warnings occurred. Blocked-notice selection scans the active transcript under writer admission even when the notice is unchanged, making it a concrete candidate for the next measurement. Existing journal and scrape-aligned Prometheus counters cannot prove which operation held the queue.Before: one opaque outer phase line. After: the same completion line carries seven numeric subspan totals and outcome; detailed per-span logs remain opt-in. No production speedup or before/after latency improvement is claimed. The next deployed boot is required to attribute the production wait. This change does not alter scheduling or database behavior.
Focused local proof: 42 tests passed across
server-startup-trace.test.ts,session-send-recovery.test.ts, andserver-startup-observers.test.ts(60.71 seconds Vitest wall time; 67.25 seconds including wrapper preparation). New timing cases use controlled clocks, exercise actual recovery-to-log wiring, cover repeated notices, trace on/off, failure, phase reset, and post-ready reporting. Changed-file formatting and scoped core/test lint passed. Independent autoreview was clean through P2. All three summary regressions fail against the original trace implementation because no breakdown is emitted (1.95 seconds Vitest wall time); the reviewed implementation was restored byte-for-byte afterward. After resolving the overlap with #174278, the complete 25-test delivery recovery file passed again (38.02 seconds Vitest wall time, 41.28 seconds including preparation; 1.05 seconds test time), including durable stale-input cancellation and our timing case. A fresh review of the merged source was clean through P2, and scoped lint passed again. Broad validation belongs to PR CI; no remote validation leases or production mutations were used.Production delta: +42 lines. Growth is required for the explicitly requested bounded timing summary and two nested measurements; there is no new cache, worker, scheduler, schema, configuration, or competing recovery path.