Repository navigation
refactor(gateway): schedule worker placement maintenance - #158662
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: blocked before merge. Reviewed September 26, 2026, 1:24 AM ET / 05:24 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch replaces worker-placement's recurring interval with separate scheduler jobs for reconciliation and disk sampling, and updates the affected tests to use an injected clock. Merge readiness⛔ Blocked before merge - 2 items remain Current main still uses the private worker-placement interval. This focused PR remains useful because it moves that work to the existing Gateway scheduler. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway starts worker-placement services for sessions running on cloud or device workers. Scheduled maintenance reconciles placements and checks disk health; shutdown must cancel and drain that work. flowchart TD
A[Gateway startup] --> B[Shared scheduler]
B --> C[Reconcile placements]
B --> D[Sample disk space]
C --> E[Worker lifecycle]
D --> F[Health warnings]
G[Gateway shutdown] --> B
Before merge
Agent review detailsSecurityNone. PR surfaceSource +10, Tests +74. Total +84 across 11 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the shared scheduler as the timer owner and demonstrate a published-install-to-candidate update and restart with an active placement, including maintenance wakeups and shutdown. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR changes internal timer ownership rather than reporting an existing failure. The scheduling path is clear in source and the injected-clock tests. Is this the best way to solve the issue? Yes: reusing the kernel scheduler removes a competing timer owner while retaining separate disk sampling and reconciliation. The lifecycle upgrade path still needs observed proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c6da2a90127f. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat 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.
|
* commit '66b812f26e725cd709e08860d2cb46ba496cd308': (70 commits) fix(gateway): preserve typed boxed-number coercion chore(ui): refresh control ui locales (#158689) fix(gateway): reset staged headers on authority errors (#158669) fix(workers): keep inbound staging stable during quota scans fix: preserve Telegram delivery after bot identity changes (#158612) fix(ui): keep automation starter prompts out of startup (#158482) fix(cli): distinguish configuration read failures from invalid input (#158671) test: remove retired progress coercion suppression allowance refactor(gateway): schedule worker placement maintenance (#158662) fix(daemon): keep native service checks within their timeout (#154565) fix(test): restore gateway steering fixture contracts (#158478) fix(acpx): use SDK filesystem publication boundary fix(agentsapi): load OpenClaw persona and workspace context (#158328) fix(gateway): drop progress snapshot coercion suppression fix(qa): accept native Codex truncation in cache evidence (#158454) fix(gateway): keep chat subscriptions stable during unrelated approvals (#158633) perf(gateway): release event payloads from live text guards (#158643) perf(sessions): reduce stalls when saving large chat messages (#158402) fix(qa): reject history-bearing utility requests without session affinity (#158496) test: allow intentional progress snapshot coercion ...
* fix(test): verify followup completion ordering Exercise the real presentation settlement helper with asynchronous cleanup, preserve continuation and admission semantics, and unconditionally release and join the held work. Remote proof covers the strengthened ordering contract and both missing-await faults. * fix(test): verify followup completion ordering * chore: retain followup test branch ancestry The current-main reconstruction preserves the original reviewed scope and supersedes its stale base. Keep the remotely qualified candidate tree unchanged while retaining the original PR ancestry for a non-force branch update. * commit 'ff35145de21cf6296bec05e86bee37b5ed53bcb8': fix(test): verify followup completion ordering * test(auto-reply): signal queued presentation entry * chore: refresh followup test on boundary fix * commit '66b812f26e725cd709e08860d2cb46ba496cd308': (70 commits) fix(gateway): preserve typed boxed-number coercion chore(ui): refresh control ui locales (#158689) fix(gateway): reset staged headers on authority errors (#158669) fix(workers): keep inbound staging stable during quota scans fix: preserve Telegram delivery after bot identity changes (#158612) fix(ui): keep automation starter prompts out of startup (#158482) fix(cli): distinguish configuration read failures from invalid input (#158671) test: remove retired progress coercion suppression allowance refactor(gateway): schedule worker placement maintenance (#158662) fix(daemon): keep native service checks within their timeout (#154565) fix(test): restore gateway steering fixture contracts (#158478) fix(acpx): use SDK filesystem publication boundary fix(agentsapi): load OpenClaw persona and workspace context (#158328) fix(gateway): drop progress snapshot coercion suppression fix(qa): accept native Codex truncation in cache evidence (#158454) fix(gateway): keep chat subscriptions stable during unrelated approvals (#158633) perf(gateway): release event payloads from live text guards (#158643) perf(sessions): reduce stalls when saving large chat messages (#158402) fix(qa): reject history-bearing utility requests without session affinity (#158496) test: allow intentional progress snapshot coercion ... Co-authored-by: Vincent Koc <[email protected]>
* fix(test): verify followup completion ordering Exercise the real presentation settlement helper with asynchronous cleanup, preserve continuation and admission semantics, and unconditionally release and join the held work. Remote proof covers the strengthened ordering contract and both missing-await faults. * fix(test): verify followup completion ordering * chore: retain followup test branch ancestry The current-main reconstruction preserves the original reviewed scope and supersedes its stale base. Keep the remotely qualified candidate tree unchanged while retaining the original PR ancestry for a non-force branch update. * commit 'ff35145de21cf6296bec05e86bee37b5ed53bcb8': fix(test): verify followup completion ordering * test(auto-reply): signal queued presentation entry * chore: refresh followup test on boundary fix * commit '622be54be3ffe0fce27d6a4b147c76d4b19c528c': (70 commits) fix(gateway): preserve typed boxed-number coercion chore(ui): refresh control ui locales (openclaw#158689) fix(gateway): reset staged headers on authority errors (openclaw#158669) fix(workers): keep inbound staging stable during quota scans fix: preserve Telegram delivery after bot identity changes (openclaw#158612) fix(ui): keep automation starter prompts out of startup (openclaw#158482) fix(cli): distinguish configuration read failures from invalid input (openclaw#158671) test: remove retired progress coercion suppression allowance refactor(gateway): schedule worker placement maintenance (openclaw#158662) fix(daemon): keep native service checks within their timeout (openclaw#154565) fix(test): restore gateway steering fixture contracts (openclaw#158478) fix(acpx): use SDK filesystem publication boundary fix(agentsapi): load OpenClaw persona and workspace context (openclaw#158328) fix(gateway): drop progress snapshot coercion suppression fix(qa): accept native Codex truncation in cache evidence (openclaw#158454) fix(gateway): keep chat subscriptions stable during unrelated approvals (openclaw#158633) perf(gateway): release event payloads from live text guards (openclaw#158643) perf(sessions): reduce stalls when saving large chat messages (openclaw#158402) fix(qa): reject history-bearing utility requests without session affinity (openclaw#158496) test: allow intentional progress snapshot coercion ... Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Worker placement uses a private recurring interval for reconciliation and disk sampling.
Change
Require the kernel scheduler and register reconciliation and disk sampling separately, preserving disk checks while reconciliation is stalled. Delete the host interval and its clearInterval plumbing. Existing startup recovery, event-driven reconciliation, idle reclaim and resource-drain ordering remain.
One scheduler instance per Gateway process, enforced by types. No private production constructor or standalone entry point is introduced.
Existing installs need no migration or operator action. Existing stores, configuration, ports, RPCs and public SDK contracts are unchanged. This timer-only slice adds no database access, schema or transaction boundary. Independent worker-thread lease heartbeats and per-operation timeouts remain unchanged.
Production: +35 / -25 / net +10. Tests/support: +99 / -25 / net +74. Docs: +0 / -0 / net 0. Required dependency/registration plumbing accounts for the growth; no unrelated cleanup offsets it.
Stack
Evidence
Current head
9eb2cc54be0b5969afa28ac055ccf3963c85e7b1passed refreshed exact-head proof onblacksmith-testbox, leasetbx_01m3e2nta4ngefyyk0dsf55cr4, run 36220641511. Frozen dependency install, commit/tree/clean checkout, and unchanged source after testing were verified. All 10 files / 84 cases passed; summed per-file command wall 200.266s.src/gateway/server-worker-placement-startup.test.tssrc/gateway/server-worker-placement-session-events.test.tssrc/gateway/server-worker-placement-recovery-events.test.tssrc/gateway/server-worker-placement-startup-cleanup.test.tssrc/gateway/server-worker-placement-startup-maintenance.test.tssrc/gateway/server-worker-placement-provision-cancellation.test.tssrc/gateway/server-worker-placement-resume.test.tssrc/gateway/server-worker-placement-move-barrier.test.tssrc/gateway/worker-workspace-recovery-binding.test.tssrc/gateway/server.worker-placement-startup-context.test.tsThe scheduler range-diff is identical. Intervening main changes to bundle retention and awaited turn release were inspected; existing shutdown joins remain intact.
The previous lease completed before an SSH refresh attempt, which ran no tests. It is verified stopped with no IP. Earlier baseline and review evidence follows.
blacksmith-testbox, leasetbx_01m3dnnvze1jmxvx1wa5ez2yb1, run 36208976081: isolated detached source rooted atfa7cedf4f2c10e042cb0e9927112b894d42f7b52, frozen install, owner baseline, then exact candidate patch/tree87820961e996c9a2c0e30b8fa447300bdc828ede. Commit, clean baseline, patch bytes, full tree and unchanged source after testing were verified. Each file usedpnpm test <file> --maxWorkers=1afterpnpm install --frozen-lockfile.Candidate: 10 files / 84 cases passed; 192.706s summed command wall. Baseline owner files passed 24 cases. No performance improvement is claimed from sequential cold/warm order.
src/gateway/server-worker-placement-startup.test.tssrc/gateway/server-worker-placement-session-events.test.tssrc/gateway/server-worker-placement-recovery-events.test.tssrc/gateway/server-worker-placement-startup-cleanup.test.tssrc/gateway/server-worker-placement-startup-maintenance.test.tssrc/gateway/server-worker-placement-provision-cancellation.test.tssrc/gateway/server-worker-placement-resume.test.tssrc/gateway/server-worker-placement-move-barrier.test.tssrc/gateway/worker-workspace-recovery-binding.test.tssrc/gateway/server.worker-placement-startup-context.test.tsThe first Codex pass raised a generic pending-job concern. Complete tracing showed reconciliation, recovery, disk, idle, retention and transcript-worker operations already joined before environment teardown; a second independent pass with that context was clean through P2. No speculative production join or mock-only regression was added. Deslop, cross-shard caller inspection, formatting and whitespace checks passed. The sparse full-index review tree and selected patch exactly matched full source before commit. Existing integration files retain their real lifecycle/storage contracts; no new per-test Gateway boot was added. Per-file hosted CI cost remains pending publication.
GitHub's enforced CI gate supplies changed-file validation. Final merged-main maintenance/cron/suspend/restart/shutdown live proof follows the last stack slice.