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