Repository navigation
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟡 Changes recommended
Batching can conflate distinct requesters and bypass one requester's revocation, while the current tests do not exercise completion-side shell dispatch through the real execution gate.
2 open issues
What changed in this PR
This PR addresses #177510 by retaining the originating requester's identity for background completions, allowing current toolsBySender policy to apply even when the requester is not a command owner.
Changes:
- Capture host-trusted requester identity independently of command-owner status.
- Project that identity onto completion turns only within the same channel and account, without granting command-owner authority.
- Add authorized, guest, and revoked-requester regression cases and register their database-worker test route.
| File | Description |
|---|---|
test/vitest/vitest.database-worker-core-paths.mjs |
Registers the new regression test on the database-worker route. |
src/auto-reply/reply/session-event-target.ts |
Retains and exposes the originating requester's identity. |
src/auto-reply/reply/session-event-context.ts |
Projects retained identity for current sender-policy evaluation. |
src/auto-reply/reply/session-event-completion-reauthorize.test.ts |
Adds completion policy and tool-surface regression cases. |
Review effort: Balanced
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f35518aa9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: blocked before merge. What this changesPreserve the initiating sender and conversation context so background command completions receive the requester's current tool policy. Example: Telegram sender 100001 has an unrestricted toolsBySender entry while the wildcard denies exec.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains This PR fixes a concrete sender-policy failure that remains on current main; no introduced blocking defect was found. Reviewed head: Before merge
FindingsNone. Agent review detailsHow this fits togetherThe session-event owner captures host-trusted requester facts at command launch and supplies them to ordinary reply admission when the command finishes. flowchart TD
A[Sender request] --> B[Background exec]
B --> C[Captured session target]
C --> D[Completion context]
D --> E[Current tool policy admission]
E --> F[Completion tools and reply]
Technical reviewBest possible solution: Land the focused requester-context repair through the existing session-event owner once required current-head CI succeeds. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the senderless wildcard-policy path, and the contributor supplies a failing-main/passing-fix Gateway comparison; no target code was executed during this read-only review. Is this the best way to solve the issue? The change repairs lost context at the existing capture and completion owners, preserves ordinary policy admission, and addresses the earlier conversation, username, guild and batching findings. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8b5220ef0b5c. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +102, Tests +302, Docs 0, Other +135. Total +539 across 11 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: 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 (8 earlier review cycles)
Reviewed November 27, 2026, 1:32 PM ET / 18:32 UTC (Revision 9). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
f5356b0 to
f2eb9ab
Compare
The original completion-requester-policy.txt allocation (301) exactly covers this PR's net test-line growth against the rebased base. The extra 25-line allocation was computed against the pre-rebase ceiling and would exceed the allowed credit.
|
@clawsweeper re-review Rebased onto main Ratchet. CI is green at |
|
🦞👀 Re-review progress:
|
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.
|
Could a maintainer remove |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
# Conflicts: # extensions/qa-lab/src/providers/mock-openai/mock-openai-owner-completion.ts # src/auto-reply/reply/session-event-context.ts # src/auto-reply/reply/session-event-target.ts
…the next start Main's openclaw#202513 and openclaw#204105 decide operator and owner authority once, when a run starts, and drop the mid-run re-checks; a started run may finish. The two "revoked after admission" rows asserted the old behaviour (the admitted turn's tool host retired before the call). On this merge the completion keeps the exec it was admitted with and runs it, as main intends. Every "before admission" row, the guild rows and the guest row are unchanged and still pass.
|
@clawsweeper re-review Merged main |
|
🦞👀 Re-review progress:
|
# Conflicts: # docs/gateway/background-process.md # src/auto-reply/reply/session-event-context.ts # src/auto-reply/reply/session-event-target.ts
|
@clawsweeper re-review Merged main Main's #204785 now hands 17 test files, 181 tests pass: the PR's two, plus every test that imports |
|
🦞👀 Re-review progress:
|


Closes #177510
What Problem This Solves
Fixes: a background command's completion turn loses
execandprocesswhen the sender who started it is allowed only by their owntoolsBySenderentry and the"*"entry denies those tools.User Impact
User impact: with a
toolsBySenderwildcard deny, a sender allowed by their own entry can let a background command finish its task on the completion turn, without sending another message. Guests stay denied, and changing that sender's entry, or denying the tool for the conversation they wrote in (a Telegram DM entry underchannels.telegram.direct.<chat>, includingtoolsBySenderkeyed on their id, username or name, or a Discord guild or channel entry underchannels.discord.guilds.<guild>), before the completion runs takes the tool away.Why This Change Was Made
A completion turn is built without a sender, so requester policy fell to the
"*"entry. #185476 restored the sender only for command owners (commands.ownerAllowFrom); a sender allowed only throughtoolsBySenderwas never restored.My first revisions restored too little. Review found four real gaps, all fixed:
resolveRequesterConversationToolPolicyskips the channel'ssecurity.resolveDirectToolPolicy, so an unchanged sender entry escaped a DM-level deny. fix: background command completions lose the owner's owner-only tools #185476's owner completions had the same gap.resolveTelegramDirectToolPolicymissed a DMtoolsBySenderentry keyedusername:orname:, fell back to the DM's unrestricted tools, and the requester's global id entry then allowed exec.resolveDiscordGuildKeyfound no guild entry, a guild or channel deny added after launch was missed, and the requester's global id entry allowed exec.combineSessionEventTargetsForHostcompared only command-owner requesters, so targets from twotoolsBySender-only requesters could share a batch that restores only the first one.What the PR does now:
SenderId,SenderE164,SenderUsername,SenderName,GroupSpace,GroupChannelandChatId, but only on the requester's own channel account and only when the turn has the requester's conversation type. A completion routed to another chat stays senderless and gets the"*"policy.senderIsOwnerstaysfalse, and owner-only effects still recheck at use.system.runevents retain a requester. Subagent announces, cron, heartbeats, session-state notices and adopted durable processes do not, so their authority is unchanged.Evidence
Merged with main (head
283e19cf875, maineee7a1bd526, macOS arm64, Node 26.12.1,OPENCLAW_VITEST_RUNTIME=node). The branch was 3,114 commits behind.9038986bf5eresolves three conflicts:session-event-context.ts: main's command-owner restore (nowconst { authority, requester } = commandOwner, withchannelPrincipal), then this PR's retained-requester restore ofSenderId,SenderE164,SenderName,SenderUsername,GroupSpace,GroupChannelandChatIdunder the same channel, account and chat-type match. Main's ownSenderId/SenderE164restore is dropped; the retained requester covers it.session-event-target.ts: main'sownerContinuationflag, which main now also sets for an operator source, then this PR'sretainedRequestercapture.mock-openai-owner-completion.ts: main'sansweredAfterhelper with this PR'slatest(...)lookups.Main's #204105 (
cb1d8cdea3e) dropped the mid-run operator re-checks in session events: a completion turn's authority is decided when it starts, and a revocation applies to the next start.283e19cf875aligns the two "revoked after admission" rows ofsession-event-completion-reauthorize.test.tswith that. The admitted completion now keeps theexecit was given and runs it; before, its tool host was retired before the call (agent harness host capability is no longer active). The guest row, the guild rows and every "before admission" row are unchanged. A revocation between launch and the completion's start still takes the tool away, which the QA flow checks.Main also reworded the refusal: a denied tool now reads
exec is outside the tools this run allows. Do not retry exec.where this description quotesexec is not available in this turnandUnknown tool id: exec.exec-completion-requester-sender-policy(host runner, mock-openai, qa-channel): passes 1/1. The allowed sender's completion runsexec(ran: true, same Gateway pid). The guest getsexec is outside the tools this run allows. Do not retry exec.at launch. Revoking the third sender's entry after launch leaves its completion with the same refusal and no marker. With main'ssession-event-context.tsandsession-event-target.tsit fails:allowed requester's completion did not run exec: {"job":"allowed-8d47450a","launched":true,"ran":false,...}.exec-completion-owner-authorityfails at "guest completion is refused" on this merge and on bare maineee7a1bd526alike. The guest's completion is refused and nothing is persisted, but the refusal now readsautomations is outside the tools this run allows. Do not retry automations., which the scenario's accepted list (needs the owner's authority,Unknown tool id: automations) predates. The owner step passes on both. The failure comes from main: the scenario predates main's own refusal wording.session-event*test files: 171 passed, 0 failed (session-event-completion-reauthorize13,session-event-handoff22). With main'ssession-event-context.tsandsession-event-target.tsand the rest of this head kept,session-event-completion-reauthorize.test.tsfails 5 of 13. Main offers noexecto the allowed owner's completion in a Telegram DM, in a Discord guild channel or in either after-admission row (outcome: "absent"), and in "command owner, DM revoked before admission" it offers and runsexec.session-event-handoff.test.tsfails 1 of 22 there: "batches retained owner authority only for the same requester" batches the guest's event with the 4 events the test keeps apart (otherGuest,otherGuild,ownerElsewhere,renamed).--base eee7a1bd526where a check takes one:tsgo:core,tsgo:extensionsandcheck:test-types0 errors; oxlint andoxfmt --checkclean on the changed files; the line-cap, assertion-safety and mock-export ratchets, the conflict-marker check and the PR wrapper inventory test (eager-import-closure.test.ts) pass.check-test-lines-ratchet: net +301, allocation 301.Everything below is from the pre-merge heads.
Head
6fbcf9eae1e(main586f576merged in), macOS arm64. Correction: the QA Lab flow and the test files in this section ran on the local default runtime, which since #172625 is OpenClaw's pinned Bun, not Node 26.12.1 as this line said. Node re-run under "Also on this head".Real Gateway (QA Lab flow
exec-completion-requester-sender-policy: Gateway child, qa-channel, realexecandconfig.patch; only the model is scripted).node scripts/run-node.mjs qa suite --provider-mode mock-openai --scenario exec-completion-requester-sender-policy --concurrency 1 --fast, run at58bf6c5:execand writes its marker. The guest getsexec is not available in this turn. Do not retry exec.at launch. Revoking the third sender's entry after launch (same Gateway pid) leaves its completion withUnknown tool id: execand no marker.session-event-target.tsandsession-event-context.ts: fail,allowed requester's completion did not run exec: {"launched":true,"ran":false,..."completionOutput":"exec is not available in this turn. Do not retry exec."}.exec-completion-owner-authoritystill passes in the same run.Completion-side exec through the real Telegram and Discord plugins (
session-event-completion-reauthorize.test.ts): the managed tool host has shell tools; DM policy resolves throughtelegramPlugin.security(resolveTelegramDirectToolPolicy) and guild policy throughdiscordPlugin.groups.resolveToolPolicy(resolveDiscordGroupToolPolicy). The completion runsprintf ran > <marker>throughexec. 13/13 pass..toolsrevoked; DMtoolsBySender["username:alice"]revoked; DMtoolsBySender["name:Alice"]revoked; command owner with DM revoked; DM revoked with the completion routed to another chat; sender or DM revoked after admission (the tool host is retired before the call:agent harness host capability is no longer active).200001, channelops): allowed;guilds["200001"].tools.denyadded after launch;guilds["200001"].channels.ops.tools.denyadded after launch.c4925913532: both Discord revocation rows fail, with exec offered and run. WithGroupSpacerestored but notGroupChannel, the channel row still fails.176614364929: the username and name rows fail. Source of my first revision: the three DM rows that existed then failed. Main's source: the allowed row fails (exec not offered), which is [Bug]: exec-completion wake loses exec under toolsBySender wildcard deny #177510.Batching (
session-event-handoff.test.ts):otherGuest,ownerElsewhere, a same-id requester with another username (renamed) and the same requester in another guild (otherGuild) combined before; now they are refused. The file passes 24/24.Also on this head:
OPENCLAW_VITEST_RUNTIME=node), merged onto main3855c896edd:session-event-completion-reauthorize.test.ts13 passed,session-event-handoff.test.ts24 passed.pnpm tsgo:allexit 0 (33 stages, 0error TS); oxlint and oxfmt clean.586f576: line-cap, max-lines, assertion-safety, mock-exports, test-lines, timeout-race.pnpm test <file> --maxWorkers=1, Bun, the local default, macOS arm64, two runs each):session-event-completion-reauthorize.test.ts64.7 s (cold worker cache, 21.9 s of it compiling) and 31.1 s wall, 23.1 s and 21.9 s of tests;session-event-handoff.test.ts15.1 s and 15.3 s wall, 9.0 s and 9.1 s of tests. CI run 42429583841, Bun:session-event-completion-reauthorize.test.ts54.1 s Vitest duration, 31.2 s of tests (checks-node-changed-compact-large-14);session-event-handoff.test.ts17.0 s Vitest duration, 9.5 s of tests (checks-node-changed-compact-large-12).session-event-completion-reauthorize.test.tsis new in this PR and runs 21.9 s of tests locally and 31.2 s in CI: 13 rows at about 1.5 s each locally (2.0 s in CI), the first carrying one-time setup (3.3 s locally, 6.5 s in CI). It pins that a background exec completion "runs completion-side exec only under the requester's current sender and conversation policy". Exec runs for the owner and in the Discord guild channel. It is not offered to a guest, or after a revocation by sender id, DM, DM username, DM display name, guild or guild channel. A revocation after admission fails the call with "agent harness host capability is no longer active". Only model inference is mocked; admission, tool policy and exec are real. No cheaper layer proves it: the rows vary the sender id, username, display name, chat, guild and channel captured at handoff, and each has to reach the decision; the real Telegram and Discord plugins own the conversation policy; and the after-admission rows depend on config publication retiring the live tool host.config/test-lines-allocations/completion-requester-policy.txt.176614364929(run 41584998941):checks-fast-baseline-ratchetsreportedTest lines: 6421452; ceiling: 6420618; over by: 834; net delta: +236.The 834 was main's own overage at the time (main went over at2a32ab046f2, fix(qa): accept direct settled Codex handoff wakes #191638; fix(ci): unblock allocated tests after inherited budget debt #191696 later raised the baseline by 834, and main was 10 over atf5f27c3ef6e). This PR's growth is allocated exactly.Live Telegram DM (2026-11-10, a throwaway bot, macOS arm64, Node 26.12.1): one isolated Gateway built from main
9a5df3d60f1with this PR's head and four of my other PR heads merged in (no file touched by two of them), on the real Telegram Bot API, with QA Lab's scripted mock provider (headee3411e1a70).tools.toolsBySendergives my id{}and"*"denies exec, process, nodes and gateway; each leg starts a 30 s background exec whose completion turn runsexeconce more to write a marker.{}): the launch and completion markers were both written.tools.toolsBySender["id:<my id>"].deny: [exec, process], applied withopenclaw config patch1.96 s after the launch marker): no completion marker, and the completion turn'sexecgotUnknown tool id: exec.Not shown end to end:
exec, but no Bot API traffic.channels.telegram.directchange made while a background exec runs is deferred until that exec completes (the Gateway logsdeferring until 1 background exec session(s) complete), so a DM deny added mid-run does not reach that run's completion turn. This is existing reload behavior (src/gateway/server-reload-active-work.ts), which this PR does not change; the DM rows are proven by the unit test. I did not measure whether achannels.discord.guildschange is deferred the same way.