Repository navigation
refactor(gateway): schedule approval deadlines with the kernel - #159081
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: needs maintainer review before merge. Reviewed September 26, 2026, 1:57 PM ET / 17:57 UTC. ClawSweeper reviewWhat this changesThe branch moves Gateway approval expiry and resolved-entry cleanup onto the existing Gateway scheduler and updates the approval tests to use scheduler clocks. Merge readiness✅ Ready for maintainer review This is a distinct, still-useful Gateway scheduler migration. Current main retains private approval timers, and the reviewed production path shows no merge-blocking defect. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway receives execution and plugin approval requests, records them in its approval store, and keeps local waiters for decisions. Scheduled wakes expire unanswered requests and clean up resolved local bindings. flowchart LR
A[Approval request] --> B[Gateway approval manager]
B --> C[Durable approval store]
B --> D[Gateway scheduler]
D --> E{Deadline or grace wake}
E --> B
B --> F[Decision or local cleanup]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +4, Tests +116. Total +120 across 25 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the durable approval store responsible for decisions and deadlines while the Gateway scheduler owns wakes and shutdown joining. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR consolidates timer ownership rather than reporting a user bug. Current main’s private timer path is visible in source. Is this the best way to solve the issue? Yes. Reusing the kernel scheduler and retaining the approval store as the decision owner is a narrow fit for this refactor. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5a27fda95008. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
What Problem This Solves
Approval expiry and resolved-entry cleanup arm private timers outside the Gateway scheduler’s lifetime.
User Impact
Approval deadlines and handoff grace retain their existing decisions, persistence, and cancellation behavior. The Gateway scheduler now owns their wakes and shutdown settlement. Existing installs need no migration: prior-epoch approvals still close through the existing startup recovery path, without restoring executable authority from stored rows.
Why This Change Was Made
Require the kernel scheduler through auxiliary handlers and each approval manager. The existing pending entry owns named expiry and cleanup jobs derived from its authoritative deadline. Remove
scheduleExpiryTimer, pending-entry timer handles, and theirsetTimeout/clearTimeoutplumbing. Definite-refusal retries retain captured persistence authority; uncertain outcomes retain their existing recovery path.One scheduler instance per Gateway process, enforced by types. No standalone constructor or hidden fallback is added. There are no schema, transaction, retention, config, SDK, RPC, or port changes. Current authority guards, durable first-answer decisions, handoff custody, and store threading remain unchanged.
Strict LOC: production +47/−43/net +4; tests +266/−150/net +116; docs +0/−0/net 0. The 506 changed lines include complete constructor closure and replacement of both bespoke timer-test fixtures with the shared scheduler clock.
Evidence
Publication head:
f9f3a4fa9a50abd7a3a4851ea3a56bde15796b1a. Current-head focused proof and exact-head CI: The three changed-main fixtures passed on the refreshed composition below; exact-head GitHub CI attaches on publication. The rebase preserves the same stable patch ID and unchanged approval owners/fixtures.. The evidence below is prior candidate proof, not a claim that the refreshed head has run.Blacksmith-testbox lease
tbx_01m3er4ym3e4e69mfkcyc84m7t, run 36239456451: all 360 cases across 16 approval candidate files passed afterpnpm install --frozen-lockfile. Tested base4543ce2515ef27e460d3545ac6c2675f483ad49c, candidate treeb391a0dfadd3b080374b8ec7a5250d248192f0db, patch SHA256bee7641ce52d33f22b6788ccc9b6502467e10cd1e0abe4b6021fa5720d91785e. These commands completed before the operator interrupted a later, unrelated post-ready baseline; no completion of that broader run is claimed.The refresh onto
be46e6966c2b52c6cde06abf965c44f9a175a47fpreserves every added/deleted code line and byte-identical production files. Its only conflict combines main’sExecApprovalRecordtest-helper import with the shared scheduler import. Main’s removed redundant cases remain removed. The full six-root caller census confirms required scheduler forwarding and no remainingscheduleExpiryTimerreference. The prior Codex P2 review (one round, two passes, zero findings) remains applicable; deslop and whitespace checks passed. Refreshed proof on blacksmith-testbox leasetbx_01m3f70jxsg7e3036jppdwwv8j, run 36253776173, verified treefb01adfddf054f671da848cc36927764cd8c676d: all three changed-main fixtures passed (104 cases, 87.41s summed command wall), usingpnpm test <file> --maxWorkers=1.exec-approval-manager.test.ts: 55 cases/37.93s;server-aux-handlers.test.ts: 19/23.17s;server-methods/approval-shared.test.ts: 30/26.31s. Their upstream test pruning is preserved; no new Gateway boots were added. GitHub’s enforcedopenclaw/ci-gatesupplies changed-file validation.The owner tests cover expiry publication, wall-clock rollback, handoff retention, stale wakes, cancellation, captured persistence on refused writes, and uncertain outcomes. No new Gateway boot, sleep, polling loop, or per-file clock implementation was added. Final merged-stack Gateway/cron/suspend/shutdown proof follows the last slice.
Recorded per-file test costs
Each row used
pnpm test <target> --maxWorkers=1. Wall time includes wrapper/build setup; no performance improvement is claimed.src/gateway/desktop/computer-authority.runtime.test.tssrc/gateway/exec-approval-manager.expiry.test.tssrc/gateway/exec-approval-manager.lifetime.test.tssrc/gateway/exec-approval-manager.test.tssrc/gateway/node-invoke-plugin-policy.test.tssrc/gateway/operator-approval-mcp-grants.test.tssrc/gateway/operator-approval-session-events.test.tssrc/gateway/operator-approval-standing-grants.test.tssrc/gateway/server-aux-handlers.authority.test.tssrc/gateway/server-aux-handlers.test.tssrc/gateway/server-aux-methods.test.tssrc/gateway/server-methods/approval-shared.storage-failure.test.tssrc/gateway/server-methods/approval-shared.test.tssrc/gateway/server-methods/approval.request-authority.test.tssrc/gateway/server-methods/approval.settlement.test.tssrc/gateway/server-methods/system-agent-approval.test.tsScheduler stack
Merged foundations: diagnostics #157517, auth naming #158275, kernel scheduler #158423, event-loop health #158531, channel health #158537, mention expiry #158614, upstream monitor #158617, worker placement #158662, idle/prewarm #158666, Incognito expiry #158690, OAuth #158717, and initial lifetime maintenance #158727.
Other published slices: worker reconciliation #158812, PR subscriptions #158821. Subsequent update/Gmail/metadata/audit links: update checks #158909, Gmail #158913, metadata #158959, and audit #158982 are merged. Task maintenance #159038 is pending; generation #159042 and post-ready #159047 are merged.. This slice migrates approval deadlines.
Later slices cover outbound recovery, session delivery, update watcher/campaign, task and cold-storage maintenance, diagnostics/auth/MCP lifetime, generation and post-ready maintenance, periodic/media cleanup, and cron due/receipt/system jobs. Final cleanup removes superseded plumbing and records timer exceptions before merged-main live proof.