Repository navigation
refactor: drop the admitted operator authority re-check and the lifetime ratchet (R6z) - #204249
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review blockedAutomated review did not run, so no review verdict was produced. Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here. Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update. Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it. |
|
Deleted test cases and rows (R6z). Each one asserted a refusal after a mid-run permission, role, profile, membership or model-policy change through the removed agents / acp / sessions / extensions
auto-reply
cron / plugins
gateway
|
|
…re URL Co-authored-by: obviyus <[email protected]>
The ratchet counts zero authority re-checks; the lint rule replaces it. Co-authored-by: obviyus <[email protected]>
Adds openclaw-boundaries/no-operator-permission-read and finishes deleting the lifetime check ratchet. Co-authored-by: obviyus <[email protected]>
…e admitted operator authority Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
…back Co-authored-by: obviyus <[email protected]>
580ee16 to
35055f0
Compare
|
Evidence on head
|
…refusals Co-authored-by: obviyus <[email protected]>
…rize # Conflicts: # src/agents/tools/image-tool.runtime-abort.test.ts # src/gateway/local-request-context.session-tools.test.ts # src/gateway/operator-run-authority.worker.test.ts # src/gateway/server-methods/users-personal-file.test.ts # src/gateway/session-access-authority.test.ts # src/gateway/sessions-patch.operator-model-policy.test.ts # src/model-picker/apply-session-model-selection.operator-context.test.ts
Co-authored-by: obviyus <[email protected]>
|
Evidence on head
|
…ession-identity pin Co-authored-by: obviyus <[email protected]>
|
Maintainer override: head
Since
Classification of the reds on
Head evidence: local ClawSweeper review complete, "patch is correct", 0 findings. One-admission E2E Q/R/S pass on |
|
Landed as 75cab7d.
|
…rn ends (#203113) ## Problem In a worktree session, the first turn starts a background exec with an exit wake and calls `sessions_yield`. When the command exits, the wake is refused before it starts with `Session changed while preparing its project; retry the task.` The exec result never reaches the agent. The chat then shows "This turn yielded, but no registered continuation can resume it. The run has ended." The user has to send another message to get the agent going again. Cause: the first turn of a session with a deferred checkout runs inside `runWithAgentWorkspaceReadiness` (#169136). The exec child's exit callback runs in that turn's async context, so it inherits the turn's workspace gate. After the turn yields and ends, the session-event wake reaches `admitReplyTurn`, which captures the inherited gate and calls its `assertCurrent()` in the store-writer phase. The retired run is no longer registered, so the check throws the ownership error, about 10 ms after admission starts. Nothing in the session changed. The production log matches: `lifecycle-admission failed reason=writer`, then the refused wake. Agent runs and follow-ups already clear this gate (#170791). Session-event wakes, queue and mailbox drains, and subagent announce/cleanup did not. ## Fix `runOutsideAdmittedTurnScopes` (renamed from `runOutsideAdmittedGenerationScopes`) is the single entry point for detached work that is re-admitted when it executes. It now also drops the inherited workspace gate, the same way it drops the inherited plugin generations. Every detached re-admission now runs under the gate of the turn it actually starts. The name change touches only its existing callers. A pre-start failure is not retried. A retry would have run in the same leaked context and failed the same way, and with the cause removed this failure no longer happens. A real session change before the wake (deleted chat, reset) keeps its existing behavior. ## Evidence - Regression test (`bash-tools.exec-background-followup.test.ts`): a real background exec started inside a turn's workspace gate. The gate retires before the command exits, and the test asserts that the wake turn runs and its prompt carries the exec output. Red on base with the production error, green with the fix. The rest of that file and the consumer tests (session-event, queue, mailbox, subagent announce, chat-send/agent-run readiness) pass. - Real Gateway, base vs head, from source. Isolated state, real model (OpenAI, embedded OpenClaw runtime). `sessions.create` with `worktree: true` and an initial message, so the checkout is deferred as in the incident. The agent runs `sleep 20; echo <marker>` in the background with an exit wake, then calls `sessions_yield`: - base: the wake fails with `session event execution failed source=exec ... Session changed while preparing its project`, then `completion delivery failed`. The transcript ends with "This turn yielded, but no registered continuation can resume it." - head: the wake turn runs, and the agent replies with the exact marker. No ownership errors. - `tsgo:core`, `check:test-types`, oxlint/oxfmt on the changed files. The `max-lines` finding on `session-event-handoff.ts` is inherited: the file has the same line count as on `main`. ## Merge danger Two-way door: no state, schema, config, or published contract changes, and a revert fully undoes it. Blast radius if wrong: detached wakes (exec, cron, restart, subagent completions) and queued follow-ups no longer see an inherited first-turn workspace gate. They admit against current session state, as agent runs and follow-ups already do. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 582f5d4) Release adaptation: Preserve stable plugin invocation cleanup while also clearing the retired workspace readiness gate. Companion audit: #204249, #204105, #203999, #202513 not applicable (later authority changes); #204260, #204178, #197395, #203156 missing in this lane, not dependencies. Co-authored-by: RomneyDa <[email protected]>
…203176) ## Problem A requester that calls `sessions_yield` after spawning several completion-mode subagents was woken only when every member of the frozen yield batch was ready. A sibling that keeps running, or that pauses on its own `sessions_yield` while a background command runs, held every finished result back. Production incident (2026-11-21): a dashboard parent spawned 3 children and yielded at 16:20 IST. Two children finished at 16:26:58 and 16:29:41 with reports that needed a decision. The third kept cycling through exec-yield and resume. The Gateway log has no `announce:requester-settle:…` run for that parent. The parent ran again only at 18:32, when the user typed into the chat. A copy of the state database shows why: both finished rows were `terminal`/`ok` with `delivery.status: pending` and a pending `requesterSettleWake` (`batchRunIds` = all 3, `rearmGeneration: 1`). The third row was still `running`. The gate in `subagent-announce.requester-settle-wake.ts` returned `false` unless every frozen member passed `isRequesterSettleMemberReady`. #200967 had already made an exception for siblings that wait for a message. An exec-yielded or running sibling is the same bug class. ## Change Rule: every ready result wakes the yielded parent. Siblings that are still working keep their wake, with the same `rearmGeneration`, and wake the parent again when they finish. Each result is delivered once. - **Settle wake:** removed the all-or-nothing gate and the message-wait exception (`isEndedSubagentMessageWait` is deleted). The wake delivers the ready members of the frozen batch as one partition, and lists the members that are still working. A member whose partition has already started dispatch records its own batch, so a later partition never offers it again. When a partition holds only results that were already delivered and siblings are still pending, it settles without a redundant wake. - **Wake message:** a partition that leaves members pending no longer says "every subagent has settled… do not call sessions_yield again". It names the siblings that are still working (label, task name or run ID, at most 5, each truncated) and tells the parent: if the request needs those results, call `sessions_yield` to wait; otherwise act on the ready results without reporting the batch as finished. - **Lifecycle failure path:** `offeredBatch` now offers only ready members, so failure settlement can never consume the wake of a sibling that is still running or exec-yielded. - **Yield transfer:** when a child ended before the yield and a sibling is still running, `afterRelease` now schedules the settle for the finished child. Before, nothing woke the parent until the sibling ended. - **Followup owners** (`sessions_send` wait-for-reply, `agent-step`, nested `agent-run-subagent`): the caller is waiting for a single reply. Only the partition that leaves no member pending continues the followup. Earlier partitions wake the session as ordinary settle turns. `successor()` accepts that last partition as a subset of its cohort, so it no longer throws and records the result as a permanent failure. - **Automation authority:** a yield that carried cron-management authority keeps it for the partition that leaves no member pending. Earlier partitions run without borrowing it, and settling them shrinks the retained cohort instead of discarding the authority. - **Silent waits:** while siblings are still working, the parent may stay silent (`NO_REPLY`) and wait. Such a turn is not treated as a missing visible reply, so it is not retried. - **Goal return:** an earlier partition leaves the Goal cohort when it settles. The partition that settles the cohort last resumes the Goal once. - `isRequesterSettleMemberReady` moved to `subagent-run-liveness.ts`, its only owner, and replaces the deleted message-wait predicate. - Docs: `tools/subagents/announce.md` and `concepts/subagent-yield-handoff.md`. Product decisions, under the rules "no stranded user" and "no false done": - A stopped child is a settled outcome, so its report now wakes the parent right away instead of waiting for its siblings. - A followup caller gets one reply, after all results are in. The session itself is still woken for each result. ## Evidence **Regression test** (`subagent-registry.requester-wake.e2e.test.ts`, real registry, lifecycle, yield tool and wake entry point): spawn 2 children, yield, finish one, keep the other exec-yielded. The parent is woken with the finished result, and the wake names the working sibling. The sibling's continuation then wakes the parent again with only its own result. A sweep adds no third wake. A second case covers a child that ended before the yield, while the requester's turn held it. - Base `eb7ca3d33375`: both cases red (`expected [] to have a length of 1`: no wake). - Head: both cases green. **Owner tests:** cron authority (`requester-cron-authority.test.ts`: the early partition neither borrows nor consumes the authority, and the last partition is admitted with it), followup partition (`subagent-announce.requester-settle-followup.test.ts`: early partition runs with no followup successor, last partition carries it). Goal partition (`goal-continuation.test.ts`: early partition does not resume the Goal, last partition resumes it once). **Updated tests that asserted the all-at-once rule:** `requester-settle-cross-turn` (paused member), `subagent-control.worker` progress card (one wake per result; the card retires once), `requester-wake-settlement` (stopped child). **Real-Gateway E2E**, incident shape. Scratch `ocx src` Gateway under `env -i`, OpenAI `gpt-5.5` on the OpenClaw runtime. Parent spawns `alpha` (replies at once) and `beta` (`exec` with `background: true` running `sleep 90`, then `sessions_yield`), then yields. | | alpha ended | first parent wake | beta yielded | beta ended | second parent wake | |---|---|---|---|---|---| | base | 19:47:10 | **19:48:53** (one combined run, after beta) | 19:47:13 | 19:48:50 | none | | head | 19:40:08 | **19:40:11** (`announce:requester-settle:…:<alpha>:yield-1`) | 19:40:12 | 19:41:55 | 19:41:59 (`…:<beta>:yield-1`) | The parent's replies on head were `alpha: ALPHA-RESULT-7`, then `alpha: ALPHA-RESULT-7 / beta: BETA-RESULT-9`. The live Peanutto launchd pid and `openclaw.json` hash did not change. **Live sibling suites** (`subagent-yield-pause`, `subagent-followup-yield`, `subagent-yield-resume`, real OpenAI `gpt-5.5`): the same tests fail on base `eb7ca3d33375` and on this branch, with the same assertions (missing `completion.resultText` after a resumed or paused child completes, a Gateway shutdown timeout, an interim reply in the follow-up watch case; follow-up-yield failed 2 of 2 on base). One run of this branch showed a parent that wrote its final report as soon as the first result arrived; the wake message now says to keep waiting when the request needs the remaining results, and that failure no longer appears. The real-Gateway restart e2e files (`test/gateway-*-restart*.e2e.test.ts`) fail locally on base too (11 of 26 on base, 9 of 26 here, same assertions). **Gates:** `pnpm tsgo:core`, `pnpm check:test-types`, oxlint and oxfmt on the changed files. Every test file in `src/agents/subagents` and `goal-continuation.test.ts` was run across the unit-fast, infra, agents-support, spawn-boundary, core-isolated and e2e projects. Two infra tests failed once under host load and passed when run alone, on head and on base. ## Size Production code is +96 / −56. The gate, the message-wait exception and its predicate are deleted. The added lines are the partition support the old gate did not need: pending members in the message, the followup last-partition rule, Goal cohort shrink, and pre-yield scheduling, and cron-authority cohort shrink. A census of `batchRunIds`, `requesterYieldBatch`, the frozen branch and `selectConnectedSettledSubagentWave` found every remaining reader still in use. v8 coverage could not attribute lines under the compiled-worker test runner (0 files collected in two attempts), so the census was done by reading the code. ## Accepted edge cases - If a Goal cohort's last partition is rejected for an unrelated reason (for example, a rearm-generation mismatch), the Goal return stays retained until Stop or a lifecycle rotation. That is the same outcome as a failed final delivery today. - A nested requester whose early partition answers without yielding reports that answer to its parent. The later result wakes it again as a separate completion. ## Merge danger - **Two-way door.** No schema, stored-row or config change: the wake rows keep their existing fields and generation. A revert restores the all-at-once wake for every cohort, including rows written while this change ran. - **Blast radius:** requesters that yield on two or more completion children (dashboard, chat and nested subagent requesters). A defect here would show as an extra or a missing wake for the parent, not as a lost child result: every result stays saved in its child session. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 09d956b) Release adaptation: Kept stable QA Gateway fixture lifecycle; filtered intentionally silent partial-result wakes. Companion audit: #203222 selected. #204249, #204069, #204048, #203892, #202513, #198960 not applicable (refactors/test cleanup); #204260, #204178, #204098, #204089, #203839, #203271 missing in lane and not prerequisites. Co-authored-by: RomneyDa <[email protected]>
* fix(subagents): settle cleaned child receipts and classify delivery notices * test(subagents): preserve notice classification assertion typing * test(subagents): build cleanup fixtures without map spread * chore(subagents): shrink identity allowance after guard removal * fix(subagents): separate receipt identity from continuation claims * test(subagents): retain main child notice classification after rebase * test(subagents): expect the ready cohort member to schedule settlement * fix(sessions): deduplicate yielded completion failure notices * test(subagents): preserve explicit claims and await terminal session state (cherry picked from commit cab76a6) Release adaptation: Preserved stable suspended-delivery sweeper; omitted main-only expiry and self-hold replacement fixtures; retained registry and Gateway yield-wait regression coverage. Identity ratchet prune clean. Companion audit: #204249 and #204191 not applicable (authority refactors); #204260 missing in lane, not a prerequisite. Co-authored-by: RomneyDa <[email protected]>
…#196172) * fix(codex): bound stalled session handoff from a retired process * fix(codex): explain how to recover from a handoff timeout * test(codex): reuse empty config responses in handoff fixtures * fix(codex): allow slow thread shutdown during handoff * test(codex): enforce model policy at admission in native config fixture --------- Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 1d409a2) Release adaptation: As in 2026.11.8 stable ed39478, preserve the stronger existing mid-preparation policy regression; omit the upstream admission-only rewrite. The handoff implementation and its regressions apply unchanged. Companion audit: #204249 is a separate authority refactor, not applicable. Verified sibling Codex d32063f96c2d, codex-rs/app-server/src/request_processors/thread_processor.rs:1153-1183 and rollout/src/writer_lock.rs:226-238. Co-authored-by: RomneyDa <[email protected]>
…ime ratchet (R6z) (openclaw#204249) ## Problem AGENTS.md says to check authority once, when work starts. The admitted operator authority (`AdmittedRunOperatorAuthority`) still carried a mid-run re-check member, `assertCurrent`, plus `onModelPolicyChanged`, a mid-run model-policy revocation hook. About 60 production readers called `assertCurrent()` in the middle of started runs, requests and queued work, and the constructor latched any failure into the run's signal. A started run could still be refused after a permission, role or profile change. The lifetime-check ratchet (`scripts/check-lifetime-check-ratchet.mts`) only kept the count from growing; it is now at zero and protects nothing. ## Fix This is the last one-admission PR (R6z). - `AdmittedRunOperatorAuthority` loses `assertCurrent` and `onModelPolicyChanged`. `createAdmittedRunOperatorAuthority` no longer composes or latches a re-check: its `signal` is the source signal (Stop) only. `bindOperatorModelExecution` keeps release and Stop, and no longer re-runs the policy on change. - Every reader the compiler listed is deleted. Stop reads its own signal (`signal.throwIfAborted()`). Data fences keep reading their own data: owner, generation, writer lease, run occurrence, released/closed flags, request lifetime, commit guards, the cron delivery fence (`scheduledAutomation.deliveryAttemptFence`) and the cron control-edit compare (`retainCronControlSource`). - `SessionControllerSourceAdapter.authority.assertCurrent` becomes optional. Non-operator producers keep their fence there. An operator authority passed there carries only Stop. - The retired-cron-delivery fence moves off the operator authority. A queued follow-up checks `scheduledAutomation.deliveryAttemptFence` before claim, in the same place where the removed `operatorAuthority.assertCurrent()` was. The follow-up runner withholds a run on `CronDeliveryAuthorityError` itself: it records the run and does not replay it. Before, it learned this only from the authority's latched signal. - The ratchet script, its test and its `ci-baseline-ratchets` entry are deleted. - New lint rule `openclaw-boundaries/no-operator-permission-read` (in `config/oxlint/boundary-guards.json`, which the `lint:no-chained-type-assertions` boundary lane runs over `src`, `extensions` and `packages`). Only the files named in `scripts/lib/no-operator-permission-read.mjs` may reference the live permission readers `resolveOperatorRolePolicy`, `resolveOperatorRolePolicyForAssignment`, `resolveOperatorRolePolicyForProfile`, `resolveOperatorRoleSelection`, `authorizeCurrentOperatorRoleScopes`, `onOperatorRolePolicyChanged` and `captureResidentUserProfileAccess`. The allowlist is the owners and the work-start files that use them today (63 files). It only shrinks: new code takes scopes, role and policy from the admitted operator authority. The planted fixture `test/fixtures/oxlint-boundary-guards/operator-permission-recheck-violation.ts` (named import, namespace member, lazy import) fails the rule (4 reports). - Parked item from R6c4a: the worktree publication message reads "The GitHub publication worktree changed" instead of "...authority changed". The test fixture URL that had fake credentials is now `https://example.test/repo?...`. - The last three refusal strings in production code are gone: - `agent-run-user-turn.ts`: the requester-owner re-read from live config (`assertRequesterCurrent`, "Requester owner authority changed") is deleted, along with its admission-phase and execution-phase plumbing. The owner decision is made once, when the turn starts. The `subagent-spawn.production-boundary` expectation "removing the spawning owner after admission must stop that dispatch" is deleted with it. - `acp/runtime/session-meta-resume-authorization.ts`: this is a data fence (the source session's facts changed). It is reworded to "The ACP resume source session changed". - `cron-creator-authority-grant.ts`: the run-scoped grant ends with its run, scope, operation or management deadline. It is reworded to "This run's MCP cron access has ended". - `scripts/perf/*-measure.ts`: removed the `assertCurrent` counters and the source-authority revocation proof, which measured the deleted mid-run re-check. Production code: 86 files, +82 / −313. Scripts, config and lint test: +138 / −242. ### Decisions - Lint rule shape (Fable 5.2): an import/reference boundary on the live readers, with exact files listed. A rule that bans the name `assertCurrent` would be wrong, because ~150 data-owner authorities use that name. The refusal-string ban would only bring the deleted ratchet back as a wording check. Accepted risk: an allowed work-start file can still call a reader twice. Review owns that. - `src/cron/service.restart-delivery.test.ts` "automation=false" row deleted. Only the fixture put the delivery fence on the operator authority. In production the queued authority comes from `decideOperatorAdmission`, whose `assertCurrent` was always a no-op. The real carrier is `scheduledAutomation.deliveryAttemptFence`, and that case stays. - Accepted edge: a queued chat input's `requesterProfile.isCurrent` is now `true` for the life of the dispatch. Before, it turned false after the admitted source was released. It only selects the requester attribution prefix. - Accepted edge: if a completion cohort settles between the steering preparation and the queue commit, the human correction now reports `failed` with the policy-mismatch error. Before, it reported `rejected: tool_authority_mismatch`. The message is still refused visibly, and the race window is a few milliseconds. - Known follow-up, not done here: a cron creator grant can still be refused when consumed after its issuing device or channel owner is revoked during the run, because the grant's `isCurrent` producers still read the device and owner lifetime. Only the wording changed in this PR. Removing those producers is a separate cut in the cron grant plumbing. ## User impact A started run, request, queued start, tool call, model execution or scheduled job finishes after a permission, role, profile or model-policy change. The next request uses the new permissions. Stop still cancels. Data fences still refuse stale writes. ## Tests Deleted, because each asserts a refusal after a mid-run permission, role, profile or model-policy change (full list in the PR comment). Stop, run-close and data-fence tests keep their condition. Test fixtures no longer pass `assertCurrent` or `onModelPolicyChanged`. ## Evidence - `pnpm tsgo:core`, `pnpm tsgo:test`, `pnpm tsgo:extensions`: clean. - oxfmt and oxlint on all changed files: clean. `pnpm lint:no-chained-type-assertions` (all focused guards, including the new rule) over the tree: 0 errors. `test/scripts/oxlint-boundary-guards.test.ts`: the planted re-check fixture fails the rule. - Pre-push `ocx test`: all 215 touched test files and the importers of every `*.test-support.ts` file. The direct-importer set is over the 150-file cap. Then the failed files, plus importers of `followup-runner.ts` and `reply-agent-turn-preparation.ts`, and after the rebase on openclaw#204191 its 17 test files. Final reruns are green. - E2E `one-admission-e2e/run.sh`: see the comment. Co-authored-by: Ayaan Zaidi <[email protected]>
## Problem AGENTS.md says to check authority once, when work starts. The MCP cron creator grant (`src/gateway/cron-creator-authority-grant.ts`) still re-read its issuer's state each time it was used: - Gateway `agent` and `chat.send` turns passed the client's `hasCurrentClientAuthority` (the issuing device's live revocation state) into the run scope's `isCurrent`. - Channel-owner turns put a live command-owner check (`isConfiguredCommandOwner` on current config) into `managementEntitlement.isCurrent` and `requesterOwner.isCurrent`. Grant mint, consume, provenance, stream exec policy, management redemption, tool construction and requester continuations all called those callbacks. A device revoke or an owner removal during a run refused the started run's next automation write with "This run's MCP cron access has ended" (R6z, #204249, named this follow-up). ## Fix - `CronManagementEntitlement` is now one shape, `{ source }`. The channel-owner variant loses `isCurrent`. `requesterOwner` keeps only its identity fields (`senderId`, `channel`, `accountId`). - Deleted every use-time read of those callbacks: grant mint, provenance and `assertCronGrantCurrent`; `bindCronManagementToolConstruction`, `captureActiveCronManagementAuthority`, `bindRequesterOwnerIdentity`, `bindCronManagementGrant`; the requester continuation's `isCurrent`. - The direct operator admission (`resolveDirectOperatorAuthority`) no longer takes or copies `isCurrent`. Removed `isCurrent` from the admission params, `GatewayChatUserTurn`, the chat external-admission contract and both call sites. The `agent` turn keeps `hasCurrentClientAuthority`: the operator-run retention (`retainGatewayOperatorRun`) still reads it at turn start. - The channel reply factory checks the owner once when it creates the run's capability. On the fresh path this happens at turn start. A queued `/followup` start passes its own owner check, so a revoke while queued still starts the turn without cron management. Kept, because they are run liveness or grant identity data, not issuer state: scope `active`/`signal` (Stop and run close), the operation signal, `scope.isCurrent` from requester continuations (session reset/archive, cohort and new-user-turn fences), the grant's `isCurrent` from the MCP loopback grant (grant replaced) and `validateAgentRunDelegatedAuthority` (run occurrence), the run/job identity compares and the 60 s management grant expiry. Production code: 9 files, +18 / −43. No new lint allowlist entry. ### Decisions - A yielded requester's continuation (child completion back to the parent) is part of the started task. It keeps the owner identity captured at the parent's admission. A channel-owner removal between yield and continuation no longer drops the continuation's cron management. Session reset/archive and a new direct user turn still retire it. - Accepted edge: a channel owner removed while their message is queued still gets their turn, but without cron management (the factory returns no capability), as before for other caller-scoped turns. ## User impact A started run can finish its automation writes after its device is revoked or its channel owner is removed mid-run. The next turn uses the new state. Stop and run close still end the grant. ## Tests Deleted, because each asserts a refusal after a mid-run device, owner or entitlement change: - `cron-creator-authority-grant.test.ts`: "channel owner" retained-creator row and the owner-revoked mint case. - `cron-creator-authority-context.test.ts`: owner-revoked construction case. - `requester-cron-authority.test.ts`: "rejects an owner revoked before dispatch" and the owner toggles in "retains %s across yields". - `run.bind-parent.test.ts`: "refuses the stored write when the owner loses authority while bind waits for the store". - `cron.ownership-matrix.test.ts`: the `revoked` caller. - `sessions-send-owner-continuation.test.ts`: the "owner revoked" row. Flipped to prove the new rule (revoke mid-run does not refuse; run close does): - `agent-run-local-operator-authority.test.ts`: device revoked mid-run → the grant is consumed; after run close an unspent grant is refused. - `cron-creator-transports.integration.test.ts`: real CLI/embedded/remote/chat/template creator mutations succeed after the issuing device is revoked; the session-data fence (skill selection) still refuses. - `mcp-cron-management.integration.test.ts`: a channel owner's MCP update succeeds after owner removal; revoking the MCP grant still returns 401. - `server.sessions-send-owner-continuation.test.ts`: the "owner revoked" row's plugin write now lands. - `sessions-send-followup-revalidation.test.ts`: the "revoked" row now resolves. ## Evidence - `pnpm tsgo:core`, `pnpm tsgo:test`, `pnpm tsgo:extensions`: clean. oxfmt and oxlint on the changed files: clean. - Pre-push `ocx test`: the 94 touched and importer test files (direct importers of every changed source and `*.test-support.ts`). All ours green after one repair round (the `agent` turn still needs `hasCurrentClientAuthority` for `retainGatewayOperatorRun`, so that plumbing is kept). `service.pr-automation*.test.ts` (32 cases) fails the same way on merge base `04ddd0ebe84e`. - `pnpm check:changed`: all lanes pass except the dead-export scan, which flags `ui/src/pages/chat/components/chat-read-aloud-status.tsx: RecordingApiKeyNotice` (not in this diff). - E2E `one-admission-e2e/run.sh` on head `882bbde7cecf`: Q (revoke while queued → refused visibly), R (revoke while running → finishes) and S (Stop → cancels) pass. `verdict.json` and `results.jsonl`: #204395 (comment) - Local review on this head: ready, no findings. CI reds are not ours: #204395 (comment) Co-authored-by: Ayaan Zaidi <[email protected]>
…opped mid-run authority re-checks (openclaw#204249) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…aw#204395) ## Problem AGENTS.md says to check authority once, when work starts. The MCP cron creator grant (`src/gateway/cron-creator-authority-grant.ts`) still re-read its issuer's state each time it was used: - Gateway `agent` and `chat.send` turns passed the client's `hasCurrentClientAuthority` (the issuing device's live revocation state) into the run scope's `isCurrent`. - Channel-owner turns put a live command-owner check (`isConfiguredCommandOwner` on current config) into `managementEntitlement.isCurrent` and `requesterOwner.isCurrent`. Grant mint, consume, provenance, stream exec policy, management redemption, tool construction and requester continuations all called those callbacks. A device revoke or an owner removal during a run refused the started run's next automation write with "This run's MCP cron access has ended" (R6z, openclaw#204249, named this follow-up). ## Fix - `CronManagementEntitlement` is now one shape, `{ source }`. The channel-owner variant loses `isCurrent`. `requesterOwner` keeps only its identity fields (`senderId`, `channel`, `accountId`). - Deleted every use-time read of those callbacks: grant mint, provenance and `assertCronGrantCurrent`; `bindCronManagementToolConstruction`, `captureActiveCronManagementAuthority`, `bindRequesterOwnerIdentity`, `bindCronManagementGrant`; the requester continuation's `isCurrent`. - The direct operator admission (`resolveDirectOperatorAuthority`) no longer takes or copies `isCurrent`. Removed `isCurrent` from the admission params, `GatewayChatUserTurn`, the chat external-admission contract and both call sites. The `agent` turn keeps `hasCurrentClientAuthority`: the operator-run retention (`retainGatewayOperatorRun`) still reads it at turn start. - The channel reply factory checks the owner once when it creates the run's capability. On the fresh path this happens at turn start. A queued `/followup` start passes its own owner check, so a revoke while queued still starts the turn without cron management. Kept, because they are run liveness or grant identity data, not issuer state: scope `active`/`signal` (Stop and run close), the operation signal, `scope.isCurrent` from requester continuations (session reset/archive, cohort and new-user-turn fences), the grant's `isCurrent` from the MCP loopback grant (grant replaced) and `validateAgentRunDelegatedAuthority` (run occurrence), the run/job identity compares and the 60 s management grant expiry. Production code: 9 files, +18 / −43. No new lint allowlist entry. ### Decisions - A yielded requester's continuation (child completion back to the parent) is part of the started task. It keeps the owner identity captured at the parent's admission. A channel-owner removal between yield and continuation no longer drops the continuation's cron management. Session reset/archive and a new direct user turn still retire it. - Accepted edge: a channel owner removed while their message is queued still gets their turn, but without cron management (the factory returns no capability), as before for other caller-scoped turns. ## User impact A started run can finish its automation writes after its device is revoked or its channel owner is removed mid-run. The next turn uses the new state. Stop and run close still end the grant. ## Tests Deleted, because each asserts a refusal after a mid-run device, owner or entitlement change: - `cron-creator-authority-grant.test.ts`: "channel owner" retained-creator row and the owner-revoked mint case. - `cron-creator-authority-context.test.ts`: owner-revoked construction case. - `requester-cron-authority.test.ts`: "rejects an owner revoked before dispatch" and the owner toggles in "retains %s across yields". - `run.bind-parent.test.ts`: "refuses the stored write when the owner loses authority while bind waits for the store". - `cron.ownership-matrix.test.ts`: the `revoked` caller. - `sessions-send-owner-continuation.test.ts`: the "owner revoked" row. Flipped to prove the new rule (revoke mid-run does not refuse; run close does): - `agent-run-local-operator-authority.test.ts`: device revoked mid-run → the grant is consumed; after run close an unspent grant is refused. - `cron-creator-transports.integration.test.ts`: real CLI/embedded/remote/chat/template creator mutations succeed after the issuing device is revoked; the session-data fence (skill selection) still refuses. - `mcp-cron-management.integration.test.ts`: a channel owner's MCP update succeeds after owner removal; revoking the MCP grant still returns 401. - `server.sessions-send-owner-continuation.test.ts`: the "owner revoked" row's plugin write now lands. - `sessions-send-followup-revalidation.test.ts`: the "revoked" row now resolves. ## Evidence - `pnpm tsgo:core`, `pnpm tsgo:test`, `pnpm tsgo:extensions`: clean. oxfmt and oxlint on the changed files: clean. - Pre-push `ocx test`: the 94 touched and importer test files (direct importers of every changed source and `*.test-support.ts`). All ours green after one repair round (the `agent` turn still needs `hasCurrentClientAuthority` for `retainGatewayOperatorRun`, so that plumbing is kept). `service.pr-automation*.test.ts` (32 cases) fails the same way on merge base `8afce9ee5e62`. - `pnpm check:changed`: all lanes pass except the dead-export scan, which flags `ui/src/pages/chat/components/chat-read-aloud-status.tsx: RecordingApiKeyNotice` (not in this diff). - E2E `one-admission-e2e/run.sh` on head `882bbde7cecf`: Q (revoke while queued → refused visibly), R (revoke while running → finishes) and S (Stop → cancels) pass. `verdict.json` and `results.jsonl`: openclaw#204395 (comment) - Local review on this head: ready, no findings. CI reds are not ours: openclaw#204395 (comment) Co-authored-by: Ayaan Zaidi <[email protected]>
… the turn starts Main now checks authority one time, when work starts (openclaw#204249). Drop the live consent callback (`admit`) from the shared Decision runtime and the consumer's mid-request rereads: the hook admits the turn with its config and a change applies to the next turn. `src/decisions` and the SDK capability docs are back to main. Tests: drop the mid-run withdrawal cases, the batch-shape test ClawSweeper flagged, the Russian integration case main removed in openclaw#184944, and unit cases already covered by the hook integration tests. Add a Chinese resume request from openclaw#151178 that the built-in matcher misses. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… change (#206747) ## Problem Root `AGENTS.md` ("Choose good compromises") says: check authority one time, when work starts. Revocation, removal and reload apply to the next request. A started request may finish. #204249 removed the mid-run re-check from the admitted operator authority. Some code added later checks authority again after the work has started: - **Participant runs (major).** A membership change aborted the invited person's work that had already started. This happened when the creator removed the person or lowered their access below `send`. It covered the running turn, its tool calls, its spawned children and its completion handoffs. A registry of `AbortController`s in `session-participation-source.ts` was merged into the run authority's signal. That is the latched re-check #204249 deleted. - **Plugin request grants (major).** `withPluginGatewayRequestAuthority` called `operatorAccessAuthority.assertCurrent()` each time a plugin required its grant. A Beam visitor upload or continuation that was already admitted was refused after its body arrived. - **One-request re-reads (minor).** These requests read the policy at start and again at commit, so a role change during the request gave a different answer: - Session invite and access change: "Invitee role changed before invitation commit". - @mention invitation: "Mention invitation is not authorized". - Invited-workspace eligibility predicate (`isInvitedWorkspaceTarget`), which re-read membership per call. - ClawHub sign-in polling. User-visible failure: the same person, with the same request, gets a refusal or an aborted run only because of when an admin acted. ## Fix Deletion only: - Delete the participation producer registry (`retainSessionParticipation`, `revokeSessionParticipation`, `publishSessionParticipationMemberChange`) and the `participationSignal` path into the run authority, typing, recovery and `retainForRun`. The run signal is Stop again. - Delete `access.assertCurrent()` in `src/plugins/runtime/gateway-request-authority.ts`. The start-time plugin match stays. - Delete the commit-time re-reads in `sessions-sharing.ts`, `human-mention-invitation.ts` and `templates-drafts.ts`. In `session-scoped-read.ts`, the invited-workspace predicate now uses the membership read once per request. - ClawHub sign-in keeps its request-lifetime fences (connection still open, commit guard) and its registry-URL fence. Only the administrator-policy re-read is gone. Kept: - Start-time admission and the participation ceiling. - Queued-input cancellation on a membership reduction. Queued work is new work, so it is admitted again when it starts. - Recovery re-admission (`invitation-ended`). - Stop. - Session-incarnation, `expectedEntry` CAS, connection-lifetime and registry-URL data fences. Production code: about +22 / −198. No schema, protocol or config change. Not in this PR: the older `retainSessionScopedRead().assertCurrent` (2026-09/10) still re-checks visibility after a read is admitted. It predates the one-admission work and gets its own change. ## User impact - An invited person's started turn, tools, children and completions finish after the creator removes them or lowers their access. Their next message is refused as before, and their queued messages are still cancelled. - An admitted Beam visitor upload or continuation finishes. - Invite, mention, scoped-read and ClawHub sign-in requests give the answer that was decided when the request started. ## Evidence See the comment. Co-authored-by: Ayaan Zaidi <[email protected]>
… change (openclaw#206747) ## Problem Root `AGENTS.md` ("Choose good compromises") says: check authority one time, when work starts. Revocation, removal and reload apply to the next request. A started request may finish. openclaw#204249 removed the mid-run re-check from the admitted operator authority. Some code added later checks authority again after the work has started: - **Participant runs (major).** A membership change aborted the invited person's work that had already started. This happened when the creator removed the person or lowered their access below `send`. It covered the running turn, its tool calls, its spawned children and its completion handoffs. A registry of `AbortController`s in `session-participation-source.ts` was merged into the run authority's signal. That is the latched re-check openclaw#204249 deleted. - **Plugin request grants (major).** `withPluginGatewayRequestAuthority` called `operatorAccessAuthority.assertCurrent()` each time a plugin required its grant. A Beam visitor upload or continuation that was already admitted was refused after its body arrived. - **One-request re-reads (minor).** These requests read the policy at start and again at commit, so a role change during the request gave a different answer: - Session invite and access change: "Invitee role changed before invitation commit". - @mention invitation: "Mention invitation is not authorized". - Invited-workspace eligibility predicate (`isInvitedWorkspaceTarget`), which re-read membership per call. - ClawHub sign-in polling. User-visible failure: the same person, with the same request, gets a refusal or an aborted run only because of when an admin acted. ## Fix Deletion only: - Delete the participation producer registry (`retainSessionParticipation`, `revokeSessionParticipation`, `publishSessionParticipationMemberChange`) and the `participationSignal` path into the run authority, typing, recovery and `retainForRun`. The run signal is Stop again. - Delete `access.assertCurrent()` in `src/plugins/runtime/gateway-request-authority.ts`. The start-time plugin match stays. - Delete the commit-time re-reads in `sessions-sharing.ts`, `human-mention-invitation.ts` and `templates-drafts.ts`. In `session-scoped-read.ts`, the invited-workspace predicate now uses the membership read once per request. - ClawHub sign-in keeps its request-lifetime fences (connection still open, commit guard) and its registry-URL fence. Only the administrator-policy re-read is gone. Kept: - Start-time admission and the participation ceiling. - Queued-input cancellation on a membership reduction. Queued work is new work, so it is admitted again when it starts. - Recovery re-admission (`invitation-ended`). - Stop. - Session-incarnation, `expectedEntry` CAS, connection-lifetime and registry-URL data fences. Production code: about +22 / −198. No schema, protocol or config change. Not in this PR: the older `retainSessionScopedRead().assertCurrent` (2026-09/10) still re-checks visibility after a read is admitted. It predates the one-admission work and gets its own change. ## User impact - An invited person's started turn, tools, children and completions finish after the creator removes them or lowers their access. Their next message is refused as before, and their queued messages are still cancelled. - An admitted Beam visitor upload or continuation finishes. - Invite, mention, scoped-read and ClawHub sign-in requests give the answer that was decided when the request started. ## Evidence See the comment. Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
AGENTS.md says to check authority once, when work starts. The admitted operator authority (
AdmittedRunOperatorAuthority) still carried a mid-run re-check member,assertCurrent, plusonModelPolicyChanged, a mid-run model-policy revocation hook. About 60 production readers calledassertCurrent()in the middle of started runs, requests and queued work, and the constructor latched any failure into the run's signal. A started run could still be refused after a permission, role or profile change. The lifetime-check ratchet (scripts/check-lifetime-check-ratchet.mts) only kept the count from growing; it is now at zero and protects nothing.Fix
This is the last one-admission PR (R6z).
AdmittedRunOperatorAuthoritylosesassertCurrentandonModelPolicyChanged.createAdmittedRunOperatorAuthorityno longer composes or latches a re-check: itssignalis the source signal (Stop) only.bindOperatorModelExecutionkeeps release and Stop, and no longer re-runs the policy on change.signal.throwIfAborted()). Data fences keep reading their own data: owner, generation, writer lease, run occurrence, released/closed flags, request lifetime, commit guards, the cron delivery fence (scheduledAutomation.deliveryAttemptFence) and the cron control-edit compare (retainCronControlSource).SessionControllerSourceAdapter.authority.assertCurrentbecomes optional. Non-operator producers keep their fence there. An operator authority passed there carries only Stop.scheduledAutomation.deliveryAttemptFencebefore claim, in the same place where the removedoperatorAuthority.assertCurrent()was. The follow-up runner withholds a run onCronDeliveryAuthorityErroritself: it records the run and does not replay it. Before, it learned this only from the authority's latched signal.ci-baseline-ratchetsentry are deleted.openclaw-boundaries/no-operator-permission-read(inconfig/oxlint/boundary-guards.json, which thelint:no-chained-type-assertionsboundary lane runs oversrc,extensionsandpackages). Only the files named inscripts/lib/no-operator-permission-read.mjsmay reference the live permission readersresolveOperatorRolePolicy,resolveOperatorRolePolicyForAssignment,resolveOperatorRolePolicyForProfile,resolveOperatorRoleSelection,authorizeCurrentOperatorRoleScopes,onOperatorRolePolicyChangedandcaptureResidentUserProfileAccess. The allowlist is the owners and the work-start files that use them today (63 files). It only shrinks: new code takes scopes, role and policy from the admitted operator authority. The planted fixturetest/fixtures/oxlint-boundary-guards/operator-permission-recheck-violation.ts(named import, namespace member, lazy import) fails the rule (4 reports).https://example.test/repo?....agent-run-user-turn.ts: the requester-owner re-read from live config (assertRequesterCurrent, "Requester owner authority changed") is deleted, along with its admission-phase and execution-phase plumbing. The owner decision is made once, when the turn starts. Thesubagent-spawn.production-boundaryexpectation "removing the spawning owner after admission must stop that dispatch" is deleted with it.acp/runtime/session-meta-resume-authorization.ts: this is a data fence (the source session's facts changed). It is reworded to "The ACP resume source session changed".cron-creator-authority-grant.ts: the run-scoped grant ends with its run, scope, operation or management deadline. It is reworded to "This run's MCP cron access has ended".scripts/perf/*-measure.ts: removed theassertCurrentcounters and the source-authority revocation proof, which measured the deleted mid-run re-check.Production code: 86 files, +82 / −313. Scripts, config and lint test: +138 / −242.
Decisions
assertCurrentwould be wrong, because ~150 data-owner authorities use that name. The refusal-string ban would only bring the deleted ratchet back as a wording check. Accepted risk: an allowed work-start file can still call a reader twice. Review owns that.src/cron/service.restart-delivery.test.ts"automation=false" row deleted. Only the fixture put the delivery fence on the operator authority. In production the queued authority comes fromdecideOperatorAdmission, whoseassertCurrentwas always a no-op. The real carrier isscheduledAutomation.deliveryAttemptFence, and that case stays.requesterProfile.isCurrentis nowtruefor the life of the dispatch. Before, it turned false after the admitted source was released. It only selects the requester attribution prefix.failedwith the policy-mismatch error. Before, it reportedrejected: tool_authority_mismatch. The message is still refused visibly, and the race window is a few milliseconds.isCurrentproducers still read the device and owner lifetime. Only the wording changed in this PR. Removing those producers is a separate cut in the cron grant plumbing.User impact
A started run, request, queued start, tool call, model execution or scheduled job finishes after a permission, role, profile or model-policy change. The next request uses the new permissions. Stop still cancels. Data fences still refuse stale writes.
Tests
Deleted, because each asserts a refusal after a mid-run permission, role, profile or model-policy change (full list in the PR comment). Stop, run-close and data-fence tests keep their condition. Test fixtures no longer pass
assertCurrentoronModelPolicyChanged.Evidence
pnpm tsgo:core,pnpm tsgo:test,pnpm tsgo:extensions: clean.pnpm lint:no-chained-type-assertions(all focused guards, including the new rule) over the tree: 0 errors.test/scripts/oxlint-boundary-guards.test.ts: the planted re-check fixture fails the rule.ocx test: all 215 touched test files and the importers of every*.test-support.tsfile. The direct-importer set is over the 150-file cap. Then the failed files, plus importers offollowup-runner.tsandreply-agent-turn-preparation.ts, and after the rebase on refactor: drop mid-request authority re-checks in the last gateway, session and node-host refusals (R6d part 4) #204191 its 17 test files. Final reruns are green.one-admission-e2e/run.sh: see the comment.