From 3db764aac8f436ad787570ed2e035489c5dfca5b Mon Sep 17 00:00:00 2001 From: aien Date: Sat, 10 Oct 2026 09:27:28 -0500 Subject: [PATCH 1/4] REGRESSION-sc386 pre-registration Co-authored-by: Drake Stapleton Co-Authored-By: Claude Fable 5.1 --- .../whole-system-e2e/REGRESSION-sc386.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 docs/campaigns/whole-system-e2e/REGRESSION-sc386.md diff --git a/docs/campaigns/whole-system-e2e/REGRESSION-sc386.md b/docs/campaigns/whole-system-e2e/REGRESSION-sc386.md new file mode 100644 index 00000000..fdccb830 --- /dev/null +++ b/docs/campaigns/whole-system-e2e/REGRESSION-sc386.md @@ -0,0 +1,29 @@ +# REGRESSION sc386: compose memory is recalled only when ALLEN is engaged + +Issue: aien-sovereign-core#386. Program: aien-architecture#190, lane L3 (decision by the orchestrator for release v1: memory stays attached to an engaged ALLEN identity through the existing aien-allen-memory path; no new store, no new subsystem). + +## Failing behaviour as observed (run folder RUN-1-dry-20261010T134202Z, harness v1.1, CPU reference backend) + +1. `artifacts/E4-remember.json`: `aien-cli compose remember --text ...` returned `ok: true` and stored a `constraint` record on a daemon with no ALLEN identity. `artifacts/E4-propose.json` then reports `memory.state = not_engaged`, `items_included = 0`: the item can never be used. Also, even when ALLEN is engaged, `remember` writes only a compose constraint record, which the proposal never reads (the proposal reads ALLEN scoped memory). +2. `artifacts/E4-propose.json`, three attempts: prompt 330 to 373 tokens, cut at 48 generated tokens (`finish_reason max_tokens`), every reply re-emitted the whole report instead of one appended line. The small-edit path uses `AIEN_COMPOSE_MAX_TOKENS`, default 48 (`crates/aien-runtime/src/server.rs`, `model_proposer`). + +## Repairs (pre-registered) + +1. `compose remember` writes the item into ALLEN scoped memory (context `work` unless `--context` names another) and still writes the constraint record. When ALLEN is not engaged it refuses with the existing NotEngaged refusal text ("ALLEN is not engaged on this machine ...") and stores nothing. `compose recall` adds a `memory` section: `state not_engaged` with that text when not engaged, otherwise the items of the context. +2. Harness `scripts/whole_system_e2e.sh` engages a host-built fixture ALLEN subject for every daemon start from PRE onward (not CTRL-E3a), as `scripts/allen_e2e_demo.sh` step S1 does, and records the identity fingerprint in the PRE and E4 receipts. +3. Append objective: option (b), chosen over (a). Option (a) changes the edit prompt, the proposal parser and the requirement verifier, which is not small. The harness sets `AIEN_COMPOSE_MAX_TOKENS` for the E4 daemon start only and records the value in the E4 receipt. + +## Tests + +| Test | On current main | After the fix | +|---|---|---| +| `crates/aien-cli/tests/compose_memory_recall_test.rs::remember_refuses_when_allen_not_engaged` (ignored, compose-linked CLI) | FAIL (remember returns ok true) | PASS | +| same file `::remember_then_recall_includes_item_when_engaged` | FAIL (recall has no memory section, item not in ALLEN memory) | PASS | +| append path: `bash scripts/whole_system_e2e.sh selftest` (checks the E4 token budget is a documented value inside the accepted range and is passed to the E4 daemon start only) | FAIL (no such constant) | PASS | +| harness selftest, ALLEN env lines (`allen_env` prints exactly `AIEN_ALLEN_SUBJECT=` and, once, `AIEN_ALLEN_ADOPT=`) | FAIL (no such function) | PASS | + +The full harness `run` mode is not run by this lane (16 minutes on CPU); the orchestrator runs declared runs. + +## Must not change + +Desk, grants, effect boundary, every refusal other than the new `remember` refusal, anything under `runs/`, the two ACCEPTANCE files and the result notes. CTRL-E3a (no desk key) starts without a subject, unchanged. From 96657da7e4e0d0547445e792b90946f27e0a43ae Mon Sep 17 00:00:00 2001 From: aien Date: Sat, 10 Oct 2026 09:28:47 -0500 Subject: [PATCH 2/4] sc#386 regression tests (failing before the fix): remember/recall with and without ALLEN, harness selftest Co-authored-by: Drake Stapleton Co-Authored-By: Claude Fable 5.1 --- .../tests/compose_memory_recall_test.rs | 251 ++++++++++++++++++ scripts/whole_system_e2e.sh | 6 + 2 files changed, 257 insertions(+) create mode 100644 crates/aien-cli/tests/compose_memory_recall_test.rs diff --git a/crates/aien-cli/tests/compose_memory_recall_test.rs b/crates/aien-cli/tests/compose_memory_recall_test.rs new file mode 100644 index 00000000..cdb3863a --- /dev/null +++ b/crates/aien-cli/tests/compose_memory_recall_test.rs @@ -0,0 +1,251 @@ +//! sc#386: `aien compose remember` and `aien compose recall` against ONE real +//! `aien daemon` process, with and without an engaged ALLEN identity. +//! +//! remember_refuses_when_allen_not_engaged +//! no identity: `remember` refuses with the NotEngaged text and stores nothing; +//! `recall` says `not_engaged` instead of looking like an empty success. +//! remember_then_recall_includes_item_when_engaged +//! engaged fixture subject: `remember` puts the item into ALLEN scoped memory; +//! `recall` returns it, also after a SIGKILL and restart. +//! +//! No model is needed. Host CPU only. Needs a compose-linked `aien-cli`: +//! +//! ```text +//! env -u AIEN_OMEGA_DIR AIEN_OMEGA_COMPOSE_LIB= CARGO_TARGET_DIR= \ +//! cargo test -p aien-cli --test compose_memory_recall_test -- --ignored --nocapture +//! ``` +#[path = "../../aien-allen/tests/support/mod.rs"] +mod support; + +use serde_json::{json, Value}; +use std::os::unix::process::{CommandExt, ExitStatusExt}; +use std::path::PathBuf; +use std::process::{Child, Command, Stdio}; +use std::time::Duration; + +const ITEM: &str = "SC386-memory-item: the topic reported on first is harbour"; + +struct Out { + code: i32, + json: Value, + raw: String, +} + +struct Rig { + _tmp: tempfile::TempDir, + root: PathBuf, + bin: PathBuf, + daemon: Option, + nd: u32, + subject: Option, +} + +impl Rig { + fn new() -> Rig { + let bin = PathBuf::from( + std::env::var("AIEN_BIN").unwrap_or_else(|_| env!("CARGO_BIN_EXE_aien-cli").into()), + ); + let tmp = tempfile::Builder::new() + .prefix("cm-") + .tempdir_in("/tmp") + .unwrap(); + let root = std::fs::canonicalize(tmp.path()).unwrap(); + for d in ["state", "home", "prov"] { + std::fs::create_dir_all(root.join(d)).unwrap(); + } + aien_runtime::approved_auth::DeskKey::create(&aien_runtime::approved_auth::desk_key_path( + &root.join("compose"), + )) + .unwrap(); + Rig { + _tmp: tmp, + root, + bin, + daemon: None, + nd: 0, + subject: None, + } + } + fn sock(&self) -> PathBuf { + self.root.join("s") + } + fn cmd_env(&self, c: &mut Command) { + c.current_dir(&self.root) + .env("HOME", self.root.join("home")) + .env("NO_COLOR", "1") + .env("AIEN_RUNTIME_SOCK", self.sock()) + .env("AIEN_RUNTIME_STATE_DIR", self.root.join("state")) + .env("AIEN_COMPOSE_DIR", self.root.join("compose")) + .env("AIEN_PROVENANCE_DIR", self.root.join("prov")) + .env("AIEN_REQUIRE_CHECKPOINT", "0"); + for k in [ + "AIEN_OMEGA_DIR", + "AIEN_OMEGA_GPU_LIB", + "AIEN_REQUIRE_BLACKWELL", + "AIEN_GPU_BACKEND", + "AIEN_MODEL_PATH", + "AIEN_TOKENIZER_PATH", + "AIEN_MODEL_DIR", + "AIEN_ALLEN_SUBJECT", + "AIEN_ALLEN_ADOPT", + "AIEN_FAULT_HOLD", + "AIEN_FAULT_HOLD_FILE", + ] { + c.env_remove(k); + } + if let Some(s) = &self.subject { + c.env("AIEN_ALLEN_SUBJECT", s); + } + } + fn start(&mut self, adopt: Option<&str>) -> PathBuf { + assert!(self.daemon.is_none()); + self.nd += 1; + let log = self.root.join(format!("daemon-{}.log", self.nd)); + let f = std::fs::File::create(&log).unwrap(); + let _ = std::fs::remove_file(self.sock()); + let mut c = Command::new(&self.bin); + c.arg("daemon"); + self.cmd_env(&mut c); + if let Some(a) = adopt { + c.env("AIEN_ALLEN_ADOPT", a); + } + c.process_group(0) + .stdin(Stdio::null()) + .stdout(f.try_clone().unwrap()) + .stderr(f); + self.daemon = Some(c.spawn().expect("spawn daemon")); + for _ in 0..1200 { + std::thread::sleep(Duration::from_millis(50)); + if let Some(st) = self.daemon.as_mut().unwrap().try_wait().unwrap() { + self.daemon = None; + panic!( + "daemon exited early ({st:?}): {}", + std::fs::read_to_string(&log).unwrap_or_default() + ); + } + let text = std::fs::read_to_string(&log).unwrap_or_default(); + if self.sock().exists() && text.contains("Replay reconcile:") { + assert!( + text.lines() + .any(|l| l.contains("Backend:") && l.contains("CPU-reference")), + "daemon is not the CPU reference build" + ); + return log; + } + } + self.kill(); + panic!("daemon did not come up in 60 s"); + } + fn kill(&mut self) { + if let Some(mut c) = self.daemon.take() { + let _ = c.kill(); + let st = c.wait().unwrap(); + assert_eq!(st.signal(), Some(9), "daemon end: {st:?}"); + } + let _ = std::fs::remove_file(self.sock()); + } + fn cli(&self, args: &[&str]) -> Out { + let mut c = Command::new(&self.bin); + c.args(args); + self.cmd_env(&mut c); + let o = c.output().expect("run aien"); + let raw = String::from_utf8_lossy(&o.stdout).to_string(); + let json = raw + .lines() + .rev() + .find_map(|l| serde_json::from_str::(l).ok()) + .unwrap_or_else(|| json!({"unparsed": raw})); + Out { + code: o.status.code().unwrap_or(-1), + json, + raw, + } + } + /// Count of constraint records the compose home holds. + fn constraints(&self) -> usize { + let o = self.cli(&["compose", "recall"]); + assert_eq!(o.code, 0, "recall: {}", o.raw); + o.json["constraints"].as_array().map_or(0, Vec::len) + } +} + +impl Drop for Rig { + fn drop(&mut self) { + if let Some(mut c) = self.daemon.take() { + let _ = c.kill(); + let _ = c.wait(); + } + } +} + +#[test] +#[ignore = "needs a compose-linked CPU aien-cli (see the file header)"] +fn remember_refuses_when_allen_not_engaged() { + let mut r = Rig::new(); + r.start(None); + let before = r.constraints(); + let o = r.cli(&["compose", "remember", "--text", ITEM]); + assert_ne!(o.code, 0, "remember must refuse without ALLEN: {}", o.raw); + assert_eq!(o.json["ok"], false, "{}", o.raw); + let err = o.json["error"].as_str().unwrap_or(""); + assert!( + err.contains("ALLEN is not engaged"), + "refusal must say ALLEN is not engaged: {}", + o.raw + ); + assert_eq!(r.constraints(), before, "a refused remember stores nothing"); + let rec = r.cli(&["compose", "recall"]); + assert_eq!(rec.code, 0, "{}", rec.raw); + assert_eq!(rec.json["memory"]["state"], "not_engaged", "{}", rec.raw); +} + +#[test] +#[ignore = "needs a compose-linked CPU aien-cli (see the file header)"] +fn remember_then_recall_includes_item_when_engaged() { + let mut r = Rig::new(); + // The home must exist so a subject can bind its first record (as the demo S1). + r.start(None); + let lin = r.cli(&["compose", "recall", "--ids", "1"]); + assert_eq!(lin.code, 0, "{}", lin.raw); + let lineage = aien_allen::unhex32(lin.json["recall"]["cited"][0]["digest"].as_str().unwrap()) + .expect("record 1 digest"); + r.kill(); + let mut f = support::fx("sc386-memory"); + f.cortex = lineage; + let subj = support::write_head( + &r.root.join("subject.bin"), + support::chain(&f, 2).last().unwrap(), + ); + let agent = aien_allen::hex(&f.agent); + r.subject = Some(subj); + let log = r.start(Some(&agent)); + assert!(std::fs::read_to_string(&log) + .unwrap() + .lines() + .any(|l| l.starts_with("ALLEN: engaged agent="))); + + let o = r.cli(&["compose", "remember", "--text", ITEM]); + assert_eq!(o.code, 0, "remember: {}", o.raw); + assert_eq!(o.json["ok"], true, "{}", o.raw); + + let texts = |r: &Rig| -> Vec { + let rec = r.cli(&["compose", "recall"]); + assert_eq!(rec.code, 0, "{}", rec.raw); + assert_eq!(rec.json["memory"]["state"], "included", "{}", rec.raw); + rec.json["memory"]["items"] + .as_array() + .expect("memory items") + .iter() + .filter_map(|i| i["text"].as_str().map(str::to_string)) + .collect() + }; + assert!(texts(&r).iter().any(|t| t == ITEM), "item recalled"); + // The same item is what a proposal in the `work` context is given. + let direct = r.cli(&["allen", "memory", "recall", "--context", "work"]); + assert!(direct.raw.contains(ITEM), "ALLEN memory holds it: {}", direct.raw); + + // SIGKILL and restart: the item is still there. + r.kill(); + r.start(None); + assert!(texts(&r).iter().any(|t| t == ITEM), "item recalled after restart"); +} diff --git a/scripts/whole_system_e2e.sh b/scripts/whole_system_e2e.sh index 03348574..21516a19 100755 --- a/scripts/whole_system_e2e.sh +++ b/scripts/whole_system_e2e.sh @@ -33,6 +33,12 @@ selftest() { [ -z "$(check_doc "$t/good.md" alpha.txt beta.txt gamma.txt)" ] || { echo "selftest: good document failed: $(check_doc "$t/good.md" alpha.txt beta.txt gamma.txt)"; rc=1; } [ "$(check_doc "$t/bad.md" alpha.txt beta.txt gamma.txt)" = "D2 D4" ] || { echo "selftest: bad document gave '$(check_doc "$t/bad.md" alpha.txt beta.txt gamma.txt)', want 'D2 D4'"; rc=1; } [ "$(check_doc "$t/absent.md")" = "D1" ] || { echo "selftest: absent file not D1"; rc=1; } + # sc#386: the ALLEN engagement lines and the E4 token budget are fixed, documented values. + [ "$(allen_env /x/subject.bin abc123 | tr '\n' ' ')" = "AIEN_ALLEN_SUBJECT=/x/subject.bin AIEN_ALLEN_ADOPT=abc123 " ] || { echo "selftest: allen_env adopt lines wrong"; rc=1; } + [ "$(allen_env /x/subject.bin | tr '\n' ' ')" = "AIEN_ALLEN_SUBJECT=/x/subject.bin " ] || { echo "selftest: allen_env without adopt wrong"; rc=1; } + case ${E4_MAX_TOKENS:-} in ''|*[!0-9]*) echo "selftest: E4_MAX_TOKENS not a number"; rc=1 ;; *) { [ "$E4_MAX_TOKENS" -ge 48 ] && [ "$E4_MAX_TOKENS" -le 4096 ]; } || { echo "selftest: E4_MAX_TOKENS outside 48..4096"; rc=1; } ;; esac + # The budget is passed on the E4 daemon start only. + [ "$(grep -c 'AIEN_COMPOSE_MAX_TOKENS="\?\$E4_MAX_TOKENS' "$0")" = 1 ] || { echo "selftest: AIEN_COMPOSE_MAX_TOKENS must be set on exactly one start (E4)"; rc=1; } rm -rf "$t"; [ $rc -eq 0 ] && echo "selftest PASS"; return $rc } case ${1:-} in From c0ced46e5afb91dc44a802aed6be4e194ddf37a7 Mon Sep 17 00:00:00 2001 From: aien Date: Sat, 10 Oct 2026 09:33:59 -0500 Subject: [PATCH 3/4] sc#386: compose remember needs an engaged ALLEN and stores into its memory; recall reports memory state; E2E harness engages a fixture subject and raises the E4 token budget Co-authored-by: Drake Stapleton Co-Authored-By: Claude Fable 5.1 --- crates/aien-cli/src/compose.rs | 50 +++++++++++++++-- .../tests/compose_memory_recall_test.rs | 11 +++- .../whole-system-e2e/REGRESSION-sc386.md | 6 +++ scripts/whole_system_e2e.sh | 53 ++++++++++++++++--- 4 files changed, 108 insertions(+), 12 deletions(-) diff --git a/crates/aien-cli/src/compose.rs b/crates/aien-cli/src/compose.rs index cd5001e2..8bb3d55a 100644 --- a/crates/aien-cli/src/compose.rs +++ b/crates/aien-cli/src/compose.rs @@ -12,7 +12,7 @@ //! Each subcommand prints one JSON object on stdout (`"ok": true|false`) and //! exits 1 on failure. //! -//! remember --text T S1 constraint record +//! remember --text T [--context C] S1 constraint record + ALLEN memory item (refused when ALLEN is not engaged) //! inspect --workspace W S2 read-only listing + receipt //! propose --goal G --workspace W [--context personal|work|project:NAME] S3 one RunComposeTask //! authorize --report S3.json --workspace W --approver NAME [--constraint ID] @@ -27,7 +27,7 @@ //! S5 the write, confined //! explain --report S3.json --cite ID,.. --receipts P,.. //! S6 evidence-citing explanation -//! recall [--ids ID,..] [--prefix N] S8 constraints + effects +//! recall [--ids ID,..] [--prefix N] [--context C] S8 constraints + effects + ALLEN memory state //! shutdown S7 stop the daemon (control Shutdown) //! recover repair a refused home //! effects the effect ledger (NEXT-PHASE-2) @@ -150,6 +150,43 @@ async fn note(kind: &str, text: &str, links: Vec) -> Result } } +/// Put one item into ALLEN scoped memory (the existing aien-allen-memory path). A refusal +/// (not engaged, foreign or damaged store) is returned as `Err` with its code and plain text. +async fn memory_put(context: &str, text: &str) -> Result { + match send(ControlCommand::AllenMemoryPut { + context: context.into(), + kind: "fact".into(), + text: text.into(), + }) + .await? + { + ControlResponse::AllenMemoryResult(r) => Ok(r.result), + ControlResponse::AllenRefused(e) => Err(format!("{} ({})", e.message, e.code)), + other => Err(format!("unexpected response {other:?}")), + } +} + +/// ALLEN scoped memory of one context, as `recall` reports it: `not_engaged` (with the +/// plain-language reason) rather than an empty success when there is no identity. +async fn memory_view(context: &str) -> Result { + match send(ControlCommand::AllenMemoryRecall { + context: context.into(), + query: None, + }) + .await? + { + ControlResponse::AllenMemoryResult(r) => Ok(json!({ + "state": "included", "context": context, + "items": r.result["items"], "omitted": r.result["omitted"], + "unresolved": r.result["unresolved"], + })), + ControlResponse::AllenRefused(e) => Ok(json!({ + "state": e.code, "context": context, "items": [], "reason": e.message, + })), + other => Err(format!("unexpected response {other:?}")), + } +} + async fn recall(ids: Vec, prefix: Option) -> Result { match send(ControlCommand::ComposeRecall { ids, prefix }).await? { ControlResponse::ComposeRecalled(r) => Ok(*r), @@ -230,8 +267,12 @@ async fn step(sub: &str, m: &HashMap) -> Result { match sub { "remember" => { let text = need(m, "text")?; + let context = m.get("context").map_or("work", String::as_str); + // sc#386: memory lives with an engaged ALLEN identity. Put it there first; a refusal + // (not engaged) stops here and nothing is stored. + let mem = memory_put(context, text).await?; let n = note("constraint", text, vec![]).await?; - Ok(json!({"step": "S1", "constraint": n})) + Ok(json!({"step": "S1", "constraint": n, "memory": mem, "context": context})) } "inspect" => { let (_, ws) = confine(need(m, "workspace")?)?; @@ -495,6 +536,7 @@ async fn step(sub: &str, m: &HashMap) -> Result { .map(|s| s.parse::().map_err(|e| format!("--prefix: {e}"))) .transpose()?; let rec = recall(want, prefix).await?; + let memory = memory_view(m.get("context").map_or("work", String::as_str)).await?; let of = |k: &str| -> Vec { rec.host .iter() @@ -505,7 +547,7 @@ async fn step(sub: &str, m: &HashMap) -> Result { }; Ok(json!({"step": "S8", "machine_id": rec.machine_id, "constraints": of("constraint"), "authorizations": of("authorization"), - "effects": of("effect"), "repairs": of("repair_tail"), "recall": rec})) + "effects": of("effect"), "repairs": of("repair_tail"), "memory": memory, "recall": rec})) } "shutdown" => { AienRuntimeClient::default_client().shutdown().await?; diff --git a/crates/aien-cli/tests/compose_memory_recall_test.rs b/crates/aien-cli/tests/compose_memory_recall_test.rs index cdb3863a..5efff491 100644 --- a/crates/aien-cli/tests/compose_memory_recall_test.rs +++ b/crates/aien-cli/tests/compose_memory_recall_test.rs @@ -242,10 +242,17 @@ fn remember_then_recall_includes_item_when_engaged() { assert!(texts(&r).iter().any(|t| t == ITEM), "item recalled"); // The same item is what a proposal in the `work` context is given. let direct = r.cli(&["allen", "memory", "recall", "--context", "work"]); - assert!(direct.raw.contains(ITEM), "ALLEN memory holds it: {}", direct.raw); + assert!( + direct.raw.contains(ITEM), + "ALLEN memory holds it: {}", + direct.raw + ); // SIGKILL and restart: the item is still there. r.kill(); r.start(None); - assert!(texts(&r).iter().any(|t| t == ITEM), "item recalled after restart"); + assert!( + texts(&r).iter().any(|t| t == ITEM), + "item recalled after restart" + ); } diff --git a/docs/campaigns/whole-system-e2e/REGRESSION-sc386.md b/docs/campaigns/whole-system-e2e/REGRESSION-sc386.md index fdccb830..d417c5fb 100644 --- a/docs/campaigns/whole-system-e2e/REGRESSION-sc386.md +++ b/docs/campaigns/whole-system-e2e/REGRESSION-sc386.md @@ -27,3 +27,9 @@ The full harness `run` mode is not run by this lane (16 minutes on CPU); the orc ## Must not change Desk, grants, effect boundary, every refusal other than the new `remember` refusal, anything under `runs/`, the two ACCEPTANCE files and the result notes. CTRL-E3a (no desk key) starts without a subject, unchanged. + +## Notes added with the fix + +- The harness engages the subject the way demo S1 does: a plain start opens the compose home, the subject is built bound to record 1 of that home (`cargo test -p aien-allen --test e2e_demo_subject -- --ignored`), the daemon is SIGKILLed and restarted with `AIEN_ALLEN_SUBJECT=` and, once, `AIEN_ALLEN_ADOPT=`. The daemon log must show `ALLEN: engaged` and `aien-cli allen status` must give a fingerprint, or the start counts as failed. +- CTRL-E4 removes the store; the home is then refused at its integrity mark before ALLEN can resolve (observed by hand: no `ALLEN: engaged` line, `allen status` returns the mark refusal), so that one start does not require engagement. The old subject is still passed. +- Append objective: option (b), `AIEN_COMPOSE_MAX_TOKENS=400` on the E4 start only, recorded as `compose_max_tokens` in the E4 receipt. Whether a 1B model then produces exactly one added line is measured by the next declared run, not claimed here. diff --git a/scripts/whole_system_e2e.sh b/scripts/whole_system_e2e.sh index 21516a19..f0a89319 100755 --- a/scripts/whole_system_e2e.sh +++ b/scripts/whole_system_e2e.sh @@ -26,6 +26,20 @@ check_doc() { local n; for n in "$@"; do grep -qF -- "$n" "$f" || { failed="$failed D4"; break; }; done echo "${failed# }" } +# ---- sc#386: ALLEN engagement and the E4 token budget ------------------------------------------------------- +# Memory belongs to an engaged ALLEN identity (aien-architecture#190 lane L3), so every daemon start from PRE +# onward carries a host-built fixture subject, the way scripts/allen_e2e_demo.sh step S1 does. CTRL-E3a (no desk +# key, refuses before serving) keeps its own start and carries none. +# E4's second objective appends one line to a document; the small-edit path caps a reply at 48 tokens by default +# (AIEN_COMPOSE_MAX_TOKENS) and the 1B model re-emits the whole report, so row E4 alone raises the cap to a +# documented value (the report is at most 200 words, about 300 tokens, plus the added line). The value is +# recorded in the E4 receipt. Later restarts (E6, CTRL-E4) keep the default. +E4_MAX_TOKENS=400 +allen_env() { # subject_path [agent_hex]: the env lines that engage the fixture subject (adopt only the first time) + echo "AIEN_ALLEN_SUBJECT=$1" + [ -z "${2:-}" ] || echo "AIEN_ALLEN_ADOPT=$2" +} + selftest() { local t; t=$(mktemp -d); local rc=0 printf '# Report\n\nabout alpha.txt, beta.txt and gamma.txt\n' >"$t/good.md" @@ -130,7 +144,7 @@ rcpt() { # step status evidence [fields json] # ---- daemon control ---------------------------------------------------------------------------------------- DN=0; DPID=""; CUR_BACKEND=""; RESTARTS=0; LAST_START_UTC=""; DLOG=/dev/null -start_daemon() { # [VAR=val ...] +start_daemon_raw() { # [VAR=val ...]: one daemon start, no ALLEN subject unless the caller passes it DN=$((DN + 1)); DLOG=$LOGS/daemon-$DN.log; rm -f "$SOCK" "${E[@]}" AIEN_MODEL_PATH="$MDIR/model.safetensors" AIEN_TOKENIZER_PATH="$MDIR/tokenizer.json" "$@" "$BIN" daemon >"$DLOG" 2>&1 & DPID=$! @@ -146,6 +160,31 @@ start_daemon() { # [VAR=val ...] case $CUR_BACKEND in *CPU-reference*) ;; *) echo "not the CPU reference backend: '$CUR_BACKEND'"; kill -9 "$DPID" 2>/dev/null; wait "$DPID" 2>/dev/null; DPID=""; return 1 ;; esac return 0 } +ALLEN_REQUIRE=1; SUBJ=""; ALLEN_ADOPT=""; ALLEN_FP=""; ALLEN_LINE=""; SUBJ_N=0 +build_subject() { # lineage_hex: host-built fixture subject bound to record 1 of the current compose home (demo S1) + SUBJ_N=$((SUBJ_N + 1)); SUBJ=$RUN/subject-$SUBJ_N.bin + local fx; fx=$(cd "$REPO" && env -u AIEN_OMEGA_DIR -u AIEN_OMEGA_COMPOSE_DIR AIEN_OMEGA_COMPOSE_LIB="$LIB" CARGO_TARGET_DIR="$D/target" \ + DEMO_SUBJECT_OUT="$SUBJ" DEMO_LINEAGE_HEX="$1" DEMO_SUBJECT_NAME="whole-system-e2e-$SUBJ_N" \ + cargo test --release -p aien-allen --test e2e_demo_subject -- --ignored --nocapture 2>&1) + ALLEN_ADOPT=$(printf '%s\n' "$fx" | sed -n 's/^AGENT=//p') + [ -n "$ALLEN_ADOPT" ] && [ -s "$SUBJ" ] || { echo "could not build the ALLEN fixture subject: $(printf '%s' "$fx" | tail -c 300)"; SUBJ=""; return 1; } +} +start_daemon() { # [VAR=val ...]: a daemon with the ALLEN fixture subject engaged; sets ALLEN_FP, ALLEN_LINE + local lin ea=() + if [ -z "$SUBJ" ]; then # this compose home has no subject yet: open it once, bind a subject to its record 1 + start_daemon_raw "$@" || return 1 + lin=$(cli compose recall --ids 1 | jq -r '.recall.cited[0].digest // empty') + sigkill || true + [ -n "$lin" ] || { echo "no record 1 digest to bind the ALLEN subject to"; return 1; } + build_subject "$lin" || return 1 + fi + mapfile -t ea < <(allen_env "$SUBJ" "$ALLEN_ADOPT") + start_daemon_raw "$@" "${ea[@]}" || return 1 + ALLEN_ADOPT="" # a subject is adopted once; later starts only name it + ALLEN_LINE=$(grep -m1 '^ALLEN: engaged' "$DLOG" | cut -c1-200) + ALLEN_FP=$(cli allen status 2>/dev/null | jq -r '.result.fingerprint // empty') + { [ "$ALLEN_REQUIRE" = 0 ] || { [ -n "$ALLEN_LINE" ] && [ -n "$ALLEN_FP" ]; }; } || { echo "ALLEN not engaged (log line '$ALLEN_LINE', fingerprint '$ALLEN_FP')"; kill -9 "$DPID" 2>/dev/null; wait "$DPID" 2>/dev/null; DPID=""; return 1; } +} stop_graceful() { [ -n "$DPID" ] || return 0; cli compose shutdown >"$LOGS/shutdown-$DN.json" 2>&1; local i=0; while [ -d "/proc/$DPID" ] && [ $i -lt 600 ]; do sleep 0.1; i=$((i + 1)); done; wait "$DPID" 2>/dev/null; DPID=""; rm -f "$SOCK"; } KILL_RC="" sigkill() { [ -n "$DPID" ] || return 1; kill -9 "$DPID" 2>/dev/null; wait "$DPID" 2>/dev/null; KILL_RC=$?; DPID=""; rm -f "$SOCK"; [ "$KILL_RC" -eq 137 ]; } @@ -216,7 +255,7 @@ else ROUTE=$(ip route 2>/dev/null | head -5 | tr '\n' ';') rcpt PRE "$([ $PRE_OK = 1 ] && echo PASS || echo FAIL)" "$PRE_EV; backend '$CUR_BACKEND'" \ "$(jq -nc --argjson fix "$FIX" --arg route "$ROUTE" --arg q "$([ -s "$QUIET" ] && echo held || echo not-held)" --arg cw "$C_W" --arg ct "$C_T" --arg cid "$C_ID" --arg mdir "$MDIR" \ - '{inbox_files:$fix, ip_route:$route, quiet_flag:$q, candidate_model_id:$cid, candidate_weights_sha256:$cw, candidate_tokenizer_sha256:$ct, model_dir:$mdir, network_check:"recorded in the NET receipt"}')" + --arg afp "$ALLEN_FP" --arg aline "$ALLEN_LINE" '{allen_identity_fingerprint:$afp, allen_log_line:$aline, allen_subject_kind:"host-built fixture subject (test-only encoder), adopted once by AIEN_ALLEN_ADOPT; same as scripts/allen_e2e_demo.sh S1", inbox_files:$fix, ip_route:$route, quiet_flag:$q, candidate_model_id:$cid, candidate_weights_sha256:$cw, candidate_tokenizer_sha256:$ct, model_dir:$mdir, network_check:"recorded in the NET receipt"}')" fi if [ "$NK_RC" != killed ] && [ "$NK_RC" != 0 ] && [ -n "$NK_LINE" ]; then rcpt CTRL-E3a PASS "daemon without a desk key exited $NK_RC before serving; log: $NK_LINE" "$(jq -nc --arg rc "$NK_RC" --arg l "$NK_LINE" '{exit:$rc, log_line:$l}')" @@ -266,7 +305,7 @@ if [ -z "$ABORT" ] && [ $E3M_OK = 1 ]; then REM_OK=$(jq -r '.ok // false' "$ART/E4-remember.json" 2>/dev/null) LINES_BEFORE=$(wc -l <"$REPORT"); SHA_BEFORE=$(sha_of "$REPORT") if sigkill; then KILLED="kill -9 (exit 137)"; else KILLED="kill rc=${KILL_RC:-none}"; fi - if start_daemon; then + if start_daemon AIEN_COMPOSE_MAX_TOKENS=$E4_MAX_TOKENS; then RESTARTS=$((RESTARTS + 1)); RESTART_UTC=$LAST_START_UTC REPL=$(grep -m1 -E 'Replay reconcile:|^Reconcile:' "$DLOG" | cut -c1-200) if task E4 "$WS" "$OBJ2" work; then @@ -280,10 +319,10 @@ if [ -z "$ABORT" ] && [ $E3M_OK = 1 ]; then printf '%s' "$NEWLINE" | grep -qiF -- "$T1" || { OK=0; WHY="$WHY last-line-lacks-$T1"; } [ "$(sha_of "$REPORT")" != "$SHA_BEFORE" ] || { OK=0; WHY="$WHY report-unchanged"; } rcpt E4 "$([ $OK = 1 ] && echo PASS || echo FAIL)" "$KILLED then restart ($REPL); second objective state $T_STATE; memory $T_MEMCTX/$T_MEMN; lines $LINES_BEFORE->$LINES_AFTER; problems [${WHY# }]" \ - "$(jq -nc --arg store "compose home (AIEN_COMPOSE_DIR records; canonical store decided by lane L3)" --arg item "$(sha_of "$ART/E4-remember.json")" --arg rk sigkill --arg ru "$RESTART_UTC" --arg cu "$RECALL_UTC" --arg nl "$NEWLINE" --arg mc "$T_MEMCTX" --argjson mn "${T_MEMN:-0}" --arg st "$T_STATE" --argjson g "$T_GRANT" --argjson rc "${T_RECEIPT:-null}" --arg p "${T_PATH:-}" \ - '{memory_store:$store, item_sha256:$item, recall_after_restart:($mn>=1), restart_kind:$rk, restart_utc:$ru, recall_utc:$cu, appended_line:$nl, memory_context:$mc, memory_items_included:$mn, effect_state:$st, grant_id:$g, written_path:$p, compose_receipt:$rc}')" + "$(jq -nc --arg store "ALLEN scoped memory (aien-allen-memory) of the engaged identity, context work" --arg afp "$ALLEN_FP" --argjson mt "$E4_MAX_TOKENS" --arg item "$(sha_of "$ART/E4-remember.json")" --arg rk sigkill --arg ru "$RESTART_UTC" --arg cu "$RECALL_UTC" --arg nl "$NEWLINE" --arg mc "$T_MEMCTX" --argjson mn "${T_MEMN:-0}" --arg st "$T_STATE" --argjson g "$T_GRANT" --argjson rc "${T_RECEIPT:-null}" --arg p "${T_PATH:-}" \ + '{memory_store:$store, allen_identity_fingerprint:$afp, compose_max_tokens:$mt, item_sha256:$item, recall_after_restart:($mn>=1), restart_kind:$rk, restart_utc:$ru, recall_utc:$cu, appended_line:$nl, memory_context:$mc, memory_items_included:$mn, effect_state:$st, grant_id:$g, written_path:$p, compose_receipt:$rc}')" else - rcpt E4 FAIL "$KILLED then restart ($REPL); second objective: $T_EV" "$(jq -nc --arg rk sigkill --arg st "$T_STATE" --arg mc "$T_MEMCTX" --argjson mn "${T_MEMN:-0}" '{restart_kind:$rk, effect_state:$st, memory_context:$mc, memory_items_included:$mn}')" + rcpt E4 FAIL "$KILLED then restart ($REPL); second objective: $T_EV" "$(jq -nc --arg afp "$ALLEN_FP" --argjson mt "$E4_MAX_TOKENS" --arg rk sigkill --arg st "$T_STATE" --arg mc "$T_MEMCTX" --argjson mn "${T_MEMN:-0}" '{allen_identity_fingerprint:$afp, compose_max_tokens:$mt, restart_kind:$rk, effect_state:$st, memory_context:$mc, memory_items_included:$mn}')" fi else rcpt E4 FAIL "$KILLED; daemon did not restart: $(tail -c 300 "$DLOG" | tr '\n' ' ')" '{"restart_kind":"sigkill"}'; ABORT=1 @@ -337,6 +376,8 @@ rcpt NET "$([ "${NET:-0}" = 0 ] && echo PASS || echo FAIL)" "established TCP soc if [ -z "$ABORT" ] && [ $E3M_OK = 1 ]; then stop_graceful SHA_BEFORE=$(sha_of "$REPORT"); mv "$RUN/compose" "$RUN/compose.removed-ctrl-e4"; mkdir -p "$RUN/compose" + # the home is refused at its integrity mark before ALLEN can resolve, so engagement is not required to start this daemon + ALLEN_REQUIRE=0 cli compose desk-key --create 1 >"$ART/CTRL-E4-deskkey.json" 2>&1 if start_daemon; then if task CTRL-E4 "$WS" "$OBJ2" work; then From 0516c13d4105644296b483bf06286053458ea832 Mon Sep 17 00:00:00 2001 From: aien Date: Sat, 10 Oct 2026 09:34:09 -0500 Subject: [PATCH 4/4] crumb compile Co-authored-by: Drake Stapleton Co-Authored-By: Claude Fable 5.1 --- .crumb | 16 ++++++++-------- crates/aien-cli/.crumb | 16 ++++++++-------- crates/aien-cli/src/.crumb | 8 ++++---- scripts/.crumb | 8 ++++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.crumb b/.crumb index b5eccb8e..6a769119 100644 --- a/.crumb +++ b/.crumb @@ -64,8 +64,8 @@ "generated": { "children": [ { - "digest": "d1fe9c3e50f927bcb7384365c3ccd84ed1bb651a05edf816be6957a6508694b8", - "last_commit": "85bea5e", + "digest": "769fafdb3a310bc083469f4bd434d5aaa9957ef9ccaa22e7ecd47a922b4b7464", + "last_commit": "c0ced46", "name": "scripts", "purpose": "" }, @@ -76,15 +76,15 @@ "purpose": "" } ], - "children_root": "sha256:f72ed37e55f4cfaf4ce00ea4fd55522cd5ee4bb93b7b9d2fbf2357ced5f00727", - "compiled_at": "2026-10-10T14:01:42Z", + "children_root": "sha256:f8d4d22287b79c410b0f7e0d2729c2efc34cc559c7c8652acd3831e2c7c74e84", + "compiled_at": "2026-10-10T14:33:59Z", "compiler": "crumb-compile/1", - "digest": "sha256:45174e4534bf166831947dc6867b2aa5752738bbe5fae769d617b715f224f894", + "digest": "sha256:282ed888cb8d8cd676aa77e8a4f23e6ade385921b5dff15ca8296fbf25a21146", "evidence_files": 187, "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280", - "files": 1944, - "generated_at_commit": "85bea5e179068f0750056c3e1f0375c954c4269d", - "source_tree": "sha256:8ddc51e15b96468bc384d4194745b8b335be4b3ddb988553a2b34b824515c892" + "files": 1946, + "generated_at_commit": "c0ced46e5afb91dc44a802aed6be4e194ddf37a7", + "source_tree": "sha256:8f42c96dcb5dcf595c11838021a3ebd8079842bfc39646a6f7493b529e697806" } }, "history": [], diff --git a/crates/aien-cli/.crumb b/crates/aien-cli/.crumb index a2553009..abdcbc64 100644 --- a/crates/aien-cli/.crumb +++ b/crates/aien-cli/.crumb @@ -34,21 +34,21 @@ "generated": { "children": [ { - "digest": "1c24673fa15c3bb2a7653404d808dda4fd97753dabd992570f3e371add429c81", - "last_commit": "8a48904", + "digest": "b4906bde0d826f84065bcbfae1724c0404dbea1561cfae1ec997e707c1f17c8e", + "last_commit": "c0ced46", "name": "src", "purpose": "" } ], - "children_root": "sha256:1c3e00a737a636e539345fe90a2f67c0bb9512bf6dbd4bbe053d43641d3bab05", - "compiled_at": "2026-10-10T08:55:54Z", + "children_root": "sha256:5d6f6c1612286d8a1999d93f2895e69ed34857e2d96e98913418950cb649efc5", + "compiled_at": "2026-10-10T14:33:59Z", "compiler": "crumb-compile/1", - "digest": "sha256:7402aa7e5c3ad0624bc6dbea93130049dc798d1e56b9e6ef20153b8b81820b10", + "digest": "sha256:aa13207860fcc47487d68feaf028ed20ec0caa3a91aebf47f517f1221a2fa263", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 37, - "generated_at_commit": "8a48904fde00f3a182f9840aeb2acd23e3c79fa6", - "source_tree": "sha256:c9e5fa0ccc920bb8d8dec375c1aa619489ea7288dd246090d403d7f8c2b76051" + "files": 38, + "generated_at_commit": "c0ced46e5afb91dc44a802aed6be4e194ddf37a7", + "source_tree": "sha256:39975b869aea43986cee1fe87eccddaabd16f195ef1fe1e4625b0ffb58f7773c" } }, "history": [ diff --git a/crates/aien-cli/src/.crumb b/crates/aien-cli/src/.crumb index 32a720b7..14aa4853 100644 --- a/crates/aien-cli/src/.crumb +++ b/crates/aien-cli/src/.crumb @@ -64,14 +64,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-10T08:55:54Z", + "compiled_at": "2026-10-10T14:33:59Z", "compiler": "crumb-compile/1", - "digest": "sha256:1c24673fa15c3bb2a7653404d808dda4fd97753dabd992570f3e371add429c81", + "digest": "sha256:b4906bde0d826f84065bcbfae1724c0404dbea1561cfae1ec997e707c1f17c8e", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 28, - "generated_at_commit": "8a48904fde00f3a182f9840aeb2acd23e3c79fa6", - "source_tree": "sha256:c5cd891af69455b3dd990b78440b756dddbb1f6dbdc05445f88e52f92ae6a8a1" + "generated_at_commit": "c0ced46e5afb91dc44a802aed6be4e194ddf37a7", + "source_tree": "sha256:b03d3940b14cfe7fe4028d7f1553968a4274840819f795460c3fabd2020dc011" } }, "history": [ diff --git a/scripts/.crumb b/scripts/.crumb index ac1b88dc..3568de89 100644 --- a/scripts/.crumb +++ b/scripts/.crumb @@ -4,14 +4,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-10T14:01:42Z", + "compiled_at": "2026-10-10T14:33:59Z", "compiler": "crumb-compile/1", - "digest": "sha256:d1fe9c3e50f927bcb7384365c3ccd84ed1bb651a05edf816be6957a6508694b8", + "digest": "sha256:769fafdb3a310bc083469f4bd434d5aaa9957ef9ccaa22e7ecd47a922b4b7464", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 28, - "generated_at_commit": "85bea5e179068f0750056c3e1f0375c954c4269d", - "source_tree": "sha256:0d888152806e304ea56866d9e73b60a9549c39fc23525e930e483079595f6220" + "generated_at_commit": "c0ced46e5afb91dc44a802aed6be4e194ddf37a7", + "source_tree": "sha256:6f5dba9221ece7e02489bc35bec7b212787496444ac79c46cc7bf65603e531dd" } }, "parent": {