interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / docs / plans / vac / M5-DESIGN.md

153 lines · 12951 bytes Raw Blame History Rendered
1# VAC M5: bounded RSI hookup, design note (IMPLEMENTED, 2026-10-08)
2
3Status: IMPLEMENTED 2026-10-08 (see "Outcome" at the end). The design text below is kept as written; where the build differs, the Outcome section wins. Original status line: PROPOSED, nothing implemented. Every claim about current code cites spark-rsi
4`origin/main` e5aab9a, interplane `origin/main` 04a05dc, or aien-protocols `origin/main`, read on
52026-10-08. Build work starts only after M4 (clean-clone reproducibility) is qualified, per the
6directive's Phase 5 rule.
7
8## Goal, one sentence
9
10spark-rsi proposes one Tier1 change to a pinned fixture repository; an evaluator it cannot control
11scores the change on a holdout it cannot read or write; the change lands only through the existing
12approved path (INTERPLANE -> ComposeApprovedProposal -> daemon ledger); the offline verifier refuses
13the bundle unless a signed evaluation receipt names the exact bytes the ledger says were written and
14the score meets a threshold fixed before the run.
15
16## What the code already gives me
17
18- **Proposal shape.** `ImprovementProposal` carries one `target_file` and a `proposed_patch`
19 (spark-rsi src/models.rs:37). That maps onto one `write_file` effect, the only effect kind the
20 daemon has.
21- **Branch-only ratifier.** The ratifier creates `rsi/<id>` plus a patch file and never commits to the
22 default branch (src/ratify.rs:14-20). This satisfies M5 done-condition (d) as it stands.
23- **Fail-closed judge.** `BlindJudge::evaluate_cycle` refuses to run without a signing key or a
24 non-empty holdout directory (src/actor/judge.rs:207-214; an empty holdout directory is refused in `HoldoutSuite::load_from_dir`, judge.rs:117-145). The judge also ships as its own binary
25 that reads its key from a file (judge.rs:49, :641, :674).
26- **Signed receipt.** `EvaluationReceipt` is signed with P-256 over `receipt_digest`
27 (src/evaluator/mod.rs:96-100). `verify_signature` recomputes the digest before checking the
28 signature (mod.rs:103-123).
29- **Tier boundaries.** Tier2 engine changes may not touch `tests`, `src/evaluator`, `src/isolation`,
30 `src/ledger`, `.rsi/holdouts`, `CONSTITUTION.md`, `LICENSE` (src/meta/tier.rs:34-42).
31
32## Gaps found (must close before M5 can pass)
33
34| id | gap | evidence | consequence |
35|---|---|---|---|
36| R1 | The signed receipt digest covers `cycle_id`, `candidate_id`, `parent_id`, `admitted` and the layer results only. It does not cover the candidate's content digest, the holdout set digest or the evaluator version. | evaluator/mod.rs:48-68 | A valid receipt can be paired with different patch bytes. Done-condition (c) cannot be checked from the receipt alone. |
37| R2 | In the daemon, the judge's signing key is read from `signing_key_hex` in the RSI config, inside the same process that proposes. The signature label says `tpm2-p256` but the key is a software key. | daemon.rs:54-61, evaluator/mod.rs:100 | The proposer can sign its own scores. This breaks the directive's rule that RSI has no authority over its own verification. |
38| R3 | The promotion safety envelope runs with an empty probe (`|| async { Ok(()) }`) and a policy digest hashed from a label built from `config.canary_target`, not from a policy file. | daemon.rs:467-504 | The envelope adds a signature, not evidence. |
39| R4 | Promotion swaps RSI's own active generation (`atomic_symlink_swap`) and records it in RSI's own ledger. | daemon.rs:529 | A second effect path beside the daemon ledger. VAC must not use it for the M5 effect. |
40| R5 | The VAC task record (`vac-task`) names `task_id`, `repo_commit` and `test_cmd` but not which file may change. The verifier ties the write path to the source pin, not to the task. | interplane provenance/src/testrun.rs:104-130; a retained `task.json` from the M3b slice | A run that edits the test file instead of the code still verifies. This also blocks M5 done-condition (f). Fix lands before M5 as its own verifier change. |
41
42## Proposed design
43
441. **Objective.** The M3b fixture `fix_the_test` (or a second pinned fixture with a measurable
45 objective) with a written objective: holdout pass count, and for a performance task a stated
46 metric and unit. The threshold is fixed in a policy file committed before the run; its sha256 goes
47 in the bundle.
482. **Holdout.** Lives outside the target repository and outside RSI's writable roots, owned by a
49 different OS user or a read-only mount. RSI receives only the judge's verdict, never the holdout
50 bytes. The holdout set digest is recorded.
513. **Judge.** The standalone judge binary, run as a separate process with its key file readable only
52 by the judge's user (closes R2 for this lane). Its public key is pinned in the verifier's trust
53 input, supplied by the operator, not read from the bundle.
544. **Receipt binding (closes R1).** A receipt version 2 whose digest also covers `subject_sha256`
55 (the exact bytes proposed), `holdout_set_sha256`, `policy_sha256` and `evaluator_version`. Version
56 1 receipts stay verifiable but cannot satisfy M5. This changes a signed format in spark-rsi, so
57 it needs Drake's approval before merge (directive: no unapproved schema or security changes).
585. **Effect.** The winning candidate goes to INTERPLANE as a `write_file` proposal on the fixture
59 repository and through ComposeApprovedProposal with the normal operator approval. RSI's
60 `atomic_symlink_swap` and the R3 envelope are not used in this lane (R4).
616. **Verifier.** A new optional bundle section `evaluation`, binding `rsi-eval/2`: the verifier checks
62 the P-256 signature against the operator-pinned key, `subject_sha256` equals the grant's
63 `content_sha256`, `policy_sha256` equals the retained policy file, and the score meets the
64 policy's threshold. New refusal codes: `evaluation_missing`, `evaluation_signature_bad`,
65 `evaluation_subject_mismatch`, `evaluation_below_threshold`.
667. **Rollback.** A second approved `write_file` that restores the source pin's bytes, with its own
67 ledger records; the rollback test checks the file digest equals the pinned prior digest.
688. **Negative tests.** (a) RSI proposes a change to a holdout or policy file: refused before any
69 proposal reaches the daemon, and the verifier refuses a bundle that writes outside the task's
70 target (needs R5). (b) A receipt for different bytes: `evaluation_subject_mismatch`. (c) A receipt
71 signed by RSI's own key: `evaluation_signature_bad`.
72
73## Decision needed from Drake before build
74
75Receipt version 2 (item 4) changes what spark-rsi signs. It is additive (version 1 still verifies),
76but it is a signed-format change and needs an explicit yes. Everything else in this note uses
77existing paths.
78
79Decided: Drake approved Option 1 (receipt version 2) on 2026-10-08 with six conditions: sign the candidate SHA-256, holdout digest, policy digest, evaluator version and results; the evaluated digest must match the authorized change and the bytes on disk; version 1 stays verifiable for history but never suffices for new promotions; the judge key stays out of the proposer's reach; missing, corrupt or incomplete holdouts are refused; negative tests for substituted changes and scores, altered policies, wrong keys and incomplete holdouts. Also: commit spark-rsi `Cargo.lock`.
80
81## Done conditions
82
83Unchanged from PLAN.md section D, row M5, items (a) to (f).
84
85## Addendum, 2026-10-08: feasibility probe and three more gaps
86
87Probe (spark-rsi `origin/main` e5aab9a, release build, no lock file): `spark-rsi-judge` ran with a
88throwaway key file, two holdout suites copied from the built-in cases, and the engine as both parent
89and candidate. It produced a signed receipt (`tpm2-p256:` label, software key) with
90`admitted: false` (the candidate equals the parent, so nothing improved). Bubblewrap 0.9.0 is
91present, so the jail runs on this host. `spark-rsi propose <path>` is a deterministic unslop scan
92(src/main.rs:277-287) that prints one `ImprovementProposal`; it needs no model server.
93
94| id | gap | evidence | consequence |
95|---|---|---|---|
96| R6 | The judge evaluates a candidate **executable**: each holdout case runs `<candidate> holdout <input>` in the jail and compares stdout (src/actor/judge.rs:220-247). The correctness layer runs `cargo check` and `cargo test` only (src/evaluator/layers/correctness.rs:112, :153). | probe; code | The C fixture `fix_the_test` cannot be judged. M5 needs a small Rust fixture whose binary answers `holdout <input>`. |
97| R7 | `HoldoutSuite::load_from_dir` skips any file that does not parse and continues if one suite remains (judge.rs:117-145). | code | A corrupted or removed holdout file shrinks the holdout silently; with R1 the receipt does not show it. |
98| R8 | spark-rsi has no committed `Cargo.lock`; `cargo build --locked` refuses. | probe | Builds of the judge are not pinned, so a receipt's evaluator cannot be rebuilt bit for bit. |
99
100Recommended M5 slice shape (session decision, recorded): a new Rust fixture with one user-facing
101file containing banned dashes and a `holdout` subcommand; `spark-rsi propose` yields the change;
102the standalone judge, run as its own process with its own key file and a holdout directory outside
103both repositories, signs the receipt; the change lands through the approved path as in M3b. RSI does
104not target its own repository in M5, because that puts the evaluator's own files in reach.
105
106How the verifier treats the receipt depends on the open decision (receipt version 2). With a yes, the
107verifier requires `subject_sha256` to equal the grant's content digest. With a no, a version 1 receipt
108can only be checked for signature and threshold, and the verdict must carry the label
109`missing=link:evaluation_subject`.
110
111## Outcome, 2026-10-08 (IMPLEMENTED)
112
113Merged: spark-rsi#34 (merge commit 24f412f699f1942861fac5afb632cc8deda31ad1) and interplane#89 (merge commit
114dc37ca3e5948945bf4619c015b6c817a0c0920a0). Final gate `adapters/aien/scripts/test-m5-rsi.sh` PASS on
115interplane 0c8a92d and spark-rsi 4becebb, 2026-10-08 23:24Z; evidence in interplane
116`adapters/aien/evidence/m5-rsi-2026-10-08/`.
117
118The six conditions, as built:
1191. Signed fields: receipt version 2 (spark-rsi `docs/RECEIPT-V2.md`) signs subject path and SHA-256, parent
120 commit, holdout-set digest, policy digest, evaluator version and binary digest, layer results and holdout
121 counts (P-256, the judge account's key).
1222. Identity match: the harness precheck and the offline verifier require the receipt subject to equal the
123 ledger grant's content digest and the ack's on-disk digest (`evaluation_subject_mismatch`), and the
124 receipt parent to equal the bundle's source pin (`evaluation_parent_mismatch`). spark-rsi's promotion
125 gate re-reads the promoted bytes before its swap.
1263. Version 1: verifiable as history; `evaluation_v1_insufficient` in the verifier, refused by the
127 promotion gate.
1284. Key separation: judge key in `/var/lib/aien-judge` (mode 700), unreadable by the proposer account
129 (setup script proves "Permission denied"). Everything the judge does with candidate source (build,
130 `cargo check`, `cargo test`) runs in one bubblewrap sandbox without the judge's home, environment or
131 network; the holdout jail has no network fallback.
1325. Holdouts: the judge refuses a missing, empty, corrupt, incomplete or extra-file holdout set and any
133 set whose digest differs from the policy pin.
1346. Negatives (all in the gate, each with its named refusal): substituted score (two), edited subject,
135 altered policy, wrong pinned key, dropped evaluation, substituted change, receipt signed by another key,
136 version 1 receipt, other policy, re-signed low-bar policy pair against the operator pin, missing,
137 corrupt, shrunk and stray-file holdouts, RSI aimed at another file, dirty workspace, workspace without
138 its own repository.
139`Cargo.lock`: committed in spark-rsi and enforced in CI with `--locked`.
140
141Review: three independent reviews (separate sessions). Two blockers in the first (promotion did not check
142the staged bytes; a prebuilt binary could be run) and one in the second (the correctness check ran
143candidate build scripts outside the sandbox, which could have read the key) were fixed and re-tested
144before merge; the third found no blockers and four smaller items, all fixed.
145
146Differences from the plan: the gate script is `test-m5-rsi.sh` (PLAN.md named `test-rsi-hookup.sh`);
147promotion goes through INTERPLANE's approved path, not spark-rsi's ratifier, so ratify is not exercised
148and spark-rsi's own daemon refuses self-promotion (it only holds version 1 receipts).
149
150Limits (also in the gate receipt): the operator account can read the judge key through sudo; the holdouts
151are public, pinned by digest, not secret; the proposer is a rule-based scan, not a model, so the verdict
152stays `PASS_LABELLED_INCOMPLETE missing=link:model_turn`; the speed allowance is 200% because timing this
153microsecond fixture varied up to 79% between identical builds; the desk MAC stays default-off.