Repository navigation
fix: background command completions lose the owner's owner-only tools - #185476
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesBackground command completions retain their original requester's owner-only tools while that requester remains authorized. Example: Telegram owner 456 starts a background command, then its completion needs to restart the Gateway.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a remaining channel-owner continuation bug on current main; no introduced correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe exec notification producer captures the initiating requester, session-event admission builds the continuation, and existing tool and Gateway owners enforce current authority before effects. flowchart LR
A[Owner or guest request] --> B[Background exec]
B --> C[Captured event target]
C --> D[Session event admission]
D --> E[Live command owner check]
E --> F[Tool execution]
F --> G[Gateway effect]
Technical reviewBest possible solution: Retain this focused repair through the existing event-target, command-owner, and execution-admission owners. Do we have a high-confidence way to reproduce the issue? Current-main source shows the missing channel-owner capability, and the supplied proof demonstrates the repaired completion path; this read-only review ran no target code. Is this the best way to solve the issue? The patch repairs requester authority at the existing producer and context boundaries, preserves live revocation checks, and prevents different requesters from sharing a batch. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 228596060e33. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +167, Tests +126, Docs +1, Other +181. Total +475 across 12 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (5 earlier review cycles)
Reviewed October 27, 2026, 11:33 PM ET / October 28, 2026, 03:33 UTC (Revision 6). |
Keep main's operator ownerContinuation for publish and plugin-reload handoffs alongside the channel requester's commandOwner for exec completions. The context binds one of them, and batches refuse to mix either. Co-authored-by: jalehman <[email protected]> Co-authored-by: obviyus <[email protected]>
Co-authored-by: jalehman <[email protected]> Co-authored-by: obviyus <[email protected]>
Configured owners share the "configured-owner" source label while each authority rechecks only its own sender, so batching keyed on the label could run a revoked owner's completion under another owner's authority. Key the retained authority on the captured requester instead. Co-authored-by: jalehman <[email protected]> Co-authored-by: obviyus <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Maintainer override: landing past one unrelated red check.
|
|
Landed as aa8b35b.
Thanks @jalehman for the co-authored work. |
…er the owner is removed (#185796) Related: #185597, #185476 ## What Problem This Solves Fixes: a subagent spawned by a channel owner (for example a Telegram owner in `commands.ownerAllowFrom`) keeps running on its native runtime, such as Muse, after that person stops being an owner. ## User Impact An owner's subagent keeps remembered native runtime consent (`nativeRuntimeConsent`) only while the spawner is still an owner. When an operator removes the owner, the child stops before its next native dispatch. Children spawned by non-owners still get refused, and owner-spawned children still dispatch. ## Why This Change Was Made #185597 made remembered consent cover an owner's own turns. A child run already gets its owner fact from the spawner's live requester check (`prepareCommandOwnerAuthority`), not from the stored `spawnedBySenderIsOwner` receipt. But that check ran only while the Gateway admitted the child. After that, nothing checked it again, so removing the owner did not stop the child. This change adds the same check to the child run's source assertion. A channel owner's own turn already uses this pattern (`captureCommandOwnerAssertion` in the run's `assertSourceCurrent`). The harness host checks that assertion just before native dispatch. If the check fails, it stays failed for the rest of the run. ## Evidence Regression test (in-process): production-boundary test `fences remembered native consent for a child spawned by a channel %s`. It runs the real `sessions_spawn` tool, then the in-process Gateway `agent` admission, then the child's run parameters. The parent turn is a Telegram sender. The agent config has `nativeRuntimeConsent: ["native-fixture"]` and the child session modes are unset. The model-facing `senderIsOwner` receipt is `true` in both rows. - Owner (`telegram:456`): the child gets `senderIsOwner: true` and `assertAgentHarnessExecutionEnvironment` returns consent. When the owner is removed after admission, the captured admitted-run assertion (the one the harness host checks before `runAttempt`) throws. - Guest (`telegram:789`): the child gets `senderIsOwner: false` and consent is refused, even with an owner receipt. - Negative control: without the production change, the owner row fails because nothing stops the child after revocation. Also ran: - The full spawn production-boundary file (106 tests), `agent.test.ts` and `agent.followup-owner.test.ts` (414 tests), and `execution-environment.test.ts`: all pass. - `pnpm tsgo:core`, `pnpm tsgo:core:test`, oxlint and `git diff --check`: clean. ### Live proof: Telegram Test Server + real Muse Isolated Gateway with a leased Telegram Test Server bot and user. The parent agent is a deterministic mock model that issues a real `sessions_spawn`. Children run on the real Muse runtime (`meta/muse-spark-1.3`, Muse Code 1.4.11). Config: `nativeRuntimeConsent: ["muse"]`, `agents.defaults.subagents.model: meta/muse-spark-1.3`, `subagents.maxConcurrent: 1`. The tester is made an owner through `commands.ownerAllowFrom`, then removed by editing the config file while child A runs on Muse. A Gateway detail controls the timing: it defers an owner-removal config reload until active runs end, or until its 300 s timeout. Child A runs a 330 s shell `sleep` on Muse, so the removal takes effect while A is still running. | Step | `main` (`32f9477bf4`) | This PR | | --- | --- | --- | | Owner's child A dispatches to Muse | Yes: Muse replies (`muse-spark-1.3`) | Yes: Muse replies (`muse-spark-1.3`) | | Owner removed; reload applies after 300 s timeout | Applied | Applied | | Child A's next native dispatch | **Continues**: `FIRST_CHILD_DONE` is delivered to Telegram | **Stopped**: "Requester owner authority changed; send a new request." | | Queued child B (admitted before removal) | Refused, no Muse turn | Refused, no Muse turn | | Guest's child (tester not an owner) | — | Refused before Muse I/O: "Muse Code cannot enforce this conversation's tool policy." No Muse assistant turn. | So the discriminating case is a child that is already running when the removal applies. A queued child was already refused on `main`. ## Merge danger Two-way door. The change writes no state and does not change config or protocol, so a revert undoes it fully. Blast radius: only child runs whose owner fact comes from a channel requester (`requesterOwner`). If the owner is removed while such a child runs, the child now stops instead of finishing. Operator, admin-scope and non-owner children do not change. Restart replay of a final reply keeps its current behavior. Co-authored-by: Ayaan Zaidi <[email protected]>
…openclaw#185476) ## What Problem This Solves Fixes: an agent cannot use owner-only tools (such as `openclaw` or `plugins`) to finish a task after a background command it started for the owner completes; the owner has to send another message first. ## User Impact User impact: when a channel owner asks the agent to do something that runs a background command, the completion turn can finish the job with the same owner tools, without asking the owner to reply "go". Commands started by other senders keep the current restrictions. ## Why This Change Was Made Owner-only tools follow the turn's sender. A background-exec completion turn has no sender, so it was never treated as the owner, even when the owner's own turn started the command. Plugin-reload and tool handoffs already continue owner authority, but only for a Gateway-owner `operatorAuthority`; channel owners configured through `commands.ownerAllowFrom` have none, so they lost it. The exec producer now asks the session event target to keep its requester as command owner. The target takes the requester identity from the host-owned tool caller (never from the producer), prepares it once with the existing `prepareCommandOwnerAuthority`, and stores it only if the requester is an owner. The completion context binds the existing command-owner capability, whose check reruns `isCurrent` against the current config each time. A batch refuses to merge completions from different requesters, keyed on the captured sender rather than the shared `configured-owner` label, so one owner's completion can't run under another owner's authority. Main has since added `ownerContinuation` for operator-authority tool handoffs (publish, plugin reload). Both now sit in the same target scope: operator handoffs bind through `ownerContinuation`, exec completions bind through the requester's `commandOwner`, the context binds only one of them, and a batch refuses to mix either. Not covered on purpose: lost-process wakes after a Gateway restart (the capability is in memory only, so they keep today's gate), and plugin/tool handoffs for channel owners (same pattern, separate change). ## Evidence - **Real Gateway, unmocked effect** (new QA Lab flow `exec-completion-owner-authority`, `pnpm openclaw qa suite --scenario exec-completion-owner-authority --provider-mode mock-openai`): a real Gateway child, the QA channel plugin, real `exec`, and the real `automations` tool persisting through the Gateway's `cron.add`. Only the model is the scripted `mock-openai`. Each sender DMs the agent, which starts `sleep 6; echo …` in the background. The completion turn then calls the owner-only `automations` tool to add a disabled job, and the flow checks `cron.list`. Run on `b2d0255`, result `pass`: ``` owner completion persists an automation pass job=o270eccda persisted=true completionToolOutput={"tool":{"id":"openclaw:core:automations",…},"result":{…"id":"8ec9e0cc-…" guest completion is refused pass job=g001c8b48 persisted=false completionToolOutput={"status":"error","tool":"dispatch_action","error":"Unknown tool id: automations. …"} ``` The guest's completion turn doesn't have `automations` in its catalog at all, so the call fails before any Gateway request and nothing is persisted. - Revocation: owner status is rechecked against the Gateway's applied config when the completion is captured, when it's admitted, and at the effect (unit cases `revoked-before-admission` and `revoked-after-admission` below). On a real Gateway, a change to `commands.ownerAllowFrom` takes effect when the Gateway applies it, and that waits for active work the same way it already does for owner message turns. This PR doesn't change that reload policy. - Requester identity for owner-checked effects: the completion now carries the captured requester's `SenderId`/`SenderE164`, but only when the completion goes back to that requester's own channel and account (a raw ID on another channel never becomes a sender). Before this, owner-only tools were enabled but the real Gateway restart handler refused the owner as having "no current owner principal" (ClawSweeper finding on `1eb0b80`). - End-to-end through real completion admission (`session-event-permissions`): an exec completion is captured under the host-owned caller with a Telegram requester, enqueued as `source: "exec"`, admitted by the ordinary reply path, and the synthetic model turn calls `gateway` `restart` through the turn's assembled tool surface. The call reaches the **real** `gateway.restart.request` handler, which rechecks the requester against current config; only the in-process transport and the final restart scheduler are stubbed. - owner (`456` in `commands.ownerAllowFrom`): the handler receives requester `telegram/456`, passes its owner check, and schedules exactly one restart. - guest (`789`): the tool is gated (`{ gated: true }`); no Gateway request. - owner revoked before admission: gated; no Gateway request. - owner revoked after admission: publishing the config change retires the admitted turn's tool host, so the call fails ("agent harness host capability is no longer active") before reaching the Gateway; nothing is scheduled. - Without the requester projection, the owner case fails with exactly the handler's "Gateway maintenance requires a current owner principal". - Exec-notify: `gives the completion turn the current owner authority of its owner requester` fails on `main` and passes here; removing the owner from config revokes the bound capability. - Handoff batching: the same owner's completions batch; a guest's or a different configured owner's do not (owners share the `configured-owner` source label, so batching keys on the captured requester). - Passing locally on `b2d0255`: `session-event-permissions` (28), `session-event-config-readmission`, `session-event-handoff`, `session-event-context` and `bash-tools.exec-notify` (98 total), and the QA flow above. `pnpm check:changed`: format, typecheck, ratchets (including test-lines) and guards pass. Its whole-extension lint lane reports only existing findings in files this PR doesn't touch (workboard, x, memory-core, copilot, knowledge and tlon fixtures); the two new qa-lab files lint clean. Independent autoreview (P1 threshold) on the branch: clean. - Test setup: the three copies of event-turn tool-host setup in `session-event-permissions` / `session-event-config-readmission` are now one `openEventToolHost` test-support helper, which offsets most of the new test lines. The test-lines ratchet passes against current `main` without a baseline change. - Independent autoreview (P1 threshold) found that batching keyed on the shared source label could let a revoked owner's completion run under another owner's authority. That's fixed in `c6a4c083` and covered above, and the re-review was clean. - Inherited CI failure: `checks-node-changed-1` fails `extensions/qa-lab/src/gateway-kill-restart-send.e2e.test.ts > recovers a killed run and replies` (the post-restart reply has `replyToId: undefined`). The lane picked the test up because this PR touches qa-lab. It reproduces identically on `main` at `8f5cb65` without this PR, and no later `main` commit touches that test or the restart-recovery reply path. Related: openclaw#167602. - Gap: no live Telegram/Discord run. The real-Gateway proof uses the QA channel plugin through the same channel plugin boundary. Size against `main`: production +100/−0, tests +231/−105 (including shared event test support), docs +1. Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: jalehman <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…er the owner is removed (openclaw#185796) Related: openclaw#185597, openclaw#185476 ## What Problem This Solves Fixes: a subagent spawned by a channel owner (for example a Telegram owner in `commands.ownerAllowFrom`) keeps running on its native runtime, such as Muse, after that person stops being an owner. ## User Impact An owner's subagent keeps remembered native runtime consent (`nativeRuntimeConsent`) only while the spawner is still an owner. When an operator removes the owner, the child stops before its next native dispatch. Children spawned by non-owners still get refused, and owner-spawned children still dispatch. ## Why This Change Was Made openclaw#185597 made remembered consent cover an owner's own turns. A child run already gets its owner fact from the spawner's live requester check (`prepareCommandOwnerAuthority`), not from the stored `spawnedBySenderIsOwner` receipt. But that check ran only while the Gateway admitted the child. After that, nothing checked it again, so removing the owner did not stop the child. This change adds the same check to the child run's source assertion. A channel owner's own turn already uses this pattern (`captureCommandOwnerAssertion` in the run's `assertSourceCurrent`). The harness host checks that assertion just before native dispatch. If the check fails, it stays failed for the rest of the run. ## Evidence Regression test (in-process): production-boundary test `fences remembered native consent for a child spawned by a channel %s`. It runs the real `sessions_spawn` tool, then the in-process Gateway `agent` admission, then the child's run parameters. The parent turn is a Telegram sender. The agent config has `nativeRuntimeConsent: ["native-fixture"]` and the child session modes are unset. The model-facing `senderIsOwner` receipt is `true` in both rows. - Owner (`telegram:456`): the child gets `senderIsOwner: true` and `assertAgentHarnessExecutionEnvironment` returns consent. When the owner is removed after admission, the captured admitted-run assertion (the one the harness host checks before `runAttempt`) throws. - Guest (`telegram:789`): the child gets `senderIsOwner: false` and consent is refused, even with an owner receipt. - Negative control: without the production change, the owner row fails because nothing stops the child after revocation. Also ran: - The full spawn production-boundary file (106 tests), `agent.test.ts` and `agent.followup-owner.test.ts` (414 tests), and `execution-environment.test.ts`: all pass. - `pnpm tsgo:core`, `pnpm tsgo:core:test`, oxlint and `git diff --check`: clean. ### Live proof: Telegram Test Server + real Muse Isolated Gateway with a leased Telegram Test Server bot and user. The parent agent is a deterministic mock model that issues a real `sessions_spawn`. Children run on the real Muse runtime (`meta/muse-spark-1.3`, Muse Code 1.4.11). Config: `nativeRuntimeConsent: ["muse"]`, `agents.defaults.subagents.model: meta/muse-spark-1.3`, `subagents.maxConcurrent: 1`. The tester is made an owner through `commands.ownerAllowFrom`, then removed by editing the config file while child A runs on Muse. A Gateway detail controls the timing: it defers an owner-removal config reload until active runs end, or until its 300 s timeout. Child A runs a 330 s shell `sleep` on Muse, so the removal takes effect while A is still running. | Step | `main` (`b5c6e98ca9`) | This PR | | --- | --- | --- | | Owner's child A dispatches to Muse | Yes: Muse replies (`muse-spark-1.3`) | Yes: Muse replies (`muse-spark-1.3`) | | Owner removed; reload applies after 300 s timeout | Applied | Applied | | Child A's next native dispatch | **Continues**: `FIRST_CHILD_DONE` is delivered to Telegram | **Stopped**: "Requester owner authority changed; send a new request." | | Queued child B (admitted before removal) | Refused, no Muse turn | Refused, no Muse turn | | Guest's child (tester not an owner) | — | Refused before Muse I/O: "Muse Code cannot enforce this conversation's tool policy." No Muse assistant turn. | So the discriminating case is a child that is already running when the removal applies. A queued child was already refused on `main`. ## Merge danger Two-way door. The change writes no state and does not change config or protocol, so a revert undoes it fully. Blast radius: only child runs whose owner fact comes from a channel requester (`requesterOwner`). If the owner is removed while such a child runs, the child now stops instead of finishing. Operator, admin-scope and non-owner children do not change. Restart replay of a final reply keeps its current behavior. Co-authored-by: Ayaan Zaidi <[email protected]>
…urns A completion turn restored only the requester's sender id. Without the conversation id, requester policy skips the channel's direct-message policy, so a requester allowed by an unchanged toolsBySender entry kept exec after their DM revoked it (channels.telegram.direct[<chat>].tools.deny). Retain the requester's chat type and conversation id with their identity, and restore ChatId with the sender. Restore them only on a turn of the requester's own conversation type: a turn routed to another chat is not a direct turn and would skip the DM policy again, so it stays senderless and gets the unknown-sender policy. Command-owner completions use the same restore, since openclaw#185476 projected the sender with the same gap.
A branch-native equivalent of upstream openclaw#190472 (head ee3411e, "exec completions keep the requester's current sender and DM tool policy", issue openclaw#177510). Upstream's fix builds on openclaw#157806 (fd2a6ca, requester identity on the tool caller) and openclaw#185476 (aa8b35b, completion requester retention); neither is on this branch. Drop this commit when a release that carries upstream's fix is carried. The defect here: a background exec's completion turn is built with no sender (session-event-context.ts), and ordinary turns apply sender policy (conversation-capability-profile.ts, senderPolicyMode "always"), so the toolsBySender "*" entry applies and a sender allowed exec only by their own entry loses it on the completion turn. Reproduced before the fix (see proof); with "*" not denying exec the same test runs exec, so the refusal is that sender policy. What it captures, and where: - At exec construction, from the host-owned run context and never from tool arguments: createOpenClawCodingTools passes resolveExecCompletionRequester(options) (new src/agents/exec-completion-requester.ts) into the exec defaults: the turn's sender id, E164, name, username, chat type, group space and group channel. A senderless turn captures nothing. - runExecProcess keeps it on the process session as a start-time notify fact, cleared at settlement with the others. prepareExecExitNotification passes it, with that exec's own notify route, to captureSessionEventTargetForHost, which keeps a frozen copy with the target. - buildSessionEventContext restores SenderId, SenderE164, SenderName, SenderUsername, GroupSpace and GroupChannel only when the completion's route exactly matches the captured route and the turn has the requester's chat type (set only on the session's own conversation). Anywhere else the turn stays senderless and gets the "*" policy. - It never widens. The completion still runs inside the starting turn's captured tool surface (toolsAllow), which already carries that DM's own policy; the restored sender's current toolsBySender entry and group policy can only narrow it. Event turns never derive owner authority from identity (command-auth.ts), so completion turns stay non-owner. combineSessionEventTargetsForHost refuses to batch targets whose requesters differ. Differences from upstream: - Owner tools: upstream, with openclaw#185476, lets an owner's completion keep owner-only tools while they remain an owner. Here a completion turn is never an owner turn (as before this commit). - DM policy: upstream re-resolves the DM's current policy; here the DM restriction is the one in force at launch (through the captured tool surface), so a DM deny added mid-run is not applied. Upstream notes a live Gateway defers channels.telegram.direct changes until background execs finish. Sender and group policy are current. - Only Gateway/sandbox exec through runExecProcess; node system.run completions are not covered. No QA Lab scenario (upstream's needs main's mock-openai owner-completion fixtures). Line cap: bash-tools.exec-runtime.ts is over its cap, so applyShellPath moves unchanged to bash-tools.exec-path-prepend.ts, next to the other exec PATH helpers. Proof (M4, Node 26.12.1): - New session-event-exec-requester.test.ts (8 rows). Only the model is synthetic: real exec, completion admission, tool host and policy, and the real Discord plugin's guild policy (without its gateway-started binding adapter). Three rows launch a real background exec through createOpenClawCodingTools; the rest capture as exec now does. 8/8 pass: the requester's own DM runs exec and keeps the DM's read deny; a command-owner requester runs exec and stays non-owner; a command started in another chat, a different sender, no captured sender, the requester's entry revoked before completion and a guild deny added before completion all leave exec absent; the Discord guild channel runs exec. session-event-handoff.test.ts adds the batch refusal. - Reproduction before the fix: the requester's DM row fails with exec not offered; with "*" not denying exec it passes. - Red-before (production files reverted, tests kept): 4 fail, the three rows that run exec and the batch refusal; the five denial rows pass. - Mutation: with the owner guard removed the owner row fails (owner true); with GroupSpace/GroupChannel not restored the guild-deny row fails (exec runs). - Every test file importing a touched module (172 files): 2590 passed, 8 skipped, 0 failed. - check-line-cap-ratchet and check-test-mock-exports (base v2026.11.2), run-oxlint on the 16 touched .ts files, tsgo:core, tsgo:test:src, oxfmt --check and format:docs:check: exit 0.
What Problem This Solves
Fixes: an agent cannot use owner-only tools (such as
openclaworplugins) to finish a task after a background command it started for the owner completes; the owner has to send another message first.User Impact
User impact: when a channel owner asks the agent to do something that runs a background command, the completion turn can finish the job with the same owner tools, without asking the owner to reply "go". Commands started by other senders keep the current restrictions.
Why This Change Was Made
Owner-only tools follow the turn's sender. A background-exec completion turn has no sender, so it was never treated as the owner, even when the owner's own turn started the command. Plugin-reload and tool handoffs already continue owner authority, but only for a Gateway-owner
operatorAuthority; channel owners configured throughcommands.ownerAllowFromhave none, so they lost it.The exec producer now asks the session event target to keep its requester as command owner. The target takes the requester identity from the host-owned tool caller (never from the producer), prepares it once with the existing
prepareCommandOwnerAuthority, and stores it only if the requester is an owner. The completion context binds the existing command-owner capability, whose check rerunsisCurrentagainst the current config each time. A batch refuses to merge completions from different requesters, keyed on the captured sender rather than the sharedconfigured-ownerlabel, so one owner's completion can't run under another owner's authority.Main has since added
ownerContinuationfor operator-authority tool handoffs (publish, plugin reload). Both now sit in the same target scope: operator handoffs bind throughownerContinuation, exec completions bind through the requester'scommandOwner, the context binds only one of them, and a batch refuses to mix either.Not covered on purpose: lost-process wakes after a Gateway restart (the capability is in memory only, so they keep today's gate), and plugin/tool handoffs for channel owners (same pattern, separate change).
Evidence
exec-completion-owner-authority,pnpm openclaw qa suite --scenario exec-completion-owner-authority --provider-mode mock-openai): a real Gateway child, the QA channel plugin, realexec, and the realautomationstool persisting through the Gateway'scron.add. Only the model is the scriptedmock-openai. Each sender DMs the agent, which startssleep 6; echo …in the background. The completion turn then calls the owner-onlyautomationstool to add a disabled job, and the flow checkscron.list. Run onb2d0255, resultpass:automationsin its catalog at all, so the call fails before any Gateway request and nothing is persisted.revoked-before-admissionandrevoked-after-admissionbelow). On a real Gateway, a change tocommands.ownerAllowFromtakes effect when the Gateway applies it, and that waits for active work the same way it already does for owner message turns. This PR doesn't change that reload policy.SenderId/SenderE164, but only when the completion goes back to that requester's own channel and account (a raw ID on another channel never becomes a sender). Before this, owner-only tools were enabled but the real Gateway restart handler refused the owner as having "no current owner principal" (ClawSweeper finding on1eb0b80).session-event-permissions): an exec completion is captured under the host-owned caller with a Telegram requester, enqueued assource: "exec", admitted by the ordinary reply path, and the synthetic model turn callsgatewayrestartthrough the turn's assembled tool surface. The call reaches the realgateway.restart.requesthandler, which rechecks the requester against current config; only the in-process transport and the final restart scheduler are stubbed.456incommands.ownerAllowFrom): the handler receives requestertelegram/456, passes its owner check, and schedules exactly one restart.789): the tool is gated ({ gated: true }); no Gateway request.gives the completion turn the current owner authority of its owner requesterfails onmainand passes here; removing the owner from config revokes the bound capability.configured-ownersource label, so batching keys on the captured requester).b2d0255:session-event-permissions(28),session-event-config-readmission,session-event-handoff,session-event-contextandbash-tools.exec-notify(98 total), and the QA flow above.pnpm check:changed: format, typecheck, ratchets (including test-lines) and guards pass. Its whole-extension lint lane reports only existing findings in files this PR doesn't touch (workboard, x, memory-core, copilot, knowledge and tlon fixtures); the two new qa-lab files lint clean. Independent autoreview (P1 threshold) on the branch: clean.session-event-permissions/session-event-config-readmissionare now oneopenEventToolHosttest-support helper, which offsets most of the new test lines. The test-lines ratchet passes against currentmainwithout a baseline change.c6a4c083and covered above, and the re-review was clean.checks-node-changed-1failsextensions/qa-lab/src/gateway-kill-restart-send.e2e.test.ts > recovers a killed run and replies(the post-restart reply hasreplyToId: undefined). The lane picked the test up because this PR touches qa-lab. It reproduces identically onmainatdafda2fwithout this PR, and no latermaincommit touches that test or the restart-recovery reply path. Related: [Bug]: Restart recovery after SIGKILL aborts and tombstones the orphaned session (gateway-kill-restart-send e2e fails on main) #167602.Size against
main: production +100/−0, tests +231/−105 (including shared event test support), docs +1.