diff --git a/.crumb b/.crumb index abfff00e..f1c84e0b 100644 --- a/.crumb +++ b/.crumb @@ -33,27 +33,27 @@ "purpose": "Directory docs. Purpose not yet described by a human." }, { - "digest": "a6970d12ef4c87df8acd2a54068d997082077b097a6649c323ee90f2223cad11", - "last_commit": "620210e", + "digest": "128178307620da9c5e813c4d6eb39085038d7bee25ac18ff8b0e8fcffb0ae7b7", + "last_commit": "638d78e", "name": "native", "purpose": "Directory native. Purpose not yet described by a human." }, { - "digest": "4e6fc7109351e6175133ad3577ab107daa624fe7e443793636c88844c2b1859a", - "last_commit": "88040d6", + "digest": "f4c0b7b6f51641d9b7a64cc22dc53abd288f1ef112191df2fec9450529de4922", + "last_commit": "638d78e", "name": "scripts", "purpose": "Directory scripts. Purpose not yet described by a human." } ], - "children_root": "sha256:792b3a044c117281fc57bed7cfa8676c9ceb203737788302df0df629bea19048", - "compiled_at": "2026-10-12T08:33:35Z", + "children_root": "sha256:d8c403e428cb92c21b6e55b7c85146eb3c1fb873bd28bf61808a59093c736a46", + "compiled_at": "2026-10-12T08:47:00Z", "compiler": "crumb-compile/1", - "digest": "sha256:a6769253d253679917d42121bbaa6bcc9c442787cd9adf6833e7034bb26e9ec4", + "digest": "sha256:3830cc8edbbdf466dc680a6e708799737fc22e2cca1d7709f620c3831175f378", "evidence_files": 155, "evidence_root": "sha256:d59c0cef4e7dd5172923754a95b411ca54b01f35baca4587f792f1b259f1eaf7", "files": 3085, - "generated_at_commit": "620210ed8651c274e7f13efd78d836b9d567f9f0", - "source_tree": "sha256:c9298eec57070bead0ca34b92185c545b85e7e2ed6787383076c7d757615e288" + "generated_at_commit": "638d78e94611546f909e559c035e640d06d2857f", + "source_tree": "sha256:18873dd280be1ba176274f68395f84d6589637a8f240ed2f4ab0660b01e2678c" }, "owner_lane": "", "provenance": { diff --git a/native/.crumb b/native/.crumb index 18445e11..2d79ea98 100644 --- a/native/.crumb +++ b/native/.crumb @@ -79,8 +79,8 @@ "purpose": "Directory native/disk. Purpose not yet described by a human." }, { - "digest": "61c6e04bb83cd28c92b897b7c522ae85f93b9b6ca7cb8fde9086aeebcffeef03", - "last_commit": "620210e", + "digest": "f97181d14fe839aa4d67dd8e69ab37ca6fdbbd22a1eb18aa147206719c4672fc", + "last_commit": "638d78e", "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:0bb44db0fc09a72e3d71268623bd085b03f5372e9562edb17172b2a33819ac36", - "compiled_at": "2026-10-12T08:33:35Z", + "children_root": "sha256:59306304f759d308be13771cb521c5d1c11d75367ff972b4355adc07a9c95095", + "compiled_at": "2026-10-12T08:47:00Z", "compiler": "crumb-compile/1", - "digest": "sha256:a6970d12ef4c87df8acd2a54068d997082077b097a6649c323ee90f2223cad11", + "digest": "sha256:128178307620da9c5e813c4d6eb39085038d7bee25ac18ff8b0e8fcffb0ae7b7", "evidence_files": 4, "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335", "files": 469, - "generated_at_commit": "620210ed8651c274e7f13efd78d836b9d567f9f0", - "source_tree": "sha256:c9469bb2804c83e3e990009171d747c9eb863de16a2bb3770963a7cd789a33d9" + "generated_at_commit": "638d78e94611546f909e559c035e640d06d2857f", + "source_tree": "sha256:dc3e2fe409b5acc97201a2303ea16b4bdbd9d81d72a9af6b91a36801f6b7275d" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/.crumb b/native/kernel/.crumb index 7c7eb4aa..380096d7 100644 --- a/native/kernel/.crumb +++ b/native/kernel/.crumb @@ -57,8 +57,8 @@ "purpose": "Directory native/kernel/artifact. Purpose not yet described by a human." }, { - "digest": "c1e462d1b7437cd8ac0a08236a36e8480a019d2e7329ef275604fbef47407fe3", - "last_commit": "491d2f5", + "digest": "d442b49555533f077c87c907efa0fea22b5b20ef93bb1650adcfcce4d4ce50ed", + "last_commit": "638d78e", "name": "core", "purpose": "Directory native/kernel/core. Purpose not yet described by a human." }, @@ -70,7 +70,7 @@ }, { "digest": "5641b8a18b587d5e35df3dccc6a157af5f4ea14d72713bb6fb970b903b554eb9", - "last_commit": "88040d6", + "last_commit": "9b3b71b", "name": "include", "purpose": "Directory native/kernel/include. Purpose not yet described by a human." }, @@ -81,14 +81,14 @@ "purpose": "Directory native/kernel/mm. Purpose not yet described by a human." }, { - "digest": "7d18df01ff7941ffed2ed82d18fed6ab5b635156333da8ae33d698756bf15e14", - "last_commit": "543c1fc", + "digest": "e303ca254129aec54d0055028a849d1e0b03d54a0b44c2b7f7f9d766ccf8819d", + "last_commit": "638d78e", "name": "svc", "purpose": "Directory native/kernel/svc. Purpose not yet described by a human." }, { - "digest": "cb0be2302b05819c629d9936885310c31648bd9dbca9e4a6ac3ac07b62fe55e5", - "last_commit": "88040d6", + "digest": "83457528f2132fa686bb428663db2585a32f3a731dddb30ea0c2295a28c45656", + "last_commit": "638d78e", "name": "tests", "purpose": "Directory native/kernel/tests. Purpose not yet described by a human." }, @@ -99,15 +99,15 @@ "purpose": "Directory native/kernel/tools. Purpose not yet described by a human." } ], - "children_root": "sha256:02930edad8a38a5004de63ac26b49a0f050f7865297e3fa70504e9f41b985da7", - "compiled_at": "2026-10-12T08:33:35Z", + "children_root": "sha256:a28f68361f11832ef2f17c13acca5da7f049f69e897f6a1b41641d31743a7e9c", + "compiled_at": "2026-10-12T08:47:00Z", "compiler": "crumb-compile/1", - "digest": "sha256:61c6e04bb83cd28c92b897b7c522ae85f93b9b6ca7cb8fde9086aeebcffeef03", + "digest": "sha256:f97181d14fe839aa4d67dd8e69ab37ca6fdbbd22a1eb18aa147206719c4672fc", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 305, - "generated_at_commit": "620210ed8651c274e7f13efd78d836b9d567f9f0", - "source_tree": "sha256:6390c6ef3a77b3ae0aa436bbe0b998ebd96f768c21cf407041e92d26ef3bcb0f" + "generated_at_commit": "638d78e94611546f909e559c035e640d06d2857f", + "source_tree": "sha256:f03c549ca78b54cf26590dfb6e922c3d103c05b2338c880ad1c97915df6951f9" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/GATES.md b/native/kernel/GATES.md index a533d614..d355404a 100644 --- a/native/kernel/GATES.md +++ b/native/kernel/GATES.md @@ -832,7 +832,7 @@ are this adapter's choices (UNVERIFIED against a frozen contract). (5) The reque bytes; the contract's exact digest input is not defined (UNVERIFIED). (6) The "task" is the adapter's session; the EL0 shell units hold no capability (caps=0) and the check is made by the kernel-side adapter. -## LIFECYCLE: resident production lifecycle (native v1 plan P03, P04 cut 1, P05 cut 1, P06 cuts 2-3; C-only) -> CK `LIFECYCLE` (scripts/qemu_ck_lifecycle_test.sh) +## LIFECYCLE: resident production lifecycle (native v1 plan P03, P04 cut 1, P05 cut 1, P06 cuts 2-4; C-only) -> CK `LIFECYCLE` (scripts/qemu_ck_lifecycle_test.sh) The product boundary. A `CK_SERVICE=1` image (`full-service/`, allowed with `CK_HARDWARE_STAGING`, refused with every TEST-only flag) links `core/lifecycle.c` + `core/lifecycle_fsm.c`: after every boot stage the kernel serves bounded operator requests on the serial console (states init, locked, ready, serve, quiesce, stop; verbs status, unlock, task , prompt , approve, deny, cancel, recall, evidence, help, shutdown; one 96-byte line, one 48-byte task or prompt, one 256-byte reply, one pending proposal at a time) until `shutdown`, then runs the stop order (Store closed, NVMe normal shutdown + bus master off + SMMU stream to abort, final report, reset) instead of resetting at once. The diagnostic images are unchanged (the weak `ck_lifecycle_run` is absent). The production key source still refuses (no in-kernel K_vol unwrap, P04), so the production service image comes up LOCKED. The TEST-ONLY `CK_SERVICE_TEST_KEYS=1` image (`full-service-testkeys/`, refused with `CK_HARDWARE_STAGING`) opens the Store with the TEST keys so the ready/serve/commit paths run in QEMU. Host test: `tests/test_lifecycle.c` (`make test`, 79 checks on the state machine and decoder). P06 cut 2 (rows 174-176): a service image built with `CK_INFER_LIB` keeps the model and one bounded session resident from boot to the stop order (`core/infer.c` resident mode, `CK_INFER_RESIDENT`); `prompt ` generates a bounded reply between whose steps only `cancel` is accepted, the reply becomes the pending proposal and `approve` commits it as one sealed reply object (kind 0x5231 'R1': `aienos.reply.v1`, the prompt and the reply); `recall` reads the newest approved note or reply back through the sealed Store, so a cold boot answers from the disk and never from memory. QEMU only: the model arrives over the TEST-ONLY fw_cfg channel and `CK_INFER_LIB` cannot combine with `CK_HARDWARE_STAGING`, so the hardware service image still has no inference (the MODEL.MAP boot-disk source is the hardware path, P06 next cut). QEMU qualifies nothing physical. @@ -859,3 +859,6 @@ The product boundary. A `CK_SERVICE=1` image (`full-service/`, allowed with `CK_ | 176 | evidence and stop order (boot 5): `evidence requests=5 ... approved=1 ... prompts=2 replies=1 gen_cancelled=1 gen_failed=0 recalls=0 inference=resident` (the `cancel` that stops a generation is `gen_cancelled`, not a request; `cancelled` counts dropped proposals); stop order `infer: resident close rc=0` < `infer: unloaded ... frames_free_after = frames_free_before rc=0,0` < `lifecycle: stop order store=closed nvme=released state=stop requests=7` < `stage lifecycle: ok` < final report; no panic or fault; QEMU exit 0; M1 checks. Separate verdict `AIENOS_CK_LIFECYCLE_INFER: PASS|FAIL|NOT_RUN` (NOT_RUN when the model file, cargo or the Rust target is missing; the main `AIENOS_CK_LIFECYCLE` verdict covers rows 174-176 whenever they run). Limits: QEMU only (TCG ~25 min for both boots); the hardware service image has no inference; a prompt is 48 bytes and a reply 256 bytes; generation is not pre-emptible inside a step (one prefill or token step, ~30 s under TCG); the bump allocator never frees between prompts; a second resident session per boot is not supported (one static slot) | LIFECYCLE / INFER | QEMU PASS (2026-10-12, tree ce0026e: 130 rows, AIENOS_CK_LIFECYCLE and AIENOS_CK_LIFECYCLE_INFER PASS; hardware NOT_RUN) | | 177 | P06 cut 3, canonical Omega Cortex store over the sealed Store (`third_party/omega/rx_cortex.c` at omega `362c9ab`, built freestanding by `svc/cortex_store.c`; journal = `svc/cortex_journal.c`, kind `0x434a` 'CJ' chunks of <= 16 KiB, one Cortex record = one sealed transaction, truncate only at the current length): host test `test_cortex_journal` in `svc/tests/stage_test.c`: a blank Store gets the 32-byte header as one generation; three records are three generations and `cx_verify_chain` passes; a second writable open is `CX_ERR_WRITER` while read-only opens are served; `truncate(len)` OK and `truncate(len-1)` `CX_ERR_IO`; a record above 128 KiB is refused (`CX_ERR_IO`) with memory and Store generation unchanged; a 40000-byte payload is three chunks of one transaction; reopen on the same mount and after a cold start replays all five records (40760 bytes, 8 chunks, heap peak 287 KiB); another subject count is `CX_ERR_FORMAT`; an in-memory edit is `CX_ERR_DIGEST`; a 256-byte heap makes the open `CX_ERR_NOMEM` without a write | LIFECYCLE (host, `make stage-test` and `stage-sanitize`) | PASS (host test, 2026-10-12, `CK_STAGE_HOST: PASS checks=772`, ASan + UBSan clean; kernel use of the journal is the next P06 cut; hardware NOT_RUN) | | 178 | the vendored files equal omega `362c9ab50c8ecc3012dd2e3ac20329865ba80982` (`omega.lock`, `scripts/omega_lock_check.sh`: offline sha256 always, the omega blob when reachable; an edited copy FAILs) and the adapter compiles freestanding (`make stage-free`: `CK_STAGE_FREE: PASS objects=45`, undefined symbols are ck.h services only); the `CK_SERVICE` image links `cx_open_with`, `cx_append`, `ck_cj_init`, `ck_cx_heap_init` and no `malloc`/`open`/`fsync` | LIFECYCLE (host) | PASS (host, 2026-10-12; both checks run in CI from this cut) | +| 179 | P06 cut 4, remembered facts (the N3 memory-only fact) on the test-keys boot (boot 2): `remember ` (1..48 bytes, refused LOCKED, allowed READY and SERVE, never changes the state or the pending task) opens the Cortex journal lazily (`lifecycle: cortex open records=0 chunks=1 journal_bytes=32 ... chain=ok`: one sealed header transaction) and appends one CX_CLAIM record (one sealed transaction, durable before `lifecycle: remembered id=1 t=1 store_gen=N bytes=18 text="prefer short notes"`); `facts` in the same boot lists it (`lifecycle: fact id=1 t=1 ...`, `facts records=1 shown=1 journal_bytes=192 chain=ok`: every digest re-checked by `cx_recall_id`, the chain by `cx_verify_chain`); `evidence ... remembers=1 facts=1 cortex=open records=1`; stop order closes the journal first (`lifecycle: cortex closed records=1 appends=2 ...` before the stop order line; the CK_CX_HEAP_PAGES frames are returned) | LIFECYCLE | QEMU PASS (2026-10-12 08:30-08:46Z, tree 61f4e66: 150 rows, both verdicts PASS; observed `remembered id=1 t=1 ... bytes=18`, `facts records=1 shown=1 ... chain=ok`, `cortex closed records=1 appends=2`; hardware NOT_RUN) | +| 180 | the same two verbs on the production Store (boot 3, recovery keyslot genesis, after the approved note at generation 4): journal header at generation 5 (`cortex open ... store_gen=5`), the fact at generation 6 (`remembered id=1 t=1 store_gen=6`), `facts records=1 shown=1`, evidence `requests=8 refused=1 ... last_commit_gen=4 ... remembers=1 facts=1 cortex=open records=1`, stop order `requests=9`; no `REFUSED verb=(remember|facts)` | LIFECYCLE | QEMU PASS (2026-10-12, tree 61f4e66: `cortex open records=0 chunks=1 journal_bytes=32 store_gen=5`, `remembered id=1 t=1 store_gen=6`, evidence `remembers=1 facts=1 cortex=open records=1`; hardware NOT_RUN) | +| 181 | cold production boot on the same disk (boot 4): the Store opens at generation 6, commits the boot record at 7 and the continuity resume at 8 (rows 169/172 unchanged otherwise); `facts` alone (`cortex open records=1 chunks=2 journal_bytes=192 store_gen=8 ... chain=ok`) answers `fact id=1 t=1 store_gen=6 text="prefer short notes"` from the disk; the fact is never typed in that boot (no `> remember`, no `lifecycle: remembered`); evidence `requests=6 refused=1 ... remembers=0 facts=1 cortex=open records=1`; `cortex closed records=1 appends=0` before the stop order; a disk without a journal answers `facts none cortex=none records=0` without creating one (host FSM test: 95 checks) | LIFECYCLE | QEMU PASS (2026-10-12, tree 61f4e66: `cortex open records=1 chunks=2 journal_bytes=192 store_gen=8 chain=ok`, `fact id=1 t=1 store_gen=6`, no `remember` typed, evidence `remembers=0 facts=1`, `cortex closed appends=0 reads=1`; hardware NOT_RUN) | diff --git a/native/kernel/core/.crumb b/native/kernel/core/.crumb index c5ce6ff1..4ef87e2c 100644 --- a/native/kernel/core/.crumb +++ b/native/kernel/core/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-12T08:33:35Z", + "compiled_at": "2026-10-12T08:47:00Z", "compiler": "crumb-compile/1", - "digest": "sha256:c1e462d1b7437cd8ac0a08236a36e8480a019d2e7329ef275604fbef47407fe3", + "digest": "sha256:d442b49555533f077c87c907efa0fea22b5b20ef93bb1650adcfcce4d4ce50ed", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 42, - "generated_at_commit": "620210ed8651c274e7f13efd78d836b9d567f9f0", - "source_tree": "sha256:2e404f5904fc49648af79be70201287a9a1468ad053c2e9803d4ab0a3155716f" + "generated_at_commit": "638d78e94611546f909e559c035e640d06d2857f", + "source_tree": "sha256:787dbd3bdd1de24aa7f87a795ce75b145e39c7b1a758bacddafad52fc452c7be" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/core/lifecycle.c b/native/kernel/core/lifecycle.c index 01a37c1d..9d4e1fba 100644 --- a/native/kernel/core/lifecycle.c +++ b/native/kernel/core/lifecycle.c @@ -28,14 +28,28 @@ * * Continuity (P05 cut 1): every Store open runs svc/continuity_service.c: * identity + ALLEN subject provisioned once, restored and resumed on every - * later boot; a refusal keeps the lifecycle LOCKED. `status` reports it. */ + * boot; a refusal keeps the lifecycle LOCKED. `status` reports it. + * + * Remembered facts (P06 cut 4, the N3 "memory-only fact"): `remember ` + * appends one CX_CLAIM record to the canonical Omega Cortex store whose + * journal is the sealed Store (svc/cortex_journal.c, chunks of kind 'CJ'); + * `facts` reads the journal back (every record digest and the chain + * re-verified by Omega's cx_open replay) and lists the newest facts. The + * journal opens lazily on the first of either verb (a fresh journal is + * created only by `remember`), stays open for the service lifetime and is + * closed first in the stop order. Its heap is CK_CX_HEAP_PAGES kernel frames + * handed to the Cortex bump allocator and returned at the stop order. + * Nothing in memory is authoritative: a cold boot answers `facts` from the + * disk, the fact never has to be restated. */ #include #include #include "ck.h" +#include "ck_internal.h" #include "lifecycle_fsm.h" #include "store_boot.h" #include "store_sealed.h" #include "continuity_service.h" +#include "cortex_journal.h" #if !defined(CK_SERVICE) #error "lifecycle.c is only part of a CK_SERVICE=1 image" @@ -61,9 +75,20 @@ static uint8_t g_last_id[32]; static uint64_t g_last_gen; static unsigned g_overlong, g_dropped; +/* The Cortex store over the sealed Store (P06 cuts 3 and 4). */ +#define CK_CX_SUBJECTS 2u /* subject 0: the owner (facts); 1: reserved for ALLEN */ +#define CK_CX_FACT_SUBJECT 0u +#define CK_CX_FACTS_SHOWN 16u /* `facts` lists at most the newest 16 */ +#define CK_CX_HEAP_BYTES (CK_CX_HEAP_PAGES * 4096u) +static ck_cj g_cj; +static CxStore g_cx; +static int g_cx_open; /* 1 while the journal is open */ +static uint64_t g_cx_heap_pa; /* 0: no frames held */ +static uint32_t g_cx_refused; /* remember/facts refused by the Store or Cortex */ + static void help(void) { - ck_puts("lifecycle: verbs: status unlock [<64-hex recovery secret>] task prompt approve deny cancel recall evidence help shutdown\n"); + ck_puts("lifecycle: verbs: status unlock [<64-hex recovery secret>] task prompt approve deny cancel recall remember facts evidence help shutdown\n"); } static void status(void) @@ -78,11 +103,12 @@ static void evidence(void) { ck_printf("lifecycle: evidence requests=%u refused=%u invalid=%u tasks=%u approved=%u denied=%u cancelled=%u " "overlong=%u last_commit_gen=%llu last_id=%02x%02x%02x%02x prompts=%u replies=%u gen_cancelled=%u " - "gen_failed=%u recalls=%u inference=%s\n", + "gen_failed=%u recalls=%u inference=%s remembers=%u facts=%u cortex=%s records=%llu\n", g_lc.requests, g_lc.refused, g_lc.invalid, g_lc.tasks, g_lc.approved, g_lc.denied, g_lc.cancelled, g_overlong, (unsigned long long)g_last_gen, g_last_id[0], g_last_id[1], g_last_id[2], g_last_id[3], g_lc.prompts, g_lc.replies, g_lc.gen_cancelled, g_lc.gen_failed, g_lc.recalls, - ck_infer_resident() ? "resident" : "none"); + ck_infer_resident() ? "resident" : "none", g_lc.remembers, g_lc.facts, g_cx_open ? "open" : "none", + (unsigned long long)(g_cx_open ? g_cx.n : 0)); } /* Commit the pending task as one sealed Store object. Bytes: a fixed header @@ -248,6 +274,157 @@ static void recall(void) kind == CK_LC_REPLY_KIND ? "reply" : "note", sid[0], sid[1], sid[2], sid[3], (unsigned)len, shown); } +/* Number of journal chunks ('CJ' objects) the open Store holds: 0 means no + * Cortex journal exists on this disk yet. */ +static uint32_t cortex_chunks(const ss_store *s) +{ + uint32_t k, n = 0; + for (k = 0; k < s->nclaims; k++) + if (s->ws->claims[k].c.obj.object_kind == CK_CJ_KIND) n++; + return n; +} + +/* Open the Cortex journal once per service lifetime. create: a missing + * journal is created (one sealed header transaction); else a missing journal + * answers 1 and opens nothing. 0: open. <0: refused (printed). */ +static int cortex_open(int create) +{ + ss_store *s = store_boot_store(); + if (g_cx_open) return 0; + if (!s || !ck_store_service_ready()) return -1; + if (!create && cortex_chunks(s) == 0) return 1; + if (create && !ck_cont_service_writable()) return CK_SB_E_CONTINUITY; + if (!g_cx_heap_pa) { + uint64_t pa = 0; + int rc = ck_mm_frames_alloc(CK_CX_HEAP_PAGES, &pa); + if (rc) { + ck_printf("lifecycle: cortex REFUSED heap frames=%u rc=%d\n", (unsigned)CK_CX_HEAP_PAGES, rc); + return -2; + } + g_cx_heap_pa = pa; + } + ck_cx_heap_init((void *)(uintptr_t)g_cx_heap_pa, CK_CX_HEAP_BYTES); + ck_cj_init(&g_cj, s); + int rc = cx_open_with(&g_cx, &ck_cx_journal_store, &g_cj, "cortex", CK_CX_SUBJECTS, 0); + if (rc != CX_OK) { + ck_printf("lifecycle: cortex REFUSED open rc=%d chunks=%u\n", rc, cortex_chunks(s)); + return rc; + } + g_cx_open = 1; + { + size_t used = 0, peak = 0, size = 0; + ck_cx_heap_stats(&used, &peak, &size); + ck_printf("lifecycle: cortex open records=%llu chunks=%u journal_bytes=%u store_gen=%llu heap_used_kib=%u chain=%s\n", + (unsigned long long)g_cx.n, g_cj.nchunks, (unsigned)g_cj.len, (unsigned long long)ss_generation(s), + (unsigned)(used / 1024), cx_verify_chain(&g_cx) == CX_OK ? "ok" : "FAIL"); + } + return 0; +} + +/* remember: one CX_CLAIM record about the owner subject, payload = the text + * packed into little-endian 64-bit words, tag = its byte length, t = the + * record count + 1 (monotonic across boots: the count is replayed at open), + * generation = the Store generation its transaction commits. One record is one + * sealed Store transaction: durable before `remembered` is printed. */ +static void remember(void) +{ + uint64_t pay[(CK_LC_TASK_MAX + 7) / 8]; + uint32_t nw = (uint32_t)((g_lc.fact_len + 7) / 8), i; + int rc = cortex_open(1); + if (rc == CK_SB_E_CONTINUITY || (rc == 0 && !ck_cont_service_writable())) { + g_lc.refused++; g_cx_refused++; + ck_printf("lifecycle: REFUSED verb=remember rc=%d state=%s reason=\"continuity read-only (degraded mount)\"\n", + CK_SB_E_CONTINUITY, ck_lc_state_name(g_lc.state)); + return; + } + if (rc) { + g_lc.refused++; g_cx_refused++; + ck_printf("lifecycle: REFUSED verb=remember rc=%d state=%s reason=\"cortex journal not open\"\n", rc, + ck_lc_state_name(g_lc.state)); + return; + } + for (i = 0; i < nw; i++) pay[i] = 0; + for (i = 0; i < g_lc.fact_len; i++) pay[i / 8] |= (uint64_t)(uint8_t)g_lc.fact[i] << (8 * (i % 8)); + CxHeader h; + uint64_t id = 0; + for (i = 0; i < sizeof h; i++) ((uint8_t *)&h)[i] = 0; + h.cls = CX_CLAIM; + h.kind = CX_K_CLAIM; + h.subject = CK_CX_FACT_SUBJECT; + h.t = g_cx.n + 1; + h.generation = ss_generation(store_boot_store()) + 1; /* the generation this append commits */ + h.tag = g_lc.fact_len; + rc = cx_append(&g_cx, &h, pay, nw, &id); + if (rc != CX_OK) { + g_lc.refused++; g_cx_refused++; + ck_printf("lifecycle: REFUSED verb=remember rc=%d state=%s reason=\"cortex append failed, nothing written\"\n", rc, + ck_lc_state_name(g_lc.state)); + return; + } + ck_printf("lifecycle: remembered id=%llu t=%llu store_gen=%llu bytes=%u text=\"%s\"\n", (unsigned long long)id, + (unsigned long long)h.t, (unsigned long long)ss_generation(store_boot_store()), (unsigned)g_lc.fact_len, + g_lc.fact); +} + +/* facts: the newest CK_CX_FACTS_SHOWN owner records, oldest first, each read + * back through cx_recall_id (digest re-checked) from the journal replayed at + * open; then the whole chain is verified again. */ +static void facts(void) +{ + static CxRecord r; + static char shown[CK_LC_TASK_MAX + 1]; + uint64_t id, first; + unsigned n = 0; + int rc = cortex_open(0); + if (rc == 1) { + ck_puts("lifecycle: facts none cortex=none records=0\n"); + return; + } + if (rc) { + g_lc.refused++; g_cx_refused++; + ck_printf("lifecycle: REFUSED verb=facts rc=%d state=%s reason=\"cortex journal not open\"\n", rc, + ck_lc_state_name(g_lc.state)); + return; + } + first = g_cx.n > CK_CX_FACTS_SHOWN ? g_cx.n - CK_CX_FACTS_SHOWN + 1 : 1; + for (id = first; id <= g_cx.n; id++) { + uint8_t text[CK_LC_TASK_MAX]; + size_t len, i; + if (cx_recall_id(&g_cx, id, &r) != CX_OK || !r.verified) { + ck_printf("lifecycle: fact id=%llu DIGEST_FAIL\n", (unsigned long long)id); + continue; + } + if (r.hdr.cls != CX_CLAIM || r.hdr.kind != CX_K_CLAIM || r.hdr.subject != CK_CX_FACT_SUBJECT) continue; + len = (size_t)r.hdr.tag; + if (len > sizeof text || len > (size_t)r.hdr.n * 8) len = 0; /* malformed tag: shown empty, still counted */ + for (i = 0; i < len; i++) text[i] = (uint8_t)(r.payload[i / 8] >> (8 * (i % 8))); + printable(shown, sizeof shown, text, len); + ck_printf("lifecycle: fact id=%llu t=%llu store_gen=%llu text=\"%s\"\n", (unsigned long long)id, + (unsigned long long)r.hdr.t, (unsigned long long)r.hdr.generation, shown); + n++; + } + ck_printf("lifecycle: facts records=%llu shown=%u journal_bytes=%u chain=%s\n", (unsigned long long)g_cx.n, n, + (unsigned)g_cj.len, cx_verify_chain(&g_cx) == CX_OK ? "ok" : "FAIL"); +} + +/* Stop order step 0: close the journal (nothing to flush: every append was + * already durable) and return its heap frames. */ +static void cortex_close(void) +{ + if (g_cx_open) { + size_t used = 0, peak = 0, size = 0; + ck_cx_heap_stats(&used, &peak, &size); + ck_printf("lifecycle: cortex closed records=%llu appends=%u reads=%u refused=%u heap_peak_kib=%u\n", + (unsigned long long)g_cx.n, g_cj.appends, g_cj.reads, g_cx_refused, (unsigned)(peak / 1024)); + cx_close(&g_cx); + g_cx_open = 0; + } + if (g_cx_heap_pa) { + ck_mm_frames_free(g_cx_heap_pa, CK_CX_HEAP_PAGES); + g_cx_heap_pa = 0; + } +} + static void handle_line(const char *line, size_t len) { const char *arg; @@ -289,6 +466,8 @@ static void handle_line(const char *line, size_t len) return; case CK_LC_R_GENERATE: generate(); return; case CK_LC_R_RECALL: recall(); return; + case CK_LC_R_REMEMBER: remember(); return; + case CK_LC_R_FACTS: facts(); return; case CK_LC_R_OK: break; } switch (v) { @@ -381,8 +560,10 @@ int ck_lifecycle_run(void) } } } - /* Stop order: inference session closed (frames returned), Store closed, - * then NVMe released, then the caller resets. */ + /* Stop order: Cortex journal closed (frames returned), inference session + * closed (frames returned), Store closed, then NVMe released, then the + * caller resets. */ + cortex_close(); ck_infer_resident_close(); int closed = ck_store_service_close(); ck_dev_nvme_release(); diff --git a/native/kernel/core/lifecycle_fsm.c b/native/kernel/core/lifecycle_fsm.c index a20a5706..df49137c 100644 --- a/native/kernel/core/lifecycle_fsm.c +++ b/native/kernel/core/lifecycle_fsm.c @@ -43,6 +43,10 @@ enum ck_lc_verb ck_lc_decode(const char *line, size_t len, const char **arg, siz if (*arg_len == 0 || *arg_len > CK_LC_TASK_MAX) return CK_LC_V_INVALID; return CK_LC_V_PROMPT; } + if (word_is(w, n, "remember")) { + if (*arg_len == 0 || *arg_len > CK_LC_TASK_MAX) return CK_LC_V_INVALID; + return CK_LC_V_REMEMBER; + } /* unlock carries the optional recovery secret (the binding checks its * shape and never echoes it); every other verb takes no argument. */ if (word_is(w, n, "unlock")) return CK_LC_V_UNLOCK; @@ -53,6 +57,7 @@ enum ck_lc_verb ck_lc_decode(const char *line, size_t len, const char **arg, siz if (word_is(w, n, "deny")) return CK_LC_V_DENY; if (word_is(w, n, "cancel")) return CK_LC_V_CANCEL; if (word_is(w, n, "recall")) return CK_LC_V_RECALL; + if (word_is(w, n, "facts")) return CK_LC_V_FACTS; if (word_is(w, n, "evidence")) return CK_LC_V_EVIDENCE; if (word_is(w, n, "shutdown")) return CK_LC_V_SHUTDOWN; return CK_LC_V_UNKNOWN; @@ -75,6 +80,8 @@ const char *ck_lc_verb_name(enum ck_lc_verb v) case CK_LC_V_SHUTDOWN: return "shutdown"; case CK_LC_V_PROMPT: return "prompt"; case CK_LC_V_RECALL: return "recall"; + case CK_LC_V_REMEMBER: return "remember"; + case CK_LC_V_FACTS: return "facts"; } return "?"; } @@ -170,6 +177,20 @@ enum ck_lc_result ck_lc_apply(ck_lc *lc, enum ck_lc_verb v, const char *arg, siz if (lc->state == CK_LC_LOCKED) return refuse(lc, "locked: no production Store"); lc->recalls++; return CK_LC_R_RECALL; + case CK_LC_V_REMEMBER: { + size_t i; + if (lc->state == CK_LC_LOCKED) return refuse(lc, "locked: no production Store"); + if (arg_len == 0 || arg_len > CK_LC_TASK_MAX) return refuse(lc, "fact text out of bounds"); + for (i = 0; i < arg_len; i++) lc->fact[i] = arg[i]; + lc->fact[arg_len] = 0; + lc->fact_len = arg_len; /* the pending task (if any) is untouched: remember never changes the state */ + lc->remembers++; + return CK_LC_R_REMEMBER; + } + case CK_LC_V_FACTS: + if (lc->state == CK_LC_LOCKED) return refuse(lc, "locked: no production Store"); + lc->facts++; + return CK_LC_R_FACTS; case CK_LC_V_APPROVE: if (lc->state != CK_LC_SERVE) return refuse(lc, "nothing pending"); return CK_LC_R_COMMIT; diff --git a/native/kernel/core/lifecycle_fsm.h b/native/kernel/core/lifecycle_fsm.h index ce84de00..ff1d0265 100644 --- a/native/kernel/core/lifecycle_fsm.h +++ b/native/kernel/core/lifecycle_fsm.h @@ -13,7 +13,8 @@ * QUIESCE stop order running: flush, revoke, halt * STOP nothing more is accepted * Verbs are the v1 operator surface and nothing else: status, unlock, task - * , approve, deny, cancel, evidence, help, shutdown. */ + * , approve, deny, cancel, evidence, help, shutdown, and (P06) prompt + * , recall, remember , facts. */ #ifndef AIENOS_CK_LIFECYCLE_FSM_H #define AIENOS_CK_LIFECYCLE_FSM_H @@ -37,6 +38,8 @@ enum ck_lc_verb { CK_LC_V_SHUTDOWN, CK_LC_V_PROMPT, /* native v1 P06: bounded generation from the resident model */ CK_LC_V_RECALL, /* read back the newest approved object from the Store */ + CK_LC_V_REMEMBER, /* P06 cut 4: record one owner fact in the Cortex journal (sealed Store) */ + CK_LC_V_FACTS, /* list the remembered facts read back from the journal */ }; /* Bounds: one request line, and the task text that a line may carry. */ @@ -56,6 +59,8 @@ enum ck_lc_result { CK_LC_R_STOP, /* shutdown accepted: the binding must run the stop order */ CK_LC_R_GENERATE, /* prompt accepted: the binding must generate (task holds the prompt) */ CK_LC_R_RECALL, /* recall accepted: the binding must read the newest approved object */ + CK_LC_R_REMEMBER, /* remember accepted: the binding must append the fact (task holds the text) */ + CK_LC_R_FACTS, /* facts accepted: the binding must list the journal */ }; typedef struct { @@ -68,11 +73,15 @@ typedef struct { /* counters for the evidence verb (bounded, wrap is harmless) */ uint32_t requests, refused, invalid, tasks, approved, denied, cancelled; uint32_t prompts, replies, gen_cancelled, gen_failed, recalls; + uint32_t remembers, facts; /* P06 cut 4: accepted remember / facts requests */ + char fact[CK_LC_TASK_MAX + 1]; /* text of the remember request being served, else "" */ + size_t fact_len; const char *reason; /* last refusal reason, static string */ } ck_lc; /* Decode one request line (len bytes, no terminator required). arg and arg_len - * receive the text after "task" or "prompt" (trimmed), else an empty span. */ + * receive the text after "task", "prompt" or "remember" (trimmed), else an + * empty span. */ enum ck_lc_verb ck_lc_decode(const char *line, size_t len, const char **arg, size_t *arg_len); const char *ck_lc_verb_name(enum ck_lc_verb v); const char *ck_lc_state_name(enum ck_lc_state s); diff --git a/native/kernel/svc/.crumb b/native/kernel/svc/.crumb index 99964ed4..180cd5eb 100644 --- a/native/kernel/svc/.crumb +++ b/native/kernel/svc/.crumb @@ -24,20 +24,20 @@ }, { "digest": "88c4fc1ed3ed47dc767deb9c59923934ca9b73b66aabec84a2c3e19cebdf8283", - "last_commit": "453f41e", + "last_commit": "543c1fc", "name": "tests", "purpose": "Directory native/kernel/svc/tests. Purpose not yet described by a human." } ], "children_root": "sha256:c08ae620be123d4ae06a01d1830984c81570c3c44fc528987cee2ad37c3c2ca9", - "compiled_at": "2026-10-12T07:42:03Z", + "compiled_at": "2026-10-12T08:47:00Z", "compiler": "crumb-compile/1", - "digest": "sha256:7d18df01ff7941ffed2ed82d18fed6ab5b635156333da8ae33d698756bf15e14", + "digest": "sha256:e303ca254129aec54d0055028a849d1e0b03d54a0b44c2b7f7f9d766ccf8819d", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 41, - "generated_at_commit": "453f41e7fca07a97ee52db3a125d106dfaf17ff5", - "source_tree": "sha256:f5ce71ef8038e16c2de685108d74a32c41ee82205eae65a77aa3b8301f3ada77" + "generated_at_commit": "638d78e94611546f909e559c035e640d06d2857f", + "source_tree": "sha256:38af02cb9fe0c5b69d636d71bbd312e91f5c152f0b7f422fa1ccbd77e7ff5db3" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/svc/cortex_journal.h b/native/kernel/svc/cortex_journal.h index 7447f74f..bdd73c8d 100644 --- a/native/kernel/svc/cortex_journal.h +++ b/native/kernel/svc/cortex_journal.h @@ -23,8 +23,8 @@ * SS_MAX_PLAINTEXT bytes (larger: CX_ERR_IO, nothing written), replay reads * the whole journal into the Cortex heap, the heap is a bump allocator that * frees nothing until ck_cx_heap_init is called again (sized by the caller; - * the kernel hands over CK_CX_HEAP_PAGES frames). Kernel use (the - * lifecycle's remembered facts) is the next P06 cut. */ + * the kernel hands over CK_CX_HEAP_PAGES frames). Kernel use: the + * lifecycle's `remember` and `facts` verbs (core/lifecycle.c, P06 cut 4). */ #ifndef AIENOS_CORTEX_JOURNAL_H #define AIENOS_CORTEX_JOURNAL_H diff --git a/native/kernel/tests/.crumb b/native/kernel/tests/.crumb index 188066f1..e1d97bb6 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-12T08:33:35Z", + "compiled_at": "2026-10-12T08:47:00Z", "compiler": "crumb-compile/1", - "digest": "sha256:cb0be2302b05819c629d9936885310c31648bd9dbca9e4a6ac3ac07b62fe55e5", + "digest": "sha256:83457528f2132fa686bb428663db2585a32f3a731dddb30ea0c2295a28c45656", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 150, - "generated_at_commit": "620210ed8651c274e7f13efd78d836b9d567f9f0", - "source_tree": "sha256:dfb81d431a173b2d5d4d42265351fbb8d5e57908e71f35960c60d87d705eaf81" + "generated_at_commit": "638d78e94611546f909e559c035e640d06d2857f", + "source_tree": "sha256:8483be0dfe530af053090ec861972ffd7733e43dfcad9ff1c3c30cece0c1bc4f" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/tests/test_lifecycle.c b/native/kernel/tests/test_lifecycle.c index 88fdb7dc..db550dc4 100644 --- a/native/kernel/tests/test_lifecycle.c +++ b/native/kernel/tests/test_lifecycle.c @@ -32,6 +32,10 @@ int main(void) CHECK(dec("prompt", &a, &al) == CK_LC_V_INVALID); /* prompt needs text */ CHECK(dec("recall", &a, &al) == CK_LC_V_RECALL && al == 0); CHECK(dec("recall x", &a, &al) == CK_LC_V_INVALID); /* no argument allowed */ + CHECK(dec("remember prefer short notes", &a, &al) == CK_LC_V_REMEMBER && al == 18 && memcmp(a, "prefer short notes", 18) == 0); + CHECK(dec("remember", &a, &al) == CK_LC_V_INVALID); /* remember needs text */ + CHECK(dec("facts", &a, &al) == CK_LC_V_FACTS && al == 0); + CHECK(dec("facts all", &a, &al) == CK_LC_V_INVALID); /* no argument allowed */ CHECK(dec("sta\x01tus", &a, &al) == CK_LC_V_INVALID); /* unprintable */ { char big[CK_LC_LINE_MAX + 2]; @@ -145,5 +149,30 @@ int main(void) CHECK(lc.state == CK_LC_QUIESCE && lc.reply_len == 0 && lc.task_len == 0 && lc.pending == CK_LC_PENDING_NONE); CHECK(req(&lc, "prompt q") == CK_LC_R_REFUSED && req(&lc, "recall") == CK_LC_R_REFUSED); CHECK(lc.requests == 18 && lc.prompts == 7 && lc.refused == 4 && lc.approved == 1); + + /* P06 cut 4: remember and facts. Locked: both refused, nothing counted. */ + ck_lc_init(&lc); + ck_lc_start(&lc, 0); + CHECK(req(&lc, "remember prefer short notes") == CK_LC_R_REFUSED && lc.remembers == 0 && strstr(lc.reason, "locked")); + CHECK(req(&lc, "facts") == CK_LC_R_REFUSED && lc.facts == 0 && lc.refused == 2); + /* ready: remember hands the text to the binding and never changes the + * state or the pending task; facts likewise */ + ck_lc_init(&lc); + ck_lc_start(&lc, 1); + CHECK(req(&lc, "remember prefer short notes") == CK_LC_R_REMEMBER && lc.state == CK_LC_READY && lc.remembers == 1); + CHECK(lc.fact_len == 18 && strcmp(lc.fact, "prefer short notes") == 0 && lc.task_len == 0 && lc.pending == CK_LC_PENDING_NONE); + CHECK(req(&lc, "facts") == CK_LC_R_FACTS && lc.facts == 1 && lc.state == CK_LC_READY); + CHECK(req(&lc, "task n") == CK_LC_R_OK && lc.state == CK_LC_SERVE); + CHECK(req(&lc, "remember second") == CK_LC_R_REMEMBER && lc.remembers == 2 && lc.state == CK_LC_SERVE); + CHECK(strcmp(lc.fact, "second") == 0 && lc.fact_len == 6 && strcmp(lc.task, "n") == 0 && lc.pending == CK_LC_PENDING_NOTE); + CHECK(req(&lc, "facts") == CK_LC_R_FACTS && lc.facts == 2 && lc.state == CK_LC_SERVE); + { + char big[CK_LC_LINE_MAX + 1]; + memset(big, 'f', CK_LC_LINE_MAX); big[CK_LC_LINE_MAX] = 0; + memcpy(big, "remember ", 9); + CHECK(req(&lc, big) == CK_LC_R_INVALID && lc.invalid == 1 && lc.remembers == 2); /* text 87 > 48 refused whole */ + } + CHECK(req(&lc, "shutdown") == CK_LC_R_STOP && req(&lc, "remember z") == CK_LC_R_REFUSED && req(&lc, "facts") == CK_LC_R_REFUSED); + CHECK(lc.requests == 9 && lc.remembers == 2 && lc.facts == 2 && lc.refused == 2 && lc.invalid == 1); return ck_t_verdict("CK_LIFECYCLE"); } diff --git a/scripts/.crumb b/scripts/.crumb index dd5cd14f..16185149 100644 --- a/scripts/.crumb +++ b/scripts/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-12T08:33:35Z", + "compiled_at": "2026-10-12T08:47:00Z", "compiler": "crumb-compile/1", - "digest": "sha256:4e6fc7109351e6175133ad3577ab107daa624fe7e443793636c88844c2b1859a", + "digest": "sha256:f4c0b7b6f51641d9b7a64cc22dc53abd288f1ef112191df2fec9450529de4922", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 83, - "generated_at_commit": "620210ed8651c274e7f13efd78d836b9d567f9f0", - "source_tree": "sha256:e216f80c2123f9abc3c15fef6c960caac89011b534a1d8d10aecb53f1aca0132" + "generated_at_commit": "638d78e94611546f909e559c035e640d06d2857f", + "source_tree": "sha256:4b5456a28ff42ec4d9fdf8b1526319f21f82bdbb7f608364ed4f6ed4d87d00e7" }, "owner_lane": "", "provenance": { diff --git a/scripts/qemu_ck_lifecycle_test.sh b/scripts/qemu_ck_lifecycle_test.sh index fe40d209..992ee562 100755 --- a/scripts/qemu_ck_lifecycle_test.sh +++ b/scripts/qemu_ck_lifecycle_test.sh @@ -80,6 +80,17 @@ # QEMU exit 0; M1 checks. Separate verdict AIENOS_CK_LIFECYCLE_INFER: # NOT_RUN (never a silent pass) when the model file, cargo or the Rust # target aarch64-unknown-none is missing; TCG needs ~25 min for it +# row 179 P06 cut 4 (test-keys boot 2): `remember prefer short notes` creates +# the Cortex journal (one sealed header transaction) and appends one +# CX_CLAIM record (one sealed transaction); `facts` in the same boot +# lists it with the chain verified; evidence counts remembers/facts; +# the journal closes (heap frames returned) before the stop order +# row 180 production genesis boot (boot 3): the same two verbs on the +# production Store after the approved note; stop order requests=9 +# row 181 cold production boot (boot 4): `facts` alone answers the fact from +# the disk (records=1, digest and chain re-verified at open); the fact +# is never typed in that boot; the Store opens at generation 6 (journal open at 8: +# note 4, journal header 5, fact 6, boot record 7, continuity resume 8) # build the default (diagnostic) image carries no lifecycle; CK_SERVICE is # refused with CK_CONSOLE_SESSION, CK_QEMU_UNSAFE_DMA and a CK_TEST_* # flag; CK_SERVICE_TEST_KEYS is refused with CK_HARDWARE_STAGING @@ -200,6 +211,8 @@ drive_ready() { ser_line "task to be denied"; ser_line deny ser_line "task to be cancelled"; ser_line cancel ser_line "$(printf 'x%.0s' $(seq 97))" + ser_line "remember prefer short notes"; ser_wait '^lifecycle: (remembered|REFUSED verb=remember)' + ser_line facts; ser_wait '^lifecycle: (facts records=|facts none|REFUSED verb=facts)' ser_line evidence ser_line shutdown } @@ -209,6 +222,8 @@ drive_unlock() { ser_line "unlock ${secret_ok}"; ser_wait '^(lifecycle: unlock ok|lifecycle: REFUSED verb=unlock)' ser_line status ser_line "task write a note"; ser_line approve; ser_wait '^lifecycle: (approve committed|REFUSED verb=approve)' + ser_line "remember prefer short notes"; ser_wait '^lifecycle: (remembered|REFUSED verb=remember)' + ser_line facts; ser_wait '^lifecycle: (facts records=|facts none|REFUSED verb=facts)' ser_line evidence ser_line shutdown } @@ -236,6 +251,7 @@ drive_relock() { ser_line status ser_line "unlock ${secret_ok}"; ser_wait '^(lifecycle: unlock ok|lifecycle: REFUSED verb=unlock)' ser_line status + ser_line facts; ser_wait '^lifecycle: (facts records=|facts none|REFUSED verb=facts)' ser_line evidence ser_line shutdown } @@ -268,7 +284,7 @@ rcheck 161 "task refused while locked" '^lifecycle: REFUSED verb=task state=lock rcheck 161 "unlock refused, still locked" '^lifecycle: REFUSED verb=unlock state=locked reason="production key source refused: still locked"' rcheck 161 "unlock asked the production key source again" '^store: unlock REFUSED proof=keyed step="production Store key source" rc=-2002' rcheck 161 "status answered" '^lifecycle: state=locked store=locked pending=- requests=' -rcheck 161 "help answered" '^lifecycle: verbs: status unlock \[<64-hex recovery secret>\] task prompt approve deny cancel recall evidence help shutdown$' +rcheck 161 "help answered" '^lifecycle: verbs: status unlock \[<64-hex recovery secret>\] task prompt approve deny cancel recall remember facts evidence help shutdown$' rcheck 161 "evidence answered" '^lifecycle: evidence requests=5 refused=2 invalid=0 tasks=0 approved=0' rcheck 162 "stop order with no Store" '^lifecycle: stop order store=was-locked nvme=released state=stop requests=6$' before 162 "locked lifecycle ready < NVMe revoke (revoke only at the stop order)" '^lifecycle: ready state=locked' '^dma_gate: nvme bus master revoked' @@ -295,8 +311,15 @@ rcheck 165 "approve with nothing pending refused" '^lifecycle: REFUSED verb=appr rcheck 165 "deny drops" '^lifecycle: denied state=ready$' rcheck 165 "cancel drops" '^lifecycle: cancelled state=ready$' rcheck 166 "overlong line refused whole" '^lifecycle: REFUSED verb=invalid reason="line longer than 96 bytes"$' -rcheck 166 "evidence counts" '^lifecycle: evidence requests=10 refused=2 invalid=0 tasks=3 approved=1 denied=1 cancelled=1 overlong=1 last_commit_gen=[0-9]+ last_id=[0-9a-f]{8} prompts=0 replies=0 gen_cancelled=0 gen_failed=0 recalls=0 inference=none$' -rcheck 167 "stop order closed the Store" '^lifecycle: stop order store=closed nvme=released state=stop requests=11$' +rcheck 166 "evidence counts" '^lifecycle: evidence requests=12 refused=2 invalid=0 tasks=3 approved=1 denied=1 cancelled=1 overlong=1 last_commit_gen=[0-9]+ last_id=[0-9a-f]{8} prompts=0 replies=0 gen_cancelled=0 gen_failed=0 recalls=0 inference=none remembers=1 facts=1 cortex=open records=1$' +rcheck 167 "stop order closed the Store" '^lifecycle: stop order store=closed nvme=released state=stop requests=13$' +rcheck 179 "remember created the journal (header transaction, no records yet)" '^lifecycle: cortex open records=0 chunks=1 journal_bytes=32 store_gen=[0-9]+ heap_used_kib=[0-9]+ chain=ok$' +rcheck 179 "remembered as record 1 (one sealed transaction)" '^lifecycle: remembered id=1 t=1 store_gen=[0-9]+ bytes=18 text="prefer short notes"$' +rcheck 179 "facts lists the fact in the same boot" '^lifecycle: fact id=1 t=1 store_gen=[0-9]+ text="prefer short notes"$' +rcheck 179 "facts summary, chain verified" '^lifecycle: facts records=1 shown=1 journal_bytes=192 chain=ok$' +rcheck 179 "journal closed first in the stop order" '^lifecycle: cortex closed records=1 appends=2 reads=[0-9]+ refused=0 heap_peak_kib=[0-9]+$' +before 179 "cortex closed < stop order line" '^lifecycle: cortex closed' '^lifecycle: stop order store=closed' +rabsent 179 "no refusal of remember or facts" '^lifecycle: REFUSED verb=(remember|facts)' before 167 "lifecycle ready < NVMe revoke (revoke only at the stop order)" '^lifecycle: ready state=ready' '^dma_gate: nvme bus master revoked' before 167 "NVMe revoke < stop order line" '^dma_gate: nvme bus master revoked' '^lifecycle: stop order store=closed' before 167 "stop order < stage result" '^lifecycle: stop order store=closed' '^stage lifecycle: ok rc=0$' @@ -325,7 +348,12 @@ before 171 "PROVISIONED < lifecycle unlock ok" '^continuity: PROVISIONED' '^life rcheck 171 "status reports continuity" '^lifecycle: state=ready store=open pending=- requests=[0-9]+ continuity=provisioned agent=[0-9a-f]{16} incarnation=1 subject_seq=1$' unlock_agent="$(grep -oE '^continuity: PROVISIONED agent=[0-9a-f]{64}' "${top}/unlock/serial.txt" | head -1 | sed 's/.*agent=//')" [[ -n "${unlock_agent}" ]] || unlock_agent="NO_AGENT" -rcheck 168 "stop order closed the Store" '^lifecycle: stop order store=closed nvme=released state=stop requests=7$' +rcheck 168 "stop order closed the Store" '^lifecycle: stop order store=closed nvme=released state=stop requests=9$' +rcheck 180 "production Store: journal created after the note (header at generation 5)" '^lifecycle: cortex open records=0 chunks=1 journal_bytes=32 store_gen=5 heap_used_kib=[0-9]+ chain=ok$' +rcheck 180 "production Store: fact committed at generation 6" '^lifecycle: remembered id=1 t=1 store_gen=6 bytes=18 text="prefer short notes"$' +rcheck 180 "production Store: facts lists it" '^lifecycle: facts records=1 shown=1 journal_bytes=192 chain=ok$' +rcheck 180 "evidence counts the two verbs" '^lifecycle: evidence requests=8 refused=1 invalid=0 tasks=1 approved=1 denied=0 cancelled=0 overlong=0 last_commit_gen=4 last_id=[0-9a-f]{8} prompts=0 replies=0 gen_cancelled=0 gen_failed=0 recalls=0 inference=none remembers=1 facts=1 cortex=open records=1$' +rabsent 180 "no refusal of remember or facts" '^lifecycle: REFUSED verb=(remember|facts)' before 168 "stop order < stage result" '^lifecycle: stop order store=closed' '^stage lifecycle: ok rc=0$' rabsent 168 "no panic or fault" '^report_kind: (panic|fault)' if [[ "${qemu_status}" == 0 ]]; then ok 168 "QEMU exit 0"; else bad 168 "QEMU exit ${qemu_status}"; fi @@ -343,9 +371,9 @@ rcheck 169 "lifecycle still locked after the wrong secret" '^lifecycle: REFUSED rcheck 169 "status still locked" '^lifecycle: state=locked store=locked pending=- requests=2 continuity=none$' rabsent 169 "not reformatted" '^store: blank disk' rcheck 169 "key source line: recovery keyslot resume" '^store: key source=recovery-keyslot genesis=0 ' -rcheck 169 "store opened at generation 4 (keyslot + boot record + continuity genesis + note), boot_count 1" '^store: opened generation=4 boot_count=1 prev_commit=[0-9a-f]+ anchor=valid-resume$' -rcheck 169 "store committed generation 5 boot 2" '^store: committed generation=5 boot_count=2$' -rcheck 169 "unlock ok, no genesis" '^store: unlock ok source=recovery-keyslot slot=1 genesis=0 generation=5 boot_count=2$' +rcheck 169 "store opened at generation 6 (keyslot + boot record + continuity genesis + note + journal header + fact), boot_count 1" '^store: opened generation=6 boot_count=1 prev_commit=[0-9a-f]+ anchor=valid-resume$' +rcheck 169 "store committed generation 7 boot 2" '^store: committed generation=7 boot_count=2$' +rcheck 169 "unlock ok, no genesis" '^store: unlock ok source=recovery-keyslot slot=1 genesis=0 generation=7 boot_count=2$' rcheck 172 "ALLEN subject RESTORED sequence 1" '^allen: RESTORED subject=[0-9a-f]{64} sequence=1 lineage=[0-9a-f]{64} intents=0 active=0 knowledge=0$' rcheck 172 "identity RESUMED incarnation 2, same agent as the genesis boot" "^continuity: RESUMED agent=${unlock_agent} incarnation=2 sequence=2 cortex=0 branches=1\$" rabsent 172 "no second genesis" '^continuity: (PROVISIONED|genesis)' @@ -354,8 +382,16 @@ before 172 "unlock ok < RESUMED" '^store: unlock ok' '^continuity: RESUMED' before 172 "RESUMED < lifecycle unlock ok" '^continuity: RESUMED' '^lifecycle: unlock ok' rcheck 172 "status reports resumed" "^lifecycle: state=ready store=open pending=- requests=[0-9]+ continuity=resumed agent=${unlock_agent:0:16} incarnation=2 subject_seq=1\$" rcheck 169 "lifecycle unlocked to ready" '^lifecycle: unlock ok state=ready$' -rcheck 169 "evidence: one refused unlock" '^lifecycle: evidence requests=5 refused=1 invalid=0 tasks=0 approved=0' -rcheck 169 "stop order closed the Store" '^lifecycle: stop order store=closed nvme=released state=stop requests=6$' +rcheck 169 "evidence: one refused unlock" '^lifecycle: evidence requests=6 refused=1 invalid=0 tasks=0 approved=0' +rcheck 169 "stop order closed the Store" '^lifecycle: stop order store=closed nvme=released state=stop requests=7$' +rcheck 181 "cold boot: journal opened from the disk, chain verified (1 record, 2 chunks)" '^lifecycle: cortex open records=1 chunks=2 journal_bytes=192 store_gen=8 heap_used_kib=[0-9]+ chain=ok$' +rcheck 181 "cold boot: the fact answers from the disk, not restated" '^lifecycle: fact id=1 t=1 store_gen=6 text="prefer short notes"$' +rcheck 181 "cold boot: facts summary" '^lifecycle: facts records=1 shown=1 journal_bytes=192 chain=ok$' +rabsent 181 "cold boot: the fact was never typed in this boot" '^> remember ' +rabsent 181 "cold boot: nothing remembered in this boot" '^lifecycle: remembered ' +rcheck 181 "cold boot: evidence shows facts only" '^lifecycle: evidence requests=6 refused=1 invalid=0 tasks=0 approved=0 denied=0 cancelled=0 overlong=0 last_commit_gen=0 last_id=00000000 prompts=0 replies=0 gen_cancelled=0 gen_failed=0 recalls=0 inference=none remembers=0 facts=1 cortex=open records=1$' +rcheck 181 "cold boot: journal closed before the stop order" '^lifecycle: cortex closed records=1 appends=0 reads=[0-9]+ refused=0 heap_peak_kib=[0-9]+$' +before 181 "cold boot: cortex closed < stop order" '^lifecycle: cortex closed' '^lifecycle: stop order store=closed' rabsent 169 "no panic or fault" '^report_kind: (panic|fault)' if [[ "${qemu_status}" == 0 ]]; then ok 169 "QEMU exit 0"; else bad 169 "QEMU exit ${qemu_status}"; fi m1 169 @@ -406,7 +442,7 @@ else rabsent 175 "the cancel was not refused" '^lifecycle: REFUSED verb=cancel' rabsent 175 "no prompt refused" '^lifecycle: REFUSED verb=prompt' rcheck 175 "recall (same boot) reads the reply back through the sealed Store" "${re_recall}" - rcheck 176 "evidence counters" '^lifecycle: evidence requests=5 refused=0 invalid=0 tasks=0 approved=1 denied=0 cancelled=0 overlong=0 last_commit_gen=[0-9]+ last_id=[0-9a-f]{8} prompts=2 replies=1 gen_cancelled=1 gen_failed=0 recalls=0 inference=resident$' + rcheck 176 "evidence counters" '^lifecycle: evidence requests=5 refused=0 invalid=0 tasks=0 approved=1 denied=0 cancelled=0 overlong=0 last_commit_gen=[0-9]+ last_id=[0-9a-f]{8} prompts=2 replies=1 gen_cancelled=1 gen_failed=0 recalls=0 inference=resident remembers=0 facts=0 cortex=none records=0$' rcheck 176 "resident close" '^infer: resident close rc=0 heap_used_kib=[0-9]+ heap_peak_kib=[0-9]+$' frames_kept 176 "unload returned every frame" before 176 "resident close < unload line" '^infer: resident close rc=0' '^infer: unloaded ' @@ -426,7 +462,7 @@ else rcheck 175 "cold boot: continuity RESUMED on the same disk" '^continuity: RESUMED agent=[0-9a-f]{64} incarnation=2 ' rabsent 175 "cold boot: no second genesis" '^continuity: PROVISIONED' rcheck 175 "cold boot: recall returns the approved reply from the disk" "${re_recall}" - rcheck 175 "cold boot: evidence shows one recall, no prompt" '^lifecycle: evidence requests=3 refused=0 invalid=0 tasks=0 approved=0 denied=0 cancelled=0 overlong=0 last_commit_gen=0 last_id=00000000 prompts=0 replies=0 gen_cancelled=0 gen_failed=0 recalls=1 inference=resident$' + rcheck 175 "cold boot: evidence shows one recall, no prompt" '^lifecycle: evidence requests=3 refused=0 invalid=0 tasks=0 approved=0 denied=0 cancelled=0 overlong=0 last_commit_gen=0 last_id=00000000 prompts=0 replies=0 gen_cancelled=0 gen_failed=0 recalls=1 inference=resident remembers=0 facts=0 cortex=none records=0$' frames_kept 175 "cold boot: unload returned every frame" rcheck 175 "cold boot: stop order closed the Store" '^lifecycle: stop order store=closed nvme=released state=stop requests=4$' rabsent 175 "cold boot: no panic or fault" '^report_kind: (panic|fault)'