From 383600c23426d339ea6045a5786afd564701adea Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 22 Oct 2026 21:56:58 +0200 Subject: [PATCH] Lineage: a follow-up's line is global, as a ruling's; re-homing work across campaigns supersedes (ruling supersession-lineage-3) Co-Authored-By: Claude Sonnet 5.5 --- crates/huginn-mind/src/admission.rs | 23 +++++++++++++---------- crates/huginn-mind/src/docs.rs | 10 +++++----- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/crates/huginn-mind/src/admission.rs b/crates/huginn-mind/src/admission.rs index 28b9a03..de9a875 100644 --- a/crates/huginn-mind/src/admission.rs +++ b/crates/huginn-mind/src/admission.rs @@ -2962,23 +2962,26 @@ mod tests { ])); } + /// Re-homing work is how Self routes it (ruling `supersession-lineage-3`): + /// a gap follow-up of one campaign is superseded by its successor in the + /// campaign that owns the work now, and the typed edge survives. #[test] - fn a_follow_up_is_superseded_only_within_its_campaign() { + fn a_follow_up_is_superseded_by_one_re_homed_to_another_campaign() { let mut mind = seeded(); let source = r(K::Target, &id("target", "r1")); - committed(admit(&mut mind, vec![follow_up("old", source.clone())])); + committed(admit(&mut mind, vec![follow_up("gap-session-id", source.clone())])); let mut batch = rival_revision(1); - let D::FollowUp(mut foreign) = follow_up("new", source.clone()) else { panic!("a follow-up") }; + let D::FollowUp(mut foreign) = follow_up("gap-session-id", source) else { panic!("a follow-up") }; foreign.campaign = RIVAL.into(); batch.push(D::FollowUp(foreign)); + batch.push(resolution( + r(K::FollowUp, &id("follow_up", "gap-session-id")), + superseded(&[r(K::FollowUp, &format!("{RIVAL}:follow_up:gap-session-id"))]), + )); committed(admit(&mut mind, batch)); - let lone = vec![resolution(r(K::FollowUp, &id("follow_up", "old")), superseded(&[r(K::FollowUp, &format!("{RIVAL}:follow_up:new"))]))]; - assert!(supersession_refused(admit(&mut mind, lone), K::FollowUp)); - // Nothing was written: this campaign's own follow-up still supersedes it. - committed(admit(&mut mind, vec![ - follow_up("own", source), - resolution(r(K::FollowUp, &id("follow_up", "old")), superseded(&[r(K::FollowUp, &id("follow_up", "own"))])), - ])); + let docs = docs_of(&mind); + assert!(!docs.in_force(K::FollowUp, &id("follow_up", "gap-session-id"))); + assert!(docs.in_force(K::FollowUp, &format!("{RIVAL}:follow_up:gap-session-id"))); } #[test] diff --git a/crates/huginn-mind/src/docs.rs b/crates/huginn-mind/src/docs.rs index bb73776..49bbbbb 100644 --- a/crates/huginn-mind/src/docs.rs +++ b/crates/huginn-mind/src/docs.rs @@ -299,20 +299,21 @@ impl Docs { } } -/// The line a record belongs to (ruling `supersession-lineage-2`): the one place +/// The line a record belongs to (rulings `supersession-lineage-2` and `-3`): the one place /// lineage is decided. A record supersedes, and is reinstated over, only a record /// of its own line. `None` is a kind the resolution matrix never lets be /// superseded; the match names every kind, so a new kind fails to compile until /// its line is stated. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub(crate) enum Lineage<'a> { - /// A target, or a follow-up: the campaign. + /// A target: the campaign. Campaign(&'a Slug), /// A cut spec: the campaign and the cut. Cut(&'a Slug, &'a Label), /// A stewardship: the instance and the repo. Assignment(&'a Slug, &'a OrgRepo), - /// A ruling: operator directions cut across campaigns. + /// A ruling or a follow-up: operator directions and re-homed work cut + /// across campaigns. Global, } @@ -321,9 +322,8 @@ pub(crate) fn line_of(document: &PipelineDocument) -> Option> { match document { D::Target(target) => Some(Lineage::Campaign(&target.campaign)), D::CutSpec(spec) => Some(Lineage::Cut(&spec.campaign, &spec.cut)), - D::FollowUp(follow_up) => Some(Lineage::Campaign(&follow_up.campaign)), D::Stewardship(stewardship) => Some(Lineage::Assignment(&stewardship.instance, &stewardship.repo)), - D::Ruling(_) => Some(Lineage::Global), + D::Ruling(_) | D::FollowUp(_) => Some(Lineage::Global), D::Campaign(_) | D::Question(_) | D::CutReport(_)