@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.
- package/CITATION.cff +1 -1
- package/README.md +20 -3
- package/TARGET.bound +85 -47
- package/dist/cli/accept.js +61 -590
- package/dist/cli/act-result.js +3 -103
- package/dist/cli/args.js +3 -44
- package/dist/cli/custodian.js +2 -29
- package/dist/cli/host.js +4 -32
- package/dist/cli/names.js +1 -12
- package/dist/cli/native-descendant.js +1 -19
- package/dist/cli/native.js +3 -60
- package/dist/cli/observe.js +1 -13
- package/dist/cli/owner.js +3 -139
- package/dist/cli/pass.js +22 -321
- package/dist/cli/place.js +6 -282
- package/dist/cli/release-result.js +3 -80
- package/dist/cli/retained-judgment.js +1 -25
- package/dist/cli/standing-result.js +4 -19
- package/dist/cli/takes.js +10 -112
- package/dist/cli/verb.d.ts +1 -2
- package/dist/cli/verb.js +85 -684
- package/dist/engine/computation.js +2 -0
- package/dist/engine/conformance.js +4 -0
- package/dist/engine/encoding.js +1 -2
- package/dist/engine/index.d.ts +1 -13
- package/dist/engine/index.js +2 -11
- package/dist/engine/object.js +1 -38
- package/dist/engine/ports.js +2 -117
- package/dist/fold/admission-history.js +1 -17
- package/dist/fold/bootstrap-anchor.js +1 -28
- package/dist/fold/ceilings.js +1 -142
- package/dist/fold/claims.js +2 -132
- package/dist/fold/closed.js +24 -235
- package/dist/fold/configures.js +1 -25
- package/dist/fold/digests.js +10 -226
- package/dist/fold/evidence.js +1 -22
- package/dist/fold/fold-worker.js +1 -13
- package/dist/fold/kept.js +12 -173
- package/dist/fold/keys.js +3 -91
- package/dist/fold/laid.js +3 -90
- package/dist/fold/nos.js +1 -48
- package/dist/fold/object.js +1 -2
- package/dist/fold/observed.js +28 -534
- package/dist/fold/opened.js +1 -33
- package/dist/fold/own.js +3 -217
- package/dist/fold/paid.js +1 -92
- package/dist/fold/place-inputs.js +1 -70
- package/dist/fold/places.js +3 -100
- package/dist/fold/rank.js +1 -9
- package/dist/fold/reach.js +1 -83
- package/dist/fold/readers.js +6 -142
- package/dist/fold/receipts.js +1 -47
- package/dist/fold/region-declarations.js +1 -13
- package/dist/fold/region.js +8 -286
- package/dist/fold/release-policy.js +1 -101
- package/dist/fold/resolved.js +6 -145
- package/dist/fold/roles.js +2 -59
- package/dist/fold/second.js +4 -71
- package/dist/fold/shards.js +12 -100
- package/dist/fold/signed.js +3 -81
- package/dist/fold/signers.js +1 -54
- package/dist/fold/stranger.js +6 -24
- package/dist/fold/views.js +1 -66
- package/dist/fold/wire.js +1 -46
- package/dist/fold/zoom.js +3 -81
- package/dist/host/act-cost.js +1 -25
- package/dist/host/adapters/keys/ed25519.js +1 -30
- package/dist/host/adapters/modules/javascript.js +1 -50
- package/dist/host/adapters/transport/http.js +1 -28
- package/dist/host/admitted-place.js +1 -35
- package/dist/host/archive.js +1 -152
- package/dist/host/call-context.js +1 -14
- package/dist/host/capsule-process.js +2 -62
- package/dist/host/capsule.js +9 -171
- package/dist/host/cell-receipts.js +12 -128
- package/dist/host/command-server.js +4 -0
- package/dist/host/commit-result.js +1 -5
- package/dist/host/content-needed.js +1 -8
- package/dist/host/content-store.js +1 -31
- package/dist/host/contextual-place.js +2 -72
- package/dist/host/digest.js +2 -15
- package/dist/host/hash.js +1 -9
- package/dist/host/host-controls.js +1 -19
- package/dist/host/in-process-act.js +3 -84
- package/dist/host/in-process-context.js +3 -91
- package/dist/host/in-process-root.js +6 -84
- package/dist/host/in-process.js +4 -55
- package/dist/host/index.d.ts +1 -15
- package/dist/host/index.js +1 -7
- package/dist/host/io.js +1 -11
- package/dist/host/lifetime.js +1 -79
- package/dist/host/located.js +6 -105
- package/dist/host/native/authority-card-view.js +5 -0
- package/dist/host/native/authority-card.js +1 -0
- package/dist/host/native/bounded-file.js +1 -32
- package/dist/host/native/command.js +1 -91
- package/dist/host/native/control-bridge-worker.js +2 -88
- package/dist/host/native/control-bridge.js +1 -110
- package/dist/host/native/control-selection.js +1 -32
- package/dist/host/native/custody.js +1 -91
- package/dist/host/native/deadline.js +1 -28
- package/dist/host/native/descendants.js +1 -528
- package/dist/host/native/generated-custodian.js +5 -267
- package/dist/host/native/generated.js +1 -379
- package/dist/host/native/image.js +1 -45
- package/dist/host/native/installed-package.d.ts +1 -0
- package/dist/host/native/installed-package.js +5 -0
- package/dist/host/native/jobs.js +2 -148
- package/dist/host/native/loader.js +1 -269
- package/dist/host/native/materialize.js +1 -175
- package/dist/host/native/module-closure.js +1 -130
- package/dist/host/native/module-delivery.d.ts +1 -62
- package/dist/host/native/module-delivery.js +1 -151
- package/dist/host/native/module-inventory.js +2 -0
- package/dist/host/native/module-syntax.js +1 -69
- package/dist/host/native/native-binary.js +1 -115
- package/dist/host/native/native-program.js +1 -72
- package/dist/host/native/node-jobs.js +3 -187
- package/dist/host/native/node-launch.js +1 -159
- package/dist/host/native/preload.js +1 -45
- package/dist/host/native/probes.js +1 -0
- package/dist/host/native/reading-witness-admission.js +5 -0
- package/dist/host/native/reading.js +1 -249
- package/dist/host/native/receipt-environment.js +1 -41
- package/dist/host/native/references.js +1 -30
- package/dist/host/native/root.js +1 -37
- package/dist/host/native/route.js +1 -216
- package/dist/host/native/runtime.js +1 -9
- package/dist/host/native-place-state.js +1 -0
- package/dist/host/native-reader-context.js +1 -8
- package/dist/host/native-receiver.js +1 -25
- package/dist/host/objects.js +1 -38
- package/dist/host/order.js +1 -2
- package/dist/host/persistent-host.js +1 -0
- package/dist/host/physical-lines.d.ts +1 -0
- package/dist/host/physical-lines.js +1 -0
- package/dist/host/place-act-transaction.js +4 -78
- package/dist/host/place-clock-selection.js +5 -124
- package/dist/host/ports/ingress.js +2 -57
- package/dist/host/ports/local-act.js +5 -183
- package/dist/host/ports/place-act.js +1 -134
- package/dist/host/ports/publication.js +1 -56
- package/dist/host/ports/signing.js +1 -74
- package/dist/host/ports/store.js +1 -18
- package/dist/host/ports/transport.js +1 -48
- package/dist/host/process-lifetime.js +1 -17
- package/dist/host/profile-composition.d.ts +1 -0
- package/dist/host/profile-composition.js +2 -0
- package/dist/host/provide.js +1 -183
- package/dist/host/read-only.js +1 -9
- package/dist/host/reading-closures.js +7 -227
- package/dist/host/reading-context.js +1 -53
- package/dist/host/reading-identity-types.js +0 -0
- package/dist/host/reading-identity.js +3 -0
- package/dist/host/reading-preparation.js +6 -0
- package/dist/host/reference-authenticated.d.ts +1 -40
- package/dist/host/reference-authenticated.js +3 -100
- package/dist/host/reference-contracts.js +1 -6
- package/dist/host/reference-export.js +6 -81
- package/dist/host/reference-native-api.d.ts +1 -3
- package/dist/host/reference-native-api.js +1 -3
- package/dist/host/reference-native.js +1 -74
- package/dist/host/reference-profile.js +1 -63
- package/dist/host/reference-standing.js +2 -18
- package/dist/host/reference.js +1 -24
- package/dist/host/refusals.js +2 -43
- package/dist/host/release.js +4 -256
- package/dist/host/root-clock-source.js +1 -307
- package/dist/host/selected-capsules.js +1 -50
- package/dist/host/selected-topos.js +1 -80
- package/dist/host/signature-era.js +1 -12
- package/dist/host/signing.js +2 -48
- package/dist/host/source-content.js +2 -111
- package/dist/host/standing-carrier.js +1 -18
- package/dist/host/standing-projection.js +1 -50
- package/dist/host/timing.js +1 -7
- package/dist/host/walk.js +20 -193
- package/dist/host/work-trace.js +1 -0
- package/dist/judge/late.js +1 -33
- package/dist/judge/take.js +2 -75
- package/dist/judge/widening.js +1 -25
- package/dist/land/act.js +8 -336
- package/dist/land/alias.js +1 -41
- package/dist/land/held.js +1 -23
- package/dist/land/inert.js +1 -33
- package/dist/land/leaving.js +1 -55
- package/dist/land/ledger.js +6 -188
- package/dist/land/owned.js +4 -66
- package/dist/land/sign.js +1 -53
- package/dist/land/standing-pin.js +1 -49
- package/dist/land/vouched.js +1 -112
- package/dist/land/withdraw.js +1 -24
- package/dist/observe/files.js +1 -88
- package/dist/observe/identity.js +1 -61
- package/dist/observe/match.js +1 -8
- package/dist/observe/regions.js +7 -306
- package/dist/observe/run.js +1 -41
- package/dist/observe/runner.js +4 -101
- package/dist/public-types.d.ts +2019 -0
- package/dist/render/capsule.js +1 -30
- package/dist/render/field.js +1 -40
- package/dist/render/names.js +1 -4
- package/dist/render/open.js +1 -61
- package/dist/render/page.js +1 -7
- package/dist/render/receipt-projection.js +1 -0
- package/dist/render/receipts.js +1 -47
- package/dist/render/shape.js +1 -74
- package/dist/render/target.js +4 -52
- package/dist/render/view.js +7 -197
- package/dist/vendor/bundle.json +1 -0
- package/dist/vendor/library14.js +1 -0
- package/dist/vendor/object-provider.js +42 -0
- package/dist/vendor/runtime.js +61 -0
- package/dist/wasm/adapter.d.ts +1 -51
- package/dist/wasm/adapter.js +1 -180
- package/dist/wasm/node-worker.js +1 -13
- package/dist/wasm/object.js +1 -76
- package/dist/wasm/worker.js +1 -7
- package/docs/contracts/authenticated-reference.publication.json +1 -1
- package/docs/contracts/authority-preflight.md +17 -0
- package/docs/contracts/authority-preflight.publication.json +25 -0
- package/docs/contracts/closure-delivery.md +1 -1
- package/docs/contracts/closure-delivery.publication.json +1 -1
- package/docs/contracts/conformance.json +142 -0
- package/docs/contracts/determinism.bound +9 -0
- package/docs/contracts/engine-object-projection.publication.json +1 -1
- package/docs/contracts/engine.md +21 -1
- package/docs/contracts/installed-package.md +21 -0
- package/docs/contracts/installed-package.publication.json +25 -0
- package/docs/contracts/materialized-leaf-sequence.md +15 -0
- package/docs/contracts/materialized-leaf-sequence.publication.json +25 -0
- package/docs/contracts/module-inventory.md +15 -0
- package/docs/contracts/module-inventory.publication.json +25 -0
- package/docs/contracts/native-host.md +29 -1
- package/docs/contracts/native-host.publication.json +4 -4
- package/docs/contracts/native-probes.md +13 -0
- package/docs/contracts/native-probes.publication.json +25 -0
- package/docs/contracts/native-publication.inventory.json +10 -1
- package/docs/contracts/native-view-batch.md +17 -0
- package/docs/contracts/native-view-batch.publication.json +25 -0
- package/docs/contracts/optional-wasm-adapter.publication.json +1 -1
- package/docs/contracts/physical-lines.md +19 -0
- package/docs/contracts/physical-lines.publication.json +25 -0
- package/docs/contracts/profile-composition.md +17 -0
- package/docs/contracts/profile-composition.publication.json +25 -0
- package/docs/contracts/profile-preparation-native-meaning.md +9 -0
- package/docs/contracts/publication.md +12 -0
- package/docs/contracts/reading-identity.md +61 -0
- package/docs/contracts/reading-identity.publication.json +25 -0
- package/docs/contracts/reading-witness-admission.md +49 -0
- package/docs/contracts/readme.publication.json +1 -1
- package/docs/contracts/reference-port.md +11 -0
- package/docs/contracts/reference-port.publication.json +1 -1
- package/docs/contracts/refusals.bound +346 -94
- package/docs/contracts/refusals.md +119 -39
- package/docs/contracts/refusals.publication.json +2 -2
- package/docs/contracts/views.md +8 -0
- package/docs/reference.md +9 -0
- package/licenses/wasm/{fast-text-encoding.txt → NOTICE.txt} +111 -0
- package/package.json +84 -34
- package/receipts.bound +12952 -10449
- package/samples/authority-preflight/no.json +6 -0
- package/samples/authority-preflight/yes.json +30 -0
- package/samples/engine-alphabet/reader.js +3 -1457
- package/samples/engine-alphabet/receipts.bound +7 -7
- package/samples/engine-interval/reader.js +3 -1457
- package/samples/engine-interval/receipts.bound +7 -7
- package/samples/installed-package/consumer.mjs +29 -0
- package/samples/installed-package/fixture.json +48 -0
- package/samples/installed-package/no.json +10 -0
- package/samples/installed-package/yes.json +52 -0
- package/samples/materialized-leaf-sequence/no.json +11 -0
- package/samples/materialized-leaf-sequence/yes.json +10 -0
- package/samples/module-inventory/yes.json +28 -0
- package/samples/native/physical-line-reader.mjs +1 -0
- package/samples/native/physical-line-reader.source.mjs +13 -0
- package/samples/native-host/no.json +6 -1
- package/samples/native-host/yes.json +18 -1
- package/samples/native-probes/inputs/inspection.json +28 -0
- package/samples/native-probes/no.json +7 -0
- package/samples/native-probes/yes.json +28 -0
- package/samples/native-view-batch/no.json +14 -0
- package/samples/native-view-batch/yes.json +10 -0
- package/samples/no/engine-order/reader.js +3 -1457
- package/samples/no/module-inventory/no.json +10 -0
- package/samples/physical-lines/no.json +5 -0
- package/samples/physical-lines/yes.json +9 -0
- package/samples/profile-composition/no.json +6 -0
- package/samples/profile-composition/yes.json +14 -0
- package/samples/reading-identity/no.json +26 -0
- package/samples/reading-identity/yes.json +69 -0
- package/vectors/native/authority-preflight.vector.json +55 -0
- package/vectors/native/installed-package.vector.json +31 -0
- package/vectors/native/materialized-leaf-sequence.vector.json +31 -0
- package/vectors/native/module-inventory.vector.json +56 -0
- package/vectors/native/native-host.vector.json +214 -0
- package/vectors/native/native-probes.vector.json +31 -0
- package/vectors/native/native-view-batch.vector.json +31 -0
- package/vectors/native/physical-lines.vector.json +105 -0
- package/vectors/native/profile-composition.vector.json +53 -0
- package/vectors/native/reading-identity.vector.json +139 -0
- package/vectors/native/refusals.vector.json +138 -0
- package/vendor/syntax/LICENSE.md +7 -0
- package/vendor/syntax/parser.js +1 -0
- package/.github/workflows/release.yml +0 -67
- package/.github/workflows/test.yml +0 -35
- package/dist/engine/object.d.ts +0 -17
- package/dist/engine/ports.d.ts +0 -37
- package/dist/fold/claims.d.ts +0 -29
- package/dist/host/call-context.d.ts +0 -20
- package/dist/host/commit-result.d.ts +0 -6
- package/dist/host/in-process-act.d.ts +0 -82
- package/dist/host/in-process-context.d.ts +0 -46
- package/dist/host/in-process-root.d.ts +0 -117
- package/dist/host/in-process.d.ts +0 -41
- package/dist/host/native/module-closure.d.ts +0 -35
- package/dist/host/native-receiver.d.ts +0 -19
- package/dist/host/place-act-transaction.d.ts +0 -24
- package/dist/host/place-clock-selection.d.ts +0 -55
- package/dist/host/ports/local-act.d.ts +0 -44
- package/dist/host/ports/place-act.d.ts +0 -49
- package/dist/host/ports/publication.d.ts +0 -10
- package/dist/host/reference-export.d.ts +0 -33
- package/dist/host/reference-native.d.ts +0 -30
- package/dist/host/reference-profile.d.ts +0 -23
- package/dist/host/refusals.d.ts +0 -14
- package/dist/host/root-clock-source.d.ts +0 -86
- package/licenses/wasm/jitl-quickjs-ffi-types.txt +0 -21
- package/licenses/wasm/jitl-quickjs-wasmfile-release-sync.txt +0 -47
- package/licenses/wasm/quickjs-emscripten-core.txt +0 -21
- package/licenses/wasm/topos.txt +0 -21
- /package/{licenses/wasm/bound.txt → dist/vendor/28cba430228db1c04f446c93f81b09a2705d6bf3e222d35adbe5a4cee4061884.LICENSE} +0 -0
- /package/{licenses/wasm/obligations.txt → dist/vendor/7aca161279d14bc0e054dcc281cd110aeb95be2e026b42fdf527a260e58b2aae.LICENSE} +0 -0
package/dist/fold/kept.js
CHANGED
|
@@ -1,173 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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,
|
|
2
|
-
|
|
3
|
-
|
|
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 o=(e,s)=>E(e,"name",{value:s,configurable:!0});import{hostRequiresFreshBytes as F}from"../host/call-context.js";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 I}from"../land/ledger.js";import{fieldOf as a,foldClaims as y,isWire as K,LOCK as R,selfName as q}from"./claims.js";import{observeText as B}from"../observe/files.js";import{library14_publicLock as w}from"../vendor/runtime.js";const b=new Map,x=new Map,L=new Map,T=o((e,s,t=[])=>S(e,t).classes.get(s)?.[0],"keyOf");function V(e,s,t=[]){const i=T(e,s,t);if(i===void 0)throw new Error(`${q()}: REFUSE\xB7keys the lock admits no key of class \`${s}\`: name one as \`keys/<id> measure=class value=${s}\``);return i}o(V,"keyFor");function v(e,s=[]){const t=S(e,s),i=new Set(t.classes.get("attest")??[]);return t.signers.filter(c=>!i.has(c))}o(v,"lockSigners");function U(e){const s=m(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 c=t.length===1?t[0]:t.flat();return L.set(e,{parts:t,lines:c}),c}o(U,"lockLines");const M=new WeakMap;function X(e){const s=U(e);return M.get(s)??M.set(s,y(_(e)).standing).get(s)}o(X,"lockStanding");function _(e,s=[]){const t=m(e);return t?[...t]:v(e,s).flatMap(i=>I(e,i))}o(_,"signedLockLines");function S(e,s){const t=p(e).join(`
|
|
2
|
+
`),i=s.length?d(e,s):x.get(e)===t?b.get(e)??d(e):d(e);return s.length||x.set(e,t),s.length||b.set(e,i),i}o(S,"keysOf");const p=o(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 m(e){if(!F()&&g.has(e))return g.get(e);const s=j(N(e),R),t=p(e).length||!$(s)?[]:(B(s)??"").split(`
|
|
3
|
+
`).filter(K),c=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,c),c}o(m,"releaseOf");function d(e,s=[]){const t=m(e)??[],i=w(t)===void 0?[]:t,c=[...p(e),...t,...s].filter(n=>(/\bsig=/.test(n)||i.includes(n))&&/(?:^|\s)scope=keys\/[^/\s]+\s/.test(n)),r=y(c).standing.filter(n=>a(n,"value")!=="withdraw").sort((n,u)=>(Number(a(n,"epoch"))||0)-(Number(a(u,"epoch"))||0)),l=o(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}}o(d,"read");export{V as keyFor,T as keyOf,U as lockLines,v as lockSigners,X as lockStanding,m as releaseOf,_ as signedLockLines};
|
package/dist/fold/laid.js
CHANGED
|
@@ -1,90 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
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{library14_canonical as y,library14_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
|
-
|
|
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};
|
package/dist/fold/object.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { objectFold } from "../engine/index.js";
|
|
1
|
+
import{objectFold as r}from"../engine/index.js";export{r as objectFold};
|