architecture-harness 0.20.2 → 0.20.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architecture-harness",
3
- "version": "0.20.2",
3
+ "version": "0.20.3",
4
4
  "type": "module",
5
5
  "description": "Architecture gates, lint rules and scaffolding for the bounded-vertical-slice architecture",
6
6
  "license": "MIT",
@@ -117,12 +117,15 @@ function worktreeAddPath(args) {
117
117
  return null;
118
118
  }
119
119
 
120
- /** A path as a shell resolves it from `cwd`. PowerShell also reads a backslash as a separator on Linux and macOS. */
121
- function resolveFrom(cwd, spelled, parse) {
120
+ /** A path as the shell spells it, in the form of this platform. PowerShell also reads a backslash as a separator on Linux and macOS. */
121
+ function spelledPath(spelled, parse) {
122
122
  const word = parse === powershellSegments ? spelled.replace(/\\/g, "/") : spelled;
123
- return path.resolve(cwd, nativePath(word.replace(/^~(?=$|[\\/])/, os.homedir())));
123
+ return nativePath(word.replace(/^~(?=$|[\\/])/, os.homedir()));
124
124
  }
125
125
 
126
+ /** A path as a shell resolves it from `cwd`. */
127
+ const resolveFrom = (cwd, spelled, parse) => path.resolve(cwd, spelledPath(spelled, parse));
128
+
126
129
  /** True when `target` is one folder directly under `folder`, as `qc worktree add` makes it. */
127
130
  function inFolder(folder, target) {
128
131
  const parts = path.relative(keyOf(folder), keyOf(target)).split(path.sep);
@@ -138,16 +141,35 @@ const REASONS = {
138
141
  script:
139
142
  "a hand run of a hook script writes a lease or a ledger record under a made-up session id, and that lease blocks later " +
140
143
  "edits in the worktree for hours. Test a hook only through its own suite (`node --test`), in temporary folders.",
144
+ explicitDir:
145
+ "`--git-dir`, `GIT_DIR`, `--work-tree`, and `GIT_WORK_TREE` make git read the repository from a path it resolves after every `-C`, " +
146
+ "so this guard cannot tell which repository gets the worktree. Run `git worktree add` from inside the target repository instead: " +
147
+ "use `-C <repository>`, `cd <repository>`, or `Set-Location <repository>`, and drop the git directory and work tree settings.",
141
148
  worktree:
142
149
  "a worktree lives in the worktree folder of the main checkout, so git ignores it and `qc worktree remove` finds it. " +
143
150
  "Run `npx qc worktree add <name> <branch>` from the repository, or give `git worktree add` a path one level under that folder.",
144
151
  };
145
152
 
146
153
  /**
147
- * @param {{cwd: string, folder: string} | null} [place] the working directory and the worktree folder; null skips the worktree rule
154
+ * The worktree folder that judges `git worktree add`: the one of the repository the command targets. A `cd`,
155
+ * `Set-Location`, or `-C` into a repository names it, and else the session's own
156
+ * repository does. The path that `add` names never decides, because git adds the worktree to the repository
157
+ * of the working directory wherever the path is. `null` means the targeted repository is not guarded.
158
+ */
159
+ function folderFor(place, from) {
160
+ // `undefined` means no checkout holds `from`, and `null` means one does that is not guarded.
161
+ const worked = place.folderAt(from);
162
+ return worked === undefined ? place.folder : worked;
163
+ }
164
+
165
+ /**
166
+ * @param {{cwd: string, folder: string, folderAt: (dir: string) => string | null | undefined} | null} [place] the working directory,
167
+ * the session's worktree folder, and the folder of the repository that holds a directory (`undefined` when none does, `null` when
168
+ * it is not guarded); null skips the worktree rule
169
+ * @param {string[]} [refused] receives the folder of each refused worktree path
148
170
  * @returns the reasons the command breaks a rule, in a stable order.
149
171
  */
150
- export function violations(command, parse = segmentsOf, place = null) {
172
+ export function violations(command, parse = segmentsOf, place = null, refused = []) {
151
173
  const segments = parse(command);
152
174
  const found = new Set();
153
175
  let cwd = place?.cwd;
@@ -158,17 +180,29 @@ export function violations(command, parse = segmentsOf, place = null) {
158
180
  if (git && skipsHooks(git)) found.add("hooks");
159
181
  if (git && setsHooksPath(git)) found.add("hooksPath");
160
182
  const added = place && git?.sub === "worktree" ? worktreeAddPath(git.args) : null;
161
- if (added !== null) {
183
+ if (added !== null && git.explicitDir) {
184
+ // The session is guarded, because `place` exists only then.
185
+ found.add("explicitDir");
186
+ } else if (added !== null) {
162
187
  const from = git.dirs.filter(Boolean).reduce((dir, next) => resolveFrom(dir, next, parse), cwd);
163
- if (!inFolder(place.folder, resolveFrom(from, added, parse))) found.add("worktree");
188
+ const folder = folderFor(place, from);
189
+ if (folder !== null && !inFolder(folder, resolveFrom(from, added, parse))) {
190
+ found.add("worktree");
191
+ refused.push(folder);
192
+ }
164
193
  }
165
194
  const nested = nestedCommand(segment);
166
- if (nested) for (const key of violations(nested.command, nested.parse, place && { ...place, cwd })) found.add(key);
195
+ if (nested) for (const key of violations(nested.command, nested.parse, place && { ...place, cwd }, refused)) found.add(key);
167
196
  }
168
197
  if (!segments.some(runsTests) && segments.some(runsHookScript)) found.add("script");
169
198
  return Object.keys(REASONS).filter((key) => found.has(key));
170
199
  }
171
200
 
201
+ /** The worktree folder of the repository that holds `dir`: undefined when none does, null when it has no config or turns the rule off. */
202
+ function folderAt(dir) {
203
+ return checkoutRootOf(dir) === null ? undefined : (worktreeRuleAt(dir)?.folder ?? null);
204
+ }
205
+
172
206
  /** The verdict on one Bash or PowerShell call. @returns the hook output, or null to let the call run with no message. */
173
207
  export function decide(call) {
174
208
  const command = call.tool_input?.command;
@@ -179,9 +213,11 @@ export function decide(call) {
179
213
  if (!root || !existsSync(path.join(root, CONFIG_FILE))) return null;
180
214
  // The config is read only for a command that can add a worktree, so every other call stays cheap.
181
215
  const rule = /\bworktree\b/i.test(command) ? worktreeRuleAt(cwd) : null;
182
- const found = violations(command, parse, rule && { cwd: path.resolve(cwd), folder: rule.folder });
216
+ const refused = [];
217
+ const place = rule && { cwd: path.resolve(cwd), folder: rule.folder, folderAt };
218
+ const found = violations(command, parse, place, refused);
183
219
  if (found.length === 0) return null;
184
- const reasonOf = (key) => (key === "worktree" ? `${REASONS.worktree} The folder is ${rule.folder}.` : REASONS[key]);
220
+ const reasonOf = (key) => (key === "worktree" ? `${REASONS.worktree} The folder is ${[...new Set(refused)].join(" or ")}.` : REASONS[key]);
185
221
  return {
186
222
  hookSpecificOutput: {
187
223
  hookEventName: "PreToolUse",
@@ -234,3 +234,122 @@ test("inside a linked worktree, the folder is the main checkout's", (t) => {
234
234
  assert.equal(decide(bash(linked, "git worktree add ../x")), null);
235
235
  assert.ok(outsideFolder(decide(bash(linked, "git worktree add x"))), "a worktree nested in a worktree is refused");
236
236
  });
237
+
238
+ /** The adopted checkout plus a second adopted checkout, `kit`, and a checkout with no config. Forward slashes, as a Bash command spells a path. */
239
+ function twoRepos(t) {
240
+ const ws = workspace(t);
241
+ const kit = path.join(path.dirname(ws.adopted), "kit");
242
+ mkdirSync(kit);
243
+ execFileSync("git", ["init", "-q"], { cwd: kit, stdio: "pipe" });
244
+ writeFileSync(path.join(kit, "qc.config.json"), "{}");
245
+ return { ...ws, kit, slash: (dir) => dir.replaceAll("\\", "/") };
246
+ }
247
+
248
+ test("a worktree add judges the repository the command targets, through -C, cd, or Set-Location", (t) => {
249
+ const ws = twoRepos(t);
250
+ const kit = ws.slash(ws.kit);
251
+ for (const command of [
252
+ `git -C ${kit} worktree add ${kit}/.worktree/x -b feat/x`,
253
+ `git -C ${kit} worktree add .worktree/x`,
254
+ `cd ${kit} && git worktree add .worktree/x`,
255
+ `cd ${kit} && git worktree add ${kit}/.worktree/x`,
256
+ `bash -c 'cd ${kit} && git worktree add .worktree/x'`,
257
+ ]) {
258
+ assert.equal(decide(bash(ws.adopted, command)), null, command);
259
+ }
260
+ for (const command of [`Set-Location ${kit}; git worktree add .worktree/x`, `Set-Location ${kit}; git worktree add ${kit}/.worktree/x`, `git -C ${kit} worktree add .worktree/x`]) {
261
+ assert.equal(decide(powershell(ws.adopted, command)), null, command);
262
+ }
263
+ });
264
+
265
+ test("a worktree add in the targeted repository is still held to that repository's folder, and the deny names it", (t) => {
266
+ const ws = twoRepos(t);
267
+ const kit = ws.slash(ws.kit);
268
+ for (const command of [`git -C ${kit} worktree add ../x`, `git -C ${kit} worktree add ${ws.slash(ws.adopted)}/.worktree/x`, `cd ${kit} && git worktree add x`]) {
269
+ const reason = reasonOf(decide(bash(ws.adopted, command))) ?? "";
270
+ assert.match(reason, /npx qc worktree add <name> <branch>/, command);
271
+ assert.ok(reason.includes(`The folder is ${path.join(ws.kit, ".worktree")}.`), `${command}: ${reason}`);
272
+ }
273
+ });
274
+
275
+ test("an absolute worktree path alone does not name the repository: git adds to the session's repository", (t) => {
276
+ const ws = twoRepos(t);
277
+ const kit = ws.slash(ws.kit);
278
+ for (const command of [`git worktree add ${kit}/.worktree/x`, `git worktree add ${kit}/x`, `git worktree add ../x`]) {
279
+ const reason = reasonOf(decide(bash(ws.adopted, command))) ?? "";
280
+ assert.ok(reason.includes(`The folder is ${path.join(ws.adopted, ".worktree")}.`), `${command}: ${reason}`);
281
+ }
282
+ assert.equal(decide(bash(ws.adopted, `git worktree add ${ws.slash(ws.adopted)}/.worktree/x`)), null);
283
+ });
284
+
285
+ /** The refusal for an explicit git directory or work tree: it says to run `git worktree add` from inside the target repository. */
286
+ const explicitDirReason = (output) => {
287
+ const reason = reasonOf(output) ?? "";
288
+ assert.match(reason, /--git-dir|GIT_DIR|--work-tree|GIT_WORK_TREE/, reason);
289
+ assert.match(reason, /from inside the target repository/, reason);
290
+ assert.match(reason, /-C/, reason);
291
+ return reason;
292
+ };
293
+
294
+ test("a worktree add with --git-dir, GIT_DIR, --work-tree, or GIT_WORK_TREE is refused from a guarded session", (t) => {
295
+ const ws = twoRepos(t);
296
+ const kit = ws.slash(ws.kit);
297
+ const plain = ws.slash(ws.plain);
298
+ const adopted = ws.slash(ws.adopted);
299
+ for (const command of [
300
+ `git --git-dir=${kit}/.git worktree add ${kit}/.worktree/x`,
301
+ `git --git-dir ${kit}/.git worktree add ${kit}/.worktree/x`,
302
+ `GIT_DIR=${kit}/.git git worktree add ${kit}/.worktree/x`,
303
+ `git -C ${kit} --git-dir=${kit}/.git worktree add .worktree/x`,
304
+ `git -C ${plain} --git-dir=${kit}/.git worktree add ${kit}/.worktree/x`,
305
+ `git --git-dir=${kit}/.git worktree add ../x`,
306
+ `GIT_DIR=${kit}/.git git worktree add ../x`,
307
+ `git --git-dir=${kit}/.git worktree add .worktree/x`,
308
+ `GIT_DIR=${kit}/.git git worktree add .worktree/x`,
309
+ `cd ${plain} && git --git-dir=${kit}/.git worktree add .worktree/x`,
310
+ `git -C ${plain} --git-dir=${adopted}/.git worktree add ../x`,
311
+ `git --git-dir=${plain}/.git worktree add ../x`,
312
+ `git --git-dir=${adopted}/.git worktree add ${adopted}/.worktree/x`,
313
+ `env GIT_DIR=${kit}/.git git worktree add ../x`,
314
+ `bash -c 'git --git-dir=${kit}/.git worktree add ../x'`,
315
+ `git --work-tree=${plain} worktree add ../x`,
316
+ `git --work-tree ${plain} worktree add ../x`,
317
+ `GIT_WORK_TREE=${plain} git worktree add ../x`,
318
+ `git --work-tree=${kit} worktree add ../x`,
319
+ `GIT_WORK_TREE=${kit} git worktree add ../x`,
320
+ `git --work-tree=${plain} worktree add .worktree/x`,
321
+ ]) {
322
+ explicitDirReason(decide(bash(ws.adopted, command)));
323
+ }
324
+ explicitDirReason(decide(powershell(ws.adopted, `git --git-dir=${kit}/.git worktree add ../x`)));
325
+ });
326
+
327
+ test("git resolves a relative git dir from the working directory after every -C, so these probes are refused", (t) => {
328
+ const ws = twoRepos(t);
329
+ const adopted = ws.slash(ws.adopted);
330
+ const plain = ws.slash(ws.plain);
331
+ // Real git adds ../x1 as a worktree of `adopted` from these.
332
+ for (const command of [
333
+ `cd ${plain} && git --git-dir=.git -C ${adopted} worktree add ../x1`,
334
+ `cd ${plain} && GIT_DIR=.git git -C ${adopted} worktree add ../x1`,
335
+ ]) {
336
+ explicitDirReason(decide(bash(ws.adopted, command)));
337
+ }
338
+ });
339
+
340
+ test("an explicit git dir on a command other than worktree add is not refused by the worktree rule", (t) => {
341
+ const ws = twoRepos(t);
342
+ const kit = ws.slash(ws.kit);
343
+ for (const command of [`git --git-dir=${kit}/.git status`, `git --git-dir=${kit}/.git worktree list`, `GIT_DIR=${kit}/.git git log`]) {
344
+ assert.equal(decide(bash(ws.adopted, command)), null, command);
345
+ }
346
+ });
347
+
348
+ test("a worktree add in a repository with no qc.config.json is not guarded", (t) => {
349
+ const ws = twoRepos(t);
350
+ const plain = ws.slash(ws.plain);
351
+ for (const command of [`git -C ${plain} worktree add ../x`, `cd ${plain} && git worktree add ../x`]) {
352
+ assert.equal(decide(bash(ws.adopted, command)), null, command);
353
+ }
354
+ assert.equal(decide(bash(ws.plain, "git worktree add ../x")), null, "a session in it is not guarded either");
355
+ });
@@ -0,0 +1,46 @@
1
+ // The CI state of a commit, read from its GitHub check runs. The task gate asks it before a review: a
2
+ // head whose CI is not green changes before it is reviewed, so the review waits.
3
+
4
+ import { runGh } from "./gh-run.mjs";
5
+ import { originOf } from "./git-read.mjs";
6
+
7
+ // The hook that asks has a 10 second limit, and a hook that the limit kills lets the call through. The two reads
8
+ // together stay well under it, so a slow gh leaves the head unknown and the review refusal stands.
9
+ const GH_TIMEOUT_MS = 3_000;
10
+ const ORIGIN_TIMEOUT_MS = 1_000;
11
+ const FAILED = new Set(["failure", "cancelled", "timed_out", "action_required"]);
12
+ const short = (sha) => sha.slice(0, 7);
13
+
14
+ /**
15
+ * @param runs the `check_runs` array of the GitHub API
16
+ * @returns why the head is not green, naming the run, or null when every run completed without a failure
17
+ * or when there are no runs, because a head with no CI is unknown.
18
+ */
19
+ export function notGreenReason(runs) {
20
+ const failed = runs.find((entry) => entry.status === "completed" && FAILED.has(entry.conclusion));
21
+ if (failed) return `${failed.name} ended ${failed.conclusion}`;
22
+ const open = runs.find((entry) => entry.status !== "completed");
23
+ return open ? `${open.name} is ${open.status}` : null;
24
+ }
25
+
26
+ /**
27
+ * @returns the reason CI on `sha` is not green, as `CI on <short sha>: <why>`, or null when it is green or
28
+ * unknown: gh fails, times out, answers with no check runs, or the checkout has no `origin`.
29
+ * `gh` and `origin` replace the real reads, for a test.
30
+ */
31
+ export function ciNotGreen(sha, cwd, { gh = runGh, origin = originOf } = {}) {
32
+ if (typeof sha !== "string" || sha === "") return null;
33
+ const repo = origin(cwd, ORIGIN_TIMEOUT_MS);
34
+ if (repo === null) return null;
35
+ const out = gh(["api", `repos/${repo}/commits/${sha}/check-runs?per_page=100`], { cwd, timeoutMs: GH_TIMEOUT_MS });
36
+ if (out === null) return null;
37
+ let runs;
38
+ try {
39
+ runs = JSON.parse(out)?.check_runs;
40
+ } catch {
41
+ return null;
42
+ }
43
+ if (!Array.isArray(runs)) return null;
44
+ const why = notGreenReason(runs);
45
+ return why === null ? null : `CI on ${short(sha)}: ${why}`;
46
+ }
@@ -0,0 +1,62 @@
1
+ import { strict as assert } from "node:assert";
2
+ import { test } from "node:test";
3
+ import { ciNotGreen, notGreenReason } from "./ci-state.mjs";
4
+
5
+ const SHA = "a".repeat(40);
6
+ const run = (name, status, conclusion = null) => ({ name, status, conclusion });
7
+ const reply = (...runs) => JSON.stringify({ total_count: runs.length, check_runs: runs });
8
+
9
+ test("a head whose check runs all completed green is green", () => {
10
+ assert.equal(notGreenReason([run("lint", "completed", "success"), run("docs", "completed", "skipped"), run("x", "completed", "neutral")]), null);
11
+ });
12
+
13
+ test("each failing conclusion makes the head not green, and the reason names the run", () => {
14
+ for (const conclusion of ["failure", "cancelled", "timed_out", "action_required"]) {
15
+ assert.match(notGreenReason([run("ok", "completed", "success"), run("build", "completed", conclusion)]) ?? "", new RegExp(`build.*${conclusion}`));
16
+ }
17
+ });
18
+
19
+ test("a run that has not completed makes the head not green", () => {
20
+ for (const status of ["queued", "in_progress", "waiting", "pending"]) {
21
+ assert.match(notGreenReason([run("build", status)]) ?? "", new RegExp(`build.*${status}`));
22
+ }
23
+ });
24
+
25
+ test("a head with no check runs is unknown, not red", () => {
26
+ assert.equal(notGreenReason([]), null);
27
+ });
28
+
29
+ test("ciNotGreen reads the check runs of the sha from the repository of origin", () => {
30
+ const calls = [];
31
+ const gh = (args, options) => {
32
+ calls.push({ args, options });
33
+ return reply(run("build", "completed", "failure"));
34
+ };
35
+ const reason = ciNotGreen(SHA, "/checkout", { gh, origin: () => "o/r" });
36
+ assert.match(reason ?? "", /^CI on aaaaaaa:.*build.*failure/);
37
+ assert.equal(calls.length, 1);
38
+ assert.equal(calls[0].args[0], "api");
39
+ assert.ok(calls[0].args[1].startsWith(`repos/o/r/commits/${SHA}/check-runs`));
40
+ assert.equal(calls[0].options.cwd, "/checkout");
41
+ });
42
+
43
+ test("ciNotGreen is null when the head is green, gh fails, the reply is not JSON, or origin is unknown", () => {
44
+ const origin = () => "o/r";
45
+ assert.equal(ciNotGreen(SHA, "/c", { gh: () => reply(run("a", "completed", "success")), origin }), null);
46
+ assert.equal(ciNotGreen(SHA, "/c", { gh: () => null, origin }), null);
47
+ assert.equal(ciNotGreen(SHA, "/c", { gh: () => "not json", origin }), null);
48
+ assert.equal(ciNotGreen(SHA, "/c", { gh: () => "{}", origin }), null);
49
+ assert.equal(ciNotGreen(SHA, "/c", { gh: () => reply(run("a", "completed", "failure")), origin: () => null }), null);
50
+ assert.equal(ciNotGreen(null, "/c", { gh: () => reply(run("a", "completed", "failure")), origin }), null);
51
+ });
52
+
53
+ test("ciNotGreen bounds its reads so the whole gate stays under the hook's 10 second limit", () => {
54
+ let ghOptions;
55
+ let originTimeout;
56
+ const gh = (_args, options) => ((ghOptions = options), null);
57
+ const origin = (_cwd, timeoutMs) => ((originTimeout = timeoutMs), "o/r");
58
+ assert.equal(ciNotGreen(SHA, "/c", { gh, origin }), null, "a gh that timed out leaves the head unknown, so the review refusal stands");
59
+ assert.ok(ghOptions.timeoutMs > 0 && ghOptions.timeoutMs <= 3000, `gh timeout ${ghOptions.timeoutMs}`);
60
+ assert.ok(originTimeout > 0 && originTimeout <= 1000, `origin timeout ${originTimeout}`);
61
+ assert.ok(ghOptions.timeoutMs + originTimeout < 5000);
62
+ });
@@ -11,9 +11,11 @@ export const REMINDER =
11
11
  "Dispatch architecture:sdd-planner to write a plan, architecture:sdd-implementer for one task, and " +
12
12
  "architecture:sdd-reviewer to review it; before merge, dispatch architecture:sdd-branch-reviewer to review the " +
13
13
  "whole branch. " +
14
- "Run one implementer at a time: a hook refuses a second while one runs. Name a model on any other dispatch, and " +
14
+ "Run one implementer at a time: a hook refuses a second. Name a model on any other dispatch, and " +
15
15
  "pass each brief as a file path. Name the worktree on a prompt line `Worktree: <path>`. A reviewer starts with " +
16
- "`VERDICT: <APPROVED|CHANGES_REQUIRED> <sha>`, and a merge passes `--match-head-commit <sha>`.";
16
+ "`VERDICT: <APPROVED|CHANGES_REQUIRED> <sha>`, and a merge passes `--match-head-commit <sha>`. " +
17
+ "Review a head only once CI on it is green: fix a CI failure first. After an APPROVED review, review each fix round " +
18
+ "once, by its increment: add `Reviewed: <sha>`.";
17
19
 
18
20
  const ROLES = ["sdd-planner", "sdd-implementer", "sdd-reviewer", "sdd-branch-reviewer"];
19
21
 
@@ -63,6 +63,17 @@ test("the note names the workflow, the four types, and the one-implementer rule,
63
63
  assert.ok(REMINDER.length < 800, `${REMINDER.length} characters`);
64
64
  });
65
65
 
66
+ test("the note says to review a green head only, to fix CI first, and to review a fix round by its increment", () => {
67
+ for (const phrase of [
68
+ /only once CI on it is green/,
69
+ /fix a CI failure first/,
70
+ /`Reviewed: <sha>`/,
71
+ /review each fix round once, by its increment/,
72
+ ]) {
73
+ assert.match(REMINDER, phrase);
74
+ }
75
+ });
76
+
66
77
  test("with swarm.explore also on, the note names its tools", (t) => {
67
78
  const [on] = checkouts(t, [
68
79
  { swarm: { dispatch: {}, explore: { tools: [{ name: "CocoIndex", use: "u", how: "h" }, { name: "GitNexus", use: "u", how: "h" }] } } },
@@ -6,6 +6,7 @@ import { spawnSync } from "node:child_process";
6
6
  export { keyOf as pathKey } from "./worktree.mjs";
7
7
 
8
8
  const GIT_TIMEOUT_MS = 10_000;
9
+ const ORIGIN_TIMEOUT_MS = 5_000;
9
10
 
10
11
  /** @returns git's trimmed stdout, or null on a non-zero exit or after `timeoutMs`. */
11
12
  export function gitOutWithin(timeoutMs, cwd, ...args) {
@@ -16,6 +17,18 @@ export function gitOutWithin(timeoutMs, cwd, ...args) {
16
17
  /** @returns git's trimmed stdout, or null on a non-zero exit or a timeout. */
17
18
  export const gitOut = (cwd, ...args) => gitOutWithin(GIT_TIMEOUT_MS, cwd, ...args);
18
19
 
20
+ /** `owner/repo` from a git remote URL in the https, ssh, or scp spelling, or from gh's `[HOST/]OWNER/REPO`; lower case. */
21
+ export function repoOfSpelling(spelled) {
22
+ const parts = String(spelled).trim().replace(/\/+$/, "").replace(/\.git$/i, "").split(/[/:]/).filter(Boolean);
23
+ return parts.length >= 2 ? parts.slice(-2).join("/").toLowerCase() : null;
24
+ }
25
+
26
+ /** The repository of the checkout's `origin` remote, or null when git cannot say or `timeoutMs` passes. */
27
+ export const originOf = (root, timeoutMs = ORIGIN_TIMEOUT_MS) => {
28
+ const url = gitOutWithin(timeoutMs, root, "remote", "get-url", "origin");
29
+ return url === null ? null : repoOfSpelling(url);
30
+ };
31
+
19
32
  /** @returns the full sha that `ref` names as a commit, or null when the repository holds none. */
20
33
  export const commitOf = (cwd, ref) => gitOut(cwd, "rev-parse", "--verify", "--quiet", `${ref}^{commit}`);
21
34
 
@@ -108,6 +108,8 @@ const short = (sha) => (typeof sha === "string" ? sha.slice(0, MIN_SHA) : "");
108
108
  const SUMMARIES = {
109
109
  dispatch: (r) =>
110
110
  `${r.agentType} ${r.task ? `${r.branch} ${short(r.head)}` : "(no task)"}${r.resumeReason ? ` NO-RESUME: ${r.resumeReason}` : ""}${
111
+ r.ciPass ? ` CI-PASS: ${short(r.ciPass.sha)} ${r.ciPass.reason}` : ""
112
+ }${
111
113
  r.handoff ? ` HANDOFF: ${r.handoff}` : ""
112
114
  }`,
113
115
  stop: (r) => `${r.role} ${r.agentType} ${r.agentId}${r.plan ? ` ${r.plan}` : ""}${r.handoff ? ` HANDOFF: ${r.handoff}` : ""}`,
@@ -8,6 +8,7 @@ import { fileURLToPath } from "node:url";
8
8
  import {
9
9
  appendRecord,
10
10
  commonDirOf,
11
+ formatRecord,
11
12
  lastTaskDispatchOn,
12
13
  latestVerdictFor,
13
14
  latestVerdictOn,
@@ -125,3 +126,16 @@ test("an append after a torn last line keeps the new record whole", (t) => {
125
126
  appendRecord(file, { type: "stop", role: "task" });
126
127
  assert.equal(readLedger(file).length, 3, "a file that ends in a newline gets no blank line");
127
128
  });
129
+
130
+ test("a dispatch that passed on a CI failure shows the sha and the reason in the ledger line", () => {
131
+ const line = formatRecord({
132
+ at: "t",
133
+ type: "dispatch",
134
+ agentType: "sdd-implementer",
135
+ task: true,
136
+ branch: "feat/1-x",
137
+ head: "abcdef1234",
138
+ ciPass: { sha: "1234567890abcdef", reason: "CI on 1234567: build ended failure" },
139
+ });
140
+ assert.match(line, /CI-PASS: 1234567 CI on 1234567: build ended failure/);
141
+ });
@@ -5,12 +5,12 @@
5
5
  // A merge that names another repository than the checkout's `origin` is that repository's own, so it passes.
6
6
  // With `swarm.dispatch` off, the record is still written for the worktree check of QC-015, and nothing is judged.
7
7
 
8
- import { spawnSync } from "node:child_process";
9
8
  import { fileURLToPath } from "node:url";
10
9
  import { PARSERS } from "./bash-command-guard.mjs";
11
10
  import { LANE_BUDGET_MS, mergeLane, sizeLine } from "./direct-lane.mjs";
12
11
  import { ghApiMerges, ghMerges } from "./gh-merge-command.mjs";
13
12
  import { runGh } from "./gh-run.mjs";
13
+ import { originOf, repoOfSpelling } from "./git-read.mjs";
14
14
  import { appendRecord, latestVerdictFor, readLedger } from "./ledger.mjs";
15
15
  import { workflowAt } from "./workflow-settings.mjs";
16
16
  import { worktreeRuleAt } from "./worktree-settings.mjs";
@@ -19,7 +19,6 @@ const VIEW_FIELDS = "number,url,state,mergedAt,baseRefName,headRefName,body,clos
19
19
  const MAYBE_GH = /\bgh(?:\.exe)?\b/i;
20
20
  const BODY_REF = /(?<![\w/#])#(\d+)\b/g;
21
21
  const REF_LINE = /^\s*(?:[-*]\s+)?(?:refs|closes|fixes|resolves)\b/i;
22
- const ORIGIN_TIMEOUT_MS = 5_000;
23
22
  const PR_URL = /^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/pull\/\d+/;
24
23
  const POST_EVENTS = new Set(["PostToolUse", "PostToolUseFailure"]);
25
24
  const REVIEWER = { branch: "the branch reviewer (sdd-branch-reviewer)", task: "the task reviewer (sdd-reviewer)" };
@@ -112,18 +111,6 @@ export function namedIssues(pr, repo) {
112
111
  return [...found.values()];
113
112
  }
114
113
 
115
- /** `owner/repo` from a git remote URL in the https, ssh, or scp spelling, or from gh's `[HOST/]OWNER/REPO`; lower case. */
116
- function repoOfSpelling(spelled) {
117
- const parts = String(spelled).trim().replace(/\/+$/, "").replace(/\.git$/i, "").split(/[/:]/).filter(Boolean);
118
- return parts.length >= 2 ? parts.slice(-2).join("/").toLowerCase() : null;
119
- }
120
-
121
- /** The repository of the checkout's `origin` remote, or null when git cannot say. */
122
- function originOf(root) {
123
- const result = spawnSync("git", ["remote", "get-url", "origin"], { cwd: root, encoding: "utf8", windowsHide: true, timeout: ORIGIN_TIMEOUT_MS });
124
- return result.status === 0 ? repoOfSpelling(result.stdout) : null;
125
- }
126
-
127
114
  /** Splits the merges into those of this checkout's repository and those that name another repository. */
128
115
  function partition(merges, root) {
129
116
  const origin = merges.some((merge) => merge.repo) ? originOf(root) : null;
@@ -155,3 +155,14 @@ test("no type pins a prompt cache lifetime, so a user's own setting decides it",
155
155
  assert.equal(front.cacheTtl, undefined, `${name} sets cacheTtl`);
156
156
  }
157
157
  });
158
+
159
+ test("both reviewers review only the increment when the dispatch carries a Reviewed line, and still put the verdict first", () => {
160
+ for (const name of ["sdd-reviewer", "sdd-branch-reviewer"]) {
161
+ const text = readFileSync(path.join(AGENTS, `${name}.md`), "utf8").replace(/\r/g, "");
162
+ assert.match(text, /`Reviewed: <sha>`/, name);
163
+ assert.match(text, /<sha>\.\.<head>/, name);
164
+ assert.match(text, /only that increment|only the increment/i, name);
165
+ assert.match(text, /Without the line, review as before/, name);
166
+ assert.ok(text.indexOf("`Reviewed: <sha>`") < text.indexOf("`VERDICT: APPROVED <sha>`"), `${name} keeps the verdict line rule last`);
167
+ }
168
+ });
@@ -49,4 +49,5 @@ test("the checkout directories are each location change and each git -C director
49
49
  ["C:\\repo\\a", "C:\\b c", "..\\d", "C:\\e"],
50
50
  );
51
51
  assert.deepEqual(checkoutDirs("Get-ChildItem"), []);
52
+ assert.deepEqual(checkoutDirs("Set-Content f x; git -C"), []);
52
53
  });
@@ -233,21 +233,29 @@ export const commandEnv = (segment) => unwrap(segment.words).env;
233
233
  const isGit = (word) => /(^|[\\/])git(\.exe)?$/i.test(word ?? "");
234
234
 
235
235
  /**
236
- * @returns the git subcommand, each `-C` directory, each `-c` setting and the words after the
237
- * subcommand, or null when the segment is no git call.
236
+ * @returns the git subcommand, each `-C` directory, each `-c` setting and the words after the subcommand, or null
237
+ * when the segment is no git call. `explicitDir` is true when the call names a git directory or a work tree, through
238
+ * `--git-dir`, `--work-tree`, `GIT_DIR` or `GIT_WORK_TREE`. It is never resolved: git reads a relative one from the
239
+ * working directory after every `-C`, so no later reader can know which repository it picks.
238
240
  */
239
241
  export function gitCall(segment) {
240
242
  const [program, ...words] = commandWords(segment);
241
243
  if (!isGit(program)) return null;
244
+ const { GIT_DIR, GIT_WORK_TREE } = commandEnv(segment);
245
+ let explicitDir = Boolean(GIT_DIR || GIT_WORK_TREE);
242
246
  const dirs = [];
243
247
  const configs = [];
244
248
  for (let i = 0; i < words.length; i++) {
245
249
  const word = words[i];
246
250
  if (word === "-C") dirs.push(words[++i]);
251
+ else if (word === "--git-dir" || word === "--work-tree") {
252
+ explicitDir = true;
253
+ i++;
254
+ } else if (/^--(git-dir|work-tree)=/.test(word)) explicitDir = true;
247
255
  else if (word === "-c") configs.push(words[++i]);
248
- else if (!word.startsWith("-")) return { sub: word, dirs, configs, args: words.slice(i + 1) };
256
+ else if (!word.startsWith("-")) return { sub: word, dirs, explicitDir, configs, args: words.slice(i + 1) };
249
257
  }
250
- return { sub: null, dirs, configs, args: [] };
258
+ return { sub: null, dirs, explicitDir, configs, args: [] };
251
259
  }
252
260
 
253
261
  /** @returns the directory a `cd` or `pushd` segment moves to, or null. */
@@ -32,9 +32,28 @@ test("a redirect target is recorded apart from the words, and a descriptor copy
32
32
  assert.deepEqual(segmentsOf("cat log >> all.log")[0].redirects, ["all.log"]);
33
33
  });
34
34
 
35
+ test("a git call flags an explicit git dir or work tree, and does not resolve it", () => {
36
+ const explicitOf = (command) => gitCall(segmentsOf(command)[0]).explicitDir;
37
+ for (const command of [
38
+ "git --git-dir=/r/.git status",
39
+ "git --git-dir /r/.git status",
40
+ "GIT_DIR=/r/.git git status",
41
+ "env GIT_DIR=/r/.git git status",
42
+ "git -C /a --git-dir=/r/.git status",
43
+ "git --work-tree=/r status",
44
+ "git --work-tree /r status",
45
+ "GIT_WORK_TREE=/r git status",
46
+ ]) {
47
+ assert.equal(explicitOf(command), true, command);
48
+ }
49
+ for (const command of ["git status", "git -C /a status", "git -c core.x=y status"]) assert.equal(explicitOf(command), false, command);
50
+ assert.deepEqual(gitCall(segmentsOf("git -C /a --git-dir /r/.git status")[0]).dirs, ["/a"], "the git dir is no checkout directory");
51
+ assert.equal(gitCall(segmentsOf("git --git-dir /r/.git status")[0]).sub, "status", "the value is not the subcommand");
52
+ });
53
+
35
54
  test("a git call names its subcommand and every -C directory", () => {
36
55
  const [segment] = segmentsOf(`GIT_PAGER=cat git -C "C:/a b" -c core.x=y --no-pager commit -m x`);
37
- assert.deepEqual(gitCall(segment), { sub: "commit", dirs: ["C:/a b"], configs: ["core.x=y"], args: ["-m", "x"] });
56
+ assert.deepEqual(gitCall(segment), { sub: "commit", dirs: ["C:/a b"], explicitDir: false, configs: ["core.x=y"], args: ["-m", "x"] });
38
57
  assert.equal(gitCall(segmentsOf("gitk --all")[0]), null);
39
58
  });
40
59
 
@@ -92,6 +111,7 @@ test("the checkout directories are every cd target and every git -C directory, i
92
111
  "/repo/d",
93
112
  ]);
94
113
  assert.deepEqual(checkoutDirs("ls"), []);
114
+ assert.deepEqual(checkoutDirs("echo x > f; git -C"), []);
95
115
  });
96
116
 
97
117
  test("a git call carries each -c setting and the words after its subcommand", () => {
@@ -99,10 +119,11 @@ test("a git call carries each -c setting and the words after its subcommand", ()
99
119
  assert.deepEqual(gitCall(segment), {
100
120
  sub: "commit",
101
121
  dirs: ["repo"],
122
+ explicitDir: false,
102
123
  configs: ["core.hooksPath=/dev/null"],
103
124
  args: ["-m", "a b", "--no-verify"],
104
125
  });
105
- assert.deepEqual(gitCall(segmentsOf("git --version")[0]), { sub: null, dirs: [], configs: [], args: [] });
126
+ assert.deepEqual(gitCall(segmentsOf("git --version")[0]), { sub: null, dirs: [], explicitDir: false, configs: [], args: [] });
106
127
  });
107
128
 
108
129
  test("the PowerShell escape keeps a backslash literal and escapes with a backtick", () => {
@@ -4,6 +4,7 @@
4
4
  import os from "node:os";
5
5
  import path from "node:path";
6
6
  import { checkoutRootOf } from "./checkout-root.mjs";
7
+ import { ciNotGreen } from "./ci-state.mjs";
7
8
  import { typeOf } from "./dispatch.mjs";
8
9
  import { handoffPathOf, resolveHandoff } from "./handoff-note.mjs";
9
10
  import { branchAt, gitOut, linkedWorktrees, pathKey } from "./git-read.mjs";
@@ -27,6 +28,7 @@ const fixRoundRefusal = (branch, sha, type) =>
27
28
  const unreviewedRefusal = (branch, stopHead, head) =>
28
29
  `Task gate: an implementer stopped on ${branch} at ${short(stopHead)}, and no review in the ledger names ${short(stopHead)} or a later commit. ` +
29
30
  `Dispatch the task reviewer on ${short(head)} first; its first line \`VERDICT: <APPROVED|CHANGES_REQUIRED> <sha>\` records the review. ` +
31
+ `The review runs once CI on the head is green: when CI on ${short(stopHead)} has failed or still runs, the next implementer continues the task and this gate passes it. ` +
30
32
  `If that stop handed off, its report named \`HANDOFF: <note path>\`; the same line in the next implementer prompt continues the task. ` +
31
33
  `\`qc ledger ${branch}\` lists what is recorded.`;
32
34
 
@@ -72,22 +74,32 @@ export function continuedStop(records, branch, handoff) {
72
74
  }
73
75
 
74
76
  /**
75
- * @returns the reason an implementer may not start on `branch` now, or null. Only implementer commits need a
76
- * review, so a controller commit after a reviewed head passes. `cwd` is any checkout; `git` reads it.
77
+ * The task gate's answer for an implementer on `branch`: `refusal` is the reason it may not start now, or null.
78
+ * `ciPass` is `{ sha, reason }` when an unreviewed stop head passes because CI on it is not green, else absent.
79
+ * Only implementer commits need a review, so a controller commit after a reviewed head passes. `cwd` is any
80
+ * checkout; `git` reads it, and `ci` answers why CI on a sha is not green, or null.
77
81
  */
78
- export function gateRefusal({ records, branch, head, reason, type, cwd, git = gitOut, handoff = null }) {
82
+ export function gateVerdict({ records, branch, head, reason, type, cwd, git = gitOut, handoff = null, ci = (sha) => ciNotGreen(sha, cwd) }) {
79
83
  // A continuation of the newest stop's hand-off is the same task, so it is neither a fix round nor a new task.
80
84
  const continued = continuedStop(records, branch, handoff);
81
85
  const why = reason ?? (continued ? `continues the hand-off ${continued.handoff}` : null);
82
86
  const last = latestVerdictOn(records, branch);
83
- if (last?.verdict === "CHANGES_REQUIRED" && why === null) return fixRoundRefusal(branch, last.sha, type);
87
+ if (last?.verdict === "CHANGES_REQUIRED" && why === null) return { refusal: fixRoundRefusal(branch, last.sha, type) };
84
88
  const unreviewed = unreviewedImplementerStop({ records, branch, head, cwd, git });
85
- if (unreviewed && unreviewed !== continued) return unreviewedRefusal(branch, unreviewed.head, head);
89
+ if (unreviewed && unreviewed !== continued) {
90
+ // A head that CI failed changes before a review, so a review now would be spent on a commit that is replaced.
91
+ const notGreen = ci(unreviewed.head);
92
+ if (notGreen === null) return { refusal: unreviewedRefusal(branch, unreviewed.head, head) };
93
+ return { refusal: null, ciPass: { sha: unreviewed.head, reason: notGreen } };
94
+ }
86
95
  const current = latestVerdictFor(records, head, ["task", "branch"]);
87
- if (current?.verdict === "CHANGES_REQUIRED" && why === null) return fixRoundRefusal(branch, current.sha, type);
88
- return null;
96
+ if (current?.verdict === "CHANGES_REQUIRED" && why === null) return { refusal: fixRoundRefusal(branch, current.sha, type) };
97
+ return { refusal: null };
89
98
  }
90
99
 
100
+ /** @returns the reason an implementer may not start on `branch` now, or null. `gateVerdict` has the inputs. */
101
+ export const gateRefusal = (input) => gateVerdict(input).refusal;
102
+
91
103
  const pass = (workflow, record, note = null) => ({ refusal: null, workflow, record, note });
92
104
  const refuse = (refusal) => ({ refusal, workflow: null, record: null, note: null });
93
105
 
@@ -97,9 +109,10 @@ const taskTypeIn = (type, review) =>
97
109
  /**
98
110
  * Judges one main-session Agent call. The repository of the worktree the prompt names decides, and the
99
111
  * repository of the cwd decides only when the prompt names none.
112
+ * `ci` replaces the CI read of the task gate, for a test.
100
113
  * @returns the refusal, or the record to write once the dispatch runs.
101
114
  */
102
- export function judgeTask(call, tmp = os.tmpdir()) {
115
+ export function judgeTask(call, tmp = os.tmpdir(), { ci } = {}) {
103
116
  const cwd = call.cwd ?? process.cwd();
104
117
  let own;
105
118
  try {
@@ -161,10 +174,11 @@ export function judgeTask(call, tmp = os.tmpdir()) {
161
174
  const reason = noResumeReason(prompt);
162
175
  const spelled = handoffPathOf(prompt);
163
176
  const handoff = spelled === null ? null : resolveHandoff(spelled, cwd);
164
- const refusal = gateRefusal({ records, branch: worktree.branch, head: worktree.head, reason, type, cwd: workflow.root, handoff });
177
+ const { refusal, ciPass } = gateVerdict({ records, branch: worktree.branch, head: worktree.head, reason, type, cwd: workflow.root, handoff, ...(ci ? { ci } : {}) });
165
178
  if (refusal) return refuse(refusal);
166
179
  const continues = handoff ? { handoff } : {};
167
- return pass(workflow, { ...base, task: true, worktree: worktree.path, branch: worktree.branch, head: worktree.head, resumeReason: reason, ...continues });
180
+ const unreviewed = ciPass ? { ciPass } : {};
181
+ return pass(workflow, { ...base, task: true, worktree: worktree.path, branch: worktree.branch, head: worktree.head, resumeReason: reason, ...continues, ...unreviewed });
168
182
  }
169
183
 
170
184
  /** Writes the dispatch record of a judged call. @returns a note for the session, or null. */
@@ -7,7 +7,7 @@ import { test } from "node:test";
7
7
  import { decide as dispatchDecide } from "./dispatch-guard.mjs";
8
8
  import { appendRecord, readLedger } from "./ledger.mjs";
9
9
  import { gitOut } from "./git-read.mjs";
10
- import { continuedStop, gateRefusal, judgeTask, noResumeReason, recordDispatch, worktreeNamed } from "./task-gate.mjs";
10
+ import { continuedStop, gateRefusal, gateVerdict, judgeTask, noResumeReason, recordDispatch, worktreeNamed } from "./task-gate.mjs";
11
11
  import { sessionDirOf } from "./workflow-settings.mjs";
12
12
 
13
13
  // The guard processes below run under Codex, whatever runtime runs the test.
@@ -508,3 +508,61 @@ test("a later verdict on the branch ends the continuation, whatever commit it na
508
508
  assert.equal(continuedStop(readLedger(ws.ledger), "feat/1-x", note), null);
509
509
  assert.match(refusalOf(ws, `HANDOFF: ${note}`) ?? "", /CHANGES_REQUIRED/);
510
510
  });
511
+
512
+ test("a stop head with CI that is not green lets the next implementer continue, and the dispatch record holds the reason", (t) => {
513
+ const ws = workspace(t);
514
+ recordDispatch(judgeTask(dispatch(ws.main, taskPrompt(ws.linked)), ws.tmp));
515
+ const moved = commitIn(ws.linked, "b.txt");
516
+ implementerStop(ws, moved);
517
+ const asked = [];
518
+ const ci = (sha) => {
519
+ asked.push(sha);
520
+ return `CI on ${sha.slice(0, 7)}: build ended failure`;
521
+ };
522
+ const task = judgeTask(dispatch(ws.main, taskPrompt(ws.linked)), ws.tmp, { ci });
523
+ assert.equal(task.refusal, null);
524
+ assert.deepEqual(asked, [moved]);
525
+ assert.deepEqual(task.record.ciPass, { sha: moved, reason: `CI on ${moved.slice(0, 7)}: build ended failure` });
526
+ recordDispatch(task);
527
+ const [, written] = readLedger(ws.ledger).filter((record) => record.type === "dispatch");
528
+ assert.deepEqual(written.ciPass, task.record.ciPass);
529
+ });
530
+
531
+ test("a stop head with green or unknown CI keeps the refusal, and the refusal says the review waits for green CI", (t) => {
532
+ const ws = workspace(t);
533
+ implementerStop(ws, commitIn(ws.linked, "b.txt"));
534
+ const refusal = judgeTask(dispatch(ws.main, taskPrompt(ws.linked)), ws.tmp, { ci: () => null }).refusal;
535
+ assert.match(refusal ?? "", /no review in the ledger/);
536
+ assert.match(refusal ?? "", /once CI on the head is green/);
537
+ });
538
+
539
+ test("the CI pass does not skip a review that is already on record", (t) => {
540
+ const ws = workspace(t);
541
+ const moved = commitIn(ws.linked, "b.txt");
542
+ implementerStop(ws, moved);
543
+ verdict(ws, moved);
544
+ let asked = 0;
545
+ const task = judgeTask(dispatch(ws.main, taskPrompt(ws.linked)), ws.tmp, { ci: () => (asked += 1, "red") });
546
+ assert.equal(task.refusal, null);
547
+ assert.equal(asked, 0);
548
+ assert.equal(task.record.ciPass, undefined);
549
+ });
550
+
551
+ test("a CI pass does not lift a CHANGES_REQUIRED fix round", (t) => {
552
+ const ws = workspace(t);
553
+ const moved = commitIn(ws.linked, "b.txt");
554
+ implementerStop(ws, moved);
555
+ verdict(ws, moved, "CHANGES_REQUIRED");
556
+ assert.match(judgeTask(dispatch(ws.main, taskPrompt(ws.linked)), ws.tmp, { ci: () => "red" }).refusal ?? "", /CHANGES_REQUIRED/);
557
+ });
558
+
559
+ test("gateVerdict reports the stop and the reason of a CI pass, and gateRefusal still answers with the refusal alone", (t) => {
560
+ const ws = workspace(t);
561
+ const moved = commitIn(ws.linked, "b.txt");
562
+ implementerStop(ws, moved);
563
+ const input = { records: readLedger(ws.ledger), branch: "feat/1-x", head: moved, reason: null, type: "sdd-implementer", cwd: ws.linked };
564
+ assert.deepEqual(gateVerdict({ ...input, ci: () => "red" }), { refusal: null, ciPass: { sha: moved, reason: "red" } });
565
+ assert.match(gateVerdict({ ...input, ci: () => null }).refusal ?? "", /no review/);
566
+ assert.match(gateRefusal({ ...input, ci: () => null }) ?? "", /no review/);
567
+ assert.equal(gateRefusal({ ...input, ci: () => "red" }), null);
568
+ });
@@ -65,7 +65,7 @@ recorded.
65
65
  |---|---|
66
66
  | A review states its verdict and the sha it reviewed on its first line | `report-stop.mjs`, on `SubagentHandback` and `SubagentStop` |
67
67
  | An implementer reports the failing test before the passing one | `report-stop.mjs` |
68
- | A task is reviewed before the next implementer starts on its branch | `dispatch-guard.mjs`, through `task-gate.mjs` |
68
+ | A task is reviewed before the next implementer starts on its branch, unless CI on the stop head is not green: the review runs once CI is green | `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
70
  | A merge pins the head that an APPROVED review named, or a head inside the direct lane, whose limits come from the commit the PR merges into | `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` |