diff --git a/core/continuum-academy/src/cognition/eval/cognition_eval.rs b/core/continuum-academy/src/cognition/eval/cognition_eval.rs index 09b221225a..7b205af465 100644 --- a/core/continuum-academy/src/cognition/eval/cognition_eval.rs +++ b/core/continuum-academy/src/cognition/eval/cognition_eval.rs @@ -428,8 +428,8 @@ impl CognitionEval { ); } - let max_acts = p.max_acts.unwrap_or(DEFAULT_MAX_ACTS) as usize; - let max_retries = p.max_retries.unwrap_or(MAX_FAIL_RETRIES); + // The caller declared both: an exam's budget is part of what it measures. + let (max_acts, max_retries) = (p.budget, p.max_retries); let total = tasks.len() as u32; let rate = |score: u32| { if total > 0 { @@ -564,6 +564,7 @@ impl CognitionEval { &eval_set_label, _fleet_lease.as_ref().map(|_| true), _eval_lane.as_ref().and_then(|lane| lane.measured_gene.as_ref()), + ExamPolicy { budget: max_acts, max_retries }, ); world.finish().await; return Ok(result); @@ -655,7 +656,7 @@ impl CognitionEval { } let who = sp .sender - .map(|u| u.to_string()[..8].to_string()) + .map(airc_core::shown_id::shown_form) .unwrap_or_else(|| "peer".into()); // legacy senderless call site: an anonymous voice, labeled as such wm.record_dispatch_event( Uuid::new_v4(), @@ -778,6 +779,7 @@ impl CognitionEval { &eval_set_label, _fleet_lease.as_ref().map(|_| true), None, + ExamPolicy { budget: max_acts, max_retries }, ); world.finish().await; Ok(result) diff --git a/core/continuum-academy/src/cognition/eval/default_eval_set.rs b/core/continuum-academy/src/cognition/eval/default_eval_set.rs index 106cc65114..3ff3a129f2 100644 --- a/core/continuum-academy/src/cognition/eval/default_eval_set.rs +++ b/core/continuum-academy/src/cognition/eval/default_eval_set.rs @@ -11,18 +11,6 @@ use super::*; /// the resolver instead of `std::fs::read_to_string`. pub(super) const DEFAULT_EVAL_SET: &str = "docs/genome/coder-eval.jsonl"; -/// How many act→observe cycles a single task may take before it counts as -/// unfinished, when neither the caller nor the task row sets `max_acts`. -/// -/// Raised 8 → 32 on 2026-08-23 after the MirrorCode baseline showed what 8 -/// buys on a frontier task: Atlas spent the whole budget on a genuinely -/// competent case-bucketing analysis and was graded with an EMPTY src/ — the -/// cap measured our patience, not the model ("repeated engineering process -/// till finished … who cares if it has to cycle to do it" — the doctrine the -/// old default contradicted). Tasks that need fewer acts settle on their own; -/// the cap only exists to bound a runaway, so it must sit ABOVE what honest -/// engineering needs. Per-task rows override via `EvalTask::max_acts`. -pub(super) const DEFAULT_MAX_ACTS: u32 = 32; /// Fixed "exam epoch" stamped on every task's burst (`[t=] peer: …`). The /// live burst carries each message's real `occurred_at_ms`; the eval pins it to @@ -153,26 +141,7 @@ where /// step over — the living persona's lane. pub(super) const EVAL_LANE_BASE_PORT: u16 = 58_200; -/// How much of a graded answer to persist in the result. A coder answer (code + reasoning) -/// fits far under this; the generous bound exists ONLY to cap a pathological loop-to-length -/// generation (which is captured up to here, still a diagnosable signal). The old 200-char -/// cap stored only the preamble and blinded every failure diagnosis + correction-corpus mine. -// context-budget-exempt: observability: how much of an answer is CAPTURED into the run ledger for humans, never text sent to a model -pub(super) const ANSWER_CAPTURE_CHARS: usize = 24_000; - -/// Per-task detail retained in the DURABLE run ledger row (`append_progress_ledger`). -/// The ledger stored only the summary (score/total), so a detached run's per-task -/// verdicts were unrecoverable — a webdev pass/fail could not be glass-boxed after the -/// fact (glass-boxed 2026-07-21: could not tell whether an `acts=0` webdev miss was the -/// mouth-or-hands capture not firing or the spoken page failing a strict check). We now -/// persist a compact per-task array; the diagnostic `grade` verdict + answer head are kept -/// ONLY for FAILED tasks, so a 164-task humaneval row stays lean while a failing 6-task -/// webdev row is fully inspectable. [[self-test-via-command-feedback-surface-never-blind]] -// context-budget-exempt: observability: ledger rendering width for a failed grade, human-facing only -pub(super) const LEDGER_FAIL_GRADE_CHARS: usize = 800; -// context-budget-exempt: observability: ledger rendering width for a failed answer, human-facing only -pub(super) const LEDGER_FAIL_ANSWER_CHARS: usize = 1_200; /// Wall-clock TTL for the eval lane's governed VRAM lease (#56/G1). Expiry /// makes a lease eligible for the governor's reclaim protocol; it is not proof diff --git a/core/continuum-academy/src/cognition/eval/eval_settle.rs b/core/continuum-academy/src/cognition/eval/eval_settle.rs index 8fe8764dbc..a8ccfc786b 100644 --- a/core/continuum-academy/src/cognition/eval/eval_settle.rs +++ b/core/continuum-academy/src/cognition/eval/eval_settle.rs @@ -9,7 +9,7 @@ pub(super) async fn eval_settle( cycle: &crate::cognition::workspace::WorkspaceCycle, room: crate::identity::ActivityRoom, prompt: &str, - max_acts: usize, + max_acts: crate::cognition::act_observe::TurnBudget, ) -> crate::cognition::act_observe::SettleOutcome { let delivery = crate::cognition::rag_budget::RagDelivery { source_id: "airc".to_string(), @@ -56,7 +56,7 @@ pub(super) async fn run_pass_team( reviewer_iso: &crate::cognition::workspace::EvalIsolation, tasks: &[EvalTask], room: crate::identity::ActivityRoom, - max_acts: usize, + max_acts: crate::cognition::act_observe::TurnBudget, // The run's resolved eval root (explicit pin or #312 ephemeral clone) — // artifact grading resolves solution files against it, same as solo. workspace_root: Option<&str>, @@ -180,7 +180,7 @@ pub(super) async fn run_pass_team( ok, grade, acts, - answer: answer.chars().take(ANSWER_CAPTURE_CHARS).collect(), + answer, latency_ms: m.latency_ms, output_tokens: m.output_tokens, tokens_per_second: m.tokens_per_second(), diff --git a/core/continuum-academy/src/cognition/eval/eval_task_result.rs b/core/continuum-academy/src/cognition/eval/eval_task_result.rs index 1996745082..8f1e4efdd0 100644 --- a/core/continuum-academy/src/cognition/eval/eval_task_result.rs +++ b/core/continuum-academy/src/cognition/eval/eval_task_result.rs @@ -15,9 +15,9 @@ pub struct EvalTaskResult { /// the act budget mid-action — an honest "did not finish", never fabricated). For a /// coder exam the answer IS the code, so this must carry the whole thing: a 200-char /// cap stored only the "Sure, I can help..." preamble and made every failure - /// undiagnosable AND un-minable for a correction corpus (2026-07-21). Bounded by - /// ANSWER_CAPTURE_CHARS against a pathological loop-to-length, which is itself a - /// signal worth capturing up to the cap. + /// undiagnosable AND un-minable for a correction corpus (2026-07-21). Kept whole: the + /// generation's own token bound already sizes it, and a loop-to-length is a signal to + /// keep complete, never a reason to cut her newest words (2026-11-02). pub answer: String, /// Wall-clock latency to SETTLE this task: the summed deliberation-generation /// time across every act→observe tick (the model's own measured request time, diff --git a/core/continuum-academy/src/cognition/eval/format_exam_lesson.rs b/core/continuum-academy/src/cognition/eval/format_exam_lesson.rs index b4a8ed2f4a..c3f54f0100 100644 --- a/core/continuum-academy/src/cognition/eval/format_exam_lesson.rs +++ b/core/continuum-academy/src/cognition/eval/format_exam_lesson.rs @@ -1,4 +1,5 @@ use super::*; +use continuum_kernel::system_resources::disk_reporters::ClassWriter; /// Build the durable LESSON string for one graded exam task — what she was asked /// and how she did. Pure and answer-key-agnostic (the caller's redaction policy @@ -370,14 +371,34 @@ crate::register_stateless_command!(CognitionEvalStatus); /// The progress-ledger directory (`~/.continuum/progress`), the ONE place /// [`append_progress_ledger`] writes and `cognition/eval-status` reads. -pub(crate) fn progress_ledger_dir() -> Option { - dirs::home_dir().map(|home| home.join(".continuum/progress")) +/// The disk class exam ledgers live in (registered in `disk_reporters::standard`). +const PROGRESS_CLASS: &str = "progress"; + +pub(crate) fn progress_ledger() -> std::io::Result { + ClassWriter::of(PROGRESS_CLASS) +} + +/// A persona's exam ledger file in the progress class: the one place its name is formed. +fn ledger_file(persona_id: &str) -> std::path::PathBuf { + std::path::PathBuf::from(format!("{persona_id}.jsonl")) +} + +/// Append one row to `persona_id`'s ledger, through the class (never a path picked here). +/// A ledger that cannot be written is logged, never silently dropped. +fn append_ledger_row(persona_id: &str, row: &serde_json::Value) { + use std::io::Write; + let written = progress_ledger() + .and_then(|class| class.append(&ledger_file(persona_id))) + .and_then(|mut file| writeln!(file, "{row}")); + if let Err(error) = written { + tracing::warn!(persona_id, %error, "the exam ledger row was not written"); + } } /// The terminal ledger row for `run_id` in a KNOWN persona's ledger, newest-first. /// `None` = no such row yet (the run is still in flight, or the id is wrong). pub(super) fn find_run_row_for_persona(persona_id: &str, run_id: &str) -> Option { - let path = progress_ledger_dir()?.join(format!("{persona_id}.jsonl")); + let path = progress_ledger().ok()?.path(&ledger_file(persona_id)).ok()?; let text = std::fs::read_to_string(&path).ok()?; row_with_run_id(&text, run_id) } @@ -388,12 +409,12 @@ pub(super) fn find_run_row_for_persona(persona_id: &str, run_id: &str) -> Option /// one persona's ledger). Keeps run_id a sufficient key so a matrix/CI poller never /// hangs on a false pending just because it didn't also thread the persona_id. pub(crate) fn find_run_row_any_persona(run_id: &str) -> Option { - let dir = progress_ledger_dir()?; - for entry in std::fs::read_dir(&dir).ok()?.flatten() { - let path = entry.path(); - if path.extension().and_then(|e| e.to_str()) != Some("jsonl") { + let class = progress_ledger().ok()?; + for name in class.files().ok()? { + if name.extension().and_then(|e| e.to_str()) != Some("jsonl") { continue; } + let Ok(path) = class.path(&name) else { continue }; if let Ok(text) = std::fs::read_to_string(&path) { if let Some(row) = row_with_run_id(&text, run_id) { return Some(row); @@ -449,14 +470,6 @@ pub(super) fn append_failed_ledger( error: &str, ) { let persona_id = persona.as_str(); - let Some(home) = std::env::var("HOME").ok() else { - return; - }; - let dir = std::path::PathBuf::from(home).join(".continuum/progress"); - if std::fs::create_dir_all(&dir).is_err() { - return; - } - let path = dir.join(format!("{persona_id}.jsonl")); let row = serde_json::json!({ "capturedAtMs": EpochMs::now().millis(), "personaId": persona_id, @@ -467,14 +480,7 @@ pub(super) fn append_failed_ledger( "score": 0, "total": 0, }); - use std::io::Write; - if let Ok(mut f) = std::fs::OpenOptions::new() - .create(true) - .append(true) - .open(&path) - { - let _ = writeln!(f, "{row}"); - } + append_ledger_row(persona_id, &row); } /// `clean_lane`: whether an eval-preemption quiesce lease was held for this run @@ -587,12 +593,6 @@ pub(super) fn append_task_ledger_row( ok: bool, acts: u32, ) { - let Some(dir) = progress_ledger_dir() else { - return; - }; - if std::fs::create_dir_all(&dir).is_err() { - return; - } let row = serde_json::json!({ "kind": "task", "capturedAtMs": EpochMs::now().millis(), @@ -603,14 +603,7 @@ pub(super) fn append_task_ledger_row( "ok": ok, "acts": acts, }); - use std::io::Write; - if let Ok(mut f) = std::fs::OpenOptions::new() - .create(true) - .append(true) - .open(dir.join(format!("{persona_id}.jsonl"))) - { - let _ = writeln!(f, "{row}"); - } + append_ledger_row(persona_id, &row); } pub(super) fn append_progress_ledger( @@ -619,18 +612,14 @@ pub(super) fn append_progress_ledger( eval_set: &str, clean_lane: Option, measured_gene: Option<&crate::genome::adapter_manifest::TrainedAdapter>, + policy: ExamPolicy, ) { - let Some(dir) = progress_ledger_dir() else { - return; - }; - if std::fs::create_dir_all(&dir).is_err() { - return; - } - let path = dir.join(format!("{}.jsonl", result.persona_id)); let row = serde_json::json!({ "capturedAtMs": EpochMs::now().millis(), "personaId": result.persona_id, "evalSet": eval_set, + // The declared policy this score was measured under. + "policy": policy, "cleanLane": clean_lane, "score": result.score, "total": result.total, @@ -665,20 +654,13 @@ pub(super) fn append_progress_ledger( // Without it the two read identical in the ledger and get hand-diagnosed each time. let mut t = serde_json::json!({ "id": r.id, "ok": r.ok, "acts": r.acts, "outputTokens": r.output_tokens }); if !r.ok { - t["grade"] = serde_json::json!(r.grade.chars().take(LEDGER_FAIL_GRADE_CHARS).collect::()); - t["answerHead"] = serde_json::json!(r.answer.chars().take(LEDGER_FAIL_ANSWER_CHARS).collect::()); + t["grade"] = serde_json::json!(r.grade); + t["answerHead"] = serde_json::json!(r.answer); } t }).collect::>(), }); - use std::io::Write; - if let Ok(mut f) = std::fs::OpenOptions::new() - .create(true) - .append(true) - .open(&path) - { - let _ = writeln!(f, "{row}"); - } + append_ledger_row(&result.persona_id, &row); // TERMINAL completion event (the fire-and-stream close, #86). Every finished eval — // gene A/B, base-model, single-pass — funnels through here, so this ONE publish gives a // monitoring widget/persona "done + final score + per-task detail" as a single push @@ -692,15 +674,6 @@ pub(super) fn append_progress_ledger( } } -/// Run the full task set once through the persona's LIVE cognition, returning the -/// pass count and per-task results. Operates over whatever genome is currently -/// paged into `cycle` — the A/B pages a gene in/out around two calls to this, so -/// the base and candidate arms run the IDENTICAL motion (the only difference is -/// the genome). That sameness is what makes the lift a fair measurement. -/// How many times a FAILED (test-graded) task is handed its compiler/test output to fix -/// before we score it a miss. This is the agentic-recovery budget — the edge over one-shot -/// inference. 3 keeps a full eval bounded while giving real iteration room. -pub(super) const MAX_FAIL_RETRIES: u32 = 3; /// Seconds to wait (1s/try) for a persona's fork-template to appear before failing the /// eval. Covers the post-reboot window where the supervisor's `register_from_cfg` is diff --git a/core/continuum-academy/src/cognition/eval/gene_exam.rs b/core/continuum-academy/src/cognition/eval/gene_exam.rs index 40878b4a88..dc01412d82 100644 --- a/core/continuum-academy/src/cognition/eval/gene_exam.rs +++ b/core/continuum-academy/src/cognition/eval/gene_exam.rs @@ -27,6 +27,13 @@ const UNRELATED_SET: &str = "lc-unrelated"; const NLL_UNMEASURED: &str = "the engine has no forward-only route that scores a supplied completion (POST /learn \ trains a shadow adapter and refuses lr 0), and the acceptance sets carry no reference solutions"; +/// The gene exam's declared policy: the bounds its earlier runs were measured under (32 steps +/// per task, 3 test-output retries), kept so its scores stay comparable across runs. +const GENE_EXAM_POLICY: ExamPolicy = ExamPolicy { + budget: crate::cognition::act_observe::TurnBudget::Steps(32), + max_retries: 3, +}; + pub struct MindExamHost; #[async_trait] @@ -103,7 +110,7 @@ impl ExamHost for MindExamHost { cycle.page_in(genome); let (cycle, isolation, root) = (&cycle, &isolation, root_str.as_str()); async move { - let out = run_pass(cycle, isolation, &tasks, room, DEFAULT_MAX_ACTS as usize, MAX_FAIL_RETRIES, Some(root), None).await; + let out = run_pass(cycle, isolation, &tasks, room, GENE_EXAM_POLICY.budget, GENE_EXAM_POLICY.max_retries, Some(root), None).await; match out.infra_reason { Some(why) => Err(why), None => Ok(ArmTally { settled: tasks.len() as u32, passed: out.pass }), diff --git a/core/continuum-academy/src/cognition/eval/run_pass.rs b/core/continuum-academy/src/cognition/eval/run_pass.rs index 36d1e4082d..db19e65805 100644 --- a/core/continuum-academy/src/cognition/eval/run_pass.rs +++ b/core/continuum-academy/src/cognition/eval/run_pass.rs @@ -5,7 +5,7 @@ pub(super) async fn run_pass( isolation: &crate::cognition::workspace::EvalIsolation, tasks: &[EvalTask], room: crate::identity::ActivityRoom, - max_acts: usize, + max_acts: crate::cognition::act_observe::TurnBudget, max_retries: u32, // The pinned workspace root the persona's hands were rooted at (from-scratch build / // SWE-bench). UI grading MUST observe the artifact HERE, where she wrote it — not the @@ -291,7 +291,7 @@ pub(super) async fn run_pass( let drive = crate::cognition::act_observe::drive_to_settle( cycle, make_burst(), - t.max_acts.map(|v| v as usize).unwrap_or(max_acts), // None = row sets no budget; the run's budget is the documented inherit + task_budget(t, max_acts), if t.silence { // A silence-graded task is AMBIENT by definition: the room moved and // nothing addressed her. Posed as directed, a correct answer to an @@ -433,7 +433,7 @@ pub(super) async fn run_pass( crate::cognition::act_observe::drive_to_settle( cycle, nudge_burst, - t.max_acts.map(|v| v as usize).unwrap_or(max_acts), // None = row sets no budget; the run's budget is the documented inherit + task_budget(t, max_acts), if t.workspace_deliverable() { crate::cognition::workspace::TurnFraming::directed().on_workspace() } else { @@ -512,14 +512,8 @@ pub(super) async fn run_pass( round = redrive_round as u64, "settled on a RED DoD — handing her the verdict with a bounded re-drive" ); - let tail: String = dod_out - .chars() - .rev() - .take(4000) - .collect::>() - .into_iter() - .rev() - .collect(); + // Whole: the one context budget sizes what she sees, newest kept (never a cut here). + let tail = &dod_out; let red_delivery = crate::cognition::rag_budget::RagDelivery { source_id: "airc".to_string(), items: vec![crate::cognition::rag_budget::RagItem { @@ -553,7 +547,7 @@ Fix the workspace and finish — the grade reads th crate::cognition::act_observe::drive_to_settle( cycle, red_burst, - t.max_acts.map(|v| v as usize).unwrap_or(max_acts), // None = row sets no budget; the run's budget is the documented inherit + task_budget(t, max_acts), crate::cognition::workspace::TurnFraming::directed().on_workspace(), ), ) @@ -590,7 +584,7 @@ Fix the workspace and finish — the grade reads th ok: false, grade: format!("infra (DoD could not run, NOT a wrong answer): {reason}"), acts: settled.acts as u32, - answer: answer.chars().take(ANSWER_CAPTURE_CHARS).collect(), + answer, latency_ms: settled.metrics.latency_ms, output_tokens: settled.metrics.output_tokens, tokens_per_second: settled.metrics.tokens_per_second(), @@ -713,7 +707,7 @@ Fix the workspace and finish — the grade reads th ok, grade, acts: total_acts, - answer: answer.chars().take(ANSWER_CAPTURE_CHARS).collect(), + answer, latency_ms: m.latency_ms, output_tokens: m.output_tokens, tokens_per_second: m.tokens_per_second(), @@ -745,3 +739,23 @@ Fix the workspace and finish — the grade reads th infra_reason, } } + +/// A task's act budget: its own row's bound when it sets one, else the run's (one owner for +/// the three drives that read it). +fn task_budget( + t: &EvalTask, + inherit: crate::cognition::act_observe::TurnBudget, +) -> crate::cognition::act_observe::TurnBudget { + t.max_acts + .map(|steps| crate::cognition::act_observe::TurnBudget::Steps(steps as usize)) + .unwrap_or(inherit) +} + +/// An exam's declared resource policy: part of what it measures, so declared by the exam or +/// its caller and never defaulted, and recorded on every ledger row it produces. +#[derive(Clone, Copy, Debug, serde::Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct ExamPolicy { + pub(crate) budget: crate::cognition::act_observe::TurnBudget, + pub(crate) max_retries: u32, +} diff --git a/core/continuum-academy/src/cognition/eval/spawn_gene_eval_lane.rs b/core/continuum-academy/src/cognition/eval/spawn_gene_eval_lane.rs index b7a19817e1..cd62f8902d 100644 --- a/core/continuum-academy/src/cognition/eval/spawn_gene_eval_lane.rs +++ b/core/continuum-academy/src/cognition/eval/spawn_gene_eval_lane.rs @@ -649,19 +649,7 @@ pub(super) fn write_eval_run_marker(root: &std::path::Path, run_id: &str) { // breadcrumb could not be written; the reboot guard just loses this run. // Written through the eval-roots class the run's root lives in (a disk marker read by // the CLI process — a true process boundary). - let written = (|| -> std::io::Result<()> { - use continuum_kernel::system_resources::disk_reporters::tracked_dir; - let class = tracked_dir("eval-roots").ok_or_else(|| { - std::io::Error::new(std::io::ErrorKind::NotFound, "the eval-roots disk class is not registered") - })?; - let within = root.strip_prefix(class.path()).map_err(|_| { - std::io::Error::new( - std::io::ErrorKind::InvalidInput, - format!("{} is not under the eval-roots class {}", root.display(), class.path().display()), - ) - })?; - class.writer().replace(&within.join(EVAL_RUN_MARKER), marker.to_string().as_bytes()) - })(); + let written = write_in_eval_root(&root, EVAL_RUN_MARKER, marker.to_string().as_bytes()); if let Err(e) = written { tracing::warn!(error = %e, "eval run marker not written — reboot guard cannot see this run"); } diff --git a/core/continuum-academy/src/cognition/eval/sweep_orphan_eval_roots.rs b/core/continuum-academy/src/cognition/eval/sweep_orphan_eval_roots.rs index ec6dba09cc..ac47c9fc1f 100644 --- a/core/continuum-academy/src/cognition/eval/sweep_orphan_eval_roots.rs +++ b/core/continuum-academy/src/cognition/eval/sweep_orphan_eval_roots.rs @@ -72,7 +72,7 @@ impl EphemeralEvalRoot { let marker = UnresolvedHands { pids }; let written = serde_json::to_string(&marker) // disk marker read by a later process's sweep — a true process boundary .map_err(|e| e.to_string()) - .and_then(|body| std::fs::write(self.path.join(UNRESOLVED_HANDS_MARKER), body).map_err(|e| e.to_string())); + .and_then(|body| write_in_eval_root(&self.path, UNRESOLVED_HANDS_MARKER, body.as_bytes()).map_err(|e| e.to_string())); if let Err(e) = written { tracing::error!(root = %self.path.display(), error = %e, "an unresolved eval world's marker could not be written; only this process's registry keeps it from the sweep"); } @@ -85,6 +85,22 @@ impl EphemeralEvalRoot { } } +/// Write `name` into the eval world at `root`, through the eval-roots disk class the world +/// lives in (replaced whole). The one way a marker reaches an eval world. +pub(crate) fn write_in_eval_root(root: &std::path::Path, name: &str, bytes: &[u8]) -> std::io::Result<()> { + use continuum_kernel::system_resources::disk_reporters::tracked_dir; + let class = tracked_dir("eval-roots").ok_or_else(|| { + std::io::Error::new(std::io::ErrorKind::NotFound, "the eval-roots disk class is not registered") + })?; + let within = root.strip_prefix(class.path()).map_err(|_| { + std::io::Error::new( + std::io::ErrorKind::InvalidInput, + format!("{} is not under the eval-roots class {}", root.display(), class.path().display()), + ) + })?; + class.writer().replace(&within.join(name), bytes) +} + /// Written into an eval world kept because a fork's hands in it weren't confirmed ended. pub(crate) const UNRESOLVED_HANDS_MARKER: &str = "unresolved-hands.json"; @@ -593,21 +609,16 @@ pub struct CognitionEvalParams { #[ts(optional)] #[ts(optional, type = "number")] pub reviewers: Option, - /// Max act→observe cycles per task before it counts as unfinished. Default 32 - /// (see DEFAULT_MAX_ACTS); a task row's own max_acts overrides per task. - #[serde(default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - #[ts(optional, type = "number")] - pub max_acts: Option, + /// The run's step budget per task, declared by the caller (`{"steps": 32}` or + /// `"unbounded"`): an exam's budget is part of what it measures, so it is never defaulted. + /// A task row's own `max_acts` overrides it per task. + pub budget: crate::cognition::act_observe::TurnBudget, /// Agentic-recovery budget: how many times a FAILED test-graded task is handed its - /// compiler/test output to fix before it scores a miss. Default [`MAX_FAIL_RETRIES`]. - /// Set `0` for the ONE-SHOT baseline (what plain inference gets on the same - /// weights) — so a `0` vs `N` A/B on the identical model+benchmark measures exactly the + /// compiler/test output to fix before it scores a miss, declared by the caller (never + /// defaulted). `0` is the ONE-SHOT baseline (what plain inference gets on the same + /// weights), so a `0` vs `N` A/B on the identical model+benchmark measures exactly the /// edge our agentic loop adds, repeatably, from one param. - #[serde(default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - #[ts(optional, type = "number")] - pub max_retries: Option, + pub max_retries: u32, /// Decoding temperature pin for the WHOLE run. **Omitted → her LIVED /// sampling** (the engineerable form — Joel 2026-08-23: "the old form is /// useless"): greedy 0.0 measured pathological on long-context agentic diff --git a/core/continuum-academy/src/cognition/eval/tests.rs b/core/continuum-academy/src/cognition/eval/tests.rs index e0a6a3cff9..9bcd69be04 100644 --- a/core/continuum-academy/src/cognition/eval/tests.rs +++ b/core/continuum-academy/src/cognition/eval/tests.rs @@ -65,9 +65,15 @@ // regression for the 2026-08-23 finding (a SIGTERM'd reboot orphaned a 31 GB // eval clone that Drop could never reap; the sweep is the crash-path owner, // and live_eval_roots() is what scopes it to true orphans). - #[test] - fn orphan_sweep_removes_dead_worlds_and_never_live_ones() { - let parent = tempfile::tempdir().expect("tempdir"); + #[tokio::test] + async fn orphan_sweep_removes_dead_worlds_and_never_live_ones() { + // Worlds live in the eval-roots class (as a real run's do), so a kept world's marker is + // written through the class like production's. + continuum_kernel::system_resources::disk_reporters::prepare_writer_fixture().await; + let class = continuum_kernel::system_resources::disk_reporters::tracked_dir("eval-roots") + .expect("the fixture registers the eval-roots class"); + std::fs::create_dir_all(class.path()).expect("mkdir the eval-roots class"); + let parent = tempfile::tempdir_in(class.path()).expect("tempdir in the eval-roots class"); let live = parent.path().join("live-run"); let orphan = parent.path().join("orphan-run"); std::fs::create_dir_all(&live).expect("mkdir live"); diff --git a/core/continuum-academy/src/cognition/eval/warm_gate.rs b/core/continuum-academy/src/cognition/eval/warm_gate.rs index 7995ea34fc..bf4c667aab 100644 --- a/core/continuum-academy/src/cognition/eval/warm_gate.rs +++ b/core/continuum-academy/src/cognition/eval/warm_gate.rs @@ -33,7 +33,7 @@ pub(super) async fn warm_gate(cycle: &crate::cognition::workspace::WorkspaceCycl let probe = crate::cognition::act_observe::drive_to_settle( cycle, burst, - 0, // no acts — a bare deliberation is enough to prove the lane answers + crate::cognition::act_observe::TurnBudget::Steps(0), // no acts — a bare deliberation is enough to prove the lane answers crate::cognition::workspace::TurnFraming::directed(), ) .await; diff --git a/core/continuum-cognition/src/cognition/act_observe/settle/tests.rs b/core/continuum-cognition/src/cognition/act_observe/settle/tests.rs index 99eaa552d4..8337d81ee0 100644 --- a/core/continuum-cognition/src/cognition/act_observe/settle/tests.rs +++ b/core/continuum-cognition/src/cognition/act_observe/settle/tests.rs @@ -295,7 +295,7 @@ let settled = crate::cognition::act_observe::drive_to_settle_with_input( &cycle, Burst::raw_in(room, "a line".into()), - 8, + crate::cognition::act_observe::TurnBudget::Steps(8), TurnFraming::message(TurnAttention::default()), &mut conversation, ) diff --git a/core/continuum-cognition/src/cognition/act_observe/settle/tick_deadline.rs b/core/continuum-cognition/src/cognition/act_observe/settle/tick_deadline.rs index 46cf927916..94e1c2797f 100644 --- a/core/continuum-cognition/src/cognition/act_observe/settle/tick_deadline.rs +++ b/core/continuum-cognition/src/cognition/act_observe/settle/tick_deadline.rs @@ -251,10 +251,10 @@ impl PaceCadence { pub fn drive_to_settle( cycle: &WorkspaceCycle, burst: impl Into, - budget: impl Into, + budget: TurnBudget, framing: TurnFraming, ) -> impl std::future::Future + Send + '_ { - drive_with_input(cycle, burst.into(), budget.into(), framing, None, None) + drive_with_input(cycle, burst.into(), budget, framing, None, None) } /// The live driver leases its existing conversation between steps. No second @@ -262,11 +262,11 @@ pub fn drive_to_settle( pub fn drive_to_settle_with_input<'a>( cycle: &'a WorkspaceCycle, burst: Burst, - budget: impl Into, + budget: TurnBudget, framing: TurnFraming, conversation: &'a mut dyn crate::cognition::conversation::PersonaConversation, ) -> impl std::future::Future + Send + 'a { - drive_with_input(cycle, burst, budget.into(), framing, Some(conversation), None) + drive_with_input(cycle, burst, budget, framing, Some(conversation), None) } /// A live card-linked turn uses the same driver with its own credit capture. @@ -274,14 +274,14 @@ pub fn drive_to_settle_with_input<'a>( pub fn drive_to_settle_with_credit<'a>( cycle: &'a WorkspaceCycle, burst: Burst, - budget: impl Into, + budget: TurnBudget, framing: TurnFraming, conversation: &'a mut dyn crate::cognition::conversation::PersonaConversation, credit: Option<&'a mut dyn TurnCredit>, ) -> impl std::future::Future + Send + 'a { // Return the shared driver directly: an async forwarding wrapper needlessly // nests its state in every live/eval caller and inflates future layout depth. - drive_with_input(cycle, burst, budget.into(), framing, Some(conversation), credit) + drive_with_input(cycle, burst, budget, framing, Some(conversation), credit) } pub(super) async fn drive_with_input<'c>( diff --git a/core/continuum-cognition/src/cognition/act_observe/settle/turn_budget.rs b/core/continuum-cognition/src/cognition/act_observe/settle/turn_budget.rs index ab3eeb80dd..0181e59706 100644 --- a/core/continuum-cognition/src/cognition/act_observe/settle/turn_budget.rs +++ b/core/continuum-cognition/src/cognition/act_observe/settle/turn_budget.rs @@ -3,13 +3,17 @@ //! (`usize::MAX` was the live turn's sentinel, and a probe once read its remainder as //! 18446744073709551614). -/// A turn's step budget. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +/// A turn's step budget. On the wire a caller declares it: `"unbounded"` or `{"steps": n}`. +#[derive( + Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema, ts_rs::TS, +)] +#[serde(rename_all = "camelCase")] +#[ts(export, export_to = "../../../protocol/typescript/cognition/TurnBudget.ts")] pub enum TurnBudget { /// A live turn: she acts until she settles. Unbounded, /// A caller-bounded turn (an eval, a solve): at most this many steps. - Steps(usize), + Steps(#[ts(type = "number")] usize), } impl TurnBudget { @@ -39,9 +43,3 @@ impl TurnBudget { } } } - -impl From for TurnBudget { - fn from(steps: usize) -> Self { - Self::Steps(steps) - } -} diff --git a/core/continuum-cognition/src/cognition/act_observe/tests/credit.rs b/core/continuum-cognition/src/cognition/act_observe/tests/credit.rs index 145842b41e..045dff050e 100644 --- a/core/continuum-cognition/src/cognition/act_observe/tests/credit.rs +++ b/core/continuum-cognition/src/cognition/act_observe/tests/credit.rs @@ -152,7 +152,7 @@ async fn live_room_input_reaches_next_action_without_replacing_task_or_room() { ); let original_world = burst.rendered.clone(); let outcome = - drive_to_settle_with_input(&cycle, burst, 8, framing, &mut conversation).await; + drive_to_settle_with_input(&cycle, burst, crate::cognition::act_observe::TurnBudget::Steps(8), framing, &mut conversation).await; assert!( outcome.inference_error.is_none(), "{:?}", diff --git a/core/continuum-cognition/src/cognition/act_observe/tests/drive.rs b/core/continuum-cognition/src/cognition/act_observe/tests/drive.rs index 258b793958..6046309d9b 100644 --- a/core/continuum-cognition/src/cognition/act_observe/tests/drive.rs +++ b/core/continuum-cognition/src/cognition/act_observe/tests/drive.rs @@ -68,7 +68,7 @@ async fn drive_to_settle_acts_then_settles_on_speak() { let outcome = drive_to_settle( &cycle, "[eval]\npeer: what is 2+2?", - 8, + crate::cognition::act_observe::TurnBudget::Steps(8), TurnFraming::ambient(), ) .await; @@ -119,7 +119,7 @@ async fn acted_then_capacity_refused_retains_work_without_replay() { Arc::new(SalienceArbiter), ) .with_acting(body_with_wm(exec, admission(), wm)); - let outcome = drive_to_settle(&cycle, "perform the task", 8, TurnFraming::ambient()).await; + let outcome = drive_to_settle(&cycle, "perform the task", crate::cognition::act_observe::TurnBudget::Steps(8), TurnFraming::ambient()).await; assert_eq!(outcome.acts, 1); assert_eq!(outcome.turn_acts.len(), 1); assert_eq!(outcome.metrics.input_tokens, 700); @@ -162,7 +162,7 @@ async fn capacity_refusal_leaves_the_driver_once_with_typed_custody() { let faculty = Arc::new(Refusing(std::sync::atomic::AtomicUsize::new(0))); let cycle = WorkspaceCycle::new(vec![faculty.clone()], Arc::new(SalienceArbiter)); let outcome = - drive_to_settle(&cycle, "keep the complete input", 8, TurnFraming::ambient()).await; + drive_to_settle(&cycle, "keep the complete input", crate::cognition::act_observe::TurnBudget::Steps(8), TurnFraming::ambient()).await; assert_eq!(faculty.0.load(std::sync::atomic::Ordering::SeqCst), 1); assert!(outcome.inference_error.is_none()); assert!(outcome.deferred_before_dispatch); @@ -205,7 +205,7 @@ async fn a_zero_change_speak_reperceives_within_the_turns_step_budget_when_the_w let outcome = drive_to_settle( &cycle, "fix the bug in sympy/core/basic.py", - 8, + crate::cognition::act_observe::TurnBudget::Steps(8), TurnFraming::directed().on_workspace(), ) .await; @@ -255,7 +255,7 @@ async fn an_ordinary_turn_still_settles_on_the_first_speak() { .with_acting(body_with_wm(exec, admission(), Arc::clone(&wm))); let outcome = - drive_to_settle(&cycle, "what do you think?", 8, TurnFraming::directed()).await; + drive_to_settle(&cycle, "what do you think?", crate::cognition::act_observe::TurnBudget::Steps(8), TurnFraming::directed()).await; assert_eq!( speaker.generations(), @@ -330,7 +330,7 @@ async fn drive_to_settle_gates_discovery_at_half_budget_on_workspace_deliverable let outcome = drive_to_settle( &cycle, "fix the bug", - 20, + crate::cognition::act_observe::TurnBudget::Steps(20), TurnFraming::ambient().on_workspace(), ) .await; @@ -360,7 +360,7 @@ async fn drive_to_settle_gates_discovery_at_half_budget_on_workspace_deliverable Arc::new(SalienceArbiter), ) .with_acting(body(exec2, admission())); - let ambient = drive_to_settle(&cycle2, "look around", 20, TurnFraming::ambient()).await; + let ambient = drive_to_settle(&cycle2, "look around", crate::cognition::act_observe::TurnBudget::Steps(20), TurnFraming::ambient()).await; assert_eq!( ambient.acts, 20, "a non-workspace turn reads to the full budget — the gate scopes to \ @@ -393,7 +393,7 @@ async fn act_budget_facts_reach_working_memory_on_workspace_turns_only() { drive_to_settle( &cycle, "fix the bug", - 6, + crate::cognition::act_observe::TurnBudget::Steps(6), TurnFraming::ambient().on_workspace(), ) .await; @@ -430,7 +430,7 @@ async fn act_budget_facts_reach_working_memory_on_workspace_turns_only() { Arc::new(SalienceArbiter), ) .with_acting(body2); - drive_to_settle(&cycle2, "look around", 6, TurnFraming::ambient()).await; + drive_to_settle(&cycle2, "look around", crate::cognition::act_observe::TurnBudget::Steps(6), TurnFraming::ambient()).await; assert!( !wm2.recent_entries() .iter() @@ -453,7 +453,7 @@ async fn drive_to_settle_returns_unsettled_act_when_budget_exhausted() { let cycle = WorkspaceCycle::new(vec![Arc::new(AlwaysAct)], Arc::new(SalienceArbiter)) .with_acting(body(exec.clone(), adm.clone())); - let outcome = drive_to_settle(&cycle, "go", 2, TurnFraming::ambient()).await; + let outcome = drive_to_settle(&cycle, "go", crate::cognition::act_observe::TurnBudget::Steps(2), TurnFraming::ambient()).await; assert_eq!(outcome.acts, 2, "spent exactly the observer's budget"); assert!( @@ -488,7 +488,7 @@ async fn repeated_calls_respect_the_callers_budget() { let exec = Arc::new(ScriptedExecutor::new(results)); let cycle = WorkspaceCycle::new(vec![Arc::new(AlwaysAct)], Arc::new(SalienceArbiter)) .with_acting(body(exec.clone(), admission())); - let outcome = drive_to_settle(&cycle, "go", 6, TurnFraming::ambient()).await; + let outcome = drive_to_settle(&cycle, "go", crate::cognition::act_observe::TurnBudget::Steps(6), TurnFraming::ambient()).await; assert_eq!(outcome.acts, expected_acts); assert_eq!(exec.results.lock().unwrap().len(), 6 - expected_acts); assert!(matches!(outcome.decision, Decision::Act { .. })); @@ -505,8 +505,8 @@ async fn two_turns_in_one_room_are_two_turns() { let exec = Arc::new(RecordingExecutor { seen_context: Arc::new(Mutex::new(None)), result_content: "src/".into() }); let cycle = WorkspaceCycle::new(vec![Arc::clone(&speaker) as Arc], Arc::new(SalienceArbiter)) .with_acting(body_with_wm(exec, admission(), Arc::clone(&wm))); - let _ = drive_to_settle(&cycle, "first", 8, TurnFraming::ambient()).await; - let _ = drive_to_settle(&cycle, "second", 8, TurnFraming::ambient()).await; + let _ = drive_to_settle(&cycle, "first", crate::cognition::act_observe::TurnBudget::Steps(8), TurnFraming::ambient()).await; + let _ = drive_to_settle(&cycle, "second", crate::cognition::act_observe::TurnBudget::Steps(8), TurnFraming::ambient()).await; let steps = speaker.steps(); assert_eq!(steps.len(), 2, "one generation per ambient turn"); let (a, b) = (steps[0].expect("first turn's step"), steps[1].expect("second turn's step")); diff --git a/core/continuum-cognition/src/cognition/act_observe/tests/investigation.rs b/core/continuum-cognition/src/cognition/act_observe/tests/investigation.rs index 9c988f5e5a..62b1a4c8ff 100644 --- a/core/continuum-cognition/src/cognition/act_observe/tests/investigation.rs +++ b/core/continuum-cognition/src/cognition/act_observe/tests/investigation.rs @@ -113,7 +113,7 @@ async fn the_hands_change_the_mind_across_a_multi_act_investigation() { let outcome = drive_to_settle( &cycle, "[eval]\npeer: where does the program start and what does it call?", - 8, + crate::cognition::act_observe::TurnBudget::Steps(8), TurnFraming::ambient(), ) .await; @@ -274,7 +274,7 @@ async fn it_settles_then_re_awakens_without_cranking_to_a_halt() { let a = drive_to_settle( &cycle, "[eval]\npeer: concern A?", - 8, + crate::cognition::act_observe::TurnBudget::Steps(8), TurnFraming::ambient(), ) .await; @@ -286,7 +286,7 @@ async fn it_settles_then_re_awakens_without_cranking_to_a_halt() { let b = drive_to_settle( &cycle, "[eval]\npeer: a totally different concern B?", - 8, + crate::cognition::act_observe::TurnBudget::Steps(8), TurnFraming::ambient(), ) .await; diff --git a/core/continuum-core/src/test_env/mind_integration/training_credit/directed.rs b/core/continuum-core/src/test_env/mind_integration/training_credit/directed.rs index cd5d6b3de0..1602f6f359 100644 --- a/core/continuum-core/src/test_env/mind_integration/training_credit/directed.rs +++ b/core/continuum-core/src/test_env/mind_integration/training_credit/directed.rs @@ -105,7 +105,7 @@ async fn directed_credit_survives_partial_cancellation_and_atomic_retry() { let mut drive = Box::pin(drive_to_settle_with_credit( &cycle, "review first card".into(), - 8, + crate::cognition::act_observe::TurnBudget::Steps(8), TurnFraming::ambient(), &mut conversation, Some(&mut capture), diff --git a/core/continuum-kernel/src/system_resources/disk_reporters/class_writer.rs b/core/continuum-kernel/src/system_resources/disk_reporters/class_writer.rs index ebf8d9d828..7151f8963b 100644 --- a/core/continuum-kernel/src/system_resources/disk_reporters/class_writer.rs +++ b/core/continuum-kernel/src/system_resources/disk_reporters/class_writer.rs @@ -89,6 +89,21 @@ impl ClassWriter { Ok(owners) } + /// The files directly in this scope, by name (the flat-class mirror of `owners`), for a + /// reader that scans every file a class holds: each is read through `path`. A class nothing + /// has written yet has none. + pub fn files(&self) -> io::Result> { + let mut files = Vec::new(); + for entry in self.held()?.entries()? { + let entry = entry?; + if entry.file_type()?.is_file() { + files.push(PathBuf::from(entry.file_name())); + } + } + files.sort(); + Ok(files) + } + /// Where `relative` lives in this class, by name, for display and for readers outside this /// type: refused unless it is plain names. Writes never go through it; they go through the /// held directory. diff --git a/core/continuum-mind/src/persona/obligation/recover.rs b/core/continuum-mind/src/persona/obligation/recover.rs index bc4a92a83f..21b5f366e3 100644 --- a/core/continuum-mind/src/persona/obligation/recover.rs +++ b/core/continuum-mind/src/persona/obligation/recover.rs @@ -320,7 +320,7 @@ mod tests { "a new line in the room".into(), ); let framing = crate::cognition::workspace::TurnFraming::message(TurnAttention::default()); - let settled = drive_to_settle_with_input(&cycle, burst, 8, framing, &mut conversation).await; + let settled = drive_to_settle_with_input(&cycle, burst, crate::cognition::act_observe::TurnBudget::Steps(8), framing, &mut conversation).await; let (_, _, receipts) = SettleStep::from_settled(settled); let served: Vec = requests .lock() diff --git a/core/continuum-mind/src/persona/wake_backlog.rs b/core/continuum-mind/src/persona/wake_backlog.rs index 6b77a393d0..725a07ed5b 100644 --- a/core/continuum-mind/src/persona/wake_backlog.rs +++ b/core/continuum-mind/src/persona/wake_backlog.rs @@ -674,7 +674,7 @@ mod tests { ) }; let refused = - drive_to_settle_with_input(&cycle, burst(&original), 8, framing, &mut conversation).await; + drive_to_settle_with_input(&cycle, burst(&original), crate::cognition::act_observe::TurnBudget::Steps(8), framing, &mut conversation).await; assert!(refused.deferred_before_dispatch); assert_eq!(refused.acts, 0); assert!(exec.seen_context.lock().unwrap().is_none()); @@ -686,7 +686,7 @@ mod tests { // A second failed admission neither consumes nor replaces the original. let retried = pending.message().unwrap().clone(); - let refused_again = drive_to_settle_with_input(&cycle, burst(&retried), 8, framing, &mut conversation).await; + let refused_again = drive_to_settle_with_input(&cycle, burst(&retried), crate::cognition::act_observe::TurnBudget::Steps(8), framing, &mut conversation).await; let (step, _, _) = SettleStep::from_settled(refused_again); pending.settle(&retried, cause, framing.attention, &step); assert_eq!(pending.message(), Some(&original)); @@ -696,7 +696,7 @@ mod tests { let completed = drive_to_settle_with_input( &cycle, burst(pending.message().unwrap()), - 8, + crate::cognition::act_observe::TurnBudget::Steps(8), framing, &mut conversation, ) diff --git a/protocol/typescript/cognition/TurnBudget.ts b/protocol/typescript/cognition/TurnBudget.ts new file mode 100644 index 0000000000..7c5835309a --- /dev/null +++ b/protocol/typescript/cognition/TurnBudget.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * A turn's step budget. On the wire a caller declares it: `"unbounded"` or `{"steps": n}`. + */ +export type TurnBudget = "unbounded" | { "steps": number }; diff --git a/protocol/typescript/cognition/index.ts b/protocol/typescript/cognition/index.ts index 8b9d183707..677ae7a9eb 100644 --- a/protocol/typescript/cognition/index.ts +++ b/protocol/typescript/cognition/index.ts @@ -158,6 +158,7 @@ export type { ToolOutput } from './ToolOutput'; export type { ToolVerb } from './ToolVerb'; export type { TrackResponseParams } from './TrackResponseParams'; export type { TrackResponseResult } from './TrackResponseResult'; +export type { TurnBudget } from './TurnBudget'; export type { ValidateResponseDecision } from './ValidateResponseDecision'; export type { ValidateResponseRequest } from './ValidateResponseRequest'; export type { VisionDescribeOptions } from './VisionDescribeOptions'; diff --git a/tools/scripts/harness/cognition-cycle.sh b/tools/scripts/harness/cognition-cycle.sh index fae11846e8..bc1939e239 100755 --- a/tools/scripts/harness/cognition-cycle.sh +++ b/tools/scripts/harness/cognition-cycle.sh @@ -140,9 +140,11 @@ RUN_DIR="$HOME/.continuum/harness-runs/$STAMP-${PNAME}" EVAL_ARGS=(cognition/eval --persona_id "$PID" --eval_set "$EVAL_PATH") [[ -n "$NOTE" ]] && EVAL_ARGS+=(--note "$NOTE") [[ -n "$GENE" ]] && EVAL_ARGS+=(--gene "$GENE") -[[ -n "$MAX_ACTS" ]] && EVAL_ARGS+=(--max_acts "$MAX_ACTS") +# The eval's policy is part of what it measures, so the caller always declares it. This +# harness declares the bounds its earlier runs were measured under unless told otherwise. +EVAL_ARGS+=(--budget "{\"steps\":${MAX_ACTS:-32}}" --max_retries "${MAX_RETRIES:-3}") -echo "harness: persona=$PNAME ($PID) eval_set=$EVAL_SET note='${NOTE:-}'" +echo "harness: persona=$PNAME ($PID) eval_set=$EVAL_SET note='${NOTE:-}' budget=${MAX_ACTS:-32} steps retries=${MAX_RETRIES:-3}" echo "harness: report → $RUN_DIR" echo "harness: command → $CU ${EVAL_ARGS[*]}"