huginn-mind: a Steward ruling is selected by decider and repo, indexed by her words, and printed with who decided it
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c9a8e73dbc
commit
c2f251cb26
7 changed files with 187 additions and 20 deletions
|
|
@ -100,7 +100,17 @@ pub fn header(item: &PipelineDocumentSummary) -> String {
|
|||
let _ = write!(line, " {name}");
|
||||
}
|
||||
for (key, value) in facts {
|
||||
if key != "title"
|
||||
if key == "authority"
|
||||
&& let Some(Value::Object(steward)) = value.get("Steward")
|
||||
{
|
||||
// Her words stay out of the header: it names who decided and under what.
|
||||
let _ = write!(line, " authority=Steward");
|
||||
for field in ["steward", "repo"] {
|
||||
if let Some(shown) = steward.get(field).and_then(scalar) {
|
||||
let _ = write!(line, " {field}={shown}");
|
||||
}
|
||||
}
|
||||
} else if key != "title"
|
||||
&& key != "label"
|
||||
&& let Some(shown) = scalar(value)
|
||||
{
|
||||
|
|
@ -256,6 +266,32 @@ two
|
|||
assert_eq!(serde_json::from_str::<SourceHits>(&json).unwrap(), found, "--json round-trips");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_steward_ruling_header_names_the_decider_and_her_stewardship_but_not_her_words() {
|
||||
use huginn_mind::eureka_pipeline::{OrgRepo, PipelineRuling, RulingAuthority};
|
||||
let mut view = viewed(None, PipelineStatus::InForce);
|
||||
view.document = PipelineDocument::Ruling(PipelineRuling {
|
||||
campaign: Slug("c".into()),
|
||||
label: "R1".into(),
|
||||
title: "Zeros".into(),
|
||||
answers: None,
|
||||
choice: None,
|
||||
ruling: "Refuse them.".into(),
|
||||
operator_quote: None,
|
||||
ruled_on: Date("2026-11-11".into()),
|
||||
precedents: vec![],
|
||||
authority: RulingAuthority::Steward {
|
||||
steward: "@heimdall:chat".into(),
|
||||
repo: OrgRepo("GameCult/Bifrost".into()),
|
||||
words: "refuse leading zeros".into(),
|
||||
event: None,
|
||||
},
|
||||
});
|
||||
let line = header(&PipelineDocumentSummary::of(&view, &|_| None));
|
||||
assert!(line.contains("authority=Steward steward=@heimdall:chat repo=GameCult/Bifrost"), "{line}");
|
||||
assert!(!line.contains("zeros"), "{line}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_fact_is_one_token_or_nothing() {
|
||||
assert_eq!(scalar(&json!("")), None);
|
||||
|
|
|
|||
|
|
@ -2345,6 +2345,22 @@ mod tests {
|
|||
committed(admit(&mut mind, vec![D::Ruling(quoted)]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_steward_ruling_takes_no_operator_quote() {
|
||||
let mut mind = seeded();
|
||||
let mut peer = ruling("R1");
|
||||
peer.authority = RulingAuthority::Steward {
|
||||
steward: "@heimdall:chat".into(),
|
||||
repo: eureka_pipeline::OrgRepo("GameCult/Bifrost".into()),
|
||||
words: "refuse leading zeros".into(),
|
||||
event: None,
|
||||
};
|
||||
peer.operator_quote = Some("all recommendations, go ahead".into());
|
||||
assert_eq!(refusal(admit(&mut mind, vec![D::Ruling(peer.clone())])), MindRefusal::QuoteWithoutOperator { ruling: id("ruling", "R1") });
|
||||
peer.operator_quote = None;
|
||||
committed(admit(&mut mind, vec![D::Ruling(peer)]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_mind_ruling_without_a_quote_is_admitted() {
|
||||
let mut mind = seeded();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
//! how a change to it makes every projection rebuild. No network, no JSON, no
|
||||
//! store handle: the daemon owns the vector store and the embedder.
|
||||
|
||||
use eureka_pipeline::{PipelineDocument, PipelineKind, PipelineRef};
|
||||
use eureka_pipeline::{PipelineDocument, PipelineKind, PipelineRef, RulingAuthority};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
use crate::mind::Mind;
|
||||
|
|
@ -56,6 +56,9 @@ pub fn index_text(document: &PipelineDocument) -> Option<String> {
|
|||
lines.push(&ruling.title.0);
|
||||
lines.push(&ruling.ruling.0);
|
||||
lines.extend(ruling.operator_quote.iter().map(|quote| quote.0.as_str()));
|
||||
if let RulingAuthority::Steward { words, .. } = &ruling.authority {
|
||||
lines.push(&words.0);
|
||||
}
|
||||
}
|
||||
D::CutSpec(spec) => {
|
||||
lines.push(&spec.title.0);
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ impl PipelineFacts {
|
|||
title: value.title.clone(),
|
||||
answers: value.answers.clone(),
|
||||
choice: value.choice.clone(),
|
||||
authority: value.authority,
|
||||
authority: value.authority.clone(),
|
||||
ruled_on: value.ruled_on.clone(),
|
||||
},
|
||||
D::CutSpec(value) => Self::CutSpec {
|
||||
|
|
@ -1504,6 +1504,25 @@ mod tests {
|
|||
assert!(matches!(refused(&mind, &misspelt), MindRefusal::SelectionInvalid { value: Some(v), .. } if v == "Minds"));
|
||||
}
|
||||
|
||||
/// A peer's ruling is found by the Mind who decided, by the stewardship she decided under, and by authority.
|
||||
#[test]
|
||||
fn a_peers_rulings_are_selected_by_mind_and_by_repo() {
|
||||
let mut mind = seeded();
|
||||
let mut peer = ruling("R1");
|
||||
peer.authority = RulingAuthority::Steward {
|
||||
steward: "@heimdall:chat".into(),
|
||||
repo: eureka_pipeline::OrgRepo("GameCult/Bifrost".into()),
|
||||
words: "refuse leading zeros".into(),
|
||||
event: None,
|
||||
};
|
||||
committed(admit(&mut mind, vec![D::Ruling(peer), D::Ruling(ruling("R2"))]));
|
||||
let found = |alias: &str, word: &str| mind.query(&with(of_kinds(&[K::Ruling]), any_of(alias, &[word]))).unwrap().matched;
|
||||
assert_eq!(found("authority", "Steward"), 1);
|
||||
assert_eq!(found("about", "@heimdall:chat"), 1);
|
||||
assert_eq!(found("repo", "GameCult/Bifrost"), 1);
|
||||
assert_eq!(found("repo", "GameCult/CultLib"), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unknown_schema_or_malformed_key_is_refused() {
|
||||
let mind = worked();
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use std::collections::BTreeMap;
|
|||
|
||||
use cultnet_rs::{Row, RowSet, Selection};
|
||||
use eureka_pipeline::{
|
||||
FindingConfidence, FindingOrigin, FindingSeverity, Label, MemoryOrigin, MemorySort, OrgRepo, PipelineDocument, PipelineKind, PipelineRef, ResolutionOutcome,
|
||||
FindingConfidence, FindingOrigin, FindingSeverity, Label, MemoryOrigin, MemorySort, OrgRepo, PipelineDocument, PipelineKind, PipelineRef, PipelineRuling, ResolutionOutcome,
|
||||
RulingAuthority, RunOperator, RunTurn, Slug,
|
||||
};
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ impl Alias {
|
|||
match self {
|
||||
Self::Root | Self::InForce | Self::Faculty => true,
|
||||
Self::Repo => {
|
||||
matches!(kind, K::Campaign | K::CutSpec | K::CutReport | K::FollowUp | K::Stewardship | K::HandOff | K::Resolution)
|
||||
matches!(kind, K::Campaign | K::CutSpec | K::CutReport | K::FollowUp | K::Stewardship | K::HandOff | K::Resolution | K::Ruling)
|
||||
}
|
||||
Self::Cut => matches!(kind, K::CutSpec | K::CutReport | K::Verdict | K::Finding | K::Resolution),
|
||||
Self::Severity | Self::Confidence | Self::Origin => kind == K::Finding,
|
||||
|
|
@ -143,7 +143,8 @@ impl Alias {
|
|||
Self::Outcome => kind == K::Resolution,
|
||||
Self::Turn | Self::OperatedBy | Self::Ran => kind == K::Run,
|
||||
Self::Voted | Self::Urged => kind == K::Pulse,
|
||||
Self::Sort | Self::About | Self::MemoryOrigin => kind == K::Memory,
|
||||
Self::Sort | Self::MemoryOrigin => kind == K::Memory,
|
||||
Self::About => matches!(kind, K::Memory | K::Ruling),
|
||||
Self::Pass => matches!(kind, K::Research | K::Idea),
|
||||
}
|
||||
}
|
||||
|
|
@ -246,6 +247,7 @@ impl SelectionRow {
|
|||
D::FollowUp(follow_up) => vec![follow_up.repo.identity()],
|
||||
D::Stewardship(stewardship) => vec![stewardship.repo.identity()],
|
||||
D::HandOff(hand_off) => vec![hand_off.repo.identity()],
|
||||
D::Ruling(PipelineRuling { authority: RulingAuthority::Steward { repo, .. }, .. }) => vec![repo.identity()],
|
||||
D::Target(_) | D::Question(_) | D::Ruling(_) | D::Verdict(_) | D::Finding(_) | D::Instance(_) | D::Resolution(_) | D::Run(_) | D::Pulse(_) | D::Reply(_) | D::Thought(_) | D::Memory(_) | D::Research(_) | D::Idea(_) | D::DeskAnswer(_) => {
|
||||
Vec::new()
|
||||
}
|
||||
|
|
@ -267,7 +269,12 @@ impl SelectionRow {
|
|||
put(Alias::Confidence, vec![format!("{:?}", finding.confidence)]);
|
||||
put(Alias::Origin, vec![format!("{:?}", finding.origin)]);
|
||||
}
|
||||
D::Ruling(ruling) => put(Alias::Authority, vec![format!("{:?}", ruling.authority)]),
|
||||
D::Ruling(ruling) => {
|
||||
put(Alias::Authority, vec![ruling.authority.name().to_string()]);
|
||||
if let RulingAuthority::Steward { steward, .. } = &ruling.authority {
|
||||
put(Alias::About, vec![steward.0.clone()]);
|
||||
}
|
||||
}
|
||||
D::Verdict(verdict) => {
|
||||
put(Alias::ClaimOutcome, verdict.claims.iter().map(|claim| format!("{:?}", claim.outcome)).collect())
|
||||
}
|
||||
|
|
@ -463,7 +470,7 @@ mod tests {
|
|||
(K::Campaign, &["repo"]),
|
||||
(K::Target, &[]),
|
||||
(K::Question, &[]),
|
||||
(K::Ruling, &["authority"]),
|
||||
(K::Ruling, &["authority", "repo", "about"]),
|
||||
(K::CutSpec, &["repo", "cut"]),
|
||||
(K::CutReport, &["repo", "cut"]),
|
||||
(K::Verdict, &["cut", "claim_outcome"]),
|
||||
|
|
|
|||
|
|
@ -2929,12 +2929,55 @@
|
|||
]
|
||||
},
|
||||
"RulingAuthority": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Operator",
|
||||
"Standing",
|
||||
"Defaulted",
|
||||
"Mind"
|
||||
"description": "Who decided a ruling, and under what. `Mind` is this mind's own decision, admitted by her Self. `Steward` is\na named peer's decision inside the peer's stewardship, as this mind heard it: `steward` is the deciding Mind's\nMatrix id, `repo` the stewardship she decided under, `words` her own words copied from the line this mind heard,\n`event` that line's Matrix event id when it was a delivery. The four unit variants stay bare strings on the wire.",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Operator",
|
||||
"Standing",
|
||||
"Defaulted",
|
||||
"Mind"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Steward": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"event": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/$defs/Short"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"repo": {
|
||||
"$ref": "#/$defs/OrgRepo"
|
||||
},
|
||||
"steward": {
|
||||
"$ref": "#/$defs/Short"
|
||||
},
|
||||
"words": {
|
||||
"$ref": "#/$defs/Para"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"steward",
|
||||
"repo",
|
||||
"words"
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"Steward"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"RunOperator": {
|
||||
|
|
|
|||
|
|
@ -5891,12 +5891,55 @@
|
|||
]
|
||||
},
|
||||
"RulingAuthority": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Operator",
|
||||
"Standing",
|
||||
"Defaulted",
|
||||
"Mind"
|
||||
"description": "Who decided a ruling, and under what. `Mind` is this mind's own decision, admitted by her Self. `Steward` is\na named peer's decision inside the peer's stewardship, as this mind heard it: `steward` is the deciding Mind's\nMatrix id, `repo` the stewardship she decided under, `words` her own words copied from the line this mind heard,\n`event` that line's Matrix event id when it was a delivery. The four unit variants stay bare strings on the wire.",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Operator",
|
||||
"Standing",
|
||||
"Defaulted",
|
||||
"Mind"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Steward": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"event": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/$defs/Short"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"repo": {
|
||||
"$ref": "#/$defs/OrgRepo"
|
||||
},
|
||||
"steward": {
|
||||
"$ref": "#/$defs/Short"
|
||||
},
|
||||
"words": {
|
||||
"$ref": "#/$defs/Para"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"steward",
|
||||
"repo",
|
||||
"words"
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"Steward"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"RunId": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue