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