minga-swarm 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +41 -4
- package/README.md +17 -1
- package/dist/minga.mjs +532 -79
- package/examples/pnp-lean/project.toml +1 -1
- package/package.json +1 -1
- package/src/cli/client.ts +9 -3
- package/src/cli/commands.ts +218 -24
- package/src/cli/dispatch.ts +86 -21
- package/src/cli/doctor.ts +53 -2
- package/src/cli/init.ts +5 -3
- package/src/cli/join-doc.ts +29 -14
- package/src/cli/main.ts +28 -7
- package/src/cli/mcp.ts +54 -13
- package/src/cli/runtime.ts +2 -2
- package/src/cli/store.ts +60 -3
- package/src/cli/sync.ts +157 -0
- package/src/core/protocol.ts +27 -2
- package/src/log/reducer.ts +6 -0
- package/src/sched/scheduler.ts +17 -5
- package/src/server/app.ts +65 -10
- package/src/server/git-http.ts +76 -0
- package/src/server/latency.ts +38 -0
- package/src/server/main.ts +39 -2
- package/src/ui/dev-server.ts +39 -21
- package/src/ui/index.html +266 -116
package/src/server/main.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { loadProject } from "../project/config.ts";
|
|
|
18
18
|
import { branchHead, changedPaths, commitAccepted } from "../verify/gitops.ts";
|
|
19
19
|
import { createCheckPool } from "../verify/runner.ts";
|
|
20
20
|
import { createApp } from "./app.ts";
|
|
21
|
+
import { isGitRequest, serveGit } from "./git-http.ts";
|
|
21
22
|
|
|
22
23
|
const { values } = parseArgs({
|
|
23
24
|
options: {
|
|
@@ -28,6 +29,7 @@ const { values } = parseArgs({
|
|
|
28
29
|
"check-concurrency": { type: "string" },
|
|
29
30
|
"join-limit": { type: "string", default: "20" },
|
|
30
31
|
"dry-run": { type: "boolean", default: false },
|
|
32
|
+
"allow-checked-out": { type: "boolean", default: false },
|
|
31
33
|
},
|
|
32
34
|
});
|
|
33
35
|
|
|
@@ -53,7 +55,29 @@ let head: string;
|
|
|
53
55
|
try {
|
|
54
56
|
head = await branchHead(repoDir, cfg.branch);
|
|
55
57
|
} catch {
|
|
56
|
-
|
|
58
|
+
// A missing project branch starts at the current commit (init picks a dedicated "minga" branch).
|
|
59
|
+
const start = Bun.spawnSync(["git", "-C", repoDir, "rev-parse", "--verify", "--quiet", "HEAD^{commit}"]);
|
|
60
|
+
const startSha = start.stdout.toString().trim();
|
|
61
|
+
if (start.exitCode !== 0 || startSha === "") {
|
|
62
|
+
die(`branch ${cfg.branch} does not exist in ${repoDir} and there is no commit to start it from`, "commit something first");
|
|
63
|
+
}
|
|
64
|
+
if (!values["dry-run"]) {
|
|
65
|
+
const made = Bun.spawnSync(["git", "-C", repoDir, "update-ref", `refs/heads/${cfg.branch}`, startSha, ""]);
|
|
66
|
+
if (made.exitCode !== 0) die(`cannot create branch ${cfg.branch}: ${made.stderr.toString().trim()}`);
|
|
67
|
+
console.log(`minga: created branch ${cfg.branch} at ${startSha.slice(0, 12)}; accepted work lands there (merge it whenever you like)`);
|
|
68
|
+
}
|
|
69
|
+
head = startSha;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Accepted commits move the branch ref directly. If that branch is checked out, the
|
|
73
|
+
// working tree and index fall behind it and the next "git commit -a" there silently
|
|
74
|
+
// reverts the agents' work, so refuse unless told otherwise.
|
|
75
|
+
const checkedOut = checkedOutIn(repoDir, cfg.branch);
|
|
76
|
+
if (checkedOut !== null && !values["allow-checked-out"]) {
|
|
77
|
+
die(
|
|
78
|
+
`branch ${cfg.branch} is checked out in ${checkedOut}; accepted commits would move it under that working tree`,
|
|
79
|
+
`set branch = "minga" in project.toml (serve creates it), check out another branch there, or pass --allow-checked-out`,
|
|
80
|
+
);
|
|
57
81
|
}
|
|
58
82
|
const concurrency = values["check-concurrency"] !== undefined
|
|
59
83
|
? Math.max(1, Number(values["check-concurrency"]) || 1)
|
|
@@ -69,6 +93,18 @@ if (values["dry-run"]) {
|
|
|
69
93
|
process.exit(0);
|
|
70
94
|
}
|
|
71
95
|
|
|
96
|
+
/** The worktree path that has `branch` checked out, or null. Check-pool worktrees are detached. */
|
|
97
|
+
function checkedOutIn(repo: string, branch: string): string | null {
|
|
98
|
+
const list = Bun.spawnSync(["git", "-C", repo, "worktree", "list", "--porcelain"]);
|
|
99
|
+
if (list.exitCode !== 0) return null;
|
|
100
|
+
let path: string | null = null;
|
|
101
|
+
for (const line of list.stdout.toString().split(/\r?\n/)) {
|
|
102
|
+
if (line.startsWith("worktree ")) path = line.slice("worktree ".length);
|
|
103
|
+
else if (line === `branch refs/heads/${branch}` && path !== null) return path;
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
72
108
|
const LOOPBACK = new Set(["127.0.0.1", "localhost", "::1"]);
|
|
73
109
|
if (!LOOPBACK.has(values.host!)) {
|
|
74
110
|
console.warn(
|
|
@@ -88,7 +124,7 @@ const store = openEventStore(dbPath);
|
|
|
88
124
|
const pool = await createCheckPool({ repoDir, size: concurrency, keep: cfg.checkKeep });
|
|
89
125
|
|
|
90
126
|
const app = createApp({
|
|
91
|
-
cfg, store, repoDir, pool, commitAccepted, branchHead, changedPaths,
|
|
127
|
+
cfg, store, repoDir, pool, commitAccepted, branchHead, changedPaths, initialHead: head,
|
|
92
128
|
joinLimitPerHour: Math.max(0, Number(values["join-limit"]) || 0),
|
|
93
129
|
});
|
|
94
130
|
|
|
@@ -119,6 +155,7 @@ const server = Bun.serve({
|
|
|
119
155
|
if (req.method === "GET" && (url.pathname === "/join" || url.pathname === "/llms.txt")) {
|
|
120
156
|
return new Response(renderJoinDoc(app.projectInfo(), origin), { headers: { "content-type": "text/plain; charset=utf-8" } });
|
|
121
157
|
}
|
|
158
|
+
if (isGitRequest(url.pathname)) return serveGit(req, repoDir);
|
|
122
159
|
if (req.method === "GET" && url.pathname === "/kit/minga.mjs") {
|
|
123
160
|
return kit ? new Response(kit, { headers: { "content-type": "text/javascript; charset=utf-8" } }) : new Response("kit unavailable", { status: 503 });
|
|
124
161
|
}
|
package/src/ui/dev-server.ts
CHANGED
|
@@ -160,20 +160,35 @@ const MESSAGES = [
|
|
|
160
160
|
"checked small cases", "rewrite with decidable equality",
|
|
161
161
|
];
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
"
|
|
166
|
-
"Resolution
|
|
163
|
+
// Each area owns a distinct pool of sub-areas, so no two branches share a label.
|
|
164
|
+
const AREAS = [
|
|
165
|
+
{ name: "Circuit lower bounds", subs: ["Switching lemmas", "Monotone circuits", "Depth hierarchy", "Gate elimination"] },
|
|
166
|
+
{ name: "Proof complexity", subs: ["Resolution width", "Cutting planes", "Nullstellensatz", "Proof size separations"] },
|
|
167
|
+
{ name: "Barriers", subs: ["Relativization", "Natural proofs", "Algebrization", "Entropy obstructions"] },
|
|
168
|
+
{ name: "Algebraic methods", subs: ["Polynomial method", "Approximating polynomials", "Rank arguments", "Combinatorial Nullstellensatz"] },
|
|
169
|
+
{ name: "Communication complexity", subs: ["Discrepancy bounds", "Information complexity", "Protocol compression", "Lower bound templates"] },
|
|
170
|
+
{ name: "Derandomization", subs: ["Pseudorandom generators", "Hardness versus randomness", "Extractor constructions", "Hitting sets"] },
|
|
167
171
|
] as const;
|
|
168
172
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
173
|
+
// Templates take a parameter, so every generated leaf title is unique without a "(variant N)" suffix.
|
|
174
|
+
const LEAF_TEMPLATES: ReadonlyArray<(n: number) => string> = [
|
|
175
|
+
n => `Formalize Håstad's switching lemma for depth-${3 + ((n - 1) % 3)} width ${n + 2}`,
|
|
176
|
+
n => `Bound Razborov approximators for CLIQUE_${n + 2}`,
|
|
177
|
+
n => `Prove the sunflower lemma for ${n + 3}-uniform families`,
|
|
178
|
+
n => `Separate monotone circuits for CLIQUE_${n + 2}`,
|
|
179
|
+
n => `Establish a resolution width lower bound of ${n + 4}`,
|
|
180
|
+
n => `Derive shrinkage exponent ${(n % 5) + 1} for depth-3 formulas`,
|
|
181
|
+
n => `Reduce SAT to 3-SAT on ${n + 6} variables`,
|
|
182
|
+
n => `Construct oracle B separating P^B from NP^B at length ${n + 4}`,
|
|
183
|
+
n => `Verify natural-proofs barrier instance ${n + 1} in Lean`,
|
|
184
|
+
n => `Bound Andreev's function on ${n + 7} inputs`,
|
|
185
|
+
n => `Prove backdoor set detection for width ${n + 2}`,
|
|
186
|
+
n => `Refine the Karchmer–Wigderson game for depth ${n + 3}`,
|
|
187
|
+
];
|
|
188
|
+
const leafTitle = (index: number): string => {
|
|
189
|
+
const t = LEAF_TEMPLATES[index % LEAF_TEMPLATES.length]!;
|
|
190
|
+
return t(Math.floor(index / LEAF_TEMPLATES.length) + 1);
|
|
191
|
+
};
|
|
177
192
|
|
|
178
193
|
// ---------------------------------------------------------------- seeding
|
|
179
194
|
|
|
@@ -305,23 +320,26 @@ function seed(): void {
|
|
|
305
320
|
}
|
|
306
321
|
|
|
307
322
|
const total = Math.max(4, FLAGS.tasks);
|
|
308
|
-
|
|
309
|
-
const
|
|
323
|
+
// Three to six named top-level areas, each with one shallow layer of named sub-areas.
|
|
324
|
+
const areaCount = Math.max(3, Math.min(6, Math.round(Math.sqrt(total) / 4)));
|
|
325
|
+
const subPerArea = Math.max(2, Math.min(4, Math.round(total / (areaCount * 40))));
|
|
326
|
+
const subCount = Math.min(areaCount * subPerArea, Math.max(0, total - areaCount - 1));
|
|
310
327
|
const areas: TaskState[] = [];
|
|
311
328
|
for (let i = 0; i < areaCount; i += 1) {
|
|
312
|
-
const a = addTask(
|
|
329
|
+
const a = addTask(AREAS[i]?.name ?? "Area " + (i + 1), "Branch point. Leaves below carry the work.", null, "open", 0, int(120, 400));
|
|
313
330
|
areas.push(a);
|
|
314
331
|
}
|
|
315
332
|
const subs: TaskState[] = [];
|
|
316
333
|
for (let i = 0; i < subCount; i += 1) {
|
|
317
|
-
const
|
|
318
|
-
|
|
334
|
+
const slot = i % areas.length;
|
|
335
|
+
const area = areas[slot]!;
|
|
336
|
+
const name = AREAS[slot]?.subs[Math.floor(i / areas.length)] ?? "Subarea";
|
|
337
|
+
subs.push(addTask(name, "Grouping of related leaves.", area.id, "open", 0, int(90, 320)));
|
|
319
338
|
}
|
|
320
339
|
const leaves = total - areaCount - subCount;
|
|
321
340
|
for (let i = 0; i < leaves; i += 1) {
|
|
322
|
-
const parent = subs[i % subs.length]!;
|
|
323
|
-
const
|
|
324
|
-
const title = i < LEAF_TITLES.length ? base : base + " (variant " + (1 + Math.floor(i / LEAF_TITLES.length)) + ")";
|
|
341
|
+
const parent = subs.length ? subs[i % subs.length]! : areas[i % areas.length]!;
|
|
342
|
+
const title = leafTitle(i);
|
|
325
343
|
const roll = rnd();
|
|
326
344
|
const status: TaskStatus = roll < 0.06 ? "solved" : roll < 0.1 ? "refuted" : roll < 0.13 ? "impossible" : roll < 0.16 ? "withdrawn" : "open";
|
|
327
345
|
const t = addTask(title, "Prove or refute the statement with machine-checked steps in Proofs/**.", parent.id, status, int(10, 80), int(10, 300));
|
|
@@ -786,7 +804,7 @@ function actionJoin(): boolean {
|
|
|
786
804
|
|
|
787
805
|
function actionPost(): boolean {
|
|
788
806
|
const parent = pick(Object.values(db.tasks));
|
|
789
|
-
const title = "
|
|
807
|
+
const title = "New task: " + leafTitle(int(0, 500));
|
|
790
808
|
const t = addTask(title, "Posted from the dev fixture.", parent ? parent.id : null, "open", rules.defaultPoints, 0);
|
|
791
809
|
emit("task.posted", HEAD, { task: t.id, title: t.title, body: t.body, parent: t.parent, points: t.points, by: "head" });
|
|
792
810
|
return true;
|