diff --git a/crates/mind-body/src/bin/mind-self-run.rs b/crates/mind-body/src/bin/mind-self-run.rs
index 3a1e9b8..52322cf 100644
--- a/crates/mind-body/src/bin/mind-self-run.rs
+++ b/crates/mind-body/src/bin/mind-self-run.rs
@@ -1,8 +1,3 @@
-//! `mind-self-run inject --spool
[--pre-compact]` is the hook `claude` runs
-//! inside the session: it prints the briefs waiting in the spool as context for
-//! the next request, and with `--pre-compact` blocks an auto-compaction (exit 2).
-//! It reads the hook's JSON on stdin and the spool, nothing else.
-//!
//! `mind-self-run --instance [--endpoint rudp://:]`: carries
//! her one open Self run (`mind_body::self_run::carry`) inside
//! `mind-self@`. This reads the process's arguments and environment,
@@ -18,8 +13,6 @@
//! The connector's lease socket is `CLAUDE_LEASE_SOCKET`: the token itself is
//! never in this process's environment, only the descriptor the lease grants.
-use std::io::Read;
-use std::path::PathBuf;
use std::time::Duration;
use anyhow::{Result, anyhow};
@@ -28,7 +21,6 @@ use mind_body::cli::instance_and_endpoint;
use mind_body::launch::SystemClock;
use mind_body::lease_client::{LEASE_SOCKET_VARIABLE, SocketLender};
use mind_body::queue::HuginnMind;
-use mind_body::self_run::inbox::inject;
use mind_body::self_run::{ClaudeSpawner, RUN_CAP_VARIABLE, carry};
/// How long one call to the mind may take.
@@ -41,9 +33,6 @@ const USAGE: &str = "usage: mind-self-run --instance [--endpoint rudp://<
#[allow(clippy::disallowed_methods, reason = "the binary reads its own arguments and environment, and hands them to the library")]
fn run() -> Result {
let args: Vec = std::env::args().skip(1).collect();
- if args.first().map(String::as_str) == Some("inject") {
- return hook(&args[1..]);
- }
let (instance, address) = instance_and_endpoint(&args, std::env::var("HUGINN_ENDPOINT").ok(), USAGE)?;
let socket = std::env::var_os(LEASE_SOCKET_VARIABLE).ok_or_else(|| anyhow!("{LEASE_SOCKET_VARIABLE} is not set"))?;
let run_cap_s: u64 = std::env::var(RUN_CAP_VARIABLE)
@@ -52,24 +41,11 @@ fn run() -> Result {
.filter(|seconds| *seconds > 0)
.ok_or_else(|| anyhow!("{RUN_CAP_VARIABLE} is not set to the unit's RuntimeMaxSec in seconds"))?;
let mind = HuginnMind::new(HuginnClient::new(address, instance, TIMEOUT));
- let outcome = carry(&mind, &SystemClock, &SocketLender::new(socket), &ClaudeSpawner::new(std::env::vars_os(), std::env::current_exe()?)?, run_cap_s, &mut std::io::stdout())?;
+ let outcome = carry(&mind, &SystemClock, &SocketLender::new(socket), &ClaudeSpawner::new(std::env::vars_os())?, run_cap_s, &mut std::io::stdout())?;
println!("{outcome}");
Ok(outcome.exit_status())
}
-/// The hook: the spool named by `--spool`, the hook's input on stdin.
-fn hook(args: &[String]) -> Result {
- let spool = args.iter().position(|arg| arg == "--spool").and_then(|at| args.get(at + 1)).map(PathBuf::from).ok_or_else(|| anyhow!("inject needs --spool "))?;
- let mut input = String::new();
- std::io::stdin().read_to_string(&mut input)?;
- let injection = inject(&spool, &input, args.iter().any(|arg| arg == "--pre-compact"))?;
- if injection.exit == 2 {
- eprintln!("compaction blocked: the actuator asks for the flush");
- }
- print!("{}", injection.stdout);
- Ok(injection.exit)
-}
-
fn main() {
match run() {
Ok(status) => std::process::exit(status),
diff --git a/crates/mind-body/src/self_run.rs b/crates/mind-body/src/self_run.rs
index a11ebcd..bcdaf67 100644
--- a/crates/mind-body/src/self_run.rs
+++ b/crates/mind-body/src/self_run.rs
@@ -14,12 +14,17 @@
//!
//! One run is one live session (ruling `eureka-body:ruling:live-mind-sessions`).
//! A result ends a turn, not the session. What her Self is asked is derived from
-//! her mind (the `inbox` module): an open follow-up with owner `self-run` is a
-//! brief not yet answered. The actuator polls for briefs and tells them to the
-//! session, between tool calls through the PostToolBatch hook and between turns
-//! as a user line; a result closes every brief told to that turn. The session
-//! ends where its cache would be evicted, near the unit's cap, at the context
-//! ceiling, or after the flush each of those asks.
+//! her mind (the `inbox` module): an open follow-up with owner `self-run` sourced
+//! from a Persona turn is a brief. `drive` is the one writer into her session: the
+//! start message, every tell and the flush are stdin lines, a tell written whenever
+//! a brief waits and the flush has not been written, mid-turn or idle. The CLI
+//! echoes each line it takes into a request (`--replay-user-messages`); the echo is
+//! the consumption point, folded or queued, and idle is derived from the lines
+//! written and the lines echoed. Her Self resolves each brief she answers; the
+//! actuator closes only what she left open at an idle end. Compaction is off in
+//! the CLI (`DISABLE_COMPACT=1`): the organ's own ceiling, flush, end and rehydrate
+//! is the only path. The session ends where its cache would be evicted, near the
+//! unit's cap, at the context ceiling, or after the flush each of those asks.
//!
//! Every timing decision is one pure function, `decide` (the `decide` module,
//! ruling `eureka-body:ruling:self-run-decider`). `carry` is the loop that turns
@@ -46,7 +51,7 @@
//! foreign owner's JSON: it is parsed into `serde_json::Value` here and nothing
//! parsed is stored.
-use std::collections::VecDeque;
+use std::collections::{HashSet, VecDeque};
use std::ffi::{OsStr, OsString};
use std::fmt;
use std::io::{BufRead, BufReader, Write};
@@ -69,8 +74,8 @@ use crate::lease_client::{LeaseRefusalKind, LeaseRequest, Lender, Lent, TokenFd}
use model_connector::PlanQuota;
use crate::queue::MindPort;
-use decide::{Action, Event, State, decide, next_deadline};
-use inbox::{Brief, Hooks};
+use decide::{Action, Event, State, Why, decide, next_deadline};
+use inbox::Brief;
/// The measured Self ceiling: at this prefix the flush is asked for.
pub const CEILING_TOKENS: u64 = 300_000;
@@ -84,10 +89,11 @@ pub const ESCALATE_AFTER_S: i64 = 120;
/// How long a stream may stay open after the child has exited (a descendant
/// holding its stdout) before the run is over without it.
pub const EXIT_DRAIN_S: i64 = 2;
-/// How long before the unit's cap an idle session is closed for rotation.
-pub const ROTATE_MARGIN_S: i64 = 20 * 60;
-/// How long before the unit's cap a working session is asked for its flush.
-pub const FLUSH_MARGIN_S: i64 = 10 * 60;
+/// How long before the unit's cap the session is asked for its flush, idle or working.
+pub const ROTATE_MARGIN_S: i64 = 25 * 60;
+/// The signal ladder's length: three escalations, the stream drain and a minute of slack. The grace interrupt is never later than the cap less this.
+pub const LADDER_S: i64 = 3 * ESCALATE_AFTER_S + EXIT_DRAIN_S + 60;
+const _: () = assert!(FLUSH_GRACE_S + LADDER_S < ROTATE_MARGIN_S, "the flush and the whole ladder must finish before the unit's cap");
/// How often the mind is asked for new briefs.
pub const INBOX_POLL_S: i64 = 30;
/// The prompt cache's lifetimes, and how long before one runs out the session ends.
@@ -110,6 +116,8 @@ pub const SCRATCH_VARIABLE: &str = "RUNTIME_DIRECTORY";
pub const SEED_VARIABLE: &str = "MIND_SELF_CONFIG_SEED";
/// Names the descriptor the child reads its credential from.
const TOKEN_FD_VARIABLE: &str = "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR";
+/// Turns off the CLI's compaction, auto, idle and manual: the mind is the one summary.
+const DISABLE_COMPACT_VARIABLE: &str = "DISABLE_COMPACT";
/// Tells `claude` to scrub credentials from the environment of what it starts.
const ENV_SCRUB_VARIABLE: &str = "CLAUDE_CODE_SUBPROCESS_ENV_SCRUB";
/// Optional, set by the unit: `off` turns that scrub off for a run whose user holds root, where it
@@ -127,7 +135,7 @@ const POLL: StdDuration = StdDuration::from_secs(INBOX_POLL_S as u64);
/// skill: it names the skill, the instance and the run id.
pub fn start_message(instance: &Slug, run: &PipelineRef, plan_quota: &[PlanQuota], now_ms: u64) -> String {
format!(
- "Use the eureka skill. You are Self for the instance `{}`; your run is `{}`. Admit as faculty SelfFaculty, agent {AGENT}.\n\nThis session stays open after you answer: briefs from your Persona arrive while you work and between tasks, and each answer you give closes the brief it answers. Work you take on beyond an answer is a follow-up of your own.\n\n{}",
+ "Use the eureka skill. You are Self for the instance `{}`; your run is `{}`. Admit as faculty SelfFaculty, agent {AGENT}.\n\nThis session stays open after you answer: briefs from your Persona arrive while you work and between tasks. When you answer a brief, resolve follow-up Recorded with your answer as rationale; if you decline it, resolve it Withdrawn with why. Work you take on beyond an answer is a follow-up of your own.\n\n{}",
instance.0,
run.id.0,
render_plan(plan_quota, now_ms)
@@ -171,26 +179,38 @@ The run claims `{id}`, which the mind does not hold: its task is unknown.")),
Ok(task)
}
-/// What the child is told once, at the context ceiling.
+/// What the child is told once, when its session must end: the ceiling, the cap or the cache.
pub const FLUSH_MESSAGE: &str = "The context ceiling is reached. Admit to the mind what it lacks, close your run, and end.";
+/// The flush as written: the one message, and what she does with the briefs she holds.
+fn flush_text(why: Why) -> String {
+ let cause = match why {
+ Why::Ceiling => "",
+ Why::Rotation => " (This session ends soon: the unit's time is nearly up.)",
+ Why::Idle => " (This session ends because nothing is waiting and its cache would lapse.)",
+ };
+ format!("{FLUSH_MESSAGE}{cause} Resolve each brief you answered (Recorded, your answer as rationale); a brief you are still working stays open and the next session continues it.")
+}
+
/// The session id of a run: UUIDv5 over the run's id. Derived, never stored.
pub fn session_id(run: &PipelineRef) -> Uuid {
Uuid::new_v5(&SESSION_NAMESPACE, run.id.0.as_bytes())
}
/// The argument list of the child, and nothing else: no resume, continue or
-/// fork, no model and no settings of its own belong to this actuator, except the
-/// hooks the actuator builds on its own argv (`--settings`, never a file in her
-/// sandbox): the tell between tool calls and the block on auto-compaction. It fixes
-/// the permission mode: print mode starts in Manual when nothing on the command
+/// fork, no model, no settings and no hooks belong to this actuator. It asks the
+/// CLI to echo each stdin line it takes into a request (`--replay-user-messages`),
+/// which is how delivery is counted. It fixes the permission mode: print mode starts in Manual when nothing on the command
/// line sets a mode (the managed `defaultMode` was not applied in print mode,
/// 2026-10-31), and `--permission-prompts none` then denies every tool that
-/// needs approval, so a Mind's reach within her slice is granted here. Only the
+/// needs approval, so a Mind's reach within her slice is granted here, but
+/// with `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB` set the CLI forces the mode to
+/// default (probe, claude 2.1.312): the flag has no effect there and only the
+/// seed's allow list decides tools. Only the
/// user's settings load (the fresh configuration directory
/// the seed fills); the working directory's project and local settings, which a
/// run could have written, do not.
-pub fn claude_args(session: Uuid, hooks: &Hooks) -> Vec {
+pub fn claude_args(session: Uuid) -> Vec {
[
"-p",
"--input-format",
@@ -208,8 +228,7 @@ pub fn claude_args(session: Uuid, hooks: &Hooks) -> Vec {
"none",
"--setting-sources",
"user",
- "--settings",
- &hooks.settings(),
+ "--replay-user-messages",
]
.map(String::from)
.to_vec()
@@ -221,7 +240,10 @@ pub enum Usage {
/// A request of the main thread: the message's id and the context it
/// read (input, cache read and cache write tokens).
Request { id: String, prefix: u64 },
- Result,
+ /// A user line of the main thread that the CLI took into a request (a replay echo): ours, never a tool result.
+ Echo,
+ /// A turn ended. `ok`: not an error. `blocked`: the CLI refused the context (`blocking_limit`).
+ Result { ok: bool, blocked: bool },
/// Valid JSON that is none of the above, or a request of a subagent.
Other,
/// Not a JSON object.
@@ -244,7 +266,17 @@ pub fn writes_hour_cache(line: &str) -> Option {
pub fn read_usage(line: &str) -> Usage {
let Ok(Value::Object(event)) = serde_json::from_str::(line) else { return Usage::Unreadable };
match event.get("type").and_then(Value::as_str) {
- Some("result") => Usage::Result,
+ Some("result") => Usage::Result {
+ ok: !event.get("is_error").and_then(Value::as_bool).unwrap_or(false),
+ blocked: event.get("terminal_reason").and_then(Value::as_str) == Some("blocking_limit"),
+ },
+ Some("user")
+ if event.get("isReplay").and_then(Value::as_bool) == Some(true)
+ && event.get("parent_tool_use_id").is_none_or(Value::is_null)
+ && event.get("message").and_then(|message| message.get("content")).is_some_and(Value::is_string) =>
+ {
+ Usage::Echo
+ }
Some("assistant") if event.get("parent_tool_use_id").is_none_or(Value::is_null) => {
let message = event.get("message");
let Some(id) = message.and_then(|message| message.get("id")).and_then(Value::as_str) else { return Usage::Other };
@@ -300,8 +332,6 @@ impl Stop {
}
pub trait Spawner {
- /// The spool the child's hooks drain and the program they run.
- fn hooks(&self) -> Hooks;
/// Starts the child with `token` as its credential descriptor.
fn spawn(&self, args: &[String], token: &TokenFd) -> Result>;
}
@@ -382,15 +412,23 @@ fn her_run(mind: &dyn MindPort) -> Result)
/// What the stream said at the end of the run: its head becomes the closure's reason, its text (bounded) the rationale.
#[derive(Default)]
struct Heard {
- /// The last result heard: its head line and its text cut to `RATIONALE_RESULT_LIMIT`.
+ /// The last result heard, ok or not: its head line and its text cut to `RATIONALE_RESULT_LIMIT`.
concluded: Option<(String, String)>,
+ /// The text of the last ok result: what an idle end records as her answer.
+ answer: Option,
+ /// The idle flush was answered by an ok result.
+ idle_end: bool,
}
impl Heard {
fn hear(&mut self, line: &str) {
let Ok(Value::Object(event)) = serde_json::from_str::(line) else { return };
if event.get("type").and_then(Value::as_str) == Some("result") {
- self.concluded = Some((result_head(&event), cut_text(result_text(&event), RATIONALE_RESULT_LIMIT)));
+ let text = cut_text(result_text(&event), RATIONALE_RESULT_LIMIT);
+ if !event.get("is_error").and_then(Value::as_bool).unwrap_or(false) {
+ self.answer = Some(text.clone());
+ }
+ self.concluded = Some((result_head(&event), text));
}
}
}
@@ -469,25 +507,24 @@ fn withdraw_misconfigured(mind: &dyn MindPort, clock: &dyn Clock, run: &Pipeline
/// error, and the launch that opens the next run closes the run left open.
pub fn carry(mind: &dyn MindPort, clock: &dyn Clock, lender: &dyn Lender, spawner: &dyn Spawner, run_cap_s: u64, out: &mut dyn Write) -> Result {
let Some((run, claims)) = her_run(mind)? else { return Ok(SelfRunOutcome::NoRun) };
- let hooks = spawner.hooks();
- // The briefs a closed run claimed were answered by that run: closed now, before anything is told.
- inbox::reset(&hooks.spool)?;
- inbox::close_past(mind, clock.now(), session_label(&run))?;
let mut task = task_section(mind, &claims)?;
- let open = inbox::derive(mind, &hooks.spool)?;
- let also: Vec<&Brief> = open.iter().filter(|brief| !claims.iter().any(|claim| claim.id.0 == brief.id)).collect();
+ let mut told: Vec = inbox::derive(mind, &HashSet::new())?;
+ let also: Vec<&Brief> = told.iter().filter(|brief| !claims.iter().any(|claim| claim.id.0 == brief.id)).collect();
if !also.is_empty() {
task.push_str("
Also open for you:");
for brief in also {
task.push_str(&format!("
-- follow-up `{}` (campaign `{}`, repo `{}`): {}", brief.id, brief.campaign, brief.repo, brief.item));
+- follow-up `{}` (campaign `{}`, repo `{}`): {} {}", brief.id, brief.campaign, brief.repo, brief.item, inbox::resolving_sentence(&brief.id)));
}
}
- inbox::mark_told(&hooks.spool, &open)?;
let mut heard = Heard::default();
- let ran = lend_and_drive(mind, clock, lender, spawner, run_cap_s, out, (&run, &task), &mut heard);
+ let ran = lend_and_drive(mind, clock, lender, spawner, run_cap_s, out, (&run, &task), &mut told, &mut heard);
+ // An idle end answered by an ok result: what she left open is closed, saying so. After a rotation, a ceiling, an error or a crash the told briefs stay open for the successor.
+ if heard.idle_end && ran.is_ok() {
+ close_left_open(mind, clock, &run, &told, &heard, out);
+ }
let closed = close_if_open(mind, clock, &run, &ran, &heard);
if closed.is_err() {
let _ = writeln!(out, "the run could not be closed: the next launch closes it");
@@ -500,7 +537,7 @@ Also open for you:");
}
#[allow(clippy::too_many_arguments, reason = "carry's ports, passed on whole")]
-fn lend_and_drive(mind: &dyn MindPort, clock: &dyn Clock, lender: &dyn Lender, spawner: &dyn Spawner, run_cap_s: u64, out: &mut dyn Write, (run, task): (&PipelineRef, &str), heard: &mut Heard) -> Result {
+fn lend_and_drive(mind: &dyn MindPort, clock: &dyn Clock, lender: &dyn Lender, spawner: &dyn Spawner, run_cap_s: u64, out: &mut dyn Write, (run, task): (&PipelineRef, &str), told: &mut Vec, heard: &mut Heard) -> Result {
let started_ms = unix_ms(clock.now());
let request = LeaseRequest { expires_at_unix_ms: started_ms.saturating_add(run_cap_s.saturating_mul(1000)) };
let lease = match lender.lend(&request)? {
@@ -511,9 +548,8 @@ fn lend_and_drive(mind: &dyn MindPort, clock: &dyn Clock, lender: &dyn Lender, s
}
Lent::Refused(refused) => return close_refused(mind, clock, run, refused.kind),
};
- let hooks = spawner.hooks();
- let child = spawner.spawn(&claude_args(session_id(run), &hooks), lease.token())?;
- drive(mind, clock, child, &hooks, (run, task), (lease.plan_quota(), started_ms, run_cap_s), heard, out)
+ let child = spawner.spawn(&claude_args(session_id(run)), lease.token())?;
+ drive(mind, clock, child, (run, task), (lease.plan_quota(), started_ms, run_cap_s), told, heard, out)
}
/// The most of a result's text that reaches the journal.
@@ -563,51 +599,43 @@ fn write_result(line: &str, out: &mut dyn Write) -> std::io::Result<()> {
writeln!(out, "{}", describe_result(&event, RESULT_TEXT_LIMIT))
}
-/// What a brief's closing resolution says when the result had no text.
+/// What a brief's closing resolution says when her last answer had no text.
const NO_ANSWER_TEXT: &str = "The turn ended with no answer text.";
-/// Resolves Recorded every brief told to the session that this result answers.
-/// A failed close leaves them told: the next result tries again.
-fn close_told(mind: &dyn MindPort, clock: &dyn Clock, hooks: &Hooks, session: &str, heard: &Heard, out: &mut dyn Write) -> Result {
- let rationale = heard.concluded.as_ref().map(|(_, text)| text.as_str()).filter(|text| !text.is_empty()).unwrap_or(NO_ANSWER_TEXT);
- let closed = inbox::told(&hooks.spool).and_then(|told| {
- let answered: Vec<(Brief, String)> = told.iter().map(|brief| (brief.clone(), rationale.to_string())).collect();
- let count = inbox::close(mind, clock.now(), session, &answered, "answered by the turn's result")?;
- inbox::forget(&hooks.spool, &told);
- Ok(count)
- });
- match closed {
- Ok(count) => Ok(count),
- Err(_) => {
- writeln!(out, "briefs could not be closed: the next result tries again")?;
- Ok(0)
- }
+/// At an idle end: resolves Recorded the told briefs she left in force, the last ok result's text as the rationale. One try; a failure is logged and the briefs stay open for the successor.
+fn close_left_open(mind: &dyn MindPort, clock: &dyn Clock, run: &PipelineRef, told: &[Brief], heard: &Heard, out: &mut dyn Write) {
+ let rationale = heard.answer.as_deref().filter(|text| !text.is_empty()).unwrap_or(NO_ANSWER_TEXT);
+ let label = session_label(run);
+ let reason = format!("told to Self run {label}; the session went idle and ended without her resolving it");
+ let answered: Vec<(Brief, String)> = told.iter().map(|brief| (brief.clone(), rationale.to_string())).collect();
+ if inbox::close(mind, clock.now(), label, &answered, &reason).is_err() {
+ let _ = writeln!(out, "briefs could not be closed: they stay open for the next session");
}
}
-/// The loop: facts in, one clock read per fact, actions out.
+/// The loop: facts in, one clock read per fact, actions out. The one writer into her session.
#[allow(clippy::too_many_arguments, reason = "the loop's ports and the run's facts, passed on whole")]
fn drive(
mind: &dyn MindPort,
clock: &dyn Clock,
mut child: Box,
- hooks: &Hooks,
(run, task): (&PipelineRef, &str),
(plan_quota, now_ms, run_cap_s): (&[PlanQuota], u64, u64),
+ told: &mut Vec,
heard: &mut Heard,
out: &mut dyn Write,
) -> Result {
let user_line = |text: &str| json!({"type": "user", "message": {"role": "user", "content": text}}).to_string();
let plan = render_plan(plan_quota, now_ms);
- inbox::write_plan(&hooks.spool, &plan)?;
child.write_line(&user_line(&format!("{}{task}", start_message(mind.instance(), run, plan_quota, now_ms))));
- let session = session_label(run);
let mut now = clock.now();
let mut state = State::started(now, run_cap_s);
let mut polled = now;
let mut ttl_1h = false;
let mut closed = false;
+ // The briefs derived at the last poll that no line has carried yet.
+ let mut waiting: Vec = Vec::new();
loop {
let poll_due = polled + ChronoDuration::seconds(INBOX_POLL_S);
let wake = next_deadline(&state).into_iter().chain((!closed).then_some(poll_due)).min();
@@ -621,7 +649,8 @@ fn drive(
}
match read_usage(&line) {
Usage::Request { id, prefix } => Event::Request { id, prefix },
- Usage::Result => Event::Result { ttl_1h },
+ Usage::Echo => Event::Echo,
+ Usage::Result { ok, blocked } => Event::Result { ok, blocked, ttl_1h },
Usage::Other | Usage::Unreadable => Event::Tick,
}
}
@@ -633,42 +662,31 @@ fn drive(
let mut events = VecDeque::from([fact]);
if !closed && now >= poll_due {
polled = now;
- match inbox::derive(mind, &hooks.spool).and_then(|briefs| inbox::spool(&hooks.spool, &briefs)).and_then(|()| inbox::pending(&hooks.spool)) {
- Ok(pending) => events.push_back(Event::Inbox { pending }),
+ let held: HashSet = told.iter().map(|brief| brief.id.clone()).collect();
+ match inbox::derive(mind, &held) {
+ Ok(briefs) => {
+ events.push_back(Event::Inbox { pending: !briefs.is_empty() });
+ waiting = briefs;
+ }
Err(_) => writeln!(out, "inbox poll failed")?,
}
}
- if inbox::take_pre_compact(&hooks.spool) {
- events.push_back(Event::PreCompact);
- }
while let Some(heard_event) = events.pop_front() {
let counted = state.requests;
// The decision's inputs, as they stood when the event came.
let (ttl_s, inbox, idle_s) = (state.ttl_s, state.inbox, state.idle_s(now));
let (next, action) = decide(state, heard_event, now);
state = next;
+ heard.idle_end = state.idle_end_answered();
if state.requests != counted {
writeln!(out, "request {} prefix {}", state.requests, state.prefix)?;
}
- let mut briefs_closed = 0;
match &action {
Action::None => {}
- Action::WriteFlush => child.write_line(&user_line(FLUSH_MESSAGE)),
- Action::WriteTells => match inbox::claim(&hooks.spool) {
- Ok(briefs) if !briefs.is_empty() => {
- child.write_line(&user_line(&inbox::render(&briefs, &plan)));
- events.push_front(Event::Told);
- }
- Ok(_) => events.push_front(Event::Inbox { pending: false }),
- Err(_) => {
- writeln!(out, "inbox claim failed")?;
- events.push_front(Event::Inbox { pending: false });
- }
- },
- Action::CloseBriefs => {
- briefs_closed = close_told(mind, clock, hooks, session, heard, out)?;
- // The result's own pass goes on to the lifecycle: a waiting brief is told, a finished flush closes the input.
- events.push_front(Event::Tick);
+ Action::WriteFlush(why) => child.write_line(&user_line(&flush_text(*why))),
+ Action::WriteTells => {
+ child.write_line(&user_line(&inbox::render(&waiting, &plan)));
+ told.append(&mut waiting);
}
Action::CloseStdin => {
child.close_input();
@@ -679,7 +697,7 @@ fn drive(
}
if !matches!(action, Action::None | Action::Finish(_)) {
let idle = idle_s.map_or_else(|| "working".to_string(), |seconds| seconds.to_string());
- writeln!(out, "decision {action:?} prefix {} ttl_s {ttl_s} idle_s {idle} inbox {inbox} briefs_closed {briefs_closed}", state.prefix)?;
+ writeln!(out, "decision {action:?} prefix {} ttl_s {ttl_s} idle_s {idle} inbox {inbox} written {} consumed {}", state.prefix, state.written, state.consumed)?;
}
if let Action::Finish(outcome) = action {
return Ok(outcome);
@@ -697,31 +715,21 @@ pub struct ClaudeSpawner {
unit_environment: Vec<(OsString, OsString)>,
scratch: PathBuf,
seed: Option,
- /// The program the child's hooks run: this actuator's own binary.
- injector: PathBuf,
}
impl ClaudeSpawner {
/// From the unit's environment: it must name [`SCRATCH_VARIABLE`], and may name [`SEED_VARIABLE`].
- /// `injector` is the absolute path of `mind-self-run`, which the hooks run as `inject`.
- pub fn new(unit_environment: impl IntoIterator- , injector: PathBuf) -> Result
{
+ pub fn new(unit_environment: impl IntoIterator- ) -> Result
{
let unit_environment: Vec<(OsString, OsString)> = unit_environment.into_iter().collect();
let named = |variable: &str| unit_environment.iter().find(|(name, _)| name == variable).map(|(_, value)| PathBuf::from(value));
// systemd lists several runtime directories colon-separated; the unit names one.
let scratch = named(SCRATCH_VARIABLE).filter(|path| !path.as_os_str().is_empty()).ok_or_else(|| anyhow!("{SCRATCH_VARIABLE} is not set: the unit needs RuntimeDirectory="))?;
let seed = named(SEED_VARIABLE).filter(|path| !path.as_os_str().is_empty());
- Ok(Self { unit_environment, scratch, seed, injector })
+ Ok(Self { unit_environment, scratch, seed })
}
}
-/// The directory name of the spool inside the scratch directory.
-const SPOOL_DIR_NAME: &str = "inbox";
-
impl Spawner for ClaudeSpawner {
- fn hooks(&self) -> Hooks {
- Hooks { spool: self.scratch.join(SPOOL_DIR_NAME), injector: self.injector.clone() }
- }
-
fn spawn(&self, args: &[String], token: &TokenFd) -> Result> {
let config = FreshConfig::create(&self.scratch, self.seed.as_deref())?;
spawn_program(Path::new("claude"), args, token, &self.unit_environment, config)
@@ -863,7 +871,7 @@ fn spawn_program(program: &Path, args: &[String], token: &TokenFd, unit: &[(OsSt
command.args(args).stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::inherit());
command.env_clear().envs(child_environment(unit));
command.env("HOME", &config.0).env(CONFIG_DIR_VARIABLE, &config.0);
- command.env(TOKEN_FD_VARIABLE, inheritable.number().to_string()).env(ENV_SCRUB_VARIABLE, if scrub_is_off(unit) { "0" } else { "1" });
+ command.env(DISABLE_COMPACT_VARIABLE, "1").env(TOKEN_FD_VARIABLE, inheritable.number().to_string()).env(ENV_SCRUB_VARIABLE, if scrub_is_off(unit) { "0" } else { "1" });
// Its own process group, so that a signal reaches what the child started too.
#[cfg(unix)]
std::os::unix::process::CommandExt::process_group(&mut command, 0);
diff --git a/crates/mind-body/src/self_run/claude-2.1.312-live-session-api-error-first-scrub.jsonl b/crates/mind-body/src/self_run/claude-2.1.312-live-session-api-error-first-scrub.jsonl
new file mode 100644
index 0000000..3cd50f8
--- /dev/null
+++ b/crates/mind-body/src/self_run/claude-2.1.312-live-session-api-error-first-scrub.jsonl
@@ -0,0 +1,6 @@
+{"t": 0.0, "sent": "APIERROR turn."}
+{"t": 0.57, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"16afc4bb-d205-4268-b826-22a8c9c11d49\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"default\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"996eca5a-63c5-420e-b574-f39e752426a6\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2505058.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.88, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"APIERROR turn.\"},\"session_id\":\"16afc4bb-d205-4268-b826-22a8c9c11d49\",\"parent_tool_use_id\":null,\"uuid\":\"a7103a52-e487-4e58-a1ee-7108d5963c13\",\"timestamp\":\"2026-10-31T17:34:08.994Z\",\"isReplay\":true}"}
+{"t": 0.88, "line": "{\"type\":\"assistant\",\"message\":{\"diagnostics\":null,\"id\":\"f9e4a2e8-a4a8-4b8e-8e5f-8bd7d5d6fbd4\",\"container\":null,\"model\":\"\",\"role\":\"assistant\",\"stop_details\":null,\"stop_reason\":\"stop_sequence\",\"stop_sequence\":\"\",\"type\":\"message\",\"usage\":{\"output_tokens_details\":null,\"input_tokens\":0,\"output_tokens\":0,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":null,\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":null,\"iterations\":null,\"speed\":null,\"fallback_credit\":null},\"content\":[{\"type\":\"text\",\"text\":\"API Error: 400 probe: bad request\"}],\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"16afc4bb-d205-4268-b826-22a8c9c11d49\",\"uuid\":\"2114ac02-0532-4ede-aacd-b1e9b003b01d\",\"timestamp\":\"2026-10-31T17:34:09.321Z\",\"error\":\"unknown\",\"is_api_error_message\":true,\"api_error_status\":400}"}
+{"t": 0.89, "line": "{\"duration_api_ms\":0,\"stop_reason\":\"stop_sequence\",\"session_id\":\"16afc4bb-d205-4268-b826-22a8c9c11d49\",\"total_cost_usd\":0,\"usage\":{\"output_tokens_details\":{\"thinking_tokens\":0},\"input_tokens\":0,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":0,\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{},\"permission_denials\":[],\"terminal_reason\":\"api_error\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":true,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":400,\"result\":\"API Error: 400 probe: bad request\",\"type\":\"result\",\"duration_ms\":358,\"uuid\":\"c270db8e-fc6b-4e67-b9db-48a6f9e1b325\",\"queued_turn_count\":0,\"result_index\":0,\"model_usage_since_last_result\":{}}"}
+{"t": 0.97, "exit": 1}
diff --git a/crates/mind-body/src/self_run/claude-2.1.312-live-session-api-error-first.jsonl b/crates/mind-body/src/self_run/claude-2.1.312-live-session-api-error-first.jsonl
new file mode 100644
index 0000000..87f8640
--- /dev/null
+++ b/crates/mind-body/src/self_run/claude-2.1.312-live-session-api-error-first.jsonl
@@ -0,0 +1,6 @@
+{"t": 0.0, "sent": "APIERROR turn."}
+{"t": 0.37, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"dd429f40-9e2c-46fd-a93b-35923cfd219f\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"bypassPermissions\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"b9d58432-83ae-425c-bbff-57ffc4da95d9\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2504059.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.68, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"APIERROR turn.\"},\"session_id\":\"dd429f40-9e2c-46fd-a93b-35923cfd219f\",\"parent_tool_use_id\":null,\"uuid\":\"4f22def4-2c7d-4640-98e9-2e1eff346096\",\"timestamp\":\"2026-10-31T17:33:53.056Z\",\"isReplay\":true}"}
+{"t": 0.68, "line": "{\"type\":\"assistant\",\"message\":{\"diagnostics\":null,\"id\":\"257066c3-a003-4e8b-81b8-e41a54b58909\",\"container\":null,\"model\":\"\",\"role\":\"assistant\",\"stop_details\":null,\"stop_reason\":\"stop_sequence\",\"stop_sequence\":\"\",\"type\":\"message\",\"usage\":{\"output_tokens_details\":null,\"input_tokens\":0,\"output_tokens\":0,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":null,\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":null,\"iterations\":null,\"speed\":null,\"fallback_credit\":null},\"content\":[{\"type\":\"text\",\"text\":\"API Error: 400 probe: bad request\"}],\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"dd429f40-9e2c-46fd-a93b-35923cfd219f\",\"uuid\":\"7c80799a-49a2-4ed0-ab2d-5431beb6fd08\",\"timestamp\":\"2026-10-31T17:33:53.377Z\",\"error\":\"unknown\",\"is_api_error_message\":true,\"api_error_status\":400}"}
+{"t": 0.68, "line": "{\"duration_api_ms\":0,\"stop_reason\":\"stop_sequence\",\"session_id\":\"dd429f40-9e2c-46fd-a93b-35923cfd219f\",\"total_cost_usd\":0,\"usage\":{\"output_tokens_details\":{\"thinking_tokens\":0},\"input_tokens\":0,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":0,\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{},\"permission_denials\":[],\"terminal_reason\":\"api_error\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":true,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":400,\"result\":\"API Error: 400 probe: bad request\",\"type\":\"result\",\"duration_ms\":351,\"uuid\":\"22bf140f-015a-4069-839e-87c9415dd7a5\",\"queued_turn_count\":0,\"result_index\":0,\"model_usage_since_last_result\":{}}"}
+{"t": 0.73, "exit": 1}
diff --git a/crates/mind-body/src/self_run/claude-2.1.312-live-session-blocking-limit-scrub.jsonl b/crates/mind-body/src/self_run/claude-2.1.312-live-session-blocking-limit-scrub.jsonl
new file mode 100644
index 0000000..f9d3302
--- /dev/null
+++ b/crates/mind-body/src/self_run/claude-2.1.312-live-session-blocking-limit-scrub.jsonl
@@ -0,0 +1,11 @@
+{"t": 0.0, "sent": "BIGCONTEXT turn E."}
+{"t": 0.59, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"cc5c961f-57a8-4895-8e67-f41aae93605a\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"default\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"2914d80e-c3cd-456c-8a39-1582e8405690\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2505150.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.64, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"BIGCONTEXT turn E.\"},\"session_id\":\"cc5c961f-57a8-4895-8e67-f41aae93605a\",\"parent_tool_use_id\":null,\"uuid\":\"9b62090a-4f76-4de7-b278-61fca3e8ace5\",\"timestamp\":\"2026-10-31T17:34:10.045Z\",\"isReplay\":true}"}
+{"t": 0.64, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0001\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 1\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":990000,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"cc5c961f-57a8-4895-8e67-f41aae93605a\",\"uuid\":\"d7ec96d8-22a3-4877-83d2-a724ff0389c4\",\"timestamp\":\"2026-10-31T17:34:10.104Z\"}"}
+{"t": 0.67, "line": "{\"duration_api_ms\":27,\"stop_reason\":\"end_turn\",\"session_id\":\"cc5c961f-57a8-4895-8e67-f41aae93605a\",\"total_cost_usd\":3.9601,\"usage\":{\"input_tokens\":990000,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":990000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":3.9601,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 1\",\"ttft_ms\":85,\"type\":\"result\",\"duration_ms\":101,\"uuid\":\"d02b7cb5-d9b7-4310-96c2-305586a27980\",\"ttft_stream_ms\":85,\"time_to_request_ms\":75,\"first_content_frame_ms\":85,\"queued_turn_count\":0,\"result_index\":0,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":990000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":3.9601,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 0.7, "sent": "after big F."}
+{"t": 0.72, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"cc5c961f-57a8-4895-8e67-f41aae93605a\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"default\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"2d494e81-54c8-410d-aa75-5156c6a45bc6\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2505150.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.73, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"after big F.\"},\"session_id\":\"cc5c961f-57a8-4895-8e67-f41aae93605a\",\"parent_tool_use_id\":null,\"uuid\":\"f0232589-9e2b-40e6-aed9-08a5555f6dfd\",\"timestamp\":\"2026-10-31T17:34:10.184Z\",\"isReplay\":true}"}
+{"t": 0.73, "line": "{\"type\":\"assistant\",\"message\":{\"diagnostics\":null,\"id\":\"b9f3c719-1ac3-4652-9268-b7c86c078ad3\",\"container\":null,\"model\":\"\",\"role\":\"assistant\",\"stop_details\":null,\"stop_reason\":\"stop_sequence\",\"stop_sequence\":\"\",\"type\":\"message\",\"usage\":{\"output_tokens_details\":null,\"input_tokens\":0,\"output_tokens\":0,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":null,\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":null,\"iterations\":null,\"speed\":null,\"fallback_credit\":null},\"content\":[{\"type\":\"text\",\"text\":\"Prompt is too long\"}],\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"cc5c961f-57a8-4895-8e67-f41aae93605a\",\"uuid\":\"d2427e64-e61b-4a44-b199-8a9a5fc93014\",\"timestamp\":\"2026-10-31T17:34:10.194Z\",\"error\":\"invalid_request\",\"is_api_error_message\":true}"}
+{"t": 0.73, "line": "{\"duration_api_ms\":27,\"stop_reason\":\"stop_sequence\",\"session_id\":\"cc5c961f-57a8-4895-8e67-f41aae93605a\",\"total_cost_usd\":3.9601,\"usage\":{\"output_tokens_details\":{\"thinking_tokens\":0},\"input_tokens\":0,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":0,\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":990000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":3.9601,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"blocking_limit\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":true,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"Prompt is too long\",\"type\":\"result\",\"duration_ms\":21,\"uuid\":\"ee366487-aa25-4e0f-8dbe-799c5b329ea4\",\"queued_turn_count\":0,\"result_index\":1,\"model_usage_since_last_result\":{}}"}
+{"t": 0.78, "exit": 1}
diff --git a/crates/mind-body/src/self_run/claude-2.1.312-live-session-blocking-limit.jsonl b/crates/mind-body/src/self_run/claude-2.1.312-live-session-blocking-limit.jsonl
new file mode 100644
index 0000000..64ca1b4
--- /dev/null
+++ b/crates/mind-body/src/self_run/claude-2.1.312-live-session-blocking-limit.jsonl
@@ -0,0 +1,11 @@
+{"t": 0.0, "sent": "BIGCONTEXT turn E."}
+{"t": 0.4, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"6a8016e9-1915-49d6-b900-5dd8d3658a5a\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"bypassPermissions\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"b93e754b-850c-4d06-a79c-96f47f3d81ef\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2504141.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.47, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"BIGCONTEXT turn E.\"},\"session_id\":\"6a8016e9-1915-49d6-b900-5dd8d3658a5a\",\"parent_tool_use_id\":null,\"uuid\":\"6b95e7d9-9e60-4428-ae66-c058c4325c43\",\"timestamp\":\"2026-10-31T17:33:53.896Z\",\"isReplay\":true}"}
+{"t": 0.47, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0001\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 1\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":990000,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"6a8016e9-1915-49d6-b900-5dd8d3658a5a\",\"uuid\":\"f026c0cf-4d44-48b4-b34c-41d5782ad568\",\"timestamp\":\"2026-10-31T17:33:53.977Z\"}"}
+{"t": 0.49, "line": "{\"duration_api_ms\":22,\"stop_reason\":\"end_turn\",\"session_id\":\"6a8016e9-1915-49d6-b900-5dd8d3658a5a\",\"total_cost_usd\":3.9601,\"usage\":{\"input_tokens\":990000,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":990000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":3.9601,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 1\",\"ttft_ms\":110,\"type\":\"result\",\"duration_ms\":119,\"uuid\":\"1b6939c5-e28c-4fdf-bea0-c3e1c9bcab1b\",\"ttft_stream_ms\":110,\"time_to_request_ms\":101,\"first_content_frame_ms\":110,\"queued_turn_count\":0,\"result_index\":0,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":990000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":3.9601,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 0.5, "sent": "after big F."}
+{"t": 0.52, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"6a8016e9-1915-49d6-b900-5dd8d3658a5a\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"bypassPermissions\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"ca78fec1-445f-4b37-bd0d-d4aff95d8893\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2504141.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.53, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"after big F.\"},\"session_id\":\"6a8016e9-1915-49d6-b900-5dd8d3658a5a\",\"parent_tool_use_id\":null,\"uuid\":\"97993af7-cd2d-4125-a42f-b91a67a4ee49\",\"timestamp\":\"2026-10-31T17:33:54.017Z\",\"isReplay\":true}"}
+{"t": 0.53, "line": "{\"type\":\"assistant\",\"message\":{\"diagnostics\":null,\"id\":\"45e3911e-0150-4a68-b64a-68ccd5cf4795\",\"container\":null,\"model\":\"\",\"role\":\"assistant\",\"stop_details\":null,\"stop_reason\":\"stop_sequence\",\"stop_sequence\":\"\",\"type\":\"message\",\"usage\":{\"output_tokens_details\":null,\"input_tokens\":0,\"output_tokens\":0,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":null,\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":null,\"iterations\":null,\"speed\":null,\"fallback_credit\":null},\"content\":[{\"type\":\"text\",\"text\":\"Prompt is too long\"}],\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"6a8016e9-1915-49d6-b900-5dd8d3658a5a\",\"uuid\":\"6b811a37-4c2c-42b0-a838-6cf69cff45dd\",\"timestamp\":\"2026-10-31T17:33:54.035Z\",\"error\":\"invalid_request\",\"is_api_error_message\":true}"}
+{"t": 0.53, "line": "{\"duration_api_ms\":22,\"stop_reason\":\"stop_sequence\",\"session_id\":\"6a8016e9-1915-49d6-b900-5dd8d3658a5a\",\"total_cost_usd\":3.9601,\"usage\":{\"output_tokens_details\":{\"thinking_tokens\":0},\"input_tokens\":0,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":0,\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":990000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":3.9601,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"blocking_limit\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":true,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"Prompt is too long\",\"type\":\"result\",\"duration_ms\":25,\"uuid\":\"cbf6fb03-d264-4d31-b7b4-677a00debad1\",\"queued_turn_count\":0,\"result_index\":1,\"model_usage_since_last_result\":{}}"}
+{"t": 0.62, "exit": 1}
diff --git a/crates/mind-body/src/self_run/claude-2.1.312-live-session-ceiling-flush-folded.jsonl b/crates/mind-body/src/self_run/claude-2.1.312-live-session-ceiling-flush-folded.jsonl
new file mode 100644
index 0000000..3205a43
--- /dev/null
+++ b/crates/mind-body/src/self_run/claude-2.1.312-live-session-ceiling-flush-folded.jsonl
@@ -0,0 +1,12 @@
+{"t": 0.0, "sent": "SLEEPCMD CEIL300 turn."}
+{"t": 0.41, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"7b736ef1-91c5-4732-aafe-32f4514a1189\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"bypassPermissions\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"87581eeb-54a3-4b41-9086-b3c883a9f0ba\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2502341.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.48, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"SLEEPCMD CEIL300 turn.\"},\"session_id\":\"7b736ef1-91c5-4732-aafe-32f4514a1189\",\"parent_tool_use_id\":null,\"uuid\":\"3b77c087-baba-43db-a442-0f42ca59559a\",\"timestamp\":\"2026-10-31T17:33:23.800Z\",\"isReplay\":true}"}
+{"t": 0.48, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0001\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"tool_use\",\"id\":\"toolu_0001\",\"name\":\"Bash\",\"input\":{\"command\":\"python3 -c 'import time; time.sleep(25)'\",\"description\":\"probe wait\"}}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":300000,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"7b736ef1-91c5-4732-aafe-32f4514a1189\",\"uuid\":\"71ac68b4-098b-4935-885b-646ce8ba1df3\",\"timestamp\":\"2026-10-31T17:33:23.877Z\"}"}
+{"t": 0.5, "sent": "The context ceiling is reached. Admit to the mind what it lacks, close your run, and end."}
+{"t": 3.54, "line": "{\"type\":\"system\",\"subtype\":\"task_started\",\"task_id\":\"bthzjys1l\",\"run_id\":\"0mvwojms9-8c20511b\",\"tool_use_id\":\"toolu_0001\",\"description\":\"probe wait\",\"is_backgrounded\":false,\"task_type\":\"local_bash\",\"uuid\":\"1c7de05d-8fd1-41a5-9271-3c3d73a0812e\",\"session_id\":\"7b736ef1-91c5-4732-aafe-32f4514a1189\"}"}
+{"t": 25.55, "line": "{\"type\":\"system\",\"subtype\":\"task_notification\",\"task_id\":\"bthzjys1l\",\"run_id\":\"0mvwojms9-8c20511b\",\"tool_use_id\":\"toolu_0001\",\"status\":\"completed\",\"output_file\":\"\",\"summary\":\"probe wait\",\"uuid\":\"cc5fe6b4-33c9-409b-a193-b1b12e9c80a3\",\"session_id\":\"7b736ef1-91c5-4732-aafe-32f4514a1189\"}"}
+{"t": 25.56, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":[{\"tool_use_id\":\"toolu_0001\",\"type\":\"tool_result\",\"content\":\"(Bash completed with no output)\",\"is_error\":false}]},\"parent_tool_use_id\":null,\"session_id\":\"7b736ef1-91c5-4732-aafe-32f4514a1189\",\"uuid\":\"3d8ec750-aaea-4945-a6f8-ed7893633372\",\"timestamp\":\"2026-10-31T17:33:48.958Z\",\"tool_use_result\":{\"stdout\":\"\",\"stderr\":\"\",\"interrupted\":false,\"isImage\":false,\"noOutputExpected\":false},\"tool_result_meta\":[{\"id\":\"toolu_0001\",\"permission_decision\":{\"decision\":\"accept\",\"source\":\"config\",\"reason_type\":\"mode\"}}]}"}
+{"t": 25.56, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"The context ceiling is reached. Admit to the mind what it lacks, close your run, and end.\"},\"session_id\":\"7b736ef1-91c5-4732-aafe-32f4514a1189\",\"parent_tool_use_id\":null,\"uuid\":\"bcb6e03c-eba6-4ef4-abc5-6aa0d2f79186\",\"timestamp\":\"2026-10-31T17:33:23.907Z\",\"isReplay\":true}"}
+{"t": 25.58, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0002\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 2\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":10,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"7b736ef1-91c5-4732-aafe-32f4514a1189\",\"uuid\":\"29959f77-a5e1-472d-be37-18916ad1ac48\",\"timestamp\":\"2026-10-31T17:33:48.979Z\"}"}
+{"t": 25.59, "line": "{\"duration_api_ms\":55,\"stop_reason\":\"end_turn\",\"session_id\":\"7b736ef1-91c5-4732-aafe-32f4514a1189\",\"total_cost_usd\":1.20024,\"usage\":{\"input_tokens\":300010,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":10,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":300010,\"outputTokens\":10,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.20024,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":2,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 2\",\"ttft_ms\":105,\"type\":\"result\",\"duration_ms\":25212,\"uuid\":\"637d4fe1-844e-4fc7-8322-18923207adcb\",\"ttft_stream_ms\":104,\"time_to_request_ms\":91,\"first_content_frame_ms\":104,\"queued_turn_count\":0,\"result_index\":0,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":300010,\"outputTokens\":10,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.20024,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 28.68, "exit": 0}
diff --git a/crates/mind-body/src/self_run/claude-2.1.312-live-session-ceiling-flush-queued-scrub.jsonl b/crates/mind-body/src/self_run/claude-2.1.312-live-session-ceiling-flush-queued-scrub.jsonl
new file mode 100644
index 0000000..626ce88
--- /dev/null
+++ b/crates/mind-body/src/self_run/claude-2.1.312-live-session-ceiling-flush-queued-scrub.jsonl
@@ -0,0 +1,11 @@
+{"t": 0.0, "sent": "CEIL300 turn."}
+{"t": 0.6, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"a245f057-89b0-409c-b3d1-83fb0e67bb51\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"default\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"7d66dc28-b8d3-461c-8bd8-feeab49c7e7c\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2504967.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.65, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"CEIL300 turn.\"},\"session_id\":\"a245f057-89b0-409c-b3d1-83fb0e67bb51\",\"parent_tool_use_id\":null,\"uuid\":\"8a9e12b5-bf4f-476a-895b-72242502868a\",\"timestamp\":\"2026-10-31T17:34:08.173Z\",\"isReplay\":true}"}
+{"t": 0.65, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0001\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 1\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":300000,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"a245f057-89b0-409c-b3d1-83fb0e67bb51\",\"uuid\":\"b455e484-b7ff-43f8-93df-5ac3e940837b\",\"timestamp\":\"2026-10-31T17:34:08.239Z\"}"}
+{"t": 0.65, "sent": "The context ceiling is reached. Admit to the mind what it lacks, close your run, and end."}
+{"t": 0.68, "line": "{\"duration_api_ms\":20,\"stop_reason\":\"end_turn\",\"session_id\":\"a245f057-89b0-409c-b3d1-83fb0e67bb51\",\"total_cost_usd\":1.2001,\"usage\":{\"input_tokens\":300000,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":300000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.2001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 1\",\"ttft_ms\":106,\"type\":\"result\",\"duration_ms\":116,\"uuid\":\"50577674-3be5-4ed7-9550-fc6f46ed5614\",\"ttft_stream_ms\":106,\"time_to_request_ms\":98,\"first_content_frame_ms\":106,\"queued_turn_count\":0,\"result_index\":0,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":300000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.2001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 0.7, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"a245f057-89b0-409c-b3d1-83fb0e67bb51\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"default\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"760d5b39-0f94-4aa1-a9fd-0f24d415e395\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2504967.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.72, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"The context ceiling is reached. Admit to the mind what it lacks, close your run, and end.\"},\"session_id\":\"a245f057-89b0-409c-b3d1-83fb0e67bb51\",\"parent_tool_use_id\":null,\"uuid\":\"1f8189a0-c2e1-4c6d-bfbe-b49244589d4c\",\"timestamp\":\"2026-10-31T17:34:08.288Z\",\"isReplay\":true}"}
+{"t": 0.72, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0002\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 2\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":10,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"a245f057-89b0-409c-b3d1-83fb0e67bb51\",\"uuid\":\"66206100-1bad-4fa7-bf91-fd7608e54a79\",\"timestamp\":\"2026-10-31T17:34:08.309Z\"}"}
+{"t": 0.72, "line": "{\"duration_api_ms\":31,\"stop_reason\":\"end_turn\",\"session_id\":\"a245f057-89b0-409c-b3d1-83fb0e67bb51\",\"total_cost_usd\":1.20024,\"usage\":{\"input_tokens\":10,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":300010,\"outputTokens\":10,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.20024,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 2\",\"ttft_ms\":34,\"type\":\"result\",\"duration_ms\":38,\"uuid\":\"9074d4d8-8e87-47c4-b0e9-a040ab6e952f\",\"ttft_stream_ms\":33,\"time_to_request_ms\":30,\"first_content_frame_ms\":33,\"queued_turn_count\":0,\"result_index\":1,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":10,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00014000000000000001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 0.78, "exit": 0}
diff --git a/crates/mind-body/src/self_run/claude-2.1.312-live-session-ceiling-flush-queued.jsonl b/crates/mind-body/src/self_run/claude-2.1.312-live-session-ceiling-flush-queued.jsonl
new file mode 100644
index 0000000..d457e48
--- /dev/null
+++ b/crates/mind-body/src/self_run/claude-2.1.312-live-session-ceiling-flush-queued.jsonl
@@ -0,0 +1,11 @@
+{"t": 0.0, "sent": "CEIL300 turn."}
+{"t": 0.33, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"83e18ef5-b9a0-4a66-9175-9b56f7b31914\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"bypassPermissions\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"572b2d29-b666-433a-a8e7-c3ffaf3ee25f\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2503995.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.37, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"CEIL300 turn.\"},\"session_id\":\"83e18ef5-b9a0-4a66-9175-9b56f7b31914\",\"parent_tool_use_id\":null,\"uuid\":\"f608c041-de00-44c9-8929-7e1b52c606ea\",\"timestamp\":\"2026-10-31T17:33:52.461Z\",\"isReplay\":true}"}
+{"t": 0.38, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0001\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 1\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":300000,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"83e18ef5-b9a0-4a66-9175-9b56f7b31914\",\"uuid\":\"cd1e18db-f5ff-4ba8-b26d-b6b36efb86e7\",\"timestamp\":\"2026-10-31T17:33:52.519Z\"}"}
+{"t": 0.4, "line": "{\"duration_api_ms\":23,\"stop_reason\":\"end_turn\",\"session_id\":\"83e18ef5-b9a0-4a66-9175-9b56f7b31914\",\"total_cost_usd\":1.2001,\"usage\":{\"input_tokens\":300000,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":300000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.2001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 1\",\"ttft_ms\":83,\"type\":\"result\",\"duration_ms\":92,\"uuid\":\"d63e9f4a-3924-4f4d-9863-53da1d46f071\",\"ttft_stream_ms\":82,\"time_to_request_ms\":70,\"first_content_frame_ms\":82,\"queued_turn_count\":0,\"result_index\":0,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":300000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.2001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 0.4, "sent": "The context ceiling is reached. Admit to the mind what it lacks, close your run, and end."}
+{"t": 0.41, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"83e18ef5-b9a0-4a66-9175-9b56f7b31914\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"bypassPermissions\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"d45ec166-3020-42d3-97dc-934c026f696f\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2503995.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.43, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"The context ceiling is reached. Admit to the mind what it lacks, close your run, and end.\"},\"session_id\":\"83e18ef5-b9a0-4a66-9175-9b56f7b31914\",\"parent_tool_use_id\":null,\"uuid\":\"8d183a31-53a4-4879-b600-c77cc360b4cd\",\"timestamp\":\"2026-10-31T17:33:52.556Z\",\"isReplay\":true}"}
+{"t": 0.43, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0002\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 2\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":10,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"83e18ef5-b9a0-4a66-9175-9b56f7b31914\",\"uuid\":\"64f2633c-cd3c-4b27-af49-f40f060bf53f\",\"timestamp\":\"2026-10-31T17:33:52.573Z\"}"}
+{"t": 0.43, "line": "{\"duration_api_ms\":32,\"stop_reason\":\"end_turn\",\"session_id\":\"83e18ef5-b9a0-4a66-9175-9b56f7b31914\",\"total_cost_usd\":1.20024,\"usage\":{\"input_tokens\":10,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":300010,\"outputTokens\":10,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.20024,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 2\",\"ttft_ms\":22,\"type\":\"result\",\"duration_ms\":26,\"uuid\":\"85270168-1851-4da3-be34-3da91d719673\",\"ttft_stream_ms\":22,\"time_to_request_ms\":19,\"first_content_frame_ms\":22,\"queued_turn_count\":0,\"result_index\":1,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":10,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00014000000000000001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 0.48, "exit": 0}
diff --git a/crates/mind-body/src/self_run/claude-2.1.312-live-session-compaction-off-360k-scrub.jsonl b/crates/mind-body/src/self_run/claude-2.1.312-live-session-compaction-off-360k-scrub.jsonl
new file mode 100644
index 0000000..56232ca
--- /dev/null
+++ b/crates/mind-body/src/self_run/claude-2.1.312-live-session-compaction-off-360k-scrub.jsonl
@@ -0,0 +1,11 @@
+{"t": 0.0, "sent": "MID360 turn E."}
+{"t": 0.56, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"1827d168-97a1-4658-8bbb-25b2a9b88989\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"default\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"356e22ac-8c51-42fc-ae97-05acaac27f8e\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2505236.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.62, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"MID360 turn E.\"},\"session_id\":\"1827d168-97a1-4658-8bbb-25b2a9b88989\",\"parent_tool_use_id\":null,\"uuid\":\"f583c8be-c8a7-4073-a4b3-ceb8b41e9b86\",\"timestamp\":\"2026-10-31T17:34:10.861Z\",\"isReplay\":true}"}
+{"t": 0.62, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0001\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 1\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":360000,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"1827d168-97a1-4658-8bbb-25b2a9b88989\",\"uuid\":\"b34b3d9d-db8a-46c4-8737-8a55cb8a5f61\",\"timestamp\":\"2026-10-31T17:34:10.932Z\"}"}
+{"t": 0.64, "line": "{\"duration_api_ms\":24,\"stop_reason\":\"end_turn\",\"session_id\":\"1827d168-97a1-4658-8bbb-25b2a9b88989\",\"total_cost_usd\":1.4401,\"usage\":{\"input_tokens\":360000,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":360000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.4401,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 1\",\"ttft_ms\":100,\"type\":\"result\",\"duration_ms\":110,\"uuid\":\"8cae6854-8711-4b79-a96a-6b82ea3b721a\",\"ttft_stream_ms\":100,\"time_to_request_ms\":90,\"first_content_frame_ms\":100,\"queued_turn_count\":0,\"result_index\":0,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":360000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.4401,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 0.65, "sent": "after 360 F."}
+{"t": 0.67, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"1827d168-97a1-4658-8bbb-25b2a9b88989\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"default\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"a641ddd7-1140-4ff7-aecc-329729521388\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2505236.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.68, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"after 360 F.\"},\"session_id\":\"1827d168-97a1-4658-8bbb-25b2a9b88989\",\"parent_tool_use_id\":null,\"uuid\":\"eec03a51-f148-4fd1-8882-393a52f9e3da\",\"timestamp\":\"2026-10-31T17:34:10.976Z\",\"isReplay\":true}"}
+{"t": 0.68, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0002\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 2\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":10,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"1827d168-97a1-4658-8bbb-25b2a9b88989\",\"uuid\":\"6d2db569-66ed-4351-875c-65b6f9fa0b9b\",\"timestamp\":\"2026-10-31T17:34:10.994Z\"}"}
+{"t": 0.68, "line": "{\"duration_api_ms\":34,\"stop_reason\":\"end_turn\",\"session_id\":\"1827d168-97a1-4658-8bbb-25b2a9b88989\",\"total_cost_usd\":1.44024,\"usage\":{\"input_tokens\":10,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":360010,\"outputTokens\":10,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.44024,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 2\",\"ttft_ms\":24,\"type\":\"result\",\"duration_ms\":27,\"uuid\":\"aeee9cb3-383a-49e7-bd0d-5dfa61d955f6\",\"ttft_stream_ms\":23,\"time_to_request_ms\":20,\"first_content_frame_ms\":23,\"queued_turn_count\":0,\"result_index\":1,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":10,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00014000000000000001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 0.77, "exit": 0}
diff --git a/crates/mind-body/src/self_run/claude-2.1.312-live-session-compaction-off-360k.jsonl b/crates/mind-body/src/self_run/claude-2.1.312-live-session-compaction-off-360k.jsonl
new file mode 100644
index 0000000..f82d8e1
--- /dev/null
+++ b/crates/mind-body/src/self_run/claude-2.1.312-live-session-compaction-off-360k.jsonl
@@ -0,0 +1,11 @@
+{"t": 0.0, "sent": "MID360 turn E."}
+{"t": 0.37, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"93b381ad-c5fa-4d79-bf38-cd1b56080558\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"bypassPermissions\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"e18d3769-16bf-4003-9c2e-d556b982b7e9\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2504207.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.43, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"MID360 turn E.\"},\"session_id\":\"93b381ad-c5fa-4d79-bf38-cd1b56080558\",\"parent_tool_use_id\":null,\"uuid\":\"60b9d6ea-b625-4757-b9fd-a522c1f11feb\",\"timestamp\":\"2026-10-31T17:33:54.546Z\",\"isReplay\":true}"}
+{"t": 0.43, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0001\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 1\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":360000,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"93b381ad-c5fa-4d79-bf38-cd1b56080558\",\"uuid\":\"b15019cf-c6a5-46da-9529-44a22042342c\",\"timestamp\":\"2026-10-31T17:33:54.617Z\"}"}
+{"t": 0.45, "line": "{\"duration_api_ms\":20,\"stop_reason\":\"end_turn\",\"session_id\":\"93b381ad-c5fa-4d79-bf38-cd1b56080558\",\"total_cost_usd\":1.4401,\"usage\":{\"input_tokens\":360000,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":360000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.4401,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 1\",\"ttft_ms\":96,\"type\":\"result\",\"duration_ms\":105,\"uuid\":\"0d48eeeb-9264-4ef9-a035-aa2ac5340045\",\"ttft_stream_ms\":95,\"time_to_request_ms\":87,\"first_content_frame_ms\":95,\"queued_turn_count\":0,\"result_index\":0,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":360000,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.4401,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 0.45, "sent": "after 360 F."}
+{"t": 0.47, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"93b381ad-c5fa-4d79-bf38-cd1b56080558\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"bypassPermissions\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"29d96b34-1b4f-4edc-b29d-8b7d6a4a9a4b\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2504207.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.49, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"after 360 F.\"},\"session_id\":\"93b381ad-c5fa-4d79-bf38-cd1b56080558\",\"parent_tool_use_id\":null,\"uuid\":\"3e15b4b7-d908-4377-b895-017b333ba030\",\"timestamp\":\"2026-10-31T17:33:54.654Z\",\"isReplay\":true}"}
+{"t": 0.49, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0002\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 2\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":10,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"93b381ad-c5fa-4d79-bf38-cd1b56080558\",\"uuid\":\"bcad2f9f-54a3-4a98-8b95-94aba33506de\",\"timestamp\":\"2026-10-31T17:33:54.683Z\"}"}
+{"t": 0.5, "line": "{\"duration_api_ms\":40,\"stop_reason\":\"end_turn\",\"session_id\":\"93b381ad-c5fa-4d79-bf38-cd1b56080558\",\"total_cost_usd\":1.44024,\"usage\":{\"input_tokens\":10,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":360010,\"outputTokens\":10,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":1.44024,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 2\",\"ttft_ms\":34,\"type\":\"result\",\"duration_ms\":38,\"uuid\":\"05945db7-7d57-4ca5-9bcf-48ef8d1739f4\",\"ttft_stream_ms\":34,\"time_to_request_ms\":20,\"first_content_frame_ms\":34,\"queued_turn_count\":0,\"result_index\":1,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":10,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00014000000000000001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 0.57, "exit": 0}
diff --git a/crates/mind-body/src/self_run/claude-2.1.312-live-session-folded.jsonl b/crates/mind-body/src/self_run/claude-2.1.312-live-session-folded.jsonl
new file mode 100644
index 0000000..5fbe4e2
--- /dev/null
+++ b/crates/mind-body/src/self_run/claude-2.1.312-live-session-folded.jsonl
@@ -0,0 +1,12 @@
+{"t": 0.0, "sent": "SLEEPCMD turn C."}
+{"t": 0.39, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"3c946c14-82f9-40b0-b687-70bc881e16da\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"bypassPermissions\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"54f0b45e-8a41-4851-a959-04ae1e577d83\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2497819.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 0.46, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"SLEEPCMD turn C.\"},\"session_id\":\"3c946c14-82f9-40b0-b687-70bc881e16da\",\"parent_tool_use_id\":null,\"uuid\":\"be733558-c1c0-4249-b923-0669acb0c038\",\"timestamp\":\"2026-10-31T17:32:42.382Z\",\"isReplay\":true}"}
+{"t": 0.46, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0001\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"tool_use\",\"id\":\"toolu_0001\",\"name\":\"Bash\",\"input\":{\"command\":\"python3 -c 'import time; time.sleep(25)'\",\"description\":\"probe wait\"}}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":10,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"3c946c14-82f9-40b0-b687-70bc881e16da\",\"uuid\":\"d42ffba9-ca8b-4650-b03d-255169e09a28\",\"timestamp\":\"2026-10-31T17:32:42.471Z\"}"}
+{"t": 3.53, "line": "{\"type\":\"system\",\"subtype\":\"task_started\",\"task_id\":\"b74113tl4\",\"run_id\":\"0mvwoiquf-9925163d\",\"tool_use_id\":\"toolu_0001\",\"description\":\"probe wait\",\"is_backgrounded\":false,\"task_type\":\"local_bash\",\"uuid\":\"f4274003-dfb6-4dd3-a4ae-9c67341775c4\",\"session_id\":\"3c946c14-82f9-40b0-b687-70bc881e16da\"}"}
+{"t": 8.0, "sent": "FOLDED line D."}
+{"t": 25.55, "line": "{\"type\":\"system\",\"subtype\":\"task_notification\",\"task_id\":\"b74113tl4\",\"run_id\":\"0mvwoiquf-9925163d\",\"tool_use_id\":\"toolu_0001\",\"status\":\"completed\",\"output_file\":\"\",\"summary\":\"probe wait\",\"uuid\":\"24f2afab-1d9b-4900-ae6c-f3a186a5f9c3\",\"session_id\":\"3c946c14-82f9-40b0-b687-70bc881e16da\"}"}
+{"t": 25.56, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":[{\"tool_use_id\":\"toolu_0001\",\"type\":\"tool_result\",\"content\":\"(Bash completed with no output)\",\"is_error\":false}]},\"parent_tool_use_id\":null,\"session_id\":\"3c946c14-82f9-40b0-b687-70bc881e16da\",\"uuid\":\"33c2e703-278c-4e08-85d1-066bd7718a7f\",\"timestamp\":\"2026-10-31T17:33:07.566Z\",\"tool_use_result\":{\"stdout\":\"\",\"stderr\":\"\",\"interrupted\":false,\"isImage\":false,\"noOutputExpected\":false},\"tool_result_meta\":[{\"id\":\"toolu_0001\",\"permission_decision\":{\"decision\":\"accept\",\"source\":\"config\",\"reason_type\":\"mode\"}}]}"}
+{"t": 25.58, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"FOLDED line D.\"},\"session_id\":\"3c946c14-82f9-40b0-b687-70bc881e16da\",\"parent_tool_use_id\":null,\"uuid\":\"f030000d-ef52-4865-898d-02b53f418d0e\",\"timestamp\":\"2026-10-31T17:32:50.017Z\",\"isReplay\":true}"}
+{"t": 25.59, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0002\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 2\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":10,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"3c946c14-82f9-40b0-b687-70bc881e16da\",\"uuid\":\"fe2d434d-6b9a-47a4-95b4-86e62da6577d\",\"timestamp\":\"2026-10-31T17:33:07.604Z\"}"}
+{"t": 25.6, "line": "{\"duration_api_ms\":56,\"stop_reason\":\"end_turn\",\"session_id\":\"3c946c14-82f9-40b0-b687-70bc881e16da\",\"total_cost_usd\":0.00028000000000000003,\"usage\":{\"input_tokens\":20,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":10,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":20,\"outputTokens\":10,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00028000000000000003,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":2,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 2\",\"ttft_ms\":119,\"type\":\"result\",\"duration_ms\":25259,\"uuid\":\"5784e78c-c270-46b1-a366-5d88fa09f2a6\",\"ttft_stream_ms\":117,\"time_to_request_ms\":108,\"first_content_frame_ms\":117,\"queued_turn_count\":0,\"result_index\":0,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":20,\"outputTokens\":10,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00028000000000000003,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 28.69, "exit": 0}
diff --git a/crates/mind-body/src/self_run/claude-2.1.312-live-session-queued-scrub.jsonl b/crates/mind-body/src/self_run/claude-2.1.312-live-session-queued-scrub.jsonl
new file mode 100644
index 0000000..e8ca605
--- /dev/null
+++ b/crates/mind-body/src/self_run/claude-2.1.312-live-session-queued-scrub.jsonl
@@ -0,0 +1,11 @@
+{"t": 0.0, "sent": "SLOWEND turn A."}
+{"t": 0.53, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"fe59ae62-86a6-4538-9ed5-6514735dff38\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"default\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"494260e7-1b1c-433a-a6ad-f3c0340566f8\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2504350.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 4.0, "sent": "QUEUED line B."}
+{"t": 12.59, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"SLOWEND turn A.\"},\"session_id\":\"fe59ae62-86a6-4538-9ed5-6514735dff38\",\"parent_tool_use_id\":null,\"uuid\":\"6ba0d9fb-e1ac-4650-b882-2b4b7b3e3659\",\"timestamp\":\"2026-10-31T17:33:55.332Z\",\"isReplay\":true}"}
+{"t": 12.59, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0001\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 1\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":10,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"fe59ae62-86a6-4538-9ed5-6514735dff38\",\"uuid\":\"ae291574-166d-4fcb-bbba-a1e20d66a7e4\",\"timestamp\":\"2026-10-31T17:34:07.405Z\"}"}
+{"t": 12.6, "line": "{\"duration_api_ms\":12031,\"stop_reason\":\"end_turn\",\"session_id\":\"fe59ae62-86a6-4538-9ed5-6514735dff38\",\"total_cost_usd\":0.00014000000000000001,\"usage\":{\"input_tokens\":10,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":10,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00014000000000000001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 1\",\"ttft_ms\":12099,\"type\":\"result\",\"duration_ms\":12110,\"uuid\":\"4de4c5f1-3507-4692-9c4f-7deec6542ec3\",\"ttft_stream_ms\":100,\"time_to_request_ms\":93,\"first_content_frame_ms\":100,\"queued_turn_count\":0,\"result_index\":0,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":10,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00014000000000000001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 12.61, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"fe59ae62-86a6-4538-9ed5-6514735dff38\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"default\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"aba5555c-d033-4f01-9204-cd0d6d7ce798\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2504350.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 12.63, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"QUEUED line B.\"},\"session_id\":\"fe59ae62-86a6-4538-9ed5-6514735dff38\",\"parent_tool_use_id\":null,\"uuid\":\"a9501d56-5520-4bf3-a4a7-84f0af12f62f\",\"timestamp\":\"2026-10-31T17:34:07.428Z\",\"isReplay\":true}"}
+{"t": 12.63, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0002\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 2\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":10,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"fe59ae62-86a6-4538-9ed5-6514735dff38\",\"uuid\":\"226295d5-b356-4417-bbb9-67522b5ce83e\",\"timestamp\":\"2026-10-31T17:34:07.446Z\"}"}
+{"t": 12.63, "line": "{\"duration_api_ms\":12041,\"stop_reason\":\"end_turn\",\"session_id\":\"fe59ae62-86a6-4538-9ed5-6514735dff38\",\"total_cost_usd\":0.00028000000000000003,\"usage\":{\"input_tokens\":10,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":20,\"outputTokens\":10,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00028000000000000003,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 2\",\"ttft_ms\":24,\"type\":\"result\",\"duration_ms\":29,\"uuid\":\"7f4b815b-2429-4b4d-b53d-8cf05d710389\",\"ttft_stream_ms\":24,\"time_to_request_ms\":20,\"first_content_frame_ms\":24,\"queued_turn_count\":0,\"result_index\":1,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":10,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00014000000000000001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 12.71, "exit": 0}
diff --git a/crates/mind-body/src/self_run/claude-2.1.312-live-session-queued.jsonl b/crates/mind-body/src/self_run/claude-2.1.312-live-session-queued.jsonl
new file mode 100644
index 0000000..e35de2e
--- /dev/null
+++ b/crates/mind-body/src/self_run/claude-2.1.312-live-session-queued.jsonl
@@ -0,0 +1,11 @@
+{"t": 0.0, "sent": "SLOWEND turn A."}
+{"t": 0.38, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"43536997-53c9-4df5-9b0d-88306a147d43\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"bypassPermissions\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"edd449db-1403-47d0-909a-0fdd332d4642\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2500539.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 4.0, "sent": "QUEUED line B."}
+{"t": 12.42, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"SLOWEND turn A.\"},\"session_id\":\"43536997-53c9-4df5-9b0d-88306a147d43\",\"parent_tool_use_id\":null,\"uuid\":\"2b58f7af-40bd-4fc6-8bf7-7bb01a745add\",\"timestamp\":\"2026-10-31T17:33:11.137Z\",\"isReplay\":true}"}
+{"t": 12.43, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0001\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 1\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":10,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"43536997-53c9-4df5-9b0d-88306a147d43\",\"uuid\":\"da85a878-bec3-4f7d-b9c8-f5928c1d26ba\",\"timestamp\":\"2026-10-31T17:33:23.195Z\"}"}
+{"t": 12.44, "line": "{\"duration_api_ms\":12025,\"stop_reason\":\"end_turn\",\"session_id\":\"43536997-53c9-4df5-9b0d-88306a147d43\",\"total_cost_usd\":0.00014000000000000001,\"usage\":{\"input_tokens\":10,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":10,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00014000000000000001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 1\",\"ttft_ms\":12097,\"type\":\"result\",\"duration_ms\":12111,\"uuid\":\"e61e2ba8-7ee2-46c0-b66c-fd4d50dd8a0c\",\"ttft_stream_ms\":97,\"time_to_request_ms\":88,\"first_content_frame_ms\":97,\"queued_turn_count\":0,\"result_index\":0,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":10,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00014000000000000001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 12.46, "line": "{\"type\":\"system\",\"subtype\":\"init\",\"cwd\":\"/probe/work\",\"session_id\":\"43536997-53c9-4df5-9b0d-88306a147d43\",\"tools\":[\"Task\",\"Bash\",\"CronCreate\",\"CronDelete\",\"CronList\",\"Edit\",\"EnterWorktree\",\"ExitWorktree\",\"ListAgents\",\"Monitor\",\"NotebookEdit\",\"Read\",\"ReportFindings\",\"ScheduleWakeup\",\"SendMessage\",\"Skill\",\"TaskStop\",\"ToolSearch\",\"WebFetch\",\"WebSearch\",\"Workflow\",\"Write\"],\"mcp_servers\":[],\"model\":\"claude-opus-5-5\",\"permissionMode\":\"bypassPermissions\",\"slash_commands\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\",\"agents\",\"auto-mode-setup\",\"autocompact\",\"clear\",\"color\",\"config\",\"output-style\",\"context\",\"effort\",\"fast\",\"focus\",\"heapdump\",\"init\",\"mcp\",\"model\",\"__remote-workflow\",\"workflow-launch-exec\",\"reload-plugins\",\"reload-skills\",\"rename\",\"security-review\",\"usage\",\"insights\",\"recap\",\"goal\",\"list-agents\",\"team-onboarding\"],\"terminal_slash_commands\":[\"doctor\",\"color\",\"focus\",\"reload-plugins\"],\"apiKeySource\":\"ANTHROPIC_API_KEY\",\"claude_code_version\":\"2.1.312\",\"output_style\":\"default\",\"agents\":[\"claude\",\"Explore\",\"general-purpose\",\"Plan\",\"statusline-setup\"],\"skills\":[\"deep-research\",\"dataviz\",\"update-config\",\"verify\",\"debug\",\"code-review\",\"simplify\",\"batch\",\"fewer-permission-prompts\",\"doctor\",\"loop\",\"claude-api\",\"workflow-authoring\",\"run\",\"run-skill-generator\",\"plugin-authoring\"],\"plugins\":[{\"name\":\"cc-plugin-sec-default\",\"path\":\"builtin\",\"source\":\"cc-plugin-sec-default@builtin\"},{\"name\":\"cc-plugin-agents-md\",\"path\":\"builtin\",\"source\":\"cc-plugin-agents-md@builtin\"},{\"name\":\"cc-plugin-plugin-authoring\",\"path\":\"builtin\",\"source\":\"cc-plugin-plugin-authoring@builtin\"}],\"capabilities\":[\"interrupt_receipt_v1\",\"interrupt_cancel_queued_v1\",\"interrupt_send_now_v1\",\"interrupt_requeue_taken_v1\",\"msg_lifecycle_v1\",\"request_marker_lists_v1\",\"ask_user_question_unanswered_v1\",\"lifecycle_wakeup_source_v1\",\"sdk_mcp_tools_list_changed\",\"sdk_mcp_manifests\",\"mcp_read_resource_v1\",\"mcp_tool_ui_meta_v1\",\"ui_surface_v1\",\"mcp_call_result_not_for_model_v1\"],\"analytics_disabled\":true,\"product_feedback_disabled\":true,\"uuid\":\"b1a8a49b-d0c9-4dd1-a57a-2eb7cb20e820\",\"memory_paths\":{\"auto\":\"/probe/cfg/projects/-probe-work/memory/\"},\"original_cwd\":\"/probe/work\",\"additional_directories\":[],\"messaging_socket_path\":\"/tmp/cc-socks/2500539.sock\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"per_turn_effort_active\":true,\"view_mode\":\"default\"}"}
+{"t": 12.48, "line": "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"QUEUED line B.\"},\"session_id\":\"43536997-53c9-4df5-9b0d-88306a147d43\",\"parent_tool_use_id\":null,\"uuid\":\"76294643-efba-44b9-9dc0-8848b510b44d\",\"timestamp\":\"2026-10-31T17:33:23.226Z\",\"isReplay\":true}"}
+{"t": 12.48, "line": "{\"type\":\"assistant\",\"message\":{\"id\":\"msg_0002\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-opus-5-5\",\"content\":[{\"type\":\"text\",\"text\":\"ANSWER to request 2\"}],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":10,\"output_tokens\":5,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0},\"context_management\":null},\"parent_tool_use_id\":null,\"session_id\":\"43536997-53c9-4df5-9b0d-88306a147d43\",\"uuid\":\"e61daf2d-c452-43e0-9863-ac6e8572e380\",\"timestamp\":\"2026-10-31T17:33:23.251Z\"}"}
+{"t": 12.49, "line": "{\"duration_api_ms\":12039,\"stop_reason\":\"end_turn\",\"session_id\":\"43536997-53c9-4df5-9b0d-88306a147d43\",\"total_cost_usd\":0.00028000000000000003,\"usage\":{\"input_tokens\":10,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":5,\"output_tokens_details\":{\"thinking_tokens\":0},\"server_tool_use\":{\"web_search_requests\":0,\"web_fetch_requests\":0},\"service_tier\":\"standard\",\"cache_creation\":{\"ephemeral_1h_input_tokens\":0,\"ephemeral_5m_input_tokens\":0},\"inference_geo\":\"\",\"iterations\":[],\"speed\":\"standard\",\"fallback_credit\":null},\"modelUsage\":{\"claude-opus-5-5\":{\"inputTokens\":20,\"outputTokens\":10,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00028000000000000003,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}},\"permission_denials\":[],\"terminal_reason\":\"completed\",\"fast_mode_state\":\"off\",\"fast_mode_disabled_reason\":\"sdk_opt_in_required\",\"subagent_stats\":{\"spawned\":0,\"requested\":{\"background\":0,\"foreground\":0,\"unset\":0},\"started_in_background\":0,\"max_depth\":0,\"spawned_by_subagents\":0,\"completed\":0,\"failed\":0,\"killed\":{\"parent\":0,\"user\":0,\"system\":0},\"refused\":{\"depth_limit\":0,\"concurrency_limit\":0,\"budget\":0},\"by_type\":{}},\"safety_stops\":0,\"is_error\":false,\"num_turns\":1,\"subtype\":\"success\",\"api_error_status\":null,\"result\":\"ANSWER to request 2\",\"ttft_ms\":34,\"type\":\"result\",\"duration_ms\":39,\"uuid\":\"fb89a6ae-1683-4df0-bb53-e54705c05671\",\"ttft_stream_ms\":33,\"time_to_request_ms\":28,\"first_content_frame_ms\":33,\"queued_turn_count\":0,\"result_index\":1,\"model_usage_since_last_result\":{\"claude-opus-5-5\":{\"inputTokens\":10,\"outputTokens\":5,\"cacheReadInputTokens\":0,\"cacheCreationInputTokens\":0,\"webSearchRequests\":0,\"costUSD\":0.00014000000000000001,\"contextWindow\":1000000,\"maxOutputTokens\":128000,\"thinkingTokens\":0,\"cacheCreationEphemeral5mInputTokens\":0,\"cacheCreationEphemeral1hInputTokens\":0,\"canonicalModel\":\"claude-opus-5-5\",\"provider\":\"firstParty\",\"costBasis\":\"list\"}}}"}
+{"t": 12.55, "exit": 0}
diff --git a/crates/mind-body/src/self_run/decide.rs b/crates/mind-body/src/self_run/decide.rs
index cdc96ed..72fe12c 100644
--- a/crates/mind-body/src/self_run/decide.rs
+++ b/crates/mind-body/src/self_run/decide.rs
@@ -7,45 +7,61 @@
//! into events, reads the clock once per event, and executes the action. A
//! timing rule is pinned here, by tables and by an enumeration of event orders.
//!
-//! The flush's turn begins at the first result after the flush is written (the
-//! turn already running ends there; the queued flush is the next one). The
-//! headroom counts only requests after that boundary, measured from the prefix
-//! the flush was written at, and the grace from the flush write (ruling
-//! `eureka-body:ruling:flush-always-gets-a-turn`, refined by the decider ruling).
-//! At most one action comes out of an event; a deadline that is already due
-//! yields its action at the next event, and `next_deadline` says it is now.
+//! Delivery is counted, not guessed: every stdin line the actuator writes (the
+//! start message, a tell, the flush) increments `written`; every replay echo of
+//! a line increments `consumed`. The echo is the point the CLI takes a line into
+//! a request, folded into the running turn or queued for the next, so one rule
+//! serves both. Idle is derived: no turn open and `written == consumed`.
//!
-//! A result ends a turn, never the session: it marks the session idle and asks
-//! for the briefs it answered to be closed. A brief waiting while idle is told.
-//! The session ends where its cache would be evicted (ruling
-//! `eureka-body:ruling:live-session-floor-cache-evicts`): at the last request's
-//! cache TTL less a margin, while no brief waits, the flush is asked, and stdin
-//! closes after the flush's own result. Under the run cap it closes at an idle
-//! rotation deadline; the PreCompact hook and the cap's margin ask the same
-//! flush the ceiling asks.
+//! The rules, in this order, while stdin is open and no signal is out:
+//! (1) a result that is blocked, or an error before any answer, closes stdin: no
+//! cache is worth keeping and a flush would fail the same way; (2) the first
+//! result after the flush's echo closes stdin, folded or queued alike; (3) a
+//! brief waiting and no flush written: tell it, idle or mid-turn; (4) the cap
+//! less `ROTATE_MARGIN_S`: ask the flush (rotation), idle or mid-turn; (5) idle
+//! with no brief waiting, at the last result's cache lifetime less a margin: ask
+//! the flush (idle). The ceiling asks the same flush from a request. Compaction
+//! is off in the CLI (`DISABLE_COMPACT=1`), so the flush is the only way a
+//! session ends short of its cache.
+//!
+//! The headroom counts the requests after the flush's echo, from the prefix the
+//! flush was written at. The grace interrupt is at the earlier of the grace
+//! after the flush write and the cap less `LADDER_S`, so the signal ladder
+//! finishes before the unit's cap (ruling
+//! `eureka-body:ruling:flush-always-gets-a-turn`). At most one action comes out
+//! of an event; a deadline that is already due yields its action at the next
+//! event, and `next_deadline` says it is now.
use std::collections::HashSet;
use chrono::{DateTime, Duration, Utc};
use super::{
- CEILING_TOKENS, Cause, ESCALATE_AFTER_S, EXIT_DRAIN_S, FLUSH_GRACE_S, FLUSH_HEADROOM_TOKENS, FLUSH_MARGIN_S, ROTATE_MARGIN_S, SelfRunOutcome, Stop, TTL_1H_S, TTL_5M_S,
- TTL_MARGIN_S,
+ CEILING_TOKENS, Cause, ESCALATE_AFTER_S, EXIT_DRAIN_S, FLUSH_GRACE_S, FLUSH_HEADROOM_TOKENS, LADDER_S, ROTATE_MARGIN_S, SelfRunOutcome, Stop, TTL_1H_S, TTL_5M_S, TTL_MARGIN_S,
};
+/// Why the flush was asked: the session's own end, three ways.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub(super) enum Why {
+ /// The context reached the ceiling.
+ Ceiling,
+ /// The unit's cap is near.
+ Rotation,
+ /// The cache would be evicted and nothing waits.
+ Idle,
+}
+
/// What the loop saw, already turned into a fact the decision can use.
#[derive(Clone, Debug, PartialEq, Eq)]
pub(super) enum Event {
/// A request of the main thread: its message id and the context it read.
Request { id: String, prefix: u64 },
- /// A turn ended. `ttl_1h`: the last request wrote its cache for an hour, else for five minutes.
- Result { ttl_1h: bool },
- /// A poll of the inbox: whether a brief waits in the spool.
+ /// The CLI took one of our stdin lines into a request (its replay echo).
+ Echo,
+ /// A turn ended. `ok`: not an error. `blocked`: the CLI refused the context. `ttl_1h`: the last request wrote its cache for an hour, else five minutes.
+ Result { ok: bool, blocked: bool, ttl_1h: bool },
+ /// A poll of the mind: whether a brief waits to be told.
Inbox { pending: bool },
- /// A user line carrying briefs was written: a turn has begun.
- Told,
- /// The PreCompact hook blocked an auto-compaction.
- PreCompact,
/// `waitpid` returned: the child's exit code, none when a signal ended it.
ChildExited(Option),
StdoutEof,
@@ -58,11 +74,9 @@ pub(super) enum Event {
#[derive(Clone, Debug, PartialEq, Eq)]
pub(super) enum Action {
None,
- WriteFlush,
- /// Claim the spool and write its briefs as one user line (the session is idle).
+ WriteFlush(Why),
+ /// Write the waiting briefs as one user line.
WriteTells,
- /// Resolve the briefs told up to this result.
- CloseBriefs,
CloseStdin,
/// To the child's whole process group.
Signal(Stop),
@@ -71,13 +85,16 @@ pub(super) enum Action {
#[derive(Clone, Debug, PartialEq, Eq)]
struct Flush {
+ /// The flush's line number: its echo is the `seq`-th.
+ seq: u32,
/// The prefix at which the flush was written: the headroom's base.
prefix: u64,
written: DateTime,
- /// A result has come since the write: the flush is the next turn.
- turn_begun: bool,
- /// A request of the flush's turn reached the headroom.
+ /// Its echo has come: the CLI took it into a request.
+ consumed: bool,
+ /// A request after its echo reached the headroom.
exhausted: bool,
+ why: Why,
}
#[derive(Clone, Debug, Default, PartialEq, Eq)]
@@ -85,8 +102,12 @@ pub(super) struct State {
seen: HashSet,
pub(super) requests: u64,
pub(super) prefix: u64,
- /// A turn is running or queued: the start message, a tell and the flush begin one; a result ends it.
- busy: bool,
+ /// Lines written to stdin, and lines the CLI echoed back as taken.
+ pub(super) written: u32,
+ pub(super) consumed: u32,
+ turn_open: bool,
+ /// An ok result has come: the session holds an answer worth its cache.
+ answered_once: bool,
last_result_at: Option>,
/// The cache lifetime the last result left, in seconds.
pub(super) ttl_s: i64,
@@ -95,6 +116,8 @@ pub(super) struct State {
cap: Option<(DateTime, i64)>,
stdin_closed: bool,
flush: Option,
+ /// An ok result answered the flush.
+ flush_answered_ok: bool,
/// The last signal attempted and when.
stopping: Option<(Stop, DateTime)>,
/// The strongest signal delivered.
@@ -102,17 +125,28 @@ pub(super) struct State {
exited: Option<(Option, DateTime)>,
eof: bool,
finished: bool,
+ /// The clock at the last decision: where a due action says "now".
+ at: Option>,
}
impl State {
- /// A session whose start message was just written: its first turn is running.
+ /// A session whose start message was just written.
pub(super) fn started(at: DateTime, run_cap_s: u64) -> Self {
- Self { busy: true, cap: Some((at, i64::try_from(run_cap_s).unwrap_or(i64::MAX))), ..Self::default() }
+ Self { written: 1, cap: Some((at, i64::try_from(run_cap_s).unwrap_or(i64::MAX))), at: Some(at), ..Self::default() }
}
- /// Seconds idle since the last result, none while a turn runs.
+ fn idle(&self) -> bool {
+ !self.turn_open && self.written == self.consumed
+ }
+
+ /// Seconds idle since the last result, none while a line or a turn is outstanding.
pub(super) fn idle_s(&self, now: DateTime) -> Option {
- (!self.busy).then(|| self.last_result_at.map_or(0, |at| (now - at).num_seconds()))
+ self.idle().then(|| self.last_result_at.map_or(0, |at| (now - at).num_seconds()))
+ }
+
+ /// The session went idle, its cache would have lapsed, and its idle flush was answered by an ok result.
+ pub(super) fn idle_end_answered(&self) -> bool {
+ self.flush_answered_ok && self.flush.as_ref().is_some_and(|flush| flush.why == Why::Idle)
}
}
@@ -129,6 +163,34 @@ fn cause(state: &State) -> Cause {
}
}
+/// When the flush's grace runs out: the grace after the write, never later than
+/// the point the signal ladder needs to finish before the unit's cap.
+fn grace_deadline(state: &State, flush: &Flush) -> DateTime {
+ let grace = flush.written + Duration::seconds(FLUSH_GRACE_S);
+ match state.cap {
+ Some((started, cap)) => grace.min(started + Duration::seconds(cap.saturating_sub(LADDER_S))),
+ None => grace,
+ }
+}
+
+/// What the session does next on its own, and when.
+enum Due {
+ Tells,
+ Flush(Why),
+}
+
+fn due(state: &State) -> Option<(DateTime, Due)> {
+ if state.stdin_closed || state.exited.is_some() || state.flush.is_some() {
+ return None;
+ }
+ if state.inbox {
+ return state.at.map(|at| (at, Due::Tells));
+ }
+ let rotation = state.cap.map(|(started, cap)| (started + Duration::seconds(cap.saturating_sub(ROTATE_MARGIN_S)), Due::Flush(Why::Rotation)));
+ let idle = state.idle().then_some(state.last_result_at).flatten().map(|last| (last + Duration::seconds(state.ttl_s - TTL_MARGIN_S), Due::Flush(Why::Idle)));
+ [rotation, idle].into_iter().flatten().min_by_key(|(at, _)| *at)
+}
+
/// The moment the loop must next be heard at, if any. A moment already past
/// means an action is due now.
pub(super) fn next_deadline(state: &State) -> Option> {
@@ -140,72 +202,41 @@ pub(super) fn next_deadline(state: &State) -> Option> {
}
let signals = match (&state.stopping, &state.flush) {
(Some((_, sent)), _) => return Some(*sent + Duration::seconds(ESCALATE_AFTER_S)),
- (None, Some(flush)) => Some(flush.written + Duration::seconds(FLUSH_GRACE_S)),
+ (None, Some(flush)) => Some(grace_deadline(state, flush)),
(None, None) => None,
};
- signals.into_iter().chain(lifecycle_deadline(state)).min()
+ signals.into_iter().chain(due(state).map(|(at, _)| at)).min()
}
-/// The deadline of the next lifecycle action: the flush margin while a turn
-/// runs; while idle, now for a pending tell or a finished flush, else the
-/// earlier of the rotation and the cache.
-fn lifecycle_deadline(state: &State) -> Option> {
- if state.stdin_closed {
- return None;
- }
- let rotation = |margin: i64| state.cap.map(|(started, cap)| started + Duration::seconds(cap - margin));
- if state.busy {
- return if state.flush.is_none() { rotation(FLUSH_MARGIN_S) } else { None };
- }
- let last = state.last_result_at?;
- if state.flush.as_ref().is_some_and(|flush| flush.turn_begun) || state.inbox {
- return Some(last);
- }
- [rotation(ROTATE_MARGIN_S), Some(last + Duration::seconds(state.ttl_s - TTL_MARGIN_S))].into_iter().flatten().min()
-}
-
-/// The flush is asked once, by the ceiling, the PreCompact hook, the cap's
-/// margin or the cache's end; never to a child whose input is closed or that has exited.
-fn ask_flush(state: &mut State, now: DateTime) -> bool {
+/// The flush is asked once, by the ceiling, the cap's margin or the cache's end;
+/// never to a child whose input is closed or that has exited.
+fn ask_flush(state: &mut State, now: DateTime, why: Why) -> bool {
if state.flush.is_some() || state.stdin_closed || state.exited.is_some() {
return false;
}
- // Written while idle, its turn begins at once; written mid-turn, it is the next one.
- state.flush = Some(Flush { prefix: state.prefix, written: now, turn_begun: !state.busy, exhausted: false });
- state.busy = true;
+ state.written += 1;
+ state.flush = Some(Flush { seq: state.written, prefix: state.prefix, written: now, consumed: false, exhausted: false, why });
true
}
-/// What the session does next on its own. Mid-turn: the flush at the cap's
-/// margin. Idle: close after the flush's own result or at the rotation; tell a
-/// waiting brief; ask the flush where the cache would be evicted.
+/// The lifecycle rules 3 to 5: tell a waiting brief, or ask the flush where it is due.
fn lifecycle(state: &mut State, now: DateTime) -> Action {
- if state.stdin_closed || state.exited.is_some() {
- return Action::None;
+ match due(state) {
+ Some((at, Due::Tells)) if at <= now => {
+ state.inbox = false;
+ state.written += 1;
+ Action::WriteTells
+ }
+ Some((at, Due::Flush(why))) if at <= now && ask_flush(state, now, why) => Action::WriteFlush(why),
+ _ => Action::None,
}
- if state.busy {
- let due = state.cap.is_some_and(|(started, cap)| now >= started + Duration::seconds(cap - FLUSH_MARGIN_S));
- return if due && ask_flush(state, now) { Action::WriteFlush } else { Action::None };
- }
- let last = state.last_result_at.unwrap_or(now);
- let rotate = state.cap.is_some_and(|(started, cap)| now >= started + Duration::seconds(cap - ROTATE_MARGIN_S));
- if rotate || state.flush.as_ref().is_some_and(|flush| flush.turn_begun) {
- state.stdin_closed = true;
- return Action::CloseStdin;
- }
- if state.inbox {
- return Action::WriteTells;
- }
- if now >= last + Duration::seconds(state.ttl_s - TTL_MARGIN_S) && ask_flush(state, now) {
- return Action::WriteFlush;
- }
- Action::None
}
pub(super) fn decide(mut state: State, event: Event, now: DateTime) -> (State, Action) {
if state.finished {
return (state, Action::None);
}
+ state.at = Some(now);
let mut action = Action::None;
match event {
Event::Request { id, prefix } => {
@@ -213,36 +244,40 @@ pub(super) fn decide(mut state: State, event: Event, now: DateTime) -> (Sta
state.requests += 1;
state.prefix = prefix;
if let Some(flush) = state.flush.as_mut()
- && flush.turn_begun
+ && flush.consumed
&& flush.prefix.checked_add(FLUSH_HEADROOM_TOKENS).is_some_and(|limit| prefix >= limit)
{
flush.exhausted = true;
}
- if prefix >= CEILING_TOKENS && ask_flush(&mut state, now) {
- action = Action::WriteFlush;
+ if prefix >= CEILING_TOKENS && ask_flush(&mut state, now, Why::Ceiling) {
+ action = Action::WriteFlush(Why::Ceiling);
}
}
}
- Event::Result { ttl_1h } => {
- state.busy = false;
+ Event::Echo => {
+ state.consumed += 1;
+ state.turn_open = true;
+ let consumed = state.consumed;
+ if let Some(flush) = state.flush.as_mut()
+ && consumed >= flush.seq
+ {
+ flush.consumed = true;
+ }
+ }
+ Event::Result { ok, blocked, ttl_1h } => {
+ state.turn_open = false;
state.last_result_at = Some(now);
state.ttl_s = if ttl_1h { TTL_1H_S } else { TTL_5M_S };
- // The turn already running ends here; a queued flush is the next one.
- if state.flush.as_mut().is_some_and(|flush| !std::mem::replace(&mut flush.turn_begun, true)) {
- state.busy = true;
+ let no_answer = !ok && !state.answered_once;
+ state.answered_once |= ok;
+ let flush_answered = state.flush.as_ref().is_some_and(|flush| flush.consumed);
+ state.flush_answered_ok |= flush_answered && ok;
+ if (blocked || no_answer || flush_answered) && !state.stdin_closed && state.exited.is_none() {
+ state.stdin_closed = true;
+ action = Action::CloseStdin;
}
- action = Action::CloseBriefs;
}
Event::Inbox { pending } => state.inbox = pending,
- Event::Told => {
- state.inbox = false;
- state.busy = true;
- }
- Event::PreCompact => {
- if ask_flush(&mut state, now) {
- action = Action::WriteFlush;
- }
- }
Event::ChildExited(code) => {
state.exited.get_or_insert((code, now));
}
@@ -286,7 +321,7 @@ pub(super) fn decide(mut state: State, event: Event, now: DateTime) -> (Sta
}
let how = match (&state.stopping, &state.flush) {
(Some((last, sent)), _) => (now >= *sent + Duration::seconds(ESCALATE_AFTER_S)).then(|| last.next()),
- (None, Some(flush)) => (flush.exhausted || now >= flush.written + Duration::seconds(FLUSH_GRACE_S)).then_some(Stop::Interrupt),
+ (None, Some(flush)) => (flush.exhausted || now >= grace_deadline(&state, flush)).then_some(Stop::Interrupt),
(None, None) => None,
};
match how {
diff --git a/crates/mind-body/src/self_run/inbox.rs b/crates/mind-body/src/self_run/inbox.rs
index e161547..d571395 100644
--- a/crates/mind-body/src/self_run/inbox.rs
+++ b/crates/mind-body/src/self_run/inbox.rs
@@ -1,26 +1,21 @@
//! Her Self's inbox: the briefs her Persona has given her Self, derived from the
-//! mind, spooled for the session, claimed exactly once, and closed by the answer.
+//! mind and told to the live session by the actuator's one stdin writer.
//!
//! The mind owns what her Self is asked: an in-force follow-up with owner
-//! `self-run` is a brief not yet answered. `derive` lists those that no closed
-//! run claims and that the session does not hold yet; `spool` writes each as
-//! `/-.json`. A claim renames entries into `/told/`
-//! and returns them: the rename is the exactly-once point, so the PostToolBatch
-//! hook (`inject`) and the actuator's idle tell race safely, and `told/` is the
-//! record of what this session has heard. A brief is closed by the result that
-//! answers it (`close`), and the same rule closes, at session start, the briefs
-//! a closed run claimed (`close_past`). Everything here is derived or a cache:
-//! the spool is lost with the unit and rebuilt from the mind.
+//! `self-run` whose source is a Persona turn's run is a brief. A follow-up her
+//! Self files for herself, or one whose source the mind does not hold, is not.
+//! `derive` lists the briefs the session has not been told (the told set is the
+//! actuator's process memory, a cache; the mind is the truth). Her Self resolves
+//! each brief she answers; `close` resolves the ones she left open at an idle
+//! end. `backlog` lists, and never closes, the in-force briefs a closed run
+//! claimed: the one-time sweep at deploy.
use std::collections::{HashMap, HashSet};
-use std::path::{Path, PathBuf};
-use anyhow::{Context, Result, anyhow};
+use anyhow::{Result, anyhow};
use chrono::{DateTime, Utc};
-use eureka_pipeline::{PipelineDocument, PipelineKind, PipelineRef, ResolutionOutcome};
+use eureka_pipeline::{PipelineDocument, PipelineKind, PipelineRef, ResolutionOutcome, RunTurn};
use huginn_mind::{PipelineAdmissionOutcome, PipelineFacts, PipelineStatusSummary};
-use serde::{Deserialize, Serialize};
-use serde_json::{Value, json};
use super::AGENT;
use crate::launch::closure;
@@ -28,17 +23,9 @@ use crate::queue::{MindPort, any_of, headers, in_force, of_kind};
/// The owner a follow-up names when it is a brief for her Self.
pub const OWNER: &str = "self-run";
-/// The entries this session has claimed.
-const TOLD: &str = "told";
-/// The plan line as of the lease grant, which a tell ends with.
-const PLAN: &str = "plan.txt";
-/// The PreCompact hook's marker: the ceiling is reached by the CLI's own measure.
-const PRE_COMPACT: &str = "pre-compact";
-/// What the hook event is called when its input does not say.
-const DEFAULT_EVENT: &str = "PostToolBatch";
/// One brief from her Persona: a follow-up of the mind, as the session hears it.
-#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Brief {
/// The follow-up's full id.
pub id: String,
@@ -53,35 +40,6 @@ impl Brief {
fn follow_up(&self) -> PipelineRef {
PipelineRef { kind: PipelineKind::FollowUp, id: self.id.as_str().into() }
}
-
- fn file_name(&self) -> String {
- let label = self.id.rsplit(':').next().unwrap_or(&self.id);
- format!("{:020}-{label}.json", self.ordinal)
- }
-}
-
-/// Where the hooks find the spool and the program they run.
-#[derive(Clone, Debug, PartialEq, Eq)]
-pub struct Hooks {
- pub spool: PathBuf,
- /// The absolute path of `mind-self-run`.
- pub injector: PathBuf,
-}
-
-fn quoted(path: &Path) -> String {
- format!("'{}'", path.to_string_lossy().replace('\'', "'\\''"))
-}
-
-impl Hooks {
- /// The `--settings` JSON: the tell between tool calls, and the block on auto-compaction.
- pub fn settings(&self) -> String {
- let command = format!("{} inject --spool {}", quoted(&self.injector), quoted(&self.spool));
- json!({"hooks": {
- "PostToolBatch": [{"hooks": [{"type": "command", "command": command}]}],
- "PreCompact": [{"matcher": "auto", "hooks": [{"type": "command", "command": format!("{command} --pre-compact")}]}],
- }})
- .to_string()
- }
}
/// The ids of the follow-ups a closed run claims, with the run each was claimed by.
@@ -97,122 +55,43 @@ fn claimed_by_closed(mind: &dyn MindPort) -> Result> {
Ok(claimed)
}
-/// Every in-force follow-up with owner `self-run`, oldest first.
+/// Every in-force brief, oldest first: owner `self-run`, sourced from a run of
+/// the mind whose turn is a Persona turn.
fn open_briefs(mind: &dyn MindPort) -> Result> {
- let mut briefs: Vec = headers(mind, &in_force(of_kind(PipelineKind::FollowUp)))?
+ let mut candidates: Vec<(Brief, String)> = headers(mind, &in_force(of_kind(PipelineKind::FollowUp)))?
.into_iter()
.filter_map(|summary| match summary.facts {
- PipelineFacts::FollowUp { repo, owner, item, .. } if owner.0 == OWNER => {
+ PipelineFacts::FollowUp { repo, owner, item, source, .. } if owner.0 == OWNER => {
let campaign = summary.id.id.0.split(':').next().unwrap_or("").to_string();
- Some(Brief { id: summary.id.id.0, campaign, repo: repo.0, item: item.0, ordinal: summary.admission.ordinal })
+ Some((Brief { id: summary.id.id.0, campaign, repo: repo.0, item: item.0, ordinal: summary.admission.ordinal }, source.id.0))
}
_ => None,
})
.collect();
+ if candidates.is_empty() {
+ return Ok(Vec::new());
+ }
+ let persona: HashSet = headers(mind, &any_of(of_kind(PipelineKind::Run), "root", &[&mind.instance().0]))?
+ .into_iter()
+ .filter(|run| matches!(run.facts, PipelineFacts::Run { turn: RunTurn::PersonaTurn, .. }))
+ .map(|run| run.id.id.0)
+ .collect();
+ candidates.retain(|(_, source)| persona.contains(source));
+ let mut briefs: Vec = candidates.into_iter().map(|(brief, _)| brief).collect();
briefs.sort_by_key(|brief| brief.ordinal);
Ok(briefs)
}
-/// Her open briefs that no closed run claims and the session does not hold yet.
-pub fn derive(mind: &dyn MindPort, spool: &Path) -> Result> {
- let held: HashSet = entries(spool)?.into_iter().chain(entries(&spool.join(TOLD))?).map(|brief| brief.id).collect();
- let mut open: Vec = open_briefs(mind)?.into_iter().filter(|brief| !held.contains(&brief.id)).collect();
- if !open.is_empty() {
- let claimed = claimed_by_closed(mind)?;
- open.retain(|brief| !claimed.contains_key(&brief.id));
- }
- Ok(open)
+/// Her briefs in force that the session has not been told.
+pub fn derive(mind: &dyn MindPort, told: &HashSet) -> Result> {
+ Ok(open_briefs(mind)?.into_iter().filter(|brief| !told.contains(&brief.id)).collect())
}
-fn entries(dir: &Path) -> Result> {
- let read = match std::fs::read_dir(dir) {
- Ok(read) => read,
- Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(Vec::new()),
- Err(error) => return Err(error).context("the inbox could not be read"),
- };
- let mut names: Vec = read.filter_map(|entry| entry.ok()).filter(|entry| entry.file_type().is_ok_and(|kind| kind.is_file())).map(|entry| entry.path()).collect();
- names.retain(|path| path.extension().is_some_and(|extension| extension == "json") && !path.file_name().is_some_and(|name| name.to_string_lossy().starts_with('.')));
- names.sort();
- names.iter().filter_map(|path| read_entry(path).transpose()).collect()
-}
-
-/// None where another claimer renamed the entry away since it was listed.
-fn read_entry(path: &Path) -> Result> {
- let text = match std::fs::read_to_string(path) {
- Ok(text) => text,
- Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(None),
- Err(error) => return Err(error).context("an inbox entry could not be read"),
- };
- serde_json::from_str(&text).map(Some).context("an inbox entry is not a brief")
-}
-
-fn write_entry(dir: &Path, brief: &Brief) -> Result<()> {
- std::fs::create_dir_all(dir).context("the inbox could not be made")?;
- let name = brief.file_name();
- // Written under a dot name, then renamed: a claimer never sees half an entry.
- let partial = dir.join(format!(".{name}"));
- std::fs::write(&partial, serde_json::to_vec(brief)?).context("an inbox entry could not be written")?;
- std::fs::rename(&partial, dir.join(name)).context("an inbox entry could not be placed")
-}
-
-/// Writes each brief into the spool.
-pub fn spool(spool: &Path, briefs: &[Brief]) -> Result<()> {
- briefs.iter().try_for_each(|brief| write_entry(spool, brief))
-}
-
-/// Records briefs as already heard (the start message carries them).
-pub fn mark_told(spool: &Path, briefs: &[Brief]) -> Result<()> {
- briefs.iter().try_for_each(|brief| write_entry(&spool.join(TOLD), brief))
-}
-
-/// Whether a brief waits in the spool.
-pub fn pending(spool: &Path) -> Result {
- Ok(!entries(spool)?.is_empty())
-}
-
-/// Takes every waiting entry. A rename into `told/` is the claim: an entry some
-/// other claimer renamed first is theirs, and is not returned here.
-pub fn claim(spool: &Path) -> Result> {
- let told = spool.join(TOLD);
- std::fs::create_dir_all(&told).context("the inbox could not be made")?;
- let mut taken = Vec::new();
- for brief in entries(spool)? {
- let name = brief.file_name();
- match std::fs::rename(spool.join(&name), told.join(&name)) {
- Ok(()) => taken.push(brief),
- Err(error) if error.kind() == std::io::ErrorKind::NotFound => {}
- Err(error) => return Err(error).context("an inbox entry could not be claimed"),
- }
- }
- Ok(taken)
-}
-
-/// The briefs this session has heard and not yet closed.
-pub fn told(spool: &Path) -> Result> {
- entries(&spool.join(TOLD))
-}
-
-/// Forgets heard briefs once they are closed.
-pub fn forget(spool: &Path, briefs: &[Brief]) {
- for brief in briefs {
- let _ = std::fs::remove_file(spool.join(TOLD).join(brief.file_name()));
- }
-}
-
-/// Starts the spool empty: a session hears only what it is told after it starts.
-pub fn reset(spool: &Path) -> Result<()> {
- match std::fs::remove_dir_all(spool) {
- Ok(()) => {}
- Err(error) if error.kind() == std::io::ErrorKind::NotFound => {}
- Err(error) => return Err(error).context("a stale inbox could not be removed"),
- }
- std::fs::create_dir_all(spool).context("the inbox could not be made")
-}
-
-/// The plan line a tell ends with: as of the lease grant.
-pub fn write_plan(spool: &Path, line: &str) -> Result<()> {
- std::fs::create_dir_all(spool).context("the inbox could not be made")?;
- std::fs::write(spool.join(PLAN), line).context("the plan line could not be written")
+/// Her briefs in force that a closed run claimed, with that run's id: a list for
+/// the one-time sweep at deploy. Nothing is admitted.
+pub fn backlog(mind: &dyn MindPort) -> Result> {
+ let claimed = claimed_by_closed(mind)?;
+ Ok(open_briefs(mind)?.into_iter().filter_map(|brief| claimed.get(&brief.id).cloned().map(|run| (brief, run))).collect())
}
/// One factual block per brief, then the plan line.
@@ -221,8 +100,12 @@ pub fn render(briefs: &[Brief], plan: &str) -> String {
.iter()
.map(|brief| {
format!(
- "A brief from your Persona: follow-up {} (campaign {}, repo {}): {}. Your answer closes it; work you take on beyond this answer is a follow-up of your own.",
- brief.id, brief.campaign, brief.repo, brief.item
+ "A brief from your Persona: follow-up {} (campaign {}, repo {}): {}. {}",
+ brief.id,
+ brief.campaign,
+ brief.repo,
+ brief.item,
+ resolving_sentence(&brief.id)
)
})
.collect();
@@ -232,6 +115,11 @@ pub fn render(briefs: &[Brief], plan: &str) -> String {
blocks.join("\n\n")
}
+/// What her Self does when she answers or declines a brief.
+pub fn resolving_sentence(id: &str) -> String {
+ format!("When you answer this brief, resolve follow-up {id} Recorded with your answer as rationale; if you decline it, resolve it Withdrawn with why.")
+}
+
/// Resolves Recorded each of `briefs` that is still in force, in one admission:
/// a brief her Self resolved herself is left as it is. Returns how many.
pub fn close(mind: &dyn MindPort, now: DateTime, session: &str, briefs: &[(Brief, String)], reason: &str) -> Result {
@@ -250,56 +138,5 @@ pub fn close(mind: &dyn MindPort, now: DateTime, session: &str, briefs: &[(
}
}
-/// The rule applied to the past: every open brief that a closed run claims is
-/// resolved Recorded, naming that run, whose closure holds the result.
-pub fn close_past(mind: &dyn MindPort, now: DateTime, session: &str) -> Result {
- let claimed = claimed_by_closed(mind)?;
- let answered: Vec<(Brief, String)> = open_briefs(mind)?
- .into_iter()
- .filter_map(|brief| {
- let run = claimed.get(&brief.id)?;
- let rationale = format!("Claimed by run {run}, which has closed; its closure holds the result.");
- Some((brief, rationale))
- })
- .collect();
- close(mind, now, session, &answered, "answered by a closed run")
-}
-
-/// What a hook prints, and the status it exits with.
-#[derive(Clone, Debug, PartialEq, Eq)]
-pub struct Injection {
- pub stdout: String,
- pub exit: i32,
-}
-
-/// The hook: data only. It claims the spool and prints what it claimed; with an
-/// agent id (a subagent's call) it prints nothing; `pre_compact` writes the
-/// marker and exits 2, which blocks the compaction. It reads neither the mind,
-/// chat nor the lease, and opens no socket.
-pub fn inject(spool: &Path, input: &str, pre_compact: bool) -> Result {
- if pre_compact {
- std::fs::create_dir_all(spool).context("the inbox could not be made")?;
- std::fs::write(spool.join(PRE_COMPACT), b"").context("the marker could not be written")?;
- return Ok(Injection { stdout: String::new(), exit: 2 });
- }
- let event: Value = serde_json::from_str(input).unwrap_or(Value::Null);
- if event.get("agent_id").is_some_and(|id| !id.is_null()) {
- return Ok(Injection { stdout: String::new(), exit: 0 });
- }
- let briefs = claim(spool)?;
- if briefs.is_empty() {
- return Ok(Injection { stdout: String::new(), exit: 0 });
- }
- let plan = std::fs::read_to_string(spool.join(PLAN)).unwrap_or_default();
- let name = event.get("hook_event_name").and_then(Value::as_str).unwrap_or(DEFAULT_EVENT);
- let stdout = json!({"hookSpecificOutput": {"hookEventName": name, "additionalContext": render(&briefs, &plan)}}).to_string();
- Ok(Injection { stdout, exit: 0 })
-}
-
-/// Whether the PreCompact hook fired since the last look; the marker is consumed.
-pub fn take_pre_compact(spool: &Path) -> bool {
- std::fs::remove_file(spool.join(PRE_COMPACT)).is_ok()
-}
-
#[cfg(test)]
mod tests;
diff --git a/crates/mind-body/src/self_run/probe/driver.py b/crates/mind-body/src/self_run/probe/driver.py
new file mode 100644
index 0000000..699d7e7
--- /dev/null
+++ b/crates/mind-body/src/self_run/probe/driver.py
@@ -0,0 +1,132 @@
+"""Drives the real claude CLI (stream-json, --replay-user-messages) against fake.py
+through one scenario and records its stdout and what was written to its stdin.
+
+ PROBE_SCENARIO folded | queued | ceiling-flush-folded | ceiling-flush-queued |
+ api-error-first | blocking-limit | compaction-off-360k
+ PROBE_BASE a scratch directory (config and work dirs are made in it)
+ PROBE_OUT where stream.jsonl is written: one JSON object per line,
+ {"t": seconds, "line": } or {"t": seconds, "sent": }
+ SCRUB 1 (default) sets CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 as the actuator does; 0 turns it off
+ CLAUDE the claude binary (default /opt/claude-code/2.1.312/claude)
+ PROBE_PORT the fake port (default 18611)
+
+DISABLE_COMPACT=1 is always set, as the actuator sets it. No credential is used.
+"""
+import json
+import os
+import subprocess
+import sys
+import threading
+import time
+import uuid
+
+SCENARIO = os.environ["PROBE_SCENARIO"]
+BASE = os.environ["PROBE_BASE"]
+OUT = os.environ["PROBE_OUT"]
+CFG = f"{BASE}/cfg"
+WORK = f"{BASE}/work"
+for d in (OUT, CFG, WORK):
+ os.makedirs(d, exist_ok=True)
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+import fake # noqa: E402
+
+port = fake.start(int(os.environ.get("PROBE_PORT", "18611")))
+json.dump({}, open(f"{CFG}/settings.json", "w"))
+json.dump({"hasCompletedOnboarding": True}, open(f"{CFG}/.claude.json", "w"))
+T0 = time.time()
+CLAUDE = os.environ.get("CLAUDE", "/opt/claude-code/2.1.312/claude")
+args = [CLAUDE, "-p", "--input-format", "stream-json", "--output-format", "stream-json", "--verbose", "--session-id", str(uuid.uuid4()),
+ "--max-turns", "20", "--permission-mode", "bypassPermissions", "--permission-prompts", "none", "--setting-sources", "user",
+ "--replay-user-messages", "--allowedTools", "Bash"]
+env = {"PATH": f"{os.path.dirname(CLAUDE)}:/usr/local/bin:/usr/bin:/bin", "HOME": CFG, "CLAUDE_CONFIG_DIR": CFG,
+ "CLAUDE_CODE_SUBPROCESS_ENV_SCRUB": os.environ.get("SCRUB", "1"), "DISABLE_COMPACT": "1", "LANG": "C.UTF-8",
+ "ANTHROPIC_API_KEY": "sk-ant-fake-probe", "ANTHROPIC_BASE_URL": f"http://127.0.0.1:{port}",
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1", "DISABLE_AUTOUPDATER": "1"}
+p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=open(f"{OUT}/stderr.txt", "w"), cwd=WORK, env=env, text=True)
+events = []
+out = open(f"{OUT}/stream.jsonl", "w")
+lock = threading.Lock()
+
+
+def record(entry):
+ with lock:
+ out.write(json.dumps(dict(t=round(time.time() - T0, 2), **entry)) + "\n")
+ out.flush()
+
+
+def reader():
+ for line in p.stdout:
+ record({"line": line.rstrip("\n")})
+ try:
+ events.append(json.loads(line))
+ except Exception:
+ pass
+
+
+threading.Thread(target=reader, daemon=True).start()
+
+
+def send(text):
+ p.stdin.write(json.dumps({"type": "user", "message": {"role": "user", "content": text}}) + "\n")
+ p.stdin.flush()
+ record({"sent": text})
+
+
+def results():
+ return sum(1 for e in events if e.get("type") == "result")
+
+
+def assistants():
+ return sum(1 for e in events if e.get("type") == "assistant")
+
+
+def wait(pred, limit=60):
+ end = time.time() + limit
+ while time.time() < end and not pred() and p.poll() is None:
+ time.sleep(0.05)
+
+
+FLUSH = "The context ceiling is reached. Admit to the mind what it lacks, close your run, and end."
+if SCENARIO == "folded":
+ send("SLEEPCMD turn C.")
+ time.sleep(8)
+ send("FOLDED line D.")
+ wait(lambda: results() >= 1)
+ time.sleep(3)
+elif SCENARIO == "queued":
+ send("SLOWEND turn A.")
+ time.sleep(4)
+ send("QUEUED line B.")
+ wait(lambda: results() >= 2)
+elif SCENARIO == "ceiling-flush-folded":
+ send("SLEEPCMD CEIL300 turn.")
+ wait(lambda: assistants() >= 1)
+ send(FLUSH)
+ wait(lambda: results() >= 1)
+ time.sleep(3)
+elif SCENARIO == "ceiling-flush-queued":
+ send("CEIL300 turn.")
+ wait(lambda: assistants() >= 1)
+ send(FLUSH)
+ wait(lambda: results() >= 2, 20)
+elif SCENARIO == "api-error-first":
+ send("APIERROR turn.")
+ wait(lambda: results() >= 1)
+elif SCENARIO == "blocking-limit":
+ send("BIGCONTEXT turn E.")
+ wait(lambda: results() >= 1)
+ send("after big F.")
+ wait(lambda: results() >= 2)
+elif SCENARIO == "compaction-off-360k":
+ send("MID360 turn E.")
+ wait(lambda: results() >= 1)
+ send("after 360 F.")
+ wait(lambda: results() >= 2)
+else:
+ sys.exit(f"unknown scenario {SCENARIO}")
+p.stdin.close()
+try:
+ p.wait(30)
+except Exception:
+ p.kill()
+record({"exit": p.returncode})
diff --git a/crates/mind-body/src/self_run/probe/fake.py b/crates/mind-body/src/self_run/probe/fake.py
new file mode 100644
index 0000000..d005055
--- /dev/null
+++ b/crates/mind-body/src/self_run/probe/fake.py
@@ -0,0 +1,102 @@
+"""A fake Messages API for probing the claude CLI stream-json session: it answers
+every request with a scripted text or a Bash tool call and reports scripted
+usage. A marker in the newest user text picks the behaviour:
+
+ SLEEPCMD answer with a 25 s Bash tool call (the turn stays open)
+ SLOWEND hold the closing text request for 12 s
+ APIERROR answer 400 (the CLI reports an api_error result)
+ CEIL300 report 300000 input tokens (the actuator ceiling)
+ MID360 report 360000 input tokens
+ BIGCONTEXT report 990000 input tokens (the CLI blocking limit)
+
+Holds no credential: the CLI is pointed at it with a fake key.
+"""
+import json
+import http.server
+import os
+import threading
+import time
+
+OUT = os.environ["PROBE_OUT"]
+T0 = time.time()
+N = [0]
+LOCK = threading.Lock()
+
+
+def sse(w, ev, data):
+ w.write(f"event: {ev}\ndata: {json.dumps(data)}\n\n".encode())
+ w.flush()
+
+
+def reply(h, code, body):
+ h.send_response(code)
+ h.send_header("content-type", "application/json")
+ h.send_header("content-length", str(len(body)))
+ h.end_headers()
+ h.wfile.write(body)
+
+
+class H(http.server.BaseHTTPRequestHandler):
+ protocol_version = "HTTP/1.1"
+
+ def log_message(self, *a):
+ pass
+
+ def do_GET(self):
+ reply(self, 200, b"{}")
+
+ def do_POST(self):
+ body = self.rfile.read(int(self.headers.get("content-length", 0)))
+ with LOCK:
+ N[0] += 1
+ n = N[0]
+ try:
+ req = json.loads(body)
+ except Exception:
+ req = {}
+ msgs = req.get("messages", [])
+ last_assistant = max([i for i, m in enumerate(msgs) if m.get("role") == "assistant"], default=-1)
+ tail = json.dumps(msgs[last_assistant + 1:])
+ tools = [t.get("name") for t in req.get("tools", [])]
+ rec = {"n": n, "t": round(time.time() - T0, 2), "path": self.path, "nmsgs": len(msgs), "main": "Bash" in tools, "tail": tail[-500:]}
+ open(f"{OUT}/requests.jsonl", "a").write(json.dumps(rec) + "\n")
+ if "count_tokens" in self.path:
+ reply(self, 200, json.dumps({"input_tokens": 100}).encode())
+ return
+ if "APIERROR" in tail:
+ reply(self, 400, json.dumps({"type": "error", "error": {"type": "invalid_request_error", "message": "probe: bad request"}}).encode())
+ return
+ if "SLEEPCMD" in tail and '"tool_result"' not in tail:
+ block = {"type": "tool_use", "id": f"toolu_{n:04d}", "name": "Bash", "input": {}}
+ delta = {"type": "input_json_delta", "partial_json": json.dumps({"command": "python3 -c 'import time; time.sleep(25)'", "description": "probe wait"})}
+ stop = "tool_use"
+ else:
+ block = {"type": "text", "text": ""}
+ delta = {"type": "text_delta", "text": f"ANSWER to request {n}"}
+ stop = "end_turn"
+ tokens = 10
+ for marker, value in (("CEIL300", 300000), ("MID360", 360000), ("BIGCONTEXT", 990000)):
+ if marker in tail:
+ tokens = value
+ usage = {"input_tokens": tokens, "output_tokens": 5, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0}
+ self.send_response(200)
+ self.send_header("content-type", "text/event-stream")
+ self.send_header("cache-control", "no-cache")
+ self.send_header("connection", "close")
+ self.end_headers()
+ w = self.wfile
+ sse(w, "message_start", {"type": "message_start", "message": {"id": f"msg_{n:04d}", "type": "message", "role": "assistant", "model": req.get("model", "x"), "content": [], "stop_reason": None, "stop_sequence": None, "usage": usage}})
+ sse(w, "content_block_start", {"type": "content_block_start", "index": 0, "content_block": block})
+ if "SLOWEND" in tail and stop == "end_turn":
+ time.sleep(12)
+ sse(w, "content_block_delta", {"type": "content_block_delta", "index": 0, "delta": delta})
+ sse(w, "content_block_stop", {"type": "content_block_stop", "index": 0})
+ sse(w, "message_delta", {"type": "message_delta", "delta": {"stop_reason": stop, "stop_sequence": None}, "usage": {"output_tokens": 5}})
+ sse(w, "message_stop", {"type": "message_stop"})
+ self.close_connection = True
+
+
+def start(port):
+ server = http.server.ThreadingHTTPServer(("127.0.0.1", port), H)
+ threading.Thread(target=server.serve_forever, daemon=True).start()
+ return port
diff --git a/crates/mind-body/tests/self_run.rs b/crates/mind-body/tests/self_run.rs
index a5df03a..2300795 100644
--- a/crates/mind-body/tests/self_run.rs
+++ b/crates/mind-body/tests/self_run.rs
@@ -46,46 +46,6 @@ fn the_run_cap_must_be_a_positive_number_of_seconds_and_the_runtime_directory_mu
assert!(!message.contains("MIND_SELF_RUN_CAP_S") && message.contains("RUNTIME_DIRECTORY is not set"), "{message}");
}
-/// The hook `claude` runs in the session: `mind-self-run inject --spool ` reads the hook's
-/// JSON on stdin and prints what the spool holds as context, exit 0; with `--pre-compact` it
-/// blocks the compaction with exit 2; without a spool it is a usage error.
-#[test]
-fn inject_prints_the_spooled_briefs_as_hook_context_and_blocks_a_compaction() {
- use std::io::Write;
- use std::process::Stdio;
- let spool = std::env::temp_dir().join(format!("mind-self-run-inject-{}", std::process::id()));
- std::fs::create_dir_all(&spool).unwrap();
- std::fs::write(
- spool.join("00000000000000000007-b7.json"),
- r#"{"id":"eureka-body:follow_up:b7","campaign":"eureka-body","repo":"GameCult/Huginn","item":"Wire the thing.","ordinal":7}"#,
- )
- .unwrap();
- let inject = |extra: &[&str], input: &str| {
- let mut child = Command::new(env!("CARGO_BIN_EXE_mind-self-run"))
- .args(["inject", "--spool", spool.to_str().unwrap()])
- .args(extra)
- .stdin(Stdio::piped())
- .stdout(Stdio::piped())
- .stderr(Stdio::piped())
- .spawn()
- .unwrap();
- child.stdin.take().unwrap().write_all(input.as_bytes()).unwrap();
- child.wait_with_output().unwrap()
- };
- let blocked = inject(&["--pre-compact"], "{}");
- assert_eq!((blocked.status.code(), blocked.stdout.is_empty()), (Some(2), true));
- assert!(String::from_utf8_lossy(&blocked.stderr).contains("compaction blocked"), "the block says why");
- let printed = inject(&[], r#"{"hook_event_name":"PostToolBatch"}"#);
- assert_eq!(printed.status.code(), Some(0));
- assert!(printed.stderr.is_empty(), "a tell prints nothing on stderr");
- let text = String::from_utf8_lossy(&printed.stdout);
- assert!(text.contains("hookSpecificOutput") && text.contains("eureka-body:follow_up:b7") && text.contains("Wire the thing."), "{text}");
- assert!(inject(&[], "{}").stdout.is_empty(), "claimed once");
- let bare = Command::new(env!("CARGO_BIN_EXE_mind-self-run")).arg("inject").stdin(Stdio::null()).output().unwrap();
- assert_eq!(bare.status.code(), Some(2));
- std::fs::remove_dir_all(&spool).unwrap();
-}
-
#[test]
fn without_an_instance_or_with_a_stray_argument_it_exits_2_with_the_usage_and_echoes_nothing() {
let canary = "canary-argument-3f9a";
@@ -96,6 +56,8 @@ fn without_an_instance_or_with_a_stray_argument_it_exits_2_with_the_usage_and_ec
vec!["--instance", NO_SUCH_INSTANCE, "--instance", canary],
vec![canary],
vec!["--resume", canary],
+ // The hook subcommand is gone: it is a stray argument now.
+ vec!["inject", "--spool", canary],
] {
let output = self_run(&args);
assert_eq!(output.status.code(), Some(2), "{args:?}");
@@ -361,9 +323,10 @@ mod lane {
let body = format!(
"read -r -u \"$CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR\" cred
echo journal-line >&2
-echo '{first}'\necho '{second}'\nread -t 5 start\nread -t 5 flush\necho \"$start\" >> {record}\necho \"$flush\" >> {record}\necho \"$SELF_RUN_ENV_CANARY\" >> {record}\necho \"$cred\" >> {record}\necho '{{\"type\":\"result\"}}'\necho '{{\"type\":\"result\"}}'\nwhile read more; do :; done\nexit 0",
+echo '{first}'\necho '{second}'\nread -t 5 start\nread -t 5 flush\necho \"$start\" >> {record}\necho \"$flush\" >> {record}\necho \"$SELF_RUN_ENV_CANARY\" >> {record}\necho \"$cred\" >> {record}\necho '{echo}'\necho '{echo}'\necho '{{\"type\":\"result\"}}'\nwhile read more; do :; done\nexit 0",
first = request("msg_1", 100),
second = request("msg_2", 299_999),
+ echo = r#"{"type":"user","isReplay":true,"message":{"role":"user","content":"x"}}"#,
record = bin.path().join("record").display(),
);
let record = fake_claude(bin.path(), &body);
@@ -382,7 +345,7 @@ echo '{first}'\necho '{second}'\nread -t 5 start\nread -t 5 flush\necho \"$start
let mut lines = recorded.lines();
let argv = lines.next().unwrap();
assert!(argv.contains(&format!("--session-id {LANE_SESSION}")) && !argv.contains("--max-budget-usd"), "{argv}");
- assert!(argv.starts_with("-p --input-format stream-json"), "{argv}");
+ assert!(argv.starts_with("-p --input-format stream-json") && argv.contains("--replay-user-messages") && !argv.contains("--settings"), "{argv}");
assert!(lines.next().unwrap().contains("yggdrasil:run:selfrun-lane"), "the start message names her run");
let flush = lines.next().unwrap();
assert!(flush.contains(FLUSH_MESSAGE) && flush.contains("\"type\":\"user\""), "the flush went to the child's stdin: {flush}");