Skip to content

refactor(gateway): own update campaign scheduling in its lifecycle - #159306

Merged
steipete merged 1 commit into
mainfrom
hostneutral/scheduler-update-campaign-0926
Sep 27, 2026
Merged

steipete merged 1 commit into
mainfrom
hostneutral/scheduler-update-campaign-0926

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Automatic update campaigns own a process-global timer and mutable campaign singleton separately from the Gateway lifetime. Replacing the Gateway can leave campaign state with the retired owner.

User Impact

The existing idle, countdown, hold, adoption and forced-update behavior now uses the Gateway's scheduler and current update lifecycle. Replacement clears only the retired lifecycle's campaign; status and run handlers consume the current owner.

Why This Change Was Made

Require a scheduler in UpdateCampaignController and create the controller in the update-check lifecycle. Remove the native timeout and clear/unref plumbing, global gatewayUpdateCampaign export, and the redundant injected-controller option. One scheduler instance per Gateway process, enforced by types. The existing async-work scope tracks admitted apply work through shutdown.

Update behavior: no config, state, spool, port, schema or public SDK change. Existing countdown/hold boundaries, persisted update rows, acknowledgments and adopted-run ownership remain intact. The recently landed OCM managed-update selection and its older-manager fallback are preserved; only campaign access moves to the lifecycle. Expired process-local campaigns do not leak into a replacement Gateway. No new persisted schedule is introduced.

LOC: production +68/-58/net +10; tests +207/-136/net +71; docs +0/-0/net 0. The 469 changed lines cut over the owner and its status/startup/RPC callers together.

Evidence

Provider blacksmith-testbox, lease tbx_01m3fe5xws0vqv7gvgg8bg9q61, run 36261201574. After frozen install, pnpm test <file> --maxWorkers=1 passed all 18 files / 346 cases in 202.751 s on proof tree 6272615737b3c906868e2e1dc26cb0e97cfc4ece:

File Passing cases Command wall
src/gateway/server-methods/update-admission-freshness.test.ts 7 21.041 s
src/gateway/server-methods/update-effective-channel.test.ts 11 8.993 s
src/gateway/server-methods/update-freebsd-pkg.test.ts 7 8.965 s
src/gateway/server-methods/update-handoff-failure.test.ts 18 13.150 s
src/gateway/server-methods/update-hold.test.ts 4 9.253 s
src/gateway/server-methods/update-owner.test.ts 24 21.399 s
src/gateway/server-methods/update-run-campaign.test.ts 28 10.627 s
src/gateway/server-methods/update-status-schedule.test.ts 15 8.199 s
src/gateway/server-methods/update-status.test.ts 24 10.304 s
src/gateway/server-methods/update-unexpected-error.test.ts 7 8.959 s
src/gateway/server-methods/update.test.ts 48 18.367 s
src/gateway/server-startup-update-check.test.ts 5 6.758 s
src/gateway/update-run-watcher.test.ts 7 7.874 s
src/infra/update-campaign.test.ts 17 11.018 s
src/infra/update-startup-campaign-run.test.ts 9 9.005 s
src/infra/update-startup-request-adoption.test.ts 3 8.191 s
src/infra/update-startup.campaign-apply-error.test.ts 3 8.167 s
src/infra/update-startup.test.ts 109 12.481 s

Fresh-main OCM composition: provider blacksmith-testbox, lease tbx_01m3g6q6b7x9nvanv9zngc0r1q, run 36284825347. After pnpm install --frozen-lockfile (5.644 s), the same focused command passed src/gateway/server-methods/update-status.test.ts (24 cases, 25.701 s), src/gateway/server-methods/update.ocm.test.ts (36 cases, 17.715 s), and src/infra/update-campaign.test.ts (17 cases, 18.927 s): 77 cases in 62.343 s. Proof tree 3e1dea844d1c3fb445c8bf05da28f58ed27dcffc. Publication head 1ec0ab80c653fa5e66c25fb5f360db18eb5043e9 preserves every changed file byte-for-byte after rebasing onto main containing the merged watcher.

The original owner review and fixture-composition review were clean through P2. Deslop of the fresh-main delta retained OCM's existing behavior without extra wrappers or guards; a fresh full-diff Codex P2 review found no actionable findings. Cross-shard grep finds no remaining gatewayUpdateCampaign export/caller or injected updateCampaign option. Exact-head GitHub ci-gate supplies changed-file validation. Final merged-main Gateway/cron/suspend/restart/shutdown proof follows the last slice.

Stack

Follows update watcher #159291, update checks #158909, and session delivery #159275. System-job retry #159129 is independent. Earlier stack links are in the predecessor bodies. Next: diagnostic/CLI/SDK lifetime, auth pruning, MCP preparation/cutover, final census and docs.

@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant