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