Skip to main content

magi/
lib.rs

1//! magi — a blind multi-agent implementation competition.
2//!
3//! One task, several agents, and a graph that decides which implementation
4//! survives without a human reading the diff:
5//!
6//! 1. **implement** — N agents solve the same task in isolated git worktrees,
7//!    unaware of each other.
8//! 2. **judge** — M judges rank the candidates blind: labels `A`/`B`/`C`, a
9//!    per-judge presentation order, attribution trailers stripped at write time
10//!    by a `commit-msg` hook and again at presentation time.
11//! 3. **deliberate** — if the first choices disagree, the judges argue, with
12//!    magi as the facilitator. A facilitator made of code cannot leak an author.
13//! 4. **vote** — final votes are collected one-to-one and privately, so nobody
14//!    can drift toward a visible majority.
15//! 5. **review** — the winner enters a bounded review + real-machine
16//!    verification loop with a fixer that may reject a finding with an argument.
17//! 6. **gate** — configured commands must pass before anything merges.
18//!
19//! Everything is recorded, so the by-products are real numbers: per-agent win
20//! rates, per-reviewer precision, and how often execution caught what static
21//! review missed. See [`stats`].
22#![deny(missing_docs)]
23
24pub mod advise;
25pub mod agent;
26pub mod already;
27pub mod ask;
28mod base_conflict;
29mod base_recovery_control;
30mod base_sync_recovery;
31pub mod blind;
32pub mod blockers;
33pub mod bump;
34pub mod cache;
35pub mod chat_control;
36mod chat_merge;
37pub mod chat_notify;
38pub mod chat_watch;
39pub mod chat_worker;
40pub mod clean;
41pub mod conduct;
42pub mod config;
43pub mod consult;
44pub mod daemon;
45pub mod deputy;
46pub mod direct;
47pub mod disk;
48mod driver;
49pub mod dupes;
50mod external_merge_attention;
51pub mod fixer;
52mod fold_evidence;
53pub mod followup;
54pub mod foreign_checkout;
55pub mod git;
56pub mod github_text;
57pub mod graft;
58pub mod graft_report;
59pub mod graph;
60pub mod handover;
61mod id_reserve;
62pub mod incremental;
63pub mod land;
64pub mod lang;
65mod lock_file;
66pub mod md;
67pub mod merge_decision;
68pub mod notice_delivery;
69mod notice_semantics;
70pub mod notices;
71pub mod persona;
72pub mod persona_icon;
73mod pr_head;
74pub mod pr_outcome;
75pub mod pr_recovery;
76pub mod proc;
77pub mod prompt;
78pub mod question_delivery;
79pub mod queue;
80pub mod rebase;
81pub mod reconcile;
82pub mod recovery;
83pub mod refs;
84pub mod release_local;
85pub mod release_manifest;
86pub mod release_watch;
87pub mod repair_budget;
88pub mod repo_clone;
89mod repo_lock;
90pub mod report;
91pub mod report_view;
92pub mod repos;
93pub mod retention;
94pub mod review_repair;
95pub mod rng;
96pub mod run;
97pub mod run_progress;
98pub mod scrub;
99mod seat_process;
100pub mod settings;
101/// Explicit audit-only repair of never-executed startup reservations.
102pub mod startup_reconcile;
103pub mod stats;
104mod stop_reason;
105pub mod talk;
106pub mod task_chat;
107pub mod task_decision;
108pub mod task_inquiry;
109pub mod triage;
110pub mod tui;
111pub mod updater;
112pub mod verdict;
113pub mod waiter;
114pub mod web;
115pub mod worker;
116mod worktree_clean;
117pub mod worktree_setup;
118
119pub mod choice_effect;
120mod resume;
121
122// Run environment-sensitive unit fixtures as ordinary standalone invocations,
123// without mutating the concurrent test harness or inheriting worker ownership.
124#[cfg(test)]
125pub(crate) fn standalone_test(name: &str) -> bool {
126    const CHILD: &str = "MAGI_STANDALONE_TEST";
127    if std::env::var(CHILD).as_deref() == Ok(name) {
128        return true;
129    }
130    let mut command = std::process::Command::new(std::env::current_exe().expect("test executable"));
131    for key in worker::INVOCATION_ENV {
132        command.env_remove(key);
133    }
134    let output = command
135        .args(["--exact", name, "--nocapture"])
136        .env(CHILD, name)
137        .output()
138        .expect("standalone test process");
139    assert!(
140        output.status.success() && String::from_utf8_lossy(&output.stdout).contains("1 passed"),
141        "standalone test {name} failed: {}\n{}\n{}",
142        output.status,
143        String::from_utf8_lossy(&output.stdout),
144        String::from_utf8_lossy(&output.stderr)
145    );
146    false
147}
148
149pub mod repo_selector;
150pub mod task_reassign;