@feigi/fleet-ctl 0.0.0 → 3.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/agents/{fleet-implementer.agent.md → fleet-implementer-slow-high.agent.md} +23 -2
  2. package/agents/fleet-implementer-slow-medium.agent.md +231 -0
  3. package/agents/fleet-implementer-smol-high.agent.md +231 -0
  4. package/agents/{fleet-implementer-alt.agent.md → fleet-implementer-task-high.agent.md} +23 -2
  5. package/agents/fleet-implementer-task-max.agent.md +231 -0
  6. package/agents/fleet-review-comments.agent.md +4 -2
  7. package/agents/fleet-review-correctness.agent.md +2 -1
  8. package/agents/fleet-review-runner.agent.md +14 -10
  9. package/agents/fleet-review-silent-failure.agent.md +4 -3
  10. package/agents/fleet-review-simplify.agent.md +2 -1
  11. package/agents/fleet-review-snapshot.agent.md +2 -1
  12. package/agents/fleet-review-test-run.agent.md +29 -0
  13. package/agents/fleet-review-tests.agent.md +10 -5
  14. package/agents/fleet-review-types.agent.md +4 -2
  15. package/agents/fleet-review-verifier.agent.md +4 -3
  16. package/commands/review-and-fix.md +7 -6
  17. package/commands/run-merge-bot.md +14 -4
  18. package/package.json +4 -2
  19. package/scripts/agent-test.test.mjs +36 -32
  20. package/scripts/ambient-git-vars-mjs-prose.test.mjs +23 -13
  21. package/scripts/apply-ruleset.test.mjs +4 -3
  22. package/scripts/arg-header-probes-prose.test.mjs +1 -0
  23. package/scripts/arg.test.mjs +18 -18
  24. package/scripts/board-cli.test.mjs +18 -21
  25. package/scripts/board-identity.test.mjs +9 -9
  26. package/scripts/board-liveness-banner.test.mjs +6 -6
  27. package/scripts/board-prev-shape.test.mjs +12 -13
  28. package/scripts/board-tryparse-null.test.mjs +7 -7
  29. package/scripts/board.mjs +4 -7
  30. package/scripts/board.test.mjs +57 -61
  31. package/scripts/candidates.test.mjs +228 -17
  32. package/scripts/ci-completes-premise-prose.test.mjs +1 -1
  33. package/scripts/ci-state-prose.test.mjs +2 -2
  34. package/scripts/ci-state.mjs +389 -187
  35. package/scripts/ci-state.test.mjs +458 -165
  36. package/scripts/claim-lifecycle.test.mjs +2 -1
  37. package/scripts/claim-ticket.test.mjs +35 -34
  38. package/scripts/closing-keyword-prose.test.mjs +1 -1
  39. package/scripts/cockpit-tick-nonblocking.test.mjs +8 -8
  40. package/scripts/compute-board.mjs +13 -3
  41. package/scripts/compute-board.test.mjs +64 -1
  42. package/scripts/compute-spend.mjs +46 -8
  43. package/scripts/compute-spend.test.mjs +64 -10
  44. package/scripts/cross-repo-citation-prose.test.mjs +18 -19
  45. package/scripts/delete-merged-branch.sh +218 -0
  46. package/scripts/delete-merged-branch.test.mjs +576 -0
  47. package/scripts/derive-testcmd.sh +18 -7
  48. package/scripts/derive-testcmd.test.mjs +9 -8
  49. package/scripts/diff-stats.mjs +2 -2
  50. package/scripts/diff-stats.test.mjs +7 -11
  51. package/scripts/dispatch-block-golden-prose.test.mjs +111 -6
  52. package/scripts/dispatch-block-pins-prose.test.mjs +5 -5
  53. package/scripts/dispositions-check.mjs +507 -0
  54. package/scripts/dispositions-check.test.mjs +843 -0
  55. package/scripts/dispositions-gate-prose.test.mjs +114 -0
  56. package/scripts/drop-merged-label.test.mjs +3 -4
  57. package/scripts/exec-stub.mjs +93 -0
  58. package/scripts/exec-stub.test.mjs +69 -0
  59. package/scripts/filing-bar-seat-prose.test.mjs +1 -1
  60. package/scripts/finisher-test-verdict-prose.test.mjs +102 -0
  61. package/scripts/fix-applier-correction-rules-prose.test.mjs +11 -10
  62. package/scripts/fleet-bootstrap +5 -20
  63. package/scripts/fleet-bootstrap.test.mjs +75 -0
  64. package/scripts/fleet-heartbeat.mjs +2 -2
  65. package/scripts/fleet-provenance +15 -24
  66. package/scripts/fleet-provenance.test.mjs +86 -12
  67. package/scripts/fleet-run.test.mjs +5 -5
  68. package/scripts/fleet-state.mjs +33 -11
  69. package/scripts/fleet-state.test.mjs +90 -3
  70. package/scripts/fleet-tick.mjs +346 -70
  71. package/scripts/fleet-tick.test.mjs +566 -16
  72. package/scripts/force-with-lease-reason-prose.test.mjs +1 -1
  73. package/scripts/frontmatter-check.mjs +3 -2
  74. package/scripts/frontmatter-check.test.mjs +6 -6
  75. package/scripts/immutable-body-claim-prose.test.mjs +53 -262
  76. package/scripts/implementer-model-tier.test.mjs +98 -506
  77. package/scripts/inflight.test.mjs +18 -127
  78. package/scripts/is-cli.mjs +26 -0
  79. package/scripts/is-cli.test.mjs +99 -0
  80. package/scripts/json.test.mjs +3 -3
  81. package/scripts/ledger-dispatch.test.mjs +368 -7
  82. package/scripts/ledger-grammar.mjs +85 -1
  83. package/scripts/ledger-grammar.test.mjs +86 -1
  84. package/scripts/ledger-read-require-file.test.mjs +7 -7
  85. package/scripts/ledger-rotate.test.mjs +142 -0
  86. package/scripts/ledger.mjs +181 -17
  87. package/scripts/ledger.test.mjs +12 -130
  88. package/scripts/main-checkout.mjs +312 -0
  89. package/scripts/main-checkout.test.mjs +332 -0
  90. package/scripts/member-outcomes-header.test.mjs +3 -3
  91. package/scripts/member-outcomes.mjs +4 -5
  92. package/scripts/member-outcomes.test.mjs +92 -18
  93. package/scripts/member-prompt-prose.test.mjs +17 -13
  94. package/scripts/member-record.mjs +8 -3
  95. package/scripts/member-record.test.mjs +5 -5
  96. package/scripts/member-write-guard.mjs +5 -5
  97. package/scripts/member-write-guard.test.mjs +6 -3
  98. package/scripts/no-undo-audit.sh +24 -21
  99. package/scripts/no-undo-audit.test.mjs +9 -13
  100. package/scripts/pointer-target-prose.test.mjs +1 -1
  101. package/scripts/pr-overlap.test.mjs +6 -9
  102. package/scripts/prompt-renderer.mjs +10 -9
  103. package/scripts/prose-pin.mjs +10 -11
  104. package/scripts/prove-merge.test.mjs +3 -3
  105. package/scripts/quiet-payload-prose.test.mjs +1 -1
  106. package/scripts/reap.test.mjs +3 -4
  107. package/scripts/release-label-split-prose.test.mjs +17 -2
  108. package/scripts/release-ticket.test.mjs +35 -44
  109. package/scripts/review-core-cwd-isolation.test.mjs +7 -6
  110. package/scripts/review-core-reads.test.mjs +1 -1
  111. package/scripts/review-core-scratch-refusal.test.mjs +64 -0
  112. package/scripts/review-core-shared-test-run.test.mjs +238 -0
  113. package/scripts/review-core-snapshot-path.test.mjs +59 -12
  114. package/scripts/review-core-specialist-scratch.test.mjs +12 -10
  115. package/scripts/review-core-testcmd.test.mjs +76 -45
  116. package/scripts/review-core-unrun.test.mjs +154 -168
  117. package/scripts/review-core.mjs +250 -56
  118. package/scripts/review-eval.mjs +11 -4
  119. package/scripts/review-host-fixture.mjs +12 -3
  120. package/scripts/review-in-run-retry.test.mjs +27 -3
  121. package/scripts/review-runner-spawns.test.mjs +5 -3
  122. package/scripts/review-runner.test.mjs +14 -3
  123. package/scripts/review-tier-audit.test.mjs +1 -1
  124. package/scripts/run-merge-bot-prose.test.mjs +29 -6
  125. package/scripts/scratch-partition-invariant-prose.test.mjs +1 -1
  126. package/scripts/section-between-guard-prose.test.mjs +4 -3
  127. package/scripts/select-dimensions.test.mjs +1 -1
  128. package/scripts/shell-traps-prose.test.mjs +6 -9
  129. package/scripts/shortlist.mjs +4 -1
  130. package/scripts/shortlist.test.mjs +30 -16
  131. package/scripts/snapshot-repo.test.mjs +177 -4
  132. package/scripts/stash-prohibition-prose.test.mjs +1 -1
  133. package/scripts/temp-dir.mjs +47 -0
  134. package/scripts/tier-check.mjs +95 -28
  135. package/scripts/tier-check.test.mjs +131 -29
  136. package/scripts/tier-outcomes-header.test.mjs +11 -54
  137. package/scripts/tier-outcomes.mjs +34 -12
  138. package/scripts/tier-outcomes.test.mjs +157 -4
  139. package/scripts/tier-roles.mjs +118 -29
  140. package/scripts/tier-roles.test.mjs +226 -61
  141. package/scripts/tracker-block-copy-prose.test.mjs +3 -3
  142. package/scripts/verify-sha.test.mjs +4 -5
  143. package/scripts/watcher-degraded-block.test.mjs +5 -8
  144. package/scripts/within-run-pair-prose.test.mjs +43 -75
  145. package/scripts/worktree-audit.test.mjs +2 -1
  146. package/skills/next-ticket/SKILL.md +2 -2
  147. package/skills/run-team/SKILL.md +433 -303
  148. package/skills/run-team/references/ci-and-staleness.md +7 -6
  149. package/skills/run-team/references/correction-tickets.md +3 -3
  150. package/skills/run-team/references/isolation.md +1 -1
  151. package/skills/sizing-a-ticket/SKILL.md +8 -8
  152. package/scripts/tier-guard-gate-prose.test.mjs +0 -216
@@ -27,12 +27,13 @@ elsewhere. Tell members monitor event is wake-up, never verdict — they re-quer
27
27
  ## `no-ci`: absence is its own verdict, never green and never red
28
28
 
29
29
  Third verdict `ci-state.mjs` emits, alongside `green`/`not-green`. Only genuine
30
- absence earns it: no `.github/workflows/` directory, or one holding no workflow
31
- files. Every failure to *read* a workflow — directory unreadable, target
32
- unreadable, files present under names other than `--workflow`, two readable
33
- files sharing that name, no resolvable repo root — is exit 2, "could not be
34
- answered", never `no-ci`. So a repo whose CI is merely misconfigured can never
35
- borrow the declarable verdict.
30
+ absence earns it, judged at the PR's base commit: no `.github/workflows/`
31
+ directory there, or one holding no workflow files. Every failure to *read* a
32
+ workflow — the path not a directory, a workflow blob not read whole, files
33
+ present under names other than `--workflow`, two files sharing that name, no
34
+ GitHub repository gh resolves from the cwd's git remotes — is exit 2, "could
35
+ not be answered", never `no-ci`. So a repo whose CI is merely misconfigured
36
+ can never borrow the declarable verdict.
36
37
 
37
38
  Absence never means pass. `no-ci` alone exits **1**, same bucket as `not-green`
38
39
  — nothing to be green, and not red either. Exit 0 comes only with the caller's
@@ -1,8 +1,8 @@
1
1
  # Correction tickets ship new wrong claims
2
2
 
3
- Why ticket meant to correct fact tends to ship fresh wrong one, and why check belongs on implementer as much as reviewer. Two assertions in SKILL.md cite this: the Reviewers section, and phase 0 step 4's `class=correction` judgement. Evidence here.
3
+ Why ticket meant to correct fact tends to ship fresh wrong one, and why check belongs on implementer as much as reviewer. Evidence here.
4
4
 
5
- Nothing below measures a **model tier**. The four-for-four ran at one tier and this file records no comparison, so it cannot support a claim that either tier is better or worse for this class — step 4 cites it as a precaution and says so.
5
+ Nothing below measures a **model tier**. The four-for-four ran at one tier and this file records no comparison, so it cannot support a claim that either tier is better or worse.
6
6
 
7
7
  ## The four-for-four finding
8
8
 
@@ -20,7 +20,7 @@ Both were **positional references**: "the *closing* `report-file verification` b
20
20
 
21
21
  Ordinals also **fake their own verification**: the wrong ordinal named an assertion earlier than the real one, and **a failing assertion aborts the rest of its test** (true of `node --test` + `assert.*` here, not only of their runner) — so the obvious mutation (setting the workflow step under test to `if: ${{ always() }}`) reds the named assertion and never reaches the true one, appearing to confirm the wrong claim. One mutation cannot discriminate an ordinal: PR #32 measured that `always()` reds the named assertion, and only the narrower `always() && steps.mutate.outcome == 'success'` reds the true one.
22
22
 
23
- Two rules for the implementer, both cheap: **match the ticket's stated size** — added prose is where minted claims enter — and **never write a positional reference** (`the closing/second/last X`); name what the thing *is*, not where it sits.
23
+ Two rules for the implementer, both cheap: **write no prose the ticket did not ask for** — added prose is where minted claims enter — and **never write a positional reference** (`the closing/second/last X`); name what the thing *is*, not where it sits.
24
24
 
25
25
  ## The clause-by-clause duty
26
26
 
@@ -16,7 +16,7 @@ Private copy and test command solve different problems; conflating them is how s
16
16
 
17
17
  One flat namespace, generic filenames (`b.min.js`, `probe.mjs`) — one agent overwrote sibling's `package.json`. And finding ids restart at 1 every review, so two fix-appliers on different PRs both reach for `unv1`. Two levels, and nothing outside them — a probe built a git repo at the *checkout root*.
18
18
 
19
- The axis is two-sided: the member partitions, and the parent assigns each child's path. A member owns one directory — `<scratch>/impl-<N>/` for an implementer, `<scratch>/pr<N>/…` on the review side — and every agent it dispatches gets a directory under that one, unique to that child and never shared, written into the child's prompt as an absolute path; a child never derives its own. The review side is already laid out this way: `review-core.mjs` makes the run root `<scratch>/pr<N>/run-XXXXXXXX/` with `mktemp`, then writes `<run>/<dim>/` into each specialist's prompt and `<run>/verify-<dim>/f<i>-l<j>/` into each refuter's. A fix-applier makes its own run root the same way — `<scratch>/pr<N>/fix-XXXXXXXX/` with `mktemp` — then resolves `<run>/<finding>/` to an absolute path for the refuter it dispatches on a suggestion; the bare `<scratch>/pr<N>/<finding>/` is not that path, since finding ids restart at 1 each fix-applier round too, and a later round on the same PR would reach for the same directory a prior round's refuter left fixtures in. An implementer's child gets `<scratch>/impl-<N>/<childName>/`, named after its dispatch name. Refuters are grandchildren, not members, which is why the member partition alone is not the rule: the agents that actually collided were ones no member rule reaches, and a parent-assigned path is what reaches them. Read from the object store at a pinned ref, write only under own path.
19
+ The axis is two-sided: the member partitions, and the parent assigns each child's path. A member owns one directory — `<scratch>/impl-<N>/` for an implementer, `<scratch>/pr<N>/…` on the review side — and every agent it dispatches gets a directory under that one, unique to that child and never shared, written into the child's prompt as an absolute path; a child never derives its own. The review side is already laid out this way: `review-core.mjs` makes the run root `<scratch>/pr<N>/run-XXXXXXXX/` with `mktemp` — it appends `pr<N>/` to the scratch root it is handed and refuses a scratch already ending in one, so a review runner is given the root, never `<scratch>/pr<N>` — then writes `<run>/<dim>/` into each specialist's prompt and `<run>/verify-<dim>/f<i>-l<j>/` into each refuter's. A fix-applier makes its own run root the same way — `<scratch>/pr<N>/fix-XXXXXXXX/` with `mktemp` — then resolves `<run>/<finding>/` to an absolute path for the refuter it dispatches on a suggestion; the bare `<scratch>/pr<N>/<finding>/` is not that path, since finding ids restart at 1 each fix-applier round too, and a later round on the same PR would reach for the same directory a prior round's refuter left fixtures in. An implementer's child gets `<scratch>/impl-<N>/<childName>/`, named after its dispatch name. Refuters are grandchildren, not members, which is why the member partition alone is not the rule: the agents that actually collided were ones no member rule reaches, and a parent-assigned path is what reaches them. Read from the object store at a pinned ref, write only under own path.
20
20
 
21
21
  ## IDE/harness diagnostics attribute by bare filename, with no path
22
22
 
@@ -12,15 +12,15 @@ Read first: `gh issue view <N> --json title,body,comments --jq '.title, .body, (
12
12
 
13
13
  | Row | Signal | Path |
14
14
  |---|---|---|
15
- | **light** | States exactly what to change, one-two files, no design choice open | `superpowers:test-driven-development` |
16
- | **heavy** | Ambiguity in *what* to build, >~3 files, new API/schema/UX, or several viable approaches | `superpowers:brainstorming` → `superpowers:writing-plans` → `superpowers:subagent-driven-development` |
15
+ | **light** | States exactly what to change, one-two files, no design choice open | Test first, make the one change, run it with the repo's test runner |
16
+ | **heavy** | Ambiguity in *what* to build, >~3 files, new API/schema/UX, or several viable approaches | Write a short plan, then carry it out inline, test first |
17
17
 
18
- **Fleet member on heavy: enter at `superpowers:writing-plans`.**
19
- `superpowers:brainstorming` is the maintainer-present step — its `<HARD-GATE>`
20
- waits on user approval no unattended member gets, and a `ready-for-agent`
21
- ticket's `## Agent Brief` already is that output. Solo session has a user: run full path.
18
+ **Fleet member on heavy: write the plan under your own scratch path, `<scratch>/impl-<N>/`, then carry it out inline, test first.**
19
+ Heavy is never a reason to give up: a `ready-for-agent` ticket's `## Agent Brief`
20
+ already settles the open design choices, so plan from it. Solo session has a user:
21
+ settle the open design choices with them before planning.
22
22
 
23
- Bug reports: `superpowers:systematic-debugging` first, either row.
23
+ Bug reports, either row: reproduce with a failing test before fixing.
24
24
 
25
25
  Report row, path, one-line why. **Process depth only** — no admissibility call
26
26
  here, for anyone. Both rows workable, solo and in fleet; heavy means more process,
@@ -33,7 +33,7 @@ questions, two biases. Never carry this one across.
33
33
  ## Red flags
34
34
 
35
35
  - "Body is short, so it's simple" → short bodies hide most design ambiguity. Size by unknowns, not word count.
36
- - "Brainstorming is overkill here" → that thought is heavy row.
36
+ - "A plan is overkill here" → that thought is heavy row.
37
37
  - "The Agent Brief is thorough, so it's light now" → brief quality never promotes
38
38
  a heavy row *for process depth*. Says nothing about admissibility — thorough
39
39
  brief is exactly what makes big ticket safe to run unattended.
@@ -1,216 +0,0 @@
1
- // #528. Phase 3 is the only place in the loop that dispatches phase 2's tier
2
- // guard, so whatever it says the gate is IS the gate. It used to state one of
3
- // its own — "once three or more `class=routine` PRs have been ruled since the
4
- // last check" — which failed twice over: it is a second threshold beside phase
5
- // 2's, free to drift from it, and it keys on a set nothing on disk records. A
6
- // grep for any last-check marker over `skills` and `docs` returned only that
7
- // sentence itself, and `docs/metrics/tier-outcomes.tsv` has no check-state
8
- // column, so no controller could evaluate it and no marker would survive a
9
- // compaction.
10
- //
11
- // The same document already ruled against this shape one phase earlier: the
12
- // phase-2 guard rejects concluding inside one run and fires on the accumulated
13
- // file instead. This pins phase 3 to that same floor.
14
- //
15
- // WHERE THE GUARD RUNS (#1805, ADR 0005 as amended by ADR 0012). Its trigger
16
- // was the pool-empty event — "Pool empty → phase 0 again" — until the slot
17
- // loop retired both the pool and phase 0's re-entry. It now runs at every alt
18
- // Pull, before the alternate tier is chosen: the one dispatch the floor can
19
- // still change. Every pin below was moved with it, unchanged in what it bans.
20
- //
21
- // HOW THIS FILE WAS WRONG THE FIRST TIME (PR #1122 review, dimensions
22
- // `correctness` and `tests`, both reproduced by refuters). It pinned the duty as
23
- // four word-presence checks — /tier\s+guard/, /phase\s+2/, /floor/,
24
- // /accumulated/ — and banned two literal wordings. Measured GREEN against that:
25
- // a sentence NEGATING the duty ("Do NOT run phase 2's tier guard here, on the
26
- // floor phase 2 defines over the accumulated `…tsv` or otherwise"); one
27
- // rescoping the floor to the run in front of the controller ("over this run's
28
- // rows only rather than the accumulated `…tsv`"); phase 2's floor restated here
29
- // in a one-word paraphrase; an incremental key phrased "after the most recent
30
- // check"; and the counts "at least four", "more than three", "six or more" and
31
- // "3+". Every one of those is a fixture below now — but the lesson is the shape,
32
- // not the list: a presence check is satisfied by the sentence that repudiates
33
- // it, and a wording ban catches the wording it was written from and nothing
34
- // adjacent to it.
35
- //
36
- // So the duty is pinned as one wrap-tolerant PHRASE, and the two defect classes
37
- // are banned structurally — any count, not any comparator.
38
- //
39
- // THE PHRASE PIN IS DELIBERATELY TIGHT. Reflowing the paragraph stays green (the
40
- // accept test at the bottom flattens every wrap in the bullet and proves it);
41
- // rewording the sentence does not. That clause is #528's whole deliverable, so a
42
- // reword is exactly the moment someone should read this file. Reworded on
43
- // purpose → update the string in DUTY. Do not delete the pin to clear the red.
44
- //
45
- // THE CEILING: this proves phase 3 defers to phase 2's floor. It cannot prove
46
- // the floor itself is the right one — that lives in phase 2 and #528 left it
47
- // deliberately untouched.
48
- import { test } from "node:test";
49
- import assert from "node:assert/strict";
50
- import { readFileSync } from "node:fs";
51
- import { join } from "node:path";
52
- import { between, phrase, sentences } from "./prose-pin.mjs";
53
-
54
- const REPO = join(import.meta.dirname, "..");
55
- const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
56
-
57
- // Paragraph-tight, and bounded at both ends: widen this to the phase and the
58
- // tier-guard prose living elsewhere in phase 3 satisfies the pins on its own.
59
- // The start anchor is single-hit, so the slice cannot silently start elsewhere:
60
- // grep -c -- '\*\*Tier guards under Pull\.\*\*' skills/run-team/SKILL.md → 1
61
- const START = "**Tier guards under Pull.**";
62
- const gate = (text = RUN_TEAM) =>
63
- between(text, START, "**`--max-reviews <n>`", "run-team phase 3 tier guard under Pull");
64
-
65
- // The duty as a phrase, not as the words it is built from. `phrase` puts `\s+`
66
- // at every word gap, so a hard wrap landing anywhere inside it is fine, while
67
- // any rewriting of the claim — negation, rescoping, restatement — is not.
68
- const DUTY = phrase(
69
- "Run phase 2's tier guard before choosing the alternate tier, on the floor phase 2 defines over the accumulated `docs/metrics/tier-outcomes.tsv` and on no gate of this Pull's own",
70
- );
71
- // DUTY pins the imperative with its leading capital, so a mid-sentence "…do not
72
- // run phase 2's tier guard here" already fails it. This is the belt, for a
73
- // negation that capitalises.
74
- const NEGATED = /(?:\bnot|\bnever|n't)\s+run\b/i;
75
-
76
- // A count of the step's own. Every threshold is a count, whatever comparator it
77
- // wears — "at least three", "more than two", "six or more", "3+", "a further
78
- // four" — so ban the numbers and not the wordings; enumerating comparators is
79
- // what let four of those five through. Three spans in this bullet are counts of
80
- // nothing and are removed before the check, and nothing else is exempt:
81
- // `phase N` — how this step names the owner it defers to;
82
- // a backticked span — a path or identifier (`tier-outcomes.tsv`, `run_date`);
83
- // "the one that/which" — the pronoun, as in "drift from the one that governs".
84
- // CEILING: a count written inside backticks is exempt with them, and a threshold
85
- // stated with no number at all ("once a handful have queued") is not covered by
86
- // this or by any regex over prose.
87
- const countable = (text) =>
88
- text
89
- .replace(/`[^`]*`/g, " ")
90
- .replace(/\bphase\s+\d+\b/gi, " ")
91
- .replace(/\bthe one\s+(?=that\b|which\b)/gi, " ");
92
- const OWN_COUNT = /\b(?:one|two|three|four|five|six|seven|eight|nine|ten|\d+)\b/i;
93
-
94
- // A set nothing persists. The literal that shipped was "since the last check";
95
- // the shapes measured green against that literal were "since it was last
96
- // checked" (words between the halves) and "after the most recent check" (a
97
- // different preposition and a different recency word).
98
- // CEILING: this covers a since/after clause reaching a recency word, and a
99
- // "not yet <verb>ed" set. A recency set named without either — "the rows this
100
- // run appended" — is caught only when it displaces DUTY, which is where the
101
- // review's own within-run mutant was caught.
102
- //
103
- // Read one sentence at a time, via `sentences()`, with a gap that tolerates a
104
- // period — never a first-period `[^.]` window (#1983). The pin is NEGATIVE, so
105
- // a window cut short is its silent direction: an "e.g." or a `SKILL.md` between
106
- // "since" and "last" ended the old window before the recency word. The sentence
107
- // is what bounds the gap, so a "since" in one sentence never pairs with a
108
- // recency word in the next. RESIDUAL: sentences() still cuts short at a
109
- // `.)`, `."`, a mid-sentence `?`, a capitalised "E.g." or an "etc." (silent
110
- // here — none of those four is in this paragraph today), and still merges
111
- // two real sentences across #1987's `**late**.[1]` and #1899's
112
- // sentence-final lowercase "vs." (an over-fire here, also absent today).
113
- // `.**` itself IS in this slice once (its own opening bold lead), but that
114
- // boundary is a genuine sentence end, not one straddling the since/recency
115
- // pair this pin reads.
116
- const UNPERSISTED_SET =
117
- /\b(?:since|after)\b[\s\S]{0,40}\b(?:last|previous|prior|earlier|latest|most\s+recent)\b|\bnot\s+yet\s+\w+ed\b/i;
118
- const unpersisted = (slice) => sentences(slice).filter((s) => UNPERSISTED_SET.test(s));
119
-
120
- // Every pin in one place, so a fixture can assert WHICH ones fire rather than
121
- // that something somewhere went red — a pin that reddens on the wrong mutant has
122
- // discriminated nothing.
123
- const PINS = {
124
- duty: (slice) => !DUTY.test(slice),
125
- negation: (slice) => NEGATED.test(slice),
126
- count: (slice) => OWN_COUNT.test(countable(slice)),
127
- unpersisted: (slice) => unpersisted(slice).length > 0,
128
- };
129
- const firing = (slice) => Object.keys(PINS).filter((name) => PINS[name](slice));
130
-
131
- test("every alt Pull runs phase 2's tier guard against phase 2's floor", () => {
132
- const slice = gate();
133
- // Positive control against a vacuous pin: a stale start anchor that matched an
134
- // empty slice would pass every doesNotMatch below while asserting nothing.
135
- assert.ok(slice.length > START.length, "the tier-guard slice is no longer than its anchor — the extractor is broken, not the docs");
136
- assert.match(slice, DUTY, "the alt Pull no longer states, word for word, that it runs phase 2's tier guard on phase 2's accumulated floor and on no gate of its own — reworded on purpose? update DUTY. Do not delete it");
137
- assert.doesNotMatch(slice, NEGATED, "the alt Pull now says NOT to run the guard it is the only step that dispatches");
138
- });
139
-
140
- test("the alt-Pull gate states no count of its own", () => {
141
- // The drift direction: a second threshold here is a second definition, and
142
- // nothing makes the two move together.
143
- assert.doesNotMatch(countable(gate()), OWN_COUNT, "the alt-Pull gate has grown a count of its own beside phase 2's floor");
144
- });
145
-
146
- test("the alt-Pull gate keys on nothing that has to be remembered between runs", () => {
147
- assert.deepEqual(unpersisted(gate()), [], "the alt-Pull gate names a set nothing on disk records");
148
- });
149
-
150
- // The refuse direction. Entry one is the sentence #528 actually removed; the
151
- // rest are the shapes the PR #1122 review measured green against this file's
152
- // first pins. Each mutation asserts it changed the document before it is scored,
153
- // because a mutation that fails to apply is green in exactly the way a pin that
154
- // does not bite is green — and this file's prose wraps, so every search here is
155
- // a wrap-tolerant `phrase` rather than the line breaks it has today.
156
- const append = (sentence) => (text) =>
157
- text.replace(START, `${START} ${sentence}\n\n${START}`);
158
- // Built with `phrase`, not written out with the wraps the file happens to have
159
- // today: a fixture that hardcodes "\n" applies nothing the moment someone
160
- // reflows the paragraph, and its own notEqual guard then reddens a reflow the
161
- // accept test at the bottom promises is green.
162
- const PREDICATE_TAIL = phrase("on the floor phase 2 defines over the accumulated `docs/metrics/tier-outcomes.tsv` and on no gate of this Pull's own");
163
- const IMPERATIVE = phrase("Run phase 2's tier guard before choosing the alternate tier");
164
-
165
- const mutants = [
166
- ["the incremental gate #528 removed comes back", ["count", "unpersisted"],
167
- append("→ run the guard once three or more `class=routine` PRs have been ruled since the last check.")],
168
- ["phase 2's floor is restated here in a paraphrase", ["duty", "count"],
169
- (text) => text.replace(PREDICATE_TAIL, "on the floor over the accumulated `docs/metrics/tier-outcomes.tsv`: it holds at least three `class=routine` PRs spanning two distinct `run_date`s")],
170
- ["the duty is negated outright", ["duty", "negation"],
171
- (text) => text.replace(IMPERATIVE, "Do NOT run phase 2's tier guard before choosing the alternate tier")],
172
- ["the floor is rescoped to the run in front of the controller", ["duty"],
173
- (text) => text.replace(PREDICATE_TAIL, "on the floor phase 2 defines over this run's rows only rather than the accumulated `docs/metrics/tier-outcomes.tsv` it was written for")],
174
- ["an incremental key comes back in fresh wording", ["unpersisted"],
175
- append("Re-run it only for rows appended after the most recent check.")],
176
- ["a count no comparator list reaches", ["count"],
177
- append("Run it once six or more `class=routine` PRs have been ruled, or 3+ in a day.")],
178
- // #1983: a period in the gap ended the old `[^.]` window before the recency
179
- // word, and both of these were green.
180
- ["an incremental key comes back with an abbreviation in the gap", ["unpersisted"],
181
- append("Re-run it only for rows appended after, e.g., the most recent check.")],
182
- ["an incremental key comes back with a filename in the gap", ["unpersisted"],
183
- append("Re-run it only for rows appended since SKILL.md was last edited.")],
184
- ];
185
-
186
- for (const [what, expected, mutate] of mutants) {
187
- test(`the pins redden when ${what}`, () => {
188
- const mutated = mutate(RUN_TEAM);
189
- assert.notEqual(mutated, RUN_TEAM, `the "${what}" fixture no longer matches the paragraph and applied nothing — update the fixture, do not delete it`);
190
- assert.deepEqual(firing(gate(mutated)), expected, `the "${what}" fixture did not fire exactly the pins it is here to exercise`);
191
- });
192
- }
193
-
194
- test("a since/after in one sentence does not pair with the next sentence's recency word", () => {
195
- // The accept half of #1983's widening: the gap tolerates a period now, so the
196
- // SENTENCE is all that keeps the two halves apart. Benign, and red the moment
197
- // the scan reads the raw slice instead of `sentences()`.
198
- const mutated = append("It runs after each Pull's dispatch. The last word on the floor is phase 2's.")(RUN_TEAM);
199
- assert.notEqual(mutated, RUN_TEAM, "the accept fixture no longer matches the paragraph — update it");
200
- assert.deepEqual(firing(gate(mutated)), [], "a since/after paired with a recency word in the NEXT sentence");
201
- });
202
-
203
- test("reflowing the paragraph and editing it elsewhere stays green", () => {
204
- // The accept direction. A pin that reddens on any edit to the section has
205
- // discriminated nothing, and would be deleted by whoever next reflows this
206
- // paragraph. `between` returns raw text, so every pin above must tolerate a
207
- // line break landing anywhere in the prose it reads — this joins every wrap
208
- // inside it at once — and `phase 1` must not read as a count.
209
- const para = gate();
210
- const benign = RUN_TEAM.replace(para, () =>
211
- para
212
- .replace(/([^\n])\n(?=[^\n])/g, "$1 ")
213
- .replace("Nothing else in the loop owns it.", "Nothing else in the loop owns it. Re-enter phase 1 for each slot it opens."));
214
- assert.notEqual(benign, RUN_TEAM, "the benign-edit fixture no longer matches the paragraph — update it");
215
- assert.deepEqual(firing(gate(benign)), [], "a reflow plus an unrelated edit reddened a pin — the pins are over-tight, not the docs wrong");
216
- });