From 144370e8818ff5c87a7c751291fbad2859d26686 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 29 Oct 2026 20:00:14 -0500 Subject: [PATCH 1/2] feat(bots): persist bot identity bindings and durable inbox events Signed-off-by: Drake Stapleton --- docs/BOTS.md | 93 ++++++ scripts/bots/.crumb | 19 ++ scripts/bots/build.sh | 18 + src/bots/.crumb | 19 ++ src/bots/bots.om | 755 ++++++++++++++++++++++++++++++++++++++++++ tests/bots/.crumb | 19 ++ tests/bots/run.sh | 238 +++++++++++++ 7 files changed, 1161 insertions(+) create mode 100644 docs/BOTS.md create mode 100644 scripts/bots/.crumb create mode 100755 scripts/bots/build.sh create mode 100644 src/bots/.crumb create mode 100644 src/bots/bots.om create mode 100644 tests/bots/.crumb create mode 100755 tests/bots/run.sh diff --git a/docs/BOTS.md b/docs/BOTS.md new file mode 100644 index 0000000..c24bc21 --- /dev/null +++ b/docs/BOTS.md @@ -0,0 +1,93 @@ +# M2: persistent bot records and durable inboxes + +PROPOSED local component for [architecture #311](https://github.com/aien-dev/aien-architecture-mv/issues/311). Not a master plan, network schema, capability, or new subject identity. + +## Owners and source map + +Design read against aien main `b02bc7fb8c28bf90803d5bd357d1749cabdfc974`, architecture ADR 0035 (LogicalAgentId + AgentRoot) and ADR 0022 (canonical Omega rx_cortex single writer). Open Humanity `crates/oh-core/src/identity.rs` owns Ed25519 identity provisioning through atlas-vault. This tool accepts only its public key, never a private seed; it neither signs nor proves key ownership. Registering requires an already trusted local caller. No auto-enrollment. + +The bot id is an address for a local record bound to the existing subject, not a replacement LogicalAgentId or AllenId. Derivation is SHA-256 of ASCII `AIEN-BOT-V1`, one zero byte, OH Ed25519 public key (32 bytes), LogicalAgentId (32 bytes), AgentRoot reference (32 bytes). Registration stores those bindings immutably. Display name is 1..64 printable ASCII bytes. Skill refs, routine refs and Cortex memory refs are each ordered lists of up to four opaque nonzero 32-byte ids. A zero slot means absent. Memory contents, claims, promotion and planning stay with Cortex/JSpace; no Cortex writes occur. + +Worker leases are separate records referencing bot_id. Rotating a lease never changes bot identity, registration, or memory references. Model residency is a separate owner record referencing bot_id; no model, seat, weights, process, budget or routing field is stored in the bot record. A lease token is a nonzero opaque 32-byte id, never reused for this bot within a journal. This is local optimistic ownership, not cryptographic authorization. + +Core `crates/spark-hive/src/store.rs` ForgeTask/HiveComb remain task/comb records in SQLite, not bot identity or a second inbox. AEGIS `src/sessions/session.rs` remains session state, messages, profiles and budgets, not bot continuity. No automatic migration or caller cutover is claimed: this new CLI has no existing runtime consumers. A future network binding belongs to aien-protocols, transport/signing to Open Humanity. This local journal is not a wire format. + +## Inbox state machine + +REGISTER, ROTATE, DELIVER, CLAIM, ACK, NACK, EXPIRE and RETIRE are typed events. Bots are active or retired; retirement is irreversible. DELIVER accepts recipient bot_id, sender bot_id (an opaque external reference), payload bytes and a nonzero handoff reference. Payload bytes are hashed and discarded: the journal retains only SHA-256(payload). Message id is SHA-256 of ASCII `AIEN-BOT-MESSAGE-V1`, zero byte, recipient id, sender id, payload digest and handoff ref: the content digest of that complete immutable envelope. Identical envelope delivery is idempotent, including after ACK, with no second event or inbox copy. Different sender, recipient or handoff is different content. + +Messages are pending, claimed or acknowledged. CLAIM requires the bot's current lease and a pending message. ACK/NACK require both current lease and the message's recorded claimant. ACK is durable and accepted only once; any later ACK or claim is refused. Rotation makes old claimants stale but does not silently acknowledge or discard their work. EXPIRE explicitly returns a claim to pending only when its claimant is no longer current. NACK returns a current claim to pending. No timer, scheduler or wall-clock trust is introduced. Retired bots reject delivery (even duplicates), rotation and message mutations; show remains available. + +## Durability design + +The existing `src/goal_microjobs/kernel.om` is the typed replay/admission reference; its `scripts/goal_microjobs/microjobs.sh` owns flock, candidate replay and sync/rename. Here those mechanics live in the Omega binary itself: a stable JOURNAL.lock inode is locked exclusively, even for show, then JOURNAL is replayed from zero. Accepted events extend the previous bytes without modifying historical event bytes. The candidate JOURNAL.cand is completely written, fsynced, renamed over JOURNAL, then the containing directory is fsynced before success output. A refused command leaves JOURNAL unchanged. A stranded candidate is never replayed and is overwritten under the lock. SIGKILL before rename leaves the old state; after rename leaves the new state. This is process-interruption evidence, not physical power-loss qualification. + +Journal directories must be private and trusted; all callers must use one canonical path and this locking convention. Advisory locking is not protection against a malicious local writer, hardlink aliases, directory replacement or external file edits. The implementation refuses final-component symlinks for journal/lock/candidate. Existing journal bytes are integrity checked, not authenticated. Atomic replacement requires candidate and journal in the same directory. There is no network listener or background loop. + +Bounded local storage: 64 bots, 256 messages, 1024 events. Each event is 1024 bytes, magic BJT1, type at byte 4, sequence at 8 (big-endian u64), bot_id at 16, typed body at 48, SHA-256 of bytes 0..991 at 992. All unused bytes are zero. REGISTER stores public key/logical/root at 48/80/112, name at 144 (zero padded to 64), skills/routines/memory at 208/336/464. ROTATE stores lease at 48. DELIVER stores sender/payload-digest/handoff/message-id at 48/80/112/144. CLAIM/ACK/NACK/EXPIRE store message-id/lease at 48/80 (EXPIRE lease is the stale claimant). RETIRE has no body. The committed journal is authoritative; no state cache is persisted. + +## CLI and acceptance + +Shell is limited to the pinned build adapter and acceptance harness. Runtime parsing, hashing, journal IO, replay and admission are Omega. This is a Linux aarch64 executable, not a portable filesystem layer. Payload arguments are limited to 4096 bytes, journal paths to 2047 bytes, and ids use exactly 64 lowercase hex characters. Reference lists use comma-separated ids, or `-` for none. Strings are literal argv bytes, not JSON. + +```text +bots register JOURNAL OH_PUBLIC_KEY LOGICAL_AGENT_ID AGENT_ROOT NAME SKILL_REFS ROUTINE_REFS CORTEX_REFS +bots rotate JOURNAL BOT_ID NEW_WORKER_LEASE +bots deliver JOURNAL BOT_ID SENDER_BOT_ID PAYLOAD HANDOFF_REF +bots claim JOURNAL BOT_ID MESSAGE_ID WORKER_LEASE +bots ack JOURNAL BOT_ID MESSAGE_ID WORKER_LEASE +bots nack JOURNAL BOT_ID MESSAGE_ID WORKER_LEASE +bots expire JOURNAL BOT_ID MESSAGE_ID STALE_CLAIMANT_LEASE +bots retire JOURNAL BOT_ID +bots show JOURNAL +``` + +Successful mutations print `OK `, except DELIVER prints `OK `. Repeated DELIVER prints `DUPLICATE ` without appending. Refusals print `REFUSE ` and exit with that code; success exits zero. `show` emits registration-order `BOT <592-byte-event-prefix-hex> `, `LEASE `, then delivery-order `MESSAGE <160-byte-envelope-hex> `. Bot status is 1 active / 2 retired; message state is 1 pending / 2 claimed / 3 ACKed. The BOT prefix includes original sequence, binding, display and all references; the MESSAGE prefix includes recipient, sender, payload digest, handoff and message id. No wall time or worker/model-dependent text occurs. + +| Exit | Refusal | +| --- | --- | +| 2 | Usage, malformed hex/reference list/name/path or oversized argument | +| 3 | Filesystem, output or syscall failure, including final-component symlinks | +| 4 | Zero id/reference supplied through CLI | +| 5 | Bounded bot/message/event/journal capacity | +| 6 | Invalid journal type, framing, canonical body or derived identity/content id | +| 7 | Noncontiguous event sequence | +| 8 | Record checksum mismatch | +| 9 | Exclusive lock unavailable | +| 10 | Bot already registered | +| 11 | Bot not registered | +| 12 | Bot retired | +| 13 | Worker lease token previously used for this bot | +| 14 | Message not found in this bot's inbox | +| 15 | Stale, foreign or absent current worker lease | +| 16 | CLAIM requires pending state (including claim after ACK) | +| 17 | ACK/NACK/EXPIRE requires claimed state (including repeated ACK) | +| 18 | Supplied worker lease is not the message claimant | +| 19 | EXPIRE requires a stale claimant, not a live claim | + +Refusal precedence follows framing/integrity, replay, then the requested transition. Retirement precedes duplicate-delivery handling. A storage failure after rename may leave a committed event without success output: retries must inspect/replay state, not assume refusal means no commit. Exactly-once ACK refers to admission of the ACK event, not exactly-once execution of an external action. There are no external actions here. + +## Reproducing host acceptance + +The build adapter checks `omc` SHA-256 `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` (Omega `e5b32567`). It composes the unchanged first-party seeded SHA-256 unit `om/sha256/sha256-om2.om` at `55845e70`, SHA-256 `dbf002dd6aa36585632b9d01d98ac3f0bd2fa0f0475082940de53638847994bb`, with this runtime. Only export declarations are removed when composing the unit. No foreign crypto implementation is linked. + +```sh +taskset -c 10-14 nice -n 19 ionice -c3 env PYTHONDONTWRITEBYTECODE=1 \ + OMEGA_OMC=/home/drakestapleton/workspace/omega-mcp/build/omc \ + OMEGA_MV=/home/drakestapleton/workspace/bridge-g1-mv \ + BOTS_RUN_ROOT=/tmp/aienet-m2-acceptance-final bash tests/bots/run.sh +``` + +Use a fresh external run root. The harness records `transcript`, `mutants.tsv`, `results.txt`, source/compiler hashes, exact fixture journals, show output and mutant build/probe transcripts. Independent `sha256sum` checks both public identity derivation and envelope content identity. Capacity fixtures are constructed by the harness, with independently recomputed SHA-256 checksums, not generated through a fake runtime. + +Each catalogued admission/integrity guard (`BOT-GUARD` in the source) gets a precise failing negative control and a separately compiled sed-patched removal mutant. A mutant counts as killed only when its targeted baseline probe fails; build failures are harness failures, not kills. The corpus additionally checks usage, missing bot/message, filesystem refusals, lock contention and symlink refusal. `BOTS_KILL=1` through `6` is a deliberately explicit test-only fault seam in the runtime: SIGKILL after candidate open, prefix write, event write, candidate fsync, rename and directory fsync. Eight event types exercise every boundary. Replay must match the exact old/new committed bytes and deterministic show output. An arbitrary truncated candidate is ignored and replaced. These are process-interruption tests, not power-loss or filesystem/hardware qualification. + +Compiler restrictions encountered, with no dropped behavior: error 19 at composed line 484 (global arrays cannot be passed as views) was resolved by selector-based bounded copy/access functions and local SHA buffers; error 12 at composed line 621 (register pressure) by splitting reference decoding into temporaries; error 8 at composed line 390 (loop bound too large) by using the supported 999999 bound. No compiler extension or host runtime fallback was required. + +Owner reference revisions: architecture `c6512a4c6ae2e8f8babe23fc9f38880d20d25812`; Open Humanity `53c39bf2031c01e28703dfdad7e8cae89de2d756`; Core `b65e00b0652a3b426dce1bf77f7fe4eccf5f7473`; AEGIS `a39788b0eaaabc694dfa17652420e35b7dc3eda5`. This adds a local component, not a change to language syntax, compiler ownership, wire schemas, gates or model serving. + +P1 two-machine, P2 federation, signing/key-ownership proof, Cortex integration, network transport, scheduling/model routing, power-loss testing and hardware qualification: **NOT_RUN**, outside this change. No merge or deployment is claimed. + +## Host receipt + +The command above exited 0. The final transcript contains 317 PASS assertions (262 exact CLI exit-code checks), 48 process-interruption replay equalities and 33 compiled guard-removal mutants killed, zero survived. `crumb compile . && crumb verify .` also exited 0 (six crumbs current). Evidence is copied to `/home/drakestapleton/handoffs/aienet-m2/acceptance-final/`; `mutants.tsv` and individual probe transcripts distinguish behavioral kills from compilation. This is HOST_TESTED only, not two-machine, federation, power-loss or hardware qualification. diff --git a/scripts/bots/.crumb b/scripts/bots/.crumb new file mode 100644 index 0000000..14341f5 --- /dev/null +++ b/scripts/bots/.crumb @@ -0,0 +1,19 @@ +{ + "extensions": { + "generated": { + "children": [], + "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "compiled_at": "2026-10-30T00:58:14Z", + "compiler": "crumb-compile/1", + "digest": "sha256:a08eb763297c28d8decb4f281845d8c27f48e5099eb42eda594c659ee12e65b9", + "evidence_files": 0, + "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "files": 0, + "generated_at_commit": "b02bc7fb8c28bf90803d5bd357d1749cabdfc974", + "source_tree": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + "name": "bots-build", + "purpose": "Pinned Omega build adapter for the local M2 bot journal", + "schema_version": "1.0.0" +} diff --git a/scripts/bots/build.sh b/scripts/bots/build.sh new file mode 100755 index 0000000..8c0983b --- /dev/null +++ b/scripts/bots/build.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# Named migration build adapter only; runtime logic is src/bots/bots.om. +set -eu +HERE=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) +OUT=${1:?usage: build.sh OUTPUT} +: "${OMEGA_OMC:?set OMEGA_OMC to e5b32567 omc}" +: "${OMEGA_MV:?set OMEGA_MV to a checkout containing 55845e70}" +[ "$(sha256sum < "$OMEGA_OMC" | cut -c1-64)" = 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f ] || { echo 'BLOCKED: omc pin mismatch' >&2; exit 3; } +T=$(mktemp -d) +trap 'rm -rf "$T"' EXIT HUP INT TERM +git -C "$OMEGA_MV" show 55845e70:om/sha256/sha256-om2.om > "$T/sha.om" +[ "$(sha256sum < "$T/sha.om" | cut -c1-64)" = dbf002dd6aa36585632b9d01d98ac3f0bd2fa0f0475082940de53638847994bb ] || { echo 'BLOCKED: SHA unit mismatch' >&2; exit 3; } +sed 's/^export fn /fn /' "$T/sha.om" > "$T/unit.om" +cat "$T/unit.om" "${BOTS_SOURCE:-$HERE/src/bots/bots.om}" > "$T/source.om" +"$OMEGA_OMC" < "$T/source.om" > "$T/bots" +chmod +x "$T/bots" +mv "$T/bots" "$OUT" +sha256sum "$OUT" diff --git a/src/bots/.crumb b/src/bots/.crumb new file mode 100644 index 0000000..335a51d --- /dev/null +++ b/src/bots/.crumb @@ -0,0 +1,19 @@ +{ + "extensions": { + "generated": { + "children": [], + "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "compiled_at": "2026-10-30T00:58:14Z", + "compiler": "crumb-compile/1", + "digest": "sha256:1fda2bea1749fa6a745930268ee725c9e61e4b2294bebf4ce62ec540eecb0f04", + "evidence_files": 0, + "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "files": 0, + "generated_at_commit": "b02bc7fb8c28bf90803d5bd357d1749cabdfc974", + "source_tree": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + "name": "bots", + "purpose": "M2 local bot identity bindings and durable inbox journal in Omega", + "schema_version": "1.0.0" +} diff --git a/src/bots/bots.om b/src/bots/bots.om new file mode 100644 index 0000000..dfefce9 --- /dev/null +++ b/src/bots/bots.om @@ -0,0 +1,755 @@ +note SPDX-License-Identifier: AGPL-3.0-or-later +note Local bot journal only. Concatenate after pinned Omega sha256-om2 unit. +global BR uchar 1024 +global BJ uchar 1048576 +global BB uchar 65536 +global BL uchar 2048 +global BM uchar 262144 +global BC uchar 8192 +global BS ulong 256 +global BT ulong 64 +global BV ulong 12 +global BA uchar 4096 +global BP uchar 4096 +global BK uchar 4096 +global BF uchar 4096 +global BD uchar 4096 +global BN uchar 8192 +global BO uchar 4096 +text bdom "AIEN-BOT-V1" +text mdom "AIEN-BOT-MESSAGE-V1" +text hx "0123456789abcdef" +text ec "REFUSE " +text ok "OK " +text dup "DUPLICATE " +text bn "BOT " +text ln "LEASE " +text mn "MESSAGE " +text cmds "register rotate deliver claim ack nack expire retire show" +text kenv "BOTS_KILL=" + +text lockend ".lock" +text candend ".cand" +global BH uchar 32 +fn bg s ulong p ulong to uchar +if eq s 1 +ret get BR p +end +if eq s 2 +ret get BJ p +end +if eq s 3 +ret get BB p +end +if eq s 4 +ret get BL p +end +if eq s 5 +ret get BM p +end +if eq s 6 +ret get BC p +end +if eq s 7 +ret get BA p +end +if eq s 8 +ret get BP p +end +if eq s 9 +ret get BK p +end +if eq s 10 +ret get BF p +end +if eq s 11 +ret get BD p +end +if eq s 12 +ret get BN p +end +if eq s 13 +ret get BO p +end +if eq s 14 +ret get BH p +end +if eq s 15 +ret get cmds p +end +if eq s 16 +ret get kenv p +end +if eq s 17 +ret get lockend p +end +if eq s 18 +ret get candend p +end +bfail 3 +ret 0 +end +fn bp s ulong p ulong v uchar to void +if eq s 1 +put BR p v +ret +end +if eq s 2 +put BJ p v +ret +end +if eq s 3 +put BB p v +ret +end +if eq s 4 +put BL p v +ret +end +if eq s 5 +put BM p v +ret +end +if eq s 6 +put BC p v +ret +end +if eq s 7 +put BA p v +ret +end +if eq s 8 +put BP p v +ret +end +if eq s 9 +put BK p v +ret +end +if eq s 10 +put BF p v +ret +end +if eq s 11 +put BD p v +ret +end +if eq s 12 +put BN p v +ret +end +if eq s 13 +put BO p v +ret +end +if eq s 14 +put BH p v +ret +end +bfail 3 +end +fn bfail code int to void +w = write 1 ec 0 len ec +bdecimal ulong code +bend +exit code +end +fn bcheck yes bool code int to void +if not yes +bfail code +end +end +fn bwrite fd int s ulong off ulong n ulong to void +p = ulong 0 +while lt p n bound 999999 +w = long 0 +if eq s 1 +w = write fd BR add off p sub n p +else +w = write fd BJ add off p sub n p +end +bcheck gt w 0 3 +p = add p ulong w +end +end +fn bdecimal v ulong to void +if gt v 9 +bdecimal div v 10 +end +put BO 0 uchar add rem v 10 48 +w = write 1 BO 0 1 +bcheck eq w 1 3 +end +fn bend to void +put BO 0 10 +w = write 1 BO 0 1 +bcheck eq w 1 3 +end +fn bspace to void +put BO 0 32 +w = write 1 BO 0 1 +bcheck eq w 1 3 +end +fn bhex s ulong off ulong n ulong to void +for i ulong n +v = ulong bg s add off i +put BO mul i 2 get hx shr v 4 +put BO add mul i 2 1 get hx and v 15 +end +w = write 1 BO 0 mul n 2 +bcheck eq w long mul n 2 3 +end +fn bcopy ds ulong dp ulong ss ulong sp ulong n ulong to void +for i ulong n +bp ds add dp i bg ss add sp i +end +end +fn bequal ds ulong dp ulong ss ulong sp ulong n ulong to bool +for i ulong n +if ne bg ds add dp i bg ss add sp i +ret false +end +end +ret true +end +fn bzero s ulong off ulong n ulong to bool +v = uchar 0 +for i ulong n +v = or v bg s add off i +end +ret eq v 0 +end +fn bget a ulong to ulong +v = ulong 0 +for i ulong 8 +v = or shl v 8 ulong get BR add a i +end +ret v +end +fn bset a ulong v ulong to void +for i ulong 8 +put BR add a i uchar and shr v mul sub 7 i 8 255 +end +end +fn bclear to void +for i ulong 1024 +put BR i 0 +end +end +fn barg n ulong to ulong +r = argread n BA 0 len BA +bcheck ge r 0 2 +ret ulong r +end +fn bnyb c uchar to uchar +if and ge c 48 le c 57 +ret sub c 48 +end +if and ge c 97 le c 102 +ret add sub c 97 10 +end +bfail 2 +ret 0 +end +fn bparse n ulong off ulong to void +r = barg n +note BOT-GUARD hex +bcheck eq r 64 2 +for i ulong 32 +v = shl bnyb get BA mul i 2 4 +put BR add off i or v bnyb get BA add mul i 2 1 +end +note BOT-GUARD nonzero +bcheck not bzero 1 off 32 4 +end +fn brefs n ulong off ulong to void +r = barg n +if and eq r 1 eq get BA 0 45 +ret +end +note BOT-GUARD refs +bcheck and le r 259 eq rem add r 1 65 0 2 +cnt = div add r 1 65 +for j ulong cnt +for i ulong 32 +p = add mul j 65 mul i 2 +v = shl bnyb get BA p 4 +v = or v bnyb get BA add p 1 +p = add off mul j 32 +put BR add p i v +end +bcheck not bzero 1 add off mul j 32 32 4 +if lt add j 1 cnt +bcheck eq get BA add mul j 65 64 44 2 +end +end +end +fn bhash mode ulong to void +p = new uchar 1024 0 +d = new uchar 32 0 +n = ulong 992 +dest = ulong 992 +if eq mode 0 +for i ulong 992 +put p i get BR i +end +else +if eq mode 1 +for i ulong len bdom +put p i get bdom i +end +n = add len bdom 97 +for i ulong 96 +put p add add len bdom 1 i get BR add 48 i +end +dest = 16 +else +for i ulong len mdom +put p i get mdom i +end +n = add len mdom 129 +for i ulong 32 +put p add add len mdom 1 i get BR add 16 i +end +for i ulong 96 +put p add add len mdom 33 i get BR add 48 i +end +dest = 144 +end +end +sha256_hash part p 0 n d +for i ulong 32 +put BR add dest i get d i +end +end +fn bpayload n ulong to void +p = new uchar 4096 0 +d = new uchar 32 0 +r = barg n +for i ulong r +put p i get BA i +end +sha256_hash part p 0 r d +for i ulong 32 +put BR add 80 i get d i +end +end +fn bcommand to ulong +n = barg 1 +p = ulong 0 +for k ulong 9 +q = p +while lt p len cmds bound 64 +if eq get cmds p 32 +break +end +p = add p 1 +end +if eq n sub p q +if bequal 7 0 15 q n +ret add k 1 +end +end +p = add p 1 +end +bfail 2 +ret 0 +end +fn bargs t ulong to void +bclear +put BR 0 66 +put BR 1 74 +put BR 2 84 +put BR 3 49 +put BR 4 uchar t +if eq t 1 +bcheck eq argcnt 10 2 +bparse 3 48 +bparse 4 80 +bparse 5 112 +r = barg 6 +note BOT-GUARD name +bcheck and gt r 0 le r 64 2 +for i ulong r +bcheck and ge get BA i 32 le get BA i 126 2 +put BR add 144 i get BA i +end +brefs 7 208 +brefs 8 336 +brefs 9 464 +bhash 1 +ret +end +if eq t 9 +bcheck eq argcnt 3 2 +ret +end +bparse 3 16 +if eq t 8 +bcheck eq argcnt 4 2 +ret +end +if eq t 2 +bcheck eq argcnt 5 2 +bparse 4 48 +ret +end +if eq t 3 +bcheck eq argcnt 7 2 +bparse 4 48 +bpayload 5 +bparse 6 112 +bhash 2 +ret +end +bcheck eq argcnt 6 2 +bparse 4 48 +bparse 5 80 +end +fn bfind to ulong +for i ulong get BV 1 +if bequal 1 16 3 add mul i 1024 16 32 +ret i +end +end +bfail 11 +ret 0 +end +fn bmfind to ulong +for i ulong get BV 2 +if bequal 1 16 5 add mul i 1024 16 32 +if bequal 1 48 5 add mul i 1024 144 32 +ret i +end +end +end +bfail 14 +ret 0 +end +fn bcurrent b ulong off ulong to void +note BOT-GUARD current +bcheck bequal 1 off 4 mul b 32 32 15 +end +fn bregister to void +for i ulong get BV 1 +note BOT-GUARD registered +bcheck not bequal 1 16 3 add mul i 1024 16 32 10 +end +note BOT-GUARD botcap +bcheck lt get BV 1 64 5 +b = get BV 1 +bcopy 3 mul b 1024 1 0 1024 +put BT b 1 +put BV 1 add b 1 +end +fn brotate b ulong to void +for i ulong sub bget 8 1 +p = mul i 1024 +if eq get BJ add p 4 2 +if bequal 2 add p 16 1 16 32 +note BOT-GUARD leaseunique +bcheck not bequal 2 add p 48 1 48 32 13 +end +end +end +bcopy 4 mul b 32 1 48 32 +end +fn bdeliver to void +for i ulong get BV 2 +if bequal 1 144 5 add mul i 1024 144 32 +note BOT-GUARD dedup +put BV 3 1 +ret +end +end +note BOT-GUARD msgcap +bcheck lt get BV 2 256 5 +i = get BV 2 +bcopy 5 mul i 1024 1 0 1024 +put BS i 1 +put BV 2 add i 1 +end +fn bmessage t ulong b ulong to void +m = bmfind +s = get BS m +if eq t 4 +note BOT-GUARD pending +bcheck eq s 1 16 +bcurrent b 80 +bcopy 6 mul m 32 1 80 32 +put BS m 2 +ret +end +note BOT-GUARD claimed +bcheck eq s 2 17 +note BOT-GUARD claimant +bcheck bequal 1 80 6 mul m 32 32 18 +if eq t 7 +note BOT-GUARD expiry +bcheck not bequal 1 80 4 mul b 32 32 19 +else +bcurrent b 80 +end +if eq t 5 +put BS m 3 +else +put BS m 1 +end +for i ulong 32 +put BC add mul m 32 i 0 +end +end +fn bapply to void +put BV 3 0 +t = ulong get BR 4 +note BOT-GUARD type +bcheck and gt t 0 le t 8 6 +if eq t 1 +bregister +ret +end +b = bfind +note BOT-GUARD active +bcheck eq get BT b 1 12 +if eq t 2 +brotate b +ret +end +if eq t 3 +bdeliver +ret +end +if eq t 8 +put BT b 2 +ret +end +bmessage t b +end +fn bshape to void +note BOT-GUARD magic +bcheck and and eq get BR 0 66 eq get BR 1 74 and eq get BR 2 84 eq get BR 3 49 6 +t = ulong get BR 4 +note BOT-GUARD botvalue +bcheck not bzero 1 16 32 6 +note BOT-GUARD reserved +bcheck bzero 1 5 3 6 +if eq t 1 +note BOT-GUARD bindings +bcheck and not bzero 1 48 32 and not bzero 1 80 32 not bzero 1 112 32 6 +bcopy 14 0 1 16 32 +bhash 1 +note BOT-GUARD identity +bcheck bequal 14 0 1 16 32 6 +z = ulong 0 +for i ulong 64 +v = get BR add 144 i +if eq v 0 +z = 1 +else +note BOT-GUARD display +bcheck and eq z 0 and ge v 32 le v 126 6 +end +end +note BOT-GUARD nonempty +bcheck ne get BR 144 0 6 +end +if eq t 2 +note BOT-GUARD leasevalue +bcheck not bzero 1 48 32 6 +end +if eq t 3 +note BOT-GUARD envelope +bcheck and not bzero 1 48 32 not bzero 1 112 32 6 +bcopy 14 0 1 144 32 +bhash 2 +note BOT-GUARD content +bcheck bequal 14 0 1 144 32 6 +end +if and ge t 4 le t 7 +note BOT-GUARD transition +bcheck and not bzero 1 48 32 not bzero 1 80 32 6 +end +n = ulong 48 +if eq t 1 +n = 592 +end +if eq t 2 +n = 80 +end +if eq t 3 +n = 176 +end +if and ge t 4 le t 7 +n = 112 +end +note BOT-GUARD padding +bcheck bzero 1 n sub 992 n 6 +end +fn breplay to void +p = ulong 0 +while lt p get BV 0 bound 1024 +bcopy 1 0 2 p 1024 +bshape +note BOT-GUARD sequence +bcheck eq bget 8 add div p 1024 1 7 +bcopy 14 0 1 992 32 +bhash 0 +note BOT-GUARD checksum +bcheck bequal 14 0 1 992 32 8 +bapply +p = add p 1024 +end +end +fn bpaths to void +n = argread 2 BP 0 2048 +bcheck and gt n 0 lt n 2048 2 +put BV 4 ulong n +bcopy 9 0 8 0 ulong n +bcopy 10 0 8 0 ulong n +bcopy 9 ulong n 17 0 5 +bcopy 10 ulong n 18 0 5 +p = ulong 0 +for i ulong ulong n +if eq get BP i 47 +p = add i 1 +end +end +bcheck lt p ulong n 2 +if eq p 0 +put BD 0 46 +put BV 5 1 +else +bcopy 11 0 8 0 p +put BV 5 p +end +note packed path pair for renameat2 +put BN 0 2 +put BN 2 uchar and add ulong n 5 255 +put BN 3 uchar shr add ulong n 5 8 +bcopy 12 4 10 0 add ulong n 5 +p = add ulong n 9 +put BN p uchar and ulong n 255 +put BN add p 1 uchar shr ulong n 8 +bcopy 12 add p 2 8 0 ulong n +put BV 6 add p add ulong n 2 +end +fn bload to void +n = get BV 4 +note Linux aarch64 O_NOFOLLOW=0100000 and O_DIRECTORY=040000 +lk = int fopen BK 0 add n 5 or int 32768 int 66 384 +bcheck ge lk 0 3 +note BOT-GUARD lock +bcheck eq flock lk 6 0 9 +put BV 7 ulong lk +fd = fopen BP 0 n 32768 0 +if eq fd -2 +ret +end +bcheck ge fd 0 3 +p = ulong 0 +while lt p len BJ bound 999999 +r = read int fd BJ p sub len BJ p +bcheck ge r 0 3 +if eq r 0 +break +end +p = add p ulong r +end +x = new uchar 1 0 +r = read int fd x 0 1 +bcheck eq r 0 5 +bcheck eq fclose int fd 0 3 +note BOT-GUARD alignment +bcheck eq rem p 1024 0 6 +put BV 0 p +breplay +end +fn bfault n ulong to void +for i ulong ulong envcnt +r = envread i BA 0 len BA +if eq r 11 +if bequal 7 0 16 0 10 +if eq ulong get BA 10 add n 48 +w = killpid int getpid 9 +bfail 3 +end +end +end +end +end +fn bcommit to void +n = get BV 4 +note BOT-GUARD eventcap +bcheck lt get BV 0 len BJ 5 +fd = int fopen BF 0 add n 5 or int 32768 int 578 384 +bcheck ge fd 0 3 +bfault 1 +bwrite fd 2 0 get BV 0 +bfault 2 +bwrite fd 1 0 1024 +bfault 3 +bcheck eq fsync fd 0 3 +bfault 4 +bcheck eq fclose fd 0 3 +bcheck eq renames BN 0 get BV 6 0 0 3 +bfault 5 +df = int fopen BD 0 get BV 5 or int 32768 int 16384 0 +bcheck ge df 0 3 +bcheck eq fsync df 0 3 +bfault 6 +bcheck eq fclose df 0 3 +end +fn bshow to void +for i ulong get BV 1 +w = write 1 bn 0 len bn +bhex 3 mul i 1024 592 +bspace +bdecimal get BT i +bend +w = write 1 ln 0 len ln +bhex 3 add mul i 1024 16 32 +bspace +bhex 4 mul i 32 32 +bend +end +for i ulong get BV 2 +w = write 1 mn 0 len mn +bhex 5 add mul i 1024 16 160 +bspace +bdecimal get BS i +bspace +bhex 6 mul i 32 32 +bend +end +end +fn main to int +bcheck ge argcnt 3 2 +bpaths +bload +t = bcommand +if eq t 9 +bcheck eq argcnt 3 2 +bshow +ret 0 +end +bargs t +bset 8 add div get BV 0 1024 1 +bshape +bapply +if eq get BV 3 1 +w = write 1 dup 0 len dup +bhex 1 144 32 +bend +ret 0 +end +bhash 0 +bcommit +w = write 1 ok 0 len ok +if eq t 3 +bhex 1 144 32 +else +bhex 1 16 32 +end +bend +ret 0 +end diff --git a/tests/bots/.crumb b/tests/bots/.crumb new file mode 100644 index 0000000..0cee45b --- /dev/null +++ b/tests/bots/.crumb @@ -0,0 +1,19 @@ +{ + "extensions": { + "generated": { + "children": [], + "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "compiled_at": "2026-10-30T00:58:14Z", + "compiler": "crumb-compile/1", + "digest": "sha256:8c75c397d20cc61816a2306691de2093262a3b9b7708ea519d5fd5cedfa43bcf", + "evidence_files": 0, + "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "files": 0, + "generated_at_commit": "b02bc7fb8c28bf90803d5bd357d1749cabdfc974", + "source_tree": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + "name": "bots-acceptance", + "purpose": "Host negative controls process interruption and guard-removal mutants for M2", + "schema_version": "1.0.0" +} diff --git a/tests/bots/run.sh b/tests/bots/run.sh new file mode 100755 index 0000000..38c6c4b --- /dev/null +++ b/tests/bots/run.sh @@ -0,0 +1,238 @@ +#!/bin/bash +# Harness/oracle only. Production logic remains in src/bots/bots.om. +set -eu +set -o pipefail +HERE=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) +hex() { printf '%064x' "$1"; } +K=$(hex 1); L=$(hex 2); R=$(hex 3); W=$(hex 4); H=$(hex 5); V=$(hex 6); Z=$(hex 0) +fail() { echo "FAIL $*"; exit 1; } +pass() { echo "PASS $*"; } +invoke() { + local expected=$1; shift + set +e + "$@" > "$T/out" 2> "$T/err" + local rc=$? + set -e + [ "$rc" = "$expected" ] || { cat "$T/out" "$T/err"; fail "expected=$expected observed=$rc command=$*"; } + if [ "$expected" -ge 2 ] && [ "$expected" -le 19 ]; then + [ "$(cat "$T/out")" = "REFUSE $expected" ] || fail "refusal output $*" + fi + pass "rc=$rc $*" +} +patch() { # fixture modification, not runtime implementation + printf '%s' "$3" | xxd -r -p | dd of="$1" bs=1 seek="$2" conv=notrunc status=none +} +seal() { + local h + h=$(dd if="$1" bs=1 count=992 status=none | sha256sum | cut -c1-64) + patch "$1" 992 "$h" +} +record() { + dd if="$1" of="$2" bs=1024 skip="$3" count=1 status=none +} +sequence() { patch "$1" 8 "$(printf '%016x' "$2")"; seal "$1"; } +fixture_probe() { + local g=$1; B=$2; F=$3 + T=$(mktemp -d "$4/probe-$g-XXXXXX") + local j=$T/j + case "$g" in + hex) invoke 2 "$B" rotate "$j" "${K}0" "$W";; + nonzero) invoke 4 "$B" rotate "$j" "$Z" "$W";; + refs) invoke 2 "$B" register "$j" "$K" "$L" "$R" Allen bad - -;; + name) invoke 2 "$B" register "$j" "$K" "$L" "$R" '' - - -;; + current) cp "$F/stale" "$j"; invoke 15 "$B" ack "$j" "$ID" "$MID" "$W";; + registered) cp "$F/base" "$j"; invoke 10 "$B" register "$j" "$K" "$L" "$R" Allen "$K,$L" "$R" "$H";; + botcap) cp "$F/botcap" "$j"; invoke 5 "$B" register "$j" "$(hex 999)" "$L" "$R" Extra - - -;; + leaseunique) cp "$F/lease" "$j"; invoke 13 "$B" rotate "$j" "$ID" "$W";; + dedup) cp "$F/acked" "$j"; cp "$j" "$T/before"; invoke 0 "$B" deliver "$j" "$ID" "$K" hello "$H"; [ "$(cat "$T/out")" = "DUPLICATE $MID" ] || fail duplicate-output; cmp "$j" "$T/before" || fail duplicate-append; pass duplicate-no-append;; + msgcap) cp "$F/msgcap" "$j"; invoke 5 "$B" deliver "$j" "$ID" "$K" overflow "$H";; + pending) cp "$F/acked" "$j"; invoke 16 "$B" claim "$j" "$ID" "$MID" "$V";; + claimed) cp "$F/acked" "$j"; invoke 17 "$B" ack "$j" "$ID" "$MID" "$V";; + claimant) cp "$F/claimed" "$j"; invoke 18 "$B" ack "$j" "$ID" "$MID" "$V";; + expiry) cp "$F/claimed" "$j"; invoke 19 "$B" expire "$j" "$ID" "$MID" "$W";; + active) cp "$F/retired" "$j"; invoke 12 "$B" deliver "$j" "$ID" "$K" hello "$H";; + type) cp "$F/type" "$j"; invoke 6 "$B" show "$j";; + magic) cp "$F/magic" "$j"; invoke 6 "$B" show "$j";; + botvalue) cp "$F/botvalue" "$j"; invoke 6 "$B" show "$j";; + reserved) cp "$F/reserved" "$j"; invoke 6 "$B" show "$j";; + bindings) cp "$F/bindings" "$j"; invoke 6 "$B" show "$j";; + identity) cp "$F/identity" "$j"; invoke 6 "$B" show "$j";; + display) cp "$F/display" "$j"; invoke 6 "$B" show "$j";; + nonempty) cp "$F/nonempty" "$j"; invoke 6 "$B" show "$j";; + leasevalue) cp "$F/leasevalue" "$j"; invoke 6 "$B" show "$j";; + envelope) cp "$F/envelope" "$j"; invoke 6 "$B" show "$j";; + content) cp "$F/content" "$j"; invoke 6 "$B" show "$j";; + transition) cp "$F/transition" "$j"; invoke 6 "$B" show "$j";; + padding) cp "$F/padding" "$j"; invoke 6 "$B" show "$j";; + sequence) cp "$F/sequence" "$j"; invoke 7 "$B" show "$j";; + checksum) cp "$F/checksum" "$j"; invoke 8 "$B" show "$j";; + lock) cp "$F/base" "$j"; exec 8>"$j.lock"; flock -x 8; invoke 9 "$B" show "$j"; flock -u 8; exec 8>&-;; + alignment) dd if="$F/base" of="$j" bs=1 count=1000 status=none; invoke 6 "$B" show "$j";; + eventcap) cp "$F/eventcap" "$j"; invoke 5 "$B" nack "$j" "$ID" "$MID" "$W";; + *) fail "unknown probe $g";; + esac +} +if [ "${1:-}" = --probe ]; then + ID=$5; MID=$6 + fixture_probe "$2" "$3" "$4" "$7" + exit 0 +fi +: "${BOTS_RUN_ROOT:?set an external BOTS_RUN_ROOT}" +: "${OMEGA_OMC:?set pinned OMEGA_OMC}" +: "${OMEGA_MV:?set OMEGA_MV checkout}" +case "$BOTS_RUN_ROOT" in "$HERE"|"$HERE"/*) fail 'run root must be external';; esac +mkdir -p "$BOTS_RUN_ROOT" +[ ! -e "$BOTS_RUN_ROOT/transcript" ] || fail 'use a fresh run root' +exec > >(tee "$BOTS_RUN_ROOT/transcript") 2>&1 +T=$BOTS_RUN_ROOT/work +F=$BOTS_RUN_ROOT/fixtures +mkdir -p "$T" "$F" "$BOTS_RUN_ROOT/mutants" +B=$BOTS_RUN_ROOT/bots +sh "$HERE/scripts/bots/build.sh" "$B" > "$BOTS_RUN_ROOT/build.txt" +sha256sum "$OMEGA_OMC" "$HERE/src/bots/bots.om" "$HERE/scripts/bots/build.sh" "$0" > "$BOTS_RUN_ROOT/sources.sha256" +j=$T/j +invoke 0 "$B" show "$j" +[ ! -s "$T/out" ] || fail empty-show +invoke 0 "$B" register "$j" "$K" "$L" "$R" Allen "$K,$L" "$R" "$H" +ID=${ID:-$(cut -d' ' -f2 "$T/out")} +ORACLE=$({ printf 'AIEN-BOT-V1\0'; printf '%s' "$K$L$R" | xxd -r -p; } | sha256sum | cut -c1-64) +[ "$ID" = "$ORACLE" ] || fail identity-oracle +pass independent-identity-sha256 +cp "$j" "$F/base" +invoke 0 "$B" rotate "$j" "$ID" "$W"; cp "$j" "$F/lease" +invoke 0 "$B" deliver "$j" "$ID" "$K" hello "$H" +MID=$(cut -d' ' -f2 "$T/out") +PD=$(printf hello | sha256sum | cut -c1-64) +ORACLE=$({ printf 'AIEN-BOT-MESSAGE-V1\0'; printf '%s' "$ID$K$PD$H" | xxd -r -p; } | sha256sum | cut -c1-64) +[ "$MID" = "$ORACLE" ] || fail message-oracle +pass independent-message-sha256 +cp "$j" "$F/pending" +invoke 0 "$B" claim "$j" "$ID" "$MID" "$W"; cp "$j" "$F/claimed" +invoke 0 "$B" nack "$j" "$ID" "$MID" "$W" +invoke 0 "$B" claim "$j" "$ID" "$MID" "$W" +# Keep minimal fixtures to make the exact historical sequence unambiguous. +cp "$F/claimed" "$j" +invoke 0 "$B" rotate "$j" "$ID" "$V"; cp "$j" "$F/stale" +invoke 0 "$B" expire "$j" "$ID" "$MID" "$W"; cp "$j" "$F/expired" +invoke 0 "$B" claim "$j" "$ID" "$MID" "$V"; cp "$j" "$F/claim2" +invoke 0 "$B" ack "$j" "$ID" "$MID" "$V"; cp "$j" "$F/acked" +invoke 0 "$B" retire "$j" "$ID"; cp "$j" "$F/retired" +invoke 0 "$B" show "$j"; cp "$T/out" "$BOTS_RUN_ROOT/final-state.txt" +invoke 0 "$B" show "$j"; cmp "$T/out" "$BOTS_RUN_ROOT/final-state.txt"; pass deterministic-replay +# Typed, rechecksummed adversarial fixtures. The checksum is integrity, not authentication. +for name in magic reserved bindings identity display nonempty padding sequence checksum; do cp "$F/base" "$F/$name"; done +patch "$F/magic" 0 00; seal "$F/magic" +patch "$F/reserved" 5 01; seal "$F/reserved" +patch "$F/identity" 16 "$K"; seal "$F/identity" +patch "$F/display" 144 01; seal "$F/display" +printf '%0128d' 0 | xxd -r -p | dd of="$F/nonempty" bs=1 seek=144 conv=notrunc status=none; seal "$F/nonempty" +patch "$F/padding" 700 01; seal "$F/padding" +sequence "$F/sequence" 2 +patch "$F/checksum" 1023 ff +patch "$F/bindings" 48 "$Z" +NEWID=$({ printf 'AIEN-BOT-V1\0'; printf '%s' "$Z$L$R" | xxd -r -p; } | sha256sum | cut -c1-64) +patch "$F/bindings" 16 "$NEWID"; seal "$F/bindings" +record "$F/retired" "$T/rec" 8 +patch "$T/rec" 4 09; sequence "$T/rec" 2; cat "$F/base" "$T/rec" > "$F/type" +patch "$T/rec" 4 08; patch "$T/rec" 16 "$Z"; seal "$T/rec"; cat "$F/base" "$T/rec" > "$F/botvalue" +record "$F/lease" "$T/rec" 1; patch "$T/rec" 48 "$Z"; seal "$T/rec"; cat "$F/base" "$T/rec" > "$F/leasevalue" +record "$F/pending" "$T/rec" 2; patch "$T/rec" 48 "$Z" +NEWMID=$({ printf 'AIEN-BOT-MESSAGE-V1\0'; printf '%s' "$ID$Z$PD$H" | xxd -r -p; } | sha256sum | cut -c1-64) +patch "$T/rec" 144 "$NEWMID"; seal "$T/rec"; cat "$F/lease" "$T/rec" > "$F/envelope" +record "$F/pending" "$T/rec" 2; patch "$T/rec" 144 "$K"; seal "$T/rec"; cat "$F/lease" "$T/rec" > "$F/content" +record "$F/claimed" "$T/rec" 3; patch "$T/rec" 80 "$Z"; seal "$T/rec"; cat "$F/pending" "$T/rec" > "$F/transition" +# Capacity fixtures derive valid records with the independent SHA-256 oracle. +: > "$F/botcap" +for ((i=1;i<=64;i++)); do + cp "$F/base" "$T/rec"; PK=$(hex "$i"); patch "$T/rec" 48 "$PK" + BI=$({ printf 'AIEN-BOT-V1\0'; printf '%s' "$PK$L$R" | xxd -r -p; } | sha256sum | cut -c1-64) + patch "$T/rec" 16 "$BI"; sequence "$T/rec" "$i"; cat "$T/rec" >> "$F/botcap" +done +cp "$F/lease" "$F/msgcap" +for ((i=1;i<=256;i++)); do + record "$F/pending" "$T/rec" 2; HH=$(hex "$i"); patch "$T/rec" 112 "$HH" + MI=$({ printf 'AIEN-BOT-MESSAGE-V1\0'; printf '%s' "$ID$K$PD$HH" | xxd -r -p; } | sha256sum | cut -c1-64) + patch "$T/rec" 144 "$MI"; sequence "$T/rec" "$((i+2))"; cat "$T/rec" >> "$F/msgcap" +done +cp "$F/pending" "$F/eventcap" +for ((i=4;i<=1024;i++)); do + record "$F/claimed" "$T/rec" 3 + if ((i%2)); then patch "$T/rec" 4 06; fi + sequence "$T/rec" "$i"; cat "$T/rec" >> "$F/eventcap" +done +# Every catalogued state/integrity guard has a baseline refusal and a compiling removal mutant. +GUARDS=$(sed -n 's/^note BOT-GUARD //p' "$HERE/src/bots/bots.om") +for g in $GUARDS; do fixture_probe "$g" "$B" "$F" "$BOTS_RUN_ROOT"; done +T=$BOTS_RUN_ROOT/work +# Other exact refusal surfaces: usage, I/O, missing bot and missing message. +invoke 2 "$B" bogus "$T/unknown" +invoke 2 "$B" register "$T/unknown" "$K" "$L" "$R" $'bad\nname' - - - +invoke 3 "$B" show "$T/absent/j" +cp "$F/lease" "$T/missing" +invoke 11 "$B" rotate "$T/missing" "$K" "$W" +invoke 14 "$B" claim "$T/missing" "$ID" "$K" "$W" +# Final components must not follow symlinks; lock/journal/candidate each independently refused. +for target in lock journal candidate; do + SJ=$T/symlink-$target + case "$target" in lock) ln -s "$F/base" "$SJ.lock";; journal) ln -s "$F/base" "$SJ";; candidate) cp "$F/base" "$SJ"; ln -s "$F/base" "$SJ.cand";; esac + if [ "$target" = candidate ]; then invoke 3 "$B" rotate "$SJ" "$ID" "$W"; else invoke 3 "$B" show "$SJ"; fi +done +# Each typed transition is killed after candidate open, prefix write, event write, +# candidate fsync, rename and directory fsync. Before rename old state; after rename new. +for op in register rotate deliver claim ack nack expire retire; do + case "$op" in + register) pre=; args=(register "$K" "$L" "$R" Allen "$K,$L" "$R" "$H");; + rotate) pre=base; args=(rotate "$ID" "$W");; + deliver) pre=lease; args=(deliver "$ID" "$K" hello "$H");; + claim) pre=pending; args=(claim "$ID" "$MID" "$W");; + ack) pre=claimed; args=(ack "$ID" "$MID" "$W");; + nack) pre=claimed; args=(nack "$ID" "$MID" "$W");; + expire) pre=stale; args=(expire "$ID" "$MID" "$W");; + retire) pre=base; args=(retire "$ID");; + esac + d=$BOTS_RUN_ROOT/crash/$op; mkdir -p "$d" + [ -z "$pre" ] || cp "$F/$pre" "$d/expected" + invoke 0 "$B" "${args[0]}" "$d/expected" "${args[@]:1}" + invoke 0 "$B" show "$d/expected"; cp "$T/out" "$d/new-show" + for boundary in 1 2 3 4 5 6; do + cj=$d/j-$boundary + [ -z "$pre" ] || cp "$F/$pre" "$cj" + invoke 137 env BOTS_KILL=$boundary "$B" "${args[0]}" "$cj" "${args[@]:1}" + if [ "$boundary" -lt 5 ]; then + if [ -n "$pre" ]; then cmp "$F/$pre" "$cj"; else [ ! -e "$cj" ] || fail crash-created; fi + invoke 0 "$B" show "$cj"; cp "$T/out" "$d/old-show-$boundary" + if [ -n "$pre" ]; then invoke 0 "$B" show "$F/$pre"; cmp "$T/out" "$d/old-show-$boundary"; else [ ! -s "$d/old-show-$boundary" ] || fail crash-old; fi + invoke 0 "$B" "${args[0]}" "$cj" "${args[@]:1}" + fi + cmp "$d/expected" "$cj" || fail "crash journal $op/$boundary" + invoke 0 "$B" show "$cj"; cmp "$T/out" "$d/new-show" || fail "crash replay $op/$boundary" + pass "crash-equality $op/$boundary" + done +done +# An arbitrary torn, uncommitted candidate is ignored, then safely overwritten. +cp "$F/pending" "$T/torn"; dd if="$F/claimed" of="$T/torn.cand" bs=1 count=3500 status=none +invoke 0 "$B" show "$T/torn"; cp "$T/out" "$T/torn-show" +invoke 0 "$B" show "$F/pending"; cmp "$T/out" "$T/torn-show"; pass torn-candidate-ignored +invoke 0 "$B" claim "$T/torn" "$ID" "$MID" "$W"; cmp "$T/torn" "$F/claimed"; pass torn-candidate-replaced +printf 'guard\tbuild_exit\tprobe_exit\tverdict\n' > "$BOTS_RUN_ROOT/mutants.tsv" +killed=0; survived=0 +for g in $GUARDS; do + md=$BOTS_RUN_ROOT/mutants/$g; mkdir -p "$md" + if [ "$g" = dedup ]; then + sed '/^note BOT-GUARD dedup$/{n;s/.*/put BV 3 0/;}' "$HERE/src/bots/bots.om" > "$md/bots.om" + else + sed "/^note BOT-GUARD $g\$/{n;s/^bcheck .*/bcheck true 99/;}" "$HERE/src/bots/bots.om" > "$md/bots.om" + fi + cmp -s "$md/bots.om" "$HERE/src/bots/bots.om" && fail "no mutation $g" + BOTS_SOURCE=$md/bots.om sh "$HERE/scripts/bots/build.sh" "$md/bots" > "$md/build.txt" 2>&1 || fail "mutant did not compile $g" + set +e + bash "$0" --probe "$g" "$md/bots" "$F" "$ID" "$MID" "$md" > "$md/probe.txt" 2>&1 + rc=$? + set -e + if [ "$rc" = 0 ]; then verdict=SURVIVED; survived=$((survived+1)); else verdict=KILLED; killed=$((killed+1)); fi + printf '%s\t0\t%s\t%s\n' "$g" "$rc" "$verdict" >> "$BOTS_RUN_ROOT/mutants.tsv" + echo "$verdict $g probe_exit=$rc" +done +printf 'mutants_killed=%s\nmutants_survived=%s\ncrash_cases=48\n' "$killed" "$survived" > "$BOTS_RUN_ROOT/results.txt" +[ "$survived" = 0 ] || fail "surviving mutants=$survived" +pass "ALL mutants_killed=$killed mutants_survived=$survived crash_cases=48" From c528c790ac97d309100b44ef042f7fb95740d088 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 29 Oct 2026 20:18:17 -0500 Subject: [PATCH 2/2] test(bots): classify mutant outcomes and verify commit barriers Signed-off-by: Drake Stapleton --- docs/BOTS.md | 10 +-- scripts/bots/.crumb | 10 +-- src/bots/.crumb | 10 +-- tests/bots/.crumb | 10 +-- tests/bots/run.sh | 147 ++++++++++++++++++++++++++++++++++++++------ 5 files changed, 148 insertions(+), 39 deletions(-) diff --git a/docs/BOTS.md b/docs/BOTS.md index c24bc21..92922ed 100644 --- a/docs/BOTS.md +++ b/docs/BOTS.md @@ -1,6 +1,6 @@ # M2: persistent bot records and durable inboxes -PROPOSED local component for [architecture #311](https://github.com/aien-dev/aien-architecture-mv/issues/311). Not a master plan, network schema, capability, or new subject identity. +PROPOSED local component for the [bot-network plan comment](https://github.com/aien-dev/aien-architecture-mv/issues/311#issuecomment-6511785962), coordinated on architecture issue #311, whose title is TURING NETWORK R0. Not a master plan, network schema, capability, or new subject identity. ## Owners and source map @@ -75,12 +75,14 @@ The build adapter checks `omc` SHA-256 `2c82480596bbdc50cda9626866209ef662d5834f taskset -c 10-14 nice -n 19 ionice -c3 env PYTHONDONTWRITEBYTECODE=1 \ OMEGA_OMC=/home/drakestapleton/workspace/omega-mcp/build/omc \ OMEGA_MV=/home/drakestapleton/workspace/bridge-g1-mv \ - BOTS_RUN_ROOT=/tmp/aienet-m2-acceptance-final bash tests/bots/run.sh + BOTS_RUN_ROOT=/home/drakestapleton/handoffs/aienet-m2/round2 bash tests/bots/run.sh ``` Use a fresh external run root. The harness records `transcript`, `mutants.tsv`, `results.txt`, source/compiler hashes, exact fixture journals, show output and mutant build/probe transcripts. Independent `sha256sum` checks both public identity derivation and envelope content identity. Capacity fixtures are constructed by the harness, with independently recomputed SHA-256 checksums, not generated through a fake runtime. -Each catalogued admission/integrity guard (`BOT-GUARD` in the source) gets a precise failing negative control and a separately compiled sed-patched removal mutant. A mutant counts as killed only when its targeted baseline probe fails; build failures are harness failures, not kills. The corpus additionally checks usage, missing bot/message, filesystem refusals, lock contention and symlink refusal. `BOTS_KILL=1` through `6` is a deliberately explicit test-only fault seam in the runtime: SIGKILL after candidate open, prefix write, event write, candidate fsync, rename and directory fsync. Eight event types exercise every boundary. Replay must match the exact old/new committed bytes and deterministic show output. An arbitrary truncated candidate is ignored and replaced. These are process-interruption tests, not power-loss or filesystem/hardware qualification. +Each catalogued admission/integrity guard (`BOT-GUARD` in the source) gets a precise failing negative control and a separately compiled sed-patched removal mutant. `mutants.tsv` preserves expected and actual binary exits separately from the assertion-child exit. Semantic admissions are `KILLED_ADMIT`; changed valid refusal codes are `KILLED_CODE`; output/state/barrier mismatches have distinct `KILLED_OUTPUT`, `KILLED_STATE`, `KILLED_BARRIER` verdicts. Omega traps (101..114), signals and infrastructure/build failures are `TRAPPED`, `SIGNALLED` and `ERROR`, never kills. Removing botcap/msgcap checks hits fixed-size array bounds (exit 103, trap 3), so these two controls are honestly TRAPPED, not semantic counterexamples. No extra allocation is introduced solely to make a mutant admissible. + +The corpus additionally checks usage, missing bot/message, filesystem refusals, lock contention and symlink refusal. `BOTS_KILL=1` through `6` is a deliberately explicit test-only fault seam: SIGKILL after candidate open, prefix write, event write, candidate fsync, rename and directory fsync. Eight event types exercise every boundary. Replay must match exact old/new committed bytes and deterministic show output; a truncated candidate is ignored and replaced. A required strace oracle tracks actual candidate/directory descriptor opens and asserts successful `fsync(candidate)` then `renameat2(candidate,journal)` then `fsync(directory)`. Separate mutants remove each fsync and move rename before candidate fsync. Missing strace fails closed with NOT_RUN, not PASS. This establishes commit-barrier ordering evidence, not power-loss qualification. Compiler restrictions encountered, with no dropped behavior: error 19 at composed line 484 (global arrays cannot be passed as views) was resolved by selector-based bounded copy/access functions and local SHA buffers; error 12 at composed line 621 (register pressure) by splitting reference decoding into temporaries; error 8 at composed line 390 (loop bound too large) by using the supported 999999 bound. No compiler extension or host runtime fallback was required. @@ -90,4 +92,4 @@ P1 two-machine, P2 federation, signing/key-ownership proof, Cortex integration, ## Host receipt -The command above exited 0. The final transcript contains 317 PASS assertions (262 exact CLI exit-code checks), 48 process-interruption replay equalities and 33 compiled guard-removal mutants killed, zero survived. `crumb compile . && crumb verify .` also exited 0 (six crumbs current). Evidence is copied to `/home/drakestapleton/handoffs/aienet-m2/acceptance-final/`; `mutants.tsv` and individual probe transcripts distinguish behavioral kills from compilation. This is HOST_TESTED only, not two-machine, federation, power-loss or hardware qualification. +The earlier round-one claim of 33 semantic mutant kills is withdrawn: two capacity mutants actually trapped at fixed array bounds. Historical evidence under `/home/drakestapleton/handoffs/aienet-m2/acceptance-final/` is unchanged; round-two evidence and corrected per-verdict results live separately under `/home/drakestapleton/handoffs/aienet-m2/round2/`. Only host behavior and barrier ordering are exercised, not two-machine, federation, power-loss or hardware qualification. diff --git a/scripts/bots/.crumb b/scripts/bots/.crumb index 14341f5..e68cc8f 100644 --- a/scripts/bots/.crumb +++ b/scripts/bots/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-30T00:58:14Z", + "compiled_at": "2026-10-30T01:17:49Z", "compiler": "crumb-compile/1", - "digest": "sha256:a08eb763297c28d8decb4f281845d8c27f48e5099eb42eda594c659ee12e65b9", + "digest": "sha256:2d28448812bbbcb9afc98df6b680a7cb97ecf73bbb955334d1c34486afdb6e14", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 0, - "generated_at_commit": "b02bc7fb8c28bf90803d5bd357d1749cabdfc974", - "source_tree": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + "files": 1, + "generated_at_commit": "144370e8818ff5c87a7c751291fbad2859d26686", + "source_tree": "sha256:ae28d99ab544137ec9321f14d5d1a2c45ae3c16038aef930ec69f12bc8c57b19" } }, "name": "bots-build", diff --git a/src/bots/.crumb b/src/bots/.crumb index 335a51d..671a5a8 100644 --- a/src/bots/.crumb +++ b/src/bots/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-30T00:58:14Z", + "compiled_at": "2026-10-30T01:17:49Z", "compiler": "crumb-compile/1", - "digest": "sha256:1fda2bea1749fa6a745930268ee725c9e61e4b2294bebf4ce62ec540eecb0f04", + "digest": "sha256:7c98171f6e5aad846a859793f80e28bf88d5894d2f2e866abc0828fea19d79ac", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 0, - "generated_at_commit": "b02bc7fb8c28bf90803d5bd357d1749cabdfc974", - "source_tree": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + "files": 1, + "generated_at_commit": "144370e8818ff5c87a7c751291fbad2859d26686", + "source_tree": "sha256:6240c0a3ce454d956d38d7e31ff7ea22e813c56d53ee621cca8a8fb14a64fb95" } }, "name": "bots", diff --git a/tests/bots/.crumb b/tests/bots/.crumb index 0cee45b..9213df7 100644 --- a/tests/bots/.crumb +++ b/tests/bots/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-30T00:58:14Z", + "compiled_at": "2026-10-30T01:17:49Z", "compiler": "crumb-compile/1", - "digest": "sha256:8c75c397d20cc61816a2306691de2093262a3b9b7708ea519d5fd5cedfa43bcf", + "digest": "sha256:5ec32d1e2234b31b60e3d113531f952972c1b927d989df7466bbf38a1fc5d826", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 0, - "generated_at_commit": "b02bc7fb8c28bf90803d5bd357d1749cabdfc974", - "source_tree": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + "files": 1, + "generated_at_commit": "144370e8818ff5c87a7c751291fbad2859d26686", + "source_tree": "sha256:84f6f9dd02d484da8e032ab6410b3bba112ee28a39f328af044699b319059ef1" } }, "name": "bots-acceptance", diff --git a/tests/bots/run.sh b/tests/bots/run.sh index 38c6c4b..27f2489 100755 --- a/tests/bots/run.sh +++ b/tests/bots/run.sh @@ -7,15 +7,42 @@ hex() { printf '%064x' "$1"; } K=$(hex 1); L=$(hex 2); R=$(hex 3); W=$(hex 4); H=$(hex 5); V=$(hex 6); Z=$(hex 0) fail() { echo "FAIL $*"; exit 1; } pass() { echo "PASS $*"; } +probe_result() { + # A separate receipt preserves the binary status even though the assertion child exits 1. + if [ -n "${PROBE_META:-}" ]; then + printf '%s\t%s\t%s\n' "$1" "$2" "$3" > "$PROBE_META" + fi +} +probe_state_fail() { + probe_result 0 0 KILLED_STATE + fail "$*" +} +classify_status() { + local expected=$1 actual=$2 + if ((actual>=101 && actual<=114)); then echo TRAPPED + elif ((actual>128 && actual<=192)); then echo SIGNALLED + elif [ "$actual" = 0 ] && [ "$expected" != 0 ]; then echo KILLED_ADMIT + elif ((actual>=2 && actual<=19)) && [ "$(cat "$T/out")" = "REFUSE $actual" ]; then echo KILLED_CODE + else echo ERROR + fi +} invoke() { local expected=$1; shift set +e "$@" > "$T/out" 2> "$T/err" local rc=$? set -e - [ "$rc" = "$expected" ] || { cat "$T/out" "$T/err"; fail "expected=$expected observed=$rc command=$*"; } + probe_result "$expected" "$rc" SURVIVED + if [ "$rc" != "$expected" ]; then + probe_result "$expected" "$rc" "$(classify_status "$expected" "$rc")" + cat "$T/out" "$T/err" + fail "expected=$expected observed=$rc command=$*" + fi if [ "$expected" -ge 2 ] && [ "$expected" -le 19 ]; then - [ "$(cat "$T/out")" = "REFUSE $expected" ] || fail "refusal output $*" + if [ "$(cat "$T/out")" != "REFUSE $expected" ]; then + probe_result "$expected" "$rc" KILLED_OUTPUT + fail "refusal output $*" + fi fi pass "rc=$rc $*" } @@ -44,7 +71,7 @@ fixture_probe() { registered) cp "$F/base" "$j"; invoke 10 "$B" register "$j" "$K" "$L" "$R" Allen "$K,$L" "$R" "$H";; botcap) cp "$F/botcap" "$j"; invoke 5 "$B" register "$j" "$(hex 999)" "$L" "$R" Extra - - -;; leaseunique) cp "$F/lease" "$j"; invoke 13 "$B" rotate "$j" "$ID" "$W";; - dedup) cp "$F/acked" "$j"; cp "$j" "$T/before"; invoke 0 "$B" deliver "$j" "$ID" "$K" hello "$H"; [ "$(cat "$T/out")" = "DUPLICATE $MID" ] || fail duplicate-output; cmp "$j" "$T/before" || fail duplicate-append; pass duplicate-no-append;; + dedup) cp "$F/acked" "$j"; cp "$j" "$T/before"; invoke 0 "$B" deliver "$j" "$ID" "$K" hello "$H"; [ "$(cat "$T/out")" = "DUPLICATE $MID" ] || probe_state_fail duplicate-output; cmp "$j" "$T/before" || probe_state_fail duplicate-append; pass duplicate-no-append;; msgcap) cp "$F/msgcap" "$j"; invoke 5 "$B" deliver "$j" "$ID" "$K" overflow "$H";; pending) cp "$F/acked" "$j"; invoke 16 "$B" claim "$j" "$ID" "$MID" "$V";; claimed) cp "$F/acked" "$j"; invoke 17 "$B" ack "$j" "$ID" "$MID" "$V";; @@ -72,6 +99,45 @@ fixture_probe() { *) fail "unknown probe $g";; esac } +barrier_probe() { + B=$1 + T=$(mktemp -d "$2/barrier-XXXXXX") + local j=$T/j trace=$T/commit.strace line fd kind events='' + declare -A kinds=() + if ! command -v strace >/dev/null; then + echo 'NOT_RUN commit barriers: strace unavailable' + probe_result 0 NA ERROR + fail 'strace required' + fi + invoke 0 strace -qq -s 4096 -o "$trace" -e trace=openat,close,fsync,renameat2 \ + "$B" register "$j" "$K" "$L" "$R" Allen - - - + while IFS= read -r line; do + if [[ "$line" == openat* && "$line" =~ =[[:space:]]([0-9]+)$ ]]; then + fd=${BASH_REMATCH[1]} + if [[ "$line" == *"\"$j.cand\""* ]]; then kinds[$fd]=candidate + elif [[ "$line" == *O_DIRECTORY* ]]; then kinds[$fd]=directory + else kinds[$fd]=other + fi + elif [[ "$line" =~ ^fsync\(([0-9]+)\)[[:space:]]*=[[:space:]]0$ ]]; then + fd=${BASH_REMATCH[1]}; kind=${kinds[$fd]:-unknown} + events="${events}${kind} " + elif [[ "$line" == renameat2* && "$line" == *"\"$j.cand\""* && "$line" == *"\"$j\""* && "$line" =~ =[[:space:]]0$ ]]; then + events="${events}rename " + elif [[ "$line" =~ ^close\(([0-9]+)\) ]]; then + unset "kinds[${BASH_REMATCH[1]}]" + fi + done < "$trace" + printf '%s\n' "$events" > "$T/barriers.txt" + if [ "$events" != 'candidate rename directory ' ]; then + probe_result 0 0 KILLED_BARRIER + fail "commit barriers expected=candidate,rename,directory observed=$events trace=$trace" + fi + pass "commit-barrier-order trace=$trace (not power-loss qualification)" +} +if [ "${1:-}" = --barrier ]; then + barrier_probe "$2" "$3" + exit 0 +fi if [ "${1:-}" = --probe ]; then ID=$5; MID=$6 fixture_probe "$2" "$3" "$4" "$7" @@ -84,6 +150,10 @@ case "$BOTS_RUN_ROOT" in "$HERE"|"$HERE"/*) fail 'run root must be external';; e mkdir -p "$BOTS_RUN_ROOT" [ ! -e "$BOTS_RUN_ROOT/transcript" ] || fail 'use a fresh run root' exec > >(tee "$BOTS_RUN_ROOT/transcript") 2>&1 +if ! command -v strace >/dev/null; then + printf 'barriers=NOT_RUN\nreason=strace unavailable\n' > "$BOTS_RUN_ROOT/results.txt" + fail 'NOT_RUN: strace required for commit-barrier acceptance' +fi T=$BOTS_RUN_ROOT/work F=$BOTS_RUN_ROOT/fixtures mkdir -p "$T" "$F" "$BOTS_RUN_ROOT/mutants" @@ -214,25 +284,62 @@ cp "$F/pending" "$T/torn"; dd if="$F/claimed" of="$T/torn.cand" bs=1 count=3500 invoke 0 "$B" show "$T/torn"; cp "$T/out" "$T/torn-show" invoke 0 "$B" show "$F/pending"; cmp "$T/out" "$T/torn-show"; pass torn-candidate-ignored invoke 0 "$B" claim "$T/torn" "$ID" "$MID" "$W"; cmp "$T/torn" "$F/claimed"; pass torn-candidate-replaced -printf 'guard\tbuild_exit\tprobe_exit\tverdict\n' > "$BOTS_RUN_ROOT/mutants.tsv" -killed=0; survived=0 -for g in $GUARDS; do +barrier_probe "$B" "$BOTS_RUN_ROOT" +printf 'guard\tbuild_exit\tprobe_exit\texpected_binary_exit\tbinary_exit\tverdict\n' > "$BOTS_RUN_ROOT/mutants.tsv" +declare -A counts=() +for g in $GUARDS fsync-candidate fsync-directory barrier-order; do md=$BOTS_RUN_ROOT/mutants/$g; mkdir -p "$md" - if [ "$g" = dedup ]; then - sed '/^note BOT-GUARD dedup$/{n;s/.*/put BV 3 0/;}' "$HERE/src/bots/bots.om" > "$md/bots.om" - else - sed "/^note BOT-GUARD $g\$/{n;s/^bcheck .*/bcheck true 99/;}" "$HERE/src/bots/bots.om" > "$md/bots.om" - fi + case "$g" in + dedup) + sed '/^note BOT-GUARD dedup$/{n;s/.*/put BV 3 0/;}' "$HERE/src/bots/bots.om" > "$md/bots.om";; + fsync-candidate) + sed 's/^bcheck eq fsync fd 0 3$/bcheck true 3/' "$HERE/src/bots/bots.om" > "$md/bots.om";; + fsync-directory) + sed 's/^bcheck eq fsync df 0 3$/bcheck true 3/' "$HERE/src/bots/bots.om" > "$md/bots.om";; + barrier-order) + # Keep both barriers, but move the atomic rename before candidate fsync. + sed '/^bcheck eq renames BN 0 get BV 6 0 0 3$/d; /^bcheck eq fsync fd 0 3$/i bcheck eq renames BN 0 get BV 6 0 0 3' "$HERE/src/bots/bots.om" > "$md/bots.om";; + *) + sed "/^note BOT-GUARD $g\$/{n;s/^bcheck .*/bcheck true 99/;}" "$HERE/src/bots/bots.om" > "$md/bots.om";; + esac cmp -s "$md/bots.om" "$HERE/src/bots/bots.om" && fail "no mutation $g" - BOTS_SOURCE=$md/bots.om sh "$HERE/scripts/bots/build.sh" "$md/bots" > "$md/build.txt" 2>&1 || fail "mutant did not compile $g" set +e - bash "$0" --probe "$g" "$md/bots" "$F" "$ID" "$MID" "$md" > "$md/probe.txt" 2>&1 - rc=$? + BOTS_SOURCE=$md/bots.om sh "$HERE/scripts/bots/build.sh" "$md/bots" > "$md/build.txt" 2>&1 + build_rc=$? set -e - if [ "$rc" = 0 ]; then verdict=SURVIVED; survived=$((survived+1)); else verdict=KILLED; killed=$((killed+1)); fi - printf '%s\t0\t%s\t%s\n' "$g" "$rc" "$verdict" >> "$BOTS_RUN_ROOT/mutants.tsv" - echo "$verdict $g probe_exit=$rc" + rc=NA; expected=NA; actual=NA; verdict=ERROR + if [ "$build_rc" = 0 ]; then + set +e + case "$g" in + fsync-*|barrier-order) PROBE_META=$md/outcome.tsv bash "$0" --barrier "$md/bots" "$md" > "$md/probe.txt" 2>&1;; + *) PROBE_META=$md/outcome.tsv bash "$0" --probe "$g" "$md/bots" "$F" "$ID" "$MID" "$md" > "$md/probe.txt" 2>&1;; + esac + rc=$? + set -e + if [ -f "$md/outcome.tsv" ]; then + IFS=$'\t' read -r expected actual verdict < "$md/outcome.tsv" + # An assertion child that failed without recording a specific counterexample is infrastructure failure. + if [ "$rc" != 0 ] && [ "$verdict" = SURVIVED ]; then verdict=ERROR; fi + if [ "$rc" = 0 ] && [ "$verdict" != SURVIVED ]; then verdict=ERROR; fi + fi + fi + counts[$verdict]=$((${counts[$verdict]:-0}+1)) + printf '%s\t%s\t%s\t%s\t%s\t%s\n' "$g" "$build_rc" "$rc" "$expected" "$actual" "$verdict" >> "$BOTS_RUN_ROOT/mutants.tsv" + echo "$verdict $g binary_exit=$actual probe_exit=$rc" done -printf 'mutants_killed=%s\nmutants_survived=%s\ncrash_cases=48\n' "$killed" "$survived" > "$BOTS_RUN_ROOT/results.txt" -[ "$survived" = 0 ] || fail "surviving mutants=$survived" -pass "ALL mutants_killed=$killed mutants_survived=$survived crash_cases=48" +{ + for verdict in KILLED_ADMIT KILLED_CODE KILLED_STATE KILLED_OUTPUT KILLED_BARRIER TRAPPED SIGNALLED ERROR SURVIVED; do + printf '%s=%s\n' "$verdict" "${counts[$verdict]:-0}" + done + printf 'crash_cases=48\nbarriers=PASS\n' +} > "$BOTS_RUN_ROOT/results.txt" +cat "$BOTS_RUN_ROOT/results.txt" +# Fixed-capacity array bounds make botcap/msgcap removals trap; do not claim semantic kills. +while IFS=$'\t' read -r g build_rc rc expected actual verdict; do + case "$verdict" in + KILLED_*) ;; + TRAPPED) [[ "$g" = botcap || "$g" = msgcap ]] && [ "$actual" = 103 ] || fail "unexpected trap $g=$actual";; + *) fail "unqualified mutant $g verdict=$verdict";; + esac +done < <(sed '1d' "$BOTS_RUN_ROOT/mutants.tsv") +pass 'ALL classified mutants; 48 crash equalities; commit barrier order PASS (not power-loss qualification)'