Repository navigation
fix(automations): limit webhook-triggered turns to their own automation - #178904
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 changesGive event-triggered cron-runner turns the existing current-automation tool scope. Example: A POST to /hooks/agent asks automations.remove to delete sibling ae776663-ea3c-4add-9748-d1e7ecd31a41.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reviewed change; reproduction). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review This PR makes a focused, useful scope repair. The supplied Gateway evidence resolves the previous proof concern, and no actionable patch defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway webhook ingress creates a transient job and passes it through the cron runner; agent tool assembly selects its automation scope before tool calls reach Gateway authorization and storage. flowchart LR
A[Webhook POST] --> B[Gateway ingress]
B --> C[Transient event job]
C --> D[Cron runner]
D --> E[Agent tool assembly]
E --> F[Current automation scope]
F --> G[Gateway authorization]
G --> H[Cron store]
Technical reviewBest possible solution: Use the existing current-job scope for both cron and event jobs while preserving ordinary conversation tools and Gateway authorization. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the mismatch, and the supplied real-Gateway negative control reproduces it by reverting only agent-tools.ts; no target code was executed during this review. Is this the best way to solve the issue? The production change repairs the existing scope selector without adding another authorization owner, and the QA dispatcher preserves the previous scenario order. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5199713a8ebf. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +44, Tests +148, Other +144. Total +336 across 6 files. Added test files: 1. View PR surface stats
LabelsLabel 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 (1 earlier review cycle)
Reviewed October 20, 2026, 10:42 PM ET / October 21, 2026, 02:42 UTC (Revision 2). |
Real behavior proof: Crabbox (direct AWS)
CI attribution. Closed-run authority. A hook turn's job is built in memory ( Redacted Crabbox output (IPs, SSH and local paths removed) |
|
CI attribution for the new head
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
048267b to
ca10df7
Compare
CI attribution after refresh onto
|
| Lane | File | CI at ca10df7c2c4 |
Base 8021f987ed4 (local) |
Cause |
|---|---|---|---|---|
checks-node-changed-18 |
test/gateway-account-history.e2e.test.ts |
2 failed | same 2 failed | fixture config still sets agents.defaults.heartbeat, which #179387 retired; Gateway exits 78 (Unrecognized key: "heartbeat") |
checks-node-changed-23 |
test/gateway-completion-replay.e2e.test.ts |
1 failed / 3 | same 1 failed | same retired heartbeat fixture key |
checks-node-changed-4 |
test/e2e/qa-lab/runtime/channel-progress-presentation.e2e.test.ts |
5 failed / 16 (Discord cases) | same Discord cases time out (accepted final answer, ambiguous announcement settlement) |
not touched by this PR; the same file passed 16/16 at the pre-rebase head on the older base |
#179530 fixed the retired heartbeat key in two other fixtures but not these two. openclaw/ci-gate fails only because of these three lanes.
ca10df7 to
5570f12
Compare
…urns Webhook hook turns and channel join introductions run through the cron runner with trigger "event". Give them the same current-job automations scope that scheduled runs already get, so the tool cannot act on other automations from those turns.
5570f12 to
da10c8e
Compare
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…on (openclaw#178904) * fix(agents): scope automations tool for event-triggered cron-runner turns Webhook hook turns and channel join introductions run through the cron runner with trigger "event". Give them the same current-job automations scope that scheduled runs already get, so the tool cannot act on other automations from those turns. * test(qa): cover hook turn automations scope * test(qa): add allowed list control to hook automations scope proof * test(cron): assert self-scoped automations schema without pinning main's action list * test(cron): pass scheduled occurrence to event-trigger scope runs
What Problem This Solves
Fixes: webhook (
/hooks/agent) turns get the full automations tool instead of the current-job scope scheduled runs get, although both run through the same automation runner.User Impact
User impact: an agent turn started by an inbound webhook or a channel join introduction now gets the same automations tool scope as a scheduled run. Within that turn it can only inspect or remove its own run, not list or change other automations. Scheduled runs and ordinary conversation turns are unchanged.
Why This Change Was Made
This is consistency and defense-in-depth hardening. The Gateway already limits agent-runtime callers to automations their own session can see. Before this change, a hook turn's request for another automation passed the tool and was rejected only by the Gateway. The current-job scope was derived only from the
crontrigger, so turns with triggereventthat the cron runner starts were left out. They now share it. The condition still requires a job id, so othereventturns that don't come from the cron runner stay as they were.Channel join introductions already run with an empty tool allowlist. This change keeps that behavior and adds a test for it.
Evidence
cbx_a903c769bf38, clean--fresh-prcheckout at048267bca94): see the proof comment below, which includes the redacted run output.hook-turn-automations-scoperuns a real Gateway child and sends an HTTPPOST /hooks/agentto it, with mock-openai inference. It passes on the PR head:removeof a sibling automation is rejected by the tool scope (Automations tool is restricted to the current automation.) before any Gateway call.listwithincludeDisabled: true, succeeds and doesn't expose the sibling.cron.listafterward.src/agents/agent-tools.tsreverted tomainfails. The siblingremovegets past the tool and reaches the Gateway, which rejects it ascron job not found.cron.removekeeps its existing live-run check (bindCronSelfRemovalCommitGuard), which this PR doesn't change.removeis rejected, and the turn gets the self-scoped schema (noadd). The test doesn't pin the exact self action list, whichcron-tool-schema.tsowns and which grew onmain(scratch_get,scratch_set,record_result). Join introductions still get no automations tool. 3/3 and 13/13 pass on Crabbox. I removed the mocked option-forwarding construction asserts, since ClawSweeper flagged them as low-value.checks-node-changed-10(gateway-mcp-app-grant-revalidation.e2e.test.ts) andchecks-node-changed-18(gateway-rpc-chat.e2e.test.ts) fail the same way on the merge base50dfbacf1ab, which doesn't include this PR. Neither failure comes from this PR.cron-send-then-continueandcron-blocked-outcomepass.cron-failure-repair-owner-conversationfails the same way on unmodifiedmain.cron-explicit-authority-executionneeds the live-frontier lane and wasn't run.main8021f987ed4(headca10df7c2c4, includes fix: MCP Apps cannot be pinned by their signed-in owner #178043): rebased cleanly. Locally the unit suite passes 3/3, and reverting onlysrc/agents/agent-tools.tsmakes the hook-turn case fail.gateway-mcp-app-grant-revalidation.e2e.test.tsandgateway-rpc-chat.e2e.test.tsnow pass 10/10, and thehook-turn-automations-scopeQA scenario passes.