Skip to content

fix(audit): report denied exec approvals only once - #130560

Merged
joshavant merged 1 commit into
mainfrom
fix/int-owner-native-tool-receipts
Aug 27, 2026
Merged

joshavant merged 1 commit into
mainfrom
fix/int-owner-native-tool-receipts

Conversation

@joshavant

Copy link
Copy Markdown
Collaborator

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-action attribution; 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-receipt
  • actual Gateway agent run, actual exec approval registration, actual denial
  • failed with both model-routing/model_route_selected and duplicate tool/generic_action_attributed rows

Post-fix real-flow proof:

  • same QA scenario passes through denial, conflicting-retry rejection, CLI audit inspection, redaction checks, generic tool-duplicate check, Gateway replacement, and byte-equivalent durable readback
  • channel message flow scenario passed on qa-channel with mock-openai
  • Control UI Playwright: activity-run-inspector.e2e.test.ts, 10/10 passed
  • Codex native approval E2E: 1/1 passed across Gateway restart
  • focused cross-owner matrix: 31 files, 655 passed, 4 skipped
  • focused owner matrix: 3 files, 40 passed
  • focused oxlint and oxfmt checks passed
  • ordinary Codex autoreview: no actionable finding
  • TruffleHog 565fd935...3cd8705f: 0 verified, 0 unknown

Blacksmith Testbox pearl-barnacle-e78d built successfully, then stopped at QA CLI preflight because the submitted --output-dir was 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/33027065807

The 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:

  • Observable invariant: one decision owner per approved tool action.
  • Prior coverage only exercised owners decided by the pre-execution hook.
  • The new focused regression covers an owner-native record created during implementation, and the QA scenario covers the real Gateway/approval path.
  • The async scope is used by production generic and exec approval owners; no test-only production seam was added.

Best-fix verdict: best owner-boundary fix.

Alternatives considered:

  • Excluding every exec action from generic attribution would lose valid no-approval facts.
  • Filtering or deleting the generic row during audit reads would retain duplicate persisted state and move repair to a consumer.
  • Inferring approval from tool names or arguments would violate the owner boundary.

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 generic allowed record 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-1681
  • codex-rs/app-server-protocol/src/protocol/v2/item.rs:58-103,1451-1525
  • codex-rs/protocol/src/protocol.rs:3868-3905

Codex distinguishes Decline (deny command, continue agent) from Cancel/Abort (interrupt). OpenClaw preserves that contract in extensions/codex/src/app-server/approval-bridge.ts:828-843, with regression coverage at extensions/codex/src/app-server/approval-bridge.test.ts:1415-1439.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 27, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 9:58 PM ET / August 27, 2026, 01:58 UTC.

ClawSweeper review

What this changes

The 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 provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep 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
Reviewed head: 3cd8705f5d814605a6050bb35f21259e3cbcce07
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused producer-boundary repair with direct source support and meaningful QA coverage, pending normal exact-head validation.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is exempt from the contributor proof gate; its body nevertheless describes an after-fix isolated Gateway and durable-audit run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is exempt from the contributor proof gate; its body nevertheless describes an after-fix isolated Gateway and durable-audit run.
Evidence reviewed 6 items Current main still has the duplicate-producing ordering: Current main records the generic allowed receipt before invoking a tool whenever no early hook owner decided the action, so a later exec approval record cannot suppress it.
The branch moves the decision to the producer boundary: The wrapper creates the scoped generic decision only for calls without an early owner decision, and the scope emits the generic fact only if execution did not mark an owner-native record.
Exec marks only after durable approval registration: The client marks the scoped call after the gateway request returns; the gateway registers the pending approval synchronously, and its manager persists the operator approval before completing registration.
Findings None None.
Security None None.

Live Verification

Command: pnpm qa suite --provider-mode mock-openai --scenario agent-run-decision-receipt

Result: FAIL (failed) — execution before step 1 run: terminal command failed with exit status 1: "pnpm qa suite --provider-mode mock-openai --scenario agent-run-decision-receipt"

terminal command failed with exit status 1: "pnpm qa suite --provider-mode mock-openai --scenario agent-run-decision-receipt"

Captured output:
undefined
[ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL] Command "qa" not found

















































Assertions:

  • FAIL expect_output: denied approval projected before/after Gateway replacement

How this fits together

Agent 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]
Loading

Decision needed

Question Recommendation
Does a maintainer accept the new deferred audit-recording scope after exact-head validation completes? Validate and merge the owner-boundary repair: Let exact-head checks confirm the scoped deferral while retaining generic attribution for tools that do not register an approval.

Why: This is a protected, maintainer-authored change to durable audit attribution and needs an explicit maintainer merge judgment.

Before merge

  • Resolve merge risk (P1) - Production grows by 26 net lines for an AsyncLocalStorage ownership seam; exact-head validation should confirm the deferred audit ordering across the broader tool suite before merge.
Agent review details

Security

None.

PR surface

Source +26, Tests +24. Total +50 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 37 11 +26
Tests 2 30 6 +24
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 67 17 +50

Review metrics

Metric Value Why it matters
Production versus test delta production +37/-11 (net +26); tests +30/-6 (net +24) The production increase is the private async ownership scope needed to carry a post-await approval-registration fact back to the generic audit producer.

Stored data model

Persistent data-model change detected: serialized state: test/e2e/qa-lab/runtime/agent-run-decision-receipt.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify the scoped audit ordering on the exact head (recommended)
    Run the existing Gateway decision-receipt scenario and affected agent tests on the exact merge head before accepting the new async ownership seam.

Technical review

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

Labels

Label justifications:

  • P2: This is a bounded correctness repair for audit attribution, without evidence of an immediate availability or security incident.
  • merge-risk: 🚨 other: Merging changes the timing and ownership of durable audit decision facts, a semantic surface not fully settled by static review.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is exempt from the contributor proof gate; its body nevertheless describes an after-fix isolated Gateway and durable-audit run.

Evidence

What I checked:

Likely related people:

  • joshavant: The supplied merged predecessor metadata and the current branch commit both identify this contributor on the generic tool-decision receipt implementation. (role: feature and follow-up author; confidence: high; commits: 29625bc310f5, 3cd8705f5d81; files: src/agents/agent-tools.before-tool-call.wrapper.ts, src/agents/agent-tools.before-tool-call.decision.ts, src/agents/bash-tools.exec-approval-request.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Run the decision-receipt QA scenario and affected agent tests on the exact merge head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-27T01:19:04.532Z sha 3cd8705 :: needs maintainer review before merge. :: none

@joshavant
joshavant marked this pull request as ready for review August 27, 2026 01:51
@joshavant
joshavant merged commit ba6034c into main Aug 27, 2026
433 of 435 checks passed
@joshavant
joshavant deleted the fix/int-owner-native-tool-receipts branch August 27, 2026 02:12
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant