Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
About Files History Releases Proposed changes Issues For developers
desk block: 9 PRs (#391, #395, #412, #416, #423, #426, #433, #434...)
closed b2f4c89f30a3e5f3 #440 · opened 2026-10-20 20:52 UTC · closed 2026-10-30 03:02 UTC
Imported from GitHub aien-dev/aienux#440, by drakestapleton
Base 18e276590424593647cd7c39c6d16c2f9f8d6027 · Head 77e346e636b875ff02957a51a11fb22c5a1a2ade
drakestapleton wrote on 2026-10-20 20:52 UTC
Desk block built by renda-harness: one judge run for 9 pull requests instead of 9 (Drake 2026-10-20: do the shared work once, in blocks).
When this merges, each carried PR is closed with a link here. If the judge fails, the block is split and retried in halves; nothing is waived.
Carries #391 (test/osc-launch-rehash-383@8bee122c ): test(osc): verify changed executable bytes are refused at launch
Carries #395 (pipeline/gate-inputs@3efa1f71 ): tests/gates: inputs cover every file each gate reads
Carries #412 (fix/410-imac-report-opt-in@f46e218e ): iMac: network report is opt-in lab-only, allowlisted, labelled unauthenticated (fixes #410)
Carries #416 (docs/readme-refresh-2026-10-18@e9ba0e1c ): docs: ADR index lists ADR 0017; links and dashes (2026-10-18)
Carries #423 (feat/85-audio-output@03f33e84 ): C kernel can recognise a USB speaker and prepare sound for it (audio.output step 1, #85)
Carries #426 (fix/409-x86-wx@7aa0a37a ): iMac kernel refuses to run data or rewrite its own code
Carries #433 (feat/native-pipe-1@f8700d4c ): feat(kernel): native bounded byte pipe primitive (AIENOS-NATIVE-PIPE-1, #428)
Carries #434 (crumb/on-demand-migration@49e6f6a3 ): crumb: stop committing generated crumb data (RFC-0003 amendment 1 migration)
Carries #438 (fix/timer-window-starvation@54fe5b96 ): ck: timer window no longer fails M1 on a starved QEMU vCPU (AIENOS-CK-QEMU-GATES flake on #434)
Not carried (left for their own path):
#392: conflicts with main or another PR in the block: .crumb, .github/workflows/ck-kernel.yml, native/.crumb, native/kernel/.crumb, native/kernel/core/.crumb, scripts/.crumb
#397: conflicts with main or another PR in the block: .crumb, .github/workflows/aien-verification.yml
#439: conflicts with main or another PR in the block: .crumb, crates/.crumb, crates/aienos-artifact-tool/.crumb, docs/.crumb, docs/adr/.crumb, docs/adr/README.md
drakestapleton wrote on 2026-10-24 06:42 UTC
Merge-desk dependency audit: #416 is already merged as a9055204ca55336e3937f2952d0ebbb3ad067c6c ; this aggregate still names it and carries older component heads. Rebuild the existing #440 integration against current main f45d00ade01c64a532e8ef6b8e38fabeed95ebe0 using the current #391/#395/#412/#423/#426/#433/#434/#438 scope, preserving original acceptance requirements and unresolved source-review findings.
For the iMac chain, #413 closed without merging. #426 is the current W^X replacement; reconcile that prerequisite before #414 -> #415 -> #418 -> #421 -> #424, with #420 as a sibling on #418. A closed PR is not evidence that its dependency landed.
Existing implementation owners retain their work. ChatGPT now coordinates integration order under aien-dev/aien-architecture-mv#190. This is routing, not aggregate merge approval or hardware qualification.
Fetch it
A git bundle of the pull request's head, 156804 bytes.
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/b2f4c89f30a3e5f3 .bundle -o b2f4c89f30a3e5f3 .bundle
git fetch b2f4c89f30a3e5f3 .bundle refs/pull/440/head
Raw bundle · 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
440
77e346e636b875ff02957a51a11fb22c5a1a2ade
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":440,"url":"https://github.com/aien-dev/aienux/pull/440","export_sha256":"222ed873664c8b6770fec92487a3521a4b5f81629ee6399038e519facf854bee ","imported_utc":"2026-11-18T16:35:38Z"}
Changes
diff --git a/.crumb b/.crumb
index b35a3b6e ..fcc6e0c2 100644
--- a/.crumb
+++ b/.crumb
@@ -18,43 +18,7 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "b5ced6fea583b485206b73ec08b91de68a5cfd2672ac448191831754c9e0907d ",
- "last_commit": "7db773a ",
- "name": "crates",
- "purpose": "Directory crates. Purpose not yet described by a human."
- },
- {
- "digest": "2f740ef54106c2b6419bfd2df1266762cd444f439c7e12ae2a7c5c3877de926c ",
- "last_commit": "4bd49ca ",
- "name": "docs",
- "purpose": "Directory docs. Purpose not yet described by a human."
- },
- {
- "digest": "64cc87f8507bb580e1788d335c5a76039f3e3a016552595526718448ab5aa098 ",
- "last_commit": "3037967 ",
- "name": "native",
- "purpose": "Directory native. Purpose not yet described by a human."
- },
- {
- "digest": "28cf2363c4d527a9d7ecc2974f3dcda3e065959cbddaed7863d9c9354f166967 ",
- "last_commit": "00d7759 ",
- "name": "scripts",
- "purpose": "Directory scripts. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:9dce6ec60d33531c951ea265c84962b9a7e5ca0199cd76e63ba01585a7c01928 ",
- "compiled_at": "2026-10-19T15:08:12Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:ea1028946ad65a777ed93ea1a58dee8a194f58035dbf961f631a313b044ee868 ",
- "evidence_files": 211,
- "evidence_root": "sha256:3a8f56415109a697e4beb6048c85805c50c9c6c4089629057f4e8b3e76863981 ",
- "files": 3491,
- "generated_at_commit": "00d77597386501631f08ac78ea5c0c3a0795348f ",
- "source_tree": "sha256:68db139dcb9eaed72ca1bd7795960ebd933df55d7f3f5b9d3495639071aba901 "
- },
+ "generated_policy": "on-demand",
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/.github/workflows/aien-verification.yml b/.github/workflows/aien-verification.yml
index 54770fcc ..6d6b4eb9 100644
--- a/.github/workflows/aien-verification.yml
+++ b/.github/workflows/aien-verification.yml
@@ -83,11 +83,11 @@ jobs:
echo "blocked=false" >> "$GITHUB_OUTPUT"
fi
- - name: Checkout the pinned crumb tool source (aien-architecture @ d0f0b95d344b4c6628c3d868346932fd247ce168 )
+ - name: Checkout the pinned crumb tool source (aien-architecture @ 12ad0141b41ec67ef5aa51cb4e1815894c1083bb )
uses: actions/checkout@v4
with:
repository: aien-spark/aien-architecture
- ref: d0f0b95d344b4c6628c3d868346932fd247ce168
+ ref: 12ad0141b41ec67ef5aa51cb4e1815894c1083bb
path: .crumb-tool-src
- name: Build the crumb tool, then remove its source from this tree
diff --git a/crates/.crumb b/crates/.crumb
index 6f56e027 ..9f358a9c 100644
--- a/crates/.crumb
+++ b/crates/.crumb
@@ -62,103 +62,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "0a8510e7fedafbf6b5d1ea15307da3a1eb6e8d6bd6ffa7caabf193fabaa464b5 ",
- "last_commit": "3e71759 ",
- "name": "aienos-accel",
- "purpose": "Directory crates/aienos-accel. Purpose not yet described by a human."
- },
- {
- "digest": "68682a56017aef2e95b4101731a5bc023e0d297127e6b07af7d3be9f3d8afaeb ",
- "last_commit": "15d5f3d ",
- "name": "aienos-aegis",
- "purpose": "Directory crates/aienos-aegis. Purpose not yet described by a human."
- },
- {
- "digest": "d5ad195a8f38c6bd0e1cc00feb8c5040f0fc8eabe47a9a69d961c73d6901d61e ",
- "last_commit": "39e246a ",
- "name": "aienos-agent-state",
- "purpose": "Directory crates/aienos-agent-state. Purpose not yet described by a human."
- },
- {
- "digest": "ffb6a9a637e1eca1408280c4522ea52b283d740a90b8efad30350082900cbcdc ",
- "last_commit": "e12e6f6 ",
- "name": "aienos-artifact",
- "purpose": "Directory crates/aienos-artifact. Purpose not yet described by a human."
- },
- {
- "digest": "ff4260f8fede1182f834d89589eb4d5a6c6160032dfc570003d506411fe93aa4 ",
- "last_commit": "e9d39a9 ",
- "name": "aienos-artifact-tool",
- "purpose": "Directory crates/aienos-artifact-tool. Purpose not yet described by a human."
- },
- {
- "digest": "223e3399133c766986b1044a16c8367b51b78158d3070c0ec63c7ed3e639d644 ",
- "last_commit": "49ff776 ",
- "name": "aienos-boot",
- "purpose": "Directory crates/aienos-boot. Purpose not yet described by a human."
- },
- {
- "digest": "01d4fe4a0bd556f338ac4615b7ed1c9141e4f8035c07e0082f2894a57fa071d0 ",
- "last_commit": "bc25e73 ",
- "name": "aienos-c1-tree",
- "purpose": "Directory crates/aienos-c1-tree. Purpose not yet described by a human."
- },
- {
- "digest": "ca15c2b9ae570b0aa2c7859672de2c976d6ce046188c09b7c74b5ccbee350136 ",
- "last_commit": "51c05da ",
- "name": "aienos-capability",
- "purpose": "Directory crates/aienos-capability. Purpose not yet described by a human."
- },
- {
- "digest": "c63ab3d5643ac3c0974eee276273a0ab80584c54926cbb62c637294b5b857718 ",
- "last_commit": "51c05da ",
- "name": "aienos-capability-ffi",
- "purpose": "Directory crates/aienos-capability-ffi. Purpose not yet described by a human."
- },
- {
- "digest": "f062e2e58faa2950ce8adeb2e4c16234dacce6672d560ed4fdeb7224c5093a77 ",
- "last_commit": "bc25e73 ",
- "name": "aienos-cortex",
- "purpose": "Directory crates/aienos-cortex. Purpose not yet described by a human."
- },
- {
- "digest": "feccaaf349b9e88bc116db18951ffbd0145176b40ce702bc6320338c35b2e85e ",
- "last_commit": "f0facc7 ",
- "name": "aienos-crypto",
- "purpose": "Directory crates/aienos-crypto. Purpose not yet described by a human."
- },
- {
- "digest": "e88324eb9a32d23d8358413c7404038ee4095fcf8c4889ac9c221b97aef80b8e ",
- "last_commit": "e960272 ",
- "name": "aienos-evidence",
- "purpose": "Directory crates/aienos-evidence. Purpose not yet described by a human."
- },
- {
- "digest": "a0d0036c90e3d64d6e1caa67b77bf2b8deb898c597e9f0b797df4a144468e061 ",
- "last_commit": "2951ea1 ",
- "name": "aienos-kernel",
- "purpose": "Directory crates/aienos-kernel. Purpose not yet described by a human."
- },
- {
- "digest": "716d679da128e7aab8efb6e9cf836ee22a62fe9fe6993e2d0a20c3016d78b3a0 ",
- "last_commit": "761e63d ",
- "name": "aienos-store-tool",
- "purpose": "Directory crates/aienos-store-tool. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:ca16d018c0c02840ba1f87e2a7b64ed259a36253ed29230f274ebcabb43c8a7e ",
- "compiled_at": "2026-10-14T14:58:51Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:b5ced6fea583b485206b73ec08b91de68a5cfd2672ac448191831754c9e0907d ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 268,
- "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84 ",
- "source_tree": "sha256:cc0bfe148dc436da2bb46428408257fbc55e5643cf516241a3e9021656c5fc2c "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-accel/.crumb b/crates/aienos-accel/.crumb
index 7d1daf82 ..6f67bcf0 100644
--- a/crates/aienos-accel/.crumb
+++ b/crates/aienos-accel/.crumb
@@ -14,31 +14,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "6b70f66e4d236c180f8cd0dc9d5cd6c5d541938032b782c8f8525e809ec317a3 ",
- "last_commit": "3e71759 ",
- "name": "src",
- "purpose": "Directory crates/aienos-accel/src. Purpose not yet described by a human."
- },
- {
- "digest": "f3d113cfcfbdea76e735ccb0543a6007b9e079c4eabc34dcc2bf64c6d9e550a6 ",
- "last_commit": "3e71759 ",
- "name": "tests",
- "purpose": "Directory crates/aienos-accel/tests. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:f4367a3dee18b6a295d8e251a7f087e15038dd61899025c62b614c2f0303cebe ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:0a8510e7fedafbf6b5d1ea15307da3a1eb6e8d6bd6ffa7caabf193fabaa464b5 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 6,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:448f9760aea980ca3e70325123b5475c23b25e2424a772c6173653153850e95d "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-accel/src/.crumb b/crates/aienos-accel/src/.crumb
index 4f85cda3 ..080ef08d 100644
--- a/crates/aienos-accel/src/.crumb
+++ b/crates/aienos-accel/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:6b70f66e4d236c180f8cd0dc9d5cd6c5d541938032b782c8f8525e809ec317a3 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 4,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:0d2c946ed95261cbf0accb56bb2a7d378a41ffbcef9834998a79b11eb55e7411 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-accel/tests/.crumb b/crates/aienos-accel/tests/.crumb
index ee6f5f0a ..0169a077 100644
--- a/crates/aienos-accel/tests/.crumb
+++ b/crates/aienos-accel/tests/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:f3d113cfcfbdea76e735ccb0543a6007b9e079c4eabc34dcc2bf64c6d9e550a6 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 1,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:caaeed577657c655780a497e0206dc7a5e4fb7828123e0e8156a07615d4ac924 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-aegis/.crumb b/crates/aienos-aegis/.crumb
index 1cd5803e ..af851d3b 100644
--- a/crates/aienos-aegis/.crumb
+++ b/crates/aienos-aegis/.crumb
@@ -14,31 +14,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "81c04634d08cd2e965d3a6a66fbb586bcb221ca33c71d60049257da9271059d0 ",
- "last_commit": "15d5f3d ",
- "name": "src",
- "purpose": "Directory crates/aienos-aegis/src. Purpose not yet described by a human."
- },
- {
- "digest": "116b4a84f2a0b3f537433c1187e35f911f0c0dedea3b489607ac0132fdde9542 ",
- "last_commit": "15d5f3d ",
- "name": "tests",
- "purpose": "Directory crates/aienos-aegis/tests. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:5a5cd518112edc332b4816792d79b64de08bf002b02784b720a6076c467fa974 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:68682a56017aef2e95b4101731a5bc023e0d297127e6b07af7d3be9f3d8afaeb ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 8,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:477b338366a9f9335fbc3da1b9469fcd79fc01ad53c023595e025fcb5c508cc2 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-aegis/src/.crumb b/crates/aienos-aegis/src/.crumb
index 98016e37 ..c903f67e 100644
--- a/crates/aienos-aegis/src/.crumb
+++ b/crates/aienos-aegis/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:81c04634d08cd2e965d3a6a66fbb586bcb221ca33c71d60049257da9271059d0 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 6,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:19de1b67205d779ab95e2daadf92756d98c234bf57962078922574a1b0ab3d10 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-aegis/tests/.crumb b/crates/aienos-aegis/tests/.crumb
index a9cef321 ..031c2fde 100644
--- a/crates/aienos-aegis/tests/.crumb
+++ b/crates/aienos-aegis/tests/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:116b4a84f2a0b3f537433c1187e35f911f0c0dedea3b489607ac0132fdde9542 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 1,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:0934c6689e8111e99bd3072e461d5c14ddc96b1153f266fa7ca8ee6cebd64a4c "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-agent-state/.crumb b/crates/aienos-agent-state/.crumb
index 98a8389b ..39db5643 100644
--- a/crates/aienos-agent-state/.crumb
+++ b/crates/aienos-agent-state/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "65a8c460540b0190c0d00418ba79639832abd8764dc0ea59a1ddec40cc1747bb ",
- "last_commit": "39e246a ",
- "name": "src",
- "purpose": "Directory crates/aienos-agent-state/src. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:141b42405835f497b7769439b232fa33c45b093c4022ed8df2d70cfcc7bedba0 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:d5ad195a8f38c6bd0e1cc00feb8c5040f0fc8eabe47a9a69d961c73d6901d61e ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 8,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:15f902241a2f247dfeec1b22c4f35fd957718fc9d76ecf7256fac0603f11f0c1 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-agent-state/src/.crumb b/crates/aienos-agent-state/src/.crumb
index 20bbe098 ..817e2ae8 100644
--- a/crates/aienos-agent-state/src/.crumb
+++ b/crates/aienos-agent-state/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:65a8c460540b0190c0d00418ba79639832abd8764dc0ea59a1ddec40cc1747bb ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 7,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:ff373815f562e46d5dbf89c4879e35d4abafb3e4c8bfab7c0dfc77c47019f3b1 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-artifact-tool/.crumb b/crates/aienos-artifact-tool/.crumb
index a79f1dda ..7d46c873 100644
--- a/crates/aienos-artifact-tool/.crumb
+++ b/crates/aienos-artifact-tool/.crumb
@@ -14,25 +14,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "2e9b452905c551e57f1e70075f5bac994cefa497181800f3bf145a9c6ceb36df ",
- "last_commit": "2276906 ",
- "name": "src",
- "purpose": "Directory crates/aienos-artifact-tool/src. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:9e74efbe992bdf8537913d0945f0b28487e757732babf47a95707d1203682e7b ",
- "compiled_at": "2026-10-14T13:28:10Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:ff4260f8fede1182f834d89589eb4d5a6c6160032dfc570003d506411fe93aa4 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 39,
- "generated_at_commit": "a0fa796235409ce465c467e8c72fbd977485d8f7 ",
- "source_tree": "sha256:89eb7ba0259498354bbb1f270b83b0a487ff86996ecb068df73ea51e473a92e2 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-artifact-tool/fixtures/p2_5/.crumb b/crates/aienos-artifact-tool/fixtures/p2_5/.crumb
index 7c9624bf ..f8a87375 100644
--- a/crates/aienos-artifact-tool/fixtures/p2_5/.crumb
+++ b/crates/aienos-artifact-tool/fixtures/p2_5/.crumb
@@ -18,37 +18,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "12ec8e2c7352d6526bad902bc37434ba39b42bf3b35f0ea96f6fed4e566e5013 ",
- "last_commit": "3a6174a ",
- "name": "p25exec",
- "purpose": "Directory crates/aienos-artifact-tool/fixtures/p2_5/p25exec. Purpose not yet described by a huma"
- },
- {
- "digest": "e49ae76bea4102e68c5fb6241d8aa2a2eb70e7b9469608d2903c04069d37638b ",
- "last_commit": "3a6174a ",
- "name": "p25spin",
- "purpose": "Directory crates/aienos-artifact-tool/fixtures/p2_5/p25spin. Purpose not yet described by a huma"
- },
- {
- "digest": "86ac75b1138c0be9f16ffca1e4f4e6d35ca206fd7bcdd65a272573f98cf9d180 ",
- "last_commit": "3a6174a ",
- "name": "p25wx",
- "purpose": "Directory crates/aienos-artifact-tool/fixtures/p2_5/p25wx. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:6082777c4ccc20cae47f6fcac9a1198acc351d38d1aaed3d1839fc45d7577afc ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:31145588e22426c6766a2386e5616395ed12f603f12e9c84c23ba703cf374bf6 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 14,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:d9139352311dfefa51c34ca2553ff646cf58db6785f877efa5fbecaf40eb69cc "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-artifact-tool/fixtures/p2_5/p25exec/.crumb b/crates/aienos-artifact-tool/fixtures/p2_5/p25exec/.crumb
index aa9404b0 ..dc590454 100644
--- a/crates/aienos-artifact-tool/fixtures/p2_5/p25exec/.crumb
+++ b/crates/aienos-artifact-tool/fixtures/p2_5/p25exec/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:12ec8e2c7352d6526bad902bc37434ba39b42bf3b35f0ea96f6fed4e566e5013 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 4,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:828948c76413f3bf1958b30b7bfd0c148b0f333f13f832cd4b33b1c7e75d920d "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-artifact-tool/fixtures/p2_5/p25spin/.crumb b/crates/aienos-artifact-tool/fixtures/p2_5/p25spin/.crumb
index 16cd76be ..40c126b7 100644
--- a/crates/aienos-artifact-tool/fixtures/p2_5/p25spin/.crumb
+++ b/crates/aienos-artifact-tool/fixtures/p2_5/p25spin/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:e49ae76bea4102e68c5fb6241d8aa2a2eb70e7b9469608d2903c04069d37638b ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 4,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:d7efff00bb51fb0b08989bf6f450e0c0f48739516e2766a12198b3cee011e9b4 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-artifact-tool/fixtures/p2_5/p25wx/.crumb b/crates/aienos-artifact-tool/fixtures/p2_5/p25wx/.crumb
index 19d0926b ..efe7e651 100644
--- a/crates/aienos-artifact-tool/fixtures/p2_5/p25wx/.crumb
+++ b/crates/aienos-artifact-tool/fixtures/p2_5/p25wx/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:86ac75b1138c0be9f16ffca1e4f4e6d35ca206fd7bcdd65a272573f98cf9d180 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 4,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:6ae037a567fbdac6ea366495cffd5cbc846f42130f400a4761170acadaef2fa8 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-artifact-tool/fixtures/p2_6/.crumb b/crates/aienos-artifact-tool/fixtures/p2_6/.crumb
index bb7b9608 ..f9dd4662 100644
--- a/crates/aienos-artifact-tool/fixtures/p2_6/.crumb
+++ b/crates/aienos-artifact-tool/fixtures/p2_6/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "840aed89b746a4a7ce182a9c0451e9b214b661542a794f553d062b4bfb432ed6 ",
- "last_commit": "5ad82b3 ",
- "name": "p26seed",
- "purpose": "Directory crates/aienos-artifact-tool/fixtures/p2_6/p26seed. Purpose not yet described by a huma"
- }
- ],
- "children_root": "sha256:b71def74f45a5689a4e18998806238c664fd678eaded10a7933b8fb0a21da02c ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:2811606d395a9d99516bd97b845fd673bfed3f04b5f592c795868c3f8abe5727 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 6,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:55cfddf35a6d8695b3cf45be65b914e4c96d1f053e48f4c81de1e16243595d67 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-artifact-tool/fixtures/p2_6/p26seed/.crumb b/crates/aienos-artifact-tool/fixtures/p2_6/p26seed/.crumb
index 42156e21 ..f64147f7 100644
--- a/crates/aienos-artifact-tool/fixtures/p2_6/p26seed/.crumb
+++ b/crates/aienos-artifact-tool/fixtures/p2_6/p26seed/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:840aed89b746a4a7ce182a9c0451e9b214b661542a794f553d062b4bfb432ed6 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 4,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:1e8d6325e9abc0a69563558608e0645a0dbad2f059f9ed5684539b334ed43f2c "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-artifact-tool/src/.crumb b/crates/aienos-artifact-tool/src/.crumb
index 2226bf9f ..39d2993e 100644
--- a/crates/aienos-artifact-tool/src/.crumb
+++ b/crates/aienos-artifact-tool/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:2e9b452905c551e57f1e70075f5bac994cefa497181800f3bf145a9c6ceb36df ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 3,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:45786c050f91edf80cdec22f2cd1f859c4210a1274370d276eefc6b74fcc70ad "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-artifact/.crumb b/crates/aienos-artifact/.crumb
index 6e095876 ..6d6cf0e6 100644
--- a/crates/aienos-artifact/.crumb
+++ b/crates/aienos-artifact/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "72839a0b74ae80e6e1a4c702fd619096974eb051aff136506d974522ac6c5651 ",
- "last_commit": "8307a68 ",
- "name": "src",
- "purpose": "Directory crates/aienos-artifact/src. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:13e8558a828816f21f57e02ca246057abb20a456f1bb257cc4c0392203981f3a ",
- "compiled_at": "2026-10-14T01:54:45Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:ffb6a9a637e1eca1408280c4522ea52b283d740a90b8efad30350082900cbcdc ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 13,
- "generated_at_commit": "8307a68a2eedcc5c8d6c2a6ffbf7c12f398c094b ",
- "source_tree": "sha256:1d331b83e3479a7cb19bd437c3402f13ed2d89917dc90a623af90eb4cc93d649 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-artifact/src/.crumb b/crates/aienos-artifact/src/.crumb
index f9f2afc8 ..911e2064 100644
--- a/crates/aienos-artifact/src/.crumb
+++ b/crates/aienos-artifact/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-14T01:54:45Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:72839a0b74ae80e6e1a4c702fd619096974eb051aff136506d974522ac6c5651 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 12,
- "generated_at_commit": "8307a68a2eedcc5c8d6c2a6ffbf7c12f398c094b ",
- "source_tree": "sha256:3dc9736a359478ce0c6cc8d522b63556fe5a62b4de2ef1fe16016a9c17cdfb2f "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-boot/.crumb b/crates/aienos-boot/.crumb
index 427ee2a3 ..803dfaf3 100644
--- a/crates/aienos-boot/.crumb
+++ b/crates/aienos-boot/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "a293e29bdbd2290940857d026086a68804efd1b345d7eacc5b16cd542656ab0d ",
- "last_commit": "3761935 ",
- "name": "src",
- "purpose": "Directory crates/aienos-boot/src. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:021ca31625bb390fc4fa28820082502f108d3826b7c69936d0f448f981488ce2 ",
- "compiled_at": "2026-10-13T02:27:54Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:223e3399133c766986b1044a16c8367b51b78158d3070c0ec63c7ed3e639d644 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 9,
- "generated_at_commit": "74f638c298bc04543b03d6851a83dac815d36645 ",
- "source_tree": "sha256:6f188aa85aafc6b582fa0b6ecdde7ff91d0e7a6714a769d684313d15e3e013c8 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-boot/src/.crumb b/crates/aienos-boot/src/.crumb
index 3ef75509 ..35181c87 100644
--- a/crates/aienos-boot/src/.crumb
+++ b/crates/aienos-boot/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-13T02:27:54Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:a293e29bdbd2290940857d026086a68804efd1b345d7eacc5b16cd542656ab0d ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 8,
- "generated_at_commit": "74f638c298bc04543b03d6851a83dac815d36645 ",
- "source_tree": "sha256:63ca92587d96a5f5803d68284e9ffbf32b960df2959a95482aa0d90d0f3b9f00 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-c1-tree/.crumb b/crates/aienos-c1-tree/.crumb
index 73b12697 ..76b5a0b9 100644
--- a/crates/aienos-c1-tree/.crumb
+++ b/crates/aienos-c1-tree/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "c4e73e6c433a48fb64a5245f2013976b042e08e61547fed29f63a81eb83ae4a9 ",
- "last_commit": "bc25e73 ",
- "name": "src",
- "purpose": "Directory crates/aienos-c1-tree/src. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:b8d86bd2ff955746678ddf4f8fab9182bb3c0a3648bb24eece36bece39743278 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:01d4fe4a0bd556f338ac4615b7ed1c9141e4f8035c07e0082f2894a57fa071d0 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 6,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:1e157d25c5dc194c76b5962990147c5735dfb314d1ed11bbe5976b48534f211e "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-c1-tree/src/.crumb b/crates/aienos-c1-tree/src/.crumb
index 006e0b8c ..fe899b6f 100644
--- a/crates/aienos-c1-tree/src/.crumb
+++ b/crates/aienos-c1-tree/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:c4e73e6c433a48fb64a5245f2013976b042e08e61547fed29f63a81eb83ae4a9 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 5,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:f4d9fd2df72f5219d4397bde29a2f2c7c175bd238ca247586addb2577803a52b "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-capability-ffi/.crumb b/crates/aienos-capability-ffi/.crumb
index ebbd11c1 ..2dcc11ca 100644
--- a/crates/aienos-capability-ffi/.crumb
+++ b/crates/aienos-capability-ffi/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "1cb093121e30c7650490bef5f1b0d9d7daeba6b02576ceb70c063924375e8458 ",
- "last_commit": "6d17b22 ",
- "name": "src",
- "purpose": "Directory crates/aienos-capability-ffi/src. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:951f011130547622847c6176f56210f3d984788efdbbfecc80a553721dfef1bb ",
- "compiled_at": "2026-10-11T21:20:24Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:c63ab3d5643ac3c0974eee276273a0ab80584c54926cbb62c637294b5b857718 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 2,
- "generated_at_commit": "362cba9653c8021996a21b17ead00d5d1140b371 ",
- "source_tree": "sha256:96faad31a59d21e328ed818589933b387d5487b69b7e046ee5c40ed8a9574e4e "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-capability-ffi/src/.crumb b/crates/aienos-capability-ffi/src/.crumb
index 69258cfd ..f0ac035e 100644
--- a/crates/aienos-capability-ffi/src/.crumb
+++ b/crates/aienos-capability-ffi/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-11T21:20:24Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:1cb093121e30c7650490bef5f1b0d9d7daeba6b02576ceb70c063924375e8458 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 1,
- "generated_at_commit": "362cba9653c8021996a21b17ead00d5d1140b371 ",
- "source_tree": "sha256:334a2324f5258126e7f4e8b4fbc53f9a051c8dc53b7f9c25a9b7343292dd7c84 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-capability/.crumb b/crates/aienos-capability/.crumb
index c46fd152 ..a59fb48f 100644
--- a/crates/aienos-capability/.crumb
+++ b/crates/aienos-capability/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "9c1c32b183b9272d26de382e1327aac1da7373f79096fb3e421f795b36d17c8b ",
- "last_commit": "362cba9 ",
- "name": "src",
- "purpose": "Directory crates/aienos-capability/src. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:ec5b8bc5ec1d665dcfbecf32ea2408e5d3c84ec78e9d4623554ffc9a32d6970d ",
- "compiled_at": "2026-10-11T21:20:24Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:ca15c2b9ae570b0aa2c7859672de2c976d6ce046188c09b7c74b5ccbee350136 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 2,
- "generated_at_commit": "362cba9653c8021996a21b17ead00d5d1140b371 ",
- "source_tree": "sha256:a435f6cea762e4c709af5e49797c27aeedc468b7003993e72cf5f429dcf5e5b0 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-capability/src/.crumb b/crates/aienos-capability/src/.crumb
index c4140490 ..0050f5ba 100644
--- a/crates/aienos-capability/src/.crumb
+++ b/crates/aienos-capability/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-11T21:20:24Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:9c1c32b183b9272d26de382e1327aac1da7373f79096fb3e421f795b36d17c8b ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 1,
- "generated_at_commit": "362cba9653c8021996a21b17ead00d5d1140b371 ",
- "source_tree": "sha256:fe35483a6d43ccd7a9450e95bde44a95ec22e67a282447450ca4c70d1a8b32b8 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-cortex/.crumb b/crates/aienos-cortex/.crumb
index 8b8bd508 ..d71d22b3 100644
--- a/crates/aienos-cortex/.crumb
+++ b/crates/aienos-cortex/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "1ea60299f5c468e6713aff04a2588ae50d1d9667270d629368f6bcf3a6837ef0 ",
- "last_commit": "bc25e73 ",
- "name": "src",
- "purpose": "Directory crates/aienos-cortex/src. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:92d1cbf580400ebb38fb86483abce93e4ec128765daa059f5d84d27f9ef52eee ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:f062e2e58faa2950ce8adeb2e4c16234dacce6672d560ed4fdeb7224c5093a77 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 6,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:8d85c1d3b93b28be2a5bada5c383d51b4d1bf11af78751aef5f628465b43a93d "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-cortex/src/.crumb b/crates/aienos-cortex/src/.crumb
index 7eb740e3 ..86b49134 100644
--- a/crates/aienos-cortex/src/.crumb
+++ b/crates/aienos-cortex/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:1ea60299f5c468e6713aff04a2588ae50d1d9667270d629368f6bcf3a6837ef0 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 5,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:8909001899839398417d11d829dedf944384cf2dfb2b9e732120ed8fef024565 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-crypto/.crumb b/crates/aienos-crypto/.crumb
index 0c47d8c2 ..0ec820fa 100644
--- a/crates/aienos-crypto/.crumb
+++ b/crates/aienos-crypto/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "df22f43d422699a0008974d22f67f8be01d22d0d654b47b70fe18f4528fb9daa ",
- "last_commit": "f0facc7 ",
- "name": "src",
- "purpose": "Directory crates/aienos-crypto/src. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:ef6e4823cebb32eaffb834d1c1e26e12b4ae6b026ccdddb6ba707032d40550e5 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:feccaaf349b9e88bc116db18951ffbd0145176b40ce702bc6320338c35b2e85e ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 6,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:2f0bb7150a70335c17ca5809b37982f1788f0e212a8ab9719de5a1f0a4a503a7 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-crypto/src/.crumb b/crates/aienos-crypto/src/.crumb
index 3403854b ..9de22e4e 100644
--- a/crates/aienos-crypto/src/.crumb
+++ b/crates/aienos-crypto/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:df22f43d422699a0008974d22f67f8be01d22d0d654b47b70fe18f4528fb9daa ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 5,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:4796887182256b3bb93023aac24d014cd096e6f6aa139d72b1c96d69371df6f3 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-evidence/.crumb b/crates/aienos-evidence/.crumb
index 7cf1a74e ..7c099ec7 100644
--- a/crates/aienos-evidence/.crumb
+++ b/crates/aienos-evidence/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "3a2a8524efb5a0ba6ee9470537d862bad5b69a58ca6328e49e48715f8de36c09 ",
- "last_commit": "e960272 ",
- "name": "src",
- "purpose": "Directory crates/aienos-evidence/src. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:77c1f566be80f025bdb191e29a47eb07fe3ed2832535f5df4f29ff60aec4b4b3 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:e88324eb9a32d23d8358413c7404038ee4095fcf8c4889ac9c221b97aef80b8e ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 10,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:f0c5766c2a965888b6e893213d2b31052c9e7c52f22c6a02be4b39cf80f6b36d "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-evidence/src/.crumb b/crates/aienos-evidence/src/.crumb
index 741b0455 ..b1ca3da8 100644
--- a/crates/aienos-evidence/src/.crumb
+++ b/crates/aienos-evidence/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:3a2a8524efb5a0ba6ee9470537d862bad5b69a58ca6328e49e48715f8de36c09 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 9,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:b7dec6edff310b7a8af19c5fd59dee61f43b885bad3d2a2a5417e405f8a92319 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/.crumb b/crates/aienos-kernel/.crumb
index 8601194a ..173466c1 100644
--- a/crates/aienos-kernel/.crumb
+++ b/crates/aienos-kernel/.crumb
@@ -14,31 +14,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "734b26e98d61b37aac677c0414839f40a617df3d632281dcdb103300def3fb33 ",
- "last_commit": "c9e49a1 ",
- "name": "src",
- "purpose": "Directory crates/aienos-kernel/src. Purpose not yet described by a human."
- },
- {
- "digest": "4a5f74d8e889ecb0089082469852f1e4b1c034af70dfeab3df2902cd35662ddb ",
- "last_commit": "09e59a8 ",
- "name": "tests",
- "purpose": "Directory crates/aienos-kernel/tests. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:77d394e8ab2668a7a8970995479282d55313a816627a71d753dd0dcc2ad63a12 ",
- "compiled_at": "2026-10-14T05:42:42Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:a0d0036c90e3d64d6e1caa67b77bf2b8deb898c597e9f0b797df4a144468e061 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 85,
- "generated_at_commit": "02f8eab6a95907159c13e8b83fc0aaf2c100db11 ",
- "source_tree": "sha256:c86f23913fbd167149dbe254e7369e586f9d6011adab1d612e70c6a3ed2f9ec7 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/src/.crumb b/crates/aienos-kernel/src/.crumb
index 9a056ef4 ..398b7639 100644
--- a/crates/aienos-kernel/src/.crumb
+++ b/crates/aienos-kernel/src/.crumb
@@ -42,73 +42,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "ad829eca65ef7878ec3f262d4ba17592c984c4f25e29b2012ea00fd6d3909260 ",
- "last_commit": "49ff776 ",
- "name": "arch",
- "purpose": "Directory crates/aienos-kernel/src/arch. Purpose not yet described by a human."
- },
- {
- "digest": "b7d0aa65cc5d5530c8946550c0c917d2f5b413fd7fd26c951a927061e88c42ac ",
- "last_commit": "f0facc7 ",
- "name": "crypto",
- "purpose": "Directory crates/aienos-kernel/src/crypto. Purpose not yet described by a human."
- },
- {
- "digest": "fa2848da5714e9ff05bc46ce48d916c1c257295dd384fb690564773344006884 ",
- "last_commit": "a22b1d8 ",
- "name": "display",
- "purpose": "Directory crates/aienos-kernel/src/display. Purpose not yet described by a human."
- },
- {
- "digest": "aeb814fd7cfb0fdd7f62ddb86ecaea68bbb7c6a36baac72b3037db4db01de7d0 ",
- "last_commit": "fbbfc9c ",
- "name": "infer",
- "purpose": "Directory crates/aienos-kernel/src/infer. Purpose not yet described by a human."
- },
- {
- "digest": "fedb9de89144afbd947950265a8abd584f23af9188889330b1efb7ac600b6655 ",
- "last_commit": "3a6174a ",
- "name": "mem",
- "purpose": "Directory crates/aienos-kernel/src/mem. Purpose not yet described by a human."
- },
- {
- "digest": "ec1328a2fc6f55a1a0a66efe3322f9eaa4fe3dd495c458b2fb64ceabf69951f4 ",
- "last_commit": "c851d01 ",
- "name": "nvme",
- "purpose": "Directory crates/aienos-kernel/src/nvme. Purpose not yet described by a human."
- },
- {
- "digest": "65eae3c74fff17cf4adf6f795c72ce3a65a32bb8d90a735fa8674a9a7bbe5a4e ",
- "last_commit": "a2a0382 ",
- "name": "store",
- "purpose": "Directory crates/aienos-kernel/src/store. Purpose not yet described by a human."
- },
- {
- "digest": "2d69db3de4cc825da15f576da8375d3994c484741be4dafd356a1b469afce7f1 ",
- "last_commit": "bc25e73 ",
- "name": "sync",
- "purpose": "Directory crates/aienos-kernel/src/sync. Purpose not yet described by a human."
- },
- {
- "digest": "f51233705a5c33d1c72abca84575d077a80fd907e73c14ee95d9939a02c06eb0 ",
- "last_commit": "49ff776 ",
- "name": "usb",
- "purpose": "Directory crates/aienos-kernel/src/usb. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:e84717f6b7c3368dbb75c1fe5496c2b6b70a63404a35a96dc89e2aa5dec251b2 ",
- "compiled_at": "2026-10-14T05:42:42Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:734b26e98d61b37aac677c0414839f40a617df3d632281dcdb103300def3fb33 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 75,
- "generated_at_commit": "02f8eab6a95907159c13e8b83fc0aaf2c100db11 ",
- "source_tree": "sha256:6922d3c9969a87d4fa673b02e20dba31cec91d56266fdc7ff3a57454fcef3de0 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/src/arch/.crumb b/crates/aienos-kernel/src/arch/.crumb
index 8112643e ..7f916aee 100644
--- a/crates/aienos-kernel/src/arch/.crumb
+++ b/crates/aienos-kernel/src/arch/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-13T02:27:54Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:ad829eca65ef7878ec3f262d4ba17592c984c4f25e29b2012ea00fd6d3909260 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 2,
- "generated_at_commit": "74f638c298bc04543b03d6851a83dac815d36645 ",
- "source_tree": "sha256:8ca36aa449d5b268a7e8b8e233aeef95f4f6a282492d45763bfe62f780a03e32 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/src/crypto/.crumb b/crates/aienos-kernel/src/crypto/.crumb
index 5216ee65 ..c76ae2f2 100644
--- a/crates/aienos-kernel/src/crypto/.crumb
+++ b/crates/aienos-kernel/src/crypto/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:b7d0aa65cc5d5530c8946550c0c917d2f5b413fd7fd26c951a927061e88c42ac ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 5,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:99da0e4c88bda0206dc3eea2b04209579ba60975dc625d3044ec6a31ee62ddf3 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/src/display/.crumb b/crates/aienos-kernel/src/display/.crumb
index e6ec9c74 ..2c26a11b 100644
--- a/crates/aienos-kernel/src/display/.crumb
+++ b/crates/aienos-kernel/src/display/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:fa2848da5714e9ff05bc46ce48d916c1c257295dd384fb690564773344006884 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 2,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:aef57a83d373447720cb87d8ad9c14429ea3c813d55c17972b9a7f8772d82ea1 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/src/infer/.crumb b/crates/aienos-kernel/src/infer/.crumb
index 4d6c7e7b ..58f2450b 100644
--- a/crates/aienos-kernel/src/infer/.crumb
+++ b/crates/aienos-kernel/src/infer/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T20:01:05Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:aeb814fd7cfb0fdd7f62ddb86ecaea68bbb7c6a36baac72b3037db4db01de7d0 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 5,
- "generated_at_commit": "79456d09c1e2aaf0c84f853f0e3d76b864475bb7 ",
- "source_tree": "sha256:10bca0cfb9f161ce82da5e2f09ac664f09c70dadfafda71d89f1ee2766c4c23a "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/src/mem/.crumb b/crates/aienos-kernel/src/mem/.crumb
index 91c79fca ..66d97d16 100644
--- a/crates/aienos-kernel/src/mem/.crumb
+++ b/crates/aienos-kernel/src/mem/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:fedb9de89144afbd947950265a8abd584f23af9188889330b1efb7ac600b6655 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 4,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:f52d292558dfe1f43a5a2400f0b0c83f5409953dc075683391c42c41e2025404 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/src/nvme/.crumb b/crates/aienos-kernel/src/nvme/.crumb
index 9f7b67bd ..40adeab3 100644
--- a/crates/aienos-kernel/src/nvme/.crumb
+++ b/crates/aienos-kernel/src/nvme/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:ec1328a2fc6f55a1a0a66efe3322f9eaa4fe3dd495c458b2fb64ceabf69951f4 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 2,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:514dde2f4c77d89d342397ff2d893685cfc619147cbfcf46477426da3db22a49 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/src/store/.crumb b/crates/aienos-kernel/src/store/.crumb
index 6b146ac9 ..f6082e02 100644
--- a/crates/aienos-kernel/src/store/.crumb
+++ b/crates/aienos-kernel/src/store/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:65eae3c74fff17cf4adf6f795c72ce3a65a32bb8d90a735fa8674a9a7bbe5a4e ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 5,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:7f1e21a5ca6cbc472d4498884beaaf3edee4780ca9a3969f68e031a1c185eac3 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/src/sync/.crumb b/crates/aienos-kernel/src/sync/.crumb
index 513952e7 ..4205a020 100644
--- a/crates/aienos-kernel/src/sync/.crumb
+++ b/crates/aienos-kernel/src/sync/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:2d69db3de4cc825da15f576da8375d3994c484741be4dafd356a1b469afce7f1 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 2,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:78893ae665ae14dbb92a18c10850eb08ebdcf04f21d2f15ed652709b13c16f99 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/src/usb/.crumb b/crates/aienos-kernel/src/usb/.crumb
index 96749bf7 ..e4565659 100644
--- a/crates/aienos-kernel/src/usb/.crumb
+++ b/crates/aienos-kernel/src/usb/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "451d20161f6df66f91a25be8a7257306238f81ce0afb80c7f22b5994d05f1350 ",
- "last_commit": "35b3086 ",
- "name": "xhci",
- "purpose": "Directory crates/aienos-kernel/src/usb/xhci. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:84fa272544e7bafacd247ab2c9371317f746bd408f0bdb5e0918007370dfe5c3 ",
- "compiled_at": "2026-10-13T02:27:54Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:f51233705a5c33d1c72abca84575d077a80fd907e73c14ee95d9939a02c06eb0 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 9,
- "generated_at_commit": "74f638c298bc04543b03d6851a83dac815d36645 ",
- "source_tree": "sha256:cb2d7930d8dbaad0d76d7e5d5903ae3a810e34e6558192ecc4554d8fb6e89675 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/src/usb/xhci/.crumb b/crates/aienos-kernel/src/usb/xhci/.crumb
index 6bcf602d ..5f7f445e 100644
--- a/crates/aienos-kernel/src/usb/xhci/.crumb
+++ b/crates/aienos-kernel/src/usb/xhci/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-13T02:27:54Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:451d20161f6df66f91a25be8a7257306238f81ce0afb80c7f22b5994d05f1350 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 5,
- "generated_at_commit": "74f638c298bc04543b03d6851a83dac815d36645 ",
- "source_tree": "sha256:c939574330b003b590ddc42d63608e3ba2363fe2d368d1fd015029770f71787e "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-kernel/tests/.crumb b/crates/aienos-kernel/tests/.crumb
index 8926caa0 ..b472dcd6 100644
--- a/crates/aienos-kernel/tests/.crumb
+++ b/crates/aienos-kernel/tests/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-14T01:16:45Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:4a5f74d8e889ecb0089082469852f1e4b1c034af70dfeab3df2902cd35662ddb ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 9,
- "generated_at_commit": "f78977a6ce33ea89a5b3b1952c0a0e403d4504fa ",
- "source_tree": "sha256:a09dde2f26dcf3d7bbc7d2f7e8e511d5ebfff434dcd9a2f010963413d795756a "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-store-tool/.crumb b/crates/aienos-store-tool/.crumb
index fc99a21e ..e52e452f 100644
--- a/crates/aienos-store-tool/.crumb
+++ b/crates/aienos-store-tool/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "37a250c16fcf1ee0351e5ef165ee010fd987c23958b5582b4fd86b212e966573 ",
- "last_commit": "761e63d ",
- "name": "src",
- "purpose": "Directory crates/aienos-store-tool/src. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:0213c8f331c9520c68ce679b8e1104c04aa862cfa3dedbad3f88410b2a11b380 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:716d679da128e7aab8efb6e9cf836ee22a62fe9fe6993e2d0a20c3016d78b3a0 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 2,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:b7c2b35b4232b998b5a2ba1ef98ce05fc4e6353d0c3a45bc5abb56baa9137100 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crates/aienos-store-tool/src/.crumb b/crates/aienos-store-tool/src/.crumb
index 824cf9ee ..58785146 100644
--- a/crates/aienos-store-tool/src/.crumb
+++ b/crates/aienos-store-tool/src/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:37a250c16fcf1ee0351e5ef165ee010fd987c23958b5582b4fd86b212e966573 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 1,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:0f2ae2a0d9e6f9d7a098fc76b6f75a79b8321fee1da94e1756dba13fac47984b "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/crumb.lock b/crumb.lock
index 3dea07e0 ..dede5d05 100644
--- a/crumb.lock
+++ b/crumb.lock
@@ -1 +1 @@
-d0f0b95d344b4c6628c3d868346932fd247ce168
+12ad0141b41ec67ef5aa51cb4e1815894c1083bb
diff --git a/docs/.crumb b/docs/.crumb
index 51b2754a ..7d529c81 100644
--- a/docs/.crumb
+++ b/docs/.crumb
@@ -14,31 +14,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "e84f072935b7d6d9f5a7bcaedb3fc366b4f73f8f609abcc2ea450e65665c64fa ",
- "last_commit": "09e59a8 ",
- "name": "adr",
- "purpose": "Directory docs/adr. Purpose not yet described by a human."
- },
- {
- "digest": "5dc4f124f1c023aa4786f45336a671138fce9fa046478364cdc7454307d7b588 ",
- "last_commit": "09e59a8 ",
- "name": "crumbs",
- "purpose": "Directory docs/crumbs. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:491e93c09b6185b662afda8b29d24bb3ee81bc2aed9009757fdf4674d197be31 ",
- "compiled_at": "2026-10-16T10:58:02Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:2f740ef54106c2b6419bfd2df1266762cd444f439c7e12ae2a7c5c3877de926c ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 216,
- "generated_at_commit": "4637b04d06f4e3cec4c79920bbed0efb46b93995 ",
- "source_tree": "sha256:1abaa75a2a66a6ce77842c9439ad7a5cbb7dee680ef47a6c33d9b865e8f70417 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/docs/adr/.crumb b/docs/adr/.crumb
index 16b9e5a4 ..0d4820b6 100644
--- a/docs/adr/.crumb
+++ b/docs/adr/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-14T01:16:45Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:e84f072935b7d6d9f5a7bcaedb3fc366b4f73f8f609abcc2ea450e65665c64fa ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 23,
- "generated_at_commit": "f78977a6ce33ea89a5b3b1952c0a0e403d4504fa ",
- "source_tree": "sha256:45ba8a61db7b8af23a680740d4ca9545ba9d53c36d42bf59802459d3555051b3 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/docs/adr/README.md b/docs/adr/README.md
index ff904f80 ..33abeea9 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -12,16 +12,17 @@ This directory documents the key architectural decisions and formal technical sp
| [ADR 0004](0004-reversibility-definition-and-network-effect-boundary.md) | Reversibility Definition and Network Effect Boundary | Accepted | 2026-09-23 | [`ARCHITECTURE.md` §5](../ARCHITECTURE.md); [`BLUEPRINT.md` §5, §12, §13](../BLUEPRINT.md); [`MILESTONES.md` Phase 4](../MILESTONES.md); [`PHASE_3_TO_5_SPECIFICATION.md` §3](../PHASE_3_TO_5_SPECIFICATION.md#3-phase-4-native-system-intelligence-aegis-worlds-capabilities) |
| [ADR 0005](0005-unified-memory-c1-cow-and-reservation-accounting.md) | Unified Memory C1 Copy-On-Write and Reservation Accounting | Accepted | 2026-09-23 | [`ARCHITECTURE.md` §2, §7](../ARCHITECTURE.md); [`BLUEPRINT.md` §9, §10, §28](../BLUEPRINT.md); [`MILESTONES.md` Phase 4, 5](../MILESTONES.md); [`PHASE_3_TO_5_SPECIFICATION.md` §4](../PHASE_3_TO_5_SPECIFICATION.md#4-phase-5-native-hardware-acceleration--hardware-bound-c1-compute) |
| [ADR 0006](0006-deterministic-recovery-core-and-offline-operator-authority.md) | Deterministic Recovery Core and Offline Operator Authority | Accepted | 2026-09-23 | [`ARCHITECTURE.md` §1, §4, §6](../ARCHITECTURE.md); [`BLUEPRINT.md` §5, §6, §33](../BLUEPRINT.md); [`MILESTONES.md` Phase 2, 6](../MILESTONES.md); [`SYSTEMS_INTEGRATION_SEQUENCE.md` §2.5](../SYSTEMS_INTEGRATION_SEQUENCE.md#step-5-prove-recovery-core-before-the-model-adr-0006) |
-| [ADR 0007](0007-continuous-existence-provisioning-once.md) | Continuous Existence and Provisioning-Once | Accepted | 2026-09-23 | [`CONTINUOUS_EXISTENCE_AMENDMENT.md`](../CONTINUOUS_EXISTENCE_AMENDMENT.md); [`ARCHITECTURE.md` §1, §10](../ARCHITECTURE.md); [`SYSTEMS_INTEGRATION_SEQUENCE.md` Steps 1–10](../SYSTEMS_INTEGRATION_SEQUENCE.md); [`MILESTONES.md` Phase 3, 6, 8](../MILESTONES.md); [ADR 0005](0005-unified-memory-c1-cow-and-reservation-accounting.md); [ADR 0006](0006-deterministic-recovery-core-and-offline-operator-authority.md) |
+| [ADR 0007](0007-continuous-existence-provisioning-once.md) | Continuous Existence and Provisioning-Once | Accepted | 2026-09-23 | [`CONTINUOUS_EXISTENCE_AMENDMENT.md`](../CONTINUOUS_EXISTENCE_AMENDMENT.md); [`ARCHITECTURE.md` §1, §10](../ARCHITECTURE.md); [`SYSTEMS_INTEGRATION_SEQUENCE.md` Steps 1 to 10](../SYSTEMS_INTEGRATION_SEQUENCE.md); [`MILESTONES.md` Phase 3, 6, 8](../MILESTONES.md); [ADR 0005](0005-unified-memory-c1-cow-and-reservation-accounting.md); [ADR 0006](0006-deterministic-recovery-core-and-offline-operator-authority.md) |
| [ADR 0008](0008-temporary-bring-up-firmware-report-exception.md) | Temporary bring-up exception: post-handoff firmware report (trigger 11) | Accepted (temporary) | 2026-09-24 | [ADR 0003](0003-bootstrap-firmware-handoff-and-minimal-object-store.md); [`MILESTONES.md` section 0](../MILESTONES.md); [`NATIVE_BOOT_ONE_TIME.md`](../NATIVE_BOOT_ONE_TIME.md) |
| [ADR 0009](0009-el2-bootstrap-to-el1h-kernel-transition.md) | Two-Stage Exception Level Architecture (EL2 Bootstrap to EL1h Kernel) | Accepted | 2026-09-24 | [`ARCHITECTURE.md` §3, §6](../ARCHITECTURE.md); [`BLUEPRINT.md` §8, §15](../BLUEPRINT.md); [`MILESTONES.md` Phase 2, 3](../MILESTONES.md) |
-| [ADR 0010](0010-fabric-machine-identity-and-capability-advertisement.md) | Fabric Machine Identity and Capability Advertisement | Proposed (post-M6) | 2026-09-24 | [`ARCHITECTURE.md` §2](../ARCHITECTURE.md); [`BLUEPRINT.md` §21, §25, §26](../BLUEPRINT.md); [`MILESTONES.md` Phase 8](../MILESTONES.md); [ADR 0004](0004-reversibility-definition-and-network-effect-boundary.md); [ADR 0007](0007-continuous-existence-provisioning-once.md); [issue #37](https://github.com/aien-spark/aienos/issues/37) |
+| [ADR 0010](0010-fabric-machine-identity-and-capability-advertisement.md) | Fabric Machine Identity and Capability Advertisement | Proposed (post-M6) | 2026-09-24 | [`ARCHITECTURE.md` §2](../ARCHITECTURE.md); [`BLUEPRINT.md` §21, §25, §26](../BLUEPRINT.md); [`MILESTONES.md` Phase 8](../MILESTONES.md); [ADR 0004](0004-reversibility-definition-and-network-effect-boundary.md); [ADR 0007](0007-continuous-existence-provisioning-once.md); [issue #37](https://github.com/aien-dev/aienos/issues/37) |
| [ADR 0011](0011-machine-1-hardware-test-rig.md) | Machine 1 Hardware Test Rig (Power, Capture, Input) | Proposed | 2026-09-24 | [`MILESTONES.md` section 0, gate M2C](../MILESTONES.md); [`HARDWARE_TEST_RIG.md`](../HARDWARE_TEST_RIG.md); [`NATIVE_BOOT_ONE_TIME.md`](../NATIVE_BOOT_ONE_TIME.md) |
| [ADR 0012](0012-self-construction-capability-growth-and-generations.md) | Self-Construction, Capability Growth, and Reversible System Generations | Accepted | 2026-09-24 | [ADR 0002](0002-incumbent-os-as-migration-environment.md); [ADR 0006](0006-deterministic-recovery-core-and-offline-operator-authority.md); [ADR 0007](0007-continuous-existence-provisioning-once.md); [`ROADMAP.md`](../../ROADMAP.md) (SEED-0A, SEED-0B) |
-| [ADR 0013](0013-aienos-abi-v1.md) | AIENOS ABI v1 | Proposed | 2026-09-24 | [ADR 0012](0012-self-construction-capability-growth-and-generations.md); [ADR 0004](0004-reversibility-definition-and-network-effect-boundary.md); [issue #30](https://github.com/aien-spark/aienos/issues/30); [PR #106](https://github.com/aien-spark/aienos/pull/106); [`abi.rs`](../../crates/aienos-kernel/src/abi.rs) |
+| [ADR 0013](0013-aienos-abi-v1.md) | AIENOS ABI v1 | Proposed | 2026-09-24 | [ADR 0012](0012-self-construction-capability-growth-and-generations.md); [ADR 0004](0004-reversibility-definition-and-network-effect-boundary.md); [issue #30](https://github.com/aien-dev/aienos/issues/30); [PR #106](https://github.com/aien-dev/aienos/pull/106); [`abi.rs`](../../crates/aienos-kernel/src/abi.rs) |
| [ADR 0014](0014-binary-artifact-v0-and-native-admission.md) | Binary Artifact v0 and Native Admission | Proposed | 2026-09-25 | [ADR 0012](0012-self-construction-capability-growth-and-generations.md); [ADR 0013](0013-aienos-abi-v1.md); SEED-0B qualification |
| [ADR 0015](0015-system-store-v1-format.md) | AIENOS System Store v1 Format | Accepted for P3-1 format freeze | 2026-09-25 | [ADR 0003](0003-bootstrap-firmware-handoff-and-minimal-object-store.md); P3 Native Persistence & Continuity |
| [ADR 0016](0016-continuity-objects-over-store-v1.md) | Continuity objects over System Store v1 | Proposed (format freeze needs operator approval) | 2026-09-25 | [ADR 0007](0007-continuous-existence-provisioning-once.md), [ADR 0015](0015-system-store-v1-format.md); M4 continuity |
+| [ADR 0017](0017-m5-key-hierarchy-and-encrypted-store.md) | M5 Key Hierarchy, Encrypted Envelopes, and Storage Security Roots | Proposed | 2026-09-25 | [ADR 0006](0006-deterministic-recovery-core-and-offline-operator-authority.md); [ADR 0015](0015-system-store-v1-format.md); [ADR 0016](0016-continuity-objects-over-store-v1.md); Milestone M5 (Encryption and Identity) |
| [ADR 0018](0018-allen-subject-state-object.md) | ALLEN Subject State Object (continuity kind 24) | Proposed (companion to ARCH-0035; format freeze needs operator approval) | 2026-10-04 | [ADR 0016](0016-continuity-objects-over-store-v1.md); omega ARCH-0022 Cortex; R16 |
| [ADR 0019](0019-per-resource-capability-generation.md) | Per-resource capability generation (OSC unit `required_generation`, domain 1) | Accepted (Option 3; counter tracked in aienos#285) | 2026-10-08 | [ADR 0013](0013-aienos-abi-v1.md); [ADR 0014](0014-binary-artifact-v0-and-native-admission.md) amendment point 5; aien-protocols `specs/osc-unit-artifact` section 15.3 C1 |
| [ADR 0020](0020-pi5-software-only-dma-confinement.md) | Pi 5 software-only DMA confinement (Pi-only exception to ADR 0012 rule 5) | Accepted (operator D3, 2026-10-13) | 2026-10-13 | [ADR 0012](0012-self-construction-capability-growth-and-generations.md) rule 5; `native/kernel/core/smmu.c` (Spark) |
@@ -34,24 +35,24 @@ In addition to discrete decision records, AIENOS maintains formal technical spec
| Document | Scope | Status | Authority | Target Phases |
|---|---|---|---|---|
-| [AIENOS Technical Specification & Contracts (Phases 3 – 5)](../PHASE_3_TO_5_SPECIFICATION.md) | Agent State ABI, Model ABI, Cortex Epistemic Store, AEGIS Effect Intent Pipeline, J-Space Worlds, and C1 CoW Prefix Tree | Confirmed Specification | Blueprint §§ 9–14, 17–19, 28 | Phases 3, 4, 5 |
-| [AIENOS Systems Integration Sequence & Epistemic Calibration](../SYSTEMS_INTEGRATION_SEQUENCE.md) | 10-step empirical hardware integration sequence, epistemic claim precision, and host-tested vs. native-qualified gates | Governing Framework | Operator Directive (2026-09-23) | Phases 1 – 8 |
-| [AIENOS Continuous-Existence Amendment](../CONTINUOUS_EXISTENCE_AMENDMENT.md) | Provisioning-once lifecycle, power states, state classes A/B/C, continuous-existence acceptance criteria for Gates 1–10 | Operator-Approved Governing Amendment | Operator Directive (2026-09-23); ADR 0007 | All Phases |
+| [AIENOS Technical Specification & Contracts (Phases 3 to 5)](../PHASE_3_TO_5_SPECIFICATION.md) | Agent State ABI, Model ABI, Cortex Epistemic Store, AEGIS Effect Intent Pipeline, J-Space Worlds, and C1 CoW Prefix Tree | Confirmed Specification | Blueprint §§ 9 to 14, 17 to 19, 28 | Phases 3, 4, 5 |
+| [AIENOS Systems Integration Sequence & Epistemic Calibration](../SYSTEMS_INTEGRATION_SEQUENCE.md) | 10-step empirical hardware integration sequence, epistemic claim precision, and host-tested vs. native-qualified gates | Governing Framework | Operator Directive (2026-09-23) | Phases 1 to 8 |
+| [AIENOS Continuous-Existence Amendment](../CONTINUOUS_EXISTENCE_AMENDMENT.md) | Provisioning-once lifecycle, power states, state classes A/B/C, continuous-existence acceptance criteria for Gates 1 to 10 | Operator-Approved Governing Amendment | Operator Directive (2026-09-23); ADR 0007 | All Phases |
| [AIENOS Final Architectural Blueprint](../BLUEPRINT.md) | Complete 37-section architectural foundation, core principles, and final success definitions | Immutable Foundation | Operator Directive | All Phases |
-| [AIENOS Architectural Milestones Matrix](../MILESTONES.md) | 8-phase execution roadmap, deliverables, invariant contracts, and escalation triggers | Confirmed Specification | Blueprint §36 | Phases 1 – 8 |
+| [AIENOS Architectural Milestones Matrix](../MILESTONES.md) | 8-phase execution roadmap, deliverables, invariant contracts, and escalation triggers | Confirmed Specification | Blueprint §36 | Phases 1 to 8 |
| [AIENOS Governing Architecture](../ARCHITECTURE.md) | High-level system overview, stack, trusted base, agent authority, security, and roadmap | Confirmed Architecture | Operator Directive | All Phases |
---
## 3. Operator Invariant Freeze Summary (2026-09-23)
-The operator confirmed immutable architectural invariants in ADR 0003–0007:
+The operator confirmed immutable architectural invariants in ADRs 0003 to 0007:
1. **ADR 0003 (Firmware Handoff & AIEN System Store)**: Firmware loads the immutable boot bundle only. Firmware services are bootstrap machinery, never a runtime dependency. Phase 3 introduces a minimal native AIEN System Store (immutable content-addressed extents `model/<hash>`, Cortex WAL + checkpoints, agent branches) rather than a general-purpose POSIX filesystem.
2. **ADR 0004 (Reversibility & AEGIS Egress Boundary)**: Reversibility requires that all observable state changes remain under AIENOS transactional control. Outbound network packets, telemetry, and external device state are external effects (`EffectIntent`) crossing into AEGIS even when read-only. Reversibility and authorization are decoupled via Standing Capabilities; network access never bypasses AEGIS under the guise of "reversible research."
3. **ADR 0005 (Unified Memory & C1 Block Accounting)**: Unified memory (NVLink-C2C) requires explicit block ownership across System, Model, KV Pool, Agent State, and Cortex budgets. C1 CoW prefix tree uses shared immutable blocks (`refcount > 1`) and private blocks (`refcount == 1`). Multi-branch divergence mandates transactional KV reservations prior to step admission to prevent mid-step OOM corruption. Logical identity survives; physical state is expendable.
4. **ADR 0006 (Recovery Core & Offline Authority)**: Recovery Core is an autonomous, deterministic subsystem operating completely outside the model, neural runtime, and network stack. Root authority and authentication are strictly local (offline physical credentials/passphrase). System updates use transactional A/B slot switching with deterministic kernel health milestone verification. Kernel panics write deterministic crash records to raw storage, and Cortex corruption is resolved via WAL truncation without semantic AI dependencies.
-5. **ADR 0007 (Continuous Existence & Provisioning-Once)**: AIEN is provisioned once. Boot, reboot, sleep, model reload, kernel restart, hardware failure, and migration are execution-state transitions—not agent creation events. Cold boot initializes hardware and never silently mints a replacement `LogicalAgentId`. Uncertain identity fails toward Recovery Core and operator decision, never toward false continuity. Gate order (1–10) is unchanged; continuous-existence acceptance criteria bind every gate.
+5. **ADR 0007 (Continuous Existence & Provisioning-Once)**: AIEN is provisioned once. Boot, reboot, sleep, model reload, kernel restart, hardware failure, and migration are execution-state transitions, not agent creation events. Cold boot initializes hardware and never silently mints a replacement `LogicalAgentId`. Uncertain identity fails toward Recovery Core and operator decision, never toward false continuity. Gate order (1 to 10) is unchanged; continuous-existence acceptance criteria bind every gate.
---
diff --git a/docs/crumbs/.crumb b/docs/crumbs/.crumb
index aca9512e ..e48c31f7 100644
--- a/docs/crumbs/.crumb
+++ b/docs/crumbs/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-14T01:16:45Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:5dc4f124f1c023aa4786f45336a671138fce9fa046478364cdc7454307d7b588 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 1,
- "generated_at_commit": "f78977a6ce33ea89a5b3b1952c0a0e403d4504fa ",
- "source_tree": "sha256:faea024f49787ed8180a590d705866486b71504ea61a285870ec3b8401eb5786 "
- },
"owner_lane": "",
"seed": {
"files": [
diff --git a/evidence/timer_window_starvation_2026-10-19/README.md b/evidence/timer_window_starvation_2026-10-19/README.md
new file mode 100644
index 00000000 ..977cbedb
--- /dev/null
+++ b/evidence/timer_window_starvation_2026-10-19/README.md
@@ -0,0 +1,31 @@
+# M1 timer window starvation (aienos#434 gate AIENOS-CK-QEMU-GATES, rc_nonzero), 2026-10-19
+
+## Symptom
+Judge run of aienos#434 head 49e6f6a : `AIENOS-CK-QEMU-GATES` FAIL rc_nonzero. The failing child was the
+Allen gate (`[allen] exit 1`), whose M1 checks (`scripts/lib_ck_m1_checks.sh`) rejected the timer window:
+"timer IRQ delivered fewer than five ticks" or "tick statistics out of range". The same head passes
+when the Spark is quiet (5/5 `qemu_ck_allen_test.sh` runs PASS), so the code under test was not at fault.
+
+## Cause
+`ck_timer_window` is wall-clock (200 ms). QEMU TCG shares the Spark with the whole hive (load 20 to 67).
+A starved vCPU runs fewer than five 10 ms ticks inside the 200 ms window, and `ck_timer_tick` read the
+counter a second time after re-arming, so a host stall between the two reads made one interval long and the
+next one short (min_us as low as 9 against a 10000 us period).
+
+## Fix (native/kernel/arch/timer.c, scripts/ck_gates.sh)
+1. An interval runs from IRQ entry to IRQ entry, the same counter value the next deadline is built from, so
+ it is never shorter than the period.
+2. The window keeps counting, up to 5 s, until five ticks have arrived. A dead timer still reports 0 ticks.
+3. A failing child's own FAIL lines are now copied into the gate's evidence blob (the child log lives in a
+ temp folder that is removed at exit, which is why the first failure could not be read afterwards).
+
+## Measurement (Spark, 20 boots of `scripts/qemu_ck_boot_test.sh` per arm, pinned to CPU 3 with 5 busy loops
+on the same CPU at the same nice level; `pinned-stress.sh`)
+| arm | pass | fail |
+|---|---|---|
+| before the fix (origin/main 18e2765 ) | 2 | 18 |
+| after the fix (fix/timer-window-starvation) | 20 | 0 |
+
+Red: `red-before-fix-fails.txt`, `red-before-fix-stats.txt`. Green: `green-after-fix-stats.txt`.
+Quiet machine, 5 runs of the Allen gate before the fix: 5/5 PASS (so the fix changes nothing when idle).
+Also run after the fix: `scripts/ck_gates.sh --self-test` PASS, `make -C native/kernel test` PASS (CK_CORE_HOST).
diff --git a/evidence/timer_window_starvation_2026-10-19/green-after-fix-stats.txt b/evidence/timer_window_starvation_2026-10-19/green-after-fix-stats.txt
new file mode 100644
index 00000000 ..7b050800
--- /dev/null
+++ b/evidence/timer_window_starvation_2026-10-19/green-after-fix-stats.txt
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/evidence/timer_window_starvation_2026-10-19/pinned-stress.sh b/evidence/timer_window_starvation_2026-10-19/pinned-stress.sh
new file mode 100644
index 00000000 ..0dded3dd
--- /dev/null
+++ b/evidence/timer_window_starvation_2026-10-19/pinned-stress.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+# usage: pinned-stress.sh WORKTREE N HOGS TAG : N boot tests pinned to CPU 3 with HOGS busy loops on CPU 3 (same nice), counts FAILs
+cd "$1" || exit 1
+D=$HOME/workspace/hermes-desk/allen-logs/$4; mkdir -p "$D"; : > "$D/fails.txt"
+for i in $(seq 1 "$3"); do timeout 1200 taskset -c 3 nice -n 19 sh -c 'while :; do :; done' & done
+pass=0; fail=0
+for i in $(seq 1 "$2"); do
+ taskset -c 3 nice -n 19 bash scripts/qemu_ck_boot_test.sh > "$D/run-$i.txt" 2>&1
+ rc=$?
+ if [ $rc = 0 ]; then pass=$((pass+1)); else fail=$((fail+1)); echo "run $i rc=$rc" >> "$D/fails.txt"; grep -h "^FAIL" "$D/run-$i.txt" >> "$D/fails.txt"; fi
+ grep -h "timer_irq\|timer_stats" "$D/run-$i.txt" | tr '\n' ' ' >> "$D/stats.txt"; echo >> "$D/stats.txt"
+done
+echo "$4 pass=$pass fail=$fail" >> $HOME/workspace/hermes-desk/allen-logs/summary.txt
+kill $(jobs -p) 2>/dev/null
diff --git a/evidence/timer_window_starvation_2026-10-19/red-before-fix-fails.txt b/evidence/timer_window_starvation_2026-10-19/red-before-fix-fails.txt
new file mode 100644
index 00000000 ..e04b0407
--- /dev/null
+++ b/evidence/timer_window_starvation_2026-10-19/red-before-fix-fails.txt
@@ -0,0 +1,38 @@
+run 1 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 2 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 3 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 4 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 5 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 6 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 7 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+FAIL tick statistics out of range: timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=0 avg_us=0 max_us=0
+run 10 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 11 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 12 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 13 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 14 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 15 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 16 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 17 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+FAIL tick statistics out of range: timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=0 avg_us=0 max_us=0
+run 18 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 19 rc=1
+FAIL timer IRQ delivered fewer than five ticks
+run 20 rc=1
+FAIL timer IRQ delivered fewer than five ticks
diff --git a/evidence/timer_window_starvation_2026-10-19/red-before-fix-stats.txt b/evidence/timer_window_starvation_2026-10-19/red-before-fix-stats.txt
new file mode 100644
index 00000000 ..8e1b3f15
--- /dev/null
+++ b/evidence/timer_window_starvation_2026-10-19/red-before-fix-stats.txt
@@ -0,0 +1,20 @@
+timer_irq: 3 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=22261 avg_us=63425 max_us=127049
+timer_irq: 2 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=22671 avg_us=99331 max_us=175990
+timer_irq: 1 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=189039 avg_us=189039 max_us=189039
+timer_irq: 1 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=251606 avg_us=251606 max_us=251606
+timer_irq: 2 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=28106 avg_us=127561 max_us=227016
+timer_irq: 2 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=18965 avg_us=65979 max_us=112993
+FAIL tick statistics out of range: timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=0 avg_us=0 max_us=0 timer_irq: 0 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=0 avg_us=0 max_us=0
+
+
+timer_irq: 1 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=64112 avg_us=64112 max_us=64112
+timer_irq: 1 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=234449 avg_us=234449 max_us=234449
+timer_irq: 1 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=128576 avg_us=128576 max_us=128576
+timer_irq: 3 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=18093 avg_us=67359 max_us=120038
+timer_irq: 3 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=61419 avg_us=83425 max_us=126006
+timer_irq: 2 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=63812 avg_us=125928 max_us=188044
+timer_irq: 2 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=120501 avg_us=124589 max_us=128677
+FAIL tick statistics out of range: timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=0 avg_us=0 max_us=0 timer_irq: 0 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=0 avg_us=0 max_us=0
+timer_irq: 2 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=62871 avg_us=125027 max_us=187183
+timer_irq: 2 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=63837 avg_us=125671 max_us=187505
+timer_irq: 1 ticks in 200 ms timer_stats: intid=30 freq_hz=62500000 period_us=10000 min_us=62338 avg_us=62338 max_us=62338
diff --git a/native/.crumb b/native/.crumb
index dbbce44e ..14e7ba1a 100644
--- a/native/.crumb
+++ b/native/.crumb
@@ -46,79 +46,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "50aa2fbd6ca356b7703517bc7ecf439f7b6e0a6b935d0ca6ca4c6f7caf23ce34 ",
- "last_commit": "4bd49ca ",
- "name": "argus",
- "purpose": "Directory native/argus. Purpose not yet described by a human."
- },
- {
- "digest": "7bd231b92b38492fbb936e28caa803047edd9250800eac92fe56e09d38bf98cd ",
- "last_commit": "bfea771 ",
- "name": "boot",
- "purpose": "Directory native/boot. Purpose not yet described by a human."
- },
- {
- "digest": "750c519c466783ed6330a6a2c8fcb2153efdaadb9d65b38a6a85e8463d78b68d ",
- "last_commit": "4bd49ca ",
- "name": "capability",
- "purpose": "Directory native/capability. Purpose not yet described by a human."
- },
- {
- "digest": "0a3e98a5f36f528eb7ae6e1611d466343068780b9029621286b292ec1c796950 ",
- "last_commit": "4bd49ca ",
- "name": "crypto",
- "purpose": "Directory native/crypto. Purpose not yet described by a human."
- },
- {
- "digest": "99bc55e79695290b65ae08a38e5731e3ed976d79cdb3b6c9bc21c706b1ddab22 ",
- "last_commit": "4bd49ca ",
- "name": "disk",
- "purpose": "Directory native/disk. Purpose not yet described by a human."
- },
- {
- "digest": "7a81b1b4b47154e15b9682b72d7fa49f309454f093aeb019061b8148550920ae ",
- "last_commit": "3037967 ",
- "name": "kernel",
- "purpose": "Directory native/kernel. Purpose not yet described by a human."
- },
- {
- "digest": "a805df7e3af4b8a2ef345223523b54e7e47565204ec8f8e598f6dcaf53b07419 ",
- "last_commit": "4bd49ca ",
- "name": "m5",
- "purpose": "Directory native/m5. Purpose not yet described by a human."
- },
- {
- "digest": "ff5c88f5e9bf86e7ff836d24c048dd2d4efc94f6f19a21a0caf72ae9c402deaf ",
- "last_commit": "4bd49ca ",
- "name": "net",
- "purpose": "Directory native/net. Purpose not yet described by a human."
- },
- {
- "digest": "135fd1edbe2388764de7dc755611b483b0c61adab858718c390b7745d141635c ",
- "last_commit": "4bd49ca ",
- "name": "sig",
- "purpose": "Directory native/sig. Purpose not yet described by a human."
- },
- {
- "digest": "f75197d76b7daaeee8223cf25353251824cd4497400a439724a3a424e014a229 ",
- "last_commit": "4bd49ca ",
- "name": "store",
- "purpose": "Directory native/store. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:cec690f1b64aaba9f5f7ea41048a25c5b3cdf4834f672e977dc7eb47d34e4be2 ",
- "compiled_at": "2026-10-17T01:49:45Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:64cc87f8507bb580e1788d335c5a76039f3e3a016552595526718448ab5aa098 ",
- "evidence_files": 4,
- "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335 ",
- "files": 606,
- "generated_at_commit": "30379678add587e388db4e11713d6bca8d159b08 ",
- "source_tree": "sha256:1d9fe182bcaa94de3564ee02f9e8c63bddcea00fcea22feed112ffe6e01a1b78 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/argus/.crumb b/native/argus/.crumb
index ac2f33a7 ..155e0b65 100644
--- a/native/argus/.crumb
+++ b/native/argus/.crumb
@@ -18,37 +18,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "8fa25040d5da98cfa76b5c39ed4b48f9f02252e42b00d0eaf84b99265813c0f1 ",
- "last_commit": "1625f69 ",
- "name": "bridge",
- "purpose": "Directory native/argus/bridge. Purpose not yet described by a human."
- },
- {
- "digest": "c519b9b561e14e4c8017f79c86093d14b250c72e5c17258d77507130dd420a44 ",
- "last_commit": "09e59a8 ",
- "name": "docs",
- "purpose": "Directory native/argus/docs. Purpose not yet described by a human."
- },
- {
- "digest": "9da71b144b276a79663b8240d09f6ee8ec187a336b45c48dc47adeca8012a11c ",
- "last_commit": "130aa20 ",
- "name": "tests",
- "purpose": "Directory native/argus/tests. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:60f887eb1e514a9e647f622c81848e2accd452e38b157103e8a9f58a32bb1694 ",
- "compiled_at": "2026-10-14T13:28:10Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:50aa2fbd6ca356b7703517bc7ecf439f7b6e0a6b935d0ca6ca4c6f7caf23ce34 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 47,
- "generated_at_commit": "a0fa796235409ce465c467e8c72fbd977485d8f7 ",
- "source_tree": "sha256:9511497343ad28d30fb7c58c0d11c87ab936d6e95ff561bf245ea2e5acbbb4f1 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/argus/bridge/.crumb b/native/argus/bridge/.crumb
index 4b34c68b ..9e93e9fd 100644
--- a/native/argus/bridge/.crumb
+++ b/native/argus/bridge/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:8fa25040d5da98cfa76b5c39ed4b48f9f02252e42b00d0eaf84b99265813c0f1 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 2,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:f6e5004e675b332b7d7173fba4c502a341aec78a02e2e917f0092f83cf39b401 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/argus/docs/.crumb b/native/argus/docs/.crumb
index 04dcec57 ..1aae1188 100644
--- a/native/argus/docs/.crumb
+++ b/native/argus/docs/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-14T01:16:45Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:c519b9b561e14e4c8017f79c86093d14b250c72e5c17258d77507130dd420a44 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 5,
- "generated_at_commit": "f78977a6ce33ea89a5b3b1952c0a0e403d4504fa ",
- "source_tree": "sha256:e107063b520edc71b65a5716f848d41682145c2f69d9acde5b291834208eea85 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/argus/tests/.crumb b/native/argus/tests/.crumb
index 8bba1f25 ..c7c18abd 100644
--- a/native/argus/tests/.crumb
+++ b/native/argus/tests/.crumb
@@ -10,18 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-14T13:28:10Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:9da71b144b276a79663b8240d09f6ee8ec187a336b45c48dc47adeca8012a11c ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 24,
- "generated_at_commit": "a0fa796235409ce465c467e8c72fbd977485d8f7 ",
- "source_tree": "sha256:9b3b6e1d929d015275c4ed69028acc5b2ea489d66c53540908bb375803fa13f1 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/argus/tests/fixtures/argus1/.crumb b/native/argus/tests/fixtures/argus1/.crumb
index d6e458ec ..a11a4c20 100644
--- a/native/argus/tests/fixtures/argus1/.crumb
+++ b/native/argus/tests/fixtures/argus1/.crumb
@@ -4,18 +4,6 @@
"path": "../.."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:6015c201f5b44accd324bff7b333661ce3fec741c4df4cb97cff7dc88bbb6136 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 4,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:9981995798edce4b48ab377bc2702188e98e7c9d45456eb3e8584f99ba7c13c1 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/boot/.crumb b/native/boot/.crumb
index cc53e7fd ..a879ca1c 100644
--- a/native/boot/.crumb
+++ b/native/boot/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-16T23:33:50Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:7bd231b92b38492fbb936e28caa803047edd9250800eac92fe56e09d38bf98cd ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 26,
- "generated_at_commit": "4bd49ca164761fe66c6eb339acabdbcc84e8a33c ",
- "source_tree": "sha256:57b9a2e0d628acd6b2c2d1dab4fc1a4eafec507bc2601b54d92f96fc46393666 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/capability/.crumb b/native/capability/.crumb
index 5c3d300d ..9163c9f4 100644
--- a/native/capability/.crumb
+++ b/native/capability/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "78115cdbda04ee0b7568424dbdba2833bd201f01118cf01464cb17653fc26aee ",
- "last_commit": "b84c0a6 ",
- "name": "tests",
- "purpose": "Directory native/capability/tests. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:0c70cfa122966e11065bca94434dcb159c75a4557cf6322bbc5256e28d49f2e5 ",
- "compiled_at": "2026-10-14T14:58:51Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:750c519c466783ed6330a6a2c8fcb2153efdaadb9d65b38a6a85e8463d78b68d ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 8,
- "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84 ",
- "source_tree": "sha256:bb4b4f4706f6b22f2cb4a92ec9ed82733cff2ef5c3a626843e3ee584785e8b9b "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/capability/tests/.crumb b/native/capability/tests/.crumb
index aab86d5f ..b55bf613 100644
--- a/native/capability/tests/.crumb
+++ b/native/capability/tests/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-06T14:20:29Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:78115cdbda04ee0b7568424dbdba2833bd201f01118cf01464cb17653fc26aee ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 2,
- "generated_at_commit": "2529de3fb99083fbf46e3b028806efd8b2789259 ",
- "source_tree": "sha256:f9e15c7c882c1946001bb923ff71e3650d0bb777a187a228a21df8d21decb860 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/crypto/.crumb b/native/crypto/.crumb
index bd1d3cb2 ..b261158d 100644
--- a/native/crypto/.crumb
+++ b/native/crypto/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "dac1583f9b7627f80272af9cf90ef4e62dccc25593f8c4ee1ffbc2471b8f3462 ",
- "last_commit": "a4bba0c ",
- "name": "tests",
- "purpose": "Directory native/crypto/tests. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:db2c6d092f9d97c30dc5cc4531ae25cb558d206d66ca31f94ca14d0ff2cfacea ",
- "compiled_at": "2026-10-14T14:58:51Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:0a3e98a5f36f528eb7ae6e1611d466343068780b9029621286b292ec1c796950 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 10,
- "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84 ",
- "source_tree": "sha256:25932bcca4e7eea369babe75a4e82b72000bb1d1b2437272f2c2a73fb70ffd57 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/crypto/tests/.crumb b/native/crypto/tests/.crumb
index 3e27d979 ..a266c206 100644
--- a/native/crypto/tests/.crumb
+++ b/native/crypto/tests/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:dac1583f9b7627f80272af9cf90ef4e62dccc25593f8c4ee1ffbc2471b8f3462 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 1,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:8d8a1d7e007ce2f36bca8e9edb7c6e6849804b50612c56b412d739a2603ed907 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/disk/.crumb b/native/disk/.crumb
index 0d481d00 ..9db8f080 100644
--- a/native/disk/.crumb
+++ b/native/disk/.crumb
@@ -14,31 +14,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "54a25a2ce38d5cde54cce87582dfdcd66b3f21ba3ae18d330c8c66a7004b386a ",
- "last_commit": "2563059 ",
- "name": "qemu",
- "purpose": "Directory native/disk/qemu. Purpose not yet described by a human."
- },
- {
- "digest": "28bc8b4021cec8ccd5b90c15d11db3fe7dd396db65e062f5e1046631fa2e4755 ",
- "last_commit": "2563059 ",
- "name": "tests",
- "purpose": "Directory native/disk/tests. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:fb9a25a745be4f0d38936d5ff30f3fafdc68a80d6aaeff667fde54d196d6b132 ",
- "compiled_at": "2026-10-14T14:58:51Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:99bc55e79695290b65ae08a38e5731e3ed976d79cdb3b6c9bc21c706b1ddab22 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 20,
- "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84 ",
- "source_tree": "sha256:667e44de55a53f223607fe87bd5ccd445c674f962fd5baa7570a467b3fedeb1a "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/disk/qemu/.crumb b/native/disk/qemu/.crumb
index c6819a14 ..d49b9070 100644
--- a/native/disk/qemu/.crumb
+++ b/native/disk/qemu/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-13T05:44:11Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:54a25a2ce38d5cde54cce87582dfdcd66b3f21ba3ae18d330c8c66a7004b386a ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 6,
- "generated_at_commit": "1994c4f8c4e8521d7febed45306515aa5085f207 ",
- "source_tree": "sha256:4d0fc11e9b44f17aac5aaf0d404e6a384fb933c953e68d948403f563f6a054d4 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/disk/tests/.crumb b/native/disk/tests/.crumb
index 92672421 ..2e1d691f 100644
--- a/native/disk/tests/.crumb
+++ b/native/disk/tests/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-13T05:44:11Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:28bc8b4021cec8ccd5b90c15d11db3fe7dd396db65e062f5e1046631fa2e4755 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 3,
- "generated_at_commit": "1994c4f8c4e8521d7febed45306515aa5085f207 ",
- "source_tree": "sha256:cccd4c2564da56cc8dfc304b792f4f7949c5fa157a28feb973042d2dd93d93cb "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/.crumb b/native/kernel/.crumb
index 57d1b019 ..268d86f2 100644
--- a/native/kernel/.crumb
+++ b/native/kernel/.crumb
@@ -42,73 +42,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "8f63182b423b274a3fa6dcf0a17811343f93bd1539e33479102ffa87935da1ca ",
- "last_commit": "4bd49ca ",
- "name": "arch",
- "purpose": "Directory native/kernel/arch. Purpose not yet described by a human."
- },
- {
- "digest": "cd3be26829bc7f947521b1e5df144df2504ef25a3763ec0356861b7d17d5d901 ",
- "last_commit": "4bd49ca ",
- "name": "artifact",
- "purpose": "Directory native/kernel/artifact. Purpose not yet described by a human."
- },
- {
- "digest": "c9035b8f32a9539fe8d1f93ed968b3b56dd3ba4c2630b32b6c286b1dbd19d908 ",
- "last_commit": "4bd49ca ",
- "name": "core",
- "purpose": "Directory native/kernel/core. Purpose not yet described by a human."
- },
- {
- "digest": "ebdd66c0966fba664f36dc167836b98d26ffae97f9502b4409e9c22da687b473 ",
- "last_commit": "4bd49ca ",
- "name": "dev",
- "purpose": "Directory native/kernel/dev. Purpose not yet described by a human."
- },
- {
- "digest": "8198bb9a0fbd634281a251b012eca8874c97e469a45eec8b5a6bf06a7e828f9a ",
- "last_commit": "4bd49ca ",
- "name": "include",
- "purpose": "Directory native/kernel/include. Purpose not yet described by a human."
- },
- {
- "digest": "8252fab960e4a3bb686f2e864b0d9a0571f43381d5006de2ff6c134c132ef092 ",
- "last_commit": "4bd49ca ",
- "name": "mm",
- "purpose": "Directory native/kernel/mm. Purpose not yet described by a human."
- },
- {
- "digest": "2a98333d826d94a7131119aaeb5a15d8bc543baa5531fa930e6f0afc1fccb83d ",
- "last_commit": "4bd49ca ",
- "name": "svc",
- "purpose": "Directory native/kernel/svc. Purpose not yet described by a human."
- },
- {
- "digest": "0f3d28a645346382567a7a279a3e02a095c8e7f298967db175944c0a58ca9c5d ",
- "last_commit": "3037967 ",
- "name": "tests",
- "purpose": "Directory native/kernel/tests. Purpose not yet described by a human."
- },
- {
- "digest": "412f0a290f187935193ec94f1817c46dbe0edc07a5eb427e39977b65c1d00f9f ",
- "last_commit": "3037967 ",
- "name": "tools",
- "purpose": "Hosted (Linux-built) checkers for the native kernel, run by `make -C native/kernel test`; nothin"
- }
- ],
- "children_root": "sha256:658a040f493b6ff9dc4a775b2b73a0c89ded592a235231016dd8594094530e0f ",
- "compiled_at": "2026-10-17T01:49:45Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:7a81b1b4b47154e15b9682b72d7fa49f309454f093aeb019061b8148550920ae ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 421,
- "generated_at_commit": "30379678add587e388db4e11713d6bca8d159b08 ",
- "source_tree": "sha256:cfa9d56bd0bae125be856e13a57758e007e620d1fc9501643728e676f53eaabe "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/GATES.md b/native/kernel/GATES.md
index b7e37370 ..cf9840d9 100644
--- a/native/kernel/GATES.md
+++ b/native/kernel/GATES.md
@@ -858,6 +858,33 @@ real asynchronous events. (4) Numeric resource-class and operation ids, the REVO
are this adapter's choices (UNVERIFIED against a frozen contract). (5) The request digest covers the request cells and the OUT
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.
+## PIPE: the native bounded byte pipe (AIENOS-NATIVE-PIPE-1, aienos-mv#428) -> CK `PIPE` (scripts/qemu_ck_pipe_test.sh)
+
+Label: **QEMU (aarch64 virt), TEST build, not physical.** Host and QEMU evidence qualify nothing physical; nothing here ran on
+a Spark, a Pi or the iMac. Contract: OSH_PLATFORM_ABI sections 4.4, 8.1, 8.5, 8.6, 9 read at aien-protocols-mv `fb5fca98e667 `
+(v1 DRAFT, unfrozen). The image is `make CK_PIPE_TEST=1` (own OUT `target/native-kernel-test-pipe`, refused with
+`CK_HARDWARE_STAGING` and `CK_SERVICE`; default images are checked to carry no trace of it). After `kernel: alive` it runs
+`core/pipe_test.c`: a producer and a consumer task, step functions interleaved by `core/sched.c`, each holding one end of a
+`core/pipe.c` pipe in its own capability table (`core/ipc.c`), through the same driver as the host test (`core/pipe_drive.h`);
+then the boot goes on to its report and PSCI reset. Checks, one boot, every one with both tables and the pool empty afterwards:
+160 KiB payload with every fifth byte NUL byte for byte; a slow consumer fills the 64 KiB pipe and the producer sees WOULD_BLOCK;
+EOF after the last writer closes; never more than the capacity buffered; the blocking variant parks and wakes through the
+scheduler; BROKEN_PIPE with no reader; a write after revoke refused with 0 bytes delivered after it; a revoke mid-transfer with no
+read succeeding afterwards; a closed handle STALE after its slot is reused; an unknown op and another ABI version NOT_SUPPORTED;
+cancel INTERRUPTED once with no byte moved. Host test `test_pipe` (the 20-case corpus in `tests/fixtures/pipe/` plus the
+scheduler transfers, also under ASan+UBSan); a mutant that skips the write-right check must fail it (`make pipe-mutant`).
+Limits: (1) the kernel's wait hook yields cooperatively to the scheduler inside one kernel thread; blocking a real M3 thread with
+a context switch is not exercised. (2) Revoke, close and cancel "while waiting" are run by the peer task's step or the host test's
+scripted wait hook, not by asynchronous interrupts. (3) The op ids, the call frame cell layout, the second return value of
+PIPE_CREATE, the capability resource layout, the pool size (4 pipes) and STREAM_DUP's capability form (rights and a target table
+instead of a descriptor number) are this kernel's choices, UNVERIFIED against a frozen contract. (4) A ck_cap_table has 8 slots,
+below the draft's "3 standard streams plus 16 open streams" per session; a session with more streams needs a larger table.
+(5) No QEMU negative control mutates the kernel image; the red-before-green control is the host mutant.
+
+| # | Check | CK gate | Status |
+|---|---|---|---|
+| 221 | `CK_PIPE_TEST=1` image: 11 `pipe_check` lines PASS with `tables_empty=1`, `pipe_test: done checks=11 failed=0 capacity=65536 pool_pipes=4`, payload detail `bytes=163840 ... mismatches=0 would_block>0`, revoked write `n=0 ... bytes_delivered=0`, boot report reached, no panic, QEMU exit 0 | PIPE | QEMU PASS (2026-10-18, base ee34c7d plus this change, QEMU 8.2.2, AIENOS_CK_PIPE PASS; hardware NOT_RUN) |
+
## LIFECYCLE: resident production lifecycle (native v1 plan P03, P04 cuts 1-2b, P05 cut 1, P06 cuts 2-4; C-only) -> CK `LIFECYCLE` (scripts/qemu_ck_lifecycle_test.sh)
diff --git a/native/kernel/Makefile b/native/kernel/Makefile
index 20a92ad3 ..7dd30fb5 100644
--- a/native/kernel/Makefile
+++ b/native/kernel/Makefile
@@ -464,6 +464,21 @@ endif
OUT ?= $(REPO)/target/native-kernel-test-rollback-$(strip $(CK_TEST_ROLLBACK))
SMP_TEST_FLAGS += -DCK_TEST_ROLLBACK_$(subst -,_,$(shell echo '$(strip $(CK_TEST_ROLLBACK))' | tr a-z A-Z))=1
endif
+# AIENOS-NATIVE-PIPE-1 (aienos-mv#428): CK_PIPE_TEST=1 adds the TEST-ONLY pipe self-test (core/pipe_test.c, gate
+# scripts/qemu_ck_pipe_test.sh): after "kernel: alive" it drives the pipe primitive (core/pipe.c) with a producer and a
+# consumer task through the scheduler and prints pipe_check lines. Own OUT; announces itself; refused with
+# CK_HARDWARE_STAGING and CK_SERVICE. Default images are checked to carry no trace of it (pipe_check).
+CK_PIPE_TEST ?=
+ifneq ($(strip $(CK_PIPE_TEST)),)
+ifneq ($(strip $(CK_PIPE_TEST)),1)
+$(error CK_PIPE_TEST must be empty or 1)
+endif
+ifneq ($(strip $(CK_HARDWARE_STAGING)),)
+$(error CK_PIPE_TEST (TEST-only pipe self-test) cannot be combined with CK_HARDWARE_STAGING)
+endif
+OUT ?= $(REPO)/target/native-kernel-test-pipe
+SMP_TEST_FLAGS += -DCK_PIPE_TEST=1
+endif
# SLOTLDR.EFI trusted keys (native v1 plan P11 cut 2a; native/boot/slot_loader.c,
# make slot-loader):
# CK_SLOT_KEYS=<file> owner public keys, "owner_root_ed25519 <64 hex>" lines
@@ -644,7 +659,7 @@ endif
ifneq ($(strip $(CK_CONSOLE_SESSION)),)
$(error CK_SERVICE cannot be combined with CK_CONSOLE_SESSION)
endif
-ifneq ($(strip $(CK_TEST_XHCI_MUTATION)$(CK_TEST_STORE_CRASH)$(CK_TEST_CONTINUITY)$(CK_TEST_FWCFG_ARTIFACTS)$(CK_TEST_SMP_SKIP_CPU)$(CK_TEST_ROLLBACK)$(CK_TEST_STALE_HANDOFF)$(CK_TEST_DISK_XLATE_BYPASS)),)
+ifneq ($(strip $(CK_TEST_XHCI_MUTATION)$(CK_TEST_STORE_CRASH)$(CK_TEST_CONTINUITY)$(CK_TEST_FWCFG_ARTIFACTS)$(CK_TEST_SMP_SKIP_CPU)$(CK_TEST_ROLLBACK)$(CK_TEST_STALE_HANDOFF)$(CK_TEST_DISK_XLATE_BYPASS)$(CK_PIPE_TEST)),)
$(error CK_SERVICE cannot be combined with a CK_TEST_* flag)
endif
endif
@@ -912,6 +927,9 @@ ART_C += $(KDIR)/core/artifact_card.c $(KDIR)/core/artifact_card_stage.c
CORE_C += $(BOOT)/efi_artifact.c
endif
CORE_C += $(ART_C)
+ifeq ($(strip $(CK_PIPE_TEST)),1)
+CORE_C += $(KDIR)/core/pipe.c $(KDIR)/core/pipe_test.c
+endif
CORE_S := $(BOOT)/efi_entry.S $(KDIR)/arch/vectors.S $(KDIR)/arch/m3.S $(KDIR)/arch/smp_entry.S
HDRS := $(wildcard $(KDIR)/include/*.h $(KDIR)/*/*.h $(BOOT)/*.h)
@@ -1207,6 +1225,15 @@ define rollback_check
fi
endef
+# pipe_check(elf): only a CK_PIPE_TEST image may carry the TEST-only pipe self-test, and it must announce itself.
+define pipe_check
+ @if [ "$(strip $(CK_PIPE_TEST))" = 1 ]; then \
+ grep -aqF "TEST-ONLY pipe self-test" $(1) || { echo "pipe test image lacks its TEST-ONLY announcement"; rm -f $(1); exit 1; }; \
+ else \
+ if grep -aqF "TEST-ONLY pipe self-test" $(1); then echo "default image carries the TEST-ONLY pipe self-test"; rm -f $(1); exit 1; fi; \
+ fi
+endef
+
# smp_check(elf): only a CK_TEST_SMP_SKIP_CPU image may carry the SMP mutation
# announcement, and such an image must carry it.
define smp_check
@@ -1298,6 +1325,7 @@ $(ELF): $(CORE_OBJS) $(BOOT)/image.ld
@if [ -z "$(strip $(CK_TEST_STALE_HANDOFF))" ] && grep -aqF "TEST-ONLY stale handoff" $@; then \
echo "default image carries the TEST-only stale handoff"; rm -f $@; exit 1; fi
$(call rollback_check,$@)
+ $(call pipe_check,$@)
@s=$$($(KNM) $@ | grep -E ' [TtDdBbWwVv] ck_stage_(devices|security|store|quiesce)$$' || true); \
if [ -n "$$s" ]; then echo "core image defines stage symbols: $$s"; rm -f $@; exit 1; fi
$(call fwcfg_check,$@)
@@ -1307,6 +1335,7 @@ $(ELF): $(CORE_OBJS) $(BOOT)/image.ld
$(FULL_ELF): $(CORE_OBJS) $(STAGE_BUILT) $(BOOT)/image.ld
$(call link_image,$@,$(CORE_OBJS) $(STAGE_LINK) $(CK_RUST_LIBS) $(CK_INFER_LIB))
$(call rollback_check,$@)
+ $(call pipe_check,$@)
@for s in $(FULL_STAGE_SYMS); do \
$(KNM) $@ | grep -qE " [TW] $$s$$" || { echo "full image lacks $$s"; rm -f $@; exit 1; }; done
$(call fwcfg_check,$@)
@@ -1332,7 +1361,7 @@ HOST_SRCS := $(KDIR)/core/fmt.c $(KDIR)/core/acpi.c $(KDIR)/core/smmu.c $(KDIR)/
$(KDIR)/core/line_rx.c $(KDIR)/core/klog.c $(KDIR)/core/klog_slot.c $(KDIR)/core/cpufeat.c $(KDIR)/core/unlock_req.c $(KDIR)/core/agent_cmd.c $(KDIR)/core/artifact_card.c
TESTS := test_fmt test_frames test_pt test_acpi test_acpi_dev test_heap test_smmu test_sched test_ipc test_artifact test_osc_unit test_osc_launch test_osc_admit test_osc_receipt test_entropy test_handoff test_fbcon test_osh_op \
test_continuity_codec test_continuity_resolve test_continuity_commit test_continuity_recovery test_continuity_geometry \
- test_continuity_subject test_continuity_subject_provision test_lifecycle test_console_rx test_klog test_klog_slot test_pi5 test_pi5_marker test_pi5_rng test_cpufeat test_dma_window test_pi5_pcie test_pi5_net test_pi5_gem test_unlock_req test_context test_agent_cmd test_artifact_card
+ test_continuity_subject test_continuity_subject_provision test_lifecycle test_console_rx test_klog test_klog_slot test_pi5 test_pi5_marker test_pi5_rng test_cpufeat test_dma_window test_pi5_pcie test_pi5_net test_pi5_gem test_unlock_req test_context test_agent_cmd test_artifact_card test_pipe
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
@@ -1365,6 +1394,29 @@ osh-op-mutant: $(OUT)/host/test_osh_op_mutant
@if $< > $<.log 2>&1; then cat $<.log; echo "test_osh_op mutant (permission check always OK): PASSED, test does not catch it"; exit 1; \
else grep -F "test_osh_op: FAIL" $<.log && echo "test_osh_op mutant (permission check always OK): FAILS as required"; fi
+# Native pipe primitive (core/pipe.c, aienos-mv#428): pure logic over ipc.c capability tables, driven through sched.c by
+# core/pipe_drive.h. Own rule: the test reads the fixture corpus in tests/fixtures/pipe/.
+PIPE_SRCS := $(KDIR)/core/pipe.c $(KDIR)/core/ipc.c $(KDIR)/core/sched.c
+PIPE_DEPS := $(KDIR)/tests/test_pipe.c $(PIPE_SRCS) $(KDIR)/tests/ck_test.h $(HDRS) $(wildcard $(KDIR)/tests/fixtures/pipe/*)
+PIPE_DEF := -DPIPE_FIXTURE_DIR='"$(abspath $(KDIR)/tests/fixtures/pipe)"'
+$(OUT)/host/test_pipe: $(PIPE_DEPS)
+ @mkdir -p $(dir $@)
+ $(HOSTCC) $(HCFLAGS) $(PIPE_DEF) -o $@ $< $(PIPE_SRCS)
+
+$(OUT)/host-san/test_pipe: $(PIPE_DEPS)
+ @mkdir -p $(dir $@)
+ $(HOSTCC) $(HCFLAGS) $(SANFLAGS) $(PIPE_DEF) -o $@ $< $(PIPE_SRCS)
+
+# TEST-ONLY mutant of core/pipe.c: a write does not check the WRITE right or the end. test_pipe must FAIL against it
+# (red before green); "make test" fails if the test stops catching it. Host only.
+$(OUT)/host/test_pipe_mutant: $(PIPE_DEPS)
+ @mkdir -p $(dir $@)
+ $(HOSTCC) $(HCFLAGS) $(PIPE_DEF) -DCK_PIPE_MUTANT_SKIP_RIGHTS -o $@ $< $(PIPE_SRCS)
+
+pipe-mutant: $(OUT)/host/test_pipe_mutant
+ @if $< > $<.log 2>&1; then cat $<.log; echo "test_pipe mutant (write right not checked): PASSED, test does not catch it"; exit 1; \
+ else grep -F "test_pipe: FAIL" $<.log && echo "test_pipe mutant (write right not checked): FAILS as required"; fi
+
# N3 context assembly + approval binding (core/context.c, core/context_proposal.c, aienos#329): pure logic over
# the argus SHA-256. Own rule (needs sha256.c). The mutant skips the foreign-binding check: test_context must
# FAIL against it (red before green); "make test" fails if the test stops catching it. Host only (context.c
@@ -1484,8 +1536,8 @@ smmu-l2-mutants: $(OUT)/host/test_smmu
else echo "mutant flag refused under CK_HARDWARE_STAGING"; fi; \
if [ $$fail = 0 ]; then echo "CK_SMMU_L2_MUTANTS: PASS"; else echo "CK_SMMU_L2_MUTANTS: FAIL"; exit 1; fi
-test: $(addprefix $(OUT)/host/,$(TESTS)) osc-receipt-mutants osc-receipt-release handoff-mutant acpi-dev-mutant iort-mutants smmu-l2-mutants osh-op-mutant context-mutant agent-cmd-mutant artifact-card-mutant artifact-tier-pi5 artifact-tier-mutant test-continuity-subject-restart gsp-fw-inspect-test gsp-cot-test gsp-bindata-test gsp-bootargs-test gsp-rpc-test slot-test slot-free package-test slot-loader-check
- @fail=0; for t in $(filter-out osc-receipt-mutants osc-receipt-release handoff-mutant acpi-dev-mutant iort-mutants smmu-l2-mutants osh-op-mutant context-mutant agent-cmd-mutant artifact-card-mutant artifact-tier-pi5 artifact-tier-mutant test-continuity-subject-restart gsp-fw-inspect-test gsp-cot-test gsp-bindata-test gsp-bootargs-test gsp-rpc-test slot-test slot-free package-test slot-loader-check,$^); do $$t || fail=1; done; \
+test: $(addprefix $(OUT)/host/,$(TESTS)) osc-receipt-mutants osc-receipt-release handoff-mutant acpi-dev-mutant iort-mutants smmu-l2-mutants osh-op-mutant pipe-mutant context-mutant agent-cmd-mutant artifact-card-mutant artifact-tier-pi5 artifact-tier-mutant test-continuity-subject-restart gsp-fw-inspect-test gsp-cot-test gsp-bindata-test gsp-bootargs-test gsp-rpc-test slot-test slot-free package-test slot-loader-check
+ @fail=0; for t in $(filter-out osc-receipt-mutants osc-receipt-release handoff-mutant acpi-dev-mutant iort-mutants smmu-l2-mutants osh-op-mutant pipe-mutant context-mutant agent-cmd-mutant artifact-card-mutant artifact-tier-pi5 artifact-tier-mutant test-continuity-subject-restart gsp-fw-inspect-test gsp-cot-test gsp-bindata-test gsp-bootargs-test gsp-rpc-test slot-test slot-free package-test slot-loader-check,$^); do $$t || fail=1; done; \
if [ $$fail = 0 ]; then echo "CK_CORE_HOST: PASS"; else echo "CK_CORE_HOST: FAIL"; exit 1; fi
sanitize: $(addprefix $(OUT)/host-san/,$(TESTS))
@@ -2241,17 +2293,32 @@ imac-diag: $(IMACDIAG_EFI)
# (GDT/TSS/IDT, own page tables, guard page, HPET-timed TSC, local APIC timer, ACPI S5)
# + x86/pci_x86.c (PCI walk; AHCI via x86/ahci_x86.c and NVMe via ../disk/disk_nvme.c, both
# read-only, GPT checked by dev/disk_part.c; a look at the Ethernet chip) + x86/smp_x86.S
-# (secondary cores started and parked) + x86/tg3_x86.c (BCM57766 Ethernet, transmit only) and
-# x86/report_x86.c with ../../net/aienos_net.c (the screen sent as UDP broadcasts during the hold;
-# host test scripts/ck_imac_report_test.sh, receiver tools/ck_imac_report_listen.c)
+# (secondary cores started and parked) + x86/tg3_x86.c (BCM57766 Ethernet: link detection; no
+# transmit in the default image)
# + x86/trap.S + x86/console_x86.c (COM1 when present, GOP framebuffer), on the
# arch-neutral core: fbcon, fmt, acpi, handoff_check, frames, heap. Same toolchain and PE
# header as IMACDIAG. Copy to a FAT stick as EFI/BOOT/BOOTX64.EFI.
# make imac-kernel -> $(OUT)/IMACKERN.EFI QEMU test: scripts/qemu_ck_imac_kernel_test.sh
+# The network report is a LAB-ONLY diagnostic, opt-in and default off:
+# make imac-kernel CK_X86_REPORT=1 -> $(OUT)/IMACKERN-LAB.EFI (own object dir)
+# adds x86/report_x86.c + ../../net/aienos_net.c and tg3 transmit (-DCK_X86_REPORT=1): during the
+# hold it broadcasts only allowlisted console lines (ck_x86_report_filter, never the raw console)
+# as UDP to port 47031, header "AIENOS-IMAC-REPORT v=2 auth=none": UNAUTHENTICATED, never a
+# receipt, evidence or a command. Host test scripts/ck_imac_report_test.sh, receiver
+# tools/ck_imac_report_listen.c. The default image, and any resident or service (ALLEN) build,
+# must not contain it: the link step below fails a default image that has a report symbol.
+CK_X86_REPORT ?= 0
X86K := $(KDIR)/x86
+ifeq ($(CK_X86_REPORT),1)
+IMACKERN_DIR := $(OUT)/imackern-lab
+IMACKERN_EFI := $(OUT)/IMACKERN-LAB.EFI
+else ifeq ($(CK_X86_REPORT),0)
IMACKERN_DIR := $(OUT)/imackern
-IMACKERN_ELF := $(IMACKERN_DIR)/imackern.elf
IMACKERN_EFI := $(OUT)/IMACKERN.EFI
+else
+$(error CK_X86_REPORT must be 0 (default) or 1 (lab-only network report))
+endif
+IMACKERN_ELF := $(IMACKERN_DIR)/imackern.elf
IMACKERN_CFLAGS := $(X86CFLAGS) -I$(KDIR)/include -I$(KDIR)/mm -I$(KDIR)/dev -I$(NATIVE)/disk -I$(NATIVE)/net
IMACKERN_OBJS := $(IMACKERN_DIR)/efi_entry_x86_64.o $(IMACKERN_DIR)/efi_x86.o $(IMACKERN_DIR)/efi_gop.o \
$(IMACKERN_DIR)/kmain_x86.o $(IMACKERN_DIR)/console_x86.o $(IMACKERN_DIR)/trap.o \
@@ -2259,7 +2326,14 @@ IMACKERN_OBJS := $(IMACKERN_DIR)/efi_entry_x86_64.o $(IMACKERN_DIR)/efi_x86.o $(
$(IMACKERN_DIR)/frames.o $(IMACKERN_DIR)/heap.o $(IMACKERN_DIR)/libc_min.o \
$(IMACKERN_DIR)/ahci_x86.o $(IMACKERN_DIR)/disk_part.o $(IMACKERN_DIR)/disk.o \
$(IMACKERN_DIR)/pci_x86.o $(IMACKERN_DIR)/smp_x86.o $(IMACKERN_DIR)/disk_nvme.o \
- $(IMACKERN_DIR)/tg3_x86.o $(IMACKERN_DIR)/report_x86.o $(IMACKERN_DIR)/aienos_net.o
+ $(IMACKERN_DIR)/tg3_x86.o
+IMACKERN_REPORT_OBJS := $(IMACKERN_DIR)/report_x86.o $(IMACKERN_DIR)/aienos_net.o
+# Symbols only the lab image may contain; the default image is checked for them after linking.
+IMACKERN_REPORT_SYMS := ck_x86_report_hold|ck_x86_report_frame|ck_x86_report_filter|ck_x86_report_parts|ck_x86_tg3_send|ck_x86_tg3_drain|net_udp_build
+ifeq ($(CK_X86_REPORT),1)
+IMACKERN_OBJS += $(IMACKERN_REPORT_OBJS)
+IMACKERN_CFLAGS += -DCK_X86_REPORT=1
+endif
IMACKERN_HDRS := $(X86K)/x86.h $(BOOT)/handoff.h $(BOOT)/efi.h $(KDIR)/core/ck_internal.h $(KDIR)/include/ck.h
$(IMACKERN_DIR)/efi_entry_x86_64.o: $(BOOT)/efi_entry_x86_64.S
$(IMACKERN_DIR)/efi_x86.o: $(X86K)/efi_x86.c $(IMACKERN_HDRS)
@@ -2283,7 +2357,7 @@ $(IMACKERN_DIR)/disk_nvme.o: $(NATIVE)/disk/disk_nvme.c $(NATIVE)/disk/disk_nvme
$(IMACKERN_DIR)/tg3_x86.o: $(X86K)/tg3_x86.c $(IMACKERN_HDRS) $(KDIR)/mm/frames.h
$(IMACKERN_DIR)/report_x86.o: $(X86K)/report_x86.c $(X86K)/report_x86.h $(IMACKERN_HDRS) $(NATIVE)/net/aienos_net.h
$(IMACKERN_DIR)/aienos_net.o: $(NATIVE)/net/aienos_net.c $(NATIVE)/net/aienos_net.h
-$(IMACKERN_OBJS):
+$(sort $(IMACKERN_OBJS) $(IMACKERN_REPORT_OBJS)):
@mkdir -p $(dir $@)
$(X86CC) $(IMACKERN_CFLAGS) -DAIENOS_COMMIT='"$(AIENOS_COMMIT)"' -c -o $@ $<
$(IMACKERN_ELF): $(IMACKERN_OBJS) $(BOOT)/image_x86_64.ld
@@ -2302,6 +2376,15 @@ $(IMACKERN_ELF): $(IMACKERN_OBJS) $(BOOT)/image_x86_64.ld
@n=$$($(X86NM) $@ | grep -c ' t isr_common$$' || true); s=$$($(X86NM) $@ | grep ' T ck_x86_isr_stubs$$' | cut -c1-16); \
e=$$($(X86NM) $@ | grep ' t isr_common$$' | cut -c1-16); \
if [ "$$n" != 1 ] || [ $$((0x$$e - 0x$$s)) != 4096 ]; then echo "interrupt stubs are not 256 x 16 bytes"; rm -f $@; exit 1; fi
+ @r=$$($(X86NM) $@ | grep -E ' [TtDdBbRr] ($(IMACKERN_REPORT_SYMS))$$' || true); \
+ if [ "$(CK_X86_REPORT)" = 1 ]; then \
+ for s in ck_x86_report_hold ck_x86_report_filter ck_x86_report_frame; do \
+ echo "$$r" | grep -q " $$s$$" || { echo "lab image lacks $$s"; rm -f $@; exit 1; }; done; \
+ elif [ -n "$$r" ]; then \
+ echo "default iMac image links the lab-only network report (build it with CK_X86_REPORT=1 only):"; \
+ echo "$$r"; rm -f $@; exit 1; fi
+ @if [ "$(CK_X86_REPORT)" != 1 ] && grep -aq "AIENOS-IMAC-REPORT" $@; then \
+ echo "default iMac image carries the report header string"; rm -f $@; exit 1; fi
$(IMACKERN_EFI): $(IMACKERN_ELF)
$(X86OBJCOPY) -O binary $< $@
@sz=$$(stat -c %s $@); pad=$$(( (4096 - sz % 4096) % 4096 )); \
@@ -2310,6 +2393,25 @@ $(IMACKERN_EFI): $(IMACKERN_ELF)
@[ "$$(od -An -tx1 -j68 -N2 $@ | tr -d ' ')" = "6486" ] || { echo "PE Machine is not x86_64 (0x8664)"; rm -f $@; exit 1; }
@echo "built $@ (commit $(AIENOS_COMMIT))"
imac-kernel: $(IMACKERN_EFI)
+# W^X negative controls (#409), TEST-ONLY, QEMU only, never deployed: IMACKERN_WX_MUTANT=no_nx drops every
+# NX bit, =text_writable leaves the kernel's code writable. The kernel's W^X probes must then panic
+# (scripts/qemu_ck_imac_kernel_test.sh builds both into their own OUT). The stamp rebuilds kmain_x86.o
+# whenever the setting changes, so a mutant object never lingers in a default build.
+IMACKERN_WX_MUTANT ?=
+ifeq ($(strip $(IMACKERN_WX_MUTANT)),)
+IMACKERN_WX_FLAGS :=
+else ifeq ($(strip $(IMACKERN_WX_MUTANT)),no_nx)
+IMACKERN_WX_FLAGS := -DCK_X86_WX_MUTANT_NO_NX=1
+else ifeq ($(strip $(IMACKERN_WX_MUTANT)),text_writable)
+IMACKERN_WX_FLAGS := -DCK_X86_WX_MUTANT_TEXT_RW=1
+else
+$(error IMACKERN_WX_MUTANT must be empty, no_nx or text_writable)
+endif
+$(IMACKERN_DIR)/kmain_x86.o: IMACKERN_CFLAGS += $(IMACKERN_WX_FLAGS)
+$(IMACKERN_DIR)/kmain_x86.o: $(IMACKERN_DIR)/wx_mutant.stamp
+$(IMACKERN_DIR)/wx_mutant.stamp: FORCE
+ @mkdir -p $(dir $@)
+ @echo '$(strip $(IMACKERN_WX_MUTANT))' | cmp -s - $@ || echo '$(strip $(IMACKERN_WX_MUTANT))' > $@
# Raspberry Pi 5 board image (see CK_PI5 above): target/native-kernel-pi5/BOOTAA64.EFI
pi5-store:
diff --git a/native/kernel/README.md b/native/kernel/README.md
index 9b30cc2f ..2cd091ef 100644
--- a/native/kernel/README.md
+++ b/native/kernel/README.md
@@ -14,7 +14,7 @@ QEMU qualifies nothing physical: a PASS here says nothing about real hardware.
| `core/` | Console, printf, ACPI, reports/panic/PSCI reset, M3 (threads, scheduler, EL0, capabilities, IPC), `kmain.c`. |
| `tests/` | Host unit tests. |
| `third_party/omega/` | The canonical Omega Cortex store, byte for byte from the omega commit in `omega.lock` (checked by `scripts/omega_lock_check.sh`); built freestanding by `svc/cortex_store.c` over the sealed Store through `svc/cortex_journal.c` (native v1 plan P06). |
-| `x86/` | x86_64 port, first cut (AIENOS-IMAC-KERNEL-0, 2017 iMac): UEFI stub, descriptor tables and interrupt stubs, page tables, local APIC timer, ACPI power off, console, secondary-core start, PCI walk, read-only AHCI and NVMe disks, transmit-only BCM57766 Ethernet report. |
+| `x86/` | x86_64 port, first cut (AIENOS-IMAC-KERNEL-0, 2017 iMac): UEFI stub, descriptor tables and interrupt stubs, page tables, local APIC timer, ACPI power off, console, secondary-core start, PCI walk, read-only AHCI and NVMe disks, BCM57766 Ethernet link detection; a lab-only, opt-in network report (`CK_X86_REPORT=1`). |
| `../boot/` | Minimal UEFI entry stub (one image with the kernel). |
## Build and test
@@ -168,19 +168,39 @@ build refuses any other ATA command); NVMe through the shared
`x86/`). Both disk_dev write hooks always refuse, serial numbers and MAC
addresses are never printed, and each disk's GPT is checked by the shared
`dev/disk_part.c` (both copies, CRCs, the AIENOS partition located if present).
-The Broadcom BCM57766 Ethernet chip (14e4:1686) gets a transmit-only, polled
-driver (`x86/tg3_x86.c`: core reset, bootcode handshake, rings in one DMA block
-below 4 GiB, PHY autonegotiation; it never receives and the MAC address is
-never printed). The last line before the hold is a one-line `summary:`. It
-prints `kernel: alive`, holds the screen 60 s and powers off through ACPI S5.
-During the hold `x86/report_x86.c` sends the RAM copy of the console (first
-16 KiB) every 2 s while the link is up, as UDP broadcast from 0.0.0.0 to
-255.255.255.255 port 47031 (TTL 1), in 1 KiB parts that each start with
-`AIENOS-IMAC-REPORT v=1 run=<id> part=<i>/<n> bytes=<total>`.
-`tools/ck_imac_report_listen.c` (`make -C native/kernel imac-report-listen`,
-run as `ck_imac_report_listen 47031 OUTDIR SECONDS`) rebuilds each run into
-`OUTDIR/imac-<run>.txt`; `scripts/ck_imac_report_test.sh` checks frames and
-reassembly on the host, so a wired iMac no longer needs a photo of its screen. Output: the GOP framebuffer
+The Broadcom BCM57766 Ethernet chip (14e4:1686) gets a polled driver
+(`x86/tg3_x86.c`: core reset, bootcode handshake, rings in one DMA block below
+4 GiB, PHY autonegotiation; it never reads received frames and the MAC address
+is never printed). In the default image it only detects the link: frame
+transmit is not compiled in. The last line before the hold is a one-line
+`summary:`. It prints `kernel: alive`, holds the screen 60 s and powers off
+through ACPI S5.
+
+**Network report: lab-only, opt-in, unauthenticated.** `make -C native/kernel
+imac-kernel CK_X86_REPORT=1` builds a separate lab image,
+`IMACKERN-LAB.EFI`, that adds `x86/report_x86.c`, `../net/aienos_net.c` and
+tg3 transmit. The default `IMACKERN.EFI`, and any resident or service (ALLEN)
+build, contain none of it; the link step fails a default image that has a
+report symbol. During the hold the lab image sends, every 2 s while the link
+is up, an allowlisted copy of the console (`ck_x86_report_filter`: only
+complete, printable lines of at most 240 bytes whose key is on a fixed list of
+kernel diagnostic keys; everything else, including `memory:`, is dropped
+whole, so chat, keys, tokens and credentials cannot enter it), as UDP
+broadcast from 0.0.0.0 to 255.255.255.255 port 47031 (TTL 1), in 1 KiB parts
+that each start with
+`AIENOS-IMAC-REPORT v=2 auth=none run=<id> part=<i>/<n> bytes=<total>`.
+Anyone on the LAN can read or forge these datagrams; the run id and checksum
+are not authenticity, so a report is never a receipt, evidence or a command.
+Future service diagnostics belong on the authenticated transport with an
+explicitly authorized peer. `tools/ck_imac_report_listen.c` (`make -C
+native/kernel imac-report-listen`, run as `ck_imac_report_listen 47031 OUTDIR
+SECONDS`) says so when it starts, refuses the retired v=1 raw-console format
+and rebuilds each run into `OUTDIR/imac-<run>.unauthenticated.txt`;
+`scripts/ck_imac_report_test.sh` checks the default and lab builds' symbols,
+the allowlist (sentinel lines never leave), the frames and reassembly on the
+host.
+
+Output: the GOP framebuffer
(`core/fbcon.c`, lines from before ExitBootServices replayed onto it) and COM1
when a 16550 answers there (QEMU; the iMac has none). Shared, unchanged:
`core/fbcon.c`, `fmt.c`, `acpi.c`, `handoff_check.c`, `mm/frames.c`, `heap.c`,
@@ -188,11 +208,32 @@ when a 16550 answers there (QEMU; the iMac has none). Shared, unchanged:
cores and attaches a SATA data disk and an NVMe disk, each with a GPT from
`ck_gpt_image`, and fails unless three cores check in, the kernel finds each
AIENOS partition where the tool wrote it and both disks are byte-identical
-afterwards. Not yet: work scheduled on the other cores, x2APIC, NX, disk writes,
+afterwards. Not yet: work scheduled on the other cores, x2APIC, disk writes,
VT-d, receiving on the network, a store. QEMU (no BCM57766 there)
qualifies nothing physical; copy the image to a FAT stick as
`EFI/BOOT/BOOTX64.EFI` and start it from the Option-key boot picker.
+Page permissions (W^X, #409): the kernel refuses a CPU without NX, sets
+EFER.NXE and CR0.WP on the boot core and in the trampoline for every other
+core, and maps its code read-only executable, its PE header and read-only data
+(`.rodata`, relocations, GOT) read-only no-execute, and everything else (data,
+bss, stacks, heap, page tables, MMIO, the framebuffer) no-execute, keeping the
+PAT cache types and the stack guard; the 2 MiB pages around the image and the
+trampoline are split into 4 KiB pages at the boundaries from
+`../boot/image_x86_64.ld`. The trampoline page is never writable and executable
+at once (writable while it is filled, executable while a core runs it,
+read-only no-execute once the cores are parked). At boot the kernel proves it:
+writes to code and to read-only data and execution from heap and stack must
+each fault with the right error code (`wx: ok ...`), and after the cores and
+disks are up an audit of every page table leaf must find nothing writable and
+executable, only the code executable, and NXE and WP on every core
+(`wx_audit: ok ...`). The QEMU test also builds two TEST-ONLY mutants
+(`make imac-kernel IMACKERN_WX_MUTANT=no_nx` or `=text_writable`) and fails
+unless their probes panic. W^X is not process isolation: everything here still
+runs in ring 0 in one address space, any kernel code can change the page
+tables, and learned or generated code must never be given kernel authority.
+QEMU only; not yet run on the iMac.
+
## Raspberry Pi 5 image (AIENOS-PI5 step 1)
make -C native/kernel pi5 # target/native-kernel-pi5/BOOTAA64.EFI (-DCK_PI5=1 -DCK_KLOG=1)
@@ -494,7 +535,7 @@ a FAIL to report, not to retry.
3. `ck_enter_el1`: EL2 -> EL1h with the MMU already on our tables.
4. EL1: `mmu: enabled`, `mmu_switch: ...` read back from the registers,
heap check, guard-page self test, GICv3 from the MADT, 200 ms timer window
- (INTID 30, 10 ms period), `kernel: alive`, `kernel_el: EL1h`.
+ (INTID 30, 10 ms period; on a starved emulator the window keeps counting up to 5 s until five ticks arrived, and each interval is measured from IRQ entry, so a host stall cannot produce a short interval), `kernel: alive`, `kernel_el: EL1h`.
5. Stages, in order, if linked: `ck_stage_devices`, `ck_stage_security`,
`ck_stage_store`. Each prints `stage <name>: ok`, `stage <name>: FAIL
rc=<n>` or `stage <name>: not linked`.
@@ -539,6 +580,36 @@ low-water free bytes.
lists (whole pages). Tables, stack, heap and pool come from it and are never
handed out again.
+## Native pipes (AIENOS-NATIVE-PIPE-1, aienos-mv#428)
+
+`core/pipe.c` / `core/pipe.h` make a pipe a kernel primitive: two independently scheduled operations exchange ordered
+bytes through a bounded buffer, with no intermediate file. It is a byte stream, separate from the 56-byte typed
+message ring of `core/ipc.h`; it reuses only the ipc.h capability tables.
+
+- **Contract.** OSH_PLATFORM_ABI (aien-protocols-mv `specs/osh-platform/`, read at `fb5fca98e667 `, v1 DRAFT, unfrozen):
+ PIPE_CREATE, STREAM_READ / WRITE / CLOSE / DUP (section 8.1), at least 64 KiB per pipe (8.5), the error codes of 8.6
+ (one shared copy in `core/osh_err.h`, also used by `core/osh_op.h`), epoch staleness (4.4) and authority at the
+ moment of the effect (9.2). Choices the draft does not pin are marked UNVERIFIED in `pipe.h`.
+- **Ends are capabilities.** The read end holds `CK_R_READ`, the write end `CK_R_WRITE`, never both; optional
+ `CK_R_DERIVE` (dup in the same table), `CK_R_GRANT` (dup into another principal's table) and `CK_R_REVOKE`. Every
+ operation calls `ck_cap_lookup` when it acts, so a handle that was closed, reused or revoked is refused even if it
+ was valid a moment earlier (STALE, DENIED, REVOKED).
+- **Bounded.** A static pool of `CK_PIPE_POOL_PIPES` (4) pipes of `CK_PIPE_CAPACITY` (65536) bytes; nothing is allocated.
+ A write past the free space is partial, a write on a full pipe returns WOULD_BLOCK (or parks with `CK_PIPE_F_BLOCK`
+ through the pool's wait / wake hook, which the kernel points at the scheduler). Last writer closed: reads return 0
+ bytes once drained (EOF). No reader: BROKEN_PIPE. Revoke scrubs the buffer and no byte is delivered after it; cancel
+ makes the next or the blocked call on that end return INTERRUPTED with no byte moved. Counters (bytes, max resident,
+ WOULD_BLOCK, waits, wakeups, cancellations, revocations, refusals) are in `struct ck_pipe_stats`.
+- **Versioned op table.** `ck_pipe_dispatch` takes a platform call frame (magic `OSHF`, `CK_PIPE_ABI_VERSION` 1, op id,
+ reserved, arguments) and refuses malformed frames and unknown ops or versions (INVALID_ARG, NOT_SUPPORTED) before any
+ effect.
+- **Tests.** `make test` runs `test_pipe` (the 20-case corpus in `tests/fixtures/pipe/`, format in its README, plus
+ producer / consumer transfers through `core/sched.c`) and `pipe-mutant` (the write-right check removed: the test must
+ fail); `make sanitize` runs it under ASan+UBSan. `scripts/qemu_ck_pipe_test.sh` builds the TEST-ONLY `CK_PIPE_TEST=1`
+ image and checks the in-kernel run (GATES.md, PIPE). Host and QEMU evidence qualify nothing physical.
+- **Not yet.** Task execution and shell dispatch over pipes are separate issues; the kernel's blocking hook yields
+ cooperatively inside one kernel thread, it does not switch M3 threads.
+
## Notes for stage code
- `ck_puts` prints the string as given; it does not add a newline.
diff --git a/native/kernel/arch/.crumb b/native/kernel/arch/.crumb
index 8da07878 ..8fcd5863 100644
--- a/native/kernel/arch/.crumb
+++ b/native/kernel/arch/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-13T12:30:58Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:8f63182b423b274a3fa6dcf0a17811343f93bd1539e33479102ffa87935da1ca ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 8,
- "generated_at_commit": "a01f365f16ea16bb4843f97b031ee72b4e028389 ",
- "source_tree": "sha256:a3f57569a3f0d39ed15c92cf2444286702f51e87ade81dea77e76af193678a6b "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/arch/timer.c b/native/kernel/arch/timer.c
index c905c893 ..dab231b4 100644
--- a/native/kernel/arch/timer.c
+++ b/native/kernel/arch/timer.c
@@ -1,12 +1,23 @@
/* timer.c -- EL1 physical generic timer (CNTP, PPI INTID 30) and the
* monotonic time services. Tick semantics match the Rust kernel: the IRQ
* re-arms CNTP_CVAL 10 ms after "now", then records the interval since the
- * previous tick (the first interval is measured from arming). */
+ * previous tick (the first interval is measured from arming).
+ *
+ * Both ends of an interval are the counter value read at IRQ ENTRY, the same
+ * value the next deadline is built from. An interval is therefore never
+ * shorter than the period, whatever the host does: the old code read the
+ * counter again AFTER re-arming, so a host stall between the two reads (QEMU
+ * TCG on a loaded machine) made one interval long and the next one short, and
+ * the M1 "no interval shorter than half a period" check failed (an interrupt
+ * storm or a missing EOI still shows: the next IRQ arrives at once). */
#include "arch.h"
#include "ck_internal.h"
static volatile uint64_t ticks, last, tmin, tmax;
+#define CK_TIMER_MIN_TICKS 5 /* the M1 gate wants at least five ticks */
+#define CK_TIMER_GRACE_MS 5000 /* longest extra wait for them */
+
static uint64_t counter(void)
{
ck_isb();
@@ -42,9 +53,8 @@ void ck_timer_tick(void)
ck_wr(cntp_ctl_el0, 1);
ck_isb();
ticks++;
- uint64_t t = counter();
- uint64_t interval = t - last;
- last = t;
+ uint64_t interval = now - last;
+ last = now;
if (interval < tmin)
tmin = interval;
if (interval > tmax)
@@ -66,15 +76,21 @@ int ck_timer_window(uint32_t ms, struct ck_timer_window *w)
ck_isb();
ck_irq_on();
ck_isb();
+ /* The window is wall-clock. A starved vCPU (QEMU TCG on a loaded host) may
+ * see fewer than CK_TIMER_MIN_TICKS ticks in it, which says nothing about
+ * the timer. Keep counting past the window until that many ticks arrived,
+ * giving up after CK_TIMER_GRACE_MS: a dead timer still reports 0 ticks. */
uint64_t window = hz / 1000 * ms;
- while (counter() - start < window)
+ uint64_t grace = hz / 1000 * CK_TIMER_GRACE_MS;
+ uint64_t t;
+ while ((t = counter()) - start < window || (ticks < CK_TIMER_MIN_TICKS && t - start < grace))
;
ck_irq_off();
ck_isb();
ck_wr(cntp_ctl_el0, 0);
ck_isb();
w->ticks = ticks;
- w->ms = ms;
+ w->ms = (t - start) / (hz / 1000);
w->freq_hz = hz;
w->min_interval = ticks ? tmin : 0;
w->max_interval = tmax;
diff --git a/native/kernel/artifact/.crumb b/native/kernel/artifact/.crumb
index 43b52963 ..9a859fa3 100644
--- a/native/kernel/artifact/.crumb
+++ b/native/kernel/artifact/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-15T02:48:19Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:cd3be26829bc7f947521b1e5df144df2504ef25a3763ec0356861b7d17d5d901 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 13,
- "generated_at_commit": "edd175183f30a31f4c7683e194dd6479dc8c7a6e ",
- "source_tree": "sha256:6cd37233b62c978bf5adeb03aeafb474e456a830a8992130b0fba7492840faa8 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/core/.crumb b/native/kernel/core/.crumb
index 11410454 ..8d7a71b6 100644
--- a/native/kernel/core/.crumb
+++ b/native/kernel/core/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-15T02:48:19Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:c9035b8f32a9539fe8d1f93ed968b3b56dd3ba4c2630b32b6c286b1dbd19d908 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 69,
- "generated_at_commit": "edd175183f30a31f4c7683e194dd6479dc8c7a6e ",
- "source_tree": "sha256:928d92ef1abd9076c57a25fb07becf22b43f0a46a7edd1998383f3dd6296e083 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/core/kmain.c b/native/kernel/core/kmain.c
index d4a788c9 ..134e2cef 100644
--- a/native/kernel/core/kmain.c
+++ b/native/kernel/core/kmain.c
@@ -122,6 +122,10 @@ static __attribute__((noreturn)) void rollback_test_end(void)
}
#endif
+#ifdef CK_PIPE_TEST
+void ck_pipe_selftest(void);
+#endif
+
static __attribute__((noreturn)) void ck_el1_main(void *arg)
{
struct ck_handoff *h = arg;
@@ -212,6 +216,10 @@ static __attribute__((noreturn)) void ck_el1_main(void *arg)
#if defined(CK_TEST_ROLLBACK_CPU_FAULT) || defined(CK_TEST_ROLLBACK_HANG)
rollback_test_end();
#endif
+#ifdef CK_PIPE_TEST
+ /* TEST-ONLY pipe self-test (core/pipe_test.c, scripts/qemu_ck_pipe_test.sh); never in a production image. */
+ ck_pipe_selftest();
+#endif
{
struct ck_cpu_features cf;
diff --git a/native/kernel/core/osc_admit.c b/native/kernel/core/osc_admit.c
index ed912892 ..0acaa9e9 100644
--- a/native/kernel/core/osc_admit.c
+++ b/native/kernel/core/osc_admit.c
@@ -218,7 +218,7 @@ struct lt_step {
int ws; /* 0 none, 1..2 which caller workspace */
uint64_t cap;
const char *rcpt; /* receipt Store entry; NULL: the unit's own (lt_rcpt_for), "-": none */
- int variant; /* receipt policy variant for this launch (ck_osc_rcpt_variant): 0 qual, 1 release, 2 revoked key */
+ int variant; /* TEST ONLY: 0 qual, 1 release, 2 revoked key, 3 changed code under qual policy */
};
/* The receipt of each launched unit: a receipt binds the IR and the code, so l02 (l01 with a bigger stack) shares
@@ -270,8 +270,14 @@ static void lt_run(const struct lt_step *s)
const char *rn = s->rcpt ? s->rcpt : lt_rcpt_for(s->unit);
size_t rlen = 0;
const uint8_t *rb = lt_streq(rn, "-") ? 0 : ck_osc_receipt_find(rn, &rlen);
- ck_osc_rcpt_variant = s->variant;
+ ck_osc_rcpt_variant = s->variant == 3 ? 0 : s->variant;
+ /* Preserve the valid receipt and admitted view; alter only the bytes
+ * privately copied by the launcher, exercising its final rehash. */
+ if (s->variant == 3)
+ lt_unit[u].bytes[lt_unit[u].acc.code_off] ^= 1;
ck_osc_launch(lt_unit[u].bytes, lt_unit[u].len, <_unit[u].acc, rb, rlen, &rq, &r, &info);
+ if (s->variant == 3)
+ lt_unit[u].bytes[lt_unit[u].acc.code_off] ^= 1;
ck_osc_rcpt_variant = 0;
char rs[96], as[80];
ck_osc_result_str(&r, rs, sizeof rs);
@@ -295,7 +301,7 @@ static void lt_run(const struct lt_step *s)
hex(idh, info.rcpt.id, 8);
ck_printf("osc_rcpt_launch: %s %s(%s) receipt=%s policy=%s -> %s receipt_id=%s revoked=%s ticks=%llu "
"pages_mapped=%u page_tables_zeroed=%u slot_free=%u; QEMU (aarch64 virt), TEST signer, not physical\n",
- s->unit, s->fn, as, rb ? rn : "none", vname[s->variant], rs, idh,
+ s->unit, s->fn, as, rb ? rn : "none", vname[s->variant == 3 ? 0 : s->variant], rs, idh,
info.rcpt.revoked == OSC_RCPT_REVOKED_ID ? "receipt_id"
: info.rcpt.revoked == OSC_RCPT_REVOKED_KEY ? "signer_key" : "-",
(unsigned long long)r.ticks, info.pages_mapped, (unsigned)info.tables_zeroed,
@@ -339,6 +345,7 @@ static void rt_all(void)
{ "a01_valid_min.unit", "add", 2, { 15, 16 }, 0, 0, 0, "n_deps.rcpt", 0 },
{ "a01_valid_min.unit", "add", 2, { 16, 17 }, 0, 0, 0, "n_checker.rcpt", 0 },
{ "a01_valid_min.unit", "add", 2, { 17, 18 }, 0, 0, 0, "a01.owner.rcpt", 1 },
+ { "a01_valid_min.unit", "add", 2, { 18, 19 }, 0, 0, 0, "a01.rcpt", 3 },
{ "a01_valid_min.unit", "add", 2, { 20, 22 }, 0, 0, 0, "a01.rcpt", 0 },
};
ck_printf("osc_rcpt_selftest: launches=%u unit=a01_valid_min.unit; QEMU (aarch64 virt), TEST signer, not physical\n",
diff --git a/native/kernel/core/osh_err.h b/native/kernel/core/osh_err.h
new file mode 100644
index 00000000 ..b4754102
--- /dev/null
+++ b/native/kernel/core/osh_err.h
@@ -0,0 +1,25 @@
+/* osh_err.h -- OSH platform error codes (OSH_PLATFORM_ABI.md section 8.6, v1 DRAFT, unfrozen; read at aien-protocols-mv
+ * fb5fca98e667 ). One copy of the numbering, shared by the test-only shell adapter (osh_op.h) and the kernel pipe primitive
+ * (pipe.h), so the two can never disagree. Pure definitions, no test-only guard: the pipe primitive is not test-only. */
+#ifndef AIENOS_CK_OSH_ERR_H
+#define AIENOS_CK_OSH_ERR_H
+
+enum osh_err {
+ OSH_E_OK = 0, OSH_E_DENIED = 1, OSH_E_REVOKED = 2, OSH_E_STALE = 3, OSH_E_NOT_FOUND = 4, OSH_E_UNAVAILABLE = 5,
+ OSH_E_INVALID_ARG = 6, OSH_E_LIMIT = 7, OSH_E_INTERRUPTED = 8, OSH_E_BROKEN_PIPE = 9, OSH_E_IO = 10,
+ OSH_E_OUTCOME_UNKNOWN = 11, OSH_E_CAP_DOMAIN_MISMATCH = 12, OSH_E_CAP_GEN_NARROW = 13, OSH_E_NOT_SUPPORTED = 14,
+ OSH_E_WOULD_BLOCK = 15, OSH_E_PARTIAL_LAUNCH = 16
+};
+#define OSH_E_COUNT 17u
+
+/* Name of a code; section 8.6: an unknown code is IO, never OK. */
+static inline const char *osh_err_label(unsigned e)
+{
+ static const char *const n[OSH_E_COUNT] = { "OK", "DENIED", "REVOKED", "STALE", "NOT_FOUND", "UNAVAILABLE",
+ "INVALID_ARG", "LIMIT", "INTERRUPTED", "BROKEN_PIPE", "IO",
+ "OUTCOME_UNKNOWN", "CAP_DOMAIN_MISMATCH", "CAP_GEN_NARROW",
+ "NOT_SUPPORTED", "WOULD_BLOCK", "PARTIAL_LAUNCH" };
+ return e < OSH_E_COUNT ? n[e] : "IO";
+}
+
+#endif
diff --git a/native/kernel/core/osh_op.c b/native/kernel/core/osh_op.c
index 9c53dcfc ..69dcfdd6 100644
--- a/native/kernel/core/osh_op.c
+++ b/native/kernel/core/osh_op.c
@@ -38,10 +38,7 @@ __attribute__((unused)) static int same(const void *a, const void *b, size_t n)
const char *osh_err_name(unsigned e)
{
- static const char *const n[] = { "OK", "DENIED", "REVOKED", "STALE", "NOT_FOUND", "UNAVAILABLE", "INVALID_ARG", "LIMIT",
- "INTERRUPTED", "BROKEN_PIPE", "IO", "OUTCOME_UNKNOWN", "CAP_DOMAIN_MISMATCH",
- "CAP_GEN_NARROW", "NOT_SUPPORTED", "WOULD_BLOCK", "PARTIAL_LAUNCH" };
- return e < sizeof n / sizeof n[0] ? n[e] : "IO"; /* section 8.6: an unknown code is IO, never OK */
+ return osh_err_label(e); /* osh_err.h; section 8.6: an unknown code is IO, never OK */
}
const char *osh_outcome_name(unsigned o)
diff --git a/native/kernel/core/osh_op.h b/native/kernel/core/osh_op.h
index e39a8b49 ..5ce842ae 100644
--- a/native/kernel/core/osh_op.h
+++ b/native/kernel/core/osh_op.h
@@ -25,13 +25,8 @@
#error "CK_OSH_OP_TEST cannot be combined with CK_HARDWARE_STAGING"
#endif
-/* section 8.6 platform error codes (numbers as in the draft) */
-enum osh_err {
- OSH_E_OK = 0, OSH_E_DENIED = 1, OSH_E_REVOKED = 2, OSH_E_STALE = 3, OSH_E_NOT_FOUND = 4, OSH_E_UNAVAILABLE = 5,
- OSH_E_INVALID_ARG = 6, OSH_E_LIMIT = 7, OSH_E_INTERRUPTED = 8, OSH_E_BROKEN_PIPE = 9, OSH_E_IO = 10,
- OSH_E_OUTCOME_UNKNOWN = 11, OSH_E_CAP_DOMAIN_MISMATCH = 12, OSH_E_CAP_GEN_NARROW = 13, OSH_E_NOT_SUPPORTED = 14,
- OSH_E_WOULD_BLOCK = 15, OSH_E_PARTIAL_LAUNCH = 16
-};
+/* section 8.6 platform error codes: one shared numbering (osh_err.h), also used by the kernel pipe primitive (pipe.h) */
+#include "osh_err.h"
/* section 10 outcomes */
enum osh_outcome { OSH_O_NOT_STARTED = 0, OSH_O_COMPLETED, OSH_O_FAILED_NO_EFFECT, OSH_O_CANCELLED, OSH_O_OUTCOME_UNKNOWN };
diff --git a/native/kernel/core/pipe.c b/native/kernel/core/pipe.c
new file mode 100644
index 00000000 ..2496832e
--- /dev/null
+++ b/native/kernel/core/pipe.c
@@ -0,0 +1,465 @@
+/* pipe.c -- see pipe.h. Bounded byte pipes over ipc.h capability tables; no allocation, no libc. */
+#include "pipe.h"
+
+static void bytes_zero(uint8_t *d, size_t n)
+{
+ for (size_t i = 0; i < n; i++)
+ d[i] = 0;
+}
+
+static void stats_zero(struct ck_pipe_stats *s)
+{
+ *s = (struct ck_pipe_stats){ 0 };
+}
+
+void ck_pipe_pool_init(struct ck_pipe_pool *p, const struct ck_pipe_hooks *hooks)
+{
+ for (unsigned i = 0; i < CK_PIPE_POOL_PIPES; i++) {
+ struct ck_pipe *q = &p->pipes[i];
+ bytes_zero(q->buf, CK_PIPE_CAPACITY);
+ q->head = q->len = q->epoch = 0;
+ q->reader_refs = q->writer_refs = 0;
+ q->flags = 0;
+ q->waiting[0] = q->waiting[1] = 0;
+ stats_zero(&q->stats);
+ }
+ p->hooks = hooks;
+ stats_zero(&p->total);
+ p->live = 0;
+}
+
+int ck_pipe_pool_empty(const struct ck_pipe_pool *p)
+{
+ for (unsigned i = 0; i < CK_PIPE_POOL_PIPES; i++)
+ if (p->pipes[i].flags & CK_PIPE_LIVE)
+ return 0;
+ return p->live == 0;
+}
+
+/* Every counter is kept twice: this incarnation and the pool total. */
+#define BUMP(p, q, field, by) \
+ do { \
+ (q)->stats.field += (by); \
+ (p)->total.field += (by); \
+ } while (0)
+
+static void wake(struct ck_pipe_pool *p, unsigned idx, unsigned end)
+{
+ struct ck_pipe *q = &p->pipes[idx];
+ if (!q->waiting[end] || !p->hooks || !p->hooks->wake)
+ return;
+ BUMP(p, q, wakeups, 1);
+ p->hooks->wake(p->hooks->ctx, idx, end);
+}
+
+static unsigned data_right(unsigned end)
+{
+ return end == CK_PIPE_END_READ ? CK_R_READ : CK_R_WRITE;
+}
+
+/* The effect-boundary check, run inside every operation at the moment of its effect.
+ * need: rights the capability must hold. want_end: the end the operation needs, or -1 for either.
+ * OK with *idx and *end set; otherwise the refusal. A REVOKED pipe is reported only when live_ok is 0. */
+static unsigned resolve(struct ck_pipe_pool *p, const struct ck_cap_table *t, struct ck_handle h, unsigned need,
+ int want_end, int live_ok, unsigned *idx, unsigned *end)
+{
+ if (!t || h.generation == 0 || h.index >= t->n)
+ return OSH_E_INVALID_ARG;
+ uint32_t res = 0;
+ int r = ck_cap_lookup(t, h, need, &res);
+ if (r == CK_CAP_INVALID)
+ return OSH_E_STALE; /* slot closed, or reused under a newer generation */
+ if (r != CK_CAP_OK)
+ return OSH_E_DENIED; /* the capability lacks a right this effect needs */
+ if ((res >> 24) != CK_PIPE_RES_TAG)
+ return OSH_E_DENIED; /* not a stream capability */
+ unsigned i = (res >> 20) & 7u, e = (res >> 23) & 1u;
+ uint32_t epoch = res & CK_PIPE_EPOCH_MAX;
+ if (i >= CK_PIPE_POOL_PIPES)
+ return OSH_E_DENIED;
+ if (want_end >= 0 && e != (unsigned)want_end)
+ return OSH_E_DENIED; /* a read end cannot write, a write end cannot read */
+ const struct ck_pipe *q = &p->pipes[i];
+ if (!(q->flags & CK_PIPE_LIVE) || q->epoch != epoch)
+ return OSH_E_STALE; /* section 4.4: an id from an earlier incarnation */
+ if (!live_ok && (q->flags & CK_PIPE_REVOKED))
+ return OSH_E_REVOKED;
+ *idx = i;
+ *end = e;
+ return OSH_E_OK;
+}
+
+static unsigned refuse(struct ck_pipe_pool *p, unsigned e)
+{
+ if (e == OSH_E_DENIED || e == OSH_E_STALE || e == OSH_E_REVOKED)
+ p->total.refused++;
+ return e;
+}
+
+unsigned ck_pipe_create(struct ck_pipe_pool *p, struct ck_cap_table *t, struct ck_handle *rd, struct ck_handle *wr)
+{
+ if (!t || !rd || !wr)
+ return OSH_E_INVALID_ARG;
+ unsigned idx = CK_PIPE_POOL_PIPES;
+ for (unsigned i = 0; i < CK_PIPE_POOL_PIPES; i++)
+ if (!(p->pipes[i].flags & CK_PIPE_LIVE) && p->pipes[i].epoch < CK_PIPE_EPOCH_MAX) {
+ idx = i;
+ break;
+ }
+ if (idx == CK_PIPE_POOL_PIPES)
+ return OSH_E_LIMIT;
+ struct ck_pipe *q = &p->pipes[idx];
+ uint32_t epoch = q->epoch + 1;
+ struct ck_handle r, w;
+ if (ck_cap_insert(t, ck_pipe_resource(idx, CK_PIPE_END_READ, epoch), CK_R_READ | CK_PIPE_CTL_RIGHTS, &r) !=
+ CK_CAP_OK)
+ return OSH_E_LIMIT;
+ if (ck_cap_insert(t, ck_pipe_resource(idx, CK_PIPE_END_WRITE, epoch), CK_R_WRITE | CK_PIPE_CTL_RIGHTS, &w) !=
+ CK_CAP_OK) {
+ ck_cap_remove(t, r); /* nothing stays allocated on failure */
+ return OSH_E_LIMIT;
+ }
+ q->epoch = epoch;
+ q->head = q->len = 0;
+ q->reader_refs = q->writer_refs = 1;
+ q->flags = CK_PIPE_LIVE;
+ q->waiting[0] = q->waiting[1] = 0;
+ stats_zero(&q->stats);
+ p->live++;
+ *rd = r;
+ *wr = w;
+ return OSH_E_OK;
+}
+
+static unsigned read_once(struct ck_pipe_pool *p, const struct ck_cap_table *t, struct ck_handle h, uint8_t *buf,
+ size_t max, size_t *n, unsigned *idx_out)
+{
+ unsigned idx, end;
+ unsigned e = resolve(p, t, h, CK_R_READ, CK_PIPE_END_READ, 0, &idx, &end);
+ if (e != OSH_E_OK)
+ return refuse(p, e);
+ struct ck_pipe *q = &p->pipes[idx];
+ *idx_out = idx;
+ if (q->flags & CK_PIPE_CANCEL_READ) {
+ q->flags &= ~CK_PIPE_CANCEL_READ;
+ BUMP(p, q, cancellations, 1);
+ return OSH_E_INTERRUPTED;
+ }
+ if (max == 0)
+ return OSH_E_OK;
+ if (q->len == 0) {
+ if (q->writer_refs == 0) {
+ BUMP(p, q, eof, 1);
+ return OSH_E_OK; /* every writer closed and the buffer is drained: EOF */
+ }
+ BUMP(p, q, would_block, 1);
+ return OSH_E_WOULD_BLOCK;
+ }
+ size_t take = max < q->len ? max : q->len;
+ for (size_t i = 0; i < take; i++) {
+ buf[i] = q->buf[q->head];
+ q->buf[q->head] = 0; /* consumed bytes do not stay resident */
+ q->head = (q->head + 1) % CK_PIPE_CAPACITY;
+ }
+ q->len -= (uint32_t)take;
+ if (q->len == 0)
+ q->head = 0;
+ *n = take;
+ BUMP(p, q, bytes_read, take);
+ BUMP(p, q, reads, 1);
+ wake(p, idx, CK_PIPE_END_WRITE);
+ return OSH_E_OK;
+}
+
+static unsigned write_once(struct ck_pipe_pool *p, const struct ck_cap_table *t, struct ck_handle h,
+ const uint8_t *buf, size_t len, size_t *n, unsigned *idx_out)
+{
+ unsigned idx, end;
+#ifdef CK_PIPE_MUTANT_SKIP_RIGHTS
+ /* TEST-ONLY mutant (make pipe-mutant): the write right and the end are not checked. test_pipe must fail. */
+ unsigned e = resolve(p, t, h, 0, -1, 0, &idx, &end);
+#else
+ unsigned e = resolve(p, t, h, CK_R_WRITE, CK_PIPE_END_WRITE, 0, &idx, &end);
+#endif
+ if (e != OSH_E_OK)
+ return refuse(p, e);
+ struct ck_pipe *q = &p->pipes[idx];
+ *idx_out = idx;
+ if (q->flags & CK_PIPE_CANCEL_WRITE) {
+ q->flags &= ~CK_PIPE_CANCEL_WRITE;
+ BUMP(p, q, cancellations, 1);
+ return OSH_E_INTERRUPTED;
+ }
+ if (q->reader_refs == 0) {
+ BUMP(p, q, broken_pipe, 1);
+ return OSH_E_BROKEN_PIPE;
+ }
+ if (len == 0)
+ return OSH_E_OK;
+ size_t room = CK_PIPE_CAPACITY - q->len;
+ if (room == 0) {
+ BUMP(p, q, would_block, 1);
+ return OSH_E_WOULD_BLOCK;
+ }
+ size_t put = len < room ? len : room;
+ uint32_t at = (q->head + q->len) % CK_PIPE_CAPACITY;
+ for (size_t i = 0; i < put; i++) {
+ q->buf[at] = buf[i];
+ at = (at + 1) % CK_PIPE_CAPACITY;
+ }
+ q->len += (uint32_t)put;
+ *n = put;
+ BUMP(p, q, bytes_written, put);
+ BUMP(p, q, writes, 1);
+ if (q->len > q->stats.max_resident)
+ q->stats.max_resident = q->len;
+ if (q->len > p->total.max_resident)
+ p->total.max_resident = q->len;
+ wake(p, idx, CK_PIPE_END_READ);
+ return OSH_E_OK;
+}
+
+/* Park on (idx, end) through the wait hook. OK = retry; anything else ends the call with no byte moved. */
+static unsigned park(struct ck_pipe_pool *p, unsigned idx, unsigned end)
+{
+ if (!p->hooks || !p->hooks->wait)
+ return OSH_E_WOULD_BLOCK;
+ struct ck_pipe *q = &p->pipes[idx];
+ uint32_t epoch = q->epoch;
+ q->waiting[end]++;
+ BUMP(p, q, waits, 1);
+ unsigned w = p->hooks->wait(p->hooks->ctx, idx, end);
+ /* The pipe may have been freed and recreated while parked; count only our own wait out. */
+ if (q->epoch == epoch && q->waiting[end])
+ q->waiting[end]--;
+ if (w != OSH_E_OK) {
+ if (w == OSH_E_INTERRUPTED)
+ BUMP(p, q, cancellations, 1);
+ return w >= OSH_E_COUNT ? OSH_E_IO : w; /* section 8.6: an unknown code is IO, never OK */
+ }
+ return OSH_E_OK;
+}
+
+unsigned ck_stream_read(struct ck_pipe_pool *p, const struct ck_cap_table *t, struct ck_handle h, uint8_t *buf,
+ size_t max, unsigned flags, size_t *n)
+{
+ if (!n || (max && !buf) || (flags & ~CK_PIPE_F_BLOCK))
+ return OSH_E_INVALID_ARG;
+ for (;;) {
+ unsigned idx = 0;
+ *n = 0;
+ unsigned e = read_once(p, t, h, buf, max, n, &idx);
+ if (e != OSH_E_WOULD_BLOCK || !(flags & CK_PIPE_F_BLOCK))
+ return e;
+ e = park(p, idx, CK_PIPE_END_READ);
+ if (e != OSH_E_OK)
+ return e;
+ }
+}
+
+unsigned ck_stream_write(struct ck_pipe_pool *p, const struct ck_cap_table *t, struct ck_handle h, const uint8_t *buf,
+ size_t len, unsigned flags, size_t *n)
+{
+ if (!n || (len && !buf) || (flags & ~CK_PIPE_F_BLOCK))
+ return OSH_E_INVALID_ARG;
+ for (;;) {
+ unsigned idx = 0;
+ *n = 0;
+ unsigned e = write_once(p, t, h, buf, len, n, &idx);
+ if (e != OSH_E_WOULD_BLOCK || !(flags & CK_PIPE_F_BLOCK))
+ return e;
+ e = park(p, idx, CK_PIPE_END_WRITE);
+ if (e != OSH_E_OK)
+ return e;
+ }
+}
+
+static void pipe_free(struct ck_pipe_pool *p, struct ck_pipe *q)
+{
+ bytes_zero(q->buf, CK_PIPE_CAPACITY);
+ q->head = q->len = 0;
+ q->flags = 0;
+ q->waiting[0] = q->waiting[1] = 0;
+ p->live--;
+}
+
+unsigned ck_stream_close(struct ck_pipe_pool *p, struct ck_cap_table *t, struct ck_handle h)
+{
+ if (!t || h.generation == 0 || h.index >= t->n)
+ return OSH_E_INVALID_ARG;
+ uint32_t res = 0;
+ if (ck_cap_lookup(t, h, 0, &res) != CK_CAP_OK)
+ return refuse(p, OSH_E_STALE); /* already closed, or the slot belongs to someone newer */
+ if ((res >> 24) != CK_PIPE_RES_TAG || ((res >> 20) & 7u) >= CK_PIPE_POOL_PIPES)
+ return refuse(p, OSH_E_DENIED); /* not ours to close here */
+ unsigned idx, end;
+ unsigned e = resolve(p, t, h, 0, -1, 1, &idx, &end);
+ ck_cap_remove(t, h); /* the handle is released whatever the pipe's state */
+ if (e != OSH_E_OK)
+ return refuse(p, e);
+ struct ck_pipe *q = &p->pipes[idx];
+ if (end == CK_PIPE_END_READ) {
+ if (q->reader_refs)
+ q->reader_refs--;
+ if (q->reader_refs == 0)
+ wake(p, idx, CK_PIPE_END_WRITE); /* a blocked writer now sees BROKEN_PIPE */
+ } else {
+ if (q->writer_refs)
+ q->writer_refs--;
+ if (q->writer_refs == 0)
+ wake(p, idx, CK_PIPE_END_READ); /* a blocked reader now sees EOF once drained */
+ }
+ if (q->reader_refs == 0 && q->writer_refs == 0)
+ pipe_free(p, q);
+ return OSH_E_OK;
+}
+
+unsigned ck_stream_dup(struct ck_pipe_pool *p, struct ck_cap_table *from, struct ck_handle h, struct ck_cap_table *to,
+ unsigned rights, struct ck_handle *out)
+{
+ if (!to || !out)
+ return OSH_E_INVALID_ARG;
+ unsigned need = to == from ? CK_R_DERIVE : CK_R_GRANT;
+ unsigned idx, end;
+ unsigned e = resolve(p, from, h, need, -1, 0, &idx, &end);
+ if (e != OSH_E_OK)
+ return refuse(p, e);
+ unsigned have = 0;
+ ck_cap_rights(from, h, &have);
+ unsigned dr = data_right(end);
+ if (!(rights & dr) || (rights & ~(dr | CK_PIPE_CTL_RIGHTS)))
+ return OSH_E_INVALID_ARG; /* a dup carries its end's data right and nothing of the other end */
+ if (rights & ~have)
+ return refuse(p, OSH_E_DENIED); /* attenuation only: never more than the source holds */
+ struct ck_pipe *q = &p->pipes[idx];
+ struct ck_handle c;
+ if (ck_cap_insert(to, ck_pipe_resource(idx, end, q->epoch), rights, &c) != CK_CAP_OK)
+ return OSH_E_LIMIT;
+ if (end == CK_PIPE_END_READ)
+ q->reader_refs++;
+ else
+ q->writer_refs++;
+ *out = c;
+ return OSH_E_OK;
+}
+
+unsigned ck_pipe_revoke(struct ck_pipe_pool *p, const struct ck_cap_table *t, struct ck_handle h)
+{
+ unsigned idx, end;
+ unsigned e = resolve(p, t, h, CK_R_REVOKE, -1, 0, &idx, &end);
+ if (e != OSH_E_OK)
+ return refuse(p, e);
+ struct ck_pipe *q = &p->pipes[idx];
+ q->flags |= CK_PIPE_REVOKED;
+ q->flags &= ~(CK_PIPE_CANCEL_READ | CK_PIPE_CANCEL_WRITE);
+ bytes_zero(q->buf, CK_PIPE_CAPACITY); /* buffered bytes are never delivered after a revoke */
+ q->head = q->len = 0;
+ BUMP(p, q, revocations, 1);
+ wake(p, idx, CK_PIPE_END_READ);
+ wake(p, idx, CK_PIPE_END_WRITE);
+ return OSH_E_OK;
+}
+
+unsigned ck_pipe_cancel(struct ck_pipe_pool *p, const struct ck_cap_table *t, struct ck_handle h)
+{
+ unsigned idx, end, rights = 0;
+ unsigned e = resolve(p, t, h, 0, -1, 0, &idx, &end);
+ if (e != OSH_E_OK)
+ return refuse(p, e);
+ ck_cap_rights(t, h, &rights);
+ if (!(rights & data_right(end))) /* the end's own data right: READ to interrupt reads, WRITE to interrupt writes */
+ return refuse(p, OSH_E_DENIED);
+ p->pipes[idx].flags |= end == CK_PIPE_END_READ ? CK_PIPE_CANCEL_READ : CK_PIPE_CANCEL_WRITE;
+ wake(p, idx, end);
+ return OSH_E_OK;
+}
+
+unsigned ck_pipe_release_table(struct ck_pipe_pool *p, struct ck_cap_table *t)
+{
+ unsigned closed = 0;
+ for (unsigned i = 0; i < t->n; i++) {
+ const struct ck_cap_slot *s = &t->slots[i];
+ if (!s->live || s->tombstone || (s->resource >> 24) != CK_PIPE_RES_TAG)
+ continue;
+ struct ck_handle h = { i, s->generation };
+ ck_stream_close(p, t, h);
+ closed++;
+ }
+ return closed;
+}
+
+/* ---- versioned op table ---- */
+static const uint8_t op_args[] = { [CK_PIPE_OP_CREATE] = 0, [CK_PIPE_OP_READ] = 2, [CK_PIPE_OP_WRITE] = 2,
+ [CK_PIPE_OP_CLOSE] = 1, [CK_PIPE_OP_DUP] = 3 };
+#define OP_MAX CK_PIPE_OP_DUP
+
+unsigned ck_pipe_dispatch(struct ck_pipe_pool *p, struct ck_cap_table *caller, struct ck_cap_table *peer,
+ const uint64_t *frame, size_t ncells, uint8_t *slice, size_t slice_len,
+ struct ck_pipe_ret *ret)
+{
+ struct ck_pipe_ret r = { 0 };
+ unsigned e;
+ struct ck_handle h = { 0, 0 };
+ if (!frame || ncells < 4 || frame[0] != CK_PIPE_FRAME_MAGIC) {
+ e = OSH_E_INVALID_ARG;
+ goto done;
+ }
+ if (frame[1] != CK_PIPE_ABI_VERSION) {
+ e = OSH_E_NOT_SUPPORTED; /* section 3: never guess at another version */
+ goto done;
+ }
+ if (frame[3] != 0) {
+ e = OSH_E_INVALID_ARG;
+ goto done;
+ }
+ if (frame[2] == 0 || frame[2] > OP_MAX) {
+ e = OSH_E_NOT_SUPPORTED; /* unknown op: refused before any effect */
+ goto done;
+ }
+ unsigned op = (unsigned)frame[2];
+ if (ncells != 4u + op_args[op] || (op != CK_PIPE_OP_CREATE && ck_handle_from_raw(frame[4], &h) != 0)) {
+ e = OSH_E_INVALID_ARG;
+ goto done;
+ }
+ size_t n = 0;
+ switch (op) {
+ case CK_PIPE_OP_CREATE: {
+ struct ck_handle rd, wr;
+ e = ck_pipe_create(p, caller, &rd, &wr);
+ if (e == OSH_E_OK) {
+ r.value = ck_handle_raw(rd);
+ r.value2 = ck_handle_raw(wr);
+ }
+ break;
+ }
+ case CK_PIPE_OP_READ:
+ case CK_PIPE_OP_WRITE:
+ if (frame[5] & ~(uint64_t)CK_PIPE_F_BLOCK) {
+ e = OSH_E_INVALID_ARG;
+ break;
+ }
+ e = op == CK_PIPE_OP_READ ? ck_stream_read(p, caller, h, slice, slice_len, (unsigned)frame[5], &n)
+ : ck_stream_write(p, caller, h, slice, slice_len, (unsigned)frame[5], &n);
+ r.value = n;
+ break;
+ case CK_PIPE_OP_CLOSE:
+ e = ck_stream_close(p, caller, h);
+ break;
+ default: { /* CK_PIPE_OP_DUP */
+ struct ck_handle c;
+ if (frame[5] & ~(uint64_t)CK_R_ALL || frame[6] > 1 || (frame[6] == 1 && !peer)) {
+ e = OSH_E_INVALID_ARG;
+ break;
+ }
+ e = ck_stream_dup(p, caller, h, frame[6] ? peer : caller, (unsigned)frame[5], &c);
+ if (e == OSH_E_OK)
+ r.value = ck_handle_raw(c);
+ break;
+ }
+ }
+done:
+ r.error = e;
+ if (ret)
+ *ret = r;
+ return e;
+}
diff --git a/native/kernel/core/pipe.h b/native/kernel/core/pipe.h
new file mode 100644
index 00000000 ..cb48d874
--- /dev/null
+++ b/native/kernel/core/pipe.h
@@ -0,0 +1,174 @@
+/* pipe.h -- bounded byte-stream pipes, a native AIENOS execution primitive (aienos-mv#428, AIENOS-NATIVE-PIPE-1).
+ *
+ * Contract: aien-protocols-mv specs/osh-platform/OSH_PLATFORM_ABI.md read at commit fb5fca98e667 (v1 DRAFT, unfrozen):
+ * section 8.1 (PIPE_CREATE, STREAM_READ / WRITE / CLOSE / DUP; bounded pipes with backpressure, WOULD_BLOCK or block,
+ * BROKEN_PIPE when the reader closed), 8.5 (64 KiB per pipe minimum, LIMIT instead of truncation), 8.6 (error codes,
+ * shared with osh_op.h through osh_err.h), 4.4 (epoch: an id from another epoch fails STALE) and 9.2 (authority is
+ * checked at the moment of the effect). Anything below marked UNVERIFIED is this kernel's own choice where the draft
+ * names a thing but does not pin it.
+ *
+ * This is a byte pipe, separate from the 56-byte typed message ring in ipc.h. It reuses only the capability tables of
+ * ipc.h: every stream end is a capability in the caller's ck_cap_table, and every operation looks the handle up with
+ * ck_cap_lookup (live slot, matching generation, required right) when the effect happens, not before.
+ *
+ * read end capability with CK_R_READ (never CK_R_WRITE)
+ * write end capability with CK_R_WRITE (never CK_R_READ)
+ * optional CK_R_DERIVE (dup into the same table), CK_R_GRANT (dup into another table), CK_R_REVOKE (revoke the pipe)
+ *
+ * Lifetimes. A pipe lives while at least one end capability is open. reader_refs / writer_refs count the open end
+ * capabilities (create gives one of each, every dup adds one, every close removes one). Last writer closed: once the
+ * buffer is drained a read returns OK with 0 bytes (EOF). No reader: a write returns BROKEN_PIPE. Both counts zero: the
+ * pipe slot is scrubbed and freed. Capabilities are independent slots (no derive parent link), so a closed end frees
+ * its slot at once and a table can always be emptied; ipc.h cascading revoke is therefore not used for pipes.
+ * Every pipe capability must be released through ck_stream_close or ck_pipe_release_table: removing one with
+ * ck_cap_remove directly would leave its count held.
+ *
+ * Epoch. Each pool slot has an epoch, incremented every time the slot is (re)created. The capability resource carries
+ * it, so a capability that outlived its pipe never reaches the next pipe in that slot: STALE. A handle whose capability
+ * slot was closed (and maybe reused with a new generation) also fails STALE, by the ck_cap generation check.
+ *
+ * Revocation and cancellation. ck_pipe_revoke (CK_R_REVOKE on either end) kills the whole pipe: the buffered bytes are
+ * scrubbed, both ends are woken, and every later read, write, dup or cancel on any end returns REVOKED; no byte is
+ * delivered after a revoke. Only close still works, to release the handles. ck_pipe_cancel (the data right of that
+ * end) interrupts the end: the next or currently blocked read (or write) on that end returns INTERRUPTED with no
+ * bytes moved, once; a later call runs normally (section 10: an interrupted wait is retried without re-running an
+ * effect, and an interrupted call here never moved a byte).
+ *
+ * Blocking. With CK_PIPE_F_BLOCK a read on an empty pipe or a write on a full one parks the caller through the
+ * pool's wait hook instead of returning WOULD_BLOCK, and retries (re-checking authority) after the hook returns OK.
+ * A blocking call returns as soon as it moved at least one byte (partial I/O; the caller loops). The kernel's hook
+ * yields to the scheduler; the host test simulates it. Without a wait hook a blocking call returns WOULD_BLOCK.
+ *
+ * Memory: a fixed pool of CK_PIPE_POOL_PIPES pipes with CK_PIPE_CAPACITY bytes each, all static; nothing grows.
+ * Pure logic, no hardware: host-tested in tests/test_pipe.c (fixtures in tests/fixtures/pipe/), driven in QEMU by
+ * core/pipe_test.c (CK_PIPE_TEST). Host and QEMU evidence qualify nothing physical. */
+#ifndef AIENOS_CK_PIPE_H
+#define AIENOS_CK_PIPE_H
+
+#include <stddef.h>
+#include <stdint.h>
+#include "ipc.h"
+#include "osh_err.h"
+
+#define CK_PIPE_ABI_VERSION 1u /* section 3: abi_version of the platform frame */
+#define CK_PIPE_FRAME_MAGIC 0x4F534846u /* section 3: "OSHF", platform frame magic */
+#define CK_PIPE_CAPACITY 65536u /* bytes per pipe; section 8.5 minimum 64 KiB (LIMITS_GET max_pipe_bytes) */
+#define CK_PIPE_POOL_PIPES 4u /* pipes per pool; UNVERIFIED: the draft sets no pipe count */
+_Static_assert(CK_PIPE_CAPACITY >= 65536u, "section 8.5: at least 64 KiB per pipe");
+_Static_assert(CK_PIPE_POOL_PIPES >= 1u && CK_PIPE_POOL_PIPES <= 8u, "the pipe index has three bits in the resource");
+
+/* Capability resource of a stream end: tag 0x50 ("P") in bits 31..24, end in bit 23, pipe index in bits 22..20,
+ * epoch in bits 19..0. A slot whose epoch reached CK_PIPE_EPOCH_MAX is retired for good. Layout UNVERIFIED (own). */
+#define CK_PIPE_RES_TAG 0x50u
+#define CK_PIPE_EPOCH_MAX 0xFFFFFu
+static inline uint32_t ck_pipe_resource(unsigned idx, unsigned end, uint32_t epoch)
+{
+ return (CK_PIPE_RES_TAG << 24) | ((uint32_t)(end & 1u) << 23) | ((uint32_t)(idx & 7u) << 20) |
+ (epoch & CK_PIPE_EPOCH_MAX);
+}
+
+enum ck_pipe_end { CK_PIPE_END_READ = 0, CK_PIPE_END_WRITE = 1 };
+
+/* Platform op ids of the versioned op table. The draft names the operations; the numbers are UNVERIFIED (own). */
+enum ck_pipe_op {
+ CK_PIPE_OP_CREATE = 1, /* PIPE_CREATE() -> (read_stream, write_stream) */
+ CK_PIPE_OP_READ = 2, /* STREAM_READ(stream, out_slice) -> n, 0 = EOF */
+ CK_PIPE_OP_WRITE = 3, /* STREAM_WRITE(stream, in_slice) -> n, partial writes allowed */
+ CK_PIPE_OP_CLOSE = 4, /* STREAM_CLOSE(stream) */
+ CK_PIPE_OP_DUP = 5, /* STREAM_DUP(src_stream, rights, target table) -> stream; capability form, UNVERIFIED */
+};
+
+#define CK_PIPE_F_BLOCK 0x1u /* read / write flag: park through the wait hook instead of WOULD_BLOCK */
+
+/* Rights a create gives each end beyond its data right, and the only rights a dup may carry. */
+#define CK_PIPE_CTL_RIGHTS (CK_R_DERIVE | CK_R_GRANT | CK_R_REVOKE)
+
+struct ck_pipe_stats {
+ uint64_t bytes_written, bytes_read; /* bytes that moved */
+ uint64_t writes, reads; /* calls that moved at least one byte */
+ uint64_t max_resident; /* most bytes ever buffered at once (never above CK_PIPE_CAPACITY) */
+ uint64_t would_block; /* WOULD_BLOCK results seen, returned or waited on (backpressure) */
+ uint64_t waits; /* calls into the wait hook */
+ uint64_t wakeups; /* calls into the wake hook (an end had a waiter) */
+ uint64_t cancellations; /* INTERRUPTED results */
+ uint64_t revocations; /* pipes revoked */
+ uint64_t broken_pipe; /* BROKEN_PIPE results */
+ uint64_t eof; /* reads that returned EOF */
+ uint64_t refused; /* DENIED, STALE and REVOKED results at the effect boundary (pool total only) */
+};
+
+#define CK_PIPE_LIVE 0x1u
+#define CK_PIPE_REVOKED 0x2u
+#define CK_PIPE_CANCEL_READ 0x4u
+#define CK_PIPE_CANCEL_WRITE 0x8u
+
+struct ck_pipe {
+ uint8_t buf[CK_PIPE_CAPACITY]; /* ring: bytes head..head+len-1 (mod capacity) are buffered */
+ uint32_t head, len;
+ uint32_t epoch; /* 0 = never created */
+ uint32_t reader_refs, writer_refs;
+ uint32_t flags;
+ uint32_t waiting[2]; /* callers parked in the wait hook, per end */
+ struct ck_pipe_stats stats; /* this incarnation; reset at create */
+};
+
+/* Wait / wake hook. wait: the caller would block on (pipe, end); return OSH_E_OK to retry the operation (it re-checks
+ * authority) or an error (normally OSH_E_INTERRUPTED) to give up; the operation then returns it with no byte moved.
+ * wake: (pipe, end) may proceed (bytes, space, close, revoke or cancel); called only when that end has a waiter. */
+struct ck_pipe_hooks {
+ void *ctx;
+ unsigned (*wait)(void *ctx, unsigned pipe, unsigned end);
+ void (*wake)(void *ctx, unsigned pipe, unsigned end);
+};
+
+struct ck_pipe_pool {
+ struct ck_pipe pipes[CK_PIPE_POOL_PIPES];
+ const struct ck_pipe_hooks *hooks; /* may be 0 */
+ struct ck_pipe_stats total; /* every incarnation since init */
+ unsigned live; /* pipes currently live */
+};
+
+void ck_pipe_pool_init(struct ck_pipe_pool *p, const struct ck_pipe_hooks *hooks);
+/* 1 if no pipe is live (every end of every pipe was closed). */
+int ck_pipe_pool_empty(const struct ck_pipe_pool *p);
+
+/* PIPE_CREATE: a new pipe, both ends inserted into t. LIMIT if the pool or the table is full (nothing is left
+ * allocated). The draft's PIPE_CREATE takes no binding, so no prior capability is required (UNVERIFIED). */
+unsigned ck_pipe_create(struct ck_pipe_pool *p, struct ck_cap_table *t, struct ck_handle *rd, struct ck_handle *wr);
+/* STREAM_READ / STREAM_WRITE: *n = bytes moved (0 with OK on a read = EOF, or max == 0). */
+unsigned ck_stream_read(struct ck_pipe_pool *p, const struct ck_cap_table *t, struct ck_handle h, uint8_t *buf,
+ size_t max, unsigned flags, size_t *n);
+unsigned ck_stream_write(struct ck_pipe_pool *p, const struct ck_cap_table *t, struct ck_handle h, const uint8_t *buf,
+ size_t len, unsigned flags, size_t *n);
+/* STREAM_CLOSE: releases the capability. Works on a revoked pipe. STALE (after releasing the capability) if it named
+ * an earlier incarnation of the slot. */
+unsigned ck_stream_close(struct ck_pipe_pool *p, struct ck_cap_table *t, struct ck_handle h);
+/* STREAM_DUP: a new capability on the same end in `to` with `rights`, which must hold the end's data right, be a
+ * subset of the source rights and of data right | CK_PIPE_CTL_RIGHTS. Needs CK_R_DERIVE (to == from) or
+ * CK_R_GRANT (another table) on the source. */
+unsigned ck_stream_dup(struct ck_pipe_pool *p, struct ck_cap_table *from, struct ck_handle h, struct ck_cap_table *to,
+ unsigned rights, struct ck_handle *out);
+/* Revoke the whole pipe (CK_R_REVOKE on either end). */
+unsigned ck_pipe_revoke(struct ck_pipe_pool *p, const struct ck_cap_table *t, struct ck_handle h);
+/* Interrupt the end h names (its data right needed). */
+unsigned ck_pipe_cancel(struct ck_pipe_pool *p, const struct ck_cap_table *t, struct ck_handle h);
+/* Section 12 cleanup: closes every pipe capability in t. Returns how many were closed. */
+unsigned ck_pipe_release_table(struct ck_pipe_pool *p, struct ck_cap_table *t);
+
+/* ---- versioned op table ----
+ * A platform call frame is cells (u64): 0 magic CK_PIPE_FRAME_MAGIC, 1 abi_version, 2 op, 3 reserved (0), then the
+ * op's arguments; the frame must be exactly 4 + nargs cells. Arguments: READ / WRITE: handle (ck_handle_raw form),
+ * flags; CLOSE: handle; DUP: handle, rights, target (0 caller table, 1 peer table); CREATE: none. The byte slice is
+ * the read destination or the write source. Check order, first failure wins, all before any effect: frame shorter
+ * than 4 cells, bad magic or nonzero reserved -> INVALID_ARG; abi_version not CK_PIPE_ABI_VERSION or an unknown op
+ * -> NOT_SUPPORTED; wrong cell count, a generation-0 handle or unknown flag bits -> INVALID_ARG.
+ * Result: {error, value} as in section 8; PIPE_CREATE also fills value2 (the write end). value2 is UNVERIFIED. */
+struct ck_pipe_ret {
+ uint32_t error;
+ uint64_t value, value2;
+};
+unsigned ck_pipe_dispatch(struct ck_pipe_pool *p, struct ck_cap_table *caller, struct ck_cap_table *peer,
+ const uint64_t *frame, size_t ncells, uint8_t *slice, size_t slice_len,
+ struct ck_pipe_ret *ret);
+
+#endif
diff --git a/native/kernel/core/pipe_drive.h b/native/kernel/core/pipe_drive.h
new file mode 100644
index 00000000 ..447e774e
--- /dev/null
+++ b/native/kernel/core/pipe_drive.h
@@ -0,0 +1,222 @@
+/* pipe_drive.h -- TEST driver for the pipe primitive (pipe.h): a producer and a consumer task, each a step function,
+ * interleaved by the run-queue scheduler (sched.h), exchanging a binary payload (every fifth byte NUL) through one pipe.
+ * Shared by the host test (tests/test_pipe.c) and the QEMU self-test (core/pipe_test.c, CK_PIPE_TEST) so both run
+ * the same scenario. No libc, no allocation: the caller owns the world, the pool, both tables and the sink buffer.
+ *
+ * The producer owns the write end; the read end is handed to the consumer's own table with STREAM_DUP (READ, plus
+ * REVOKE for the revocation scenario) and the producer's copy is closed, so each task holds one end. Non-blocking mode:
+ * a WOULD_BLOCK ends the step with no progress and the scheduler runs the other task. Blocking mode: the wait hook
+ * marks the caller blocked and keeps ticking the scheduler, running the other task's steps, until the wake hook fires
+ * for that end (OK, the call retries) or the spin bound runs out (INTERRUPTED: a stalled peer). Static functions only. */
+#ifndef AIENOS_CK_PIPE_DRIVE_H
+#define AIENOS_CK_PIPE_DRIVE_H
+
+#include "pipe.h"
+#include "sched.h"
+
+#define PD_CHUNK_MAX 8192u
+#define PD_SPIN_MAX 64u
+#define PD_TICK_MAX 2000000u
+
+struct pd_world;
+struct pd_task {
+ uint32_t id;
+ int done, blocked;
+ void (*step)(struct pd_world *w, struct pd_task *t);
+};
+
+struct pd_world {
+ struct ck_pipe_pool *pool;
+ struct ck_cap_table *prod_t, *cons_t;
+ struct ck_pipe_hooks hooks;
+ struct ck_sched sched;
+ struct pd_task tasks[2]; /* 0 producer, 1 consumer */
+ struct pd_task *current;
+ struct ck_handle w, r;
+ uint8_t woken[CK_PIPE_POOL_PIPES][2];
+ unsigned flags; /* CK_PIPE_F_BLOCK or 0 */
+ size_t total; /* payload bytes to send */
+ size_t chunk_w, chunk_r; /* bytes per producer write / consumer read */
+ unsigned prod_every, cons_every; /* a task moves bytes on one step in this many (a slow side), 0 or 1 = every step */
+ size_t revoke_at; /* consumer revokes the pipe once it has this many bytes (0 = never) */
+ uint8_t *sink; /* total bytes */
+ uint8_t wbuf[PD_CHUNK_MAX], rbuf[PD_CHUNK_MAX];
+ /* results */
+ size_t sent, recvd, reads_after_revoke;
+ unsigned setup_err, prod_err, cons_err; /* OSH_E_OK, or the error the task ended on */
+ int eof_seen, revoked;
+ uint64_t ticks, wait_spins, prod_steps, cons_steps;
+};
+
+static inline uint8_t pd_byte(size_t i)
+{
+ return i % 5 == 0 ? 0 : (uint8_t)(((uint32_t)i * 2654435761u) >> 13);
+}
+
+static inline struct pd_task *pd_find(struct pd_world *w, uint32_t id)
+{
+ return w->tasks[0].id == id ? &w->tasks[0] : w->tasks[1].id == id ? &w->tasks[1] : 0;
+}
+
+/* One scheduler tick: run the picked task's step unless it is blocked (parked on the stack) or done. */
+static inline int pd_tick(struct pd_world *w)
+{
+ uint32_t id = 0;
+ if (ck_sched_tick(&w->sched, 0, &id) != 1)
+ return 0;
+ w->ticks++;
+ struct pd_task *t = pd_find(w, id);
+ if (!t || t->blocked || t->done)
+ return 1;
+ struct pd_task *prev = w->current;
+ w->current = t;
+ t->step(w, t);
+ w->current = prev;
+ if (t->done)
+ ck_sched_remove(&w->sched, t->id);
+ return 1;
+}
+
+static inline unsigned pd_wait(void *ctx, unsigned pipe, unsigned end)
+{
+ struct pd_world *w = ctx;
+ struct pd_task *me = w->current;
+ if (!me)
+ return OSH_E_INTERRUPTED;
+ me->blocked = 1;
+ w->woken[pipe][end] = 0;
+ for (unsigned s = 0; s < PD_SPIN_MAX && !w->woken[pipe][end]; s++) {
+ w->wait_spins++;
+ if (!pd_tick(w))
+ break;
+ }
+ me->blocked = 0;
+ return w->woken[pipe][end] ? OSH_E_OK : OSH_E_INTERRUPTED;
+}
+
+static inline void pd_wake(void *ctx, unsigned pipe, unsigned end)
+{
+ struct pd_world *w = ctx;
+ w->woken[pipe][end] = 1;
+}
+
+static inline void pd_producer(struct pd_world *w, struct pd_task *t)
+{
+ w->prod_steps++;
+ if (w->prod_every > 1 && w->prod_steps % w->prod_every)
+ return; /* thinking: no I/O this step */
+ if (w->sent == w->total) {
+ ck_stream_close(w->pool, w->prod_t, w->w); /* last writer: the consumer sees EOF once drained */
+ t->done = 1;
+ return;
+ }
+ size_t want = w->total - w->sent;
+ if (want > w->chunk_w)
+ want = w->chunk_w;
+ for (size_t i = 0; i < want; i++)
+ w->wbuf[i] = pd_byte(w->sent + i);
+ size_t n = 0;
+ unsigned e = ck_stream_write(w->pool, w->prod_t, w->w, w->wbuf, want, w->flags, &n);
+ if (e == OSH_E_OK) {
+ w->sent += n;
+ } else if (e != OSH_E_WOULD_BLOCK) {
+ w->prod_err = e;
+ ck_stream_close(w->pool, w->prod_t, w->w);
+ t->done = 1;
+ }
+}
+
+static inline void pd_consumer(struct pd_world *w, struct pd_task *t)
+{
+ w->cons_steps++;
+ if (w->cons_every > 1 && w->cons_steps % w->cons_every)
+ return;
+ size_t n = 0;
+ unsigned e = ck_stream_read(w->pool, w->cons_t, w->r, w->rbuf, w->chunk_r, w->flags, &n);
+ if (e == OSH_E_OK && n > 0) {
+ if (w->revoked)
+ w->reads_after_revoke++;
+ for (size_t i = 0; i < n && w->recvd + i < w->total; i++)
+ w->sink[w->recvd + i] = w->rbuf[i];
+ w->recvd += n;
+ if (w->revoke_at && !w->revoked && w->recvd >= w->revoke_at) {
+ w->revoked = ck_pipe_revoke(w->pool, w->cons_t, w->r) == OSH_E_OK;
+ if (!w->revoked)
+ w->cons_err = OSH_E_IO;
+ }
+ } else if (e == OSH_E_OK) {
+ w->eof_seen = 1;
+ ck_stream_close(w->pool, w->cons_t, w->r);
+ t->done = 1;
+ } else if (e != OSH_E_WOULD_BLOCK) {
+ w->cons_err = e;
+ ck_stream_close(w->pool, w->cons_t, w->r);
+ t->done = 1;
+ }
+}
+
+/* Run one transfer. pool and both tables must be fresh (the pool initialised with &w->hooks by this call). */
+static inline void pd_run(struct pd_world *w, struct ck_pipe_pool *pool, struct ck_cap_table *prod_t,
+ struct ck_cap_table *cons_t, uint8_t *sink, size_t total, size_t chunk_w, size_t chunk_r,
+ unsigned flags, unsigned prod_every, unsigned cons_every, size_t revoke_at)
+{
+ *w = (struct pd_world){ .pool = pool, .prod_t = prod_t, .cons_t = cons_t, .sink = sink, .total = total,
+ .chunk_w = chunk_w > PD_CHUNK_MAX ? PD_CHUNK_MAX : chunk_w,
+ .chunk_r = chunk_r > PD_CHUNK_MAX ? PD_CHUNK_MAX : chunk_r, .flags = flags,
+ .prod_every = prod_every, .cons_every = cons_every, .revoke_at = revoke_at };
+ w->hooks = (struct ck_pipe_hooks){ w, pd_wait, pd_wake };
+ ck_pipe_pool_init(pool, &w->hooks);
+ struct ck_handle r0;
+ w->setup_err = ck_pipe_create(pool, prod_t, &r0, &w->w);
+ if (w->setup_err != OSH_E_OK)
+ return;
+ w->setup_err = ck_stream_dup(pool, prod_t, r0, cons_t, CK_R_READ | (revoke_at ? CK_R_REVOKE : 0), &w->r);
+ unsigned c = ck_stream_close(pool, prod_t, r0); /* the producer keeps only the write end */
+ if (w->setup_err == OSH_E_OK)
+ w->setup_err = c;
+ if (w->setup_err != OSH_E_OK) {
+ ck_pipe_release_table(pool, prod_t);
+ ck_pipe_release_table(pool, cons_t);
+ return;
+ }
+ static const uint8_t classes[1] = { 0 };
+ ck_sched_init(&w->sched, 1, classes, CK_SCHED_MAX_TASKS, 1);
+ w->tasks[0] = (struct pd_task){ .id = 0x50524f44u, .step = pd_producer }; /* "PROD" */
+ w->tasks[1] = (struct pd_task){ .id = 0x434f4e53u, .step = pd_consumer }; /* "CONS" */
+ ck_sched_enqueue(&w->sched, w->tasks[0].id, CK_PRIO_NORMAL);
+ ck_sched_enqueue(&w->sched, w->tasks[1].id, CK_PRIO_NORMAL);
+ while ((!w->tasks[0].done || !w->tasks[1].done) && w->ticks < PD_TICK_MAX)
+ if (!pd_tick(w))
+ break;
+ /* section 12: whatever happened, no end stays open */
+ ck_pipe_release_table(pool, prod_t);
+ ck_pipe_release_table(pool, cons_t);
+}
+
+/* Bytes of the sink that differ from the payload, over what was received. */
+static inline size_t pd_mismatches(const struct pd_world *w)
+{
+ size_t bad = 0, n = w->recvd < w->total ? w->recvd : w->total;
+ for (size_t i = 0; i < n; i++)
+ bad += w->sink[i] != pd_byte(i);
+ return bad;
+}
+
+static inline size_t pd_nul_count(const struct pd_world *w)
+{
+ size_t z = 0, n = w->recvd < w->total ? w->recvd : w->total;
+ for (size_t i = 0; i < n; i++)
+ z += w->sink[i] == 0;
+ return z;
+}
+
+/* 1 if the table holds no live slot at all (tombstones included). */
+static inline int pd_table_empty(const struct ck_cap_table *t)
+{
+ for (unsigned i = 0; i < CK_CAP_SLOTS; i++)
+ if (t->slots[i].live)
+ return 0;
+ return 1;
+}
+
+#endif
diff --git a/native/kernel/core/pipe_test.c b/native/kernel/core/pipe_test.c
new file mode 100644
index 00000000 ..57f382d6
--- /dev/null
+++ b/native/kernel/core/pipe_test.c
@@ -0,0 +1,172 @@
+/* pipe_test.c -- AIENOS_CK_PIPE kernel self-test (TEST ONLY, CK_PIPE_TEST=1; gate scripts/qemu_ck_pipe_test.sh).
+ *
+ * Drives the pipe primitive (core/pipe.c, aienos-mv#428) inside the kernel: a producer and a consumer task, step
+ * functions interleaved by the run-queue scheduler (core/sched.c), each holding one end in its own capability table,
+ * through the same driver the host test uses (core/pipe_drive.h). The kernel's wait hook yields to the scheduler
+ * (it keeps ticking it, running the other task) until the wake hook fires; this is cooperative scheduling inside one
+ * kernel thread, not a context switch between M3 threads. Lines on the serial console:
+ * pipe_check: name=<check> result=PASS|FAIL <details>; <label>
+ * pipe_test: done checks=<n> failed=<n> capacity=<bytes> pool_pipes=<n>; <label>
+ * QEMU (aarch64 virt), TEST build, not physical: qualifies nothing physical. */
+#ifndef CK_PIPE_TEST
+#error "pipe_test is test-only: build with make CK_PIPE_TEST=1"
+#endif
+#ifdef CK_HARDWARE_STAGING
+#error "CK_PIPE_TEST cannot be combined with CK_HARDWARE_STAGING"
+#endif
+#include "ck_internal.h"
+#include "pipe.h"
+#include "pipe_drive.h"
+
+#define LABEL "QEMU (aarch64 virt), TEST build, not physical"
+#define PAYLOAD (160u * 1024u) /* 2.5 pipe capacities */
+
+static struct ck_pipe_pool pool;
+static struct ck_cap_table ta, tb;
+static struct pd_world world;
+static uint8_t sink[PAYLOAD];
+static unsigned checks, failed;
+
+static void fresh(void)
+{
+ ck_cap_init(&ta, 0x41, CK_CAP_SLOTS);
+ ck_cap_init(&tb, 0x42, CK_CAP_SLOTS);
+}
+
+static int empty(void)
+{
+ return pd_table_empty(&ta) && pd_table_empty(&tb) && ck_pipe_pool_empty(&pool);
+}
+
+static void verdict(const char *name, int ok)
+{
+ checks++;
+ failed += !ok;
+ ck_printf("pipe_check: name=%s result=%s tables_empty=%d; %s\n", name, ok ? "PASS" : "FAIL", empty(), LABEL);
+}
+
+static size_t expected_nuls(size_t n)
+{
+ size_t z = 0;
+ for (size_t i = 0; i < n; i++)
+ z += pd_byte(i) == 0;
+ return z;
+}
+
+static void transfer(const char *name, unsigned flags)
+{
+ fresh();
+ pd_run(&world, &pool, &ta, &tb, sink, PAYLOAD, 8192, 1000, flags, 1, 4, 0);
+ const struct ck_pipe_stats *s = &pool.total;
+ size_t bad = pd_mismatches(&world), nul = pd_nul_count(&world);
+ ck_printf("pipe_detail: %s bytes=%lu sent=%lu nul=%lu expected_nul=%lu mismatches=%lu would_block=%llu waits=%llu "
+ "wakeups=%llu max_resident=%llu capacity=%u eof=%d prod_steps=%llu cons_steps=%llu ticks=%llu\n",
+ name, (unsigned long)world.recvd, (unsigned long)world.sent, (unsigned long)nul,
+ (unsigned long)expected_nuls(PAYLOAD), (unsigned long)bad, (unsigned long long)s->would_block,
+ (unsigned long long)s->waits, (unsigned long long)s->wakeups, (unsigned long long)s->max_resident,
+ CK_PIPE_CAPACITY, world.eof_seen, (unsigned long long)world.prod_steps,
+ (unsigned long long)world.cons_steps, (unsigned long long)world.ticks);
+ int moved = world.setup_err == OSH_E_OK && world.prod_err == OSH_E_OK && world.cons_err == OSH_E_OK &&
+ world.recvd == PAYLOAD && world.sent == PAYLOAD && bad == 0 && nul == expected_nuls(PAYLOAD) &&
+ nul > 0 && s->bytes_read == PAYLOAD;
+ if (!flags) {
+ verdict("payload_nul_byte_for_byte", moved);
+ verdict("backpressure_would_block", moved && s->would_block > 0 && s->max_resident == CK_PIPE_CAPACITY &&
+ world.prod_steps > 1 && world.cons_steps > 1);
+ verdict("eof_after_last_writer", moved && world.eof_seen && s->eof == 1);
+ verdict("bounded_memory", s->max_resident <= CK_PIPE_CAPACITY && empty());
+ } else {
+ verdict("blocking_wait_wake_through_scheduler", moved && s->waits > 0 && s->wakeups > 0 &&
+ s->cancellations == 0 && world.eof_seen && empty());
+ }
+}
+
+static void broken_pipe(void)
+{
+ fresh();
+ ck_pipe_pool_init(&pool, 0);
+ struct ck_handle r, w;
+ size_t n = 1;
+ static const uint8_t b[3] = { 'a', 0, 'b' };
+ int ok = ck_pipe_create(&pool, &ta, &r, &w) == OSH_E_OK;
+ ok = ok && ck_stream_close(&pool, &ta, r) == OSH_E_OK;
+ unsigned e = ck_stream_write(&pool, &ta, w, b, 3, 0, &n);
+ ok = ok && e == OSH_E_BROKEN_PIPE && n == 0 && pool.total.broken_pipe == 1;
+ ok = ok && ck_stream_close(&pool, &ta, w) == OSH_E_OK;
+ ck_printf("pipe_detail: broken_pipe write_after_reader_close=%s n=%lu\n", osh_err_label(e), (unsigned long)n);
+ verdict("broken_pipe_no_reader", ok && empty());
+}
+
+static void revoked_write(void)
+{
+ fresh();
+ ck_pipe_pool_init(&pool, 0);
+ struct ck_handle r, w;
+ size_t n = 0, m = 9;
+ uint8_t got[4];
+ static const uint8_t b1[2] = { 'o', 'k' }, b2[2] = { 0, 'x' };
+ int ok = ck_pipe_create(&pool, &ta, &r, &w) == OSH_E_OK;
+ ok = ok && ck_stream_write(&pool, &ta, w, b1, 2, 0, &n) == OSH_E_OK && n == 2;
+ ok = ok && ck_pipe_revoke(&pool, &ta, w) == OSH_E_OK;
+ unsigned ew = ck_stream_write(&pool, &ta, w, b2, 2, 0, &n);
+ unsigned er = ck_stream_read(&pool, &ta, r, got, 4, 0, &m);
+ ok = ok && ew == OSH_E_REVOKED && n == 0 && er == OSH_E_REVOKED && m == 0 && pool.total.bytes_read == 0;
+ ok = ok && ck_stream_close(&pool, &ta, r) == OSH_E_OK && ck_stream_close(&pool, &ta, w) == OSH_E_OK;
+ ck_printf("pipe_detail: revoked write=%s n=%lu read=%s n=%lu bytes_delivered=%llu\n", osh_err_label(ew),
+ (unsigned long)n, osh_err_label(er), (unsigned long)m, (unsigned long long)pool.total.bytes_read);
+ verdict("revoked_write_refused_no_bytes_after", ok && empty());
+
+ /* revoked mid-stream by the consumer through the scheduler: nothing is read after the revoke */
+ fresh();
+ pd_run(&world, &pool, &ta, &tb, sink, PAYLOAD, 8192, 1000, CK_PIPE_F_BLOCK, 1, 4, 50000);
+ ck_printf("pipe_detail: revoke_midstream recvd=%lu reads_after_revoke=%lu prod=%s cons=%s bytes_read=%llu\n",
+ (unsigned long)world.recvd, (unsigned long)world.reads_after_revoke, osh_err_label(world.prod_err),
+ osh_err_label(world.cons_err), (unsigned long long)pool.total.bytes_read);
+ verdict("revoke_midstream_no_data_after", world.revoked && world.reads_after_revoke == 0 &&
+ world.prod_err == OSH_E_REVOKED && world.cons_err == OSH_E_REVOKED &&
+ pool.total.bytes_read == world.recvd && pd_mismatches(&world) == 0 &&
+ empty());
+}
+
+static void stale_and_ops(void)
+{
+ fresh();
+ ck_pipe_pool_init(&pool, 0);
+ struct ck_handle r, w, r2, w2;
+ size_t n = 0;
+ uint8_t b[2] = { 0, 0 };
+ int ok = ck_pipe_create(&pool, &ta, &r, &w) == OSH_E_OK;
+ ok = ok && ck_stream_close(&pool, &ta, r) == OSH_E_OK && ck_stream_close(&pool, &ta, w) == OSH_E_OK;
+ ok = ok && ck_pipe_create(&pool, &ta, &r2, &w2) == OSH_E_OK && r2.index == r.index;
+ unsigned es = ck_stream_read(&pool, &ta, r, b, 2, 0, &n);
+ ok = ok && es == OSH_E_STALE && ck_pipe_release_table(&pool, &ta) == 2;
+ verdict("stale_handle_after_close", ok && empty());
+
+ struct ck_pipe_ret ret;
+ uint64_t unknown[4] = { CK_PIPE_FRAME_MAGIC, CK_PIPE_ABI_VERSION, 9, 0 };
+ uint64_t v2[4] = { CK_PIPE_FRAME_MAGIC, 2, CK_PIPE_OP_CREATE, 0 };
+ unsigned eu = ck_pipe_dispatch(&pool, &ta, &tb, unknown, 4, 0, 0, &ret);
+ unsigned ev = ck_pipe_dispatch(&pool, &ta, &tb, v2, 4, 0, 0, &ret);
+ ck_printf("pipe_detail: op_table abi_version=%u unknown_op=%s version_2=%s\n", CK_PIPE_ABI_VERSION,
+ osh_err_label(eu), osh_err_label(ev));
+ verdict("unknown_op_not_supported", eu == OSH_E_NOT_SUPPORTED && ev == OSH_E_NOT_SUPPORTED && empty());
+
+ ok = ck_pipe_create(&pool, &ta, &r, &w) == OSH_E_OK && ck_pipe_cancel(&pool, &ta, w) == OSH_E_OK;
+ unsigned ei = ck_stream_write(&pool, &ta, w, b, 2, 0, &n);
+ ok = ok && ei == OSH_E_INTERRUPTED && n == 0 && ck_stream_write(&pool, &ta, w, b, 2, 0, &n) == OSH_E_OK && n == 2;
+ ok = ok && ck_pipe_release_table(&pool, &ta) == 2;
+ verdict("cancel_interrupts_once", ok && empty());
+}
+
+void ck_pipe_selftest(void)
+{
+ ck_printf("pipe_test: TEST-ONLY pipe self-test begin abi_version=%u capacity=%u pool_pipes=%u payload=%u; %s\n",
+ CK_PIPE_ABI_VERSION, CK_PIPE_CAPACITY, CK_PIPE_POOL_PIPES, PAYLOAD, LABEL);
+ transfer("nonblocking", 0);
+ transfer("blocking", CK_PIPE_F_BLOCK);
+ broken_pipe();
+ revoked_write();
+ stale_and_ops();
+ ck_printf("pipe_test: done checks=%u failed=%u capacity=%u pool_pipes=%u; %s\n", checks, failed, CK_PIPE_CAPACITY,
+ CK_PIPE_POOL_PIPES, LABEL);
+}
diff --git a/native/kernel/dev/.crumb b/native/kernel/dev/.crumb
index 722e1a6b ..264e810a 100644
--- a/native/kernel/dev/.crumb
+++ b/native/kernel/dev/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-13T23:37:04Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:ebdd66c0966fba664f36dc167836b98d26ffae97f9502b4409e9c22da687b473 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 43,
- "generated_at_commit": "23c8bcd5490dd2ec9ded661ffefd5ecb5533dcec ",
- "source_tree": "sha256:802face91e606e3063e35e7499217980f488aa11797961decc4c17e21bf4c22f "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/dev/tests/usb_audio_test.c b/native/kernel/dev/tests/usb_audio_test.c
new file mode 100644
index 00000000 ..4c158953
--- /dev/null
+++ b/native/kernel/dev/tests/usb_audio_test.c
@@ -0,0 +1,224 @@
+/* usb_audio_test.c -- host tests for the audio.output pure logic
+ * (dev/usb_audio.c, issue #85): the Rust reference vectors and regressions of
+ * crates/aienos-kernel/src/usb/audio.rs, plus hostile descriptors. Hosted
+ * test code only. Run by make usb-audio-test (and stage-test). */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "usb_audio.h"
+
+static int checks, failures;
+#define CHECK(c) \
+ do { \
+ checks++; \
+ if (!(c)) { \
+ failures++; \
+ printf(" FAIL %s:%d: %s\n", __FILE__, __LINE__, #c); \
+ } \
+ } while (0)
+
+/* Real UAC1 shape: AC, AS alt zero, stereo Type I PCM 16-bit/48 kHz, OUT. */
+static const uint8_t UAC1[] = {
+ 9, 2, 73, 0, 2, 1, 0, 0x80, 50, 9, 4, 0, 0, 0, 1, 1, 0, 0, 9, 0x24, 1, 0, 1, 0x26, 0, 1, 1,
+ 9, 4, 1, 0, 0, 1, 2, 0, 0, 9, 4, 1, 1, 1, 1, 2, 0, 0, 7, 0x24, 1, 1, 2, 3, 0, 11, 0x24, 2,
+ 1, 2, 2, 16, 1, 0x80, 0xbb, 0, 9, 5, 1, 1, 192, 0, 1, 0, 0,
+};
+/* UAC2 clock source and Type I 16-bit stereo format, one 48 kHz clock. */
+static const uint8_t UAC2[] = {
+ 9, 2, 85, 0, 2, 1, 0, 0x80, 50, 9, 4, 0, 0, 0, 1, 1, 0, 0, 9, 0x24, 1, 0, 2, 9, 0, 1, 1, 8,
+ 0x24, 0x0a, 3, 7, 0, 0, 0, 9, 4, 1, 0, 0, 1, 2, 0, 0, 9, 4, 1, 1, 1, 1, 2, 0, 0, 16, 0x24,
+ 1, 1, 0, 1, 1, 0, 0, 0, 2, 3, 0, 0, 0, 0, 6, 0x24, 2, 1, 2, 16, 9, 5, 1, 1, 192, 0, 1, 0,
+ 0,
+};
+
+static size_t find(const uint8_t *v, size_t n, const uint8_t *pat, size_t pn)
+{
+ for (size_t i = 0; i + pn <= n; i++)
+ if (!memcmp(v + i, pat, pn)) return i;
+ return (size_t)-1;
+}
+
+static void test_parse(void)
+{
+ ck_uac_stream s;
+ CHECK(ck_uac_select_output(UAC1, sizeof UAC1, &s) == 0);
+ CHECK(s.version == CK_UAC1 && s.interface == 1 && s.alternate == 1 && s.channels == 2 && s.bit_resolution == 16);
+ CHECK(s.control_interface == 0 && s.endpoint_address == 1 && s.max_packet == 192 && s.interval == 1);
+ CHECK(s.rate_count == 1 && s.sample_rates[0] == 48000u && s.clock_source == CK_UAC_NO_CLOCK);
+ CHECK(ck_uac_select_output(UAC2, sizeof UAC2, &s) == 0);
+ CHECK(s.version == CK_UAC2 && s.clock_source == 3 && s.channels == 2 && s.subframe_bytes == 2);
+}
+
+static void test_uac1_channels_from_format_type(void)
+{
+ /* UAC1 AS_GENERAL offset 4 is bDelay, not a channel count. */
+ uint8_t v[sizeof UAC1];
+ memcpy(v, UAC1, sizeof v);
+ static const uint8_t asg[] = {7, 0x24, 1, 1, 2, 3, 0};
+ size_t at = find(v, sizeof v, asg, sizeof asg);
+ CHECK(at != (size_t)-1);
+ v[at + 4] = 7;
+ ck_uac_stream s;
+ CHECK(ck_uac_select_output(v, sizeof v, &s) == 0 && s.channels == 2);
+}
+
+static void test_hostile(void)
+{
+ ck_uac_stream s;
+ uint8_t v[sizeof UAC1];
+ static const uint8_t ft[] = {11, 0x24, 2};
+ size_t at = find(UAC1, sizeof UAC1, ft, sizeof ft);
+ CHECK(at != (size_t)-1);
+ /* Short UAC1 FORMAT_TYPE_I (bLength 7 < 8): no read past it, no crash. */
+ memcpy(v, UAC1, sizeof v);
+ v[at] = 7;
+ (void)ck_uac_select_output(v, sizeof v, &s);
+ /* Every truncation of the descriptor is refused, in an exact-size heap
+ * buffer so ASan catches any read past it. */
+ for (size_t n = 0; n < sizeof UAC1; n++) {
+ uint8_t *cut = (uint8_t *)malloc(n ? n : 1);
+ if (!cut) continue;
+ memcpy(cut, UAC1, n);
+ CHECK(ck_uac_select_output(cut, n, &s) == -1);
+ free(cut);
+ }
+ /* Zero bLength inside the walk is malformed. */
+ memcpy(v, UAC1, sizeof v);
+ v[9] = 0;
+ CHECK(ck_uac_select_output(v, sizeof v, &s) == -1);
+ /* An element running past wTotalLength is malformed. */
+ memcpy(v, UAC1, sizeof v);
+ v[sizeof v - 9] = 40;
+ CHECK(ck_uac_select_output(v, sizeof v, &s) == -1);
+ /* Not a configuration descriptor, NULL arguments. */
+ memcpy(v, UAC1, sizeof v);
+ v[1] = 1;
+ CHECK(ck_uac_select_output(v, sizeof v, &s) == -1);
+ CHECK(ck_uac_select_output(NULL, 9, &s) == -1);
+ CHECK(ck_uac_select_output(UAC1, sizeof UAC1, NULL) == -1);
+ /* An IN endpoint (a capture stream) is never selected for output. */
+ memcpy(v, UAC1, sizeof v);
+ v[sizeof v - 7] = 0x81;
+ CHECK(ck_uac_select_output(v, sizeof v, &s) == -1);
+ /* A mono stream is refused. */
+ memcpy(v, UAC1, sizeof v);
+ v[at + 4] = 1;
+ CHECK(ck_uac_select_output(v, sizeof v, &s) == -1);
+ /* 44.1 kHz only (48 kHz not offered) is refused. */
+ memcpy(v, UAC1, sizeof v);
+ v[at + 8] = 0x44;
+ v[at + 9] = 0xac;
+ CHECK(ck_uac_select_output(v, sizeof v, &s) == -1);
+}
+
+static void test_interval(void)
+{
+ CHECK(ck_uac_interval_us(0, 1) == 1000u && ck_uac_interval_us(0, 4) == 1000u);
+ CHECK(ck_uac_interval_us(1, 1) == 125u && ck_uac_interval_us(1, 4) == 1000u);
+ CHECK(ck_uac_interval_us(1, 16) == (125u << 15) && ck_uac_interval_us(1, 17) == 0);
+ CHECK(ck_uac_interval_us(0, 0) == 0 && ck_uac_interval_us(1, 0) == 0);
+}
+
+static void test_framer(void)
+{
+ ck_pcm_framer f;
+ CHECK(ck_pcm_framer_init(&f, 44100, 1, 2, 1000) == 0);
+ size_t frames = 0;
+ int saw44 = 0, saw45 = 0;
+ for (int i = 0; i < 1000; i++) {
+ size_t n = ck_pcm_next_bytes(&f) / 2;
+ frames += n;
+ saw44 |= n == 44;
+ saw45 |= n == 45;
+ }
+ CHECK(frames == 44100 && saw44 && saw45);
+
+ CHECK(ck_pcm_framer_init(&f, 44100, 2, 2, 1000) == 0);
+ int16_t src[256], out[90];
+ for (unsigned i = 0; i < 256; i++) src[i] = 7;
+ size_t cursor = 0, total = 0;
+ for (int i = 0; i < 1000; i++) total += ck_pcm_fill_i16(&f, src, 256, &cursor, out, 90) * 2;
+ CHECK(total == 176400);
+
+ CHECK(ck_pcm_framer_init(&f, 48000, 2, 2, 1000) == 0);
+ const int16_t ring[5] = {1, 2, 3, 4, 5};
+ int16_t o[192];
+ cursor = 3;
+ CHECK(ck_pcm_fill_i16(&f, ring, 5, &cursor, o, 192) == 96);
+ CHECK(o[0] == 4 && o[1] == 5 && o[2] == 1 && o[3] == 2 && cursor == 4);
+ /* Empty ring: silence. */
+ for (unsigned i = 0; i < 192; i++) o[i] = 9;
+ CHECK(ck_pcm_fill_i16(&f, NULL, 0, &cursor, o, 192) == 96 && o[0] == 0 && o[95] == 0 && o[96] == 9);
+
+ CHECK(ck_pcm_framer_init(&f, 0, 2, 2, 1000) == -1);
+ CHECK(ck_pcm_framer_init(&f, 48000, 0, 2, 1000) == -1);
+ CHECK(ck_pcm_framer_init(&f, 48000, 2, 0, 1000) == -1);
+ CHECK(ck_pcm_framer_init(&f, 48000, 2, 2, 0) == -1);
+ CHECK(ck_pcm_next_bytes(&f) == 0);
+}
+
+static void test_schedule(void)
+{
+ ck_pcm_framer f;
+ ck_pcm_framer_init(&f, 48000, 2, 2, 1000);
+ const ck_uac_packet pk[2] = {{0x1000, 192}, {0x2000, 192}};
+ int16_t pcm[192];
+ ck_uac_trb t[2];
+ memset(t, 0xa5, sizeof t);
+ size_t cursor = 0;
+ CHECK(ck_uac_schedule(&f, 2046, 2, pk, 2, NULL, 0, &cursor, pcm, 192, 96, t, 2) == 2);
+ CHECK(((t[0].d[3] >> 20) & 0x7ff) == 0 && ((t[1].d[3] >> 20) & 0x7ff) == 1);
+ CHECK(t[0].d[2] == 192 && t[1].d[2] == 192);
+ CHECK(t[0].d[0] == 0x1000 && t[1].d[0] == 0x2000 && t[0].d[1] == 0);
+ CHECK(((t[0].d[3] >> 10) & 0x3f) == CK_UAC_TRB_ISOCH);
+ CHECK((t[0].d[3] & CK_UAC_TRB_IOC) == 0 && (t[1].d[3] & CK_UAC_TRB_IOC) != 0);
+ /* No SIA, no cycle (the ring writer sets it), no CHAIN, TBC zero. */
+ CHECK((t[0].d[3] & (CK_UAC_TRB_SIA | 1u | 0x10u | (7u << 7))) == 0);
+
+ /* 96 kHz stereo needs 384 B per 1 ms packet: it does not fit 192 B, so
+ * nothing is scheduled and no sample is consumed. */
+ ck_pcm_framer_init(&f, 96000, 2, 2, 1000);
+ int16_t ring[512];
+ for (unsigned i = 0; i < 512; i++) ring[i] = 7;
+ int16_t pcm2[256];
+ ck_uac_trb t1[1];
+ const ck_uac_packet small[1] = {{0x1000, 192}};
+ cursor = 0;
+ CHECK(ck_uac_schedule(&f, 0, 1, small, 1, ring, 512, &cursor, pcm2, 256, 256, t1, 1) == 0);
+ CHECK(cursor == 0);
+ const ck_uac_packet big[1] = {{0x1000, 1024}};
+ CHECK(ck_uac_schedule(&f, 0, 1, big, 1, ring, 512, &cursor, pcm2, 256, 0, t1, 1) == 0);
+ /* Fits now: one packet, IOC set. */
+ CHECK(ck_uac_schedule(&f, 0, 1, big, 1, ring, 512, &cursor, pcm2, 256, 256, t1, 1) == 1);
+ CHECK(t1[0].d[2] == 384 && cursor == 192 && (t1[0].d[3] & CK_UAC_TRB_IOC));
+}
+
+static void test_tone(void)
+{
+ ck_test_tone t;
+ CHECK(ck_test_tone_init(&t, 440, 48000) == 0);
+ int lo = 0, hi = 0, ok = 1;
+ for (int i = 0; i < 48000; i++) {
+ int16_t x = ck_test_tone_next(&t);
+ /* The tone never emits INT16_MIN: it is the one sample whose negation overflows. */
+ ok &= x != -32768;
+ lo |= x < -30000;
+ hi |= x > 30000;
+ }
+ CHECK(ok && lo && hi);
+ CHECK(ck_test_tone_init(&t, 24000, 48000) == -1);
+ CHECK(ck_test_tone_init(&t, 440, 0) == -1);
+}
+
+int main(void)
+{
+ test_parse();
+ test_uac1_channels_from_format_type();
+ test_hostile();
+ test_interval();
+ test_framer();
+ test_schedule();
+ test_tone();
+ printf("CK_USB_AUDIO_TEST: %s checks=%d failures=%d\n", failures ? "FAIL" : "PASS", checks, failures);
+ return failures ? 1 : 0;
+}
diff --git a/native/kernel/dev/usb_audio.c b/native/kernel/dev/usb_audio.c
new file mode 100644
index 00000000 ..8ef92c55
--- /dev/null
+++ b/native/kernel/dev/usb_audio.c
@@ -0,0 +1,251 @@
+/* usb_audio.c -- audio.output pure logic (see usb_audio.h). Freestanding. */
+#include "usb_audio.h"
+
+#define D_CONFIG 2u
+#define D_INTERFACE 4u
+#define D_ENDPOINT 5u
+#define D_CS_INTERFACE 0x24u
+
+static uint32_t le24(const uint8_t *b) { return (uint32_t)b[0] | ((uint32_t)b[1] << 8) | ((uint32_t)b[2] << 16); }
+
+static int usable(const ck_uac_stream *s)
+{
+ if (s->channels < 2 || s->subframe_bytes < 2 || s->bit_resolution < 16) return 0;
+ if (s->rate_count == 0) return 1;
+ for (unsigned i = 0; i < s->rate_count; i++)
+ if (s->sample_rates[i] == 48000u) return 1;
+ return 0;
+}
+
+/* Lexicographic preference key: lower is better. */
+static int better(const ck_uac_stream *a, const ck_uac_stream *b)
+{
+ int ac = a->channels != 2, bc = b->channels != 2;
+ if (ac != bc) return ac < bc;
+ int ab = a->bit_resolution != 16, bb = b->bit_resolution != 16;
+ if (ab != bb) return ab < bb;
+ return a->max_packet < b->max_packet;
+}
+
+int ck_uac_select_output(const uint8_t *b, size_t len, ck_uac_stream *out)
+{
+ if (!b || !out || len < 9 || b[0] < 9 || b[1] != D_CONFIG) return -1;
+ size_t total = (size_t)b[2] | ((size_t)b[3] << 8);
+ if (total > len) total = len;
+
+ uint8_t version = CK_UAC_NONE;
+ int have_control = 0, have_iface = 0, have_fmt = 0;
+ uint8_t control = 0, if_num = 0, if_alt = 0, if_as = 0;
+ uint8_t f_ch = 0, f_sub = 0, f_bits = 0, f_count = 0;
+ uint32_t f_rates[CK_UAC_MAX_RATES] = {0};
+ uint16_t clock = CK_UAC_NO_CLOCK;
+ ck_uac_stream best;
+ int have_best = 0;
+ unsigned n = 0;
+
+ size_t at = 0;
+ while (at + 2 <= total) {
+ size_t l = b[at];
+ if (l < 2 || at + l > total) return -1;
+ const uint8_t *d = b + at;
+ if (d[1] == D_INTERFACE && l >= 9) {
+ have_iface = 1;
+ if_num = d[2];
+ if_alt = d[3];
+ if_as = d[5] == 1 && d[6] == 2;
+ have_fmt = 0;
+ if (d[5] == 1 && d[6] == 1) {
+ have_control = 1;
+ control = d[2];
+ }
+ } else if (d[1] == D_CS_INTERFACE && l >= 3) {
+ int in_as = have_iface && if_as;
+ int in_other = have_iface && !if_as;
+ if (d[2] == 1 && in_as) {
+ /* UAC2 AS_GENERAL: bNrChannels at offset 10. UAC1 has none
+ * there (offset 4 is bDelay); its channels come from
+ * FORMAT_TYPE_I. */
+ if (version == CK_UAC2 && l >= 11) {
+ if (!have_fmt) {
+ f_sub = 0;
+ f_bits = 0;
+ f_count = 0;
+ for (unsigned i = 0; i < CK_UAC_MAX_RATES; i++) f_rates[i] = 0;
+ have_fmt = 1;
+ }
+ f_ch = d[10];
+ }
+ } else if (d[2] == 1 && l >= 8 && in_other) {
+ uint16_t bcd = (uint16_t)(d[3] | (d[4] << 8));
+ version = bcd >= 0x0200 ? CK_UAC2 : CK_UAC1;
+ if (version == CK_UAC2) clock = d[7];
+ } else if (d[2] == 2 && in_as && l >= (version == CK_UAC2 ? 6u : 8u)) {
+ /* FORMAT_TYPE_I. UAC1: bNrChannels[4] bSubframeSize[5]
+ * bBitResolution[6] bSamFreqType[7]. UAC2: bSubslotSize[4]
+ * bBitResolution[5]. */
+ uint8_t ch, sub, bits;
+ if (version == CK_UAC2) {
+ ch = have_fmt ? f_ch : 0;
+ sub = d[4];
+ bits = d[5];
+ } else {
+ ch = d[4];
+ sub = d[5];
+ bits = d[6];
+ }
+ uint32_t rates[CK_UAC_MAX_RATES] = {0};
+ uint8_t count = 0;
+ if (version == CK_UAC1) {
+ size_t nr = d[7];
+ if (nr != 0 && l >= 8 + nr * 3) {
+ count = (uint8_t)(nr < CK_UAC_MAX_RATES ? nr : CK_UAC_MAX_RATES);
+ for (unsigned i = 0; i < count; i++) rates[i] = le24(d + 8 + i * 3);
+ }
+ } else if (version == CK_UAC2) {
+ /* Rates belong to the UAC2 clock entity (not queried). */
+ rates[0] = 48000u;
+ count = 1;
+ }
+ have_fmt = 1;
+ f_ch = ch;
+ f_sub = sub;
+ f_bits = bits;
+ f_count = count;
+ for (unsigned i = 0; i < CK_UAC_MAX_RATES; i++) f_rates[i] = rates[i];
+ } else if (d[2] == 0x0a && l >= 4 && version == CK_UAC2) {
+ clock = d[3]; /* CLOCK_SOURCE bClockID */
+ }
+ } else if (d[1] == D_ENDPOINT && l >= 7) {
+ if (have_iface && if_as && have_fmt && version != CK_UAC_NONE && have_control) {
+ if (if_alt != 0 && (d[2] & 0x80u) == 0 && (d[3] & 3u) == 1u && n < CK_UAC_MAX_CANDIDATES) {
+ ck_uac_stream s;
+ s.version = version;
+ s.control_interface = control;
+ s.interface = if_num;
+ s.alternate = if_alt;
+ s.endpoint_address = d[2];
+ s.max_packet = (uint16_t)((d[4] | (d[5] << 8)) & 0x7ff);
+ s.interval = d[6];
+ s.channels = f_ch;
+ s.subframe_bytes = f_sub;
+ s.bit_resolution = f_bits;
+ s.clock_source = clock;
+ for (unsigned i = 0; i < CK_UAC_MAX_RATES; i++) s.sample_rates[i] = f_rates[i];
+ s.rate_count = f_count;
+ if (version == CK_UAC2 && f_count == 1) s.sample_rates[0] = 48000u;
+ n++;
+ if (usable(&s) && (!have_best || better(&s, &best))) {
+ best = s;
+ have_best = 1;
+ }
+ }
+ }
+ }
+ at += l;
+ }
+ if (!have_best) return -1;
+ *out = best;
+ return 0;
+}
+
+uint32_t ck_uac_interval_us(int high_speed, uint8_t interval)
+{
+ if (interval == 0) return 0;
+ if (!high_speed) return 1000u;
+ return interval <= 16 ? 125u << (interval - 1) : 0;
+}
+
+int ck_pcm_framer_init(ck_pcm_framer *f, uint32_t rate, uint8_t channels, uint8_t sample_bytes, uint32_t interval_us)
+{
+ if (!f) return -1;
+ f->rate = rate;
+ f->channels = channels;
+ f->sample_bytes = sample_bytes;
+ f->interval_us = interval_us;
+ f->remainder = 0;
+ if (!rate || !channels || !sample_bytes || !interval_us) {
+ f->rate = 0; /* unusable: every packet is 0 bytes */
+ return -1;
+ }
+ return 0;
+}
+
+size_t ck_pcm_peek_bytes(const ck_pcm_framer *f)
+{
+ uint64_t num = (uint64_t)f->rate * f->interval_us + f->remainder;
+ return (size_t)(num / 1000000u) * f->channels * f->sample_bytes;
+}
+
+size_t ck_pcm_next_bytes(ck_pcm_framer *f)
+{
+ uint64_t num = (uint64_t)f->rate * f->interval_us + f->remainder;
+ f->remainder = num % 1000000u;
+ return (size_t)(num / 1000000u) * f->channels * f->sample_bytes;
+}
+
+size_t ck_pcm_fill_i16(ck_pcm_framer *f, const int16_t *ring, size_t ring_len, size_t *cursor, int16_t *out,
+ size_t out_len)
+{
+ size_t samples = ck_pcm_next_bytes(f) / 2;
+ if (samples > out_len) samples = out_len;
+ if (!ring || ring_len == 0) {
+ for (size_t i = 0; i < samples; i++) out[i] = 0;
+ return samples;
+ }
+ for (size_t i = 0; i < samples; i++) {
+ out[i] = ring[*cursor % ring_len];
+ *cursor = (*cursor + 1) % ring_len;
+ }
+ return samples;
+}
+
+static ck_uac_trb isoch_trb(uint64_t buf, uint32_t length, uint16_t frame_id, int ioc)
+{
+ ck_uac_trb t;
+ t.d[0] = (uint32_t)buf;
+ t.d[1] = (uint32_t)(buf >> 32);
+ t.d[2] = length & 0x1ffffu;
+ /* One packet per TD (no CHAIN), TBC (bits 8:7) zero, SIA clear. */
+ t.d[3] = ((uint32_t)(frame_id & 0x7ffu) << 20) | (CK_UAC_TRB_ISOCH << 10) | (ioc ? CK_UAC_TRB_IOC : 0u);
+ return t;
+}
+
+size_t ck_uac_schedule(ck_pcm_framer *f, uint16_t controller_frame, uint16_t lead_frames, const ck_uac_packet *packets,
+ size_t npackets, const int16_t *ring, size_t ring_len, size_t *cursor, int16_t *pcm,
+ size_t pcm_len, size_t stride, ck_uac_trb *trbs, size_t ntrbs)
+{
+ if (!f || !packets || !cursor || !pcm || !trbs || stride == 0) return 0;
+ size_t slots = npackets < ntrbs ? npackets : ntrbs;
+ if (pcm_len / stride < slots) slots = pcm_len / stride;
+ size_t count = 0;
+ while (count < slots) {
+ /* Check before consuming PCM: never truncate a packet. */
+ size_t need = ck_pcm_peek_bytes(f);
+ if (need > packets[count].capacity || need > stride * 2) break;
+ size_t samples = ck_pcm_fill_i16(f, ring, ring_len, cursor, pcm + count * stride, stride);
+ uint16_t frame = (uint16_t)((controller_frame + lead_frames + count) & 0x7ffu);
+ trbs[count] = isoch_trb(packets[count].dma, (uint32_t)(samples * 2), frame, 0);
+ count++;
+ }
+ if (count > 0) trbs[count - 1].d[3] |= CK_UAC_TRB_IOC;
+ return count;
+}
+
+int ck_test_tone_init(ck_test_tone *t, uint32_t frequency_hz, uint32_t sample_rate)
+{
+ if (!t || sample_rate == 0 || frequency_hz >= sample_rate / 2) return -1;
+ t->phase = 0;
+ t->step = (uint32_t)(((uint64_t)frequency_hz << 32) / sample_rate);
+ return 0;
+}
+
+int16_t ck_test_tone_next(ck_test_tone *t)
+{
+ t->phase += t->step;
+ int32_t x = (int32_t)(t->phase >> 16);
+ int32_t tri = x < 32768 ? x : 65535 - x;
+ int64_t y = (4 * (int64_t)tri * (int64_t)(32767 - tri) * 2) / 32767 - 32767;
+ if (y > 32767) y = 32767;
+ if (y < -32767) y = -32767;
+ return (int16_t)y;
+}
diff --git a/native/kernel/dev/usb_audio.h b/native/kernel/dev/usb_audio.h
new file mode 100644
index 00000000 ..c241ee21
--- /dev/null
+++ b/native/kernel/dev/usb_audio.h
@@ -0,0 +1,112 @@
+/* usb_audio.h -- audio.output (issue #85, ADR 0012 rule 15), C kernel slice 1:
+ * the pure logic of USB Audio Class output. No MMIO, no DMA, no controller
+ * access; host tested in dev/tests/usb_audio_test.c (make usb-audio-test).
+ *
+ * Port of the Rust reference crates/aienos-kernel/src/usb/audio.rs (#96,
+ * #102), which the C kernel (ADR 0024) does not link:
+ * - ck_uac_select_output: walk one configuration descriptor (UAC1 or UAC2)
+ * and pick the best isochronous OUT stream for 48 kHz 16-bit stereo;
+ * - ck_uac_interval_us: endpoint service interval from bInterval;
+ * - ck_pcm_framer: bytes per service interval with the fractional frame
+ * carried, so 44.1 kHz at 1 ms totals exactly 44100 frames per second;
+ * - ck_uac_schedule: one isochronous TD (one Isoch TRB) per packet, Frame
+ * IDs wrapping at the 11-bit field, IOC on the last scheduled packet only;
+ * - ck_test_tone: deterministic integer sine-like tone (no floating point).
+ *
+ * Behaviour matches the Rust reference, including its known limit: UAC2
+ * sample rates belong to the clock entity and are not queried here, so a UAC2
+ * stream is taken to offer 48 kHz. Every descriptor length is bounds checked
+ * and the walk never reads past min(len, wTotalLength).
+ *
+ * Not in this slice (later #85 cuts): the xHCI isochronous endpoint inside
+ * the DMA fence, the QEMU usb-audio gate, and any speaker policy. Output
+ * only: nothing here records audio or touches a microphone.
+ * Freestanding. QEMU is not hardware: nothing here is physically qualified. */
+#ifndef AIENOS_CK_USB_AUDIO_H
+#define AIENOS_CK_USB_AUDIO_H
+#include <stddef.h>
+#include <stdint.h>
+
+enum ck_uac_version { CK_UAC_NONE = 0, CK_UAC1 = 1, CK_UAC2 = 2 };
+
+#define CK_UAC_MAX_RATES 8u
+#define CK_UAC_MAX_CANDIDATES 16u
+#define CK_UAC_NO_CLOCK 0xffffu
+
+typedef struct {
+ uint8_t version; /* enum ck_uac_version */
+ uint8_t control_interface; /* AudioControl bInterfaceNumber */
+ uint8_t interface; /* AudioStreaming bInterfaceNumber */
+ uint8_t alternate; /* bAlternateSetting carrying the endpoint */
+ uint8_t endpoint_address; /* isochronous OUT bEndpointAddress */
+ uint16_t max_packet; /* wMaxPacketSize bits 10:0 */
+ uint8_t interval; /* bInterval */
+ uint8_t channels;
+ uint8_t subframe_bytes;
+ uint8_t bit_resolution;
+ uint16_t clock_source; /* UAC2 clock entity id, or CK_UAC_NO_CLOCK */
+ uint32_t sample_rates[CK_UAC_MAX_RATES]; /* rate_count 0 = continuous */
+ uint8_t rate_count;
+} ck_uac_stream;
+
+/* 0 and *out filled, or -1: no usable stream (at least 2 channels, 2-byte
+ * subframes, 16-bit resolution, 48 kHz offered or continuous) or a malformed
+ * descriptor. Preference: exactly 2 channels, then exactly 16 bits, then the
+ * smallest max_packet; ties keep the first stream found. */
+int ck_uac_select_output(const uint8_t *cfg, size_t len, ck_uac_stream *out);
+
+/* Service interval in microseconds: full speed 1000, high speed
+ * 125 << (bInterval - 1) for bInterval 1..16. 0 when bInterval is 0 or out
+ * of range. */
+uint32_t ck_uac_interval_us(int high_speed, uint8_t interval);
+
+typedef struct {
+ uint32_t rate;
+ uint8_t channels;
+ uint8_t sample_bytes;
+ uint32_t interval_us;
+ uint64_t remainder;
+} ck_pcm_framer;
+/* 0, or -1 when any argument is zero (the framer is then unusable). */
+int ck_pcm_framer_init(ck_pcm_framer *f, uint32_t rate, uint8_t channels, uint8_t sample_bytes, uint32_t interval_us);
+/* Bytes of the next packet, advancing the fractional carry. */
+size_t ck_pcm_next_bytes(ck_pcm_framer *f);
+/* Bytes the next packet will need, without advancing. */
+size_t ck_pcm_peek_bytes(const ck_pcm_framer *f);
+/* Advance one packet and copy its samples (at most out_len) from the
+ * interleaved ring, wrapping *cursor. An empty ring writes silence. Returns
+ * the samples written. */
+size_t ck_pcm_fill_i16(ck_pcm_framer *f, const int16_t *ring, size_t ring_len, size_t *cursor, int16_t *out,
+ size_t out_len);
+
+/* One isochronous packet buffer: DMA address and capacity in bytes. */
+typedef struct {
+ uint64_t dma;
+ uint16_t capacity;
+} ck_uac_packet;
+/* Isoch TRB dwords (xHCI 1.2 section 6.4.1.3); the cycle bit is left 0 for
+ * the ring writer to set. */
+typedef struct {
+ uint32_t d[4];
+} ck_uac_trb;
+#define CK_UAC_TRB_ISOCH 5u
+#define CK_UAC_TRB_IOC (1u << 5)
+#define CK_UAC_TRB_SIA (1u << 31)
+/* Prepare up to min(npackets, ntrbs, pcm_len / stride) packets, Frame ID
+ * (controller_frame + lead_frames + i) & 0x7ff. Stops, without consuming any
+ * PCM, at the first packet that would not fit its buffer capacity or its
+ * stride-sample PCM chunk (never truncates). stride 0 schedules nothing.
+ * Returns the number of TRBs written; the last one carries IOC. */
+size_t ck_uac_schedule(ck_pcm_framer *f, uint16_t controller_frame, uint16_t lead_frames, const ck_uac_packet *packets,
+ size_t npackets, const int16_t *ring, size_t ring_len, size_t *cursor, int16_t *pcm,
+ size_t pcm_len, size_t stride, ck_uac_trb *trbs, size_t ntrbs);
+
+typedef struct {
+ uint32_t phase;
+ uint32_t step;
+} ck_test_tone;
+/* 0, or -1 when sample_rate is 0 or frequency_hz is not below Nyquist. */
+int ck_test_tone_init(ck_test_tone *t, uint32_t frequency_hz, uint32_t sample_rate);
+/* Next sample, always within [-32767, 32767]. */
+int16_t ck_test_tone_next(ck_test_tone *t);
+#endif
diff --git a/native/kernel/include/.crumb b/native/kernel/include/.crumb
index 5552b219 ..bbf838ce 100644
--- a/native/kernel/include/.crumb
+++ b/native/kernel/include/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-13T21:27:22Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:8198bb9a0fbd634281a251b012eca8874c97e469a45eec8b5a6bf06a7e828f9a ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 1,
- "generated_at_commit": "03de8681ae58720bd01a45ccb5311c792f1d517b ",
- "source_tree": "sha256:0a4c28ea11fe90d281fb0e4bf8a3239b9689e2b33fafcbc83fe23e3e89d7c168 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/mm/.crumb b/native/kernel/mm/.crumb
index 4b7603a9 ..b61db69d 100644
--- a/native/kernel/mm/.crumb
+++ b/native/kernel/mm/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-08T19:22:53Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:8252fab960e4a3bb686f2e864b0d9a0571f43381d5006de2ff6c134c132ef092 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 7,
- "generated_at_commit": "6c9c2799bd7e4a2a3f9b4185ae55c15942ed5fdb ",
- "source_tree": "sha256:e3954d4a28bd18509793abc2e76ab42f73855e9d4c4421a5fddb3c5293eb3683 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/stage.mk b/native/kernel/stage.mk
index f589a4ec ..3a8f108e 100644
--- a/native/kernel/stage.mk
+++ b/native/kernel/stage.mk
@@ -45,7 +45,11 @@ STAGE_SRCS := $(STAGE_OWN_SRCS) $(STAGE_NATIVE_SRCS) $(STAGE_KERNEL_SRCS)
# omega.lock) over the sealed Store. Linked into the CK_SERVICE image by the
# kernel Makefile; compiled freestanding here so stage-free proves the link.
STAGE_CORTEX_SRCS := $(STAGE_DIR)/svc/cortex_store.c $(STAGE_DIR)/svc/cortex_journal.c
-STAGE_FREE_SRCS := $(STAGE_SRCS) $(STAGE_CORTEX_SRCS)
+# audio.output slice 1 (issue #85): USB Audio Class output pure logic. Not
+# linked into any image yet (no xHCI isochronous endpoint); compiled
+# freestanding here and host tested by usb-audio-test.
+STAGE_AUDIO_SRCS := $(STAGE_DIR)/dev/usb_audio.c
+STAGE_FREE_SRCS := $(STAGE_SRCS) $(STAGE_CORTEX_SRCS) $(STAGE_AUDIO_SRCS)
STAGE_INC := -I$(STAGE_DIR)/include -I$(STAGE_DIR)/dev -I$(STAGE_DIR)/svc \
-I$(STAGE_NATIVE)/disk -I$(STAGE_NATIVE)/store -I$(STAGE_NATIVE)/m5 -I$(STAGE_NATIVE)/crypto \
@@ -159,6 +163,25 @@ disk-part-sanitize: $(STAGE_OUT)/disk_part_test_san
stage-test: disk-part-test
stage-sanitize: disk-part-sanitize
+# ---- audio.output pure logic host test (dev/tests/usb_audio_test.c, issue #85) ----
+USB_AUDIO_TEST_SRCS := $(STAGE_AUDIO_SRCS) $(STAGE_DIR)/dev/tests/usb_audio_test.c
+USB_AUDIO_TEST_DEPS := $(USB_AUDIO_TEST_SRCS) $(STAGE_DIR)/dev/usb_audio.h
+$(STAGE_OUT)/usb_audio_test: $(USB_AUDIO_TEST_DEPS)
+ @mkdir -p $(@D)
+ $(STAGE_CC) $(STAGE_HOST_FLAGS) -I$(STAGE_DIR)/dev -o $@ $(USB_AUDIO_TEST_SRCS)
+$(STAGE_OUT)/usb_audio_test_san: $(USB_AUDIO_TEST_DEPS)
+ @mkdir -p $(@D)
+ $(STAGE_CC) $(STAGE_HOST_FLAGS) $(STAGE_SAN_FLAGS) -I$(STAGE_DIR)/dev -o $@ $(USB_AUDIO_TEST_SRCS)
+
+.PHONY: usb-audio-test usb-audio-sanitize
+usb-audio-test: $(STAGE_OUT)/usb_audio_test
+ $<
+usb-audio-sanitize: $(STAGE_OUT)/usb_audio_test_san
+ ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 $<
+
+stage-test: usb-audio-test
+stage-sanitize: usb-audio-sanitize
+
# ---- AIENOS-PI5 step 3b: sealed Store over the Pi card layout (dev/tests/pi5_store_test.c) ----
# Same sources as disk_part_test; the image build of this stage is "make pi5-store".
PI5_STORE_TEST_SRCS := $(filter-out %/disk_part_test.c,$(DISK_PART_TEST_SRCS)) $(STAGE_DIR)/core/pi5_marker.c $(STAGE_DIR)/dev/tests/pi5_store_test.c
diff --git a/native/kernel/svc/.crumb b/native/kernel/svc/.crumb
index dd0aab6a ..5df1843c 100644
--- a/native/kernel/svc/.crumb
+++ b/native/kernel/svc/.crumb
@@ -14,31 +14,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "17d9c9eba5fe222af0e8700ac3baa3461eb217a372f16a5e79e00a19cc5df6f5 ",
- "last_commit": "31ed9f8 ",
- "name": "compat",
- "purpose": "Directory native/kernel/svc/compat. Purpose not yet described by a human."
- },
- {
- "digest": "44ea8525d341bcebcb307fb1743de084b124745bd7c46d85761e554183ee02cc ",
- "last_commit": "22eb360 ",
- "name": "tests",
- "purpose": "Directory native/kernel/svc/tests. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:d835471b1405ca482a41beb34ed339d21e11064a59138599ee5754d198926878 ",
- "compiled_at": "2026-10-13T23:07:22Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:2a98333d826d94a7131119aaeb5a15d8bc543baa5531fa930e6f0afc1fccb83d ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 48,
- "generated_at_commit": "53de55c5dd3485948cd34734caf0f646e28a68c4 ",
- "source_tree": "sha256:8ea0c11b9dedede3565f8e3d47b8192651e0790f8e3df92b172ce4a8dc936af1 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/svc/compat/.crumb b/native/kernel/svc/compat/.crumb
index dd79a25d ..d12358d7 100644
--- a/native/kernel/svc/compat/.crumb
+++ b/native/kernel/svc/compat/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:17d9c9eba5fe222af0e8700ac3baa3461eb217a372f16a5e79e00a19cc5df6f5 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 6,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:280325388d9286e9e0406ec34db18ff1f3c77447cdad0c5b3050d46f8639382c "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/svc/tests/.crumb b/native/kernel/svc/tests/.crumb
index e18924b2 ..01d0ef94 100644
--- a/native/kernel/svc/tests/.crumb
+++ b/native/kernel/svc/tests/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-12T10:28:17Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:44ea8525d341bcebcb307fb1743de084b124745bd7c46d85761e554183ee02cc ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 3,
- "generated_at_commit": "56d125f12abf2b8ba2886d6da4d86fda8dd244b3 ",
- "source_tree": "sha256:0dd845f9e709078f6366a7917056263c5148eb84f38aa92c70490f0246099f57 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/tests/.crumb b/native/kernel/tests/.crumb
index fbe93953 ..30b3e9a5 100644
--- a/native/kernel/tests/.crumb
+++ b/native/kernel/tests/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-17T01:49:45Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:0f3d28a645346382567a7a279a3e02a095c8e7f298967db175944c0a58ca9c5d ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 189,
- "generated_at_commit": "30379678add587e388db4e11713d6bca8d159b08 ",
- "source_tree": "sha256:78682dfae8385bcec29c757bca316fadddcefbfc3c85a3f021a1aa8b948c623a "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/tests/fixtures/osh/.crumb b/native/kernel/tests/fixtures/osh/.crumb
index 52f4c61a ..b76ff1a3 100644
--- a/native/kernel/tests/fixtures/osh/.crumb
+++ b/native/kernel/tests/fixtures/osh/.crumb
@@ -1,18 +1,4 @@
{
- "extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-08T14:02:25Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:60edbebffefe31a8e0bafc12c9fd5cb402a7bb8b7af4407e35a952bca394480a ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 49,
- "generated_at_commit": "3b26ea92c67fbee8db58539e03b55ccb9b35bc53 ",
- "source_tree": "sha256:2cbfd4c6e6ea7f1233640027a2a98a7d8140b93cc260f48bf38e511389a0e276 "
- }
- },
"name": "osh",
"purpose": "OSH-AIENOS-0 fixtures: compiled shell-core units, Linux step traces and scripts, pinned omega layout, provenance (QEMU, TEST signer, not physical)",
"schema_version": "1.0.0"
diff --git a/native/kernel/tests/fixtures/pipe/README.md b/native/kernel/tests/fixtures/pipe/README.md
new file mode 100644
index 00000000 ..447ea5dc
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/README.md
@@ -0,0 +1,34 @@
+# Pipe primitive vectors (aienos-mv#428)
+
+Machine-checkable cases for the native pipe primitive (`native/kernel/core/pipe.c`), one file per case, read by
+`native/kernel/tests/test_pipe.c`. Contract: OSH_PLATFORM_ABI v1 DRAFT (aien-protocols-mv `specs/osh-platform/`,
+read at `fb5fca98e667 `), sections 4.4, 8.1, 8.5, 8.6 and 9. Authored from that text and this kernel's choices; the
+choices the draft leaves open are marked UNVERIFIED in `core/pipe.h`. Plain text so the corpus can later move to
+`specs/osh-platform/vectors/` next to the shell-core vectors (same quoted-byte escapes as their `expected.txt`).
+
+## File `pNNN_<name>.vec`
+
+- `case <name>` and `kind positive|negative` are required.
+- `#` starts a comment. Tokens are separated by spaces.
+- `<q>` is a double-quoted byte string: `\xHH` any byte, `\"` and `\\` themselves. NUL and bytes >= 0x80 are allowed.
+- Two capability tables exist, `A` and `B` (two principals), both empty at the start; the pool has 4 pipes of 65536 bytes.
+- Every step line is `<command> => <ERROR> [n=<N>] [data=<q>]`. `<ERROR>` is a section 8.6 name (`OK`, `DENIED`,
+ `REVOKED`, `STALE`, `INVALID_ARG`, `LIMIT`, `INTERRUPTED`, `BROKEN_PIPE`, `NOT_SUPPORTED`, `WOULD_BLOCK`, ...).
+ `n=` is the byte count moved (or, for `release`, the capabilities closed); `data=` the exact bytes read.
+
+| command | meaning |
+|---|---|
+| `create <R> <W> <T>` | PIPE_CREATE in table T; names the read and write end |
+| `write <H> <q>` | non-blocking STREAM_WRITE |
+| `fill <H> <count> <hex byte>` | non-blocking STREAM_WRITE of `count` copies of one byte |
+| `read <H> <max>` | non-blocking STREAM_READ |
+| `bread <H> <max> <action>` / `bwrite <H> <q> <action>` | blocking read / write; the first time it parks, the peer runs `<action>` (`none`, or one `write`, `read`, `close`, `revoke`, `cancel` command, which must return OK); a second park gives up INTERRUPTED (a stalled peer) |
+| `close <H>` | STREAM_CLOSE |
+| `dup <H> <NEW> <T> <rights>` | STREAM_DUP into table T; rights letters `r` READ, `w` WRITE, `m` MAP, `g` GRANT, `d` DERIVE, `v` REVOKE |
+| `revoke <H>` / `cancel <H>` | revoke the pipe / interrupt that end |
+| `release <T>` | close every pipe capability in table T (section 12 cleanup) |
+| `frame <T> <slice> <cell>...` | raw platform call through the versioned op table; `<slice>` is `-` or `<q>`; cells are hex, or `$<H>` for a handle in register form; the peer table is the other one |
+| `check <item>...` | `empty` (both tables and the pool hold nothing), or `<counter>=<N>` over the pool totals: `bytes_written bytes_read writes reads max_resident would_block waits wakeups cancellations revocations broken_pipe eof refused`, and `pipes` (live pipes) |
+
+A handle name keeps its value after `close`, so a later use of it tests a stale handle. Each case must end with every
+capability released: the runner fails a case whose tables or pool are not empty at the end of the file.
diff --git a/native/kernel/tests/fixtures/pipe/p001_nul_payload.vec b/native/kernel/tests/fixtures/pipe/p001_nul_payload.vec
new file mode 100644
index 00000000 ..e084ca5b
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p001_nul_payload.vec
@@ -0,0 +1,11 @@
+case nul_payload
+kind positive
+# bytes including NUL and 0xFF pass byte for byte; last writer closed -> EOF once drained
+create R W A => OK
+write W "a\x00b\x00\xff\x00" => OK n=6
+read R 16 => OK n=6 data="a\x00b\x00\xff\x00"
+close W => OK
+read R 16 => OK n=0
+check eof=1 bytes_written=6 bytes_read=6
+close R => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p002_capacity_partial.vec b/native/kernel/tests/fixtures/pipe/p002_capacity_partial.vec
new file mode 100644
index 00000000 ..38467866
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p002_capacity_partial.vec
@@ -0,0 +1,15 @@
+case capacity_partial
+kind negative
+# a finite buffer: a write past capacity is partial, a write on a full pipe is WOULD_BLOCK, never unbounded
+create R W A => OK
+fill W 65000 41 => OK n=65000
+fill W 1000 42 => OK n=536
+write W "x" => WOULD_BLOCK
+check max_resident=65536 would_block=1
+read R 100 => OK n=100
+fill W 200 43 => OK n=100
+write W "x" => WOULD_BLOCK
+check max_resident=65536 would_block=2
+close W => OK
+close R => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p003_zero_length.vec b/native/kernel/tests/fixtures/pipe/p003_zero_length.vec
new file mode 100644
index 00000000 ..f25f11b3
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p003_zero_length.vec
@@ -0,0 +1,12 @@
+case zero_length
+kind negative
+# zero-length read and write move nothing; authority and state are still checked
+create R W A => OK
+write W "" => OK n=0
+read R 0 => OK n=0
+read R 4 => WOULD_BLOCK
+write R "" => DENIED
+close R => OK
+write W "" => BROKEN_PIPE
+close W => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p004_broken_pipe.vec b/native/kernel/tests/fixtures/pipe/p004_broken_pipe.vec
new file mode 100644
index 00000000 ..95f01b7b
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p004_broken_pipe.vec
@@ -0,0 +1,9 @@
+case broken_pipe
+kind negative
+create R W A => OK
+write W "kept" => OK n=4
+close R => OK
+write W "x" => BROKEN_PIPE
+check broken_pipe=1 bytes_written=4 bytes_read=0
+close W => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p005_eof_after_drain.vec b/native/kernel/tests/fixtures/pipe/p005_eof_after_drain.vec
new file mode 100644
index 00000000 ..ef9ff074
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p005_eof_after_drain.vec
@@ -0,0 +1,12 @@
+case eof_after_drain
+kind positive
+create R W A => OK
+write W "abc" => OK n=3
+close W => OK
+read R 2 => OK n=2 data="ab"
+read R 2 => OK n=1 data="c"
+read R 2 => OK n=0
+read R 2 => OK n=0
+check eof=2
+close R => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p006_rights.vec b/native/kernel/tests/fixtures/pipe/p006_rights.vec
new file mode 100644
index 00000000 ..f3f92cc5
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p006_rights.vec
@@ -0,0 +1,23 @@
+case rights
+kind negative
+# a read end cannot write and a write end cannot read; dup attenuates and never widens
+create R W A => OK
+write R "x" => DENIED
+read W 1 => DENIED
+dup R X A w => INVALID_ARG
+dup R X A rm => INVALID_ARG
+dup R RB B r => OK
+dup RB RC B r => DENIED
+dup RB RC A r => DENIED
+revoke RB => DENIED
+cancel W => OK
+dup W WB B wg => OK
+dup WB WC B wd => DENIED
+write WB "q" => INTERRUPTED
+write WB "q" => OK n=1
+read RB 4 => OK n=1 data="q"
+close RB => OK
+close WB => OK
+close R => OK
+close W => OK
+check empty refused=6
diff --git a/native/kernel/tests/fixtures/pipe/p007_handle_reuse.vec b/native/kernel/tests/fixtures/pipe/p007_handle_reuse.vec
new file mode 100644
index 00000000 ..02e46de7
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p007_handle_reuse.vec
@@ -0,0 +1,17 @@
+case handle_reuse
+kind negative
+# a closed handle is stale even after its slot is reused by a new pipe (generation check)
+create R W A => OK
+close R => OK
+close W => OK
+create R2 W2 A => OK
+read R 1 => STALE
+write W "x" => STALE
+close R => STALE
+cancel W => STALE
+revoke W => STALE
+write W2 "ok" => OK n=2
+read R2 8 => OK n=2 data="ok"
+close R2 => OK
+close W2 => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p008_revoke_blocked_read.vec b/native/kernel/tests/fixtures/pipe/p008_revoke_blocked_read.vec
new file mode 100644
index 00000000 ..9021f8fa
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p008_revoke_blocked_read.vec
@@ -0,0 +1,13 @@
+case revoke_blocked_read
+kind negative
+# a reader parked on an empty pipe wakes on revoke and gets REVOKED; nothing flows afterwards
+create R W A => OK
+bread R 4 revoke W => REVOKED
+check revocations=1 waits=1 wakeups=1
+write W "x" => REVOKED
+read R 1 => REVOKED
+dup R X A r => REVOKED
+cancel R => REVOKED
+close R => OK
+close W => OK
+check empty bytes_read=0
diff --git a/native/kernel/tests/fixtures/pipe/p009_revoke_blocked_write.vec b/native/kernel/tests/fixtures/pipe/p009_revoke_blocked_write.vec
new file mode 100644
index 00000000 ..6c580b01
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p009_revoke_blocked_write.vec
@@ -0,0 +1,11 @@
+case revoke_blocked_write
+kind negative
+# a writer parked on a full pipe wakes on revoke; the 64 KiB already buffered is scrubbed, never delivered
+create R W A => OK
+fill W 65536 61 => OK n=65536
+bwrite W "z" revoke R => REVOKED
+check revocations=1 waits=1 wakeups=1 bytes_written=65536
+read R 1 => REVOKED
+close W => OK
+close R => OK
+check empty bytes_read=0
diff --git a/native/kernel/tests/fixtures/pipe/p010_close_reader_race.vec b/native/kernel/tests/fixtures/pipe/p010_close_reader_race.vec
new file mode 100644
index 00000000 ..04e8c68d
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p010_close_reader_race.vec
@@ -0,0 +1,9 @@
+case close_reader_race
+kind negative
+# a writer parked at capacity when the last reader closes wakes to BROKEN_PIPE
+create R W A => OK
+fill W 65536 62 => OK n=65536
+bwrite W "z" close R => BROKEN_PIPE
+check broken_pipe=1 waits=1 wakeups=1
+close W => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p011_close_writer_race.vec b/native/kernel/tests/fixtures/pipe/p011_close_writer_race.vec
new file mode 100644
index 00000000 ..0911f4f6
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p011_close_writer_race.vec
@@ -0,0 +1,8 @@
+case close_writer_race
+kind positive
+# a reader parked on an empty pipe when the last writer closes wakes to EOF (0 bytes, OK)
+create R W A => OK
+bread R 4 close W => OK n=0
+check eof=1 waits=1 wakeups=1
+close R => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p012_both_closed.vec b/native/kernel/tests/fixtures/pipe/p012_both_closed.vec
new file mode 100644
index 00000000 ..775de480
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p012_both_closed.vec
@@ -0,0 +1,11 @@
+case both_closed
+kind negative
+create R W A => OK
+write W "lost" => OK n=4
+close W => OK
+close R => OK
+check empty
+close R => STALE
+close W => STALE
+read R 1 => STALE
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p013_cancel_blocked_read.vec b/native/kernel/tests/fixtures/pipe/p013_cancel_blocked_read.vec
new file mode 100644
index 00000000 ..f6e08cc3
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p013_cancel_blocked_read.vec
@@ -0,0 +1,12 @@
+case cancel_blocked_read
+kind negative
+# cancel interrupts a parked reader once, no byte moved; the next call runs normally
+create R W A => OK
+bread R 4 cancel R => INTERRUPTED
+check cancellations=1 waits=1 wakeups=1
+read R 4 => WOULD_BLOCK
+write W "ok" => OK n=2
+read R 4 => OK n=2 data="ok"
+close W => OK
+close R => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p014_cancel_pending_write.vec b/native/kernel/tests/fixtures/pipe/p014_cancel_pending_write.vec
new file mode 100644
index 00000000 ..533904e3
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p014_cancel_pending_write.vec
@@ -0,0 +1,15 @@
+case cancel_pending_write
+kind negative
+# a cancel with no waiter interrupts the next call on that end only
+create R W A => OK
+cancel W => OK
+read R 1 => WOULD_BLOCK
+write W "x" => INTERRUPTED
+write W "x" => OK n=1
+cancel R => OK
+read R 1 => INTERRUPTED
+read R 1 => OK n=1 data="x"
+check cancellations=2 bytes_read=1
+close R => OK
+close W => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p015_stalled_consumer.vec b/native/kernel/tests/fixtures/pipe/p015_stalled_consumer.vec
new file mode 100644
index 00000000 ..7cb7417d
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p015_stalled_consumer.vec
@@ -0,0 +1,11 @@
+case stalled_consumer
+kind negative
+# a writer parked behind a consumer that never reads gives up INTERRUPTED at the wait bound, no byte moved
+create R W A => OK
+fill W 65536 63 => OK n=65536
+bwrite W "z" none => INTERRUPTED
+check waits=2 would_block=2 cancellations=1 bytes_written=65536
+read R 3 => OK n=3 data="ccc"
+close R => OK
+close W => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p016_blocked_read_progress.vec b/native/kernel/tests/fixtures/pipe/p016_blocked_read_progress.vec
new file mode 100644
index 00000000 ..bef5c901
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p016_blocked_read_progress.vec
@@ -0,0 +1,11 @@
+case blocked_read_progress
+kind positive
+# a parked reader wakes when bytes arrive and returns them (partial: what is there)
+create R W B => OK
+bread R 8 write W "hi\x00" => OK n=3 data="hi\x00"
+check waits=1 wakeups=1
+bwrite W "yo" none => OK n=2
+read R 8 => OK n=2 data="yo"
+close R => OK
+close W => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p017_malformed_frames.vec b/native/kernel/tests/fixtures/pipe/p017_malformed_frames.vec
new file mode 100644
index 00000000 ..6de5e746
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p017_malformed_frames.vec
@@ -0,0 +1,27 @@
+case malformed_frames
+kind negative
+# platform call frames: every malformed header is refused before any effect
+frame A - 4F534846 1 => INVALID_ARG
+frame A - 12345678 1 1 0 => INVALID_ARG
+frame A - 4F534846 2 1 0 => NOT_SUPPORTED
+frame A - 4F534846 0 1 0 => NOT_SUPPORTED
+frame A - 4F534846 1 1 1 => INVALID_ARG
+frame A - 4F534846 1 0 0 => NOT_SUPPORTED
+frame A - 4F534846 1 6 0 => NOT_SUPPORTED
+frame A - 4F534846 1 FFFFFFFF00000001 0 => NOT_SUPPORTED
+frame A - 4F534846 1 1 0 0 => INVALID_ARG
+frame A - 4F534846 1 4 0 0 => INVALID_ARG
+check empty
+create R W A => OK
+frame A - 4F534846 1 3 0 $W => INVALID_ARG
+frame A "abc" 4F534846 1 3 0 $W 2 => INVALID_ARG
+frame A "abc" 4F534846 1 3 0 $W 0 => OK n=3
+frame A - 4F534846 1 5 0 $R 1 2 => INVALID_ARG
+frame A - 4F534846 1 5 0 $R 1 1 => OK
+frame A - 4F534846 1 7 0 $R => NOT_SUPPORTED
+check bytes_written=3 bytes_read=0
+release B => OK n=1
+frame A - 4F534846 1 4 0 $R => OK
+frame A - 4F534846 1 4 0 $R => STALE
+close W => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p018_limits.vec b/native/kernel/tests/fixtures/pipe/p018_limits.vec
new file mode 100644
index 00000000 ..8f328f1d
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p018_limits.vec
@@ -0,0 +1,19 @@
+case limits
+kind negative
+# a full pool or a full capability table returns LIMIT and leaves nothing allocated
+create R1 W1 A => OK
+create R2 W2 A => OK
+create R3 W3 A => OK
+create R4 W4 A => OK
+create X Y B => LIMIT
+check pipes=4
+close R1 => OK
+close W1 => OK
+check pipes=3
+dup R2 D1 A r => OK
+dup R2 D2 A r => OK
+create X Y A => LIMIT
+dup R2 D3 A r => LIMIT
+check pipes=3
+release A => OK n=8
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p019_dup_refs.vec b/native/kernel/tests/fixtures/pipe/p019_dup_refs.vec
new file mode 100644
index 00000000 ..fda38b90
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p019_dup_refs.vec
@@ -0,0 +1,13 @@
+case dup_refs
+kind positive
+# every dup is a reference: EOF only after the last write end closes
+create R W A => OK
+dup W W2 A w => OK
+close W => OK
+write W2 "x" => OK n=1
+read R 4 => OK n=1 data="x"
+read R 4 => WOULD_BLOCK
+close W2 => OK
+read R 4 => OK n=0
+close R => OK
+check empty
diff --git a/native/kernel/tests/fixtures/pipe/p020_transfer.vec b/native/kernel/tests/fixtures/pipe/p020_transfer.vec
new file mode 100644
index 00000000 ..796f2a13
--- /dev/null
+++ b/native/kernel/tests/fixtures/pipe/p020_transfer.vec
@@ -0,0 +1,13 @@
+case transfer
+kind positive
+# an end handed to another principal's table (GRANT) works there; the giver closes its copy
+create R W A => OK
+dup R RB B rv => OK
+close R => OK
+write W "\x00\x01\x02" => OK n=3
+read RB 3 => OK n=3 data="\x00\x01\x02"
+revoke RB => OK
+write W "x" => REVOKED
+close RB => OK
+close W => OK
+check empty revocations=1
diff --git a/native/kernel/tests/test_imac_report.c b/native/kernel/tests/test_imac_report.c
index 27cc6473 ..7eb31e14 100644
--- a/native/kernel/tests/test_imac_report.c
+++ b/native/kernel/tests/test_imac_report.c
@@ -1,12 +1,16 @@
-/* test_imac_report.c -- host test for the iMac kernel's network report
- * frames (x86/report_x86.c, built with -DCK_X86_REPORT_HOST).
+/* test_imac_report.c -- host test for the iMac kernel's lab-only network
+ * report (x86/report_x86.c, built with -DCK_X86_REPORT_HOST): the allowlist
+ * filter and the frames.
*
- * test_imac_report unit checks on the frames
+ * test_imac_report unit checks on the filter and frames
* test_imac_report send PORT LOGFILE also writes a sample report to
* LOGFILE and sends every part's UDP payload to 127.0.0.1:PORT (last
* part first, then all again), so scripts/ck_imac_report_test.sh can
- * check that ck_imac_report_listen rebuilds LOGFILE byte for byte. */
+ * check that ck_imac_report_listen rebuilds LOGFILE byte for byte.
+ * test_imac_report legacy PORT sends one datagram in the retired
+ * v=1 raw-console format, which the listener must refuse. */
#define _POSIX_C_SOURCE 200809L
+#define _GNU_SOURCE /* memmem */
#include <arpa/inet.h>
#include <fcntl.h>
#include <netinet/in.h>
@@ -21,8 +25,112 @@
#include "report_x86.h"
static const uint8_t mac[6] = {0x02, 0x00, 0x00, 0x00, 0x00, 0x01};
-static char log_text[3 * CK_X86_REPORT_CHUNK + 300];
+/* 56 lines of 61 bytes, each an allowlisted "pci: " line: 4 parts. */
+static char log_text[56 * 61];
+/* A console log mixing allowlisted lines with lines that must never leave
+ * the machine: keys off the allowlist (chat, keys, tokens, the memory
+ * layout), near-miss keys, control and non-ASCII bytes inside an allowed
+ * key, an over-long line, and an unterminated tail. */
+static const char allowed_part[] =
+ "AIENOS-IMAC-KERNEL-0\n"
+ "aienos_commit: 0123abcd \n"
+ "pci: ahci 00:1f.2 id=8086:2922 class=0106\n"
+ "net_tg3: link up 1000 Mb/s full duplex\n"
+ "summary: cores=4/4 timer=ok sata_disks=1 nvme_disks=1 gpt_valid=1 writes=none net=up\n"
+ "kernel: alive\n"
+ "panic: exception: vector 14 #PF error=0x2\n"
+ "AIENOS-IMAC-KERNEL-0 DONE\n";
+
+static size_t build_mixed(char *out, size_t cap)
+{
+ static const char *const lines[] = {
+ "AIENOS-IMAC-KERNEL-0\n",
+ "allen: secret-chat-SENTINEL\n",
+ "aienos_commit: 0123abcd \n",
+ "key: SENTINEL-KEY\n",
+ "memory: frame_ranges=3 free_bytes=1 heap=0x1000+64 SENTINEL-MEM\n",
+ "pci: ahci 00:1f.2 id=8086:2922 class=0106\n",
+ "token: SENTINEL-TOKEN\n",
+ "credential: SENTINEL-CRED\n",
+ "chat: user said SENTINEL-CHAT\n",
+ "nett: SENTINEL-NEAR\n",
+ "net SENTINEL-NOCOLON\n",
+ " pci: SENTINEL-LEADING-SPACE\n",
+ "PCI: SENTINEL-CASE\n",
+ "net: ok \x1b[2J SENTINEL-ESC\n",
+ "summary: \tSENTINEL-TAB\n",
+ "report: caf\xc3\xa9 SENTINEL-UTF8\n",
+ "power: \r SENTINEL-CR\n",
+ "net_tg3: link up 1000 Mb/s full duplex\n",
+ "summary: cores=4/4 timer=ok sata_disks=1 nvme_disks=1 gpt_valid=1 writes=none net=up\n",
+ "\n",
+ "kernel: alive\n",
+ "panic: exception: vector 14 #PF error=0x2\n",
+ "AIENOS-IMAC-KERNEL-0 DONE\n",
+ };
+ size_t w = 0;
+ for (size_t i = 0; i < sizeof lines / sizeof lines[0]; i++) {
+ size_t n = strlen(lines[i]);
+ if (w + n > cap)
+ return 0;
+ memcpy(out + w, lines[i], n);
+ w += n;
+ if (i == 3) { /* an over-long but otherwise allowed line */
+ const char *p = "stack: ";
+ memcpy(out + w, p, 7);
+ w += 7;
+ for (unsigned k = 0; k < CK_X86_REPORT_LINE_MAX; k++)
+ out[w++] = 'x';
+ memcpy(out + w, "SENTINEL-LONG\n", 14);
+ w += 14;
+ }
+ }
+ static const char tail[] = "screen: SENTINEL-TAIL"; /* no newline */
+ memcpy(out + w, tail, sizeof tail - 1);
+ return w + sizeof tail - 1;
+}
+
+static void filter_checks(void)
+{
+ static char raw[4096], out[4096];
+ size_t rl = build_mixed(raw, sizeof raw);
+ CHECK(rl > 0);
+ CHECK(memmem(raw, rl, "SENTINEL", 8) != 0);
+ size_t n = ck_x86_report_filter(raw, rl, out, sizeof out);
+ /* The allowed lines survive byte for byte, in order; nothing else does. */
+ CHECK(n == sizeof allowed_part - 1 && memcmp(out, allowed_part, n) == 0);
+ CHECK(memmem(out, n, "SENTINEL", 8) == 0);
+ for (size_t i = 0; i < n; i++)
+ CHECK(out[i] == '\n' || (out[i] >= 0x20 && out[i] <= 0x7e));
+ /* Nor does any sentinel reach a frame built from the filtered copy. */
+ uint8_t f[1600];
+ for (unsigned p = 0; p < ck_x86_report_parts(n); p++) {
+ size_t fl = ck_x86_report_frame(mac, 1, out, n, p, f, sizeof f);
+ CHECK(fl > 0 && memmem(f, fl, "SENTINEL", 8) == 0);
+ }
+ /* A line at the length cap is kept, one byte more is dropped. */
+ char edge[2 * CK_X86_REPORT_LINE_MAX + 8], eo[sizeof edge];
+ size_t e = 0;
+ memcpy(edge, "cpu: ", 5);
+ for (e = 5; e < CK_X86_REPORT_LINE_MAX; e++)
+ edge[e] = 'a';
+ edge[e++] = '\n';
+ size_t keep = e;
+ memcpy(edge + e, "cpu: ", 5);
+ for (size_t k = 5; k <= CK_X86_REPORT_LINE_MAX; k++)
+ edge[e + k] = 'b';
+ e += CK_X86_REPORT_LINE_MAX + 1;
+ edge[e++] = '\n';
+ CHECK(ck_x86_report_filter(edge, e, eo, sizeof eo) == keep && memcmp(eo, edge, keep) == 0);
+ /* Only whole lines are written: a line that does not fit is dropped. */
+ size_t first = strlen("AIENOS-IMAC-KERNEL-0\n");
+ CHECK(ck_x86_report_filter(raw, rl, out, first + 5) == first && memcmp(out, raw, first) == 0);
+ CHECK(ck_x86_report_filter(raw, rl, out, first - 1) == 14 && memcmp(out, "kernel: alive\n", 14) == 0);
+ CHECK(ck_x86_report_filter(0, rl, out, sizeof out) == 0);
+ CHECK(ck_x86_report_filter(raw, rl, 0, sizeof out) == 0);
+ CHECK(ck_x86_report_filter(raw, 0, out, sizeof out) == 0);
+}
/* Unwraps one frame; returns the UDP payload view or 0. */
static const uint8_t *unwrap(const uint8_t *f, size_t n, size_t *plen)
{
@@ -50,7 +158,7 @@ static const uint8_t *unwrap(const uint8_t *f, size_t n, size_t *plen)
int main(int argc, char **argv)
{
for (size_t i = 0; i < sizeof log_text; i++)
- log_text[i] = (i % 61 == 60) ? '\n' : (char)('A' + i % 26);
+ log_text[i] = (i % 61 == 60) ? '\n' : i % 61 < 5 ? "pci: "[i % 61] : (char)('A' + i % 26);
size_t len = sizeof log_text;
uint64_t run = 0x0123456789abcdefull;
uint8_t f[1600];
@@ -63,6 +171,11 @@ int main(int argc, char **argv)
CHECK(ck_x86_report_parts(CK_X86_REPORT_MAX) == CK_X86_REPORT_MAX / CK_X86_REPORT_CHUNK);
CHECK(ck_x86_report_parts(CK_X86_REPORT_MAX + 1) == 0);
CHECK(parts == 4);
+ filter_checks();
+ /* The sample report is what the filter makes of itself: every line is kept. */
+ static char filtered[sizeof log_text];
+ CHECK(ck_x86_report_filter(log_text, len, filtered, sizeof filtered) == len &&
+ memcmp(filtered, log_text, len) == 0);
CHECK(ck_x86_report_frame(mac, run, log_text, len, parts, f, sizeof f) == 0);
CHECK(ck_x86_report_frame(mac, run, log_text, len, 0, f, 100) == 0);
CHECK(ck_x86_report_frame(0, run, log_text, len, 0, f, sizeof f) == 0);
@@ -78,7 +191,8 @@ int main(int argc, char **argv)
if (!d)
continue;
char want[128];
- int h = snprintf(want, sizeof want, "AIENOS-IMAC-REPORT v=1 run=0123456789abcdef part=%u/%u bytes=%zu\n", p,
+ int h = snprintf(want, sizeof want, "AIENOS-IMAC-REPORT v=2 auth=none run=0123456789abcdef part=%u/%u bytes=%zu\n",
+ p,
parts, len);
CHECK(pl > (size_t)h && memcmp(d, want, (size_t)h) == 0);
if (pl > (size_t)h && got + pl - h <= sizeof rebuilt) {
@@ -109,5 +223,16 @@ int main(int argc, char **argv)
}
close(s);
}
+ if (argc == 3 && !strcmp(argv[1], "legacy")) { /* a forged or old v=1 raw-console part */
+ static const char old[] = "AIENOS-IMAC-REPORT v=1 run=00000000000000ff part=0/1 bytes=5\nhello";
+ int s = socket(AF_INET, SOCK_DGRAM, 0);
+ struct sockaddr_in a;
+ memset(&a, 0, sizeof a);
+ a.sin_family = AF_INET;
+ a.sin_port = htons((unsigned short)atoi(argv[2]));
+ a.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ CHECK(s >= 0 && sendto(s, old, sizeof old - 1, 0, (struct sockaddr *)&a, sizeof a) == (ssize_t)(sizeof old - 1));
+ close(s);
+ }
return ck_t_verdict("test_imac_report");
}
diff --git a/native/kernel/tests/test_pipe.c b/native/kernel/tests/test_pipe.c
new file mode 100644
index 00000000 ..4a69a384
--- /dev/null
+++ b/native/kernel/tests/test_pipe.c
@@ -0,0 +1,587 @@
+/* test_pipe.c -- host tests for core/pipe.c (aienos-mv#428): the fixture corpus in tests/fixtures/pipe/ (format in its
+ * README.md), then producer / consumer transfers through the scheduler (core/pipe_drive.h), revocation mid-stream,
+ * epoch staleness and the versioned op table. Every case ends with both capability tables and the pipe pool empty. */
+#include <dirent.h>
+#include <stdlib.h>
+#include <string.h>
+#include "ck_test.h"
+#include "pipe.h"
+#include "pipe_drive.h"
+
+#ifndef PIPE_FIXTURE_DIR
+#define PIPE_FIXTURE_DIR "native/kernel/tests/fixtures/pipe"
+#endif
+
+static struct ck_pipe_pool pool;
+static struct ck_cap_table ta, tb;
+
+static int expect(int ok, const char *file, int line, const char *what)
+{
+ ck_t_run++;
+ if (!ok) {
+ ck_t_fail++;
+ printf(" FAIL %s:%d: %s\n", file, line, what);
+ }
+ return ok;
+}
+
+/* ---- fixture runner ---- */
+#define TOK_MAX 24
+#define BYTES_MAX 256
+struct tok {
+ char s[64];
+ int quoted;
+ uint8_t b[BYTES_MAX];
+ size_t n;
+};
+struct name {
+ char s[16];
+ struct ck_cap_table *t;
+ struct ck_handle h;
+};
+static struct name names[32];
+static unsigned nnames;
+static const char *cur_file;
+static int cur_line;
+
+/* the wait hook's scripted peer: first wait runs the action, every later wait gives up (a stalled peer) */
+static struct tok *act;
+static int nact, wait_calls;
+static unsigned act_err;
+
+static int hexval(int c)
+{
+ return c >= '0' && c <= '9' ? c - '0' : c >= 'a' && c <= 'f' ? c - 'a' + 10 : c >= 'A' && c <= 'F' ? c - 'A' + 10 : -1;
+}
+
+static int tokenize(const char *line, struct tok *t, int max)
+{
+ int n = 0;
+ const char *p = line;
+ while (*p) {
+ while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r')
+ p++;
+ if (!*p || *p == '#')
+ break;
+ if (n == max)
+ return -1;
+ struct tok *k = &t[n++];
+ memset(k, 0, sizeof *k);
+ if (*p == '"') {
+ k->quoted = 1;
+ p++;
+ while (*p && *p != '"') {
+ int c = (unsigned char)*p++;
+ if (c == '\\') {
+ if (*p == 'x' && hexval(p[1]) >= 0 && hexval(p[2]) >= 0) {
+ c = hexval(p[1]) * 16 + hexval(p[2]);
+ p += 3;
+ } else if (*p == '"' || *p == '\\') {
+ c = (unsigned char)*p++;
+ } else {
+ return -1;
+ }
+ }
+ if (k->n == BYTES_MAX)
+ return -1;
+ k->b[k->n++] = (uint8_t)c;
+ }
+ if (*p != '"')
+ return -1;
+ p++;
+ strcpy(k->s, "\"\"");
+ } else {
+ size_t l = 0;
+ while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != '\r' && *p != '"') {
+ if (l + 1 >= sizeof k->s)
+ return -1;
+ k->s[l++] = *p++;
+ }
+ }
+ }
+ return n;
+}
+
+static struct ck_cap_table *table_of(const char *s)
+{
+ return !strcmp(s, "A") ? &ta : !strcmp(s, "B") ? &tb : 0;
+}
+
+static struct name *find(const char *s)
+{
+ for (unsigned i = 0; i < nnames; i++)
+ if (!strcmp(names[i].s, s))
+ return &names[i];
+ return 0;
+}
+
+static void bind(const char *s, struct ck_cap_table *t, struct ck_handle h)
+{
+ struct name *n = find(s);
+ if (!n && nnames < 32)
+ n = &names[nnames++];
+ if (!n)
+ return;
+ snprintf(n->s, sizeof n->s, "%s", s);
+ n->t = t;
+ n->h = h;
+}
+
+static int parse_err(const char *s)
+{
+ for (unsigned i = 0; i < OSH_E_COUNT; i++)
+ if (!strcmp(s, osh_err_label(i)))
+ return (int)i;
+ return -1;
+}
+
+static int parse_rights(const char *s, unsigned *r)
+{
+ *r = 0;
+ for (; *s; s++) {
+ switch (*s) {
+ case 'r': *r |= CK_R_READ; break;
+ case 'w': *r |= CK_R_WRITE; break;
+ case 'm': *r |= CK_R_MAP; break;
+ case 'g': *r |= CK_R_GRANT; break;
+ case 'd': *r |= CK_R_DERIVE; break;
+ case 'v': *r |= CK_R_REVOKE; break;
+ default: return -1;
+ }
+ }
+ return 0;
+}
+
+static uint8_t big[70000], rbig[70000];
+
+/* Runs one data or control command (also used for the wait hook's action). *n and the read bytes are returned. */
+static int run_cmd(struct tok *c, int nc, unsigned *err, size_t *n, const uint8_t **data, int *handled_bind)
+{
+ *n = 0;
+ *data = 0;
+ *handled_bind = 0;
+ struct name *h = nc > 1 ? find(c[1].s) : 0;
+ if (!strcmp(c[0].s, "write") && nc == 3 && h && c[2].quoted) {
+ *err = ck_stream_write(&pool, h->t, h->h, c[2].b, c[2].n, 0, n);
+ } else if (!strcmp(c[0].s, "fill") && nc == 4 && h) {
+ size_t cnt = strtoul(c[2].s, 0, 10);
+ if (cnt > sizeof big)
+ return -1;
+ memset(big, (int)strtoul(c[3].s, 0, 16), cnt);
+ *err = ck_stream_write(&pool, h->t, h->h, big, cnt, 0, n);
+ } else if (!strcmp(c[0].s, "read") && nc == 3 && h) {
+ size_t max = strtoul(c[2].s, 0, 10);
+ if (max > sizeof rbig)
+ return -1;
+ *err = ck_stream_read(&pool, h->t, h->h, rbig, max, 0, n);
+ *data = rbig;
+ } else if (!strcmp(c[0].s, "close") && nc == 2 && h) {
+ *err = ck_stream_close(&pool, h->t, h->h);
+ } else if (!strcmp(c[0].s, "revoke") && nc == 2 && h) {
+ *err = ck_pipe_revoke(&pool, h->t, h->h);
+ } else if (!strcmp(c[0].s, "cancel") && nc == 2 && h) {
+ *err = ck_pipe_cancel(&pool, h->t, h->h);
+ } else {
+ return -1;
+ }
+ return 0;
+}
+
+static unsigned vec_wait(void *ctx, unsigned pipe, unsigned end)
+{
+ (void)ctx;
+ (void)pipe;
+ (void)end;
+ if (wait_calls++ > 0 || !act)
+ return OSH_E_INTERRUPTED;
+ if (nact == 1 && !strcmp(act[0].s, "none"))
+ return OSH_E_OK;
+ size_t n;
+ const uint8_t *d;
+ int hb;
+ if (run_cmd(act, nact, &act_err, &n, &d, &hb) != 0)
+ act_err = 0xff;
+ return OSH_E_OK;
+}
+static void vec_wake(void *ctx, unsigned pipe, unsigned end)
+{
+ (void)ctx;
+ (void)pipe;
+ (void)end;
+}
+static const struct ck_pipe_hooks vec_hooks = { 0, vec_wait, vec_wake };
+
+static uint64_t stat_of(const char *k, int *ok)
+{
+ const struct ck_pipe_stats *s = &pool.total;
+ *ok = 1;
+#define S(f) if (!strcmp(k, #f)) return s->f;
+ S(bytes_written) S(bytes_read) S(writes) S(reads) S(max_resident) S(would_block) S(waits) S(wakeups)
+ S(cancellations) S(revocations) S(broken_pipe) S(eof) S(refused)
+#undef S
+ if (!strcmp(k, "pipes"))
+ return pool.live;
+ *ok = 0;
+ return 0;
+}
+
+static int all_empty(void)
+{
+ return pd_table_empty(&ta) && pd_table_empty(&tb) && ck_pipe_pool_empty(&pool);
+}
+
+static void run_line(struct tok *t, int nt)
+{
+ char what[160];
+ if (!strcmp(t[0].s, "case") || !strcmp(t[0].s, "kind"))
+ return;
+ if (!strcmp(t[0].s, "check")) {
+ for (int i = 1; i < nt; i++) {
+ if (!strcmp(t[i].s, "empty")) {
+ expect(all_empty(), cur_file, cur_line, "check empty: tables and pool hold nothing");
+ continue;
+ }
+ char key[64];
+ snprintf(key, sizeof key, "%s", t[i].s);
+ char *eq = strchr(key, '=');
+ int ok = 0;
+ if (eq) {
+ *eq = 0;
+ uint64_t want = strtoull(eq + 1, 0, 10), got = stat_of(key, &ok);
+ snprintf(what, sizeof what, "check %s: want %llu got %llu", key, (unsigned long long)want,
+ (unsigned long long)got);
+ ok = ok && got == want;
+ } else {
+ snprintf(what, sizeof what, "check: bad item %s", t[i].s);
+ }
+ expect(ok, cur_file, cur_line, what);
+ }
+ return;
+ }
+ int arrow = -1;
+ for (int i = 0; i < nt; i++)
+ if (!t[i].quoted && !strcmp(t[i].s, "=>"))
+ arrow = i;
+ if (!expect(arrow > 0 && arrow + 1 < nt, cur_file, cur_line, "line has '<command> => <ERR>'"))
+ return;
+ int want = parse_err(t[arrow + 1].s);
+ if (!expect(want >= 0, cur_file, cur_line, "known error name"))
+ return;
+ long want_n = -1;
+ struct tok *want_data = 0;
+ for (int i = arrow + 2; i < nt; i++) {
+ if (!strncmp(t[i].s, "n=", 2))
+ want_n = strtol(t[i].s + 2, 0, 10);
+ else if (!strcmp(t[i].s, "data=") && i + 1 < nt && t[i + 1].quoted)
+ want_data = &t[++i];
+ else
+ expect(0, cur_file, cur_line, "unknown expectation item");
+ }
+ struct tok *c = t;
+ int nc = arrow;
+ unsigned err = 0xff;
+ size_t n = 0;
+ const uint8_t *data = 0;
+ struct name *h = nc > 1 ? find(c[1].s) : 0;
+ act = 0;
+ nact = 0;
+ wait_calls = 0;
+ act_err = 0;
+ if (!strcmp(c[0].s, "create") && nc == 4 && table_of(c[3].s)) {
+ struct ck_handle r, w;
+ err = ck_pipe_create(&pool, table_of(c[3].s), &r, &w);
+ if (err == OSH_E_OK) {
+ bind(c[1].s, table_of(c[3].s), r);
+ bind(c[2].s, table_of(c[3].s), w);
+ }
+ } else if (!strcmp(c[0].s, "dup") && nc == 5 && h && table_of(c[3].s)) {
+ unsigned rights;
+ struct ck_handle o;
+ if (!expect(parse_rights(c[4].s, &rights) == 0, cur_file, cur_line, "rights letters"))
+ return;
+ err = ck_stream_dup(&pool, h->t, h->h, table_of(c[3].s), rights, &o);
+ if (err == OSH_E_OK)
+ bind(c[2].s, table_of(c[3].s), o);
+ } else if (!strcmp(c[0].s, "release") && nc == 2 && table_of(c[1].s)) {
+ n = ck_pipe_release_table(&pool, table_of(c[1].s));
+ err = OSH_E_OK;
+ } else if ((!strcmp(c[0].s, "bread") || !strcmp(c[0].s, "bwrite")) && nc >= 4 && h) {
+ act = &c[3];
+ nact = nc - 3;
+ if (c[0].s[1] == 'r') {
+ size_t max = strtoul(c[2].s, 0, 10);
+ if (!expect(max <= sizeof rbig, cur_file, cur_line, "read size"))
+ return;
+ err = ck_stream_read(&pool, h->t, h->h, rbig, max, CK_PIPE_F_BLOCK, &n);
+ data = rbig;
+ } else {
+ err = ck_stream_write(&pool, h->t, h->h, c[2].b, c[2].n, CK_PIPE_F_BLOCK, &n);
+ }
+ expect(act_err == OSH_E_OK, cur_file, cur_line, "the wait hook's action succeeded");
+ } else if (!strcmp(c[0].s, "frame") && nc >= 3 && table_of(c[1].s)) {
+ uint64_t cells[16];
+ size_t ncell = 0;
+ for (int i = 3; i < nc && ncell < 16; i++) {
+ if (c[i].s[0] == '$') {
+ struct name *x = find(c[i].s + 1);
+ if (!expect(x != 0, cur_file, cur_line, "frame names a known handle"))
+ return;
+ cells[ncell++] = ck_handle_raw(x->h);
+ } else {
+ cells[ncell++] = strtoull(c[i].s, 0, 16);
+ }
+ }
+ struct ck_pipe_ret ret;
+ struct ck_cap_table *me = table_of(c[1].s);
+ uint8_t slice[BYTES_MAX];
+ size_t sl = 0;
+ if (c[2].quoted) {
+ memcpy(slice, c[2].b, c[2].n);
+ sl = c[2].n;
+ }
+ err = ck_pipe_dispatch(&pool, me, me == &ta ? &tb : &ta, cells, ncell, sl ? slice : 0, sl, &ret);
+ expect(ret.error == err, cur_file, cur_line, "frame result carries the error");
+ n = (size_t)ret.value;
+ if (want_n < 0)
+ n = 0;
+ } else {
+ int hb;
+ if (!expect(run_cmd(c, nc, &err, &n, &data, &hb) == 0, cur_file, cur_line, "known command"))
+ return;
+ }
+ snprintf(what, sizeof what, "%s: want %s got %s", c[0].s, osh_err_label((unsigned)want), osh_err_label(err));
+ expect(err == (unsigned)want, cur_file, cur_line, what);
+ if (want_n >= 0) {
+ snprintf(what, sizeof what, "%s: want n=%ld got n=%zu", c[0].s, want_n, n);
+ expect(n == (size_t)want_n, cur_file, cur_line, what);
+ }
+ if (want_data)
+ expect(data && n == want_data->n && !memcmp(data, want_data->b, n), cur_file, cur_line, "data byte for byte");
+}
+
+static int run_file(const char *dir, const char *fname)
+{
+ char path[512], line[1024];
+ snprintf(path, sizeof path, "%s/%s", dir, fname);
+ FILE *f = fopen(path, "r");
+ if (!expect(f != 0, fname, 0, "fixture opens"))
+ return 0;
+ ck_cap_init(&ta, 0x41, CK_CAP_SLOTS);
+ ck_cap_init(&tb, 0x42, CK_CAP_SLOTS);
+ ck_pipe_pool_init(&pool, &vec_hooks);
+ nnames = 0;
+ cur_file = fname;
+ cur_line = 0;
+ int has_case = 0, has_kind = 0, fail_before = ck_t_fail;
+ struct tok t[TOK_MAX];
+ while (fgets(line, sizeof line, f)) {
+ cur_line++;
+ int nt = tokenize(line, t, TOK_MAX);
+ if (!expect(nt >= 0, fname, cur_line, "line tokenizes"))
+ continue;
+ if (nt == 0)
+ continue;
+ has_case |= !strcmp(t[0].s, "case") && nt == 2;
+ has_kind |= !strcmp(t[0].s, "kind") && nt == 2 && (!strcmp(t[1].s, "positive") || !strcmp(t[1].s, "negative"));
+ run_line(t, nt);
+ }
+ fclose(f);
+ expect(has_case && has_kind, fname, cur_line, "fixture names its case and kind");
+ expect(all_empty(), fname, cur_line, "end of case: both tables and the pool are empty");
+ printf(" pipe fixture %s: %s\n", fname, ck_t_fail == fail_before ? "ok" : "FAILED");
+ return 1;
+}
+
+static int cmp_str(const void *a, const void *b)
+{
+ return strcmp(*(char *const *)a, *(char *const *)b);
+}
+
+static void run_fixtures(const char *dir)
+{
+ DIR *d = opendir(dir);
+ if (!expect(d != 0, dir, 0, "fixture directory opens"))
+ return;
+ char *list[128];
+ int n = 0;
+ struct dirent *e;
+ while ((e = readdir(d)) && n < 128) {
+ size_t l = strlen(e->d_name);
+ if (l > 4 && !strcmp(e->d_name + l - 4, ".vec"))
+ list[n++] = strdup(e->d_name);
+ }
+ closedir(d);
+ qsort(list, (size_t)n, sizeof list[0], cmp_str);
+ int ran = 0;
+ for (int i = 0; i < n; i++) {
+ ran += run_file(dir, list[i]);
+ free(list[i]);
+ }
+ CHECK(ran >= 20);
+}
+
+/* ---- transfers through the scheduler ---- */
+static struct pd_world world;
+static uint8_t sink[200000];
+
+static size_t expected_nuls(size_t n)
+{
+ size_t z = 0;
+ for (size_t i = 0; i < n; i++)
+ z += pd_byte(i) == 0;
+ return z;
+}
+
+static void fresh_tables(void)
+{
+ ck_cap_init(&ta, 0x41, CK_CAP_SLOTS);
+ ck_cap_init(&tb, 0x42, CK_CAP_SLOTS);
+}
+
+static void check_full_transfer(const char *label, unsigned flags, size_t cw, size_t cr, unsigned pe, unsigned ce)
+{
+ fresh_tables();
+ memset(sink, 0xaa, sizeof sink);
+ pd_run(&world, &pool, &ta, &tb, sink, sizeof sink, cw, cr, flags, pe, ce, 0);
+ const struct ck_pipe_stats *s = &pool.total;
+ printf(" transfer %s: sent=%zu recvd=%zu nul=%zu would_block=%llu waits=%llu wakeups=%llu max_resident=%llu "
+ "prod_steps=%llu cons_steps=%llu ticks=%llu\n",
+ label, world.sent, world.recvd, pd_nul_count(&world), (unsigned long long)s->would_block,
+ (unsigned long long)s->waits, (unsigned long long)s->wakeups, (unsigned long long)s->max_resident,
+ (unsigned long long)world.prod_steps, (unsigned long long)world.cons_steps,
+ (unsigned long long)world.ticks);
+ CHECK(world.setup_err == OSH_E_OK);
+ CHECK(world.prod_err == OSH_E_OK && world.cons_err == OSH_E_OK);
+ CHECK(world.tasks[0].done && world.tasks[1].done);
+ CHECK(world.sent == sizeof sink && world.recvd == sizeof sink);
+ CHECK(pd_mismatches(&world) == 0); /* byte for byte */
+ CHECK(pd_nul_count(&world) == expected_nuls(sizeof sink)); /* NUL bytes included */
+ CHECK(pd_nul_count(&world) >= sizeof sink / 5);
+ CHECK(world.eof_seen && s->eof == 1); /* last writer closed -> EOF */
+ CHECK(s->bytes_written == sizeof sink && s->bytes_read == sizeof sink);
+ CHECK(s->max_resident <= CK_PIPE_CAPACITY); /* bounded memory */
+ CHECK(s->cancellations == 0 && s->broken_pipe == 0 && s->revocations == 0);
+ CHECK(world.prod_steps > 1 && world.cons_steps > 1); /* real interleaving */
+ CHECK(all_empty());
+}
+
+static void test_transfers(void)
+{
+ /* slow consumer, non-blocking: the producer sees WOULD_BLOCK and the buffer reaches capacity */
+ check_full_transfer("slow-consumer-nonblocking", 0, 8192, 1000, 1, 4);
+ CHECK(pool.total.would_block > 0);
+ CHECK(pool.total.max_resident == CK_PIPE_CAPACITY);
+ CHECK(pool.total.waits == 0);
+ /* slow consumer, blocking: the producer parks and the consumer's reads wake it */
+ check_full_transfer("slow-consumer-blocking", CK_PIPE_F_BLOCK, 8192, 1000, 1, 4);
+ CHECK(pool.total.waits > 0 && pool.total.wakeups > 0);
+ CHECK(pool.total.max_resident == CK_PIPE_CAPACITY);
+ /* slow producer, blocking: the consumer parks on an empty pipe and the producer's writes wake it */
+ check_full_transfer("slow-producer-blocking", CK_PIPE_F_BLOCK, 1000, 8192, 4, 1);
+ CHECK(pool.total.waits > 0 && pool.total.wakeups > 0);
+ CHECK(pool.total.max_resident < CK_PIPE_CAPACITY);
+}
+
+static void test_revoke_midstream(unsigned flags)
+{
+ fresh_tables();
+ memset(sink, 0xaa, sizeof sink);
+ pd_run(&world, &pool, &ta, &tb, sink, sizeof sink, 8192, 1000, flags, 1, 4, 50000);
+ const struct ck_pipe_stats *s = &pool.total;
+ printf(" revoke mid-stream (%s): recvd=%zu sent=%zu reads_after_revoke=%zu prod_err=%s cons_err=%s\n",
+ flags ? "blocking" : "nonblocking", world.recvd, world.sent, world.reads_after_revoke,
+ osh_err_label(world.prod_err), osh_err_label(world.cons_err));
+ CHECK(world.setup_err == OSH_E_OK);
+ CHECK(world.revoked);
+ CHECK(world.reads_after_revoke == 0); /* no data emitted after revocation */
+ CHECK(world.recvd >= 50000 && world.recvd < 50000 + 1000);
+ CHECK(s->bytes_read == world.recvd);
+ CHECK(world.cons_err == OSH_E_REVOKED && world.prod_err == OSH_E_REVOKED);
+ CHECK(world.sent < sizeof sink);
+ CHECK(pd_mismatches(&world) == 0);
+ CHECK(s->revocations == 1 && s->eof == 0);
+ CHECK(world.tasks[0].done && world.tasks[1].done);
+ CHECK(all_empty());
+}
+
+static void test_epoch_and_forgery(void)
+{
+ fresh_tables();
+ ck_pipe_pool_init(&pool, 0);
+ struct ck_handle r, w, f, g;
+ size_t n = 0;
+ uint8_t b[4] = { 1, 2, 3, 4 };
+ CHECK(ck_pipe_create(&pool, &ta, &r, &w) == OSH_E_OK);
+ uint32_t epoch = pool.pipes[0].epoch;
+ CHECK(epoch == 1);
+ /* a capability naming another incarnation of the same slot is STALE (section 4.4), and close still releases it */
+ CHECK(ck_cap_insert(&ta, ck_pipe_resource(0, CK_PIPE_END_WRITE, epoch + 1), CK_R_WRITE, &f) == CK_CAP_OK);
+ CHECK(ck_stream_write(&pool, &ta, f, b, 4, 0, &n) == OSH_E_STALE && n == 0);
+ CHECK(ck_stream_close(&pool, &ta, f) == OSH_E_STALE);
+ CHECK(ck_cap_lookup(&ta, f, 0, 0) == CK_CAP_INVALID);
+ CHECK(pool.pipes[0].writer_refs == 1); /* the live pipe's count is untouched */
+ /* a capability on something that is not a stream is DENIED and not closed here */
+ CHECK(ck_cap_insert(&ta, CK_IPC_OBJECT_RESOURCE, CK_R_WRITE, &g) == CK_CAP_OK);
+ CHECK(ck_stream_write(&pool, &ta, g, b, 4, 0, &n) == OSH_E_DENIED);
+ CHECK(ck_stream_close(&pool, &ta, g) == OSH_E_DENIED);
+ CHECK(ck_cap_remove(&ta, g) == CK_CAP_OK);
+ /* no wait hook: a blocking read on an empty pipe returns WOULD_BLOCK */
+ CHECK(ck_stream_read(&pool, &ta, r, b, 4, CK_PIPE_F_BLOCK, &n) == OSH_E_WOULD_BLOCK);
+ CHECK(ck_stream_read(&pool, &ta, r, b, 4, 0x80, &n) == OSH_E_INVALID_ARG);
+ CHECK(ck_stream_close(&pool, &ta, r) == OSH_E_OK && ck_stream_close(&pool, &ta, w) == OSH_E_OK);
+ CHECK(all_empty());
+ /* a slot whose epoch reached the maximum is retired; with every slot retired create is LIMIT */
+ for (unsigned i = 0; i < CK_PIPE_POOL_PIPES; i++)
+ pool.pipes[i].epoch = CK_PIPE_EPOCH_MAX - 1;
+ CHECK(ck_pipe_create(&pool, &ta, &r, &w) == OSH_E_OK && pool.pipes[0].epoch == CK_PIPE_EPOCH_MAX);
+ CHECK(ck_pipe_release_table(&pool, &ta) == 2);
+ for (unsigned i = 1; i < CK_PIPE_POOL_PIPES; i++)
+ pool.pipes[i].epoch = CK_PIPE_EPOCH_MAX;
+ CHECK(ck_pipe_create(&pool, &ta, &r, &w) == OSH_E_LIMIT);
+ CHECK(all_empty());
+}
+
+static void test_dispatch(void)
+{
+ fresh_tables();
+ ck_pipe_pool_init(&pool, 0);
+ struct ck_pipe_ret ret;
+ uint64_t create[4] = { CK_PIPE_FRAME_MAGIC, CK_PIPE_ABI_VERSION, CK_PIPE_OP_CREATE, 0 };
+ CHECK(ck_pipe_dispatch(&pool, &ta, &tb, create, 4, 0, 0, &ret) == OSH_E_OK && ret.error == OSH_E_OK);
+ uint64_t rd = ret.value, wr = ret.value2;
+ CHECK(rd != 0 && wr != 0 && rd != wr);
+ uint8_t msg[5] = { 'p', 0, 'i', 0, 'p' }, got[8];
+ uint64_t wf[6] = { CK_PIPE_FRAME_MAGIC, CK_PIPE_ABI_VERSION, CK_PIPE_OP_WRITE, 0, wr, 0 };
+ CHECK(ck_pipe_dispatch(&pool, &ta, &tb, wf, 6, msg, 5, &ret) == OSH_E_OK && ret.value == 5);
+ uint64_t dup[7] = { CK_PIPE_FRAME_MAGIC, CK_PIPE_ABI_VERSION, CK_PIPE_OP_DUP, 0, rd, CK_R_READ, 1 };
+ CHECK(ck_pipe_dispatch(&pool, &ta, &tb, dup, 7, 0, 0, &ret) == OSH_E_OK);
+ uint64_t rb = ret.value;
+ uint64_t rf[6] = { CK_PIPE_FRAME_MAGIC, CK_PIPE_ABI_VERSION, CK_PIPE_OP_READ, 0, rb, 0 };
+ /* the dup lives in the peer table: from the caller's table the same raw handle is not ours */
+ CHECK(ck_pipe_dispatch(&pool, &tb, &ta, rf, 6, got, 8, &ret) == OSH_E_OK && ret.value == 5 && !memcmp(got, msg, 5));
+ /* the read end in the peer table cannot write */
+ uint64_t wb[6] = { CK_PIPE_FRAME_MAGIC, CK_PIPE_ABI_VERSION, CK_PIPE_OP_WRITE, 0, rb, 0 };
+ CHECK(ck_pipe_dispatch(&pool, &tb, &ta, wb, 6, msg, 5, &ret) == OSH_E_DENIED && ret.value == 0);
+ uint64_t cl[5] = { CK_PIPE_FRAME_MAGIC, CK_PIPE_ABI_VERSION, CK_PIPE_OP_CLOSE, 0, 0 };
+ cl[4] = rd;
+ CHECK(ck_pipe_dispatch(&pool, &ta, &tb, cl, 5, 0, 0, &ret) == OSH_E_OK);
+ cl[4] = wr;
+ CHECK(ck_pipe_dispatch(&pool, &ta, &tb, cl, 5, 0, 0, &ret) == OSH_E_OK);
+ cl[4] = rb;
+ CHECK(ck_pipe_dispatch(&pool, &tb, &ta, cl, 5, 0, 0, &ret) == OSH_E_OK);
+ CHECK(all_empty());
+ CHECK(ck_pipe_dispatch(&pool, &ta, &tb, 0, 0, 0, 0, &ret) == OSH_E_INVALID_ARG);
+}
+
+int main(int argc, char **argv)
+{
+ _Static_assert(CK_PIPE_CAPACITY >= 65536u, "section 8.5 minimum");
+ CHECK(osh_err_label(OSH_E_WOULD_BLOCK)[0] == 'W' && !strcmp(osh_err_label(99), "IO"));
+ run_fixtures(argc > 1 ? argv[1] : PIPE_FIXTURE_DIR);
+ test_transfers();
+ test_revoke_midstream(0);
+ test_revoke_midstream(CK_PIPE_F_BLOCK);
+ test_epoch_and_forgery();
+ test_dispatch();
+ return ck_t_verdict("test_pipe");
+}
diff --git a/native/kernel/tools/.crumb b/native/kernel/tools/.crumb
index 434135ec ..3dcffa99 100644
--- a/native/kernel/tools/.crumb
+++ b/native/kernel/tools/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-17T01:49:45Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:412f0a290f187935193ec94f1817c46dbe0edc07a5eb427e39977b65c1d00f9f ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 24,
- "generated_at_commit": "30379678add587e388db4e11713d6bca8d159b08 ",
- "source_tree": "sha256:811d4174e2479ef3a1cf5ed3f0ae69346da056fc12745e9f1b33afbe0b6f6dc5 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/kernel/tools/ck_imac_report_listen.c b/native/kernel/tools/ck_imac_report_listen.c
index 7cf699e9 ..e03aa32a 100644
--- a/native/kernel/tools/ck_imac_report_listen.c
+++ b/native/kernel/tools/ck_imac_report_listen.c
@@ -1,17 +1,25 @@
-/* ck_imac_report_listen.c -- host-side receiver for the iMac kernel's report
- * (native/kernel/x86/report_x86.c). Hosted C (POSIX sockets), tooling only,
- * never in a kernel image. No Python, no nc/socat.
+/* ck_imac_report_listen.c -- host-side receiver for the iMac kernel's LAB-ONLY
+ * report (native/kernel/x86/report_x86.c, only in the opt-in lab image built
+ * with make imac-kernel CK_X86_REPORT=1). Hosted C (POSIX sockets), tooling
+ * only, never in a kernel image. No Python, no nc/socat.
+ *
+ * UNAUTHENTICATED: the reports are plaintext UDP broadcasts that anyone on the
+ * LAN can read or forge (header field auth=none). The run id and the UDP
+ * checksum are not authenticity. A collected report is a lab note to read,
+ * never a receipt, evidence or a command, and this tool never acts on one.
*
* ck_imac_report_listen PORT OUTDIR SECONDS
*
* Binds 0.0.0.0:PORT and collects datagrams of the form
- * "AIENOS-IMAC-REPORT v=1 run=<16 hex> part=<i>/<n> bytes=<total>\n" + chunk
+ * "AIENOS-IMAC-REPORT v=2 auth=none run=<16 hex> part=<i>/<n> bytes=<total>\n" + chunk
* (the kernel broadcasts them from 0.0.0.0 to 255.255.255.255). Part i of n
* carries bytes [i * CHUNK, ...) of a report of <total> bytes. When every part
- * of a run is in, the report is written once to OUTDIR/imac-<run>.txt and a
- * line "complete run=... bytes=... file=..." goes to OUTDIR/listen.log. Repeats
- * of a finished run are counted, not rewritten. Anything else is logged as
- * ignored. Exit 0 at the deadline, 2 usage, 3 socket/bind error. */
+ * of a run is in, the report is written once to
+ * OUTDIR/imac-<run>.unauthenticated.txt and a line
+ * "complete run=... auth=none bytes=... file=..." goes to OUTDIR/listen.log.
+ * Repeats of a finished run are counted, not rewritten. Anything else,
+ * including the retired v=1 raw-console format, is logged as ignored.
+ * Exit 0 at the deadline, 2 usage, 3 socket/bind error. */
#define _POSIX_C_SOURCE 200809L
#include <arpa/inet.h>
#include <errno.h>
@@ -25,7 +33,11 @@
#include <time.h>
#include <unistd.h>
-#define MAGIC "AIENOS-IMAC-REPORT v=1 "
+#define MAGIC "AIENOS-IMAC-REPORT v=2 auth=none "
+#define LEGACY "AIENOS-IMAC-REPORT v=1 "
+#define UNAUTH_NOTE \
+ "note: iMac reports are UNAUTHENTICATED UDP broadcasts (auth=none); anyone on the LAN can read or " \
+ "forge one; never treat a report as a receipt, evidence or a command\n"
#define CHUNK 1024u
#define MAX_PARTS 64u
#define MAX_RUNS 16u
@@ -73,14 +85,14 @@ static FILE *open_private(const char *path, int flags, const char *mode)
static void finish_run(FILE *lg, const char *dir, struct run *r)
{
char path[4096];
- snprintf(path, sizeof path, "%s/imac-%s.txt", dir, r->id);
+ snprintf(path, sizeof path, "%s/imac-%s.unauthenticated.txt", dir, r->id);
FILE *f = open_private(path, O_TRUNC, "w");
if (!f || fwrite(r->data, 1, r->total, f) != r->total || fclose(f) != 0) {
fprintf(lg, "write failed run=%s file=%s errno=%d (%s)\n", r->id, path, errno, strerror(errno));
return;
}
r->done = 1;
- fprintf(lg, "complete run=%s bytes=%u parts=%u file=%s\n", r->id, r->total, r->parts, path);
+ fprintf(lg, "complete run=%s auth=none bytes=%u parts=%u file=%s\n", r->id, r->total, r->parts, path);
}
int main(int argc, char **argv)
@@ -116,7 +128,8 @@ int main(int argc, char **argv)
fclose(lg);
return 3;
}
- fprintf(lg, "ready port=%ld\n", port);
+ fprintf(lg, "ready port=%ld\n" UNAUTH_NOTE, port);
+ fputs(UNAUTH_NOTE, stderr);
double deadline = now_s() + (double)secs;
for (;;) {
double left = deadline - now_s();
@@ -139,6 +152,10 @@ int main(int argc, char **argv)
char id[17];
unsigned part, parts, total;
int used = 0;
+ if ((size_t)n >= sizeof LEGACY - 1 && memcmp(in, LEGACY, sizeof LEGACY - 1) == 0) {
+ fprintf(lg, "ignored from %s:%u len=%zd: retired v=1 raw-console report\n", fa, ntohs(from.sin_port), n);
+ continue;
+ }
if (!nl || (size_t)n < sizeof MAGIC - 1 || memcmp(in, MAGIC, sizeof MAGIC - 1) != 0 ||
sscanf((char *)in + sizeof MAGIC - 1, "run=%16[0-9a-f] part=%u/%u bytes=%u%n", id, &part, &parts, &total,
&used) != 4 ||
diff --git a/native/kernel/x86/kmain_x86.c b/native/kernel/x86/kmain_x86.c
index e6f0b871 ..c1d99c06 100644
--- a/native/kernel/x86/kmain_x86.c
+++ b/native/kernel/x86/kmain_x86.c
@@ -7,7 +7,11 @@
* allocator over the memory map (mm/frames.c), own 4-level page tables that
* identity map [0, top) with 2 MiB pages (RAM write-back, the rest uncached,
* the GOP framebuffer write-combining through PAT entry 1) and a 4 KiB guard
- * page under the kernel stack, CR3 switched and the stack moved. Then: the
+ * page under the kernel stack, CR3 switched and the stack moved. W^X (#409):
+ * EFER.NXE and CR0.WP on every core, the image's code read-only executable,
+ * its read-only data read-only no-execute, everything else (data, bss,
+ * stacks, heap, MMIO, framebuffer) no-execute; probes and an audit of every
+ * leaf prove it. W^X is not process isolation. Then: the
* screen console (core/fbcon.c), heap (mm/heap.c), the guard page proven to
* fault and the fault contained, the TSC measured against the HPET, the
* local APIC (xAPIC) with its timer at 100 Hz for 20 ticks, the MADT CPU
@@ -27,6 +31,9 @@
#ifndef AIENOS_COMMIT
#define AIENOS_COMMIT "unknown"
#endif
+#ifndef CK_X86_REPORT
+#define CK_X86_REPORT 0 /* 1 only in the opt-in lab image: the network report */
+#endif
#ifndef CK_X86_HOLD_S
#define CK_X86_HOLD_S 60u
#endif
@@ -47,6 +54,29 @@
#define PTE_PCD 0x10ull
#define PTE_PS 0x80ull
#define PTE_ADDR 0x000ffffffffff000ull
+#define MSR_EFER 0xc0000080u
+#define EFER_NXE (1ull << 11)
+#define CR0_WP (1ull << 16)
+
+/* W^X negative controls (make IMACKERN_WX_MUTANT=..., QEMU only, never
+ * deployed): no_nx drops every NX bit, text_writable leaves the code
+ * writable. The W^X probes below must then fail. */
+#define PTE_XD (1ull << 63) /* the hardware execute-disable bit */
+#ifdef CK_X86_WX_MUTANT_NO_NX
+#define PTE_NX 0ull
+#else
+#define PTE_NX PTE_XD
+#endif
+#ifdef CK_X86_WX_MUTANT_TEXT_RW
+#define TEXT_W PTE_W
+#else
+#define TEXT_W 0ull
+#endif
+
+/* image_x86_64.ld, runtime addresses: [image_base, text_start) PE header,
+ * [text_start, text_end) code, [ro_start, ro_end) rodata/relocs/GOT, then
+ * data and bss up to image_end. All page aligned. */
+extern char __image_base[], __text_start[], __text_end[], __ro_start[], __ro_end[], __image_end[];
const char *ck_commit(void) { return AIENOS_COMMIT; }
@@ -213,7 +243,14 @@ static __attribute__((noreturn)) void finish(void)
}
if (CK_X86_HOLD_S) {
ck_printf("power: holding the screen %u s, then ACPI S5\n", (unsigned)CK_X86_HOLD_S);
- ck_x86_report_hold(tsc_hz, CK_X86_HOLD_S); /* sends the report if the network is up */
+#if CK_X86_REPORT
+ /* Lab build only (make imac-kernel CK_X86_REPORT=1): sends the
+ * allowlisted, unauthenticated report if the network is up. */
+ ck_x86_report_hold(tsc_hz, CK_X86_HOLD_S);
+#else
+ /* Default and resident builds: no report code is linked; nothing is sent. */
+ delay_ms((uint64_t)CK_X86_HOLD_S * 1000u);
+#endif
}
acpi_poweroff();
ck_puts("power: halted; hold the power button to turn the machine off\n");
@@ -305,6 +342,7 @@ struct mm {
int fb_ok;
};
static struct mm mm;
+static uint64_t *pds[MAP_TOP_MAX >> 30];
static uint64_t *table_new(void)
{
@@ -323,6 +361,45 @@ static int efi_ram(uint32_t type)
return type <= 10 && type != 0 && type != 8;
}
+static int in_range(uint64_t p, const char *lo, const char *hi)
+{
+ return p >= (uint64_t)(uintptr_t)lo && p < (uint64_t)(uintptr_t)hi;
+}
+
+/* One 4 KiB page of a split 2 MiB page (cache bits from the 2 MiB entry):
+ * the stack guard unmapped, code RX, the PE header and read-only data R+NX,
+ * everything else RW+NX (the trampoline page included until smp_start). */
+static uint64_t leaf_4k(uint64_t p, uint64_t cache)
+{
+ if (p == (uint64_t)(uintptr_t)kstack)
+ return 0;
+ if (in_range(p, __text_start, __text_end))
+ return p | PTE_P | TEXT_W | cache;
+ if (in_range(p, __image_base, __text_start) || in_range(p, __ro_start, __ro_end))
+ return p | PTE_P | PTE_NX | cache;
+ return p | PTE_P | PTE_W | PTE_NX | cache;
+}
+
+/* The 2 MiB page holding a, split into 4 KiB pages at the protection
+ * boundaries above; a no-op when it already is. */
+static void split_2m(uint64_t a)
+{
+ uint64_t *e = &pds[a >> 30][(a >> 21) & 511];
+ if (!(*e & PTE_PS))
+ return;
+ uint64_t cache = *e & (PTE_PCD | PTE_PWT), *pt = table_new();
+ a &= ~((2ull << 20) - 1);
+ for (uint64_t j = 0; j < 512; j++)
+ pt[j] = leaf_4k(a | j << 12, cache);
+ *e = (uint64_t)(uintptr_t)pt | PTE_P | PTE_W;
+}
+
+static uint64_t *pte_4k(uint64_t a)
+{
+ uint64_t e = pds[a >> 30][(a >> 21) & 511];
+ return (uint64_t *)(uintptr_t)(e & PTE_ADDR) + ((a >> 12) & 511);
+}
+
static void mm_build(void)
{
const struct ck_handoff *h = hand;
@@ -364,30 +441,26 @@ static void mm_build(void)
/* Every 2 MiB page starts uncached (PCD|PWT, PAT index 3): device memory
* (local APIC, I/O APIC, HPET, PCI BARs) whatever the MTRRs say. Pages
* that hold RAM from the memory map become write-back (index 0), the
- * framebuffer write-combining (PWT alone, index 1, set to WC below). The
- * 2 MiB page holding the stack guard is split into 4 KiB pages. */
- static uint64_t *pds[MAP_TOP_MAX >> 30];
+ * framebuffer write-combining (PWT alone, index 1, set to WC below).
+ * Every 2 MiB page is no-execute; the ones holding the image or the
+ * trampoline are split into 4 KiB pages (leaf_4k) after the cache types
+ * are set. */
if (ck_rd_cr4() & (1ull << 12))
ck_panic("paging: firmware runs 5-level paging (CR4.LA57); this kernel builds 4-level tables");
+ uint32_t x[4];
+ ck_cpuid(0x80000000, 0, x);
+ if (x[0] < 0x80000001)
+ ck_panic("paging: no CPUID leaf 0x80000001, so no NX");
+ ck_cpuid(0x80000001, 0, x);
+ if (!(x[3] & (1u << 20)))
+ ck_panic("paging: CPU has no NX (execute disable); this kernel needs it for W^X");
uint64_t *pml4 = table_new(), *pdpt = table_new();
pml4[0] = (uint64_t)(uintptr_t)pdpt | PTE_P | PTE_W;
- uint64_t guard = (uint64_t)(uintptr_t)kstack;
for (uint64_t g = 0; g < top >> 30; g++) {
uint64_t *pd = pds[g] = table_new();
pdpt[g] = (uint64_t)(uintptr_t)pd | PTE_P | PTE_W;
- for (uint64_t i = 0; i < 512; i++) {
- uint64_t a = g << 30 | i << 21;
- if (a <= guard && guard < a + (2ull << 20)) {
- uint64_t *pt = table_new();
- for (uint64_t j = 0; j < 512; j++) {
- uint64_t p = a | j << 12;
- pt[j] = p == guard ? 0 : (p | PTE_P | PTE_W);
- }
- pd[i] = (uint64_t)(uintptr_t)pt | PTE_P | PTE_W;
- continue;
- }
- pd[i] = a | PTE_P | PTE_W | PTE_PS | PTE_PCD | PTE_PWT;
- }
+ for (uint64_t i = 0; i < 512; i++)
+ pd[i] = (g << 30 | i << 21) | PTE_P | PTE_W | PTE_PS | PTE_PCD | PTE_PWT | PTE_NX;
}
for (uint64_t off = 0; off + h->desc_size <= h->map_size; off += h->desc_size) {
const struct ck_efi_desc *d = (const void *)(uintptr_t)(h->memory_map + off);
@@ -405,6 +478,11 @@ static void mm_build(void)
if (*e & PTE_PS)
*e = (*e & ~PTE_PCD) | PTE_PWT;
}
+ for (uint64_t a = (uint64_t)(uintptr_t)__image_base & ~((2ull << 20) - 1); a < (uint64_t)(uintptr_t)__image_end;
+ a += 2ull << 20)
+ split_2m(a);
+ if (tramp_pa)
+ split_2m(tramp_pa);
for (uint64_t g = 0; g < top >> 30; g++)
for (uint64_t i = 0; i < 512; i++) {
uint64_t e = pds[g][i];
@@ -426,7 +504,11 @@ static void mm_build(void)
ck_panic("paging: CPU has no PAT");
__asm__ volatile("wbinvd" ::: "memory");
ck_wrmsr(0x277, 0x0007040600070106ull);
+ /* NX bits are reserved (every access faults) until EFER.NXE is set;
+ * CR0.WP makes read-only pages bind the kernel too. */
+ ck_wrmsr(MSR_EFER, ck_rdmsr(MSR_EFER) | EFER_NXE);
ck_wr_cr3(mm.root);
+ __asm__ volatile("mov %0, %%cr0" ::"r"(ck_rd_cr0() | CR0_WP) : "memory");
/* Toggling CR4.PGE drops global TLB entries the firmware's tables left. */
uint64_t cr4 = ck_rd_cr4();
if (cr4 & 0x80) {
@@ -457,7 +539,7 @@ int ck_x86_map_mmio(uint64_t pa, uint64_t len)
uint64_t *pd = sub_table(sub_table(pml4, (unsigned)(a >> 39) & 511), (unsigned)(a >> 30) & 511);
uint64_t *e = &pd[(a >> 21) & 511];
if (!(*e & PTE_P)) {
- *e = a | PTE_P | PTE_W | PTE_PS | PTE_PCD | PTE_PWT;
+ *e = a | PTE_P | PTE_W | PTE_PS | PTE_PCD | PTE_PWT | PTE_NX;
mm.pages_uc++;
}
__asm__ volatile("invlpg (%0)" ::"r"(a) : "memory");
@@ -620,7 +702,7 @@ struct smp_report {
uint32_t ids[SMP_MAX], up_ids[SMP_MAX];
const char *why;
};
-static volatile uint32_t ap_up, ap_ids[SMP_MAX];
+static volatile uint32_t ap_up, ap_ids[SMP_MAX], ap_nx_wp; /* ap_nx_wp: cores that came up with EFER.NXE and CR0.WP */
static void delay_us(uint64_t us)
{
@@ -644,6 +726,8 @@ static void ap_entry(void *arg)
apic_wr(APIC_TPR, 0);
apic_wr(APIC_SVR, 0x100 | VEC_SPURIOUS);
ap_ids[idx] = apic_rd(APIC_ID) >> 24;
+ if ((ck_rdmsr(MSR_EFER) & EFER_NXE) && (ck_rd_cr0() & CR0_WP))
+ __atomic_fetch_add(&ap_nx_wp, 1, __ATOMIC_SEQ_CST);
__atomic_fetch_add(&ap_up, 1, __ATOMIC_SEQ_CST);
for (;;)
__asm__ volatile("cli; hlt");
@@ -676,6 +760,16 @@ static uint32_t tramp_at(const char *sym)
return (uint32_t)(tramp_pa + (uint64_t)(uintptr_t)(sym - ck_x86_tramp_start));
}
+/* The trampoline page is never writable and executable at once: RW+NX while
+ * it is filled, RX while a core runs it, R+NX once the cores are parked (a
+ * parked core runs nothing, so no TLB shootdown). */
+static void tramp_prot(uint64_t bits)
+{
+ uint64_t *e = pte_4k(tramp_pa);
+ *e = (*e & (PTE_ADDR | PTE_PCD | PTE_PWT)) | PTE_P | bits;
+ __asm__ volatile("invlpg (%0)" ::"r"(tramp_pa) : "memory");
+}
+
static void smp_start(const struct apic_report *ar, struct smp_report *sr)
{
const uint8_t *m = ck_acpi_lookup(hand->rsdp, "APIC");
@@ -690,8 +784,11 @@ static void smp_start(const struct apic_report *ar, struct smp_report *sr)
sr->why = "page tables above 4 GiB";
else if (size > CK_PAGE)
sr->why = "trampoline larger than a page";
- if (sr->why)
+ if (sr->why) {
+ if (tramp_pa)
+ tramp_prot(PTE_NX);
return;
+ }
memcpy((void *)(uintptr_t)tramp_pa, ck_x86_tramp_start, size);
tramp_put32(ck_x86_tramp_gdtr + 2, tramp_at(ck_x86_tramp_gdt));
tramp_put32(ck_x86_tramp_far32, tramp_at(ck_x86_tramp_pm32));
@@ -708,8 +805,10 @@ static void smp_start(const struct apic_report *ar, struct smp_report *sr)
continue;
}
unsigned before = ap_up;
+ tramp_prot(PTE_W | PTE_NX);
tramp_put64(ck_x86_tramp_stack, st + AP_STACK_PAGES * CK_PAGE);
tramp_put64(ck_x86_tramp_arg, before);
+ tramp_prot(0);
__asm__ volatile("mfence" ::: "memory");
int bad = icr_send(id, 0x4500); /* INIT, assert */
delay_ms(10);
@@ -727,6 +826,126 @@ static void smp_start(const struct apic_report *ar, struct smp_report *sr)
if (ap_up > before + 1)
break; /* a core checked in twice or out of turn: stop starting more */
}
+ tramp_prot(PTE_NX);
+}
+
+/* ---- W^X (#409) ----
+ * Each probe arms the #PF catcher (ck_x86_trap), touches one address and
+ * resumes after the access. The store writes back the byte it read, so a
+ * build that lets it through changes nothing. The execute probe jumps to
+ * `jmp *%rax` (rax = the resume label), so code that does run comes straight
+ * back and the probe sees no fault. Error code bits: P 0, W 1, RSVD 3, I/D 4. */
+static int probe_write(uint64_t a)
+{
+ probe.hit = 0;
+ probe.armed = 1;
+ __asm__ volatile("lea 1f(%%rip), %%rax\n\t"
+ "mov %%rax, %0\n\t"
+ "movb (%1), %%cl\n\t"
+ "movb %%cl, (%1)\n"
+ "1:"
+ : "=m"(probe.resume)
+ : "r"(a)
+ : "rax", "rcx", "memory");
+ probe.armed = 0;
+ return probe.hit && probe.cr2 == a && (probe.err & 0x1b) == 0x03;
+}
+
+static int probe_exec(uint8_t *buf)
+{
+ buf[0] = 0xff; /* jmp *%rax */
+ buf[1] = 0xe0;
+ uint64_t a = (uint64_t)(uintptr_t)buf;
+ probe.hit = 0;
+ probe.armed = 1;
+ __asm__ volatile("lea 1f(%%rip), %%rax\n\t"
+ "mov %%rax, %0\n\t"
+ "jmp *%1\n"
+ "1:"
+ : "=m"(probe.resume)
+ : "r"(a)
+ : "rax", "memory");
+ probe.armed = 0;
+ return probe.hit && probe.cr2 == a && (probe.err & 0x1b) == 0x11;
+}
+
+static void wx_probes(void)
+{
+ uint64_t efer = ck_rdmsr(MSR_EFER), cr0 = ck_rd_cr0();
+ uint8_t *hb = ck_heap_alloc(&heap, 16);
+ uint8_t sb[16];
+ if (!hb)
+ ck_panic("wx: no heap for the execute probe");
+ int tw = probe_write((uint64_t)(uintptr_t)__text_start), rw = probe_write((uint64_t)(uintptr_t)__ro_start);
+ int hx = probe_exec(hb), sx = probe_exec(sb);
+ ck_heap_free(&heap, hb);
+ const char *f = "fault", *n = "ALLOWED";
+ if (!(efer & EFER_NXE) || !(cr0 & CR0_WP) || !tw || !rw || !hx || !sx)
+ ck_panic("wx: FAIL nx=%s wp=%s text_write=%s ro_write=%s heap_exec=%s stack_exec=%s",
+ efer & EFER_NXE ? "on" : "off", cr0 & CR0_WP ? "on" : "off", tw ? f : n, rw ? f : n,
+ hx ? f : n, sx ? f : n);
+ ck_puts("wx: ok nx=on wp=on text_write=fault ro_write=fault heap_exec=fault stack_exec=fault\n");
+}
+
+/* Every present leaf of the live tables (identity map, MMIO above it, the
+ * trampoline): no page may be writable and executable, the executable ones
+ * must be exactly the code, and the PE header and read-only data must not
+ * be writable. Counts are 4 KiB pages. */
+static void wx_audit(unsigned started)
+{
+ uint64_t wx = 0, ex = 0, ex_out = 0, ro_w = 0, text = (uint64_t)(__text_end - __text_start) >> 12;
+ const uint64_t *pml4 = (const uint64_t *)(uintptr_t)mm.root;
+ for (uint64_t i = 0; i < 512; i++) {
+ if (!(pml4[i] & PTE_P))
+ continue;
+ const uint64_t *pdpt = (const uint64_t *)(uintptr_t)(pml4[i] & PTE_ADDR);
+ for (uint64_t j = 0; j < 512; j++) {
+ if (!(pdpt[j] & PTE_P))
+ continue;
+ if (pdpt[j] & PTE_PS) { /* 1 GiB page: never built here, counted if present */
+ if (!(pdpt[j] & PTE_XD)) {
+ ex += 1u << 18, ex_out += 1u << 18;
+ wx += pdpt[j] & PTE_W ? 1u << 18 : 0;
+ }
+ continue;
+ }
+ const uint64_t *pd = (const uint64_t *)(uintptr_t)(pdpt[j] & PTE_ADDR);
+ for (uint64_t k = 0; k < 512; k++) {
+ uint64_t e = pd[k];
+ if (!(e & PTE_P))
+ continue;
+ if (e & PTE_PS) {
+ if (!(e & PTE_XD)) {
+ ex += 512, ex_out += 512;
+ wx += e & PTE_W ? 512 : 0;
+ }
+ continue;
+ }
+ const uint64_t *pt = (const uint64_t *)(uintptr_t)(e & PTE_ADDR);
+ for (uint64_t l = 0; l < 512; l++) {
+ uint64_t p = i << 39 | j << 30 | k << 21 | l << 12;
+ if (!(pt[l] & PTE_P))
+ continue;
+ if ((pt[l] & PTE_W) && (in_range(p, __image_base, __text_start) || in_range(p, __ro_start, __ro_end)))
+ ro_w++;
+ if (pt[l] & PTE_XD)
+ continue;
+ ex++;
+ ex_out += !in_range(p, __text_start, __text_end);
+ wx += !!(pt[l] & PTE_W);
+ }
+ }
+ }
+ }
+ if (wx || ex != text || ex_out || ro_w || ap_nx_wp != started)
+ ck_panic("wx_audit: FAIL wx_pages=%llu exec_pages=%llu text_pages=%llu exec_outside_text=%llu ro_writable=%llu "
+ "cores_nx_wp=%u/%u",
+ (unsigned long long)wx, (unsigned long long)ex, (unsigned long long)text,
+ (unsigned long long)ex_out, (unsigned long long)ro_w, ap_nx_wp + 1, started + 1);
+ ck_printf("wx_audit: ok wx_pages=0 exec_pages=%llu text_pages=%llu exec_outside_text=0 ro_writable=0 "
+ "cores_nx_wp=%u/%u trampoline=%s\n",
+ (unsigned long long)ex, (unsigned long long)text, ap_nx_wp + 1, started + 1,
+ tramp_pa ? "retired" : "none");
}
/* ---- the kernel ---- */
@@ -813,6 +1032,7 @@ static __attribute__((noreturn)) void kernel_main(void *arg)
else
ck_panic("guard_page: FAIL hit=%d cr2=0x%llx error=0x%llx", probe.hit, (unsigned long long)probe.cr2,
(unsigned long long)probe.err);
+ wx_probes();
tsc_measure();
if (!tsc_hz)
@@ -849,6 +1069,7 @@ static __attribute__((noreturn)) void kernel_main(void *arg)
}
const struct ck_x86_storage_result *st = ck_x86_storage(h->rsdp, &frames, tsc_hz, mm.top);
+ wx_audit(sr.started);
ck_puts("kernel: alive\n");
ck_printf("summary: cores=%u/%u timer=ok sata_disks=%u nvme_disks=%u gpt_valid=%u writes=none net=%s\n",
sr.started + 1, sr.listed, st->ahci_disks, st->nvme_disks, st->gpt_valid,
@@ -868,6 +1089,9 @@ void ck_x86_kernel_entry(struct ck_handoff *h)
hand = h;
tables_load();
ck_puts("\nreport_kind: kernel\n");
+#if defined(CK_X86_WX_MUTANT_NO_NX) || defined(CK_X86_WX_MUTANT_TEXT_RW)
+ ck_puts("wx: TEST-ONLY W^X mutant build, page permissions deliberately broken, never deploy\n");
+#endif
ck_printf("exit_boot_services: ok attempts=%u\n", h->exit_attempts);
cpu_line();
ck_puts("descriptors: gdt=5 tss=yes ist1=df,nmi,mc idt=256\n");
diff --git a/native/kernel/x86/report_x86.c b/native/kernel/x86/report_x86.c
index cbf9c993 ..0880a2d8 100644
--- a/native/kernel/x86/report_x86.c
+++ b/native/kernel/x86/report_x86.c
@@ -1,18 +1,32 @@
-/* report_x86.c -- sends the iMac kernel's report over Ethernet, so the
- * owner no longer has to photograph the screen.
+/* report_x86.c -- LAB-ONLY: sends the iMac kernel's diagnostic lines over
+ * Ethernet, so the owner does not have to photograph the screen.
*
- * The report is the console's RAM copy (console_x86.c: everything printed,
- * the first 16 KiB). It is cut into parts of CK_X86_REPORT_CHUNK bytes; each
- * part is one UDP datagram from 0.0.0.0:PORT to 255.255.255.255:PORT in an
- * Ethernet broadcast frame (no address to configure, no ARP, nothing to
- * answer), with a one-line header the receiver checks:
- * "AIENOS-IMAC-REPORT v=1 run=<16 hex> part=<i>/<n> bytes=<total>\n"
- * The host side is native/kernel/tools/ck_imac_report_listen.c. During the
- * screen hold the whole report is sent again every 2 s while the link is up,
- * so a receiver that missed a datagram gets it on the next round.
+ * Built only into the opt-in lab image (make imac-kernel CK_X86_REPORT=1,
+ * which writes IMACKERN-LAB.EFI). The default image links none of this file
+ * nor the network library, and the Makefile fails a default image that has
+ * its symbols; resident and service builds must never add it. Any future
+ * service diagnostics go over the authenticated transport with an explicitly
+ * authorized peer, never this broadcast.
*
- * ck_x86_report_frame is a pure function of its arguments (no device, no
- * clock) and is host-tested by scripts/ck_imac_report_test.sh. */
+ * What is sent: ck_x86_report_filter's copy of the console's RAM copy
+ * (console_x86.c, the first 16 KiB), which keeps only complete, printable,
+ * bounded lines that start with a fixed kernel diagnostic key and drops
+ * everything else whole. The raw console is never sent. The copy is cut into
+ * parts of CK_X86_REPORT_CHUNK bytes; each part is one UDP datagram from
+ * 0.0.0.0:PORT to 255.255.255.255:PORT in an Ethernet broadcast frame (no
+ * address to configure, no ARP, nothing to answer), with a one-line header the
+ * receiver checks:
+ * "AIENOS-IMAC-REPORT v=2 auth=none run=<16 hex> part=<i>/<n> bytes=<total>\n"
+ * auth=none says what it is: anyone on the LAN can read or forge one, and the
+ * run id and checksum are not authenticity. A received report is never a
+ * receipt, evidence or a command. The host side is
+ * native/kernel/tools/ck_imac_report_listen.c. During the screen hold the whole
+ * report is sent again every 2 s while the link is up, so a receiver that
+ * missed a datagram gets it on the next round.
+ *
+ * ck_x86_report_filter and ck_x86_report_frame are pure functions of their
+ * arguments (no device, no clock) and are host-tested by
+ * scripts/ck_imac_report_test.sh. */
#ifdef CK_X86_REPORT_HOST
#include <string.h>
#else
@@ -22,8 +36,64 @@
#include "aienos_net.h"
#include "report_x86.h"
-#define REPORT_HDR "AIENOS-IMAC-REPORT v=1 "
+#define REPORT_HDR "AIENOS-IMAC-REPORT v=2 auth=none "
+
+/* The allowlist: every key the iMac kernel prints (the x86 sources, efi_gop.c,
+ * and the disk report's ahci_/nvme_ _read and _gpt lines), minus "memory:",
+ * which describes the kernel's own memory layout. A new key stays off the
+ * report until it is added here. */
+static const char *const allowed_keys[] = {
+ "acpi_rsdp", "ahci", "ahci_disk", "ahci_gpt", "ahci_port", "ahci_read", "aienos_commit", "apic", "cpu",
+ "descriptors", "exit_boot_services", "firmware_cpl", "firmware_revision", "firmware_vendor", "gop",
+ "guard_page", "handoff", "image", "kernel", "kernel_impl", "madt", "net", "net_tg3", "note", "nvme",
+ "nvme_disk", "nvme_gpt", "nvme_read", "paging", "panic", "pci", "power", "report", "report_kind", "screen",
+ "smp", "stack", "storage", "summary", "timebase", "timer_irq", "timer_stats",
+};
+static const char *const allowed_lines[] = {
+ "AIENOS-IMAC-KERNEL-0",
+ "AIENOS-IMAC-KERNEL-0 DONE",
+ "exiting firmware boot services",
+};
+
+static int line_allowed(const char *s, size_t n)
+{
+ if (n > CK_X86_REPORT_LINE_MAX)
+ return 0;
+ for (size_t i = 0; i < n; i++)
+ if ((unsigned char)s[i] < 0x20 || (unsigned char)s[i] > 0x7e)
+ return 0;
+ for (size_t k = 0; k < sizeof allowed_lines / sizeof allowed_lines[0]; k++)
+ if (strlen(allowed_lines[k]) == n && !memcmp(s, allowed_lines[k], n))
+ return 1;
+ for (size_t k = 0; k < sizeof allowed_keys / sizeof allowed_keys[0]; k++) {
+ size_t kl = strlen(allowed_keys[k]);
+ if (n > kl && s[kl] == ':' && !memcmp(s, allowed_keys[k], kl))
+ return 1;
+ }
+ return 0;
+}
+size_t ck_x86_report_filter(const char *log, size_t len, char *out, size_t cap)
+{
+ size_t w = 0;
+ if (!log || !out)
+ return 0;
+ for (size_t i = 0; i < len;) {
+ size_t e = i;
+ while (e < len && log[e] != '\n')
+ e++;
+ if (e == len) /* unterminated last line: dropped */
+ break;
+ size_t n = e - i;
+ if (line_allowed(log + i, n) && cap - w > n) {
+ memcpy(out + w, log + i, n);
+ out[w + n] = '\n';
+ w += n + 1;
+ }
+ i = e + 1;
+ }
+ return w;
+}
static void hex16(char *out, uint64_t v)
{
for (int i = 15; i >= 0; i--, v >>= 4)
@@ -49,12 +119,12 @@ unsigned ck_x86_report_parts(size_t len)
return (unsigned)((len + CK_X86_REPORT_CHUNK - 1) / CK_X86_REPORT_CHUNK);
}
-size_t ck_x86_report_frame(const uint8_t mac[6], uint64_t run, const char *log, size_t len, unsigned part,
+size_t ck_x86_report_frame(const uint8_t mac[6], uint64_t run, const char *report, size_t len, unsigned part,
uint8_t *out, size_t cap)
{
static uint8_t data[160 + CK_X86_REPORT_CHUNK], udp[8 + sizeof data], ip[20 + sizeof udp];
unsigned parts = ck_x86_report_parts(len);
- if (!mac || !log || !out || part >= parts)
+ if (!mac || !report || !out || part >= parts)
return 0;
size_t off = (size_t)part * CK_X86_REPORT_CHUNK;
size_t n = len - off < CK_X86_REPORT_CHUNK ? len - off : CK_X86_REPORT_CHUNK;
@@ -72,7 +142,7 @@ size_t ck_x86_report_frame(const uint8_t mac[6], uint64_t run, const char *log,
h += 7;
h += dec((char *)data + h, (unsigned)len);
data[h++] = '\n';
- memcpy(data + h, log + off, n);
+ memcpy(data + h, report + off, n);
const net_ipv4 any = {{0, 0, 0, 0}}, bcast_ip = {{255, 255, 255, 255}};
net_udp_header uh = {CK_X86_REPORT_PORT, CK_X86_REPORT_PORT};
@@ -100,8 +170,9 @@ size_t ck_x86_report_frame(const uint8_t mac[6], uint64_t run, const char *log,
}
#ifndef CK_X86_REPORT_HOST
-/* Holds for `seconds`, sending the report every 2 s while the link is up.
- * Without a working network it only waits. Returns the rounds sent. */
+/* Lab build only. Holds for `seconds`, sending the allowlisted report every
+ * 2 s while the link is up. Without a working network it only waits. Returns
+ * the rounds sent. */
unsigned ck_x86_report_hold(uint64_t tsc_hz, unsigned seconds)
{
static uint8_t frame[1600];
@@ -112,10 +183,14 @@ unsigned ck_x86_report_hold(uint64_t tsc_hz, unsigned seconds)
ck_pause();
return 0;
}
- ck_printf("report: sending this screen to UDP port %u (broadcast) every 2 s during the hold\n",
+ ck_printf("report: LAB BUILD, sending allowlisted diagnostic lines to UDP port %u (broadcast, "
+ "unauthenticated, auth=none) every 2 s during the hold\n",
(unsigned)CK_X86_REPORT_PORT);
- size_t len;
- const char *log = ck_x86_console_log(&len);
+ static char report[CK_X86_REPORT_MAX];
+ size_t raw_len;
+ const char *raw = ck_x86_console_log(&raw_len);
+ /* Only the filtered copy leaves the machine; the raw console never does. */
+ size_t len = ck_x86_report_filter(raw, raw_len, report, sizeof report);
unsigned parts = ck_x86_report_parts(len), rounds = 0, failed = 0;
uint8_t mac[6];
ck_x86_tg3_mac(mac);
@@ -129,7 +204,7 @@ unsigned ck_x86_report_hold(uint64_t tsc_hz, unsigned seconds)
if (!ck_x86_tg3_link())
continue;
for (unsigned p = 0; p < parts; p++) {
- size_t n = ck_x86_report_frame(mac, run, log, len, p, frame, sizeof frame);
+ size_t n = ck_x86_report_frame(mac, run, report, len, p, frame, sizeof frame);
if (!n || ck_x86_tg3_send(frame, n))
failed++;
}
diff --git a/native/kernel/x86/report_x86.h b/native/kernel/x86/report_x86.h
index 72b67577 ..4dd02a58 100644
--- a/native/kernel/x86/report_x86.h
+++ b/native/kernel/x86/report_x86.h
@@ -1,20 +1,39 @@
-/* report_x86.h -- the iMac kernel's network report (report_x86.c): the
- * console's RAM copy cut into UDP broadcast datagrams. No machine access in
- * here, so the frame builder is also compiled and tested on the host. */
+/* report_x86.h -- the iMac kernel's network report (report_x86.c), a
+ * LAB-ONLY diagnostic: compiled and linked only into the opt-in lab image
+ * (make imac-kernel CK_X86_REPORT=1 -> IMACKERN-LAB.EFI). The default and
+ * any resident or service build carry none of it, and the Makefile fails a
+ * default image that contains it. The report is an unauthenticated UDP
+ * broadcast (header field auth=none): its run id and the UDP checksum are not
+ * cryptographic authenticity, so a received report is never a receipt,
+ * evidence or a command. It carries only console lines whose key is on a
+ * fixed allowlist (ck_x86_report_filter), never the raw console. No machine
+ * access in here, so the filter and the frame builder are also compiled and
+ * tested on the host. */
#ifndef AIENOS_CK_X86_REPORT_H
#define AIENOS_CK_X86_REPORT_H
#include <stddef.h>
#include <stdint.h>
-#define CK_X86_REPORT_PORT 47031u /* UDP, source and destination */
-#define CK_X86_REPORT_CHUNK 1024u /* report bytes per datagram */
-#define CK_X86_REPORT_MAX 16384u /* the console's RAM copy */
+#define CK_X86_REPORT_PORT 47031u /* UDP, source and destination */
+#define CK_X86_REPORT_CHUNK 1024u /* report bytes per datagram */
+#define CK_X86_REPORT_MAX 16384u /* the console's RAM copy */
+#define CK_X86_REPORT_LINE_MAX 240u /* longest line kept, newline excluded */
+/* Copies into out (cap bytes) only the complete lines of log[0, len) that
+ * are on the allowlist: the line starts with one of the fixed kernel
+ * diagnostic keys followed by ':' (or is one of the fixed title lines), is at
+ * most CK_X86_REPORT_LINE_MAX bytes and holds printable ASCII only (0x20 to
+ * 0x7e). Every other line is dropped whole, as is an unterminated last line
+ * and any line that no longer fits. Kept lines are copied byte for byte, each
+ * ending in '\n'. Returns the bytes written. Pure: no device, no clock. */
+size_t ck_x86_report_filter(const char *log, size_t len, char *out, size_t cap);
/* Datagrams needed for a report of len bytes; 0 when len is 0 or too big. */
unsigned ck_x86_report_parts(size_t len);
/* The Ethernet frame (no FCS) carrying part `part` of the report: broadcast
- * from `mac`, IPv4 0.0.0.0 -> 255.255.255.255, UDP PORT -> PORT, TTL 1.
+ * from `mac`, IPv4 0.0.0.0 -> 255.255.255.255, UDP PORT -> PORT, TTL 1,
+ * payload "AIENOS-IMAC-REPORT v=2 auth=none run=<16 hex> part=<i>/<n>
+ * bytes=<total>\n" + chunk. `report` must be ck_x86_report_filter output.
* Bytes written, 0 on a bad argument or a buffer too small. */
-size_t ck_x86_report_frame(const uint8_t mac[6], uint64_t run, const char *log, size_t len, unsigned part,
+size_t ck_x86_report_frame(const uint8_t mac[6], uint64_t run, const char *report, size_t len, unsigned part,
uint8_t *out, size_t cap);
#endif
diff --git a/native/kernel/x86/smp_x86.S b/native/kernel/x86/smp_x86.S
index a49955ee ..59b6e186 100644
--- a/native/kernel/x86/smp_x86.S
+++ b/native/kernel/x86/smp_x86.S
@@ -7,9 +7,11 @@
* INIT, SIPI, SIPI with the page number as the vector. A core then starts
* here in real mode at CS = page >> 4, IP = 0, and walks: 16-bit -> 32-bit
* protected mode (the trampoline's own flat GDT) -> PAE + the kernel's page
- * tables + EFER.LME + paging -> 64-bit, then calls entry(arg) on its own
- * stack (-mabi=ms: the argument in rcx, 32 bytes of shadow space). If entry
- * returns, the core halts with interrupts off. */
+ * tables + EFER.LME/NXE + paging and CR0.WP -> 64-bit, then calls entry(arg)
+ * on its own stack (-mabi=ms: the argument in rcx, 32 bytes of shadow space).
+ * If entry returns, the core halts with interrupts off. Once paging is on the
+ * page is read-only executable (W^X, kmain_x86.c tramp_prot), so the GDT
+ * descriptors carry their accessed bit already: the CPU never writes them. */
.text
.globl ck_x86_tramp_start, ck_x86_tramp_end
@@ -44,10 +46,10 @@ tramp_pm32:
mov %eax, %cr3
mov $0xc0000080, %ecx /* EFER */
rdmsr
- or $0x100, %eax /* LME */
+ or $0x900, %eax /* LME + NXE: the kernel's tables carry NX bits */
wrmsr
mov %cr0, %eax
- or $0x80000000, %eax /* PG */
+ or $0x80010000, %eax /* PG + WP: read-only pages bind this core too */
mov %eax, %cr0
ljmpl *(ck_x86_tramp_far64 - ck_x86_tramp_start)(%ebx)
@@ -70,9 +72,9 @@ tramp_lm64:
.p2align 3
tramp_gdt:
.quad 0
- .quad 0x00cf9a000000ffff /* 0x08: 32-bit code */
- .quad 0x00cf92000000ffff /* 0x10: data */
- .quad 0x00209a0000000000 /* 0x18: 64-bit code */
+ .quad 0x00cf9b000000ffff /* 0x08: 32-bit code, accessed */
+ .quad 0x00cf93000000ffff /* 0x10: data, accessed */
+ .quad 0x00209b0000000000 /* 0x18: 64-bit code, accessed */
ck_x86_tramp_gdtr:
.word 31
.long 0 /* page + (tramp_gdt - start) */
diff --git a/native/kernel/x86/tg3_x86.c b/native/kernel/x86/tg3_x86.c
index d8ef92d3 ..ea2647b0 100644
--- a/native/kernel/x86/tg3_x86.c
+++ b/native/kernel/x86/tg3_x86.c
@@ -1,5 +1,8 @@
/* tg3_x86.c -- the 2017 iMac's Broadcom BCM57766 Ethernet chip (PCI
- * 14e4:1686), transmit only, polled, for the kernel's network report.
+ * 14e4:1686), polled, received frames never read. The default image uses
+ * it for link detection only; frame transmit (ck_x86_tg3_send,
+ * ck_x86_tg3_drain) is compiled only into the opt-in lab image
+ * (CK_X86_REPORT=1), for the lab-only network report.
*
* Written from Broadcom's register layout as the Linux tg3 driver documents
* it (no code taken from it); the order of every step follows tg3's
@@ -161,7 +164,7 @@
static volatile uint8_t *regs, *cfg;
static uint64_t hz, dma;
static uint8_t mac[6];
-static int ready, link_up, stalled_shown;
+static int ready, link_up;
static unsigned tx_prod, pcie_cap;
static uint32_t mac_mode;
@@ -632,6 +635,11 @@ int ck_x86_tg3_link(void)
return 1;
}
+#if defined(CK_X86_REPORT) && CK_X86_REPORT
+/* Transmit exists only in the opt-in lab image, for the network report
+ * (report_x86.c). The default image has no way to send a frame. */
+static int stalled_shown;
+
static unsigned tx_cons(void)
{
__asm__ volatile("" ::: "memory");
@@ -685,3 +693,4 @@ int ck_x86_tg3_drain(unsigned ms)
}
return -1;
}
+#endif /* CK_X86_REPORT */
diff --git a/native/kernel/x86/x86.h b/native/kernel/x86/x86.h
index d2e2f7f5 ..04d85288 100644
--- a/native/kernel/x86/x86.h
+++ b/native/kernel/x86/x86.h
@@ -83,7 +83,7 @@ int ck_x86_console_fb_on(volatile void *base, uint32_t width, uint32_t height, u
uint32_t format, uint32_t *scale, uint32_t *cols, uint32_t *rows);
/* console_x86.c: the RAM copy of everything written so far (the first
- * 16 KiB), for the network report. */
+ * 16 KiB); in the lab image, the input the network report filters. */
const char *ck_x86_console_log(size_t *len);
/* pci_x86.c: PCI walk over the MCFG ECAM window; every AHCI and NVMe disk
@@ -109,11 +109,16 @@ int ck_x86_tg3_start(volatile uint8_t *regs, volatile uint8_t *cfg, struct ck_fr
int ck_x86_tg3_ready(void);
int ck_x86_tg3_link(void);
void ck_x86_tg3_mac(uint8_t mac[6]);
+#if defined(CK_X86_REPORT) && CK_X86_REPORT
+/* Lab image only (make imac-kernel CK_X86_REPORT=1); absent from the default
+ * and any resident or service build. */
int ck_x86_tg3_send(const uint8_t *frame, size_t len);
int ck_x86_tg3_drain(unsigned ms);
-/* report_x86.c: holds `seconds`, sending the console's RAM copy over the
- * network every 2 s while the link is up; returns the rounds sent. */
+/* report_x86.c (lab only): holds `seconds`, sending the allowlisted console
+ * lines as unauthenticated UDP broadcasts every 2 s while the link is up;
+ * returns the rounds sent. */
unsigned ck_x86_report_hold(uint64_t tsc_hz, unsigned seconds);
+#endif
/* smp_x86.S: the secondary-core trampoline, copied below 1 MiB and patched. */
extern char ck_x86_tramp_start[], ck_x86_tramp_end[], ck_x86_tramp_gdt[], ck_x86_tramp_pm32[],
diff --git a/native/m5/.crumb b/native/m5/.crumb
index af341836 ..cdb70750 100644
--- a/native/m5/.crumb
+++ b/native/m5/.crumb
@@ -14,31 +14,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "14c3d97cc49d279cf57a819bf7aa2c75c8bcd3d0071b302f352ae6ddda74f2b6 ",
- "last_commit": "1feaca1 ",
- "name": "tests",
- "purpose": "Directory native/m5/tests. Purpose not yet described by a human."
- },
- {
- "digest": "0cfa96047a78c70ea597daf37fb756f310424080491969f3e38802e71b60c994 ",
- "last_commit": "ec6ebd6 ",
- "name": "tools",
- "purpose": "Directory native/m5/tools. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:b461ac42b9135cc73e941d0acb46347321f14ed28765e041f00445bdbff7ab54 ",
- "compiled_at": "2026-10-14T14:58:51Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:a805df7e3af4b8a2ef345223523b54e7e47565204ec8f8e598f6dcaf53b07419 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 13,
- "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84 ",
- "source_tree": "sha256:d9e34890925e31f604e9c876f5ceff76db9fdd9adc26361800c542cc0b009994 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/m5/tests/.crumb b/native/m5/tests/.crumb
index 04c68ca8 ..4b173e22 100644
--- a/native/m5/tests/.crumb
+++ b/native/m5/tests/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-12T05:32:10Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:14c3d97cc49d279cf57a819bf7aa2c75c8bcd3d0071b302f352ae6ddda74f2b6 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 3,
- "generated_at_commit": "a9d120b2e91893bb80a378dc746cf0a274e42878 ",
- "source_tree": "sha256:ca5032aab793b251b45c2292dff134fe9ef7e98f55bbd01480984375ef9f9559 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/m5/tools/.crumb b/native/m5/tools/.crumb
index c760da44 ..3f2c1dfd 100644
--- a/native/m5/tools/.crumb
+++ b/native/m5/tools/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:0cfa96047a78c70ea597daf37fb756f310424080491969f3e38802e71b60c994 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 1,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:2754374819d074c008f340b81ac691059f1eff0dbc229676116c962234443cd4 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/net/.crumb b/native/net/.crumb
index d4dbb083 ..e5109165 100644
--- a/native/net/.crumb
+++ b/native/net/.crumb
@@ -14,31 +14,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "bcfb85b12af64194fd5008d1083ea51394f327d16d46fd3849c4f3a022fcd2b6 ",
- "last_commit": "d75a266 ",
- "name": "receipts",
- "purpose": "Directory native/net/receipts. Purpose not yet described by a human."
- },
- {
- "digest": "fd139e90ca41167b0025352fafdca0d2c9c869c6e13bab72c04d30b5776ddd93 ",
- "last_commit": "4a116e5 ",
- "name": "tests",
- "purpose": "Directory native/net/tests. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:72c6a05fd3be86ab3a6985c3b1d9ed75262d875773aff4440ec13869435108cc ",
- "compiled_at": "2026-10-14T14:58:51Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:ff5c88f5e9bf86e7ff836d24c048dd2d4efc94f6f19a21a0caf72ae9c402deaf ",
- "evidence_files": 4,
- "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335 ",
- "files": 29,
- "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84 ",
- "source_tree": "sha256:f44c1b908aa86c0360aa8d0f01723a1deae07cdecc40354390204e2ee456834d "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/net/receipts/.crumb b/native/net/receipts/.crumb
index ec46afc7 ..64dc4c9e 100644
--- a/native/net/receipts/.crumb
+++ b/native/net/receipts/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:bcfb85b12af64194fd5008d1083ea51394f327d16d46fd3849c4f3a022fcd2b6 ",
- "evidence_files": 4,
- "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335 ",
- "files": 4,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:83d8443faeee245aee7da7d46384221218e100a4f75823c55c46bdaf40914086 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/net/tests/.crumb b/native/net/tests/.crumb
index b467f111 ..b6b7daf1 100644
--- a/native/net/tests/.crumb
+++ b/native/net/tests/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "dee52184bb1879d3bbb1b3db0cb6b8aa9cce4fc524e3aa18e1ba93da79802f5f ",
- "last_commit": "d75a266 ",
- "name": "fixtures",
- "purpose": "Directory native/net/tests/fixtures. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:eefad7996e552393c5e8e30abc9d90b9ec8f10e51bef5b788e6131b1c76c0907 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:fd139e90ca41167b0025352fafdca0d2c9c869c6e13bab72c04d30b5776ddd93 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 9,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:60565b9b1b0f84a1b034f20a7529336725a73f81a4b494da142265d8b2da8c19 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/net/tests/fixtures/.crumb b/native/net/tests/fixtures/.crumb
index 71ab7879 ..25ab1177 100644
--- a/native/net/tests/fixtures/.crumb
+++ b/native/net/tests/fixtures/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:dee52184bb1879d3bbb1b3db0cb6b8aa9cce4fc524e3aa18e1ba93da79802f5f ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 3,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:f0f0eac73e6e1d46bdba6992cc6bcd18226fff511be129ceb01a0aac34334aad "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/sig/.crumb b/native/sig/.crumb
index 983b3a0d ..8fb90f5c 100644
--- a/native/sig/.crumb
+++ b/native/sig/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "33dc4e9fb2d9d884bb3ae8b384327e07d1c4d6871a536b42317da9882e666ffb ",
- "last_commit": "cea54be ",
- "name": "tests",
- "purpose": "Directory native/sig/tests. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:2c318acd4ff46092a89eec7b6b1f764bdc91bb6428427fffa9b04f05753be9fd ",
- "compiled_at": "2026-10-14T14:58:51Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:135fd1edbe2388764de7dc755611b483b0c61adab858718c390b7745d141635c ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 10,
- "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84 ",
- "source_tree": "sha256:e0f0c7871cebb725ef0fbe9a56e1e0ca558690712174e9f2d8eab5fc2b848ce2 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/sig/tests/.crumb b/native/sig/tests/.crumb
index 05ddc644 ..339563d2 100644
--- a/native/sig/tests/.crumb
+++ b/native/sig/tests/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-04T13:47:18Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:33dc4e9fb2d9d884bb3ae8b384327e07d1c4d6871a536b42317da9882e666ffb ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 2,
- "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512 ",
- "source_tree": "sha256:1fc98112613acef8760f9e485b6cb47a33081a4265c370ddf29bea83ccac1cf0 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/store/.crumb b/native/store/.crumb
index 0d3ecf9a ..02df507d 100644
--- a/native/store/.crumb
+++ b/native/store/.crumb
@@ -10,25 +10,6 @@
}
],
"extensions": {
- "generated": {
- "children": [
- {
- "digest": "2d3d3126d372770e8db78cfd308c5912d55104a6b8761ea21190679f9d37c9f1 ",
- "last_commit": "22eb360 ",
- "name": "tests",
- "purpose": "Directory native/store/tests. Purpose not yet described by a human."
- }
- ],
- "children_root": "sha256:63c601409e5cfba3ed2b46512984506078778d1d861501e8f4604e9277027df8 ",
- "compiled_at": "2026-10-14T20:37:20Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:f75197d76b7daaeee8223cf25353251824cd4497400a439724a3a424e014a229 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 22,
- "generated_at_commit": "7db773a8c3e041d4415c3c37240b26235c81b7a7 ",
- "source_tree": "sha256:9cc41dbe9d2dc974564886203d0e1ff8f418eeea4dddde0f6cd1c57a698b65cb "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/native/store/tests/.crumb b/native/store/tests/.crumb
index 8a71b8d5 ..9cec5264 100644
--- a/native/store/tests/.crumb
+++ b/native/store/tests/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-14T20:37:20Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:2d3d3126d372770e8db78cfd308c5912d55104a6b8761ea21190679f9d37c9f1 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 10,
- "generated_at_commit": "7db773a8c3e041d4415c3c37240b26235c81b7a7 ",
- "source_tree": "sha256:4a4feaaf5e38a6686d18f88aa72b5cf31245c24d51daac422dafa2302f428340 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/scripts/.crumb b/scripts/.crumb
index 610b7ddd ..587c6b02 100644
--- a/scripts/.crumb
+++ b/scripts/.crumb
@@ -4,18 +4,6 @@
"path": ".."
},
"extensions": {
- "generated": {
- "children": [],
- "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-19T15:08:12Z",
- "compiler": "crumb-compile/1",
- "digest": "sha256:28cf2363c4d527a9d7ecc2974f3dcda3e065959cbddaed7863d9c9354f166967 ",
- "evidence_files": 0,
- "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 119,
- "generated_at_commit": "00d77597386501631f08ac78ea5c0c3a0795348f ",
- "source_tree": "sha256:be5e87b53a3b65b5663691620e616c5490a3a866f959349e7b608ead2a5ffcf6 "
- },
"owner_lane": "",
"provenance": {
"entries": [
diff --git a/scripts/ck_gates.sh b/scripts/ck_gates.sh
index 7ef86853 ..b3fd32c4 100755
--- a/scripts/ck_gates.sh
+++ b/scripts/ck_gates.sh
@@ -227,6 +227,12 @@ run_children() {
child_log_sha[${c}]="$(sha_of <"${log}")"
child_lines[${c}]="$(wc -l <"${log}")"
echo "--- [${c}] exit ${child_rc[${c}]} after ${child_secs[${c}]} s" >&2
+ # A failing child's own FAIL lines go to stderr (the evidence blob), so a red gate can be read
+ # without rerunning it: the child log itself lives in a temp folder that is removed at exit.
+ if [[ "${child_rc[${c}]}" != 0 ]]; then
+ { grep -aE '^(FAIL|ALLEN: |CONTINUITY: )' "${log}" | tail -n 40 | sed "s/^/ [${c}] /" >&2; } || true
+ { tail -n 5 "${log}" | sed "s/^/ [${c}] tail: /" >&2; } || true
+ fi
done
}
diff --git a/scripts/ck_imac_report_test.sh b/scripts/ck_imac_report_test.sh
index 03aa0b17 ..eae8a7c5 100755
--- a/scripts/ck_imac_report_test.sh
+++ b/scripts/ck_imac_report_test.sh
@@ -1,10 +1,19 @@
#!/bin/sh
-# ck_imac_report_test.sh -- host test of the iMac kernel's network report:
-# the frames x86/report_x86.c builds (Ethernet broadcast, IPv4, UDP with a
-# checksum, part headers) and the receiver tools/ck_imac_report_listen.c,
-# which must rebuild the report byte for byte from parts sent out of order
-# and repeated. Hosted only; the BCM57766 itself cannot be emulated.
-# Ends with "AIENOS_IMAC_REPORT: PASS" or "AIENOS_IMAC_REPORT: FAIL <why>".
+# ck_imac_report_test.sh -- test of the iMac kernel's LAB-ONLY network report.
+# 1. Build check: the default image (make imac-kernel) links no report code
+# and no frame transmit; the opt-in lab image (CK_X86_REPORT=1) has them.
+# 2. Host checks of x86/report_x86.c: the allowlist filter (sentinel chat,
+# key, token and memory lines, control bytes and over-long lines never
+# reach the exported copy or a frame; allowed lines survive byte for
+# byte) and the frames (Ethernet broadcast, IPv4, UDP with a checksum,
+# "v=2 auth=none" part headers).
+# 3. The receiver tools/ck_imac_report_listen.c rebuilds the report byte for
+# byte from parts sent out of order and repeated, labels it
+# unauthenticated, and refuses the retired v=1 raw-console format.
+# Hosted only; the BCM57766 itself cannot be emulated, and nothing here
+# touches a real network interface (the round trip runs over 127.0.0.1).
+# Ends with "AIENOS_IMAC_REPORT: PASS", "AIENOS_IMAC_REPORT: FAIL <why>" or
+# "AIENOS_IMAC_REPORT: NOT_RUN <why>" (no x86_64 toolchain for step 1).
set -u
cd "$(dirname "$0")/.."
K=native/kernel
@@ -14,26 +23,55 @@ LP=
fail() { echo "AIENOS_IMAC_REPORT: FAIL $*"; exit 1; }
CC=${HOSTCC:-cc}
CF="-std=gnu11 -O2 -Wall -Wextra -Werror"
+
+# 1. Build check, into a scratch output directory.
+X=""
+[ "$(uname -m)" = x86_64 ] || X="x86_64-linux-gnu-"
+for t in "${X}gcc" "${X}ld" "${X}nm"; do
+ command -v "$t" >/dev/null || { echo "AIENOS_IMAC_REPORT: NOT_RUN ($t missing)"; exit 2; }
+done
+SYMS='ck_x86_report_(hold|frame|filter|parts)|ck_x86_tg3_(send|drain)|net_udp_build'
+make -s -C $K X86_CROSS="$X" OUT="$W/build" imac-kernel >"$W/build.log" 2>&1 ||
+ fail "default imac-kernel build: $(tail -3 "$W/build.log")"
+make -s -C $K X86_CROSS="$X" OUT="$W/build" CK_X86_REPORT=1 imac-kernel >>"$W/build.log" 2>&1 ||
+ fail "lab imac-kernel build: $(tail -3 "$W/build.log")"
+d=$("${X}nm" "$W/build/imackern/imackern.elf" | grep -E " ($SYMS)\$" || true)
+[ -z "$d" ] || fail "default image has report symbols: $(echo $d)"
+grep -aq "AIENOS-IMAC-REPORT" "$W/build/IMACKERN.EFI" && fail "default image carries the report header"
+l=$("${X}nm" "$W/build/imackern-lab/imackern.elf" | grep -cE " ($SYMS)\$" || true)
+[ "$l" = 7 ] || fail "lab image has $l of 7 report symbols"
+grep -aq "AIENOS-IMAC-REPORT v=2 auth=none " "$W/build/IMACKERN-LAB.EFI" || fail "lab image lacks the v=2 auth=none header"
+echo "build: default image report_symbols=0, lab image report_symbols=7"
+
+# 2. Host checks of the filter and frames.
$CC $CF -o "$W/listen" $K/tools/ck_imac_report_listen.c || fail "listener does not build"
$CC $CF -DCK_X86_REPORT_HOST -I$K/x86 -I$K/tests -Inative/net -o "$W/test" \
$K/tests/test_imac_report.c $K/x86/report_x86.c native/net/aienos_net.c || fail "test does not build"
-"$W/test" || fail "frame checks"
+"$W/test" || fail "filter and frame checks"
+
+# 3. Listener round trip over loopback.
PORT=$((47100 + $$ % 800))
mkdir -p "$W/out"
-"$W/listen" $PORT "$W/out" 20 &
+"$W/listen" $PORT "$W/out" 20 2>/dev/null &
LP=$!
i=0
until grep -q "^ready port=$PORT" "$W/out/listen.log" 2>/dev/null; do
i=$((i + 1)); [ $i -gt 50 ] && fail "listener not ready: $(cat "$W/out/listen.log" 2>/dev/null)"
sleep 0.1
done
+grep -q '^note: iMac reports are UNAUTHENTICATED UDP broadcasts (auth=none)' "$W/out/listen.log" ||
+ fail "listener does not label reports unauthenticated"
+"$W/test" legacy $PORT >/dev/null || fail "legacy send"
"$W/test" send $PORT "$W/sent.txt" >/dev/null || fail "send"
i=0
-until grep -q "^complete run=0123456789abcdef " "$W/out/listen.log"; do
+until grep -q "^complete run=0123456789abcdef auth=none " "$W/out/listen.log"; do
i=$((i + 1)); [ $i -gt 50 ] && fail "report not completed: $(cat "$W/out/listen.log")"
sleep 0.1
done
-cmp -s "$W/sent.txt" "$W/out/imac-0123456789abcdef .txt" || fail "rebuilt report differs"
+cmp -s "$W/sent.txt" "$W/out/imac-0123456789abcdef .unauthenticated.txt" || fail "rebuilt report differs"
[ "$(grep -c '^complete ' "$W/out/listen.log")" = 1 ] || fail "report written more than once"
-grep -q '^ignored' "$W/out/listen.log" && fail "listener ignored a valid part"
+[ "$(grep -c '^ignored .*retired v=1 raw-console report$' "$W/out/listen.log")" = 1 ] ||
+ fail "listener did not refuse the v=1 datagram"
+ls "$W/out" | grep -q '00000000000000ff ' && fail "listener wrote the v=1 datagram"
+grep '^ignored' "$W/out/listen.log" | grep -vq 'retired v=1' && fail "listener ignored a valid part"
echo "AIENOS_IMAC_REPORT: PASS"
diff --git a/scripts/qemu_artifact_test.sh b/scripts/qemu_artifact_test.sh
index 6d0786c1 ..530c14ef 100755
--- a/scripts/qemu_artifact_test.sh
+++ b/scripts/qemu_artifact_test.sh
@@ -105,7 +105,7 @@ fi
# Test-only signing: debug build by design (release refuses the feature).
cargo build --quiet -p aienos-artifact-tool --features seed0b-test-signing
-tool="target/debug/aienos-artifact-tool"
+tool="${CARGO_TARGET_DIR:-target}/debug/aienos-artifact-tool"
esp_art="${work}/esp/EFI/AIENOS/ARTIFACTS"
mkdir -p "${work}/esp/EFI/BOOT" "${esp_art}"
"${fixtures}/pack.sh" "${tool}" "${esp_art}"
@@ -195,7 +195,7 @@ commit="$(git rev-parse HEAD 2>/dev/null || echo unknown)"
build_image() { # features, output
AIENOS_COMMIT="${commit}" AIENOS_RESTART_SECS=1 cargo build --quiet --release \
-p aienos-boot --target aarch64-unknown-uefi --features "$1" --bin aienos-handoff
- cp target/aarch64-unknown-uefi/release/aienos-handoff.efi "$2"
+ cp "${CARGO_TARGET_DIR:-target}"/aarch64-unknown-uefi/release/aienos-handoff.efi "$2"
}
if [[ -z "${captured}" ]]; then
build_image seed0b-qualification "${work}/qualification.efi"
diff --git a/scripts/qemu_boot_test.sh b/scripts/qemu_boot_test.sh
index 0157d807 ..9b65edbd 100755
--- a/scripts/qemu_boot_test.sh
+++ b/scripts/qemu_boot_test.sh
@@ -23,7 +23,7 @@ work="$(mktemp -d)"
trap 'rm -rf "${work}"' EXIT
mkdir -p "${work}/esp/EFI/BOOT" "${work}/esp/EFI/AIENOS"
touch "${work}/esp/EFI/AIENOS/BOOTREPORT.TXT"
-cp target/aarch64-unknown-uefi/release/aienos-handoff.efi "${work}/esp/EFI/BOOT/BOOTAA64.EFI"
+cp "${CARGO_TARGET_DIR:-target}"/aarch64-unknown-uefi/release/aienos-handoff.efi "${work}/esp/EFI/BOOT/BOOTAA64.EFI"
cp "${vars_fd}" "${work}/vars.fd"
log="${work}/serial.log"
diff --git a/scripts/qemu_ck_imac_kernel_test.sh b/scripts/qemu_ck_imac_kernel_test.sh
index 701b4331 ..d4998fc8 100755
--- a/scripts/qemu_ck_imac_kernel_test.sh
+++ b/scripts/qemu_ck_imac_kernel_test.sh
@@ -13,7 +13,11 @@
# writing (the ESP, and a data disk with a GPT whose AIENOS partition the kernel
# must locate where ck_gpt_image wrote it; the data disk must be byte-identical
# afterwards), print "kernel: alive", hold the screen and power QEMU off through
-# ACPI S5 by itself.
+# ACPI S5 by itself. W^X (#409): each run must show writes to code and read-only
+# data and execution from heap and stack faulting with the right #PF error code,
+# and an audit of every page table leaf (only the code executable, nothing
+# writable and executable, NXE and WP on every core). Two TEST-ONLY mutant builds
+# (IMACKERN_WX_MUTANT=no_nx, =text_writable) must make those probes panic.
# The kernel's report reaches the serial log through COM1, which QEMU has and the
# iMac does not. Needs qemu-system-x86_64, OVMF, mtools and an x86_64 gcc. Final line:
# AIENOS_IMAC_KERNEL: PASS|FAIL|NOT_RUN [(...)] exit 0 / 1 / 2 (tools) / 3 (NOT_RUN)
@@ -118,6 +122,9 @@ run() { # name, -cpu model, expected APIC mode
chk "${name}: one-line summary" "${txt}" "^summary: cores=4/4 timer=ok sata_disks=2 nvme_disks=1 gpt_valid=2 writes=none net=none\$"
[[ "$(sha256sum "${nvm}" | cut -d" " -f1)" == "${nvm_sum}" ]] && echo "PASS ${name}: NVMe disk unchanged" || { echo "FAIL ${name}: NVMe disk changed"; fails=$((fails + 1)); }
[[ "$(sha256sum "${data}" | cut -d" " -f1)" == "${data_sum}" ]] && echo "PASS ${name}: data disk unchanged" || { echo "FAIL ${name}: data disk changed"; fails=$((fails + 1)); }
+ chk "${name}: W^X probes fault" "${txt}" '^wx: ok nx=on wp=on text_write=fault ro_write=fault heap_exec=fault stack_exec=fault$'
+ chk "${name}: W^X audit, only code executable, every core" "${txt}" '^wx_audit: ok wx_pages=0 exec_pages=([1-9][0-9]*) text_pages=\1 exec_outside_text=0 ro_writable=0 cores_nx_wp=4/4 trampoline=retired$'
+ if grep -aq '^wx: TEST-ONLY' "${txt}"; then echo "FAIL ${name}: default image is a W^X mutant"; fails=$((fails + 1)); fi
chk "${name}: kernel alive" "${txt}" '^kernel: alive$'
chk "${name}: DONE" "${txt}" '^AIENOS-IMAC-KERNEL-0 DONE$'
chk "${name}: ACPI S5 power off" "${txt}" '^power: off via ACPI S5 pm1a=0x[0-9a-f]+ '
@@ -126,10 +133,50 @@ run() { # name, -cpu model, expected APIC mode
else
echo "PASS ${name}: no panic"
fi
+ # The default image carries no network report (lab-only, CK_X86_REPORT=1).
+ if grep -aqE '^report: ' "${txt}"; then
+ echo "FAIL ${name}: default image ran the lab-only network report"; fails=$((fails + 1))
+ else
+ echo "PASS ${name}: no network report in the default image"
+ fi
[[ ${self_exit} == 1 ]] && echo "PASS ${name}: QEMU powered off by itself" || { echo "FAIL ${name}: QEMU still running"; fails=$((fails + 1)); }
echo "---- ${name} serial ----"; cat "${txt}"; echo "----"
}
run max max xapic
run qemu64 qemu64 xapic
+# W^X negative controls: the probes run before the clock is measured, so a mutant's
+# panic halts instead of powering off; wait for the panic line, then stop QEMU.
+mutant() { # IMACKERN_WX_MUTANT value, expected panic pattern
+ local m="$1" mo="${out}-wx-$1" mi="${work}/wx-$1.img" log="${work}/wx-$1.log" hit=0
+ make -s -C native/kernel X86_CROSS="${cross}" OUT="${mo}" AIENOS_COMMIT="${commit}" IMACKERN_WX_MUTANT="${m}" imac-kernel >/dev/null
+ truncate -s 64M "${mi}"
+ mformat -i "${mi}" -F ::
+ mmd -i "${mi}" ::/EFI ::/EFI/BOOT
+ mcopy -i "${mi}" "${mo}/IMACKERN.EFI" ::/EFI/BOOT/BOOTX64.EFI
+ cp "${vars_fd}" "${work}/vars.fd"
+ qemu-system-x86_64 -M q35 -accel tcg -cpu max -smp 1 -m 1024 \
+ -drive if=pflash,format=raw,readonly=on,file="${code_fd}" \
+ -drive if=pflash,format=raw,file="${work}/vars.fd" \
+ -drive if=none,id=esp,format=raw,file="${mi}" -device ide-hd,drive=esp,bus=ide.0 \
+ -display none -nic none -serial file:"${log}" -no-reboot &
+ qpid=$!
+ for _ in $(seq 1 "${AIENOS_IMAC_KERNEL_WAIT:-300}"); do
+ if tr -d '\r' <"${log}" 2>/dev/null | grep -aqE -- "$2"; then hit=1; break; fi
+ kill -0 "${qpid}" 2>/dev/null || break
+ sleep 1
+ done
+ kill "${qpid}" 2>/dev/null || true
+ wait "${qpid}" 2>/dev/null || true
+ qpid=""
+ if [[ ${hit} == 1 ]] && tr -d '\r' <"${log}" | grep -aq '^wx: TEST-ONLY W^X mutant build'; then
+ echo "PASS mutant ${m}: W^X probes catch it"
+ tr -d '\r' <"${log}" | grep -a '^panic: wx'
+ else
+ echo "FAIL mutant ${m}: no match for: $2"; fails=$((fails + 1))
+ tr -d '\r' <"${log}" | tail -20
+ fi
+}
+mutant no_nx '^panic: wx: FAIL nx=on wp=on text_write=fault ro_write=fault heap_exec=ALLOWED stack_exec=ALLOWED$'
+mutant text_writable '^panic: wx: FAIL nx=on wp=on text_write=ALLOWED ro_write=fault heap_exec=fault stack_exec=fault$'
if [[ ${fails} == 0 ]]; then echo "${tag}: PASS"; exit 0; fi
echo "${tag}: FAIL (${fails} checks)"; exit 1
diff --git a/scripts/qemu_ck_osc_receipt_test.sh b/scripts/qemu_ck_osc_receipt_test.sh
index 19f50954 ..51934982 100755
--- a/scripts/qemu_ck_osc_receipt_test.sh
+++ b/scripts/qemu_ck_osc_receipt_test.sh
@@ -121,7 +121,7 @@ for rf in "${files[@]:1}"; do
check "${serial}" "${r}.rcpt stored from the Store (bytes=${b})" "^osc_receipt: ${r//./\\.}\\.rcpt STORED bytes=${b} id=${id} "
done
check "${serial}" "receipt totals: 14 seen, 14 stored" "^osc_receipts: seen=14 stored=14 dropped=0 "
-check "${serial}" "self-test announces 18 launches" "^osc_rcpt_selftest: launches=18 unit=a01_valid_min\\.unit; "
+check "${serial}" "self-test announces 19 launches" "^osc_rcpt_selftest: launches=19 unit=a01_valid_min\\.unit; "
label='QEMU \(aarch64 virt\), TEST signer, not physical'
a=a01_valid_min.unit
@@ -152,11 +152,12 @@ rline "receipt naming firmware: RECEIPT_WRONG_FIRMWARE (81)" '14,15' n_firmware.
rline "receipt with a dependency: RECEIPT_DEPENDENCIES_MISMATCH (88)" '15,16' n_deps.rcpt qualification "$(ref 88 DEPENDENCIES_MISMATCH)" -
rline "receipt from an unlisted checker: RECEIPT_UNTRUSTED_CHECKER (86)" '16,17' n_checker.rcpt qualification "$(ref 86 UNTRUSTED_CHECKER)" -
rline "owner receipt (signed on the owner YubiKey) in release mode: the unit runs, add(17,18) RETURNED 35" '17,18' a01.owner.rcpt release 'RETURNED value=35' - run
+rline "valid receipt with code changed after admission: CODE_HASH_MISMATCH (16), nothing mapped or executed" '18,19' a01.rcpt qualification 'REFUSED_AT_ADMISSION code=16 name=CODE_HASH_MISMATCH' -
rline "after every refusal, the valid receipt still runs the unit: add(20,22) RETURNED 42" '20,22' a01.rcpt qualification 'RETURNED value=42' - run
-check "${serial}" "summary: 3 returned, 15 refused" "^osc_rcpt_launches: returned=3 trapped=0 refused=15 unknown=0; ${label}\$"
+check "${serial}" "summary: 3 returned, 16 refused" "^osc_rcpt_launches: returned=3 trapped=0 refused=16 unknown=0; ${label}\$"
nl=$(grep -c '^osc_rcpt_launch: ' "${serial}" || true)
names=$(grep -oE '^osc_rcpt_launch: .* name=RECEIPT_[A-Z_]+' "${serial}" | sed -E 's/.*name=//' | sort | uniq -d | tr '\n' ' ')
-[[ "${nl}" == 18 ]] && pass "exactly 18 receipt launch lines" || fail "receipt launch lines (${nl} of 18)"
+[[ "${nl}" == 19 ]] && pass "exactly 19 receipt launch lines" || fail "receipt launch lines (${nl} of 19)"
# REVOKED appears twice on purpose (receipt id, signer key), told apart by the revoked= column
[[ "${names}" == "RECEIPT_REVOKED " ]] && pass "every other refusal names a reason of its own" || fail "refusal reasons repeated: ${names}"
if grep -E '^osc_launch: ' "${serial}" | grep -q .; then fail "a C3-3a launch line appeared in the receipt self-test"; else pass "only the receipt self-test ran"; fi
diff --git a/scripts/qemu_ck_pipe_test.sh b/scripts/qemu_ck_pipe_test.sh
new file mode 100755
index 00000000 ..17f3cb1e
--- /dev/null
+++ b/scripts/qemu_ck_pipe_test.sh
@@ -0,0 +1,108 @@
+#!/usr/bin/env bash
+# AIENOS_CK_PIPE gate (AIENOS-NATIVE-PIPE-1, aienos-mv#428): the native pipe primitive (native/kernel/core/pipe.c) driven
+# from inside the C kernel. A TEST-ONLY image (make CK_PIPE_TEST=1, refused with CK_HARDWARE_STAGING) runs
+# core/pipe_test.c after "kernel: alive": a producer and a consumer task, step functions interleaved by the kernel's
+# run-queue scheduler, each holding one pipe end in its own capability table, then the negative cases. The boot then
+# goes on as usual to its report and PSCI reset.
+#
+# Label: QEMU (aarch64 virt), TEST build, not physical. Nothing here ran on a Spark or any real machine; a PASS
+# qualifies nothing physical.
+# Checks (one boot):
+# payload_nul_byte_for_byte 160 KiB with every fifth byte NUL arrives byte for byte, no temporary file
+# backpressure_would_block a slow consumer fills the 64 KiB pipe; the producer sees WOULD_BLOCK
+# eof_after_last_writer the consumer reads EOF (0 bytes, OK) after the producer closes
+# bounded_memory never more than the pipe capacity buffered
+# blocking_wait_wake_through_scheduler the blocking variant parks and is woken through the scheduler
+# broken_pipe_no_reader write with no reader -> BROKEN_PIPE, no bytes
+# revoked_write_refused_no_bytes_after write after revoke -> REVOKED, nothing delivered after it
+# revoke_midstream_no_data_after the consumer revokes mid-transfer; no read succeeds afterwards
+# stale_handle_after_close a closed handle stays STALE after its slot is reused
+# unknown_op_not_supported unknown op / other ABI version -> NOT_SUPPORTED before any effect
+# cancel_interrupts_once cancel -> INTERRUPTED once with no byte moved
+# every check: both capability tables and the pipe pool empty afterwards (tables_empty=1).
+# Last line: AIENOS_CK_PIPE: PASS|FAIL|NOT_RUN.
+set -euo pipefail
+
+repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+cd "${repo_root}"
+verdict=AIENOS_CK_PIPE
+code_fd="${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}"
+vars_fd="${AAVMF_VARS:-/usr/share/AAVMF/AAVMF_VARS.fd}"
+command -v qemu-system-aarch64 >/dev/null || { echo "qemu-system-aarch64 not installed"; echo "${verdict}: NOT_RUN"; exit 2; }
+[[ -r "${code_fd}" && -r "${vars_fd}" ]] || { echo "AAVMF firmware not found"; echo "${verdict}: NOT_RUN"; exit 2; }
+
+cross=""
+if [ "$(uname -m)" != "aarch64" ]; then cross="aarch64-linux-gnu-"; fi
+commit="$(git rev-parse HEAD 2>/dev/null || echo unknown)"
+out="${AIENOS_CK_OUT_PIPE:-${repo_root}/target/native-kernel-test-pipe}"
+make -s -C native/kernel CROSS="${cross}" OUT="${out}" AIENOS_COMMIT="${commit}" CK_PIPE_TEST=1 >/dev/null
+
+# Machine quiet flag (read only) and the QEMU gate lock (one gate at a time):
+# scripts/lib_gate_hold.sh (aienos#278).
+. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib_gate_hold.sh"
+if ! gh_quiet_check || ! gh_lock_take qemu_ck_pipe_test "${AIENOS_GATE_MINUTES:-60}"; then
+ echo "NOT_RUN ${gh_why}"
+ echo "${verdict}: NOT_RUN"
+ exit 3
+fi
+# Release only this run's own gate lock record, at most once.
+release_flag() { gh_lock_release; }
+work="$(mktemp -d)"
+cleanup() { rm -rf "${work}"; release_flag; }
+trap cleanup EXIT
+mkdir -p "${work}/esp/EFI/BOOT" "${work}/esp/EFI/AIENOS"
+touch "${work}/esp/EFI/AIENOS/BOOTREPORT.TXT"
+cp "${out}/BOOTAA64.EFI" "${work}/esp/EFI/BOOT/BOOTAA64.EFI"
+cp "${vars_fd}" "${work}/vars.fd"
+log="${work}/serial.log"
+
+started=$(date +%s)
+set +e
+timeout "${AIENOS_QEMU_TIMEOUT:-300}" qemu-system-aarch64 \
+ -M virt,virtualization=on,gic-version=3 -accel tcg,thread=single -cpu max -smp 4 -m 2048 \
+ -drive if=pflash,format=raw,readonly=on,file="${code_fd}" \
+ -drive if=pflash,format=raw,file="${work}/vars.fd" \
+ -drive if=none,id=esp,format=raw,file=fat:rw:"${work}/esp" \
+ -device virtio-blk-pci,drive=esp \
+ -device ramfb -display none -nic none \
+ -serial file:"${log}" -no-reboot
+qemu_status=$?
+set -e
+elapsed=$(( $(date +%s) - started ))
+release_flag
+
+serial="${work}/serial.txt"
+tr -d '\r' <"${log}" >"${serial}"
+[[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${serial}" "${AIENOS_LOG_DIR}/qemu_ck_pipe_serial.log"
+failed=0
+pass() { echo "PASS $1"; }
+fail() { echo "FAIL $1"; failed=1; }
+has() { grep -qE -- "$2" "$1"; }
+check() { if has "${serial}" "$2"; then pass "$1"; else fail "$1"; fi; }
+echo "qemu exit ${qemu_status} after ${elapsed} s (commit ${commit:0:12})"
+[[ "${qemu_status}" == 0 ]] && pass "QEMU exit status 0 (PSCI reset)" || fail "QEMU exit status ${qemu_status} (124 = timeout)"
+
+label='QEMU \(aarch64 virt\), TEST build, not physical'
+check "left firmware and entered the kernel" "kernel: alive"
+check "the image announces the TEST-ONLY pipe self-test" "^pipe_test: TEST-ONLY pipe self-test begin abi_version=1 capacity=65536 pool_pipes=4 payload=163840; ${label}\$"
+for c in payload_nul_byte_for_byte backpressure_would_block eof_after_last_writer bounded_memory \
+ blocking_wait_wake_through_scheduler broken_pipe_no_reader revoked_write_refused_no_bytes_after \
+ revoke_midstream_no_data_after stale_handle_after_close unknown_op_not_supported cancel_interrupts_once; do
+ check "${c}" "^pipe_check: name=${c} result=PASS tables_empty=1; ${label}\$"
+done
+check "payload detail: all 163840 bytes, NUL bytes counted, zero mismatches" "^pipe_detail: nonblocking bytes=163840 sent=163840 nul=[1-9][0-9]* expected_nul=[1-9][0-9]* mismatches=0 would_block=[1-9]"
+check "blocking detail: waits and wakeups observed" "^pipe_detail: blocking bytes=163840 .* waits=[1-9][0-9]* wakeups=[1-9]"
+check "revoked write refused, zero bytes delivered" "^pipe_detail: revoked write=REVOKED n=0 read=REVOKED n=0 bytes_delivered=0\$"
+check "broken pipe detail" "^pipe_detail: broken_pipe write_after_reader_close=BROKEN_PIPE n=0\$"
+check "self-test summary: 11 checks, 0 failed" "^pipe_test: done checks=11 failed=0 capacity=65536 pool_pipes=4; ${label}\$"
+if has "${serial}" "^pipe_check: .* result=FAIL"; then fail "no pipe check failed"; else pass "no pipe check failed"; fi
+check "the boot went on to its report" "report_kind: final"
+if has "${serial}" "report_kind: (panic|fault)"; then fail "panic or fault reported"; else pass "no kernel panic or fault report"; fi
+
+if [[ "${failed}" != 0 || -n "${AIENOS_QEMU_VERBOSE:-}" ]]; then
+ echo "---- serial console (pipe lines) ----"
+ grep -E "^(pipe_|kernel: alive|report_kind|panic)" "${serial}" || true
+fi
+[[ "${failed}" == 0 ]] && { echo "${verdict}: PASS"; exit 0; }
+echo "${verdict}: FAIL"
+exit 1
diff --git a/scripts/verify_all.sh b/scripts/verify_all.sh
index dec4c3a7 ..93f57f6c 100755
--- a/scripts/verify_all.sh
+++ b/scripts/verify_all.sh
@@ -105,9 +105,9 @@ echo "PASS AArch64 build: aienos-kernel for aarch64-unknown-none"
echo ""
echo "--- [AArch64 UEFI Image Builds] ---"
cargo build --release -p aienos-boot --target aarch64-unknown-uefi --features firmware --bin aienos-boot
-cargo run --quiet --release -p aienos-evidence -- verify-efi target/aarch64-unknown-uefi/release/aienos-boot.efi
+cargo run --quiet --release -p aienos-evidence -- verify-efi "${CARGO_TARGET_DIR:-target}"/aarch64-unknown-uefi/release/aienos-boot.efi
cargo build --release -p aienos-boot --target aarch64-unknown-uefi --features handoff --bin aienos-handoff
-cargo run --quiet --release -p aienos-evidence -- verify-efi target/aarch64-unknown-uefi/release/aienos-handoff.efi
+cargo run --quiet --release -p aienos-evidence -- verify-efi "${CARGO_TARGET_DIR:-target}"/aarch64-unknown-uefi/release/aienos-handoff.efi
echo "PASS AArch64 build: aienos-boot.efi and aienos-handoff.efi PE headers verified"
# Step 6: QEMU AArch64 UEFI Boot Verification (Emulator Boot Test)
diff --git a/tests/gates/aienos-ck-b7b-probe.gate b/tests/gates/aienos-ck-b7b-probe.gate
index c8ca7105 ..ba4908bc 100644
--- a/tests/gates/aienos-ck-b7b-probe.gate
+++ b/tests/gates/aienos-ck-b7b-probe.gate
@@ -16,6 +16,7 @@ inputs:
- crates/aienos-infer-kernel/
- tests/gates/
- scripts/
+ - native/
run:
exec: tests/gates/run.sh
args: ["ck-b7b-probe"]
diff --git a/tests/gates/aienos-ck-host-tests.gate b/tests/gates/aienos-ck-host-tests.gate
index b3f9cb0c ..b0ba45d0 100644
--- a/tests/gates/aienos-ck-host-tests.gate
+++ b/tests/gates/aienos-ck-host-tests.gate
@@ -15,6 +15,12 @@ inputs:
- crates/aienos-fpu-probe/
- crates/aienos-infer-kernel/
- tests/gates/
+ - native/
+ - scripts/native_package_test.sh
+ - scripts/native_package.sh
+ - crates/aienos-infer/
+ - Cargo.toml
+ - .cargo/
run:
exec: tests/gates/run.sh
args: ["ck-host-tests"]
diff --git a/tests/gates/aienos-ck-owner-keys.gate b/tests/gates/aienos-ck-owner-keys.gate
index d0cd33a5 ..9a9053a4 100644
--- a/tests/gates/aienos-ck-owner-keys.gate
+++ b/tests/gates/aienos-ck-owner-keys.gate
@@ -16,6 +16,7 @@ inputs:
- crates/aienos-infer-kernel/
- tests/gates/
- scripts/
+ - native/
run:
exec: tests/gates/run.sh
args: ["ck-owner-keys"]
diff --git a/tests/gates/aienos-ck-qemu-gates.gate b/tests/gates/aienos-ck-qemu-gates.gate
index 7ebbb030 ..a1e0a341 100644
--- a/tests/gates/aienos-ck-qemu-gates.gate
+++ b/tests/gates/aienos-ck-qemu-gates.gate
@@ -16,6 +16,12 @@ inputs:
- crates/aienos-infer-kernel/
- tests/gates/
- scripts/
+ - native/
+ - crates/
+ - Cargo.toml
+ - Cargo.lock
+ - .cargo/
+ - vendor/
run:
exec: tests/gates/run.sh
args: ["ck-qemu-gates"]
diff --git a/tests/gates/aienos-ck-stage-tests.gate b/tests/gates/aienos-ck-stage-tests.gate
index af76e173 ..f0c1e17a 100644
--- a/tests/gates/aienos-ck-stage-tests.gate
+++ b/tests/gates/aienos-ck-stage-tests.gate
@@ -15,6 +15,7 @@ inputs:
- crates/aienos-fpu-probe/
- crates/aienos-infer-kernel/
- tests/gates/
+ - native/
run:
exec: tests/gates/run.sh
args: ["ck-stage-tests"]
diff --git a/tests/gates/aienos-crypto-boundary.gate b/tests/gates/aienos-crypto-boundary.gate
index f923bce0 ..d6d481af 100644
--- a/tests/gates/aienos-crypto-boundary.gate
+++ b/tests/gates/aienos-crypto-boundary.gate
@@ -12,6 +12,9 @@ inputs:
- Cargo.lock
- vendor/
- tests/gates/
+ - crates/
+ - .cargo/
+ - docs/adr/0015-golden-vectors.json
run:
exec: tests/gates/run.sh
args: ["crypto-boundary"]
diff --git a/tests/gates/aienos-disk-qemu.gate b/tests/gates/aienos-disk-qemu.gate
index d8ac7a13 ..2b8fe430 100644
--- a/tests/gates/aienos-disk-qemu.gate
+++ b/tests/gates/aienos-disk-qemu.gate
@@ -10,6 +10,7 @@ inputs:
- scripts/qemu_native_nvme_test.sh
- scripts/lib_gate_hold.sh
- tests/gates/
+ - scripts/qemu_native_sdhci_test.sh
run:
exec: tests/gates/run.sh
args: ["disk-qemu"]
diff --git a/tests/gates/aienos-infer-crate.gate b/tests/gates/aienos-infer-crate.gate
index 9110ee81 ..03612d05 100644
--- a/tests/gates/aienos-infer-crate.gate
+++ b/tests/gates/aienos-infer-crate.gate
@@ -10,6 +10,9 @@ inputs:
- Cargo.toml
- Cargo.lock
- tests/gates/
+ - crates/
+ - .cargo/
+ - vendor/
run:
exec: tests/gates/run.sh
args: ["infer-crate"]
diff --git a/tests/gates/aienos-infer-forward.gate b/tests/gates/aienos-infer-forward.gate
new file mode 100644
index 00000000 ..2782428a
--- /dev/null
+++ b/tests/gates/aienos-infer-forward.gate
@@ -0,0 +1,26 @@
+# tests/gates/aienos-infer-forward.gate
+# Not hosted (the hosted runner has no model file): release-build Llama forward comparisons against llama.cpp
+# (crates/aienos-infer/tests/forward.rs) with the real model; FAILS if the model is missing or any test SKIPs
+# (measured 2026-10-16 on the Spark: 178 s test wall, release build warm; timeout 15m leaves room for a cold build)
+gate: AIENOS-INFER-FORWARD
+manifest_version: 2
+owner: aienos
+requires:
+ - host
+inputs:
+ - crates/aienos-infer/
+ - Cargo.toml
+ - Cargo.lock
+ - tests/gates/
+ - crates/
+ - .cargo/
+ - vendor/
+run:
+ exec: tests/gates/run.sh
+ args: ["infer-forward"]
+expects:
+ exit: 0
+ verdict: PASS
+timeout: 15m
+exactness: EXACT
+cache_scope: machine
diff --git a/tests/gates/aienos-native-argus.gate b/tests/gates/aienos-native-argus.gate
index ffb04708 ..d521cfe5 100644
--- a/tests/gates/aienos-native-argus.gate
+++ b/tests/gates/aienos-native-argus.gate
@@ -8,6 +8,7 @@ requires:
inputs:
- native/argus/
- tests/gates/
+ - native/capability/
run:
exec: tests/gates/run.sh
args: ["native-argus"]
diff --git a/tests/gates/aienos-native-capability.gate b/tests/gates/aienos-native-capability.gate
index e2410afb ..b87f0540 100644
--- a/tests/gates/aienos-native-capability.gate
+++ b/tests/gates/aienos-native-capability.gate
@@ -8,6 +8,7 @@ requires:
inputs:
- native/capability/
- tests/gates/
+ - native/argus/
run:
exec: tests/gates/run.sh
args: ["native-capability"]
diff --git a/tests/gates/aienos-native-crypto.gate b/tests/gates/aienos-native-crypto.gate
index 7025555f ..6394691e 100644
--- a/tests/gates/aienos-native-crypto.gate
+++ b/tests/gates/aienos-native-crypto.gate
@@ -8,6 +8,7 @@ requires:
inputs:
- native/crypto/
- tests/gates/
+ - native/argus/
run:
exec: tests/gates/run.sh
args: ["native-crypto"]
diff --git a/tests/gates/aienos-native-m5.gate b/tests/gates/aienos-native-m5.gate
index 5682a090 ..440d4678 100644
--- a/tests/gates/aienos-native-m5.gate
+++ b/tests/gates/aienos-native-m5.gate
@@ -8,6 +8,9 @@ requires:
inputs:
- native/m5/
- tests/gates/
+ - native/argus/
+ - native/crypto/
+ - native/sig/
run:
exec: tests/gates/run.sh
args: ["native-m5"]
diff --git a/tests/gates/aienos-native-net.gate b/tests/gates/aienos-native-net.gate
index ac8d497c ..010d767b 100644
--- a/tests/gates/aienos-native-net.gate
+++ b/tests/gates/aienos-native-net.gate
@@ -8,6 +8,9 @@ requires:
inputs:
- native/net/
- tests/gates/
+ - native/argus/
+ - native/crypto/
+ - native/sig/
run:
exec: tests/gates/run.sh
args: ["native-net"]
diff --git a/tests/gates/aienos-store-native.gate b/tests/gates/aienos-store-native.gate
index f7c3bfb2 ..02b47867 100644
--- a/tests/gates/aienos-store-native.gate
+++ b/tests/gates/aienos-store-native.gate
@@ -8,6 +8,11 @@ requires:
inputs:
- native/store/
- tests/gates/
+ - native/argus/
+ - native/crypto/
+ - native/disk/
+ - native/m5/
+ - docs/adr/0015-golden-vectors.json
run:
exec: tests/gates/run.sh
args: ["store-native"]
diff --git a/tests/gates/aienos-verify-all.gate b/tests/gates/aienos-verify-all.gate
index 39690c64 ..7237486a 100644
--- a/tests/gates/aienos-verify-all.gate
+++ b/tests/gates/aienos-verify-all.gate
@@ -11,6 +11,14 @@ inputs:
- crates/
- native/boot/
- tests/gates/
+ - scripts/
+ - evidence/
+ - native/kernel/tests/fixtures/
+ - Cargo.toml
+ - Cargo.lock
+ - .cargo/
+ - vendor/
+ - docs/adr/0015-golden-vectors.json
run:
exec: tests/gates/run.sh
args: ["verify-all"]
diff --git a/tests/gates/run.sh b/tests/gates/run.sh
index 1efeedad ..5a6652d0 100755
--- a/tests/gates/run.sh
+++ b/tests/gates/run.sh
@@ -115,9 +115,34 @@ case "$step" in
cargo test -p aienos-infer
cargo build -p aienos-infer --target aarch64-unknown-none
;;
+ # Not hosted (the hosted runner has no model file): the real Llama forward comparisons in
+ # crates/aienos-infer/tests/forward.rs, release build. The sandbox finds the model at
+ # $HOME/models (aien-run-exec bind-mounts the operator's ~/models read-only there).
+ # A missing model or any SKIPPED line is a FAIL, never a silent pass.
+ infer-forward)
+ model="${AIENOS_MODEL:-$HOME/models/aien-mail/Llama-3.2-1B-Instruct-Q4_K_M.gguf}"
+ if [ ! -f "$model" ]; then
+ echo "::error::model file $model not present; infer-forward needs the real model" >&2
+ obs model_present false
+ exit 1
+ fi
+ obs model_present true
+ export AIENOS_MODEL="$model"
+ set -o pipefail
+ cargo test --release -p aienos-infer --test forward 2>&1 | tee "$TMP/forward.log"
+ if grep -q 'SKIPPED' "$TMP/forward.log"; then
+ echo "::error::forward tests printed SKIPPED" >&2
+ obs skipped_in_log true
+ exit 1
+ fi
+ obs skipped_in_log false
+ ;;
# ci.yml (disabled on GitHub since the CK workflow took over): the suites it still names
store-native) make -C native/store test mutants ;;
- verify-all) bash scripts/verify_all.sh ;;
+ verify-all)
+ export AIENOS_MODEL="${AIENOS_MODEL:-/nonexistent/no-model.gguf}" # hosted parity: the debug workspace sweep skips forward tests (they run in infer-forward)
+ bash scripts/verify_all.sh
+ ;;
zero-disk-secrets)
echo "Auditing repository for prohibited plaintext secret files..."
if find . -maxdepth 4 -name ".env*" -not -path "*/.git/*" -not -path "*/target/*" -not -path "*/vendor/*" | grep -q .; then