Policy: add runtime audit metadata and attestation enforcement#81104
Policy: add runtime audit metadata and attestation enforcement#81104giodl73-repo wants to merge 20 commits into
Conversation
|
Codex review: found issues before merge. Reviewed July 3, 2026, 11:52 PM ET / 03:52 UTC. Summary PR surface: Source +1845, Tests +1704, Docs +316, Config +5, Other +30. Total +3900 across 32 files. Reproducibility: yes. for the PR blockers by source inspection: the runtime gate computes attestations with empty findings while policy check hashes attested findings, and the secret-file test changes the rejected-file expectation from throwing to undefined. Review metrics: 2 noteworthy metrics.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land a narrower rebased runtime-audit change that shares the policy check attestation builder/evaluator, preserves fail-closed secret handling, and gets maintainer signoff on runtime blocking plus metadata API expansion. Do we have a high-confidence way to reproduce the issue? Yes for the PR blockers by source inspection: the runtime gate computes attestations with empty findings while policy check hashes attested findings, and the secret-file test changes the rejected-file expectation from throwing to undefined. Is this the best way to solve the issue? No. The feature direction is plausible, but the current branch is not the best implementation until it reuses the policy check attestation contract, preserves fail-closed secret handling, and is rebased for maintainer review. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9d68f877ac3e. Label changesLabel justifications:
Evidence reviewedPR surface: Source +1845, Tests +1704, Docs +316, Config +5, Other +30. Total +3900 across 32 files. View PR surface stats
Security concerns:
What I checked:
Likely related people:
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. How this review workflow works
|
11d74ba to
97c39e0
Compare
|
Restacked on the refreshed policy conformance stack and current origin/main (e643890). Verified runtime approval metadata/stale-attestation behavior with focused tests and extension typecheck.\n\nChecks:\n- node scripts/test-projects.mjs extensions/policy/src/runtime-tool-policy.test.ts extensions/policy/src/doctor/register.test.ts extensions/policy/src/cli.test.ts src/flows/bundled-health-checks.test.ts --reporter=verbose\n- node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfo\n- node scripts/check-changed.mjs\n- git diff --check\n\n@clawsweeper re-review |
|
Updated the runtime audit pass after the rebase. The policy health context now accepts optional runtime evidence, channel runtime findings use a non-oc evidence target ( |
|
Reviewed the runtime-audit branch after the runtime evidence change and updated the PR body. One small follow-up fix: runtime evidence refs now URI-encode channel/account segments so |
|
Small wording follow-up after review: clarified that runtime audit findings are centered on the |
a67ce8e to
3e4e780
Compare
b0ef865 to
ea08857
Compare
Make tools.requireMetadata the canonical policy schema for risk, sensitivity, and owner requirements. Update runtime enforcement, doctor findings, evidence parsing, tests, and policy docs to use the new schema. Co-authored-by: Copilot <[email protected]>
5903758 to
b11c171
Compare
Policy: add runtime audit metadata and attestation enforcement
Branch:
policy-runtime-auditGitHub base:
mainLogical base:
policy-conformance-examplesCurrent draft: #81104
Draft status: final policy runtime/audit step
Title
Policy: add runtime audit metadata and attestation enforcement
Summary
This PR closes the first policy arc by connecting clean policy checks to
runtime decisions and runtime audit evidence.
xarlier policy drafts establish the model:
policy.jsoncdefines authored requirements.doctor --lintandpolicy checkreport conformance findings.policy check --jsonemits a stable attestation hash for the accepted cleanstate.
This PR makes that attestation useful at runtime. When the policy runtime tool
gate is enabled, approval decisions carry structured policy metadata. If
expectedAttestationHashis configured and watched evidence changes, the gatefails closed before approval. That lets a supervisor or gateway compare a tool
decision against the exact policy/evidence state that was previously accepted.
policy diffcan then compare two savedpolicy check --jsonoutputs toexplain whether the policy, evidence, findings, or clean result changed.
The PR also adds the first runtime evidence slice for policy health checks.
Health checks can receive a channel runtime snapshot and report a denied
channel account that is still running. The important contract is the runtime
evidence payload; any finding
targetis only a compact evidence label, not anew path language.
The intended ownership model is that a workspace can produce a candidate clean
attestation, but a supervisor or gateway authority accepts the attestation. The
agent/container should not be able to silently update the accepted hash that
governs its own runtime decisions.
Motivation
Policy conformance is only useful for runtime governance if the runtime can
prove which policy check it is relying on. Otherwise an operator can run
policy check, accept a clean result, and then miss a later change to thewatched evidence before a tool call is approved.
This PR adds the missing handshake:
policy checkproduces the accepted attestation hash;expectedAttestationHash;policy.jsoncandwatched evidence;
The runtime gate still uses OpenClaw's existing trusted tool policy hook. This
does not add a new gateway protocol or a second policy engine.
checkedAtremains audit timing metadata. It is not part ofattestationHash, so repeated clean checks of unchanged policy state do notforce a new accepted hash.
Maintainer Input Requested
Is the accepted-attestation handshake the right runtime boundary?
The draft treats
expectedAttestationHashas the compact value a supervisoror gateway can compare against. It binds policy hash, evidence hash,
findings hash, and clean result. Is that the right unit to carry into
runtime decisions, and should the accepted value be owned by the supervisor
rather than by the workspace being governed?
Is
runtimeEvidencethe right health-check input for runtime audits?The draft adds optional
runtimeEvidenceto the health check context. Thepolicy extension uses it for channel runtime snapshots and keeps runtime
findings focused on the evidence package rather than oc-path syntax. Is this
the right shape for health checks that need to compare config/policy against
live runtime state?
Should runtime evidence refs stay
runtime://..., or become read-onlyoc://runtime/...paths?The draft intentionally separates live runtime evidence from document/config
oc-paths: policy findings can point to resolvable files with
oc://..., butrunning channel accounts and other live observations are evidence refs rather
than writable workspace documents. We chose a separate
runtime://...-stylenamespace for that boundary. Would maintainers prefer exposing runtime
evidence as read-only
oc://runtime/...paths instead, so path tooling candiscover/search them consistently with config and workspace paths? In
particular, should
openclaw path find(or the future shared find surface)be able to search runtime refs alongside document-backed
oc://paths whilestill making runtime refs non-mutating and clearly evidence-only?
Should block decisions have structured metadata too?
Approval decisions already carry structured metadata through gateway approval
records. Attestation mismatch blocks currently include both hashes in the
block reason because the existing block result shape has no metadata slot.
Should blocked trusted-tool-policy decisions also gain structured metadata,
or is the human-readable block reason enough for this first step?
Is this the right place to thread approval metadata?
This PR keeps metadata on the existing approval descriptor and preserves it
through gateway approval list/resolve events. Is that the correct audit path,
or should policy decisions be recorded in a separate runtime audit event?
What Changed
and resolve paths.
evidence hash, current/expected attestation hash, and target tool reference.
expectedAttestationHash.policy difffor comparing two saved policy check outputs.runtimeEvidenceand a policy channel runtimeaudit check for denied channel accounts that are still running.
TOOLS.mdchanges after an accepted clean policy checkand the runtime gate refuses the tool request because the current
attestation differs.
Runtime Shape
Config records the accepted clean policy check:
{ "plugins": { "entries": { "policy": { "enabled": true, "config": { "enabled": true, "runtimeToolPolicy": true, "expectedAttestationHash": "sha256:..." } } } } }In an enterprise deployment, that value should come from a supervisor/gateway
acceptance flow, not from the agent updating its own workspace. A typical review
loop is:
policy check --json > accepted.jsonfor the currently accepted state.sensitivity metadata.
policy check --json > candidate.json.policy diff accepted.json candidate.json.attestationHash.expectedAttestationHash.At runtime:
policy.jsonc.TOOLS.mdevidence.policy check.expectedAttestationHash, the toolcall is blocked before approval.
call proceeds or requires approval.
Policy health checks can also receive runtime evidence. The first supported
runtime shape is a channel runtime snapshot with
channelAccounts. If policydenies a channel provider but that provider still has a running account, policy
reports
policy/channels-denied-provider-runningagainst that runtime evidence:{ "checkId": "policy/channels-denied-provider-running", "path": "gateway runtime", "target": "runtime:channels/telegram/accounts/default", "requirement": "oc://policy.jsonc/channels/denyRules/#0" }The
targetstring is intentionally minimal. It is a label inside the runtimeevidence package, not a new oc-path surface. Config and workspace findings keep
using real
oc://paths when they point to resolvable documents.Real Behavior Proof
Behavior addressed: Policy check should emit auditable policy/evidence/findings/attestation hashes,
policy diff/policy watchshould distinguish timestamp-only checks from real drift, runtime tool policy should fail closed whenexpectedAttestationHashis stale, and policy-governed approval requests should carry structured policy/evidence/attestation metadata.Real environment tested: Clean WSL detached worktrees for upstream/main and PR #81104 head, with a temporary workspace containing
policy.jsoncandTOOLS.md. The source-level probe imported the PR-head policy runtime modules through the repotsxloader.Exact steps or command run after this patch:
node --import ./node_modules/tsx/dist/loader.mjs probe-policy-runtime-audit.mjs.policy.jsoncand a critical governeddeploytool inTOOLS.md.checkedAtchanged and compared it to the original.expectedAttestationHashto capture approval metadata.expectedAttestationHash=sha256:not-currentto prove fail-closed behavior.Evidence before fix: Upstream/main has no policy check/watch/diff CLI layer, no runtime
expectedAttestationHashenforcement, no policy approval metadata view, no audit hash tuple, no watch/diff stale-attestation result, and no fail-closed runtime block for stale accepted attestations.Evidence after fix:
Observed result after fix: PR #81104 emits policy, evidence, findings, and attestation hashes; keeps the attestation stable when only
checkedAtchanges; reports no diff for timestamp-only changes; reportsevidenceandattestationdrift when evidence changes; marks a mismatched accepted attestation asstale; includes Policy Hash, Workspace Hash, Attestation Hash, Expected Attestation, and Policy Target approval metadata; and blocks runtime tool calls when the current attestation no longer matches the accepted one.What was not tested: This proof focuses on the runtime audit/attestation contract and does not exercise every policy category already covered by earlier stack PRs.
Testing
Latest local result:
Related
Doctor: add health-check contract and --lint validation #80055
Policy: add conformance system with channel checks #80407
Policy: add tool metadata conformance #80056
Policy: add model, network, and MCP conformance checks #80783
Policy stack links
This PR is part of the Policy 1.0 proof stack. Final category branches added after the runtime-audit layer:
Full stack reference: