@feigi/fleet-ctl 3.23.36 → 3.23.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/cell-readout.mjs +38 -11
- package/scripts/main-checkout.mjs +1 -1
- package/scripts/member-write-guard.mjs +1 -1
- package/scripts/repo-root.mjs +1 -1
- package/skills/run-team/references/reaping.md +1 -1
- package/scripts/agent-test-dir-prose.test.mjs +0 -59
- package/scripts/agent-test.test.mjs +0 -1640
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
- package/scripts/ambient-git-vars-prose.test.mjs +0 -192
- package/scripts/ancestry-check-position-prose.test.mjs +0 -175
- package/scripts/apply-ruleset.test.mjs +0 -421
- package/scripts/arg-header-probes-prose.test.mjs +0 -394
- package/scripts/arg.test.mjs +0 -1354
- package/scripts/board-cli.test.mjs +0 -710
- package/scripts/board-identity.test.mjs +0 -429
- package/scripts/board-liveness-banner.test.mjs +0 -119
- package/scripts/board-prev-shape.test.mjs +0 -228
- package/scripts/board-tryparse-null.test.mjs +0 -119
- package/scripts/board.test.mjs +0 -3121
- package/scripts/brief-after-cut-prose.test.mjs +0 -53
- package/scripts/candidates-exit3-prose.test.mjs +0 -302
- package/scripts/candidates.test.mjs +0 -2312
- package/scripts/caveat-unification-prose.test.mjs +0 -98
- package/scripts/cell-readout.test.mjs +0 -615
- package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
- package/scripts/ci-completes-premise-prose.test.mjs +0 -257
- package/scripts/ci-state-prose.test.mjs +0 -113
- package/scripts/ci-state.test.mjs +0 -1933
- package/scripts/ci-vacuous-green.test.mjs +0 -368
- package/scripts/citation-sweep-prose.test.mjs +0 -1712
- package/scripts/claim-lifecycle.test.mjs +0 -187
- package/scripts/claim-ticket.test.mjs +0 -1122
- package/scripts/closing-keyword-prose.test.mjs +0 -193
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
- package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
- package/scripts/compute-board.test.mjs +0 -1214
- package/scripts/compute-spend.test.mjs +0 -517
- package/scripts/consumer-technology-prose.test.mjs +0 -126
- package/scripts/cross-repo-citation-prose.test.mjs +0 -155
- package/scripts/cwd-isolation-pins.mjs +0 -83
- package/scripts/dedupe-guard-prose.test.mjs +0 -243
- package/scripts/delete-merged-branch.test.mjs +0 -576
- package/scripts/derive-testcmd.test.mjs +0 -595
- package/scripts/diff-stats.test.mjs +0 -404
- package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
- package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
- package/scripts/dispositions-check.test.mjs +0 -936
- package/scripts/dispositions-gate-prose.test.mjs +0 -129
- package/scripts/drop-merged-label.test.mjs +0 -479
- package/scripts/exec-stub.mjs +0 -93
- package/scripts/exec-stub.test.mjs +0 -69
- package/scripts/expected-jobs-prose.test.mjs +0 -80
- package/scripts/fan-out-authorization-prose.test.mjs +0 -80
- package/scripts/filing-bar-seat-prose.test.mjs +0 -242
- package/scripts/filing-claim-bar-prose.test.mjs +0 -166
- package/scripts/finisher-died-prose.test.mjs +0 -31
- package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
- package/scripts/finisher-halt-prose.test.mjs +0 -106
- package/scripts/finisher-name-prose.test.mjs +0 -134
- package/scripts/finisher-own-tree-prose.test.mjs +0 -299
- package/scripts/finisher-pin-race-prose.test.mjs +0 -339
- package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
- package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
- package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
- package/scripts/fleet-bootstrap.test.mjs +0 -75
- package/scripts/fleet-heartbeat.test.mjs +0 -450
- package/scripts/fleet-provenance.test.mjs +0 -138
- package/scripts/fleet-run.test.mjs +0 -90
- package/scripts/fleet-state.test.mjs +0 -460
- package/scripts/fleet-tick-prose.test.mjs +0 -300
- package/scripts/fleet-tick.test.mjs +0 -2444
- package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
- package/scripts/frontmatter-check.test.mjs +0 -436
- package/scripts/git-env.test.mjs +0 -149
- package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
- package/scripts/gone-walk.test.mjs +0 -213
- package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
- package/scripts/head-moved-after-label-prose.test.mjs +0 -233
- package/scripts/immutable-body-claim-prose.test.mjs +0 -204
- package/scripts/implementer-model-tier.test.mjs +0 -235
- package/scripts/inflight-citation-prose.test.mjs +0 -144
- package/scripts/inflight-exit2-prose.test.mjs +0 -81
- package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
- package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
- package/scripts/inflight.test.mjs +0 -2882
- package/scripts/injection-control-prose.test.mjs +0 -404
- package/scripts/install-root-audit.test.mjs +0 -464
- package/scripts/instrument-check-prose.test.mjs +0 -235
- package/scripts/instruments.test.mjs +0 -787
- package/scripts/is-cli.test.mjs +0 -99
- package/scripts/issue-tracker-prose.test.mjs +0 -71
- package/scripts/json.test.mjs +0 -364
- package/scripts/ledger-dispatch.test.mjs +0 -927
- package/scripts/ledger-grammar.test.mjs +0 -227
- package/scripts/ledger-read-require-file.test.mjs +0 -197
- package/scripts/ledger-rotate.test.mjs +0 -142
- package/scripts/ledger.test.mjs +0 -3436
- package/scripts/line-distance-prose.test.mjs +0 -245
- package/scripts/liveness-rationale-prose.test.mjs +0 -83
- package/scripts/locale-pin-prose.test.mjs +0 -189
- package/scripts/main-checkout.test.mjs +0 -332
- package/scripts/member-outcome-prose.test.mjs +0 -167
- package/scripts/member-outcomes-header.test.mjs +0 -129
- package/scripts/member-outcomes-prose.test.mjs +0 -63
- package/scripts/member-outcomes.test.mjs +0 -638
- package/scripts/member-prompt-prose.test.mjs +0 -165
- package/scripts/member-record.test.mjs +0 -541
- package/scripts/member-write-guard.test.mjs +0 -214
- package/scripts/merge-commit-probe-prose.test.mjs +0 -122
- package/scripts/merge-gate.test.mjs +0 -613
- package/scripts/muted-git-guard-sweep.test.mjs +0 -493
- package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
- package/scripts/net-watchdog-prose.test.mjs +0 -79
- package/scripts/net.test.mjs +0 -211
- package/scripts/no-ci-gate-prose.test.mjs +0 -108
- package/scripts/no-undo-audit.test.mjs +0 -3961
- package/scripts/no-wave.test.mjs +0 -138
- package/scripts/node-floor-sweep.test.mjs +0 -611
- package/scripts/pointer-target-prose.test.mjs +0 -186
- package/scripts/pr-cost.test.mjs +0 -521
- package/scripts/pr-overlap.test.mjs +0 -692
- package/scripts/printf-die-sweep.test.mjs +0 -384
- package/scripts/prompt-renderer.mjs +0 -40
- package/scripts/prompt-renderer.test.mjs +0 -68
- package/scripts/prose-pin.mjs +0 -807
- package/scripts/prose-pin.test.mjs +0 -1034
- package/scripts/prove-merge.test.mjs +0 -995
- package/scripts/pull-table-relabel-prose.test.mjs +0 -60
- package/scripts/quiet-payload-prose.test.mjs +0 -222
- package/scripts/reap-cherry-check-prose.test.mjs +0 -80
- package/scripts/reap.test.mjs +0 -4432
- package/scripts/reaping-prose.test.mjs +0 -239
- package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
- package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
- package/scripts/recipe-derivation-prose.test.mjs +0 -112
- package/scripts/recipe-prove.test.mjs +0 -1042
- package/scripts/refuter-scratch-prose.test.mjs +0 -135
- package/scripts/release-label-required-prose.test.mjs +0 -71
- package/scripts/release-label-split-prose.test.mjs +0 -184
- package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
- package/scripts/release-ticket.test.mjs +0 -5099
- package/scripts/renovate-release-contract.test.mjs +0 -379
- package/scripts/repo-root.test.mjs +0 -873
- package/scripts/reporter-output-rule-prose.test.mjs +0 -208
- package/scripts/review-agent-report-only.test.mjs +0 -49
- package/scripts/review-core-booking.test.mjs +0 -35
- package/scripts/review-core-cwd-isolation.test.mjs +0 -374
- package/scripts/review-core-reads.test.mjs +0 -478
- package/scripts/review-core-refuter-scratch.test.mjs +0 -148
- package/scripts/review-core-scratch-refusal.test.mjs +0 -64
- package/scripts/review-core-shared-test-run.test.mjs +0 -275
- package/scripts/review-core-snapshot-path.test.mjs +0 -830
- package/scripts/review-core-specialist-scratch.test.mjs +0 -191
- package/scripts/review-core-testcmd.test.mjs +0 -335
- package/scripts/review-core-unrun.test.mjs +0 -566
- package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
- package/scripts/review-eval-resolver-path.test.mjs +0 -55
- package/scripts/review-host-fixture.mjs +0 -89
- package/scripts/review-in-run-retry.test.mjs +0 -211
- package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
- package/scripts/review-path-default.test.mjs +0 -796
- package/scripts/review-runner-spawns.test.mjs +0 -95
- package/scripts/review-runner.test.mjs +0 -166
- package/scripts/review-tier-audit.test.mjs +0 -140
- package/scripts/run-artifact-pr-prose.test.mjs +0 -341
- package/scripts/run-merge-bot-prose.test.mjs +0 -1413
- package/scripts/run-team-local-hook.test.mjs +0 -442
- package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
- package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
- package/scripts/section-between-guard-prose.test.mjs +0 -379
- package/scripts/select-dimensions.test.mjs +0 -674
- package/scripts/shared-refusal.test.mjs +0 -388
- package/scripts/shell-traps-prose.test.mjs +0 -504
- package/scripts/shortlist.test.mjs +0 -380
- package/scripts/slow-transport.mjs +0 -72
- package/scripts/snapshot-repo.test.mjs +0 -1006
- package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
- package/scripts/spend-view.test.mjs +0 -312
- package/scripts/staleness-qualifier-prose.test.mjs +0 -251
- package/scripts/staleness-verdict-prose.test.mjs +0 -142
- package/scripts/staleness.test.mjs +0 -893
- package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
- package/scripts/stash-prohibition-prose.test.mjs +0 -313
- package/scripts/strip-comments.mjs +0 -44
- package/scripts/temp-dir.mjs +0 -47
- package/scripts/ticket-router.test.mjs +0 -981
- package/scripts/tier-check.test.mjs +0 -828
- package/scripts/tier-outcomes-header.test.mjs +0 -518
- package/scripts/tier-outcomes.test.mjs +0 -572
- package/scripts/tier-roles.test.mjs +0 -535
- package/scripts/tracker-block-copy-prose.test.mjs +0 -288
- package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
- package/scripts/unattended-git-sweep.test.mjs +0 -142
- package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
- package/scripts/verify-sha.test.mjs +0 -692
- package/scripts/watcher-degraded-block.test.mjs +0 -369
- package/scripts/watcher-key-prose.test.mjs +0 -106
- package/scripts/within-run-pair-prose.test.mjs +0 -212
- package/scripts/worktree-audit.test.mjs +0 -1408
- package/scripts/worktree-head-prose.test.mjs +0 -276
- package/scripts/worktree-listing-sweep.test.mjs +0 -217
- package/scripts/worktree-model-prose.test.mjs +0 -216
- package/scripts/worktree-porcelain.mjs +0 -35
- package/scripts/worktree-porcelain.test.mjs +0 -102
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
// #393. A closing keyword immediately before an issue reference in a PR body
|
|
2
|
-
// creates a closing link, so narrative prose about what a pass already did is
|
|
3
|
-
// indistinguishable from a deliberate `Closes #N`. Two triage-authored PRs
|
|
4
|
-
// shipped one, and both were caught only because someone happened to check
|
|
5
|
-
// `closingIssuesReferences`.
|
|
6
|
-
//
|
|
7
|
-
// `docs/agents/issue-tracker.md` carries both remedies the ticket rules on —
|
|
8
|
-
// the guidance that prevents the common case and the check that catches a body
|
|
9
|
-
// nobody wrote to the guidance. This pins the parts of that section that decide
|
|
10
|
-
// BEHAVIOUR, so a later edit cannot leave the section looking complete with a
|
|
11
|
-
// rule silently gone or reversed.
|
|
12
|
-
//
|
|
13
|
-
// SHAPE, and the reason every pin below is one exact contiguous span rather
|
|
14
|
-
// than two matches on the same slice: N independent matches pin N facts and
|
|
15
|
-
// never the text between them, so a clause spliced into the join reverses a
|
|
16
|
-
// rule while every token an assertion wants is still present. The rules here
|
|
17
|
-
// are all joins — a mechanism bound to its fix, a surface bound to its
|
|
18
|
-
// exclusion — so each is asserted whole. `phrase()` rebuilds the span with
|
|
19
|
-
// `\s+` between words, which is what keeps an exact-span pin from reddening on
|
|
20
|
-
// a reflow; "a reflowed section still matches" below is what holds that open.
|
|
21
|
-
//
|
|
22
|
-
// THE CEILING: these prove a rule is PRESENT and unspliced. They cannot prove
|
|
23
|
-
// it is not negated by a sentence added elsewhere in the section, and they say
|
|
24
|
-
// nothing about whether the rule is correct.
|
|
25
|
-
import { test } from "node:test";
|
|
26
|
-
import assert from "node:assert/strict";
|
|
27
|
-
import { readFileSync } from "node:fs";
|
|
28
|
-
import { join } from "node:path";
|
|
29
|
-
import { between, phrase } from "./prose-pin.mjs";
|
|
30
|
-
|
|
31
|
-
const REPO = join(import.meta.dirname, "..", "..");
|
|
32
|
-
const TRACKER = readFileSync(join(REPO, "docs", "agents", "issue-tracker.md"), "utf8");
|
|
33
|
-
|
|
34
|
-
// Bounded at both ends. Run to EOF and the wayfinding section below supplies
|
|
35
|
-
// enough `gh`/issue vocabulary to satisfy a loose assertion with this section
|
|
36
|
-
// deleted outright; the heading that follows is the boundary, and `between()`
|
|
37
|
-
// reddens loudly if either anchor goes stale rather than widening the slice.
|
|
38
|
-
//
|
|
39
|
-
// Flattened, not raw: the source is hard-wrapped, so a pinned span breaks
|
|
40
|
-
// across lines at a width nobody should have to preserve. Every assertion below
|
|
41
|
-
// runs against the flattened text and is therefore reflow-safe.
|
|
42
|
-
const section = (text = TRACKER) =>
|
|
43
|
-
between(text, '## When a skill says "compose a PR body"', "\n## When a skill says", "docs/agents/issue-tracker.md")
|
|
44
|
-
.split(/\s+/)
|
|
45
|
-
.join(" ");
|
|
46
|
-
|
|
47
|
-
// Positive control. An equality-free suite of `match` assertions is exactly the
|
|
48
|
-
// shape that passes on a slice that has degenerated to its own heading, and a
|
|
49
|
-
// stale-but-still-findable anchor pair is how it would get there.
|
|
50
|
-
test("the section slice is more than its own heading", () => {
|
|
51
|
-
assert.ok(section().length > 200, "the slice collapsed to (near) its heading — the extractor is broken, not the docs");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test("the adjacency rule names its fix in the same breath", () => {
|
|
55
|
-
// The mechanism alone is not actionable and the fix alone is not derivable:
|
|
56
|
-
// an agent told only that adjacency links, or only to write `closed issue
|
|
57
|
-
// #N`, cannot generalize to the reference forms the rule actually covers.
|
|
58
|
-
// Asserted as one span so a spliced exception ("unless the issue is already
|
|
59
|
-
// closed") reddens rather than sliding between two matches.
|
|
60
|
-
assert.match(
|
|
61
|
-
section(),
|
|
62
|
-
phrase("immediately before an issue reference creates a closing link, and the fix is to insert a word: write `closed issue #219`, or name the issue without the `#`"),
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("the keyword list stays whole and stays bound to the mechanism", () => {
|
|
67
|
-
// The list is operationally load-bearing and reads like a tidy-up target: an
|
|
68
|
-
// agent narrating with a keyword that has silently dropped off it gets no
|
|
69
|
-
// signal that adjacency will auto-link. Pinned as one span with the clause it
|
|
70
|
-
// qualifies, so a list orphaned from its rule reddens too.
|
|
71
|
-
assert.match(
|
|
72
|
-
section(),
|
|
73
|
-
phrase("A closing keyword — `close`, `closes`, `closed`, `fix`, `fixes`, `fixed`, `resolve`, `resolves`, `resolved` — immediately before an issue reference"),
|
|
74
|
-
);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test("the preventive rule names what to do with every OTHER mention", () => {
|
|
78
|
-
// The cheapest of the two remedies, and the only one that prevents rather
|
|
79
|
-
// than detects. "Write one deliberate `Closes #N`" alone is not the rule —
|
|
80
|
-
// it is silent on the narrative mentions that caused both instances, so the
|
|
81
|
-
// deliberate keyword and the treatment of the rest are asserted as one span.
|
|
82
|
-
assert.match(
|
|
83
|
-
section(),
|
|
84
|
-
phrase("Write one deliberate `Closes #N` and give every other issue mention a word in front of it"),
|
|
85
|
-
);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test("the section records that one keyword does not chain across a list", () => {
|
|
89
|
-
// Without it, an author who fixes the reference they noticed leaves the rest
|
|
90
|
-
// of the list linked and reads the partial result as arbitrary rather than as
|
|
91
|
-
// the documented behaviour.
|
|
92
|
-
assert.match(section(), phrase("One keyword before a list links exactly the first reference, never the rest"));
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test("the section says to re-query the closing references and act on a mismatch", () => {
|
|
96
|
-
// "Re-query" without "compare against intent" is a command with no verdict,
|
|
97
|
-
// and both without "surface it" is a verdict nobody sees — this is the
|
|
98
|
-
// remedy that actually caught both historical instances, so the whole chain
|
|
99
|
-
// is pinned as one span.
|
|
100
|
-
assert.match(
|
|
101
|
-
section(),
|
|
102
|
-
phrase("re-query its closing references and compare them against what you meant to close, surfacing a mismatch rather than accepting it silently"),
|
|
103
|
-
);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test("the lazy-recompute caveat sits with the check it qualifies", () => {
|
|
107
|
-
// The check produces a false clean read without it, which is worse than no
|
|
108
|
-
// check: it converts "unverified" into "verified fine".
|
|
109
|
-
assert.match(
|
|
110
|
-
section(),
|
|
111
|
-
phrase("recomputes closing references lazily, so a query issued immediately after the create can read falsely clean — re-query after a pause"),
|
|
112
|
-
);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test("the section refuses a keyword regex as evidence on its own", () => {
|
|
116
|
-
// The false-POSITIVE half. Everything else here guards against a missed
|
|
117
|
-
// link; this guards against reporting one that GitHub never made, measured
|
|
118
|
-
// on a body whose keyword sits in a code span.
|
|
119
|
-
assert.match(
|
|
120
|
-
section(),
|
|
121
|
-
phrase("Compare a regex hit against the linked set before calling it a defect"),
|
|
122
|
-
);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test("the section binds the rule to PR bodies and commit messages and excludes issue comments", () => {
|
|
126
|
-
// A MAPPING: surface in, surface out. Pinning "PR bodies and commit
|
|
127
|
-
// messages" and "issue comment" as two matches leaves a swap — comments
|
|
128
|
-
// bound, bodies exempted — green with every token still present, so the
|
|
129
|
-
// sentence that carries the mapping is asserted whole.
|
|
130
|
-
assert.match(
|
|
131
|
-
section(),
|
|
132
|
-
phrase("Closing keywords bind in PR bodies and commit messages only. An issue comment may write the adjacency freely — it creates no link"),
|
|
133
|
-
);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
test("a reflowed section still matches", () => {
|
|
137
|
-
// The ACCEPT direction, and the only thing here proving the exact-span pins
|
|
138
|
-
// discriminate content rather than layout. A pin that reddened on a rewrap
|
|
139
|
-
// would be loosened by the next person who reflowed a paragraph, and a
|
|
140
|
-
// loosened span pin is the vacuous keyword pin this shape exists to avoid.
|
|
141
|
-
const rewrapped = TRACKER.replace("creates a closing link, and the fix", "creates a closing link,\nand the fix");
|
|
142
|
-
assert.notEqual(rewrapped, TRACKER, "the rewrap fixture no longer matches the section — update it");
|
|
143
|
-
assert.match(section(rewrapped), phrase("creates a closing link, and the fix is to insert a word"));
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
// #1118. The section above is reached only by a skill that says "compose a PR
|
|
147
|
-
// body", and the step that actually opens a PR — `next-ticket` step 7, which
|
|
148
|
-
// every implementer runs — never said it. The ruling put the rule in the step
|
|
149
|
-
// itself instead of a citation, so it is pinned where the PR is opened. Same
|
|
150
|
-
// anchors as force-with-lease-reason-prose.test.mjs's step-7 slice.
|
|
151
|
-
const NEXT_TICKET = readFileSync(join(REPO, "plugin", "skills", "next-ticket", "SKILL.md"), "utf8");
|
|
152
|
-
const step7 = (text = NEXT_TICKET) =>
|
|
153
|
-
between(text, "## 7. When the sizing-a-ticket path reports done", "## Red flags", "next-ticket/SKILL.md step 7");
|
|
154
|
-
|
|
155
|
-
test("next-ticket step 7 says one keyword per intended close, and that several such closes are fine", () => {
|
|
156
|
-
// The per-issue half and the multi-close example are one span: a rewrite to
|
|
157
|
-
// "only one closing keyword per body" is the plausible over-correction, and
|
|
158
|
-
// it forbids the deliberate `Closes #971, closes #864` this sentence allows.
|
|
159
|
-
assert.match(
|
|
160
|
-
step7(),
|
|
161
|
-
phrase("Write one `Closes #M` per issue you mean to close, so `Closes #971, closes #864` closes both"),
|
|
162
|
-
"step 7 lost the one-keyword-per-intended-close rule, or narrowed it so a deliberate multi-issue close reads as wrong",
|
|
163
|
-
);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test("next-ticket step 7 says what to do with every OTHER issue mention", () => {
|
|
167
|
-
assert.match(
|
|
168
|
-
step7(),
|
|
169
|
-
phrase("give every other issue mention a word in front of it — `closed issue #M`, or the issue named without the `#`"),
|
|
170
|
-
"step 7 no longer tells the author to put a word in front of issue mentions it does not mean to close",
|
|
171
|
-
);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
test("next-ticket step 7 says a keyword before a list links only its first reference", () => {
|
|
175
|
-
assert.match(
|
|
176
|
-
step7(),
|
|
177
|
-
phrase("A keyword before a list links only the first reference in that list, never the rest"),
|
|
178
|
-
"step 7 no longer says one keyword does not chain across a list",
|
|
179
|
-
);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
test("the step-7 pins survive a reflow of the rule", () => {
|
|
183
|
-
// The ACCEPT direction for the step-7 pins, as the section's reflow test is
|
|
184
|
-
// for the ones above.
|
|
185
|
-
const rewrapped = NEXT_TICKET.replace("per issue you mean to close, so", "per issue\nyou mean to close,\nso").replace(
|
|
186
|
-
"links only the first reference",
|
|
187
|
-
"links only\nthe first reference",
|
|
188
|
-
);
|
|
189
|
-
assert.notEqual(rewrapped, NEXT_TICKET, "the rewrap fixture no longer matches step 7 — update it");
|
|
190
|
-
const s = step7(rewrapped);
|
|
191
|
-
assert.match(s, phrase("Write one `Closes #M` per issue you mean to close, so `Closes #971, closes #864` closes both"));
|
|
192
|
-
assert.match(s, phrase("A keyword before a list links only the first reference in that list, never the rest"));
|
|
193
|
-
});
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
// #1586. Phase 0 step 0's cockpit-launch bullet was right about the symptom
|
|
2
|
-
// and wrong about the cause: a second launch finding the first one alive and
|
|
3
|
-
// exiting 0 is not an accident of "doing it anyway is harmless" — #1585 made
|
|
4
|
-
// that behaviour the DESIGN, an identity handshake on a held port with a
|
|
5
|
-
// bounded fallback scan, so the launch is idempotent PER WORKSPACE. The old
|
|
6
|
-
// wording still told the controller to gate the command to "the first
|
|
7
|
-
// phase-0 pass only" and to "skip" it on a later re-shortlist, which frames
|
|
8
|
-
// the reuse path as an accident worth avoiding rather than the rule. #39's
|
|
9
|
-
// multi-instance cockpit needs the opposite doctrine: run the launch on every
|
|
10
|
-
// re-shortlist, because reuse is cheap and a second workspace's launch never
|
|
11
|
-
// contends with the first — it derives a different port and serves its own
|
|
12
|
-
// board there.
|
|
13
|
-
//
|
|
14
|
-
// This file pins the REPLACEMENT doctrine and, separately, that the
|
|
15
|
-
// superseded "skip on later re-shortlists" framing is gone rather than left
|
|
16
|
-
// beside it (the plugin's prefer-moving rule) — so a revert back to the old
|
|
17
|
-
// wording, whole or partial, reds here even if it also keeps some of the new
|
|
18
|
-
// phrasing.
|
|
19
|
-
//
|
|
20
|
-
// Slice: `paragraph()`, `instrument-check-prose.test.mjs`'s own bound for the
|
|
21
|
-
// two sibling bullets immediately above this one in the same phase-0 step.
|
|
22
|
-
// Bounded at the anchor's own blank line, never widened to the whole step:
|
|
23
|
-
// step 0's OTHER two bullets ("Fast-forward the checkout", "Pin the
|
|
24
|
-
// instruments") talk about exit codes and staleness, not this bullet's
|
|
25
|
-
// claims, so an unbounded slice buys nothing extra and a bounded one is what
|
|
26
|
-
// keeps a decoy elsewhere in step 0 from satisfying these assertions.
|
|
27
|
-
//
|
|
28
|
-
// CEILING, shared with every prose pin in this repo: presence over a bounded
|
|
29
|
-
// slice proves the clause is STATED, not that a later sentence in the same
|
|
30
|
-
// bullet does not quietly carve out an exception. Measured — reverting this
|
|
31
|
-
// bullet to its pre-#1586 wording (`git show <base>:…` restored in place)
|
|
32
|
-
// reds every test below; the docs/specs design note this bullet does not
|
|
33
|
-
// cross-reference is untouched by either wording either way.
|
|
34
|
-
//
|
|
35
|
-
// PR #1664's own review amended the doctrine before merge: the idempotence
|
|
36
|
-
// claim is conditioned on the running cockpit ANSWERING the handshake;
|
|
37
|
-
// `--open` fires on the reuse arm too, so a re-shortlist reopens the board
|
|
38
|
-
// tab, reproduced directly; and the "own port" claim is softened — a
|
|
39
|
-
// derived-port collision (#1657) lands the second workspace on the next free
|
|
40
|
-
// port in its scan range, not its own derived one, though it still gets its
|
|
41
|
-
// own board. The tests below that name PR #1664 pin these amendments; the
|
|
42
|
-
// two existing tests they sit beside were tightened rather than replaced.
|
|
43
|
-
//
|
|
44
|
-
// #1713 then removed one of those amendments at the source rather than in
|
|
45
|
-
// the prose: the cockpit's tick no longer blocks its own HTTP server, so the
|
|
46
|
-
// caveat that a holder "blocked inside its own synchronous gather()" reads
|
|
47
|
-
// as foreign and gets duplicated is no longer true of any build this runbook
|
|
48
|
-
// describes. The paragraph stating it is deleted, and the test that pinned
|
|
49
|
-
// it is replaced below by one holding the deletion — a caveat that is false
|
|
50
|
-
// is worse than absent here, because it tells the controller to avoid the
|
|
51
|
-
// relaunch phase 0 now runs on every pass.
|
|
52
|
-
//
|
|
53
|
-
// #1714 removed another of those amendments the same way: the reuse arm no
|
|
54
|
-
// longer opens anything, `--open` or not — only the launch that binds a port
|
|
55
|
-
// and starts the server opens a tab — so a re-shortlist no longer reopens
|
|
56
|
-
// the board tab. The sentence saying it did is rewritten in the runbook, and
|
|
57
|
-
// the test that pinned it is deleted; board.test.mjs holds the behaviour,
|
|
58
|
-
// with stub launchers recording what each launch opened.
|
|
59
|
-
//
|
|
60
|
-
// Zero deps: `node --test plugin/scripts/cockpit-launch-idempotent-prose.test.mjs`.
|
|
61
|
-
|
|
62
|
-
import { test } from "node:test";
|
|
63
|
-
import assert from "node:assert/strict";
|
|
64
|
-
import { readFileSync } from "node:fs";
|
|
65
|
-
import { join } from "node:path";
|
|
66
|
-
import { paragraph, phrase } from "./prose-pin.mjs";
|
|
67
|
-
|
|
68
|
-
const REPO = join(import.meta.dirname, "..");
|
|
69
|
-
const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
|
|
70
|
-
|
|
71
|
-
// The whole bullet, bounded by its own blank line — the bound the two
|
|
72
|
-
// sibling bullets above it already use in `instrument-check-prose.test.mjs`.
|
|
73
|
-
const LAUNCH_STEP = () => paragraph(RUN_TEAM, "**Launch the cockpit.**", "run-team phase 0 cockpit-launch bullet");
|
|
74
|
-
|
|
75
|
-
test("phase 0 runs the cockpit launch on every pass, not just the first", () => {
|
|
76
|
-
const step = LAUNCH_STEP();
|
|
77
|
-
// The gate word itself, inverted: "only" on the first pass is exactly the
|
|
78
|
-
// instruction #1586 removes. Pinning the positive alone would stay green if
|
|
79
|
-
// a later edit restored a first-pass-only gate elsewhere in the sentence
|
|
80
|
-
// under different wording, so the negative below carries the real weight.
|
|
81
|
-
assert.match(step, phrase("On every phase-0 pass, not just the first"));
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test("phase 0 states the cockpit launch is idempotent per workspace, conditioned on the handshake answering", () => {
|
|
85
|
-
const step = LAUNCH_STEP();
|
|
86
|
-
// The doctrine statement itself — not a symptom description ("a second
|
|
87
|
-
// launch is harmless"), a stated design property ("idempotent"), scoped to
|
|
88
|
-
// the unit #39's multi-instance cockpit cares about ("per workspace").
|
|
89
|
-
assert.match(step, phrase("The launch is idempotent per workspace"));
|
|
90
|
-
// PR #1664 review (finding 1): unconditional idempotence overclaims — the
|
|
91
|
-
// reuse path exists only as far as the held port ANSWERS, so the doctrine
|
|
92
|
-
// states the condition rather than leaving it implicit. #1713 removed the
|
|
93
|
-
// one cause that made the condition bite in ordinary operation (a tick
|
|
94
|
-
// blocking its own server), which is why the caveat that followed this
|
|
95
|
-
// sentence is gone; the condition itself still holds — a cockpit stopped
|
|
96
|
-
// or wedged for any other reason answers nothing either.
|
|
97
|
-
assert.match(step, phrase("when the running cockpit answers the identity"));
|
|
98
|
-
// The mechanism the doctrine rests on, named rather than left implicit: an
|
|
99
|
-
// already-served workspace's launch finds the running server and exits 0
|
|
100
|
-
// instead of starting a second one.
|
|
101
|
-
assert.match(step, phrase("an already-served workspace's launch finds the"));
|
|
102
|
-
assert.match(step, phrase("exits 0 without starting a second one"));
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
test("the superseded mid-gather() duplication caveat is gone, not left beside the fixed behaviour", () => {
|
|
106
|
-
const step = LAUNCH_STEP();
|
|
107
|
-
// Verbatim phrases from the caveat #1713 made false. The cockpit answers
|
|
108
|
-
// HTTP throughout a tick now (gather()'s child reads are asynchronous), so
|
|
109
|
-
// a relaunch landing mid-tick is recognised and reused like any other —
|
|
110
|
-
// the plain no-op the sentence above already promises. Pinned as an
|
|
111
|
-
// ABSENCE for the same reason the skip-on-re-shortlist row below is: the
|
|
112
|
-
// plugin's prefer-moving rule means a superseded sentence is deleted, and
|
|
113
|
-
// a revert that restores it — in full, or pasted back beside the fixed
|
|
114
|
-
// doctrine — would send the controller round a hazard that no longer
|
|
115
|
-
// exists. cockpit-tick-nonblocking.test.mjs holds the behaviour itself.
|
|
116
|
-
for (const gone of [
|
|
117
|
-
"does not answer inside the probe window and reads",
|
|
118
|
-
"starts a second server sharing this workspace's",
|
|
119
|
-
"relaunching mid-gather is not the free no-op",
|
|
120
|
-
]) {
|
|
121
|
-
assert.doesNotMatch(step, phrase(gone),
|
|
122
|
-
`phase 0 warns about a mid-gather() duplicate again; #1713 made the cockpit answer throughout its tick, so the warning is false: ${gone}`);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test("phase 0 states a second workspace's launch derives its own port, falling back when it is held", () => {
|
|
127
|
-
const step = LAUNCH_STEP();
|
|
128
|
-
// The other half of #39's doctrine: idempotence is per WORKSPACE, not
|
|
129
|
-
// global, so a second fleet on a different workspace is not merely
|
|
130
|
-
// "unaffected" — it gets a board of its own. Pinning "collides with none of
|
|
131
|
-
// that" alone would be vacuous to a rewrite that dropped the affirmative
|
|
132
|
-
// claim and left only the negative, so both are asserted.
|
|
133
|
-
assert.match(step, phrase("A second fleet on another workspace collides with none of that"));
|
|
134
|
-
assert.match(step, phrase("its own launch derives that"));
|
|
135
|
-
assert.match(step, phrase("workspace's own port and binds it when free"));
|
|
136
|
-
// PR #1664 review (finding D): derived ports collide across workspaces at
|
|
137
|
-
// a real, non-negligible probability (#1657, filed and deferred
|
|
138
|
-
// separately) — the doctrine must not promise the derived port
|
|
139
|
-
// specifically, only that a board gets served either way.
|
|
140
|
-
assert.match(step, phrase("scans to the next free port in its range when the derived one is already held"));
|
|
141
|
-
assert.match(step, phrase("it gets its own board, just not always on the port its hash predicts"));
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
test("the old skip-on-re-shortlist framing is gone, not left beside its replacement", () => {
|
|
145
|
-
const step = LAUNCH_STEP();
|
|
146
|
-
// Verbatim phrases from the text #1586 replaced. Verified zero occurrences
|
|
147
|
-
// in the current file — the plugin's prefer-moving rule means the
|
|
148
|
-
// superseded sentence is DELETED, so a reword that restores either phrase
|
|
149
|
-
// (in full or copy-pasted back in beside the new doctrine) reds here.
|
|
150
|
-
assert.doesNotMatch(
|
|
151
|
-
step,
|
|
152
|
-
phrase("On the first phase-0 pass only"),
|
|
153
|
-
"the cockpit launch is gated to the first phase-0 pass again — #1586's per-workspace doctrine has been reverted",
|
|
154
|
-
);
|
|
155
|
-
assert.doesNotMatch(
|
|
156
|
-
step,
|
|
157
|
-
phrase("Skip on later re-shortlists"),
|
|
158
|
-
"phase 0 tells the controller to skip the cockpit launch on a later re-shortlist again — that is the exact defect #1586 closed",
|
|
159
|
-
);
|
|
160
|
-
assert.doesNotMatch(
|
|
161
|
-
step,
|
|
162
|
-
phrase("Doing it anyway is harmless rather than a collision"),
|
|
163
|
-
"the cockpit launch is framed as an accidentally-harmless collision again, rather than a per-workspace-idempotent design",
|
|
164
|
-
);
|
|
165
|
-
});
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
// #1713: the cockpit answers HTTP — `/board.json` included — while a tick is
|
|
2
|
-
// computing, and a relaunch that lands mid-tick therefore recognises it and
|
|
3
|
-
// reuses it instead of starting a duplicate.
|
|
4
|
-
//
|
|
5
|
-
// The defect this pins was a TIMING one, not a missing handshake. serve()
|
|
6
|
-
// ticked in-process on a timer and gather() read `gh`, `ledger.mjs` and
|
|
7
|
-
// `ci-state.mjs` through execFileSync, so for the 4.72–4.91s a board took to
|
|
8
|
-
// build (measured, #1713) the process answered nothing at all. A second
|
|
9
|
-
// launch's identity probe is PROBE_TIMEOUT_MS with one retry — ~2s in total —
|
|
10
|
-
// so a probe that landed inside a tick timed out, read the port as FOREIGN,
|
|
11
|
-
// stepped to the next candidate and started a second cockpit on the same
|
|
12
|
-
// workspace's `.fleet` directory. That is the duplicate #1585/#1660 exist to
|
|
13
|
-
// prevent, reached by a clock rather than by a missing payload, at a rate of
|
|
14
|
-
// roughly (4.8 − 2) / 15 relaunches.
|
|
15
|
-
//
|
|
16
|
-
// A separate file rather than more of board.test.mjs, for the reason
|
|
17
|
-
// board-identity.test.mjs and board-prev-shape.test.mjs both give: the fleet
|
|
18
|
-
// runs several implementers at once and two PRs appending to one test file
|
|
19
|
-
// conflict, which costs the PR its CI entirely.
|
|
20
|
-
//
|
|
21
|
-
// The DERIVED port, not `--port 0`: the reuse handshake is gated on
|
|
22
|
-
// `instance.derived` (an operator-chosen port never handshakes, by design),
|
|
23
|
-
// so an ephemeral bind cannot reach the behaviour under test at all.
|
|
24
|
-
|
|
25
|
-
import { test } from "node:test";
|
|
26
|
-
import assert from "node:assert/strict";
|
|
27
|
-
import { spawn, spawnSync } from "node:child_process";
|
|
28
|
-
import { symlinkSync, rmSync, realpathSync, existsSync } from "node:fs";
|
|
29
|
-
import { createServer } from "node:net";
|
|
30
|
-
import { tempDir } from "./temp-dir.mjs";
|
|
31
|
-
import { join } from "node:path";
|
|
32
|
-
import { fileURLToPath } from "node:url";
|
|
33
|
-
import { resolveCockpitInstance, cockpitPorts, probeCockpitWorkspace } from "./board.mjs";
|
|
34
|
-
import { gitEnv } from "./git-env.mjs";
|
|
35
|
-
import { writeExecStub } from "./exec-stub.mjs";
|
|
36
|
-
|
|
37
|
-
const SCRIPT = fileURLToPath(new URL("./board.mjs", import.meta.url));
|
|
38
|
-
|
|
39
|
-
// Long enough that the whole assertion window below — a probe bounded at 1s
|
|
40
|
-
// plus a second `node board.mjs serve` that has to start, resolve its
|
|
41
|
-
// workspace, fail a bind and handshake — sits comfortably inside one `gh`
|
|
42
|
-
// call, and far past the ~2s a probe spends before it gives up. The ticket
|
|
43
|
-
// names 5s for exactly that arithmetic.
|
|
44
|
-
const GH_SLEEP_S = 5;
|
|
45
|
-
|
|
46
|
-
// Only `gh issue list` is slowed, which is gather()'s FIRST gh read: that puts
|
|
47
|
-
// the block at a known point in the tick rather than spreading it over three
|
|
48
|
-
// calls, so the marker below means "inside gather()" and not merely "somewhere
|
|
49
|
-
// in a tick". Everything else fails immediately — tryRun catches and degrades,
|
|
50
|
-
// so the board still builds and nothing here touches the network.
|
|
51
|
-
//
|
|
52
|
-
// `/bin/sleep` by absolute path and `:` (a shell builtin) for the marker: PATH
|
|
53
|
-
// is stripped to the shim directory, so a bare `sleep` or a `touch` would fail
|
|
54
|
-
// ENOENT and the stub would answer instantly — a green test over a cockpit
|
|
55
|
-
// that was never slow.
|
|
56
|
-
const slowGh = (mark) => "#!/bin/sh\ncase \"$1 $2\" in\n"
|
|
57
|
-
+ `"issue list") : > ${JSON.stringify(mark)}; /bin/sleep ${GH_SLEEP_S}; exit 1 ;;\n`
|
|
58
|
-
+ "esac\nexit 1\n";
|
|
59
|
-
|
|
60
|
-
// git and the stub gh, nothing else. `node` is deliberately unreachable so
|
|
61
|
-
// gather()'s ledger read fails fast instead of shelling out to a real
|
|
62
|
-
// ledger.mjs — the same shim board-identity.test.mjs uses, and no row here
|
|
63
|
-
// asserts a ticket.
|
|
64
|
-
function shimPath(mark) {
|
|
65
|
-
const bin = tempDir("tick-bin-");
|
|
66
|
-
const real = spawnSync("sh", ["-c", "command -v git"], { encoding: "utf8" });
|
|
67
|
-
assert.equal(real.status, 0, "test setup: no git on PATH to shim, so the derived-port arm cannot be reached");
|
|
68
|
-
symlinkSync(real.stdout.trim(), join(bin, "git"));
|
|
69
|
-
writeExecStub(join(bin, "gh"), slowGh(mark));
|
|
70
|
-
return bin;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// realpath, not the bare mkdtemp path: on darwin $TMPDIR lives under /var,
|
|
74
|
-
// which is a symlink to /private/var, and resolveCockpitInstance canonicalises
|
|
75
|
-
// the workspace it derives.
|
|
76
|
-
function gitRepo(prefix) {
|
|
77
|
-
const dir = realpathSync(tempDir(prefix));
|
|
78
|
-
// GIT_DIR/GIT_WORK_TREE scrubbed off the fixture: under an ambient one `git
|
|
79
|
-
// init` exits 0 having re-inited whichever directory the variable names.
|
|
80
|
-
const init = spawnSync("git", ["init", "-q"], { cwd: dir, stdio: "ignore", env: gitEnv() });
|
|
81
|
-
assert.equal(init.status, 0, "test setup: git init must succeed");
|
|
82
|
-
return dir;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const withTimeout = (pr, ms, what) => Promise.race([
|
|
86
|
-
pr,
|
|
87
|
-
new Promise((_, rej) => setTimeout(() => rej(new Error(`timed out waiting for ${what}`)), ms).unref()),
|
|
88
|
-
]);
|
|
89
|
-
|
|
90
|
-
// HOME is redirected at every child: gatherSpend() scans $HOME for this cwd's
|
|
91
|
-
// omp session transcripts, and an empty directory keeps these runs off the
|
|
92
|
-
// machine's real session tree.
|
|
93
|
-
const childEnv = (bin, home) => ({ ...process.env, PATH: bin, HOME: home });
|
|
94
|
-
|
|
95
|
-
function serveProcess(cwd, bin, home) {
|
|
96
|
-
const p = spawn(process.execPath, [SCRIPT, "serve", "--interval", "3600"],
|
|
97
|
-
{ cwd, env: childEnv(bin, home), stdio: ["ignore", "ignore", "pipe"] });
|
|
98
|
-
p.stderr.setEncoding("utf8");
|
|
99
|
-
let buf = "";
|
|
100
|
-
const port = new Promise((res, rej) => {
|
|
101
|
-
p.stderr.on("data", (d) => {
|
|
102
|
-
buf += d;
|
|
103
|
-
const m = buf.match(/cockpit on http:\/\/localhost:(\d+)/);
|
|
104
|
-
if (m) res(Number(m[1]));
|
|
105
|
-
});
|
|
106
|
-
p.on("exit", (code) => rej(new Error(`serve exited (${code}) before announcing: ${buf}`)));
|
|
107
|
-
});
|
|
108
|
-
return { p, port, stderr: () => buf };
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// The first candidate this machine can actually bind — the derived port itself
|
|
112
|
-
// unless something outside this suite is sitting on it.
|
|
113
|
-
async function firstFreePort(ports) {
|
|
114
|
-
for (const p of ports) {
|
|
115
|
-
const free = await new Promise((res) => {
|
|
116
|
-
const probe = createServer();
|
|
117
|
-
probe.once("error", () => res(false));
|
|
118
|
-
probe.listen(p, () => probe.close(() => res(true)));
|
|
119
|
-
});
|
|
120
|
-
if (free) return p;
|
|
121
|
-
}
|
|
122
|
-
throw new Error(`test setup: no free port among ${ports.join(", ")}`);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async function until(what, ms, pred) {
|
|
126
|
-
const deadline = Date.now() + ms;
|
|
127
|
-
for (;;) {
|
|
128
|
-
const v = await pred();
|
|
129
|
-
if (v) return v;
|
|
130
|
-
if (Date.now() > deadline) throw new Error(`${what} did not happen within ${ms}ms`);
|
|
131
|
-
await new Promise((res) => setTimeout(res, 20));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const boardJson = async (port) => {
|
|
136
|
-
const res = await fetch(`http://localhost:${port}/board.json`);
|
|
137
|
-
if (!res.ok) { await res.arrayBuffer().catch(() => {}); return null; }
|
|
138
|
-
return res.json();
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// The whole ticket, end to end, in the order the defect happened: a cockpit is
|
|
142
|
-
// up, a tick is running, and a relaunch arrives while it runs.
|
|
143
|
-
//
|
|
144
|
-
// Every assertion here fails on the pre-#1713 build, and each for its own
|
|
145
|
-
// reason — measured against the synchronous gather(): the probe returns null
|
|
146
|
-
// after ~2s rather than the workspace in milliseconds, and the second launch
|
|
147
|
-
// reads the port as foreign, announces a cockpit of its own on the next
|
|
148
|
-
// candidate and never exits, so spawnSync reports the timeout instead of 0.
|
|
149
|
-
test("CLI: a relaunch that lands mid-gather() is answered within 1s and reuses the live cockpit", async () => {
|
|
150
|
-
const repo = gitRepo("tick-block-");
|
|
151
|
-
const mark = join(tempDir("tick-mark-"), "gathering");
|
|
152
|
-
const bin = shimPath(mark);
|
|
153
|
-
const home = tempDir("tick-home-");
|
|
154
|
-
const instance = resolveCockpitInstance({ cwd: repo, gitCommonDir: join(repo, ".git") });
|
|
155
|
-
const expected = await firstFreePort(cockpitPorts(instance));
|
|
156
|
-
const first = serveProcess(repo, bin, home);
|
|
157
|
-
try {
|
|
158
|
-
const port = await withTimeout(first.port, 20000, "the cockpit to announce");
|
|
159
|
-
// Not decoration: the second launch below scans this workspace's window in
|
|
160
|
-
// order, so a first launch that landed somewhere else would leave the
|
|
161
|
-
// reuse assertion passing for a reason this test does not name.
|
|
162
|
-
assert.equal(port, expected, "a launch with nothing in its way must take the port its workspace derives");
|
|
163
|
-
|
|
164
|
-
// The tick is now INSIDE `gh issue list`, which will not answer for
|
|
165
|
-
// GH_SLEEP_S. On the pre-#1713 build this is precisely the window in which
|
|
166
|
-
// the process answered nothing at all.
|
|
167
|
-
await until("gather() to reach its first gh read", 20000, async () => existsSync(mark));
|
|
168
|
-
|
|
169
|
-
// The launcher's own code path, not a hand-rolled fetch: what #1585's
|
|
170
|
-
// handshake asks is exactly what has to be answered here.
|
|
171
|
-
const started = Date.now();
|
|
172
|
-
const who = await probeCockpitWorkspace(expected);
|
|
173
|
-
const waited = Date.now() - started;
|
|
174
|
-
assert.equal(who, repo,
|
|
175
|
-
`a cockpit that cannot name its workspace mid-tick is read as foreign, which is how the duplicate starts (waited ${waited}ms)`);
|
|
176
|
-
assert.ok(waited < 1000,
|
|
177
|
-
`the identity came back in ${waited}ms; a launch's probe gives it PROBE_TIMEOUT_MS and this cockpit must answer inside that at all times`);
|
|
178
|
-
|
|
179
|
-
// AC 2: the second launch reuses the first cockpit — still mid-tick.
|
|
180
|
-
const second = spawnSync(process.execPath, [SCRIPT, "serve", "--interval", "3600"],
|
|
181
|
-
{ cwd: repo, encoding: "utf8", env: childEnv(bin, home), timeout: 30000 });
|
|
182
|
-
assert.equal(second.status, 0,
|
|
183
|
-
`the reuse path must exit 0 — a backgrounded launch reports nothing else: ${second.stderr}`);
|
|
184
|
-
assert.match(second.stderr, new RegExp(`already running for this workspace on http://localhost:${expected}/`), second.stderr);
|
|
185
|
-
assert.doesNotMatch(second.stderr, /cockpit on http/,
|
|
186
|
-
`a second cockpit was started for one workspace: ${second.stderr}`);
|
|
187
|
-
|
|
188
|
-
// …and all of the above really did happen inside the first tick. Without
|
|
189
|
-
// this the two assertions above would also pass on a build whose tick had
|
|
190
|
-
// simply finished first, which is the ordinary case and not this ticket's.
|
|
191
|
-
const midTick = await boardJson(expected);
|
|
192
|
-
assert.equal(midTick?.generatedAt, undefined,
|
|
193
|
-
"the first tick finished before the assertions above ran — they proved nothing about a mid-tick relaunch");
|
|
194
|
-
assert.equal(midTick?.workspace, repo, "the payload answered mid-tick is #1660's identity stub");
|
|
195
|
-
|
|
196
|
-
// The other half, and the one a merely-unblocked server could fail: the
|
|
197
|
-
// tick still LANDS, whole and atomically, once its reads return.
|
|
198
|
-
const built = await until("the first tick to publish a board", 30000, async () => {
|
|
199
|
-
const body = await boardJson(expected);
|
|
200
|
-
return typeof body?.generatedAt === "number" ? body : null;
|
|
201
|
-
});
|
|
202
|
-
assert.ok(Array.isArray(built.tickets), "the tick published something that is not a board");
|
|
203
|
-
assert.equal(built.workspace, repo);
|
|
204
|
-
assert.equal(built.port, expected);
|
|
205
|
-
assert.equal(first.p.exitCode, null, `the cockpit died during its own tick: ${first.stderr()}`);
|
|
206
|
-
} finally {
|
|
207
|
-
first.p.kill("SIGKILL");
|
|
208
|
-
for (const d of [bin, repo, home]) rmSync(d, { recursive: true, force: true });
|
|
209
|
-
}
|
|
210
|
-
});
|