spec-controller 0.1.0-alpha.3 → 0.1.0-alpha.31
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/README.md +27 -5
- package/dist/cli-allocate/cli.d.ts +2 -0
- package/dist/cli-allocate/cli.d.ts.map +1 -0
- package/dist/cli-allocate/cli.js +45 -0
- package/dist/cli-allocate/cli.js.map +1 -0
- package/dist/cli-allocate/readHistory.d.ts +21 -0
- package/dist/cli-allocate/readHistory.d.ts.map +1 -0
- package/dist/cli-allocate/readHistory.js +97 -0
- package/dist/cli-allocate/readHistory.js.map +1 -0
- package/dist/cli-allocate/readParts.d.ts +3 -0
- package/dist/cli-allocate/readParts.d.ts.map +1 -0
- package/dist/cli-allocate/readParts.js +25 -0
- package/dist/cli-allocate/readParts.js.map +1 -0
- package/dist/cli-allocate/readTree.d.ts +17 -0
- package/dist/cli-allocate/readTree.d.ts.map +1 -0
- package/dist/cli-allocate/readTree.js +63 -0
- package/dist/cli-allocate/readTree.js.map +1 -0
- package/dist/cli-allocate/request.d.ts +11 -0
- package/dist/cli-allocate/request.d.ts.map +1 -0
- package/dist/cli-allocate/request.js +29 -0
- package/dist/cli-allocate/request.js.map +1 -0
- package/dist/cli-allocate/stderr.d.ts +14 -0
- package/dist/cli-allocate/stderr.d.ts.map +1 -0
- package/dist/cli-allocate/stderr.js +33 -0
- package/dist/cli-allocate/stderr.js.map +1 -0
- package/dist/cli-args.d.ts +70 -14
- package/dist/cli-args.d.ts.map +1 -1
- package/dist/cli-args.js +239 -18
- package/dist/cli-args.js.map +1 -1
- package/dist/cli-balance/cli.d.ts +18 -1
- package/dist/cli-balance/cli.d.ts.map +1 -1
- package/dist/cli-balance/cli.js +185 -161
- package/dist/cli-balance/cli.js.map +1 -1
- package/dist/cli-balance/emit/writer.d.ts +8 -23
- package/dist/cli-balance/emit/writer.d.ts.map +1 -1
- package/dist/cli-balance/emit/writer.js +24 -32
- package/dist/cli-balance/emit/writer.js.map +1 -1
- package/dist/cli-registry.d.ts +28 -0
- package/dist/cli-registry.d.ts.map +1 -1
- package/dist/cli-registry.js +39 -34
- package/dist/cli-registry.js.map +1 -1
- package/dist/cli.d.ts +4 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +26 -12
- package/dist/cli.js.map +1 -1
- package/dist/deferralTags.d.ts +2 -2
- package/dist/deferralTags.js +2 -2
- package/dist/host.d.ts +25 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +119 -15
- package/dist/host.js.map +1 -1
- package/dist/ingest/gherkinValidation.d.ts +9 -12
- package/dist/ingest/gherkinValidation.d.ts.map +1 -1
- package/dist/ingest/gherkinValidation.js +9 -12
- package/dist/ingest/gherkinValidation.js.map +1 -1
- package/dist/ingest/ingestQualityChecks.d.ts +3 -49
- package/dist/ingest/ingestQualityChecks.d.ts.map +1 -1
- package/dist/ingest/ingestQualityChecks.js +27 -120
- package/dist/ingest/ingestQualityChecks.js.map +1 -1
- package/dist/ingest/ingestScenarios.d.ts +8 -14
- package/dist/ingest/ingestScenarios.d.ts.map +1 -1
- package/dist/ingest/ingestScenarios.js +32 -55
- package/dist/ingest/ingestScenarios.js.map +1 -1
- package/dist/outputLocation.d.ts +15 -0
- package/dist/outputLocation.d.ts.map +1 -0
- package/dist/outputLocation.js +39 -0
- package/dist/outputLocation.js.map +1 -0
- package/dist/run-management/keptRun.d.ts +14 -19
- package/dist/run-management/keptRun.d.ts.map +1 -1
- package/dist/run-management/keptRun.js +15 -20
- package/dist/run-management/keptRun.js.map +1 -1
- package/package.json +2 -7
- package/dist/corpus/cli.d.ts +0 -34
- package/dist/corpus/cli.d.ts.map +0 -1
- package/dist/corpus/cli.js +0 -128
- package/dist/corpus/cli.js.map +0 -1
- package/dist/mutation-ratchet/index.d.ts +0 -46
- package/dist/mutation-ratchet/index.d.ts.map +0 -1
- package/dist/mutation-ratchet/index.js +0 -46
- package/dist/mutation-ratchet/index.js.map +0 -1
- package/dist/mutation-ratchet/record.d.ts +0 -178
- package/dist/mutation-ratchet/record.d.ts.map +0 -1
- package/dist/mutation-ratchet/record.js +0 -314
- package/dist/mutation-ratchet/record.js.map +0 -1
- package/dist/mutation-ratchet/report.d.ts +0 -109
- package/dist/mutation-ratchet/report.d.ts.map +0 -1
- package/dist/mutation-ratchet/report.js +0 -156
- package/dist/mutation-ratchet/report.js.map +0 -1
package/dist/cli-balance/cli.js
CHANGED
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { existsSync, readFileSync } from "node:fs";
|
|
15
15
|
import { dirname } from "node:path";
|
|
16
|
-
import { runReconcile, readEvidenceObligations, readFeatureNames, featureCorpusParseErrors,
|
|
16
|
+
import { runReconcile, readEvidenceObligations, readFeatureNames, featureCorpusParseErrors, } from "../ingest/ingestQualityChecks.js";
|
|
17
17
|
import { planOutput } from "./emit/format.js";
|
|
18
18
|
import { writeOutputs } from "./emit/writer.js";
|
|
19
|
-
import { renderReportFromJson, isBalanced, hasPendingItems, hasBrokenEvidence, hasNothingToReconcile, } from "@3f-consulting/spec-controller-core";
|
|
19
|
+
import { renderReportFromJson, isBalanced, hasPendingItems, hasBrokenEvidence, hasNothingToReconcile, hasScenarioCodeErrors, } from "@3f-consulting/spec-controller-core";
|
|
20
20
|
import { resolveSourceSha, resolveTargetRoot, resolveToolIdentity } from "../run-management/resolveRunInputs.js";
|
|
21
21
|
import { cliRegistry, renderCommandHelp } from "../cli-registry.js";
|
|
22
22
|
// THE ARGV READING AND ITS REGISTRY BOUNDING, SHARED WITH EVERY OTHER COMMAND (3F-3300). Both
|
|
23
23
|
// lived here while `balance` was the only command; a second command needs them, and a second
|
|
24
24
|
// copy of "what did the operator type" is the one thing this tree least wants two of.
|
|
25
|
-
import { parseArgs, checkUnknownFlags } from "../cli-args.js";
|
|
25
|
+
import { parseArgs, checkArgvShape, checkUnknownFlags, checkMissingValues, checkMisplacedHostModifiers, } from "../cli-args.js";
|
|
26
26
|
/**
|
|
27
27
|
* Collect the `--format <spec>` values from argv in order (the flag is REPEATABLE, unlike
|
|
28
28
|
* the single-valued flags `parseArgs` records) — the raw specs `planOutput` parses. Empty
|
|
@@ -72,23 +72,6 @@ export function checkLegacyJson(args) {
|
|
|
72
72
|
export function sourceTarget(args) {
|
|
73
73
|
return args["target"] ?? "unknown-target";
|
|
74
74
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Guard the supplied input-file/dir flags at the CLI edge (@SCN-CLI-002). A
|
|
77
|
-
* mistyped `--vitest` / `--cucumber` / `--features` / `--ci` / `--package-json`
|
|
78
|
-
* pointing at a non-existent path used to reconcile silently against ZERO evidence —
|
|
79
|
-
* a terrifying false all-red report meaning "you forgot the reports", not "your code
|
|
80
|
-
* is broken" (the dogfooding fault). These flags are Examples of ONE boundary
|
|
81
|
-
* rule: a supplied-but-absent input path is a hard error, and a flag added to the set
|
|
82
|
-
* inherits it rather than restating it. Scope is existence only
|
|
83
|
-
* (readability / file-vs-dir type-correctness out of scope; `exists` covers the dir
|
|
84
|
-
* flag and the file flags alike).
|
|
85
|
-
*
|
|
86
|
-
* PURE and `@unit`-testable like `checkLegacyJson` / `sourceTarget`: reads the parsed
|
|
87
|
-
* args + an injected `exists` fn (no fs), returns the FIRST supplied-but-absent
|
|
88
|
-
* `(flag, path)` as a typed error naming both — routed to stderr + a non-zero exit by
|
|
89
|
-
* `runBalance` (the shared typed-error surface) — else null. An OMITTED flag is not an
|
|
90
|
-
* error (legitimately optional: simply no evidence of that kind).
|
|
91
|
-
*/
|
|
92
75
|
/**
|
|
93
76
|
* The parsed args, as the reconciler's input paths — the one place a `--flag` name becomes a
|
|
94
77
|
* `ReconcileOptions` key.
|
|
@@ -104,16 +87,32 @@ function reconcileInputsOf(args) {
|
|
|
104
87
|
cucumber: args["cucumber"],
|
|
105
88
|
ci: args["ci"],
|
|
106
89
|
packageJson: args["package-json"],
|
|
107
|
-
measurements: args["measurements"],
|
|
108
90
|
ciSteps: args["ci-steps"],
|
|
109
91
|
};
|
|
110
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Guard the supplied input-file/dir flags at the CLI edge (@SCN-CLI-002). A
|
|
95
|
+
* mistyped `--vitest` / `--cucumber` / `--features` / `--ci` / `--package-json`
|
|
96
|
+
* pointing at a non-existent path used to reconcile silently against ZERO evidence —
|
|
97
|
+
* a terrifying false all-red report meaning "you forgot the reports", not "your code
|
|
98
|
+
* is broken" (the dogfooding fault). These flags are Examples of ONE boundary
|
|
99
|
+
* rule: a supplied-but-absent input path is a hard error, and a flag added to the set
|
|
100
|
+
* inherits it rather than restating it. Scope is existence only
|
|
101
|
+
* (readability / file-vs-dir type-correctness out of scope; `exists` covers the dir
|
|
102
|
+
* flag and the file flags alike).
|
|
103
|
+
*
|
|
104
|
+
* PURE and `@unit`-testable like `checkLegacyJson` / `sourceTarget`: reads the parsed
|
|
105
|
+
* args + an injected `exists` fn (no fs), returns the FIRST supplied-but-absent
|
|
106
|
+
* `(flag, path)` as a typed error naming both — routed to stderr + a non-zero exit by
|
|
107
|
+
* `refuseUnreadableInputs` (the shared typed-error surface) — else null. An OMITTED flag is not an
|
|
108
|
+
* error (legitimately optional: simply no evidence of that kind).
|
|
109
|
+
*/
|
|
111
110
|
export function checkInputsExist(args, exists) {
|
|
112
111
|
// The input flags in a fixed order — the FIRST supplied-but-absent one is the
|
|
113
112
|
// reported error (deterministic; the operator fixes and re-runs). Keys are the
|
|
114
113
|
// parseArgs form (the `--` stripped); the message names the flag WITH its dashes.
|
|
115
114
|
const flags = [
|
|
116
|
-
"vitest", "cucumber", "features", "ci", "package-json", "
|
|
115
|
+
"vitest", "cucumber", "features", "ci", "package-json", "ci-steps",
|
|
117
116
|
];
|
|
118
117
|
for (const flag of flags) {
|
|
119
118
|
const path = args[flag];
|
|
@@ -130,7 +129,7 @@ export function checkInputsExist(args, exists) {
|
|
|
130
129
|
* process, and on garbage both reconcile normally (verified, 3F-1742 Discovery).
|
|
131
130
|
*/
|
|
132
131
|
const JSON_INPUT_FLAGS = [
|
|
133
|
-
"vitest", "cucumber", "package-json", "
|
|
132
|
+
"vitest", "cucumber", "package-json", "ci-steps",
|
|
134
133
|
];
|
|
135
134
|
/**
|
|
136
135
|
* Guard the READABILITY of the supplied JSON inputs at the CLI edge (@SCN-CLI-014).
|
|
@@ -143,7 +142,7 @@ const JSON_INPUT_FLAGS = [
|
|
|
143
142
|
*
|
|
144
143
|
* PURE and `@unit`-testable like its sibling guards: reads the parsed args + an injected
|
|
145
144
|
* `read` fn (no fs), returns the FIRST supplied-but-unparseable `(flag, path, failure)` as
|
|
146
|
-
* a typed error naming all three — routed to stderr + exit 2 by `
|
|
145
|
+
* a typed error naming all three — routed to stderr + exit 2 by `refuseUnreadableInputs` — else null.
|
|
147
146
|
* An omitted flag is not an error, and an unreadable file (a race after the existence
|
|
148
147
|
* check) reports as the same input fault rather than escaping as a crash.
|
|
149
148
|
*/
|
|
@@ -217,20 +216,27 @@ export function runBalance(argv) {
|
|
|
217
216
|
// guard's typed error is routed to stderr + a non-zero exit, exactly as planOutput's error
|
|
218
217
|
// is below (the shared typed-error surface).
|
|
219
218
|
const legacyJsonError = checkLegacyJson(args);
|
|
220
|
-
if (legacyJsonError)
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
//
|
|
228
|
-
//
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
//
|
|
233
|
-
//
|
|
219
|
+
if (legacyJsonError)
|
|
220
|
+
exitUsage(legacyJsonError);
|
|
221
|
+
// A host modifier after the command is out of place, not unknown (@SCN-CLI-061, 3F-3639), so it is
|
|
222
|
+
// refused before the drift advice, through `process.exit` so a stored run is never stamped.
|
|
223
|
+
const misplacedModifierError = checkMisplacedHostModifiers(args, cliRegistry, "balance");
|
|
224
|
+
if (misplacedModifierError)
|
|
225
|
+
exitUsage(misplacedModifierError);
|
|
226
|
+
// Every token is a flag or the value of the flag before it (3F-3672), refused through
|
|
227
|
+
// `process.exit` so a stored run is never stamped, and before the unknown-flag check below.
|
|
228
|
+
const shapeError = checkArgvShape(argv, cliRegistry, "balance");
|
|
229
|
+
if (shapeError)
|
|
230
|
+
exitUsage(shapeError);
|
|
231
|
+
// Registry-bounded flag NAMES (@SCN-CLI-009): `balance` accepts ONLY the flags its registry
|
|
232
|
+
// scope LISTS. An unregistered flag — a typo `--strcit`, a stray `--bogus` — is a USAGE error:
|
|
233
|
+
// name it on stderr, set process.exitCode = 2 (the enumerated usage code, 3F-1414's 0/1/2
|
|
234
|
+
// taxonomy — never 1, never 0), and RETURN before any reconcile. It bounds names only; that every
|
|
235
|
+
// other token is read or refused is the argv-shape check above (@SCN-CLI-062–066, 3F-3672).
|
|
236
|
+
// Runs AFTER the legacy-`--json` guard so `--json` keeps its specific migration hint, after the
|
|
237
|
+
// misplaced-modifier refusal, so a `--store` / `--run-id` written after the command is named as
|
|
238
|
+
// out of place rather than given pin advice, and after the argv-shape check, so `--format=json` is
|
|
239
|
+
// refused as a form and never given pin advice. This is the structural teeth behind "accepted =
|
|
234
240
|
// registry = help" — a flag can't affect behaviour without a registry entry.
|
|
235
241
|
const unknownFlagError = checkUnknownFlags(args, cliRegistry, "balance", resolveToolIdentity().toolVersion);
|
|
236
242
|
if (unknownFlagError) {
|
|
@@ -238,97 +244,15 @@ export function runBalance(argv) {
|
|
|
238
244
|
process.exitCode = 2;
|
|
239
245
|
return;
|
|
240
246
|
}
|
|
241
|
-
//
|
|
242
|
-
//
|
|
243
|
-
//
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
// malformed file to SyntaxError, both landing on Node's default exit 1 — the
|
|
249
|
-
// out-of-balance code. The missing-path case was a live violation of @SCN-CLI-002's own
|
|
250
|
-
// shipped principle, which the CLI enforced for the five evidence flags and not for this
|
|
251
|
-
// one. The guard therefore runs INSIDE this branch, ahead of the read (3F-1764).
|
|
252
|
-
const unreadableSavedReportError = checkRenderFromJson(args, (path) => readFileSync(path, "utf8"));
|
|
253
|
-
if (unreadableSavedReportError) {
|
|
254
|
-
process.stderr.write(unreadableSavedReportError + "\n");
|
|
255
|
-
process.exit(2);
|
|
256
|
-
}
|
|
257
|
-
const rehydratePath = args["render-from-json"];
|
|
258
|
-
if (rehydratePath !== undefined) {
|
|
259
|
-
const savedReport = readFileSync(rehydratePath, "utf8");
|
|
260
|
-
process.stdout.write(renderReportFromJson(savedReport) + "\n");
|
|
247
|
+
// A flag that takes a value, given none (@SCN-CLI-058, 3F-3639), refused before anything reads
|
|
248
|
+
// the value `parseArgs` made up for it. `process.exit`, never a set status and a return: inside a
|
|
249
|
+
// stored run the return would reach the kept-run scaffold, which stamps a run.yaml (3F-3650).
|
|
250
|
+
const missingValueError = checkMissingValues(argv, cliRegistry, "balance");
|
|
251
|
+
if (missingValueError)
|
|
252
|
+
exitUsage(missingValueError);
|
|
253
|
+
if (renderSavedReport(args))
|
|
261
254
|
return;
|
|
262
|
-
|
|
263
|
-
// Input-existence guard (@SCN-CLI-002): a supplied input-file/dir flag pointing at a
|
|
264
|
-
// non-existent path is a HARD ERROR — halt BEFORE reconciling, with a typed message
|
|
265
|
-
// naming the flag + path, never the silent zero-evidence all-red report a mistyped
|
|
266
|
-
// path used to produce (the dogfooding fault). Routed to stderr + a non-zero exit,
|
|
267
|
-
// exactly as the legacy-`--json` guard above (the shared typed-error surface). An
|
|
268
|
-
// omitted flag is legitimately optional and passes through untouched.
|
|
269
|
-
const missingInputError = checkInputsExist(args, existsSync);
|
|
270
|
-
if (missingInputError) {
|
|
271
|
-
process.stderr.write(missingInputError + "\n");
|
|
272
|
-
// Usage/input error → exit 2 (@SCN-CLI-002), distinct from the out-of-balance
|
|
273
|
-
// verdict code 1 (@SCN-CLI-004).
|
|
274
|
-
process.exit(2);
|
|
275
|
-
}
|
|
276
|
-
// Input-READABILITY guard (@SCN-CLI-014): existence is not enough. A report that is
|
|
277
|
-
// PRESENT but UNPARSEABLE (`--vitest /dev/null`, truncated JSON, non-JSON) used to throw
|
|
278
|
-
// mid-parse inside reconcileWithCensus, uncaught — and Node's default exit code is 1, the
|
|
279
|
-
// code reserved for a genuine OUT-OF-BALANCE verdict (@SCN-CLI-004). So a tool that
|
|
280
|
-
// CRASHED before reconciling was indistinguishable, by exit code, from an honest
|
|
281
|
-
// disagreement (3F-1742). Runs immediately after the existence guard and BEFORE any
|
|
282
|
-
// reconcile, routing to the same stderr + exit 2 lane: an input the tool cannot read is a
|
|
283
|
-
// usage fault, sibling to a missing path and an unrecognised flag — never a verdict.
|
|
284
|
-
const unparseableInputError = checkInputsParse(args, (path) => readFileSync(path, "utf8"));
|
|
285
|
-
if (unparseableInputError) {
|
|
286
|
-
process.stderr.write(unparseableInputError + "\n");
|
|
287
|
-
process.exit(2);
|
|
288
|
-
}
|
|
289
|
-
// The FEATURE-CORPUS integrity checkpoint (@SCN-CLI-016, 3F-1767). The feature corpus is an
|
|
290
|
-
// input too — the ledger's DEBIT side — and it was read by a hand-rolled TAG-LINE SCAN that
|
|
291
|
-
// never consulted a parser. So a malformed tag line simply stopped being a tag line and its
|
|
292
|
-
// scenario CEASED TO EXIST: one stray character deleted a failing row and turned an
|
|
293
|
-
// out-of-balance run (exit 1) into a clean BALANCED (exit 0). A dropped scenario cannot even
|
|
294
|
-
// reconcile `missing`, because it was never RAISED to be missing — the run read cleaner than
|
|
295
|
-
// reality, the exact false-green this tool exists to prevent.
|
|
296
|
-
//
|
|
297
|
-
// Validated with the REAL Gherkin parser (cucumber's own), so a file the tool would reconcile is
|
|
298
|
-
// at least a file cucumber would RUN. A file it rejects is an input we CANNOT READ: exit 2,
|
|
299
|
-
// halting BEFORE any reconcile, naming the file and the parse failure — the same Rule as
|
|
300
|
-
// @SCN-CLI-014 and @SCN-CLI-015 ("an input the tool cannot read is a usage error, never a
|
|
301
|
-
// verdict"), now on the obligation side. Never a verdict, and never a green.
|
|
302
|
-
//
|
|
303
|
-
// The corpus is EXTRACTED from the same real AST (@SCN-LDG-020), so what the tool reconciles is
|
|
304
|
-
// what cucumber runs — Feature/Rule tag inheritance included. This guard decides whether the file
|
|
305
|
-
// can be read at all; parseScenarios then reads it exactly as cucumber would.
|
|
306
|
-
const featureParseErrors = featureCorpusParseErrors(args["features"]);
|
|
307
|
-
if (featureParseErrors.length > 0) {
|
|
308
|
-
for (const { file, message } of featureParseErrors) {
|
|
309
|
-
process.stderr.write(`The --features corpus contains a feature file that could not be parsed: ${file}\n${message}\n`);
|
|
310
|
-
}
|
|
311
|
-
process.exit(2);
|
|
312
|
-
}
|
|
313
|
-
// AMBIGUOUS-CORPUS guard (@SCN-LDG-020's guardrail, 3F-1775). An @SCN identifies exactly ONE
|
|
314
|
-
// scenario — that is the whole basis of attributing evidence to it. Tag inheritance makes a
|
|
315
|
-
// DUPLICATE reachable: an @SCN hoisted to a Feature:/Rule: is inherited by every scenario
|
|
316
|
-
// beneath it (cucumber does this, so we do). One passing test would then mark EVERY scenario
|
|
317
|
-
// sharing that id `balanced` — including scenarios nothing proves — a BALANCED-WHEN-BROKEN run
|
|
318
|
-
// at exit 0. A new silent false-green, introduced by the very fix that closed the last one.
|
|
319
|
-
//
|
|
320
|
-
// So the corpus is REFUSED, not reconciled: the tool cannot know which scenario a citing test
|
|
321
|
-
// proves, and any verdict over it would be a guess. Same Rule as @SCN-CLI-014/015/016 — an input
|
|
322
|
-
// the tool cannot read is a usage error, never a verdict.
|
|
323
|
-
const duplicateScnIds = featureCorpusDuplicateScnIds(args["features"]);
|
|
324
|
-
if (duplicateScnIds.length > 0) {
|
|
325
|
-
process.stderr.write(`The --features corpus names the same @SCN on more than one scenario: ` +
|
|
326
|
-
`${duplicateScnIds.join(", ")}.\n` +
|
|
327
|
-
`An @SCN identifies exactly one scenario — evidence citing a duplicated id cannot be ` +
|
|
328
|
-
`attributed, so no verdict over this corpus would be trustworthy. (An @SCN on a Feature: ` +
|
|
329
|
-
`or Rule: line is inherited by every scenario beneath it — name it on the scenario.)\n`);
|
|
330
|
-
process.exit(2);
|
|
331
|
-
}
|
|
255
|
+
refuseUnreadableInputs(args);
|
|
332
256
|
const inputs = reconcileInputsOf(args);
|
|
333
257
|
// Reconcile the obligation-vs-observation evidence into the Ledger. The runtime evidence-observation
|
|
334
258
|
// views (Test volume, the evidence grid) are FOLDS the renderers derive off this Ledger's posted
|
|
@@ -348,31 +272,7 @@ export function runBalance(argv) {
|
|
|
348
272
|
// — the by-feature cut's full-name labels. The 5th sibling, threaded to the MARKDOWN
|
|
349
273
|
// renderer via writeOutputs only (markdown-only; the by-feature cut isn't on JSON).
|
|
350
274
|
const featureNames = readFeatureNames(args["features"]);
|
|
351
|
-
|
|
352
|
-
// Ledger staying pure — reusing the existing runStart. The target is the
|
|
353
|
-
// operator's --target VERBATIM (unknown-target on omit; Fork A — no
|
|
354
|
-
// resolution, no basename guessing). Source SHA via the read-only target read, with
|
|
355
|
-
// --source-sha as the override (resolveSourceSha).
|
|
356
|
-
const ctx = {
|
|
357
|
-
target: sourceTarget(args),
|
|
358
|
-
inputs,
|
|
359
|
-
runStart,
|
|
360
|
-
sourceSha: resolveSourceSha({
|
|
361
|
-
sourceSha: args["source-sha"],
|
|
362
|
-
targetDir: args["features"] !== undefined ? dirname(args["features"]) : undefined,
|
|
363
|
-
}),
|
|
364
|
-
// The TARGET repo root the recorded input paths are made portable against (fixed to
|
|
365
|
-
// the target root, not the run cwd, by @SCN-RPT-016) — the SAME
|
|
366
|
-
// root readEvidenceObservations passes to countRuntimeEvidenceObservationKinds, derived from
|
|
367
|
-
// --features, so a cross-repo reconcile records inputs relative (`features`) rather
|
|
368
|
-
// than leaking the target's absolute path.
|
|
369
|
-
root: resolveTargetRoot({ features: inputs.features }),
|
|
370
|
-
// The TOOL's own identity (@SCN-RPT-026, 3F-1916) — which spec-controller produced
|
|
371
|
-
// this run, distinct from the target's sourceSha. Read from the tool's OWN dir, never
|
|
372
|
-
// cwd (which is the target). One call, spread into the ctx; the same identity feeds
|
|
373
|
-
// the run.yaml manifest.
|
|
374
|
-
...resolveToolIdentity(),
|
|
375
|
-
};
|
|
275
|
+
const ctx = runContextOf(args, inputs, runStart);
|
|
376
276
|
// Plan the outputs from the --format specs (no flag → md→stdout) and write them via
|
|
377
277
|
// the writer — the pure plan / impure writer split (@SCN-FMT-001). The plan
|
|
378
278
|
// parse+validate is pure; the writer is the only IO for the emitted report. This is
|
|
@@ -380,12 +280,8 @@ export function runBalance(argv) {
|
|
|
380
280
|
// legacy runs/<target>/<ISO>/ auto-archive was removed with @SCN-RUN-001, the
|
|
381
281
|
// caller now routes stored runs (spec-controller's run-management layer).
|
|
382
282
|
const planResult = planOutput(collectFormatSpecs(argv));
|
|
383
|
-
if (!planResult.ok)
|
|
384
|
-
|
|
385
|
-
// Usage/config error (bad --format spec) → exit 2 (@SCN-CLI-002), distinct from the
|
|
386
|
-
// out-of-balance verdict code 1 (@SCN-CLI-004).
|
|
387
|
-
process.exit(2);
|
|
388
|
-
}
|
|
283
|
+
if (!planResult.ok)
|
|
284
|
+
exitUsage(planResult.error);
|
|
389
285
|
writeOutputs(planResult.plan, { balance, ctx, evidenceObligations, withRuntimeObservations: true, withStaticChecks: true, featureNames });
|
|
390
286
|
// The CI gate (@SCN-CLI-004): `balance` is a GATE, not just a reporter. AFTER the report
|
|
391
287
|
// is written in full, map the whole-run verdict to the process exit code. Out-of-balance
|
|
@@ -449,12 +345,126 @@ export function runBalance(argv) {
|
|
|
449
345
|
// credits HAS a row — its suspense row — and is an ordinary out-of-balance report at exit 1
|
|
450
346
|
// (@SCN-CLI-020). @SCN-CLI-004/005/010/012 are BYSTANDERS: every one of their fixtures carries
|
|
451
347
|
// rows, so none reaches this branch.
|
|
452
|
-
const
|
|
348
|
+
const verdict = verdictExitCode(balance, args["strict"] !== undefined);
|
|
349
|
+
const code = args["exit-zero"] !== undefined ? exitZeroStatus(verdict) : verdict;
|
|
453
350
|
// Assigned only when NON-ZERO, so a balanced run still LEAVES process.exitCode at its default
|
|
454
351
|
// rather than writing a 0 over it — the distinction @SCN-CLI-005 and @SCN-CLI-010 both rest on.
|
|
455
352
|
if (code !== 0)
|
|
456
353
|
process.exitCode = code;
|
|
457
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* A usage or input fault: the message on stderr, then exit 2 — the enumerated usage code
|
|
357
|
+
* (@SCN-CLI-002), distinct from the out-of-balance verdict code 1 (@SCN-CLI-004). An
|
|
358
|
+
* out-of-balance run must never masquerade as a usage error, nor the reverse.
|
|
359
|
+
*/
|
|
360
|
+
function exitUsage(message) {
|
|
361
|
+
process.stderr.write(message + "\n");
|
|
362
|
+
process.exit(2);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Render-from-saved-JSON mode (@SCN-RMD-007): regenerate the human markdown from a
|
|
366
|
+
* banked spec-reconciliation.json ALONE — no reconcile, no live inputs, no RunContext. Reads
|
|
367
|
+
* the file, JSON.parses it back into the whole-document report model, renders the markdown via
|
|
368
|
+
* renderReport, and writes it to stdout (the same trailing-newline convention as the writer's
|
|
369
|
+
* stdout path). The load-bearing proof that the JSON IS the model — true when it answered the
|
|
370
|
+
* run, so `runBalance` returns before any reconcile.
|
|
371
|
+
*/
|
|
372
|
+
function renderSavedReport(args) {
|
|
373
|
+
// Saved-report READABILITY guard (@SCN-CLI-015). This mode RETURNS before
|
|
374
|
+
// `refuseUnreadableInputs` ever runs, so it honoured NEITHER of its guards: a missing path
|
|
375
|
+
// crashed to ENOENT and a malformed file to SyntaxError, both landing on Node's default exit 1
|
|
376
|
+
// — the out-of-balance code. The missing-path case was a live violation of @SCN-CLI-002's own
|
|
377
|
+
// shipped principle, which the CLI enforced for the five evidence flags and not for this
|
|
378
|
+
// one. The guard therefore runs INSIDE this mode, ahead of the read (3F-1764).
|
|
379
|
+
const unreadableSavedReportError = checkRenderFromJson(args, (path) => readFileSync(path, "utf8"));
|
|
380
|
+
if (unreadableSavedReportError)
|
|
381
|
+
exitUsage(unreadableSavedReportError);
|
|
382
|
+
const rehydratePath = args["render-from-json"];
|
|
383
|
+
if (rehydratePath === undefined)
|
|
384
|
+
return false;
|
|
385
|
+
const savedReport = readFileSync(rehydratePath, "utf8");
|
|
386
|
+
process.stdout.write(renderReportFromJson(savedReport) + "\n");
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* The live-input guards, in the order they run: each halts at exit 2 BEFORE any reconcile,
|
|
391
|
+
* because an input the tool cannot read is a usage error, never a verdict.
|
|
392
|
+
*/
|
|
393
|
+
function refuseUnreadableInputs(args) {
|
|
394
|
+
// Input-existence guard (@SCN-CLI-002): a supplied input-file/dir flag pointing at a
|
|
395
|
+
// non-existent path is a HARD ERROR — halt BEFORE reconciling, with a typed message
|
|
396
|
+
// naming the flag + path, never the silent zero-evidence all-red report a mistyped
|
|
397
|
+
// path used to produce (the dogfooding fault). Routed to stderr + a non-zero exit,
|
|
398
|
+
// exactly as the legacy-`--json` guard (the shared typed-error surface). An
|
|
399
|
+
// omitted flag is legitimately optional and passes through untouched.
|
|
400
|
+
const missingInputError = checkInputsExist(args, existsSync);
|
|
401
|
+
if (missingInputError)
|
|
402
|
+
exitUsage(missingInputError);
|
|
403
|
+
// Input-READABILITY guard (@SCN-CLI-014): existence is not enough. A report that is
|
|
404
|
+
// PRESENT but UNPARSEABLE (`--vitest /dev/null`, truncated JSON, non-JSON) used to throw
|
|
405
|
+
// mid-parse inside reconcileWithCensus, uncaught — and Node's default exit code is 1, the
|
|
406
|
+
// code reserved for a genuine OUT-OF-BALANCE verdict (@SCN-CLI-004). So a tool that
|
|
407
|
+
// CRASHED before reconciling was indistinguishable, by exit code, from an honest
|
|
408
|
+
// disagreement (3F-1742). Runs immediately after the existence guard and BEFORE any
|
|
409
|
+
// reconcile, routing to the same stderr + exit 2 lane: an input the tool cannot read is a
|
|
410
|
+
// usage fault, sibling to a missing path and an unrecognised flag — never a verdict.
|
|
411
|
+
const unparseableInputError = checkInputsParse(args, (path) => readFileSync(path, "utf8"));
|
|
412
|
+
if (unparseableInputError)
|
|
413
|
+
exitUsage(unparseableInputError);
|
|
414
|
+
// The FEATURE-CORPUS integrity checkpoint (@SCN-CLI-016, 3F-1767). The feature corpus is an
|
|
415
|
+
// input too — the ledger's DEBIT side — and it was read by a hand-rolled TAG-LINE SCAN that
|
|
416
|
+
// never consulted a parser. So a malformed tag line simply stopped being a tag line and its
|
|
417
|
+
// scenario CEASED TO EXIST: one stray character deleted a failing row and turned an
|
|
418
|
+
// out-of-balance run (exit 1) into a clean BALANCED (exit 0). A dropped scenario cannot even
|
|
419
|
+
// reconcile `missing`, because it was never RAISED to be missing — the run read cleaner than
|
|
420
|
+
// reality, the exact false-green this tool exists to prevent.
|
|
421
|
+
//
|
|
422
|
+
// Validated with the REAL Gherkin parser (cucumber's own), so a file the tool would reconcile is
|
|
423
|
+
// at least a file cucumber would RUN. A file it rejects is an input we CANNOT READ: exit 2,
|
|
424
|
+
// halting BEFORE any reconcile, naming the file and the parse failure — the same Rule as
|
|
425
|
+
// @SCN-CLI-014 and @SCN-CLI-015 ("an input the tool cannot read is a usage error, never a
|
|
426
|
+
// verdict"), now on the obligation side. Never a verdict, and never a green.
|
|
427
|
+
//
|
|
428
|
+
// The corpus is EXTRACTED from the same real AST (@SCN-LDG-020), so what the tool reconciles is
|
|
429
|
+
// what cucumber runs — Feature/Rule tag inheritance included. This guard decides whether the file
|
|
430
|
+
// can be read at all; parseScenarios then reads it exactly as cucumber would.
|
|
431
|
+
const featureParseErrors = featureCorpusParseErrors(args["features"]);
|
|
432
|
+
if (featureParseErrors.length > 0) {
|
|
433
|
+
for (const { file, message } of featureParseErrors) {
|
|
434
|
+
process.stderr.write(`The --features corpus contains a feature file that could not be parsed: ${file}\n${message}\n`);
|
|
435
|
+
}
|
|
436
|
+
process.exit(2);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Build the run provenance ONCE (project design §1) — a sibling RunContext, the
|
|
441
|
+
* Ledger staying pure — reusing the existing runStart. The target is the
|
|
442
|
+
* operator's --target VERBATIM (unknown-target on omit; Fork A — no
|
|
443
|
+
* resolution, no basename guessing). Source SHA via the read-only target read, with
|
|
444
|
+
* --source-sha as the override (resolveSourceSha).
|
|
445
|
+
*/
|
|
446
|
+
function runContextOf(args, inputs, runStart) {
|
|
447
|
+
return {
|
|
448
|
+
target: sourceTarget(args),
|
|
449
|
+
inputs,
|
|
450
|
+
runStart,
|
|
451
|
+
sourceSha: resolveSourceSha({
|
|
452
|
+
sourceSha: args["source-sha"],
|
|
453
|
+
targetDir: args["features"] !== undefined ? dirname(args["features"]) : undefined,
|
|
454
|
+
}),
|
|
455
|
+
// The TARGET repo root the recorded input paths are made portable against (fixed to
|
|
456
|
+
// the target root, not the run cwd, by @SCN-RPT-016) — the SAME
|
|
457
|
+
// root readEvidenceObservations passes to countRuntimeEvidenceObservationKinds, derived from
|
|
458
|
+
// --features, so a cross-repo reconcile records inputs relative (`features`) rather
|
|
459
|
+
// than leaking the target's absolute path.
|
|
460
|
+
root: resolveTargetRoot({ features: inputs.features }),
|
|
461
|
+
// The TOOL's own identity (@SCN-RPT-026, 3F-1916) — which spec-controller produced
|
|
462
|
+
// this run, distinct from the target's sourceSha. Read from the tool's OWN dir, never
|
|
463
|
+
// cwd (which is the target). One call, spread into the ctx; the same identity feeds
|
|
464
|
+
// the run.yaml manifest.
|
|
465
|
+
...resolveToolIdentity(),
|
|
466
|
+
};
|
|
467
|
+
}
|
|
458
468
|
/**
|
|
459
469
|
* THE DOMINANCE LADDER — the whole-run verdict as the enumerated status a consumer's CI branches
|
|
460
470
|
* on, and the ONE place the order argued for above is written down. Extracted from `runBalance`
|
|
@@ -464,17 +474,31 @@ export function runBalance(argv) {
|
|
|
464
474
|
* ENUMERATED, NEVER A COUNT — a count would 8-bit `& 0xFF` wrap into a false pass. Returns 0 for a
|
|
465
475
|
* balanced run; the caller leaves the process's default alone rather than writing that 0 back.
|
|
466
476
|
*/
|
|
467
|
-
function verdictExitCode(
|
|
477
|
+
function verdictExitCode(balance, strict) {
|
|
478
|
+
const { ledger } = balance;
|
|
468
479
|
if (hasNothingToReconcile(ledger))
|
|
469
480
|
return 5;
|
|
470
481
|
if (hasBrokenEvidence(ledger))
|
|
471
482
|
return 4;
|
|
483
|
+
// A misfiled code (3F-3635): every account still reconciles, so `isBalanced` alone would pass it.
|
|
484
|
+
if (hasScenarioCodeErrors(balance))
|
|
485
|
+
return 1;
|
|
472
486
|
if (!isBalanced(ledger))
|
|
473
487
|
return 1;
|
|
474
488
|
if (strict && hasPendingItems(ledger))
|
|
475
489
|
return 3;
|
|
476
490
|
return 0;
|
|
477
491
|
}
|
|
492
|
+
/**
|
|
493
|
+
* The codes `--exit-zero` moves to 0 (@SCN-CLI-021, 3F-3100): the two VERDICTS on the target —
|
|
494
|
+
* out-of-balance and pending-under-`--strict`. Enumerated rather than "anything non-zero", because
|
|
495
|
+
* unsound (4) and nothing-to-reconcile (5) are not verdicts but the absence of a trustworthy one,
|
|
496
|
+
* and suppressing a verdict never suppresses that. Usage (2) exits before the ladder is reached.
|
|
497
|
+
*/
|
|
498
|
+
const VERDICT_CODES = new Set([1, 3]);
|
|
499
|
+
function exitZeroStatus(code) {
|
|
500
|
+
return VERDICT_CODES.has(code) ? 0 : code;
|
|
501
|
+
}
|
|
478
502
|
// Only run the balance command when this module is executed directly
|
|
479
503
|
// (`tsx cli-balance/cli.ts`), NOT when imported by the top-level `spec-controller`
|
|
480
504
|
// bin dispatcher or by a test that exercises the pure edge guards.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli-balance/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,gBAAgB,EAChB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":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,CAAC;AAE3D,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED,qEAAqE;AACrE,mFAAmF;AACnF,mEAAmE;AACnE,MAAM,eAAe,GACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AACnF,IAAI,eAAe;IAAE,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The output
|
|
3
|
-
*
|
|
4
|
-
* the payload via the PURE renderers (`renderMarkdown` / `renderJson` in `src/render/`)
|
|
5
|
-
* and performs the IO: stdout, or a file.
|
|
6
|
-
*
|
|
7
|
-
* This is the ONLY layer that performs IO — the renderers stay pure (`model → string`)
|
|
8
|
-
* and `planOutput` stays pure (parse+validate). So the writer carries the `@integration`
|
|
9
|
-
* evidence: its real stdout/file effect is asserted directly (the anti-watermelon rule),
|
|
10
|
-
* never a re-run of the `planOutput` `@unit`.
|
|
11
|
-
*
|
|
12
|
-
* FMT-001 (`@SCN-FMT-001`) writes markdown to stdout. The `json` format (FMT-002) and the
|
|
13
|
-
* file destination (FMT-002/003) are wired on the same `render` + `dest` switch below as
|
|
14
|
-
* later sub-issues plan them.
|
|
15
|
-
*
|
|
16
|
-
* Parent: @SCN-FMT-001 — the output-dispatch rework.
|
|
2
|
+
* The output writer: renders each planned output through the pure renderers and performs the only
|
|
3
|
+
* IO in the pipeline, to stdout or to a file.
|
|
17
4
|
*/
|
|
18
5
|
import type { FeatureNames } from "@3f-consulting/spec-controller-core";
|
|
19
6
|
import type { OutputPlan } from "./format.js";
|
|
@@ -22,12 +9,9 @@ import type { EvidenceObligations } from "@3f-consulting/spec-controller-core";
|
|
|
22
9
|
import type { EvidenceReconciliation } from "@3f-consulting/spec-controller-core";
|
|
23
10
|
/**
|
|
24
11
|
* The reconciliation payloads the writer renders — the balance plus its sibling reads
|
|
25
|
-
* (ctx / evidenceObligations / featureNames), exactly the arguments the pure renderers take.
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* the Static checks cut): the renderers fold BOTH off the Ledger themselves (3F-2103 / 3F-2118 —
|
|
29
|
-
* the parallel censuses are retired), so the writer threads only whether each axis is in play,
|
|
30
|
-
* never a census object.
|
|
12
|
+
* (ctx / evidenceObligations / featureNames), exactly the arguments the pure renderers take.
|
|
13
|
+
* `withRuntimeObservations` and `withStaticChecks` gate the two observation axes; the renderers
|
|
14
|
+
* fold both off the Ledger themselves, so the writer threads only whether each axis is in play.
|
|
31
15
|
*/
|
|
32
16
|
export interface OutputPayloads {
|
|
33
17
|
readonly balance: EvidenceReconciliation;
|
|
@@ -38,8 +22,9 @@ export interface OutputPayloads {
|
|
|
38
22
|
readonly featureNames?: FeatureNames;
|
|
39
23
|
}
|
|
40
24
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
25
|
+
* Every file destination is proved writable before any output is emitted, so a refused run never
|
|
26
|
+
* leaves a report behind, on stdout or in a file, whose headline names an exit the process does not
|
|
27
|
+
* take. Writing files first and stdout last would not do: an earlier file would still be written.
|
|
43
28
|
*/
|
|
44
29
|
export declare function writeOutputs(plan: OutputPlan, payloads: OutputPayloads): void;
|
|
45
30
|
//# sourceMappingURL=writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../../src/cli-balance/emit/writer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../../src/cli-balance/emit/writer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,KAAK,EAAgB,UAAU,EAAiB,MAAM,aAAa,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAGlF;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IACzC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IACnD,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAC3C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;CACtC;AAQD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI,CAO7E"}
|