@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,152 +1 @@
1
- import { lstatSync, mkdirSync, writeFileSync } from 'node:fs';
2
- import { dirname, join, resolve } from 'node:path';
3
- import { gunzipSync } from 'node:zlib';
4
- const BLOCK = 512; // POSIX tar record size.
5
- const refuse = (why) => { throw new Error(`REFUSE·archive ${why}`); };
6
- /** POSIX archive coordinates; normalization cannot make two members share one destination. */
7
- export function archiveCoordinate(name) {
8
- if (!name || name.startsWith('/') || /^[A-Za-z]:/.test(name) || name.includes('\\') || name.includes('\0'))
9
- refuse(`invalid coordinate ${JSON.stringify(name)}`);
10
- const parts = name.replace(/\/+$/, '').split('/');
11
- while (parts[0] === '.')
12
- parts.shift();
13
- if (!parts.length || parts.some((part) => !part || part === '.' || part === '..'))
14
- refuse(`invalid coordinate ${JSON.stringify(name)}`);
15
- return parts.join('/');
16
- }
17
- function pax(bytes) {
18
- const fields = {};
19
- for (let at = 0; at < bytes.length;) {
20
- const space = bytes.indexOf(32, at);
21
- if (space < 0)
22
- refuse('malformed PAX record length');
23
- const lengthText = new TextDecoder().decode(bytes.subarray(at, space));
24
- if (!/^\d+$/.test(lengthText))
25
- refuse('malformed PAX record length');
26
- const length = Number(lengthText);
27
- const end = at + length;
28
- if (!Number.isSafeInteger(length) || length <= space - at + 1 || end > bytes.length || bytes[end - 1] !== 10)
29
- refuse('truncated PAX record');
30
- const record = new TextDecoder().decode(bytes.subarray(space + 1, end - 1));
31
- const equals = record.indexOf('=');
32
- if (equals < 1)
33
- refuse('malformed PAX attribute');
34
- const key = record.slice(0, equals);
35
- if (key.startsWith('GNU.sparse') || key.startsWith('SCHILY.realsize'))
36
- refuse('sparse PAX members are unsupported');
37
- fields[key] = record.slice(equals + 1);
38
- at = end;
39
- }
40
- return fields;
41
- }
42
- /** The gzip/POSIX tar adapter reads regular files, directories and PAX attributes, or rejects the whole archive. */
43
- export function members(archive) {
44
- const bytes = gunzipSync(archive);
45
- const text = (at, length) => bytes.subarray(at, at + length).toString('utf8').replace(/\0[\s\S]*$/, '');
46
- const octal = (at, length) => {
47
- const raw = text(at, length).trim();
48
- if (!/^[0-7]+$/.test(raw))
49
- refuse(`invalid octal field at ${at}`);
50
- const n = Number.parseInt(raw, 8);
51
- if (!Number.isSafeInteger(n) || n < 0)
52
- refuse(`unrepresentable field at ${at}`);
53
- return n;
54
- };
55
- const out = [];
56
- const files = new Set();
57
- const directories = new Set();
58
- let global = {};
59
- let local;
60
- for (let at = 0;;) {
61
- if (at + BLOCK > bytes.length)
62
- refuse('missing complete end records');
63
- const header = bytes.subarray(at, at + BLOCK);
64
- if (header.every((byte) => byte === 0)) {
65
- if (local !== undefined)
66
- refuse('PAX attributes have no following member');
67
- if (at + 2 * BLOCK > bytes.length || !bytes.subarray(at).every((byte) => byte === 0))
68
- refuse('invalid end records or trailing data');
69
- return out;
70
- }
71
- const checksum = header.reduce((sum, byte, i) => sum + (i >= 148 && i < 156 ? 32 : byte), 0);
72
- if (octal(at + 148, 8) !== checksum)
73
- refuse(`header checksum mismatch at ${at}`);
74
- const magic = text(at + 257, 6);
75
- if (magic && magic !== 'ustar' && magic !== 'ustar ')
76
- refuse(`unsupported tar format ${magic}`);
77
- const type = text(at + 156, 1);
78
- const attrs = { ...global, ...local };
79
- let size = octal(at + 124, 12);
80
- if (type !== 'x' && type !== 'g' && attrs['size'] !== undefined) {
81
- if (!/^\d+$/.test(attrs['size']))
82
- refuse('invalid PAX size');
83
- size = Number(attrs['size']);
84
- if (!Number.isSafeInteger(size))
85
- refuse('unrepresentable PAX size');
86
- }
87
- const next = at + BLOCK + Math.ceil(size / BLOCK) * BLOCK;
88
- if (next > bytes.length)
89
- refuse(`truncated member at ${at}`);
90
- const body = bytes.subarray(at + BLOCK, at + BLOCK + size);
91
- if (type === 'x' || type === 'g') {
92
- const fields = pax(body);
93
- if (type === 'g')
94
- global = { ...global, ...fields };
95
- else
96
- local = { ...local, ...fields };
97
- }
98
- else {
99
- const rawName = attrs['path'] ?? [magic ? text(at + 345, 155) : '', text(at, 100)].filter(Boolean).join('/');
100
- local = undefined;
101
- if (type === '5' && /^\.\/?$/.test(rawName) && size === 0) {
102
- at = next;
103
- continue;
104
- }
105
- const name = archiveCoordinate(rawName);
106
- if (!['', '0', '5'].includes(type))
107
- refuse(`unsupported member type ${type} at ${name}`);
108
- const steps = name.split('/');
109
- if (steps.slice(0, -1).some((_, i) => files.has(steps.slice(0, i + 1).join('/'))))
110
- refuse(`file is an ancestor of ${name}`);
111
- if (type === '5') {
112
- if (size !== 0 || files.has(name))
113
- refuse(`invalid directory ${name}`);
114
- directories.add(name);
115
- }
116
- else {
117
- if (files.has(name) || directories.has(name))
118
- refuse(`duplicate or conflicting member ${name}`);
119
- files.add(name);
120
- steps.slice(0, -1).forEach((_, i) => directories.add(steps.slice(0, i + 1).join('/')));
121
- out.push({ name, bytes: body });
122
- }
123
- }
124
- at = next;
125
- }
126
- }
127
- /** Existing links or files are never followed or overwritten by extraction. */
128
- export function archiveDestination(into, name) {
129
- const root = resolve(into);
130
- const parts = archiveCoordinate(name).split('/');
131
- let at = root;
132
- const base = lstatSync(at, { throwIfNoEntry: false });
133
- if (base !== undefined && !base.isDirectory())
134
- refuse(`destination is not a directory: ${root}`);
135
- for (let i = 0; i < parts.length; i += 1) {
136
- at = join(at, parts[i]);
137
- const st = lstatSync(at, { throwIfNoEntry: false });
138
- if (st !== undefined && (i === parts.length - 1 || !st.isDirectory()))
139
- refuse(`destination already occupied: ${at}`);
140
- }
141
- return at;
142
- }
143
- export function unpack(archive, into) {
144
- const files = members(archive);
145
- const destinations = files.map((one) => archiveDestination(into, one.name));
146
- for (const [i, one] of files.entries()) {
147
- const at = destinations[i];
148
- mkdirSync(dirname(at), { recursive: true });
149
- writeFileSync(at, one.bytes, { flag: 'wx' });
150
- }
151
- return files.map((one) => one.name);
152
- }
1
+ var X=Object.defineProperty;var p=(t,r)=>X(t,"name",{value:r,configurable:!0});import{lstatSync as z,mkdirSync as I,writeFileSync as E}from"node:fs";import{dirname as j,join as k,resolve as D}from"node:path";import{gunzipSync as O}from"node:zlib";const g=512,n=p(t=>{throw new Error(`REFUSE\xB7archive ${t}`)},"refuse");function A(t){(!t||t.startsWith("/")||/^[A-Za-z]:/.test(t)||t.includes("\\")||t.includes("\0"))&&n(`invalid coordinate ${JSON.stringify(t)}`);const r=t.replace(/\/+$/,"").split("/");for(;r[0]===".";)r.shift();return(!r.length||r.some(i=>!i||i==="."||i===".."))&&n(`invalid coordinate ${JSON.stringify(t)}`),r.join("/")}p(A,"archiveCoordinate");function C(t){const r={};for(let i=0;i<t.length;){const c=t.indexOf(32,i);c<0&&n("malformed PAX record length");const s=new TextDecoder().decode(t.subarray(i,c));/^\d+$/.test(s)||n("malformed PAX record length");const a=Number(s),o=i+a;(!Number.isSafeInteger(a)||a<=c-i+1||o>t.length||t[o-1]!==10)&&n("truncated PAX record");const d=new TextDecoder().decode(t.subarray(c+1,o-1)),u=d.indexOf("=");u<1&&n("malformed PAX attribute");const e=d.slice(0,u);(e.startsWith("GNU.sparse")||e.startsWith("SCHILY.realsize"))&&n("sparse PAX members are unsupported"),r[e]=d.slice(u+1),i=o}return r}p(C,"pax");function T(t){const r=O(t),i=p((e,y)=>r.subarray(e,e+y).toString("utf8").replace(/\0[\s\S]*$/,""),"text"),c=p((e,y)=>{const x=i(e,y).trim();/^[0-7]+$/.test(x)||n(`invalid octal field at ${e}`);const m=Number.parseInt(x,8);return(!Number.isSafeInteger(m)||m<0)&&n(`unrepresentable field at ${e}`),m},"octal"),s=[],a=new Set,o=new Set;let d={},u;for(let e=0;;){e+g>r.length&&n("missing complete end records");const y=r.subarray(e,e+g);if(y.every(f=>f===0))return u!==void 0&&n("PAX attributes have no following member"),(e+2*g>r.length||!r.subarray(e).every(f=>f===0))&&n("invalid end records or trailing data"),s;const x=y.reduce((f,l,b)=>f+(b>=148&&b<156?32:l),0);c(e+148,8)!==x&&n(`header checksum mismatch at ${e}`);const m=i(e+257,6);m&&m!=="ustar"&&m!=="ustar "&&n(`unsupported tar format ${m}`);const h=i(e+156,1),S={...d,...u};let $=c(e+124,12);h!=="x"&&h!=="g"&&S.size!==void 0&&(/^\d+$/.test(S.size)||n("invalid PAX size"),$=Number(S.size),Number.isSafeInteger($)||n("unrepresentable PAX size"));const v=e+g+Math.ceil($/g)*g;v>r.length&&n(`truncated member at ${e}`);const N=r.subarray(e+g,e+g+$);if(h==="x"||h==="g"){const f=C(N);h==="g"?d={...d,...f}:u={...u,...f}}else{const f=S.path??[m?i(e+345,155):"",i(e,100)].filter(Boolean).join("/");if(u=void 0,h==="5"&&/^\.\/?$/.test(f)&&$===0){e=v;continue}const l=A(f);["","0","5"].includes(h)||n(`unsupported member type ${h} at ${l}`);const b=l.split("/");b.slice(0,-1).some((P,w)=>a.has(b.slice(0,w+1).join("/")))&&n(`file is an ancestor of ${l}`),h==="5"?(($!==0||a.has(l))&&n(`invalid directory ${l}`),o.add(l)):((a.has(l)||o.has(l))&&n(`duplicate or conflicting member ${l}`),a.add(l),b.slice(0,-1).forEach((P,w)=>o.add(b.slice(0,w+1).join("/"))),s.push({name:l,bytes:N}))}e=v}}p(T,"members");function W(t,r){const i=D(t),c=A(r).split("/");let s=i;const a=z(s,{throwIfNoEntry:!1});a!==void 0&&!a.isDirectory()&&n(`destination is not a directory: ${i}`);for(let o=0;o<c.length;o+=1){s=k(s,c[o]);const d=z(s,{throwIfNoEntry:!1});d!==void 0&&(o===c.length-1||!d.isDirectory())&&n(`destination already occupied: ${s}`)}return s}p(W,"archiveDestination");function U(t,r){const i=T(t),c=i.map(s=>W(r,s.name));for(const[s,a]of i.entries()){const o=c[s];I(j(o),{recursive:!0}),E(o,a.bytes,{flag:"wx"})}return i.map(s=>s.name)}p(U,"unpack");export{A as archiveCoordinate,W as archiveDestination,T as members,U as unpack};
@@ -1,14 +1 @@
1
- import { AsyncLocalStorage } from 'node:async_hooks';
2
- const calls = new AsyncLocalStorage();
3
- export const hostInstrumentName = () => calls.getStore()?.instrumentName;
4
- export const hostInstrumentRuntime = () => calls.getStore()?.runtime;
5
- export const withHostInstrument = (instrumentName, run) => calls.run({ ...calls.getStore(), instrumentName }, run);
6
- export const withHostCall = (call, run) => calls.run(call, run);
7
- /** No stream monkey-patching: diagnostics follow only this asynchronous call. */
8
- export function hostOutput(stream, text) {
9
- const output = calls.getStore()?.output;
10
- if (output)
11
- output(stream, text);
12
- else
13
- (stream === 'out' ? process.stdout : process.stderr).write(text);
14
- }
1
+ var n=Object.defineProperty;var o=(t,e)=>n(t,"name",{value:e,configurable:!0});import{AsyncLocalStorage as u}from"node:async_hooks";const s=new u,m=o(()=>s.getStore()?.freshBytes===!0,"hostRequiresFreshBytes"),i=o(()=>s.getStore()?.arguments,"hostArguments"),g=o(()=>s.getStore()?.instrumentName,"hostInstrumentName"),h=o(()=>s.getStore()?.runtime,"hostInstrumentRuntime"),S=o((t,e)=>s.run({...s.getStore(),instrumentName:t},e),"withHostInstrument"),a=o((t,e)=>s.run(t,e),"withHostCall");function l(t,e){const r=s.getStore()?.output;r?r(t,e):(t==="out"?process.stdout:process.stderr).write(e)}o(l,"hostOutput");export{i as hostArguments,g as hostInstrumentName,h as hostInstrumentRuntime,l as hostOutput,m as hostRequiresFreshBytes,a as withHostCall,S as withHostInstrument};
@@ -1,62 +1,2 @@
1
- import { hostOutput } from "./call-context.js";
2
- import { actCosts } from "./act-cost.js";
3
- import { fileURLToPath } from 'node:url';
4
- import { boundedProcess } from "./process-lifetime.js";
5
- import { spawnSync } from 'node:child_process';
6
- import { PROTOCOL } from '@lapxo/topos/wire';
7
- /** Operational process failure, distinct from a valid contract refusal or abstention. */
8
- export class CapsuleProcessError extends Error {
9
- constructor(reason, result) {
10
- const stdout = result.stdout ?? '';
11
- const stderr = result.stderr ?? '';
12
- super(`REFUSE·capsule process ${reason}\n${stderr}${stdout}`);
13
- this.name = 'CapsuleProcessError';
14
- this.stdout = stdout;
15
- this.stderr = stderr;
16
- this.status = result.status;
17
- this.signal = result.signal;
18
- this.cause = result.error;
19
- }
20
- }
21
- export function validResponse(value, request) {
22
- if (value === null || typeof value !== 'object' || Array.isArray(value))
23
- return false;
24
- const one = value;
25
- if (one['protocol'] !== PROTOCOL)
26
- return false;
27
- if (one['kind'] === 'refuse' || one['kind'] === 'abstain')
28
- return typeof one['why'] === 'string';
29
- if (one['kind'] !== 'fact')
30
- return false;
31
- if (request.verb === 'render')
32
- return Array.isArray(one['lines']) && one['lines'].every((line) => typeof line === 'string');
33
- if (request.verb === 'read')
34
- return Array.isArray(one['claims']);
35
- return true;
36
- }
37
- /** Last-line JSON is the wire framing. No partial batch, failed exit or synthetic missing response is accepted. */
38
- export function executeCapsule(command, args, requests, limits = {}, lifetime) {
39
- return actCosts.measure(() => {
40
- const cwd = limits.cwd;
41
- const directory = cwd === undefined ? undefined : typeof cwd === 'string' ? cwd : fileURLToPath(cwd);
42
- const run = lifetime === undefined ? spawnSync(command, args, { input: JSON.stringify(requests), encoding: 'utf8', maxBuffer: 1 << 26, ...limits }) : boundedProcess(command, args, JSON.stringify(requests), lifetime, directory, limits.env);
43
- if ('error' in run && run.error)
44
- throw new CapsuleProcessError(`failed: ${run.error.message}`, run);
45
- if (run.signal !== null || run.status !== 0)
46
- throw new CapsuleProcessError(`exited ${run.status ?? `with signal ${run.signal}`}`, run);
47
- const last = /(?:^|\n)([^\n]*)$/.exec(run.stdout.trimEnd())?.[1] ?? '';
48
- let values;
49
- try {
50
- values = JSON.parse(last);
51
- }
52
- catch (error) {
53
- throw new CapsuleProcessError('returned malformed or absent JSON', { ...run, error });
54
- }
55
- if (!Array.isArray(values) || values.length !== requests.length || !values.every((value, i) => validResponse(value, requests[i]))) {
56
- throw new CapsuleProcessError(`returned an invalid batch; expected ${requests.length} responses`, run);
57
- }
58
- if (run.stderr)
59
- hostOutput('error', run.stderr);
60
- return values;
61
- });
62
- }
1
+ var y=Object.defineProperty;var f=(e,n)=>y(e,"name",{value:n,configurable:!0});import{hostOutput as h}from"./call-context.js";import{actCosts as m}from"./act-cost.js";import{fileURLToPath as g}from"node:url";import{boundedProcess as w}from"./process-lifetime.js";import{spawnSync as O}from"node:child_process";import{library14_PROTOCOL as x}from"../vendor/runtime.js";class d extends Error{static{f(this,"CapsuleProcessError")}constructor(n,r){const s=r.stdout??"",o=r.stderr??"";super(`REFUSE\xB7capsule process ${n}
2
+ ${o}${s}`),this.name="CapsuleProcessError",this.stdout=s,this.stderr=o,this.status=r.status,this.signal=r.signal,this.cause=r.error}}function b(e,n){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const r=e;return r.protocol!==x?!1:r.kind==="refuse"||r.kind==="abstain"?typeof r.why=="string":r.kind!=="fact"?!1:n.verb==="render"?Array.isArray(r.lines)&&r.lines.every(s=>typeof s=="string"):n.verb==="read"?Array.isArray(r.claims):!0}f(b,"validResponse");function R(e,n,r,s={},o){return m.measure(()=>{const a=s.cwd,u=a===void 0?void 0:typeof a=="string"?a:g(a),t=o===void 0?O(e,n,{input:JSON.stringify(r),encoding:"utf8",maxBuffer:1<<26,...s}):w(e,n,JSON.stringify(r),o,u,s.env);if("error"in t&&t.error)throw new d(`failed: ${t.error.message}`,t);if(t.signal!==null||t.status!==0)throw new d(`exited ${t.status??`with signal ${t.signal}`}`,t);const p=/(?:^|\n)([^\n]*)$/.exec(t.stdout.trimEnd())?.[1]??"";let i;try{i=JSON.parse(p)}catch(c){throw new d("returned malformed or absent JSON",{...t,error:c})}if(!Array.isArray(i)||i.length!==r.length||!i.every((c,l)=>b(c,r[l])))throw new d(`returned an invalid batch; expected ${r.length} responses`,t);return t.stderr&&h("error",t.stderr),i})}f(R,"executeCapsule");export{d as CapsuleProcessError,R as executeCapsule,b as validResponse};
@@ -1,171 +1,9 @@
1
- import { hostOutput } from "./call-context.js";
2
- import { readerLifetime, parse } from '@lapxo/topos/wire';
3
- import { contentStore, verifiedContent, contentPolicy } from "./content-store.js";
4
- import { readOnly } from "./read-only.js";
5
- import { readingBoundary } from "./reading-context.js";
6
- import { nativeReaderRoute } from "./native-reader-context.js";
7
- import { assertNativeRouteCurrent, invokeNativeRoute, materializeNativeRoute } from "./native/route.js";
8
- import { sha } from "./hash.js";
9
- import { wireLinesOf as linesOf } from "../fold/claims.js";
10
- import { createHash } from 'node:crypto';
11
- import { mkdtempSync, rmSync, statSync } from 'node:fs';
12
- import { tmpdir } from 'node:os';
13
- import { basename, join, resolve, relative, isAbsolute, sep } from 'node:path';
14
- import { CAPSULE } from '@lapxo/topos/wire';
15
- import { declarationOf } from '@lapxo/topos/capsule';
16
- import { unpack } from "./archive.js";
17
- import { executeCapsule, validResponse } from "./capsule-process.js";
18
- import { holdStore, replaceWhole, storeAt } from "../land/ledger.js";
19
- import { coordinatesUnder, observeFile, observeText } from "../observe/files.js";
20
- import { hostOf } from "../observe/run.js";
21
- import { ownLock, ownRoot, ownStore, processOf } from "../observe/runner.js";
22
- import { said } from "../fold/wire.js";
23
- const declared = new Map();
24
- const laid = new Map();
25
- const releaseLaid = () => { for (const at of laid.values())
26
- rmSync(at, { recursive: true, force: true }); };
27
- /** A blob is unpacked once in a process, where every run of it the process asks for reads it. */
28
- function unpacked(digest, bytes) {
29
- const held = laid.get(digest);
30
- if (held !== undefined)
31
- return held;
32
- const at = mkdtempSync(join(tmpdir(), `${basename(ownRoot())}-capsule-`));
33
- try {
34
- unpack(bytes, at);
35
- }
36
- catch (error) {
37
- rmSync(at, { recursive: true, force: true });
38
- throw error;
39
- }
40
- laid.set(digest, at);
41
- if (!process.listeners('exit').includes(releaseLaid))
42
- process.once('exit', releaseLaid);
43
- return at;
44
- }
45
- /**
46
- * A capsule is the bytes a digest names in the instrument's own store, and only when they hash to it: its own lock is
47
- * read from them, and the coordinate a lock names runs as a process of its own, like a reader. Each answer is kept by the
48
- * digest of its complete declared request and implementation; distinct views retain distinct answers, and the same
49
- * request reads its verified answer without running again. Operational failures never enter the cache; refusals and abstentions are asked again.
50
- */
51
- const capsules = new Map();
52
- /** A blob is loaded once in an act. A later ask for the same digest reads that capsule, and does not hash or unpack it again. */
53
- export function capsuleAt(digest, entry, store) {
54
- const cacheStore = store ?? contentStore();
55
- const { bytes } = verifiedContent(digest, cacheStore);
56
- const identity = `${cacheStore}\0${digest}\0${entry}`;
57
- const held = capsules.get(identity);
58
- if (held !== undefined)
59
- return held;
60
- const known = declared.get(digest) ?? ((lines) => ({ lines, declaration: declarationOf(lines) }))(linesOf(observeText(join(unpacked(digest, bytes), CAPSULE))));
61
- declared.set(digest, known);
62
- const names = Object.keys(known.declaration.regions);
63
- const root = unpacked(digest, bytes);
64
- const module = resolve(root, entry);
65
- const coordinate = relative(root, module);
66
- if (!entry || isAbsolute(entry) || (coordinate === '..' || coordinate.startsWith(`..${sep}`)) || entry.split(/[\\/]/).includes('..')) {
67
- throw new Error(`REFUSE·capsule ${digest} declared entry ${entry || '(absent)'} unavailable`);
68
- }
69
- const capsule = { digest, ...known, ask: (requests, reader) => {
70
- if (!statSync(module, { throwIfNoEntry: false })?.isFile())
71
- throw new Error(`REFUSE·capsule ${digest} declared entry ${entry} unavailable`);
72
- return answered(digest, bytes, requests, names, root, cacheStore, module, reader);
73
- } };
74
- capsules.set(identity, capsule);
75
- return capsule;
76
- }
77
- const layoutsOf = () => said(ownLock(), 'release/layout')
78
- .map((token) => token.split(':')).filter((pair) => pair.length === 2 && pair[0] !== undefined && pair[1] !== undefined);
79
- const oneModule = (at) => {
80
- const files = coordinatesUnder(at, at).filter((one) => one.endsWith('.js'));
81
- return files.length === 1 ? files[0] : undefined;
82
- };
83
- const split = new Map();
84
- const spawnOf = (at, names) => {
85
- const held = split.get(at);
86
- if (held !== undefined)
87
- return held;
88
- const layout = names.length === 0 ? undefined : layoutsOf().find(([dir, ext]) => names.some((name) => observeText(join(at, dir, `${name}${ext}`)) !== undefined));
89
- const child = layout !== undefined ? [processOf('located', 'host'), at, layout[0], layout[1]]
90
- : ((file) => (file === undefined ? [] : [processOf('located', 'host'), at, file, 'render']))(oneModule(at));
91
- split.set(at, child);
92
- return child;
93
- };
94
- export const childFlags = (argv = process.execArgv) => argv.filter((flag, i) => !/^(-e|-p|--eval|--print)$/.test(argv[i - 1] ?? '') && !/^(-e|-p|--eval|--print|--input-type)(=|$)/.test(flag));
95
- function answered(digest, bytes, requests, names, tree, cacheStore = ownStore(), entry, reader) {
96
- const boundary = readingBoundary();
97
- const native = nativeReaderRoute();
98
- if (native) {
99
- if (!boundary?.execution || digest !== native.profile.selection.archive)
100
- throw Error('REFUSE·native reader lacks its complete implementation identity');
101
- assertNativeRouteCurrent(native);
102
- }
103
- const child = entry === undefined ? spawnOf(tree ?? unpacked(digest, bytes), names) : [entry];
104
- if (!child.length) {
105
- hostOutput('error', `LOAD regions · none of ${names.length} under the directories release/layout names\n`);
106
- return requests.map(() => undefined);
107
- }
108
- const loader = entry !== undefined ? `${createHash('sha256').update(`${relative(tree, entry)}\n`).digest('hex')}\n` : child.length > 1 ? `${createHash('sha256').update(observeFile(child[0]) ?? new Uint8Array()).digest('hex')}\n` : '';
109
- const lifetime = readerLifetime(contentPolicy().flatMap(line => { const p = parse(line); return p.kind === 'fact' ? [p.value.fields] : []; }), reader ?? digest);
110
- const policy = lifetime === undefined ? '' : JSON.stringify(lifetime) + '\n';
111
- const hitOf = (request) => sha(`${digest}\n${loader}${policy}${boundary === undefined ? '' : boundary.identity + '\n'}${JSON.stringify(request)}`);
112
- const hits = requests.map(hitOf);
113
- const kept = hits.map(hit => storeAt(cacheStore, 'cas', 'answers', hit));
114
- const held = kept.map((at, i) => {
115
- const text = observeText(at);
116
- if (text === undefined)
117
- return undefined;
118
- try {
119
- const got = JSON.parse(text);
120
- return got.format === 'capsule-answer/2' && got.hit === hits[i] && validResponse(got.said, requests[i]) && got.said.kind === 'fact' ? got.said : undefined;
121
- }
122
- catch (error) {
123
- throw new Error(`${at}: ${error instanceof Error ? error.message : String(error)}`);
124
- }
125
- });
126
- const missing = requests.filter((_, i) => held[i] === undefined);
127
- if (missing.length && readOnly())
128
- throw Error(`REFUSE·preview capsule ${digest} has no verified answer for the proposed inputs; fold the declared inputs first`);
129
- if (missing.length)
130
- hostOutput('error', `CAPSULE ${digest.slice(7, 19)} · ${requests.length} asked · ${missing.length} run · ${missing.map((one) => `${one.rootScope}${one.region}`).join(' ')}\n`);
131
- // Execute and validate the entire batch before committing any answer to the cache.
132
- if (native && !lifetime)
133
- throw Error('REFUSE·native reader missing declared lifetime');
134
- const ran = !missing.length ? [] : native
135
- ? invokeNativeRoute(native, { ...materializeNativeRoute(native), requests: missing, execution: boundary.execution, limits: lifetime })
136
- : executeCapsule(process.execPath, [...childFlags(boundary?.execution?.flags), hostOf(), ...child], missing, boundary?.execution ? { env: boundary.execution.env, cwd: boundary.execution.cwd } : {}, lifetime);
137
- return requests.map((request, i) => {
138
- if (held[i] !== undefined)
139
- return held[i];
140
- const said = ran[missing.indexOf(request)];
141
- if (said?.kind === 'fact') {
142
- const text = JSON.stringify({ format: 'capsule-answer/2', hit: hits[i], said });
143
- replaceWhole(kept[i], text);
144
- holdStore(cacheStore, 'answers', hits[i], Buffer.byteLength(text));
145
- }
146
- return said;
147
- });
148
- }
149
- /** The host may supply its cache store independently of the located executable. */
150
- export function locatedAt(tree, place, cacheStore = ownStore()) {
151
- const at = join(tree, place);
152
- const lines = linesOf(observeText(join(at, CAPSULE)));
153
- if (!lines.length)
154
- return undefined;
155
- const known = { lines, declaration: declarationOf(lines) };
156
- const names = Object.keys(known.declaration.regions);
157
- if (!spawnOf(at, names).length)
158
- return undefined;
159
- const hash = createHash('sha256');
160
- hash.update(observeFile(join(at, CAPSULE)) ?? new Uint8Array());
161
- for (const name of names)
162
- for (const [dir, ext] of layoutsOf()) {
163
- const bytes = observeFile(join(at, dir, `${name}${ext}`));
164
- if (bytes !== undefined) {
165
- hash.update(bytes);
166
- break;
167
- }
168
- }
169
- const digest = `sha256:${hash.digest('hex')}`;
170
- return { digest, ...known, ask: (requests, reader) => answered(digest, new Uint8Array(), requests, names, at, cacheStore, undefined, reader) };
171
- }
1
+ var G=Object.defineProperty;var l=(e,n)=>G(e,"name",{value:n,configurable:!0});import{hostOutput as F}from"./call-context.js";import{library14_readerLifetime as K,library14_parse as Q}from"../vendor/runtime.js";import{contentStore as V,verifiedContent as X,contentPolicy as Y}from"./content-store.js";import{readOnly as Z}from"./read-only.js";import{readingBoundary as q}from"./reading-context.js";import{nativeReaderRoute as ee}from"./native-reader-context.js";import{assertNativeRouteCurrent as ne,invokeNativeRoute as te,materializeNativeRoute as re}from"./native/route.js";import{sha as oe}from"./hash.js";import{wireLinesOf as N}from"../fold/claims.js";import{createHash as b}from"node:crypto";import{mkdtempSync as ie,rmSync as C,statSync as se}from"node:fs";import{tmpdir as ae}from"node:os";import{basename as ce,join as $,resolve as de,relative as M,isAbsolute as fe,sep as le}from"node:path";import{library14_CAPSULE as k}from"../vendor/runtime.js";import{library4_declarationOf as j}from"../vendor/runtime.js";import{unpack as ue}from"./archive.js";import{executeCapsule as pe,validResponse as me}from"./capsule-process.js";import{holdStore as he,replaceWhole as we,storeAt as $e}from"../land/ledger.js";import{coordinatesUnder as ve,observeFile as A,observeText as E}from"../observe/files.js";import{hostOf as ye}from"../observe/run.js";import{ownLock as xe,ownRoot as ge,ownStore as P,processOf as _}from"../observe/runner.js";import{said as Ee}from"../fold/wire.js";const J=new Map,R=new Map,W=l(()=>{for(const e of R.values())C(e,{recursive:!0,force:!0})},"releaseLaid");function U(e,n){const r=R.get(e);if(r!==void 0)return r;const t=ie($(ae(),`${ce(ge())}-capsule-`));try{ue(n,t)}catch(o){throw C(t,{recursive:!0,force:!0}),o}return R.set(e,t),process.listeners("exit").includes(W)||process.once("exit",W),t}l(U,"unpacked");const B=new Map;function Qe(e,n,r){const t=r??V(),{bytes:o}=X(e,t),a=`${t}\0${e}\0${n}`,c=B.get(a);if(c!==void 0)return c;const m=J.get(e)??(y=>({lines:y,declaration:j(y)}))(N(E($(U(e,o),k))));J.set(e,m);const d=Object.keys(m.declaration.regions),i=U(e,o),u=de(i,n),v=M(i,u);if(!n||fe(n)||v===".."||v.startsWith(`..${le}`)||n.split(/[\\/]/).includes(".."))throw new Error(`REFUSE\xB7capsule ${e} declared entry ${n||"(absent)"} unavailable`);const h={digest:e,...m,ask:l((y,S)=>{if(!se(u,{throwIfNoEntry:!1})?.isFile())throw new Error(`REFUSE\xB7capsule ${e} declared entry ${n} unavailable`);return I(e,o,y,d,i,t,u,S)},"ask")};return B.set(a,h),h}l(Qe,"capsuleAt");const z=l(()=>Ee(xe(),"release/layout").map(e=>e.split(":")).filter(e=>e.length===2&&e[0]!==void 0&&e[1]!==void 0),"layoutsOf"),Se=l(e=>{const n=ve(e,e).filter(r=>r.endsWith(".js"));return n.length===1?n[0]:void 0},"oneModule"),D=new Map,H=l((e,n)=>{const r=D.get(e);if(r!==void 0)return r;const t=n.length===0?void 0:z().find(([a,c])=>n.some(m=>E($(e,a,`${m}${c}`))!==void 0)),o=t!==void 0?[_("located","host"),e,t[0],t[1]]:(a=>a===void 0?[]:[_("located","host"),e,a,"render"])(Se(e));return D.set(e,o),o},"spawnOf"),Oe=l((e=process.execArgv)=>e.filter((n,r)=>!/^(-e|-p|--eval|--print)$/.test(e[r-1]??"")&&!/^(-e|-p|--eval|--print|--input-type)(=|$)/.test(n)),"childFlags");function I(e,n,r,t,o,a=P(),c,m){const d=q(),i=ee();if(i){if(!d?.execution||e!==i.profile.selection.archive)throw Error("REFUSE\xB7native reader lacks its complete implementation identity");ne(i)}const u=c===void 0?H(o??U(e,n),t):[c];if(!u.length)return F("error",`LOAD regions \xB7 none of ${t.length} under the directories release/layout names
2
+ `),r.map(()=>{});const v=c!==void 0?`${b("sha256").update(`${M(o,c)}
3
+ `).digest("hex")}
4
+ `:u.length>1?`${b("sha256").update(A(u[0])??new Uint8Array).digest("hex")}
5
+ `:"",h=K(Y().flatMap(s=>{const f=Q(s);return f.kind==="fact"?[f.value.fields]:[]}),m??e),y=h===void 0?"":JSON.stringify(h)+`
6
+ `,S=l(s=>oe(`${e}
7
+ ${v}${y}${d===void 0?"":d.identity+`
8
+ `}${JSON.stringify(s)}`),"hitOf"),g=r.map(S),L=g.map(s=>$e(a,"cas","answers",s)),O=L.map((s,f)=>{const x=E(s);if(x!==void 0)try{const p=JSON.parse(x);return p.format==="capsule-answer/2"&&p.hit===g[f]&&me(p.said,r[f])&&p.said.kind==="fact"?p.said:void 0}catch(p){throw new Error(`${s}: ${p instanceof Error?p.message:String(p)}`)}}),w=r.filter((s,f)=>O[f]===void 0);if(w.length&&Z())throw Error(`REFUSE\xB7preview capsule ${e} has no verified answer for the proposed inputs; fold the declared inputs first`);if(w.length&&F("error",`CAPSULE ${e.slice(7,19)} \xB7 ${r.length} asked \xB7 ${w.length} run \xB7 ${w.map(s=>`${s.rootScope}${s.region}`).join(" ")}
9
+ `),i&&!h)throw Error("REFUSE\xB7native reader missing declared lifetime");const T=w.length?i?te(i,{...re(i),requests:w,execution:d.execution,limits:h}):pe(process.execPath,[...Oe(d?.execution?.flags),ye(),...u],w,d?.execution?{env:d.execution.env,cwd:d.execution.cwd}:{},h):[];return r.map((s,f)=>{if(O[f]!==void 0)return O[f];const x=T[w.indexOf(s)];if(x?.kind==="fact"){const p=JSON.stringify({format:"capsule-answer/2",hit:g[f],said:x});we(L[f],p),he(a,"answers",g[f],Buffer.byteLength(p))}return x})}l(I,"answered");function Ve(e,n,r=P()){const t=$(e,n),o=N(E($(t,k)));if(!o.length)return;const a={lines:o,declaration:j(o)},c=Object.keys(a.declaration.regions);if(!H(t,c).length)return;const m=b("sha256");m.update(A($(t,k))??new Uint8Array);for(const i of c)for(const[u,v]of z()){const h=A($(t,u,`${i}${v}`));if(h!==void 0){m.update(h);break}}const d=`sha256:${m.digest("hex")}`;return{digest:d,...a,ask:l((i,u)=>I(d,new Uint8Array,i,c,t,r,void 0,u),"ask")}}l(Ve,"locatedAt");export{Qe as capsuleAt,Oe as childFlags,Ve as locatedAt};
@@ -1,128 +1,12 @@
1
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
2
- import { join, dirname } from 'node:path';
3
- import { performance } from 'node:perf_hooks';
4
- import { fileURLToPath } from 'node:url';
5
- import { canonical, objectHistory, parse, byBytes, wireAt, RECEIPTS } from '@lapxo/topos/wire';
6
- import { cellInputs, cellReceiptContract, cellInputProfile } from '@lapxo/topos/cell-inputs';
7
- import { renderCells } from '@lapxo/topos/cells-view';
8
- import { admittedObjects } from "./objects.js";
9
- import { objectFold } from "../engine/index.js";
10
- import { fullDigest, bytesDigest } from "./digest.js";
11
- import { closeReceipts, noteIdle } from "../fold/closed.js";
12
- import { authorityFor, rootSigner } from "../fold/signers.js";
13
- import { signaturesOf } from "../fold/digests.js";
14
- import { storeOf } from "../land/ledger.js";
15
- import { ownLock } from "../observe/runner.js";
16
- import { toposAt } from "./selected-topos.js";
17
- const fields = (line) => { const p = parse(line); return p.kind === 'fact' ? p.value.fields : {}; };
18
- /** Only Topos input/render entry bytes enter region identity; host locations do not. */
19
- function implementation(algorithm) {
20
- return ['@lapxo/topos/cell-inputs', '@lapxo/topos/cells-view'].map(member => bytesDigest(readFileSync(fileURLToPath(import.meta.resolve(member))), algorithm)).sort(byBytes);
21
- }
22
- /** Native count/bytes receipt lines; carried render blobs are separate verified cache payloads. */
23
- export async function cellsWithReceipts(root, history, emit) {
24
- const started = performance.now(), store = storeOf(root), parsed = objectHistory(history);
25
- if (parsed.kind !== 'fact')
26
- throw Error(`REFUSE·wire ${parsed.why}`);
27
- const authority = authorityFor(history, rootSigner(root), signaturesOf(store).admitted);
28
- for (const record of parsed.value.objects)
29
- if (authority.of(canonical(record.fields)).kind !== 'admitted')
30
- throw Error(`REFUSE·authority receipt input ${record.fields.id}`);
31
- const config = parsed.value.configuration.filter(f => authority.of(canonical(f)).kind === 'admitted');
32
- cellReceiptContract(config);
33
- const profile = cellInputProfile(config);
34
- const instrument = ownLock().map(fields);
35
- const wire = wireAt(instrument, Number.MAX_SAFE_INTEGER);
36
- if (!wire)
37
- throw Error('REFUSE·receipt no admitted digest algorithm');
38
- const algorithm = [...wire.digests][0];
39
- if (!algorithm)
40
- throw Error('REFUSE·receipt no digest algorithm');
41
- const code = implementation(algorithm);
42
- const inputs = cellInputs(parsed.value.objects, profile), semantic = new Map(), inputBytes = new Map();
43
- const pins = new Map();
44
- for (const record of parsed.value.objects.filter(r => r.record === 'cell')) {
45
- const pin = record.fields.topos;
46
- if (!pins.has(pin)) {
47
- const top = toposAt(pin, store);
48
- pins.set(pin, [pin, ...top.dependencies]);
49
- }
50
- const scope = `receipts/cells/${record.fields.scope}`;
51
- const ownInputs = inputs.get(record.fields.scope);
52
- const metadata = [...pins.get(pin), ...code, 'resolution=1'];
53
- const bytes = profile === 'semantic-live@1' ? [...ownInputs, ...metadata].sort(byBytes).join('\n') :
54
- [...ownInputs, ...metadata.sort(byBytes), `receipt-inputs=${profile}`].join('\n');
55
- inputBytes.set(scope, bytes);
56
- semantic.set(scope, fullDigest(bytes, algorithm));
57
- }
58
- // The context stamp is a cache validity guard, not any cell's semantic receipt identity.
59
- const contextStamp = fullDigest([...history, ...code].sort(byBytes), algorithm);
60
- const at = join(root, RECEIPTS), raw = existsSync(at) ? readFileSync(at, 'utf8').split('\n').filter(Boolean) : [], native = raw.filter(l => parse(l).kind === 'fact');
61
- const headers = native.filter(l => fields(l).scope === 'receipts' && fields(l).measure === 'digest');
62
- const carried = (digest) => join(store, 'cas', 'carried', digest.slice(digest.indexOf(':') + 1));
63
- const readVerified = (digest) => {
64
- if (!digest.startsWith(algorithm + ':') || !/^[a-f0-9]+$/.test(digest.split(':')[1] ?? ''))
65
- return;
66
- const file = carried(digest);
67
- if (!existsSync(file))
68
- return;
69
- const bytes = readFileSync(file);
70
- const got = bytesDigest(bytes, algorithm);
71
- if (got !== digest) {
72
- emit(`RECEIPT invalid ${digest} · got ${got} · recompute`);
73
- return;
74
- }
75
- return bytes.toString('utf8');
76
- };
77
- const opened = new Set(await closeReceipts(root, store, semantic));
78
- const bodyLines = native.filter(l => fields(l).scope !== 'receipts').sort(byBytes).join('\n') + '\n';
79
- const intact = raw.length === native.length && headers.length === 1 && readVerified(fields(headers[0]).at.replace(/^place:/, '')) === bodyLines;
80
- if (!intact)
81
- for (const scope of semantic.keys())
82
- opened.add(scope);
83
- const cached = new Map();
84
- for (const [scope, digest] of semantic) {
85
- const bytes = native.filter(l => fields(l).scope === scope && fields(l).measure === 'bytes');
86
- const counts = native.filter(l => fields(l).scope === scope && fields(l).measure === 'count');
87
- if (bytes.length !== 1 || counts.length !== 1 || fields(bytes[0]).value !== digest || fields(counts[0]).value !== '1..1') {
88
- opened.add(scope);
89
- continue;
90
- }
91
- const output = readVerified(fields(counts[0]).at.replace(/^place:/, ''));
92
- if (output === undefined) {
93
- opened.add(scope);
94
- continue;
95
- }
96
- cached.set(scope, output);
97
- }
98
- const idle = headers.length === 1 && fields(headers[0]).value === contextStamp && readVerified(fields(headers[0]).at.replace(/^place:/, '')) !== undefined && opened.size === 0;
99
- let readings;
100
- if (!idle) {
101
- const held = await admittedObjects(root, history, emit);
102
- readings = objectFold(held.records, held.context);
103
- }
104
- const newLines = [], outputs = [];
105
- const save = (text) => { const digest = bytesDigest(Buffer.from(text), algorithm); const path = carried(digest); mkdirSync(dirname(path), { recursive: true }); if (!existsSync(path) || readFileSync(path, 'utf8') !== text)
106
- writeFileSync(path, text); return digest; };
107
- for (const [scope, digest] of semantic) {
108
- const cellName = scope.slice('receipts/cells/'.length);
109
- const output = (!opened.has(scope) && cached.has(scope)) ? cached.get(scope) : renderCells([readings.find(c => c.cell === cellName)]).join('\n') + '\n';
110
- outputs.push(output.trimEnd());
111
- const payload = save(output);
112
- if (save(inputBytes.get(scope)) !== digest)
113
- throw Error('REFUSE·receipt input closure hash mismatch');
114
- newLines.push(canonical({ scope, role: 'writes', form: 'interval', measure: 'count', value: '1..1', at: `place:${payload}`, by: 'bound' }), canonical({ scope, role: 'writes', form: 'alphabet', measure: 'bytes', value: digest, at: `place:${digest}`, by: 'bound' }));
115
- emit(`RECEIPT ${scope}@1 · ${digest} · ${opened.has(scope) ? 'opened' : 'same'}`);
116
- }
117
- const nativeBody = newLines.sort(byBytes).join('\n') + '\n', body = save(nativeBody);
118
- // One native header names carried count/bytes lines; at closes the exact carried bytes.
119
- const next = [canonical({ scope: 'receipts', role: 'writes', form: 'alphabet', measure: 'digest', value: contextStamp, at: `place:${body}`, by: 'bound' }), ...newLines.sort(byBytes)].join('\n') + '\n';
120
- if (!existsSync(at) || readFileSync(at, 'utf8') !== next)
121
- writeFileSync(at, next);
122
- if (idle)
123
- noteIdle();
124
- emit(`RECEIPTS ${semantic.size} read · ${opened.size} opened · ${idle ? 'idle' : 'context checked'} · provider ${idle ? 0 : pins.size}`);
125
- for (const output of outputs)
126
- emit(output);
127
- emit(`COST cells@1 · ${(performance.now() - started).toFixed(3)} ms · admission/context/receipt/render included`);
128
- }
1
+ var ee=Object.defineProperty;var f=(n,i)=>ee(n,"name",{value:i,configurable:!0});import{readFileSync as w,writeFileSync as D,existsSync as R,mkdirSync as te}from"node:fs";import{join as H,dirname as oe}from"node:path";import{performance as W}from"node:perf_hooks";import{fileURLToPath as re}from"node:url";import{library14_canonical as g,library14_objectHistory as se,library14_parse as G,library14_byBytes as d,library14_wireAt as ne,library14_RECEIPTS as ie}from"../vendor/runtime.js";import{library11_cellInputs as ce,library11_cellReceiptContract as ae,library11_cellInputProfile as le}from"../vendor/runtime.js";import{library12_renderCells as pe}from"../vendor/runtime.js";import{admittedObjects as fe}from"./objects.js";import{objectFold as de}from"../engine/index.js";import{fullDigest as V,bytesDigest as k}from"./digest.js";import{closeReceipts as ue,noteIdle as me}from"../fold/closed.js";import{authorityFor as ye,rootSigner as be}from"../fold/signers.js";import{signaturesOf as he}from"../fold/digests.js";import{storeOf as Ee}from"../land/ledger.js";import{ownLock as we}from"../observe/runner.js";import{toposAt as ge}from"./selected-topos.js";const r=f(n=>{const i=G(n);return i.kind==="fact"?i.value.fields:{}},"fields");function ve(n){return["@lapxo/topos/cell-inputs","@lapxo/topos/cells-view"].map(i=>k(w(re(import.meta.resolve(i))),n)).sort(d)}f(ve,"implementation");async function Le(n,i,u){const X=W.now(),v=Ee(n),m=se(i);if(m.kind!=="fact")throw Error(`REFUSE\xB7wire ${m.why}`);const x=ye(i,be(n),he(v).admitted);for(const e of m.value.objects)if(x.of(g(e.fields)).kind!=="admitted")throw Error(`REFUSE\xB7authority receipt input ${e.fields.id}`);const P=m.value.configuration.filter(e=>x.of(g(e)).kind==="admitted");ae(P);const j=le(P),q=we().map(r),T=ne(q,Number.MAX_SAFE_INTEGER);if(!T)throw Error("REFUSE\xB7receipt no admitted digest algorithm");const a=[...T.digests][0];if(!a)throw Error("REFUSE\xB7receipt no digest algorithm");const B=ve(a),J=ce(m.value.objects,j),y=new Map,U=new Map,S=new Map;for(const e of m.value.objects.filter(t=>t.record==="cell")){const t=e.fields.topos;if(!S.has(t)){const Z=ge(t,v);S.set(t,[t,...Z.dependencies])}const o=`receipts/cells/${e.fields.scope}`,s=J.get(e.fields.scope),p=[...S.get(t),...B,"resolution=1"],c=j==="semantic-live@1"?[...s,...p].sort(d).join(`
2
+ `):[...s,...p.sort(d),`receipt-inputs=${j}`].join(`
3
+ `);U.set(o,c),y.set(o,V(c,a))}const A=V([...i,...B].sort(d),a),b=H(n,ie),M=R(b)?w(b,"utf8").split(`
4
+ `).filter(Boolean):[],h=M.filter(e=>G(e).kind==="fact"),E=h.filter(e=>r(e).scope==="receipts"&&r(e).measure==="digest"),O=f(e=>H(v,"cas","carried",e.slice(e.indexOf(":")+1)),"carried"),I=f(e=>{if(!e.startsWith(a+":")||!/^[a-f0-9]+$/.test(e.split(":")[1]??""))return;const t=O(e);if(!R(t))return;const o=w(t),s=k(o,a);if(s!==e){u(`RECEIPT invalid ${e} \xB7 got ${s} \xB7 recompute`);return}return o.toString("utf8")},"readVerified"),l=new Set(await ue(n,v,y)),K=h.filter(e=>r(e).scope!=="receipts").sort(d).join(`
5
+ `)+`
6
+ `;if(!(M.length===h.length&&E.length===1&&I(r(E[0]).at.replace(/^place:/,""))===K))for(const e of y.keys())l.add(e);const _=new Map;for(const[e,t]of y){const o=h.filter(c=>r(c).scope===e&&r(c).measure==="bytes"),s=h.filter(c=>r(c).scope===e&&r(c).measure==="count");if(o.length!==1||s.length!==1||r(o[0]).value!==t||r(s[0]).value!=="1..1"){l.add(e);continue}const p=I(r(s[0]).at.replace(/^place:/,""));if(p===void 0){l.add(e);continue}_.set(e,p)}const $=E.length===1&&r(E[0]).value===A&&I(r(E[0]).at.replace(/^place:/,""))!==void 0&&l.size===0;let z;if(!$){const e=await fe(n,i,u);z=de(e.records,e.context)}const F=[],L=[],C=f(e=>{const t=k(Buffer.from(e),a),o=O(t);return te(oe(o),{recursive:!0}),(!R(o)||w(o,"utf8")!==e)&&D(o,e),t},"save");for(const[e,t]of y){const o=e.slice(15),s=!l.has(e)&&_.has(e)?_.get(e):pe([z.find(c=>c.cell===o)]).join(`
7
+ `)+`
8
+ `;L.push(s.trimEnd());const p=C(s);if(C(U.get(e))!==t)throw Error("REFUSE\xB7receipt input closure hash mismatch");F.push(g({scope:e,role:"writes",form:"interval",measure:"count",value:"1..1",at:`place:${p}`,by:"bound"}),g({scope:e,role:"writes",form:"alphabet",measure:"bytes",value:t,at:`place:${t}`,by:"bound"})),u(`RECEIPT ${e}@1 \xB7 ${t} \xB7 ${l.has(e)?"opened":"same"}`)}const Q=F.sort(d).join(`
9
+ `)+`
10
+ `,Y=C(Q),N=[g({scope:"receipts",role:"writes",form:"alphabet",measure:"digest",value:A,at:`place:${Y}`,by:"bound"}),...F.sort(d)].join(`
11
+ `)+`
12
+ `;(!R(b)||w(b,"utf8")!==N)&&D(b,N),$&&me(),u(`RECEIPTS ${y.size} read \xB7 ${l.size} opened \xB7 ${$?"idle":"context checked"} \xB7 provider ${$?0:S.size}`);for(const e of L)u(e);u(`COST cells@1 \xB7 ${(W.now()-X).toFixed(3)} ms \xB7 admission/context/receipt/render included`)}f(Le,"cellsWithReceipts");export{Le as cellsWithReceipts};
@@ -0,0 +1,4 @@
1
+ var I=Object.defineProperty;var s=(m,d)=>I(m,"name",{value:d,configurable:!0});import{withActCosts as H}from"./act-cost.js";import{mkdtempSync as O,writeFileSync as P,rmSync as N,realpathSync as w}from"node:fs";import{join as x}from"node:path";import{nativeHostInstrument as T}from"./native-receiver.js";import{withHostCall as z}from"./call-context.js";import{withActHost as G,underTheLock as J}from"../land/act.js";import{storeOf as M}from"../land/ledger.js";import{withNativeSigning as Z}from"./signing.js";import{BoundRefusal as c,refusalRecord as W}from"./refusals.js";import{readFileSync as _}from"node:fs";import{sha256 as $}from"./hash.js";import{nativePlaceState as D}from"./native-place-state.js";function dt(m){let d,o,E=!1,a;const h=s(t=>{process.connected&&process.send(t)},"send"),f=s(()=>{E=!0,o?.abort.abort(),a?.reject(new c("host/cancelled","REFUSE\xB7host/cancelled")),o||(d&&N(d.scratch,{recursive:!0,force:!0}),process.removeListener("message",v),process.connected&&process.disconnect())},"stop"),v=s(t=>{if(t?.kind==="configure"&&!d){d={place:w(t.place),scratch:w(t.scratch),limits:t.limits,instrumentName:t.instrumentName,instrumentRoot:w(t.instrumentRoot),instrumentEntry:w(process.argv[1])},h({kind:"ready",pid:process.pid});return}if(t?.kind==="close"){f();return}if(t?.kind==="cancel"&&o&&o.id===t.id){o.abort.abort(),a?.reject(new c("host/cancelled","REFUSE\xB7host/cancelled"));return}if(t?.kind==="signed"&&o?.id===t.id&&a){const u=a;if(a=void 0,t.error){const l=["host/signer-mismatch","host/unbound-signer"].includes(t.error.code)?t.error.code:"host-port/failed";u.reject(new c(l,"REFUSE\xB7"+l))}else u.resolve(t.records);return}if(t?.kind!=="request"||!d||E)return;if(o){h({kind:"result",id:t.id,status:1,stdout:"",stderr:`REFUSE\xB7host/busy
2
+ `});return}const n=d,S=new AbortController,g=t.id,A=s(async()=>{let u,l="",p="",F=0,k=1;const U=s((e,i)=>{if(F+=Buffer.byteLength(i),F>n.limits.responseBytes)throw new c("host/budget","REFUSE\xB7host/budget");e==="out"?l+=i:p+=i},"output");try{const e=t.command;if(Buffer.byteLength(JSON.stringify(e))>n.limits.requestBytes||!["fold","sign","land"].includes(e.verb)||!Array.isArray(e.args)||e.args.some(r=>typeof r!="string"))throw new c("host/context","REFUSE\xB7host/context");const i=D(n.place);if(i==="birth"&&e.verb!=="land")throw new c("host/foundation-required","REFUSE\xB7host/foundation-required");u=O(x(n.scratch,"request-"));const b=new Map;for(const r of e.inputs??[]){if(!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(r.name)||b.has(r.name)||typeof r.text!="string")throw new c("host/context","REFUSE\xB7host/context");const y=x(u,r.name);P(y,r.text,{mode:384,flag:"wx"}),b.set(r.name,y)}const B=e.args.map(r=>r.startsWith("@input/")?b.get(r.slice(7))??(()=>{throw new c("host/context","REFUSE\xB7host/context")})():r),R=[e.verb,n.place,...B],L=t.signer?{...t.signer,signal:S.signal,sign:s(async r=>new Promise((y,C)=>{a={resolve:y,reject:C},h({kind:"sign",id:g,lot:r})}),"sign")}:void 0,j=T(n.instrumentRoot,n.instrumentEntry).runtime;k=await z({instrumentName:n.instrumentName,runtime:j,freshBytes:!0,arguments:R,output:U},()=>G({name:n.instrumentName,report:s(r=>U("error",r),"report"),signal:S.signal},()=>Z(L,()=>e.verb==="land"&&i==="admitted"?J(M(n.place),"host land",()=>m(R)):m(R))))}catch(e){if(p+=(e instanceof Error?e.message:"REFUSE\xB7host/failed")+`
3
+ `,e instanceof c){let i="";try{i=_(new URL("../../docs/contracts/refusals.bound",import.meta.url),"utf8")}catch{}p+=JSON.stringify(W(e,i,$))+`
4
+ `}}finally{a=void 0,u&&N(u,{recursive:!0,force:!0})}h({kind:"result",id:g,status:k,stdout:l,stderr:p})},"run"),q=Promise.resolve().then(()=>H(A)).finally(()=>{o=void 0,E&&f()});o={id:g,abort:S,done:q}},"receive");process.on("message",v),process.once("disconnect",f),process.once("SIGTERM",f),process.once("SIGINT",f)}s(dt,"serveNativeCommands");export{dt as serveNativeCommands};
@@ -1,5 +1 @@
1
- import { BoundRefusal } from "./refusals.js";
2
- /** Visibility may precede a failed publication response; never asserts rollback. */
3
- export class ActCommitUnknown extends BoundRefusal {
4
- constructor(identity, cause) { super('host/commit-unknown', `REFUSE·act publication uncertain · ${cause instanceof Error ? cause.message : 'storage failure'}`); this.identity = identity; }
5
- }
1
+ var e=Object.defineProperty;var r=(n,t)=>e(n,"name",{value:t,configurable:!0});import{BoundRefusal as i}from"./refusals.js";class c extends i{static{r(this,"ActCommitUnknown")}constructor(t,o){super("host/commit-unknown",`REFUSE\xB7act publication uncertain \xB7 ${o instanceof Error?o.message:"storage failure"}`),this.identity=t}}export{c as ActCommitUnknown};
@@ -1,8 +1 @@
1
- /** The synchronous host names unavailable content; the enclosing fold resolves exactly that request. */
2
- export class ContentNeeded extends Error {
3
- constructor(digest, why = `REFUSE·pin ${digest} content unavailable · not laid`) {
4
- super(why);
5
- this.digest = digest;
6
- this.name = 'ContentNeeded';
7
- }
8
- }
1
+ var r=Object.defineProperty;var n=(t,e)=>r(t,"name",{value:e,configurable:!0});class a extends Error{static{n(this,"ContentNeeded")}constructor(e,o=`REFUSE\xB7pin ${e} content unavailable \xB7 not laid`){super(o),this.digest=e,this.name="ContentNeeded"}}export{a as ContentNeeded};