interplane-mv
INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority.
Brought by drakestapleton
interplane-mv / adapters / aien / README.md
| 1 | # interplane-adapter-aien |
| 2 | |
| 3 | Reference adapter that lets the INTERPLANE `Pipeline` (Crossveil) talk to AIEN's existing |
| 4 | authority machinery. License: AGPL-3.0-or-later (see `LICENSE`). Design: `docs/adr/0003`. |
| 5 | |
| 6 | **This adapter never changes AIEN and AIEN keeps all authority.** It builds nothing that AIEN |
| 7 | could mistake for its own decision: no `AuthorizedEffect`, no `DoctrineDecision`, no |
| 8 | `SafetyDecision`. `authorized` appears only when AIEN's own gate returned `Ok` for a read, or when AIEN's |
| 9 | `EffectLane::authorize` minted an `AuthorizedEffect` after AIEN's `EffectClassAuthority` said Allow. |
| 10 | `requires_approval` and `denied` carry AIEN's reason. The approval id on `requires_approval` is an adapter handle with no authority: grants come only from AIEN's `ApprovalDesk` and are |
| 11 | spent only by AIEN. Nothing under `rust/`, `spec/` or |
| 12 | `conformance/` and no AIEN repository is modified. |
| 13 | |
| 14 | ## Pinned AIEN sources |
| 15 | |
| 16 | `aien-capability` and `aien-mcp` are git dependencies pinned to |
| 17 | [`aien-dev/aien-sovereign-core-mv`](https://github.com/aien-dev/aien-sovereign-core-mv) at `9b5e6e82359f4ad6b6f03042e83ef6411c5f15ce` (main 2026-10-08; `crates/aien-capability` and `crates/aien-mcp` are byte-identical to 4d4dfd4, `git diff --stat 4d4dfd4 9b5e6e8 -- crates/aien-capability crates/aien-mcp` is empty, and the live gate below passed against a daemon built from 9b5e6e8. 4d4dfd4 was main 2026-10-07, after PR #296 merged: the daemon honours only grants it minted itself and refuses every caller-written authorization note, sovereign-core #261; and PR #295: an approved proposal carries a signed requirements goal, a missing one is refused, #289. `crates/aien-capability` and `crates/aien-mcp` are byte-identical to 8bcd79b, main after PR #262 merged: the authenticated `ComposeApprovedProposal` daemon command the ledger route uses; `crates/aien-capability` and `crates/aien-mcp` are byte-identical to 7d37da1, after PR #260 merged: two-phase approval spend, a grant is reserved at mint, committed when the effect runs, released if the effect is dropped, and `EffectLane::with_clock` re-checks expiry at commit; before #260 `crates/aien-capability` and `crates/aien-mcp` are byte-identical to 0bdc97a, main after PR #208 merged, which binds the idempotency ledger to effect identity and lets an approver revoke an unspent grant; before it, PR #207 merged, |
| 18 | which makes the authority exposure-aware, on top of PR #204 single-use approvals and the PR #203 |
| 19 | authority seam). `aegis` (feature `aegis-gate`, on by default) cannot be a git dependency because |
| 20 | `aegis-runtime`'s own `Cargo.toml` reaches a sibling checkout by relative path |
| 21 | (`../aien-protocols/crates/*`). The build therefore expects this layout next to the INTERPLANE |
| 22 | checkout: |
| 23 | |
| 24 | ``` |
| 25 | <parent>/interplane/adapters/aien (this crate) |
| 26 | <parent>/interplane-audit/aegis-runtime aien-dev/aegis-runtime-mv @ AEGIS_RUNTIME_REV in PINS |
| 27 | <parent>/interplane-audit/aien-protocols aien-dev/aien-protocols-mv @ AIEN_PROTOCOLS_REV in PINS |
| 28 | ``` |
| 29 | |
| 30 | All sibling pins live in one file, `PINS` (this directory). The Spark gate `INTERPLANE-ADAPTER-AIEN` |
| 31 | (`tests/gates/run.sh adapter-aien`; it replaced the hosted job `adapter-aien`, removed on 2026-10-18) |
| 32 | and local setup both call `setup-siblings.sh`, which reads `PINS`, so they use the same commits: |
| 33 | |
| 34 | ``` |
| 35 | cd <parent>/interplane |
| 36 | adapters/aien/setup-siblings.sh # clones/checks out ../interplane-audit/{aegis-runtime,aien-protocols} |
| 37 | cd adapters/aien && cargo test # toolchain is pinned by /rust-toolchain.toml (1.99.0) |
| 38 | ``` |
| 39 | |
| 40 | The script also fails if the `aien-sovereign-core` rev in `Cargo.toml` differs from `SOVEREIGN_CORE_REV` in `PINS`. |
| 41 | To move a pin, change `PINS` (and `Cargo.toml` for sovereign-core) in the same PR. |
| 42 | Without the `aegis-gate` feature the crate still builds and every `decide()` is `denied` (fail closed). |
| 43 | Building `aegis-runtime` at the pinned commit (f4e8709, 2026-10-04) writes `mojo/libaegis_simd.so` inside that |
| 44 | checkout (its `build.rs`) when a `mojo` compiler is installed. aegis-runtime removed Mojo on its `main` on |
| 45 | 2026-10-15 (aegis-runtime PR #49); the pin here has not moved past that yet. |
| 46 | |
| 47 | The in-process write provider uses `rustix` **1.1.5** as an explicit Linux syscall |
| 48 | binding (`openat2`, `openat`, `statat`, `renameat`, `unlinkat`). This is a host dependency, |
| 49 | not Omega code. The Omega replacement is a descriptor-relative host filesystem boundary |
| 50 | with beneath/no-symlinks resolution and exclusive-create/atomic-replace operations; it is |
| 51 | not implemented by this Rust adapter. No pathname fallback is used on kernels without |
| 52 | `openat2` or on non-Linux systems: writes fail closed. The workspace descriptor is opened |
| 53 | at enrollment, parent symlinks and non-regular final entries are refused, and existing |
| 54 | regular files are atomically replaced rather than truncated (hard links are not written through). |
| 55 | |
| 56 | Effect request correlation, exposure and replay handles are retained for the adapter's |
| 57 | lifetime and bounded to 4096 distinct effect request ids. New effect ids are denied when |
| 58 | that capacity is exhausted; existing approvals/replays and reads remain available. A host |
| 59 | must finish or abandon outstanding approvals before retiring that adapter and creating a |
| 60 | fresh one. Closing a pipeline trace alone does not retire the adapter's correlation state. |
| 61 | |
| 62 | ## Reused from AIEN (called for real) |
| 63 | |
| 64 | All paths relative to the pinned clones. |
| 65 | |
| 66 | | What | Where | |
| 67 | |---|---| |
| 68 | | `ToolDescriptor::new`, `capability_digest` | `aien-sovereign-core/crates/aien-capability/src/tool.rs:7,30` | |
| 69 | | `catalog_digest` (the catalog digest this repository publishes) | `aien-capability/src/tool.rs:43` | |
| 70 | | `routing_class`, `speculation_safe` (effect classification) | `aien-capability/src/effects.rs:54,74` | |
| 71 | | `SessionManager::enroll`, `speculative_lane` | `aien-mcp/src/session.rs:38,29` (wraps `McpBroker::admit`, `broker.rs:53`) | |
| 72 | | `SpeculativeLane::invoke_speculative` (read execution; refuses unsafe effects) | `aien-mcp/src/broker.rs:151` | |
| 73 | | `SpeculativeLane::stage_effect_intent` (records an intent, executes nothing) | `aien-mcp/src/broker.rs:181` | |
| 74 | | `MemoryWire` (in-process `McpWire`) | `aien-mcp/src/memory.rs:11` | |
| 75 | | `aegis::pre_dispatch_check` (live allowlist gate) | `aegis-runtime/src/enforcement.rs:31` (`ALLOWED_SKILLS` at `:14`) | |
| 76 | |
| 77 | `AuthorizedEffect` is never constructed here. The only production mint is crate-private inside |
| 78 | `aien-mcp`, reached through `EffectLane::authorize(intent, scope, &dyn EffectAuthority)`; the adapter |
| 79 | passes AIEN's own `EffectClassAuthority`. A test (`adapter_source_never_constructs_authorized_effect`) |
| 80 | greps `src/lib.rs` for struct-literal construction, `authorize_for_test`, `mint(` and any local |
| 81 | `EffectAuthority` impl. |
| 82 | |
| 83 | ## Effect path (0.2) |
| 84 | |
| 85 | Reads are unchanged (speculative lane). Everything else (`routing_class` not Pure/ReadOnly) goes: |
| 86 | stage intent (a speculation-safe local-ephemeral tool cannot be staged by AIEN, so a plain |
| 87 | `EffectIntent` is used; it carries no authority) -> `EffectLane::authorize` with |
| 88 | `EffectClassAuthority` -> in `decide`: |
| 89 | |
| 90 | | AIEN decision | Crossveil decision | Executes | |
| 91 | |---|---|---| |
| 92 | | Allow / AllowRestricted (PURE, READ_*, LOCAL_EPHEMERAL) | `authorized`; the minted effect is held until `execute` | yes, via `EffectLane::execute_effect`; result carries the `EffectReceipt` | |
| 93 | | RequireApproval (EXTERNAL_WRITE, WORLD_MUTATION, SECRET_BEARING, SPAWN_PROCESS) | `requires_approval`, `runtime_state` has `staged=true` and `intent_digest=...` | no | |
| 94 | | Deny (EXTERNAL_IRREVERSIBLE, unknown tool or bits, stale intent) | `denied` with AIEN's reason | no | |
| 95 | | Contain | `denied` with AIEN's reason | no | |
| 96 | |
| 97 | Approvals (aien-mcp single-use grants, PR #204), routed through the host-only continuation API |
| 98 | (0.3 cut A3, `spec/CORE.md` "Approval continuation"). `decide` never reads a grant: a |
| 99 | `requires_approval` answer stays pending and carries `approval.approval_id`, a handle this adapter |
| 100 | mints (`aien-approval:<request_id>:<intent digest prefix>`) so the host can correlate the |
| 101 | continuation; the handle carries no authority (the authority is the grant AIEN's desk issues, whose |
| 102 | id is private to aien-mcp). Nothing in `arguments`, `extensions`, the envelope or model text is read |
| 103 | as a grant. The host's approver calls `AienAuthority::issue_approval(req, expires_at)`, which issues |
| 104 | a grant through AIEN's `ApprovalDesk` bound to that exact effect, then |
| 105 | `AienAuthority::present_approval(req, &grant, now)`, which spends it through |
| 106 | `EffectLane::authorize_approved` and returns the runtime's continuation decision (citing the minted |
| 107 | id). That decision goes to `Pipeline::continue_approval`. Because the pipeline borrows its runtime |
| 108 | for its whole life, hosts wrap the adapter in `AienShared` (give the pipeline a clone) and call |
| 109 | `AienShared::continue_approval(&mut pipeline, trace, request_id, &grant, now_epoch, now)`, which |
| 110 | reads the request and digest from the pipeline's own pending entry, runs the continuation, and |
| 111 | drops any minted effect the pipeline did not run. Refusals (`Unknown`, `Mismatch`, `Consumed`, `Reserved`, |
| 112 | `Expired`) come back as `denied` with `approval refused: <variant>` and the pipeline denies the |
| 113 | request for good (terminal; the host starts a new request). A spent grant presented again for the |
| 114 | same completed effect is a replay at the adapter: AIEN's ledger returns the existing receipt |
| 115 | (`authorize_and_execute_approved`) and nothing re-executes; through the pipeline a second |
| 116 | continuation is refused first. The stock `write_file` and `bash_eval` descriptors are WORLD_MUTATION, |
| 117 | so they stay pending until continued. `with_effects(name, bits)` re-declares a stock capability's |
| 118 | `ToolEffects` (used by tests with a LOCAL_EPHEMERAL temp-dir write and an EXTERNAL_IRREVERSIBLE |
| 119 | deny); AIEN's authority decides from the new bits. |
| 120 | |
| 121 | **Spend point (limit).** AIEN spends the grant when it mints the effect, inside `present_approval`, |
| 122 | not when the provider runs it. aien-mcp at 0bdc97a can revoke only an unspent grant (#208), so a spent grant still cannot be given back (sovereign-core #206). So the |
| 123 | grant is gone before the pipeline's own checks (digest, expiry string, catalog) and before the |
| 124 | provider call. Outcomes, all tested in `tests/approval.rs`: |
| 125 | |
| 126 | | What fails after the mint | What happens | Second effect? | |
| 127 | |---|---|---| |
| 128 | | the pipeline refuses the continuation (wrong digest, stale clock, catalog change) | `denied` reported; the minted effect is dropped (`discard_unexecuted`); the grant is RELEASED (sovereign-core #260: reserved at mint, never spent here; AIEN records the reason, a later mint re-checks expiry, revocation and binding) | no: nothing ran | |
| 129 | | the provider rejects the call (`CallOutcome::Rejected`, e.g. missing directory) | `error` reported; AIEN removes the ledger entry; the grant stays `Consumed` (spent at commit, just before the provider call), the request is terminal | no: the host recovers with a new request and a new grant after fixing the cause | |
| 130 | | the provider outcome is unknown (`Uncertain` or a wire error) | `error` reported; AIEN's ledger keeps `Uncertain`; the same effect (same idempotency key) is `ReconciliationRequired` for any later grant (`broker.rs` `execute_effect`) | no, but it needs reconciliation by the host; not exercised by a test because the in-process provider cannot return `Uncertain` | |
| 131 | |
| 132 | What AIEN cannot do: reserve a grant and commit it only when the effect runs, so a refusal between |
| 133 | mint and execute burns an approval that bought nothing, and the human approves again. That costs a |
| 134 | re-approval, never a duplicate effect. Recorded as a limit; a sovereign-core issue is drafted in the |
| 135 | PR body (not filed). Other limits: grants and the minted handles live in memory only (restart: no |
| 136 | pending request, fail closed); the minted `approval.expires_at` is left empty, so expiry is AIEN's |
| 137 | (`now >= expires_at` against the epoch the host passes), and the pipeline's string clock is a |
| 138 | second, separate check; the desk is separated from other desks by handle discipline, not by type. |
| 139 | |
| 140 | ## Not the production effect path |
| 141 | |
| 142 | The adapter reaches AIEN through `aien-mcp` (`EffectLane`, `EffectClassAuthority`, `ApprovalDesk`, |
| 143 | in-memory single-use grants). At the pinned rev no other sovereign-core crate depends on |
| 144 | `aien-mcp` or `aien-capability`. The production effect path is `aien compose` (`aien-cli` |
| 145 | `src/compose.rs`): a CLI step talks to the `aien-runtime` daemon, which runs omega COMPOSITION-2 |
| 146 | through `aien-omega-compose` (FFI to `librx_compose.a`, pinned by `omega.lock`); the approval is a |
| 147 | durable Cortex `authorization` record, the write is bracketed by durable `effect` intent/ack |
| 148 | records (`aien-runtime/src/effects.rs`), and every step leaves an `aien-cli` |
| 149 | `record_effect_receipt` file. None of that is reached by the default adapter, so adapter |
| 150 | conformance proves the `aien-mcp` authority path; the opt-in `ComposeLedgerAuthority` below is |
| 151 | the route that reaches the compose/World/Cortex boundary. |
| 152 | |
| 153 | ## Durable effect ledger (`ComposeLedgerAuthority`, opt-in) |
| 154 | |
| 155 | `src/compose_ledger.rs` wraps `AienShared` (approval desk, `decide` and reads unchanged) and routes |
| 156 | an approved `write_file` through a running `aien-cli daemon` (sovereign-core #249) instead of the |
| 157 | in-process provider. The route opens only when AIEN's `EffectLane` minted the effect for that |
| 158 | request (`holds_minted_effect`); that in-process effect is then dropped unexecuted. An approved |
| 159 | write has exactly one route: |
| 160 | |
| 161 | 1. **Authenticated handoff.** `ComposeApprovedProposal` with an `ApprovedProposal` (trace id, |
| 162 | request id, approval id, approver, path, content, approved `{content, path}` digest, content |
| 163 | digest) and `approval_mac`, HMAC-SHA256 under the approval desk key (`DeskKey`, made by |
| 164 | `aien compose desk-key --create 1` in the daemon's compose home) over the canonical binding. |
| 165 | The daemon re-checks the MAC and claims the request id, approval id and approval key durably; |
| 166 | any replay (same request, same approval id, after a restart, after a crash) is refused. |
| 167 | 2. **Compose.** The approved text runs through the daemon's compose path: J-Space branch, AEGIS |
| 168 | verify, World commit, Cortex promotion and evidence records. |
| 169 | 3. **Grant.** The daemon itself writes the grant: a reserved `approved_grant` authorization keyed |
| 170 | on the returned `compose_proposal_sha256`, confined to the workspace, linked to the promotion, |
| 171 | evidence and replay claim. The adapter reads it back and checks every field; it never writes a |
| 172 | grant, so there is no client-minted fallback. |
| 173 | 4. **Intent, write, ack.** `ComposeEffectIntent` (stop, revoke, spent, stale, confinement and the |
| 174 | grant's committed backing checked by the daemon), the write (tmp + rename inside the |
| 175 | workspace), `ComposeEffectAck` (the daemon reads the disk: DONE / NOT_DONE / UNRESOLVED). |
| 176 | |
| 177 | The desk key never reaches the model: `ComposeLedgerAuthority::new` refuses a key inside the |
| 178 | workspace (or a workspace inside the key's directory) and a key file that is a symlink, not owned |
| 179 | by this user, group- or world-readable, or malformed; only its `desk_key_id` is recorded. The MAC |
| 180 | proves that the holder of the desk key approved these exact fields, not that a particular human |
| 181 | did; the OS user is the outer boundary. The socket client speaks the daemon's JSON line protocol |
| 182 | directly, so `aien-runtime` (whose build needs the omega libraries) is not a dependency. |
| 183 | |
| 184 | Boundary, stated on every receipt (`LEDGER_BOUNDARY`): authenticated daemon handoff -> compose |
| 185 | verify + AEGIS -> J-Space branch -> World commit -> Cortex promotion/evidence -> daemon grant on |
| 186 | compose_proposal_sha256 -> effect intent -> write -> ack. It is the production effect path; it is |
| 187 | not WALDO provenance and not a full provenance chain: trace_id and request_id are on the handoff, the replay claim and the daemon grant, but not yet on the effect intent, the ack or `record_effect_receipt` (#76). |
| 188 | Evidence: `tests/compose_ledger.rs` rows 1-8 (approved write with both hash identities, forged |
| 189 | approval id, stale target, replay including a re-presented approval id, operator stop/resume, |
| 190 | adapter restart, the T4 injection subset, forged handoffs) need `AIEN_BIN` (an `aien-cli` binary |
| 191 | built from sovereign-core main 9b5e6e8) and `cargo test -- --ignored`; rows 10 and 11 (#260 expiry and re-mint) likewise; row 9 (desk key out of the model's |
| 192 | reach, key file rules) always runs. |
| 193 | |
| 194 | Recorded run at this pin (CPU evidence only, 2026-10-08 00:52Z to 00:58Z): `aien-cli` built from |
| 195 | sovereign-core 4d4dfd4 with the compose engine linked and the GPU engine not linked (build shows |
| 196 | `has_omega_compose`, not `has_omega_gpu`; the daemon logs `Backend: NativeTransformerBackend/CPU-reference`), |
| 197 | sha256 `279d38992b72f7c3f888d9b02c5ac7b26e57f6a47746c4e8107b2a9081ae4056`, model Llama-3.2-1B-Instruct |
| 198 | on the CPU reference backend. `tests/compose_ledger.rs` rows 1-8, 10, 11: 10 passed; `tests/compose_ledger_attacks.rs` |
| 199 | x1-x4: 4 passed. This is not GPU evidence and not native-OS evidence. A daemon built with the GPU engine |
| 200 | linked selects the GB10 backend whenever the chip is present, so build without `AIEN_OMEGA_DIR` for CPU runs. |
| 201 | |
| 202 | Since sovereign-core #260 (in 8bcd79b and the pinned 4d4dfd4): the effect lane is built `with_clock(host_clock())` |
| 203 | (epoch seconds; `AienAuthority::set_clock` for tests), a grant presented while reserved is |
| 204 | refused as `Reserved`, and a dropped effect releases its grant. On the ledger route the adapter |
| 205 | holds the minted effect (and its reservation) while the daemon runs, checks the grant's expiry |
| 206 | with the same clock just before the handoff (row 10: expired between grant and commit, refused, |
| 207 | no handoff, no write), and releases the reservation afterwards: the daemon's durable replay |
| 208 | ledger is what spends the approval. Row 11: the released grant re-minted with the same approval |
| 209 | id is answered by the daemon with the original result (ALREADY_COMMITTED, no second compose) and |
| 210 | refused by the adapter, with no second write. |
| 211 | |
| 212 | Since sovereign-core #295 (in the pinned 4d4dfd4): every approved proposal the adapter hands the |
| 213 | daemon carries `requirements` and `requirements_mac`. The host approves the exact bytes of a |
| 214 | `write_file`, so there is no natural-language goal whose requirements the daemon could check; the |
| 215 | adapter binds the explicit "none" (`BOUND_REQUIREMENTS`, the empty goal), MACed with the desk key |
| 216 | under tag `aien.requirements.v1` over the same approval binding. A proposal without it is refused |
| 217 | (`RequirementsUnbound`, #289). Since #296 (#261): the daemon honours only grants it minted itself; |
| 218 | `tests/compose_ledger_attacks.rs` x1 and x3 present a caller-written authorization note and assert |
| 219 | the daemon refuses it (`sovereign-core #261`), the ledger gains no record and no effect is written. |
| 220 | |
| 221 | ## Reimplemented, and why |
| 222 | |
| 223 | - **The workspace read provider** (`read_file`, `list_dir`) behind `MemoryWire`. AIEN ships no |
| 224 | filesystem provider in `aien-mcp`; ADR 0003 names an in-process `LocalToolServer`, but that |
| 225 | needs an `rmcp` transport pair for no gain here, so the simpler `McpWire` implementation |
| 226 | `MemoryWire` is used. The call still goes through the real `SpeculativeLane`. |
| 227 | - **Effect enrollment.** No AIEN crate enrolls a catalog (`CURRENT_STATE.md`: nothing depends on |
| 228 | `aien-capability`), so the adapter enrolls four descriptors named after aegis `ALLOWED_SKILLS` |
| 229 | (`read_file`, `list_dir`: `READ_FILESYSTEM`; `write_file`: `WORLD_MUTATION`; `bash_eval`: |
| 230 | `SPAWN_PROCESS | WORLD_MUTATION`) using AIEN's own `ToolEffects` bits. |
| 231 | - **Argument-schema check** (`missing required argument: <key>`, `argument <key> must be string`), |
| 232 | because AIEN has no schema validator on this path; messages match the CORE.md mock wording. |
| 233 | - **Workspace confinement** (paths must stay under the workspace root). An adapter-side |
| 234 | restriction that can only deny. It stands in for `aien-cli::SafetyEngine::evaluate`. |
| 235 | |
| 236 | ## Not possible: `SafetyEngine` |
| 237 | |
| 238 | ADR 0003 asks for `SafetyEngine::evaluate` before `pre_dispatch_check`. It cannot be linked: the |
| 239 | `aien-cli` crate declares `mod safety;` privately in `main.rs` and its `lib.rs` is empty, so |
| 240 | there is no public path without editing AIEN. This is a discrepancy with the ADR; the adapter |
| 241 | uses the aegis gate plus confinement instead, and the decision's `authority.policy_engine` |
| 242 | names the gate actually used. Reaching `SafetyEngine` needs an AIEN change (export it) or an |
| 243 | operator-side process. |
| 244 | |
| 245 | ## Not executed |
| 246 | |
| 247 | `bash_eval` has no provider body, and any call whose decision is not authorized |
| 248 | returns `status: error`, `code: execution_error`, message `not executed by the reference adapter` |
| 249 | if `execute()` is ever called on it. `write_file` executes only with an AIEN-minted effect. |
| 250 | |
| 251 | ## Fail closed |
| 252 | |
| 253 | `AienAuthority::unavailable()` and a build without the `aegis-gate` feature make `decide()` |
| 254 | return `denied` with `aien runtime not available` for every request. Never `authorized`. |
| 255 | |
| 256 | ## Catalog digests |
| 257 | |
| 258 | `catalog()` publishes AIEN's `catalog_digest` (SHA-256 over the name-sorted per-tool digests, |
| 259 | tool digest = SHA-256 of name, effect bits little-endian u32, schema digest) as |
| 260 | `sha256:<hex>`. INTERPLANE's `Catalog::compute_digest` uses a different formula (JCS over |
| 261 | name/schema pairs), so the two differ. Both are recorded, unequal, in `catalog.extensions.aien` |
| 262 | (`catalog_digest`, `interplane_computed_digest`, `digests_equal`). `mapping_table(true)` pins to |
| 263 | the published value, so `stale_capability` protection reuses AIEN's digest. |
| 264 | |
| 265 | ## Provenance |
| 266 | |
| 267 | Results are labelled by what they are (0.3 cut E4, CROSSVEIL.md rule 7): |
| 268 | |
| 269 | | Capability | `content_kind` | `trust` | |
| 270 | |---|---|---| |
| 271 | | `read_file` | workspace_content | workspace_untrusted | |
| 272 | | `list_dir` | tool_result | workspace_untrusted | |
| 273 | | `write_file` (after approval) | tool_result | trusted_runtime (AIEN's receipt plus the adapter's acknowledgement) | |
| 274 | | anything else | tool_result | external_untrusted | |
| 275 | |
| 276 | `with_trusted_workspace(true)` lifts the two reads to `trusted_runtime`. Non-executed outcomes carry |
| 277 | null content kind and trust, as CORE.md requires. |
| 278 | |
| 279 | ## Exposure (0.3 cut E4) |
| 280 | |
| 281 | `decide` hands the pipeline's `CallContext.exposure` to AIEN (`EffectLane::with_exposure`, |
| 282 | sovereign-core #207) in AIEN's own `Exposure` / `TrustLevel` types, and keeps it per request so the |
| 283 | grant presented later is checked against what the model saw when it asked. AIEN's |
| 284 | `EffectClassAuthority` holds every effect class for approval when the floor is below `user_supplied` |
| 285 | or exposure is absent; its reason then names exposure. AIEN already required approval for those |
| 286 | effect classes, so the visible change is the reason and the explicit rule, not a new block. A host |
| 287 | registers the user's request first; with an empty ledger the floor is `external_untrusted`. |
| 288 | Evidence: `tests/exposure.rs` (5 host-registered untrusted sources and a workspace read, against |
| 289 | `write_file` and `bash_eval`: all held, 0 executed, nothing written). A `bash_eval` outside the |
| 290 | catalogued forms is refused earlier by the AEGIS gate. |
| 291 | |
| 292 | ## Live verified run gate |
| 293 | |
| 294 | `scripts/test-live-daemon.sh` is the one command that ties the live daemon rows to the offline |
| 295 | provenance verifier: |
| 296 | |
| 297 | ``` |
| 298 | AIEN_BIN=<native aien-cli> AIEN_LEDGER_MODEL_DIR=<dir with model.safetensors, tokenizer.json, config.json> \ |
| 299 | OUT=<fresh dir> scripts/test-live-daemon.sh # LIVE_ROWS="row1_ x1_ x2_ x3_ x4_" limits the rows |
| 300 | ``` |
| 301 | |
| 302 | It (1) runs the `#[ignore]`d live tests against a real `aien-cli daemon` (`--ignored --test-threads=1`; |
| 303 | each row starts a daemon that loads the model, about 6.5 min on the CPU reference backend with a debug |
| 304 | build) and fails if zero tests ran or row 1 or an attack test `x1_`..`x4_` did not; (2) row 1 exports its |
| 305 | run with `provenance_export::export_bundle` (the daemon's own `ComposeRecall` views of the claim, |
| 306 | settlement, grant, intent and ack, the load log, the trace, the loaded model files, `COMPANION.json`) |
| 307 | and the gate runs `provenance verify` on it; the only accepted verdict is exactly |
| 308 | `PASS_LABELLED_INCOMPLETE missing=link:model_turn effect=aien-ledger-slice/1:strong proposal=scripted_turn`; |
| 309 | (3) it tampers with hard-linked copies of the bundle and requires named refusals: an untouched copy |
| 310 | still passes (negative control), a changed proposal content or a changed ack fails `digest_mismatch`, |
| 311 | the same change with the manifest restamped fails `binding_mismatch`, and a truncated record fails |
| 312 | `size_mismatch`; (4) it writes `OUT/receipt.json` (adapter commit, binary sha256, sovereign-core |
| 313 | revision, omega lock, verdict, test names, negative-check verdicts, timestamps). |
| 314 | |
| 315 | What a pass proves: for one real daemon run, the claim, settlement, grant, intent and ack the daemon |
| 316 | wrote agree with each other and with the INTERPLANE call (path, bytes, request, trace, the approval key |
| 317 | recomputed from the grant's own fields, the daemon process identity), and the verifier refuses the |
| 318 | tampered copies above. |
| 319 | |
| 320 | What it does not prove: the exported records carry no signatures, so the verifier cannot tell an export |
| 321 | from a hand-written file (`provenance/BINDING.md`, Trust); the model turn is scripted, so the verdict is |
| 322 | labelled incomplete (no authorship claim); the desk MAC for `ComposeAuthorize` stays default-off (not |
| 323 | changed here; this path authenticates by the desk-key MAC regardless); CPU reference backend only; the |
| 324 | daemon (before sovereign-core #346) does not report whether the native compose library is linked or which revision it was |
| 325 | built from, so the receipt records those as caller-asserted or `UNVERIFIED`; a daemon with #346 reports |
| 326 | `compose_native` and `omega_sha`, which the fix-the-test slice below carries and checks. |
| 327 | |
| 328 | Recorded run: `evidence/live-gate-2026-10-08/receipt.json` (CPU, debug `aien-cli` sha256 9704f29f..., sovereign-core 9b5e6e8 caller-asserted, omega 6c6180c). It ran `LIVE_ROWS="row1_ x1_ x2_ x3_ x4_"` (5 tests); rows 2-8, 10 and 11 passed against the same binary in an earlier unrecorded-by-this-gate run (14 of 14), not by this receipt. |
| 329 | |
| 330 | ## Fix-the-test slice |
| 331 | |
| 332 | `scripts/test-fix-the-test.sh` (also run at the end of `test-live-daemon.sh` unless `SKIP_SLICE=1`) is the |
| 333 | first product-shaped run on top of the live gate: an agent step fixes a deliberately failing test, and the |
| 334 | whole run is verified offline. |
| 335 | |
| 336 | ``` |
| 337 | AIEN_BIN=<aien-cli> OUT=<fresh dir> scripts/test-fix-the-test.sh # one live row, about 8.5 min on CPU |
| 338 | ``` |
| 339 | |
| 340 | The fixture `fixtures/fix_the_test/` is a tiny C project: `clamp()` returns `lo` where it must return `hi`, |
| 341 | so `make test` fails before the fix (GNU make exits 2 on a failing recipe; the gate requires non-zero) and |
| 342 | exits 0 after. `TASK.md` carries the task id and the exact test command; `solution/clamp.c` is harness |
| 343 | material (not copied into the task workspace). No binaries are committed. |
| 344 | |
| 345 | The live row `slice1_fix_the_test_lands_and_tests_pass` (`tests/compose_ledger.rs`, `#[ignore]`d) copies the |
| 346 | fixture to a workspace, `git init`s and commits it, runs `make test` (expected red), then drives a |
| 347 | SCRIPTED `write_file` proposal whose content is the corrected `src/clamp.c` through the existing adapter and |
| 348 | the daemon's `ComposeApprovedProposal` path (desk-key MAC, durable claim, grant, intent, ack), waits for |
| 349 | `DONE`, and runs `make test` again (expected green). `src/fix_the_test.rs` builds the task, source-pin and |
| 350 | `vac-test-run/1` records; the exporter retains them next to the daemon's ledger records, and the daemon's |
| 351 | raw `ComposeRecall` report, which since sovereign-core #346 says whether the compose library is native. |
| 352 | The gate then runs `provenance verify` and, on hard-linked copies, requires a named refusal for a changed |
| 353 | exit code, a swapped stdout digest, a wrong target blob, a dropped test run, a tampered source pin and a |
| 354 | forged native claim (`provenance/BINDING.md`, "Fix-the-test slice"). |
| 355 | |
| 356 | Expected verdict: `PASS_LABELLED_INCOMPLETE missing=link:model_turn effect=aien-ledger-slice/1:strong |
| 357 | proposal=scripted_turn`; with a daemon that does not report `compose_native` it is `missing=link:model_turn,link:native` |
| 358 | (labelled, never complete). Never `PASS complete`: the model turn is scripted. |
| 359 | |
| 360 | What it proves: the approval is bound to the exact bytes written; the write went through the daemon's |
| 361 | ledger; the tests were run after the write and their output is retained and digest-checked; the source |
| 362 | pin matches the grant's `prior_sha256` (the bytes the daemon replaced are the bytes of the pinned commit's |
| 363 | file); the bundle's native claim agrees with the daemon's own report. |
| 364 | |
| 365 | What it does not prove: the model turn is scripted (no authorship claim); the records are unsigned exports, |
| 366 | so the verifier cannot tell an export from a hand-written file; the test run is harness evidence, not a |
| 367 | daemon effect (the daemon only writes, `bash_eval` stays `NOT_EXECUTED`); nothing ties the second test run |
| 368 | to the workspace state beyond the digest of the target file and the harness's own commit; the desk MAC for |
| 369 | `ComposeAuthorize` stays default-off (not changed here); CPU reference backend only. |
| 370 | |
| 371 | Recorded run: `evidence/fix-the-test-2026-10-08/` (receipt and the small bundle files; the 2.4 GB weights are |
| 372 | hard links in the original and are not copied). |
| 373 | |
| 374 | ## Reproducible demo |
| 375 | |
| 376 | `scripts/demo-verified-fix.sh` is the one command that runs the verified fix-the-test workflow end to end and |
| 377 | writes a machine-made record, `$OUT/DEMO-RESULT.md`: exact revisions (interplane, sovereign-core, omega, |
| 378 | physics and aienos locks, daemon hash, model and tokenizer hashes, host, rustc), whether the daemon says it is |
| 379 | native (its own `Compose:` line and `ComposeRecall`), the starting task, the approved write (path, content |
| 380 | digest, approval binding id), the ledger ack, the test results before and after, the verifier verdict and the |
| 381 | tamper summary, plus "What is proven" and "What is not". It runs `scripts/test-fix-the-test.sh` once. |
| 382 | |
| 383 | Prerequisites: `git jq make cc cargo rustc sha256sum`, the sibling checkouts from `adapters/aien/setup-siblings.sh` (run it once from the interplane checkout first, otherwise the gate build fails with "failed to read .../interplane-audit/aegis-runtime/Cargo.toml"), the Llama-3.2-1B-Instruct snapshot (`AIEN_LEDGER_MODEL_DIR`, default the |
| 384 | unsloth snapshot in the Hugging Face cache), a clean interplane checkout, and a native sovereign-core daemon. |
| 385 | |
| 386 | ``` |
| 387 | # with a native aien-cli you already have |
| 388 | AIEN_BIN=<native aien-cli> SOVEREIGN_CORE_REV=<its sovereign-core rev> OUT=<fresh dir> adapters/aien/scripts/demo-verified-fix.sh |
| 389 | |
| 390 | # or build it from the four checkouts (each HEAD must equal its lock; CPU, debug build) |
| 391 | SC_DIR=<aien-sovereign-core> OMEGA_DIR=<omega @ SC_DIR/omega.lock> PHYSICS_DIR=<physics @ OMEGA_DIR/physics.lock> \ |
| 392 | AIENOS_REPO=<aienos @ OMEGA_DIR/aienos.lock> OUT=<fresh dir> adapters/aien/scripts/demo-verified-fix.sh |
| 393 | ``` |
| 394 | |
| 395 | The demo exits non-zero if the daemon reports a stub compose library, if `compose_native` and the `Compose:` |
| 396 | line disagree, if the model or tokenizer hash in the daemon log differs from the file on disk, if the verdict |
| 397 | is anything but the labelled-incomplete one (`missing=link:model_turn`; a scripted run is never `PASS |
| 398 | complete`), or if any tamper is not refused. The stub check reads the daemon's report after the gate's run |
| 399 | (about 9 to 15 minutes), not before it. Recorded run: `evidence/demo-2026-10-08/DEMO-RESULT.md`. Nothing here |
| 400 | changes a security default. |
| 401 | |
| 402 | ## Bounded self-improvement, independently judged (VAC M5) |
| 403 | |
| 404 | `scripts/test-m5-rsi.sh` runs one bounded self-improvement cycle where the proposing agent cannot forge |
| 405 | the evidence that approves its own change: |
| 406 | |
| 407 | ``` |
| 408 | scripts/m5-setup-judge.sh <pinned public key file> # once: the judge account makes its own key |
| 409 | AIEN_BIN=<aien-cli> OUT=<fresh dir> SPARK_RSI_DIR=<spark-rsi target/release> \ |
| 410 | M5_JUDGE_KEY=<pinned public key file> scripts/test-m5-rsi.sh |
| 411 | ``` |
| 412 | |
| 413 | `m5-setup-judge.sh` refuses to finish unless it can run a command as the proposing account and that |
| 414 | account gets "Permission denied" reading the judge key, and unless neither service account can write the |
| 415 | pinned public key, its directory or any directory above it, or use sudo. |
| 416 | |
| 417 | Three separate parties, three separate operating-system accounts: |
| 418 | |
| 419 | - **Proposer** (`aien-rsi`, no sudo): `spark-rsi propose` reads a read-only copy of the task workspace |
| 420 | (`fixtures/rsi_dashes/`, whose tests fail while its README contains dashes) and prints one proposal. The |
| 421 | hook (`scripts/m5-propose-and-judge.sh`) refuses a workspace with uncommitted changes or symbolic |
| 422 | links, and a proposal for any file other than `README.md`. |
| 423 | - **Judge** (`aien-judge`, home mode 700, holds the only copy of `judge.key`): `spark-rsi-judge` receives |
| 424 | its own copies of the parent tree, the candidate tree, the holdout suite (`m5/holdouts/`) and the |
| 425 | operator policy (`m5/policy.json`). Before running anything it refuses a holdout set that does not hash |
| 426 | to the policy's pinned digest, a subject outside `allowed_targets` or under `protected_paths`, and a |
| 427 | candidate that differs from the parent in any file but the subject. It builds both trees and runs their |
| 428 | own `cargo check` and `cargo test` inside a bubblewrap sandbox (no network, no environment, only the |
| 429 | tree and the toolchain visible, so a build script or test in the candidate cannot read the key), runs the holdouts, re-hashes the subject and signs a |
| 430 | version 2 receipt (`spark-rsi` `docs/RECEIPT-V2.md`) naming the parent commit it compared against. |
| 431 | - **Operator path** (the harness and the daemon): the harness refuses a judged policy that is not byte for |
| 432 | byte its own `m5/policy.json`, then `evaluation::precheck` checks the receipt against the pinned public |
| 433 | key, the exact bytes about to be proposed, the task's commit and the policy pin; only then does the |
| 434 | scripted proposal go through `ComposeApprovedProposal` with the normal approval, exactly like the |
| 435 | fix-the-test slice. After the tests pass, a second approved write restores the original README |
| 436 | (rollback) and the tests fail again. |
| 437 | |
| 438 | The bundle carries the receipt and the policy as records with an `evaluation` section, and |
| 439 | `provenance verify <bundle> --judge-key <file> --policy-sha256 <sha of m5/policy.json>` checks it offline |
| 440 | (`provenance/BINDING.md`, "Independent evaluation"). Without the key the verdict is |
| 441 | `FAIL evaluation_untrusted`: a bundle never carries the key that verifies it. The gate then requires a |
| 442 | named refusal for each counterfeit: an edited score, layer or subject digest (`evaluation_signature_bad`), |
| 443 | an edited policy (`evaluation_policy_mismatch`), the wrong pinned key (`evaluation_signature_bad`), a |
| 444 | dropped section (`evaluation_missing`), a genuine receipt for a different README |
| 445 | (`evaluation_subject_mismatch`), a receipt signed with a throwaway key, a version 1 receipt |
| 446 | (`evaluation_v1_insufficient`), a policy with a lower bar re-signed into a consistent pair |
| 447 | (`evaluation_policy_mismatch` against the operator's pin), a workspace with uncommitted changes (the hook |
| 448 | refuses), and holdout suites that are missing, corrupt, shrunk or carry a stray file (the judge refuses to |
| 449 | sign). |
| 450 | |
| 451 | What it proves: the change that landed is byte for byte the change the judge evaluated, judged against the |
| 452 | task's own commit; the judge ran under the operator's pinned policy and holdout set and signed with a key |
| 453 | the proposer cannot read; a version 1 receipt, a substituted score or a substituted change is refused |
| 454 | before the write and again offline; the change can be undone through the same approved path. |
| 455 | |
| 456 | What it does not prove: the operator account can still read the judge key through sudo (that is the |
| 457 | operator's authority, not the agent's); the holdouts are not secret from the proposer (its account can |
| 458 | read the operator's files), only fixed by digest; the proposal is a deterministic rule-based edit, not a |
| 459 | model turn, so the verdict stays labelled incomplete (`missing=link:model_turn`); the speed check allows |
| 460 | 200% slowdown because timing a microsecond program here varied by up to 79% between identical builds; the |
| 461 | desk MAC for `ComposeAuthorize` stays default-off (not changed here). |
| 462 | |
| 463 | Recorded run: `evidence/m5-rsi-2026-10-08/` (`receipt.json`: gate PASS on adapter 0c8a92d and spark-rsi 4becebb, tests |
| 464 | failing before, passing after and failing again after the rollback; `judge-receipt.json`: the judge's signed |
| 465 | version 2 receipt, 4 of 4 holdout suites; `negative-verdicts.txt`: the control and 18 named refusals; |
| 466 | `speed-noise.txt`: the timing noise behind the 200% allowance). The same receipt is the cross-language |
| 467 | fixture in `provenance/fixtures/rsi-eval-v2/`. |
| 468 | |
| 469 | ## Build and test |
| 470 | |
| 471 | ``` |
| 472 | cd adapters/aien |
| 473 | cargo build --offline |
| 474 | cargo test --offline |
| 475 | cargo fmt --check && cargo clippy --offline --all-targets -- -D warnings |
| 476 | ``` |
| 477 | |
| 478 | Building `aegis` at the pinned commit runs its `build.rs`, which writes `mojo/libaegis_simd.so` into the |
| 479 | pinned aegis clone as an untracked file when a `mojo` compiler is installed (aegis-runtime `main` has had |
| 480 | no Mojo since 2026-10-15). This crate is its own Cargo workspace and is not a member of |
| 481 | `rust/Cargo.toml`. |
| 482 | |
| 483 | ### The same cycle with a real model turn |
| 484 | |
| 485 | `scripts/test-m5-model-turn.sh` (same inputs as `test-m5-rsi.sh`, plus the two restart rows) replaces the |
| 486 | deterministic proposer with the model the daemon loaded: the harness sends one `StreamTurn` (CPU), the daemon |
| 487 | generates the `write_file` tool call and writes its own generation record, and the same judge, approval and |
| 488 | rollback follow. The bundle carries a `model-turn/2` record (request and response bytes, weights digest, the |
| 489 | backend line, times). The verifier compares each with the retained bytes and the daemon's record, so the |
| 490 | verdict is `PASS complete ... proposal=model_generation/2` only when the digests chain; a turn that does not |
| 491 | chain is a `FAIL`, and a bundle that says its turn was scripted stays `PASS_LABELLED_INCOMPLETE |
| 492 | missing=link:model_turn`. Limits: one 1B model turn with a worked example in the prompt is not a learning |
| 493 | system; the request bytes and times are the harness's own; the generation record is unsigned. |
| 494 | |
| 495 | ## Bridge binary (`aien-authority-bridge`) |
| 496 | |
| 497 | `cargo build --bin aien-authority-bridge`, then `aien-authority-bridge <workspace>`. It reads one JSON |
| 498 | request per line on stdin (`catalog`, `mapping_table`, `decide`, `execute`, `approve`, `discard`) and |
| 499 | writes one JSON line per request on stdout. Every call goes straight to `AienAuthority`; answers are |
| 500 | the serde JSON of `interplane-core`'s `Catalog`, `Decision` and `ToolResult`. Unknown ops, malformed |
| 501 | JSON or a wrong shape return `{"ok":false,"error":...}` and never a decision. `approve` is the host-only |
| 502 | approver channel (AIEN's desk issues one single-use grant, the bridge allows one approve per request id). |
| 503 | Its first consumer was the Python Motus adapter (`adapters/motus`, removed 2026-10-15); any host that |
| 504 | can speak JSON lines can use it. Test: `cargo test --test bridge`. |