Skip to content

refactor(gateway): share update watcher scheduling - #159291

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

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

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Gateway update watcher owns separate native timers for active-run observation and deferred schema publication. Their wakes are outside the kernel schedule.

User Impact

Update status, interrupted-run reconciliation, final notices, and schema-publication grace retain their existing contracts. The Gateway scheduler now owns both wakeups and exposes them through its existing next-wake fact.

Why This Change Was Made

The watcher borrows the required scheduler from its update-check lifecycle. Remove both native timer handles and their clear/unref plumbing. One scheduler instance per Gateway process, enforced by types: no private default or optional scheduler is added. The existing work scope still joins admitted notices and cancels interrupted-update verification on stop.

Update behavior: existing install state, configuration, callback ports, run rows, upgrade receipts and schema versions are unchanged. The publication deadline is re-derived from the owning ledger on each boot, preserving the old updater's grace rather than restarting it. A late wake observes current state once; no missed-poll replay. No schema, config, RPC or SDK surface changes.

Production +26/-24/net +2; tests +122/-59/net +63; docs +0/-0/net 0. The eight-file cutover replaces timer-driven owner tests with the shared injected clock and preserves the existing durable-recovery fixture.

Evidence

Provider blacksmith-testbox, lease tbx_01m3fe5xws0vqv7gvgg8bg9q61, run 36261201574. Frozen install and exact source verification preceded pnpm test <file> --maxWorkers=1:

File Passing cases Command wall
src/gateway/server-methods/update-status.test.ts 24 21.505 s
src/gateway/server-runtime-services.delivery-recovery.test.ts 1 11.114 s
src/gateway/update-run-watcher.interruption.test.ts 29 10.279 s
src/gateway/update-run-watcher.schema-publication.test.ts 4 8.490 s
src/gateway/update-run-watcher.test.ts 7 7.943 s
src/gateway/server-startup-update-check.test.ts 5 8.765 s

Six files / 70 cases passed in 68.096 s; the baseline selections also passed. Publication head 21364cf0660d655818fef27e1736659dcb701e19, based on main 5e0d86f46d83a0bf81dd4242ccb7ce86d23d0a40. Proof tree aa35863a90bae8b69e2322cd96fa5edda8a3aa90; all eight published files match the reviewed/proved composition byte-for-byte. Sleep catch-up, pending verifier cancellation, final notices, and schema-publication deadlines are exercised. This is focused proof, not yet the final merged-main live run.

Deslop and independent Codex review through P2 have no accepted/actionable findings. Cross-shard call-site grep confirms the only production start is the lifecycle-owned Gateway entry point. git diff --check passes. Exact-head GitHub ci-gate supplies changed-file validation; the final slice carries live Gateway/cron/suspend/restart/shutdown proof.

Stack

Follows kernel scheduler #158423, update-check lifecycle #158909, and outbound recovery #159096. Session delivery #159275 and system-job retries #159129 are separate slices. Earlier stack links are in those PRs. Next: update campaign, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M labels Sep 27, 2026
@steipete
steipete enabled auto-merge (squash) September 27, 2026 00:54
@clawsweeper

clawsweeper Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 26, 2026, 8:55 PM ET / September 27, 2026, 00:55 UTC.

ClawSweeper review

What this changes

The branch moves Gateway update-run polling and delayed state-schema publication onto the shared scheduler and updates the affected lifecycle tests.

Merge readiness

⛔ Blocked before merge - 2 items remain

Current main still uses separate watcher timers, so this PR remains useful. The focused tests support the cutover, but the repository’s required published-updater-to-candidate compatibility proof is still outstanding.

Priority: P3
Reviewed head: 21364cf0660d655818fef27e1736659dcb701e19

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The cutover is focused and has meaningful tests, with confidence limited by the unverified published-updater handoff.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The maintainer-authored PR is exempt from the external contributor proof gate. Focused tests exercise the watcher and a synthetic older-run SQLite fixture, but they do not supply the separate repository-required published-updater compatibility cell; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external contributor proof gate. Focused tests exercise the watcher and a synthetic older-run SQLite fixture, but they do not supply the separate repository-required published-updater compatibility cell; no stored-data contract changes.
Evidence reviewed 6 items Introduced scheduling change: The introduced patch replaces native polling and schema-publication timers with named jobs on the lifecycle's scheduler.
Still needed on main: Fetched current main still declares separate native watcher timer handles and schedules the polling timeout.
Existing-state test boundary: The schema-publication test creates a synthetic run marked as version 2026.9.2 and checks the retained SQLite connection and grace deadline; it does not run a published updater.
Findings None None.
Security None None.

How this fits together

The Gateway watches update-run records written during updates. It broadcasts progress, sends eligible notices, and publishes the state schema after older updater activity clears.

flowchart LR
  A[Update run records] --> B[Gateway update watcher]
  C[Update lifecycle] --> D[Shared scheduler]
  D --> B
  B --> E[Progress and notices]
  B --> F[Schema publication]
Loading

Before merge

  • Resolve merge risk (P1) - The synthetic version-2026.9.2 ledger fixture does not prove that a published updater's actual persisted state retains the intended schema-publication grace when the candidate Gateway takes over.
  • Complete next step (P2) - Before merge, record the required published 2026.9.2 updater × candidate Gateway proof for persisted-run recovery and schema-publication grace.
Agent review details

Security

None.

PR surface

Source +2, Tests +63. Total +65 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 3 26 24 +2
Tests 5 122 59 +63
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 148 83 +65

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Prove the published updater handoff (recommended)
    Exercise state written by the published 2026.9.2 updater with the candidate Gateway and record the observed restart and schema-publication result before merge.

Technical review

Best possible solution:

Keep the shared scheduler cutover and verify the candidate Gateway against state produced by the published 2026.9.2 updater through restart and the existing schema-publication grace.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this is a scheduling refactor, and current main's native watcher timers establish the pre-change behavior.

Is this the best way to solve the issue?

Yes: the existing Gateway scheduler is the appropriate owner for these wakeups. The published-updater compatibility cell is still needed to validate the upgrade path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 038b10b48de0.

Labels

Label changes:

  • add P3: This is a bounded internal scheduling refactor without an established urgent user regression.
  • add merge-risk: 🚨 compatibility: The changed wakeup owner participates in schema publication after older updater runs, and published-updater handoff proof remains outstanding.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This is a bounded internal scheduling refactor without an established urgent user regression.
  • merge-risk: 🚨 compatibility: The changed wakeup owner participates in schema publication after older updater runs, and published-updater handoff proof remains outstanding.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Introduced scheduling change: The introduced patch replaces native polling and schema-publication timers with named jobs on the lifecycle's scheduler. (src/gateway/update-run-watcher.ts:51, 21364cf0660d)
  • Still needed on main: Fetched current main still declares separate native watcher timer handles and schedules the polling timeout. (src/gateway/update-run-watcher.ts:27, 038b10b48de0)
  • Existing-state test boundary: The schema-publication test creates a synthetic run marked as version 2026.9.2 and checks the retained SQLite connection and grace deadline; it does not run a published updater. (src/gateway/update-run-watcher.schema-publication.test.ts:53, 21364cf0660d)
  • Update proof policy: The root repository policy requires a published-driver × candidate proof cell for update behavior. (AGENTS.md:82, 21364cf0660d)
  • Recorded focused validation: The captured PR body reports 70 passing focused cases and expressly defers the final merged-main live run. That evidence does not establish a published-updater-to-candidate run.
  • Area history: Recent merged history connects Peter Steinberger to the scheduler and update lifecycle, Vincent Koc to watcher status reconciliation, and SunnyShu to interrupted-update handling. (src/gateway/update-run-watcher.ts, 21364cf0660d)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • SunnyShu: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record a published 2026.9.2 updater × candidate Gateway run that covers persisted run recovery and schema publication.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

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