Repository navigation
refactor(gateway): schedule update checks through the lifetime owner - #158909
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. |
| const controller = new AbortController(); | ||
| const { signal } = controller; | ||
| const pending = new Set<Promise<unknown>>(); | ||
| const scope = new AsyncWorkScope(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Codex review: blocked before merge. Reviewed September 26, 2026, 10:24 AM ET / 14:24 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch moves Gateway update and remote catalog checks onto the shared scheduler and registers their lifecycle for shutdown, including modes that suppress automatic checks. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 3 items remain Keep open. In the minimal test Gateway, an authenticated update request can arrive before the new lifecycle exists. The repository-required published-updater to candidate upgrade proof is also outstanding. Priority: P2 Review scores
Verification
How this fits togetherGateway startup creates the owner used by automatic update checks and operator update requests. That owner schedules checks and drains accepted work when the Gateway closes. flowchart LR
A[Gateway startup] --> B[Update lifecycle]
C[Operator update request] --> B
B --> D[Shared scheduler]
D --> E[Update and catalog checks]
E --> F[Update status]
B --> G[Shutdown drain]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +8, Tests +113. Total +121 across 14 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Register one update lifecycle before minimal-mode RPC admission, keep automatic checks gated on readiness, and verify an existing installation updates into the candidate through the published driver. Do we have a high-confidence way to reproduce the issue? Yes, from source: connect an authenticated administrator to a minimal test Gateway after its listener binds but before post-attach registers the update lifecycle, then request update.run. This read-only review did not execute that race. Is this the best way to solve the issue? No. The shared scheduler is the appropriate owner, but the lifecycle must be registered before its admitted RPC callers can use it. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 84d71bf32329. LabelsLabel changes: No label changes. Label justifications:
EvidenceAcceptance criteria:
What 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 (1 earlier review cycle)
|
|
Merged via squash.
|
…penclaw#158909) * refactor(gateway): schedule update checks through the lifetime owner * test(gateway): avoid shadowing the update lifecycle signal
What Problem This Solves
Gateway update checks own sleep loops outside the kernel’s timed-work and shutdown owner.
User Impact
Checks keep their existing cadence and update decisions. Early update RPC work is cancelled and joined with the Gateway, including minimal/canary modes where autonomous checks remain disabled. Existing installs need no migration or operator action; the installed updater still owns staging, activation, and recovery.
Why This Change Was Made
Require the kernel scheduler in the existing update lifecycle and require that lifecycle in the check factory. Named check/catalog jobs replace sleep loops; the deferred owner is registered for shutdown before automatic work can start. Delete implicit lifecycle construction and retain the existing cancellation/drain contract.
One scheduler instance per Gateway process, enforced by types. This slice adds no standalone scheduler. Campaign/watch timers remain assigned to their later slices. No storage/schema, retention, config, RPC, SDK, or port change.
Strict LOC: production +78/−62/net +16; tests +122/−17/net +105; docs +0/−0/net 0. The production metric includes eight test-harness lines; required lifecycle admission and dependency closure explain the growth.
Evidence
Current publication head:
382eca5fb9c05ea17cde994328ce32d6a5be8b59. Current-head focused proof and exact-head CI: after frozen install,pnpm test src/infra/update-startup.test.ts --maxWorkers=1passed 109 cases in 30.214s on blacksmith-testbox leasetbx_01m3er4ym3e4e69mfkcyc84m7t, run 36239456451. Exact commit/tree and unchanged tracked source were verified. the original update-startup overlap proof was on 00ca227; current head also passed focused type-aware lint (20.475s) and all 117server-startup-post-attach.test.tscases (12.839s) on blacksmith-testbox leasetbx_01m3ezy8rsvrbyzc6121b5y475, run 36246724140. Current CI and the enforced gate are green; the exact-head watcher exited successfully. CI on 00ca227 found oneno-shadowviolation in the new regression; a three-line local binding rename fixed it without changing test behavior. The delta passed Codex P2 review. The remaining prior proof below is reused for the unchanged production patch. GitHub’s enforcedopenclaw/ci-gatereplaces a separate Testboxcheck-changedrun.Prior proof: Blacksmith-testbox, lease
tbx_01m3egmtwwrpzy41g7v4x5807e, run 36232827179. Commands ran afterpnpm install --frozen-lockfilein isolated checkouts. Head05d6381638fb247c3f4ac2c48085a9811b09ce5c, verified treee507580be304168e8769416cec31c220e947adfd: 431 cases across 16 files passed. The earlier minimal/canary regression also failed with the old dummy owner and passed with explicit lifecycle publication.The reviewed composition on
bde1d5fae5976acd64c04902af82c9a866100f3fchanges only the test-helper conflict resolution: retain main’s log/Nix defaults and the required scheduler. Production files are byte-identical to the reviewed slice. The published rebase onto380a77a86f6a1e877cb3876c6c67d2759455eddehas the identical stable patch ID. Deslop and a fresh Codex P2 review passed with zero findings; the six-root caller census found no new production callers.Recorded commands and per-file test cost
Each test row is
pnpm test <target> --maxWorkers=1; command wall includes wrapper/build setup. These are prior-run measurements, not a performance comparison.src/gateway/server-startup-update-check.test.tssrc/infra/update-startup.test.tssrc/infra/update-startup-request-adoption.test.tssrc/infra/update-global.freebsd.test.tssrc/gateway/server-methods/update-admission-freshness.test.tssrc/infra/update-startup.campaign-apply-error.test.tssrc/gateway/server-methods/update-status-schedule.test.tssrc/gateway/server-methods/update-run-campaign.test.tssrc/gateway/server-startup-post-attach.test.tssrc/gateway/server-methods/update.test.ts,src/gateway/server-methods/update-owner.test.ts,src/gateway/server-methods/update-unexpected-error.test.ts,src/gateway/server-methods/update-freebsd-pkg.test.ts,src/gateway/server-methods/update-handoff-failure.test.tssrc/gateway/server-startup-update-canary.test.tssrc/gateway/server.roles-allowlist-update.test.tsScheduler stack
Merged: diagnostic preparation (#157517), auth factory naming (#158275), kernel scheduler and companion sweep (#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 is also merged: #158812. Also merged: PR subscriptions (#158821). Publication order continues with update checks, Gmail renewal, metadata capture maintenance, and audit maintenance; this PR is update checks. Links for these four: Gmail renewal (#158913) is open; metadata and audit follow.
Later reviewed slices: task maintenance, cold storage, approval/secret expiry, publication and post-ready work, diagnostic heartbeat and SDK/CLI lifetime, auth pruning, MCP idle retirement, generation/periodic/media maintenance, outbound recovery, session delivery, update watcher/campaign, and cron due/foreign-receipt/system jobs. Final cleanup removes superseded timer plumbing and records the exception census; merged-main Gateway/cron/SIGSTOP/SIGTERM proof follows the last slice.