@feigi/fleet-ctl 0.0.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/.claude-plugin/plugin.json +9 -0
- package/LICENSE +202 -0
- package/NOTICE +18 -0
- package/agents/fleet-finisher.agent.md +7 -0
- package/agents/fleet-implementer-alt.agent.md +210 -0
- package/agents/fleet-implementer.agent.md +210 -0
- package/agents/fleet-merge-bot.agent.md +7 -0
- package/agents/fleet-review-comments.agent.md +40 -0
- package/agents/fleet-review-correctness.agent.md +43 -0
- package/agents/fleet-review-runner.agent.md +73 -0
- package/agents/fleet-review-silent-failure.agent.md +49 -0
- package/agents/fleet-review-simplify.agent.md +46 -0
- package/agents/fleet-review-snapshot.agent.md +24 -0
- package/agents/fleet-review-tests.agent.md +46 -0
- package/agents/fleet-review-types.agent.md +41 -0
- package/agents/fleet-review-verifier.agent.md +29 -0
- package/commands/review-and-fix.md +98 -0
- package/commands/run-merge-bot.md +357 -0
- package/commands/run-team-help.md +17 -0
- package/package.json +23 -0
- package/scripts/agent-test-dir-prose.test.mjs +59 -0
- package/scripts/agent-test.test.mjs +1636 -0
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +354 -0
- package/scripts/ambient-git-vars-prose.test.mjs +192 -0
- package/scripts/ancestry-check-position-prose.test.mjs +175 -0
- package/scripts/apply-ruleset.test.mjs +420 -0
- package/scripts/arg-header-probes-prose.test.mjs +393 -0
- package/scripts/arg.mjs +600 -0
- package/scripts/arg.test.mjs +1354 -0
- package/scripts/board-cli.test.mjs +694 -0
- package/scripts/board-identity.test.mjs +429 -0
- package/scripts/board-liveness-banner.test.mjs +119 -0
- package/scripts/board-prev-shape.test.mjs +229 -0
- package/scripts/board-tryparse-null.test.mjs +119 -0
- package/scripts/board.html +471 -0
- package/scripts/board.mjs +2037 -0
- package/scripts/board.test.mjs +3086 -0
- package/scripts/brief-after-cut-prose.test.mjs +53 -0
- package/scripts/candidates-exit3-prose.test.mjs +302 -0
- package/scripts/candidates.mjs +674 -0
- package/scripts/candidates.test.mjs +2101 -0
- package/scripts/caveat-unification-prose.test.mjs +98 -0
- package/scripts/ci-comment-rot-prose.test.mjs +2025 -0
- package/scripts/ci-completes-premise-prose.test.mjs +257 -0
- package/scripts/ci-state-prose.test.mjs +113 -0
- package/scripts/ci-state.mjs +761 -0
- package/scripts/ci-state.test.mjs +1640 -0
- package/scripts/ci-vacuous-green.test.mjs +368 -0
- package/scripts/citation-sweep-prose.test.mjs +1572 -0
- package/scripts/claim-lifecycle.test.mjs +185 -0
- package/scripts/claim-ticket.sh +417 -0
- package/scripts/claim-ticket.test.mjs +1121 -0
- package/scripts/closing-keyword-prose.test.mjs +193 -0
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +165 -0
- package/scripts/cockpit-tick-nonblocking.test.mjs +210 -0
- package/scripts/compute-board.mjs +579 -0
- package/scripts/compute-board.test.mjs +1060 -0
- package/scripts/compute-spend.mjs +329 -0
- package/scripts/compute-spend.test.mjs +451 -0
- package/scripts/cross-repo-citation-prose.test.mjs +156 -0
- package/scripts/cwd-isolation-pins.mjs +83 -0
- package/scripts/dedupe-guard-prose.test.mjs +243 -0
- package/scripts/derive-testcmd.sh +239 -0
- package/scripts/derive-testcmd.test.mjs +380 -0
- package/scripts/diff-stats.mjs +231 -0
- package/scripts/diff-stats.test.mjs +408 -0
- package/scripts/dispatch-block-golden-prose.test.mjs +1024 -0
- package/scripts/dispatch-block-pins-prose.test.mjs +615 -0
- package/scripts/drop-merged-label.sh +173 -0
- package/scripts/drop-merged-label.test.mjs +480 -0
- package/scripts/expected-jobs-prose.test.mjs +80 -0
- package/scripts/filing-bar-seat-prose.test.mjs +242 -0
- package/scripts/filing-claim-bar-prose.test.mjs +166 -0
- package/scripts/finisher-dispatch-premise-prose.test.mjs +312 -0
- package/scripts/finisher-halt-prose.test.mjs +106 -0
- package/scripts/finisher-name-prose.test.mjs +134 -0
- package/scripts/finisher-own-tree-prose.test.mjs +285 -0
- package/scripts/finisher-pin-race-prose.test.mjs +339 -0
- package/scripts/fix-applier-correction-rules-prose.test.mjs +201 -0
- package/scripts/fix-applier-result-file-prose.test.mjs +100 -0
- package/scripts/fleet-bootstrap +155 -0
- package/scripts/fleet-heartbeat.mjs +272 -0
- package/scripts/fleet-heartbeat.test.mjs +450 -0
- package/scripts/fleet-provenance +207 -0
- package/scripts/fleet-provenance.test.mjs +64 -0
- package/scripts/fleet-run +148 -0
- package/scripts/fleet-run.test.mjs +90 -0
- package/scripts/fleet-state.mjs +400 -0
- package/scripts/fleet-state.test.mjs +373 -0
- package/scripts/fleet-tick-prose.test.mjs +299 -0
- package/scripts/fleet-tick.mjs +832 -0
- package/scripts/fleet-tick.test.mjs +1332 -0
- package/scripts/force-with-lease-reason-prose.test.mjs +184 -0
- package/scripts/frontmatter-allowlist.json +64 -0
- package/scripts/frontmatter-check.mjs +256 -0
- package/scripts/frontmatter-check.test.mjs +436 -0
- package/scripts/git-env.mjs +124 -0
- package/scripts/git-env.test.mjs +149 -0
- package/scripts/git-status-untracked-mode-sweep.test.mjs +216 -0
- package/scripts/gone-walk.test.mjs +213 -0
- package/scripts/gp-sep-invariant-prose.test.mjs +188 -0
- package/scripts/head-moved-after-label-prose.test.mjs +233 -0
- package/scripts/immutable-body-claim-prose.test.mjs +413 -0
- package/scripts/implementer-model-tier.test.mjs +643 -0
- package/scripts/inflight-citation-prose.test.mjs +144 -0
- package/scripts/inflight-exit2-prose.test.mjs +81 -0
- package/scripts/inflight-probe-guard-prose.test.mjs +109 -0
- package/scripts/inflight-scan-scope-prose.test.mjs +57 -0
- package/scripts/inflight.sh +1106 -0
- package/scripts/inflight.test.mjs +2984 -0
- package/scripts/injection-control-prose.test.mjs +404 -0
- package/scripts/install-root-audit.test.mjs +464 -0
- package/scripts/instrument-check-prose.test.mjs +235 -0
- package/scripts/instruments.sh +394 -0
- package/scripts/instruments.test.mjs +787 -0
- package/scripts/issue-tracker-prose.test.mjs +71 -0
- package/scripts/json.sh +248 -0
- package/scripts/json.test.mjs +364 -0
- package/scripts/ledger-dispatch.test.mjs +516 -0
- package/scripts/ledger-grammar.mjs +85 -0
- package/scripts/ledger-grammar.test.mjs +142 -0
- package/scripts/ledger-read-require-file.test.mjs +197 -0
- package/scripts/ledger.mjs +1753 -0
- package/scripts/ledger.test.mjs +3554 -0
- package/scripts/line-distance-prose.test.mjs +245 -0
- package/scripts/liveness-rationale-prose.test.mjs +83 -0
- package/scripts/locale-pin-prose.test.mjs +189 -0
- package/scripts/member-outcome-prose.test.mjs +167 -0
- package/scripts/member-outcomes-header.test.mjs +148 -0
- package/scripts/member-outcomes-prose.test.mjs +63 -0
- package/scripts/member-outcomes.mjs +231 -0
- package/scripts/member-outcomes.test.mjs +507 -0
- package/scripts/member-prompt-prose.test.mjs +161 -0
- package/scripts/member-record.mjs +605 -0
- package/scripts/member-record.test.mjs +516 -0
- package/scripts/member-write-guard.mjs +279 -0
- package/scripts/member-write-guard.test.mjs +211 -0
- package/scripts/merge-commit-probe-prose.test.mjs +122 -0
- package/scripts/merge-gate.mjs +262 -0
- package/scripts/merge-gate.test.mjs +613 -0
- package/scripts/muted-git-guard-sweep.test.mjs +493 -0
- package/scripts/net-ssh-precedence-prose.test.mjs +91 -0
- package/scripts/net-watchdog-prose.test.mjs +79 -0
- package/scripts/net.sh +409 -0
- package/scripts/net.test.mjs +211 -0
- package/scripts/no-ci-gate-prose.test.mjs +108 -0
- package/scripts/no-undo-audit.sh +1134 -0
- package/scripts/no-undo-audit.test.mjs +3965 -0
- package/scripts/no-wave.test.mjs +138 -0
- package/scripts/node-floor-sweep.test.mjs +611 -0
- package/scripts/pointer-target-prose.test.mjs +186 -0
- package/scripts/pr-overlap.mjs +417 -0
- package/scripts/pr-overlap.test.mjs +695 -0
- package/scripts/printf-die-sweep.test.mjs +384 -0
- package/scripts/prompt-renderer.mjs +39 -0
- package/scripts/prompt-renderer.test.mjs +68 -0
- package/scripts/prose-pin.mjs +808 -0
- package/scripts/prose-pin.test.mjs +1034 -0
- package/scripts/prove-merge.sh +228 -0
- package/scripts/prove-merge.test.mjs +995 -0
- package/scripts/pull-table-relabel-prose.test.mjs +60 -0
- package/scripts/quiet-payload-prose.test.mjs +222 -0
- package/scripts/reap.sh +1768 -0
- package/scripts/reap.test.mjs +4395 -0
- package/scripts/reaping-prose.test.mjs +159 -0
- package/scripts/refuter-scratch-prose.test.mjs +135 -0
- package/scripts/release-label-required-prose.test.mjs +71 -0
- package/scripts/release-label-split-prose.test.mjs +169 -0
- package/scripts/release-ticket.sh +1716 -0
- package/scripts/release-ticket.test.mjs +5106 -0
- package/scripts/renovate-release-contract.test.mjs +379 -0
- package/scripts/repo-root.mjs +544 -0
- package/scripts/repo-root.test.mjs +873 -0
- package/scripts/reporter-output-rule-prose.test.mjs +208 -0
- package/scripts/review-agent-report-only.test.mjs +49 -0
- package/scripts/review-core-cwd-isolation.test.mjs +374 -0
- package/scripts/review-core-reads.test.mjs +478 -0
- package/scripts/review-core-refuter-scratch.test.mjs +148 -0
- package/scripts/review-core-snapshot-path.test.mjs +777 -0
- package/scripts/review-core-specialist-scratch.test.mjs +189 -0
- package/scripts/review-core-testcmd.test.mjs +288 -0
- package/scripts/review-core-unrun.test.mjs +530 -0
- package/scripts/review-core-unverified-discriminant.test.mjs +208 -0
- package/scripts/review-core.mjs +1028 -0
- package/scripts/review-eval-resolver-path.test.mjs +55 -0
- package/scripts/review-eval.mjs +197 -0
- package/scripts/review-host-fixture.mjs +73 -0
- package/scripts/review-in-run-retry.test.mjs +187 -0
- package/scripts/review-no-vendor-dispatch.test.mjs +45 -0
- package/scripts/review-path-default.test.mjs +796 -0
- package/scripts/review-runner-spawns.test.mjs +93 -0
- package/scripts/review-runner.test.mjs +155 -0
- package/scripts/review-tier-audit.test.mjs +140 -0
- package/scripts/run-artifact-pr-prose.test.mjs +341 -0
- package/scripts/run-merge-bot-prose.test.mjs +1391 -0
- package/scripts/scratch-partition-invariant-prose.test.mjs +74 -0
- package/scripts/scripts-path-citation-sweep.test.mjs +73 -0
- package/scripts/section-between-guard-prose.test.mjs +378 -0
- package/scripts/select-dimensions.test.mjs +674 -0
- package/scripts/shared-refusal.test.mjs +388 -0
- package/scripts/shell-traps-prose.test.mjs +507 -0
- package/scripts/shortlist.mjs +355 -0
- package/scripts/shortlist.test.mjs +366 -0
- package/scripts/slow-transport.mjs +72 -0
- package/scripts/snapshot-repo.test.mjs +772 -0
- package/scripts/snapshot-runner-audience-prose.test.mjs +129 -0
- package/scripts/spend-view.test.mjs +312 -0
- package/scripts/staleness-qualifier-prose.test.mjs +251 -0
- package/scripts/staleness-verdict-prose.test.mjs +142 -0
- package/scripts/staleness.mjs +414 -0
- package/scripts/staleness.test.mjs +893 -0
- package/scripts/stalled-member-liveness-prose.test.mjs +219 -0
- package/scripts/stash-prohibition-prose.test.mjs +313 -0
- package/scripts/strip-comments.mjs +44 -0
- package/scripts/tier-check.mjs +468 -0
- package/scripts/tier-check.test.mjs +726 -0
- package/scripts/tier-guard-gate-prose.test.mjs +216 -0
- package/scripts/tier-outcomes-header.test.mjs +586 -0
- package/scripts/tier-outcomes.mjs +441 -0
- package/scripts/tier-outcomes.test.mjs +342 -0
- package/scripts/tier-roles.mjs +250 -0
- package/scripts/tier-roles.test.mjs +316 -0
- package/scripts/tracker-block-copy-prose.test.mjs +288 -0
- package/scripts/triage-labels-gloss-prose.test.mjs +97 -0
- package/scripts/unattended-git-sweep.test.mjs +142 -0
- package/scripts/verify-sha-exit2-prose.test.mjs +269 -0
- package/scripts/verify-sha.sh +117 -0
- package/scripts/verify-sha.test.mjs +693 -0
- package/scripts/watcher-degraded-block.test.mjs +372 -0
- package/scripts/watcher-key-prose.test.mjs +106 -0
- package/scripts/within-run-pair-prose.test.mjs +208 -0
- package/scripts/worktree-audit.sh +482 -0
- package/scripts/worktree-audit.test.mjs +1407 -0
- package/scripts/worktree-head-prose.test.mjs +276 -0
- package/scripts/worktree-listing-sweep.test.mjs +217 -0
- package/scripts/worktree-model-prose.test.mjs +216 -0
- package/scripts/worktree.sh +470 -0
- package/skills/next-ticket/SKILL.md +138 -0
- package/skills/run-team/SKILL.md +3603 -0
- package/skills/run-team/references/ci-and-staleness.md +75 -0
- package/skills/run-team/references/correction-tickets.md +37 -0
- package/skills/run-team/references/isolation.md +23 -0
- package/skills/run-team/references/member-lifecycle.md +73 -0
- package/skills/run-team/references/reaping.md +73 -0
- package/skills/sizing-a-ticket/SKILL.md +39 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { sentences } from "./prose-pin.mjs";
|
|
6
|
+
|
|
7
|
+
// #389. The runbook calls the finisher an auditor, but its gate MUTATES: the
|
|
8
|
+
// controller has it independently re-run the ticket's acceptance mutation, run
|
|
9
|
+
// the suite, and discard. That makes it a writer in the worktree the
|
|
10
|
+
// fix-applier owns, with nothing sequencing the two. Measured on #380 — the
|
|
11
|
+
// finisher was inside that worktree at the instant the fix-applier announced
|
|
12
|
+
// one more clause to land. Neither ordering is detectable afterwards from the
|
|
13
|
+
// diff: a restore eats the uncommitted clause, or the mutant is still there
|
|
14
|
+
// when the fix-applier commits and a deliberately broken guard ships as the
|
|
15
|
+
// fix, in a commit nothing re-reviews.
|
|
16
|
+
//
|
|
17
|
+
// The ruling was the middle option of the three the ticket raised: give the
|
|
18
|
+
// finisher its own tree. NOT "sequence them" (controller discipline is what
|
|
19
|
+
// failed) and NOT "make the finisher non-mutating" (that trades away the
|
|
20
|
+
// independent verification the gate exists for) — so this file pins the
|
|
21
|
+
// mutation as much as the isolation.
|
|
22
|
+
//
|
|
23
|
+
// Slice-scoped, not whole-file: a bare presence check anywhere in this
|
|
24
|
+
// 1900+ line SKILL.md stays green even when the text moves somewhere its
|
|
25
|
+
// reader never reaches (measured before in this same file, #172).
|
|
26
|
+
const REPO = join(import.meta.dirname, "..");
|
|
27
|
+
const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
|
|
28
|
+
|
|
29
|
+
// The gate belongs to the finisher's duty 2 — verifying a claim by RUNNING is
|
|
30
|
+
// the same duty as verifying it by reading the diff, and duty 2 is where the
|
|
31
|
+
// finisher already reads. Anchored on the two duties' own opening text, so a
|
|
32
|
+
// renumber or a move out of the duty list reds rather than passing vacuously.
|
|
33
|
+
const DUTY1_START = "1. **Audit the worktree**";
|
|
34
|
+
const DUTY2_START = "2. **Confirm every deferral";
|
|
35
|
+
const DUTY2_END = "3. Add `ready-to-merge`";
|
|
36
|
+
|
|
37
|
+
// Markdown hard-wraps at ~80 columns and this text is a list continuation, so
|
|
38
|
+
// every phrase can split across a line with leading indent re-injected at the
|
|
39
|
+
// wrap point. Flattening makes the wrap invisible to a phrase match — so a
|
|
40
|
+
// pure rewrap, words untouched, cannot red a pin here. Every match in this
|
|
41
|
+
// file goes through it; a raw-RUN_TEAM assertion is reflow-brittle and reds
|
|
42
|
+
// with a message implying the prose was weakened when nothing was.
|
|
43
|
+
const flat = (s) => s.replace(/\n[ \t]*/g, " ");
|
|
44
|
+
|
|
45
|
+
function between(start, end) {
|
|
46
|
+
const at = RUN_TEAM.indexOf(start);
|
|
47
|
+
assert.notEqual(at, -1, `finisher duty opener ('${start}') moved — update this test`);
|
|
48
|
+
const to = RUN_TEAM.indexOf(end, at);
|
|
49
|
+
assert.notEqual(to, -1, `finisher duty opener ('${end}') moved — update this test`);
|
|
50
|
+
return flat(RUN_TEAM.slice(at, to));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const duty1Text = () => between(DUTY1_START, DUTY2_START);
|
|
54
|
+
const duty2Text = () => between(DUTY2_START, DUTY2_END);
|
|
55
|
+
|
|
56
|
+
test("the mutation gate runs in a worktree the finisher adds itself, at its dispatch pin", () => {
|
|
57
|
+
const text = duty2Text();
|
|
58
|
+
// ONE contiguous span. The command and its ref operand have to stay joined:
|
|
59
|
+
// `worktree add --detach` at some other ref is a different instruction, and
|
|
60
|
+
// two independent phrase matches stay green through exactly that swap.
|
|
61
|
+
assert.match(
|
|
62
|
+
text,
|
|
63
|
+
/git worktree add --detach [^`]*<your dispatch pin>/,
|
|
64
|
+
"the gate no longer adds its own detached worktree at the dispatch pin — either the finisher is back to mutating the worktree another member owns, or the tree is created at some other ref",
|
|
65
|
+
);
|
|
66
|
+
// Which ref is the whole point, and it is the same substitution the halt
|
|
67
|
+
// block's head-equality check already rejects: a member that kept working
|
|
68
|
+
// and pushed after the pin matches the branch tip, so a tree cut at
|
|
69
|
+
// `headRefOid` gets mutation-verified over commits no reviewer read.
|
|
70
|
+
assert.doesNotMatch(
|
|
71
|
+
text,
|
|
72
|
+
/git worktree add --detach [^`]*(headRefOid|origin\/)/,
|
|
73
|
+
"the throwaway tree is cut at the pushed branch tip rather than the dispatch pin — a member that pushed past the pin gets its unreviewed commits verified and labelled",
|
|
74
|
+
);
|
|
75
|
+
// The scratch root is shared with every sibling member, so the PR number
|
|
76
|
+
// alone is not a unique path: a PR with a second finisher collides, and
|
|
77
|
+
// `worktree add` on an occupied path fails closed into a halt with a purely
|
|
78
|
+
// mechanical cause.
|
|
79
|
+
//
|
|
80
|
+
// Read the path OFF the add and require the remove to name it back. The
|
|
81
|
+
// token appears twice, so a bare match on the scoping is satisfied by
|
|
82
|
+
// either occurrence alone: strip it from just one command and add/remove
|
|
83
|
+
// silently target different paths, which is undetectable in both
|
|
84
|
+
// directions. Mismatched, the remove either refuses (rc 128, tree leaked)
|
|
85
|
+
// or succeeds against a differently-scoped path and takes a sibling
|
|
86
|
+
// finisher's tree with it.
|
|
87
|
+
const added = text.match(/git worktree add --detach ([^`]*?) <your dispatch pin>/);
|
|
88
|
+
assert.ok(added, "no `git worktree add --detach <path> <your dispatch pin>` left to read a path out of");
|
|
89
|
+
assert.match(
|
|
90
|
+
added[1],
|
|
91
|
+
/^<scratch>\/pr<N>\/finish-<your member name>$/,
|
|
92
|
+
"the throwaway tree's path no longer carries the member name — the scratch root is shared, so two finishers on one PR collide on it",
|
|
93
|
+
);
|
|
94
|
+
assert.match(
|
|
95
|
+
text,
|
|
96
|
+
new RegExp(`git worktree remove --force ${added[1].replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`),
|
|
97
|
+
"the remove names a different path than the add — either the remove refuses and the tree leaks, or it removes a differently-scoped tree that is not this finisher's",
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("the throwaway tree is removed on every path, failures included, and --force is scoped to it", () => {
|
|
102
|
+
const text = duty2Text();
|
|
103
|
+
assert.match(
|
|
104
|
+
text,
|
|
105
|
+
/git worktree remove --force/,
|
|
106
|
+
"the removal no longer forces — the tree is deliberately dirty when the gate finishes, so a plain remove refuses it and the tree leaks",
|
|
107
|
+
);
|
|
108
|
+
// Contiguous: "remove it" and "on every path including the failing ones" are
|
|
109
|
+
// one invariant. A removal documented only on the success path is exactly
|
|
110
|
+
// the leak this criterion exists to prevent, and it reads as satisfied if
|
|
111
|
+
// the two halves are matched separately.
|
|
112
|
+
assert.match(
|
|
113
|
+
text,
|
|
114
|
+
/Remove it on every path, the failing ones included/,
|
|
115
|
+
"the every-path removal invariant is gone or was split — a gate that only removes the tree when the mutation behaves leaks one worktree per halt",
|
|
116
|
+
);
|
|
117
|
+
// `--force` is banned elsewhere in this runbook on worktrees that might hold
|
|
118
|
+
// someone's only copy. Without the stated scope this reads as a licence.
|
|
119
|
+
assert.match(
|
|
120
|
+
text,
|
|
121
|
+
/right only here/,
|
|
122
|
+
"the `--force` exception no longer says it is scoped to this tree — elsewhere in this runbook a `worktree remove` refusal is a finding, and an unscoped exception reads as permission to force past it",
|
|
123
|
+
);
|
|
124
|
+
// Nothing sweeps a leak for the finisher: reap's branchless sweep is bounded
|
|
125
|
+
// to the fleet's worktree home, so a tree under <scratch> is reported and
|
|
126
|
+
// left. A gate that assumes reap collects it will leak silently.
|
|
127
|
+
assert.match(
|
|
128
|
+
text,
|
|
129
|
+
/reap\.sh/,
|
|
130
|
+
"the gate no longer says a leaked scratch tree is outside reap's sweep — a finisher that assumes the leak is collected for it leaves one per finish",
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("the owned worktree stays a read — the finisher never writes to or restores it", () => {
|
|
135
|
+
const text = duty2Text();
|
|
136
|
+
// The live incident's near-miss: the controller's halt instruction said
|
|
137
|
+
// "restore the mutated paths", which IS the silent-destruction ordering. The
|
|
138
|
+
// finisher refused because it could not prove the diff was its own. That
|
|
139
|
+
// refusal was judgement, not a rule; this makes it a rule.
|
|
140
|
+
assert.match(
|
|
141
|
+
text,
|
|
142
|
+
/None of this licenses a write to the owned worktree\./,
|
|
143
|
+
"the ban on writing to the owned worktree is gone — the throwaway tree removes the hazard only while the finisher also stops treating the owned tree as a write target",
|
|
144
|
+
);
|
|
145
|
+
assert.match(
|
|
146
|
+
text,
|
|
147
|
+
/you never restore that tree, because you never wrote to it/,
|
|
148
|
+
"the no-restore rule no longer reads as a consequence of never having written — stated as a bare prohibition it invites a controller instruction to override it, which is what happened live",
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test("independent re-verification survives — the gate still mutates and runs the suite itself", () => {
|
|
153
|
+
const text = duty2Text();
|
|
154
|
+
// ACCEPT side. The ticket's third option was to make the finisher
|
|
155
|
+
// non-mutating and have it read the fix-applier's record instead. That was
|
|
156
|
+
// ruled out: the independent gate caught two unpinned fixes in the run that
|
|
157
|
+
// produced this ticket. A change that isolates the writes but quietly drops
|
|
158
|
+
// the mutation satisfies every other test here and guts the gate.
|
|
159
|
+
assert.match(
|
|
160
|
+
text,
|
|
161
|
+
/acceptance mutation/,
|
|
162
|
+
"the gate no longer re-runs the ticket's acceptance mutation — isolating the write is not the point if the independent verification goes with it",
|
|
163
|
+
);
|
|
164
|
+
assert.match(
|
|
165
|
+
text,
|
|
166
|
+
/<testCmd>/,
|
|
167
|
+
"the gate no longer runs the suite itself — reading the fix-applier's recorded result is the option this ticket's ruling rejected",
|
|
168
|
+
);
|
|
169
|
+
// A placeholder nobody substitutes is not a gate. `<testCmd>` reaches the
|
|
170
|
+
// finisher only through the controller's prompt — there is no fleet-finisher
|
|
171
|
+
// agent definition to carry a default — and the runbook's pass-list named
|
|
172
|
+
// the workflow and the fix-applier only, so the gate shipped unenforceable.
|
|
173
|
+
//
|
|
174
|
+
// The instruction and its reason in ONE sentence, `sentences()`'s (#1940).
|
|
175
|
+
// The first-period `[^.]*` gap this replaces refused a valid rewording with
|
|
176
|
+
// an "e.g." or a filename between the two, and ran on past a `?` or `!` —
|
|
177
|
+
// the latter nearly inert here, since both phrases must be verbatim anyway.
|
|
178
|
+
assert.ok(
|
|
179
|
+
sentences(duty1Text()).some((s) => /Give it `<testCmd>` too.*duty 2's mutation gate runs it/.test(s)),
|
|
180
|
+
"the controller is no longer told to hand the finisher a `<testCmd>` — duty 2's placeholders reach it unsubstituted and the gate has no command to run",
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// #525: duty 1 names `worktree-audit.sh` as the audit to run, and that script
|
|
185
|
+
// takes NO argument and audits every worktree at once. Without the clause, a
|
|
186
|
+
// finisher reads "run worktree-audit.sh" against a runbook full of
|
|
187
|
+
// path-taking siblings, passes this worktree's path, and gets exit 2 — or,
|
|
188
|
+
// before #525's guard, a full audit of every OTHER worktree at exit 0 with
|
|
189
|
+
// the main checkout on top, which is the failure the guard exists to stop.
|
|
190
|
+
// The contract is pinned at the script (worktree-audit.test.mjs), unpinned in
|
|
191
|
+
// the runbook the finisher actually reads.
|
|
192
|
+
test("duty 1 says worktree-audit.sh takes no argument and audits every worktree", () => {
|
|
193
|
+
// ONE contiguous span: "takes no argument" and "find this worktree's row"
|
|
194
|
+
// are halves of the same instruction. Matched separately, dropping the
|
|
195
|
+
// lookup half stays green and leaves a finisher reading the first row —
|
|
196
|
+
// the main checkout — as if it were this worktree's.
|
|
197
|
+
assert.match(
|
|
198
|
+
duty1Text(),
|
|
199
|
+
/it takes no argument; it audits every worktree in one pass, so find this worktree's row in its output/,
|
|
200
|
+
"duty 1 no longer says `worktree-audit.sh` takes no argument and audits every worktree — a finisher that passes it this worktree's path gets exit 2, and one that reads the first row reads the main checkout",
|
|
201
|
+
);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// #1106: duty 1 offered the audit and `git status --porcelain -unormal` as
|
|
205
|
+
// equal alternatives, then halted on "dirty or diverged" — and neither can
|
|
206
|
+
// see diverged. Porcelain is empty over a clean tree one commit past the pin,
|
|
207
|
+
// and the audit's `ahead` is counted against `origin/main`
|
|
208
|
+
// (worktree-audit.sh's `base=${BASE_REF:-origin/main}`), which a PR worktree
|
|
209
|
+
// is always ahead of. The only divergence check is the cause block's
|
|
210
|
+
// head-equality against the dispatch pin. And "find this worktree's row" gave
|
|
211
|
+
// no rule for a row that cannot answer, or for no row at all. Each pin below
|
|
212
|
+
// holds ONE sentence (`sentences()`, #1940), so a clause deleted from inside
|
|
213
|
+
// the duty reds its own pin rather than being satisfied by a neighbour.
|
|
214
|
+
test("duty 1 names the instrument for each check, and halts on a row that cannot answer", () => {
|
|
215
|
+
const said = (re) => sentences(duty1Text()).some((s) => re.test(s));
|
|
216
|
+
assert.ok(
|
|
217
|
+
said(/\*\*Dirty:\*\* the row's `dirty` field, or `git status --porcelain -unormal` inside the worktree/),
|
|
218
|
+
"duty 1 no longer names the dirty check's two instruments — the row's `dirty` field and `git status --porcelain -unormal`",
|
|
219
|
+
);
|
|
220
|
+
assert.ok(
|
|
221
|
+
said(/\*\*Diverged:\*\* the worktree's `HEAD` against your dispatch pin/),
|
|
222
|
+
"duty 1 no longer says diverged is the worktree's HEAD against the dispatch pin — neither the audit nor git status can see a clean tree that moved past it",
|
|
223
|
+
);
|
|
224
|
+
assert.ok(
|
|
225
|
+
said(/row's `ahead`.*counted against `origin\/main`.*cannot answer/),
|
|
226
|
+
"duty 1 no longer says the audit's `ahead` is counted against origin/main — a finisher reading it as divergence sees every PR worktree as diverged, or learns to ignore it",
|
|
227
|
+
);
|
|
228
|
+
// The three non-clean row shapes, each halting and each named. Unreadable
|
|
229
|
+
// and missing share `readable:false` and differ only in their counts, so
|
|
230
|
+
// each is pinned with its count shape and stderr line — dropping one leaves
|
|
231
|
+
// a finisher to read the other's zero counts as clean.
|
|
232
|
+
assert.ok(
|
|
233
|
+
said(/halt.*`readable:false` with `null` counts \(`UNREADABLE: <wt> \(<cause>\)`\) is \*worktree unreadable\*/),
|
|
234
|
+
"duty 1 no longer halts on an unreadable row (`readable:false`, null counts) — the one state the audit exists never to report as clean",
|
|
235
|
+
);
|
|
236
|
+
assert.ok(
|
|
237
|
+
said(/halt.*`readable:false` with zero counts \(`MISSING on disk: <wt>`\) is \*worktree missing\*/),
|
|
238
|
+
"duty 1 no longer halts on a missing row (`readable:false`, zero counts) — zero counts read as a clean tree",
|
|
239
|
+
);
|
|
240
|
+
assert.ok(
|
|
241
|
+
said(/halt.*no row for this worktree at all is \*worktree absent\*/),
|
|
242
|
+
"duty 1 no longer halts when this worktree has no row — a finisher finds nothing wrong in a row it never found",
|
|
243
|
+
);
|
|
244
|
+
// #2141: the row's `worktree` field is `git worktree list`'s, which always
|
|
245
|
+
// reports the resolved physical path — worktree-audit.sh resolves nothing
|
|
246
|
+
// itself. A finisher dispatched with a symlinked spelling (macOS's `/tmp`
|
|
247
|
+
// and `/var/folders` are symlinks too) finds no row for the path as
|
|
248
|
+
// written and halts a healthy tree as *worktree absent*. Its own sentence,
|
|
249
|
+
// so deleting the clause reds here and nowhere else.
|
|
250
|
+
assert.ok(
|
|
251
|
+
said(/Match the row by the resolved form of the worktree path you were dispatched with.*`realpath <abs-path>`.*`cd <abs-path> && pwd -P`.*never by that path as written/),
|
|
252
|
+
"duty 1 no longer tells the finisher to match its row by the resolved (`realpath` / `pwd -P`) form of its dispatched worktree path — a symlinked spelling finds no row and halts a healthy tree as *worktree absent*",
|
|
253
|
+
);
|
|
254
|
+
// `git status` answers the dirty check only. Presented as a full
|
|
255
|
+
// substitute, it lets a finisher skip the audit and never see the three
|
|
256
|
+
// shapes above.
|
|
257
|
+
assert.ok(
|
|
258
|
+
said(/`git status` is no substitute for the audit here/),
|
|
259
|
+
"duty 1 no longer says `git status` cannot stand in for the audit on the three row shapes — it is back to reading as an equal alternative",
|
|
260
|
+
);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test("duty 1's dirty-tree halt survives, and duty 2's own caveats are not clipped", () => {
|
|
264
|
+
// ACCEPT side, and the neighbour check. Duty 1's halt is the guard that
|
|
265
|
+
// caught #389 live; the throwaway tree makes an overlap harmless, which is
|
|
266
|
+
// not a reason to stop detecting one. It is unpinned everywhere else, and it
|
|
267
|
+
// sits one duty away from this edit. (The always-halts invariant in the halt
|
|
268
|
+
// block's cause list is already owned by finisher-pin-race-prose.test.mjs —
|
|
269
|
+
// not re-pinned here.)
|
|
270
|
+
assert.match(
|
|
271
|
+
duty1Text(),
|
|
272
|
+
/Dirty, diverged, unreadable, missing or absent halts the finisher \*here\*, before the label/,
|
|
273
|
+
"duty 1's halt no longer covers all five causes, or no longer halts *here*, before the label — check it was not weakened",
|
|
274
|
+
);
|
|
275
|
+
// The paragraph the new gate is appended directly after, and the half of
|
|
276
|
+
// duty 2 that dedupe-guard-prose.test.mjs does NOT cover: it pins the
|
|
277
|
+
// positive `origin/main...HEAD` check, nothing pins this scoping caveat. An
|
|
278
|
+
// insertion that swallows a trailing paragraph is the ordinary way to break
|
|
279
|
+
// a neighbour, and it leaves every other test here green.
|
|
280
|
+
assert.match(
|
|
281
|
+
duty2Text(),
|
|
282
|
+
/That range is right for the positive check and wrong for a negative one\./,
|
|
283
|
+
"duty 2's negative-claim scoping caveat was clipped — appending the mutation gate must not swallow the paragraph it lands after",
|
|
284
|
+
);
|
|
285
|
+
});
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { between, paragraph } from "./prose-pin.mjs";
|
|
6
|
+
|
|
7
|
+
// #144. The finisher is dispatched pinned to a SHA the reviewer already left
|
|
8
|
+
// behind: the reviewer composes a verdict once it has enough, then keeps
|
|
9
|
+
// applying late-arriving specialist relays and pushes again. The pin going
|
|
10
|
+
// stale isn't the defect — the halt-on-moved-head rule already catches it,
|
|
11
|
+
// correctly, every time. The defect is that (a) the controller dispatches
|
|
12
|
+
// before every specialist report is relayed, when it holds the receipts to
|
|
13
|
+
// know better, and (b) a halt reads only "SHA differs from pin" and gives
|
|
14
|
+
// the controller nothing to act on without a fresh audit.
|
|
15
|
+
//
|
|
16
|
+
// Slice-scoped, not whole-file: a bare presence check anywhere in this
|
|
17
|
+
// 1200+ line SKILL.md would stay green even if the text moved somewhere
|
|
18
|
+
// that never reaches its reader (measured before, in this same file —
|
|
19
|
+
// member-prompt-prose.test.mjs #172). Two different readers here: the
|
|
20
|
+
// dispatch gate is controller-facing and lives in the Fallback section, the
|
|
21
|
+
// cause-block evidence is finisher-facing and must sit inside a `>` block the
|
|
22
|
+
// controller carries verbatim.
|
|
23
|
+
const REPO = join(import.meta.dirname, "..");
|
|
24
|
+
const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
|
|
25
|
+
|
|
26
|
+
const FALLBACK_START = "#### Fallback: hand-dispatched reviewer member";
|
|
27
|
+
const FALLBACK_END = "### Merge bot";
|
|
28
|
+
|
|
29
|
+
// #753: proven output-identical to `between()` on the real SKILL.md text —
|
|
30
|
+
// FALLBACK_END never occurs inside FALLBACK_START's own text, so searching
|
|
31
|
+
// from `at` instead of `at + FALLBACK_START.length` never changes the match.
|
|
32
|
+
const fallbackSection = () => between(RUN_TEAM, FALLBACK_START, FALLBACK_END, "run-team fallback section");
|
|
33
|
+
|
|
34
|
+
const CAUSE_BLOCK_START = "instead of asking anyone:";
|
|
35
|
+
// The controller-facing resolution table (#2083) follows the block directly;
|
|
36
|
+
// it is no part of what the finisher is handed.
|
|
37
|
+
const CAUSE_BLOCK_END = "**Resolving a finisher halt.**";
|
|
38
|
+
|
|
39
|
+
// Raw slice: keeps the `>` prefixes, needed by the structural (every-line-quoted)
|
|
40
|
+
// test below.
|
|
41
|
+
function causeBlock() {
|
|
42
|
+
const at = RUN_TEAM.indexOf(CAUSE_BLOCK_START);
|
|
43
|
+
assert.notEqual(at, -1, `cause-block anchor ('${CAUSE_BLOCK_START}') moved — update this test`);
|
|
44
|
+
const end = RUN_TEAM.indexOf(CAUSE_BLOCK_END, at);
|
|
45
|
+
assert.notEqual(end, -1, `the resolution paragraph that follows ('${CAUSE_BLOCK_END}') moved — update this test`);
|
|
46
|
+
return RUN_TEAM.slice(at + CAUSE_BLOCK_START.length, end);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Flattened: markdown hard-wraps a `>` block at ~80 columns, so a phrase can
|
|
50
|
+
// split across a line with a literal `>` re-injected at the wrap point. A
|
|
51
|
+
// phrase match needs the wrap invisible; the structural test needs it intact,
|
|
52
|
+
// hence two helpers instead of one.
|
|
53
|
+
function causeText() {
|
|
54
|
+
return causeBlock().replace(/\n>?[ \t]*/g, " ");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// #997. The lead-in that introduces the list sits OUTSIDE the `>` block, so
|
|
58
|
+
// `causeText()` cannot see it — and the count word this ticket removes lived
|
|
59
|
+
// there, not in the block. Anchored on the surviving half of that sentence and
|
|
60
|
+
// bounded by its own paragraph: `anchorAt` refuses a duplicated or missing
|
|
61
|
+
// anchor rather than widening to the whole file, which is the only way a
|
|
62
|
+
// "no closed count anywhere" assertion could pass by looking at nothing.
|
|
63
|
+
const LEAD_ANCHOR = "A halt at step 1 reads identical from a bare SHA mismatch";
|
|
64
|
+
const leadIn = () => paragraph(RUN_TEAM, LEAD_ANCHOR, "run-team halt-cause lead-in");
|
|
65
|
+
|
|
66
|
+
test("finisher dispatch is gated on outstanding specialist relays, in the section that owns relay receipts", () => {
|
|
67
|
+
const section = fallbackSection();
|
|
68
|
+
assert.match(
|
|
69
|
+
section,
|
|
70
|
+
/receipts gate the finisher dispatch/i,
|
|
71
|
+
"the fallback section no longer gates finisher dispatch on relay receipts — a late relay can again land after dispatch with nothing checking for it",
|
|
72
|
+
);
|
|
73
|
+
assert.match(
|
|
74
|
+
section,
|
|
75
|
+
/unrelayed/,
|
|
76
|
+
"the gate no longer names an unrelayed report as the blocking condition",
|
|
77
|
+
);
|
|
78
|
+
// The scope boundary matters as much as the rule: the workflow path has no
|
|
79
|
+
// async relay at all (`agent()` returns synchronously), so a gate that reads
|
|
80
|
+
// as universal would strand controllers into believing a wait is needed
|
|
81
|
+
// where none exists.
|
|
82
|
+
assert.match(
|
|
83
|
+
section,
|
|
84
|
+
/workflow path/i,
|
|
85
|
+
"the gate doesn't say it's a no-op on the workflow path — a controller reading only this rule may wait on a relay that can never arrive there",
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test("the cause evidence sits inside a quote block, not only in controller narrative", () => {
|
|
90
|
+
const block = causeBlock();
|
|
91
|
+
const lines = block.split("\n").filter((l) => l.trim() !== "");
|
|
92
|
+
assert.ok(lines.length > 0, "the cause block is empty");
|
|
93
|
+
const stray = lines.filter((l) => !l.startsWith(">"));
|
|
94
|
+
assert.deepEqual(
|
|
95
|
+
stray,
|
|
96
|
+
[],
|
|
97
|
+
"cause text sits outside the `>` block — a finisher only receives this if the controller paraphrases it, same failure #172 already fixed once in this file for the implementer",
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("the live-editor and rebase causes are named, with evidence a finisher can gather without asking anyone", () => {
|
|
102
|
+
const text = causeText();
|
|
103
|
+
|
|
104
|
+
assert.match(text, /\*\*Live editor\.\*\*/, "the live-editor cause is no longer named");
|
|
105
|
+
assert.match(
|
|
106
|
+
text,
|
|
107
|
+
/git status --porcelain.*dirty/,
|
|
108
|
+
"live editor is no longer tied to a dirty worktree, checkable with a plain git command",
|
|
109
|
+
);
|
|
110
|
+
assert.match(
|
|
111
|
+
text,
|
|
112
|
+
/git diff --stat.*\bapart\b/,
|
|
113
|
+
"the growth check (two samples apart) is missing — a single dirty read can't distinguish a live editor from a one-off leftover",
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
assert.match(text, /\*\*Rebase\.\*\*/, "the rebase cause is no longer named");
|
|
117
|
+
assert.match(
|
|
118
|
+
text,
|
|
119
|
+
/git reflog/,
|
|
120
|
+
"the rebase cause no longer points at git reflog — without it a finisher has no self-checkable way to tell a rebase from a live edit on a clean tree",
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// #997, measured 2026-08-28 on #983: the working tree was clean (sampled twice
|
|
125
|
+
// a minute apart, empty diffstat both times), the reflog head was a plain
|
|
126
|
+
// `commit` past the dispatch pin, and the `reset`/rebase entries sat BEHIND the
|
|
127
|
+
// pin — the implementer's own pre-push replay, which the block already excuses
|
|
128
|
+
// as provenance. So it matched neither named cause, and the block's own count
|
|
129
|
+
// word said that was impossible. The finisher halted on its own judgement,
|
|
130
|
+
// which is luck: the block's whole purpose is that an unattended finisher
|
|
131
|
+
// DERIVES the cause, and the block itself calls a bare "head moved" an
|
|
132
|
+
// inadequate report — so a closed list that excludes the live case leaves
|
|
133
|
+
// "unexplained" as the only remaining output, and that is the state where
|
|
134
|
+
// labelling over a moved head starts looking reasonable.
|
|
135
|
+
test("the commit-past-the-pin cause is named, with a discriminator neither other cause matches", () => {
|
|
136
|
+
const text = causeText();
|
|
137
|
+
assert.match(
|
|
138
|
+
text,
|
|
139
|
+
/\*\*Work past the pin\.\*\*/,
|
|
140
|
+
"the commit-past-the-pin cause is no longer named — a finisher meeting a clean tree with a plain `commit` past its pin is back to a list that excludes the thing it is looking at",
|
|
141
|
+
);
|
|
142
|
+
// ONE contiguous span, because the discriminator IS the join. The rebase
|
|
143
|
+
// bullet opens on the same clean-tree-and-head-differs read and is told apart
|
|
144
|
+
// only by what the reflog says at the move, so a bare `/plain `commit`/`
|
|
145
|
+
// matches the rebase bullet's own "not a plain `commit`" exclusion and buys
|
|
146
|
+
// the green with this cause deleted.
|
|
147
|
+
assert.match(
|
|
148
|
+
text,
|
|
149
|
+
/`git status --porcelain -unormal` is clean, head still differs from your pin, and `git reflog` in the worktree reads a plain `commit` at the move/,
|
|
150
|
+
"the discriminator no longer separates this cause from the rebase one — either the clean-tree-and-head-differs read went, or the reflog test stopped keying on a plain `commit` at the move",
|
|
151
|
+
);
|
|
152
|
+
// The provenance carve-out the block already grants rebase entries at or
|
|
153
|
+
// behind the pin has to stay attached to THIS cause too, or a finisher that
|
|
154
|
+
// sees any rebase entry in the reflog routes back to `rebase` and reports the
|
|
155
|
+
// replay instead of the commit that actually moved the head.
|
|
156
|
+
assert.match(
|
|
157
|
+
text,
|
|
158
|
+
/no `reset`\/rebase entry there, any of those sitting at or behind the pin as provenance/,
|
|
159
|
+
"the reflog entries behind the pin are no longer excused inside this cause — a stale rebase entry anywhere in the reflog sends the finisher back to `rebase` and the commit past the pin goes unreported",
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("the commit-past-the-pin report names the commit and whether it is pushed, unpushed, or unknown", () => {
|
|
164
|
+
const text = causeText();
|
|
165
|
+
// Pushed, unpushed, and unknown need different controller moves, so a report
|
|
166
|
+
// shape that collapses any two of them is a report of a different cause.
|
|
167
|
+
// Contiguous: the report verb, the cause's own name, and the three facts it
|
|
168
|
+
// owes travel together, and splitting them lets a mutant keep the halt
|
|
169
|
+
// while dropping what the halt is worth.
|
|
170
|
+
assert.match(
|
|
171
|
+
text,
|
|
172
|
+
/Halt, name `past-pin`, and report \*\*the commit, and whether it is pushed, unpushed, or unknown\*\*/,
|
|
173
|
+
"the report shape no longer owes all three facts — a halt naming the commit without saying pushed/unpushed/unknown leaves the controller unable to tell an unreviewed push from a commit no reviewer can even fetch, or from a check that never got an answer",
|
|
174
|
+
);
|
|
175
|
+
// Both commands, because "whether it is pushed" is only self-checkable if the
|
|
176
|
+
// block says what to run. The remote read is `ls-remote`, not the PR object's
|
|
177
|
+
// head: that field lags a ref move, which is why `run-merge-bot.md` refuses
|
|
178
|
+
// to poll it, and a lagging read answers "unpushed" for a commit that is
|
|
179
|
+
// already on the branch.
|
|
180
|
+
assert.match(
|
|
181
|
+
text,
|
|
182
|
+
/`git log -1 --format='%h %s'` names it/,
|
|
183
|
+
"the commit is no longer named by a command the finisher can run — a report shape that owes a SHA and a subject with no way to read them is a request, not an instruction",
|
|
184
|
+
);
|
|
185
|
+
assert.match(
|
|
186
|
+
text,
|
|
187
|
+
/`git ls-remote origin <branch>` answers the rest/,
|
|
188
|
+
"the pushed read is gone or moved off `git ls-remote` — the PR object's head lags a ref move, so asking it reports an already-pushed commit as local-only",
|
|
189
|
+
);
|
|
190
|
+
// #997 finding: a FAILED `git ls-remote` (unreachable origin, non-zero exit)
|
|
191
|
+
// used to read as "anything else" — the same shape as a genuinely absent
|
|
192
|
+
// ref — which folds an unknown answer into "unpushed" and reports an
|
|
193
|
+
// already-pushed commit as local-only. This is the unknown-answer-as-a-"no"
|
|
194
|
+
// hole `release-ticket.sh` (1157-1179) and `reaping.md` (56) both forbid;
|
|
195
|
+
// pinning that this bullet now matches them.
|
|
196
|
+
assert.match(
|
|
197
|
+
text,
|
|
198
|
+
/a non-zero exit or any other failed read is \*\*unknown\*\*, never folded into "unpushed"/,
|
|
199
|
+
"a failed `ls-remote` (unreachable origin, non-zero exit) no longer names a third, unknown answer — it reads as indistinguishable from a successful read finding no matching ref, reporting an unreachable-origin failure as 'unpushed'",
|
|
200
|
+
);
|
|
201
|
+
// The consequence, in all three directions. Without it the answers read as
|
|
202
|
+
// trivia and the next reader deletes one of them as redundant.
|
|
203
|
+
assert.match(
|
|
204
|
+
text,
|
|
205
|
+
/Only a successful read settles pushed vs not: equal to that commit means pushed, and a fresh finisher can audit it; a successful read that comes back without it means the commit exists only in that worktree, where no reviewer can reach it/,
|
|
206
|
+
"the pushed/unpushed answers no longer say what each one means for the controller, or no longer require a successful read to reach either — the distinction survives as a fact nobody can act on, or a failed read can satisfy the unpushed branch again",
|
|
207
|
+
);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test("the cause list is open — no count is asserted, and an unmatched cause is named rather than called unexplained", () => {
|
|
211
|
+
const lead = leadIn();
|
|
212
|
+
const text = causeText();
|
|
213
|
+
|
|
214
|
+
// Generic over the number word, in both slices that carried one. A count
|
|
215
|
+
// that has been wrong once will be wrong again, so a rewrite to "exactly
|
|
216
|
+
// three causes" is this defect again and not a fix of it — that is why
|
|
217
|
+
// these pins do not name `two`.
|
|
218
|
+
//
|
|
219
|
+
// Wide, not `exactly \w+ causes`: that narrower gap only forbade the literal
|
|
220
|
+
// word "exactly" immediately before the count, so restoring a closed count
|
|
221
|
+
// as "the three causes below" (no "exactly", one extra word before "causes")
|
|
222
|
+
// passed it clean — measured, mutate.py M4. `(?:\s+\w+){0,3}` spans the
|
|
223
|
+
// count word forward to "causes"/"things" through up to three filler words,
|
|
224
|
+
// which is what both slices' surrounding prose needs room for.
|
|
225
|
+
assert.doesNotMatch(
|
|
226
|
+
lead,
|
|
227
|
+
/\b(two|three|four|five|\d+)\b(?:\s+\w+){0,3}\s+causes\b/i,
|
|
228
|
+
"the lead-in asserts a fixed number of causes again — the enumeration is closed, and the cause that is not on the list reads as impossible to the finisher deriving it",
|
|
229
|
+
);
|
|
230
|
+
assert.match(
|
|
231
|
+
lead,
|
|
232
|
+
/not a closed list/,
|
|
233
|
+
"the lead-in no longer says the list is open — silence there is the closed reading restored, since a list with no disclaimer is read as complete",
|
|
234
|
+
);
|
|
235
|
+
// Same widening, same reason: `which of \w+ things happened` only forbids a
|
|
236
|
+
// single word between "of" and "things", so "which of the three things
|
|
237
|
+
// happened" (two words: "the three") passed it clean — measured, mutate.py
|
|
238
|
+
// M3.
|
|
239
|
+
assert.doesNotMatch(
|
|
240
|
+
text,
|
|
241
|
+
/\b(two|three|four|five|\d+)\b(?:\s+\w+){0,3}\s+things\b/i,
|
|
242
|
+
"the block the finisher reads counts the causes again — the count word inside the `>` block is the one that reaches the finisher verbatim",
|
|
243
|
+
);
|
|
244
|
+
assert.match(
|
|
245
|
+
text,
|
|
246
|
+
/`anything else` is a cause too, not a gap/,
|
|
247
|
+
"the block no longer tells the finisher that an unmatched cause is still a cause — without it the fallback bullet reads as a note about incompleteness rather than an instruction",
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
// The fallback itself, and the report it forbids. `unexplained` is the exact
|
|
251
|
+
// output the block exists to make unnecessary: it is the one verdict from
|
|
252
|
+
// which letting the mismatch through is the cheapest next step.
|
|
253
|
+
assert.match(
|
|
254
|
+
text,
|
|
255
|
+
/\*\*Anything else\.\*\*/,
|
|
256
|
+
"the open-ended cause is gone — a fourth shape now has no bullet at all, which is the state #997 was filed from",
|
|
257
|
+
);
|
|
258
|
+
assert.match(
|
|
259
|
+
text,
|
|
260
|
+
/not a licence to report the mismatch as unexplained/,
|
|
261
|
+
"the fallback no longer forbids the unexplained report — an open list whose escape hatch is 'unexplained' is the closed list with extra words",
|
|
262
|
+
);
|
|
263
|
+
assert.match(
|
|
264
|
+
text,
|
|
265
|
+
/name what you did find: both `git status --porcelain -unormal` samples, the `git reflog` line at the move, and both SHAs/,
|
|
266
|
+
"the fallback no longer says what to put in the report — 'name whatever you find' with no named evidence is the bare \"head moved\" this block already rejects",
|
|
267
|
+
);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test("a moved head still halts, always — the cause decides what the report says, never whether it halts", () => {
|
|
271
|
+
const text = causeText();
|
|
272
|
+
// ONE exact contiguous span, not two independent phrase matches. The
|
|
273
|
+
// invariant lives in the join: splicing an exception clause between
|
|
274
|
+
// "halts, always" and "you never verify the dirt is harmless" reverses the
|
|
275
|
+
// rule while leaving both phrases intact, and two separate `assert.match`
|
|
276
|
+
// calls stayed green through exactly that mutation (measured, #488 review).
|
|
277
|
+
// The tail is the explicit rejection of issue option 3 ("accept a
|
|
278
|
+
// fast-forward") — the controller ruling took options 2+4, not 3, and a
|
|
279
|
+
// finisher that treats a clean rebase as auto-approved is what triage
|
|
280
|
+
// rejected. Whitespace is already normalised by causeText(), so this is
|
|
281
|
+
// literal text, not a shape.
|
|
282
|
+
// #997 widened this from "Either cause", which quantified over exactly two.
|
|
283
|
+
// The open list creates a false-negative the two-valued form could not
|
|
284
|
+
// cover: an unmatched cause with no halt rule quantifying over it reads as
|
|
285
|
+
// the one case where naming what you found might substitute for halting.
|
|
286
|
+
// Hence `named or not`, inside the same contiguous span.
|
|
287
|
+
assert.match(
|
|
288
|
+
text,
|
|
289
|
+
/Every cause halts, always — named or not, you never verify the dirt is harmless and label over it, a rebase is not a fast-forward you get to accept, a commit past the pin is not one either, and a cause you could not name is the least settled of the lot\./,
|
|
290
|
+
"the always-halts invariant no longer reads verbatim in the block the finisher reads — either it's gone, or a clause was inserted into it that makes the halt conditional, or it stopped quantifying over the unnamed cause, or the ban on labelling over a moved head was dropped",
|
|
291
|
+
);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
test("the head-equality short-circuit compares against the dispatch pin, on a clean tree", () => {
|
|
295
|
+
const text = causeText();
|
|
296
|
+
// The short-circuit exists to stop finishers adjudicating a reflog that
|
|
297
|
+
// head-equality had already settled. WHICH head it compares to is the whole
|
|
298
|
+
// rule: this block is ENTERED on a mismatch against the dispatch pin, so a
|
|
299
|
+
// comparison against `PR headRefOid` answers a different question — "is the
|
|
300
|
+
// local tree in sync with the pushed tip?" — and a member that kept working
|
|
301
|
+
// and pushed after the pin passes it while holding commits no reviewer read.
|
|
302
|
+
// ONE contiguous span, not two matches: the operand and the clean-tree scope
|
|
303
|
+
// have to stay joined, since either half alone is satisfiable by the broken
|
|
304
|
+
// form.
|
|
305
|
+
assert.match(
|
|
306
|
+
text,
|
|
307
|
+
/head-equality first: `worktree HEAD == the SHA you were dispatched against` on a clean tree settles it\./,
|
|
308
|
+
"the head-equality short-circuit no longer reads as pin-equality scoped to a clean tree — either the operand moved off the dispatch pin, or the clean-tree scope was dropped",
|
|
309
|
+
);
|
|
310
|
+
// The superseded operand, verbatim. `headRefOid` still appears in the block
|
|
311
|
+
// as the SECOND, separate read (pushed vs unpushed), so only this exact
|
|
312
|
+
// equality can be excluded here, not the identifier.
|
|
313
|
+
assert.doesNotMatch(
|
|
314
|
+
text,
|
|
315
|
+
/`worktree HEAD == PR headRefOid`/,
|
|
316
|
+
"the short-circuit is back to comparing the worktree head to the pushed branch tip — a member that pushed after the pin reads as 'settled' and gets labelled over commits no reviewer saw",
|
|
317
|
+
);
|
|
318
|
+
// The clean-tree scope is what keeps the live-editor cause reachable at all:
|
|
319
|
+
// a dirty tree is never settled by the short-circuit, and the bullet opens
|
|
320
|
+
// directly on the dirty read with no head predicate to fail. Contiguous, so
|
|
321
|
+
// splicing a head condition in front of that read reds this — the loose
|
|
322
|
+
// `git status --porcelain.*dirty` pin above walks straight through it.
|
|
323
|
+
assert.match(
|
|
324
|
+
text,
|
|
325
|
+
/\*\*Live editor\.\*\* `git status --porcelain -unormal` is dirty\./,
|
|
326
|
+
"the live-editor cause is no longer keyed on a dirty tree alone — a head predicate in front of the dirty read strands the mid-mutation case with no named cause",
|
|
327
|
+
);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
test("the pre-existing ruling-owed gate for the fix-applier is untouched", () => {
|
|
331
|
+
// ACCEPT side: this run's edit sits right next to the fix-applier dispatch
|
|
332
|
+
// paragraph. This pins that the older, unrelated rule wasn't clipped or
|
|
333
|
+
// reworded by mistake while adding the new one beside it.
|
|
334
|
+
assert.match(
|
|
335
|
+
RUN_TEAM,
|
|
336
|
+
/Never dispatch\s*\n?one while you still owe the fix-applier a ruling/,
|
|
337
|
+
"the fix-applier ruling-owed gate no longer reads as before — check it wasn't altered while adding the specialist-relay gate nearby",
|
|
338
|
+
);
|
|
339
|
+
});
|