@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,183 @@
1
+ import { type WorldSelection, type WorldUsage } from './schema.js';
2
+ export type CoverageStatus = 'covered' | 'missing' | 'uninterceptable' | 'unknown-sdk' | 'acknowledged' | 'excluded';
3
+ export type CoverageRow = {
4
+ /** vendor key for mapped vendors; the raw dep/env name for unknown-sdk rows */
5
+ vendor: string;
6
+ /** how the repo betrayed the vendor, e.g. 'npm: stripe' / 'env: STRIPE_SECRET_KEY' */
7
+ detectedVia: string[];
8
+ /** Transport from pack metadata, or a separately required native connection. */
9
+ connection?: string;
10
+ /** the matching world service/env identifier when covered, else null */
11
+ twinInWorld: string | null;
12
+ status: CoverageStatus;
13
+ };
14
+ export type CoverageReport = {
15
+ world: string;
16
+ /** 'instance' when a booted/recorded instance was read; 'config' for the stable config */
17
+ worldSource: 'instance' | 'config';
18
+ worldPath: string;
19
+ repo: string;
20
+ twinsInWorld: string[];
21
+ rows: CoverageRow[];
22
+ covered: string[];
23
+ missing: string[];
24
+ /** vendors whose twin IS in the world but nothing can route vendor traffic to it (the
25
+ * service resolves to no injector vendor and exposes no app-read endpoint env) — the
26
+ * LibreChat AWS_TWIN_URL trap. Fails the proof: a twin nothing reaches covers nothing. */
27
+ uninterceptable: string[];
28
+ unknown: string[];
29
+ acknowledged: {
30
+ vendor: string;
31
+ reason: string;
32
+ }[];
33
+ excluded: string[];
34
+ allowUnknown: boolean;
35
+ ok: boolean;
36
+ };
37
+ /**
38
+ * The INJECTOR vendor keys that can carry this vendor's traffic, in a stable order — the single
39
+ * source of truth for "can zero-edit interception work here, and under which `*_TWIN_URL` name?".
40
+ *
41
+ * Read from `@volter/world-core/inject`'s own VENDOR_HOSTS table (never a re-encoding of it), and
42
+ * filtered through the same `VENDOR_WORLD_IDS` aliasing the proof matches with: `aws` yields
43
+ * `['s3','dynamodb','timestream']` (the consolidated twin's real keys — `AWS_TWIN_URL` is the
44
+ * inert trap), `stripe` yields `['stripe']`, and a pack in vendor-hosts.test.ts's
45
+ * descriptor hostsNone ruling yields `[]`.
46
+ *
47
+ * Two callers, one answer: `covers` uses it to decide whether an UNINTERCEPTABLE finding is a
48
+ * fixable wiring bug (keys exist) or an acknowledgeable allowlist gap (none do), and `init` uses
49
+ * it to DERIVE the canonical `injectEnv` it emits — so an emitted world can never claim a
50
+ * `*_TWIN_URL` var the injector does not read.
51
+ */
52
+ export declare function injectorVendorKeysFor(vendor: string): string[];
53
+ /** Shell-safe env name read by the injector for a vendor key, including hyphenated keys. */
54
+ export declare function injectorEnvNameForKey(key: string): string;
55
+ /** Vendor-shaped env var detection (the secondary signal). The var must end in a
56
+ * credential/endpoint suffix; the remaining stem (framework prefixes stripped,
57
+ * normalized) is looked up here. */
58
+ export declare const ENV_STEM_VENDORS: Record<string, string>;
59
+ /** Is this env NAME shaped like a CREDENTIAL/endpoint at all (any broad vendor suffix)? The
60
+ * question `init` asks before deciding whether a value in a repo's `.env.example` may be copied
61
+ * verbatim: `APP_NAME` may, `ANYTHING_SECRET` may not — a committed example file is exactly where
62
+ * live keys hide (the ponder blind-adoption run found real ones), so a credential-shaped name is
63
+ * ALWAYS replaced by a fake, whether or not its stem maps to a vendor this repo twins. Exported
64
+ * from here so the emission path and the proof read ONE definition of "credential-shaped". */
65
+ export declare function isCredentialShapedEnvName(name: string): boolean;
66
+ /** The vendor a credential-shaped env NAME betrays, or null. Same broad-suffix route the
67
+ * coverage proof's secondary signal uses (`STRIPE_SECRET_KEY` → 'stripe'). */
68
+ export declare function envNameVendor(name: string): string | null;
69
+ export declare function scopeVendorFor(name: string): string | undefined;
70
+ export declare function isMappedScopeSibling(name: string): boolean;
71
+ /**
72
+ * THE PACKLESS-VENDOR REGISTRY — `known-external-services.json`, shipped inside this package.
73
+ * ONE home for the knowledge that used to live in three inline sets here (NOT_AN_EXTERNAL_
74
+ * SERVICE, UNKNOWN_DEP_KNOWN_SERVICES, UNKNOWN_DEP_PATTERNS) plus the 2026-08-31 census
75
+ * rulings: `deps`/`envStems` are external-service signals the catalog KNOWS but has no pack
76
+ * for (`disposition: 'demanded'` stays a LOUD coverage gap — the demand queue;
77
+ * `'acknowledged'` was adjudicated acceptable and auto-acknowledges with its recorded
78
+ * reason); `notExternal` suppresses vendor-adjacent glue (protocol/type/UI helpers, auth
79
+ * libraries); `patterns` are the external-shape heuristics. AN ENTRY DIES THE DAY ITS PACK
80
+ * IS BORN — scripts/packless-claims.test.ts enforces disjointness with pack adoption and
81
+ * SDK_TWINS (the `@planetscale/database`/twin#255 lesson, mechanized). Lazy + cached like
82
+ * pack-facts.ts's loader — though note this module ALREADY does module-scope I/O via the
83
+ * overlayCoversMaps call below, so laziness here is consistency, not a load-bearing
84
+ * invariant (§9 round two L1).
85
+ */
86
+ export type PacklessDisposition = 'demanded' | 'acknowledged';
87
+ export type PacklessEntry = {
88
+ disposition: PacklessDisposition;
89
+ reason: string;
90
+ };
91
+ export type KnownExternalServices = {
92
+ deps: Record<string, PacklessEntry>;
93
+ envStems: Record<string, PacklessEntry>;
94
+ notExternal: Record<string, string>;
95
+ patterns: Array<{
96
+ pattern: string;
97
+ reason: string;
98
+ }>;
99
+ };
100
+ export declare function knownExternalServices(): KnownExternalServices;
101
+ /** The registry's STANDING acknowledgment for an unknown-signal name (npm dep or env stem),
102
+ * or null when the signal is unlisted or listed as a demanded (loud) gap. Exported for init,
103
+ * whose plan partitions the same signals the proof does.
104
+ *
105
+ * DEMANDED ANYWHERE WINS: the unknown map merges npm deps, env stems and registry-host ids
106
+ * under one key space, so a name listed in BOTH registry sections must never let one
107
+ * section's acknowledgment quiet the other's demanded gap (§9 round two H5, 2026-08-31: an
108
+ * acknowledged dep entry silently green-lit a repo whose only signal was the same-named
109
+ * DEMANDED env stem). Loud beats quiet; the gate also refuses conflicting dispositions. */
110
+ export declare function registryAcknowledgedReason(name: string): string | null;
111
+ export type WorldTwinId = {
112
+ /** display label (e.g. 'stripe (twin service)') */
113
+ label: string;
114
+ /** whether traffic can actually REACH the twin behind this identifier: the injector/proxy
115
+ * intercepts its vendor hosts, or the service exposes app-read endpoint env. A twin that is
116
+ * merely present — reachable by nothing — must not count as coverage (the LibreChat
117
+ * AWS_TWIN_URL trap: the injectEnv looked wired but the injector reads no `aws` vendor). */
118
+ interceptable: boolean;
119
+ };
120
+ type WorldTwinInventory = {
121
+ source: 'instance' | 'config';
122
+ path: string;
123
+ /** normalized identifier → id record (e.g. 'stripe' → { label: 'stripe (service)', … }) */
124
+ ids: Map<string, WorldTwinId>;
125
+ connections: Map<string, {
126
+ protocol: string | null;
127
+ label: string;
128
+ }>;
129
+ /** Saved policy at boot/config time; absent means legacy all-signals coverage. */
130
+ selection?: WorldSelection;
131
+ declared: Map<string, WorldTwinId>;
132
+ };
133
+ /** The twins actually IN the named world: instance first (the booted truth), stable
134
+ * config as the pre-boot fallback. Throws loudly when the world resolves to neither. */
135
+ export declare function worldTwinInventory(world: string, root: string): WorldTwinInventory;
136
+ export type CoverageOptions = {
137
+ root?: string;
138
+ allowUnknown?: boolean;
139
+ /**
140
+ * vendor → reason: vendors the operator ACKNOWLEDGES need no twin in this world — e.g. an SDK
141
+ * used verifier-only (svix's Webhook verifies incoming signatures locally and never calls out).
142
+ * An acknowledged vendor downgrades missing/unknown-sdk to status 'acknowledged' (reason shown,
143
+ * never silent); a reason is REQUIRED — an empty one throws.
144
+ *
145
+ * UNINTERCEPTABLE splits in two (the Cal.com svix finding):
146
+ * • an injector vendor key EXISTS for the vendor and the wiring is merely wrong (the LibreChat
147
+ * AWS_TWIN_URL trap) — a config bug, NOT acknowledgeable: the acknowledgment is refused
148
+ * loudly on the row and the proof stays red until the wiring is fixed;
149
+ * • NO injector key exists at all (the pack is in its descriptor's hostsNone ruling
150
+ * allowlist — ~15 packs wire by explicit endpoint config only) — acknowledgeable WITH a
151
+ * reason. Before this, the only route to green was DELETING the twin from the world and
152
+ * acknowledging it as un-twinned, which made the config LESS truthful than the red proof.
153
+ */
154
+ acknowledge?: Record<string, string>;
155
+ };
156
+ /** What a repo BETRAYS about the external services it talks to — the repo half of the coverage
157
+ * proof, split out so `init` (which must EMIT a twin per detected vendor) and `covers` (which must
158
+ * PROVE one exists) can never drift apart by re-encoding detection twice. */
159
+ export type RepoVendorSignals = {
160
+ /** vendor key → the sources that betrayed it (`npm: stripe`, `env: STRIPE_SECRET_KEY`,
161
+ * `fetch: src/billing.ts:12 -> api.stripe.com`) */
162
+ detected: Map<string, string[]>;
163
+ /** external-service-shaped signal with NO vendor mapping → its sources (dep name, or env stem) */
164
+ unknown: Map<string, string[]>;
165
+ uses: Map<string, Array<{
166
+ usage: WorldUsage;
167
+ evidence: string;
168
+ }>>;
169
+ unknownUses: Map<string, Array<{
170
+ usage: WorldUsage;
171
+ evidence: string;
172
+ }>>;
173
+ };
174
+ /** Detect every vendor (and every unmapped external-service-shaped signal) an application repo
175
+ * betrays: mapped npm dependencies across the root + all workspace members, vendor-shaped env
176
+ * names in committed `.env*` files, the SMTP/raw-protocol signal, and literal vendor URLs passed
177
+ * directly to fetch in production source. URL attribution reads the injector's VENDOR_HOSTS table
178
+ * rather than re-encoding host rules here. Insertion order follows the sorted dependency, env-name,
179
+ * and source lists, so callers that preserve it are deterministic. */
180
+ export declare function detectRepoVendors(repoPath: string): RepoVendorSignals;
181
+ export declare function coverWorld(world: string, repoPath: string, options?: CoverageOptions): CoverageReport;
182
+ export declare function formatCoverageReport(report: CoverageReport): string;
183
+ export {};