wear-facts: a Mind's first line shows the wear her own mind holds, specs with no report, open Soul findings and quiet campaigns on what she stewards, each leading to a record she can open (squash of hands/eureka-body-wear-facts ab61a53..6014554; Soul s1-s2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ab61a538bb
commit
cb86f58a7d
14 changed files with 1203 additions and 24 deletions
|
|
@ -17,7 +17,7 @@ use eureka_state::{ClientError, HuginnClient};
|
|||
use huginn_mind::{
|
||||
Faculty, HuginnMindRequest, HuginnMindResponse, PipelineAdmissionBatch,
|
||||
PipelineAdmissionOutcome, PipelineDocumentSummary, PipelineFacts, PipelineProvenance,
|
||||
PipelineSelectionPage, PipelineStatusSummary, RepoActivity, SemanticQuery,
|
||||
PipelineSelectionPage, PipelineStatusSummary, RepoActivity, RootTouched, SemanticQuery,
|
||||
};
|
||||
|
||||
/// The last `CONSECUTIVE` ended runs over an item, all empty, trip its breaker.
|
||||
|
|
@ -46,6 +46,11 @@ pub trait MindPort {
|
|||
fn stewarded_activity(&self, _repos: &[OrgRepo], _after: Option<u64>) -> Result<RepoActivity> {
|
||||
bail!("this mind port has no forge to read")
|
||||
}
|
||||
/// Every root her mind holds a document under, with its newest admission and a campaign's repos in force. A port that does not
|
||||
/// read a mind refuses.
|
||||
fn roots_touched(&self) -> Result<Vec<RootTouched>> {
|
||||
bail!("this mind port has no roots to read")
|
||||
}
|
||||
/// Admits `documents` as one batch, attributed to `agent` in `session`.
|
||||
fn admit(&self, agent: &str, session: &str, documents: Vec<PipelineDocument>) -> Result<PipelineAdmissionOutcome>;
|
||||
}
|
||||
|
|
@ -104,6 +109,15 @@ impl MindPort for HuginnMind<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
fn roots_touched(&self) -> Result<Vec<RootTouched>> {
|
||||
let request = HuginnMindRequest::RootsTouched { instance: self.instance().clone() };
|
||||
match (self.call)(request).map_err(|error| anyhow!("the mind could not be asked: {}", client_error_code(&error)))? {
|
||||
HuginnMindResponse::RootsTouched(roots) => Ok(roots),
|
||||
HuginnMindResponse::Refused(_) => bail!("the mind refused the roots read"),
|
||||
_ => bail!("the mind answered a roots read with something else"),
|
||||
}
|
||||
}
|
||||
|
||||
fn admit(&self, agent: &str, session: &str, documents: Vec<PipelineDocument>) -> Result<PipelineAdmissionOutcome> {
|
||||
let batch = PipelineAdmissionBatch {
|
||||
instance: self.instance().clone(),
|
||||
|
|
@ -575,6 +589,38 @@ mod tests {
|
|||
assert!(format!("{:#}", port.stewarded_activity(&repos, None).unwrap_err()).contains("something else"));
|
||||
}
|
||||
|
||||
/// The roots ask goes out as the one `RootsTouched` request naming her instance, a real mind's answer comes back whole through
|
||||
/// `HuginnMind` itself, and a refusal, a client error or any other answer is an error that carries nothing of the refusal.
|
||||
#[test]
|
||||
fn a_roots_read_goes_through_the_port_as_one_request() {
|
||||
let mind = TestMind::seeded();
|
||||
let seen = std::cell::RefCell::new(Vec::new());
|
||||
let broken = std::cell::Cell::new(0u8);
|
||||
let port = HuginnMind::over(Slug(INSTANCE.into()), Box::new(|request| {
|
||||
seen.borrow_mut().push(request.clone());
|
||||
match broken.get() {
|
||||
0 => Ok(mind.answer(request)),
|
||||
1 => Ok(HuginnMindResponse::Refused(huginn_mind::MindRefusal::Unavailable { detail: "canary-roots-detail".into() })),
|
||||
2 => Ok(HuginnMindResponse::View(None)),
|
||||
_ => Err(ClientError::Unencodable { detail: "canary-detail".into() }),
|
||||
}
|
||||
}));
|
||||
let roots = port.roots_touched().unwrap();
|
||||
assert_eq!(seen.borrow()[0], HuginnMindRequest::RootsTouched { instance: Slug(INSTANCE.into()) });
|
||||
let campaign = roots.iter().find(|root| root.root.0 == CAMPAIGN).expect("the seeded campaign is a root");
|
||||
assert_eq!(campaign.repos, [OrgRepo::from(REPO)], "the campaign's repos in force come back through the port");
|
||||
assert!(roots.iter().any(|root| root.root.0 == INSTANCE && root.repos.is_empty()), "{roots:?}");
|
||||
|
||||
broken.set(1);
|
||||
let refused = port.roots_touched().unwrap_err();
|
||||
assert!(format!("{refused:#}").contains("refused the roots read") && !format!("{refused:#}").contains("canary"), "{refused:#}");
|
||||
broken.set(2);
|
||||
assert!(format!("{:#}", port.roots_touched().unwrap_err()).contains("something else"));
|
||||
broken.set(3);
|
||||
let down = port.roots_touched().unwrap_err();
|
||||
assert!(format!("{down:#}").contains("could not be asked") && !format!("{down:#}").contains("canary"), "{down:#}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runs_of_another_item_are_not_this_items_runs() {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue