@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/fold/kept.js CHANGED
@@ -1,173 +1,12 @@
1
- import { encodeUTF8 } from "../host/io.js";
2
- import { actLines, committedLocalActs } from "../host/ports/local-act.js";
3
- import { readOnly } from "../host/read-only.js";
4
- import { createHash, dirname, existsSync, join, mkdirSync, readdirSync, renameSync, writeFileSync } from "../host/io.js";
5
- import { bytesDigest, coordinateDigest } from "./digests.js";
6
- import { viewsOf } from "./views.js";
7
- import { landMemo, ledgerLines, ledgerWriters, memoAt, shardFile, writerFile } from "../land/ledger.js";
8
- import { coordinatesUnder, observeFile, observeText } from "../observe/files.js";
9
- import { EXTENSION, fieldOf } from "./claims.js";
10
- import { keyFor, keyOf, lockSigners } from "./keys.js";
11
- import { sourceOf, vouching } from "../land/vouched.js";
12
- import { wordsOf } from "./wire.js";
13
- import { ownLock } from "../observe/runner.js";
14
- const text = encodeUTF8;
15
- const atOf = (line) => {
16
- if (line.includes(' about='))
17
- return fieldOf(line, 'at');
18
- const from = line.indexOf(' at=') + ' at='.length;
19
- return line.slice(from, line.indexOf(' ', from));
20
- };
21
- export function foldPoints(store, standing, under, keeper, instrument = '', observed = [], root = dirname(store), answered, reads) {
22
- const said = new Map();
23
- for (const line of answered === undefined ? observed : []) {
24
- if (line.includes(' measure=observed '))
25
- continue;
26
- const key = `${fieldOf(line, 'by').split(':')[1] ?? ''} ${atOf(line)}`;
27
- (said.get(key) ?? said.set(key, []).get(key)).push(line);
28
- }
29
- const coordinates = observed
30
- .filter((line) => line.includes(' measure=observed ') && atOf(line).startsWith('place:') && (!under || fieldOf(line, 'scope').startsWith(under)))
31
- .map((line) => ((key) => `${fieldOf(line, 'scope')} ${atOf(line)} ${answered?.get(key) ?? saidDigest(store, said.get(key) ?? [])}`)(`${fieldOf(line, 'by').split(':')[1] ?? ''} ${atOf(line)}`));
32
- const signers = new Set(reads ? lockSigners(store) : []);
33
- const tree = reads ? vouching(standing) : undefined;
34
- const digestOf = (lines) => bytesDigest(store, text(lines.join('\n')));
35
- const narrowed = reads === undefined ? [] : [
36
- `lock ${digestOf([...reads.owned].sort())}`,
37
- `judge ${digestOf(ledgerLines(store, 'judge').filter((line) => reads.scopes.has(fieldOf(line, 'scope'))))}`,
38
- `take ${digestOf(ledgerLines(store, 'take').filter((line) => reads.scopes.has(fieldOf(line, 'scope').replace(/^take\//, ''))))}`,
39
- `tree ${digestOf(ledgerLines(store, tree ?? '').filter((line) => (sourceOf(line) ?? '').startsWith(reads.place)))}`,
40
- ];
41
- const heads = ledgerWriters(store)
42
- .filter((writer) => writer !== keeper && writer !== 'gate' && !writer.startsWith('reader') && !(reads && (signers.has(writer) || writer === 'judge' || writer === 'take' || writer === tree)))
43
- .map((writer) => `${writer} ${writer === liveWriter(store, standing) ? lastWord(store, writer) : bytesDigest(store, text(ledgerLines(store, writer).join('\n')))}`);
44
- const written = [...new Set([...viewsOf(standing).values()].flatMap((view) => ('regions' in view && view.shape ? [view.shape] : [])))].sort()
45
- .map((shape) => `written ${shape} ${coordinateDigest(store, join(root, under ?? '', shape)) ?? 'absent'}`);
46
- const lined = ownLock().filter((line) => fieldOf(line, 'scope').startsWith('region/') && fieldOf(line, 'measure') === 'lines' && fieldOf(line, 'value') !== 'withdraw')
47
- .flatMap((line) => fieldOf(line, 'value').split('|').filter(Boolean)).sort().map((coordinate) => `lines ${coordinate} ${coordinateDigest(store, join(root, under ?? '', coordinate)) ?? 'absent'}`);
48
- return [
49
- `place ${under ?? '.'}`,
50
- `instrument ${instrument}`,
51
- `reading context ${readingContext(store)}`,
52
- ...written,
53
- ...lined,
54
- ...[...new Set(coordinates)].sort(),
55
- ...heads.sort(),
56
- ...narrowed,
57
- `lines ${bytesDigest(store, text([...standing].sort().join('\n')))}`,
58
- ...(existsSync(join(store, 'cas', 'receipts')) ? readdirSync(join(store, 'cas', 'receipts')).sort() : []),
59
- ];
60
- }
61
- /**
62
- * What a reader said at one digest, as one digest: every point of a fold that stands for an answer is this. The writer
63
- * whose class the lock names live is judged when read, so a fold keeps what it said — which lines it found standing and
64
- * which ledger it folded — and not when.
65
- */
66
- export const saidDigest = (store, lines) => bytesDigest(store, text([...new Set(lines
67
- .filter((line) => !line.includes(' measure=observed ') && !line.includes(' scope=cost/'))
68
- .map((line) => `${fieldOf(line, 'scope')} ${fieldOf(line, 'measure')} ${fieldOf(line, 'value')}`))].sort().join('\n')));
69
- function liveWriter(store, standing) {
70
- if (!wordsOf(standing, 'live').includes('attest'))
71
- return undefined;
72
- try {
73
- return keyFor(store, 'attest');
74
- }
75
- catch {
76
- return undefined;
77
- }
78
- }
79
- const lastWord = (store, writer) => ((last) => `${fieldOf(last, 'at')} ${fieldOf(last, 'restsOn')} ${fieldOf(last, 'value')}`)(ledgerLines(store, writer).filter((line) => fieldOf(line, 'scope') === `${writer}/target`).at(-1) ?? '');
80
- export function movedPoints(store, now, key) {
81
- const last = observeText(memoAt(store, lastOf(now)))?.trim();
82
- const held = last === undefined || last === key ? undefined : observeText(memoAt(store, `fold/${last}`));
83
- if (held === undefined)
84
- return undefined;
85
- const was = new Set((JSON.parse(held).points ?? []));
86
- const has = new Set(now);
87
- return { gone: [...was].filter((one) => !has.has(one)), came: now.filter((one) => !was.has(one)) };
88
- }
89
- const lastOf = (points) => `last/${createHash('sha256').update(points[0] ?? '').digest('hex')}`;
90
- /**
91
- * A fold is kept under its key and a view's text under the key and the view's name, in the store's memos: the first to
92
- * keep a key keeps it, since one point set folds into one set of bytes, and a fold kept by another instrument is
93
- * another origin's, readable as history and never as this instrument's own state.
94
- */
95
- const elsewhere = { folds: 0 };
96
- export const foldsElsewhere = () => elsewhere.folds;
97
- const joined = (lines) => lines.join('\n');
98
- const split = (text) => (text === '' ? [] : text.split('\n'));
99
- const linesOf = (value) => value === undefined ? [] : typeof value === 'string' ? split(value) : value;
100
- /** Operational reader history guards file-fold reuse, never cell-region identity. */
101
- function readingContext(store) {
102
- const speaker = keyOf(store, 'read');
103
- const files = speaker === undefined ? [] : [writerFile(store, speaker), ...coordinatesUnder(dirname(shardFile(store, speaker, '')), store)
104
- .filter(file => file.endsWith(EXTENSION)).map(file => join(store, file))];
105
- const segments = speaker === undefined ? [] : committedLocalActs(store).flatMap(act => act.bundle.placements?.flatMap(placement => {
106
- const records = actLines(placement.records).filter(line => fieldOf(line, 'by') === speaker);
107
- return records.length ? [placement.place + '\n' + records.join('\n')] : [];
108
- }) ?? []);
109
- return bytesDigest(store, text([...files.filter(file => existsSync(file)).sort()
110
- .map(file => bytesDigest(store, observeFile(file) ?? new Uint8Array())), ...segments].join('\n')));
111
- }
112
- /** A new judgment changes the result even when the files and reader history do not. */
113
- function judgmentContext(store, demands) {
114
- const scopes = new Set(demands.map(line => fieldOf(line, 'scope')));
115
- return bytesDigest(store, text(ledgerLines(store, 'judge')
116
- .filter(line => scopes.has(fieldOf(line, 'scope'))).join('\n')));
117
- }
118
- export function keptPlace(store, under, currentInstrument) {
119
- const key = observeText(memoAt(store, lastOf([`place ${under ?? '.'}`])))?.trim();
120
- if (key === undefined || key === '')
121
- return undefined;
122
- const held = observeText(memoAt(store, `fold/${key}`));
123
- if (held === undefined)
124
- return undefined;
125
- const blob = JSON.parse(held);
126
- if (blob.readingContext !== readingContext(store))
127
- return undefined;
128
- const fold = blob.fold;
129
- if (currentInstrument !== undefined && fold.instrument !== currentInstrument)
130
- return undefined;
131
- if (blob.judgmentContext !== judgmentContext(store, linesOf(fold.demands)))
132
- return undefined;
133
- return {
134
- ...fold,
135
- standing: linesOf(fold.standing),
136
- observed: linesOf(fold.observed),
137
- grey: linesOf(fold.grey),
138
- refused: linesOf(fold.refused),
139
- demands: linesOf(fold.demands),
140
- paid: linesOf(fold.paid),
141
- missing: linesOf(fold.missing),
142
- history: linesOf(fold.history),
143
- orphans: linesOf(fold.orphans),
144
- signed: new Map(fold.signed),
145
- kept: true,
146
- };
147
- }
148
- export const keptRender = (store, key, name) => observeText(memoAt(store, `render/${key}/${name}`));
149
- export const keepRender = (store, _signer, key, name, _epoch, text_) => { if (!readOnly())
150
- landMemo(store, `render/${key}/${name}`, text(text_)); };
151
- export function keepFold(store, key, fold, points, instrument = '') {
152
- if (readOnly())
153
- return;
154
- const packed = {
155
- ...fold,
156
- standing: joined(fold.standing),
157
- observed: joined(fold.observed),
158
- grey: joined(fold.grey),
159
- refused: joined(fold.refused),
160
- demands: joined(fold.demands),
161
- paid: joined(fold.paid),
162
- missing: joined(fold.missing),
163
- history: joined(fold.history),
164
- orphans: joined(fold.orphans),
165
- signed: [...fold.signed],
166
- kept: false,
167
- };
168
- landMemo(store, `fold/${key}`, text(JSON.stringify({ fold: packed, points, instrument, readingContext: readingContext(store), judgmentContext: judgmentContext(store, fold.demands) })));
169
- const at = memoAt(store, lastOf(points));
170
- mkdirSync(dirname(at), { recursive: true });
171
- writeFileSync(`${at}.${process.pid}.part`, `${key}\n`);
172
- renameSync(`${at}.${process.pid}.part`, at);
173
- }
1
+ var U=Object.defineProperty;var a=(e,s)=>U(e,"name",{value:s,configurable:!0});import{encodeUTF8 as R}from"../host/io.js";import{actLines as _,committedLocalActs as B}from"../host/ports/local-act.js";import{readOnly as F}from"../host/read-only.js";import{createHash as H,dirname as S,existsSync as M,join as x,mkdirSync as X,readdirSync as q,renameSync as z,writeFileSync as G}from"../host/io.js";import{bytesDigest as g,coordinateDigest as C}from"./digests.js";import{viewsOf as I}from"./views.js";import{landMemo as N,ledgerLines as h,ledgerWriters as K,memoAt as y,shardFile as Q,writerFile as V}from"../land/ledger.js";import{coordinatesUnder as Y,observeFile as Z,observeText as b}from"../observe/files.js";import{EXTENSION as ee,fieldOf as r}from"./claims.js";import{keyFor as ne,keyOf as te,lockSigners as se}from"./keys.js";import{sourceOf as ie,vouching as re}from"../land/vouched.js";import{wordsOf as oe}from"./wire.js";import{ownLock as de}from"../observe/runner.js";const l=R,j=a(e=>{if(e.includes(" about="))return r(e,"at");const s=e.indexOf(" at=")+4;return e.slice(s,e.indexOf(" ",s))},"atOf");function We(e,s,t,o,d="",c=[],i=S(e),u,m){const O=new Map;for(const n of u===void 0?c:[]){if(n.includes(" measure=observed "))continue;const $=`${r(n,"by").split(":")[1]??""} ${j(n)}`;(O.get($)??O.set($,[]).get($)).push(n)}const A=c.filter(n=>n.includes(" measure=observed ")&&j(n).startsWith("place:")&&(!t||r(n,"scope").startsWith(t))).map(n=>($=>`${r(n,"scope")} ${j(n)} ${u?.get($)??ae(e,O.get($)??[])}`)(`${r(n,"by").split(":")[1]??""} ${j(n)}`)),D=new Set(m?se(e):[]),W=m?re(s):void 0,k=a(n=>g(e,l(n.join(`
2
+ `))),"digestOf"),E=m===void 0?[]:[`lock ${k([...m.owned].sort())}`,`judge ${k(h(e,"judge").filter(n=>m.scopes.has(r(n,"scope"))))}`,`take ${k(h(e,"take").filter(n=>m.scopes.has(r(n,"scope").replace(/^take\//,""))))}`,`tree ${k(h(e,W??"").filter(n=>(ie(n)??"").startsWith(m.place)))}`],J=K(e).filter(n=>n!==o&&n!=="gate"&&!n.startsWith("reader")&&!(m&&(D.has(n)||n==="judge"||n==="take"||n===W))).map(n=>`${n} ${n===ce(e,s)?fe(e,n):g(e,l(h(e,n).join(`
3
+ `)))}`),P=[...new Set([...I(s).values()].flatMap(n=>"regions"in n&&n.shape?[n.shape]:[]))].sort().map(n=>`written ${n} ${C(e,x(i,t??"",n))??"absent"}`),T=de().filter(n=>r(n,"scope").startsWith("region/")&&r(n,"measure")==="lines"&&r(n,"value")!=="withdraw").flatMap(n=>r(n,"value").split("|").filter(Boolean)).sort().map(n=>`lines ${n} ${C(e,x(i,t??"",n))??"absent"}`);return[`place ${t??"."}`,`instrument ${d}`,`reading context ${w(e)}`,...P,...T,...[...new Set(A)].sort(),...J.sort(),...E,`lines ${g(e,l([...s].sort().join(`
4
+ `)))}`,...M(x(e,"cas","receipts"))?q(x(e,"cas","receipts")).sort():[]]}a(We,"foldPoints");const ae=a((e,s)=>g(e,l([...new Set(s.filter(t=>!t.includes(" measure=observed ")&&!t.includes(" scope=cost/")).map(t=>`${r(t,"scope")} ${r(t,"measure")} ${r(t,"value")}`))].sort().join(`
5
+ `))),"saidDigest");function ce(e,s){if(oe(s,"live").includes("attest"))try{return ne(e,"attest")}catch{return}}a(ce,"liveWriter");const fe=a((e,s)=>(t=>`${r(t,"at")} ${r(t,"restsOn")} ${r(t,"value")}`)(h(e,s).filter(t=>r(t,"scope")===`${s}/target`).at(-1)??""),"lastWord");function Fe(e,s,t){const o=b(y(e,v(s)))?.trim(),d=o===void 0||o===t?void 0:b(y(e,`fold/${o}`));if(d===void 0)return;const c=new Set(JSON.parse(d).points??[]),i=new Set(s);return{gone:[...c].filter(u=>!i.has(u)),came:s.filter(u=>!c.has(u))}}a(Fe,"movedPoints");const v=a(e=>`last/${H("sha256").update(e[0]??"").digest("hex")}`,"lastOf"),pe={folds:0},Me=a(()=>pe.folds,"foldsElsewhere"),p=a(e=>e.join(`
6
+ `),"joined"),ue=a(e=>e===""?[]:e.split(`
7
+ `),"split"),f=a(e=>e===void 0?[]:typeof e=="string"?ue(e):e,"linesOf");function w(e){const s=te(e,"read"),t=s===void 0?[]:[V(e,s),...Y(S(Q(e,s,"")),e).filter(d=>d.endsWith(ee)).map(d=>x(e,d))],o=s===void 0?[]:B(e).flatMap(d=>d.bundle.placements?.flatMap(c=>{const i=_(c.records).filter(u=>r(u,"by")===s);return i.length?[c.place+`
8
+ `+i.join(`
9
+ `)]:[]})??[]);return g(e,l([...t.filter(d=>M(d)).sort().map(d=>g(e,Z(d)??new Uint8Array)),...o].join(`
10
+ `)))}a(w,"readingContext");function L(e,s){const t=new Set(s.map(o=>r(o,"scope")));return g(e,l(h(e,"judge").filter(o=>t.has(r(o,"scope"))).join(`
11
+ `)))}a(L,"judgmentContext");function Ce(e,s,t){const o=b(y(e,v([`place ${s??"."}`])))?.trim();if(o===void 0||o==="")return;const d=b(y(e,`fold/${o}`));if(d===void 0)return;const c=JSON.parse(d);if(c.readingContext!==w(e))return;const i=c.fold;if(!(t!==void 0&&i.instrument!==t)&&c.judgmentContext===L(e,f(i.demands)))return{...i,standing:f(i.standing),observed:f(i.observed),grey:f(i.grey),refused:f(i.refused),demands:f(i.demands),paid:f(i.paid),missing:f(i.missing),history:f(i.history),orphans:f(i.orphans),signed:new Map(i.signed),kept:!0}}a(Ce,"keptPlace");const Ne=a((e,s,t)=>b(y(e,`render/${s}/${t}`)),"keptRender"),Le=a((e,s,t,o,d,c)=>{F()||N(e,`render/${t}/${o}`,l(c))},"keepRender");function Ae(e,s,t,o,d=""){if(F())return;const c={...t,standing:p(t.standing),observed:p(t.observed),grey:p(t.grey),refused:p(t.refused),demands:p(t.demands),paid:p(t.paid),missing:p(t.missing),history:p(t.history),orphans:p(t.orphans),signed:[...t.signed],kept:!1};N(e,`fold/${s}`,l(JSON.stringify({fold:c,points:o,instrument:d,readingContext:w(e),judgmentContext:L(e,t.demands)})));const i=y(e,v(o));X(S(i),{recursive:!0}),G(`${i}.${process.pid}.part`,`${s}
12
+ `),z(`${i}.${process.pid}.part`,i)}a(Ae,"keepFold");export{We as foldPoints,Me as foldsElsewhere,Ae as keepFold,Le as keepRender,Ce as keptPlace,Ne as keptRender,Fe as movedPoints,ae as saidDigest};
package/dist/fold/keys.js CHANGED
@@ -1,91 +1,3 @@
1
- import { dirname, existsSync, join } from "../host/io.js";
2
- import { ledgerLines, ledgerWriters, signedLines } from "../land/ledger.js";
3
- import { fieldOf, foldClaims, isWire, LOCK, selfName } from "./claims.js";
4
- import { observeText } from "../observe/files.js";
5
- import { publicLock } from '@lapxo/topos/wire';
6
- const held = new Map();
7
- const keyInputs = new Map();
8
- const merged = new Map();
9
- /**
10
- * Whose lines carry a class of writing, as the lock says it. Every ledger the store keeps is read, the key claims
11
- * folded, and the class answered with the id the lock admitted first for it: no module here holds a signer's name, so
12
- * the day another head runs the same work its lines come out under its own name without a letter changing.
13
- */
14
- export const keyOf = (store, kind, told = []) => keysOf(store, told).classes.get(kind)?.[0];
15
- export function keyFor(store, kind, told = []) {
16
- const id = keyOf(store, kind, told);
17
- if (id === undefined) {
18
- throw new Error(`${selfName()}: REFUSE·keys the lock admits no key of class \`${kind}\`: name one as \`keys/<id> measure=class value=${kind}\``);
19
- }
20
- return id;
21
- }
22
- export function lockSigners(store, told = []) {
23
- const keys = keysOf(store, told);
24
- const attests = new Set(keys.classes.get('attest') ?? []);
25
- return keys.signers.filter((id) => !attests.has(id));
26
- }
27
- export function lockLines(store) {
28
- const release = releaseOf(store);
29
- if (release)
30
- return release;
31
- const parts = lockSigners(store).map((id) => ledgerLines(store, id)).filter((part) => part.length > 0);
32
- const last = merged.get(store);
33
- if (last !== undefined && last.parts.length === parts.length && last.parts.every((part, i) => part === parts[i]))
34
- return last.lines;
35
- const lines = parts.length === 1 ? parts[0] : parts.flat();
36
- merged.set(store, { parts, lines });
37
- return lines;
38
- }
39
- const standings = new WeakMap();
40
- /** What stands of the lock, folded once per landing of any of its ledgers: lockLines is the bytes, lockSigners the ids that write them, signedLockLines the same lines still carrying their signatures. */
41
- export function lockStanding(store) {
42
- const lines = lockLines(store);
43
- return standings.get(lines) ?? standings.set(lines, foldClaims(signedLockLines(store)).standing).get(lines);
44
- }
45
- export function signedLockLines(store, told = []) {
46
- const release = releaseOf(store);
47
- if (release)
48
- return [...release];
49
- return lockSigners(store, told).flatMap((id) => signedLines(store, id));
50
- }
51
- function keysOf(store, told) {
52
- const input = ledgerKeyLines(store).join('\n');
53
- const mine = told.length ? read(store, told) : keyInputs.get(store) === input ? held.get(store) ?? read(store) : read(store);
54
- if (!told.length)
55
- keyInputs.set(store, input);
56
- if (!told.length)
57
- held.set(store, mine);
58
- return mine;
59
- }
60
- const ledgerKeyLines = (store) => ledgerWriters(store).flatMap(writer => ledgerLines(store, writer))
61
- .filter((line) => /\bsig=/.test(line) && /(?:^|\s)scope=keys\/[^/\s]+\s/.test(line));
62
- const releases = new Map();
63
- /**
64
- * A release's lock, where the store signs no key of its own: the lock as it was laid is the place's only lines, read
65
- * and never written. What it says is true where a pin names the release; no ledger is made of it.
66
- */
67
- export function releaseOf(store) {
68
- if (releases.has(store))
69
- return releases.get(store);
70
- const at = join(dirname(store), LOCK);
71
- const lines = ledgerKeyLines(store).length || !existsSync(at) ? [] : (observeText(at) ?? '').split('\n').filter(isWire);
72
- const published = lines.some(line => fieldOf(line, 'scope').startsWith('keys/') && fieldOf(line, 'measure') === 'public-key' && fieldOf(line, 'sig'))
73
- && publicLock(lines) !== undefined;
74
- const got = published || lines.some((line) => fieldOf(line, 'scope') === 'publish/bootstrap' && fieldOf(line, 'value') !== 'withdraw') ? lines : undefined;
75
- releases.set(store, got);
76
- return got;
77
- }
78
- function read(store, told = []) {
79
- const release = releaseOf(store) ?? [], published = publicLock(release) === undefined ? [] : release;
80
- const said = [...ledgerKeyLines(store), ...release, ...told]
81
- .filter((line) => (/\bsig=/.test(line) || published.includes(line)) && /(?:^|\s)scope=keys\/[^/\s]+\s/.test(line));
82
- const standing = foldClaims(said).standing.filter((line) => fieldOf(line, 'value') !== 'withdraw')
83
- .sort((a, b) => (Number(fieldOf(a, 'epoch')) || 0) - (Number(fieldOf(b, 'epoch')) || 0));
84
- const idOf = (line) => fieldOf(line, 'scope').slice('keys/'.length);
85
- const classes = new Map();
86
- for (const line of standing.filter((one) => fieldOf(one, 'measure') === 'class'))
87
- classes.set(fieldOf(line, 'value'), [...(classes.get(fieldOf(line, 'value')) ?? []), idOf(line)]);
88
- const named = new Set(standing.filter((one) => fieldOf(one, 'measure') === 'public-key').map(idOf));
89
- const signers = [...new Set(standing.filter((one) => fieldOf(one, 'measure') === 'class').map(idOf))].filter((id) => named.has(id));
90
- return { classes, signers };
91
- }
1
+ var E=Object.defineProperty;var c=(e,s)=>E(e,"name",{value:s,configurable:!0});import{viewInput as h}from"../host/reading-context.js";import{dirname as N,existsSync as $,join as j}from"../host/io.js";import{ledgerLines as k,ledgerWriters as C,signedLines as F}from"../land/ledger.js";import{fieldOf as a,foldClaims as y,isWire as I,LOCK as K,selfName as R}from"./claims.js";import{observeText as T}from"../observe/files.js";import{library11_publicLock as w}from"../vendor/runtime.js";const b=new Map,x=new Map,L=new Map,U=c((e,s,t=[])=>S(e,t).classes.get(s)?.[0],"keyOf");function P(e,s,t=[]){const i=U(e,s,t);if(i===void 0)throw new Error(`${R()}: REFUSE\xB7keys the lock admits no key of class \`${s}\`: name one as \`keys/<id> measure=class value=${s}\``);return i}c(P,"keyFor");function v(e,s=[]){const t=S(e,s),i=new Set(t.classes.get("attest")??[]);return t.signers.filter(o=>!i.has(o))}c(v,"lockSigners");function _(e){const s=d(e);if(s)return s;const t=v(e).map(r=>h("authority-ledger:"+e+":"+r,()=>k(e,r))).filter(r=>r.length>0),i=L.get(e);if(i!==void 0&&i.parts.length===t.length&&i.parts.every((r,l)=>r===t[l]))return i.lines;const o=t.length===1?t[0]:t.flat();return L.set(e,{parts:t,lines:o}),o}c(_,"lockLines");const M=new WeakMap;function Q(e){const s=_(e);return M.get(s)??M.set(s,y(q(e)).standing).get(s)}c(Q,"lockStanding");function q(e,s=[]){const t=d(e);return t?[...t]:v(e,s).flatMap(i=>F(e,i))}c(q,"signedLockLines");function S(e,s){const t=p(e).join(`
2
+ `),i=s.length?m(e,s):x.get(e)===t?b.get(e)??m(e):m(e);return s.length||x.set(e,t),s.length||b.set(e,i),i}c(S,"keysOf");const p=c(e=>h("key-claims:"+e,()=>C(e).flatMap(s=>k(e,s)).filter(s=>/\bsig=/.test(s)&&/(?:^|\s)scope=keys\/[^/\s]+\s/.test(s))),"ledgerKeyLines"),g=new Map;function d(e){if(g.has(e))return g.get(e);const s=j(N(e),K),t=p(e).length||!$(s)?[]:(T(s)??"").split(`
3
+ `).filter(I),o=t.some(r=>a(r,"scope").startsWith("keys/")&&a(r,"measure")==="public-key"&&a(r,"sig"))&&w(t)!==void 0||t.some(r=>a(r,"scope")==="publish/bootstrap"&&a(r,"value")!=="withdraw")?t:void 0;return g.set(e,o),o}c(d,"releaseOf");function m(e,s=[]){const t=d(e)??[],i=w(t)===void 0?[]:t,o=[...p(e),...t,...s].filter(n=>(/\bsig=/.test(n)||i.includes(n))&&/(?:^|\s)scope=keys\/[^/\s]+\s/.test(n)),r=y(o).standing.filter(n=>a(n,"value")!=="withdraw").sort((n,u)=>(Number(a(n,"epoch"))||0)-(Number(a(u,"epoch"))||0)),l=c(n=>a(n,"scope").slice(5),"idOf"),f=new Map;for(const n of r.filter(u=>a(u,"measure")==="class"))f.set(a(n,"value"),[...f.get(a(n,"value"))??[],l(n)]);const O=new Set(r.filter(n=>a(n,"measure")==="public-key").map(l)),W=[...new Set(r.filter(n=>a(n,"measure")==="class").map(l))].filter(n=>O.has(n));return{classes:f,signers:W}}c(m,"read");export{P as keyFor,U as keyOf,_ as lockLines,v as lockSigners,Q as lockStanding,d as releaseOf,q as signedLockLines};
package/dist/fold/laid.js CHANGED
@@ -1,90 +1,3 @@
1
- import { createHash, gzipSync, join } from "../host/io.js";
2
- import { canonical, LOCK } from '@lapxo/topos/wire';
3
- import { fieldOf, isWire } from "./claims.js";
4
- import { memoized } from "./digests.js";
5
- import { rolesOf } from "./roles.js";
6
- import { said } from "./wire.js";
7
- import { releasesOf } from "../host/release.js";
8
- import { land, landBlob, ledgerLines } from "../land/ledger.js";
9
- import { coordinatesUnder, observeFile, observeText, stampOf } from "../observe/files.js";
10
- import { ownLock } from "../observe/runner.js";
11
- const RECEIPT = 'laid/';
12
- const DIGEST = '{digest}';
13
- /** The host's marks, named by the lock: `release/asset` on this place, else the asset and archive the tree already writes. */
14
- const assetsOf = (_store) => said(ownLock(), 'release/asset');
15
- const marked = (coordinate, tokens) => tokens.some((token) => {
16
- const at = token.indexOf(DIGEST);
17
- if (at < 0)
18
- return !token.includes('{') && coordinate === token;
19
- const head = token.slice(0, at);
20
- const tail = token.slice(at + DIGEST.length);
21
- return coordinate.startsWith(head) && coordinate.endsWith(tail)
22
- && coordinate.length === head.length + tail.length + 64
23
- && /^[0-9a-f]{64}$/.test(coordinate.slice(head.length, coordinate.length - tail.length));
24
- });
25
- const coordinatesOf = (store, place) => {
26
- const roleOf = rolesOf(store);
27
- const written = new Set((observeText(join(place, LOCK)) ?? '').split('\n').filter(isWire)
28
- .map((line) => fieldOf(line, 'shape').split('/')[0] ?? ''));
29
- const held = (coordinate) => !coordinate || (roleOf(coordinate) !== 'foreign' && (!coordinate.startsWith('.') || written.has(coordinate.split('/')[0] ?? '')));
30
- const marks = assetsOf(store);
31
- return coordinatesUnder(place, place, held).filter((coordinate) => held(coordinate) && !marked(coordinate, marks)).sort();
32
- };
33
- const stateOf = (place, files) => createHash('sha256').update(files.map((coordinate) => `${coordinate} ${stampOf(join(place, coordinate))?.stamp ?? ''}`).join('\n')).digest('hex');
34
- /**
35
- * A release is named by the digest of its folder, and what is laid is read again from its bytes by the same method: every
36
- * coordinate but those the tree's roles call foreign, a dotted one only where the folder's own lock writes into it, sorted, each a
37
- * ustar entry of mode 0644, owner 0 and time 0, then two empty blocks, gzipped at level nine. The mark the host writes is
38
- * none of those coordinates, so the digest of a place is the digest of the release laid there, or it is not that release.
39
- */
40
- export function releaseDigest(store, place) {
41
- const files = coordinatesOf(store, place);
42
- const state = stateOf(place, files);
43
- return { state, digest: memoized(store, `laid ${state}`, () => {
44
- const blocks = [];
45
- for (const coordinate of files) {
46
- const bytes = Buffer.from(observeFile(join(place, coordinate)) ?? new Uint8Array());
47
- const header = Buffer.alloc(512);
48
- const cut = coordinate.length <= 100 ? -1 : coordinate.lastIndexOf('/');
49
- header.write(cut < 0 ? coordinate : coordinate.slice(cut + 1), 0, 100, 'utf8');
50
- header.write('0000644\0', 100, 8, 'utf8');
51
- header.write('0000000\0', 108, 8, 'utf8');
52
- header.write('0000000\0', 116, 8, 'utf8');
53
- header.write(`${bytes.length.toString(8).padStart(11, '0')}\0`, 124, 12, 'utf8');
54
- header.write('00000000000\0', 136, 12, 'utf8');
55
- header.write(' ', 148, 8, 'utf8');
56
- header.write('0', 156, 1, 'utf8');
57
- header.write('ustar\0', 257, 6, 'utf8');
58
- header.write('00', 263, 2, 'utf8');
59
- header.write(cut < 0 ? '' : coordinate.slice(0, cut), 345, 155, 'utf8');
60
- header.write(`${header.reduce((sum, byte) => sum + byte, 0).toString(8).padStart(6, '0')}\0 `, 148, 8, 'utf8');
61
- blocks.push(header, bytes, Buffer.alloc((512 - (bytes.length % 512)) % 512));
62
- }
63
- blocks.push(Buffer.alloc(1024));
64
- const archive = gzipSync(Buffer.concat(blocks), { level: 9 });
65
- const digest = `sha256:${createHash('sha256').update(archive).digest('hex')}`;
66
- landBlob(store, digest, archive);
67
- return digest;
68
- }) };
69
- }
70
- /**
71
- * What the pass lands after it lays: for each release the own lock lays where it needs it, the digest its bytes give, by
72
- * the stamps of the bytes it read. What is read is the receipt of the bytes as they lie now: none is a count, and one
73
- * whose digest is not the one the lock names is a count.
74
- */
75
- export function landLaid(store, own, lock, folder) {
76
- if (folder === undefined)
77
- return;
78
- land(store, folder, releasesOf(lock).filter((line) => fieldOf(line, 'needs')).map((line) => ((got) => canonical({
79
- scope: `${RECEIPT}${fieldOf(line, 'scope').slice('dep/'.length)}/digest`, role: 'writes', form: 'alphabet', measure: 'digest',
80
- value: got.digest, by: folder, at: `place:${got.state}`,
81
- }))(releaseDigest(store, join(own, fieldOf(line, 'needs'))))));
82
- }
83
- export const laidDiffers = (store, own, lock, folder) => {
84
- const said = new Map((folder === undefined ? [] : ledgerLines(store, folder)).filter((line) => fieldOf(line, 'scope').startsWith(RECEIPT))
85
- .map((line) => [`${fieldOf(line, 'scope')} ${fieldOf(line, 'at')}`, fieldOf(line, 'value')]));
86
- return releasesOf(lock).filter((line) => fieldOf(line, 'needs')).filter((line) => {
87
- const place = join(own, fieldOf(line, 'needs'));
88
- return said.get(`${RECEIPT}${fieldOf(line, 'scope').slice('dep/'.length)}/digest place:${stateOf(place, coordinatesOf(store, place))}`) !== fieldOf(line, 'value');
89
- }).length;
90
- };
1
+ var v=Object.defineProperty;var o=(t,s)=>v(t,"name",{value:s,configurable:!0});import{createHash as h,gzipSync as S,join as u}from"../host/io.js";import{library11_canonical as y,library11_LOCK as B}from"../vendor/runtime.js";import{fieldOf as l,isWire as L}from"./claims.js";import{memoized as W}from"./digests.js";import{rolesOf as C}from"./roles.js";import{said as D}from"./wire.js";import{releasesOf as g}from"../host/release.js";import{land as E,landBlob as I,ledgerLines as T}from"../land/ledger.js";import{coordinatesUnder as _,observeFile as j,observeText as z,stampOf as K}from"../observe/files.js";import{ownLock as U}from"../observe/runner.js";const m="laid/",w="{digest}",A=o(t=>D(U(),"release/asset"),"assetsOf"),F=o((t,s)=>s.some(r=>{const n=r.indexOf(w);if(n<0)return!r.includes("{")&&t===r;const i=r.slice(0,n),e=r.slice(n+w.length);return t.startsWith(i)&&t.endsWith(e)&&t.length===i.length+e.length+64&&/^[0-9a-f]{64}$/.test(t.slice(i.length,t.length-e.length))}),"marked"),$=o((t,s)=>{const r=C(t),n=new Set((z(u(s,B))??"").split(`
2
+ `).filter(L).map(a=>l(a,"shape").split("/")[0]??"")),i=o(a=>!a||r(a)!=="foreign"&&(!a.startsWith(".")||n.has(a.split("/")[0]??"")),"held"),e=A(t);return _(s,s,i).filter(a=>i(a)&&!F(a,e)).sort()},"coordinatesOf"),O=o((t,s)=>h("sha256").update(s.map(r=>`${r} ${K(u(t,r))?.stamp??""}`).join(`
3
+ `)).digest("hex"),"stateOf");function G(t,s){const r=$(t,s),n=O(s,r);return{state:n,digest:W(t,`laid ${n}`,()=>{const i=[];for(const c of r){const d=Buffer.from(j(u(s,c))??new Uint8Array),f=Buffer.alloc(512),p=c.length<=100?-1:c.lastIndexOf("/");f.write(p<0?c:c.slice(p+1),0,100,"utf8"),f.write("0000644\0",100,8,"utf8"),f.write("0000000\0",108,8,"utf8"),f.write("0000000\0",116,8,"utf8"),f.write(`${d.length.toString(8).padStart(11,"0")}\0`,124,12,"utf8"),f.write("00000000000\0",136,12,"utf8"),f.write(" ",148,8,"utf8"),f.write("0",156,1,"utf8"),f.write("ustar\0",257,6,"utf8"),f.write("00",263,2,"utf8"),f.write(p<0?"":c.slice(0,p),345,155,"utf8"),f.write(`${f.reduce((b,x)=>b+x,0).toString(8).padStart(6,"0")}\0 `,148,8,"utf8"),i.push(f,d,Buffer.alloc((512-d.length%512)%512))}i.push(Buffer.alloc(1024));const e=S(Buffer.concat(i),{level:9}),a=`sha256:${h("sha256").update(e).digest("hex")}`;return I(t,a,e),a})}}o(G,"releaseDigest");function Y(t,s,r,n){n!==void 0&&E(t,n,g(r).filter(i=>l(i,"needs")).map(i=>(e=>y({scope:`${m}${l(i,"scope").slice(4)}/digest`,role:"writes",form:"alphabet",measure:"digest",value:e.digest,by:n,at:`place:${e.state}`}))(G(t,u(s,l(i,"needs"))))))}o(Y,"landLaid");const Z=o((t,s,r,n)=>{const i=new Map((n===void 0?[]:T(t,n)).filter(e=>l(e,"scope").startsWith(m)).map(e=>[`${l(e,"scope")} ${l(e,"at")}`,l(e,"value")]));return g(r).filter(e=>l(e,"needs")).filter(e=>{const a=u(s,l(e,"needs"));return i.get(`${m}${l(e,"scope").slice(4)}/digest place:${O(a,$(t,a))}`)!==l(e,"value")}).length},"laidDiffers");export{Z as laidDiffers,Y as landLaid,G as releaseDigest};
package/dist/fold/nos.js CHANGED
@@ -1,48 +1 @@
1
- import { existsSync, join } from "../host/io.js";
2
- import { fieldOf } from "./claims.js";
3
- import { lockLines } from "./keys.js";
4
- import { wordsOf } from "./wire.js";
5
- import { entriesIn } from "../observe/files.js";
6
- const sampleWord = (standing, root, place) => wordsOf(standing, 'families').find((one) => [one, `${one}s`].some((name) => existsSync(join(root, place, name))));
7
- const noOf = (need, word) => {
8
- const steps = need.split('/');
9
- const i = steps.findIndex((step) => step === word || step === `${word}s`);
10
- if (i < 0 || steps[i + 2] !== 'no')
11
- return undefined;
12
- const file = steps[i + 3];
13
- return file === undefined || file.includes('*') ? undefined : file.replace(/\.[^.]+$/, '');
14
- };
15
- /**
16
- * A bug found lands as a no of the law it broke. From the epoch the lock asks for it on — the next one while no line
17
- * asks yet, the epoch an accept would sign it at — every law of the place a witness names, a demand or a ceiling, holds
18
- * its bug in a no: a need under the wire's sample family /<area>/no/, or a no of the place named after the law. What this
19
- * counts is each law witnessed since then that holds none. When the lock lists no sample family, every such law is a
20
- * demand: the folder is not guessed.
21
- */
22
- export function bugsWithoutANo(root, store, standing, place, measure) {
23
- const epoch = (line) => Number(fieldOf(line, 'epoch'));
24
- const asking = standing.filter((line) => fieldOf(line, 'measure') === measure && fieldOf(line, 'value') !== 'withdraw').map(epoch);
25
- const from = asking.length ? Math.min(...asking) : lockLines(store).reduce((most, line) => Math.max(most, epoch(line)), 0) + 1;
26
- const word = sampleWord(standing, root, place);
27
- const nos = new Set();
28
- for (const line of standing)
29
- for (const need of fieldOf(line, 'needs').split('|').filter(Boolean)) {
30
- const name = word === undefined ? undefined : noOf(need, word);
31
- if (name)
32
- nos.add(name);
33
- }
34
- if (word !== undefined) {
35
- const dir = [word, `${word}s`].map((name) => join(root, place, name)).find((at) => existsSync(at));
36
- if (dir !== undefined)
37
- for (const area of entriesIn(dir).filter((one) => one.dir)) {
38
- for (const one of entriesIn(join(dir, area.name, 'no')))
39
- nos.add(one.name.replace(/\.[^.]+$/, ''));
40
- }
41
- }
42
- const named = (scope) => scope.slice(scope.lastIndexOf('/') + 1);
43
- const holds = (line) => nos.has(named(fieldOf(line, 'scope')))
44
- || (word !== undefined && fieldOf(line, 'needs').split('|').some((need) => noOf(need, word) !== undefined && existsSync(join(root, need))));
45
- return standing.filter((line) => fieldOf(line, 'at').startsWith('witness:') && fieldOf(line, 'value') !== 'withdraw' && epoch(line) >= from
46
- && fieldOf(line, 'scope').startsWith(`${place}/`)
47
- && (fieldOf(line, 'role') === 'demands' || fieldOf(line, 'form') === 'interval') && !holds(line)).length;
48
- }
1
+ var v=Object.defineProperty;var c=(f,r)=>v(f,"name",{value:r,configurable:!0});import{existsSync as p,join as u}from"../host/io.js";import{fieldOf as o}from"./claims.js";import{lockLines as I}from"./keys.js";import{wordsOf as b}from"./wire.js";import{entriesIn as w}from"../observe/files.js";const k=c((f,r,t)=>b(f,"families").find(s=>[s,`${s}s`].some(i=>p(u(r,t,i)))),"sampleWord"),$=c((f,r)=>{const t=f.split("/"),s=t.findIndex(m=>m===r||m===`${r}s`);if(s<0||t[s+2]!=="no")return;const i=t[s+3];return i===void 0||i.includes("*")?void 0:i.replace(/\.[^.]+$/,"")},"noOf");function A(f,r,t,s,i){const m=c(e=>Number(o(e,"epoch")),"epoch"),h=t.filter(e=>o(e,"measure")===i&&o(e,"value")!=="withdraw").map(m),x=h.length?Math.min(...h):I(r).reduce((e,n)=>Math.max(e,m(n)),0)+1,d=k(t,f,s),l=new Set;for(const e of t)for(const n of o(e,"needs").split("|").filter(Boolean)){const a=d===void 0?void 0:$(n,d);a&&l.add(a)}if(d!==void 0){const e=[d,`${d}s`].map(n=>u(f,s,n)).find(n=>p(n));if(e!==void 0)for(const n of w(e).filter(a=>a.dir))for(const a of w(u(e,n.name,"no")))l.add(a.name.replace(/\.[^.]+$/,""))}const O=c(e=>e.slice(e.lastIndexOf("/")+1),"named"),W=c(e=>l.has(O(o(e,"scope")))||d!==void 0&&o(e,"needs").split("|").some(n=>$(n,d)!==void 0&&p(u(f,n))),"holds");return t.filter(e=>o(e,"at").startsWith("witness:")&&o(e,"value")!=="withdraw"&&m(e)>=x&&o(e,"scope").startsWith(`${s}/`)&&(o(e,"role")==="demands"||o(e,"form")==="interval")&&!W(e)).length}c(A,"bugsWithoutANo");export{A as bugsWithoutANo};
@@ -1,2 +1 @@
1
- /** Compatibility path; the engine owns the single object projection. */
2
- export { objectFold } from "../engine/index.js";
1
+ import{objectFold as r}from"../engine/index.js";export{r as objectFold};