@feigi/fleet-ctl 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +9 -0
- package/LICENSE +202 -0
- package/NOTICE +18 -0
- package/agents/fleet-finisher.agent.md +7 -0
- package/agents/fleet-implementer-alt.agent.md +210 -0
- package/agents/fleet-implementer.agent.md +210 -0
- package/agents/fleet-merge-bot.agent.md +7 -0
- package/agents/fleet-review-comments.agent.md +40 -0
- package/agents/fleet-review-correctness.agent.md +43 -0
- package/agents/fleet-review-runner.agent.md +73 -0
- package/agents/fleet-review-silent-failure.agent.md +49 -0
- package/agents/fleet-review-simplify.agent.md +46 -0
- package/agents/fleet-review-snapshot.agent.md +24 -0
- package/agents/fleet-review-tests.agent.md +46 -0
- package/agents/fleet-review-types.agent.md +41 -0
- package/agents/fleet-review-verifier.agent.md +29 -0
- package/commands/review-and-fix.md +98 -0
- package/commands/run-merge-bot.md +357 -0
- package/commands/run-team-help.md +17 -0
- package/package.json +23 -0
- package/scripts/agent-test-dir-prose.test.mjs +59 -0
- package/scripts/agent-test.test.mjs +1636 -0
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +354 -0
- package/scripts/ambient-git-vars-prose.test.mjs +192 -0
- package/scripts/ancestry-check-position-prose.test.mjs +175 -0
- package/scripts/apply-ruleset.test.mjs +420 -0
- package/scripts/arg-header-probes-prose.test.mjs +393 -0
- package/scripts/arg.mjs +600 -0
- package/scripts/arg.test.mjs +1354 -0
- package/scripts/board-cli.test.mjs +694 -0
- package/scripts/board-identity.test.mjs +429 -0
- package/scripts/board-liveness-banner.test.mjs +119 -0
- package/scripts/board-prev-shape.test.mjs +229 -0
- package/scripts/board-tryparse-null.test.mjs +119 -0
- package/scripts/board.html +471 -0
- package/scripts/board.mjs +2037 -0
- package/scripts/board.test.mjs +3086 -0
- package/scripts/brief-after-cut-prose.test.mjs +53 -0
- package/scripts/candidates-exit3-prose.test.mjs +302 -0
- package/scripts/candidates.mjs +674 -0
- package/scripts/candidates.test.mjs +2101 -0
- package/scripts/caveat-unification-prose.test.mjs +98 -0
- package/scripts/ci-comment-rot-prose.test.mjs +2025 -0
- package/scripts/ci-completes-premise-prose.test.mjs +257 -0
- package/scripts/ci-state-prose.test.mjs +113 -0
- package/scripts/ci-state.mjs +761 -0
- package/scripts/ci-state.test.mjs +1640 -0
- package/scripts/ci-vacuous-green.test.mjs +368 -0
- package/scripts/citation-sweep-prose.test.mjs +1572 -0
- package/scripts/claim-lifecycle.test.mjs +185 -0
- package/scripts/claim-ticket.sh +417 -0
- package/scripts/claim-ticket.test.mjs +1121 -0
- package/scripts/closing-keyword-prose.test.mjs +193 -0
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +165 -0
- package/scripts/cockpit-tick-nonblocking.test.mjs +210 -0
- package/scripts/compute-board.mjs +579 -0
- package/scripts/compute-board.test.mjs +1060 -0
- package/scripts/compute-spend.mjs +329 -0
- package/scripts/compute-spend.test.mjs +451 -0
- package/scripts/cross-repo-citation-prose.test.mjs +156 -0
- package/scripts/cwd-isolation-pins.mjs +83 -0
- package/scripts/dedupe-guard-prose.test.mjs +243 -0
- package/scripts/derive-testcmd.sh +239 -0
- package/scripts/derive-testcmd.test.mjs +380 -0
- package/scripts/diff-stats.mjs +231 -0
- package/scripts/diff-stats.test.mjs +408 -0
- package/scripts/dispatch-block-golden-prose.test.mjs +1024 -0
- package/scripts/dispatch-block-pins-prose.test.mjs +615 -0
- package/scripts/drop-merged-label.sh +173 -0
- package/scripts/drop-merged-label.test.mjs +480 -0
- package/scripts/expected-jobs-prose.test.mjs +80 -0
- package/scripts/filing-bar-seat-prose.test.mjs +242 -0
- package/scripts/filing-claim-bar-prose.test.mjs +166 -0
- package/scripts/finisher-dispatch-premise-prose.test.mjs +312 -0
- package/scripts/finisher-halt-prose.test.mjs +106 -0
- package/scripts/finisher-name-prose.test.mjs +134 -0
- package/scripts/finisher-own-tree-prose.test.mjs +285 -0
- package/scripts/finisher-pin-race-prose.test.mjs +339 -0
- package/scripts/fix-applier-correction-rules-prose.test.mjs +201 -0
- package/scripts/fix-applier-result-file-prose.test.mjs +100 -0
- package/scripts/fleet-bootstrap +155 -0
- package/scripts/fleet-heartbeat.mjs +272 -0
- package/scripts/fleet-heartbeat.test.mjs +450 -0
- package/scripts/fleet-provenance +207 -0
- package/scripts/fleet-provenance.test.mjs +64 -0
- package/scripts/fleet-run +148 -0
- package/scripts/fleet-run.test.mjs +90 -0
- package/scripts/fleet-state.mjs +400 -0
- package/scripts/fleet-state.test.mjs +373 -0
- package/scripts/fleet-tick-prose.test.mjs +299 -0
- package/scripts/fleet-tick.mjs +832 -0
- package/scripts/fleet-tick.test.mjs +1332 -0
- package/scripts/force-with-lease-reason-prose.test.mjs +184 -0
- package/scripts/frontmatter-allowlist.json +64 -0
- package/scripts/frontmatter-check.mjs +256 -0
- package/scripts/frontmatter-check.test.mjs +436 -0
- package/scripts/git-env.mjs +124 -0
- package/scripts/git-env.test.mjs +149 -0
- package/scripts/git-status-untracked-mode-sweep.test.mjs +216 -0
- package/scripts/gone-walk.test.mjs +213 -0
- package/scripts/gp-sep-invariant-prose.test.mjs +188 -0
- package/scripts/head-moved-after-label-prose.test.mjs +233 -0
- package/scripts/immutable-body-claim-prose.test.mjs +413 -0
- package/scripts/implementer-model-tier.test.mjs +643 -0
- package/scripts/inflight-citation-prose.test.mjs +144 -0
- package/scripts/inflight-exit2-prose.test.mjs +81 -0
- package/scripts/inflight-probe-guard-prose.test.mjs +109 -0
- package/scripts/inflight-scan-scope-prose.test.mjs +57 -0
- package/scripts/inflight.sh +1106 -0
- package/scripts/inflight.test.mjs +2984 -0
- package/scripts/injection-control-prose.test.mjs +404 -0
- package/scripts/install-root-audit.test.mjs +464 -0
- package/scripts/instrument-check-prose.test.mjs +235 -0
- package/scripts/instruments.sh +394 -0
- package/scripts/instruments.test.mjs +787 -0
- package/scripts/issue-tracker-prose.test.mjs +71 -0
- package/scripts/json.sh +248 -0
- package/scripts/json.test.mjs +364 -0
- package/scripts/ledger-dispatch.test.mjs +516 -0
- package/scripts/ledger-grammar.mjs +85 -0
- package/scripts/ledger-grammar.test.mjs +142 -0
- package/scripts/ledger-read-require-file.test.mjs +197 -0
- package/scripts/ledger.mjs +1753 -0
- package/scripts/ledger.test.mjs +3554 -0
- package/scripts/line-distance-prose.test.mjs +245 -0
- package/scripts/liveness-rationale-prose.test.mjs +83 -0
- package/scripts/locale-pin-prose.test.mjs +189 -0
- package/scripts/member-outcome-prose.test.mjs +167 -0
- package/scripts/member-outcomes-header.test.mjs +148 -0
- package/scripts/member-outcomes-prose.test.mjs +63 -0
- package/scripts/member-outcomes.mjs +231 -0
- package/scripts/member-outcomes.test.mjs +507 -0
- package/scripts/member-prompt-prose.test.mjs +161 -0
- package/scripts/member-record.mjs +605 -0
- package/scripts/member-record.test.mjs +516 -0
- package/scripts/member-write-guard.mjs +279 -0
- package/scripts/member-write-guard.test.mjs +211 -0
- package/scripts/merge-commit-probe-prose.test.mjs +122 -0
- package/scripts/merge-gate.mjs +262 -0
- package/scripts/merge-gate.test.mjs +613 -0
- package/scripts/muted-git-guard-sweep.test.mjs +493 -0
- package/scripts/net-ssh-precedence-prose.test.mjs +91 -0
- package/scripts/net-watchdog-prose.test.mjs +79 -0
- package/scripts/net.sh +409 -0
- package/scripts/net.test.mjs +211 -0
- package/scripts/no-ci-gate-prose.test.mjs +108 -0
- package/scripts/no-undo-audit.sh +1134 -0
- package/scripts/no-undo-audit.test.mjs +3965 -0
- package/scripts/no-wave.test.mjs +138 -0
- package/scripts/node-floor-sweep.test.mjs +611 -0
- package/scripts/pointer-target-prose.test.mjs +186 -0
- package/scripts/pr-overlap.mjs +417 -0
- package/scripts/pr-overlap.test.mjs +695 -0
- package/scripts/printf-die-sweep.test.mjs +384 -0
- package/scripts/prompt-renderer.mjs +39 -0
- package/scripts/prompt-renderer.test.mjs +68 -0
- package/scripts/prose-pin.mjs +808 -0
- package/scripts/prose-pin.test.mjs +1034 -0
- package/scripts/prove-merge.sh +228 -0
- package/scripts/prove-merge.test.mjs +995 -0
- package/scripts/pull-table-relabel-prose.test.mjs +60 -0
- package/scripts/quiet-payload-prose.test.mjs +222 -0
- package/scripts/reap.sh +1768 -0
- package/scripts/reap.test.mjs +4395 -0
- package/scripts/reaping-prose.test.mjs +159 -0
- package/scripts/refuter-scratch-prose.test.mjs +135 -0
- package/scripts/release-label-required-prose.test.mjs +71 -0
- package/scripts/release-label-split-prose.test.mjs +169 -0
- package/scripts/release-ticket.sh +1716 -0
- package/scripts/release-ticket.test.mjs +5106 -0
- package/scripts/renovate-release-contract.test.mjs +379 -0
- package/scripts/repo-root.mjs +544 -0
- package/scripts/repo-root.test.mjs +873 -0
- package/scripts/reporter-output-rule-prose.test.mjs +208 -0
- package/scripts/review-agent-report-only.test.mjs +49 -0
- package/scripts/review-core-cwd-isolation.test.mjs +374 -0
- package/scripts/review-core-reads.test.mjs +478 -0
- package/scripts/review-core-refuter-scratch.test.mjs +148 -0
- package/scripts/review-core-snapshot-path.test.mjs +777 -0
- package/scripts/review-core-specialist-scratch.test.mjs +189 -0
- package/scripts/review-core-testcmd.test.mjs +288 -0
- package/scripts/review-core-unrun.test.mjs +530 -0
- package/scripts/review-core-unverified-discriminant.test.mjs +208 -0
- package/scripts/review-core.mjs +1028 -0
- package/scripts/review-eval-resolver-path.test.mjs +55 -0
- package/scripts/review-eval.mjs +197 -0
- package/scripts/review-host-fixture.mjs +73 -0
- package/scripts/review-in-run-retry.test.mjs +187 -0
- package/scripts/review-no-vendor-dispatch.test.mjs +45 -0
- package/scripts/review-path-default.test.mjs +796 -0
- package/scripts/review-runner-spawns.test.mjs +93 -0
- package/scripts/review-runner.test.mjs +155 -0
- package/scripts/review-tier-audit.test.mjs +140 -0
- package/scripts/run-artifact-pr-prose.test.mjs +341 -0
- package/scripts/run-merge-bot-prose.test.mjs +1391 -0
- package/scripts/scratch-partition-invariant-prose.test.mjs +74 -0
- package/scripts/scripts-path-citation-sweep.test.mjs +73 -0
- package/scripts/section-between-guard-prose.test.mjs +378 -0
- package/scripts/select-dimensions.test.mjs +674 -0
- package/scripts/shared-refusal.test.mjs +388 -0
- package/scripts/shell-traps-prose.test.mjs +507 -0
- package/scripts/shortlist.mjs +355 -0
- package/scripts/shortlist.test.mjs +366 -0
- package/scripts/slow-transport.mjs +72 -0
- package/scripts/snapshot-repo.test.mjs +772 -0
- package/scripts/snapshot-runner-audience-prose.test.mjs +129 -0
- package/scripts/spend-view.test.mjs +312 -0
- package/scripts/staleness-qualifier-prose.test.mjs +251 -0
- package/scripts/staleness-verdict-prose.test.mjs +142 -0
- package/scripts/staleness.mjs +414 -0
- package/scripts/staleness.test.mjs +893 -0
- package/scripts/stalled-member-liveness-prose.test.mjs +219 -0
- package/scripts/stash-prohibition-prose.test.mjs +313 -0
- package/scripts/strip-comments.mjs +44 -0
- package/scripts/tier-check.mjs +468 -0
- package/scripts/tier-check.test.mjs +726 -0
- package/scripts/tier-guard-gate-prose.test.mjs +216 -0
- package/scripts/tier-outcomes-header.test.mjs +586 -0
- package/scripts/tier-outcomes.mjs +441 -0
- package/scripts/tier-outcomes.test.mjs +342 -0
- package/scripts/tier-roles.mjs +250 -0
- package/scripts/tier-roles.test.mjs +316 -0
- package/scripts/tracker-block-copy-prose.test.mjs +288 -0
- package/scripts/triage-labels-gloss-prose.test.mjs +97 -0
- package/scripts/unattended-git-sweep.test.mjs +142 -0
- package/scripts/verify-sha-exit2-prose.test.mjs +269 -0
- package/scripts/verify-sha.sh +117 -0
- package/scripts/verify-sha.test.mjs +693 -0
- package/scripts/watcher-degraded-block.test.mjs +372 -0
- package/scripts/watcher-key-prose.test.mjs +106 -0
- package/scripts/within-run-pair-prose.test.mjs +208 -0
- package/scripts/worktree-audit.sh +482 -0
- package/scripts/worktree-audit.test.mjs +1407 -0
- package/scripts/worktree-head-prose.test.mjs +276 -0
- package/scripts/worktree-listing-sweep.test.mjs +217 -0
- package/scripts/worktree-model-prose.test.mjs +216 -0
- package/scripts/worktree.sh +470 -0
- package/skills/next-ticket/SKILL.md +138 -0
- package/skills/run-team/SKILL.md +3603 -0
- package/skills/run-team/references/ci-and-staleness.md +75 -0
- package/skills/run-team/references/correction-tickets.md +37 -0
- package/skills/run-team/references/isolation.md +23 -0
- package/skills/run-team/references/member-lifecycle.md +73 -0
- package/skills/run-team/references/reaping.md +73 -0
- package/skills/sizing-a-ticket/SKILL.md +39 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { phrase } from "./prose-pin.mjs";
|
|
2
|
+
|
|
3
|
+
// The inherited-cwd rule's pinned spans (#1433, #1673), spelled once.
|
|
4
|
+
// review-core-cwd-isolation.test.mjs pins the rule into the prompts
|
|
5
|
+
// (scripts/review-core.mjs) against these spans rather than transcribing its
|
|
6
|
+
// own copy of the prose, so the pin and the prompt cannot silently drift
|
|
7
|
+
// apart the way two independent copies of the same wording would.
|
|
8
|
+
//
|
|
9
|
+
// Three spans are TEXT, not RegExps, because at least one caller pins each of
|
|
10
|
+
// them with the sentence that leads into it, passing `${leadIn} ${SPAN}`
|
|
11
|
+
// through phrase(). phrase() trims and joins every whitespace run as `\s+`, so
|
|
12
|
+
// the lead-in and the span stay one contiguous pin — never two assertions,
|
|
13
|
+
// never a free-text `.{0,N}` gap a spliced exception could fit into. The rest
|
|
14
|
+
// carry no lead-in anywhere and are exported ready to match.
|
|
15
|
+
|
|
16
|
+
// Part 1, the inherited cwd named as a tree not to write to. The three
|
|
17
|
+
// clauses have to arrive together or the rule is not the rule: "carries no
|
|
18
|
+
// working directory of its own" alone is a fact with no instruction; naming
|
|
19
|
+
// the controller's checkout alone reads as context; and "a relative path lands
|
|
20
|
+
// THERE" is the only clause that says what to do differently.
|
|
21
|
+
export const SPECIALIST_CWD =
|
|
22
|
+
"this dispatch carries no working directory of its own, so you begin wherever the controller's own review cell is standing — its checkout, the tree it reads instruments.sh, ci-state.mjs and every gate decision out of. A relative path in any command lands THERE, not in the snapshot and not in your scratch dir.";
|
|
23
|
+
export const REFUTER_CWD =
|
|
24
|
+
"this dispatch carries no working directory of its own, so you begin wherever the controller's own review cell is standing — its checkout, the tree it reads every gate decision out of — and a relative path in any command lands THERE.";
|
|
25
|
+
|
|
26
|
+
// Part 2, `pwd` first and the inherited directory a no-run zone. Both halves
|
|
27
|
+
// in one span: `pwd` with no consequence attached is a print statement, and "a
|
|
28
|
+
// no-run zone" naming no directory is unenforceable — the recorded failure is
|
|
29
|
+
// an agent that BELIEVED it was somewhere else, which only a printed path
|
|
30
|
+
// settles.
|
|
31
|
+
export const PWD_FIRST = phrase("Run `pwd` as your FIRST command and keep the path it prints; that directory is a no-run zone from then on");
|
|
32
|
+
|
|
33
|
+
// Part 2.5 (#1721): once PWD_FIRST fixes which directory the dispatch
|
|
34
|
+
// inherited, each prompt goes on to claim where the snapshot and scratch dir
|
|
35
|
+
// THEMSELVES are named as absolute paths — and the two dispatches word that
|
|
36
|
+
// claim differently, because the fact differs between them. The specialist
|
|
37
|
+
// prompt's scratch dir is only named several paragraphs LATER ("Scratch files
|
|
38
|
+
// go in ${snap.runRoot}/${d.key}/"), so its own claim has to stay
|
|
39
|
+
// location-neutral ("in this prompt") rather than "above" — "above" was false
|
|
40
|
+
// there until #1721 fixed it. The refuter prompt's scratch dir IS named
|
|
41
|
+
// earlier ("Scratch: ${snap.runRoot}/verify-${d.key}/..."), so "above" is
|
|
42
|
+
// accurate there and is not a synonym for the specialist's span: rewording
|
|
43
|
+
// either one to match the other would silently reintroduce #1721 in whichever
|
|
44
|
+
// dispatch changed. Measured at PR #1825's review: reverting the specialist
|
|
45
|
+
// prompt in ONE harness only, leaving the other on the fixed wording, left the
|
|
46
|
+
// entire suite green — nothing previously pinned past PWD_FIRST's "no-run
|
|
47
|
+
// zone from then on" on either dispatch.
|
|
48
|
+
export const SCRATCH_NAMED_SPECIALIST = phrase(
|
|
49
|
+
"and every command after it chains its own `cd` into the snapshot or into your scratch dir, both named in this prompt as absolute paths.",
|
|
50
|
+
);
|
|
51
|
+
export const SCRATCH_NAMED_REFUTER = phrase("and the snapshot and your scratch dir are both named above as absolute paths.");
|
|
52
|
+
|
|
53
|
+
// Part 3, the positive self-check. The audit command and the report contract
|
|
54
|
+
// are separate spans because they fail separately: a bare `--porcelain` is a
|
|
55
|
+
// silently WRONG audit (a `status.showUntrackedFiles=no` config makes it print
|
|
56
|
+
// nothing on a tree holding new files, which reads as clean), while a missing
|
|
57
|
+
// report contract is an audit nobody can read.
|
|
58
|
+
export const AUDIT_COMMAND =
|
|
59
|
+
"`git -C <that path> status --porcelain -uall` — the explicit untracked mode, never bare `--porcelain`, which a `status.showUntrackedFiles=no` config silences into a false clean.";
|
|
60
|
+
|
|
61
|
+
// The report contract. The field name is a capture group so a caller EXTRACTS
|
|
62
|
+
// it from the rendered prompt rather than transcribing it, and checks it
|
|
63
|
+
// against the schema that must carry it. Gaps are `\s+`, never literal spaces
|
|
64
|
+
// — this prose is hard-wrapped at ~78 columns, so every one of them may be a
|
|
65
|
+
// newline (measured: a literal-space version of this regex matched nothing).
|
|
66
|
+
// The two prompts phrase this two different ways ("Report the result in" /
|
|
67
|
+
// "Report it in") — one alternation between them, not two independent
|
|
68
|
+
// optionals, which would also admit the dead combination neither prompt
|
|
69
|
+
// writes ("Report the result it in").
|
|
70
|
+
export const REPORT_FIELD = /Report\s+(?:the\s+result|it)\s+in\s+`(\w+)`\s+as\s+one\s+line\s+beginning\s+`CWD-AUDIT:`/;
|
|
71
|
+
|
|
72
|
+
// Every state the audit line can take, and the clause that demands it on a
|
|
73
|
+
// clean run. A state a prompt cannot spell is a state it will not report, and
|
|
74
|
+
// an audit reported only when it finds something is indistinguishable from one
|
|
75
|
+
// never run.
|
|
76
|
+
export const AUDIT_STATES = ["clean", "dirty", "unrepo"];
|
|
77
|
+
export const auditLine = (state) => phrase(`\`CWD-AUDIT: ${state} <path>`);
|
|
78
|
+
export const EVERY_RUN = phrase("every run, clean or not");
|
|
79
|
+
|
|
80
|
+
// One marker, spelled once, or a controller grepping a review's payload for it
|
|
81
|
+
// finds half the reports — matched as a code span, since a reader cannot tell
|
|
82
|
+
// a bare literal from the prose around it.
|
|
83
|
+
export const CWD_AUDIT_MARKER = /`CWD-AUDIT:`/;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// #151. `ledger.mjs check` is the fleet's duplicate-filing guard, and #145
|
|
2
|
+
// rebuilt it into a real one — tracker query, `--state all`, overlap scoring,
|
|
3
|
+
// a warned failure mode, exit 3 on a tracker hit. The path that files most of a
|
|
4
|
+
// run's issues never called it: `review-and-fix.md` step 5 hand-rolled
|
|
5
|
+
// `gh issue list --search` and the file contained zero occurrences of "ledger".
|
|
6
|
+
// The measured 5x rediscovery of #114 came through that reviewer path — the
|
|
7
|
+
// filed row in #145's own fixture is tagged `(review-pr-108)` — so the guard
|
|
8
|
+
// had been improved on a path that was not the one producing duplicates.
|
|
9
|
+
//
|
|
10
|
+
// Two slices are pinned, because two different agents file issues and each
|
|
11
|
+
// reads only its own instructions: the reviewer/fix-applier gets step 5, and
|
|
12
|
+
// the finisher gets run-team's deferral-audit duty, whose "Not filed → file it"
|
|
13
|
+
// branch is a filing site of its own. A fix reaching only one leaves the other
|
|
14
|
+
// filing blind.
|
|
15
|
+
//
|
|
16
|
+
// The exit-code reading is pinned as tightly as the call itself, and for the
|
|
17
|
+
// opposite failure. `check` exits 0 for BOTH `clean` and `unverified`, so an
|
|
18
|
+
// instruction that reads exit 0 as a green light files over a tracker nobody
|
|
19
|
+
// read; and exit 2 is a usage error where nothing was checked at all, so an
|
|
20
|
+
// instruction that reads any non-zero as "duplicate" turns a deferral into a
|
|
21
|
+
// silent drop. Getting the guard called is half the fix; getting it read
|
|
22
|
+
// correctly is the other half.
|
|
23
|
+
//
|
|
24
|
+
// THE CEILING, same as fleet-tick-prose.test.mjs, issue-tracker-prose.test.mjs
|
|
25
|
+
// and refuter-scratch-prose.test.mjs: these are PRESENCE pins over a bounded
|
|
26
|
+
// slice. They prove a phrase is there and that the superseded instruction is
|
|
27
|
+
// not; they cannot prove a later sentence in the same slice does not carve out
|
|
28
|
+
// an exception. A reflow of the same words stays green by design.
|
|
29
|
+
import { test } from "node:test";
|
|
30
|
+
import assert from "node:assert/strict";
|
|
31
|
+
import { readFileSync } from "node:fs";
|
|
32
|
+
import { join } from "node:path";
|
|
33
|
+
import { between } from "./prose-pin.mjs";
|
|
34
|
+
|
|
35
|
+
const REPO = join(import.meta.dirname, "..");
|
|
36
|
+
const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
|
|
37
|
+
const REVIEW_AND_FIX = readFileSync(join(REPO, "commands", "review-and-fix.md"), "utf8");
|
|
38
|
+
|
|
39
|
+
// run-team's finisher duties are an indented ordered list, so a hard wrap puts
|
|
40
|
+
// leading spaces mid-phrase. Collapse whitespace so `\s+` spans a wrap.
|
|
41
|
+
const flat = (s) => s.replace(/\s+/g, " ");
|
|
42
|
+
|
|
43
|
+
// Flattened for the same reason as the run-team slices below. review-and-fix.md
|
|
44
|
+
// authors one long line per step today, so this is a no-op on the current file —
|
|
45
|
+
// but every pin here is a literal phrase with spaces in it, and the moment the
|
|
46
|
+
// file is wrapped, whichever pin a break happens to land inside reds on words
|
|
47
|
+
// that never changed. Measured at width 100: `never a dropped finding` split and
|
|
48
|
+
// reddened test 4 while 80/120/140 stayed green, i.e. the class is present in
|
|
49
|
+
// all five step-5 pins and line width merely samples which one fires.
|
|
50
|
+
const step5 = () => flat(between(REVIEW_AND_FIX, "5. File each deferred finding", "\n6. Diff-check green", "review-and-fix step 5"));
|
|
51
|
+
const finisherDeferrals = () =>
|
|
52
|
+
flat(between(RUN_TEAM, "**Confirm every deferral — and every claimed APPLY —", "Add `ready-to-merge`", "run-team finisher duty 2"));
|
|
53
|
+
|
|
54
|
+
test("step 5 files through ledger.mjs check, not its own gh search", () => {
|
|
55
|
+
const s = step5();
|
|
56
|
+
assert.match(s, /ledger\.mjs check/, "step 5 no longer calls the duplicate-filing guard");
|
|
57
|
+
// The superseded instruction, verbatim. Reverting to it is the exact
|
|
58
|
+
// regression this ticket exists to close, and the new text still names
|
|
59
|
+
// `gh issue list --search` (to rule it out), so only the old *phrasing*
|
|
60
|
+
// can be excluded here.
|
|
61
|
+
assert.doesNotMatch(
|
|
62
|
+
s,
|
|
63
|
+
/`gh issue list --search` first/,
|
|
64
|
+
"step 5 is back to hand-rolling its own dedupe search instead of calling ledger.mjs check",
|
|
65
|
+
);
|
|
66
|
+
// Presence of the call is not the same as being required by it. Measured
|
|
67
|
+
// GREEN on "run `ledger.mjs check` if you like" without this.
|
|
68
|
+
assert.doesNotMatch(
|
|
69
|
+
s,
|
|
70
|
+
/ledger\.mjs check[\s\S]{0,140}?(optional|if you like|may be skipped|need not)/i,
|
|
71
|
+
"step 5 turned the dedupe guard into a suggestion",
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("step 5 tells exit 1 from exit 3 — already filed this run vs a tracker hit", () => {
|
|
76
|
+
const s = step5();
|
|
77
|
+
assert.match(s, /\*\*1\*\*[^.]{0,60}already filed/i, "step 5 no longer says exit 1 means already filed in this run");
|
|
78
|
+
assert.match(s, /\*\*3\*\*[^.]{0,90}tracker/i, "step 5 no longer says exit 3 is a tracker hit");
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test("step 5 refuses to read exit 0 as a green light", () => {
|
|
82
|
+
// `check` exits 0 for `clean` and for `unverified` alike. An unreachable
|
|
83
|
+
// `gh` degrades to a ledger-only answer that prints TRACKER NOT CHECKED, and
|
|
84
|
+
// `verdict` on stdout is the only thing separating the two.
|
|
85
|
+
const s = step5();
|
|
86
|
+
assert.match(s, /Exit 0 is not automatically\s+"?safe to file"?/i, "step 5 no longer warns that exit 0 can mean unverified");
|
|
87
|
+
assert.match(s, /`verdict`/, "step 5 no longer points at the stdout field that separates clean from unverified");
|
|
88
|
+
assert.match(s, /TRACKER NOT CHECKED/, "step 5 no longer names the string an unread tracker prints");
|
|
89
|
+
assert.match(s, /\bunverified\b/, "step 5 no longer names the unverified verdict by its own value");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("step 5 does not let the guard turn a deferral into a drop", () => {
|
|
93
|
+
// The guard's own failure directions. Exit 2 is a usage error — nothing was
|
|
94
|
+
// checked, so reading it as a duplicate drops the finding; and a real
|
|
95
|
+
// duplicate is a comment on the existing issue, never a dropped finding.
|
|
96
|
+
const s = step5();
|
|
97
|
+
assert.match(s, /\*\*2\*\*[\s\S]{0,200}?never read it as a duplicate/i, "step 5 lets a usage error read as a duplicate, dropping the finding");
|
|
98
|
+
assert.match(s, /never a dropped finding/i, "step 5 no longer says a duplicate is a comment rather than a dropped deferral");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("step 5 cites a Run ledger section that exists in run-team", () => {
|
|
102
|
+
// Step 5 defers the full exit-code and `verdict` semantics rather than
|
|
103
|
+
// restating them — a cross-file citation that rots silently if the section
|
|
104
|
+
// is renamed, since neither file's prose fails on its own.
|
|
105
|
+
assert.match(step5(), /\*\*Run ledger\*\*/, "step 5 no longer defers the exit-code semantics to run-team's Run ledger section");
|
|
106
|
+
assert.match(RUN_TEAM, /^## Run ledger$/m, "run-team no longer has a `## Run ledger` section for step 5 to cite");
|
|
107
|
+
// And that section has to still carry what step 5 sends a reader there for.
|
|
108
|
+
// Flattened like the sibling below: the slice is hard-wrapped Markdown, so an
|
|
109
|
+
// un-flattened match reds on a pure reflow — the one thing the header at the
|
|
110
|
+
// top of this file promises stays green.
|
|
111
|
+
const runLedger = flat(between(RUN_TEAM, "## Run ledger", "\n## Report", "run-team Run ledger section"));
|
|
112
|
+
assert.match(runLedger, /`verdict` is `already-filed`, `tracker-hit`, `clean`, `soft-hit` or `unverified`/, "the cited section no longer enumerates the verdict values");
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("step 5's exit-code readings agree with the section it cites", () => {
|
|
116
|
+
// Step 5 cites run-team for the full semantics but states the reading of each
|
|
117
|
+
// code inline, because the agent acting on it is mid-filing and a second file
|
|
118
|
+
// read is a cost it will skip. Two copies of a number→meaning mapping drift,
|
|
119
|
+
// and neither file fails on its own when they do: each stays internally
|
|
120
|
+
// coherent while an agent reading one acts on the other's contract. So the
|
|
121
|
+
// numbers are pinned on BOTH sides — renumbering in either file alone reddens
|
|
122
|
+
// the suite, which is the only signal the split produces. One test per side,
|
|
123
|
+
// though, and this is not the one holding step 5: it reads RUN_TEAM only, and
|
|
124
|
+
// the step-5 side is pinned by "step 5 tells exit 1 from exit 3" above.
|
|
125
|
+
// Measured: `exit **3**` → `exit **4**` in review-and-fix.md alone reds that
|
|
126
|
+
// test and leaves this one green; the same edit in run-team alone inverts it.
|
|
127
|
+
const runLedger = flat(between(RUN_TEAM, "## Run ledger", "\n## Report", "run-team Run ledger section"));
|
|
128
|
+
assert.match(runLedger, /\*\*1\*\* already in this run's filed list/, "run-team no longer reads exit 1 as already filed this run — step 5 still does");
|
|
129
|
+
assert.match(runLedger, /\*\*2\*\* usage\s+error/, "run-team no longer reads exit 2 as a usage error — step 5 still does");
|
|
130
|
+
assert.match(runLedger, /\*\*3\*\* the ledger is clean but open or closed tracker issues match/, "run-team no longer reads exit 3 as a tracker hit — step 5 still does");
|
|
131
|
+
// The exit-0 hazard is the one both files must state, not merely agree on:
|
|
132
|
+
// it is the code that reads as permission.
|
|
133
|
+
assert.match(runLedger, /Exit 0 is not\s+automatically "safe to file"/, "the cited section no longer warns that exit 0 can mean unverified");
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test("both filing sites read soft-hit as rows to read rather than as permission", () => {
|
|
137
|
+
// `soft-hit` exits 0, which is the code an instruction is most likely to read
|
|
138
|
+
// as a green light — the same hazard `unverified` carries and the same reason
|
|
139
|
+
// it is pinned above. A verdict no caller understands is worse than the wrong
|
|
140
|
+
// verdict it replaced (#388), and there are two callers because two different
|
|
141
|
+
// agents file issues and each reads only its own instructions.
|
|
142
|
+
assert.match(step5(), /`soft-hit`[\s\S]{0,400}?read the rows/i, "step 5 names soft-hit without telling its reader to read the rows it printed");
|
|
143
|
+
const runLedger = flat(between(RUN_TEAM, "## Run ledger", "\n## Report", "run-team Run ledger section"));
|
|
144
|
+
assert.match(runLedger, /`soft-hit`[\s\S]{0,400}?read\s+them before filing/i, "the cited section names soft-hit without saying what to do about it");
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test("the finisher verifies a claimed APPLY against the branch diff, not the applier's word", () => {
|
|
148
|
+
// Duty 2 audits deferrals AND applies. The review ran against a snapshot cut
|
|
149
|
+
// before the fix-applier's edits existed, so nothing but the finisher ever
|
|
150
|
+
// checks that a claimed APPLY actually landed — measured once at five applies
|
|
151
|
+
// where the controller's hand-written list named three.
|
|
152
|
+
//
|
|
153
|
+
// ONE bounded span, not two presence pins: a pin on the claim sentence alone
|
|
154
|
+
// stays green with the verification command deleted, and a pin on the command
|
|
155
|
+
// alone stays green with the duty reworded into a suggestion. Bounded rather
|
|
156
|
+
// than exact so a reflow of the sentence between them survives, which is the
|
|
157
|
+
// ceiling this whole file already accepts.
|
|
158
|
+
assert.match(
|
|
159
|
+
finisherDeferrals(),
|
|
160
|
+
/\*\*A fix-applier's "applied" is a claim like any other\*\*.{0,200}?Confirm `git diff origin\/main\.\.\.HEAD` actually contains what it reported applying\./,
|
|
161
|
+
"duty 2 no longer requires the finisher to verify a claimed APPLY against the branch diff — an applier's \"applied\" becomes self-certifying and a dropped fix ships labelled",
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test("the finisher files its own deferrals through the same guard", () => {
|
|
166
|
+
// The finisher reaches `gh issue create` by a different route — auditing the
|
|
167
|
+
// reviewer's deferrals and filing whatever is missing — so it is precisely
|
|
168
|
+
// the agent most likely to re-file what a reviewer already filed.
|
|
169
|
+
assert.match(finisherDeferrals(), /ledger\.mjs check/, "the finisher's file-it branch no longer runs the dedupe guard");
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// ── Filers record what they file (#531) ──────────────────────────────────────
|
|
173
|
+
//
|
|
174
|
+
// `check`'s ledger arm — exit 1, `already-filed`, and the near-miss rows behind
|
|
175
|
+
// `soft-hit` — reads a `## Filed` list, and until #531 no filing site wrote to
|
|
176
|
+
// it: both sites ran `check` and then `gh issue create`, and the controller,
|
|
177
|
+
// which owned every ledger write, never files. So the arm had never held a row.
|
|
178
|
+
// The fix is the filer recording its own filing, under a ledger lock that lets
|
|
179
|
+
// a second kind of writer exist; these pin the instruction half of it.
|
|
180
|
+
const runLedger = () => flat(between(RUN_TEAM, "## Run ledger", "\n## Report", "run-team Run ledger section"));
|
|
181
|
+
const finisherReport = () =>
|
|
182
|
+
flat(between(RUN_TEAM, "4. Report you the label", "**Give the finisher the instrument", "run-team finisher duty 4"));
|
|
183
|
+
const fixApplierReport = () =>
|
|
184
|
+
flat(between(RUN_TEAM, "> Then report to the controller the pushed SHA", "**Deferring everything", "fix-applier report line"));
|
|
185
|
+
|
|
186
|
+
test("both filing sites run `ledger.mjs filed` right after `gh issue create`, under the subject they checked", () => {
|
|
187
|
+
// The subject is half of it: `check` matches the filed list by the words in
|
|
188
|
+
// the subject, so a filing recorded under different words is one the next
|
|
189
|
+
// `check` for the same finding can only score as a near miss, never exit 1.
|
|
190
|
+
const s = step5();
|
|
191
|
+
assert.match(s, /immediately after each `gh issue create`, run `[^`]*ledger\.mjs filed <N> "<subject>"`/, "step 5 no longer records the issue it just created");
|
|
192
|
+
assert.match(s, /the same subject string you passed to `check`/, "step 5 no longer ties the recorded subject to the one it checked");
|
|
193
|
+
const f = finisherDeferrals();
|
|
194
|
+
assert.match(f, /`ledger\.mjs filed <N> "<subject>"` immediately after `gh issue create`/, "the finisher's file-it branch no longer records the issue it created");
|
|
195
|
+
assert.match(f, /the same subject string you passed to `check`/, "the finisher no longer ties the recorded subject to the one it checked");
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test("a failed `filed` is retried once, then reported unrecorded — never a second issue", () => {
|
|
199
|
+
// The issue exists and is correct once `gh issue create` returned; only its
|
|
200
|
+
// ledger row is missing. Re-filing to "fix" that makes the duplicate the
|
|
201
|
+
// whole guard exists to stop.
|
|
202
|
+
for (const [where, s] of [["step 5", step5()], ["finisher duty 2", finisherDeferrals()]]) {
|
|
203
|
+
assert.match(s, /retry (it )?once/, `${where} no longer retries a failed \`filed\``);
|
|
204
|
+
assert.match(s, /leave the issue alone — it exists and is correct/, `${where} no longer says to leave a created issue alone`);
|
|
205
|
+
assert.match(s, /`unrecorded: #N <subject>`/, `${where} no longer reports a filing it could not record`);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test("both report contracts carry `filed: #N <subject>` and the `unrecorded:` fallback", () => {
|
|
210
|
+
for (const [where, s] of [["fix-applier report", fixApplierReport()], ["finisher duty 4", finisherReport()], ["step 5", step5()]]) {
|
|
211
|
+
assert.match(s, /`filed: #N <subject>`/, `${where} no longer returns the issues it filed`);
|
|
212
|
+
}
|
|
213
|
+
for (const [where, s] of [["fix-applier report", fixApplierReport()], ["finisher duty 4", finisherReport()]]) {
|
|
214
|
+
assert.match(s, /`unrecorded: #N <subject>`/, `${where} no longer carries the unrecorded fallback`);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test("the controller records every filing a filer reported unrecorded", () => {
|
|
219
|
+
// The fallback is only a fallback if someone acts on it: an `unrecorded:`
|
|
220
|
+
// line nobody turns into a `filed` row leaves the arm exactly as blind as
|
|
221
|
+
// before, one filing at a time.
|
|
222
|
+
const table = between(RUN_TEAM, "| Wake | Record, then tick |", "\n\n", "record-before-tick table");
|
|
223
|
+
for (const wake of ["Fix-applier report", "Finisher report", "Finisher report (halted)"]) {
|
|
224
|
+
const row = table.split("\n").find((r) => r.startsWith(`| ${wake} |`)) ?? "";
|
|
225
|
+
assert.match(row, /`ledger\.mjs filed <N> "<subject>"` for each `unrecorded:` line/, `the "${wake}" wake no longer records unrecorded filings`);
|
|
226
|
+
}
|
|
227
|
+
assert.match(runLedger(), /reports `unrecorded: #N <subject>` instead, and you run `filed` for it/, "the Run ledger section no longer hands unrecorded filings to the controller");
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test("the Run ledger section states the writer policy and the check→create gap; step 5 states the gap too", () => {
|
|
231
|
+
const r = runLedger();
|
|
232
|
+
assert.match(
|
|
233
|
+
r,
|
|
234
|
+
/the controller owns run state \(`row`\/`settle`\/`dispatch`\/`drain`\/`ruled`\); filers append filings with `filed`; all writes are serialized by `<file>\.lock`/,
|
|
235
|
+
"the Run ledger section no longer states who writes what, and that the lock serializes it",
|
|
236
|
+
);
|
|
237
|
+
// The lock covers each command alone. Stated at the section and at the
|
|
238
|
+
// filing site, so neither reader takes the lock for a reservation.
|
|
239
|
+
for (const [where, s] of [["Run ledger", r], ["step 5", step5()]]) {
|
|
240
|
+
assert.match(s, /`check` → `gh issue create` → `filed` is three commands/, `${where} no longer states the check→create gap`);
|
|
241
|
+
assert.match(s, /both read `clean`/, `${where} no longer says what the gap lets through`);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Read one command of a repository's proven Recipe out of its Recipe cache:
|
|
3
|
+
# `install` (the Install step) or `test` (the Test entrypoint). ADR 0015.
|
|
4
|
+
#
|
|
5
|
+
# The fleet keeps no table of technologies. A Recipe is DERIVED by an agent
|
|
6
|
+
# reasoning over the repository and PROVEN before it is written — the Install
|
|
7
|
+
# step ran in a fresh worktree and left the tree clean, the Test entrypoint ran
|
|
8
|
+
# and showed real tests — so this script infers nothing. A missing cache is a
|
|
9
|
+
# refusal naming the step that derives one, never a guess: a guessed command
|
|
10
|
+
# that passes vacuously reads as a green suite to every consumer, which is the
|
|
11
|
+
# #142 hazard the old inference already refused over.
|
|
12
|
+
#
|
|
13
|
+
# The ONE reader of the cache — reused, not reimplemented, by claim-ticket.sh
|
|
14
|
+
# (the Install step it runs and the Test entrypoint it bakes into the runner)
|
|
15
|
+
# and by review-core.mjs's snapshot agent (the Test entrypoint handed to the
|
|
16
|
+
# specialists). Two independent readers is what drifts; see #142.
|
|
17
|
+
#
|
|
18
|
+
# THE CACHE is `<workspace>/.fleet/recipe.json`, where <workspace> is the
|
|
19
|
+
# directory holding the repository's COMMON git dir — the main checkout, the
|
|
20
|
+
# same place the ledger and the heartbeat live — so a claimed worktree and a
|
|
21
|
+
# review worktree read the one cache the main checkout holds rather than a
|
|
22
|
+
# private copy each. A single JSON object:
|
|
23
|
+
#
|
|
24
|
+
# install string the Install step, a shell command run from the root
|
|
25
|
+
# test string the Test entrypoint, a shell command run from the root
|
|
26
|
+
# derivedAt string the full commit id (40 or 64 hex) it was proven at
|
|
27
|
+
# installClean true the Install step left `git status --porcelain` empty
|
|
28
|
+
# testCount integer >0, the test count the proving run reported, and/or
|
|
29
|
+
# mutation string the deliberate failing mutation that turned it red
|
|
30
|
+
#
|
|
31
|
+
# At least one of testCount/mutation is the proof; a cache carrying neither,
|
|
32
|
+
# or `installClean` anything but `true`, is an UNPROVEN Recipe and refused like
|
|
33
|
+
# an absent one. Written only by the deriving agent; no script writes it.
|
|
34
|
+
#
|
|
35
|
+
# INVALID on failure to RUN, never on failing tests: the command this script
|
|
36
|
+
# is asked for must name something that resolves from <repo> (a builtin, a
|
|
37
|
+
# PATH entry, an executable path). A red suite is a finding, not a stale
|
|
38
|
+
# Recipe, so nothing here ever runs the command.
|
|
39
|
+
set -eu
|
|
40
|
+
|
|
41
|
+
# Byte semantics for the one byte-sensitive construct below: the `case`
|
|
42
|
+
# patterns that pick the command's leading word apart (`[A-Za-z_]` ranges and
|
|
43
|
+
# `*` over an arbitrary byte string from the cache). Under an ambient UTF-8
|
|
44
|
+
# locale a range is collation-ordered and `*` refuses to match across an
|
|
45
|
+
# invalid byte (#582's hazard). Nothing here sorts or folds case, so pinning
|
|
46
|
+
# the locale changes nothing else — locale-pin-prose.test.mjs enforces the
|
|
47
|
+
# placement (#612).
|
|
48
|
+
export LC_ALL=C
|
|
49
|
+
|
|
50
|
+
# Below the locale pin, not above it with `set -eu`: `unset` touches no
|
|
51
|
+
# byte-sensitive tool, but locale-pin-prose.test.mjs treats ANY line here that
|
|
52
|
+
# is not a comment, a blank, or `set -[eux]+` as work the pin must sit above,
|
|
53
|
+
# and refuses on principle rather than on this line's own behaviour. Same
|
|
54
|
+
# placement, same reason, as release-ticket.sh's copy.
|
|
55
|
+
#
|
|
56
|
+
# GIT_DIR outranks the `-C "$repo"` on the git calls below, so an ambient one
|
|
57
|
+
# answers `--git-common-dir` for the WRONG repository while still being handed
|
|
58
|
+
# `$repo` — and the cache it then reads is another repository's Recipe,
|
|
59
|
+
# reported as this one's. Both consumers act on that string: claim-ticket.sh
|
|
60
|
+
# runs it in a fresh worktree and bakes it into the runner, and review-core.mjs's
|
|
61
|
+
# snapshot agent hands it to every specialist.
|
|
62
|
+
#
|
|
63
|
+
# GIT_WORK_TREE is unset alongside it and is INERT here: `rev-parse --git-dir`
|
|
64
|
+
# and `--git-common-dir` consult no work tree. It stays on the line because the
|
|
65
|
+
# pair is one hazard with one remedy, and "inert today" is a measurement of the
|
|
66
|
+
# current call set, not a property of the script.
|
|
67
|
+
# ambient-git-vars-prose.test.mjs pins the line itself.
|
|
68
|
+
unset GIT_DIR GIT_WORK_TREE
|
|
69
|
+
|
|
70
|
+
# shellcheck disable=SC2100 # literal name "derive-testcmd", not arithmetic — the unrelated $derive var assigned below is what the heuristic collides on, not this line
|
|
71
|
+
NAME=derive-testcmd
|
|
72
|
+
die() { printf '%s: %s\n' "$NAME" "$1" >&2; exit 1; }
|
|
73
|
+
|
|
74
|
+
# Named once: every refusal that sends the caller to re-derive names the same
|
|
75
|
+
# step, so a controller or reviewer reading any of them knows what to run.
|
|
76
|
+
derive="run the Recipe derivation step (run-team phase 0, before the first claim — ADR 0015) to derive, prove and write it"
|
|
77
|
+
|
|
78
|
+
[ $# -eq 2 ] || die "usage: derive-testcmd.sh <repo> <install|test>"
|
|
79
|
+
repo=$1
|
|
80
|
+
field=$2
|
|
81
|
+
|
|
82
|
+
git -C "$repo" rev-parse --git-dir >/dev/null 2>&1 || die "$repo is not a git repository"
|
|
83
|
+
|
|
84
|
+
case $field in
|
|
85
|
+
install|test) ;;
|
|
86
|
+
*) die "unknown Recipe field '$field' — expected install or test" ;;
|
|
87
|
+
esac
|
|
88
|
+
|
|
89
|
+
# `--path-format=absolute` so the workspace is a real directory whatever the
|
|
90
|
+
# caller's cwd; the workspace is the common dir's parent, the same rule
|
|
91
|
+
# git-env.mjs's workspaceDirFromGitCommonDir() applies for the ledger.
|
|
92
|
+
common=$(git -C "$repo" rev-parse --path-format=absolute --git-common-dir 2>&1) \
|
|
93
|
+
|| die "cannot resolve the common git dir of $repo — $common"
|
|
94
|
+
cache="${common%/*}/.fleet/recipe.json"
|
|
95
|
+
|
|
96
|
+
# Absent is its own refusal, ahead of the interpreter probe: it is the one
|
|
97
|
+
# state every fresh repository starts in, and its message must name the step
|
|
98
|
+
# that ends it rather than anything about a parser.
|
|
99
|
+
[ -e "$cache" ] || die "no Recipe cache at $cache — refusing to infer an Install step or a Test entrypoint; $derive"
|
|
100
|
+
|
|
101
|
+
# An INVOCATION, not a name lookup (#1141): a version-manager shim satisfies
|
|
102
|
+
# `command -v node` and then fails, and its stderr would arrive below under the
|
|
103
|
+
# cache's name — a corrupt-cache refusal for a cache nobody read.
|
|
104
|
+
nodeerr=$(node -e 0 </dev/null 2>&1) || die "node is unusable, refusing to read the Recipe cache without the interpreter — $nodeerr"
|
|
105
|
+
|
|
106
|
+
# Validation and extraction in one pass, so a field is never printed out of a
|
|
107
|
+
# cache the checks did not pass. rc 0 prints the value; anything else carries
|
|
108
|
+
# the reason on stderr. An interpreter made chatty by the caller's environment
|
|
109
|
+
# writes on the SUCCESS path too, and whatever reaches the capture arrives
|
|
110
|
+
# inside the command this script hands claim-ticket.sh to run — so each stream
|
|
111
|
+
# is guarded on its own:
|
|
112
|
+
#
|
|
113
|
+
# stderr is kept APART — to a file, never merged into the capture — because
|
|
114
|
+
# NODE_OPTIONS or NODE_DEBUG chatter lands there (#752, #1175).
|
|
115
|
+
#
|
|
116
|
+
# stdout carries the value FRAMED, `recipe<` before it and `>recipe` after,
|
|
117
|
+
# and the WHOLE capture must be exactly that frame, byte for byte (#2217):
|
|
118
|
+
# the anchored match alone only proves the ends line up, so a shim whose
|
|
119
|
+
# own chatter happens to spell out `recipe<`/`>recipe` around the real
|
|
120
|
+
# frame would still pass it and splice that chatter into the value — node
|
|
121
|
+
# writes the frame's own byte length to a second temp file ($lenf) before
|
|
122
|
+
# writing the frame itself, and the capture is refused unless its length
|
|
123
|
+
# matches that count exactly, closing the gap no anchor check alone can
|
|
124
|
+
# close. A version-manager or proxy shim prints to stdout before exec'ing
|
|
125
|
+
# the real node (`Now using node v22.0.0`), and one that does not exec can
|
|
126
|
+
# print after node exits; the anchor and the length check both refuse it,
|
|
127
|
+
# and the refusal names node's output, never the cache — the cache passed.
|
|
128
|
+
# Refused, never recovered: no value is cut out of chatter. The end
|
|
129
|
+
# sentinel also stops `$(…)` stripping a trailing newline off a value the
|
|
130
|
+
# way an unframed capture always did — a value that itself ends in a
|
|
131
|
+
# newline now survives inside the frame, and the trailing-operator check
|
|
132
|
+
# below treats it exactly like a trailing `;` or `&`: refused, not
|
|
133
|
+
# silently accepted.
|
|
134
|
+
errf=$(mktemp) || die "cannot create a temporary file to read the Recipe cache"
|
|
135
|
+
lenf=$(mktemp) || die "cannot create a temporary file to read the Recipe cache"
|
|
136
|
+
trap 'rm -f "$errf" "$lenf"' EXIT
|
|
137
|
+
|
|
138
|
+
open='recipe<' close='>recipe'
|
|
139
|
+
framed=$(node -e '
|
|
140
|
+
const fs = require("fs");
|
|
141
|
+
const [file, field, open, close, lenFile] = process.argv.slice(1);
|
|
142
|
+
const bad = (why) => { console.error(why); process.exit(2); };
|
|
143
|
+
let r;
|
|
144
|
+
try { r = JSON.parse(fs.readFileSync(file, "utf8")); } catch (e) { bad(`it does not parse: ${e.message}`); }
|
|
145
|
+
if (r === null || typeof r !== "object" || Array.isArray(r)) bad("it is not a JSON object");
|
|
146
|
+
for (const k of ["install", "test"])
|
|
147
|
+
if (typeof r[k] !== "string" || !r[k].trim() || r[k].includes("\0")) bad(`\`${k}\` is not a non-empty command string`);
|
|
148
|
+
if (typeof r.derivedAt !== "string" || !/^[0-9a-f]{40}([0-9a-f]{24})?$/.test(r.derivedAt))
|
|
149
|
+
bad("`derivedAt` is not a full commit id");
|
|
150
|
+
if (r.installClean !== true) bad("`installClean` is not true — the Install step was never proven to leave the tree clean");
|
|
151
|
+
const counted = Number.isInteger(r.testCount) && r.testCount > 0;
|
|
152
|
+
const mutated = typeof r.mutation === "string" && r.mutation.trim() !== "";
|
|
153
|
+
if (!counted && !mutated) bad("it carries no proof of real tests — neither a positive `testCount` nor a `mutation`");
|
|
154
|
+
const value = r[field];
|
|
155
|
+
fs.writeFileSync(lenFile, String(Buffer.byteLength(open + value + close)));
|
|
156
|
+
process.stdout.write(open + value + close);
|
|
157
|
+
' "$cache" "$field" "$open" "$close" "$lenf" 2>"$errf") || die "the Recipe cache at $cache is unusable: $(cat "$errf") — $derive"
|
|
158
|
+
carriedmsg="node's stdout carried more than the framed Recipe value — expected exactly the value between '$open' and '$close', got '$framed'. The cache at $cache passed validation; the extra output comes from how node is launched here (a version-manager or proxy shim, a preload), and is refused rather than cut out of the command"
|
|
159
|
+
case $framed in
|
|
160
|
+
"$open"*"$close") ;;
|
|
161
|
+
*) die "$carriedmsg" ;;
|
|
162
|
+
esac
|
|
163
|
+
framedlen=$(cat "$lenf")
|
|
164
|
+
case $framedlen in
|
|
165
|
+
''|*[!0-9]*) die "the Recipe cache at $cache is unusable: node's byte-count file is missing or corrupt — $derive" ;;
|
|
166
|
+
esac
|
|
167
|
+
[ "${#framed}" -eq "$framedlen" ] || die "$carriedmsg"
|
|
168
|
+
value=${framed#"$open"}
|
|
169
|
+
value=${value%"$close"}
|
|
170
|
+
|
|
171
|
+
# Both consumers append the runner's own arguments after this string
|
|
172
|
+
# textually (claim-ticket.sh's `exec sh -c '<cmd> "$@"' agent-test "$@"`), so
|
|
173
|
+
# a command ending in `;`, `&`, or a newline lets a real shell read the
|
|
174
|
+
# caller's "$@" as an unrelated top-level command instead of args reaching
|
|
175
|
+
# the Test entrypoint, and one containing a `#`-led word swallows everything
|
|
176
|
+
# after it, "$@" included, as a comment — measured on both. A trailing
|
|
177
|
+
# newline is checked here too (#2217): the frame above lets a value keep one
|
|
178
|
+
# where an unframed `$(…)` capture always dropped it silently, so a value
|
|
179
|
+
# that used to read as `true;` now reads as `true;\n` and would otherwise
|
|
180
|
+
# slip past a check written for the no-newline case. Checked on the raw
|
|
181
|
+
# string for the trailing operator (adjacency to whitespace is not what
|
|
182
|
+
# makes `;`/`&` a shell operator) and on the same naive field split the
|
|
183
|
+
# leading-word check below already trusts for the comment word, since
|
|
184
|
+
# neither hazard is about whether the command resolves.
|
|
185
|
+
case $value in
|
|
186
|
+
*';'|*'&'|*'
|
|
187
|
+
') die "the Recipe cache at $cache is invalid: its $field command '$value' ends in ';', '&', or a newline — a runner-appended argument after it would run as an unrelated command instead of reaching the Test entrypoint; $derive" ;;
|
|
188
|
+
esac
|
|
189
|
+
set -f
|
|
190
|
+
IFS='
|
|
191
|
+
'
|
|
192
|
+
# shellcheck disable=SC2086 # field splitting is the point: scanning every word
|
|
193
|
+
for word in $value; do
|
|
194
|
+
case $word in
|
|
195
|
+
'#'*) set +f; die "the Recipe cache at $cache is invalid: its $field command '$value' contains a '#' word — a runner-appended argument would be swallowed as a comment rather than reaching the Test entrypoint; $derive" ;;
|
|
196
|
+
esac
|
|
197
|
+
done
|
|
198
|
+
set +f
|
|
199
|
+
|
|
200
|
+
# The failure-to-run probe. The leading word is found by the shell's own field
|
|
201
|
+
# splitting with globbing off, past any `NAME=value` prefix assignments. A word
|
|
202
|
+
# carrying quoting or an expansion cannot be settled without running the
|
|
203
|
+
# command, and running it is exactly what this script never does, so such a
|
|
204
|
+
# word is accepted unprobed rather than refused on a split it cannot trust —
|
|
205
|
+
# the runner then fails loudly at run time, which is where it would anyway.
|
|
206
|
+
# IFS is set, not inherited, so the split is the default one whatever the
|
|
207
|
+
# caller exported.
|
|
208
|
+
set -f
|
|
209
|
+
IFS='
|
|
210
|
+
'
|
|
211
|
+
# shellcheck disable=SC2086 # field splitting is the point: the leading word
|
|
212
|
+
set -- $value
|
|
213
|
+
set +f
|
|
214
|
+
while [ $# -gt 0 ]; do
|
|
215
|
+
case $1 in
|
|
216
|
+
[A-Za-z_]*=*)
|
|
217
|
+
case ${1%%=*} in *[!A-Za-z0-9_]*) break ;; esac
|
|
218
|
+
shift ;;
|
|
219
|
+
*) break ;;
|
|
220
|
+
esac
|
|
221
|
+
done
|
|
222
|
+
[ $# -gt 0 ] || die "the Recipe cache at $cache is invalid: its $field command names no command, only assignments — $derive"
|
|
223
|
+
case $1 in
|
|
224
|
+
*[\'\"\\\$\`\(\)\{\}\<\>\|\&\;\*\?\[\~]*) ;;
|
|
225
|
+
*)
|
|
226
|
+
# In <repo>, so a relative `./run-tests.sh` resolves where the command
|
|
227
|
+
# itself will run from. `command -v` alone is not exec-bit-aware for a
|
|
228
|
+
# `/`-containing word under dash (Ubuntu's default /bin/sh): it only
|
|
229
|
+
# stat()s the path there, never checking execute permission — measured:
|
|
230
|
+
# `dash -c 'command -v ./run.sh'` on a chmod 0644 file exits 0. `[ -x ]`
|
|
231
|
+
# is the exec-bit-aware check that closes the gap; a bare name (builtin
|
|
232
|
+
# or a PATH match) has no path to test and is left to `command -v`.
|
|
233
|
+
(cd "$repo" && command -v -- "$1" || exit 1
|
|
234
|
+
case $1 in */*) [ -x "$1" ] || exit 1 ;; esac) >/dev/null 2>&1 \
|
|
235
|
+
|| die "the Recipe cache at $cache is invalid: its $field command '$1' is not found or not executable from $repo — a Recipe that cannot run is stale, not a finding; $derive"
|
|
236
|
+
;;
|
|
237
|
+
esac
|
|
238
|
+
|
|
239
|
+
printf '%s\n' "$value"
|