mind-persona tests: a mind with no campaign; doctrine re-read across turns

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-31 01:27:06 +01:00
commit 35677d7ff0
2 changed files with 19 additions and 7 deletions

View file

@ -1012,12 +1012,15 @@ fn doctrine_files_lead_the_instructions_in_the_configured_order_ahead_of_the_per
#[test]
fn doctrine_is_read_at_every_turn_start() {
let rig = Rig::new(vec![operator_says(1, "a"), operator_says(2, "b")], &[says(&[("swarm", "x")]), says(&[])]);
let rig = Rig::new(vec![operator_says(1, "a")], &[says(&[("swarm", "x")]), says(&[])]);
let path = write_doctrine(&rig, "d.md", "BEFORE-BUMP");
rig.chat.on_send.replace(Some(Box::new({
let path = path.clone();
move || std::fs::write(&path, "AFTER-BUMP").unwrap()
})));
let (deliveries, bump) = (rig.chat.deliveries.clone(), path.clone());
*rig.connector.during.borrow_mut() = Some(Box::new(move || {
if deliveries.borrow().len() == 1 {
deliveries.borrow_mut().push(operator_says(2, "b"));
std::fs::write(&bump, "AFTER-BUMP").unwrap();
}
}));
rig.go_with(&Config { doctrine: vec![path], max_turns: 3, ..config() });
let requests = rig.connector.requests.borrow();
assert_eq!(requests.len(), 2);
@ -1104,8 +1107,8 @@ fn a_self_run_naming_a_listed_campaign_passes_the_campaign_check() {
#[test]
fn with_no_campaign_in_force_the_instructions_say_so_and_the_schema_allows_no_start() {
let rig = Rig::new(vec![operator_says(1, "a")], &[says(&[])]);
rig.mind.committed(vec![close(PipelineRef { kind: K::Campaign, id: format!("{CAMPAIGN}:campaign:self").as_str().into() }, recorded())]);
let mut rig = Rig::new(vec![operator_says(1, "a")], &[says(&[])]);
rig.mind = TestMind::without_campaigns();
rig.go();
let requests = rig.connector.requests.borrow();
assert!(requests[0].instructions.contains("No campaign is in force"), "{}", requests[0].instructions);

View file

@ -92,6 +92,15 @@ impl TestMind {
Self::seeded_as(INSTANCE)
}
/// A mind holding only its identity and the repo's stewardship: no campaign.
pub(crate) fn without_campaigns() -> Self {
let dir = TempDir::new().unwrap();
let mind = Mind::open(dir.path(), &Slug(INSTANCE.into())).unwrap();
let this = Self { _dir: dir, instance: Slug(INSTANCE.into()), mind: RefCell::new(mind), now: Cell::new(at(0)) };
this.put(vec![instance(INSTANCE), stewardship(INSTANCE)]);
this
}
/// The same, for another instance name.
pub(crate) fn seeded_as(name: &str) -> Self {
let dir = TempDir::new().unwrap();