interplane.Get Omega
Read in your language

spark-rsi-mv

Native Rust recursive self-improvement engine with paired bootstrap evaluation and cryptographic ledger

Brought by drakestapleton

branch main Branches Tags History

spark-rsi-mv / docs / RECEIPT-V2.md

123 lines · 8753 bytes Raw Blame History Rendered
1# Evaluation receipt, version 2
2
3A version 2 receipt is the judge's signed statement that one exact change was evaluated against
4one exact holdout set under one exact policy by one exact judge binary, with the results it
5records. The invariant it serves:
6
7> No code change may be promoted unless its exact identity matches the identity covered by a
8> valid, independently signed evaluation.
9
10Approved by the operator on 2026-10-08 (VAC mission, M5 Option 1).
11
12## Fields
13
14The receipt keeps every version 1 field and adds:
15
16| Field | Meaning |
17|---|---|
18| `format_version` | `2`. Absent in old records, which load as `1`. |
19| `binding.subject_path` | The one file the change touches, relative to the tree root. |
20| `binding.subject_sha256` | SHA-256 of the exact bytes of that file as evaluated. |
21| `binding.holdout_set_sha256` | Digest of the whole holdout directory (below). |
22| `binding.holdouts_total` / `holdouts_passed` | Holdout counts from this run. |
23| `binding.policy_sha256` | SHA-256 of the exact policy file bytes. |
24| `binding.evaluator_binary_sha256` | SHA-256 of the running judge executable (the evaluator, not the candidate program). |
25
26## Digest
27
28`receipt_digest` is the lowercase hex SHA-256 of a sequence of fields. Each field is written as
29its length in bytes (u64, little-endian) followed by the bytes. Strings are UTF-8, numbers are
30little-endian, flags are one byte (0 or 1), floats are their IEEE-754 bit pattern as a u64.
31
321. the string `spark-rsi.evaluation-receipt.v2`
332. `cycle_id`, `candidate_id`, `parent_id`, `evaluated_at`, `evaluator_version`
343. `binding.evaluator_binary_sha256`, `binding.subject_path`, `binding.subject_sha256`,
35 `binding.holdout_set_sha256`, `binding.policy_sha256` (as their hex strings)
364. `binding.holdouts_total`, `binding.holdouts_passed` (u64)
375. flags `admitted`, `passed_all_hard_invariants`, `passed_statistical_gates`
386. the number of layers (u64), then for each layer in order: `layer_name`, flag
39 `is_hard_invariant`, flag `passed`, `score` (f64 bits), `summary`, the number of
40 `violations` (u64), then each violation string
417. `metrics_summary`: one byte 0 if absent; otherwise one byte 1, then `latency_delta_pct`,
42 `p_value`, `p95_ci_upper_degradation_pct`, `p99_ci_upper_degradation_pct`,
43 `rss_growth_pct` (f64 bits) and `candidate_resident_mb` (u64)
44
45Every field of the receipt except `receipt_digest` and `signature` is covered. The domain string
46binds the format, so a version 2 digest cannot be read as version 1.
47
48## Signature
49
50`signature` is `tpm2-p256:` followed by the hex of a 64-byte P-256 ECDSA signature (r||s) over
51the 32 raw digest bytes, the same scheme as version 1. The judge's public key is distributed out
52of band as an uncompressed SEC1 point in hex (`spark-rsi-judge --public-key`). A receipt never
53carries the key that verifies it.
54
55## Holdout set digest
56
57The judge loads the holdout directory strictly. It fails closed when the directory is missing or
58empty, when an entry is anything other than a regular `.json` file (subdirectories, symlinks and
59stray files are refused), when a file does not parse, when a suite has no cases, when a case has
60an empty `id` or `expected_output`, or when two cases share an `id`. Nothing is skipped.
61
62The digest is SHA-256 over length-prefixed fields: the string `spark-rsi.holdout-set.v1`, the
63number of files (u64), then for each file sorted by name: the file name, then the 32 raw bytes of
64SHA-256 of the file contents.
65
66## Policy
67
68The operator's policy file (JSON, unknown fields refused):
69
70```json
71{
72 "policy_id": "vac-m5",
73 "holdout_set_sha256": "<64 hex>",
74 "min_holdout_pass_ratio": 1.0,
75 "require_admitted": true,
76 "allowed_targets": ["README.md"],
77 "protected_paths": ["holdouts", "policy"]
78}
79```
80
81`require_admitted` must be `true`; `min_holdout_pass_ratio` must be in (0, 1]; `allowed_targets` must name at least one file; every path in `allowed_targets` and `protected_paths` must be a clean relative path (no `.`, `..`, empty or leading `/` component), because paths are compared as strings. A ratio below 1 is recorded faithfully, but each failed holdout also fails the replay layer, so in practice any failed holdout keeps the change from being admitted. An optional
82`non_inferiority_margin_pct` sets the latency margin for this evaluation; being part of the policy
83bytes, it is covered by the signed `policy_sha256`.
84
85Before running any candidate code the judge refuses when the holdout directory does not hash to
86the policy's `holdout_set_sha256`, when the subject is not a clean relative path, is not in
87`allowed_targets` or lies under a `protected_paths` entry, or when the candidate tree differs from
88the parent tree in anything other than the subject file. That comparison includes dotfiles and
89skips only `.git` and the top-level `target` directory; symlinks and special files are refused.
90The program that runs the holdouts must come from the compared trees: a version 2 evaluation names its executable (`--executable`, never searched for), and either the judge builds both trees itself (`--build-release`) or the executable is a clean relative path outside `.git` and `target`, which the comparison skips. Only the root `.git` and `target` are skipped; a nested `.git` entry is refused.
91
92Everything the judge does with candidate source runs in one bubblewrap sandbox (`isolation::sandboxed_cargo`): the release build (`--build-release`) and the correctness layer's `cargo check` and `cargo test`. The sandbox has no network and a cleared environment, the tree read-only, only a fresh target directory writable, the toolchain read-only, and nothing of the judge's home (where its key lives). Build scripts, proc macros, `include_bytes!` and the candidate's own tests run or read only inside it, and all cargo runs are `--offline --locked`, so a tree without its `Cargo.lock` fails. There is no unsandboxed fallback. The holdouts run the built binary in the existing candidate jail, which also clears the environment and never retries without its network namespace (the jailed program writes its own error output, so an error-string fallback would let it ask for the network). The correctness layer passes only when `cargo test` itself exits successfully; the parsed counts describe, they do not decide.
93
94`parent_id` is the identity the caller passes (`--parent-id`, the commit the parent tree was checked out from); the judge signs it but does not derive it from the parent tree. The promotion gate and the INTERPLANE verifier (against the bundle's `source_pin.commit`) refuse a receipt whose parent is not the one the change applies on.
95
96After the run the judge re-hashes the subject and refuses to sign if it changed. A run below the
97pass ratio is recorded as not admitted.
98
99## Promotion
100
101Promotion (`EvaluationReceipt::verify_for_promotion`, `promotion_gate::check_v2_promotion`)
102requires all of:
103
104- `format_version == 2` with a binding; version 1 receipts stay verifiable for history with
105 `verify_signature` but are never sufficient for a new promotion;
106- a valid signature under the operator-pinned judge key, which must differ from the promoter's
107 own key;
108- `parent_id` equal to the parent the caller applies the change on;
109- `subject_path` equal to the file the change replaces, and `subject_sha256` equal both to the digest of the change's bytes and to the digest of that file read back from the generation being promoted, right before the swap;
110- `policy_sha256` equal to the digest of the operator's policy file as it is now, and
111 `holdout_set_sha256` equal to the digest that policy pins;
112- `admitted`, the subject listed in the policy's `allowed_targets`, and
113 `holdouts_passed >= min_holdout_pass_ratio * holdouts_total` with a non-zero total.
114
115The daemon checks this right before its symlink swap and fails closed when
116`judge_public_key_hex` or `judge_policy_file` is not configured. The daemon's own cycle produces only a version 1 receipt from its in-process judge, so until an externally judged version 2 receipt is supplied to it, self-promotion by the spark-rsi daemon is refused every time. (The daemon's parent is the label it hands its own judge, and it re-reads only the subject file of the staged generation; the judge's strict tree comparison is what rules out other changed files.) That is the intended direction: promotion of an RSI change goes through the operator's approved path (the INTERPLANE M5 slice), not through the proposer's own daemon.
117
118## Key separation
119
120The judge's private key lives only in the judge account's home (`/var/lib/aien-judge`, mode
121700). The proposing agent runs as a different account with no sudo and cannot read it. The
122operator account can still read it through sudo; that is the operator's authority, not the
123agent's.