Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/patches/e3fac044c639f044 # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/aienux#260 (code only) closed derived `e3fac044c639f044` #260 Imported from GitHub aien-dev/aienux#260 (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 `71d5b326eea6a330f3cc1c4377fc4bc2d134d5aa` · Head `197206cd659e212c09400c8f0f7604a81f88792e` greptile-apps[bot] reviewed (COMMENTED) on 2026-10-05 02:02 UTC `aien-dev` has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan . ### Apply it ``` git checkout -b patch-e3fac044c639f044 71d5b326eea6a330f3cc1c4377fc4bc2d134d5aa curl -fsSL https://interplane.io/drakestapleton/aienux/patches/e3fac044c639f044.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 260 197206cd659e212c09400c8f0f7604a81f88792e ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"aienux","number":260,"url":"https://github.com/aien-dev/aienux/pull/260","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:04Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.crumb b/.crumb index ee51eba3..30f96af4 100644 --- a/.crumb +++ b/.crumb @@ -27,33 +27,33 @@ "purpose": "Directory crates. Purpose not yet described by a human." }, { - "digest": "cd17a1a9f319bb252beac32f1f685f0c013ff1d22f7cff0cf338718610ff003c", - "last_commit": "fbbfc9c", + "digest": "3947ba1fe343472af9f2afe65c10051bdda114a47e52ed281c9c496928613a69", + "last_commit": "640522a", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, { - "digest": "e6f06b76c4d9c1884afb930cfbb1b72266981bbe588b75705b1211ed150cc0d9", - "last_commit": "fbbfc9c", + "digest": "4c3af9c590d65bc53f1ff800c6c71a182d1198942af77723468fc3b1ec983d7d", + "last_commit": "640522a", "name": "native", "purpose": "Directory native. Purpose not yet described by a human." }, { - "digest": "c2faf9bb1f39cfe42057ef4fc740d04cc8c614bd4e31917f41b5cbe1acb8fcb6", - "last_commit": "fbbfc9c", + "digest": "07ca1d2521f97f9ca307c0d11fd0793cb00558b2a429f581c9bd3c2b91e4f1cf", + "last_commit": "640522a", "name": "scripts", "purpose": "Directory scripts. Purpose not yet described by a human." } ], - "children_root": "sha256:cbde8aefbebbd9837642fc925d153f80f184de79b51d695cb9167b2ada04fd50", - "compiled_at": "2026-10-05T00:51:39Z", + "children_root": "sha256:71ab00ea4d4d7468795bbc75e618c4c1f85bc089a59a6f2d534ff3ec02e9edb0", + "compiled_at": "2026-10-05T02:27:48Z", "compiler": "crumb-compile/1", - "digest": "sha256:5b207342462caa8ff93fa5de37b3f5fb36e37ab1060cf766200360177fa89a98", - "evidence_files": 143, - "evidence_root": "sha256:3a3cbeef2e097d532b986e4579accee3f65ae5815e78716aefe3fd5f569812cf", - "files": 2845, - "generated_at_commit": "fbbfc9c90b5609cdd94a327fad3503366e1b11b1", - "source_tree": "sha256:6f3b279cb0739d8bfbeabb79c3ea1314fcd4435ecc01a1052812ae2c4a387431" + "digest": "sha256:b97fc8060559ff252ae45da063dfe5d19a499c0fbf5c3df259116c76777971e6", + "evidence_files": 147, + "evidence_root": "sha256:3f1c80574189eaded43ead3929d21a74c01f77dee31e7b2e2bd3858e67155dc7", + "files": 2853, + "generated_at_commit": "640522a03b9f939d2d07ef0d0fdc08e35ecefc7e", + "source_tree": "sha256:01fd2bbb73681268d64b27e5cf332a4ffe7d93c072aed2f1bc494d7d7e3c6798" }, "owner_lane": "", "provenance": { diff --git a/docs/.crumb b/docs/.crumb index c12d6428..d887570d 100644 --- a/docs/.crumb +++ b/docs/.crumb @@ -17,8 +17,8 @@ "generated": { "children": [ { - "digest": "9c529d8484dc3636be937fab05cb2729e86864926a4c3be1ae9d6fc8c92755d6", - "last_commit": "fbbfc9c", + "digest": "c24b943fbbd6b536c29d731066917fc908de275c72f594d2d4a5a1c7d19f879c", + "last_commit": "640522a", "name": "adr", "purpose": "Directory docs/adr. Purpose not yet described by a human." }, @@ -29,15 +29,15 @@ "purpose": "Directory docs/crumbs. Purpose not yet described by a human." } ], - "children_root": "sha256:cb92ed84c76d44749e07a32e2f5a5059d9ae47b0c7333dc3503c9f6e70d8c437", - "compiled_at": "2026-10-05T00:51:39Z", + "children_root": "sha256:25a2af14107c1c2ae96916dd5c4086195ebd4117975ea0ae458855ac21f46099", + "compiled_at": "2026-10-05T02:27:48Z", "compiler": "crumb-compile/1", - "digest": "sha256:cd17a1a9f319bb252beac32f1f685f0c013ff1d22f7cff0cf338718610ff003c", + "digest": "sha256:3947ba1fe343472af9f2afe65c10051bdda114a47e52ed281c9c496928613a69", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 57, - "generated_at_commit": "fbbfc9c90b5609cdd94a327fad3503366e1b11b1", - "source_tree": "sha256:274652c9b0eb78d0001ff38d07192ce14e3c0be9c24657ad99963670cb4dc3f8" + "generated_at_commit": "640522a03b9f939d2d07ef0d0fdc08e35ecefc7e", + "source_tree": "sha256:49ef00c2c9e4238564ac5645aac7a6e1c186eca16afc8564ea6e12bae757f750" }, "owner_lane": "", "provenance": { diff --git a/docs/adr/.crumb b/docs/adr/.crumb index df986b14..e19e4b8e 100644 --- a/docs/adr/.crumb +++ b/docs/adr/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-05T00:51:39Z", + "compiled_at": "2026-10-05T02:27:48Z", "compiler": "crumb-compile/1", - "digest": "sha256:9c529d8484dc3636be937fab05cb2729e86864926a4c3be1ae9d6fc8c92755d6", + "digest": "sha256:c24b943fbbd6b536c29d731066917fc908de275c72f594d2d4a5a1c7d19f879c", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 21, - "generated_at_commit": "fbbfc9c90b5609cdd94a327fad3503366e1b11b1", - "source_tree": "sha256:801465156554cf3a979affcc8c0a6fe410234235e252ed5ffd39a5d5879bb240" + "generated_at_commit": "640522a03b9f939d2d07ef0d0fdc08e35ecefc7e", + "source_tree": "sha256:c92fa7310220ab8a92ea8189797537fba23da7e720846117fe16f8973e559cec" }, "owner_lane": "", "provenance": { diff --git a/docs/adr/0018-allen-subject-state-object.md b/docs/adr/0018-allen-subject-state-object.md index fe765c16..a5a88752 100644 --- a/docs/adr/0018-allen-subject-state-object.md +++ b/docs/adr/0018-allen-subject-state-object.md @@ -66,6 +66,15 @@ The subject object is state, not authority. Nothing in `continuity_subject.c` mi Four mutants (`CS_MUTANT_ACCEPT_FOREIGN`, `CS_MUTANT_ACCEPT_TWO_ACTIVE`, `CS_MUTANT_SKIP_INTENT_ID`, `CS_MUTANT_ACCEPT_FORK`) are test-only, each must turn the host test red, and each is refused by `#error` under `CK_HARDWARE_STAGING`. + +### 2.7 Native genesis and restore (two paths) + +**PROVISION** is the only path that creates a subject. `cs_provision` (`native/kernel/svc/continuity_subject_provision.c`) wraps the Store sink that `cr_provision` (ADR 0016) already uses: inside that single `cr_sink.transact` call it decodes the AgentRoot being written, builds the genesis subject (sequence 1, provenance, origin, the Cortex lineage reference from the provisioning request) and appends it as one more object of the **same** transaction. The barrier is the existing sealed Store commit (`ss_transact`, ADR 0017: payload objects, catalog, commit record, flush, inactive superblock, flush, anchor); there is no second WAL, no second database and no other write path. A crash anywhere leaves either an unprovisioned Store or an identity with exactly one genesis subject; "identity without subject" cannot be produced by a power cut. After the commit it resolves the Store again and refuses unless the subject on media is the genesis it sent. A Store that is already provisioned is refused (`AlreadyProvisioned`, nothing written); an image with subject objects but no root is CORRUPT. A standing intent given at provisioning is written afterwards with `cs_commit` (sequence 2), through the same Store. + +**RESTORE** never creates one. On every resume the kernel resolves identity read-only, then `cs_resolve`: RESOLVED prints the subject and resume continues; ABSENT is reported and resume continues with no subject minted; CORRUPT (fork, gap, foreign root or agent, undecodable object) stops before anything is written, so a damaged subject is never replaced by a fresh one. The restore plan carries only the mode: the subject, its intents and its lineage come from the disk. + +In the kernel the two paths live in the TEST continuity image (`make full CK_TEST_CONTINUITY=1`), the only image that provisions an identity today; the default image provisions no identity and therefore no subject. Two more TEST-only mutants (`CS_MUTANT_RESTORE_MINTS`, `CS_MUTANT_ACCEPT_FOREIGN` in the kernel image) and one host mutant (`CS_MUTANT_PROVISION_SPLIT_TXN`) must be killed by the gates; each is refused under `CK_HARDWARE_STAGING`. + ## 3. Qualification Status vocabulary: IMPLEMENTED / TESTED / QUALIFIED / NOT_RUN / FUTURE. @@ -79,8 +88,9 @@ Status vocabulary: IMPLEMENTED / TESTED / QUALIFIED / NOT_RUN / FUTURE. | **process restart over one sealed Store image** (writer process exits; a second process resolves the same subject id, sequence 2, one intent regime 7 / 1000 ns) | TESTED (host) | `make -C native/kernel test-continuity-subject-restart`: `CK_CONTINUITY_SUBJECT_RESTART: PASS` | | mutants load-bearing and refused in hardware staging | TESTED | `make -C native/kernel continuity-subject-mutants`: `CK_CONTINUITY_SUBJECT_MUTANTS: PASS` | | sanitizer build | TESTED | host-san target of the same test | -| QEMU cold restart over NVMe (ADR 0016 §Qualification shape) | NOT_RUN | no QEMU run was made for kind 24 | -| hardware (Spark NVMe, Secure Boot chain) | NOT_RUN | host tests are not hardware qualification | +| native genesis inside the provisioning transaction; exactly once; refusals; power cut at 9 checkpoints and every block boundary (4096 and 512 byte blocks) leaves unprovisioned or identity + one genesis, never one without the other | IMPLEMENTED, TESTED (host) | `make -C native/kernel test`: `test_continuity_subject_provision: PASS`; `make -C native/kernel continuity-mutants`: `CK_CONTINUITY_SUBJECT_PROVISION_MUTANTS: PASS` (split-transaction mutant killed) | +| **QEMU cold restart over emulated NVMe** (gate `M4_ALLEN`, `scripts/qemu_ck_allen_test.sh`): G7 kernel genesis + one standing intent during provisioning; G8 second provisioning refused; G9 two restores, each a new QEMU process with the same image, same subject, intent and lineage; G10 the subject comes from the disk only; G11 fork, flipped envelope and missing subject never re-provision; G12 a foreign subject chain is refused; SIGKILL at all 9 checkpoints of the genesis transaction then a cold boot | TESTED (QEMU) | receipts `evidence/allen_native_qemu_cfe9aecffb8b20e0c1ff51fad54c46c522ec7d6c56c6cba7661e4b8cda1ee25a.json` and `evidence/ck_gates_1ecf5bcd303bf88422dd0542f14851c931f5d52276838fa182c812f3c73f3c1b.json` (full `ck_gates.sh` at `640522a`), gate log `evidence/allen_native_m4_allen_f50447aa35e01c30deaf5508bc88e5fa3e011ae49d34fd2010f6eefe280a35bb.log`, omega cross-check `evidence/allen_native_omega_xcheck_d0f88c96c7785db00c4a97bc09a6204e8fc5fcff32dbf6cde4a993f155b91111.log`; mutants `subject_restore_mints` and `subject_accept_foreign` KILLED | +| hardware (Spark NVMe, Secure Boot chain, physical cold reboot) | NOT_RUN | host tests and an emulator are not hardware qualification | | OS reboot, machine migration | NOT_RUN | not claimed | | multi-subject Stores | FUTURE | the format does not preclude it (root + agent per object); v0 resolves one chain per root | | manifest link to the subject head | FUTURE | the manifest (kind 17) is frozen; v0 resolves the subject chain by scan | @@ -94,5 +104,5 @@ Status vocabulary: IMPLEMENTED / TESTED / QUALIFIED / NOT_RUN / FUTURE. ## 5. Open questions for the operator -1. Freeze format_version 0 of kind 24 together with ADR 0016, or keep both open until a QEMU cold-restart run has been made for kind 24. +1. Freeze format_version 0 of kind 24 together with ADR 0016, or keep both open until hardware qualification (the QEMU cold-restart run for kind 24 now exists, §3). 2. Whether `origin = promoted` (a subject object written from a Cortex promotion rather than by the operator) is allowed before AEGIS review of the promotion path. diff --git a/evidence/allen_native_m4_allen_f50447aa35e01c30deaf5508bc88e5fa3e011ae49d34fd2010f6eefe280a35bb.log b/evidence/allen_native_m4_allen_f50447aa35e01c30deaf5508bc88e5fa3e011ae49d34fd2010f6eefe280a35bb.log new file mode 100644 index 00000000..13d35446 --- /dev/null +++ b/evidence/allen_native_m4_allen_f50447aa35e01c30deaf5508bc88e5fa3e011ae49d34fd2010f6eefe280a35bb.log @@ -0,0 +1,73 @@ +PASS make refuses the continuity test mode with CK_HARDWARE_STAGING +PASS make refuses the continuity test mode with CK_QEMU_UNSAFE_DMA +PASS make refuses the continuity test mode with the Store crash hook +PASS make refuses a continuity mutant without the TEST mode +PASS make refuses an unknown continuity mutant +PASS default image carries no continuity test strings +PASS TEST continuity image announces itself +PASS default image carries no ALLEN TEST markers +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS G7 native genesis: blank image (store=Refused) -> kernel provisioning created subject 72202492e778f430.. sequence 1 for agent b7790b84adadf955.., lineage bound +PASS G7 standing intent: sequence 2 2c1d46fad965476d.. holds intent e09a6143f9eabe03.. (regime 7, 1000 ns) +PASS G7 host reader: the image holds one genesis and one successor, head 2c1d46fad965476d.. (no host tool created them) +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS G8 second provisioning refused: no genesis, image unchanged +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS G9 cold restart 1: new QEMU process (previous exited 0), same subject 2c1d46fad965476d.., same intent, same lineage, incarnation 2 +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS G9 cold restart 2: new QEMU process (previous exited 0), same subject 2c1d46fad965476d.., same intent, same lineage, incarnation 3 +PASS G9 after two restores: still one genesis, two subject objects, head object byte-identical +PASS G10 restore plan carries no subject, lineage or intent ('AIENCONT v1 mode=6') +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS G10 a second image restores its own subject 4011427261e5854b.. (agent 1bbc5f49928c51f5..), not 2c1d46fad965476d..: the subject comes from the disk +PASS G10 host reader decoded the head object from the sealed Store on the image (2c1d46fad965476d..) +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS G11a forked chain, boot 1: CORRUPT, nothing restored, nothing minted, image unchanged +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS G11a forked chain, boot 2: CORRUPT, nothing restored, nothing minted, image unchanged +PASS G11a image still holds exactly the planted objects (3), no replacement +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS G11b corrupted subject envelope: refused ('CONTINUITY: STOP (store Refused(-303))'), nothing restored or minted, image unchanged +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS G11c missing subject, boot 1: ABSENT reported, none minted +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS G11c missing subject, boot 2: ABSENT reported, none minted +PASS G11c host reader: still no subject object on the image +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS G12a foreign chain beside our own: CORRUPT (another agent), nothing restored or minted, image unchanged +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS G12b foreign chain on a subjectless identity: refused, never adopted, nothing minted, image unchanged +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS FI.1 SIGKILL at before_first_write: cold boot finds the old state (unprovisioned, no subject) +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS FI.1b interrupted provisioning that committed nothing can be provisioned again +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS FI.2 SIGKILL at after_payload_objects: cold boot finds the old state (unprovisioned, no subject) +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS FI.3 SIGKILL at after_catalog: cold boot finds the old state (unprovisioned, no subject) +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS FI.4 SIGKILL at after_commit_record: cold boot finds the old state (unprovisioned, no subject) +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS FI.5 SIGKILL at after_first_flush: cold boot finds the old state (unprovisioned, no subject) +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS FI.6 SIGKILL at after_inactive_superblock: cold boot finds the new state (identity with its genesis subject) +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS FI.7 SIGKILL at after_final_flush: cold boot finds the new state (identity with its genesis subject) +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS FI.8 SIGKILL at before_anchor: cold boot finds the new state (identity with its genesis subject) +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +Could not open option rom 'vgabios-ramfb.bin': No such file or directory +PASS FI.9 SIGKILL at after_anchor: cold boot finds the new state (identity with its genesis subject) +ALLEN_FACTS agent=b7790b84adadf9550c781586b215523dd83598c6a61535500ad827c1397069b4 genesis=72202492e778f4300c734ee8ac158ed5fd664faaa1475fd27aed65b5a3092704 subject=2c1d46fad965476dedb6e74e2a4601f0d1438c580a81bbc7a621e4924035b011 intent=e09a6143f9eabe03d41455b4c4624cdc979f172554a6a107589671e137f2b721 lineage=e3f241da5ea18408653a70e3691653db216b5dcc51169b799827cf4f2699731b regime=7 target_ns=1000 prov_image_sha256=b2f94e53a1abe7b499813a337537f3c0d96d3440b7fc805f524e7774352a5987 head_object_sha256=dd543b4315deb24073b1cbb34072f8d06c26369d8a9c1780c6097d5c9400912e +rows 30/30; M1 failures: 0 +AIENOS_CK_M4_ALLEN: PASS diff --git a/evidence/allen_native_omega_xcheck_d0f88c96c7785db00c4a97bc09a6204e8fc5fcff32dbf6cde4a993f155b91111.log b/evidence/allen_native_omega_xcheck_d0f88c96c7785db00c4a97bc09a6204e8fc5fcff32dbf6cde4a993f155b91111.log new file mode 100644 index 00000000..273dc192 --- /dev/null +++ b/evidence/allen_native_omega_xcheck_d0f88c96c7785db00c4a97bc09a6204e8fc5fcff32dbf6cde4a993f155b91111.log @@ -0,0 +1,34 @@ +## omega b544d81db1f8d576685a8de19add13c7c59b052a tool 8b05208a74691cb23f05dde76282967e60fde6e7eb667dabdaf9b09382e1e48d +## head object sha256 dd543b4315deb24073b1cbb34072f8d06c26369d8a9c1780c6097d5c9400912e +## inspect +ALLEN subject 2c1d46fad965476dedb6e74e2a4601f0d1438c580a81bbc7a621e4924035b011 +ALLEN agent b7790b84adadf9550c781586b215523dd83598c6a61535500ad827c1397069b4 +ALLEN root e8efb1a747b644397fca48565dd925a29655cba2ba8bba285c3d4b41709f37c9 +ALLEN chain sequence 2 previous 72202492e778f4300c734ee8ac158ed5fd664faaa1475fd27aed65b5a3092704 +ALLEN cortex e3f241da5ea18408653a70e3691653db216b5dcc51169b799827cf4f2699731b +ALLEN provenance 4d9afd341d68f58e0ac71ed68d0125017a8bd2a16afc3038a0e0e40dfcc5956d origin 1 +ALLEN intents 1 knowledge 0 +ALLEN intent e09a6143f9eabe03d41455b4c4624cdc979f172554a6a107589671e137f2b721 kind 1 state 1 since 2 regime 7 target_ns 1000 +rc=0 +## publish j1 (seed 1) +ALLEN seeded journal j1.cx record 1 lineage e3f241da5ea18408653a70e3691653db216b5dcc51169b799827cf4f2699731b +ALLEN subject 2c1d46fad965476dedb6e74e2a4601f0d1438c580a81bbc7a621e4924035b011 +ALLEN agent b7790b84adadf9550c781586b215523dd83598c6a61535500ad827c1397069b4 +ALLEN root e8efb1a747b644397fca48565dd925a29655cba2ba8bba285c3d4b41709f37c9 +ALLEN chain sequence 2 previous 72202492e778f4300c734ee8ac158ed5fd664faaa1475fd27aed65b5a3092704 +ALLEN cortex e3f241da5ea18408653a70e3691653db216b5dcc51169b799827cf4f2699731b +ALLEN provenance 4d9afd341d68f58e0ac71ed68d0125017a8bd2a16afc3038a0e0e40dfcc5956d origin 1 +ALLEN intents 1 knowledge 0 +ALLEN intent e09a6143f9eabe03d41455b4c4624cdc979f172554a6a107589671e137f2b721 kind 1 state 1 since 2 regime 7 target_ns 1000 +ALLEN binding external_subject 7 agent b7790b84adadf9550c781586b215523dd83598c6a61535500ad827c1397069b4 sequence 2 +ALLEN memory BOUND lineage e3f241da5ea18408653a70e3691653db216b5dcc51169b799827cf4f2699731b journal j1.cx +ALLEN model none (no model required) +ALLEN publish intent e09a6143f9eabe03d41455b4c4624cdc979f172554a6a107589671e137f2b721 -> EXTERNAL crumb 12 +ALLEN goal object seq 1 regime 7 target_ns 1000 intent_lo 03beeaf943619ae0 +AIEN assess activations 1 in_episode_of_last_publish 1 assessment goal_seq 1 status 1 +ALLEN published 1 goals_in_world 1 crumbs 14 journal_records 15 +rc=0 +## publish j2 (seed 2, other lineage) +ALLEN seeded journal j2.cx record 1 lineage 513564b418797e33dedaa4548640db09029c6c0e58dabe2f5686b2bd6883744d +allen: refused: Cortex lineage mismatch: this journal is not the subject's memory +rc=3 diff --git a/evidence/allen_native_qemu_cfe9aecffb8b20e0c1ff51fad54c46c522ec7d6c56c6cba7661e4b8cda1ee25a.json b/evidence/allen_native_qemu_cfe9aecffb8b20e0c1ff51fad54c46c522ec7d6c56c6cba7661e4b8cda1ee25a.json new file mode 100644 index 00000000..77f026cf --- /dev/null +++ b/evidence/allen_native_qemu_cfe9aecffb8b20e0c1ff51fad54c46c522ec7d6c56c6cba7661e4b8cda1ee25a.json @@ -0,0 +1,287 @@ +{ + "schema": "aienos.allen_native.v1", + "results": { + "ALLEN_V0_HOST": { + "verdict": "PASS", + "evidence": "omega evidence/ALLEN/18cfa250cee91ce5abe4cba21fa9fb70da4df36b9b593924b86538dcdfdfabef.json (omega b544d81)", + "note": "host rig; unchanged, not relabelled" + }, + "ALLEN_NATIVE_PROVISIONING": { + "verdict": "PASS", + "gates": [ + "G7", + "G8", + "G10", + "FI" + ], + "note": "the kernel (TEST continuity image) creates the genesis subject inside the identity provisioning transaction; no host tool creates it" + }, + "ALLEN_QEMU_COLD_RESTART": { + "verdict": "PASS", + "gates": [ + "G9", + "G10", + "G11", + "G12" + ], + "note": "each boot is a new qemu-system-aarch64 process; ESP and UEFI vars rebuilt per boot; only the NVMe image file carries state" + } + }, + "gate_M4_ALLEN": { + "verdict_in_ck_receipt": "PASS", + "pass_lines": 37, + "fail_lines": 0, + "gate_rows_line": "rows 30/30; M1 failures: 0", + "lines": [ + "PASS make refuses the continuity test mode with CK_HARDWARE_STAGING", + "PASS make refuses the continuity test mode with CK_QEMU_UNSAFE_DMA", + "PASS make refuses the continuity test mode with the Store crash hook", + "PASS make refuses a continuity mutant without the TEST mode", + "PASS make refuses an unknown continuity mutant", + "PASS default image carries no continuity test strings", + "PASS TEST continuity image announces itself", + "PASS default image carries no ALLEN TEST markers", + "PASS G7 native genesis: blank image (store=Refused) -> kernel provisioning created subject 72202492e778f430.. sequence 1 for agent b7790b84adadf955.., lineage bound", + "PASS G7 standing intent: sequence 2 2c1d46fad965476d.. holds intent e09a6143f9eabe03.. (regime 7, 1000 ns)", + "PASS G7 host reader: the image holds one genesis and one successor, head 2c1d46fad965476d.. (no host tool created them)", + "PASS G8 second provisioning refused: no genesis, image unchanged", + "PASS G9 cold restart 1: new QEMU process (previous exited 0), same subject 2c1d46fad965476d.., same intent, same lineage, incarnation 2", + "PASS G9 cold restart 2: new QEMU process (previous exited 0), same subject 2c1d46fad965476d.., same intent, same lineage, incarnation 3", + "PASS G9 after two restores: still one genesis, two subject objects, head object byte-identical", + "PASS G10 restore plan carries no subject, lineage or intent ('AIENCONT v1 mode=6')", + "PASS G10 a second image restores its own subject 4011427261e5854b.. (agent 1bbc5f49928c51f5..), not 2c1d46fad965476d..: the subject comes from the disk", + "PASS G10 host reader decoded the head object from the sealed Store on the image (2c1d46fad965476d..)", + "PASS G11a forked chain, boot 1: CORRUPT, nothing restored, nothing minted, image unchanged", + "PASS G11a forked chain, boot 2: CORRUPT, nothing restored, nothing minted, image unchanged", + "PASS G11a image still holds exactly the planted objects (3), no replacement", + "PASS G11b corrupted subject envelope: refused ('CONTINUITY: STOP (store Refused(-303))'), nothing restored or minted, image unchanged", + "PASS G11c missing subject, boot 1: ABSENT reported, none minted", + "PASS G11c missing subject, boot 2: ABSENT reported, none minted", + "PASS G11c host reader: still no subject object on the image", + "PASS G12a foreign chain beside our own: CORRUPT (another agent), nothing restored or minted, image unchanged", + "PASS G12b foreign chain on a subjectless identity: refused, never adopted, nothing minted, image unchanged", + "PASS FI.1 SIGKILL at before_first_write: cold boot finds the old state (unprovisioned, no subject)", + "PASS FI.1b interrupted provisioning that committed nothing can be provisioned again", + "PASS FI.2 SIGKILL at after_payload_objects: cold boot finds the old state (unprovisioned, no subject)", + "PASS FI.3 SIGKILL at after_catalog: cold boot finds the old state (unprovisioned, no subject)", + "PASS FI.4 SIGKILL at after_commit_record: cold boot finds the old state (unprovisioned, no subject)", + "PASS FI.5 SIGKILL at after_first_flush: cold boot finds the old state (unprovisioned, no subject)", + "PASS FI.6 SIGKILL at after_inactive_superblock: cold boot finds the new state (identity with its genesis subject)", + "PASS FI.7 SIGKILL at after_final_flush: cold boot finds the new state (identity with its genesis subject)", + "PASS FI.8 SIGKILL at before_anchor: cold boot finds the new state (identity with its genesis subject)", + "PASS FI.9 SIGKILL at after_anchor: cold boot finds the new state (identity with its genesis subject)" + ] + }, + "bound_to": { + "aienos_commit": "640522a03b9f939d2d07ef0d0fdc08e35ecefc7e", + "ck_gates_receipt": "evidence/ck_gates_1ecf5bcd303bf88422dd0542f14851c931f5d52276838fa182c812f3c73f3c1b.json", + "ck_gates_receipt_sha256": "1ecf5bcd303bf88422dd0542f14851c931f5d52276838fa182c812f3c73f3c1b", + "allen_child": { + "name": "allen", + "script": "scripts/qemu_ck_allen_test.sh", + "present": true, + "script_sha256": "0fe58465d5183781b8339f50861fd76f7773051bee939b73fdaede4b7a752355", + "exit": "0", + "seconds": 212, + "log_sha256": "f50447aa35e01c30deaf5508bc88e5fa3e011ae49d34fd2010f6eefe280a35bb", + "log_lines": 73 + }, + "omega_commit": "b544d81db1f8d576685a8de19add13c7c59b052a", + "omega_allen_tool_sha256": "8b05208a74691cb23f05dde76282967e60fde6e7eb667dabdaf9b09382e1e48d" + }, + "qemu": { + "version": "QEMU emulator version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.18)", + "machine": "-M virt,virtualization=on,gic-version=3,iommu=smmuv3 -accel tcg,thread=single -cpu max -smp 4 -m 2048", + "nvme": "-device nvme,drive=nvme0,serial=aienos-continuity,logical_block_size=4096,physical_block_size=4096 (raw image, 64 MiB GPT)", + "boot": "-no-reboot; one process per boot; pflash AAVMF code read-only, vars copied fresh per boot", + "firmware": { + "aavmf_code": "/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd", + "aavmf_code_sha256": "4a4cb7f6d8106bb2a7dd8c763fab14b1810152136fc4304e5b728f0043e84f12", + "aavmf_vars": "/usr/share/AAVMF/AAVMF_VARS.fd", + "aavmf_vars_sha256": "b3b855c5a80310168051164986855692d1bdb06e67619856177965cd87c6774f" + }, + "host": { + "hostname": "spark-b87b", + "arch": "aarch64", + "kernel": "7.0.0-1019-nvidia", + "cpu_model": "Cortex-A725;Cortex-X925" + }, + "quiet_flag": "/home/drakestapleton/.claude/jobs/cb2575c5/tmp/quiet-allen" + }, + "subject": { + "agent": "b7790b84adadf9550c781586b215523dd83598c6a61535500ad827c1397069b4", + "genesis_subject": "72202492e778f4300c734ee8ac158ed5fd664faaa1475fd27aed65b5a3092704", + "head_subject": "2c1d46fad965476dedb6e74e2a4601f0d1438c580a81bbc7a621e4924035b011", + "head_sequence": 2, + "standing_intent": { + "id": "e09a6143f9eabe03d41455b4c4624cdc979f172554a6a107589671e137f2b721", + "kind": "GOAL_LATENCY", + "regime": 7, + "target_ns": 1000 + }, + "cortex_lineage": "e3f241da5ea18408653a70e3691653db216b5dcc51169b799827cf4f2699731b", + "provisioning_request": "AIENCONT v1 mode=5 lineage= intent=7,1000 (provenance = SHA-256 of this plan line)", + "restore_request": "AIENCONT v1 mode=6 (carries no subject, lineage or intent)" + }, + "state_digests": { + "pre_blank_image_sha256": "6dd0fa809e4b3a8315309ea389c3051366bdbd8f49dbbd04062a2515f738dba8", + "post_provision_image_sha256": "b2f94e53a1abe7b499813a337537f3c0d96d3440b7fc805f524e7774352a5987", + "head_object_sha256": "dd543b4315deb24073b1cbb34072f8d06c26369d8a9c1780c6097d5c9400912e", + "serial_logs": [ + { + "file": "qemu_ck_allen_0.log", + "sha256": "ac7e3e922f8db14513173fc6dd7b4c5d6ef4d507895255624bc520d0bba67ad7" + }, + { + "file": "qemu_ck_allen_10.log", + "sha256": "954004dd7281b0646d3d5b09da539a6fc4ee690b2e1caaba81bbd53313cf1f50" + }, + { + "file": "qemu_ck_allen_11.log", + "sha256": "0374e30ded3c449bc8e0f150219b57457c0d809deeca522d9531c50061e0c38e" + }, + { + "file": "qemu_ck_allen_12.log", + "sha256": "47b8c6860f817d808b2ed5ec48a5d24f353c58fe13b0b8f69051bd386eb71a21" + }, + { + "file": "qemu_ck_allen_13.log", + "sha256": "b28c188c74d24ec8eeec35ee32b07496d9eb620ce40dff45b69518026e9557ff" + }, + { + "file": "qemu_ck_allen_14.log", + "sha256": "ed80704523fab63541836ccf2b78e2102eb4d723a59f2cd341aba34e8df425ba" + }, + { + "file": "qemu_ck_allen_15.log", + "sha256": "17fe1c232f8e3386cafeee9f61fd7aa906095369a8701041790b15c6c1e03318" + }, + { + "file": "qemu_ck_allen_16.log", + "sha256": "e618caae0f7dda22a8f29b9bd7d5f37bfd3def81f7acf7066fa9ca89c1fb1ace" + }, + { + "file": "qemu_ck_allen_17.log", + "sha256": "02c66a43d51231ef277542207ae02a90ec32600ac1576a6505eb417696dc1eb5" + }, + { + "file": "qemu_ck_allen_18.log", + "sha256": "9bcca5c73657120736950bf9986caba4224ece715fdbc8e65f797835288e50d1" + }, + { + "file": "qemu_ck_allen_19.log", + "sha256": "13299acfadd675a793eceaf44eee84a4411ebad7b3b8e22f40a62083f12cdc78" + }, + { + "file": "qemu_ck_allen_1.log", + "sha256": "2b24cc1e2085368c1f85afc30e0548a63a58517aab4074b84a4eee1dd1601199" + }, + { + "file": "qemu_ck_allen_20.log", + "sha256": "c4cb2db4223027bec4da57dcc96fe0e67ebaa8d3bbc7e21515eb53c59163b7dd" + }, + { + "file": "qemu_ck_allen_21.log", + "sha256": "00e7c482402238e343a38c20f8e256a7cce74b438e862ba561babb754ce27e9a" + }, + { + "file": "qemu_ck_allen_22.log", + "sha256": "90144e9f1e01cf464d7bc0eb156457fd645d3fc51b017db038843af41a6e2a95" + }, + { + "file": "qemu_ck_allen_23.log", + "sha256": "9c7599121dad402c90629fe4c813ab6da7b131c37138f7598f6156aac5aaaf7b" + }, + { + "file": "qemu_ck_allen_2.log", + "sha256": "9f7f54af81c2da0c08b12f9730f170d71d56bfd7d84ca715e3f78d7087b2ef39" + }, + { + "file": "qemu_ck_allen_3.log", + "sha256": "a4c34245f5d0df1f9ff455d9ad8f70a43a9451aff924a7016551a2c5d2de7343" + }, + { + "file": "qemu_ck_allen_4.log", + "sha256": "f8945e383e73bf9935f2ee81cf4f1067b96a5bd67713d776d7d2f89da21324b6" + }, + { + "file": "qemu_ck_allen_5.log", + "sha256": "5ba210589b65552a65bcabe25373f4f85c189e94203a5f731cf3202260b304d1" + }, + { + "file": "qemu_ck_allen_6.log", + "sha256": "adb921ae190bfebea9744e56d8f12f9d4b669ae5f447af3900e2f205c702110e" + }, + { + "file": "qemu_ck_allen_7.log", + "sha256": "970b4adb26b0b1702892d8525cfc17dc831e43ff675860ae7d709f5f38b55cd0" + }, + { + "file": "qemu_ck_allen_8.log", + "sha256": "92a22dbee88b5336ac84c258e2fda8b2ffb7c028716e23a9259d2b36ee2381f3" + }, + { + "file": "qemu_ck_allen_9.log", + "sha256": "851bb5550edbe4e29506e358477457154abaec9fdb69afaa37086e25b364e361" + }, + { + "file": "qemu_ck_allen_kill_after_anchor.log", + "sha256": "f8bce50815c485ebf5ab344721db8da9c64509c2bbb3bbb7e926260d8c23627d" + }, + { + "file": "qemu_ck_allen_kill_after_catalog.log", + "sha256": "9561ac1758b01fde2749af7ca2b2b3935e4f2c6df3a8fccf6deffc699a6fd797" + }, + { + "file": "qemu_ck_allen_kill_after_commit_record.log", + "sha256": "31c3a9c81ad003e38e595df114db5f5680140aa4793cdbe2891c99d7c762bd2a" + }, + { + "file": "qemu_ck_allen_kill_after_final_flush.log", + "sha256": "292cee6c626ae2c0b5c483d0a43f8d6aaf283001ab48c922ab8fea2aaec38496" + }, + { + "file": "qemu_ck_allen_kill_after_first_flush.log", + "sha256": "ba69938b7d559c8b4be1c00034191822f0f9b977e00a8b0cae3111c2d0fd012b" + }, + { + "file": "qemu_ck_allen_kill_after_inactive_superblock.log", + "sha256": "ed4e667a02f8f1a8b1b7bdc57bcd5b9bed2c638786743df4baf4014cca842c79" + }, + { + "file": "qemu_ck_allen_kill_after_payload_objects.log", + "sha256": "1f81db56f98def8c9bfe5ceb1feb6bdb7fde70b77d9b1b63e623b240ffab14bd" + }, + { + "file": "qemu_ck_allen_kill_before_anchor.log", + "sha256": "3e60b210c973a54edda2c9822a4fb4740d9b3e369f4a68a81057b14d98703ff9" + }, + { + "file": "qemu_ck_allen_kill_before_first_write.log", + "sha256": "6a24b92a8ed90cb65fcde394e448eb7d5f3aa4c3c587642c5e6d9f5e169ee2db" + } + ] + }, + "omega_cross_check": { + "log_sha256": "d0f88c96c7785db00c4a97bc09a6204e8fc5fcff32dbf6cde4a993f155b91111", + "claim": "omega allen inspect/publish of the head object the kernel wrote: same subject, intent, lineage; the intent becomes the AIEN goal; a journal of another lineage is refused" + }, + "r16": { + "new_semantic_orchestrator": false, + "new_allen_loop_sites": 0, + "note": "new kernel code holds only bounded data loops; no thread, wait, timer, poll or scheduling; omega unchanged by this work; omega R16 inventory pre-existing FAIL (76 unclassified, 2 stale) is recorded in the omega host receipt and not weakened" + }, + "not_proven": [ + "physical DGX Spark cold reboot", + "physical NVMe", + "machine migration", + "multi-subject", + "default (production) image provisioning: it provisions no identity today", + "full lifecycle" + ], + "adr_status": { + "aienos_ADR_0018": "PROPOSED", + "ARCH_0035": "PROPOSED", + "canonical_creed_changed": false + } +} diff --git a/evidence/ck_gates_1ecf5bcd303bf88422dd0542f14851c931f5d52276838fa182c812f3c73f3c1b.json b/evidence/ck_gates_1ecf5bcd303bf88422dd0542f14851c931f5d52276838fa182c812f3c73f3c1b.json new file mode 100644 index 00000000..f64a5254 --- /dev/null +++ b/evidence/ck_gates_1ecf5bcd303bf88422dd0542f14851c931f5d52276838fa182c812f3c73f3c1b.json @@ -0,0 +1,57 @@ +{ + "schema": "aienos.ck_gates.v1", + "started_utc": "2026-10-05T02:02:21Z", + "finished_utc": "2026-10-05T02:26:41Z", + "commit": "640522a03b9f939d2d07ef0d0fdc08e35ecefc7e", + "commit_subject": "continuity: ALLEN native genesis at provisioning and QEMU cold restore (M4_ALLEN)", + "tree_clean_before": true, + "tree_clean_after": true, + "quiet_flag": "/home/drakestapleton/.claude/jobs/cb2575c5/tmp/quiet-allen", + "quiet_flag_present_at_start": false, + "host": {"hostname": "spark-b87b", "arch": "aarch64", "kernel": "7.0.0-1019-nvidia", "cpu_model": "Cortex-A725;Cortex-X925"}, + "qemu": {"binary": "/usr/bin/qemu-system-aarch64", "version": "QEMU emulator version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.18)"}, + "firmware": {"aavmf_code": "/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd", "aavmf_code_sha256": "4a4cb7f6d8106bb2a7dd8c763fab14b1810152136fc4304e5b728f0043e84f12", "aavmf_vars": "/usr/share/AAVMF/AAVMF_VARS.fd", "aavmf_vars_sha256": "b3b855c5a80310168051164986855692d1bdb06e67619856177965cd87c6774f"}, + "nvme_dma_mode": "Confined (QEMU SMMUv3 stage 1, out-of-window DMA faulted); no-SMMU boot denied (NoSmmu); TEST-ONLY bypass image checked separately", + "children": [ + {"name": "boot", "script": "scripts/qemu_ck_boot_test.sh", "present": true, "script_sha256": "d17a7e0f00081e935a804c092c9b05c0bd1f319f5dd5c8bd90f3982e8939c3c8", "exit": "0", "seconds": 7, "log_sha256": "48807b28615e79cebd8d88a62913b7ba7f6a7e76baed243318a1afa04016230b", "log_lines": 24}, + {"name": "store", "script": "scripts/qemu_ck_store_test.sh", "present": true, "script_sha256": "0b31a44af9388302d5488fdef318a509c4f26c2420f82ceb2fa7f7b698647748", "exit": "0", "seconds": 95, "log_sha256": "51f7f9be554fce446db6311bc5bae3fa038a557242d854a52e19dbccc24d10b5", "log_lines": 612}, + {"name": "net", "script": "scripts/qemu_ck_net_test.sh", "present": true, "script_sha256": "ea051cc946c206f92c0c1563b3463b6bebffbce04e361e76d51dd49c1be4a6cf", "exit": "0", "seconds": 19, "log_sha256": "ce695b5af5130ef46ff46f3bea4eea39a699bd51e9ffbfd636da6aac4b2057ac", "log_lines": 95}, + {"name": "artifact", "script": "scripts/qemu_ck_artifact_test.sh", "present": true, "script_sha256": "e60f6c4aed822f693a530cb98b2fa4689b7b56e7c0efed5f9bf9ff4e9f75fc67", "exit": "0", "seconds": 36, "log_sha256": "04a436560240b1473a80a4cf37cce880c21e462ab09226e889dcd239eda72aad", "log_lines": 215}, + {"name": "smp", "script": "scripts/qemu_ck_smp_test.sh", "present": true, "script_sha256": "b5665568394f391c17aaa9148bce2358f1145240cc38422c2927664b0ffd41d6", "exit": "0", "seconds": 7, "log_sha256": "81f2c65aae39e9db66bb4766d3f2328b931b1f6766c6b3eb57583c856029e6aa", "log_lines": 16}, + {"name": "crash", "script": "scripts/qemu_ck_store_crash_test.sh", "present": true, "script_sha256": "3d04ca0775db7e70a244b6a09b19c5adf987f777b6ff630874c42e339add7765", "exit": "0", "seconds": 709, "log_sha256": "4059e2ca3fc2df078693ca717505424da031e32d9b8da1a159ced4e993dc12c6", "log_lines": 239}, + {"name": "disk", "script": "scripts/qemu_ck_disk_layout_test.sh", "present": true, "script_sha256": "f490548245252b97518e9049ce8e7078f5297c81584b60f08f802cfea6bb3110", "exit": "0", "seconds": 60, "log_sha256": "4fd8335f4750aaa281e3575c332cf1951aa211057050394ff2602ec52be88203", "log_lines": 264}, + {"name": "cont", "script": "scripts/qemu_ck_continuity_test.sh", "present": true, "script_sha256": "30a8eb2dbb949eab29ad046231869a306199908022cb2345151988ea4957cf2e", "exit": "0", "seconds": 185, "log_sha256": "5e5623c4a4c868b2f5c83926af81af9f20ec8070f90d1e7745a7907efb9f78bb", "log_lines": 57}, + {"name": "recov", "script": "scripts/qemu_ck_recovery_test.sh", "present": true, "script_sha256": "89c461e211532f6577d2c88668ae8ca0d32d91f3b29ce6e39f7082a03a45b8cc", "exit": "0", "seconds": 119, "log_sha256": "500cd02050eae8f2f4aa34fdb004ff4d5399751de25de9dfe554ed5cdca32e30", "log_lines": 46}, + {"name": "allen", "script": "scripts/qemu_ck_allen_test.sh", "present": true, "script_sha256": "0fe58465d5183781b8339f50861fd76f7773051bee939b73fdaede4b7a752355", "exit": "0", "seconds": 212, "log_sha256": "f50447aa35e01c30deaf5508bc88e5fa3e011ae49d34fd2010f6eefe280a35bb", "log_lines": 73}, + {"name": "fpu", "script": "scripts/qemu_ck_fpu_test.sh", "present": true, "script_sha256": "f04fa538752f6864bc2d5f9ff5af6eac71a5e3a005fe9c76b77477012325cc14", "exit": "3", "seconds": 3, "log_sha256": "3f88a53e3176404950a62a1cc76f11ba1db201604c396f535319bcfa853897a4", "log_lines": 2}, + {"name": "infer", "script": "scripts/qemu_ck_infer_test.sh", "present": true, "script_sha256": "185c78b8688004dc6a807182c81e319b1598414935934b6c881cfafae5ce31fa", "exit": "3", "seconds": 3, "log_sha256": "af95e1b1273486429b7d3d5d3c8ccd274a882e8daa62377163cd2deb6dd18597", "log_lines": 2}, + {"name": "screen", "script": "scripts/qemu_ck_screen_test.sh", "present": true, "script_sha256": "b2b71aff7fb9274eb15d8381e44dda9d7b700821fd45a23cde1c9a1132dc6b3f", "exit": "3", "seconds": 5, "log_sha256": "98a17a8f46bd03c91cd81e2f9596a607915f1d0d53e93cb7bd0bc2aef971665d", "log_lines": 2} + ], + "gates": [ + {"id": "M1", "marker": "AIENOS_CK_M1", "source": "boot", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "M3", "marker": "AIENOS_CK_M3", "source": "boot", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "SMMU", "marker": "AIENOS_CK_SMMU", "source": "store", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "NVME_SHUTDOWN", "marker": "AIENOS_CK_NVME_SHUTDOWN", "source": "store", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "P2_ARTIFACT", "marker": "AIENOS_CK_P2_ARTIFACT", "source": "artifact", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "M0_ROLLBACK", "marker": "AIENOS_CK_M0_ROLLBACK", "source": "missing", "verdict": "NOT_RUN", "reason": "MISSING_IMPLEMENTATION: C loader signatures, A/B, BootNext and rollback are parked (native/boot/README.md)"}, + {"id": "M4_NVME", "marker": "AIENOS_CK_M4_NVME", "source": "store", "verdict": "PASS", "reason": "SMMU-confined NVMe DMA in QEMU (iommu=smmuv3, default build); TEST-ONLY bypass build boot-checked separately"}, + {"id": "M4_STORE", "marker": "AIENOS_CK_M4_STORE", "source": "store", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "M4_STORE_CRASH", "marker": "AIENOS_CK_M4_STORE_CRASH", "source": "crash", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "M4_CONTINUITY", "marker": "AIENOS_CK_M4_CONTINUITY", "source": "cont", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "M4_RECOVERY", "marker": "AIENOS_CK_M4_RECOVERY", "source": "recov", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "M4_ALLEN", "marker": "AIENOS_CK_M4_ALLEN", "source": "allen", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "ARGUS1_REVOKE", "marker": "AIENOS_CK_ARGUS1_REVOKE", "source": "store", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "KEYBOARD", "marker": "AIENOS_CK_KEYBOARD", "source": "missing", "verdict": "NOT_RUN", "reason": "MISSING_IMPLEMENTATION: no xHCI/USB HID keyboard driver in the C kernel"}, + {"id": "NET", "marker": "AIENOS_CK_NET", "source": "net", "verdict": "PASS", "reason": "QEMU user networking (slirp), virtio-net with ACCESS_PLATFORM required behind the smmuv3 vIOMMU; this PASS covers: attach, UDP TX seen by the host helper, UDP reply RX parsed by M6-A, an out-of-window device DMA refused (F_TRANSLATION, page intact) and recovery by reset, as checked by this run only; QEMU, not hardware"}, + {"id": "SMP", "marker": "AIENOS_CK_SMP", "source": "smp", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "DISK_LAYOUT", "marker": "AIENOS_CK_DISK_LAYOUT", "source": "disk", "verdict": "PASS", "reason": "child reported PASS, exit 0"}, + {"id": "FPU", "marker": "AIENOS_CK_FPU", "source": "fpu", "verdict": "NOT_RUN", "reason": "child reported NOT_RUN (exit 3)"}, + {"id": "INFER", "marker": "AIENOS_CK_INFER", "source": "infer", "verdict": "NOT_RUN", "reason": "child reported NOT_RUN (exit 3)"}, + {"id": "SCREEN", "marker": "AIENOS_CK_SCREEN", "source": "screen", "verdict": "NOT_RUN", "reason": "child reported NOT_RUN (exit 3)"} + ], + "counts": {"total": 20, "pass": 15, "fail": 0, "not_run": 5}, + "verdict": "NOT_ALL_GATES_PASS", + "parity": "native/kernel/GATES.md", + "physical": "NOT_RUN", + "physical_statement": "QEMU emulator runs only. Nothing here was run on Machine 1 or any GB10; no physical qualification is claimed." +} diff --git a/native/.crumb b/native/.crumb index 19e02b09..b2fbcebe 100644 --- a/native/.crumb +++ b/native/.crumb @@ -79,8 +79,8 @@ "purpose": "Directory native/disk. Purpose not yet described by a human." }, { - "digest": "8e35a9e1835b16a6cb134750cfeeeec6d305657c54fe1d314f104281e620a69c", - "last_commit": "fbbfc9c", + "digest": "34045d52cf1ce9839b95234570e02f8a20bda7a3db7aa372b269216e56de0c14", + "last_commit": "640522a", "name": "kernel", "purpose": "Directory native/kernel. Purpose not yet described by a human." }, @@ -109,15 +109,15 @@ "purpose": "Directory native/store. Purpose not yet described by a human." } ], - "children_root": "sha256:80f2c4f08f2c4fb4507e247a920c0efbf74c0772a777f3d26a9107da0f8b546e", - "compiled_at": "2026-10-05T00:51:39Z", + "children_root": "sha256:5ab2c82623d9812f31030e96f594b08e9b95758ee4f3bb585ae6219689009b45", + "compiled_at": "2026-10-05T02:27:48Z", "compiler": "crumb-compile/1", - "digest": "sha256:e6f06b76c4d9c1884afb930cfbb1b72266981bbe588b75705b1211ed150cc0d9", + "digest": "sha256:4c3af9c590d65bc53f1ff800c6c71a182d1198942af77723468fc3b1ec983d7d", "evidence_files": 4, "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335", - "files": 303, - "generated_at_commit": "fbbfc9c90b5609cdd94a327fad3503366e1b11b1", - "source_tree": "sha256:7815bc208ce76ad5bc86a6af2a24bb33e9bd7b4be86f1e32d6de1255493e927f" + "files": 306, + "generated_at_commit": "640522a03b9f939d2d07ef0d0fdc08e35ecefc7e", + "source_tree": "sha256:7dce6ca5a3f01416b5d98ea50618a61d9bc7ee5f8094710283fd1d6b1a180b32" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/.crumb b/native/kernel/.crumb index 281b7ad8..84bb06d3 100644 --- a/native/kernel/.crumb +++ b/native/kernel/.crumb @@ -81,33 +81,33 @@ "purpose": "Directory native/kernel/mm. Purpose not yet described by a human." }, { - "digest": "a869aee7e92862a2d16efb62a0d881209fe82a9ba1b70332050f755a58230630", - "last_commit": "fbbfc9c", + "digest": "f24db6711bf88a0d7c48375f6f979fd589306a9266c697c5f25d4e8a2dbdb90d", + "last_commit": "640522a", "name": "svc", "purpose": "Directory native/kernel/svc. Purpose not yet described by a human." }, { - "digest": "2becacc3ed46f19dcd0a7b91acef18c77abb4e2f1231204a1ab02d74b244e80c", - "last_commit": "fbbfc9c", + "digest": "20157ea957a698743f9078faf6c765b507733f9a9e67877ea5602c7f461b7a7b", + "last_commit": "640522a", "name": "tests", "purpose": "Directory native/kernel/tests. Purpose not yet described by a human." }, { - "digest": "76d69ccab500306184f1ee05b9b252c740236a9656ceda44fe96c93bce2f2b21", - "last_commit": "fbbfc9c", + "digest": "5e6a44b4b936178bd58d2840921cc5d478ed9126ffea1aa3c36d628a6598549f", + "last_commit": "640522a", "name": "tools", "purpose": "Directory native/kernel/tools. Purpose not yet described by a human." } ], - "children_root": "sha256:433b5ab933dc9613e1b5b300532e3d4ec3dd21fd1b1bd7b18ddfe22f332daebc", - "compiled_at": "2026-10-05T00:51:39Z", + "children_root": "sha256:2030704d394ed4b573afc5f97226836308cfab5e9d7f6e4279deb2170cb42628", + "compiled_at": "2026-10-05T02:27:48Z", "compiler": "crumb-compile/1", - "digest": "sha256:8e35a9e1835b16a6cb134750cfeeeec6d305657c54fe1d314f104281e620a69c", + "digest": "sha256:34045d52cf1ce9839b95234570e02f8a20bda7a3db7aa372b269216e56de0c14", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 139, - "generated_at_commit": "fbbfc9c90b5609cdd94a327fad3503366e1b11b1", - "source_tree": "sha256:8f8be86b10860cc789c9cc253b3c07aa3810db6e523c14df8e492d9deae2ac1b" + "files": 142, + "generated_at_commit": "640522a03b9f939d2d07ef0d0fdc08e35ecefc7e", + "source_tree": "sha256:9d452ec08da8105e068565db40d91f630dddd15e9045da7d7c687e760eebbe78" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/GATES.md b/native/kernel/GATES.md index f6570344..ba58eee1 100644 --- a/native/kernel/GATES.md +++ b/native/kernel/GATES.md @@ -25,7 +25,7 @@ C gates (one line each from `ck_gates.sh`): `M1` and `M3` (from `scripts/qemu_ck_net_test.sh`; rows 102-106 and 110-112; the script now also checks the virtio-net SMMU fence (ACCESS_PLATFORM required, out-of-window device DMA refused), rows 102 and 110-112 are QEMU PASS on this branch from the committed forge log `evidence/ck_net_qemu_8bdbc2e46b85d04c422f9d2830c1c4b263e254b3cfecfe21ff0063c9e33c86e8.log`, hardware NOT_RUN), the kernel entropy rows 107-109 (M1 via `scripts/lib_ck_m1_checks.sh`, ARGUS1_REVOKE and M4_STORE via the Store gate boot 7), `DISK_LAYOUT` (C-only, from `scripts/qemu_ck_disk_layout_test.sh`, rows 118-123: QEMU PASS at 741b2b8 before the merge with main 8555049, rerun pending at the merged head; row 123 host test), and the NOT_RUN gates `SMP` (C-only, from `scripts/qemu_ck_smp_test.sh`, rows 113-117, NOT_RUN pending forge receipt), `M0_ROLLBACK`, `M4_STORE_CRASH` (now read from `scripts/qemu_ck_store_crash_test.sh`, rows 73-80; NOT_RUN until a forge receipt exists), -`M4_CONTINUITY`, `M4_RECOVERY`, `KEYBOARD`, `FPU` (C-only, from `scripts/qemu_ck_fpu_test.sh`, rows 124-128; QEMU PASS, hardware NOT_RUN), `INFER` (C-only, from `scripts/qemu_ck_infer_test.sh`, rows 129-139; QEMU PASS, hardware NOT_RUN), and `SCREEN` (C-only, from `scripts/qemu_ck_screen_test.sh`, rows 140-145; QEMU PASS, hardware NOT_RUN). +`M4_CONTINUITY`, `M4_RECOVERY`, `M4_ALLEN` (C-only, from `scripts/qemu_ck_allen_test.sh`, rows A1-A30; QEMU PASS, hardware NOT_RUN), `KEYBOARD`, `FPU` (C-only, from `scripts/qemu_ck_fpu_test.sh`, rows 124-128; QEMU PASS, hardware NOT_RUN), `INFER` (C-only, from `scripts/qemu_ck_infer_test.sh`, rows 129-139; QEMU PASS, hardware NOT_RUN), and `SCREEN` (C-only, from `scripts/qemu_ck_screen_test.sh`, rows 140-145; QEMU PASS, hardware NOT_RUN). `M4_NVME` and `SMMU` PASS in the SMMU-confined mode (default `make full` image, QEMU `iommu=smmuv3`). The unconfined bypass build @@ -406,6 +406,25 @@ C-only rows are as stated. Operator key is TEST-ONLY in the oracle. | 91o | host `operator_auth_rejects_legacy_bare_sha256_response` (recovery.rs:299) | M4_RECOVERY (host) | HOST PASS (cut 3, `test_continuity_resolve` (`make -C native/kernel test`, real sealed Store in a file): bare SHA-256 response refused; mutant MR-8 `CR_MUTANT_BARE_SHA256` killed); gate NOT_RUN | | 91p | host `operator_auth_rejects_undomained_hmac_and_zero_response` (recovery.rs:311) | M4_RECOVERY (host) | HOST PASS (cut 3, `test_continuity_resolve` (`make -C native/kernel test`, real sealed Store in a file): undomained HMAC and zero response refused; mutant MR-8 `CR_MUTANT_NO_DOMAIN` killed); gate NOT_RUN | +## M4 ALLEN: C-only -> CK `M4_ALLEN` (scripts/qemu_ck_allen_test.sh; OS-0018 / ARCH-0035, both PROPOSED) + +No Rust-kernel counterpart. The TEST continuity image (`make full CK_TEST_CONTINUITY=1`), a 4096-byte-LBA emulated NVMe image, one new `qemu-system-aarch64` process per boot (ESP folder and UEFI vars rebuilt every boot; only the image carries state). Plan mode 5 with `lineage=` provisions identity and genesis subject in one sealed Store transaction; `intent=` adds one standing intent; mode 6 restores. Status for every row: QEMU PASS (receipts `evidence/allen_native_qemu_cfe9aecffb8b20e0c1ff51fad54c46c522ec7d6c56c6cba7661e4b8cda1ee25a.json` and `evidence/ck_gates_1ecf5bcd303bf88422dd0542f14851c931f5d52276838fa182c812f3c73f3c1b.json`, full `ck_gates.sh` at `640522a`), hardware NOT_RUN. QEMU is not a physical cold reboot. + +| row | check | gate | status | +|---|---|---|---| +| A1 | default image carries no ALLEN TEST markers | M4_ALLEN | QEMU PASS | +| A2 | G7 blank image, then kernel provisioning prints `PROVISIONED` and `ALLEN: GENESIS subject=<64> sequence=1 agent= lineage=` | M4_ALLEN | QEMU PASS | +| A3 | G7 standing intent: `ALLEN: INTENDED .. sequence=2 .. intents=1 active=1` and `ALLEN: INTENT .. kind=1 regime=7 target_ns=1000 since=2` | M4_ALLEN | QEMU PASS | +| A4 | G7 independent host reader (`ck_cont_tool subject-dump`, on a copy) finds one genesis and one successor on the image, head = serial head | M4_ALLEN | QEMU PASS | +| A5 | G8 provisioning a provisioned image: `CONTINUITY: STOP (AlreadyProvisioned)`, no genesis, image unchanged | M4_ALLEN | QEMU PASS | +| A6-A8 | G9 two cold restores (new QEMU process each): `ALLEN: RESTORED` with the same subject, intent and lineage, incarnation 2 then 3; afterwards still one genesis, head object byte-identical | M4_ALLEN | QEMU PASS | +| A9-A11 | G10 restore plan is only `AIENCONT v1 mode=6`; a second image restores its own, different subject; the host reader decodes the head from the sealed Store | M4_ALLEN | QEMU PASS | +| A12-A14 | G11a forked chain (second genesis planted): `ALLEN: CORRUPT (subject chain fork)` on two boots, no resume, nothing minted, image unchanged | M4_ALLEN | QEMU PASS | +| A15 | G11b flipped byte in a subject envelope: refused by the Store, nothing restored or minted, image unchanged | M4_ALLEN | QEMU PASS | +| A16-A18 | G11c identity provisioned without a subject: `ALLEN: ABSENT` on two boots, none minted (kills `subject_restore_mints`) | M4_ALLEN | QEMU PASS | +| A19-A20 | G12 another installation's subject chain, beside ours or on a subjectless identity: `ALLEN: CORRUPT (subject object belongs to another agent)`, never adopted (kills `subject_accept_foreign`) | M4_ALLEN | QEMU PASS | +| A21-A30 | power loss: SIGKILL at each of the 9 Store checkpoints of the genesis transaction, then a cold boot finds unprovisioned with no subject (before_first_write .. after_first_flush), either (after_inactive_superblock), or identity with its genesis subject (after_final_flush, before_anchor, after_anchor); never identity without subject; an interrupted provisioning that committed nothing provisions again | M4_ALLEN | QEMU PASS | + ## TRUST-1 Gate 4: scripts/qemu_security_suite.sh, scripts/qemu_secureboot_signing_test.sh These boot the Rust loader image. No C-kernel wrapper exists and @@ -499,7 +518,7 @@ corruption is covered only by the host test `dev/tests/disk_part_test.c` ## Summary counts -**C kernel receipt tally (QEMU only, no physical run):** Newest: `evidence/ck_gates_ad05e004e30237e57e72fc1d3362cfe2b31af9b99451d9d2bb2414238e4d6590.json` (full `ck_gates.sh` at 2e44c0b, L6-C branch, 19 CK gates with `SCREEN`): 17 PASS, 0 FAIL, 2 NOT_RUN (M0_ROLLBACK, KEYBOARD: MISSING_IMPLEMENTATION). Earlier: 16 CK gates since the merge of main 8555049 (#224 adds `SMP`, #226 moves `M4_STORE_CRASH` to its own child script) into the CK-4 branch. The newest full receipt, `evidence/ck_gates_d80363cc871372963743ae85fc08c6fa4608f9870c4e06e8988f21950c73ace6.json` (full `ck_gates.sh` run at 741b2b8, the CK-4 branch after merging main #221 and #225; log CK-4-184524.log, `AIENOS_CK_GATES: NOT_ALL_GATES_PASS (pass=10 fail=0 not_run=5 of 15; physical NOT_RUN)`), predates that merge: by it, 10 of 16 CK gates PASS (the 9 of the earlier receipt plus `DISK_LAYOUT`), 6 NOT_RUN (M0_ROLLBACK, M4_STORE_CRASH, M4_CONTINUITY, M4_RECOVERY, KEYBOARD; and SMP, not in that receipt, NOT_RUN pending forge receipt), 0 FAIL. No `ck_gates.sh` run exists at the merged head yet; `M4_STORE_CRASH` stays NOT_RUN until a forge receipt. `DISK_LAYOUT` also PASSed alone (log CK-4-184423.log, translation-bypass mutant killed); the Store, NET and artifact gates boot GPT images now and PASS in the same receipt. The receipt before it was 9 of 14 CK gates PASS, 5 NOT_RUN, 0 FAIL (`evidence/ck_gates_929f287e9c950c45c7dcd569c7caa03709ea62ecfe393635b435058afa969c54.json`, run at 41aa0e6, which adds the kernel entropy rows 107-109; that commit was then rebased onto #210, which changed only README.md and CONTRIBUTING.md). The row counts below are per Rust-parity row, not per gate. +**C kernel receipt tally (QEMU only, no physical run):** Newest: `evidence/ck_gates_1ecf5bcd303bf88422dd0542f14851c931f5d52276838fa182c812f3c73f3c1b.json` (full `ck_gates.sh` at 640522a, ALLEN native genesis branch, 20 CK gates with `M4_ALLEN`): 15 PASS, 0 FAIL, 5 NOT_RUN (M0_ROLLBACK, KEYBOARD: MISSING_IMPLEMENTATION; FPU, INFER, SCREEN: the shared QEMU gate lock was held by another run). Before it: `evidence/ck_gates_ad05e004e30237e57e72fc1d3362cfe2b31af9b99451d9d2bb2414238e4d6590.json` (full `ck_gates.sh` at 2e44c0b, L6-C branch, 19 CK gates with `SCREEN`): 17 PASS, 0 FAIL, 2 NOT_RUN (M0_ROLLBACK, KEYBOARD: MISSING_IMPLEMENTATION). Earlier: 16 CK gates since the merge of main 8555049 (#224 adds `SMP`, #226 moves `M4_STORE_CRASH` to its own child script) into the CK-4 branch. The newest full receipt, `evidence/ck_gates_d80363cc871372963743ae85fc08c6fa4608f9870c4e06e8988f21950c73ace6.json` (full `ck_gates.sh` run at 741b2b8, the CK-4 branch after merging main #221 and #225; log CK-4-184524.log, `AIENOS_CK_GATES: NOT_ALL_GATES_PASS (pass=10 fail=0 not_run=5 of 15; physical NOT_RUN)`), predates that merge: by it, 10 of 16 CK gates PASS (the 9 of the earlier receipt plus `DISK_LAYOUT`), 6 NOT_RUN (M0_ROLLBACK, M4_STORE_CRASH, M4_CONTINUITY, M4_RECOVERY, KEYBOARD; and SMP, not in that receipt, NOT_RUN pending forge receipt), 0 FAIL. No `ck_gates.sh` run exists at the merged head yet; `M4_STORE_CRASH` stays NOT_RUN until a forge receipt. `DISK_LAYOUT` also PASSed alone (log CK-4-184423.log, translation-bypass mutant killed); the Store, NET and artifact gates boot GPT images now and PASS in the same receipt. The receipt before it was 9 of 14 CK gates PASS, 5 NOT_RUN, 0 FAIL (`evidence/ck_gates_929f287e9c950c45c7dcd569c7caa03709ea62ecfe393635b435058afa969c54.json`, run at 41aa0e6, which adds the kernel entropy rows 107-109; that commit was then rebased onto #210, which changed only README.md and CONTRIBUTING.md). The row counts below are per Rust-parity row, not per gate. Rows 118-123 (DISK_LAYOUT, C-only, CK-4; numbered 113-118 on the CK-4 branch before the merge with main, which gave 113-117 to SMP) are 5 QEMU PASS (118-122, receipt `ck_gates_d80363...` at 741b2b8, before the merge with main 8555049) and 1 host-test PASS (123), none NOT_RUN. With them, rows 1-123 plus the M4 continuity/recovery sub-rows: IDENTICAL 28, DIFFERS 39, NOT_RUN 91, PASS 6 (C-only DISK_LAYOUT, hardware NOT_RUN) (91 from the SMP line next; recounted from the table at the merge commit, status = each row's first status cell, escaped pipes read as text: 28 IDENTICAL, 39 DIFFERS, 87 NOT_RUN (82 + SMP 113-117), 9 QEMU PASS (NET 102, 110-112, counted as NOT_RUN as below, and DISK_LAYOUT 118-122), 1 PASS (123); sub-rows 24a and 24b not counted). diff --git a/native/kernel/Makefile b/native/kernel/Makefile index 16816fd6..4475bc42 100644 --- a/native/kernel/Makefile +++ b/native/kernel/Makefile @@ -266,6 +266,8 @@ endif # degraded_is_unprovisioned a degraded mount reads as unprovisioned (MR-5) # compare_16 operator response compared on 16 of 32 bytes # bare_sha256 operator response is a bare SHA-256, not an HMAC +# subject_restore_mints restore mints an ALLEN subject when it finds none (OS-0018) +# subject_accept_foreign restore accepts a subject bound to another agent (MS-1) CK_TEST_CONTINUITY ?= CK_TEST_CONTINUITY_MUTANT ?= ifneq ($(strip $(CK_TEST_CONTINUITY)),) @@ -296,8 +298,12 @@ else ifeq ($(strip $(CK_TEST_CONTINUITY_MUTANT)),compare_16) CONT_MUTANT_FLAGS := -DCR_MUTANT_COMPARE_16=1 else ifeq ($(strip $(CK_TEST_CONTINUITY_MUTANT)),bare_sha256) CONT_MUTANT_FLAGS := -DCR_MUTANT_BARE_SHA256=1 +else ifeq ($(strip $(CK_TEST_CONTINUITY_MUTANT)),subject_restore_mints) +CONT_MUTANT_FLAGS := -DCS_MUTANT_RESTORE_MINTS=1 +else ifeq ($(strip $(CK_TEST_CONTINUITY_MUTANT)),subject_accept_foreign) +CONT_MUTANT_FLAGS := -DCS_MUTANT_ACCEPT_FOREIGN=1 else -$(error CK_TEST_CONTINUITY_MUTANT must be resume_no_commit, resume_provisions, degraded_is_unprovisioned, compare_16 or bare_sha256) +$(error CK_TEST_CONTINUITY_MUTANT must be resume_no_commit, resume_provisions, degraded_is_unprovisioned, compare_16, bare_sha256, subject_restore_mints or subject_accept_foreign) endif endif @@ -449,7 +455,7 @@ endif STAGE_DMA_FLAGS += -DCK_TEST_CONTINUITY=1 $(CONT_MUTANT_FLAGS) -I$(KDIR)/core STAGE_SRCS += $(KDIR)/svc/continuity_codec.c $(KDIR)/svc/continuity_resolve.c \ $(KDIR)/svc/continuity_resolve_sealed.c $(KDIR)/svc/continuity_commit.c $(KDIR)/svc/continuity_recovery.c \ - $(KDIR)/svc/continuity_boot.c + $(KDIR)/svc/continuity_boot.c $(KDIR)/svc/continuity_subject.c $(KDIR)/svc/continuity_subject_provision.c endif ifeq ($(strip $(CK_TEST_DISK_XLATE_BYPASS)),1) FULL_NAME := $(FULL_NAME)-test-xlate-bypass @@ -567,11 +573,16 @@ endef # crash_check(elf): a full image built without CK_TEST_STORE_CRASH must carry # no Store crash hook code or strings; a TEST crash image must announce itself. +# The bare "TEST-ONLY MUTANT" phrase is refused here except in the TEST +# continuity image, whose own mutants print it (cont_check refuses it in every +# image built without CK_TEST_CONTINUITY; crash-hook mutants are still caught +# by their "store_crash:" prefix). define crash_check @if [ "$(strip $(CK_TEST_STORE_CRASH))" = 1 ]; then \ grep -aqF "TEST-ONLY Store crash hook image" $(1) || { echo "TEST crash image lacks its TEST-ONLY announcement"; rm -f $(1); exit 1; }; \ else \ - s=$$(grep -aoE "store_crash:|AIENCRSH|TEST-ONLY MUTANT" $(1) | sort -u | tr "\n" " "); \ + m="|TEST-ONLY MUTANT"; [ "$(strip $(CK_TEST_CONTINUITY))" = 1 ] && m=""; \ + s=$$(grep -aoE "store_crash:|AIENCRSH$$m" $(1) | sort -u | tr "\n" " "); \ y=$$($(KNM) $(1) | grep -E " ck_store_crash_[a-z_]+$$" | tr "\n" " "); \ if [ -n "$$s$$y" ]; then echo "default image carries the TEST Store crash hook: $$s$$y"; rm -f $(1); exit 1; fi; \ echo "no Store crash hook code in $(1)"; \ @@ -580,11 +591,16 @@ endef # cont_check(elf): a full image built without CK_TEST_CONTINUITY must carry no # continuity wiring code or strings; a TEST continuity image must announce itself. +# The bare "TEST-ONLY MUTANT" phrase is refused here except in the TEST Store +# crash image, whose own mutants print it (crash_check refuses it in every +# image built without CK_TEST_STORE_CRASH; continuity mutants are still caught +# by the continuity strings). define cont_check @if [ "$(strip $(CK_TEST_CONTINUITY))" = 1 ]; then \ grep -aqF "TEST-ONLY continuity mode selection image" $(1) || { echo "TEST continuity image lacks its TEST-ONLY announcement"; rm -f $(1); exit 1; }; \ else \ - s=$$(grep -aoE "AIENCONT|RECOVERY_OPERATOR_KEY|RECOVERY_CORE:|CONTINUITY: |TEST-ONLY MUTANT" $(1) | sort -u | tr "\n" " "); \ + m="|TEST-ONLY MUTANT"; [ "$(strip $(CK_TEST_STORE_CRASH))" = 1 ] && m=""; \ + s=$$(grep -aoE "AIENCONT|RECOVERY_OPERATOR_KEY|RECOVERY_CORE:|CONTINUITY: $$m" $(1) | sort -u | tr "\n" " "); \ y=$$($(KNM) $(1) | grep -E " (ck_cont_boot_stage|cr_resume|cr_provision|rc_inspect)$$" | tr "\n" " "); \ if [ -n "$$s$$y" ]; then echo "default image carries the TEST continuity wiring: $$s$$y"; rm -f $(1); exit 1; fi; \ echo "no continuity wiring code in $(1)"; \ @@ -641,7 +657,7 @@ HOST_SRCS := $(KDIR)/core/fmt.c $(KDIR)/core/acpi.c $(KDIR)/core/smmu.c $(KDIR)/ $(KDIR)/core/handoff_check.c $(KDIR)/core/fbcon.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_fbcon \ test_continuity_codec test_continuity_resolve test_continuity_commit test_continuity_recovery test_continuity_geometry \ - test_continuity_subject + test_continuity_subject test_continuity_subject_provision 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 @@ -721,7 +737,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-commit-mutants continuity-recovery-mutants continuity-subject-mutants +continuity-mutants: $(OUT)/host/test_continuity_codec continuity-resolve-mutants continuity-commit-mutants continuity-recovery-mutants continuity-subject-mutants continuity-subject-provision-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 \ @@ -881,6 +897,40 @@ continuity-subject-mutants: $(OUT)/host/test_continuity_subject done; \ if [ $$fail = 0 ]; then echo "CK_CONTINUITY_SUBJECT_MUTANTS: PASS"; else echo "CK_CONTINUITY_SUBJECT_MUTANTS: FAIL"; exit 1; fi +# ALLEN genesis at identity provisioning (svc/continuity_subject_provision.c; +# ARCH-0035 / OS-0018, PROPOSED): identity and genesis subject in ONE Store +# transaction, power cuts at every checkpoint and block boundary, and the +# TEST-only split-transaction mutant (MSP-1), which the test must catch. The +# mutant flag is refused under CK_HARDWARE_STAGING. +CSP_HOST_SRCS := $(KDIR)/svc/continuity_subject_provision.c $(CS_HOST_SRCS) +CSP_HOST_DEPS := $(CSP_HOST_SRCS) $(CS_HOST_DEPS) +CSP_MUTANTS := CS_MUTANT_PROVISION_SPLIT_TXN + +$(OUT)/host/test_continuity_subject_provision: $(KDIR)/tests/test_continuity_subject_provision.c $(CSP_HOST_DEPS) + @mkdir -p $(dir $@) + $(HOSTCC) $(HCFLAGS) $(CM_HOST_INC) -o $@ $< $(CSP_HOST_SRCS) + +$(OUT)/host-san/test_continuity_subject_provision: $(KDIR)/tests/test_continuity_subject_provision.c $(CSP_HOST_DEPS) + @mkdir -p $(dir $@) + $(HOSTCC) $(HCFLAGS) $(SANFLAGS) $(CM_HOST_INC) -o $@ $< $(CSP_HOST_SRCS) + +continuity-subject-provision-mutants: $(OUT)/host/test_continuity_subject_provision + @mkdir -p $(OUT)/host-mut; fail=0; \ + $(OUT)/host/test_continuity_subject_provision > $(OUT)/host-mut/subject_provision_base.log 2>&1 || { echo "unmutated test_continuity_subject_provision fails"; fail=1; }; \ + for m in $(CSP_MUTANTS); do \ + b=$(OUT)/host-mut/test_continuity_subject_provision_$$m; \ + if ! $(HOSTCC) $(HCFLAGS) $(CM_HOST_INC) -D$$m -o $$b $(KDIR)/tests/test_continuity_subject_provision.c $(CSP_HOST_SRCS); then \ + echo "mutant $$m does not build (FAIL)"; fail=1; continue; fi; \ + $$b > $$b.log 2>&1; \ + if grep -q "^test_continuity_subject_provision: FAIL" $$b.log; then echo "mutant $$m caught ($$(grep -c '^ FAIL ' $$b.log) checks failed)"; \ + else echo "mutant $$m NOT caught (FAIL)"; fail=1; fi; \ + if $(HOSTCC) $(HCFLAGS) $(CM_HOST_INC) -DCK_HARDWARE_STAGING=1 -D$$m \ + -fsyntax-only $(KDIR)/svc/continuity_subject_provision.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_SUBJECT_PROVISION_MUTANTS: PASS"; else echo "CK_CONTINUITY_SUBJECT_PROVISION_MUTANTS: FAIL"; exit 1; fi + # Continuity Recovery Core (C port cut 5): host test over the REAL sealed Store in a # file, 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_recovery.h). @@ -953,10 +1003,11 @@ store-image: $(STORE_IMG_TOOL) CONT_TOOL := $(OUT)/host/ck_cont_tool CONT_TOOL_SRCS := $(STAGE_OWN_SRCS) $(STAGE_NATIVE_SRCS) $(NATIVE)/disk/disk_file.c \ $(KDIR)/svc/tests/ck_host.c $(KDIR)/svc/continuity_resolve.c $(KDIR)/svc/continuity_codec.c \ + $(KDIR)/svc/continuity_resolve_sealed.c $(KDIR)/svc/continuity_subject.c \ $(KDIR)/tools/ck_cont_tool.c $(CONT_TOOL): $(CONT_TOOL_SRCS) $(STAGE_HDRS) @mkdir -p $(dir $@) - $(HOSTCC) $(STAGE_HOST_FLAGS) $(STAGE_INC) -o $@ $(CONT_TOOL_SRCS) + $(HOSTCC) $(STAGE_HOST_FLAGS) $(STAGE_INC) -idirafter $(KDIR)/core -o $@ $(CONT_TOOL_SRCS) cont-tool: $(CONT_TOOL) # GPT boot-disk image tool (QEMU gates; hosted, never part of an image). diff --git a/native/kernel/svc/.crumb b/native/kernel/svc/.crumb index 5fc45d81..8281f0cc 100644 --- a/native/kernel/svc/.crumb +++ b/native/kernel/svc/.crumb @@ -30,14 +30,14 @@ } ], "children_root": "sha256:9e2977ce5ea7f74952e26dfb57f3703ab65c5ccbe933e2f5135ab1a5496e0af7", - "compiled_at": "2026-10-05T00:51:39Z", + "compiled_at": "2026-10-05T02:01:59Z", "compiler": "crumb-compile/1", - "digest": "sha256:a869aee7e92862a2d16efb62a0d881209fe82a9ba1b70332050f755a58230630", + "digest": "sha256:f24db6711bf88a0d7c48375f6f979fd589306a9266c697c5f25d4e8a2dbdb90d", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 33, - "generated_at_commit": "fbbfc9c90b5609cdd94a327fad3503366e1b11b1", - "source_tree": "sha256:3736ca3a8cea72dfd0aa38b84c397d80bd756b08c83a53a27485c08da75b8a54" + "files": 35, + "generated_at_commit": "71d5b326eea6a330f3cc1c4377fc4bc2d134d5aa", + "source_tree": "sha256:947429839de94404d11be4fef56449e2d79c1c4a1d0fe51f95c0bb9b1c18b73b" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/svc/continuity_boot.c b/native/kernel/svc/continuity_boot.c index 1761f335..c2ed227c 100644 --- a/native/kernel/svc/continuity_boot.c +++ b/native/kernel/svc/continuity_boot.c @@ -22,10 +22,12 @@ #include "ck.h" #include "continuity_recovery.h" +#include "continuity_subject_provision.h" #include "disk_layout.h" #include "entropy.h" #include "fmt.h" #include "m5.h" +#include "sha256.h" #include "store_boot.h" #define PLAN_MAGIC "AIENCONT v1 " @@ -40,6 +42,11 @@ struct plan { int cp; /* -1 none */ int have_response; uint8_t response[32]; + int have_lineage; /* mode 5: provision WITH the ALLEN subject (OS-0018) */ + uint8_t lineage[32]; + int have_intent; /* mode 5 with lineage: one standing intent after genesis */ + uint64_t intent[2]; + uint8_t request[32]; /* SHA-256 of the plan line: the provisioning request */ }; static const int k_cps[] = {ST_CP_BEFORE_FIRST_WRITE, ST_CP_AFTER_PAYLOAD_OBJECTS, ST_CP_AFTER_CATALOG, @@ -101,12 +108,45 @@ static int parse_plan(const char *p, size_t len, struct plan *out) out->response[k] = (uint8_t)(hi << 4 | lo); } out->have_response = 1; + } else if (n == 8 + 64 && !memcmp(w, "lineage=", 8)) { + for (size_t k = 0; k < 32; k++) { + int hi = hexv(w[8 + 2 * k]), lo = hexv(w[9 + 2 * k]); + if (hi < 0 || lo < 0) return -1; + out->lineage[k] = (uint8_t)(hi << 4 | lo); + } + out->have_lineage = 1; + } else if (n > 7 && !memcmp(w, "intent=", 7)) { + /* intent=,: one CS_INTENT_GOAL_LATENCY intent. */ + size_t k = 7; + for (int f = 0; f < 2; f++) { + uint64_t v = 0; + size_t d = 0; + while (k < n && w[k] >= '0' && w[k] <= '9' && d < 19) { + v = v * 10 + (uint64_t)(w[k] - '0'); + k++; + d++; + } + if (!d) return -1; + out->intent[f] = v; + if (f == 0) { + if (k >= n || w[k] != ',') return -1; + k++; + } + } + if (k != n) return -1; + out->have_intent = 1; } else { return -1; } if (i < len && p[i] == ' ') i++; } if (!have_mode || i >= len) return -1; + { + sha256_ctx h; /* the provisioning request: the plan line up to its newline */ + sha256_init(&h); + sha256_update(&h, (const uint8_t *)p, i); + sha256_final(&h, out->request); + } for (i = i + 1; i < len; i++) if (p[i]) return -1; return 0; @@ -136,6 +176,7 @@ static struct { struct cr_txwork *tw; struct cr_view *v, *v2; struct cc_state *st; + struct cs_subject *subj, *subj2; /* ALLEN (OS-0018) */ st_disk sd; st_dev sdev; ts_device tdev; @@ -153,7 +194,9 @@ static int alloc_all(void) g.v = ck_alloc(sizeof *g.v); g.v2 = ck_alloc(sizeof *g.v2); g.st = ck_alloc(sizeof *g.st); - return g.ws && g.s && g.w && g.tw && g.v && g.v2 && g.st ? 0 : -1; + g.subj = ck_alloc(sizeof *g.subj); + g.subj2 = ck_alloc(sizeof *g.subj2); + return g.ws && g.s && g.w && g.tw && g.v && g.v2 && g.st && g.subj && g.subj2 ? 0 : -1; } static void line(const char *s) @@ -297,6 +340,115 @@ static void recovery_phase(const disk_dev *d, const struct plan *p) } } +/* ---- ALLEN (ARCH-0035 / OS-0018, PROPOSED) ---- + * Provision (mode 5 with lineage=): identity and the genesis subject in ONE + * Store transaction (cs_provision), then, if intent= is given, one standing + * intent as subject sequence 2 through cs_commit (its own transaction). + * Restore (modes 6..8): the subject is resolved read-only BEFORE anything is + * written. RESOLVED is reported; ABSENT is reported and never minted; + * anything else (corrupt, forked, foreign, unreadable) stops the boot with + * nothing written. Markers: + * ALLEN: GENESIS|INTENDED|RESTORED subject=<64> sequence= agent=<64> lineage=<64> intents= active= + * ALLEN: INTENT id=<64> kind= regime= target_ns= since= (each ACTIVE intent) + * ALLEN: ABSENT (...) ALLEN: CORRUPT () ALLEN: STOP () */ +static void allen_lines(const char *word, const struct cs_subject *s, const uint8_t id[32]) +{ + char b[400], sub[65], ag[65], ln[65]; + uint32_t active = 0; + for (uint32_t i = 0; i < s->n_intents; i++) active += s->in[i].state == CS_ACTIVE; + hex_into(sub, id, 32); + hex_into(ag, s->agent, 32); + hex_into(ln, s->cortex, 32); + ck_snprintf(b, sizeof b, "ALLEN: %s subject=%s sequence=%llu agent=%s lineage=%s intents=%u active=%u", word, sub, + (unsigned long long)s->sequence, ag, ln, (unsigned)s->n_intents, (unsigned)active); + line(b); + for (uint32_t i = 0; i < s->n_intents; i++) { + const struct cs_intent *a = &s->in[i]; + if (a->state != CS_ACTIVE) continue; + hex_into(sub, a->id, 32); + ck_snprintf(b, sizeof b, "ALLEN: INTENT id=%s kind=%u regime=%llu target_ns=%llu since=%llu", sub, + (unsigned)a->kind, (unsigned long long)a->payload[0], (unsigned long long)a->payload[1], + (unsigned long long)a->since); + line(b); + } +} + +static void allen_stop(int o, const char *why) +{ + char b[256]; + if (o == CR_CORRUPT) ck_snprintf(b, sizeof b, "ALLEN: CORRUPT (%s)", why ? why : "-"); + else ck_snprintf(b, sizeof b, "ALLEN: STOP (%s%s%s)", cr_outcome_name(o), why ? ": " : "", why ? why : ""); + line(b); +} + +static void allen_provision(const struct cr_source *src, const struct cr_sink *snk, struct cr_sealed_sink *sk, + const struct plan *p, struct ck_rng *rng) +{ + static struct cs_genesis gen; + uint8_t sid[32], sid2[32], iid[32]; + const char *why = 0; + int store_rc = 0; + memcpy(gen.provenance, p->request, 32); + gen.origin = CS_ORIGIN_OPERATOR; + memcpy(gen.cortex, p->lineage, 32); + if (p->cp >= 0) { + sk->hook = cont_hook; + sk->hook_arg = (void *)p; + } + int o = cs_provision(src, snk, g.w, g.tw, rng, ck_store_test_uuid, CC_SOURCE_QUALIFICATION, &gen, g.v, g.subj, + sid, &why, &store_rc); + sk->hook = 0; + if (o != CR_RESOLVED) { + print_outcome(o, why, store_rc); + allen_stop(o, why); + return; + } + print_view("PROVISIONED", g.v); + allen_lines("GENESIS", g.subj, sid); + if (!p->have_intent) return; + memcpy(g.subj2, g.subj, sizeof *g.subj2); + cs_subject_advance(g.subj2, sid, p->request, CS_ORIGIN_OPERATOR); + if (cs_subject_intend(g.subj2, CS_INTENT_GOAL_LATENCY, p->intent, iid, &why) != CC_OK) { + allen_stop(CR_E_ARG, why); + return; + } + o = cs_commit(src, snk, g.w, g.v, g.subj2, sid2, &why, &store_rc); + if (o != CS_RESOLVED) { + allen_stop(o, why); + return; + } + allen_lines("INTENDED", g.subj2, sid2); +} + +/* 1 = go on with the resume, 0 = stop (nothing written). */ +static int allen_restore(const struct cr_source *src, const struct cr_sink *snk, const struct plan *p) +{ + uint8_t sid[32]; + const char *why = 0; + int store_rc = 0; + (void)snk; + (void)p; + if (cr_resolve(src, g.w, g.v2, &why, &store_rc) != CR_RESOLVED) return 1; /* cr_resume reports it */ + int s = cs_resolve(src, g.w, g.v2, g.subj, sid, &why, &store_rc); +#ifdef CS_MUTANT_RESTORE_MINTS + if (s == CS_ABSENT) { /* MUTANT: restore mints a fresh subject */ + cs_subject_genesis(g.subj, g.v2, p->request, CS_ORIGIN_OPERATOR); + if (cs_commit(src, snk, g.w, g.v2, g.subj, sid, &why, &store_rc) == CS_RESOLVED) + s = cs_resolve(src, g.w, g.v2, g.subj, sid, &why, &store_rc); + } +#endif + if (s == CS_RESOLVED) { + allen_lines("RESTORED", g.subj, sid); + return 1; + } + if (s == CS_ABSENT) { + line("ALLEN: ABSENT (provisioned without a subject; restore never mints one)"); + return 1; + } + allen_stop(s, why); + return 0; +} + static void continuity_phase(const disk_dev *d, const struct plan *p) { struct cr_source src; @@ -315,6 +467,10 @@ static void continuity_phase(const disk_dev *d, const struct plan *p) line("CONTINUITY: NO_ENTROPY"); return; } + if (p->have_lineage) { + allen_provision(&src, &snk, &sk, p, &rng); + return; + } int o = cr_provision(&src, &snk, g.w, g.tw, &rng, ck_store_test_uuid, CC_SOURCE_QUALIFICATION, g.v, &why, &store_rc); if (o == CR_RESOLVED) print_view("PROVISIONED", g.v); @@ -322,6 +478,7 @@ static void continuity_phase(const disk_dev *d, const struct plan *p) return; } + if (!allen_restore(&src, &snk, p)) return; int committed = 0; int o = cr_resume(&src, &snk, g.w, g.tw, g.v, &committed, &why, &store_rc); if (o != CR_RESOLVED) { @@ -374,6 +531,12 @@ int ck_cont_boot_stage(const disk_dev *d, int *rc) #endif #ifdef CR_MUTANT_BARE_SHA256 ck_puts("continuity: TEST-ONLY MUTANT bare_sha256: operator response is a bare SHA-256\n"); +#endif +#ifdef CS_MUTANT_RESTORE_MINTS + ck_puts("continuity: TEST-ONLY MUTANT subject_restore_mints: restore mints an ALLEN subject when it finds none\n"); +#endif +#ifdef CS_MUTANT_ACCEPT_FOREIGN + ck_puts("continuity: TEST-ONLY MUTANT subject_accept_foreign: restore accepts a subject of another agent\n"); #endif if (!d || (d->block_size != 512 && d->block_size != 4096)) return 0; uint32_t bpu = CK_LAYOUT_UNIT / d->block_size; diff --git a/native/kernel/svc/continuity_subject_provision.c b/native/kernel/svc/continuity_subject_provision.c new file mode 100644 index 00000000..e5471905 --- /dev/null +++ b/native/kernel/svc/continuity_subject_provision.c @@ -0,0 +1,154 @@ +/* continuity_subject_provision.c -- see continuity_subject_provision.h. */ +#include "continuity_subject_provision.h" + +#include "store_sealed.h" +#include "store_v1.h" + +static int fail(const char **why, int cls, const char *w) +{ + if (why) *why = w; + return cls; +} + +static int map_cc(int rc) +{ + return rc == CC_E_LIMIT ? CR_LIMIT : rc == CC_E_ARG ? CR_E_ARG : CR_CORRUPT; +} + +/* The genesis sink: forwards cr_provision's one transaction with the genesis + * subject object appended. It accepts exactly one call carrying exactly one + * AgentRoot; anything else is refused before the inner sink is touched, so a + * provisioning write without its subject cannot reach the Store. */ +struct gsink { + const struct cr_sink *inner; + const struct cs_genesis *g; + int calls; + int rc; /* 0, or why the sink refused (CR_*) */ + const char *why; + struct cs_subject subj; /* the genesis object that was sent */ + uint8_t id[32]; + uint8_t buf[CS_MAX_BYTES]; + size_t len; +}; + +#define GSINK_REFUSED (-7700) /* store-style error code for a refused call */ + +static int gsink_transact(void *ctx, const struct cr_wobj *objs, size_t n) +{ + struct gsink *k = ctx; + struct cr_wobj all[SS_MAX_OBJECTS]; + const struct cr_wobj *root = 0; + static struct cr_view rv; /* only root_id and root.agent_id are used */ + const char *y = 0; + int rc; + if (k->calls++ != 0) { + k->rc = fail(&k->why, CR_E_ARG, "provisioning made a second transaction"); + return GSINK_REFUSED; + } + if (n + 1 > SS_MAX_OBJECTS) { + k->rc = fail(&k->why, CR_LIMIT, "no room for the subject in the provisioning transaction"); + return GSINK_REFUSED; + } + for (size_t i = 0; i < n; i++) { + if (objs[i].kind != CC_KIND_AGENT_ROOT) continue; + if (root) { + k->rc = fail(&k->why, CR_CORRUPT, "provisioning transaction carries two agent roots"); + return GSINK_REFUSED; + } + root = &objs[i]; + } + if (!root) { + k->rc = fail(&k->why, CR_CORRUPT, "provisioning transaction carries no agent root"); + return GSINK_REFUSED; + } + sv1_zero(&rv, sizeof rv); + if ((rc = cc_root_decode(root->bytes, root->len, &rv.root, &y)) != CC_OK) { + k->rc = fail(&k->why, map_cc(rc), y); + return GSINK_REFUSED; + } + if (cc_object_id(CC_KIND_AGENT_ROOT, root->bytes, root->len, rv.root_id) != CC_OK) { + k->rc = fail(&k->why, CR_E_ARG, "agent root object id"); + return GSINK_REFUSED; + } + cs_subject_genesis(&k->subj, &rv, k->g->provenance, k->g->origin); + cs_subject_bind_cortex(&k->subj, k->g->cortex); + if ((rc = cs_subject_encode(&k->subj, k->buf, sizeof k->buf, &k->len, &y)) != CC_OK) { + k->rc = fail(&k->why, map_cc(rc), y); + return GSINK_REFUSED; + } + if (cc_object_id(CC_KIND_SUBJECT, k->buf, k->len, k->id) != CC_OK) { + k->rc = fail(&k->why, CR_E_ARG, "subject object id"); + return GSINK_REFUSED; + } + for (size_t i = 0; i < n; i++) all[i] = objs[i]; + all[n].kind = CC_KIND_SUBJECT; + all[n].version = CC_STORE_OBJECT_VERSION; + all[n].bytes = k->buf; + all[n].len = k->len; +#ifdef CS_MUTANT_PROVISION_SPLIT_TXN + /* MUTANT: identity first, subject in a second transaction (a crash + * between them leaves an identity without its subject). */ + if ((rc = k->inner->transact(k->inner->ctx, all, n))) return rc; + return k->inner->transact(k->inner->ctx, all + n, 1); +#else + return k->inner->transact(k->inner->ctx, all, n + 1); +#endif +} + +int cs_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, const struct cs_genesis *g, struct cr_view *out, + struct cs_subject *subj, uint8_t subj_id[32], const char **why, int *store_rc) +{ + static struct gsink k; + struct cr_sink wrap; + uint32_t n, roots = 0, subjects = 0; + int rc; + if (why) *why = 0; + if (store_rc) *store_rc = 0; + if (!src || !src->count || !src->entry || !snk || !snk->transact || !w || !tw || !rng || + !store_uuid || !g || !out || !subj || !subj_id) + return fail(why, CR_E_ARG, "null argument"); + if (sv1_all_zero(g->provenance, 32)) + return fail(why, CR_E_ARG, "subject genesis needs a provenance"); + if (sv1_all_zero(g->cortex, 32)) + return fail(why, CR_E_ARG, "subject genesis needs a memory lineage reference"); + if (g->origin != CS_ORIGIN_OPERATOR && g->origin != CS_ORIGIN_PROMOTED) + return fail(why, CR_E_ARG, "subject genesis origin"); + + /* A subject object without an agent root is never provisioned over. */ + n = src->count(src->ctx); + for (uint32_t i = 0; i < n; i++) { + uint16_t kind = 0, version = 0; + if ((rc = src->entry(src->ctx, i, &kind, &version))) { + if (store_rc) *store_rc = rc; + return fail(why, CR_STORE, "store entry failed"); + } + roots += kind == CC_KIND_AGENT_ROOT; + subjects += kind == CC_KIND_SUBJECT; + } + if (subjects && !roots) + return fail(why, CR_CORRUPT, "subject objects without an agent root"); + + sv1_zero(&k, sizeof k); + k.inner = snk; + k.g = g; + wrap.ctx = &k; + wrap.transact = gsink_transact; + rc = cr_provision(src, &wrap, w, tw, rng, store_uuid, source, out, why, store_rc); + if (k.rc) { /* the sink refused: nothing reached the Store */ + if (why) *why = k.why; + if (store_rc) *store_rc = 0; + return k.rc; + } + if (rc != CR_RESOLVED) return rc; + + /* Post-condition, read back from the Store: one subject, sequence 1, + * this root and agent, the object that was sent. */ + rc = cs_resolve(src, w, out, subj, subj_id, why, store_rc); + if (rc == CS_ABSENT) return fail(why, CR_CORRUPT, "identity provisioned without its subject"); + if (rc != CS_RESOLVED) return rc; + if (subj->sequence != 1 || !sv1_equal(subj_id, k.id, 32)) + return fail(why, CR_CORRUPT, "provisioned subject is not the genesis object"); + return CR_RESOLVED; +} diff --git a/native/kernel/svc/continuity_subject_provision.h b/native/kernel/svc/continuity_subject_provision.h new file mode 100644 index 00000000..e16a6288 --- /dev/null +++ b/native/kernel/svc/continuity_subject_provision.h @@ -0,0 +1,53 @@ +/* continuity_subject_provision.h -- ALLEN genesis at identity provisioning. + * + * ARCH-0035 (PROPOSED) / OS-0018 (PROPOSED). A single-subject installation + * creates its ALLEN subject exactly once: in the SAME Store transaction that + * creates its identity. cs_provision runs cr_provision (OS-0016 provisioning, + * unchanged) over a sink that appends the genesis subject object (kind 24, + * sequence 1) to cr_provision's one transaction (AgentRoot, AgentState, + * Manifest 1): four objects, one ss_transact, one generation. There is no + * second WAL, no second database and no separate write: the subject inherits + * the Store's commit protocol (payload objects, catalog, commit record, + * flushes, superblock, anchor). A crash anywhere leaves either an + * unprovisioned Store or an identity WITH its subject, never one without + * the other. + * + * Restore never comes here. A provisioned Store whose subject is absent, + * corrupt, forked or foreign is reported by cs_resolve and never minted over. + * + * Kernel-side composition only (it needs cr_provision and the entropy + * source); omega links continuity_subject.c without this file. No thread, no + * wait, no clock, no scheduling, no authority. */ +#ifndef CK_CONTINUITY_SUBJECT_PROVISION_H +#define CK_CONTINUITY_SUBJECT_PROVISION_H + +#include + +#include "continuity_commit.h" +#include "continuity_subject.h" + +#if defined(CK_HARDWARE_STAGING) && defined(CS_MUTANT_PROVISION_SPLIT_TXN) +#error "continuity subject provision mutants are TEST-only and refused under CK_HARDWARE_STAGING" +#endif + +/* What the provisioning request supplies about the subject. */ +struct cs_genesis { + uint8_t provenance[32]; /* nonzero: who/what established the subject */ + uint8_t origin; /* CS_ORIGIN_OPERATOR or CS_ORIGIN_PROMOTED */ + uint8_t cortex[32]; /* memory lineage reference; nonzero required */ +}; + +/* Identity + ALLEN genesis in one transaction. Refusals, in order: null or + * invalid genesis input (CR_E_ARG, nothing read); kind-24 objects already in + * the Store (CR_CORRUPT "subject objects without an agent root" when there is + * no root; a Store with a root is CR_ALREADY_PROVISIONED from cr_provision); + * then every cr_provision refusal unchanged. On success returns CR_RESOLVED + * with the identity view in *out, the genesis subject in *subj and its + * ObjectId in subj_id, after re-resolving both from the Store (post-condition: + * exactly one subject object, sequence 1, bound to this root and agent). */ +int cs_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, const struct cs_genesis *g, struct cr_view *out, + struct cs_subject *subj, uint8_t subj_id[32], const char **why, int *store_rc); + +#endif diff --git a/native/kernel/tests/.crumb b/native/kernel/tests/.crumb index bb524bb0..3ea618c5 100644 --- a/native/kernel/tests/.crumb +++ b/native/kernel/tests/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-05T00:51:39Z", + "compiled_at": "2026-10-05T02:01:59Z", "compiler": "crumb-compile/1", - "digest": "sha256:2becacc3ed46f19dcd0a7b91acef18c77abb4e2f1231204a1ab02d74b244e80c", + "digest": "sha256:20157ea957a698743f9078faf6c765b507733f9a9e67877ea5602c7f461b7a7b", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 23, - "generated_at_commit": "fbbfc9c90b5609cdd94a327fad3503366e1b11b1", - "source_tree": "sha256:ec4f10b297f5d783fafcc54204ce43d28a029c6ac911cfc1eac4f51de20740eb" + "files": 24, + "generated_at_commit": "71d5b326eea6a330f3cc1c4377fc4bc2d134d5aa", + "source_tree": "sha256:9f9b47091ea12cf2b6e0e95fe6e0e9ea655a0203c432d1a5a720c07179035fb0" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/tests/test_continuity_subject_provision.c b/native/kernel/tests/test_continuity_subject_provision.c new file mode 100644 index 00000000..7c0ed6a3 --- /dev/null +++ b/native/kernel/tests/test_continuity_subject_provision.c @@ -0,0 +1,479 @@ +/* test_continuity_subject_provision.c -- host tests of + * svc/continuity_subject_provision.c (ALLEN genesis at identity provisioning; + * ARCH-0035 / OS-0018, PROPOSED) over the REAL sealed Store in a file with the + * real ck_rng over a mocked RNDR. + * + * genesis cs_provision writes identity + subject in ONE transaction of + * four objects; reopened, both resolve; the subject is + * sequence 1, bound to this root and agent, lineage and + * provenance as requested + * exactly once a second cs_provision is CR_ALREADY_PROVISIONED and writes + * nothing; a standing intent then advances the chain (seq 2) + * refusals zero provenance / lineage, bad origin, subject objects + * without a root, a failing Store: nothing written + * no minting a Store provisioned WITHOUT a subject (cr_provision alone) + * resolves ABSENT and nothing here writes one + * power cuts a cut at every Store checkpoint and at every block boundary + * of the provisioning write leaves exactly the old state + * (unprovisioned, no subject object) or exactly the new one + * (identity WITH its genesis subject); never one without the + * other + * Mutant (Makefile continuity-subject-provision-mutants): + * CS_MUTANT_PROVISION_SPLIT_TXN subject in a second transaction */ +#include +#include +#include +#include +#include + +#include "ck_test.h" +#include "continuity_resolve_sealed.h" +#include "continuity_subject_provision.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 IMG_BYTES ((size_t)(A_UNITS + S_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 struct cs_subject g_subj, g_subj2; +static uint8_t g_sid[32], g_sid2[32]; +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 struct cs_genesis G; + +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 + S_UNITS) * bpu, create) != 0) return -1; + g_open = 1; + if (st_disk_bind(&g_sd, &g_d, (uint64_t)A_UNITS * bpu, S_UNITS, &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); +} + +/* Counting sink in front of the sealed sink: how many Store transactions + * the operation made, and how many objects the last one carried. */ +static int g_tx, g_tx_objs, g_tx_kind24, g_fail_store; +static int count_transact(void *ctx, const struct cr_wobj *objs, size_t n) +{ + struct cr_sink *inner = ctx; + g_tx++; + g_tx_objs = (int)n; + g_tx_kind24 = 0; + for (size_t i = 0; i < n; i++) g_tx_kind24 += objs[i].kind == CC_KIND_SUBJECT; + if (g_fail_store) return -42; + return inner->transact(inner->ctx, objs, n); +} +static struct cr_sink g_sealed, g_count; +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_sealed, &g_sk); + g_count.ctx = &g_sealed; + g_count.transact = count_transact; + g_snk = g_count; + g_tx = g_tx_objs = g_tx_kind24 = 0; +} +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; +} +static void snapshot(void) +{ + dev_close(); + CK_(file_load(snap_img) == 0, "snapshot"); + CK_(reopen() == 0, "reopen after snapshot"); +} +static int unchanged(void) +{ + static uint8_t now[IMG_BYTES]; + dev_close(); + int same = file_load(now) == 0 && memcmp(now, snap_img, IMG_BYTES) == 0; + (void)reopen(); + return same; +} + +/* ---- 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) +{ + g_m.present = 1; + 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); + CK_(ck_rng_probe(&g_rng, &g_ops) == CK_RNG_OK, "rng probe"); +} + +static int do_cs_provision(const char **why, int *rc) +{ + return cs_provision(&g_src, &g_snk, &g_w, &g_tw, &g_rng, RUUID, CC_SOURCE_QUALIFICATION, &G, &g_v, + &g_subj, g_sid, why, rc); +} +static uint32_t count_kind24(void) +{ + uint32_t n = g_src.count(g_src.ctx), k = 0; + for (uint32_t i = 0; i < n; i++) { + uint16_t kind = 0, ver = 0; + if (g_src.entry(g_src.ctx, i, &kind, &ver) == 0 && kind == CC_KIND_SUBJECT) k++; + } + return k; +} + +/* ---- 1. genesis ---- */ +static void t_genesis(void) +{ + const char *why = NULL; + int rc = 0; + fresh(); + rng_init(11); + int o = do_cs_provision(&why, &rc); + CK_(o == CR_RESOLVED, "cs_provision: %s (%s rc=%d)", cr_outcome_name(o), why ? why : "-", rc); + CK_(g_tx == 1, "exactly one Store transaction (%d)", g_tx); + CK_(g_tx_objs == 4 && g_tx_kind24 == 1, "the transaction carries AgentRoot, AgentState, Manifest and the subject (%d objects, %d subject)", + g_tx_objs, g_tx_kind24); + CK_(g_subj.sequence == 1 && sv1_all_zero(g_subj.previous, 32), "genesis is sequence 1 with no previous"); + CK_(memcmp(g_subj.root, g_v.root_id, 32) == 0 && memcmp(g_subj.agent, g_v.root.agent_id, 32) == 0, + "subject bound to this root and agent"); + CK_(memcmp(g_subj.cortex, G.cortex, 32) == 0, "memory lineage as requested"); + CK_(memcmp(g_subj.provenance, G.provenance, 32) == 0 && g_subj.origin == CS_ORIGIN_OPERATOR, "provenance and origin"); + CK_(g_subj.n_intents == 0 && g_subj.n_knowledge == 0, "no intents, no knowledge at genesis"); + + /* Another process: reopen the image and resolve both chains. */ + dev_close(); + CK_(reopen() == 0, "reopen"); + CK_(cr_resolve(&g_src, &g_w, &g_v2, &why, &rc) == CR_RESOLVED, "identity resolves after reopen"); + CK_(memcmp(g_v2.root.agent_id, g_v.root.agent_id, 32) == 0, "same agent"); + CK_(cs_resolve(&g_src, &g_w, &g_v2, &g_subj2, g_sid2, &why, &rc) == CS_RESOLVED, "subject resolves: %s", why ? why : "-"); + CK_(memcmp(g_sid2, g_sid, 32) == 0 && g_subj2.sequence == 1, "same subject object, sequence 1"); + CK_(count_kind24() == 1, "exactly one subject object in the Store"); +} + +/* ---- 2. exactly once, then a standing intent ---- */ +static void t_exactly_once(void) +{ + const char *why = NULL; + int rc = 0; + fresh(); + rng_init(12); + CK_(do_cs_provision(&why, &rc) == CR_RESOLVED, "provision"); + snapshot(); + rng_init(13); + int o = do_cs_provision(&why, &rc); + CK_(o == CR_ALREADY_PROVISIONED, "second provisioning refused: %s", cr_outcome_name(o)); + CK_(g_tx == 0, "nothing sent to the Store"); + CK_(unchanged(), "image unchanged"); + CK_(count_kind24() == 1, "still one subject object"); + + /* The standing intent through the ALLEN commit path. */ + CK_(cr_resolve(&g_src, &g_w, &g_v2, &why, &rc) == CR_RESOLVED, "resolve"); + CK_(cs_resolve(&g_src, &g_w, &g_v2, &g_subj2, g_sid2, &why, &rc) == CS_RESOLVED, "subject"); + uint8_t prov[32], iid[32]; + memset(prov, 0x31, 32); + cs_subject_advance(&g_subj2, g_sid2, prov, CS_ORIGIN_OPERATOR); + const uint64_t p[2] = {7, 1000}; + CK_(cs_subject_intend(&g_subj2, CS_INTENT_GOAL_LATENCY, p, iid, &why) == CC_OK, "intend"); + CK_(cs_commit(&g_src, &g_snk, &g_w, &g_v2, &g_subj2, g_sid, &why, &rc) == CS_RESOLVED, "commit seq 2: %s", why ? why : "-"); + dev_close(); + CK_(reopen() == 0, "reopen"); + CK_(cr_resolve(&g_src, &g_w, &g_v2, &why, &rc) == CR_RESOLVED, "resolve after reopen"); + CK_(cs_resolve(&g_src, &g_w, &g_v2, &g_subj, g_sid2, &why, &rc) == CS_RESOLVED, "subject after reopen"); + CK_(g_subj.sequence == 2 && memcmp(g_sid2, g_sid, 32) == 0, "head is the sequence-2 object"); + const struct cs_intent *a = cs_subject_active(&g_subj, CS_INTENT_GOAL_LATENCY, 7); + CK_(a && memcmp(a->id, iid, 32) == 0 && a->payload[1] == 1000, "standing intent survives reopen"); + CK_(count_kind24() == 2, "two subject objects: genesis and one successor"); +} + +/* ---- 3. refusals: nothing written ---- */ +static void t_refusals(void) +{ + const char *why = NULL; + int rc = 0; + struct cs_genesis keep = G; + fresh(); + snapshot(); + rng_init(21); + memset(G.provenance, 0, 32); + CK_(do_cs_provision(&why, &rc) == CR_E_ARG && why && !strcmp(why, "subject genesis needs a provenance"), "zero provenance"); + G = keep; + memset(G.cortex, 0, 32); + CK_(do_cs_provision(&why, &rc) == CR_E_ARG && why && !strcmp(why, "subject genesis needs a memory lineage reference"), "zero lineage"); + G = keep; + G.origin = 9; + CK_(do_cs_provision(&why, &rc) == CR_E_ARG, "bad origin"); + G = keep; + CK_(cs_provision(&g_src, &g_snk, &g_w, &g_tw, &g_rng, RUUID, CC_SOURCE_QUALIFICATION, NULL, &g_v, &g_subj, g_sid, &why, &rc) == CR_E_ARG, + "null genesis"); + G = keep; + fresh(); + snapshot(); + rng_init(22); + g_fail_store = 1; + int o = do_cs_provision(&why, &rc); + g_fail_store = 0; + CK_(o == CR_STORE, "failing Store: %s", cr_outcome_name(o)); + CK_(unchanged(), "failing Store: image unchanged"); + CK_(cr_resolve(&g_src, &g_w, &g_v2, &why, &rc) == CR_UNPROVISIONED && count_kind24() == 0, "still unprovisioned, no subject"); + + /* A subject object with no agent root is never provisioned over. */ + fresh(); + { + static struct cs_subject f; + static uint8_t b[CS_MAX_BYTES]; + size_t len = 0; + memset(&f, 0, sizeof f); + memset(f.root, 0x44, 32); + memset(f.agent, 0x45, 32); + f.sequence = 1; + memset(f.provenance, 0x46, 32); + f.origin = CS_ORIGIN_OPERATOR; + memset(f.cortex, 0x47, 32); + CK_(cs_subject_encode(&f, b, sizeof b, &len, &why) == CC_OK, "encode orphan"); + struct cr_wobj ob = {CC_KIND_SUBJECT, CC_STORE_OBJECT_VERSION, b, len}; + CK_(g_sealed.transact(g_sealed.ctx, &ob, 1) == 0, "plant orphan subject"); + } + snapshot(); + rng_init(23); + o = do_cs_provision(&why, &rc); + CK_(o == CR_CORRUPT && why && !strcmp(why, "subject objects without an agent root"), "orphan subject: %s (%s)", + cr_outcome_name(o), why ? why : "-"); + CK_(g_tx == 0 && unchanged(), "orphan subject: nothing written"); +} + +/* ---- 4. a Store provisioned without a subject resolves ABSENT ---- */ +static void t_absent_never_minted(void) +{ + const char *why = NULL; + int rc = 0; + fresh(); + rng_init(31); + CK_(cr_provision(&g_src, &g_snk, &g_w, &g_tw, &g_rng, RUUID, CC_SOURCE_QUALIFICATION, &g_v, &why, &rc) == CR_RESOLVED, + "identity-only provisioning"); + snapshot(); + CK_(cs_resolve(&g_src, &g_w, &g_v, &g_subj, g_sid, &why, &rc) == CS_ABSENT, "subject ABSENT"); + rng_init(32); + CK_(do_cs_provision(&why, &rc) == CR_ALREADY_PROVISIONED, "cs_provision does not add a subject to a provisioned identity"); + CK_(unchanged() && count_kind24() == 0, "nothing written; still no subject object"); +} + +/* ---- 5. power cuts during the provisioning write ---- */ +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); +} +static uint8_t g_agent_new[32], g_sid_new[32]; + +/* 1 = old (unprovisioned, no subject object), 2 = new (identity + its + * genesis subject, the same objects as the uncut run), 0 = anything else. */ +static int classify(const char *what) +{ + const char *why = NULL; + int rc = reopen(); + CK_(rc == 0, "%s: reopen after the cut: %d", what, rc); + if (rc) return 0; + int o = cr_resolve(&g_src, &g_w, &g_v2, &why, &rc); + if (o == CR_UNPROVISIONED) { + uint32_t k = count_kind24(); + CK_(k == 0, "%s: unprovisioned but %u subject objects", what, k); + return k == 0 ? 1 : 0; + } + if (o != CR_RESOLVED) { + CK_(0, "%s: identity %s (%s)", what, cr_outcome_name(o), why ? why : "-"); + return 0; + } + int s = cs_resolve(&g_src, &g_w, &g_v2, &g_subj2, g_sid2, &why, &rc); + int ok = s == CS_RESOLVED && g_subj2.sequence == 1 && memcmp(g_sid2, g_sid_new, 32) == 0 && + memcmp(g_v2.root.agent_id, g_agent_new, 32) == 0 && count_kind24() == 1; + CK_(ok, "%s: identity present but subject %s (%s)", what, s == CS_ABSENT ? "ABSENT" : cr_outcome_name(s), + why ? why : "-"); + return ok ? 2 : 0; +} + +static void t_power_cuts(void) +{ + const char *why = NULL; + int rc = 0, old = 0, neu = 0, bad = 0; + fresh(); + dev_close(); + CK_(file_load(base_img) == 0, "save base"); + CK_(reopen() == 0, "reopen base"); + uint64_t w0 = g_f.blocks_written; + rng_init(777); + CK_(do_cs_provision(&why, &rc) == CR_RESOLVED, "uncut provisioning"); + uint64_t W = g_f.blocks_written - w0; + memcpy(g_agent_new, g_v.root.agent_id, 32); + memcpy(g_sid_new, g_sid, 32); + dev_close(); + for (int i = 0; i < CUT_CHECKPOINTS; i++) { + char what[96]; + snprintf(what, sizeof what, "bs=%u cp %s", 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); + rng_init(777); + (void)do_cs_provision(&why, &rc); + CK_(g_cp_fired == 1, "%s: checkpoint never reached", what); + disk_file_disarm(&g_f); + int v = classify(what); + if (CPS[i] <= ST_CP_AFTER_FIRST_FLUSH) CK_(v == 1, "%s: expected unprovisioned", what); + if (CPS[i] == ST_CP_AFTER_FINAL_FLUSH || CPS[i] >= SS_CP_BEFORE_ANCHOR) CK_(v == 2, "%s: expected identity + subject", what); + old += v == 1; + neu += v == 2; + bad += v == 0; + } + for (uint64_t k = 0; k <= W; k++) { + char what[96]; + snprintf(what, sizeof what, "bs=%u block cut %llu/%llu", 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); + rng_init(777); + (void)do_cs_provision(&why, &rc); + disk_file_disarm(&g_f); + int v = classify(what); + if (k == 0) CK_(v == 1, "%s: cut 0 must be unprovisioned", what); + if (k == W) CK_(v == 2, "%s: full write must be identity + subject", what); + old += v == 1; + neu += v == 2; + bad += v == 0; + } + printf("power cut, ALLEN genesis, %4u-byte blocks: %d checkpoints + %llu block boundaries: %d unprovisioned, " + "%d identity+subject, %d other\n", + g_bs, CUT_CHECKPOINTS, (unsigned long long)W + 1, old, neu, bad); + CK_(bad == 0, "never an identity without its subject, never a stray subject"); +} + +int main(void) +{ + make_keys(); + memset(G.provenance, 0xa5, 32); + memset(G.cortex, 0xc0, 32); + G.origin = CS_ORIGIN_OPERATOR; + snprintf(g_path, sizeof g_path, "/tmp/ck_csp_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_genesis(); + t_exactly_once(); + t_refusals(); + t_absent_never_minted(); + t_power_cuts(); + } + dev_close(); + unlink(g_path); + return ck_t_verdict("test_continuity_subject_provision"); +} diff --git a/native/kernel/tools/.crumb b/native/kernel/tools/.crumb index 20173a60..19b356f2 100644 --- a/native/kernel/tools/.crumb +++ b/native/kernel/tools/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-04T17:01:01Z", + "compiled_at": "2026-10-05T02:01:59Z", "compiler": "crumb-compile/1", - "digest": "sha256:76d69ccab500306184f1ee05b9b252c740236a9656ceda44fe96c93bce2f2b21", + "digest": "sha256:5e6a44b4b936178bd58d2840921cc5d478ed9126ffea1aa3c36d628a6598549f", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 10, - "generated_at_commit": "1e28ff5b9ba3193a14e6063175d81e39d545e11f", - "source_tree": "sha256:9dd19dc4affb3f453632808fe1454100fc3b8d554018f0e1c310002bea0bbd45" + "generated_at_commit": "71d5b326eea6a330f3cc1c4377fc4bc2d134d5aa", + "source_tree": "sha256:c41d2afc039bf7d3064effb8d26770dad71d9432e6a06b3e8cb28c7eaea5f334" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/tools/ck_cont_tool.c b/native/kernel/tools/ck_cont_tool.c index 3a9d4887..03a16f7f 100644 --- a/native/kernel/tools/ck_cont_tool.c +++ b/native/kernel/tools/ck_cont_tool.c @@ -12,11 +12,20 @@ * ck_cont_tool corrupt-root IMG BS * flip byte 20 of the first AgentRoot (kind 16) envelope (the Rust `corrupt-kind ... 16` * stand-in; contract K-3/K-4: the sealed mount refuses it) + * ck_cont_tool subject-dump IMG BS [HEAD_OUT] + * read-only: the ALLEN subject (kind 24) on the image as the kernel resolves it; optional + * canonical bytes of the head object (ARCH-0035 / OS-0018, PROPOSED) + * ck_cont_tool subject-plant IMG BS fork | foreign SRC_IMG + * TEST fixture: a second genesis subject (fork), or every subject object of another image, verbatim + * ck_cont_tool corrupt-subject IMG BS + * flip byte 20 of the first subject envelope */ #include #include #include #include "continuity_resolve.h" +#include "continuity_resolve_sealed.h" +#include "continuity_subject.h" #include "disk_file.h" #include "disk_layout.h" #include "disk_part.h" @@ -24,7 +33,9 @@ static int usage(void) { - fprintf(stderr, "usage: ck_cont_tool respond KEY CHALLENGE | inject-peer IMG BS | corrupt-root IMG BS\n"); + fprintf(stderr, "usage: ck_cont_tool respond KEY CHALLENGE | inject-peer IMG BS | corrupt-root IMG BS |\n" + " subject-dump IMG BS [HEAD_OUT] | subject-plant IMG BS fork | subject-plant IMG BS foreign SRC_IMG |\n" + " corrupt-subject IMG BS\n"); return 2; } @@ -168,11 +179,235 @@ static int cmd_corrupt_root(int argc, char **argv) return rc ? 1 : 0; } +/* ---- ALLEN subject (kind 24; ARCH-0035 / OS-0018, PROPOSED) ---- + * subject-dump reads the Store of a boot-disk image the way the kernel does + * (sealed mount, cr_resolve, cs_resolve) and prints what is ON THE DISK, + * independent of the guest's serial output. It writes nothing; the gate runs + * it on a copy. subject-plant and corrupt-subject make TEST fixtures. */ +static void hexp(const uint8_t *b, size_t n) +{ + for (size_t i = 0; i < n; i++) printf("%02x", b[i]); +} + +struct subj_ctx { + image im; + ss_workspace *ws; + ss_store *s; + struct cr_source src; + struct cr_work w; + struct cr_view v; + struct cs_subject subj; + uint8_t id[32]; +}; + +/* Mount, resolve identity, resolve subject. Returns the cr_resolve outcome + * in *io and the cs_resolve outcome in *so (-1 if not reached); 0 or -1 when + * the image could not be mounted. */ +static int subj_open(struct subj_ctx *c, const char *path, const char *bs, int *io, int *so, const char **why) +{ + int src_rc = 0; + *io = *so = -1; + if (img_open(&c->im, path, bs)) return -1; + c->ws = calloc(1, sizeof *c->ws); + c->s = calloc(1, sizeof *c->s); + if (!c->ws || !c->s || img_mount(&c->im, c->s, c->ws)) return -1; + cr_bind_sealed(&c->src, c->s); + *io = cr_resolve(&c->src, &c->w, &c->v, why, &src_rc); + if (*io != CR_RESOLVED) return 0; + *so = cs_resolve(&c->src, &c->w, &c->v, &c->subj, c->id, why, &src_rc); + return 0; +} +static void subj_close(struct subj_ctx *c) +{ + free(c->s); + free(c->ws); + disk_file_close(&c->im.f); +} + +static int cmd_subject_dump(int argc, char **argv) +{ + if (argc != 4 && argc != 5) return usage(); + static struct subj_ctx c; + const char *why = NULL; + int io, so; + if (subj_open(&c, argv[2], argv[3], &io, &so, &why)) { + printf("subject-dump: store=Refused\n"); + return 1; + } + uint32_t n = c.src.count(c.src.ctx), objs = 0, genesis = 0; + for (uint32_t i = 0; i < n; i++) { + uint16_t kind = 0, ver = 0; + size_t len = 0; + if (c.src.entry(c.src.ctx, i, &kind, &ver) || kind != CC_KIND_SUBJECT) continue; + objs++; + static struct cs_subject t; + if (c.src.read(c.src.ctx, i, c.w.buf, sizeof c.w.buf, &len) == 0 && + cs_subject_decode(c.w.buf, len, &t, NULL) == CC_OK && t.sequence == 1) + genesis++; + } + printf("subject-dump: generation=%llu identity=%s", (unsigned long long)ss_generation(c.s), cr_outcome_name(io)); + if (io == CR_RESOLVED) { + printf(" agent="); + hexp(c.v.root.agent_id, 32); + } + printf(" subject_objects=%u genesis_objects=%u", objs, genesis); + if (so == CS_RESOLVED) { + uint32_t active = 0; + for (uint32_t i = 0; i < c.subj.n_intents; i++) active += c.subj.in[i].state == CS_ACTIVE; + printf(" subject="); + hexp(c.id, 32); + printf(" sequence=%llu lineage=", (unsigned long long)c.subj.sequence); + hexp(c.subj.cortex, 32); + printf(" active=%u\n", active); + for (uint32_t i = 0; i < c.subj.n_intents; i++) { + const struct cs_intent *a = &c.subj.in[i]; + if (a->state != CS_ACTIVE) continue; + printf("subject-dump: intent id="); + hexp(a->id, 32); + printf(" kind=%u regime=%llu target_ns=%llu since=%llu\n", (unsigned)a->kind, + (unsigned long long)a->payload[0], (unsigned long long)a->payload[1], (unsigned long long)a->since); + } + if (argc == 5) { /* the head object, canonical bytes, for omega's allen tool */ + static uint8_t b[CS_MAX_BYTES]; + size_t len = 0; + uint8_t id2[32]; + FILE *f = NULL; + if (cs_subject_encode(&c.subj, b, sizeof b, &len, &why) != CC_OK || cs_subject_id(b, len, id2) != CC_OK || + memcmp(id2, c.id, 32) || !(f = fopen(argv[4], "wb")) || fwrite(b, 1, len, f) != len) { + if (f) fclose(f); + fprintf(stderr, "subject-dump: cannot write the head object\n"); + subj_close(&c); + return 1; + } + fclose(f); + } + } else if (so == CS_ABSENT) { + printf(" subject=ABSENT\n"); + } else if (so >= 0) { + printf(" subject=%s (%s)\n", cr_outcome_name(so), why ? why : "-"); + } else { + printf("\n"); + } + subj_close(&c); + return 0; +} + +static int plant(struct subj_ctx *c, const uint8_t *b, size_t len) +{ + struct cr_sealed_sink sk = {c->s, 0, 0}; + struct cr_sink snk; + struct cr_wobj o = {CC_KIND_SUBJECT, CC_STORE_OBJECT_VERSION, b, len}; + cr_bind_sealed_sink(&snk, &sk); + return snk.transact(snk.ctx, &o, 1); +} + +/* subject-plant IMG BS fork : a second sequence-1 subject for the same root and agent + * subject-plant IMG BS foreign SRC : every subject object of image SRC, verbatim */ +static int cmd_subject_plant(int argc, char **argv) +{ + if (argc < 5) return usage(); + static struct subj_ctx c, f; + static uint8_t b[CS_MAX_BYTES]; + size_t len = 0; + const char *why = NULL; + int io, so, rc = 1; + if (subj_open(&c, argv[2], argv[3], &io, &so, &why) || io != CR_RESOLVED) { + fprintf(stderr, "subject-plant: target identity does not resolve\n"); + return 1; + } + if (!strcmp(argv[4], "fork") && argc == 5) { + if (so != CS_RESOLVED) { + fprintf(stderr, "subject-plant: target has no subject to fork\n"); + } else { + uint8_t prov[32]; + memset(prov, 0xf0, 32); + static struct cs_subject g; + cs_subject_genesis(&g, &c.v, prov, CS_ORIGIN_OPERATOR); + cs_subject_bind_cortex(&g, c.subj.cortex); + if (cs_subject_encode(&g, b, sizeof b, &len, &why) == CC_OK && plant(&c, b, len) == 0) { + printf("subject-plant: second genesis subject planted (fork)\n"); + rc = 0; + } + } + } else if (!strcmp(argv[4], "foreign") && argc == 6) { + int fio, fso; + if (subj_open(&f, argv[5], argv[3], &fio, &fso, &why) || fso != CS_RESOLVED) { + fprintf(stderr, "subject-plant: source image has no subject\n"); + } else if (!memcmp(f.v.root.agent_id, c.v.root.agent_id, 32)) { + fprintf(stderr, "subject-plant: source and target share an agent\n"); + } else { + /* every subject object of the source image, verbatim */ + uint32_t n = f.src.count(f.src.ctx), k = 0; + rc = 0; + for (uint32_t i = 0; i < n && !rc; i++) { + uint16_t kind = 0, ver = 0; + if (f.src.entry(f.src.ctx, i, &kind, &ver) || kind != CC_KIND_SUBJECT) continue; + if (f.src.read(f.src.ctx, i, b, sizeof b, &len) || plant(&c, b, len)) rc = 1; + else k++; + } + if (!rc) { + printf("subject-plant: %u foreign subject objects of agent ", k); + hexp(f.subj.agent, 32); + printf(" planted\n"); + } + } + if (f.s) subj_close(&f); + } else { + subj_close(&c); + return usage(); + } + subj_close(&c); + return rc; +} + +/* corrupt-subject IMG BS: flip byte 20 of the first subject (kind 24) envelope. */ +static int cmd_corrupt_subject(int argc, char **argv) +{ + if (argc != 4) return usage(); + image im; + if (img_open(&im, argv[2], argv[3])) return 1; + ss_workspace *ws = calloc(1, sizeof *ws); + ss_store *s = calloc(1, sizeof *s); + int rc = !ws || !s ? -1 : img_mount(&im, s, ws), done = 0; + for (uint32_t k = 0; !rc && !done && k < s->nclaims; k++) { + if (ws->claims[k].c.obj.object_kind != CC_KIND_SUBJECT) continue; + uint32_t n = 0; + const sv1_entry *cat = st_catalog(&s->st, &n); + for (uint32_t j = 0; j < n; j++) { + if (memcmp(cat[j].object_id, ws->claims[k].sid, 32)) continue; + uint8_t *u = malloc(CK_LAYOUT_UNIT); + uint64_t lba = im.base_lba + cat[j].first_unit * im.bpu; + rc = disk_read(im.d, lba, im.bpu, u); + if (!rc) { + u[20] ^= 0xff; + rc = disk_write(im.d, lba, im.bpu, u); + } + if (!rc) rc = disk_flush(im.d); + free(u); + done = 1; + if (!rc) printf("corrupt-subject: byte 20 of a subject envelope (store unit %llu) flipped\n", + (unsigned long long)cat[j].first_unit); + break; + } + } + if (!rc && !done) { + fprintf(stderr, "no subject envelope found\n"); + rc = -1; + } + free(s); + free(ws); + disk_file_close(&im.f); + return rc ? 1 : 0; +} + int main(int argc, char **argv) { if (argc < 2) return usage(); if (!strcmp(argv[1], "respond")) return cmd_respond(argc, argv); if (!strcmp(argv[1], "inject-peer")) return cmd_inject_peer(argc, argv); if (!strcmp(argv[1], "corrupt-root")) return cmd_corrupt_root(argc, argv); + if (!strcmp(argv[1], "subject-dump")) return cmd_subject_dump(argc, argv); + if (!strcmp(argv[1], "subject-plant")) return cmd_subject_plant(argc, argv); + if (!strcmp(argv[1], "corrupt-subject")) return cmd_corrupt_subject(argc, argv); return usage(); } diff --git a/scripts/.crumb b/scripts/.crumb index 09875185..d6b09735 100644 --- a/scripts/.crumb +++ b/scripts/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-04T16:47:58Z", + "compiled_at": "2026-10-05T02:01:59Z", "compiler": "crumb-compile/1", - "digest": "sha256:c2faf9bb1f39cfe42057ef4fc740d04cc8c614bd4e31917f41b5cbe1acb8fcb6", + "digest": "sha256:07ca1d2521f97f9ca307c0d11fd0793cb00558b2a429f581c9bd3c2b91e4f1cf", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 62, - "generated_at_commit": "2e44c0bba93bcc605dd45570ee8cfb8d56591cc3", - "source_tree": "sha256:145f37544c387b2b7a0c69d7ee85d8c35911ffada9808e4c6b4b0b7a97b0ec61" + "files": 63, + "generated_at_commit": "71d5b326eea6a330f3cc1c4377fc4bc2d134d5aa", + "source_tree": "sha256:ec0193ea6eed88a2b80cd9ab91a52708e5cf613af4a4f719531eee4ac77d624d" }, "owner_lane": "", "provenance": { diff --git a/scripts/ck_gates.sh b/scripts/ck_gates.sh index 1f896d7e..333af731 100755 --- a/scripts/ck_gates.sh +++ b/scripts/ck_gates.sh @@ -7,12 +7,12 @@ # scripts/qemu_ck_net_test.sh, scripts/qemu_ck_artifact_test.sh, # scripts/qemu_ck_smp_test.sh, scripts/qemu_ck_store_crash_test.sh, # scripts/qemu_ck_disk_layout_test.sh, scripts/qemu_ck_continuity_test.sh, -# scripts/qemu_ck_recovery_test.sh, scripts/qemu_ck_fpu_test.sh, +# scripts/qemu_ck_recovery_test.sh, scripts/qemu_ck_allen_test.sh, scripts/qemu_ck_fpu_test.sh, # scripts/qemu_ck_infer_test.sh, scripts/qemu_ck_screen_test.sh), and prints # one line per gate: # AIENOS_CK_: PASS|FAIL|NOT_RUN [(reason)] # for M1 M3 SMMU NVME_SHUTDOWN P2_ARTIFACT M0_ROLLBACK M4_NVME M4_STORE M4_STORE_CRASH -# M4_CONTINUITY M4_RECOVERY ARGUS1_REVOKE KEYBOARD NET SMP DISK_LAYOUT FPU INFER SCREEN. Gates with no C +# M4_CONTINUITY M4_RECOVERY M4_ALLEN ARGUS1_REVOKE KEYBOARD NET SMP DISK_LAYOUT FPU INFER SCREEN. Gates with no C # implementation print NOT_RUN (MISSING_IMPLEMENTATION: ) and never # run anything. A missing child script, a child that reports NOT_RUN, a child # that prints no verdict line, or a PASS line contradicted by the child's exit @@ -53,6 +53,7 @@ set -uo pipefail # disk -> verdict line from scripts/qemu_ck_disk_layout_test.sh # cont -> verdict line from scripts/qemu_ck_continuity_test.sh # recov -> verdict line from scripts/qemu_ck_recovery_test.sh +# allen -> verdict line from scripts/qemu_ck_allen_test.sh (ALLEN genesis/restore, OS-0018 PROPOSED) # fpu -> verdict line from scripts/qemu_ck_fpu_test.sh (NOT_RUN without the Rust target) # infer -> verdict line from scripts/qemu_ck_infer_test.sh (NOT_RUN without the model file or the Rust target) # screen -> verdict line from scripts/qemu_ck_screen_test.sh (GOP framebuffer console vs a QMP screendump) @@ -70,6 +71,7 @@ M4_STORE|store|- M4_STORE_CRASH|crash|- M4_CONTINUITY|cont|- M4_RECOVERY|recov|- +M4_ALLEN|allen|- ARGUS1_REVOKE|store|- KEYBOARD|missing|no xHCI/USB HID keyboard driver in the C kernel NET|net|- @@ -79,7 +81,7 @@ FPU|fpu|- INFER|infer|- SCREEN|screen|- ' -CHILDREN=(boot store net artifact smp crash disk cont recov fpu infer screen) +CHILDREN=(boot store net artifact smp crash disk cont recov allen fpu infer screen) # =========================================================================== repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" @@ -126,6 +128,7 @@ set_default_children() { [disk]="${repo_root}/scripts/qemu_ck_disk_layout_test.sh" [cont]="${repo_root}/scripts/qemu_ck_continuity_test.sh" [recov]="${repo_root}/scripts/qemu_ck_recovery_test.sh" + [allen]="${repo_root}/scripts/qemu_ck_allen_test.sh" [fpu]="${repo_root}/scripts/qemu_ck_fpu_test.sh" [infer]="${repo_root}/scripts/qemu_ck_infer_test.sh" [screen]="${repo_root}/scripts/qemu_ck_screen_test.sh" @@ -358,11 +361,11 @@ self_test() { } expect_missing_all() { local g - for g in P2_ARTIFACT M0_ROLLBACK M4_STORE_CRASH M4_CONTINUITY M4_RECOVERY KEYBOARD DISK_LAYOUT FPU INFER SCREEN; do expect "${g}" NOT_RUN; done # P2_ARTIFACT: no artifact child in A..G; M4_STORE_CRASH: no crash child in A..J and R; DISK_LAYOUT: no disk child in A..S + for g in P2_ARTIFACT M0_ROLLBACK M4_STORE_CRASH M4_CONTINUITY M4_RECOVERY M4_ALLEN KEYBOARD DISK_LAYOUT FPU INFER SCREEN; do expect "${g}" NOT_RUN; done # P2_ARTIFACT: no artifact child in A..G; M4_STORE_CRASH: no crash child in A..J and R; DISK_LAYOUT: no disk child in A..S } scenario() { # NAME BOOT_SCRIPT STORE_SCRIPT [NET_SCRIPT] [ARTIFACT_SCRIPT] [SMP_SCRIPT] [CRASH_SCRIPT] [DISK_SCRIPT] (absent: missing) scen="$1" - declare -gA child_script=([boot]="$2" [store]="$3" [net]="${4:-${tmp}/kids/net_not_present.sh}" [artifact]="${5:-${tmp}/kids/no_artifact_child.sh}" [smp]="${6:-${tmp}/kids/no_smp_child.sh}" [crash]="${7:-${tmp}/kids/no_crash_child.sh}" [disk]="${8:-${tmp}/kids/no_disk_child.sh}" [cont]="${tmp}/kids/no_cont_child.sh" [recov]="${tmp}/kids/no_recov_child.sh" [fpu]="${tmp}/kids/no_fpu_child.sh" [infer]="${tmp}/kids/no_infer_child.sh" [screen]="${tmp}/kids/no_screen_child.sh") + declare -gA child_script=([boot]="$2" [store]="$3" [net]="${4:-${tmp}/kids/net_not_present.sh}" [artifact]="${5:-${tmp}/kids/no_artifact_child.sh}" [smp]="${6:-${tmp}/kids/no_smp_child.sh}" [crash]="${7:-${tmp}/kids/no_crash_child.sh}" [disk]="${8:-${tmp}/kids/no_disk_child.sh}" [cont]="${tmp}/kids/no_cont_child.sh" [recov]="${tmp}/kids/no_recov_child.sh" [allen]="${tmp}/kids/no_allen_child.sh" [fpu]="${tmp}/kids/no_fpu_child.sh" [infer]="${tmp}/kids/no_infer_child.sh" [screen]="${tmp}/kids/no_screen_child.sh") run_children 2>/dev/null evaluate_table >"${tmp}/${scen}.out" } @@ -378,8 +381,8 @@ self_test() { "$(fake smpA 0 'PASS 3 secondary cores checked in' 'AIENOS_CK_SMP_MUTATION: FAIL' 'AIENOS_CK_SMP: PASS')" expect M1 PASS; expect M3 PASS; expect M4_NVME PASS; expect M4_STORE PASS; expect ARGUS1_REVOKE PASS; expect SMMU PASS; expect NVME_SHUTDOWN PASS; expect NET PASS; expect SMP PASS; expect_missing_all count_rows - [[ "${n_pass}/${n_fail}/${n_notrun}/${n_total}" == "9/0/10/19" && ${overall} == NOT_ALL_GATES_PASS ]] \ - && ok "A: counts 9/0/10 of 19, verdict NOT_ALL_GATES_PASS" || bad "A: counts ${n_pass}/${n_fail}/${n_notrun}/${n_total} ${overall}" + [[ "${n_pass}/${n_fail}/${n_notrun}/${n_total}" == "9/0/11/20" && ${overall} == NOT_ALL_GATES_PASS ]] \ + && ok "A: counts 9/0/11 of 20, verdict NOT_ALL_GATES_PASS" || bad "A: counts ${n_pass}/${n_fail}/${n_notrun}/${n_total} ${overall}" [[ "$(nvme_dma_mode)" == "Confined (QEMU SMMUv3 stage 1, out-of-window DMA faulted); no-SMMU boot denied (NoSmmu); TEST-ONLY bypass image checked separately" ]] && ok "A: confined DMA mode recorded from the store PASS lines" || bad "A: dma mode '$(nvme_dma_mode)'" grep -qxF "AIENOS_CK_M4_NVME: PASS (${M4_NVME_PASS_NOTE})" "${tmp}/A.out" \ && ok "A: M4_NVME PASS line carries the confined-mode note" || bad "A: M4_NVME PASS line lacks the note" @@ -387,7 +390,7 @@ self_test() { && ok "A: NET PASS line carries the QEMU slirp / SMMU fence note" || bad "A: NET PASS line lacks the note" grep -qx 'AIENOS_CK_KEYBOARD: NOT_RUN (MISSING_IMPLEMENTATION: no xHCI/USB HID keyboard driver in the C kernel)' "${tmp}/A.out" \ && ok "A: missing gate prints NOT_RUN (MISSING_IMPLEMENTATION: reason)" || bad "A: KEYBOARD line wrong" - [[ "$(grep -c '^AIENOS_CK_[A-Z0-9_]*: ' "${tmp}/A.out")" == 19 ]] && ok "A: exactly 19 verdict lines" || bad "A: verdict line count" + [[ "$(grep -c '^AIENOS_CK_[A-Z0-9_]*: ' "${tmp}/A.out")" == 20 ]] && ok "A: exactly 20 verdict lines" || bad "A: verdict line count" # B: boot FAIL; store script missing -> its three gates NOT_RUN, never PASS. scenario B "$(fake bootB 1 'FAIL kernel: alive' 'AIENOS_CK_M3: FAIL' 'AIENOS_CK_M1: FAIL')" "${tmp}/kids/does_not_exist.sh" @@ -500,10 +503,10 @@ self_test() { # Restore the clean-tree receipt as the one the checks below look at. write_receipt if command -v jq >/dev/null; then - jq -e '.physical == "NOT_RUN" and (.gates | length) == 19 and .verdict == "NOT_ALL_GATES_PASS" + jq -e '.physical == "NOT_RUN" and (.gates | length) == 20 and .verdict == "NOT_ALL_GATES_PASS" and ([.gates[] | select(.id == "M1")][0].verdict == "PASS") and ([.gates[] | select(.id == "ARGUS1_REVOKE")][0].verdict == "FAIL") - and (.children | length) == 12 and .commit_subject == "quote \" backslash \\ tab\tend"' "${receipt_path}" >/dev/null \ + and (.children | length) == 13 and .commit_subject == "quote \" backslash \\ tab\tend"' "${receipt_path}" >/dev/null \ && ok "receipt is valid JSON (jq) with expected fields" || bad "receipt JSON invalid or fields wrong" else echo "NOT_RUN jq not installed; JSON validity not machine-checked"; jq_skipped=1 @@ -516,18 +519,18 @@ self_test() { bad "an existing receipt was overwritten or the clash was not refused" fi - # The gate table parses: 19 rows, known sources, reasons only on missing rows. + # The gate table parses: 20 rows, known sources, reasons only on missing rows. local g s w rows=0 tbad=0 while IFS='|' read -r g s w; do [[ -n "${g}" ]] || continue rows=$((rows + 1)) case "${s}" in - boot|store|net|artifact|smp|crash|disk|cont|recov|fpu|infer|screen) [[ "${w}" == - ]] || tbad=1 ;; + boot|store|net|artifact|smp|crash|disk|cont|recov|allen|fpu|infer|screen) [[ "${w}" == - ]] || tbad=1 ;; missing) [[ -n "${w}" && "${w}" != - ]] || tbad=1 ;; *) tbad=1 ;; esac done <<<"${CK_GATE_TABLE}" - [[ ${tbad} == 0 && ${rows} == 19 ]] && ok "gate table: 19 rows well-formed" || bad "gate table malformed (${rows} rows)" + [[ ${tbad} == 0 && ${rows} == 20 ]] && ok "gate table: 20 rows well-formed" || bad "gate table malformed (${rows} rows)" # Dirty-tree refusal, end to end, on a private clone (never this tree). # Both runs stop before any child script (no QEMU). diff --git a/scripts/lib_ck_cont_qemu.sh b/scripts/lib_ck_cont_qemu.sh index c882981f..061c3e9a 100644 --- a/scripts/lib_ck_cont_qemu.sh +++ b/scripts/lib_ck_cont_qemu.sh @@ -23,8 +23,8 @@ cq_init() { --mutant) cq_mode=mutant; cq_mutant="${2:-}" case "${cq_mutant}" in - resume_no_commit|resume_provisions|degraded_is_unprovisioned|compare_16|bare_sha256) ;; - *) echo "usage: $0 [--mutant resume_no_commit|resume_provisions|degraded_is_unprovisioned|compare_16|bare_sha256]" >&2; exit 2 ;; + resume_no_commit|resume_provisions|degraded_is_unprovisioned|compare_16|bare_sha256|subject_restore_mints|subject_accept_foreign) ;; + *) echo "usage: $0 [--mutant resume_no_commit|resume_provisions|degraded_is_unprovisioned|compare_16|bare_sha256|subject_restore_mints|subject_accept_foreign]" >&2; exit 2 ;; esac ;; *) echo "usage: $0 [--mutant NAME]" >&2; exit 2 ;; esac diff --git a/scripts/qemu_ck_allen_test.sh b/scripts/qemu_ck_allen_test.sh new file mode 100755 index 00000000..78644904 --- /dev/null +++ b/scripts/qemu_ck_allen_test.sh @@ -0,0 +1,231 @@ +#!/usr/bin/env bash +# CK gate M4_ALLEN: the ALLEN subject (ARCH-0035 / OS-0018, both PROPOSED) in +# the AIENOS lifecycle, on a 4096-byte-LBA emulated NVMe image under QEMU, one +# cold QEMU process per boot (scripts/lib_ck_cont_qemu.sh: every boot is a new +# qemu-system-aarch64 process; the ESP folder and the UEFI vars are rebuilt for +# every boot; only the NVMe image file carries state from one boot to the next). +# +# The kernel is the TEST continuity image (make full CK_TEST_CONTINUITY=1), +# the same image and the same provisioning boundary as M4_CONTINUITY: plan +# mode 5 with lineage= provisions the identity AND the genesis subject in one +# Store transaction (svc/continuity_subject_provision.c); intent= adds one +# standing intent as subject sequence 2; plan mode 6 resumes and restores the +# subject read-only before anything is written (svc/continuity_boot.c). +# +# G7 native genesis the kernel creates the subject during provisioning +# G8 exactly once provisioning a provisioned image is refused; restores never mint +# G9 cold restart same subject, intent and lineage after QEMU process death, twice +# G10 native path an independent host reader finds the subject ON the image; the +# restore plan carries no subject; another image restores another subject +# G11 corruption forked chain, flipped envelope, missing subject: refused, nothing minted +# G12 foreign identity another installation's subject chain: refused, never adopted +# FI power loss SIGKILL at every Store checkpoint of the genesis transaction, then a +# cold boot: unprovisioned or identity WITH subject, never one alone +# +# QEMU is not hardware: a PASS qualifies nothing physical (no DGX Spark reboot, +# no physical NVMe, no machine migration). Usage: [--mutant NAME] (the +# subject_restore_mints and subject_accept_foreign mutants must be KILLED). +set -uo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")/.." +repo_root="$(pwd)" +gate_name=M4_ALLEN +script_tag=qemu_ck_allen +# shellcheck source=scripts/lib_ck_cont_qemu.sh +source scripts/lib_ck_cont_qemu.sh +cq_init "$@" +cq_build +[[ "${cq_mode}" == mutant ]] || cq_default_image_checks +cq_quiet_and_trap +[[ "${cq_mode}" == mutant || "${hw_ok}" == 1 ]] || fail=1 +new_disk + +# Qualification inputs. The lineage is the digest of record 1 of the omega +# Cortex journal the ALLEN v0 host gates seed (omega tests/allen/run.sh j1); +# the intent is the v0 qualification goal (regime 7, 1000 ns per call). +LINEAGE=e3f241da5ea18408653a70e3691653db216b5dcc51169b799827cf4f2699731b +REGIME=7 +TARGET=1000 +prov_plan() { plan 5 "lineage=${LINEAGE}" "intent=${REGIME},${TARGET}" "$@"; } + +if [[ "${cq_mode}" != mutant ]]; then + if grep -aqF "ALLEN: GENESIS" "${plain_efi}"; then bad "default image carries the ALLEN TEST markers"; else pass "default image carries no ALLEN TEST markers"; fi +fi + +dump() { # IMG -> the host reader's lines, on a COPY (the reader never touches the image under test) + local c="${top}/dump.img"; cp "$1" "${c}" + "${cont_tool}" subject-dump "${c}" 4096 "${2:-}" 2>&1; rm -f "${c}" +} +kv() { sed -nE "s/.* $1=([^ ]+).*/\1/p" <<<"$2" | head -1; } +allen() { grep -E "^ALLEN: $1( |$)" "${work}/serial.txt" | tail -1; } +n_allen() { grep -cE "^ALLEN: $1( |$)" "${work}/serial.txt" || true; } +plan_text() { dd if="${image}" bs="${unit}" skip="${plan_unit}" count=1 status=none | tr -d '\0' | head -1; } + +# ---------------------------------------------------------------- G7 genesis +fresh_image +d0=$(dump "${image}") +prov_plan +boot +l_prov=$(out '^CONTINUITY: ') +l_gen=$(allen GENESIS); l_int=$(allen INTENDED); l_i=$(allen INTENT) +agent=$(agent_of "${l_prov}") +S1=$(kv subject "${l_gen}"); S2=$(kv subject "${l_int}"); I=$(kv id "${l_i}") +d1=$(dump "${image}" "${top}/allen_head.bin") +if [[ "${d0}" =~ subject-dump:\ store=Refused$ || "${d0}" =~ identity=Unprovisioned ]] \ + && [[ "${l_prov}" =~ ^CONTINUITY:\ PROVISIONED\ agent=[0-9a-f]{64}\ incarnation=1\ sequence=1\ cortex=0\ branches=1 ]] \ + && [[ "${l_gen}" == "ALLEN: GENESIS subject=${S1} sequence=1 agent=${agent} lineage=${LINEAGE} intents=0 active=0" ]] \ + && [[ ${#S1} == 64 ]]; then + pass "G7 native genesis: blank image (${d0##*subject-dump: }) -> kernel provisioning created subject ${S1:0:16}.. sequence 1 for agent ${agent:0:16}.., lineage bound" +else bad "G7 genesis: before='${d0}' prov='${l_prov}' gen='${l_gen}'"; fi +if [[ "${l_int}" == "ALLEN: INTENDED subject=${S2} sequence=2 agent=${agent} lineage=${LINEAGE} intents=1 active=1" ]] \ + && [[ "${l_i}" == "ALLEN: INTENT id=${I} kind=1 regime=${REGIME} target_ns=${TARGET} since=2" && ${#I} == 64 && "${S2}" != "${S1}" ]]; then + pass "G7 standing intent: sequence 2 ${S2:0:16}.. holds intent ${I:0:16}.. (regime ${REGIME}, ${TARGET} ns)" +else bad "G7 intent: '${l_int}' / '${l_i}'"; fi +if [[ "$(kv genesis_objects "${d1}")" == 1 && "$(kv subject_objects "${d1}")" == 2 && "$(kv subject "${d1}")" == "${S2}" \ + && "$(kv agent "${d1}")" == "${agent}" && "$(kv lineage "${d1}")" == "${LINEAGE}" ]]; then + pass "G7 host reader: the image holds one genesis and one successor, head ${S2:0:16}.. (no host tool created them)" +else bad "G7 host reader: '${d1}'"; fi +prov_image="${top}/prov.img"; cp "${image}" "${prov_image}" +prov_sha=$(sha "${prov_image}") + +# ------------------------------------------------------- G8 exactly once +image="${top}/g8.img"; cp "${prov_image}" "${image}" +prov_plan +boot +if [[ "$(out '^CONTINUITY: ')" == "CONTINUITY: STOP (AlreadyProvisioned)" && "$(n_allen GENESIS)" == 0 ]] && unchanged; then + pass "G8 second provisioning refused: no genesis, image unchanged" +else bad "G8 second provisioning: '$(out '^CONTINUITY: ')' genesis=$(n_allen GENESIS)"; fi + +# --------------------------------------------- G9 cold restart (two restores) +image="${top}/g9.img"; cp "${prov_image}" "${image}" +plan 6 +rplan=$(plan_text) +g9_ok=1 +for k in 1 2; do + boot; q=${qemu_status} + l_r=$(allen RESTORED); l_ri=$(allen INTENT); l_c=$(out '^CONTINUITY: RESUMED ') + inc=$(( k + 1 )) + if [[ "${q}" == 0 && "${l_r}" == "ALLEN: RESTORED subject=${S2} sequence=2 agent=${agent} lineage=${LINEAGE} intents=1 active=1" \ + && "${l_ri}" == "ALLEN: INTENT id=${I} kind=1 regime=${REGIME} target_ns=${TARGET} since=2" \ + && "$(n_allen GENESIS)" == 0 && "${l_c}" =~ incarnation=${inc}\ && "$(agent_of "${l_c}")" == "${agent}" ]]; then + pass "G9 cold restart ${k}: new QEMU process (previous exited ${q}), same subject ${S2:0:16}.., same intent, same lineage, incarnation ${inc}" + else g9_ok=0; bad "G9 cold restart ${k}: q=${q} '${l_r}' / '${l_ri}' / '${l_c}'"; fi +done +d9=$(dump "${image}" "${top}/allen_head_after.bin") +if [[ "$(kv genesis_objects "${d9}")" == 1 && "$(kv subject_objects "${d9}")" == 2 && "$(kv subject "${d9}")" == "${S2}" ]] \ + && cmp -s "${top}/allen_head.bin" "${top}/allen_head_after.bin"; then + pass "G9 after two restores: still one genesis, two subject objects, head object byte-identical" +else bad "G9 after restores: '${d9}'"; fi + +# --------------------------------------------------------- G10 native path +# The restore plan names only the mode; the ESP and UEFI vars are rebuilt for +# every boot (prep); an image provisioned separately restores ITS subject. +if [[ "${rplan}" == "AIENCONT v1 mode=6" ]]; then pass "G10 restore plan carries no subject, lineage or intent ('${rplan}')"; else bad "G10 restore plan: '${rplan}'"; fi +fresh_image +prov_plan; boot +b_agent=$(agent_of "$(out '^CONTINUITY: PROVISIONED ')"); B2=$(kv subject "$(allen INTENDED)") +b_image="${top}/b.img"; cp "${image}" "${b_image}" +plan 6; boot +l_b=$(allen RESTORED) +if [[ -n "${B2}" && "${B2}" != "${S2}" && "${b_agent}" != "${agent}" && "$(kv subject "${l_b}")" == "${B2}" && "$(kv agent "${l_b}")" == "${b_agent}" ]]; then + pass "G10 a second image restores its own subject ${B2:0:16}.. (agent ${b_agent:0:16}..), not ${S2:0:16}..: the subject comes from the disk" +else bad "G10 second image: B2=${B2} restored='${l_b}'"; fi +if [[ -s "${top}/allen_head.bin" && "$(sha256sum "${top}/allen_head.bin" | cut -c1-64)" != "" ]]; then + pass "G10 host reader decoded the head object from the sealed Store on the image (${S2:0:16}..)" +else bad "G10 host reader produced no head object"; fi + +# ------------------------------------------------------------ G11 corruption +# a) a forked chain (a second genesis subject for the same agent) +image="${top}/g11a.img"; cp "${prov_image}" "${image}" +"${cont_tool}" subject-plant "${image}" 4096 fork >/dev/null || bad "G11a plant fork tool failed" +plan 6 +for k in 1 2; do + boot + if [[ "$(allen CORRUPT)" == "ALLEN: CORRUPT (subject chain fork)" && -z "$(allen RESTORED)" && "$(n_allen GENESIS)" == 0 \ + && -z "$(out '^CONTINUITY: RESUMED')" ]] && unchanged; then + pass "G11a forked chain, boot ${k}: CORRUPT, nothing restored, nothing minted, image unchanged" + else bad "G11a fork boot ${k}: '$(allen CORRUPT)' restored='$(allen RESTORED)' cont='$(out '^CONTINUITY: ')'"; fi +done +d11=$(dump "${image}") +[[ "$(kv subject_objects "${d11}")" == 3 ]] && pass "G11a image still holds exactly the planted objects (3), no replacement" || bad "G11a objects: '${d11}'" +# b) a flipped byte in a subject envelope +image="${top}/g11b.img"; cp "${prov_image}" "${image}" +"${cont_tool}" corrupt-subject "${image}" 4096 >/dev/null || bad "G11b corrupt tool failed" +plan 6; boot +l11b="$(out '^(ALLEN|CONTINUITY): ')" +if [[ -z "$(allen RESTORED)" && "$(n_allen GENESIS)" == 0 && -z "$(out '^CONTINUITY: RESUMED')" ]] && unchanged \ + && [[ "${l11b}" =~ ^(ALLEN:\ STOP|ALLEN:\ CORRUPT|CONTINUITY:\ STOP\ \(store\ Refused) ]]; then + pass "G11b corrupted subject envelope: refused ('${l11b}'), nothing restored or minted, image unchanged" +else bad "G11b envelope: '${l11b}' restored='$(allen RESTORED)'"; fi +# c) a provisioned identity without a subject (identity-only provisioning) +fresh_image; plan 5; boot +c_agent=$(agent_of "$(out '^CONTINUITY: PROVISIONED ')") +plan 6 +for k in 1 2; do + boot + if [[ "$(allen ABSENT)" == "ALLEN: ABSENT (provisioned without a subject; restore never mints one)" && "$(n_allen GENESIS)" == 0 \ + && -z "$(allen RESTORED)" && "$(agent_of "$(out '^CONTINUITY: RESUMED ')")" == "${c_agent}" ]]; then + pass "G11c missing subject, boot ${k}: ABSENT reported, none minted" + else bad "G11c missing subject boot ${k}: '$(allen 'ABSENT|RESTORED|CORRUPT|STOP')'"; fi +done +d11c=$(dump "${image}") +[[ "$(kv subject_objects "${d11c}")" == 0 ]] && pass "G11c host reader: still no subject object on the image" || bad "G11c objects: '${d11c}'" +c_image="${top}/c.img"; cp "${image}" "${c_image}" + +# ------------------------------------------------------ G12 foreign identity +# a) another installation's whole subject chain beside this one's +image="${top}/g12a.img"; cp "${prov_image}" "${image}" +"${cont_tool}" subject-plant "${image}" 4096 foreign "${b_image}" >/dev/null || bad "G12a plant tool failed" +plan 6; boot +if [[ "$(allen CORRUPT)" == "ALLEN: CORRUPT (subject object belongs to another agent)" && -z "$(allen RESTORED)" \ + && "$(n_allen GENESIS)" == 0 ]] && unchanged; then + pass "G12a foreign chain beside our own: CORRUPT (another agent), nothing restored or minted, image unchanged" +else bad "G12a: '$(allen 'CORRUPT|STOP|RESTORED')'"; fi +# b) another installation's chain on an identity that has none of its own +image="${top}/g12b.img"; cp "${c_image}" "${image}" +"${cont_tool}" subject-plant "${image}" 4096 foreign "${b_image}" >/dev/null || bad "G12b plant tool failed" +plan 6; boot +if [[ "$(allen CORRUPT)" == "ALLEN: CORRUPT (subject object belongs to another agent)" && -z "$(allen RESTORED)" \ + && "$(n_allen GENESIS)" == 0 ]] && unchanged; then + pass "G12b foreign chain on a subjectless identity: refused, never adopted, nothing minted, image unchanged" +else bad "G12b: '$(allen 'CORRUPT|STOP|RESTORED')'"; fi + +# ------------------------------------- FI power loss during the genesis write +i=0 +for cp in before_first_write after_payload_objects after_catalog after_commit_record after_first_flush \ + after_inactive_superblock after_final_flush before_anchor after_anchor; do + case "${cp}" in + after_inactive_superblock) want=either ;; + after_final_flush|before_anchor|after_anchor) want=new ;; + *) want=old ;; + esac + fresh_image + prov_plan "cp=${cp}" + boot_kill "${cp}" + seen=$(grep -c "^continuity: HALT at ${cp} " "${work}/serial.txt" || true) + plan 6; boot + l=$(out '^CONTINUITY: '); la=$(out '^ALLEN: ') + if [[ "${l}" == "CONTINUITY: UNPROVISIONED" && -z "${la}" ]]; then got=old + elif [[ "${l}" =~ ^CONTINUITY:\ RESUMED\ && "${la}" =~ ^ALLEN:\ RESTORED\ subject=[0-9a-f]{64}\ sequence=1\ agent=$(agent_of "${l}")\ lineage=${LINEAGE}\ intents=0\ active=0$ ]]; then got=new + else got=bad; fi + i=$(( i + 1 )) + if [[ "${seen}" -ge 1 && "${got}" != bad && ( "${want}" == either || "${want}" == "${got}" ) ]]; then + pass "FI.${i} SIGKILL at ${cp}: cold boot finds the ${got} state ($([[ ${got} == old ]] && echo unprovisioned, no subject || echo identity with its genesis subject))" + else bad "FI.${i} SIGKILL at ${cp}: seen=${seen} want=${want} got=${got} '${l}' / '${la}'"; fi + if [[ "${got}" == old && "${cp}" == before_first_write ]]; then + prov_plan; boot + [[ -n "$(allen GENESIS)" ]] && pass "FI.${i}b interrupted provisioning that committed nothing can be provisioned again" \ + || bad "FI.${i}b re-provision: '$(out '^(ALLEN|CONTINUITY): ')'" + fi +done + +[[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${top}/allen_head.bin" "${AIENOS_LOG_DIR}/allen_head.bin" +# Facts for the evidence receipt (one line, parsed by the receipt writer). +echo "ALLEN_FACTS agent=${agent} genesis=${S1} subject=${S2} intent=${I} lineage=${LINEAGE} regime=${REGIME} target_ns=${TARGET} prov_image_sha256=${prov_sha} head_object_sha256=$(sha "${top}/allen_head.bin")" +echo "rows ${rows_ok}/${rows}; M1 failures: ${m1_fail}" +if [[ "${cq_mode}" == mutant ]]; then + release_flag + if [[ "${fail}" == 0 ]]; then verdict SURVIVED; else verdict "KILLED (gate failed)"; fi + exit 0 +fi +[[ "${hw_ok:-1}" == 1 && "${fail}" == 0 ]] && verdict PASS || verdict FAIL +[[ "${fail}" == 0 ]] ```