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 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-22 21:56:58 +02:00
commit 383600c234
2 changed files with 18 additions and 15 deletions

View file

@ -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]

View file

@ -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<Lineage<'_>> {
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(_)