# Receipt Schema

Every action enforced by Nobulex produces a signed receipt. The receipt is the proof artifact. It contains everything needed for independent verification without access to the originating system.

## Full Receipt Fields

Field | Type | Description
--- | --- | ---
`receipt_id` | string | Unique identifier for this receipt
`index` | number | Position in the hash chain (sequential)
`timestamp` | ISO 8601 | When enforcement was evaluated
`agent_did` | string | W3C DID of the agent that performed the action

## Action Object

The `action` field contains the full payload of what the agent attempted. This is what hanselhansel asked about: tool inputs are included, not just tool names.

Field | Type | Description
--- | --- | ---
`action.tool` | string | Name of the tool or action invoked
`action.arguments` | object | Full arguments passed to the tool (query, amount, patient_id, etc.)
`action.result` | string | "executed" if allowed, "blocked" if denied

Example: `"called search_tool with query='cancel order 8821' and got back confirmation #4419"` is captured in the action object, hashed into the outcome_hash, and signed.

## Enforcement Object

Field | Type | Description
--- | --- | ---
`enforcement.decision` | string | "ALLOW" or "DENY"
`enforcement.matched_rule` | string | The specific covenant rule that was evaluated
`enforcement.evaluated_at` | ISO 8601 | When the rule was evaluated

## Covenant in Effect

The receipt carries the covenant that was active at the time of enforcement. This means you can answer two questions from a single artifact: "what was the agent allowed to do" and "what did it actually do."

## Hash Chain Fields

Field | Type | Description
--- | --- | ---
`outcome_hash` | hex string | SHA-256 hash of the full action payload (tool, arguments, result, timestamp)
`previous_hash` | hex string | Chain hash from the previous receipt (or zeros for the first)
`chain_hash` | hex string | SHA-256 of previous_hash + outcome_hash. Links this receipt to the chain.
`signature` | string | Ed25519 signature over the entire receipt. Verifiable with the agent's public key.
`verifiable` | boolean | Always true. Indicates the receipt can be verified independently.

## Verification

Any third party can verify a receipt by:

    1. Recomputing outcome_hash from the action payload
    2. Checking chain_hash == SHA-256(previous_hash + outcome_hash)
    3. Verifying the Ed25519 signature against the agent's public key
    4. Walking the chain to verify integrity from receipt #1 to #N

No access to the originating system is required. The receipt is self-contained.

## Example Receipt

    {
      "receipt_id": "rx_k8m2q1a7",
      "index": 3,
      "timestamp": "2026-04-18T20:15:33.421Z",
      "agent_did": "did:nobulex:agent-a1b2c3",
      "action": {
        "tool": "search_tool",
        "arguments": { "query": "cancel order 8821" },
        "result": "executed"
      },
      "covenant_in_effect": "permit search_tool; forbid delete; require audit_all",
      "enforcement": {
        "decision": "ALLOW",
        "matched_rule": "permit search_tool",
        "evaluated_at": "2026-04-18T20:15:33.421Z"
      },
      "outcome_hash": "a3f8c1d4e5b6...64 hex chars",
      "previous_hash": "7b2e9f1a4c8d...64 hex chars",
      "chain_hash": "d9e2f3a1b5c7...64 hex chars",
      "signature": "ed25519:a1b2c3d4e5f6...",
      "verifiable": true
    }