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