Skip to content

fix(decisions): report applied tool restrictions - #174013

Merged
vincentkoc merged 2 commits into
mainfrom
fix/decision-prefilter-effect-diagnostics-20261016
Oct 16, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/decision-prefilter-effect-diagnostics-20261016

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

Operators cannot distinguish a successful Decision evaluation from whether its automatic tool restriction was proposed, applied, or restored before dispatch.

User Impact

Debug diagnostics now record bounded consumer status and model-facing tool counts at the policy owner. Model routing, restriction policy, and tool output are unchanged.

Why This Change Was Made

The existing consumer policy owner records actual application and withdrawal separately from the provider evaluation log. The provider's existing not-observed result remains unchanged; these observations do not claim tool dispatch or task success.

The change adds no configuration, schema, storage, or caller-authored identifiers. Production code increases by 29 net lines to record facts at their owning boundary; tests increase by 25 net lines.

Evidence

  • Existing structured and code-mode policy-owner regressions now assert observations for forced tools, permission-generation changes, one-time restoration, and ordinary hooks that do not emit Decision policy effects.
  • Disabled-logger and prompt-assembly guard coverage is included.
  • Scoped formatting with the repository-pinned formatter, the native commit hook, TypeScript syntax checks, and git diff --check passed.
  • Independent scoped review found no actionable P0-P2 findings.
  • Runtime tests were not run before publication because the source checkout has no qualified application dependencies. Exact-head CI must cover src/decisions/diagnostics.test.ts, src/agents/embedded-agent-runner/run/attempt-prompt-tool-policy.test.ts, and src/agents/embedded-agent-runner/run/attempt-prompt-build.provenance.test.ts before landing.
  • No performance, cost-savings, dispatch, or task-success claim is made.

@vincentkoc vincentkoc self-assigned this Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@vincentkoc
vincentkoc marked this pull request as ready for review October 16, 2026 08:22
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR adds debug observations for proposed, applied, and restored Decision tool restrictions, including model-facing tool counts.

Example: A structured tool surface contains read, write, and a host-required message tool.

  • Before: Provider diagnostics report callerEffect as not-observed, without recording the applied restriction.
  • After: Consumer diagnostics record applied with counts 3 to 1, then restored when the Decision cap is withdrawn.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful, focused production instrumentation is held by an introduced test-mock ratchet failure; the separate test-type failure remains unattributed.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored diagnostics change is outside the ordinary contributor proof gate and does not materially change authority; supplied evidence contains source assertions and CI, with no shipped-entry-point diagnostic trace.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Maintenance · Worth it: Yes · Fix scope: Complete
User problem: Operators cannot tell whether a successful Decision evaluation actually changed the tool surface or was later withdrawn.
Reason: The maintainer-authored direction adds useful, bounded observations without introducing another policy owner or changing defaults.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this maintainer-authored PR open: the diagnostic improvement is useful, but its new mock introduces a concrete CI ratchet failure.

Priority: P3
Reviewed head: f88f026bb29a4218f49e8be4bd63ad1a5c9fa9a8

Before merge

  • Replace the closed diagnostics mock with a scoped spy (P2) - This new first-party mock returns only logDecisionToolPrefilter, without preserving the module's real exports or explaining isolation. It is absent from the grandfathered baseline, so check:test-mock-exports rejects it; exact-head CI already reports that ratchet failure. Use a scoped spy on the real diagnostics module and restore it after each test, avoiding both a broad partial mock and baseline expansion.

Findings

  • [P2] Replace the closed diagnostics mock with a scoped spy — src/agents/embedded-agent-runner/run/attempt-prompt-tool-policy.test.ts:12-14
Agent review details

How this fits together

The embedded runner combines Decision results with host and hook tool policy before model submission; the existing decisions logger receives bounded status and count observations.

flowchart TD
  A[Prompt assembly] --> B[Decision evaluation]
  B --> C[Existing tool policy owner]
  D[Host and hook policy] --> C
  C --> E[Model submission]
  B --> F[Decision debug logger]
  C --> F
Loading

Technical review

Best possible solution:

Keep observations at the existing policy owner and replace the closed test mock with a scoped spy while preserving the diagnostic contract.

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

Current-main source explicitly leaves provider caller effects unobserved and has no matching consumer observations; no runtime reproduction was performed.

Is this the best way to solve the issue?

Recording bounded facts where restrictions are applied and withdrawn preserves ownership and avoids inferring policy effects from provider success.

Full review comments:

  • [P2] Replace the closed diagnostics mock with a scoped spy — src/agents/embedded-agent-runner/run/attempt-prompt-tool-policy.test.ts:12-14
    This new first-party mock returns only logDecisionToolPrefilter, without preserving the module's real exports or explaining isolation. It is absent from the grandfathered baseline, so check:test-mock-exports rejects it; exact-head CI already reports that ratchet failure. Use a scoped spy on the real diagnostics module and restore it after each test, avoiding both a broad partial mock and baseline expansion.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 62240dbc4fa6.

Provenance checked

  • Decision restriction application and restoration keeps the original intent (2f1f8be: The optional consumer narrows tools at their policy owner and restores the latest permitted generation when model selection changes.)
  • Provider evaluation diagnostics keeps the original intent (560d15c: Provider diagnostics intentionally report caller effects as unobserved and exclude private submitted content.)
  • Prompt module ownership keeps the original intent (b05a308: Move-only consolidation placed prompt assembly and observability in their current modules; history was followed across the earlier assembly and observability names.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/agents/embedded-agent-runner/run/attempt-prompt-tool-policy.test.ts --maxWorkers=1
  • pnpm test src/agents/embedded-agent-runner/run/attempt-prompt-build.provenance.test.ts --maxWorkers=1
  • pnpm test src/decisions/diagnostics.test.ts --maxWorkers=1
  • pnpm check:test-mock-exports
  • git diff --check

What I checked:

PR surface

Source +29, Tests +25. Total +54 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 30 1 +29
Tests 3 27 2 +25
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 57 3 +54

Labels

Label changes:

  • add P3: This improves operator diagnostics without changing tool availability, provider behavior, or user state.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This improves operator diagnostics without changing tool availability, provider behavior, or user state.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 16, 2026, 4:38 AM ET / 08:38 UTC.

@vincentkoc
vincentkoc merged commit 3431d6a into main Oct 16, 2026
110 checks passed
@vincentkoc
vincentkoc deleted the fix/decision-prefilter-effect-diagnostics-20261016 branch October 16, 2026 14:22
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
* fix(decisions): report applied tool restrictions

* test(decisions): document policy diagnostic isolation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant