@lapxo/bound 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CITATION.cff +1 -1
- package/TARGET.bound +44 -39
- package/dist/cli/accept.js +72 -590
- package/dist/cli/act-result.js +3 -103
- package/dist/cli/args.js +3 -44
- package/dist/cli/custodian.js +2 -29
- package/dist/cli/host.js +4 -32
- package/dist/cli/names.js +1 -12
- package/dist/cli/native-descendant.js +1 -19
- package/dist/cli/native.js +3 -60
- package/dist/cli/observe.js +1 -13
- package/dist/cli/owner.js +3 -139
- package/dist/cli/pass.js +21 -321
- package/dist/cli/place.js +6 -282
- package/dist/cli/release-result.js +3 -80
- package/dist/cli/retained-judgment.js +1 -25
- package/dist/cli/standing-result.js +4 -19
- package/dist/cli/takes.js +10 -112
- package/dist/cli/verb.d.ts +1 -2
- package/dist/cli/verb.js +83 -684
- package/dist/engine/computation.js +2 -0
- package/dist/engine/conformance.js +4 -0
- package/dist/engine/encoding.js +1 -2
- package/dist/engine/index.d.ts +1 -13
- package/dist/engine/index.js +2 -11
- package/dist/engine/object.js +1 -38
- package/dist/engine/ports.js +2 -117
- package/dist/fold/admission-history.js +1 -17
- package/dist/fold/bootstrap-anchor.js +1 -28
- package/dist/fold/ceilings.js +1 -142
- package/dist/fold/claims.js +2 -132
- package/dist/fold/closed.js +24 -235
- package/dist/fold/configures.js +1 -25
- package/dist/fold/digests.js +10 -226
- package/dist/fold/evidence.js +1 -22
- package/dist/fold/fold-worker.js +1 -13
- package/dist/fold/kept.js +12 -173
- package/dist/fold/keys.js +3 -91
- package/dist/fold/laid.js +3 -90
- package/dist/fold/nos.js +1 -48
- package/dist/fold/object.js +1 -2
- package/dist/fold/observed.js +27 -534
- package/dist/fold/opened.js +1 -33
- package/dist/fold/own.js +3 -217
- package/dist/fold/paid.js +1 -92
- package/dist/fold/place-inputs.js +1 -70
- package/dist/fold/places.js +3 -100
- package/dist/fold/rank.js +1 -9
- package/dist/fold/reach.js +1 -83
- package/dist/fold/readers.js +6 -142
- package/dist/fold/receipts.js +1 -47
- package/dist/fold/region-declarations.js +1 -13
- package/dist/fold/region.js +8 -286
- package/dist/fold/release-policy.js +1 -101
- package/dist/fold/resolved.js +6 -145
- package/dist/fold/roles.js +2 -59
- package/dist/fold/second.js +4 -71
- package/dist/fold/shards.js +12 -100
- package/dist/fold/signed.js +3 -81
- package/dist/fold/signers.js +1 -54
- package/dist/fold/stranger.js +6 -24
- package/dist/fold/views.js +1 -66
- package/dist/fold/wire.js +1 -46
- package/dist/fold/zoom.js +3 -81
- package/dist/host/act-cost.js +1 -25
- package/dist/host/adapters/keys/ed25519.js +1 -30
- package/dist/host/adapters/modules/javascript.js +1 -50
- package/dist/host/adapters/transport/http.js +1 -28
- package/dist/host/admitted-place.js +1 -35
- package/dist/host/archive.js +1 -152
- package/dist/host/call-context.js +1 -14
- package/dist/host/capsule-process.js +2 -62
- package/dist/host/capsule.js +9 -171
- package/dist/host/cell-receipts.js +12 -128
- package/dist/host/commit-result.js +1 -5
- package/dist/host/content-needed.js +1 -8
- package/dist/host/content-store.js +1 -31
- package/dist/host/contextual-place.js +2 -72
- package/dist/host/digest.js +2 -15
- package/dist/host/hash.js +1 -9
- package/dist/host/host-controls.js +1 -19
- package/dist/host/in-process-act.js +3 -84
- package/dist/host/in-process-context.js +3 -91
- package/dist/host/in-process-root.js +6 -84
- package/dist/host/in-process.js +4 -55
- package/dist/host/index.d.ts +1 -15
- package/dist/host/index.js +1 -7
- package/dist/host/io.js +1 -11
- package/dist/host/lifetime.js +1 -79
- package/dist/host/located.js +6 -105
- package/dist/host/native/bounded-file.js +1 -32
- package/dist/host/native/command.js +1 -91
- package/dist/host/native/control-bridge-worker.js +2 -88
- package/dist/host/native/control-bridge.js +1 -110
- package/dist/host/native/control-selection.js +1 -32
- package/dist/host/native/custody.js +1 -91
- package/dist/host/native/deadline.js +1 -28
- package/dist/host/native/descendants.js +1 -528
- package/dist/host/native/generated-custodian.js +5 -267
- package/dist/host/native/generated.js +1 -379
- package/dist/host/native/image.js +1 -45
- package/dist/host/native/jobs.js +2 -148
- package/dist/host/native/loader.js +1 -269
- package/dist/host/native/materialize.js +1 -175
- package/dist/host/native/module-closure.js +1 -130
- package/dist/host/native/module-delivery.d.ts +1 -62
- package/dist/host/native/module-delivery.js +1 -151
- package/dist/host/native/module-syntax.js +1 -69
- package/dist/host/native/native-binary.js +1 -115
- package/dist/host/native/native-program.js +1 -72
- package/dist/host/native/node-jobs.js +3 -187
- package/dist/host/native/node-launch.js +1 -159
- package/dist/host/native/preload.js +1 -45
- package/dist/host/native/reading.js +1 -249
- package/dist/host/native/receipt-environment.js +1 -41
- package/dist/host/native/references.js +1 -30
- package/dist/host/native/root.js +1 -37
- package/dist/host/native/route.js +1 -216
- package/dist/host/native/runtime.js +1 -9
- package/dist/host/native-reader-context.js +1 -8
- package/dist/host/native-receiver.js +1 -25
- package/dist/host/objects.js +1 -38
- package/dist/host/order.js +1 -2
- package/dist/host/place-act-transaction.js +4 -78
- package/dist/host/place-clock-selection.js +5 -124
- package/dist/host/ports/ingress.js +2 -57
- package/dist/host/ports/local-act.js +5 -183
- package/dist/host/ports/place-act.js +1 -134
- package/dist/host/ports/publication.js +1 -56
- package/dist/host/ports/signing.js +1 -74
- package/dist/host/ports/store.js +1 -18
- package/dist/host/ports/transport.js +1 -48
- package/dist/host/process-lifetime.js +1 -17
- package/dist/host/provide.js +1 -183
- package/dist/host/read-only.js +1 -9
- package/dist/host/reading-closures.js +7 -227
- package/dist/host/reading-context.js +1 -53
- package/dist/host/reading-identity-types.js +0 -0
- package/dist/host/reading-identity.js +3 -0
- package/dist/host/reading-preparation.js +6 -0
- package/dist/host/reference-authenticated.d.ts +1 -40
- package/dist/host/reference-authenticated.js +3 -100
- package/dist/host/reference-contracts.js +1 -6
- package/dist/host/reference-export.js +6 -81
- package/dist/host/reference-native-api.d.ts +1 -3
- package/dist/host/reference-native-api.js +1 -3
- package/dist/host/reference-native.js +1 -74
- package/dist/host/reference-profile.js +1 -63
- package/dist/host/reference-standing.js +2 -18
- package/dist/host/reference.js +1 -24
- package/dist/host/refusals.js +2 -43
- package/dist/host/release.js +4 -256
- package/dist/host/root-clock-source.js +1 -307
- package/dist/host/selected-capsules.js +1 -50
- package/dist/host/selected-topos.js +1 -80
- package/dist/host/signature-era.js +1 -12
- package/dist/host/signing.js +2 -48
- package/dist/host/source-content.js +2 -111
- package/dist/host/standing-carrier.js +1 -18
- package/dist/host/standing-projection.js +1 -50
- package/dist/host/timing.js +1 -7
- package/dist/host/walk.js +20 -193
- package/dist/judge/late.js +1 -33
- package/dist/judge/take.js +2 -75
- package/dist/judge/widening.js +1 -25
- package/dist/land/act.js +8 -336
- package/dist/land/alias.js +1 -41
- package/dist/land/held.js +1 -23
- package/dist/land/inert.js +1 -33
- package/dist/land/leaving.js +1 -55
- package/dist/land/ledger.js +7 -188
- package/dist/land/owned.js +4 -66
- package/dist/land/sign.js +1 -53
- package/dist/land/standing-pin.js +1 -49
- package/dist/land/vouched.js +1 -112
- package/dist/land/withdraw.js +1 -24
- package/dist/observe/files.js +1 -88
- package/dist/observe/identity.js +1 -61
- package/dist/observe/match.js +1 -8
- package/dist/observe/regions.js +7 -306
- package/dist/observe/run.js +2 -41
- package/dist/observe/runner.js +4 -101
- package/dist/public-types.d.ts +1114 -0
- package/dist/render/capsule.js +1 -30
- package/dist/render/field.js +1 -40
- package/dist/render/names.js +1 -4
- package/dist/render/open.js +1 -61
- package/dist/render/page.js +1 -7
- package/dist/render/receipts.js +1 -47
- package/dist/render/shape.js +1 -74
- package/dist/render/target.js +4 -52
- package/dist/render/view.js +7 -197
- package/dist/vendor/50086958553b9376d600583f7dff354196bfeb41170fc6d1482ca7bea7c493e2.LICENSE +21 -0
- package/dist/vendor/b3e938d28f88a1851af303a40c749e12ebd5a686daac4f0b343b5cdd2e040419.LICENSE +21 -0
- package/dist/vendor/bundle.json +1 -0
- package/dist/vendor/library11.js +1 -0
- package/dist/vendor/object-provider.js +42 -0
- package/dist/vendor/runtime.js +38 -0
- package/dist/vendor/sources.json +1 -0
- package/dist/wasm/adapter.d.ts +1 -51
- package/dist/wasm/adapter.js +1 -180
- package/dist/wasm/node-worker.js +1 -13
- package/dist/wasm/object.js +1 -76
- package/dist/wasm/worker.js +1 -7
- package/docs/contracts/closure-delivery.md +1 -1
- package/docs/contracts/closure-delivery.publication.json +1 -1
- package/docs/contracts/conformance.json +142 -0
- package/docs/contracts/determinism.bound +9 -0
- package/docs/contracts/engine-object-projection.publication.json +1 -1
- package/docs/contracts/engine.md +21 -1
- package/docs/contracts/native-publication.inventory.json +2 -1
- package/docs/contracts/optional-wasm-adapter.publication.json +1 -1
- package/docs/contracts/reading-identity.md +37 -0
- package/docs/contracts/reading-identity.publication.json +25 -0
- package/docs/contracts/refusals.bound +51 -0
- package/docs/contracts/refusals.md +18 -3
- package/docs/contracts/refusals.publication.json +2 -2
- package/docs/contracts/views.md +8 -0
- package/docs/reference.md +1 -0
- package/package.json +23 -34
- package/receipts.bound +11627 -10323
- package/samples/reading-identity/no.json +20 -0
- package/samples/reading-identity/yes.json +46 -0
- package/vectors/native/reading-identity.vector.json +101 -0
- package/vectors/native/refusals.vector.json +104 -0
- package/vendor/syntax/LICENSE.md +7 -0
- package/vendor/syntax/parser.js +1 -0
- package/.github/workflows/release.yml +0 -67
- package/.github/workflows/test.yml +0 -35
- package/dist/engine/object.d.ts +0 -17
- package/dist/engine/ports.d.ts +0 -37
- package/dist/fold/claims.d.ts +0 -29
- package/dist/host/call-context.d.ts +0 -20
- package/dist/host/commit-result.d.ts +0 -6
- package/dist/host/in-process-act.d.ts +0 -82
- package/dist/host/in-process-context.d.ts +0 -46
- package/dist/host/in-process-root.d.ts +0 -117
- package/dist/host/in-process.d.ts +0 -41
- package/dist/host/native/module-closure.d.ts +0 -35
- package/dist/host/native-receiver.d.ts +0 -19
- package/dist/host/place-act-transaction.d.ts +0 -24
- package/dist/host/place-clock-selection.d.ts +0 -55
- package/dist/host/ports/local-act.d.ts +0 -44
- package/dist/host/ports/place-act.d.ts +0 -49
- package/dist/host/ports/publication.d.ts +0 -10
- package/dist/host/reference-export.d.ts +0 -33
- package/dist/host/reference-native.d.ts +0 -30
- package/dist/host/reference-profile.d.ts +0 -23
- package/dist/host/refusals.d.ts +0 -14
- package/dist/host/root-clock-source.d.ts +0 -86
package/dist/cli/act-result.js
CHANGED
|
@@ -1,103 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { actResultOf, actResultProfile } from '@lapxo/topos/wire';
|
|
5
|
-
import { actLines, intactLocalAct, localActResult } from "../host/ports/local-act.js";
|
|
6
|
-
import { storeOf } from "../land/ledger.js";
|
|
7
|
-
import { lockStanding } from "../fold/keys.js";
|
|
8
|
-
import { authorityFor, writerFor } from "../fold/signers.js";
|
|
9
|
-
import { eraOf } from "../fold/digests.js";
|
|
10
|
-
import { fieldOf, isConfig, foldClaims, parsedLine } from "../fold/claims.js";
|
|
11
|
-
import { ownRecordAdmitted } from "../fold/signed.js";
|
|
12
|
-
import { admissionAnchor, admissionHistoryAt } from "../fold/admission-history.js";
|
|
13
|
-
import { fullDigest } from "../host/digest.js";
|
|
14
|
-
import { wordOf, wireLine } from "../fold/wire.js";
|
|
15
|
-
import { viewsOf } from "../fold/views.js";
|
|
16
|
-
/** Historical proof only. Exact current bodies, admission history and bootstrap
|
|
17
|
-
* anchor are reread before lookup; this never retains a current command grant. */
|
|
18
|
-
const historicalProofs = new WeakMap();
|
|
19
|
-
function proofFingerprint(identity, bundle, history, anchor, algorithms) {
|
|
20
|
-
const hash = createHash('sha256'), text = hashText.bind(undefined, hash);
|
|
21
|
-
text('legacy-act-historical-proof/1');
|
|
22
|
-
text(identity);
|
|
23
|
-
text(bundle.records);
|
|
24
|
-
text(bundle.receipt);
|
|
25
|
-
text(bundle.placements === undefined ? 'absent' : 'present');
|
|
26
|
-
text(String(bundle.placements?.length ?? 0));
|
|
27
|
-
for (const placement of bundle.placements ?? []) {
|
|
28
|
-
text(placement.place);
|
|
29
|
-
text(placement.records);
|
|
30
|
-
}
|
|
31
|
-
text(String(history.length));
|
|
32
|
-
for (const line of history)
|
|
33
|
-
text(line);
|
|
34
|
-
text(JSON.stringify(anchor));
|
|
35
|
-
text(String(algorithms.length));
|
|
36
|
-
for (const algorithm of algorithms)
|
|
37
|
-
text(algorithm);
|
|
38
|
-
return hash.digest('hex');
|
|
39
|
-
}
|
|
40
|
-
const freshResult = (result) => ({ ...result, records: [...result.records] });
|
|
41
|
-
/** Public query of a committed identity, using the same admission authority.
|
|
42
|
-
* Native fold evidence has store provenance; it never grants coverage. */
|
|
43
|
-
export function verifiedLegacyActResult(root, identity) {
|
|
44
|
-
const store = storeOf(root);
|
|
45
|
-
let observation;
|
|
46
|
-
const bundle = localActResult(store, identity, (id, current) => {
|
|
47
|
-
const receipt = parsedLine(current.receipt.trim());
|
|
48
|
-
if (receipt.kind !== 'fact')
|
|
49
|
-
return intactLocalAct(id, current);
|
|
50
|
-
const epoch = Number(fieldOf(current.receipt.trim(), 'epoch'));
|
|
51
|
-
const history = admissionHistoryAt(root, epoch), before = history.filter(line => !isConfig(line) || Number(fieldOf(line, 'epoch')) < epoch);
|
|
52
|
-
const algorithms = eraOf(foldClaims(before).standing).admitted, anchor = admissionAnchor(root);
|
|
53
|
-
const fingerprint = proofFingerprint(id, current, history, anchor, algorithms), cached = historicalProofs.get(receipt.value);
|
|
54
|
-
const retained = cached?.fingerprint === fingerprint ? cached.result : undefined;
|
|
55
|
-
observation = { epoch, history, before, algorithms, anchor, key: receipt.value, fingerprint, ...(retained ? { retained } : {}) };
|
|
56
|
-
return retained !== undefined || intactLocalAct(id, current);
|
|
57
|
-
});
|
|
58
|
-
if (!bundle)
|
|
59
|
-
throw Error('REFUSE·act no committed result ' + identity);
|
|
60
|
-
if (!observation)
|
|
61
|
-
throw Error('REFUSE·act historical proof observation absent');
|
|
62
|
-
const records = actLines(bundle.records), { epoch, history, before, algorithms, anchor, retained } = observation;
|
|
63
|
-
if (retained)
|
|
64
|
-
return { result: freshResult(retained), bundle, records, epoch, history };
|
|
65
|
-
const authority = authorityFor(history, anchor, algorithms);
|
|
66
|
-
const admittedBefore = foldClaims(before.filter(line => authority.of(line).kind === 'admitted')).standing;
|
|
67
|
-
const profile = actResultProfile(admittedBefore);
|
|
68
|
-
if (!profile)
|
|
69
|
-
throw Error('REFUSE·act no result profile at admission');
|
|
70
|
-
const family = authority.admitted.some(signer => !signer.coverage.includes('*')) ? wordOf(admittedBefore, 'families', 'region') : '';
|
|
71
|
-
const algorithm = identity.slice(0, identity.indexOf(':'));
|
|
72
|
-
const named = fieldOf(wireLine(admittedBefore, 'digest-algorithms') ?? '', 'value').split('|').map(value => value.split(':')[0]);
|
|
73
|
-
if (!named.includes(algorithm))
|
|
74
|
-
throw Error('REFUSE·act digest algorithm was not admitted at commitment');
|
|
75
|
-
const result = actResultOf(records, bundle.receipt.trim(), { ...profile, localEpoch: epoch,
|
|
76
|
-
digest: bytes => fullDigest(bytes, algorithm),
|
|
77
|
-
placements: bundle.placements.map(p => ({ place: p.place, records: actLines(p.records) })),
|
|
78
|
-
admitsRecord: line => {
|
|
79
|
-
if (isConfig(line) && Number(fieldOf(line, 'epoch')) !== epoch)
|
|
80
|
-
return false;
|
|
81
|
-
return bundle.placements.some(p => actLines(p.records).includes(line) && (p.place === '.' ? authority.of(line).kind === 'admitted' : ownRecordAdmitted(line, p.place.slice(0, p.place.lastIndexOf('/')), family, authority.admitted, algorithms)));
|
|
82
|
-
},
|
|
83
|
-
verifiesReceipt: line => fieldOf(line, 'by') === writerFor(admittedBefore, 'fold') && intactLocalAct(identity, bundle), });
|
|
84
|
-
const kept = Object.freeze({ ...result, records: Object.freeze([...result.records]) });
|
|
85
|
-
historicalProofs.set(observation.key, { fingerprint: observation.fingerprint, result: kept });
|
|
86
|
-
return { result: freshResult(kept), bundle, records, epoch, history };
|
|
87
|
-
}
|
|
88
|
-
export function printActResult(root, identity) {
|
|
89
|
-
const store = storeOf(root), standing = lockStanding(store), view = viewsOf(standing).get('act');
|
|
90
|
-
if (!view || view.shape || !view.regions.some(region => region.name === 'act'))
|
|
91
|
-
throw Error('REFUSE·view act requires an admitted result profile and act view');
|
|
92
|
-
if (!identity)
|
|
93
|
-
throw Error('REFUSE·act name one committed identity');
|
|
94
|
-
if (hasContextualPlace(root)) {
|
|
95
|
-
const contextual = contextualAct(root, identity);
|
|
96
|
-
if (contextual) {
|
|
97
|
-
process.stdout.write(JSON.stringify(contextual) + '\n');
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
const { result, bundle } = verifiedLegacyActResult(root, identity);
|
|
102
|
-
process.stdout.write(`ACT ${result.identity} · epoch ${result.epoch} · admitted · conformance not asserted\n` + bundle.records + bundle.receipt);
|
|
103
|
-
}
|
|
1
|
+
var $=Object.defineProperty;var f=(o,r)=>$(o,"name",{value:r,configurable:!0});import{hashText as q}from"../host/hash.js";import{hasContextualPlace as B,contextualAct as D}from"../host/contextual-place.js";import{createHash as I}from"node:crypto";import{library11_actResultOf as M,library11_actResultProfile as W}from"../vendor/runtime.js";import{actLines as w,intactLocalAct as R,localActResult as G}from"../host/ports/local-act.js";import{storeOf as C}from"../land/ledger.js";import{lockStanding as K}from"../fold/keys.js";import{authorityFor as Q,writerFor as V}from"../fold/signers.js";import{eraOf as X}from"../fold/digests.js";import{fieldOf as l,isConfig as P,foldClaims as j,parsedLine as Y}from"../fold/claims.js";import{ownRecordAdmitted as Z}from"../fold/signed.js";import{admissionAnchor as ee,admissionHistoryAt as te}from"../fold/admission-history.js";import{fullDigest as re}from"../host/digest.js";import{wordOf as oe,wireLine as ie}from"../fold/wire.js";import{viewsOf as se}from"../fold/views.js";const z=new WeakMap;function ce(o,r,m,n,i){const a=I("sha256"),t=q.bind(void 0,a);t("legacy-act-historical-proof/1"),t(o),t(r.records),t(r.receipt),t(r.placements===void 0?"absent":"present"),t(String(r.placements?.length??0));for(const s of r.placements??[])t(s.place),t(s.records);t(String(m.length));for(const s of m)t(s);t(JSON.stringify(n)),t(String(i.length));for(const s of i)t(s);return a.digest("hex")}f(ce,"proofFingerprint");const H=f(o=>({...o,records:[...o.records]}),"freshResult");function ne(o,r){const m=C(o);let n;const i=G(m,r,(e,c)=>{const u=Y(c.receipt.trim());if(u.kind!=="fact")return R(e,c);const h=Number(l(c.receipt.trim(),"epoch")),g=te(o,h),A=g.filter(N=>!P(N)||Number(l(N,"epoch"))<h),F=X(j(A).standing).admitted,k=ee(o),U=ce(e,c,g,k,F),L=z.get(u.value),E=L?.fingerprint===U?L.result:void 0;return n={epoch:h,history:g,before:A,algorithms:F,anchor:k,key:u.value,fingerprint:U,...E?{retained:E}:{}},E!==void 0||R(e,c)});if(!i)throw Error("REFUSE\xB7act no committed result "+r);if(!n)throw Error("REFUSE\xB7act historical proof observation absent");const a=w(i.records),{epoch:t,history:s,before:J,algorithms:b,anchor:T,retained:O}=n;if(O)return{result:H(O),bundle:i,records:a,epoch:t,history:s};const d=Q(s,T,b),p=j(J.filter(e=>d.of(e).kind==="admitted")).standing,v=W(p);if(!v)throw Error("REFUSE\xB7act no result profile at admission");const _=d.admitted.some(e=>!e.coverage.includes("*"))?oe(p,"families","region"):"",S=r.slice(0,r.indexOf(":"));if(!l(ie(p,"digest-algorithms")??"","value").split("|").map(e=>e.split(":")[0]).includes(S))throw Error("REFUSE\xB7act digest algorithm was not admitted at commitment");const x=M(a,i.receipt.trim(),{...v,localEpoch:t,digest:f(e=>re(e,S),"digest"),placements:i.placements.map(e=>({place:e.place,records:w(e.records)})),admitsRecord:f(e=>P(e)&&Number(l(e,"epoch"))!==t?!1:i.placements.some(c=>w(c.records).includes(e)&&(c.place==="."?d.of(e).kind==="admitted":Z(e,c.place.slice(0,c.place.lastIndexOf("/")),_,d.admitted,b))),"admitsRecord"),verifiesReceipt:f(e=>l(e,"by")===V(p,"fold")&&R(r,i),"verifiesReceipt")}),y=Object.freeze({...x,records:Object.freeze([...x.records])});return z.set(n.key,{fingerprint:n.fingerprint,result:y}),{result:H(y),bundle:i,records:a,epoch:t,history:s}}f(ne,"verifiedLegacyActResult");function ye(o,r){const m=C(o),n=K(m),i=se(n).get("act");if(!i||i.shape||!i.regions.some(s=>s.name==="act"))throw Error("REFUSE\xB7view act requires an admitted result profile and act view");if(!r)throw Error("REFUSE\xB7act name one committed identity");if(B(o)){const s=D(o,r);if(s){process.stdout.write(JSON.stringify(s)+`
|
|
2
|
+
`);return}}const{result:a,bundle:t}=ne(o,r);process.stdout.write(`ACT ${a.identity} \xB7 epoch ${a.epoch} \xB7 admitted \xB7 conformance not asserted
|
|
3
|
+
`+t.records+t.receipt)}f(ye,"printActResult");export{ye as printActResult,ne as verifiedLegacyActResult};
|
package/dist/cli/args.js
CHANGED
|
@@ -1,44 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { PROTOCOL, parse } from '@lapxo/topos/wire';
|
|
5
|
-
import { FLAGS, VALUED } from "./names.js";
|
|
6
|
-
export { VALUED };
|
|
7
|
-
/** What the loop runs that is not source: its entry, the packages it imports and the readers it loads, read by where they lie. */
|
|
8
|
-
export function entryOf(root) {
|
|
9
|
-
return relative(root, sourceOf()).split(sep).join('/');
|
|
10
|
-
}
|
|
11
|
-
export function valueOf(args, flag) {
|
|
12
|
-
const i = args.indexOf(flag);
|
|
13
|
-
return i >= 0 ? args[i + 1] : undefined;
|
|
14
|
-
}
|
|
15
|
-
export const valuesOf = (args, flag) => args.flatMap((arg, i) => (arg === flag && args[i + 1] !== undefined ? [args[i + 1]] : []));
|
|
16
|
-
export const namedPlaces = (args) => valuesOf(args, FLAGS.place).map((one) => one.replace(/\/$/, ''));
|
|
17
|
-
export function positionalIndexes(args) {
|
|
18
|
-
const out = [];
|
|
19
|
-
for (let i = 0; i < args.length; i += 1) {
|
|
20
|
-
const arg = args[i] ?? '';
|
|
21
|
-
if (VALUED.includes(arg)) {
|
|
22
|
-
i += 1;
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
if (!arg.startsWith('--'))
|
|
26
|
-
out.push(i);
|
|
27
|
-
}
|
|
28
|
-
return out;
|
|
29
|
-
}
|
|
30
|
-
export function positionalsOf(args) {
|
|
31
|
-
return positionalIndexes(args).map(index => args[index]);
|
|
32
|
-
}
|
|
33
|
-
export const placesOfFile = (file) => (observeText(file) ?? '').split('\n').map((line) => line.trim())
|
|
34
|
-
.filter((line) => line.startsWith('# place ')).map((line) => line.slice('# place '.length).trim().replace(/\/$/, '')).filter(Boolean);
|
|
35
|
-
export function claimLinesIn(file) {
|
|
36
|
-
const lines = (observeText(file) ?? '').split('\n').map(line => line.trim())
|
|
37
|
-
.filter(line => line.startsWith(`${PROTOCOL.split('/')[0]}/`));
|
|
38
|
-
for (const line of lines) {
|
|
39
|
-
const got = parse(line);
|
|
40
|
-
if (got.kind !== 'fact')
|
|
41
|
-
throw new Error(`REFUSE·wire batch ${got.why} · nothing signed or landed`);
|
|
42
|
-
}
|
|
43
|
-
return lines;
|
|
44
|
-
}
|
|
1
|
+
var s=Object.defineProperty;var n=(t,e)=>s(t,"name",{value:e,configurable:!0});import{relative as l,sep as a}from"node:path";import{observeText as i}from"../observe/files.js";import{sourceOf as f}from"../observe/runner.js";import{library11_PROTOCOL as c,library11_parse as m}from"../vendor/runtime.js";import{FLAGS as u,VALUED as p}from"./names.js";function y(t){return l(t,f()).split(a).join("/")}n(y,"entryOf");function E(t,e){const r=t.indexOf(e);return r>=0?t[r+1]:void 0}n(E,"valueOf");const O=n((t,e)=>t.flatMap((r,o)=>r===e&&t[o+1]!==void 0?[t[o+1]]:[]),"valuesOf"),$=n(t=>O(t,u.place).map(e=>e.replace(/\/$/,"")),"namedPlaces");function d(t){const e=[];for(let r=0;r<t.length;r+=1){const o=t[r]??"";if(p.includes(o)){r+=1;continue}o.startsWith("--")||e.push(r)}return e}n(d,"positionalIndexes");function F(t){return d(t).map(e=>t[e])}n(F,"positionalsOf");const P=n(t=>(i(t)??"").split(`
|
|
2
|
+
`).map(e=>e.trim()).filter(e=>e.startsWith("# place ")).map(e=>e.slice(8).trim().replace(/\/$/,"")).filter(Boolean),"placesOfFile");function R(t){const e=(i(t)??"").split(`
|
|
3
|
+
`).map(r=>r.trim()).filter(r=>r.startsWith(`${c.split("/")[0]}/`));for(const r of e){const o=m(r);if(o.kind!=="fact")throw new Error(`REFUSE\xB7wire batch ${o.why} \xB7 nothing signed or landed`)}return e}n(R,"claimLinesIn");export{p as VALUED,R as claimLinesIn,y as entryOf,$ as namedPlaces,P as placesOfFile,d as positionalIndexes,F as positionalsOf,E as valueOf,O as valuesOf};
|
package/dist/cli/custodian.js
CHANGED
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { createConnection } from 'node:net';
|
|
5
|
-
import { scheduleDeadline } from "../host/native/deadline.js";
|
|
6
|
-
const cap = Number(process.argv[2]);
|
|
7
|
-
if (!Number.isSafeInteger(cap) || cap < 1)
|
|
8
|
-
throw Error('REFUSE·producer sync client input resources');
|
|
9
|
-
const chunks = [];
|
|
10
|
-
let size = 0;
|
|
11
|
-
for await (const chunk of process.stdin) {
|
|
12
|
-
const raw = Buffer.from(chunk);
|
|
13
|
-
size += raw.length;
|
|
14
|
-
if (size > cap)
|
|
15
|
-
throw Error('REFUSE·producer sync client input bytes');
|
|
16
|
-
chunks.push(raw);
|
|
17
|
-
}
|
|
18
|
-
const { endpoint, frame } = JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
19
|
-
if (!endpoint || typeof endpoint.socket !== 'string' || !Number.isSafeInteger(endpoint.timeoutMs) || endpoint.timeoutMs < 1 || !Number.isSafeInteger(endpoint.responseBytes) || endpoint.responseBytes < 1 || typeof frame !== 'string' || Buffer.byteLength(frame) > endpoint.responseBytes)
|
|
20
|
-
throw Error('REFUSE·producer sync client binding');
|
|
21
|
-
const socket = createConnection(endpoint.socket), remaining = Math.max(1, Math.min(endpoint.timeoutMs, endpoint.deadlineMs - Date.now())), cancel = scheduleDeadline(process.hrtime.bigint() + BigInt(remaining) * 1000000n, () => socket.destroy(Error('REFUSE·producer IPC timeout')));
|
|
22
|
-
let bytes = 0;
|
|
23
|
-
socket.once('connect', () => socket.write(frame + '\n'));
|
|
24
|
-
socket.on('data', chunk => { bytes += chunk.length; if (bytes > endpoint.responseBytes)
|
|
25
|
-
socket.destroy(Error('REFUSE·producer IPC response bytes'));
|
|
26
|
-
else
|
|
27
|
-
process.stdout.write(chunk); });
|
|
28
|
-
socket.once('error', error => { process.stderr.write(error.message); process.exitCode = 1; });
|
|
29
|
-
socket.once('close', cancel);
|
|
1
|
+
import{createConnection as u}from"node:net";import{scheduleDeadline as a}from"../host/native/deadline.js";const s=Number(process.argv[2]);if(!Number.isSafeInteger(s)||s<1)throw Error("REFUSE\xB7producer sync client input resources");const c=[];let i=0;for await(const t of process.stdin){const n=Buffer.from(t);if(i+=n.length,i>s)throw Error("REFUSE\xB7producer sync client input bytes");c.push(n)}const{endpoint:e,frame:o}=JSON.parse(Buffer.concat(c).toString("utf8"));if(!e||typeof e.socket!="string"||!Number.isSafeInteger(e.timeoutMs)||e.timeoutMs<1||!Number.isSafeInteger(e.responseBytes)||e.responseBytes<1||typeof o!="string"||Buffer.byteLength(o)>e.responseBytes)throw Error("REFUSE\xB7producer sync client binding");const r=u(e.socket),f=Math.max(1,Math.min(e.timeoutMs,e.deadlineMs-Date.now())),m=a(process.hrtime.bigint()+BigInt(f)*1000000n,()=>r.destroy(Error("REFUSE\xB7producer IPC timeout")));let p=0;r.once("connect",()=>r.write(o+`
|
|
2
|
+
`)),r.on("data",t=>{p+=t.length,p>e.responseBytes?r.destroy(Error("REFUSE\xB7producer IPC response bytes")):process.stdout.write(t)}),r.once("error",t=>{process.stderr.write(t.message),process.exitCode=1}),r.once("close",m);
|
package/dist/cli/host.js
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
return path;
|
|
8
|
-
};
|
|
9
|
-
import { readFileSync } from 'node:fs';
|
|
10
|
-
import { resolve } from 'node:path';
|
|
11
|
-
import { pathToFileURL } from 'node:url';
|
|
12
|
-
import { respond } from '@lapxo/topos/contract';
|
|
13
|
-
import { provide } from "../host/provide.js";
|
|
14
|
-
/**
|
|
15
|
-
* The host end of the contract, a process of its own: it loads the one module a lock names, or the blob built from it
|
|
16
|
-
* with the module named beside it, hands it the requests on its standard input and prints on its last line what the
|
|
17
|
-
* contract answers. The instrument never loads a reader or a
|
|
18
|
-
* capsule into itself; this process is theirs, and the only one that reads a request off standard input.
|
|
19
|
-
*/
|
|
20
|
-
void (async () => {
|
|
21
|
-
try {
|
|
22
|
-
provide();
|
|
23
|
-
const loaded = (await import(__rewriteRelativeImportExtension(pathToFileURL(resolve(process.argv[2] ?? '')).href)));
|
|
24
|
-
const self = resolve(process.argv[3] ?? process.argv[2] ?? '');
|
|
25
|
-
process.stdout.write(`\n${respond(typeof loaded['load'] === 'function' ? await loaded['load']() : loaded, readFileSync(0, 'utf8'), self)}\n`);
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
const message = (error instanceof Error ? error.message : String(error)).replace(/\s+/g, ' ').trim();
|
|
29
|
-
process.stderr.write(`LOAD index · module error · ${message}\n`);
|
|
30
|
-
process.exitCode = 1;
|
|
31
|
-
}
|
|
32
|
-
})();
|
|
1
|
+
var m=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(o){throw e=0,o}};import{readFileSync as f}from"node:fs";import{resolve as a}from"node:path";import{pathToFileURL as d}from"node:url";import{library2_respond as l}from"../vendor/runtime.js";import{provide as u}from"../host/provide.js";var v=m(t=>{var p=t&&t.__rewriteRelativeImportExtension||function(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(o,c,s,i,n){return c?e?".jsx":".js":s&&(!i||!n)?o:s+i+"."+n.toLowerCase()+"js"}):r};(async()=>{try{u();const r=await import(p(d(a(process.argv[2]??"")).href)),e=a(process.argv[3]??process.argv[2]??"");process.stdout.write(`
|
|
2
|
+
${l(typeof r.load=="function"?await r.load():r,f(0,"utf8"),e)}
|
|
3
|
+
`)}catch(r){const e=(r instanceof Error?r.message:String(r)).replace(/\s+/g," ").trim();process.stderr.write(`LOAD index \xB7 module error \xB7 ${e}
|
|
4
|
+
`),process.exitCode=1}})()});export default v();
|
package/dist/cli/names.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const VERB_NAMES = ['fold', 'land', 'sign'];
|
|
3
|
-
/** Every flag the CLI reads, spelled once; a valued flag takes the argument after it. */
|
|
4
|
-
export const FLAGS = { as: '--as', check: '--check', key: '--key', keyFile: '--key-file', signer: '--signer', place: '--place' };
|
|
5
|
-
export const VALUED = [FLAGS.keyFile, FLAGS.key, FLAGS.signer, FLAGS.as, FLAGS.place];
|
|
6
|
-
/** Views the CLI renders from these names, never from a handwritten usage string. */
|
|
7
|
-
export const NAMED_VIEWS = { help: 'help', lines: 'lines', because: 'because' };
|
|
8
|
-
export const EXIT = { closed: 0, refuse: 1, usage: 2 };
|
|
9
|
-
export const helpLines = () => [
|
|
10
|
-
`verbs ${VERB_NAMES.join(' ')}`,
|
|
11
|
-
`flags ${Object.values(FLAGS).join(' ')}`,
|
|
12
|
-
];
|
|
1
|
+
var n=Object.defineProperty;var s=(c,l)=>n(c,"name",{value:l,configurable:!0});const o=["fold","land","sign"],e={as:"--as",check:"--check",key:"--key",keyFile:"--key-file",signer:"--signer",place:"--place"},a=[e.keyFile,e.key,e.signer,e.as,e.place],i={help:"help",lines:"lines",because:"because"},p={closed:0,refuse:1,usage:2},r=s(()=>[`verbs ${o.join(" ")}`,`flags ${Object.values(e).join(" ")}`],"helpLines");export{p as EXIT,e as FLAGS,i as NAMED_VIEWS,a as VALUED,o as VERB_NAMES,r as helpLines};
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* actual grants/counters live in the retained Root producer service.
|
|
3
|
-
*/
|
|
4
|
-
import { createHash } from 'node:crypto';
|
|
5
|
-
import { readBoundedFile } from "../host/native/bounded-file.js";
|
|
6
|
-
import { installDescendantBoundary } from "../host/native/descendants.js";
|
|
7
|
-
import { protectNativeLoaderRegistration } from "../host/native/loader.js";
|
|
8
|
-
import { assertNativeRuntime } from "../host/native/runtime.js";
|
|
9
|
-
const url = new URL(import.meta.url), path = url.searchParams.get('config'), cap = Number(url.searchParams.get('bytes')), expected = url.searchParams.get('digest');
|
|
10
|
-
if (!path || !expected || !Number.isSafeInteger(cap) || cap < 1)
|
|
11
|
-
throw Error('REFUSE·native descendant inherited envelope absent');
|
|
12
|
-
assertNativeRuntime(process.env, []);
|
|
13
|
-
const raw = readBoundedFile(path, cap, 'descendant host envelope');
|
|
14
|
-
if ('sha256:' + createHash('sha256').update(raw).digest('hex') !== expected)
|
|
15
|
-
throw Error('REFUSE·native descendant envelope changed');
|
|
16
|
-
const config = JSON.parse(raw.toString('utf8'));
|
|
17
|
-
config.custodian.preload = url.href;
|
|
18
|
-
installDescendantBoundary(config);
|
|
19
|
-
protectNativeLoaderRegistration();
|
|
1
|
+
import{createHash as s}from"node:crypto";import{readBoundedFile as i}from"../host/native/bounded-file.js";import{installDescendantBoundary as d}from"../host/native/descendants.js";import{protectNativeLoaderRegistration as c}from"../host/native/loader.js";import{assertNativeRuntime as m}from"../host/native/runtime.js";const e=new URL(import.meta.url),r=e.searchParams.get("config"),t=Number(e.searchParams.get("bytes")),a=e.searchParams.get("digest");if(!r||!a||!Number.isSafeInteger(t)||t<1)throw Error("REFUSE\xB7native descendant inherited envelope absent");m(process.env,[]);const o=i(r,t,"descendant host envelope");if("sha256:"+s("sha256").update(o).digest("hex")!==a)throw Error("REFUSE\xB7native descendant envelope changed");const n=JSON.parse(o.toString("utf8"));n.custodian.preload=e.href,d(n),c();
|
package/dist/cli/native.js
CHANGED
|
@@ -1,60 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
import { realpathSync } from 'node:fs';
|
|
6
|
-
import { readingIdentityBytes } from '@lapxo/topos/contract';
|
|
7
|
-
import { readBoundedBatch } from "../host/native/bounded-file.js";
|
|
8
|
-
import { inheritedNativeGuard, inheritedNativeRoot } from "../host/native/root.js";
|
|
9
|
-
import { authenticateNativeProfile, loadSignedNativeReading, answerNativeReading } from "../host/native/reading.js";
|
|
10
|
-
import { readingEnvironment } from "../host/reading-context.js";
|
|
11
|
-
import { assertNativeRuntime } from "../host/native/runtime.js";
|
|
12
|
-
import { nativeReferenceInputs } from "../host/native/references.js";
|
|
13
|
-
const fail = (why) => { throw Error('REFUSE·native dispatcher ' + why); };
|
|
14
|
-
const ordered = (value) => [...value].sort(([a], [b]) => Buffer.compare(Buffer.from(a), Buffer.from(b)));
|
|
15
|
-
async function run() {
|
|
16
|
-
const inherited = { store: process.argv[2], parent: Number(process.argv[8]), expected: JSON.parse(process.argv[4]) }, coordinate = process.argv[3], inputLimit = Number(process.argv[6]), phase = process.argv[7], execution = JSON.parse(process.argv[9]);
|
|
17
|
-
if (phase !== 'act')
|
|
18
|
-
fail('effects forbidden during ' + phase);
|
|
19
|
-
if (!Number.isSafeInteger(inputLimit) || inputLimit < 1)
|
|
20
|
-
fail('missing inherited input limit');
|
|
21
|
-
if (!execution?.context || !execution.env || !Array.isArray(execution.flags) || !execution.cwd)
|
|
22
|
-
fail('missing complete inherited reading identity');
|
|
23
|
-
assertNativeRuntime(process.env, process.execArgv);
|
|
24
|
-
const identity = hash(readingIdentityBytes(execution.context));
|
|
25
|
-
if (JSON.stringify(ordered(readingEnvironment(hash, execution.env, execution.cwd, execution.flags))) !== JSON.stringify(ordered(execution.context.environment)))
|
|
26
|
-
fail('inherited execution differs from context');
|
|
27
|
-
if (JSON.stringify(ordered(readingEnvironment(hash))) !== JSON.stringify(ordered(execution.context.environment)))
|
|
28
|
-
fail('actual child environment differs from inherited identity');
|
|
29
|
-
const chunks = [];
|
|
30
|
-
let bytes = 0;
|
|
31
|
-
for await (const chunk of process.stdin) {
|
|
32
|
-
const got = Buffer.from(chunk);
|
|
33
|
-
bytes += got.length;
|
|
34
|
-
if (bytes > inputLimit)
|
|
35
|
-
fail('input bytes exceeded');
|
|
36
|
-
chunks.push(got);
|
|
37
|
-
}
|
|
38
|
-
const frame = JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
39
|
-
const current = inheritedNativeRoot(inherited, frame.proof), guard = inheritedNativeGuard(inherited, frame.proof), authenticated = authenticateNativeProfile(current, coordinate), profile = authenticated.profile;
|
|
40
|
-
const selected = authenticated.selection;
|
|
41
|
-
if (execution.context.implementation !== profile.selection.archive)
|
|
42
|
-
fail('reading implementation differs from selected archive');
|
|
43
|
-
if (!Array.isArray(frame.locations) || frame.locations.length !== profile.selection.members.length || frame.locations.length > profile.selection.budget.members)
|
|
44
|
-
fail('image member budget/count');
|
|
45
|
-
const runtime = frame.locations.find((location) => location.member === profile.selection.runtime);
|
|
46
|
-
if (!runtime || realpathSync(runtime.path) !== realpathSync(process.execPath))
|
|
47
|
-
fail('runtime differs from executing interpreter');
|
|
48
|
-
nativeReferenceInputs(execution.context.inputs, profile.selection.members.map(member => ['native/' + member.coordinate, member.digest]));
|
|
49
|
-
const imagePaths = profile.selection.members.map(member => { const rows = frame.locations.filter((location) => location.member === member.coordinate); if (rows.length !== 1)
|
|
50
|
-
return fail('missing/ambiguous actual member ' + member.coordinate); return { path: rows[0].path, coordinate: member.coordinate }; });
|
|
51
|
-
const raw = readBoundedBatch([...imagePaths, { path: frame.archive, coordinate: 'implementation archive' }], profile.selection.budget.bytes), archive = raw.at(-1), members = profile.selection.members.map((member, index) => ({ ...member, bytes: new Uint8Array(raw[index]) }));
|
|
52
|
-
if (hash(archive) !== profile.selection.archive)
|
|
53
|
-
fail('implementation archive differs');
|
|
54
|
-
const handoff = { place: inherited.expected.namespace, instrument: execution.context.instrument, policy: execution.context.policy, authoritySnapshot: identity, budget: profile.selection.budget, members, bindings: profile.selection.bindings, loads: profile.selection.loads };
|
|
55
|
-
const image = { cwd: execution.cwd, locations: frame.locations, runtime: profile.selection.runtime, preload: profile.selection.preload ?? undefined, nativePreloadMembers: profile.selection.nativePreloadMembers, condition: profile.selection.condition, commandPort: profile.port };
|
|
56
|
-
const handle = await loadSignedNativeReading(selected, { profile, handoff, image, archive }, guard);
|
|
57
|
-
const results = await answerNativeReading(handle, frame.requests, profile.selection.reader, { phase: 'act', guard });
|
|
58
|
-
process.stdout.write(JSON.stringify(results) + '\n');
|
|
59
|
-
}
|
|
60
|
-
run().catch(error => { process.stderr.write((error instanceof Error ? error.message : String(error)) + '\n'); process.exitCode = 1; });
|
|
1
|
+
var k=Object.defineProperty;var d=(i,a)=>k(i,"name",{value:a,configurable:!0});import{sha256 as m}from"../host/hash.js";import{realpathSync as x}from"node:fs";import{library2_readingIdentityBytes as M}from"../vendor/runtime.js";import{readBoundedBatch as U}from"../host/native/bounded-file.js";import{inheritedNativeGuard as q,inheritedNativeRoot as C}from"../host/native/root.js";import{authenticateNativeProfile as F,loadSignedNativeReading as G,answerNativeReading as L}from"../host/native/reading.js";import{readingEnvironment as N}from"../host/reading-context.js";import{assertNativeRuntime as _}from"../host/native/runtime.js";import{nativeReferenceInputs as j}from"../host/native/references.js";const r=d(i=>{throw Error("REFUSE\xB7native dispatcher "+i)},"fail"),f=d(i=>[...i].sort(([a],[c])=>Buffer.compare(Buffer.from(a),Buffer.from(c))),"ordered");async function z(){const i={store:process.argv[2],parent:Number(process.argv[8]),expected:JSON.parse(process.argv[4])},a=process.argv[3],c=Number(process.argv[6]),p=process.argv[7],t=JSON.parse(process.argv[9]);p!=="act"&&r("effects forbidden during "+p),(!Number.isSafeInteger(c)||c<1)&&r("missing inherited input limit"),(!t?.context||!t.env||!Array.isArray(t.flags)||!t.cwd)&&r("missing complete inherited reading identity"),_(process.env,process.execArgv);const S=m(M(t.context));JSON.stringify(f(N(m,t.env,t.cwd,t.flags)))!==JSON.stringify(f(t.context.environment))&&r("inherited execution differs from context"),JSON.stringify(f(N(m)))!==JSON.stringify(f(t.context.environment))&&r("actual child environment differs from inherited identity");const l=[];let u=0;for await(const n of process.stdin){const s=Buffer.from(n);u+=s.length,u>c&&r("input bytes exceeded"),l.push(s)}const o=JSON.parse(Buffer.concat(l).toString("utf8")),w=C(i,o.proof),g=q(i,o.proof),h=F(w,a),e=h.profile,B=h.selection;t.context.implementation!==e.selection.archive&&r("reading implementation differs from selected archive"),(!Array.isArray(o.locations)||o.locations.length!==e.selection.members.length||o.locations.length>e.selection.budget.members)&&r("image member budget/count");const v=o.locations.find(n=>n.member===e.selection.runtime);(!v||x(v.path)!==x(process.execPath))&&r("runtime differs from executing interpreter"),j(t.context.inputs,e.selection.members.map(n=>["native/"+n.coordinate,n.digest]));const J=e.selection.members.map(n=>{const s=o.locations.filter(I=>I.member===n.coordinate);return s.length!==1?r("missing/ambiguous actual member "+n.coordinate):{path:s[0].path,coordinate:n.coordinate}}),y=U([...J,{path:o.archive,coordinate:"implementation archive"}],e.selection.budget.bytes),b=y.at(-1),O=e.selection.members.map((n,s)=>({...n,bytes:new Uint8Array(y[s])}));m(b)!==e.selection.archive&&r("implementation archive differs");const A={place:i.expected.namespace,instrument:t.context.instrument,policy:t.context.policy,authoritySnapshot:S,budget:e.selection.budget,members:O,bindings:e.selection.bindings,loads:e.selection.loads},P={cwd:t.cwd,locations:o.locations,runtime:e.selection.runtime,preload:e.selection.preload??void 0,nativePreloadMembers:e.selection.nativePreloadMembers,condition:e.selection.condition,commandPort:e.port},R=await G(B,{profile:e,handoff:A,image:P,archive:b},g),E=await L(R,o.requests,e.selection.reader,{phase:"act",guard:g});process.stdout.write(JSON.stringify(E)+`
|
|
2
|
+
`)}d(z,"run"),z().catch(i=>{process.stderr.write((i instanceof Error?i.message:String(i))+`
|
|
3
|
+
`),process.exitCode=1});
|
package/dist/cli/observe.js
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { observedClaims } from "../fold/observed.js";
|
|
3
|
-
import { storeOf } from "../land/ledger.js";
|
|
4
|
-
import { withContentStore } from "../host/content-store.js";
|
|
5
|
-
import { lockStanding } from "../fold/keys.js";
|
|
6
|
-
import { underRootAuthority } from "../land/act.js";
|
|
7
|
-
/** One reader, run to the end behind a fold that did not wait for it: what it lands, the next fold reads. */
|
|
8
|
-
const args = process.argv.slice(2);
|
|
9
|
-
if (args.length > 3 || (args[2] !== undefined && (args[1] === undefined || !/^sha256:[a-f0-9]{64}$/.test(args[2]))))
|
|
10
|
-
throw Error('REFUSE·reader invalid internal background arguments');
|
|
11
|
-
const [root = '.', only, selected] = args;
|
|
12
|
-
const place = resolve(root), store = storeOf(place);
|
|
13
|
-
await underRootAuthority(store, 'reader authority', () => withContentStore(store, () => observedClaims(place, store, { wait: true, ...(only === undefined ? {} : { only }), ...(selected === undefined ? {} : { selected }) }), () => lockStanding(store)));
|
|
1
|
+
import{resolve as i}from"node:path";import{observedClaims as a}from"../fold/observed.js";import{storeOf as d}from"../land/ledger.js";import{withContentStore as s}from"../host/content-store.js";import{lockStanding as m}from"../fold/keys.js";import{underRootAuthority as f}from"../land/act.js";const r=process.argv.slice(2);if(r.length>3||r[2]!==void 0&&(r[1]===void 0||!/^sha256:[a-f0-9]{64}$/.test(r[2])))throw Error("REFUSE\xB7reader invalid internal background arguments");const[l=".",e,t]=r,n=i(l),o=d(n);await f(o,"reader authority",()=>s(o,()=>a(n,o,{wait:!0,...e===void 0?{}:{only:e},...t===void 0?{}:{selected:t}}),()=>m(o)));
|
package/dist/cli/owner.js
CHANGED
|
@@ -1,139 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { ingressReceipts } from "../host/ports/ingress.js";
|
|
5
|
-
import { readOnly } from "../host/read-only.js";
|
|
6
|
-
import { keyFor, lockLines, releaseOf, signedLockLines } from "../fold/keys.js";
|
|
7
|
-
import { existsSync, renameSync, writeFileSync } from 'node:fs';
|
|
8
|
-
import { join, resolve } from 'node:path';
|
|
9
|
-
import { bytesDigest, fullDigest, memoized, signaturesOf, instrumentDigest } from "../fold/digests.js";
|
|
10
|
-
import { claimKey, isConfig, fieldOf, foldClaims, LOCK, selfName } from "../fold/claims.js";
|
|
11
|
-
import { asksThePlace } from "../fold/configures.js";
|
|
12
|
-
import { receiptsIn } from "../fold/receipts.js";
|
|
13
|
-
import { authorityFor, releaseSigner, rootSigner } from "../fold/signers.js";
|
|
14
|
-
import { storeRoot } from "../host/ports/store.js";
|
|
15
|
-
import { blobAt, landBlob, ledgerLines, storeOf } from "../land/ledger.js";
|
|
16
|
-
import { observeText } from "../observe/files.js";
|
|
17
|
-
import { appliedHistoryIn } from "../fold/signed.js";
|
|
18
|
-
import { everLanded, inside, locationsOf } from "../land/vouched.js";
|
|
19
|
-
import { renderTarget } from "../render/target.js";
|
|
20
|
-
export const ownerOf = (store, told = []) => keyFor(store, 'authorize', told);
|
|
21
|
-
/** The signed lines standing in the lock: the owner's, and those of every key it admits to authorize, each in its own ledger. */
|
|
22
|
-
export function signedOwnerLines(store) {
|
|
23
|
-
return signedLockLines(store);
|
|
24
|
-
}
|
|
25
|
-
function forkReceipts(store, lines) {
|
|
26
|
-
const scopes = [...new Set(foldClaims(lines.filter(line => fieldOf(line, 'sig') !== '')).forks.map((f) => f.key.split(' ')[0] ?? ''))].filter(Boolean);
|
|
27
|
-
return scopes.length ? receiptsIn(store, scopes) : [];
|
|
28
|
-
}
|
|
29
|
-
export function standingDemands(store) {
|
|
30
|
-
const lines = signedOwnerLines(store);
|
|
31
|
-
return foldClaims(lines, forkReceipts(store, lines)).standing
|
|
32
|
-
.filter((line) => asksThePlace(line) && fieldOf(line, 'value') !== 'withdraw');
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* A demand is history when it asks about a place that is gone: one the tree once held and holds no more. It paid, or
|
|
36
|
-
* did not, in its own time; whoever wants it again signs it against the region as it is. A place never held is not
|
|
37
|
-
* gone — it is still to be made, and its demand stays live.
|
|
38
|
-
*/
|
|
39
|
-
export function historyOf(root, store, demands) {
|
|
40
|
-
const held = [...everLanded(store)];
|
|
41
|
-
const gone = (need) => {
|
|
42
|
-
const at = need.replace(/\/+$/, '');
|
|
43
|
-
return !existsSync(join(root, at)) && held.some((coordinate) => coordinate === at || inside(coordinate, at));
|
|
44
|
-
};
|
|
45
|
-
const history = demands.filter((line) => locationsOf(fieldOf(line, 'needs')).locations.some(gone));
|
|
46
|
-
return { live: demands.filter((line) => !history.includes(line)), history };
|
|
47
|
-
}
|
|
48
|
-
export function signedDemands(store, root = resolve('.')) {
|
|
49
|
-
return historyOf(root, store, standingDemands(store)).live;
|
|
50
|
-
}
|
|
51
|
-
export function forkedScopes(store) {
|
|
52
|
-
const lines = signedOwnerLines(store);
|
|
53
|
-
return new Set(foldClaims(lines, forkReceipts(store, lines)).forks.flatMap((f) => f.lines.map((line) => fieldOf(line, 'scope'))));
|
|
54
|
-
}
|
|
55
|
-
/** Import receipts are local acts; foreign evidence and sender epochs never enter this input. */
|
|
56
|
-
export function localActLines(root, placed = []) {
|
|
57
|
-
const store = storeOf(root), local = lockLines(store), receipts = ingressReceipts(store);
|
|
58
|
-
if (receipts.length) {
|
|
59
|
-
const authority = authorityFor(local, rootSigner(root), signaturesOf(store).admitted);
|
|
60
|
-
for (const receipt of receipts) {
|
|
61
|
-
if (fieldOf(receipt, 'scope') !== 'receipts' || fieldOf(receipt, 'role') !== 'writes' || fieldOf(receipt, 'form') !== 'alphabet' || fieldOf(receipt, 'measure') !== 'digest' || authority.of(receipt).kind !== 'admitted')
|
|
62
|
-
throw Error('REFUSE·ingress local import receipt is not admitted');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return [...local, ...receipts, ...committedLocalActs(store).map(act => act.bundle.receipt.trim()), ...placed.flatMap(place => appliedHistoryIn(root, place))];
|
|
66
|
-
}
|
|
67
|
-
export function epochOf(lines) {
|
|
68
|
-
return lines.reduce((top, line) => Math.max(top, Number(fieldOf(line, 'epoch')) || 0), 0);
|
|
69
|
-
}
|
|
70
|
-
export function targetFile(root) {
|
|
71
|
-
return join(storeRoot(root), LOCK);
|
|
72
|
-
}
|
|
73
|
-
export function renderInto(root, store) {
|
|
74
|
-
if (!lockLines(store).length)
|
|
75
|
-
throw new Error(`${selfName()}: the owner ledger is empty; land it before rendering TARGET`);
|
|
76
|
-
const rendered = renderedLock(root, store);
|
|
77
|
-
if (releaseOf(store))
|
|
78
|
-
return rendered;
|
|
79
|
-
const at = targetFile(root);
|
|
80
|
-
writeFileSync(`${at}.render`, rendered.text);
|
|
81
|
-
renameSync(`${at}.render`, at);
|
|
82
|
-
return rendered;
|
|
83
|
-
}
|
|
84
|
-
const rendered = new WeakMap();
|
|
85
|
-
/**
|
|
86
|
-
* A release's lock is read as it was laid and never rendered over. Its target lines are true only where a pin names the
|
|
87
|
-
* release, so here they stand grey; a line signed by a key the release does not carry is refused and does not stand.
|
|
88
|
-
*/
|
|
89
|
-
function readRelease(lines) {
|
|
90
|
-
const of = authorityFor(lines, releaseSigner(lines), [], { digest: '', pins: [] }).of;
|
|
91
|
-
const refused = lines.filter((line) => of(line).kind === 'refuse');
|
|
92
|
-
const standing = lines.filter((line) => !refused.includes(line));
|
|
93
|
-
return {
|
|
94
|
-
text: `${standing.join('\n')}\n`, standing: standing.length, superseded: [], retracted: [], forks: [],
|
|
95
|
-
grey: standing.filter((line) => of(line).kind === 'grey'), refused, vacuous: [],
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
export function renderedLock(root, store, told = []) {
|
|
99
|
-
const released = releaseOf(store);
|
|
100
|
-
if (released && !told.length)
|
|
101
|
-
return readRelease(released);
|
|
102
|
-
const owned = [...lockLines(store), ...told];
|
|
103
|
-
const render = () => renderTarget(owned, undefined, authorityFor(owned, rootSigner(root), signaturesOf(store, told).admitted).of, forkReceipts(store, owned));
|
|
104
|
-
if (readOnly())
|
|
105
|
-
return render();
|
|
106
|
-
if (told.length) {
|
|
107
|
-
const byLock = rendered.get(lockLines(store)) ?? rendered.set(lockLines(store), new Map()).get(lockLines(store));
|
|
108
|
-
return byLock.get(told) ?? byLock.set(told, render()).get(told);
|
|
109
|
-
}
|
|
110
|
-
const anchor = JSON.stringify(bootstrapAnchor(root) ?? null);
|
|
111
|
-
const judged = ledgerLines(store, 'judge');
|
|
112
|
-
const key = `lock ${fullDigest(store, [instrumentDigest(store, fileURLToPath(import.meta.url), [], root), new Date().toISOString().slice(0, 10), anchor, `${judged.length} ${judged.at(-1) ?? ''}`, ...owned])}`;
|
|
113
|
-
const held = memoized(store, key, () => {
|
|
114
|
-
const bytes = new TextEncoder().encode(JSON.stringify(render()));
|
|
115
|
-
const digest = bytesDigest(store, bytes);
|
|
116
|
-
landBlob(store, digest, bytes);
|
|
117
|
-
return digest;
|
|
118
|
-
});
|
|
119
|
-
const text = observeText(blobAt(store, held));
|
|
120
|
-
return text === undefined ? render() : JSON.parse(text);
|
|
121
|
-
}
|
|
122
|
-
export function forksJoinedBy(store, signed) {
|
|
123
|
-
signed = signed.filter(isConfig);
|
|
124
|
-
const keys = new Set(signed.map(claimKey));
|
|
125
|
-
const held = signedOwnerLines(store).filter((line) => isConfig(line) && keys.has(claimKey(line)));
|
|
126
|
-
const vacuous = new Set(foldClaims(held, forkReceipts(store, held)).vacuous);
|
|
127
|
-
const live = held.filter((line) => !vacuous.has(line));
|
|
128
|
-
return foldClaims([...live, ...signed]).forks.filter((fork) => fork.lines.some((line) => signed.includes(line)));
|
|
129
|
-
}
|
|
130
|
-
export function forksItself(lines) {
|
|
131
|
-
const bySigner = new Map();
|
|
132
|
-
for (const line of lines)
|
|
133
|
-
bySigner.set(fieldOf(line, 'by'), (bySigner.get(fieldOf(line, 'by')) ?? 0) + 1);
|
|
134
|
-
return [...bySigner.values()].some((n) => n > 1);
|
|
135
|
-
}
|
|
136
|
-
export function sideOf(line, landed) {
|
|
137
|
-
const at = landed.indexOf(line);
|
|
138
|
-
return ['value', 'at', 'needs', 'restsOn'].map((k) => `${k}=${fieldOf(line, k) || '∅'}`).join(' ') + ` landed=${at < 0 ? 'new' : `#${at + 1}`}`;
|
|
139
|
-
}
|
|
1
|
+
var R=Object.defineProperty;var i=(t,e)=>R(t,"name",{value:e,configurable:!0});import{bootstrapAnchor as T}from"../fold/bootstrap-anchor.js";import{committedLocalActs as D}from"../host/ports/local-act.js";import{fileURLToPath as E}from"node:url";import{ingressReceipts as M}from"../host/ports/ingress.js";import{readOnly as j}from"../host/read-only.js";import{keyFor as A,lockLines as l,releaseOf as k,signedLockLines as F}from"../fold/keys.js";import{existsSync as I,renameSync as N,writeFileSync as J}from"node:fs";import{join as w,resolve as B}from"node:path";import{bytesDigest as C,fullDigest as z,memoized as K,signaturesOf as O,instrumentDigest as P}from"../fold/digests.js";import{claimKey as S,isConfig as b,fieldOf as f,foldClaims as p,LOCK as U,selfName as G}from"../fold/claims.js";import{asksThePlace as H}from"../fold/configures.js";import{receiptsIn as W}from"../fold/receipts.js";import{authorityFor as g,releaseSigner as q,rootSigner as v}from"../fold/signers.js";import{storeRoot as Q}from"../host/ports/store.js";import{blobAt as V,landBlob as X,ledgerLines as Y,storeOf as Z}from"../land/ledger.js";import{observeText as _}from"../observe/files.js";import{appliedHistoryIn as ee}from"../fold/signed.js";import{everLanded as te,inside as re,locationsOf as ne}from"../land/vouched.js";import{renderTarget as oe}from"../render/target.js";const Ee=i((t,e=[])=>A(t,"authorize",e),"ownerOf");function h(t){return F(t)}i(h,"signedOwnerLines");function u(t,e){const r=[...new Set(p(e.filter(n=>f(n,"sig")!=="")).forks.map(n=>n.key.split(" ")[0]??""))].filter(Boolean);return r.length?W(t,r):[]}i(u,"forkReceipts");function ie(t){const e=h(t);return p(e,u(t,e)).standing.filter(r=>H(r)&&f(r,"value")!=="withdraw")}i(ie,"standingDemands");function se(t,e,r){const n=[...te(e)],s=i(o=>{const a=o.replace(/\/+$/,"");return!I(w(t,a))&&n.some(d=>d===a||re(d,a))},"gone"),c=r.filter(o=>ne(f(o,"needs")).locations.some(s));return{live:r.filter(o=>!c.includes(o)),history:c}}i(se,"historyOf");function Me(t,e=B(".")){return se(e,t,ie(t)).live}i(Me,"signedDemands");function je(t){const e=h(t);return new Set(p(e,u(t,e)).forks.flatMap(r=>r.lines.map(n=>f(n,"scope"))))}i(je,"forkedScopes");function Ae(t,e=[]){const r=Z(t),n=l(r),s=M(r);if(s.length){const c=g(n,v(t),O(r).admitted);for(const o of s)if(f(o,"scope")!=="receipts"||f(o,"role")!=="writes"||f(o,"form")!=="alphabet"||f(o,"measure")!=="digest"||c.of(o).kind!=="admitted")throw Error("REFUSE\xB7ingress local import receipt is not admitted")}return[...n,...s,...D(r).map(c=>c.bundle.receipt.trim()),...e.flatMap(c=>ee(t,c))]}i(Ae,"localActLines");function Fe(t){return t.reduce((e,r)=>Math.max(e,Number(f(r,"epoch"))||0),0)}i(Fe,"epochOf");function ce(t){return w(Q(t),U)}i(ce,"targetFile");function Ie(t,e){if(!l(e).length)throw new Error(`${G()}: the owner ledger is empty; land it before rendering TARGET`);const r=ae(t,e);if(k(e))return r;const n=ce(t);return J(`${n}.render`,r.text),N(`${n}.render`,n),r}i(Ie,"renderInto");const L=new WeakMap;function fe(t){const e=g(t,q(t),[],{digest:"",pins:[]}).of,r=t.filter(s=>e(s).kind==="refuse"),n=t.filter(s=>!r.includes(s));return{text:`${n.join(`
|
|
2
|
+
`)}
|
|
3
|
+
`,standing:n.length,superseded:[],retracted:[],forks:[],grey:n.filter(s=>e(s).kind==="grey"),refused:r,vacuous:[]}}i(fe,"readRelease");function ae(t,e,r=[]){const n=k(e);if(n&&!r.length)return fe(n);const s=[...l(e),...r],c=i(()=>oe(s,void 0,g(s,v(t),O(e,r).admitted).of,u(e,s)),"render");if(j())return c();if(r.length){const m=L.get(l(e))??L.set(l(e),new Map).get(l(e));return m.get(r)??m.set(r,c()).get(r)}const o=JSON.stringify(T(t)??null),a=Y(e,"judge"),d=`lock ${z(e,[P(e,E(import.meta.url),[],t),new Date().toISOString().slice(0,10),o,`${a.length} ${a.at(-1)??""}`,...s])}`,$=K(e,d,()=>{const m=new TextEncoder().encode(JSON.stringify(c())),x=C(e,m);return X(e,x,m),x}),y=_(V(e,$));return y===void 0?c():JSON.parse(y)}i(ae,"renderedLock");function Ne(t,e){e=e.filter(b);const r=new Set(e.map(S)),n=h(t).filter(o=>b(o)&&r.has(S(o))),s=new Set(p(n,u(t,n)).vacuous),c=n.filter(o=>!s.has(o));return p([...c,...e]).forks.filter(o=>o.lines.some(a=>e.includes(a)))}i(Ne,"forksJoinedBy");function Je(t){const e=new Map;for(const r of t)e.set(f(r,"by"),(e.get(f(r,"by"))??0)+1);return[...e.values()].some(r=>r>1)}i(Je,"forksItself");function Be(t,e){const r=e.indexOf(t);return["value","at","needs","restsOn"].map(n=>`${n}=${f(t,n)||"\u2205"}`).join(" ")+` landed=${r<0?"new":`#${r+1}`}`}i(Be,"sideOf");export{Fe as epochOf,je as forkedScopes,Je as forksItself,Ne as forksJoinedBy,se as historyOf,Ae as localActLines,Ee as ownerOf,Ie as renderInto,ae as renderedLock,Be as sideOf,Me as signedDemands,h as signedOwnerLines,ie as standingDemands,ce as targetFile};
|