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

GitHub aien-dev/aienux#238 (code only)

closed derived ea215793fd15756f #238

Imported from GitHub aien-dev/aienux#238 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base ee4cb36723e05e68389203e3270c734e6f1693b9 · Head 56ea169d4e29bd8888d4501f1f517d0aa1730ea5

Apply it

git checkout -b patch-ea215793fd15756f ee4cb36723e05e68389203e3270c734e6f1693b9
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/ea215793fd15756f.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aienux
238
56ea169d4e29bd8888d4501f1f517d0aa1730ea5
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":238,"url":"https://github.com/aien-dev/aienux/pull/238","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:02Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/native/kernel/CONTINUITY_RECOVERY_CONTRACT.md b/native/kernel/CONTINUITY_RECOVERY_CONTRACT.md
index fb37324b..666eb533 100644
--- a/native/kernel/CONTINUITY_RECOVERY_CONTRACT.md
+++ b/native/kernel/CONTINUITY_RECOVERY_CONTRACT.md
@@ -1,13 +1,18 @@
 # C kernel contract: continuity objects and Recovery Core
 
-Status: **SPEC, NOT_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) and, new in
-cut 3, boot **resolution** (`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), and the sealed-Store binding `svc/continuity_resolve_sealed.c`, all run by
-`make -C native/kernel test`, `sanitize` and `continuity-mutants` against the REAL sealed Store in a file.
-No provision, commit or resume (cut 4), no Recovery Core inspection or actions (cut 5), no wiring. Every C
-gate named here stays `NOT_RUN (MISSING_IMPLEMENTATION)` until a forge receipt covers it.
+Status: **IMPLEMENTED (host PASS), QEMU NOT_RUN, hardware NOT_RUN** for the continuity half (M4_CONTINUITY).
+**Recovery Core (M4_RECOVERY) is NOT implemented beyond the challenge, state digest and operator HMAC of cut 3**:
+no inspection, no repair, no operator provisioning action (cut 5). 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`, and, new in cut 4, **provision, commit and resume**
+(`svc/continuity_commit.c`: INV-4, INV-8 to INV-11, K-1, markers of section 3), run by
+`make -C native/kernel test`, `sanitize` and `continuity-mutants` against the REAL sealed Store in a file, with
+power cuts at every Store and anchor checkpoint and at every block boundary, for commit AND for provisioning.
+Not done: Recovery Core inspection and actions (cut 5); wiring into the kernel and any QEMU run (the first wiring cut
+needs the K-7 test-mode mechanism and a kernel stage that calls these functions). Every QEMU row (81-87, 88-91)
+stays `NOT_RUN` until a forge receipt covers it. Host rows 87a-87d, 87f, 87g are HOST PASS (see GATES.md).
 QEMU qualifies nothing physical; nothing here says anything about Machine 1.
 
 Authority:
@@ -300,6 +305,7 @@ 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:`, `RECOVERY_*` markers are not implemented (no wiring; cut 5).
 
 ---
 
@@ -357,7 +363,7 @@ main design point of this contract.
 
 - **P-1 (PROPOSED).** Continuity objects are stored through `ss_transact` as
   `ss_object{kind = 16|17|18|20, version = 1, bytes = canonical plaintext}`.
-  **Read side IMPLEMENTED, host PASS (cut 3); write side (provision, commit) is cut 4.** Evidence:
+  **IMPLEMENTED, host PASS: read side cut 3, write side (provision, commit, resume) cut 4 (`cr_bind_sealed_sink` -> `ss_transact`, one call per transaction, at most 3 objects, order AgentState, WAL, Manifest).** Evidence:
   `test_continuity_resolve.c` writes all four kinds with `ss_transact` at version 1 and `cr_resolve`
   reads them back through the claims (`t_resolved`, `t_orphans`, `t_references`, at 512 and 4096 byte
   blocks).
@@ -423,6 +429,7 @@ main design point of this contract.
   one transaction record, so the Store v1 catalog bound (4096 entries,
   store/v1.rs:12) is reached in fewer continuity commits than in Rust. ADR 0016
   already defers compaction; the C gate must report the count, not hide it.
+  **MEASURED (cut 4, host, `t_catalog_bound`, real sealed Store):** provisioning leaves 4 catalog entries (root, state, manifest, transaction record). Each commit adds its payload objects plus the manifest plus one transaction record: a plain resume 2 entries, a commit with one WAL segment 3. After provisioning and 64 one-record WAL commits the catalog holds **196** entries (4 + 64 x 3), at 4096 and at 512 byte blocks. The 65th WAL segment is refused (`Limit "cortex WAL needs compaction"`, nothing written), so the WAL cap is reached long before the 4096-entry catalog bound. Resumes alone are the fastest way to fill the catalog: (4096 - 4) / 2 = 2046 resumes in theory. **Run to exhaustion (`CK_K2_FULL=1`, slow, about 3 minutes, not part of `make test`):** in a 16384-unit (64 MiB) Store region at 4096 byte blocks, 915 resumes after provisioning succeeded and the 916th returned `Store rc=-205` (`NoSpace`), at 1834 of 4096 catalog entries. So the limit reached first is **Store space (append-only, no reclaim), not the catalog bound**: about 18 units (72 KiB) per resume at that depth. Either refusal arrives as `CR_STORE` with nothing half written (the last transaction failed cleanly). A real boot disk has a larger Store region, so the practical bound there is the catalog (<= 2046 resumes) or space, whichever is smaller; UNVERIFIED for any real partition size. Compaction stays deferred (ADR 0016:96-98), so a long-lived store needs it; this is the number the gate reports.
 - **K-3 Identity loss looks different.** The Rust campaign flips byte 20 of the
   AgentRoot's first unit (crates/aienos-store-tool/src/main.rs:177-201,
   qemu_recovery_test.sh:168). In the sealed Store that byte is ciphertext, so
@@ -601,17 +608,17 @@ M4_CONTINUITY:
 
 | id | mutation | must turn FAIL |
 |---|---|---|
-| MC-1 | resume provisions when Unprovisioned | 82, 87a |
+| MC-1 | resume provisions when Unprovisioned: `CM_MUTANT_RESUME_PROVISIONS`, IMPLEMENTED, killed (cut 4) | 82, 87a |
 | MC-2 | drop 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-3 | resume skips the commit (no incarnation + 1) | 84, 85, 85a, 87b |
+| MC-3 | resume skips the commit (no incarnation + 1): `CM_MUTANT_RESUME_NO_COMMIT`, IMPLEMENTED, killed (cut 4) | 84, 85, 85a, 87b |
 | MC-4 | manifest chain check ignores `previous`: `CR_MUTANT_IGNORE_PREVIOUS`, IMPLEMENTED, killed (cut 3) | 87e |
 | MC-5 | accept `format_version != 0` or nonzero reserved bytes | 87h, D-2 |
 | MC-6 | `child_branch_id` index little-endian | D-1, 87i |
-| MC-7 | provision allowed when a root exists | 83a, 87c |
-| MC-8 | provision or commit split into two transactions (manifest after payload) | 86-86f, 87g |
-| MC-9 | `writable` check removed (commit on degraded mount) | 87, 87f |
-| MC-10 | agent id from a fixed value instead of RNDR | 83b |
-| MC-11 | WAL segment truncated silently at the size bound (K-1) instead of Limit | C size-bound test (PROPOSED) |
+| MC-7 | provision allowed when a root exists: `CM_MUTANT_PROVISION_WITH_ROOT`, IMPLEMENTED, killed (cut 4) | 83a, 87c |
+| MC-8 | provision 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-9 | `writable` 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-10 | agent id from a fixed value instead of RNDR: `CM_MUTANT_FIXED_AGENT`, IMPLEMENTED, killed (cut 4) | 83b |
+| MC-11 | WAL 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-12 | Conflict check skipped (first root used): `CR_MUTANT_SKIP_CONFLICT`, IMPLEMENTED, killed (cut 3) | 87d |
 | MC-13 | fork-count sum unchecked (wraps): `CC_MUTANT_UNCHECKED_FORK_SUM`, IMPLEMENTED, killed | 87i, `state_forksum_overflow` (D-1, D-2) |
 | MC-14 | golden mismatch only the vectors see (manifest WAL id 63 replaced by id 0): `CC_MUTANT_MANIFEST_LAST_WAL_ZERO`, IMPLEMENTED, killed | D-1 |
@@ -634,8 +641,7 @@ M4_RECOVERY:
 
 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). PROPOSED: the C
-gate adds one.
+(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.
 
 ---
 
@@ -696,3 +702,24 @@ 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).
+
+| item | Rust | C (cut 4) | effect |
+|---|---|---|---|
+| provision over orphans | `provision` checks only that no root exists (continuity.rs:727-730); orphan manifest/state/WAL objects do not stop it | refuses: provision resolves first and returns the resolve outcome (`Corrupt: continuity objects without an agent root`), nothing written | stricter, 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 broken | AlreadyProvisioned (a root exists) | the resolve outcome (Corrupt, Limit or Store) | still a refusal; the class differs, the marker says why |
+| provision with two roots | AlreadyProvisioned | AlreadyProvisioned (Conflict counts as "a root exists") | same |
+| provision with no entropy | the caller (nvme_read.rs:1184-1193) prints `NO_ENTROPY` before calling `provision` | `cr_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 refuses | the refusal is inside the library, so no caller can mint without entropy; order: ReadOnly, AlreadyProvisioned/orphans, NoEntropy |
+| zero agent id | Corrupt("zero agent id") (:731) | same, from the drawn bytes (unreachable with a working rng: `ck_rng_fill` refuses repeated words) | same |
+| `provisioned_generation` | `store.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 commit | same value |
+| resume returns | `(Continuity, committed)` with the full record list | `cr_view` (count + `memory` digest) and `*committed` | as 9.1 |
+| commit sees a stale `current` | not 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 overwrite | UNVERIFIED by a dedicated test; the chain check (INV-6, `t_chain`, cut 3) is what catches it |
+| object limits | AgentState 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 whole | C-only Limit, tested at the bound (`t_size_bound`); a 65-record segment is `Limit "WAL segment record count"` as in Rust |
+| 65th WAL segment | `Limit("cortex WAL needs compaction")` | same text; 64 segments commit, the 65th is refused with nothing written | same |
+| marker text for a Store error | `STOP (<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 spelling | the QEMU rows for store-error cases will be DIFFERS |
+| crash campaign | 7 Store checkpoints (kill points) per commit; provisioning not cut | 9 (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 order | four RNDR words stored little-endian, word 0 first | whatever `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 |
diff --git a/native/kernel/GATES.md b/native/kernel/GATES.md
index 2515ff1f..171822e5 100644
--- a/native/kernel/GATES.md
+++ b/native/kernel/GATES.md
@@ -333,10 +333,10 @@ The default `make full` image must carry no crash hook string (Makefile
 
 ## M4 continuity: scripts/qemu_continuity_test.sh -> CK `M4_CONTINUITY`
 
-Contract: `native/kernel/CONTINUITY_RECOVERY_CONTRACT.md` (SPEC, NOT_RUN). One row per Rust check: rows 81-87 are the
+Contract: `native/kernel/CONTINUITY_RECOVERY_CONTRACT.md` (IMPLEMENTED host PASS, QEMU NOT_RUN, hardware NOT_RUN). One row per Rust check: rows 81-87 are the
 QEMU PASS lines of `scripts/qemu_continuity_test.sh` (receipt `evidence/continuity_qemu_2026-09-25.md`), rows
 87a-87i are the host tests `cargo test -p aienos-kernel --lib continuity`
-(`crates/aienos-kernel/src/continuity_tests.rs`). The C continuity codec (`svc/continuity_codec.c`, cuts 1-2) and the C resolve + challenge/HMAC code (`svc/continuity_resolve.c`, cut 3, run over the real sealed Store in a file) have host tests only, with no kernel wiring and no QEMU run: rows 87a, 87d-87f, 87h-87k, 91i, 91k and 91m-91p below say HOST PASS (for the half that has code, where stated) for those host tests; no gate row is QEMU PASS and `M4_CONTINUITY` stays NOT_RUN. Every other row is NOT_RUN.
+(`crates/aienos-kernel/src/continuity_tests.rs`). The C continuity codec (`svc/continuity_codec.c`, cuts 1-2) and the C resolve + challenge/HMAC code (`svc/continuity_resolve.c`, cut 3, run over the real sealed Store in a file) have host tests only, with no kernel wiring and no QEMU run (cut 4 adds provision, commit and resume, `svc/continuity_commit.c`, same host-only status): rows 87a-87i, 91i, 91k and 91m-91p below say HOST PASS (for the half that has code, where stated) for those host tests; no gate row is QEMU PASS and `M4_CONTINUITY` stays NOT_RUN. Every other row is NOT_RUN.
 
 | # | Rust check | CK gate | Status |
 | --- | --- | --- | --- |
@@ -356,13 +356,13 @@ QEMU PASS lines of `scripts/qemu_continuity_test.sh` (receipt `evidence/continui
 | 86e | SIGKILL at `after_superblock_write`: same agent, old or new memory | M4_CONTINUITY | NOT_RUN (MISSING_IMPLEMENTATION; C name `after_inactive_superblock`; the sealed Store adds two anchor checkpoints, contract section 6.1) |
 | 86f | SIGKILL at `after_final_flush`: same agent, new memory | M4_CONTINUITY | NOT_RUN (MISSING_IMPLEMENTATION) |
 | 87 | malformed peer superblock: `CONTINUITY: RESUMED_READONLY`, same agent and memory, image unchanged (:196-205) | M4_CONTINUITY | NOT_RUN (MISSING_IMPLEMENTATION) |
-| 87a | host `unprovisioned_store_never_mints_an_identity` (continuity_tests.rs:84) | M4_CONTINUITY (host) | HOST PASS for the resolve half (cut 3, `test_continuity_resolve` (`make -C native/kernel test`, real sealed Store in a file): empty formatted store is Unprovisioned, kind 19 and unrelated kinds ignored, resolve writes no block; the no-mint-on-resume half is cut 4); gate NOT_RUN |
-| 87b | host `provision_then_cold_restart_returns_the_same_identity_and_memory` (:97) | M4_CONTINUITY (host) | NOT_RUN (MISSING_IMPLEMENTATION) |
-| 87c | host `provisioning_twice_is_refused` (:142) | M4_CONTINUITY (host) | NOT_RUN (MISSING_IMPLEMENTATION) |
+| 87a | host `unprovisioned_store_never_mints_an_identity` (continuity_tests.rs:84) | M4_CONTINUITY (host) | HOST PASS for the resolve half (cut 3, `test_continuity_resolve` (`make -C native/kernel test`, real sealed Store in a file): empty formatted store is Unprovisioned, kind 19 and unrelated kinds ignored, resolve writes no block; resume on an Unprovisioned store returns Unprovisioned, writes no block and mints nothing, `test_continuity_commit` cut 4, mutant MC-1 `CM_MUTANT_RESUME_PROVISIONS` killed); gate NOT_RUN |
+| 87b | host `provision_then_cold_restart_returns_the_same_identity_and_memory` (:97) | M4_CONTINUITY (host) | HOST PASS (cut 4, `test_continuity_commit` (`make -C native/kernel test`, real sealed Store in a file, 4096 and 512 byte blocks): provision, remember (fork + record in one transaction), then 6 cold restarts return the same agent, the same `memory=`, 2 branches, incarnation and sequence growing by one each; markers PROVISIONED, RESUMED, REMEMBERED, RESUMED_READONLY match the format of nvme_read.rs:1118-1143; mutants MC-3 `CM_MUTANT_RESUME_NO_COMMIT`, MC-10 `CM_MUTANT_FIXED_AGENT` killed); gate NOT_RUN |
+| 87c | host `provisioning_twice_is_refused` (:142) | M4_CONTINUITY (host) | HOST PASS (cut 4, `test_continuity_commit`: second provision is AlreadyProvisioned (also with two roots), image byte for byte unchanged; provision over orphans is Corrupt (C is stricter than Rust, contract 9.2), no entropy is NO_ENTROPY with nothing written; mutant MC-7 `CM_MUTANT_PROVISION_WITH_ROOT` killed); gate NOT_RUN |
 | 87d | host `two_roots_stop_with_conflict` (:152) | M4_CONTINUITY (host) | HOST PASS (cut 3, `test_continuity_resolve` (`make -C native/kernel test`, real sealed Store in a file): two roots give Conflict, mutant MC-12 `CR_MUTANT_SKIP_CONFLICT` killed); gate NOT_RUN (no QEMU, no kernel wiring) |
 | 87e | host `forked_or_gapped_manifest_chains_are_corrupt` (:178) | M4_CONTINUITY (host) | HOST PASS (cut 3, `test_continuity_resolve` (`make -C native/kernel test`, real sealed Store in a file): wrong previous, absent previous, sequence gap, fork, foreign root, root without manifest are Corrupt with the Rust reason text; mutant MC-4 `CR_MUTANT_IGNORE_PREVIOUS` killed); gate NOT_RUN |
-| 87f | host `degraded_mount_resumes_read_only` (:221) | M4_CONTINUITY (host) | HOST PASS for the resolve half (cut 3, `test_continuity_resolve` (`make -C native/kernel test`, real sealed Store in a file): K-5 answered, ss_open returns 0 on a malformed-peer mount, resolve returns the same agent and memory, `cr_writable` is read-only; the committed=false resume half is cut 4); gate NOT_RUN |
-| 87g | host `a_crash_at_every_write_of_a_commit_leaves_old_or_new_never_a_third_state` (:242) | M4_CONTINUITY (host) | NOT_RUN (MISSING_IMPLEMENTATION) |
+| 87f | host `degraded_mount_resumes_read_only` (:221) | M4_CONTINUITY (host) | HOST PASS for the resolve half (cut 3, `test_continuity_resolve` (`make -C native/kernel test`, real sealed Store in a file): K-5 answered, ss_open returns 0 on a malformed-peer mount, resolve returns the same agent and memory, `cr_writable` is read-only; on a degraded mount resume returns the verified view with committed=0 (`RESUMED_READONLY`), commit and provision return ReadOnly, image unchanged, `test_continuity_commit` cut 4; mutant MC-9 `CM_MUTANT_NO_WRITABLE_CHECK` killed); gate NOT_RUN |
+| 87g | host `a_crash_at_every_write_of_a_commit_leaves_old_or_new_never_a_third_state` (:242) | M4_CONTINUITY (host) | HOST PASS (cut 4, `test_continuity_commit`: power cut at all 9 checkpoints (ST_CP_* 0-6, SS_CP_BEFORE_ANCHOR, SS_CP_AFTER_ANCHOR) and at every block boundary (10 at 4096 byte blocks, 73 at 512) of a commit AND of provisioning; after every cut the store reopens and resolves to exactly the old or exactly the new state, and keeps working; checkpoints 0-4 old, 5 and 6 and both anchor points new; mutant MC-8 `CM_MUTANT_SPLIT_TXN` killed); gate NOT_RUN |
 | 87h | host `encodings_round_trip_and_reject_tampering` (:286) | M4_CONTINUITY (host) | HOST PASS for the C codec twin (`make -C native/kernel test`, `test_continuity_codec`: round trips, one refusal per rule, every single-bit flip of every golden vector decodes as in Rust, D-2); gate NOT_RUN (no QEMU, no kernel wiring) |
 | 87i | host `branch_table_validation_rejects_broken_lineage` (:328) | M4_CONTINUITY (host) | HOST PASS for the C codec twin (`cc_state_validate`, incl. the checked fork-count sum and hostile fork counts); gate NOT_RUN (no QEMU, no kernel wiring) |
 | 87j | D-1 golden vectors (contract 6.3): Rust-emitted canonical bytes and ObjectIds for 22 vectors, reproduced by C from `native/kernel/tests/fixtures/continuity_vectors.txt`; tampered bytes, ObjectId and verdicts are refused (`cargo test -p aienos-kernel --lib continuity_vectors` fails on fixture drift) | M4_CONTINUITY (host) | HOST PASS (`make -C native/kernel test`, `continuity-mutants`: golden and skip-D1 mutants killed); challenges and HMAC responses (4 fixture lines) are now reproduced byte for byte by C (cut 3, `test_continuity_resolve`); gate NOT_RUN |
diff --git a/native/kernel/Makefile b/native/kernel/Makefile
index edf67e33..4cb70cd5 100644
--- a/native/kernel/Makefile
+++ b/native/kernel/Makefile
@@ -60,6 +60,9 @@
 #   make continuity-resolve-mutants
 #                        TEST-only -D mutants of svc/continuity_resolve.c must each fail
 #                        test_continuity_resolve -> CK_CONTINUITY_RESOLVE_MUTANTS: PASS
+#   make continuity-commit-mutants
+#                        TEST-only -D mutants of svc/continuity_commit.c (and MC-11 of the codec) must
+#                        each fail test_continuity_commit -> CK_CONTINUITY_COMMIT_MUTANTS: PASS
 #   make stage-test | stage-sanitize | stage-free   stage host tests (stage.mk)
 #   make print-kcflags   flags stage code must be built with
 #   make udp-echo        host UDP echo helper for scripts/qemu_ck_net_test.sh:
@@ -494,7 +497,7 @@ HOST_SRCS := $(KDIR)/core/fmt.c $(KDIR)/core/acpi.c $(KDIR)/core/smmu.c $(KDIR)/
 	$(KDIR)/mm/pt.c $(KDIR)/mm/heap.c $(KDIR)/core/sched.c $(KDIR)/core/ipc.c $(KDIR)/core/entropy.c \
 	$(KDIR)/core/handoff_check.c
 TESTS := test_fmt test_frames test_pt test_acpi test_heap test_smmu test_sched test_ipc test_artifact test_entropy test_handoff \
-	test_continuity_codec test_continuity_resolve
+	test_continuity_codec test_continuity_resolve test_continuity_commit
 HCFLAGS := -std=gnu11 -O1 -g -Wall -Wextra -Werror -I$(KDIR)/core -I$(KDIR)/mm -I$(KDIR)/tests -I$(BOOT)
 SANFLAGS := -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer
 
@@ -574,7 +577,7 @@ $(OUT)/host-san/test_continuity_codec: $(KDIR)/tests/test_continuity_codec.c $(C
 	@mkdir -p $(dir $@)
 	$(HOSTCC) $(HCFLAGS) $(SANFLAGS) $(CC_HOST_INC) $(CC_FIXTURE_DEF) -o $@ $< $(CC_HOST_SRCS)
 
-continuity-mutants: $(OUT)/host/test_continuity_codec continuity-resolve-mutants
+continuity-mutants: $(OUT)/host/test_continuity_codec continuity-resolve-mutants continuity-commit-mutants
 	@mkdir -p $(OUT)/host-mut; fail=0; \
 	$(OUT)/host/test_continuity_codec > $(OUT)/host-mut/base.log 2>&1 || { echo "unmutated test_continuity_codec fails"; fail=1; }; \
 	for m in $(CC_MUTANTS); do \
@@ -640,6 +643,50 @@ continuity-resolve-mutants: $(OUT)/host/test_continuity_resolve
 	done; \
 	if [ $$fail = 0 ]; then echo "CK_CONTINUITY_RESOLVE_MUTANTS: PASS"; else echo "CK_CONTINUITY_RESOLVE_MUTANTS: FAIL"; exit 1; fi
 
+
+# Continuity provision/commit/resume (C port cut 4): host test over the REAL sealed
+# Store in a file with the real ck_rng over a mocked RNDR, power cuts at every
+# checkpoint and block boundary, and TEST-only -D mutants, each of which must make
+# the test print its FAIL verdict. Mutant flags are refused under
+# CK_HARDWARE_STAGING (svc/continuity_commit.h; MC-11 in svc/continuity_codec.h).
+CM_HOST_SRCS := $(KDIR)/svc/continuity_commit.c $(CR_HOST_SRCS) $(KDIR)/core/entropy.c
+CM_HOST_INC := $(CR_HOST_INC) -I$(KDIR)/core
+CM_HOST_DEPS := $(CM_HOST_SRCS) $(wildcard $(KDIR)/svc/continuity_*.h) $(KDIR)/core/entropy.h \
+	$(wildcard $(NATIVE)/store/*.h $(NATIVE)/m5/*.h $(NATIVE)/disk/*.h $(NATIVE)/crypto/*.h) $(KDIR)/tests/ck_test.h
+# MC-1 resume provisions, MC-3 resume skips the commit, MC-7 provision with a root,
+# MC-8 split transaction, MC-9 writable check removed, MC-10 fixed agent id,
+# MC-11 silent truncation (the codec's CC_MUTANT_TRUNCATE_AT_CAP).
+CM_MUTANTS := CM_MUTANT_RESUME_PROVISIONS CM_MUTANT_RESUME_NO_COMMIT CM_MUTANT_PROVISION_WITH_ROOT \
+	CM_MUTANT_SPLIT_TXN CM_MUTANT_NO_WRITABLE_CHECK CM_MUTANT_FIXED_AGENT CC_MUTANT_TRUNCATE_AT_CAP
+
+$(OUT)/host/test_continuity_commit: $(KDIR)/tests/test_continuity_commit.c $(CM_HOST_DEPS)
+	@mkdir -p $(dir $@)
+	$(HOSTCC) $(HCFLAGS) $(CM_HOST_INC) -o $@ $< $(CM_HOST_SRCS)
+
+$(OUT)/host-san/test_continuity_commit: $(KDIR)/tests/test_continuity_commit.c $(CM_HOST_DEPS)
+	@mkdir -p $(dir $@)
+	$(HOSTCC) $(HCFLAGS) $(SANFLAGS) $(CM_HOST_INC) -o $@ $< $(CM_HOST_SRCS)
+
+continuity-commit-mutants: $(OUT)/host/test_continuity_commit
+	@mkdir -p $(OUT)/host-mut; fail=0; \
+	$(OUT)/host/test_continuity_commit > $(OUT)/host-mut/commit_base.log 2>&1 || { echo "unmutated test_continuity_commit fails"; fail=1; }; \
+	for m in $(CM_MUTANTS); do \
+	  b=$(OUT)/host-mut/test_continuity_commit_$$m; \
+	  if ! $(HOSTCC) $(HCFLAGS) $(CM_HOST_INC) -D$$m -o $$b $(KDIR)/tests/test_continuity_commit.c $(CM_HOST_SRCS); then \
+	    echo "mutant $$m: does not build (FAIL)"; fail=1; continue; fi; \
+	  if $$b > $$b.log 2>&1; then echo "mutant $$m: SURVIVED (FAIL)"; fail=1; \
+	  elif grep -q "^test_continuity_commit: FAIL" $$b.log; then \
+	    echo "mutant $$m: killed ($$(grep -c '^  FAIL ' $$b.log) checks failed)"; \
+	  else echo "mutant $$m: no FAIL verdict (crashed?) (FAIL)"; fail=1; fi; \
+	done; \
+	for m in $(CM_MUTANTS); do \
+	  if $(HOSTCC) $(HCFLAGS) $(CM_HOST_INC) -DCK_HARDWARE_STAGING=1 -D$$m \
+	      -fsyntax-only $(KDIR)/svc/continuity_commit.c 2>/dev/null; then \
+	    echo "mutant flag $$m accepted under CK_HARDWARE_STAGING (FAIL)"; fail=1; \
+	  else echo "mutant flag $$m refused under CK_HARDWARE_STAGING"; fi; \
+	done; \
+	if [ $$fail = 0 ]; then echo "CK_CONTINUITY_COMMIT_MUTANTS: PASS"; else echo "CK_CONTINUITY_COMMIT_MUTANTS: FAIL"; exit 1; fi
+
 ART_TOOL := $(OUT)/host/ck_artifact_tool
 $(ART_TOOL): $(KDIR)/tools/ck_artifact_tool.c $(ART_HOST_DEPS)
 	@mkdir -p $(dir $@)
diff --git a/native/kernel/svc/continuity_commit.c b/native/kernel/svc/continuity_commit.c
new file mode 100644
index 00000000..01e8b44a
--- /dev/null
+++ b/native/kernel/svc/continuity_commit.c
@@ -0,0 +1,386 @@
+/* continuity_commit.c -- see continuity_commit.h. */
+#include <string.h>
+
+#include "continuity_commit.h"
+#include "../../store/store_v1.h"
+
+static int map_cc(int rc, const char *why_in, const char **why)
+{
+    if (rc == CC_OK) return 0;
+    if (why) *why = why_in ? why_in : "continuity object";
+    if (rc == CC_E_CORRUPT) return CR_CORRUPT;
+    if (rc == CC_E_LIMIT) return CR_LIMIT;
+    return CR_E_ARG;
+}
+
+static int is_zero32(const uint8_t *p)
+{
+    uint8_t a = 0;
+    for (int i = 0; i < 32; i++) a |= p[i];
+    return a == 0;
+}
+
+/* INV-8: ONE transaction. (MC-8 mutant: the manifest, always last, goes alone.) */
+static int do_transact(const struct cr_sink *snk, const struct cr_wobj *o, size_t n, int *store_rc)
+{
+    int rc;
+#ifdef CM_MUTANT_SPLIT_TXN
+    if (n > 1) {
+        rc = snk->transact(snk->ctx, o, n - 1);
+        if (rc == 0) rc = snk->transact(snk->ctx, o + n - 1, 1);
+    } else
+#endif
+        rc = snk->transact(snk->ctx, o, n);
+    if (rc != 0) {
+        if (store_rc) *store_rc = rc;
+        return CR_STORE;
+    }
+    return 0;
+}
+
+static int writable(const struct cr_source *src)
+{
+#ifdef CM_MUTANT_NO_WRITABLE_CHECK
+    (void)src;
+    return CR_RESOLVED;
+#else
+    return cr_writable(src);
+#endif
+}
+
+static int args_ok(const struct cr_source *src, const struct cr_sink *snk, const struct cr_work *w,
+                   const struct cr_txwork *tw, const struct cr_view *out)
+{
+    return src && snk && snk->transact && w && tw && out;
+}
+
+int cr_provision(const struct cr_source *src, const struct cr_sink *snk, struct cr_work *w,
+                 struct cr_txwork *tw, struct ck_rng *rng, const uint8_t store_uuid[16],
+                 uint8_t source, struct cr_view *out, const char **why, int *store_rc)
+{
+    if (why) *why = NULL;
+    if (store_rc) *store_rc = 0;
+    if (!args_ok(src, snk, w, tw, out) || !rng || !store_uuid || !src->generation ||
+        (source != CC_SOURCE_OPERATOR && source != CC_SOURCE_QUALIFICATION))
+        return CR_E_ARG;
+    memset(out, 0, sizeof *out);
+
+    int o = writable(src); /* INV-11: before anything else */
+    if (o != CR_RESOLVED) return CR_READ_ONLY;
+
+    /* Provision only from Unprovisioned: a root (also two) is AlreadyProvisioned;
+     * orphans, a broken graph or a store error are refused with that outcome. */
+    o = cr_resolve(src, w, &tw->tmp, why, store_rc);
+#ifdef CM_MUTANT_PROVISION_WITH_ROOT
+    if (o == CR_RESOLVED || o == CR_CONFLICT) o = CR_UNPROVISIONED; /* MC-7 */
+#endif
+    if (o == CR_RESOLVED || o == CR_CONFLICT) return CR_ALREADY_PROVISIONED;
+    if (o != CR_UNPROVISIONED) return o;
+
+    uint8_t agent[32];
+#ifdef CM_MUTANT_FIXED_AGENT
+    memset(agent, 0x42, sizeof agent); /* MC-10 */
+    (void)rng;
+#else
+    if (ck_rng_fill(rng, agent, sizeof agent) != 0) return CR_NO_ENTROPY; /* no fallback */
+#endif
+    if (is_zero32(agent)) {
+        if (why) *why = "zero agent id";
+        return CR_CORRUPT;
+    }
+    uint64_t gen = src->generation(src->ctx);
+    if (gen == UINT64_MAX) {
+        if (why) *why = "store generation";
+        return CR_LIMIT;
+    }
+
+    struct cc_root root;
+    memset(&root, 0, sizeof root);
+    memcpy(root.agent_id, agent, 32);
+    memcpy(root.store_uuid, store_uuid, 16);
+    cc_root_branch_id(agent, root.root_branch);
+    root.provisioned_generation = gen + 1;
+    root.source = source;
+    uint8_t root_id[32], state_id[32];
+    size_t n_root = 0, n_state = 0, n_man = 0;
+    const char *y = NULL;
+    int rc = cc_root_encode(&root, tw->b[0], sizeof tw->b[0], &n_root, &y);
+    if ((o = map_cc(rc, y, why))) return o;
+    if (cc_object_id(CC_KIND_AGENT_ROOT, tw->b[0], n_root, root_id) != CC_OK) return CR_E_ARG;
+    cc_state_genesis(&tw->state, agent, 1);
+    rc = cc_state_encode(&tw->state, tw->b[1], sizeof tw->b[1], &n_state, &y);
+    if ((o = map_cc(rc, y, why))) return o;
+    if (cc_object_id(CC_KIND_AGENT_STATE, tw->b[1], n_state, state_id) != CC_OK) return CR_E_ARG;
+
+    memset(&tw->man, 0, sizeof tw->man);
+    memcpy(tw->man.root, root_id, 32);
+    tw->man.sequence = 1;
+    tw->man.incarnation = 1;
+    memcpy(tw->man.agent_state, state_id, 32);
+    rc = cc_manifest_encode(&tw->man, tw->b[2], sizeof tw->b[2], &n_man, &y);
+    if ((o = map_cc(rc, y, why))) return o;
+
+    struct cr_wobj objs[3] = {
+        {CC_KIND_AGENT_ROOT, CC_STORE_OBJECT_VERSION, tw->b[0], n_root},
+        {CC_KIND_AGENT_STATE, CC_STORE_OBJECT_VERSION, tw->b[1], n_state},
+        {CC_KIND_MANIFEST, CC_STORE_OBJECT_VERSION, tw->b[2], n_man},
+    };
+    if ((o = do_transact(snk, objs, 3, store_rc))) return o;
+    return cr_resolve(src, w, out, why, store_rc);
+}
+
+int cr_commit(const struct cr_source *src, const struct cr_sink *snk, struct cr_work *w,
+              struct cr_txwork *tw, const struct cr_view *cur, const struct cr_update *up,
+              int new_incarnation, struct cr_view *out, const char **why, int *store_rc)
+{
+    if (why) *why = NULL;
+    if (store_rc) *store_rc = 0;
+    if (!args_ok(src, snk, w, tw, out) || !cur || !up || cur == out) return CR_E_ARG;
+    if (up->n_rec && !up->rec) return CR_E_ARG;
+    memset(out, 0, sizeof *out);
+
+    int o = writable(src);
+    if (o != CR_RESOLVED) return CR_READ_ONLY;
+
+    if (cur->manifest.sequence == UINT64_MAX) {
+        if (why) *why = "manifest sequence";
+        return CR_LIMIT;
+    }
+    uint64_t seq = cur->manifest.sequence + 1;
+    struct cr_wobj objs[3];
+    size_t n = 0, lens[3] = {0, 0, 0};
+    const char *y = NULL;
+    int rc;
+
+    memset(&tw->man, 0, sizeof tw->man);
+    memcpy(tw->man.agent_state, cur->manifest.agent_state, 32);
+    tw->man.n_wal = cur->manifest.n_wal;
+    memcpy(tw->man.wal, cur->manifest.wal, sizeof tw->man.wal);
+
+    if (up->state) {
+        if (memcmp(up->state->agent_id, cur->root.agent_id, 32) != 0) {
+            if (why) *why = "agent state belongs to another agent";
+            return CR_CORRUPT;
+        }
+        memcpy(&tw->state, up->state, sizeof tw->state);
+        tw->state.written_at = seq; /* INV-9 */
+        rc = cc_state_encode(&tw->state, tw->b[n], sizeof tw->b[n], &lens[n], &y);
+        if ((o = map_cc(rc, y, why))) return o;
+        if (cc_object_id(CC_KIND_AGENT_STATE, tw->b[n], lens[n], tw->man.agent_state) != CC_OK)
+            return CR_E_ARG;
+        objs[n] = (struct cr_wobj){CC_KIND_AGENT_STATE, CC_STORE_OBJECT_VERSION, tw->b[n], lens[n]};
+        n++;
+    }
+
+    if (up->n_rec) {
+        if (cur->manifest.n_wal >= CC_MAX_WAL_SEGMENTS) {
+            if (why) *why = "cortex WAL needs compaction";
+            return CR_LIMIT;
+        }
+        if (up->n_rec > CC_MAX_WAL_RECORDS) {
+            if (why) *why = "WAL segment record count";
+            return CR_LIMIT;
+        }
+        memset(&tw->wal, 0, sizeof tw->wal);
+        tw->wal.sequence = seq;
+        tw->wal.n = up->n_rec;
+        for (uint32_t i = 0; i < up->n_rec; i++) tw->wal.rec[i] = up->rec[i];
+        rc = cc_wal_encode(&tw->wal, tw->b[n], sizeof tw->b[n], &lens[n], &y);
+        if ((o = map_cc(rc, y, why))) return o;
+        if (cc_object_id(CC_KIND_CORTEX_WAL, tw->b[n], lens[n], tw->man.wal[tw->man.n_wal]) != CC_OK)
+            return CR_E_ARG;
+        tw->man.n_wal++;
+        objs[n] = (struct cr_wobj){CC_KIND_CORTEX_WAL, CC_STORE_OBJECT_VERSION, tw->b[n], lens[n]};
+        n++;
+    }
+
+    uint64_t inc = cur->manifest.incarnation;
+    if (new_incarnation) {
+        if (inc == UINT64_MAX) {
+            if (why) *why = "incarnation";
+            return CR_LIMIT;
+        }
+        inc++;
+    }
+    memcpy(tw->man.root, cur->root_id, 32);
+    memcpy(tw->man.previous, cur->manifest_id, 32);
+    tw->man.sequence = seq;
+    tw->man.incarnation = inc;
+    rc = cc_manifest_encode(&tw->man, tw->b[n], sizeof tw->b[n], &lens[n], &y);
+    if ((o = map_cc(rc, y, why))) return o;
+    objs[n] = (struct cr_wobj){CC_KIND_MANIFEST, CC_STORE_OBJECT_VERSION, tw->b[n], lens[n]};
+    n++;
+
+    if ((o = do_transact(snk, objs, n, store_rc))) return o;
+    return cr_resolve(src, w, out, why, store_rc);
+}
+
+int cr_resume(const struct cr_source *src, const struct cr_sink *snk, struct cr_work *w,
+              struct cr_txwork *tw, struct cr_view *out, int *committed, const char **why,
+              int *store_rc)
+{
+    if (committed) *committed = 0;
+    if (why) *why = NULL;
+    if (store_rc) *store_rc = 0;
+    if (!args_ok(src, snk, w, tw, out)) return CR_E_ARG;
+    struct cr_view *cur = &tw->tmp;
+    int o = cr_resolve(src, w, cur, why, store_rc);
+#ifdef CM_MUTANT_RESUME_PROVISIONS
+    if (o == CR_UNPROVISIONED) { /* MC-1: a resume that mints an identity */
+        static const uint8_t fake_uuid[16] = {0};
+        uint8_t agent[32];
+        memset(agent, 0x99, sizeof agent);
+        struct cc_root root;
+        memset(&root, 0, sizeof root);
+        memcpy(root.agent_id, agent, 32);
+        memcpy(root.store_uuid, fake_uuid, 16);
+        cc_root_branch_id(agent, root.root_branch);
+        root.provisioned_generation = src->generation ? src->generation(src->ctx) + 1 : 1;
+        root.source = CC_SOURCE_OPERATOR;
+        uint8_t rid[32], sid[32];
+        size_t nr = 0, ns = 0, nm = 0;
+        cc_root_encode(&root, tw->b[0], sizeof tw->b[0], &nr, NULL);
+        cc_object_id(CC_KIND_AGENT_ROOT, tw->b[0], nr, rid);
+        cc_state_genesis(&tw->state, agent, 1);
+        cc_state_encode(&tw->state, tw->b[1], sizeof tw->b[1], &ns, NULL);
+        cc_object_id(CC_KIND_AGENT_STATE, tw->b[1], ns, sid);
+        memset(&tw->man, 0, sizeof tw->man);
+        memcpy(tw->man.root, rid, 32);
+        tw->man.sequence = 1;
+        tw->man.incarnation = 1;
+        memcpy(tw->man.agent_state, sid, 32);
+        cc_manifest_encode(&tw->man, tw->b[2], sizeof tw->b[2], &nm, NULL);
+        struct cr_wobj objs[3] = {
+            {CC_KIND_AGENT_ROOT, 1, tw->b[0], nr},
+            {CC_KIND_AGENT_STATE, 1, tw->b[1], ns},
+            {CC_KIND_MANIFEST, 1, tw->b[2], nm},
+        };
+        if (do_transact(snk, objs, 3, store_rc) == 0) o = cr_resolve(src, w, cur, why, store_rc);
+    }
+#endif
+    if (o != CR_RESOLVED) {
+        memset(out, 0, sizeof *out);
+        return o; /* INV-4: Unprovisioned stays Unprovisioned, nothing written */
+    }
+    if (cr_writable(src) != CR_RESOLVED) { /* INV-11: verified view, no commit */
+        memcpy(out, cur, sizeof *out);
+        return CR_RESOLVED;
+    }
+#ifdef CM_MUTANT_RESUME_NO_COMMIT
+    memcpy(out, cur, sizeof *out); /* MC-3: no incarnation + 1 */
+    if (committed) *committed = 1;
+    return CR_RESOLVED;
+#else
+    static const struct cr_update none = {NULL, NULL, 0};
+    o = cr_commit(src, snk, w, tw, cur, &none, 1, out, why, store_rc);
+    if (o == CR_RESOLVED && committed) *committed = 1;
+    return o;
+#endif
+}
+
+/* ---- markers ---- */
+struct mb {
+    char *p;
+    size_t cap, n;
+    int over;
+};
+static void mb_s(struct mb *b, const char *s)
+{
+    for (; *s; s++) {
+        if (b->n + 1 < b->cap) b->p[b->n] = *s;
+        else b->over = 1;
+        b->n++;
+    }
+}
+static void mb_u(struct mb *b, uint64_t v)
+{
+    char t[24];
+    int i = 0;
+    do t[i++] = (char)('0' + v % 10);
+    while ((v /= 10) != 0);
+    char o[24];
+    for (int k = 0; k < i; k++) o[k] = t[i - 1 - k];
+    o[i] = 0;
+    mb_s(b, o);
+}
+static void mb_i(struct mb *b, int v)
+{
+    if (v < 0) {
+        mb_s(b, "-");
+        mb_u(b, (uint64_t)0 - (uint64_t)(int64_t)v);
+    } else
+        mb_u(b, (uint64_t)v);
+}
+static void mb_hex(struct mb *b, const uint8_t *p, size_t n)
+{
+    static const char H[] = "0123456789abcdef";
+    char t[3] = {0, 0, 0};
+    for (size_t i = 0; i < n; i++) {
+        t[0] = H[p[i] >> 4];
+        t[1] = H[p[i] & 15];
+        mb_s(b, t);
+    }
+}
+static size_t mb_done(struct mb *b)
+{
+    if (!b->cap) return 0;
+    if (b->over) {
+        b->p[0] = 0;
+        return 0;
+    }
+    b->p[b->n] = 0;
+    return b->n;
+}
+
+size_t cr_marker_view(char *out, size_t cap, const char *word, const struct cr_view *v)
+{
+    struct mb b = {out, cap, 0, 0};
+    if (!out || !word || !v) return 0;
+    mb_s(&b, "CONTINUITY: ");
+    mb_s(&b, word);
+    mb_s(&b, " agent=");
+    mb_hex(&b, v->root.agent_id, 32);
+    mb_s(&b, " incarnation=");
+    mb_u(&b, v->manifest.incarnation);
+    mb_s(&b, " sequence=");
+    mb_u(&b, v->manifest.sequence);
+    mb_s(&b, " cortex=");
+    mb_u(&b, v->cortex_count);
+    mb_s(&b, " branches=");
+    mb_u(&b, v->state.n);
+    mb_s(&b, " memory=");
+    mb_hex(&b, v->memory, 8);
+    return mb_done(&b);
+}
+
+size_t cr_marker_outcome(char *out, size_t cap, int outcome, const char *why, int store_rc)
+{
+    struct mb b = {out, cap, 0, 0};
+    if (!out) return 0;
+    switch (outcome) {
+    case CR_UNPROVISIONED: mb_s(&b, "CONTINUITY: UNPROVISIONED"); break;
+    case CR_CONFLICT: mb_s(&b, "CONTINUITY: CONFLICT"); break;
+    case CR_NO_ENTROPY: mb_s(&b, "CONTINUITY: NO_ENTROPY"); break;
+    case CR_CORRUPT:
+        mb_s(&b, "CONTINUITY: CORRUPT (");
+        mb_s(&b, why ? why : "continuity unreadable");
+        mb_s(&b, ")");
+        break;
+    case CR_LIMIT:
+        mb_s(&b, "CONTINUITY: STOP (Limit(\"");
+        mb_s(&b, why ? why : "");
+        mb_s(&b, "\"))");
+        break;
+    case CR_STORE:
+        mb_s(&b, "CONTINUITY: STOP (Store(");
+        mb_i(&b, store_rc);
+        mb_s(&b, "))");
+        break;
+    default:
+        mb_s(&b, "CONTINUITY: STOP (");
+        mb_s(&b, cr_outcome_name(outcome));
+        mb_s(&b, ")");
+        break;
+    }
+    return mb_done(&b);
+}
diff --git a/native/kernel/svc/continuity_commit.h b/native/kernel/svc/continuity_commit.h
new file mode 100644
index 00000000..d8d5e59b
--- /dev/null
+++ b/native/kernel/svc/continuity_commit.h
@@ -0,0 +1,99 @@
+/* continuity_commit.h -- C port, cut 4: provision, commit and resume of the
+ * continuity objects over the sealed Store (contract section 1.3-1.5, INV-4,
+ * INV-8..INV-11, K-1, K-2, P-1, P-2).
+ *
+ * Contract: native/kernel/CONTINUITY_RECOVERY_CONTRACT.md. Oracle: the Rust
+ * kernel at aienos 4a116e5: continuity.rs `provision` (:712-772), `commit_with_hook`
+ * (:786-855), `resume` (:859-868), nvme_read.rs `summary`/`stop` (:1118-1155).
+ *
+ * Writes go through cr_sink, one call = ONE Store transaction (INV-8): payload
+ * objects and the manifest together, in the order AgentState, WAL, Manifest.
+ * continuity_resolve_sealed.c binds it to ss_transact (<= SS_MAX_OBJECTS = 8,
+ * this layer writes <= 3). Cross references are logical ObjectIds (P-2).
+ *
+ * Nothing here is wired into the kernel. */
+#ifndef CK_CONTINUITY_COMMIT_H
+#define CK_CONTINUITY_COMMIT_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "continuity_resolve.h"
+#include "entropy.h"
+
+/* TEST-only mutants for the host mutation run (Makefile continuity-mutants).
+ * MC-11 (silent truncation) is CC_MUTANT_TRUNCATE_AT_CAP in continuity_codec.h. */
+#if defined(CK_HARDWARE_STAGING) &&                                                          \
+    (defined(CM_MUTANT_RESUME_PROVISIONS) || defined(CM_MUTANT_RESUME_NO_COMMIT) ||          \
+     defined(CM_MUTANT_PROVISION_WITH_ROOT) || defined(CM_MUTANT_SPLIT_TXN) ||               \
+     defined(CM_MUTANT_NO_WRITABLE_CHECK) || defined(CM_MUTANT_FIXED_AGENT))
+#error "continuity commit mutants are TEST-only and refused under CK_HARDWARE_STAGING"
+#endif
+
+/* One object of a transaction (an application object, not an envelope). */
+struct cr_wobj {
+    uint16_t kind, version;
+    const uint8_t *bytes;
+    size_t len;
+};
+
+/* Write interface: all n objects commit atomically in one Store transaction
+ * or none do. Returns 0 or a store error (passed through as CR_STORE). */
+struct cr_sink {
+    void *ctx;
+    int (*transact)(void *ctx, const struct cr_wobj *objs, size_t n);
+};
+
+/* rs `Update` (continuity.rs:178-184): optional new branch table, optional new
+ * Cortex records (one WAL segment). Records are only read. */
+struct cr_update {
+    const struct cc_state *state; /* NULL = keep the current one */
+    const struct cc_record *rec;  /* NULL / n_rec 0 = no WAL segment */
+    uint32_t n_rec;
+};
+
+/* Caller-owned scratch for the objects of one transaction (static storage). */
+struct cr_txwork {
+    uint8_t b[3][CC_MAX_OBJECT_BYTES];
+    struct cc_state state;
+    struct cc_manifest man;
+    struct cc_wal wal;
+    struct cr_view tmp;
+};
+
+/* rs `provision`. Order of refusals: not writable (CR_READ_ONLY, INV-11);
+ * a root exists (CR_ALREADY_PROVISIONED, also on Conflict); orphans or any
+ * other unreadable state (the resolve outcome: Corrupt, Limit, Store);
+ * no entropy (CR_NO_ENTROPY, nothing written, no fallback); zero agent
+ * (CR_CORRUPT). Writes AgentRoot + genesis AgentState + Manifest 1 in ONE
+ * transaction and returns the resolved view (CR_RESOLVED). `source` is
+ * CC_SOURCE_*. store_uuid is the Store's uuid. */
+int cr_provision(const struct cr_source *src, const struct cr_sink *snk, struct cr_work *w,
+                 struct cr_txwork *tw, struct ck_rng *rng, const uint8_t store_uuid[16],
+                 uint8_t source, struct cr_view *out, const char **why, int *store_rc);
+
+/* rs `commit`: one transaction for the optional state, the optional WAL
+ * segment and the new manifest; then re-resolve into out (must not alias cur).
+ * K-1: an object over 16384 bytes is CR_LIMIT and nothing is written. */
+int cr_commit(const struct cr_source *src, const struct cr_sink *snk, struct cr_work *w,
+              struct cr_txwork *tw, const struct cr_view *cur, const struct cr_update *up,
+              int new_incarnation, struct cr_view *out, const char **why, int *store_rc);
+
+/* rs `resume`: resolve; on a mount that is not Valid return the view with
+ * *committed = 0 (INV-11); else commit incarnation + 1 before returning
+ * (INV-10). Never mints an identity: Unprovisioned stays CR_UNPROVISIONED (INV-4). */
+int cr_resume(const struct cr_source *src, const struct cr_sink *snk, struct cr_work *w,
+              struct cr_txwork *tw, struct cr_view *out, int *committed, const char **why,
+              int *store_rc);
+
+/* ---- serial markers (contract section 3, nvme_read.rs:1118-1155) ----
+ * Write the NUL-terminated line, without newline, into out[0..cap). Return the
+ * length, or 0 when cap is too small. word: "PROVISIONED", "RESUMED",
+ * "RESUMED_READONLY", "REMEMBERED", "COMMITTED". */
+size_t cr_marker_view(char *out, size_t cap, const char *word, const struct cr_view *v);
+/* UNPROVISIONED, CONFLICT, CORRUPT (why), NO_ENTROPY, else STOP (<Rust spelling>).
+ * For CR_STORE the text is `STOP (Store(<rc>))` (rc decimal; Rust prints the
+ * Debug of its own error, which differs). */
+size_t cr_marker_outcome(char *out, size_t cap, int outcome, const char *why, int store_rc);
+
+#endif /* CK_CONTINUITY_COMMIT_H */
diff --git a/native/kernel/svc/continuity_resolve.c b/native/kernel/svc/continuity_resolve.c
index 0e4f0e6c..11e89af0 100644
--- a/native/kernel/svc/continuity_resolve.c
+++ b/native/kernel/svc/continuity_resolve.c
@@ -18,6 +18,7 @@ const char *cr_outcome_name(int o)
     case CR_ALREADY_PROVISIONED: return "AlreadyProvisioned";
     case CR_READ_ONLY: return "ReadOnly";
     case CR_E_ARG: return "Arg";
+    case CR_NO_ENTROPY: return "NoEntropy";
     }
     return "?";
 }
diff --git a/native/kernel/svc/continuity_resolve.h b/native/kernel/svc/continuity_resolve.h
index 066f79ea..063930d2 100644
--- a/native/kernel/svc/continuity_resolve.h
+++ b/native/kernel/svc/continuity_resolve.h
@@ -53,6 +53,7 @@ enum {
     CR_ALREADY_PROVISIONED = 6, /* provision only (cut 4); never returned by resolve */
     CR_READ_ONLY = 7,        /* cr_writable on a mount that is not Valid */
     CR_E_ARG = 8,            /* C only: caller bug (NULL); nothing read */
+    CR_NO_ENTROPY = 9,       /* C only: provision found no entropy (no fallback), nothing written */
 };
 const char *cr_outcome_name(int outcome); /* Rust spelling: "Unprovisioned", ... */
 
@@ -74,6 +75,9 @@ struct cr_source {
     int (*read)(void *ctx, uint32_t i, uint8_t *out, size_t cap, size_t *len);
     /* CR_MOUNT_VALID or CR_MOUNT_DEGRADED. */
     int (*mount_state)(void *ctx);
+    /* Store generation (rs `store.generation()`); NULL for a read-only fake. Provision
+     * needs it (provisioned_generation = generation + 1) and refuses CR_E_ARG without. */
+    uint64_t (*generation)(void *ctx);
 };
 
 /* Objects this layer tracks: kinds 16, 17, 18, 20 (kind 19 is ignored, as in Rust). */
diff --git a/native/kernel/svc/continuity_resolve_sealed.c b/native/kernel/svc/continuity_resolve_sealed.c
index 8822cda2..a0cc4c40 100644
--- a/native/kernel/svc/continuity_resolve_sealed.c
+++ b/native/kernel/svc/continuity_resolve_sealed.c
@@ -32,6 +32,11 @@ static int sealed_read(void *ctx, uint32_t i, uint8_t *out, size_t cap, size_t *
     return 0;
 }
 
+static uint64_t sealed_generation(void *ctx)
+{
+    return ss_generation(ctx);
+}
+
 static int sealed_mount_state(void *ctx)
 {
     const ss_store *s = ctx;
@@ -45,6 +50,7 @@ void cr_bind_sealed(struct cr_source *out, ss_store *s)
     out->entry = sealed_entry;
     out->read = sealed_read;
     out->mount_state = sealed_mount_state;
+    out->generation = sealed_generation;
 }
 
 void cr_state_digest_dev(const st_dev *dev, uint8_t out[32])
@@ -61,3 +67,23 @@ void cr_state_digest_dev(const st_dev *dev, uint8_t out[32])
     sha256_update(&h, raw[1], SV1_UNIT);
     sha256_final(&h, out);
 }
+
+static int sealed_transact(void *ctx, const struct cr_wobj *objs, size_t n)
+{
+    struct cr_sealed_sink *k = ctx;
+    ss_object so[SS_MAX_OBJECTS];
+    if (n == 0 || n > SS_MAX_OBJECTS) return SS_E_ARG;
+    for (size_t i = 0; i < n; i++) {
+        so[i].kind = objs[i].kind;
+        so[i].version = objs[i].version;
+        so[i].bytes = objs[i].bytes;
+        so[i].len = objs[i].len;
+    }
+    return ss_transact(k->s, so, n, k->hook, k->hook_arg, NULL);
+}
+
+void cr_bind_sealed_sink(struct cr_sink *out, struct cr_sealed_sink *ctx)
+{
+    out->ctx = ctx;
+    out->transact = sealed_transact;
+}
diff --git a/native/kernel/svc/continuity_resolve_sealed.h b/native/kernel/svc/continuity_resolve_sealed.h
index d3c9c94f..0b39f8b6 100644
--- a/native/kernel/svc/continuity_resolve_sealed.h
+++ b/native/kernel/svc/continuity_resolve_sealed.h
@@ -3,13 +3,22 @@
 #ifndef CK_CONTINUITY_RESOLVE_SEALED_H
 #define CK_CONTINUITY_RESOLVE_SEALED_H
 
-#include "continuity_resolve.h"
+#include "continuity_commit.h"
 #include "store_sealed.h"
 
 /* Source over the verified claims of an opened ss_store (P-3: kind and version
  * come from the claim, no decryption to list). The store must stay open. */
 void cr_bind_sealed(struct cr_source *out, ss_store *s);
 
+/* Write side (cut 4): a cr_sink over ss_transact. hook/hook_arg are passed to
+ * every ss_transact (crash checkpoints ST_CP_*, SS_CP_*); NULL for none. */
+struct cr_sealed_sink {
+    ss_store *s;
+    st_hook hook;
+    void *hook_arg;
+};
+void cr_bind_sealed_sink(struct cr_sink *out, struct cr_sealed_sink *ctx);
+
 /* Raw-unit state digest of the Store region (units 0 and 1 of dev), as
  * recovery_core.rs:109-133: an unreadable unit leaves its buffer zero. */
 void cr_state_digest_dev(const st_dev *dev, uint8_t out[32]);
diff --git a/native/kernel/tests/test_continuity_commit.c b/native/kernel/tests/test_continuity_commit.c
new file mode 100644
index 00000000..d5ad0ec3
--- /dev/null
+++ b/native/kernel/tests/test_continuity_commit.c
@@ -0,0 +1,786 @@
+/* test_continuity_commit.c -- host tests of svc/continuity_commit.c (C
+ * continuity port, cut 4: provision, commit, resume; contract
+ * native/kernel/CONTINUITY_RECOVERY_CONTRACT.md, aienos#222). Oracle:
+ * crates/aienos-kernel/src/continuity.rs `provision`/`commit`/`resume`
+ * (:712-868), continuity_tests.rs, scripts/qemu_continuity_test.sh.
+ *
+ * Storage: the REAL sealed Store (native/store, M5 envelopes, anchor) in a
+ * file, at 512 and 4096 byte blocks. Entropy: the real ck_rng over a mocked
+ * RNDR (core/entropy.c).
+ *
+ * 1. Provision, resume N times, remember (INV-8..INV-10, markers).
+ * 2. Refusals: Unprovisioned resume, provision with a root / two roots /
+ *    orphans, degraded mount, K-1 size, no entropy.
+ * 3. Power cut at every checkpoint (ST_CP_* 0-6, SS_CP_BEFORE_ANCHOR,
+ *    SS_CP_AFTER_ANCHOR) AND at every block boundary, for commit and for
+ *    provisioning: the store resolves to exactly the old or the new state.
+ * Mutants (make continuity-mutants) must each turn this test FAIL. */
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "ck_test.h"
+#include "continuity_resolve_sealed.h"
+#include "disk_file.h"
+#include "../argus/sha256.h"
+
+#define CK_(c, ...)                                                            \
+    do {                                                                       \
+        ck_t_run++;                                                            \
+        if (!(c)) {                                                            \
+            ck_t_fail++;                                                       \
+            printf("  FAIL %s:%d: %s: ", __FILE__, __LINE__, #c);              \
+            printf(__VA_ARGS__);                                               \
+            printf("\n");                                                      \
+        }                                                                      \
+    } while (0)
+
+#define A_UNITS 4u
+#define S_UNITS 512u
+#define T_UNITS (A_UNITS + S_UNITS)
+static uint32_t g_su = S_UNITS; /* Store region units (K-2 full run enlarges it) */
+#define IMG_BYTES ((size_t)T_UNITS * 4096u)
+
+static ss_workspace g_ws;
+static ss_store g_s;
+static disk_file g_f;
+static disk_dev g_d;
+static st_disk g_sd;
+static st_dev g_sdev;
+static ts_device g_tdev;
+static ss_keys g_k;
+static uint32_t g_bs;
+static char g_path[256];
+static struct cr_work g_w;
+static struct cr_txwork g_tw;
+static struct cr_view g_v, g_v2;
+static struct cr_source g_src;
+static struct cr_sink g_snk;
+static struct cr_sealed_sink g_sk;
+static const uint8_t RUUID[16] = {0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a,
+                                  0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a};
+static uint8_t base_img[IMG_BYTES], snap_img[IMG_BYTES];
+
+static int g_open;
+static void dev_close(void)
+{
+    if (g_open) disk_file_close(&g_f);
+    g_open = 0;
+}
+static int dev_open(int create)
+{
+    dev_close();
+    uint32_t bpu = 4096u / g_bs;
+    if (create) unlink(g_path);
+    memset(&g_f, 0, sizeof g_f);
+    if (disk_file_open(&g_f, &g_d, g_path, g_bs, (uint64_t)(A_UNITS + g_su) * bpu, create) != 0) return -1;
+    g_open = 1;
+    if (st_disk_bind(&g_sd, &g_d, (uint64_t)A_UNITS * bpu, g_su, &g_sdev) != 0) return -2;
+    ss_ts_device(&g_d, &g_tdev);
+    return 0;
+}
+static void make_keys(void)
+{
+    uint8_t kvol[32];
+    memset(kvol, 0x77, 32);
+    m5_subkeys sk;
+    m5_derive_subkeys(kvol, M5_ID_TEST, 0, &sk);
+    memset(&g_k, 0, sizeof g_k);
+    g_k.identity_class = M5_ID_TEST;
+    g_k.key_generation = 1;
+    memcpy(g_k.k_root_auth, sk.k_root_auth, 32);
+    memcpy(g_k.k_domain, sk.k_artifact, 32);
+    m5_subkeys_wipe(&sk);
+}
+static void bind(st_hook hook)
+{
+    g_sk.s = &g_s;
+    g_sk.hook = hook;
+    g_sk.hook_arg = NULL;
+    cr_bind_sealed(&g_src, &g_s);
+    cr_bind_sealed_sink(&g_snk, &g_sk);
+}
+static void fresh(void)
+{
+    CK_(dev_open(1) == 0, "rig create");
+    CK_(ss_format(&g_sdev, &g_tdev, 0, RUUID, &g_k, &g_ws) == 0, "format");
+    CK_(ss_open(&g_s, &g_sdev, &g_tdev, 0, &g_k, &g_ws) == 0, "open genesis");
+    bind(NULL);
+}
+static int reopen(void)
+{
+    if (dev_open(0) != 0) return -9999;
+    memset(&g_s, 0, sizeof g_s);
+    int rc = ss_open(&g_s, &g_sdev, &g_tdev, 0, &g_k, &g_ws);
+    bind(NULL);
+    return rc;
+}
+static int file_load(uint8_t *dst)
+{
+    FILE *f = fopen(g_path, "rb");
+    if (!f) return -1;
+    size_t n = fread(dst, 1, IMG_BYTES, f);
+    fclose(f);
+    return n == IMG_BYTES ? 0 : -2;
+}
+static int file_store(const uint8_t *src)
+{
+    FILE *f = fopen(g_path, "wb");
+    if (!f) return -1;
+    size_t n = fwrite(src, 1, IMG_BYTES, f);
+    fclose(f);
+    return n == IMG_BYTES ? 0 : -2;
+}
+/* The image must be byte for byte what it was (a refusal writes nothing). */
+static void snapshot(void) { CK_(file_load(snap_img) == 0, "snapshot"); }
+static int unchanged(void)
+{
+    static uint8_t now[IMG_BYTES];
+    return file_load(now) == 0 && memcmp(now, snap_img, IMG_BYTES) == 0;
+}
+
+/* ---- mocked RNDR ---- */
+struct mock {
+    int present;
+    uint64_t ctr;
+};
+static struct mock g_m;
+static struct ck_rng_ops g_ops;
+static struct ck_rng g_rng;
+static int m_present(void *c) { return ((struct mock *)c)->present; }
+static int m_read(void *c, uint64_t *out)
+{
+    struct mock *m = c;
+    uint64_t z = (m->ctr += 0x9e3779b97f4a7c15ull);
+    z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9ull;
+    z = (z ^ (z >> 27)) * 0x94d049bb133111ebull;
+    *out = z ^ (z >> 31);
+    return 1;
+}
+static void rng_init(uint64_t seed, int present)
+{
+    g_m.present = present;
+    g_m.ctr = seed;
+    g_ops.present = m_present;
+    g_ops.read = m_read;
+    g_ops.ctx = &g_m;
+    memset(&g_rng, 0, sizeof g_rng);
+    (void)ck_rng_probe(&g_rng, &g_ops);
+}
+
+static int do_provision(const char **why, int *rc)
+{
+    return cr_provision(&g_src, &g_snk, &g_w, &g_tw, &g_rng, RUUID, CC_SOURCE_QUALIFICATION, &g_v, why, rc);
+}
+static int do_resume(int *committed)
+{
+    return cr_resume(&g_src, &g_snk, &g_w, &g_tw, &g_v, committed, NULL, NULL);
+}
+static int do_resolve(void)
+{
+    return cr_resolve(&g_src, &g_w, &g_v2, NULL, NULL);
+}
+static void hex(const uint8_t *p, size_t n, char *o)
+{
+    static const char H[] = "0123456789abcdef";
+    for (size_t i = 0; i < n; i++) {
+        o[2 * i] = H[p[i] >> 4];
+        o[2 * i + 1] = H[p[i] & 15];
+    }
+    o[2 * n] = 0;
+}
+
+static void check_marker(const char *word, const struct cr_view *v)
+{
+    char got[300], want[300], ag[65], mem[17];
+    hex(v->root.agent_id, 32, ag);
+    hex(v->memory, 8, mem);
+    snprintf(want, sizeof want, "CONTINUITY: %s agent=%s incarnation=%llu sequence=%llu cortex=%llu branches=%u memory=%s",
+             word, ag, (unsigned long long)v->manifest.incarnation, (unsigned long long)v->manifest.sequence,
+             (unsigned long long)v->cortex_count, v->state.n, mem);
+    size_t n = cr_marker_view(got, sizeof got, word, v);
+    CK_(n == strlen(want) && strcmp(got, want) == 0, "marker: got '%s' want '%s'", got, want);
+    CK_(cr_marker_view(got, 20, word, v) == 0, "marker too small buffer refused");
+}
+
+/* ---- 1. provision, resume, remember ---- */
+
+static struct cc_record fact(const char *s)
+{
+    struct cc_record r;
+    memset(&r, 0, sizeof r);
+    r.status = CC_EPI_DIRECT_OBSERVATION;
+    r.len = (uint16_t)strlen(s);
+    r.statement = (const uint8_t *)s;
+    return r;
+}
+
+static uint8_t g_agent_a[32];
+
+static void t_provision_resume(void)
+{
+    fresh();
+    rng_init(1001, 1);
+    uint64_t gen0 = ss_generation(&g_s);
+    const char *why = NULL;
+    int rc = 0;
+    int o = do_provision(&why, &rc);
+    CK_(o == CR_RESOLVED, "bs=%u provision: %s %s", g_bs, cr_outcome_name(o), why ? why : "-");
+    CK_(g_v.manifest.incarnation == 1 && g_v.manifest.sequence == 1 && g_v.cortex_count == 0 && g_v.state.n == 1,
+        "provisioned view");
+    CK_(g_v.state.written_at == 1 && g_v.root.source == CC_SOURCE_QUALIFICATION, "genesis written_at 1, source");
+    CK_(g_v.root.provisioned_generation == gen0 + 1 && ss_generation(&g_s) == gen0 + 1,
+        "provisioned_generation = generation + 1, one transaction");
+    CK_(memcmp(g_v.root.store_uuid, RUUID, 16) == 0, "store uuid");
+    static const uint8_t Z[32];
+    CK_(memcmp(g_v.root.agent_id, Z, 32) != 0, "agent id is not zero");
+    /* contract 1.7: the agent id is the four RNDR words, little-endian, word 0 first (UNVERIFIED on
+     * hardware; here the mocked words are what ck_rng_fill returned). */
+    {
+        struct mock m2 = {1, 1001};
+        struct ck_rng_ops o2 = {m_present, m_read, &m2};
+        struct ck_rng r2;
+        memset(&r2, 0, sizeof r2);
+        ck_rng_probe(&r2, &o2);
+        uint8_t want[32];
+        CK_(ck_rng_fill(&r2, want, 32) == 0 && memcmp(want, g_v.root.agent_id, 32) == 0,
+            "agent id = ck_rng_fill output");
+    }
+    check_marker("PROVISIONED", &g_v);
+    {
+        char mem[17];
+        hex(g_v.memory, 8, mem);
+        CK_(strcmp(mem, "e3b0c44298fc1c14") == 0, "no records: memory= is SHA-256 of nothing, got %s", mem);
+    }
+    memcpy(g_agent_a, g_v.root.agent_id, 32);
+
+    /* Second provision: AlreadyProvisioned, nothing written (83a). */
+    snapshot();
+    rng_init(2002, 1);
+    o = do_provision(&why, &rc);
+    CK_(o == CR_ALREADY_PROVISIONED, "second provision: %s", cr_outcome_name(o));
+    CK_(unchanged(), "second provision changed the image");
+    char mk[200];
+    cr_marker_outcome(mk, sizeof mk, o, why, rc);
+    CK_(strcmp(mk, "CONTINUITY: STOP (AlreadyProvisioned)") == 0, "marker '%s'", mk);
+
+    /* Cold restart, resume N times: same agent, incarnation +1 each, memory preserved (84, 85, 85a). */
+    CK_(reopen() == 0, "reopen");
+    int committed = 0;
+    CK_(do_resume(&committed) == CR_RESOLVED && committed == 1, "resume 1");
+    CK_(g_v.manifest.incarnation == 2 && g_v.manifest.sequence == 2 && g_v.cortex_count == 0 && g_v.state.n == 1,
+        "RESUMED incarnation=2 sequence=2");
+    CK_(memcmp(g_v.root.agent_id, g_agent_a, 32) == 0, "same agent");
+    check_marker("RESUMED", &g_v);
+
+    /* remember: fork the root branch and append one record, in ONE transaction (REMEMBERED). */
+    static struct cc_state st;
+    memcpy(&st, &g_v.state, sizeof st);
+    uint8_t child[32];
+    CK_(cc_state_fork(&st, g_v.root.root_branch, child, NULL) == CC_OK, "fork");
+    struct cc_record r1 = fact("qemu: the operator asked AIEN to remember this");
+    struct cr_update up = {&st, &r1, 1};
+    static struct cr_view cur;
+    memcpy(&cur, &g_v, sizeof cur);
+    uint64_t g1 = ss_generation(&g_s);
+    o = cr_commit(&g_src, &g_snk, &g_w, &g_tw, &cur, &up, 0, &g_v, &why, &rc);
+    CK_(o == CR_RESOLVED, "remember: %s %s", cr_outcome_name(o), why ? why : "-");
+    CK_(ss_generation(&g_s) == g1 + 1, "remember is ONE transaction (INV-8): gen %llu -> %llu",
+        (unsigned long long)g1, (unsigned long long)ss_generation(&g_s));
+    CK_(g_v.manifest.incarnation == 2 && g_v.manifest.sequence == 3 && g_v.cortex_count == 1 && g_v.state.n == 2,
+        "REMEMBERED incarnation=2 sequence=3 cortex=1 branches=2");
+    CK_(g_v.state.written_at == 3, "state.written_at = new sequence (INV-9)");
+    check_marker("REMEMBERED", &g_v);
+    uint8_t mem1[32];
+    memcpy(mem1, g_v.memory, 32);
+
+    uint64_t inc = 2, seq = 3;
+    for (int i = 0; i < 6; i++) {
+        CK_(reopen() == 0, "cold restart %d", i);
+        CK_(do_resume(&committed) == CR_RESOLVED && committed == 1, "resume %d", i);
+        inc++;
+        seq++;
+        CK_(g_v.manifest.incarnation == inc && g_v.manifest.sequence == seq, "cold restart %d: inc %llu seq %llu", i,
+            (unsigned long long)g_v.manifest.incarnation, (unsigned long long)g_v.manifest.sequence);
+        CK_(memcmp(g_v.root.agent_id, g_agent_a, 32) == 0 && memcmp(g_v.memory, mem1, 32) == 0 &&
+                g_v.cortex_count == 1 && g_v.state.n == 2,
+            "same agent, same memory, same branches");
+        CK_(do_resolve() == CR_RESOLVED && g_v2.manifest.incarnation == inc, "stored view agrees");
+    }
+    /* Independent provisioning draws another agent (83b). */
+    fresh();
+    rng_init(3003, 1);
+    CK_(do_provision(&why, &rc) == CR_RESOLVED, "provision B");
+    CK_(memcmp(g_v.root.agent_id, g_agent_a, 32) != 0, "independent provisioning gives a different agent (MC-10)");
+}
+
+/* ---- 2. refusals ---- */
+
+static void t_unprovisioned_resume(void)
+{
+    fresh();
+    CK_(reopen() == 0, "reopen");
+    snapshot();
+    uint64_t gen0 = ss_generation(&g_s);
+    int committed = 7;
+    int o = do_resume(&committed);
+    CK_(o == CR_UNPROVISIONED && committed == 0, "bs=%u resume on Unprovisioned: %s", g_bs, cr_outcome_name(o));
+    CK_(ss_generation(&g_s) == gen0 && unchanged(), "resume minted nothing (INV-4, MC-1)");
+    CK_(reopen() == 0 && do_resolve() == CR_UNPROVISIONED, "still Unprovisioned after reopen");
+    char mk[100];
+    cr_marker_outcome(mk, sizeof mk, o, NULL, 0);
+    CK_(strcmp(mk, "CONTINUITY: UNPROVISIONED") == 0, "marker '%s'", mk);
+}
+
+/* An object committed straight to the Store, to build hostile states. */
+static int raw_commit(uint16_t kind, const uint8_t *b, size_t n)
+{
+    ss_object so = {kind, 1, b, n};
+    return ss_transact(&g_s, &so, 1, NULL, NULL, NULL);
+}
+
+static void t_provision_refusals(void)
+{
+    const char *why = NULL;
+    int rc = 0, o;
+    /* with a root (MC-7) was covered in t_provision_resume; here: two roots and orphans. */
+    fresh();
+    rng_init(11, 1);
+    CK_(do_provision(&why, &rc) == CR_RESOLVED, "provision");
+    /* a second, foreign root written behind the layer's back -> Conflict -> provision refuses */
+    struct cc_root r;
+    memset(&r, 0, sizeof r);
+    memset(r.agent_id, 0x77, 32);
+    cc_root_branch_id(r.agent_id, r.root_branch);
+    r.provisioned_generation = 9;
+    r.source = CC_SOURCE_OPERATOR;
+    static uint8_t b[CC_MAX_OBJECT_BYTES];
+    size_t n = 0;
+    CK_(cc_root_encode(&r, b, sizeof b, &n, NULL) == CC_OK && raw_commit(CC_KIND_AGENT_ROOT, b, n) == 0, "second root");
+    CK_(do_resolve() == CR_CONFLICT, "two roots resolve to Conflict");
+    snapshot();
+    rng_init(12, 1);
+    o = do_provision(&why, &rc);
+    CK_(o == CR_ALREADY_PROVISIONED, "provision on Conflict: %s", cr_outcome_name(o));
+    CK_(unchanged(), "refusal wrote nothing");
+
+    /* orphan manifest only: provision must refuse (never provision over orphans). */
+    fresh();
+    struct cc_manifest m;
+    memset(&m, 0, sizeof m);
+    memset(m.root, 0x55, 32);
+    m.sequence = 1;
+    m.incarnation = 1;
+    memset(m.agent_state, 0x66, 32);
+    CK_(cc_manifest_encode(&m, b, sizeof b, &n, NULL) == CC_OK && raw_commit(CC_KIND_MANIFEST, b, n) == 0, "orphan manifest");
+    snapshot();
+    rng_init(13, 1);
+    o = do_provision(&why, &rc);
+    CK_(o == CR_CORRUPT && why && !strcmp(why, "continuity objects without an agent root"),
+        "provision over orphans: %s %s", cr_outcome_name(o), why ? why : "-");
+    CK_(unchanged(), "orphans: nothing written");
+    int committed = 0;
+    CK_(do_resume(&committed) == CR_CORRUPT && committed == 0, "resume over orphans is Corrupt, not Unprovisioned");
+    CK_(unchanged(), "resume over orphans wrote nothing");
+
+    /* no entropy: absent, then never probed; nothing written, no fallback */
+    fresh();
+    snapshot();
+    rng_init(14, 0);
+    o = do_provision(&why, &rc);
+    CK_(o == CR_NO_ENTROPY && unchanged(), "no RNDR: %s", cr_outcome_name(o));
+    char mk[100];
+    cr_marker_outcome(mk, sizeof mk, o, NULL, 0);
+    CK_(strcmp(mk, "CONTINUITY: NO_ENTROPY") == 0, "marker '%s'", mk);
+    memset(&g_rng, 0, sizeof g_rng);
+    o = do_provision(&why, &rc);
+    CK_(o == CR_NO_ENTROPY && unchanged(), "unprobed rng: %s", cr_outcome_name(o));
+    CK_(do_resolve() == CR_UNPROVISIONED, "still Unprovisioned");
+
+    /* caller bugs */
+    CK_(cr_provision(NULL, &g_snk, &g_w, &g_tw, &g_rng, RUUID, 1, &g_v, NULL, NULL) == CR_E_ARG, "NULL src");
+    rng_init(15, 1);
+    CK_(cr_provision(&g_src, &g_snk, &g_w, &g_tw, &g_rng, RUUID, 0, &g_v, NULL, NULL) == CR_E_ARG, "bad source");
+    CK_(cr_provision(&g_src, &g_snk, &g_w, &g_tw, NULL, RUUID, 1, &g_v, NULL, NULL) == CR_E_ARG, "NULL rng");
+    CK_(unchanged(), "caller bugs wrote nothing");
+}
+
+static void junk_inactive(void)
+{
+    uint32_t active = st_active_slot(&g_s.st);
+    dev_close();
+    FILE *f = fopen(g_path, "r+b");
+    CK_(f != NULL, "open image");
+    static uint8_t junk[4096];
+    for (size_t i = 0; i < sizeof junk; i++) junk[i] = (uint8_t)(i * 37u + 11u);
+    if (f) {
+        fseek(f, (long)((A_UNITS + (1u - active)) * 4096u), SEEK_SET);
+        CK_(fwrite(junk, 1, sizeof junk, f) == sizeof junk, "write junk");
+        fclose(f);
+    }
+}
+
+static void t_degraded(void)
+{
+    const char *why = NULL;
+    int rc = 0, o;
+    /* provisioned store, malformed peer: resume is read only (INV-11), commit and provision are ReadOnly */
+    fresh();
+    rng_init(21, 1);
+    CK_(do_provision(&why, &rc) == CR_RESOLVED, "provision");
+    int committed = 0;
+    CK_(do_resume(&committed) == CR_RESOLVED && committed == 1, "resume");
+    uint8_t agent[32], mem[32];
+    memcpy(agent, g_v.root.agent_id, 32);
+    memcpy(mem, g_v.memory, 32);
+    uint64_t inc = g_v.manifest.incarnation;
+    junk_inactive();
+    CK_(reopen() == 0 && g_s.st.state == ST_DEGRADED_RECOVERY, "degraded mount (K-5)");
+    snapshot();
+    uint64_t gen = ss_generation(&g_s);
+    o = do_resume(&committed);
+    CK_(o == CR_RESOLVED && committed == 0, "bs=%u degraded resume: %s committed=%d", g_bs, cr_outcome_name(o), committed);
+    CK_(memcmp(g_v.root.agent_id, agent, 32) == 0 && memcmp(g_v.memory, mem, 32) == 0 && g_v.manifest.incarnation == inc,
+        "RESUMED_READONLY: same agent, memory, incarnation");
+    check_marker("RESUMED_READONLY", &g_v);
+    struct cc_record r1 = fact("x");
+    struct cr_update up = {NULL, &r1, 1};
+    static struct cr_view cur;
+    memcpy(&cur, &g_v, sizeof cur);
+    o = cr_commit(&g_src, &g_snk, &g_w, &g_tw, &cur, &up, 1, &g_v2, &why, &rc);
+    CK_(o == CR_READ_ONLY, "commit on a degraded mount: %s (MC-9)", cr_outcome_name(o));
+    CK_(ss_generation(&g_s) == gen && unchanged(), "nothing written");
+    cr_marker_outcome((char[64]){0}, 64, o, NULL, 0);
+    char mk[100];
+    cr_marker_outcome(mk, sizeof mk, o, NULL, 0);
+    CK_(strcmp(mk, "CONTINUITY: STOP (ReadOnly)") == 0, "marker '%s'", mk);
+
+    /* degraded and unprovisioned: provision refuses ReadOnly (never mints on a degraded mount) */
+    fresh();
+    static uint8_t b[16];
+    memset(b, 1, sizeof b);
+    CK_(raw_commit(0x0B01, b, sizeof b) == 0, "unrelated object (second generation)");
+    junk_inactive();
+    CK_(reopen() == 0 && g_s.st.state == ST_DEGRADED_RECOVERY, "degraded");
+    snapshot();
+    rng_init(22, 1);
+    o = do_provision(&why, &rc);
+    CK_(o == CR_READ_ONLY, "provision on a degraded mount: %s (MC-9)", cr_outcome_name(o));
+    CK_(unchanged(), "provision wrote nothing");
+    CK_(do_resolve() == CR_UNPROVISIONED, "still Unprovisioned");
+}
+
+static void t_size_bound(void)
+{
+    const char *why = NULL;
+    int rc = 0, o;
+    fresh();
+    rng_init(31, 1);
+    CK_(do_provision(&why, &rc) == CR_RESOLVED, "provision");
+    static struct cr_view cur;
+    memcpy(&cur, &g_v, sizeof cur);
+
+    /* K-1: 205 branches = 16464 bytes is Limit, nothing written; 204 = 16384 fits. */
+    static struct cc_state st;
+    memcpy(&st, &cur.state, sizeof st);
+    uint8_t child[32];
+    for (int i = 0; i < 203; i++) CK_(cc_state_fork(&st, cur.root.root_branch, child, NULL) == CC_OK, "fork");
+    CK_(st.n == 204, "204 branches");
+    snapshot();
+    uint64_t gen0 = ss_generation(&g_s);
+    struct cr_update up = {&st, NULL, 0};
+    o = cr_commit(&g_src, &g_snk, &g_w, &g_tw, &cur, &up, 0, &g_v, &why, &rc);
+    CK_(o == CR_RESOLVED && ss_generation(&g_s) == gen0 + 1, "204 branches commit: %s %s", cr_outcome_name(o), why ? why : "-");
+    memcpy(&cur, &g_v, sizeof cur);
+    memcpy(&st, &cur.state, sizeof st);
+    CK_(cc_state_fork(&st, cur.root.root_branch, child, NULL) == CC_OK && st.n == 205, "205 branches");
+    snapshot();
+    gen0 = ss_generation(&g_s);
+    o = cr_commit(&g_src, &g_snk, &g_w, &g_tw, &cur, &up, 0, &g_v, &why, &rc);
+    CK_(o == CR_LIMIT && why && !strcmp(why, "continuity object exceeds the 16384-byte sealed Store cap"),
+        "205 branches: %s %s (K-1)", cr_outcome_name(o), why ? why : "-");
+    CK_(ss_generation(&g_s) == gen0 && unchanged(), "K-1: nothing written");
+
+    /* 64 records of 1024 bytes = 67872 bytes: Limit, never truncated (MC-11). */
+    static uint8_t stmt[1024];
+    memset(stmt, 'm', sizeof stmt);
+    static struct cc_record recs[64];
+    for (int i = 0; i < 64; i++) {
+        recs[i] = fact("");
+        recs[i].len = 1024;
+        recs[i].statement = stmt;
+    }
+    struct cr_update w64 = {NULL, recs, 64};
+    snapshot();
+    o = cr_commit(&g_src, &g_snk, &g_w, &g_tw, &cur, &w64, 0, &g_v2, &why, &rc);
+    CK_(o == CR_LIMIT, "64 x 1024 byte WAL: %s (K-1, MC-11)", cr_outcome_name(o));
+    CK_(unchanged(), "oversize WAL: nothing written, nothing truncated");
+    struct cr_update w65 = {NULL, recs, 65};
+    o = cr_commit(&g_src, &g_snk, &g_w, &g_tw, &cur, &w65, 0, &g_v2, &why, &rc);
+    CK_(o == CR_LIMIT && why && !strcmp(why, "WAL segment record count"), "65 records: %s", cr_outcome_name(o));
+    /* 15 records of 1024 bytes = 15.9 KiB fits and reads back whole. */
+    struct cr_update w15 = {NULL, recs, 15};
+    o = cr_commit(&g_src, &g_snk, &g_w, &g_tw, &cur, &w15, 0, &g_v2, &why, &rc);
+    CK_(o == CR_RESOLVED && g_v2.cortex_count == 15, "15 x 1024 fits and is read back whole: %s %llu", cr_outcome_name(o),
+        (unsigned long long)g_v2.cortex_count);
+}
+
+/* K-2: the catalog bound. */
+static void t_catalog_bound(void)
+{
+    const char *why = NULL;
+    int rc = 0;
+    fresh();
+    rng_init(41, 1);
+    CK_(do_provision(&why, &rc) == CR_RESOLVED, "provision");
+    uint32_t n;
+    st_catalog(&g_s.st, &n);
+    uint32_t after_prov = n;
+    struct cc_record r1 = fact("k2");
+    struct cr_update up = {NULL, &r1, 1};
+    static struct cr_view cur;
+    int ok = 1;
+    for (int i = 0; i < 64 && ok; i++) {
+        memcpy(&cur, &g_v, sizeof cur);
+        ok = cr_commit(&g_src, &g_snk, &g_w, &g_tw, &cur, &up, 0, &g_v2, &why, &rc) == CR_RESOLVED;
+        memcpy(&g_v, &g_v2, sizeof g_v);
+    }
+    CK_(ok && g_v.manifest.n_wal == 64, "64 WAL commits");
+    st_catalog(&g_s.st, &n);
+    printf("K-2 (bs=%u): catalog entries after provision = %u; after provision + 64 one-record WAL commits = %u "
+           "(%.2f entries per transaction; bound %u)\n",
+           g_bs, after_prov, n, (double)(n - after_prov) / 64.0, (unsigned)SV1_MAX_CATALOG_ENTRIES);
+    CK_(n == after_prov + 64u * 3u, "each WAL commit adds WAL + manifest + transaction record (3 entries), got %u", n);
+    memcpy(&cur, &g_v, sizeof cur);
+    uint64_t gen0 = ss_generation(&g_s);
+    int o = cr_commit(&g_src, &g_snk, &g_w, &g_tw, &cur, &up, 0, &g_v2, &why, &rc);
+    CK_(o == CR_LIMIT && why && !strcmp(why, "cortex WAL needs compaction"), "65th WAL segment: %s", cr_outcome_name(o));
+    CK_(ss_generation(&g_s) == gen0, "nothing written");
+}
+
+/* K-2 run to exhaustion (slow, CK_K2_FULL=1): resumes add manifest + transaction record = 2 entries. */
+static void t_catalog_full(void)
+{
+    const char *why = NULL;
+    int rc = 0, committed = 0, oo;
+    uint32_t n;
+    g_su = 16384;
+    fresh();
+    rng_init(51, 1);
+    CK_(do_provision(&why, &rc) == CR_RESOLVED, "provision");
+    unsigned resumes = 0;
+    while ((oo = cr_resume(&g_src, &g_snk, &g_w, &g_tw, &g_v2, &committed, &why, &rc)) == CR_RESOLVED) resumes++;
+    st_catalog(&g_s.st, &n);
+    printf("K-2 full (bs=4096, %u-unit Store region): %u resumes after provisioning, then %s rc=%d (%s); catalog entries %u of %u\n",
+           g_su, resumes, cr_outcome_name(oo), rc, rc ? st_strerror(rc) : "-", n, (unsigned)SV1_MAX_CATALOG_ENTRIES);
+    CK_(oo == CR_STORE && (rc == ST_E_CATALOG_FULL || rc == ST_E_NO_SPACE), "stops with a Store refusal (catalog full or no space), not a wrong result");
+    g_su = S_UNITS;
+}
+
+/* ---- 3. power cuts ---- */
+
+static int g_cp_target, g_cp_fired;
+static void cp_hook(void *arg, int cp)
+{
+    (void)arg;
+    if (cp == g_cp_target && !g_cp_fired) {
+        g_cp_fired = 1;
+        disk_file_arm_cut(&g_f, 0);
+    }
+}
+enum { CUT_CHECKPOINTS = 9 };
+static const int CPS[CUT_CHECKPOINTS] = {ST_CP_BEFORE_FIRST_WRITE, ST_CP_AFTER_PAYLOAD_OBJECTS, ST_CP_AFTER_CATALOG,
+                                         ST_CP_AFTER_COMMIT_RECORD, ST_CP_AFTER_FIRST_FLUSH,
+                                         ST_CP_AFTER_INACTIVE_SUPERBLOCK, ST_CP_AFTER_FINAL_FLUSH,
+                                         SS_CP_BEFORE_ANCHOR, SS_CP_AFTER_ANCHOR};
+static const char *cp_name(int cp)
+{
+    return cp >= 100 ? (cp == SS_CP_BEFORE_ANCHOR ? "before_anchor" : "after_anchor") : st_checkpoint_name(cp);
+}
+
+struct pc_stats {
+    int old, neu, other_bad, degraded;
+};
+
+/* The operation under test. */
+enum { OP_COMMIT, OP_PROVISION };
+static uint64_t g_gen_old;
+static uint8_t g_agent_exp[32]; /* provisioning: the agent the mocked RNDR yields */
+static struct cr_view g_old_view, g_new_view;
+
+static int run_op(int op)
+{
+    const char *why = NULL;
+    int rc = 0;
+    if (op == OP_PROVISION) {
+        rng_init(777, 1);
+        return do_provision(&why, &rc);
+    }
+    static struct cc_state st;
+    memcpy(&st, &g_old_view.state, sizeof st);
+    uint8_t child[32];
+    (void)cc_state_fork(&st, g_old_view.root.root_branch, child, NULL);
+    struct cc_record r1 = fact("remember across the crash");
+    struct cr_update up = {&st, &r1, 1};
+    return cr_commit(&g_src, &g_snk, &g_w, &g_tw, &g_old_view, &up, 1, &g_v, &why, &rc);
+}
+
+/* Verdict after the cut: exactly the old state or exactly the new one. Returns 1 old, 2 new, 0 bad. */
+static int classify(int op, const char *what)
+{
+    int rc = reopen();
+    CK_(rc == 0, "%s: reopen after the cut: %s (%d)", what, rc ? ss_strerror(rc) : "ok", rc);
+    if (rc != 0) return 0;
+    uint64_t gen = ss_generation(&g_s);
+    int o = do_resolve();
+    if (op == OP_PROVISION) {
+        if (o == CR_UNPROVISIONED) {
+            CK_(gen == g_gen_old, "%s: old state but generation %llu", what, (unsigned long long)gen);
+            return gen == g_gen_old ? 1 : 0;
+        }
+        int ok = o == CR_RESOLVED && gen == g_gen_old + 1 && memcmp(g_v2.root.agent_id, g_agent_exp, 32) == 0 &&
+                 g_v2.manifest.sequence == 1 && g_v2.manifest.incarnation == 1 && g_v2.state.n == 1;
+        CK_(ok, "%s: neither Unprovisioned nor the full genesis: %s gen %llu", what, cr_outcome_name(o), (unsigned long long)gen);
+        return ok ? 2 : 0;
+    }
+    if (o != CR_RESOLVED) {
+        CK_(0, "%s: resolve after cut: %s", what, cr_outcome_name(o));
+        return 0;
+    }
+    CK_(memcmp(g_v2.root.agent_id, g_old_view.root.agent_id, 32) == 0, "%s: identity changed", what);
+    if (g_v2.manifest.sequence == g_old_view.manifest.sequence) {
+        int ok = gen == g_gen_old && g_v2.manifest.incarnation == g_old_view.manifest.incarnation &&
+                 g_v2.cortex_count == g_old_view.cortex_count && memcmp(g_v2.memory, g_old_view.memory, 32) == 0 &&
+                 g_v2.state.n == g_old_view.state.n;
+        CK_(ok, "%s: sequence old but content mixed (gen %llu)", what, (unsigned long long)gen);
+        return ok ? 1 : 0;
+    }
+    int ok = gen == g_gen_old + 1 && g_v2.manifest.sequence == g_new_view.manifest.sequence &&
+             g_v2.manifest.incarnation == g_new_view.manifest.incarnation && g_v2.cortex_count == g_new_view.cortex_count &&
+             memcmp(g_v2.memory, g_new_view.memory, 32) == 0 && g_v2.state.n == g_new_view.state.n;
+    CK_(ok, "%s: third state: seq %llu inc %llu gen %llu", what, (unsigned long long)g_v2.manifest.sequence,
+        (unsigned long long)g_v2.manifest.incarnation, (unsigned long long)gen);
+    return ok ? 2 : 0;
+}
+
+/* After a cut the store must keep working: provision again (old) / resume (any). */
+static void still_works(int op, int verdict, const char *what)
+{
+    if (!verdict) return;
+    if (g_s.st.state != ST_VALID) return; /* degraded: read only, the Recovery Core's case, not this layer's */
+    int committed = 0;
+    if (op == OP_PROVISION && verdict == 1) {
+        const char *why = NULL;
+        int rc = 0;
+        rng_init(888, 1);
+        int o = do_provision(&why, &rc);
+        CK_(o == CR_RESOLVED, "%s: provisioning again after a cut that left the old state: %s %s", what, cr_outcome_name(o),
+            why ? why : "-");
+        return;
+    }
+    int o = do_resume(&committed);
+    CK_(o == CR_RESOLVED && committed == 1, "%s: resume after the cut: %s", what, cr_outcome_name(o));
+}
+
+static void cut_campaign(int op, const char *label)
+{
+    /* Base state for this op. */
+    fresh();
+    if (op == OP_COMMIT) {
+        rng_init(999, 1);
+        const char *why = NULL;
+        int rc = 0;
+        CK_(do_provision(&why, &rc) == CR_RESOLVED, "provision (base)");
+        int committed = 0;
+        CK_(do_resume(&committed) == CR_RESOLVED, "resume (base)");
+        memcpy(&g_old_view, &g_v, sizeof g_old_view);
+    }
+    dev_close();
+    CK_(file_load(base_img) == 0, "save base");
+
+    /* Learn the new state and the block count with an uncut run. */
+    CK_(reopen() == 0, "reopen base");
+    g_gen_old = ss_generation(&g_s);
+    uint64_t w0 = g_f.blocks_written;
+    int o = run_op(op);
+    CK_(o == CR_RESOLVED, "%s uncut: %s", label, cr_outcome_name(o));
+    uint64_t W = g_f.blocks_written - w0;
+    memcpy(&g_new_view, &g_v, sizeof g_new_view);
+    if (op == OP_PROVISION) memcpy(g_agent_exp, g_v.root.agent_id, 32);
+    dev_close();
+
+    struct pc_stats cp = {0}, bl = {0};
+    /* Every checkpoint. */
+    for (int i = 0; i < CUT_CHECKPOINTS; i++) {
+        char what[96];
+        snprintf(what, sizeof what, "%s bs=%u cp %s", label, g_bs, cp_name(CPS[i]));
+        CK_(file_store(base_img) == 0, "restore");
+        CK_(reopen() == 0, "reopen base");
+        g_cp_target = CPS[i];
+        g_cp_fired = 0;
+        bind(cp_hook);
+        (void)run_op(op);
+        CK_(g_cp_fired == 1, "%s: checkpoint never reached", what);
+        disk_file_disarm(&g_f);
+        int v = classify(op, what);
+        /* Expected by the Rust oracle and the sealed-store rule (contract 6.1). */
+        if (CPS[i] <= ST_CP_AFTER_FIRST_FLUSH) CK_(v == 1, "%s: expected the old state", what);
+        if (CPS[i] == ST_CP_AFTER_FINAL_FLUSH || CPS[i] >= SS_CP_BEFORE_ANCHOR)
+            CK_(v == 2, "%s: expected the new state", what);
+        if (CPS[i] == SS_CP_BEFORE_ANCHOR) CK_(g_s.rb == SS_RB_PREPARED_ADVANCE, "%s: anchor one behind (rb=%d)", what, g_s.rb);
+        cp.old += v == 1;
+        cp.neu += v == 2;
+        cp.other_bad += v == 0;
+        cp.degraded += g_s.st.state == ST_DEGRADED_RECOVERY;
+        still_works(op, v, what);
+    }
+    /* Every block boundary of the write sequence. */
+    for (uint64_t k = 0; k <= W; k++) {
+        char what[96];
+        snprintf(what, sizeof what, "%s bs=%u block cut %llu/%llu", label, g_bs, (unsigned long long)k, (unsigned long long)W);
+        CK_(file_store(base_img) == 0, "restore");
+        CK_(reopen() == 0, "reopen base");
+        disk_file_arm_cut(&g_f, k);
+        (void)run_op(op);
+        disk_file_disarm(&g_f);
+        int v = classify(op, what);
+        if (k == 0) CK_(v == 1, "%s: cut 0 must be old", what);
+        if (k == W) CK_(v == 2, "%s: full write must be new", what);
+        bl.old += v == 1;
+        bl.neu += v == 2;
+        bl.other_bad += v == 0;
+        bl.degraded += g_s.st.state == ST_DEGRADED_RECOVERY;
+        still_works(op, v, what);
+    }
+    printf("power cut, %s, %4u-byte blocks: %d checkpoints (%d old, %d new, %d bad), %llu block boundaries "
+           "(%d old, %d new, %d bad, %d read-only degraded)\n",
+           label, g_bs, CUT_CHECKPOINTS, cp.old, cp.neu, cp.other_bad, (unsigned long long)W + 1, bl.old, bl.neu,
+           bl.other_bad, bl.degraded);
+    CK_(cp.other_bad == 0 && bl.other_bad == 0, "no mixed state");
+    CK_(cp.old + cp.neu == CUT_CHECKPOINTS, "every checkpoint classified");
+    CK_(bl.old + bl.neu == (int)W + 1, "every block cut classified");
+}
+
+int main(void)
+{
+    make_keys();
+    snprintf(g_path, sizeof g_path, "/tmp/ck_cm_test_%d.img", (int)getpid());
+    static const uint32_t geos[2] = {4096u, 512u};
+    for (int g = 0; g < 2; g++) {
+        g_bs = geos[g];
+        t_provision_resume();
+        t_unprovisioned_resume();
+        t_provision_refusals();
+        t_degraded();
+        t_size_bound();
+        t_catalog_bound();
+        if (g_bs == 4096 && getenv("CK_K2_FULL")) t_catalog_full();
+        cut_campaign(OP_COMMIT, "commit");
+        cut_campaign(OP_PROVISION, "provision");
+    }
+    dev_close();
+    unlink(g_path);
+    return ck_t_verdict("test_continuity_commit");
+}
diff --git a/native/kernel/tests/test_continuity_resolve.c b/native/kernel/tests/test_continuity_resolve.c
index a62e49ef..ab383a0a 100644
--- a/native/kernel/tests/test_continuity_resolve.c
+++ b/native/kernel/tests/test_continuity_resolve.c
@@ -804,7 +804,7 @@ static void t_fake(void)
 {
     struct fake f;
     memset(&f, 0, sizeof f);
-    struct cr_source src = {&f, fk_count, fk_entry, fk_read, fk_mount};
+    struct cr_source src = {&f, fk_count, fk_entry, fk_read, fk_mount, NULL};
     const char *w = NULL;
     int rc = 0;
     /* oversize (K-1): Limit, never decoded, never truncated */