Repository navigation
refactor(gateway): schedule media maintenance with the kernel - #159126
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. |
bb57042 to
bce298b
Compare
|
Codex review: blocked before merge. Reviewed September 26, 2026, 4:55 PM ET / 20:55 UTC. ClawSweeper reviewWhat this changesMoves delivery-queue, playback-cache, managed-outgoing, and general media cleanup onto the Gateway kernel scheduler and updates maintenance tests. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 5 items remain Keep open. Current main has not made this media lifecycle cutover, but the proposed patch lets a stuck cleanup block whole-Gateway shutdown beyond the existing five-second watchdog. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway starts maintenance after readiness and uses its kernel scheduler to wake cleanup work. Cleanup prunes queue and attachment media; shutdown must join or safely retain running work before shared state closes. flowchart LR
A[Gateway ready] --> B[Kernel scheduler]
B --> C[Queue cleanup]
B --> D[Playback and outgoing cleanup]
B --> E[General media cleanup]
C --> F[Media stores]
D --> F
E --> F
G[Gateway shutdown] --> B
B --> H[Cleanup drain]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource -53, Tests +10. Total -43 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Let the kernel scheduler own media wakeups while the existing cross-generation media drain owns bounded shutdown custody, retaining shared state until late cleanup settles. Do we have a high-confidence way to reproduce the issue? Yes, by source: leave a scheduled media cleanup pending past five seconds, then close the Gateway; scheduler.stop still awaits that callback. This read-only review did not execute the scenario. Is this the best way to solve the issue? No. Central scheduling is a suitable wakeup owner, but the patch also moves running media work into an unbounded shutdown join; the bounded media drain must retain that custody. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 19c6ef8d9e02. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
bce298b to
1a8f126
Compare
What Problem This Solves
Delivery-queue media and general media cleanup maintain private timers and duplicate pending-work bookkeeping.
User Impact
Media cleanup keeps its existing hourly policy, independently schedules each cleanup owner, and joins running work on stop. A stuck prior generation still defers only media cleanup; the existing five-second stop watchdog and shared-state drain custody remain.
Why This Change Was Made
Register delivery-queue media, playback cache, managed outgoing media and general media cleanup as separate jobs. Remove the media interval, lazy-promise wrappers, delivery cleanup timestamp polling and duplicate in-flight/start promises. Existing queue/tombstone and attachment policies remain unchanged.
One scheduler instance per Gateway process, enforced by types. No private fallback or standalone scheduler constructor is introduced. Existing state, configuration, spools and ports remain unchanged on update. No storage, schema, config, SDK or RPC contract changes are required.
Production +49/−102/net −53; tests +32/−22/net +10; docs +0/−0/net 0. This slice depends on the periodic maintenance scheduler injection.
Evidence
Publication head
bb5704274e6ce769ebb323bd07752784bde45af1. The reviewed media patch applies unchanged after periodic maintenance; newer main's first-hour worktree policy and its tests remain intact. Independent Codex P2 review, deslop, whitespace and caller closure passed.Blacksmith-testbox lease
tbx_01m3f70jxsg7e3036jppdwwv8j, run 36253776173: all three media files passed (45 cases, 36.508s command wall) on exact treec2a5feaba852172869afdb88b440e2ff0dcd25c1, following the proven periodic composition.Current-parent proof used blacksmith-testbox lease
tbx_01m3fe5xws0vqv7gvgg8bg9q61, run 36261201574, frozen install and exact tree116f5484fe92c41e16025484e8fbec4672b563d0. All 45 cases passed again, with source verified clean before and after. Each row ispnpm test <file> --maxWorkers=1:src/gateway/server-maintenance.test.tssrc/gateway/server-maintenance.delivery-queue.test.tssrc/gateway/server-maintenance.telemetry.test.tsSum: 39.58s. Prior periodic-phase measurements for these files were 21.396s, 8.086s and 3.536s; these command costs include setup and are not a performance comparison. Coverage retains hourly execution, TTL/default branches, independent cleanup, in-flight non-overlap, previous-generation custody and shutdown joins. No new sleeps or Gateway boots were added. Publication rebase preserves the reviewed patch. GitHub's enforced
openclaw/ci-gatesupplies changed-file validation; final merged-stack live proof follows the last slice.CI checkpoint: exact-head run 36266641884 failed its core-test type lanes with TS2741: three newly landed cron fixtures omitted the required scheduler (
ops-lifecycle.start-arm.test.ts,cron.history-publication.test.ts,cron.history.test.ts). The remaining red lanes were fail-fast cancellations. The fixture correction is now on main in c0e6951d6f02, with ancestry verified. This PR has not yet been rebased or rechecked after that fix. The stack is paused at the maintainer's reviewed-design boundary because a separate, unlanded session-delivery slice needs an elapsed-preemption contract correction. This existing auto-merge request remains armed; no passing current-head CI is claimed.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 is the media cleanup slice after periodic maintenance #159111. Merged predecessors also include task #159038, generation #159042, post-ready #159047, approval #159081, cold storage #159088, outbound recovery #159096, cron due #159099, and foreign receipts #159114.
Remaining reviewed work includes diagnostic/SDK lifetimes, session delivery, update watchers and cron system-job retry. Final timer exceptions and the merged-main Gateway/cron/suspend/shutdown proof follow the last slice.