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. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. for the review findings: the PR diff and current main source show the stale secret-file expectation and the runtime 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 findings
Review detailsBest possible solution: Refresh on latest main, preserve fail-closed credential and malformed-policy behavior, then land the runtime audit layer only after maintainers accept the trusted-config attestation semantics. Do we have a high-confidence way to reproduce the issue? Yes for the review findings: the PR diff and current main source show the stale secret-file expectation and the runtime Is this the best way to solve the issue? No, not yet: the runtime audit direction is plausible and well-proved, but the branch must preserve fail-closed security contracts and align runtime policy shape validation with current doctor validation. Label justifications:
Full review comments:
Overall correctness: patch is incorrect Security concerns:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 79be9401306f. |
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
5bdc799 to
5903758
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
|
Restacked this runtime-audit PR on the refreshed policy stack through #80783 and pushed Cleanup included:
Verification: node --import tsx scripts/protocol-gen.ts && node --import tsx scripts/protocol-gen-swift.ts && node scripts/run-vitest.mjs extensions/policy/src/runtime-tool-policy.test.ts extensions/policy/src/doctor/register.test.ts extensions/policy/src/cli.test.ts src/infra/approval-view-model.test.ts src/gateway/server-methods/plugin-approval.test.ts src/flows/bundled-health-checks.test.ts --reporter=dot
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test-policy-81104-restack.tsbuildinfo && node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test-policy-81104-restack.tsbuildinfo && git diff --checkObserved locally:
CI has restarted on the new SHA; the PR is still draft and currently mergeable with pending checks. |
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 <223556219+Copilot@users.noreply.github.com>
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: