Cut RS-2: delete open_items, history, and the admission window

Subtraction only, per eureka-read-side-cut.md. Deletes PipelineOpenItems,
HistoryScope, open_items, history, and the admitted_after/admitted_before
window from the read side, their wire variants and arms, the daemon arms
and tests that exercised only these, the OpenItems/History lines from the
instance-gate tests (each keeps its query and view cases), and the README
clause. serve.rs's N4 gate fixtures use whoami in place of open_items as
the long operation name; the case is kept.

Deleted the now-dead Reader::views() helper and the 'a lifetime it forced
on Reader, and stripped the History-only assertions from two tests the
map did not name (a_ref_whose_kind_and_id_disagree_is_refused_by_both_doors
and views_read_admitted_at_from_the_receipt_not_stored_at) that also called
the deleted API. Regenerated both published wire schemas.

Removes cut9 V9-V15, V22 and V22L (12 entries incl. V13L/V14L), and cut10
D19, D19L, D23, D23L, S1 and S1d (6 entries). D13 and D13L are re-anchored
on the surviving view/query arms; D13L uses a near-miss spelling rather
than a pure casing change, since PowerShell's default -eq made a casing
mutant read as "changes nothing" to the harness's own guard. V24 collapses
from a two-door Edits array to a single edit now that view is the only
door left. cut9 (27 entries) and cut10 (65 entries) both rerun clean with
M0 green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-22 09:51:32 +02:00
commit 92ac16c5b0
10 changed files with 48 additions and 1058 deletions

View file

@ -47,11 +47,10 @@ the resolution matrix, derived resolutions and stewardships), then one
compare-and-swap that lands the batch whole with a receipt naming the exact
bytes it read and wrote. An exact replay answers with the stored receipt.
It reads them back the same way: a document with the facts of its admission
joined from that receipt and its status derived at read time, typed queries
over one mind, a campaign's open work, and a subject's or a repo's history.
Status is never stored, and the views derive it through the same rules
admission does. Document shape and keys come from `epiphany-pipeline`; the
store is CultLib's Rust CultCache.
joined from that receipt and its status derived at read time, and typed
queries over one mind. Status is never stored, and the views derive it
through the same rules admission does. Document shape and keys come from
`epiphany-pipeline`; the store is CultLib's Rust CultCache.
`huginn-daemon` opens one mind, binds one UDP socket in that order, and
answers every frame on the session it arrived on: one operation per `Mind`

View file

@ -89,14 +89,6 @@ impl<S: MindStore, I: IndexSink<S>> Daemon<S, I> {
Ok(page) => HuginnMindResponse::Query(page),
Err(refusal) => HuginnMindResponse::Refused(refusal),
},
HuginnMindRequest::OpenItems { campaign, .. } => match self.mind.open_items(&campaign) {
Ok(items) => HuginnMindResponse::OpenItems(items),
Err(refusal) => HuginnMindResponse::Refused(refusal),
},
HuginnMindRequest::History { scope, .. } => match self.mind.history(&scope) {
Ok(views) => HuginnMindResponse::History(views),
Err(refusal) => HuginnMindResponse::Refused(refusal),
},
}
}
}
@ -112,10 +104,7 @@ pub(crate) mod tests {
StructuralDelta, VerificationTest,
};
use huginn_mind::wire::MindStatus;
use huginn_mind::{
Faculty, HistoryScope, PipelineAdmissionBatch, PipelineProvenance, PipelineQuery, PipelineStatus,
SemanticQuery,
};
use huginn_mind::{Faculty, PipelineAdmissionBatch, PipelineProvenance, PipelineQuery, PipelineStatus, SemanticQuery};
use std::sync::{Arc, Mutex};
use tempfile::TempDir;
@ -397,24 +386,6 @@ pub(crate) mod tests {
let id = writes[0].clone();
let view = daemon.handle(HuginnMindRequest::View { instance: slug(INSTANCE), id: id.clone() }, now());
assert_eq!(view, HuginnMindResponse::View(Some(page.items[0].clone())));
let HuginnMindResponse::OpenItems(items) =
daemon.handle(HuginnMindRequest::OpenItems { instance: slug(INSTANCE), campaign: slug(CAMPAIGN) }, now())
else {
panic!("expected open items");
};
assert_eq!(
(items.questions.len(), items.findings.len(), items.follow_ups.len()),
(0, 0, 0),
"a mind holding only its identity has nothing open"
);
assert!(items.specs_without_report.is_empty() && items.reports_without_verdict.is_empty());
let scope = HistoryScope::Repo(OrgRepo("GameCult/Huginn".into()));
assert_eq!(
daemon.handle(HuginnMindRequest::History { instance: slug(INSTANCE), scope }, now()),
HuginnMindResponse::History(vec![])
);
}
/// Ruling 14 across the transport, on both sides: the mind refuses a read
@ -450,14 +421,7 @@ pub(crate) mod tests {
);
let view = HuginnMindRequest::View { instance: slug(OTHER), id: writes[0].clone() };
assert_eq!(daemon.handle(view, now()), HuginnMindResponse::Refused(foreign.clone()));
let items = HuginnMindRequest::OpenItems { instance: slug(OTHER), campaign: slug(CAMPAIGN) };
assert_eq!(daemon.handle(items, now()), HuginnMindResponse::Refused(foreign.clone()));
let scope = HistoryScope::Repo(OrgRepo("GameCult/Huginn".into()));
let history = HuginnMindRequest::History { instance: slug(OTHER), scope };
assert_eq!(daemon.handle(history, now()), HuginnMindResponse::Refused(foreign));
assert_eq!(daemon.handle(view, now()), HuginnMindResponse::Refused(foreign));
// Three names a comparison could mistake for this mind's. `NEAR` is
// `INSTANCE`'s own length and differs in its last byte, so a check
@ -513,14 +477,7 @@ pub(crate) mod tests {
instance: slug(fullwidth),
id: PipelineRef { kind: PipelineKind::Question, id: Short("not-reached".into()) },
};
assert_eq!(daemon.handle(view, now()), HuginnMindResponse::Refused(expected.clone()));
let items = HuginnMindRequest::OpenItems { instance: slug(fullwidth), campaign: slug(CAMPAIGN) };
assert_eq!(daemon.handle(items, now()), HuginnMindResponse::Refused(expected.clone()));
let scope = HistoryScope::Repo(OrgRepo("GameCult/Huginn".into()));
let history = HuginnMindRequest::History { instance: slug(fullwidth), scope };
assert_eq!(daemon.handle(history, now()), HuginnMindResponse::Refused(expected));
assert_eq!(daemon.handle(view, now()), HuginnMindResponse::Refused(expected));
}
/// `Admit` is excluded from the daemon's own pre-check (its batch is not a
@ -560,10 +517,6 @@ pub(crate) mod tests {
/// as `Unavailable`, not rewrapped as another read's refusal, and not
/// swallowed into an empty answer, which would read as "no such document"
/// rather than "that is not a reference".
///
/// The fourth arm, `open_items`, is pinned by the test below rather than
/// here, because the refusal it must carry needs a store to be broken
/// first.
#[test]
fn a_refusal_a_read_raised_is_the_answer_the_dispatch_returns_whole() {
let (_root, mut daemon) = seeded();
@ -575,11 +528,8 @@ pub(crate) mod tests {
field: "ref.id".into(),
value: "not a reference".into(),
});
let view = HuginnMindRequest::View { instance: slug(INSTANCE), id: invalid.clone() };
assert_eq!(daemon.handle(view, now()), HuginnMindResponse::Refused(malformed.clone()));
let history = HuginnMindRequest::History { instance: slug(INSTANCE), scope: HistoryScope::Subject(invalid) };
assert_eq!(daemon.handle(history, now()), HuginnMindResponse::Refused(malformed));
let view = HuginnMindRequest::View { instance: slug(INSTANCE), id: invalid };
assert_eq!(daemon.handle(view, now()), HuginnMindResponse::Refused(malformed));
// A semantic query is unavailable until Cut 11 wires an index, and the
// detail is the mind's own sentence.
@ -606,168 +556,6 @@ pub(crate) mod tests {
assert_eq!(page.matched, 1);
}
/// The fourth read arm, pinned the same way. `open_items` raises no refusal
/// of its own, so the refusal it must carry comes from the reader beneath
/// it: a mind whose commit receipt has been deleted still opens, because
/// the opener reads the store's types, epoch and identity and not its
/// receipts, and then a read that joins a document to its receipt refuses
/// by name over the orphan. The arm must return that sentence whole, like
/// its three siblings: rewrapped it says the mind is unavailable for some
/// unstated reason, and swallowed it says the campaign has nothing open,
/// which is what a healthy mind says.
///
/// The store is broken through `huginn-mind`'s own re-export of CultCache's
/// row traits, so this crate still names one revision through one
/// dependency. Hands had recorded this arm as impossible to pin; the
/// swallow and the rewrap both survived the suite until this landed.
#[test]
fn a_refusal_open_items_raised_is_the_answer_the_dispatch_returns_whole() {
use huginn_mind::HuginnCommitReceipt;
use huginn_mind::store::{CacheBackingStore, DatabaseEntry};
let root = tempfile::tempdir().unwrap();
let path = Mind::<OwnedRedbMessagePackBackingStore>::store_path_for(root.path(), &slug(INSTANCE)).unwrap();
{
let mut daemon = Daemon::open(root.path(), &slug(INSTANCE)).unwrap();
let outcome = daemon.handle(HuginnMindRequest::Admit(batch(INSTANCE, vec![identity(INSTANCE)])), now());
assert!(matches!(outcome, HuginnMindResponse::Admit(PipelineAdmissionOutcome::Committed { .. })));
}
{
let mut store = OwnedRedbMessagePackBackingStore::new(&path).unwrap();
let rows = store.pull_all().unwrap();
let receipt =
rows.iter().find(|row| row.r#type == HuginnCommitReceipt::TYPE).expect("one receipt").clone();
store.delete(&receipt).unwrap();
}
let mut daemon = Daemon::open(root.path(), &slug(INSTANCE)).expect("an orphaned image still opens");
let orphaned = MindRefusal::Unavailable {
detail: format!("document epiphany.pipeline.instance.v1/{INSTANCE}:instance:self has no commit receipt"),
};
let items = HuginnMindRequest::OpenItems { instance: slug(INSTANCE), campaign: slug(CAMPAIGN) };
assert_eq!(daemon.handle(items, now()), HuginnMindResponse::Refused(orphaned));
}
/// The fault the test above drives sits outside the campaign asked about:
/// the orphan is the mind's own identity document, rooted at the instance,
/// not at `CAMPAIGN`. A loosening that only refuses a fault *outside* the
/// requested campaign, and one that swallows every fault except a missing
/// receipt, both survive it. This drives the same arm with a fault on a
/// document rooted inside the requested campaign, of each kind Soul named:
/// a missing receipt, a document that does not decode, and a document two
/// receipts both claim to have written.
#[test]
fn open_items_refuses_on_a_fault_inside_the_requested_campaign() {
use huginn_mind::HuginnCommitReceipt;
use huginn_mind::store::{CacheBackingStore, DatabaseEntry};
// A campaign-rooted document (a cut spec) admitted alone, so its own
// receipt writes nothing else and can be found and broken without
// touching the identity or stewardship receipt from the seed batch.
fn campaign_rooted_cut_spec(
root: &std::path::Path,
cut: &str,
) -> (String, OwnedRedbMessagePackBackingStore) {
let mut daemon = Daemon::open(root, &slug(INSTANCE)).unwrap();
let seeded = daemon.handle(HuginnMindRequest::Admit(batch(INSTANCE, campaign_seed())), now());
assert!(matches!(seeded, HuginnMindResponse::Admit(PipelineAdmissionOutcome::Committed { .. })));
let outcome = daemon.handle(HuginnMindRequest::Admit(batch(INSTANCE, vec![cut_spec(cut, 1)])), now());
let HuginnMindResponse::Admit(PipelineAdmissionOutcome::Committed { writes, .. }) = outcome else {
panic!("expected a commit");
};
assert_eq!(writes.len(), 1, "a cut spec alone derives nothing");
let cut_spec_id = writes[0].id.0.clone();
drop(daemon);
(cut_spec_id, OwnedRedbMessagePackBackingStore::new(&Mind::<OwnedRedbMessagePackBackingStore>::store_path_for(root, &slug(INSTANCE)).unwrap()).unwrap())
}
let cut_spec_type = PipelineKind::CutSpec.type_id();
// A missing receipt, this time on a document rooted in `CAMPAIGN`.
{
let root = tempfile::tempdir().unwrap();
let (cut_spec_id, mut store) = campaign_rooted_cut_spec(root.path(), "orphan-in-campaign");
let rows = store.pull_all().unwrap();
let receipt_row = rows
.iter()
.find(|row| {
row.r#type == HuginnCommitReceipt::TYPE
&& rmp_serde::from_slice::<HuginnCommitReceipt>(&row.payload)
.map(|receipt| receipt.writes.iter().any(|write| write.document_key == cut_spec_id))
.unwrap_or(false)
})
.expect("the cut spec's own receipt")
.clone();
store.delete(&receipt_row).unwrap();
drop(store);
let mut daemon = Daemon::open(root.path(), &slug(INSTANCE)).expect("an orphaned image still opens");
let expected = MindRefusal::Unavailable {
detail: format!("document {cut_spec_type}/{cut_spec_id} has no commit receipt"),
};
let items = HuginnMindRequest::OpenItems { instance: slug(INSTANCE), campaign: slug(CAMPAIGN) };
assert_eq!(daemon.handle(items, now()), HuginnMindResponse::Refused(expected));
}
// An undecodable stored document, rooted in `CAMPAIGN`.
{
let root = tempfile::tempdir().unwrap();
let (cut_spec_id, mut store) = campaign_rooted_cut_spec(root.path(), "garbled-in-campaign");
let rows = store.pull_all().unwrap();
let mut doc_row =
rows.iter().find(|row| row.r#type == cut_spec_type && row.key == cut_spec_id).unwrap().clone();
store.delete(&doc_row).unwrap();
doc_row.payload = b"not messagepack".to_vec();
store.push(&doc_row).unwrap();
drop(store);
let mut daemon = Daemon::open(root.path(), &slug(INSTANCE)).expect("a garbled document still opens");
let items = HuginnMindRequest::OpenItems { instance: slug(INSTANCE), campaign: slug(CAMPAIGN) };
let HuginnMindResponse::Refused(MindRefusal::Unavailable { detail }) = daemon.handle(items, now())
else {
panic!("a document that does not decode must refuse, not answer");
};
assert!(
detail.starts_with(&format!("stored document {cut_spec_id} does not decode")),
"unexpected detail: {detail}"
);
}
// A document two receipts both claim to have written, rooted in
// `CAMPAIGN`: the cut spec's own receipt, cloned under a new key and
// id, so the same identity is now landed twice.
{
let root = tempfile::tempdir().unwrap();
let (cut_spec_id, mut store) = campaign_rooted_cut_spec(root.path(), "doubled-in-campaign");
let rows = store.pull_all().unwrap();
let receipt_row = rows
.iter()
.find(|row| {
row.r#type == HuginnCommitReceipt::TYPE
&& rmp_serde::from_slice::<HuginnCommitReceipt>(&row.payload)
.map(|receipt| receipt.writes.iter().any(|write| write.document_key == cut_spec_id))
.unwrap_or(false)
})
.expect("the cut spec's own receipt")
.clone();
let mut receipt: HuginnCommitReceipt = rmp_serde::from_slice(&receipt_row.payload).unwrap();
receipt.receipt_id = format!("{}-forged", receipt.receipt_id);
let mut forged_row = receipt_row.clone();
forged_row.key = receipt.receipt_id.clone();
forged_row.payload = rmp_serde::to_vec_named(&receipt).unwrap();
store.push(&forged_row).unwrap();
drop(store);
let mut daemon =
Daemon::open(root.path(), &slug(INSTANCE)).expect("two receipts for one document still opens");
let expected = MindRefusal::Unavailable {
detail: format!("document {cut_spec_type}/{cut_spec_id} is written by two receipts"),
};
let items = HuginnMindRequest::OpenItems { instance: slug(INSTANCE), campaign: slug(CAMPAIGN) };
assert_eq!(daemon.handle(items, now()), HuginnMindResponse::Refused(expected));
}
}
/// Cut 11's seam: the index is handed every landed write, derived ones
/// included, and can read each; an index that fails changes nothing.
#[test]

View file

@ -308,8 +308,7 @@ pub fn run<S: MindStore, I: IndexSink<S>>(
mod tests {
use super::*;
use crate::daemon::tests::{
CAMPAIGN, FITTING_CHANGES, FITTING_CUT, INSTANCE, OTHER, WIDE_CHANGES, WIDE_CUT, batch, identity, now,
seeded_wide, slug,
FITTING_CHANGES, FITTING_CUT, INSTANCE, OTHER, WIDE_CHANGES, WIDE_CUT, batch, identity, now, seeded_wide, slug,
};
use huginn_mind::epiphany_pipeline::{PipelineKind, PipelineRef};
use crate::envelope::{FAILURE_SCHEMA, decode_response, encode_request};
@ -588,7 +587,6 @@ mod tests {
let reads = [
("m-q", HuginnMindRequest::Query { instance: slug(INSTANCE), query: PipelineQuery::default() }),
("m-v", HuginnMindRequest::View { instance: slug(INSTANCE), id: wide }),
("m-o", HuginnMindRequest::OpenItems { instance: slug(INSTANCE), campaign: slug(CAMPAIGN) }),
];
let stopping = Arc::new(AtomicBool::new(false));
let loop_stopping = Arc::clone(&stopping);
@ -847,12 +845,12 @@ mod tests {
/// `m-0`'s three bytes and the other fixture's forty -- has no way to be
/// wrong there and every way to be wrong once the operation or the
/// runtime id it never looked at changes length too. This holds the
/// boundary at `open_items` (ten bytes, not `view`'s four) over a second
/// boundary at `whoami` (six bytes, not `view`'s four) over a second
/// runtime id, so such a formula is measured somewhere it was never
/// fitted.
#[test]
fn the_gates_boundary_holds_across_operation_and_runtime_id() {
for (operation, runtime_id) in [("view", "huginn-yggdrasil"), ("open_items", "huginn-thought-cage")] {
for (operation, runtime_id) in [("view", "huginn-yggdrasil"), ("whoami", "huginn-thought-cage")] {
let at = sized_exactly_full("m-g", operation, runtime_id, MAX_RESPONSE_BYTES);
let over = sized_exactly_full("m-g", operation, runtime_id, MAX_RESPONSE_BYTES + 1);
assert_eq!(
@ -875,7 +873,7 @@ mod tests {
/// Residue S1: every fixture up to this one, including the pair above,
/// moves `operation` and the runtime id together -- both short (`view`,
/// 4 bytes / `huginn-yggdrasil`, 16) or both long (`open_items`, 10 /
/// 4 bytes / `huginn-yggdrasil`, 16) or both long (`whoami`, 6 /
/// `huginn-thought-cage`, 19) -- so a formula that tracks only one of the
/// two and ignores the other still lands on the right answer at both
/// points by coincidence. This pins a point where they move apart: a long
@ -883,7 +881,7 @@ mod tests {
/// long one, so a gate that dropped either term is wrong at one of them.
#[test]
fn the_gates_boundary_holds_when_operation_and_runtime_id_vary_independently() {
for (operation, runtime_id) in [("open_items", "huginn-yggdrasil"), ("view", "huginn-thought-cage")] {
for (operation, runtime_id) in [("whoami", "huginn-yggdrasil"), ("view", "huginn-thought-cage")] {
let at = sized_exactly_full("m-g", operation, runtime_id, MAX_RESPONSE_BYTES);
let over = sized_exactly_full("m-g", operation, runtime_id, MAX_RESPONSE_BYTES + 1);
assert_eq!(

View file

@ -38,8 +38,8 @@ pub(crate) mod fixtures;
pub use admission::{BATCH_MAX, PipelineAdmissionBatch, PipelineAdmissionOutcome};
pub use mind::{HuginnMindEpoch, Mind};
pub use query::{
AdmissionFacts, HistoryScope, PipelineDocumentView, PipelineOpenItems, PipelineQuery, PipelineQueryPage,
PipelineStatus, QUERY_LIMIT_MAX, SemanticQuery,
AdmissionFacts, PipelineDocumentView, PipelineQuery, PipelineQueryPage, PipelineStatus, QUERY_LIMIT_MAX,
SemanticQuery,
};
pub use receipt::{DocumentVersion, Faculty, HuginnCommitReceipt, PipelineProvenance, RECEIPT_SCHEMA_VERSION};
pub use refusal::MindRefusal;

View file

@ -86,10 +86,6 @@ pub struct PipelineQuery {
pub in_force: Option<bool>,
/// Attribution, ruling 18: it filters, it grants nothing.
pub faculty: Option<Faculty>,
/// Exclusive, compared as a string against `admitted_at`.
pub admitted_after: Option<Short>,
/// Exclusive, compared as a string against `admitted_at`.
pub admitted_before: Option<Short>,
/// `None` is `QUERY_LIMIT_MAX`; anything else is clamped into
/// `1..=QUERY_LIMIT_MAX`.
pub limit: Option<u32>,
@ -104,26 +100,6 @@ pub struct PipelineQueryPage {
pub matched: u32,
}
/// One campaign's open work, derived from what is in force and what cites
/// what. Uncapped: the open set of a campaign is bounded by the campaign, and
/// truncating it would hide work.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct PipelineOpenItems {
pub questions: Vec<PipelineDocumentView>,
pub findings: Vec<PipelineDocumentView>,
pub follow_ups: Vec<PipelineDocumentView>,
pub specs_without_report: Vec<PipelineDocumentView>,
pub reports_without_verdict: Vec<PipelineDocumentView>,
}
/// What a history is a history of: every resolution one subject ever had, or
/// every assignment of one repo to this mind.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub enum HistoryScope {
Subject(PipelineRef),
Repo(OrgRepo),
}
/// The admission facts of every stored document, built once per read call from
/// the receipts. `writes` only: a document a later batch cited as a strong read
/// keeps the receipt that wrote it. A10 admits one write per identity, so two
@ -194,18 +170,17 @@ fn repo_matches(document: &PipelineDocument, repo: &OrgRepo) -> bool {
}
}
/// One read call's working set: the decoded image, the facts, and the mind the
/// two came from. Built once per call and thrown away with it; nothing here
/// outlives the answer.
struct Reader<'a, S: MindStore> {
/// One read call's working set: the decoded image and the facts it was built
/// from. Built once per call and thrown away with it; nothing here outlives
/// the answer.
struct Reader {
docs: Docs,
facts: AdmissionIndex,
mind: &'a Mind<S>,
}
impl<'a, S: MindStore> Reader<'a, S> {
fn new(mind: &'a Mind<S>) -> Result<Self, MindRefusal> {
Ok(Self { docs: Docs::from_image(mind.envelopes())?, facts: AdmissionIndex::build(mind)?, mind })
impl Reader {
fn new<S: MindStore>(mind: &Mind<S>) -> Result<Self, MindRefusal> {
Ok(Self { docs: Docs::from_image(mind.envelopes())?, facts: AdmissionIndex::build(mind)? })
}
fn held(&self, kind: PipelineKind, key: &str) -> Option<&Held> {
@ -276,29 +251,8 @@ impl<'a, S: MindStore> Reader<'a, S> {
{
return false;
}
if let Some(after) = &query.admitted_after
&& view.admission.admitted_at <= after.0
{
return false;
}
if let Some(before) = &query.admitted_before
&& view.admission.admitted_at >= before.0
{
return false;
}
true
}
/// Every view of the image, in order, refusing rather than skipping a
/// document the receipts do not account for.
fn views(&self) -> Result<Vec<PipelineDocumentView>, MindRefusal> {
let mut views = Vec::with_capacity(self.docs.image.len());
for held in &self.docs.image {
views.push(self.view_of(held)?);
}
ordered(&mut views);
Ok(views)
}
}
/// `(admitted_at, id)` ascending. The batch decides the order and the key
@ -348,105 +302,17 @@ impl<S: MindStore> Mind<S> {
items.truncate(limit);
Ok(PipelineQueryPage { items, matched })
}
/// One campaign's open work: the questions, findings and follow-ups still
/// in force, the in-force cut specs no report names, and the cut reports no
/// verdict names.
pub fn open_items(&self, campaign: &Slug) -> Result<PipelineOpenItems, MindRefusal> {
let reader = Reader::new(self)?;
let views = reader
.views()?
.into_iter()
.filter(|view| root_and_local(&view.id.id.0).0 == campaign.0)
.collect::<Vec<_>>();
let of_kind = |kind: PipelineKind| views.iter().filter(move |view| view.id.kind == kind);
let in_force = |kind: PipelineKind| {
of_kind(kind).filter(|view| view.status == PipelineStatus::InForce).cloned().collect::<Vec<_>>()
};
let cited = |referent: fn(&PipelineDocument) -> Option<&str>| {
views.iter().filter_map(|view| referent(&view.document)).collect::<Vec<_>>()
};
let reported = cited(|document| match document {
PipelineDocument::CutReport(report) => Some(report.cut_spec.0.as_str()),
_ => None,
});
let judged = cited(|document| match document {
PipelineDocument::Verdict(verdict) => Some(verdict.cut_report.0.as_str()),
_ => None,
});
Ok(PipelineOpenItems {
questions: in_force(PipelineKind::Question),
findings: in_force(PipelineKind::Finding),
follow_ups: in_force(PipelineKind::FollowUp),
specs_without_report: in_force(PipelineKind::CutSpec)
.into_iter()
.filter(|view| !reported.contains(&view.id.id.0.as_str()))
.collect(),
// A report is not resolvable, so standing is not a condition here.
reports_without_verdict: of_kind(PipelineKind::CutReport)
.filter(|view| !judged.contains(&view.id.id.0.as_str()))
.cloned()
.collect(),
})
}
/// Every record of one scope, withdrawn ones included with their status
/// and their reasons, in the scope's own sequence order. Uncapped: a
/// scope's history is bounded by the scope.
///
/// A subject scope is validated as `view`'s id is, and for the same
/// reason: an empty history is the answer for a subject with no records,
/// not for a ref that is no ref. A repo scope is an `OrgRepo`, which the
/// type already holds to its own format.
pub fn history(&self, scope: &HistoryScope) -> Result<Vec<PipelineDocumentView>, MindRefusal> {
if let HistoryScope::Subject(subject) = scope {
subject.validate_ref()?;
}
let reader = Reader::new(self)?;
let (kind, mut records) = match scope {
HistoryScope::Subject(subject) => (
PipelineKind::Resolution,
reader
.docs
.resolutions_of(subject)
.map(|(key, resolution)| (resolution.sequence, key.to_string()))
.collect::<Vec<_>>(),
),
HistoryScope::Repo(repo) => (
PipelineKind::Stewardship,
reader
.docs
.assignments_of(reader.mind.instance(), repo)
.map(|(key, stewardship)| (stewardship.sequence, key.to_string()))
.collect::<Vec<_>>(),
),
};
// The sequence owns history order. `admitted_at` coincides in a mind
// written in order, but it is not the rule.
records.sort_by_key(|(sequence, _)| *sequence);
let mut views = Vec::with_capacity(records.len());
for (_, key) in records {
let held = reader
.held(kind, &key)
.ok_or_else(|| integrity(kind.type_id(), &key, "is derived over the image but not held in it"))?;
views.push(reader.view_of(held)?);
}
Ok(views)
}
}
#[cfg(test)]
mod tests {
use std::collections::BTreeSet;
use super::*;
use crate::fixtures::*;
use crate::mind::schema_cache;
use crate::store::test_stores::MemoryStore;
use chrono::{TimeZone, Utc};
use epiphany_pipeline::{
ClaimOutcome, Date, FindingConfidence, PipelineDocument as D, PipelineKind as K, PipelineRefusal,
ResolutionOutcome,
ClaimOutcome, FindingConfidence, PipelineDocument as D, PipelineKind as K, PipelineRefusal, ResolutionOutcome,
};
fn view(mind: &Mind<MemoryStore>, kind: K, key: &str) -> PipelineDocumentView {
@ -548,7 +414,6 @@ mod tests {
// read as a ruling it names neither, and is not a reference at all.
let disagreeing = r(K::Ruling, &q1);
assert_eq!(mind.view(&disagreeing), Err(malformed(&q1)));
assert_eq!(mind.history(&HistoryScope::Subject(disagreeing)), Err(malformed(&q1)));
// A local no writer composes is the same refusal, so the door is the
// whole grammar and not the kind segment alone. The refusal's `value`
@ -556,107 +421,11 @@ mod tests {
// and not the whole id.
let dotted = r(K::Question, &format!("{q1}."));
assert_eq!(mind.view(&dotted), Err(malformed("")));
assert_eq!(mind.history(&HistoryScope::Subject(dotted)), Err(malformed("")));
// Absence is not malformation: a well-formed id of a kind this mind
// does not hold answers as it always did.
let absent = id("question", "Q9");
assert_eq!(mind.view(&r(K::Question, &absent)), Ok(None));
assert_eq!(mind.history(&HistoryScope::Subject(r(K::Question, &absent))), Ok(Vec::new()));
}
/// R-B and D7: a subject's resolutions are a first-class view, withdrawn
/// ones included with their status and their reasons, in sequence order.
#[test]
fn a_subjects_history_lists_every_resolution_with_its_status_and_receipt() {
let mut mind = seeded();
let q1 = id("question", "Q1");
committed(admit(&mut mind, vec![question("Q1", &["A", "B"], "A")]));
// Ten reopen cycles: each ruling answers, each withdrawal but the last
// reopens.
for cycle in 1..=10u32 {
committed(admit(&mut mind, vec![answering(&format!("R{cycle}"), &q1)]));
if cycle < 10 {
let closed = id("resolution", &format!("question.Q1.n{cycle}"));
committed(admit(&mut mind, vec![resolution(r(K::Resolution, &closed), withdrawn())]));
}
}
let history = mind.history(&HistoryScope::Subject(r(K::Question, &q1))).unwrap();
assert_eq!(
ids(&history),
(1..=10).map(|n| id("resolution", &format!("question.Q1.n{n}"))).collect::<Vec<_>>(),
"sequence order, so n10 lands after n9 and not after n1 as the key string would have it"
);
for (index, entry) in history.iter().enumerate() {
let sequence = index as u32 + 1;
if sequence == 10 {
assert_eq!(entry.status, PipelineStatus::InForce, "the standing closure");
continue;
}
let PipelineStatus::Resolved { resolution, record } = &entry.status else { panic!("n{sequence}") };
let withdrawal = id("resolution", &format!("resolution.question.Q1.n{sequence}.n1"));
assert_eq!(*resolution, r(K::Resolution, &withdrawal));
assert!(matches!(&record.outcome, ResolutionOutcome::Withdrawn { reason } if reason.0 == "moot"));
}
// A withdrawal's subject is the resolution, not the question, so it is
// in the resolution's history and not the question's.
let n1 = id("resolution", "question.Q1.n1");
assert_eq!(ids(&mind.history(&HistoryScope::Subject(r(K::Resolution, &n1))).unwrap()), vec![
id("resolution", "resolution.question.Q1.n1.n1")
]);
// A subject whose kind disagrees with its id is no subject at all, and
// the door says so: the id names ten resolutions, and a mind that
// answered an empty history over it would report a malformed reference
// as a subject with no records.
assert_eq!(
mind.history(&HistoryScope::Subject(r(K::Ruling, &q1))),
Err(malformed(&q1)),
"a malformed scope is refused, not answered over"
);
// History lands one record per batch (Cut 12's import constraint), so
// ten records carry ten receipts.
let receipts = history.iter().map(|entry| entry.admission.receipt_id.clone()).collect::<BTreeSet<_>>();
assert_eq!(receipts.len(), 10);
}
/// D7's other scope: every assignment of one repo to this mind, the
/// withdrawn ones with the hand-off that withdrew them.
#[test]
fn a_repos_stewardship_history_on_a_mind_lists_every_assignment() {
let mut mind = seeded();
committed(admit(&mut mind, vec![stewardship(INSTANCE, OTHER_REPO)]));
let away = format!("{INSTANCE}:hand_off:{OTHER_INSTANCE}.GameCult_-Epiphany.2026-09-16");
committed(admit(&mut mind, vec![hand_off(INSTANCE, OTHER_INSTANCE, REPO, &[])]));
let D::HandOff(mut back) = hand_off(OTHER_INSTANCE, INSTANCE, REPO, &[]) else { panic!() };
back.handed_on = Date("2026-09-17".into());
committed(admit(&mut mind, vec![D::HandOff(back)]));
let history = mind.history(&HistoryScope::Repo(repo(REPO))).unwrap();
assert_eq!(ids(&history), vec![
format!("{INSTANCE}:stewardship:GameCult_-Epiphany.n1"),
format!("{INSTANCE}:stewardship:GameCult_-Epiphany.n2"),
]);
let PipelineStatus::Resolved { record, .. } = &history[0].status else { panic!("handed away") };
assert!(
matches!(&record.outcome, ResolutionOutcome::Withdrawn { reason } if reason.0 == away),
"the withdrawal names the hand-off that caused it"
);
assert_eq!(history[1].status, PipelineStatus::InForce);
let (D::Stewardship(first), D::Stewardship(second)) = (&history[0].document, &history[1].document) else {
panic!()
};
assert_eq!(first.assigned_on, date());
assert_eq!(second.assigned_on, Date("2026-09-17".into()), "the assignment carries the hand-off's day");
// Another repo's assignments are another history; the scope is
// `(this mind, this repo)` and nothing else.
assert_eq!(ids(&mind.history(&HistoryScope::Repo(repo(OTHER_REPO))).unwrap()), vec![
format!("{INSTANCE}:stewardship:GameCult_-Huginn.n1")
]);
}
/// D3: the facts come from the one receipt that wrote the document, from
@ -751,13 +520,11 @@ mod tests {
}
opened(copy, INSTANCE)
};
let scope = HistoryScope::Subject(r(K::Question, &q1));
let expected = (mind.query(&PipelineQuery::default()).unwrap(), mind.history(&scope).unwrap());
let expected = mind.query(&PipelineQuery::default()).unwrap();
let constant = vec!["2000-01-01T00:00:00Z".to_string(); rows.len()];
let reversed = rows.iter().rev().map(|row| row.stored_at.clone()).collect::<Vec<_>>();
for other in [reopened(constant), reopened(reversed)] {
assert_eq!(other.query(&PipelineQuery::default()).unwrap(), expected.0);
assert_eq!(other.history(&scope).unwrap(), expected.1);
assert_eq!(other.query(&PipelineQuery::default()).unwrap(), expected);
}
}
@ -792,7 +559,7 @@ mod tests {
withdrawn(),
)]));
committed(admit_as(&mut mind, Faculty::Soul, vec![D::Ruling(ruling("R2"))]));
// One batch at a later clock, so the window filters have a boundary.
// One batch at a later clock, so a second question exists for `kinds`.
let later = Utc.with_ymd_and_hms(2026, 9, 17, 12, 0, 0).unwrap();
committed(admit_at(&mut mind, vec![question_n(2)], later));
@ -870,16 +637,6 @@ mod tests {
// `faculty`: attribution filters, and grants nothing (ruling 18).
assert_eq!(matching(PipelineQuery { faculty: Some(Faculty::Soul), ..Default::default() }), vec![id("ruling", "R2")]);
assert!(!matching(PipelineQuery { faculty: Some(Faculty::Hands), ..Default::default() }).contains(&id("ruling", "R2")));
// The window, exclusive at the exact boundary on both sides.
let boundary = s("2026-09-17T12:00:00Z");
let opened_at = s("2026-09-16T12:00:00Z");
assert_eq!(matching(PipelineQuery { admitted_after: Some(opened_at.clone()), ..Default::default() }), vec![
id("question", "Q2")
]);
assert!(matching(PipelineQuery { admitted_after: Some(boundary.clone()), ..Default::default() }).is_empty());
assert!(matching(PipelineQuery { admitted_before: Some(opened_at), ..Default::default() }).is_empty());
assert!(!matching(PipelineQuery { admitted_before: Some(boundary), ..Default::default() }).contains(&id("question", "Q2")));
}
/// D5's order and cap: `(admitted_at, id)` ascending, at most 200, and the
@ -937,71 +694,6 @@ mod tests {
}
}
/// D6: open work is derived from what is in force and what cites what,
/// never maintained.
#[test]
fn open_items_are_derived_from_in_force_and_citation() {
let mut mind = seeded();
let q1 = id("question", "Q1");
let q2 = id("question", "Q2");
committed(admit(&mut mind, vec![question("Q1", &["A", "B"], "A"), question("Q2", &["A", "B"], "A")]));
committed(admit(&mut mind, vec![answering("R1", &q2)]));
// cut-9: a superseded r1 with a report of its own, and an r2 with none.
// The citation is the exact spec and not its cut, so r2 is open work
// while the cut it belongs to has been reported.
committed(admit(&mut mind, vec![D::CutSpec(cut_spec("9", 1))]));
committed(admit(&mut mind, vec![D::CutReport(cut_report("9", 1))]));
committed(admit(&mut mind, vec![
D::CutSpec(cut_spec("9", 2)),
resolution(r(K::CutSpec, &id("cut_spec", "cut-9.r1")), superseded(&[r(K::CutSpec, &id("cut_spec", "cut-9.r2"))])),
]));
// cut-12: a superseded r1 and an r2, neither reported, so standing is
// still what decides which of the two is open work.
committed(admit(&mut mind, vec![D::CutSpec(cut_spec("12", 1))]));
committed(admit(&mut mind, vec![
D::CutSpec(cut_spec("12", 2)),
resolution(r(K::CutSpec, &id("cut_spec", "cut-12.r1")), superseded(&[r(K::CutSpec, &id("cut_spec", "cut-12.r2"))])),
]));
// cut-10: a spec with a report, and that report with no verdict.
committed(admit(&mut mind, vec![D::CutSpec(cut_spec("10", 1))]));
committed(admit(&mut mind, vec![D::CutReport(cut_report("10", 1))]));
// cut-11: a spec with a report, that report with a verdict, and two
// findings, one of which is then fixed.
committed(admit(&mut mind, vec![D::CutSpec(cut_spec("11", 1))]));
// Two reports of one cut, one of them judged, so "this cut has a
// verdict" is not the same answer as "this report has one".
committed(admit(&mut mind, vec![D::CutReport(cut_report("11", 1)), D::CutReport(cut_report("11", 2))]));
let f1 = id("finding", "cut-11.s1.F1");
let f2 = id("finding", "cut-11.s1.F2");
committed(admit(&mut mind, vec![
verdict("11", 1, vec![claim(ClaimOutcome::Unproven, &[&f1, &f2], Some("P1"), &["M1"])]),
D::Finding(finding("11", 1, "F1", FindingConfidence::Plausible)),
D::Finding(finding("11", 1, "F2", FindingConfidence::Plausible)),
]));
committed(admit(&mut mind, vec![
follow_up("FU-1", r(K::Finding, &f1)),
resolution(r(K::Finding, &f2), ResolutionOutcome::Fixed { commit: sha(), by: None }),
]));
committed(admit(&mut mind, elsewhere("Q3")));
let open = mind.open_items(&slug(CAMPAIGN)).unwrap();
assert_eq!(ids(&open.questions), vec![q1], "the answered one is closed, another campaign's is not ours");
assert_eq!(ids(&open.findings), vec![f1], "the fixed one is closed");
assert_eq!(ids(&open.follow_ups), vec![id("follow_up", "FU-1")]);
assert_eq!(
ids(&open.specs_without_report),
vec![id("cut_spec", "cut-12.r2"), id("cut_spec", "cut-9.r2")],
"a superseded revision is not open, a spec with a report is not either, and the report of the \
revision it superseded is not this revision's"
);
assert_eq!(
ids(&open.reports_without_verdict),
vec![id("cut_report", "cut-10.h1"), id("cut_report", "cut-11.h2"), id("cut_report", "cut-9.h1")],
"a report is not resolvable, so only the verdict that names it, exactly, closes it"
);
}
/// D5: `semantic` is refused typed, before the image or the receipts are
/// read, and never answered with an empty page that reads like "nothing
/// matched". Where the check sits is the rule: below the reader, a store
@ -1021,8 +713,6 @@ mod tests {
kinds: vec![K::Question],
in_force: Some(true),
faculty: Some(Faculty::Hands),
admitted_after: Some(s("2026-01-01")),
admitted_before: Some(s("2027-01-01")),
limit: Some(10),
semantic: Some(SemanticQuery { text: "what did we rule about keys".into(), top_k: 5 }),
};

View file

@ -11,9 +11,7 @@ use serde::{Deserialize, Serialize};
use crate::admission::{PipelineAdmissionBatch, PipelineAdmissionOutcome};
use crate::mind::Mind;
use crate::query::{
HistoryScope, PipelineDocumentView, PipelineOpenItems, PipelineQuery, PipelineQueryPage,
};
use crate::query::{PipelineDocumentView, PipelineQuery, PipelineQueryPage};
use crate::receipt::HuginnCommitReceipt;
use crate::refusal::MindRefusal;
use crate::store::MindStore;
@ -45,8 +43,6 @@ pub enum HuginnMindRequest {
Admit(PipelineAdmissionBatch),
View { instance: Slug, id: PipelineRef },
Query { instance: Slug, query: PipelineQuery },
OpenItems { instance: Slug, campaign: Slug },
History { instance: Slug, scope: HistoryScope },
}
impl HuginnMindRequest {
@ -57,8 +53,6 @@ impl HuginnMindRequest {
Self::Admit(_) => "admit",
Self::View { .. } => "view",
Self::Query { .. } => "query",
Self::OpenItems { .. } => "open_items",
Self::History { .. } => "history",
}
}
@ -67,10 +61,7 @@ impl HuginnMindRequest {
match self {
Self::Whoami => None,
Self::Admit(batch) => Some(&batch.instance),
Self::View { instance, .. }
| Self::Query { instance, .. }
| Self::OpenItems { instance, .. }
| Self::History { instance, .. } => Some(instance),
Self::View { instance, .. } | Self::Query { instance, .. } => Some(instance),
}
}
}
@ -84,8 +75,6 @@ pub enum HuginnMindResponse {
Admit(PipelineAdmissionOutcome),
View(Option<PipelineDocumentView>),
Query(PipelineQueryPage),
OpenItems(PipelineOpenItems),
History(Vec<PipelineDocumentView>),
Refused(MindRefusal),
}
@ -138,7 +127,7 @@ impl<S: MindStore> Mind<S> {
#[cfg(test)]
mod tests {
use super::*;
use crate::fixtures::{CAMPAIGN, INSTANCE, OTHER_INSTANCE, instance, provenance, r, repo, seeded, slug};
use crate::fixtures::{CAMPAIGN, INSTANCE, OTHER_INSTANCE, instance, provenance, r, seeded, slug};
use crate::receipt::Faculty;
fn requests() -> Vec<HuginnMindRequest> {
@ -151,12 +140,7 @@ mod tests {
HuginnMindRequest::Whoami,
HuginnMindRequest::Admit(batch),
HuginnMindRequest::View { instance: slug(INSTANCE), id: r(PipelineKind::Campaign, CAMPAIGN) },
HuginnMindRequest::Query { instance: slug(INSTANCE), query: PipelineQuery::default() },
HuginnMindRequest::OpenItems { instance: slug(INSTANCE), campaign: slug(CAMPAIGN) },
HuginnMindRequest::History {
instance: slug(OTHER_INSTANCE),
scope: HistoryScope::Repo(repo("GameCult/Huginn")),
},
HuginnMindRequest::Query { instance: slug(OTHER_INSTANCE), query: PipelineQuery::default() },
]
}
@ -169,8 +153,6 @@ mod tests {
HuginnMindResponse::Admit(PipelineAdmissionOutcome::Refused(refusal.clone())),
HuginnMindResponse::View(None),
HuginnMindResponse::Query(PipelineQueryPage { items: vec![], matched: 0 }),
HuginnMindResponse::OpenItems(seeded().open_items(&slug(CAMPAIGN)).unwrap()),
HuginnMindResponse::History(vec![]),
HuginnMindResponse::Refused(refusal),
]
}
@ -181,7 +163,7 @@ mod tests {
#[test]
fn the_wire_vocabulary_is_the_minds_methods_and_status_is_derived_from_the_response() {
let names: Vec<&str> = requests().iter().map(|request| request.operation()).collect();
assert_eq!(names, ["whoami", "admit", "view", "query", "open_items", "history"]);
assert_eq!(names, ["whoami", "admit", "view", "query"]);
for request in requests() {
let declared = request.instance().is_none();
assert_eq!(declared, matches!(request, HuginnMindRequest::Whoami), "{request:?}");
@ -189,7 +171,7 @@ mod tests {
assert_eq!(rmp_serde::from_slice::<HuginnMindRequest>(&bytes).unwrap(), request);
}
assert_eq!(
requests()[5].instance(),
requests()[3].instance(),
Some(&slug(OTHER_INSTANCE)),
"the request's instance is the one it declares, not the mind's"
);

View file

@ -68,54 +68,6 @@
"required": [
"Query"
]
},
{
"type": "object",
"properties": {
"OpenItems": {
"type": "object",
"properties": {
"campaign": {
"$ref": "#/$defs/Slug"
},
"instance": {
"$ref": "#/$defs/Slug"
}
},
"required": [
"instance",
"campaign"
]
}
},
"additionalProperties": false,
"required": [
"OpenItems"
]
},
{
"type": "object",
"properties": {
"History": {
"type": "object",
"properties": {
"instance": {
"$ref": "#/$defs/Slug"
},
"scope": {
"$ref": "#/$defs/HistoryScope"
}
},
"required": [
"instance",
"scope"
]
}
},
"additionalProperties": false,
"required": [
"History"
]
}
],
"$defs": {
@ -443,35 +395,6 @@
"type": "string",
"maxLength": 40
},
"HistoryScope": {
"description": "What a history is a history of: every resolution one subject ever had, or\nevery assignment of one repo to this mind.",
"oneOf": [
{
"type": "object",
"properties": {
"Subject": {
"$ref": "#/$defs/PipelineRef"
}
},
"additionalProperties": false,
"required": [
"Subject"
]
},
{
"type": "object",
"properties": {
"Repo": {
"$ref": "#/$defs/OrgRepo"
}
},
"additionalProperties": false,
"required": [
"Repo"
]
}
]
},
"Label": {
"description": "A key label: `[A-Za-z0-9_-]{1,64}`.",
"type": "string",
@ -1270,28 +1193,6 @@
"description": "The filters over one mind. Each is one rule, and an unset filter matches\neverything. The mind is the instance, so there is no `instance` field: the\ndaemon picks the mind before it calls here.",
"type": "object",
"properties": {
"admitted_after": {
"description": "Exclusive, compared as a string against `admitted_at`.",
"anyOf": [
{
"$ref": "#/$defs/Short"
},
{
"type": "null"
}
]
},
"admitted_before": {
"description": "Exclusive, compared as a string against `admitted_at`.",
"anyOf": [
{
"$ref": "#/$defs/Short"
},
{
"type": "null"
}
]
},
"campaign": {
"description": "The key's root segment: a campaign slug, or an instance for\nstewardships, hand-offs and the identity document.",
"anyOf": [

View file

@ -58,33 +58,6 @@
"Query"
]
},
{
"type": "object",
"properties": {
"OpenItems": {
"$ref": "#/$defs/PipelineOpenItems"
}
},
"additionalProperties": false,
"required": [
"OpenItems"
]
},
{
"type": "object",
"properties": {
"History": {
"type": "array",
"items": {
"$ref": "#/$defs/PipelineDocumentView"
}
}
},
"additionalProperties": false,
"required": [
"History"
]
},
{
"type": "object",
"properties": {
@ -2117,49 +2090,6 @@
"HandOff"
]
},
"PipelineOpenItems": {
"description": "One campaign's open work, derived from what is in force and what cites\nwhat. Uncapped: the open set of a campaign is bounded by the campaign, and\ntruncating it would hide work.",
"type": "object",
"properties": {
"findings": {
"type": "array",
"items": {
"$ref": "#/$defs/PipelineDocumentView"
}
},
"follow_ups": {
"type": "array",
"items": {
"$ref": "#/$defs/PipelineDocumentView"
}
},
"questions": {
"type": "array",
"items": {
"$ref": "#/$defs/PipelineDocumentView"
}
},
"reports_without_verdict": {
"type": "array",
"items": {
"$ref": "#/$defs/PipelineDocumentView"
}
},
"specs_without_report": {
"type": "array",
"items": {
"$ref": "#/$defs/PipelineDocumentView"
}
}
},
"required": [
"questions",
"findings",
"follow_ups",
"specs_without_report",
"reports_without_verdict"
]
},
"PipelineProvenance": {
"description": "Who admitted a batch: the faculty, the agent, its session and the tool.\nA field on the receipt and nothing else; the digest excludes it.",
"type": "object",

View file

@ -27,11 +27,11 @@
# mind is opened and then dropped when the mind refuses. Any weaker form is
# the correct order again.
#
# `D17`-`D19` pin three of the dispatch's four read arms and `D23` the fourth.
# The fourth was once recorded here as unpinnable, on the grounds that
# `Mind::open_items` raises no refusal of its own; the refusal it carries comes
# from the reader beneath it over a store whose receipt is gone, and such a
# store is reachable from this crate's surface, so the entry exists.
# `D17`-`D18` pin the dispatch's two read arms, `view` and `query`. RS-2
# deleted `open_items` and `history` along with `D19`, `D19L`, `D23` and
# `D23L`, the entries that pinned their arms; `D13` and `D13L` are re-anchored
# on the surviving `view`/`query` arms rather than deleted, since the rule
# they pin (one operation name per method) still holds over what remains.
@{
Mutations = @(
@{
@ -707,141 +707,6 @@ fn require_grammatical_slug(field: &str, declared: &Slug) -> Result<(), MindRefu
New = @'
Ok(page) => HuginnMindResponse::Query(page),
Err(_) => HuginnMindResponse::Query(huginn_mind::PipelineQueryPage { items: vec![], matched: 0 }),
'@
}
@{
Id = 'D19'
Rule = 'A refusal `history` raised crosses the dispatch as itself, not as another read''s refusal.'
Test = 'daemon::tests::a_refusal_a_read_raised_is_the_answer_the_dispatch_returns_whole'
File = 'crates/huginn-daemon/src/daemon.rs'
Old = @'
HuginnMindRequest::History { scope, .. } => match self.mind.history(&scope) {
Ok(views) => HuginnMindResponse::History(views),
Err(refusal) => HuginnMindResponse::Refused(refusal),
},
'@
New = @'
HuginnMindRequest::History { scope, .. } => match self.mind.history(&scope) {
Ok(views) => HuginnMindResponse::History(views),
Err(_) => HuginnMindResponse::Refused(huginn_mind::MindRefusal::Unavailable {
detail: "semantic query: the index is not wired (Cut 11)".into(),
}),
},
'@
}
@{
Id = 'D19L'
Rule = 'Nor is a history refusal swallowed into an empty history, which is the answer for a subject with no records.'
Test = 'daemon::tests::a_refusal_a_read_raised_is_the_answer_the_dispatch_returns_whole'
File = 'crates/huginn-daemon/src/daemon.rs'
Old = @'
Ok(views) => HuginnMindResponse::History(views),
Err(refusal) => HuginnMindResponse::Refused(refusal),
'@
New = @'
Ok(views) => HuginnMindResponse::History(views),
Err(_) => HuginnMindResponse::History(vec![]),
'@
}
@{
Id = 'D23'
Rule = 'A refusal `open_items` carries out of the reader crosses the dispatch as itself, not rewrapped as unavailable.'
Test = 'daemon::tests::a_refusal_open_items_raised_is_the_answer_the_dispatch_returns_whole'
File = 'crates/huginn-daemon/src/daemon.rs'
Old = @'
HuginnMindRequest::OpenItems { campaign, .. } => match self.mind.open_items(&campaign) {
Ok(items) => HuginnMindResponse::OpenItems(items),
Err(refusal) => HuginnMindResponse::Refused(refusal),
},
'@
New = @'
HuginnMindRequest::OpenItems { campaign, .. } => match self.mind.open_items(&campaign) {
Ok(items) => HuginnMindResponse::OpenItems(items),
Err(refusal) => HuginnMindResponse::Refused(huginn_mind::MindRefusal::Unavailable {
detail: format!("{refusal}"),
}),
},
'@
}
@{
Id = 'D23L'
Rule = 'Nor is it swallowed into an empty open set, which is what a healthy campaign with nothing open answers.'
Test = 'daemon::tests::a_refusal_open_items_raised_is_the_answer_the_dispatch_returns_whole'
File = 'crates/huginn-daemon/src/daemon.rs'
Old = @'
Ok(items) => HuginnMindResponse::OpenItems(items),
Err(refusal) => HuginnMindResponse::Refused(refusal),
'@
New = @'
Ok(items) => HuginnMindResponse::OpenItems(items),
Err(_) => HuginnMindResponse::OpenItems(huginn_mind::PipelineOpenItems {
questions: vec![],
findings: vec![],
follow_ups: vec![],
specs_without_report: vec![],
reports_without_verdict: vec![],
}),
'@
}
# S1 and S1d's fixture, `open_items_refuses_on_a_fault_inside_the_requested_campaign`,
# runs three faults in one test body: an orphan receipt, an undecodable
# document, and a document two receipts claim. N5, correcting an
# earlier claim here: neither mutant "dies on all three". S1d's own
# `New` exempts any detail containing "has no commit receipt" by
# construction, so the orphan block never fails under it; the test
# panics at the very next block, the undecodable document, and never
# reaches the third. S1 has no such exemption and is killed by the
# same first block its own widened check reaches, the orphan. Each
# mutant dies on the fault its own body actually mangles, not on all
# three the fixture happens to carry.
@{
Id = 'S1'
Rule = 'open_items refuses on a fault anywhere in the image it must read, not only on one outside the requested campaign.'
Test = 'daemon::tests::open_items_refuses_on_a_fault_inside_the_requested_campaign'
Command = 'cargo test -p huginn-daemon --lib'
File = 'crates/huginn-mind/src/query.rs'
Old = @'
let reader = Reader::new(self)?;
let views = reader
.views()?
.into_iter()
.filter(|view| root_and_local(&view.id.id.0).0 == campaign.0)
.collect::<Vec<_>>();
'@
New = @'
let views = match Reader::new(self).and_then(|reader| reader.views()) {
Ok(views) => views,
Err(MindRefusal::Unavailable { detail }) if detail.contains(campaign.0.as_str()) => Vec::new(),
Err(other) => return Err(other),
}
.into_iter()
.filter(|view| root_and_local(&view.id.id.0).0 == campaign.0)
.collect::<Vec<_>>();
'@
}
@{
Id = 'S1d'
Rule = 'It refuses on every kind of fault a document can carry, not only a missing receipt.'
Test = 'daemon::tests::open_items_refuses_on_a_fault_inside_the_requested_campaign'
Command = 'cargo test -p huginn-daemon --lib'
File = 'crates/huginn-mind/src/query.rs'
Old = @'
let reader = Reader::new(self)?;
let views = reader
.views()?
.into_iter()
.filter(|view| root_and_local(&view.id.id.0).0 == campaign.0)
.collect::<Vec<_>>();
'@
New = @'
let views = match Reader::new(self).and_then(|reader| reader.views()) {
Ok(views) => views,
Err(MindRefusal::Unavailable { detail }) if !detail.contains("has no commit receipt") => Vec::new(),
Err(other) => return Err(other),
}
.into_iter()
.filter(|view| root_and_local(&view.id.id.0).0 == campaign.0)
.collect::<Vec<_>>();
'@
}
@{
@ -1035,21 +900,21 @@ fn require_grammatical_slug(field: &str, declared: &Slug) -> Result<(), MindRefu
}
@{
Id = 'D13'
Rule = 'The wire vocabulary is the mind''s methods: one operation name per method, and it is that method''s name.'
Rule = 'The wire vocabulary is the mind''s methods: one operation name per method, and it is that method''s name. Re-anchored on `view` after RS-2 deleted `History`: `View`''s own name, duplicated onto `Query`''s spelling, breaks the one-name-per-method rule the same way.'
Test = 'wire::tests::the_wire_vocabulary_is_the_minds_methods_and_status_is_derived_from_the_response'
Command = 'cargo test -p huginn-mind --lib'
File = 'crates/huginn-mind/src/wire.rs'
Old = ' Self::History { .. } => "history",'
New = ' Self::History { .. } => "query",'
Old = ' Self::View { .. } => "view",'
New = ' Self::View { .. } => "query",'
}
@{
Id = 'D13L'
Rule = 'The operation name is the method''s spelling, so a client reading `Mind`''s surface can address it without a translation table.'
Rule = 'The operation name is the method''s exact spelling, so a client reading `Mind`''s surface can address it without a translation table. Re-anchored on `query` after RS-2 deleted `OpenItems`: PowerShell''s default `-eq` is case-insensitive, so a pure-casing mutant (`"query"` -> `"Query"`) reads as no change to the harness''s own "replacement changes nothing" guard; this loosening instead adds a plausible near-miss spelling.'
Test = 'wire::tests::the_wire_vocabulary_is_the_minds_methods_and_status_is_derived_from_the_response'
Command = 'cargo test -p huginn-mind --lib'
File = 'crates/huginn-mind/src/wire.rs'
Old = ' Self::OpenItems { .. } => "open_items",'
New = ' Self::OpenItems { .. } => "openItems",'
Old = ' Self::Query { .. } => "query",'
New = ' Self::Query { .. } => "queries",'
}
@{
Id = 'D14'

View file

@ -219,90 +219,6 @@
}
'@
}
@{
Id = 'V9'
Rule = 'History is in the scope''s own sequence order, not the image''s key order.'
Test = 'query::tests::a_subjects_history_lists_every_resolution_with_its_status_and_receipt'
File = 'crates/huginn-mind/src/query.rs'
Old = ' records.sort_by_key(|(sequence, _)| *sequence);'
New = ' let _ = &records;'
}
@{
Id = 'V10'
Rule = 'A subject''s history is selected by the subject field, so a resolution''s own withdrawals are not in it.'
Test = 'query::tests::a_subjects_history_lists_every_resolution_with_its_status_and_receipt'
File = 'crates/huginn-mind/src/query.rs'
Old = @'
.resolutions_of(subject)
.map(|(key, resolution)| (resolution.sequence, key.to_string()))
'@
New = @'
.resolutions()
.map(|(key, resolution)| { let _ = subject; (resolution.sequence, key.to_string()) })
'@
}
@{
Id = 'V11'
Rule = 'A repo''s history is selected by (this mind, this repo), so another repo''s assignments are another history.'
Test = 'query::tests::a_repos_stewardship_history_on_a_mind_lists_every_assignment'
File = 'crates/huginn-mind/src/query.rs'
Old = @'
.assignments_of(reader.mind.instance(), repo)
.map(|(key, stewardship)| (stewardship.sequence, key.to_string()))
'@
New = @'
.stewardships()
.map(|(key, stewardship)| { let _ = repo; (stewardship.sequence, key.to_string()) })
'@
}
@{
Id = 'V12'
Rule = 'Open questions, findings and follow-ups are the ones in force.'
Test = 'query::tests::open_items_are_derived_from_in_force_and_citation'
File = 'crates/huginn-mind/src/query.rs'
Old = ' of_kind(kind).filter(|view| view.status == PipelineStatus::InForce).cloned().collect::<Vec<_>>()'
New = ' of_kind(kind).cloned().collect::<Vec<_>>()'
}
@{
Id = 'V13'
Rule = 'A spec without a report is open only while it is in force: a superseded revision is not open work.'
Test = 'query::tests::open_items_are_derived_from_in_force_and_citation'
File = 'crates/huginn-mind/src/query.rs'
Old = ' specs_without_report: in_force(PipelineKind::CutSpec)'
New = ' specs_without_report: of_kind(PipelineKind::CutSpec).cloned().collect::<Vec<_>>()'
}
@{
Id = 'V13L'
Rule = 'A spec is reported by a report naming its exact id, not by any report of its cut: a report of the revision this one superseded is not this revision''s report.'
Test = 'query::tests::open_items_are_derived_from_in_force_and_citation'
File = 'crates/huginn-mind/src/query.rs'
Old = ' .filter(|view| !reported.contains(&view.id.id.0.as_str()))'
New = ' .filter(|view| !reported.iter().any(|cited| root_and_local(cited).1.split(''.'').next() == root_and_local(&view.id.id.0).1.split(''.'').next()))'
}
@{
Id = 'V14'
Rule = 'A report is closed by the verdict that names it; a report is not resolvable, so nothing else closes it.'
Test = 'query::tests::open_items_are_derived_from_in_force_and_citation'
File = 'crates/huginn-mind/src/query.rs'
Old = ' .filter(|view| !judged.contains(&view.id.id.0.as_str()))'
New = ' .filter(|view| { let _ = &judged; true })'
}
@{
Id = 'V14L'
Rule = 'The citation is compared as the exact id, not as the cut it belongs to: one cut may have two reports and one verdict.'
Test = 'query::tests::open_items_are_derived_from_in_force_and_citation'
File = 'crates/huginn-mind/src/query.rs'
Old = ' .filter(|view| !judged.contains(&view.id.id.0.as_str()))'
New = ' .filter(|view| !judged.iter().any(|cited| root_and_local(cited).1.split(''.'').next() == root_and_local(&view.id.id.0).1.split(''.'').next()))'
}
@{
Id = 'V15'
Rule = 'Open items are one campaign''s, selected by the key''s root.'
Test = 'query::tests::open_items_are_derived_from_in_force_and_citation'
File = 'crates/huginn-mind/src/query.rs'
Old = ' .filter(|view| root_and_local(&view.id.id.0).0 == campaign.0)'
New = ' .filter(|view| { let _ = &campaign; true })'
}
@{
Id = 'V16'
Rule = 'The cut filter is the label, not every cut.'
@ -416,52 +332,6 @@
'@
New = ''
}
@{
Id = 'V22'
Rule = 'The admission window selects by admitted_at.'
Test = 'query::tests::query_filters_each_select_by_one_field'
Edits = @(
@{
File = 'crates/huginn-mind/src/query.rs'
Old = @'
if let Some(after) = &query.admitted_after
&& view.admission.admitted_at <= after.0
{
return false;
}
'@
New = ''
}
@{
File = 'crates/huginn-mind/src/query.rs'
Old = @'
if let Some(before) = &query.admitted_before
&& view.admission.admitted_at >= before.0
{
return false;
}
'@
New = ''
}
)
}
@{
Id = 'V22L'
Rule = 'Both ends of the window are exclusive at the exact boundary.'
Test = 'query::tests::query_filters_each_select_by_one_field'
Edits = @(
@{
File = 'crates/huginn-mind/src/query.rs'
Old = ' && view.admission.admitted_at <= after.0'
New = ' && view.admission.admitted_at < after.0'
}
@{
File = 'crates/huginn-mind/src/query.rs'
Old = ' && view.admission.admitted_at >= before.0'
New = ' && view.admission.admitted_at > before.0'
}
)
}
@{
Id = 'V23'
Rule = 'repo selects by the repo the document names, read through the base.'
@ -486,48 +356,15 @@
}
@{
Id = 'V24'
Rule = 'Every door that takes a ref asks the leaf''s grammar first: a ref whose kind and id disagree is refused, never answered over as an absent document or an empty history.'
Test = 'query::tests::a_ref_whose_kind_and_id_disagree_is_refused_by_both_doors'
Edits = @(
@{
File = 'crates/huginn-mind/src/query.rs'
Old = @'
id.validate_ref()?;
let reader = Reader::new(self)?;
'@
New = @'
let reader = Reader::new(self)?;
'@
}
@{
File = 'crates/huginn-mind/src/query.rs'
Old = @'
if let HistoryScope::Subject(subject) = scope {
subject.validate_ref()?;
}
'@
New = @'
if let HistoryScope::Subject(subject) = scope {
let _ = subject;
}
'@
}
)
}
@{
Id = 'V24L'
Rule = 'Both doors ask, not one: a mind that validates the ref it views and not the subject it takes a history of still answers an empty history over a ref that is no ref.'
Rule = 'The door that takes a ref asks the leaf''s grammar first: a ref whose kind and id disagree is refused, never answered over as an absent document. RS-2 deleted `history`, the rule''s other door; only `view`''s survives, so this is now a single edit rather than the two-door `Edits` array it was before.'
Test = 'query::tests::a_ref_whose_kind_and_id_disagree_is_refused_by_both_doors'
File = 'crates/huginn-mind/src/query.rs'
Old = @'
if let HistoryScope::Subject(subject) = scope {
subject.validate_ref()?;
}
id.validate_ref()?;
let reader = Reader::new(self)?;
'@
New = @'
if let HistoryScope::Subject(subject) = scope {
let _ = subject;
}
let reader = Reader::new(self)?;
'@
}
)