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;
28pub mod blind;
29pub mod blockers;
30pub mod bump;
31pub mod cache;
32pub mod chat_control;
33pub mod chat_notify;
34pub mod chat_watch;
35pub mod clean;
36pub mod conduct;
37pub mod config;
38pub mod consult;
39pub mod daemon;
40pub mod deputy;
41pub mod direct;
42pub mod disk;
43mod driver;
44pub mod dupes;
45pub mod fixer;
46mod fold_evidence;
47pub mod followup;
48pub mod git;
49pub mod github_text;
50pub mod graft;
51pub mod graft_report;
52pub mod graph;
53pub mod handover;
54mod id_reserve;
55pub mod land;
56pub mod lang;
57mod lock_file;
58pub mod md;
59pub mod merge_decision;
60pub mod notice_delivery;
61pub mod notices;
62pub mod persona;
63pub mod persona_icon;
64mod pr_head;
65pub mod pr_outcome;
66pub mod pr_recovery;
67pub mod proc;
68pub mod prompt;
69pub mod question_delivery;
70pub mod queue;
71pub mod rebase;
72pub mod reconcile;
73pub mod recovery;
74pub mod refs;
75pub mod release_local;
76pub mod release_manifest;
77pub mod release_watch;
78mod repo_lock;
79pub mod report;
80pub mod report_view;
81pub mod repos;
82pub mod retention;
83pub mod review_repair;
84pub mod rng;
85pub mod run;
86pub mod scrub;
87mod seat_process;
88pub mod settings;
89pub mod stats;
90mod stop_reason;
91pub mod talk;
92pub mod task_chat;
93pub mod triage;
94pub mod tui;
95pub mod updater;
96pub mod verdict;
97pub mod waiter;
98pub mod web;
99pub mod worker;
100pub mod worktree_setup;
101
102pub mod choice_effect;
103mod resume;
104
105// Run environment-sensitive unit fixtures as ordinary standalone invocations,
106// without mutating the concurrent test harness or inheriting worker ownership.
107#[cfg(test)]
108pub(crate) fn standalone_test(name: &str) -> bool {
109    const CHILD: &str = "MAGI_STANDALONE_TEST";
110    if std::env::var(CHILD).as_deref() == Ok(name) {
111        return true;
112    }
113    let mut command = std::process::Command::new(std::env::current_exe().expect("test executable"));
114    for key in worker::INVOCATION_ENV {
115        command.env_remove(key);
116    }
117    let output = command
118        .args(["--exact", name, "--nocapture"])
119        .env(CHILD, name)
120        .output()
121        .expect("standalone test process");
122    assert!(
123        output.status.success() && String::from_utf8_lossy(&output.stdout).contains("1 passed"),
124        "standalone test {name} failed: {}\n{}\n{}",
125        output.status,
126        String::from_utf8_lossy(&output.stdout),
127        String::from_utf8_lossy(&output.stderr)
128    );
129    false
130}