Skip to content

feat(audit): record generic tool action decisions - #130358

Merged
joshavant merged 6 commits into
mainfrom
codex/c02-generic-tool-data-actions
Aug 27, 2026
Merged

joshavant merged 6 commits into
mainfrom
codex/c02-generic-tool-data-actions

Conversation

@joshavant

@joshavant joshavant commented Aug 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • record private generic tool/data decision facts at the canonical before-tool-call execution boundary
  • classify filesystem/process tools from their assembly owners and memory tools from process-stable manifest kind metadata; generic plugin tools remain tool/openclaw
  • preserve owner-native plugin-hook and approval receipts without duplicate generic decisions
  • keep arguments, results, paths, tool names, plugin IDs, owner prose, and target references out of generic receipts

Architecture

The closed private action descriptor carries only family and broad operation through the existing identity-backed tool metadata path. The wrapper records through the existing recordExecutionDecisionWork sink, which shares the canonical AuditEventWriter FIFO in Gateway and direct-local modes. Receipt authority is revalidated immediately before each enqueue after asynchronous policy, approval, and preparation work.

Ordinary execution is attribution-only. Only an exact trusted generic policy veto is enforced. Execution errors remain lifecycle-owned, pre-launch disposal records suppression, missing/stale authority emits no fact, and plugin-hook/approval owners remain authoritative.

Browser plugins remain generic tool/openclaw: the current generic manifest/registry contract has no canonical browser capability kind. This PR does not invent a public SDK or manifest surface.

Proof

  • fail-before: the new behavior test reached assertions against the pinned base and failed because zero generic decision work was emitted
  • focused C02: 17/17, including a registered void before_tool_call hook that emits exactly one owner-native allow receipt and zero generic decision work, plus a matcher-miss case that emits zero owner receipts and one generic attribution
  • hosted exact review artifact 9621963163: accepted P1 reproduced on the production createOpenClawTools({ wrapBeforeToolCallHook: false }) Gateway-shaped path (zero decision work before the fix). Binding descriptors once at the final OpenClaw assembly boundary makes the same path emit one bounded tool/openclaw attribution receipt; OpenClaw registration 60/60, Gateway resolution 32/32, and skill-runtime dispatch 5/5 remain green.
  • Ready-triggered CI exposed an observable-shape regression in the existing embedded-mode full-object assertion: enumerable genericDecision widened HookOutcome. The unchanged test is the fail-before (1/23 failed); both generic veto producers now use the canonical non-enumerable private-marker owner shared with ownerDecision, and embedded-mode plus decision tests pass 38/38.
  • plugin hook ownership: 29/29
  • wrapper metadata rebuild: 130/130
  • channel/wrapper siblings: 180/180
  • before-tool-call E2E: 99/99
  • plugin optional paths: 86/86
  • Codex dynamic-tool siblings: 5 files / 301 tests
  • local node scripts/check-changed.mjs --staged: green
  • proportional private-marker node scripts/check-changed.mjs: green
  • automatic exact-head ClawSweeper at b83f4b9 found a valid P1: a void hook already emitted plugin_hook_allowed, but the undefined aggregate result omitted the private owner marker and allowed a duplicate generic attribution. Fail-before was 1/16 at the exact zero-generic-work assertion; the repair preserved non-enumerability and owner-native routing for handlers returning void. Pass-after: decision 16/16, embedded-mode 23/23, plugin-hook owner 29/29.
  • automatic exact-head ClawSweeper at 9beee70e found a valid matcher-scope P1: global hook registration suppressed generic attribution even when an exec-only hook did not match a data/read tool and emitted no owner receipt. Fail-before was 1/17 at the exact one-generic-work assertion. The hook owner now invokes receipt.markOwnerDecision only from onHandlerResult/onHandlerError; the policy closure suppresses generic attribution only when marked or when final approval exists, without duplicating matcher logic. Pass-after: decision + embedded-mode + plugin-hook owner 69/69; proportional check-changed green.
  • Testbox: tbx_01m0zn9jctv1tvrtgsw52rkncp, Actions run 32999895022; check:changed, all builds, C02 14/14, approval/plugin ownership, Gateway/CLI siblings, and browser privacy 10/10 passed. The broad sweep then exited nonzero from unrelated worker OOM/exits, timing-sensitive UI/doctor failures, stale Codex fixtures, and a missing dist/control-ui artifact; none intersects the 11 changed C02 paths.
  • final autoreview/TruffleHog: exact matcher-scope repair clean; no actionable P0/P1 finding (0.92 correctness confidence), Codex thread 01a04059-bf6b-7651-af35-3f9d59cd0055

Test audit

The new table-driven tests own behavior rather than implementation shape: the void-return row proves an owner-native allow remains singular even when the aggregate hook result is undefined; the matcher-miss row proves an unrelated registered hook cannot suppress generic attribution; arbitrary tool names and plugin IDs prove metadata ownership; allow/deny/failure/suppression/missing/stale authority exercise distinct boundaries; owner-native hook and approval receipts prove nonduplication; privacy assertions reject raw inputs/results/paths/prose. The Gateway-shaped regression uses the production final assembly path, credibly failed at its receipt assertion before the owner fix, and adds no test-only production seam or duplicate Gateway/UI mapping test.

LOC / best fix

  • production: +183 / -18 (net +165)
  • tests: +523 / -0
  • assertion baseline metadata: +1 / -1

Positive production growth is the private capability/ownership boundary: a closed descriptor and its identity-preserving copy path, fixed decision composition at the recorder owner, assembly bindings for filesystem/process, process-stable manifest-kind carriage for memory, and nonduplication markers at the policy owner. Repeated wrapper metadata copies were consolidated into one narrow helper. No schema, protocol, config, SDK, or public display surface changed.

Alternatives were rejected: tool-name/argument inference is unstable and private-data-prone; hardcoded plugin IDs violate plugin-agnostic core architecture; widening the public plugin contract solely for browser classification exceeds C02; the runtime-action owner does not provide the required post-await authority-adjacent enqueue on this wrapper path.

Dependency contract

Direct Codex inspection confirmed dynamic tool calls route by name through the runtime registry and handler, then execute through the same dispatcher/parallel machinery; unsupported wholly Codex-native actions therefore produce no inferred OpenClaw fact. Checked codex-rs/core/src/tools/registry.rs, handlers/dynamic.rs, router.rs, and parallel.rs at sibling head f1087ff151b06e781ecb086068d45fcc62d02da3.

@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper

clawsweeper Bot commented Aug 26, 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: L maintainer Maintainer-authored PR labels Aug 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 7:27 PM ET / 23:27 UTC.

ClawSweeper review

What this changes

Adds private, bounded audit receipts for generic filesystem, process, memory, and OpenClaw tool actions while retaining owner-native plugin-hook and approval receipts.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for protected maintainer review. Available source shows the prior matcher-scope concern is addressed, but the PR explicitly relies on a Codex dynamic-tool contract that could not be directly inspected because the required sibling checkout is absent and network resolution is unavailable.

Priority: P2
Reviewed head: 84a61b29ce3bf7d97197590559fd769e3856d983
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The local owner-boundary patch and regression coverage are coherent, but direct verification of the explicitly claimed Codex dependency contract is still missing.
Proof confidence 🌊 off-meta tidepool Not applicable: The trusted-maintainer proof gate does not apply; the PR body nevertheless reports an after-fix Testbox production-path artifact and focused regression runs.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The trusted-maintainer proof gate does not apply; the PR body nevertheless reports an after-fix Testbox production-path artifact and focused regression runs.
Evidence reviewed 6 items Current-main gap: Current main has no generic tool-decision module and proceeds from the final execution guard directly to tool start, so this central behavior is not already implemented.
Generic receipt boundary: The branch obtains the bound descriptor and caller identity, revalidates receipt authority immediately before enqueueing, and sends only the bounded receipt shape to the existing work sink.
Owner-routing repair: Only a handler that actually ran marks owner decision routing; the policy converts that private marker into suppression of the generic receipt, covering the earlier unmatched-hook concern.
Findings None None.
Security None None.

Live Verification

Command: pnpm test src/agents/agent-tools.before-tool-call.decision.test.ts

Result: FAIL (failed) — step 1 run pnpm test src/agents/agent-tools.before-tool-call.decision.test.ts: previous terminal command was still running after 30 seconds: "pnpm test src/agents/agent-tools.before-tool-call.decision.test.ts"

$ node --import tsx scripts/test-projects.mts src/agents/agent-tools.before-tool-call.decision.test.ts
[test] starting test/vitest/vitest.agents-core.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130358-vkar5U/target

 ✓  agents-core  src/agents/agent-tools.before-tool-call.decision.test.ts (17 tests) 836ms
     ✓ records ordinary 'tool' execution as private attribution independent of name and payload  460ms

 Test Files  1 passed (1)
      Tests  17 passed (17)
   Start at  23:28:14
   Duration  24.36s (transform 19.58s, setup 1.10s, import 22.02s, tests 836ms, environment 0ms)

[test] passed 1 Vitest shard in 31.39s

Assertions:

  • FAIL expect_output: generic tool action decision receipts

How this fits together

Agent tools are assembled with identity-backed metadata, then pass through the before-tool-call policy wrapper before execution. The wrapper either preserves an owner-native decision receipt or writes a generic bounded receipt to the lifecycle-owned audit writer.

flowchart LR
  A[Assembled agent tools] --> B[Action descriptor binding]
  B --> C[Before-tool-call wrapper]
  C --> D{Owner-native hook or approval receipt?}
  D -->|yes| E[Owner-native decision receipt]
  D -->|no| F[Generic bounded audit receipt]
  E --> G[Execution audit writer]
  F --> G
Loading

Decision needed

Question Recommendation
Should this protected audit change proceed after direct verification that the Codex dynamic-tool contract does not require an additional OpenClaw receipt path? Verify the Codex boundary, then land: Inspect the named Codex registry, dynamic handler, router, and parallel-dispatch paths against this receipt boundary before approving the exact head.

Why: The PR explicitly bases scope and proof on that external runtime contract, but the required sibling source was unavailable to this review.

Before merge

  • Resolve merge risk (P1) - The PR's stated Codex dynamic-tool compatibility cannot be independently validated until the exact Codex source contract is available.
  • Resolve merge risk (P1) - This changes persistent audit attribution and receipt ownership; exact-head checks are still incomplete, so merge should wait for the maintained audit path to be reviewed and green.
  • Complete next step (P2) - The protected maintainer label and unavailable direct Codex contract proof require human owner review rather than an automated repair lane.
Agent review details

Security

None.

PR surface

Source +165, Tests +523, Other 0. Total +688 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 11 183 18 +165
Tests 1 523 0 +523
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 13 707 19 +688

Review metrics

Metric Value Why it matters
Production versus test delta production +165, tests +523 The new private audit boundary is substantial feature growth, so its owner and non-duplication behavior merit maintainer scrutiny before merge.

Stored data model

Persistent data-model change detected: database schema: src/agents/agent-tools.before-tool-call.decision.ts, serialized state: src/agents/agent-tools.before-tool-call.decision.ts, unknown-data-model-change: src/agents/agent-tool-metadata.ts, vector/embedding metadata: src/agents/agent-tool-metadata.ts, vector/embedding metadata: src/agents/agent-tools.before-tool-call.decision.test.ts, vector/embedding metadata: src/agents/agent-tools.before-tool-call.decision.ts, and 5 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify audit ownership before merge (recommended)
    Confirm the external dynamic-tool boundary and wait for exact-head checks so generic receipts neither duplicate nor replace an owner-native record.
  2. Pause the audit expansion
    Defer the generic receipt producer if the required dependency contract cannot be checked without changing the intended scope.

Technical review

Best possible solution:

Retain the closed descriptor and canonical audit-writer path, then verify the claimed Codex dynamic-tool boundary from source and land only after exact-head checks pass.

Do we have a high-confidence way to reproduce the issue?

Yes for the local behavior: the new test describes the matched-void and matcher-miss execution paths, though this read-only review did not execute the branch.

Is this the best way to solve the issue?

Unclear: the OpenClaw owner boundary is coherent in available source, but the PR's Codex-dependent scope claim still needs direct contract verification.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b17930af5432.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The trusted-maintainer proof gate does not apply; the PR body nevertheless reports an after-fix Testbox production-path artifact and focused regression runs.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded audit-attribution feature with normal maintainer priority.
  • merge-risk: 🚨 other: The patch changes which persistent audit receipt is emitted for tool execution and how it is attributed to generic versus owner-native paths.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The trusted-maintainer proof gate does not apply; the PR body nevertheless reports an after-fix Testbox production-path artifact and focused regression runs.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Current-main blame attributes both the final before-tool-call execution boundary and the plugin hook runner to the same recent area commit. (role: recent area contributor; confidence: high; commits: 549360bc4261, b17930af5432; files: src/agents/agent-tools.before-tool-call.wrapper.ts, src/plugins/hooks.ts, src/gateway/server-runtime-subscriptions.ts)

Rank-up moves

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

  • Inspect the exact Codex dynamic-tool registry, handler, router, and parallel-dispatch sources referenced by the PR body.
  • Wait for exact-head checks to complete successfully.

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 (6 earlier review cycles)
  • reviewed 2026-08-26T20:15:56.519Z sha 51f820a :: found issues before merge. :: [P1] Bind descriptors in the OpenClaw-tools execution path
  • reviewed 2026-08-26T20:58:54.872Z sha 2dac49e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T21:31:56.132Z sha b83f4b9 :: found issues before merge. :: [P1] Mark no-op plugin hooks as owner decisions
  • reviewed 2026-08-26T22:02:13.351Z sha b83f4b9 :: found issues before merge. :: [P1] Mark executed void hooks as owner decisions
  • reviewed 2026-08-26T22:24:54.949Z sha 9beee70 :: found issues before merge. :: [P1] Record unmatched scoped hooks generically
  • reviewed 2026-08-26T22:45:27.475Z sha 9beee70 :: found issues before merge. :: [P1] Only suppress generic receipts for matching hooks

@joshavant
joshavant marked this pull request as ready for review August 26, 2026 20:50
@joshavant
joshavant marked this pull request as draft August 26, 2026 21:02
@joshavant
joshavant marked this pull request as ready for review August 26, 2026 21:24
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Aug 26, 2026
@joshavant
joshavant marked this pull request as draft August 26, 2026 21:56
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 26, 2026
@joshavant
joshavant marked this pull request as ready for review August 26, 2026 22:17
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 26, 2026
@joshavant
joshavant marked this pull request as draft August 26, 2026 22:39
@joshavant
joshavant marked this pull request as ready for review August 26, 2026 23:19
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@joshavant
joshavant merged commit 29625bc into main Aug 27, 2026
195 checks passed
@joshavant
joshavant deleted the codex/c02-generic-tool-data-actions branch August 27, 2026 00:13
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
* feat(audit): record generic tool action decisions

* fix(audit): bind OpenClaw action descriptors

* fix(audit): keep decision routing private

* fix(audit): avoid duplicate void-hook decisions

* fix(audit): scope plugin hook ownership

* docs(agents): preserve decision audit FIFO ownership
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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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