Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions core/continuum-academy/src/cognition/eval/cognition_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
Expand Down
31 changes: 0 additions & 31 deletions core/continuum-academy/src/cognition/eval/default_eval_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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=<ms>] peer: …`). The
/// live burst carries each message's real `occurred_at_ms`; the eval pins it to
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions core/continuum-academy/src/cognition/eval/eval_settle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions core/continuum-academy/src/cognition/eval/eval_task_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
99 changes: 36 additions & 63 deletions core/continuum-academy/src/cognition/eval/format_exam_lesson.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<std::path::PathBuf> {
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> {
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<serde_json::Value> {
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)
}
Expand All @@ -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<serde_json::Value> {
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);
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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(),
Expand All @@ -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(
Expand All @@ -619,18 +612,14 @@ pub(super) fn append_progress_ledger(
eval_set: &str,
clean_lane: Option<bool>,
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,
Expand Down Expand Up @@ -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::<String>());
t["answerHead"] = serde_json::json!(r.answer.chars().take(LEDGER_FAIL_ANSWER_CHARS).collect::<String>());
t["grade"] = serde_json::json!(r.grade);
t["answerHead"] = serde_json::json!(r.answer);
}
t
}).collect::<Vec<_>>(),
});
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
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion core/continuum-academy/src/cognition/eval/gene_exam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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 }),
Expand Down
Loading
Loading