eureka-pipeline, huginn-mind: a Sleep turn shares the Persona slot, a consolidation is a pair
RunTurn gains Sleep and RunSlot/RunTurn::slot (PersonaTurn and Sleep hold the Persona slot, a Self run the other); live_holder, launch holders and the unit template compare slots, not turns. MemoryOrigin gains Sleep { run }. Admission refuses an unpaired consolidation both ways (MindRefusal::UnpairedConsolidation): a memory that consolidates others without a Superseded resolution of each by it in the batch, and a memory Superseded by memories that do not name it. Published schemas regenerated.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c1c3e7d6fe
commit
79edda37f6
15 changed files with 293 additions and 29 deletions
|
|
@ -25,7 +25,7 @@ use chrono::{DateTime, Duration, Utc};
|
|||
use cultnet_rs::Selection;
|
||||
use eureka_pipeline::{
|
||||
Date, Label, PipelineDocument, PipelineKind, PipelineQuestion, PipelineRef, PipelineResolution, PipelineRun, QuestionOption, ResolutionOutcome,
|
||||
RunOperator, RunTurn, Slug, pipeline_key,
|
||||
RunOperator, RunSlot, RunTurn, Slug, pipeline_key,
|
||||
};
|
||||
use huginn_mind::{
|
||||
MindRefusal, PipelineAdmissionOutcome, PipelineDocumentSummary, PipelineFacts,
|
||||
|
|
@ -115,12 +115,12 @@ impl Default for SystemdLauncher {
|
|||
}
|
||||
}
|
||||
|
||||
/// The unit template of one turn, named only through `unit()`, which start,
|
||||
/// The unit template of one slot, named only through `unit()`, which start,
|
||||
/// alive and stop all call.
|
||||
fn template(turn: RunTurn) -> &'static str {
|
||||
match turn {
|
||||
RunTurn::PersonaTurn => "mind-persona",
|
||||
RunTurn::SelfRun => "mind-self",
|
||||
match turn.slot() {
|
||||
RunSlot::Persona => "mind-persona",
|
||||
RunSlot::SelfRun => "mind-self",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -340,7 +340,7 @@ pub(crate) fn holders(mind: &dyn MindPort, instance: &Slug, turn: RunTurn) -> Re
|
|||
let runs = headers(mind, &in_force(any_of(of_kind(PipelineKind::Run), "root", &[&instance.0])))?;
|
||||
Ok(runs
|
||||
.into_iter()
|
||||
.filter(|run| matches!(run.facts, PipelineFacts::Run { turn: held, operated_by: RunOperator::Mind, .. } if held == turn))
|
||||
.filter(|run| matches!(run.facts, PipelineFacts::Run { turn: held, operated_by: RunOperator::Mind, .. } if held.slot() == turn.slot()))
|
||||
.collect())
|
||||
}
|
||||
|
||||
|
|
@ -384,7 +384,7 @@ pub fn open_and_launch(ports: &Ports, request: LaunchRequest) -> Result<LaunchOu
|
|||
if grant.instance() != &instance {
|
||||
return Ok(LaunchOutcome::Refused(Declined::GrantForOtherInstance));
|
||||
}
|
||||
if turn == RunTurn::PersonaTurn && !claims.is_empty() {
|
||||
if turn != RunTurn::SelfRun && !claims.is_empty() {
|
||||
return Ok(LaunchOutcome::Refused(Declined::PersonaRunTakesNoClaims));
|
||||
}
|
||||
let now = ports.clock.now();
|
||||
|
|
@ -631,6 +631,32 @@ mod tests {
|
|||
assert_eq!(*rig.launcher.started.borrow(), vec![(Slug(INSTANCE.into()), RunTurn::SelfRun)]);
|
||||
}
|
||||
|
||||
/// A Sleep run and a Persona session are one slot of hers: one unit, one live holder, in either order.
|
||||
#[test]
|
||||
fn a_sleep_run_and_a_persona_run_share_one_slot() {
|
||||
let rig = Rig::new();
|
||||
let LaunchOutcome::Launched { run } = rig.launch(RunTurn::Sleep, &[]) else { panic!("not launched") };
|
||||
rig.at(1);
|
||||
assert_eq!(rig.launch(RunTurn::PersonaTurn, &[]), LaunchOutcome::Busy { run: run.clone() }, "a live Sleep holds the Persona slot");
|
||||
assert_eq!(rig.launch(RunTurn::Sleep, &[]), LaunchOutcome::Busy { run: run.clone() });
|
||||
assert!(matches!(rig.launch(RunTurn::SelfRun, &[]), LaunchOutcome::Launched { .. }), "a Self run is the other slot");
|
||||
let ports = Ports { mind: &rig.mind, launcher: &rig.launcher, clock: &rig.clock, host: "yggdrasil-host" };
|
||||
assert!(slot(&ports, rig.mind.instance(), RunTurn::PersonaTurn, rig.clock.now()).unwrap().live.is_some());
|
||||
assert_eq!(unit(&eureka(), RunTurn::Sleep).unwrap(), "mind-persona@eureka.service", "the night runs in the Persona unit");
|
||||
rig.mind.committed(vec![close(run, recorded())]);
|
||||
rig.at(2);
|
||||
let LaunchOutcome::Launched { run: persona } = rig.launch(RunTurn::PersonaTurn, &[]) else { panic!("not launched") };
|
||||
rig.at(3);
|
||||
assert_eq!(rig.launch(RunTurn::Sleep, &[]), LaunchOutcome::Busy { run: persona }, "a live Persona session holds the slot a night needs");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_sleep_run_takes_no_claims() {
|
||||
let rig = Rig::new();
|
||||
assert_eq!(rig.launch(RunTurn::Sleep, &[spec_ref("x")]), LaunchOutcome::Refused(Declined::PersonaRunTakesNoClaims));
|
||||
assert_eq!(rig.runs(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_unit_started_names_the_minds_instance() {
|
||||
let rig = Rig::new();
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ pub(crate) fn people_of(memory: &eureka_pipeline::PipelineMemory) -> Vec<String>
|
|||
let origin: &[eureka_pipeline::Short] = match &memory.origin {
|
||||
MemoryOrigin::Room { heard_from, .. } => heard_from,
|
||||
MemoryOrigin::Direct { with, .. } => with,
|
||||
MemoryOrigin::Wake | MemoryOrigin::SelfRun { .. } => &[],
|
||||
MemoryOrigin::Wake | MemoryOrigin::SelfRun { .. } | MemoryOrigin::Sleep { .. } => &[],
|
||||
};
|
||||
memory.about.iter().chain(origin).map(|id| id.0.clone()).collect()
|
||||
}
|
||||
|
|
@ -206,6 +206,7 @@ pub(crate) fn origin_phrase(origin: &MemoryOrigin, names: &BTreeMap<&str, &str>)
|
|||
MemoryOrigin::Direct { with, .. } => format!("privately, with {}", who(with.iter().map(|id| id.0.as_str()), names)),
|
||||
MemoryOrigin::Wake => "on a wake".to_string(),
|
||||
MemoryOrigin::SelfRun { run } => format!("in your Self run {}", run.0),
|
||||
MemoryOrigin::Sleep { run } => format!("in your sleep {}", run.0),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,12 +55,17 @@ pub(crate) struct Recording {
|
|||
pub(crate) fail: Cell<bool>,
|
||||
/// One named instance whose unit never starts.
|
||||
pub(crate) fail_for: RefCell<Option<Slug>>,
|
||||
running: RefCell<Vec<(Slug, RunTurn)>>,
|
||||
running: RefCell<Vec<(Slug, eureka_pipeline::RunSlot)>>,
|
||||
}
|
||||
|
||||
impl Recording {
|
||||
pub(crate) fn kill(&self, turn: RunTurn) {
|
||||
self.running.borrow_mut().retain(|unit| *unit != (Slug(INSTANCE.into()), turn));
|
||||
self.running.borrow_mut().retain(|unit| *unit != (Slug(INSTANCE.into()), turn.slot()));
|
||||
}
|
||||
|
||||
/// `kill` for a named instance.
|
||||
pub(crate) fn kill_as(&self, instance: &Slug, turn: RunTurn) {
|
||||
self.running.borrow_mut().retain(|unit| *unit != (instance.clone(), turn.slot()));
|
||||
}
|
||||
|
||||
pub(crate) fn revive(&self, turn: RunTurn) {
|
||||
|
|
@ -69,7 +74,7 @@ impl Recording {
|
|||
|
||||
/// `revive` for a named instance.
|
||||
pub(crate) fn revive_as(&self, instance: &Slug, turn: RunTurn) {
|
||||
self.running.borrow_mut().push((instance.clone(), turn));
|
||||
self.running.borrow_mut().push((instance.clone(), turn.slot()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -79,12 +84,12 @@ impl Launcher for Recording {
|
|||
return Err(anyhow!("refused"));
|
||||
}
|
||||
self.started.borrow_mut().push((instance.clone(), turn));
|
||||
self.running.borrow_mut().push((instance.clone(), turn));
|
||||
self.running.borrow_mut().push((instance.clone(), turn.slot()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn alive(&self, instance: &Slug, turn: RunTurn) -> bool {
|
||||
self.running.borrow().contains(&(instance.clone(), turn))
|
||||
self.running.borrow().contains(&(instance.clone(), turn.slot()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue