Skip to content

refactor: drop the admitted operator authority re-check and the lifetime ratchet (R6z) - #204249

Merged
obviyus merged 12 commits into
mainfrom
refactor/drop-reauthorize
Nov 24, 2026
Merged

obviyus merged 12 commits into
mainfrom
refactor/drop-reauthorize

Conversation

@obviyus

@obviyus obviyus commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

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 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.
  • E2E one-admission-e2e/run.sh: see the comment.

@clawsweeper

clawsweeper Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review blocked

Automated 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.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling extensions: codex size: XL labels Nov 23, 2026
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

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 assertCurrent or onModelPolicyChanged. Stop, run-close and data-fence cases stay and keep their condition.

agents / acp / sessions / extensions

  • "publishes latched operator revocation without reviving its source (source signal=%s)"
  • retained-owner rows revoked, owner-revoked
  • "keeps a committed CLI reply successful after operator model authority revokes post-commit"
  • the mid-run revocation step of "selects the permitted default before execution and holds its current authority"
  • "keeps retained unknown-model work admitted through policy introduction and releases once"
  • "keeps admitted CLI output and surviving models available after a logical model is removed"
  • "keeps admitted completions and siblings alive while the next start uses current policy"
  • "withholds a delayed location result after the original operator is revoked"
  • "publishes committed registration despite operator policy revocation before ACK"
  • publication, final-outbound, automation and requester-reply revoked variants
  • registration source callback; completion policy-revoked and cancelled-by-another-operator variants (the latter revoked operator access; it was not a Stop)
  • independent-participant revocation blocks; native facade live-policy and in-flight-revocation blocks
  • Codex: revoked compaction, credential caller, parent continuation, Access retry and supervised-model variants
  • "cancels an unqualified parent on new policy while preserving its permitted sibling"
  • "keeps the admitted applied-model ceiling through the pre-prompt guard"
  • "rechecks caller authority after model preparation before mutation"
  • "rechecks operator authority after loading the thinking catalog"
  • message-join revoked-source, late-source-and-cohort-revocation, "incoming authority revoked independently"
  • image tool rows retired after download (admitted, direct)

auto-reply

  • "keeps input through preparation only for a revoked during preflight source"
  • "preserves input at fingerprint-1/-2 (caller revoked: true, …)"
  • "uses creator policy and incoming source authority for operator-source"
  • "retains the accepted input and physical owner across independent revoked mutation"
  • "settles revoked before admission / after admission / without target without replay and preserves its visible classification"
  • "settles memory target preparation after operator revocation during mkdir / open"
  • "keeps captured policy isolated and checks revocation after preparation"
  • "checks operator revocation again after asynchronous final enqueue preparation"
  • "leaves the notice with dispatch after a recorded authority revocation"
  • revoked-after-bind, revoked-before-bind and revoked rows of the channel-owner ingress cases

cron / plugins

  • "rejects retired requester before direct / isolated provider execution from agent-tool"
  • "rechecks a retired requester after awaited direct / isolated pricing before publishing usage"
  • "retains the requester through direct / isolated cleanup after returning the denial"
  • "records a retired cron follow-up without replay (automation=false)": only the fixture put the delivery fence on the operator authority; production carries it on scheduledAutomation.deliveryAttemptFence (the kept case)

gateway

  • "users.prefs refuses a pending write when the participant is revoked before worker commit"
  • "settles accepted steering custody after source revoked (backend settlement: true)"
  • "validates model fixture/allowed after preparation (change=source)"
  • revocation steps inside the participant, theme, screen-request, Access-grant, family-wildcard and model-selection cases
  • "rechecks collaborative admission after awaited projection: caller revoked"
  • "does not publish after revocation during an awaited native-owner read"
  • run rows of "%s refuses authority revoked during discovery" and "rechecks current membership, policy, source, and caller after message preparation"
  • "preserves assertion revocation across modules"
  • revoked and result-revoked rows of "keeps original caller custody and delivery for remote exec: %s"
  • "sessions.create rejects a session-only creator revoked after initial mention validation"
  • "durable replay refuses membership revocation after authorization and before metadata disclosure"
  • "durable cold / warm replay refuses membership removal at final response publication"
  • "sessions.create refuses persistence after membership changes during worker preparation"
  • "does not deliver detail when the original operator is revoked during the read"
  • "rejects revoked / rotated caller authority before I/O" (commit/outer, commit/authorization, commit/inner, session/inner)
  • account-capture rows role scope, connection scope, profile; stalled catalog wait authority revocation
  • "rechecks delegated source authority before filesystem mutation" (the commit-guard case stays)
  • profile merge rows of "keeps bound native V2 steering on its captured owner" (native, mailbox)
  • profile merge mid-approval: "terminalizes a native command account merge during fresh transcript approval without rewriting the ACK"

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 64eb20a152759c4f2f0f9e3ab10f26c9e7cccf67
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/admitted-run-operator-authority.types.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/gateway/cron-creator-authority-grant.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/cron-stream-sandbox-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-invocation-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-role-policy.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-run-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/agent.caller-authority.test-utils.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/nodes.invoke-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-plugin-in-process-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/session-access-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/session-activity-summary-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/session-permission-authorization.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/session-sharing-authorization-async.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/talk/client-run-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/security/dangerous-tools.ts: Controls product security checks or trust decisions. Check whether the change weakens detection, protection, or remediation.

Carefully review these changes before merging.

obviyus and others added 8 commits November 24, 2026 03:11
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]>
@obviyus
obviyus force-pushed the refactor/drop-reauthorize branch from 580ee16 to 35055f0 Compare November 23, 2026 21:42
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Evidence on head 35055f0070a5:

  • E2E one-admission-e2e/run.sh on the head: pass. R: the running turn finishes after the revoke (3 tool ends after the revoke). Q: the queued input is refused visibly (0 provider requests with the queued marker; the refusal is shown in the transcript). S: Stop cancels (state aborted). The proof is in verdict.json and results.jsonl from /tmp/one-admission-e2e.umZeBA.
  • Local ClawSweeper review: complete, "patch is correct", 0 findings. The review covered the range 70de2e540e76..35055f0070a5. The first commit (70de2e540e76, test only) removes the synthetic https://user:[email protected]/... URL from the redaction fixture in src/gateway/github-publication.test.ts. The local review's input scanner refuses any diff that shows the removed credential line, so that one-line synthetic-fixture change sits below the reviewed range.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 23, 2026
obviyus and others added 3 commits November 24, 2026 04:42
…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
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Evidence on head 11a346f7ce68:

  • E2E one-admission-e2e/run.sh: pass. R (the running turn finishes after the revoke), Q (the queued input is refused visibly) and S (Stop cancels) all pass. The run is in /tmp/one-admission-e2e.mVDG0y (verdict.json, results.jsonl).
  • Local ClawSweeper review round 2: complete, "patch is correct", 0 findings (range 70de2e540e76..11a346f7ce68; the reason for this range is explained in the earlier evidence comment).
  • Refusal-string scan of production code (src, extensions, packages, without tests) for "authority changed", "authority is no longer active/current", "request connection is no longer current" and "changing before execution": 0 matches.
  • Lint rule: openclaw-boundaries/no-operator-permission-read reports 4 errors on the planted re-check fixture and 0 on the tree.

@obviyus

obviyus commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: head 64eb20a15275.

ci-triage on this head finds no failing test files. The only red is preflight: Canonical pull_request Node matrix has 189 jobs, exceeding limit 130. The planner selects broad lanes because config/session-identity-allowlist.txt changed. That change is a required one-line ratchet prune (cron-creator-authority-grant.ts 13 → 12, because a "no longer active" refusal string was removed). This is a CI planner cap, not a test result.

Since 11a346f7ce68, the last head with full PR CI, this head changes only the following:

  • config/session-identity-allowlist.txt: 1 line, the prune the ratchet asked for. check-session-identity-ratchet passes locally.
  • src/gateway/operator-run-authority.principal.test.ts: lint fix (no-underscore-dangle).
  • src/gateway/server-methods/chat-send-steering-commit.test-support.ts: deleted the internal fresh row, which asserts a refusal after a mid-steering profile merge (removed behavior). chat-send-steering-custody passes locally: 40/40.

Classification of the reds on 11a346f7ce68 (full CI):

  • OURS, fixed here: checks-fast-baseline-ratchets (the allowlist prune above), check-lint-core-5 (the lint fix above), chat-send-steering-custody internal fresh (deleted).
  • MAIN-ALSO (ci-triage): embedded-agent-runner.prompt-cache, agent-runner-compaction-fallback, server.chat-membership-authority.product.
  • Red on merge base 36bc0460f420 locally, not ours: gateway-restart-resume.e2e "blocked store: false", channel-progress-presentation.e2e (Slack and Discord announcement cases), session-run.session-model-strictness "preflight compaction", agent-runner-required-maintenance.pending-input "two archives".
  • Flakes, green locally on the head: subagent-registry.requester-wake.e2e (CI: 120 s timeouts; local: 50/50), extension-relay-daemon-spawn, codex session-catalog-backoff, voice-call signed-call-boundary (13/13, 3/3, 3/3).

Head evidence: local ClawSweeper review complete, "patch is correct", 0 findings. One-admission E2E Q/R/S pass on 11a346f7ce68; production code is identical on this head. The refusal-string scan of production code finds 0 matches. The lint rule fails on the planted re-check (4 errors).

@obviyus
obviyus merged commit 75cab7d into main Nov 24, 2026
96 of 99 checks passed
@obviyus
obviyus deleted the refactor/drop-reauthorize branch November 24, 2026 00:48
@obviyus

obviyus commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 75cab7d.

  • What it fixes: started runs could still be refused after a mid-run permission, role or model-policy change, through AdmittedRunOperatorAuthority.assertCurrent and onModelPolicyChanged.
  • Change: the type no longer has these members, and every reader is gone. Stop and data fences stay. The last three refusal strings are removed or reworded. The lifetime ratchet is replaced by the lint rule openclaw-boundaries/no-operator-permission-read.
  • Proof: local review clean on the head. One-admission E2E Q/R/S pass. Production code has 0 refusal strings. The lint rule fails on the planted re-check.
  • Follow-up: the cron creator grant still reads the issuing device's and channel owner's lifetime when the grant is consumed (see the PR body).

tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
* 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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…#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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…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]>
obviyus added a commit that referenced this pull request Nov 24, 2026
## 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]>
fransqaas added a commit to fransqaas/openclaw that referenced this pull request Nov 24, 2026
…opped mid-run authority re-checks (openclaw#204249)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 25, 2026
…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]>
fransqaas added a commit to fransqaas/openclaw that referenced this pull request Nov 27, 2026
… 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]>
obviyus added a commit that referenced this pull request Nov 27, 2026
… 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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
… 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. extensions: codex gateway Gateway runtime scripts Repository scripts security-sensitive-changed size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant