Repository navigation
refactor(cron): keep occurrence authority fixed after admission - #201377
Conversation
- Capture recovered operator policy once while retaining cancellation, release and physical-source fences. - Recheck recovered policy only at explicit queued starts and refuse changed model-policy snapshots. - Remove in-flight occurrence generation and message-policy mutation vetoes; preserve queued on-exit admission. - Checkpoint before stacking on the admitted-authority reauthorization contract; final validation follows integration.
- Keep the mixed ingress signal listener because it includes service stop, Gateway closure and plugin disposal. - Leave separation of ingress policy signals outside this occurrence-authority change.
- Update explicit scope-closure refusals to the owning released capabilities. - Keep captured occurrence grants across marker retirement while refusing a fresh capture. - Preserve exact self-removal fencing of replacement markers.
… work - Check current shared-auth generation at recovered readmission and reauthorize distinct continuation starts. - Preserve admitted writes while rejecting future starts after durable device and policy revocation. - Update obsolete recovery expectations and explicit resource-release coverage.
- Reauthorize recovered operator authority once before the first runtime admission starts. - Keep cached retries and fallbacks on their original admitted authority. - Extend the fallback regression to reject a revoked fresh request without aborting the running holder. - Verified the owner unit suite and all twelve cron failure-repair final-effect cases, including queued device revocation.
- Reauthorize the current principal policy without invoking an expired origin-claim assertion. - Keep normal start assertions and explicit origin Stop cancellation before runtime admission. - Prove a closed original connection can start, while Stop and role revocation refuse; preserve origin-scope closure checks. - Verified seven focused recovery cases and isolated snapshot/authorized queued-child controls.
- Keep abandonment as generic fallback so recorded admission failures remain visible. - Let in-flight merges finish after role changes while fresh restoration refuses. - Check published policy changes without depending on a prior restoration to invalidate cached role policy.
- Treat the not-admitted placeholder as generic fallback, like abandonment. - Both principal early-refusal regressions retain their specific reasons on parent and head.
- Route recovered operator authorization failures before provider auth heuristics. - Measure model admission rather than synthetic runner entry in continuation refusal proof.
|
🦞👀 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. What this changesThis PR preserves admitted cron and recovered operator authority until completion and rechecks authority when new work starts. Example: An automation's owner is demoted while its model-requested exec command sleeps.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 4 items remain Keep open: this maintainer-authored PR addresses demonstrated interruptions, but recovered queued starts can retain newly forbidden models, and the consumer tests and documentation need a complete cutover. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherCron and Gateway recovery restore authenticated operator snapshots into authority used by agent admission, queued turns, model selection, and tool effects. flowchart TD
A[Stored operator snapshot] --> B[Recovery admission]
B --> C[Captured authority]
C --> D[Running occurrence]
D --> E[Model and tool effects]
C --> F[Queued request]
F --> G[Start reauthorization]
G --> E
Technical reviewBest possible solution: Keep admitted authority fixed, compare resolved model membership at recovered starts using the existing model-policy owner, and finish the consumer cutover. Do we have a high-confidence way to reproduce the issue? Current-main subscriptions explain the reported interruption, and the supplied isolated-Gateway observations exercise it; this review executed no target code. Is this the best way to solve the issue? The existing recovery and admission owners are appropriate, but comparing configured policy alone misses derived model restrictions that the direct Gateway owner already handles. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 646bfd36d9d7. Provenance checked
TestingProof path: shipped entry point. SecurityNeeds attention: Recovered model admission misses a current-policy restriction when allowed models change through sourceAgent. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource -87, Tests +137, Docs 0. Total +50 across 18 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 18, 2026, 1:54 PM ET / 18:54 UTC. |
- Let admitted Access, Template Add, OCID, stream and child work finish after policy revocation; refuse fresh starts. - Preserve queued CLI refusals using their specific identity/source-policy diagnostics. - Keep provider reply settlement in its admitted creation request and verify explicit cleanup remains available after revocation.
The Goal product test waited for role revocation to cancel an admitted provider request, which #201377 correctly keeps alive under #197557. Release that response, prove it persists while the next Goal turn is refused, and separately verify Stop closes the provider and pauses the Goal with its interruption note. Preserve disclosure and scope checks. Production behavior is unchanged. Thanks @obviyus for #201377. Co-authored-by: Ayaan Zaidi <[email protected]>
…claw#201377) Problem: a running cron occurrence was aborted when its owner's role, device or membership changed (base: "Session event execution aborted"), because the restored operator authority subscribed to those changes and the occurrence re-checked its marker on every effect. Fix: a cron occurrence checks its owner's authority once when it is restored and starts; the running occurrence keeps that authority until it ends. Each new occurrence, queued child and replayed follow-up re-checks once at its own start (`reauthorize`, the person's current authority, never socket liveness). Job removal, explicit Stop, cancellation and release still end the occurrence. Refusals keep their specific reason instead of a generic "abandoned"/sign-in message. User impact: editing a job or the owner's role while an occurrence runs applies to the next occurrence instead of killing the current one; a revoked owner's next occurrence is refused with a clear reason. Proof: real Gateway from source with a real model: owner demoted while the occurrence's exec sleeps aborts it on base and finishes it on head; the next occurrence is refused on both. Regression tests cover first-start reauthorization, closed-connection starts, Stop, revocation, refusal reasons and the rewritten in-flight expectations. Builds on openclaw#201334. Co-authored-by: Ayaan Zaidi <[email protected]>
…1567) The Goal product test waited for role revocation to cancel an admitted provider request, which openclaw#201377 correctly keeps alive under openclaw#197557. Release that response, prove it persists while the next Goal turn is refused, and separately verify Stop closes the provider and pauses the Goal with its interruption note. Preserve disclosure and scope checks. Production behavior is unchanged. Thanks @obviyus for openclaw#201377. Co-authored-by: Ayaan Zaidi <[email protected]>
…ducers (O4a) 🌊's O4 ruling (a) pins, carried to the pure candidate (stage 2) from e88f3a9 (hop-2 -> hop-3 revocation through real Gateway wakes) and 9d8c242 (channel saved/live source and scheduled producers), both verbatim except the producer precondition below. Post-b894 upstream openclaw#201377 (ad550e9) changed the restored scheduled source: its admission is fixed once started (assertCurrent no longer sees a role change) and it now carries a reauthorize that re-checks the owner's current policy. The scheduled cases therefore assert reauthorize is present; the channel cases still assert it is absent, with assertCurrent live. Negative control on this tree: removing the wake's custody.operatorAuthority.reauthorize?.() call (5bd2723) turns the scheduled "role changed" and "device revoked" wakes into dispatched turns (expected failed) and reds the product file's revoked gate; the channel cases stay green. So for restored scheduled sources the wake-time reauthorize is now the load-bearing refusal, not assertCurrent. Producers 9/9, product file 3/3, durable-7 and session-reset-cleanup green. (cherry picked from commit e88f3a9) (cherry picked from commit 9d8c242) Refs openclaw#129388 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Release adaptation: extract the independent mixed-requester repair and its queue regression. Stable already strips display/owner flags but copies requester origin and the private owner capability. The wider saved-requester cutover needs the newer fixed-request and Cron occurrence authorities and the durable queue owner; do not replace the stable custody or restart contract. Companions: #203468 and #203521 are separate selected start-grant repairs. #201334, #201377, #200533 and #202318 are missing full-cutover prerequisites; #203516, #202522 and #202520 are later distinct lifetime refactors, not needed by the isolated mixed-requester repair. (cherry picked from commit 3ad2cce) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit a26e1e7b02425b94d31c3e6bc6add8d417dc3fda)
Problem
A cron occurrence restores its owner's authority successfully, then
restoreGatewayOperatorSnapshotsubscribes to role/profile/device/shared-auth/OCID/access-policy changes and revokes that same running occurrence. A real isolated Gateway reproduction demoted the owner while a model-requestedexeccommand slept: the base occurrence immediately failed withSession event execution aborted(recorded aserrorReason: timeout). That observed failure is not relabeled as a different log family.Root cause on base: the role-assignment subscription in
operator-run-recovery.ts:275–289callsrevokeat line 285, whose abort is at:98–105. Shared-auth/device listeners (:182–199) and profile notifications (:375) feed the same lifetime owner. The occurrence marker's independent repeated generation/map comparison isactive-jobs.ts:127; its explicit removal/cancellation branches (:128–129) remain.The logged T10 string is
followup queue: input withheld; refusing replay: Cron occurrence source authority is no longer active(12 baseline events). It was not reproduced by the real cron/yield or role-change probes. On base,captureCronJobSourceAuthorityemits its inner literal when the current marker differs (including generation retirement), when the job is removed without accepted self-removal, or when cancellation was requested. A standing-grant owner failure is forwarded separately. On this change, the captured callback no longer compares the active-marker map/generation; removal and explicit cancellation can still emit the exact literal. Fresh capture still requires an active occurrence. Historical T10 causation remains unproven.The original tool-caller/T05 investigation was stopped by the lead after three current-main real-Gateway compaction flows passed. Its chronology, proof limits and
watch after next deployfinding are retained at../refactor-check-once-tool-caller/body.md; this branch does not claim a T05 fix.Rule
Each occurrence checks its owner's current authority once when the occurrence starts. A running occurrence keeps its captured identity, scope/model ceiling and tool surface. Role/policy changes and job-definition edits apply to the next occurrence. Queued or replayed work checks again at its own start. Deleting/disabling a job or explicit Stop still cancels. Resource release, exact write ownership and command approvals remain authoritative.
Change
reauthorizefor fresh queued/replayed starts through PR 1's shared authority contract. It reruns the saved policy check without subscribing or aborting other holders when admission is refused. A configured model-policy object that differs from its captured copy at the new start, widening included, refuses that queued start; the user re-sends and a fresh request gets a fresh ceiling. This rare, visible, recoverable refusal avoids wildcard-subset machinery and never mutates an in-flight ceiling.Non-cron callers:
restoreGatewayQueuedOperatorRecovery's Gateway-source branch uses the same recovered owner, so queued native/restart work gets the same check-once rule;captureGatewayOperatorContinuationuses that path too. The separate channel-source recovery branch is intentionally unchanged per scope. No schema, stored-row or protocol change.Obsolete tests now let admitted writes and captured message grants finish, then refuse fresh restoration/readmission after revoked authority. Stop/release/deletion, pending admission and exact self-removal ownership remain covered. The accepted-child real-write regression moved from the oversized recovery test into its existing effects-test owner; its boundary coverage was retained. The scheduled-message transport matrix now exercises explicit admission closure/cancellation rather than using a policy edit as a synthetic Stop.
Threat model
reauthorizecall sites; a refused new start does not abort another running holder. Queued on-exit source-change admission remains intact.Remaining lifetime checks
The combined plugin-ingress recovery listener stays in this PR.
restoreIngressPrincipalRecoverycombines the ingress owner's service/Gateway/plugin-disposal signal with consent-grant and principal-admission policy signals. The owner signal includes real stop/close/dispose cancellation (service-control-ui-ingress.ts:38–43,59–63), so removing the combined listener wholesale would lose cancellation. Per the lead's explicit scope decision, ingress consent/admission signals can therefore still revoke a restored run; no logged refusal here was attributed to that path. The separately scoped next step is to expose the owner cancellation signal independently inremote-ingress-principal-recovery.ts, then stop forwarding policy invalidation into already-admitted work.Shared-auth-generation invalidation can include rotation of the Gateway authentication secret, including a rotation after a leak. Its post-admission subscription is deliberately removed under the same next-request rule: one already-admitted request may finish. Initial restoration and explicit queued-start reauthorization still check the recorded generation against the current required generation, so the old credential cannot start another request. Secret storage, redaction and credential ownership are unchanged.
Evidence
Source tier; real isolated Gateways launched with
ocx src, a real model via exec SecretRef, unique named profiles and loopback ports. The real model created an authenticated conversation-linked recurring automation through the real automations tool;cron.runstarted its occurrence. No authority predicate, Gateway handler or refusal was substituted.6ec27bd739c7users.setRolewhile real model-requestedexecsleepsSession event execution aborted; noS1_CRON_FINISHEDsessions_listcompleted; occurrencestatus: ok,summary: S1_CRON_FINISHEDThe operator authority that created this automation was refused ... Cause: Restart recovery operator identity changed.FORBIDDEN: missing scope: operator.writeEach occurrence waits for the previous one's terminal result before the next one starts. Earlier attempts where the model skipped the probe command, or where the harness asked for the next occurrence too early, are not counted as proof. All test Gateways and state were removed afterwards.
Integration and checks
Builds on #201334 (merged as
04cb8179ccd66c88f2b32eb8bca8c53d2e8b9cb5).Rebased the eight cron-only commits off
a8e5504847bbonto narrowed PR 1, added the typed-refusal correction, then rebased all nine commits onto merged main04cb8179ccd66c88f2b32eb8bca8c53d2e8b9cb5; all rebases were conflict-free. Current head:9db9ccc8dcc9ac7a25832832b00908b7fa792290, including the CI consumer-contract corrections. The narrowed base's runtime-guard, registry and approval ownership remains unchanged; none of the old PR 1-only lifecycle scope changes was reintroduced.04cb8179ccd66c88f2b32eb8bca8c53d2e8b9cb5: +57 / −144 (net −87; 201 lines touched) across eight runtime files.noteActiveCronJobMessageActionAuthorityMutation,cronJobMessageToolAuthorityInputsEqual,messageActionAuthorityRevoked, recovered-policy subscriptionrecheck, detacheddeviceRevocation/stopDeviceRevocation.reauthorizeredundantly. Both check current person authority, not socket liveness, before execution; neither installs a running-request policy check. Per the lead's explicit decision, this admission-time redundancy is retained rather than adding per-start deduplication/ownership machinery. The shared authority contract has no safe recovery-owner discriminator.Rebased-head proof
Proof tier: vitest-source, explicit files through
ocx test --maxWorkers=2; no build, push or autoreview. The CI repair replay ran all 19 affected/owner files, 307 cases: 305 passed, with one new expected-message mismatch and one paired-device Template Add timeout. After correcting the expected message, the final complete provider/Template Add replay passed 24/24. All 247 owner-suite cases below passed in the broad replay.operator-run-recovery*.test.tsfilessession-event-handoff.test.tsserver-cron-failure-repair.final-effect.test.tsadmitted-run-context.test.tsactive-jobs.test.tsmessage-tool.scheduled-lifetime.test.tsrun.operator-continuation.test.tscommands-plugin.scheduled-turns.test.tsThe recovery owner's closed-socket / explicit Stop / revoked-person table passes unchanged, as do pending preparation, retained accepted children and fresh continuation restoration.
Rebase integration findings
GatewayOperatorRecoveryAuthorizationErrorfrom first admission could enter provider-auth string classification and display an unrelated AI-service sign-in instruction. The execution error handler now routes that existing error type before provider classification. Both before-effect allowlist/auth-mode cases pass with specific reasons. Both passed unchanged on basea73eded68c45; this was an integration regression, not inherited red.queued→terminal; the same case passed alone on base and corrected head. Subsequent full infra replays passed, including all 50 handoff/commands cases on the merged-main head, with this child passing in 6.7 seconds. All 35 continuation cases also pass on that head. Its channel recovery branch is unchanged by this PR. Passing replay does not establish a production cause or a fix; no timeout increase, weakened assertion or speculative queue change was added.Static checks on merged main
tsgo:core: passed after the typed-refusal correction.tsgo:core:test: 29/29 shards passed for the CI consumer repair. Subsequent changes were formatting and an expected error string only. The inheritedqueue.authority.test.tstyping errors ona73eded68c45were corrected in refactor(gateway): keep operator authority fixed per request #201334 before merge.check:session-identity-ratchet: passed, 1615 files / 6415 grandfathered pins. The inheritedoperator-run-authority.tsbaseline shrink was corrected in refactor(gateway): keep operator authority fixed per request #201334 before merge.check:test-lines-ratchet: passed, +278 / 400.check:lifetime-check-ratchet: passed, 24 inventoried checks, no per-file growth against04cb8179ccd66c88f2b32eb8bca8c53d2e8b9cb5.CI consumer contract corrections
CI run
44371699265exposed additional consumers of the changed recovery contract:createWithRequest, rather than starting queued/replayed work. The test now requires that creation to finish, fresh source restoration to refuse, and explicit destruction to clean the allocation after the original authority is released. Lost-reply and bootstrap-cleanup tests retain their strict cleanup requirements.Consumer-file proof: Access 9/9, Template Add 12/12, OCID persistence 14/14, stream 2/2, child 7/7, CLI 4/4, provider recovery 12/12. The first paired-device Template Add replay timed out at the existing 120-second limit; its final full-file replay passed unchanged. That replay is not claimed as a timeout fix, and no timeout or assertion was weakened. Provider cleanup passed, including explicit destruction after release and the unchanged lost-reply/bootstrap-cleanup scenarios. No additional production change was necessary.