@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/verb.js
CHANGED
|
@@ -1,685 +1,86 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (values.size !== 1)
|
|
88
|
-
throw new Error(`REFUSE·bootstrap root key ${owner} must declare one ${measure}`);
|
|
89
|
-
return [...values][0];
|
|
90
|
-
};
|
|
91
|
-
if (said('class') !== 'authorize')
|
|
92
|
-
throw new Error('REFUSE·bootstrap the root key must authorize');
|
|
93
|
-
const publicKey = said('public-key');
|
|
94
|
-
const coverage = said('coverage').split('|').filter(Boolean);
|
|
95
|
-
if (!publicKey || !coverage.length)
|
|
96
|
-
throw new Error('REFUSE·bootstrap the root key must declare its public key and coverage');
|
|
97
|
-
const drafted = today.filter(line => !fieldOf(line, 'sig'));
|
|
98
|
-
if (drafted.length) {
|
|
99
|
-
const invoke = signerFor(today, keyId, valueOf(args, FLAGS.signer), valueOf(args, FLAGS.keyFile));
|
|
100
|
-
const got = await signConsentLot(drafted, { epoch: 1, by: keyId, algorithm: config.era }, publicKey, config.admitted, invoke);
|
|
101
|
-
if (got.kind === 'refuse')
|
|
102
|
-
throw new Error(got.why);
|
|
103
|
-
let i = 0;
|
|
104
|
-
today.splice(0, today.length, ...today.map(line => fieldOf(line, 'sig') ? line : got.lines[i++]));
|
|
105
|
-
}
|
|
106
|
-
const authority = authorityFor(today, { ...releaseSigner(today), id: owner, publicKey, coverage }, config.admitted);
|
|
107
|
-
for (const line of today) {
|
|
108
|
-
const verdict = authority.of(line);
|
|
109
|
-
if (verdict.kind !== 'admitted')
|
|
110
|
-
throw new Error(`REFUSE·bootstrap ${fieldOf(line, 'scope')} is not admitted: ${verdict.why ?? verdict.kind}`);
|
|
111
|
-
verified += 1;
|
|
112
|
-
}
|
|
113
|
-
// Source receipts require admitted instrument coordinates before the root commit.
|
|
114
|
-
vouching(today);
|
|
115
|
-
sourced(today);
|
|
116
|
-
born = bootstrapDigest(today.map((line) => line.replace(/ sig="[^"]*"/, '')).sort(), algorithm);
|
|
117
|
-
anchored = { [owner]: { id: owner, publicKey, coverage } };
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
process.stderr.write(`${selfName()}: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
121
|
-
return EXIT.refuse;
|
|
122
|
-
}
|
|
123
|
-
// Preflight above performs no writes. Only an admitted batch may establish its root of trust.
|
|
124
|
-
return underTheLock(store, 'bootstrap', () => {
|
|
125
|
-
if (ledgerLines(store, owner).length || observeText(targetFile(root)) !== proposed) {
|
|
126
|
-
process.stderr.write(`${selfName()}: REFUSE·bootstrap the proposed lock or owner ledger changed before commit\n`);
|
|
127
|
-
return EXIT.refuse;
|
|
128
|
-
}
|
|
129
|
-
const landed = land(store, owner, today);
|
|
130
|
-
if (keyId !== owner)
|
|
131
|
-
land(store, keyId, today);
|
|
132
|
-
const file = join(store, `${selfName()}.keys`);
|
|
133
|
-
mkdirSync(dirname(file), { recursive: true });
|
|
134
|
-
writeFileSync(file, `${JSON.stringify(anchored, null, 2)}\n`);
|
|
135
|
-
const signedLines = today.filter((line) => /\bsig=/.test(line));
|
|
136
|
-
const failing = signedLines.length - verified;
|
|
137
|
-
land(store, 'land', [canonical({
|
|
138
|
-
scope: 'bootstrap', role: 'writes', form: 'alphabet', measure: 'status', value: 'present', by: 'land', at: `bootstrap:${born}`,
|
|
139
|
-
about: 'the lines this clone was born from: one land per clone, and a second is a fork of the same cell',
|
|
140
|
-
})]);
|
|
141
|
-
const rendered = renderInto(root, store);
|
|
142
|
-
process.stdout.write(`FACT landed ${landed.appended} unique lines from ${today.length} in TARGET`
|
|
143
|
-
+ ` · ${failing} of ${signedLines.length} signed lines fail admission by declared authority\n`
|
|
144
|
-
+ `TARGET ${rendered.standing} claims · ${rendered.superseded.length} superseded · ${Date.now() - started} ms\n`);
|
|
145
|
-
for (const line of rendered.superseded)
|
|
146
|
-
process.stdout.write(`SUPERSEDED ${line}\n`);
|
|
147
|
-
if (!hasVouchedTree(store)) {
|
|
148
|
-
const locations = new Set();
|
|
149
|
-
const refused = new Set();
|
|
150
|
-
for (const line of signedDemands(store)) {
|
|
151
|
-
const got = locationsOf(fieldOf(line, 'needs'));
|
|
152
|
-
for (const l of got.locations)
|
|
153
|
-
locations.add(l);
|
|
154
|
-
for (const r of got.refused)
|
|
155
|
-
refused.add(r);
|
|
156
|
-
}
|
|
157
|
-
const coordinates = new Map();
|
|
158
|
-
const roleOf = rolesOf(store);
|
|
159
|
-
for (const location of locations)
|
|
160
|
-
for (const [path, digest] of coordinatesOf(root, location, roleOf))
|
|
161
|
-
coordinates.set(path, digest);
|
|
162
|
-
const vouched = landCoordinates(store, coordinates, [], 'origin:land');
|
|
163
|
-
process.stdout.write(`FACT vouched · ${vouched} sources under ${locations.size} locations · ${refused.size} needs refused as globs\n`);
|
|
164
|
-
}
|
|
165
|
-
return EXIT.closed;
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
/** What one fold cost, where it was taken and whether its points had already been folded: a beat of the instrument. */
|
|
169
|
-
function beat(root, fold, ms) {
|
|
170
|
-
const folder = writerFor(fold.standing, 'fold');
|
|
171
|
-
const seconds = (n) => `${(n / 1000).toFixed(n < 100 ? 2 : 1)} s`;
|
|
172
|
-
process.stderr.write(`BEAT fold ${fold.key.slice(0, 8)} ${fold.kept ? 'kept' : 'folded'} ${seconds(ms)}`
|
|
173
|
-
+ `${fold.beats.kept ? ` · ${seconds(fold.beats.kept)} kept` : ''}${fold.beats.folded ? ` · ${seconds(fold.beats.folded)} folded` : ''}\n`);
|
|
174
|
-
if (folder === undefined)
|
|
175
|
-
return;
|
|
176
|
-
if (!fold.kept) {
|
|
177
|
-
const moved = movedPoints(storeOf(root), foldPoints(storeOf(root), fold.standing, fold.under, folder, fold.instrument), fold.key);
|
|
178
|
-
const named = moved === undefined ? 'no fold was kept before this one'
|
|
179
|
-
: `${moved.gone.length} points gone · ${moved.came.length} came · ${[...moved.gone, ...moved.came].slice(0, 3).map((one) => one.split(' ')[0]).join(' ') || 'none'}`;
|
|
180
|
-
process.stderr.write(`KEPT fold ${fold.key.slice(0, 8)} miss · ${named}\n`);
|
|
181
|
-
}
|
|
182
|
-
land(storeOf(root), folder, [canonical({
|
|
183
|
-
scope: `beat/${fold.under ?? '.'}`, role: 'writes', form: 'interval', measure: 'ms',
|
|
184
|
-
value: `${ms}..${ms}`, by: folder, at: `place:${fold.kept ? 'kept' : 'folded'}`,
|
|
185
|
-
})]);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* A view of a place, rendered from its fold; a shaped one writes the coordinate its shape names. With a batch named, it is the view of the tree
|
|
189
|
-
* as if the batch had landed: the batch is signed and folded, never landed, and nothing is written — `--as rank <batch>`
|
|
190
|
-
* is what a batch would move, read before land.
|
|
191
|
-
*/
|
|
192
|
-
async function view(root, under, asked, told = [], coord, key, includePolicy = true, authorityHeld = false) {
|
|
193
|
-
const [name = asked, depth] = asked.split('@');
|
|
194
|
-
if (name === NAMED_VIEWS.help) {
|
|
195
|
-
process.stdout.write(`${helpLines().join('\n')}\n`);
|
|
196
|
-
return EXIT.closed;
|
|
197
|
-
}
|
|
198
|
-
// A declared executable reader holds the acting Root's authority throughout
|
|
199
|
-
// observation and publication. This predicate acquires exclusion only; the
|
|
200
|
-
// native route authenticates the actual declaration before use.
|
|
201
|
-
if (!authorityHeld && !told.length && !readOnly() && lockStanding(storeOf(root)).some(line => /^reader\/.+\/port$/.test(fieldOf(line, 'scope')) && fieldOf(line, 'role') === 'writes' && fieldOf(line, 'value') !== 'withdraw')) {
|
|
202
|
-
return underRootAuthority(storeOf(root), 'view reader authority', () => view(root, under, asked, told, coord, key, includePolicy, true));
|
|
203
|
-
}
|
|
204
|
-
if (!lockLines(storeOf(root)).length) {
|
|
205
|
-
process.stderr.write(`${selfName()}: the owner ledger is empty; land it before rendering a view\n`);
|
|
206
|
-
return EXIT.refuse;
|
|
207
|
-
}
|
|
208
|
-
if (name === 'act') {
|
|
209
|
-
if (under || told.length)
|
|
210
|
-
throw Error('REFUSE·act committed identity query only');
|
|
211
|
-
printActResult(root, coord);
|
|
212
|
-
return EXIT.closed;
|
|
213
|
-
}
|
|
214
|
-
if (name === 'standing') {
|
|
215
|
-
if (under || told.length || coord || depth !== undefined)
|
|
216
|
-
throw new BoundRefusal('standing/query', 'REFUSE·standing local committed projection only');
|
|
217
|
-
printStandingResult(root);
|
|
218
|
-
return EXIT.closed;
|
|
219
|
-
}
|
|
220
|
-
if (name === 'evidence' && !under && !told.length && ingressBundles(storeOf(root)).length) {
|
|
221
|
-
const declared = viewsOf(lockStanding(storeOf(root))).get(name);
|
|
222
|
-
if (!declared || declared.shape || !declared.regions.some(region => region.name === 'evidence'))
|
|
223
|
-
throw Error('REFUSE·view foreign evidence requires a declared evidence view');
|
|
224
|
-
const received = await foreignWalkLines(root), authority = authorityFor(lockLines(storeOf(root)), rootSigner(root), signaturesOf(storeOf(root)).admitted);
|
|
225
|
-
const local = [...new Set(authority.admitted.flatMap(key => ledgerLines(storeOf(root), key.id)))].filter(line => authority.of(line).kind === 'admitted');
|
|
226
|
-
for (const line of [...new Set([...local, ...ingressReceipts(storeOf(root)), ...received])])
|
|
227
|
-
process.stdout.write(line + '\n');
|
|
228
|
-
process.stdout.write('FACT authenticated histories · readings · no encounters computed\n');
|
|
229
|
-
return EXIT.closed;
|
|
230
|
-
}
|
|
231
|
-
const at = Date.now();
|
|
232
|
-
const place = under?.replace(/\/$/, '');
|
|
233
|
-
const released = releaseOf(storeOf(root));
|
|
234
|
-
const authority = authorityFor([...released ?? lockLines(storeOf(root)), ...told], released ? releaseSigner(released) : rootSigner(root), signaturesOf(storeOf(root), told).admitted);
|
|
235
|
-
const ledger = told.filter((line) => authority.of(line).kind === 'admitted');
|
|
236
|
-
const rest = told.filter((line) => !ledger.includes(line));
|
|
237
|
-
if (place && rest.length)
|
|
238
|
-
tellOwn(place, rest);
|
|
239
|
-
if (name === NAMED_VIEWS.lines && (told.length || depth === undefined)) {
|
|
240
|
-
const text = standingOf(root, under, ledger).standing.filter(isWire).join('\n');
|
|
241
|
-
process.stdout.write(text ? `${text}\n` : '');
|
|
242
|
-
return EXIT.closed;
|
|
243
|
-
}
|
|
244
|
-
if (told.length) {
|
|
245
|
-
const selected = viewsOf(standingOf(root, under, ledger).standing).get(name);
|
|
246
|
-
if (selected && !selected.shape && selected.regions.some(region => region.name === 'cells')) {
|
|
247
|
-
const history = [...signedOwnerLines(storeOf(root)), ...ledger];
|
|
248
|
-
const held = await admittedObjects(root, history);
|
|
249
|
-
process.stdout.write(`TOLD ${told.length} lines folded as if landed · nothing written\n`);
|
|
250
|
-
for (const line of renderCells(objectFold(held.records, held.context)))
|
|
251
|
-
process.stdout.write(line + '\n');
|
|
252
|
-
return EXIT.closed;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
const own = place ? rest.filter((line) => admittedIn(root, place, line)) : [];
|
|
256
|
-
// Executed views use the place's declared mounts before observation, as pass
|
|
257
|
-
// does. Prospective folds and public standing queries do not lay releases.
|
|
258
|
-
if (!told.length && !readOnly())
|
|
259
|
-
layReleases(storeOf(root), root, standingOf(root, under).standing, storeOf(root));
|
|
260
|
-
const fold = told.length
|
|
261
|
-
? foldPlace(root, entryOf(root), under, false, { standing: standingOf(root, under, ledger), observed: observedClaims(root, storeOf(root), { wait: false }), free: true })
|
|
262
|
-
: foldPlace(root, entryOf(root), under, true);
|
|
263
|
-
if (!told.length && readerRefusals().length) {
|
|
264
|
-
for (const why of readerRefusals())
|
|
265
|
-
process.stderr.write(`${selfName()}: ${why}\n`);
|
|
266
|
-
return EXIT.refuse;
|
|
267
|
-
}
|
|
268
|
-
if (coord)
|
|
269
|
-
askWhy(fold, coord);
|
|
270
|
-
if (name === NAMED_VIEWS.lines) {
|
|
271
|
-
if (!told.length)
|
|
272
|
-
beat(root, fold, Date.now() - at);
|
|
273
|
-
const text = fold.standing.filter(isWire).join('\n');
|
|
274
|
-
process.stdout.write(text ? `${text}\n` : '');
|
|
275
|
-
if (depth === '1')
|
|
276
|
-
for (const line of readingsIn([...fold.standing.filter(isCeiling), ...ownCeilings(under)], fold))
|
|
277
|
-
process.stdout.write(`${line}\n`);
|
|
278
|
-
return EXIT.closed;
|
|
279
|
-
}
|
|
280
|
-
const views = viewsOf(fold.standing);
|
|
281
|
-
const cellsView = [...views.entries()].find(([, one]) => !one.shape && one.regions.some((region) => region.name === 'cells'));
|
|
282
|
-
if (cellsView && name === cellsView[0]) {
|
|
283
|
-
const history = signedOwnerLines(storeOf(root));
|
|
284
|
-
const { objectHistory } = await import('@lapxo/topos/wire');
|
|
285
|
-
const parsed = objectHistory(history);
|
|
286
|
-
if (parsed.kind !== 'fact')
|
|
287
|
-
throw Error(`REFUSE·wire ${parsed.why}`);
|
|
288
|
-
if (parsed.value.objects.length) {
|
|
289
|
-
await cellsWithReceipts(root, history, text => process.stdout.write(text + '\n'));
|
|
290
|
-
if (includePolicy)
|
|
291
|
-
for (const line of releasePolicyLines(fold.release))
|
|
292
|
-
process.stdout.write(line + '\n');
|
|
293
|
-
if (!told.length)
|
|
294
|
-
beat(root, fold, Date.now() - at);
|
|
295
|
-
return EXIT.closed;
|
|
296
|
-
}
|
|
297
|
-
if (!told.length)
|
|
298
|
-
beat(root, fold, Date.now() - at);
|
|
299
|
-
const cells = fold.open ?? [];
|
|
300
|
-
const mine = key ? cells.filter((cell) => cell.origins.includes(key)) : cells;
|
|
301
|
-
const cards = openCards(mine);
|
|
302
|
-
if (key)
|
|
303
|
-
process.stdout.write(`KEY ${key}\n`);
|
|
304
|
-
if (cards.length)
|
|
305
|
-
process.stdout.write(`${cards.join('\n')}\n`);
|
|
306
|
-
return EXIT.closed;
|
|
307
|
-
}
|
|
308
|
-
if (!told.length)
|
|
309
|
-
beat(root, fold, Date.now() - at);
|
|
310
|
-
if (name === 'rank') {
|
|
311
|
-
const asked = place ? [place] : placesIn(root);
|
|
312
|
-
const reds = asked.flatMap((one) => sharedShapes(ownLockOf(root, one)).map((said) => `${one} ${said}`));
|
|
313
|
-
if (reds.length) {
|
|
314
|
-
process.stderr.write(`${selfName()}: REFUSE·rank ${reds.join(' · ')}: two views naming the same shape in one place\n`);
|
|
315
|
-
return EXIT.refuse;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
const signed = views.get(name);
|
|
319
|
-
if (!signed) {
|
|
320
|
-
process.stderr.write(`${selfName()}: no view/${name} is signed; the lock signs ${[...views.keys()].sort().map((v) => `view/${v}`).join(' · ') || 'no view'}\n`);
|
|
321
|
-
return EXIT.usage;
|
|
322
|
-
}
|
|
323
|
-
const missing = unrendered(fold, signed);
|
|
324
|
-
if (missing.length) {
|
|
325
|
-
process.stderr.write(`${selfName()}: REFUSE·view view/${name} asks regions nothing renders: ${missing.join(' ')} · none is the instrument's own and no capsule ${under ?? 'the root'} can run declares it\n`);
|
|
326
|
-
return EXIT.refuse;
|
|
327
|
-
}
|
|
328
|
-
const bound = placesOf(fold.standing, signed);
|
|
329
|
-
if (bound.length && !bound.includes(under ?? '')) {
|
|
330
|
-
process.stderr.write(`${selfName()}: view/${name} writes ${bound.map((place) => `${place}${signed.shape}`).join(' · ')}, and nothing of ${under ?? 'this place'}\n`);
|
|
331
|
-
return EXIT.usage;
|
|
332
|
-
}
|
|
333
|
-
const folder = writerFor(fold.standing, 'fold');
|
|
334
|
-
if (folder !== undefined && !told.length) {
|
|
335
|
-
const spent = Date.now() - at;
|
|
336
|
-
land(storeOf(root), folder, [canonical({
|
|
337
|
-
scope: `beat/${under ?? '.'}`, role: 'writes', form: 'interval', measure: 'ms',
|
|
338
|
-
value: `${spent}..${spent}`, by: folder, at: `place:command-${fold.kept ? 'kept' : 'folded'}`,
|
|
339
|
-
})]);
|
|
340
|
-
}
|
|
341
|
-
const shown = (fold) => {
|
|
342
|
-
const text = viewOf(fold, Number.isFinite(Number(depth)) && depth !== undefined ? { ...signed, regions: signed.regions.map((one) => (one.called ? { ...one, at: Number(depth) } : one)) } : signed);
|
|
343
|
-
if (process.argv.includes(FLAGS.check)) {
|
|
344
|
-
const coordinate = join(root, under ?? '', signed.shape || '');
|
|
345
|
-
const held = signed.shape ? observeText(coordinate) : undefined;
|
|
346
|
-
const same = held !== undefined && held === text;
|
|
347
|
-
if (same) {
|
|
348
|
-
process.stdout.write(`SAME ${signed.shape || `view/${name}`}\n`);
|
|
349
|
-
return EXIT.closed;
|
|
350
|
-
}
|
|
351
|
-
const heldLines = (held ?? '').split('\n');
|
|
352
|
-
const next = text.split('\n');
|
|
353
|
-
const found = heldLines.findIndex((line, i) => line !== next[i]);
|
|
354
|
-
const at = found < 0 ? Math.min(heldLines.length, next.length) : found;
|
|
355
|
-
const line = (found < 0 ? next[at] : heldLines[at]) ?? next[at] ?? '';
|
|
356
|
-
process.stdout.write(`DIFFERS ${signed.shape || `view/${name}`}${held === undefined ? ' · this place holds no such region' : ` · line ${at + 1} · ${line}`}\n`);
|
|
357
|
-
return EXIT.refuse;
|
|
358
|
-
}
|
|
359
|
-
if (!signed.shape || told.length) {
|
|
360
|
-
if (told.length) {
|
|
361
|
-
process.stdout.write(`TOLD ${told.length} lines folded as if landed · ${ledger.length} in the ledger · ${own.length} in ${place ?? 'the root'}'s own lock`
|
|
362
|
-
+ `${rest.length - own.length ? ` · ${rest.length - own.length} admitted nowhere` : ''} · the batch lands nothing and nothing is written\n`);
|
|
363
|
-
}
|
|
364
|
-
process.stdout.write(text);
|
|
365
|
-
if (depth === '1')
|
|
366
|
-
for (const line of readingsIn(told.length ? told.filter(isCeiling) : [...fold.standing.filter(isCeiling), ...ownCeilings(under)], fold))
|
|
367
|
-
process.stdout.write(`${line}\n`);
|
|
368
|
-
return EXIT.closed;
|
|
369
|
-
}
|
|
370
|
-
const coordinate = join(root, under ?? '', signed.shape);
|
|
371
|
-
return underTheRegions(storeOf(root), [under ?? ''], `view/${name}`, () => {
|
|
372
|
-
mkdirSync(dirname(coordinate), { recursive: true });
|
|
373
|
-
writeFileSync(coordinate, text);
|
|
374
|
-
process.stdout.write(`RENDERED ${relative(root, coordinate).split(sep).join('/')} · view/${name} · ${text.split('\n').length - 1} lines\n`);
|
|
375
|
-
return EXIT.closed;
|
|
376
|
-
});
|
|
377
|
-
};
|
|
378
|
-
return shown(fold);
|
|
379
|
-
}
|
|
380
|
-
async function signVerb(root, rest) {
|
|
381
|
-
const as = valueOf(rest, FLAGS.as);
|
|
382
|
-
if (as !== undefined) {
|
|
383
|
-
const sources = positionalsOf(rest);
|
|
384
|
-
if (as !== 'reference' || sources.length !== 1 || rest.includes(FLAGS.check))
|
|
385
|
-
throw new BoundRefusal('reference-export/usage', 'REFUSE·reference-export usage: sign --as reference <source-url>');
|
|
386
|
-
const result = await exportAuthenticatedReference(root, sources[0], { key: valueOf(rest, FLAGS.key), keyFile: valueOf(rest, FLAGS.keyFile), signer: valueOf(rest, FLAGS.signer) });
|
|
387
|
-
process.stdout.write(JSON.stringify(result) + '\n');
|
|
388
|
-
return EXIT.closed;
|
|
389
|
-
}
|
|
390
|
-
const batch = await signedBatch(root, rest, positionalsOf(rest));
|
|
391
|
-
if (batch.kind === 'exit')
|
|
392
|
-
return batch.code;
|
|
393
|
-
if (batch.kind === 'once') {
|
|
394
|
-
process.stderr.write(`ONCE ${batch.proposed.length} lines · every one already landed: nothing to sign\n`);
|
|
395
|
-
return EXIT.closed;
|
|
396
|
-
}
|
|
397
|
-
for (const place of namedPlaces(rest))
|
|
398
|
-
process.stdout.write(`# place ${place}\n`);
|
|
399
|
-
for (const line of batch.signed)
|
|
400
|
-
process.stdout.write(`${line}\n`);
|
|
401
|
-
process.stderr.write(`SIGNED ${batch.signed.length} lines · epoch ${batch.epoch}${namedPlaces(rest).length ? ` · own lines for ${namedPlaces(rest).join(', ')}` : ''} · they land together, before the lock moves\n`);
|
|
402
|
-
return EXIT.closed;
|
|
403
|
-
}
|
|
404
|
-
async function landVerb(root, rest) {
|
|
405
|
-
const lock = resolve(targetFile(root));
|
|
406
|
-
const batch = positionalsOf(rest).filter((one) => {
|
|
407
|
-
const at = resolve(one);
|
|
408
|
-
return existsSync(at) && !lstatSync(at).isDirectory() && at !== lock;
|
|
409
|
-
});
|
|
410
|
-
if (!batch.length) {
|
|
411
|
-
const store = storeOf(root);
|
|
412
|
-
if (existsSync(join(store, 'ledger')) && ledgerLines(store, ownerOf(store)).length) {
|
|
413
|
-
process.stderr.write(`${selfName()}: REFUSE·bootstrap the owner ledger already holds claims; provide an explicit signed batch to change it\n`);
|
|
414
|
-
return EXIT.refuse;
|
|
415
|
-
}
|
|
416
|
-
return firstLand(root, rest);
|
|
417
|
-
}
|
|
418
|
-
const die = (why) => {
|
|
419
|
-
process.stderr.write(`${selfName()}: ${why.startsWith('REFUSE·') ? why : `REFUSE·crash ${why}`}\n`);
|
|
420
|
-
process.exitCode = EXIT.refuse;
|
|
421
|
-
};
|
|
422
|
-
process.once('SIGINT', () => die('SIGINT'));
|
|
423
|
-
process.once('SIGHUP', () => die('SIGHUP'));
|
|
424
|
-
process.once('uncaughtException', (error) => die(error instanceof Error ? error.message : String(error)));
|
|
425
|
-
process.once('unhandledRejection', (error) => die(error instanceof Error ? error.message : String(error)));
|
|
426
|
-
try {
|
|
427
|
-
const proposed = batch.flatMap(claimLinesIn);
|
|
428
|
-
if (proposed.some(isWalkHeader)) {
|
|
429
|
-
for (const line of await landWalk(root, proposed, valueOf(rest, FLAGS.key), valueOf(rest, FLAGS.keyFile), valueOf(rest, FLAGS.signer)))
|
|
430
|
-
process.stdout.write(line + '\n');
|
|
431
|
-
return EXIT.closed;
|
|
432
|
-
}
|
|
433
|
-
return await accept(root, rest);
|
|
434
|
-
}
|
|
435
|
-
catch (error) {
|
|
436
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
437
|
-
process.stderr.write(`${selfName()}: ${message.startsWith('REFUSE·') ? message : `REFUSE·crash ${message}`}\n`);
|
|
438
|
-
return EXIT.refuse;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
function foldFile(at) {
|
|
442
|
-
const lines = claimLinesIn(at);
|
|
443
|
-
const folded = foldClaims(lines);
|
|
444
|
-
const fields = folded.standing.flatMap(line => { const got = parseWire(line); return got.kind === 'fact' ? [got.value.fields] : []; });
|
|
445
|
-
const isTopos = fields.some(f => f.scope?.startsWith('region/') && f.measure === 'reads');
|
|
446
|
-
if (isTopos && folded.forks.length)
|
|
447
|
-
throw Error('REFUSE·topos incompatible live claims in declared fold');
|
|
448
|
-
const selected = isTopos ? toposStanding(folded.standing) : undefined;
|
|
449
|
-
if (selected !== undefined) {
|
|
450
|
-
const wire = wireAt(ownLock().flatMap(line => { const got = parseWire(line); return got.kind === 'fact' ? [got.value.fields] : []; }), Number.MAX_SAFE_INTEGER);
|
|
451
|
-
const algorithm = wire?.digests.values().next().value;
|
|
452
|
-
if (!algorithm)
|
|
453
|
-
throw Error('REFUSE·topos instrument names no digest algorithm');
|
|
454
|
-
process.stdout.write(selected.split('\n').filter(Boolean).map(line => 'TOPOS ' + line).join('\n') + '\n');
|
|
455
|
-
process.stdout.write('PIN ' + bootstrapDigest([selected], algorithm) + '\n');
|
|
456
|
-
}
|
|
457
|
-
for (const line of folded.standing)
|
|
458
|
-
process.stdout.write(`${line}\n`);
|
|
459
|
-
for (const fork of folded.forks)
|
|
460
|
-
process.stdout.write(`FORK ${fork.key}${fork.state ? ` · ${fork.state}` : ''}\n`);
|
|
461
|
-
process.stdout.write(`FACT ${folded.standing.length} standing · ${folded.forks.length} forks · ${basename(at)} · readings · no encounters computed\n`);
|
|
462
|
-
return EXIT.closed;
|
|
463
|
-
}
|
|
464
|
-
function foldVerb(root, rest) {
|
|
465
|
-
const references = positionalsOf(rest).filter(one => /^#bound(?::|$)/.test(one));
|
|
466
|
-
if (references.length) {
|
|
467
|
-
if (references.length !== 1 || positionalsOf(rest).length !== 1 || rest.some(one => one.startsWith('--')))
|
|
468
|
-
throw Error('REFUSE·reference name one reference without view, check or signing options');
|
|
469
|
-
if (authenticatedReferenceSelected(standingOf(root).standing))
|
|
470
|
-
return openAuthenticatedReference(root, references[0]).then(result => {
|
|
471
|
-
process.stdout.write(`SOURCE ${result.reference.source}\n`);
|
|
472
|
-
for (const line of result.semanticStanding.split('\n').filter(Boolean))
|
|
473
|
-
process.stdout.write(`TOPOS ${line}\n`);
|
|
474
|
-
for (const cell of result.readings)
|
|
475
|
-
process.stdout.write('CELL ' + JSON.stringify(cell) + '\n');
|
|
476
|
-
process.stdout.write(`AUTHENTICATED standing ${result.semanticIdentity} · authority ${result.authorityContextIdentity} · no effects committed\n`);
|
|
477
|
-
return EXIT.closed;
|
|
478
|
-
});
|
|
479
|
-
return inspectReference(references[0], standingOf(root).standing).then(result => {
|
|
480
|
-
process.stdout.write(`SOURCE ${result.reference.source}\n`);
|
|
481
|
-
for (const line of result.lines)
|
|
482
|
-
process.stdout.write(`TOPOS ${line}\n`);
|
|
483
|
-
process.stdout.write(`INSPECT standing sha256:${result.reference.digest} · blob ${result.reference.blob} · no encounters computed · unauthenticated\n`);
|
|
484
|
-
return EXIT.closed;
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
const files = positionalsOf(rest).filter((one) => existsSync(resolve(one)) && !lstatSync(resolve(one)).isDirectory() && one.endsWith(EXTENSION));
|
|
488
|
-
const places = positionalsOf(rest).filter((one) => existsSync(resolve(one)) && lstatSync(resolve(one)).isDirectory());
|
|
489
|
-
if (files.length === 1 && !places.length && valueOf(rest, FLAGS.as) === undefined) {
|
|
490
|
-
const at = resolve(files[0]);
|
|
491
|
-
if (!at.endsWith(`/${LOCK}`) && at !== LOCK)
|
|
492
|
-
return foldFile(at);
|
|
493
|
-
return foldAt(dirname(at), undefined, rest);
|
|
494
|
-
}
|
|
495
|
-
const under = places[0];
|
|
496
|
-
// A prospective lot is data, not the place whose authority admits it.
|
|
497
|
-
const tree = files.length ? root : resolve('.');
|
|
498
|
-
const place = under ? relative(tree, resolve(under)).split(sep).join('/') : '';
|
|
499
|
-
return foldAt(tree, place ? `${place}/` : undefined, rest);
|
|
500
|
-
}
|
|
501
|
-
async function foldAt(root, under, argv) {
|
|
502
|
-
return withContentStore(storeOf(root), () => foldRequested(root, under, argv), () => standingOf(root, under).standing);
|
|
503
|
-
}
|
|
504
|
-
async function foldRequested(root, under, argv) {
|
|
505
|
-
const as = valueOf(argv, FLAGS.as);
|
|
506
|
-
const prospective = as !== undefined && positionalsOf(argv).some(one => existsSync(resolve(one)) && !lstatSync(resolve(one)).isDirectory());
|
|
507
|
-
if (as === 'release' || as?.split('@')[0] === 'act' || as === NAMED_VIEWS.help || prospective || argv.includes(FLAGS.check))
|
|
508
|
-
return foldResolved(root, under, argv);
|
|
509
|
-
return resolveRequested(digest => resolveSources(standingOf(root, under).standing, [digest]), () => foldResolved(root, under, argv));
|
|
510
|
-
}
|
|
511
|
-
async function foldResolved(root, under, argv) {
|
|
512
|
-
const as = valueOf(argv, FLAGS.as);
|
|
513
|
-
if (as === 'release') {
|
|
514
|
-
const approvals = positionalsOf(argv).filter(one => !(existsSync(resolve(one)) && lstatSync(resolve(one)).isDirectory()));
|
|
515
|
-
if (approvals.length !== 1 || argv.includes(FLAGS.check))
|
|
516
|
-
throw Error('REFUSE·release name one approval file; check does not authorize delivery');
|
|
517
|
-
return withoutEffects(() => { printReleaseApproval(under ? resolve(root, under) : root, resolve(approvals[0])); return EXIT.closed; });
|
|
518
|
-
}
|
|
519
|
-
const inputs = positionalsOf(argv).filter(one => existsSync(resolve(one)) && !lstatSync(resolve(one)).isDirectory());
|
|
520
|
-
// Public content is authenticated by its digest, independently of owner history.
|
|
521
|
-
// A named view does not request mounting every release of the instrument.
|
|
522
|
-
const receiptCheck = as === undefined && argv.includes(FLAGS.check);
|
|
523
|
-
if (as?.split('@')[0] === 'walk') {
|
|
524
|
-
if (argv.includes(FLAGS.check))
|
|
525
|
-
throw Error('REFUSE·walk check does not initiate or sign an exchange');
|
|
526
|
-
if (under || inputs.length > 1)
|
|
527
|
-
throw Error('REFUSE·walk one place and one authenticated peer inventory per fold');
|
|
528
|
-
const depth = as.split('@')[1];
|
|
529
|
-
if (depth !== undefined && (!/^(0|[1-9][0-9]*)$/.test(depth) || !Number.isSafeInteger(Number(depth))))
|
|
530
|
-
throw Error('REFUSE·walk invalid resolution');
|
|
531
|
-
const peer = inputs.length ? claimLinesIn(inputs[0]) : [];
|
|
532
|
-
for (const line of await renderWalk(root, depth === undefined ? undefined : Number(depth), peer, valueOf(argv, FLAGS.key), valueOf(argv, FLAGS.keyFile), valueOf(argv, FLAGS.signer)))
|
|
533
|
-
process.stdout.write(line + '\n');
|
|
534
|
-
return EXIT.closed;
|
|
535
|
-
}
|
|
536
|
-
if (as === OBJECT_VIEW) {
|
|
537
|
-
const inputs = positionalsOf(argv).filter(one => existsSync(resolve(one)) && !lstatSync(resolve(one)).isDirectory());
|
|
538
|
-
if (inputs.length > 1)
|
|
539
|
-
throw Error('REFUSE·object one history snapshot per fold');
|
|
540
|
-
const history = inputs.length ? claimLinesIn(inputs[0]) : signedOwnerLines(storeOf(root));
|
|
541
|
-
const held = await admittedObjects(root, history, text => process.stdout.write(text + '\n'));
|
|
542
|
-
let cells;
|
|
543
|
-
if (usesWasmObject(held.configuration)) {
|
|
544
|
-
const cancellation = new AbortController(), interrupt = () => cancellation.abort();
|
|
545
|
-
process.once('SIGINT', interrupt);
|
|
546
|
-
try {
|
|
547
|
-
cells = await foldObjectsWithWasm(root, held.records, held.context, held.configuration, cancellation.signal);
|
|
548
|
-
}
|
|
549
|
-
finally {
|
|
550
|
-
process.removeListener('SIGINT', interrupt);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
else
|
|
554
|
-
cells = objectFold(held.records, held.context);
|
|
555
|
-
for (const cell of cells)
|
|
556
|
-
process.stdout.write('CELL ' + JSON.stringify(cell) + '\n');
|
|
557
|
-
process.stdout.write(`FACT object fold ${cells.length} cells\n`);
|
|
558
|
-
return EXIT.closed;
|
|
559
|
-
}
|
|
560
|
-
const key = valueOf(argv, FLAGS.key);
|
|
561
|
-
if (as === undefined) {
|
|
562
|
-
const exit = await pass(root, entryOf(root), under, argv.includes(FLAGS.check));
|
|
563
|
-
if (receiptCheck)
|
|
564
|
-
return exit;
|
|
565
|
-
if (exit !== 0)
|
|
566
|
-
return exit;
|
|
567
|
-
const history = signedOwnerLines(storeOf(root));
|
|
568
|
-
const { objectHistory } = await import('@lapxo/topos/wire');
|
|
569
|
-
const parsed = objectHistory(history);
|
|
570
|
-
if (parsed.kind !== 'fact')
|
|
571
|
-
throw Error(`REFUSE·wire ${parsed.why}`);
|
|
572
|
-
if (parsed.value.objects.length) {
|
|
573
|
-
const signedCells = [...viewsOf(history).values()].find(one => !one.shape && one.regions.some(region => region.name === 'cells'));
|
|
574
|
-
if (!signedCells)
|
|
575
|
-
throw Error('REFUSE·view object cells require a signed cells view');
|
|
576
|
-
return view(root, under, signedCells.name, [], undefined, undefined, false);
|
|
577
|
-
}
|
|
578
|
-
return exit;
|
|
579
|
-
}
|
|
580
|
-
const named = inputs;
|
|
581
|
-
const coord = positionalsOf(argv).find((one) => one !== under?.replace(/\/$/, '') && !one.startsWith('-') && !(existsSync(resolve(one)) && lstatSync(resolve(one)).isDirectory()));
|
|
582
|
-
if (as === 'act') {
|
|
583
|
-
if (positionalsOf(argv).length !== 1)
|
|
584
|
-
throw Error('REFUSE·act name one committed identity');
|
|
585
|
-
return view(root, under, as, [], coord);
|
|
586
|
-
}
|
|
587
|
-
if ((as === 'why' || as === NAMED_VIEWS.because || as.split('@')[0] === 'why') && coord !== undefined)
|
|
588
|
-
return view(root, under, as === NAMED_VIEWS.because ? 'why' : as, [], coord, key);
|
|
589
|
-
if (!named.length)
|
|
590
|
-
return view(root, under, as, [], undefined, key);
|
|
591
|
-
const batch = await signedBatch(root, argv, named);
|
|
592
|
-
if (batch.kind === 'exit')
|
|
593
|
-
return batch.code;
|
|
594
|
-
if (batch.kind === 'once')
|
|
595
|
-
process.stdout.write(`ONCE ${batch.proposed.length} lines · every one already landed: the view folds the tree as it stands\n`);
|
|
596
|
-
return withoutEffects(() => view(root, under, as, batch.kind === 'signed' ? batch.signed : batch.proposed, undefined, key));
|
|
597
|
-
}
|
|
598
|
-
const VERBS = {
|
|
599
|
-
fold: (root, rest) => foldVerb(root, rest),
|
|
600
|
-
land: (root, rest) => landVerb(root, rest),
|
|
601
|
-
sign: (root, rest) => signVerb(root, rest),
|
|
602
|
-
};
|
|
603
|
-
function main(argv) {
|
|
604
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
605
|
-
const arg = argv[i];
|
|
606
|
-
if (!arg.startsWith('--'))
|
|
607
|
-
continue;
|
|
608
|
-
if (!Object.values(FLAGS).includes(arg)) {
|
|
609
|
-
process.stderr.write(`${selfName()}: REFUSE·flag unknown option ${arg}\n`);
|
|
610
|
-
return EXIT.usage;
|
|
611
|
-
}
|
|
612
|
-
if (arg !== FLAGS.check) {
|
|
613
|
-
if (argv[i + 1] === undefined || argv[i + 1].startsWith('--')) {
|
|
614
|
-
process.stderr.write(`${selfName()}: REFUSE·flag ${arg} needs a value\n`);
|
|
615
|
-
return EXIT.usage;
|
|
616
|
-
}
|
|
617
|
-
i += 1;
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
const verb = argv[0] ?? '';
|
|
621
|
-
const run = verb in VERBS ? VERBS[verb] : undefined;
|
|
622
|
-
const places = positionalsOf(run === undefined ? argv : argv.slice(1)).filter((one) => existsSync(resolve(one)) && lstatSync(resolve(one)).isDirectory());
|
|
623
|
-
if (run !== undefined) {
|
|
624
|
-
const rest = argv.slice(1);
|
|
625
|
-
const roots = positionalIndexes(rest).filter(index => {
|
|
626
|
-
const path = resolve(rest[index]);
|
|
627
|
-
return existsSync(path) && lstatSync(path).isDirectory();
|
|
628
|
-
});
|
|
629
|
-
if (roots.length > 1) {
|
|
630
|
-
process.stderr.write(`${selfName()}: REFUSE·root name one acting directory\n`);
|
|
631
|
-
return EXIT.usage;
|
|
632
|
-
}
|
|
633
|
-
const selected = roots[0];
|
|
634
|
-
const root = resolve(selected === undefined ? '.' : rest[selected]);
|
|
635
|
-
const normalized = selected === undefined ? rest : rest.filter((_, index) => index !== selected);
|
|
636
|
-
return withContentStore(storeOf(root), () => verb === 'fold' && selected !== undefined && !positionalsOf(normalized).some(one => /^#bound(?::|$)/.test(one))
|
|
637
|
-
? foldAt(root, undefined, normalized)
|
|
638
|
-
: run(root, normalized, [verb, ...normalized]), () => standingOf(root).standing);
|
|
639
|
-
}
|
|
640
|
-
const under = argv[0] ?? '';
|
|
641
|
-
if (under && !under.startsWith('-') && places.includes(under)) {
|
|
642
|
-
const root = resolve('.');
|
|
643
|
-
const place = relative(root, resolve(under)).split(sep).join('/');
|
|
644
|
-
return foldAt(root, place ? `${place}/` : undefined, argv);
|
|
645
|
-
}
|
|
646
|
-
process.stderr.write(`${selfName()}: ${helpLines().join(' · ')}\n`);
|
|
647
|
-
return EXIT.usage;
|
|
648
|
-
}
|
|
649
|
-
function printRefusal(error) {
|
|
650
|
-
try {
|
|
651
|
-
const text = readCatalogFile(new URL('../../docs/contracts/refusals.bound', import.meta.url), 'utf8');
|
|
652
|
-
const entry = describeRefusal(error, readRefusalCatalog(text));
|
|
653
|
-
process.stderr.write(JSON.stringify({ profile: 'bound-refusal@1', ...entry, catalog: catalogDigest(text) }) + '\n');
|
|
654
|
-
}
|
|
655
|
-
catch {
|
|
656
|
-
// A missing/invalid catalog cannot supply trustworthy metadata. Keep the
|
|
657
|
-
// failure named instead of recursively failing while formatting a refusal.
|
|
658
|
-
process.stderr.write(JSON.stringify({ profile: 'bound-refusal@1', code: 'catalog/invalid', unmeasured: ['category', 'meaning', 'next', 'catalog'] }) + '\n');
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
// Legacy numeric refusals receive a generic code by exit result, never by parsing
|
|
662
|
-
// a diagnostic. Specific causes retain their own typed code in the error path.
|
|
663
|
-
function finished(code) {
|
|
664
|
-
if (code === EXIT.refuse || code === EXIT.usage)
|
|
665
|
-
printRefusal(new BoundRefusal(code === EXIT.usage ? 'operation/usage' : 'operation/failed', ''));
|
|
666
|
-
process.exitCode = code;
|
|
667
|
-
}
|
|
668
|
-
// The same refusal boundary covers synchronous operations and asynchronous processes.
|
|
669
|
-
const refused = (error) => {
|
|
670
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
671
|
-
process.stderr.write(`${selfName()}: ${message.startsWith('REFUSE·') ? message : `REFUSE·crash ${message}`}\n`);
|
|
672
|
-
printRefusal(error instanceof BoundRefusal ? error : new BoundRefusal('operation/failed', message));
|
|
673
|
-
process.exitCode = EXIT.refuse;
|
|
674
|
-
};
|
|
675
|
-
installActSignalHandler();
|
|
676
|
-
try {
|
|
677
|
-
const ran = main(process.argv.slice(2));
|
|
678
|
-
if (ran instanceof Promise)
|
|
679
|
-
ran.then(finished).catch(refused);
|
|
680
|
-
else
|
|
681
|
-
finished(ran);
|
|
682
|
-
}
|
|
683
|
-
catch (error) {
|
|
684
|
-
refused(error);
|
|
685
|
-
}
|
|
2
|
+
var tt=Object.defineProperty;var $=(e,t)=>tt(e,"name",{value:t,configurable:!0});import{hostOutput as s,hostArguments as nt}from"../host/call-context.js";import{serveNativeCommands as it}from"../host/command-server.js";import{authenticatedStanding as rt}from"../host/admitted-place.js";import{prepareNativeProbe as ot}from"../host/native/probes.js";import{nativeAuthorityCardView as st}from"../host/native/authority-card-view.js";import{prepareNativeReadingIdentity as at,prepareNativeViewIdentity as ct,prepareNativeViewIdentities as lt,declaredReadingIdentityLimits as Fe}from"../host/reading-identity.js";import{nativeHostInstrument as te}from"../host/native-receiver.js";import{ownRoot as X,processOf as Y}from"../observe/runner.js";import{BoundRefusal as O,refusalRecord as dt}from"../host/refusals.js";import{readFileSync as Oe}from"node:fs";import{sha256 as Q}from"../host/hash.js";import{printReleaseApproval as ft}from"./release-result.js";import{inspectReference as ut}from"../host/reference.js";import{exportAuthenticatedReference as pt}from"../host/reference-export.js";import{authenticatedReferenceSelected as mt,openAuthenticatedReference as ht}from"../host/reference-native.js";import{printActResult as gt}from"./act-result.js";import{printStandingResult as wt}from"./standing-result.js";import{withContentStore as Ue}from"../host/content-store.js";import{readOnly as xe,withoutEffects as Ne}from"../host/read-only.js";import{layReleases as yt}from"../host/release.js";import{resolveSources as Et,resolveRequested as $t}from"../host/source-content.js";import{cellsWithReceipts as bt}from"../host/cell-receipts.js";import{library12_renderCells as kt}from"../vendor/runtime.js";import{releasePolicyLines as St}from"../fold/release-policy.js";import{admittedObjects as Ce}from"../host/objects.js";import{objectFold as De,executeComputation as vt}from"../engine/index.js";import{readingEnvironment as Rt}from"../host/reading-context.js";import{verifyBytes as Ft}from"../host/adapters/keys/ed25519.js";import{instrumentDigest as Ot}from"../fold/digests.js";import{library14_authorityAtEpoch as Ut}from"../vendor/runtime.js";import{toposAt as xt,contentAt as Nt}from"../host/selected-topos.js";import{foldObjectsWithWasm as Ct,usesWasmObject as Te}from"../wasm/object.js";import{library14_OBJECT_VIEW as Dt}from"../vendor/runtime.js";import{library10_toposStanding as Tt}from"../vendor/runtime.js";import{library14_wireAt as jt,library14_parse as je}from"../vendor/runtime.js";import{lockStanding as me}from"../fold/keys.js";import{ownStore as It,ownLock as Ie}from"../observe/runner.js";import{signedOwnerLines as oe}from"./owner.js";import{existsSync as _,lstatSync as V,mkdirSync as Ae,writeFileSync as Le}from"node:fs";import{basename as At,dirname as he,join as se,relative as ge,resolve as b,sep as we}from"node:path";import{eraOf as Lt,signaturesOf as ye}from"../fold/digests.js";import{fullDigest as We}from"../host/digest.js";import{library14_canonical as ne}from"../vendor/runtime.js";import{EXTENSION as Wt,LOCK as Be,fieldOf as W,foldClaims as Bt,isWire as Je,selfName as A}from"../fold/claims.js";import{observedClaims as Jt,readerRefusals as qe}from"../fold/observed.js";import{rolesOf as qt}from"../fold/roles.js";import{authorityFor as ae,releaseSigner as Me,rootSigner as Ee,writerFor as $e}from"../fold/signers.js";import{land as ie,ledgerLines as ce,storeOf as w}from"../land/ledger.js";import{lockLines as be,releaseOf as Mt}from"../fold/keys.js";import{signConsentLot as _t}from"../land/sign.js";import{signerFor as Pt,frameSignerFor as Vt}from"../host/signing.js";import{admittedIn as zt,ownLockOf as Gt,tellOwn as Ht}from"../fold/signed.js";import{hasVouchedTree as Kt,landCoordinates as Xt,coordinatesOf as Yt,locationsOf as Qt,vouching as Zt,sourced as en}from"../land/vouched.js";import{observeText as ke}from"../observe/files.js";import{askWhy as tn,unrendered as nn,viewOf as rn}from"../render/view.js";import{openCards as on}from"../render/open.js";import{foldPlace as _e,ownCeilings as Pe,standingOf as z}from"./place.js";import{foldPoints as sn,movedPoints as an}from"../fold/kept.js";import{placesOf as cn,sharedShapes as ln,viewsOf as le}from"../fold/views.js";import{placesIn as dn}from"../fold/places.js";import{isCeiling as Se}from"../fold/configures.js";import{readingsIn as Ve}from"../land/inert.js";import{pass as fn}from"./pass.js";import{installActSignalHandler as un,underTheLock as pn,underTheRegions as mn,underRootAuthority as hn}from"../land/act.js";import{ownerOf as gn,renderInto as wn,signedDemands as yn,targetFile as de}from"./owner.js";import{claimLinesIn as re,entryOf as ve,namedPlaces as Re,positionalIndexes as En,positionalsOf as B,valueOf as N}from"./args.js";import{EXIT as l,FLAGS as g,NAMED_VIEWS as Z,helpLines as ze}from"./names.js";import{accept as $n,signedBatch as Ge}from"./accept.js";import{renderWalk as bn,landWalk as kn,foreignWalkLines as Sn}from"../host/walk.js";import{library13_isWalkHeader as vn}from"../vendor/runtime.js";import{ingressBundles as Rn,ingressReceipts as Fn}from"../host/ports/ingress.js";async function On(e,t){const a=Date.now(),n=w(e),i=re(de(e)),c=ke(de(e));let d,E,r,u=0,f;try{if(!i.length)throw new Error("REFUSE\xB7bootstrap the proposed lock holds no claims");const m=Lt(i),k=i.find(p=>["wire/digest-algorithms","audit/wire/digest-algorithms"].includes(W(p,"scope"))&&W(p,"value")!=="withdraw"),U=W(k??"","value").split("|").filter(Boolean)[0]?.split(":")[0]??"";if(!U)throw new Error("REFUSE\xB7bootstrap the proposed lock names no digest algorithm");if(d=$e(i,"authorize")??"",!d)throw new Error("REFUSE\xB7bootstrap the proposed lock declares no root authorizer");if(E=N(t,g.key)??d,ce(n,d).length)throw new Error("REFUSE\xB7bootstrap the owner ledger already holds claims; the first land happens once");const L=$(p=>{const x=new Set(i.filter(I=>W(I,"scope")===`keys/${d}`&&W(I,"measure")===p&&W(I,"value")!=="withdraw").map(I=>W(I,"value")));if(x.size!==1)throw new Error(`REFUSE\xB7bootstrap root key ${d} must declare one ${p}`);return[...x][0]},"said");if(L("class")!=="authorize")throw new Error("REFUSE\xB7bootstrap the root key must authorize");const y=L("public-key"),S=L("coverage").split("|").filter(Boolean);if(!y||!S.length)throw new Error("REFUSE\xB7bootstrap the root key must declare its public key and coverage");const D=i.filter(p=>!W(p,"sig"));if(D.length){const p=Pt(i,E,N(t,g.signer),N(t,g.keyFile)),x=await _t(D,{epoch:1,by:E,algorithm:m.era},y,m.admitted,p);if(x.kind==="refuse")throw new Error(x.why);let I=0;i.splice(0,i.length,...i.map(R=>W(R,"sig")?R:x.lines[I++]))}const q=ae(i,{...Me(i),id:d,publicKey:y,coverage:S},m.admitted);for(const p of i){const x=q.of(p);if(x.kind!=="admitted")throw new Error(`REFUSE\xB7bootstrap ${W(p,"scope")} is not admitted: ${x.why??x.kind}`);u+=1}Zt(i),en(i),r=We(i.map(p=>p.replace(/ sig="[^"]*"/,"")).sort(),U),f={[d]:{id:d,publicKey:y,coverage:S}}}catch(m){if(m instanceof O)throw m;return s("error",`${A()}: ${m instanceof Error?m.message:String(m)}
|
|
3
|
+
`),l.refuse}return pn(n,"bootstrap",()=>{if(ce(n,d).length||ke(de(e))!==c)return s("error",`${A()}: REFUSE\xB7bootstrap the proposed lock or owner ledger changed before commit
|
|
4
|
+
`),l.refuse;const m=ie(n,d,i);E!==d&&ie(n,E,i);const k=se(n,`${A()}.keys`);Ae(he(k),{recursive:!0}),Le(k,`${JSON.stringify(f,null,2)}
|
|
5
|
+
`);const U=i.filter(S=>/\bsig=/.test(S)),L=U.length-u;ie(n,"land",[ne({scope:"bootstrap",role:"writes",form:"alphabet",measure:"status",value:"present",by:"land",at:`bootstrap:${r}`,about:"the lines this clone was born from: one land per clone, and a second is a fork of the same cell"})]);const y=wn(e,n);s("out",`FACT landed ${m.appended} unique lines from ${i.length} in TARGET \xB7 ${L} of ${U.length} signed lines fail admission by declared authority
|
|
6
|
+
TARGET ${y.standing} claims \xB7 ${y.superseded.length} superseded \xB7 ${Date.now()-a} ms
|
|
7
|
+
`);for(const S of y.superseded)s("out",`SUPERSEDED ${S}
|
|
8
|
+
`);if(!Kt(n)){const S=new Set,D=new Set;for(const I of yn(n)){const R=Qt(W(I,"needs"));for(const P of R.locations)S.add(P);for(const P of R.refused)D.add(P)}const q=new Map,p=qt(n);for(const I of S)for(const[R,P]of Yt(e,I,p))q.set(R,P);const x=Xt(n,q,[],"origin:land");s("out",`FACT vouched \xB7 ${x} sources under ${S.size} locations \xB7 ${D.size} needs refused as globs
|
|
9
|
+
`)}return l.closed})}$(On,"firstLand");function fe(e,t,a){const n=$e(t.standing,"fold"),i=$(c=>`${(c/1e3).toFixed(c<100?2:1)} s`,"seconds");if(s("error",`BEAT fold ${t.key.slice(0,8)} ${t.kept?"kept":"folded"} ${i(a)}${t.beats.kept?` \xB7 ${i(t.beats.kept)} kept`:""}${t.beats.folded?` \xB7 ${i(t.beats.folded)} folded`:""}
|
|
10
|
+
`),n!==void 0){if(!t.kept){const c=an(w(e),sn(w(e),t.standing,t.under,n,t.instrument),t.key),d=c===void 0?"no fold was kept before this one":`${c.gone.length} points gone \xB7 ${c.came.length} came \xB7 ${[...c.gone,...c.came].slice(0,3).map(E=>E.split(" ")[0]).join(" ")||"none"}`;s("error",`KEPT fold ${t.key.slice(0,8)} miss \xB7 ${d}
|
|
11
|
+
`)}ie(w(e),n,[ne({scope:`beat/${t.under??"."}`,role:"writes",form:"interval",measure:"ms",value:`${a}..${a}`,by:n,at:`place:${t.kept?"kept":"folded"}`})])}}$(fe,"beat");async function ee(e,t,a,n=[],i,c,d=!0,E=!1){const[r=a,u,f,...m]=a.split("@");if(r===Z.help)return s("out",`${ze().join(`
|
|
12
|
+
`)}
|
|
13
|
+
`),l.closed;if(r==="authority-card"){if(t||n.length||i||!u||f!==void 0||m.length)throw new O("authority-card/selection","REFUSE\xB7authority-card/selection requires one admitted request scope");const o=await st(e,te(X(),Y("verb")),u);if(o.kind==="refuse")throw new O(o.code,o.diagnostic);return s("out",JSON.stringify(o)+`
|
|
14
|
+
`),l.closed}if(r==="probe"){if(t||n.length||i||!u||m.length||f==="")throw new O("reading-identity/selection","REFUSE\xB7probe requires one local native view");const o=Fe(rt(e)),h=ot({place:e,instrument:te(X(),Y("verb")),view:u,...f?{expectedIdentity:f}:{},port:{coordinate:"port/native-probe",probes:o.probes,responseBytes:o.bytes},counter:{used:new Map}});if(h.kind==="refuse")throw new O(h.code,h.diagnostic);return s("out",JSON.stringify(h)+`
|
|
15
|
+
`),l.closed}if(r==="reading-identities"){if(t||n.length||i||!u||f!==void 0||m.length)throw new O("reading-identity/selection","REFUSE\xB7native view identities require one local place and explicit views");const o=lt({place:e,instrument:te(X(),Y("verb")),views:u.split("+")});if(o.kind==="refuse")throw new O(o.code,o.diagnostic);return s("out",JSON.stringify(o)+`
|
|
16
|
+
`),l.closed}if(r==="reading-identity"&&u!==void 0){if(t||n.length||i||m.length||f==="")throw new O("reading-identity/selection","REFUSE\xB7native view identity requires one local place and a declared selector");const o=ct({place:e,instrument:te(X(),Y("verb")),view:u,...f?{expectedIdentity:f}:{}});if(o.kind==="refuse")throw new O(o.code,o.diagnostic);return s("out",JSON.stringify(f===void 0?{kind:o.kind,view:o.view,identity:o.identity}:o)+`
|
|
17
|
+
`),l.closed}if(r==="reading-identity"){if(t||n.length||i||u!==void 0)throw new O("host/context","REFUSE\xB7reading identity requires one local admitted place");const o=Fe(me(w(e))),h=await at({place:e,instrument:te(X(),Y("verb")),limits:o});if(h.kind==="refuse")throw new O(h.code,h.diagnostic);return s("out",JSON.stringify(h)+`
|
|
18
|
+
`),l.closed}if(!E&&!n.length&&!xe()&&me(w(e)).some(o=>/^reader\/.+\/port$/.test(W(o,"scope"))&&W(o,"role")==="writes"&&W(o,"value")!=="withdraw"))return hn(w(e),"view reader authority",()=>ee(e,t,a,n,i,c,d,!0));if(!be(w(e)).length)return s("error",`${A()}: the owner ledger is empty; land it before rendering a view
|
|
19
|
+
`),l.refuse;if(r==="act"){if(t||n.length)throw Error("REFUSE\xB7act committed identity query only");return gt(e,i),l.closed}if(r==="standing"){if(t||n.length||i||u!==void 0)throw new O("standing/query","REFUSE\xB7standing local committed projection only");return wt(e),l.closed}if(r==="evidence"&&!t&&!n.length&&Rn(w(e)).length){const o=le(me(w(e))).get(r);if(!o||o.shape||!o.regions.some(j=>j.name==="evidence"))throw Error("REFUSE\xB7view foreign evidence requires a declared evidence view");const h=await Sn(e),T=ae(be(w(e)),Ee(e),ye(w(e)).admitted),C=[...new Set(T.admitted.flatMap(j=>ce(w(e),j.id)))].filter(j=>T.of(j).kind==="admitted");for(const j of[...new Set([...C,...Fn(w(e)),...h])])s("out",j+`
|
|
20
|
+
`);return s("out",`FACT authenticated histories \xB7 readings \xB7 no encounters computed
|
|
21
|
+
`),l.closed}const k=Date.now(),U=t?.replace(/\/$/,""),L=Mt(w(e)),y=ae([...L??be(w(e)),...n],L?Me(L):Ee(e),ye(w(e),n).admitted),S=n.filter(o=>y.of(o).kind==="admitted"),D=n.filter(o=>!S.includes(o));if(U&&D.length&&Ht(U,D),r===Z.lines&&(n.length||u===void 0)){const o=z(e,t,S).standing.filter(Je).join(`
|
|
22
|
+
`);return s("out",o?`${o}
|
|
23
|
+
`:""),l.closed}if(n.length){const o=le(z(e,t,S).standing).get(r);if(o&&!o.shape&&o.regions.some(h=>h.name==="cells")){const h=[...oe(w(e)),...S],T=await Ce(e,h);s("out",`TOLD ${n.length} lines folded as if landed \xB7 nothing written
|
|
24
|
+
`);for(const C of kt(De(T.records,T.context)))s("out",C+`
|
|
25
|
+
`);return l.closed}}const q=U?D.filter(o=>zt(e,U,o)):[];!n.length&&!xe()&&yt(w(e),e,z(e,t).standing,w(e));const p=n.length?_e(e,ve(e),t,!1,{standing:z(e,t,S),observed:Jt(e,w(e),{wait:!1}),free:!0}):_e(e,ve(e),t,!0);if(!n.length&&qe().length){for(const o of qe())s("error",`${A()}: ${o}
|
|
26
|
+
`);return l.refuse}if(i&&tn(p,i),r===Z.lines){n.length||fe(e,p,Date.now()-k);const o=p.standing.filter(Je).join(`
|
|
27
|
+
`);if(s("out",o?`${o}
|
|
28
|
+
`:""),u==="1")for(const h of Ve([...p.standing.filter(Se),...Pe(t)],p))s("out",`${h}
|
|
29
|
+
`);return l.closed}const x=le(p.standing),I=[...x.entries()].find(([,o])=>!o.shape&&o.regions.some(h=>h.name==="cells"));if(I&&r===I[0]){const o=oe(w(e)),{objectHistory:h}=await import("../vendor/library14.js"),T=h(o);if(T.kind!=="fact")throw Error(`REFUSE\xB7wire ${T.why}`);if(T.value.objects.length){if(await bt(e,o,v=>s("out",v+`
|
|
30
|
+
`)),d)for(const v of St(p.release))s("out",v+`
|
|
31
|
+
`);return n.length||fe(e,p,Date.now()-k),l.closed}n.length||fe(e,p,Date.now()-k);const C=p.open??[],j=c?C.filter(v=>v.origins.includes(c)):C,F=on(j);return c&&s("out",`KEY ${c}
|
|
32
|
+
`),F.length&&s("out",`${F.join(`
|
|
33
|
+
`)}
|
|
34
|
+
`),l.closed}if(n.length||fe(e,p,Date.now()-k),r==="rank"){const h=(U?[U]:dn(e)).flatMap(T=>ln(Gt(e,T)).map(C=>`${T} ${C}`));if(h.length)return s("error",`${A()}: REFUSE\xB7rank ${h.join(" \xB7 ")}: two views naming the same shape in one place
|
|
35
|
+
`),l.refuse}const R=x.get(r);if(!R)return s("error",`${A()}: no view/${r} is signed; the lock signs ${[...x.keys()].sort().map(o=>`view/${o}`).join(" \xB7 ")||"no view"}
|
|
36
|
+
`),l.usage;const P=nn(p,R);if(P.length)return s("error",`${A()}: REFUSE\xB7view view/${r} asks regions nothing renders: ${P.join(" ")} \xB7 none is the instrument's own and no capsule ${t??"the root"} can run declares it
|
|
37
|
+
`),l.refuse;const G=cn(p.standing,R);if(G.length&&!G.includes(t??""))return s("error",`${A()}: view/${r} writes ${G.map(o=>`${o}${R.shape}`).join(" \xB7 ")}, and nothing of ${t??"this place"}
|
|
38
|
+
`),l.usage;const H=$e(p.standing,"fold");if(H!==void 0&&!n.length){const o=Date.now()-k;ie(w(e),H,[ne({scope:`beat/${t??"."}`,role:"writes",form:"interval",measure:"ms",value:`${o}..${o}`,by:H,at:`place:command-${p.kept?"kept":"folded"}`})])}return $(o=>{const h=rn(o,Number.isFinite(Number(u))&&u!==void 0?{...R,regions:R.regions.map(C=>C.called?{...C,at:Number(u)}:C)}:R);if((nt()??process.argv).includes(g.check)){const C=se(e,t??"",R.shape||""),j=R.shape?ke(C):void 0;if(j!==void 0&&j===h)return s("out",`SAME ${R.shape||`view/${r}`}
|
|
39
|
+
`),l.closed;const v=(j??"").split(`
|
|
40
|
+
`),J=h.split(`
|
|
41
|
+
`),K=v.findIndex((Ze,et)=>Ze!==J[et]),M=K<0?Math.min(v.length,J.length):K,Qe=(K<0?J[M]:v[M])??J[M]??"";return s("out",`DIFFERS ${R.shape||`view/${r}`}${j===void 0?" \xB7 this place holds no such region":` \xB7 line ${M+1} \xB7 ${Qe}`}
|
|
42
|
+
`),l.refuse}if(!R.shape||n.length){if(n.length&&s("out",`TOLD ${n.length} lines folded as if landed \xB7 ${S.length} in the ledger \xB7 ${q.length} in ${U??"the root"}'s own lock${D.length-q.length?` \xB7 ${D.length-q.length} admitted nowhere`:""} \xB7 the batch lands nothing and nothing is written
|
|
43
|
+
`),s("out",h),u==="1")for(const C of Ve(n.length?n.filter(Se):[...o.standing.filter(Se),...Pe(t)],o))s("out",`${C}
|
|
44
|
+
`);return l.closed}const T=se(e,t??"",R.shape);return mn(w(e),[t??""],`view/${r}`,()=>(Ae(he(T),{recursive:!0}),Le(T,h),s("out",`RENDERED ${ge(e,T).split(we).join("/")} \xB7 view/${r} \xB7 ${h.split(`
|
|
45
|
+
`).length-1} lines
|
|
46
|
+
`),l.closed))},"shown")(p)}$(ee,"view");async function Un(e,t){const a=N(t,g.as);if(a!==void 0){const i=B(t);if(a!=="reference"||i.length!==1||t.includes(g.check))throw new O("reference-export/usage","REFUSE\xB7reference-export usage: sign --as reference <source-url>");const c=await pt(e,i[0],{key:N(t,g.key),keyFile:N(t,g.keyFile),signer:N(t,g.signer)});return s("out",JSON.stringify(c)+`
|
|
47
|
+
`),l.closed}const n=await Ge(e,t,B(t));if(n.kind==="exit")return n.code;if(n.kind==="once")return s("error",`ONCE ${n.proposed.length} lines \xB7 every one already landed: nothing to sign
|
|
48
|
+
`),l.closed;for(const i of Re(t))s("out",`# place ${i}
|
|
49
|
+
`);for(const i of n.signed)s("out",`${i}
|
|
50
|
+
`);return s("error",`SIGNED ${n.signed.length} lines \xB7 epoch ${n.epoch}${Re(t).length?` \xB7 own lines for ${Re(t).join(", ")}`:""} \xB7 they land together, before the lock moves
|
|
51
|
+
`),l.closed}$(Un,"signVerb");async function xn(e,t){const a=b(de(e)),n=B(t).filter(i=>{const c=b(i);return _(c)&&!V(c).isDirectory()&&c!==a});if(!n.length){const i=w(e);return _(se(i,"ledger"))&&ce(i,gn(i)).length?(s("error",`${A()}: REFUSE\xB7bootstrap the owner ledger already holds claims; provide an explicit signed batch to change it
|
|
52
|
+
`),l.refuse):On(e,t)}try{const i=n.flatMap(re);if(i.some(vn)){for(const c of await kn(e,i,N(t,g.key),N(t,g.keyFile),N(t,g.signer)))s("out",c+`
|
|
53
|
+
`);return l.closed}return await $n(e,t)}catch(i){if(i instanceof O)throw i;const c=i instanceof Error?i.message:String(i);return s("error",`${A()}: ${c.startsWith("REFUSE\xB7")?c:`REFUSE\xB7crash ${c}`}
|
|
54
|
+
`),l.refuse}}$(xn,"landVerb");function Nn(e){const t=re(e),a=Bt(t),i=a.standing.flatMap(d=>{const E=je(d);return E.kind==="fact"?[E.value.fields]:[]}).some(d=>d.scope?.startsWith("region/")&&d.measure==="reads");if(i&&a.forks.length)throw Error("REFUSE\xB7topos incompatible live claims in declared fold");const c=i?Tt(a.standing):void 0;if(c!==void 0){const E=jt(Ie().flatMap(r=>{const u=je(r);return u.kind==="fact"?[u.value.fields]:[]}),Number.MAX_SAFE_INTEGER)?.digests.values().next().value;if(!E)throw Error("REFUSE\xB7topos instrument names no digest algorithm");s("out",c.split(`
|
|
55
|
+
`).filter(Boolean).map(r=>"TOPOS "+r).join(`
|
|
56
|
+
`)+`
|
|
57
|
+
`),s("out","PIN "+We([c],E)+`
|
|
58
|
+
`)}for(const d of a.standing)s("out",`${d}
|
|
59
|
+
`);for(const d of a.forks)s("out",`FORK ${d.key}${d.state?` \xB7 ${d.state}`:""}
|
|
60
|
+
`);return s("out",`FACT ${a.standing.length} standing \xB7 ${a.forks.length} forks \xB7 ${At(e)} \xB7 readings \xB7 no encounters computed
|
|
61
|
+
`),l.closed}$(Nn,"foldFile");function Cn(e,t){const a=B(t).filter(r=>/^#(?:bound|topos-reference)(?::|$)/.test(r));if(a.length){if(a.length!==1||B(t).length!==1||t.some(r=>r.startsWith("--")))throw Error("REFUSE\xB7reference name one reference without view, check or signing options");if(mt(z(e).standing)){if(a[0].startsWith("#topos-reference:"))throw Error("REFUSE\xB7reference located profile is inspection only; authenticated opening requires its declared carrier");return ht(e,a[0]).then(r=>{s("out",`SOURCE ${r.reference.source}
|
|
62
|
+
`);for(const u of r.semanticStanding.split(`
|
|
63
|
+
`).filter(Boolean))s("out",`TOPOS ${u}
|
|
64
|
+
`);for(const u of r.readings)s("out","CELL "+JSON.stringify(u)+`
|
|
65
|
+
`);return s("out",`AUTHENTICATED standing ${r.semanticIdentity} \xB7 authority ${r.authorityContextIdentity} \xB7 no effects committed
|
|
66
|
+
`),l.closed})}return ut(a[0],z(e).standing).then(r=>{const u="source"in r.reference?r.reference.source:r.reference.location;if(u&&s("out",`SOURCE ${u}
|
|
67
|
+
`),"needs"in r)return s("out",`NEEDS ${r.needs} \xB7 unauthenticated inspection
|
|
68
|
+
`),l.closed;for(const f of r.lines)s("out",`TOPOS ${f}
|
|
69
|
+
`);return s("out",`INSPECT standing sha256:${r.reference.digest} \xB7 blob ${r.reference.blob} \xB7 no encounters computed \xB7 unauthenticated
|
|
70
|
+
`),l.closed})}const n=B(t).filter(r=>_(b(r))&&!V(b(r)).isDirectory()&&r.endsWith(Wt)),i=B(t).filter(r=>_(b(r))&&V(b(r)).isDirectory());if(n.length===1&&!i.length&&N(t,g.as)===void 0){const r=b(n[0]);return!r.endsWith(`/${Be}`)&&r!==Be?Nn(r):ue(he(r),void 0,t)}const c=i[0],d=n.length?e:b("."),E=c?ge(d,b(c)).split(we).join("/"):"";return ue(d,E?`${E}/`:void 0,t)}$(Cn,"foldVerb");async function ue(e,t,a){return Ue(w(e),()=>Dn(e,t,a),()=>z(e,t).standing)}$(ue,"foldAt");async function Dn(e,t,a){const n=N(a,g.as),i=n!==void 0&&B(a).some(c=>_(b(c))&&!V(b(c)).isDirectory());if(["reading-identity","reading-identities","probe","authority-card"].includes(n?.split("@")[0]??"")&&(i||t||a.includes(g.check)))throw new O("reading-identity/selection","REFUSE\xB7reading-identity/selection preparation does not sign batches or check rendered output");return["reading-identity","reading-identities","probe","authority-card"].includes(n?.split("@")[0]??"")||n==="release"||n?.split("@")[0]==="act"||n===Z.help||i||a.includes(g.check)?He(e,t,a):$t(c=>Et(z(e,t).standing,[c]),()=>He(e,t,a))}$(Dn,"foldRequested");async function He(e,t,a){const n=N(a,g.as);if(n==="release"){const f=B(a).filter(m=>!(_(b(m))&&V(b(m)).isDirectory()));if(f.length!==1||a.includes(g.check))throw Error("REFUSE\xB7release name one approval file; check does not authorize delivery");return Ne(()=>(ft(t?b(e,t):e,b(f[0])),l.closed))}const i=B(a).filter(f=>_(b(f))&&!V(b(f)).isDirectory()),c=n===void 0&&a.includes(g.check);if(n?.split("@")[0]==="walk"){if(a.includes(g.check))throw Error("REFUSE\xB7walk check does not initiate or sign an exchange");if(t||i.length>1)throw Error("REFUSE\xB7walk one place and one authenticated peer inventory per fold");const f=n.split("@")[1];if(f!==void 0&&(!/^(0|[1-9][0-9]*)$/.test(f)||!Number.isSafeInteger(Number(f))))throw Error("REFUSE\xB7walk invalid resolution");const m=i.length?re(i[0]):[];for(const k of await bn(e,f===void 0?void 0:Number(f),m,N(a,g.key),N(a,g.keyFile),N(a,g.signer)))s("out",k+`
|
|
71
|
+
`);return l.closed}if(n===Dt||n==="computation"){const f=B(a).filter(y=>_(b(y))&&!V(b(y)).isDirectory());if(f.length>1)throw Error("REFUSE\xB7object one history snapshot per fold");const m=f.length?re(f[0]):oe(w(e)),k=await Ce(e,m,y=>(n==="computation"?process.stderr:process.stdout).write(y+`
|
|
72
|
+
`)),U=$(async()=>{if(Te(k.configuration)){const y=new AbortController,S=$(()=>y.abort(),"interrupt");process.once("SIGINT",S);try{return await Ct(e,k.records,k.context,k.configuration,y.signal)}finally{process.removeListener("SIGINT",S)}}return De(k.records,k.context)},"project");if(n==="computation"){if(t||a.includes(g.check))throw new O("computation/context","REFUSE\xB7computation/context");const y=$(F=>{const v=k.configuration.filter(J=>J.scope===F&&J.value!=="withdraw");if(v.length!==1)throw new O("computation/context","REFUSE\xB7computation/context");return v[0].value},"one");if(y("view/computation")!=="computation@1")throw new O("computation/context","REFUSE\xB7computation/context");const S=$(F=>{const v=/^0\.\.([1-9][0-9]*)$/.exec(y(F)),J=Number(v?.[1]);if(!v||!Number.isSafeInteger(J))throw new O("computation/budget","REFUSE\xB7computation/budget");return J},"resource"),D=N(a,g.key),q=ye(w(e)),p=ae(m,Ee(e),q.admitted),x=p.admitted.find(F=>F.id===D),I=Math.max(...m.map(F=>Number(W(F,"epoch")||0)));if(!D||!x||Ut({scope:"computation",by:D},x,I,"computation","authority").kind!=="admitted")throw new O("computation/authority","REFUSE\xB7computation/authority");const R=new TextEncoder().encode(m.join(`
|
|
73
|
+
`)+`
|
|
74
|
+
`),P=Q(k.configuration.map(F=>ne(F)).join(`
|
|
75
|
+
`)),G=new Map;for(const F of new Set(k.records.filter(v=>v.record==="cell").map(v=>v.fields.topos))){G.set("form/"+F,F);const v=xt(F),J=v.parts.find(K=>K.scope==="wire/topos/context-view")?.value;for(const K of v.parts.filter(M=>M.kind==="check"&&M.view===J))for(const M of(K.restsOn??"").split("|").filter(Boolean))Nt(M),G.set("form-module/"+M,M)}const H=Ot(It(),Y("verb"),Ie(),X()),pe=Te(k.configuration)?["manifest.json","runtime.js","runtime.wasm","guest.js"].map(F=>[F,Q(Oe(new URL("../../assets/wasm/"+F,import.meta.url)))]):[],o=pe.length?Q(JSON.stringify([H,pe])):H,h=Vt(k.configuration.map(F=>ne(F)),D,N(a,g.signer),N(a,g.keyFile)),T={maxBytes:S("computation/bytes"),timeoutMs:S("computation/milliseconds")},C={contract:y("computation/contract"),numericPolicy:y("computation/numeric-policy"),reading:{instrument:H,implementation:o,policy:P,inputs:[...G],environment:Rt(Q)},keyId:D,algorithm:q.era},j=await vt(C,R,{digest:Q,evaluate:$(async()=>new TextEncoder().encode(JSON.stringify(await U())+`
|
|
76
|
+
`),"evaluate"),sign:h,verify:$(async(F,v,J)=>v.keyId===D&&Ft(F,x.publicKey,v.signature,[J]),"verify")},T);return s("out",JSON.stringify({profile:"bound-computation-delivery@1",context:C,input:new TextDecoder().decode(R),statement:j.statement,output:new TextDecoder().decode(j.output)})+`
|
|
77
|
+
`),l.closed}const L=await U();for(const y of L)s("out","CELL "+JSON.stringify(y)+`
|
|
78
|
+
`);return s("out",`FACT object fold ${L.length} cells
|
|
79
|
+
`),l.closed}const d=N(a,g.key);if(n===void 0){const f=await fn(e,ve(e),t,a.includes(g.check));if(c||f!==0)return f;const m=oe(w(e)),{objectHistory:k}=await import("../vendor/library14.js"),U=k(m);if(U.kind!=="fact")throw Error(`REFUSE\xB7wire ${U.why}`);if(U.value.objects.length){const L=[...le(m).values()].find(y=>!y.shape&&y.regions.some(S=>S.name==="cells"));if(!L)throw Error("REFUSE\xB7view object cells require a signed cells view");return ee(e,t,L.name,[],void 0,void 0,!1)}return f}const E=i,r=B(a).find(f=>f!==t?.replace(/\/$/,"")&&!f.startsWith("-")&&!(_(b(f))&&V(b(f)).isDirectory()));if(n==="act"){if(B(a).length!==1)throw Error("REFUSE\xB7act name one committed identity");return ee(e,t,n,[],r)}if((n==="why"||n===Z.because||n.split("@")[0]==="why")&&r!==void 0)return ee(e,t,n===Z.because?"why":n,[],r,d);if(!E.length)return ee(e,t,n,[],void 0,d);const u=await Ge(e,a,E);return u.kind==="exit"?u.code:(u.kind==="once"&&s("out",`ONCE ${u.proposed.length} lines \xB7 every one already landed: the view folds the tree as it stands
|
|
80
|
+
`),Ne(()=>ee(e,t,n,u.kind==="signed"?u.signed:u.proposed,void 0,d)))}$(He,"foldResolved");const Ke={fold:$((e,t)=>Cn(e,t),"fold"),land:$((e,t)=>xn(e,t),"land"),sign:$((e,t)=>Un(e,t),"sign")};function Tn(e){for(let c=0;c<e.length;c+=1){const d=e[c];if(d.startsWith("--")){if(!Object.values(g).includes(d))return s("error",`${A()}: REFUSE\xB7flag unknown option ${d}
|
|
81
|
+
`),l.usage;if(d!==g.check){if(e[c+1]===void 0||e[c+1].startsWith("--"))return s("error",`${A()}: REFUSE\xB7flag ${d} needs a value
|
|
82
|
+
`),l.usage;c+=1}}}const t=e[0]??"",a=t in Ke?Ke[t]:void 0,n=B(a===void 0?e:e.slice(1)).filter(c=>_(b(c))&&V(b(c)).isDirectory());if(a!==void 0){const c=e.slice(1),d=En(c).filter(f=>{const m=b(c[f]);return _(m)&&V(m).isDirectory()});if(d.length>1)return s("error",`${A()}: REFUSE\xB7root name one acting directory
|
|
83
|
+
`),l.usage;const E=d[0],r=b(E===void 0?".":c[E]),u=E===void 0?c:c.filter((f,m)=>m!==E);return Ue(w(r),()=>t==="fold"&&E!==void 0&&!B(u).some(f=>/^#bound(?::|$)/.test(f))?ue(r,void 0,u):a(r,u,[t,...u]),()=>z(r).standing)}const i=e[0]??"";if(i&&!i.startsWith("-")&&n.includes(i)){const c=b("."),d=ge(c,b(i)).split(we).join("/");return ue(c,d?`${d}/`:void 0,e)}return s("error",`${A()}: ${ze().join(" \xB7 ")}
|
|
84
|
+
`),l.usage}$(Tn,"main");function Xe(e){let t="";try{t=Oe(new URL("../../docs/contracts/refusals.bound",import.meta.url),"utf8")}catch{}s("error",JSON.stringify(dt(e,t,Q))+`
|
|
85
|
+
`)}$(Xe,"printRefusal");function jn(e){return(e===l.refuse||e===l.usage)&&Xe(new O(e===l.usage?"operation/usage":"operation/failed","")),e}$(jn,"completed");async function Ye(e){try{return jn(await Tn(e))}catch(t){const a=t instanceof Error?t.message:String(t);return s("error",`${A()}: ${a.startsWith("REFUSE\xB7")?a:`REFUSE\xB7crash ${a}`}
|
|
86
|
+
`),Xe(t instanceof O?t:new O("operation/failed",a)),l.refuse}}$(Ye,"runNativeCommand"),process.send&&process.argv.length===2?it(Ye):(un(),Ye(process.argv.slice(2)).then(e=>{process.exitCode=e}));
|