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