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 notices;
61pub mod persona;
62pub mod persona_icon;
63mod pr_head;
64pub mod pr_outcome;
65pub mod pr_recovery;
66pub mod proc;
67pub mod prompt;
68pub mod question_delivery;
69pub mod queue;
70pub mod rebase;
71pub mod reconcile;
72pub mod recovery;
73pub mod refs;
74pub mod release_local;
75pub mod release_manifest;
76pub mod release_watch;
77mod repo_lock;
78pub mod report;
79pub mod report_view;
80pub mod repos;
81pub mod retention;
82pub mod review_repair;
83pub mod rng;
84pub mod run;
85pub mod scrub;
86mod seat_process;
87pub mod settings;
88pub mod stats;
89mod stop_reason;
90pub mod talk;
91pub mod task_chat;
92pub mod triage;
93pub mod tui;
94pub mod updater;
95pub mod verdict;
96pub mod waiter;
97pub mod web;
98pub mod worker;
99pub mod worktree_setup;
100
101pub mod choice_effect;
102mod resume;
103
104// Run environment-sensitive unit fixtures as ordinary standalone invocations,
105// without mutating the concurrent test harness or inheriting worker ownership.
106#[cfg(test)]
107pub(crate) fn standalone_test(name: &str) -> bool {
108    const CHILD: &str = "MAGI_STANDALONE_TEST";
109    if std::env::var(CHILD).as_deref() == Ok(name) {
110        return true;
111    }
112    let output = std::process::Command::new(std::env::current_exe().expect("test executable"))
113        .args(["--exact", name, "--nocapture"])
114        .env(CHILD, name)
115        .env_remove("MAGI_WORKER_ID")
116        .env_remove("MAGI_WORKER_GENERATION")
117        .env_remove("MAGI_WORKER_HOME")
118        .env_remove("MAGI_WORKER_EXE")
119        .output()
120        .expect("standalone test process");
121    assert!(
122        output.status.success() && String::from_utf8_lossy(&output.stdout).contains("1 passed"),
123        "standalone test {name} failed: {}\n{}\n{}",
124        output.status,
125        String::from_utf8_lossy(&output.stdout),
126        String::from_utf8_lossy(&output.stderr)
127    );
128    false
129}