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