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