Repository navigation
refactor(admission): drop the replay automationAdmin bit and the R7 source re-check - #205268
Conversation
… source re-check - Delete the trigger/jobId fallback in automations-run-scope.ts; the admitted occurrence context owns a scheduled run's job scope. - Delete the replay automationAdmin output; an in-session scheduled run binds command-owner authority from its restored grant.owner. - The prepared session target no longer re-runs the run's source mid-run (source_authority_refused); target, Stop and run-lifetime fences stay. Co-authored-by: obviyus <[email protected]>
|
🦞👀 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. |
|
E2E on exact head
verdict.json: [{"id":"R.running-turn-finishes","pass":true},{"id":"Q.queued-input-refused-visibly","pass":true},{"id":"S.stop-cancels","pass":true}]results.jsonl: 28 records (kept with the PR worker proof). Local review on the same head: complete, "patch is correct", no findings. |
…scheduled runs A failed occurrence admission binds no context and the run still starts; the fallback is the only limit for that case until admission carries it. Co-authored-by: obviyus <[email protected]>
|
E2E on exact head [{"id":"R.running-turn-finishes","pass":true},{"id":"Q.queued-input-refused-visibly","pass":true},{"id":"S.stop-cancels","pass":true}]Local review on this head: complete, "patch is correct", no findings. This head restores the |
|
Codex review: needs maintainer review before merge. What this changesThis PR removes replay-specific administrator classification and stops rechecking requester policy during prepared transcript and context writes. Example: An admitted scheduled turn loses operator access while generating its response.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-directed simplification preserves admission as the permission owner, and no concrete introduced correctness or security defect was found. Reviewed head: Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway admission restores requester facts into a frozen turn grant; scheduled session turns consume that grant, and prepared write assertions preserve the run's lifetime and destination. flowchart TD
A[Saved requester source] --> B[Operator admission]
B --> C[Frozen turn grant]
C --> D[Scheduled session turn]
D --> E[Prepared target and lifetime fences]
E --> F[Transcript and context writers]
Technical reviewBest possible solution: Keep admission authoritative, consume grant.owner for scheduled owner binding, and preserve the existing target, storage, cancellation, and occurrence fences. Do we have a high-confidence way to reproduce the issue? Fetched-main source directly shows both the saved UI-delegation requirement and the repeated source assertion; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch is a small, coherent cutover to existing admission and lifetime owners, and retaining the trigger fallback is justified by the documented failed-admission path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 485c7dcac255. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -26, Tests -93. Total -119 across 14 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:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 25, 2026, 5:38 AM ET / 10:38 UTC. |
|
Landed as ca087d4.
|
…ource re-check (openclaw#205268) ## Problem OA2 PR 4e (DESIGN §4.7 and §4.12; the two steps openclaw#205173 split off). Two places still decided what a running scheduled turn may do outside admission: - **Replay `automationAdmin` output.** `decideOperatorAdmission` returned a second owner-like bit for replays: admin scope **and** a saved Control UI delegation. In-session scheduled runs (`runCronSessionTurn`) used it to decide whether the run carries its restored operator source and binds command-owner authority. Same admin, different answer depending on which client created the job. - **R7 mid-run re-check (`source_authority_refused`).** The prepared session target in `attempt-session-target.ts` re-ran the run's whole source assertion (operator access, policy grants, session-event config) on every transcript and context write during the run, and refused with `source_authority_refused` (REFUSALS R7, seen on Peanutto). Admission already checked that source once, at start. ## Fix - `automationAdmin` is deleted from the admission decision, `RestoredGatewayOperatorAuthority`, `ScheduledSessionAutomation` and the participation path. An in-session scheduled run now binds command-owner authority iff its restored grant is owner (`grant.owner`), the same rule restart and owner continuations already use. - `createPreparedSessionTargetAssertion` no longer calls the run's source. It keeps the selected-target fence (attempt, session identity, target fields), Stop and the run lifetime (`assertScopeCurrent`), and the session row predicates still reach the writer through `composeSessionSourceAssertion`. - **Pre-start session-event config check:** no split code needed. The session-event config policy already stops at `start()`; before start, a config publication that denies the selected model is refused by the start's own model-policy check, before any provider request. The integration test now asserts that refusal instead of probing it through the prepared target. ## Decisions (recorded, not asked) - **Widening (same principal, same answer):** an in-session scheduled run whose restored requester is an admin now binds command-owner authority even when the job was created outside the Control UI (remote CLI, TUI, native app). Same rule as openclaw#205173 for `grant.automations`. - **Stored rows unchanged:** the codec keeps writing/reading `automationAdmin`/`controlUiAdmin` on saved sources (no stored-row change); `hasAutomationAdminDelegation` keeps its two non-admission readers (`cron-job-turn-target.ts`, the control-edit refresh in `cron-operator-source.ts`). - **Cut less: the `automations-run-scope.ts` trigger fallback stays.** Every Gateway occurrence is admitted through `admitScheduledOccurrence`, but when that admission fails (`status: "fail"`), `bind()` binds no context and the run still starts. The fallback is then the only thing that keeps an unadmitted hook/event turn (no sender bit, owner surface) from getting the full automations tool, and a cron turn limited to its own job. Deleting it needs the failed occurrence to carry its scope from admission (or a refused start), which is a separate change. Found while running the pre-push set (the fallback's own suite asserts the unadmitted event case); I removed it on the first head, then restored it: not patched here. - **Accepted edge (AGENTS.md "a started request may finish"):** an operator whose access is revoked mid-run no longer has the run's transcript/context writes refused; Stop and the run lifetime still end it. ## Tests - Deleted (assert removed behavior): `run-attempt-dispatch.owner` "policy" case (mid-run access-policy revoke → `source_authority_refused`); `operator-run-recovery.native` "preserves legacy browser grants…" (only asserted the deleted `automationAdmin` output). - Changed: `run-attempt-dispatch.owner` now applies each invalidation directly and asserts the prepared target never calls the run's source (red on base: base calls it once); "source-closed" refuses through the run lifetime (`scope_authority_refused`). `run.operator-continuation` and `execution-context-owner-authority` fixtures now admit occurrences / build the Codex host on the run's admitted context, as the Gateway does, so their scope comes from admission rather than the fallback. ## Evidence - **Production lines** (`src`, non-test): +12 / −38 (net −26). - **Red on base, green on head:** `run-attempt-dispatch.owner.test.ts` invalidation cases now assert the prepared target never calls the run's source (`assertSourceCurrent` not called). On base the same case asserted it was called once (`toHaveBeenCalledOnce`), i.e. the R7 mid-run re-check. - **Pre-start refusal kept:** `session-run.session-model-strictness.integration.test.ts` "selected-model-denied": a config publication during target preparation that denies the selected model still ends the occurrence with `status: "error"`, `executionStarted: false` and zero provider requests; the error now names the policy (`Scheduled model "primary/model-a" is not allowed by agents.defaults.modelPolicy.allow…`). - **Scheduled scope:** `run.operator-continuation` (36/36, incl. self-removal and `next_check`) and `execution-context-owner-authority` (embedded, Codex and CLI surfaces equal) pass with the fixtures admitting occurrences like the Gateway. - **Pre-push:** one `ocx test` call over 81 files (touched tests + importers of every changed source/test-support + every test constructing cron tools with `trigger`/`jobId`): all green on the first head; after restoring the fallback, the fallback's own suite and the affected files rerun green. `pnpm tsgo:core` and `tsgo:test` clean (also after rebase on `5279ca48bbe1`); oxfmt/oxlint clean on changed files. - **E2E:** Q/R/S pass on both heads (`75ac48d68d24`, `4cddd31e0f21`); see the PR comments. Co-authored-by: Ayaan Zaidi <[email protected]>
…207947) ## Problem A started cron turn died when someone edited its job. Daily refusal watch, 2026-11-28: ``` [gateway] cron: job updated [agent/embedded] session target preparation refused reason=scope_authority_refused lane task error: lane=cron-nested durationMs=36667 error="Session target preparation outlived its attempt | This agent run is no longer active. Start a new turn to retry. | Automation operator source changed" ``` `captureCronJobTurnTarget` (`src/gateway/cron-job-turn-target.ts`) gave the session event target an `assertCurrent` that re-read the job on every fence check. It compared the stored `operatorSource` (or the scheduled requester) with the value captured at start. `cron.update` changes that value, so the next fence check threw. The run's `assertScopeCurrent` turned it into `scope_authority_refused`. The cron notice and failure-repair turns use this target. A repair turn that fixes its own job killed itself. Root `AGENTS.md` "Decide authority once" does not allow this: authority is checked once, when work starts. The only stop after start is a permission writer stopping a named person's work. Editing a job is neither. This is the same class as R7 `source_authority_refused` (removed in #205268). ## Change - Remove both job re-reads from `captureCronJobTurnTarget`: the operator-source comparison ("Automation operator source changed") and the scheduled-requester comparison ("Automation requester changed."). - The edited source applies from the next occurrence. Admission at that start decides it. - Kept: admission at start, data fences (attempt lifecycle, session identity, target fields), the run abort signal, and the cron remove/disable cancellation (active-job marker → run `AbortController`). - `scope_authority_refused` stays. The run-registry binding (`source-closed`) still produces it. `scripts/lib/no-operator-permission-read.mjs` lists no removed site. ## What the user sees A cron notice or repair turn finishes after the job is edited. Before, it failed with "This agent run is no longer active. Start a new turn to retry." ## Evidence - New test `keeps a started cron turn running when its job is edited` (`src/gateway/operator-run-recovery.effects.test.ts`). It uses the real `CronService`, `captureCronJobTurnTarget` and `prepareSessionEventTargetForHost`, then edits the stored job's `operatorSource`. - Base `848732ff`: red, `Error: Automation operator source changed`. - Head: green. - `ocx test` on the four test files that import `cron-job-turn-target.ts`: 35/35 pass. - `pnpm check:changed`: typecheck, lint, format and guards pass. The dead-export scan fails on base-only entries (`AgentCommandPluginIngressOpts`, `clearNativeRepositorySourceModulesForTest`, `resolveUpdateInstallSurfaceMock`). None of them are in this diff. - Live Gateway E2E (isolated Gateway, real `openai/gpt-5.5`, scratch state). Steps: the agent creates a cron job from chat with a 3 s timeout. `cron.run` fails, and the failure-repair turn starts in the owner session. The repair turn calls the cron tool to set `timeoutSeconds: 120` (`cron.update`), then runs one more `exec` and replies. - Base `848732ff`: the job edit lands, then the repair turn ends `state: error` with `Session target preparation outlived its attempt | This agent run is no longer active. Start a new turn to retry. | Automation operator source changed`. The Gateway log has `scope_authority_refused`. This is the incident. - Head `4d50bb57`: the job edit lands and the repair turn ends `state: final`. The log has no `scope_authority_refused`. - One-admission E2E Q/R/S on head `4d50bb57`: all PASS. Revoking access while work is queued refuses it visibly, revoking access while a turn runs stops it (`access-reduced`), and Stop cancels the turn. Production: −18/+6 lines. Test: +56/−1. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#207947) ## Problem A started cron turn died when someone edited its job. Daily refusal watch, 2026-11-28: ``` [gateway] cron: job updated [agent/embedded] session target preparation refused reason=scope_authority_refused lane task error: lane=cron-nested durationMs=36667 error="Session target preparation outlived its attempt | This agent run is no longer active. Start a new turn to retry. | Automation operator source changed" ``` `captureCronJobTurnTarget` (`src/gateway/cron-job-turn-target.ts`) gave the session event target an `assertCurrent` that re-read the job on every fence check. It compared the stored `operatorSource` (or the scheduled requester) with the value captured at start. `cron.update` changes that value, so the next fence check threw. The run's `assertScopeCurrent` turned it into `scope_authority_refused`. The cron notice and failure-repair turns use this target. A repair turn that fixes its own job killed itself. Root `AGENTS.md` "Decide authority once" does not allow this: authority is checked once, when work starts. The only stop after start is a permission writer stopping a named person's work. Editing a job is neither. This is the same class as R7 `source_authority_refused` (removed in openclaw#205268). ## Change - Remove both job re-reads from `captureCronJobTurnTarget`: the operator-source comparison ("Automation operator source changed") and the scheduled-requester comparison ("Automation requester changed."). - The edited source applies from the next occurrence. Admission at that start decides it. - Kept: admission at start, data fences (attempt lifecycle, session identity, target fields), the run abort signal, and the cron remove/disable cancellation (active-job marker → run `AbortController`). - `scope_authority_refused` stays. The run-registry binding (`source-closed`) still produces it. `scripts/lib/no-operator-permission-read.mjs` lists no removed site. ## What the user sees A cron notice or repair turn finishes after the job is edited. Before, it failed with "This agent run is no longer active. Start a new turn to retry." ## Evidence - New test `keeps a started cron turn running when its job is edited` (`src/gateway/operator-run-recovery.effects.test.ts`). It uses the real `CronService`, `captureCronJobTurnTarget` and `prepareSessionEventTargetForHost`, then edits the stored job's `operatorSource`. - Base `9e839f97`: red, `Error: Automation operator source changed`. - Head: green. - `ocx test` on the four test files that import `cron-job-turn-target.ts`: 35/35 pass. - `pnpm check:changed`: typecheck, lint, format and guards pass. The dead-export scan fails on base-only entries (`AgentCommandPluginIngressOpts`, `clearNativeRepositorySourceModulesForTest`, `resolveUpdateInstallSurfaceMock`). None of them are in this diff. - Live Gateway E2E (isolated Gateway, real `openai/gpt-5.5`, scratch state). Steps: the agent creates a cron job from chat with a 3 s timeout. `cron.run` fails, and the failure-repair turn starts in the owner session. The repair turn calls the cron tool to set `timeoutSeconds: 120` (`cron.update`), then runs one more `exec` and replies. - Base `9e839f97`: the job edit lands, then the repair turn ends `state: error` with `Session target preparation outlived its attempt | This agent run is no longer active. Start a new turn to retry. | Automation operator source changed`. The Gateway log has `scope_authority_refused`. This is the incident. - Head `4d50bb57`: the job edit lands and the repair turn ends `state: final`. The log has no `scope_authority_refused`. - One-admission E2E Q/R/S on head `4d50bb57`: all PASS. Revoking access while work is queued refuses it visibly, revoking access while a turn runs stops it (`access-reduced`), and Stop cancels the turn. Production: −18/+6 lines. Test: +56/−1. Co-authored-by: Ayaan Zaidi <[email protected]>
…207947) ## Problem A started cron turn died when someone edited its job. Daily refusal watch, 2026-11-28: ``` [gateway] cron: job updated [agent/embedded] session target preparation refused reason=scope_authority_refused lane task error: lane=cron-nested durationMs=36667 error="Session target preparation outlived its attempt | This agent run is no longer active. Start a new turn to retry. | Automation operator source changed" ``` `captureCronJobTurnTarget` (`src/gateway/cron-job-turn-target.ts`) gave the session event target an `assertCurrent` that re-read the job on every fence check. It compared the stored `operatorSource` (or the scheduled requester) with the value captured at start. `cron.update` changes that value, so the next fence check threw. The run's `assertScopeCurrent` turned it into `scope_authority_refused`. The cron notice and failure-repair turns use this target. A repair turn that fixes its own job killed itself. Root `AGENTS.md` "Decide authority once" does not allow this: authority is checked once, when work starts. The only stop after start is a permission writer stopping a named person's work. Editing a job is neither. This is the same class as R7 `source_authority_refused` (removed in #205268). ## Change - Remove both job re-reads from `captureCronJobTurnTarget`: the operator-source comparison ("Automation operator source changed") and the scheduled-requester comparison ("Automation requester changed."). - The edited source applies from the next occurrence. Admission at that start decides it. - Kept: admission at start, data fences (attempt lifecycle, session identity, target fields), the run abort signal, and the cron remove/disable cancellation (active-job marker → run `AbortController`). - `scope_authority_refused` stays. The run-registry binding (`source-closed`) still produces it. `scripts/lib/no-operator-permission-read.mjs` lists no removed site. ## What the user sees A cron notice or repair turn finishes after the job is edited. Before, it failed with "This agent run is no longer active. Start a new turn to retry." ## Evidence - New test `keeps a started cron turn running when its job is edited` (`src/gateway/operator-run-recovery.effects.test.ts`). It uses the real `CronService`, `captureCronJobTurnTarget` and `prepareSessionEventTargetForHost`, then edits the stored job's `operatorSource`. - Base `848732ff`: red, `Error: Automation operator source changed`. - Head: green. - `ocx test` on the four test files that import `cron-job-turn-target.ts`: 35/35 pass. - `pnpm check:changed`: typecheck, lint, format and guards pass. The dead-export scan fails on base-only entries (`AgentCommandPluginIngressOpts`, `clearNativeRepositorySourceModulesForTest`, `resolveUpdateInstallSurfaceMock`). None of them are in this diff. - Live Gateway E2E (isolated Gateway, real `openai/gpt-5.5`, scratch state). Steps: the agent creates a cron job from chat with a 3 s timeout. `cron.run` fails, and the failure-repair turn starts in the owner session. The repair turn calls the cron tool to set `timeoutSeconds: 120` (`cron.update`), then runs one more `exec` and replies. - Base `848732ff`: the job edit lands, then the repair turn ends `state: error` with `Session target preparation outlived its attempt | This agent run is no longer active. Start a new turn to retry. | Automation operator source changed`. The Gateway log has `scope_authority_refused`. This is the incident. - Head `4d50bb57`: the job edit lands and the repair turn ends `state: final`. The log has no `scope_authority_refused`. - One-admission E2E Q/R/S on head `4d50bb57`: all PASS. Revoking access while work is queued refuses it visibly, revoking access while a turn runs stops it (`access-reduced`), and Stop cancels the turn. Production: −18/+6 lines. Test: +56/−1. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 7895017) Release adaptation: Remove the mutable job-source assertions while retaining beta.2 requesterOwner and delegated ownerContinuation option shapes; preserve the existing source-conversation fence. Co-authored-by: RomneyDa <[email protected]>
…chiving (#205026) * fix(sessions): keep inactive chats eligible for cold storage after archiving * test(sessions): align archive fixtures and identity baseline * test(sessions): create a private cold backup restore target (cherry picked from commit 81d69df) Follow-ups: 7cb8975 fix: keep forked Claude chats separate after a Gateway crash (#208048) [separately ordered lane row]; ece7a74 improve(workboard): apply the Control UI glossary and style to Workboard copy [not selected for this narrow backport]; b616036 refactor(subagents): simplify ACP spawn relay ownership (#207023) [not selected for this narrow backport]; 93ca762 improve: reduce allocations when preparing session rows (#207109) [not selected for this narrow backport]; 9993328 refactor(subagents): simplify kill claim and ownership handling (#207025) [not selected for this narrow backport]; 97815bd refactor(subagents): consolidate registry cleanup and publication guards (#207064) [not selected for this narrow backport]; e94f799 refactor(subagents): centralize requester turn matching (#206584) [not selected for this narrow backport]; ea77ca3 refactor: report update failures from recorded runs (#206700) [not selected for this narrow backport]; 4d7e00b fix: let started participant runs and requests finish after an access change (#206747) [not selected for this narrow backport]; f89ae43 refactor(subagents): use cleanup and terminal owners in sweeps (#206533) [not selected for this narrow backport]; a882e0f fix(agents): preserve task answers when sessions are reused (#126263) [not selected for this narrow backport]; 81fc833 refactor(subagents): own dormant child Stop decisions (#206479) [not selected for this narrow backport]; 91d4912 fix(update): stop using foreign recovery records as admission (#206295) [not selected for this narrow backport]; be3c73e fix(subagents): finish claimed stops after session rotation (#206405) [not selected for this narrow backport]; ed8b883 fix(update): settle after plugins and share one completion summary (#205987) [not selected for this narrow backport]; 1de306e fix: pause interrupted shell turns when their result is unknown (#205859) [separately ordered lane row]; 16a6aa4 fix(memory): keep a child's memory audience after its parent resets (#205887) [not selected for this narrow backport]; 50a7368 feat: let agents snooze a conversation after replying [not selected for this narrow backport]; 40f3903 fix(ci): remove unused role and workflow exports (#205720) [not selected for this narrow backport]; e43debf refactor(state): migrate in place and remove copy-and-swap (#205165) [not selected for this narrow backport]; 8027293 refactor(plugins): plugin tools take the turn's owner bit; delete the requester-owner continuation (OA2 PR 6j) (#205483) [not selected for this narrow backport]; 13e2ec3 feat: let participants publish through the session's shared GitHub account (#204914) [not selected for this narrow backport]; 5434992 fix: use the configured runtime when switching model providers (#203973) [not selected for this narrow backport]; 5271519 fix(feishu): honor the filename override on sent attachments (#205287) [not selected for this narrow backport]; ca087d4 refactor(admission): drop the replay automationAdmin bit and the R7 source re-check (#205268) [not selected for this narrow backport] Co-authored-by: RomneyDa <[email protected]>
…207947) A started cron turn died when someone edited its job. Daily refusal watch, 2026-11-28: ``` [gateway] cron: job updated [agent/embedded] session target preparation refused reason=scope_authority_refused lane task error: lane=cron-nested durationMs=36667 error="Session target preparation outlived its attempt | This agent run is no longer active. Start a new turn to retry. | Automation operator source changed" ``` `captureCronJobTurnTarget` (`src/gateway/cron-job-turn-target.ts`) gave the session event target an `assertCurrent` that re-read the job on every fence check. It compared the stored `operatorSource` (or the scheduled requester) with the value captured at start. `cron.update` changes that value, so the next fence check threw. The run's `assertScopeCurrent` turned it into `scope_authority_refused`. The cron notice and failure-repair turns use this target. A repair turn that fixes its own job killed itself. Root `AGENTS.md` "Decide authority once" does not allow this: authority is checked once, when work starts. The only stop after start is a permission writer stopping a named person's work. Editing a job is neither. This is the same class as R7 `source_authority_refused` (removed in #205268). - Remove both job re-reads from `captureCronJobTurnTarget`: the operator-source comparison ("Automation operator source changed") and the scheduled-requester comparison ("Automation requester changed."). - The edited source applies from the next occurrence. Admission at that start decides it. - Kept: admission at start, data fences (attempt lifecycle, session identity, target fields), the run abort signal, and the cron remove/disable cancellation (active-job marker → run `AbortController`). - `scope_authority_refused` stays. The run-registry binding (`source-closed`) still produces it. `scripts/lib/no-operator-permission-read.mjs` lists no removed site. A cron notice or repair turn finishes after the job is edited. Before, it failed with "This agent run is no longer active. Start a new turn to retry." - New test `keeps a started cron turn running when its job is edited` (`src/gateway/operator-run-recovery.effects.test.ts`). It uses the real `CronService`, `captureCronJobTurnTarget` and `prepareSessionEventTargetForHost`, then edits the stored job's `operatorSource`. - Base `848732ff`: red, `Error: Automation operator source changed`. - Head: green. - `ocx test` on the four test files that import `cron-job-turn-target.ts`: 35/35 pass. - `pnpm check:changed`: typecheck, lint, format and guards pass. The dead-export scan fails on base-only entries (`AgentCommandPluginIngressOpts`, `clearNativeRepositorySourceModulesForTest`, `resolveUpdateInstallSurfaceMock`). None of them are in this diff. - Live Gateway E2E (isolated Gateway, real `openai/gpt-5.5`, scratch state). Steps: the agent creates a cron job from chat with a 3 s timeout. `cron.run` fails, and the failure-repair turn starts in the owner session. The repair turn calls the cron tool to set `timeoutSeconds: 120` (`cron.update`), then runs one more `exec` and replies. - Base `848732ff`: the job edit lands, then the repair turn ends `state: error` with `Session target preparation outlived its attempt | This agent run is no longer active. Start a new turn to retry. | Automation operator source changed`. The Gateway log has `scope_authority_refused`. This is the incident. - Head `4d50bb57`: the job edit lands and the repair turn ends `state: final`. The log has no `scope_authority_refused`. - One-admission E2E Q/R/S on head `4d50bb57`: all PASS. Revoking access while work is queued refuses it visibly, revoking access while a turn runs stops it (`access-reduced`), and Stop cancels the turn. Production: −18/+6 lines. Test: +56/−1. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 7895017) Release adaptation: Replace the stable restored source snapshot equality assertion with the job-incarnation fence, retaining the revoked-device and profile checks and stable target ownership. Prove edits and removal against admitted repair target and authority. Companion audit: 213f9b9 applied immediately before this source; no other required companions. Co-authored-by: RomneyDa <[email protected]>
Problem
OA2 PR 4e (DESIGN §4.7 and §4.12; the two steps #205173 split off). Two places still decided what a running scheduled turn may do outside admission:
automationAdminoutput.decideOperatorAdmissionreturned a second owner-like bit for replays: admin scope and a saved Control UI delegation. In-session scheduled runs (runCronSessionTurn) used it to decide whether the run carries its restored operator source and binds command-owner authority. Same admin, different answer depending on which client created the job.source_authority_refused). The prepared session target inattempt-session-target.tsre-ran the run's whole source assertion (operator access, policy grants, session-event config) on every transcript and context write during the run, and refused withsource_authority_refused(REFUSALS R7, seen on Peanutto). Admission already checked that source once, at start.Fix
automationAdminis deleted from the admission decision,RestoredGatewayOperatorAuthority,ScheduledSessionAutomationand the participation path. An in-session scheduled run now binds command-owner authority iff its restored grant is owner (grant.owner), the same rule restart and owner continuations already use.createPreparedSessionTargetAssertionno longer calls the run's source. It keeps the selected-target fence (attempt, session identity, target fields), Stop and the run lifetime (assertScopeCurrent), and the session row predicates still reach the writer throughcomposeSessionSourceAssertion.start(); before start, a config publication that denies the selected model is refused by the start's own model-policy check, before any provider request. The integration test now asserts that refusal instead of probing it through the prepared target.Decisions (recorded, not asked)
grant.automations.automationAdmin/controlUiAdminon saved sources (no stored-row change);hasAutomationAdminDelegationkeeps its two non-admission readers (cron-job-turn-target.ts, the control-edit refresh incron-operator-source.ts).automations-run-scope.tstrigger fallback stays. Every Gateway occurrence is admitted throughadmitScheduledOccurrence, but when that admission fails (status: "fail"),bind()binds no context and the run still starts. The fallback is then the only thing that keeps an unadmitted hook/event turn (no sender bit, owner surface) from getting the full automations tool, and a cron turn limited to its own job. Deleting it needs the failed occurrence to carry its scope from admission (or a refused start), which is a separate change. Found while running the pre-push set (the fallback's own suite asserts the unadmitted event case); I removed it on the first head, then restored it: not patched here.Tests
run-attempt-dispatch.owner"policy" case (mid-run access-policy revoke →source_authority_refused);operator-run-recovery.native"preserves legacy browser grants…" (only asserted the deletedautomationAdminoutput).run-attempt-dispatch.ownernow applies each invalidation directly and asserts the prepared target never calls the run's source (red on base: base calls it once); "source-closed" refuses through the run lifetime (scope_authority_refused).run.operator-continuationandexecution-context-owner-authorityfixtures now admit occurrences / build the Codex host on the run's admitted context, as the Gateway does, so their scope comes from admission rather than the fallback.Evidence
src, non-test): +12 / −38 (net −26).run-attempt-dispatch.owner.test.tsinvalidation cases now assert the prepared target never calls the run's source (assertSourceCurrentnot called). On base the same case asserted it was called once (toHaveBeenCalledOnce), i.e. the R7 mid-run re-check.session-run.session-model-strictness.integration.test.ts"selected-model-denied": a config publication during target preparation that denies the selected model still ends the occurrence withstatus: "error",executionStarted: falseand zero provider requests; the error now names the policy (Scheduled model "primary/model-a" is not allowed by agents.defaults.modelPolicy.allow…).run.operator-continuation(36/36, incl. self-removal andnext_check) andexecution-context-owner-authority(embedded, Codex and CLI surfaces equal) pass with the fixtures admitting occurrences like the Gateway.ocx testcall over 81 files (touched tests + importers of every changed source/test-support + every test constructing cron tools withtrigger/jobId): all green on the first head; after restoring the fallback, the fallback's own suite and the affected files rerun green.pnpm tsgo:coreandtsgo:testclean (also after rebase on81d69df5dcea); oxfmt/oxlint clean on changed files.