feat(proxy): optional evidence payload on POST /audit (#11)#72
Merged
Conversation
Lets a hook-based adapter populate evidence-grounding facts on its single adapter-scoped token, instead of the SDK-scoped POST /evidence — the remaining core change for the OpenClaw adapter (#11). - governance-service: add `evidence` to AuditInput and write it via EvidenceStore on a successful, first-finalize audit, bound to the pending evaluation's own session_id/tool_name (the adapter never supplies them). Every per-entry failure is soft (reported, never request-fatal): caps are enforced here as soft-drops — `too_many` (>16) / `too_large` (>64 KiB) — and the store's `key_not_in_policy_allowlist` / `closed`, plus `no_session` / `evidence_unavailable`, all still finalize 201. Critically, `closed` is NOT the 503 the standalone /evidence route returns — losing the audit row for a call that already ran would be worse than a dropped evidence entry. - governance-api: add `evidence` to the auditBody schema (no route-level `.max()`, so caps stay soft-drops) and fold it into auditPayloadHash, order-independent (sorted by the full canonical tuple) so an identical retry replays cleanly while divergent evidence is a 409 conflict. Success-only, first-finalize-only (idempotent replays never re-write). Tests cover every soft-drop reason, the closed!=503 asymmetry over HTTP, the gross-body 413, and order-independent idempotency.
- Add a "Populating evidence" section: array shape, success-only, first-finalize-only, per-entry soft-fail outcomes (and their reasons), and order-independent idempotency. - Rewrite the Authentication note that claimed "an adapter cannot write evidence" — it now describes the narrow, scoped capability the adapter gains via /audit (bound to its own session/tool, allowlist-enforced), without the SDK-scoped /evidence route. - Fix the summary-table /install-scan line that still read "observational" to reflect the deny_install enforcement shipped in #13.
1b78acb to
cd11a52
Compare
olivrg
added a commit
that referenced
this pull request
Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds an optional
evidencearray toPOST /auditso a hook-based adapter (OpenClaw, #11) can populateevidence-grounding facts on its single adapter-scoped token, instead of the SDK-scoped
POST /evidence. This is the one remaining Helio-core change the adapter depends on.governance-service:AuditInputgainsevidence; on a successful, first-finalize audit it writes each entry viaEvidenceStore, bound to the pending evaluation's ownsession_id/tool_name(the adapter never supplies them — it cannot target another session). Every per-entry failure is soft (reported, never request-fatal) and the audit still finalizes201: caps are enforced here as soft-drops —too_many(>16) /too_large(>64 KiB) — alongside the store'skey_not_in_policy_allowlist/closedandno_session/evidence_unavailable. Notablyclosedis not the503the standalone/evidenceroute returns — losing the audit row for a call that already ran would be worse than a dropped evidence entry.governance-api:evidenceadded to theauditBodyschema (no route-level.max(), so caps stay soft-drops) and folded intoauditPayloadHash, order-independent (sorted by the full canonical tuple) — an identical retry replays cleanly while divergent evidence is a409 evaluation_conflict.Success-only, first-finalize-only (idempotent replays never re-write). The
/auditendpoint stays adapter-token-scoped; non-evidence audits are byte-identical and the MCP path is untouched.Type of Change
Packages Affected
packages/proxypackages/dashboardpackages/python-sdkdocs/examples/Checklist
anytypes or@ts-ignorewithout justificationpnpm secrets:scan,pnpm docs:check:ci,pnpm audit --audit-level=high,pnpm build,pnpm lint,pnpm format:check,pnpm typecheck,pnpm test)feat:,fix:,docs:)How to Test
evidence.requiresrule for a key, thenPOST /evaluate→POST /auditwithstatus: "success"andevidence: [{ evidence_key, evidence_data }]; confirm the response returnsevidence: [{ evidence_key, stored: true }]and a later evidence-grounded/evaluatesees the stored fact.key_not_in_policy_allowlist/too_large/too_many) while the audit still returns201.POST /auditwith evidence; confirm201withreason: "closed"(never503). Replay the sameevaluation_idwith divergent evidence →409 evaluation_conflict; replay with identical evidence in any order →200 already_finalized.pnpm --filter @gethelio/proxy test— full suite (1592 tests) passes, including the newaudit evidencecases ingovernance-serviceand the route-level evidence cases ingovernance-api.Part of #11.
Additional Context