huginn-mind: admission refuses a second live run of hers of one turn (AlreadyLive)

Ruling one-live-self-run, decided where batches are serialized: run_rule
(was run_claims_rule) now also refuses an opening or reinstated run whose
instance and turn already have an in-force operated_by Mind run. The
fixture run() is an operator's run; mind_run() is hers. Unverified: this
commit has not been built when written; verification follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-09 22:48:01 +02:00
commit ff259a16bb
6 changed files with 166 additions and 14 deletions

View file

@ -7,8 +7,8 @@
use cultcache_rs::CultCacheEnvelope;
use eureka_pipeline::{
OrgRepo, PipelineDocument, PipelineKind, PipelineRef, PipelineResolution, PipelineStewardship, ResolutionOutcome,
Short, Slug,
OrgRepo, PipelineDocument, PipelineKind, PipelineRef, PipelineResolution, PipelineRun, PipelineStewardship, ResolutionOutcome,
RunOperator, Short, Slug,
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
@ -229,6 +229,29 @@ impl Docs {
})
}
/// The in-force run of hers, other than `run_key`, that holds the slot of
/// the turn `run` is of: ruling one-live-self-run's one live run per
/// instance and turn, asked by a run's opening and by the withdrawal that
/// would put a closed run back in force. An operator's run neither holds
/// the slot nor is refused for it.
pub(crate) fn live_holder(&self, run_key: &str, run: &PipelineRun) -> Option<&str> {
if run.operated_by == RunOperator::Operator {
return None;
}
self.of_kind(PipelineKind::Run).find_map(|(other_key, document)| match document {
PipelineDocument::Run(other)
if other_key != run_key
&& other.instance == run.instance
&& other.turn == run.turn
&& other.operated_by == RunOperator::Mind
&& self.in_force(PipelineKind::Run, other_key) =>
{
Some(other_key)
}
_ => None,
})
}
/// The stewardship of `(mind, repo)` a hand-off acts on: the one whose
/// withdrawal already carries `hand_off_key`, when image or batch holds
/// that withdrawal, so a replay derives the same withdrawal again and A9