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