@feigi/fleet-ctl 3.23.36 → 3.23.37

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 (204) hide show
  1. package/package.json +1 -1
  2. package/scripts/main-checkout.mjs +1 -1
  3. package/scripts/member-write-guard.mjs +1 -1
  4. package/scripts/repo-root.mjs +1 -1
  5. package/skills/run-team/references/reaping.md +1 -1
  6. package/scripts/agent-test-dir-prose.test.mjs +0 -59
  7. package/scripts/agent-test.test.mjs +0 -1640
  8. package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
  9. package/scripts/ambient-git-vars-prose.test.mjs +0 -192
  10. package/scripts/ancestry-check-position-prose.test.mjs +0 -175
  11. package/scripts/apply-ruleset.test.mjs +0 -421
  12. package/scripts/arg-header-probes-prose.test.mjs +0 -394
  13. package/scripts/arg.test.mjs +0 -1354
  14. package/scripts/board-cli.test.mjs +0 -710
  15. package/scripts/board-identity.test.mjs +0 -429
  16. package/scripts/board-liveness-banner.test.mjs +0 -119
  17. package/scripts/board-prev-shape.test.mjs +0 -228
  18. package/scripts/board-tryparse-null.test.mjs +0 -119
  19. package/scripts/board.test.mjs +0 -3121
  20. package/scripts/brief-after-cut-prose.test.mjs +0 -53
  21. package/scripts/candidates-exit3-prose.test.mjs +0 -302
  22. package/scripts/candidates.test.mjs +0 -2312
  23. package/scripts/caveat-unification-prose.test.mjs +0 -98
  24. package/scripts/cell-readout.test.mjs +0 -615
  25. package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
  26. package/scripts/ci-completes-premise-prose.test.mjs +0 -257
  27. package/scripts/ci-state-prose.test.mjs +0 -113
  28. package/scripts/ci-state.test.mjs +0 -1933
  29. package/scripts/ci-vacuous-green.test.mjs +0 -368
  30. package/scripts/citation-sweep-prose.test.mjs +0 -1712
  31. package/scripts/claim-lifecycle.test.mjs +0 -187
  32. package/scripts/claim-ticket.test.mjs +0 -1122
  33. package/scripts/closing-keyword-prose.test.mjs +0 -193
  34. package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
  35. package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
  36. package/scripts/compute-board.test.mjs +0 -1214
  37. package/scripts/compute-spend.test.mjs +0 -517
  38. package/scripts/consumer-technology-prose.test.mjs +0 -126
  39. package/scripts/cross-repo-citation-prose.test.mjs +0 -155
  40. package/scripts/cwd-isolation-pins.mjs +0 -83
  41. package/scripts/dedupe-guard-prose.test.mjs +0 -243
  42. package/scripts/delete-merged-branch.test.mjs +0 -576
  43. package/scripts/derive-testcmd.test.mjs +0 -595
  44. package/scripts/diff-stats.test.mjs +0 -404
  45. package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
  46. package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
  47. package/scripts/dispositions-check.test.mjs +0 -936
  48. package/scripts/dispositions-gate-prose.test.mjs +0 -129
  49. package/scripts/drop-merged-label.test.mjs +0 -479
  50. package/scripts/exec-stub.mjs +0 -93
  51. package/scripts/exec-stub.test.mjs +0 -69
  52. package/scripts/expected-jobs-prose.test.mjs +0 -80
  53. package/scripts/fan-out-authorization-prose.test.mjs +0 -80
  54. package/scripts/filing-bar-seat-prose.test.mjs +0 -242
  55. package/scripts/filing-claim-bar-prose.test.mjs +0 -166
  56. package/scripts/finisher-died-prose.test.mjs +0 -31
  57. package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
  58. package/scripts/finisher-halt-prose.test.mjs +0 -106
  59. package/scripts/finisher-name-prose.test.mjs +0 -134
  60. package/scripts/finisher-own-tree-prose.test.mjs +0 -299
  61. package/scripts/finisher-pin-race-prose.test.mjs +0 -339
  62. package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
  63. package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
  64. package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
  65. package/scripts/fleet-bootstrap.test.mjs +0 -75
  66. package/scripts/fleet-heartbeat.test.mjs +0 -450
  67. package/scripts/fleet-provenance.test.mjs +0 -138
  68. package/scripts/fleet-run.test.mjs +0 -90
  69. package/scripts/fleet-state.test.mjs +0 -460
  70. package/scripts/fleet-tick-prose.test.mjs +0 -300
  71. package/scripts/fleet-tick.test.mjs +0 -2444
  72. package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
  73. package/scripts/frontmatter-check.test.mjs +0 -436
  74. package/scripts/git-env.test.mjs +0 -149
  75. package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
  76. package/scripts/gone-walk.test.mjs +0 -213
  77. package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
  78. package/scripts/head-moved-after-label-prose.test.mjs +0 -233
  79. package/scripts/immutable-body-claim-prose.test.mjs +0 -204
  80. package/scripts/implementer-model-tier.test.mjs +0 -235
  81. package/scripts/inflight-citation-prose.test.mjs +0 -144
  82. package/scripts/inflight-exit2-prose.test.mjs +0 -81
  83. package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
  84. package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
  85. package/scripts/inflight.test.mjs +0 -2882
  86. package/scripts/injection-control-prose.test.mjs +0 -404
  87. package/scripts/install-root-audit.test.mjs +0 -464
  88. package/scripts/instrument-check-prose.test.mjs +0 -235
  89. package/scripts/instruments.test.mjs +0 -787
  90. package/scripts/is-cli.test.mjs +0 -99
  91. package/scripts/issue-tracker-prose.test.mjs +0 -71
  92. package/scripts/json.test.mjs +0 -364
  93. package/scripts/ledger-dispatch.test.mjs +0 -927
  94. package/scripts/ledger-grammar.test.mjs +0 -227
  95. package/scripts/ledger-read-require-file.test.mjs +0 -197
  96. package/scripts/ledger-rotate.test.mjs +0 -142
  97. package/scripts/ledger.test.mjs +0 -3436
  98. package/scripts/line-distance-prose.test.mjs +0 -245
  99. package/scripts/liveness-rationale-prose.test.mjs +0 -83
  100. package/scripts/locale-pin-prose.test.mjs +0 -189
  101. package/scripts/main-checkout.test.mjs +0 -332
  102. package/scripts/member-outcome-prose.test.mjs +0 -167
  103. package/scripts/member-outcomes-header.test.mjs +0 -129
  104. package/scripts/member-outcomes-prose.test.mjs +0 -63
  105. package/scripts/member-outcomes.test.mjs +0 -638
  106. package/scripts/member-prompt-prose.test.mjs +0 -165
  107. package/scripts/member-record.test.mjs +0 -541
  108. package/scripts/member-write-guard.test.mjs +0 -214
  109. package/scripts/merge-commit-probe-prose.test.mjs +0 -122
  110. package/scripts/merge-gate.test.mjs +0 -613
  111. package/scripts/muted-git-guard-sweep.test.mjs +0 -493
  112. package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
  113. package/scripts/net-watchdog-prose.test.mjs +0 -79
  114. package/scripts/net.test.mjs +0 -211
  115. package/scripts/no-ci-gate-prose.test.mjs +0 -108
  116. package/scripts/no-undo-audit.test.mjs +0 -3961
  117. package/scripts/no-wave.test.mjs +0 -138
  118. package/scripts/node-floor-sweep.test.mjs +0 -611
  119. package/scripts/pointer-target-prose.test.mjs +0 -186
  120. package/scripts/pr-cost.test.mjs +0 -521
  121. package/scripts/pr-overlap.test.mjs +0 -692
  122. package/scripts/printf-die-sweep.test.mjs +0 -384
  123. package/scripts/prompt-renderer.mjs +0 -40
  124. package/scripts/prompt-renderer.test.mjs +0 -68
  125. package/scripts/prose-pin.mjs +0 -807
  126. package/scripts/prose-pin.test.mjs +0 -1034
  127. package/scripts/prove-merge.test.mjs +0 -995
  128. package/scripts/pull-table-relabel-prose.test.mjs +0 -60
  129. package/scripts/quiet-payload-prose.test.mjs +0 -222
  130. package/scripts/reap-cherry-check-prose.test.mjs +0 -80
  131. package/scripts/reap.test.mjs +0 -4432
  132. package/scripts/reaping-prose.test.mjs +0 -239
  133. package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
  134. package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
  135. package/scripts/recipe-derivation-prose.test.mjs +0 -112
  136. package/scripts/recipe-prove.test.mjs +0 -1042
  137. package/scripts/refuter-scratch-prose.test.mjs +0 -135
  138. package/scripts/release-label-required-prose.test.mjs +0 -71
  139. package/scripts/release-label-split-prose.test.mjs +0 -184
  140. package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
  141. package/scripts/release-ticket.test.mjs +0 -5099
  142. package/scripts/renovate-release-contract.test.mjs +0 -379
  143. package/scripts/repo-root.test.mjs +0 -873
  144. package/scripts/reporter-output-rule-prose.test.mjs +0 -208
  145. package/scripts/review-agent-report-only.test.mjs +0 -49
  146. package/scripts/review-core-booking.test.mjs +0 -35
  147. package/scripts/review-core-cwd-isolation.test.mjs +0 -374
  148. package/scripts/review-core-reads.test.mjs +0 -478
  149. package/scripts/review-core-refuter-scratch.test.mjs +0 -148
  150. package/scripts/review-core-scratch-refusal.test.mjs +0 -64
  151. package/scripts/review-core-shared-test-run.test.mjs +0 -275
  152. package/scripts/review-core-snapshot-path.test.mjs +0 -830
  153. package/scripts/review-core-specialist-scratch.test.mjs +0 -191
  154. package/scripts/review-core-testcmd.test.mjs +0 -335
  155. package/scripts/review-core-unrun.test.mjs +0 -566
  156. package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
  157. package/scripts/review-eval-resolver-path.test.mjs +0 -55
  158. package/scripts/review-host-fixture.mjs +0 -89
  159. package/scripts/review-in-run-retry.test.mjs +0 -211
  160. package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
  161. package/scripts/review-path-default.test.mjs +0 -796
  162. package/scripts/review-runner-spawns.test.mjs +0 -95
  163. package/scripts/review-runner.test.mjs +0 -166
  164. package/scripts/review-tier-audit.test.mjs +0 -140
  165. package/scripts/run-artifact-pr-prose.test.mjs +0 -341
  166. package/scripts/run-merge-bot-prose.test.mjs +0 -1413
  167. package/scripts/run-team-local-hook.test.mjs +0 -442
  168. package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
  169. package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
  170. package/scripts/section-between-guard-prose.test.mjs +0 -379
  171. package/scripts/select-dimensions.test.mjs +0 -674
  172. package/scripts/shared-refusal.test.mjs +0 -388
  173. package/scripts/shell-traps-prose.test.mjs +0 -504
  174. package/scripts/shortlist.test.mjs +0 -380
  175. package/scripts/slow-transport.mjs +0 -72
  176. package/scripts/snapshot-repo.test.mjs +0 -1006
  177. package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
  178. package/scripts/spend-view.test.mjs +0 -312
  179. package/scripts/staleness-qualifier-prose.test.mjs +0 -251
  180. package/scripts/staleness-verdict-prose.test.mjs +0 -142
  181. package/scripts/staleness.test.mjs +0 -893
  182. package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
  183. package/scripts/stash-prohibition-prose.test.mjs +0 -313
  184. package/scripts/strip-comments.mjs +0 -44
  185. package/scripts/temp-dir.mjs +0 -47
  186. package/scripts/ticket-router.test.mjs +0 -981
  187. package/scripts/tier-check.test.mjs +0 -828
  188. package/scripts/tier-outcomes-header.test.mjs +0 -518
  189. package/scripts/tier-outcomes.test.mjs +0 -572
  190. package/scripts/tier-roles.test.mjs +0 -535
  191. package/scripts/tracker-block-copy-prose.test.mjs +0 -288
  192. package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
  193. package/scripts/unattended-git-sweep.test.mjs +0 -142
  194. package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
  195. package/scripts/verify-sha.test.mjs +0 -692
  196. package/scripts/watcher-degraded-block.test.mjs +0 -369
  197. package/scripts/watcher-key-prose.test.mjs +0 -106
  198. package/scripts/within-run-pair-prose.test.mjs +0 -212
  199. package/scripts/worktree-audit.test.mjs +0 -1408
  200. package/scripts/worktree-head-prose.test.mjs +0 -276
  201. package/scripts/worktree-listing-sweep.test.mjs +0 -217
  202. package/scripts/worktree-model-prose.test.mjs +0 -216
  203. package/scripts/worktree-porcelain.mjs +0 -35
  204. package/scripts/worktree-porcelain.test.mjs +0 -102
@@ -1,379 +0,0 @@
1
- // #753. `section()` was a name-invisible twin of prose-pin.mjs's exported
2
- // `between(text, from, to, what)`, duplicated byte-for-byte in
3
- // implementer-model-tier.test.mjs and review-path-default.test.mjs, and with
4
- // `RUN_TEAM` closed over instead of taken as an argument in
5
- // fleet-tick-prose.test.mjs, within-run-pair-prose.test.mjs, and
6
- // member-outcomes-prose.test.mjs. All five survived #751's own extraction
7
- // because every sweep of that PR searched for the NAME `between` — this one
8
- // searches for the SHAPE instead: `indexOf` -> `assert.notEqual(_, -1)` ->
9
- // `indexOf(_, at + from.length)` -> `assert.notEqual(_, -1)` -> `return
10
- // src.slice(at, end)`, the five statements `between()`'s body is built from,
11
- // independent of what the function, its parameters, or its captured
12
- // variables are called.
13
- //
14
- // NOT scoped to a reusable (parameterized) definition — an earlier revision
15
- // of this file was, on the theory that a closure over a module-level
16
- // constant is a distinct, already-blessed pattern (#608: "a file-local test
17
- // fixture... drift produced no false green and no wrong behaviour"). That
18
- // theory under-caught: within-run-pair-prose.test.mjs's own closure-shaped
19
- // `section(startAnchor, endAnchor, label)` is exactly as much a twin of
20
- // `between()` as the two parameterized copies were, and #608's own reasoning
21
- // is about a fixture with ONE consumer, not about whether the five
22
- // statements happen to close over an outer name instead of taking it as an
23
- // argument. The shape below no longer cares which.
24
- //
25
- // Two near-misses in this same directory are NOT twins, and must not match,
26
- // because each changes what the function DOES relative to `between()`
27
- // (measured against this file's own detector, not asserted):
28
- //
29
- // dispatch-block-pins-prose.test.mjs's `region()` and
30
- // finisher-pin-race-prose.test.mjs's `causeBlock()` both return
31
- // `SRC.slice(at + START.length, end)` — the start anchor STRIPPED, not
32
- // kept. `member-prompt-prose.test.mjs`'s inlined `memberBlocks()` was the
33
- // same divergence when #753 cited it: `between()` keeps the start anchor;
34
- // these need it gone, and swapping in `between()` un-stripped changes their
35
- // output. #1465 rewrote `memberBlocks()` onto `anchorAt()`/`phrase()`, so it
36
- // no longer has an `indexOf`/`assert.notEqual` shape at all and is excluded
37
- // from this file's own detector by construction, not by this near-miss.
38
- //
39
- // finisher-own-tree-prose.test.mjs's `between()` returns
40
- // `flat(RUN_TEAM.slice(at, to))` — flattened before return, not a bare
41
- // slice. Its own caller needs the flattening; a shared `between()` does not
42
- // do it and could not without changing every other caller's output too.
43
- //
44
- // cross-repo-citation-prose.test.mjs's `slice(text, startAnchor,
45
- // endAnchor, what, { endsFile })` threads an `if (end === -1 && endsFile)
46
- // return text.slice(at);` branch between the second `indexOf` and the
47
- // second `assert.notEqual` — the five statements are no longer adjacent,
48
- // and the function does something (`endsFile`'s EOF tolerance) `between()`
49
- // cannot.
50
- //
51
- // finisher-pin-race-prose.test.mjs's `fallbackSection()` and the `specialists()`
52
- // in `ed9f2967^:plugin/scripts/review-pr-citation-prose.test.mjs` looked like
53
- // two more —
54
- // a search from `at` instead of `at + start.length`, and a literal-anchor
55
- // call this detector cannot even see, respectively — but a before/after
56
- // byte comparison against their real inputs (RUN_TEAM / REVIEW_AND_FIX)
57
- // proved both output-identical to `between()`: neither pair's end anchor
58
- // ever occurs inside its own start anchor's text, so the narrower contract
59
- // `fallbackSection()`'s own header once claimed never actually diverges.
60
- // Both became `import { between }` call sites like every other consumer,
61
- // not documented exceptions.
62
- //
63
- // THE FLOOR: an empty or near-empty directory listing (a broken glob, or
64
- // this file moved to the wrong place) would make the main assertion below
65
- // pass vacuously — nothing scanned, nothing found. `SCRIPTS.length` is
66
- // asserted against a conservative floor to catch that before it hides a real
67
- // regression.
68
- import { test } from "node:test";
69
- import assert from "node:assert/strict";
70
- import { readdirSync, readFileSync } from "node:fs";
71
- import { join } from "node:path";
72
- import { stripComments } from "./strip-comments.mjs";
73
-
74
- const DIR = import.meta.dirname;
75
- const SELF = "section-between-guard-prose.test.mjs";
76
- const PROSE_PIN = "prose-pin.mjs";
77
-
78
- // The five statements `between()`'s body is built from, as one pattern:
79
- // const AT = SRC.indexOf(FROM);
80
- // assert.notEqual(AT, -1, ...);
81
- // const END = SRC.indexOf(TO, AT + FROM.length);
82
- // assert.notEqual(END, -1, ...);
83
- // return SRC.slice(AT, END);
84
- // captured over a `function name(...)` declaration, a `(...) => {` arrow
85
- // bound with `const`, `let`, or `var`, or a bare method-shorthand
86
- // `name(...) {` (the name position excludes the JS control-flow keywords —
87
- // `if`/`for`/`while`/`switch`/`catch`/`do`/`with`/`else` — so an ordinary
88
- // control-flow block is never mistaken for a twin), with every identifier
89
- // free to vary (matched by backreference, not by name) and free to be
90
- // either a parameter or a closed-over outer constant — `between`,
91
- // `section`, and any future reintroduction's own choice of names and
92
- // scoping all satisfy it identically. `const`, `let`, and `var` are all
93
- // accepted for the two inner declarations for the same reason: nothing
94
- // about the shape depends on which keyword binds `at` and `end`.
95
- // The exact offset (`AT + FROM.length`) in the second `indexOf` call used
96
- // to be mandatory. That meant an offset-less reintroduction — exactly
97
- // `fallbackSection()`'s own historical shape (a search from `AT` instead
98
- // of `AT + FROM.length`) — passed this detector completely undetected:
99
- // #1422 (item 2) measured this live, writing that exact historical shape
100
- // as a real scanned file and finding zero offenders reported, which is a
101
- // genuine detection gap, not a documented exclusion — the ticket's own
102
- // stated rationale is that this shape is exactly what the guard exists to
103
- // catch. Fixed here by making the offset argument optional rather than
104
- // mandatory: the second `indexOf` may now take no offset argument, a bare
105
- // `AT`, or the full `AT + FROM.length`, and all three still bind the same
106
- // two variable names. The dedicated `offsetOnly` positive control (see the
107
- // "fires" test below) isolates this on its own — everywhere else identical
108
- // to `between()` — and is now correctly flagged as a twin. The two
109
- // return-shape near-misses below (`strippedStart`, `flattenedReturn`)
110
- // remain excluded regardless, because their divergence is in the return
111
- // statement, not the offset.
112
- //
113
- // Comments are stripped before matching (`strip-comments.mjs`, the same
114
- // helper candidates.test.mjs and the review-pr-*.test.mjs pins already
115
- // share): this repo's own style routinely puts a `//` line between two of
116
- // the five statements (cross-repo-citation-prose.test.mjs), and the `\s*`
117
- // separators above do not span a real comment's text — measured directly,
118
- // an un-stripped scan misses a reintroduced twin written that way.
119
- // `strip-comments.mjs` only blanks WHOLE-LINE comments by design (its own
120
- // header's documented ceiling — candidates.test.mjs and the review-pr-*
121
- // pins depend on trailing comment text surviving); a TRAILING `stmt; //
122
- // note` therefore reaches TWIN_SHAPE unstripped. #1422: measured live, a
123
- // trailing-commented twin appended to a real scanned file passed the sweep
124
- // below undetected. Fixed here, not in the shared helper, with an optional
125
- // `(?:[ \t]*\/\/[^\n]*)?` after each of the five statements' own `;` —
126
- // scoped to this file's own separator so the shared helper's ceiling, and
127
- // everything measured against it, is untouched.
128
- //
129
- // SCOPE, and not reopened after this round: the shape above is matched
130
- // under function, const/let/var arrow, and method-shorthand declarations
131
- // and no others — generator functions, computed method names, decorators,
132
- // and any spelling past those are deliberately unattempted, because a
133
- // regex-based structural guard cannot enumerate every JS declaration syntax
134
- // and only needs to outlast the spellings a reintroduction has actually
135
- // taken, not every one it could someday take.
136
- //
137
- // KNOWN-OPEN, deliberately not chased this round (#1422's own boundary: a
138
- // test-only guard has diminishing returns from hunting every regex edge
139
- // case): a `//` comment on the declaration line right after the opening
140
- // `{`; a trailing `/* ... */` block comment in place of `//` after any of
141
- // the five statements; a `//` or `/* ... */` comment inside the second
142
- // `indexOf`'s own argument list, between `\5.length` and its closing `)`.
143
- // All three bypass this detector entirely — measured directly against the
144
- // regex below, not asserted. None occur in this repo's own style today
145
- // (see the `commented` and `trailingComment` fixtures above for the style
146
- // that does occur); revisit only if a real file is measured to use one.
147
- const TWIN_SHAPE = /(?:function\s+\w+\s*\(([^)]*)\)|(?:const|let|var)\s+\w+\s*=\s*\(([^)]*)\)\s*=>|\b(?!function\b|if\b|for\b|while\b|switch\b|catch\b|do\b|with\b|else\b)\w+\s*\((?:[^)]*)\))\s*\{\s*(?:const|let|var)\s+(\w+)\s*=\s*(\w+)\.indexOf\((\w+)\);(?:[ \t]*\/\/[^\n]*)?\s*assert\.notEqual\(\3,\s*-1,[\s\S]*?\);(?:[ \t]*\/\/[^\n]*)?\s*(?:const|let|var)\s+(\w+)\s*=\s*\4\.indexOf\((\w+)(?:,\s*\3(?:\s*\+\s*\5\.length)?)?\);(?:[ \t]*\/\/[^\n]*)?\s*assert\.notEqual\(\6,\s*-1,[\s\S]*?\);(?:[ \t]*\/\/[^\n]*)?\s*return\s+\4\.slice\(\3,\s*\6\);(?:[ \t]*\/\/[^\n]*)?\s*\}/g;
148
-
149
- /** Every `between()`-shaped definition in `text`, wherever it lives. */
150
- function twinDefinitions(text) {
151
- return [...stripComments(text).matchAll(TWIN_SHAPE)].map((m) => ({ src: m[4], from: m[5], to: m[7] }));
152
- }
153
-
154
- const SCRIPTS = readdirSync(DIR).filter((f) => f.endsWith(".mjs") && f !== SELF && f !== PROSE_PIN);
155
-
156
- test("the sweep sees the scripts it is supposed to police", () => {
157
- // A floor, not a count: this directory carries ~150 `.mjs` files today and
158
- // a regression here (an empty/near-empty listing) would make the twin
159
- // sweep below pass over nothing rather than over the tree.
160
- assert.ok(SCRIPTS.length >= 100, `expected the plugin/scripts .mjs files, found ${SCRIPTS.length}`);
161
- });
162
-
163
- test("the shape detector fires on the exact bodies #753 removed, by construction", () => {
164
- // Positive control, parameterized form (implementer-model-tier.test.mjs
165
- // and review-path-default.test.mjs's own removed shape).
166
- const parameterized = `
167
- function section(source, startAnchor, endAnchor, label) {
168
- const at = source.indexOf(startAnchor);
169
- assert.notEqual(at, -1, \`\${label}: '\${startAnchor}' moved\`);
170
- const end = source.indexOf(endAnchor, at + startAnchor.length);
171
- assert.notEqual(end, -1, \`\${label}: '\${endAnchor}' moved\`);
172
- return source.slice(at, end);
173
- }`;
174
- assert.deepEqual(twinDefinitions(parameterized), [{ src: "source", from: "startAnchor", to: "endAnchor" }]);
175
-
176
- // Positive control, closure form (fleet-tick-prose.test.mjs,
177
- // within-run-pair-prose.test.mjs, and member-outcomes-prose.test.mjs's own
178
- // removed shape) — the source text is a free variable, not a parameter,
179
- // and must fire exactly as readily.
180
- const closure = `
181
- const RUN_TEAM = "…";
182
- function section(startAnchor, endAnchor, label) {
183
- const at = RUN_TEAM.indexOf(startAnchor);
184
- assert.notEqual(at, -1, label);
185
- const end = RUN_TEAM.indexOf(endAnchor, at + startAnchor.length);
186
- assert.notEqual(end, -1, label);
187
- return RUN_TEAM.slice(at, end);
188
- }`;
189
- assert.deepEqual(twinDefinitions(closure), [{ src: "RUN_TEAM", from: "startAnchor", to: "endAnchor" }]);
190
-
191
- // prose-pin.mjs's own `between` — an arrow-function reintroduction under a
192
- // different name must be caught exactly as readily as a `function` one.
193
- const arrowForm = `
194
- const clone = (text, from, to, what) => {
195
- const at = text.indexOf(from);
196
- assert.notEqual(at, -1, what);
197
- const end = text.indexOf(to, at + from.length);
198
- assert.notEqual(end, -1, what);
199
- return text.slice(at, end);
200
- };`;
201
- assert.deepEqual(twinDefinitions(arrowForm), [{ src: "text", from: "from", to: "to" }]);
202
-
203
- // A `//` comment between two of the five statements, and `let` instead of
204
- // `const` for both inner declarations — this repo's own style
205
- // (cross-repo-citation-prose.test.mjs) and a measured miss: an earlier
206
- // revision of TWIN_SHAPE matched none of this against the unstripped
207
- // source.
208
- const commented = `
209
- function twin(text, from, to, what) {
210
- let at = text.indexOf(from);
211
- // explain why this search runs first
212
- assert.notEqual(at, -1, what);
213
- let end = text.indexOf(to, at + from.length);
214
- assert.notEqual(end, -1, what);
215
- return text.slice(at, end);
216
- }`;
217
- assert.deepEqual(twinDefinitions(commented), [{ src: "text", from: "from", to: "to" }]);
218
-
219
- // #1422: a TRAILING `//` comment on one of the five statement lines, not
220
- // a comment on its own line — `strip-comments.mjs` only blanks whole-line
221
- // comments (its own documented ceiling), so this reaches TWIN_SHAPE with
222
- // the comment text still attached to the statement. Measured miss: an
223
- // earlier revision of TWIN_SHAPE matched none of this. TWIN_SHAPE has a
224
- // separate optional trailing-comment allowance after each of its five
225
- // statements; each case below isolates one, so deleting any single
226
- // allowance turns exactly that one case red without disturbing the
227
- // other four — measured directly, one position at a time.
228
- const trailingCommentExpected = [{ src: "text", from: "from", to: "to" }];
229
- const trailingCommentCases = {
230
- "first indexOf": `
231
- function twin(text, from, to, what) {
232
- let at = text.indexOf(from); // note
233
- assert.notEqual(at, -1, what);
234
- let end = text.indexOf(to, at + from.length);
235
- assert.notEqual(end, -1, what);
236
- return text.slice(at, end);
237
- }`,
238
- "first assert.notEqual": `
239
- function twin(text, from, to, what) {
240
- let at = text.indexOf(from);
241
- assert.notEqual(at, -1, what); // note
242
- let end = text.indexOf(to, at + from.length);
243
- assert.notEqual(end, -1, what);
244
- return text.slice(at, end);
245
- }`,
246
- "second indexOf": `
247
- function twin(text, from, to, what) {
248
- let at = text.indexOf(from);
249
- assert.notEqual(at, -1, what);
250
- let end = text.indexOf(to, at + from.length); // note
251
- assert.notEqual(end, -1, what);
252
- return text.slice(at, end);
253
- }`,
254
- "second assert.notEqual": `
255
- function twin(text, from, to, what) {
256
- let at = text.indexOf(from);
257
- assert.notEqual(at, -1, what);
258
- let end = text.indexOf(to, at + from.length);
259
- assert.notEqual(end, -1, what); // note
260
- return text.slice(at, end);
261
- }`,
262
- return: `
263
- function twin(text, from, to, what) {
264
- let at = text.indexOf(from);
265
- assert.notEqual(at, -1, what);
266
- let end = text.indexOf(to, at + from.length);
267
- assert.notEqual(end, -1, what);
268
- return text.slice(at, end); // note
269
- }`,
270
- };
271
- for (const [label, source] of Object.entries(trailingCommentCases)) {
272
- assert.deepEqual(twinDefinitions(source), trailingCommentExpected, `trailing comment after ${label}`);
273
- }
274
-
275
- // Positive control, method-shorthand form — no real removed twin took
276
- // this shape, but a bare `name(...) { ... }` inside an object literal or
277
- // class must fire exactly as readily as a `function` declaration or an
278
- // arrow, and must not be confused with an ordinary control-flow block
279
- // (see the "does not fire" test below for that half of the guard).
280
- const methodShorthand = `
281
- const helper = {
282
- grab(text, from, to, what) {
283
- const at = text.indexOf(from);
284
- assert.notEqual(at, -1, what);
285
- const end = text.indexOf(to, at + from.length);
286
- assert.notEqual(end, -1, what);
287
- return text.slice(at, end);
288
- },
289
- };`;
290
- assert.deepEqual(twinDefinitions(methodShorthand), [{ src: "text", from: "from", to: "to" }]);
291
-
292
- // Positive control, `var`-declared form — both the arrow-style
293
- // declaration and the two inner offset variables must fire when bound
294
- // with `var` instead of `const`/`let`, the same reasoning carried one
295
- // keyword further.
296
- const varForm = `
297
- var twin = (text, from, to, what) => {
298
- var at = text.indexOf(from);
299
- assert.notEqual(at, -1, what);
300
- var end = text.indexOf(to, at + from.length);
301
- assert.notEqual(end, -1, what);
302
- return text.slice(at, end);
303
- };`;
304
- assert.deepEqual(twinDefinitions(varForm), [{ src: "text", from: "from", to: "to" }]);
305
-
306
- // Positive control, offset-less form — #1422: TWIN_SHAPE's second
307
- // `indexOf` used to require the `AT + FROM.length` offset exactly;
308
- // `fallbackSection()`'s own historical shape searched from `AT` alone
309
- // and reached this detector completely undetected (measured live: zero
310
- // offenders reported for that exact shape as a real scanned file). The
311
- // offset argument is now optional, so a bare `AT` (or no offset at all)
312
- // must fire exactly as readily as the full `AT + FROM.length` form,
313
- // while the return-shape near-misses below remain excluded.
314
- const offsetOnly = `
315
- function offsetless(text, from, to, what) {
316
- const at = text.indexOf(from);
317
- assert.notEqual(at, -1, what);
318
- const end = text.indexOf(to, at);
319
- assert.notEqual(end, -1, what);
320
- return text.slice(at, end);
321
- }`;
322
- assert.deepEqual(twinDefinitions(offsetOnly), [{ src: "text", from: "from", to: "to" }]);
323
- });
324
-
325
- test("the shape detector does not fire on the measured near-misses", () => {
326
- // Each changes one thing between() does not: stripped start anchor, or a
327
- // flattened return. See the header for which file each is modeled on.
328
- // Neither isolates the offset backreference on its own — that's the
329
- // `offsetOnly` positive control in the "fires" test above, now that the
330
- // offset argument is optional rather than mandatory.
331
- const strippedStart = `
332
- function region() {
333
- const at = RUN_TEAM.indexOf(START);
334
- assert.notEqual(at, -1, "x");
335
- const end = RUN_TEAM.indexOf(END, at);
336
- assert.notEqual(end, -1, "y");
337
- return RUN_TEAM.slice(at + START.length, end);
338
- }`;
339
- assert.deepEqual(twinDefinitions(strippedStart), []);
340
-
341
- const flattenedReturn = `
342
- function between(start, end) {
343
- const at = RUN_TEAM.indexOf(start);
344
- assert.notEqual(at, -1, "x");
345
- const to = RUN_TEAM.indexOf(end, at);
346
- assert.notEqual(to, -1, "y");
347
- return flat(RUN_TEAM.slice(at, to));
348
- }`;
349
- assert.deepEqual(twinDefinitions(flattenedReturn), []);
350
-
351
- // A control-flow block shaped exactly like the five statements must not
352
- // be mistaken for a method-shorthand twin — the third TWIN_SHAPE
353
- // alternative excludes JS keywords from the name position for exactly
354
- // this reason.
355
- const ifBlock = `
356
- if (x) {
357
- const at = RUN_TEAM.indexOf(x);
358
- assert.notEqual(at, -1, "x");
359
- const end = RUN_TEAM.indexOf(y, at + x.length);
360
- assert.notEqual(end, -1, "y");
361
- return RUN_TEAM.slice(at, end);
362
- }`;
363
- assert.deepEqual(twinDefinitions(ifBlock), []);
364
- });
365
-
366
- test("no file outside prose-pin.mjs defines a second between()-shaped slicer", () => {
367
- const offenders = [];
368
- for (const file of SCRIPTS) {
369
- const text = readFileSync(join(DIR, file), "utf8");
370
- for (const twin of twinDefinitions(text)) {
371
- offenders.push(`${file} (src: ${twin.src}, from: ${twin.from}, to: ${twin.to})`);
372
- }
373
- }
374
- assert.deepEqual(
375
- offenders,
376
- [],
377
- `reintroduced a between()-shaped slicer outside prose-pin.mjs — import { between } instead:\n${offenders.join("\n")}`,
378
- );
379
- });