Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/spark-rsi-mv/blob/main/docs/RECEIPT-V2.md # spark-rsi-mv Native Rust recursive self-improvement engine with paired bootstrap evaluation and cryptographic ledger Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers 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 3 A version 2 receipt is the judge's signed statement that one exact change was evaluated against 4 one exact holdout set under one exact policy by one exact judge binary, with the results it 5 records. 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 10 Approved by the operator on 2026-10-08 (VAC mission, M5 Option 1). 11 12 ## Fields 13 14 The 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 29 its length in bytes (u64, little-endian) followed by the bytes. Strings are UTF-8, numbers are 30 little-endian, flags are one byte (0 or 1), floats are their IEEE-754 bit pattern as a u64. 31 32 1. the string `spark-rsi.evaluation-receipt.v2` 33 2. `cycle_id`, `candidate_id`, `parent_id`, `evaluated_at`, `evaluator_version` 34 3. `binding.evaluator_binary_sha256`, `binding.subject_path`, `binding.subject_sha256`, 35 `binding.holdout_set_sha256`, `binding.policy_sha256` (as their hex strings) 36 4. `binding.holdouts_total`, `binding.holdouts_passed` (u64) 37 5. flags `admitted`, `passed_all_hard_invariants`, `passed_statistical_gates` 38 6. 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 41 7. `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 45 Every field of the receipt except `receipt_digest` and `signature` is covered. The domain string 46 binds 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 51 the 32 raw digest bytes, the same scheme as version 1. The judge's public key is distributed out 52 of band as an uncompressed SEC1 point in hex (`spark-rsi-judge --public-key`). A receipt never 53 carries the key that verifies it. 54 55 ## Holdout set digest 56 57 The judge loads the holdout directory strictly. It fails closed when the directory is missing or 58 empty, when an entry is anything other than a regular `.json` file (subdirectories, symlinks and 59 stray files are refused), when a file does not parse, when a suite has no cases, when a case has 60 an empty `id` or `expected_output`, or when two cases share an `id`. Nothing is skipped. 61 62 The digest is SHA-256 over length-prefixed fields: the string `spark-rsi.holdout-set.v1`, the 63 number of files (u64), then for each file sorted by name: the file name, then the 32 raw bytes of 64 SHA-256 of the file contents. 65 66 ## Policy 67 68 The 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 83 bytes, it is covered by the signed `policy_sha256`. 84 85 Before running any candidate code the judge refuses when the holdout directory does not hash to 86 the 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 88 the parent tree in anything other than the subject file. That comparison includes dotfiles and 89 skips only `.git` and the top-level `target` directory; symlinks and special files are refused. 90 The 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 92 Everything 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 96 After the run the judge re-hashes the subject and refuses to sign if it changed. A run below the 97 pass ratio is recorded as not admitted. 98 99 ## Promotion 100 101 Promotion (`EvaluationReceipt::verify_for_promotion`, `promotion_gate::check_v2_promotion`) 102 requires 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 115 The 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 120 The judge's private key lives only in the judge account's home (`/var/lib/aien-judge`, mode 121 700). The proposing agent runs as a different account with no sudo and cannot read it. The 122 operator account can still read it through sudo; that is the operator's authority, not the 123 agent's.