Repository navigation
improve(gateway): reduce redundant startup work - #147165
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 maintainer review before merge. Reviewed September 13, 2026, 12:35 PM ET / 16:35 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR reuses cached process identity for Gateway locks, removes an unused startup placement scan, and synchronizes Discord transcript tests with actual conversation dispatch. Merge readiness✅ Ready for maintainer review Keep open as useful, bounded work: current main still performs both redundant operations, and no actionable defect was found in the introduced changes. The updated Discord test resolves the synchronization mismatch without weakening assertions. Priority: P3 Review scores
Verification
How this fits togetherGateway startup acquires exclusive ownership of local state and initializes worker services from retained records. Process identity supports safe lock ownership checks, while worker recovery and reconciliation handle existing placements. flowchart TD
A[Gateway startup] --> B[Acquire state locks]
B --> C[Shared process identity]
C --> D[Cached self identity or fresh foreign lookup]
A --> E[Load worker stores]
E --> F[Initialize worker runtime]
F --> G[Recover and reconcile placements]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -6, Tests +47. Total +41 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep process identity with the shared reader and placement recovery with the worker runtime, eliminating startup work that has no consumer. Do we have a high-confidence way to reproduce the issue? Not applicable as a user-facing bug report: source confirms redundant startup work, and the supplied Windows measurements quantify it; this read-only review did not execute the benchmark. Is this the best way to solve the issue? Yes. Reusing the existing identity cache and deleting an unconsumed query are narrow changes that preserve lock formats, process checks, configuration, and worker recovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 149648a3d073. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
* improve(gateway): reduce redundant startup work * test(discord): await transcript conversation dispatch
What Problem This Solves
Gateway startup repeats Windows process-identity queries and reads historical worker placements whose result is no longer used.
User Impact
Startup avoids redundant native process launches and work proportional to retained placement history. At 10,000 historical placements, the worker-state loader's median time fell from 48.9 to 4.4 ms and temporary heap growth from 30.6 to 0.18 MiB. Overall readiness remained approximately 12.3 seconds, within measurement noise. No configuration changes or operator action are required.
Why This Change Was Made
Gateway locks now use the existing shared process-identity owner, which caches successful self reads while checking other processes freshly. The unused placement-presence projection and its full scan are removed; runtime recovery and reconciliation retain their existing reads.
Evidence
Filename too longfixture failures; the eight relevant Gateway startup/cleanup cases pass.pnpm build sourcePerformance), targeted lint, production typechecking, affected test typechecks, formatting, and diff checks pass. Independent review found no actionable issues; required autoreview is scoped-clean at its default P0 threshold.The Gateway measurements use the repository's default isolated benchmark configuration and asynchronous health/readiness probes. Periodic synchronous PowerShell memory sampling was omitted from both versions because it blocked the stock benchmark's own HTTP probe deadlines on this host. No live Gateway state was changed.
Hosted CI exposed an existing Discord test synchronization race in checks-node-compact-small-33:
preserves whole-utterance conversation across capture with empty CLI opening audioexpected agent dispatch before it occurred. The test waited for recording, while dispatch runs on a separate conversation queue. The repair now awaits a deferred milestone resolved at the actual agent/control dispatch boundary. All six cases and their assertions remain intact, with no sleeps, polling, timeout changes, or production changes. All six repaired cases pass on Linux and Windows. Both Windows jobs passed in the initial hosted run, whose only failing test was this Discord case.