From 596870d6ef47c5238cc2c7fa1c08f5e5486e5d84 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Wed, 14 Oct 2026 09:19:14 -0500 Subject: [PATCH 1/2] test(native,allen-reflex): parallelize C mutant sweeps and add ALLEN Tower core --- .crumb | 18 +- crates/.crumb | 8 +- crates/allen-reflex/src/lib.rs | 1 + crates/allen-reflex/src/tower.rs | 350 +++++++++++++++++++++++++++++++ native/.crumb | 26 +-- native/capability/.crumb | 8 +- native/capability/Makefile | 48 +++-- native/crypto/.crumb | 8 +- native/crypto/Makefile | 30 ++- native/disk/.crumb | 12 +- native/disk/Makefile | 57 +++-- native/m5/.crumb | 10 +- native/m5/Makefile | 46 ++-- native/net/.crumb | 8 +- native/net/Makefile | 43 ++-- native/sig/.crumb | 8 +- native/sig/Makefile | 31 ++- native/store/.crumb | 10 +- native/store/Makefile | 67 ++++-- 19 files changed, 625 insertions(+), 164 deletions(-) create mode 100644 crates/allen-reflex/src/tower.rs diff --git a/.crumb b/.crumb index 0c8d100d..0ccb6d4a 100644 --- a/.crumb +++ b/.crumb @@ -21,7 +21,7 @@ "generated": { "children": [ { - "digest": "0a64e70b4b3a673fd433dc6404ed4c8fa0218362d90af3f16bd9f23ec4efc3e3", + "digest": "54d65ab06d6d4d4b9eb7f0580e9533f6402e5b0cfa290a32178d3307db0d90eb", "last_commit": "2951ea1", "name": "crates", "purpose": "Directory crates. Purpose not yet described by a human." @@ -33,27 +33,27 @@ "purpose": "Directory docs. Purpose not yet described by a human." }, { - "digest": "9b55aeb41d7187fbef6fd8438a748fbb77ed95967f124b82e4d466a08793df09", - "last_commit": "a0fa796", + "digest": "c892bb8ae2aabd5566432f63d72f6937cf36d0e20f36bfae5f838238a89bcedd", + "last_commit": "f5c90e7", "name": "native", "purpose": "Directory native. Purpose not yet described by a human." }, { "digest": "fe47cb248b0f45e1d91fe38a8787181eee2a42fcd49cc313a70323f207d48392", - "last_commit": "a0fa796", + "last_commit": "f5c90e7", "name": "scripts", "purpose": "Directory scripts. Purpose not yet described by a human." } ], - "children_root": "sha256:655675e603ff7ebfc946a44bc5d4f03ca7391513474aec182e1ae465ea82701b", - "compiled_at": "2026-10-14T13:28:10Z", + "children_root": "sha256:b6d0862da67164153aa48f4e9efa007268d6ea7063132c7d14fb9f10a3a25bfc", + "compiled_at": "2026-10-14T14:17:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:496650be293999f74ccead651ea81b1bec6bf4f6e0f123fe306cbbfee0254317", + "digest": "sha256:2855ef7e0d08a2385f4d2913155dc8c24d5574cdb03bd172e34203a79009f646", "evidence_files": 183, "evidence_root": "sha256:9ac286aca0d673f856463c2a1541854df773bfe792792e6b82b7cb7a47cd17cc", "files": 3421, - "generated_at_commit": "a0fa796235409ce465c467e8c72fbd977485d8f7", - "source_tree": "sha256:469f3f55a14e1ae1e1afce9e45608d7d8c33504375697b603fac08d6f03b6e49" + "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", + "source_tree": "sha256:aa43b39e9ca3d3f2cb6c4542d571a8de8164ae20fe8a4aa7c80fd073cc681e18" }, "owner_lane": "", "provenance": { diff --git a/crates/.crumb b/crates/.crumb index 58809c7a..f71b2c36 100644 --- a/crates/.crumb +++ b/crates/.crumb @@ -150,14 +150,14 @@ } ], "children_root": "sha256:ca16d018c0c02840ba1f87e2a7b64ed259a36253ed29230f274ebcabb43c8a7e", - "compiled_at": "2026-10-14T13:28:10Z", + "compiled_at": "2026-10-14T14:17:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:0a64e70b4b3a673fd433dc6404ed4c8fa0218362d90af3f16bd9f23ec4efc3e3", + "digest": "sha256:54d65ab06d6d4d4b9eb7f0580e9533f6402e5b0cfa290a32178d3307db0d90eb", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 267, - "generated_at_commit": "a0fa796235409ce465c467e8c72fbd977485d8f7", - "source_tree": "sha256:95fcb3209b6312b16f4a300bbe9ef3fb0136389b0b418f049e82ea7a425b65c0" + "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", + "source_tree": "sha256:573af20504e6f43ca144bea4aeb5cc0fbb8fbd6f30a16171933296f196a85776" }, "owner_lane": "", "provenance": { diff --git a/crates/allen-reflex/src/lib.rs b/crates/allen-reflex/src/lib.rs index b44f7bfc..6acacce3 100644 --- a/crates/allen-reflex/src/lib.rs +++ b/crates/allen-reflex/src/lib.rs @@ -36,6 +36,7 @@ pub mod policy; pub mod segment; pub mod span; pub mod text; +pub mod tower; pub use action::{Action, N_LABELS}; pub use dialog::{Pending, Role, Turn}; diff --git a/crates/allen-reflex/src/tower.rs b/crates/allen-reflex/src/tower.rs new file mode 100644 index 00000000..eb90053d --- /dev/null +++ b/crates/allen-reflex/src/tower.rs @@ -0,0 +1,350 @@ +//! ALLEN Tower: Pi 5 bare-metal AIENOS test & verification orchestrator core. +//! +//! Pairs the persistent 8 GB Raspberry Pi 5 (booting bare-metal AIENOS + ALLEN REFLEX) +//! with DGX Spark ("Spark Forge"): +//! - Reuses content-addressed PASS receipts across commits when `(gate, input_digest)` matches. +//! - Folds observed Mneme (`libmneme.so`) file-read digests and sibling pins into `input_digest`. +//! - Deduplicates concurrent identical `(gate, input_digest)` requests in-flight (`JoinInflight`). +//! - Routes `Portable` and `Pi5Host` gates to local Pi 5 Cortex-A76 cores (`RunPi5Local`), +//! `SparkHost` and `SparkQemu` gates to Spark's 20-core host pool (`DispatchSparkHost`), +//! and `SparkGb10` / `SparkNvrm` gates to Spark's serialized GPU queue (`QueueSparkGb10`). + +use alloc::string::String; +use alloc::vec::Vec; + +/// Execution tier for a verification gate. +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum GateTier { + /// Pure tree/receipt check with no hardware or host tool assumptions. + Portable, + /// Lightweight C or Rust check runnable directly on the persistent 8 GB Pi 5. + Pi5Host, + /// Multi-core compilation or mutation sweep dispatched to Spark's 20 Grace cores. + SparkHost, + /// Full-system AArch64 QEMU emulation dispatched to Spark's host pool. + SparkQemu, + /// Exclusive Grace Blackwell GB10 silicon gate (serialized 1-at-a-time). + SparkGb10, + /// Exclusive NVRM kernel-driver lifecycle gate (serialized 1-at-a-time). + SparkNvrm, +} + +/// Gate scheduling request evaluated by ALLEN Tower. +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct GateSpec { + pub gate: String, + pub tier: GateTier, + pub input_digest: [u8; 32], + pub cacheable: bool, +} + +/// Orchestrator action emitted by ALLEN Tower. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum TowerAction { + /// Exact `(gate, input_digest)` already has a verified PASS receipt. + ReuseReceipt { receipt_digest: [u8; 32] }, + /// Identical `(gate, input_digest)` is currently running in slot `slot`; join its result. + JoinInflight { slot: usize }, + /// Execute locally on the persistent Pi 5 orchestrator node. + RunPi5Local, + /// Dispatch to DGX Spark's parallel host/QEMU worker pool. + DispatchSparkHost, + /// Enqueue on DGX Spark's serialized GB10/NVRM hardware lock queue. + QueueSparkGb10, +} + +impl TowerAction { + /// Canonical wire name for the tower action. + pub fn name(&self) -> &'static str { + match self { + TowerAction::ReuseReceipt { .. } => "reuse_receipt", + TowerAction::JoinInflight { .. } => "join_inflight", + TowerAction::RunPi5Local => "run_pi5_local", + TowerAction::DispatchSparkHost => "dispatch_spark_host", + TowerAction::QueueSparkGb10 => "queue_spark_gb10", + } + } +} + +/// Machine-checkable reason for a [`TowerDecision`]. +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum TowerWhy { + CachedPassReceipt, + InflightDuplicate, + TierLocalPi5, + TierSparkHostPool, + TierSparkGpuSerial, + UncacheableGate, +} + +impl TowerWhy { + pub fn name(self) -> &'static str { + match self { + TowerWhy::CachedPassReceipt => "cached_pass_receipt", + TowerWhy::InflightDuplicate => "inflight_duplicate", + TowerWhy::TierLocalPi5 => "tier_local_pi5", + TowerWhy::TierSparkHostPool => "tier_spark_host_pool", + TowerWhy::TierSparkGpuSerial => "tier_spark_gpu_serial", + TowerWhy::UncacheableGate => "uncacheable_gate", + } + } +} + +/// Deterministic scheduling decision from ALLEN Tower. +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct TowerDecision { + pub gate: String, + pub action: TowerAction, + pub why: TowerWhy, +} + +impl TowerDecision { + /// Format as a single-line canonical JSON decision record. + pub fn to_json(&self) -> String { + let mut out = String::from(r#"{"tower_action":""#); + out.push_str(self.action.name()); + out.push_str(r#"","gate":""#); + out.push_str(&self.gate); + out.push_str(r#"","why":""#); + out.push_str(self.why.name()); + out.push_str(r#""}"#); + out + } +} + +/// Combine declared input digest, sibling pin digest, and Mneme observed read-set digests +/// into a single 32-byte effective cache key (`no_std`, order-sensitive, domain-separated). +pub fn combine_mneme_digest( + declared_inputs: &[u8; 32], + sibling_pins: &[u8; 32], + mneme_reads: &[[u8; 32]], +) -> [u8; 32] { + let mut state = [0u64; 4]; + let seeds: [u64; 4] = [ + 0x6a09e667f3bcc908, + 0xbb67ae8584caa73b, + 0x3c6ef372fe94f82b, + 0xa54ff53a5f1d36f1, + ]; + state.copy_from_slice(&seeds); + + fn absorb(st: &mut [u64; 4], tag: u64, block: &[u8; 32]) { + st[0] ^= tag; + for i in 0..4 { + let mut w = 0u64; + for b in 0..8 { + w = (w << 8) | (block[i * 8 + b] as u64); + } + st[i] = st[i].wrapping_add(w).wrapping_mul(0x9e3779b97f4a7c15); + st[i] = st[i].rotate_left(27) ^ st[(i + 1) & 3]; + } + } + + absorb(&mut state, 0x4445434c_u64, declared_inputs); + absorb(&mut state, 0x50494e53_u64, sibling_pins); + absorb( + &mut state, + (mneme_reads.len() as u64) ^ 0x4d4e454d_u64, + &[0u8; 32], + ); + for r in mneme_reads { + absorb(&mut state, 0x52454144_u64, r); + } + + let mut out = [0u8; 32]; + for i in 0..4 { + let bytes = state[i].to_be_bytes(); + out[i * 8..(i + 1) * 8].copy_from_slice(&bytes); + } + out +} + +/// Bounded, `no_std` orchestrator state machine for the Pi 5 ALLEN Tower. +pub struct TowerOrchestrator { + pub max_receipts: usize, + pub max_inflight: usize, + receipts: Vec<(String, [u8; 32], [u8; 32])>, + inflight: Vec<(String, [u8; 32])>, +} + +impl TowerOrchestrator { + pub fn new(max_receipts: usize, max_inflight: usize) -> Self { + Self { + max_receipts, + max_inflight, + receipts: Vec::new(), + inflight: Vec::new(), + } + } + + /// Record a verified PASS receipt in the bounded content-addressed index. + pub fn record_pass_receipt( + &mut self, + gate: &str, + input_digest: [u8; 32], + receipt_digest: [u8; 32], + ) { + self.complete_inflight(gate, &input_digest); + for entry in &mut self.receipts { + if entry.0 == gate && entry.1 == input_digest { + entry.2 = receipt_digest; + return; + } + } + if self.max_receipts == 0 { + return; + } + if self.receipts.len() >= self.max_receipts { + self.receipts.remove(0); + } + self.receipts + .push((String::from(gate), input_digest, receipt_digest)); + } + + /// Remove an in-flight gate entry when execution finishes. + pub fn complete_inflight(&mut self, gate: &str, input_digest: &[u8; 32]) -> bool { + if let Some(pos) = self + .inflight + .iter() + .position(|(g, d)| g == gate && d == input_digest) + { + self.inflight.remove(pos); + true + } else { + false + } + } + + /// Decide how to handle `spec` without dropping or weakening any gate check. + pub fn schedule_gate(&mut self, spec: &GateSpec) -> TowerDecision { + if spec.cacheable { + for (g, din, drcpt) in &self.receipts { + if g == &spec.gate && *din == spec.input_digest { + return TowerDecision { + gate: spec.gate.clone(), + action: TowerAction::ReuseReceipt { + receipt_digest: *drcpt, + }, + why: TowerWhy::CachedPassReceipt, + }; + } + } + } + + if let Some(slot) = self + .inflight + .iter() + .position(|(g, d)| g == &spec.gate && *d == spec.input_digest) + { + return TowerDecision { + gate: spec.gate.clone(), + action: TowerAction::JoinInflight { slot }, + why: TowerWhy::InflightDuplicate, + }; + } + + if self.inflight.len() < self.max_inflight { + self.inflight.push((spec.gate.clone(), spec.input_digest)); + } + + let (action, default_why) = match spec.tier { + GateTier::Portable | GateTier::Pi5Host => { + (TowerAction::RunPi5Local, TowerWhy::TierLocalPi5) + } + GateTier::SparkHost | GateTier::SparkQemu => { + (TowerAction::DispatchSparkHost, TowerWhy::TierSparkHostPool) + } + GateTier::SparkGb10 | GateTier::SparkNvrm => { + (TowerAction::QueueSparkGb10, TowerWhy::TierSparkGpuSerial) + } + }; + + let why = if spec.cacheable { + default_why + } else { + TowerWhy::UncacheableGate + }; + + TowerDecision { + gate: spec.gate.clone(), + action, + why, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn tower_reuses_receipt_and_deduplicates_inflight_and_routes_tiers() { + let mut tower = TowerOrchestrator::new(64, 16); + let d_decl = [0x11u8; 32]; + let d_pins = [0x22u8; 32]; + let d_read1 = [0x33u8; 32]; + let d_in = combine_mneme_digest(&d_decl, &d_pins, &[d_read1]); + let d_rcpt = [0x99u8; 32]; + + tower.record_pass_receipt("OMEGA-ALGEBRA", d_in, d_rcpt); + + let spec = GateSpec { + gate: String::from("OMEGA-ALGEBRA"), + tier: GateTier::SparkHost, + input_digest: d_in, + cacheable: true, + }; + let dec = tower.schedule_gate(&spec); + assert_eq!( + dec.action, + TowerAction::ReuseReceipt { + receipt_digest: d_rcpt + } + ); + assert_eq!(dec.why, TowerWhy::CachedPassReceipt); + assert_eq!( + dec.to_json(), + r#"{"tower_action":"reuse_receipt","gate":"OMEGA-ALGEBRA","why":"cached_pass_receipt"}"# + ); + + // Changing a Mneme observed read-set file invalidates the receipt and dispatches to Spark. + let d_in_changed = combine_mneme_digest(&d_decl, &d_pins, &[[0x34u8; 32]]); + assert_ne!(d_in, d_in_changed); + let spec_changed = GateSpec { + gate: String::from("OMEGA-ALGEBRA"), + tier: GateTier::SparkHost, + input_digest: d_in_changed, + cacheable: true, + }; + let dec1 = tower.schedule_gate(&spec_changed); + assert_eq!(dec1.action, TowerAction::DispatchSparkHost); + assert_eq!(dec1.why, TowerWhy::TierSparkHostPool); + + // A second concurrent request for the same (gate, input_digest) joins the in-flight run. + let dec2 = tower.schedule_gate(&spec_changed); + assert_eq!(dec2.action, TowerAction::JoinInflight { slot: 0 }); + assert_eq!(dec2.why, TowerWhy::InflightDuplicate); + + // Portable/Pi5Host routes locally to Pi 5; SparkGb10 queues on Spark GPU lock. + let pi_spec = GateSpec { + gate: String::from("AIENOS-ZERO-DISK-SECRETS"), + tier: GateTier::Portable, + input_digest: [0x55u8; 32], + cacheable: true, + }; + assert_eq!( + tower.schedule_gate(&pi_spec).action, + TowerAction::RunPi5Local + ); + + let gpu_spec = GateSpec { + gate: String::from("OMEGA-DIVSQRT-CHIP"), + tier: GateTier::SparkGb10, + input_digest: [0x66u8; 32], + cacheable: false, + }; + let gpu_dec = tower.schedule_gate(&gpu_spec); + assert_eq!(gpu_dec.action, TowerAction::QueueSparkGb10); + assert_eq!(gpu_dec.why, TowerWhy::UncacheableGate); + } +} diff --git a/native/.crumb b/native/.crumb index bb3b28da..a454dc47 100644 --- a/native/.crumb +++ b/native/.crumb @@ -61,63 +61,63 @@ "purpose": "Directory native/boot. Purpose not yet described by a human." }, { - "digest": "aaee52694510c1aea1e16ffd54201ce8e900742974d538bbf4640ab01d239872", + "digest": "4326d5aff89483ffbd3f109b4849fad5e3ed9c78d97145df6a0a0e326a63de34", "last_commit": "51c05da", "name": "capability", "purpose": "Directory native/capability. Purpose not yet described by a human." }, { - "digest": "44513be407ed44a29feac97bfec222e968f9f6415631f0cd62dc65a522c420e4", + "digest": "2d681397b90b5102fc04a957deb11ca4b56fe21c368d46394a85df9782b31475", "last_commit": "a4bba0c", "name": "crypto", "purpose": "Directory native/crypto. Purpose not yet described by a human." }, { - "digest": "3508a201e84c9e6a53160c5c46395f17c376b0c460b3b81049803505876d4f07", + "digest": "5f7e090612dfe2e9c4a1e77fcf8443615bf6191ae6eb50ec8a472f5855f29506", "last_commit": "2563059", "name": "disk", "purpose": "Directory native/disk. Purpose not yet described by a human." }, { "digest": "31737455b2245028f473bf7d18f3c5e45f3f5e89d948d55d480c90f6b8b87f32", - "last_commit": "a0fa796", + "last_commit": "f5c90e7", "name": "kernel", "purpose": "Directory native/kernel. Purpose not yet described by a human." }, { - "digest": "3883ad91cdafdb9158b14c4d8b11d4dcbfe1205ad8071c988b8f7c4b959a4004", + "digest": "8a8ec123b3898cbb63e073593baf4756abc4c0c6ab93db804937d937425f3f9a", "last_commit": "1feaca1", "name": "m5", "purpose": "Directory native/m5. Purpose not yet described by a human." }, { - "digest": "c91e9201f6ce9cb909ce3fadfa60d4869fc661db8d4266cd2c15e0688d384cf7", + "digest": "370c8b53b1041e4db242950e1be4667c260fbaba7d7bfe397ffe73775f71af6b", "last_commit": "4a116e5", "name": "net", "purpose": "Directory native/net. Purpose not yet described by a human." }, { - "digest": "295150763e0b19f9f74a3b49d679213467075e9682f1f23d0e5ea838872d20e1", + "digest": "531200647a05b2f1b7da7d7bcd012461a6988ff9c8ec5b9f4a888c7ee4f8f8cf", "last_commit": "cea54be", "name": "sig", "purpose": "Directory native/sig. Purpose not yet described by a human." }, { - "digest": "eeec17e754d15d5723d77d953711620c568c160f47e6c90a4c927c85ec5bb32d", + "digest": "afee8b21a480493ada6062451cb53deb08ad3441978653f1bc9f41ac727c8a6c", "last_commit": "22eb360", "name": "store", "purpose": "Directory native/store. Purpose not yet described by a human." } ], - "children_root": "sha256:ecde64d885b25ff0007256821368d782117a3229767f1288f58501f2fa5618fe", - "compiled_at": "2026-10-14T13:28:10Z", + "children_root": "sha256:505add7cf041a00f92a5ee94cec544b526dfea53989cfd8b541472b49bd68f93", + "compiled_at": "2026-10-14T14:17:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:9b55aeb41d7187fbef6fd8438a748fbb77ed95967f124b82e4d466a08793df09", + "digest": "sha256:c892bb8ae2aabd5566432f63d72f6937cf36d0e20f36bfae5f838238a89bcedd", "evidence_files": 4, "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335", "files": 562, - "generated_at_commit": "a0fa796235409ce465c467e8c72fbd977485d8f7", - "source_tree": "sha256:b01897405fdf7f14cf3e5349b434489acfc2c0469455ec92bb91bd5666a435d2" + "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", + "source_tree": "sha256:df045e3d50780709d0ed71a3012a3ba5ede2c9d3e536f395d4652522dcdfeef8" }, "owner_lane": "", "provenance": { diff --git a/native/capability/.crumb b/native/capability/.crumb index cec65f50..fca5563a 100644 --- a/native/capability/.crumb +++ b/native/capability/.crumb @@ -20,14 +20,14 @@ } ], "children_root": "sha256:0c70cfa122966e11065bca94434dcb159c75a4557cf6322bbc5256e28d49f2e5", - "compiled_at": "2026-10-11T21:20:24Z", + "compiled_at": "2026-10-14T14:17:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:aaee52694510c1aea1e16ffd54201ce8e900742974d538bbf4640ab01d239872", + "digest": "sha256:4326d5aff89483ffbd3f109b4849fad5e3ed9c78d97145df6a0a0e326a63de34", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 8, - "generated_at_commit": "362cba9653c8021996a21b17ead00d5d1140b371", - "source_tree": "sha256:90b68117013a8044617b567a023aa2938e3695ba48153b9a7f89b263e371a14c" + "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", + "source_tree": "sha256:d3faa108df05fcf2e4869afc82e07693ba3b85b3d6caa55107e0ec2c515898c8" }, "owner_lane": "", "provenance": { diff --git a/native/capability/Makefile b/native/capability/Makefile index bd417897..a5cfd3e9 100644 --- a/native/capability/Makefile +++ b/native/capability/Makefile @@ -127,7 +127,11 @@ MUT_DIR = $(OUT)/mut MUT_TABLE = $(OUT)/mutants.table MUT_TIMEOUT ?= 300 -mutants: $(TEST) $(CONTAIN_TEST) | $(OUT) +CAP_MUT_TEST_OBJS = $(OUT)/t_capability_test.o $(OUT)/t_contain_test.o $(OUT)/aienos_capability.o $(OUT)/aienos_contain.o +$(OUT)/t_%_test.o: tests/%_test.c aienos_capability.h aienos_contain.h | $(OUT) + $(CC) $(CFLAGS) -Wno-error -I. -pthread -c -o $@ $< + +mutants: $(TEST) $(CONTAIN_TEST) $(CAP_MUT_TEST_OBJS) | $(OUT) @rm -rf $(MUT_DIR); mkdir -p $(MUT_DIR) $(file >$(MUT_TABLE),$(CAP_MUTANTS)) @ulimit -c 0; \ @@ -136,25 +140,33 @@ mutants: $(TEST) $(CONTAIN_TEST) | $(OUT) else echo "baseline (no mutation): tests FAIL, mutants are meaningless"; \ echo "---- baseline log ($(MUT_DIR)/baseline.log) ----"; cat $(MUT_DIR)/baseline.log; echo "---- end baseline log ----"; \ echo "AIENOS_CAP_MUTANTS: FAIL"; exit 1; fi; \ - n=0; killed=0; fail=0; \ + n=0; killed=0; fail=0; names=""; \ while IFS='|' read -r name file k from to; do \ - [ -n "$$name" ] || continue; n=$$((n+1)); d=$(MUT_DIR)/$$name; mkdir -p $$d; \ - if ! awk -v k="$$k" -v from="$$from" -v to="$$to" \ - 'index($$0, from) { c++; if (c == k) { i = index($$0, from); $$0 = substr($$0, 1, i - 1) to substr($$0, i + length(from)); hit = 1 } } { print } END { exit hit ? 0 : 3 }' \ - $$file > $$d/$$file; then \ - echo "mutant $$name: did not apply, text not found in $$file (FAIL)"; fail=1; continue; fi; \ - if cmp -s $$file $$d/$$file; then echo "mutant $$name: no change (FAIL)"; fail=1; continue; fi; \ - if [ $$file = aienos_capability.c ]; then capsrc=$$d/aienos_capability.c; gatesrc=aienos_contain.c; \ - else capsrc=aienos_capability.c; gatesrc=$$d/aienos_contain.c; fi; \ - if ! $(CC) $(CFLAGS) -Wno-error -I. -pthread -o $$d/capability_test tests/capability_test.c $$capsrc > $$d/build.log 2>&1 || \ - ! $(CC) $(CFLAGS) -Wno-error -I. -pthread -o $$d/contain_test tests/contain_test.c $$gatesrc $$capsrc >> $$d/build.log 2>&1; then \ - echo "mutant $$name: does not compile (FAIL, see $$d/build.log)"; fail=1; continue; fi; \ - by=""; \ - timeout $(MUT_TIMEOUT) $$d/capability_test > $$d/run.log 2>&1 || by="capability_test"; \ - timeout $(MUT_TIMEOUT) $$d/contain_test >> $$d/run.log 2>&1 || by="$${by:+$$by+}contain_test"; \ - if [ -n "$$by" ]; then echo "mutant $$name: killed by $$by"; killed=$$((killed+1)); \ - else echo "mutant $$name: SURVIVED (FAIL)"; fail=1; fi; \ + [ -n "$$name" ] || continue; n=$$((n+1)); names="$$names $$name"; d=$(MUT_DIR)/$$name; mkdir -p $$d; \ + ( if ! awk -v k="$$k" -v from="$$from" -v to="$$to" \ + 'index($$0, from) { c++; if (c == k) { i = index($$0, from); $$0 = substr($$0, 1, i - 1) to substr($$0, i + length(from)); hit = 1 } } { print } END { exit hit ? 0 : 3 }' \ + $$file > $$d/$$file; then \ + echo "mutant $$name: did not apply, text not found in $$file (FAIL)" > $$d/msg; echo 1 > $$d/fail; exit 0; fi; \ + if cmp -s $$file $$d/$$file; then echo "mutant $$name: no change (FAIL)" > $$d/msg; echo 1 > $$d/fail; exit 0; fi; \ + if ! $(CC) $(CFLAGS) -Wno-error -I. -pthread -c -o $$d/m.o $$d/$$file > $$d/build.log 2>&1; then \ + echo "mutant $$name: does not compile (FAIL, see $$d/build.log)" > $$d/msg; echo 1 > $$d/fail; exit 0; fi; \ + if [ $$file = aienos_capability.c ]; then capobj=$$d/m.o; gateobj=$(OUT)/aienos_contain.o; \ + else capobj=$(OUT)/aienos_capability.o; gateobj=$$d/m.o; fi; \ + if ! $(CC) $(CFLAGS) -Wno-error -pthread -o $$d/capability_test $(OUT)/t_capability_test.o $$capobj >> $$d/build.log 2>&1 || \ + ! $(CC) $(CFLAGS) -Wno-error -pthread -o $$d/contain_test $(OUT)/t_contain_test.o $$gateobj $$capobj >> $$d/build.log 2>&1; then \ + echo "mutant $$name: does not compile (FAIL, see $$d/build.log)" > $$d/msg; echo 1 > $$d/fail; exit 0; fi; \ + by=""; \ + timeout $(MUT_TIMEOUT) $$d/capability_test > $$d/run.log 2>&1 || by="capability_test"; \ + timeout $(MUT_TIMEOUT) $$d/contain_test >> $$d/run.log 2>&1 || by="$${by:+$$by+}contain_test"; \ + if [ -n "$$by" ]; then echo "mutant $$name: killed by $$by" > $$d/msg; \ + else echo "mutant $$name: SURVIVED (FAIL)" > $$d/msg; echo 1 > $$d/fail; fi \ + ) & \ done < $(MUT_TABLE); \ + wait; \ + for name in $$names; do \ + d=$(MUT_DIR)/$$name; cat $$d/msg; \ + if [ -f $$d/fail ]; then fail=1; else killed=$$((killed+1)); fi; \ + done; \ if [ $$n -lt 8 ]; then echo "only $$n mutants defined, need at least 8"; fail=1; fi; \ if [ $$fail -eq 0 ] && [ $$killed -eq $$n ]; then echo "AIENOS_CAP_MUTANTS: PASS ($$killed/$$n killed)"; \ else echo "AIENOS_CAP_MUTANTS: FAIL ($$killed/$$n killed)"; exit 1; fi diff --git a/native/crypto/.crumb b/native/crypto/.crumb index 94e8a781..f7bac087 100644 --- a/native/crypto/.crumb +++ b/native/crypto/.crumb @@ -20,14 +20,14 @@ } ], "children_root": "sha256:db2c6d092f9d97c30dc5cc4531ae25cb558d206d66ca31f94ca14d0ff2cfacea", - "compiled_at": "2026-10-04T13:47:18Z", + "compiled_at": "2026-10-14T14:17:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:44513be407ed44a29feac97bfec222e968f9f6415631f0cd62dc65a522c420e4", + "digest": "sha256:2d681397b90b5102fc04a957deb11ca4b56fe21c368d46394a85df9782b31475", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 10, - "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512", - "source_tree": "sha256:b3968497ba4c99693f617830c95a9f1b1a5e23eaa5b546cd104d4408025a7178" + "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", + "source_tree": "sha256:5b3ccd83e8032a7eecd2f0f18c998fc357f533e0dfaa3ec4ff72836d013e2ef5" }, "owner_lane": "", "provenance": { diff --git a/native/crypto/Makefile b/native/crypto/Makefile index d108912d..ec210ab2 100644 --- a/native/crypto/Makefile +++ b/native/crypto/Makefile @@ -59,15 +59,27 @@ endif # fail (or crash) for every mutant, or that rule is not tested. GUARDS = tag-msb ctr-msb pt-max aad-max-seal ct-max aad-max-open tag-check wipe-on-fail -mutants: | $(OUT) - @ulimit -c 0; fail=0; for g in $(GUARDS); do \ - grep -q "GUARD:$$g \*/" gcm_siv.c || { echo "mutant $$g: guard tag missing"; fail=1; continue; }; \ - sed "/GUARD:$$g \*\//d" gcm_siv.c > $(OUT)/mut_$$g.c; \ - $(CC) $(CFLAGS) -Wno-error -I. -o $(OUT)/mut_$$g tests/crypto_test.c $(OUT)/mut_$$g.c \ - aes.c polyval.c hmac.c ct.c ../argus/sha256.c || { fail=1; continue; }; \ - if ./$(OUT)/mut_$$g > $(OUT)/mut_$$g.log 2>&1; then \ - echo "mutant $$g: SURVIVED (FAIL)"; fail=1; \ - else echo "mutant $$g: killed"; fi; \ +$(OUT)/t_crypto_test.o: tests/crypto_test.c $(HDRS) | $(OUT) + $(CC) $(CFLAGS) -Wno-error -I. -c -o $@ $< + +mutants: $(OBJS) $(OUT)/sha256.o $(OUT)/t_crypto_test.o | $(OUT) + @ulimit -c 0; fail=0; \ + for g in $(GUARDS); do \ + ( grep -q "GUARD:$$g \*/" gcm_siv.c || { echo "mutant $$g: guard tag missing" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; exit 0; }; \ + sed "/GUARD:$$g \*\//d" gcm_siv.c > $(OUT)/mut_$$g.c; \ + $(CC) $(CFLAGS) -Wno-error -I. -c -o $(OUT)/mut_$$g.o $(OUT)/mut_$$g.c \ + && $(CC) $(CFLAGS) -Wno-error -o $(OUT)/mut_$$g $(OUT)/t_crypto_test.o $(OUT)/mut_$$g.o \ + $(OUT)/aes.o $(OUT)/polyval.o $(OUT)/hmac.o $(OUT)/ct.o $(OUT)/sha256.o \ + || { echo "mutant $$g: does not compile" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; exit 0; }; \ + if ./$(OUT)/mut_$$g > $(OUT)/mut_$$g.log 2>&1; then \ + echo "mutant $$g: SURVIVED (FAIL)" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; \ + else echo "mutant $$g: killed" > $(OUT)/mut_$$g.msg; fi \ + ) & \ + done; \ + wait; \ + for g in $(GUARDS); do \ + cat $(OUT)/mut_$$g.msg; \ + if [ -f $(OUT)/mut_$$g.fail ]; then fail=1; rm -f $(OUT)/mut_$$g.fail; fi; \ done; \ if [ $$fail -eq 0 ]; then echo "AIENOS_CRYPTO_MUTANTS: PASS"; else echo "AIENOS_CRYPTO_MUTANTS: FAIL"; exit 1; fi diff --git a/native/disk/.crumb b/native/disk/.crumb index 25dc25bd..ccca8a7a 100644 --- a/native/disk/.crumb +++ b/native/disk/.crumb @@ -18,26 +18,26 @@ "children": [ { "digest": "54a25a2ce38d5cde54cce87582dfdcd66b3f21ba3ae18d330c8c66a7004b386a", - "last_commit": "1994c4f", + "last_commit": "2563059", "name": "qemu", "purpose": "Directory native/disk/qemu. Purpose not yet described by a human." }, { "digest": "28bc8b4021cec8ccd5b90c15d11db3fe7dd396db65e062f5e1046631fa2e4755", - "last_commit": "1994c4f", + "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-13T05:44:11Z", + "compiled_at": "2026-10-14T14:17:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:3508a201e84c9e6a53160c5c46395f17c376b0c460b3b81049803505876d4f07", + "digest": "sha256:5f7e090612dfe2e9c4a1e77fcf8443615bf6191ae6eb50ec8a472f5855f29506", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 20, - "generated_at_commit": "1994c4f8c4e8521d7febed45306515aa5085f207", - "source_tree": "sha256:5aacdfa45187fd64a3b11a63ea0baa0a1445461e674422908bfc6ae1b8dbd9d7" + "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", + "source_tree": "sha256:3d0f1765860ba9a04e29b2bc9becb299ca5bef8ded1b52082712e27bdaf37163" }, "owner_lane": "", "provenance": { diff --git a/native/disk/Makefile b/native/disk/Makefile index f58a500d..9e233a55 100644 --- a/native/disk/Makefile +++ b/native/disk/Makefile @@ -27,7 +27,7 @@ ifeq ($(shell uname -m),aarch64) FREEFLAGS += -mstrict-align -mgeneral-regs-only endif OUT ?= out -MUTANT_TIMEOUT ?= 60 +MUTANT_TIMEOUT ?= 5 SRCS = disk.c disk_nvme.c disk_sdhci.c OBJS = $(SRCS:%.c=$(OUT)/%.o) @@ -109,24 +109,43 @@ GUARDS = disk-zero disk-lba disk-end queue-bound queue-failstop \ sdhci-nocard sdhci-cmd8 sdhci-acmd41-bound sdhci-csd-zero sdhci-ready sdhci-range \ sdhci-tran sdhci-failstop -mutants: | $(OUT) - @ulimit -c 0; fail=0; n=0; k=0; for g in $(GUARDS); do \ - n=$$((n+1)); \ - f=$$(grep -l "GUARD:$$g \*/" $(SRCS)); \ - if [ $$(echo "$$f" | wc -w) -ne 1 ]; then echo "mutant $$g: guard tag missing or duplicated"; fail=1; continue; fi; \ - if [ $$(grep -c "GUARD:$$g \*/" $$f) -ne 1 ]; then echo "mutant $$g: guard tag duplicated"; fail=1; continue; fi; \ - d=$(OUT)/mut_$$g; rm -rf $$d; mkdir -p $$d/scratch; \ - for s in $(SRCS); do if [ $$s = $$f ]; then sed "/GUARD:$$g \*\//d" $$s > $$d/$$s; else cp $$s $$d/$$s; fi; done; \ - if cmp -s $$f $$d/$$f; then echo "mutant $$g: sed changed nothing (FAIL)"; fail=1; continue; fi; \ - $(CC) $(CFLAGS) -Wno-error -I. -o $$d/dt tests/disk_test.c disk_file.c $$d/disk.c $$d/disk_nvme.c $$d/disk_sdhci.c 2> $$d/cc.log \ - && $(CC) $(CFLAGS) -Wno-error -I. -o $$d/nt tests/nvme_test.c $$d/disk.c $$d/disk_nvme.c $$d/disk_sdhci.c 2>> $$d/cc.log \ - && $(CC) $(CFLAGS) -Wno-error -I. -o $$d/st tests/sdhci_test.c $$d/disk.c $$d/disk_nvme.c $$d/disk_sdhci.c 2>> $$d/cc.log \ - || { echo "mutant $$g: does not compile (FAIL)"; fail=1; continue; }; \ - if timeout $(MUTANT_TIMEOUT) ./$$d/dt $$d/scratch > $$d/run.log 2>&1 && \ - timeout $(MUTANT_TIMEOUT) ./$$d/nt >> $$d/run.log 2>&1 && \ - timeout $(MUTANT_TIMEOUT) ./$$d/st >> $$d/run.log 2>&1; then \ - echo "mutant $$g: SURVIVED (FAIL)"; fail=1; \ - else echo "mutant $$g: killed"; k=$$((k+1)); fi; \ +DISK_MUT_TEST_OBJS = $(OUT)/t_disk_test.o $(OUT)/t_nvme_test.o $(OUT)/t_sdhci_test.o +$(OUT)/t_%_test.o: tests/%_test.c $(HDRS) | $(OUT) + $(CC) $(CFLAGS) -Wno-error -I. -c -o $@ $< + +mutants: $(OBJS) $(FILE_OBJ) $(DISK_MUT_TEST_OBJS) | $(OUT) + @ulimit -c 0; fail=0; n=0; k=0; \ + for g in $(GUARDS); do \ + n=$$((n+1)); d=$(OUT)/mut_$$g; rm -rf $$d; mkdir -p $$d/scratch; \ + ( f=$$(grep -l "GUARD:$$g \*/" $(SRCS)); \ + if [ $$(echo "$$f" | wc -w) -ne 1 ]; then echo "mutant $$g: guard tag missing or duplicated" > $$d/msg; echo 1 > $$d/fail; exit 0; fi; \ + if [ $$(grep -c "GUARD:$$g \*/" $$f) -ne 1 ]; then echo "mutant $$g: guard tag duplicated" > $$d/msg; echo 1 > $$d/fail; exit 0; fi; \ + sed "/GUARD:$$g \*\//d" $$f > $$d/$$f; \ + if cmp -s $$f $$d/$$f; then echo "mutant $$g: sed changed nothing (FAIL)" > $$d/msg; echo 1 > $$d/fail; exit 0; fi; \ + others=""; for s in $(SRCS); do [ "$$s" = "$$f" ] || others="$$others $(OUT)/$${s%.c}.o"; done; \ + $(CC) $(CFLAGS) -Wno-error -I. -c -o $$d/m.o $$d/$$f 2> $$d/cc.log \ + && $(CC) $(CFLAGS) -Wno-error -o $$d/dt $(OUT)/t_disk_test.o $(FILE_OBJ) $$d/m.o $$others 2>> $$d/cc.log \ + && $(CC) $(CFLAGS) -Wno-error -o $$d/nt $(OUT)/t_nvme_test.o $$d/m.o $$others 2>> $$d/cc.log \ + && $(CC) $(CFLAGS) -Wno-error -o $$d/st $(OUT)/t_sdhci_test.o $$d/m.o $$others 2>> $$d/cc.log \ + || { echo "mutant $$g: does not compile (FAIL)" > $$d/msg; echo 1 > $$d/fail; exit 0; }; \ + case "$$f" in \ + disk.c) order="dt nt st" ;; \ + disk_nvme.c) order="nt dt st" ;; \ + *) order="st dt nt" ;; \ + esac; \ + pass=1; : > $$d/run.log; \ + for b in $$order; do \ + if [ "$$b" = "dt" ]; then timeout $(MUTANT_TIMEOUT) ./$$d/dt $$d/scratch >> $$d/run.log 2>&1 || { pass=0; break; }; \ + else timeout $(MUTANT_TIMEOUT) ./$$d/$$b >> $$d/run.log 2>&1 || { pass=0; break; }; fi; \ + done; \ + if [ $$pass -eq 1 ]; then echo "mutant $$g: SURVIVED (FAIL)" > $$d/msg; echo 1 > $$d/fail; \ + else echo "mutant $$g: killed" > $$d/msg; fi \ + ) & \ + done; \ + wait; \ + for g in $(GUARDS); do \ + d=$(OUT)/mut_$$g; cat $$d/msg; \ + if [ -f $$d/fail ]; then fail=1; else k=$$((k+1)); fi; \ done; \ echo "mutants killed: $$k/$$n"; \ if [ $$fail -eq 0 ] && [ $$n -ge 10 ]; then echo "AIENOS_DISK_MUTANTS: PASS"; else echo "AIENOS_DISK_MUTANTS: FAIL"; exit 1; fi diff --git a/native/m5/.crumb b/native/m5/.crumb index 7c787da8..49d560f5 100644 --- a/native/m5/.crumb +++ b/native/m5/.crumb @@ -18,7 +18,7 @@ "children": [ { "digest": "14c3d97cc49d279cf57a819bf7aa2c75c8bcd3d0071b302f352ae6ddda74f2b6", - "last_commit": "a9d120b", + "last_commit": "1feaca1", "name": "tests", "purpose": "Directory native/m5/tests. Purpose not yet described by a human." }, @@ -30,14 +30,14 @@ } ], "children_root": "sha256:b461ac42b9135cc73e941d0acb46347321f14ed28765e041f00445bdbff7ab54", - "compiled_at": "2026-10-12T05:32:10Z", + "compiled_at": "2026-10-14T14:17:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:3883ad91cdafdb9158b14c4d8b11d4dcbfe1205ad8071c988b8f7c4b959a4004", + "digest": "sha256:8a8ec123b3898cbb63e073593baf4756abc4c0c6ab93db804937d937425f3f9a", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 13, - "generated_at_commit": "a9d120b2e91893bb80a378dc746cf0a274e42878", - "source_tree": "sha256:d76bad451b8d4bd994e32e8d58cc2584527549751edb1a8f570d9bc87c194cf9" + "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", + "source_tree": "sha256:4f597bb3c2d1d47d81d1d9caa658e6b72b9450184e0c663fb48d62dbfca44a4b" }, "owner_lane": "", "provenance": { diff --git a/native/m5/Makefile b/native/m5/Makefile index 3d2a07c2..3da70600 100644 --- a/native/m5/Makefile +++ b/native/m5/Makefile @@ -101,21 +101,37 @@ GUARDS = class-in-kdf slot-empty slot-check slot-suite slot-kdf slot-flags secma osig-self osig-source osig-dest osig-agent osig-gen osig-format osig-envcount osig-envset \ osig-manifest osig-ownergen osig-replay osig-bind-manifest osig-bind-counter -mutants: | $(OUT) - @ulimit -c 0; fail=0; for g in $(GUARDS); do \ - f=$$(grep -l "GUARD:$$g \*/" $(SRCS)); \ - if [ $$(echo "$$f" | wc -w) -ne 1 ]; then echo "mutant $$g: guard tag missing or duplicated"; fail=1; continue; fi; \ - if [ $$(grep -c "GUARD:$$g \*/" $$f) -ne 1 ]; then echo "mutant $$g: guard tag duplicated"; fail=1; continue; fi; \ - mkdir -p $(OUT)/mut_$$g; \ - for s in $(SRCS); do if [ $$s = $$f ]; then sed "/GUARD:$$g \*\//d" $$s > $(OUT)/mut_$$g/$$s; else cp $$s $(OUT)/mut_$$g/$$s; fi; done; \ - $(CC) $(CFLAGS) -Wno-error -I. -o $(OUT)/mut_$$g/t tests/m5_test.c \ - $(addprefix $(OUT)/mut_$$g/,$(SRCS)) $(CRYPTO_SRCS) $(SIG_SRCS) ../argus/sha256.c 2> $(OUT)/mut_$$g/cc.log \ - && $(CC) $(CFLAGS) -Wno-error -I. -o $(OUT)/mut_$$g/t2 tests/m5_migsig_test.c \ - $(addprefix $(OUT)/mut_$$g/,$(SRCS)) $(CRYPTO_SRCS) $(SIG_SRCS) ../argus/sha256.c 2>> $(OUT)/mut_$$g/cc.log \ - || { echo "mutant $$g: does not compile (FAIL)"; fail=1; continue; }; \ - if ./$(OUT)/mut_$$g/t > $(OUT)/mut_$$g/run.log 2>&1 && ./$(OUT)/mut_$$g/t2 >> $(OUT)/mut_$$g/run.log 2>&1; then \ - echo "mutant $$g: SURVIVED (FAIL)"; fail=1; \ - else echo "mutant $$g: killed"; fi; \ +M5_MUT_TEST_OBJS = $(OUT)/t_m5_test.o $(OUT)/t_m5_migsig_test.o +$(OUT)/t_%_test.o: tests/%_test.c $(HDRS) | $(OUT) + $(CC) $(CFLAGS) -Wno-error -I. -c -o $@ $< + +mutants: $(OBJS) $(DEP_OBJS) $(M5_MUT_TEST_OBJS) | $(OUT) + @ulimit -c 0; fail=0; \ + for g in $(GUARDS); do \ + d=$(OUT)/mut_$$g; rm -rf $$d; mkdir -p $$d; \ + ( f=$$(grep -l "GUARD:$$g \*/" $(SRCS)); \ + if [ $$(echo "$$f" | wc -w) -ne 1 ]; then echo "mutant $$g: guard tag missing or duplicated" > $$d/msg; echo 1 > $$d/fail; exit 0; fi; \ + if [ $$(grep -c "GUARD:$$g \*/" $$f) -ne 1 ]; then echo "mutant $$g: guard tag duplicated" > $$d/msg; echo 1 > $$d/fail; exit 0; fi; \ + sed "/GUARD:$$g \*\//d" $$f > $$d/$$f; \ + others=""; for s in $(SRCS); do [ "$$s" = "$$f" ] || others="$$others $(OUT)/$${s%.c}.o"; done; \ + $(CC) $(CFLAGS) -Wno-error -I. -c -o $$d/m.o $$d/$$f 2> $$d/cc.log \ + && $(CC) $(CFLAGS) -Wno-error -o $$d/t $(OUT)/t_m5_test.o $$d/m.o $$others $(DEP_OBJS) 2>> $$d/cc.log \ + && $(CC) $(CFLAGS) -Wno-error -o $$d/t2 $(OUT)/t_m5_migsig_test.o $$d/m.o $$others $(DEP_OBJS) 2>> $$d/cc.log \ + || { echo "mutant $$g: does not compile (FAIL)" > $$d/msg; echo 1 > $$d/fail; exit 0; }; \ + case "$$f" in \ + m5_owner_sig.c) order="t2 t" ;; \ + *) order="t t2" ;; \ + esac; \ + pass=1; : > $$d/run.log; \ + for b in $$order; do ./$$d/$$b >> $$d/run.log 2>&1 || { pass=0; break; }; done; \ + if [ $$pass -eq 1 ]; then echo "mutant $$g: SURVIVED (FAIL)" > $$d/msg; echo 1 > $$d/fail; \ + else echo "mutant $$g: killed" > $$d/msg; fi \ + ) & \ + done; \ + wait; \ + for g in $(GUARDS); do \ + d=$(OUT)/mut_$$g; cat $$d/msg; \ + [ ! -f $$d/fail ] || fail=1; \ done; \ if [ $$fail -eq 0 ]; then echo "M5_NATIVE_MUTANTS: PASS"; else echo "M5_NATIVE_MUTANTS: FAIL"; exit 1; fi diff --git a/native/net/.crumb b/native/net/.crumb index 4c22cfbf..99352810 100644 --- a/native/net/.crumb +++ b/native/net/.crumb @@ -30,14 +30,14 @@ } ], "children_root": "sha256:72c6a05fd3be86ab3a6985c3b1d9ed75262d875773aff4440ec13869435108cc", - "compiled_at": "2026-10-04T13:47:18Z", + "compiled_at": "2026-10-14T14:17:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:c91e9201f6ce9cb909ce3fadfa60d4869fc661db8d4266cd2c15e0688d384cf7", + "digest": "sha256:370c8b53b1041e4db242950e1be4667c260fbaba7d7bfe397ffe73775f71af6b", "evidence_files": 4, "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335", "files": 29, - "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512", - "source_tree": "sha256:e5d6692edc46704b3aa288eb662ad1c6c51b6bdd8a289ac757626ab8c25ead11" + "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", + "source_tree": "sha256:13089e10600f3393e8d0b493839bfd55e6e0344656c874f77c0e0e954d02274c" }, "owner_lane": "", "provenance": { diff --git a/native/net/Makefile b/native/net/Makefile index 84718e4d..b1757bf8 100644 --- a/native/net/Makefile +++ b/native/net/Makefile @@ -141,23 +141,40 @@ endif # the M6-B sources and the Lane 19 resend jitter in aienos_ctl.c; the X25519, # secure transport and control-transport tests must then fail. A # mutant that compiles and passes all three tests SURVIVED, and fails this target. -mutants: | $(OUT) - @killed=0; total=0; survived=""; \ +NET_MUT_TEST_OBJS = $(OUT)/t_x25519_test.o $(OUT)/t_sec_test.o $(OUT)/t_ctl_test.o +$(OUT)/t_%_test.o: tests/%_test.c $(wildcard *.h) | $(OUT) + $(CC) $(CFLAGS) -Wno-error -I. -c -o $@ $< + +mutants: $(OBJS) $(NET_MUT_TEST_OBJS) | $(OUT) + @killed=0; total=0; survived=""; pids=""; list=""; \ for f in $(SEC_GUARD_FILES); do \ for g in $$(grep -o 'GUARD:[a-z0-9-]*' $$f | cut -d: -f2); do \ - total=$$((total+1)); mdir=$(OUT)/mut_$$g; mkdir -p $$mdir; \ - for s in $(SRCS); do cp $$s $$mdir/; done; cp *.h $$mdir/; \ - sed "/GUARD:$$g \*\//d" $$f > $$mdir/$$f; \ - if cmp -s $$f $$mdir/$$f; then echo "mutant $$g: guard line not found"; survived="$$survived $$g"; continue; fi; \ - if ! $(CC) $(CFLAGS) -Wno-error -I. -o $$mdir/x25519_t tests/x25519_test.c $$(for s in $(SRCS); do echo $$mdir/$$s; done) $(DEP_SRCS) 2>/dev/null || \ - ! $(CC) $(CFLAGS) -Wno-error -I. -o $$mdir/sec_t tests/sec_test.c $$(for s in $(SRCS); do echo $$mdir/$$s; done) $(DEP_SRCS) 2>/dev/null || \ - ! $(CC) $(CFLAGS) -Wno-error -I. -o $$mdir/ctl_t tests/ctl_test.c $$(for s in $(SRCS); do echo $$mdir/$$s; done) $(DEP_SRCS) 2>/dev/null; then \ - echo "mutant $$g: does not compile (counts as not killed)"; survived="$$survived $$g"; continue; fi; \ - if ./$$mdir/x25519_t >/dev/null 2>&1 && ./$$mdir/sec_t >/dev/null 2>&1 && ./$$mdir/ctl_t >/dev/null 2>&1; then \ - echo "mutant $$g: SURVIVED"; survived="$$survived $$g"; \ - else echo "mutant $$g: killed"; killed=$$((killed+1)); fi; \ + total=$$((total+1)); mdir=$(OUT)/mut_$$g; rm -rf $$mdir; mkdir -p $$mdir; list="$$list $$g"; \ + ( cp *.h $$mdir/; \ + sed "/GUARD:$$g \*\//d" $$f > $$mdir/$$f; \ + if cmp -s $$f $$mdir/$$f; then echo "mutant $$g: guard line not found" > $$mdir/msg; echo "$$g" > $$mdir/surv; exit 0; fi; \ + others=""; for s in $(SRCS); do [ "$$s" = "$$f" ] || others="$$others $(OUT)/$${s%.c}.o"; done; \ + if ! $(CC) $(CFLAGS) -Wno-error -I. -c -o $$mdir/m.o $$mdir/$$f 2>/dev/null || \ + ! $(CC) $(CFLAGS) -Wno-error -o $$mdir/x25519_t $(OUT)/t_x25519_test.o $$mdir/m.o $$others $(DEP_OBJS) 2>/dev/null || \ + ! $(CC) $(CFLAGS) -Wno-error -o $$mdir/sec_t $(OUT)/t_sec_test.o $$mdir/m.o $$others $(DEP_OBJS) 2>/dev/null || \ + ! $(CC) $(CFLAGS) -Wno-error -o $$mdir/ctl_t $(OUT)/t_ctl_test.o $$mdir/m.o $$others $(DEP_OBJS) 2>/dev/null; then \ + echo "mutant $$g: does not compile (counts as not killed)" > $$mdir/msg; echo "$$g" > $$mdir/surv; exit 0; fi; \ + case "$$f" in \ + x25519.c) order="$$mdir/x25519_t $$mdir/sec_t $$mdir/ctl_t" ;; \ + aienos_sec.c) order="$$mdir/sec_t $$mdir/x25519_t $$mdir/ctl_t" ;; \ + *) order="$$mdir/ctl_t $$mdir/x25519_t $$mdir/sec_t" ;; \ + esac; \ + pass=1; for b in $$order; do if ! ./$$b >/dev/null 2>&1; then pass=0; break; fi; done; \ + if [ $$pass -eq 1 ]; then echo "mutant $$g: SURVIVED" > $$mdir/msg; echo "$$g" > $$mdir/surv; \ + else echo "mutant $$g: killed" > $$mdir/msg; fi \ + ) & \ done; \ done; \ + wait; \ + for g in $$list; do \ + mdir=$(OUT)/mut_$$g; cat $$mdir/msg; \ + if [ -f $$mdir/surv ]; then survived="$$survived $$g"; else killed=$$((killed+1)); fi; \ + done; \ echo "NET_SECURE_MUTANTS: $$killed/$$total killed"; \ [ -z "$$survived" ] && [ $$total -ge 12 ] || { echo "NET_SECURE_MUTANTS: FAIL (not killed:$$survived)"; exit 1; } diff --git a/native/sig/.crumb b/native/sig/.crumb index 559877a2..95c9dfda 100644 --- a/native/sig/.crumb +++ b/native/sig/.crumb @@ -20,14 +20,14 @@ } ], "children_root": "sha256:2c318acd4ff46092a89eec7b6b1f764bdc91bb6428427fffa9b04f05753be9fd", - "compiled_at": "2026-10-04T13:47:18Z", + "compiled_at": "2026-10-14T14:17:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:295150763e0b19f9f74a3b49d679213467075e9682f1f23d0e5ea838872d20e1", + "digest": "sha256:531200647a05b2f1b7da7d7bcd012461a6988ff9c8ec5b9f4a888c7ee4f8f8cf", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 10, - "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512", - "source_tree": "sha256:a75148cfdf71f99296a21640ad3cd979132d28df47879301c198da0f2f4b7a5a" + "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", + "source_tree": "sha256:ebdccd9ffc2d84538089299d04b4836364643d80d57ac1182861d362d7049244" }, "owner_lane": "", "provenance": { diff --git a/native/sig/Makefile b/native/sig/Makefile index 77275fc0..d7c28b1b 100644 --- a/native/sig/Makefile +++ b/native/sig/Makefile @@ -60,17 +60,28 @@ MUTANTS = sha512.c:sha-pad sha512.c:sha-len \ ed25519.c:sc-sub ed25519.c:s-range ed25519.c:a-small-order ed25519.c:r-small-order \ ed25519.c:r-check -mutants: | $(OUT) - @ulimit -c 0; fail=0; n=0; for m in $(MUTANTS); do \ +$(OUT)/t_sig_test.o: tests/sig_test.c $(TEST_HDRS) $(HDRS) | $(OUT) + $(CC) $(CFLAGS) -Wno-error -I. -c -o $@ $< + +mutants: $(OBJS) $(OUT)/t_sig_test.o | $(OUT) + @ulimit -c 0; fail=0; n=0; \ + for m in $(MUTANTS); do \ f=$${m%%:*}; g=$${m#*:}; n=$$((n+1)); \ - grep -q "GUARD:$$g \*/" $$f || { echo "mutant $$g: guard tag missing"; fail=1; continue; }; \ - sed "/GUARD:$$g \*\//d" $$f > $(OUT)/mut_$$g.c; \ - others=$$(for s in $(SRCS); do [ $$s = $$f ] || echo $$s; done); \ - $(CC) $(CFLAGS) -Wno-error -I. -o $(OUT)/mut_$$g tests/sig_test.c $(OUT)/mut_$$g.c $$others \ - || { fail=1; continue; }; \ - if ./$(OUT)/mut_$$g > $(OUT)/mut_$$g.log 2>&1; then \ - echo "mutant $$g: SURVIVED (FAIL)"; fail=1; \ - else echo "mutant $$g: killed"; fi; \ + ( grep -q "GUARD:$$g \*/" $$f || { echo "mutant $$g: guard tag missing" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; exit 0; }; \ + sed "/GUARD:$$g \*\//d" $$f > $(OUT)/mut_$$g.c; \ + others=$$(for s in $(SRCS); do [ $$s = $$f ] || echo $(OUT)/$${s%.c}.o; done); \ + $(CC) $(CFLAGS) -Wno-error -I. -c -o $(OUT)/mut_$$g.o $(OUT)/mut_$$g.c \ + && $(CC) $(CFLAGS) -Wno-error -o $(OUT)/mut_$$g $(OUT)/t_sig_test.o $(OUT)/mut_$$g.o $$others \ + || { echo "mutant $$g: does not compile" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; exit 0; }; \ + if ./$(OUT)/mut_$$g > $(OUT)/mut_$$g.log 2>&1; then \ + echo "mutant $$g: SURVIVED (FAIL)" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; \ + else echo "mutant $$g: killed" > $(OUT)/mut_$$g.msg; fi \ + ) & \ + done; \ + wait; \ + for m in $(MUTANTS); do \ + g=$${m#*:}; cat $(OUT)/mut_$$g.msg; \ + if [ -f $(OUT)/mut_$$g.fail ]; then fail=1; rm -f $(OUT)/mut_$$g.fail; fi; \ done; \ if [ $$fail -eq 0 ]; then echo "AIENOS_SIG_MUTANTS: PASS ($$n/$$n killed)"; else echo "AIENOS_SIG_MUTANTS: FAIL"; exit 1; fi diff --git a/native/store/.crumb b/native/store/.crumb index 1e437996..ff7e1ca8 100644 --- a/native/store/.crumb +++ b/native/store/.crumb @@ -14,20 +14,20 @@ "children": [ { "digest": "0a09ffa7f22b22f32d3c23ca76645b1858d972e8575c3236120f0b747c856c05", - "last_commit": "56d125f", + "last_commit": "22eb360", "name": "tests", "purpose": "Directory native/store/tests. Purpose not yet described by a human." } ], "children_root": "sha256:24a9259b30657d17f3cab3901246fb8cd28441d8a929839fd58a86aa951a66a3", - "compiled_at": "2026-10-12T10:28:17Z", + "compiled_at": "2026-10-14T14:17:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:eeec17e754d15d5723d77d953711620c568c160f47e6c90a4c927c85ec5bb32d", + "digest": "sha256:afee8b21a480493ada6062451cb53deb08ad3441978653f1bc9f41ac727c8a6c", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 22, - "generated_at_commit": "56d125f12abf2b8ba2886d6da4d86fda8dd244b3", - "source_tree": "sha256:b243a2c9f993a61cda3bd5602ae99a6f22e954a37e85d20a92c4c90b13ba5368" + "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", + "source_tree": "sha256:689d3dedcb0160db58a09ae48098e25d1229ec499599becdfece59aaa35556e2" }, "owner_lane": "", "provenance": { diff --git a/native/store/Makefile b/native/store/Makefile index 37432948..4593833e 100644 --- a/native/store/Makefile +++ b/native/store/Makefile @@ -131,34 +131,57 @@ GUARDS = parity-a parity-b b-needs-a adjacent first-remnant a-alone-seq1 mutants: torn-slot-mutants store-mutants -torn-slot-mutants: | $(OUT) - @fail=0; for g in $(GUARDS); do \ - grep -q "GUARD:$$g \*/" torn_slot.c || { echo "mutant $$g: guard tag missing"; fail=1; continue; }; \ - sed "/GUARD:$$g \*\//d" torn_slot.c > $(OUT)/mut_$$g.c; \ - $(CC) $(CFLAGS) -Wno-error -I. -o $(OUT)/mut_$$g tests/torn_slot_test.c $(OUT)/mut_$$g.c ../argus/sha256.c || { fail=1; continue; }; \ - if ./$(OUT)/mut_$$g --rules-only > $(OUT)/mut_$$g.log 2>&1; then \ - echo "mutant $$g: SURVIVED (FAIL)"; fail=1; \ - else echo "mutant $$g: killed"; fi; \ +$(OUT)/t_torn_slot_test.o: tests/torn_slot_test.c torn_slot.h ../argus/sha256.h | $(OUT) + $(CC) $(CFLAGS) -Wno-error -I. -c -o $@ $< + +torn-slot-mutants: $(OUT)/t_torn_slot_test.o $(OUT)/sha256.o | $(OUT) + @fail=0; \ + for g in $(GUARDS); do \ + ( grep -q "GUARD:$$g \*/" torn_slot.c || { echo "mutant $$g: guard tag missing" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; exit 0; }; \ + sed "/GUARD:$$g \*\//d" torn_slot.c > $(OUT)/mut_$$g.c; \ + $(CC) $(CFLAGS) -Wno-error -I. -c -o $(OUT)/mut_$$g.o $(OUT)/mut_$$g.c \ + && $(CC) $(CFLAGS) -Wno-error -o $(OUT)/mut_$$g $(OUT)/t_torn_slot_test.o $(OUT)/mut_$$g.o $(OUT)/sha256.o \ + || { echo "mutant $$g: does not compile" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; exit 0; }; \ + if ./$(OUT)/mut_$$g --rules-only > $(OUT)/mut_$$g.log 2>&1; then \ + echo "mutant $$g: SURVIVED (FAIL)" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; \ + else echo "mutant $$g: killed" > $(OUT)/mut_$$g.msg; fi \ + ) & \ + done; \ + wait; \ + for g in $(GUARDS); do \ + cat $(OUT)/mut_$$g.msg; \ + if [ -f $(OUT)/mut_$$g.fail ]; then fail=1; rm -f $(OUT)/mut_$$g.fail; fi; \ done; \ if [ $$fail -eq 0 ]; then echo "TORN_SLOT_MUTANTS: PASS"; else echo "TORN_SLOT_MUTANTS: FAIL"; exit 1; fi STORE_GUARDS = $(shell grep -ho 'GUARD:[a-z0-9-]* \*/' $(STORE_SRCS) | sed 's/GUARD://; s/ \*\///') store-mutants: $(STORE_OBJS) $(TEST_OBJS) $(DEP_OBJS) $(OUT)/torn_slot.o $(HOST_OBJS) - @mkdir -p $(OUT)/mut; fail=0; total=0; killed=0; \ + @fail=0; total=0; killed=0; \ + for g in $(STORE_GUARDS); do \ + total=$$((total + 1)); d=$(OUT)/mut_$$g; rm -rf $$d; mkdir -p $$d; \ + ( f=$$(grep -l "GUARD:$$g \*/" $(STORE_SRCS)); \ + [ $$(echo $$f | wc -w) -eq 1 ] || { echo "mutant $$g: tag not unique ($$f)" > $$d/msg; echo 1 > $$d/fail; exit 0; }; \ + sed "/GUARD:$$g \*\//d" $$f > $$d/$$f; \ + $(CC) $(CFLAGS) -Wno-error $(INC) -c -o $$d/m.o $$d/$$f 2>/dev/null || { echo "mutant $$g: does not compile" > $$d/msg; echo 1 > $$d/fail; exit 0; }; \ + objs=""; for s in $(STORE_SRCS); do [ $$s = $$f ] || objs="$$objs $(OUT)/$${s%.c}.o"; done; \ + case "$$f" in \ + store_v1.c) order="store_v1_test store_engine_test store_sealed_test store_powercut_test" ;; \ + store_sealed.c) order="store_sealed_test store_powercut_test store_engine_test store_v1_test" ;; \ + *) order="store_engine_test store_v1_test store_sealed_test store_powercut_test" ;; \ + esac; \ + dead=0; by=""; \ + for t in $$order; do \ + $(CC) $(CFLAGS) -o $$d/$$t $(OUT)/t_$$t.o $$d/m.o $$objs $(OUT)/torn_slot.o $(DEP_OBJS) $(HOST_OBJS) || { dead=2; break; }; \ + if ! ./$$d/$$t $$d > $$d/$$g.log 2>&1; then dead=1; by="$$t"; break; fi; \ + done; \ + if [ $$dead -eq 1 ]; then echo "mutant $$g ($$f): killed by $$by" > $$d/msg; \ + else echo "mutant $$g ($$f): SURVIVED (FAIL)" > $$d/msg; echo 1 > $$d/fail; fi \ + ) & \ + done; \ + wait; \ for g in $(STORE_GUARDS); do \ - total=$$((total + 1)); \ - f=$$(grep -l "GUARD:$$g \*/" $(STORE_SRCS)); \ - [ $$(echo $$f | wc -w) -eq 1 ] || { echo "mutant $$g: tag not unique ($$f)"; fail=1; continue; }; \ - sed "/GUARD:$$g \*\//d" $$f > $(OUT)/mut/$$f; \ - $(CC) $(CFLAGS) -Wno-error $(INC) -c -o $(OUT)/mut/m.o $(OUT)/mut/$$f || { echo "mutant $$g: does not compile"; fail=1; continue; }; \ - objs=""; for s in $(STORE_SRCS); do [ $$s = $$f ] || objs="$$objs $(OUT)/$${s%.c}.o"; done; \ - dead=0; \ - for t in $(TEST_NAMES); do \ - $(CC) $(CFLAGS) -o $(OUT)/mut/$$t $(OUT)/t_$$t.o $(OUT)/mut/m.o $$objs $(OUT)/torn_slot.o $(DEP_OBJS) $(HOST_OBJS) || { dead=2; break; }; \ - if ! ./$(OUT)/mut/$$t $(OUT)/mut > $(OUT)/mut/$$g.log 2>&1; then dead=1; break; fi; \ - done; \ - if [ $$dead -eq 1 ]; then echo "mutant $$g ($$f): killed by $$t"; killed=$$((killed + 1)); \ - else echo "mutant $$g ($$f): SURVIVED (FAIL)"; fail=1; fi; \ + d=$(OUT)/mut_$$g; cat $$d/msg; \ + if [ -f $$d/fail ]; then fail=1; else killed=$$((killed + 1)); fi; \ done; \ echo "store mutants: $$killed of $$total killed"; \ if [ $$fail -eq 0 ] && [ $$total -ge 12 ]; then echo "AIENOS_STORE_MUTANTS: PASS"; else echo "AIENOS_STORE_MUTANTS: FAIL"; exit 1; fi From 1800c4e63db021d48633309bf211f13404067ebe Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Wed, 14 Oct 2026 10:23:37 -0500 Subject: [PATCH 2/2] fix(native,allen-reflex): make parallel mutant tallies fail closed; fix ALLEN Tower keying Parallel C mutant sweeps (native/{capability,crypto,disk,m5,net,sig,store}): - A mutant now counts as killed only when its job wrote an explicit "killed" marker. Before, a job that died before writing any result was tallied as killed (crypto negative control: a job killed mid-run printed AIENOS_CRYPTO_MUTANTS: PASS; it now prints FAIL). - Stale per-mutant result files from an earlier run are removed before the sweep (crypto, sig, torn-slot keep them flat in out/). - Duplicate guard names are refused up front: two parallel jobs with one name would share one work directory. - store: store mutants work in out/smut_, separate from the torn-slot mutants' out/mut_ files, so `make -j mutants` cannot mix them. - disk: MUTANT_TIMEOUT back to 60 s. A timeout counts as a kill, so the 5 s value could turn a slow (loaded machine) survivor into a false kill. allen_reflex::tower: - Receipts and in-flight runs are keyed by (gate, tier, input_digest): a PASS from one tier (e.g. the labelled Pi test tier) is never reused for another. - JoinInflight slots are stable (fixed slot table); before, a slot index shifted when an earlier run completed and could point at another gate. - Uncacheable gates are never joined to another run. - combine_mneme_digest is SHA-256 (in-repo aienos-crypto) over a domain-separated, length-prefixed encoding; the previous mix was trivially invertible. Test vector computed independently with coreutils sha256sum. - to_json escapes the gate name. - Module docs state it is a library only, not yet linked into any kernel or runner. Crumbs recompiled with the pinned crumb tool (crumb.lock) on a clean tree. Co-Authored-By: Claude Opus 5.5 --- .crumb | 20 +- Cargo.lock | 3 + crates/.crumb | 10 +- crates/allen-reflex/Cargo.toml | 3 + crates/allen-reflex/src/lib.rs | 5 +- crates/allen-reflex/src/tower.rs | 369 +++++++++++++++++++++---------- native/.crumb | 38 ++-- native/capability/.crumb | 8 +- native/capability/Makefile | 11 +- native/crypto/.crumb | 8 +- native/crypto/Makefile | 9 +- native/disk/.crumb | 8 +- native/disk/Makefile | 11 +- native/m5/.crumb | 8 +- native/m5/Makefile | 9 +- native/net/.crumb | 8 +- native/net/Makefile | 10 +- native/sig/.crumb | 8 +- native/sig/Makefile | 10 +- native/store/.crumb | 8 +- native/store/Makefile | 24 +- 21 files changed, 384 insertions(+), 204 deletions(-) diff --git a/.crumb b/.crumb index 0ccb6d4a..886d9d8d 100644 --- a/.crumb +++ b/.crumb @@ -21,8 +21,8 @@ "generated": { "children": [ { - "digest": "54d65ab06d6d4d4b9eb7f0580e9533f6402e5b0cfa290a32178d3307db0d90eb", - "last_commit": "2951ea1", + "digest": "b5ced6fea583b485206b73ec08b91de68a5cfd2672ac448191831754c9e0907d", + "last_commit": "596870d", "name": "crates", "purpose": "Directory crates. Purpose not yet described by a human." }, @@ -33,8 +33,8 @@ "purpose": "Directory docs. Purpose not yet described by a human." }, { - "digest": "c892bb8ae2aabd5566432f63d72f6937cf36d0e20f36bfae5f838238a89bcedd", - "last_commit": "f5c90e7", + "digest": "36e7b840be2a09ca3829e87caa6c20bbc2ac1dd96b57b5037ffdf3c23514be4e", + "last_commit": "596870d", "name": "native", "purpose": "Directory native. Purpose not yet described by a human." }, @@ -45,15 +45,15 @@ "purpose": "Directory scripts. Purpose not yet described by a human." } ], - "children_root": "sha256:b6d0862da67164153aa48f4e9efa007268d6ea7063132c7d14fb9f10a3a25bfc", - "compiled_at": "2026-10-14T14:17:07Z", + "children_root": "sha256:bc2942f3b74d8955d6f64b3b23b32d07968ecebead0fdd812354d8605a6b2092", + "compiled_at": "2026-10-14T14:58:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:2855ef7e0d08a2385f4d2913155dc8c24d5574cdb03bd172e34203a79009f646", + "digest": "sha256:0f52ccba14b1dcae9ea1bc645da446a3514b7b56343985798a6ce4c382d7b59e", "evidence_files": 183, "evidence_root": "sha256:9ac286aca0d673f856463c2a1541854df773bfe792792e6b82b7cb7a47cd17cc", - "files": 3421, - "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", - "source_tree": "sha256:aa43b39e9ca3d3f2cb6c4542d571a8de8164ae20fe8a4aa7c80fd073cc681e18" + "files": 3422, + "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84", + "source_tree": "sha256:faf037d68527df001e15b6ac2738ca5debd0413004019e2b1eab99a0eb87b1cc" }, "owner_lane": "", "provenance": { diff --git a/Cargo.lock b/Cargo.lock index e7f5fb7a..d7261e66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -134,6 +134,9 @@ dependencies = [ [[package]] name = "allen-reflex" version = "0.1.0" +dependencies = [ + "aienos-crypto", +] [[package]] name = "base64ct" diff --git a/crates/.crumb b/crates/.crumb index f71b2c36..6f56e027 100644 --- a/crates/.crumb +++ b/crates/.crumb @@ -150,14 +150,14 @@ } ], "children_root": "sha256:ca16d018c0c02840ba1f87e2a7b64ed259a36253ed29230f274ebcabb43c8a7e", - "compiled_at": "2026-10-14T14:17:07Z", + "compiled_at": "2026-10-14T14:58:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:54d65ab06d6d4d4b9eb7f0580e9533f6402e5b0cfa290a32178d3307db0d90eb", + "digest": "sha256:b5ced6fea583b485206b73ec08b91de68a5cfd2672ac448191831754c9e0907d", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 267, - "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", - "source_tree": "sha256:573af20504e6f43ca144bea4aeb5cc0fbb8fbd6f30a16171933296f196a85776" + "files": 268, + "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84", + "source_tree": "sha256:cc0bfe148dc436da2bb46428408257fbc55e5643cf516241a3e9021656c5fc2c" }, "owner_lane": "", "provenance": { diff --git a/crates/allen-reflex/Cargo.toml b/crates/allen-reflex/Cargo.toml index ea2f33fd..b95b12a9 100644 --- a/crates/allen-reflex/Cargo.toml +++ b/crates/allen-reflex/Cargo.toml @@ -9,3 +9,6 @@ description = "ALLEN REFLEX: no_std hypervector decision core that maps an opera [lib] path = "src/lib.rs" + +[dependencies] +aienos-crypto = { workspace = true } diff --git a/crates/allen-reflex/src/lib.rs b/crates/allen-reflex/src/lib.rs index 6acacce3..03c91f45 100644 --- a/crates/allen-reflex/src/lib.rs +++ b/crates/allen-reflex/src/lib.rs @@ -19,8 +19,9 @@ //! 6. Abstention: low similarity, low margin or low neighbour agreement -> `clarify`/`none`. //! 7. [`span`]: copy the argument text (1..48 printable ASCII bytes) or answer `clarify`. //! -//! The crate is `no_std` + `alloc` with no dependencies. A kernel that links it must -//! provide a global allocator and a panic handler. Every input is bounded (see [`Config`]). +//! The crate is `no_std` + `alloc`; its only dependency is the in-repo `aienos-crypto` +//! (SHA-256 for [`tower`] cache keys). A kernel that links it must provide a global +//! allocator and a panic handler. Every input is bounded (see [`Config`]). extern crate alloc; #[cfg(test)] diff --git a/crates/allen-reflex/src/tower.rs b/crates/allen-reflex/src/tower.rs index eb90053d..1286d130 100644 --- a/crates/allen-reflex/src/tower.rs +++ b/crates/allen-reflex/src/tower.rs @@ -1,15 +1,24 @@ -//! ALLEN Tower: Pi 5 bare-metal AIENOS test & verification orchestrator core. +//! ALLEN Tower: scheduling core for a Pi 5 bare-metal AIENOS test and verification orchestrator. //! -//! Pairs the persistent 8 GB Raspberry Pi 5 (booting bare-metal AIENOS + ALLEN REFLEX) -//! with DGX Spark ("Spark Forge"): -//! - Reuses content-addressed PASS receipts across commits when `(gate, input_digest)` matches. -//! - Folds observed Mneme (`libmneme.so`) file-read digests and sibling pins into `input_digest`. -//! - Deduplicates concurrent identical `(gate, input_digest)` requests in-flight (`JoinInflight`). -//! - Routes `Portable` and `Pi5Host` gates to local Pi 5 Cortex-A76 cores (`RunPi5Local`), -//! `SparkHost` and `SparkQemu` gates to Spark's 20-core host pool (`DispatchSparkHost`), -//! and `SparkGb10` / `SparkNvrm` gates to Spark's serialized GPU queue (`QueueSparkGb10`). +//! Intended pairing: the persistent 8 GB Raspberry Pi 5 (bare-metal AIENOS + ALLEN REFLEX) +//! with the DGX Spark. Status: library only. Nothing links this module into the Pi kernel or +//! any test runner yet, and no Pi or Spark run has exercised it. +//! +//! Rules this core enforces: +//! - A PASS receipt is reused only for the exact `(gate, tier, input_digest)` it was recorded +//! for, and only for gates marked cacheable. A receipt from one tier (for example the +//! labelled Pi test tier) never stands in for another tier. +//! - `input_digest` is meant to come from [`combine_mneme_digest`]: SHA-256 over the declared +//! inputs, the sibling pins and every observed Mneme (`libmneme.so`) file-read digest. +//! - Concurrent identical cacheable requests join the run already in flight (`JoinInflight`). +//! Uncacheable gates always run on their own. +//! - Routing: `Portable` and `Pi5Host` gates run on the Pi 5 (`RunPi5Local`), `SparkHost` and +//! `SparkQemu` gates go to the Spark host pool (`DispatchSparkHost`), and `SparkGb10` / +//! `SparkNvrm` gates go to the Spark's one-at-a-time GPU queue (`QueueSparkGb10`). +use aienos_crypto::sha256::Sha256; use alloc::string::String; +use alloc::vec; use alloc::vec::Vec; /// Execution tier for a verification gate. @@ -41,9 +50,10 @@ pub struct GateSpec { /// Orchestrator action emitted by ALLEN Tower. #[derive(Clone, PartialEq, Eq, Debug)] pub enum TowerAction { - /// Exact `(gate, input_digest)` already has a verified PASS receipt. + /// Exact `(gate, tier, input_digest)` already has a verified PASS receipt. ReuseReceipt { receipt_digest: [u8; 32] }, - /// Identical `(gate, input_digest)` is currently running in slot `slot`; join its result. + /// Identical `(gate, tier, input_digest)` is running in slot `slot`; join its result. + /// The slot number stays the same until that run is completed. JoinInflight { slot: usize }, /// Execute locally on the persistent Pi 5 orchestrator node. RunPi5Local, @@ -99,12 +109,12 @@ pub struct TowerDecision { } impl TowerDecision { - /// Format as a single-line canonical JSON decision record. + /// Format as a single-line JSON decision record. The gate name is JSON-escaped. pub fn to_json(&self) -> String { let mut out = String::from(r#"{"tower_action":""#); out.push_str(self.action.name()); out.push_str(r#"","gate":""#); - out.push_str(&self.gate); + push_json_escaped(&mut out, &self.gate); out.push_str(r#"","why":""#); out.push_str(self.why.name()); out.push_str(r#""}"#); @@ -112,82 +122,95 @@ impl TowerDecision { } } -/// Combine declared input digest, sibling pin digest, and Mneme observed read-set digests -/// into a single 32-byte effective cache key (`no_std`, order-sensitive, domain-separated). +fn push_json_escaped(out: &mut String, s: &str) { + const HEX: &[u8; 16] = b"0123456789abcdef"; + for c in s.chars() { + match c { + '"' => out.push_str("\\\""), + '\\' => out.push_str("\\\\"), + '\n' => out.push_str("\\n"), + '\r' => out.push_str("\\r"), + '\t' => out.push_str("\\t"), + c if (c as u32) < 0x20 => { + let b = c as u32 as u8; + out.push_str("\\u00"); + out.push(HEX[(b >> 4) as usize] as char); + out.push(HEX[(b & 0xf) as usize] as char); + } + c => out.push(c), + } + } +} + +/// Domain tag that starts every cache-key encoding (NUL-terminated). +const INPUT_DOMAIN: &[u8] = b"ALLEN-TOWER-INPUT-V1\0"; + +/// Combine the declared input digest, the sibling pin digest and the Mneme observed +/// read-set digests into one 32-byte cache key. +/// +/// Key = SHA-256(`"ALLEN-TOWER-INPUT-V1\0"` || declared || pins || read count as u64 LE || +/// each read digest in order). Every field has a fixed size and the count is explicit, so two +/// different inputs never share an encoding; the order of the reads matters. pub fn combine_mneme_digest( declared_inputs: &[u8; 32], sibling_pins: &[u8; 32], mneme_reads: &[[u8; 32]], ) -> [u8; 32] { - let mut state = [0u64; 4]; - let seeds: [u64; 4] = [ - 0x6a09e667f3bcc908, - 0xbb67ae8584caa73b, - 0x3c6ef372fe94f82b, - 0xa54ff53a5f1d36f1, - ]; - state.copy_from_slice(&seeds); - - fn absorb(st: &mut [u64; 4], tag: u64, block: &[u8; 32]) { - st[0] ^= tag; - for i in 0..4 { - let mut w = 0u64; - for b in 0..8 { - w = (w << 8) | (block[i * 8 + b] as u64); - } - st[i] = st[i].wrapping_add(w).wrapping_mul(0x9e3779b97f4a7c15); - st[i] = st[i].rotate_left(27) ^ st[(i + 1) & 3]; - } - } - - absorb(&mut state, 0x4445434c_u64, declared_inputs); - absorb(&mut state, 0x50494e53_u64, sibling_pins); - absorb( - &mut state, - (mneme_reads.len() as u64) ^ 0x4d4e454d_u64, - &[0u8; 32], - ); + let mut h = Sha256::new(); + h.update(INPUT_DOMAIN); + h.update(declared_inputs); + h.update(sibling_pins); + h.update(&(mneme_reads.len() as u64).to_le_bytes()); for r in mneme_reads { - absorb(&mut state, 0x52454144_u64, r); + h.update(r); } - - let mut out = [0u8; 32]; - for i in 0..4 { - let bytes = state[i].to_be_bytes(); - out[i * 8..(i + 1) * 8].copy_from_slice(&bytes); - } - out + h.finalize() } +/// One recorded PASS receipt: `(gate, tier, input_digest, receipt_digest)`. +type ReceiptEntry = (String, GateTier, [u8; 32], [u8; 32]); +/// One occupied in-flight slot: `(gate, tier, input_digest)`. +type InflightEntry = (String, GateTier, [u8; 32]); + /// Bounded, `no_std` orchestrator state machine for the Pi 5 ALLEN Tower. pub struct TowerOrchestrator { - pub max_receipts: usize, - pub max_inflight: usize, - receipts: Vec<(String, [u8; 32], [u8; 32])>, - inflight: Vec<(String, [u8; 32])>, + max_receipts: usize, + receipts: Vec, + /// Fixed table of `max_inflight` slots; a run keeps its slot index until completed. + inflight: Vec>, } impl TowerOrchestrator { pub fn new(max_receipts: usize, max_inflight: usize) -> Self { Self { max_receipts, - max_inflight, receipts: Vec::new(), - inflight: Vec::new(), + inflight: vec![None; max_inflight], } } - /// Record a verified PASS receipt in the bounded content-addressed index. + /// Maximum number of PASS receipts kept (oldest evicted first). + pub fn max_receipts(&self) -> usize { + self.max_receipts + } + + /// Number of in-flight slots. + pub fn max_inflight(&self) -> usize { + self.inflight.len() + } + + /// Record a verified PASS receipt for `(gate, tier, input_digest)` and free its in-flight slot. pub fn record_pass_receipt( &mut self, gate: &str, + tier: GateTier, input_digest: [u8; 32], receipt_digest: [u8; 32], ) { - self.complete_inflight(gate, &input_digest); + self.complete_inflight(gate, tier, &input_digest); for entry in &mut self.receipts { - if entry.0 == gate && entry.1 == input_digest { - entry.2 = receipt_digest; + if entry.0 == gate && entry.1 == tier && entry.2 == input_digest { + entry.3 = receipt_digest; return; } } @@ -198,56 +221,31 @@ impl TowerOrchestrator { self.receipts.remove(0); } self.receipts - .push((String::from(gate), input_digest, receipt_digest)); + .push((String::from(gate), tier, input_digest, receipt_digest)); } - /// Remove an in-flight gate entry when execution finishes. - pub fn complete_inflight(&mut self, gate: &str, input_digest: &[u8; 32]) -> bool { - if let Some(pos) = self - .inflight - .iter() - .position(|(g, d)| g == gate && d == input_digest) - { - self.inflight.remove(pos); - true - } else { - false + /// Free the in-flight slot of a finished run. Returns false if no slot held it. + pub fn complete_inflight( + &mut self, + gate: &str, + tier: GateTier, + input_digest: &[u8; 32], + ) -> bool { + for slot in &mut self.inflight { + if matches!(slot, Some((g, t, d)) if g == gate && *t == tier && d == input_digest) { + *slot = None; + return true; + } } + false } /// Decide how to handle `spec` without dropping or weakening any gate check. + /// + /// A cacheable request that finds every in-flight slot taken is dispatched without being + /// tracked, so a duplicate of it runs again instead of joining (never skipped). pub fn schedule_gate(&mut self, spec: &GateSpec) -> TowerDecision { - if spec.cacheable { - for (g, din, drcpt) in &self.receipts { - if g == &spec.gate && *din == spec.input_digest { - return TowerDecision { - gate: spec.gate.clone(), - action: TowerAction::ReuseReceipt { - receipt_digest: *drcpt, - }, - why: TowerWhy::CachedPassReceipt, - }; - } - } - } - - if let Some(slot) = self - .inflight - .iter() - .position(|(g, d)| g == &spec.gate && *d == spec.input_digest) - { - return TowerDecision { - gate: spec.gate.clone(), - action: TowerAction::JoinInflight { slot }, - why: TowerWhy::InflightDuplicate, - }; - } - - if self.inflight.len() < self.max_inflight { - self.inflight.push((spec.gate.clone(), spec.input_digest)); - } - - let (action, default_why) = match spec.tier { + let (action, tier_why) = match spec.tier { GateTier::Portable | GateTier::Pi5Host => { (TowerAction::RunPi5Local, TowerWhy::TierLocalPi5) } @@ -259,16 +257,42 @@ impl TowerOrchestrator { } }; - let why = if spec.cacheable { - default_why - } else { - TowerWhy::UncacheableGate - }; + if !spec.cacheable { + return TowerDecision { + gate: spec.gate.clone(), + action, + why: TowerWhy::UncacheableGate, + }; + } + + for (g, t, din, drcpt) in &self.receipts { + if *g == spec.gate && *t == spec.tier && *din == spec.input_digest { + return TowerDecision { + gate: spec.gate.clone(), + action: TowerAction::ReuseReceipt { + receipt_digest: *drcpt, + }, + why: TowerWhy::CachedPassReceipt, + }; + } + } + + let same = |e: &Option| matches!(e, Some((g, t, d)) if *g == spec.gate && *t == spec.tier && *d == spec.input_digest); + if let Some(slot) = self.inflight.iter().position(same) { + return TowerDecision { + gate: spec.gate.clone(), + action: TowerAction::JoinInflight { slot }, + why: TowerWhy::InflightDuplicate, + }; + } + if let Some(free) = self.inflight.iter_mut().find(|e| e.is_none()) { + *free = Some((spec.gate.clone(), spec.tier, spec.input_digest)); + } TowerDecision { gate: spec.gate.clone(), action, - why, + why: tier_why, } } } @@ -286,7 +310,7 @@ mod tests { let d_in = combine_mneme_digest(&d_decl, &d_pins, &[d_read1]); let d_rcpt = [0x99u8; 32]; - tower.record_pass_receipt("OMEGA-ALGEBRA", d_in, d_rcpt); + tower.record_pass_receipt("OMEGA-ALGEBRA", GateTier::SparkHost, d_in, d_rcpt); let spec = GateSpec { gate: String::from("OMEGA-ALGEBRA"), @@ -347,4 +371,127 @@ mod tests { assert_eq!(gpu_dec.action, TowerAction::QueueSparkGb10); assert_eq!(gpu_dec.why, TowerWhy::UncacheableGate); } + + fn spec(gate: &str, tier: GateTier, d: u8, cacheable: bool) -> GateSpec { + GateSpec { + gate: String::from(gate), + tier, + input_digest: [d; 32], + cacheable, + } + } + + #[test] + fn join_slot_stays_stable_after_an_earlier_run_completes() { + let mut tower = TowerOrchestrator::new(8, 4); + let a = spec("GATE-A", GateTier::SparkHost, 1, true); + let b = spec("GATE-B", GateTier::SparkHost, 2, true); + assert_eq!( + tower.schedule_gate(&a).action, + TowerAction::DispatchSparkHost + ); + assert_eq!( + tower.schedule_gate(&b).action, + TowerAction::DispatchSparkHost + ); + assert_eq!( + tower.schedule_gate(&b).action, + TowerAction::JoinInflight { slot: 1 } + ); + assert!(tower.complete_inflight("GATE-A", GateTier::SparkHost, &[1; 32])); + // B is still the run in slot 1; a joiner must keep pointing at it. + assert_eq!( + tower.schedule_gate(&b).action, + TowerAction::JoinInflight { slot: 1 } + ); + } + + #[test] + fn receipt_from_one_tier_is_not_reused_for_another_tier() { + let mut tower = TowerOrchestrator::new(8, 4); + tower.record_pass_receipt("AIENOS-STORE", GateTier::Pi5Host, [7; 32], [0xaa; 32]); + // Same gate and inputs, but asked for on the Spark host tier: must run there. + let spark = spec("AIENOS-STORE", GateTier::SparkHost, 7, true); + let dec = tower.schedule_gate(&spark); + assert_eq!(dec.action, TowerAction::DispatchSparkHost); + assert_eq!(dec.why, TowerWhy::TierSparkHostPool); + // The Pi tier still reuses its own receipt. + let pi = spec("AIENOS-STORE", GateTier::Pi5Host, 7, true); + assert_eq!( + tower.schedule_gate(&pi).action, + TowerAction::ReuseReceipt { + receipt_digest: [0xaa; 32] + } + ); + // An in-flight run on one tier is not joined by a request for another tier. + let qemu = spec("AIENOS-STORE", GateTier::SparkQemu, 7, true); + assert_eq!( + tower.schedule_gate(&qemu).action, + TowerAction::DispatchSparkHost + ); + } + + #[test] + fn full_slot_table_dispatches_every_request_and_pass_frees_the_slot() { + let mut tower = TowerOrchestrator::new(8, 1); + let a = spec("GATE-A", GateTier::Pi5Host, 1, true); + let b = spec("GATE-B", GateTier::Pi5Host, 2, true); + assert_eq!(tower.schedule_gate(&a).action, TowerAction::RunPi5Local); + // No free slot: B runs untracked, so a duplicate of B runs again (never skipped). + assert_eq!(tower.schedule_gate(&b).action, TowerAction::RunPi5Local); + assert_eq!(tower.schedule_gate(&b).action, TowerAction::RunPi5Local); + // Recording A's PASS frees slot 0 for the next run. + tower.record_pass_receipt("GATE-A", GateTier::Pi5Host, [1; 32], [0xbb; 32]); + assert_eq!(tower.schedule_gate(&b).action, TowerAction::RunPi5Local); + assert_eq!( + tower.schedule_gate(&b).action, + TowerAction::JoinInflight { slot: 0 } + ); + assert_eq!(tower.max_inflight(), 1); + } + + #[test] + fn uncacheable_gate_is_never_joined_to_another_run() { + let mut tower = TowerOrchestrator::new(8, 4); + let g = spec("OMEGA-DIVSQRT-CHIP", GateTier::SparkGb10, 6, false); + assert_eq!(tower.schedule_gate(&g).action, TowerAction::QueueSparkGb10); + let again = tower.schedule_gate(&g); + assert_eq!(again.action, TowerAction::QueueSparkGb10); + assert_eq!(again.why, TowerWhy::UncacheableGate); + } + + #[test] + fn decision_json_escapes_the_gate_name() { + let dec = TowerDecision { + gate: String::from("a\"b\\c\nd\u{1}"), + action: TowerAction::RunPi5Local, + why: TowerWhy::TierLocalPi5, + }; + assert_eq!( + dec.to_json(), + r#"{"tower_action":"run_pi5_local","gate":"a\"b\\c\nd\u0001","why":"tier_local_pi5"}"# + ); + } + + #[test] + fn cache_key_is_sha256_of_the_domain_separated_encoding() { + // Expected value computed outside Rust with coreutils sha256sum over + // "ALLEN-TOWER-INPUT-V1\0" || [0x11;32] || [0x22;32] || 2u64 LE || [0x33;32] || [0x34;32]. + let got = combine_mneme_digest(&[0x11; 32], &[0x22; 32], &[[0x33; 32], [0x34; 32]]); + let want = [ + 0x37, 0x6b, 0xdf, 0x72, 0xe9, 0xfb, 0xa8, 0xe7, 0xca, 0xf8, 0x23, 0x76, 0xb2, 0xc5, + 0x3d, 0xb5, 0x54, 0xca, 0xda, 0x99, 0xb8, 0xbb, 0x40, 0x1d, 0x54, 0x34, 0xf0, 0xc2, + 0xd9, 0x09, 0x83, 0x93, + ]; + assert_eq!(got, want); + // Order of the observed reads and their count both change the key. + assert_ne!( + got, + combine_mneme_digest(&[0x11; 32], &[0x22; 32], &[[0x34; 32], [0x33; 32]]) + ); + assert_ne!( + combine_mneme_digest(&[0x11; 32], &[0x22; 32], &[]), + combine_mneme_digest(&[0x11; 32], &[0x22; 32], &[[0; 32]]) + ); + } } diff --git a/native/.crumb b/native/.crumb index a454dc47..d7d843c7 100644 --- a/native/.crumb +++ b/native/.crumb @@ -61,20 +61,20 @@ "purpose": "Directory native/boot. Purpose not yet described by a human." }, { - "digest": "4326d5aff89483ffbd3f109b4849fad5e3ed9c78d97145df6a0a0e326a63de34", - "last_commit": "51c05da", + "digest": "750c519c466783ed6330a6a2c8fcb2153efdaadb9d65b38a6a85e8463d78b68d", + "last_commit": "596870d", "name": "capability", "purpose": "Directory native/capability. Purpose not yet described by a human." }, { - "digest": "2d681397b90b5102fc04a957deb11ca4b56fe21c368d46394a85df9782b31475", - "last_commit": "a4bba0c", + "digest": "0a3e98a5f36f528eb7ae6e1611d466343068780b9029621286b292ec1c796950", + "last_commit": "596870d", "name": "crypto", "purpose": "Directory native/crypto. Purpose not yet described by a human." }, { - "digest": "5f7e090612dfe2e9c4a1e77fcf8443615bf6191ae6eb50ec8a472f5855f29506", - "last_commit": "2563059", + "digest": "99bc55e79695290b65ae08a38e5731e3ed976d79cdb3b6c9bc21c706b1ddab22", + "last_commit": "596870d", "name": "disk", "purpose": "Directory native/disk. Purpose not yet described by a human." }, @@ -85,39 +85,39 @@ "purpose": "Directory native/kernel. Purpose not yet described by a human." }, { - "digest": "8a8ec123b3898cbb63e073593baf4756abc4c0c6ab93db804937d937425f3f9a", - "last_commit": "1feaca1", + "digest": "a805df7e3af4b8a2ef345223523b54e7e47565204ec8f8e598f6dcaf53b07419", + "last_commit": "596870d", "name": "m5", "purpose": "Directory native/m5. Purpose not yet described by a human." }, { - "digest": "370c8b53b1041e4db242950e1be4667c260fbaba7d7bfe397ffe73775f71af6b", - "last_commit": "4a116e5", + "digest": "ff5c88f5e9bf86e7ff836d24c048dd2d4efc94f6f19a21a0caf72ae9c402deaf", + "last_commit": "596870d", "name": "net", "purpose": "Directory native/net. Purpose not yet described by a human." }, { - "digest": "531200647a05b2f1b7da7d7bcd012461a6988ff9c8ec5b9f4a888c7ee4f8f8cf", - "last_commit": "cea54be", + "digest": "135fd1edbe2388764de7dc755611b483b0c61adab858718c390b7745d141635c", + "last_commit": "596870d", "name": "sig", "purpose": "Directory native/sig. Purpose not yet described by a human." }, { - "digest": "afee8b21a480493ada6062451cb53deb08ad3441978653f1bc9f41ac727c8a6c", - "last_commit": "22eb360", + "digest": "d8b2495b09640d45919094f4d070d5f9e23773c455b539ed1824830c99ec541d", + "last_commit": "596870d", "name": "store", "purpose": "Directory native/store. Purpose not yet described by a human." } ], - "children_root": "sha256:505add7cf041a00f92a5ee94cec544b526dfea53989cfd8b541472b49bd68f93", - "compiled_at": "2026-10-14T14:17:07Z", + "children_root": "sha256:6bba5c2399e16a6f3a7cda693b353ca774f89e94e057ffe45122413893a522a2", + "compiled_at": "2026-10-14T14:58:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:c892bb8ae2aabd5566432f63d72f6937cf36d0e20f36bfae5f838238a89bcedd", + "digest": "sha256:36e7b840be2a09ca3829e87caa6c20bbc2ac1dd96b57b5037ffdf3c23514be4e", "evidence_files": 4, "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335", "files": 562, - "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", - "source_tree": "sha256:df045e3d50780709d0ed71a3012a3ba5ede2c9d3e536f395d4652522dcdfeef8" + "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84", + "source_tree": "sha256:d213659f087013363f173e225433381e655cf696c1bcd7590409fdfc4e7077c0" }, "owner_lane": "", "provenance": { diff --git a/native/capability/.crumb b/native/capability/.crumb index fca5563a..5c3d300d 100644 --- a/native/capability/.crumb +++ b/native/capability/.crumb @@ -20,14 +20,14 @@ } ], "children_root": "sha256:0c70cfa122966e11065bca94434dcb159c75a4557cf6322bbc5256e28d49f2e5", - "compiled_at": "2026-10-14T14:17:07Z", + "compiled_at": "2026-10-14T14:58:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:4326d5aff89483ffbd3f109b4849fad5e3ed9c78d97145df6a0a0e326a63de34", + "digest": "sha256:750c519c466783ed6330a6a2c8fcb2153efdaadb9d65b38a6a85e8463d78b68d", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 8, - "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", - "source_tree": "sha256:d3faa108df05fcf2e4869afc82e07693ba3b85b3d6caa55107e0ec2c515898c8" + "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84", + "source_tree": "sha256:bb4b4f4706f6b22f2cb4a92ec9ed82733cff2ef5c3a626843e3ee584785e8b9b" }, "owner_lane": "", "provenance": { diff --git a/native/capability/Makefile b/native/capability/Makefile index a5cfd3e9..93ed741a 100644 --- a/native/capability/Makefile +++ b/native/capability/Makefile @@ -142,7 +142,9 @@ mutants: $(TEST) $(CONTAIN_TEST) $(CAP_MUT_TEST_OBJS) | $(OUT) echo "AIENOS_CAP_MUTANTS: FAIL"; exit 1; fi; \ n=0; killed=0; fail=0; names=""; \ while IFS='|' read -r name file k from to; do \ - [ -n "$$name" ] || continue; n=$$((n+1)); names="$$names $$name"; d=$(MUT_DIR)/$$name; mkdir -p $$d; \ + [ -n "$$name" ] || continue; n=$$((n+1)); \ + case " $$names " in *" $$name "*) echo "mutant $$name: name appears twice, parallel runs would collide (FAIL)"; fail=1; continue ;; esac; \ + names="$$names $$name"; d=$(MUT_DIR)/$$name; mkdir -p $$d; \ ( if ! awk -v k="$$k" -v from="$$from" -v to="$$to" \ 'index($$0, from) { c++; if (c == k) { i = index($$0, from); $$0 = substr($$0, 1, i - 1) to substr($$0, i + length(from)); hit = 1 } } { print } END { exit hit ? 0 : 3 }' \ $$file > $$d/$$file; then \ @@ -158,14 +160,15 @@ mutants: $(TEST) $(CONTAIN_TEST) $(CAP_MUT_TEST_OBJS) | $(OUT) by=""; \ timeout $(MUT_TIMEOUT) $$d/capability_test > $$d/run.log 2>&1 || by="capability_test"; \ timeout $(MUT_TIMEOUT) $$d/contain_test >> $$d/run.log 2>&1 || by="$${by:+$$by+}contain_test"; \ - if [ -n "$$by" ]; then echo "mutant $$name: killed by $$by" > $$d/msg; \ + if [ -n "$$by" ]; then echo "mutant $$name: killed by $$by" > $$d/msg; : > $$d/killed; \ else echo "mutant $$name: SURVIVED (FAIL)" > $$d/msg; echo 1 > $$d/fail; fi \ ) & \ done < $(MUT_TABLE); \ wait; \ for name in $$names; do \ - d=$(MUT_DIR)/$$name; cat $$d/msg; \ - if [ -f $$d/fail ]; then fail=1; else killed=$$((killed+1)); fi; \ + d=$(MUT_DIR)/$$name; \ + if [ -f $$d/msg ]; then cat $$d/msg; else echo "mutant $$name: no result recorded (FAIL)"; fi; \ + if [ -f $$d/killed ] && [ ! -f $$d/fail ]; then killed=$$((killed+1)); else fail=1; fi; \ done; \ if [ $$n -lt 8 ]; then echo "only $$n mutants defined, need at least 8"; fail=1; fi; \ if [ $$fail -eq 0 ] && [ $$killed -eq $$n ]; then echo "AIENOS_CAP_MUTANTS: PASS ($$killed/$$n killed)"; \ diff --git a/native/crypto/.crumb b/native/crypto/.crumb index f7bac087..bd1d3cb2 100644 --- a/native/crypto/.crumb +++ b/native/crypto/.crumb @@ -20,14 +20,14 @@ } ], "children_root": "sha256:db2c6d092f9d97c30dc5cc4531ae25cb558d206d66ca31f94ca14d0ff2cfacea", - "compiled_at": "2026-10-14T14:17:07Z", + "compiled_at": "2026-10-14T14:58:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:2d681397b90b5102fc04a957deb11ca4b56fe21c368d46394a85df9782b31475", + "digest": "sha256:0a3e98a5f36f528eb7ae6e1611d466343068780b9029621286b292ec1c796950", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 10, - "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", - "source_tree": "sha256:5b3ccd83e8032a7eecd2f0f18c998fc357f533e0dfaa3ec4ff72836d013e2ef5" + "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84", + "source_tree": "sha256:25932bcca4e7eea369babe75a4e82b72000bb1d1b2437272f2c2a73fb70ffd57" }, "owner_lane": "", "provenance": { diff --git a/native/crypto/Makefile b/native/crypto/Makefile index ec210ab2..3dc0444a 100644 --- a/native/crypto/Makefile +++ b/native/crypto/Makefile @@ -64,7 +64,10 @@ $(OUT)/t_crypto_test.o: tests/crypto_test.c $(HDRS) | $(OUT) mutants: $(OBJS) $(OUT)/sha256.o $(OUT)/t_crypto_test.o | $(OUT) @ulimit -c 0; fail=0; \ + dups=$$(printf '%s\n' $(GUARDS) | sort | uniq -d); \ + [ -z "$$dups" ] || { echo "duplicate guard names (parallel runs would collide):" $$dups; echo "AIENOS_CRYPTO_MUTANTS: FAIL"; exit 1; }; \ for g in $(GUARDS); do \ + rm -f $(OUT)/mut_$$g.msg $(OUT)/mut_$$g.fail $(OUT)/mut_$$g.killed; \ ( grep -q "GUARD:$$g \*/" gcm_siv.c || { echo "mutant $$g: guard tag missing" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; exit 0; }; \ sed "/GUARD:$$g \*\//d" gcm_siv.c > $(OUT)/mut_$$g.c; \ $(CC) $(CFLAGS) -Wno-error -I. -c -o $(OUT)/mut_$$g.o $(OUT)/mut_$$g.c \ @@ -73,13 +76,13 @@ mutants: $(OBJS) $(OUT)/sha256.o $(OUT)/t_crypto_test.o | $(OUT) || { echo "mutant $$g: does not compile" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; exit 0; }; \ if ./$(OUT)/mut_$$g > $(OUT)/mut_$$g.log 2>&1; then \ echo "mutant $$g: SURVIVED (FAIL)" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; \ - else echo "mutant $$g: killed" > $(OUT)/mut_$$g.msg; fi \ + else echo "mutant $$g: killed" > $(OUT)/mut_$$g.msg; : > $(OUT)/mut_$$g.killed; fi \ ) & \ done; \ wait; \ for g in $(GUARDS); do \ - cat $(OUT)/mut_$$g.msg; \ - if [ -f $(OUT)/mut_$$g.fail ]; then fail=1; rm -f $(OUT)/mut_$$g.fail; fi; \ + if [ -f $(OUT)/mut_$$g.msg ]; then cat $(OUT)/mut_$$g.msg; else echo "mutant $$g: no result recorded (FAIL)"; fi; \ + [ -f $(OUT)/mut_$$g.killed ] && [ ! -f $(OUT)/mut_$$g.fail ] || fail=1; \ done; \ if [ $$fail -eq 0 ]; then echo "AIENOS_CRYPTO_MUTANTS: PASS"; else echo "AIENOS_CRYPTO_MUTANTS: FAIL"; exit 1; fi diff --git a/native/disk/.crumb b/native/disk/.crumb index ccca8a7a..0d481d00 100644 --- a/native/disk/.crumb +++ b/native/disk/.crumb @@ -30,14 +30,14 @@ } ], "children_root": "sha256:fb9a25a745be4f0d38936d5ff30f3fafdc68a80d6aaeff667fde54d196d6b132", - "compiled_at": "2026-10-14T14:17:07Z", + "compiled_at": "2026-10-14T14:58:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:5f7e090612dfe2e9c4a1e77fcf8443615bf6191ae6eb50ec8a472f5855f29506", + "digest": "sha256:99bc55e79695290b65ae08a38e5731e3ed976d79cdb3b6c9bc21c706b1ddab22", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 20, - "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", - "source_tree": "sha256:3d0f1765860ba9a04e29b2bc9becb299ca5bef8ded1b52082712e27bdaf37163" + "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84", + "source_tree": "sha256:667e44de55a53f223607fe87bd5ccd445c674f962fd5baa7570a467b3fedeb1a" }, "owner_lane": "", "provenance": { diff --git a/native/disk/Makefile b/native/disk/Makefile index 9e233a55..7c27dfd8 100644 --- a/native/disk/Makefile +++ b/native/disk/Makefile @@ -27,7 +27,7 @@ ifeq ($(shell uname -m),aarch64) FREEFLAGS += -mstrict-align -mgeneral-regs-only endif OUT ?= out -MUTANT_TIMEOUT ?= 5 +MUTANT_TIMEOUT ?= 60 SRCS = disk.c disk_nvme.c disk_sdhci.c OBJS = $(SRCS:%.c=$(OUT)/%.o) @@ -115,6 +115,8 @@ $(OUT)/t_%_test.o: tests/%_test.c $(HDRS) | $(OUT) mutants: $(OBJS) $(FILE_OBJ) $(DISK_MUT_TEST_OBJS) | $(OUT) @ulimit -c 0; fail=0; n=0; k=0; \ + dups=$$(printf '%s\n' $(GUARDS) | sort | uniq -d); \ + [ -z "$$dups" ] || { echo "duplicate guard names (parallel runs would collide):" $$dups; echo "AIENOS_DISK_MUTANTS: FAIL"; exit 1; }; \ for g in $(GUARDS); do \ n=$$((n+1)); d=$(OUT)/mut_$$g; rm -rf $$d; mkdir -p $$d/scratch; \ ( f=$$(grep -l "GUARD:$$g \*/" $(SRCS)); \ @@ -139,13 +141,14 @@ mutants: $(OBJS) $(FILE_OBJ) $(DISK_MUT_TEST_OBJS) | $(OUT) else timeout $(MUTANT_TIMEOUT) ./$$d/$$b >> $$d/run.log 2>&1 || { pass=0; break; }; fi; \ done; \ if [ $$pass -eq 1 ]; then echo "mutant $$g: SURVIVED (FAIL)" > $$d/msg; echo 1 > $$d/fail; \ - else echo "mutant $$g: killed" > $$d/msg; fi \ + else echo "mutant $$g: killed" > $$d/msg; : > $$d/killed; fi \ ) & \ done; \ wait; \ for g in $(GUARDS); do \ - d=$(OUT)/mut_$$g; cat $$d/msg; \ - if [ -f $$d/fail ]; then fail=1; else k=$$((k+1)); fi; \ + d=$(OUT)/mut_$$g; \ + if [ -f $$d/msg ]; then cat $$d/msg; else echo "mutant $$g: no result recorded (FAIL)"; fi; \ + if [ -f $$d/killed ] && [ ! -f $$d/fail ]; then k=$$((k+1)); else fail=1; fi; \ done; \ echo "mutants killed: $$k/$$n"; \ if [ $$fail -eq 0 ] && [ $$n -ge 10 ]; then echo "AIENOS_DISK_MUTANTS: PASS"; else echo "AIENOS_DISK_MUTANTS: FAIL"; exit 1; fi diff --git a/native/m5/.crumb b/native/m5/.crumb index 49d560f5..af341836 100644 --- a/native/m5/.crumb +++ b/native/m5/.crumb @@ -30,14 +30,14 @@ } ], "children_root": "sha256:b461ac42b9135cc73e941d0acb46347321f14ed28765e041f00445bdbff7ab54", - "compiled_at": "2026-10-14T14:17:07Z", + "compiled_at": "2026-10-14T14:58:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:8a8ec123b3898cbb63e073593baf4756abc4c0c6ab93db804937d937425f3f9a", + "digest": "sha256:a805df7e3af4b8a2ef345223523b54e7e47565204ec8f8e598f6dcaf53b07419", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 13, - "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", - "source_tree": "sha256:4f597bb3c2d1d47d81d1d9caa658e6b72b9450184e0c663fb48d62dbfca44a4b" + "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84", + "source_tree": "sha256:d9e34890925e31f604e9c876f5ceff76db9fdd9adc26361800c542cc0b009994" }, "owner_lane": "", "provenance": { diff --git a/native/m5/Makefile b/native/m5/Makefile index 3da70600..2f8488c6 100644 --- a/native/m5/Makefile +++ b/native/m5/Makefile @@ -107,6 +107,8 @@ $(OUT)/t_%_test.o: tests/%_test.c $(HDRS) | $(OUT) mutants: $(OBJS) $(DEP_OBJS) $(M5_MUT_TEST_OBJS) | $(OUT) @ulimit -c 0; fail=0; \ + dups=$$(printf '%s\n' $(GUARDS) | sort | uniq -d); \ + [ -z "$$dups" ] || { echo "duplicate guard names (parallel runs would collide):" $$dups; echo "M5_NATIVE_MUTANTS: FAIL"; exit 1; }; \ for g in $(GUARDS); do \ d=$(OUT)/mut_$$g; rm -rf $$d; mkdir -p $$d; \ ( f=$$(grep -l "GUARD:$$g \*/" $(SRCS)); \ @@ -125,13 +127,14 @@ mutants: $(OBJS) $(DEP_OBJS) $(M5_MUT_TEST_OBJS) | $(OUT) pass=1; : > $$d/run.log; \ for b in $$order; do ./$$d/$$b >> $$d/run.log 2>&1 || { pass=0; break; }; done; \ if [ $$pass -eq 1 ]; then echo "mutant $$g: SURVIVED (FAIL)" > $$d/msg; echo 1 > $$d/fail; \ - else echo "mutant $$g: killed" > $$d/msg; fi \ + else echo "mutant $$g: killed" > $$d/msg; : > $$d/killed; fi \ ) & \ done; \ wait; \ for g in $(GUARDS); do \ - d=$(OUT)/mut_$$g; cat $$d/msg; \ - [ ! -f $$d/fail ] || fail=1; \ + d=$(OUT)/mut_$$g; \ + if [ -f $$d/msg ]; then cat $$d/msg; else echo "mutant $$g: no result recorded (FAIL)"; fi; \ + [ -f $$d/killed ] && [ ! -f $$d/fail ] || fail=1; \ done; \ if [ $$fail -eq 0 ]; then echo "M5_NATIVE_MUTANTS: PASS"; else echo "M5_NATIVE_MUTANTS: FAIL"; exit 1; fi diff --git a/native/net/.crumb b/native/net/.crumb index 99352810..d4dbb083 100644 --- a/native/net/.crumb +++ b/native/net/.crumb @@ -30,14 +30,14 @@ } ], "children_root": "sha256:72c6a05fd3be86ab3a6985c3b1d9ed75262d875773aff4440ec13869435108cc", - "compiled_at": "2026-10-14T14:17:07Z", + "compiled_at": "2026-10-14T14:58:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:370c8b53b1041e4db242950e1be4667c260fbaba7d7bfe397ffe73775f71af6b", + "digest": "sha256:ff5c88f5e9bf86e7ff836d24c048dd2d4efc94f6f19a21a0caf72ae9c402deaf", "evidence_files": 4, "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335", "files": 29, - "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", - "source_tree": "sha256:13089e10600f3393e8d0b493839bfd55e6e0344656c874f77c0e0e954d02274c" + "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84", + "source_tree": "sha256:f44c1b908aa86c0360aa8d0f01723a1deae07cdecc40354390204e2ee456834d" }, "owner_lane": "", "provenance": { diff --git a/native/net/Makefile b/native/net/Makefile index b1757bf8..12026b33 100644 --- a/native/net/Makefile +++ b/native/net/Makefile @@ -146,9 +146,10 @@ $(OUT)/t_%_test.o: tests/%_test.c $(wildcard *.h) | $(OUT) $(CC) $(CFLAGS) -Wno-error -I. -c -o $@ $< mutants: $(OBJS) $(NET_MUT_TEST_OBJS) | $(OUT) - @killed=0; total=0; survived=""; pids=""; list=""; \ + @killed=0; total=0; survived=""; list=""; \ for f in $(SEC_GUARD_FILES); do \ for g in $$(grep -o 'GUARD:[a-z0-9-]*' $$f | cut -d: -f2); do \ + case " $$list " in *" $$g "*) echo "mutant $$g: guard tag appears twice, parallel runs would collide"; survived="$$survived $$g"; continue ;; esac; \ total=$$((total+1)); mdir=$(OUT)/mut_$$g; rm -rf $$mdir; mkdir -p $$mdir; list="$$list $$g"; \ ( cp *.h $$mdir/; \ sed "/GUARD:$$g \*\//d" $$f > $$mdir/$$f; \ @@ -166,14 +167,15 @@ mutants: $(OBJS) $(NET_MUT_TEST_OBJS) | $(OUT) esac; \ pass=1; for b in $$order; do if ! ./$$b >/dev/null 2>&1; then pass=0; break; fi; done; \ if [ $$pass -eq 1 ]; then echo "mutant $$g: SURVIVED" > $$mdir/msg; echo "$$g" > $$mdir/surv; \ - else echo "mutant $$g: killed" > $$mdir/msg; fi \ + else echo "mutant $$g: killed" > $$mdir/msg; : > $$mdir/killed; fi \ ) & \ done; \ done; \ wait; \ for g in $$list; do \ - mdir=$(OUT)/mut_$$g; cat $$mdir/msg; \ - if [ -f $$mdir/surv ]; then survived="$$survived $$g"; else killed=$$((killed+1)); fi; \ + mdir=$(OUT)/mut_$$g; \ + if [ -f $$mdir/msg ]; then cat $$mdir/msg; else echo "mutant $$g: no result recorded (counts as not killed)"; fi; \ + if [ -f $$mdir/killed ] && [ ! -f $$mdir/surv ]; then killed=$$((killed+1)); else survived="$$survived $$g"; fi; \ done; \ echo "NET_SECURE_MUTANTS: $$killed/$$total killed"; \ [ -z "$$survived" ] && [ $$total -ge 12 ] || { echo "NET_SECURE_MUTANTS: FAIL (not killed:$$survived)"; exit 1; } diff --git a/native/sig/.crumb b/native/sig/.crumb index 95c9dfda..983b3a0d 100644 --- a/native/sig/.crumb +++ b/native/sig/.crumb @@ -20,14 +20,14 @@ } ], "children_root": "sha256:2c318acd4ff46092a89eec7b6b1f764bdc91bb6428427fffa9b04f05753be9fd", - "compiled_at": "2026-10-14T14:17:07Z", + "compiled_at": "2026-10-14T14:58:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:531200647a05b2f1b7da7d7bcd012461a6988ff9c8ec5b9f4a888c7ee4f8f8cf", + "digest": "sha256:135fd1edbe2388764de7dc755611b483b0c61adab858718c390b7745d141635c", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 10, - "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", - "source_tree": "sha256:ebdccd9ffc2d84538089299d04b4836364643d80d57ac1182861d362d7049244" + "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84", + "source_tree": "sha256:e0f0c7871cebb725ef0fbe9a56e1e0ca558690712174e9f2d8eab5fc2b848ce2" }, "owner_lane": "", "provenance": { diff --git a/native/sig/Makefile b/native/sig/Makefile index d7c28b1b..77f8057b 100644 --- a/native/sig/Makefile +++ b/native/sig/Makefile @@ -65,8 +65,11 @@ $(OUT)/t_sig_test.o: tests/sig_test.c $(TEST_HDRS) $(HDRS) | $(OUT) mutants: $(OBJS) $(OUT)/t_sig_test.o | $(OUT) @ulimit -c 0; fail=0; n=0; \ + dups=$$(printf '%s\n' $(MUTANTS) | sed 's/.*://' | sort | uniq -d); \ + [ -z "$$dups" ] || { echo "duplicate guard names (parallel runs would collide):" $$dups; echo "AIENOS_SIG_MUTANTS: FAIL"; exit 1; }; \ for m in $(MUTANTS); do \ f=$${m%%:*}; g=$${m#*:}; n=$$((n+1)); \ + rm -f $(OUT)/mut_$$g.msg $(OUT)/mut_$$g.fail $(OUT)/mut_$$g.killed; \ ( grep -q "GUARD:$$g \*/" $$f || { echo "mutant $$g: guard tag missing" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; exit 0; }; \ sed "/GUARD:$$g \*\//d" $$f > $(OUT)/mut_$$g.c; \ others=$$(for s in $(SRCS); do [ $$s = $$f ] || echo $(OUT)/$${s%.c}.o; done); \ @@ -75,13 +78,14 @@ mutants: $(OBJS) $(OUT)/t_sig_test.o | $(OUT) || { echo "mutant $$g: does not compile" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; exit 0; }; \ if ./$(OUT)/mut_$$g > $(OUT)/mut_$$g.log 2>&1; then \ echo "mutant $$g: SURVIVED (FAIL)" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; \ - else echo "mutant $$g: killed" > $(OUT)/mut_$$g.msg; fi \ + else echo "mutant $$g: killed" > $(OUT)/mut_$$g.msg; : > $(OUT)/mut_$$g.killed; fi \ ) & \ done; \ wait; \ for m in $(MUTANTS); do \ - g=$${m#*:}; cat $(OUT)/mut_$$g.msg; \ - if [ -f $(OUT)/mut_$$g.fail ]; then fail=1; rm -f $(OUT)/mut_$$g.fail; fi; \ + g=$${m#*:}; \ + if [ -f $(OUT)/mut_$$g.msg ]; then cat $(OUT)/mut_$$g.msg; else echo "mutant $$g: no result recorded (FAIL)"; fi; \ + [ -f $(OUT)/mut_$$g.killed ] && [ ! -f $(OUT)/mut_$$g.fail ] || fail=1; \ done; \ if [ $$fail -eq 0 ]; then echo "AIENOS_SIG_MUTANTS: PASS ($$n/$$n killed)"; else echo "AIENOS_SIG_MUTANTS: FAIL"; exit 1; fi diff --git a/native/store/.crumb b/native/store/.crumb index ff7e1ca8..1379238a 100644 --- a/native/store/.crumb +++ b/native/store/.crumb @@ -20,14 +20,14 @@ } ], "children_root": "sha256:24a9259b30657d17f3cab3901246fb8cd28441d8a929839fd58a86aa951a66a3", - "compiled_at": "2026-10-14T14:17:07Z", + "compiled_at": "2026-10-14T14:58:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:afee8b21a480493ada6062451cb53deb08ad3441978653f1bc9f41ac727c8a6c", + "digest": "sha256:d8b2495b09640d45919094f4d070d5f9e23773c455b539ed1824830c99ec541d", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 22, - "generated_at_commit": "f5c90e7c1eb273e8bbe3ace0e49e02841e89b046", - "source_tree": "sha256:689d3dedcb0160db58a09ae48098e25d1229ec499599becdfece59aaa35556e2" + "generated_at_commit": "596870d6ef47c5238cc2c7fa1c08f5e5486e5d84", + "source_tree": "sha256:830232db3fb90c3167555ee7c1876e578f5a9d51e81b938244f5f8c403ebee30" }, "owner_lane": "", "provenance": { diff --git a/native/store/Makefile b/native/store/Makefile index 4593833e..abd211cb 100644 --- a/native/store/Makefile +++ b/native/store/Makefile @@ -136,7 +136,10 @@ $(OUT)/t_torn_slot_test.o: tests/torn_slot_test.c torn_slot.h ../argus/sha256.h torn-slot-mutants: $(OUT)/t_torn_slot_test.o $(OUT)/sha256.o | $(OUT) @fail=0; \ + dups=$$(printf '%s\n' $(GUARDS) | sort | uniq -d); \ + [ -z "$$dups" ] || { echo "duplicate guard names (parallel runs would collide):" $$dups; echo "TORN_SLOT_MUTANTS: FAIL"; exit 1; }; \ for g in $(GUARDS); do \ + rm -f $(OUT)/mut_$$g.msg $(OUT)/mut_$$g.fail $(OUT)/mut_$$g.killed; \ ( grep -q "GUARD:$$g \*/" torn_slot.c || { echo "mutant $$g: guard tag missing" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; exit 0; }; \ sed "/GUARD:$$g \*\//d" torn_slot.c > $(OUT)/mut_$$g.c; \ $(CC) $(CFLAGS) -Wno-error -I. -c -o $(OUT)/mut_$$g.o $(OUT)/mut_$$g.c \ @@ -144,25 +147,29 @@ torn-slot-mutants: $(OUT)/t_torn_slot_test.o $(OUT)/sha256.o | $(OUT) || { echo "mutant $$g: does not compile" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; exit 0; }; \ if ./$(OUT)/mut_$$g --rules-only > $(OUT)/mut_$$g.log 2>&1; then \ echo "mutant $$g: SURVIVED (FAIL)" > $(OUT)/mut_$$g.msg; echo 1 > $(OUT)/mut_$$g.fail; \ - else echo "mutant $$g: killed" > $(OUT)/mut_$$g.msg; fi \ + else echo "mutant $$g: killed" > $(OUT)/mut_$$g.msg; : > $(OUT)/mut_$$g.killed; fi \ ) & \ done; \ wait; \ for g in $(GUARDS); do \ - cat $(OUT)/mut_$$g.msg; \ - if [ -f $(OUT)/mut_$$g.fail ]; then fail=1; rm -f $(OUT)/mut_$$g.fail; fi; \ + if [ -f $(OUT)/mut_$$g.msg ]; then cat $(OUT)/mut_$$g.msg; else echo "mutant $$g: no result recorded (FAIL)"; fi; \ + [ -f $(OUT)/mut_$$g.killed ] && [ ! -f $(OUT)/mut_$$g.fail ] || fail=1; \ done; \ if [ $$fail -eq 0 ]; then echo "TORN_SLOT_MUTANTS: PASS"; else echo "TORN_SLOT_MUTANTS: FAIL"; exit 1; fi STORE_GUARDS = $(shell grep -ho 'GUARD:[a-z0-9-]* \*/' $(STORE_SRCS) | sed 's/GUARD://; s/ \*\///') +# Each store mutant works in its own $(OUT)/smut_ directory, a different name +# space from the torn-slot mutants above, so `make -j mutants` can run both at once. store-mutants: $(STORE_OBJS) $(TEST_OBJS) $(DEP_OBJS) $(OUT)/torn_slot.o $(HOST_OBJS) @fail=0; total=0; killed=0; \ + dups=$$(printf '%s\n' $(STORE_GUARDS) | sort | uniq -d); \ + [ -z "$$dups" ] || { echo "duplicate guard tags (parallel runs would collide):" $$dups; echo "AIENOS_STORE_MUTANTS: FAIL"; exit 1; }; \ for g in $(STORE_GUARDS); do \ - total=$$((total + 1)); d=$(OUT)/mut_$$g; rm -rf $$d; mkdir -p $$d; \ + total=$$((total + 1)); d=$(OUT)/smut_$$g; rm -rf $$d; mkdir -p $$d; \ ( f=$$(grep -l "GUARD:$$g \*/" $(STORE_SRCS)); \ [ $$(echo $$f | wc -w) -eq 1 ] || { echo "mutant $$g: tag not unique ($$f)" > $$d/msg; echo 1 > $$d/fail; exit 0; }; \ sed "/GUARD:$$g \*\//d" $$f > $$d/$$f; \ - $(CC) $(CFLAGS) -Wno-error $(INC) -c -o $$d/m.o $$d/$$f 2>/dev/null || { echo "mutant $$g: does not compile" > $$d/msg; echo 1 > $$d/fail; exit 0; }; \ + $(CC) $(CFLAGS) -Wno-error $(INC) -c -o $$d/m.o $$d/$$f 2> $$d/cc.log || { echo "mutant $$g: does not compile (see $$d/cc.log)" > $$d/msg; echo 1 > $$d/fail; exit 0; }; \ objs=""; for s in $(STORE_SRCS); do [ $$s = $$f ] || objs="$$objs $(OUT)/$${s%.c}.o"; done; \ case "$$f" in \ store_v1.c) order="store_v1_test store_engine_test store_sealed_test store_powercut_test" ;; \ @@ -174,14 +181,15 @@ store-mutants: $(STORE_OBJS) $(TEST_OBJS) $(DEP_OBJS) $(OUT)/torn_slot.o $(HOST_ $(CC) $(CFLAGS) -o $$d/$$t $(OUT)/t_$$t.o $$d/m.o $$objs $(OUT)/torn_slot.o $(DEP_OBJS) $(HOST_OBJS) || { dead=2; break; }; \ if ! ./$$d/$$t $$d > $$d/$$g.log 2>&1; then dead=1; by="$$t"; break; fi; \ done; \ - if [ $$dead -eq 1 ]; then echo "mutant $$g ($$f): killed by $$by" > $$d/msg; \ + if [ $$dead -eq 1 ]; then echo "mutant $$g ($$f): killed by $$by" > $$d/msg; : > $$d/killed; \ else echo "mutant $$g ($$f): SURVIVED (FAIL)" > $$d/msg; echo 1 > $$d/fail; fi \ ) & \ done; \ wait; \ for g in $(STORE_GUARDS); do \ - d=$(OUT)/mut_$$g; cat $$d/msg; \ - if [ -f $$d/fail ]; then fail=1; else killed=$$((killed + 1)); fi; \ + d=$(OUT)/smut_$$g; \ + if [ -f $$d/msg ]; then cat $$d/msg; else echo "mutant $$g: no result recorded (FAIL)"; fi; \ + if [ -f $$d/killed ] && [ ! -f $$d/fail ]; then killed=$$((killed + 1)); else fail=1; fi; \ done; \ echo "store mutants: $$killed of $$total killed"; \ if [ $$fail -eq 0 ] && [ $$total -ge 12 ]; then echo "AIENOS_STORE_MUTANTS: PASS"; else echo "AIENOS_STORE_MUTANTS: FAIL"; exit 1; fi