architecture-harness 0.19.0 → 0.20.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 +1 -1
- package/src/cli/controller-guard.mjs +16 -9
- package/src/cli/controller-guard.test.mjs +44 -0
- package/src/cli/direct-lane.mjs +209 -0
- package/src/cli/direct-lane.test.mjs +196 -0
- package/src/cli/dispatch-guard.test.mjs +6 -23
- package/src/cli/dispatch-reminder.mjs +19 -4
- package/src/cli/dispatch-reminder.test.mjs +36 -15
- package/src/cli/dispatch.mjs +4 -3
- package/src/cli/dispatch.test.mjs +25 -17
- package/src/cli/explore-guard.mjs +11 -87
- package/src/cli/explore-guard.test.mjs +34 -97
- package/src/cli/explore-hint.mjs +3 -3
- package/src/cli/explore-hint.test.mjs +14 -5
- package/src/cli/gh-run.mjs +2 -2
- package/src/cli/git-read.mjs +3 -3
- package/src/cli/merge-guard.mjs +70 -21
- package/src/cli/merge-guard.test.mjs +57 -0
- package/src/cli/plugin-agents.test.mjs +4 -4
- package/src/cli/workflow-settings.mjs +18 -1
- package/src/config.mjs +26 -12
- package/src/glob.mjs +7 -0
- package/templates/docs/enforcement.md +2 -2
|
@@ -9,7 +9,7 @@ import { decide, excerptOf, replacedOutput } from "./explore-hint.mjs";
|
|
|
9
9
|
|
|
10
10
|
const HOOKS = fileURLToPath(new URL("../../../../hooks/hooks.json", import.meta.url));
|
|
11
11
|
|
|
12
|
-
const TOOLS = [{ name: "
|
|
12
|
+
const TOOLS = [{ name: "CocoIndex", use: "find the files for a concept", how: 'ccc search "<question>"' }];
|
|
13
13
|
|
|
14
14
|
/** A checkout with `swarm.explore` on, and one with no config. */
|
|
15
15
|
function workspace(t, explore = { tools: TOOLS, maxGrepLines: 5, maxOutputChars: 20, longOutput: "hint", summarizer: "lfm-ask" }) {
|
|
@@ -40,7 +40,13 @@ const lines = (n) => Array.from({ length: n }, (_, i) => `match ${i}`).join("\n"
|
|
|
40
40
|
test("a Grep answer over maxGrepLines adds context naming the tools", (t) => {
|
|
41
41
|
const ws = workspace(t);
|
|
42
42
|
const text = contextOf(decide(call(ws.on, "Grep", lines(10))));
|
|
43
|
-
assert.match(text, /
|
|
43
|
+
assert.match(text, /CocoIndex/);
|
|
44
|
+
assert.match(text, /optional/i);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("a long Grep answer with no tools keeps its output and receives no tool hint", (t) => {
|
|
48
|
+
const ws = workspace(t, { maxGrepLines: 5 });
|
|
49
|
+
assert.equal(decide(call(ws.on, "Grep", lines(10))), null);
|
|
44
50
|
});
|
|
45
51
|
|
|
46
52
|
test("a Grep answer at or under maxGrepLines sees no change", (t) => {
|
|
@@ -91,20 +97,23 @@ test("a bad key reports the error as context instead of a hint", (t) => {
|
|
|
91
97
|
test("a Grep { content } shaped answer over maxGrepLines adds context naming the tools", (t) => {
|
|
92
98
|
const ws = workspace(t);
|
|
93
99
|
const text = contextOf(decide(call(ws.on, "Grep", { content: lines(10) })));
|
|
94
|
-
assert.match(text, /
|
|
100
|
+
assert.match(text, /CocoIndex/);
|
|
101
|
+
assert.match(text, /optional/i);
|
|
95
102
|
});
|
|
96
103
|
|
|
97
104
|
test("a Grep { matches } shaped answer over maxGrepLines adds context naming the tools", (t) => {
|
|
98
105
|
const ws = workspace(t);
|
|
99
106
|
const matches = Array.from({ length: 10 }, (_, i) => `match ${i}`);
|
|
100
107
|
const text = contextOf(decide(call(ws.on, "Grep", { matches })));
|
|
101
|
-
assert.match(text, /
|
|
108
|
+
assert.match(text, /CocoIndex/);
|
|
109
|
+
assert.match(text, /optional/i);
|
|
102
110
|
});
|
|
103
111
|
|
|
104
112
|
test("a Grep answer of unknown shape counts real newlines and escaped \\n sequences", (t) => {
|
|
105
113
|
const ws = workspace(t);
|
|
106
114
|
const text = contextOf(decide(call(ws.on, "Grep", { blob: lines(10) })));
|
|
107
|
-
assert.match(text, /
|
|
115
|
+
assert.match(text, /CocoIndex/);
|
|
116
|
+
assert.match(text, /optional/i);
|
|
108
117
|
});
|
|
109
118
|
|
|
110
119
|
test("a Bash { stdout, stderr } shaped answer over maxOutputChars adds context naming the summarizer", (t) => {
|
package/src/cli/gh-run.mjs
CHANGED
|
@@ -18,12 +18,12 @@ export function expandHome(env) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/** @returns gh's stdout on exit 0, or null when gh fails, times out, or is not installed. */
|
|
21
|
-
export function runGh(args, { cwd = process.cwd(), env = {} } = {}) {
|
|
21
|
+
export function runGh(args, { cwd = process.cwd(), env = {}, timeoutMs = GH_TIMEOUT_MS } = {}) {
|
|
22
22
|
const result = spawnSync("gh", args, {
|
|
23
23
|
cwd,
|
|
24
24
|
encoding: "utf8",
|
|
25
25
|
windowsHide: true,
|
|
26
|
-
timeout:
|
|
26
|
+
timeout: timeoutMs,
|
|
27
27
|
env: { ...process.env, ...expandHome(env) },
|
|
28
28
|
});
|
|
29
29
|
return result.status === 0 ? (result.stdout ?? "") : null;
|
package/src/cli/git-read.mjs
CHANGED
|
@@ -22,9 +22,9 @@ export const commitOf = (cwd, ref) => gitOut(cwd, "rev-parse", "--verify", "--qu
|
|
|
22
22
|
/** @returns the branch checked out at `dir`, or null on a detached head. */
|
|
23
23
|
export const branchAt = (dir) => gitOut(dir, "branch", "--show-current") || null;
|
|
24
24
|
|
|
25
|
-
/** @returns the local branches whose head is `sha`, in ref order. */
|
|
26
|
-
export const branchesAt = (cwd, sha) =>
|
|
27
|
-
(
|
|
25
|
+
/** @returns the local branches whose head is `sha`, in ref order. `read` replaces `gitOut`, for a time budget. */
|
|
26
|
+
export const branchesAt = (cwd, sha, read = gitOut) =>
|
|
27
|
+
(read(cwd, "for-each-ref", "--points-at", sha, "--format=%(refname:short)", "refs/heads") ?? "").split(/\r?\n/).filter(Boolean);
|
|
28
28
|
|
|
29
29
|
/** @returns each linked worktree of the repository at `root`, with its branch and head; the primary checkout is left out. */
|
|
30
30
|
export function linkedWorktrees(root) {
|
package/src/cli/merge-guard.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// The trigger that holds `gh pr merge` to its review. Before the call it needs `--match-head-commit` and an
|
|
3
|
-
// APPROVED review of `swarm.review.merge` for that sha
|
|
3
|
+
// APPROVED review of `swarm.review.merge` for that sha, or a head inside the direct lane of `swarm.direct`.
|
|
4
|
+
// After the call it records the merge and its issues.
|
|
4
5
|
// A merge that names another repository than the checkout's `origin` is that repository's own, so it passes.
|
|
5
6
|
// With `swarm.dispatch` off, the record is still written for the worktree check of QC-015, and nothing is judged.
|
|
6
7
|
|
|
7
8
|
import { spawnSync } from "node:child_process";
|
|
8
9
|
import { fileURLToPath } from "node:url";
|
|
9
10
|
import { PARSERS } from "./bash-command-guard.mjs";
|
|
11
|
+
import { LANE_BUDGET_MS, mergeLane, sizeLine } from "./direct-lane.mjs";
|
|
10
12
|
import { ghApiMerges, ghMerges } from "./gh-merge-command.mjs";
|
|
11
13
|
import { runGh } from "./gh-run.mjs";
|
|
12
14
|
import { appendRecord, latestVerdictFor, readLedger } from "./ledger.mjs";
|
|
@@ -25,23 +27,67 @@ const REVIEWER = { branch: "the branch reviewer (sdd-branch-reviewer)", task: "t
|
|
|
25
27
|
const deny = (reason) => ({ hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: reason } });
|
|
26
28
|
const context = (text) => ({ hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: text } });
|
|
27
29
|
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Judges each merge: an APPROVED review of `kind` on its head, or else the direct lane that `lane(merge)` decides.
|
|
32
|
+
* @returns `{ refusal }` for the first merge that may not run, or `{ refusal: null, direct }` with the lane notes.
|
|
33
|
+
*/
|
|
34
|
+
export function mergeVerdict(merges, records, kind, lane = null) {
|
|
35
|
+
const direct = [];
|
|
30
36
|
for (const merge of merges) {
|
|
31
37
|
if (!merge.sha) {
|
|
32
|
-
return `Merge guard: \`gh pr merge\` must pass \`--match-head-commit <sha>\` with the head the ${kind} review approved, so a push after the review cannot merge unreviewed. Add it
|
|
38
|
+
return { refusal: `Merge guard: \`gh pr merge\` must pass \`--match-head-commit <sha>\` with the head the ${kind} review approved, so a push after the review cannot merge unreviewed. Add it.` };
|
|
33
39
|
}
|
|
34
40
|
const verdict = latestVerdictFor(records, merge.sha, [kind]);
|
|
35
|
-
if (verdict?.verdict
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
if (verdict?.verdict === "APPROVED") continue;
|
|
42
|
+
const fit = lane ? lane(merge) : null;
|
|
43
|
+
if (fit && fit.problem === null) {
|
|
44
|
+
direct.push(fit.note);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const latest = verdict ? ` (the latest is ${verdict.verdict})` : "";
|
|
48
|
+
const laneNote = fit ? ` The direct lane of swarm.direct does not apply: ${fit.problem}.` : "";
|
|
49
|
+
return {
|
|
50
|
+
refusal:
|
|
38
51
|
`Merge guard: the ledger holds no APPROVED ${kind} review of ${merge.sha}${latest}. ` +
|
|
39
52
|
`Dispatch ${REVIEWER[kind]} on that head, and merge after it approves. ` +
|
|
40
|
-
"`qc ledger` lists the verdicts, and swarm.review.merge names the kind that counts."
|
|
41
|
-
|
|
42
|
-
}
|
|
53
|
+
"`qc ledger` lists the verdicts, and swarm.review.merge names the kind that counts." +
|
|
54
|
+
laneNote,
|
|
55
|
+
};
|
|
43
56
|
}
|
|
44
|
-
return null;
|
|
57
|
+
return { refusal: null, direct };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @returns the reason the first of `merges` may not run, or null when each pins an approved head. */
|
|
61
|
+
export const mergeRefusal = (merges, records, kind, lane = null) => mergeVerdict(merges, records, kind, lane).refusal;
|
|
62
|
+
|
|
63
|
+
/** The base branch the PR of `merge` merges into, as gh reads it before the merge, or null. */
|
|
64
|
+
function prBaseOf(merge, cwd, gh, timeoutMs) {
|
|
65
|
+
const args = ["pr", "view", ...(merge.selector ? [merge.selector] : []), ...(merge.repo ? ["-R", merge.repo] : []), "--json", "baseRefName"];
|
|
66
|
+
try {
|
|
67
|
+
return JSON.parse(gh(args, { cwd, env: merge.env, timeoutMs }) ?? "null")?.baseRefName ?? null;
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The direct lane of one workflow, as `mergeVerdict` asks it. Null while `swarm.direct` is false; a wrong value
|
|
75
|
+
* names itself. The lane measures against `worktree.base`, so a PR into another base stays out of it.
|
|
76
|
+
* The merges of one call share one time budget.
|
|
77
|
+
*/
|
|
78
|
+
function laneOf(workflow, records, cwd, gh) {
|
|
79
|
+
const { direct, directProblem, base } = workflow;
|
|
80
|
+
if (!direct) return directProblem ? () => ({ problem: directProblem }) : null;
|
|
81
|
+
const deadline = Date.now() + LANE_BUDGET_MS;
|
|
82
|
+
return (merge) => {
|
|
83
|
+
const fit = mergeLane({ root: workflow.root, base, direct, protectedBranches: workflow.protectedBranches, sha: merge.sha, records, budgetMs: deadline - Date.now() });
|
|
84
|
+
if (fit.problem !== null) return fit;
|
|
85
|
+
const left = deadline - Date.now();
|
|
86
|
+
const prBase = left > 0 ? prBaseOf(merge, cwd, gh, left) : null;
|
|
87
|
+
if (prBase === null) return { problem: "gh cannot read the base branch of the PR within the time budget of the lane" };
|
|
88
|
+
if (prBase !== base && `origin/${prBase}` !== base) return { problem: `the PR merges into ${prBase}, and the lane measures against ${base}` };
|
|
89
|
+
return { problem: null, note: `Merge guard: ${merge.sha} merges through the direct lane, with ${sizeLine(fit.size, direct)} and no review.` };
|
|
90
|
+
};
|
|
45
91
|
}
|
|
46
92
|
|
|
47
93
|
/**
|
|
@@ -158,21 +204,24 @@ export function decide(call, { gh = runGh } = {}) {
|
|
|
158
204
|
if (merges.length === 0) return null;
|
|
159
205
|
const { origin, own, other } = partition(merges, workflow.root);
|
|
160
206
|
if (event === "PreToolUse") {
|
|
161
|
-
let
|
|
207
|
+
let verdict = { refusal: null, direct: [] };
|
|
162
208
|
if (own.length > 0) {
|
|
163
209
|
try {
|
|
164
|
-
|
|
210
|
+
const records = readLedger(workflow.ledger);
|
|
211
|
+
verdict = mergeVerdict(own, records, workflow.review.merge, laneOf(workflow, records, call.cwd ?? process.cwd(), gh));
|
|
165
212
|
} catch (error) {
|
|
166
|
-
|
|
213
|
+
verdict = { refusal: `Merge guard: the ledger cannot be read (${error.message}), so no review can be checked. Fix the ledger file, and merge again.` };
|
|
167
214
|
}
|
|
168
215
|
}
|
|
169
|
-
if (refusal) return deny(refusal);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
216
|
+
if (verdict.refusal) return deny(verdict.refusal);
|
|
217
|
+
const notes = [...verdict.direct];
|
|
218
|
+
if (other.length > 0) {
|
|
219
|
+
notes.push(
|
|
220
|
+
`Merge guard passes ${[...new Set(other.map((merge) => merge.repo))].join(", ")}: it is not this checkout's repository (${origin}), ` +
|
|
221
|
+
"so its reviews are not in this ledger. The guard records nothing for it.",
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
return notes.length > 0 ? context(notes.join(" ")) : null;
|
|
176
225
|
}
|
|
177
226
|
const notes = own.map((merge) => recordMerge(merge, call, workflow, gh)).filter(Boolean);
|
|
178
227
|
return notes.length > 0 ? { systemMessage: notes.join(" ") } : null;
|
|
@@ -345,3 +345,60 @@ test("with swarm.dispatch off, a merge whose command failed after GitHub merged
|
|
|
345
345
|
assert.equal(decide(shell(ws.off, "gh pr merge 60 --squash --delete-branch", "PostToolUseFailure"), { gh: fakeGh(MERGED).gh }), null);
|
|
346
346
|
assert.deepEqual(readLedger(ws.ledgerOf(ws.off)).map(({ type, pr }) => ({ type, pr })), [{ type: "merge", pr: 60 }]);
|
|
347
347
|
});
|
|
348
|
+
|
|
349
|
+
/** A checkout with the checks on, `origin/main` at its first commit, and a small fix on `feat/1-x`. */
|
|
350
|
+
function laneRepo(t, config = { swarm: { dispatch: {} } }) {
|
|
351
|
+
const dir = realpathSync.native(mkdtempSync(path.join(os.tmpdir(), "qc-merge-lane-")));
|
|
352
|
+
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
353
|
+
const git = (...args) => execFileSync("git", args, { cwd: dir, stdio: "pipe", encoding: "utf8" }).trim();
|
|
354
|
+
git("init", "-q", "-b", "main");
|
|
355
|
+
for (const [key, value] of [["user.name", "qc"], ["user.email", "qc@example.com"], ["commit.gpgsign", "false"]]) git("config", key, value);
|
|
356
|
+
writeFileSync(path.join(dir, "qc.config.json"), JSON.stringify(config));
|
|
357
|
+
writeFileSync(path.join(dir, "a.ts"), "one\ntwo\n");
|
|
358
|
+
git("add", ".");
|
|
359
|
+
git("commit", "-q", "-m", "init");
|
|
360
|
+
git("update-ref", "refs/remotes/origin/main", "HEAD");
|
|
361
|
+
git("switch", "-q", "-c", "feat/1-x");
|
|
362
|
+
writeFileSync(path.join(dir, "a.ts"), "one\n2\n");
|
|
363
|
+
git("commit", "-q", "-am", "fix");
|
|
364
|
+
return { dir, head: git("rev-parse", "HEAD"), ledger: path.join(dir, ".git", "qc", "ledger.jsonl") };
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
test("a small head with no review merges through the direct lane, with a note", (t) => {
|
|
368
|
+
const { dir, head } = laneRepo(t);
|
|
369
|
+
const { gh, calls } = fakeGh(JSON.stringify({ baseRefName: "main" }));
|
|
370
|
+
const output = decide(shell(dir, `gh pr merge 7 --squash --match-head-commit ${head}`), { gh });
|
|
371
|
+
assert.equal(denied(output), null);
|
|
372
|
+
assert.deepEqual(calls[0].args, ["pr", "view", "7", "--json", "baseRefName"]);
|
|
373
|
+
assert.match(output?.hookSpecificOutput?.additionalContext ?? "", /merges through the direct lane, with 2 of 20 lines in 1 of 2 files and no review/);
|
|
374
|
+
assert.match(denied(decide(shell(dir, "gh pr merge 7 --squash"))) ?? "", /--match-head-commit <sha>/);
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
test("a review that asked for changes keeps a small head out of the direct lane", (t) => {
|
|
378
|
+
const { dir, head, ledger } = laneRepo(t);
|
|
379
|
+
appendRecord(ledger, verdict("task", "CHANGES_REQUIRED", head));
|
|
380
|
+
const reason = denied(decide(shell(dir, `gh pr merge 7 --squash --match-head-commit ${head}`))) ?? "";
|
|
381
|
+
assert.match(reason, /no APPROVED branch review/);
|
|
382
|
+
assert.match(reason, /The direct lane of swarm\.direct does not apply: the latest review on the branch, of .*, is CHANGES_REQUIRED/);
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
test("with swarm.direct false, a small head needs its review as before", (t) => {
|
|
386
|
+
const { dir, head } = laneRepo(t, { swarm: { dispatch: {}, direct: false } });
|
|
387
|
+
const reason = denied(decide(shell(dir, `gh pr merge 7 --squash --match-head-commit ${head}`))) ?? "";
|
|
388
|
+
assert.match(reason, /no APPROVED branch review/);
|
|
389
|
+
assert.doesNotMatch(reason, /direct lane/);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
test("a wrong swarm.direct closes the lane and keeps the merge guard on", (t) => {
|
|
393
|
+
const { dir, head } = laneRepo(t, { swarm: { dispatch: {}, direct: { maxLines: 0 } } });
|
|
394
|
+
const reason = denied(decide(shell(dir, `gh pr merge 7 --squash --match-head-commit ${head}`))) ?? "";
|
|
395
|
+
assert.match(reason, /no APPROVED branch review/);
|
|
396
|
+
assert.match(reason, /does not apply: swarm.direct.maxLines/);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
test("a PR into another base, or a PR whose base gh cannot read, stays out of the direct lane", (t) => {
|
|
400
|
+
const { dir, head } = laneRepo(t);
|
|
401
|
+
const merge = shell(dir, `gh pr merge 7 --squash --match-head-commit ${head}`);
|
|
402
|
+
assert.match(denied(decide(merge, { gh: fakeGh(JSON.stringify({ baseRefName: "release/2.0" })).gh })) ?? "", /the PR merges into release\/2\.0, and the lane measures against origin\/main/);
|
|
403
|
+
assert.match(denied(decide(merge, { gh: fakeGh(null).gh })) ?? "", /gh cannot read the base branch of the PR/);
|
|
404
|
+
});
|
|
@@ -41,10 +41,10 @@ const ALWAYS_PRESENT = ["Read", "Bash"];
|
|
|
41
41
|
const READ_TOOLS = ["Read", "Grep", "Glob", "Bash", "PowerShell"];
|
|
42
42
|
const EDIT_TOOLS = [...READ_TOOLS, "Skill", "Edit", "Write"];
|
|
43
43
|
const EXPECTED = {
|
|
44
|
-
"sdd-implementer": { model: "
|
|
45
|
-
"sdd-planner": { model: "
|
|
46
|
-
"sdd-reviewer": { model: "
|
|
47
|
-
"sdd-branch-reviewer": { model: "
|
|
44
|
+
"sdd-implementer": { model: "gpt-6.1-sol", effort: "high", tools: EDIT_TOOLS },
|
|
45
|
+
"sdd-planner": { model: "gpt-6.1-sol", effort: "high", tools: EDIT_TOOLS },
|
|
46
|
+
"sdd-reviewer": { model: "gpt-6.1-sol", effort: "high", tools: READ_TOOLS },
|
|
47
|
+
"sdd-branch-reviewer": { model: "gpt-6.1-sol", effort: "high", tools: READ_TOOLS },
|
|
48
48
|
};
|
|
49
49
|
// Fields Claude Code ignores on a plugin agent, and the one that drops a repository's CLAUDE.md and rules.
|
|
50
50
|
const FORBIDDEN_FIELDS = ["disallowedTools", "hooks", "mcpServers", "permissionMode", "omitClaudeMd"];
|
|
@@ -5,6 +5,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { CONFIG_FILE, load, merge, reviewDefaults } from "../config.mjs";
|
|
7
7
|
import { checkoutRootOf } from "./checkout-root.mjs";
|
|
8
|
+
import { directSettings } from "./direct-lane.mjs";
|
|
8
9
|
import { dispatchSettings } from "./dispatch.mjs";
|
|
9
10
|
import { fileSafe } from "./edit-batch-state.mjs";
|
|
10
11
|
import { ledgerFileOf } from "./ledger.mjs";
|
|
@@ -46,7 +47,23 @@ export function workflowAt(cwd) {
|
|
|
46
47
|
const review = reviewSettings(config.swarm);
|
|
47
48
|
const ledger = review ? ledgerFileOf(root) : null;
|
|
48
49
|
if (!review || !ledger) return null;
|
|
49
|
-
|
|
50
|
+
// A wrong `swarm.direct` closes the lane only: the guards that read this workflow keep their checks.
|
|
51
|
+
let direct = null;
|
|
52
|
+
let directProblem = null;
|
|
53
|
+
try {
|
|
54
|
+
direct = directSettings(config.swarm);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
directProblem = error.message;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
root,
|
|
60
|
+
ledger,
|
|
61
|
+
review,
|
|
62
|
+
direct,
|
|
63
|
+
directProblem,
|
|
64
|
+
base: config.worktree?.base ?? "origin/main",
|
|
65
|
+
protectedBranches: config.swarm.isolation?.protectedBranches ?? [],
|
|
66
|
+
};
|
|
50
67
|
}
|
|
51
68
|
|
|
52
69
|
/** The workflow folder of one session under the OS temp folder. */
|
package/src/config.mjs
CHANGED
|
@@ -249,6 +249,8 @@ export const defaults = {
|
|
|
249
249
|
dispatch: null,
|
|
250
250
|
// Read only while `dispatch` is on. `reviewDefaults` fills each key it omits.
|
|
251
251
|
review: null,
|
|
252
|
+
// Read only while `dispatch` is on, and on by default then. `false` turns it off; `directDefaults` fills each key it omits.
|
|
253
|
+
direct: null,
|
|
252
254
|
},
|
|
253
255
|
|
|
254
256
|
// Files a generator writes. The generated-file hook refuses a hand edit of one and names `command`.
|
|
@@ -493,21 +495,20 @@ export const dispatchDefaults = {
|
|
|
493
495
|
implementerSlots: 1,
|
|
494
496
|
// The model families each type's named `model` may carry. `"*"` covers every other type.
|
|
495
497
|
models: {
|
|
496
|
-
"sdd-planner": ["
|
|
497
|
-
"architecture:sdd-planner": ["
|
|
498
|
-
"sdd-branch-reviewer": ["
|
|
499
|
-
"architecture:sdd-branch-reviewer": ["
|
|
500
|
-
"sdd-implementer": ["
|
|
501
|
-
"architecture:sdd-implementer": ["
|
|
502
|
-
"sdd-reviewer": ["
|
|
503
|
-
"architecture:sdd-reviewer": ["
|
|
504
|
-
"*": ["
|
|
498
|
+
"sdd-planner": ["gpt-6.1-sol"],
|
|
499
|
+
"architecture:sdd-planner": ["gpt-6.1-sol"],
|
|
500
|
+
"sdd-branch-reviewer": ["gpt-6.1-sol"],
|
|
501
|
+
"architecture:sdd-branch-reviewer": ["gpt-6.1-sol"],
|
|
502
|
+
"sdd-implementer": ["gpt-6.1-sol"],
|
|
503
|
+
"architecture:sdd-implementer": ["gpt-6.1-sol"],
|
|
504
|
+
"sdd-reviewer": ["gpt-6.1-sol"],
|
|
505
|
+
"architecture:sdd-reviewer": ["gpt-6.1-sol"],
|
|
506
|
+
"*": ["gpt-6.1-sol"],
|
|
505
507
|
},
|
|
506
508
|
};
|
|
507
509
|
|
|
508
|
-
//
|
|
509
|
-
|
|
510
|
-
export const MODEL_FAMILIES = ["opus", "sonnet", "haiku", "fable"];
|
|
510
|
+
// GPT uses an exact model id; Claude families remain available for repository overrides.
|
|
511
|
+
export const MODEL_FAMILIES = ["gpt-6.1-sol", "opus", "sonnet", "haiku", "fable"];
|
|
511
512
|
|
|
512
513
|
// What each key of `swarm.explore` means when a repository omits it. The kit names no tool; a
|
|
513
514
|
// repository lists its own index, call graph or summarizer in `tools` and `summarizer`.
|
|
@@ -552,6 +553,19 @@ export const reviewDefaults = {
|
|
|
552
553
|
plannerTypes: ["sdd-planner", "architecture:sdd-planner"],
|
|
553
554
|
};
|
|
554
555
|
|
|
556
|
+
// What each key of `swarm.direct` means when a repository omits it. A fix inside these limits skips the
|
|
557
|
+
// subagent workflow: the main session edits it and merges it with no review. A list replaces its default.
|
|
558
|
+
export const directDefaults = {
|
|
559
|
+
// The most changed lines, added plus deleted, of the branch against its merge base.
|
|
560
|
+
maxLines: 20,
|
|
561
|
+
// The most changed files of the branch against its merge base.
|
|
562
|
+
maxFiles: 2,
|
|
563
|
+
// Globs a direct fix may not touch. A change to one of these runs the subagent workflow.
|
|
564
|
+
excludes: ["schemas/**", "**/migrations/**"],
|
|
565
|
+
// Globs a direct fix may touch only with one APPROVED review of its head, of either kind.
|
|
566
|
+
reviewPaths: [],
|
|
567
|
+
};
|
|
568
|
+
|
|
555
569
|
function isPlainObject(value) {
|
|
556
570
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
557
571
|
}
|
package/src/glob.mjs
CHANGED
|
@@ -21,3 +21,10 @@ export function globMatcher(globs) {
|
|
|
21
21
|
const patterns = globs.map(globToRegExp);
|
|
22
22
|
return (rel) => patterns.some((pattern) => pattern.test(rel) || pattern.test(`/${rel}`));
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
/** A `globMatcher` over file paths. Windows paths ignore case, so both sides are lowercased there. */
|
|
26
|
+
export function pathMatcher(globs, platform = process.platform) {
|
|
27
|
+
if (platform !== "win32") return globMatcher(globs);
|
|
28
|
+
const matches = globMatcher(globs.map((glob) => glob.toLowerCase()));
|
|
29
|
+
return (rel) => matches(rel.toLowerCase());
|
|
30
|
+
}
|
|
@@ -67,9 +67,9 @@ recorded.
|
|
|
67
67
|
| An implementer reports the failing test before the passing one | `report-stop.mjs` |
|
|
68
68
|
| A task is reviewed before the next implementer starts on its branch | `dispatch-guard.mjs`, through `task-gate.mjs` |
|
|
69
69
|
| A fix round goes back to the implementer that wrote the task | `dispatch-guard.mjs`, through `task-gate.mjs` |
|
|
70
|
-
| A merge pins the head that an APPROVED review named | `merge-guard.mjs` |
|
|
70
|
+
| A merge pins the head that an APPROVED review named, or a head inside the direct lane | `merge-guard.mjs`, through `direct-lane.mjs` |
|
|
71
71
|
| An issue that a merge names is closed, or has a comment after the merge | `issue-gate.mjs`, on `Stop` |
|
|
72
|
-
| The controller edits only its own paths | `controller-guard.mjs` |
|
|
72
|
+
| The controller edits only its own paths, or a small fix inside the direct lane | `controller-guard.mjs`, through `direct-lane.mjs` |
|
|
73
73
|
| A plan task names its files, a test step, and a commit step, within the budget | `qc plan-check`, and `plan-stop.mjs` |
|
|
74
74
|
|
|
75
75
|
## Worktrees — QC-015
|