self_run resume: existing tests learn the session journal lines and the keep order

This commit is contained in:
Meta Vens 2026-11-06 23:14:13 +01:00 • committed by Meta Vens
commit 30fb34917e
3 changed files with 7 additions and 7 deletions

View file

@ -167,7 +167,7 @@ impl Ran {
/// What the unit's stdout holds apart from the decisions the actuator journals.
fn lines(&self) -> String {
self.out.lines().filter(|line| !line.starts_with("decision ")).map(|line| format!("{line}\n")).collect()
self.out.lines().filter(|line| !line.starts_with("decision ") && !line.starts_with("session ")).map(|line| format!("{line}\n")).collect()
}
fn count(&self, wanted: &Event) -> usize {
@ -548,7 +548,7 @@ fn records_that_share_a_message_id_count_once_and_subagent_records_never_move_th
steps.insert(3, Out(subagent("msg_sub", 999_999)));
let ran = go(steps);
assert_eq!(
ran.out,
ran.lines(),
"request 1 prefix 84210
request 2 prefix 100751
request 3 prefix 117174
@ -874,8 +874,8 @@ fn a_child_that_exited_is_never_signalled_however_long_its_stream_stays_open() {
#[test]
fn the_outcome_names_how_it_ended_and_the_exit_status_follows_the_childs_code() {
let own = carry_with(&Seen::of(&with_run()), vec![Out(at("m1", 10)), Out(result_line())], Some(0), false);
assert_eq!(own.outcome.as_ref().unwrap(), &SelfRunOutcome::Ended { cause: Cause::Own, code: Some(0), requests: 1, prefix: 10, warm_until: Some(at_start() + ChronoDuration::seconds(TTL_1H_S - TTL_MARGIN_S)) });
assert_eq!(own.outcome.as_ref().unwrap().to_string(), "ended: own code 0 requests 1 prefix 10 warm until 2026-10-09T14:14:00Z");
assert_eq!(own.outcome.as_ref().unwrap(), &SelfRunOutcome::Ended { cause: Cause::Own, code: Some(0), requests: 1, prefix: 10, warm_until: None });
assert_eq!(own.outcome.as_ref().unwrap().to_string(), "ended: own code 0 requests 1 prefix 10");
assert_eq!(own.outcome.unwrap().exit_status(), 0);
let flushed = carry_with(&Seen::of(&with_run()), vec![Out(at("m1", CEILING_TOKENS)), Out(result_line())], Some(0), false);
@ -1111,7 +1111,7 @@ exit 0");
let mut out = Vec::new();
let outcome = carry(&Seen::of(&mind), &SystemClock, &FakeLender::new(Answer::Grant), &Spawn(program), TEST_CAP_S, &mut out).unwrap();
assert_eq!(outcome, SelfRunOutcome::Ended { cause: Cause::FlushRequested, code: Some(0), requests: 2, prefix: 300_000, warm_until: None });
let printed: String = String::from_utf8(out).unwrap().lines().filter(|line| !line.starts_with("decision ")).map(|line| format!("{line}\n")).collect();
let printed: String = String::from_utf8(out).unwrap().lines().filter(|line| !line.starts_with("decision ") && !line.starts_with("session ")).map(|line| format!("{line}\n")).collect();
assert_eq!(printed, "request 1 prefix 10
request 2 prefix 300000
result subtype=success is_error=false: The answer.

View file

@ -56,7 +56,7 @@ fn a_lease_is_asked_for_before_claude_starts_for_the_units_runtime_cap() {
let ran = go(vec![Out(result_line())]);
assert_eq!(ran.asked, vec![LeaseRequest { expires_at_unix_ms: u64::try_from(at_start().timestamp_millis()).unwrap() + TEST_CAP_S * 1000 }], "the request is only the expiry, the cap the unit gave");
assert_eq!(ran.all.first(), Some(&Event::Lent), "nothing happens before the lease");
assert_eq!(ran.all.get(1), Some(&Event::Spawned), "the child is the next thing");
assert_eq!(ran.all.get(2), Some(&Event::Spawned), "the child is the next thing after the (empty) kept conversation is cleared");
}
#[test]

View file

@ -216,7 +216,7 @@ fn keeping_one_conversation_removes_the_one_before_it_and_clearing_leaves_the_di
write(&state.path().join("session/stray.jsonl.tmp"), "half");
spawner.keep(Some((newer, until))).unwrap();
assert_eq!(names(&state.path().join("session")), ["kept.json", &format!("{newer}.jsonl")], "at most one transcript, and no stray");
assert_eq!(names(&state.path().join("session")), [format!("{newer}.jsonl"), "kept.json".to_string()], "at most one transcript, and no stray");
assert_eq!(spawner.kept(), Some(Kept { session: newer, transcript: newer_path, warm_until: until, same_seed: true }));
spawner.keep(None).unwrap();