Test ACTIVITY_REPOS_MAX bounds in huginn activity CLI round trip
This commit is contained in:
parent
87f815af7f
commit
f025e0ecb2
1 changed files with 79 additions and 2 deletions
|
|
@ -4066,8 +4066,8 @@ fn serve_with_persona(
|
||||||
fn huginn_escalate_and_activity_cli_round_trip() {
|
fn huginn_escalate_and_activity_cli_round_trip() {
|
||||||
use huginn_mind::eureka_pipeline::{MemoryOrigin, PipelineFollowUp};
|
use huginn_mind::eureka_pipeline::{MemoryOrigin, PipelineFollowUp};
|
||||||
use huginn_mind::{
|
use huginn_mind::{
|
||||||
OpenPr, PipelineDocumentSummary, PipelineFacts, PipelineStatusSummary, PrAction, RepoActivity, RepoChange,
|
ACTIVITY_REPOS_MAX, OpenPr, PipelineDocumentSummary, PipelineFacts, PipelineStatusSummary, PrAction, RepoActivity,
|
||||||
RepoEvent, RepoMoved,
|
RepoChange, RepoEvent, RepoMoved,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 1. Live daemon with Door::Persona: escalate commits FollowUp with server-pinned fields,
|
// 1. Live daemon with Door::Persona: escalate commits FollowUp with server-pinned fields,
|
||||||
|
|
@ -4280,4 +4280,81 @@ fn huginn_escalate_and_activity_cli_round_trip() {
|
||||||
let ran = at(spy.addr, &bad, None);
|
let ran = at(spy.addr, &bad, None);
|
||||||
assert_eq!(ran.code, 2, "{bad:?}: {} {}", ran.out, ran.err);
|
assert_eq!(ran.code, 2, "{bad:?}: {} {}", ran.out, ran.err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Boundary checks on ACTIVITY_REPOS_MAX (64): autodiscovery collects all up to the cap
|
||||||
|
// instead of stopping at 1, explicit --repo allows exact cap (64), and rejects cap + 1 (65).
|
||||||
|
let seen_cap = Arc::new(Mutex::new(Vec::<HuginnMindRequest>::new()));
|
||||||
|
let sink_cap = Arc::clone(&seen_cap);
|
||||||
|
let empty_activity = RepoActivity {
|
||||||
|
head: 1,
|
||||||
|
events: vec![],
|
||||||
|
capped: vec![],
|
||||||
|
open_prs: vec![],
|
||||||
|
unseen: vec![],
|
||||||
|
moved: vec![],
|
||||||
|
};
|
||||||
|
let cap_srv = scripted(move |message| {
|
||||||
|
let (_, request) = decode_request(message).unwrap();
|
||||||
|
sink_cap.lock().unwrap().push(request.clone());
|
||||||
|
match request {
|
||||||
|
HuginnMindRequest::Query { .. } => {
|
||||||
|
let items: Vec<PipelineDocumentSummary> = (0..=ACTIVITY_REPOS_MAX)
|
||||||
|
.map(|idx| PipelineDocumentSummary {
|
||||||
|
id: PipelineRef { kind: PipelineKind::Stewardship, id: Short(format!("{INSTANCE}:stewardship:r{idx}")) },
|
||||||
|
status: PipelineStatusSummary::InForce,
|
||||||
|
admission: AdmissionFacts {
|
||||||
|
receipt_id: "r1".into(),
|
||||||
|
admitted_at: "2026-10-10T10:00:00Z".into(),
|
||||||
|
provenance: provenance(),
|
||||||
|
ordinal: idx as u64 + 1,
|
||||||
|
},
|
||||||
|
facts: PipelineFacts::Stewardship {
|
||||||
|
instance: slug(INSTANCE),
|
||||||
|
repo: OrgRepo(format!("GameCult/R{idx:02}")),
|
||||||
|
sequence: 1,
|
||||||
|
assigned_on: Date("2026-10-10".into()),
|
||||||
|
note: "assigned".into(),
|
||||||
|
names: vec![],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
let page = PipelineSelectionPage {
|
||||||
|
matched: items.len() as u32,
|
||||||
|
as_of: 1,
|
||||||
|
next: None,
|
||||||
|
items: PipelinePageItems::Headers(items),
|
||||||
|
edges: None,
|
||||||
|
scores: None,
|
||||||
|
};
|
||||||
|
answer("query", &HuginnMindResponse::Query(page))
|
||||||
|
}
|
||||||
|
HuginnMindRequest::StewardedActivity { .. } => {
|
||||||
|
answer("stewarded_activity", &HuginnMindResponse::Activity(empty_activity.clone()))
|
||||||
|
}
|
||||||
|
other => panic!("unexpected request: {other:?}"),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let capped_auto = at(cap_srv.addr, &["activity"], None);
|
||||||
|
assert_eq!(capped_auto.code, 0, "{} {}", capped_auto.out, capped_auto.err);
|
||||||
|
|
||||||
|
let exact_args: Vec<String> = std::iter::once("activity".to_string())
|
||||||
|
.chain((0..ACTIVITY_REPOS_MAX).flat_map(|idx| ["--repo".to_string(), format!("GameCult/R{idx:02}")]))
|
||||||
|
.collect();
|
||||||
|
let exact_refs: Vec<&str> = exact_args.iter().map(String::as_str).collect();
|
||||||
|
let exact_cap = at(cap_srv.addr, &exact_refs, None);
|
||||||
|
assert_eq!(exact_cap.code, 0, "{} {}", exact_cap.out, exact_cap.err);
|
||||||
|
|
||||||
|
let over_args: Vec<String> = std::iter::once("activity".to_string())
|
||||||
|
.chain((0..=ACTIVITY_REPOS_MAX).flat_map(|idx| ["--repo".to_string(), format!("GameCult/R{idx:02}")]))
|
||||||
|
.collect();
|
||||||
|
let over_refs: Vec<&str> = over_args.iter().map(String::as_str).collect();
|
||||||
|
let over_cap = at(cap_srv.addr, &over_refs, None);
|
||||||
|
assert_eq!(over_cap.code, 2, "{} {}", over_cap.out, over_cap.err);
|
||||||
|
|
||||||
|
let cap_recorded = seen_cap.lock().unwrap();
|
||||||
|
assert_eq!(cap_recorded.len(), 3, "over-cap must not send");
|
||||||
|
let HuginnMindRequest::StewardedActivity { repos: auto_repos, .. } = &cap_recorded[1] else {
|
||||||
|
panic!("expected StewardedActivity");
|
||||||
|
};
|
||||||
|
assert_eq!(auto_repos.len(), ACTIVITY_REPOS_MAX);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue