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