rungate 0.6.0 → 0.8.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/hooks/ActionVerificationGate.hook.ts +96 -0
- package/hooks/AgentBriefGuard.hook.ts +38 -0
- package/hooks/AgentVerdictCapture.hook.ts +87 -0
- package/hooks/AutoVerifyGate.hook.ts +79 -0
- package/hooks/BashToolGuard.hook.ts +65 -0
- package/hooks/BashWriteGuard.hook.ts +60 -0
- package/hooks/CommitEnforcement.hook.ts +130 -0
- package/hooks/DocHygiene.hook.ts +148 -0
- package/hooks/GateEnforcement.hook.ts +58 -0
- package/hooks/GateResultProtection.hook.ts +69 -0
- package/hooks/HarnessAFKGate.hook.ts +85 -0
- package/hooks/HookCurrency.hook.ts +99 -0
- package/hooks/IssueCloseGuard.hook.ts +149 -0
- package/hooks/MergeGuard.hook.ts +58 -0
- package/hooks/PostCompact.hook.ts +60 -0
- package/hooks/ProjectStateSync.hook.ts +103 -0
- package/hooks/SkillGuard.hook.ts +69 -0
- package/hooks/SpecConformityTrigger.hook.ts +43 -0
- package/hooks/SpecSCGuard.hook.ts +123 -0
- package/hooks/StaleTTLCleanup.hook.ts +141 -0
- package/hooks/TaskCompleted.hook.ts +51 -0
- package/hooks/TeamInit.hook.ts +85 -0
- package/hooks/TestSuiteGuard.hook.ts +70 -0
- package/hooks/TestSuiteRelease.hook.ts +85 -0
- package/hooks/TopLevelCdGuard.hook.ts +108 -0
- package/hooks/VerifyPhaseLock.hook.ts +84 -0
- package/hooks/WorkflowStateGuard.hook.ts +40 -0
- package/hooks/lib/agent-config.json +9 -0
- package/hooks/lib/agentDetection.ts +201 -0
- package/hooks/lib/comment-template.ts +86 -0
- package/hooks/lib/findWorkflow.ts +101 -0
- package/hooks/lib/parseStdin.ts +37 -0
- package/hooks/lib/paths.ts +111 -0
- package/hooks/lib/utils.ts +338 -0
- package/lib/affected-tests.ts +427 -0
- package/lib/agent-audit.ts +2 -3
- package/lib/agent-worktree.ts +287 -0
- package/lib/agents-md-sections.ts +81 -16
- package/lib/bash-write-guard.ts +373 -0
- package/lib/behavioral-cache.ts +150 -2
- package/lib/branch-cleanup.ts +279 -7
- package/lib/branch-protection.ts +790 -0
- package/lib/brief-ac-alignment.ts +104 -0
- package/lib/brief-references.ts +205 -0
- package/lib/bun-version.ts +93 -14
- package/lib/check-remedy.ts +140 -0
- package/lib/ci-checkout.ts +17 -0
- package/lib/ci-history-depth.ts +159 -0
- package/lib/ci-setup-step.ts +96 -0
- package/lib/claude-code-action.ts +85 -0
- package/lib/claude-tool-vocabulary.ts +188 -0
- package/lib/cli-commands.ts +15 -0
- package/lib/commit-sha.ts +42 -0
- package/lib/commit-subject.ts +90 -0
- package/lib/compliance-report.ts +377 -45
- package/lib/compliance.ts +191 -17
- package/lib/config-loader.ts +39 -1
- package/lib/config-trackable.ts +400 -0
- package/lib/conformity.ts +1087 -100
- package/lib/containment.ts +238 -0
- package/lib/content-hash.ts +24 -0
- package/lib/create-sc.ts +249 -16
- package/lib/dev-liveness.ts +180 -0
- package/lib/discovery-branch-points.ts +432 -0
- package/lib/discovery-stability.ts +481 -0
- package/lib/distribution-currency.ts +236 -0
- package/lib/doc-routing.ts +157 -0
- package/lib/evidence-prevalidator.ts +224 -2
- package/lib/evidence-satisfiability.ts +534 -12
- package/lib/failure-intake.ts +323 -0
- package/lib/fallow-availability.ts +157 -0
- package/lib/fs-write-capabilities.ts +232 -0
- package/lib/gate-enforcement.ts +222 -28
- package/lib/gate-names.ts +72 -0
- package/lib/gate-result-protection.ts +427 -0
- package/lib/gate-run-split.ts +147 -0
- package/lib/generators/agents-md.ts +140 -32
- package/lib/git-isolation.ts +140 -0
- package/lib/github.ts +15 -0
- package/lib/google-auth-action.ts +93 -0
- package/lib/harness-project.ts +48 -0
- package/lib/harness-provenance.ts +255 -0
- package/lib/hook-evidence.ts +235 -0
- package/lib/hook-scopes.ts +386 -0
- package/lib/hook-target-tree.ts +398 -0
- package/lib/hook-trees.ts +447 -0
- package/lib/intake-sources.ts +380 -0
- package/lib/js-top-level-code.ts +78 -10
- package/lib/junit-checks.ts +52 -0
- package/lib/late-env-spawn.ts +331 -0
- package/lib/launch-base.ts +376 -0
- package/lib/line-citation.ts +372 -0
- package/lib/orphan-reaper.ts +468 -0
- package/lib/parity-binding.ts +205 -0
- package/lib/paths.ts +96 -3
- package/lib/per-test-timeouts.ts +219 -0
- package/lib/phase2-decomposition.ts +1 -1
- package/lib/plan-coverage.ts +151 -0
- package/lib/prior-branch.ts +201 -8
- package/lib/process-table.ts +146 -0
- package/lib/project-state-derivation.ts +219 -0
- package/lib/project-state-root.ts +258 -0
- package/lib/published-artifact.ts +669 -0
- package/lib/readdir-sorted.ts +45 -0
- package/lib/review-execution-reading.ts +206 -0
- package/lib/review-tool-agreement.ts +433 -0
- package/lib/rule-promotion.ts +234 -0
- package/lib/rule-retirement.ts +525 -0
- package/lib/run-branch.ts +612 -0
- package/lib/rungate-schema.ts +19 -0
- package/lib/runner-home.ts +274 -0
- package/lib/sc-id-cross-tree.ts +103 -15
- package/lib/sc-ids.ts +121 -13
- package/lib/sc-reservations.ts +289 -0
- package/lib/scaffold/ai-review-findings.ts +409 -0
- package/lib/scaffold/ai-review-step.ts +5406 -64
- package/lib/scaffold/defaults.ts +82 -1
- package/lib/scaffold/managed-workflow.ts +587 -192
- package/lib/scaffold/owned-files.ts +152 -45
- package/lib/scaffold/pre-push-hook.ts +49 -5
- package/lib/scaffold/steps.ts +1836 -275
- package/lib/scaffold/workflow-census.ts +217 -0
- package/lib/scaffold/workflow-drift.ts +217 -0
- package/lib/scaffold/write-steps.ts +4 -0
- package/lib/scan-budget.ts +247 -0
- package/lib/scanner.ts +43 -51
- package/lib/scratch-roots.ts +50 -5
- package/lib/screenshot-discovery.ts +121 -0
- package/lib/screenshot-upload.ts +41 -1
- package/lib/secret-patterns.ts +511 -8
- package/lib/security-verdict.ts +1 -1
- package/lib/shell-path-interpolation.ts +594 -0
- package/lib/ship-mode.ts +219 -0
- package/lib/source-slice.ts +294 -0
- package/lib/stale-cleanup.ts +37 -3
- package/lib/suite-flake.ts +278 -0
- package/lib/suite-measurement.ts +23 -4
- package/lib/suite-run-reading.ts +241 -1
- package/lib/suite-timeout-margin.ts +193 -0
- package/lib/test-case-bodies.ts +883 -0
- package/lib/test-case-deletion.ts +653 -0
- package/lib/test-census.ts +97 -29
- package/lib/test-command-positions.ts +274 -0
- package/lib/test-suite-lock.ts +159 -16
- package/lib/text-dependents.ts +875 -0
- package/lib/tool-probe.ts +31 -9
- package/lib/top-level-cd.ts +393 -0
- package/lib/tree-entries.ts +89 -0
- package/lib/ts-ast.ts +200 -0
- package/lib/walk-test-files.ts +97 -0
- package/lib/workflow-actions.ts +263 -0
- package/lib/workflow-security.ts +29 -0
- package/lib/workflow-taint.ts +732 -0
- package/lib/worktree-cleanup.ts +65 -38
- package/lib/worktree-collect.ts +177 -5
- package/lib/worktree-repo.ts +68 -3
- package/package.json +4 -1
- package/scripts/ai-review-findings.ts +45 -0
- package/scripts/check-installed-hook-currency.ts +825 -0
- package/scripts/create-sc.ts +21 -1
- package/scripts/extract-constraints.ts +107 -7
- package/scripts/generate-code-map.ts +23 -30
- package/scripts/scaffold-project.ts +8 -1
- package/scripts/sync-sc-status.ts +77 -16
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether what a consumer can install IS what this tree is (#875).
|
|
3
|
+
*
|
|
4
|
+
* ## The question this asks, and why it is not the one next door
|
|
5
|
+
*
|
|
6
|
+
* `lib/published-artifact.ts` compares the registry tarball against the tree
|
|
7
|
+
* by content and classifies the result. Its refusal — `artifactViolations` —
|
|
8
|
+
* is about a LABEL: `DIVERGED` means one version string is being used for two
|
|
9
|
+
* different trees, and `AHEAD` is waved through because a repository past its
|
|
10
|
+
* last release is what a repository between releases is.
|
|
11
|
+
*
|
|
12
|
+
* That is the right refusal for the question it asks and it is the wrong one
|
|
13
|
+
* for the question #875 was filed about. The harm in the issue is not a label:
|
|
14
|
+
* it is that `bunx rungate` hands a consumer the **pre-#863 tier-2 secret
|
|
15
|
+
* scan**, which reported five property references as credential assignments
|
|
16
|
+
* and turned `gates` red on `hornjason/agentgrit`. That consumer is no better
|
|
17
|
+
* off if `package.json` says `0.7.0`.
|
|
18
|
+
*
|
|
19
|
+
* So this module asks the consumer's question: **is the published artifact the
|
|
20
|
+
* content this tree would publish?** No version string is an input to it.
|
|
21
|
+
*
|
|
22
|
+
* ## Which is also what makes it survive the cheapest wrong fix
|
|
23
|
+
*
|
|
24
|
+
* The 5pm repair for a red distribution check is to bump `package.json`. It
|
|
25
|
+
* works on the label — `artifactStanding` reads `AHEAD` and
|
|
26
|
+
* `artifactViolations` returns `[]` — and it moves nothing a consumer can
|
|
27
|
+
* observe. Measured on this tree 2026-10-21, the reading either side of that
|
|
28
|
+
* bump:
|
|
29
|
+
*
|
|
30
|
+
* | | tree `0.6.0` | tree `0.7.0` |
|
|
31
|
+
* |---|---|---|
|
|
32
|
+
* | `artifactStanding` | `DIVERGED` | `AHEAD` |
|
|
33
|
+
* | `artifactViolations` | 1 violation | **none** |
|
|
34
|
+
* | files differing in bytes | 45 | **45** |
|
|
35
|
+
* | files the artifact lacks | 58 | **58** |
|
|
36
|
+
* | commits since the published tag | 183 | **183** |
|
|
37
|
+
*
|
|
38
|
+
* `currencyRefusal` reads the bottom three rows, so the bump moves it not at
|
|
39
|
+
* all. That is the fifth shape in `.claude/rules/checks-must-be-able-to-fail.md`
|
|
40
|
+
* — *a case that goes green under the WRONG fix* — answered by choosing inputs
|
|
41
|
+
* the wrong fix does not touch, rather than by hoping nobody reaches for it.
|
|
42
|
+
*
|
|
43
|
+
* ## Two refusals, not one decider wearing two hats
|
|
44
|
+
*
|
|
45
|
+
* `currencyRefusal` and `artifactViolations` are NOT the fourth shape. They
|
|
46
|
+
* are distinguishable, and the distinguishing input is named rather than
|
|
47
|
+
* asserted: a tree at `0.7.0` against a published `0.6.0` whose content
|
|
48
|
+
* differs. `artifactViolations` returns `[]` — no label is lying — and
|
|
49
|
+
* `currencyRefusal` refuses, because a consumer still cannot obtain this tree.
|
|
50
|
+
* A mutation of either is visible on that input alone.
|
|
51
|
+
*
|
|
52
|
+
* ## This is a script's refusal, deliberately, and not the suite's
|
|
53
|
+
*
|
|
54
|
+
* `STALE` is the NORMAL state of this repository between releases, because
|
|
55
|
+
* `preflightRefusal` in `lib/release-preflight.ts` requires the tree's version
|
|
56
|
+
* to be absent from the registry at release time — so the bump happens AT the
|
|
57
|
+
* release and never before it. A gate wired into `bun test` would therefore be
|
|
58
|
+
* red on `main` every day of the repo's life, and `lib/release-preflight.ts`
|
|
59
|
+
* already records what that costs: *a red job over a green release is how a
|
|
60
|
+
* gate teaches people to stop reading it.*
|
|
61
|
+
*
|
|
62
|
+
* So the reading lives behind `scripts/check-distribution-currency.ts`, which
|
|
63
|
+
* exits non-zero. It is a thing you run before cutting a release and a thing
|
|
64
|
+
* that answers "how far behind is npm" in one command — not a thing that
|
|
65
|
+
* blocks an unrelated PR on a condition its author cannot clear.
|
|
66
|
+
*/
|
|
67
|
+
import {
|
|
68
|
+
contentAgrees,
|
|
69
|
+
STANDING_CAUSE_HEADLINE,
|
|
70
|
+
type ArtifactStanding,
|
|
71
|
+
type ContentDifference,
|
|
72
|
+
type StandingCause,
|
|
73
|
+
type UnmeasuredReason,
|
|
74
|
+
} from "./published-artifact";
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The one non-zero exit in the distribution-currency path.
|
|
78
|
+
*
|
|
79
|
+
* Declared once and exported so a test can build a mutant with it set to `0`
|
|
80
|
+
* and observe the refusal being removed — `.claude/rules/checks-must-be-able-
|
|
81
|
+
* to-fail.md`, *For a script whose job is to exit non-zero*. A later branch
|
|
82
|
+
* that inlines `process.exit(1)` bypasses the mutation and the case goes green
|
|
83
|
+
* having witnessed nothing, so `test/distribution-currency.test.ts` also
|
|
84
|
+
* asserts the constant is the script's only exit code.
|
|
85
|
+
*/
|
|
86
|
+
export const DISTRIBUTION_STALE_EXIT = 1;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* `CURRENT` — a consumer installing from npm gets this tree.
|
|
90
|
+
* `STALE` — they do not, whatever the version strings say.
|
|
91
|
+
* `UNMEASURED` — nobody looked. Never a pass.
|
|
92
|
+
*/
|
|
93
|
+
export type CurrencyReading = "CURRENT" | "STALE" | "UNMEASURED";
|
|
94
|
+
|
|
95
|
+
export interface DistributionCurrency {
|
|
96
|
+
reading: CurrencyReading;
|
|
97
|
+
/** Published files whose bytes differ from the tree's. */
|
|
98
|
+
staleFiles: string[];
|
|
99
|
+
/** Files the tree would publish that the artifact does not have at all. */
|
|
100
|
+
missingFiles: string[];
|
|
101
|
+
/** Files in the artifact that the tree no longer publishes. */
|
|
102
|
+
removedFiles: string[];
|
|
103
|
+
/** Commits between the published tag and `HEAD`. `null` is a reading nobody took. */
|
|
104
|
+
commitsAhead: number | null;
|
|
105
|
+
/** The version a consumer can install, for the report. Never an input to the verdict. */
|
|
106
|
+
publishedVersion: string | null;
|
|
107
|
+
/** Non-empty exactly when `reading` is `UNMEASURED`. */
|
|
108
|
+
unmeasuredReasons: string[];
|
|
109
|
+
/**
|
|
110
|
+
* WHICH condition produced the refusal (#1117). Empty when `CURRENT`.
|
|
111
|
+
* Never an input to `currencyRefusal` — a cause makes a red legible, it
|
|
112
|
+
* does not decide whether there is one.
|
|
113
|
+
*/
|
|
114
|
+
causes: StandingCause[];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The conditions behind THIS reading, which is not the standing's question.
|
|
119
|
+
*
|
|
120
|
+
* `standingCauses` answers it for `artifactStanding`'s label. This answers it
|
|
121
|
+
* for the consumer's question, and the two genuinely disagree on an input
|
|
122
|
+
* this module already names: a tree at `0.7.0` against a published `0.6.0`
|
|
123
|
+
* whose content differs is `AHEAD` with no cause at all, and `STALE` with
|
|
124
|
+
* `CONTENT` — because a consumer still cannot obtain this tree. Reusing
|
|
125
|
+
* `standingCauses` here would make the version ordering an input to this
|
|
126
|
+
* module after all, which is exactly what the header says it is not.
|
|
127
|
+
*
|
|
128
|
+
* The SENTENCES are not restated: both selectors render through
|
|
129
|
+
* `STANDING_CAUSE_HEADLINE`, so there is one declaring position for the text
|
|
130
|
+
* and two readings that select from it.
|
|
131
|
+
*/
|
|
132
|
+
function currencyCauses(reading: CurrencyReading, unmeasured: UnmeasuredReason[]): StandingCause[] {
|
|
133
|
+
if (reading === "UNMEASURED") {
|
|
134
|
+
const seen: StandingCause[] = [];
|
|
135
|
+
for (const r of unmeasured) if (!seen.includes(r.cause)) seen.push(r.cause);
|
|
136
|
+
return seen.length > 0 ? seen : ["UNCLASSIFIED"];
|
|
137
|
+
}
|
|
138
|
+
if (reading === "STALE") return ["CONTENT"];
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Project an `ArtifactStanding` onto the consumer's question.
|
|
144
|
+
*
|
|
145
|
+
* A projection and not a second measurement: every field here is read off the
|
|
146
|
+
* standing, so this cannot disagree with `lib/published-artifact.ts` about
|
|
147
|
+
* what was observed — only about what the observation means.
|
|
148
|
+
*
|
|
149
|
+
* `reading` is derived from `contentAgrees`, which is the same predicate
|
|
150
|
+
* `artifactStanding` uses to separate `MATCHED` from `DIVERGED`. The version
|
|
151
|
+
* ordering that sends an equal-content tree to `AHEAD` is simply not consulted.
|
|
152
|
+
*/
|
|
153
|
+
export function distributionCurrency(s: ArtifactStanding): DistributionCurrency {
|
|
154
|
+
const d: ContentDifference | null = s.difference;
|
|
155
|
+
const base = {
|
|
156
|
+
staleFiles: d?.differing ?? [],
|
|
157
|
+
missingFiles: d?.onlyLocal ?? [],
|
|
158
|
+
removedFiles: d?.onlyPublished ?? [],
|
|
159
|
+
commitsAhead: s.commitsAhead,
|
|
160
|
+
publishedVersion: s.publishedVersion,
|
|
161
|
+
};
|
|
162
|
+
if (s.reading === "UNMEASURED" || d === null) {
|
|
163
|
+
const unmeasured: UnmeasuredReason[] =
|
|
164
|
+
s.unmeasured.length > 0
|
|
165
|
+
? s.unmeasured
|
|
166
|
+
: [{ cause: "UNCLASSIFIED", text: "the content comparison was not performed" }];
|
|
167
|
+
return {
|
|
168
|
+
...base,
|
|
169
|
+
reading: "UNMEASURED",
|
|
170
|
+
unmeasuredReasons: unmeasured.map(r => r.text),
|
|
171
|
+
causes: currencyCauses("UNMEASURED", unmeasured),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
const reading: CurrencyReading = contentAgrees(d) ? "CURRENT" : "STALE";
|
|
175
|
+
return {
|
|
176
|
+
...base,
|
|
177
|
+
reading,
|
|
178
|
+
unmeasuredReasons: [],
|
|
179
|
+
causes: currencyCauses(reading, []),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The single refusal. `null` allows.
|
|
185
|
+
*
|
|
186
|
+
* One exported binding, so there is one thing to mutate. A second predicate
|
|
187
|
+
* over the same fields would always agree with this one and would survive any
|
|
188
|
+
* mutation of it.
|
|
189
|
+
*
|
|
190
|
+
* `c.causes` leads each message (#1117) and is read by neither branch: the
|
|
191
|
+
* set of states this refuses is exactly what it was before the cause existed.
|
|
192
|
+
*/
|
|
193
|
+
export function currencyRefusal(c: DistributionCurrency): string | null {
|
|
194
|
+
const why = currencyHeadline(c);
|
|
195
|
+
if (c.reading === "UNMEASURED") {
|
|
196
|
+
return (
|
|
197
|
+
`${why} ` +
|
|
198
|
+
`UNMEASURED: nothing was compared — ${c.unmeasuredReasons.join("; ")}. ` +
|
|
199
|
+
`A reading that could not be taken is not one that passed, so this exits ` +
|
|
200
|
+
`non-zero rather than reporting that the distribution is fine.`
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
if (c.reading === "STALE") {
|
|
204
|
+
const n = c.staleFiles.length + c.missingFiles.length + c.removedFiles.length;
|
|
205
|
+
return (
|
|
206
|
+
`${why} ` +
|
|
207
|
+
`STALE: a consumer running \`bunx rungate\` today does NOT get this tree. ` +
|
|
208
|
+
`rungate@${c.publishedVersion} on the registry differs from what this tree ` +
|
|
209
|
+
`would publish in ${n} files — ${c.staleFiles.length} whose bytes differ, ` +
|
|
210
|
+
`${c.missingFiles.length} it does not have at all, ${c.removedFiles.length} ` +
|
|
211
|
+
`it still has` +
|
|
212
|
+
(c.commitsAhead === null ? "" : `, across ${c.commitsAhead} commits since the published tag`) +
|
|
213
|
+
`. Bumping package.json does not change one of those numbers. The remedy ` +
|
|
214
|
+
`is a release.`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Every condition behind this refusal, as sentences. `""` when nothing refuses. */
|
|
221
|
+
export function currencyHeadline(c: DistributionCurrency): string {
|
|
222
|
+
return c.causes.map(x => STANDING_CAUSE_HEADLINE[x]).join(" ");
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Every number this reading produced, whether or not it refuses. */
|
|
226
|
+
export function currencyReportLines(c: DistributionCurrency): string[] {
|
|
227
|
+
return [
|
|
228
|
+
`distribution currency: ${c.reading}`,
|
|
229
|
+
` condition ${c.causes.length > 0 ? c.causes.join(", ") : "none"}`,
|
|
230
|
+
` published version ${c.publishedVersion ?? "UNREAD"}`,
|
|
231
|
+
` commits since its tag ${c.commitsAhead ?? "UNREAD"}`,
|
|
232
|
+
` files differing in bytes ${c.staleFiles.length}`,
|
|
233
|
+
` files npm does not have ${c.missingFiles.length}`,
|
|
234
|
+
` files npm still has ${c.removedFiles.length}`,
|
|
235
|
+
];
|
|
236
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #617 / #619 — the one place that decides what a top-level `docs/*.md`
|
|
3
|
+
* contributes to the Documentation Routing table.
|
|
4
|
+
*
|
|
5
|
+
* ## What was wrong
|
|
6
|
+
*
|
|
7
|
+
* Both doc-routing sites ended with a "filter to non-obvious mappings":
|
|
8
|
+
*
|
|
9
|
+
* return docRouting.filter(d => {
|
|
10
|
+
* const slug = d.file.replace(/\.md$/, "").replace(/.*\//, "")
|
|
11
|
+
* .toLowerCase().replace(/-/g, " ");
|
|
12
|
+
* return !d.need.toLowerCase().startsWith(slug)
|
|
13
|
+
* || d.need.includes("—") || d.need.includes("(");
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* `need` falls back to the filename with dashes turned into spaces when a
|
|
17
|
+
* document carries no `governs:`, so `need === slug` and the row was dropped.
|
|
18
|
+
* Measured on one consumer: **0 of 38 top-level `docs/*.md`
|
|
19
|
+
* carried the field, so all 38 were dropped** — `ENVIRONMENTS.md` among them,
|
|
20
|
+
* which cost a DA a false P1 on 2026-10-17 after it inferred the production
|
|
21
|
+
* host rather than reading the document that names it in three places.
|
|
22
|
+
*
|
|
23
|
+
* The filter's instinct is right — `| environments | docs/ENVIRONMENTS.md |`
|
|
24
|
+
* teaches nothing about *when* to read the file. Its action is wrong: dropping
|
|
25
|
+
* the row does not produce a better row, it produces no evidence the document
|
|
26
|
+
* exists. That is `.claude/rules/config-access.md`'s *Silent Default
|
|
27
|
+
* Substitution* — **a document with no `governs:` is UNMEASURED, not
|
|
28
|
+
* "governs nothing"**, and a dropped row is indistinguishable from a document
|
|
29
|
+
* that was never written.
|
|
30
|
+
*
|
|
31
|
+
* ## What it does instead
|
|
32
|
+
*
|
|
33
|
+
* - Never drops a document for being quiet. The row is emitted with
|
|
34
|
+
* `NO_GOVERNS_MARKER` in front of the filename-derived description, so the
|
|
35
|
+
* gap reads as a to-do rather than as an answer — the same treatment
|
|
36
|
+
* `specs-routing.md` already gives a spec with no criteria.
|
|
37
|
+
* - Exclusion is something a document declares **about itself**
|
|
38
|
+
* (`status: archived`, `routing: exclude`), not a string-similarity accident.
|
|
39
|
+
* Without a deliberate way out, every consumer gets rows it does not want
|
|
40
|
+
* and the next person widens the filter again.
|
|
41
|
+
*
|
|
42
|
+
* ## Why this is a module and not two edits
|
|
43
|
+
*
|
|
44
|
+
* `lib/scanner.ts` and `lib/scaffold/steps.ts` each held a complete copy of
|
|
45
|
+
* this scan, each with its own inline `governs:` regex. #91 is what that costs:
|
|
46
|
+
* the scaffold calls the steps.ts copy, so a fix to scanner.ts alone changed
|
|
47
|
+
* no generated output at all while the scanner tests went green over the copy
|
|
48
|
+
* nobody calls. Two deciders answering one question are behaviourally one —
|
|
49
|
+
* a mutation of either leaves the other holding every case up, and both read
|
|
50
|
+
* as covered (`.claude/rules/checks-must-be-able-to-fail.md`, fourth shape).
|
|
51
|
+
*
|
|
52
|
+
* So there is exactly ONE decider here, `topLevelDocRoute`, and exactly one
|
|
53
|
+
* frontmatter parser underneath it, `lib/frontmatter.ts` `parseFrontmatter`.
|
|
54
|
+
* The obvious-mapping filter is deleted rather than kept-but-defeated: the
|
|
55
|
+
* marker already contains an em dash, so leaving the filter in place would
|
|
56
|
+
* make it dead code that no mutation could distinguish from live code.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
60
|
+
import { join } from "path";
|
|
61
|
+
import { parseFrontmatter } from "./frontmatter";
|
|
62
|
+
|
|
63
|
+
export interface DocRoutingRow {
|
|
64
|
+
need: string;
|
|
65
|
+
file: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The marker that makes an undiscoverable document visible. It leads the row
|
|
70
|
+
* so a reader scanning the first column sees the gap without reading on.
|
|
71
|
+
*/
|
|
72
|
+
export const NO_GOVERNS_MARKER = "NO GOVERNS FIELD —";
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The frontmatter declarations by which a document takes itself out of the
|
|
76
|
+
* routing table. One table, so there is one place to add a spelling and one
|
|
77
|
+
* place to mutate.
|
|
78
|
+
*/
|
|
79
|
+
export const ROUTING_EXCLUSIONS: ReadonlyArray<{ key: string; value: string }> = [
|
|
80
|
+
{ key: "status", value: "archived" },
|
|
81
|
+
{ key: "routing", value: "exclude" },
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
/** A `governs:` holding this is a placeholder, not a statement. */
|
|
85
|
+
const GOVERNS_PLACEHOLDER = "TODO";
|
|
86
|
+
|
|
87
|
+
export type DocRoutingReading = "GOVERNS" | "UNMEASURED";
|
|
88
|
+
|
|
89
|
+
export type TopLevelDocDecision =
|
|
90
|
+
| { routed: true; need: string; reading: DocRoutingReading }
|
|
91
|
+
| { routed: false; excludedBy: string };
|
|
92
|
+
|
|
93
|
+
/** `MAC-MINI-DEMO-SETUP.md` → `mac mini demo setup`. */
|
|
94
|
+
export function filenameDescription(filename: string): string {
|
|
95
|
+
return filename.replace(/\.md$/, "").replace(/.*\//, "").replace(/-/g, " ").toLowerCase();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The single decider: what, if anything, this document contributes.
|
|
100
|
+
*
|
|
101
|
+
* A frontmatter block `parseFrontmatter` refuses is UNMEASURED, never
|
|
102
|
+
* excluded — silence from the parser must not read as a document opting out.
|
|
103
|
+
*/
|
|
104
|
+
export function topLevelDocRoute(filename: string, content: string): TopLevelDocDecision {
|
|
105
|
+
const parsed = parseFrontmatter(content);
|
|
106
|
+
const entries = parsed?.entries ?? [];
|
|
107
|
+
const valueOf = (key: string): string | null => {
|
|
108
|
+
const e = entries.find(x => x.key === key);
|
|
109
|
+
return e ? e.inline.trim() : null;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
for (const ex of ROUTING_EXCLUSIONS) {
|
|
113
|
+
if (valueOf(ex.key)?.toLowerCase() === ex.value) {
|
|
114
|
+
return { routed: false, excludedBy: `${ex.key}: ${ex.value}` };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const governs = valueOf("governs");
|
|
119
|
+
if (governs && governs !== GOVERNS_PLACEHOLDER) {
|
|
120
|
+
return { routed: true, need: governs, reading: "GOVERNS" };
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
routed: true,
|
|
124
|
+
need: `${NO_GOVERNS_MARKER} ${filenameDescription(filename)}`,
|
|
125
|
+
reading: "UNMEASURED",
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Every row `docs/` contributes: top-level documents, then subdirectories the
|
|
131
|
+
* caller has not already listed as a category.
|
|
132
|
+
*
|
|
133
|
+
* The caller owns the categories because the two sites build that list from
|
|
134
|
+
* their own configuration; everything else about the scan lives here.
|
|
135
|
+
*/
|
|
136
|
+
export function scanDocsDirectory(docsDir: string, categoryDirs: readonly string[]): DocRoutingRow[] {
|
|
137
|
+
if (!existsSync(docsDir)) return [];
|
|
138
|
+
const rows: DocRoutingRow[] = [];
|
|
139
|
+
|
|
140
|
+
for (const f of readdirSync(docsDir).filter(f => f.endsWith(".md"))) {
|
|
141
|
+
const decision = topLevelDocRoute(f, readFileSync(join(docsDir, f), "utf-8"));
|
|
142
|
+
if (!decision.routed) continue;
|
|
143
|
+
rows.push({ need: decision.need, file: `docs/${f}` });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const subDirs = readdirSync(docsDir, { withFileTypes: true })
|
|
147
|
+
.filter(d => d.isDirectory() && !categoryDirs.includes(`docs/${d.name}`))
|
|
148
|
+
.map(d => d.name);
|
|
149
|
+
for (const sub of subDirs) {
|
|
150
|
+
const subFiles = readdirSync(join(docsDir, sub)).filter(f => f.endsWith(".md"));
|
|
151
|
+
if (subFiles.length > 0) {
|
|
152
|
+
rows.push({ need: `${sub} (${subFiles.length} files)`, file: `docs/${sub}/` });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return rows;
|
|
157
|
+
}
|
|
@@ -26,9 +26,57 @@ export interface ACInput {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/** The AC's own bar, recorded verbatim beside the output it will be judged against. */
|
|
30
|
+
export interface ACThresholdInput {
|
|
31
|
+
op?: string;
|
|
32
|
+
value?: string | number;
|
|
33
|
+
unit?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Whether the baseline output is a value a threshold can be compared against.
|
|
38
|
+
*
|
|
39
|
+
* MEASURED means the command printed something that stands for a reading of
|
|
40
|
+
* the tree. UNMEASURED means it did not — it printed nothing, or it printed
|
|
41
|
+
* only the tool announcing itself. Those two states are the whole point: `0`,
|
|
42
|
+
* `{}`, an empty string and `bun test v1.3.14 (d1632b29)` are all
|
|
43
|
+
* indistinguishable from success, and UNMEASURED is not.
|
|
44
|
+
*/
|
|
45
|
+
export type BaselineVerdict = "MEASURED" | "UNMEASURED";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* What an AC's evidence command printed on the PRE-CHANGE tree, beside the
|
|
49
|
+
* threshold it will later be judged against (#669).
|
|
50
|
+
*
|
|
51
|
+
* Both halves are persisted so neither has to be re-derived: the pre-change
|
|
52
|
+
* tree stops existing the moment Marcus writes a line, so a reader asking
|
|
53
|
+
* "what did this print before the work" had no way to find out that did not
|
|
54
|
+
* involve a checkout.
|
|
55
|
+
*/
|
|
56
|
+
export interface ACBaseline {
|
|
57
|
+
verdict: BaselineVerdict;
|
|
58
|
+
/** The command's own output, verbatim and trimmed. Empty only when UNMEASURED. */
|
|
59
|
+
output: string;
|
|
60
|
+
/** Why the baseline is UNMEASURED. Null — and only null — when it is MEASURED. */
|
|
61
|
+
reason: string | null;
|
|
62
|
+
/** The AC's threshold as written. Null when the AC declares none. */
|
|
63
|
+
threshold: ACThresholdInput | null;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the PRE-CHANGE output already clears the bar.
|
|
66
|
+
*
|
|
67
|
+
* Null — and only null — when no comparison was made: an UNMEASURED
|
|
68
|
+
* baseline is never reduced to one, and neither is a bar nothing can be
|
|
69
|
+
* compared against. `false` would claim the comparison happened and missed,
|
|
70
|
+
* which is a different fact and the one that hides a banner.
|
|
71
|
+
*/
|
|
72
|
+
satisfiesThreshold: boolean | null;
|
|
73
|
+
}
|
|
74
|
+
|
|
29
75
|
export interface PrevalidationResult {
|
|
30
76
|
id: string;
|
|
31
77
|
status: "ok" | "broken" | "empty" | "skipped";
|
|
78
|
+
/** The pre-change reading (#669). */
|
|
79
|
+
baseline?: ACBaseline;
|
|
32
80
|
autoFixed?: boolean;
|
|
33
81
|
/**
|
|
34
82
|
* The command as the AC was written, present only when `autoFixed` is.
|
|
@@ -74,10 +122,156 @@ export interface EvidencePrevalidationReading {
|
|
|
74
122
|
* nothing, which is part of how #261 cost two.
|
|
75
123
|
*/
|
|
76
124
|
broken: string[];
|
|
125
|
+
/**
|
|
126
|
+
* The ids whose PRE-CHANGE output already satisfied their own threshold
|
|
127
|
+
* (#669).
|
|
128
|
+
*
|
|
129
|
+
* Derived from `acs` by `alreadySatisfiedIds`, the same binding the gate's
|
|
130
|
+
* refusal reads, so the list the reading carries and the list the refusal
|
|
131
|
+
* names cannot be two different answers to one question.
|
|
132
|
+
*/
|
|
133
|
+
alreadySatisfied: string[];
|
|
77
134
|
/** Why the reading is UNMEASURED. Null — and only null — when it is not. */
|
|
78
135
|
reason: string | null;
|
|
79
136
|
}
|
|
80
137
|
|
|
138
|
+
// ── The pre-change baseline (#669) ──────────────────────────────────────
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* A line that is a tool announcing itself rather than reporting anything.
|
|
142
|
+
*
|
|
143
|
+
* Deliberately narrow. The direction this is allowed to be wrong in is toward
|
|
144
|
+
* MEASURED: a pattern that swallowed ordinary output would convert real
|
|
145
|
+
* evidence into an absence, which is strictly worse than the state it
|
|
146
|
+
* replaces. So the digits must be introduced by a literal `v` or the word
|
|
147
|
+
* `version` — `3.14` on its own is a number somebody measured, and
|
|
148
|
+
* `bun test v1.3.14 (d1632b29)` is not.
|
|
149
|
+
*/
|
|
150
|
+
const VERSION_BANNER =
|
|
151
|
+
/^(?:[A-Za-z][\w.+-]*(?:[ \t]+[A-Za-z][\w.+-]*){0,2}[ \t]+)?(?:v|[Vv]ersion[ \t]+)\d+\.\d+(?:\.\d+)?[\w.+-]*(?:[ \t]*\([0-9a-f]{6,}\))?$/;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Why this output is not a measurement, or null if it is.
|
|
155
|
+
*
|
|
156
|
+
* THE single binding that decides it, because two deciders answering one
|
|
157
|
+
* question are behaviourally one and a mutation of either leaves the other
|
|
158
|
+
* holding the case up (`.claude/rules/checks-must-be-able-to-fail.md`).
|
|
159
|
+
*
|
|
160
|
+
* The two unmeasured states carry DIFFERENT sentences on purpose. A command
|
|
161
|
+
* that printed nothing and a command that printed only a banner are fixed by
|
|
162
|
+
* different edits, so one shared reason would be a warning nobody can act on.
|
|
163
|
+
*/
|
|
164
|
+
export function baselineUnmeasuredReason(output: string | null): string | null {
|
|
165
|
+
if (output === null) {
|
|
166
|
+
return "the evidence command was not run, so there is no baseline output to read";
|
|
167
|
+
}
|
|
168
|
+
const trimmed = output.trim();
|
|
169
|
+
if (trimmed.length === 0) {
|
|
170
|
+
return "the command ran and printed nothing, so there is no value to compare against the threshold";
|
|
171
|
+
}
|
|
172
|
+
const lines = trimmed.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
173
|
+
if (lines.every((l) => VERSION_BANNER.test(l))) {
|
|
174
|
+
return (
|
|
175
|
+
`the only output is a tool version banner (${lines.join(" / ")}), which is the tool ` +
|
|
176
|
+
"announcing itself and not a reading of the tree"
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Does this output clear this bar? Null when no comparison could be made.
|
|
184
|
+
*
|
|
185
|
+
* Null rather than false for an uncomparable pair, because `false` says the
|
|
186
|
+
* bar was tested and missed — a claim about the tree — while null says nobody
|
|
187
|
+
* could test it. Collapsing the two is how an AC with a nonsense threshold
|
|
188
|
+
* reads as an AC that simply has not landed yet.
|
|
189
|
+
*/
|
|
190
|
+
export function thresholdSatisfiedBy(
|
|
191
|
+
output: string,
|
|
192
|
+
threshold: ACThresholdInput | null | undefined,
|
|
193
|
+
): boolean | null {
|
|
194
|
+
const op = threshold?.op;
|
|
195
|
+
if (!op) return null;
|
|
196
|
+
const text = output.trim();
|
|
197
|
+
if (op === "exists") return text.length > 0;
|
|
198
|
+
if (op === "contains") {
|
|
199
|
+
if (threshold?.value === undefined || threshold.value === null) return null;
|
|
200
|
+
return text.includes(String(threshold.value));
|
|
201
|
+
}
|
|
202
|
+
const expected = parseFloat(String(threshold?.value));
|
|
203
|
+
const actual = parseFloat(text);
|
|
204
|
+
if (Number.isNaN(expected) || Number.isNaN(actual) || !/^-?\d+(?:\.\d+)?$/.test(text)) return null;
|
|
205
|
+
switch (op) {
|
|
206
|
+
case ">=": return actual >= expected;
|
|
207
|
+
case "<=": return actual <= expected;
|
|
208
|
+
case ">": return actual > expected;
|
|
209
|
+
case "<": return actual < expected;
|
|
210
|
+
case "==": return actual === expected;
|
|
211
|
+
case "!=": return actual !== expected;
|
|
212
|
+
default: return null;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Compose one AC's pre-change baseline from what its command printed.
|
|
218
|
+
*
|
|
219
|
+
* One site, so the ordering is not re-decided anywhere: the output is
|
|
220
|
+
* classified FIRST, and only a MEASURED output is ever handed to the
|
|
221
|
+
* comparison. That ordering is the whole of #669's third criterion — an
|
|
222
|
+
* UNMEASURED baseline is never reduced to a threshold comparison, and the
|
|
223
|
+
* only way to guarantee that is to make the comparison unreachable from the
|
|
224
|
+
* unmeasured branch rather than to check afterwards that it did not happen.
|
|
225
|
+
*
|
|
226
|
+
* `output` is null when the command never ran at all.
|
|
227
|
+
*/
|
|
228
|
+
export function acBaseline(
|
|
229
|
+
output: string | null,
|
|
230
|
+
threshold: ACThresholdInput | null | undefined,
|
|
231
|
+
): ACBaseline {
|
|
232
|
+
const recorded = threshold ? { ...threshold } : null;
|
|
233
|
+
const reason = baselineUnmeasuredReason(output);
|
|
234
|
+
if (reason !== null) {
|
|
235
|
+
return {
|
|
236
|
+
verdict: "UNMEASURED",
|
|
237
|
+
output: (output ?? "").trim(),
|
|
238
|
+
reason,
|
|
239
|
+
threshold: recorded,
|
|
240
|
+
satisfiesThreshold: null,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
const text = (output as string).trim();
|
|
244
|
+
return {
|
|
245
|
+
verdict: "MEASURED",
|
|
246
|
+
output: text,
|
|
247
|
+
reason: null,
|
|
248
|
+
threshold: recorded,
|
|
249
|
+
satisfiesThreshold: recorded ? thresholdSatisfiedBy(text, recorded) : null,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The ids whose PRE-CHANGE output already clears their own threshold.
|
|
255
|
+
*
|
|
256
|
+
* An AC in this list cannot observe the work: its command printed a
|
|
257
|
+
* satisfying value before a line was written, so it will print one afterwards
|
|
258
|
+
* whatever Marcus does. That is a check that cannot fail, arriving in the
|
|
259
|
+
* harness's own acceptance criteria.
|
|
260
|
+
*
|
|
261
|
+
* Exported and called by BOTH the writer (`measureEvidencePrevalidation`) and
|
|
262
|
+
* the reader (`prevalidationViolations` in gates/workflow.test.ts), so there
|
|
263
|
+
* is one binding to mutate. `broken` taught this at the cost of a heal round:
|
|
264
|
+
* until #295 the reader derived its own answer, disagreed with the writer, and
|
|
265
|
+
* the refusal named nothing.
|
|
266
|
+
*/
|
|
267
|
+
export function alreadySatisfiedIds(acs: unknown): string[] {
|
|
268
|
+
if (!Array.isArray(acs)) return [];
|
|
269
|
+
return acs
|
|
270
|
+
.filter((ac: unknown) => (ac as { baseline?: ACBaseline })?.baseline?.satisfiesThreshold === true)
|
|
271
|
+
.map((ac: unknown) => String((ac as { id?: unknown })?.id ?? ""))
|
|
272
|
+
.filter((id: string) => id.length > 0);
|
|
273
|
+
}
|
|
274
|
+
|
|
81
275
|
// ── Auto-fix patterns ───────────────────────────────────────────────────
|
|
82
276
|
|
|
83
277
|
/**
|
|
@@ -160,11 +354,17 @@ export async function prevalidateEvidence(
|
|
|
160
354
|
for (const ac of acs) {
|
|
161
355
|
const rawCommand = ac.evidenceMethod?.command;
|
|
162
356
|
|
|
163
|
-
// Skip ACs without a command
|
|
357
|
+
// Skip ACs without a command.
|
|
358
|
+
//
|
|
359
|
+
// It still carries a baseline (#669), and the baseline still says why
|
|
360
|
+
// there is nothing in it. A missing `baseline` key and a command that
|
|
361
|
+
// produced no value read identically to every consumer, which is the
|
|
362
|
+
// confusion this field exists to remove.
|
|
164
363
|
if (!rawCommand) {
|
|
165
364
|
results.push({
|
|
166
365
|
id: ac.id,
|
|
167
366
|
status: "skipped",
|
|
367
|
+
baseline: acBaseline(null, ac.threshold),
|
|
168
368
|
});
|
|
169
369
|
continue;
|
|
170
370
|
}
|
|
@@ -203,8 +403,22 @@ export async function prevalidateEvidence(
|
|
|
203
403
|
* single push site rather than at each branch is what keeps a later
|
|
204
404
|
* auto-fix pattern from quietly landing with only half the pair.
|
|
205
405
|
*/
|
|
406
|
+
/**
|
|
407
|
+
* What the command printed on this tree, or null if it never ran (#669).
|
|
408
|
+
*
|
|
409
|
+
* Captured per AC and read by `record` so the baseline is composed at the
|
|
410
|
+
* SINGLE push site. Stamping it at each branch instead would let a later
|
|
411
|
+
* classification land with the pre-change reading quietly missing, which
|
|
412
|
+
* is the half-pair problem `originalCommand` already has a comment about.
|
|
413
|
+
*/
|
|
414
|
+
let printed: string | null = null;
|
|
415
|
+
|
|
206
416
|
const record = (r: PrevalidationResult): void => {
|
|
207
|
-
|
|
417
|
+
const withBaseline: PrevalidationResult = {
|
|
418
|
+
...r,
|
|
419
|
+
baseline: acBaseline(printed, ac.threshold),
|
|
420
|
+
};
|
|
421
|
+
results.push(withBaseline.autoFixed ? { ...withBaseline, originalCommand: rawCommand } : withBaseline);
|
|
208
422
|
};
|
|
209
423
|
|
|
210
424
|
// Check for bun test pipe pattern BEFORE running — always auto-fix
|
|
@@ -262,6 +476,7 @@ export async function prevalidateEvidence(
|
|
|
262
476
|
cwd: projectRoot,
|
|
263
477
|
stdio: ["pipe", "pipe", "pipe"],
|
|
264
478
|
}).trim();
|
|
479
|
+
printed = output;
|
|
265
480
|
|
|
266
481
|
if (output.length === 0) {
|
|
267
482
|
record(withRefFix({
|
|
@@ -284,6 +499,10 @@ export async function prevalidateEvidence(
|
|
|
284
499
|
const exitCode: number = e.status ?? 1;
|
|
285
500
|
const stdout = (e.stdout?.toString?.() || "").trim();
|
|
286
501
|
const stderr = (e.stderr?.toString?.() || "").trim();
|
|
502
|
+
// A command that exited non-zero still ran, so its stdout is the
|
|
503
|
+
// baseline reading. `grep` exit 1 is the case that matters: it is a
|
|
504
|
+
// RESULT (#271), and the value it measured is in stdout.
|
|
505
|
+
printed = stdout;
|
|
287
506
|
|
|
288
507
|
// A grep that selected nothing has not failed — it has measured zero
|
|
289
508
|
// (#271). Classified here, before any repair is attempted, so the
|
|
@@ -366,6 +585,7 @@ export async function measureEvidencePrevalidation(
|
|
|
366
585
|
checkedAt,
|
|
367
586
|
acs: [],
|
|
368
587
|
broken: [],
|
|
588
|
+
alreadySatisfied: [],
|
|
369
589
|
reason,
|
|
370
590
|
});
|
|
371
591
|
|
|
@@ -407,6 +627,8 @@ export async function measureEvidencePrevalidation(
|
|
|
407
627
|
// site that derives it, so the verdict and the names it refuses under
|
|
408
628
|
// cannot disagree.
|
|
409
629
|
broken: broken.map((r) => r.id),
|
|
630
|
+
// Same discipline as `broken`, through the binding the gate reads (#669).
|
|
631
|
+
alreadySatisfied: alreadySatisfiedIds(results),
|
|
410
632
|
reason: null,
|
|
411
633
|
};
|
|
412
634
|
}
|