diff --git a/.crumb b/.crumb index 5a30f4f3..cba6ac26 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ } ], "children_root": "sha256:10d81c6270915316b54eee21734bb8e8f2716ffdc567100fb347a5f22ed95e24", - "compiled_at": "2026-10-06T02:53:13Z", + "compiled_at": "2026-10-06T03:25:30Z", "compiler": "crumb-compile/1", - "digest": "sha256:10d7705a26e8cc45a2e2e42ef766aaac4d7a79828d000bcf0500076e0b544f15", + "digest": "sha256:b630e0720f32de35df66e7982c1e50020f374004e890bca004986450c0bc7fd5", "evidence_files": 20, "evidence_root": "sha256:1ef4526f6fe1ba0cee21a89c3313d37bf2e94e1aa2e9bd1a364225e52882d170", - "files": 711, - "generated_at_commit": "1a745e913ee8456adf65e50fc93da8be1d4cecab", - "source_tree": "sha256:c7a91c84482f5e692432ed69c2b4e0609c12ec91a2234c08ae467d54b4fb6d6d" + "files": 715, + "generated_at_commit": "6264a9e34551c4aff3f5e7f08aec6677125c4387", + "source_tree": "sha256:2ea3d0f8b8d455157c595a0a5ed59e1b19111429ec7aeff23be10b9eb06c1c1b" } }, "history": [], diff --git a/crates/aien-runtime/src/server.rs b/crates/aien-runtime/src/server.rs index 7ddd4cc7..9e60b6aa 100644 --- a/crates/aien-runtime/src/server.rs +++ b/crates/aien-runtime/src/server.rs @@ -102,6 +102,7 @@ impl AienRuntimeServer { let is_running_worker = self.is_running.clone(); let shutdown_notify_worker = self.shutdown_notify.clone(); + let step_log = std::env::var("AIEN_STEP_LOG").is_ok_and(|v| v == "1"); let worker_handle = tokio::spawn(async move { while is_running_worker.load(Ordering::Relaxed) { let has_work = { @@ -111,10 +112,21 @@ impl AienRuntimeServer { if has_work { let mut s = spine_worker.lock().await; - if let Err(e) = s.step(&mut backend).await { + let t_step = std::time::Instant::now(); + match s.step(&mut backend).await { + // NEXT-PHASE-1 v3 observation: one line per engine step + // (AIEN_STEP_LOG=1) from the metrics the step already reports. + Ok(Some(m)) if step_log => eprintln!( + "step: prefill_tokens={} emitted={} backend_us={} spine_us={}", + m.prefill_tokens_processed, + m.decode_tokens_emitted, + m.step_latency_us, + t_step.elapsed().as_micros() + ), + Ok(_) => {} // A swallowed step error makes the daemon look alive // while its decode loop is dead. Print it. - eprintln!("runtime step error: {}", e); + Err(e) => eprintln!("runtime step error: {}", e), } } else { tokio::select! { @@ -298,7 +310,7 @@ async fn generate_text( /// from an omega World worker thread (not a tokio thread) via `block_on`. /// Greedy, at most `AIEN_COMPOSE_MAX_TOKENS` (default 48) tokens per reply; /// each call gets the limit `propose_with_retries` passes (what is left of -/// the 25 s budget, under rx_compose_run's 30 s quiescence wait), so a slow +/// the 29 s budget, under rx_compose_run's 30 s quiescence wait), so a slow /// model fails the Skill (no proposal) instead of failing the run. pub fn model_proposer( spine: Arc>, diff --git a/crates/aien-runtime/src/spine.rs b/crates/aien-runtime/src/spine.rs index a2cbc4a2..8305c0ea 100644 --- a/crates/aien-runtime/src/spine.rs +++ b/crates/aien-runtime/src/spine.rs @@ -696,9 +696,14 @@ pub fn parse_file_proposal(text: &str) -> Option { /// At most this many proposals per task (ACCEPTANCE-v2 Section 3b). pub const COMPOSE_MAX_ATTEMPTS: u32 = 3; -/// Wall budget for all attempts of one task: under rx_compose_run's 30 s -/// quiescence wait, which is not raised (ACCEPTANCE-v2 Section 4). -pub const COMPOSE_SKILL_BUDGET: std::time::Duration = std::time::Duration::from_secs(25); +/// Wall budget for all attempts of one task: rx_compose_run's 30 s +/// quiescence wait (not raised) less a 1 s margin (ACCEPTANCE-v3 Section 3b). +pub const COMPOSE_SKILL_BUDGET: std::time::Duration = std::time::Duration::from_secs(29); +/// Time one full attempt needs, from the v3 measurement: 173-token retry +/// prompt prefill (2 839 + 896 ms) + 47 decode steps x 166.6 ms + 60 ms +/// = 11 625 ms, rounded up (ACCEPTANCE-v3 Section 3b). Attempt k > 1 starts +/// only if at least this much budget is left. +pub const COMPOSE_ATTEMPT_BUDGET: std::time::Duration = std::time::Duration::from_millis(12_000); /// The fixed proposal template of the production RunComposeTask path. pub fn proposal_prompt(goal: &str, workspace: &str, entries: &str) -> String { @@ -721,26 +726,26 @@ pub fn retry_prompt(base: &str, reason: &str) -> String { /// Runs up to `max_attempts` proposals within `budget`: attempt 1 always /// starts; attempt k > 1 starts only if the remaining budget is at least -/// the measured duration of attempt k-1, and gets the remaining budget as -/// its limit. Returns the first reply that passes `check_file_proposal` -/// (or the last refusal reason) and every attempt made. +/// `attempt_budget` (the measured cost of one full attempt), and gets the +/// remaining budget as its limit. Returns the first reply that passes +/// `check_file_proposal` (or the last refusal reason) and every attempt made. pub fn propose_with_retries( proposer: &(dyn Fn(&str, std::time::Duration) -> Result + Send + Sync), base: &str, budget: std::time::Duration, + attempt_budget: std::time::Duration, max_attempts: u32, ) -> (Result, Vec) { let start = std::time::Instant::now(); let mut attempts: Vec = Vec::new(); let mut last_reason = "no attempt made".to_string(); - let mut last_ms: u64 = 0; + let need_ms = (attempt_budget.as_millis() as u64).max(1); for k in 1..=max_attempts { let remaining = budget.saturating_sub(start.elapsed()); - if k > 1 && (remaining.as_millis() as u64) < last_ms.max(1) { + if k > 1 && (remaining.as_millis() as u64) < need_ms { last_reason = format!( - "{last_reason}; no attempt {k}: {} ms left < {last_ms} ms measured for attempt {}", - remaining.as_millis(), - k - 1 + "{last_reason}; no attempt {k}: {} ms left < {need_ms} ms per-attempt budget", + remaining.as_millis() ); break; } @@ -751,7 +756,7 @@ pub fn propose_with_retries( }; let t0 = std::time::Instant::now(); let out = proposer(&prompt, remaining); - last_ms = t0.elapsed().as_millis() as u64; + let last_ms = t0.elapsed().as_millis() as u64; let mut a = ProposalAttempt { attempt: k, ms: last_ms, @@ -872,11 +877,13 @@ impl ComposeBridge { compose .register_skill(COMPOSE_MODEL_SKILL, None, 10, move |task| { let prompt = pr.lock().get(&task).cloned()?; - // Fixed template + bounded automatic retry (ACCEPTANCE-v2 3a, 3b). + // Fixed template + bounded automatic retry (ACCEPTANCE-v2 3a, 3b), + // measured per-attempt budget (ACCEPTANCE-v3 3b). let (out, attempts) = propose_with_retries( proposer.as_ref(), &prompt, COMPOSE_SKILL_BUDGET, + COMPOSE_ATTEMPT_BUDGET, COMPOSE_MAX_ATTEMPTS, ); let h = out.as_ref().ok().map(|t| proposal_handle(t)); diff --git a/crates/aien-runtime/tests/chat_template_test.rs b/crates/aien-runtime/tests/chat_template_test.rs new file mode 100644 index 00000000..00061eb9 --- /dev/null +++ b/crates/aien-runtime/tests/chat_template_test.rs @@ -0,0 +1,89 @@ +//! NEXT-PHASE-1 v3: the proposal request goes through the model's own chat +//! template. Source: TinyLlama-1.1B-Chat-v1.0 tokenizer_config.json +//! (sha256 7b41ba7d0eb91e77914ca3dafde559ea3e19878769b7e68409e89bed5222e77a), +//! field `chat_template`, rendered with the Hugging Face settings +//! (trim_blocks, lstrip_blocks): per message `'<|' + role + '|>\n' + content +//! + eos_token` followed by the newline after the expression, then +//! `'<|assistant|>'` and its newline when a generation prompt is asked for. + +use aien_inference_abi::TinyLlamaTokenizer; +use aien_runtime::control::{format_tinyllama_chat, ChatTurn}; + +fn turn(role: &str, content: &str) -> ChatTurn { + ChatTurn { + role: role.into(), + content: content.into(), + } +} + +/// The template as the tokenizer_config.json jinja renders it, by hand. +fn rendered_by_template(messages: &[(&str, &str)]) -> String { + let mut out = String::new(); + for (role, content) in messages { + out.push_str(&format!("<|{role}|>\n{content}\n")); + } + out.push_str("<|assistant|>\n"); + out +} + +const V2_PROMPT: &str = "Goal: Create the file NOTES.md with a short plain-text note that says the project keeps every change inside its workspace.\nAuthorized workspace: /tmp/ws\nTop-level entries: README.md, docs\nPropose exactly one file change inside the workspace.\nAnswer in exactly this format and nothing else:\nfilename: \n"; + +#[test] +fn streamturn_formatting_matches_the_model_template() { + let ours = format_tinyllama_chat(&[turn("user", V2_PROMPT)]); + assert_eq!(ours, rendered_by_template(&[("user", V2_PROMPT)])); + let with_system = format_tinyllama_chat(&[turn("system", "S"), turn("user", "U")]); + assert_eq!( + with_system, + rendered_by_template(&[("system", "S"), ("user", "U")]) + ); +} + +/// With the real tokenizer (AIEN_TOKENIZER_PATH): BOS first, and `` in the +/// rendered text becomes the single EOS token id 2, not the characters. +#[test] +fn template_encodes_bos_and_one_eos_token() { + let Ok(path) = std::env::var("AIEN_TOKENIZER_PATH") else { + eprintln!("AIEN_TOKENIZER_PATH not set: token check skipped"); + return; + }; + let tok = TinyLlamaTokenizer::from_file(path).expect("tokenizer"); + let ids = tok + .encode(&format_tinyllama_chat(&[turn("user", V2_PROMPT)])) + .expect("encode"); + eprintln!("template ids ({}): {:?}", ids.len(), ids); + assert_eq!(ids[0], TinyLlamaTokenizer::BOS_TOKEN_ID); + let eos: Vec = ids + .iter() + .enumerate() + .filter(|(_, &t)| t == TinyLlamaTokenizer::EOS_TOKEN_ID) + .map(|(i, _)| i) + .collect(); + assert_eq!(eos.len(), 1, "exactly one EOS (the user turn end)"); +} + +/// Prompt sizes behind the ACCEPTANCE-v3 budget arithmetic (printed; the +/// assertion only guards the 2-chunk assumption: at most 256 prompt tokens). +#[test] +fn proposal_prompt_token_counts() { + let Ok(path) = std::env::var("AIEN_TOKENIZER_PATH") else { + eprintln!("AIEN_TOKENIZER_PATH not set: token count skipped"); + return; + }; + let tok = TinyLlamaTokenizer::from_file(path).expect("tokenizer"); + let ws = "/home/drakestapleton/.claude/jobs/9bfe8553/tmp/np1-v3run/ws"; + let goal = "Create the file NOTES.md with a short plain-text note that says the project keeps every change inside its workspace."; + let base = aien_runtime::spine::proposal_prompt(goal, ws, "README.md, docs"); + let retry = aien_runtime::spine::retry_prompt( + &base, + "no filename line: the first line must be 'filename: '", + ); + for (name, p) in [("base", &base), ("retry", &retry)] { + let n = tok + .encode(&format_tinyllama_chat(&[turn("user", p)])) + .expect("encode") + .len(); + eprintln!("{name} prompt tokens: {n}"); + assert!(n <= 256); + } +} diff --git a/crates/aien-runtime/tests/compose_task_test.rs b/crates/aien-runtime/tests/compose_task_test.rs index 89120c62..c2006d6a 100644 --- a/crates/aien-runtime/tests/compose_task_test.rs +++ b/crates/aien-runtime/tests/compose_task_test.rs @@ -7,7 +7,7 @@ use aien_runtime::control::{ComposeRecallReport, ComposeTaskReport, ControlResponse}; use aien_runtime::spine::{ check_file_proposal, parse_file_proposal, propose_with_retries, ComposeBridge, ComposeProposer, - Generation, COMPOSE_MAX_ATTEMPTS, + Generation, COMPOSE_ATTEMPT_BUDGET, COMPOSE_MAX_ATTEMPTS, COMPOSE_SKILL_BUDGET, }; use std::sync::Arc; @@ -318,7 +318,13 @@ fn retry_is_capped_and_recorded() { tokens: 2, }) }; - let (out, a) = propose_with_retries(&chatty, "base", budget, COMPOSE_MAX_ATTEMPTS); + let (out, a) = propose_with_retries( + &chatty, + "base", + budget, + COMPOSE_ATTEMPT_BUDGET, + COMPOSE_MAX_ATTEMPTS, + ); assert!(out.unwrap_err().contains("no filename line")); assert_eq!(calls.load(Ordering::SeqCst), COMPOSE_MAX_ATTEMPTS); assert_eq!(a.len(), 3); @@ -345,7 +351,13 @@ ok tokens: 3, }) }; - let (out, a) = propose_with_retries(&second, "base", budget, COMPOSE_MAX_ATTEMPTS); + let (out, a) = propose_with_retries( + &second, + "base", + budget, + COMPOSE_ATTEMPT_BUDGET, + COMPOSE_MAX_ATTEMPTS, + ); assert_eq!( out.unwrap(), "filename: a.txt @@ -366,7 +378,7 @@ ok ) && p[1].contains("previous answer was refused") ); drop(p); - // budget: attempt 2 does not start when less time is left than attempt 1 took + // budget: attempt 2 does not start when less than the per-attempt budget is left let slow = |_: &str, _: Duration| { std::thread::sleep(Duration::from_millis(30)); Ok(Generation { @@ -378,6 +390,7 @@ ok &slow, "base", Duration::from_millis(40), + Duration::from_millis(30), COMPOSE_MAX_ATTEMPTS, ); assert_eq!(a.len(), 1); @@ -385,10 +398,48 @@ ok // model errors are recorded, not retried past the cap let err = |_: &str, _: Duration| Err::("model proposal exceeded 25000 ms".to_string()); - let (_, a) = propose_with_retries(&err, "base", budget, COMPOSE_MAX_ATTEMPTS); + let (_, a) = propose_with_retries( + &err, + "base", + budget, + COMPOSE_ATTEMPT_BUDGET, + COMPOSE_MAX_ATTEMPTS, + ); assert!(a.len() <= 3 && a.iter().all(|x| x.outcome == "timeout")); } +/// ACCEPTANCE-v3 Section 3b at 1/100 scale: a slow (cold) attempt 1 of 16.1 s +/// no longer blocks attempt 2; attempt 2 of 11.6 s leaves too little for 3. +#[test] +fn measured_attempt_budget_admits_a_second_attempt() { + use std::time::Duration; + assert!(COMPOSE_SKILL_BUDGET < Duration::from_secs(30)); + assert_eq!(COMPOSE_SKILL_BUDGET, Duration::from_secs(29)); + assert_eq!(COMPOSE_ATTEMPT_BUDGET, Duration::from_millis(12_000)); + // 2 839 + 896 + 47 x 166.6 + 60 ms, the measured full retry attempt + let measured: [f64; 4] = [2_839.0, 896.0, 47.0 * 166.6, 60.0]; + assert!(measured.iter().sum::() <= COMPOSE_ATTEMPT_BUDGET.as_millis() as f64); + let n = std::sync::atomic::AtomicU32::new(0); + let cold_then_warm = |_: &str, _: Duration| { + let k = n.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + std::thread::sleep(Duration::from_millis(if k == 0 { 161 } else { 116 })); + Ok(Generation { + text: "Goal: echo".into(), + tokens: 48, + }) + }; + let (out, a) = propose_with_retries( + &cold_then_warm, + "base", + COMPOSE_SKILL_BUDGET / 100, + COMPOSE_ATTEMPT_BUDGET / 100, + COMPOSE_MAX_ATTEMPTS, + ); + assert_eq!(a.len(), 2, "{a:?}"); + let reason = out.unwrap_err(); + assert!(reason.contains("no attempt 3") && reason.contains("120 ms per-attempt budget")); +} + #[test] fn unparseable_proposal_fails_the_aegis_contract() { if !aien_omega_compose::LINKED { diff --git a/docs/campaigns/next-phase-1/1e042f7e7269dbb708df0dde60f7e244dfc0fdb1736e9b45cf13cc574785fd32.json b/docs/campaigns/next-phase-1/1e042f7e7269dbb708df0dde60f7e244dfc0fdb1736e9b45cf13cc574785fd32.json new file mode 100644 index 00000000..17281e9b --- /dev/null +++ b/docs/campaigns/next-phase-1/1e042f7e7269dbb708df0dde60f7e244dfc0fdb1736e9b45cf13cc574785fd32.json @@ -0,0 +1,405 @@ +{ + "gate": "NEXT_PHASE_1", + "commit": "6264a9e34551c4aff3f5e7f08aec6677125c4387", + "omega_compose_commit": "62b6a2899fa230e57fcf7855ea7e2c26404514b6", + "omega_gpu_commit": "62b6a2899fa230e57fcf7855ea7e2c26404514b6", + "verdict": "FAIL", + "machine_id": "6c5c22458c75f6d1e608974f8e4646d221520db130cbcf7dda19d8304521aa54", + "tier": "host", + "uname": "Linux 7.0.0-1019-nvidia aarch64", + "model": [ + " Model: checkpoint loaded from /home/drakestapleton/models/TinyLlama-1.1B-Chat-v1.0/model.safetensors (tokenizer loaded, model_id=TinyLlama-1.1B-Chat-v1.0, model_sha256=6e6001da2106d4757498752a021df6c2bdc332c650aae4bae6b0c004dcf14933, tokenizer_sha256=bcd04f0eadf90287bd26e1a183ac487d8a141b09b06aecb7725bbdd343640f2e)", + " Model: checkpoint loaded from /home/drakestapleton/models/TinyLlama-1.1B-Chat-v1.0/model.safetensors (tokenizer loaded, model_id=TinyLlama-1.1B-Chat-v1.0, model_sha256=6e6001da2106d4757498752a021df6c2bdc332c650aae4bae6b0c004dcf14933, tokenizer_sha256=bcd04f0eadf90287bd26e1a183ac487d8a141b09b06aecb7725bbdd343640f2e)" + ], + "note": "v3: one driver launch, zero hand input; AIEN_STEP_LOG=1 set for observation (stderr step lines only)", + "acceptance_spec": "ACCEPTANCE-v3.md spec_version 3", + "observations": { + "tokens_per_s": [ + { + "attempt": 1, + "tokens": 48, + "ms": 16375, + "tokens_per_s": 2.93 + }, + { + "attempt": 2, + "tokens": 48, + "ms": 11891, + "tokens_per_s": 4.03 + } + ] + }, + "skills": [ + { + "id": 0, + "name": "aien.model.propose-file-change", + "version": null, + "digest": "d65463850af0b3055ec3fd55d29144bd49bb41768d5fc143d61059b34c76d105", + "cost": 10 + } + ], + "record_digest": [ + "414375ced6a558e65c6c88e81891733027b3819fd374be758c4e96b2d40aa134" + ], + "prefix_digest": [ + null, + null + ], + "winner_digest": [ + "0000000000000000000000000000000000000000000000000000000000000000" + ], + "acceptance": [ + { + "criterion": "Task completion", + "threshold": "8 of 8 (PROPOSED)", + "value": 3, + "reached": { + "S1": true, + "S2": true, + "S3": false, + "S4": false, + "S5": false, + "S6": false, + "S7": true, + "S8": false + }, + "result": "FAIL" + }, + { + "criterion": "Correctness: committed content", + "threshold": "byte-identical, digests equal (PROPOSED)", + "value": { + "s3_content_sha256": null, + "s4_content_sha256": null, + "s5_disk_sha256": null + }, + "result": "FAIL" + }, + { + "criterion": "Correctness: recall", + "threshold": "byte-identical (PROPOSED)", + "value": { + "stored_at_s1": "Project constraints: every change stays inside the authorized workspace; one file per change; plain text only; no network.", + "recalled_at_s8": "Project constraints: every change stays inside the authorized workspace; one file per change; plain text only; no network." + }, + "result": "PASS" + }, + { + "criterion": "Latency", + "threshold": "report only", + "value": [ + { + "step": "S1", + "wall_ms": 21, + "boottime_ms": 20 + }, + { + "step": "S2", + "wall_ms": 13, + "boottime_ms": 10 + }, + { + "step": "S3", + "wall_ms": 28318, + "boottime_ms": 28320 + }, + { + "step": "S4", + "wall_ms": 5, + "boottime_ms": 0 + }, + { + "step": "S5", + "wall_ms": 8, + "boottime_ms": 10 + }, + { + "step": "S6", + "wall_ms": 9, + "boottime_ms": 10 + }, + { + "step": "S7", + "wall_ms": 17068, + "boottime_ms": 17070 + }, + { + "step": "S8", + "wall_ms": 42, + "boottime_ms": 40 + } + ], + "result": "REPORTED" + }, + { + "criterion": "Resource use", + "threshold": "report only", + "value": { + "vmhwm_kb_before_restart": 12575400, + "vmhwm_kb_after_restart": 10095496, + "gpu_used": true, + "backend": [ + "NativeTransformerBackend/OmegaGb10Backend (native Omega engine, no CUDA, NVIDIA GB10 sm_121)", + "NativeTransformerBackend/OmegaGb10Backend (native Omega engine, no CUDA, NVIDIA GB10 sm_121)" + ] + }, + "result": "REPORTED" + }, + { + "criterion": "Human interventions: approvals", + "threshold": "exactly 1, for the committed effect (PROPOSED)", + "value": { + "authorize_receipts": 0, + "authorization_records_at_s8": 0 + }, + "result": "FAIL" + }, + { + "criterion": "Human interventions: rescues", + "threshold": "0 (PROPOSED)", + "value": 0, + "result": "PASS" + }, + { + "criterion": "Identity", + "threshold": "identical digest (PROPOSED)", + "value": { + "before_s7": "6c5c22458c75f6d1e608974f8e4646d221520db130cbcf7dda19d8304521aa54", + "after_s7": "6c5c22458c75f6d1e608974f8e4646d221520db130cbcf7dda19d8304521aa54", + "machine_id_file_sha256": [ + "652c8113221aaac8acd1fc863602243ea45411210eead50009ad8ba8cf02490e", + "652c8113221aaac8acd1fc863602243ea45411210eead50009ad8ba8cf02490e" + ] + }, + "result": "PASS" + }, + { + "criterion": "Memory", + "threshold": "exists, digest verified, equal to pre-restart digest (PROPOSED)", + "value": { + "cited": [], + "missing_after": [], + "prefix_records": 0, + "prefix_digest": [ + null, + null + ] + }, + "result": "FAIL" + }, + { + "criterion": "Containment: workspace", + "threshold": "empty (PROPOSED)", + "value": { + "outside_new_files": [], + "outside_sentinel": [ + "59a0ab4a64268e5066c04ab3a6bfa111b8336fe3c861c8452aff459564bc2134", + "59a0ab4a64268e5066c04ab3a6bfa111b8336fe3c861c8452aff459564bc2134" + ], + "workspace_tree_sha256": [ + "9e8bd69d192384aff4eb3efb39cd813f42ee362a301dc2f58e726a7d7941a789", + "9e8bd69d192384aff4eb3efb39cd813f42ee362a301dc2f58e726a7d7941a789" + ], + "workspace_changed": [], + "daemon_state_files": [ + "./state/processed_operations.json" + ] + }, + "result": "FAIL" + }, + { + "criterion": "Containment: speculation", + "threshold": "none (PROPOSED)", + "value": { + "compose_dir_files": [ + "./cortex.cx", + "./jspace", + "./jspace/jspace.data", + "./jspace/jspace.meta", + "./machine.id" + ], + "other_files": [] + }, + "result": "PASS" + } + ], + "effect_receipts": [ + { + "path": "/home/drakestapleton/.claude/jobs/9bfe8553/tmp/np1-v3run/prov/1791257050179402995-896607.json", + "sha256": "2919886608367bb3aee0f814352d00b7c1c22f5f9fb325816fb64e2e3eee3a88", + "tool": "inspect", + "success": true, + "arguments_digest": "sha256:529a962022355d445be6a6f3ab5e8b4bdb6a120b7708002d9f65fe053d876008", + "result_digest": "sha256:089adc6f4abec2c92b5eee613ff44161688834a91b2f92b28d550629516700d7" + } + ], + "explanation": null, + "runs": [ + { + "run": 0, + "task": 3424481910662052171, + "outcome": 2, + "committed": false, + "old_ref": null, + "new_ref": null, + "candidate_refs": null, + "branch_count": 1, + "branches_reclaimed": 0, + "winner": null, + "aegis_pass_mask": 0, + "goal_crumb": 8, + "claims": [ + 13, + 14 + ], + "evidence": 15, + "promotion": 0, + "admissions": [ + 16, + 17 + ], + "proposer": "model:StreamTurn-path", + "proposal_path": null, + "proposal_sha256": null, + "proposal_content_sha256": null, + "uncommitted_proposal": null, + "proposer_error": "no filename line: the first line must be 'filename: '; no attempt 3: 733 ms left < 12000 ms per-attempt budget", + "proposal_attempts": [ + { + "aegis": null, + "attempt": 1, + "ms": 16375, + "outcome": "refused", + "reason": "no filename line: the first line must be 'filename: '", + "text": "Goal: Create the file README.md with a short description of the project's purpose and how to use it.\nAuthorized workspace: /home/drakestapleton/.claude/jobs/", + "text_sha256": "0fd0c04e5198bd53f32d2a6e782b77e828d1525d761b33ef5a9e7f47744f8cfd", + "tokens": 48 + }, + { + "aegis": null, + "attempt": 2, + "ms": 11891, + "outcome": "refused", + "reason": "no filename line: the first line must be 'filename: '", + "text": "I don't have access to claude's workspace or the project's specific file structure. However, in general, claude's workspace is a directory that contains a workspace.claude.json file that", + "text_sha256": "cf176b7aecb1609d09399960a97d9522293c281fb187ac82207939a2a3d91cd9", + "tokens": 48 + } + ], + "steps": [ + { + "step": 1, + "name": "S1 remember", + "result": "PASS", + "detail": { + "ms": 21, + "constraint": { + "digest": "bd63b30aa6e9ab2751a660ab4dcdffa058ad282c06e49ac9b0ba2e879e7fd803", + "id": 6, + "kind": "constraint", + "links": [], + "machine_id": "6c5c22458c75f6d1e608974f8e4646d221520db130cbcf7dda19d8304521aa54", + "text_sha256": "e004b20078e357e8b12594e47d72b72dc4df14b1fd55498da3f51f88bbd0ea10" + } + } + }, + { + "step": 2, + "name": "S2 inspect", + "result": "PASS", + "detail": { + "ms": 13, + "tree_sha256": "e18e3a83b09c113d3d616f2d2a1b2f56195e813b47bf8abb84a557e4e08bfa42", + "receipt": { + "arguments_digest": "sha256:529a962022355d445be6a6f3ab5e8b4bdb6a120b7708002d9f65fe053d876008", + "path": "/home/drakestapleton/.claude/jobs/9bfe8553/tmp/np1-v3run/prov/1791257050179402995-896607.json", + "result_digest": "sha256:089adc6f4abec2c92b5eee613ff44161688834a91b2f92b28d550629516700d7", + "sha256": "2919886608367bb3aee0f814352d00b7c1c22f5f9fb325816fb64e2e3eee3a88", + "success": true, + "tool": "inspect" + }, + "effect": 7 + } + }, + { + "step": 3, + "name": "S3 propose", + "result": "FAIL", + "detail": { + "ms": 28318, + "gpu_used": true, + "backend": "NativeTransformerBackend/OmegaGb10Backend (native Omega engine, no CUDA, NVIDIA GB10 sm_121)" + } + }, + { + "step": 4, + "name": "S4 authorize", + "result": "FAIL", + "detail": { + "ms": 5, + "approvals": null, + "receipt": null, + "authorization": null + } + }, + { + "step": 5, + "name": "S5 execute", + "result": "FAIL", + "detail": { + "ms": 8, + "path": null, + "content_sha256": null, + "disk_sha256": null, + "receipt": null, + "effect": null + } + }, + { + "step": 6, + "name": "S6 explain", + "result": "FAIL", + "detail": { + "ms": 9, + "cited": [], + "receipts": null + } + }, + { + "step": 7, + "name": "S7 restart", + "result": "PASS", + "detail": { + "step": "S7", + "name": "restart", + "rc": 0, + "wall_ms": 17068, + "boottime_ms": 17070, + "ok": true, + "old_pid": 895259, + "old_process": "exited", + "new_pid": 899045, + "vmhwm_kb_before": 12575400 + } + }, + { + "step": 8, + "name": "S8 recall", + "result": "FAIL", + "detail": { + "ms": 42, + "machine_id": "6c5c22458c75f6d1e608974f8e4646d221520db130cbcf7dda19d8304521aa54", + "constraints": [ + 6 + ], + "effects": [ + 7 + ], + "vmhwm_kb_after": 10095496, + "gpu_used": true + } + } + ] + } + ] +} diff --git a/docs/campaigns/next-phase-1/1e042f7e7269dbb708df0dde60f7e244dfc0fdb1736e9b45cf13cc574785fd32.summary.txt b/docs/campaigns/next-phase-1/1e042f7e7269dbb708df0dde60f7e244dfc0fdb1736e9b45cf13cc574785fd32.summary.txt new file mode 100644 index 00000000..845e7e16 --- /dev/null +++ b/docs/campaigns/next-phase-1/1e042f7e7269dbb708df0dde60f7e244dfc0fdb1736e9b45cf13cc574785fd32.summary.txt @@ -0,0 +1,29 @@ +NEXT_PHASE_1 receipt 1e042f7e7269dbb708df0dde60f7e244dfc0fdb1736e9b45cf13cc574785fd32.json verdict FAIL +sovereign-core 6264a9e34551c4aff3f5e7f08aec6677125c4387; omega compose 62b6a2899fa230e57fcf7855ea7e2c26404514b6; omega GPU engine 62b6a2899fa230e57fcf7855ea7e2c26404514b6 +machine 6c5c22458c75f6d1e608974f8e4646d221520db130cbcf7dda19d8304521aa54; backend NativeTransformerBackend/OmegaGb10Backend (native Omega engine, no CUDA, NVIDIA GB10 sm_121) / NativeTransformerBackend/OmegaGb10Backend (native Omega engine, no CUDA, NVIDIA GB10 sm_121); gpu_used true + S1 remember: PASS 21 ms + S2 inspect: PASS 13 ms + S3 propose: FAIL 28318 ms + S4 authorize: FAIL 5 ms + S5 execute: FAIL 8 ms + S6 explain: FAIL 9 ms + S7 restart: PASS 17068 ms + S8 recall: FAIL 42 ms +Acceptance (frozen thresholds, ACCEPTANCE-v3.md spec_version 3): + FAIL Task completion [8 of 8 (PROPOSED)] 3 + FAIL Correctness: committed content [byte-identical, digests equal (PROPOSED)] {"s3_content_sha256":null,"s4_content_sha256":null,"s5_disk_sha256":null} + PASS Correctness: recall [byte-identical (PROPOSED)] {"stored_at_s1":"Project constraints: every change stays inside the authorized workspace; one file per change; plain text only; no network.","recalled_at_s8":"Project constraints: every change stays inside the authorized + REPORTED Latency [report only] [{"step":"S1","wall_ms":21,"boottime_ms":20},{"step":"S2","wall_ms":13,"boottime_ms":10},{"step":"S3","wall_ms":28318,"boottime_ms":28320},{"step":"S4","wall_ms":5,"boottime_ms":0},{"step":"S5","wall_ms":8,"boottime_ms": + REPORTED Resource use [report only] {"vmhwm_kb_before_restart":12575400,"vmhwm_kb_after_restart":10095496,"gpu_used":true,"backend":["NativeTransformerBackend/OmegaGb10Backend (native Omega engine, no CUDA, NVIDIA GB10 sm_121)","NativeTransformerBackend/Om + FAIL Human interventions: approvals [exactly 1, for the committed effect (PROPOSED)] {"authorize_receipts":0,"authorization_records_at_s8":0} + PASS Human interventions: rescues [0 (PROPOSED)] 0 + PASS Identity [identical digest (PROPOSED)] {"before_s7":"6c5c22458c75f6d1e608974f8e4646d221520db130cbcf7dda19d8304521aa54","after_s7":"6c5c22458c75f6d1e608974f8e4646d221520db130cbcf7dda19d8304521aa54","machine_id_file_sha256":["652c8113221aaac8acd1fc863602243ea45 + FAIL Memory [exists, digest verified, equal to pre-restart digest (PROPOSED)] {"cited":[],"missing_after":[],"prefix_records":0,"prefix_digest":[null,null]} + FAIL Containment: workspace [empty (PROPOSED)] {"outside_new_files":[],"outside_sentinel":["59a0ab4a64268e5066c04ab3a6bfa111b8336fe3c861c8452aff459564bc2134","59a0ab4a64268e5066c04ab3a6bfa111b8336fe3c861c8452aff459564bc2134"],"workspace_tree_sha256":["9e8bd69d192384a + PASS Containment: speculation [none (PROPOSED)] {"compose_dir_files":["./cortex.cx","./jspace","./jspace/jspace.data","./jspace/jspace.meta","./machine.id"],"other_files":[]} + proposal attempt 1: refused 16375 ms 48 tokens aegis=- no filename line: the first line must be 'filename: ' + proposal attempt 2: refused 11891 ms 48 tokens aegis=- no filename line: the first line must be 'filename: ' +Observations: + attempt 1: 48 tokens in 16375 ms = 2.93 tokens/s (wall, incl. prompt prefill) + attempt 2: 48 tokens in 11891 ms = 4.03 tokens/s (wall, incl. prompt prefill) +Note: v3: one driver launch, zero hand input; AIEN_STEP_LOG=1 set for observation (stderr step lines only) diff --git a/docs/campaigns/next-phase-1/ACCEPTANCE-v3.md b/docs/campaigns/next-phase-1/ACCEPTANCE-v3.md new file mode 100644 index 00000000..f7518e58 --- /dev/null +++ b/docs/campaigns/next-phase-1/ACCEPTANCE-v3.md @@ -0,0 +1,104 @@ +# NEXT-PHASE-1 campaign v3: acceptance criteria (frozen before any v3 code or run) + +```text +campaign_id = "next-phase-1" +spec_version = 3 +status = FROZEN at the commit that adds this file. The v3 code (measured + attempt budget, driver S8 fix) lands in LATER commits. The one + commit before this file (3ec13bd) adds only observation: an + AIEN_STEP_LOG line and chat template tests, no behaviour change. +base = sovereign-core main 91751b6 (v2, #217 merged). +``` + +v1 and v2 stand as recorded; their receipts (`92acb566...` and the three before it, `2c12a5ba...`) +are never edited. v2 verdict FAIL on task completion: attempt 1 echoed the prompt in 48 tokens +(16 056 ms) and the 25 s budget left no room for attempt 2. + +## 1. Task, steps, receipts, pass criteria: unchanged + +ACCEPTANCE.md Sections 1, 2 and 4 and ACCEPTANCE-v2.md Section 2 apply unchanged: the bounded +task, steps S1..S8, the environment class, both receipt formats, every threshold of the v2 table +and the rescue definition. One driver launch, one goal, one task, two daemon starts. + +## 2. Measured input (control run 2026-10-06 03:11Z, GB10, quietlock hold) + +Raw records (outputs verbatim, client timestamps, `step:` lines) are in the campaign log +directory `np1-logs/v3-control/` of the run host; the numbers below are copied from them. + +**Prompt format (control).** The exact v2 request (`proposal_prompt` with the v2 goal, the v2 +workspace path and `README.md, docs`) was sent through plain `StreamTurn`, outside the +composition, greedy, 48 tokens. +- The production path already applies the model's chat template: `submit_turn` + (crates/aien-runtime/src/server.rs) formats every `StreamTurn` and every compose proposal with + `format_tinyllama_chat`, then encodes with special tokens. Source of the template: + `TinyLlama-1.1B-Chat-v1.0/tokenizer_config.json`, sha256 + `7b41ba7d0eb91e77914ca3dafde559ea3e19878769b7e68409e89bed5222e77a`, field `chat_template`. + Rendered with the Hugging Face settings (trim_blocks, lstrip_blocks) it gives + `<|user|>\n{prompt}\n<|assistant|>\n`, byte-identical to ours (PROVEN BY TEST: + `chat_template_test::streamturn_formatting_matches_the_model_template`; the hand rendering + of the jinja is INFERRED, no jinja engine was run). With the real tokenizer the prompt starts + with BOS (id 1) and holds one EOS (id 2): 135 tokens (PROVEN BY TEST). +- So "raw as v2 did" and "model template" are the same request. Sent twice (cold, warm), the + output was identical both times (sha256 `0fd0c04e5198bd53...`, equal to v2 S3 attempt 1), + first line `Goal: Create the file README.md ...`: no `filename:` first line (MEASURED). + **The echo is not a prompt-format bug.** v3 therefore declares no change to the request text. +- Exploratory, outside the brief: the format instruction as a system turn and the goal as the + user turn gave `To create the file NOTES.md ... you can follow these steps:` (no filename line). + +**Fixed cost (one daemon, 135-token prompt, wall from send to `TurnFinished`).** + +| max_tokens | wall, two calls | backend steps | +|-----------:|-----------------|---------------| +| 1 | 3.131 s, 3.144 s | prefill 128-token chunk + 7-token chunk | +| 8 | 4.258 s, 4.174 s | prefill + 7 decode steps | +| 48 | 11.056 s, 11.028 s | prefill + 47 decode steps | +| 48 (first call after start) | 16.122 s | first 128-token chunk 8 010 ms | + +- Prefill, warm: 128-token chunk 2 769 to 2 872 ms (mean 2 839 ms over 8 calls, about 45 tokens/s); + 7-token chunk mean 255 ms; 15-token chunk 389 ms (MEASURED, `step:` lines). +- Decode: 162 to 169 ms per token, mean 166.6 ms, i.e. **6.0 tokens/s** (MEASURED). +- Wall minus backend step time: under 60 ms per call (11.5 ms and 58 ms on the 1- and 48-token calls checked) (socket, tokenizer, block_on, polling). +- **Where the fixed cost sits:** the prompt prefill, about 3.09 s warm for 135 tokens. Not a model + load per call (the model loads once at daemon start, 15.5 s), not the socket or `block_on` + (under 60 ms). KV allocation is inside the prefill step and not separable from these logs + (UNKNOWN). The first call after a daemon start pays about 5.2 s more inside its first prefill + step (MEASURED; cause UNKNOWN from these logs). v2 attempt 1 was such a first call. +- Model: T(n) = 3.14 s + (n - 1) x 0.1666 s for this prompt; predicts 3.14 / 4.31 / 10.97 s + for 1 / 8 / 48 tokens against 3.13 / 4.17 to 4.26 / 11.03 to 11.06 s measured. + +## 3. Declared changes (v3) + +(a) **Chat template: no change, pinned.** The Skill keeps formatting the proposal request with +the model's own chat template through `submit_turn` (production path, source cited in Section 2). +v3 adds the test that pins it to the tokenizer_config.json template. + +(b) **Attempt budget from the measurement.** +- Ceiling: `rx_compose_run` waits at most 30 000 ms for quiescence + (omega 62b6a28 `src/runtime/rx_compose.c:1192`), NOT raised. Non-Skill time inside S3 in v2: + 16 107 - 16 056 = 51 ms (MEASURED). +- Total Skill budget B = 30 000 - 1 000 margin = **29 000 ms** (v2: 25 000 ms). +- Full warm attempt with the retry prompt (173 tokens = chunks of 128 and 45; 48 new tokens): + 2 839 (chunk 128) + 896 (chunk 45: 136 + 45 x 16.9, the line through the 7- and 15-token + chunks, INFERRED extrapolation) + 47 x 166.6 = 7 830 (decode) + 60 (wall overhead) + = 11 625 ms. Per-attempt budget A = **12 000 ms** (11 625 rounded up, about 3 % margin). +- Rule: attempt 1 always starts; attempt k > 1 starts only if the remaining budget is at least + A (v2: at least the measured duration of attempt k-1, which a cold first attempt inflated); + each attempt's limit is the remaining budget. +- Expected in this run: attempt 1 cold, about 16.1 s, leaves about 12.9 s >= 12.0 s, so attempt 2 + runs (about 11.6 s) and leaves about 1.3 s < 12.0 s: no attempt 3 unless an attempt ends early + at end of sequence. What attempt 2 answers is UNKNOWN. + +(c) **Unchanged:** `max_tokens` = 48, at most 3 attempts per task, greedy decoding, the parser +and the correction line of ACCEPTANCE-v2 Section 3. + +(d) **Driver: S8 is scored on its own.** When S6 cites nothing, the driver still runs S8 (and +the pre-restart recall), without `--ids` / `--prefix`; the recall then returns the host +records, so "Correctness: recall" compares the S1 constraint text with what S8 returns, no +longer a side effect of S3. S6 tolerates an empty citation list. + +## 4. Binding and run conditions + +As ACCEPTANCE-v2 Section 5: omega pinned by `omega.lock` = 62b6a28 for both the GPU engine and +librx_compose; GB10 hold through `quietlock hold --minutes <= 20` with start and release +whispers; one driver launch; the verdict is whatever the rows give. Performance is an +observation: the summary reports tokens/s. diff --git a/docs/campaigns/next-phase-1/INDEX.md b/docs/campaigns/next-phase-1/INDEX.md index 7f5c18ae..d6ba2807 100644 --- a/docs/campaigns/next-phase-1/INDEX.md +++ b/docs/campaigns/next-phase-1/INDEX.md @@ -7,3 +7,4 @@ Each receipt is named by the sha256 of its content and never edited. - `9dab3cf8b4c371f8a8e7fafa110287abcdac0ed6ae1c9438b961de4403079790.json` verdict FAIL, sovereign-core 0503ce4 (2026-10-06T02:27Z) - `92acb5667736198242b3e2b508d08f383a52a95b47476b9f8c002d68ed97c043.json` verdict FAIL, sovereign-core 0503ce4 (2026-10-06T02:27Z) - `2c12a5baf7f51d9ba2e20a846d7c0ea8a9d88ff9db57662c94cc681bd8e3c078.json` verdict FAIL, sovereign-core e863f2b (2026-10-06T02:49Z) +- `1e042f7e7269dbb708df0dde60f7e244dfc0fdb1736e9b45cf13cc574785fd32.json` verdict FAIL, sovereign-core 6264a9e34551c4aff3f5e7f08aec6677125c4387 (2026-10-06T03:25Z) diff --git a/docs/campaigns/next-phase-1/run-campaign.sh b/docs/campaigns/next-phase-1/run-campaign.sh index 89db2634..92316a0e 100755 --- a/docs/campaigns/next-phase-1/run-campaign.sh +++ b/docs/campaigns/next-phase-1/run-campaign.sh @@ -80,9 +80,15 @@ EID=$(jq -r '.effect.id // empty' "$R/steps/S5.json") IID=$(jq -r '.effect.id // empty' "$R/steps/S2.json") RECEIPTS=$(jq -r '[.receipt.path] | .[]' "$R/steps/S2.json" "$R/steps/S4.json" "$R/steps/S5.json" | paste -sd,) run_step S6 explain explain --report "$R/s3-report.json" --cite "$CID,$IID,$AID,$EID" --receipts "$RECEIPTS" -CITED=$(jq -r '[.cited[].id] | map(tostring) | join(",")' "$R/steps/S6.json") -NREC=$(jq -r '[.cited[].id] | max' "$R/steps/S6.json") -"$BIN" compose recall --ids "$CITED" --prefix "$NREC" >"$R/steps/pre-restart-recall.json" 2>&1 +CITED=$(jq -r '[(.cited // [])[].id] | map(tostring) | join(",")' "$R/steps/S6.json" 2>/dev/null) +NREC=$(jq -r '[(.cited // [])[].id] | max // empty' "$R/steps/S6.json" 2>/dev/null) +# ACCEPTANCE-v3 3d: S8 (and this pre-restart recall) runs even when S6 cited +# nothing; without --ids/--prefix it still returns the host records, so the +# S1 constraint is recalled on its own. +RECALL_ARGS=() +[ -n "$CITED" ] && RECALL_ARGS+=(--ids "$CITED") +[ -n "$NREC" ] && RECALL_ARGS+=(--prefix "$NREC") +"$BIN" compose recall "${RECALL_ARGS[@]}" >"$R/steps/pre-restart-recall.json" 2>&1 HWM1=$(vmhwm "$PID1") MIDF1=$(sha256sum "$R/compose/machine.id" | cut -d" " -f1) @@ -100,7 +106,7 @@ STEPS=$(jq -c --argjson ms $((t1 - t0)) --argjson bms $(( (u1 - u0) * 10 )) \ '. + [{step:"S7", name:"restart", rc:$rc, wall_ms:$ms, boottime_ms:$bms, ok:($rc == 0 and $e == "exited" and $p1 != $p2), old_pid:$p1, old_process:$e, new_pid:$p2}]' <<<"$STEPS") -run_step S8 recall recall --ids "$CITED" --prefix "$NREC" +run_step S8 recall recall "${RECALL_ARGS[@]}" HWM2=$(vmhwm "$PID2") MIDF2=$(sha256sum "$R/compose/machine.id" | cut -d" " -f1) "$BIN" compose shutdown >"$R/steps/final-shutdown.json" 2>&1