@lapxo/bound 0.2.3 → 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.
- package/CITATION.cff +19 -0
- package/TARGET.bound +95 -39
- package/dist/cli/accept.js +72 -558
- 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 +21 -321
- package/dist/cli/place.js +6 -281
- package/dist/cli/release-result.js +3 -80
- package/dist/cli/retained-judgment.js +1 -25
- package/dist/cli/standing-result.js +4 -21
- package/dist/cli/takes.js +10 -111
- package/dist/cli/verb.d.ts +1 -2
- package/dist/cli/verb.js +83 -683
- 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 -103
- 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 -131
- package/dist/fold/closed.js +24 -234
- 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 +27 -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 -63
- package/dist/host/archive.js +1 -152
- package/dist/host/call-context.js +1 -0
- package/dist/host/capsule-process.js +2 -61
- package/dist/host/capsule.js +9 -168
- package/dist/host/cell-receipts.js +12 -128
- package/dist/host/commit-result.js +1 -0
- package/dist/host/content-needed.js +1 -8
- package/dist/host/content-store.js +1 -31
- package/dist/host/contextual-place.js +2 -77
- package/dist/host/digest.js +2 -15
- package/dist/host/hash.js +1 -9
- package/dist/host/host-controls.js +1 -0
- package/dist/host/in-process-act.js +3 -0
- package/dist/host/in-process-context.js +3 -0
- package/dist/host/in-process-root.js +6 -0
- package/dist/host/in-process.js +4 -0
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.js +1 -0
- 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/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/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-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/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-reader-context.js +1 -8
- package/dist/host/native-receiver.js +1 -0
- package/dist/host/objects.js +1 -38
- package/dist/host/order.js +1 -2
- package/dist/host/place-act-transaction.js +4 -0
- 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 -172
- package/dist/host/ports/place-act.js +1 -169
- 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/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 -305
- package/dist/host/selected-capsules.js +1 -50
- package/dist/host/selected-topos.js +1 -80
- package/dist/host/signature-era.js +1 -0
- package/dist/host/signing.js +2 -48
- package/dist/host/source-content.js +2 -110
- package/dist/host/standing-carrier.js +1 -0
- package/dist/host/standing-projection.js +1 -0
- package/dist/host/timing.js +1 -7
- package/dist/host/walk.js +20 -193
- 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 -302
- 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 +7 -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 +2 -40
- package/dist/observe/runner.js +4 -93
- package/dist/public-types.d.ts +1114 -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/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/50086958553b9376d600583f7dff354196bfeb41170fc6d1482ca7bea7c493e2.LICENSE +21 -0
- package/dist/vendor/b3e938d28f88a1851af303a40c749e12ebd5a686daac4f0b343b5cdd2e040419.LICENSE +21 -0
- package/dist/vendor/bundle.json +1 -0
- package/dist/vendor/library11.js +1 -0
- package/dist/vendor/object-provider.js +42 -0
- package/dist/vendor/runtime.js +38 -0
- package/dist/vendor/sources.json +1 -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/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/native-host.md +21 -0
- package/docs/contracts/native-host.publication.json +25 -0
- package/docs/contracts/native-publication.inventory.json +3 -1
- package/docs/contracts/optional-wasm-adapter.publication.json +1 -1
- package/docs/contracts/publication.inventory.json +29 -0
- package/docs/contracts/reading-identity.md +37 -0
- package/docs/contracts/reading-identity.publication.json +25 -0
- package/docs/contracts/refusals.bound +51 -0
- package/docs/contracts/refusals.md +18 -3
- package/docs/contracts/refusals.publication.json +2 -2
- package/docs/contracts/views.md +8 -0
- package/docs/guide.md +10 -0
- package/docs/reference.md +40 -0
- package/docs/why.md +109 -0
- package/package.json +37 -18
- package/receipts.bound +11675 -9725
- package/samples/native-host/no.json +10 -0
- package/samples/native-host/yes.json +20 -0
- package/samples/reading-identity/no.json +20 -0
- package/samples/reading-identity/yes.json +46 -0
- package/vectors/native/native-host.vector.json +62 -0
- package/vectors/native/reading-identity.vector.json +101 -0
- package/vectors/native/refusals.vector.json +104 -0
- package/vendor/syntax/LICENSE.md +7 -0
- package/vendor/syntax/parser.js +1 -0
- package/dist/engine/object.d.ts +0 -17
- package/dist/engine/ports.d.ts +0 -32
- package/dist/host/native/module-closure.d.ts +0 -35
- 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/cli/accept.js
CHANGED
|
@@ -1,558 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return { coordinates, judged, fold };
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
/** One witness rule for prospective admission and the locked act. */
|
|
77
|
-
function refusesWidening(signed, standing) {
|
|
78
|
-
const widened = widenedWithoutWitness(signed, standing, isCeiling, wordOf(standing, 'at-classes', 'witness'));
|
|
79
|
-
if (widened.length) {
|
|
80
|
-
for (const line of widened)
|
|
81
|
-
process.stderr.write(`WIDER ${fieldOf(line, 'scope')} · ${fieldOf(line, 'value')}\n`);
|
|
82
|
-
process.stderr.write(`${selfName()}: REFUSE·widening nothing landed · a ceiling that admits more than it did gives back freedom the lock had spent: sign it under a witness that names what made the old ceiling wrong\n`);
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
/** Admission-only checks; observation and mutation belong to the later act. */
|
|
88
|
-
function refusesAdmission(root, signed, standing) {
|
|
89
|
-
if (refusesWidening(signed, standing))
|
|
90
|
-
return true;
|
|
91
|
-
const store = storeOf(root);
|
|
92
|
-
const outside = outsideTheirCapsule(root, standing, signed);
|
|
93
|
-
for (const line of outside)
|
|
94
|
-
process.stderr.write(`OUTSIDE ${fieldOf(line, 'scope')} · ${fieldOf(line, 'value')}\n`);
|
|
95
|
-
if (outside.length) {
|
|
96
|
-
process.stderr.write(`${selfName()}: REFUSE·outside nothing landed · a reader or a capsule lands in the capsule of its world, never in the wire or the instrument\n`);
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
const forks = forksJoinedBy(store, signed).filter(fork => forksItself(fork.lines) || fork.lines.filter(line => signed.includes(line)).length > 1);
|
|
100
|
-
if (forks.length) {
|
|
101
|
-
for (const fork of forks) {
|
|
102
|
-
process.stderr.write(`FORK ${fork.key}\n`);
|
|
103
|
-
for (const line of fork.lines)
|
|
104
|
-
process.stderr.write(` ${signed.includes(line) ? 'new ' : 'held'} by=${fieldOf(line, 'by')} ${sideOf(line, lockLines(store))}\n`);
|
|
105
|
-
}
|
|
106
|
-
process.stderr.write(`${selfName()}: REFUSE·fork nothing landed · one signer never forks itself, and one act never forks itself: withdraw the held side in this batch, or sign the other reading under its own scope\n`);
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
const held = aliasPinned(root, signed);
|
|
110
|
-
if (held.length) {
|
|
111
|
-
for (const one of held)
|
|
112
|
-
process.stderr.write(`ALIAS ${one.scope} · ${one.digest} · ${one.by.join(' ')}\n`);
|
|
113
|
-
process.stderr.write(`${selfName()}: REFUSE·alias nothing landed · an alias is withdrawn only when no pin names its digest\n`);
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
function refusesStandingPins(root, lines) {
|
|
119
|
-
try {
|
|
120
|
-
admitStandingPins(root, lines);
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
process.stderr.write(`${selfName()}: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/** A batch signed as accept signs it: at the next epoch, by the key it names, each line read by the wire it would land under. */
|
|
129
|
-
export async function signedBatch(root, args, files) {
|
|
130
|
-
const byFile = files.map((file) => [placesOfFile(file), claimLinesIn(file)]);
|
|
131
|
-
const proposed = byFile.flatMap(([, lines]) => lines);
|
|
132
|
-
if (!proposed.length) {
|
|
133
|
-
process.stderr.write(`${selfName()}: a batch is a file with claim lines\n`);
|
|
134
|
-
return { kind: 'exit', code: 2 };
|
|
135
|
-
}
|
|
136
|
-
const drafted = proposed.filter((line) => !fieldOf(line, 'sig'));
|
|
137
|
-
const bare = drafted.filter((line) => fieldOf(line, 'epoch') || !['', 'target'].includes(fieldOf(line, 'by')));
|
|
138
|
-
if (bare.length) {
|
|
139
|
-
for (const line of bare)
|
|
140
|
-
process.stderr.write(`BARE ${fieldOf(line, 'scope')} · by=${fieldOf(line, 'by') || '∅'}${fieldOf(line, 'epoch') ? ` epoch=${fieldOf(line, 'epoch')}` : ''}\n`);
|
|
141
|
-
process.stderr.write(`${selfName()}: REFUSE·bare nothing landed · ${bare.length} lines name a signer or an epoch they were not signed with: a drafted line proposes by=target and sign signs it, a line a lane signed carries its sig\n`);
|
|
142
|
-
return { kind: 'exit', code: 1 };
|
|
143
|
-
}
|
|
144
|
-
const store = storeOf(root);
|
|
145
|
-
const destinations = [...new Set([...namedPlaces(args), ...byFile.flatMap(([heads]) => heads)])];
|
|
146
|
-
const rooted = lockStanding(store);
|
|
147
|
-
const stray = destinations.filter(one => !placesIn(root).includes(one) && !foundableIn(root, rooted, wordOf(rooted, 'families', 'region'), one));
|
|
148
|
-
if (stray.length) {
|
|
149
|
-
process.stderr.write(`${selfName()}: REFUSE·place nothing landed · ${stray.join(', ')} is no place of the tree, and no line of the root founds it: --place names the own lock a line lands in\n`);
|
|
150
|
-
return { kind: 'exit', code: 2 };
|
|
151
|
-
}
|
|
152
|
-
const local = localActLines(root, destinations);
|
|
153
|
-
const base = { digest: fullDigest(store, local), places: destinations };
|
|
154
|
-
const epoch = epochOf(local) + 1;
|
|
155
|
-
const stale = proposed.filter((line) => fieldOf(line, 'sig')).flatMap((line) => ((by, key) => (key === undefined || !verifiesOwnerLine(line, key, signaturesOf(store).admitted)
|
|
156
|
-
? [`${fieldOf(line, 'scope')} · the signature does not hold for ${by || '∅'}`]
|
|
157
|
-
: []))(fieldOf(line, 'by'), publicKeyOf(root, fieldOf(line, 'by'))));
|
|
158
|
-
if (stale.length) {
|
|
159
|
-
for (const one of stale)
|
|
160
|
-
process.stderr.write(`SIGNED ${one}\n`);
|
|
161
|
-
process.stderr.write(`${selfName()}: REFUSE·signed nothing landed · ${stale.length} lines a lane signed stand at no epoch this act\n`);
|
|
162
|
-
return { kind: 'exit', code: 1 };
|
|
163
|
-
}
|
|
164
|
-
const [named, places] = [namedPlaces(args), placesIn(root)];
|
|
165
|
-
const inLock = new Set(lockLines(store).map(sayingOf));
|
|
166
|
-
const inPlace = new Map(places.map((place) => [place, new Set(appliedIn(root, place).map(sayingOf))]));
|
|
167
|
-
const deliveryAuthority = authorityFor(lockLines(store), rootSigner(root), signaturesOf(store).admitted);
|
|
168
|
-
const delivered = (line) => Boolean(fieldOf(line, 'sig'))
|
|
169
|
-
&& deliveryAuthority.of(line).kind === 'admitted'
|
|
170
|
-
&& ledgerLines(store, fieldOf(line, 'by')).includes(line);
|
|
171
|
-
const held = (line, at = named.length ? named : byFile.flatMap(([heads, lines]) => (lines.includes(line) ? heads : []))) => at.length
|
|
172
|
-
? at.every((place) => inPlace.get(place)?.has(sayingOf(line)))
|
|
173
|
-
: delivered(line) || inLock.has(sayingOf(line)) || places.some((place) => inPlace.get(place)?.has(sayingOf(line)));
|
|
174
|
-
if (proposed.every((line) => held(line))) {
|
|
175
|
-
if (proposed.some(line => !isConfig(line))) {
|
|
176
|
-
try {
|
|
177
|
-
await admittedObjects(root, [...signedOwnerLines(store), ...proposed]);
|
|
178
|
-
}
|
|
179
|
-
catch (e) {
|
|
180
|
-
process.stderr.write(`${selfName()}: ${String(e)} · nothing landed\n`);
|
|
181
|
-
return { kind: 'exit', code: 1 };
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return { kind: 'once', proposed };
|
|
185
|
-
}
|
|
186
|
-
const outdated = proposed.filter(line => fieldOf(line, 'sig') && isConfig(line) && Number(fieldOf(line, 'epoch')) !== epoch);
|
|
187
|
-
if (outdated.length) {
|
|
188
|
-
for (const line of outdated)
|
|
189
|
-
process.stderr.write(`SIGNED ${fieldOf(line, 'scope')} · signed by ${fieldOf(line, 'by')} at epoch ${fieldOf(line, 'epoch')}, and this act lands at ${epoch}: sign it again\n`);
|
|
190
|
-
process.stderr.write(`${selfName()}: REFUSE·signed nothing landed · ${outdated.length} lines a lane signed stand at no epoch this act\n`);
|
|
191
|
-
return { kind: 'exit', code: 1 };
|
|
192
|
-
}
|
|
193
|
-
const keyFile = valueOf(args, FLAGS.keyFile);
|
|
194
|
-
const keyId = valueOf(args, FLAGS.key) ?? ownerOf(store);
|
|
195
|
-
const publicKey = drafted.length ? publicKeyOf(root, keyId) : undefined;
|
|
196
|
-
if (drafted.length && !publicKey) {
|
|
197
|
-
process.stderr.write(`${selfName()}: unknown key ${keyId} — name it in ${selfName()}.keys\n`);
|
|
198
|
-
return { kind: 'exit', code: 2 };
|
|
199
|
-
}
|
|
200
|
-
let signed = proposed.filter((line) => fieldOf(line, 'sig'));
|
|
201
|
-
if (drafted.length) {
|
|
202
|
-
let invoke;
|
|
203
|
-
try {
|
|
204
|
-
invoke = signerFor([...lockStanding(store), ...destinations.flatMap(place => ownLockOf(root, place))], keyId, valueOf(args, FLAGS.signer), keyFile);
|
|
205
|
-
}
|
|
206
|
-
catch (error) {
|
|
207
|
-
process.stderr.write(`${selfName()}: ${error instanceof Error ? error.message : 'REFUSE·signer unavailable'}\n`);
|
|
208
|
-
return { kind: 'exit', code: 1 };
|
|
209
|
-
}
|
|
210
|
-
const got = await signConsentLot(drafted, { epoch, by: keyId, algorithm: signaturesOf(store).era }, publicKey, signaturesOf(store).admitted, invoke);
|
|
211
|
-
if (got.kind === 'refuse') {
|
|
212
|
-
process.stderr.write(`${selfName()}: ${got.why}\n`);
|
|
213
|
-
return { kind: 'exit', code: 1 };
|
|
214
|
-
}
|
|
215
|
-
let index = 0;
|
|
216
|
-
signed = proposed.map(line => fieldOf(line, 'sig') ? line : got.lines[index++]);
|
|
217
|
-
}
|
|
218
|
-
const wireLines = [...signedOwnerLines(store), ...signed].flatMap((line) => {
|
|
219
|
-
const got = parse(line);
|
|
220
|
-
return got.kind === 'fact' ? [got.value.fields] : [];
|
|
221
|
-
});
|
|
222
|
-
for (const line of signed) {
|
|
223
|
-
const got = admittedLine(line, wireLines, Number(fieldOf(line, 'epoch')), foldClaims(signedOwnerLines(store)).standing.filter(one => fieldOf(one, 'scope').startsWith('uses/') && fieldOf(one, 'value') !== 'withdraw'));
|
|
224
|
-
if (got.kind !== 'fact') {
|
|
225
|
-
process.stderr.write(`${selfName()}: REFUSE·wire ${fieldOf(line, 'scope')} · ${got.why} · nothing landed\n`);
|
|
226
|
-
return { kind: 'exit', code: 1 };
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
if (refusesStandingPins(root, signed))
|
|
230
|
-
return { kind: 'exit', code: 1 };
|
|
231
|
-
const taken = retractedTogether(signed);
|
|
232
|
-
if (taken.length) {
|
|
233
|
-
for (const pair of taken) {
|
|
234
|
-
process.stderr.write(`WITHDRAW ${sayingOf(pair.withdraw)}\n`);
|
|
235
|
-
process.stderr.write(`NEW ${sayingOf(pair.line)}\n`);
|
|
236
|
-
}
|
|
237
|
-
process.stderr.write(`${selfName()}: REFUSE·withdraw nothing landed · a withdraw matches a new line in this batch, so it takes that line too\n`);
|
|
238
|
-
return { kind: 'exit', code: 1 };
|
|
239
|
-
}
|
|
240
|
-
const authority = authorityFor([...lockLines(store), ...signed], rootSigner(root), signaturesOf(store).admitted);
|
|
241
|
-
const ownership = ownedOf(root, signed, line => authority.of(line).kind === 'admitted', by => authority.admitted.find(one => one.id === by)?.coverage ?? [], named, line => { const heads = byFile.flatMap(([heads, lines]) => lines.some(draft => sayingOf(draft) === sayingOf(line)) ? heads : []); return heads.length ? heads : undefined; });
|
|
242
|
-
if (ownership.nowhere.length) {
|
|
243
|
-
for (const line of ownership.nowhere)
|
|
244
|
-
process.stderr.write(`${selfName()}: REFUSE·signer ${keyId} uncovered ${fieldOf(line, 'scope')} · nothing signed for delivery\n`);
|
|
245
|
-
return { kind: 'exit', code: 1 };
|
|
246
|
-
}
|
|
247
|
-
if (ownership.forked.length) {
|
|
248
|
-
for (const one of ownership.forked)
|
|
249
|
-
process.stderr.write(`FORKED ${one.place}/${LOCK} · ${one.key} · the lot would leave two standing claims where the lock had one\n`);
|
|
250
|
-
process.stderr.write(`${selfName()}: REFUSE·forked nothing landed · ${ownership.forked.length} claims an own lot would fork: a lot for many places lands the same lines at each, and lines meant for one place go in a lot of their own\n`);
|
|
251
|
-
return { kind: 'exit', code: 1 };
|
|
252
|
-
}
|
|
253
|
-
if (refusesAdmission(root, ownership.ledger, lockStanding(store)))
|
|
254
|
-
return { kind: 'exit', code: 1 };
|
|
255
|
-
if (signed.some(line => !isConfig(line))) {
|
|
256
|
-
try {
|
|
257
|
-
await admittedObjects(root, [...signedOwnerLines(store), ...signed], text => process.stdout.write(text + '\n'));
|
|
258
|
-
}
|
|
259
|
-
catch (e) {
|
|
260
|
-
process.stderr.write(`${selfName()}: ${e instanceof Error ? e.message : String(e)} · nothing landed\n`);
|
|
261
|
-
return { kind: 'exit', code: 1 };
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
try {
|
|
265
|
-
admissionEvidence(root, ownership.ledger, lockStanding(store));
|
|
266
|
-
}
|
|
267
|
-
catch (error) {
|
|
268
|
-
process.stderr.write(`${selfName()}: ${error instanceof Error ? error.message : String(error)} · nothing landed\n`);
|
|
269
|
-
return { kind: 'exit', code: 1 };
|
|
270
|
-
}
|
|
271
|
-
return { kind: 'signed', signed, epoch, base, ...(drafted.length ? { keyId } : {}) };
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* accept is one act under the descent of its lines. Every place, then the root where they join, only when those lines
|
|
275
|
-
* rest on every place; a line in one place's own lock is that place. It signs the batch at the epoch the lock
|
|
276
|
-
* stands at, folds it, judges every take of it, and lands only when all of it holds. A batch refused lands nothing.
|
|
277
|
-
* What a batch would move is read before it with `--as rank <batch>`. A cycle's lanes each sign
|
|
278
|
-
* their batch with `bound sign` at the epoch the act lands at, and one land takes them all, each line in its signer's
|
|
279
|
-
* ledger once it verifies against that signer: one signer never forks itself, and one act never forks itself.
|
|
280
|
-
*/
|
|
281
|
-
export async function accept(root, args) {
|
|
282
|
-
const started = Date.now();
|
|
283
|
-
const contextFiles = positionalsOf(args);
|
|
284
|
-
if (contextFiles.length === 1 && hasContextualPlace(root) && !claimLinesIn(contextFiles[0]).length) {
|
|
285
|
-
if (namedPlaces(args).length || valueOf(args, FLAGS.key) || valueOf(args, FLAGS.keyFile) || valueOf(args, FLAGS.signer))
|
|
286
|
-
throw Error('REFUSE·contextual place accepts one already signed context envelope');
|
|
287
|
-
const result = await landContextualPlace(root, contextFiles[0]);
|
|
288
|
-
process.stdout.write(JSON.stringify({ profile: 'place-act-context@1', identity: result.identity, status: result.kind, context: result.context, receipts: result.receipts }) + '\n');
|
|
289
|
-
return 0;
|
|
290
|
-
}
|
|
291
|
-
const named = namedPlaces(args);
|
|
292
|
-
const placed = positionalsOf(args).reduce((all, file) => ((places) => (places.length ? claimLinesIn(file).reduce((got, line) => got.set(sayingOf(line), [...new Set([...(got.get(sayingOf(line)) ?? []), ...places])]), all) : all))(placesOfFile(file)), new Map());
|
|
293
|
-
const batch = await signedBatch(root, args, positionalsOf(args));
|
|
294
|
-
if (batch.kind === 'exit')
|
|
295
|
-
return batch.code;
|
|
296
|
-
if (batch.kind === 'once')
|
|
297
|
-
return underTheLock(storeOf(root), 'land', () => repaid(root, batch.proposed, started));
|
|
298
|
-
const store = storeOf(root);
|
|
299
|
-
const authority = authorityFor([...lockLines(store), ...batch.signed], rootSigner(root), signaturesOf(store).admitted);
|
|
300
|
-
const owned = ownedOf(root, batch.signed, (line) => authority.of(line).kind === 'admitted', (by) => authority.admitted.find((one) => one.id === by)?.coverage ?? [], named, (line) => placed.get(sayingOf(line)));
|
|
301
|
-
if (owned.nowhere.length) {
|
|
302
|
-
for (const line of owned.nowhere)
|
|
303
|
-
process.stderr.write(`NOWHERE ${fieldOf(line, 'scope')} · ${((got) => (got.kind === 'admitted' ? 'admitted' : got.why))(authority.of(line))}, and ${named.length ? `no place of ${named.join(', ')} takes it` : 'no one own lock it covers takes it: name the places with --place'}\n`);
|
|
304
|
-
process.stderr.write(`${selfName()}: REFUSE·nowhere nothing landed · ${owned.nowhere.length} lines neither the ledger nor an own lock admits: a line is landed signed where it stands, never written in bare\n`);
|
|
305
|
-
return 1;
|
|
306
|
-
}
|
|
307
|
-
const places = placesIn(root);
|
|
308
|
-
const pinned = [...new Set([...owned.own.keys(), ...named])];
|
|
309
|
-
const touched = pinned.length === 0 && owned.ledger.length ? touchedBy(root, places, owned.ledger, lockStanding(store)) : [];
|
|
310
|
-
const every = pinned.length === 0 && touched.length === places.length && places.length > 0;
|
|
311
|
-
const regions = (pinned.length ? pinned : every ? places : touched).filter((one) => places.includes(one));
|
|
312
|
-
const where = every ? 'every place · then the root, where the places join' : regions.length ? regions.map((one) => `${one}/`).join(' · ') : 'the root alone, where the places join';
|
|
313
|
-
process.stdout.write(`ACTS ${where} · ${owned.ledger.length} lines to the ledger${[...owned.own].map(([place, lines]) => ` · ${lines.length} to ${place}'s own lock`).join('')} · before the lock\n`);
|
|
314
|
-
const asked = Date.now();
|
|
315
|
-
// Root-ledger writes may change grants or inherited policies. Child-only
|
|
316
|
-
// lots read that authority through publication, without excluding siblings.
|
|
317
|
-
const rootWrite = owned.ledger.length > 0 || every || regions.length === 0;
|
|
318
|
-
const enter = rootWrite ? underTheRegions : underAuthorityRegions;
|
|
319
|
-
return enter(store, rootWrite ? [...regions, ''] : regions, 'land', () => acceptNow(root, { ...batch, signed: owned.ledger, records: batch.signed }, started, owned, asked, regions));
|
|
320
|
-
}
|
|
321
|
-
async function acceptNow(root, batch, started, owned, asked = started, descent = []) {
|
|
322
|
-
const waited = Date.now() - asked;
|
|
323
|
-
if (waited > 60000)
|
|
324
|
-
process.stdout.write(`RED wait ${Math.round(waited / 1000)} s for the lock before the act · a wait over a minute is a red\n`);
|
|
325
|
-
const spent = [`sign ${asked - started}`, `wait ${waited}`];
|
|
326
|
-
const took = timing(spent);
|
|
327
|
-
const { signed, epoch } = batch;
|
|
328
|
-
if (refusesStandingPins(root, batch.records ?? signed))
|
|
329
|
-
return 1;
|
|
330
|
-
const store = storeOf(root);
|
|
331
|
-
const currentBase = fullDigest(store, localActLines(root, batch.base.places));
|
|
332
|
-
if (currentBase !== batch.base.digest) {
|
|
333
|
-
process.stderr.write(`${selfName()}: REFUSE·base moved ${batch.base.digest} → ${currentBase} · nothing landed\n`);
|
|
334
|
-
return 1;
|
|
335
|
-
}
|
|
336
|
-
try {
|
|
337
|
-
assertProspectiveRootClockSelection(root, signed);
|
|
338
|
-
}
|
|
339
|
-
catch (error) {
|
|
340
|
-
process.stderr.write(`${selfName()}: ${error instanceof Error ? error.message : String(error)} · nothing landed\n`);
|
|
341
|
-
return 1;
|
|
342
|
-
}
|
|
343
|
-
if (signed.some(line => !isConfig(line))) {
|
|
344
|
-
try {
|
|
345
|
-
await admittedObjects(root, [...signedOwnerLines(store), ...signed]);
|
|
346
|
-
}
|
|
347
|
-
catch (e) {
|
|
348
|
-
process.stderr.write(`${selfName()}: ${e instanceof Error ? e.message : String(e)} · nothing landed\n`);
|
|
349
|
-
return 1;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
const snapshot = took('lines', () => standingOf(root));
|
|
353
|
-
if (refusesAdmission(root, signed, snapshot.standing))
|
|
354
|
-
return 1;
|
|
355
|
-
let evidence;
|
|
356
|
-
try {
|
|
357
|
-
evidence = took('evidence', () => admissionEvidence(root, signed, snapshot.standing));
|
|
358
|
-
}
|
|
359
|
-
catch (error) {
|
|
360
|
-
process.stderr.write(`${selfName()}: ${error instanceof Error ? error.message : String(error)} · nothing landed\n`);
|
|
361
|
-
return 1;
|
|
362
|
-
}
|
|
363
|
-
const fold = evidence.fold;
|
|
364
|
-
const authority = took('authority', () => authorityFor([...lockLines(store), ...signed], rootSigner(root), signaturesOf(store).admitted));
|
|
365
|
-
for (const line of signed) {
|
|
366
|
-
const verdict = authority.of(line);
|
|
367
|
-
if (verdict.kind !== 'admitted') {
|
|
368
|
-
process.stderr.write(`${selfName()}: ${verdict.kind === 'refuse' ? verdict.why : `REFUSE·authority grey: ${verdict.why}`}\n`);
|
|
369
|
-
return 1;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
const withdraws = signed.filter((line) => fieldOf(line, 'value') === 'withdraw');
|
|
373
|
-
const coordinates = evidence.coordinates;
|
|
374
|
-
const withdrawn = withdraws.length ? withdrawal(withdraws, lockLines(store)) : null;
|
|
375
|
-
const view = `${wordOf(fold.standing, 'families', 'view')}/`;
|
|
376
|
-
const lot = fullDigest(store, signed);
|
|
377
|
-
const tree = hasVouchedTree(store)
|
|
378
|
-
? fullDigest(store, [...vouchedCoordinates(store)].sort(([a], [b]) => a.localeCompare(b)).map(([coordinate, digest]) => `${coordinate} ${digest}`))
|
|
379
|
-
: 'key' in fold && typeof fold.key === 'string' ? fold.key : fullDigest(store, fold.standing);
|
|
380
|
-
const cached = keptTakes(keptVerdict(store, tree, lot));
|
|
381
|
-
const judged = cached ?? evidence.judged;
|
|
382
|
-
if (!cached)
|
|
383
|
-
keepVerdict(store, tree, lot, judged.map(packTake));
|
|
384
|
-
const refused = judged.filter((one) => one.kind === 'refused' || (one.kind === 'judged' && one.verdict.kind === 'refuse'));
|
|
385
|
-
if (refused.length) {
|
|
386
|
-
for (const one of refused)
|
|
387
|
-
process.stdout.write(`REFUSE take ${one.scope} · ${one.kind === 'judged' ? one.verdict.why : one.kind === 'refused' ? one.why : ''}\n`);
|
|
388
|
-
process.stderr.write(`${selfName()}: REFUSE·takes nothing landed · ${refused.length} takes refused: a batch lands whole or not at all\n`);
|
|
389
|
-
return 1;
|
|
390
|
-
}
|
|
391
|
-
const told = took('told', () => standingOf(root, undefined, signed));
|
|
392
|
-
for (const name of openedBy(descent, told.standing, signed))
|
|
393
|
-
process.stderr.write(`OPEN ${name}\n`);
|
|
394
|
-
if (owned.own.size)
|
|
395
|
-
layReleases(store, root, told.standing, store);
|
|
396
|
-
const resultProfile = actResultProfile(snapshot.standing);
|
|
397
|
-
let landed = [];
|
|
398
|
-
if (resultProfile) {
|
|
399
|
-
const records = batch.records ?? signed;
|
|
400
|
-
const placements = [...(signed.length ? [{ place: '.', records: signed }] : []), ...[...owned.own].map(([place, records]) => ({ place: `${place}/${LOCK}`, records }))];
|
|
401
|
-
const digest = (bytes) => bytesDigest(store, new TextEncoder().encode(bytes));
|
|
402
|
-
const identity = actIdentity(records, { ...resultProfile, digest, placements, localEpoch: epoch });
|
|
403
|
-
const folder = writerFor(snapshot.standing, 'fold');
|
|
404
|
-
if (!folder)
|
|
405
|
-
throw Error('REFUSE·act native result requires a declared fold identity');
|
|
406
|
-
const receipt = canonical({ scope: resultProfile.scope, at: resultProfile.context, role: 'writes', form: 'alphabet', measure: 'digest', value: identity, by: folder, epoch: String(epoch) });
|
|
407
|
-
const bundle = { records: records.join('\n') + '\n', receipt: receipt + '\n', placements: placements.map(p => ({ place: p.place, records: p.records.join('\n') + '\n' })) };
|
|
408
|
-
await commitLocalAct(store, identity, descent, async () => bundle, intactLocalAct);
|
|
409
|
-
// Commitment precedes projections and conformance work. If either fails,
|
|
410
|
-
// this public identity still names the admitted act; it is never rollback.
|
|
411
|
-
process.stdout.write(`ACT ${identity} · epoch ${epoch} · admitted · conformance not asserted\n`);
|
|
412
|
-
for (const line of records)
|
|
413
|
-
process.stdout.write(line + '\n');
|
|
414
|
-
process.stdout.write(receipt + '\n');
|
|
415
|
-
landed = [{ at: 'committed act ' + identity, appended: records.length }];
|
|
416
|
-
}
|
|
417
|
-
else
|
|
418
|
-
landed = took('land', () => [...new Set(signed.map(line => fieldOf(line, 'by')))].map(by => land(store, by, signed.filter(line => fieldOf(line, 'by') === by))));
|
|
419
|
-
for (const [place, lines] of owned.own)
|
|
420
|
-
landOwned(root, place, lines, resultProfile !== undefined);
|
|
421
|
-
return underRootProjection(store, 'projection', async () => {
|
|
422
|
-
landSaid(store, writerFor(told.standing, 'fold'), []);
|
|
423
|
-
for (const line of signed) {
|
|
424
|
-
const value = fieldOf(line, 'value');
|
|
425
|
-
if (!/^[a-z0-9-]+:[0-9a-f]{32,}$/.test(value))
|
|
426
|
-
continue;
|
|
427
|
-
for (const need of locationsOf(fieldOf(line, 'needs')).locations) {
|
|
428
|
-
const at = join(root, need);
|
|
429
|
-
const bytes = observeFile(at);
|
|
430
|
-
if (bytes === undefined)
|
|
431
|
-
continue;
|
|
432
|
-
if (bytesDigest(store, bytes) === value)
|
|
433
|
-
landBlob(store, value, bytes);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
if (coordinates.taken.length) {
|
|
437
|
-
for (const path of coordinates.taken) {
|
|
438
|
-
if (existsSync(join(root, path)))
|
|
439
|
-
rmSync(join(root, path), { recursive: true });
|
|
440
|
-
for (let dir = dirname(path); dir !== '.' && existsSync(join(root, dir)) && !entriesIn(join(root, dir)).length; dir = dirname(dir))
|
|
441
|
-
rmdirSync(join(root, dir));
|
|
442
|
-
}
|
|
443
|
-
landCoordinates(store, new Map(), coordinates.taken, `withdraw:epoch-${epoch}`);
|
|
444
|
-
for (const path of coordinates.taken)
|
|
445
|
-
process.stdout.write(`GONE ${path} · withdrawn by its line\n`);
|
|
446
|
-
}
|
|
447
|
-
for (const one of judged)
|
|
448
|
-
landTake(root, one, []);
|
|
449
|
-
const standingAsked = [...signed, ...fold.standing].filter((line) => fieldOf(line, 'role') === 'demands' && fieldOf(line, 'value') !== 'withdraw');
|
|
450
|
-
const paidScopes = new Set(paidOf(store, standingAsked, fold.observed, view).paid.map((line) => fieldOf(line, 'scope')));
|
|
451
|
-
const late = lateFacts(store, [...signed, ...fold.standing], paidScopes);
|
|
452
|
-
if (late.length) {
|
|
453
|
-
land(store, 'judge', late);
|
|
454
|
-
for (const line of late)
|
|
455
|
-
if (fieldOf(line, 'measure') !== 'cone')
|
|
456
|
-
process.stdout.write(`LATE ${fieldOf(line, 'scope')} · answered from the landed cone\n`);
|
|
457
|
-
}
|
|
458
|
-
if (signed.some((line) => fieldOf(line, 'scope').startsWith(`${basename(ownRoot())}/`) && !fieldOf(line, 'scope').split('/').slice(1, -1).includes('uses'))) {
|
|
459
|
-
const code = instrumentOf(store, entryOf(root), told.standing, root, ownLock());
|
|
460
|
-
if (instrumentKept(store) !== code) {
|
|
461
|
-
const open = await closeReceipts(root, store);
|
|
462
|
-
instrumentKeep(store, code);
|
|
463
|
-
process.stderr.write(`open by instrument · ${open.length}\n`);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
const rendered = took('render', () => renderInto(root, store));
|
|
467
|
-
process.stdout.write(`RENDER 0\n`);
|
|
468
|
-
const own = new Set([...owned.own.values()].flat()).size;
|
|
469
|
-
const perLine = Math.round((Date.now() - started) / Math.max(1, signed.length + own));
|
|
470
|
-
const folder = writerFor(fold.standing, 'fold');
|
|
471
|
-
const beat = (ms, at) => canonical({ scope: 'beat/accept', role: 'writes', form: 'interval', measure: 'ms', value: `${ms}..${ms}`, by: folder ?? '', at: `place:${at}` });
|
|
472
|
-
if (folder !== undefined)
|
|
473
|
-
land(store, folder, [beat(perLine, 'line'), beat(1, fold.kept ? 'kept' : 'folded'), beat(Date.now() - started, 'total')]);
|
|
474
|
-
process.stdout.write(`FACT signed ${signed.length + own} · landed ${landed.length ? landed.map((one) => `${one.appended} in ${one.at}`).join(' · ') : '0'}${[...owned.own].map(([place, lines]) => ` · ${lines.length} in ${place}/${LOCK}`).join('')} · epoch ${epoch}\n`
|
|
475
|
-
+ `TARGET ${rendered.standing} claims · ${rendered.forks.length} forks · ${rendered.vacuous.length} vacuous · ${rendered.grey.length} grey · ${rendered.refused.length} refused · readings · no encounters computed · ${Date.now() - started} ms\n`
|
|
476
|
-
+ `SPENT ${spent.join(' ms · ')} ms · ${signed.length} lines\n`);
|
|
477
|
-
if (withdrawn) {
|
|
478
|
-
process.stdout.write(`WITHDRAW ${withdrawn.taken.length} taken · ${withdrawn.exact.length} exact on distributive scales · ${withdrawn.open.length} on open scales, not computed\n`);
|
|
479
|
-
for (const line of withdrawn.inexact)
|
|
480
|
-
process.stdout.write(`INEXACT ${fieldOf(line, 'scope')} · its scale is not distributive: what the others hold is not what they held without it\n`);
|
|
481
|
-
}
|
|
482
|
-
return 0;
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* A batch landed twice is one: nothing of it lands again. What it left unpaid is judged again, the way it would be now:
|
|
487
|
-
* each of its demands the fold counts unpaid is taken, and the takes land only when all of it holds.
|
|
488
|
-
*/
|
|
489
|
-
function repaid(root, proposed, started) {
|
|
490
|
-
const store = storeOf(root);
|
|
491
|
-
const prior = committedLocalActs(store).find(act => { const lines = act.bundle.records.trimEnd().split('\n'); return lines.length === proposed.length && lines.every((line, i) => line === proposed[i]); });
|
|
492
|
-
if (prior) {
|
|
493
|
-
process.stdout.write(`ACT ${prior.identity} · epoch ${fieldOf(prior.bundle.receipt.trim(), 'epoch')} · admitted · replay\n` + prior.bundle.records + prior.bundle.receipt);
|
|
494
|
-
}
|
|
495
|
-
const asked = new Set(proposed.filter((line) => fieldOf(line, 'role') === 'demands').map((line) => fieldOf(line, 'scope')));
|
|
496
|
-
const view = `${wordOf(foldClaims(signedOwnerLines(store)).standing, 'families', 'view')}/`;
|
|
497
|
-
const standingAsked = signedDemands(store).filter((line) => asked.has(fieldOf(line, 'scope')) && !fieldOf(line, 'scope').startsWith(view));
|
|
498
|
-
const owed = paidOf(store, standingAsked, [], view).missing;
|
|
499
|
-
if (!owed.length) {
|
|
500
|
-
process.stdout.write(`ONCE ${proposed.length} lines · every one already landed and every demand of it paid: a batch landed twice is one, nothing landed\n`);
|
|
501
|
-
return 0;
|
|
502
|
-
}
|
|
503
|
-
const judged = owed.map((line) => judgeDemand(root, line));
|
|
504
|
-
process.stdout.write(`ONCE ${proposed.length} lines · every one already landed · ${owed.length} of its demands unpaid, judged again\n`);
|
|
505
|
-
if (judged.every((one) => one.kind === 'owed')) {
|
|
506
|
-
for (const one of judged)
|
|
507
|
-
landTake(root, one, []);
|
|
508
|
-
return 0;
|
|
509
|
-
}
|
|
510
|
-
const refused = judged.filter((one) => one.kind === 'refused' || (one.kind === 'judged' && one.verdict.kind === 'refuse'));
|
|
511
|
-
if (refused.length) {
|
|
512
|
-
for (const one of refused)
|
|
513
|
-
process.stdout.write(`REFUSE take ${one.scope} · ${one.kind === 'judged' ? one.verdict.why : one.kind === 'refused' ? one.why : ''}\n`);
|
|
514
|
-
process.stderr.write(`${selfName()}: REFUSE·takes nothing landed · ${refused.length} takes refused: what a batch left unpaid is paid whole or not at all\n`);
|
|
515
|
-
return 1;
|
|
516
|
-
}
|
|
517
|
-
const standing = standingOf(root);
|
|
518
|
-
for (const one of judged)
|
|
519
|
-
landTake(root, one, []);
|
|
520
|
-
landSaid(store, writerFor(standing.standing, 'fold'), []);
|
|
521
|
-
const unpaidStanding = standing.standing.filter((line) => fieldOf(line, 'role') === 'demands' && fieldOf(line, 'value') !== 'withdraw');
|
|
522
|
-
const paidScopes = new Set(paidOf(store, unpaidStanding, [], `${wordOf(standing.standing, 'families', 'view')}/`).paid.map((line) => fieldOf(line, 'scope')));
|
|
523
|
-
const late = lateFacts(store, standing.standing, paidScopes);
|
|
524
|
-
if (late.length) {
|
|
525
|
-
land(store, 'judge', late);
|
|
526
|
-
for (const line of late)
|
|
527
|
-
if (fieldOf(line, 'measure') !== 'cone')
|
|
528
|
-
process.stdout.write(`LATE ${fieldOf(line, 'scope')} · answered from the landed cone\n`);
|
|
529
|
-
}
|
|
530
|
-
const rendered = renderInto(root, store);
|
|
531
|
-
process.stdout.write(`RENDER 0\n`);
|
|
532
|
-
process.stdout.write(`TARGET ${rendered.standing} claims · ${rendered.forks.length} forks · ${rendered.vacuous.length} vacuous · ${rendered.grey.length} grey · ${rendered.refused.length} refused · readings · no encounters computed · ${Date.now() - started} ms\n`);
|
|
533
|
-
return 0;
|
|
534
|
-
}
|
|
535
|
-
function packTake(one) {
|
|
536
|
-
return one.kind === 'judged'
|
|
537
|
-
? { kind: one.kind, scope: one.scope, demand: one.demand, locations: one.locations, before: [...one.before], after: [...one.after], verdict: one.verdict, ignored: [...one.ignored] }
|
|
538
|
-
: one;
|
|
539
|
-
}
|
|
540
|
-
function keptTakes(raw) {
|
|
541
|
-
if (raw === undefined)
|
|
542
|
-
return undefined;
|
|
543
|
-
const out = [];
|
|
544
|
-
for (const one of raw) {
|
|
545
|
-
if (one === null || typeof one !== 'object' || !('kind' in one) || !('scope' in one))
|
|
546
|
-
return undefined;
|
|
547
|
-
const row = one;
|
|
548
|
-
if (row.kind !== 'judged') {
|
|
549
|
-
out.push(row);
|
|
550
|
-
continue;
|
|
551
|
-
}
|
|
552
|
-
out.push({
|
|
553
|
-
kind: 'judged', scope: row.scope, demand: row.demand, locations: row.locations,
|
|
554
|
-
before: new Map(row.before), after: new Map(row.after), verdict: row.verdict, ignored: new Map(row.ignored), started: Date.now(),
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
return out;
|
|
558
|
-
}
|
|
1
|
+
var _e=Object.defineProperty;var F=(n,r)=>_e(n,"name",{value:r,configurable:!0});import{BoundRefusal as $e}from"../host/refusals.js";import{assertHostNotCancelled as oe}from"../host/host-controls.js";import{library11_authorityAtEpoch as He}from"../vendor/runtime.js";import{requireEffects as qe}from"../host/read-only.js";import{hostOutput as o}from"../host/call-context.js";import{assertProspectiveRootClockSelection as ke}from"../host/root-clock-source.js";import{hasContextualPlace as ze,landContextualPlace as Ve}from"../host/contextual-place.js";import{commitLocalAct as Je,intactLocalAct as Xe,committedLocalActs as Qe}from"../host/ports/local-act.js";import{withoutEffects as Ye}from"../host/read-only.js";import{admittedLine as Ze}from"../host/selected-topos.js";import{timing as en}from"../host/timing.js";import{admittedObjects as le}from"../host/objects.js";import{existsSync as ye,rmdirSync as nn,rmSync as tn}from"node:fs";import{dirname as Ee,join as H,basename as rn}from"node:path";import{closeReceipts as on,instrumentKeep as sn,instrumentKept as an}from"../fold/closed.js";import{bytesDigest as ve,fullDigest as Y,instrumentOf as dn,signaturesOf as I}from"../fold/digests.js";import{library11_canonical as be,library11_LOCK as fe,library11_parse as Se,library11_actIdentity as cn,library11_actResultProfile as Re}from"../vendor/runtime.js";import{fieldOf as t,isConfig as q,foldClaims as Fe,sayingOf as D,selfName as k}from"../fold/claims.js";import{isReaderLock as ln}from"../fold/observed.js";import{authorityFor as Z,publicKeyOf as xe,rootSigner as ee,writerFor as ie}from"../fold/signers.js";import{lockLines as C,lockStanding as z}from"../fold/keys.js";import{keepVerdict as fn,keptVerdict as un,land as se,landBlob as hn,ledgerLines as mn,storeOf as N}from"../land/ledger.js";import{signConsentLot as pn,verifiesOwnerLine as gn}from"../land/sign.js";import{signerFor as wn}from"../host/signing.js";import{appliedIn as $n,ownLockOf as kn}from"../fold/signed.js";import{wordOf as V}from"../fold/wire.js";import{hasVouchedTree as yn,landCoordinates as En,locationsOf as vn,vouchedCoordinates as bn}from"../land/vouched.js";import{entriesIn as Sn,observeFile as Rn}from"../observe/files.js";import{coneOf as Fn,standingOf as ue}from"./place.js";import{ownLock as xn,ownRoot as jn}from"../observe/runner.js";import{widenedWithoutWitness as On}from"../judge/widening.js";import{retractedTogether as Un,withdrawal as An}from"../land/withdraw.js";import{isCeiling as ae}from"../fold/configures.js";import{inertIn as Dn}from"../land/inert.js";import{landSaid as je}from"./pass.js";import{underTheLock as Ln,underTheRegions as Tn,underAuthorityRegions as Cn,underRootProjection as In}from"../land/act.js";import{openedBy as Nn}from"../fold/opened.js";import{touchedBy as Mn}from"../fold/reach.js";import{landOwned as Wn,ownedOf as Oe}from"../land/owned.js";import{layReleases as Pn}from"../host/release.js";import{foundableIn as Bn,placesIn as he}from"../fold/places.js";import{outsideTheirCapsule as Kn}from"../fold/own.js";import{lateFacts as Ue}from"../judge/late.js";import{paidOf as me}from"../fold/paid.js";import{aliasPinned as Gn}from"../land/alias.js";import{admitStandingPins as _n}from"../land/standing-pin.js";import{coordinatesWithdrawn as Hn}from"../land/leaving.js";import{ownerOf as qn,epochOf as Ae,localActLines as De,forksItself as zn,forksJoinedBy as Vn,renderInto as Le,sideOf as Jn,signedDemands as Xn,signedOwnerLines as J}from"./owner.js";import{claimLinesIn as pe,entryOf as Te,namedPlaces as ne,placesOfFile as Ce,positionalsOf as ge,valueOf as X}from"./args.js";import{FLAGS as Q}from"./names.js";import{judgeDemand as Ie,landTake as we}from"./takes.js";function Ne(n,r,c){return Ye(()=>{const i=N(n);ke(n,r);const S=!r.some(ln)&&r.some(ae),y=S?Fn(n,Te(n),r.filter(ae)):{standing:c,observed:[],own:{},kept:!0};if(Dn(r,{standing:y.standing,ceiling:ae,signsReader:!S,observed:y.observed,own:y.own,epoch:Ae([...C(i),...r])}).length)throw Error("REFUSE\xB7inert no existing reading meets these ceilings; fold the declared inputs first");const m=Hn(n,i,r,[...r,...c]);if(m.refused.length)throw Error(`REFUSE\xB7withdraw a file is still read: ${m.refused.map(d=>`${d.path} by ${d.by}`).join(" \xB7 ")}`);const l=`${V(c,"families","view")}/`,g=r.filter(d=>q(d)&&t(d,"role")==="demands"&&t(d,"value")!=="withdraw"&&!t(d,"scope").startsWith(l)).map(d=>{const h=t(d,"scope");return c.some($=>q($)&&t($,"role")==="demands"&&t($,"value")!=="withdraw"&&t($,"scope")===h&&t($,"form")===t(d,"form")&&t($,"measure")===t(d,"measure"))?Ie(n,d):{kind:"owed",scope:h,why:"new demand declared; no conformance reading is claimed"}}),f=g.filter(d=>d.kind==="refused"||d.kind==="judged"&&d.verdict.kind==="refuse");if(f.length)throw Error(`REFUSE\xB7takes ${f.map(d=>`${d.scope}: ${d.kind==="judged"?d.verdict.why:d.kind==="refused"?d.why:""}`).join(" \xB7 ")}`);return{coordinates:m,judged:g,fold:y}})}F(Ne,"admissionEvidence");function Qn(n,r){const c=On(n,r,ae,V(r,"at-classes","witness"));if(c.length){for(const i of c)o("error",`WIDER ${t(i,"scope")} \xB7 ${t(i,"value")}
|
|
2
|
+
`);return o("error",`${k()}: REFUSE\xB7widening nothing landed \xB7 a ceiling that admits more than it did gives back freedom the lock had spent: sign it under a witness that names what made the old ceiling wrong
|
|
3
|
+
`),!0}return!1}F(Qn,"refusesWidening");function Me(n,r,c){if(Qn(r,c))return!0;const i=N(n),S=Kn(n,c,r);for(const m of S)o("error",`OUTSIDE ${t(m,"scope")} \xB7 ${t(m,"value")}
|
|
4
|
+
`);if(S.length)return o("error",`${k()}: REFUSE\xB7outside nothing landed \xB7 a reader or a capsule lands in the capsule of its world, never in the wire or the instrument
|
|
5
|
+
`),!0;const y=Vn(i,r).filter(m=>zn(m.lines)||m.lines.filter(l=>r.includes(l)).length>1);if(y.length){for(const m of y){o("error",`FORK ${m.key}
|
|
6
|
+
`);for(const l of m.lines)o("error",` ${r.includes(l)?"new ":"held"} by=${t(l,"by")} ${Jn(l,C(i))}
|
|
7
|
+
`)}return o("error",`${k()}: REFUSE\xB7fork nothing landed \xB7 one signer never forks itself, and one act never forks itself: withdraw the held side in this batch, or sign the other reading under its own scope
|
|
8
|
+
`),!0}const w=Gn(n,r);if(w.length){for(const m of w)o("error",`ALIAS ${m.scope} \xB7 ${m.digest} \xB7 ${m.by.join(" ")}
|
|
9
|
+
`);return o("error",`${k()}: REFUSE\xB7alias nothing landed \xB7 an alias is withdrawn only when no pin names its digest
|
|
10
|
+
`),!0}return!1}F(Me,"refusesAdmission");function We(n,r){try{return _n(n,r),!1}catch(c){return o("error",`${k()}: ${c instanceof Error?c.message:String(c)}
|
|
11
|
+
`),!0}}F(We,"refusesStandingPins");async function Pe(n,r,c,i){const S=i?[[[],i.records]]:c.map(e=>[Ce(e),pe(e)]),y=S.flatMap(([,e])=>e);if(!y.length)return o("error",`${k()}: a batch is a file with claim lines
|
|
12
|
+
`),{kind:"exit",code:2};const w=y.filter(e=>!t(e,"sig")),m=w.filter(e=>t(e,"epoch")||!["","target"].includes(t(e,"by")));if(m.length){for(const e of m)o("error",`BARE ${t(e,"scope")} \xB7 by=${t(e,"by")||"\u2205"}${t(e,"epoch")?` epoch=${t(e,"epoch")}`:""}
|
|
13
|
+
`);return o("error",`${k()}: REFUSE\xB7bare nothing landed \xB7 ${m.length} lines name a signer or an epoch they were not signed with: a drafted line proposes by=target and sign signs it, a line a lane signed carries its sig
|
|
14
|
+
`),{kind:"exit",code:1}}const l=N(n),g=[...new Set([...ne(r),...S.flatMap(([e])=>e)])],f=z(l),d=g.filter(e=>!he(n).includes(e)&&!Bn(n,f,V(f,"families","region"),e));if(d.length)return o("error",`${k()}: REFUSE\xB7place nothing landed \xB7 ${d.join(", ")} is no place of the tree, and no line of the root founds it: --place names the own lock a line lands in
|
|
15
|
+
`),{kind:"exit",code:2};const h=De(n,g),L={digest:Y(l,h),places:g},$=Ae(h)+1,x=y.filter(e=>t(e,"sig")).flatMap(e=>((p,b)=>b===void 0||!gn(e,b,I(l).admitted)?[`${t(e,"scope")} \xB7 the signature does not hold for ${p||"\u2205"}`]:[])(t(e,"by"),xe(n,t(e,"by"))));if(x.length){for(const e of x)o("error",`SIGNED ${e}
|
|
16
|
+
`);return o("error",`${k()}: REFUSE\xB7signed nothing landed \xB7 ${x.length} lines a lane signed stand at no epoch this act
|
|
17
|
+
`),{kind:"exit",code:1}}const[s,T]=[ne(r),he(n)],M=new Set(C(l).map(D)),v=new Map(T.map(e=>[e,new Set($n(n,e).map(D))])),U=Z(C(l),ee(n),I(l).admitted),de=F(e=>!!t(e,"sig")&&U.of(e).kind==="admitted"&&mn(l,t(e,"by")).includes(e),"delivered"),te=F((e,p=s.length?s:S.flatMap(([b,j])=>j.includes(e)?b:[]))=>p.length?p.every(b=>v.get(b)?.has(D(e))):de(e)||M.has(D(e))||T.some(b=>v.get(b)?.has(D(e))),"held");if(y.every(e=>te(e))){if(y.some(e=>!q(e)))try{await le(n,[...J(l),...y])}catch(e){return o("error",`${k()}: ${String(e)} \xB7 nothing landed
|
|
18
|
+
`),{kind:"exit",code:1}}return{kind:"once",proposed:y}}const K=y.filter(e=>t(e,"sig")&&q(e)&&Number(t(e,"epoch"))!==$);if(K.length){for(const e of K)o("error",`SIGNED ${t(e,"scope")} \xB7 signed by ${t(e,"by")} at epoch ${t(e,"epoch")}, and this act lands at ${$}: sign it again
|
|
19
|
+
`);return o("error",`${k()}: REFUSE\xB7signed nothing landed \xB7 ${K.length} lines a lane signed stand at no epoch this act
|
|
20
|
+
`),{kind:"exit",code:1}}const re=i?void 0:X(r,Q.keyFile),A=i?.keyId??X(r,Q.key)??qn(l),G=w.length?xe(n,A):void 0;if(w.length&&!G)return o("error",`${k()}: unknown key ${A} \u2014 name it in ${k()}.keys
|
|
21
|
+
`),{kind:"exit",code:2};let O=y.filter(e=>t(e,"sig"));if(i&&w.length){oe(i.signal);const e=Z(C(l),ee(n),I(l).admitted).admitted.find(p=>p.id===A);for(const p of w){const b=Se(p);if(b.kind!=="fact"||!e||He({...b.value.fields,by:A,epoch:String($)},e,$,t(p,"scope"),"authority").kind!=="admitted")throw new $e("host/receiver-authority","REFUSE\xB7host/receiver-authority")}}if(w.length){let e;try{e=wn([...z(l),...g.flatMap(j=>kn(n,j))],A,i?.signer.name??X(r,Q.signer),re,i?.signer)}catch(j){return o("error",`${k()}: ${j instanceof Error?j.message:"REFUSE\xB7signer unavailable"}
|
|
22
|
+
`),{kind:"exit",code:1}}const p=await pn(w,{epoch:$,by:A,algorithm:I(l).era},G,I(l).admitted,e);if(p.kind==="refuse")return o("error",`${k()}: ${p.why}
|
|
23
|
+
`),{kind:"exit",code:1};let b=0;O=y.map(j=>t(j,"sig")?j:p.lines[b++])}const W=[...J(l),...O].flatMap(e=>{const p=Se(e);return p.kind==="fact"?[p.value.fields]:[]});for(const e of O){const p=Ze(e,W,Number(t(e,"epoch")),Fe(J(l)).standing.filter(b=>t(b,"scope").startsWith("uses/")&&t(b,"value")!=="withdraw"));if(p.kind!=="fact")return o("error",`${k()}: REFUSE\xB7wire ${t(e,"scope")} \xB7 ${p.why} \xB7 nothing landed
|
|
24
|
+
`),{kind:"exit",code:1}}if(We(n,O))return{kind:"exit",code:1};const P=Un(O);if(P.length){for(const e of P)o("error",`WITHDRAW ${D(e.withdraw)}
|
|
25
|
+
`),o("error",`NEW ${D(e.line)}
|
|
26
|
+
`);return o("error",`${k()}: REFUSE\xB7withdraw nothing landed \xB7 a withdraw matches a new line in this batch, so it takes that line too
|
|
27
|
+
`),{kind:"exit",code:1}}const a=Z([...C(l),...O],ee(n),I(l).admitted),E=Oe(n,O,e=>a.of(e).kind==="admitted",e=>a.admitted.find(p=>p.id===e)?.coverage??[],s,e=>{const p=S.flatMap(([b,j])=>j.some(B=>D(B)===D(e))?b:[]);return p.length?p:void 0});if(E.nowhere.length){for(const e of E.nowhere)o("error",`${k()}: REFUSE\xB7signer ${A} uncovered ${t(e,"scope")} \xB7 nothing signed for delivery
|
|
28
|
+
`);return{kind:"exit",code:1}}if(E.forked.length){for(const e of E.forked)o("error",`FORKED ${e.place}/${fe} \xB7 ${e.key} \xB7 the lot would leave two standing claims where the lock had one
|
|
29
|
+
`);return o("error",`${k()}: REFUSE\xB7forked nothing landed \xB7 ${E.forked.length} claims an own lot would fork: a lot for many places lands the same lines at each, and lines meant for one place go in a lot of their own
|
|
30
|
+
`),{kind:"exit",code:1}}if(Me(n,E.ledger,z(l)))return{kind:"exit",code:1};if(O.some(e=>!q(e)))try{await le(n,[...J(l),...O],e=>o("out",e+`
|
|
31
|
+
`))}catch(e){return o("error",`${k()}: ${e instanceof Error?e.message:String(e)} \xB7 nothing landed
|
|
32
|
+
`),{kind:"exit",code:1}}try{Ne(n,E.ledger,z(l))}catch(e){return o("error",`${k()}: ${e instanceof Error?e.message:String(e)} \xB7 nothing landed
|
|
33
|
+
`),{kind:"exit",code:1}}return{kind:"signed",signed:O,epoch:$,base:L,...w.length?{keyId:A}:{}}}F(Pe,"signedBatch");async function er(n,r){const c=Date.now(),i=ge(r);if(i.length===1&&ze(n)&&!pe(i[0]).length){if(ne(r).length||X(r,Q.key)||X(r,Q.keyFile)||X(r,Q.signer))throw Error("REFUSE\xB7contextual place accepts one already signed context envelope");const m=await Ve(n,i[0]);return o("out",JSON.stringify({profile:"place-act-context@1",identity:m.identity,status:m.kind,context:m.context,receipts:m.receipts})+`
|
|
34
|
+
`),0}const S=ne(r),y=ge(r).reduce((m,l)=>(g=>g.length?pe(l).reduce((f,d)=>f.set(D(d),[...new Set([...f.get(D(d))??[],...g])]),m):m)(Ce(l)),new Map),w=await Pe(n,r,ge(r));return Be(n,r,w,y,c)}F(er,"accept");async function nr(n,r){if(qe("Root lot admission"),oe(r.signal),!Re(z(N(n))))throw new $e("host/act","REFUSE\xB7Root host requires the admitted atomic result profile");const c=Date.now(),i=await Pe(n,[],[],r);return Be(n,[],i,new Map,c,r)}F(nr,"acceptRootRecords");async function Be(n,r,c,i,S,y){const w=ne(r);if(c.kind==="exit")return c.code;if(c.kind==="once")return Ln(N(n),"land",()=>Zn(n,c.proposed,S));const m=N(n),l=Z([...C(m),...c.signed],ee(n),I(m).admitted),g=Oe(n,c.signed,v=>l.of(v).kind==="admitted",v=>l.admitted.find(U=>U.id===v)?.coverage??[],w,v=>i.get(D(v)));if(g.nowhere.length){for(const v of g.nowhere)o("error",`NOWHERE ${t(v,"scope")} \xB7 ${(U=>U.kind==="admitted"?"admitted":U.why)(l.of(v))}, and ${w.length?`no place of ${w.join(", ")} takes it`:"no one own lock it covers takes it: name the places with --place"}
|
|
35
|
+
`);return o("error",`${k()}: REFUSE\xB7nowhere nothing landed \xB7 ${g.nowhere.length} lines neither the ledger nor an own lock admits: a line is landed signed where it stands, never written in bare
|
|
36
|
+
`),1}const f=he(n),d=[...new Set([...g.own.keys(),...w])],h=d.length===0&&g.ledger.length?Mn(n,f,g.ledger,z(m)):[],L=d.length===0&&h.length===f.length&&f.length>0,$=(d.length?d:L?f:h).filter(v=>f.includes(v)),x=L?"every place \xB7 then the root, where the places join":$.length?$.map(v=>`${v}/`).join(" \xB7 "):"the root alone, where the places join";o("out",`ACTS ${x} \xB7 ${g.ledger.length} lines to the ledger${[...g.own].map(([v,U])=>` \xB7 ${U.length} to ${v}'s own lock`).join("")} \xB7 before the lock
|
|
37
|
+
`);const s=Date.now(),T=g.ledger.length>0||L||$.length===0;return(T?Tn:Cn)(m,T?[...$,""]:$,"land",()=>Yn(n,{...c,signed:g.ledger,records:c.signed},S,g,s,$,y))}F(Be,"finishAcceptance");async function Yn(n,r,c,i,S=c,y=[],w){const m=Date.now()-S;m>6e4&&o("out",`RED wait ${Math.round(m/1e3)} s for the lock before the act \xB7 a wait over a minute is a red
|
|
38
|
+
`);const l=[`sign ${S-c}`,`wait ${m}`],g=en(l),{signed:f,epoch:d}=r;if(We(n,r.records??f))return 1;const h=N(n),L=Y(h,De(n,r.base.places));if(L!==r.base.digest)return o("error",`${k()}: REFUSE\xB7base moved ${r.base.digest} \u2192 ${L} \xB7 nothing landed
|
|
39
|
+
`),1;try{ke(n,f)}catch(a){return o("error",`${k()}: ${a instanceof Error?a.message:String(a)} \xB7 nothing landed
|
|
40
|
+
`),1}if(f.some(a=>!q(a)))try{await le(n,[...J(h),...f])}catch(a){return o("error",`${k()}: ${a instanceof Error?a.message:String(a)} \xB7 nothing landed
|
|
41
|
+
`),1}const $=g("lines",()=>ue(n));if(Me(n,f,$.standing))return 1;let x;try{x=g("evidence",()=>Ne(n,f,$.standing))}catch(a){return o("error",`${k()}: ${a instanceof Error?a.message:String(a)} \xB7 nothing landed
|
|
42
|
+
`),1}const s=x.fold,T=g("authority",()=>Z([...C(h),...f],ee(n),I(h).admitted));for(const a of f){const E=T.of(a);if(E.kind!=="admitted")return o("error",`${k()}: ${E.kind==="refuse"?E.why:`REFUSE\xB7authority grey: ${E.why}`}
|
|
43
|
+
`),1}const M=f.filter(a=>t(a,"value")==="withdraw"),v=x.coordinates,U=M.length?An(M,C(h)):null,de=`${V(s.standing,"families","view")}/`,te=Y(h,f),K=yn(h)?Y(h,[...bn(h)].sort(([a],[E])=>a.localeCompare(E)).map(([a,E])=>`${a} ${E}`)):"key"in s&&typeof s.key=="string"?s.key:Y(h,s.standing),re=nt(un(h,K,te)),A=re??x.judged;re||fn(h,K,te,A.map(et));const G=A.filter(a=>a.kind==="refused"||a.kind==="judged"&&a.verdict.kind==="refuse");if(G.length){for(const a of G)o("out",`REFUSE take ${a.scope} \xB7 ${a.kind==="judged"?a.verdict.why:a.kind==="refused"?a.why:""}
|
|
44
|
+
`);return o("error",`${k()}: REFUSE\xB7takes nothing landed \xB7 ${G.length} takes refused: a batch lands whole or not at all
|
|
45
|
+
`),1}const O=g("told",()=>ue(n,void 0,f));for(const a of Nn(y,O.standing,f))o("error",`OPEN ${a}
|
|
46
|
+
`);i.own.size&&Pn(h,n,O.standing,h);const W=Re($.standing);let P=[];if(W){const a=r.records??f,E=[...f.length?[{place:".",records:f}]:[],...[...i.own].map(([u,R])=>({place:`${u}/${fe}`,records:R}))],p=cn(a,{...W,digest:F(u=>ve(h,new TextEncoder().encode(u)),"digest"),placements:E,localEpoch:d}),b=ie($.standing,"fold");if(!b)throw Error("REFUSE\xB7act native result requires a declared fold identity");const j=be({scope:W.scope,at:W.context,role:"writes",form:"alphabet",measure:"digest",value:p,by:b,epoch:String(d)}),B={records:a.join(`
|
|
47
|
+
`)+`
|
|
48
|
+
`,receipt:j+`
|
|
49
|
+
`,placements:E.map(u=>({place:u.place,records:u.records.join(`
|
|
50
|
+
`)+`
|
|
51
|
+
`}))};oe(w?.signal),w?.prepared?.(p),oe(w?.signal);const _=await Je(h,p,y,async()=>B,Xe,w?.storage,w?.signal);w?.committed?.(p,_,_.kind),o("out",`ACT ${p} \xB7 epoch ${d} \xB7 admitted \xB7 conformance not asserted
|
|
52
|
+
`);for(const u of a)o("out",u+`
|
|
53
|
+
`);o("out",j+`
|
|
54
|
+
`),P=[{at:"committed act "+p,appended:a.length}]}else P=g("land",()=>[...new Set(f.map(a=>t(a,"by")))].map(a=>se(h,a,f.filter(E=>t(E,"by")===a))));for(const[a,E]of i.own)Wn(n,a,E,W!==void 0);return In(h,"projection",async()=>{je(h,ie(O.standing,"fold"),[]);for(const u of f){const R=t(u,"value");if(/^[a-z0-9-]+:[0-9a-f]{32,}$/.test(R))for(const Ke of vn(t(u,"needs")).locations){const Ge=H(n,Ke),ce=Rn(Ge);ce!==void 0&&ve(h,ce)===R&&hn(h,R,ce)}}if(v.taken.length){for(const u of v.taken){ye(H(n,u))&&tn(H(n,u),{recursive:!0});for(let R=Ee(u);R!=="."&&ye(H(n,R))&&!Sn(H(n,R)).length;R=Ee(R))nn(H(n,R))}En(h,new Map,v.taken,`withdraw:epoch-${d}`);for(const u of v.taken)o("out",`GONE ${u} \xB7 withdrawn by its line
|
|
55
|
+
`)}for(const u of A)we(n,u,[]);const a=[...f,...s.standing].filter(u=>t(u,"role")==="demands"&&t(u,"value")!=="withdraw"),E=new Set(me(h,a,s.observed,de).paid.map(u=>t(u,"scope"))),e=Ue(h,[...f,...s.standing],E);if(e.length){se(h,"judge",e);for(const u of e)t(u,"measure")!=="cone"&&o("out",`LATE ${t(u,"scope")} \xB7 answered from the landed cone
|
|
56
|
+
`)}if(f.some(u=>t(u,"scope").startsWith(`${rn(jn())}/`)&&!t(u,"scope").split("/").slice(1,-1).includes("uses"))){const u=dn(h,Te(n),O.standing,n,xn());if(an(h)!==u){const R=await on(n,h);sn(h,u),o("error",`open by instrument \xB7 ${R.length}
|
|
57
|
+
`)}}const p=g("render",()=>Le(n,h));o("out",`RENDER 0
|
|
58
|
+
`);const b=new Set([...i.own.values()].flat()).size,j=Math.round((Date.now()-c)/Math.max(1,f.length+b)),B=ie(s.standing,"fold"),_=F((u,R)=>be({scope:"beat/accept",role:"writes",form:"interval",measure:"ms",value:`${u}..${u}`,by:B??"",at:`place:${R}`}),"beat");if(B!==void 0&&se(h,B,[_(j,"line"),_(1,s.kept?"kept":"folded"),_(Date.now()-c,"total")]),o("out",`FACT signed ${f.length+b} \xB7 landed ${P.length?P.map(u=>`${u.appended} in ${u.at}`).join(" \xB7 "):"0"}${[...i.own].map(([u,R])=>` \xB7 ${R.length} in ${u}/${fe}`).join("")} \xB7 epoch ${d}
|
|
59
|
+
TARGET ${p.standing} claims \xB7 ${p.forks.length} forks \xB7 ${p.vacuous.length} vacuous \xB7 ${p.grey.length} grey \xB7 ${p.refused.length} refused \xB7 readings \xB7 no encounters computed \xB7 ${Date.now()-c} ms
|
|
60
|
+
SPENT ${l.join(" ms \xB7 ")} ms \xB7 ${f.length} lines
|
|
61
|
+
`),U){o("out",`WITHDRAW ${U.taken.length} taken \xB7 ${U.exact.length} exact on distributive scales \xB7 ${U.open.length} on open scales, not computed
|
|
62
|
+
`);for(const u of U.inexact)o("out",`INEXACT ${t(u,"scope")} \xB7 its scale is not distributive: what the others hold is not what they held without it
|
|
63
|
+
`)}return 0})}F(Yn,"acceptNow");function Zn(n,r,c){const i=N(n),S=Qe(i).find(s=>{const T=s.bundle.records.trimEnd().split(`
|
|
64
|
+
`);return T.length===r.length&&T.every((M,v)=>M===r[v])});S&&o("out",`ACT ${S.identity} \xB7 epoch ${t(S.bundle.receipt.trim(),"epoch")} \xB7 admitted \xB7 replay
|
|
65
|
+
`+S.bundle.records+S.bundle.receipt);const y=new Set(r.filter(s=>t(s,"role")==="demands").map(s=>t(s,"scope"))),w=`${V(Fe(J(i)).standing,"families","view")}/`,m=Xn(i).filter(s=>y.has(t(s,"scope"))&&!t(s,"scope").startsWith(w)),l=me(i,m,[],w).missing;if(!l.length)return o("out",`ONCE ${r.length} lines \xB7 every one already landed and every demand of it paid: a batch landed twice is one, nothing landed
|
|
66
|
+
`),0;const g=l.map(s=>Ie(n,s));if(o("out",`ONCE ${r.length} lines \xB7 every one already landed \xB7 ${l.length} of its demands unpaid, judged again
|
|
67
|
+
`),g.every(s=>s.kind==="owed")){for(const s of g)we(n,s,[]);return 0}const f=g.filter(s=>s.kind==="refused"||s.kind==="judged"&&s.verdict.kind==="refuse");if(f.length){for(const s of f)o("out",`REFUSE take ${s.scope} \xB7 ${s.kind==="judged"?s.verdict.why:s.kind==="refused"?s.why:""}
|
|
68
|
+
`);return o("error",`${k()}: REFUSE\xB7takes nothing landed \xB7 ${f.length} takes refused: what a batch left unpaid is paid whole or not at all
|
|
69
|
+
`),1}const d=ue(n);for(const s of g)we(n,s,[]);je(i,ie(d.standing,"fold"),[]);const h=d.standing.filter(s=>t(s,"role")==="demands"&&t(s,"value")!=="withdraw"),L=new Set(me(i,h,[],`${V(d.standing,"families","view")}/`).paid.map(s=>t(s,"scope"))),$=Ue(i,d.standing,L);if($.length){se(i,"judge",$);for(const s of $)t(s,"measure")!=="cone"&&o("out",`LATE ${t(s,"scope")} \xB7 answered from the landed cone
|
|
70
|
+
`)}const x=Le(n,i);return o("out",`RENDER 0
|
|
71
|
+
`),o("out",`TARGET ${x.standing} claims \xB7 ${x.forks.length} forks \xB7 ${x.vacuous.length} vacuous \xB7 ${x.grey.length} grey \xB7 ${x.refused.length} refused \xB7 readings \xB7 no encounters computed \xB7 ${Date.now()-c} ms
|
|
72
|
+
`),0}F(Zn,"repaid");function et(n){return n.kind==="judged"?{kind:n.kind,scope:n.scope,demand:n.demand,locations:n.locations,before:[...n.before],after:[...n.after],verdict:n.verdict,ignored:[...n.ignored]}:n}F(et,"packTake");function nt(n){if(n===void 0)return;const r=[];for(const c of n){if(c===null||typeof c!="object"||!("kind"in c)||!("scope"in c))return;const i=c;if(i.kind!=="judged"){r.push(i);continue}r.push({kind:"judged",scope:i.scope,demand:i.demand,locations:i.locations,before:new Map(i.before),after:new Map(i.after),verdict:i.verdict,ignored:new Map(i.ignored),started:Date.now()})}return r}F(nt,"keptTakes");export{er as accept,nr as acceptRootRecords,Pe as signedBatch};
|