spec-controller 0.1.0-alpha.9 → 0.1.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/README.md +18 -11
- 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 +61 -0
- package/dist/cli-allocate/cli.js.map +1 -0
- package/dist/cli-allocate/readHistory.d.ts +14 -0
- package/dist/cli-allocate/readHistory.d.ts.map +1 -0
- package/dist/cli-allocate/readHistory.js +109 -0
- package/dist/cli-allocate/readHistory.js.map +1 -0
- package/dist/cli-allocate/readParts.d.ts +2 -0
- package/dist/cli-allocate/readParts.d.ts.map +1 -0
- package/dist/cli-allocate/readParts.js +23 -0
- package/dist/cli-allocate/readParts.js.map +1 -0
- package/dist/cli-allocate/readTree.d.ts +5 -0
- package/dist/cli-allocate/readTree.d.ts.map +1 -0
- package/dist/cli-allocate/readTree.js +74 -0
- package/dist/cli-allocate/readTree.js.map +1 -0
- package/dist/cli-allocate/refStore.d.ts +2 -0
- package/dist/cli-allocate/refStore.d.ts.map +1 -0
- package/dist/cli-allocate/refStore.js +35 -0
- package/dist/cli-allocate/refStore.js.map +1 -0
- package/dist/cli-allocate/request.d.ts +9 -0
- package/dist/cli-allocate/request.d.ts.map +1 -0
- package/dist/cli-allocate/request.js +23 -0
- package/dist/cli-allocate/request.js.map +1 -0
- package/dist/cli-allocate/stderr.d.ts +7 -0
- package/dist/cli-allocate/stderr.d.ts.map +1 -0
- package/dist/cli-allocate/stderr.js +32 -0
- package/dist/cli-allocate/stderr.js.map +1 -0
- package/dist/cli-allocate/unreadable.d.ts +13 -0
- package/dist/cli-allocate/unreadable.d.ts.map +1 -0
- package/dist/cli-allocate/unreadable.js +37 -0
- package/dist/cli-allocate/unreadable.js.map +1 -0
- package/dist/cli-args.d.ts +15 -70
- package/dist/cli-args.d.ts.map +1 -1
- package/dist/cli-args.js +167 -85
- package/dist/cli-args.js.map +1 -1
- package/dist/cli-balance/cli.d.ts +1 -82
- package/dist/cli-balance/cli.d.ts.map +1 -1
- package/dist/cli-balance/cli.js +86 -397
- package/dist/cli-balance/cli.js.map +1 -1
- package/dist/cli-balance/emit/format.d.ts +18 -39
- package/dist/cli-balance/emit/format.d.ts.map +1 -1
- package/dist/cli-balance/emit/format.js +32 -63
- package/dist/cli-balance/emit/format.js.map +1 -1
- package/dist/cli-balance/emit/writer.d.ts +2 -34
- package/dist/cli-balance/emit/writer.d.ts.map +1 -1
- package/dist/cli-balance/emit/writer.js +62 -37
- package/dist/cli-balance/emit/writer.js.map +1 -1
- package/dist/cli-balance/exitStatus.d.ts +2 -0
- package/dist/cli-balance/exitStatus.d.ts.map +1 -0
- package/dist/cli-balance/exitStatus.js +5 -0
- package/dist/cli-balance/exitStatus.js.map +1 -0
- package/dist/cli-balance/inputsRead.d.ts +11 -0
- package/dist/cli-balance/inputsRead.d.ts.map +1 -0
- package/dist/cli-balance/inputsRead.js +54 -0
- package/dist/cli-balance/inputsRead.js.map +1 -0
- package/dist/cli-balance/reRender.d.ts +8 -0
- package/dist/cli-balance/reRender.d.ts.map +1 -0
- package/dist/cli-balance/reRender.js +21 -0
- package/dist/cli-balance/reRender.js.map +1 -0
- package/dist/cli-balance/unreadableInputs.d.ts +15 -0
- package/dist/cli-balance/unreadableInputs.d.ts.map +1 -0
- package/dist/cli-balance/unreadableInputs.js +100 -0
- package/dist/cli-balance/unreadableInputs.js.map +1 -0
- package/dist/cli-registry.d.ts +16 -71
- package/dist/cli-registry.d.ts.map +1 -1
- package/dist/cli-registry.js +71 -136
- package/dist/cli-registry.js.map +1 -1
- package/dist/cli.d.ts +0 -21
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -85
- package/dist/cli.js.map +1 -1
- package/dist/deferralTags.d.ts +0 -14
- package/dist/deferralTags.d.ts.map +1 -1
- package/dist/deferralTags.js +0 -14
- package/dist/deferralTags.js.map +1 -1
- package/dist/host.d.ts +10 -41
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +99 -50
- package/dist/host.js.map +1 -1
- package/dist/ingest/ciSourcePaths.d.ts +0 -39
- package/dist/ingest/ciSourcePaths.d.ts.map +1 -1
- package/dist/ingest/ciSourcePaths.js +1 -39
- package/dist/ingest/ciSourcePaths.js.map +1 -1
- package/dist/ingest/gherkinValidation.d.ts +0 -80
- package/dist/ingest/gherkinValidation.d.ts.map +1 -1
- package/dist/ingest/gherkinValidation.js +3 -82
- package/dist/ingest/gherkinValidation.js.map +1 -1
- package/dist/ingest/ingestQualityChecks.d.ts +8 -93
- package/dist/ingest/ingestQualityChecks.d.ts.map +1 -1
- package/dist/ingest/ingestQualityChecks.js +61 -224
- package/dist/ingest/ingestQualityChecks.js.map +1 -1
- package/dist/ingest/ingestScenarios.d.ts +0 -45
- package/dist/ingest/ingestScenarios.d.ts.map +1 -1
- package/dist/ingest/ingestScenarios.js +24 -110
- package/dist/ingest/ingestScenarios.js.map +1 -1
- package/dist/ingest/inputShapes.d.ts +16 -0
- package/dist/ingest/inputShapes.d.ts.map +1 -0
- package/dist/ingest/inputShapes.js +114 -0
- package/dist/ingest/inputShapes.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +93 -0
- package/dist/main.js.map +1 -0
- package/dist/messages.d.ts +223 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +319 -0
- package/dist/messages.js.map +1 -0
- package/dist/outputLocation.d.ts +23 -0
- package/dist/outputLocation.d.ts.map +1 -0
- package/dist/outputLocation.js +139 -0
- package/dist/outputLocation.js.map +1 -0
- package/dist/run-management/keptRun.d.ts +8 -109
- package/dist/run-management/keptRun.d.ts.map +1 -1
- package/dist/run-management/keptRun.js +49 -89
- package/dist/run-management/keptRun.js.map +1 -1
- package/dist/run-management/resolveRunInputs.d.ts +0 -67
- package/dist/run-management/resolveRunInputs.d.ts.map +1 -1
- package/dist/run-management/resolveRunInputs.js +13 -117
- package/dist/run-management/resolveRunInputs.js.map +1 -1
- package/dist/storedRun.d.ts +6 -0
- package/dist/storedRun.d.ts.map +1 -0
- package/dist/storedRun.js +27 -0
- package/dist/storedRun.js.map +1 -0
- package/package.json +2 -2
- package/dist/corpus/cli.d.ts +0 -34
- package/dist/corpus/cli.d.ts.map +0 -1
- package/dist/corpus/cli.js +0 -125
- package/dist/corpus/cli.js.map +0 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { closeSync, constants, fstatSync, lstatSync, openSync, readlinkSync, realpathSync, statSync, unlinkSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve, sep } from "node:path";
|
|
3
|
+
const USAGE_EXIT_CODE = 2;
|
|
4
|
+
class UsageRefusal extends Error {
|
|
5
|
+
name = "UsageRefusal";
|
|
6
|
+
exitCode = USAGE_EXIT_CODE;
|
|
7
|
+
}
|
|
8
|
+
export function unwritableRefusal(subject, path, err) {
|
|
9
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
10
|
+
return `${subject}: ${path} (${reason})`;
|
|
11
|
+
}
|
|
12
|
+
export function writeOrRefuse(subject, path, write) {
|
|
13
|
+
try {
|
|
14
|
+
write();
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
refuse(unwritableRefusal(subject, path, err));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function refuse(message) {
|
|
21
|
+
process.stderr.write(message + "\n");
|
|
22
|
+
throw new UsageRefusal(message);
|
|
23
|
+
}
|
|
24
|
+
export function settlingRefusal(run, refused) {
|
|
25
|
+
try {
|
|
26
|
+
return run();
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
if (!(err instanceof UsageRefusal))
|
|
30
|
+
throw err;
|
|
31
|
+
process.exitCode = err.exitCode;
|
|
32
|
+
return refused;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function probeDestination(path) {
|
|
36
|
+
try {
|
|
37
|
+
return { identity: identityOf(openSync(path, constants.O_WRONLY)), created: undefined };
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
if (err.code !== "ENOENT")
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
const identity = identityOf(openSync(path, constants.O_WRONLY | constants.O_CREAT));
|
|
44
|
+
return { identity, created: realpathSync(path) };
|
|
45
|
+
}
|
|
46
|
+
export function firstSharingFile(file, others) {
|
|
47
|
+
const created = [];
|
|
48
|
+
try {
|
|
49
|
+
const identity = identityOrNone(file, created);
|
|
50
|
+
if (identity === undefined)
|
|
51
|
+
return undefined;
|
|
52
|
+
return others.find((other) => sameIdentity(identityOrNone(other, created), identity));
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
for (const path of created)
|
|
56
|
+
unlinkSync(path);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function identityOrNone(path, created) {
|
|
60
|
+
try {
|
|
61
|
+
const probed = probeDestination(path);
|
|
62
|
+
if (probed.created !== undefined)
|
|
63
|
+
created.push(probed.created);
|
|
64
|
+
return probed.identity;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// A path that cannot be opened for writing shares no file with the one being checked.
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
function sameIdentity(a, b) {
|
|
72
|
+
return a !== undefined && a.dev === b.dev && a.ino === b.ino;
|
|
73
|
+
}
|
|
74
|
+
export function regularFileIdentity(path) {
|
|
75
|
+
try {
|
|
76
|
+
return regularIdentity(statSync(path, { bigint: true }));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// A path that cannot be stat'd is no file, so it is no input's file either.
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
export function inputAt(path, inputs) {
|
|
84
|
+
const identity = regularFileIdentity(path);
|
|
85
|
+
if (identity === undefined)
|
|
86
|
+
return undefined;
|
|
87
|
+
return inputs.find((input) => sameIdentity(regularFileIdentity(input.path), identity));
|
|
88
|
+
}
|
|
89
|
+
export function stdoutIdentity() {
|
|
90
|
+
try {
|
|
91
|
+
return regularIdentity(fstatSync(1, { bigint: true }));
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// A closed stdout has no file for a destination to share.
|
|
95
|
+
}
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
function identityOf(fd) {
|
|
99
|
+
try {
|
|
100
|
+
return regularIdentity(fstatSync(fd, { bigint: true }));
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
closeSync(fd);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function regularIdentity(stats) {
|
|
107
|
+
return stats.isFile() ? { dev: stats.dev, ino: stats.ino } : undefined;
|
|
108
|
+
}
|
|
109
|
+
const STDOUT_SPELLINGS = new Set(["/dev/stdout", "/dev/fd/1", "/proc/self/fd/1", "/proc/thread-self/fd/1", `/proc/${process.pid}/fd/1`]);
|
|
110
|
+
const MAX_LINKS_FOLLOWED = 40;
|
|
111
|
+
export function namesStdout(path) {
|
|
112
|
+
let current = resolve(path);
|
|
113
|
+
for (let followed = 0; current !== undefined && followed <= MAX_LINKS_FOLLOWED; followed++) {
|
|
114
|
+
if (STDOUT_SPELLINGS.has(current))
|
|
115
|
+
return true;
|
|
116
|
+
current = withFirstLinkFollowed(current);
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
function withFirstLinkFollowed(path) {
|
|
121
|
+
const parts = path.split(sep).filter((part) => part !== "");
|
|
122
|
+
for (let length = 1; length <= parts.length; length++) {
|
|
123
|
+
const prefix = sep + parts.slice(0, length).join(sep);
|
|
124
|
+
const target = linkTarget(prefix);
|
|
125
|
+
if (target !== undefined)
|
|
126
|
+
return resolve(dirname(prefix), target, ...parts.slice(length));
|
|
127
|
+
}
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
function linkTarget(path) {
|
|
131
|
+
try {
|
|
132
|
+
return lstatSync(path).isSymbolicLink() ? readlinkSync(path) : undefined;
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// A prefix that cannot be read is followed no further: the path names stdout only as spelled.
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=outputLocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outputLocation.js","sourceRoot":"","sources":["../src/outputLocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjI,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAElD,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B,MAAM,YAAa,SAAQ,KAAK;IACZ,IAAI,GAAG,cAAc,CAAC;IAC/B,QAAQ,GAAG,eAAe,CAAC;CACrC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,IAAY,EAAE,GAAY;IAC3E,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChE,OAAO,GAAG,OAAO,KAAK,IAAI,KAAK,MAAM,GAAG,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,IAAY,EAAE,KAAiB;IAC5E,IAAI,CAAC;QACH,KAAK,EAAE,CAAC;IACV,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAe;IACpC,OAAO,CAAC,MAAM,CA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AO,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAY;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;IAC5D,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;QACtD,MAAM,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3E,CAAC;IAAC,MAAM,CAAC;QACP,8FAA8F;IAChG,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,79 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
* The KEPT-RUN scaffold — the thin app-layer that turns a bare tool invocation into a
|
|
3
|
-
* STORED run (the run-management layer). A kept run is a consultancy / product-dev artefact (NOT CI):
|
|
4
|
-
* it makes a per-run directory under a caller-INJECTED store root and routes the tool's
|
|
5
|
-
* `--format` outputs into it. The tool holds no storage opinion (the `--format` surface); this
|
|
6
|
-
* scaffold adds only the directory + the routing.
|
|
7
|
-
*
|
|
8
|
-
* Split by the three-layer architecture:
|
|
9
|
-
* - PURE planner (`planKeptRun`): given `{ storeRoot, target, runId }`, yields the run
|
|
10
|
-
* dir `<storeRoot>/<target>/<runId>/` and the two file-dest paths — no IO, proven
|
|
11
|
-
* `@unit`.
|
|
12
|
-
* - IMPURE runner (`executeKeptRun`): `mkdir -p` the run dir, then route the tool's
|
|
13
|
-
* `--format` outputs into the two files by handing an injected tool-invoker the two
|
|
14
|
-
* file-dest `--format` specs. The ONLY IO, proven `@integration` (the real on-disk
|
|
15
|
-
* files under a temp root + the repo untouched — never a planner re-run).
|
|
16
|
-
*
|
|
17
|
-
* The store root is an INJECTED parameter — never hardcoded — so the scaffold is
|
|
18
|
-
* location-agnostic (proven against a temp root; the repo is never written). RMG-001 is
|
|
19
|
-
* the dir + the routed outputs; the `run.yaml` stamp (RMG-002) and the `--run-id` mnemonic
|
|
20
|
-
* override (RMG-003) land in later sub-issues.
|
|
21
|
-
*
|
|
22
|
-
* Parent: @SCN-RMG-001 — the run-management layer.
|
|
23
|
-
*/
|
|
24
|
-
/** The two artefact filenames a kept run routes the tool's outputs into. */
|
|
25
|
-
export declare const RECONCILIATION_DOCUMENT = "spec-reconciliation.md";
|
|
26
|
-
/**
|
|
27
|
-
* The machine artefact filename (@SCN-RMD-001) — renamed `ledger.json` →
|
|
28
|
-
* `spec-reconciliation.json` (parity with `spec-reconciliation.md`): it is the machine form
|
|
29
|
-
* of the WHOLE reconciliation document, not just the ledger.
|
|
30
|
-
*/
|
|
31
|
-
export declare const RECONCILIATION_JSON = "spec-reconciliation.json";
|
|
32
|
-
/** The manifest filename a kept run stamps in the run dir (RMG-002). */
|
|
1
|
+
import { type ReadInput } from "../outputLocation.js";
|
|
33
2
|
export declare const RUN_MANIFEST = "run.yaml";
|
|
34
|
-
|
|
35
|
-
* The run.yaml schema version this scaffold stamps. Bumped 1 → 2 by 3F-1916, which added
|
|
36
|
-
* the tool identity (`tool_sha` / `tool_version`) — so a reader can tell a run that
|
|
37
|
-
* predates tool-identity recording (schema 1) from one that should carry it (schema 2).
|
|
38
|
-
* run.yaml is write-only (no production reader), so the bump breaks no read path.
|
|
39
|
-
*/
|
|
40
|
-
export declare const RUN_MANIFEST_SCHEMA_VERSION = 2;
|
|
41
|
-
/** The stored-run modes (run.yaml `mode`). */
|
|
42
|
-
export type RunMode = "balance" | "analyse" | "migrate";
|
|
43
|
-
/**
|
|
44
|
-
* The manifest-only metadata a kept run stamps that the path spec (`KeptRunSpec`) does not
|
|
45
|
-
* carry — the source SHA, the run mode, and the ISO date.
|
|
46
|
-
*/
|
|
3
|
+
type RunMode = "balance";
|
|
47
4
|
export interface RunManifestMeta {
|
|
48
5
|
readonly sourceSha: string;
|
|
49
|
-
/**
|
|
50
|
-
* The TOOL's own git SHA — which spec-controller produced this run (3F-1916), distinct
|
|
51
|
-
* from the target's `sourceSha`. A string ("unknown" when the tool is not a git
|
|
52
|
-
* checkout), mirroring `sourceSha`'s own "unknown" fallback — so run.yaml is internally
|
|
53
|
-
* consistent (both facts use the same absent-marker, never a bare null).
|
|
54
|
-
*/
|
|
55
6
|
readonly toolSha: string;
|
|
56
|
-
/** The tool's package version — always present. */
|
|
57
7
|
readonly toolVersion: string;
|
|
58
8
|
readonly mode: RunMode;
|
|
59
9
|
readonly date: string;
|
|
60
10
|
}
|
|
61
|
-
/** The full manifest input: the path spec's run-id + target, plus the manifest-only meta. */
|
|
62
11
|
export interface RunManifestInput extends RunManifestMeta {
|
|
63
12
|
readonly runId: string;
|
|
64
13
|
readonly target: string;
|
|
65
14
|
}
|
|
66
|
-
/**
|
|
67
|
-
* The run.yaml manifest — the decided light field set. `purpose`/`links` default EMPTY (the ad-hoc default; slugs are
|
|
68
|
-
* added by operator hand-edit afterward). `category`/`use_case` are NOT stamped (`purpose`
|
|
69
|
-
* subsumes them). Keys are listed in the decided stamp order.
|
|
70
|
-
*/
|
|
71
15
|
export interface RunManifest {
|
|
72
16
|
readonly schema_version: number;
|
|
73
17
|
readonly run_id: string;
|
|
74
18
|
readonly target: string;
|
|
75
19
|
readonly source_sha: string;
|
|
76
|
-
/** The TOOL's identity (3F-1916) — which spec-controller produced the run. */
|
|
77
20
|
readonly tool_sha: string;
|
|
78
21
|
readonly tool_version: string;
|
|
79
22
|
readonly mode: RunMode;
|
|
@@ -85,72 +28,28 @@ export interface RunManifest {
|
|
|
85
28
|
readonly reconciliation: string;
|
|
86
29
|
};
|
|
87
30
|
}
|
|
88
|
-
/** The kept-run inputs: the injected store root, the target, and the run-id. */
|
|
89
31
|
export interface KeptRunSpec {
|
|
90
32
|
readonly storeRoot: string;
|
|
91
33
|
readonly target: string;
|
|
92
34
|
readonly runId: string;
|
|
35
|
+
readonly formatPaths?: readonly string[];
|
|
36
|
+
readonly inputs?: readonly ReadInput[];
|
|
93
37
|
}
|
|
94
|
-
/** The planned run: the run dir plus the two file-dest paths inside it. */
|
|
95
38
|
export interface KeptRunPlan {
|
|
96
39
|
readonly runDir: string;
|
|
97
40
|
readonly documentPath: string;
|
|
98
41
|
readonly reconciliationJsonPath: string;
|
|
99
42
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
* the scaffold stays the tool's black-box caller (the real CLI subprocess in the
|
|
103
|
-
* `@integration` arm) and holds no opinion on HOW the tool is run — only WHERE its outputs
|
|
104
|
-
* land (the two file-dest paths the runner hands it).
|
|
105
|
-
*/
|
|
106
|
-
export type RouteOutputs = (formatSpecs: readonly string[]) => void;
|
|
107
|
-
/**
|
|
108
|
-
* PURE planner: yield the run dir `<storeRoot>/<target>/<runId>/` and the two file-dest
|
|
109
|
-
* paths (`<dir>/spec-reconciliation.md`, `<dir>/spec-reconciliation.json`) from the spec. No
|
|
110
|
-
* IO — the store root is threaded straight through `join`, so it is a parameter, never
|
|
111
|
-
* hardcoded.
|
|
112
|
-
*/
|
|
43
|
+
export type RouteOutputs = (formatSpecs: readonly string[], runDir: string) => boolean;
|
|
44
|
+
export declare function earlierStoredRunDirOf(path: string, ownRunDir: string | undefined): string | undefined;
|
|
113
45
|
export declare function planKeptRun(spec: KeptRunSpec): KeptRunPlan;
|
|
114
|
-
/**
|
|
115
|
-
* Options for the pure run-id resolver (RMG-003): the operator's OPTIONAL `--run-id` mnemonic
|
|
116
|
-
* and the INJECTED clock instant the default timestamp derives from.
|
|
117
|
-
*/
|
|
118
46
|
export interface ResolveRunIdOptions {
|
|
119
|
-
/** The operator's `--run-id` mnemonic when supplied; overrides the timestamp default, verbatim. */
|
|
120
47
|
readonly runId?: string;
|
|
121
|
-
/**
|
|
122
|
-
* The injected instant the default ISO-timestamp run-id derives from — the deterministic-@unit
|
|
123
|
-
* seam. Never a bare `new Date()` inside the resolver, so the default run-id is pin-testable.
|
|
124
|
-
*/
|
|
125
48
|
readonly now: Date;
|
|
126
49
|
}
|
|
127
|
-
/**
|
|
128
|
-
* PURE run-id resolver — the CLI/edge seam that turns an OPTIONAL `--run-id` into the concrete
|
|
129
|
-
* run-id naming the run dir (feeds `KeptRunSpec.runId`). No `--run-id` → an ISO-8601 UTC
|
|
130
|
-
* timestamp derived from the INJECTED `now` (filesystem-safe: no colons, no millis — matching
|
|
131
|
-
* the existing store run dir); `--run-id <mnemonic>` → that mnemonic verbatim (`acme-q3`, `e1`
|
|
132
|
-
* — an earlier precedent), which ignores the clock. No IO — proven `@unit` (RMG-003).
|
|
133
|
-
* The clock is injected (never a bare `new Date()`) so the default timestamp is deterministic
|
|
134
|
-
* under test (the discipline the old `formatRunTimestamp` used). Just default-vs-override — no
|
|
135
|
-
* sanitisation / collision policy (deferred).
|
|
136
|
-
*/
|
|
137
50
|
export declare function resolveRunId(options: ResolveRunIdOptions): string;
|
|
138
|
-
/**
|
|
139
|
-
* PURE: build the run.yaml manifest object from the run metadata (RMG-002). `purpose` and
|
|
140
|
-
* `links` are stamped EMPTY (the ad-hoc default; slugs are added by operator hand-edit of
|
|
141
|
-
* run.yaml afterward — the documented curation convention); `artefacts` carry the decided
|
|
142
|
-
* filenames. No IO — proven `@unit`.
|
|
143
|
-
*/
|
|
144
51
|
export declare function planRunManifest(input: RunManifestInput): RunManifest;
|
|
145
|
-
/** PURE: serialise the manifest to YAML text the impure runner writes verbatim. */
|
|
146
52
|
export declare function serialiseRunManifest(manifest: RunManifest): string;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
* files via the injected `route` — the document as `md:<documentPath>`, the reconciliation
|
|
150
|
-
* JSON as `json:<reconciliationJsonPath>` — and stamp `run.yaml` with the manifest built from the spec + `meta`
|
|
151
|
-
* (RMG-002). Returns the plan it realised. The only IO. The `mkdir` is load-bearing: the
|
|
152
|
-
* tool's writer uses `writeFileSync`, which needs the parent dir to exist — so the scaffold
|
|
153
|
-
* creates the dir the location-agnostic tool writes into.
|
|
154
|
-
*/
|
|
155
|
-
export declare function executeKeptRun(spec: KeptRunSpec, meta: RunManifestMeta, route: RouteOutputs): KeptRunPlan;
|
|
53
|
+
export declare function executeKeptRun(spec: KeptRunSpec, meta: RunManifestMeta, route: RouteOutputs): KeptRunPlan | undefined;
|
|
54
|
+
export {};
|
|
156
55
|
//# sourceMappingURL=keptRun.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keptRun.d.ts","sourceRoot":"","sources":["../../src/run-management/keptRun.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keptRun.d.ts","sourceRoot":"","sources":["../../src/run-management/keptRun.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoD,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAKxG,eAAO,MAAM,YAAY,aAAa,CAAC;AAIvC,KAAK,OAAO,GAAG,SAAS,CAAC;AAEzB,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7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CAAC;IAC9B,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;CACzC;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;AAEvF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAIrG;AA0BD,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,CAO1D;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAKjE;AAMD,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,WAAW,CAiBpE;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,CAElE;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,eAAe,EACrB,KAAK,EAAE,YAAY,GAClB,WAAW,GAAG,SAAS,CAoBzB"}
|
|
@@ -1,52 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Split by the three-layer architecture:
|
|
9
|
-
* - PURE planner (`planKeptRun`): given `{ storeRoot, target, runId }`, yields the run
|
|
10
|
-
* dir `<storeRoot>/<target>/<runId>/` and the two file-dest paths — no IO, proven
|
|
11
|
-
* `@unit`.
|
|
12
|
-
* - IMPURE runner (`executeKeptRun`): `mkdir -p` the run dir, then route the tool's
|
|
13
|
-
* `--format` outputs into the two files by handing an injected tool-invoker the two
|
|
14
|
-
* file-dest `--format` specs. The ONLY IO, proven `@integration` (the real on-disk
|
|
15
|
-
* files under a temp root + the repo untouched — never a planner re-run).
|
|
16
|
-
*
|
|
17
|
-
* The store root is an INJECTED parameter — never hardcoded — so the scaffold is
|
|
18
|
-
* location-agnostic (proven against a temp root; the repo is never written). RMG-001 is
|
|
19
|
-
* the dir + the routed outputs; the `run.yaml` stamp (RMG-002) and the `--run-id` mnemonic
|
|
20
|
-
* override (RMG-003) land in later sub-issues.
|
|
21
|
-
*
|
|
22
|
-
* Parent: @SCN-RMG-001 — the run-management layer.
|
|
23
|
-
*/
|
|
24
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
25
|
-
import { join } from "node:path";
|
|
26
|
-
import { stringify } from "yaml";
|
|
27
|
-
/** The two artefact filenames a kept run routes the tool's outputs into. */
|
|
28
|
-
export const RECONCILIATION_DOCUMENT = "spec-reconciliation.md";
|
|
29
|
-
/**
|
|
30
|
-
* The machine artefact filename (@SCN-RMD-001) — renamed `ledger.json` →
|
|
31
|
-
* `spec-reconciliation.json` (parity with `spec-reconciliation.md`): it is the machine form
|
|
32
|
-
* of the WHOLE reconciliation document, not just the ledger.
|
|
33
|
-
*/
|
|
34
|
-
export const RECONCILIATION_JSON = "spec-reconciliation.json";
|
|
35
|
-
/** The manifest filename a kept run stamps in the run dir (RMG-002). */
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { parse, stringify } from "yaml";
|
|
4
|
+
import { APP_MESSAGES, AppMessage } from "../messages.js";
|
|
5
|
+
import { firstSharingFile, inputAt, refuse, writeOrRefuse } from "../outputLocation.js";
|
|
6
|
+
const RECONCILIATION_DOCUMENT = "spec-reconciliation.md";
|
|
7
|
+
const RECONCILIATION_JSON = "spec-reconciliation.json";
|
|
36
8
|
export const RUN_MANIFEST = "run.yaml";
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
9
|
+
const RUN_MANIFEST_SCHEMA_VERSION = 2;
|
|
10
|
+
export function earlierStoredRunDirOf(path, ownRunDir) {
|
|
11
|
+
const dir = existsSync(path) ? dirname(realpathSync(path)) : realpathSync(dirname(path));
|
|
12
|
+
if (ownRunDir !== undefined && dir === realpathSync(ownRunDir))
|
|
13
|
+
return undefined;
|
|
14
|
+
return holdsRunManifest(dir) ? dir : undefined;
|
|
15
|
+
}
|
|
16
|
+
function holdsRunManifest(dir) {
|
|
17
|
+
return readsAsRunManifest(runManifestDocumentIn(dir));
|
|
18
|
+
}
|
|
19
|
+
function runManifestDocumentIn(dir) {
|
|
20
|
+
try {
|
|
21
|
+
return parse(readFileSync(join(dir, RUN_MANIFEST), "utf8"));
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// A run.yaml that is absent, unreadable or not YAML reads as no document.
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
function readsAsRunManifest(document) {
|
|
29
|
+
if (typeof document !== "object" || document === null)
|
|
30
|
+
return false;
|
|
31
|
+
const fields = document;
|
|
32
|
+
return (fields["schema_version"] !== undefined &&
|
|
33
|
+
fields["run_id"] !== undefined &&
|
|
34
|
+
typeof fields["artefacts"] === "object" &&
|
|
35
|
+
fields["artefacts"] !== null);
|
|
36
|
+
}
|
|
50
37
|
export function planKeptRun(spec) {
|
|
51
38
|
const runDir = join(spec.storeRoot, spec.target, spec.runId);
|
|
52
39
|
return {
|
|
@@ -55,39 +42,15 @@ export function planKeptRun(spec) {
|
|
|
55
42
|
reconciliationJsonPath: join(runDir, RECONCILIATION_JSON),
|
|
56
43
|
};
|
|
57
44
|
}
|
|
58
|
-
/**
|
|
59
|
-
* PURE run-id resolver — the CLI/edge seam that turns an OPTIONAL `--run-id` into the concrete
|
|
60
|
-
* run-id naming the run dir (feeds `KeptRunSpec.runId`). No `--run-id` → an ISO-8601 UTC
|
|
61
|
-
* timestamp derived from the INJECTED `now` (filesystem-safe: no colons, no millis — matching
|
|
62
|
-
* the existing store run dir); `--run-id <mnemonic>` → that mnemonic verbatim (`acme-q3`, `e1`
|
|
63
|
-
* — an earlier precedent), which ignores the clock. No IO — proven `@unit` (RMG-003).
|
|
64
|
-
* The clock is injected (never a bare `new Date()`) so the default timestamp is deterministic
|
|
65
|
-
* under test (the discipline the old `formatRunTimestamp` used). Just default-vs-override — no
|
|
66
|
-
* sanitisation / collision policy (deferred).
|
|
67
|
-
*/
|
|
68
45
|
export function resolveRunId(options) {
|
|
69
|
-
// The operator mnemonic, when given, names the run dir verbatim — the clock is ignored.
|
|
70
46
|
if (options.runId !== undefined) {
|
|
71
47
|
return options.runId;
|
|
72
48
|
}
|
|
73
|
-
// Otherwise the run-id defaults to the injected instant as a filesystem-safe timestamp.
|
|
74
49
|
return formatRunTimestamp(options.now);
|
|
75
50
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Format an injected instant as a filesystem-safe ISO-8601 UTC timestamp: `toISOString()`
|
|
78
|
-
* yields `2026-06-30T10:04:01.123Z`; drop the milliseconds, then swap the time-separator
|
|
79
|
-
* colons for hyphens so the string is a safe directory name (`2026-06-30T10-04-01Z` — the
|
|
80
|
-
* form the existing store run dir uses).
|
|
81
|
-
*/
|
|
82
51
|
function formatRunTimestamp(instant) {
|
|
83
|
-
return instant.toISOString().replace(/\.\d+Z
|
|
52
|
+
return instant.toISOString().replace(/\.\d+Z/, "Z").replace(/:/g, "-");
|
|
84
53
|
}
|
|
85
|
-
/**
|
|
86
|
-
* PURE: build the run.yaml manifest object from the run metadata (RMG-002). `purpose` and
|
|
87
|
-
* `links` are stamped EMPTY (the ad-hoc default; slugs are added by operator hand-edit of
|
|
88
|
-
* run.yaml afterward — the documented curation convention); `artefacts` carry the decided
|
|
89
|
-
* filenames. No IO — proven `@unit`.
|
|
90
|
-
*/
|
|
91
54
|
export function planRunManifest(input) {
|
|
92
55
|
return {
|
|
93
56
|
schema_version: RUN_MANIFEST_SCHEMA_VERSION,
|
|
@@ -98,8 +61,6 @@ export function planRunManifest(input) {
|
|
|
98
61
|
tool_version: input.toolVersion,
|
|
99
62
|
mode: input.mode,
|
|
100
63
|
date: input.date,
|
|
101
|
-
// EMPTY defaults — the ad-hoc run; slugs/links are added by operator hand-edit of
|
|
102
|
-
// run.yaml afterward (no --purpose flag, no vocab enforcement — both deferred).
|
|
103
64
|
purpose: [],
|
|
104
65
|
links: [],
|
|
105
66
|
artefacts: {
|
|
@@ -108,26 +69,25 @@ export function planRunManifest(input) {
|
|
|
108
69
|
},
|
|
109
70
|
};
|
|
110
71
|
}
|
|
111
|
-
/** PURE: serialise the manifest to YAML text the impure runner writes verbatim. */
|
|
112
72
|
export function serialiseRunManifest(manifest) {
|
|
113
73
|
return stringify(manifest);
|
|
114
74
|
}
|
|
115
|
-
/**
|
|
116
|
-
* IMPURE runner: `mkdir -p` the run dir, route the tool's `--format` outputs into the two
|
|
117
|
-
* files via the injected `route` — the document as `md:<documentPath>`, the reconciliation
|
|
118
|
-
* JSON as `json:<reconciliationJsonPath>` — and stamp `run.yaml` with the manifest built from the spec + `meta`
|
|
119
|
-
* (RMG-002). Returns the plan it realised. The only IO. The `mkdir` is load-bearing: the
|
|
120
|
-
* tool's writer uses `writeFileSync`, which needs the parent dir to exist — so the scaffold
|
|
121
|
-
* creates the dir the location-agnostic tool writes into.
|
|
122
|
-
*/
|
|
123
75
|
export function executeKeptRun(spec, meta, route) {
|
|
124
76
|
const plan = planKeptRun(spec);
|
|
125
|
-
mkdirSync(plan.runDir, { recursive: true });
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
77
|
+
writeOrRefuse(APP_MESSAGES[AppMessage.StoredRunDirectoryNotCreated](), plan.runDir, () => mkdirSync(plan.runDir, { recursive: true }));
|
|
78
|
+
const manifestPath = join(plan.runDir, RUN_MANIFEST);
|
|
79
|
+
const sharesManifest = firstSharingFile(manifestPath, spec.formatPaths ?? []);
|
|
80
|
+
if (sharesManifest !== undefined) {
|
|
81
|
+
refuse(APP_MESSAGES[AppMessage.FormatNamesStoredRunManifest](sharesManifest, manifestPath, plan.runDir));
|
|
82
|
+
}
|
|
83
|
+
const readManifest = inputAt(manifestPath, spec.inputs ?? []);
|
|
84
|
+
if (readManifest !== undefined) {
|
|
85
|
+
refuse(APP_MESSAGES[AppMessage.StoredRunReadsItsManifest](manifestPath, readManifest.path, readManifest.subject));
|
|
86
|
+
}
|
|
87
|
+
if (!route([`md:${plan.documentPath}`, `json:${plan.reconciliationJsonPath}`], plan.runDir))
|
|
88
|
+
return undefined;
|
|
129
89
|
const manifest = planRunManifest({ runId: spec.runId, target: spec.target, ...meta });
|
|
130
|
-
|
|
90
|
+
writeOrRefuse(APP_MESSAGES[AppMessage.StoredRunManifestNotWritten](), manifestPath, () => writeFileSync(manifestPath, serialiseRunManifest(manifest)));
|
|
131
91
|
return plan;
|
|
132
92
|
}
|
|
133
93
|
//# sourceMappingURL=keptRun.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keptRun.js","sourceRoot":"","sources":["../../src/run-management/keptRun.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"keptRun.js","sourceRoot":"","sources":["../../src/run-management/keptRun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAkB,MAAM,sBAAsB,CAAC;AAExG,MAAM,uBAAuB,G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AAQ,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IACtF,aAAa,CAAC,YAAY,CAAC,UAAU,CAAC,2BAA2B,CAAC,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CACvF,aAAa,CAAC,YAAY,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAC5D,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,82 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolve a run's git-derived inputs — the target's source SHA and repo root. The
|
|
3
|
-
* IMPURE half of the old run/runContext.ts: both shell out to `git` over the
|
|
4
|
-
* target tree, so they live in the app's run-management layer, apart from the pure
|
|
5
|
-
* provenance projection (packages/core/src/provenance/provenance.ts) they feed. The
|
|
6
|
-
* CLI (cli-balance/cli.ts) calls these once to build the RunContext.
|
|
7
|
-
*
|
|
8
|
-
* Scenarios: @SCN-RPT-001 (the run-provenance slice); the --source-sha override;
|
|
9
|
-
* @SCN-RPT-016 (target-root derivation); @SCN-RPT-026 / @SCN-RPT-029 (the tool's own identity).
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Resolve the target's source SHA (project design §4). An explicit non-empty
|
|
13
|
-
* `sourceSha` wins — the override for non-git / zip / detached-HEAD targets (the
|
|
14
|
-
* --source-sha flag). Otherwise `git -C <targetDir> rev-parse HEAD` (trimmed) as a
|
|
15
|
-
* READ-ONLY pure read. On any throw —
|
|
16
|
-
* a non-git target, git absent, an empty answer — resolve to `null` ("unknown")
|
|
17
|
-
* rather than crashing. `targetDir` = dirname(--features) when given, else cwd.
|
|
18
|
-
*/
|
|
19
1
|
export declare function resolveSourceSha(opts: {
|
|
20
2
|
sourceSha?: string;
|
|
21
3
|
targetDir?: string;
|
|
22
4
|
}): string | null;
|
|
23
|
-
/** The tool's own identity — which spec-controller produced a run (3F-1916). */
|
|
24
5
|
export interface ToolIdentity {
|
|
25
|
-
/** The tool's own git HEAD, or null when the tool is not a git checkout (an installed package). */
|
|
26
6
|
toolSha: string | null;
|
|
27
|
-
/** The tool's package version — always present (read from the tool's own package.json). */
|
|
28
7
|
toolVersion: string;
|
|
29
8
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Resolve the TOOL's own identity (3F-1916) — which spec-controller produced this run,
|
|
32
|
-
* distinct from the TARGET's `sourceSha`. Two facts, one call, threaded to both the
|
|
33
|
-
* report provenance (RunContext) and the run.yaml manifest.
|
|
34
|
-
*
|
|
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.
|
|
38
|
-
*
|
|
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).
|
|
59
|
-
*/
|
|
60
9
|
export declare function resolveToolIdentity(opts?: {
|
|
61
10
|
toolDir?: string;
|
|
62
11
|
packageJsonPath?: string;
|
|
63
12
|
}): ToolIdentity;
|
|
64
|
-
/**
|
|
65
|
-
* Resolve the TARGET repo root — the root the recorded input paths (`presentInputs`)
|
|
66
|
-
* and the evidence-observation locators (`countRuntimeEvidenceObservationKinds`) are both made
|
|
67
|
-
* portable against (@SCN-RPT-016). The bug it fixes: the prior CLI relativized
|
|
68
|
-
* against `process.cwd()` — the TOOL's own repo — so a cross-repo reconcile
|
|
69
|
-
* (cwd ≠ target) kept the target's absolute paths (they aren't under cwd → the
|
|
70
|
-
* "absolute-not-under-root" branch of `relativizeToRoot` → leaked verbatim).
|
|
71
|
-
*
|
|
72
|
-
* The rule (mirrors `resolveSourceSha`'s targetDir derivation): the root is derived from
|
|
73
|
-
* the TARGET, never the run cwd — the git top-level of `dirname(--features)` when the
|
|
74
|
-
* target is a git repo (the robust case: `--features` may sit in a nested dir), else
|
|
75
|
-
* `dirname(--features)` itself (a non-git target — a zip / extracted tree), else
|
|
76
|
-
* `process.cwd()` for a self-reconcile with no `--features` (the legacy cwd = target
|
|
77
|
-
* assumption, preserved as the fallback). A READ-ONLY `git -C … rev-parse --show-toplevel`
|
|
78
|
-
* (read-only-target-safe); any throw falls back to `dirname(--features)`.
|
|
79
|
-
*/
|
|
80
13
|
export declare function resolveTargetRoot(opts: {
|
|
81
14
|
features?: string;
|
|
82
15
|
}): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveRunInputs.d.ts","sourceRoot":"","sources":["../../src/run-management/resolveRunInputs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveRunInputs.d.ts","sourceRoot":"","sources":["../../src/run-management/resolveRunInputs.ts"],"names":[],"mappings":"AAKA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAQhG;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,mBAAmB,CAAC,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,YAAY,CAQ3G;AAgCD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAMrE"}
|