diff --git a/crates/eureka-state/src/bin/huginn/main.rs b/crates/eureka-state/src/bin/huginn/main.rs index 280ae96..3e8ef08 100644 --- a/crates/eureka-state/src/bin/huginn/main.rs +++ b/crates/eureka-state/src/bin/huginn/main.rs @@ -39,11 +39,13 @@ use clap::{CommandFactory, FromArgMatches, Parser, Subcommand}; use cultnet_rs::{PROJECTION_DOCUMENT, Selection}; use eureka_state::hold; use huginn_mind::eureka_pipeline::{ - Line, PipelineDocument, PipelineRef, Short, Slug, pipeline_key, + Label, Line, MemoryOrigin, OrgRepo, PipelineDocument, PipelineFollowUp, PipelineKind, PipelineRef, Short, Slug, + pipeline_key, }; use huginn_mind::{ - BATCH_MAX, ChatQuery, ChatWindowQuery, Faculty, HuginnMindRequest, HuginnMindResponse, MindRefusal, PipelineAdmissionBatch, PipelineAdmissionOutcome, - PipelinePageItems, PipelineProvenance, PipelineSelectionPage, SemanticQuery, SourceQuery, + ACTIVITY_REPOS_MAX, BATCH_MAX, ChatQuery, ChatWindowQuery, Faculty, HuginnMindRequest, HuginnMindResponse, + MindRefusal, PipelineAdmissionBatch, PipelineAdmissionOutcome, PipelineFacts, PipelinePageItems, + PipelineProvenance, PipelineSelectionPage, SemanticQuery, SourceQuery, }; use serde_json::Value; @@ -68,7 +70,7 @@ After Committed or AlreadyAdmitted the batch is read back and compared with what const IMPORT_HELP: &str = "Reads the giver's mind (it sends Query alone) and admits its receipts for the campaign into this one, one batch per source receipt, in order, each naming the giver's receipt in imported_from. It refuses unless the campaign is moved to this mind (exit 1), and when this mind already holds records under the campaign that it did not import from the giver, except follow-ups and ideas it admitted after the import began, which stay in place and are named (exit 1). A rerun after any stop resumes at the first batch this mind does not hold; it prints `imported from : ... verified` only after comparing every document it holds with the giver's (exit 5 if one differs). Until it prints imported, this mind writes nothing else under the campaign; a write that collides stops the import with the refusal (exit 1). Exit 3 Unavailable (rerun), 4 the history cannot be replayed whole (a receipt over 64 documents, too many external referents, a receipt held in part). Only a Self run can run it: a Persona's traffic to a peer's huginn port is fenced."; #[derive(Parser, Debug)] -#[command(name = "huginn", about = "Huginn's mind: whoami, view, query, recipes, persona, admit, import, recall, schema", arg_required_else_help = true)] +#[command(name = "huginn", about = "Huginn's mind: whoami, view, query, recipes, persona, activity, escalate, admit, import, recall, schema", arg_required_else_help = true)] struct Cli { #[command(subcommand)] command: Command, @@ -221,6 +223,50 @@ enum Command { #[command(subcommand)] command: Box, }, + /// Recent forge activity and open PRs in stewarded (or named) repositories. + Activity { + /// Repository as `Org/Repo`. Repeat for several; defaults to in-force stewardships for this instance. + #[arg(long = "repo")] + repos: Vec, + /// Only events after this forge feed cursor (from a previous `head`). + #[arg(long)] + after: Option, + }, + /// Escalate a follow-up brief to Self (usable over the persona door). + Escalate { + /// The campaign's slug; the brief's source is `:campaign:self`. + #[arg(long)] + campaign: String, + /// The repository as `Org/Repo`. + #[arg(long)] + repo: String, + /// What needs attention in the next Self run. + #[arg(long)] + item: String, + /// Why this can wait for a Self run rather than blocking now. + #[arg(long)] + why_it_can_wait: String, + /// The follow-up's label; generated from the timestamp if omitted. + #[arg(long)] + label: Option, + /// The room alias or id where the need arose (conflicts with --dm). + #[arg(long, conflicts_with = "dm")] + room: Option, + /// The direct-message room id where the need arose (conflicts with --room). + #[arg(long, conflicts_with = "room")] + dm: Option, + /// Sender(s) heard from in --room or --dm. Repeat for several. + #[arg(long = "heard-from")] + heard_from: Vec, + #[arg(long, value_parser = faculty, default_value = "Member")] + faculty: Faculty, + /// The escalating agent's name (the daemon pins `mind-persona` on the receipt). + #[arg(long, default_value = "mind-persona")] + agent: String, + /// The escalating session; else HUGINN_SESSION. + #[arg(long)] + session: Option, + }, } #[derive(Subcommand, Debug)] @@ -375,6 +421,33 @@ fn run(settings: &Settings, command: Command) -> Result { import::run(settings, import::Flags { campaign, from, from_endpoint, faculty, agent, session }) } Command::Persona { command } => persona::run(settings, *command), + Command::Activity { repos, after } => activity(settings, repos, after), + Command::Escalate { + campaign, + repo, + item, + why_it_can_wait, + label, + room, + dm, + heard_from, + faculty, + agent, + session, + } => escalate( + settings, + campaign, + repo, + item, + why_it_can_wait, + label, + room, + dm, + heard_from, + faculty, + agent, + session, + ), Command::Recall { command: RecallCommand::Dispatch { top_k, max_anchors, budget, deadline_ms } } => Ok(recall::dispatch( settings, &recall::Flags { top_k: top_k as usize, max_anchors: max_anchors as usize, budget: budget as usize, deadline_ms }, @@ -652,17 +725,22 @@ fn admit( let request = |instance: &Slug| { HuginnMindRequest::Admit(PipelineAdmissionBatch { instance: instance.clone(), provenance, documents }) }; - match settings.ask(request)? { + let response = settings.ask(request)?; + handle_admit_outcome(settings, response, &sent) +} + +fn handle_admit_outcome(settings: &Settings, response: HuginnMindResponse, sent: &[PipelineDocument]) -> Result { + match response { HuginnMindResponse::Admit(PipelineAdmissionOutcome::Committed { receipt_id, committed_at, writes }) => { say(format_args!("Committed {receipt_id} at {committed_at}")); for write in &writes { say(format_args!("wrote {}", write.id.0)); } - read_back(settings, &sent) + read_back(settings, sent) } HuginnMindResponse::Admit(PipelineAdmissionOutcome::AlreadyAdmitted { receipt_id }) => { say(format_args!("AlreadyAdmitted {receipt_id}")); - read_back(settings, &sent) + read_back(settings, sent) } HuginnMindResponse::Admit(PipelineAdmissionOutcome::Refused(refusal)) | HuginnMindResponse::Refused(refusal) => { Ok(refused(&refusal)) @@ -678,6 +756,163 @@ fn admit( } } +fn stewarded_repos(settings: &Settings) -> Result, Trouble> { + let owner = settings.client()?.instance().0.clone(); + let mut selection = door::selection_value(&serde_json::json!({ + "schemas": [PipelineKind::Stewardship.type_id()], + "fields": [{ "index": "in_force", "op": "any_of", "values": ["true"] }], + "limit": DEFAULT_LIMIT, + }))?; + let mut repos: Vec = Vec::new(); + loop { + let page = match settings.ask(|instance| HuginnMindRequest::Query { + instance: instance.clone(), + selection: selection.clone(), + semantic: None, + })? { + HuginnMindResponse::Query(page) => page, + HuginnMindResponse::Refused(refusal) => { + return Err(Trouble::Internal(format!("stewardship query refused: {refusal:?}"))); + } + other => return Err(unexpected(&other)), + }; + let PipelinePageItems::Headers(headers) = page.items else { + return Err(Trouble::Internal("stewardship query answered documents, not headers".into())); + }; + for header in headers { + if let PipelineFacts::Stewardship { instance, repo, .. } = header.facts + && instance.0 == owner + && !repos.iter().any(|held| held.0.eq_ignore_ascii_case(&repo.0)) + { + repos.push(repo); + if repos.len() >= ACTIVITY_REPOS_MAX { + return Ok(repos); + } + } + } + let Some(next) = page.next else { + return Ok(repos); + }; + selection.cursor = Some(next); + } +} + +fn activity(settings: &Settings, repos: Vec, after: Option) -> Result { + let repos = if repos.is_empty() { + stewarded_repos(settings)? + } else { + if repos.len() > ACTIVITY_REPOS_MAX { + return Err(Trouble::invalid(format!( + "at most {ACTIVITY_REPOS_MAX} repositories may be queried at once" + ))); + } + let mut parsed = Vec::with_capacity(repos.len()); + for raw in repos { + let repo = OrgRepo(raw); + repo.validate_org_repo() + .map_err(|refusal| Trouble::invalid(format!("--repo is not Org/Repo: {refusal:?}")))?; + if !parsed.iter().any(|held: &OrgRepo| held.0.eq_ignore_ascii_case(&repo.0)) { + parsed.push(repo); + } + } + parsed + }; + match settings.ask(|instance| HuginnMindRequest::StewardedActivity { + instance: instance.clone(), + repos, + after, + })? { + HuginnMindResponse::Activity(found) => { + say(render::activity(&found)); + Ok(0) + } + HuginnMindResponse::Refused(MindRefusal::Unavailable { detail }) => Err(Trouble::Unavailable(detail)), + HuginnMindResponse::Refused(refusal) => Ok(refused(&refusal)), + other => Err(unexpected(&other)), + } +} + +#[allow(clippy::too_many_arguments)] +fn escalate( + settings: &Settings, + campaign: String, + repo: String, + item: String, + why_it_can_wait: String, + label: Option, + room: Option, + dm: Option, + heard_from: Vec, + faculty: Faculty, + agent: String, + session: Option, +) -> Result { + let session = settings.session(session)?; + if !heard_from.is_empty() && room.is_none() && dm.is_none() { + return Err(Trouble::invalid("--heard-from requires --room or --dm")); + } + if item.trim().is_empty() { + return Err(Trouble::invalid("--item must not be blank")); + } + if why_it_can_wait.trim().is_empty() { + return Err(Trouble::invalid("--why-it-can-wait must not be blank")); + } + let campaign = Slug(campaign); + let label = Label(label.unwrap_or_else(|| { + format!("esc-{}-{}", chrono::Utc::now().timestamp_millis(), std::process::id()) + })); + let repo = OrgRepo(repo); + let item = Line(item); + let why_it_can_wait = Line(why_it_can_wait); + let origin = match (room, dm) { + (Some(rooms), None) => Some(MemoryOrigin::Room { + rooms: Short(rooms), + heard_from: heard_from.into_iter().map(Short).collect(), + }), + (None, Some(room)) => Some(MemoryOrigin::Direct { + room: Short(room), + with: heard_from.into_iter().map(Short).collect(), + }), + (None, None) => None, + (Some(_), Some(_)) => return Err(Trouble::invalid("--room and --dm cannot both be given")), + }; + let expected = PipelineDocument::FollowUp(PipelineFollowUp { + campaign: campaign.clone(), + label: label.clone(), + source: PipelineRef { + kind: PipelineKind::Campaign, + id: Short(format!("{}:campaign:self", campaign.0)), + }, + repo: repo.clone(), + locations: Vec::new(), + item: item.clone(), + why_it_can_wait: why_it_can_wait.clone(), + owner: Short("self-run".into()), + origin: origin.clone(), + }); + expected + .validate() + .map_err(|refusal| Trouble::invalid(format!("invalid escalation field: {refusal:?}")))?; + let provenance = PipelineProvenance { + faculty, + agent: Short(agent), + session: Short(session), + tool: Short(TOOL.to_string()), + imported_from: None, + }; + let response = settings.ask(|instance| HuginnMindRequest::EscalateGoal { + instance: instance.clone(), + provenance, + campaign, + label, + repo, + item, + why_it_can_wait, + origin, + })?; + handle_admit_outcome(settings, response, &[expected]) +} + /// The end-to-end check that the mind kept what was sent: one `keys` query, /// each stored document compared with the one sent. A difference is exit 5, /// not silence, whatever dropped it (an older leaf, a serde default, skew). diff --git a/crates/eureka-state/src/bin/huginn/render.rs b/crates/eureka-state/src/bin/huginn/render.rs index 5da647e..5ee34e1 100644 --- a/crates/eureka-state/src/bin/huginn/render.rs +++ b/crates/eureka-state/src/bin/huginn/render.rs @@ -3,7 +3,10 @@ use std::fmt::Write; use huginn_mind::eureka_pipeline::{PipelineResolution, ResolutionOutcome}; -use huginn_mind::{ChatHits, ChatWindow, SourceHits, IndexStatus, PersonaStatus, PipelineDocumentSummary, PipelineDocumentView, PipelineStatus, PipelineStatusSummary}; +use huginn_mind::{ + ChatHits, ChatWindow, IndexStatus, PersonaStatus, PipelineDocumentSummary, PipelineDocumentView, PipelineStatus, + PipelineStatusSummary, RepoActivity, RepoChange, SourceHits, +}; use serde::Serialize; use serde_json::Value; @@ -213,6 +216,47 @@ pub fn chat_window(found: &ChatWindow) -> String { out } +/// Forge activity as plain text: `head `, then events, open PRs, and +/// any `capped`, `unseen`, or `moved` repositories. +pub fn activity(found: &RepoActivity) -> String { + let mut out = format!("head {}\n", found.head); + for event in &found.events { + let what = match event.change { + RepoChange::Pushed { commits } => format!("pushed {commits}"), + RepoChange::Pr { number, action } => format!("pr #{number} {}", name_of(&action)), + }; + let _ = writeln!( + out, + "event {} {} {} {} {what}", + event.id, + crate::chat::shown(event.at), + event.repo.0, + event.actor.0 + ); + } + for pr in &found.open_prs { + let _ = writeln!( + out, + "open_pr {} #{} {} {}", + pr.repo.0, + pr.number, + pr.author.0, + crate::chat::shown(pr.updated_at) + ); + } + for repo in &found.capped { + let _ = writeln!(out, "capped {}", repo.0); + } + for repo in &found.unseen { + let _ = writeln!(out, "unseen {}", repo.0); + } + for moved in &found.moved { + let _ = writeln!(out, "moved {} -> {}", moved.from.0, moved.to.0); + } + out.pop(); + out +} + /// A fact as one token: a string, a number, a flag, a reference's id, or a /// list of those joined by commas. Anything deeper is not a header fact. fn scalar(value: &Value) -> Option { diff --git a/crates/eureka-state/tests/cli.rs b/crates/eureka-state/tests/cli.rs index 860f5ae..3272299 100644 --- a/crates/eureka-state/tests/cli.rs +++ b/crates/eureka-state/tests/cli.rs @@ -4035,3 +4035,249 @@ fn persona_bond_custom_kind_and_expired_intention_semantics() { assert_eq!(seed_after.code, 0, "{} {}", seed_after.out, seed_after.err); assert!(seed_after.out.contains("deru [my_custom]"), "{}", seed_after.out); } + +fn serve_with_persona( + root: TempDir, + mut daemon: huginn_daemon::Daemon, +) -> (Server, SocketAddr) { + let mut hub = huginn_daemon::serve::bind("127.0.0.1:0".parse().unwrap(), &daemon.runtime_id()).unwrap(); + let mut persona_hub = huginn_daemon::serve::bind("127.0.0.1:0".parse().unwrap(), &daemon.runtime_id()).unwrap(); + let addr = hub.local_addr().unwrap(); + let persona_addr = persona_hub.local_addr().unwrap(); + let stopping = Arc::new(std::sync::atomic::AtomicBool::new(false)); + let loop_stopping = Arc::clone(&stopping); + let registry = huginn_daemon::serve::schema_registry().unwrap(); + let thread = std::thread::spawn(move || { + huginn_daemon::serve::run( + &mut daemon, + &mut hub, + Some(&mut persona_hub), + ®istry, + None, + &loop_stopping, + &huginn_daemon::ServeOptions::default(), + ) + .unwrap(); + }); + (Server { addr, stopping, thread: Some(thread), ended: Arc::default(), _root: Some(root) }, persona_addr) +} + +#[test] +fn huginn_escalate_and_activity_cli_round_trip() { + use huginn_mind::eureka_pipeline::{MemoryOrigin, PipelineFollowUp}; + use huginn_mind::{ + OpenPr, PipelineDocumentSummary, PipelineFacts, PipelineStatusSummary, PrAction, RepoActivity, RepoChange, + RepoEvent, RepoMoved, + }; + + // 1. Live daemon with Door::Persona: escalate commits FollowUp with server-pinned fields, + // read_back verifies, while plain `admit` is still refused with NotThisDoor, and + // `activity` exits 3 when the daemon has no forge. + let (root, daemon) = mind(vec![vec![campaign(), stewardship()]]); + let (_server, persona_addr) = serve_with_persona(root, daemon); + + let escalated = at( + persona_addr, + &[ + "escalate", + "--campaign", + CAMPAIGN, + "--repo", + REPO, + "--label", + "esc-cli-1", + "--item", + "Investigate mutex contention.", + "--why-it-can-wait", + "Next Self run can inspect.", + "--room", + "#swarm:gamecult.org", + "--heard-from", + "@meta:gamecult.org", + "--agent", + "spoofed-agent", + "--session", + "p-session-1", + ], + None, + ); + assert_eq!(escalated.code, 0, "{} {}", escalated.out, escalated.err); + assert!(escalated.out.contains("Committed mind-commit-"), "{}", escalated.out); + assert!(escalated.out.contains(&format!("wrote {CAMPAIGN}:follow_up:esc-cli-1")), "{}", escalated.out); + assert!(escalated.out.contains("read back 1 equal"), "{}", escalated.out); + + let viewed = at(persona_addr, &["view", &format!("{CAMPAIGN}:follow_up:esc-cli-1")], None); + assert_eq!(viewed.code, 0, "{} {}", viewed.out, viewed.err); + assert!(viewed.out.contains("Member/mind-persona session p-session-1"), "{}", viewed.out); + let raw = at(persona_addr, &["view", "--raw", &format!("{CAMPAIGN}:follow_up:esc-cli-1")], None); + assert_eq!(raw.code, 0, "{} {}", raw.out, raw.err); + let doc: PipelineDocument = serde_json::from_str(&raw.out).unwrap(); + let PipelineDocument::FollowUp(PipelineFollowUp { source, owner, locations, origin, .. }) = doc else { + panic!("expected FollowUp"); + }; + assert_eq!(owner.0, "self-run"); + assert!(locations.is_empty()); + assert_eq!(source, PipelineRef { kind: PipelineKind::Campaign, id: Short(format!("{CAMPAIGN}:campaign:self")) }); + assert_eq!( + origin, + Some(MemoryOrigin::Room { + rooms: Short("#swarm:gamecult.org".into()), + heard_from: vec![Short("@meta:gamecult.org".into())], + }) + ); + + // Omitting --label auto-generates a valid label and --dm sets Direct origin. + let dm_escalated = at( + persona_addr, + &[ + "escalate", + "--campaign", + CAMPAIGN, + "--repo", + REPO, + "--item", + "Follow up from DM.", + "--why-it-can-wait", + "Next Self run.", + "--dm", + "!dm:gamecult.org", + "--heard-from", + "@meta:gamecult.org", + "--session", + "p-session-2", + ], + None, + ); + assert_eq!(dm_escalated.code, 0, "{} {}", dm_escalated.out, dm_escalated.err); + assert!(dm_escalated.out.contains("read back 1 equal"), "{}", dm_escalated.out); + + // Admit still refuses over Door::Persona. + let dir = tempfile::tempdir().unwrap(); + let batch_file = write(&dir, "c.json", &json!([campaign_json()])); + let admit_refused = at(persona_addr, &admit_args(&batch_file), None); + assert_eq!(admit_refused.code, 1, "{} {}", admit_refused.out, admit_refused.err); + assert!(admit_refused.out.contains("NotThisDoor"), "{}", admit_refused.out); + + // escalate negative validations: no --json, no --heard-from without --room/--dm, no blank item. + for bad in [ + vec!["escalate", "--json", "--campaign", CAMPAIGN, "--repo", REPO, "--item", "x", "--why-it-can-wait", "y", "--session", "s"], + vec!["escalate", "--campaign", CAMPAIGN, "--repo", REPO, "--item", "x", "--why-it-can-wait", "y", "--heard-from", "@a", "--session", "s"], + vec!["escalate", "--campaign", CAMPAIGN, "--repo", REPO, "--item", " ", "--why-it-can-wait", "y", "--session", "s"], + ] { + let ran = at(persona_addr, &bad, None); + assert_eq!(ran.code, 2, "{bad:?}: {} {}", ran.out, ran.err); + } + + // activity against a daemon without a forge exits 3 (Unavailable). + let no_forge = at(persona_addr, &["activity"], None); + assert_eq!(no_forge.code, 3, "{} {}", no_forge.out, no_forge.err); + assert!(no_forge.err.starts_with("Unavailable: "), "{}", no_forge.err); + + // 2. Scripted server verifying Stewardship autodiscovery, --repo/--after, and plain-text rendering. + let seen = Arc::new(Mutex::new(Vec::::new())); + let sink = Arc::clone(&seen); + let activity_payload = RepoActivity { + head: 42, + events: vec![RepoEvent { + id: 41, + at: 1_765_000_000_000, + repo: OrgRepo("GameCult/Huginn".into()), + actor: Short("alice".into()), + change: RepoChange::Pr { number: 12, action: PrAction::Opened }, + }], + capped: vec![OrgRepo("GameCult/Capped".into())], + open_prs: vec![OpenPr { + repo: OrgRepo("GameCult/Huginn".into()), + number: 12, + author: Short("alice".into()), + updated_at: 1_765_000_000_000, + }], + unseen: vec![OrgRepo("GameCult/Secret".into())], + moved: vec![RepoMoved { + from: OrgRepo("GameCult/Old".into()), + to: OrgRepo("GameCult/New".into()), + }], + }; + let payload_for_srv = activity_payload.clone(); + let spy = scripted(move |message| { + let (_, request) = decode_request(message).unwrap(); + sink.lock().unwrap().push(request.clone()); + match request { + HuginnMindRequest::Query { .. } => { + let make_hdr = |id: &str, inst: &str, repo_name: &str| PipelineDocumentSummary { + id: PipelineRef { kind: PipelineKind::Stewardship, id: Short(id.into()) }, + status: PipelineStatusSummary::InForce, + admission: AdmissionFacts { + receipt_id: "r1".into(), + admitted_at: "2026-10-10T10:00:00Z".into(), + provenance: provenance(), + ordinal: 1, + }, + facts: PipelineFacts::Stewardship { + instance: slug(inst), + repo: OrgRepo(repo_name.into()), + sequence: 1, + assigned_on: Date("2026-10-10".into()), + note: "assigned".into(), + names: vec![], + }, + }; + let page = PipelineSelectionPage { + matched: 2, + as_of: 1, + next: None, + items: PipelinePageItems::Headers(vec![ + make_hdr(&format!("{INSTANCE}:stewardship:GameCult.Huginn.s1"), INSTANCE, "GameCult/Huginn"), + make_hdr("other-mind:stewardship:GameCult.Foreign.s1", "other-mind", "GameCult/Foreign"), + ]), + edges: None, + scores: None, + }; + answer("query", &HuginnMindResponse::Query(page)) + } + HuginnMindRequest::StewardedActivity { .. } => { + answer("stewarded_activity", &HuginnMindResponse::Activity(payload_for_srv.clone())) + } + other => panic!("unexpected request: {other:?}"), + } + }); + + let auto = at(spy.addr, &["activity"], None); + assert_eq!(auto.code, 0, "{} {}", auto.out, auto.err); + assert!(auto.out.contains("head 42"), "{}", auto.out); + assert!(auto.out.contains("event 41 "), "{}", auto.out); + assert!(auto.out.contains("GameCult/Huginn alice pr #12 Opened"), "{}", auto.out); + assert!(auto.out.contains("open_pr GameCult/Huginn #12 alice "), "{}", auto.out); + assert!(auto.out.contains("capped GameCult/Capped"), "{}", auto.out); + assert!(auto.out.contains("unseen GameCult/Secret"), "{}", auto.out); + assert!(auto.out.contains("moved GameCult/Old -> GameCult/New"), "{}", auto.out); + + let explicit = at(spy.addr, &["activity", "--repo", "GameCult/Epiphany", "--after", "10"], None); + assert_eq!(explicit.code, 0, "{} {}", explicit.out, explicit.err); + + let recorded = seen.lock().unwrap(); + assert_eq!(recorded.len(), 3, "{recorded:?}"); + assert!(matches!(&recorded[0], HuginnMindRequest::Query { .. })); + assert_eq!( + recorded[1], + HuginnMindRequest::StewardedActivity { + instance: slug(INSTANCE), + repos: vec![OrgRepo("GameCult/Huginn".into())], + after: None, + } + ); + assert_eq!( + recorded[2], + HuginnMindRequest::StewardedActivity { + instance: slug(INSTANCE), + repos: vec![OrgRepo("GameCult/Epiphany".into())], + after: Some(10), + } + ); + + // Negative activity flags: no --json, invalid --repo. + for bad in [vec!["activity", "--json"], vec!["activity", "--repo", "not-org-repo"]] { + let ran = at(spy.addr, &bad, None); + assert_eq!(ran.code, 2, "{bad:?}: {} {}", ran.out, ran.err); + } +}