@lapxo/bound 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/CITATION.cff +1 -1
  2. package/README.md +20 -3
  3. package/TARGET.bound +85 -47
  4. package/dist/cli/accept.js +61 -590
  5. package/dist/cli/act-result.js +3 -103
  6. package/dist/cli/args.js +3 -44
  7. package/dist/cli/custodian.js +2 -29
  8. package/dist/cli/host.js +4 -32
  9. package/dist/cli/names.js +1 -12
  10. package/dist/cli/native-descendant.js +1 -19
  11. package/dist/cli/native.js +3 -60
  12. package/dist/cli/observe.js +1 -13
  13. package/dist/cli/owner.js +3 -139
  14. package/dist/cli/pass.js +22 -321
  15. package/dist/cli/place.js +6 -282
  16. package/dist/cli/release-result.js +3 -80
  17. package/dist/cli/retained-judgment.js +1 -25
  18. package/dist/cli/standing-result.js +4 -19
  19. package/dist/cli/takes.js +10 -112
  20. package/dist/cli/verb.d.ts +1 -2
  21. package/dist/cli/verb.js +85 -684
  22. package/dist/engine/computation.js +2 -0
  23. package/dist/engine/conformance.js +4 -0
  24. package/dist/engine/encoding.js +1 -2
  25. package/dist/engine/index.d.ts +1 -13
  26. package/dist/engine/index.js +2 -11
  27. package/dist/engine/object.js +1 -38
  28. package/dist/engine/ports.js +2 -117
  29. package/dist/fold/admission-history.js +1 -17
  30. package/dist/fold/bootstrap-anchor.js +1 -28
  31. package/dist/fold/ceilings.js +1 -142
  32. package/dist/fold/claims.js +2 -132
  33. package/dist/fold/closed.js +24 -235
  34. package/dist/fold/configures.js +1 -25
  35. package/dist/fold/digests.js +10 -226
  36. package/dist/fold/evidence.js +1 -22
  37. package/dist/fold/fold-worker.js +1 -13
  38. package/dist/fold/kept.js +12 -173
  39. package/dist/fold/keys.js +3 -91
  40. package/dist/fold/laid.js +3 -90
  41. package/dist/fold/nos.js +1 -48
  42. package/dist/fold/object.js +1 -2
  43. package/dist/fold/observed.js +28 -534
  44. package/dist/fold/opened.js +1 -33
  45. package/dist/fold/own.js +3 -217
  46. package/dist/fold/paid.js +1 -92
  47. package/dist/fold/place-inputs.js +1 -70
  48. package/dist/fold/places.js +3 -100
  49. package/dist/fold/rank.js +1 -9
  50. package/dist/fold/reach.js +1 -83
  51. package/dist/fold/readers.js +6 -142
  52. package/dist/fold/receipts.js +1 -47
  53. package/dist/fold/region-declarations.js +1 -13
  54. package/dist/fold/region.js +8 -286
  55. package/dist/fold/release-policy.js +1 -101
  56. package/dist/fold/resolved.js +6 -145
  57. package/dist/fold/roles.js +2 -59
  58. package/dist/fold/second.js +4 -71
  59. package/dist/fold/shards.js +12 -100
  60. package/dist/fold/signed.js +3 -81
  61. package/dist/fold/signers.js +1 -54
  62. package/dist/fold/stranger.js +6 -24
  63. package/dist/fold/views.js +1 -66
  64. package/dist/fold/wire.js +1 -46
  65. package/dist/fold/zoom.js +3 -81
  66. package/dist/host/act-cost.js +1 -25
  67. package/dist/host/adapters/keys/ed25519.js +1 -30
  68. package/dist/host/adapters/modules/javascript.js +1 -50
  69. package/dist/host/adapters/transport/http.js +1 -28
  70. package/dist/host/admitted-place.js +1 -35
  71. package/dist/host/archive.js +1 -152
  72. package/dist/host/call-context.js +1 -14
  73. package/dist/host/capsule-process.js +2 -62
  74. package/dist/host/capsule.js +9 -171
  75. package/dist/host/cell-receipts.js +12 -128
  76. package/dist/host/command-server.js +4 -0
  77. package/dist/host/commit-result.js +1 -5
  78. package/dist/host/content-needed.js +1 -8
  79. package/dist/host/content-store.js +1 -31
  80. package/dist/host/contextual-place.js +2 -72
  81. package/dist/host/digest.js +2 -15
  82. package/dist/host/hash.js +1 -9
  83. package/dist/host/host-controls.js +1 -19
  84. package/dist/host/in-process-act.js +3 -84
  85. package/dist/host/in-process-context.js +3 -91
  86. package/dist/host/in-process-root.js +6 -84
  87. package/dist/host/in-process.js +4 -55
  88. package/dist/host/index.d.ts +1 -15
  89. package/dist/host/index.js +1 -7
  90. package/dist/host/io.js +1 -11
  91. package/dist/host/lifetime.js +1 -79
  92. package/dist/host/located.js +6 -105
  93. package/dist/host/native/authority-card-view.js +5 -0
  94. package/dist/host/native/authority-card.js +1 -0
  95. package/dist/host/native/bounded-file.js +1 -32
  96. package/dist/host/native/command.js +1 -91
  97. package/dist/host/native/control-bridge-worker.js +2 -88
  98. package/dist/host/native/control-bridge.js +1 -110
  99. package/dist/host/native/control-selection.js +1 -32
  100. package/dist/host/native/custody.js +1 -91
  101. package/dist/host/native/deadline.js +1 -28
  102. package/dist/host/native/descendants.js +1 -528
  103. package/dist/host/native/generated-custodian.js +5 -267
  104. package/dist/host/native/generated.js +1 -379
  105. package/dist/host/native/image.js +1 -45
  106. package/dist/host/native/installed-package.d.ts +1 -0
  107. package/dist/host/native/installed-package.js +5 -0
  108. package/dist/host/native/jobs.js +2 -148
  109. package/dist/host/native/loader.js +1 -269
  110. package/dist/host/native/materialize.js +1 -175
  111. package/dist/host/native/module-closure.js +1 -130
  112. package/dist/host/native/module-delivery.d.ts +1 -62
  113. package/dist/host/native/module-delivery.js +1 -151
  114. package/dist/host/native/module-inventory.js +2 -0
  115. package/dist/host/native/module-syntax.js +1 -69
  116. package/dist/host/native/native-binary.js +1 -115
  117. package/dist/host/native/native-program.js +1 -72
  118. package/dist/host/native/node-jobs.js +3 -187
  119. package/dist/host/native/node-launch.js +1 -159
  120. package/dist/host/native/preload.js +1 -45
  121. package/dist/host/native/probes.js +1 -0
  122. package/dist/host/native/reading-witness-admission.js +5 -0
  123. package/dist/host/native/reading.js +1 -249
  124. package/dist/host/native/receipt-environment.js +1 -41
  125. package/dist/host/native/references.js +1 -30
  126. package/dist/host/native/root.js +1 -37
  127. package/dist/host/native/route.js +1 -216
  128. package/dist/host/native/runtime.js +1 -9
  129. package/dist/host/native-place-state.js +1 -0
  130. package/dist/host/native-reader-context.js +1 -8
  131. package/dist/host/native-receiver.js +1 -25
  132. package/dist/host/objects.js +1 -38
  133. package/dist/host/order.js +1 -2
  134. package/dist/host/persistent-host.js +1 -0
  135. package/dist/host/physical-lines.d.ts +1 -0
  136. package/dist/host/physical-lines.js +1 -0
  137. package/dist/host/place-act-transaction.js +4 -78
  138. package/dist/host/place-clock-selection.js +5 -124
  139. package/dist/host/ports/ingress.js +2 -57
  140. package/dist/host/ports/local-act.js +5 -183
  141. package/dist/host/ports/place-act.js +1 -134
  142. package/dist/host/ports/publication.js +1 -56
  143. package/dist/host/ports/signing.js +1 -74
  144. package/dist/host/ports/store.js +1 -18
  145. package/dist/host/ports/transport.js +1 -48
  146. package/dist/host/process-lifetime.js +1 -17
  147. package/dist/host/profile-composition.d.ts +1 -0
  148. package/dist/host/profile-composition.js +2 -0
  149. package/dist/host/provide.js +1 -183
  150. package/dist/host/read-only.js +1 -9
  151. package/dist/host/reading-closures.js +7 -227
  152. package/dist/host/reading-context.js +1 -53
  153. package/dist/host/reading-identity-types.js +0 -0
  154. package/dist/host/reading-identity.js +3 -0
  155. package/dist/host/reading-preparation.js +6 -0
  156. package/dist/host/reference-authenticated.d.ts +1 -40
  157. package/dist/host/reference-authenticated.js +3 -100
  158. package/dist/host/reference-contracts.js +1 -6
  159. package/dist/host/reference-export.js +6 -81
  160. package/dist/host/reference-native-api.d.ts +1 -3
  161. package/dist/host/reference-native-api.js +1 -3
  162. package/dist/host/reference-native.js +1 -74
  163. package/dist/host/reference-profile.js +1 -63
  164. package/dist/host/reference-standing.js +2 -18
  165. package/dist/host/reference.js +1 -24
  166. package/dist/host/refusals.js +2 -43
  167. package/dist/host/release.js +4 -256
  168. package/dist/host/root-clock-source.js +1 -307
  169. package/dist/host/selected-capsules.js +1 -50
  170. package/dist/host/selected-topos.js +1 -80
  171. package/dist/host/signature-era.js +1 -12
  172. package/dist/host/signing.js +2 -48
  173. package/dist/host/source-content.js +2 -111
  174. package/dist/host/standing-carrier.js +1 -18
  175. package/dist/host/standing-projection.js +1 -50
  176. package/dist/host/timing.js +1 -7
  177. package/dist/host/walk.js +20 -193
  178. package/dist/host/work-trace.js +1 -0
  179. package/dist/judge/late.js +1 -33
  180. package/dist/judge/take.js +2 -75
  181. package/dist/judge/widening.js +1 -25
  182. package/dist/land/act.js +8 -336
  183. package/dist/land/alias.js +1 -41
  184. package/dist/land/held.js +1 -23
  185. package/dist/land/inert.js +1 -33
  186. package/dist/land/leaving.js +1 -55
  187. package/dist/land/ledger.js +6 -188
  188. package/dist/land/owned.js +4 -66
  189. package/dist/land/sign.js +1 -53
  190. package/dist/land/standing-pin.js +1 -49
  191. package/dist/land/vouched.js +1 -112
  192. package/dist/land/withdraw.js +1 -24
  193. package/dist/observe/files.js +1 -88
  194. package/dist/observe/identity.js +1 -61
  195. package/dist/observe/match.js +1 -8
  196. package/dist/observe/regions.js +7 -306
  197. package/dist/observe/run.js +1 -41
  198. package/dist/observe/runner.js +4 -101
  199. package/dist/public-types.d.ts +2019 -0
  200. package/dist/render/capsule.js +1 -30
  201. package/dist/render/field.js +1 -40
  202. package/dist/render/names.js +1 -4
  203. package/dist/render/open.js +1 -61
  204. package/dist/render/page.js +1 -7
  205. package/dist/render/receipt-projection.js +1 -0
  206. package/dist/render/receipts.js +1 -47
  207. package/dist/render/shape.js +1 -74
  208. package/dist/render/target.js +4 -52
  209. package/dist/render/view.js +7 -197
  210. package/dist/vendor/bundle.json +1 -0
  211. package/dist/vendor/library14.js +1 -0
  212. package/dist/vendor/object-provider.js +42 -0
  213. package/dist/vendor/runtime.js +61 -0
  214. package/dist/wasm/adapter.d.ts +1 -51
  215. package/dist/wasm/adapter.js +1 -180
  216. package/dist/wasm/node-worker.js +1 -13
  217. package/dist/wasm/object.js +1 -76
  218. package/dist/wasm/worker.js +1 -7
  219. package/docs/contracts/authenticated-reference.publication.json +1 -1
  220. package/docs/contracts/authority-preflight.md +17 -0
  221. package/docs/contracts/authority-preflight.publication.json +25 -0
  222. package/docs/contracts/closure-delivery.md +1 -1
  223. package/docs/contracts/closure-delivery.publication.json +1 -1
  224. package/docs/contracts/conformance.json +142 -0
  225. package/docs/contracts/determinism.bound +9 -0
  226. package/docs/contracts/engine-object-projection.publication.json +1 -1
  227. package/docs/contracts/engine.md +21 -1
  228. package/docs/contracts/installed-package.md +21 -0
  229. package/docs/contracts/installed-package.publication.json +25 -0
  230. package/docs/contracts/materialized-leaf-sequence.md +15 -0
  231. package/docs/contracts/materialized-leaf-sequence.publication.json +25 -0
  232. package/docs/contracts/module-inventory.md +15 -0
  233. package/docs/contracts/module-inventory.publication.json +25 -0
  234. package/docs/contracts/native-host.md +29 -1
  235. package/docs/contracts/native-host.publication.json +4 -4
  236. package/docs/contracts/native-probes.md +13 -0
  237. package/docs/contracts/native-probes.publication.json +25 -0
  238. package/docs/contracts/native-publication.inventory.json +10 -1
  239. package/docs/contracts/native-view-batch.md +17 -0
  240. package/docs/contracts/native-view-batch.publication.json +25 -0
  241. package/docs/contracts/optional-wasm-adapter.publication.json +1 -1
  242. package/docs/contracts/physical-lines.md +19 -0
  243. package/docs/contracts/physical-lines.publication.json +25 -0
  244. package/docs/contracts/profile-composition.md +17 -0
  245. package/docs/contracts/profile-composition.publication.json +25 -0
  246. package/docs/contracts/profile-preparation-native-meaning.md +9 -0
  247. package/docs/contracts/publication.md +12 -0
  248. package/docs/contracts/reading-identity.md +61 -0
  249. package/docs/contracts/reading-identity.publication.json +25 -0
  250. package/docs/contracts/reading-witness-admission.md +49 -0
  251. package/docs/contracts/readme.publication.json +1 -1
  252. package/docs/contracts/reference-port.md +11 -0
  253. package/docs/contracts/reference-port.publication.json +1 -1
  254. package/docs/contracts/refusals.bound +346 -94
  255. package/docs/contracts/refusals.md +119 -39
  256. package/docs/contracts/refusals.publication.json +2 -2
  257. package/docs/contracts/views.md +8 -0
  258. package/docs/reference.md +9 -0
  259. package/licenses/wasm/{fast-text-encoding.txt → NOTICE.txt} +111 -0
  260. package/package.json +84 -34
  261. package/receipts.bound +12952 -10449
  262. package/samples/authority-preflight/no.json +6 -0
  263. package/samples/authority-preflight/yes.json +30 -0
  264. package/samples/engine-alphabet/reader.js +3 -1457
  265. package/samples/engine-alphabet/receipts.bound +7 -7
  266. package/samples/engine-interval/reader.js +3 -1457
  267. package/samples/engine-interval/receipts.bound +7 -7
  268. package/samples/installed-package/consumer.mjs +29 -0
  269. package/samples/installed-package/fixture.json +48 -0
  270. package/samples/installed-package/no.json +10 -0
  271. package/samples/installed-package/yes.json +52 -0
  272. package/samples/materialized-leaf-sequence/no.json +11 -0
  273. package/samples/materialized-leaf-sequence/yes.json +10 -0
  274. package/samples/module-inventory/yes.json +28 -0
  275. package/samples/native/physical-line-reader.mjs +1 -0
  276. package/samples/native/physical-line-reader.source.mjs +13 -0
  277. package/samples/native-host/no.json +6 -1
  278. package/samples/native-host/yes.json +18 -1
  279. package/samples/native-probes/inputs/inspection.json +28 -0
  280. package/samples/native-probes/no.json +7 -0
  281. package/samples/native-probes/yes.json +28 -0
  282. package/samples/native-view-batch/no.json +14 -0
  283. package/samples/native-view-batch/yes.json +10 -0
  284. package/samples/no/engine-order/reader.js +3 -1457
  285. package/samples/no/module-inventory/no.json +10 -0
  286. package/samples/physical-lines/no.json +5 -0
  287. package/samples/physical-lines/yes.json +9 -0
  288. package/samples/profile-composition/no.json +6 -0
  289. package/samples/profile-composition/yes.json +14 -0
  290. package/samples/reading-identity/no.json +26 -0
  291. package/samples/reading-identity/yes.json +69 -0
  292. package/vectors/native/authority-preflight.vector.json +55 -0
  293. package/vectors/native/installed-package.vector.json +31 -0
  294. package/vectors/native/materialized-leaf-sequence.vector.json +31 -0
  295. package/vectors/native/module-inventory.vector.json +56 -0
  296. package/vectors/native/native-host.vector.json +214 -0
  297. package/vectors/native/native-probes.vector.json +31 -0
  298. package/vectors/native/native-view-batch.vector.json +31 -0
  299. package/vectors/native/physical-lines.vector.json +105 -0
  300. package/vectors/native/profile-composition.vector.json +53 -0
  301. package/vectors/native/reading-identity.vector.json +139 -0
  302. package/vectors/native/refusals.vector.json +138 -0
  303. package/vendor/syntax/LICENSE.md +7 -0
  304. package/vendor/syntax/parser.js +1 -0
  305. package/.github/workflows/release.yml +0 -67
  306. package/.github/workflows/test.yml +0 -35
  307. package/dist/engine/object.d.ts +0 -17
  308. package/dist/engine/ports.d.ts +0 -37
  309. package/dist/fold/claims.d.ts +0 -29
  310. package/dist/host/call-context.d.ts +0 -20
  311. package/dist/host/commit-result.d.ts +0 -6
  312. package/dist/host/in-process-act.d.ts +0 -82
  313. package/dist/host/in-process-context.d.ts +0 -46
  314. package/dist/host/in-process-root.d.ts +0 -117
  315. package/dist/host/in-process.d.ts +0 -41
  316. package/dist/host/native/module-closure.d.ts +0 -35
  317. package/dist/host/native-receiver.d.ts +0 -19
  318. package/dist/host/place-act-transaction.d.ts +0 -24
  319. package/dist/host/place-clock-selection.d.ts +0 -55
  320. package/dist/host/ports/local-act.d.ts +0 -44
  321. package/dist/host/ports/place-act.d.ts +0 -49
  322. package/dist/host/ports/publication.d.ts +0 -10
  323. package/dist/host/reference-export.d.ts +0 -33
  324. package/dist/host/reference-native.d.ts +0 -30
  325. package/dist/host/reference-profile.d.ts +0 -23
  326. package/dist/host/refusals.d.ts +0 -14
  327. package/dist/host/root-clock-source.d.ts +0 -86
  328. package/licenses/wasm/jitl-quickjs-ffi-types.txt +0 -21
  329. package/licenses/wasm/jitl-quickjs-wasmfile-release-sync.txt +0 -47
  330. package/licenses/wasm/quickjs-emscripten-core.txt +0 -21
  331. package/licenses/wasm/topos.txt +0 -21
  332. /package/{licenses/wasm/bound.txt → dist/vendor/28cba430228db1c04f446c93f81b09a2705d6bf3e222d35adbe5a4cee4061884.LICENSE} +0 -0
  333. /package/{licenses/wasm/obligations.txt → dist/vendor/7aca161279d14bc0e054dcc281cd110aeb95be2e026b42fdf527a260e58b2aae.LICENSE} +0 -0
@@ -1,83 +1 @@
1
- import { selectedCapsules } from "../host/selected-capsules.js";
2
- import { basename } from "../host/io.js";
3
- import { canonical, matches, parse } from '@lapxo/topos/wire';
4
- import { fieldOf } from "./claims.js";
5
- import { spoken, worldsIn } from "./places.js";
6
- import { wordOf, wordsOf } from "./wire.js";
7
- import { ownLock, ownRoot } from "../observe/runner.js";
8
- import { ownLockOf } from "./signed.js";
9
- const ROOT = '.';
10
- const WORLD = '\0';
11
- /**
12
- * Who reads a line: the place its scope's first step names, or the one place its needs lie in but bound; every place for
13
- * a line an own lock speaks, the published place bound is measured over, a line publish/takes carries into every place,
14
- * a view, and a line whose needs are bound's own modules; the one place a later step of its scope names; and the root
15
- * alone, where the places join, for every other line: no place's pages read it.
16
- */
17
- function ownerIn(root, places, standing) {
18
- const own = basename(ownRoot());
19
- const words = new Set(spoken(root).map((one) => one.line));
20
- const views = `${wordOf(standing, 'families', 'view')}/`;
21
- const takes = ownLock().filter((line) => fieldOf(line, 'scope') === 'publish/takes').flatMap((line) => fieldOf(line, 'value').split('|').filter(Boolean));
22
- return (line) => {
23
- const scope = fieldOf(line, 'scope');
24
- if (words.has(line))
25
- return undefined;
26
- const steps = scope.split('/');
27
- if (places.includes(steps[0] ?? ''))
28
- return steps[0];
29
- const heads = new Set(fieldOf(line, 'needs').split('|').filter(Boolean).map((need) => need.split('/')[0] ?? ''));
30
- const head = [...heads][0] ?? '';
31
- if (heads.size === 1 && head !== own && places.includes(head))
32
- return head;
33
- if (scope.startsWith(views))
34
- return wordsOf(standing, 'views/world').includes(scope.slice(views.length)) ? WORLD : undefined;
35
- if (takes.some((glob) => matches(glob, scope)))
36
- return undefined;
37
- const named = places.filter((one) => steps.slice(1).includes(one));
38
- if (named.length)
39
- return named.length === 1 ? named[0] : undefined;
40
- return heads.size && [...heads].every((one) => one === own) ? undefined : ROOT;
41
- };
42
- }
43
- export const placedAt = (places, line) => {
44
- const [first = '', next = ''] = fieldOf(line, 'scope').split('/');
45
- return places.includes(first) ? first : places.includes(next) ? next : undefined;
46
- };
47
- export function touchedBy(root, places, lines, standing) {
48
- const owners = lines.map(ownerIn(root, places, standing));
49
- if (owners.some((one) => one === undefined))
50
- return places;
51
- const worlds = owners.some((one) => one === WORLD) ? worldsIn(root) : [];
52
- return [...new Set([...owners.filter((one) => one !== undefined && one !== ROOT && one !== WORLD), ...worlds])].sort();
53
- }
54
- /** A selected world can execute only its explicit capsule offers. Dependency aliases are host projections, not selections. */
55
- export const selectionLines = (fold) => {
56
- const local = fold.under ? ownLockOf(fold.root, fold.under.replace(/\/$/, '')).filter((line) => fieldOf(line, 'scope').startsWith('uses/')) : [];
57
- const qualified = fold.standing.filter((line) => fieldOf(line, 'scope').startsWith(`${fold.under ?? ''}uses/`));
58
- return [...new Set([...local, ...qualified])].filter((line) => fieldOf(line, 'value') !== 'withdraw');
59
- };
60
- /** Host bindings belong to the selected place, never to another sibling's lock. */
61
- const relativeProjections = (standing, prefix) => standing.filter(line => fieldOf(line, 'scope').startsWith(`${prefix}dep/`)).map(line => {
62
- const got = parse(line, { preserveKeys: true });
63
- if (got.kind !== 'fact')
64
- throw Error(`REFUSE·wire ${got.why}`);
65
- // An unsigned host projection of admitted fields, never a newly signed claim.
66
- const { sig, by, epoch, expires, repo, ...fields } = got.value.fields;
67
- return canonical({ ...fields, scope: fields.scope.slice(prefix.length) }, got.value.version);
68
- });
69
- export const projectionLines = (fold) => {
70
- const place = fold.under?.replace(/\/$/, '') ?? '';
71
- const prefix = place ? `${place}/` : '';
72
- const local = ownLockOf(fold.root, place).filter(line => fieldOf(line, 'scope').startsWith('dep/'));
73
- const qualified = relativeProjections(fold.standing, prefix);
74
- return [...new Set([...ownLock(), ...local, ...qualified])];
75
- };
76
- export function capsulesFor(standing, place, root) {
77
- const prefix = place ? `${place}/` : '';
78
- const pins = root === undefined ? standing.filter(line => fieldOf(line, 'scope').startsWith(`${prefix}uses/`) && fieldOf(line, 'value') !== 'withdraw')
79
- : selectionLines({ root, standing, ...(prefix ? { under: prefix } : {}) });
80
- const host = root === undefined ? [...ownLock(), ...relativeProjections(standing, prefix)]
81
- : projectionLines({ root, standing, ...(prefix ? { under: prefix } : {}) });
82
- return selectedCapsules(pins, undefined, undefined, host);
83
- }
1
+ var O=Object.defineProperty;var l=(t,s)=>O(t,"name",{value:s,configurable:!0});import{selectedCapsules as W}from"../host/selected-capsules.js";import{basename as b}from"../host/io.js";import{library14_canonical as k,library14_matches as S,library14_parse as L}from"../vendor/runtime.js";import{fieldOf as o}from"./claims.js";import{spoken as g,worldsIn as R}from"./places.js";import{wordOf as B,wordsOf as E}from"./wire.js";import{ownLock as h,ownRoot as _}from"../observe/runner.js";import{ownLockOf as $}from"./signed.js";const x=".",v="\0";function j(t,s,n){const e=b(_()),i=new Set(g(t).map(c=>c.line)),u=`${B(n,"families","view")}/`,r=h().filter(c=>o(c,"scope")==="publish/takes").flatMap(c=>o(c,"value").split("|").filter(Boolean));return c=>{const a=o(c,"scope");if(i.has(c))return;const f=a.split("/");if(s.includes(f[0]??""))return f[0];const p=new Set(o(c,"needs").split("|").filter(Boolean).map(d=>d.split("/")[0]??"")),m=[...p][0]??"";if(p.size===1&&m!==e&&s.includes(m))return m;if(a.startsWith(u))return E(n,"views/world").includes(a.slice(u.length))?v:void 0;if(r.some(d=>S(d,a)))return;const w=s.filter(d=>f.slice(1).includes(d));return w.length?w.length===1?w[0]:void 0:p.size&&[...p].every(d=>d===e)?void 0:x}}l(j,"ownerIn");const U=l((t,s)=>{const[n="",e=""]=o(s,"scope").split("/");return t.includes(n)?n:t.includes(e)?e:void 0},"placedAt");function G(t,s,n,e){const i=n.map(j(t,s,e));if(i.some(r=>r===void 0))return s;const u=i.some(r=>r===v)?R(t):[];return[...new Set([...i.filter(r=>r!==void 0&&r!==x&&r!==v),...u])].sort()}l(G,"touchedBy");const q=l(t=>{const s=t.under?$(t.root,t.under.replace(/\/$/,"")).filter(e=>o(e,"scope").startsWith("uses/")):[],n=t.standing.filter(e=>o(e,"scope").startsWith(`${t.under??""}uses/`));return[...new Set([...s,...n])].filter(e=>o(e,"value")!=="withdraw")},"selectionLines"),y=l((t,s)=>t.filter(n=>o(n,"scope").startsWith(`${s}dep/`)).map(n=>{const e=L(n,{preserveKeys:!0});if(e.kind!=="fact")throw Error(`REFUSE\xB7wire ${e.why}`);const{sig:i,by:u,epoch:r,expires:c,repo:a,...f}=e.value.fields;return k({...f,scope:f.scope.slice(s.length)},e.value.version)}),"relativeProjections"),z=l(t=>{const s=t.under?.replace(/\/$/,"")??"",n=s?`${s}/`:"",e=$(t.root,s).filter(u=>o(u,"scope").startsWith("dep/")),i=y(t.standing,n);return[...new Set([...h(),...e,...i])]},"projectionLines");function H(t,s,n){const e=s?`${s}/`:"",i=n===void 0?t.filter(r=>o(r,"scope").startsWith(`${e}uses/`)&&o(r,"value")!=="withdraw"):q({root:n,standing:t,...e?{under:e}:{}}),u=n===void 0?[...h(),...y(t,e)]:z({root:n,standing:t,...e?{under:e}:{}});return W(i,void 0,void 0,u)}l(H,"capsulesFor");export{H as capsulesFor,U as placedAt,z as projectionLines,q as selectionLines,G as touchedBy};
@@ -1,142 +1,6 @@
1
- import { resolve } from "../host/io.js";
2
- import { canonical, fields, matches, byBytes } from '@lapxo/topos/wire';
3
- import { namesAt, wordOn, wordsOf, wireLine } from "./wire.js";
4
- import { fits } from "../observe/match.js";
5
- import { bytesDigest, coordinateDigest } from "./digests.js";
6
- import { fieldOf } from "./claims.js";
7
- import { capsuleAt, placesIn } from "./places.js";
8
- import { capsulesFor } from "./reach.js";
9
- import { ownLockOf } from "./signed.js";
10
- import { ownLock } from "../observe/runner.js";
11
- import { selectedWireList } from "../host/selected-topos.js";
12
- import { entriesIn, coordinatesUnder, observeFile, stampOf } from "../observe/files.js";
13
- export function lookOf(root, roleOf) {
14
- const walked = new Map();
15
- const stamped = new Map();
16
- return {
17
- under: (dir, pruned) => walked.get(`${pruned} ${dir}`) ?? walked.set(`${pruned} ${dir}`, coordinatesUnder(dir, root, pruned ? (one) => roleOf(one) !== 'foreign' : undefined)).get(`${pruned} ${dir}`),
18
- stamp: (at) => stamped.get(at) ?? stamped.set(at, stampOf(at)?.stamp ?? '').get(at),
19
- };
20
- }
21
- function entriesOf(root, where, roleOf) {
22
- const dir = where.replace(/\/?$/, '/');
23
- const at = resolve(root, dir);
24
- if (stampOf(at)?.kind !== 'dir')
25
- return undefined;
26
- const names = entriesIn(at)
27
- .filter((entry) => roleOf(`${dir}${entry.name}`) === 'source')
28
- .map((entry) => (entry.dir ? `${entry.name}/` : entry.name))
29
- .sort();
30
- return new TextEncoder().encode(names.join('\n'));
31
- }
32
- const reachOfLine = (module, where) => {
33
- const [pkg = '', ...rest] = module.split('/');
34
- const stem = (rest.at(-1) ?? '').replace(/\.[^.]+$/, '');
35
- return where.flatMap((one) => [`${pkg} ${stem} ${one.replace(/\/?$/, '/')}`, `${pkg} ${stem}s ${one.replace(/\/?$/, '/')}`]);
36
- };
37
- /**
38
- * The reader regions of the capsules a place can run, where the place's own lock offers them or, at a world, the wire's offers/world list does for a
39
- * region its own lock does not name: each selected capsule that writes a declared region reads the coordinates
40
- * it declares among the place's offered coordinates. Selection identifies attribution, never independence.
41
- * An existing reader suppresses only that same selected provider, region and place; an ambiguous legacy
42
- * owner refuses instead of hiding another provider or invoking the same provider twice.
43
- * A newly declared region does not need a retired reader in private history to be observed.
44
- */
45
- export function capsuleReadersOf(root, store, standing, lines, resolve = capsulesFor) {
46
- const origin = (capsule) => capsule?.selected?.selection;
47
- const coordinateMeasure = wordOn(standing, 'region-coordinate', ownLock());
48
- const localMeasures = wordsOf(standing, 'region-measures');
49
- const pins = standing.filter(line => fieldOf(line, 'scope').startsWith('uses/') && fieldOf(line, 'value') !== 'withdraw');
50
- const measures = localMeasures.length || !pins.length ? localMeasures
51
- : selectedWireList(standing, Number.MAX_SAFE_INTEGER, pins, 'region-measures');
52
- const world = fields(fieldOf(wireLine(standing, 'offers/world') ?? '', 'value')).map(([region, globs]) => canonical({ scope: `region/${region}`, measure: wordOn(standing, 'region-coordinate', ownLock()), value: globs }));
53
- const groups = new Map();
54
- for (const place of ['', ...placesIn(root)]) {
55
- const where = place ? `${place}/` : '';
56
- const own = ownLockOf(root, place).filter((line) => fieldOf(line, 'scope').startsWith('region/') && measures.includes(fieldOf(line, 'measure')) && fieldOf(line, 'measure') === coordinateMeasure && fieldOf(line, 'value') !== 'withdraw');
57
- const offered = [...own, ...(capsuleAt(root, place) ? world.filter((line) => !own.some((one) => fieldOf(one, 'scope') === fieldOf(line, 'scope'))) : [])];
58
- if (!offered.length)
59
- continue;
60
- const capsules = resolve(standing, place, root);
61
- for (const line of offered) {
62
- const region = fieldOf(line, 'scope').slice('region/'.length);
63
- for (const by of capsules.filter(({ capsule }) => capsule.lines.some((one) => fieldOf(one, 'scope') === `region/${region}` && fieldOf(one, 'measure') === 'writes'))) {
64
- const pkg = fieldOf(by.offer, 'scope').split('/')[1] ?? '';
65
- const reaches = lines.filter(reader => reachOfLine(reader.module, reader.where).includes(`${pkg} ${region} ${where || '/'}`));
66
- if (reaches.some(reader => origin(reader.capsule) === undefined))
67
- throw Error(`REFUSE·reader ${pkg}/${region} existing provider origin unmeasured at ${where || '/'}`);
68
- if (by.capsule.selection !== undefined && lines.some(reader => origin(reader.capsule) === by.capsule.selection && reader.capsule?.region === region && reader.where.some(place => place.replace(/\/?$/, '/') === (where || '/'))))
69
- continue;
70
- const key = `${by.capsule.selection ?? by.capsule.digest} ${region}`;
71
- const group = groups.get(key) ?? groups.set(key, { module: `${pkg}/${region}`, digest: by.capsule.digest, entry: fieldOf(by.offer, 'shape'), selected: by.capsule, region, reads: by.capsule.declaration.regions[region] ?? [], globs: new Map() }).get(key);
72
- group.globs.set(where, fieldOf(line, 'value').split('|').filter(Boolean));
73
- }
74
- }
75
- }
76
- return [...groups.entries()].sort(([a], [b]) => byBytes(a, b)).map(([, group]) => ({ id: group.module, shape: ['run'], where: [...group.globs.keys()], module: group.module, kind: 'process',
77
- capsule: { selected: group.selected, digest: group.digest, entry: group.entry, region: group.region, reads: group.reads, globs: group.globs } }));
78
- }
79
- export function handedAt(root, reader, roleOf, look, place) {
80
- const { reads, globs } = reader.capsule;
81
- const run = reads.some((read) => read.includes('@'));
82
- return look.under(resolve(root, place), true).filter((coordinate) => {
83
- const inside = coordinate.slice(place.length);
84
- return (!run || roleOf(coordinate) === 'source') && reads.some((read) => fits(read, inside)) && (globs.get(place) ?? []).some((glob) => matches(glob, inside));
85
- }).sort();
86
- }
87
- /**
88
- * What a reader is offered at the places it reads: a coordinate for a reader of coordinates, the listing for one that reads a
89
- * directory, and for one that runs over its place its sources and every coordinate its shape names besides — a coordinate a view
90
- * writes from what readers said is offered only when named, so no reading moves its own offer — each by the stamp it
91
- * was seen at and the bytes that key what it said; a capsule reader is offered the coordinates it is handed.
92
- */
93
- export function offersOf(root, store, reader, roleOf, look, into) {
94
- const offered = [];
95
- const wheres = reader.where.filter(into);
96
- if (reader.capsule !== undefined && reader.capsule.reads.some((read) => read.includes('@'))) {
97
- for (const where of wheres) {
98
- const held = handedAt(root, reader, roleOf, look, where);
99
- const stamps = held.map((coordinate) => `${coordinate} ${look.stamp(resolve(root, coordinate))}`).join('\n');
100
- offered.push({
101
- place: where,
102
- seen: bytesDigest(store, new TextEncoder().encode(stamps)).replace(/^[^:]*:/, '').slice(0, 16),
103
- bytes: () => new TextEncoder().encode(held.map((coordinate) => `${coordinate} ${coordinateDigest(store, resolve(root, coordinate)) ?? bytesDigest(store, new Uint8Array())}`).join('\n')),
104
- });
105
- }
106
- }
107
- else if (reader.capsule !== undefined) {
108
- for (const coordinate of [...new Set(wheres.flatMap((where) => handedAt(root, reader, roleOf, look, where)))].sort()) {
109
- offered.push({ place: coordinate, seen: look.stamp(resolve(root, coordinate)), bytes: () => observeFile(resolve(root, coordinate)) ?? new Uint8Array(), digest: () => coordinateDigest(store, resolve(root, coordinate)) ?? bytesDigest(store, new Uint8Array()) });
110
- }
111
- }
112
- else if (reader.kind === 'process') {
113
- for (const where of wheres) {
114
- const dir = resolve(root, where);
115
- if (stampOf(dir)?.kind !== 'dir')
116
- continue;
117
- const held = look.under(dir, true).filter((coordinate) => roleOf(coordinate) === 'source' || (roleOf(coordinate) !== 'foreign' && reader.shape.some((name) => namesAt(coordinate, name) || fits(name, coordinate)))).sort();
118
- const stamps = held.map((coordinate) => `${coordinate} ${look.stamp(resolve(root, coordinate))}`).join('\n');
119
- offered.push({
120
- place: where.replace(/\/?$/, '/'),
121
- seen: bytesDigest(store, new TextEncoder().encode(stamps)).replace(/^[^:]*:/, '').slice(0, 16),
122
- bytes: () => new TextEncoder().encode(held.map((coordinate) => `${coordinate} ${coordinateDigest(store, resolve(root, coordinate)) ?? bytesDigest(store, new Uint8Array())}`).join('\n')),
123
- });
124
- }
125
- }
126
- else if (reader.shape.some((name) => name.endsWith('/'))) {
127
- for (const where of wheres) {
128
- const listed = entriesOf(root, where, roleOf);
129
- if (listed)
130
- offered.push({ place: where.replace(/\/?$/, '/'), seen: bytesDigest(store, listed).replace(/^[^:]*:/, '').slice(0, 16), bytes: () => listed });
131
- }
132
- }
133
- else {
134
- const paths = wheres.flatMap((where) => look.under(resolve(root, where), true));
135
- for (const path of [...new Set(paths)].sort()) {
136
- if (!reader.shape.some((name) => namesAt(path, name)))
137
- continue;
138
- offered.push({ place: path, seen: look.stamp(resolve(root, path)), bytes: () => observeFile(resolve(root, path)) ?? new Uint8Array(), digest: () => coordinateDigest(store, resolve(root, path)) ?? bytesDigest(store, new Uint8Array()) });
139
- }
140
- }
141
- return offered;
142
- }
1
+ var I=Object.defineProperty;var p=(s,i)=>I(s,"name",{value:i,configurable:!0});import{resolve as u}from"../host/io.js";import{library14_canonical as R,library14_fields as D,library14_matches as N,library14_byBytes as G}from"../vendor/runtime.js";import{namesAt as _,wordOn as j,wordsOf as X,wireLine as q}from"./wire.js";import{fits as k}from"../observe/match.js";import{bytesDigest as A,coordinateDigest as x}from"./digests.js";import{fieldOf as f}from"./claims.js";import{capsuleAt as z,placesIn as C}from"./places.js";import{capsulesFor as H}from"./reach.js";import{ownLockOf as J}from"./signed.js";import{ownLock as L}from"../observe/runner.js";import{selectedWireList as K}from"../host/selected-topos.js";import{entriesIn as P,coordinatesUnder as Q,observeFile as F,stampOf as U}from"../observe/files.js";function me(s,i){const t=new Map,o=new Map;return{under:p((n,l)=>t.get(`${l} ${n}`)??t.set(`${l} ${n}`,Q(n,s,l?a=>i(a)!=="foreign":void 0)).get(`${l} ${n}`),"under"),stamp:p(n=>o.get(n)??o.set(n,U(n)?.stamp??"").get(n),"stamp")}}p(me,"lookOf");function V(s,i,t){const o=i.replace(/\/?$/,"/"),n=u(s,o);if(U(n)?.kind!=="dir")return;const l=P(n).filter(a=>t(`${o}${a.name}`)==="source").map(a=>a.dir?`${a.name}/`:a.name).sort();return new TextEncoder().encode(l.join(`
2
+ `))}p(V,"entriesOf");const Y=p((s,i)=>{const[t="",...o]=s.split("/"),n=(o.at(-1)??"").replace(/\.[^.]+$/,"");return i.flatMap(l=>[`${t} ${n} ${l.replace(/\/?$/,"/")}`,`${t} ${n}s ${l.replace(/\/?$/,"/")}`])},"reachOfLine");function de(s,i,t,o,n=H){const l=p(e=>e?.selected?.selection,"origin"),a=j(t,"region-coordinate",L()),w=X(t,"region-measures"),c=t.filter(e=>f(e,"scope").startsWith("uses/")&&f(e,"value")!=="withdraw"),r=w.length||!c.length?w:K(t,Number.MAX_SAFE_INTEGER,c,"region-measures"),m=D(f(q(t,"offers/world")??"","value")).map(([e,$])=>R({scope:`region/${e}`,measure:j(t,"region-coordinate",L()),value:$})),d=new Map;for(const e of["",...C(s)]){const $=e?`${e}/`:"",O=J(s,e).filter(g=>f(g,"scope").startsWith("region/")&&r.includes(f(g,"measure"))&&f(g,"measure")===a&&f(g,"value")!=="withdraw"),T=[...O,...z(s,e)?m.filter(g=>!O.some(h=>f(h,"scope")===f(g,"scope"))):[]];if(!T.length)continue;const W=n(t,e,s);for(const g of T){const h=f(g,"scope").slice(7);for(const y of W.filter(({capsule:E})=>E.lines.some(M=>f(M,"scope")===`region/${h}`&&f(M,"measure")==="writes"))){const E=f(y.offer,"scope").split("/")[1]??"";if(o.filter(b=>Y(b.module,b.where).includes(`${E} ${h} ${$||"/"}`)).some(b=>l(b.capsule)===void 0))throw Error(`REFUSE\xB7reader ${E}/${h} existing provider origin unmeasured at ${$||"/"}`);if(y.capsule.selection!==void 0&&o.some(b=>l(b.capsule)===y.capsule.selection&&b.capsule?.region===h&&b.where.some(B=>B.replace(/\/?$/,"/")===($||"/"))))continue;const v=`${y.capsule.selection??y.capsule.digest} ${h}`;(d.get(v)??d.set(v,{module:`${E}/${h}`,digest:y.capsule.digest,entry:f(y.offer,"shape"),selected:y.capsule,region:h,reads:y.capsule.declaration.regions[h]??[],globs:new Map}).get(v)).globs.set($,f(g,"value").split("|").filter(Boolean))}}}return[...d.entries()].sort(([e],[$])=>G(e,$)).map(([,e])=>({id:e.module,shape:["run"],where:[...e.globs.keys()],module:e.module,kind:"process",capsule:{selected:e.selected,digest:e.digest,entry:e.entry,region:e.region,reads:e.reads,globs:e.globs}}))}p(de,"capsuleReadersOf");function S(s,i,t,o,n){const{reads:l,globs:a}=i.capsule,w=l.some(c=>c.includes("@"));return o.under(u(s,n),!0).filter(c=>{const r=c.slice(n.length);return(!w||t(c)==="source")&&l.some(m=>k(m,r))&&(a.get(n)??[]).some(m=>N(m,r))}).sort()}p(S,"handedAt");function $e(s,i,t,o,n,l){const a=[],w=t.where.filter(l);if(t.capsule!==void 0&&t.capsule.reads.some(c=>c.includes("@")))for(const c of w){const r=S(s,t,o,n,c),m=r.map(d=>`${d} ${n.stamp(u(s,d))}`).join(`
3
+ `);a.push({place:c,seen:A(i,new TextEncoder().encode(m)).replace(/^[^:]*:/,"").slice(0,16),bytes:p(()=>new TextEncoder().encode(r.map(d=>`${d} ${x(i,u(s,d))??A(i,new Uint8Array)}`).join(`
4
+ `)),"bytes")})}else if(t.capsule!==void 0)for(const c of[...new Set(w.flatMap(r=>S(s,t,o,n,r)))].sort())a.push({place:c,seen:n.stamp(u(s,c)),bytes:p(()=>F(u(s,c))??new Uint8Array,"bytes"),digest:p(()=>x(i,u(s,c))??A(i,new Uint8Array),"digest")});else if(t.kind==="process")for(const c of w){const r=u(s,c);if(U(r)?.kind!=="dir")continue;const m=n.under(r,!0).filter(e=>o(e)==="source"||o(e)!=="foreign"&&t.shape.some($=>_(e,$)||k($,e))).sort(),d=m.map(e=>`${e} ${n.stamp(u(s,e))}`).join(`
5
+ `);a.push({place:c.replace(/\/?$/,"/"),seen:A(i,new TextEncoder().encode(d)).replace(/^[^:]*:/,"").slice(0,16),bytes:p(()=>new TextEncoder().encode(m.map(e=>`${e} ${x(i,u(s,e))??A(i,new Uint8Array)}`).join(`
6
+ `)),"bytes")})}else if(t.shape.some(c=>c.endsWith("/")))for(const c of w){const r=V(s,c,o);r&&a.push({place:c.replace(/\/?$/,"/"),seen:A(i,r).replace(/^[^:]*:/,"").slice(0,16),bytes:p(()=>r,"bytes")})}else{const c=w.flatMap(r=>n.under(u(s,r),!0));for(const r of[...new Set(c)].sort())t.shape.some(m=>_(r,m))&&a.push({place:r,seen:n.stamp(u(s,r)),bytes:p(()=>F(u(s,r))??new Uint8Array,"bytes"),digest:p(()=>x(i,u(s,r))??A(i,new Uint8Array),"digest")})}return a}p($e,"offersOf");export{de as capsuleReadersOf,S as handedAt,me as lookOf,$e as offersOf};
@@ -1,47 +1 @@
1
- import { join } from "../host/io.js";
2
- import { wordOf } from "./wire.js";
3
- import { ledgerLines, storeAt } from "../land/ledger.js";
4
- import { lockStanding } from "./keys.js";
5
- import { fieldOf } from "./claims.js";
6
- import { entriesIn, exists, observeText } from "../observe/files.js";
7
- /** The writer of the index that names, per scope, the receipts judged before the ledger existed. */
8
- /** The receipt files the session index names for these scopes; without scopes, every receipt file. The index is a ledger. */
9
- function receiptNames(store, dir, scopes) {
10
- if (!scopes)
11
- return entriesIn(dir).map((entry) => entry.name);
12
- const wanted = new Set(ledgerLines(store, wordOf(lockStanding(store), 'families', 'session'))
13
- .filter((line) => scopes.includes(fieldOf(line, 'scope')))
14
- .map((line) => fieldOf(line, 'value').replace(/^sha256:/, '')));
15
- return [...wanted].flatMap((hex) => [`${hex}.json`, `sha256:${hex}.json`]).filter((name) => exists(join(dir, name)));
16
- }
17
- export function receiptsIn(store, scopes) {
18
- const out = [];
19
- const dir = storeAt(store, 'cas', 'receipts');
20
- for (const name of receiptNames(store, dir, scopes)) {
21
- if (!/^(sha256:)?[0-9a-f]{64}\.json$/.test(name))
22
- continue;
23
- const parsed = JSON.parse(observeText(join(dir, name)) ?? '{}');
24
- const r = parsed.receipt;
25
- if (r?.kind !== 'fact')
26
- continue;
27
- const floor = typeof r.floor === 'string' ? r.floor : r.floor?.scope ?? '';
28
- if (!floor)
29
- continue;
30
- const moved = Array.isArray(r.moved) ? r.moved.filter((m) => typeof m === 'string') : [];
31
- out.push({ scope: floor.replace(/\.(status|count|id|ms|order|kind)$/, ''), digest: name.replace(/\.json$/, ''), moved });
32
- }
33
- for (const line of ledgerLines(store, 'judge')) {
34
- const at = fieldOf(line, 'at');
35
- if (fieldOf(line, 'value') !== 'present' || !at.startsWith('receipt:'))
36
- continue;
37
- if (scopes && !scopes.includes(fieldOf(line, 'scope')))
38
- continue;
39
- const digest = at.slice('receipt:'.length);
40
- const envelope = JSON.parse(observeText(storeAt(store, 'cas', 'envelopes', `${digest.slice(digest.indexOf(':') + 1)}.json`)) ?? '{}');
41
- const before = envelope.before ?? {};
42
- const after = envelope.after ?? {};
43
- const moved = [...new Set([...Object.keys(before), ...Object.keys(after)])].filter((coordinate) => before[coordinate] !== after[coordinate]);
44
- out.push({ scope: fieldOf(line, 'scope'), digest, moved });
45
- }
46
- return out;
47
- }
1
+ var O=Object.defineProperty;var l=(o,n)=>O(o,"name",{value:n,configurable:!0});import{join as d}from"../host/io.js";import{wordOf as h}from"./wire.js";import{ledgerLines as u,storeAt as j}from"../land/ledger.js";import{lockStanding as y}from"./keys.js";import{fieldOf as r}from"./claims.js";import{entriesIn as $,exists as b,observeText as v}from"../observe/files.js";function k(o,n,s){return s?[...new Set(u(o,h(y(o),"families","session")).filter(e=>s.includes(r(e,"scope"))).map(e=>r(e,"value").replace(/^sha256:/,"")))].flatMap(e=>[`${e}.json`,`sha256:${e}.json`]).filter(e=>b(d(n,e))):$(n).map(e=>e.name)}l(k,"receiptNames");function L(o,n){const s=[],a=j(o,"cas","receipts");for(const e of k(o,a,n)){if(!/^(sha256:)?[0-9a-f]{64}\.json$/.test(e))continue;const t=JSON.parse(v(d(a,e))??"{}").receipt;if(t?.kind!=="fact")continue;const i=typeof t.floor=="string"?t.floor:t.floor?.scope??"";if(!i)continue;const c=Array.isArray(t.moved)?t.moved.filter(f=>typeof f=="string"):[];s.push({scope:i.replace(/\.(status|count|id|ms|order|kind)$/,""),digest:e.replace(/\.json$/,""),moved:c})}for(const e of u(o,"judge")){const p=r(e,"at");if(r(e,"value")!=="present"||!p.startsWith("receipt:")||n&&!n.includes(r(e,"scope")))continue;const t=p.slice(8),i=JSON.parse(v(j(o,"cas","envelopes",`${t.slice(t.indexOf(":")+1)}.json`))??"{}"),c=i.before??{},f=i.after??{},g=[...new Set([...Object.keys(c),...Object.keys(f)])].filter(m=>c[m]!==f[m]);s.push({scope:r(e,"scope"),digest:t,moved:g})}return s}l(L,"receiptsIn");export{L as receiptsIn};
@@ -1,13 +1 @@
1
- import { fieldOf, isConfig } from "./claims.js";
2
- import { wordsOf } from "./wire.js";
3
- /** Region input selectors consumed by the host, rather than measured ceilings. */
4
- export function isRegionDeclaration(line, wire) {
5
- if (!isConfig(line) || !fieldOf(line, 'scope').startsWith('region/') || fieldOf(line, 'value') === 'withdraw')
6
- return false;
7
- const named = ['region-coordinate', 'region-leaf'].flatMap(name => {
8
- const words = wordsOf(wire, name);
9
- return words.length === 1 ? words : [];
10
- });
11
- const measures = ['lines', 'receipts', 'reads', ...named];
12
- return measures.includes(fieldOf(line, 'measure'));
13
- }
1
+ var a=Object.defineProperty;var t=(e,r)=>a(e,"name",{value:r,configurable:!0});import{fieldOf as o,isConfig as i}from"./claims.js";import{wordsOf as f}from"./wire.js";function l(e,r){return!i(e)||!o(e,"scope").startsWith("region/")||o(e,"value")==="withdraw"?!1:["lines","receipts","reads",...["region-coordinate","region-leaf"].flatMap(n=>{const s=f(r,n);return s.length===1?s:[]})].includes(o(e,"measure"))}t(l,"isRegionDeclaration");export{l as isRegionDeclaration};
@@ -1,286 +1,8 @@
1
- import { createHash } from "../host/io.js";
2
- import { alphabetForm } from '@lapxo/obligations/forms';
3
- import { cell, parts, sign } from '@lapxo/obligations/views/field';
4
- import { point, region as coordinates, within } from '@lapxo/obligations/field';
5
- import { matches, parse, roleClaimsOf } from '@lapxo/topos/wire';
6
- import { fieldOf } from "./claims.js";
7
- import { INTERVALS, spanOf } from '@lapxo/topos/forms';
8
- const trimmed = (prefix) => prefix.replace(/(?:\/\*\*|\/\*|\/)+$/, '');
9
- const globbed = (prefix) => prefix.includes('*');
10
- export function regionsNamed(standing) {
11
- const out = new Set(['']);
12
- for (const line of standing) {
13
- if (fieldOf(line, 'value') === 'withdraw')
14
- continue;
15
- const scope = fieldOf(line, 'scope');
16
- const got = ['role', 'paths'].includes(fieldOf(line, 'measure')) ? parse(line) : undefined;
17
- const roled = got?.kind === 'fact' ? roleClaimsOf([got.value.fields]).map((claim) => claim.name) : [];
18
- const said = roled.length ? roled
19
- : scope.startsWith('dir/') ? [scope.slice('dir/'.length)]
20
- : scope.startsWith('region/') && fieldOf(line, 'res') ? [fieldOf(line, 'value')] : [];
21
- for (const prefix of [...said, ...fieldOf(line, 'needs').split('|')].map(trimmed))
22
- if (prefix && !globbed(prefix))
23
- out.add(prefix);
24
- }
25
- return [...out].sort();
26
- }
27
- function restsOn(named, prefix) {
28
- let best = '';
29
- for (const one of named)
30
- if (one.length > best.length && one !== prefix && prefix.startsWith(`${one}/`))
31
- best = one;
32
- return best;
33
- }
34
- function regionOf(named, place) {
35
- const at = trimmed(place);
36
- let best = '';
37
- for (const one of named)
38
- if (one.length > best.length && (at === one || at.startsWith(`${one}/`)))
39
- best = one;
40
- return best;
41
- }
42
- const names = (named, prefix) => (globbed(prefix) ? named.some((one) => matches(prefix, one)) : named.includes(prefix));
43
- export function boundOf(named, line) {
44
- const scope = fieldOf(line, 'scope');
45
- const steps = scope.split('/');
46
- const of = (question, region) => ({ line, question, region, measure: fieldOf(line, 'measure'), form: fieldOf(line, 'form'), value: fieldOf(line, 'value') });
47
- for (let i = 1; i < steps.length; i += 1) {
48
- const tail = trimmed(steps.slice(i).join('/'));
49
- if (tail && names(named, tail))
50
- return of(steps.slice(0, i).join('/'), tail);
51
- }
52
- for (let j = steps.length - 1; j > 0; j -= 1) {
53
- const head = steps.slice(0, j).join('/');
54
- if (names(named, head))
55
- return of(steps.slice(j).join('/'), head);
56
- }
57
- return of(scope, '');
58
- }
59
- function poleAt(named, region, bounds) {
60
- const chain = [];
61
- for (let at = region; !chain.includes(at); at = restsOn(named, at))
62
- chain.push(at);
63
- const signedIn = (L, spans) => {
64
- let world = new Map(chain.map((_, i) => [`c${i}`, cell(`c${i}`, 0, [], i + 1 < chain.length ? [`c${i + 1}`] : [])]));
65
- for (const [one, span] of spans)
66
- world = sign(L, world, `c${Math.max(0, chain.indexOf(one.region))}`, span);
67
- return parts(L, world.get('c0'), world).signed;
68
- };
69
- const spans = bounds.filter((one) => one.form === 'interval').flatMap((one) => ((got) => (got ? [[one, got]] : []))(spanOf(one.value)));
70
- if (spans.length)
71
- return signedIn(INTERVALS, spans);
72
- const alphabets = bounds.filter((one) => one.form === 'alphabet');
73
- if (!alphabets.length)
74
- return undefined;
75
- const words = (value) => (value.startsWith('not:') ? value.slice(4) : value).split('|').filter((one) => one && one !== 'none');
76
- const tokens = [...new Set(['', ...alphabets.flatMap((one) => words(one.value))])].sort();
77
- const mask = (value) => alphabetForm.parse({ tokens }, {
78
- want: value.startsWith('not:') ? tokens.filter((one) => !words(value).includes(one)) : words(value),
79
- });
80
- const held = signedIn(alphabetForm.lattice({ tokens }), alphabets.map((one) => [one, mask(one.value)])).members(tokens);
81
- return held.includes('') ? tokens.filter((one) => one !== '' && !held.includes(one)).map((one) => `not:${one}`) : held;
82
- }
83
- /**
84
- * The poles of a region, question by question: each live bound is signed at the region it names and travels by rest, as
85
- * the object signs, so the ceiling is what the region reads up its chain of rest, the meet in the lattice of their form, and beside it what the region's cells hold under that question,
86
- * value by count. Read off the summaries alone; no cell is visited.
87
- */
88
- export function polesOf(regions, region) {
89
- const chain = [];
90
- for (let at = region;; at = restsOn(regions.named, at)) {
91
- chain.push(at);
92
- if (at === '')
93
- break;
94
- }
95
- const asked = new Map();
96
- for (const bound of regions.bounds.filter((one) => chain.includes(one.region))) {
97
- const key = `${bound.question} ${bound.measure}`;
98
- asked.set(key, [...(asked.get(key) ?? []), bound]);
99
- }
100
- const summary = regions.summaries.get(region);
101
- const heldAt = (question, measure) => {
102
- const out = new Map();
103
- for (const [key, bar] of summary?.values ?? []) {
104
- const [asked_, at] = [key.slice(0, key.lastIndexOf(' ')), key.slice(key.lastIndexOf(' ') + 1)];
105
- if (at !== measure || !within(point(asked_), coordinates(question)))
106
- continue;
107
- for (const [value, count] of bar)
108
- out.set(value, (out.get(value) ?? 0) + count);
109
- }
110
- return out.size ? out : undefined;
111
- };
112
- return new Map([...asked].map(([key, bounds]) => [key, { ceiling: poleAt(regions.named, region, bounds), held: heldAt(bounds[0].question, bounds[0].measure) }]));
113
- }
114
- export function regionsOf(standing, ceilings, cells) {
115
- const named = regionsNamed(standing);
116
- const bounds = ceilings.map((line) => boundOf(named, line));
117
- const summaries = new Map();
118
- const at = (region) => summaries.get(region)
119
- ?? summaries.set(region, { region, cells: 0, sums: new Map(), values: new Map(), bounds: [] }).get(region);
120
- for (const region of [...named, ...bounds.map((one) => one.region)])
121
- at(region);
122
- for (const bound of bounds)
123
- at(bound.region).bounds.push(bound);
124
- const chains = new Map();
125
- const chainOf = (region) => chains.get(region) ?? chains.set(region, region === '' ? [''] : [region, ...chainOf(restsOn(named, region))]).get(region);
126
- const globs = [...summaries.keys()].filter(globbed);
127
- const placed = new Map();
128
- for (const cell of cells) {
129
- const key = `${cell.question} ${cell.measure}`;
130
- const span = /^(-?\d+(?:\.\d+)?)\.\./.exec(cell.value);
131
- const held = placed.get(`${cell.place}\u0000${key}`) ?? placed.set(`${cell.place}\u0000${key}`, { place: cell.place, key, ids: new Set() }).get(`${cell.place}\u0000${key}`);
132
- if (span)
133
- held.sum = (held.sum ?? 0) + Number(span[1]);
134
- else
135
- for (const one of cell.value.split('|'))
136
- if (one && one !== 'none')
137
- held.ids.add(one);
138
- }
139
- for (const { place, key, sum, ids } of placed.values()) {
140
- const home = regionOf(named, place);
141
- const reached = [...chainOf(home), ...globs.filter((glob) => chainOf(home).some((one) => one && matches(glob, one)))];
142
- for (const region of new Set(reached)) {
143
- const summary = at(region);
144
- summary.cells += 1;
145
- if (sum !== undefined)
146
- summary.sums.set(key, (summary.sums.get(key) ?? 0) + sum);
147
- const bars = summary.values.get(key) ?? summary.values.set(key, new Map()).get(key);
148
- for (const one of sum !== undefined ? [String(sum)] : ids)
149
- bars.set(one, (bars.get(one) ?? 0) + 1);
150
- }
151
- }
152
- return { named, bounds, summaries };
153
- }
154
- /**
155
- * What a bound bites, read off the summary of its region and never off a cell: the values its region's cells read that
156
- * lie outside it, and of those the ones every bound above it still admits. A question finer than a summary is not asked.
157
- */
158
- export function rankOf(regions, bound, own = {}) {
159
- const mine_ = own[bound.measure] ?? (bound.measure === 'count' ? own[fieldOf(bound.line, 'scope')] : undefined);
160
- if (mine_ !== undefined) {
161
- const span = poleAt(regions.named, bound.region, [bound]);
162
- const off = span !== undefined && !Array.isArray(span) && (mine_ < span.lo || mine_ > span.hi) ? 1 : 0;
163
- return { bars: off, cells: 0, fresh: off, met: 1, sums: off };
164
- }
165
- const summary = regions.summaries.get(bound.region);
166
- if (!summary)
167
- return { bars: 0, cells: 0, fresh: 0, met: 0, sums: 0 };
168
- const above = regions.bounds.filter((one) => one !== bound && one.measure === bound.measure && one.form === bound.form
169
- && within(point(bound.question), coordinates(one.question))
170
- && (one.region === '' || bound.region === one.region || bound.region.startsWith(`${one.region}/`) || (globbed(one.region) && matches(one.region, bound.region))));
171
- const alone = bound.form === 'alphabet' || bound.measure === 'per-file' || fieldOf(bound.line, 'scope').endsWith('/*');
172
- const outside = (value, of) => {
173
- if (of === undefined)
174
- return false;
175
- if (!Array.isArray(of)) {
176
- const n = Number(value);
177
- return !INTERVALS.leq({ lo: n, hi: n }, of);
178
- }
179
- const list = of;
180
- return list.some((one) => one.startsWith('not:')) ? list.includes(`not:${value}`) : !list.includes(value);
181
- };
182
- const mine = poleAt(regions.named, bound.region, [bound]);
183
- const held = poleAt(regions.named, bound.region, above);
184
- let bars = 0;
185
- let cells = 0;
186
- let fresh = 0;
187
- let met = 0;
188
- const whole = coordinates(fieldOf(bound.line, 'scope'));
189
- const top = regions.summaries.get('') ?? summary;
190
- const picked = new Map();
191
- const take = (from, holds) => {
192
- for (const [key, bar] of from.values) {
193
- const [question, measure] = [key.slice(0, key.lastIndexOf(' ')), key.slice(key.lastIndexOf(' ') + 1)];
194
- if (!picked.has(key) && measure === bound.measure && holds(question))
195
- picked.set(key, { bar, sum: from.sums.get(key) });
196
- }
197
- };
198
- take(top, (question) => within(point(question), whole));
199
- take(summary, (question) => within(point(question), coordinates(bound.question)));
200
- for (const { bar } of picked.values()) {
201
- for (const [value, count] of bar) {
202
- met += count;
203
- if (!alone || !outside(value, mine))
204
- continue;
205
- bars += 1;
206
- cells += count;
207
- if (!outside(value, held))
208
- fresh += count;
209
- }
210
- }
211
- const sums = alone ? 0 : [...picked.values()].filter(({ sum }) => sum !== undefined && outside(String(sum), mine)).length;
212
- return { bars, cells, fresh, met, sums };
213
- }
214
- function ownDigest(summary) {
215
- const hash = createHash('sha256');
216
- hash.update(`${summary.region}\n${summary.cells}\n`);
217
- for (const line of summary.bounds.map((one) => one.line).sort())
218
- hash.update(`${line}\n`);
219
- for (const key of [...summary.sums.keys()].sort())
220
- hash.update(`${key}=${summary.sums.get(key)}\n`);
221
- for (const key of [...summary.values.keys()].sort())
222
- hash.update(`${key}:${[...summary.values.get(key)].sort(([a], [b]) => (a < b ? -1 : 1)).map(([v, n]) => `${v}*${n}`).join(',')}\n`);
223
- return hash.digest('hex');
224
- }
225
- export function finerOf(regions) {
226
- const finer = new Map();
227
- for (const region of regions.summaries.keys())
228
- if (region !== '') {
229
- const parent = globbed(region) ? '' : restsOn(regions.named, region);
230
- finer.set(parent, [...(finer.get(parent) ?? []), region]);
231
- }
232
- return finer;
233
- }
234
- export function digestsOf(regions) {
235
- const finer = finerOf(regions);
236
- const out = new Map();
237
- const digest = (region) => out.get(region) ?? out.set(region, createHash('sha256').update(`${ownDigest(regions.summaries.get(region))}\n${[...(finer.get(region) ?? [])].sort().map(digest).join('\n')}`).digest('hex')).get(region);
238
- digest('');
239
- return out;
240
- }
241
- export function differing(a, b) {
242
- const [x, y] = [digestsOf(a), digestsOf(b)];
243
- const named = [...new Set([...a.named, ...b.named])];
244
- const out = [];
245
- let compared = 0;
246
- const descend = (region) => {
247
- compared += 1;
248
- if (x.get(region) === y.get(region))
249
- return;
250
- const [one, two] = [a.summaries.get(region), b.summaries.get(region)];
251
- if (!one || !two || ownDigest(one) !== ownDigest(two))
252
- out.push(region);
253
- const finer = new Set([...a.summaries.keys(), ...b.summaries.keys()].filter((name) => name !== '' && name !== region
254
- && (globbed(name) ? region === '' : restsOn(named, name) === region)));
255
- for (const name of [...finer].sort())
256
- descend(name);
257
- };
258
- descend('');
259
- return { regions: out, compared };
260
- }
261
- export const packRegions = (regions) => ({
262
- named: regions.named,
263
- bounds: regions.bounds.map((one) => one.line),
264
- summaries: [...regions.summaries.values()].map((one) => [one.region, one.cells, [...one.sums], [...one.values].map(([key, bars]) => [key, [...bars]])]),
265
- });
266
- export function unpackRegions(packed) {
267
- const bounds = packed.bounds.map((line) => boundOf(packed.named, line));
268
- return {
269
- named: packed.named,
270
- bounds,
271
- summaries: new Map(packed.summaries.map(([region, cells, sums, values]) => [region, {
272
- region, cells, sums: new Map(sums), values: new Map(values.map(([key, bars]) => [key, new Map(bars)])), bounds: bounds.filter((one) => one.region === region),
273
- }])),
274
- };
275
- }
276
- export function unlikeReplay(regions, red, own) {
277
- const read = new Map();
278
- for (const bound of regions.bounds) {
279
- const got = rankOf(regions, bound, own);
280
- if (got.met === 0)
281
- continue;
282
- const scope = fieldOf(bound.line, 'scope');
283
- read.set(scope, (read.get(scope) ?? false) || got.cells > 0 || got.sums > 0);
284
- }
285
- return [...read].filter(([scope, bitten]) => bitten !== red.has(scope)).length;
286
- }
1
+ var H=Object.defineProperty;var u=(s,e)=>H(s,"name",{value:e,configurable:!0});import{createHash as R}from"../host/io.js";import{library1_alphabetForm as C}from"../vendor/runtime.js";import{library2_cell as L,library2_parts as B,library2_sign as G}from"../vendor/runtime.js";import{library0_point as S,library0_region as W,library0_within as q}from"../vendor/runtime.js";import{library14_matches as j,library14_parse as J,library14_roleClaimsOf as K}from"../vendor/runtime.js";import{fieldOf as $}from"./claims.js";import{library7_INTERVALS as E,library7_spanOf as P}from"../vendor/runtime.js";const I=u(s=>s.replace(/(?:\/\*\*|\/\*|\/)+$/,""),"trimmed"),O=u(s=>s.includes("*"),"globbed");function Q(s){const e=new Set([""]);for(const o of s){if($(o,"value")==="withdraw")continue;const n=$(o,"scope"),a=["role","paths"].includes($(o,"measure"))?J(o):void 0,i=a?.kind==="fact"?K([a.value.fields]).map(f=>f.name):[],r=i.length?i:n.startsWith("dir/")?[n.slice(4)]:n.startsWith("region/")&&$(o,"res")?[$(o,"value")]:[];for(const f of[...r,...$(o,"needs").split("|")].map(I))f&&!O(f)&&e.add(f)}return[...e].sort()}u(Q,"regionsNamed");function _(s,e){let o="";for(const n of s)n.length>o.length&&n!==e&&e.startsWith(`${n}/`)&&(o=n);return o}u(_,"restsOn");function U(s,e){const o=I(e);let n="";for(const a of s)a.length>n.length&&(o===a||o.startsWith(`${a}/`))&&(n=a);return n}u(U,"regionOf");const F=u((s,e)=>O(e)?s.some(o=>j(e,o)):s.includes(e),"names");function T(s,e){const o=$(e,"scope"),n=o.split("/"),a=u((i,r)=>({line:e,question:i,region:r,measure:$(e,"measure"),form:$(e,"form"),value:$(e,"value")}),"of");for(let i=1;i<n.length;i+=1){const r=I(n.slice(i).join("/"));if(r&&F(s,r))return a(n.slice(0,i).join("/"),r)}for(let i=n.length-1;i>0;i-=1){const r=n.slice(0,i).join("/");if(F(s,r))return a(n.slice(i).join("/"),r)}return a(o,"")}u(T,"boundOf");function A(s,e,o){const n=[];for(let t=e;!n.includes(t);t=_(s,t))n.push(t);const a=u((t,c)=>{let p=new Map(n.map((b,g)=>[`c${g}`,L(`c${g}`,0,[],g+1<n.length?[`c${g+1}`]:[])]));for(const[b,g]of c)p=G(t,p,`c${Math.max(0,n.indexOf(b.region))}`,g);return B(t,p.get("c0"),p).signed},"signedIn"),i=o.filter(t=>t.form==="interval").flatMap(t=>(c=>c?[[t,c]]:[])(P(t.value)));if(i.length)return a(E,i);const r=o.filter(t=>t.form==="alphabet");if(!r.length)return;const f=u(t=>(t.startsWith("not:")?t.slice(4):t).split("|").filter(c=>c&&c!=="none"),"words"),m=[...new Set(["",...r.flatMap(t=>f(t.value))])].sort(),y=u(t=>C.parse({tokens:m},{want:t.startsWith("not:")?m.filter(c=>!f(t).includes(c)):f(t)}),"mask"),h=a(C.lattice({tokens:m}),r.map(t=>[t,y(t.value)])).members(m);return h.includes("")?m.filter(t=>t!==""&&!h.includes(t)).map(t=>`not:${t}`):h}u(A,"poleAt");function ie(s,e){const o=[];for(let r=e;o.push(r),r!=="";r=_(s.named,r));const n=new Map;for(const r of s.bounds.filter(f=>o.includes(f.region))){const f=`${r.question} ${r.measure}`;n.set(f,[...n.get(f)??[],r])}const a=s.summaries.get(e),i=u((r,f)=>{const m=new Map;for(const[y,h]of a?.values??[]){const[t,c]=[y.slice(0,y.lastIndexOf(" ")),y.slice(y.lastIndexOf(" ")+1)];if(!(c!==f||!q(S(t),W(r))))for(const[p,b]of h)m.set(p,(m.get(p)??0)+b)}return m.size?m:void 0},"heldAt");return new Map([...n].map(([r,f])=>[r,{ceiling:A(s.named,e,f),held:i(f[0].question,f[0].measure)}]))}u(ie,"polesOf");function ce(s,e,o){const n=Q(s),a=e.map(t=>T(n,t)),i=new Map,r=u(t=>i.get(t)??i.set(t,{region:t,cells:0,sums:new Map,values:new Map,bounds:[]}).get(t),"at");for(const t of[...n,...a.map(c=>c.region)])r(t);for(const t of a)r(t.region).bounds.push(t);const f=new Map,m=u(t=>f.get(t)??f.set(t,t===""?[""]:[t,...m(_(n,t))]).get(t),"chainOf"),y=[...i.keys()].filter(O),h=new Map;for(const t of o){const c=`${t.question} ${t.measure}`,p=/^(-?\d+(?:\.\d+)?)\.\./.exec(t.value),b=h.get(`${t.place}\0${c}`)??h.set(`${t.place}\0${c}`,{place:t.place,key:c,ids:new Set}).get(`${t.place}\0${c}`);if(p)b.sum=(b.sum??0)+Number(p[1]);else for(const g of t.value.split("|"))g&&g!=="none"&&b.ids.add(g)}for(const{place:t,key:c,sum:p,ids:b}of h.values()){const g=U(n,t),v=[...m(g),...y.filter(M=>m(g).some(k=>k&&j(M,k)))];for(const M of new Set(v)){const k=r(M);k.cells+=1,p!==void 0&&k.sums.set(c,(k.sums.get(c)??0)+p);const l=k.values.get(c)??k.values.set(c,new Map).get(c);for(const d of p!==void 0?[String(p)]:b)l.set(d,(l.get(d)??0)+1)}}return{named:n,bounds:a,summaries:i}}u(ce,"regionsOf");function X(s,e,o={}){const n=o[e.measure]??(e.measure==="count"?o[$(e.line,"scope")]:void 0);if(n!==void 0){const l=A(s.named,e.region,[e]),d=l!==void 0&&!Array.isArray(l)&&(n<l.lo||n>l.hi)?1:0;return{bars:d,cells:0,fresh:d,met:1,sums:d}}const a=s.summaries.get(e.region);if(!a)return{bars:0,cells:0,fresh:0,met:0,sums:0};const i=s.bounds.filter(l=>l!==e&&l.measure===e.measure&&l.form===e.form&&q(S(e.question),W(l.question))&&(l.region===""||e.region===l.region||e.region.startsWith(`${l.region}/`)||O(l.region)&&j(l.region,e.region))),r=e.form==="alphabet"||e.measure==="per-file"||$(e.line,"scope").endsWith("/*"),f=u((l,d)=>{if(d===void 0)return!1;if(!Array.isArray(d)){const x=Number(l);return!E.leq({lo:x,hi:x},d)}const w=d;return w.some(x=>x.startsWith("not:"))?w.includes(`not:${l}`):!w.includes(l)},"outside"),m=A(s.named,e.region,[e]),y=A(s.named,e.region,i);let h=0,t=0,c=0,p=0;const b=W($(e.line,"scope")),g=s.summaries.get("")??a,v=new Map,M=u((l,d)=>{for(const[w,x]of l.values){const[z,D]=[w.slice(0,w.lastIndexOf(" ")),w.slice(w.lastIndexOf(" ")+1)];!v.has(w)&&D===e.measure&&d(z)&&v.set(w,{bar:x,sum:l.sums.get(w)})}},"take");M(g,l=>q(S(l),b)),M(a,l=>q(S(l),W(e.question)));for(const{bar:l}of v.values())for(const[d,w]of l)p+=w,!(!r||!f(d,m))&&(h+=1,t+=w,f(d,y)||(c+=w));const k=r?0:[...v.values()].filter(({sum:l})=>l!==void 0&&f(String(l),m)).length;return{bars:h,cells:t,fresh:c,met:p,sums:k}}u(X,"rankOf");function N(s){const e=R("sha256");e.update(`${s.region}
2
+ ${s.cells}
3
+ `);for(const o of s.bounds.map(n=>n.line).sort())e.update(`${o}
4
+ `);for(const o of[...s.sums.keys()].sort())e.update(`${o}=${s.sums.get(o)}
5
+ `);for(const o of[...s.values.keys()].sort())e.update(`${o}:${[...s.values.get(o)].sort(([n],[a])=>n<a?-1:1).map(([n,a])=>`${n}*${a}`).join(",")}
6
+ `);return e.digest("hex")}u(N,"ownDigest");function Y(s){const e=new Map;for(const o of s.summaries.keys())if(o!==""){const n=O(o)?"":_(s.named,o);e.set(n,[...e.get(n)??[],o])}return e}u(Y,"finerOf");function V(s){const e=Y(s),o=new Map,n=u(a=>o.get(a)??o.set(a,R("sha256").update(`${N(s.summaries.get(a))}
7
+ ${[...e.get(a)??[]].sort().map(n).join(`
8
+ `)}`).digest("hex")).get(a),"digest");return n(""),o}u(V,"digestsOf");function le(s,e){const[o,n]=[V(s),V(e)],a=[...new Set([...s.named,...e.named])],i=[];let r=0;const f=u(m=>{if(r+=1,o.get(m)===n.get(m))return;const[y,h]=[s.summaries.get(m),e.summaries.get(m)];(!y||!h||N(y)!==N(h))&&i.push(m);const t=new Set([...s.summaries.keys(),...e.summaries.keys()].filter(c=>c!==""&&c!==m&&(O(c)?m==="":_(a,c)===m)));for(const c of[...t].sort())f(c)},"descend");return f(""),{regions:i,compared:r}}u(le,"differing");const fe=u(s=>({named:s.named,bounds:s.bounds.map(e=>e.line),summaries:[...s.summaries.values()].map(e=>[e.region,e.cells,[...e.sums],[...e.values].map(([o,n])=>[o,[...n]])])}),"packRegions");function ue(s){const e=s.bounds.map(o=>T(s.named,o));return{named:s.named,bounds:e,summaries:new Map(s.summaries.map(([o,n,a,i])=>[o,{region:o,cells:n,sums:new Map(a),values:new Map(i.map(([r,f])=>[r,new Map(f)])),bounds:e.filter(r=>r.region===o)}]))}}u(ue,"unpackRegions");function me(s,e,o){const n=new Map;for(const a of s.bounds){const i=X(s,a,o);if(i.met===0)continue;const r=$(a.line,"scope");n.set(r,(n.get(r)??!1)||i.cells>0||i.sums>0)}return[...n].filter(([a,i])=>i!==e.has(a)).length}u(me,"unlikeReplay");export{T as boundOf,le as differing,V as digestsOf,Y as finerOf,fe as packRegions,ie as polesOf,X as rankOf,Q as regionsNamed,ce as regionsOf,me as unlikeReplay,ue as unpackRegions};