Policy: add conformance system with channel checks#80407
Conversation
|
Codex review: needs maintainer review before merge. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: not applicable. as a bug reproduction; this is a new feature PR. The inspected proof log gives a high-confidence behavior path for policy check, doctor lint, opt-in repair, and clean recheck. PR rating Rank-up moves:
What the crustacean ranks mean
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. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Merge this only as an explicitly approved, opt-in conformance layer over existing OpenClaw config, with release/package checks confirming the new bundled plugin and dependency are packaged correctly. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction; this is a new feature PR. The inspected proof log gives a high-confidence behavior path for policy check, doctor lint, opt-in repair, and clean recheck. Is this the best way to solve the issue? Unclear until maintainers accept the product boundary. If policy-as-health is the desired architecture, the implementation is coherent and I did not find a blocking correctness defect; if not, this should pause before the dependent policy stack proceeds. Label changes:
Label justifications:
Acceptance criteria:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 45930457ca19. |
efc8b7e to
8fc98cc
Compare
b3c097b to
ab1a5fb
Compare
ab1a5fb to
860487e
Compare
|
Review result: NEEDS WORK I found one blocker before this should go to F1 IMPORTANT: Invalid In I verified this with a malformed Fix requested: Add a dedicated policy-parse-error health finding/check, or reuse an existing policy finding surface with error severity, and include tests for malformed policy files in both doctor lint and Focused tests passed locally via PowerShell: pnpm exec vitest run extensions/policy/src/doctor/register.test.ts extensions/policy/src/cli.test.ts src/flows/bundled-health-checks.test.ts extensions/oc-path/src/oc-path/tests/document.test.ts --reporter=dotResult: 4 test files passed, 24 tests passed. Note: the |
860487e to
9fa1a57
Compare
9fa1a57 to
bb7fb6f
Compare
|
Fixed in the latest push (bb7fb6f): malformed policy JSONC now emits a policy/policy-jsonc-invalid error finding instead of returning clean, with focused coverage in extensions/policy/src/doctor/register.test.ts. I also made doctor --fix reject --only/--skip outside --lint so selectors are not silently ignored. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
The prior re-review workflow run failed before producing a fresh verdict. Re-requesting now that the docs nav fix is pushed and CI is green. @clawsweeper re-review |
|
/review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Moonlit Diff Drake Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
|
Merged in cbf72e5. Thanks @giodl73-repo. What landed:
Proof:
|
Policy: add conformance system with channel checks
Branch:
policy-channels-consumerGitHub base:
mainCurrent draft: #80407
Draft status: channels-first policy PR
Title
Policy: add conformance system with channel checks
Summary
This PR adds
policyas a bundled extension for enterprise conformance. It gives operators a workspaceartifact for expressing required posture, uses existing OpenClaw settings as
the enforcement target, and produces auditable proof that the workspace still
matches the requirements.
This draft uses channels as the first concrete policy area:
policy.jsoncdefines the authored channel requirement, such as denying aprovider.
the shared health registry. Doctor then runs the registered checks; doctor
does not load plugins itself.
channels.*config as evidence.doctor --lintreports non-conforming settings, anddoctor --fixcanrepair the owned setting when repairs are enabled.
policy check --jsonemits the recordable audit tuple:policyHash + evidenceHash + findingsHash + clean result -> attestationHash.Policy is only a conformance layer here.
channels.*remains the runtimeconfiguration. Findings identify both sides of the decision:
targetpointsto the observed setting, such as
oc://openclaw.config/channels/telegram, andrequirementpoints to the authored policy rule, such asoc://policy.jsonc/channels/denyRules/#0.Motivation
Operators already use config to decide which communication surfaces exist, but
there is not a small, auditable way to say "this workspace must not enable this
surface" and then prove that setting is still true. That shows up in adjacent
requests for protected config changes, proposal-only disabling of
plugin/tool/channel surfaces, and doctor dry-run/diff behavior:
This PR keeps the answer narrow. It does not add runtime channel enforcement or
a second channel config system. It adds a way to prove which policy file was
checked against which observed channel evidence, what findings were returned,
and when that check happened.
Maintainer Input Requested
Is policy-as-health the right architecture?
This draft treats policy as a set of health checks over existing OpenClaw
surfaces.
policy.jsoncdefines requirements, the enabled policy packageregisters the relevant checks, and
doctor --lintremains the sharedconformance gate over already-registered checks. Doctor does not load
plugins itself. Is that the right shape, or should policy own a separate
check/evaluation loop?
Where should policy settings live?
The draft uses
policy.jsoncfor authored requirements andplugins.entries.policy.configfor operator toggles such asenabled,workspaceRepairs,expectedHash, and the policy path. Is that split right,or should more of this be expressed through normal OpenClaw config?
Is the attestation shape useful and sufficient?
policy check --jsonemitspolicy.hash,workspace.hashover theobserved evidence payload,
findingsHash,checkedAt, andattestationHash.checkedAtis audit metadata; the stableattestationHashbinds policy hash, evidence hash, findings hash, and cleanresult. Is that the right durable audit tuple for policy checks, or should
the evidence/result model be different before runtime consumers start
recording it?
Is the extension activation boundary right?
Doctor does not load plugins directly. This draft keeps the policy logic in
the bundled policy extension and lets the core bundled-health loader
register policy checks only when the policy extension is enabled and not
blocked by plugin control-plane settings. Is that the right boundary for
bundled policy health checks?
What Changed
policypackage and its config schema.policy check.policy.jsoncas the workspace-owned policy artifact.policy check --json.targetandrequirementfields so reviewers can seethe observed setting and authored policy rule behind each finding.
channel providers.
evidence while ignoring reserved channel config namespaces such as
channels.defaultsandchannels.modelByChannel.Policy Shape
{ "channels": { "denyRules": [ { "id": "no-telegram", "when": { "provider": "telegram" }, "reason": "Telegram is not approved for this workspace.", }, ], }, }Category blocks are namespaces.
channels: {}does not run a check by itself;the channel check runs when an authored requirement such as
denyRulesispresent.
Safety
doctor --lintandpolicy checkare read-only. The audit value comes frompolicy check --json, which records:checkedAtis emitted alongside that hash so operators can see when the checkran, but it is not part of the stable attestation hash.
doctor --fixonly changes channel config whenplugins.entries.policy.config.workspaceRepairsis explicitly enabled. Therepair is intentionally narrow: it disables denied channels and leaves all
other channel material intact.
This draft does not add a channel runtime enforcement hook. If a later channel
gateway hook uses policy to block, approve, or annotate a channel interaction,
the audit message should include the attestation hash from the last clean
policy check. That attestation binds the policy hash, observed evidence hash, findings hash, and clean result so operators can correlate the runtime decision with the exact policy file, workspace evidence, and clean result that produced it.
checkedAtremains audit metadata beside the stable hash.Real behavior proof
Fresh deterministic proof artifacts:
Behavior addressed: Policy channel checks produce lint findings, repair the
owned setting when allowed, and end with a clean
policy check --jsonattestation over the updated evidence.
Real environment tested: Local Windows source checkout with a temporary
OpenClaw config and workspace. The policy was enabled in config,
policy.jsoncdenied providertelegram, and the OpenClaw config hadchannels.telegram.enabled=true.Exact steps or command run after this patch:
policy.jsoncwithchannels.denyRules[{ when: { provider: "telegram" } }].openclaw policy check --jsonto emit channel evidence plus policy,evidence, findings, and attestation hashes.
openclaw doctor --lint --only policy/channels-denied-provider --json.openclaw doctor --fix --yes --non-interactiveto apply enabled policy repairs.openclaw doctor --lint --only policy/channels-denied-provider --jsonafter the fix.
openclaw policy check --jsonto emit the final clean attestation.Evidence after fix:
Observed result after fix: The first lint command reports the enabled
Telegram channel with
target=oc://openclaw.config/channels/telegramandrequirement=oc://policy.jsonc/channels/denyRules/#0.doctor --fix --yes --non-interactivedisableschannels.telegram.enabled. The after-fix lint command validates clean withzero findings, and the final
policy check --jsonemits a clean attestationover the updated channel evidence.
What was not tested: No live channel gateway was started. This PR only
changes policy conformance checks and config repair; it does not add runtime
channel enforcement.
Testing
Focused tests cover bounded policy health registration, policy check
attestation output, missing policy reporting, hash mismatch reporting,
deny-rule findings, disabled-channel allowance, and denied-channel repair.
Follow-Up
Tool metadata conformance is scoped as a follow-up PR. It uses the same
authored-policy plus observed-evidence model without reintroducing generated
policy:
#80056
Model, network, and MCP conformance are scoped as a combined follow-up that
shows the same policy shape across more OpenClaw settings categories:
#80783
Runtime audit metadata and accepted-attestation enforcement are scoped as the
final follow-up in this first policy arc:
#81104