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