@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
|
@@ -1,50 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { capsuleOffers, providerInputs, providerInputRegions, capsuleDescriptor, assertCapsuleDescriptor } from '@lapxo/topos/standing';
|
|
3
|
-
import { fullDigest } from "./digest.js";
|
|
4
|
-
import { wireAt, parse } from '@lapxo/topos/wire';
|
|
5
|
-
import { selectedTopoi, toposAt } from "./selected-topos.js";
|
|
6
|
-
import { canonical } from '@lapxo/topos/wire';
|
|
7
|
-
import { fieldOf } from "../fold/claims.js";
|
|
8
|
-
import { ownLock } from "../observe/runner.js";
|
|
9
|
-
import { archiveCoordinate } from "./archive.js";
|
|
10
|
-
/** Only explicit capsule offers request execution. Forms/classes/views do not need an executable alias. */
|
|
11
|
-
export function selectedCapsules(pins, resolve = capsuleAt, select = toposAt, host = ownLock()) {
|
|
12
|
-
return selectedTopoi(pins, select).flatMap(({ digest, topos }) => capsuleOffers(topos).map(offer => {
|
|
13
|
-
const load = () => {
|
|
14
|
-
const projections = host.filter(line => fieldOf(line, 'scope').startsWith('dep/') && fieldOf(line, 'role') === 'writes' && fieldOf(line, 'value') === offer.value);
|
|
15
|
-
if (!projections.length || projections.some(line => !fieldOf(line, 'shape')))
|
|
16
|
-
throw Error(`REFUSE·pin ${digest} capsule ${offer.value} needs one host projection`);
|
|
17
|
-
const entries = [...new Set(projections.map(line => archiveCoordinate(fieldOf(line, 'shape'))))];
|
|
18
|
-
if (entries.length !== 1)
|
|
19
|
-
throw Error(`REFUSE·pin ${digest} capsule ${offer.value} has conflicting host projections`);
|
|
20
|
-
const loaded = resolve(offer.value, entries[0]);
|
|
21
|
-
if (loaded === undefined)
|
|
22
|
-
throw Error(`REFUSE·pin ${digest} · ${offer.scope} · offered capsule ${offer.value} unavailable`);
|
|
23
|
-
return { capsule: loaded, offer: canonical({ ...offer, shape: entries[0] }) };
|
|
24
|
-
};
|
|
25
|
-
const descriptor = capsuleDescriptor(topos, offer.scope ?? '');
|
|
26
|
-
const loaded = descriptor === undefined ? load() : undefined;
|
|
27
|
-
const supplied = loaded === undefined ? {
|
|
28
|
-
digest: offer.value, selection: `${digest} ${offer.scope}`, ...descriptor, ask: (requests, reader) => {
|
|
29
|
-
if (!requests.length)
|
|
30
|
-
return [];
|
|
31
|
-
const actual = load();
|
|
32
|
-
assertCapsuleDescriptor(descriptor.lines, actual.capsule.lines);
|
|
33
|
-
return actual.capsule.ask(requests, reader);
|
|
34
|
-
},
|
|
35
|
-
} : { ...loaded.capsule, selection: `${digest} ${offer.scope}` };
|
|
36
|
-
const capsule = { ...supplied, selectedWorld: { standing: topos, offer: offer.scope ?? '' } };
|
|
37
|
-
const projected = loaded?.offer ?? canonical(offer);
|
|
38
|
-
if (!providerInputRegions(topos, offer.scope ?? '').length)
|
|
39
|
-
return { capsule, offer: projected };
|
|
40
|
-
const fields = ownLock().flatMap(line => { const p = parse(line); return p.kind === 'fact' ? [p.value.fields] : []; });
|
|
41
|
-
const wire = wireAt(fields, Number.MAX_SAFE_INTEGER), algorithm = wire && [...wire.digests][0];
|
|
42
|
-
if (!algorithm)
|
|
43
|
-
throw Error('REFUSE·input instrument has no admitted digest algorithm');
|
|
44
|
-
const selected = { ...capsule, selection: `${digest} ${offer.scope}`, ask: (requests, reader) => capsule.ask(requests.map(request => {
|
|
45
|
-
const provider = providerInputs(topos, digest, offer.scope ?? '', offer.value, request.region ?? '', bytes => fullDigest(bytes, algorithm));
|
|
46
|
-
return provider === undefined ? request : { ...request, provider };
|
|
47
|
-
}), reader) };
|
|
48
|
-
return { capsule: selected, offer: projected };
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
1
|
+
var R=Object.defineProperty;var n=(l,c)=>R(l,"name",{value:c,configurable:!0});import{capsuleAt as k}from"./capsule.js";import{library10_capsuleOffers as A,library10_providerInputs as S,library10_providerInputRegions as D,library10_capsuleDescriptor as F,library10_assertCapsuleDescriptor as I}from"../vendor/runtime.js";import{fullDigest as j}from"./digest.js";import{library14_wireAt as C,library14_parse as U}from"../vendor/runtime.js";import{selectedTopoi as M,toposAt as O}from"./selected-topos.js";import{library14_canonical as $}from"../vendor/runtime.js";import{fieldOf as p}from"../fold/claims.js";import{ownLock as b}from"../observe/runner.js";import{archiveCoordinate as N}from"./archive.js";function Q(l,c=k,w=O,_=b()){return M(l,w).flatMap(({digest:o,topos:i})=>A(i).map(e=>{const h=n(()=>{const r=_.filter(t=>p(t,"scope").startsWith("dep/")&&p(t,"role")==="writes"&&p(t,"value")===e.value);if(!r.length||r.some(t=>!p(t,"shape")))throw Error(`REFUSE\xB7pin ${o} capsule ${e.value} needs one host projection`);const s=[...new Set(r.map(t=>N(p(t,"shape"))))];if(s.length!==1)throw Error(`REFUSE\xB7pin ${o} capsule ${e.value} has conflicting host projections`);const a=c(e.value,s[0]);if(a===void 0)throw Error(`REFUSE\xB7pin ${o} \xB7 ${e.scope} \xB7 offered capsule ${e.value} unavailable`);return{capsule:a,offer:$({...e,shape:s[0]})}},"load"),u=F(i,e.scope??""),d=u===void 0?h():void 0,m={...d===void 0?{digest:e.value,selection:`${o} ${e.scope}`,...u,ask:n((r,s)=>{if(!r.length)return[];const a=h();return I(u.lines,a.capsule.lines),a.capsule.ask(r,s)},"ask")}:{...d.capsule,selection:`${o} ${e.scope}`},selectedWorld:{standing:i,offer:e.scope??""}},v=d?.offer??$(e);if(!D(i,e.scope??"").length)return{capsule:m,offer:v};const g=b().flatMap(r=>{const s=U(r);return s.kind==="fact"?[s.value.fields]:[]}),f=C(g,Number.MAX_SAFE_INTEGER),E=f&&[...f.digests][0];if(!E)throw Error("REFUSE\xB7input instrument has no admitted digest algorithm");return{capsule:{...m,selection:`${o} ${e.scope}`,ask:n((r,s)=>m.ask(r.map(a=>{const t=S(i,o,e.scope??"",e.value,a.region??"",y=>j(y,E));return t===void 0?a:{...a,provider:t}}),s),"ask")},offer:v}}))}n(Q,"selectedCapsules");export{Q as selectedCapsules};
|
|
@@ -1,80 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { readStanding } from '@lapxo/topos/standing';
|
|
3
|
-
import { parse, wireAt, fromLine } from '@lapxo/topos/wire';
|
|
4
|
-
import { fieldOf } from "../fold/claims.js";
|
|
5
|
-
import { moduleClosure } from "./native/module-closure.js";
|
|
6
|
-
import { sha256, isSha256 } from "./hash.js";
|
|
7
|
-
/** Local grammar is sufficient for locally declared records. Resolve selected
|
|
8
|
-
* contracts only when a reader is missing; a local refusal remains a refusal. */
|
|
9
|
-
export function admittedLine(line, local, epoch, pins, resolve = toposAt) {
|
|
10
|
-
const own = wireAt(local, epoch);
|
|
11
|
-
// A signature era alone is not a configuration grammar. An absent list
|
|
12
|
-
// must be supplied by the selected contract; an explicit local list remains
|
|
13
|
-
// authoritative and may refuse a field without opening unrelated content.
|
|
14
|
-
if (own && ['fields', 'required', 'roles', 'forms', 'at-classes'].every(name => own.lists.has(name))) {
|
|
15
|
-
const got = fromLine(line, own);
|
|
16
|
-
const needsObject = fieldOf(line, 'type') !== '' && !own.object;
|
|
17
|
-
if (got.kind === 'fact' || (got.kind === 'refuse' && !needsObject))
|
|
18
|
-
return got;
|
|
19
|
-
}
|
|
20
|
-
return fromLine(line, selectedWireAt(local, epoch, pins, resolve));
|
|
21
|
-
}
|
|
22
|
-
/** Resolve content using the instrument wire's admitted digest algorithms. No transport interpretation. */
|
|
23
|
-
export function toposAt(digest, store) {
|
|
24
|
-
const topos = readStanding(Buffer.from(contentAt(digest, store)).toString('utf8'));
|
|
25
|
-
return topos;
|
|
26
|
-
}
|
|
27
|
-
export function contentAt(digest, store) {
|
|
28
|
-
return verifiedContent(digest, store).bytes;
|
|
29
|
-
}
|
|
30
|
-
/** The declared module runs from the store that supplied its verified bytes. No copy or live-checkout fallback. */
|
|
31
|
-
export function contextModuleAt(digest, store, dependencies) {
|
|
32
|
-
if (dependencies !== undefined) {
|
|
33
|
-
if (!isSha256(digest) || !dependencies.includes(digest) || dependencies.some(pin => !isSha256(pin)))
|
|
34
|
-
throw Error('REFUSE·context module closure requires declared SHA-256 members');
|
|
35
|
-
const pins = [...new Set(dependencies)].sort(), members = new Map(pins.map(pin => [pin.slice(pin.indexOf(':') + 1), { digest: pin, source: new TextDecoder('utf-8', { fatal: true }).decode(contentAt(pin, store)) }]));
|
|
36
|
-
moduleClosure({ identity: sha256(JSON.stringify(pins)), entry: digest.slice(digest.indexOf(':') + 1), members }, () => undefined);
|
|
37
|
-
}
|
|
38
|
-
return verifiedContent(digest, store).path;
|
|
39
|
-
}
|
|
40
|
-
/** Selection verifies standing identity. Requested capabilities verify their artifact bytes separately. */
|
|
41
|
-
export function selectedTopoi(pins, resolve = toposAt) {
|
|
42
|
-
return [...new Set(pins.map(pin => fieldOf(pin, 'value')))].map(digest => ({ digest, topos: resolve(digest) }));
|
|
43
|
-
}
|
|
44
|
-
/** Read a declared wire list without copying a world's claims or executing its offers.
|
|
45
|
-
* Independent declarations must agree; selection order cannot choose a contract.
|
|
46
|
-
*/
|
|
47
|
-
export function selectedWireList(local, epoch, pins, list, resolve = toposAt) {
|
|
48
|
-
const records = local.flatMap(line => { const got = parse(line); return got.kind === 'fact' ? [got.value.fields] : []; });
|
|
49
|
-
const contracts = [{ name: 'place', wire: wireAt(records, epoch) }, ...selectedTopoi(pins, resolve).map(({ digest, topos }) => ({ name: digest, wire: wireAt(topos.parts, Number.MAX_SAFE_INTEGER) }))]
|
|
50
|
-
.flatMap(({ name, wire }) => { const words = wire?.lists.get(list); return words === undefined ? [] : [{ name, words: [...words] }]; });
|
|
51
|
-
if (!contracts.length)
|
|
52
|
-
throw Error(`REFUSE·wire wire/${list} has no declared contract in the place or its selected topoi`);
|
|
53
|
-
const first = contracts[0];
|
|
54
|
-
if (contracts.some(({ words }) => words.length !== first.words.length || words.some(word => !first.words.includes(word))))
|
|
55
|
-
throw Error(`REFUSE·wire wire/${list} has conflicting contracts · ${contracts.map(one => one.name).join(' · ')}`);
|
|
56
|
-
return first.words;
|
|
57
|
-
}
|
|
58
|
-
/** Complete an admission snapshot from the selected standing. Local declarations
|
|
59
|
-
* govern their own lists; independent selected contracts cannot choose by order. */
|
|
60
|
-
export function selectedWireAt(local, epoch, pins, resolve = toposAt) {
|
|
61
|
-
const own = wireAt(local, epoch);
|
|
62
|
-
const worlds = selectedTopoi(pins, resolve).map(({ digest, topos }) => ({ digest, parts: topos.parts, wire: wireAt(topos.parts, Number.MAX_SAFE_INTEGER) }));
|
|
63
|
-
const key = (scope) => scope.startsWith('wire/') ? scope.slice(5) : scope.startsWith('audit/wire/') ? scope.slice(11) : undefined;
|
|
64
|
-
const declared = new Set(local.filter(f => Number(f.epoch ?? 0) <= epoch).map(f => key(f.scope ?? '')).filter((k) => k !== undefined));
|
|
65
|
-
const selected = new Map();
|
|
66
|
-
for (const world of worlds)
|
|
67
|
-
for (const f of world.parts) {
|
|
68
|
-
const name = key(f.scope ?? '');
|
|
69
|
-
if (name === undefined || declared.has(name))
|
|
70
|
-
continue;
|
|
71
|
-
const list = world.wire?.lists.get(name);
|
|
72
|
-
const value = list ? [...list].sort().join('|') : f.value ?? '';
|
|
73
|
-
const previous = selected.get(name);
|
|
74
|
-
if (previous && previous.value !== value)
|
|
75
|
-
throw Error(`REFUSE·wire wire/${name} has conflicting selected contracts · ${previous.digest} · ${world.digest}`);
|
|
76
|
-
if (!previous)
|
|
77
|
-
selected.set(name, { value, fields: f, digest: world.digest });
|
|
78
|
-
}
|
|
79
|
-
return selected.size ? wireAt([...selected.values()].map(one => one.fields).concat(local), epoch) : own;
|
|
80
|
-
}
|
|
1
|
+
var b=Object.defineProperty;var a=(t,r)=>b(t,"name",{value:r,configurable:!0});import{verifiedContent as S}from"./content-store.js";import{library10_readStanding as O}from"../vendor/runtime.js";import{library14_parse as F,library14_wireAt as m,library14_fromLine as g}from"../vendor/runtime.js";import{fieldOf as x}from"../fold/claims.js";import{moduleClosure as M}from"./native/module-closure.js";import{sha256 as N,isSha256 as y}from"./hash.js";function J(t,r,o,s,f=p){const n=m(r,o);if(n&&["fields","required","roles","forms","at-classes"].every(i=>n.lists.has(i))){const i=g(t,n),u=x(t,"type")!==""&&!n.object;if(i.kind==="fact"||i.kind==="refuse"&&!u)return i}return g(t,_(r,o,s,f))}a(J,"admittedLine");function p(t,r){return O(Buffer.from(v(t,r)).toString("utf8"))}a(p,"toposAt");function v(t,r){return S(t,r).bytes}a(v,"contentAt");function R(t,r,o){if(!Array.isArray(o)||!y(t)||!o.includes(t)||o.some(n=>!y(n)))throw Error("REFUSE\xB7context module closure requires declared SHA-256 members");const s=[...new Set(o)].sort(),f=new Map(s.map(n=>[n.slice(n.indexOf(":")+1),{digest:n,source:new TextDecoder("utf-8",{fatal:!0}).decode(v(n,r))}]));return M({identity:N(JSON.stringify(s)),entry:t.slice(t.indexOf(":")+1),members:f},()=>{},{esmOnly:!0}),S(t,r).path}a(R,"contextModuleAt");function q(t){const r=new Map;return{topos:a(o=>{const s=p(o,t);for(const f of s.parts.filter(n=>n.kind==="check"&&n.value)){const n=[...new Set((f.restsOn??"").split("|").filter(Boolean))].sort(),i=r.get(f.value);if(i&&JSON.stringify(i)!==JSON.stringify(n))throw Error("REFUSE\xB7context module has conflicting declared closures");r.set(f.value,n)}return s},"topos"),module:a(o=>{const s=r.get(o);if(s===void 0)throw Error("REFUSE\xB7context module has no declared closure");return R(o,t,s)},"module")}}a(q,"contextProviderServices");function A(t,r=p){return[...new Set(t.map(o=>x(o,"value")))].map(o=>({digest:o,topos:r(o)}))}a(A,"selectedTopoi");function B(t,r,o,s,f=p){const n=t.flatMap(c=>{const e=F(c);return e.kind==="fact"?[e.value.fields]:[]}),i=[{name:"place",wire:m(n,r)},...A(o,f).map(({digest:c,topos:e})=>({name:c,wire:m(e.parts,Number.MAX_SAFE_INTEGER)}))].flatMap(({name:c,wire:e})=>{const d=e?.lists.get(s);return d===void 0?[]:[{name:c,words:[...d]}]});if(!i.length)throw Error(`REFUSE\xB7wire wire/${s} has no declared contract in the place or its selected topoi`);const u=i[0];if(i.some(({words:c})=>c.length!==u.words.length||c.some(e=>!u.words.includes(e))))throw Error(`REFUSE\xB7wire wire/${s} has conflicting contracts \xB7 ${i.map(c=>c.name).join(" \xB7 ")}`);return u.words}a(B,"selectedWireList");function _(t,r,o,s=p){const f=m(t,r),n=A(o,s).map(({digest:e,topos:d})=>({digest:e,parts:d.parts,wire:m(d.parts,Number.MAX_SAFE_INTEGER)})),i=a(e=>e.startsWith("wire/")?e.slice(5):e.startsWith("audit/wire/")?e.slice(11):void 0,"key"),u=new Set(t.filter(e=>Number(e.epoch??0)<=r).map(e=>i(e.scope??"")).filter(e=>e!==void 0)),c=new Map;for(const e of n)for(const d of e.parts){const l=i(d.scope??"");if(l===void 0||u.has(l))continue;const E=e.wire?.lists.get(l),h=E?[...E].sort().join("|"):d.value??"",w=c.get(l);if(w&&w.value!==h)throw Error(`REFUSE\xB7wire wire/${l} has conflicting selected contracts \xB7 ${w.digest} \xB7 ${e.digest}`);w||c.set(l,{value:h,fields:d,digest:e.digest})}return c.size?m([...c.values()].map(e=>e.fields).concat(t),r):f}a(_,"selectedWireAt");export{J as admittedLine,v as contentAt,R as contextModuleAt,q as contextProviderServices,A as selectedTopoi,_ as selectedWireAt,B as selectedWireList,p as toposAt};
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { fieldOf } from "../fold/claims.js";
|
|
3
|
-
/** Pure signature vocabulary; no instrument discovery for diagnostics. */
|
|
4
|
-
export function signatureEraOf(standing) {
|
|
5
|
-
const said = wireLine(standing, 'signature-algorithms');
|
|
6
|
-
const admitted = (said === undefined ? [] : fieldOf(said, 'value').split('|')).filter(Boolean);
|
|
7
|
-
const current = wireLine(standing, 'era');
|
|
8
|
-
const era = (current === undefined ? undefined : admitted.find((one) => one.endsWith(`:${fieldOf(current, 'value')}`))) ?? admitted.find((one) => one.includes(':'));
|
|
9
|
-
if (era === undefined)
|
|
10
|
-
throw new Error(`REFUSE·runtime the lock names no signature algorithm by digest: nothing can be signed here`);
|
|
11
|
-
return { admitted, era };
|
|
12
|
-
}
|
|
1
|
+
var s=Object.defineProperty;var d=(e,n)=>s(e,"name",{value:n,configurable:!0});import{wireLine as a}from"../fold/wire.js";import{fieldOf as f}from"../fold/claims.js";function m(e){const n=a(e,"signature-algorithms"),i=(n===void 0?[]:f(n,"value").split("|")).filter(Boolean),t=a(e,"era"),o=(t===void 0?void 0:i.find(r=>r.endsWith(`:${f(t,"value")}`)))??i.find(r=>r.includes(":"));if(o===void 0)throw new Error("REFUSE\xB7runtime the lock names no signature algorithm by digest: nothing can be signed here");return{admitted:i,era:o}}d(m,"signatureEraOf");export{m as signatureEraOf};
|
package/dist/host/signing.js
CHANGED
|
@@ -1,48 +1,2 @@
|
|
|
1
|
-
import { invokeSigningPort } from "../
|
|
2
|
-
|
|
3
|
-
import { parse, signerSelection, signerRequestBytes, signerResponseBytes, signerResponseOf } from '@lapxo/topos/wire';
|
|
4
|
-
import { invokeSigner, SigningFailure } from "./ports/signing.js";
|
|
5
|
-
/** An explicitly supplied host registry; a repository cannot supply executable bindings. */
|
|
6
|
-
function binding(name, keyFile) {
|
|
7
|
-
if (name === 'file') {
|
|
8
|
-
if (!keyFile)
|
|
9
|
-
throw new SigningFailure('REFUSE·signer file needs --key-file');
|
|
10
|
-
return { kind: 'file', path: keyFile };
|
|
11
|
-
}
|
|
12
|
-
if (keyFile)
|
|
13
|
-
throw new SigningFailure('REFUSE·signer command cannot use --key-file');
|
|
14
|
-
const path = process.env['BOUND_SIGNERS'];
|
|
15
|
-
if (!path)
|
|
16
|
-
throw new SigningFailure('REFUSE·signer no host binding registry');
|
|
17
|
-
try {
|
|
18
|
-
const registry = JSON.parse(readFileSync(path, 'utf8'));
|
|
19
|
-
if (!registry || typeof registry !== 'object' || !Object.prototype.hasOwnProperty.call(registry, name))
|
|
20
|
-
throw Error();
|
|
21
|
-
const record = registry[name];
|
|
22
|
-
if (!record || typeof record !== 'object')
|
|
23
|
-
throw Error();
|
|
24
|
-
const f = record;
|
|
25
|
-
if (f['kind'] !== 'command' || typeof f['executable'] !== 'string' || !f['executable']
|
|
26
|
-
|| !Array.isArray(f['args']) || !f['args'].every(a => typeof a === 'string'))
|
|
27
|
-
throw Error();
|
|
28
|
-
return { kind: 'command', executable: f['executable'], args: f['args'] };
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
throw new SigningFailure('REFUSE·signer host binding unavailable or invalid');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/** Resolve data before acquisition; all mechanisms use one wire protocol and verification path. */
|
|
35
|
-
export function signerFor(lines, keyId, selected, keyFile, injected) {
|
|
36
|
-
const fields = lines.flatMap(line => { const got = parse(line); return got.kind === 'fact' ? [got.value.fields] : []; });
|
|
37
|
-
const declaration = signerSelection(fields, keyId);
|
|
38
|
-
if (selected !== undefined && selected !== declaration.name)
|
|
39
|
-
throw new SigningFailure(`REFUSE·signer ${keyId} CLI selection conflicts with declaration`);
|
|
40
|
-
if (injected) {
|
|
41
|
-
if (injected.name !== declaration.name || keyFile)
|
|
42
|
-
throw new SigningFailure('REFUSE·signer injected host binding conflicts with declaration or key file');
|
|
43
|
-
return (lot) => invokeSigningPort(lot, injected.sign, { timeoutMs: declaration.timeoutMs, maxBytes: declaration.responseBytes }, injected.signal);
|
|
44
|
-
}
|
|
45
|
-
const mechanism = binding(declaration.name, keyFile);
|
|
46
|
-
const protocol = { request: signerRequestBytes, response: signerResponseBytes, reply: signerResponseOf };
|
|
47
|
-
return (lot) => invokeSigner(lot, mechanism, protocol, declaration);
|
|
48
|
-
}
|
|
1
|
+
var S=Object.defineProperty;var a=(t,n)=>S(t,"name",{value:n,configurable:!0});import{AsyncLocalStorage as b}from"node:async_hooks";import{BoundRefusal as l}from"./refusals.js";import{invokeSigningPort as E}from"../engine/ports.js";import{readFileSync as R}from"node:fs";import{library14_parse as v,library14_signerSelection as F,library14_signerRequestBytes as U,library14_signerResponseBytes as u,library14_signerResponseOf as p}from"../vendor/runtime.js";import{invokeSigner as m,SigningFailure as c}from"./ports/signing.js";const h=new b,A=a((t,n)=>h.run(t,n),"withNativeSigning");function y(t,n){if(t==="file"){if(!n)throw new c("REFUSE\xB7signer file needs --key-file");return{kind:"file",path:n}}if(n)throw new c("REFUSE\xB7signer command cannot use --key-file");const s=process.env.BOUND_SIGNERS;if(!s)throw new c("REFUSE\xB7signer no host binding registry");try{const i=JSON.parse(R(s,"utf8"));if(!i||typeof i!="object"||!Object.prototype.hasOwnProperty.call(i,t))throw Error();const e=i[t];if(!e||typeof e!="object")throw Error();const r=e;if(r.kind!=="command"||typeof r.executable!="string"||!r.executable||!Array.isArray(r.args)||!r.args.every(o=>typeof o=="string"))throw Error();return{kind:"command",executable:r.executable,args:r.args}}catch{throw new c("REFUSE\xB7signer host binding unavailable or invalid")}}a(y,"binding");function d(t,n,s){const i=t.flatMap(r=>{const o=v(r);return o.kind==="fact"?[o.value.fields]:[]}),e=F(i,n);if(s!==void 0&&s!==e.name)throw new c(`REFUSE\xB7signer ${n} CLI selection conflicts with declaration`);return e}a(d,"declaredSigner");function M(t,n,s,i,e){const r=h.getStore();if(!e&&r){if(r.bound===!1)throw new l("host/unbound-signer","REFUSE\xB7host/unbound-signer");if(r.keyId!==n)throw new l("host/signer-mismatch","REFUSE\xB7host/signer-mismatch");e=r}const o=d(t,n,s);if(e){if(e.name!==o.name||i)throw new c("REFUSE\xB7signer injected host binding conflicts with declaration or key file");return g=>E(g,e.sign,{timeoutMs:o.timeoutMs,maxBytes:o.responseBytes},e.signal)}const f=y(o.name,i),w={request:U,response:u,reply:p};return g=>m(g,f,w,o)}a(M,"signerFor");function J(t,n,s,i){const e=d(t,n,s),r=y(e.name,i),o={request:a(f=>JSON.stringify(f)+`
|
|
2
|
+
`,"request"),response:u,reply:p};return f=>m(f,r,o,e)}a(J,"frameSignerFor");export{J as frameSignerFor,M as signerFor,A as withNativeSigning};
|
|
@@ -1,111 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { contentStore, verifiedContent } from "./content-store.js";
|
|
4
|
-
import { ContentNeeded } from "./content-needed.js";
|
|
5
|
-
import { createHash } from 'node:crypto';
|
|
6
|
-
import { parse, wireAt } from '@lapxo/topos/wire';
|
|
7
|
-
import { landBlob } from "../land/ledger.js";
|
|
8
|
-
import { ownLock } from "../observe/runner.js";
|
|
9
|
-
/** Transport uses declared locations; only the requested digest admits bytes into the cache. */
|
|
10
|
-
export async function resolveSelectedContent(lines, port, requested) {
|
|
11
|
-
const fields = lines.flatMap(line => { const p = parse(line); return p.kind === 'fact' && p.value.fields.value !== 'withdraw' ? [p.value.fields] : []; });
|
|
12
|
-
const selectionIndex = (scope) => { const match = /(^|\/)uses\//.exec(scope); return match === null ? -1 : match.index + match[1].length; };
|
|
13
|
-
// A dependency constraint is not a content binding. Historical artifact records
|
|
14
|
-
// use measure=id; explicit digest records still validate even when malformed.
|
|
15
|
-
const bindings = fields.filter(f => selectionIndex(f.scope ?? '') >= 0 ||
|
|
16
|
-
(f.scope?.startsWith('dep/') && (f.measure === 'digest' || /^[a-zA-Z][a-zA-Z0-9-]*:[a-f0-9]+$/.test(f.value ?? ''))));
|
|
17
|
-
const locations = new Map();
|
|
18
|
-
for (const binding of bindings) {
|
|
19
|
-
const scope = binding.scope ?? '';
|
|
20
|
-
const index = selectionIndex(scope);
|
|
21
|
-
const sourceScope = index >= 0 ? scope.slice(0, index) + 'sources/' + scope.slice(index + 5) : 'sources/' + scope.slice(4);
|
|
22
|
-
const urls = fields.filter(f => f.scope === sourceScope).map(f => f.value ?? '');
|
|
23
|
-
if (urls.length)
|
|
24
|
-
locations.set(binding.value ?? '', [...new Set([...(locations.get(binding.value ?? '') ?? []), ...urls])]);
|
|
25
|
-
}
|
|
26
|
-
const received = [];
|
|
27
|
-
const validate = (digest) => {
|
|
28
|
-
const split = digest.indexOf(':');
|
|
29
|
-
const algorithm = digest.slice(0, split), hex = digest.slice(split + 1);
|
|
30
|
-
if (split < 1 || !port.algorithms.has(algorithm) || !/^[a-f0-9]+$/.test(hex))
|
|
31
|
-
throw Error(`REFUSE·pin ${digest} digest is not admitted`);
|
|
32
|
-
return { algorithm, hex };
|
|
33
|
-
};
|
|
34
|
-
const ensure = async (digest) => {
|
|
35
|
-
const { algorithm, hex } = validate(digest);
|
|
36
|
-
const verify = (bytes) => {
|
|
37
|
-
if (createHash(algorithm).update(bytes).digest('hex') !== hex)
|
|
38
|
-
throw Error(`REFUSE·pin ${digest} content hash mismatch · not laid`);
|
|
39
|
-
return bytes;
|
|
40
|
-
};
|
|
41
|
-
const cached = port.read(digest);
|
|
42
|
-
if (cached !== undefined)
|
|
43
|
-
return verify(cached);
|
|
44
|
-
const urls = locations.get(digest) ?? [];
|
|
45
|
-
if (!urls.length)
|
|
46
|
-
throw Error(`REFUSE·pin ${digest} content unavailable · no declared source · not laid`);
|
|
47
|
-
let last;
|
|
48
|
-
for (const url of urls) {
|
|
49
|
-
let bytes;
|
|
50
|
-
try {
|
|
51
|
-
bytes = await port.fetch(url, digest);
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
last = error;
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
verify(bytes);
|
|
58
|
-
port.write(digest, bytes);
|
|
59
|
-
received.push(digest);
|
|
60
|
-
return bytes;
|
|
61
|
-
}
|
|
62
|
-
throw Error(`REFUSE·source ${digest} ${last instanceof Error ? last.message : 'declared sources unavailable'}`);
|
|
63
|
-
};
|
|
64
|
-
for (const digest of new Set(requested))
|
|
65
|
-
await ensure(digest);
|
|
66
|
-
return received;
|
|
67
|
-
}
|
|
68
|
-
/** Exact resource URLs; no repository checkout or inferred release. */
|
|
69
|
-
export async function resolveSources(standing, requested) {
|
|
70
|
-
const instrument = ownLock().flatMap(line => { const p = parse(line); return p.kind === 'fact' ? [p.value.fields] : []; });
|
|
71
|
-
const wire = wireAt(instrument, Number.MAX_SAFE_INTEGER);
|
|
72
|
-
if (wire === null)
|
|
73
|
-
throw Error('REFUSE·pin instrument has no admitted wire');
|
|
74
|
-
const bindings = ownLock().filter(line => {
|
|
75
|
-
const p = parse(line);
|
|
76
|
-
if (p.kind !== 'fact')
|
|
77
|
-
return false;
|
|
78
|
-
const fields = p.value.fields;
|
|
79
|
-
return fields.scope?.startsWith('sources/') || fields.scope?.startsWith('dep/');
|
|
80
|
-
});
|
|
81
|
-
const received = await resolveSelectedContent([...standing, ...bindings], {
|
|
82
|
-
algorithms: wire.digests,
|
|
83
|
-
read: digest => { try {
|
|
84
|
-
return verifiedContent(digest).bytes;
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
if (error instanceof ContentNeeded)
|
|
88
|
-
return undefined;
|
|
89
|
-
throw error;
|
|
90
|
-
} },
|
|
91
|
-
write: (digest, bytes) => { landBlob(contentStore(), digest, bytes); },
|
|
92
|
-
fetch: async (url, digest) => transportBytes(url, digest, [...ownLock(), ...standing]),
|
|
93
|
-
}, requested);
|
|
94
|
-
for (const digest of received)
|
|
95
|
-
hostOutput('out', `FETCHED ${digest} · verified\n`);
|
|
96
|
-
}
|
|
97
|
-
/** A changed verified store is the only reason to retry. A repeated miss never loops or changes a named pin. */
|
|
98
|
-
export async function resolveRequested(resolve, fold) {
|
|
99
|
-
const attempted = new Set();
|
|
100
|
-
for (;;) {
|
|
101
|
-
try {
|
|
102
|
-
return await fold();
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
if (!(error instanceof ContentNeeded) || attempted.has(error.digest))
|
|
106
|
-
throw error;
|
|
107
|
-
attempted.add(error.digest);
|
|
108
|
-
await resolve(error.digest);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
1
|
+
var $=Object.defineProperty;var s=(c,i)=>$(c,"name",{value:i,configurable:!0});import{hostOutput as F}from"./call-context.js";import{transportBytes as R}from"./ports/transport.js";import{contentStore as A,verifiedContent as U}from"./content-store.js";import{ContentNeeded as x}from"./content-needed.js";import{createHash as k}from"node:crypto";import{library14_parse as y,library14_wireAt as C}from"../vendor/runtime.js";import{landBlob as M}from"../land/ledger.js";import{ownLock as S}from"../observe/runner.js";async function _(c,i,u){const n=c.flatMap(e=>{const t=y(e);return t.kind==="fact"&&t.value.fields.value!=="withdraw"?[t.value.fields]:[]}),h=s(e=>{const t=/(^|\/)uses\//.exec(e);return t===null?-1:t.index+t[1].length},"selectionIndex"),E=n.filter(e=>h(e.scope??"")>=0||e.scope?.startsWith("dep/")&&(e.measure==="digest"||/^[a-zA-Z][a-zA-Z0-9-]*:[a-f0-9]+$/.test(e.value??""))),r=new Map;for(const e of E){const t=e.scope??"",a=h(t),l=a>=0?t.slice(0,a)+"sources/"+t.slice(a+5):"sources/"+t.slice(4),d=n.filter(f=>f.scope===l).map(f=>f.value??"");d.length&&r.set(e.value??"",[...new Set([...r.get(e.value??"")??[],...d])])}const o=[],p=s(e=>{const t=e.indexOf(":"),a=e.slice(0,t),l=e.slice(t+1);if(t<1||!i.algorithms.has(a)||!/^[a-f0-9]+$/.test(l))throw Error(`REFUSE\xB7pin ${e} digest is not admitted`);return{algorithm:a,hex:l}},"validate"),b=s(async e=>{const{algorithm:t,hex:a}=p(e),l=s(m=>{if(k(t).update(m).digest("hex")!==a)throw Error(`REFUSE\xB7pin ${e} content hash mismatch \xB7 not laid`);return m},"verify"),d=i.read(e);if(d!==void 0)return l(d);const f=r.get(e)??[];if(!f.length)throw Error(`REFUSE\xB7pin ${e} content unavailable \xB7 no declared source \xB7 not laid`);let v;for(const m of f){let w;try{w=await i.fetch(m,e)}catch(g){v=g;continue}return l(w),i.write(e,w),o.push(e),w}throw Error(`REFUSE\xB7source ${e} ${v instanceof Error?v.message:"declared sources unavailable"}`)},"ensure");for(const e of new Set(u))await b(e);return o}s(_,"resolveSelectedContent");async function q(c,i){const u=S().flatMap(r=>{const o=y(r);return o.kind==="fact"?[o.value.fields]:[]}),n=C(u,Number.MAX_SAFE_INTEGER);if(n===null)throw Error("REFUSE\xB7pin instrument has no admitted wire");const h=S().filter(r=>{const o=y(r);if(o.kind!=="fact")return!1;const p=o.value.fields;return p.scope?.startsWith("sources/")||p.scope?.startsWith("dep/")}),E=await _([...c,...h],{algorithms:n.digests,read:s(r=>{try{return U(r).bytes}catch(o){if(o instanceof x)return;throw o}},"read"),write:s((r,o)=>{M(A(),r,o)},"write"),fetch:s(async(r,o)=>R(r,o,[...S(),...c]),"fetch")},i);for(const r of E)F("out",`FETCHED ${r} \xB7 verified
|
|
2
|
+
`)}s(q,"resolveSources");async function D(c,i){const u=new Set;for(;;)try{return await i()}catch(n){if(!(n instanceof x)||u.has(n.digest))throw n;u.add(n.digest),await c(n.digest)}}s(D,"resolveRequested");export{D as resolveRequested,_ as resolveSelectedContent,q as resolveSources};
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { foldClaims, fieldOf } from "../fold/claims.js";
|
|
3
|
-
/** Projection only, after the caller authenticates the complete carrier. The
|
|
4
|
-
* CLI and in-process reader use this same fold and output shape. */
|
|
5
|
-
export function projectContextualStanding(root, legacy, contexts, decoded) {
|
|
6
|
-
const groups = new Map();
|
|
7
|
-
for (const act of contexts) {
|
|
8
|
-
const context = decoded.find(one => one.identity === act.identity).context;
|
|
9
|
-
for (const p of context.places) {
|
|
10
|
-
const key = JSON.stringify([context.root.namespace, p.place]), group = groups.get(key) ?? { namespace: context.root.namespace, place: p.place, lines: [], contexts: [] };
|
|
11
|
-
group.lines.push(...p.records);
|
|
12
|
-
group.contexts.push({ identity: act.identity, context: act.context, receipts: act.receipts });
|
|
13
|
-
groups.set(key, group);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const legacyPlaces = legacy.map(place => ({ namespace: 'legacy-global', place: place.place, standing: foldClaims(place.history).standing.filter(line => fieldOf(line, 'value') !== 'withdraw'), history: place.history }));
|
|
17
|
-
return { profile: PLACE_ACT_CONTEXT, root, legacyPlaces, contexts, places: [...groups.values()].map(group => { const folded = foldClaims(group.lines); return { namespace: group.namespace, place: group.place, standing: folded.standing.filter(line => fieldOf(line, 'value') !== 'withdraw'), retracted: folded.retracted, superseded: folded.superseded, forks: folded.forks, contexts: group.contexts }; }) };
|
|
18
|
-
}
|
|
1
|
+
var y=Object.defineProperty;var l=(n,a)=>y(n,"name",{value:a,configurable:!0});import{library6_PLACE_ACT_CONTEXT as u}from"../vendor/runtime.js";import{foldClaims as p,fieldOf as d}from"../fold/claims.js";function h(n,a,r,f){const o=new Map;for(const e of r){const t=f.find(s=>s.identity===e.identity).context;for(const s of t.places){const i=JSON.stringify([t.root.namespace,s.place]),c=o.get(i)??{namespace:t.root.namespace,place:s.place,lines:[],contexts:[]};c.lines.push(...s.records),c.contexts.push({identity:e.identity,context:e.context,receipts:e.receipts}),o.set(i,c)}}const m=a.map(e=>({namespace:"legacy-global",place:e.place,standing:p(e.history).standing.filter(t=>d(t,"value")!=="withdraw"),history:e.history}));return{profile:u,root:n,legacyPlaces:m,contexts:r,places:[...o.values()].map(e=>{const t=p(e.lines);return{namespace:e.namespace,place:e.place,standing:t.standing.filter(s=>d(s,"value")!=="withdraw"),retracted:t.retracted,superseded:t.superseded,forks:t.forks,contexts:e.contexts}})}}l(h,"projectContextualStanding");export{h as projectContextualStanding};
|
|
@@ -1,50 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BoundRefusal } from "./refusals.js";
|
|
3
|
-
import { authorityFor } from "../fold/signers.js";
|
|
4
|
-
import { signatureEraOf as eraOf } from "./signature-era.js";
|
|
5
|
-
import { fieldOf, foldClaims, isConfig } from "../fold/claims.js";
|
|
6
|
-
import { foldedEvidence } from '@lapxo/topos/contract';
|
|
7
|
-
/** Project the supplied signed history against the host's original trust anchor.
|
|
8
|
-
* No current-root selection, storage access, effects or retained authority.
|
|
9
|
-
* The file host and the in-process host use this same admission-snapshot fold. */
|
|
10
|
-
export function projectAuthenticatedStanding(history, anchor) {
|
|
11
|
-
const snapshots = new Map();
|
|
12
|
-
const admitted = history.filter(line => {
|
|
13
|
-
const epoch = Number(fieldOf(line, 'epoch')) || 0;
|
|
14
|
-
let authority = snapshots.get(epoch);
|
|
15
|
-
if (!authority) {
|
|
16
|
-
// This invocation has freshly read the complete signed inventory. Derive
|
|
17
|
-
// the same historical cutoff without reopening it for every epoch; the
|
|
18
|
-
// next invocation still rereads every authority input.
|
|
19
|
-
const snapshot = history.filter(record => !isConfig(record) || Number(fieldOf(record, 'epoch')) <= epoch);
|
|
20
|
-
// The signature vocabulary is configuration, not the as-yet
|
|
21
|
-
// unauthenticated evidence whose values are about to be folded.
|
|
22
|
-
const wire = snapshot.filter(record => {
|
|
23
|
-
const scope = fieldOf(record, 'scope');
|
|
24
|
-
return scope.startsWith('wire/') || scope.startsWith('audit/wire/');
|
|
25
|
-
});
|
|
26
|
-
authority = authorityFor(snapshot, anchor, eraOf(foldClaims(wire).standing).admitted);
|
|
27
|
-
snapshots.set(epoch, authority);
|
|
28
|
-
}
|
|
29
|
-
return authority.of(line).kind === 'admitted';
|
|
30
|
-
});
|
|
31
|
-
// The host authenticates against historical authority; Topos projects the
|
|
32
|
-
// authenticated history using the instrument's existing fold.
|
|
33
|
-
const { standing } = foldedEvidence(admitted, {
|
|
34
|
-
classification: () => 'local',
|
|
35
|
-
fold: lines => foldClaims(lines).standing,
|
|
36
|
-
});
|
|
37
|
-
return [...standing];
|
|
38
|
-
}
|
|
39
|
-
/** One check shared by the CLI and the read-only native host. */
|
|
40
|
-
export function assertStandingView(lines) {
|
|
41
|
-
const view = viewsOf(lines).get('standing');
|
|
42
|
-
if (!view || view.shape || !view.regions.some(region => region.name === 'standing'))
|
|
43
|
-
throw new BoundRefusal('standing/view', 'REFUSE·view standing requires a declared standing view');
|
|
44
|
-
}
|
|
45
|
-
export function publicStandingProjection(history, anchor) {
|
|
46
|
-
return publishedStandingLines(projectAuthenticatedStanding(history, anchor));
|
|
47
|
-
}
|
|
48
|
-
export function publishedStandingLines(standing) {
|
|
49
|
-
return standing.filter(line => !isConfig(line) || fieldOf(line, 'value') !== 'withdraw');
|
|
50
|
-
}
|
|
1
|
+
var w=Object.defineProperty;var e=(i,t)=>w(i,"name",{value:t,configurable:!0});import{viewsOf as h}from"../fold/views.js";import{BoundRefusal as v}from"./refusals.js";import{authorityFor as b}from"../fold/signers.js";import{signatureEraOf as E}from"./signature-era.js";import{fieldOf as a,foldClaims as p,isConfig as u}from"../fold/claims.js";import{library5_foldedEvidence as S}from"../vendor/runtime.js";function x(i,t){const n=new Map,m=i.filter(o=>{const d=Number(a(o,"epoch"))||0;let r=n.get(d);if(!r){const f=i.filter(s=>!u(s)||Number(a(s,"epoch"))<=d),g=f.filter(s=>{const c=a(s,"scope");return c.startsWith("wire/")||c.startsWith("audit/wire/")});r=b(f,t,E(p(g).standing).admitted),n.set(d,r)}return r.of(o).kind==="admitted"}),{standing:l}=S(m,{classification:e(()=>"local","classification"),fold:e(o=>p(o).standing,"fold")});return[...l]}e(x,"projectAuthenticatedStanding");function k(i){const t=h(i).get("standing");if(!t||t.shape||!t.regions.some(n=>n.name==="standing"))throw new v("standing/view","REFUSE\xB7view standing requires a declared standing view")}e(k,"assertStandingView");function q(i,t){return O(x(i,t))}e(q,"publicStandingProjection");function O(i){return i.filter(t=>!u(t)||a(t,"value")!=="withdraw")}e(O,"publishedStandingLines");export{k as assertStandingView,x as projectAuthenticatedStanding,q as publicStandingProjection,O as publishedStandingLines};
|
package/dist/host/timing.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const timing = (spent) => (what, fn) => {
|
|
3
|
-
const at = Date.now();
|
|
4
|
-
const got = fn();
|
|
5
|
-
spent.push(`${what} ${Date.now() - at}`);
|
|
6
|
-
return got;
|
|
7
|
-
};
|
|
1
|
+
var s=Object.defineProperty;var n=(o,t)=>s(o,"name",{value:t,configurable:!0});import{traceWork as a}from"./work-trace.js";const p=n(o=>(t,r)=>{const e=Date.now(),c=a(t,r);return o.push(`${t} ${Date.now()-e}`),c},"timing");export{p as timing};
|