@lapxo/bound 0.2.4 → 0.2.5

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 (250) hide show
  1. package/CITATION.cff +1 -1
  2. package/TARGET.bound +44 -39
  3. package/dist/cli/accept.js +72 -590
  4. package/dist/cli/act-result.js +3 -103
  5. package/dist/cli/args.js +3 -44
  6. package/dist/cli/custodian.js +2 -29
  7. package/dist/cli/host.js +4 -32
  8. package/dist/cli/names.js +1 -12
  9. package/dist/cli/native-descendant.js +1 -19
  10. package/dist/cli/native.js +3 -60
  11. package/dist/cli/observe.js +1 -13
  12. package/dist/cli/owner.js +3 -139
  13. package/dist/cli/pass.js +21 -321
  14. package/dist/cli/place.js +6 -282
  15. package/dist/cli/release-result.js +3 -80
  16. package/dist/cli/retained-judgment.js +1 -25
  17. package/dist/cli/standing-result.js +4 -19
  18. package/dist/cli/takes.js +10 -112
  19. package/dist/cli/verb.d.ts +1 -2
  20. package/dist/cli/verb.js +83 -684
  21. package/dist/engine/computation.js +2 -0
  22. package/dist/engine/conformance.js +4 -0
  23. package/dist/engine/encoding.js +1 -2
  24. package/dist/engine/index.d.ts +1 -13
  25. package/dist/engine/index.js +2 -11
  26. package/dist/engine/object.js +1 -38
  27. package/dist/engine/ports.js +2 -117
  28. package/dist/fold/admission-history.js +1 -17
  29. package/dist/fold/bootstrap-anchor.js +1 -28
  30. package/dist/fold/ceilings.js +1 -142
  31. package/dist/fold/claims.js +2 -132
  32. package/dist/fold/closed.js +24 -235
  33. package/dist/fold/configures.js +1 -25
  34. package/dist/fold/digests.js +10 -226
  35. package/dist/fold/evidence.js +1 -22
  36. package/dist/fold/fold-worker.js +1 -13
  37. package/dist/fold/kept.js +12 -173
  38. package/dist/fold/keys.js +3 -91
  39. package/dist/fold/laid.js +3 -90
  40. package/dist/fold/nos.js +1 -48
  41. package/dist/fold/object.js +1 -2
  42. package/dist/fold/observed.js +27 -534
  43. package/dist/fold/opened.js +1 -33
  44. package/dist/fold/own.js +3 -217
  45. package/dist/fold/paid.js +1 -92
  46. package/dist/fold/place-inputs.js +1 -70
  47. package/dist/fold/places.js +3 -100
  48. package/dist/fold/rank.js +1 -9
  49. package/dist/fold/reach.js +1 -83
  50. package/dist/fold/readers.js +6 -142
  51. package/dist/fold/receipts.js +1 -47
  52. package/dist/fold/region-declarations.js +1 -13
  53. package/dist/fold/region.js +8 -286
  54. package/dist/fold/release-policy.js +1 -101
  55. package/dist/fold/resolved.js +6 -145
  56. package/dist/fold/roles.js +2 -59
  57. package/dist/fold/second.js +4 -71
  58. package/dist/fold/shards.js +12 -100
  59. package/dist/fold/signed.js +3 -81
  60. package/dist/fold/signers.js +1 -54
  61. package/dist/fold/stranger.js +6 -24
  62. package/dist/fold/views.js +1 -66
  63. package/dist/fold/wire.js +1 -46
  64. package/dist/fold/zoom.js +3 -81
  65. package/dist/host/act-cost.js +1 -25
  66. package/dist/host/adapters/keys/ed25519.js +1 -30
  67. package/dist/host/adapters/modules/javascript.js +1 -50
  68. package/dist/host/adapters/transport/http.js +1 -28
  69. package/dist/host/admitted-place.js +1 -35
  70. package/dist/host/archive.js +1 -152
  71. package/dist/host/call-context.js +1 -14
  72. package/dist/host/capsule-process.js +2 -62
  73. package/dist/host/capsule.js +9 -171
  74. package/dist/host/cell-receipts.js +12 -128
  75. package/dist/host/commit-result.js +1 -5
  76. package/dist/host/content-needed.js +1 -8
  77. package/dist/host/content-store.js +1 -31
  78. package/dist/host/contextual-place.js +2 -72
  79. package/dist/host/digest.js +2 -15
  80. package/dist/host/hash.js +1 -9
  81. package/dist/host/host-controls.js +1 -19
  82. package/dist/host/in-process-act.js +3 -84
  83. package/dist/host/in-process-context.js +3 -91
  84. package/dist/host/in-process-root.js +6 -84
  85. package/dist/host/in-process.js +4 -55
  86. package/dist/host/index.d.ts +1 -15
  87. package/dist/host/index.js +1 -7
  88. package/dist/host/io.js +1 -11
  89. package/dist/host/lifetime.js +1 -79
  90. package/dist/host/located.js +6 -105
  91. package/dist/host/native/bounded-file.js +1 -32
  92. package/dist/host/native/command.js +1 -91
  93. package/dist/host/native/control-bridge-worker.js +2 -88
  94. package/dist/host/native/control-bridge.js +1 -110
  95. package/dist/host/native/control-selection.js +1 -32
  96. package/dist/host/native/custody.js +1 -91
  97. package/dist/host/native/deadline.js +1 -28
  98. package/dist/host/native/descendants.js +1 -528
  99. package/dist/host/native/generated-custodian.js +5 -267
  100. package/dist/host/native/generated.js +1 -379
  101. package/dist/host/native/image.js +1 -45
  102. package/dist/host/native/jobs.js +2 -148
  103. package/dist/host/native/loader.js +1 -269
  104. package/dist/host/native/materialize.js +1 -175
  105. package/dist/host/native/module-closure.js +1 -130
  106. package/dist/host/native/module-delivery.d.ts +1 -62
  107. package/dist/host/native/module-delivery.js +1 -151
  108. package/dist/host/native/module-syntax.js +1 -69
  109. package/dist/host/native/native-binary.js +1 -115
  110. package/dist/host/native/native-program.js +1 -72
  111. package/dist/host/native/node-jobs.js +3 -187
  112. package/dist/host/native/node-launch.js +1 -159
  113. package/dist/host/native/preload.js +1 -45
  114. package/dist/host/native/reading.js +1 -249
  115. package/dist/host/native/receipt-environment.js +1 -41
  116. package/dist/host/native/references.js +1 -30
  117. package/dist/host/native/root.js +1 -37
  118. package/dist/host/native/route.js +1 -216
  119. package/dist/host/native/runtime.js +1 -9
  120. package/dist/host/native-reader-context.js +1 -8
  121. package/dist/host/native-receiver.js +1 -25
  122. package/dist/host/objects.js +1 -38
  123. package/dist/host/order.js +1 -2
  124. package/dist/host/place-act-transaction.js +4 -78
  125. package/dist/host/place-clock-selection.js +5 -124
  126. package/dist/host/ports/ingress.js +2 -57
  127. package/dist/host/ports/local-act.js +5 -183
  128. package/dist/host/ports/place-act.js +1 -134
  129. package/dist/host/ports/publication.js +1 -56
  130. package/dist/host/ports/signing.js +1 -74
  131. package/dist/host/ports/store.js +1 -18
  132. package/dist/host/ports/transport.js +1 -48
  133. package/dist/host/process-lifetime.js +1 -17
  134. package/dist/host/provide.js +1 -183
  135. package/dist/host/read-only.js +1 -9
  136. package/dist/host/reading-closures.js +7 -227
  137. package/dist/host/reading-context.js +1 -53
  138. package/dist/host/reading-identity-types.js +0 -0
  139. package/dist/host/reading-identity.js +3 -0
  140. package/dist/host/reading-preparation.js +6 -0
  141. package/dist/host/reference-authenticated.d.ts +1 -40
  142. package/dist/host/reference-authenticated.js +3 -100
  143. package/dist/host/reference-contracts.js +1 -6
  144. package/dist/host/reference-export.js +6 -81
  145. package/dist/host/reference-native-api.d.ts +1 -3
  146. package/dist/host/reference-native-api.js +1 -3
  147. package/dist/host/reference-native.js +1 -74
  148. package/dist/host/reference-profile.js +1 -63
  149. package/dist/host/reference-standing.js +2 -18
  150. package/dist/host/reference.js +1 -24
  151. package/dist/host/refusals.js +2 -43
  152. package/dist/host/release.js +4 -256
  153. package/dist/host/root-clock-source.js +1 -307
  154. package/dist/host/selected-capsules.js +1 -50
  155. package/dist/host/selected-topos.js +1 -80
  156. package/dist/host/signature-era.js +1 -12
  157. package/dist/host/signing.js +2 -48
  158. package/dist/host/source-content.js +2 -111
  159. package/dist/host/standing-carrier.js +1 -18
  160. package/dist/host/standing-projection.js +1 -50
  161. package/dist/host/timing.js +1 -7
  162. package/dist/host/walk.js +20 -193
  163. package/dist/judge/late.js +1 -33
  164. package/dist/judge/take.js +2 -75
  165. package/dist/judge/widening.js +1 -25
  166. package/dist/land/act.js +8 -336
  167. package/dist/land/alias.js +1 -41
  168. package/dist/land/held.js +1 -23
  169. package/dist/land/inert.js +1 -33
  170. package/dist/land/leaving.js +1 -55
  171. package/dist/land/ledger.js +7 -188
  172. package/dist/land/owned.js +4 -66
  173. package/dist/land/sign.js +1 -53
  174. package/dist/land/standing-pin.js +1 -49
  175. package/dist/land/vouched.js +1 -112
  176. package/dist/land/withdraw.js +1 -24
  177. package/dist/observe/files.js +1 -88
  178. package/dist/observe/identity.js +1 -61
  179. package/dist/observe/match.js +1 -8
  180. package/dist/observe/regions.js +7 -306
  181. package/dist/observe/run.js +2 -41
  182. package/dist/observe/runner.js +4 -101
  183. package/dist/public-types.d.ts +1114 -0
  184. package/dist/render/capsule.js +1 -30
  185. package/dist/render/field.js +1 -40
  186. package/dist/render/names.js +1 -4
  187. package/dist/render/open.js +1 -61
  188. package/dist/render/page.js +1 -7
  189. package/dist/render/receipts.js +1 -47
  190. package/dist/render/shape.js +1 -74
  191. package/dist/render/target.js +4 -52
  192. package/dist/render/view.js +7 -197
  193. package/dist/vendor/50086958553b9376d600583f7dff354196bfeb41170fc6d1482ca7bea7c493e2.LICENSE +21 -0
  194. package/dist/vendor/b3e938d28f88a1851af303a40c749e12ebd5a686daac4f0b343b5cdd2e040419.LICENSE +21 -0
  195. package/dist/vendor/bundle.json +1 -0
  196. package/dist/vendor/library11.js +1 -0
  197. package/dist/vendor/object-provider.js +42 -0
  198. package/dist/vendor/runtime.js +38 -0
  199. package/dist/vendor/sources.json +1 -0
  200. package/dist/wasm/adapter.d.ts +1 -51
  201. package/dist/wasm/adapter.js +1 -180
  202. package/dist/wasm/node-worker.js +1 -13
  203. package/dist/wasm/object.js +1 -76
  204. package/dist/wasm/worker.js +1 -7
  205. package/docs/contracts/closure-delivery.md +1 -1
  206. package/docs/contracts/closure-delivery.publication.json +1 -1
  207. package/docs/contracts/conformance.json +142 -0
  208. package/docs/contracts/determinism.bound +9 -0
  209. package/docs/contracts/engine-object-projection.publication.json +1 -1
  210. package/docs/contracts/engine.md +21 -1
  211. package/docs/contracts/native-publication.inventory.json +2 -1
  212. package/docs/contracts/optional-wasm-adapter.publication.json +1 -1
  213. package/docs/contracts/reading-identity.md +37 -0
  214. package/docs/contracts/reading-identity.publication.json +25 -0
  215. package/docs/contracts/refusals.bound +51 -0
  216. package/docs/contracts/refusals.md +18 -3
  217. package/docs/contracts/refusals.publication.json +2 -2
  218. package/docs/contracts/views.md +8 -0
  219. package/docs/reference.md +1 -0
  220. package/package.json +23 -34
  221. package/receipts.bound +11627 -10323
  222. package/samples/reading-identity/no.json +20 -0
  223. package/samples/reading-identity/yes.json +46 -0
  224. package/vectors/native/reading-identity.vector.json +101 -0
  225. package/vectors/native/refusals.vector.json +104 -0
  226. package/vendor/syntax/LICENSE.md +7 -0
  227. package/vendor/syntax/parser.js +1 -0
  228. package/.github/workflows/release.yml +0 -67
  229. package/.github/workflows/test.yml +0 -35
  230. package/dist/engine/object.d.ts +0 -17
  231. package/dist/engine/ports.d.ts +0 -37
  232. package/dist/fold/claims.d.ts +0 -29
  233. package/dist/host/call-context.d.ts +0 -20
  234. package/dist/host/commit-result.d.ts +0 -6
  235. package/dist/host/in-process-act.d.ts +0 -82
  236. package/dist/host/in-process-context.d.ts +0 -46
  237. package/dist/host/in-process-root.d.ts +0 -117
  238. package/dist/host/in-process.d.ts +0 -41
  239. package/dist/host/native/module-closure.d.ts +0 -35
  240. package/dist/host/native-receiver.d.ts +0 -19
  241. package/dist/host/place-act-transaction.d.ts +0 -24
  242. package/dist/host/place-clock-selection.d.ts +0 -55
  243. package/dist/host/ports/local-act.d.ts +0 -44
  244. package/dist/host/ports/place-act.d.ts +0 -49
  245. package/dist/host/ports/publication.d.ts +0 -10
  246. package/dist/host/reference-export.d.ts +0 -33
  247. package/dist/host/reference-native.d.ts +0 -30
  248. package/dist/host/reference-profile.d.ts +0 -23
  249. package/dist/host/refusals.d.ts +0 -14
  250. package/dist/host/root-clock-source.d.ts +0 -86
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{library10_walkProjection as nt,library10_walkAt as rt,library10_walkSnapshot as M,library10_walkHeaders as ot,library10_readWalkHeaders as U,library10_readForeignWalk as $,library10_walkAuthority as at,library10_walkOrigin as st,library10_walkInventory as ct,library10_walkSelection as z,library10_isWalkHeader as G}from"../vendor/runtime.js";import{library11_canonical as R,library11_parse as dt,library11_fromLine as J,library11_wireAt as X,library11_matches as lt,library11_objectHistory as ft,library11_validateObjectContext as pt}from"../vendor/runtime.js";import{objectProvider as gt}from"../vendor/object-provider.js";import{library7_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};
@@ -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{library11_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{library12_answers as D,library12_point as H,library12_region as M}from"../vendor/runtime.js";import{library11_parse as W,library11_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{library4_ALPHABETS as n,library4_idsOf as u,library4_INTERVALS as p,library4_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};