spec-controller 0.1.240 → 0.1.242

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +4 -4
  2. package/dist/cli.js +42 -12
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -42,7 +42,7 @@ spec-controller balance --features ./features --vitest ./vitest-report.json --ex
42
42
 
43
43
  The report is byte for byte the one the gate prints: the same rows, the same out-of-balance count, and the same headline naming the code the gate would give. Only the exit status changes:
44
44
 
45
- - Out-of-balance and scenario code errors (`1`), and pending under `--strict` (`3`), exit `0`.
45
+ - Out-of-balance and claim code errors (`1`), and pending under `--strict` (`3`), exit `0`.
46
46
  - Usage (`2`), unsound (`4`), nothing to reconcile (`5`) and an unexpected error before the verdict (`6`) still fail. Each means the run could not reach a verdict, and a flag that suppresses verdicts does not suppress that.
47
47
 
48
48
  Work the out-of-balance rows down, then delete `--exit-zero`, and the gate is on. Do not wrap the step in `continue-on-error` or `|| true` instead. Those swallow the codes that mean the run could not be trusted, and leave nothing in the command to show the gate is off.
@@ -56,14 +56,14 @@ spec-controller balance \
56
56
  --cucumber ./cucumber-report.json
57
57
  ```
58
58
 
59
- A scenario tagged `@unit` names an obligation: a unit test must exist and pass. The evidence answers it by citing the scenario's `@SCN` code in its test name. Where the two agree, the row is **balanced**. Where they do not, the row says how: evidence missing, evidence failing, or evidence that cites a scenario nobody wrote.
59
+ A scenario tagged `@unit` names an obligation: a unit test must exist and pass. The evidence answers it by citing the scenario's claim code in its test name. Where the two agree, the row is **balanced**. Where they do not, the row says how: evidence missing, evidence failing, or evidence that cites a scenario nobody wrote.
60
60
 
61
61
  ## Exit codes
62
62
 
63
63
  | Exit | What it says |
64
64
  | --- | --- |
65
65
  | `0` | balanced — every obligation has evidence, and it holds |
66
- | `1` | out-of-balance — the two records disagree, and the report says where; or a scenario code is misfiled, listed under `### Scenario code errors` |
66
+ | `1` | out-of-balance — the two records disagree, and the report says where; or a claim code is misfiled, listed under `### Claim code errors` |
67
67
  | `2` | usage — the invocation was wrong |
68
68
  | `3` | balanced, but carrying Pending Items, and you asked for `--strict` |
69
69
  | `4` | unsound — a proving suite failed to collect, so the ledger could not be trusted to disagree |
@@ -96,7 +96,7 @@ The refusal names the input, the path, and what was wrong with it. A well-formed
96
96
 
97
97
  ### `allocate`
98
98
 
99
- `spec-controller allocate` prints the next scenario code for a feature part. It reaches no verdict: it exits `0` when it answers, and `2` for a usage error or an unknown part. A file or directory it cannot read, directly or through git, is a usage error: it is refused, naming the path and the reason, and no code is given.
99
+ `spec-controller allocate` prints the next claim code for a feature part. It reaches no verdict: it exits `0` when it answers, and `2` for a usage error or an unknown part. A file or directory it cannot read, directly or through git, is a usage error: it is refused, naming the path and the reason, and no code is given.
100
100
 
101
101
  ## On CI
102
102
 
package/dist/cli.js CHANGED
@@ -11434,12 +11434,13 @@ function isFeaturePart(text) {
11434
11434
  function headerFeatureCode(featureTags) {
11435
11435
  return featureTags.find(isFeaturePart) ?? null;
11436
11436
  }
11437
- var FEATURE_PART_SOURCE, PREFIX_SOURCE, SCN_ID_SOURCE, SCN_CODE, FEATURE_CODE_OF, FEATURE_PART;
11437
+ var FEATURE_PART_SOURCE, CLAIM_CODE_PREFIXES, PREFIX_SOURCE, SCN_ID_SOURCE, SCN_CODE, FEATURE_CODE_OF, FEATURE_PART;
11438
11438
  var init_featureCode = __esm({
11439
11439
  "../core/dist/domain/featureCode.js"() {
11440
11440
  "use strict";
11441
11441
  FEATURE_PART_SOURCE = "[A-Z0-9]{2,5}";
11442
- PREFIX_SOURCE = "(?:CLM|SCN)";
11442
+ CLAIM_CODE_PREFIXES = ["CLM", "SCN"];
11443
+ PREFIX_SOURCE = `(?:${CLAIM_CODE_PREFIXES.join("|")})`;
11443
11444
  SCN_ID_SOURCE = `${PREFIX_SOURCE}-${FEATURE_PART_SOURCE}-\\d+`;
11444
11445
  SCN_CODE = new RegExp(`^${SCN_ID_SOURCE}$`);
11445
11446
  FEATURE_CODE_OF = new RegExp(`^${PREFIX_SOURCE}-(${FEATURE_PART_SOURCE})-\\d+$`);
@@ -11695,6 +11696,24 @@ function countScnOccurrences(source) {
11695
11696
  function gherkinDocumentOf(source) {
11696
11697
  return new Parser(new AstBuilder(IdGenerator_exports2.uuid()), new GherkinClassicTokenMatcher()).parse(source);
11697
11698
  }
11699
+ function claimColumnOf(examples) {
11700
+ return examples.tableHeader?.cells.findIndex((cell) => cell.value === CLAIM_COLUMN) ?? -1;
11701
+ }
11702
+ function rowCodeOf(cell) {
11703
+ return SCN_CODE.test(cell) ? [cell] : [];
11704
+ }
11705
+ function rowClaimsOf(outline, outlineTags) {
11706
+ if (!outline.examples.some((examples) => claimColumnOf(examples) >= 0))
11707
+ return null;
11708
+ return outline.examples.flatMap((examples) => {
11709
+ const column = claimColumnOf(examples);
11710
+ const blockTags = examples.tags.map((tag) => bareTerm(tag.name));
11711
+ return examples.tableBody.map((row) => ({
11712
+ name: outline.name,
11713
+ tags: [...row.cells.filter((_, index) => index === column).flatMap((cell) => rowCodeOf(cell.value)), ...outlineTags, ...blockTags]
11714
+ }));
11715
+ });
11716
+ }
11698
11717
  function contentOf({ feature }, source) {
11699
11718
  const scnOccurrences = countScnOccurrences(source);
11700
11719
  if (feature === void 0)
@@ -11717,7 +11736,12 @@ function contentOf({ feature }, source) {
11717
11736
  countTags(child.scenario.tags);
11718
11737
  for (const examples of child.scenario.examples)
11719
11738
  countTags(examples.tags);
11720
- scenarios.push({ name: child.scenario.name, tags: [...bare(child.scenario.tags), ...inherited] });
11739
+ const tags = [...bare(child.scenario.tags), ...inherited];
11740
+ const rows = rowClaimsOf(child.scenario, tags);
11741
+ if (rows === null)
11742
+ scenarios.push({ name: child.scenario.name, tags });
11743
+ else
11744
+ scenarios.push(...rows);
11721
11745
  }
11722
11746
  };
11723
11747
  countTags(feature.tags);
@@ -11765,7 +11789,7 @@ function namedScenariosOf(feature, deferralTags = []) {
11765
11789
  title: scenario.name
11766
11790
  }));
11767
11791
  }
11768
- var SCN_OCCURRENCE;
11792
+ var SCN_OCCURRENCE, CLAIM_COLUMN;
11769
11793
  var init_scenarios = __esm({
11770
11794
  "../core/dist/parse/scenarios.js"() {
11771
11795
  "use strict";
@@ -11778,6 +11802,7 @@ var init_scenarios = __esm({
11778
11802
  init_scenarioObligations();
11779
11803
  init_sourceParse();
11780
11804
  SCN_OCCURRENCE = new RegExp(`@${SCN_ID_SOURCE}`, "g");
11805
+ CLAIM_COLUMN = "clm";
11781
11806
  }
11782
11807
  });
11783
11808
 
@@ -12514,7 +12539,7 @@ function nextScnCode(request, occurrences) {
12514
12539
  }
12515
12540
  const highest = highestOf(request.part, occurrences);
12516
12541
  const next = (highest === null ? 0 : numberOf(highest.code)) + 1;
12517
- const code = `SCN-${request.part}-${String(next).padStart(NUMBER_WIDTH, "0")}`;
12542
+ const code = `CLM-${request.part}-${String(next).padStart(NUMBER_WIDTH, "0")}`;
12518
12543
  return headed && request.isNew === true ? { kind: "allocated", code, highest, alreadyHeaded: true } : { kind: "allocated", code, highest };
12519
12544
  }
12520
12545
  function unknownPartCarried(unknown) {
@@ -38962,7 +38987,7 @@ import { lstatSync as lstatSync3, readFileSync as readFileSync7 } from "node:fs"
38962
38987
  import { dirname as dirname5, join as join8 } from "node:path";
38963
38988
  function readHistory(cwd, part) {
38964
38989
  proveRefsReadable(cwd);
38965
- const args = ["log", "--all", "-p", "-U0", "--no-color", "--no-ext-diff", "--format=%x01%h", "-G", `SCN-${part}-`];
38990
+ const args = ["log", "--all", "-p", "-U0", "--no-color", "--no-ext-diff", "--format=%x01%h", "-G", `(${CLAIM_CODE_PREFIXES.join("|")})-${part}-`];
38966
38991
  const result = spawnSync2("git", args, { cwd, encoding: "utf8", maxBuffer: MAX_OUTPUT_BYTES });
38967
38992
  if (result.error !== void 0) refuse2("history" /* History */, cwd, result.error);
38968
38993
  if (result.status !== 0) {
@@ -39048,6 +39073,7 @@ var MAX_OUTPUT_BYTES, COMMIT_MARKER;
39048
39073
  var init_readHistory = __esm({
39049
39074
  "src/cli-allocate/readHistory.ts"() {
39050
39075
  "use strict";
39076
+ init_dist3();
39051
39077
  init_refStore();
39052
39078
  init_messages();
39053
39079
  init_unreadable();
@@ -39064,7 +39090,7 @@ function readTree(top, part) {
39064
39090
  const listed = gitListing(top, ["ls-files", "-z", "--cached", "--others", "--exclude-standard"]);
39065
39091
  const ignored = gitListing(top, ["ls-files", "-z", "--others", "--ignored", "--exclude-standard", "--directory"]);
39066
39092
  proveListable(top, "", new Set(ignored.filter(isDirectoryEntry).map((entry) => entry.slice(0, -1))));
39067
- return listed.flatMap((path) => occurrencesInListed(top, path, `SCN-${part}-`));
39093
+ return listed.flatMap((path) => occurrencesInListed(top, path, needlesFor(part)));
39068
39094
  }
39069
39095
  function gitListing(top, args) {
39070
39096
  const result = spawnSync3("git", args, { cwd: top, encoding: "utf8", maxBuffer: MAX_OUTPUT_BYTES2 });
@@ -39090,15 +39116,18 @@ function listedAndEntered(path) {
39090
39116
  accessSync(path, constants2.R_OK | constants2.X_OK);
39091
39117
  return readdirSync4(path, { withFileTypes: true });
39092
39118
  }
39093
- function occurrencesInListed(top, path, needle) {
39119
+ function needlesFor(part) {
39120
+ return CLAIM_CODE_PREFIXES.map((prefix) => `${prefix}-${part}-`);
39121
+ }
39122
+ function occurrencesInListed(top, path, needles) {
39094
39123
  const file = join9(top, path);
39095
39124
  const kind = readOrRefuse("tree-file" /* TreeFile */, file, () => lstatSync4(file, { throwIfNoEntry: false }));
39096
39125
  if (kind === void 0 || !kind.isFile()) return [];
39097
- return linesCarrying(path, readOrRefuse("tree-file" /* TreeFile */, file, () => readFileSync8(file)), needle);
39126
+ return linesCarrying(path, readOrRefuse("tree-file" /* TreeFile */, file, () => readFileSync8(file)), needles);
39098
39127
  }
39099
- function linesCarrying(path, content, needle) {
39128
+ function linesCarrying(path, content, needles) {
39100
39129
  if (content.subarray(0, BINARY_PROBE_BYTES).includes(0)) return [];
39101
- return content.toString("utf8").split("\n").flatMap((line, i) => line.includes(needle) ? [{ path, line: i + 1, text: line }] : []);
39130
+ return content.toString("utf8").split("\n").flatMap((line, i) => needles.some((needle) => line.includes(needle)) ? [{ path, line: i + 1, text: line }] : []);
39102
39131
  }
39103
39132
  function isWalkedDirectory(name) {
39104
39133
  return name !== "node_modules" && !name.startsWith(".");
@@ -39106,7 +39135,7 @@ function isWalkedDirectory(name) {
39106
39135
  function walkTree(root, part) {
39107
39136
  return filesUnder(root).flatMap((file) => {
39108
39137
  const content = readOrRefuse("tree-file" /* TreeFile */, file, () => readFileSync8(file));
39109
- return linesCarrying(relative2(root, file).split(sep4).join("/"), content, `SCN-${part}-`);
39138
+ return linesCarrying(relative2(root, file).split(sep4).join("/"), content, needlesFor(part));
39110
39139
  });
39111
39140
  }
39112
39141
  function filesUnder(dir) {
@@ -39121,6 +39150,7 @@ var MAX_OUTPUT_BYTES2, BINARY_PROBE_BYTES;
39121
39150
  var init_readTree = __esm({
39122
39151
  "src/cli-allocate/readTree.ts"() {
39123
39152
  "use strict";
39153
+ init_dist3();
39124
39154
  init_messages();
39125
39155
  init_unreadable();
39126
39156
  MAX_OUTPUT_BYTES2 = 1024 * 1024 * 1024;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-controller",
3
- "version": "0.1.240",
3
+ "version": "0.1.242",
4
4
  "description": "Reconcile the behaviour your scenarios name against the evidence that actually ran — the deterministic `balance` CLI.",
5
5
  "keywords": [
6
6
  "reconciliation",
@@ -26,7 +26,7 @@
26
26
  "fast-xml-parser": "^5.11.2",
27
27
  "ts-json-schema-generator": "^2.9.0",
28
28
  "yaml": "^2.9.0",
29
- "@3f-consulting/spec-controller-core": "0.1.240"
29
+ "@3f-consulting/spec-controller-core": "0.1.242"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"