@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/cli/place.js
CHANGED
|
@@ -1,282 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { point, region, within } from '@lapxo/obligations/field';
|
|
8
|
-
import { basename, join } from 'node:path';
|
|
9
|
-
import { observeText } from "../observe/files.js";
|
|
10
|
-
import { placesOf, viewsOf } from "../fold/views.js";
|
|
11
|
-
import { prerender, viewOf } from "../render/view.js";
|
|
12
|
-
import { meets, instrumentKept } from "../fold/closed.js";
|
|
13
|
-
import { foldPoints, keepFold, keptPlace } from "../fold/kept.js";
|
|
14
|
-
import { openCells } from "../render/open.js";
|
|
15
|
-
import { boundOf, packRegions, regionsNamed, regionsOf, unlikeReplay } from "../fold/region.js";
|
|
16
|
-
import { answersElsewhere, foldCeilings, ceilingSummary } from "../fold/ceilings.js";
|
|
17
|
-
import { keyOf, keyFor, lockLines, lockStanding } from "../fold/keys.js";
|
|
18
|
-
import { wordFrom, wordOf, wordOn } from "../fold/wire.js";
|
|
19
|
-
import { bytesDigest, instrumentOf, signaturesOf } from "../fold/digests.js";
|
|
20
|
-
import { claimKey, fieldOf, fieldsOf, isWire } from "../fold/claims.js";
|
|
21
|
-
import { canonical, LOCK, parse } from '@lapxo/topos/wire';
|
|
22
|
-
import { classDefaults, kindsOf, placesIn, spoken } from "../fold/places.js";
|
|
23
|
-
import { isCeiling } from "../fold/configures.js";
|
|
24
|
-
import { observedClaims, placedReadings } from "../fold/observed.js";
|
|
25
|
-
import { capsuleReadingsOver, currentReceiptObservations, retiredReceiptHistory } from "../observe/regions.js";
|
|
26
|
-
import { costReadings, ownReadings, currentActReadings } from "../fold/own.js";
|
|
27
|
-
import { paidOf } from "../fold/paid.js";
|
|
28
|
-
import { rolesOf } from "../fold/roles.js";
|
|
29
|
-
import { secondHead } from "../fold/second.js";
|
|
30
|
-
import { authorityFor, rootSigner, writerFor } from "../fold/signers.js";
|
|
31
|
-
import { ledgerLines, storeOf } from "../land/ledger.js";
|
|
32
|
-
import { vouchedCoordinates } from "../land/vouched.js";
|
|
33
|
-
import { ownLock, ownRoot } from "../observe/runner.js";
|
|
34
|
-
import { epochOf, historyOf, renderedLock, standingDemands } from "./owner.js";
|
|
35
|
-
function beatsOf(store, standing, under) {
|
|
36
|
-
const folder = writerFor(standing, 'fold');
|
|
37
|
-
const middle = (at) => {
|
|
38
|
-
const ms = (folder === undefined ? [] : ledgerLines(store, folder))
|
|
39
|
-
.filter((line) => fieldOf(line, 'scope') === `beat/${under ?? '.'}` && fieldOf(line, 'at') === `place:${at}`)
|
|
40
|
-
.map((line) => Number(fieldOf(line, 'value').split('..')[0])).filter((one) => Number.isFinite(one)).slice(-10).sort((a, b) => a - b);
|
|
41
|
-
return ms.length ? ms[Math.floor(ms.length / 2)] ?? 0 : 0;
|
|
42
|
-
};
|
|
43
|
-
return { kept: middle('kept'), folded: middle('folded') };
|
|
44
|
-
}
|
|
45
|
-
const costsOf = (store) => ledgerLines(store, 'take').filter((line) => fieldOf(line, 'measure') === 'ms')
|
|
46
|
-
.map((line) => Number(fieldOf(line, 'value').split('..')[0])).filter((ms) => Number.isFinite(ms)).slice(-10);
|
|
47
|
-
function effectStates(_store) {
|
|
48
|
-
return 'none';
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* The fold of a place: the standing lock and what readers saw, narrowed to the place when one is named. A demand is the
|
|
52
|
-
* place's when every place it asks about lies there; a SHORT on a question also read outside it is not the place's to
|
|
53
|
-
* answer. The count of a place's own readings is the instrument's, taken inside the place alone. What each key has
|
|
54
|
-
* signed that stands is counted apart: the owner's lines stand in this fold, a second head's in its own ledger, and its
|
|
55
|
-
* word on a lock is asked once for the lines a batch and the ledger own together.
|
|
56
|
-
*/
|
|
57
|
-
const counted = new WeakMap();
|
|
58
|
-
const seconds = new WeakMap();
|
|
59
|
-
function secondOf(root, store, attested, owned) {
|
|
60
|
-
const held = seconds.get(owned);
|
|
61
|
-
if (held !== undefined)
|
|
62
|
-
return held;
|
|
63
|
-
const head = keyOf(store, 'attest');
|
|
64
|
-
const heard = head === undefined ? undefined : authorityFor([...owned, ...ledgerLines(store, head)], rootSigner(root), signaturesOf(store).admitted);
|
|
65
|
-
return seconds.set(owned, secondHead(store, attested, (line) => heard?.of(line).kind === 'admitted', owned)).get(owned);
|
|
66
|
-
}
|
|
67
|
-
function signedByKey(store, standing, observed) {
|
|
68
|
-
const signed = new Map();
|
|
69
|
-
const reader = (() => {
|
|
70
|
-
try {
|
|
71
|
-
return keyFor(store, 'read');
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
})();
|
|
77
|
-
for (const line of standing)
|
|
78
|
-
signed.set(fieldOf(line, 'by'), (signed.get(fieldOf(line, 'by')) ?? 0) + 1);
|
|
79
|
-
for (const line of standing) {
|
|
80
|
-
const key = /^keys\/([^/]+)$/.exec(fieldOf(line, 'scope'))?.[1];
|
|
81
|
-
const lines = key === undefined || signed.has(key) ? undefined : key === reader ? observed : ledgerLines(store, key);
|
|
82
|
-
if (key !== undefined && lines !== undefined)
|
|
83
|
-
signed.set(key, counted.get(lines) ?? counted.set(lines, new Set(lines.filter(line => fieldOf(line, 'sig') !== '')).size).get(lines));
|
|
84
|
-
}
|
|
85
|
-
return signed;
|
|
86
|
-
}
|
|
87
|
-
/** Generic view checks: declared output equality and one writer per coordinate. Domain measurements belong to selected providers. */
|
|
88
|
-
function viewReadings(place) {
|
|
89
|
-
const leaf = wordOn(place.standing, 'region-leaf', ownLock());
|
|
90
|
-
const at = (coordinate) => join(place.root, place.under ?? '', coordinate);
|
|
91
|
-
const every = [...viewsOf(place.standing).values()].flatMap((view) => ('regions' in view && view.shape ? [view] : []))
|
|
92
|
-
.filter((view) => observeText(at(view.shape)) !== undefined);
|
|
93
|
-
const named = (view) => placesOf(place.standing, view).includes(place.under ?? '');
|
|
94
|
-
const shaped = every.filter((view) => named(view) || (!placesOf(place.standing, view).length && !every.some((other) => other.shape === view.shape && named(other))));
|
|
95
|
-
prerender(place, shaped);
|
|
96
|
-
const same = new Set(shaped.filter((view) => observeText(at(view.shape)) === viewOf(place, view)).map((view) => view.name));
|
|
97
|
-
const differ = shaped.length - same.size;
|
|
98
|
-
const twice = [...every.filter((view) => named(view) || !placesOf(place.standing, view).length)
|
|
99
|
-
.reduce((by, view) => by.set(view.shape, (by.get(view.shape) ?? 0) + 1), new Map()).values()].filter((n) => n > 1).length;
|
|
100
|
-
return { readings: { [`rendered-${leaf}-differ`]: differ, 'rendered-coordinates-differ': differ, [`${leaf}-with-two-views`]: twice, 'coordinates-with-two-views': twice }, same, here: new Set(shaped.map(view => view.name)) };
|
|
101
|
-
}
|
|
102
|
-
const NONE = [];
|
|
103
|
-
const ownings = new WeakMap();
|
|
104
|
-
const ownedOf = (store, told) => ((lock) => ((byLock) => byLock.get(told) ?? byLock.set(told, [...lock, ...told]).get(told))(ownings.get(lock) ?? ownings.set(lock, new WeakMap()).get(lock)))(lockLines(store));
|
|
105
|
-
export function standingOf(root, under, told = NONE) {
|
|
106
|
-
const store = storeOf(root);
|
|
107
|
-
const owned = ownedOf(store, told);
|
|
108
|
-
const rendered = renderedLock(root, store, told);
|
|
109
|
-
const lock = rendered.text.split('\n').filter(isWire);
|
|
110
|
-
const said = spoken(root);
|
|
111
|
-
if (!said.length)
|
|
112
|
-
return { standing: lock, lock, rendered, owned };
|
|
113
|
-
const views = `${wordOf(lock, 'families', 'view')}/`;
|
|
114
|
-
const isView = (line) => fieldOf(line, 'scope').startsWith(views);
|
|
115
|
-
const ruled = new Set(said.filter((one) => !isView(one.line)).map((one) => claimKey(one.line)));
|
|
116
|
-
const owners = new Map();
|
|
117
|
-
for (const one of said.filter((o) => isView(o.line)))
|
|
118
|
-
owners.set(fieldOf(one.line, 'scope'), (owners.get(fieldOf(one.line, 'scope')) ?? new Set()).add(`${one.place}/`));
|
|
119
|
-
const tree = lock.flatMap((line) => {
|
|
120
|
-
const by = isView(line) ? owners.get(fieldOf(line, 'scope')) : undefined;
|
|
121
|
-
if (by === undefined)
|
|
122
|
-
return ruled.has(claimKey(line)) ? [] : [line];
|
|
123
|
-
const needs = fieldOf(line, 'needs').split('|').filter(Boolean);
|
|
124
|
-
const left = needs.filter((need) => ![...by].some((place) => need.startsWith(place)));
|
|
125
|
-
if (!needs.length || left.length === needs.length)
|
|
126
|
-
return [line];
|
|
127
|
-
const got = parse(line);
|
|
128
|
-
return left.length && got.kind === 'fact' ? [canonical({ ...got.value.fields, needs: left.join('|') })] : [];
|
|
129
|
-
});
|
|
130
|
-
const here = under?.replace(/\/$/, '');
|
|
131
|
-
const first = said.filter((one) => one.place === here).map((one) => one.line);
|
|
132
|
-
const rest = said.filter((one) => one.place !== here).map((one) => one.line);
|
|
133
|
-
const standing = [...new Set([...first, ...tree, ...rest])];
|
|
134
|
-
return { standing: [...standing, ...inheritedOf(root, standing)], lock, rendered, owned };
|
|
135
|
-
}
|
|
136
|
-
function inheritedOf(root, standing) {
|
|
137
|
-
const defaults = classDefaults(root);
|
|
138
|
-
if (!defaults.length)
|
|
139
|
-
return [];
|
|
140
|
-
const held = standing.filter(isCeiling);
|
|
141
|
-
const extra = [];
|
|
142
|
-
for (const place of placesIn(root)) {
|
|
143
|
-
const kinds = kindsOf(root, place);
|
|
144
|
-
const prefix = `${place}/`;
|
|
145
|
-
const measures = new Set(held.filter((line) => fieldOf(line, 'scope').startsWith(prefix)).map((line) => fieldOf(line, 'measure')));
|
|
146
|
-
for (const def of defaults) {
|
|
147
|
-
if (!def.classes.includes('*') && !def.classes.some((kind) => kinds.includes(kind)))
|
|
148
|
-
continue;
|
|
149
|
-
const measure = fieldOf(def.line, 'measure');
|
|
150
|
-
if (measures.has(measure))
|
|
151
|
-
continue;
|
|
152
|
-
const got = parse(def.line);
|
|
153
|
-
if (got.kind !== 'fact')
|
|
154
|
-
continue;
|
|
155
|
-
extra.push(canonical({ ...got.value.fields, scope: `${prefix}${fieldOf(def.line, 'scope')}` }));
|
|
156
|
-
measures.add(measure);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return extra;
|
|
160
|
-
}
|
|
161
|
-
export function coneOf(root, entry, ceilings, descent) {
|
|
162
|
-
const store = storeOf(root);
|
|
163
|
-
const { standing, rendered } = standingOf(root);
|
|
164
|
-
// Admission consumes the verified completed fold; it does not ask providers again.
|
|
165
|
-
// Receipt bytes, reader history and instrument identity must all still agree.
|
|
166
|
-
if (meets(root, store, '') && instrumentKept(store) === instrumentOf(store, entry, standing, root, ownLock())) {
|
|
167
|
-
const held = keptPlace(store);
|
|
168
|
-
if (held !== undefined)
|
|
169
|
-
return { standing, observed: held.observed, own: { ...held.own, ...currentActReadings() }, kept: true };
|
|
170
|
-
}
|
|
171
|
-
const named = regionsNamed(standing);
|
|
172
|
-
const reach = descent !== undefined && descent.length ? [...descent] : [...new Set(ceilings.map((line) => boundOf(named, line).region))];
|
|
173
|
-
const read = observedClaims(root, store, { wait: false, ...(reach.includes('') ? {} : { reach }) });
|
|
174
|
-
const current = currentReceiptObservations({ root, store, standing, observed: read });
|
|
175
|
-
const observed = [...current, ...capsuleReadingsOver({ root, store, standing, observed: read })];
|
|
176
|
-
const own = {
|
|
177
|
-
...ownReadings({ root, store, entry, roleOf: rolesOf(store), standing, observed, unadmitted: rendered.grey.length + rendered.refused.length, orphans: 0 }),
|
|
178
|
-
...costReadings(store, standing),
|
|
179
|
-
};
|
|
180
|
-
const measured = new Set([...Object.keys(own), ...placedReadings(observed).map((reading) => reading.measure), wordOf(standing, 'states', 'unread')]);
|
|
181
|
-
const reached = ceilings.every((line) => measured.has(fieldOf(line, 'measure')) || fieldOf(line, 'scope') in own);
|
|
182
|
-
if (reached)
|
|
183
|
-
return { standing, observed, own, kept: true };
|
|
184
|
-
const whole = foldPlace(root, entry);
|
|
185
|
-
return { ...whole, kept: whole.kept ?? false };
|
|
186
|
-
}
|
|
187
|
-
export const ownCeilings = (under) => ((home) => (under === undefined || under === `${home}/`
|
|
188
|
-
? ownLock().filter(isCeiling).map((line) => canonical({ ...fieldsOf(line), scope: `${home}/${fieldOf(line, 'scope')}` })) : []))(basename(ownRoot()));
|
|
189
|
-
export function foldPlace(root, entry, under, look = true, given) {
|
|
190
|
-
const store = storeOf(root);
|
|
191
|
-
const digestAt = Date.now();
|
|
192
|
-
const closed = meets(root, store, under ?? '');
|
|
193
|
-
const digestMs = Date.now() - digestAt;
|
|
194
|
-
if (closed && given?.free !== true) {
|
|
195
|
-
const prior = keptPlace(store, under, instrumentOf(store, entry, standingOf(root).standing, root, ownLock()));
|
|
196
|
-
if (prior !== undefined) {
|
|
197
|
-
hostOutput('error', `CLOSED ${under || '.'} · digest ${digestMs} ms\n`);
|
|
198
|
-
return refreshRetainedJudgment(prior, [...prior.standing.filter((line) => isCeiling(line) && !(under && fieldOf(line, 'measure') === 'unread')), ...ownCeilings(under)]);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
const { standing, lock: attested, rendered, owned } = given?.standing ?? standingOf(root, under);
|
|
202
|
-
const folder = writerFor(standing, 'fold');
|
|
203
|
-
const answered = given === undefined && under ? new Map() : undefined;
|
|
204
|
-
const reached = given?.observed ?? observedClaims(root, store, { wait: look, ...(under ? { reach: [under], answered } : {}) });
|
|
205
|
-
const self = instrumentOf(store, entry, standing, root, ownLock());
|
|
206
|
-
const inside = (place) => !under || within(point(place.replace(/\/\*$/, '')), region(under));
|
|
207
|
-
const history = historyOf(root, store, standingDemands(store));
|
|
208
|
-
const theirs = history.live.filter((line) => ((needs) => !under || (needs.length > 0 && needs.every(inside)))(fieldOf(line, 'needs').split('|').filter(Boolean)));
|
|
209
|
-
const reads = under && under !== `${basename(ownRoot())}/` ? { owned, place: under, scopes: new Set(theirs.map((line) => fieldOf(line, 'scope'))) } : undefined;
|
|
210
|
-
const spent = [];
|
|
211
|
-
const took = timing(spent);
|
|
212
|
-
const read = given?.observed ?? (under ? took('observe', () => observedClaims(root, store, { wait: look })) : reached);
|
|
213
|
-
const current = currentReceiptObservations({ root, store, ...(under ? { under } : {}), standing, observed: read });
|
|
214
|
-
const everywhere = [...current, ...took('capsules', () => capsuleReadingsOver({ root, store, ...(under ? { under } : {}), standing, observed: read }))];
|
|
215
|
-
const points = foldPoints(store, standing, under, folder, self, reached, root, answered, reads);
|
|
216
|
-
const taken = bytesDigest(store, new TextEncoder().encode(points.join('\n'))).replace(/^sha256:/, '');
|
|
217
|
-
const observed = everywhere.filter((line) => !/ measure=observed /.test(line) || inside(fieldOf(line, 'scope')));
|
|
218
|
-
const shared = new Set(under ? placedReadings(everywhere).filter((r) => !inside(r.place)).map((r) => r.question) : []);
|
|
219
|
-
const live = history;
|
|
220
|
-
const demands = theirs;
|
|
221
|
-
const orphans = [];
|
|
222
|
-
const ceilings = [...standing.filter((line) => isCeiling(line) && !(under && fieldOf(line, 'measure') === 'unread')), ...ownCeilings(under)];
|
|
223
|
-
const own = took('own', () => ownReadings({
|
|
224
|
-
root, store, entry, roleOf: rolesOf(store), standing, observed: everywhere,
|
|
225
|
-
unadmitted: rendered.grey.length + rendered.refused.length, orphans: orphans.length, ...(under ? { under } : {}),
|
|
226
|
-
}));
|
|
227
|
-
const regions = took('regions', () => regionsOf(standing, ceilings.filter((line) => !answersElsewhere(line, own, under, new Set(placesIn(root)))), placedReadings(observed)));
|
|
228
|
-
const fold = (docs) => foldCeilings({ standing, ceilings, observed, own: { ...own, ...docs }, epoch: epochOf(owned), ...(under ? { under, places: new Set(placesIn(root)) } : {}) });
|
|
229
|
-
const folded = took('ceilings', () => fold({}));
|
|
230
|
-
const { paid, missing } = took('paid', () => paidOf(store, demands, observed, `${wordFrom(standing, 'families', 'view', lockStanding(store))}/`));
|
|
231
|
-
const lock = (observeText(join(root, under ?? '', LOCK)) ?? '').split('\n').filter(isWire).length;
|
|
232
|
-
const second = secondOf(root, store, attested, owned);
|
|
233
|
-
const policyStanding = standing.filter((line) => !rendered.grey.includes(line) && !rendered.refused.includes(line));
|
|
234
|
-
const faults = releaseFaults({ forks: rendered.forks, refused: rendered.refused, grey: rendered.grey, orphans, second });
|
|
235
|
-
const place = {
|
|
236
|
-
release: releasePolicy({ standing: policyStanding, demands, paid, ceilings, readings: folded, faults, verdicts: attestationObservations(policyStanding.map(line => { const r = parseEvidenceFields(line); return r.kind === 'fact' ? r.value.fields : {}; }), second), snapshot: { fold: taken, instrument: self } }),
|
|
237
|
-
root, store, ...(under ? { under } : {}), epoch: epochOf(owned), standing, claims: rendered.standing,
|
|
238
|
-
forks: rendered.forks, grey: rendered.grey, refused: rendered.refused, vacuous: rendered.vacuous.length,
|
|
239
|
-
demands, paid, missing,
|
|
240
|
-
history: live.history.filter((line) => fieldOf(line, 'needs').split('|').filter(Boolean).some(inside)),
|
|
241
|
-
observed,
|
|
242
|
-
receiptHistory: retiredReceiptHistory({ root, store, ...(under ? { under } : {}), standing, observed: read }),
|
|
243
|
-
ceilings: ceilingSummary(folded, ceilings.length, shared),
|
|
244
|
-
orphans,
|
|
245
|
-
lock,
|
|
246
|
-
signed: signedByKey(store, standing, everywhere),
|
|
247
|
-
second,
|
|
248
|
-
effects: effectStates(store),
|
|
249
|
-
key: taken,
|
|
250
|
-
instrument: self,
|
|
251
|
-
own,
|
|
252
|
-
open: openCells({ store, standing, observed, grey: rendered.grey, epoch: epochOf(owned) }),
|
|
253
|
-
regions: packRegions(regions),
|
|
254
|
-
beats: beatsOf(store, standing, under),
|
|
255
|
-
landed: [...vouchedCoordinates(store).keys()].filter((coordinate) => !under || coordinate.startsWith(under)).length,
|
|
256
|
-
costs: costsOf(store),
|
|
257
|
-
};
|
|
258
|
-
const { readings: found, same, here } = took('docs', () => viewReadings(place));
|
|
259
|
-
const family = `${wordFrom(standing, 'families', 'view', lockStanding(store))}/`;
|
|
260
|
-
const coordinates = new Set([...here].map((name) => `${family}${name}`));
|
|
261
|
-
const writes = (line) => coordinates.has(fieldOf(line, 'scope'));
|
|
262
|
-
const holds = (line) => same.has(fieldOf(line, 'scope').slice(family.length));
|
|
263
|
-
const owed = [...place.missing.filter((line) => !writes(line) || !holds(line)), ...place.paid.filter((line) => writes(line) && !holds(line))];
|
|
264
|
-
const docs = {
|
|
265
|
-
...found, 'payments-lost-on-equal-output': owed.filter((line) => writes(line) && holds(line)).length,
|
|
266
|
-
'poles-unlike-replay': unlikeReplay(regions, new Set(folded.over.map((one) => one.ceiling)), { ...own, unread: folded.unread.length + folded.vacuous.length }),
|
|
267
|
-
};
|
|
268
|
-
const again = took('ceilings', () => fold(docs));
|
|
269
|
-
const finalPaid = [...place.paid.filter((line) => !writes(line) || holds(line)), ...place.missing.filter((line) => writes(line) && holds(line))];
|
|
270
|
-
const whole = {
|
|
271
|
-
...place,
|
|
272
|
-
paid: finalPaid,
|
|
273
|
-
release: releasePolicy({ standing: policyStanding, demands, paid: finalPaid, ceilings, readings: again, faults, verdicts: attestationObservations(policyStanding.map(line => { const r = parseEvidenceFields(line); return r.kind === 'fact' ? r.value.fields : {}; }), second), snapshot: { fold: taken, instrument: self } }),
|
|
274
|
-
missing: owed,
|
|
275
|
-
own: { ...place.own, ...docs },
|
|
276
|
-
ceilings: ceilingSummary(again, ceilings.length, shared),
|
|
277
|
-
};
|
|
278
|
-
if (folder !== undefined && meets(root, store, under ?? '', true, whole.observed))
|
|
279
|
-
took('keep', () => keepFold(store, taken, whole, points, self));
|
|
280
|
-
hostOutput('error', `SPENT fold ${spent.join(' ms · ')} ms\n`);
|
|
281
|
-
return whole;
|
|
282
|
-
}
|
|
1
|
+
var Ae=Object.defineProperty;var m=(e,o)=>Ae(e,"name",{value:o,configurable:!0});import{traceWork as Je}from"../host/work-trace.js";import{hostOutput as me}from"../host/call-context.js";import{refreshRetainedJudgment as Ie}from"./retained-judgment.js";import{timing as Ve}from"../host/timing.js";import{attestationObservations as ue}from"../fold/evidence.js";import{library14_parse as ge}from"../vendor/runtime.js";import{releasePolicy as he,releaseFaults as Ge}from"../fold/release-policy.js";import{library0_point as Qe,library0_region as Ue,library0_within as Xe}from"../vendor/runtime.js";import{basename as we,join as ye}from"node:path";import{observeText as J}from"../observe/files.js";import{placesOf as I,viewsOf as Ye}from"../fold/views.js";import{prerender as Ze}from"../render/view.js";import{meets as V,instrumentKept as et}from"../fold/closed.js";import{foldPoints as tt,keepFold as st,keptPlace as ke}from"../fold/kept.js";import{openCells as nt}from"../render/open.js";import{boundOf as it,packRegions as ot,regionsNamed as rt,regionsOf as at,unlikeReplay as ct}from"../fold/region.js";import{answersElsewhere as ft,foldCeilings as dt,ceilingSummary as be}from"../fold/ceilings.js";import{keyOf as lt,keyFor as pt,lockLines as mt,lockStanding as ve}from"../fold/keys.js";import{wordFrom as Oe,wordOf as $e,wordOn as ut}from"../fold/wire.js";import{bytesDigest as gt,instrumentOf as G,signaturesOf as ht}from"../fold/digests.js";import{claimKey as Se,fieldOf as l,fieldsOf as wt,isWire as Me}from"../fold/claims.js";import{library14_canonical as Q,library14_LOCK as yt,library14_parse as Re}from"../vendor/runtime.js";import{classDefaults as kt,kindsOf as bt,placesIn as U,spoken as vt}from"../fold/places.js";import{isCeiling as H}from"../fold/configures.js";import{observedClaims as X,placedReadings as Y}from"../fold/observed.js";import{capsuleReadingsOver as xe,currentReceiptObservations as Ce,retiredReceiptHistory as Ot}from"../observe/regions.js";import{costReadings as $t,ownReadings as We,currentActReadings as St}from"../fold/own.js";import{paidOf as Mt}from"../fold/paid.js";import{rolesOf as Fe}from"../fold/roles.js";import{secondHead as Rt}from"../fold/second.js";import{authorityFor as xt,rootSigner as Ct,writerFor as Ne}from"../fold/signers.js";import{ledgerLines as T,storeOf as Z}from"../land/ledger.js";import{vouchedCoordinates as Wt}from"../land/vouched.js";import{ownLock as P,ownRoot as _e}from"../observe/runner.js";import{epochOf as ee,historyOf as Ft,renderedLock as Nt,standingDemands as _t}from"./owner.js";function Pt(e,o,t){const c=Ne(o,"fold"),r=m(f=>{const i=(c===void 0?[]:T(e,c)).filter(s=>l(s,"scope")===`beat/${t??"."}`&&l(s,"at")===`place:${f}`).map(s=>Number(l(s,"value").split("..")[0])).filter(s=>Number.isFinite(s)).slice(-10).sort((s,h)=>s-h);return i.length?i[Math.floor(i.length/2)]??0:0},"middle");return{kept:r("kept"),folded:r("folded")}}m(Pt,"beatsOf");const Dt=m(e=>T(e,"take").filter(o=>l(o,"measure")==="ms").map(o=>Number(l(o,"value").split("..")[0])).filter(o=>Number.isFinite(o)).slice(-10),"costsOf");function Et(e){return"none"}m(Et,"effectStates");const Pe=new WeakMap,De=new WeakMap;function Lt(e,o,t,c){const r=De.get(c);if(r!==void 0)return r;const f=lt(o,"attest"),i=f===void 0?void 0:xt([...c,...T(o,f)],Ct(e),ht(o).admitted);return De.set(c,Rt(o,t,s=>i?.of(s).kind==="admitted",c)).get(c)}m(Lt,"secondOf");function jt(e,o,t){const c=new Map,r=(()=>{try{return pt(e,"read")}catch{return}})();for(const f of o)c.set(l(f,"by"),(c.get(l(f,"by"))??0)+1);for(const f of o){const i=/^keys\/([^/]+)$/.exec(l(f,"scope"))?.[1],s=i===void 0||c.has(i)?void 0:i===r?t:T(e,i);i!==void 0&&s!==void 0&&c.set(i,Pe.get(s)??Pe.set(s,new Set(s.filter(h=>l(h,"sig")!=="")).size).get(s))}return c}m(jt,"signedByKey");function Kt(e){const o=ut(e.standing,"region-leaf",P()),t=m(a=>ye(e.root,e.under??"",a),"at"),c=[...Ye(e.standing).values()].flatMap(a=>"regions"in a&&a.shape?[a]:[]).filter(a=>J(t(a.shape))!==void 0),r=m(a=>I(e.standing,a).includes(e.under??""),"named"),f=c.filter(a=>r(a)||!I(e.standing,a).length&&!c.some(d=>d.shape===a.shape&&r(d))),i=Ze(e,f),s=new Set(f.filter(a=>J(t(a.shape))===i.get(a)).map(a=>a.name)),h=f.length-s.size,u=[...c.filter(a=>r(a)||!I(e.standing,a).length).reduce((a,d)=>a.set(d.shape,(a.get(d.shape)??0)+1),new Map).values()].filter(a=>a>1).length;return{readings:{[`rendered-${o}-differ`]:h,"rendered-coordinates-differ":h,[`${o}-with-two-views`]:u,"coordinates-with-two-views":u},same:s,here:new Set(f.map(a=>a.name))}}m(Kt,"viewReadings");const Bt=[],Ee=new WeakMap,Ht=m((e,o)=>(t=>(c=>c.get(o)??c.set(o,[...t,...o]).get(o))(Ee.get(t)??Ee.set(t,new WeakMap).get(t)))(mt(e)),"ownedOf");function te(e,o,t=Bt){const c=Z(e),r=Ht(c,t),f=Nt(e,c,t),i=f.text.split(`
|
|
2
|
+
`).filter(Me),s=vt(e);if(!s.length)return{standing:i,lock:i,rendered:f,owned:r};const h=`${$e(i,"families","view")}/`,u=m(p=>l(p,"scope").startsWith(h),"isView"),a=new Set(s.filter(p=>!u(p.line)).map(p=>Se(p.line))),d=new Map;for(const p of s.filter(y=>u(y.line)))d.set(l(p.line,"scope"),(d.get(l(p.line,"scope"))??new Set).add(`${p.place}/`));const k=i.flatMap(p=>{const y=u(p)?d.get(l(p,"scope")):void 0;if(y===void 0)return a.has(Se(p))?[]:[p];const v=l(p,"needs").split("|").filter(Boolean),M=v.filter(q=>![...y].some(C=>q.startsWith(C)));if(!v.length||M.length===v.length)return[p];const x=Re(p);return M.length&&x.kind==="fact"?[Q({...x.value.fields,needs:M.join("|")})]:[]}),g=o?.replace(/\/$/,""),b=s.filter(p=>p.place===g).map(p=>p.line),$=s.filter(p=>p.place!==g).map(p=>p.line),w=[...new Set([...b,...k,...$])];return{standing:[...w,...Tt(e,w)],lock:i,rendered:f,owned:r}}m(te,"standingOf");function Tt(e,o){const t=kt(e);if(!t.length)return[];const c=o.filter(H),r=[];for(const f of U(e)){const i=bt(e,f),s=`${f}/`,h=new Set(c.filter(u=>l(u,"scope").startsWith(s)).map(u=>l(u,"measure")));for(const u of t){if(!u.classes.includes("*")&&!u.classes.some(k=>i.includes(k)))continue;const a=l(u.line,"measure");if(h.has(a))continue;const d=Re(u.line);d.kind==="fact"&&(r.push(Q({...d.value.fields,scope:`${s}${l(u.line,"scope")}`})),h.add(a))}}return r}m(Tt,"inheritedOf");function Cs(e,o,t,c){const r=Z(e),{standing:f,rendered:i}=te(e);if(V(e,r,"")&&et(r)===G(r,o,f,e,P())){const w=ke(r);if(w!==void 0)return{standing:f,observed:w.observed,own:{...w.own,...St()},kept:!0}}const s=rt(f),h=c!==void 0&&c.length?[...c]:[...new Set(t.map(w=>it(s,w).region))],u=X(e,r,{wait:!1,...h.includes("")?{}:{reach:h}}),d=[...Ce({root:e,store:r,standing:f,observed:u}),...xe({root:e,store:r,standing:f,observed:u})],k={...We({root:e,store:r,entry:o,roleOf:Fe(r),standing:f,observed:d,unadmitted:i.grey.length+i.refused.length,orphans:0}),...$t(r,f)},g=new Set([...Object.keys(k),...Y(d).map(w=>w.measure),$e(f,"states","unread")]);if(t.every(w=>g.has(l(w,"measure"))||l(w,"scope")in k))return{standing:f,observed:d,own:k,kept:!0};const $=zt(e,o);return{...$,kept:$.kept??!1}}m(Cs,"coneOf");const Le=m(e=>(o=>e===void 0||e===`${o}/`?P().filter(H).map(t=>Q({...wt(t),scope:`${o}/${l(t,"scope")}`})):[])(we(_e())),"ownCeilings");function qt(e){return Ie(e,[...e.standing.filter(o=>H(o)&&!(e.under&&l(o,"measure")==="unread")),...Le(e.under)])}m(qt,"currentJudgment");function zt(e,o,t,c=!0,r){return Je("fold/place",()=>At(e,o,t,c,r))}m(zt,"foldPlace");function At(e,o,t,c=!0,r){const f=[],i=Ve(f),s=Z(e),h=Date.now(),u=i("closure",()=>V(e,s,t??"")),a=Date.now()-h;if(u&&r?.free!==!0){const n=ke(s,t,G(s,o,te(e).standing,e,P()));if(n!==void 0)return me("error",`CLOSED ${t||"."} \xB7 digest ${a} ms
|
|
3
|
+
`),qt(n)}const{standing:d,lock:k,rendered:g,owned:b}=r?.standing??i("standing",()=>te(e,t)),$=Ne(d,"fold"),w=r===void 0&&t?new Map:void 0,p=r?.observed??i("observed",()=>X(e,s,{wait:c,...t?{reach:[t],answered:w}:{}})),y=i("instrument",()=>G(s,o,d,e,P())),v=m(n=>!t||Xe(Qe(n.replace(/\/\*$/,"")),Ue(t)),"inside"),M=i("history",()=>Ft(e,s,_t(s))),x=M.live.filter(n=>(O=>!t||O.length>0&&O.every(v))(l(n,"needs").split("|").filter(Boolean))),q=t&&t!==`${we(_e())}/`?{owned:b,place:t,scopes:new Set(x.map(n=>l(n,"scope")))}:void 0,C=r?.observed??(t?i("observe",()=>X(e,s,{wait:c})):p),D=[...i("current-receipts",()=>Ce({root:e,store:s,...t?{under:t}:{},standing:d,observed:C})),...i("capsules",()=>xe({root:e,store:s,...t?{under:t}:{},standing:d,observed:C}))],se=i("points",()=>tt(s,d,t,$,y,p,e,w,q)),E=i("point-digest",()=>gt(s,new TextEncoder().encode(se.join(`
|
|
4
|
+
`))).replace(/^sha256:/,"")),W=D.filter(n=>!/ measure=observed /.test(n)||v(l(n,"scope"))),ne=new Set(t?Y(D).filter(n=>!v(n.place)).map(n=>n.question):[]),je=M,L=x,z=[],R=[...d.filter(n=>H(n)&&!(t&&l(n,"measure")==="unread")),...Le(t)],j=i("own",()=>We({root:e,store:s,entry:o,roleOf:Fe(s),standing:d,observed:D,unadmitted:g.grey.length+g.refused.length,orphans:z.length,...t?{under:t}:{}})),ie=i("regions",()=>at(d,R.filter(n=>!ft(n,j,t,new Set(U(e)))),Y(W))),oe=m(n=>dt({standing:d,ceilings:R,observed:W,own:{...j,...n},epoch:ee(b),...t?{under:t,places:new Set(U(e))}:{}}),"fold"),F=i("ceilings",()=>oe({})),{paid:re,missing:Ke}=i("paid",()=>Mt(s,L,W,`${Oe(d,"families","view",ve(s))}/`)),Be=(J(ye(e,t??"",yt))??"").split(`
|
|
5
|
+
`).filter(Me).length,K=i("second",()=>Lt(e,s,k,b)),B=d.filter(n=>!g.grey.includes(n)&&!g.refused.includes(n)),ae=Ge({forks:g.forks,refused:g.refused,grey:g.grey,orphans:z,second:K}),S={release:he({standing:B,demands:L,paid:re,ceilings:R,readings:F,faults:ae,verdicts:ue(B.map(n=>{const O=ge(n);return O.kind==="fact"?O.value.fields:{}}),K),snapshot:{fold:E,instrument:y}}),root:e,store:s,...t?{under:t}:{},epoch:ee(b),standing:d,claims:g.standing,forks:g.forks,grey:g.grey,refused:g.refused,vacuous:g.vacuous.length,demands:L,paid:re,missing:Ke,history:je.history.filter(n=>l(n,"needs").split("|").filter(Boolean).some(v)),observed:W,receiptHistory:i("receipt-history",()=>Ot({root:e,store:s,...t?{under:t}:{},standing:d,observed:C})),ceilings:be(F,R.length,ne),orphans:z,lock:Be,signed:i("signatures",()=>jt(s,d,D)),second:K,effects:Et(s),key:E,instrument:y,own:j,open:nt({store:s,standing:d,observed:W,grey:g.grey,epoch:ee(b)}),regions:ot(ie),beats:i("beats",()=>Pt(s,d,t)),landed:[...Wt(s).keys()].filter(n=>!t||n.startsWith(t)).length,costs:i("cost-history",()=>Dt(s))},{readings:He,same:Te,here:qe}=i("docs",()=>Kt(S)),ce=`${Oe(d,"families","view",ve(s))}/`,ze=new Set([...qe].map(n=>`${ce}${n}`)),N=m(n=>ze.has(l(n,"scope")),"writes"),_=m(n=>Te.has(l(n,"scope").slice(ce.length)),"holds"),fe=[...S.missing.filter(n=>!N(n)||!_(n)),...S.paid.filter(n=>N(n)&&!_(n))],de={...He,"payments-lost-on-equal-output":fe.filter(n=>N(n)&&_(n)).length,"poles-unlike-replay":ct(ie,new Set(F.over.map(n=>n.ceiling)),{...j,unread:F.unread.length+F.vacuous.length})},le=i("ceilings",()=>oe(de)),pe=[...S.paid.filter(n=>!N(n)||_(n)),...S.missing.filter(n=>N(n)&&_(n))],A={...S,paid:pe,release:he({standing:B,demands:L,paid:pe,ceilings:R,readings:le,faults:ae,verdicts:ue(B.map(n=>{const O=ge(n);return O.kind==="fact"?O.value.fields:{}}),K),snapshot:{fold:E,instrument:y}}),missing:fe,own:{...S.own,...de},ceilings:be(le,R.length,ne)};return $!==void 0&&V(e,s,t??"",!0,A.observed)&&i("keep",()=>st(s,E,A,se,y)),me("error",`SPENT fold ${f.join(" ms \xB7 ")} ms
|
|
6
|
+
`),A}m(At,"foldPlaceCurrent");export{Cs as coneOf,qt as currentJudgment,zt as foldPlace,Le as ownCeilings,te as standingOf};
|
|
@@ -1,80 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { fieldOf, foldClaims } from "../fold/claims.js";
|
|
5
|
-
import { observeText } from "../observe/files.js";
|
|
6
|
-
import { claimLinesIn } from "./args.js";
|
|
7
|
-
import { LOCK } from '@lapxo/topos/wire';
|
|
8
|
-
import { join } from 'node:path';
|
|
9
|
-
/** Judge an external signed approval without landing it, fetching its source,
|
|
10
|
-
* executing a provider, or changing the release-policy verdict of the place.
|
|
11
|
-
* The anchor is the place's key, never a key offered by the approval. */
|
|
12
|
-
export function releaseApproval(lock, lines) {
|
|
13
|
-
const standing = foldClaims(lock).standing;
|
|
14
|
-
const id = writerFor(standing, 'authorize');
|
|
15
|
-
if (!id)
|
|
16
|
-
throw Error('REFUSE·release place names no authorizer');
|
|
17
|
-
const one = (rows, scope, measure) => {
|
|
18
|
-
const selected = rows.filter(line => fieldOf(line, 'scope') === scope && (!measure || fieldOf(line, 'measure') === measure) && fieldOf(line, 'value') !== 'withdraw');
|
|
19
|
-
if (selected.length !== 1)
|
|
20
|
-
throw Error(`REFUSE·release ${scope} needs one declaration`);
|
|
21
|
-
return fieldOf(selected[0], 'value');
|
|
22
|
-
};
|
|
23
|
-
const anchor = { ...releaseSigner(standing), id, publicKey: one(standing, `keys/${id}`, 'public-key'), coverage: one(standing, `keys/${id}`, 'coverage').split('|') };
|
|
24
|
-
if (!lines.length)
|
|
25
|
-
throw Error('REFUSE·release empty approval');
|
|
26
|
-
for (const line of lines) {
|
|
27
|
-
const got = parse(line);
|
|
28
|
-
if (got.kind !== 'fact')
|
|
29
|
-
throw Error('REFUSE·release malformed approval');
|
|
30
|
-
if (got.value.fields['by'] !== id || !got.value.fields['sig'])
|
|
31
|
-
throw Error(`REFUSE·release approval must be signed by ${id}`);
|
|
32
|
-
}
|
|
33
|
-
// A separate release place may declare an era; its configuration must itself
|
|
34
|
-
// authenticate against the existing anchor. No packet key or coverage is used.
|
|
35
|
-
const wire = lines.filter(line => ['wire/signature-algorithms', 'audit/wire/signature-algorithms', 'wire/era', 'audit/wire/era'].includes(fieldOf(line, 'scope')));
|
|
36
|
-
let era;
|
|
37
|
-
try {
|
|
38
|
-
era = eraOf(wire.length ? foldClaims(wire).standing : standing);
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
throw Error('REFUSE·release signature era is absent or conflicting');
|
|
42
|
-
}
|
|
43
|
-
const authority = authorityFor([], anchor, era.admitted);
|
|
44
|
-
for (const line of lines) {
|
|
45
|
-
const verdict = authority.of(line);
|
|
46
|
-
if (verdict.kind !== 'admitted')
|
|
47
|
-
throw Error(`REFUSE·release ${fieldOf(line, 'scope')}: ${verdict.why ?? verdict.kind}`);
|
|
48
|
-
}
|
|
49
|
-
const released = lines.filter(line => /^release\/[^/]+$/.test(fieldOf(line, 'scope')) && fieldOf(line, 'measure') === 'digest' && fieldOf(line, 'role') === 'writes');
|
|
50
|
-
if (released.length !== 1)
|
|
51
|
-
throw Error('REFUSE·release needs one signed release/<tag> digest');
|
|
52
|
-
const required = (scope, measure) => {
|
|
53
|
-
const selected = lines.filter(line => fieldOf(line, 'scope') === scope);
|
|
54
|
-
if (selected.some(line => fieldOf(line, 'role') !== 'writes' || fieldOf(line, 'form') !== 'alphabet' || fieldOf(line, 'measure') !== measure))
|
|
55
|
-
throw Error(`REFUSE·release ${scope} is not an approval declaration`);
|
|
56
|
-
return one(selected, scope, measure);
|
|
57
|
-
};
|
|
58
|
-
const digest = required(fieldOf(released[0], 'scope'), 'digest'), name = required('release/artifact', 'id'), source = required('sources/archive', 'id');
|
|
59
|
-
if (!/^sha256:[a-f0-9]{64}$/.test(digest))
|
|
60
|
-
throw Error('REFUSE·release archive needs sha256');
|
|
61
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(name))
|
|
62
|
-
throw Error('REFUSE·release artifact needs one safe filename');
|
|
63
|
-
let url;
|
|
64
|
-
try {
|
|
65
|
-
url = new URL(source);
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
throw Error('REFUSE·release archive source needs an absolute URL');
|
|
69
|
-
}
|
|
70
|
-
if (url.username || url.password || /[\s\x00-\x1f\x7f]/.test(source))
|
|
71
|
-
throw Error('REFUSE·release archive source needs a credential-free absolute URL without whitespace');
|
|
72
|
-
return `READY ${digest} ${name} ${source}`;
|
|
73
|
-
}
|
|
74
|
-
export function printReleaseApproval(root, file) {
|
|
75
|
-
const text = observeText(file);
|
|
76
|
-
if (text === undefined)
|
|
77
|
-
throw Error('REFUSE·release approval file is absent');
|
|
78
|
-
const lines = text.split('\n').filter(line => line.trim().length > 0);
|
|
79
|
-
process.stdout.write(releaseApproval(claimLinesIn(join(root, LOCK)), lines) + '\n');
|
|
80
|
-
}
|
|
1
|
+
var S=Object.defineProperty;var f=(n,o)=>S(n,"name",{value:o,configurable:!0});import{hostOutput as y}from"../host/call-context.js";import{library14_parse as b}from"../vendor/runtime.js";import{authorityFor as $,writerFor as x,releaseSigner as k}from"../fold/signers.js";import{eraOf as L}from"../fold/digests.js";import{fieldOf as r,foldClaims as R}from"../fold/claims.js";import{observeText as A}from"../observe/files.js";import{claimLinesIn as O}from"./args.js";import{library14_LOCK as z}from"../vendor/runtime.js";import{join as C}from"node:path";function K(n,o){const a=R(n).standing,s=x(a,"authorize");if(!s)throw Error("REFUSE\xB7release place names no authorizer");const l=f((e,t,c)=>{const i=e.filter(h=>r(h,"scope")===t&&(!c||r(h,"measure")===c)&&r(h,"value")!=="withdraw");if(i.length!==1)throw Error(`REFUSE\xB7release ${t} needs one declaration`);return r(i[0],"value")},"one"),U={...k(a),id:s,publicKey:l(a,`keys/${s}`,"public-key"),coverage:l(a,`keys/${s}`,"coverage").split("|")};if(!o.length)throw Error("REFUSE\xB7release empty approval");for(const e of o){const t=b(e);if(t.kind!=="fact")throw Error("REFUSE\xB7release malformed approval");if(t.value.fields.by!==s||!t.value.fields.sig)throw Error(`REFUSE\xB7release approval must be signed by ${s}`)}const u=o.filter(e=>["wire/signature-algorithms","audit/wire/signature-algorithms","wire/era","audit/wire/era"].includes(r(e,"scope")));let m;try{m=L(u.length?R(u).standing:a)}catch{throw Error("REFUSE\xB7release signature era is absent or conflicting")}const F=$([],U,m.admitted);for(const e of o){const t=F.of(e);if(t.kind!=="admitted")throw Error(`REFUSE\xB7release ${r(e,"scope")}: ${t.why??t.kind}`)}const w=o.filter(e=>/^release\/[^/]+$/.test(r(e,"scope"))&&r(e,"measure")==="digest"&&r(e,"role")==="writes");if(w.length!==1)throw Error("REFUSE\xB7release needs one signed release/<tag> digest");const d=f((e,t)=>{const c=o.filter(i=>r(i,"scope")===e);if(c.some(i=>r(i,"role")!=="writes"||r(i,"form")!=="alphabet"||r(i,"measure")!==t))throw Error(`REFUSE\xB7release ${e} is not an approval declaration`);return l(c,e,t)},"required"),g=d(r(w[0],"scope"),"digest"),v=d("release/artifact","id"),E=d("sources/archive","id");if(!/^sha256:[a-f0-9]{64}$/.test(g))throw Error("REFUSE\xB7release archive needs sha256");if(!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(v))throw Error("REFUSE\xB7release artifact needs one safe filename");let p;try{p=new URL(E)}catch{throw Error("REFUSE\xB7release archive source needs an absolute URL")}if(p.username||p.password||/[\s\x00-\x1f\x7f]/.test(E))throw Error("REFUSE\xB7release archive source needs a credential-free absolute URL without whitespace");return`READY ${g} ${v} ${E}`}f(K,"releaseApproval");function H(n,o){const a=A(o);if(a===void 0)throw Error("REFUSE\xB7release approval file is absent");const s=a.split(`
|
|
2
|
+
`).filter(l=>l.trim().length>0);y("out",K(O(C(n,z)),s)+`
|
|
3
|
+
`)}f(H,"printReleaseApproval");export{H as printReleaseApproval,K as releaseApproval};
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { currentActReadings } from "../fold/own.js";
|
|
3
|
-
import { placedReadings } from "../fold/observed.js";
|
|
4
|
-
import { placesIn } from "../fold/places.js";
|
|
5
|
-
import { releasePolicy, releaseFaults } from "../fold/release-policy.js";
|
|
6
|
-
import { attestationObservations } from "../fold/evidence.js";
|
|
7
|
-
import { parse } from '@lapxo/topos/wire';
|
|
8
|
-
import { point, region, within } from '@lapxo/obligations/field';
|
|
9
|
-
/** A verified semantic fold can be reused. Its previous act's measurements cannot.
|
|
10
|
-
* Keep history intact and judge current measurements with the ordinary interpreters.
|
|
11
|
-
*/
|
|
12
|
-
export function refreshRetainedJudgment(prior, ceilings, current = currentActReadings(prior.under)) {
|
|
13
|
-
const own = { ...prior.own, ...current };
|
|
14
|
-
const readings = foldCeilings({ standing: prior.standing, ceilings, observed: prior.observed,
|
|
15
|
-
own, epoch: prior.epoch, ...(prior.under ? { under: prior.under, places: new Set(placesIn(prior.root)) } : {}) });
|
|
16
|
-
const standing = prior.standing.filter(line => !prior.grey.includes(line) && !prior.refused.includes(line));
|
|
17
|
-
const shared = new Set(prior.under ? placedReadings(prior.observed)
|
|
18
|
-
.filter(reading => !within(point(reading.place.replace(/\/\*$/, '')), region(prior.under)))
|
|
19
|
-
.map(reading => reading.question) : []);
|
|
20
|
-
return { ...prior, kept: true, own, ceilings: ceilingSummary(readings, ceilings.length, shared),
|
|
21
|
-
release: releasePolicy({ standing, demands: prior.demands, paid: prior.paid, ceilings, readings,
|
|
22
|
-
faults: releaseFaults(prior),
|
|
23
|
-
verdicts: attestationObservations(standing.map(line => { const got = parse(line); return got.kind === 'fact' ? got.value.fields : {}; }), prior.second),
|
|
24
|
-
snapshot: { fold: prior.key, instrument: prior.instrument } }) };
|
|
25
|
-
}
|
|
1
|
+
var r=Object.defineProperty;var m=(e,t)=>r(e,"name",{value:t,configurable:!0});import{foldCeilings as u,ceilingSummary as c}from"../fold/ceilings.js";import{currentActReadings as f}from"../fold/own.js";import{placedReadings as g}from"../fold/observed.js";import{placesIn as b}from"../fold/places.js";import{releasePolicy as h,releaseFaults as y}from"../fold/release-policy.js";import{attestationObservations as p}from"../fold/evidence.js";import{library14_parse as v}from"../vendor/runtime.js";import{library0_point as w,library0_region as _,library0_within as k}from"../vendor/runtime.js";function O(e,t,o=f(e.under)){const s={...e.own,...o},a=u({standing:e.standing,ceilings:t,observed:e.observed,own:s,epoch:e.epoch,...e.under?{under:e.under,places:new Set(b(e.root))}:{}}),d=e.standing.filter(n=>!e.grey.includes(n)&&!e.refused.includes(n)),l=new Set(e.under?g(e.observed).filter(n=>!k(w(n.place.replace(/\/\*$/,"")),_(e.under))).map(n=>n.question):[]);return{...e,kept:!0,own:s,ceilings:c(a,t.length,l),release:h({standing:d,demands:e.demands,paid:e.paid,ceilings:t,readings:a,faults:y(e),verdicts:p(d.map(n=>{const i=v(n);return i.kind==="fact"?i.value.fields:{}}),e.second),snapshot:{fold:e.key,instrument:e.instrument}})}}m(O,"refreshRetainedJudgment");export{O as refreshRetainedJudgment};
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { storeOf } from "../land/ledger.js";
|
|
6
|
-
/** An evidence projection, never a new authority lock. Authentication uses
|
|
7
|
-
* the admission snapshot at each local epoch; the existing fold applies
|
|
8
|
-
* supersessions and withdrawals across all declared classes. Storage layout
|
|
9
|
-
* and delivery mode do not enter this public boundary. */
|
|
10
|
-
export function printStandingResult(root) {
|
|
11
|
-
const store = storeOf(root);
|
|
12
|
-
assertStandingView(lockStanding(store));
|
|
13
|
-
if (hasContextualPlace(root)) {
|
|
14
|
-
process.stdout.write(JSON.stringify(contextualStanding(root)) + '\n');
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const standing = publicStandingLines(root);
|
|
18
|
-
process.stdout.write(standing.length ? standing.join('\n') + '\n' : '');
|
|
19
|
-
}
|
|
1
|
+
var e=Object.defineProperty;var o=(t,n)=>e(t,"name",{value:n,configurable:!0});import{hostOutput as r}from"../host/call-context.js";import{hasContextualPlace as m,contextualStanding as s}from"../host/contextual-place.js";import{publicStandingLines as a}from"../host/admitted-place.js";import{assertStandingView as f}from"../host/standing-projection.js";import{lockStanding as p}from"../fold/keys.js";import{storeOf as u}from"../land/ledger.js";function O(t){const n=u(t);if(f(p(n)),m(t)){r("out",JSON.stringify(s(t))+`
|
|
2
|
+
`);return}const i=a(t);r("out",i.length?i.join(`
|
|
3
|
+
`)+`
|
|
4
|
+
`:"")}o(O,"printStandingResult");export{O as printStandingResult};
|
package/dist/cli/takes.js
CHANGED
|
@@ -1,112 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { land, landEnvelope, ledgerLines, storeOf } from "../land/ledger.js";
|
|
12
|
-
import { wordOf } from "../fold/wire.js";
|
|
13
|
-
import { hasVouchedTree, inside, landCoordinates, coordinatesOf, locationsOf, vouchedCoordinates, witnessOf } from "../land/vouched.js";
|
|
14
|
-
import { ownerOf, forkedScopes, signedOwnerLines } from "./owner.js";
|
|
15
|
-
export function judgeDemand(root, demand) {
|
|
16
|
-
const started = Date.now();
|
|
17
|
-
const store = storeOf(root);
|
|
18
|
-
const scope = fieldOf(demand, 'scope');
|
|
19
|
-
const refuse = (why) => ({ kind: 'refused', scope, why });
|
|
20
|
-
if (!hasVouchedTree(store))
|
|
21
|
-
return refuse('no source is vouched; land the lock once');
|
|
22
|
-
if (forkedScopes(store).has(scope))
|
|
23
|
-
return refuse('it stands as a fork; the owner narrows or withdraws one line first');
|
|
24
|
-
const condition = fieldOf(demand, 'condition');
|
|
25
|
-
if (condition) {
|
|
26
|
-
const paid = ledgerLines(store, 'judge').filter((line) => fieldOf(line, 'scope') === condition && fieldOf(line, 'value') === 'present').pop();
|
|
27
|
-
if (!paid)
|
|
28
|
-
return { kind: 'owed', scope, why: `it rests on ${condition}, which has no FACT: it stands owed until that is paid` };
|
|
29
|
-
const absent = locationsOf(fieldOf(demand, 'needs')).locations.filter((l) => !existsSync(join(root, l.replace(/\/$/, ''))));
|
|
30
|
-
if (absent.length)
|
|
31
|
-
return refuse(`demanded locations absent: ${absent.join(', ')}`);
|
|
32
|
-
return { kind: 'conditioned', scope, demand, receipt: fieldOf(paid, 'at'), condition };
|
|
33
|
-
}
|
|
34
|
-
const { locations, refused } = locationsOf(fieldOf(demand, 'needs'));
|
|
35
|
-
if (refused.length)
|
|
36
|
-
return refuse(`needs that are not locations: ${refused.join(', ')}`);
|
|
37
|
-
const roleOf = rolesOf(store);
|
|
38
|
-
const ignored = new Map();
|
|
39
|
-
const walked = (coordinate) => {
|
|
40
|
-
const role = roleOf(coordinate);
|
|
41
|
-
if (role !== 'source')
|
|
42
|
-
ignored.set(role, (ignored.get(role) ?? 0) + 1);
|
|
43
|
-
return role;
|
|
44
|
-
};
|
|
45
|
-
const before = new Map([...vouchedCoordinates(store)].filter(([coordinate]) => locations.some((l) => inside(coordinate, l)) && roleOf(coordinate) === 'source'));
|
|
46
|
-
const after = new Map();
|
|
47
|
-
for (const location of locations)
|
|
48
|
-
for (const [coordinate, digest] of coordinatesOf(root, location, walked))
|
|
49
|
-
after.set(coordinate, digest);
|
|
50
|
-
const law = [scope.split('/').pop() ?? scope, fieldOf(demand, 'at').replace(/^witness:/, '')].filter(Boolean);
|
|
51
|
-
const standing = foldClaims(signedOwnerLines(store)).standing;
|
|
52
|
-
const unpaid = paidOf(store, [demand], [], `${wordOf(standing, 'families', 'view')}/`).missing.length === 1;
|
|
53
|
-
const verdict = judgeTake({
|
|
54
|
-
root, scope, value: fieldOf(demand, 'value'), locations, before, after, law, unpaid,
|
|
55
|
-
shape: fieldOf(demand, 'shape'), restsOn: fieldOf(demand, 'restsOn'), witnessOf: (coordinate) => witnessOf(root, coordinate),
|
|
56
|
-
template: wordOf(foldClaims(signedOwnerLines(store)).standing, 'templates', '{roots}'),
|
|
57
|
-
});
|
|
58
|
-
return { kind: 'judged', scope, demand, locations, before, after, verdict, ignored, started };
|
|
59
|
-
}
|
|
60
|
-
/** A take its batch let land: its receipt sealed with the gates the batch passed, its cone vouched, its fact landed. */
|
|
61
|
-
export function landTake(root, one, gates) {
|
|
62
|
-
const store = storeOf(root);
|
|
63
|
-
if (one.kind === 'refused')
|
|
64
|
-
return;
|
|
65
|
-
if (one.kind === 'owed') {
|
|
66
|
-
hostOutput('out', `OWED take ${one.scope} · ${one.why}\n`);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (one.kind === 'conditioned') {
|
|
70
|
-
const { scope, demand, receipt, condition } = one;
|
|
71
|
-
land(store, 'judge', [canonical({
|
|
72
|
-
scope, role: 'writes', form: 'alphabet', measure: fieldOf(demand, 'measure') || 'status', value: fieldOf(demand, 'value') || 'present', by: 'judge', at: receipt, condition,
|
|
73
|
-
})]);
|
|
74
|
-
land(store, 'take', [canonical({ scope: `take/${scope}`, role: 'writes', form: 'alphabet', measure: 'status', value: 'fact', by: 'judge', at: receipt })]);
|
|
75
|
-
hostOutput('out', `FACT take ${scope} · paid by ${receipt} · condition ${condition} · no moved set\n`);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const { scope, demand, before, after, ignored, started } = one;
|
|
79
|
-
const verdict = sealed(root, one.verdict, gates);
|
|
80
|
-
const who = writerFor(signedOwnerLines(store), 'fold') ?? ownerOf(store);
|
|
81
|
-
const cone = fullDigest(store, [...before].map(([path, digest]) => `${path} ${digest}`));
|
|
82
|
-
land(store, 'take', [canonical({ scope: `take/${scope}`, role: 'writes', form: 'alphabet', measure: 'status', value: 'open', by: who, at: `place:${cone}` })]);
|
|
83
|
-
landEnvelope(store, verdict.digest, `${JSON.stringify(verdict.envelope, null, 1)}\n`);
|
|
84
|
-
const receipt = `receipt:${verdict.digest}`;
|
|
85
|
-
const generation = fullDigest(store, [...after].sort().map(([coordinate, digest]) => `${coordinate} ${digest}`));
|
|
86
|
-
land(store, 'judge', verdict.envelope.effects.map((effect) => canonical({
|
|
87
|
-
scope: `${effect.kind}/${generation}`, role: 'writes', form: 'alphabet', measure: 'status', value: effect.status, by: 'judge', at: receipt,
|
|
88
|
-
})));
|
|
89
|
-
if (verdict.kind === 'fact') {
|
|
90
|
-
const present = new Map(verdict.changed.filter((path) => after.has(path)).map((path) => [path, after.get(path) ?? '']));
|
|
91
|
-
const gone = verdict.changed.filter((path) => !after.has(path));
|
|
92
|
-
landCoordinates(store, present, gone, receipt);
|
|
93
|
-
land(store, 'judge', [
|
|
94
|
-
canonical({
|
|
95
|
-
scope, role: 'writes', form: 'alphabet', measure: fieldOf(demand, 'measure') || 'status', value: fieldOf(demand, 'value') || 'present', by: 'judge', at: receipt,
|
|
96
|
-
}),
|
|
97
|
-
canonical({ scope, role: 'writes', form: 'alphabet', measure: 'cone', value: (verdict.changed.length ? verdict.changed : [...after.keys()].sort()).join('|'), by: 'judge', at: receipt }),
|
|
98
|
-
]);
|
|
99
|
-
}
|
|
100
|
-
const ms = Date.now() - started;
|
|
101
|
-
land(store, 'take', [
|
|
102
|
-
canonical({ scope: `take/${scope}`, role: 'writes', form: 'alphabet', measure: 'status', value: verdict.kind, by: 'judge', at: receipt }),
|
|
103
|
-
canonical({ scope: `take/${scope}`, role: 'writes', form: 'interval', measure: 'ms', value: `${ms}..${ms}`, by: 'judge', at: receipt }),
|
|
104
|
-
]);
|
|
105
|
-
const effects = verdict.envelope.effects.map((e) => `${e.kind}@${e.at || '.'}:${e.admitted ? e.status : `${e.status}·grey`}(${e.ms} ms)`).join(' ') || 'none';
|
|
106
|
-
hostOutput('out', `${verdict.kind === 'fact' ? 'FACT ' : 'REFUSE'} take ${scope} · ${verdict.why}\n`
|
|
107
|
-
+ `MOVED ${verdict.changed.length} sources: ${verdict.changed.join(' ')}\n`
|
|
108
|
-
+ `IGNORED ${[...ignored].map(([role, n]) => `${n} ${role}`).join(' · ') || 'none'} (not walked, never landed)\n`
|
|
109
|
-
+ `${verdict.notOwned.length ? `NOT OWN ${verdict.notOwned.length} witnesses of other laws, left for them: ${verdict.notOwned.join(' ')}\n` : ''}`
|
|
110
|
-
+ `EFFECTS ${effects}\n`
|
|
111
|
-
+ `RECEIPT ${verdict.digest} · ${ms} ms\n`);
|
|
112
|
-
}
|
|
1
|
+
var x=Object.defineProperty;var w=(l,o)=>x(l,"name",{value:o,configurable:!0});import{hostOutput as T}from"../host/call-context.js";import{existsSync as R}from"node:fs";import{join as A}from"node:path";import{fullDigest as F}from"../fold/digests.js";import{library14_canonical as p}from"../vendor/runtime.js";import{fieldOf as r,foldClaims as D}from"../fold/claims.js";import{paidOf as I}from"../fold/paid.js";import{rolesOf as L}from"../fold/roles.js";import{writerFor as U}from"../fold/signers.js";import{judgeTake as V,sealed as W}from"../judge/take.js";import{land as $,landEnvelope as B,ledgerLines as G,storeOf as S}from"../land/ledger.js";import{wordOf as M}from"../fold/wire.js";import{hasVouchedTree as J,inside as P,landCoordinates as _,coordinatesOf as q,locationsOf as N,vouchedCoordinates as z,witnessOf as H}from"../land/vouched.js";import{ownerOf as K,forkedScopes as Q,signedOwnerLines as C}from"./owner.js";function ue(l,o,b){if(b&&!Number.isSafeInteger(b.now))throw Error("REFUSE\xB7demand invalid explicit clock");const a=Date.now(),s=S(l),d=r(o,"scope"),m=w(e=>({kind:"refused",scope:d,why:e}),"refuse");if(!J(s))return m("no source is vouched; land the lock once");if(Q(s).has(d))return m("it stands as a fork; the owner narrows or withdraws one line first");const f=r(o,"condition");if(f){const e=G(s,"judge").filter(h=>r(h,"scope")===f&&r(h,"value")==="present").pop();if(!e)return{kind:"owed",scope:d,why:`it rests on ${f}, which has no FACT: it stands owed until that is paid`};const i=N(r(o,"needs")).locations.filter(h=>!R(A(l,h.replace(/\/$/,""))));return i.length?m(`demanded locations absent: ${i.join(", ")}`):{kind:"conditioned",scope:d,demand:o,receipt:r(e,"at"),condition:f}}const{locations:g,refused:j}=N(r(o,"needs"));if(j.length)return m(`needs that are not locations: ${j.join(", ")}`);const n=L(s),k=new Map,y=w(e=>{const i=n(e);return i!=="source"&&k.set(i,(k.get(i)??0)+1),i},"walked"),u=new Map([...z(s)].filter(([e])=>g.some(i=>P(e,i))&&n(e)==="source")),v=new Map;for(const e of g)for(const[i,h]of q(l,e,y))v.set(i,h);const O=[d.split("/").pop()??d,r(o,"at").replace(/^witness:/,"")].filter(Boolean),E=D(C(s)).standing,t=I(s,[o],[],`${M(E,"families","view")}/`).missing.length===1,c=V({root:l,scope:d,value:r(o,"value"),locations:g,before:u,after:v,law:O,unpaid:t,shape:r(o,"shape"),restsOn:r(o,"restsOn"),witnessOf:w(e=>H(l,e),"witnessOf"),template:M(D(C(s)).standing,"templates","{roots}")});return{kind:"judged",scope:d,demand:o,locations:g,before:u,after:v,verdict:c,ignored:k,started:a}}w(ue,"judgeDemand");function pe(l,o,b){const a=S(l);if(o.kind==="refused")return;if(o.kind==="owed"){T("out",`OWED take ${o.scope} \xB7 ${o.why}
|
|
2
|
+
`);return}if(o.kind==="conditioned"){const{scope:t,demand:c,receipt:e,condition:i}=o;$(a,"judge",[p({scope:t,role:"writes",form:"alphabet",measure:r(c,"measure")||"status",value:r(c,"value")||"present",by:"judge",at:e,condition:i})]),$(a,"take",[p({scope:`take/${t}`,role:"writes",form:"alphabet",measure:"status",value:"fact",by:"judge",at:e})]),T("out",`FACT take ${t} \xB7 paid by ${e} \xB7 condition ${i} \xB7 no moved set
|
|
3
|
+
`);return}const{scope:s,demand:d,before:m,after:f,ignored:g,started:j}=o,n=W(l,o.verdict,b),k=U(C(a),"fold")??K(a),y=F(a,[...m].map(([t,c])=>`${t} ${c}`));$(a,"take",[p({scope:`take/${s}`,role:"writes",form:"alphabet",measure:"status",value:"open",by:k,at:`place:${y}`})]),B(a,n.digest,`${JSON.stringify(n.envelope,null,1)}
|
|
4
|
+
`);const u=`receipt:${n.digest}`,v=F(a,[...f].sort().map(([t,c])=>`${t} ${c}`));if($(a,"judge",n.envelope.effects.map(t=>p({scope:`${t.kind}/${v}`,role:"writes",form:"alphabet",measure:"status",value:t.status,by:"judge",at:u}))),n.kind==="fact"){const t=new Map(n.changed.filter(e=>f.has(e)).map(e=>[e,f.get(e)??""])),c=n.changed.filter(e=>!f.has(e));_(a,t,c,u),$(a,"judge",[p({scope:s,role:"writes",form:"alphabet",measure:r(d,"measure")||"status",value:r(d,"value")||"present",by:"judge",at:u}),p({scope:s,role:"writes",form:"alphabet",measure:"cone",value:(n.changed.length?n.changed:[...f.keys()].sort()).join("|"),by:"judge",at:u})])}const O=Date.now()-j;$(a,"take",[p({scope:`take/${s}`,role:"writes",form:"alphabet",measure:"status",value:n.kind,by:"judge",at:u}),p({scope:`take/${s}`,role:"writes",form:"interval",measure:"ms",value:`${O}..${O}`,by:"judge",at:u})]);const E=n.envelope.effects.map(t=>`${t.kind}@${t.at||"."}:${t.admitted?t.status:`${t.status}\xB7grey`}(${t.ms} ms)`).join(" ")||"none";T("out",`${n.kind==="fact"?"FACT ":"REFUSE"} take ${s} \xB7 ${n.why}
|
|
5
|
+
MOVED ${n.changed.length} sources: ${n.changed.join(" ")}
|
|
6
|
+
IGNORED ${[...g].map(([t,c])=>`${c} ${t}`).join(" \xB7 ")||"none"} (not walked, never landed)
|
|
7
|
+
${n.notOwned.length?`NOT OWN ${n.notOwned.length} witnesses of other laws, left for them: ${n.notOwned.join(" ")}
|
|
8
|
+
`:""}EFFECTS ${E}
|
|
9
|
+
RECEIPT ${n.digest} \xB7 ${O} ms
|
|
10
|
+
`)}w(pe,"landTake");export{ue as judgeDemand,pe as landTake};
|
package/dist/cli/verb.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export {};
|
|
1
|
+
export {} from "../public-types.js";
|