spec-controller 0.1.0-alpha.2 → 0.1.0-alpha.3
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.
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* CLI (cli-balance/cli.ts) calls these once to build the RunContext.
|
|
7
7
|
*
|
|
8
8
|
* Scenarios: @SCN-RPT-001 (the run-provenance slice); the --source-sha override;
|
|
9
|
-
* @SCN-RPT-016 (target-root derivation).
|
|
9
|
+
* @SCN-RPT-016 (target-root derivation); @SCN-RPT-026 / @SCN-RPT-029 (the tool's own identity).
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* Resolve the target's source SHA (project design §4). An explicit non-empty
|
|
@@ -32,17 +32,30 @@ export interface ToolIdentity {
|
|
|
32
32
|
* distinct from the TARGET's `sourceSha`. Two facts, one call, threaded to both the
|
|
33
33
|
* report provenance (RunContext) and the run.yaml manifest.
|
|
34
34
|
*
|
|
35
|
-
* **
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* OWN dir>`, derived from `import.meta.url`, never cwd.
|
|
35
|
+
* **TWO TRAPS, AND THIS DOCBLOCK ONLY NAMED THE FIRST FOR ELEVEN WEEKS** (@SCN-RPT-029,
|
|
36
|
+
* 3F-3418). Nothing typechecks a comment, and the sentence below — true, and the whole of
|
|
37
|
+
* what was written here — is what made the second trap read as already-handled.
|
|
39
38
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* `
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
39
|
+
* **Trap one, cwd:** at run time the process cwd is the TARGET repo (reconcile runs
|
|
40
|
+
* there), so a bare `git rev-parse HEAD` would re-record the TARGET's SHA. So the SHA is
|
|
41
|
+
* read `git -C <the tool's OWN dir>`, derived from `import.meta.url`, never cwd (3F-1916).
|
|
42
|
+
*
|
|
43
|
+
* **Trap two, which the `-C` guard could not see:** the tool's own dir is ITSELF inside the
|
|
44
|
+
* target. For an installed package that dir is `<consumer>/node_modules/…`, which is inside
|
|
45
|
+
* the consumer's worktree, so `git -C` walks up to the consumer's `.git` and answers with
|
|
46
|
+
* the consumer's HEAD — being `.gitignore`d makes no difference, git does not stop at
|
|
47
|
+
* ignored directories. That is not an absent tool SHA, it is a WRONG one, and nothing on
|
|
48
|
+
* the rendered report distinguishes it from a genuine one. It is also the only case a
|
|
49
|
+
* consumer ever sees: every adopter installs into a git repository. `resolveToolSha`
|
|
50
|
+
* therefore answers a `node_modules` SEGMENT before it asks git at all.
|
|
51
|
+
*
|
|
52
|
+
* `toolSha` is `null` for a tool resolved out of `node_modules`, and otherwise
|
|
53
|
+
* `git -C <toolDir> rev-parse HEAD` (trimmed) or `null` on any throw — no `.git` above the
|
|
54
|
+
* tool, git absent, or an empty answer — mirroring `resolveSourceSha`'s fail-soft.
|
|
55
|
+
* `toolVersion` is read from the tool's own `package.json` (walked up from `toolDir`), or
|
|
56
|
+
* `"unknown"` when none is found — so a run stays attributable by version even when no SHA
|
|
57
|
+
* can be read. `toolDir` / `packageJsonPath` are injectable for the `@unit` teeth
|
|
58
|
+
* (@SCN-RPT-026, @SCN-RPT-029).
|
|
46
59
|
*/
|
|
47
60
|
export declare function resolveToolIdentity(opts?: {
|
|
48
61
|
toolDir?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveRunInputs.d.ts","sourceRoot":"","sources":["../../src/run-management/resolveRunInputs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAiBhG;AAED,gFAAgF;AAChF,MAAM,WAAW,YAAY;IAC3B,mGAAmG;IACnG,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,2FAA2F;IAC3F,WAAW,EAAE,MAAM,CAAC;CACrB;AAED
|
|
1
|
+
{"version":3,"file":"resolveRunInputs.d.ts","sourceRoot":"","sources":["../../src/run-management/resolveRunInputs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAiBhG;AAED,gFAAgF;AAChF,MAAM,WAAW,YAAY;IAC3B,mGAAmG;IACnG,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,2FAA2F;IAC3F,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,YAAY,CAQ3G;AAiED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAerE"}
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* CLI (cli-balance/cli.ts) calls these once to build the RunContext.
|
|
7
7
|
*
|
|
8
8
|
* Scenarios: @SCN-RPT-001 (the run-provenance slice); the --source-sha override;
|
|
9
|
-
* @SCN-RPT-016 (target-root derivation).
|
|
9
|
+
* @SCN-RPT-016 (target-root derivation); @SCN-RPT-026 / @SCN-RPT-029 (the tool's own identity).
|
|
10
10
|
*/
|
|
11
11
|
import { execFileSync } from "node:child_process";
|
|
12
12
|
import { readFileSync } from "node:fs";
|
|
13
|
-
import { dirname, join } from "node:path";
|
|
13
|
+
import { dirname, join, sep } from "node:path";
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
15
|
/**
|
|
16
16
|
* Resolve the target's source SHA (project design §4). An explicit non-empty
|
|
@@ -44,17 +44,30 @@ export function resolveSourceSha(opts) {
|
|
|
44
44
|
* distinct from the TARGET's `sourceSha`. Two facts, one call, threaded to both the
|
|
45
45
|
* report provenance (RunContext) and the run.yaml manifest.
|
|
46
46
|
*
|
|
47
|
-
* **
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* OWN dir>`, derived from `import.meta.url`, never cwd.
|
|
47
|
+
* **TWO TRAPS, AND THIS DOCBLOCK ONLY NAMED THE FIRST FOR ELEVEN WEEKS** (@SCN-RPT-029,
|
|
48
|
+
* 3F-3418). Nothing typechecks a comment, and the sentence below — true, and the whole of
|
|
49
|
+
* what was written here — is what made the second trap read as already-handled.
|
|
51
50
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* `
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
51
|
+
* **Trap one, cwd:** at run time the process cwd is the TARGET repo (reconcile runs
|
|
52
|
+
* there), so a bare `git rev-parse HEAD` would re-record the TARGET's SHA. So the SHA is
|
|
53
|
+
* read `git -C <the tool's OWN dir>`, derived from `import.meta.url`, never cwd (3F-1916).
|
|
54
|
+
*
|
|
55
|
+
* **Trap two, which the `-C` guard could not see:** the tool's own dir is ITSELF inside the
|
|
56
|
+
* target. For an installed package that dir is `<consumer>/node_modules/…`, which is inside
|
|
57
|
+
* the consumer's worktree, so `git -C` walks up to the consumer's `.git` and answers with
|
|
58
|
+
* the consumer's HEAD — being `.gitignore`d makes no difference, git does not stop at
|
|
59
|
+
* ignored directories. That is not an absent tool SHA, it is a WRONG one, and nothing on
|
|
60
|
+
* the rendered report distinguishes it from a genuine one. It is also the only case a
|
|
61
|
+
* consumer ever sees: every adopter installs into a git repository. `resolveToolSha`
|
|
62
|
+
* therefore answers a `node_modules` SEGMENT before it asks git at all.
|
|
63
|
+
*
|
|
64
|
+
* `toolSha` is `null` for a tool resolved out of `node_modules`, and otherwise
|
|
65
|
+
* `git -C <toolDir> rev-parse HEAD` (trimmed) or `null` on any throw — no `.git` above the
|
|
66
|
+
* tool, git absent, or an empty answer — mirroring `resolveSourceSha`'s fail-soft.
|
|
67
|
+
* `toolVersion` is read from the tool's own `package.json` (walked up from `toolDir`), or
|
|
68
|
+
* `"unknown"` when none is found — so a run stays attributable by version even when no SHA
|
|
69
|
+
* can be read. `toolDir` / `packageJsonPath` are injectable for the `@unit` teeth
|
|
70
|
+
* (@SCN-RPT-026, @SCN-RPT-029).
|
|
58
71
|
*/
|
|
59
72
|
export function resolveToolIdentity(opts = {}) {
|
|
60
73
|
const toolDir = opts.toolDir !== undefined && opts.toolDir.trim() !== ""
|
|
@@ -65,8 +78,31 @@ export function resolveToolIdentity(opts = {}) {
|
|
|
65
78
|
toolVersion: resolveToolVersion(opts.packageJsonPath ?? findPackageJson(toolDir)),
|
|
66
79
|
};
|
|
67
80
|
}
|
|
68
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* The tool's own git HEAD, read `-C <toolDir>` (never cwd), null on any throw — and null
|
|
83
|
+
* without asking at all for a tool resolved out of `node_modules` (@SCN-RPT-029).
|
|
84
|
+
*
|
|
85
|
+
* A SEGMENT, NEVER A SUBSTRING. A directory honestly named `my_node_modules_backup` is not an
|
|
86
|
+
* install, and a checkout living under a directory literally named `node_modules` reporting null is
|
|
87
|
+
* the pathological trade every tool making this distinction takes.
|
|
88
|
+
*
|
|
89
|
+
* `sep`, NOT A REGEX OVER BOTH SEPARATORS. `[/\\]` would carry a branch no arm on this platform can
|
|
90
|
+
* reach, so a mutant deleting its second half would survive the mutation gate while nothing was
|
|
91
|
+
* worse. `sep` is what `fileURLToPath` produces on each platform, which is the only thing `toolDir`
|
|
92
|
+
* is ever built from.
|
|
93
|
+
*
|
|
94
|
+
* IT ANSWERS BEFORE THE `try`, NOT INSIDE IT. Returning null from a thrown git read and returning
|
|
95
|
+
* null because the tool is an install are the same recorded answer and not the same fact, and only
|
|
96
|
+
* the first of them is allowed to depend on git being present.
|
|
97
|
+
*
|
|
98
|
+
* WHAT IT DOES NOT CLAIM. Under `--preserve-symlinks` Node reports the symlink path rather than the
|
|
99
|
+
* realpath, so a linked development checkout would carry a `node_modules` segment and report null.
|
|
100
|
+
* That is a strictly safer wrong answer than today's, nothing in this repository passes the flag,
|
|
101
|
+
* and no arm covers it — named rather than guarded.
|
|
102
|
+
*/
|
|
69
103
|
function resolveToolSha(toolDir) {
|
|
104
|
+
if (toolDir.split(sep).includes("node_modules"))
|
|
105
|
+
return null;
|
|
70
106
|
try {
|
|
71
107
|
const out = execFileSync("git", ["-C", toolDir, "rev-parse", "HEAD"], {
|
|
72
108
|
encoding: "utf8",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveRunInputs.js","sourceRoot":"","sources":["../../src/run-management/resolveRunInputs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveRunInputs.js","sourceRoot":"","sources":["../../src/run-management/resolveRunInputs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAgD;IAC/E,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACjE,O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,CAAC;YAChC,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YAC5B,IAAI,MAAM,KAAK,GAAG;gBAAE,OAAO,IAAI,CAAC;YAChC,GAAG,GAAG,MAAM,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAA2B;IAC3D,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC/D,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;IACvB,CAAC;IACD,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,CAAC,EAAE;YACjF,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;SACpC,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-controller",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
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",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@cucumber/gherkin": "^41.0.0",
|
|
31
31
|
"@cucumber/messages": "^34.0.1",
|
|
32
32
|
"yaml": "^2.9.0",
|
|
33
|
-
"@3f-consulting/spec-controller-core": "0.1.0-alpha.
|
|
33
|
+
"@3f-consulting/spec-controller-core": "0.1.0-alpha.3"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|