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