@lapxo/bound 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CITATION.cff +19 -0
- package/TARGET.bound +95 -39
- package/dist/cli/accept.js +72 -558
- package/dist/cli/act-result.js +3 -103
- package/dist/cli/args.js +3 -44
- package/dist/cli/custodian.js +2 -29
- package/dist/cli/host.js +4 -32
- package/dist/cli/names.js +1 -12
- package/dist/cli/native-descendant.js +1 -19
- package/dist/cli/native.js +3 -60
- package/dist/cli/observe.js +1 -13
- package/dist/cli/owner.js +3 -139
- package/dist/cli/pass.js +21 -321
- package/dist/cli/place.js +6 -281
- package/dist/cli/release-result.js +3 -80
- package/dist/cli/retained-judgment.js +1 -25
- package/dist/cli/standing-result.js +4 -21
- package/dist/cli/takes.js +10 -111
- package/dist/cli/verb.d.ts +1 -2
- package/dist/cli/verb.js +83 -683
- package/dist/engine/computation.js +2 -0
- package/dist/engine/conformance.js +4 -0
- package/dist/engine/encoding.js +1 -2
- package/dist/engine/index.d.ts +1 -13
- package/dist/engine/index.js +2 -11
- package/dist/engine/object.js +1 -38
- package/dist/engine/ports.js +2 -103
- package/dist/fold/admission-history.js +1 -17
- package/dist/fold/bootstrap-anchor.js +1 -28
- package/dist/fold/ceilings.js +1 -142
- package/dist/fold/claims.js +2 -131
- package/dist/fold/closed.js +24 -234
- package/dist/fold/configures.js +1 -25
- package/dist/fold/digests.js +10 -226
- package/dist/fold/evidence.js +1 -22
- package/dist/fold/fold-worker.js +1 -13
- package/dist/fold/kept.js +12 -173
- package/dist/fold/keys.js +3 -91
- package/dist/fold/laid.js +3 -90
- package/dist/fold/nos.js +1 -48
- package/dist/fold/object.js +1 -2
- package/dist/fold/observed.js +27 -534
- package/dist/fold/opened.js +1 -33
- package/dist/fold/own.js +3 -217
- package/dist/fold/paid.js +1 -92
- package/dist/fold/place-inputs.js +1 -70
- package/dist/fold/places.js +3 -100
- package/dist/fold/rank.js +1 -9
- package/dist/fold/reach.js +1 -83
- package/dist/fold/readers.js +6 -142
- package/dist/fold/receipts.js +1 -47
- package/dist/fold/region-declarations.js +1 -13
- package/dist/fold/region.js +8 -286
- package/dist/fold/release-policy.js +1 -101
- package/dist/fold/resolved.js +6 -145
- package/dist/fold/roles.js +2 -59
- package/dist/fold/second.js +4 -71
- package/dist/fold/shards.js +12 -100
- package/dist/fold/signed.js +3 -81
- package/dist/fold/signers.js +1 -54
- package/dist/fold/stranger.js +6 -24
- package/dist/fold/views.js +1 -66
- package/dist/fold/wire.js +1 -46
- package/dist/fold/zoom.js +3 -81
- package/dist/host/act-cost.js +1 -25
- package/dist/host/adapters/keys/ed25519.js +1 -30
- package/dist/host/adapters/modules/javascript.js +1 -50
- package/dist/host/adapters/transport/http.js +1 -28
- package/dist/host/admitted-place.js +1 -63
- package/dist/host/archive.js +1 -152
- package/dist/host/call-context.js +1 -0
- package/dist/host/capsule-process.js +2 -61
- package/dist/host/capsule.js +9 -168
- package/dist/host/cell-receipts.js +12 -128
- package/dist/host/commit-result.js +1 -0
- package/dist/host/content-needed.js +1 -8
- package/dist/host/content-store.js +1 -31
- package/dist/host/contextual-place.js +2 -77
- package/dist/host/digest.js +2 -15
- package/dist/host/hash.js +1 -9
- package/dist/host/host-controls.js +1 -0
- package/dist/host/in-process-act.js +3 -0
- package/dist/host/in-process-context.js +3 -0
- package/dist/host/in-process-root.js +6 -0
- package/dist/host/in-process.js +4 -0
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.js +1 -0
- package/dist/host/io.js +1 -11
- package/dist/host/lifetime.js +1 -79
- package/dist/host/located.js +6 -105
- package/dist/host/native/bounded-file.js +1 -32
- package/dist/host/native/command.js +1 -91
- package/dist/host/native/control-bridge-worker.js +2 -88
- package/dist/host/native/control-bridge.js +1 -110
- package/dist/host/native/control-selection.js +1 -32
- package/dist/host/native/custody.js +1 -91
- package/dist/host/native/deadline.js +1 -28
- package/dist/host/native/descendants.js +1 -528
- package/dist/host/native/generated-custodian.js +5 -267
- package/dist/host/native/generated.js +1 -379
- package/dist/host/native/image.js +1 -45
- package/dist/host/native/jobs.js +2 -148
- package/dist/host/native/loader.js +1 -269
- package/dist/host/native/materialize.js +1 -175
- package/dist/host/native/module-closure.js +1 -130
- package/dist/host/native/module-delivery.d.ts +1 -62
- package/dist/host/native/module-delivery.js +1 -151
- package/dist/host/native/module-syntax.js +1 -69
- package/dist/host/native/native-binary.js +1 -115
- package/dist/host/native/native-program.js +1 -72
- package/dist/host/native/node-jobs.js +3 -187
- package/dist/host/native/node-launch.js +1 -159
- package/dist/host/native/preload.js +1 -45
- package/dist/host/native/reading.js +1 -249
- package/dist/host/native/receipt-environment.js +1 -41
- package/dist/host/native/references.js +1 -30
- package/dist/host/native/root.js +1 -37
- package/dist/host/native/route.js +1 -216
- package/dist/host/native/runtime.js +1 -9
- package/dist/host/native-reader-context.js +1 -8
- package/dist/host/native-receiver.js +1 -0
- package/dist/host/objects.js +1 -38
- package/dist/host/order.js +1 -2
- package/dist/host/place-act-transaction.js +4 -0
- package/dist/host/place-clock-selection.js +5 -124
- package/dist/host/ports/ingress.js +2 -57
- package/dist/host/ports/local-act.js +5 -172
- package/dist/host/ports/place-act.js +1 -169
- package/dist/host/ports/publication.js +1 -56
- package/dist/host/ports/signing.js +1 -74
- package/dist/host/ports/store.js +1 -18
- package/dist/host/ports/transport.js +1 -48
- package/dist/host/process-lifetime.js +1 -17
- package/dist/host/provide.js +1 -183
- package/dist/host/read-only.js +1 -9
- package/dist/host/reading-closures.js +7 -227
- package/dist/host/reading-context.js +1 -53
- package/dist/host/reading-identity-types.js +0 -0
- package/dist/host/reading-identity.js +3 -0
- package/dist/host/reading-preparation.js +6 -0
- package/dist/host/reference-authenticated.d.ts +1 -40
- package/dist/host/reference-authenticated.js +3 -100
- package/dist/host/reference-contracts.js +1 -6
- package/dist/host/reference-export.js +6 -81
- package/dist/host/reference-native-api.d.ts +1 -3
- package/dist/host/reference-native-api.js +1 -3
- package/dist/host/reference-native.js +1 -74
- package/dist/host/reference-profile.js +1 -63
- package/dist/host/reference-standing.js +2 -18
- package/dist/host/reference.js +1 -24
- package/dist/host/refusals.js +2 -43
- package/dist/host/release.js +4 -256
- package/dist/host/root-clock-source.js +1 -305
- package/dist/host/selected-capsules.js +1 -50
- package/dist/host/selected-topos.js +1 -80
- package/dist/host/signature-era.js +1 -0
- package/dist/host/signing.js +2 -48
- package/dist/host/source-content.js +2 -110
- package/dist/host/standing-carrier.js +1 -0
- package/dist/host/standing-projection.js +1 -0
- package/dist/host/timing.js +1 -7
- package/dist/host/walk.js +20 -193
- package/dist/judge/late.js +1 -33
- package/dist/judge/take.js +2 -75
- package/dist/judge/widening.js +1 -25
- package/dist/land/act.js +8 -302
- package/dist/land/alias.js +1 -41
- package/dist/land/held.js +1 -23
- package/dist/land/inert.js +1 -33
- package/dist/land/leaving.js +1 -55
- package/dist/land/ledger.js +7 -188
- package/dist/land/owned.js +4 -66
- package/dist/land/sign.js +1 -53
- package/dist/land/standing-pin.js +1 -49
- package/dist/land/vouched.js +1 -112
- package/dist/land/withdraw.js +1 -24
- package/dist/observe/files.js +1 -88
- package/dist/observe/identity.js +1 -61
- package/dist/observe/match.js +1 -8
- package/dist/observe/regions.js +7 -306
- package/dist/observe/run.js +2 -40
- package/dist/observe/runner.js +4 -93
- package/dist/public-types.d.ts +1114 -0
- package/dist/render/capsule.js +1 -30
- package/dist/render/field.js +1 -40
- package/dist/render/names.js +1 -4
- package/dist/render/open.js +1 -61
- package/dist/render/page.js +1 -7
- package/dist/render/receipts.js +1 -47
- package/dist/render/shape.js +1 -74
- package/dist/render/target.js +4 -52
- package/dist/render/view.js +7 -197
- package/dist/vendor/50086958553b9376d600583f7dff354196bfeb41170fc6d1482ca7bea7c493e2.LICENSE +21 -0
- package/dist/vendor/b3e938d28f88a1851af303a40c749e12ebd5a686daac4f0b343b5cdd2e040419.LICENSE +21 -0
- package/dist/vendor/bundle.json +1 -0
- package/dist/vendor/library11.js +1 -0
- package/dist/vendor/object-provider.js +42 -0
- package/dist/vendor/runtime.js +38 -0
- package/dist/vendor/sources.json +1 -0
- package/dist/wasm/adapter.d.ts +1 -51
- package/dist/wasm/adapter.js +1 -180
- package/dist/wasm/node-worker.js +1 -13
- package/dist/wasm/object.js +1 -76
- package/dist/wasm/worker.js +1 -7
- package/docs/contracts/closure-delivery.md +1 -1
- package/docs/contracts/closure-delivery.publication.json +1 -1
- package/docs/contracts/conformance.json +142 -0
- package/docs/contracts/determinism.bound +9 -0
- package/docs/contracts/engine-object-projection.publication.json +1 -1
- package/docs/contracts/engine.md +21 -1
- package/docs/contracts/native-host.md +21 -0
- package/docs/contracts/native-host.publication.json +25 -0
- package/docs/contracts/native-publication.inventory.json +3 -1
- package/docs/contracts/optional-wasm-adapter.publication.json +1 -1
- package/docs/contracts/publication.inventory.json +29 -0
- package/docs/contracts/reading-identity.md +37 -0
- package/docs/contracts/reading-identity.publication.json +25 -0
- package/docs/contracts/refusals.bound +51 -0
- package/docs/contracts/refusals.md +18 -3
- package/docs/contracts/refusals.publication.json +2 -2
- package/docs/contracts/views.md +8 -0
- package/docs/guide.md +10 -0
- package/docs/reference.md +40 -0
- package/docs/why.md +109 -0
- package/package.json +37 -18
- package/receipts.bound +11675 -9725
- package/samples/native-host/no.json +10 -0
- package/samples/native-host/yes.json +20 -0
- package/samples/reading-identity/no.json +20 -0
- package/samples/reading-identity/yes.json +46 -0
- package/vectors/native/native-host.vector.json +62 -0
- package/vectors/native/reading-identity.vector.json +101 -0
- package/vectors/native/refusals.vector.json +104 -0
- package/vendor/syntax/LICENSE.md +7 -0
- package/vendor/syntax/parser.js +1 -0
- package/dist/engine/object.d.ts +0 -17
- package/dist/engine/ports.d.ts +0 -32
- package/dist/host/native/module-closure.d.ts +0 -35
- package/dist/host/reference-export.d.ts +0 -33
- package/dist/host/reference-native.d.ts +0 -30
- package/dist/host/reference-profile.d.ts +0 -23
- package/dist/host/refusals.d.ts +0 -14
|
@@ -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{library7_capsuleOffers as A,library7_providerInputs as S,library7_providerInputRegions as D,library7_capsuleDescriptor as F,library7_assertCapsuleDescriptor as I}from"../vendor/runtime.js";import{fullDigest as j}from"./digest.js";import{library11_wireAt as C,library11_parse as U}from"../vendor/runtime.js";import{selectedTopoi as M,toposAt as O}from"./selected-topos.js";import{library11_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{library7_readStanding as O}from"../vendor/runtime.js";import{library11_parse as F,library11_wireAt as m,library11_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};
|
|
@@ -0,0 +1 @@
|
|
|
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 {
|
|
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 });
|
|
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 d=Object.defineProperty;var a=(t,n)=>d(t,"name",{value:n,configurable:!0});import{invokeSigningPort as h}from"../engine/ports.js";import{readFileSync as w}from"node:fs";import{library11_parse as S,library11_signerSelection as b,library11_signerRequestBytes as E,library11_signerResponseBytes as l,library11_signerResponseOf as p}from"../vendor/runtime.js";import{invokeSigner as u,SigningFailure as c}from"./ports/signing.js";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 o=process.env.BOUND_SIGNERS;if(!o)throw new c("REFUSE\xB7signer no host binding registry");try{const i=JSON.parse(w(o,"utf8"));if(!i||typeof i!="object"||!Object.prototype.hasOwnProperty.call(i,t))throw Error();const r=i[t];if(!r||typeof r!="object")throw Error();const e=r;if(e.kind!=="command"||typeof e.executable!="string"||!e.executable||!Array.isArray(e.args)||!e.args.every(s=>typeof s=="string"))throw Error();return{kind:"command",executable:e.executable,args:e.args}}catch{throw new c("REFUSE\xB7signer host binding unavailable or invalid")}}a(y,"binding");function m(t,n,o){const i=t.flatMap(e=>{const s=S(e);return s.kind==="fact"?[s.value.fields]:[]}),r=b(i,n);if(o!==void 0&&o!==r.name)throw new c(`REFUSE\xB7signer ${n} CLI selection conflicts with declaration`);return r}a(m,"declaredSigner");function O(t,n,o,i,r){const e=m(t,n,o);if(r){if(r.name!==e.name||i)throw new c("REFUSE\xB7signer injected host binding conflicts with declaration or key file");return g=>h(g,r.sign,{timeoutMs:e.timeoutMs,maxBytes:e.responseBytes},r.signal)}const s=y(e.name,i),f={request:E,response:l,reply:p};return g=>u(g,s,f,e)}a(O,"signerFor");function U(t,n,o,i){const r=m(t,n,o),e=y(r.name,i),s={request:a(f=>JSON.stringify(f)+`
|
|
2
|
+
`,"request"),response:l,reply:p};return f=>u(f,e,s,r)}a(U,"frameSignerFor");export{U as frameSignerFor,O as signerFor};
|
|
@@ -1,110 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { ContentNeeded } from "./content-needed.js";
|
|
4
|
-
import { createHash } from 'node:crypto';
|
|
5
|
-
import { parse, wireAt } from '@lapxo/topos/wire';
|
|
6
|
-
import { landBlob } from "../land/ledger.js";
|
|
7
|
-
import { ownLock } from "../observe/runner.js";
|
|
8
|
-
/** Transport uses declared locations; only the requested digest admits bytes into the cache. */
|
|
9
|
-
export async function resolveSelectedContent(lines, port, requested) {
|
|
10
|
-
const fields = lines.flatMap(line => { const p = parse(line); return p.kind === 'fact' && p.value.fields.value !== 'withdraw' ? [p.value.fields] : []; });
|
|
11
|
-
const selectionIndex = (scope) => { const match = /(^|\/)uses\//.exec(scope); return match === null ? -1 : match.index + match[1].length; };
|
|
12
|
-
// A dependency constraint is not a content binding. Historical artifact records
|
|
13
|
-
// use measure=id; explicit digest records still validate even when malformed.
|
|
14
|
-
const bindings = fields.filter(f => selectionIndex(f.scope ?? '') >= 0 ||
|
|
15
|
-
(f.scope?.startsWith('dep/') && (f.measure === 'digest' || /^[a-zA-Z][a-zA-Z0-9-]*:[a-f0-9]+$/.test(f.value ?? ''))));
|
|
16
|
-
const locations = new Map();
|
|
17
|
-
for (const binding of bindings) {
|
|
18
|
-
const scope = binding.scope ?? '';
|
|
19
|
-
const index = selectionIndex(scope);
|
|
20
|
-
const sourceScope = index >= 0 ? scope.slice(0, index) + 'sources/' + scope.slice(index + 5) : 'sources/' + scope.slice(4);
|
|
21
|
-
const urls = fields.filter(f => f.scope === sourceScope).map(f => f.value ?? '');
|
|
22
|
-
if (urls.length)
|
|
23
|
-
locations.set(binding.value ?? '', [...new Set([...(locations.get(binding.value ?? '') ?? []), ...urls])]);
|
|
24
|
-
}
|
|
25
|
-
const received = [];
|
|
26
|
-
const validate = (digest) => {
|
|
27
|
-
const split = digest.indexOf(':');
|
|
28
|
-
const algorithm = digest.slice(0, split), hex = digest.slice(split + 1);
|
|
29
|
-
if (split < 1 || !port.algorithms.has(algorithm) || !/^[a-f0-9]+$/.test(hex))
|
|
30
|
-
throw Error(`REFUSE·pin ${digest} digest is not admitted`);
|
|
31
|
-
return { algorithm, hex };
|
|
32
|
-
};
|
|
33
|
-
const ensure = async (digest) => {
|
|
34
|
-
const { algorithm, hex } = validate(digest);
|
|
35
|
-
const verify = (bytes) => {
|
|
36
|
-
if (createHash(algorithm).update(bytes).digest('hex') !== hex)
|
|
37
|
-
throw Error(`REFUSE·pin ${digest} content hash mismatch · not laid`);
|
|
38
|
-
return bytes;
|
|
39
|
-
};
|
|
40
|
-
const cached = port.read(digest);
|
|
41
|
-
if (cached !== undefined)
|
|
42
|
-
return verify(cached);
|
|
43
|
-
const urls = locations.get(digest) ?? [];
|
|
44
|
-
if (!urls.length)
|
|
45
|
-
throw Error(`REFUSE·pin ${digest} content unavailable · no declared source · not laid`);
|
|
46
|
-
let last;
|
|
47
|
-
for (const url of urls) {
|
|
48
|
-
let bytes;
|
|
49
|
-
try {
|
|
50
|
-
bytes = await port.fetch(url, digest);
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
last = error;
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
verify(bytes);
|
|
57
|
-
port.write(digest, bytes);
|
|
58
|
-
received.push(digest);
|
|
59
|
-
return bytes;
|
|
60
|
-
}
|
|
61
|
-
throw Error(`REFUSE·source ${digest} ${last instanceof Error ? last.message : 'declared sources unavailable'}`);
|
|
62
|
-
};
|
|
63
|
-
for (const digest of new Set(requested))
|
|
64
|
-
await ensure(digest);
|
|
65
|
-
return received;
|
|
66
|
-
}
|
|
67
|
-
/** Exact resource URLs; no repository checkout or inferred release. */
|
|
68
|
-
export async function resolveSources(standing, requested) {
|
|
69
|
-
const instrument = ownLock().flatMap(line => { const p = parse(line); return p.kind === 'fact' ? [p.value.fields] : []; });
|
|
70
|
-
const wire = wireAt(instrument, Number.MAX_SAFE_INTEGER);
|
|
71
|
-
if (wire === null)
|
|
72
|
-
throw Error('REFUSE·pin instrument has no admitted wire');
|
|
73
|
-
const bindings = ownLock().filter(line => {
|
|
74
|
-
const p = parse(line);
|
|
75
|
-
if (p.kind !== 'fact')
|
|
76
|
-
return false;
|
|
77
|
-
const fields = p.value.fields;
|
|
78
|
-
return fields.scope?.startsWith('sources/') || fields.scope?.startsWith('dep/');
|
|
79
|
-
});
|
|
80
|
-
const received = await resolveSelectedContent([...standing, ...bindings], {
|
|
81
|
-
algorithms: wire.digests,
|
|
82
|
-
read: digest => { try {
|
|
83
|
-
return verifiedContent(digest).bytes;
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
if (error instanceof ContentNeeded)
|
|
87
|
-
return undefined;
|
|
88
|
-
throw error;
|
|
89
|
-
} },
|
|
90
|
-
write: (digest, bytes) => { landBlob(contentStore(), digest, bytes); },
|
|
91
|
-
fetch: async (url, digest) => transportBytes(url, digest, [...ownLock(), ...standing]),
|
|
92
|
-
}, requested);
|
|
93
|
-
for (const digest of received)
|
|
94
|
-
process.stdout.write(`FETCHED ${digest} · verified\n`);
|
|
95
|
-
}
|
|
96
|
-
/** A changed verified store is the only reason to retry. A repeated miss never loops or changes a named pin. */
|
|
97
|
-
export async function resolveRequested(resolve, fold) {
|
|
98
|
-
const attempted = new Set();
|
|
99
|
-
for (;;) {
|
|
100
|
-
try {
|
|
101
|
-
return await fold();
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
if (!(error instanceof ContentNeeded) || attempted.has(error.digest))
|
|
105
|
-
throw error;
|
|
106
|
-
attempted.add(error.digest);
|
|
107
|
-
await resolve(error.digest);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
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{library11_parse as y,library11_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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var y=Object.defineProperty;var l=(n,a)=>y(n,"name",{value:a,configurable:!0});import{library3_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};
|
|
@@ -0,0 +1 @@
|
|
|
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{library2_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 c=Object.defineProperty;var o=(t,n)=>c(t,"name",{value:n,configurable:!0});const g=o(t=>(n,e)=>{const s=Date.now(),a=e();return t.push(`${n} ${Date.now()-s}`),a},"timing");export{g as timing};
|
package/dist/host/walk.js
CHANGED
|
@@ -1,193 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const rows = lines.filter(line => fieldOf(line, 'scope') === scope && fieldOf(line, 'measure') === measure && fieldOf(line, 'value') !== 'withdraw');
|
|
22
|
-
if (rows.length !== 1)
|
|
23
|
-
return refuse('missing or conflicting ' + scope + ' ' + measure);
|
|
24
|
-
return fieldOf(rows[0], 'value');
|
|
25
|
-
};
|
|
26
|
-
function policy(root) {
|
|
27
|
-
const store = storeOf(root), standing = lockStanding(store), contract = walkSelection(standing);
|
|
28
|
-
const view = one(standing, 'view/walk', 'id');
|
|
29
|
-
if (view !== 'walk@*')
|
|
30
|
-
refuse('view/walk must declare walk@*');
|
|
31
|
-
const masks = standing.filter(line => fieldOf(line, 'scope') === 'view/walk').flatMap(line => fieldOf(line, 'needs').split('|')).filter(Boolean);
|
|
32
|
-
if (!masks.length)
|
|
33
|
-
refuse('view/walk has no declared history inputs');
|
|
34
|
-
const wire = wireAt(standing.map(fields), Number.MAX_SAFE_INTEGER), algorithm = wire?.digests.values().next().value;
|
|
35
|
-
if (!algorithm)
|
|
36
|
-
refuse('no admitted digest algorithm');
|
|
37
|
-
return { store, standing, contract, masks, digest: (bytes) => fullDigest(bytes, algorithm) };
|
|
38
|
-
}
|
|
39
|
-
function context(root, pin, own = false) {
|
|
40
|
-
const p = policy(root);
|
|
41
|
-
if (!own && !p.standing.some(line => fieldOf(line, 'scope').startsWith('uses/') && fieldOf(line, 'value') === pin))
|
|
42
|
-
refuse('origin context is not selected by digest');
|
|
43
|
-
const topos = toposAt(pin, p.store), authority = walkAuthority(topos.parts, verifiesFields);
|
|
44
|
-
const configuration = topos.parts.map(f => canonical({ ...f, by: 'target', epoch: '0' }));
|
|
45
|
-
return { pin, topos, authority, configuration, origin: walkOrigin(topos.parts), contract: walkSelection(topos.lines) };
|
|
46
|
-
}
|
|
47
|
-
function local(root) {
|
|
48
|
-
const p = policy(root), authority = authorityFor(lockLines(p.store), rootSigner(root), signaturesOf(p.store).admitted);
|
|
49
|
-
const history = signedOwnerLines(p.store).filter(line => p.masks.some(mask => matches(mask, fieldOf(line, 'scope'))));
|
|
50
|
-
if (history.some(line => authority.of(line).kind !== 'admitted'))
|
|
51
|
-
refuse('local history is not authenticated');
|
|
52
|
-
const selected = context(root, one(p.standing, 'walk/context', 'digest'), true);
|
|
53
|
-
return walkSnapshot(history, selected.contract.fields, p.digest, selected.origin, selected.contract.partition);
|
|
54
|
-
}
|
|
55
|
-
const headerInfo = (lines) => {
|
|
56
|
-
const roots = lines.filter(line => isWalkHeader(line) && fieldOf(line, 'scope') === 'walk/root');
|
|
57
|
-
if (roots.length !== 1)
|
|
58
|
-
return refuse('one signed root is required');
|
|
59
|
-
const at = fieldOf(roots[0], 'at');
|
|
60
|
-
if (!at.startsWith('receipt:'))
|
|
61
|
-
return refuse('root has no declared context');
|
|
62
|
-
return { pin: at.slice(8), base: fieldOf(roots[0], 'condition') };
|
|
63
|
-
};
|
|
64
|
-
async function validateHistory(root, selected, history) {
|
|
65
|
-
if (!selected.authority.authenticate(history))
|
|
66
|
-
refuse('origin history is not authenticated');
|
|
67
|
-
for (const line of history) {
|
|
68
|
-
const f = fields(line), decoded = fromLine(line, wireAt(selected.topos.parts, Number(f.epoch)));
|
|
69
|
-
if (decoded.kind !== 'fact')
|
|
70
|
-
refuse('origin wire ' + decoded.why);
|
|
71
|
-
}
|
|
72
|
-
const decoded = objectHistory([...selected.configuration, ...history]);
|
|
73
|
-
if (decoded.kind !== 'fact')
|
|
74
|
-
return refuse('origin history ' + decoded.why);
|
|
75
|
-
if (!decoded.value.objects.length)
|
|
76
|
-
return;
|
|
77
|
-
const pinned = new Set(selected.topos.lines);
|
|
78
|
-
const admit = (f) => Boolean(f.sig) ? selected.authority.of(canonical(f)).kind === 'admitted' : pinned.has(standingBytes([canonical(f)]).trim());
|
|
79
|
-
const provider = await objectProvider(decoded.value.objects, decoded.value.configuration, { admit, emit: () => { }, topos: pin => toposAt(pin, storeOf(root)), module: pin => contextModuleAt(pin, storeOf(root)) });
|
|
80
|
-
const checked = validateObjectContext(decoded.value.objects, provider);
|
|
81
|
-
if (checked.kind !== 'fact')
|
|
82
|
-
refuse('origin context ' + checked.why);
|
|
83
|
-
}
|
|
84
|
-
async function readBundle(root, bundle, earlier = []) {
|
|
85
|
-
const lines = bundle.evidence.split('\n').filter(Boolean), info = headerInfo(lines), p = policy(root);
|
|
86
|
-
const receipts = bundle.receipt.split('\n').filter(Boolean), authority = authorityFor(lockLines(p.store), rootSigner(root), signaturesOf(p.store).admitted);
|
|
87
|
-
if (receipts.length !== 1 || fieldOf(receipts[0], 'scope') !== 'receipts' || fieldOf(receipts[0], 'role') !== 'writes' || fieldOf(receipts[0], 'form') !== 'alphabet' || fieldOf(receipts[0], 'measure') !== 'digest' || fieldOf(receipts[0], 'at') !== 'receipt:' + info.pin || authority.of(receipts[0]).kind !== 'admitted')
|
|
88
|
-
refuse('retained import receipt is not authenticated');
|
|
89
|
-
const selected = context(root, info.pin);
|
|
90
|
-
const got = readForeignWalk(lines, { origin: selected.origin, regionOrigin: selected.origin, context: info.pin, base: info.base, fields: selected.contract.fields, partition: selected.contract.partition, digest: p.digest, previousPrefixes: [], authenticatePrefix: selected.authority.authenticate, authenticateEvidence: selected.authority.authenticate, validateOriginHistory: () => true });
|
|
91
|
-
if (fieldOf(receipts[0], 'value') !== got.identity)
|
|
92
|
-
refuse('retained import receipt does not authenticate this ingress');
|
|
93
|
-
await validateHistory(root, selected, [...new Set([...earlier, ...got.records])]);
|
|
94
|
-
return { ...got, context: info.pin, regions: walkSnapshot(got.records, selected.contract.fields, p.digest, got.origin, selected.contract.partition).regions };
|
|
95
|
-
}
|
|
96
|
-
async function verifiedIngress(root) {
|
|
97
|
-
const result = [], history = new Map();
|
|
98
|
-
const bundles = [...ingressBundles(storeOf(root))].sort((a, b) => epochOf(a.receipt.split('\n')) - epochOf(b.receipt.split('\n')));
|
|
99
|
-
for (const bundle of bundles) {
|
|
100
|
-
const info = headerInfo(bundle.evidence.split('\n').filter(Boolean)), origin = context(root, info.pin).origin;
|
|
101
|
-
if (result.some(prior => prior.origin === origin && prior.context !== info.pin))
|
|
102
|
-
refuse('origin context changed without declared lineage');
|
|
103
|
-
const prior = history.get(origin) ?? new Set();
|
|
104
|
-
const got = await readBundle(root, bundle, [...prior]);
|
|
105
|
-
for (const line of got.records)
|
|
106
|
-
prior.add(line);
|
|
107
|
-
history.set(origin, prior);
|
|
108
|
-
result.push(got);
|
|
109
|
-
}
|
|
110
|
-
return result;
|
|
111
|
-
}
|
|
112
|
-
async function inventory(root) {
|
|
113
|
-
const p = policy(root), regions = new Map(local(root).regions.map(region => [region.scope, region]));
|
|
114
|
-
for (const got of (await verifiedIngress(root)).sort((a, b) => a.senderEpoch - b.senderEpoch))
|
|
115
|
-
for (const region of got.regions)
|
|
116
|
-
regions.set(region.scope, region);
|
|
117
|
-
return walkInventory([[...regions.values()]], p.digest, context(root, one(p.standing, 'walk/context', 'digest'), true).contract.partition);
|
|
118
|
-
}
|
|
119
|
-
/** Verified foreign histories stay separate from the local authority and local epoch inputs. */
|
|
120
|
-
export async function foreignWalkLines(root) {
|
|
121
|
-
const verified = await verifiedIngress(root);
|
|
122
|
-
return [...new Set(verified.flatMap(got => got.records))];
|
|
123
|
-
}
|
|
124
|
-
/** A declared origin exports its own signed history. Foreign packets are retained with their contexts, never re-signed as local history. */
|
|
125
|
-
export async function renderWalk(root, resolution, peer, key, keyFile, signer) {
|
|
126
|
-
const p = policy(root), pin = one(p.standing, 'walk/context', 'digest'), selected = context(root, pin, true), own = local(root);
|
|
127
|
-
const known = peer.length ? (() => { const info = headerInfo(peer), remote = context(root, info.pin); return readWalkHeaders(peer, info.pin, info.base, remote.authority.authenticate); })() : walkSnapshot([], p.contract.fields, p.digest);
|
|
128
|
-
const projection = walkProjection(selected.contract.projections, resolution);
|
|
129
|
-
const ownInventory = projection === 'history' ? own : await inventory(root);
|
|
130
|
-
const selectedPacket = walkAt(ownInventory, known, resolution, selected.contract.projections), by = key ?? ownerOf(p.store), publicKey = publicKeyOf(root, by);
|
|
131
|
-
if (!publicKey)
|
|
132
|
-
refuse('unknown local signer ' + by);
|
|
133
|
-
const drafted = walkHeaders(selectedPacket, pin, known.root, projection !== 'inventory'), epoch = epochOf(localActLines(root));
|
|
134
|
-
const got = await signConsentLot(drafted, { by, epoch, algorithm: signaturesOf(p.store).era }, publicKey, signaturesOf(p.store).admitted, signerFor(p.standing, by, signer, keyFile));
|
|
135
|
-
if (got.kind !== 'fact')
|
|
136
|
-
return refuse(got.why);
|
|
137
|
-
if (!selected.authority.authenticate(got.lines) || !selected.authority.authenticate(selectedPacket.records))
|
|
138
|
-
refuse('local context does not authenticate exported history');
|
|
139
|
-
return [...got.lines, ...selectedPacket.records, `EXCHANGE ${selectedPacket.touched} touched regions · ${selectedPacket.open} open regions · ${Buffer.byteLength(selectedPacket.records.join('\n') + (selectedPacket.records.length ? '\n' : ''))} payload bytes`];
|
|
140
|
-
}
|
|
141
|
-
/** The SDK proves the foreign prefix; the host admits the pair at one publication point. */
|
|
142
|
-
export async function landWalk(root, lines, key, keyFile, signer) {
|
|
143
|
-
const p = policy(root), info = headerInfo(lines), selected = context(root, info.pin);
|
|
144
|
-
const retained = await verifiedIngress(root);
|
|
145
|
-
if (retained.some(prior => prior.origin === selected.origin && prior.context !== info.pin))
|
|
146
|
-
refuse('origin context changed without declared lineage');
|
|
147
|
-
const previous = (verified) => { const prefixes = new Map(); for (const prior of verified.filter(got => got.origin === selected.origin).sort((a, b) => a.senderEpoch - b.senderEpoch))
|
|
148
|
-
for (const region of prior.regions)
|
|
149
|
-
prefixes.set(region.scope, { ...region, senderEpoch: prior.senderEpoch }); return [...prefixes.values()]; };
|
|
150
|
-
const payload = lines.filter(line => !isWalkHeader(line));
|
|
151
|
-
const proof = (prefixes) => readForeignWalk(lines, { origin: selected.origin, regionOrigin: selected.origin, context: info.pin, base: info.base, fields: selected.contract.fields, partition: selected.contract.partition, digest: p.digest, previousPrefixes: prefixes, authenticatePrefix: selected.authority.authenticate, authenticateEvidence: selected.authority.authenticate, validateOriginHistory: () => true });
|
|
152
|
-
const raw = proof([]), known = retained.find(prior => prior.identity === raw.identity), got = known ? raw : proof(previous(retained));
|
|
153
|
-
const history = (prior) => [...new Set([...prior.filter(item => item.origin === selected.origin).flatMap(item => item.records), ...payload])];
|
|
154
|
-
await validateHistory(root, selected, history(retained));
|
|
155
|
-
if (!known && info.base !== (await inventory(root)).root)
|
|
156
|
-
refuse('stale receiver base');
|
|
157
|
-
if (!payload.length && !readWalkHeaders(lines, info.pin, info.base, selected.authority.authenticate).regions.length)
|
|
158
|
-
return ['ONCE 0 new evidence lines · 0 import receipts · no regions offered', `EXCHANGE 0 payload bytes · ${Buffer.byteLength(lines.join('\n') + '\n')} protocol bytes · 0 new evidence bytes · 0 new receipt bytes`];
|
|
159
|
-
const by = key ?? ownerOf(p.store), pub = publicKeyOf(root, by);
|
|
160
|
-
if (!pub)
|
|
161
|
-
refuse('unknown receiver signer ' + by);
|
|
162
|
-
const result = await commitIngress(p.store, got.identity, async () => {
|
|
163
|
-
if (info.base !== (await inventory(root)).root)
|
|
164
|
-
refuse('receiver changed before ingress');
|
|
165
|
-
const current = await verifiedIngress(root);
|
|
166
|
-
proof(previous(current));
|
|
167
|
-
await validateHistory(root, selected, history(current));
|
|
168
|
-
const next = epochOf(localActLines(root)) + 1;
|
|
169
|
-
const signed = await signConsentLot([got.importReceiptProposal], { by, epoch: next, algorithm: signaturesOf(p.store).era }, pub, signaturesOf(p.store).admitted, signerFor(p.standing, by, signer, keyFile));
|
|
170
|
-
if (signed.kind !== 'fact')
|
|
171
|
-
return refuse(signed.why);
|
|
172
|
-
const authority = authorityFor(lockLines(p.store), rootSigner(root), signaturesOf(p.store).admitted);
|
|
173
|
-
if (authority.of(signed.lines[0]).kind !== 'admitted')
|
|
174
|
-
refuse('receiver signer does not cover the import receipt');
|
|
175
|
-
const grammar = fromLine(signed.lines[0], wireAt(p.standing.map(fields), next));
|
|
176
|
-
if (grammar.kind !== 'fact')
|
|
177
|
-
refuse('receiver receipt wire ' + grammar.why);
|
|
178
|
-
return { evidence: lines.join('\n') + '\n', receipt: signed.lines.join('\n') + '\n' };
|
|
179
|
-
}, bundle => {
|
|
180
|
-
try {
|
|
181
|
-
const retainedLines = bundle.evidence.split('\n').filter(Boolean), retainedInfo = headerInfo(retainedLines);
|
|
182
|
-
if (retainedInfo.pin !== info.pin)
|
|
183
|
-
return false;
|
|
184
|
-
const retainedProof = readForeignWalk(retainedLines, { origin: selected.origin, regionOrigin: selected.origin, context: info.pin, base: retainedInfo.base, fields: selected.contract.fields, partition: selected.contract.partition, digest: p.digest, previousPrefixes: [], authenticatePrefix: selected.authority.authenticate, authenticateEvidence: selected.authority.authenticate, validateOriginHistory: () => true });
|
|
185
|
-
const receipts = bundle.receipt.split('\n').filter(Boolean), receipt = receipts[0] ?? '';
|
|
186
|
-
return receipts.length === 1 && retainedProof.identity === got.identity && fieldOf(receipt, 'scope') === 'receipts' && fieldOf(receipt, 'value') === got.identity && fieldOf(receipt, 'at') === 'receipt:' + info.pin && authorityFor(lockLines(p.store), rootSigner(root), signaturesOf(p.store).admitted).of(receipt).kind === 'admitted';
|
|
187
|
-
}
|
|
188
|
-
catch {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
return [`${result.kind === 'once' ? 'ONCE' : 'INGRESS'} ${result.kind === 'once' ? 0 : got.records.length} new evidence lines · 1 ${result.kind === 'once' ? 'retained' : 'signed local'} import receipt`, result.receipt.trim(), ingressCost(result, Buffer.byteLength(payload.join('\n') + (payload.length ? '\n' : '')), Buffer.byteLength(lines.filter(isWalkHeader).join('\n') + '\n'))];
|
|
193
|
-
}
|
|
1
|
+
var it=Object.defineProperty;var l=(t,e)=>it(t,"name",{value:e,configurable:!0});import{library10_walkProjection as nt,library10_walkAt as rt,library10_walkSnapshot as M,library10_walkHeaders as ot,library10_readWalkHeaders as U,library10_readForeignWalk as $,library10_walkAuthority as at,library10_walkOrigin as st,library10_walkInventory as ct,library10_walkSelection as z,library10_isWalkHeader as G}from"../vendor/runtime.js";import{library11_canonical as R,library11_parse as dt,library11_fromLine as J,library11_wireAt as X,library11_matches as lt,library11_objectHistory as ft,library11_validateObjectContext as pt}from"../vendor/runtime.js";import{objectProvider as gt}from"../vendor/object-provider.js";import{library7_standingBytes as ut}from"../vendor/runtime.js";import{fieldOf as p}from"../fold/claims.js";import{lockStanding as ht,lockLines as L}from"../fold/keys.js";import{authorityFor as W,rootSigner as I}from"../fold/signers.js";import{publicKeyOf as Q}from"../fold/signers.js";import{signaturesOf as v}from"../fold/digests.js";import{fullDigest as yt}from"./digest.js";import{toposAt as wt,contextProviderServices as mt}from"./selected-topos.js";import{signerFor as V}from"./signing.js";import{signConsentLot as Y,verifiesFields as kt}from"../land/sign.js";import{storeOf as K}from"../land/ledger.js";import{signedOwnerLines as bt,epochOf as C,localActLines as Z,ownerOf as tt}from"../cli/owner.js";import{commitIngress as vt,ingressBundles as xt,ingressCost as Et}from"./ports/ingress.js";const d=l(t=>{throw Error("REFUSE\xB7walk "+t)},"refuse"),q=l(t=>{const e=dt(t);return e.kind!=="fact"?d("not a wire line"):e.value.fields},"fields"),N=l((t,e,a)=>{const c=t.filter(o=>p(o,"scope")===e&&p(o,"measure")===a&&p(o,"value")!=="withdraw");return c.length!==1?d("missing or conflicting "+e+" "+a):p(c[0],"value")},"one");function O(t){const e=K(t),a=ht(e),c=z(a);N(a,"view/walk","id")!=="walk@*"&&d("view/walk must declare walk@*");const r=a.filter(s=>p(s,"scope")==="view/walk").flatMap(s=>p(s,"needs").split("|")).filter(Boolean);r.length||d("view/walk has no declared history inputs");const i=X(a.map(q),Number.MAX_SAFE_INTEGER),n=i?.digests.values().next().value;return n||d("no admitted digest algorithm"),{store:e,standing:a,contract:c,masks:r,digest:l(s=>yt(s,n),"digest")}}l(O,"policy");function E(t,e,a=!1){const c=O(t);!a&&!c.standing.some(n=>p(n,"scope").startsWith("uses/")&&p(n,"value")===e)&&d("origin context is not selected by digest");const o=wt(e,c.store),r=at(o.parts,kt),i=o.parts.map(n=>R({...n,by:"target",epoch:"0"}));return{pin:e,topos:o,authority:r,configuration:i,origin:st(o.parts),contract:z(o.lines)}}l(E,"context");function et(t){const e=O(t),a=W(L(e.store),I(t),v(e.store).admitted),c=bt(e.store).filter(r=>e.masks.some(i=>lt(i,p(r,"scope"))));c.some(r=>a.of(r).kind!=="admitted")&&d("local history is not authenticated");const o=E(t,N(e.standing,"walk/context","digest"),!0);return M(c,o.contract.fields,e.digest,o.origin,o.contract.partition)}l(et,"local");const B=l(t=>{const e=t.filter(c=>G(c)&&p(c,"scope")==="walk/root");if(e.length!==1)return d("one signed root is required");const a=p(e[0],"at");return a.startsWith("receipt:")?{pin:a.slice(8),base:p(e[0],"condition")}:d("root has no declared context")},"headerInfo");async function D(t,e,a){e.authority.authenticate(a)||d("origin history is not authenticated");for(const s of a){const g=q(s),y=J(s,X(e.topos.parts,Number(g.epoch)));y.kind!=="fact"&&d("origin wire "+y.why)}const c=ft([...e.configuration,...a]);if(c.kind!=="fact")return d("origin history "+c.why);if(!c.value.objects.length)return;const o=new Set(e.topos.lines),r=l(s=>s.sig?e.authority.of(R(s)).kind==="admitted":o.has(ut([R(s)]).trim()),"admit"),i=await gt(c.value.objects,c.value.configuration,{admit:r,emit:l(()=>{},"emit"),...mt(K(t))}),n=pt(c.value.objects,i);n.kind!=="fact"&&d("origin context "+n.why)}l(D,"validateHistory");async function _t(t,e,a=[]){const c=e.evidence.split(`
|
|
2
|
+
`).filter(Boolean),o=B(c),r=O(t),i=e.receipt.split(`
|
|
3
|
+
`).filter(Boolean),n=W(L(r.store),I(t),v(r.store).admitted);(i.length!==1||p(i[0],"scope")!=="receipts"||p(i[0],"role")!=="writes"||p(i[0],"form")!=="alphabet"||p(i[0],"measure")!=="digest"||p(i[0],"at")!=="receipt:"+o.pin||n.of(i[0]).kind!=="admitted")&&d("retained import receipt is not authenticated");const s=E(t,o.pin),g=$(c,{origin:s.origin,regionOrigin:s.origin,context:o.pin,base:o.base,fields:s.contract.fields,partition:s.contract.partition,digest:r.digest,previousPrefixes:[],authenticatePrefix:s.authority.authenticate,authenticateEvidence:s.authority.authenticate,validateOriginHistory:l(()=>!0,"validateOriginHistory")});return p(i[0],"value")!==g.identity&&d("retained import receipt does not authenticate this ingress"),await D(t,s,[...new Set([...a,...g.records])]),{...g,context:o.pin,regions:M(g.records,s.contract.fields,r.digest,g.origin,s.contract.partition).regions}}l(_t,"readBundle");async function F(t){const e=[],a=new Map,c=[...xt(K(t))].sort((o,r)=>C(o.receipt.split(`
|
|
4
|
+
`))-C(r.receipt.split(`
|
|
5
|
+
`)));for(const o of c){const r=B(o.evidence.split(`
|
|
6
|
+
`).filter(Boolean)),i=E(t,r.pin).origin;e.some(g=>g.origin===i&&g.context!==r.pin)&&d("origin context changed without declared lineage");const n=a.get(i)??new Set,s=await _t(t,o,[...n]);for(const g of s.records)n.add(g);a.set(i,n),e.push(s)}return e}l(F,"verifiedIngress");async function T(t){const e=O(t),a=new Map(et(t).regions.map(c=>[c.scope,c]));for(const c of(await F(t)).sort((o,r)=>o.senderEpoch-r.senderEpoch))for(const o of c.regions)a.set(o.scope,o);return ct([[...a.values()]],e.digest,E(t,N(e.standing,"walk/context","digest"),!0).contract.partition)}l(T,"inventory");async function Xt(t){const e=await F(t);return[...new Set(e.flatMap(a=>a.records))]}l(Xt,"foreignWalkLines");async function Kt(t,e,a,c,o,r){const i=O(t),n=N(i.standing,"walk/context","digest"),s=E(t,n,!0),g=et(t),y=a.length?(()=>{const f=B(a),u=E(t,f.pin);return U(a,f.pin,f.base,u.authority.authenticate)})():M([],i.contract.fields,i.digest),_=nt(s.contract.projections,e),H=_==="history"?g:await T(t),w=rt(H,y,e,s.contract.projections),m=c??tt(i.store),S=Q(t,m);S||d("unknown local signer "+m);const j=ot(w,n,y.root,_!=="inventory"),P=C(Z(t)),k=await Y(j,{by:m,epoch:P,algorithm:v(i.store).era},S,v(i.store).admitted,V(i.standing,m,r,o));return k.kind!=="fact"?d(k.why):((!s.authority.authenticate(k.lines)||!s.authority.authenticate(w.records))&&d("local context does not authenticate exported history"),[...k.lines,...w.records,`EXCHANGE ${w.touched} touched regions \xB7 ${w.open} open regions \xB7 ${Buffer.byteLength(w.records.join(`
|
|
7
|
+
`)+(w.records.length?`
|
|
8
|
+
`:""))} payload bytes`])}l(Kt,"renderWalk");async function qt(t,e,a,c,o){const r=O(t),i=B(e),n=E(t,i.pin),s=await F(t);s.some(f=>f.origin===n.origin&&f.context!==i.pin)&&d("origin context changed without declared lineage");const g=l(f=>{const u=new Map;for(const h of f.filter(b=>b.origin===n.origin).sort((b,x)=>b.senderEpoch-x.senderEpoch))for(const b of h.regions)u.set(b.scope,{...b,senderEpoch:h.senderEpoch});return[...u.values()]},"previous"),y=e.filter(f=>!G(f)),_=l(f=>$(e,{origin:n.origin,regionOrigin:n.origin,context:i.pin,base:i.base,fields:n.contract.fields,partition:n.contract.partition,digest:r.digest,previousPrefixes:f,authenticatePrefix:n.authority.authenticate,authenticateEvidence:n.authority.authenticate,validateOriginHistory:l(()=>!0,"validateOriginHistory")}),"proof"),H=_([]),w=s.find(f=>f.identity===H.identity),m=w?H:_(g(s)),S=l(f=>[...new Set([...f.filter(u=>u.origin===n.origin).flatMap(u=>u.records),...y])],"history");if(await D(t,n,S(s)),!w&&i.base!==(await T(t)).root&&d("stale receiver base"),!y.length&&!U(e,i.pin,i.base,n.authority.authenticate).regions.length)return["ONCE 0 new evidence lines \xB7 0 import receipts \xB7 no regions offered",`EXCHANGE 0 payload bytes \xB7 ${Buffer.byteLength(e.join(`
|
|
9
|
+
`)+`
|
|
10
|
+
`)} protocol bytes \xB7 0 new evidence bytes \xB7 0 new receipt bytes`];const j=a??tt(r.store),P=Q(t,j);P||d("unknown receiver signer "+j);const k=await vt(r.store,m.identity,async()=>{i.base!==(await T(t)).root&&d("receiver changed before ingress");const f=await F(t);_(g(f)),await D(t,n,S(f));const u=C(Z(t))+1,h=await Y([m.importReceiptProposal],{by:j,epoch:u,algorithm:v(r.store).era},P,v(r.store).admitted,V(r.standing,j,o,c));if(h.kind!=="fact")return d(h.why);W(L(r.store),I(t),v(r.store).admitted).of(h.lines[0]).kind!=="admitted"&&d("receiver signer does not cover the import receipt");const x=J(h.lines[0],X(r.standing.map(q),u));return x.kind!=="fact"&&d("receiver receipt wire "+x.why),{evidence:e.join(`
|
|
11
|
+
`)+`
|
|
12
|
+
`,receipt:h.lines.join(`
|
|
13
|
+
`)+`
|
|
14
|
+
`}},f=>{try{const u=f.evidence.split(`
|
|
15
|
+
`).filter(Boolean),h=B(u);if(h.pin!==i.pin)return!1;const b=$(u,{origin:n.origin,regionOrigin:n.origin,context:i.pin,base:h.base,fields:n.contract.fields,partition:n.contract.partition,digest:r.digest,previousPrefixes:[],authenticatePrefix:n.authority.authenticate,authenticateEvidence:n.authority.authenticate,validateOriginHistory:l(()=>!0,"validateOriginHistory")}),x=f.receipt.split(`
|
|
16
|
+
`).filter(Boolean),A=x[0]??"";return x.length===1&&b.identity===m.identity&&p(A,"scope")==="receipts"&&p(A,"value")===m.identity&&p(A,"at")==="receipt:"+i.pin&&W(L(r.store),I(t),v(r.store).admitted).of(A).kind==="admitted"}catch{return!1}});return[`${k.kind==="once"?"ONCE":"INGRESS"} ${k.kind==="once"?0:m.records.length} new evidence lines \xB7 1 ${k.kind==="once"?"retained":"signed local"} import receipt`,k.receipt.trim(),Et(k,Buffer.byteLength(y.join(`
|
|
17
|
+
`)+(y.length?`
|
|
18
|
+
`:"")),Buffer.byteLength(e.filter(G).join(`
|
|
19
|
+
`)+`
|
|
20
|
+
`))]}l(qt,"landWalk");export{Xt as foreignWalkLines,qt as landWalk,Kt as renderWalk};
|