Skip to content

Commit ccbfa6c

Browse files
authored
feat(ui): explain decision receipts in Activity (#126007)
* fix(audit): project safe decision receipt displays * docs(agents): preserve audit display privacy * fix(ci): satisfy audit receipt guardrails
1 parent ee79b0a commit ccbfa6c

37 files changed

Lines changed: 2965 additions & 825 deletions

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ Review invariants; full doctrine: `docs/gateway/audit.md`.
154154
- Invoker evidence is tri-state: tagged principal-bearing input is `present`, tagged principal-less input is `unknown`, and omission alone is `absent`. Validate the closed raw variant before projection or field dropping; reject malformed, mixed, untagged, or extra-field input instead of normalizing it to `unknown` or absence.
155155
- Each outer admitted turn owns one immutable `executionId` and `contextId`; `runId` is non-unique correlation. Retries, fallbacks, and recovery reuse the original admission identity. Only byte-identical canonical replay is idempotent.
156156
- Decision receipts adapt owner-native durable decisions; `execution_decision_facts` is only for boundaries without an owner-native record, never duplicates approvals, and stays dormant until an explicit product-boundary producer with an operator retention opt-in exists — the 30-day retention bound does not authorize default collection. Receipt coverage `enforced` is diagnostic, not authority: emit it only when the owner changed the outcome and the exact context/execution/run tuple validates; otherwise `unknown`.
157+
- `audit.run.inspect` exposes only the Gateway-owned `decisionDisplays` allowlist; display trust comes from owner-held call-path provenance, never receipt-controlled `source.owner` or prose. Pair every selected owner row or event with a required opaque selector from the same query or page result; never derive or requery selectors from private receipt, resolution, or event identifiers, or drop corrupt, oversized, or unlinked outcomes.
157158
- Admission may only validate, bound, freeze, and enqueue through the shared audit writer. Admission validates only a recursively owned, enumerable, accessor-free data snapshot constructed from descriptors before schema checks or ordinary property reads; inherited properties are absent and accessors never run. No synchronous SQLite, schema, filesystem, HMAC-key, or readiness work. Audit failure never delays or aborts execution.
158159
- Raw identity references are transient worker-message data. Never persist, export, inspect, or log them. Public Plugin SDK ingress must strip private recovery/admission authority, including JavaScript extra and inherited properties.
159160
- Channel participant evidence is host-minted only from an exact active registered native-plugin resolver result and redeemed once against the finalized context plus plugin record/lifecycle epoch. Missing, copied, substituted, replayed, stale, scope-changed, or mixed evidence becomes `unknown`. Mixed participants may remove sender-derived authority only; never widen or erase independent tools, grants, routing, or approval authority.

‎apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift‎

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11027,6 +11027,52 @@ public struct DecisionReceiptV1: Codable, Sendable {
1102711027
}
1102811028
}
1102911029

11030+
public struct DecisionReceiptDisplayV1: Codable, Sendable {
11031+
public let schemaversion: Double
11032+
public let selectorid: String
11033+
public let occurredat: Int
11034+
public let action: [String: AnyCodable]
11035+
public let decision: [String: AnyCodable]
11036+
public let enforcement: [String: AnyCodable]
11037+
public let provenance: AnyCodable
11038+
public let missingevidence: [String]
11039+
public let remediation: [[String: AnyCodable]]
11040+
11041+
public init(
11042+
schemaversion: Double,
11043+
selectorid: String,
11044+
occurredat: Int,
11045+
action: [String: AnyCodable],
11046+
decision: [String: AnyCodable],
11047+
enforcement: [String: AnyCodable],
11048+
provenance: AnyCodable,
11049+
missingevidence: [String],
11050+
remediation: [[String: AnyCodable]])
11051+
{
11052+
self.schemaversion = schemaversion
11053+
self.selectorid = selectorid
11054+
self.occurredat = occurredat
11055+
self.action = action
11056+
self.decision = decision
11057+
self.enforcement = enforcement
11058+
self.provenance = provenance
11059+
self.missingevidence = missingevidence
11060+
self.remediation = remediation
11061+
}
11062+
11063+
private enum CodingKeys: String, CodingKey {
11064+
case schemaversion = "schemaVersion"
11065+
case selectorid = "selectorId"
11066+
case occurredat = "occurredAt"
11067+
case action
11068+
case decision
11069+
case enforcement
11070+
case provenance
11071+
case missingevidence = "missingEvidence"
11072+
case remediation
11073+
}
11074+
}
11075+
1103011076
public struct AuditRunIdentityPresentV1: Codable, Sendable {
1103111077
public let state: String
1103211078
public let context: ExecutionIdentityContextV1
@@ -11165,7 +11211,7 @@ public struct AuditRunInspectResult: Codable, Sendable {
1116511211
public let schemaversion: Double
1116611212
public let run: [String: AnyCodable]
1116711213
public let identity: AuditRunIdentityV1
11168-
public let decisions: [DecisionReceiptV1]
11214+
public let decisiondisplays: [DecisionReceiptDisplayV1]
1116911215
public let coverage: [String: AnyCodable]
1117011216
public let nextdecisioncursor: String?
1117111217
public let nextexecutioncursor: String?
@@ -11174,15 +11220,15 @@ public struct AuditRunInspectResult: Codable, Sendable {
1117411220
schemaversion: Double,
1117511221
run: [String: AnyCodable],
1117611222
identity: AuditRunIdentityV1,
11177-
decisions: [DecisionReceiptV1],
11223+
decisiondisplays: [DecisionReceiptDisplayV1],
1117811224
coverage: [String: AnyCodable],
1117911225
nextdecisioncursor: String? = nil,
1118011226
nextexecutioncursor: String? = nil)
1118111227
{
1118211228
self.schemaversion = schemaversion
1118311229
self.run = run
1118411230
self.identity = identity
11185-
self.decisions = decisions
11231+
self.decisiondisplays = decisiondisplays
1118611232
self.coverage = coverage
1118711233
self.nextdecisioncursor = nextdecisioncursor
1118811234
self.nextexecutioncursor = nextexecutioncursor
@@ -11192,7 +11238,7 @@ public struct AuditRunInspectResult: Codable, Sendable {
1119211238
case schemaversion = "schemaVersion"
1119311239
case run
1119411240
case identity
11195-
case decisions
11241+
case decisiondisplays = "decisionDisplays"
1119611242
case coverage
1119711243
case nextdecisioncursor = "nextDecisionCursor"
1119811244
case nextexecutioncursor = "nextExecutionCursor"

‎docs/cli/audit.md‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,15 @@ valid host-bound evidence; it never means allowed. `unsupported` is reserved
152152
for a named path with no authoritative Phase 0 integration. A plugin-provided
153153
sender or structurally copied resolver result cannot upgrade either state.
154154

155-
A terminal approval receipt shows `allowed` or `denied`, its stable reason
156-
code, enforcement state, authoritative source boundary, policy and grant
157-
references, context fields used, and remediation. Expired and cancelled
155+
A terminal approval display shows `allowed` or `denied`, its stable reason
156+
code, enforcement state, verified producer class, policy and grant counts,
157+
context fields used, and remediation. Expired and cancelled
158158
approvals are denied non-actions with distinct reason codes. `no-route` is an
159159
enforced denial only when the approval owner recorded that terminal state. A
160-
corrupt approval is `unknown`. The text view labels `operator_approvals` as an
161-
authoritative owner-native SQLite record retained for 30 days; JSON preserves
162-
the same source owner and record reference without lossy reformatting.
160+
corrupt approval is `unknown`. The text view labels a verified
161+
operator-approval producer as an authoritative owner-native SQLite record
162+
retained for 30 days. Neither text nor JSON exposes the raw source owner, record
163+
reference, policy reference, or grant reference.
163164
`enforced` requires the approval's immutable owner-local binding to match the
164165
selected context, execution, and run exactly. A missing, malformed, or
165166
mismatched binding reports `operator_approval_execution_link_missing`,
@@ -192,8 +193,9 @@ their exact tuple was recorded and the gate changed the outcome.
192193
Portable actions and early suppressions that have no durable delivery record
193194
use the generic decision-fact owner instead of duplicating delivery state.
194195

195-
JSON output is the Gateway result without lossy reformatting. An exact result contains one
196-
bounded V1 context (maximum 16 KiB), up to 100 decision receipts, coverage and
196+
JSON output is the Gateway's safe-only result without lossy reformatting. An
197+
exact result contains one bounded V1 context (maximum 16 KiB), up to 100
198+
`decisionDisplays`, coverage and
197199
missing-evidence codes, and an optional `nextDecisionCursor`. An ambiguous run
198200
result instead contains at most 50 execution candidates and an optional
199201
`nextExecutionCursor`. Sensitive domain,
@@ -303,18 +305,25 @@ openclaw gateway call audit.run.inspect \
303305
--params '{"executionId":"5da4c4c3-e1c9-4c95-a17d-6e5c10fd45cf","decisionLimit":50}'
304306
```
305307

306-
Its result is `{ "schemaVersion": 1, "run": ..., "identity": ..., "decisions":
307-
..., "coverage": ..., "nextDecisionCursor"?: ..., "nextExecutionCursor"?: ... }`.
308+
Its result is `{ "schemaVersion": 1, "run": ..., "identity": ...,
309+
"decisionDisplays": ..., "coverage": ..., "nextDecisionCursor"?: ...,
310+
"nextExecutionCursor"?: ... }`. The required `decisionDisplays` array is the
311+
only receipt presentation field. Raw owner receipts and a `decisions` key never
312+
cross the Gateway boundary.
308313
The closed request accepts exactly one of `executionId` or `runId`.
309314
`decisionLimit` is 1–100 and `decisionCursor` is optional. Run discovery also
310315
accepts `executionLimit` from 1–50 and an optional `executionCursor`. A run
311316
with multiple retained executions returns the typed `ambiguous` identity state
312-
and no identity context or decisions until the caller selects an execution id.
317+
and no identity context; its required `decisionDisplays` array is empty until
318+
the caller selects an execution id.
313319
For one selected context, receipt paging starts with admission, then reads
314320
owner-native terminal approvals, merges outbound progress and terminal records,
315321
and finally reads generic facts for boundaries without a native durable record.
316322
The merge is deterministic across restart and rejects a cursor whose exact
317-
owner row has expired.
323+
owner row has expired. Approval and message selectors use the opaque
324+
`approval-decision:` and `message-decision:` namespaces minted from the same
325+
owner-query snapshot; raw receipt, resolution, and event identifiers never
326+
become selectors.
318327
Approval and delivery inspection never write generic duplicates. Generic fact
319328
writes and projections also require the full context, execution, and run tuple
320329
to match the immutable execution context.

‎docs/gateway/audit.md‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,16 @@ facts:
235235
authorization.
236236

237237
The method requires `operator.read`. Requests are closed and select exactly one
238-
`executionId` or `runId`. Decision pages contain at most 100 receipts;
238+
`executionId` or `runId`. The public result always contains a required
239+
`decisionDisplays` array and never contains the private raw receipt array or a
240+
`decisions` key. The Gateway builds that result from an explicit safe-field
241+
allowlist; clients do not classify receipt prose. Decision pages contain at
242+
most 100 displays;
239243
ambiguous run-discovery pages contain at most 50 candidate executions. Both use
240-
bounded cursors.
244+
bounded cursors. Approval and message-delivery selectors are minted from the
245+
same owner-query row metadata as their projected receipts, use the
246+
`approval-decision:` and `message-decision:` namespaces, and never derive from
247+
receipt, resolution, or event identifiers.
241248

242249
Every client with `operator.read` in the same Gateway operator domain may
243250
receive this retained identity category. This is intentional: the scope already
@@ -437,9 +444,11 @@ correlation alone.
437444
[Gateway protocol](/gateway/protocol#audit-ledger-rpc).
438445
- Identity RPC: `audit.run.inspect` (requires `operator.read`) accepts one
439446
`executionId` for exact inspection or one `runId` for bounded discovery. It
440-
returns the immutable V1 context plus paged admission, approval,
441-
owner-native outbound message, and generic decision receipts for an exact
442-
match, or a typed ambiguous candidate page when a run has multiple executions.
447+
returns the immutable V1 context plus paged safe displays for admission,
448+
approval, owner-native outbound message, and generic decision records for an
449+
exact match, or a typed ambiguous candidate page with an empty display array
450+
when a run has multiple executions. Raw owner receipts remain private to the
451+
aggregation and storage owners.
443452

444453
## Related
445454

‎docs/web/control-ui.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,17 @@ The Activity tab lives in **Settings › System**, next to Logs and Debug. It ha
409409

410410
- **Sessions** shows recent session activity grouped by day, with search, time, and people filters. Active rows offer **Inspect run** when the Gateway has recorded a run reference.
411411
- **Live activity** is the existing ephemeral browser-local observer for tool activity. It is derived from the same Gateway `session.tool` and tool event stream that powers Chat tool cards. It does not add another Gateway event family, endpoint, durable activity store, metrics feed, or external observer stream.
412-
- **Run inspector** is deep-link only and reads the Gateway's durable, immutable `audit.run.inspect` projection. Use **Inspect run** on an active session or the run ID link in Live activity, or open `/activity?view=run&run=<percent-encoded-run-id>` directly. Reloading or revisiting the link queries the Gateway again; it never reconstructs identity from Live activity.
412+
- **Run inspector** is deep-link only and reads the Gateway's durable, immutable `audit.run.inspect` safe-only projection. The RPC contains required `decisionDisplays` and never a raw `decisions` field. Use **Inspect run** on an active session or the run ID link in Live activity, or open `/activity?view=run&run=<percent-encoded-run-id>` directly. Reloading or revisiting the link queries the Gateway again; it never reconstructs identity from Live activity.
413413

414414
Live activity entries keep only sanitized summaries and redacted, truncated output previews. Tool argument values are not stored in Activity state; the UI shows that arguments are hidden and records only the argument field count. The in-memory list follows the current browser tab, survives navigation within the Control UI, and resets on page reload, session switch, Gateway switch, or **Clear**.
415415

416-
The Run inspector shows the retained trust domain, ingress, invoker, represented subject, sponsor, agent definition and principal, runtime instance, applicable grants, assurance evidence, lineage, and a bounded decision-receipt page summary. Every fact has a text evidence state. **Absent** means the owning boundary explicitly recorded no value; **unattributed** means a supported path had no usable invoker; **unknown** means expected evidence is missing or unreadable; and **unsupported** means the path has no Phase 0 evidence contract. Color is supplemental only.
416+
The Run inspector shows the retained trust domain, ingress, invoker, represented subject, sponsor, agent definition and principal, runtime instance, applicable grants, assurance evidence, lineage, and a bounded decision-receipt list. Every fact has a text evidence state. **Absent** means the owning boundary explicitly recorded no value; **unattributed** means a supported path had no usable invoker; **unknown** means expected evidence is missing or unreadable; and **unsupported** means the path has no Phase 0 evidence contract. Color is supplemental only.
417+
418+
Select a receipt to see the Gateway's bounded safe-display projection: structural action and outcome fields, evidence limits, and verified display provenance. Fixed core summaries and next steps appear only when the Gateway knows the producer contract from the owning call path. Generic or otherwise unverified receipts show a structural `unknown` classification and omit their summary, remediation, and self-asserted owner metadata. Activity consumes the safe result directly: it performs no UI-side inference, post-receive stripping, or raw-receipt fallback. **Enforced** means the recorded owner changed the outcome after validating the exact context, execution, and run tuple. **Attribution only** records what happened without claiming authorization. **Unsupported** means that observation has no Phase 0 enforcement contract. The inspector displays these states as text badges as well as color and never infers a reason from another field.
419+
420+
Receipt requests are limited to 50 records. **Load more receipts** follows the Gateway's opaque cursor and keeps earlier pages visible. A later-page error does not discard receipts already shown. Each receipt link adds `receipt=<opaque-display-selector>` and, for a later page, `decision=<opaque-cursor>` to the selected run or execution URL. The Gateway-owned selector chooses the projected display row without exposing the stored receipt identifier in the URL or as page text. Reloading that link requests the same bounded page and selects the same projected row. An expired or invalid page cursor is an explicit inspection error; choose **Restart inspection** to keep the selected run or execution and restart from the first page.
421+
422+
Approval and message-delivery links use the `approval-decision:` and `message-decision:` selector namespaces. The owner query mints each selector from its row metadata in the same snapshot as the displayed receipt; private receipt, resolution, and event identifiers never become URL parameters.
417423

418424
Run inspection requires `operator.read` and a Gateway that advertises `audit.run.inspect`. Execution identity collection is off by default; enable `logging.audit.executionIdentity`, restart the Gateway, and record a new run when you need this evidence. Retained contexts are limited to 30 days and 100,000 rows. A known run can therefore report unavailable or expired identity evidence, and a run reference can be ambiguous when it correlates more than one execution. The UI does not guess between executions: choose a returned candidate to navigate to `/activity?view=run&execution=<percent-encoded-execution-id>` and query that exact execution.
419425

‎packages/gateway-protocol/src/public-schema.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ export {
309309
AuditActivityToolActionV1Schema,
310310
ExecutionIdentityContextV1Schema,
311311
DecisionReceiptV1Schema,
312+
DecisionReceiptDisplayV1Schema,
312313
AuditRunIdentityPresentV1Schema,
313314
AuditRunIdentityUnknownV1Schema,
314315
AuditRunIdentityUnsupportedV1Schema,

0 commit comments

Comments
 (0)