@lapxo/bound 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CITATION.cff +1 -1
- package/TARGET.bound +44 -39
- package/dist/cli/accept.js +72 -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 +21 -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 +83 -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 +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 -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/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/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 -25
- package/dist/host/objects.js +1 -38
- package/dist/host/order.js +1 -2
- 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/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/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 +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 -41
- package/dist/observe/runner.js +4 -101
- 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-publication.inventory.json +2 -1
- package/docs/contracts/optional-wasm-adapter.publication.json +1 -1
- 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/reference.md +1 -0
- package/package.json +23 -34
- package/receipts.bound +11627 -10323
- package/samples/reading-identity/no.json +20 -0
- package/samples/reading-identity/yes.json +46 -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/.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/dist/cli/pass.js
CHANGED
|
@@ -1,321 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
import { render, renderedOf, unrendered, viewOf } from "../render/view.js";
|
|
23
|
-
import { releasePolicyLines } from "../fold/release-policy.js";
|
|
24
|
-
import { carriedFrom } from "../fold/resolved.js";
|
|
25
|
-
import { wireLine } from "../fold/wire.js";
|
|
26
|
-
import { isWire, RECEIPTS } from "../fold/claims.js";
|
|
27
|
-
import { withoutEffects } from "../host/read-only.js";
|
|
28
|
-
import { assertNativeReaderGrantsCurrent } from "../host/native/route.js";
|
|
29
|
-
/**
|
|
30
|
-
* The pass of a place, in one process: the releases its instrument names are laid out first, its readers observe
|
|
31
|
-
* once, each place a view writes in is folded once, the places before the root whose door reads them, and every coordinate a
|
|
32
|
-
* view writes there is its render or is written again.
|
|
33
|
-
* A round that wrote nothing ends the pass; one that made a coordinate or wrote one a region reads folds again, since what a
|
|
34
|
-
* place shows may rest on what another renders — a coordinate rewritten that no region reads moves no page — and a third round
|
|
35
|
-
* that still writes is named, never looped. With `--check` nothing is written; without it the pass holds the store,
|
|
36
|
-
* and what it saw answer and lay lands by the key that writes folds: which capsule rendered each region of a view and
|
|
37
|
-
* which release each dependency was laid from, each line once. What an act's gates saw answer lands only once its batch
|
|
38
|
-
* has landed, and never when it is refused.
|
|
39
|
-
*/
|
|
40
|
-
/**
|
|
41
|
-
* A check verifies existing receipts without running readers or refreshing hashes. Open regions or a different
|
|
42
|
-
* instrument refuse; an admitted fold must establish closure before it can be checked.
|
|
43
|
-
*/
|
|
44
|
-
async function checked(root, entry, under) {
|
|
45
|
-
const started = Date.now();
|
|
46
|
-
const store = storeOf(root);
|
|
47
|
-
if (!meets(root, store, under ?? '', false)) {
|
|
48
|
-
process.stderr.write(`${selfName()}: REFUSE·check receipts are open; a fold must close them\n`);
|
|
49
|
-
return 1;
|
|
50
|
-
}
|
|
51
|
-
const contract = wireLine(ownLock(), 'receipt-instrument');
|
|
52
|
-
const evidence = carriedFrom(store, (observeText(join(root, under ?? '', RECEIPTS)) ?? '').split('\n').filter(isWire));
|
|
53
|
-
const sealed = contract === undefined ? undefined : evidence?.find(line => fieldOf(line, 'scope') === fieldOf(contract, 'value') && fieldOf(line, 'measure') === 'digest');
|
|
54
|
-
const expectedInstrument = sealed === undefined ? instrumentKept(store) : fieldOf(sealed, 'value');
|
|
55
|
-
if (!expectedInstrument) {
|
|
56
|
-
process.stderr.write(`${selfName()}: REFUSE·check no verified instrument identity is available for these receipts\n`);
|
|
57
|
-
return 1;
|
|
58
|
-
}
|
|
59
|
-
const standing = emptyLedger(store) ? ownLockOf(root, under?.replace(/\/$/, '') ?? '') : standingOf(root).standing;
|
|
60
|
-
const instrument = sealed === undefined ? instrumentOf(store, entry, standing, root, ownLock()) : instrumentDigest(store, resolve(root, entry), [], ownRoot(), ownLock());
|
|
61
|
-
if (expectedInstrument !== instrument) {
|
|
62
|
-
process.stderr.write(`${selfName()}: REFUSE·check receipt instrument differs; a fold must close it\n`);
|
|
63
|
-
return 1;
|
|
64
|
-
}
|
|
65
|
-
const read = receiptsSeen();
|
|
66
|
-
const ms = Date.now() - started;
|
|
67
|
-
if (under === undefined)
|
|
68
|
-
process.stderr.write(`RECEIPTS ${read.count || receiptPlaces(root, store).length} read · 0 opened · ${ms} ms\n`);
|
|
69
|
-
else
|
|
70
|
-
process.stderr.write(`CLOSED ${under} · ${ms} ms\n`);
|
|
71
|
-
const seconds = actSeconds();
|
|
72
|
-
process.stderr.write(`COST act ${seconds} s\n`);
|
|
73
|
-
process.stdout.write(`PASS closed · ${under ? 1 : receiptPlaces(root, store).length} places · ${ms} ms\n`);
|
|
74
|
-
return 0;
|
|
75
|
-
}
|
|
76
|
-
export async function pass(root, entry, under, check) {
|
|
77
|
-
if (check) {
|
|
78
|
-
// Verification reads existing evidence; it grants no admission authority.
|
|
79
|
-
return withoutEffects(() => emptyLedger(storeOf(root)) ? checked(root, entry, under) : underTheLock(storeOf(root), 'check', () => checked(root, entry, under)));
|
|
80
|
-
}
|
|
81
|
-
if (!under && emptyLedger(storeOf(root))) {
|
|
82
|
-
sayStranger(root);
|
|
83
|
-
return 0;
|
|
84
|
-
}
|
|
85
|
-
const started = Date.now();
|
|
86
|
-
const run = async () => {
|
|
87
|
-
const swept = await sweep(root, entry, under, check, []);
|
|
88
|
-
for (const coordinate of check ? swept.written : [])
|
|
89
|
-
process.stdout.write(`DIFFERS ${coordinate}\n`);
|
|
90
|
-
// Byte seals describe the completed render pass, not its intermediate outputs.
|
|
91
|
-
if (!swept.written.length)
|
|
92
|
-
await closeReceipts(root, storeOf(root));
|
|
93
|
-
// Sealed files do not imply an empty reading. If a retained fold is stale,
|
|
94
|
-
// foldPlace must reload its evidence; a valid retained fold still costs no read.
|
|
95
|
-
const fold = foldPlace(root, entry, under, false, { standing: swept.standingAt.get(under ?? '') ?? standingOf(root, under), ...(swept.settled ? {} : { observed: swept.observed.length ? swept.observed : observedClaims(root, storeOf(root), { wait: false }) }), free: !swept.settled });
|
|
96
|
-
const closed = meets(root, storeOf(root), under ?? '', true, fold.observed) && !swept.written.length;
|
|
97
|
-
for (const line of releasePolicyLines(fold.release))
|
|
98
|
-
process.stdout.write(`${line}\n`);
|
|
99
|
-
if (closed) {
|
|
100
|
-
instrumentKeep(storeOf(root), instrumentOf(storeOf(root), entry, standingOf(root).standing, root, ownLock()));
|
|
101
|
-
process.stdout.write(`PASS closed · ${swept.places} places · ${Date.now() - started} ms\n`);
|
|
102
|
-
return 0;
|
|
103
|
-
}
|
|
104
|
-
process.stdout.write(`PASS ${swept.same + swept.written.length} renders · ${swept.same} same${swept.written.length ? ` · ${swept.written.length} ${check ? 'differ' : 'still written after three rounds'}` : ''} · ${swept.places} places · ${Date.now() - started} ms\n`);
|
|
105
|
-
process.stdout.write(render(fold, [{ name: 'programs', at: 1 }]));
|
|
106
|
-
return swept.written.length ? 1 : 0;
|
|
107
|
-
};
|
|
108
|
-
return underTheLock(storeOf(root), 'pass', run);
|
|
109
|
-
}
|
|
110
|
-
export function landSaid(store, folder, lines) {
|
|
111
|
-
if (folder === undefined || !lines.length)
|
|
112
|
-
return;
|
|
113
|
-
const bare = (line) => ((got) => (got.kind === 'fact' ? canonical(Object.fromEntries(Object.entries(got.value.fields).filter(([name]) => !ENVELOPE.has(name) && name !== 'by'))) : line))(parse(line));
|
|
114
|
-
const held = new Set(ledgerLines(store, folder).filter((line) => /(?:^|\s)scope=re(?:ndered|solved)\//.test(line)).map(bare));
|
|
115
|
-
const fresh = [...new Set(lines.filter((line) => !held.has(bare(line))).map((line) => ((got) => (got.kind === 'fact' ? canonical({ ...got.value.fields, by: folder }) : line))(parse(line))))];
|
|
116
|
-
if (fresh.length)
|
|
117
|
-
land(store, folder, fresh);
|
|
118
|
-
}
|
|
119
|
-
async function sweep(root, entry, under, check, told, journal, given, keep, reach) {
|
|
120
|
-
const store = storeOf(root);
|
|
121
|
-
const digestAt = Date.now();
|
|
122
|
-
const met = told.length === 0 && reach === undefined && meets(root, store, under ?? '');
|
|
123
|
-
const sameInstrument = instrumentKept(store) === instrumentOf(store, entry, standingOf(root).standing, root, ownLock());
|
|
124
|
-
const missingView = () => {
|
|
125
|
-
if (!under || !worldAt(root, under.replace(/\/$/, '')))
|
|
126
|
-
return false;
|
|
127
|
-
const held = standingOf(root, under);
|
|
128
|
-
const views = viewsOf(held.standing);
|
|
129
|
-
return wordsOf(held.standing, 'views/world').some((name) => {
|
|
130
|
-
const view = views.get(name);
|
|
131
|
-
return view?.shape !== undefined && view.shape !== '' && observeText(join(root, under, view.shape)) === undefined;
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
const settled = met && sameInstrument && !missingView();
|
|
135
|
-
if (settled) {
|
|
136
|
-
// File and receipt seals authenticate retained evidence. A normal quiet
|
|
137
|
-
// fold also needs today's acting Root grant; --check uses checked() above
|
|
138
|
-
// and intentionally performs historical inspection without fresh effects.
|
|
139
|
-
assertNativeReaderGrantsCurrent(store);
|
|
140
|
-
const ms = Date.now() - digestAt;
|
|
141
|
-
const read = receiptsSeen();
|
|
142
|
-
const lock = algorithmCost();
|
|
143
|
-
const hash = Math.max(0, ms - lock);
|
|
144
|
-
if (lock > 0) {
|
|
145
|
-
noteIdle();
|
|
146
|
-
process.stderr.write(`RED fold/idle · ${idleCount()} · lock ${lock} ms · hash ${hash} ms · a fold over a closed region\n`);
|
|
147
|
-
}
|
|
148
|
-
if (under === undefined)
|
|
149
|
-
process.stderr.write(`RECEIPTS ${read.count} read · 0 opened · ${ms} ms\n`);
|
|
150
|
-
else
|
|
151
|
-
process.stderr.write(`CLOSED ${under} · lock ${lock} ms · hash ${hash} ms\n`);
|
|
152
|
-
const seconds = actSeconds();
|
|
153
|
-
process.stderr.write(`COST act ${seconds} s\n`);
|
|
154
|
-
return { same: 0, written: [], places: under === undefined ? read.count : 1, observed: [], standingAt: new Map(), folds: new Map(), said: [], settled: true };
|
|
155
|
-
}
|
|
156
|
-
const lock = standingOf(root, undefined, told);
|
|
157
|
-
// A place asks for its own mounts; the instrument catalog is not a consumer dependency.
|
|
158
|
-
layReleases(store, root, lock.standing, store);
|
|
159
|
-
const descent = reach ?? (under ? [under.replace(/\/$/, '')] : undefined);
|
|
160
|
-
const limited = descent !== undefined;
|
|
161
|
-
const observed = given ?? observedClaims(root, store, { wait: true, ...(descent !== undefined ? { reach: descent } : {}) });
|
|
162
|
-
landLaid(store, root, lock.standing, writerFor(lock.standing, 'fold'));
|
|
163
|
-
const shaped = (standing) => [...viewsOf(standing).values()].flatMap((view) => ('regions' in view && view.shape ? [view] : []));
|
|
164
|
-
const views = shaped(lock.standing);
|
|
165
|
-
const tree = viewsOf(lock.lock);
|
|
166
|
-
const worldList = wordsOf(lock.standing, 'views/world');
|
|
167
|
-
const worldPlaces = new Set(worldsIn(root).map((name) => `${name}/`));
|
|
168
|
-
const resolved = (view) => {
|
|
169
|
-
const named = placesOf(lock.standing, view);
|
|
170
|
-
if (!worldList.includes(view.name))
|
|
171
|
-
return named;
|
|
172
|
-
const picked = named.filter((place) => worldPlaces.has(place));
|
|
173
|
-
return picked.length ? picked : [...worldPlaces];
|
|
174
|
-
};
|
|
175
|
-
const placeless = views.filter((view) => !worldList.includes(view.name) && !placesOf(lock.standing, view).length);
|
|
176
|
-
const holding = localDirectoriesIn(root).filter((name) => placeless.some((view) => observeText(join(root, name, view.shape)) !== undefined)).map((name) => `${name}/`);
|
|
177
|
-
const descended = (place) => !limited || descent.some((one) => one === '' || place === `${one}/` || place.startsWith(`${one}/`));
|
|
178
|
-
const reached = limited ? descent.filter((one) => one !== '').map((one) => (one.endsWith('/') ? one : `${one}/`)) : [];
|
|
179
|
-
const places = [...new Set([...views.flatMap(resolved), ...holding, ...reached])]
|
|
180
|
-
.filter((place) => place !== '' && (!under || place.startsWith(under)) && descended(place)).sort();
|
|
181
|
-
const standingAt = new Map([...places, ''].map((place) => [place, place ? standingOf(root, place, told) : lock]));
|
|
182
|
-
const writes = (place) => {
|
|
183
|
-
const { standing } = standingAt.get(place) ?? lock;
|
|
184
|
-
const mine = shaped(standing);
|
|
185
|
-
const own = worldAt(root, place.slice(0, -1)) ? ownLockOf(root, place.slice(0, -1)) : [];
|
|
186
|
-
const namedOf = (view) => placesOf(standing, view);
|
|
187
|
-
return mine.filter((view) => namedOf(view).includes(place) || (own.length > 0 && defaulted(standing, view, own, tree))
|
|
188
|
-
|| (!worldList.includes(view.name) && !namedOf(view).length && observeText(join(root, place, view.shape)) !== undefined && !mine.some((other) => other.shape === view.shape && namedOf(other).includes(place))));
|
|
189
|
-
};
|
|
190
|
-
let same = 0;
|
|
191
|
-
let written = [];
|
|
192
|
-
const read = new Set(ownLock().filter((line) => fieldOf(line, 'scope').startsWith('region/') && fieldOf(line, 'measure') === 'lines').flatMap((line) => fieldOf(line, 'value').split('|')));
|
|
193
|
-
const free = (place) => limited ? descended(place) : !sameInstrument || !meets(root, store, place);
|
|
194
|
-
const folds = new Map();
|
|
195
|
-
const answered = new Map();
|
|
196
|
-
const paint = (place, drawn, moved) => {
|
|
197
|
-
for (const view of drawn) {
|
|
198
|
-
if (view.missing.length) {
|
|
199
|
-
throw new Error(`REFUSE·view at ${place || '.'} · asks regions nothing renders: ${view.missing.join(' ')}`);
|
|
200
|
-
}
|
|
201
|
-
if (!check && view.said.length)
|
|
202
|
-
answered.set(`${place}${view.shape}`, view.said);
|
|
203
|
-
const coordinate = join(root, place, view.shape);
|
|
204
|
-
const leaf = ['s', 'v', 'g'].join('');
|
|
205
|
-
if (view.shape.endsWith(`.${leaf}`) && !view.text.includes(`<${leaf}`)) {
|
|
206
|
-
if (!check && observeText(coordinate) !== undefined) {
|
|
207
|
-
rmSync(coordinate, { force: true });
|
|
208
|
-
written.push(`${place}${view.shape}`);
|
|
209
|
-
}
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
if (observeText(coordinate) === view.text)
|
|
213
|
-
same += 1;
|
|
214
|
-
else if (check)
|
|
215
|
-
written.push(`${place}${view.shape}`);
|
|
216
|
-
else {
|
|
217
|
-
moved.at || (moved.at = observeText(coordinate) === undefined || read.has(view.shape));
|
|
218
|
-
const held = journal !== undefined && !journal.has(coordinate) ? observeFile(coordinate) : undefined;
|
|
219
|
-
const made = mkdirSync(dirname(coordinate), { recursive: true });
|
|
220
|
-
if (journal !== undefined && !journal.has(coordinate))
|
|
221
|
-
journal.set(coordinate, { held, made });
|
|
222
|
-
replaceWhole(coordinate, view.text);
|
|
223
|
-
written.push(`${place}${view.shape}`);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
for (let round = 1; round <= 3; round += 1) {
|
|
228
|
-
written = [];
|
|
229
|
-
same = 0;
|
|
230
|
-
const moved = { at: false };
|
|
231
|
-
const asked = [...places, ...(under || (limited && descent.length > 0 && !descent.includes('')) ? [] : [''])];
|
|
232
|
-
const open = asked.filter((place) => free(place));
|
|
233
|
-
for (const place of asked)
|
|
234
|
-
if (!open.includes(place))
|
|
235
|
-
same += writes(place).length;
|
|
236
|
-
if (!under && round === 1) {
|
|
237
|
-
if (!receiptsSeen().count)
|
|
238
|
-
meets(root, store, '');
|
|
239
|
-
const read = receiptsSeen();
|
|
240
|
-
process.stderr.write(`RECEIPTS ${read.count} read · ${open.length} opened · ${read.ms} ms\n`);
|
|
241
|
-
}
|
|
242
|
-
if (open.length)
|
|
243
|
-
process.stderr.write(`OPEN ${open.map((place) => place || '.').join(' ')}\n`);
|
|
244
|
-
const aside = open.filter((place) => place !== '' && !keep?.has(place) && !meets(root, store, place));
|
|
245
|
-
const drawn = aside.length > 1 ? await drawParallel(aside.map((place) => ({ root, entry, place, told, observed, views: writes(place) }))) : new Map();
|
|
246
|
-
for (const place of open) {
|
|
247
|
-
if (!check && place === '')
|
|
248
|
-
await holdRoot(store, 'join');
|
|
249
|
-
if (!check && !holds(store, place)) {
|
|
250
|
-
process.stderr.write(`OUTSIDE ${place} · not settled, and no region this act holds: the next pass renders it\n`);
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
const ready = drawn.get(place);
|
|
254
|
-
if (ready !== undefined) {
|
|
255
|
-
paint(place, ready, moved);
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
258
|
-
const standing = standingAt.get(place) ?? lock;
|
|
259
|
-
const fold = foldPlace(root, entry, place || undefined, false, { standing, observed, free: true });
|
|
260
|
-
if (keep?.has(place))
|
|
261
|
-
folds.set(place, fold);
|
|
262
|
-
paint(place, writes(place).map((view) => {
|
|
263
|
-
const missing = unrendered(fold, view);
|
|
264
|
-
return { shape: view.shape, missing, text: missing.length ? '' : viewOf(fold, view), said: missing.length ? [] : renderedOf(fold, view) };
|
|
265
|
-
}), moved);
|
|
266
|
-
}
|
|
267
|
-
if (check || !written.length)
|
|
268
|
-
break;
|
|
269
|
-
for (const coordinate of written)
|
|
270
|
-
process.stdout.write(`RENDERED ${coordinate} · round ${round}\n`);
|
|
271
|
-
if (!moved.at) {
|
|
272
|
-
same += written.length;
|
|
273
|
-
written = [];
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
const said = [...answered.values()].flat();
|
|
278
|
-
if (!check && journal === undefined)
|
|
279
|
-
landSaid(store, writerFor(lock.standing, 'fold'), [...resolvedOf(store, root, lock.standing, store), ...said]);
|
|
280
|
-
return { same, written, places: places.length + (under ? 0 : 1), observed, standingAt, folds, said: journal === undefined ? [] : said, settled: false };
|
|
281
|
-
}
|
|
282
|
-
function drawParallel(jobs) {
|
|
283
|
-
const out = new Map();
|
|
284
|
-
if (jobs.length < 2)
|
|
285
|
-
return Promise.resolve(out);
|
|
286
|
-
return new Promise((resolve, reject) => {
|
|
287
|
-
const workers = [];
|
|
288
|
-
let left = jobs.length;
|
|
289
|
-
let failed = false;
|
|
290
|
-
const refuse = (error) => {
|
|
291
|
-
if (failed)
|
|
292
|
-
return;
|
|
293
|
-
failed = true;
|
|
294
|
-
reject(error);
|
|
295
|
-
for (const worker of workers)
|
|
296
|
-
void worker.terminate();
|
|
297
|
-
};
|
|
298
|
-
try {
|
|
299
|
-
for (const job of jobs) {
|
|
300
|
-
const worker = new Worker(processOf('fold-worker', 'fold'), { execArgv: process.execArgv, workerData: job });
|
|
301
|
-
workers.push(worker);
|
|
302
|
-
worker.on('message', (msg) => out.set(msg.place, msg.texts));
|
|
303
|
-
worker.on('error', refuse);
|
|
304
|
-
worker.on('exit', (code) => {
|
|
305
|
-
if (failed)
|
|
306
|
-
return;
|
|
307
|
-
if (code !== 0 || !out.has(job.place)) {
|
|
308
|
-
refuse(new Error(`REFUSE·worker ${job.place} · exit ${code} · no completed render`));
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
left -= 1;
|
|
312
|
-
if (left === 0)
|
|
313
|
-
resolve(out);
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
catch (error) {
|
|
318
|
-
refuse(error instanceof Error ? error : new Error(String(error)));
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
}
|
|
1
|
+
var Re=Object.defineProperty;var w=(e,d)=>Re(e,"name",{value:d,configurable:!0});import{mkdirSync as De,rmSync as Pe}from"node:fs";import{dirname as xe,join as C,resolve as Le}from"node:path";import{Worker as Ce}from"node:worker_threads";import{library11_ENVELOPE as ye,library11_canonical as re,library11_parse as ie}from"../vendor/runtime.js";import{foldPlace as oe,standingOf as b}from"./place.js";import{fieldOf as k,selfName as j}from"../fold/claims.js";import{observedClaims as ae}from"../fold/observed.js";import{layReleases as Ie,resolvedOf as Me}from"../host/release.js";import{ownLock as P,ownRoot as Ae,processOf as Fe}from"../observe/runner.js";import{landLaid as Te}from"../fold/laid.js";import{actSeconds as de,closeReceipts as We,idleCount as Ne,instrumentKeep as Ue,instrumentKept as ce,meets as x,noteIdle as Ve,receiptPlaces as fe,receiptsSeen as F}from"../fold/closed.js";import{algorithmCost as _e,instrumentOf as q,instrumentDigest as Ke}from"../fold/digests.js";import{writerFor as le}from"../fold/signers.js";import{defaulted as Ge,placesOf as z,viewsOf as B}from"../fold/views.js";import{ownLockOf as me}from"../fold/signed.js";import{localDirectoriesIn as je,worldAt as pe,worldsIn as qe}from"../fold/places.js";import{wordsOf as ue}from"../fold/wire.js";import{land as ze,ledgerLines as Be,replaceWhole as He,storeOf as E}from"../land/ledger.js";import{holdRoot as Je,holds as Qe,underTheLock as he}from"../land/act.js";import{emptyLedger as H,sayStranger as Xe}from"../fold/stranger.js";import{observeFile as Ye,observeText as R}from"../observe/files.js";import{render as Ze,renderedOf as es,unrendered as ss,viewOf as ts}from"../render/view.js";import{releasePolicyLines as ns}from"../fold/release-policy.js";import{carriedFrom as rs}from"../fold/resolved.js";import{wireLine as is}from"../fold/wire.js";import{isWire as os,RECEIPTS as as}from"../fold/claims.js";import{withoutEffects as ds}from"../host/read-only.js";import{assertNativeReaderGrantsCurrent as cs}from"../host/native/route.js";async function we(e,d,t){const m=Date.now(),c=E(e);if(!x(e,c,t??"",!1))return process.stderr.write(`${j()}: REFUSE\xB7check receipts are open; a fold must close them
|
|
2
|
+
`),1;const u=is(P(),"receipt-instrument"),r=rs(c,(R(C(e,t??"",as))??"").split(`
|
|
3
|
+
`).filter(os)),f=u===void 0?void 0:r?.find(W=>k(W,"scope")===k(u,"value")&&k(W,"measure")==="digest"),l=f===void 0?ce(c):k(f,"value");if(!l)return process.stderr.write(`${j()}: REFUSE\xB7check no verified instrument identity is available for these receipts
|
|
4
|
+
`),1;const o=H(c)?me(e,t?.replace(/\/$/,"")??""):b(e).standing,S=f===void 0?q(c,d,o,e,P()):Ke(c,Le(e,d),[],Ae(),P());if(l!==S)return process.stderr.write(`${j()}: REFUSE\xB7check receipt instrument differs; a fold must close it
|
|
5
|
+
`),1;const T=F(),D=Date.now()-m;t===void 0?process.stderr.write(`RECEIPTS ${T.count||fe(e,c).length} read \xB7 0 opened \xB7 ${D} ms
|
|
6
|
+
`):process.stderr.write(`CLOSED ${t} \xB7 ${D} ms
|
|
7
|
+
`);const J=de();return process.stderr.write(`COST act ${J} s
|
|
8
|
+
`),process.stdout.write(`PASS closed \xB7 ${t?1:fe(e,c).length} places \xB7 ${D} ms
|
|
9
|
+
`),0}w(we,"checked");async function Ks(e,d,t,m){if(m)return ds(()=>H(E(e))?we(e,d,t):he(E(e),"check",()=>we(e,d,t)));if(!t&&H(E(e)))return Xe(e),0;const c=Date.now(),u=w(async()=>{const r=await ls(e,d,t,m,[]);for(const o of m?r.written:[])process.stdout.write(`DIFFERS ${o}
|
|
10
|
+
`);r.written.length||await We(e,E(e));const f=oe(e,d,t,!1,{standing:r.standingAt.get(t??"")??b(e,t),...r.settled?{}:{observed:r.observed.length?r.observed:ae(e,E(e),{wait:!1})},free:!r.settled}),l=x(e,E(e),t??"",!0,f.observed)&&!r.written.length;for(const o of ns(f.release))process.stdout.write(`${o}
|
|
11
|
+
`);return l?(Ue(E(e),q(E(e),d,b(e).standing,e,P())),process.stdout.write(`PASS closed \xB7 ${r.places} places \xB7 ${Date.now()-c} ms
|
|
12
|
+
`),0):(process.stdout.write(`PASS ${r.same+r.written.length} renders \xB7 ${r.same} same${r.written.length?` \xB7 ${r.written.length} ${m?"differ":"still written after three rounds"}`:""} \xB7 ${r.places} places \xB7 ${Date.now()-c} ms
|
|
13
|
+
`),process.stdout.write(Ze(f,[{name:"programs",at:1}])),r.written.length?1:0)},"run");return he(E(e),"pass",u)}w(Ks,"pass");function fs(e,d,t){if(d===void 0||!t.length)return;const m=w(r=>(f=>f.kind==="fact"?re(Object.fromEntries(Object.entries(f.value.fields).filter(([l])=>!ye.has(l)&&l!=="by"))):r)(ie(r)),"bare"),c=new Set(Be(e,d).filter(r=>/(?:^|\s)scope=re(?:ndered|solved)\//.test(r)).map(m)),u=[...new Set(t.filter(r=>!c.has(m(r))).map(r=>(f=>f.kind==="fact"?re({...f.value.fields,by:d}):r)(ie(r))))];u.length&&ze(e,d,u)}w(fs,"landSaid");async function ls(e,d,t,m,c,u,r,f,l){const o=E(e),S=Date.now(),T=c.length===0&&l===void 0&&x(e,o,t??""),D=ce(o)===q(o,d,b(e).standing,e,P());if(T&&D&&!w(()=>{if(!t||!pe(e,t.replace(/\/$/,"")))return!1;const s=b(e,t),a=B(s.standing);return ue(s.standing,"views/world").some(h=>{const i=a.get(h);return i?.shape!==void 0&&i.shape!==""&&R(C(e,t,i.shape))===void 0})},"missingView")()){cs(o);const s=Date.now()-S,a=F(),h=_e(),i=Math.max(0,s-h);h>0&&(Ve(),process.stderr.write(`RED fold/idle \xB7 ${Ne()} \xB7 lock ${h} ms \xB7 hash ${i} ms \xB7 a fold over a closed region
|
|
14
|
+
`)),t===void 0?process.stderr.write(`RECEIPTS ${a.count} read \xB7 0 opened \xB7 ${s} ms
|
|
15
|
+
`):process.stderr.write(`CLOSED ${t} \xB7 lock ${h} ms \xB7 hash ${i} ms
|
|
16
|
+
`);const p=de();return process.stderr.write(`COST act ${p} s
|
|
17
|
+
`),{same:0,written:[],places:t===void 0?a.count:1,observed:[],standingAt:new Map,folds:new Map,said:[],settled:!0}}const g=b(e,void 0,c);Ie(o,e,g.standing,o);const O=l??(t?[t.replace(/\/$/,"")]:void 0),y=O!==void 0,N=r??ae(e,o,{wait:!0,...O!==void 0?{reach:O}:{}});Te(o,e,g.standing,le(g.standing,"fold"));const Q=w(s=>[...B(s).values()].flatMap(a=>"regions"in a&&a.shape?[a]:[]),"shaped"),X=Q(g.standing),ge=B(g.lock),U=ue(g.standing,"views/world"),Y=new Set(qe(e).map(s=>`${s}/`)),$e=w(s=>{const a=z(g.standing,s);if(!U.includes(s.name))return a;const h=a.filter(i=>Y.has(i));return h.length?h:[...Y]},"resolved"),Ee=X.filter(s=>!U.includes(s.name)&&!z(g.standing,s).length),Se=je(e).filter(s=>Ee.some(a=>R(C(e,s,a.shape))!==void 0)).map(s=>`${s}/`),Z=w(s=>!y||O.some(a=>a===""||s===`${a}/`||s.startsWith(`${a}/`)),"descended"),ve=y?O.filter(s=>s!=="").map(s=>s.endsWith("/")?s:`${s}/`):[],V=[...new Set([...X.flatMap($e),...Se,...ve])].filter(s=>s!==""&&(!t||s.startsWith(t))&&Z(s)).sort(),_=new Map([...V,""].map(s=>[s,s?b(e,s,c):g])),K=w(s=>{const{standing:a}=_.get(s)??g,h=Q(a),i=pe(e,s.slice(0,-1))?me(e,s.slice(0,-1)):[],p=w($=>z(a,$),"namedOf");return h.filter($=>p($).includes(s)||i.length>0&&Ge(a,$,i,ge)||!U.includes($.name)&&!p($).length&&R(C(e,s,$.shape))!==void 0&&!h.some(n=>n.shape===$.shape&&p(n).includes(s)))},"writes");let L=0,v=[];const Oe=new Set(P().filter(s=>k(s,"scope").startsWith("region/")&&k(s,"measure")==="lines").flatMap(s=>k(s,"value").split("|"))),be=w(s=>y?Z(s):!D||!x(e,o,s),"free"),ee=new Map,se=new Map,te=w((s,a,h)=>{for(const i of a){if(i.missing.length)throw new Error(`REFUSE\xB7view at ${s||"."} \xB7 asks regions nothing renders: ${i.missing.join(" ")}`);!m&&i.said.length&&se.set(`${s}${i.shape}`,i.said);const p=C(e,s,i.shape),$=["s","v","g"].join("");if(i.shape.endsWith(`.${$}`)&&!i.text.includes(`<${$}`)){!m&&R(p)!==void 0&&(Pe(p,{force:!0}),v.push(`${s}${i.shape}`));continue}if(R(p)===i.text)L+=1;else if(m)v.push(`${s}${i.shape}`);else{h.at||(h.at=R(p)===void 0||Oe.has(i.shape));const n=u!==void 0&&!u.has(p)?Ye(p):void 0,I=De(xe(p),{recursive:!0});u!==void 0&&!u.has(p)&&u.set(p,{held:n,made:I}),He(p,i.text),v.push(`${s}${i.shape}`)}}},"paint");for(let s=1;s<=3;s+=1){v=[],L=0;const a={at:!1},h=[...V,...t||y&&O.length>0&&!O.includes("")?[]:[""]],i=h.filter(n=>be(n));for(const n of h)i.includes(n)||(L+=K(n).length);if(!t&&s===1){F().count||x(e,o,"");const n=F();process.stderr.write(`RECEIPTS ${n.count} read \xB7 ${i.length} opened \xB7 ${n.ms} ms
|
|
18
|
+
`)}i.length&&process.stderr.write(`OPEN ${i.map(n=>n||".").join(" ")}
|
|
19
|
+
`);const p=i.filter(n=>n!==""&&!f?.has(n)&&!x(e,o,n)),$=p.length>1?await ms(p.map(n=>({root:e,entry:d,place:n,told:c,observed:N,views:K(n)}))):new Map;for(const n of i){if(!m&&n===""&&await Je(o,"join"),!m&&!Qe(o,n)){process.stderr.write(`OUTSIDE ${n} \xB7 not settled, and no region this act holds: the next pass renders it
|
|
20
|
+
`);continue}const I=$.get(n);if(I!==void 0){te(n,I,a);continue}const ke=_.get(n)??g,M=oe(e,d,n||void 0,!1,{standing:ke,observed:N,free:!0});f?.has(n)&&ee.set(n,M),te(n,K(n).map(A=>{const G=ss(M,A);return{shape:A.shape,missing:G,text:G.length?"":ts(M,A),said:G.length?[]:es(M,A)}}),a)}if(m||!v.length)break;for(const n of v)process.stdout.write(`RENDERED ${n} \xB7 round ${s}
|
|
21
|
+
`);if(!a.at){L+=v.length,v=[];break}}const ne=[...se.values()].flat();return!m&&u===void 0&&fs(o,le(g.standing,"fold"),[...Me(o,e,g.standing,o),...ne]),{same:L,written:v,places:V.length+(t?0:1),observed:N,standingAt:_,folds:ee,said:u===void 0?[]:ne,settled:!1}}w(ls,"sweep");function ms(e){const d=new Map;return e.length<2?Promise.resolve(d):new Promise((t,m)=>{const c=[];let u=e.length,r=!1;const f=w(l=>{if(!r){r=!0,m(l);for(const o of c)o.terminate()}},"refuse");try{for(const l of e){const o=new Ce(Fe("fold-worker","fold"),{execArgv:process.execArgv,workerData:l});c.push(o),o.on("message",S=>d.set(S.place,S.texts)),o.on("error",f),o.on("exit",S=>{if(!r){if(S!==0||!d.has(l.place)){f(new Error(`REFUSE\xB7worker ${l.place} \xB7 exit ${S} \xB7 no completed render`));return}u-=1,u===0&&t(d)}})}}catch(l){f(l instanceof Error?l:new Error(String(l)))}})}w(ms,"drawParallel");export{fs as landSaid,Ks as pass};
|