@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
package/dist/host/walk.js CHANGED
@@ -1,193 +1,20 @@
1
- import { walkProjection, walkAt, walkSnapshot, walkHeaders, readWalkHeaders, readForeignWalk, walkAuthority, walkOrigin, walkInventory, walkSelection, isWalkHeader } from '@lapxo/topos/walk';
2
- import { canonical, parse, fromLine, wireAt, matches, objectHistory, validateObjectContext } from '@lapxo/topos/wire';
3
- import { objectProvider } from '@lapxo/topos/object-provider';
4
- import { standingBytes } from '@lapxo/topos/standing';
5
- import { fieldOf } from "../fold/claims.js";
6
- import { lockStanding, lockLines } from "../fold/keys.js";
7
- import { authorityFor, rootSigner } from "../fold/signers.js";
8
- import { publicKeyOf } from "../fold/signers.js";
9
- import { signaturesOf } from "../fold/digests.js";
10
- import { fullDigest } from "./digest.js";
11
- import { toposAt, contextModuleAt } from "./selected-topos.js";
12
- import { signerFor } from "./signing.js";
13
- import { signConsentLot, verifiesFields } from "../land/sign.js";
14
- import { storeOf } from "../land/ledger.js";
15
- import { signedOwnerLines, epochOf, localActLines, ownerOf } from "../cli/owner.js";
16
- import { commitIngress, ingressBundles, ingressCost } from "./ports/ingress.js";
17
- const refuse = (why) => { throw Error('REFUSE·walk ' + why); };
18
- const fields = (line) => { const p = parse(line); if (p.kind !== 'fact')
19
- return refuse('not a wire line'); return p.value.fields; };
20
- const one = (lines, scope, measure) => {
21
- const rows = lines.filter(line => fieldOf(line, 'scope') === scope && fieldOf(line, 'measure') === measure && fieldOf(line, 'value') !== 'withdraw');
22
- if (rows.length !== 1)
23
- return refuse('missing or conflicting ' + scope + ' ' + measure);
24
- return fieldOf(rows[0], 'value');
25
- };
26
- function policy(root) {
27
- const store = storeOf(root), standing = lockStanding(store), contract = walkSelection(standing);
28
- const view = one(standing, 'view/walk', 'id');
29
- if (view !== 'walk@*')
30
- refuse('view/walk must declare walk@*');
31
- const masks = standing.filter(line => fieldOf(line, 'scope') === 'view/walk').flatMap(line => fieldOf(line, 'needs').split('|')).filter(Boolean);
32
- if (!masks.length)
33
- refuse('view/walk has no declared history inputs');
34
- const wire = wireAt(standing.map(fields), Number.MAX_SAFE_INTEGER), algorithm = wire?.digests.values().next().value;
35
- if (!algorithm)
36
- refuse('no admitted digest algorithm');
37
- return { store, standing, contract, masks, digest: (bytes) => fullDigest(bytes, algorithm) };
38
- }
39
- function context(root, pin, own = false) {
40
- const p = policy(root);
41
- if (!own && !p.standing.some(line => fieldOf(line, 'scope').startsWith('uses/') && fieldOf(line, 'value') === pin))
42
- refuse('origin context is not selected by digest');
43
- const topos = toposAt(pin, p.store), authority = walkAuthority(topos.parts, verifiesFields);
44
- const configuration = topos.parts.map(f => canonical({ ...f, by: 'target', epoch: '0' }));
45
- return { pin, topos, authority, configuration, origin: walkOrigin(topos.parts), contract: walkSelection(topos.lines) };
46
- }
47
- function local(root) {
48
- const p = policy(root), authority = authorityFor(lockLines(p.store), rootSigner(root), signaturesOf(p.store).admitted);
49
- const history = signedOwnerLines(p.store).filter(line => p.masks.some(mask => matches(mask, fieldOf(line, 'scope'))));
50
- if (history.some(line => authority.of(line).kind !== 'admitted'))
51
- refuse('local history is not authenticated');
52
- const selected = context(root, one(p.standing, 'walk/context', 'digest'), true);
53
- return walkSnapshot(history, selected.contract.fields, p.digest, selected.origin, selected.contract.partition);
54
- }
55
- const headerInfo = (lines) => {
56
- const roots = lines.filter(line => isWalkHeader(line) && fieldOf(line, 'scope') === 'walk/root');
57
- if (roots.length !== 1)
58
- return refuse('one signed root is required');
59
- const at = fieldOf(roots[0], 'at');
60
- if (!at.startsWith('receipt:'))
61
- return refuse('root has no declared context');
62
- return { pin: at.slice(8), base: fieldOf(roots[0], 'condition') };
63
- };
64
- async function validateHistory(root, selected, history) {
65
- if (!selected.authority.authenticate(history))
66
- refuse('origin history is not authenticated');
67
- for (const line of history) {
68
- const f = fields(line), decoded = fromLine(line, wireAt(selected.topos.parts, Number(f.epoch)));
69
- if (decoded.kind !== 'fact')
70
- refuse('origin wire ' + decoded.why);
71
- }
72
- const decoded = objectHistory([...selected.configuration, ...history]);
73
- if (decoded.kind !== 'fact')
74
- return refuse('origin history ' + decoded.why);
75
- if (!decoded.value.objects.length)
76
- return;
77
- const pinned = new Set(selected.topos.lines);
78
- const admit = (f) => Boolean(f.sig) ? selected.authority.of(canonical(f)).kind === 'admitted' : pinned.has(standingBytes([canonical(f)]).trim());
79
- const provider = await objectProvider(decoded.value.objects, decoded.value.configuration, { admit, emit: () => { }, topos: pin => toposAt(pin, storeOf(root)), module: pin => contextModuleAt(pin, storeOf(root)) });
80
- const checked = validateObjectContext(decoded.value.objects, provider);
81
- if (checked.kind !== 'fact')
82
- refuse('origin context ' + checked.why);
83
- }
84
- async function readBundle(root, bundle, earlier = []) {
85
- const lines = bundle.evidence.split('\n').filter(Boolean), info = headerInfo(lines), p = policy(root);
86
- const receipts = bundle.receipt.split('\n').filter(Boolean), authority = authorityFor(lockLines(p.store), rootSigner(root), signaturesOf(p.store).admitted);
87
- if (receipts.length !== 1 || fieldOf(receipts[0], 'scope') !== 'receipts' || fieldOf(receipts[0], 'role') !== 'writes' || fieldOf(receipts[0], 'form') !== 'alphabet' || fieldOf(receipts[0], 'measure') !== 'digest' || fieldOf(receipts[0], 'at') !== 'receipt:' + info.pin || authority.of(receipts[0]).kind !== 'admitted')
88
- refuse('retained import receipt is not authenticated');
89
- const selected = context(root, info.pin);
90
- const got = readForeignWalk(lines, { origin: selected.origin, regionOrigin: selected.origin, context: info.pin, base: info.base, fields: selected.contract.fields, partition: selected.contract.partition, digest: p.digest, previousPrefixes: [], authenticatePrefix: selected.authority.authenticate, authenticateEvidence: selected.authority.authenticate, validateOriginHistory: () => true });
91
- if (fieldOf(receipts[0], 'value') !== got.identity)
92
- refuse('retained import receipt does not authenticate this ingress');
93
- await validateHistory(root, selected, [...new Set([...earlier, ...got.records])]);
94
- return { ...got, context: info.pin, regions: walkSnapshot(got.records, selected.contract.fields, p.digest, got.origin, selected.contract.partition).regions };
95
- }
96
- async function verifiedIngress(root) {
97
- const result = [], history = new Map();
98
- const bundles = [...ingressBundles(storeOf(root))].sort((a, b) => epochOf(a.receipt.split('\n')) - epochOf(b.receipt.split('\n')));
99
- for (const bundle of bundles) {
100
- const info = headerInfo(bundle.evidence.split('\n').filter(Boolean)), origin = context(root, info.pin).origin;
101
- if (result.some(prior => prior.origin === origin && prior.context !== info.pin))
102
- refuse('origin context changed without declared lineage');
103
- const prior = history.get(origin) ?? new Set();
104
- const got = await readBundle(root, bundle, [...prior]);
105
- for (const line of got.records)
106
- prior.add(line);
107
- history.set(origin, prior);
108
- result.push(got);
109
- }
110
- return result;
111
- }
112
- async function inventory(root) {
113
- const p = policy(root), regions = new Map(local(root).regions.map(region => [region.scope, region]));
114
- for (const got of (await verifiedIngress(root)).sort((a, b) => a.senderEpoch - b.senderEpoch))
115
- for (const region of got.regions)
116
- regions.set(region.scope, region);
117
- return walkInventory([[...regions.values()]], p.digest, context(root, one(p.standing, 'walk/context', 'digest'), true).contract.partition);
118
- }
119
- /** Verified foreign histories stay separate from the local authority and local epoch inputs. */
120
- export async function foreignWalkLines(root) {
121
- const verified = await verifiedIngress(root);
122
- return [...new Set(verified.flatMap(got => got.records))];
123
- }
124
- /** A declared origin exports its own signed history. Foreign packets are retained with their contexts, never re-signed as local history. */
125
- export async function renderWalk(root, resolution, peer, key, keyFile, signer) {
126
- const p = policy(root), pin = one(p.standing, 'walk/context', 'digest'), selected = context(root, pin, true), own = local(root);
127
- const known = peer.length ? (() => { const info = headerInfo(peer), remote = context(root, info.pin); return readWalkHeaders(peer, info.pin, info.base, remote.authority.authenticate); })() : walkSnapshot([], p.contract.fields, p.digest);
128
- const projection = walkProjection(selected.contract.projections, resolution);
129
- const ownInventory = projection === 'history' ? own : await inventory(root);
130
- const selectedPacket = walkAt(ownInventory, known, resolution, selected.contract.projections), by = key ?? ownerOf(p.store), publicKey = publicKeyOf(root, by);
131
- if (!publicKey)
132
- refuse('unknown local signer ' + by);
133
- const drafted = walkHeaders(selectedPacket, pin, known.root, projection !== 'inventory'), epoch = epochOf(localActLines(root));
134
- const got = await signConsentLot(drafted, { by, epoch, algorithm: signaturesOf(p.store).era }, publicKey, signaturesOf(p.store).admitted, signerFor(p.standing, by, signer, keyFile));
135
- if (got.kind !== 'fact')
136
- return refuse(got.why);
137
- if (!selected.authority.authenticate(got.lines) || !selected.authority.authenticate(selectedPacket.records))
138
- refuse('local context does not authenticate exported history');
139
- return [...got.lines, ...selectedPacket.records, `EXCHANGE ${selectedPacket.touched} touched regions · ${selectedPacket.open} open regions · ${Buffer.byteLength(selectedPacket.records.join('\n') + (selectedPacket.records.length ? '\n' : ''))} payload bytes`];
140
- }
141
- /** The SDK proves the foreign prefix; the host admits the pair at one publication point. */
142
- export async function landWalk(root, lines, key, keyFile, signer) {
143
- const p = policy(root), info = headerInfo(lines), selected = context(root, info.pin);
144
- const retained = await verifiedIngress(root);
145
- if (retained.some(prior => prior.origin === selected.origin && prior.context !== info.pin))
146
- refuse('origin context changed without declared lineage');
147
- const previous = (verified) => { const prefixes = new Map(); for (const prior of verified.filter(got => got.origin === selected.origin).sort((a, b) => a.senderEpoch - b.senderEpoch))
148
- for (const region of prior.regions)
149
- prefixes.set(region.scope, { ...region, senderEpoch: prior.senderEpoch }); return [...prefixes.values()]; };
150
- const payload = lines.filter(line => !isWalkHeader(line));
151
- const proof = (prefixes) => readForeignWalk(lines, { origin: selected.origin, regionOrigin: selected.origin, context: info.pin, base: info.base, fields: selected.contract.fields, partition: selected.contract.partition, digest: p.digest, previousPrefixes: prefixes, authenticatePrefix: selected.authority.authenticate, authenticateEvidence: selected.authority.authenticate, validateOriginHistory: () => true });
152
- const raw = proof([]), known = retained.find(prior => prior.identity === raw.identity), got = known ? raw : proof(previous(retained));
153
- const history = (prior) => [...new Set([...prior.filter(item => item.origin === selected.origin).flatMap(item => item.records), ...payload])];
154
- await validateHistory(root, selected, history(retained));
155
- if (!known && info.base !== (await inventory(root)).root)
156
- refuse('stale receiver base');
157
- if (!payload.length && !readWalkHeaders(lines, info.pin, info.base, selected.authority.authenticate).regions.length)
158
- return ['ONCE 0 new evidence lines · 0 import receipts · no regions offered', `EXCHANGE 0 payload bytes · ${Buffer.byteLength(lines.join('\n') + '\n')} protocol bytes · 0 new evidence bytes · 0 new receipt bytes`];
159
- const by = key ?? ownerOf(p.store), pub = publicKeyOf(root, by);
160
- if (!pub)
161
- refuse('unknown receiver signer ' + by);
162
- const result = await commitIngress(p.store, got.identity, async () => {
163
- if (info.base !== (await inventory(root)).root)
164
- refuse('receiver changed before ingress');
165
- const current = await verifiedIngress(root);
166
- proof(previous(current));
167
- await validateHistory(root, selected, history(current));
168
- const next = epochOf(localActLines(root)) + 1;
169
- const signed = await signConsentLot([got.importReceiptProposal], { by, epoch: next, algorithm: signaturesOf(p.store).era }, pub, signaturesOf(p.store).admitted, signerFor(p.standing, by, signer, keyFile));
170
- if (signed.kind !== 'fact')
171
- return refuse(signed.why);
172
- const authority = authorityFor(lockLines(p.store), rootSigner(root), signaturesOf(p.store).admitted);
173
- if (authority.of(signed.lines[0]).kind !== 'admitted')
174
- refuse('receiver signer does not cover the import receipt');
175
- const grammar = fromLine(signed.lines[0], wireAt(p.standing.map(fields), next));
176
- if (grammar.kind !== 'fact')
177
- refuse('receiver receipt wire ' + grammar.why);
178
- return { evidence: lines.join('\n') + '\n', receipt: signed.lines.join('\n') + '\n' };
179
- }, bundle => {
180
- try {
181
- const retainedLines = bundle.evidence.split('\n').filter(Boolean), retainedInfo = headerInfo(retainedLines);
182
- if (retainedInfo.pin !== info.pin)
183
- return false;
184
- const retainedProof = readForeignWalk(retainedLines, { origin: selected.origin, regionOrigin: selected.origin, context: info.pin, base: retainedInfo.base, fields: selected.contract.fields, partition: selected.contract.partition, digest: p.digest, previousPrefixes: [], authenticatePrefix: selected.authority.authenticate, authenticateEvidence: selected.authority.authenticate, validateOriginHistory: () => true });
185
- const receipts = bundle.receipt.split('\n').filter(Boolean), receipt = receipts[0] ?? '';
186
- return receipts.length === 1 && retainedProof.identity === got.identity && fieldOf(receipt, 'scope') === 'receipts' && fieldOf(receipt, 'value') === got.identity && fieldOf(receipt, 'at') === 'receipt:' + info.pin && authorityFor(lockLines(p.store), rootSigner(root), signaturesOf(p.store).admitted).of(receipt).kind === 'admitted';
187
- }
188
- catch {
189
- return false;
190
- }
191
- });
192
- return [`${result.kind === 'once' ? 'ONCE' : 'INGRESS'} ${result.kind === 'once' ? 0 : got.records.length} new evidence lines · 1 ${result.kind === 'once' ? 'retained' : 'signed local'} import receipt`, result.receipt.trim(), ingressCost(result, Buffer.byteLength(payload.join('\n') + (payload.length ? '\n' : '')), Buffer.byteLength(lines.filter(isWalkHeader).join('\n') + '\n'))];
193
- }
1
+ var it=Object.defineProperty;var l=(t,e)=>it(t,"name",{value:e,configurable:!0});import{library13_walkProjection as nt,library13_walkAt as rt,library13_walkSnapshot as M,library13_walkHeaders as ot,library13_readWalkHeaders as U,library13_readForeignWalk as $,library13_walkAuthority as at,library13_walkOrigin as st,library13_walkInventory as ct,library13_walkSelection as z,library13_isWalkHeader as G}from"../vendor/runtime.js";import{library14_canonical as R,library14_parse as dt,library14_fromLine as J,library14_wireAt as X,library14_matches as lt,library14_objectHistory as ft,library14_validateObjectContext as pt}from"../vendor/runtime.js";import{objectProvider as gt}from"../vendor/object-provider.js";import{library10_standingBytes as ut}from"../vendor/runtime.js";import{fieldOf as p}from"../fold/claims.js";import{lockStanding as ht,lockLines as L}from"../fold/keys.js";import{authorityFor as W,rootSigner as I}from"../fold/signers.js";import{publicKeyOf as Q}from"../fold/signers.js";import{signaturesOf as v}from"../fold/digests.js";import{fullDigest as yt}from"./digest.js";import{toposAt as wt,contextProviderServices as mt}from"./selected-topos.js";import{signerFor as V}from"./signing.js";import{signConsentLot as Y,verifiesFields as kt}from"../land/sign.js";import{storeOf as K}from"../land/ledger.js";import{signedOwnerLines as bt,epochOf as C,localActLines as Z,ownerOf as tt}from"../cli/owner.js";import{commitIngress as vt,ingressBundles as xt,ingressCost as Et}from"./ports/ingress.js";const d=l(t=>{throw Error("REFUSE\xB7walk "+t)},"refuse"),q=l(t=>{const e=dt(t);return e.kind!=="fact"?d("not a wire line"):e.value.fields},"fields"),N=l((t,e,a)=>{const c=t.filter(o=>p(o,"scope")===e&&p(o,"measure")===a&&p(o,"value")!=="withdraw");return c.length!==1?d("missing or conflicting "+e+" "+a):p(c[0],"value")},"one");function O(t){const e=K(t),a=ht(e),c=z(a);N(a,"view/walk","id")!=="walk@*"&&d("view/walk must declare walk@*");const r=a.filter(s=>p(s,"scope")==="view/walk").flatMap(s=>p(s,"needs").split("|")).filter(Boolean);r.length||d("view/walk has no declared history inputs");const i=X(a.map(q),Number.MAX_SAFE_INTEGER),n=i?.digests.values().next().value;return n||d("no admitted digest algorithm"),{store:e,standing:a,contract:c,masks:r,digest:l(s=>yt(s,n),"digest")}}l(O,"policy");function E(t,e,a=!1){const c=O(t);!a&&!c.standing.some(n=>p(n,"scope").startsWith("uses/")&&p(n,"value")===e)&&d("origin context is not selected by digest");const o=wt(e,c.store),r=at(o.parts,kt),i=o.parts.map(n=>R({...n,by:"target",epoch:"0"}));return{pin:e,topos:o,authority:r,configuration:i,origin:st(o.parts),contract:z(o.lines)}}l(E,"context");function et(t){const e=O(t),a=W(L(e.store),I(t),v(e.store).admitted),c=bt(e.store).filter(r=>e.masks.some(i=>lt(i,p(r,"scope"))));c.some(r=>a.of(r).kind!=="admitted")&&d("local history is not authenticated");const o=E(t,N(e.standing,"walk/context","digest"),!0);return M(c,o.contract.fields,e.digest,o.origin,o.contract.partition)}l(et,"local");const B=l(t=>{const e=t.filter(c=>G(c)&&p(c,"scope")==="walk/root");if(e.length!==1)return d("one signed root is required");const a=p(e[0],"at");return a.startsWith("receipt:")?{pin:a.slice(8),base:p(e[0],"condition")}:d("root has no declared context")},"headerInfo");async function D(t,e,a){e.authority.authenticate(a)||d("origin history is not authenticated");for(const s of a){const g=q(s),y=J(s,X(e.topos.parts,Number(g.epoch)));y.kind!=="fact"&&d("origin wire "+y.why)}const c=ft([...e.configuration,...a]);if(c.kind!=="fact")return d("origin history "+c.why);if(!c.value.objects.length)return;const o=new Set(e.topos.lines),r=l(s=>s.sig?e.authority.of(R(s)).kind==="admitted":o.has(ut([R(s)]).trim()),"admit"),i=await gt(c.value.objects,c.value.configuration,{admit:r,emit:l(()=>{},"emit"),...mt(K(t))}),n=pt(c.value.objects,i);n.kind!=="fact"&&d("origin context "+n.why)}l(D,"validateHistory");async function _t(t,e,a=[]){const c=e.evidence.split(`
2
+ `).filter(Boolean),o=B(c),r=O(t),i=e.receipt.split(`
3
+ `).filter(Boolean),n=W(L(r.store),I(t),v(r.store).admitted);(i.length!==1||p(i[0],"scope")!=="receipts"||p(i[0],"role")!=="writes"||p(i[0],"form")!=="alphabet"||p(i[0],"measure")!=="digest"||p(i[0],"at")!=="receipt:"+o.pin||n.of(i[0]).kind!=="admitted")&&d("retained import receipt is not authenticated");const s=E(t,o.pin),g=$(c,{origin:s.origin,regionOrigin:s.origin,context:o.pin,base:o.base,fields:s.contract.fields,partition:s.contract.partition,digest:r.digest,previousPrefixes:[],authenticatePrefix:s.authority.authenticate,authenticateEvidence:s.authority.authenticate,validateOriginHistory:l(()=>!0,"validateOriginHistory")});return p(i[0],"value")!==g.identity&&d("retained import receipt does not authenticate this ingress"),await D(t,s,[...new Set([...a,...g.records])]),{...g,context:o.pin,regions:M(g.records,s.contract.fields,r.digest,g.origin,s.contract.partition).regions}}l(_t,"readBundle");async function F(t){const e=[],a=new Map,c=[...xt(K(t))].sort((o,r)=>C(o.receipt.split(`
4
+ `))-C(r.receipt.split(`
5
+ `)));for(const o of c){const r=B(o.evidence.split(`
6
+ `).filter(Boolean)),i=E(t,r.pin).origin;e.some(g=>g.origin===i&&g.context!==r.pin)&&d("origin context changed without declared lineage");const n=a.get(i)??new Set,s=await _t(t,o,[...n]);for(const g of s.records)n.add(g);a.set(i,n),e.push(s)}return e}l(F,"verifiedIngress");async function T(t){const e=O(t),a=new Map(et(t).regions.map(c=>[c.scope,c]));for(const c of(await F(t)).sort((o,r)=>o.senderEpoch-r.senderEpoch))for(const o of c.regions)a.set(o.scope,o);return ct([[...a.values()]],e.digest,E(t,N(e.standing,"walk/context","digest"),!0).contract.partition)}l(T,"inventory");async function Xt(t){const e=await F(t);return[...new Set(e.flatMap(a=>a.records))]}l(Xt,"foreignWalkLines");async function Kt(t,e,a,c,o,r){const i=O(t),n=N(i.standing,"walk/context","digest"),s=E(t,n,!0),g=et(t),y=a.length?(()=>{const f=B(a),u=E(t,f.pin);return U(a,f.pin,f.base,u.authority.authenticate)})():M([],i.contract.fields,i.digest),_=nt(s.contract.projections,e),H=_==="history"?g:await T(t),w=rt(H,y,e,s.contract.projections),m=c??tt(i.store),S=Q(t,m);S||d("unknown local signer "+m);const j=ot(w,n,y.root,_!=="inventory"),P=C(Z(t)),k=await Y(j,{by:m,epoch:P,algorithm:v(i.store).era},S,v(i.store).admitted,V(i.standing,m,r,o));return k.kind!=="fact"?d(k.why):((!s.authority.authenticate(k.lines)||!s.authority.authenticate(w.records))&&d("local context does not authenticate exported history"),[...k.lines,...w.records,`EXCHANGE ${w.touched} touched regions \xB7 ${w.open} open regions \xB7 ${Buffer.byteLength(w.records.join(`
7
+ `)+(w.records.length?`
8
+ `:""))} payload bytes`])}l(Kt,"renderWalk");async function qt(t,e,a,c,o){const r=O(t),i=B(e),n=E(t,i.pin),s=await F(t);s.some(f=>f.origin===n.origin&&f.context!==i.pin)&&d("origin context changed without declared lineage");const g=l(f=>{const u=new Map;for(const h of f.filter(b=>b.origin===n.origin).sort((b,x)=>b.senderEpoch-x.senderEpoch))for(const b of h.regions)u.set(b.scope,{...b,senderEpoch:h.senderEpoch});return[...u.values()]},"previous"),y=e.filter(f=>!G(f)),_=l(f=>$(e,{origin:n.origin,regionOrigin:n.origin,context:i.pin,base:i.base,fields:n.contract.fields,partition:n.contract.partition,digest:r.digest,previousPrefixes:f,authenticatePrefix:n.authority.authenticate,authenticateEvidence:n.authority.authenticate,validateOriginHistory:l(()=>!0,"validateOriginHistory")}),"proof"),H=_([]),w=s.find(f=>f.identity===H.identity),m=w?H:_(g(s)),S=l(f=>[...new Set([...f.filter(u=>u.origin===n.origin).flatMap(u=>u.records),...y])],"history");if(await D(t,n,S(s)),!w&&i.base!==(await T(t)).root&&d("stale receiver base"),!y.length&&!U(e,i.pin,i.base,n.authority.authenticate).regions.length)return["ONCE 0 new evidence lines \xB7 0 import receipts \xB7 no regions offered",`EXCHANGE 0 payload bytes \xB7 ${Buffer.byteLength(e.join(`
9
+ `)+`
10
+ `)} protocol bytes \xB7 0 new evidence bytes \xB7 0 new receipt bytes`];const j=a??tt(r.store),P=Q(t,j);P||d("unknown receiver signer "+j);const k=await vt(r.store,m.identity,async()=>{i.base!==(await T(t)).root&&d("receiver changed before ingress");const f=await F(t);_(g(f)),await D(t,n,S(f));const u=C(Z(t))+1,h=await Y([m.importReceiptProposal],{by:j,epoch:u,algorithm:v(r.store).era},P,v(r.store).admitted,V(r.standing,j,o,c));if(h.kind!=="fact")return d(h.why);W(L(r.store),I(t),v(r.store).admitted).of(h.lines[0]).kind!=="admitted"&&d("receiver signer does not cover the import receipt");const x=J(h.lines[0],X(r.standing.map(q),u));return x.kind!=="fact"&&d("receiver receipt wire "+x.why),{evidence:e.join(`
11
+ `)+`
12
+ `,receipt:h.lines.join(`
13
+ `)+`
14
+ `}},f=>{try{const u=f.evidence.split(`
15
+ `).filter(Boolean),h=B(u);if(h.pin!==i.pin)return!1;const b=$(u,{origin:n.origin,regionOrigin:n.origin,context:i.pin,base:h.base,fields:n.contract.fields,partition:n.contract.partition,digest:r.digest,previousPrefixes:[],authenticatePrefix:n.authority.authenticate,authenticateEvidence:n.authority.authenticate,validateOriginHistory:l(()=>!0,"validateOriginHistory")}),x=f.receipt.split(`
16
+ `).filter(Boolean),A=x[0]??"";return x.length===1&&b.identity===m.identity&&p(A,"scope")==="receipts"&&p(A,"value")===m.identity&&p(A,"at")==="receipt:"+i.pin&&W(L(r.store),I(t),v(r.store).admitted).of(A).kind==="admitted"}catch{return!1}});return[`${k.kind==="once"?"ONCE":"INGRESS"} ${k.kind==="once"?0:m.records.length} new evidence lines \xB7 1 ${k.kind==="once"?"retained":"signed local"} import receipt`,k.receipt.trim(),Et(k,Buffer.byteLength(y.join(`
17
+ `)+(y.length?`
18
+ `:"")),Buffer.byteLength(e.filter(G).join(`
19
+ `)+`
20
+ `))]}l(qt,"landWalk");export{Xt as foreignWalkLines,qt as landWalk,Kt as renderWalk};
@@ -0,0 +1 @@
1
+ var v=Object.defineProperty;var d=(r,o)=>v(r,"name",{value:o,configurable:!0});import{AsyncLocalStorage as y}from"node:async_hooks";const f=new y,M=1e4;function S(r,o){const i=f.getStore();if(!i)return o();const{trace:e,parent:c}=i;if(e.spans.length>=M)return e.truncated=!0,o();const l={id:e.spans.length,parent:c,name:r,start:e.clock()};e.spans.push(l);const m=d(()=>{l.end=e.clock()},"close");return f.run({trace:e,parent:l.id},()=>{try{const s=o();return s&&typeof s.then=="function"?Promise.resolve(s).finally(m):(m(),s)}catch(s){throw m(),s}})}d(S,"traceWork");function g(r,o,i=!1){const e=r[0],c=r.flatMap(t=>[{time:t.start,id:t.id,start:!0},{time:t.end??o,id:t.id,start:!1}]).sort((t,n)=>t.time-n.time||Number(t.start)-Number(n.start)),l=new Set,m=new Map,s=r.map(t=>{let n=0,a=t.parent;for(;a>=0;)n++,a=r[a].parent;return n});let p=e.start;for(const t of c){const n=Math.min(o,Math.max(e.start,t.time));if(n>p){let a=0;for(const u of l)(s[u]>s[a]||s[u]===s[a]&&u>a)&&(a=u);const w=r[a].name;m.set(w,(m.get(w)??0)+n-p),p=n}t.start?l.add(t.id):l.delete(t.id)}const h=[...m].map(([t,n])=>({name:t,milliseconds:n}));return{profile:"bound-work-trace@1",clock:"performance.now monotonic milliseconds",totalMilliseconds:o-e.start,exclusiveMilliseconds:h.reduce((t,n)=>t+n.milliseconds,0),phases:h,inclusive:r.map(t=>({name:t.name,milliseconds:(t.end??o)-t.start})),complete:!i}}d(g,"workReport");async function b(r,o,i=()=>performance.now()){if(f.getStore())return r();const e={id:0,parent:-1,name:"command/dispatch",start:i()},c={clock:i,spans:[e],truncated:!1};try{return await f.run({trace:c,parent:0},r)}finally{e.end=i(),o(g(c.spans,e.end,c.truncated))}}d(b,"withWorkTrace");export{S as traceWork,b as withWorkTrace,g as workReport};
@@ -1,33 +1 @@
1
- import { canonical } from '@lapxo/topos/wire';
2
- import { fieldOf } from "../fold/claims.js";
3
- import { fullDigest } from "../fold/digests.js";
4
- import { inside, locationsOf, vouchedCoordinates } from "../land/vouched.js";
5
- import { wordOf } from "../fold/wire.js";
6
- import { holdsCases } from "../fold/paid.js";
7
- /**
8
- * A demand that landed after its coordinates. A take judges what moved, because it assumes the demand came first and the
9
- * tree after it; a demand that arrives second has nothing left to move — its cone is already in the ledger, every coordinate
10
- * of it vouched at a digest. Judging that is reading, not observing, so it is answered where it lands and no file is
11
- * touched to force it. A demand whose cone holds no vouched coordinate is not late, it is unlanded, and it waits for a take.
12
- */
13
- export function lateFacts(store, signed, answered) {
14
- const vouched = [...vouchedCoordinates(store)];
15
- const views = `${wordOf(signed, 'families', 'view')}/`;
16
- const out = [];
17
- for (const line of signed) {
18
- const scope = fieldOf(line, 'scope');
19
- const value = fieldOf(line, 'value') || 'present';
20
- if (fieldOf(line, 'role') !== 'demands' || value === 'withdraw' || answered.has(scope))
21
- continue;
22
- const asked = locationsOf(fieldOf(line, 'needs')).locations;
23
- if (!asked.length || (!scope.startsWith(views) && !asked.some(holdsCases)))
24
- continue;
25
- const cone = asked.map((where) => vouched.filter(([coordinate]) => inside(coordinate, where)));
26
- if (cone.some((held) => !held.length))
27
- continue;
28
- const held = cone.flat();
29
- const at = `cone:${fullDigest(store, held.map(([coordinate, digest]) => `${coordinate} ${digest}`).sort()).replace(/^sha256:/, '')}`;
30
- out.push(canonical({ scope, role: 'writes', form: 'alphabet', measure: fieldOf(line, 'measure') || 'status', value, by: 'judge', at }), canonical({ scope, role: 'writes', form: 'alphabet', measure: 'cone', value: held.map(([coordinate]) => coordinate).join('|'), by: 'judge', at }));
31
- }
32
- return out;
33
- }
1
+ var b=Object.defineProperty;var p=(s,a)=>b(s,"name",{value:a,configurable:!0});import{library14_canonical as d}from"../vendor/runtime.js";import{fieldOf as t}from"../fold/claims.js";import{fullDigest as g}from"../fold/digests.js";import{inside as $,locationsOf as j,vouchedCoordinates as y}from"../land/vouched.js";import{wordOf as O}from"../fold/wire.js";import{holdsCases as C}from"../fold/paid.js";function z(s,a,h){const v=[...y(s)],w=`${O(a,"families","view")}/`,c=[];for(const e of a){const n=t(e,"scope"),l=t(e,"value")||"present";if(t(e,"role")!=="demands"||l==="withdraw"||h.has(n))continue;const r=j(t(e,"needs")).locations;if(!r.length||!n.startsWith(w)&&!r.some(C))continue;const m=r.map(o=>v.filter(([i])=>$(i,o)));if(m.some(o=>!o.length))continue;const f=m.flat(),u=`cone:${g(s,f.map(([o,i])=>`${o} ${i}`).sort()).replace(/^sha256:/,"")}`;c.push(d({scope:n,role:"writes",form:"alphabet",measure:t(e,"measure")||"status",value:l,by:"judge",at:u}),d({scope:n,role:"writes",form:"alphabet",measure:"cone",value:f.map(([o])=>o).join("|"),by:"judge",at:u}))}return c}p(z,"lateFacts");export{z as lateFacts};
@@ -1,75 +1,2 @@
1
- import { createHash, existsSync, join } from "../host/io.js";
2
- import { fullDigest } from "../fold/digests.js";
3
- import { answers, point, region } from '@lapxo/obligations/field';
4
- import { parse, PROTOCOL } from '@lapxo/topos/wire';
5
- import { observeText } from "../observe/files.js";
6
- import { storeOf } from "../land/ledger.js";
7
- import { holdsCases } from "../fold/paid.js";
8
- /** A demanded location is a region: it is there when some place of the tree answers to it, file or directory alike. */
9
- function located(root, location) {
10
- return existsSync(join(root, location.replace(/\/+$/, '')));
11
- }
12
- function namedEffects(_root, _changed, _ROOTS) {
13
- return [];
14
- }
15
- export function judgeTake(input) {
16
- const { root, scope, value, locations, before, after } = input;
17
- const paths = [...new Set([...before.keys(), ...after.keys()])].sort();
18
- const moved = paths.filter((p) => before.get(p) !== after.get(p));
19
- const notOwned = moved.filter((coordinate) => {
20
- if (before.has(coordinate) || locations.includes(coordinate) || !input.witnessOf || !input.law)
21
- return false;
22
- const named = input.witnessOf(coordinate);
23
- return named !== undefined && !input.law.includes(named);
24
- });
25
- const changed = moved.filter((coordinate) => !notOwned.includes(coordinate));
26
- const absent = value === 'present' ? locations.filter((l) => !located(root, l)) : [];
27
- const effects = changed.length && !absent.length ? namedEffects(root, changed, input.template) : [];
28
- const envelope = {
29
- scope,
30
- cone: [...locations],
31
- before: Object.fromEntries([...before].sort()),
32
- after: Object.fromEntries([...after].filter(([coordinate]) => !notOwned.includes(coordinate)).sort()),
33
- effects,
34
- };
35
- const digest = fullDigest(storeOf(root), JSON.stringify({ ...envelope, effects: effects.map((e) => ({ kind: e.kind, status: e.status, at: e.at })) }));
36
- const refuse = (why) => ({ kind: 'refuse', why, envelope, digest, changed, notOwned });
37
- const met = (why) => ({ kind: 'fact', why, envelope, digest, changed, notOwned });
38
- if (!changed.length && !input.unpaid)
39
- return refuse('nothing in the cone moved against what was vouched');
40
- const cone = locations.map((l) => region(l));
41
- const outside = changed.filter((coordinate) => !answers([point(coordinate)], cone));
42
- if (outside.length)
43
- return refuse(`outside the cone: ${outside.join(', ')}`);
44
- if (absent.length)
45
- return refuse(`demanded locations absent: ${absent.join(', ')}`);
46
- if (input.shape === 'lock' || input.shape === 'render') {
47
- const lines = locations.map((l) => ({ at: l, text: observeText(join(root, l)) }));
48
- const absent = lines.filter((one) => one.text === undefined).map((one) => one.at);
49
- if (absent.length)
50
- return refuse(`a lock the demand names is not here: ${absent.join(', ')}`);
51
- const said = lines.flatMap((one) => (one.text ?? '').split('\n').filter((line) => line.startsWith(PROTOCOL)));
52
- const unread = said.filter((line) => parse(line).kind !== 'fact');
53
- if (input.shape === 'lock' && (!said.length || unread.length)) {
54
- return refuse(`a lock the demand names holds ${said.length ? `${unread.length} lines the wire does not read` : 'no claim'}`);
55
- }
56
- const rests = input.restsOn ?? '';
57
- const digest = rests ? `sha256:${createHash('sha256').update(lines.map((one) => one.text ?? '').join('')).digest('hex')}` : rests;
58
- if (rests && digest !== rests)
59
- return refuse(`the lock moved: it rests on ${rests} and is ${digest}`);
60
- return met(input.shape === 'lock' ? `${said.length} lines of the lock read, at the digest it rests on` : 'the region is here, at the digest it rests on');
61
- }
62
- const vectors = locations.filter((l) => holdsCases(l) && located(root, l));
63
- if (!vectors.length)
64
- return refuse('no vector location in the cone exists');
65
- const red = effects.filter((e) => e.status === 'red' && e.admitted);
66
- if (red.length)
67
- return refuse(`effects red: ${red.map((e) => `${e.kind}@${e.at}`).join(', ')}`);
68
- return met('demand met in its cone');
69
- }
70
- /** A take that met its cone carries the gates its batch passed: their runs join its envelope, and its receipt is sealed with them. */
71
- export function sealed(root, verdict, gates) {
72
- const envelope = { ...verdict.envelope, effects: [...verdict.envelope.effects, ...gates.map(({ kind, status, ms, at, admitted }) => ({ kind, status, ms, at, admitted }))] };
73
- const digest = fullDigest(storeOf(root), JSON.stringify({ ...envelope, effects: envelope.effects.map((e) => ({ kind: e.kind, status: e.status, at: e.at })) }));
74
- return { ...verdict, envelope, digest };
75
- }
1
+ var L=Object.defineProperty;var i=(t,s)=>L(t,"name",{value:s,configurable:!0});import{createHash as N,existsSync as P,join as S}from"../host/io.js";import{fullDigest as T}from"../fold/digests.js";import{library0_answers as D,library0_point as H,library0_region as M}from"../vendor/runtime.js";import{library14_parse as W,library14_PROTOCOL as q}from"../vendor/runtime.js";import{observeText as z}from"../observe/files.js";import{storeOf as C}from"../land/ledger.js";import{holdsCases as A}from"../fold/paid.js";function E(t,s){return P(S(t,s.replace(/\/+$/,"")))}i(E,"located");function B(t,s,g){return[]}i(B,"namedEffects");function Z(t){const{root:s,scope:g,value:l,locations:o,before:r,after:d}=t,u=[...new Set([...r.keys(),...d.keys()])].sort().filter(e=>r.get(e)!==d.get(e)),f=u.filter(e=>{if(r.has(e)||o.includes(e)||!t.witnessOf||!t.law)return!1;const h=t.witnessOf(e);return h!==void 0&&!t.law.includes(h)}),c=u.filter(e=>!f.includes(e)),k=l==="present"?o.filter(e=>!E(s,e)):[],O=c.length&&!k.length?B(s,c,t.template):[],b={scope:g,cone:[...o],before:Object.fromEntries([...r].sort()),after:Object.fromEntries([...d].filter(([e])=>!f.includes(e)).sort()),effects:O},v=T(C(s),JSON.stringify({...b,effects:O.map(e=>({kind:e.kind,status:e.status,at:e.at}))})),a=i(e=>({kind:"refuse",why:e,envelope:b,digest:v,changed:c,notOwned:f}),"refuse"),w=i(e=>({kind:"fact",why:e,envelope:b,digest:v,changed:c,notOwned:f}),"met");if(!c.length&&!t.unpaid)return a("nothing in the cone moved against what was vouched");const R=o.map(e=>M(e)),x=c.filter(e=>!D([H(e)],R));if(x.length)return a(`outside the cone: ${x.join(", ")}`);if(k.length)return a(`demanded locations absent: ${k.join(", ")}`);if(t.shape==="lock"||t.shape==="render"){const e=o.map(n=>({at:n,text:z(S(s,n))})),h=e.filter(n=>n.text===void 0).map(n=>n.at);if(h.length)return a(`a lock the demand names is not here: ${h.join(", ")}`);const p=e.flatMap(n=>(n.text??"").split(`
2
+ `).filter(J=>J.startsWith(q))),j=p.filter(n=>W(n).kind!=="fact");if(t.shape==="lock"&&(!p.length||j.length))return a(`a lock the demand names holds ${p.length?`${j.length} lines the wire does not read`:"no claim"}`);const m=t.restsOn??"",_=m&&`sha256:${N("sha256").update(e.map(n=>n.text??"").join("")).digest("hex")}`;return m&&_!==m?a(`the lock moved: it rests on ${m} and is ${_}`):w(t.shape==="lock"?`${p.length} lines of the lock read, at the digest it rests on`:"the region is here, at the digest it rests on")}if(!o.filter(e=>A(e)&&E(s,e)).length)return a("no vector location in the cone exists");const y=O.filter(e=>e.status==="red"&&e.admitted);return y.length?a(`effects red: ${y.map(e=>`${e.kind}@${e.at}`).join(", ")}`):w("demand met in its cone")}i(Z,"judgeTake");function ee(t,s,g){const l={...s.envelope,effects:[...s.envelope.effects,...g.map(({kind:r,status:d,ms:$,at:u,admitted:f})=>({kind:r,status:d,ms:$,at:u,admitted:f}))]},o=T(C(t),JSON.stringify({...l,effects:l.effects.map(r=>({kind:r.kind,status:r.status,at:r.at}))}));return{...s,envelope:l,digest:o}}i(ee,"sealed");export{Z as judgeTake,ee as sealed};
@@ -1,25 +1 @@
1
- import { fieldOf } from "../fold/claims.js";
2
- import { ALPHABETS, idsOf, INTERVALS, spanOf } from '@lapxo/topos/forms';
3
- /**
4
- * A ceiling that admits more than it did is not a revision of the same kind as one that admits less: narrowing costs
5
- * the signer nothing anyone else can dispute, while widening gives back freedom the tree had already spent. So a line
6
- * that widens what it replaces is refused unless it says what forced it — an `at` of the witness class, which names
7
- * the reading or the case that made the old bound wrong. Policy may narrow; only a witness may widen. A list of what is
8
- * forbidden narrows as it grows.
9
- */
10
- function widens(now, before) {
11
- const [was, held] = [spanOf(fieldOf(before, 'value')), spanOf(fieldOf(now, 'value'))];
12
- if (was && held)
13
- return INTERVALS.leq(was, held) && !INTERVALS.leq(held, was);
14
- const [old, fresh] = [idsOf(fieldOf(before, 'value')), idsOf(fieldOf(now, 'value'))];
15
- return old.polarity === fresh.polarity && ALPHABETS.leq(old, fresh) && !ALPHABETS.leq(fresh, old);
16
- }
17
- export function widenedWithoutWitness(proposed, standing, isCeiling, witness) {
18
- const held = new Map(standing.filter(isCeiling).map((line) => [fieldOf(line, 'scope'), line]));
19
- return proposed.filter((line) => {
20
- const before = held.get(fieldOf(line, 'scope'));
21
- if (!before || !isCeiling(line) || !widens(line, before))
22
- return false;
23
- return !fieldOf(line, 'at').startsWith(`${witness}:`);
24
- });
25
- }
1
+ var c=Object.defineProperty;var o=(e,a)=>c(e,"name",{value:a,configurable:!0});import{fieldOf as t}from"../fold/claims.js";import{library7_ALPHABETS as n,library7_idsOf as u,library7_INTERVALS as p,library7_spanOf as d}from"../vendor/runtime.js";function y(e,a){const[s,f]=[d(t(a,"value")),d(t(e,"value"))];if(s&&f)return p.leq(s,f)&&!p.leq(f,s);const[l,r]=[u(t(a,"value")),u(t(e,"value"))];return l.polarity===r.polarity&&n.leq(l,r)&&!n.leq(r,l)}o(y,"widens");function O(e,a,s,f){const l=new Map(a.filter(s).map(r=>[t(r,"scope"),r]));return e.filter(r=>{const i=l.get(t(r,"scope"));return!i||!s(r)||!y(r,i)?!1:!t(r,"at").startsWith(`${f}:`)})}o(O,"widenedWithoutWitness");export{O as widenedWithoutWitness};