architecture-harness 0.25.1 → 0.26.0
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/package.json +2 -18
- package/src/cli/ask.mjs +42 -0
- package/src/cli/ask.test.mjs +40 -0
- package/src/cli/check-commands.mjs +104 -7
- package/src/cli/check-commands.test.mjs +281 -7
- package/src/cli/check-full.test.mjs +152 -0
- package/src/cli/check.mjs +113 -0
- package/src/cli/check.test.mjs +45 -0
- package/src/cli/child-run.mjs +7 -2
- package/src/cli/child-run.test.mjs +17 -2
- package/src/cli/ci-failures.mjs +47 -9
- package/src/cli/ci-failures.test.mjs +116 -10
- package/src/cli/ci-preview.mjs +62 -0
- package/src/cli/ci-preview.test.mjs +85 -0
- package/src/cli/ci-state.mjs +2 -2
- package/src/cli/ci-state.test.mjs +8 -8
- package/src/cli/ci-template.test.mjs +79 -1
- package/src/cli/codex-implement.mjs +373 -44
- package/src/cli/codex-implement.test.mjs +775 -14
- package/src/cli/codex-limit.test.mjs +1 -1
- package/src/cli/codex-verify.mjs +230 -0
- package/src/cli/codex-verify.test.mjs +402 -0
- package/src/cli/comment-watch.mjs +391 -0
- package/src/cli/comment-watch.test.mjs +392 -0
- package/src/cli/commit-guard.mjs +3 -3
- package/src/cli/commit-guard.test.mjs +9 -3
- package/src/cli/diff-shape.mjs +162 -0
- package/src/cli/diff-shape.test.mjs +200 -0
- package/src/cli/dispatch-guard.test.mjs +7 -7
- package/src/cli/dispatch-reminder.mjs +18 -8
- package/src/cli/dispatch-reminder.test.mjs +46 -10
- package/src/cli/dispatch-slot.mjs +2 -2
- package/src/cli/dispatch-slot.test.mjs +18 -19
- package/src/cli/dispatch.test.mjs +3 -3
- package/src/cli/fleet.mjs +180 -0
- package/src/cli/fleet.test.mjs +213 -0
- package/src/cli/gate-slot.mjs +2 -1
- package/src/cli/gh-merge-command.mjs +5 -3
- package/src/cli/gh-merge-command.test.mjs +4 -0
- package/src/cli/gh-run.mjs +50 -7
- package/src/cli/gh-run.test.mjs +35 -5
- package/src/cli/git-read.mjs +2 -1
- package/src/cli/integrate-tree.mjs +47 -0
- package/src/cli/integrate.mjs +35 -26
- package/src/cli/integration-lane.mjs +3 -5
- package/src/cli/integration-lane.test.mjs +2 -2
- package/src/cli/ledger.test.mjs +12 -3
- package/src/cli/legs.mjs +53 -0
- package/src/cli/legs.test.mjs +70 -0
- package/src/cli/locked-tests.mjs +134 -0
- package/src/cli/locked-tests.test.mjs +188 -0
- package/src/cli/merge-guard.mjs +96 -43
- package/src/cli/merge-guard.test.mjs +272 -111
- package/src/cli/metrics.mjs +53 -0
- package/src/cli/metrics.test.mjs +73 -0
- package/src/cli/milestone.mjs +297 -0
- package/src/cli/milestone.test.mjs +294 -0
- package/src/cli/mutate.mjs +203 -0
- package/src/cli/mutate.test.mjs +134 -0
- package/src/cli/overview.mjs +131 -0
- package/src/cli/overview.test.mjs +137 -0
- package/src/cli/platform-risk.mjs +46 -0
- package/src/cli/platform-risk.test.mjs +38 -0
- package/src/cli/pr-guard.mjs +128 -0
- package/src/cli/pr-guard.test.mjs +154 -0
- package/src/cli/qc.mjs +76 -20
- package/src/cli/qc.test.mjs +35 -1
- package/src/cli/retry-failed.mjs +3 -1
- package/src/cli/run-log.mjs +73 -0
- package/src/cli/run-log.test.mjs +121 -0
- package/src/cli/skill-length.test.mjs +8 -0
- package/src/cli/tools.mjs +49 -0
- package/src/cli/tools.test.mjs +89 -0
- package/src/cli/watch.mjs +21 -8
- package/src/cli/watch.test.mjs +45 -21
- package/src/cli/work-order-guard.mjs +2 -1
- package/src/cli/workflow-hooks.test.mjs +1 -1
- package/src/cli/workflow-settings.mjs +3 -2
- package/src/cli/workflow-settings.test.mjs +11 -1
- package/src/config.mjs +64 -2
- package/src/config.test.mjs +93 -20
- package/src/consumer-package.test.mjs +3 -18
- package/src/descriptions.mjs +1 -0
- package/src/eslint/index.mjs +2 -0
- package/src/eslint/preset.mjs +12 -1
- package/src/eslint/preset.test.mjs +1 -1
- package/src/eslint/rules/timeless-comment.mjs +92 -0
- package/src/eslint/rules.test.mjs +34 -0
- package/src/gates/plain-language.mjs +396 -0
- package/src/gates/plain-language.test.mjs +210 -0
- package/src/global-skills.test.mjs +0 -1
- package/templates/docs/enforcement.md +12 -2
- package/templates/github/workflows/ci.yml +51 -4
- package/src/cli/screens-discovery.mjs +0 -60
- package/src/cli/screens.mjs +0 -85
- package/src/cli/stack.mjs +0 -14
- package/src/cli/throwaway-db.mjs +0 -133
- package/src/cli/throwaway-db.test.mjs +0 -137
- package/src/screens/auth-context.test.mjs +0 -41
- package/src/screens/auth-run.test.mjs +0 -147
- package/src/screens/auth.mjs +0 -223
- package/src/screens/auth.test.mjs +0 -76
- package/src/screens/capture-idle.test.mjs +0 -27
- package/src/screens/capture.browser-test.mjs +0 -73
- package/src/screens/capture.mjs +0 -176
- package/src/screens/capture.test.mjs +0 -28
- package/src/screens/catalog.browser-test.mjs +0 -32
- package/src/screens/catalog.mjs +0 -72
- package/src/screens/catalog.test.mjs +0 -36
- package/src/screens/chrome.mjs +0 -21
- package/src/screens/compare.mjs +0 -41
- package/src/screens/compare.test.mjs +0 -30
- package/src/screens/discovery.browser-test.mjs +0 -29
- package/src/screens/discovery.mjs +0 -158
- package/src/screens/discovery.test.mjs +0 -27
- package/src/screens/inventory.mjs +0 -69
- package/src/screens/inventory.test.mjs +0 -10
- package/src/screens/map.mjs +0 -63
- package/src/screens/map.test.mjs +0 -35
- package/src/screens/open.browser-test.mjs +0 -50
- package/src/screens/regions.mjs +0 -138
- package/src/screens/regions.test.mjs +0 -38
- package/src/screens/session-files.mjs +0 -39
- package/src/screens/session-files.test.mjs +0 -39
- package/src/screens/setup.browser-test.mjs +0 -49
- package/src/screens/setup.mjs +0 -79
- package/src/screens/stack-auth.browser-test.mjs +0 -30
- package/src/screens/stack-auth.mjs +0 -107
- package/src/screens/stack-auth.test.mjs +0 -65
- package/src/screens/write-guard.mjs +0 -26
- package/src/stack/stack.mjs +0 -131
- package/src/stack/stack.test.mjs +0 -60
- package/src/stack/supervisor.mjs +0 -30
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { test } from "node:test";
|
|
7
|
+
import { checkDiffShape } from "./diff-shape.mjs";
|
|
8
|
+
|
|
9
|
+
function fixture(t) {
|
|
10
|
+
const worktree = mkdtempSync(path.join(os.tmpdir(), "qc-diff-shape-"));
|
|
11
|
+
t.after(() => rmSync(worktree, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 }));
|
|
12
|
+
const git = (...args) => execFileSync("git", ["-c", "user.name=Shape Test", "-c", "user.email=shape@example.test", ...args], { cwd: worktree, encoding: "utf8" }).trim();
|
|
13
|
+
git("init", "-q");
|
|
14
|
+
const write = (name, text) => { mkdirSync(path.dirname(path.join(worktree, name)), { recursive: true }); writeFileSync(path.join(worktree, name), text); };
|
|
15
|
+
const commit = () => { git("add", "."); git("commit", "-qm", "fixture"); return git("rev-parse", "HEAD"); };
|
|
16
|
+
return { worktree, git, write, commit, check: (base, paths, extra = {}) => checkDiffShape({ worktree, base, paths, design: "", maxDiffLines: 400, ...extra }).problems };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
test("diff shape: file outside Paths → one problem naming the file", (t) => {
|
|
20
|
+
const f = fixture(t); f.write("owned/a.mjs", "before\n"); const base = f.commit();
|
|
21
|
+
f.write("outside.mjs", "after\n");
|
|
22
|
+
const problems = f.check(base, ["owned/**"]);
|
|
23
|
+
assert.equal(problems.length, 1); assert.match(problems[0], /outside\.mjs/);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('diff shape: 401 changed lines → one problem with "split the issue"', (t) => {
|
|
27
|
+
const f = fixture(t); f.write("a.mjs", "before\n"); const base = f.commit();
|
|
28
|
+
f.write("a.mjs", "after\n".repeat(400));
|
|
29
|
+
const problems = f.check(base, ["a.mjs"]);
|
|
30
|
+
assert.equal(problems.length, 1); assert.match(problems[0], /split the issue/);
|
|
31
|
+
{
|
|
32
|
+
const f = fixture(t); f.write("a.mjs", "new\n".repeat(400));
|
|
33
|
+
assert.deepEqual(f.check(null, ["a.mjs"]), []);
|
|
34
|
+
assert.match(f.check(null, ["a.mjs"], { maxDiffLines: 399 })[0], /split the issue/);
|
|
35
|
+
}
|
|
36
|
+
{
|
|
37
|
+
const f = fixture(t); f.write("a.mjs", "old\n".repeat(400)); const base = f.commit();
|
|
38
|
+
f.git("rm", "a.mjs"); f.write("a.mjs", "new\n");
|
|
39
|
+
const problems = f.check(base, ["a.mjs"]);
|
|
40
|
+
assert.equal(problems.length, 1); assert.match(problems[0], /401.*split the issue/);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
function baseMergeFixture(t) {
|
|
45
|
+
const f = fixture(t);
|
|
46
|
+
f.write("package.json", "{}\n"); f.write("owned/a.mjs", "before\n"); const initial = f.commit();
|
|
47
|
+
f.git("checkout", "-qb", "run");
|
|
48
|
+
f.write("existing.mjs", "already on the run branch\n"); const base = f.commit();
|
|
49
|
+
f.git("checkout", "-qb", "incoming", initial);
|
|
50
|
+
f.write("base.mjs", "from base\n".repeat(500)); f.commit();
|
|
51
|
+
f.write("package.json", '{"devDependencies":{"base-tool":"1"}}\n'); f.commit();
|
|
52
|
+
f.git("checkout", "-q", "run");
|
|
53
|
+
return { ...f, base, baseRef: "incoming" };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
test("base merge adds 500 lines and a devDependency; three own lines stay within the shape", (t) => {
|
|
57
|
+
for (const state of ["committed", "staged", "working"]) {
|
|
58
|
+
const f = baseMergeFixture(t);
|
|
59
|
+
f.write("owned/before.mjs", "own before merge\n"); f.commit();
|
|
60
|
+
f.git("merge", "--no-edit", "incoming");
|
|
61
|
+
f.write("package.json", '{"name":"own-change","devDependencies":{"base-tool":"1"}}\n');
|
|
62
|
+
if (state === "committed") f.commit();
|
|
63
|
+
else {
|
|
64
|
+
f.git("add", ".");
|
|
65
|
+
if (state === "working") f.git("reset", "--quiet");
|
|
66
|
+
}
|
|
67
|
+
const paths = ["owned/**", "package.json"];
|
|
68
|
+
assert.deepEqual(f.check(f.base, paths, { baseRef: f.baseRef }), [], state);
|
|
69
|
+
assert.ok(f.check(f.base, paths).some((problem) => /split the issue/.test(problem)));
|
|
70
|
+
assert.deepEqual(f.check(f.base, paths, { baseRef: "missing-ref" }), f.check(f.base, paths));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("conflicted manifest keeps dependencies from both the frozen base and incoming base", (t) => {
|
|
75
|
+
const f = fixture(t);
|
|
76
|
+
f.write("package.json", "{}\n"); const initial = f.commit();
|
|
77
|
+
f.git("checkout", "-qb", "run");
|
|
78
|
+
f.write("package.json", '{"devDependencies":{"existing-tool":"1"}}\n'); const base = f.commit();
|
|
79
|
+
f.git("checkout", "-qb", "incoming", initial);
|
|
80
|
+
f.write("package.json", '{"devDependencies":{"base-tool":"1"}}\n'); f.commit();
|
|
81
|
+
f.git("checkout", "-q", "run");
|
|
82
|
+
assert.throws(() => f.git("merge", "--no-edit", "incoming"));
|
|
83
|
+
f.write("package.json", '{"devDependencies":{"existing-tool":"1","base-tool":"1"}}\n'); f.commit();
|
|
84
|
+
assert.deepEqual(f.check(base, ["package.json"], { baseRef: "incoming" }), []);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("two base merges use separate boundaries and count only two owned lines", (t) => {
|
|
88
|
+
for (const state of ["committed", "staged", "working"]) {
|
|
89
|
+
const f = baseMergeFixture(t);
|
|
90
|
+
f.git("merge", "--no-edit", "incoming");
|
|
91
|
+
f.git("checkout", "-q", "incoming");
|
|
92
|
+
f.write("next-base.mjs", "more from base\n".repeat(500)); f.commit();
|
|
93
|
+
f.git("checkout", "-q", "run");
|
|
94
|
+
f.git("merge", "--no-edit", "incoming");
|
|
95
|
+
f.write("owned/after.mjs", "own first line\nown second line\n");
|
|
96
|
+
if (state === "committed") f.commit();
|
|
97
|
+
else if (state === "staged") f.git("add", ".");
|
|
98
|
+
assert.deepEqual(f.check(f.base, ["owned/**"], { baseRef: f.baseRef, maxDiffLines: 2 }), [], state);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
function removedBaseDependencyFixture(t, ownDependencies = {}) {
|
|
103
|
+
const f = baseMergeFixture(t);
|
|
104
|
+
f.git("merge", "--no-edit", "incoming");
|
|
105
|
+
f.write("package.json", JSON.stringify({ name: "own-change", devDependencies: { "base-tool": "1", ...ownDependencies } }));
|
|
106
|
+
f.commit();
|
|
107
|
+
f.git("checkout", "-q", "incoming");
|
|
108
|
+
f.write("package.json", "{}\n"); f.commit();
|
|
109
|
+
f.git("checkout", "-q", "run");
|
|
110
|
+
assert.throws(() => f.git("merge", "--no-edit", "incoming"));
|
|
111
|
+
f.write("package.json", JSON.stringify({ name: "own-change", devDependencies: ownDependencies }));
|
|
112
|
+
f.commit();
|
|
113
|
+
return f;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
test("upstream devDependency added and removed across two merges uses each manifest's baseline", (t) => {
|
|
117
|
+
const f = removedBaseDependencyFixture(t);
|
|
118
|
+
assert.deepEqual(f.check(f.base, ["package.json"], { baseRef: f.baseRef }), []);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("upstream devDependency removed after two merges still rejects an own devDependency", (t) => {
|
|
122
|
+
const f = removedBaseDependencyFixture(t, { "own-tool": "1" });
|
|
123
|
+
assert.deepEqual(f.check(f.base, ["package.json"], { baseRef: f.baseRef }), [
|
|
124
|
+
"package.json: added devDependencies own-tool is absent from Design",
|
|
125
|
+
]);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("base merge still refuses 401 own lines in Paths", (t) => {
|
|
129
|
+
for (const state of ["committed", "staged", "working"]) {
|
|
130
|
+
const f = baseMergeFixture(t);
|
|
131
|
+
f.git("merge", "--no-edit", "incoming");
|
|
132
|
+
f.write("owned/after.mjs", "own line\n".repeat(401));
|
|
133
|
+
if (state === "committed") f.commit();
|
|
134
|
+
else {
|
|
135
|
+
f.git("add", ".");
|
|
136
|
+
if (state === "working") f.git("reset", "--quiet");
|
|
137
|
+
}
|
|
138
|
+
assert.deepEqual(f.check(f.base, ["owned/**"], { baseRef: f.baseRef }), [
|
|
139
|
+
"401 changed lines exceeds codex.maxDiffLines 400; split the issue",
|
|
140
|
+
], state);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test("diff shape: Windows backslash path inside Paths → no problem", (t) => {
|
|
145
|
+
const f = fixture(t); f.write("src/a.mjs", "before\n"); const base = f.commit(); f.write("src/a.mjs", "after\n");
|
|
146
|
+
assert.deepEqual(f.check(base, ["src\\a.mjs"]), []);
|
|
147
|
+
f.git("checkout", "--", "src/a.mjs");
|
|
148
|
+
for (const name of ["src/fixtures/unit/a.mjs", "src/nested/fixtures/a.mjs", "src/fixtures/a.mjs", "src/nested/fixtures/unit/a.mjs"]) {
|
|
149
|
+
f.write(name, "new\n");
|
|
150
|
+
}
|
|
151
|
+
assert.deepEqual(f.check(base, ["src/**/fixtures/**/*.mjs"]), []);
|
|
152
|
+
{
|
|
153
|
+
const f = fixture(t); f.write("src/nested/test.mjs", "ok\n");
|
|
154
|
+
assert.deepEqual(f.check(null, ["src/"]), []);
|
|
155
|
+
assert.deepEqual(f.check(null, ["src/**/*.mjs"]), []);
|
|
156
|
+
assert.equal(f.check(null, ["sr"]).length, 1);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test("scope covers committed, index, tracked and untracked files including an unborn HEAD", (t) => {
|
|
161
|
+
const f = fixture(t); f.write("new.mjs", "new\n");
|
|
162
|
+
assert.deepEqual(f.check(null, ["new.mjs"]), []);
|
|
163
|
+
assert.equal(f.check(null, ["other.mjs"]).length, 1);
|
|
164
|
+
const base = f.commit(); f.write("committed.mjs", "commit\n"); f.commit();
|
|
165
|
+
f.write("staged.mjs", "stage\n"); f.git("add", "."); f.write("new.mjs", "edit\n"); f.write("untracked.mjs", "new\n");
|
|
166
|
+
const problems = f.check(base, ["none/**"]);
|
|
167
|
+
for (const name of ["committed", "staged", "new", "untracked"]) assert.ok(problems.some((p) => p.includes(`${name}.mjs`)));
|
|
168
|
+
{
|
|
169
|
+
const oldPath = process.platform === "win32" ? "outside space/old quote.mjs" : 'outside space/old "quote".mjs';
|
|
170
|
+
const f = fixture(t); f.write(oldPath, "same\n"); const base = f.commit();
|
|
171
|
+
mkdirSync(path.join(f.worktree, "owned")); f.git("mv", oldPath, "owned/new.mjs");
|
|
172
|
+
assert.ok(f.check(base, ["owned/**"]).some((p) => p.includes(oldPath)));
|
|
173
|
+
f.git("rm", "-f", "owned/new.mjs");
|
|
174
|
+
assert.ok(f.check(base, ["owned/**"]).some((p) => p.includes(oldPath)));
|
|
175
|
+
}
|
|
176
|
+
{
|
|
177
|
+
const f = fixture(t); f.write("owned.mjs", "ok\n"); const base = f.commit();
|
|
178
|
+
f.write("outside.mjs", "new\n"); f.commit(); f.git("rm", "outside.mjs"); f.commit();
|
|
179
|
+
assert.ok(f.check(base, ["owned.mjs"]).some((p) => p.includes("outside.mjs")));
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test("dependency additions require exact Design names, including aliases and devDependencies", (t) => {
|
|
184
|
+
const prose = fixture(t); prose.write("package.json", "{}\n"); const proseBase = prose.commit();
|
|
185
|
+
prose.write("package.json", JSON.stringify({ dependencies: { "new-library": "1" } }));
|
|
186
|
+
assert.deepEqual(prose.check(proseBase, ["package.json"], { design: "Add new-library." }), []);
|
|
187
|
+
const f = fixture(t);
|
|
188
|
+
f.write("package.json", JSON.stringify({ dependencies: { existing: "1" } })); const base = f.commit();
|
|
189
|
+
f.write("package.json", JSON.stringify({ dependencies: { existing: "2", added: "npm:actual@1" }, devDependencies: { tool: "1" } }));
|
|
190
|
+
assert.equal(f.check(base, ["package.json"]).length, 2);
|
|
191
|
+
assert.equal(f.check(base, ["package.json"], { design: "Use added-extra and toolbox" }).length, 2);
|
|
192
|
+
assert.deepEqual(f.check(base, ["package.json"], { design: "Dependencies: `added` (npm:actual@1), tool" }), []);
|
|
193
|
+
{
|
|
194
|
+
const f = fixture(t); f.write("package.json", "{}\n"); const base = f.commit();
|
|
195
|
+
f.write("package.json", '{"devDependencies":{"tool":"1"}}'); f.git("add", "."); f.write("package.json", "{}\n");
|
|
196
|
+
assert.ok(f.check(base, ["package.json"]).some((p) => p.includes("tool")));
|
|
197
|
+
f.write("package.json", "{bad");
|
|
198
|
+
assert.ok(f.check(base, ["package.json"]).some((p) => /JSON|manifest/i.test(p)));
|
|
199
|
+
}
|
|
200
|
+
});
|
|
@@ -165,7 +165,7 @@ test("a prompt over the limit is refused, and the refusal claims no slot", (t) =
|
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
test("a second implementer is refused until the first one stops, and the refusal names the slot file", (t) => {
|
|
168
|
-
const ws = workspace(t);
|
|
168
|
+
const ws = workspace(t, { implementerSlots: 1 });
|
|
169
169
|
assert.equal(decide(agentCall(ws.on, implementer), ws.tmp), null);
|
|
170
170
|
const second = reasonOf(decide(agentCall(ws.on, { ...implementer, subagent_type: "sdd-implementer" }), ws.tmp)) ?? "";
|
|
171
171
|
assert.match(second, /holds the one implementer slot/);
|
|
@@ -223,7 +223,7 @@ test("a repository's models override replaces one type's families and leaves the
|
|
|
223
223
|
});
|
|
224
224
|
|
|
225
225
|
test("a slot with no stop expires after slotMinutes", (t) => {
|
|
226
|
-
const ws = workspace(t);
|
|
226
|
+
const ws = workspace(t, { implementerSlots: 1 });
|
|
227
227
|
decide(agentCall(ws.on, implementer), ws.tmp);
|
|
228
228
|
assert.notEqual(reasonOf(decide(agentCall(ws.on, implementer), ws.tmp)), null);
|
|
229
229
|
const future = new Date(Date.now() + 61 * 60_000);
|
|
@@ -299,7 +299,7 @@ test("agents in one assistant message share the first dispatch age check", (t) =
|
|
|
299
299
|
});
|
|
300
300
|
|
|
301
301
|
test("a resumed implementer holds the slot again", (t) => {
|
|
302
|
-
const ws = workspace(t);
|
|
302
|
+
const ws = workspace(t, { implementerSlots: 1 });
|
|
303
303
|
decide(agentCall(ws.on, implementer), ws.tmp);
|
|
304
304
|
decide(subagentEvent(ws.on, "architecture:sdd-implementer"), ws.tmp);
|
|
305
305
|
decide(subagentEvent(ws.on, "architecture:sdd-implementer", "SubagentStart"), ws.tmp);
|
|
@@ -354,8 +354,8 @@ const agentEvent = (cwd, agentId, hook_event_name) => ({
|
|
|
354
354
|
agent_id: agentId,
|
|
355
355
|
});
|
|
356
356
|
|
|
357
|
-
test("
|
|
358
|
-
const ws = workspace(t
|
|
357
|
+
test("the default limit lets three implementers run, refuses the fourth with the holders and the limit, and a stop frees one", (t) => {
|
|
358
|
+
const ws = workspace(t);
|
|
359
359
|
for (const id of ["a", "b", "c"]) {
|
|
360
360
|
assert.equal(decide(slotCall(ws.on, `use-${id}`), ws.tmp), null);
|
|
361
361
|
decide(agentEvent(ws.on, `agent-${id}`, "SubagentStart"), ws.tmp);
|
|
@@ -394,7 +394,7 @@ const taskStop = (cwd, taskId) => ({
|
|
|
394
394
|
});
|
|
395
395
|
|
|
396
396
|
test("a TaskStop frees the slot of the agent it stopped, and a TaskStop of another task frees nothing", (t) => {
|
|
397
|
-
const ws = workspace(t);
|
|
397
|
+
const ws = workspace(t, { implementerSlots: 1 });
|
|
398
398
|
assert.equal(decide(slotCall(ws.on, "use-a"), ws.tmp), null);
|
|
399
399
|
decide(agentEvent(ws.on, "agent-a", "SubagentStart"), ws.tmp);
|
|
400
400
|
assert.equal(decide(taskStop(ws.on, "shell-9"), ws.tmp), null);
|
|
@@ -404,7 +404,7 @@ test("a TaskStop frees the slot of the agent it stopped, and a TaskStop of anoth
|
|
|
404
404
|
});
|
|
405
405
|
|
|
406
406
|
test("a session startup or resume frees every slot of the session, and a compaction frees none", (t) => {
|
|
407
|
-
const ws = workspace(t);
|
|
407
|
+
const ws = workspace(t, { implementerSlots: 1 });
|
|
408
408
|
assert.equal(decide(slotCall(ws.on, "use-a"), ws.tmp), null);
|
|
409
409
|
const start = (source) => ({ session_id: "session-aaaa", cwd: ws.on, hook_event_name: "SessionStart", source });
|
|
410
410
|
assert.equal(decide(start("compact"), ws.tmp), null);
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
// and fork, because a rule held only in the conversation is lost to a compaction.
|
|
4
4
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { dispatchDefaults } from "../config.mjs";
|
|
6
7
|
import { directSettingsAt } from "./direct-lane.mjs";
|
|
7
8
|
import { dispatchSettingsAt, exploreSettingsAt, exploreToolLines } from "./dispatch.mjs";
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
const reminder = (implementerSlots) =>
|
|
10
11
|
"Subagent workflow (swarm.dispatch in qc.config.json): run a plan with superpowers:subagent-driven-development. " +
|
|
11
12
|
"Dispatch architecture:sdd-planner to write a plan, architecture:sdd-implementer for one task, and " +
|
|
12
13
|
"architecture:sdd-reviewer to review it; before merge, dispatch architecture:sdd-branch-reviewer to review the " +
|
|
13
14
|
"whole branch. " +
|
|
14
|
-
|
|
15
|
+
slotsRule(implementerSlots) + " Name a model on any other dispatch, and " +
|
|
15
16
|
"write each brief to a file and name its path on a prompt line `Brief: <path>`; a dispatch with no such line, or a missing file, is refused. " +
|
|
16
17
|
"Name the worktree on a prompt line `Worktree: <path>`; a reviewer whose worktree, branch, or head the gate cannot read is refused. A reviewer starts with " +
|
|
17
18
|
"`VERDICT: <APPROVED|CHANGES_REQUIRED> <sha>`, and a merge passes `--match-head-commit <sha>`. " +
|
|
@@ -19,10 +20,16 @@ export const REMINDER =
|
|
|
19
20
|
"Review a head only once CI on it is green, with the base merged in: fix a CI failure first, and merge `origin/<base>` at Step 0 of a fix round. " +
|
|
20
21
|
"A PR gets one branch review. After it, review each fix round once, by its increment: add `Reviewed: <sha>`, the last head a branch review named.";
|
|
21
22
|
|
|
23
|
+
export const REMINDER = reminder(dispatchDefaults.implementerSlots);
|
|
24
|
+
|
|
22
25
|
/** The reminder names Codex first, its controller skill, and the runtime routing rules. */
|
|
23
26
|
export const CODEX_LINE =
|
|
24
27
|
" Implementer work runs on Codex first through `qc codex-implement --brief <file> --worktree <path> --progress <file>`; " +
|
|
25
28
|
"load the `architecture:codex` skill before the first dispatch. " +
|
|
29
|
+
"Use --role scout for read-only research, --role tests for tests, and --role review (or --review) for review. " +
|
|
30
|
+
"When codex.requireApproval is true, an implement brief needs ## Design and Approved: <scout report>; the orchestrator enables it. " +
|
|
31
|
+
"Every implement/tests run checks Paths, Design dependency names, and codex.maxDiffLines (default 400); split larger issues. " +
|
|
32
|
+
"Forward --resume <session id> only when requested; each run logs its actual session id. " +
|
|
26
33
|
"On exit 2 (a Codex limit), dispatch the same brief to an architecture:sdd-implementer (sonnet). " +
|
|
27
34
|
"Start each Agent description with `Codex <model> · ` for a codex type or `Claude <model> · ` for any other; " +
|
|
28
35
|
"the guard refuses a codex dispatch while `qc codex status` shows a limit and requires `Runtime: claude <reason>` for an implementer dispatch while Codex is free. " +
|
|
@@ -53,11 +60,12 @@ export function modelsLine({ models, runtime }) {
|
|
|
53
60
|
|
|
54
61
|
const context = (eventName, text) => ({ hookSpecificOutput: { hookEventName: eventName, additionalContext: text } });
|
|
55
62
|
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
implementerSlots > 1
|
|
59
|
-
? `
|
|
60
|
-
: "";
|
|
63
|
+
/** State the configured limit directly, retaining the original rule for a single slot. */
|
|
64
|
+
function slotsRule(implementerSlots) {
|
|
65
|
+
return implementerSlots > 1
|
|
66
|
+
? `Run up to ${implementerSlots} implementers at once, each in its own worktree with disjoint paths; each extra implementer needs more than 4 GB of free memory. A hook refuses one over the limit.`
|
|
67
|
+
: "Run one implementer at a time: a hook refuses a second.";
|
|
68
|
+
}
|
|
61
69
|
|
|
62
70
|
/** One added line for the direct lane of `swarm.direct`, or "" when it is off. */
|
|
63
71
|
function directLine(cwd) {
|
|
@@ -117,8 +125,10 @@ function decideSessionStart(call, env) {
|
|
|
117
125
|
}
|
|
118
126
|
const explore = exploreLine(cwd);
|
|
119
127
|
if (!dispatch) return explore === "" ? null : context("SessionStart", explore.trim());
|
|
128
|
+
if (env.QC_ROLE === "scout") return context("SessionStart", `scout worker mode: Work inline. Do not edit, stage, or commit worktree files. Write only the external report and progress; include Gap:, Plan:, Check:, Risks:, Questions:, Breaking: yes|no.${explore}`);
|
|
129
|
+
if (["tests", "review"].includes(env.QC_ROLE)) return context("SessionStart", `${env.QC_ROLE} worker mode: Work inline. Follow the brief's role and exit criteria. Start no helper agents.${explore}`);
|
|
120
130
|
if (env.QC_ROLE === "implementer") return context("SessionStart", `${WORKER_NOTE}${explore}`);
|
|
121
|
-
return context("SessionStart", `${
|
|
131
|
+
return context("SessionStart", `${reminder(dispatch.implementerSlots)}${modelsLine(dispatch)}${CODEX_LINE}${directLine(cwd)}${explore}`);
|
|
122
132
|
}
|
|
123
133
|
|
|
124
134
|
/** @returns the hook output, or null when there is nothing to add for this event. */
|
|
@@ -14,6 +14,7 @@ delete process.env.QC_ROLE;
|
|
|
14
14
|
const BASE = `${REMINDER}${modelsLine({ models: runtimeModels.codex, runtime: "codex" })}${CODEX_LINE}`;
|
|
15
15
|
|
|
16
16
|
test("CODEX_LINE names the runtime tags, Runtime line, and qc codex status", () => {
|
|
17
|
+
for (const phrase of [/--role scout/, /codex.requireApproval/, /Approved:/, /## Design/, /codex.maxDiffLines/, /--resume/]) assert.match(CODEX_LINE, phrase);
|
|
17
18
|
for (const text of ["Codex <model> · ", "Claude <model> · ", "Runtime: claude <reason>", "qc codex status"]) {
|
|
18
19
|
assert.ok(CODEX_LINE.includes(text), text);
|
|
19
20
|
}
|
|
@@ -59,21 +60,23 @@ test("with the section on, every start adds the note, a compaction included", (t
|
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
62
|
|
|
62
|
-
test("the note names the workflow, the four types, and the
|
|
63
|
+
test("the note names the workflow, the four types, and the parallel rule, in a short text", () => {
|
|
63
64
|
for (const word of [
|
|
64
65
|
"superpowers:subagent-driven-development",
|
|
65
66
|
"architecture:sdd-planner",
|
|
66
67
|
"architecture:sdd-implementer",
|
|
67
68
|
"architecture:sdd-reviewer",
|
|
68
69
|
"architecture:sdd-branch-reviewer",
|
|
69
|
-
"
|
|
70
|
+
"up to 3 implementers at once",
|
|
71
|
+
"disjoint paths",
|
|
72
|
+
"more than 4 GB of free memory",
|
|
70
73
|
"Worktree: <path>",
|
|
71
74
|
"VERDICT: <APPROVED|CHANGES_REQUIRED> <sha>",
|
|
72
75
|
"--match-head-commit <sha>",
|
|
73
76
|
]) {
|
|
74
77
|
assert.ok(REMINDER.includes(word), word);
|
|
75
78
|
}
|
|
76
|
-
assert.ok(REMINDER.length <
|
|
79
|
+
assert.ok(REMINDER.length < 1500, `${REMINDER.length} characters`);
|
|
77
80
|
});
|
|
78
81
|
|
|
79
82
|
test("the note says to review a green head only, to fix CI first, and to review a fix round by its increment", () => {
|
|
@@ -169,15 +172,39 @@ test("hooks.json also runs the note on SubagentStart, all matchers, beside the e
|
|
|
169
172
|
);
|
|
170
173
|
});
|
|
171
174
|
|
|
172
|
-
test("
|
|
173
|
-
const [
|
|
174
|
-
{ swarm: {
|
|
175
|
+
test("the default and custom parallel limits state the rule directly; one keeps the original rule", (t) => {
|
|
176
|
+
const [defaults, five, one] = checkouts(t, [
|
|
177
|
+
{ swarm: { direct: false, dispatch: {} } },
|
|
178
|
+
{ swarm: { direct: false, dispatch: { implementerSlots: 5 } } },
|
|
175
179
|
{ swarm: { direct: false, dispatch: { implementerSlots: 1 } } },
|
|
176
180
|
]);
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
for (const [cwd, limit] of [[defaults, 3], [five, 5]]) {
|
|
182
|
+
const text = decide(start(cwd, "startup")).hookSpecificOutput.additionalContext;
|
|
183
|
+
assert.ok(text.includes(`up to ${limit} implementers at once`));
|
|
184
|
+
assert.match(text, /each in its own worktree/);
|
|
185
|
+
assert.match(text, /disjoint paths/);
|
|
186
|
+
assert.match(text, /more than 4 GB of free memory/);
|
|
187
|
+
assert.match(text, /A hook refuses one over the limit/);
|
|
188
|
+
assert.doesNotMatch(text, /one implementer at a time|one-at-a-time/);
|
|
189
|
+
}
|
|
190
|
+
assert.equal(decide(start(defaults, "startup")).hookSpecificOutput.additionalContext, BASE);
|
|
191
|
+
const serial = decide(start(one, "startup")).hookSpecificOutput.additionalContext;
|
|
192
|
+
assert.equal(
|
|
193
|
+
serial,
|
|
194
|
+
"Subagent workflow (swarm.dispatch in qc.config.json): run a plan with superpowers:subagent-driven-development. " +
|
|
195
|
+
"Dispatch architecture:sdd-planner to write a plan, architecture:sdd-implementer for one task, and " +
|
|
196
|
+
"architecture:sdd-reviewer to review it; before merge, dispatch architecture:sdd-branch-reviewer to review the " +
|
|
197
|
+
"whole branch. " +
|
|
198
|
+
"Run one implementer at a time: a hook refuses a second. Name a model on any other dispatch, and " +
|
|
199
|
+
"write each brief to a file and name its path on a prompt line `Brief: <path>`; a dispatch with no such line, or a missing file, is refused. " +
|
|
200
|
+
"Name the worktree on a prompt line `Worktree: <path>`; a reviewer whose worktree, branch, or head the gate cannot read is refused. A reviewer starts with " +
|
|
201
|
+
"`VERDICT: <APPROVED|CHANGES_REQUIRED> <sha>`, and a merge passes `--match-head-commit <sha>`. " +
|
|
202
|
+
"Ask the user the product questions first, in one question, and record the answers under `## Product decisions` in each brief. " +
|
|
203
|
+
"Review a head only once CI on it is green, with the base merged in: fix a CI failure first, and merge `origin/<base>` at Step 0 of a fix round. " +
|
|
204
|
+
"A PR gets one branch review. After it, review each fix round once, by its increment: add `Reviewed: <sha>`, the last head a branch review named." +
|
|
205
|
+
modelsLine({ models: runtimeModels.codex, runtime: "codex" }) + CODEX_LINE,
|
|
206
|
+
);
|
|
207
|
+
assert.doesNotMatch(serial, /implementers at once|one over the limit/);
|
|
181
208
|
});
|
|
182
209
|
|
|
183
210
|
test("SubagentStart gives each tool's use and command, in config order, since a plugin agent carries no MCP tool", (t) => {
|
|
@@ -296,6 +323,15 @@ test("the controller note makes Codex the first choice, names its skill, and fal
|
|
|
296
323
|
});
|
|
297
324
|
|
|
298
325
|
test("QC_ROLE=implementer replaces the controller note with the worker note", (t) => {
|
|
326
|
+
for (const role of ["scout", "tests", "review"]) {
|
|
327
|
+
const [on] = checkouts(t, [{ swarm: { dispatch: {} } }]);
|
|
328
|
+
const text = decide(start(on, "startup"), { QC_ROLE: role }).hookSpecificOutput.additionalContext;
|
|
329
|
+
assert.match(text, /Work inline/);
|
|
330
|
+
assert.ok(text.includes(role));
|
|
331
|
+
assert.doesNotMatch(text, /run a plan with superpowers|make one commit|push once/);
|
|
332
|
+
if (role === "scout") assert.match(text, /Do not edit, stage, or commit/);
|
|
333
|
+
}
|
|
334
|
+
|
|
299
335
|
const [on] = checkouts(t, [{ swarm: { dispatch: {} } }]);
|
|
300
336
|
const text = decide(start(on, "startup"), { QC_ROLE: "implementer" }).hookSpecificOutput.additionalContext;
|
|
301
337
|
assert.equal(text, WORKER_NOTE);
|
|
@@ -24,7 +24,7 @@ const slotFileOf = (dir, index) => path.join(dir, `slot-${index}.claim`);
|
|
|
24
24
|
|
|
25
25
|
function recordedSettings(dir) {
|
|
26
26
|
try {
|
|
27
|
-
const { implementerTypes, slotMinutes, implementerSlots =
|
|
27
|
+
const { implementerTypes, slotMinutes, implementerSlots = 3 } = JSON.parse(
|
|
28
28
|
readFileSync(path.join(dir, SETTINGS_FILE), "utf8"),
|
|
29
29
|
);
|
|
30
30
|
const valid = Array.isArray(implementerTypes) && slotMinutes > 0 && Number.isInteger(implementerSlots) && implementerSlots > 0;
|
|
@@ -132,7 +132,7 @@ function refusalOf(slots, ttlMs, limit) {
|
|
|
132
132
|
*/
|
|
133
133
|
export function claimSlot(dir, settings, now, holderId = randomUUID()) {
|
|
134
134
|
const ttlMs = settings.slotMinutes * MINUTE_MS;
|
|
135
|
-
const limit = settings.implementerSlots ??
|
|
135
|
+
const limit = settings.implementerSlots ?? 3;
|
|
136
136
|
const held = `${PENDING}${holderId}`;
|
|
137
137
|
expireSlots(dir, ttlMs, now);
|
|
138
138
|
if (slotsOf(dir).some((slot) => slot.held === held)) return null;
|
|
@@ -12,7 +12,7 @@ function sessionDir(t, session = "s") {
|
|
|
12
12
|
return slotDirOf(session, tmp);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const settings = { ...dispatchDefaults, slotMinutes: 1 };
|
|
15
|
+
const settings = { ...dispatchDefaults, slotMinutes: 1, implementerSlots: 1 };
|
|
16
16
|
const withSlots = (implementerSlots) => ({ ...settings, implementerSlots });
|
|
17
17
|
const IMPLEMENTER = "sdd-implementer";
|
|
18
18
|
|
|
@@ -91,23 +91,19 @@ test("a claim whose settings cannot be written is released, and the error reache
|
|
|
91
91
|
assert.deepEqual(claimFiles(dir), []);
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
test("the default
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const refused = claimSlot(dir, withSlots(3), Date.now(), "use-4");
|
|
108
|
-
assert.equal(refused.limit, 3);
|
|
109
|
-
assert.deepEqual(refused.holders.map((holder) => holder.id).sort(), ["use-1", "use-2", "use-3"]);
|
|
110
|
-
assert.equal(claimFiles(dir).length, 3);
|
|
94
|
+
test("the default and omitted limits hold three claims and refuse the fourth", (t) => {
|
|
95
|
+
assert.equal(dispatchDefaults.implementerSlots, 3);
|
|
96
|
+
for (const implementerSlots of [dispatchDefaults.implementerSlots, undefined]) {
|
|
97
|
+
const dir = sessionDir(t);
|
|
98
|
+
const defaults = { ...settings, implementerSlots };
|
|
99
|
+
for (const id of ["use-1", "use-2", "use-3"]) assert.equal(claimSlot(dir, defaults, Date.now(), id), null);
|
|
100
|
+
const refused = claimSlot(dir, defaults, Date.now(), "use-4");
|
|
101
|
+
assert.equal(refused.limit, 3);
|
|
102
|
+
assert.deepEqual(refused.holders.map((holder) => holder.id).sort(), ["use-1", "use-2", "use-3"]);
|
|
103
|
+
assert.equal(claimFiles(dir).length, 3);
|
|
104
|
+
const recorded = JSON.parse(readFileSync(path.join(dir, "settings.json"), "utf8"));
|
|
105
|
+
assert.equal(recorded.implementerSlots, 3);
|
|
106
|
+
}
|
|
111
107
|
});
|
|
112
108
|
|
|
113
109
|
test("a stop frees its own holder's claim only, so one slot opens and the others stay", (t) => {
|
|
@@ -216,7 +212,7 @@ test("a repeat of one holder's claim leaves its slot alone and takes no second s
|
|
|
216
212
|
assert.deepEqual(claimFiles(dir), ["slot-0.claim"]);
|
|
217
213
|
});
|
|
218
214
|
|
|
219
|
-
test("the stop and the start read the limit recorded at the claim, and a record with no limit means
|
|
215
|
+
test("the stop and the start read the limit recorded at the claim, and a record with no limit means 3", (t) => {
|
|
220
216
|
const dir = sessionDir(t);
|
|
221
217
|
claimSlot(dir, withSlots(2), Date.now(), "use-1");
|
|
222
218
|
reclaimSlot(dir, IMPLEMENTER, Date.now(), "agent-1");
|
|
@@ -225,5 +221,8 @@ test("the stop and the start read the limit recorded at the claim, and a record
|
|
|
225
221
|
const { implementerTypes, slotMinutes } = settings;
|
|
226
222
|
writeFileSync(path.join(dir, "settings.json"), JSON.stringify({ implementerTypes, slotMinutes }));
|
|
227
223
|
reclaimSlot(dir, IMPLEMENTER, Date.now(), "agent-3");
|
|
224
|
+
reclaimSlot(dir, IMPLEMENTER, Date.now(), "agent-4");
|
|
225
|
+
assert.equal(claimFiles(dir).length, 3);
|
|
226
|
+
assert.equal(releaseSlot(dir, IMPLEMENTER, "agent-3"), true);
|
|
228
227
|
assert.equal(claimFiles(dir).length, 2);
|
|
229
228
|
});
|
|
@@ -170,9 +170,9 @@ test("the slot refusal names the expiry and the file that frees the slot", () =>
|
|
|
170
170
|
assert.match(reason, /delete \/tmp\/slot\.claim/);
|
|
171
171
|
});
|
|
172
172
|
|
|
173
|
-
test("implementerSlots defaults to
|
|
174
|
-
assert.equal(dispatchSettings({ dispatch: {} }).implementerSlots,
|
|
175
|
-
assert.equal(dispatchSettings({ dispatch: { implementerSlots:
|
|
173
|
+
test("implementerSlots defaults to 3, and a repository sets a whole number", () => {
|
|
174
|
+
assert.equal(dispatchSettings({ dispatch: {} }).implementerSlots, 3);
|
|
175
|
+
assert.equal(dispatchSettings({ dispatch: { implementerSlots: 1 } }).implementerSlots, 1);
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
test("a refusal over a limit above 1 names the limit and each holder, and one at 1 keeps its text", () => {
|