Skip to content

policy: repair automatic narrowing findings#99690

Merged
giodl73-repo merged 1 commit into
openclaw:mainfrom
giodl73-repo:policy-doctor-automatic-narrowers
Jul 5, 2026
Merged

policy: repair automatic narrowing findings#99690
giodl73-repo merged 1 commit into
openclaw:mainfrom
giodl73-repo:policy-doctor-automatic-narrowers

Conversation

@giodl73-repo

@giodl73-repo giodl73-repo commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add guarded automatic doctor --fix repairs for the first safe policy narrowing checks.
  • Require plugins.entries.policy.config.workspaceRepairs=true before policy config repairs mutate workspace config.
  • Keep review-required/manual findings detect-only and skip scoped data-handling repairs that would mutate shared config.
  • Preserve object-form diagnostics.otel.captureContent preferences by setting only captureContent.enabled=false.

Validation

  • node scripts/run-vitest.mjs extensions/policy/src/doctor/register.test.ts extensions/policy/src/doctor/metadata.test.ts src/flows/doctor-repair-flow.test.ts --reporter=dot passed: 2 Vitest shards / 299 tests.
  • node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfo passed.
  • OPENCLAW_OXLINT_SKIP_PREPARE=1 node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/policy/src/doctor/automatic-repairs.ts extensions/policy/src/doctor/register.test.ts extensions/policy/src/doctor/metadata.test.ts passed.
  • git diff --check passed.

Real behavior proof

Behavior or issue addressed:
doctor --fix should repair automatic policy telemetry content-capture findings without discarding granular object-form telemetry preferences.

Real environment tested:
Windows PowerShell, source checkout C:\src\openclaw-fork, PR head 525e492752. The full dev CLI was invoked with an isolated OPENCLAW_CONFIG_PATH; local full doctor execution reached the policy repair and printed the expected repair, then stalled in a later unrelated post-security doctor stage before the final config writer. The persisted-config proof therefore uses the same registered policy health check, runDoctorHealthRepairs, and replaceConfigFile writer in-process.

Exact steps or command run after this patch:

  1. Seeded isolated config with diagnostics.otel.captureContent={ enabled:true, toolInputs:true, toolOutputs:true } and policy dataHandling.telemetry.denyContentCapture=true.
  2. Ran node --import tsx src/entry.ts doctor --fix --yes --non-interactive --no-workspace-suggestions with isolated OPENCLAW_CONFIG_PATH, OPENCLAW_STATE_DIR, and OPENCLAW_HOME.
  3. Ran an in-process proof that registered the policy doctor checks, selected policy/data-handling-telemetry-content-capture, called runDoctorHealthRepairs, persisted with replaceConfigFile, and reread the config file.

Evidence after fix:
CLI transcript included Set diagnostics.otel.captureContent.enabled=false for policy conformance. The persisted proof printed:

PROOF_DIR=C:\Users\giodl\AppData\Local\Temp\openclaw-policy-repair-proof-saYFOJ
CHANGES=["Set diagnostics.otel.captureContent.enabled=false for policy conformance."]
FINDINGS=1
REMAINING_FINDINGS=0
AFTER_CAPTURE={"enabled":false,"toolInputs":true,"toolOutputs":true}

Observed result after fix:
The telemetry policy finding is repaired, no telemetry finding remains, and object-form captureContent subkeys are preserved while the master enabled switch is disabled.

What was not tested:
The packaged binary path and live LLM/provider calls were not tested. The full dev CLI did not reach final config persistence locally because it stalled after the Security doctor section in an unrelated later doctor probe.

Stack

Stacked on merged #99686. Downstream stack should be refreshed after this head: #99700, #99720, #99731, #99776.

Notes

Normal local build/prep wrappers hit the known Windows Rolldown boundary error (TypeError: Cannot convert undefined or null to object), so lint was run with the repo-supported OPENCLAW_OXLINT_SKIP_PREPARE=1 path after the focused source checks passed.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts extensions: policy size: XL maintainer Maintainer-authored PR labels Jul 3, 2026
@clawsweeper

clawsweeper Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 809e94328044b6a262d77187262f90e39b3c64ba, but the PR head is now a5b42a57d6d55c1692e7050b22e50ff4fa56ff0b. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (21 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-05T03:24:47.568Z sha 525e492 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-05T03:31:15.847Z sha 525e492 :: found issues before merge. :: [P3] Remove the duplicate surface-budget test
  • reviewed 2026-07-05T04:47:00.363Z sha d48b19d :: needs maintainer review before merge. :: none
  • reviewed 2026-07-05T04:52:50.764Z sha d48b19d :: needs changes before merge. :: [P2] Document the expanded policy repair surface
  • reviewed 2026-07-05T05:05:45.396Z sha d48b19d :: needs changes before merge. :: [P2] Document the expanded policy repair surface
  • reviewed 2026-07-05T08:16:02.668Z sha 468a474 :: needs changes before merge. :: [P1] Guard scoped elevated repairs from changing global tools config
  • reviewed 2026-07-05T13:36:07.793Z sha 24c1ded :: found issues before merge. :: [P3] Align scoped elevated repair guidance with skipped behavior
  • reviewed 2026-07-05T13:59:30.784Z sha 8343045 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 3, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Jul 3, 2026
@giodl73-repo

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

I restacked the policy series onto current upstream/main with non-force merge commits, resolved the test/scripts/plugin-sdk-surface-report.test.ts conflict, and added the exact Real behavior proof section to this PR body.

Fresh proof from the top of the stack (283c1bb4ca):

  • node scripts/run-vitest.mjs extensions/policy/src/doctor/metadata.test.ts extensions/policy/src/doctor/register.test.ts extensions/policy/src/doctor/strictness.test.ts src/flows/doctor-repair-flow.test.ts --reporter=dot passed: 10 core repair-flow tests + 297 policy doctor tests.
  • node scripts/run-vitest.mjs test/scripts/plugin-sdk-surface-report.test.ts --reporter=dot passed: 7 tests.
  • pnpm tsgo:extensions passed.
  • pnpm lint:extensions passed.
  • git diff --check passed.

@clawsweeper

clawsweeper Bot commented Jul 4, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@omarshahine

Copy link
Copy Markdown
Contributor

Codex review of the Automatic Narrowing PR.

Findings:

  1. Agent-scoped data-handling repairs can mutate global logging/telemetry config. dataHandlingFindings() re-runs redaction and telemetry findings for every scoped agentIds policy in extensions/policy/src/doctor/register.ts:4124, and the new automatic repair metadata does not restrict those rules to global scope in extensions/policy/src/doctor/metadata.ts:452. The evidence paths are global, such as oc://openclaw.config/logging/redactSensitive and oc://openclaw.config/diagnostics/otel/captureContent, so doctor --fix can satisfy an agent-scoped policy by patching the shared global setting. That is broader than the scoped policy claim and needs either a scope-local target or a skip/review-required path.

  2. disableRemoteGatewayMode writes more config than the finding reports. The detector reports gateway.mode and, when present, gateway.remote.url for remote mode findings in extensions/policy/src/policy-state.ts:933 and extensions/policy/src/doctor/scopes/gateway.ts:261; the test at extensions/policy/src/doctor/register.test.ts:7323 encodes that finding set. The repair in extensions/policy/src/doctor/automatic-repairs.ts:152 also writes gateway.remote.enabled = false whenever it is not already false. That extra mutation may be desirable, but it is not part of the reported finding path, so this is not an exact narrowed repair.

  3. The workspace-repair opt-in skip message is returned as changes, so doctor --fix can drop the actionable guidance. The split repair flow forwards warnings for skipped repairs and ignores changes unless the status is repaired in src/flows/doctor-repair-flow.ts:130. Existing policy repair skips use warnings for this reason, for example extensions/policy/src/doctor/register.ts:5343. The new helper returns the opt-in guidance in changes in extensions/policy/src/doctor/automatic-repairs.ts:200, and the test only inspects the helper result rather than the end-to-end repair flow output.

Best-fix verdict: too broad for merge as automatic repair. The repair layer should prove the write target is the exact scoped config surface, or downgrade the unsafe cases to skipped/review-required with surfaced guidance.

Evidence checked: extensions/policy/src/doctor/automatic-repairs.ts, extensions/policy/src/doctor/metadata.ts, extensions/policy/src/doctor/register.ts, extensions/policy/src/doctor/scopes/gateway.ts, extensions/policy/src/policy-state.ts, src/flows/doctor-repair-flow.ts, and the adjacent repair tests.

@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Jul 4, 2026
@giodl73-repo

Copy link
Copy Markdown
Contributor Author

Addressed Omar's automatic narrowing findings in 7341a15e7c: scoped data-handling repairs that would mutate shared logging/telemetry config now skip with warnings, remote gateway repair only changes the reported gateway.mode target, and workspace-repair opt-in guidance is surfaced via warnings so the repair flow does not drop it. Added regression coverage for scoped data-handling skip behavior.

@giodl73-repo

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Reviewer-requested fixes are pushed on this updated head. Fresh local proof before push: focused policy/core/CLI/tooling Vitest passed, pnpm tsgo:extensions passed, pnpm lint:extensions passed, git diff --check passed, and node --import tsx scripts/check-policy-config-coverage.ts --check --json passed.

@clawsweeper

clawsweeper Bot commented Jul 4, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations and removed commands Command implementations docs Improvements or additions to documentation scripts Repository scripts labels Jul 4, 2026
@giodl73-repo

Copy link
Copy Markdown
Contributor Author

Updated this PR body with current stack heads and final-stack proof after the #99686 proof refresh. The foundation proof now shows policy-owned policy.fixRecommendation in public policy JSON and recommendation-free attestation hashing, and this PR includes that fix via the forward-merged stack.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 5, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations agents Agent runtime and tooling extensions: device-pair size: XL and removed size: L labels Jul 5, 2026
@giodl73-repo
giodl73-repo force-pushed the policy-doctor-automatic-narrowers branch from 809e943 to a5b42a5 Compare July 5, 2026 15:02
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web app: ios App: ios app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling extensions: device-pair size: XL labels Jul 5, 2026
@giodl73-repo

Copy link
Copy Markdown
Contributor Author

Restacked #99690 cleanly onto current main and dropped the stale merged policy stack history.

New head: a5b42a57d6d

Final diff is scoped back to the six policy/docs files:

  • docs/cli/policy.md
  • extensions/policy/src/doctor/automatic-repairs.ts
  • extensions/policy/src/doctor/register.test.ts
  • extensions/policy/src/doctor/scopes/data-auth.ts
  • extensions/policy/src/doctor/scopes/gateway.ts
  • extensions/policy/src/doctor/scopes/tools.ts

Validation on the clean restack:

  • node scripts/run-vitest.mjs extensions/policy/src/doctor/register.test.ts extensions/policy/src/doctor/metadata.test.ts src/flows/doctor-repair-flow.test.ts --reporter=dot
  • pnpm exec oxfmt --check docs/cli/policy.md extensions/policy/src/doctor/automatic-repairs.ts extensions/policy/src/doctor/register.test.ts extensions/policy/src/doctor/scopes/data-auth.ts extensions/policy/src/doctor/scopes/gateway.ts extensions/policy/src/doctor/scopes/tools.ts
  • git diff --check origin/main...HEAD
  • git diff --check
  • pnpm tsgo:extensions

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 5, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 5, 2026
@giodl73-repo
giodl73-repo merged commit 14b2ca1 into openclaw:main Jul 5, 2026
110 of 120 checks passed
@giodl73-repo

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: policy maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants