Repository navigation
fix(audit): report denied exec approvals only once - #130560
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 9:58 PM ET / August 27, 2026, 01:58 UTC. ClawSweeper reviewWhat this changesThe PR defers generic tool-action audit attribution until execution completes, suppressing it when an exec approval registration has created an owner-native receipt path. Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readinessKeep open for maintainer handling. The branch repairs a current-main audit duplication at the producer boundary, and direct review found no actionable patch defect; its protected maintainer status prevents automated closure. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherAgent tools pass through a before-tool-call wrapper before their implementations run. Both that wrapper and the exec approval subsystem can emit audit decision facts, which Gateway and CLI audit inspection later display. flowchart LR
A[Agent tool call] --> B[Before-tool wrapper]
B --> C{Early owner decision?}
C -->|Yes| D[Tool implementation]
C -->|No| E[Scoped generic attribution]
D --> F[Exec approval registration]
F --> G[Audit decision facts]
E --> G
G --> H[CLI and Gateway audit inspection]
Decision needed
Why: This is a protected, maintainer-authored change to durable audit attribution and needs an explicit maintainer merge judgment. Before merge
Agent review detailsSecurityNone. PR surfaceSource +26, Tests +24. Total +50 across 5 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the producer-side deferred attribution: mark only after successful exec approval registration, preserve generic receipts for ordinary tools, and avoid filtering duplicate records during audit reads. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main writes a generic receipt before invoking exec, while the approval owner records only during that invocation; the changed QA scenario exercises this exact denied-approval path. Is this the best way to solve the issue? Yes for this branch: it repairs the producer that creates the duplicate, preserves generic attribution when no owner-native approval exists, and avoids a consumer-side read filter. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3cb0dd4851e8. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
What Problem This Solves
Fixes an issue where an exec command requiring operator approval produced both the authoritative operator-approval receipt and a generic tool-action receipt for the same action. Audit inspection could therefore report duplicate decision attribution after the command was denied.
Why This Change Was Made
Generic tool attribution now waits until tool execution establishes whether an owner-native decision record was registered. Successful exec approval registration marks that closure-bound execution scope, so the generic producer remains active for ordinary tools and exec calls without approval but yields to the authoritative approval owner when one exists.
The QA assertion now targets only generic
tool-actionattribution; valid generic facts from other owners, including model routing, remain allowed.User Impact
Operators inspecting a denied exec approval see one authoritative decision source. Ordinary generic tool and model-routing audit facts are preserved.
Evidence
Pinned base:
565fd935449e6b75b211ca13ff43747d66b3fac2.Pre-fix real-flow regression:
qa suite --provider-mode mock-openai --scenario agent-run-decision-receiptmodel-routing/model_route_selectedand duplicatetool/generic_action_attributedrowsPost-fix real-flow proof:
qa-channelwithmock-openaiactivity-run-inspector.e2e.test.ts, 10/10 passed565fd935...3cd8705f: 0 verified, 0 unknownBlacksmith Testbox
pearl-barnacle-e78dbuilt successfully, then stopped at QA CLI preflight because the submitted--output-dirwas absolute. This was an invocation error, not infrastructure, so the packet's one-retry rule did not permit a replacement box. Run: https://github.com/openclaw/openclaw/actions/runs/33027065807The supplementary actual subagent lineage scenario timed out waiting for its worker child session. No common cause with this receipt defect was proven; it was not retried or attributed to this change.
Root Cause and Ownership
C02 recorded generic attribution at
agent-tool.before-execute, before the exec implementation could register its owner-native approval row. The generic producer therefore had no observation of the later owner boundary.The fix stays in the generic decision owner: a per-execution async scope defers the generic decision until execution returns or throws, while exec marks the scope only after approval registration succeeds. It does not filter persisted data, special-case command text, or disable generic attribution for all exec calls.
Production LOC: +37/-11 (net +26) | Tests: +30/-6 (net +24). The production growth is the closure-bound ownership seam needed to carry a downstream owner fact across awaited execution; the already-limit-bound wrapper shrinks by two lines.
Test audit:
Best-fix verdict: best owner-boundary fix.
Alternatives considered:
Provenance
Clear regression from C02 PR #130358, merge commit
29625bc310f58dc6d6a7d66bf84b9e06e89709b3, August 26, 2026. Blamed code author, PR author, merger, and current PR author: Josh Avant (@joshavant). The triggering line was the unconditional pre-execution genericallowedrecord when the before-tool hook did not own the decision.Codex Contract Check
Direct sibling inspection used Codex SHA
f1087ff151b06e781ecb086068d45fcc62d02da3:codex-rs/app-server-protocol/src/protocol/common.rs:1649-1681codex-rs/app-server-protocol/src/protocol/v2/item.rs:58-103,1451-1525codex-rs/protocol/src/protocol.rs:3868-3905Codex distinguishes
Decline(deny command, continue agent) fromCancel/Abort(interrupt). OpenClaw preserves that contract inextensions/codex/src/app-server/approval-bridge.ts:828-843, with regression coverage atextensions/codex/src/app-server/approval-bridge.test.ts:1415-1439.