Repository navigation
fix(queue): refuse a queued Gateway followup whose requester lost its write grant - #203468
Merged
Merged
Conversation
…rator.write A queued /followup restored its requester through admission at start, but admission only narrows saved scopes to the current role. A requester demoted to read-only still started the turn. Refuse the start when the admitted scopes lack operator.write, as chat.send does for a live request. Channel senders keep their admitted scopes. Co-authored-by: obviyus <[email protected]>
A live chat.send accepts operator.sessions.write for own sessions; the queued start keeps that rule instead of requiring operator.write. Give the demotion test its own idempotency key so it is independent of the preceding queued test. Co-authored-by: obviyus <[email protected]>
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Collaborator
Author
|
Landed in b8a55ae.
|
This was referenced Nov 22, 2026
Closed
Closed
obviyus
added a commit
that referenced
this pull request
Nov 22, 2026
…d it (#203521) ## Problem Every queued, scheduled, replayed or resumed start re-admits its saved requester through `src/gateway/operator-run-recovery.ts`, which runs `prepareOperatorAdmission` + `decideOperatorAdmission`. `decideOperatorAdmission` only narrows the saved scopes to the current role, and it refuses only when no scope is left. So a requester whose role changed to read-only before the start was admitted with `["operator.read"]`. #203468 closed this for the queued `/followup` path only. Audit on `main` (requester's role changed before the start): | Start | Creation grant | Read-only on `main` | |---|---|---| | Queued chat, `/followup`, collected batch, Goal successor | write | refused (#203468 per-path check) | | Restart replay of a queued chat input | write | refused later by `chat.send` method scopes | | Restart completion wake | write | refused later by `agent` method scopes | | System turn, restart resume | write | refused (`prepareSessionPrincipalRunAccess`) | | Worker environment provision resume | admin (`environments.create`) | **starts** | | Plugin service session work | the run that accepted it | **starts** | | Cron agent turn, command, script | cron | **starts** | | Cron conversation event | cron | **starts** at the event target (refused later only by #203468's write check, which also refused cron-only creators) | | Native stream source | cron | **starts** | | Scheduled plugin command | cron | **starts** | | In-run continuation | (started run) | admitted, must stay admitted | ## Fix One private admission body, two exported start entries that differ only in the grant they require now: - `restoreGatewayQueuedOperatorRecovery` / `restoreGatewayOperatorSource`: the requester must hold `operator.sessions.write` (write, admin and own-session write satisfy it; what a live `chat.send` needs). - New `restoreScheduledAutomationOperator`: the requester must hold `operator.cron` (write and admin satisfy it; what creating an automation needs). - Refusal uses the existing `GatewayOperatorRecoveryAuthorizationError`. Channel senders (`channelRecoverySource`) are exempt, as before. `captureGatewayOperatorContinuation` uses the private body without a start grant: a started run finishes. Each call site picks its entry by the grant that authorized creating the work: - Automation entry: cron runs (`cron-operator-source.ts`), native stream sources (`cron-stream-source-authority.ts`), cron conversation events (`session-event-target.ts`; only cron supplies a deferred operator source there), scheduled plugin commands (`plugin-command-scheduled-run.ts`), and the queued follow-up of a cron conversation event (`queue/lifecycle.ts`, when `scheduledAutomation` is set). - Write entry: queued chat and `/followup` (`queue/lifecycle.ts` otherwise), restart replay, completion wake, system turns, worker provisioning resume. - Plugin service session work is the one site whose work can come from either a chat turn or a cron run, and it stores only the run's snapshot. It reads the grant from that snapshot: a snapshot that held `operator.sessions.write` needs write now; one that held only `operator.cron` needs cron or write now. No new state. - #203468's per-path check in `queue/lifecycle.ts` is deleted; the shared entries cover that path. ### Decisions - Option 2 of the design review: the entry name carries the start kind. No parameter or flag, and no exported generic entry, so a start with no stated kind cannot be written. - `decideOperatorAdmission` is unchanged: it cannot tell a start from a continuation from its facts. - Accepted edge case: service work that a cron run started for a writer later moved to a cron-only role is refused visibly at its next start, because its snapshot held write. Every other automation from that writer keeps starting through the automation entry. - Completion wakes and system turns stay on the write entry even when a cron run caused them: on `main` they already needed write (`agent` method scopes, `prepareSessionPrincipalRunAccess`), so no cron-only creator loses anything. - The sandbox stream keeps its own `operator.write` check (`cron-stream-sandbox-authority.ts` calls `decideOperatorAdmission` directly). - Production code is not net negative (+117/−89, +28): the cause is the missing grant at start, and the automation entry plus the per-site choice is the minimum for it. The admission body is now shared instead of duplicated. - Tests that asserted a read-only next start was admitted with `["operator.read"]` now assert the refusal (`operator-run-recovery.test.ts` publication case, `operator-run-recovery.access-policy.test.ts`, `remote-control-ui-ingress.integration.test.ts` viewer recovery). ## Evidence - New table test `src/gateway/operator-run-recovery.start-grant.test.ts` (24 rows). Each start kind goes through the entry its producer uses, with the saved-source shape it stores: - every chat-like kind is refused when the writer becomes read-only and when the writer becomes cron-only; - every automation kind is admitted for a cron-only creator and refused when its creator becomes read-only; - an in-run continuation and a read-only channel sender stay admitted. - Head: 24/24 pass. Base `8d1e59c2fddc` (with `restoreScheduledAutomationOperator` aliased to the unchecked queued restore that base's automation sites use): 17 fail (all 12 chat-like rows and the 5 automation read-only rows), 7 pass (5 cron-only admits, continuation, channel). - The `/followup` rows fail at the shared entry on base; end to end, base refused read-only there through #203468's check, which this PR moves into the shared entry. - `service-session-work.test.ts`: work accepted with `operator.write` or `operator.sessions.write` restores through the write entry; work accepted with only `operator.cron` restores through the automation entry. - Before push, one `ocx test` run over the touched tests plus every test importing a changed source (53 files). Reds outside this PR, each also red on base `8d1e59c2fddc`: `cron.scheduled-policy-adoption.integration.test.ts` (3 owner-origin cases, "No model is configured"), and the intermittent `operator-admission.table.test.ts > principal > before-start` flake. `ci-changed-node-test-plan.source-owners.test.ts` needed the new file committed and passes after the commit. `tsgo:core` and `tsgo:core:test` pass; oxfmt/oxlint clean. - E2E (`one-admission-e2e`: isolated Gateway, trusted-proxy Control UI clients, real model turn) on `2fb4824f6db4` and again on the final head `5a06fa530986`, all pass: - R (revoke while running → finishes): `state: final`, `toolEnds: 3`, `toolEndsAfterRevoke: 3`. - Q (revoke while queued → refused visibly): `providerRequestsWithQueuedMarker: 0`, `visibleRefusalInTranscript: true`. - S (Stop → cancels): `state: aborted`. - Local ClawSweeper review: round 1 (`2fb4824f6db4`) and round 2 (`5a06fa530986`) findings are answered in `Rejected review findings:` comments (the accepted service-work edge case; restart system turns and completion wakes, which already needed write on `main`). - CI: the only failure caused by this PR (round 1, a read-only recovery fixture in `operator-run-authority.principal.test.ts`) is fixed. The remaining reds also fail on `main` (#203496, #203542); see the `Maintainer override:` comment. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 23, 2026
… write grant (openclaw#203468) ## Problem A Control UI user with `operator.read` + `operator.write` starts a turn, then sends `/followup …`. The follow-up waits in the session queue (`pendingInputs`, state `queued`). An admin then changes the user's role to read-only (`operator.read`). When the running turn ends, the queued follow-up still starts and reaches the model. The queued start already goes through admission: `prepareFollowupRunOperatorAuthority` (`src/auto-reply/reply/queue/lifecycle.ts`) → `restoreGatewayQueuedOperatorRecovery` → `prepareOperatorAdmission` + `decideOperatorAdmission`. But `decideOperatorAdmission` only narrows the saved scopes to the current role (`scopes = intersectOperatorScopes(scopes, role.scopes)`) and refuses only when no scope is left. The demoted requester was admitted with `["operator.read"]`, and nothing at the start needed write. A live `chat.send` needs `operator.write` (method scope table), so the queued start accepted a requester that a live send refuses. ## Fix In `prepareFollowupRunOperatorAuthority`, right after admission decides, refuse the start when the admitted scopes lack the write grant a live `chat.send` needs (`operator.write`, or the own-session `operator.sessions.write`, which `operatorScopeSatisfied("operator.sessions.write", …)` covers together with write and admin). The refusal uses the existing `GatewayOperatorRecoveryAuthorizationError` path: the pending input ends `cancelled` / `policy-refused`, the run ends `aborted`, and no provider request is made. Channel senders (authority with a `channelRecoverySource`) are not affected: their live turns never need `operator.write`, so their queued turns don't either. ### Decisions - **Why not inside `decideOperatorAdmission`?** It also re-admits in-run continuations (`captureGatewayOperatorContinuation`: in-process plugin dispatch, `nodes.invoke`, question access), session sharing reads, and channel-linked identities that can have a read-only role. A write requirement there would refuse a demoted requester's running turn mid-run (against "a started run finishes") and would refuse read-only channel users' queued messages that run live. The requirement belongs to the start that is a turn, and this is that start's owner. - Production code: about +17 −1 in one file (the check and its imports). Not net negative: the cause is a missing requirement, not extra code. No new state, flag or hook. - Other queued turn starts (scheduled plugin commands, system turns) are not changed here. ## Evidence - New test `refuses a queued followup when its requester loses operator.write before it starts` (`src/gateway/server-methods/chat-send-direct-followup.test.ts`), through real `chat.send` → queue → drain: red on base (follow-up executes; pending input never refused), green on head. - Before push, one `ocx test` run over the touched test plus every test importing `queue/lifecycle.ts` (20 files). - E2E (`one-admission-e2e`: isolated Gateway, trusted-proxy Control UI clients, real `openai/gpt-5.5` turn): - base `980f6c9e73e9`: Q **fails**: the queued follow-up ran and made 1 provider request. - head `32d27d3bef`: all checks pass. - R (revoke while running → finishes): `toolEnds: 3, toolEndsAfterRevoke: 3`, state `final`. - Q (revoke while queued → refused visibly): 0 provider requests with the queued marker. The pending input ends `cancelled` / `policy-refused`. Control UI renders it in the thread as "This message was blocked by a policy and did not run." - S (Stop → cancels): state `aborted`. - The E2E checker first read only `messages`. The refusal shows on the pending-input row, which the Control UI thread also renders, so the checker now reads `pendingInputs` too. It still needs 0 provider requests, so base still fails. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 23, 2026
…d it (openclaw#203521) ## Problem Every queued, scheduled, replayed or resumed start re-admits its saved requester through `src/gateway/operator-run-recovery.ts`, which runs `prepareOperatorAdmission` + `decideOperatorAdmission`. `decideOperatorAdmission` only narrows the saved scopes to the current role, and it refuses only when no scope is left. So a requester whose role changed to read-only before the start was admitted with `["operator.read"]`. openclaw#203468 closed this for the queued `/followup` path only. Audit on `main` (requester's role changed before the start): | Start | Creation grant | Read-only on `main` | |---|---|---| | Queued chat, `/followup`, collected batch, Goal successor | write | refused (openclaw#203468 per-path check) | | Restart replay of a queued chat input | write | refused later by `chat.send` method scopes | | Restart completion wake | write | refused later by `agent` method scopes | | System turn, restart resume | write | refused (`prepareSessionPrincipalRunAccess`) | | Worker environment provision resume | admin (`environments.create`) | **starts** | | Plugin service session work | the run that accepted it | **starts** | | Cron agent turn, command, script | cron | **starts** | | Cron conversation event | cron | **starts** at the event target (refused later only by openclaw#203468's write check, which also refused cron-only creators) | | Native stream source | cron | **starts** | | Scheduled plugin command | cron | **starts** | | In-run continuation | (started run) | admitted, must stay admitted | ## Fix One private admission body, two exported start entries that differ only in the grant they require now: - `restoreGatewayQueuedOperatorRecovery` / `restoreGatewayOperatorSource`: the requester must hold `operator.sessions.write` (write, admin and own-session write satisfy it; what a live `chat.send` needs). - New `restoreScheduledAutomationOperator`: the requester must hold `operator.cron` (write and admin satisfy it; what creating an automation needs). - Refusal uses the existing `GatewayOperatorRecoveryAuthorizationError`. Channel senders (`channelRecoverySource`) are exempt, as before. `captureGatewayOperatorContinuation` uses the private body without a start grant: a started run finishes. Each call site picks its entry by the grant that authorized creating the work: - Automation entry: cron runs (`cron-operator-source.ts`), native stream sources (`cron-stream-source-authority.ts`), cron conversation events (`session-event-target.ts`; only cron supplies a deferred operator source there), scheduled plugin commands (`plugin-command-scheduled-run.ts`), and the queued follow-up of a cron conversation event (`queue/lifecycle.ts`, when `scheduledAutomation` is set). - Write entry: queued chat and `/followup` (`queue/lifecycle.ts` otherwise), restart replay, completion wake, system turns, worker provisioning resume. - Plugin service session work is the one site whose work can come from either a chat turn or a cron run, and it stores only the run's snapshot. It reads the grant from that snapshot: a snapshot that held `operator.sessions.write` needs write now; one that held only `operator.cron` needs cron or write now. No new state. - openclaw#203468's per-path check in `queue/lifecycle.ts` is deleted; the shared entries cover that path. ### Decisions - Option 2 of the design review: the entry name carries the start kind. No parameter or flag, and no exported generic entry, so a start with no stated kind cannot be written. - `decideOperatorAdmission` is unchanged: it cannot tell a start from a continuation from its facts. - Accepted edge case: service work that a cron run started for a writer later moved to a cron-only role is refused visibly at its next start, because its snapshot held write. Every other automation from that writer keeps starting through the automation entry. - Completion wakes and system turns stay on the write entry even when a cron run caused them: on `main` they already needed write (`agent` method scopes, `prepareSessionPrincipalRunAccess`), so no cron-only creator loses anything. - The sandbox stream keeps its own `operator.write` check (`cron-stream-sandbox-authority.ts` calls `decideOperatorAdmission` directly). - Production code is not net negative (+117/−89, +28): the cause is the missing grant at start, and the automation entry plus the per-site choice is the minimum for it. The admission body is now shared instead of duplicated. - Tests that asserted a read-only next start was admitted with `["operator.read"]` now assert the refusal (`operator-run-recovery.test.ts` publication case, `operator-run-recovery.access-policy.test.ts`, `remote-control-ui-ingress.integration.test.ts` viewer recovery). ## Evidence - New table test `src/gateway/operator-run-recovery.start-grant.test.ts` (24 rows). Each start kind goes through the entry its producer uses, with the saved-source shape it stores: - every chat-like kind is refused when the writer becomes read-only and when the writer becomes cron-only; - every automation kind is admitted for a cron-only creator and refused when its creator becomes read-only; - an in-run continuation and a read-only channel sender stay admitted. - Head: 24/24 pass. Base `735a7475c1fb` (with `restoreScheduledAutomationOperator` aliased to the unchecked queued restore that base's automation sites use): 17 fail (all 12 chat-like rows and the 5 automation read-only rows), 7 pass (5 cron-only admits, continuation, channel). - The `/followup` rows fail at the shared entry on base; end to end, base refused read-only there through openclaw#203468's check, which this PR moves into the shared entry. - `service-session-work.test.ts`: work accepted with `operator.write` or `operator.sessions.write` restores through the write entry; work accepted with only `operator.cron` restores through the automation entry. - Before push, one `ocx test` run over the touched tests plus every test importing a changed source (53 files). Reds outside this PR, each also red on base `735a7475c1fb`: `cron.scheduled-policy-adoption.integration.test.ts` (3 owner-origin cases, "No model is configured"), and the intermittent `operator-admission.table.test.ts > principal > before-start` flake. `ci-changed-node-test-plan.source-owners.test.ts` needed the new file committed and passes after the commit. `tsgo:core` and `tsgo:core:test` pass; oxfmt/oxlint clean. - E2E (`one-admission-e2e`: isolated Gateway, trusted-proxy Control UI clients, real model turn) on `2fb4824f6db4` and again on the final head `5a06fa530986`, all pass: - R (revoke while running → finishes): `state: final`, `toolEnds: 3`, `toolEndsAfterRevoke: 3`. - Q (revoke while queued → refused visibly): `providerRequestsWithQueuedMarker: 0`, `visibleRefusalInTranscript: true`. - S (Stop → cancels): `state: aborted`. - Local ClawSweeper review: round 1 (`2fb4824f6db4`) and round 2 (`5a06fa530986`) findings are answered in `Rejected review findings:` comments (the accepted service-work edge case; restart system turns and completion wakes, which already needed write on `main`). - CI: the only failure caused by this PR (round 1, a read-only recovery fixture in `operator-run-authority.principal.test.ts`) is fixed. The remaining reds also fail on `main` (openclaw#203496, openclaw#203542); see the `Maintainer override:` comment. Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus
added a commit
that referenced
this pull request
Nov 23, 2026
…efusals (#204048) ## Problem Authority is checked once, when work starts. A started run may finish; Stop cancels; data fences stay. After parts 1 and 2 (#203999, #204031), some checks in `src/agents`, `src/channels/inbound-event` and the bundled Discord and Telegram native commands still re-read permissions mid-run, or refuse a data/lifecycle condition with text that claims "authority changed / is no longer active". This is part 3 of the agents/sessions/auto-reply refusal sweep. ## Fix Test for each site: can it fire when only a permission, approval or config changes while nothing about the run or data changes? Yes → authority re-check, deleted. No → Stop, run close or data fence, kept and reworded. | Site | Kind | Action | |---|---|---| | `channels/inbound-event/host-context-builder.ts` channel operator `assertCurrent` ("Channel operator authority changed; send a new request.") | authority (called only once, inside `captureChannelOperatorRunAuthority`, right after the same `isCurrent` check) | **deleted**. The operator decision is taken once when the message is admitted (the existing `isCurrent` gate). The admitted authority's own `assertCurrent` was already Stop-only (`signal?.throwIfAborted()`), so queued channel messages do not re-read the enqueue-time operator; they start through the normal queued-start admission (#203468/#203521), unchanged | | `gateway/operator-run-authority.ts` `captureChannelOperatorRunAuthority` `assertCurrent` input | plumbing for the above (only called once, at capture) | **deleted**. Its other caller, `gateway/session-activity-summary-authority.ts`, now runs its own one-time check directly before the capture (same check, same moment) | | `auto-reply/command-owner-authority.ts` `CommandOwnerRevokedError` and the `instanceof` branch in `agents/command/delivery-authority.ts` | dead after the delete (no thrower left) | **deleted** | | `agents/harness/node-execution-authority.ts` live `permissionMode === "full"` re-read (`retainedFullPermission`, `fullPermissionAllowed`) | authority (session permission mode) | **deleted**; Full stays the attempt's admitted mode (`attempt.permissionMode`, `admittedFull`) | | same file, "admitted node execution authority is no longer current" (signal, plugin registry/lifecycle, Gateway context, plugin id, session occurrence, workspace) | Stop / run close / data fence | kept, reworded: "The run or its session ended. Start a new turn to retry." | | `agents/harness/tool-authority.runtime.ts` `operatorAuthority?.assertCurrent()` in `assertReplyActive` | authority (Stop is already covered by `assertAdmitted`, which reads the run's abort signal) | **deleted** | | same file, "embedded tool authority is no longer active" ×2 (lease closed, run instance/run id changed) | run close / occurrence | kept, reworded: "The agent run ended. Start a new turn to retry." | | same file, "reply authority is no longer active", "embedded reply authority is no longer active" (operation route/fingerprint or attachment changed) | data fence | kept, reworded (existing text): "The reply target changed. Start a new turn to retry." | | same file, "Embedded attempt authority changed during steering" | data fence | kept, reworded (existing text): "Steering target changed" | | `agents/tools/gateway-caller-context.ts` "agent tool caller authority is no longer active" (no active admitted run lease) | run close | kept, reworded: "The agent run ended. Start a new turn to retry." | | `agents/tools/presence-tool-authority.ts` `hasCurrentClientAuthority() === false` ("Gateway caller authority is no longer active.") | authority (client re-auth) | **deleted**; request Stop (`scope.signal`) kept | | `agents/tools/sessions-operator-authority.ts` `hasCurrentClientAuthority() === false` ("Session control caller authority is no longer active.") | authority (client re-auth) | **deleted** | | `agents/subagents/announce/subagent-announce.requester-settle-receipt.ts` "Requester settle authority changed during watch admission" (requester entry gone or store source changed) | data fence | kept, reworded: "Requester session ended during watch admission" | | `agents/subagents/requester-cron-authority.ts` "Requester session authority changed before yield handoff" (session id, archive, lifecycle revision) | data fence | kept, reworded: "Requester session was reset or archived; yield handoff stopped" | | same file, "Requester followup authority is no longer current", "Requester authority is no longer current" (`isCurrent`: active flag, lifecycle generation, binding, session revision; the channel-owner part is ingress lifetime only since #204031) | lifecycle / data fence | kept, reworded: "Requester followup ended", "Requester continuation ended" | | `agents/worktrees/registry-run-end.worker.ts` "Managed worktree binding authority changed.", `run-end-lifecycle.ts` "Managed worktree registry authority changed; …" (registry row revision/owner fences) | data fence | kept, reworded: "Managed worktree binding changed.", "Managed worktree registry changed; prepare the operation again" | | `extensions/discord/src/monitor/native-command-auth.ts` deprecated `CommandAuthorization.assertOwnerCurrent` read, `assertActive` ("Discord command authority changed; send a new request."), `assertOwnerCurrent` ("Discord owner authority changed; send a new request.") | authority (config/owner re-read after admission) | **deleted**. Access is read once at admission (`resolveDiscordNativeCommandAccess` returns `allowed` and `senderIsOwner`); the second `isAllowed()` after ACP binding readiness and the `assertAuthority`/`assertActive`/`assertOwnerCurrent` plumbing are gone | | `extensions/telegram/src/{ingress,bot-native-command-dispatch,bot-native-command-plugins}.ts` deprecated `assertOwnerCurrent` reads | dead (`undefined` since #204031) | **deleted** | Left unchanged: - `bash-tools.exec-host-shared.ts` matcher (R6d). - `agents/worktrees/errors.ts` "GitHub publication worktree authority changed" (a registry data fence). Cut less: its only test expectation lives in `gateway/github-publication.test.ts`, which carries a synthetic credential-URL fixture that the local review's input scanner refuses; the reword goes with the next gateway sweep. - `operatorAuthority.assertCurrent` callers in `src/auto-reply/**` (~42 files) and `src/agents/**` (~70 files). Split per the ~25-file rule: this PR is 20 production files; the callers go to part 4. - `extensions/discord/.../message-handler.draft-preview.ts` and `extensions/telegram/src/telegram-ingress-non-retryable.ts` strings (R6d area). Production: 20 files, +95/−198. The lifetime-check ratchet counts fall in every touched file; `config/session-identity-allowlist.txt` is pruned for the reworded "no longer active" strings. ## User impact - A linked channel user whose operator role or link changes after their message was admitted sees the run finish. The next message is admitted again. - A Discord native command whose sender loses command or owner access while it runs now finishes, as admission decided. - A session in Full permission mode whose mode is lowered during a run keeps node execution for that run; the next run uses the new mode. - Refusals that remain now name what ended and the next step instead of claiming an authority change. - No new refusal, prompt or wait. Stop still cancels. ## Tests Deleted (they assert a mid-run permission refusal): - `discord native-command.interaction-boundary.test.ts` `revoked-command` and `revoked-channel` rows (config/policy changed during the command). - `sessions-control-authority.test.ts` "keeps the live client check when the ambient authority is passed back as prepared" (client deauth mid-run). - `gateway.sessions-send-provenance.authority.test-support.ts` `unlink` and `reassign` phases (linked principal unlinked during final send). The `current` phase stays: a linked principal's message delivers. - `host-capability.node-authority.test.ts` and `agent-runner-node-authority.test.ts` `permission` rows (session lowered from Full to workspace during the run). - `commands-plugin.channel-native.test.ts` fixture cleanup for children that failed with the removed "Channel operator authority changed" text. Text-only updates (same condition): `tool-authority.runtime.participants`, `.admission`, `.retention` support, `sessions-send-followup-revalidation`, `worker-session-tool-executor`, `server.requester-pause-authority`, `local-request-context.session-tools`, node-authority run-end text. Capture-time input removed: `operator-run-authority.worker.test.ts` (the capture no longer runs a caller check; the caller gates before capture) and `operator-access-program.worker.test.ts`. Pre-push (local): - `ocx test` with `OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1` on 47 touched and directly related test files (the 537-file importer set is over the 150 cap; CI runs the rest). Reds: 3 text expectations and one capture-time test (updated above), 11 files invalidated by a mid-run edit (rerun: 13 files pass), and `gateway.sessions-send-provenance.e2e` cross-human phase (`collaborativeSteeringRefused`), which fails the same way on the merge base `6523d6ace21c`. - `pnpm tsgo:core`, `pnpm tsgo:test`, `pnpm tsgo:extensions`: clean. - oxfmt and oxlint on changed files: clean. - lifetime-check and session-identity ratchets: OK (allowlist pruned 6289 → 6281). - CI round 1 OURS (4 files: requester-pause text, node-authority `permission` rows + text, session-tools text) fixed and rerun locally with 15 files that match the old texts: all pass. Round 1 MAIN-ALSO, each red on merge base `6523d6ace21c` locally: `question.session-access`, `question.communication`, `question.own-run`, `question.recovery`, `member-profile-role-recovery`, `mcp-http.personal-authority`, `mcp-http.async-scope`, `github-publication-imported-actions`, `ui sidebar-complete-roster`. ## Evidence One-admission E2E (isolated Gateway, real model) on head `fbea806e12bd`, `verdict.json` pass: - R `running-turn-finishes`: pass (revoke while running → the turn finishes) - Q `queued-input-refused-visibly`: pass (revoke while queued → refused visibly) - S `stop-cancels`: pass (Stop → aborted) Local review on `fbea806e12bd`: "patch is correct", no findings. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 24, 2026
…efusals (openclaw#204048) ## Problem Authority is checked once, when work starts. A started run may finish; Stop cancels; data fences stay. After parts 1 and 2 (openclaw#203999, openclaw#204031), some checks in `src/agents`, `src/channels/inbound-event` and the bundled Discord and Telegram native commands still re-read permissions mid-run, or refuse a data/lifecycle condition with text that claims "authority changed / is no longer active". This is part 3 of the agents/sessions/auto-reply refusal sweep. ## Fix Test for each site: can it fire when only a permission, approval or config changes while nothing about the run or data changes? Yes → authority re-check, deleted. No → Stop, run close or data fence, kept and reworded. | Site | Kind | Action | |---|---|---| | `channels/inbound-event/host-context-builder.ts` channel operator `assertCurrent` ("Channel operator authority changed; send a new request.") | authority (called only once, inside `captureChannelOperatorRunAuthority`, right after the same `isCurrent` check) | **deleted**. The operator decision is taken once when the message is admitted (the existing `isCurrent` gate). The admitted authority's own `assertCurrent` was already Stop-only (`signal?.throwIfAborted()`), so queued channel messages do not re-read the enqueue-time operator; they start through the normal queued-start admission (openclaw#203468/openclaw#203521), unchanged | | `gateway/operator-run-authority.ts` `captureChannelOperatorRunAuthority` `assertCurrent` input | plumbing for the above (only called once, at capture) | **deleted**. Its other caller, `gateway/session-activity-summary-authority.ts`, now runs its own one-time check directly before the capture (same check, same moment) | | `auto-reply/command-owner-authority.ts` `CommandOwnerRevokedError` and the `instanceof` branch in `agents/command/delivery-authority.ts` | dead after the delete (no thrower left) | **deleted** | | `agents/harness/node-execution-authority.ts` live `permissionMode === "full"` re-read (`retainedFullPermission`, `fullPermissionAllowed`) | authority (session permission mode) | **deleted**; Full stays the attempt's admitted mode (`attempt.permissionMode`, `admittedFull`) | | same file, "admitted node execution authority is no longer current" (signal, plugin registry/lifecycle, Gateway context, plugin id, session occurrence, workspace) | Stop / run close / data fence | kept, reworded: "The run or its session ended. Start a new turn to retry." | | `agents/harness/tool-authority.runtime.ts` `operatorAuthority?.assertCurrent()` in `assertReplyActive` | authority (Stop is already covered by `assertAdmitted`, which reads the run's abort signal) | **deleted** | | same file, "embedded tool authority is no longer active" ×2 (lease closed, run instance/run id changed) | run close / occurrence | kept, reworded: "The agent run ended. Start a new turn to retry." | | same file, "reply authority is no longer active", "embedded reply authority is no longer active" (operation route/fingerprint or attachment changed) | data fence | kept, reworded (existing text): "The reply target changed. Start a new turn to retry." | | same file, "Embedded attempt authority changed during steering" | data fence | kept, reworded (existing text): "Steering target changed" | | `agents/tools/gateway-caller-context.ts` "agent tool caller authority is no longer active" (no active admitted run lease) | run close | kept, reworded: "The agent run ended. Start a new turn to retry." | | `agents/tools/presence-tool-authority.ts` `hasCurrentClientAuthority() === false` ("Gateway caller authority is no longer active.") | authority (client re-auth) | **deleted**; request Stop (`scope.signal`) kept | | `agents/tools/sessions-operator-authority.ts` `hasCurrentClientAuthority() === false` ("Session control caller authority is no longer active.") | authority (client re-auth) | **deleted** | | `agents/subagents/announce/subagent-announce.requester-settle-receipt.ts` "Requester settle authority changed during watch admission" (requester entry gone or store source changed) | data fence | kept, reworded: "Requester session ended during watch admission" | | `agents/subagents/requester-cron-authority.ts` "Requester session authority changed before yield handoff" (session id, archive, lifecycle revision) | data fence | kept, reworded: "Requester session was reset or archived; yield handoff stopped" | | same file, "Requester followup authority is no longer current", "Requester authority is no longer current" (`isCurrent`: active flag, lifecycle generation, binding, session revision; the channel-owner part is ingress lifetime only since openclaw#204031) | lifecycle / data fence | kept, reworded: "Requester followup ended", "Requester continuation ended" | | `agents/worktrees/registry-run-end.worker.ts` "Managed worktree binding authority changed.", `run-end-lifecycle.ts` "Managed worktree registry authority changed; …" (registry row revision/owner fences) | data fence | kept, reworded: "Managed worktree binding changed.", "Managed worktree registry changed; prepare the operation again" | | `extensions/discord/src/monitor/native-command-auth.ts` deprecated `CommandAuthorization.assertOwnerCurrent` read, `assertActive` ("Discord command authority changed; send a new request."), `assertOwnerCurrent` ("Discord owner authority changed; send a new request.") | authority (config/owner re-read after admission) | **deleted**. Access is read once at admission (`resolveDiscordNativeCommandAccess` returns `allowed` and `senderIsOwner`); the second `isAllowed()` after ACP binding readiness and the `assertAuthority`/`assertActive`/`assertOwnerCurrent` plumbing are gone | | `extensions/telegram/src/{ingress,bot-native-command-dispatch,bot-native-command-plugins}.ts` deprecated `assertOwnerCurrent` reads | dead (`undefined` since openclaw#204031) | **deleted** | Left unchanged: - `bash-tools.exec-host-shared.ts` matcher (R6d). - `agents/worktrees/errors.ts` "GitHub publication worktree authority changed" (a registry data fence). Cut less: its only test expectation lives in `gateway/github-publication.test.ts`, which carries a synthetic credential-URL fixture that the local review's input scanner refuses; the reword goes with the next gateway sweep. - `operatorAuthority.assertCurrent` callers in `src/auto-reply/**` (~42 files) and `src/agents/**` (~70 files). Split per the ~25-file rule: this PR is 20 production files; the callers go to part 4. - `extensions/discord/.../message-handler.draft-preview.ts` and `extensions/telegram/src/telegram-ingress-non-retryable.ts` strings (R6d area). Production: 20 files, +95/−198. The lifetime-check ratchet counts fall in every touched file; `config/session-identity-allowlist.txt` is pruned for the reworded "no longer active" strings. ## User impact - A linked channel user whose operator role or link changes after their message was admitted sees the run finish. The next message is admitted again. - A Discord native command whose sender loses command or owner access while it runs now finishes, as admission decided. - A session in Full permission mode whose mode is lowered during a run keeps node execution for that run; the next run uses the new mode. - Refusals that remain now name what ended and the next step instead of claiming an authority change. - No new refusal, prompt or wait. Stop still cancels. ## Tests Deleted (they assert a mid-run permission refusal): - `discord native-command.interaction-boundary.test.ts` `revoked-command` and `revoked-channel` rows (config/policy changed during the command). - `sessions-control-authority.test.ts` "keeps the live client check when the ambient authority is passed back as prepared" (client deauth mid-run). - `gateway.sessions-send-provenance.authority.test-support.ts` `unlink` and `reassign` phases (linked principal unlinked during final send). The `current` phase stays: a linked principal's message delivers. - `host-capability.node-authority.test.ts` and `agent-runner-node-authority.test.ts` `permission` rows (session lowered from Full to workspace during the run). - `commands-plugin.channel-native.test.ts` fixture cleanup for children that failed with the removed "Channel operator authority changed" text. Text-only updates (same condition): `tool-authority.runtime.participants`, `.admission`, `.retention` support, `sessions-send-followup-revalidation`, `worker-session-tool-executor`, `server.requester-pause-authority`, `local-request-context.session-tools`, node-authority run-end text. Capture-time input removed: `operator-run-authority.worker.test.ts` (the capture no longer runs a caller check; the caller gates before capture) and `operator-access-program.worker.test.ts`. Pre-push (local): - `ocx test` with `OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1` on 47 touched and directly related test files (the 537-file importer set is over the 150 cap; CI runs the rest). Reds: 3 text expectations and one capture-time test (updated above), 11 files invalidated by a mid-run edit (rerun: 13 files pass), and `gateway.sessions-send-provenance.e2e` cross-human phase (`collaborativeSteeringRefused`), which fails the same way on the merge base `8a52d1d0de83`. - `pnpm tsgo:core`, `pnpm tsgo:test`, `pnpm tsgo:extensions`: clean. - oxfmt and oxlint on changed files: clean. - lifetime-check and session-identity ratchets: OK (allowlist pruned 6289 → 6281). - CI round 1 OURS (4 files: requester-pause text, node-authority `permission` rows + text, session-tools text) fixed and rerun locally with 15 files that match the old texts: all pass. Round 1 MAIN-ALSO, each red on merge base `8a52d1d0de83` locally: `question.session-access`, `question.communication`, `question.own-run`, `question.recovery`, `member-profile-role-recovery`, `mcp-http.personal-authority`, `mcp-http.async-scope`, `github-publication-imported-actions`, `ui sidebar-complete-roster`. ## Evidence One-admission E2E (isolated Gateway, real model) on head `fbea806e12bd`, `verdict.json` pass: - R `running-turn-finishes`: pass (revoke while running → the turn finishes) - Q `queued-input-refused-visibly`: pass (revoke while queued → refused visibly) - S `stop-cancels`: pass (Stop → aborted) Local review on `fbea806e12bd`: "patch is correct", no findings. Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 24, 2026
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)
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 24, 2026
…3521) Release adaptation: enforce the grant inside the stable Gateway snapshot restoration owner, at explicit start call sites. Retain target and occurrence ownership, stable channel admission, and unconstrained read and in-run continuation restoration. Stable session events have no separate deferred operator source; their scheduled source is restored at the producer. In-memory followup keeps its stable reauthorize admission (#203468 equivalent). #202513 full owner redesign is not a prerequisite for this check. (cherry picked from commit 3cd3a31) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 639f3ca0a12615e3bc32cd5947e356fa2635c778)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Control UI user with
operator.read+operator.writestarts a turn, then sends/followup …. The follow-up waits in the session queue (pendingInputs, statequeued). An admin then changes the user's role to read-only (operator.read). When the running turn ends, the queued follow-up still starts and reaches the model.The queued start already goes through admission:
prepareFollowupRunOperatorAuthority(src/auto-reply/reply/queue/lifecycle.ts) →restoreGatewayQueuedOperatorRecovery→prepareOperatorAdmission+decideOperatorAdmission. ButdecideOperatorAdmissiononly narrows the saved scopes to the current role (scopes = intersectOperatorScopes(scopes, role.scopes)) and refuses only when no scope is left. The demoted requester was admitted with["operator.read"], and nothing at the start needed write. A livechat.sendneedsoperator.write(method scope table), so the queued start accepted a requester that a live send refuses.Fix
In
prepareFollowupRunOperatorAuthority, right after admission decides, refuse the start when the admitted scopes lack the write grant a livechat.sendneeds (operator.write, or the own-sessionoperator.sessions.write, whichoperatorScopeSatisfied("operator.sessions.write", …)covers together with write and admin). The refusal uses the existingGatewayOperatorRecoveryAuthorizationErrorpath: the pending input endscancelled/policy-refused, the run endsaborted, and no provider request is made.Channel senders (authority with a
channelRecoverySource) are not affected: their live turns never needoperator.write, so their queued turns don't either.Decisions
decideOperatorAdmission? It also re-admits in-run continuations (captureGatewayOperatorContinuation: in-process plugin dispatch,nodes.invoke, question access), session sharing reads, and channel-linked identities that can have a read-only role. A write requirement there would refuse a demoted requester's running turn mid-run (against "a started run finishes") and would refuse read-only channel users' queued messages that run live. The requirement belongs to the start that is a turn, and this is that start's owner.Evidence
refuses a queued followup when its requester loses operator.write before it starts(src/gateway/server-methods/chat-send-direct-followup.test.ts), through realchat.send→ queue → drain: red on base (follow-up executes; pending input never refused), green on head.ocx testrun over the touched test plus every test importingqueue/lifecycle.ts(20 files).one-admission-e2e: isolated Gateway, trusted-proxy Control UI clients, realopenai/gpt-5.5turn):7a570c41bc27: Q fails: the queued follow-up ran and made 1 provider request.32d27d3bef: all checks pass.toolEnds: 3, toolEndsAfterRevoke: 3, statefinal.cancelled/policy-refused. Control UI renders it in the thread as "This message was blocked by a policy and did not run."aborted.messages. The refusal shows on the pending-input row, which the Control UI thread also renders, so the checker now readspendingInputstoo. It still needs 0 provider requests, so base still fails.