Repository navigation
refactor(gateway): schedule generation startup sidecars - #159042
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 26, 2026, 12:56 PM ET / 16:56 UTC. ClawSweeper reviewWhat this changesThe branch schedules delayed Gateway startup hooks and post-restart recovery through the server's shared scheduler, with clock-driven lifecycle tests. Merge readiness✅ Ready for maintainer review Keep open: the pinned main still lacks this startup-sidecar cutover. The earlier scheduler foundation and the open task-maintenance slice address different work, and the reviewed patch has no concrete blocking defect. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway starts hooks and recovery work after its server attaches. Its scheduler wakes delayed work, while admission and sidecar handles control execution and shutdown. flowchart LR
A[Gateway startup] --> B[Delayed sidecar registration]
B --> C[Shared scheduler]
C --> D{Active and admitted?}
D -->|Yes| E[Startup hook or restart recovery]
D -->|No| F[Cancelled wake]
E --> G[Hook effect or restart notice]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +9, Tests +54. Total +63 across 6 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep one scheduler responsible for these wakeups while restart recovery retains its captured state context and shutdown joins admitted work. Do we have a high-confidence way to reproduce the issue? Not applicable: this is an internal scheduling refactor. Current-main source confirms the private timers it intends to replace. Is this the best way to solve the issue? Yes: passing the existing kernel scheduler to both consumers uses the established wake owner and preserves the restart-sentinel context. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 88816f79b42c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
What Problem This Solves
Delayed startup hooks and restart-sentinel recovery arm private timers outside the Gateway scheduler.
User Impact
The existing 250ms hook and 750ms sentinel delays remain. Generation retirement cancels waiting work and joins admitted callbacks, while restart recovery keeps its captured state root and legacy-update import custody.
Why This Change Was Made
Require the kernel scheduler in the generation timer owner and forward it through both consumers. Remove the private timeout, unref and clearTimeout bookkeeping. Move the two sentinel scheduling cases out of the broad startup suite and drive their owner with the shared injected clock, including cancellation while admission is suspended.
One scheduler instance per Gateway process, enforced by types. This slice creates no standalone scheduler. Updating preserves state, configuration, ports and existing sentinel rows; there is no storage, config or SDK contract change. Admission-only setImmediate sidecars, bounded ACP readiness polling and pending-update retry backoff retain their existing owners.
Production +33/−24/net +9; tests +95/−41/net +54; docs +0/−0/net 0. The small production increase makes scheduler and admission cancellation ownership explicit.
Evidence
Reviewed refresh at
be46e6966c2b52c6cde06abf965c44f9a175a47f, mechanically applied to fresh main for publication. The touched owners have no intervening changes. Gmail already supplied the required outer scheduler dependency and caller plumbing, so those duplicate hunks are omitted. Newer update-check behavior and its minimal/canary tests are preserved. The three fixture conflicts resolve to the exact previously reviewed and tested state-context file; the timer and sentinel owners also retain their reviewed bytes. Deslop, formatting, whitespace and cross-shard caller checks pass. The original slice passed independent Codex review through P2; this refresh adds no new behavior.Historical focused proof: blacksmith-testbox lease
tbx_01m3er4ym3e4e69mfkcyc84m7t, run 36239456451, pinned base3ed87e53daf5cdd5a69efbc471519ddf427b73de, candidate tree30eaa1f29b558ac9c560b62c718f542eec05c357. Afterpnpm install --frozen-lockfile, all three completed candidate files passed: 141 cases in 56.688s command wall. The later post-ready baseline in that multi-slice run was interrupted; the completed generation results were retained.Each row ran as
pnpm test <file> --maxWorkers=1:src/gateway/server-startup-restart-sentinel.test.tssrc/gateway/server-startup-post-attach.test.tssrc/gateway/server-restart-sentinel.state-context.test.tsThe two existing baseline files passed 115 cases in 12.123s and 25 cases in 48.032s respectively. These sequential measurements include wrapper/build setup and do not establish a performance improvement. No separate Testbox run was performed for this mechanical refresh; these counts and costs belong to the historical candidate. The enforced
openclaw/ci-gatevalidates the published head instead of a separate Testboxcheck-changedinvocation. The final live proof remains with the complete merged stack.Scheduler stack
Earlier slices: diagnostic preparation #157517, auth factory naming #158275, kernel scheduler #158423, event-loop health #158531, channel health #158537, mention expiry #158614, upstream monitoring #158617, worker placement #158662, idle/prewarm #158666, Incognito expiry #158690, OAuth maintenance #158717, initial lifetime maintenance #158727, worker reconciliation #158812, PR subscriptions #158821, update checks #158909, Gmail renewal #158913, metadata capture maintenance #158959, and audit maintenance #158982.
This PR migrates generation startup sidecars. The next prepared slice combines post-ready release and maintenance scheduling; its link will be added when published.
Task maintenance is #159038. Remaining reviewed work includes cold-storage maintenance, approval deadlines, periodic/media maintenance, diagnostic/SDK lifetimes, outbound/session delivery, update watchers and cron timing. Final timer exceptions and the merged-main Gateway/cron/suspend/shutdown proof follow the last slice.