@descryy/runtime-controller 0.0.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.
Files changed (61) hide show
  1. package/dist/capability-registry.d.ts +24 -0
  2. package/dist/capability-registry.d.ts.map +1 -0
  3. package/dist/capability-registry.js +42 -0
  4. package/dist/capability-registry.js.map +1 -0
  5. package/dist/collector-version.d.ts +10 -0
  6. package/dist/collector-version.d.ts.map +1 -0
  7. package/dist/collector-version.js +12 -0
  8. package/dist/collector-version.js.map +1 -0
  9. package/dist/container-sandbox.d.ts +188 -0
  10. package/dist/container-sandbox.d.ts.map +1 -0
  11. package/dist/container-sandbox.js +233 -0
  12. package/dist/container-sandbox.js.map +1 -0
  13. package/dist/controller.d.ts +162 -0
  14. package/dist/controller.d.ts.map +1 -0
  15. package/dist/controller.js +433 -0
  16. package/dist/controller.js.map +1 -0
  17. package/dist/dependency-version-check.d.ts +90 -0
  18. package/dist/dependency-version-check.d.ts.map +1 -0
  19. package/dist/dependency-version-check.js +121 -0
  20. package/dist/dependency-version-check.js.map +1 -0
  21. package/dist/env.d.ts +16 -0
  22. package/dist/env.d.ts.map +1 -0
  23. package/dist/env.js +18 -0
  24. package/dist/env.js.map +1 -0
  25. package/dist/environment-metadata.d.ts +23 -0
  26. package/dist/environment-metadata.d.ts.map +1 -0
  27. package/dist/environment-metadata.js +80 -0
  28. package/dist/environment-metadata.js.map +1 -0
  29. package/dist/environment-version-check.d.ts +83 -0
  30. package/dist/environment-version-check.d.ts.map +1 -0
  31. package/dist/environment-version-check.js +218 -0
  32. package/dist/environment-version-check.js.map +1 -0
  33. package/dist/execution-safety.d.ts +154 -0
  34. package/dist/execution-safety.d.ts.map +1 -0
  35. package/dist/execution-safety.js +194 -0
  36. package/dist/execution-safety.js.map +1 -0
  37. package/dist/index.d.ts +35 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +14 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/orchestration.d.ts +70 -0
  42. package/dist/orchestration.d.ts.map +1 -0
  43. package/dist/orchestration.js +255 -0
  44. package/dist/orchestration.js.map +1 -0
  45. package/dist/process-collector.d.ts +34 -0
  46. package/dist/process-collector.d.ts.map +1 -0
  47. package/dist/process-collector.js +148 -0
  48. package/dist/process-collector.js.map +1 -0
  49. package/dist/process-manager.d.ts +133 -0
  50. package/dist/process-manager.d.ts.map +1 -0
  51. package/dist/process-manager.js +333 -0
  52. package/dist/process-manager.js.map +1 -0
  53. package/dist/readiness.d.ts +120 -0
  54. package/dist/readiness.d.ts.map +1 -0
  55. package/dist/readiness.js +179 -0
  56. package/dist/readiness.js.map +1 -0
  57. package/dist/sandbox.d.ts +139 -0
  58. package/dist/sandbox.d.ts.map +1 -0
  59. package/dist/sandbox.js +271 -0
  60. package/dist/sandbox.js.map +1 -0
  61. package/package.json +29 -0
@@ -0,0 +1,90 @@
1
+ /**
2
+ * `DEC-NEXT-fault-layer-empirical-confirmation.md`'s `dependency` mechanism:
3
+ * "declared (lockfile) version vs. resolved (installed) version at
4
+ * runtime. A mismatch is a structural fact, the same shape as
5
+ * `automation`'s `harnessFailure` flag — not inferred, recorded."
6
+ *
7
+ * ## Node-only, checked rather than assumed
8
+ *
9
+ * This repo's own multi-language stance (`CLAUDE.md`: "check what this
10
+ * repo's existing environment/dependency inspection code, if any, already
11
+ * assumes about target project types before assuming Node-only") was
12
+ * checked directly before writing this: `captureEnvironmentMetadata`
13
+ * (`environment-metadata.ts`, the closest existing thing) probes an
14
+ * arbitrary command's `--version` output and is genuinely language-agnostic,
15
+ * but nothing in this repo already reads a *lockfile* for any language --
16
+ * there was no existing dependency-inspection assumption to match, Node or
17
+ * otherwise. Node is the one target built here because it is the one the
18
+ * ruling's own example names (`"lockfile pins left-pad@1.3.0, resolved
19
+ * 1.2.0"`) and the one every fixture in this repo (`fixture-apps/
20
+ * broken-invoices-backend`) actually is. A future target (a Python
21
+ * `requirements.txt`/`pip freeze` pair, a Ruby `Gemfile.lock`) is a real,
22
+ * disclosed gap -- a second reader function beside this one, not a rewrite
23
+ * of it, the same "framework extractors are additive" shape
24
+ * `descry-core`'s own CLAUDE.md describes for its adapters.
25
+ *
26
+ * ## Only `lockfileVersion` 2/3's `packages` shape
27
+ *
28
+ * Confirmed against this repo's own `fixture-apps/broken-invoices-backend/
29
+ * package-lock.json` (`lockfileVersion: 3`) rather than assumed: modern npm
30
+ * writes a flat `packages` map keyed by the `node_modules/<name>` path the
31
+ * package would be installed at, each entry carrying the resolved
32
+ * `version` it was locked to -- exactly the "declared" half this function
33
+ * needs, with no separate resolution algorithm required, because the key
34
+ * itself already *is* the install path. `lockfileVersion` 1's older
35
+ * `dependencies` shape is not read here -- `applicable: false`, a
36
+ * disclosed gap, not a guess dressed up as a second code path.
37
+ *
38
+ * ## "Resolved" is a direct read, not `require.resolve`
39
+ *
40
+ * The lockfile key (`node_modules/<name>`) is already the exact path this
41
+ * function reads `package.json` from under the project root. This is
42
+ * deliberately not Node's own module-resolution algorithm (walking up
43
+ * successive `node_modules` directories) -- the lockfile key already
44
+ * encodes exactly where npm decided to place that install, including for a
45
+ * nested transitive dependency (`node_modules/a/node_modules/b`), and
46
+ * re-deriving that placement with a resolver would be solving a problem the
47
+ * lockfile already solved.
48
+ *
49
+ * ## Direct dependencies only
50
+ *
51
+ * Every name in `package.json`'s `dependencies`/`devDependencies` --not
52
+ * every transitive entry the lockfile carries. "Cheap, always available, no
53
+ * rerun needed" is the ruling's own bar; checking every transitive package
54
+ * on every execution is neither cheap nor targeted at what a developer
55
+ * actually declared, and the ruling's own example (`left-pad`) is a single
56
+ * named top-level package.
57
+ */
58
+ export interface DependencyVersionMismatch {
59
+ readonly name: string;
60
+ /** The version `package-lock.json` pins this package to. */
61
+ readonly declaredVersion: string;
62
+ /** The version actually found in `node_modules/<name>/package.json` on disk. */
63
+ readonly resolvedVersion: string;
64
+ }
65
+ export interface DependencyVersionCheckResult {
66
+ /**
67
+ * `false` when this project could not be positively identified as a
68
+ * checkable Node target (no `package.json`, no lockfile, an unsupported
69
+ * lockfile shape, or malformed JSON in either file) -- "not applicable"
70
+ * rather than a guessed clean result. `mismatches` is always `[]` when
71
+ * `false`.
72
+ */
73
+ readonly applicable: boolean;
74
+ readonly mismatches: readonly DependencyVersionMismatch[];
75
+ }
76
+ /**
77
+ * Compares the lockfile-declared version of every direct dependency
78
+ * (`dependencies` + `devDependencies` in `package.json`) against the
79
+ * version actually installed under `node_modules`, for the Node project
80
+ * rooted at `cwd` -- the same `ServiceConfiguration.cwd` every collector in
81
+ * this repo already reads a spawned service's project root from.
82
+ *
83
+ * A dependency absent from the lockfile (a workspace/local-link
84
+ * dependency) or absent from `node_modules` entirely (never installed) is
85
+ * skipped, not reported -- both are real, different facts from a version
86
+ * mismatch, and reporting either as one would be a guess this function does
87
+ * not make.
88
+ */
89
+ export declare function checkDependencyVersions(cwd: string): DependencyVersionCheckResult;
90
+ //# sourceMappingURL=dependency-version-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependency-version-check.d.ts","sourceRoot":"","sources":["../src/dependency-version-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAKH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,gFAAgF;IAChF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,4BAA4B;IAC3C;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,yBAAyB,EAAE,CAAC;CAC3D;AAuBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,4BAA4B,CA6CjF"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * `DEC-NEXT-fault-layer-empirical-confirmation.md`'s `dependency` mechanism:
3
+ * "declared (lockfile) version vs. resolved (installed) version at
4
+ * runtime. A mismatch is a structural fact, the same shape as
5
+ * `automation`'s `harnessFailure` flag — not inferred, recorded."
6
+ *
7
+ * ## Node-only, checked rather than assumed
8
+ *
9
+ * This repo's own multi-language stance (`CLAUDE.md`: "check what this
10
+ * repo's existing environment/dependency inspection code, if any, already
11
+ * assumes about target project types before assuming Node-only") was
12
+ * checked directly before writing this: `captureEnvironmentMetadata`
13
+ * (`environment-metadata.ts`, the closest existing thing) probes an
14
+ * arbitrary command's `--version` output and is genuinely language-agnostic,
15
+ * but nothing in this repo already reads a *lockfile* for any language --
16
+ * there was no existing dependency-inspection assumption to match, Node or
17
+ * otherwise. Node is the one target built here because it is the one the
18
+ * ruling's own example names (`"lockfile pins left-pad@1.3.0, resolved
19
+ * 1.2.0"`) and the one every fixture in this repo (`fixture-apps/
20
+ * broken-invoices-backend`) actually is. A future target (a Python
21
+ * `requirements.txt`/`pip freeze` pair, a Ruby `Gemfile.lock`) is a real,
22
+ * disclosed gap -- a second reader function beside this one, not a rewrite
23
+ * of it, the same "framework extractors are additive" shape
24
+ * `descry-core`'s own CLAUDE.md describes for its adapters.
25
+ *
26
+ * ## Only `lockfileVersion` 2/3's `packages` shape
27
+ *
28
+ * Confirmed against this repo's own `fixture-apps/broken-invoices-backend/
29
+ * package-lock.json` (`lockfileVersion: 3`) rather than assumed: modern npm
30
+ * writes a flat `packages` map keyed by the `node_modules/<name>` path the
31
+ * package would be installed at, each entry carrying the resolved
32
+ * `version` it was locked to -- exactly the "declared" half this function
33
+ * needs, with no separate resolution algorithm required, because the key
34
+ * itself already *is* the install path. `lockfileVersion` 1's older
35
+ * `dependencies` shape is not read here -- `applicable: false`, a
36
+ * disclosed gap, not a guess dressed up as a second code path.
37
+ *
38
+ * ## "Resolved" is a direct read, not `require.resolve`
39
+ *
40
+ * The lockfile key (`node_modules/<name>`) is already the exact path this
41
+ * function reads `package.json` from under the project root. This is
42
+ * deliberately not Node's own module-resolution algorithm (walking up
43
+ * successive `node_modules` directories) -- the lockfile key already
44
+ * encodes exactly where npm decided to place that install, including for a
45
+ * nested transitive dependency (`node_modules/a/node_modules/b`), and
46
+ * re-deriving that placement with a resolver would be solving a problem the
47
+ * lockfile already solved.
48
+ *
49
+ * ## Direct dependencies only
50
+ *
51
+ * Every name in `package.json`'s `dependencies`/`devDependencies` --not
52
+ * every transitive entry the lockfile carries. "Cheap, always available, no
53
+ * rerun needed" is the ruling's own bar; checking every transitive package
54
+ * on every execution is neither cheap nor targeted at what a developer
55
+ * actually declared, and the ruling's own example (`left-pad`) is a single
56
+ * named top-level package.
57
+ */
58
+ import { existsSync, readFileSync } from "node:fs";
59
+ import { join } from "node:path";
60
+ function readJsonFile(path) {
61
+ try {
62
+ return JSON.parse(readFileSync(path, "utf8"));
63
+ }
64
+ catch {
65
+ return null;
66
+ }
67
+ }
68
+ /**
69
+ * Compares the lockfile-declared version of every direct dependency
70
+ * (`dependencies` + `devDependencies` in `package.json`) against the
71
+ * version actually installed under `node_modules`, for the Node project
72
+ * rooted at `cwd` -- the same `ServiceConfiguration.cwd` every collector in
73
+ * this repo already reads a spawned service's project root from.
74
+ *
75
+ * A dependency absent from the lockfile (a workspace/local-link
76
+ * dependency) or absent from `node_modules` entirely (never installed) is
77
+ * skipped, not reported -- both are real, different facts from a version
78
+ * mismatch, and reporting either as one would be a guess this function does
79
+ * not make.
80
+ */
81
+ export function checkDependencyVersions(cwd) {
82
+ const packageJsonPath = join(cwd, "package.json");
83
+ const lockfilePath = join(cwd, "package-lock.json");
84
+ if (!existsSync(packageJsonPath) || !existsSync(lockfilePath)) {
85
+ return { applicable: false, mismatches: [] };
86
+ }
87
+ const packageJson = readJsonFile(packageJsonPath);
88
+ const lockfile = readJsonFile(lockfilePath);
89
+ if (packageJson === null || lockfile === null) {
90
+ return { applicable: false, mismatches: [] };
91
+ }
92
+ const packages = lockfile.packages;
93
+ if (packages === undefined || typeof packages !== "object") {
94
+ // lockfileVersion 1's `dependencies` shape, or a shape this reader does
95
+ // not recognise -- see this module's own header.
96
+ return { applicable: false, mismatches: [] };
97
+ }
98
+ const declaredNames = new Set([
99
+ ...Object.keys(packageJson.dependencies ?? {}),
100
+ ...Object.keys(packageJson.devDependencies ?? {}),
101
+ ]);
102
+ const mismatches = [];
103
+ for (const name of declaredNames) {
104
+ const lockEntry = packages[`node_modules/${name}`];
105
+ const declaredVersion = lockEntry?.version;
106
+ if (typeof declaredVersion !== "string")
107
+ continue;
108
+ const installedPackageJsonPath = join(cwd, "node_modules", name, "package.json");
109
+ if (!existsSync(installedPackageJsonPath))
110
+ continue;
111
+ const installedPackageJson = readJsonFile(installedPackageJsonPath);
112
+ const resolvedVersion = installedPackageJson?.version;
113
+ if (typeof resolvedVersion !== "string")
114
+ continue;
115
+ if (resolvedVersion !== declaredVersion) {
116
+ mismatches.push({ name, declaredVersion, resolvedVersion });
117
+ }
118
+ }
119
+ return { applicable: true, mismatches };
120
+ }
121
+ //# sourceMappingURL=dependency-version-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependency-version-check.js","sourceRoot":"","sources":["../src/dependency-version-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAmCjC,SAAS,YAAY,CAAI,IAAY;IACnC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAM,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAW;IACjD,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAClD,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;IAEpD,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9D,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;IAC/C,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,CAAmB,eAAe,CAAC,CAAC;IACpE,MAAM,QAAQ,GAAG,YAAY,CAAmB,YAAY,CAAC,CAAC;IAC9D,IAAI,WAAW,KAAK,IAAI,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;IAC/C,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;IACnC,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC3D,wEAAwE;QACxE,iDAAiD;QACjD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;IAC/C,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,GAAG,CAAS;QACpC,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,IAAI,EAAE,CAAC;QAC9C,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,IAAI,EAAE,CAAC;KAClD,CAAC,CAAC;IAEH,MAAM,UAAU,GAAgC,EAAE,CAAC;IACnD,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,MAAM,SAAS,GAAG,QAAQ,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;QACnD,MAAM,eAAe,GAAG,SAAS,EAAE,OAAO,CAAC;QAC3C,IAAI,OAAO,eAAe,KAAK,QAAQ;YAAE,SAAS;QAElD,MAAM,wBAAwB,GAAG,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QACjF,IAAI,CAAC,UAAU,CAAC,wBAAwB,CAAC;YAAE,SAAS;QAEpD,MAAM,oBAAoB,GAAG,YAAY,CAAgC,wBAAwB,CAAC,CAAC;QACnG,MAAM,eAAe,GAAG,oBAAoB,EAAE,OAAO,CAAC;QACtD,IAAI,OAAO,eAAe,KAAK,QAAQ;YAAE,SAAS;QAElD,IAAI,eAAe,KAAK,eAAe,EAAE,CAAC;YACxC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC1C,CAAC"}
package/dist/env.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Default environment applied to every spawned process, on top of whatever
3
+ * the caller passes explicitly.
4
+ *
5
+ * RUST_BACKTRACE is the concrete case this guards against (Agent 3's
6
+ * finding, plan §17): a Rust panic prints only a message and "run with
7
+ * RUST_BACKTRACE=1" without it. That is a collector-absence-masquerading-
8
+ * as-application-success case — the process didn't fail to crash, the
9
+ * runtime just failed to *see* how — so it belongs here rather than being
10
+ * left to each caller to remember.
11
+ *
12
+ * Only ever adds keys the caller didn't already set explicitly — never
13
+ * overrides a deliberate choice.
14
+ */
15
+ export declare function withDefaultProcessEnv(env: Readonly<Record<string, string | undefined>>): Record<string, string | undefined>;
16
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAChD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAEpC"}
package/dist/env.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Default environment applied to every spawned process, on top of whatever
3
+ * the caller passes explicitly.
4
+ *
5
+ * RUST_BACKTRACE is the concrete case this guards against (Agent 3's
6
+ * finding, plan §17): a Rust panic prints only a message and "run with
7
+ * RUST_BACKTRACE=1" without it. That is a collector-absence-masquerading-
8
+ * as-application-success case — the process didn't fail to crash, the
9
+ * runtime just failed to *see* how — so it belongs here rather than being
10
+ * left to each caller to remember.
11
+ *
12
+ * Only ever adds keys the caller didn't already set explicitly — never
13
+ * overrides a deliberate choice.
14
+ */
15
+ export function withDefaultProcessEnv(env) {
16
+ return { RUST_BACKTRACE: "1", ...env };
17
+ }
18
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CACnC,GAAiD;IAEjD,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;AACzC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * §2's "commit is recorded; environment metadata is not captured" gap
3
+ * (RT-193): `Execution.commit` alone cannot reproduce a run -- the same
4
+ * commit under a different Node version, OS, or toolchain can behave
5
+ * differently, and nothing recorded which one actually ran.
6
+ * `captureEnvironmentMetadata` fills the missing half from the real host:
7
+ * OS platform, this controller process's own Node version (`process.version`
8
+ * -- always known, never probed), and the version of every distinct
9
+ * executable `configuration.services` actually invokes.
10
+ *
11
+ * The toolchain probe reuses `scripts/preflight.mjs`'s `interpreters()`
12
+ * shape rather than reinventing version detection: run the command with a
13
+ * version flag, read stdout+stderr combined (several of these tools --
14
+ * `java -version`, `javac -version`, `kotlinc -version` -- write to stderr
15
+ * only), keep the first line. It is not the same function, because
16
+ * `interpreters()` checks a fixed, hardcoded list of dev-environment
17
+ * toolchains against a specific expected-version regex per tool; this
18
+ * checks whatever `services[*].command` actually names, for any command,
19
+ * with no expected version to compare against -- a report, not a gate.
20
+ */
21
+ import type { EnvironmentMetadata, ServiceConfiguration } from "@descryy/runtime-contracts";
22
+ export declare function captureEnvironmentMetadata(services: Readonly<Record<string, ServiceConfiguration>>): Promise<EnvironmentMetadata>;
23
+ //# sourceMappingURL=environment-metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment-metadata.d.ts","sourceRoot":"","sources":["../src/environment-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAM5F,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,GACvD,OAAO,CAAC,mBAAmB,CAAC,CAqB9B"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * §2's "commit is recorded; environment metadata is not captured" gap
3
+ * (RT-193): `Execution.commit` alone cannot reproduce a run -- the same
4
+ * commit under a different Node version, OS, or toolchain can behave
5
+ * differently, and nothing recorded which one actually ran.
6
+ * `captureEnvironmentMetadata` fills the missing half from the real host:
7
+ * OS platform, this controller process's own Node version (`process.version`
8
+ * -- always known, never probed), and the version of every distinct
9
+ * executable `configuration.services` actually invokes.
10
+ *
11
+ * The toolchain probe reuses `scripts/preflight.mjs`'s `interpreters()`
12
+ * shape rather than reinventing version detection: run the command with a
13
+ * version flag, read stdout+stderr combined (several of these tools --
14
+ * `java -version`, `javac -version`, `kotlinc -version` -- write to stderr
15
+ * only), keep the first line. It is not the same function, because
16
+ * `interpreters()` checks a fixed, hardcoded list of dev-environment
17
+ * toolchains against a specific expected-version regex per tool; this
18
+ * checks whatever `services[*].command` actually names, for any command,
19
+ * with no expected version to compare against -- a report, not a gate.
20
+ */
21
+ import { execFile } from "node:child_process";
22
+ import { platform } from "node:os";
23
+ import { tokenizeCommand } from "./orchestration.js";
24
+ /** Bounds a single version probe so a hung command can't stall run() -- same discipline RT-030 already applies to readiness probes, applied here to a probe this module owns instead of a caller's. */
25
+ const VERSION_PROBE_TIMEOUT_MS = 3000;
26
+ export async function captureEnvironmentMetadata(services) {
27
+ const commands = new Set();
28
+ for (const service of Object.values(services)) {
29
+ // Attach-mode services (`service.attach`) have no `command` -- nothing
30
+ // was launched by this runtime for it, so there is no toolchain to
31
+ // probe on its behalf.
32
+ if (service.command === undefined)
33
+ continue;
34
+ const tokenized = tokenizeCommand(service.command);
35
+ if (tokenized.ok)
36
+ commands.add(tokenized.command);
37
+ }
38
+ const toolchainVersions = {};
39
+ for (const command of commands) {
40
+ toolchainVersions[command] = await probeVersion(command);
41
+ }
42
+ return {
43
+ platform: platform(),
44
+ nodeVersion: process.version,
45
+ toolchainVersions,
46
+ };
47
+ }
48
+ /**
49
+ * Tries `--version` then `-version` then `-v` -- the three flags
50
+ * `scripts/preflight.mjs`'s `interpreters()` needed across the toolchains
51
+ * this repo already runs (`java -version`, `mvn -v`). Returns the first
52
+ * line of whichever attempt exits 0, or `null` if none does -- an absent
53
+ * or non-version-reporting command is a disclosed gap in the map, not a
54
+ * thrown error and not an omitted key.
55
+ */
56
+ function probeVersion(command) {
57
+ return tryFlags(command, ["--version", "-version", "-v"]);
58
+ }
59
+ async function tryFlags(command, flags) {
60
+ for (const flag of flags) {
61
+ const output = await runVersionFlag(command, flag);
62
+ if (output !== null)
63
+ return output;
64
+ }
65
+ return null;
66
+ }
67
+ function runVersionFlag(command, flag) {
68
+ return new Promise((resolve) => {
69
+ execFile(command, [flag], { timeout: VERSION_PROBE_TIMEOUT_MS }, (error, stdout, stderr) => {
70
+ if (error !== null) {
71
+ resolve(null);
72
+ return;
73
+ }
74
+ const combined = `${stdout}${stderr}`.trim();
75
+ const firstLine = combined.split("\n")[0];
76
+ resolve(firstLine === undefined || firstLine === "" ? null : firstLine);
77
+ });
78
+ });
79
+ }
80
+ //# sourceMappingURL=environment-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment-metadata.js","sourceRoot":"","sources":["../src/environment-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,uMAAuM;AACvM,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,QAAwD;IAExD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9C,uEAAuE;QACvE,mEAAmE;QACnE,uBAAuB;QACvB,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;YAAE,SAAS;QAC5C,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,SAAS,CAAC,EAAE;YAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,iBAAiB,GAAkC,EAAE,CAAC;IAC5D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,iBAAiB,CAAC,OAAO,CAAC,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,QAAQ,EAAE;QACpB,WAAW,EAAE,OAAO,CAAC,OAAO;QAC5B,iBAAiB;KAClB,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO,QAAQ,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,OAAe,EAAE,KAAwB;IAC/D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACnD,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,MAAM,CAAC;IACrC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,cAAc,CAAC,OAAe,EAAE,IAAY;IACnD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACzF,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,OAAO,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO;YACT,CAAC;YACD,MAAM,QAAQ,GAAG,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;YAC7C,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * `DEC-NEXT-fault-layer-empirical-confirmation.md`'s `environment`
3
+ * mechanism: "declared/expected runner version (CI config) vs. observed
4
+ * runner version at execution." Same shape as `dependency-version-check.ts`'s
5
+ * comparison -- cheap, always available, no rerun needed.
6
+ *
7
+ * ## "Declared" is the project's own `.nvmrc`/`engines.node`, not a
8
+ * CI-workflow parser
9
+ *
10
+ * The ruling names "a CI config's pinned Node/language version" as one
11
+ * example of what "declared" can mean, not the only one -- its actual
12
+ * requirement is "whatever 'declared environment' already means elsewhere
13
+ * in this repo," checked directly rather than assumed (`environment-profile`
14
+ * turned out to mean something else entirely: DEC-270's safety level and
15
+ * credentials, not a version declaration). Nothing in this repo already
16
+ * parses a CI workflow file, and doing so first here would mean writing a
17
+ * YAML parser (or a regex sketch of one) for a signal that is, in every
18
+ * real Node project, already restated in `package.json` -- `.nvmrc` and
19
+ * `engines.node` are the actual, load-bearing declarations `nvm`/`npm`
20
+ * themselves read, checked directly against this repo's own root
21
+ * `package.json` (`engines: { node: ">=22.5" }`) and every fixture app
22
+ * under `fixture-apps/`, which all carry the same field. A future CI-file
23
+ * reader is a real, disclosed extension point, not a silent omission --
24
+ * this function's `declaredSource` is a closed union specifically so a
25
+ * third source can be added later without changing the shape callers
26
+ * already read.
27
+ *
28
+ * ## `satisfiesDeclaredNodeVersion`'s grammar is a real, narrower subset
29
+ *
30
+ * Supports `^x.y.z`, `~x.y.z`, `>=`/`<=`/`>`/`<` clauses, a bare version at
31
+ * any precision (`"20"`, `"20.11"`, `"20.11.5"`, each an x-range at that
32
+ * precision -- `"20"` means "any 20.x.y", matching what `actions/setup-node`
33
+ * itself does for a bare major), and space-separated AND clauses
34
+ * (`">=20.0.0 <21.0.0"`), npm's own shape for a bounded range. Does **not**
35
+ * support `||` (OR), hyphen ranges (`"1.2.3 - 2.3.4"`), prerelease/build
36
+ * tags, or the `x`/`*` wildcard tokens (`"20.x"`) -- an input using any of
37
+ * those parses to `null` ("cannot say") rather than a silently wrong
38
+ * true/false, the same "disclosed narrower scope, not a guess" pattern this
39
+ * repo already applies to `EnvironmentMetadata.toolchainVersions`' `null`
40
+ * entries.
41
+ */
42
+ export declare const DECLARED_VERSION_SOURCES: readonly ["nvmrc", "package.json engines.node"];
43
+ export type DeclaredVersionSource = (typeof DECLARED_VERSION_SOURCES)[number];
44
+ export interface EnvironmentVersionCheckResult {
45
+ /**
46
+ * `false` when no declared version could be found at all (neither
47
+ * `.nvmrc` nor `package.json engines.node` present), or when the declared
48
+ * or observed value could not be parsed as a version -- "not applicable,"
49
+ * never a guessed clean result. `mismatch` is always `false` when this is
50
+ * `false`.
51
+ */
52
+ readonly applicable: boolean;
53
+ readonly mismatch: boolean;
54
+ readonly declaredVersion: string | null;
55
+ readonly declaredSource: DeclaredVersionSource | null;
56
+ readonly observedVersion: string;
57
+ }
58
+ /**
59
+ * Reads the declared Node version for the project rooted at `cwd` and
60
+ * compares it against `observedVersion` (the real, already-known runtime
61
+ * value -- `process.version`, or `EnvironmentMetadata.nodeVersion`, the same
62
+ * "always known, never probed" value this repo already captures elsewhere;
63
+ * this function never probes for it itself).
64
+ *
65
+ * `.nvmrc` takes precedence over `package.json engines.node` when both are
66
+ * present -- `.nvmrc` names one exact intended version a developer actually
67
+ * runs locally; `engines.node` is more often a permissive range meant to
68
+ * describe compatibility rather than pin a single runtime. The narrower,
69
+ * more specific declaration wins, the same precedence
70
+ * `classifyFaultLayer` (`descry-core`) already applies between `dependency`
71
+ * and `environment` themselves ("the narrower, more specific structural
72
+ * fact... is checked first").
73
+ */
74
+ export declare function checkEnvironmentVersion(cwd: string, observedVersion: string): EnvironmentVersionCheckResult;
75
+ /**
76
+ * Whether `observedVersion` satisfies `declaredRange` under the grammar
77
+ * documented in this module's header. `null` means the comparison could not
78
+ * be made at all (either string used a construct this reader does not
79
+ * cover) -- distinct from `false`, which is a real, positive "does not
80
+ * satisfy" answer.
81
+ */
82
+ export declare function satisfiesDeclaredNodeVersion(declaredRange: string, observedVersion: string): boolean | null;
83
+ //# sourceMappingURL=environment-version-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment-version-check.d.ts","sourceRoot":"","sources":["../src/environment-version-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAKH,eAAO,MAAM,wBAAwB,iDAAkD,CAAC;AACxF,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E,MAAM,WAAW,6BAA6B;IAC5C;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,cAAc,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,6BAA6B,CAiD3G;AAuGD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAU3G"}