@volter/world-runtime 2.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 (164) hide show
  1. package/LICENSE +202 -0
  2. package/dist/known-external-services.json +1108 -0
  3. package/dist/src/ancestry.d.ts +2 -0
  4. package/dist/src/ancestry.js +42 -0
  5. package/dist/src/app-url.d.ts +47 -0
  6. package/dist/src/app-url.js +239 -0
  7. package/dist/src/attach.d.ts +48 -0
  8. package/dist/src/attach.js +87 -0
  9. package/dist/src/branch.d.ts +20 -0
  10. package/dist/src/branch.js +65 -0
  11. package/dist/src/browser-proxy-cli.d.ts +2 -0
  12. package/dist/src/browser-proxy-cli.js +41 -0
  13. package/dist/src/ca-trust.d.ts +5 -0
  14. package/dist/src/ca-trust.js +64 -0
  15. package/dist/src/catalog.d.ts +31 -0
  16. package/dist/src/catalog.js +148 -0
  17. package/dist/src/changeset.d.ts +142 -0
  18. package/dist/src/changeset.js +570 -0
  19. package/dist/src/cli.d.ts +2 -0
  20. package/dist/src/cli.js +1262 -0
  21. package/dist/src/command-lifetime.d.ts +15 -0
  22. package/dist/src/command-lifetime.js +98 -0
  23. package/dist/src/configs.d.ts +18 -0
  24. package/dist/src/configs.js +119 -0
  25. package/dist/src/console-apart.d.ts +38 -0
  26. package/dist/src/console-apart.js +107 -0
  27. package/dist/src/consumers.d.ts +46 -0
  28. package/dist/src/consumers.js +200 -0
  29. package/dist/src/covers.d.ts +183 -0
  30. package/dist/src/covers.js +800 -0
  31. package/dist/src/fixture-env.d.ts +42 -0
  32. package/dist/src/fixture-env.js +221 -0
  33. package/dist/src/host-cli.d.ts +2 -0
  34. package/dist/src/host-cli.js +92 -0
  35. package/dist/src/host-fault-fixture.d.ts +32 -0
  36. package/dist/src/host-fault-fixture.js +100 -0
  37. package/dist/src/host-worker.d.ts +1 -0
  38. package/dist/src/host-worker.js +23 -0
  39. package/dist/src/host.d.ts +38 -0
  40. package/dist/src/host.js +135 -0
  41. package/dist/src/index.d.ts +48 -0
  42. package/dist/src/index.js +35 -0
  43. package/dist/src/infra-cli.d.ts +2 -0
  44. package/dist/src/infra-cli.js +136 -0
  45. package/dist/src/init.d.ts +227 -0
  46. package/dist/src/init.js +1117 -0
  47. package/dist/src/inject-map.d.ts +34 -0
  48. package/dist/src/inject-map.js +56 -0
  49. package/dist/src/lifecycle-record.d.ts +47 -0
  50. package/dist/src/lifecycle-record.js +196 -0
  51. package/dist/src/origin.d.ts +31 -0
  52. package/dist/src/origin.js +139 -0
  53. package/dist/src/pack-facts.d.ts +75 -0
  54. package/dist/src/pack-facts.js +98 -0
  55. package/dist/src/pglite-backing.d.ts +21 -0
  56. package/dist/src/pglite-backing.js +158 -0
  57. package/dist/src/pglite-host.mjs +147 -0
  58. package/dist/src/placeholder.d.ts +20 -0
  59. package/dist/src/placeholder.js +100 -0
  60. package/dist/src/prerequisites.d.ts +21 -0
  61. package/dist/src/prerequisites.js +49 -0
  62. package/dist/src/process-groups.d.ts +4 -0
  63. package/dist/src/process-groups.js +49 -0
  64. package/dist/src/project-inspect.d.ts +109 -0
  65. package/dist/src/project-inspect.js +827 -0
  66. package/dist/src/proxy-daemon.d.ts +2 -0
  67. package/dist/src/proxy-daemon.js +18 -0
  68. package/dist/src/redirect-proxy.d.ts +105 -0
  69. package/dist/src/redirect-proxy.js +665 -0
  70. package/dist/src/reflect.d.ts +74 -0
  71. package/dist/src/reflect.js +392 -0
  72. package/dist/src/resources.d.ts +26 -0
  73. package/dist/src/resources.js +22 -0
  74. package/dist/src/root.d.ts +114 -0
  75. package/dist/src/root.js +312 -0
  76. package/dist/src/run-task-worker.d.ts +1 -0
  77. package/dist/src/run-task-worker.js +38 -0
  78. package/dist/src/run-task.d.ts +18 -0
  79. package/dist/src/run-task.js +48 -0
  80. package/dist/src/runtime-test-support.d.ts +59 -0
  81. package/dist/src/runtime-test-support.js +205 -0
  82. package/dist/src/runtime.d.ts +256 -0
  83. package/dist/src/runtime.js +3502 -0
  84. package/dist/src/schema.d.ts +449 -0
  85. package/dist/src/schema.js +605 -0
  86. package/dist/src/serve.d.ts +30 -0
  87. package/dist/src/serve.js +82 -0
  88. package/dist/src/served-world.d.ts +194 -0
  89. package/dist/src/served-world.js +986 -0
  90. package/dist/src/service-exit.d.ts +46 -0
  91. package/dist/src/service-exit.js +195 -0
  92. package/dist/src/service-recorder.d.ts +1 -0
  93. package/dist/src/service-recorder.js +121 -0
  94. package/dist/src/sibling.d.ts +1 -0
  95. package/dist/src/sibling.js +9 -0
  96. package/dist/src/signals.d.ts +1 -0
  97. package/dist/src/signals.js +11 -0
  98. package/dist/src/storage-capacity.d.ts +8 -0
  99. package/dist/src/storage-capacity.js +61 -0
  100. package/dist/src/tail.d.ts +30 -0
  101. package/dist/src/tail.js +160 -0
  102. package/dist/src/tcp-port.d.ts +2 -0
  103. package/dist/src/tcp-port.js +36 -0
  104. package/dist/src/up-task-worker.d.ts +1 -0
  105. package/dist/src/up-task-worker.js +61 -0
  106. package/dist/src/up-task.d.ts +17 -0
  107. package/dist/src/up-task.js +49 -0
  108. package/dist/src/websocket-relay.d.ts +3 -0
  109. package/dist/src/websocket-relay.js +40 -0
  110. package/known-external-services.json +1108 -0
  111. package/package.json +83 -0
  112. package/src/ancestry.ts +36 -0
  113. package/src/app-url.ts +253 -0
  114. package/src/attach.ts +117 -0
  115. package/src/branch.ts +63 -0
  116. package/src/browser-proxy-cli.ts +44 -0
  117. package/src/ca-trust.ts +57 -0
  118. package/src/catalog.ts +156 -0
  119. package/src/changeset.ts +627 -0
  120. package/src/cli.ts +1111 -0
  121. package/src/command-lifetime.ts +79 -0
  122. package/src/configs.ts +110 -0
  123. package/src/console-apart.ts +90 -0
  124. package/src/consumers.ts +185 -0
  125. package/src/covers.ts +934 -0
  126. package/src/fixture-env.ts +230 -0
  127. package/src/host-cli.ts +90 -0
  128. package/src/host-worker.ts +23 -0
  129. package/src/host.ts +169 -0
  130. package/src/index.ts +171 -0
  131. package/src/infra-cli.ts +133 -0
  132. package/src/init.ts +1316 -0
  133. package/src/inject-map.ts +72 -0
  134. package/src/lifecycle-record.ts +168 -0
  135. package/src/origin.ts +134 -0
  136. package/src/pack-facts.ts +128 -0
  137. package/src/pglite-backing.ts +141 -0
  138. package/src/pglite-host.mjs +147 -0
  139. package/src/placeholder.ts +89 -0
  140. package/src/prerequisites.ts +66 -0
  141. package/src/process-groups.ts +33 -0
  142. package/src/project-inspect.ts +770 -0
  143. package/src/proxy-daemon.ts +21 -0
  144. package/src/redirect-proxy.ts +684 -0
  145. package/src/reflect.ts +440 -0
  146. package/src/resources.ts +22 -0
  147. package/src/root.ts +290 -0
  148. package/src/run-task-worker.ts +27 -0
  149. package/src/run-task.ts +44 -0
  150. package/src/runtime-test-support.ts +208 -0
  151. package/src/runtime.ts +3357 -0
  152. package/src/schema.ts +922 -0
  153. package/src/serve.ts +102 -0
  154. package/src/served-world.ts +812 -0
  155. package/src/service-exit.ts +175 -0
  156. package/src/service-recorder.ts +89 -0
  157. package/src/sibling.ts +10 -0
  158. package/src/signals.ts +10 -0
  159. package/src/storage-capacity.ts +60 -0
  160. package/src/tail.ts +205 -0
  161. package/src/tcp-port.ts +35 -0
  162. package/src/up-task-worker.ts +40 -0
  163. package/src/up-task.ts +45 -0
  164. package/src/websocket-relay.ts +32 -0
@@ -0,0 +1,49 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ /** Inspect only groups already owned by the lifecycle. A dead leader does not prove that its
3
+ * descendants exited. Zombies hold no resources; unknown inspection remains live. This is
4
+ * retirement evidence, never an ownership token or a way to discover processes to kill. */
5
+ export function survivingOwnedGroups(pids) {
6
+ const candidates = pids.filter(pid => {
7
+ try {
8
+ process.kill(process.platform === 'win32' ? pid : -pid, 0);
9
+ return true;
10
+ }
11
+ catch (error) {
12
+ if (error.code !== 'ESRCH')
13
+ return true;
14
+ try {
15
+ process.kill(pid, 0);
16
+ return true;
17
+ }
18
+ catch (cause) {
19
+ return cause.code !== 'ESRCH';
20
+ }
21
+ }
22
+ });
23
+ if (!candidates.length || process.platform === 'win32')
24
+ return candidates;
25
+ const result = spawnSync('ps', ['-axo', 'pid=,pgid=,stat='], {
26
+ encoding: 'utf8', timeout: 1000, killSignal: 'SIGKILL', maxBuffer: 4 * 1024 * 1024,
27
+ });
28
+ if (result.status !== 0 || result.error)
29
+ return candidates;
30
+ const rows = result.stdout.trim().split('\n').map(line => line.trim().split(/\s+/));
31
+ return candidates.filter(pid => {
32
+ const members = rows.filter(([id, group]) => Number(group) === pid || Number(id) === pid);
33
+ // Visibility restrictions can omit a live group. Only ESRCH proves absence.
34
+ if (!members.length) {
35
+ for (const target of [-pid, pid]) {
36
+ try {
37
+ process.kill(target, 0);
38
+ return true;
39
+ }
40
+ catch (error) {
41
+ if (error.code !== 'ESRCH')
42
+ return true;
43
+ }
44
+ }
45
+ return false;
46
+ }
47
+ return members.some(([, , state]) => !state || !state.startsWith('Z'));
48
+ });
49
+ }
@@ -0,0 +1,109 @@
1
+ export type ProjectInspection = {
2
+ root: string;
3
+ runtimes: string[];
4
+ manifests: string[];
5
+ vendorSdks: Array<{
6
+ vendor: string;
7
+ packages: string[];
8
+ twin: string;
9
+ }>;
10
+ registryDestinations: Array<ProjectNpmRegistry & {
11
+ classification: 'npm-registry' | 'unknown';
12
+ twin?: '@volter/twin-npm-registry';
13
+ }>;
14
+ envNames: string[];
15
+ entrypoints: string[];
16
+ coverage: string[];
17
+ decisions: string[];
18
+ };
19
+ /** npm package → vendor/twin mapping — the shared vendor↔SDK knowledge used by both
20
+ * `inspect-project` (adoption discovery) and `covers` (room-setup coverage proof).
21
+ * The canonical entry for each pack is the real client package that pack's own tests
22
+ * prove the twin against (see each `packages/twin/<pack>/package.json` devDependencies);
23
+ * the extra aliases are the vendor's other official/first-party clients of the same
24
+ * API surface. */
25
+ export declare const SDK_TWINS: Record<string, {
26
+ vendor: string;
27
+ twin: string;
28
+ }>;
29
+ /** PyPI distribution name (PEP 503) → twin. Built ENTIRELY from descriptors' `adoption.pypi`
30
+ * (no hand table): the Python half of the same map SDK_TWINS is for npm. A Python dependency
31
+ * detected here surfaces under the vendor's key, so covers/inspect treat both halves alike. */
32
+ export declare const PYPI_TWINS: Record<string, {
33
+ vendor: string;
34
+ twin: string;
35
+ }>;
36
+ /** Python dependency names declared by a project — requirements*.txt (one requirement per line;
37
+ * `-r` includes followed one level; comments, options and URLs skipped) and pyproject.toml
38
+ * (`[project] dependencies`, every `[project.optional-dependencies.*]` list, and Poetry's
39
+ * `[tool.poetry.dependencies]` / `[tool.poetry.group.*.dependencies]` tables) — across the
40
+ * root and every manifest dir. Names are PEP 503 normalized; extras and version specs dropped. */
41
+ export declare function projectPythonDependencies(input?: string): string[];
42
+ /** Workspace member dirs of a JS monorepo: pnpm-workspace.yaml packages plus
43
+ * package.json "workspaces" (npm/yarn/bun form), glob patterns expanded via
44
+ * expandWorkspaceGlob above. A repo's vendor SDKs usually live in members, not
45
+ * the root manifest — the ponder blind-adoption test found inspect-project
46
+ * blind to exactly this. */
47
+ export declare function workspaceDirs(root: string): string[];
48
+ /** Nested JS project roots: subdirs (depth ≤ 2) holding a package.json or
49
+ * pnpm-workspace.yaml that the GIT root's own workspace declarations never reach.
50
+ * The 2026-08 battery scan (evals/battery) found the detector blind to exactly this
51
+ * shape — a Go/Rails/Python repo with its JS app in `web/` or `frontend/` (unkey's
52
+ * stripe lives in web/apps/dashboard, reachable only via web/'s OWN workspace file).
53
+ * Each nested root contributes itself plus ITS workspace members. Same class as the
54
+ * ponder workspace fix above, one level out. */
55
+ export declare function nestedProjectRoots(root: string): string[];
56
+ /** Every dir whose package.json should count toward the project's dependency /
57
+ * env-name census: the root, its declared workspace members, and nested project
58
+ * roots (plus THEIR members). Single source of truth for the walkers below. */
59
+ export declare function projectManifestDirs(root: string): string[];
60
+ /** Every dependency name declared anywhere in the repo — root manifest plus all
61
+ * workspace members, across dependencies/devDependencies/peerDependencies — plus
62
+ * the python manifest candidates. Exported raw for `covers`, which must also see
63
+ * the external-service-shaped deps that DON'T map to any twin. */
64
+ export declare function projectDependencies(input?: string): string[];
65
+ /** Env var names assigned in committed .env* files (root + workspace members) —
66
+ * the secondary vendor signal: a repo may hold a vendor key without declaring
67
+ * the vendor's SDK (raw fetch / CLI use). */
68
+ export declare function projectEnvNames(input?: string): string[];
69
+ export type ProjectNpmRegistry = {
70
+ url: string;
71
+ source: string;
72
+ };
73
+ /** Explicit npm registry destinations in root/workspace `.npmrc`, `bunfig.toml`, and publishConfig.
74
+ * npm/Bun are executables rather than SDK dependencies, so adoption must inspect their actual
75
+ * destination configuration: an NPM_TOKEN alone does not prove that traffic targets one of the
76
+ * two official hosts the npm-registry injector owns. */
77
+ export declare function projectNpmRegistries(input?: string): ProjectNpmRegistry[];
78
+ export type ProjectFetchUrl = {
79
+ /** Absolute URL passed directly as the first argument to fetch. */
80
+ url: string;
81
+ /** Repo-relative source location (`path:line`). */
82
+ source: string;
83
+ };
84
+ /** Connection facts contain names and source locations, never connection strings or credentials. */
85
+ export type ProjectConnection = {
86
+ protocol: string | null;
87
+ env?: string;
88
+ sources: string[];
89
+ };
90
+ export declare function connectionProtocol(value: string): string | null;
91
+ /** Native connections are independent of the vendor's HTTP SDK. Inspect ordinary URL schemes
92
+ * and Prisma datasource declarations; never infer a selected Prisma adapter from its presence
93
+ * in package.json. Dynamic/config-file-only datasources remain unknown, as do unbound drivers. */
94
+ export declare function projectConnections(input?: string, attributedEnv?: Set<string>): ProjectConnection[];
95
+ /** Literal HTTP(S) destinations passed directly to the platform fetch API in production source.
96
+ *
97
+ * This is the third vendor signal beside dependencies and env names: hand-written REST clients
98
+ * often declare no SDK, and an unconventional credential name can hide the same vendor from the
99
+ * env heuristic. Only direct `fetch("https://...")`, `window.fetch`, and `globalThis.fetch` calls
100
+ * count. Dynamic destinations remain intentionally unclaimed; guessing from arbitrary URL strings
101
+ * would turn docs, links, and webhook examples into false external-service dependencies. */
102
+ export declare function projectFetchUrls(input?: string): ProjectFetchUrl[];
103
+ /** Env names read directly by production JS/TS source, with repo-relative `path:line` evidence.
104
+ * This is intentionally evidence, not validator inference: seeing an empty example value read by
105
+ * the app is enough to rank it as a boot risk, but not enough to claim whether the app permits an
106
+ * empty string. Supports the standard runtime forms without guessing through arbitrary wrappers. */
107
+ export declare function projectEnvReads(input?: string): Map<string, string[]>;
108
+ export declare function inspectProject(input?: string): ProjectInspection;
109
+ export declare function formatProjectInspection(report: ProjectInspection): string;