|
| 1 | +# Vaara Audit Event Schema, v1.0 |
| 2 | + |
| 3 | +Versioned wire/storage contract for the audit events that flow through |
| 4 | +the Vaara execution layer. This document is the schema; the |
| 5 | +implementation in `src/vaara/audit/trail.py` is one conforming emitter. |
| 6 | +The schema is versioned independently of the Vaara Python package so |
| 7 | +downstream consumers (compliance combiners, regulatory exports, |
| 8 | +third-party verifiers) can pin to a schema version without coupling to |
| 9 | +a runtime version. |
| 10 | + |
| 11 | +## Status and scope |
| 12 | + |
| 13 | +- Schema version: **1.0** |
| 14 | +- Status: stable |
| 15 | +- Applies to: events appended to `trail.jsonl` and to the JSON shape |
| 16 | + returned by the audit HTTP API. |
| 17 | +- Out of scope: the combiner that assembles per-Article evidence |
| 18 | + reports, the signer that wraps an exported trail, the verifier that |
| 19 | + walks the hash chain. Those consume conforming events and have their |
| 20 | + own contracts. |
| 21 | + |
| 22 | +A conforming emitter MUST produce events that satisfy the field |
| 23 | +requirements below. A conforming consumer MUST tolerate optional |
| 24 | +fields and unknown additive fields under the rules in |
| 25 | +[§ Forward compatibility](#forward-compatibility). |
| 26 | + |
| 27 | +## Event envelope |
| 28 | + |
| 29 | +Every audit event is a JSON object with the following fields. |
| 30 | + |
| 31 | +| Field | Type | Required | Description | |
| 32 | +|---|---|---|---| |
| 33 | +| `record_id` | UUIDv4 string | yes | Identifier unique to this single event. | |
| 34 | +| `action_id` | UUIDv4 string | yes | Groups every event that belongs to one action lifecycle (request, score, decision, execute/block, outcome). | |
| 35 | +| `event_type` | string enum | yes | Lifecycle stage. Closed set in [§ Event types](#event-types). | |
| 36 | +| `timestamp` | number | yes | Unix epoch seconds (UTC), IEEE-754 double. Finite (no NaN, no ±∞). | |
| 37 | +| `agent_id` | string | yes | Identity of the agent that submitted the action. Free-form, ≤ 256 bytes. | |
| 38 | +| `tool_name` | string | yes | Name of the tool or action under interception. ≤ 512 bytes. | |
| 39 | +| `data` | object | no | Event-specific payload. Schema by `event_type`, see [§ Data payloads](#data-payloads). Default `{}`. | |
| 40 | +| `regulatory_articles` | array of objects | no | Regulatory provenance of this event. See [§ Regulatory article objects](#regulatory-article-objects). Default `[]`. | |
| 41 | +| `previous_hash` | hex string | yes | SHA-256 of the predecessor record's `record_hash`. Empty string for the first record. | |
| 42 | +| `record_hash` | hex string | yes | SHA-256 over the canonical encoding of the hashed-fields subset of this record. See [§ Hash chain](#hash-chain). | |
| 43 | +| `system_operation` | string | no | prEN ISO/IEC 12792 transparency axis: how the AI system operated at this event. Metadata, not hashed. | |
| 44 | +| `data_usage` | string | no | prEN ISO/IEC 12792 transparency axis: what data was consumed. Metadata, not hashed. | |
| 45 | +| `decision_making` | string | no | prEN ISO/IEC 12792 transparency axis: how the conclusion was reached. Metadata, not hashed. | |
| 46 | +| `limitations` | string | no | prEN ISO/IEC 12792 transparency axis: known constraints. Usually carried out-of-band. Metadata, not hashed. | |
| 47 | + |
| 48 | +## Event types |
| 49 | + |
| 50 | +`event_type` is a closed enum at schema 1.0. Additive values may |
| 51 | +appear in a minor version bump; see [§ Forward compatibility](#forward-compatibility). |
| 52 | + |
| 53 | +| Value | Lifecycle position | |
| 54 | +|---|---| |
| 55 | +| `action_requested` | Agent submitted an action; recorded before processing. | |
| 56 | +| `risk_scored` | Scorer produced a risk assessment with conformal prediction interval. | |
| 57 | +| `decision_made` | Allow / escalate / deny decided. | |
| 58 | +| `action_executed` | Action was actually executed downstream. | |
| 59 | +| `action_blocked` | Action was blocked before execution. | |
| 60 | +| `escalation_sent` | Action routed to human reviewer. | |
| 61 | +| `escalation_resolved` | Human reviewer responded. | |
| 62 | +| `outcome_recorded` | Post-execution outcome observed and recorded. | |
| 63 | +| `policy_override` | Manual override of a prior automated decision. | |
| 64 | + |
| 65 | +Each event for one action references a single shared `action_id`. The |
| 66 | +canonical lifecycle is `action_requested` → `risk_scored` → |
| 67 | +`decision_made` → (`action_executed` | `action_blocked` | |
| 68 | +`escalation_sent` → `escalation_resolved`) → `outcome_recorded`. |
| 69 | +`policy_override` may appear at any point after `decision_made`. |
| 70 | + |
| 71 | +## Hash chain |
| 72 | + |
| 73 | +The chain is SHA-256 over a canonical JSON encoding of a strict subset |
| 74 | +of the record. Encoding: `json.dumps(content, sort_keys=True, |
| 75 | +separators=(",", ":"), allow_nan=False)`. |
| 76 | + |
| 77 | +Fields included in `content`: `record_id`, `action_id`, `event_type` |
| 78 | +(as string), `timestamp`, `agent_id`, `tool_name`, `data`, |
| 79 | +`regulatory_articles`, `previous_hash`. |
| 80 | + |
| 81 | +Fields excluded: `system_operation`, `data_usage`, `decision_making`, |
| 82 | +`limitations`. Rationale: the four prEN ISO/IEC 12792 transparency |
| 83 | +annotations may evolve with the WG4 draft. Excluding them keeps |
| 84 | +records hash-stable under re-emission and avoids coupling chain |
| 85 | +integrity to a moving annotation schema. A future major schema may |
| 86 | +introduce a separate signed-bundle mechanism for transparency tagging. |
| 87 | + |
| 88 | +`previous_hash` of the first record is the empty string `""`. |
| 89 | +`record_hash` is computed at append time and stable across |
| 90 | +re-serialization. |
| 91 | + |
| 92 | +## Regulatory article objects |
| 93 | + |
| 94 | +`regulatory_articles` is an array of objects. Each object has: |
| 95 | + |
| 96 | +| Field | Type | Required | Description | |
| 97 | +|---|---|---|---| |
| 98 | +| `domain` | string | yes | Regulatory regime: `EU_AI_ACT`, `DORA`, `NIS2`, `MiFID_II`, `GDPR`. | |
| 99 | +| `article` | string | yes | Article reference, e.g. `Article 12(1)` or `Article 9(2)(a)`. | |
| 100 | +| `requirement` | string | yes | What the article requires. | |
| 101 | +| `how_satisfied` | string | yes | How this event satisfies the requirement. | |
| 102 | + |
| 103 | +The combiner uses `regulatory_articles` to assemble per-Article |
| 104 | +evidence reports. Including the regulatory provenance in the |
| 105 | +hash-covered fields means that tampering with article attribution |
| 106 | +after the fact breaks chain verification. |
| 107 | + |
| 108 | +## Data payloads |
| 109 | + |
| 110 | +`data` carries event-specific structured fields. The schema by |
| 111 | +`event_type` is non-exhaustive at 1.0 (consumers MUST accept unknown |
| 112 | +keys). Reserved top-level keys: |
| 113 | + |
| 114 | +- `action_requested`: `action_request` (object), `context` (object, optional). |
| 115 | +- `risk_scored`: `risk_score` (number in [0, 1]), `interval` (`[low, high]`), `classifier_version` (string), `contributing_signals` (array). |
| 116 | +- `decision_made`: `decision` (`allow` | `escalate` | `deny`), `threshold_set` (string), `verdict_inputs` (array). |
| 117 | +- `action_executed`: `executor` (string), `duration_ms` (number). |
| 118 | +- `action_blocked`: `reason` (string), `blocking_policy` (string). |
| 119 | +- `escalation_sent`: `reviewer_queue` (string), `priority` (string). |
| 120 | +- `escalation_resolved`: `reviewer_id` (string), `decision` (enum), `reason` (string). |
| 121 | +- `outcome_recorded`: `outcome` (`success` | `failure` | `partial` | `unknown`), `feedback` (object, optional). |
| 122 | +- `policy_override`: `overrider_id` (string), `prior_decision` (enum), `new_decision` (enum), `reason` (string). |
| 123 | + |
| 124 | +Caller-controlled strings in `data` (`agent_id`, `reason`, |
| 125 | +`override_reason`) MUST be treated as untrusted at narrative-rendering |
| 126 | +time. The hash chain still covers original values; the renderer |
| 127 | +sanitizes for display only. |
| 128 | + |
| 129 | +## Numeric and string discipline |
| 130 | + |
| 131 | +- `timestamp` is IEEE-754 double Unix epoch seconds, UTC. NaN, +∞, -∞ |
| 132 | + are rejected at the canonical-JSON boundary. |
| 133 | +- Strings are UTF-8. ≤ 256 bytes for `agent_id`, ≤ 512 bytes for |
| 134 | + `tool_name`. `record_id` and `action_id` are UUIDv4 in canonical form. |
| 135 | + |
| 136 | +## Wire and storage encodings |
| 137 | + |
| 138 | +JSONL on disk: one event per line, sorted keys, no trailing |
| 139 | +whitespace. The hash chain is computed and verified against this |
| 140 | +encoding. JSON over HTTP: the audit API returns events as JSON |
| 141 | +objects, optionally wrapped in a pagination envelope; the event |
| 142 | +object itself is byte-identical to the JSONL line modulo whitespace. |
| 143 | +Other encodings (CBOR, Protobuf) may be defined in sibling specs |
| 144 | +without bumping this version, provided they round-trip to the |
| 145 | +canonical JSON form. |
| 146 | + |
| 147 | +## Signing and export |
| 148 | + |
| 149 | +A trail is exported as a zip bundle: `trail.jsonl`, `manifest.json`, |
| 150 | +`trail.sig`, `signer_pubkey`. Signed message: |
| 151 | +`SHA-256(trail.jsonl || manifest.json)`. Reference signing algorithms: |
| 152 | +Ed25519 (default), ML-DSA-65 (FIPS 204). This schema does not |
| 153 | +constrain the signing algorithm beyond requiring that the export |
| 154 | +bundle carry the public key in a form the verifier can consume. |
| 155 | + |
| 156 | +## Forward compatibility |
| 157 | + |
| 158 | +- **Minor (1.x).** Additive only: new `event_type` values, new |
| 159 | + optional fields, new entries inside `data`. Consumers MUST tolerate |
| 160 | + unknown fields. |
| 161 | +- **Major (2.0+).** Breaking changes: field removal, renames, change |
| 162 | + of hash-input set, change of canonical encoding. Major bumps ship |
| 163 | + with a migration note and the prior schema remains a valid emission |
| 164 | + target for one release cycle. |
| 165 | + |
| 166 | +Producers SHOULD include a schema version tag in the export manifest. |
| 167 | +Events themselves do not carry a per-record schema field, since the |
| 168 | +chain integrity guarantee covers re-emission only under the same |
| 169 | +schema version. |
| 170 | + |
| 171 | +## Relation to OVERT 1.0 and SEP-2787 |
| 172 | + |
| 173 | +OVERT 1.0 Base Envelopes (`vaara.attestation.overt`) are per-action |
| 174 | +attestations encoded as deterministic CBOR. SEP-2787 v2 envelopes |
| 175 | +(`vaara.attestation.sep2787`) are per-tool-call JSON envelopes carried |
| 176 | +in MCP `_meta`. This audit-event schema is the full per-event |
| 177 | +lifecycle log. The three coexist: an OVERT or SEP-2787 envelope can |
| 178 | +back-link to the audit event that recorded the same action via |
| 179 | +`record_id`. See `docs/sep2787-overt-mapping.md` for the |
| 180 | +OVERT ↔ SEP-2787 field mapping. |
| 181 | + |
| 182 | +## Reference implementation |
| 183 | + |
| 184 | +- `src/vaara/audit/trail.py`, `signer.py`, `verify.py`, `export.py`. |
| 185 | +- `src/vaara/server/schemas.py` (pydantic HTTP wire models). |
| 186 | + |
| 187 | +The reference implementation pins this schema at version 1.0. A |
| 188 | +conforming third-party emitter or consumer may target this document |
| 189 | +without coupling to the Python implementation. |
0 commit comments