interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / kernel / CONTINUITY_RECOVERY_CONTRACT.md

772 lines · 63055 bytes Raw Blame History Source

C kernel contract: continuity objects and Recovery Core

Status: IMPLEMENTED (host PASS), QEMU NOT_RUN, hardware NOT_RUN for the continuity half (M4_CONTINUITY) and for the host half of the Recovery Core (M4_RECOVERY, cut 5). **M4_RECOVERY is NOT_RUN: there is no kernel wiring, no QEMU receipt and no hardware run.** What has C code (all host PASS, QEMU n/a, nothing wired into the kernel): the codec (cuts 1-2: svc/continuity_codec.c, golden vectors, C/Rust decode agreement), boot resolution (cut 3: svc/continuity_resolve.c: P-3 lookup, INV-5 orphan/Conflict, INV-6 chain, INV-7 references, read-only check), the Recovery Core challenge, state digest and operator HMAC (same file), the sealed-Store binding svc/continuity_resolve_sealed.c, provision, commit and resume (cut 4: svc/continuity_commit.c: INV-4, INV-8 to INV-11, K-1, markers of section 3), and, new in cut 5, the Recovery Core (svc/continuity_recovery.c: read-only inspection INV-13, entry reasons and applicable() INV-14/INV-15, the operator-authorised repair of a malformed peer INV-16/INV-17 and operator provisioning INV-16/INV-18, the C-only sealed-refusal entry reason of K-3/K-4, and the RECOVERY_CORE, RECOVERY_CHALLENGE, RECOVERY_ACTION, RECOVERY_REFUSED marker text), run by make -C native/kernel test, sanitize and continuity-mutants against the REAL sealed Store in a file (cut 4 also with power cuts at every Store and anchor checkpoint and at every block boundary, for commit AND for provisioning). Not done: wiring into the kernel and any QEMU run (the first wiring cut needs the K-7 test-mode mechanism, the RECOVERY_OPERATOR_KEY: TEST-ONLY handling and a kernel stage that calls these functions); the RECOVERY_RECORD: marker; the full K-3/K-4 tests (cut 5 proves only that a corrupted newest AgentRoot is a sealed refusal with no action; the newest-root-graph-broken case with a CRC-valid root is not built separately); power cuts during a repair or a recovery-core provisioning (cut 4 cut the underlying provisioning, a repair is one unit write plus a flush). Every QEMU row (81-87, 88-91) stays NOT_RUN until a forge receipt covers it. Host rows 87a-87d, 87f, 87g and 91d-91k are HOST PASS (see GATES.md). QEMU qualifies nothing physical; nothing here says anything about Machine 1.

Authority:

Labels used below:

Paths are relative to the aienos repo root. continuity.rs means crates/aienos-kernel/src/continuity.rs; recovery_core.rs means crates/aienos-kernel/src/recovery_core.rs; nvme_read.rs means crates/aienos-boot/src/nvme_read.rs.


1. On-disk objects the Rust code writes (CODE)

All four kinds are Store v1 objects with Store version = 1 (STORE_OBJECT_VERSION, continuity.rs:24). Each object starts with a 16-byte continuity header and the body follows. All integers are little-endian unless stated. id = 32 raw bytes.

1.1 Continuity header (16 bytes), continuity.rs:90-95, 105-122

offsizefieldrule
08magicper kind, below
82format_version (u16)must be 0 (FORMAT_VERSION, continuity.rs:26; checked :110)
102reserved (u16)must be 0 (:115)
124body_len (u32)must equal total length minus 16 (:118)

Decoders are strict (continuity.rs:97-166): every read is bounds checked ("truncated object"), every reserved byte must be zero ("nonzero reserved"), and the whole input must be consumed ("trailing bytes").

1.2 Kinds written

Store kindconstmagicnamewritten by
16KIND_AGENT_ROOT (continuity.rs:19)AIENROOT (:34)AgentRootprovision only (:721-772)
17KIND_MANIFEST (:20)AIENMANI (:35)ContinuityManifestprovision, commit_with_hook (:837-845)
18KIND_AGENT_STATE (:21)AIENBRAN (:36)AgentStateCheckpoint (branch table)provision, commit_with_hook when update.state is set (:802-812)
20KIND_CORTEX_WAL (:22)AIENCWAL (:37)CortexWalSegmentcommit_with_hook when update.cortex is non-empty (:815-826)

Kinds 19 (CortexCheckpoint) and 23 (MigrationManifest) appear in ADR 0016 (docs/adr/0016-continuity-objects-over-store-v1.md:40, :42) but **no Rust code writes or reads them**. They are PROPOSED and out of scope for the C port (section 8).

1.3 AgentRoot, kind 16 (body 96 bytes, total 112), continuity.rs:202-247

offsizefield
1632agent_id (LogicalAgentId)
4816store_uuid
6432root_branch
968provisioned_generation (u64) = Store generation + 1 at provisioning (:738)
1041source: 1 = Operator, 2 = Qualification (:186-191, :224-228)
1057reserved, zero

Decode also refuses agent_id == 0 ("zero agent id", :231) and root_branch != root_branch_id(agent_id) (:234).

1.4 ContinuityManifest, kind 17 (body 120 + 32·n, n ≤ 64), continuity.rs:253-315

offsizefield
1632root: AgentRoot ObjectId
4832previous: previous manifest ObjectId, zero when none
808sequence (u64)
888incarnation (u64)
9632agent_state: AgentState ObjectId, zero when none
1282cortex_wal count n (u16), n ≤ MAX_WAL_SEGMENTS = 64 (:28, :265, :293)
1306reserved, zero
13632·ncortex_wal: CortexWalSegment ObjectIds, in commit order

Decode refuses sequence == 0 and any manifest where (sequence == 1) is not the same as previous == zero (:301-305). Largest manifest: 2184 bytes.

1.5 AgentState, kind 18 (body 48 + 80·n, 1 ≤ n ≤ 256), continuity.rs:321-482

offsizefield
1632agent_id
488written_at (u64): manifest sequence it was written in (:334, set at :808; genesis uses 1, :743)
564branch count n (u32), 1 ≤ n ≤ MAX_BRANCHES = 256 (:29, :417)
604reserved, zero
6480·nbranches, strictly ascending by id

Each branch (80 bytes, BRANCH_BYTES, :340, encode :401-407):

offsizefield
032id
3232parent id, zero for the root branch
644depth (u32)
684reserved, zero
728forks (u64): children forked so far

validate (:447-481), run by both encode (:393) and decode (:440):

  1. 1 ≤ n ≤ 256; ids strictly ascending.
  2. Exactly one branch with zero parent; its id is root_branch_id(agent_id) and depth 0.
  3. Every child: parent present; id == child_branch_id(parent, i) for some i < parent.forks; depth == parent.depth + 1 (checked add).
  4. Sum of all forks equals the number of children ("fork indexes are not contiguous"). DECIDED (CODE, Rust #232; C agrees): the sum is checked. A sum that overflows u64 is refused with the same class and text, because it can never equal the child count (<= 255). Without the check a table with root forks = 2^64-1 and one child with forks = 2 wraps to 1 and is accepted. C: cc_state_validate (continuity_codec.c, the over flag); vector state_forksum_overflow; mutant MC-13. The child-index scan is also capped at MAX_BRANCHES hashes in both (no outcome changes for a table that passes the sum check).

fork (:365-390): refuses at 256 branches (Limit), absent parent (Corrupt), depth overflow (Limit), id collision (Corrupt); child index = parent.forks, then parent.forks += 1; insert keeps sort order. Largest object: 20544 bytes.

1.6 CortexWalSegment, kind 20, continuity.rs:488-582

offsizefield
168sequence (u64): manifest sequence it was committed in
244record count n (u32), 1 ≤ n ≤ MAX_WAL_RECORDS = 64 (:30, :529, :559)
284reserved, zero
32…n records

Each record (:545-549): status u8 (1 DirectObservation, 2 VerifiedFact, 3 Inference, 4 Hypothesis, 5 Contradiction, 6 OperatorDecision; :490-511), reserved u8 zero, statement length u16 (1 ≤ len ≤ MAX_STATEMENT_BYTES = 1024, :31, :534, :568), evidence_hash 32 bytes, statement bytes. Largest object: 67872 bytes.

1.7 Derived values (CODE, must be bit-identical)

valuedefinitionsource
ObjectIdSHA-256("AIENOS-STORE-OBJECT-V1\0" ‖ kind u16 LE ‖ version u16 LE ‖ len u64 LE ‖ bytes)crates/aienos-kernel/src/store/v1.rs:27, :63-78; C twin sv1_object_id native/store/store_v1.h:132
root branch idSHA-256("AIENOS_ROOT_BRANCH_v1:" ‖ agent_id)continuity.rs:69-75
child branch idSHA-256("AIENOS_CHILD_BRANCH_v1:" ‖ parent ‖ index u64 big-endian)continuity.rs:77-84
QEMU memory= digestfirst 8 bytes of SHA-256 over every committed record in order of (statement len u32 LE ‖ statement)nvme_read.rs:1119-1124, :1138-1140
provisioning agent idfour RNDR words, each stored little-endian, word 0 first; no fallbacknvme_read.rs:1184-1193; rndr crates/aienos-kernel/src/arch/aarch64.rs:173-183 (FEAT_RNG check, 16 tries)
recovery challengeSHA-256("AIENOS-RECOVERY-CHALLENGE-v1\0" ‖ store_uuid ‖ generation u64 LE ‖ action u8 ‖ state_digest)recovery_core.rs:94-104
state_digestSHA-256(raw superblock unit 0 ‖ raw superblock unit 1) of the Store region, read errors leave that buffer zerorecovery_core.rs:109-133
operator responseHMAC-SHA256(key, "AIENOS-RECOVERY-OPERATOR-AUTH-v1\0" ‖ challenge), compared in constant timecrates/aienos-kernel/src/recovery.rs:103, :124-140; C has aienos_hmac_sha256 and aienos_ct_equal (native/crypto/aienos_crypto.h:112, :116)
action byteRepairDegradedPeer = 1, ProvisionIdentity = 2recovery_core.rs:38-44

2. Invariants the C port must hold bit-for-bit

Each invariant names the Rust code it comes from. "Bit-for-bit" means: for the same inputs, the C encoder produces the same bytes, the C decoder accepts exactly the inputs the Rust decoder accepts and yields the same values, and the same error class is returned.


3. Boot resolution and Recovery Core entry (CODE, behaviour to port)

Continuity, in this order (continuity.rs:637-710):

  1. List catalog entries by kind. Apply INV-5.
  2. Decode the AgentRoot through a kind-checked read (INV-7).
  3. Decode every manifest; apply INV-6.
  4. Decode the current manifest's AgentState; check its agent.
  5. Decode each WAL segment in manifest order; check ordering; concatenate records.

Corrupt reasons the Rust code can return (the why text appears in serial markers; matching it exactly is PROPOSED so C markers can be grepped the same way): "bad magic", "unsupported continuity format version", "nonzero header reserved", "body length mismatch", "truncated object", "nonzero reserved", "trailing bytes", "unknown provisioning source", "zero agent id", "root branch does not derive from agent", "too many cortex WAL segments", "manifest sequence/previous mismatch", "branch count out of range", "branches not strictly sorted", "unexpected root branch", "parent branch is absent", "branch lineage is inconsistent", "fork indexes are not contiguous", "unknown epistemic status", "statement length", "WAL segment record count", "referenced object is absent", "referenced object has the wrong kind", "continuity objects without an agent root", "manifest names a foreign root", "agent root has no manifest", "manifest sequence gap or fork", "manifest chain is broken", "manifest has no agent state", "agent state belongs to another agent", "WAL segments out of order", "fork parent is absent", "child branch id collision" (all in continuity.rs:97-857).

Recovery Core (recovery_core.rs:107-187):

  1. Read Store-region units 0 and 1 raw; classify each slot Zero / Superblock{generation} / Undecodable(err) / ReadError; take the store uuid from the first decodable slot; compute state_digest.
  2. Open the Store without writing. Unformatted: reason StoreUnformatted. Other mount error: StoreMount(err).
  3. Record (mount state, peer condition, generation) and catalog counts (roots, manifests, other).
  4. Resolve continuity. Reason: Degraded(peer) if the mount is degraded, else none / Unprovisioned / Conflict / ContinuityCorrupt(why); any other continuity error is ContinuityCorrupt("continuity unreadable").

Serial markers the QEMU oracle greps (CODE, nvme_read.rs):

markersource
CONTINUITY: <PROVISIONED\|RESUMED\|RESUMED_READONLY\|REMEMBERED\|COMMITTED> agent=<64 hex> incarnation=N sequence=S cortex=K branches=B memory=<16 hex>:1118-1143
CONTINUITY: UNPROVISIONED, CONTINUITY: CONFLICT, CONTINUITY: CORRUPT (<why>), CONTINUITY: STOP (<Debug of error>), CONTINUITY: NO_ENTROPY, CONTINUITY: STOP (fork):1144-1155, :1178, :1189, :1229
CHECKPOINT: <name> (crash mode):1241-1253; names crates/aienos-kernel/src/store/checkpoint.rs:79-88
RECOVERY_OPERATOR_KEY: TEST-ONLY:1287
RECOVERY_RECORD: slot0=… slot1=… mount=… peer=… generation=… roots=… manifests=… other=… agent=<hex\|none>:1290-1322
RECOVERY_CORE: ENTERED reason=<Debug> / RECOVERY_CORE: NOT_NEEDED:1324-1333
RECOVERY_CHALLENGE: action=<name> challenge=<64 hex>:1335-1343
RECOVERY_ACTION: <name> DONE[ agent=<hex>], RECOVERY_REFUSED (<Debug>), RECOVERY_REFUSED (NoEntropy):1356, :1377-1391

PROPOSED: the C kernel prints these exact strings (same field order, same Debug spellings such as Degraded(Malformed)), so the C gate scripts can use the Rust scripts' grep patterns and the rows can be IDENTICAL rather than DIFFERS. CONTINUITY markers IMPLEMENTED, host PASS (cut 4): cr_marker_view (PROVISIONED, RESUMED, RESUMED_READONLY, REMEMBERED, COMMITTED) and cr_marker_outcome (UNPROVISIONED, CONFLICT, CORRUPT (why), NO_ENTROPY, STOP (...)) in svc/continuity_commit.c produce the strings above byte for byte (test compares with an independently printf-built line, incl. the 8-byte memory= and e3b0c44298fc1c14 for no records). Only the Store-error spelling differs (9.2). The CHECKPOINT: marker is not implemented (no wiring). Recovery markers IMPLEMENTED, host PASS (cut 5): rc_marker_entry (RECOVERY_CORE: ENTERED reason=<text> / NOT_NEEDED), rc_marker_challenge, rc_marker_done, rc_marker_refused in svc/continuity_recovery.c, with the Rust Debug spellings (Degraded(Malformed), Unprovisioned, ContinuityCorrupt("why")); the C-only reason spells SealedRefusal(<rc>), a mount error StoreMount(<rc>) (Rust prints the Debug of its own error), and RECOVERY_REFUSED (Continuity(<outcome>)) names the cut 4 outcome. RECOVERY_OPERATOR_KEY: TEST-ONLY and RECOVERY_RECORD: are not implemented (the key is a parameter of the actions; the record belongs to the wiring cut).


4. What the Recovery Core may do without a model

CODE (recovery_core.rs:1-8, ADR 0006): no model, no network, no clock.

Allowed:

Refused by design (CODE):

Operator key today is TEST-ONLY (TEST_ONLY_OPERATOR_KEY = [0x0f; 32], crates/aienos-boot/src/store_qual.rs:59-63). The real credential (Argon2id passphrase, FIDO key) is undecided (ADR 0006 / M5). PROPOSED: the C port keeps the key behind a TEST-only build flag, prints `RECOVERY_OPERATOR_KEY: TEST-ONLY` on every boot that uses it, and refuses the TEST key in a CK_HARDWARE_STAGING build the same way ck_store_keys_admissible refuses TEST Store keys (native/kernel/svc/store_boot.h:66).

Other ADR 0006 items are out of scope (section 8). Rust has an A/B SlotManager and a Cortex WalRecovery::recover_and_truncate (crates/aienos-kernel/src/recovery.rs:37-90, :144-200; tests :329, :346, :380), but neither is part of the continuity or Recovery Core QEMU campaigns this contract ports. Crash records and model-weight hash checks have no Rust code.


5. Interfaces to the C Store (PROPOSED unless marked CODE)

The C kernel does not use a plain Store v1. It mounts the sealed Store: every application object is an M5 envelope of Store kind SS_KIND_ENVELOPE (0x0510), with the application kind and version carried in the M5 binding, plus one sealed transaction record per transaction and an anti-rollback anchor outside the Store region (CODE: native/store/store_sealed.h:1-31, :43-51; boot stage native/kernel/svc/store_boot.c, store_boot_run_policy). The Rust oracle wrote continuity objects as plaintext Store v1 objects. That gap is the main design point of this contract.

5.1 Placement

5.2 Calls the continuity and recovery code needs

needC Store callstatus
mount without writingss_open (store_sealed.h:141-143), which runs st_open firstCODE
mount state, peer conditions->st.state (ST_VALID, ST_DEGRADED_RECOVERY), s->st.peer (store_engine.h:22-26, :134-141)CODE
generation, active slotss_generation, st_active_slot (store_sealed.h:151, store_engine.h:153-155)CODE
list by kindclaims loop (P-3), cr_bind_sealed in continuity_resolve_sealed.cCODE (cut 3, host PASS)
read one objectss_read(s, sid, out, cap, &len, &kind) (store_sealed.h:149-150)CODE
commit ≤ 3 objects atomicallyss_transact(s, objs, n, hook, arg, ids_out) (store_sealed.h:146-147), n ≤ SS_MAX_OBJECTS = 8CODE
read-only refusalss_prepare returns ST_E_READ_ONLY_DEGRADED when not Valid (store_sealed.c:379)CODE; continuity still checks first (INV-11)
crash checkpointsst_hook with ST_CP_* 0-6 (store_engine.h:58-69) plus SS_CP_BEFORE_ANCHOR 100, SS_CP_AFTER_ANCHOR 101 (store_sealed.h:76)CODE
raw superblock units for inspectionst_dev.read_unit(ctx, 0/1, buf) on the Store region, sv1_superblock_decode (store_engine.h:71-78, store_v1.h:184)CODE
repair writest_dev.write_unit(ctx, 1 - active, zeros) then flushCODE calls; use PROPOSED
entropy for provisioningck_rng_fill (native/kernel/core/entropy.h:53), refuses with no fallbackCODE; use PROPOSED
HMAC + constant-time compareaienos_hmac_sha256, aienos_ct_equal (native/crypto/aienos_crypto.h:112, :116)CODE

5.3 Known conflicts between the oracle and the sealed Store


6. Oracle map: Rust check -> C gate

Gate M4_CONTINUITY and gate M4_RECOVERY in scripts/ck_gates.sh (today missing, ck_gates.sh:55-56). Every row below is listed in native/kernel/GATES.md sections "M4 continuity" and "M4 recovery" with status NOT_RUN (MISSING_IMPLEMENTATION).

6.1 M4_CONTINUITY

QEMU oracle: scripts/qemu_continuity_test.sh (PASS line CONTINUITY_QEMU: PASS, :210; receipt evidence/continuity_qemu_2026-09-25.md at Rust commit 3df62b2).

GATES rowRust checkscript lines
81blank media, resume: CONTINUITY: STOP (store Unformatted), image unchanged:92-98
82formatted store, no root, resume: CONTINUITY: UNPROVISIONED, image unchanged:100-108
83provision: PROVISIONED, 64-hex agent, incarnation=1 sequence=1 cortex=0 branches=1:111-119
83asecond provision: STOP (AlreadyProvisioned), image unchanged:122-127
83bindependent provisioning gives a different agent (RNDR):129-136
84mode 7: RESUMED … incarnation=2 sequence=2 cortex=0 branches=1, then REMEMBERED … incarnation=2 sequence=3 cortex=1 branches=2:139-147
85, 85acold restarts 1 and 2: same agent, same memory=, incarnation 3 then 4, sequence 4 then 5, cortex 1, branches 2:149-160
86-86fkill at each checkpoint (before_first_write, after_payloads, after_catalog, after_commit_record, after_first_flush, after_superblock_write = either, after_final_flush = new); marker seen; same agent:163-194
87malformed peer (inject … inactive seeded_garbage): RESUMED_READONLY, same agent and memory, image unchanged:196-205

Host oracle: cargo test -p aienos-kernel --lib continuity (9 tests, crates/aienos-kernel/src/continuity_tests.rs):

GATES rowRust testline
87aunprovisioned_store_never_mints_an_identity:84
87bprovision_then_cold_restart_returns_the_same_identity_and_memory:97
87cprovisioning_twice_is_refused:142
87dtwo_roots_stop_with_conflict:152
87eforked_or_gapped_manifest_chains_are_corrupt:178
87fdegraded_mount_resumes_read_only:221
87ga_crash_at_every_write_of_a_commit_leaves_old_or_new_never_a_third_state:242
87hencodings_round_trip_and_reject_tampering:286
87ibranch_table_validation_rejects_broken_lineage:328

C-side differences already known (PROPOSED observables, to be stated in the rows when the C gate exists): the crash campaign has 9 checkpoints in C (7 Store + 2 anchor, section 5.2); the Rust "either" point after_superblock_write is after_inactive_superblock in C (native/store/store_engine.c:43-55); the anchor points need their own expected outcome, derived from the sealed-store rule that a crash between Store commit and anchor commit resumes at SS_RB_PREPARED_ADVANCE (store_sealed.h:16-21), so both anchor points are expected to show the new memory.

6.2 M4_RECOVERY

QEMU oracle: scripts/qemu_recovery_test.sh (PASS line RECOVERY_CORE_QEMU: PASS, :194; receipt evidence/recovery_core_qemu_2026-09-25.md at Rust commit e5b44d8).

GATES rowRust checkscript lines
88inspect degraded store: RECOVERY_OPERATOR_KEY: TEST-ONLY, RECOVERY_CORE: ENTERED reason=Degraded(Malformed), record shows the same agent, image unchanged; repair challenge offered:94-103
88a, 88b, 88crepair with zero / wrong-key / wrong-challenge response: RECOVERY_REFUSED (Unauthorised), image unchanged:105-117
89authorised repair: RECOVERY_ACTION: repair-degraded-peer DONE, image changed:119-125
89aresume after repair: CONTINUITY: RESUMED, same agent and memory:126-132
89breplay of the repair response: RECOVERY_REFUSED (NotApplicable), image unchanged:133-138
90unprovisioned store: ENTERED reason=Unprovisioned, provision challenge offered, image unchanged:141-149
90aprovisioning with wrong key: Unauthorised, image unchanged:150-155
90bauthorised provisioning: RECOVERY_ACTION: provision-identity DONE agent=…, a cold resume returns that agent:156-163
91corrupted agent root: ENTERED, no RECOVERY_CHALLENGE, image unchanged:166-174
91a, 91bmodes 10 and 11 with a forged response: RECOVERY_REFUSED (…), no action, image unchanged:175-183
91cnormal boot after identity loss: no RESUMED/PROVISIONED, image unchanged:184-189

Host oracle: cargo test -p aienos-kernel --lib recovery_core (8 tests, crates/aienos-kernel/src/recovery_core_tests.rs) and the operator-auth tests in crates/aienos-kernel/src/recovery.rs:

GATES rowRust testline
91dinspection_never_writes_and_names_the_reasonrecovery_core_tests.rs:89
91edegraded_repair_needs_the_operator_and_restores_a_writable_store:111
91fprovisioning_is_operator_only_and_only_on_an_unprovisioned_store:154
91gidentity_lost_in_the_newest_root_never_looks_unprovisioned:178
91hmalformed_peer_without_a_resolvable_identity_is_not_repaired:222
91iorphaned_continuity_objects_are_corrupt_not_unprovisioned:236
91jidentity_loss_through_corruption_offers_no_action_that_mints:267
91kchallenges_bind_state_and_action:300
91lhmac_primitive_rfc4231_case_2recovery.rs:238
91moperator_auth_known_answer_acceptedrecovery.rs:251
91noperator_auth_rejects_any_single_bit_fliprecovery.rs:269
91ooperator_auth_rejects_legacy_bare_sha256_responserecovery.rs:299
91poperator_auth_rejects_undomained_hmac_and_zero_responserecovery.rs:311

6.3 Differential agreement (D-1, D-2 DECIDED and IMPLEMENTED, host PASS; D-3 PROPOSED)

ADR 0024 Q2 requires differential agreement, not just parallel tests.


7. Failure modes each gate must catch, with a mutation

Each C gate and host test needs a mutation that makes it FAIL, wired as a TEST-only build flag refused by CK_HARDWARE_STAGING or as a --self-test case (LT-KERNEL rule). PROPOSED flag names; the behaviour is what matters.

M4_CONTINUITY:

idmutationmust turn FAIL
MC-1resume provisions when Unprovisioned: CM_MUTANT_RESUME_PROVISIONS, IMPLEMENTED, killed (cut 4)82, 87a
MC-2drop the orphan check (INV-5): orphan objects read as Unprovisioned: CR_MUTANT_NO_ORPHAN_CHECK, IMPLEMENTED, killed (cut 3)91i (and the C twin of 87a with an orphan manifest)
MC-3resume skips the commit (no incarnation + 1): CM_MUTANT_RESUME_NO_COMMIT, IMPLEMENTED, killed (cut 4)84, 85, 85a, 87b
MC-4manifest chain check ignores previous: CR_MUTANT_IGNORE_PREVIOUS, IMPLEMENTED, killed (cut 3)87e
MC-5accept format_version != 0 or nonzero reserved bytes87h, D-2
MC-6child_branch_id index little-endianD-1, 87i
MC-7provision allowed when a root exists: CM_MUTANT_PROVISION_WITH_ROOT, IMPLEMENTED, killed (cut 4)83a, 87c
MC-8provision or commit split into two transactions (manifest after payload): CM_MUTANT_SPLIT_TXN, IMPLEMENTED, killed (cut 4; caught by the provisioning cut sweep: root and state without a manifest is Corrupt, and by the generation check, which sees +2)86-86f, 87g
MC-9writable check removed (commit on degraded mount): CM_MUTANT_NO_WRITABLE_CHECK, IMPLEMENTED, killed (cut 4; note the sealed Store itself still refuses with ST_E_READ_ONLY_DEGRADED, so the mutant changes the outcome from ReadOnly to Store, which the test requires to be ReadOnly)87, 87f
MC-10agent id from a fixed value instead of RNDR: CM_MUTANT_FIXED_AGENT, IMPLEMENTED, killed (cut 4)83b
MC-11WAL segment truncated silently at the size bound (K-1) instead of Limit: CC_MUTANT_TRUNCATE_AT_CAP, IMPLEMENTED, killed by both test_continuity_codec (cut 1) and test_continuity_commit (cut 4: a 64 x 1024 byte commit must be Limit with the image unchanged)C size-bound tests
MC-12Conflict check skipped (first root used): CR_MUTANT_SKIP_CONFLICT, IMPLEMENTED, killed (cut 3)87d
MC-13fork-count sum unchecked (wraps): CC_MUTANT_UNCHECKED_FORK_SUM, IMPLEMENTED, killed87i, state_forksum_overflow (D-1, D-2)
MC-14golden mismatch only the vectors see (manifest WAL id 63 replaced by id 0): CC_MUTANT_MANIFEST_LAST_WAL_ZERO, IMPLEMENTED, killedD-1
MC-15golden comparison skipped: CC_MUTANT_SKIP_D1 (the test counts comparisons), IMPLEMENTED, killedD-1
MC-16decode-agreement comparison skipped: CC_MUTANT_SKIP_D2, IMPLEMENTED, killedD-2

M4_RECOVERY:

idmutationmust turn FAIL
MR-1inspection writes (for example repairs on inspect): RC_MUTANT_INSPECT_WRITES, IMPLEMENTED, killed (cut 5)88, 90, 91, 91d
MR-2challenge omits state_digest: CR_MUTANT_CHALLENGE_NO_DIGEST, IMPLEMENTED, killed (cut 3)89b, 91k
MR-3challenge omits the action byte: CR_MUTANT_CHALLENGE_NO_ACTION, IMPLEMENTED, killed (cut 3)88c, 91k
MR-4response compare checks only 16 bytes (CR_MUTANT_COMPARE_16, IMPLEMENTED, killed, cut 3), or is not constant time (not mutated: timing is not observable on the host)91n (bit flips in bytes 16-31)
MR-5applicable() treats a degraded mount with no identity as Unprovisioned (the fe2c2bd bug): RC_MUTANT_DEGRADED_IS_UNPROVISIONED, IMPLEMENTED, killed (cut 5)91g, 91
MR-6repair zeroes the active slot: RC_MUTANT_REPAIR_ACTIVE, IMPLEMENTED, killed (cut 5)89, 89a
MR-7repair offered without a resolved identity: RC_MUTANT_REPAIR_NO_IDENTITY, IMPLEMENTED, killed (cut 5)91h
MR-8operator auth uses bare SHA-256 (CR_MUTANT_BARE_SHA256) or omits the domain (CR_MUTANT_NO_DOMAIN): both IMPLEMENTED, killed (cut 3)91o, 91p
MR-9operator provisioning writes source Qualification: RC_MUTANT_PROVISION_QUALIFICATION, IMPLEMENTED, killed (cut 5)91f

Known oracle gap (CODE, not covered by any Rust test): no power-cut campaign runs on provisioning itself; only commits are cut (continuity_tests.rs:242-283, qemu_continuity_test.sh:163-194). DECIDED and IMPLEMENTED (cut 4, host PASS): test_continuity_commit cuts power during provisioning at all 9 checkpoints (ST_CP_* 0-6, SS_CP_BEFORE_ANCHOR, SS_CP_AFTER_ANCHOR) and at every block boundary of the write sequence (10 at 4096 byte blocks, 73 at 512), for commit and for provisioning: after every cut the store reopens (ss_open rc 0) and resolves to exactly the old state (Unprovisioned, generation unchanged) or exactly the full genesis (same agent as the uncut run, sequence 1, incarnation 1, generation + 1); never a root without a manifest. After a cut that left the old state, provisioning again succeeds (no orphans). Checkpoints 0-4 give the old state, 6, before_anchor and after_anchor the new one (before_anchor reopens at SS_RB_PREPARED_ADVANCE); checkpoint 5 (after_inactive_superblock) gave the NEW state in every run (the test allows either there, as the Rust oracle does). Mutant MC-8 is killed by it.


8. Out of scope


9. Differences between ADR 0016 text and the Rust code (code wins)

ADR 0016 saysRust code doeseffect on the C port
Manifest carries migration_parent_id, Cortex checkpoint id, admission receipts (:38)none of these fields exist (continuity.rs:253-315)port the code layout only
Degraded mount reports CONTINUITY: DEGRADED (:46-48)prints CONTINUITY: RESUMED_READONLY … (nvme_read.rs:1211-1213)use the code marker
Current manifest = the one no other names as previous (:57-61)all catalog manifests must form exactly 1..n (continuity.rs:656-678)port the stricter code rule
Kinds 19 and 23 listed (:40, :42)not written or readout of scope
Provisioning on a store with zero roots (:50-53)also refused when orphan continuity objects exist (continuity.rs:642-649)port the code rule
Branch-table validation sums forks (not specified in the ADR text; section 1.5 item 4)Rust #232: the sum is checked, an overflowing sum is refused as Corrupt("fork indexes are not contiguous"); before #232 a release build wrapped and accepted {root forks = 2^64-1, child forks = 2}DECIDED: C refuses on overflow (cc_state_validate), Rust and C agree; vector state_forksum_overflow, mutant MC-13

9.1 Cut 3 (resolve): C versus the Rust resolve, and what C does on purpose

Where code and contract differ, the safer behaviour (refuse) was chosen. Host evidence: test_continuity_resolve.c.

itemRustC (cut 3)effect
Cortex records in the viewContinuity.cortex keeps every record (continuity.rs:726-736)cr_view keeps cortex_count and the streamed memory digest only (continuity_resolve.h); no record is storedbounded memory (a view could hold 4 MiB); the QEMU markers and a resume need only count and digest; compare D-3 on resolved values
order of failuresreads objects lazily, root count first (:638-653)build_table reads and hashes every object of kinds 16, 17, 18, 20 first (:100-130)a Store read error, an oversize object or a duplicate logical id on ANY continuity object is reported before the root count; always a refusal, never a resolve
duplicate logical idimpossible (Store v1 dedups)Corrupt duplicate logical object id (P-3)C-only reason
oversize objectn/aLimit continuity object exceeds the size bound (K-1), before decodeC-only; a Rust-legal object over 16384 bytes cannot exist in the sealed Store, so the real-Store test refuses at the write (t_size_bound) and the resolve Limit is tested with a fake source (t_fake)
table boundcatalog bound 4096 over all objects (store/v1.rs:12)Limit too many continuity objects above CR_TABLE_CAP = 4096 objects of kinds 16/17/18/20untested at the bound (UNVERIFIED), refusal either way
empty or id-less objectn/aCorrupt continuity object has no valid idC-only; the sealed Store refused a zero-length write in the test run, so this is also unreached through the real Store
re-read checkn/aread_kind re-hashes the plaintext and compares with the logical id (object changed since lookup)C-only defence; unreachable with the real Store
manifest iteration ordercatalog orderclaim orderwhen several manifests are broken the first reported reason can differ; the class (Corrupt) is the same
mount stateresolve works on a degraded mountsame (t_degraded), cr_writable gives CR_READ_ONLYmatches INV-11
outcome setStore, Unprovisioned, Conflict, AlreadyProvisioned, ReadOnly, Corrupt, Limitsame names (CR_*), plus C-only CR_E_ARG; CR_ALREADY_PROVISIONED exists but resolve never returns it (cut 4)

D-2 result (cut 2, host PASS): no C/Rust decode divergence was found over 86598 verdicts (every single-bit flip of 22 vectors, plus the untouched vectors). The only known C/Rust difference in the codecs is the C-only K-1 size cap (section 5.3), which the flips cannot reach because they keep the length, and the C-only CC_E_ARG caller-bug class, which no decoder input reaches.

9.2 Cut 4 (provision, commit, resume): C versus the Rust code, and what C does on purpose

Where code and contract differ, the safer behaviour (refuse) was chosen. Host evidence: tests/test_continuity_commit.c (real sealed Store in a file, 4096 and 512 byte blocks).

itemRustC (cut 4)effect
provision over orphansprovision checks only that no root exists (continuity.rs:727-730); orphan manifest/state/WAL objects do not stop itrefuses: provision resolves first and returns the resolve outcome (Corrupt: continuity objects without an agent root), nothing writtenstricter, as the task and ADR 0016 (:50-53) ask; a test (t_provision_refusals) writes an orphan manifest and checks the image is byte for byte unchanged
provision with a root that is itself brokenAlreadyProvisioned (a root exists)the resolve outcome (Corrupt, Limit or Store)still a refusal; the class differs, the marker says why
provision with two rootsAlreadyProvisionedAlreadyProvisioned (Conflict counts as "a root exists")same
provision with no entropythe caller (nvme_read.rs:1184-1193) prints NO_ENTROPY before calling provisioncr_provision itself returns CR_NO_ENTROPY (C-only outcome, marker CONTINUITY: NO_ENTROPY) from ck_rng_fill, after the writable and Unprovisioned checks, before any write; a never-probed rng also refusesthe refusal is inside the library, so no caller can mint without entropy; order: ReadOnly, AlreadyProvisioned/orphans, NoEntropy
zero agent idCorrupt("zero agent id") (:731)same, from the drawn bytes (unreachable with a working rng: ck_rng_fill refuses repeated words)same
provisioned_generationstore.generation() + 1 (:738)cr_source.generation(ctx) + 1 (new field, NULL for fakes; provision refuses CR_E_ARG without it); the test checks it equals the generation after the commitsame value
resume returns(Continuity, committed) with the full record listcr_view (count + memory digest) and *committedas 9.1
commit sees a stale currentnot checked (the caller passes a Continuity)not checked either: the new manifest names cur->manifest_id as previous, and a stale cur therefore gives a manifest the next resolve refuses (sequence gap or fork), never a silent overwriteUNVERIFIED by a dedicated test; the chain check (INV-6, t_chain, cut 3) is what catches it
object limitsAgentState up to 256 branches (20544 bytes), WAL segment up to 64 records (67872 bytes)K-1 cap: an object over 16384 bytes is Limit and nothing is written; 204 branches commit, 205 do not; 64 x 1024 byte records do not; 15 x 1024 byte records do and read back wholeC-only Limit, tested at the bound (t_size_bound); a 65-record segment is Limit "WAL segment record count" as in Rust
65th WAL segmentLimit("cortex WAL needs compaction")same text; 64 segments commit, the 65th is refused with nothing writtensame
marker text for a Store errorSTOP (<Debug of the Rust error>)STOP (Store(<rc>)) with the C error number; STOP (ReadOnly), STOP (AlreadyProvisioned), STOP (Limit("...")), UNPROVISIONED, CONFLICT, CORRUPT (<why>), NO_ENTROPY match the Rust spellingthe QEMU rows for store-error cases will be DIFFERS
crash campaign7 Store checkpoints (kill points) per commit; provisioning not cut9 (7 Store + 2 anchor) plus every block boundary, for commit AND provisioning; after_inactive_superblock gives the NEW state (Rust "either")stronger; anchor points reopen at SS_RB_PREPARED_ADVANCE and show the new state, as 6.1 predicted
agent id word orderfour RNDR words stored little-endian, word 0 firstwhatever ck_rng_fill writes (it is the C kernel's entropy interface, entropy.h:53)UNVERIFIED on hardware: the byte order is the rng module's; the test checks the agent equals ck_rng_fill output, not the Rust word layout

9.3 Cut 5 (Recovery Core): C versus the Rust code, and what C does on purpose

Where code and contract differ, the safer behaviour (refuse) was chosen. Host evidence: tests/test_continuity_recovery.c (real sealed Store in a file, 4096 and 512 byte blocks; one test per Rust recovery_core test row 91d-91k; rows 91l-91p are test_continuity_resolve, cut 3). Every inspection and every refused action is checked to leave the image byte for byte unchanged.

itemRustC (cut 5)effect
entry reasonsEntryReason (recovery_core.rs:25-33)same, plus C-only RC_SEALED_REFUSAL for a sealed mount refusal (SS_E_*, -301..-314); ST_M_UNFORMATTED is StoreUnformatted, any other ST_M_* is StoreMount(rc)a sealed refusal admits no action (INV-15); the Store does not mount, so the record has no mount, challenge or catalog
flipped byte of the newest AgentRoot (rows 91, 91g, 91j)mounts degraded on the older generation (Degraded(GraphBadNewer)), or a mount errorss_open refuses with SS_E_ROLLBACK (-303): entry reason SealedRefusal(-303), no challenge, no actionidentity-loss rows stay DIFFERS: the observable is a sealed refusal, not Degraded(GraphBadNewer) (K-3, K-4)
catalog counts in the recordroots, manifests, other over the Store catalogcounts of verified application objects (sealed claims): roots, manifests, other; the Store's own envelope and transaction-record entries are not countedother differs from Rust for the same history
MR-5 killing test91g (a degraded mount whose valid root has no identity)91h (garbage in the inactive slot of a formatted store). In C row 91g never mounts (see above), so it cannot show a Degraded-without-identity mountthe mutant RC_MUTANT_DEGRADED_IS_UNPROVISIONED is killed by 91h; the 91g C test checks the refusal and that nothing is offered
agent id in provisioningthe caller passes agent_idthe id is drawn from the kernel entropy interface inside cr_provision (cut 4: no fallback); rc_provision_identity takes the rngthe test checks the stored root (source Operator, Store uuid from the inspection, generation), not a pinned id
provisioning without entropynot reachable (caller supplies the id)authorised, then RC_CONTINUITY with CR_NO_ENTROPY, nothing written (RECOVERY_REFUSED (Continuity(NoEntropy)))C-only refusal, tested
operator keyTEST_ONLY_OPERATOR_KEY in the boot cratea parameter; this file holds no key and prints no RECOVERY_OPERATOR_KEY: TEST-ONLYthe key handling and its CK_HARDWARE_STAGING refusal belong to the wiring cut (section 4 PROPOSED)
repair after a failed unit writeRecoveryError::IoRC_IO; the repair writes the single inactive unit then flushes, no power cut testUNVERIFIED for a cut during the repair write; the inactive slot is zero, malformed or half written either way and the active root is untouched
inspection mountStore::open borrows the devicess_open into a caller-owned ss_store; it stays open after rc_inspect and an action reuses it for provisioning, with nothing written between the authorisation and the writesame ordering (inspect, applicable, verify, write)
marker RECOVERY_RECORD:printed on entrynot implementedwiring cut