@lapxo/bound 0.2.4 → 0.2.6

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 (333) hide show
  1. package/CITATION.cff +1 -1
  2. package/README.md +20 -3
  3. package/TARGET.bound +85 -47
  4. package/dist/cli/accept.js +61 -590
  5. package/dist/cli/act-result.js +3 -103
  6. package/dist/cli/args.js +3 -44
  7. package/dist/cli/custodian.js +2 -29
  8. package/dist/cli/host.js +4 -32
  9. package/dist/cli/names.js +1 -12
  10. package/dist/cli/native-descendant.js +1 -19
  11. package/dist/cli/native.js +3 -60
  12. package/dist/cli/observe.js +1 -13
  13. package/dist/cli/owner.js +3 -139
  14. package/dist/cli/pass.js +22 -321
  15. package/dist/cli/place.js +6 -282
  16. package/dist/cli/release-result.js +3 -80
  17. package/dist/cli/retained-judgment.js +1 -25
  18. package/dist/cli/standing-result.js +4 -19
  19. package/dist/cli/takes.js +10 -112
  20. package/dist/cli/verb.d.ts +1 -2
  21. package/dist/cli/verb.js +85 -684
  22. package/dist/engine/computation.js +2 -0
  23. package/dist/engine/conformance.js +4 -0
  24. package/dist/engine/encoding.js +1 -2
  25. package/dist/engine/index.d.ts +1 -13
  26. package/dist/engine/index.js +2 -11
  27. package/dist/engine/object.js +1 -38
  28. package/dist/engine/ports.js +2 -117
  29. package/dist/fold/admission-history.js +1 -17
  30. package/dist/fold/bootstrap-anchor.js +1 -28
  31. package/dist/fold/ceilings.js +1 -142
  32. package/dist/fold/claims.js +2 -132
  33. package/dist/fold/closed.js +24 -235
  34. package/dist/fold/configures.js +1 -25
  35. package/dist/fold/digests.js +10 -226
  36. package/dist/fold/evidence.js +1 -22
  37. package/dist/fold/fold-worker.js +1 -13
  38. package/dist/fold/kept.js +12 -173
  39. package/dist/fold/keys.js +3 -91
  40. package/dist/fold/laid.js +3 -90
  41. package/dist/fold/nos.js +1 -48
  42. package/dist/fold/object.js +1 -2
  43. package/dist/fold/observed.js +28 -534
  44. package/dist/fold/opened.js +1 -33
  45. package/dist/fold/own.js +3 -217
  46. package/dist/fold/paid.js +1 -92
  47. package/dist/fold/place-inputs.js +1 -70
  48. package/dist/fold/places.js +3 -100
  49. package/dist/fold/rank.js +1 -9
  50. package/dist/fold/reach.js +1 -83
  51. package/dist/fold/readers.js +6 -142
  52. package/dist/fold/receipts.js +1 -47
  53. package/dist/fold/region-declarations.js +1 -13
  54. package/dist/fold/region.js +8 -286
  55. package/dist/fold/release-policy.js +1 -101
  56. package/dist/fold/resolved.js +6 -145
  57. package/dist/fold/roles.js +2 -59
  58. package/dist/fold/second.js +4 -71
  59. package/dist/fold/shards.js +12 -100
  60. package/dist/fold/signed.js +3 -81
  61. package/dist/fold/signers.js +1 -54
  62. package/dist/fold/stranger.js +6 -24
  63. package/dist/fold/views.js +1 -66
  64. package/dist/fold/wire.js +1 -46
  65. package/dist/fold/zoom.js +3 -81
  66. package/dist/host/act-cost.js +1 -25
  67. package/dist/host/adapters/keys/ed25519.js +1 -30
  68. package/dist/host/adapters/modules/javascript.js +1 -50
  69. package/dist/host/adapters/transport/http.js +1 -28
  70. package/dist/host/admitted-place.js +1 -35
  71. package/dist/host/archive.js +1 -152
  72. package/dist/host/call-context.js +1 -14
  73. package/dist/host/capsule-process.js +2 -62
  74. package/dist/host/capsule.js +9 -171
  75. package/dist/host/cell-receipts.js +12 -128
  76. package/dist/host/command-server.js +4 -0
  77. package/dist/host/commit-result.js +1 -5
  78. package/dist/host/content-needed.js +1 -8
  79. package/dist/host/content-store.js +1 -31
  80. package/dist/host/contextual-place.js +2 -72
  81. package/dist/host/digest.js +2 -15
  82. package/dist/host/hash.js +1 -9
  83. package/dist/host/host-controls.js +1 -19
  84. package/dist/host/in-process-act.js +3 -84
  85. package/dist/host/in-process-context.js +3 -91
  86. package/dist/host/in-process-root.js +6 -84
  87. package/dist/host/in-process.js +4 -55
  88. package/dist/host/index.d.ts +1 -15
  89. package/dist/host/index.js +1 -7
  90. package/dist/host/io.js +1 -11
  91. package/dist/host/lifetime.js +1 -79
  92. package/dist/host/located.js +6 -105
  93. package/dist/host/native/authority-card-view.js +5 -0
  94. package/dist/host/native/authority-card.js +1 -0
  95. package/dist/host/native/bounded-file.js +1 -32
  96. package/dist/host/native/command.js +1 -91
  97. package/dist/host/native/control-bridge-worker.js +2 -88
  98. package/dist/host/native/control-bridge.js +1 -110
  99. package/dist/host/native/control-selection.js +1 -32
  100. package/dist/host/native/custody.js +1 -91
  101. package/dist/host/native/deadline.js +1 -28
  102. package/dist/host/native/descendants.js +1 -528
  103. package/dist/host/native/generated-custodian.js +5 -267
  104. package/dist/host/native/generated.js +1 -379
  105. package/dist/host/native/image.js +1 -45
  106. package/dist/host/native/installed-package.d.ts +1 -0
  107. package/dist/host/native/installed-package.js +5 -0
  108. package/dist/host/native/jobs.js +2 -148
  109. package/dist/host/native/loader.js +1 -269
  110. package/dist/host/native/materialize.js +1 -175
  111. package/dist/host/native/module-closure.js +1 -130
  112. package/dist/host/native/module-delivery.d.ts +1 -62
  113. package/dist/host/native/module-delivery.js +1 -151
  114. package/dist/host/native/module-inventory.js +2 -0
  115. package/dist/host/native/module-syntax.js +1 -69
  116. package/dist/host/native/native-binary.js +1 -115
  117. package/dist/host/native/native-program.js +1 -72
  118. package/dist/host/native/node-jobs.js +3 -187
  119. package/dist/host/native/node-launch.js +1 -159
  120. package/dist/host/native/preload.js +1 -45
  121. package/dist/host/native/probes.js +1 -0
  122. package/dist/host/native/reading-witness-admission.js +5 -0
  123. package/dist/host/native/reading.js +1 -249
  124. package/dist/host/native/receipt-environment.js +1 -41
  125. package/dist/host/native/references.js +1 -30
  126. package/dist/host/native/root.js +1 -37
  127. package/dist/host/native/route.js +1 -216
  128. package/dist/host/native/runtime.js +1 -9
  129. package/dist/host/native-place-state.js +1 -0
  130. package/dist/host/native-reader-context.js +1 -8
  131. package/dist/host/native-receiver.js +1 -25
  132. package/dist/host/objects.js +1 -38
  133. package/dist/host/order.js +1 -2
  134. package/dist/host/persistent-host.js +1 -0
  135. package/dist/host/physical-lines.d.ts +1 -0
  136. package/dist/host/physical-lines.js +1 -0
  137. package/dist/host/place-act-transaction.js +4 -78
  138. package/dist/host/place-clock-selection.js +5 -124
  139. package/dist/host/ports/ingress.js +2 -57
  140. package/dist/host/ports/local-act.js +5 -183
  141. package/dist/host/ports/place-act.js +1 -134
  142. package/dist/host/ports/publication.js +1 -56
  143. package/dist/host/ports/signing.js +1 -74
  144. package/dist/host/ports/store.js +1 -18
  145. package/dist/host/ports/transport.js +1 -48
  146. package/dist/host/process-lifetime.js +1 -17
  147. package/dist/host/profile-composition.d.ts +1 -0
  148. package/dist/host/profile-composition.js +2 -0
  149. package/dist/host/provide.js +1 -183
  150. package/dist/host/read-only.js +1 -9
  151. package/dist/host/reading-closures.js +7 -227
  152. package/dist/host/reading-context.js +1 -53
  153. package/dist/host/reading-identity-types.js +0 -0
  154. package/dist/host/reading-identity.js +3 -0
  155. package/dist/host/reading-preparation.js +6 -0
  156. package/dist/host/reference-authenticated.d.ts +1 -40
  157. package/dist/host/reference-authenticated.js +3 -100
  158. package/dist/host/reference-contracts.js +1 -6
  159. package/dist/host/reference-export.js +6 -81
  160. package/dist/host/reference-native-api.d.ts +1 -3
  161. package/dist/host/reference-native-api.js +1 -3
  162. package/dist/host/reference-native.js +1 -74
  163. package/dist/host/reference-profile.js +1 -63
  164. package/dist/host/reference-standing.js +2 -18
  165. package/dist/host/reference.js +1 -24
  166. package/dist/host/refusals.js +2 -43
  167. package/dist/host/release.js +4 -256
  168. package/dist/host/root-clock-source.js +1 -307
  169. package/dist/host/selected-capsules.js +1 -50
  170. package/dist/host/selected-topos.js +1 -80
  171. package/dist/host/signature-era.js +1 -12
  172. package/dist/host/signing.js +2 -48
  173. package/dist/host/source-content.js +2 -111
  174. package/dist/host/standing-carrier.js +1 -18
  175. package/dist/host/standing-projection.js +1 -50
  176. package/dist/host/timing.js +1 -7
  177. package/dist/host/walk.js +20 -193
  178. package/dist/host/work-trace.js +1 -0
  179. package/dist/judge/late.js +1 -33
  180. package/dist/judge/take.js +2 -75
  181. package/dist/judge/widening.js +1 -25
  182. package/dist/land/act.js +8 -336
  183. package/dist/land/alias.js +1 -41
  184. package/dist/land/held.js +1 -23
  185. package/dist/land/inert.js +1 -33
  186. package/dist/land/leaving.js +1 -55
  187. package/dist/land/ledger.js +6 -188
  188. package/dist/land/owned.js +4 -66
  189. package/dist/land/sign.js +1 -53
  190. package/dist/land/standing-pin.js +1 -49
  191. package/dist/land/vouched.js +1 -112
  192. package/dist/land/withdraw.js +1 -24
  193. package/dist/observe/files.js +1 -88
  194. package/dist/observe/identity.js +1 -61
  195. package/dist/observe/match.js +1 -8
  196. package/dist/observe/regions.js +7 -306
  197. package/dist/observe/run.js +1 -41
  198. package/dist/observe/runner.js +4 -101
  199. package/dist/public-types.d.ts +2019 -0
  200. package/dist/render/capsule.js +1 -30
  201. package/dist/render/field.js +1 -40
  202. package/dist/render/names.js +1 -4
  203. package/dist/render/open.js +1 -61
  204. package/dist/render/page.js +1 -7
  205. package/dist/render/receipt-projection.js +1 -0
  206. package/dist/render/receipts.js +1 -47
  207. package/dist/render/shape.js +1 -74
  208. package/dist/render/target.js +4 -52
  209. package/dist/render/view.js +7 -197
  210. package/dist/vendor/bundle.json +1 -0
  211. package/dist/vendor/library14.js +1 -0
  212. package/dist/vendor/object-provider.js +42 -0
  213. package/dist/vendor/runtime.js +61 -0
  214. package/dist/wasm/adapter.d.ts +1 -51
  215. package/dist/wasm/adapter.js +1 -180
  216. package/dist/wasm/node-worker.js +1 -13
  217. package/dist/wasm/object.js +1 -76
  218. package/dist/wasm/worker.js +1 -7
  219. package/docs/contracts/authenticated-reference.publication.json +1 -1
  220. package/docs/contracts/authority-preflight.md +17 -0
  221. package/docs/contracts/authority-preflight.publication.json +25 -0
  222. package/docs/contracts/closure-delivery.md +1 -1
  223. package/docs/contracts/closure-delivery.publication.json +1 -1
  224. package/docs/contracts/conformance.json +142 -0
  225. package/docs/contracts/determinism.bound +9 -0
  226. package/docs/contracts/engine-object-projection.publication.json +1 -1
  227. package/docs/contracts/engine.md +21 -1
  228. package/docs/contracts/installed-package.md +21 -0
  229. package/docs/contracts/installed-package.publication.json +25 -0
  230. package/docs/contracts/materialized-leaf-sequence.md +15 -0
  231. package/docs/contracts/materialized-leaf-sequence.publication.json +25 -0
  232. package/docs/contracts/module-inventory.md +15 -0
  233. package/docs/contracts/module-inventory.publication.json +25 -0
  234. package/docs/contracts/native-host.md +29 -1
  235. package/docs/contracts/native-host.publication.json +4 -4
  236. package/docs/contracts/native-probes.md +13 -0
  237. package/docs/contracts/native-probes.publication.json +25 -0
  238. package/docs/contracts/native-publication.inventory.json +10 -1
  239. package/docs/contracts/native-view-batch.md +17 -0
  240. package/docs/contracts/native-view-batch.publication.json +25 -0
  241. package/docs/contracts/optional-wasm-adapter.publication.json +1 -1
  242. package/docs/contracts/physical-lines.md +19 -0
  243. package/docs/contracts/physical-lines.publication.json +25 -0
  244. package/docs/contracts/profile-composition.md +17 -0
  245. package/docs/contracts/profile-composition.publication.json +25 -0
  246. package/docs/contracts/profile-preparation-native-meaning.md +9 -0
  247. package/docs/contracts/publication.md +12 -0
  248. package/docs/contracts/reading-identity.md +61 -0
  249. package/docs/contracts/reading-identity.publication.json +25 -0
  250. package/docs/contracts/reading-witness-admission.md +49 -0
  251. package/docs/contracts/readme.publication.json +1 -1
  252. package/docs/contracts/reference-port.md +11 -0
  253. package/docs/contracts/reference-port.publication.json +1 -1
  254. package/docs/contracts/refusals.bound +346 -94
  255. package/docs/contracts/refusals.md +119 -39
  256. package/docs/contracts/refusals.publication.json +2 -2
  257. package/docs/contracts/views.md +8 -0
  258. package/docs/reference.md +9 -0
  259. package/licenses/wasm/{fast-text-encoding.txt → NOTICE.txt} +111 -0
  260. package/package.json +84 -34
  261. package/receipts.bound +12952 -10449
  262. package/samples/authority-preflight/no.json +6 -0
  263. package/samples/authority-preflight/yes.json +30 -0
  264. package/samples/engine-alphabet/reader.js +3 -1457
  265. package/samples/engine-alphabet/receipts.bound +7 -7
  266. package/samples/engine-interval/reader.js +3 -1457
  267. package/samples/engine-interval/receipts.bound +7 -7
  268. package/samples/installed-package/consumer.mjs +29 -0
  269. package/samples/installed-package/fixture.json +48 -0
  270. package/samples/installed-package/no.json +10 -0
  271. package/samples/installed-package/yes.json +52 -0
  272. package/samples/materialized-leaf-sequence/no.json +11 -0
  273. package/samples/materialized-leaf-sequence/yes.json +10 -0
  274. package/samples/module-inventory/yes.json +28 -0
  275. package/samples/native/physical-line-reader.mjs +1 -0
  276. package/samples/native/physical-line-reader.source.mjs +13 -0
  277. package/samples/native-host/no.json +6 -1
  278. package/samples/native-host/yes.json +18 -1
  279. package/samples/native-probes/inputs/inspection.json +28 -0
  280. package/samples/native-probes/no.json +7 -0
  281. package/samples/native-probes/yes.json +28 -0
  282. package/samples/native-view-batch/no.json +14 -0
  283. package/samples/native-view-batch/yes.json +10 -0
  284. package/samples/no/engine-order/reader.js +3 -1457
  285. package/samples/no/module-inventory/no.json +10 -0
  286. package/samples/physical-lines/no.json +5 -0
  287. package/samples/physical-lines/yes.json +9 -0
  288. package/samples/profile-composition/no.json +6 -0
  289. package/samples/profile-composition/yes.json +14 -0
  290. package/samples/reading-identity/no.json +26 -0
  291. package/samples/reading-identity/yes.json +69 -0
  292. package/vectors/native/authority-preflight.vector.json +55 -0
  293. package/vectors/native/installed-package.vector.json +31 -0
  294. package/vectors/native/materialized-leaf-sequence.vector.json +31 -0
  295. package/vectors/native/module-inventory.vector.json +56 -0
  296. package/vectors/native/native-host.vector.json +214 -0
  297. package/vectors/native/native-probes.vector.json +31 -0
  298. package/vectors/native/native-view-batch.vector.json +31 -0
  299. package/vectors/native/physical-lines.vector.json +105 -0
  300. package/vectors/native/profile-composition.vector.json +53 -0
  301. package/vectors/native/reading-identity.vector.json +139 -0
  302. package/vectors/native/refusals.vector.json +138 -0
  303. package/vendor/syntax/LICENSE.md +7 -0
  304. package/vendor/syntax/parser.js +1 -0
  305. package/.github/workflows/release.yml +0 -67
  306. package/.github/workflows/test.yml +0 -35
  307. package/dist/engine/object.d.ts +0 -17
  308. package/dist/engine/ports.d.ts +0 -37
  309. package/dist/fold/claims.d.ts +0 -29
  310. package/dist/host/call-context.d.ts +0 -20
  311. package/dist/host/commit-result.d.ts +0 -6
  312. package/dist/host/in-process-act.d.ts +0 -82
  313. package/dist/host/in-process-context.d.ts +0 -46
  314. package/dist/host/in-process-root.d.ts +0 -117
  315. package/dist/host/in-process.d.ts +0 -41
  316. package/dist/host/native/module-closure.d.ts +0 -35
  317. package/dist/host/native-receiver.d.ts +0 -19
  318. package/dist/host/place-act-transaction.d.ts +0 -24
  319. package/dist/host/place-clock-selection.d.ts +0 -55
  320. package/dist/host/ports/local-act.d.ts +0 -44
  321. package/dist/host/ports/place-act.d.ts +0 -49
  322. package/dist/host/ports/publication.d.ts +0 -10
  323. package/dist/host/reference-export.d.ts +0 -33
  324. package/dist/host/reference-native.d.ts +0 -30
  325. package/dist/host/reference-profile.d.ts +0 -23
  326. package/dist/host/refusals.d.ts +0 -14
  327. package/dist/host/root-clock-source.d.ts +0 -86
  328. package/licenses/wasm/jitl-quickjs-ffi-types.txt +0 -21
  329. package/licenses/wasm/jitl-quickjs-wasmfile-release-sync.txt +0 -47
  330. package/licenses/wasm/quickjs-emscripten-core.txt +0 -21
  331. package/licenses/wasm/topos.txt +0 -21
  332. /package/{licenses/wasm/bound.txt → dist/vendor/28cba430228db1c04f446c93f81b09a2705d6bf3e222d35adbe5a4cee4061884.LICENSE} +0 -0
  333. /package/{licenses/wasm/obligations.txt → dist/vendor/7aca161279d14bc0e054dcc281cd110aeb95be2e026b42fdf527a260e58b2aae.LICENSE} +0 -0
@@ -1,74 +1 @@
1
- import { spawn } from 'node:child_process';
2
- import { readFileSync } from 'node:fs';
3
- import { signBytes } from "../adapters/keys/ed25519.js";
4
- /** Contains only host-controlled diagnostics, never child output. */
5
- export class SigningFailure extends Error {
6
- }
7
- /** Host-approved mechanism only. Repository declarations do not authorize execution. */
8
- export async function invokeSigner(lot, mechanism, protocol, limits) {
9
- if (!Number.isSafeInteger(limits.timeoutMs) || limits.timeoutMs <= 0
10
- || !Number.isSafeInteger(limits.responseBytes) || limits.responseBytes <= 0) {
11
- throw new SigningFailure(`REFUSE·signer ${lot.keyId} has no valid declared limits`);
12
- }
13
- const request = protocol.request(lot);
14
- let output;
15
- if (mechanism.kind === 'file') {
16
- try {
17
- const key = readFileSync(mechanism.path, 'utf8');
18
- output = protocol.response(lot.bytes.map(bytes => ({ keyId: lot.keyId, signature: signBytes(bytes, key, lot.algorithm) })));
19
- }
20
- catch {
21
- throw new SigningFailure(`REFUSE·signer ${lot.keyId} file mechanism failed`);
22
- }
23
- }
24
- else
25
- output = await new Promise((resolve, reject) => {
26
- const child = spawn(mechanism.executable, [...mechanism.args], { stdio: ['pipe', 'pipe', 'pipe'], shell: false });
27
- let size = 0;
28
- const chunks = [];
29
- let failure;
30
- const refuse = (why) => {
31
- if (failure)
32
- return;
33
- failure = why;
34
- child.kill('SIGKILL');
35
- clearTimeout(timer);
36
- child.stdin.destroy();
37
- child.stdout.destroy();
38
- child.stderr.destroy();
39
- reject(new SigningFailure(`REFUSE·signer ${lot.keyId} ${why} · status=none · signal=SIGKILL`));
40
- };
41
- const timer = setTimeout(() => refuse('timeout'), limits.timeoutMs);
42
- child.stdout.on('data', (chunk) => {
43
- size += chunk.length;
44
- if (size > limits.responseBytes)
45
- refuse('response exceeds declared limit');
46
- if (!failure)
47
- chunks.push(chunk);
48
- });
49
- // Drain, never forward or retain signer diagnostics.
50
- child.stderr.on('data', () => { });
51
- child.stdin.on('error', () => refuse('input delivery failed'));
52
- child.on('error', () => {
53
- clearTimeout(timer);
54
- reject(new SigningFailure(`REFUSE·signer ${lot.keyId} command could not start`));
55
- });
56
- child.on('close', (status, signal) => {
57
- clearTimeout(timer);
58
- if (failure || status !== 0) {
59
- reject(new SigningFailure(`REFUSE·signer ${lot.keyId} ${failure ?? 'command failed'} · status=${status ?? 'none'} · signal=${signal ?? 'none'}`));
60
- }
61
- else
62
- resolve(Buffer.concat(chunks).toString('utf8'));
63
- });
64
- child.stdin.end(request);
65
- });
66
- if (Buffer.byteLength(output) > limits.responseBytes)
67
- throw new SigningFailure(`REFUSE·signer ${lot.keyId} response exceeds declared limit`);
68
- try {
69
- return protocol.reply(output, lot);
70
- }
71
- catch {
72
- throw new SigningFailure(`REFUSE·signer ${lot.keyId} invalid response`);
73
- }
74
- }
1
+ var I=Object.defineProperty;var u=(e,i)=>I(e,"name",{value:i,configurable:!0});import{spawn as S}from"node:child_process";import{readFileSync as k}from"node:fs";import{signBytes as w}from"../adapters/keys/ed25519.js";class t extends Error{static{u(this,"SigningFailure")}}async function R(e,i,f,n){if(!Number.isSafeInteger(n.timeoutMs)||n.timeoutMs<=0||!Number.isSafeInteger(n.responseBytes)||n.responseBytes<=0)throw new t(`REFUSE\xB7signer ${e.keyId} has no valid declared limits`);const m=f.request(e);let a;if(i.kind==="file")try{const y=k(i.path,"utf8");a=f.response(e.bytes.map(o=>({keyId:e.keyId,signature:w(o,y,e.algorithm)})))}catch{throw new t(`REFUSE\xB7signer ${e.keyId} file mechanism failed`)}else a=await new Promise((y,o)=>{const r=S(i.executable,[...i.args],{stdio:["pipe","pipe","pipe"],shell:!1});let g=0;const l=[];let d;const c=u(s=>{d||(d=s,r.kill("SIGKILL"),clearTimeout(p),r.stdin.destroy(),r.stdout.destroy(),r.stderr.destroy(),o(new t(`REFUSE\xB7signer ${e.keyId} ${s} \xB7 status=none \xB7 signal=SIGKILL`)))},"refuse"),p=setTimeout(()=>c("timeout"),n.timeoutMs);r.stdout.on("data",s=>{g+=s.length,g>n.responseBytes&&c("response exceeds declared limit"),d||l.push(s)}),r.stderr.on("data",()=>{}),r.stdin.on("error",()=>c("input delivery failed")),r.on("error",()=>{clearTimeout(p),o(new t(`REFUSE\xB7signer ${e.keyId} command could not start`))}),r.on("close",(s,E)=>{clearTimeout(p),d||s!==0?o(new t(`REFUSE\xB7signer ${e.keyId} ${d??"command failed"} \xB7 status=${s??"none"} \xB7 signal=${E??"none"}`)):y(Buffer.concat(l).toString("utf8"))}),r.stdin.end(m)});if(Buffer.byteLength(a)>n.responseBytes)throw new t(`REFUSE\xB7signer ${e.keyId} response exceeds declared limit`);try{return f.reply(a,e)}catch{throw new t(`REFUSE\xB7signer ${e.keyId} invalid response`)}}u(R,"invokeSigner");export{t as SigningFailure,R as invokeSigner};
@@ -1,18 +1 @@
1
- /** The store root is the tree that holds a TARGET.bound beside its .bound store. */
2
- import { existsSync, readdirSync } from 'node:fs';
3
- import { dirname, join, resolve } from 'node:path';
4
- import { EXTENSION, LOCK } from '@lapxo/topos/wire';
5
- export function storeRoot(from) {
6
- const abs = resolve(from || '.');
7
- let at = abs;
8
- for (let i = 0; i < 64; i += 1) {
9
- if (existsSync(join(at, LOCK)) && existsSync(join(at, EXTENSION)))
10
- return at;
11
- const parent = dirname(at);
12
- if (parent === at)
13
- break;
14
- at = parent;
15
- }
16
- return abs;
17
- }
18
- export const storeDirs = (store) => existsSync(store) ? readdirSync(store, { withFileTypes: true }).filter((entry) => entry.isDirectory()).length : 0;
1
+ var f=Object.defineProperty;var i=(r,t)=>f(r,"name",{value:t,configurable:!0});import{existsSync as o,readdirSync as l}from"node:fs";import{dirname as c,join as a,resolve as m}from"node:path";import{library14_EXTENSION as p,library14_LOCK as y}from"../../vendor/runtime.js";function O(r){const t=m(r||".");let e=t;for(let n=0;n<64;n+=1){if(o(a(e,y))&&o(a(e,p)))return e;const s=c(e);if(s===e)break;e=s}return t}i(O,"storeRoot");const S=i(r=>o(r)?l(r,{withFileTypes:!0}).filter(t=>t.isDirectory()).length:0,"storeDirs");export{S as storeDirs,O as storeRoot};
@@ -1,48 +1 @@
1
- import { readFileSync } from 'node:fs';
2
- import { contentRequest, transportSelection, parse } from '@lapxo/topos/wire';
3
- import { boundedProcess } from "../process-lifetime.js";
4
- import { fetchBytes } from "../adapters/transport/http.js";
5
- export async function transportBytes(location, digest, lines) {
6
- const scheme = new URL(location).protocol.slice(0, -1);
7
- const fields = lines.flatMap(line => { const p = parse(line); return p.kind === 'fact' ? [p.value.fields] : []; });
8
- const selected = transportSelection(fields, scheme);
9
- if (selected === undefined)
10
- throw Error(`REFUSE·transport ${scheme} no admitted content-request/1 policy`);
11
- if (selected.name === 'fetch') {
12
- if (!['http', 'https'].includes(scheme))
13
- throw Error(`REFUSE·transport ${scheme} is not supported by this host adapter`);
14
- return fetchBytes(location, selected);
15
- }
16
- const registryPath = process.env['BOUND_TRANSPORTS'];
17
- if (!registryPath)
18
- throw Error(`REFUSE·transport ${scheme} no host binding for ${selected.name}`);
19
- let record;
20
- try {
21
- const registry = JSON.parse(readFileSync(registryPath, 'utf8'));
22
- if (!registry || typeof registry !== 'object' || !Object.prototype.hasOwnProperty.call(registry, selected.name))
23
- throw Error();
24
- const value = registry[selected.name];
25
- if (!value || typeof value !== 'object')
26
- throw Error();
27
- const f = value;
28
- if (f.kind !== 'command' || typeof f.executable !== 'string' || !f.executable || !Array.isArray(f.args) || !f.args.every(x => typeof x === 'string'))
29
- throw Error();
30
- if (f.environment !== undefined && (!Array.isArray(f.environment) || !f.environment.every(x => typeof x === 'string')))
31
- throw Error();
32
- const names = (f.environment ?? []);
33
- const env = {};
34
- if (process.env.PATH !== undefined)
35
- env.PATH = process.env.PATH;
36
- for (const name of names)
37
- if (process.env[name] !== undefined)
38
- env[name] = process.env[name];
39
- record = { executable: f.executable, args: f.args, env };
40
- }
41
- catch {
42
- throw Error(`REFUSE·transport ${scheme} host binding unavailable or invalid`);
43
- }
44
- const result = boundedProcess(record.executable, record.args, contentRequest(location, digest, selected), selected, undefined, record.env);
45
- if (result.status !== 0 || result.signal !== null)
46
- throw Error(`REFUSE·transport ${scheme} failed · status ${result.status ?? result.signal}`);
47
- return Buffer.from(result.stdoutBytes ?? '', 'base64');
48
- }
1
+ var g=Object.defineProperty;var u=(o,l)=>g(o,"name",{value:l,configurable:!0});import{readFileSync as w}from"node:fs";import{library14_contentRequest as b,library14_transportSelection as v,library14_parse as R}from"../../vendor/runtime.js";import{boundedProcess as S}from"../process-lifetime.js";import{BoundRefusal as y}from"../refusals.js";import{fetchBytes as U}from"../adapters/transport/http.js";async function B(o,l,m,c={}){const t=new URL(o).protocol.slice(0,-1);if(c.allowedOrigins&&!c.allowedOrigins.includes(new URL(o).origin))throw new y("reference/transport","REFUSE\xB7transport origin is not allowed");if(c.signal?.aborted)throw new y("reference/cancelled","REFUSE\xB7reference cancelled");const h=m.flatMap(s=>{const a=R(s);return a.kind==="fact"?[a.value.fields]:[]}),e=v(h,t);if(e===void 0)throw Error(`REFUSE\xB7transport ${t} no admitted content-request/1 policy`);if(e.name==="fetch"){if(!["http","https"].includes(t))throw Error(`REFUSE\xB7transport ${t} is not supported by this host adapter`);return U(o,e,c)}const p=process.env.BOUND_TRANSPORTS;if(!p)throw Error(`REFUSE\xB7transport ${t} no host binding for ${e.name}`);let f;try{const s=JSON.parse(w(p,"utf8"));if(!s||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,e.name))throw Error();const a=s[e.name];if(!a||typeof a!="object")throw Error();const r=a;if(r.kind!=="command"||typeof r.executable!="string"||!r.executable||!Array.isArray(r.args)||!r.args.every(n=>typeof n=="string")||r.environment!==void 0&&(!Array.isArray(r.environment)||!r.environment.every(n=>typeof n=="string")))throw Error();const E=r.environment??[],d={};process.env.PATH!==void 0&&(d.PATH=process.env.PATH);for(const n of E)process.env[n]!==void 0&&(d[n]=process.env[n]);f={executable:r.executable,args:r.args,env:d}}catch{throw Error(`REFUSE\xB7transport ${t} host binding unavailable or invalid`)}const i=S(f.executable,f.args,b(o,l,e),e,void 0,f.env);if(i.status!==0||i.signal!==null)throw Error(`REFUSE\xB7transport ${t} failed \xB7 status ${i.status??i.signal}`);return Buffer.from(i.stdoutBytes??"","base64")}u(B,"transportBytes");export{B as transportBytes};
@@ -1,17 +1 @@
1
- import { spawnSync } from 'node:child_process';
2
- import { processOf } from "../observe/runner.js";
3
- /** A synchronous fold waits on a supervising host process; the supervisor owns cancellation of its child group. */
4
- export function boundedProcess(command, args, input, limits, cwd, env) {
5
- if (!Number.isSafeInteger(limits.timeoutMs) || limits.timeoutMs <= 0 || !Number.isSafeInteger(limits.responseBytes) || limits.responseBytes <= 0)
6
- throw Error('REFUSE·reader invalid process limits');
7
- // The same monotonic deadline covers handoff, input and execution. Starting a
8
- // fresh timer after stdin closes would leave the handoff outside the policy.
9
- const deadline = process.hrtime.bigint() + BigInt(limits.timeoutMs) * 1000000n;
10
- const run = spawnSync(process.execPath, [processOf('lifetime', 'host'), String(deadline), String(limits.responseBytes)], { input: JSON.stringify({ command, args, input, limits, cwd, env }), encoding: 'utf8', maxBuffer: limits.responseBytes * 12 + 4096 });
11
- if (run.error || run.status !== 0)
12
- throw Error(`REFUSE·reader lifetime supervisor ${run.error?.message ?? run.signal ?? run.status}`);
13
- const result = JSON.parse(run.stdout);
14
- if (result.failure)
15
- throw Error(`REFUSE·reader ${result.failure} · status ${result.status ?? result.signal ?? 'cancelled'}${result.stderr ? ' · child stderr: ' + result.stderr : ''}`);
16
- return result;
17
- }
1
+ var c=Object.defineProperty;var n=(t,o)=>c(t,"name",{value:o,configurable:!0});import{spawnSync as d}from"node:child_process";import{processOf as p}from"../observe/runner.js";function m(t,o,i,e,a,u){if(!Number.isSafeInteger(e.timeoutMs)||e.timeoutMs<=0||!Number.isSafeInteger(e.responseBytes)||e.responseBytes<=0)throw Error("REFUSE\xB7reader invalid process limits");const f=process.hrtime.bigint()+BigInt(e.timeoutMs)*1000000n,s=d(process.execPath,[p("lifetime","host"),String(f),String(e.responseBytes)],{input:JSON.stringify({command:t,args:o,input:i,limits:e,cwd:a,env:u}),encoding:"utf8",maxBuffer:e.responseBytes*12+4096});if(s.error||s.status!==0)throw Error(`REFUSE\xB7reader lifetime supervisor ${s.error?.message??s.signal??s.status}`);const r=JSON.parse(s.stdout);if(r.failure)throw Error(`REFUSE\xB7reader ${r.failure} \xB7 status ${r.status??r.signal??"cancelled"}${r.stderr?" \xB7 child stderr: "+r.stderr:""}`);return r}n(m,"boundedProcess");export{m as boundedProcess};
@@ -0,0 +1 @@
1
+ export {public6_ProfileCompositionRequest as ProfileCompositionRequest,public6_ProfileFieldBinding as ProfileFieldBinding,public6_ReleaseCategory as ReleaseCategory,public6_composeProfile as composeProfile,public6_profileDigest as profileDigest,public6_releaseCategoryPins as releaseCategoryPins} from "../public-types.js";
@@ -0,0 +1,2 @@
1
+ var z=Object.defineProperty;var u=(o,n)=>z(o,"name",{value:n,configurable:!0});import{sha256 as S}from"./hash.js";import{library5_decodeProfileComposition as B,library5_encodeProfileComposition as W,library5_inspectProfileComposition as A}from"../vendor/runtime.js";import{fieldOf as r}from"../fold/claims.js";import{lockLines as D,lockStanding as L}from"../fold/keys.js";import{authorityFor as T,rootSigner as U}from"../fold/signers.js";import{ownRecordAdmitted as j}from"../fold/signed.js";import{signaturesOf as G}from"../fold/digests.js";import{wordOf as x}from"../fold/wire.js";import{storeOf as H}from"../land/ledger.js";import{widenedWithoutWitness as I}from"../judge/widening.js";import{BoundRefusal as J,refuseBound as t}from"./refusals.js";const K=u(o=>S(o+`
2
+ `),"profileDigest");function se(o){const{profile:n,profiles:h,budget:m}=o,a=new Map(o.fields.map(e=>[e.contract,e]));a.size!==o.fields.length&&t("profile/ambiguous-field");let s;try{s=A(n,{profiles:h,fields:new Map(o.fields.map(e=>[e.contract,e.field])),digest:S},m)}catch(e){throw new J("profile/declaration","REFUSE\xB7profile/declaration "+(e instanceof Error?e.message:"Topos declaration refused"))}s.status==="open"&&t("profile/missing-parent"),s.fields.some(e=>e.composition!=="compatible")&&t("profile/incompatible");const l=H(o.root),d=D(l),f=L(l),w=G(l).admitted,P=T(d,U(o.root),w).admitted,E=P.some(e=>!e.coverage.includes("*"))?x(f,"families","region"):"",C=o.statements.filter(e=>j(e,o.place,E,P,w)),y=new Map;function v(e){if(y.has(e))return;const c=h.get(e);c===void 0&&t("profile/missing-parent");const i=B(c,m);y.set(e,i);for(const p of i.parents)v(p)}u(v,"visit");for(const e of n.parents)v(e);const b=K(W(n,m));y.set(b,n);const O=u((e,c)=>{const i=a.get(e.contract);if(!i||i.field.coordinate!==e.coordinate)return t("profile/undeclared-field");const p=C.filter(g=>r(g,"scope")===i.scope&&r(g,"role")===i.role&&r(g,"form")===i.form&&r(g,"measure")===i.measure&&r(g,"value")===e.value&&r(g,"restsOn")===c);return p.length!==1?t(p.length?"profile/ambiguous-authority":"profile/authority-required"):p[0]},"lineFor"),F=[...y].filter(([e])=>e!==b).flatMap(([e,c])=>c.fields.map(i=>O(i,e))),M=n.fields.map(e=>O(e,b)),R=x(f,"at-classes","witness");for(const e of F){const c=M.filter(i=>["scope","role","form","measure"].every(p=>r(i,p)===r(e,p)));I(c,[e],()=>!0,R).length&&t("profile/widening-witness-required")}const _=[...F,...M],k=N(s.pins,o.categories,C);return{status:"prepared",digest:b,inspection:s,lines:_,pins:s.pins,releases:k}}u(se,"composeProfile");function N(o,n,h){const m=[];for(const a of o){const s=n.filter(f=>f.category===a.category);s.length||t("release/category-missing"),s.length!==1&&t("release/category-ambiguous");const l=s[0];(l.class!==a.class||a.algorithm!=="sha256")&&t("release/category-class");const d=h.filter(f=>r(f,"scope")===l.scope&&r(f,"role")===l.role&&r(f,"form")==="alphabet"&&r(f,"measure")===l.measure);d.length||t("release/pin-missing"),d.length!==1&&t("release/pin-ambiguous"),r(d[0],"value")!==a.digest&&t("release/pin-integrity"),m.push(d[0])}return new Set(o.map(a=>a.category)).size!==o.length&&t("release/category-ambiguous"),m}u(N,"releaseCategoryPins");export{se as composeProfile,K as profileDigest,N as releaseCategoryPins};
@@ -1,183 +1 @@
1
- import * as nodeModule from 'node:module';
2
- import { realpathSync } from 'node:fs';
3
- import { join, relative, isAbsolute, sep } from 'node:path';
4
- import { pathToFileURL } from 'node:url';
5
- import { fieldOf } from "../fold/claims.js";
6
- import { observeText } from "../observe/files.js";
7
- import { ownLock, ownStore, ownRoot } from "../observe/runner.js";
8
- import { runtimeTreeAt } from "./release.js";
9
- import { ContentNeeded } from "./content-needed.js";
10
- import { theWord } from "../fold/wire.js";
11
- const findPackageJSON = nodeModule.findPackageJSON;
12
- const registerHooks = nodeModule.registerHooks;
13
- const taken = (exp) => (typeof exp === 'string' ? exp : exp && typeof exp === 'object' && 'default' in exp && typeof exp.default === 'string' ? exp.default : '');
14
- /**
15
- * Resolve declared library bytes for this host. A library's shape may select an
16
- * archive coordinate; world selection remains the standing contract.
17
- */
18
- export function pinPlace(name) {
19
- const lock = ownLock();
20
- const line = lock.find((one) => fieldOf(one, 'scope') === `dep/${name}` && fieldOf(one, 'role') === 'reads')
21
- ?? lock.find((one) => fieldOf(one, 'scope') === `uses/${name}`);
22
- if (line === undefined)
23
- return '';
24
- const digest = fieldOf(line, 'value');
25
- return digest ? runtimeTreeAt(ownStore(), ownRoot(), digest, ownStore(), fieldOf(line, 'role') === 'reads' ? fieldOf(line, 'shape') : '') ?? '' : '';
26
- }
27
- export function pinExport(name, sub) {
28
- const at = pinPlace(name);
29
- const file = taken(JSON.parse(observeText(join(at, manifestOf())) ?? '{}').exports?.[sub]);
30
- return at && file ? join(at, file) : '';
31
- }
32
- export function pinName(name) {
33
- const at = pinPlace(name);
34
- return at ? (JSON.parse(observeText(join(at, manifestOf())) ?? '{}').name ?? '') : '';
35
- }
36
- const manifestOf = () => `${theWord(ownLock(), 'pin-shape')}.json`;
37
- /** Node package resolution at a digest-laid library; exports remain authoritative. */
38
- export function resolvePinned(specifier, context, nextResolve, pin) {
39
- if (pin.exports)
40
- return nextResolve(specifier, { ...context, parentURL: pin.json });
41
- const sub = specifier === pin.pkg ? '' : specifier.slice(pin.pkg.length + 1);
42
- const requested = join(pin.at, sub);
43
- const coordinate = relative(pin.at, requested);
44
- if (isAbsolute(coordinate) || coordinate === '..' || coordinate.startsWith(`..${sep}`))
45
- throw new Error('REFUSE·pin library import leaves its laid tree');
46
- const file = nodeModule.createRequire(pin.json).resolve(requested);
47
- const entry = relative(realpathSync(pin.at), realpathSync(file));
48
- if (isAbsolute(entry) || entry === '..' || entry.startsWith(`..${sep}`))
49
- throw new Error('REFUSE·pin library entry leaves its laid tree');
50
- return nextResolve(pathToFileURL(file).href, context);
51
- }
52
- /**
53
- * A blob stays self-contained. The one thing it does not carry is the SDK the host provides: an import whose package
54
- * the instrument's own lock names at dep/<name> resolves at the place pinPlace delivers. Nothing is linked into the
55
- * blob's folder.
56
- */
57
- let hooked = false;
58
- function nativeResolution() {
59
- const installed = Object.getOwnPropertyDescriptor(globalThis, Symbol.for('bound.native.resolution@1'));
60
- if (!installed)
61
- return undefined;
62
- const capability = installed.value;
63
- if (installed.configurable !== false || installed.writable !== false || !capability || !Object.isFrozen(capability) || capability.profile !== 'fixed-native-resolution@1' || !Array.isArray(capability.libraryNames) || !Object.isFrozen(capability.libraryNames) || capability.libraryNames.some(name => typeof name !== 'string') || !Array.isArray(capability.libraries) || !Object.isFrozen(capability.libraries) || capability.libraries.some(lib => !lib || !Object.isFrozen(lib) || typeof lib.name !== 'string' || typeof lib.manifest !== 'string') || typeof capability.assertPins !== 'function')
64
- throw Error('REFUSE·pin fixed resolution capability invalid');
65
- return capability;
66
- }
67
- /** Fixed execution selects libraries by the instrument's explicit local mount,
68
- * before opening any artifact. An alias or package-name guess grants nothing. */
69
- export function selectNativeDependencies(root, dependencies, manifest) {
70
- const capability = nativeResolution();
71
- if (!capability)
72
- return undefined;
73
- if (dependencies.length && capability.libraries.some(library => typeof library.coordinate !== 'string' || !library.coordinate))
74
- throw Error('REFUSE·pin fixed resolution logical library coordinate missing');
75
- const selected = new Map(capability.libraries.map(library => [library.coordinate, library]));
76
- return dependencies.flatMap(line => {
77
- const mount = fieldOf(line, 'needs');
78
- if (!mount)
79
- return [];
80
- const library = selected.get(mount.replace(/\/+$/, '') + '/' + manifest);
81
- if (!library)
82
- return [];
83
- let actual;
84
- try {
85
- actual = realpathSync(join(root, mount, manifest));
86
- }
87
- catch {
88
- throw Error('REFUSE·pin selected library mount absent ' + library.name);
89
- }
90
- if (actual !== library.manifest)
91
- throw Error('REFUSE·pin selected library mount differs ' + library.name);
92
- return [{ line, library }];
93
- });
94
- }
95
- /** A declared artifact is not automatically an active Node library. This fixed
96
- * assertion reuses only the packages selected by the actual host boundary. */
97
- export function reuseNativeResolution(pins) {
98
- const capability = nativeResolution();
99
- if (!capability)
100
- return false;
101
- const selected = new Set(capability.libraryNames);
102
- // The fixed preload owns this closed assertion. Package names select which
103
- // declared pins participate; exact manifests and member bytes still decide.
104
- capability.assertPins(pins.filter(pin => selected.has(pin.pkg)).map(pin => ({ name: pin.pkg, at: pin.at })));
105
- return true;
106
- }
107
- /** Read one resolved archive's manifest; a selected fixed library cannot vanish
108
- * into the optional historical provider path when its archive is absent. */
109
- export function readProvidedPin(name, at, file, requiredName) {
110
- if (!at) {
111
- if (requiredName !== undefined)
112
- throw Error('REFUSE·pin fixed resolution requires declared library ' + name);
113
- return undefined;
114
- }
115
- const manifest = JSON.parse(observeText(join(at, file)) ?? '{}'), pkg = typeof manifest.name === 'string' ? manifest.name : '';
116
- if (requiredName !== undefined && pkg !== requiredName)
117
- throw Error('REFUSE·pin fixed resolution library name differs ' + name);
118
- return pkg ? { at, pkg, exports: Object.prototype.hasOwnProperty.call(manifest, 'exports'), href: pathToFileURL(at).href, json: pathToFileURL(join(at, file)).href } : undefined;
119
- }
120
- export function provide() {
121
- if (hooked)
122
- return;
123
- const dependencies = ownLock().filter((line) => fieldOf(line, 'scope').startsWith('dep/') && fieldOf(line, 'role') === 'reads');
124
- const file = manifestOf(), selected = selectNativeDependencies(ownRoot(), dependencies, file);
125
- const load = (line, requiredName) => {
126
- const name = fieldOf(line, 'scope').slice('dep/'.length), at = pinPlace(name);
127
- if (!at)
128
- throw new ContentNeeded(fieldOf(line, 'value'), 'REFUSE·pin declared library unavailable ' + name);
129
- const pin = readProvidedPin(name, at, file, requiredName);
130
- if (!pin)
131
- throw Error('REFUSE·pin declared library unavailable ' + name);
132
- return pin;
133
- };
134
- if (selected !== undefined) {
135
- reuseNativeResolution(selected.map(({ line, library }) => load(line, library.name)));
136
- hooked = true;
137
- return;
138
- }
139
- // A mount selects a library, but its manifest is only a routing hint until
140
- // an import requests it. The selected archive alone supplies executable bytes.
141
- const mounts = dependencies.filter(line => fieldOf(line, 'needs') !== '').map(line => {
142
- const mount = join(ownRoot(), fieldOf(line, 'needs'));
143
- const manifest = JSON.parse(observeText(join(mount, file)) ?? '{}');
144
- return { line, mount, pkg: typeof manifest.name === 'string' ? manifest.name : '' };
145
- });
146
- const verified = new Map();
147
- registerHooks({
148
- resolve(specifier, context, nextResolve) {
149
- if (specifier.startsWith('.') || specifier.startsWith('/') || specifier.includes(':'))
150
- return nextResolve(specifier, context);
151
- let selected = mounts.find(one => one.pkg && (specifier === one.pkg || specifier.startsWith(one.pkg + '/')));
152
- if (!selected) {
153
- // Identify the installed package before following its executable entry:
154
- // a renamed manifest and an escaping entry cannot bypass the declared mount.
155
- let manifest;
156
- try {
157
- manifest = findPackageJSON(specifier, pathToFileURL(join(ownRoot(), file)).href);
158
- }
159
- catch { }
160
- if (manifest)
161
- selected = mounts.find(one => {
162
- try {
163
- return realpathSync(join(one.mount, file)) === realpathSync(manifest);
164
- }
165
- catch {
166
- return false;
167
- }
168
- });
169
- }
170
- if (!selected)
171
- return nextResolve(specifier, context);
172
- let pin = verified.get(selected.line);
173
- if (!pin) {
174
- pin = load(selected.line);
175
- verified.set(selected.line, pin);
176
- }
177
- if (specifier !== pin.pkg && !specifier.startsWith(pin.pkg + '/'))
178
- throw Error('REFUSE·pin selected library name differs');
179
- return resolvePinned(specifier, context, nextResolve, pin);
180
- },
181
- });
182
- hooked = true;
183
- }
1
+ var P=Object.defineProperty;var f=(r,e)=>P(r,"name",{value:e,configurable:!0});import*as E from"node:module";import{realpathSync as y}from"node:fs";import{join as d,relative as F,isAbsolute as O,sep as R}from"node:path";import{pathToFileURL as h}from"node:url";import{fieldOf as c}from"../fold/claims.js";import{observeText as b}from"../observe/files.js";import{ownLock as w,ownStore as U,ownRoot as g}from"../observe/runner.js";import{runtimeTreeAt as W}from"./release.js";import{ContentNeeded as x}from"./content-needed.js";import{theWord as A}from"../fold/wire.js";const J=E.findPackageJSON,$=E.registerHooks,z=f(r=>typeof r=="string"?r:r&&typeof r=="object"&&"default"in r&&typeof r.default=="string"?r.default:"","taken");function S(r){const e=w(),o=e.find(l=>c(l,"scope")===`dep/${r}`&&c(l,"role")==="reads")??e.find(l=>c(l,"scope")===`uses/${r}`);if(o===void 0)return"";const n=c(o,"value");return n?W(U(),g(),n,U(),c(o,"role")==="reads"?c(o,"shape"):"")??"":""}f(S,"pinPlace");function Y(r,e){const o=S(r),n=z(JSON.parse(b(d(o,k()))??"{}").exports?.[e]);return o&&n?d(o,n):""}f(Y,"pinExport");function Z(r){const e=S(r);return e?JSON.parse(b(d(e,k()))??"{}").name??"":""}f(Z,"pinName");const k=f(()=>`${A(w(),"pin-shape")}.json`,"manifestOf");function M(r,e,o,n){if(n.exports)return o(r,{...e,parentURL:n.json});const l=r===n.pkg?"":r.slice(n.pkg.length+1),s=d(n.at,l),t=F(n.at,s);if(O(t)||t===".."||t.startsWith(`..${R}`))throw new Error("REFUSE\xB7pin library import leaves its laid tree");const i=E.createRequire(n.json).resolve(s),a=F(y(n.at),y(i));if(O(a)||a===".."||a.startsWith(`..${R}`))throw new Error("REFUSE\xB7pin library entry leaves its laid tree");return o(h(i).href,e)}f(M,"resolvePinned");let v=!1;function j(){const r=Object.getOwnPropertyDescriptor(globalThis,Symbol.for("bound.native.resolution@1"));if(!r)return;const e=r.value;if(r.configurable!==!1||r.writable!==!1||!e||!Object.isFrozen(e)||e.profile!=="fixed-native-resolution@1"||!Array.isArray(e.libraryNames)||!Object.isFrozen(e.libraryNames)||e.libraryNames.some(o=>typeof o!="string")||!Array.isArray(e.libraries)||!Object.isFrozen(e.libraries)||e.libraries.some(o=>!o||!Object.isFrozen(o)||typeof o.name!="string"||typeof o.manifest!="string")||typeof e.assertPins!="function")throw Error("REFUSE\xB7pin fixed resolution capability invalid");return e}f(j,"nativeResolution");function T(r,e,o){const n=j();if(!n)return;if(e.length&&n.libraries.some(s=>typeof s.coordinate!="string"||!s.coordinate))throw Error("REFUSE\xB7pin fixed resolution logical library coordinate missing");const l=new Map(n.libraries.map(s=>[s.coordinate,s]));return e.flatMap(s=>{const t=c(s,"needs");if(!t)return[];const i=l.get(t.replace(/\/+$/,"")+"/"+o);if(!i)return[];let a;try{a=y(d(r,t,o))}catch{throw Error("REFUSE\xB7pin selected library mount absent "+i.name)}if(a!==i.manifest)throw Error("REFUSE\xB7pin selected library mount differs "+i.name);return[{line:s,library:i}]})}f(T,"selectNativeDependencies");function L(r){const e=j();if(!e)return!1;const o=new Set(e.libraryNames);return e.assertPins(r.filter(n=>o.has(n.pkg)).map(n=>({name:n.pkg,at:n.at}))),!0}f(L,"reuseNativeResolution");function D(r,e,o,n){if(!e){if(n!==void 0)throw Error("REFUSE\xB7pin fixed resolution requires declared library "+r);return}const l=JSON.parse(b(d(e,o))??"{}"),s=typeof l.name=="string"?l.name:"";if(n!==void 0&&s!==n)throw Error("REFUSE\xB7pin fixed resolution library name differs "+r);return s?{at:e,pkg:s,exports:Object.prototype.hasOwnProperty.call(l,"exports"),href:h(e).href,json:h(d(e,o)).href}:void 0}f(D,"readProvidedPin");function _(){if(v)return;const r=w().filter(t=>c(t,"scope").startsWith("dep/")&&c(t,"role")==="reads"),e=k(),o=T(g(),r,e),n=f((t,i)=>{const a=c(t,"scope").slice(4),u=S(a);if(!u)throw new x(c(t,"value"),"REFUSE\xB7pin declared library unavailable "+a);const p=D(a,u,e,i);if(!p)throw Error("REFUSE\xB7pin declared library unavailable "+a);return p},"load");if(o!==void 0){L(o.map(({line:t,library:i})=>n(t,i.name))),v=!0;return}const l=r.filter(t=>c(t,"needs")!=="").map(t=>{const i=d(g(),c(t,"needs")),a=JSON.parse(b(d(i,e))??"{}");return{line:t,mount:i,pkg:typeof a.name=="string"?a.name:""}}),s=new Map;$({resolve(t,i,a){if(t.startsWith(".")||t.startsWith("/")||t.includes(":"))return a(t,i);let u=l.find(m=>m.pkg&&(t===m.pkg||t.startsWith(m.pkg+"/")));if(!u){let m;try{m=J(t,h(d(g(),e)).href)}catch{}m&&(u=l.find(N=>{try{return y(d(N.mount,e))===y(m)}catch{return!1}}))}if(!u)return a(t,i);let p=s.get(u.line);if(p||(p=n(u.line),s.set(u.line,p)),t!==p.pkg&&!t.startsWith(p.pkg+"/"))throw Error("REFUSE\xB7pin selected library name differs");return M(t,i,a,p)}}),v=!0}f(_,"provide");export{Y as pinExport,Z as pinName,S as pinPlace,_ as provide,D as readProvidedPin,M as resolvePinned,L as reuseNativeResolution,T as selectNativeDependencies};
@@ -1,9 +1 @@
1
- import { AsyncLocalStorage } from 'node:async_hooks';
2
- /** Prospective evaluation may read existing evidence and calculate values, but cannot acquire evidence or persist caches. */
3
- const mode = new AsyncLocalStorage();
4
- export const readOnly = () => mode.getStore() === true;
5
- export const withoutEffects = (evaluate) => mode.run(true, evaluate);
6
- export function requireEffects(operation) {
7
- if (readOnly())
8
- throw Error(`REFUSE·preview ${operation} requires an act; fold the declared inputs first`);
9
- }
1
+ var n=Object.defineProperty;var r=(e,o)=>n(e,"name",{value:o,configurable:!0});import{AsyncLocalStorage as c}from"node:async_hooks";const t=new c,f=r(()=>t.getStore()===!0,"readOnly"),u=r(e=>t.run(!0,e),"withoutEffects");function a(e){if(f())throw Error(`REFUSE\xB7preview ${e} requires an act; fold the declared inputs first`)}r(a,"requireEffects");export{f as readOnly,a as requireEffects,u as withoutEffects};