@lapxo/bound 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CITATION.cff +1 -1
- package/README.md +20 -3
- package/TARGET.bound +85 -47
- package/dist/cli/accept.js +61 -590
- package/dist/cli/act-result.js +3 -103
- package/dist/cli/args.js +3 -44
- package/dist/cli/custodian.js +2 -29
- package/dist/cli/host.js +4 -32
- package/dist/cli/names.js +1 -12
- package/dist/cli/native-descendant.js +1 -19
- package/dist/cli/native.js +3 -60
- package/dist/cli/observe.js +1 -13
- package/dist/cli/owner.js +3 -139
- package/dist/cli/pass.js +22 -321
- package/dist/cli/place.js +6 -282
- package/dist/cli/release-result.js +3 -80
- package/dist/cli/retained-judgment.js +1 -25
- package/dist/cli/standing-result.js +4 -19
- package/dist/cli/takes.js +10 -112
- package/dist/cli/verb.d.ts +1 -2
- package/dist/cli/verb.js +85 -684
- package/dist/engine/computation.js +2 -0
- package/dist/engine/conformance.js +4 -0
- package/dist/engine/encoding.js +1 -2
- package/dist/engine/index.d.ts +1 -13
- package/dist/engine/index.js +2 -11
- package/dist/engine/object.js +1 -38
- package/dist/engine/ports.js +2 -117
- package/dist/fold/admission-history.js +1 -17
- package/dist/fold/bootstrap-anchor.js +1 -28
- package/dist/fold/ceilings.js +1 -142
- package/dist/fold/claims.js +2 -132
- package/dist/fold/closed.js +24 -235
- package/dist/fold/configures.js +1 -25
- package/dist/fold/digests.js +10 -226
- package/dist/fold/evidence.js +1 -22
- package/dist/fold/fold-worker.js +1 -13
- package/dist/fold/kept.js +12 -173
- package/dist/fold/keys.js +3 -91
- package/dist/fold/laid.js +3 -90
- package/dist/fold/nos.js +1 -48
- package/dist/fold/object.js +1 -2
- package/dist/fold/observed.js +28 -534
- package/dist/fold/opened.js +1 -33
- package/dist/fold/own.js +3 -217
- package/dist/fold/paid.js +1 -92
- package/dist/fold/place-inputs.js +1 -70
- package/dist/fold/places.js +3 -100
- package/dist/fold/rank.js +1 -9
- package/dist/fold/reach.js +1 -83
- package/dist/fold/readers.js +6 -142
- package/dist/fold/receipts.js +1 -47
- package/dist/fold/region-declarations.js +1 -13
- package/dist/fold/region.js +8 -286
- package/dist/fold/release-policy.js +1 -101
- package/dist/fold/resolved.js +6 -145
- package/dist/fold/roles.js +2 -59
- package/dist/fold/second.js +4 -71
- package/dist/fold/shards.js +12 -100
- package/dist/fold/signed.js +3 -81
- package/dist/fold/signers.js +1 -54
- package/dist/fold/stranger.js +6 -24
- package/dist/fold/views.js +1 -66
- package/dist/fold/wire.js +1 -46
- package/dist/fold/zoom.js +3 -81
- package/dist/host/act-cost.js +1 -25
- package/dist/host/adapters/keys/ed25519.js +1 -30
- package/dist/host/adapters/modules/javascript.js +1 -50
- package/dist/host/adapters/transport/http.js +1 -28
- package/dist/host/admitted-place.js +1 -35
- package/dist/host/archive.js +1 -152
- package/dist/host/call-context.js +1 -14
- package/dist/host/capsule-process.js +2 -62
- package/dist/host/capsule.js +9 -171
- package/dist/host/cell-receipts.js +12 -128
- package/dist/host/command-server.js +4 -0
- package/dist/host/commit-result.js +1 -5
- package/dist/host/content-needed.js +1 -8
- package/dist/host/content-store.js +1 -31
- package/dist/host/contextual-place.js +2 -72
- package/dist/host/digest.js +2 -15
- package/dist/host/hash.js +1 -9
- package/dist/host/host-controls.js +1 -19
- package/dist/host/in-process-act.js +3 -84
- package/dist/host/in-process-context.js +3 -91
- package/dist/host/in-process-root.js +6 -84
- package/dist/host/in-process.js +4 -55
- package/dist/host/index.d.ts +1 -15
- package/dist/host/index.js +1 -7
- package/dist/host/io.js +1 -11
- package/dist/host/lifetime.js +1 -79
- package/dist/host/located.js +6 -105
- package/dist/host/native/authority-card-view.js +5 -0
- package/dist/host/native/authority-card.js +1 -0
- package/dist/host/native/bounded-file.js +1 -32
- package/dist/host/native/command.js +1 -91
- package/dist/host/native/control-bridge-worker.js +2 -88
- package/dist/host/native/control-bridge.js +1 -110
- package/dist/host/native/control-selection.js +1 -32
- package/dist/host/native/custody.js +1 -91
- package/dist/host/native/deadline.js +1 -28
- package/dist/host/native/descendants.js +1 -528
- package/dist/host/native/generated-custodian.js +5 -267
- package/dist/host/native/generated.js +1 -379
- package/dist/host/native/image.js +1 -45
- package/dist/host/native/installed-package.d.ts +1 -0
- package/dist/host/native/installed-package.js +5 -0
- package/dist/host/native/jobs.js +2 -148
- package/dist/host/native/loader.js +1 -269
- package/dist/host/native/materialize.js +1 -175
- package/dist/host/native/module-closure.js +1 -130
- package/dist/host/native/module-delivery.d.ts +1 -62
- package/dist/host/native/module-delivery.js +1 -151
- package/dist/host/native/module-inventory.js +2 -0
- package/dist/host/native/module-syntax.js +1 -69
- package/dist/host/native/native-binary.js +1 -115
- package/dist/host/native/native-program.js +1 -72
- package/dist/host/native/node-jobs.js +3 -187
- package/dist/host/native/node-launch.js +1 -159
- package/dist/host/native/preload.js +1 -45
- package/dist/host/native/probes.js +1 -0
- package/dist/host/native/reading-witness-admission.js +5 -0
- package/dist/host/native/reading.js +1 -249
- package/dist/host/native/receipt-environment.js +1 -41
- package/dist/host/native/references.js +1 -30
- package/dist/host/native/root.js +1 -37
- package/dist/host/native/route.js +1 -216
- package/dist/host/native/runtime.js +1 -9
- package/dist/host/native-place-state.js +1 -0
- package/dist/host/native-reader-context.js +1 -8
- package/dist/host/native-receiver.js +1 -25
- package/dist/host/objects.js +1 -38
- package/dist/host/order.js +1 -2
- package/dist/host/persistent-host.js +1 -0
- package/dist/host/physical-lines.d.ts +1 -0
- package/dist/host/physical-lines.js +1 -0
- package/dist/host/place-act-transaction.js +4 -78
- package/dist/host/place-clock-selection.js +5 -124
- package/dist/host/ports/ingress.js +2 -57
- package/dist/host/ports/local-act.js +5 -183
- package/dist/host/ports/place-act.js +1 -134
- package/dist/host/ports/publication.js +1 -56
- package/dist/host/ports/signing.js +1 -74
- package/dist/host/ports/store.js +1 -18
- package/dist/host/ports/transport.js +1 -48
- package/dist/host/process-lifetime.js +1 -17
- package/dist/host/profile-composition.d.ts +1 -0
- package/dist/host/profile-composition.js +2 -0
- package/dist/host/provide.js +1 -183
- package/dist/host/read-only.js +1 -9
- package/dist/host/reading-closures.js +7 -227
- package/dist/host/reading-context.js +1 -53
- package/dist/host/reading-identity-types.js +0 -0
- package/dist/host/reading-identity.js +3 -0
- package/dist/host/reading-preparation.js +6 -0
- package/dist/host/reference-authenticated.d.ts +1 -40
- package/dist/host/reference-authenticated.js +3 -100
- package/dist/host/reference-contracts.js +1 -6
- package/dist/host/reference-export.js +6 -81
- package/dist/host/reference-native-api.d.ts +1 -3
- package/dist/host/reference-native-api.js +1 -3
- package/dist/host/reference-native.js +1 -74
- package/dist/host/reference-profile.js +1 -63
- package/dist/host/reference-standing.js +2 -18
- package/dist/host/reference.js +1 -24
- package/dist/host/refusals.js +2 -43
- package/dist/host/release.js +4 -256
- package/dist/host/root-clock-source.js +1 -307
- package/dist/host/selected-capsules.js +1 -50
- package/dist/host/selected-topos.js +1 -80
- package/dist/host/signature-era.js +1 -12
- package/dist/host/signing.js +2 -48
- package/dist/host/source-content.js +2 -111
- package/dist/host/standing-carrier.js +1 -18
- package/dist/host/standing-projection.js +1 -50
- package/dist/host/timing.js +1 -7
- package/dist/host/walk.js +20 -193
- package/dist/host/work-trace.js +1 -0
- package/dist/judge/late.js +1 -33
- package/dist/judge/take.js +2 -75
- package/dist/judge/widening.js +1 -25
- package/dist/land/act.js +8 -336
- package/dist/land/alias.js +1 -41
- package/dist/land/held.js +1 -23
- package/dist/land/inert.js +1 -33
- package/dist/land/leaving.js +1 -55
- package/dist/land/ledger.js +6 -188
- package/dist/land/owned.js +4 -66
- package/dist/land/sign.js +1 -53
- package/dist/land/standing-pin.js +1 -49
- package/dist/land/vouched.js +1 -112
- package/dist/land/withdraw.js +1 -24
- package/dist/observe/files.js +1 -88
- package/dist/observe/identity.js +1 -61
- package/dist/observe/match.js +1 -8
- package/dist/observe/regions.js +7 -306
- package/dist/observe/run.js +1 -41
- package/dist/observe/runner.js +4 -101
- package/dist/public-types.d.ts +2019 -0
- package/dist/render/capsule.js +1 -30
- package/dist/render/field.js +1 -40
- package/dist/render/names.js +1 -4
- package/dist/render/open.js +1 -61
- package/dist/render/page.js +1 -7
- package/dist/render/receipt-projection.js +1 -0
- package/dist/render/receipts.js +1 -47
- package/dist/render/shape.js +1 -74
- package/dist/render/target.js +4 -52
- package/dist/render/view.js +7 -197
- package/dist/vendor/bundle.json +1 -0
- package/dist/vendor/library14.js +1 -0
- package/dist/vendor/object-provider.js +42 -0
- package/dist/vendor/runtime.js +61 -0
- package/dist/wasm/adapter.d.ts +1 -51
- package/dist/wasm/adapter.js +1 -180
- package/dist/wasm/node-worker.js +1 -13
- package/dist/wasm/object.js +1 -76
- package/dist/wasm/worker.js +1 -7
- package/docs/contracts/authenticated-reference.publication.json +1 -1
- package/docs/contracts/authority-preflight.md +17 -0
- package/docs/contracts/authority-preflight.publication.json +25 -0
- package/docs/contracts/closure-delivery.md +1 -1
- package/docs/contracts/closure-delivery.publication.json +1 -1
- package/docs/contracts/conformance.json +142 -0
- package/docs/contracts/determinism.bound +9 -0
- package/docs/contracts/engine-object-projection.publication.json +1 -1
- package/docs/contracts/engine.md +21 -1
- package/docs/contracts/installed-package.md +21 -0
- package/docs/contracts/installed-package.publication.json +25 -0
- package/docs/contracts/materialized-leaf-sequence.md +15 -0
- package/docs/contracts/materialized-leaf-sequence.publication.json +25 -0
- package/docs/contracts/module-inventory.md +15 -0
- package/docs/contracts/module-inventory.publication.json +25 -0
- package/docs/contracts/native-host.md +29 -1
- package/docs/contracts/native-host.publication.json +4 -4
- package/docs/contracts/native-probes.md +13 -0
- package/docs/contracts/native-probes.publication.json +25 -0
- package/docs/contracts/native-publication.inventory.json +10 -1
- package/docs/contracts/native-view-batch.md +17 -0
- package/docs/contracts/native-view-batch.publication.json +25 -0
- package/docs/contracts/optional-wasm-adapter.publication.json +1 -1
- package/docs/contracts/physical-lines.md +19 -0
- package/docs/contracts/physical-lines.publication.json +25 -0
- package/docs/contracts/profile-composition.md +17 -0
- package/docs/contracts/profile-composition.publication.json +25 -0
- package/docs/contracts/profile-preparation-native-meaning.md +9 -0
- package/docs/contracts/publication.md +12 -0
- package/docs/contracts/reading-identity.md +61 -0
- package/docs/contracts/reading-identity.publication.json +25 -0
- package/docs/contracts/reading-witness-admission.md +49 -0
- package/docs/contracts/readme.publication.json +1 -1
- package/docs/contracts/reference-port.md +11 -0
- package/docs/contracts/reference-port.publication.json +1 -1
- package/docs/contracts/refusals.bound +346 -94
- package/docs/contracts/refusals.md +119 -39
- package/docs/contracts/refusals.publication.json +2 -2
- package/docs/contracts/views.md +8 -0
- package/docs/reference.md +9 -0
- package/licenses/wasm/{fast-text-encoding.txt → NOTICE.txt} +111 -0
- package/package.json +84 -34
- package/receipts.bound +12952 -10449
- package/samples/authority-preflight/no.json +6 -0
- package/samples/authority-preflight/yes.json +30 -0
- package/samples/engine-alphabet/reader.js +3 -1457
- package/samples/engine-alphabet/receipts.bound +7 -7
- package/samples/engine-interval/reader.js +3 -1457
- package/samples/engine-interval/receipts.bound +7 -7
- package/samples/installed-package/consumer.mjs +29 -0
- package/samples/installed-package/fixture.json +48 -0
- package/samples/installed-package/no.json +10 -0
- package/samples/installed-package/yes.json +52 -0
- package/samples/materialized-leaf-sequence/no.json +11 -0
- package/samples/materialized-leaf-sequence/yes.json +10 -0
- package/samples/module-inventory/yes.json +28 -0
- package/samples/native/physical-line-reader.mjs +1 -0
- package/samples/native/physical-line-reader.source.mjs +13 -0
- package/samples/native-host/no.json +6 -1
- package/samples/native-host/yes.json +18 -1
- package/samples/native-probes/inputs/inspection.json +28 -0
- package/samples/native-probes/no.json +7 -0
- package/samples/native-probes/yes.json +28 -0
- package/samples/native-view-batch/no.json +14 -0
- package/samples/native-view-batch/yes.json +10 -0
- package/samples/no/engine-order/reader.js +3 -1457
- package/samples/no/module-inventory/no.json +10 -0
- package/samples/physical-lines/no.json +5 -0
- package/samples/physical-lines/yes.json +9 -0
- package/samples/profile-composition/no.json +6 -0
- package/samples/profile-composition/yes.json +14 -0
- package/samples/reading-identity/no.json +26 -0
- package/samples/reading-identity/yes.json +69 -0
- package/vectors/native/authority-preflight.vector.json +55 -0
- package/vectors/native/installed-package.vector.json +31 -0
- package/vectors/native/materialized-leaf-sequence.vector.json +31 -0
- package/vectors/native/module-inventory.vector.json +56 -0
- package/vectors/native/native-host.vector.json +214 -0
- package/vectors/native/native-probes.vector.json +31 -0
- package/vectors/native/native-view-batch.vector.json +31 -0
- package/vectors/native/physical-lines.vector.json +105 -0
- package/vectors/native/profile-composition.vector.json +53 -0
- package/vectors/native/reading-identity.vector.json +139 -0
- package/vectors/native/refusals.vector.json +138 -0
- package/vendor/syntax/LICENSE.md +7 -0
- package/vendor/syntax/parser.js +1 -0
- package/.github/workflows/release.yml +0 -67
- package/.github/workflows/test.yml +0 -35
- package/dist/engine/object.d.ts +0 -17
- package/dist/engine/ports.d.ts +0 -37
- package/dist/fold/claims.d.ts +0 -29
- package/dist/host/call-context.d.ts +0 -20
- package/dist/host/commit-result.d.ts +0 -6
- package/dist/host/in-process-act.d.ts +0 -82
- package/dist/host/in-process-context.d.ts +0 -46
- package/dist/host/in-process-root.d.ts +0 -117
- package/dist/host/in-process.d.ts +0 -41
- package/dist/host/native/module-closure.d.ts +0 -35
- package/dist/host/native-receiver.d.ts +0 -19
- package/dist/host/place-act-transaction.d.ts +0 -24
- package/dist/host/place-clock-selection.d.ts +0 -55
- package/dist/host/ports/local-act.d.ts +0 -44
- package/dist/host/ports/place-act.d.ts +0 -49
- package/dist/host/ports/publication.d.ts +0 -10
- package/dist/host/reference-export.d.ts +0 -33
- package/dist/host/reference-native.d.ts +0 -30
- package/dist/host/reference-profile.d.ts +0 -23
- package/dist/host/refusals.d.ts +0 -14
- package/dist/host/root-clock-source.d.ts +0 -86
- package/licenses/wasm/jitl-quickjs-ffi-types.txt +0 -21
- package/licenses/wasm/jitl-quickjs-wasmfile-release-sync.txt +0 -47
- package/licenses/wasm/quickjs-emscripten-core.txt +0 -21
- package/licenses/wasm/topos.txt +0 -21
- /package/{licenses/wasm/bound.txt → dist/vendor/28cba430228db1c04f446c93f81b09a2705d6bf3e222d35adbe5a4cee4061884.LICENSE} +0 -0
- /package/{licenses/wasm/obligations.txt → dist/vendor/7aca161279d14bc0e054dcc281cd110aeb95be2e026b42fdf527a260e58b2aae.LICENSE} +0 -0
|
@@ -1,31 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
3
|
-
import { blobAt } from "../land/ledger.js";
|
|
4
|
-
import { observeFile } from "../observe/files.js";
|
|
5
|
-
import { ownLock, ownStore } from "../observe/runner.js";
|
|
6
|
-
import { parse, wireAt } from '@lapxo/topos/wire';
|
|
7
|
-
import { ContentNeeded } from "./content-needed.js";
|
|
8
|
-
// Each invocation carries its place explicitly; asynchronous requests cannot share a mutable current root.
|
|
9
|
-
const requested = new AsyncLocalStorage();
|
|
10
|
-
export const withContentStore = (store, run, policy = () => []) => requested.run({ store, policy }, run);
|
|
11
|
-
export const contentPolicy = () => requested.getStore()?.policy() ?? [];
|
|
12
|
-
export const contentStore = () => requested.getStore()?.store ?? ownStore();
|
|
13
|
-
/** Only immutable verified bytes may be shared with the instrument. Local corruption is never hidden by fallback. */
|
|
14
|
-
export function verifiedContent(digest, store = contentStore(), instrument = ownStore()) {
|
|
15
|
-
const fields = ownLock().flatMap(line => { const p = parse(line); return p.kind === 'fact' ? [p.value.fields] : []; });
|
|
16
|
-
const wire = wireAt(fields, Number.MAX_SAFE_INTEGER);
|
|
17
|
-
if (!wire)
|
|
18
|
-
throw Error('REFUSE·pin instrument has no admitted wire');
|
|
19
|
-
const split = digest.indexOf(':'), algorithm = digest.slice(0, split), hex = digest.slice(split + 1);
|
|
20
|
-
if (split < 1 || !wire.digests.has(algorithm) || !/^[a-f0-9]+$/.test(hex))
|
|
21
|
-
throw Error(`REFUSE·pin ${digest} digest is not admitted`);
|
|
22
|
-
for (const at of new Set([store, instrument])) {
|
|
23
|
-
const path = blobAt(at, digest), bytes = observeFile(path);
|
|
24
|
-
if (bytes === undefined)
|
|
25
|
-
continue;
|
|
26
|
-
if (createHash(algorithm).update(bytes).digest('hex') !== hex)
|
|
27
|
-
throw Error(`REFUSE·pin ${digest} content hash mismatch · store ${at} · not laid`);
|
|
28
|
-
return { bytes, path };
|
|
29
|
-
}
|
|
30
|
-
throw new ContentNeeded(digest);
|
|
31
|
-
}
|
|
1
|
+
var w=Object.defineProperty;var e=(t,o)=>w(t,"name",{value:o,configurable:!0});import{AsyncLocalStorage as d}from"node:async_hooks";import{createHash as E}from"node:crypto";import{blobAt as u}from"../land/ledger.js";import{observeFile as S}from"../observe/files.js";import{ownLock as b,ownStore as l}from"../observe/runner.js";import{library14_parse as x,library14_wireAt as y}from"../vendor/runtime.js";import{ContentNeeded as A}from"./content-needed.js";const c=new d,L=e((t,o,i=()=>[])=>c.run({store:t,policy:i},o),"withContentStore"),M=e(()=>c.getStore()?.policy()??[],"contentPolicy"),F=e(()=>c.getStore()?.store??l(),"contentStore");function g(t,o=F(),i=l()){const h=b().flatMap(n=>{const r=x(n);return r.kind==="fact"?[r.value.fields]:[]}),f=y(h,Number.MAX_SAFE_INTEGER);if(!f)throw Error("REFUSE\xB7pin instrument has no admitted wire");const s=t.indexOf(":"),p=t.slice(0,s),m=t.slice(s+1);if(s<1||!f.digests.has(p)||!/^[a-f0-9]+$/.test(m))throw Error(`REFUSE\xB7pin ${t} digest is not admitted`);for(const n of new Set([o,i])){const r=u(n,t),a=S(r);if(a!==void 0){if(E(p).update(a).digest("hex")!==m)throw Error(`REFUSE\xB7pin ${t} content hash mismatch \xB7 store ${n} \xB7 not laid`);return{bytes:a,path:r}}}throw new A(t)}e(g,"verifiedContent");export{M as contentPolicy,F as contentStore,g as verifiedContent,L as withContentStore};
|
|
@@ -1,72 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { declaredRootClockSource, hasRootClockSource } from "./root-clock-source.js";
|
|
4
|
-
import { commitPlaceAct, placeActResult, committedPlaceActResults } from "./ports/place-act.js";
|
|
5
|
-
import { placesIn } from "../fold/places.js";
|
|
6
|
-
import { appliedHistoryIn } from "../fold/signed.js";
|
|
7
|
-
import { storeOf } from "../land/ledger.js";
|
|
8
|
-
import { publicStandingLines } from "./admitted-place.js";
|
|
9
|
-
import { projectContextualStanding } from "./standing-carrier.js";
|
|
10
|
-
import { admissionHistoryAt } from "../fold/admission-history.js";
|
|
11
|
-
const fail = (s) => { throw Error('REFUSE·contextual place ' + s); };
|
|
12
|
-
function read(path, limit) {
|
|
13
|
-
const fd = openSync(path, 'r');
|
|
14
|
-
try {
|
|
15
|
-
const stat = fstatSync(fd);
|
|
16
|
-
if (!stat.isFile() || stat.size > limit)
|
|
17
|
-
fail('batch byte budget');
|
|
18
|
-
const data = Buffer.alloc(stat.size);
|
|
19
|
-
let n = 0;
|
|
20
|
-
while (n < data.length) {
|
|
21
|
-
const got = readSync(fd, data, n, data.length - n, null);
|
|
22
|
-
if (!got)
|
|
23
|
-
fail('batch changed during read');
|
|
24
|
-
n += got;
|
|
25
|
-
}
|
|
26
|
-
if (readSync(fd, Buffer.alloc(1), 0, 1, null))
|
|
27
|
-
fail('batch changed during read');
|
|
28
|
-
return new TextDecoder('utf8', { fatal: true }).decode(data);
|
|
29
|
-
}
|
|
30
|
-
finally {
|
|
31
|
-
closeSync(fd);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export function hasContextualPlace(root) { return hasRootClockSource(root); }
|
|
35
|
-
/** Exact selected SDK frame plus complete pre-signed receiver statements. No
|
|
36
|
-
* executable/verifier/epoch selection can be supplied by this envelope. */
|
|
37
|
-
export async function landContextualPlace(root, file) {
|
|
38
|
-
const selected = declaredRootClockSource(root), raw = read(file, selected.selection.budget.bytes);
|
|
39
|
-
let packet;
|
|
40
|
-
try {
|
|
41
|
-
packet = JSON.parse(raw);
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
return fail('invalid batch JSON');
|
|
45
|
-
}
|
|
46
|
-
if (!packet || Object.keys(packet).sort().join(',') !== 'context,profile,receipts' || packet.profile !== PLACE_ACT_CONTEXT || typeof packet.context !== 'string' || !Array.isArray(packet.receipts) || JSON.stringify(packet) + '\n' !== raw)
|
|
47
|
-
fail('unsupported/noncanonical batch envelope');
|
|
48
|
-
return commitPlaceAct(storeOf(root), packet.context, packet.receipts, selected.trust, selected.selection.storageBudget);
|
|
49
|
-
}
|
|
50
|
-
export function contextualAct(root, identity) {
|
|
51
|
-
const selected = declaredRootClockSource(root), bundle = placeActResult(storeOf(root), identity, selected.trust, selected.selection.storageBudget);
|
|
52
|
-
if (!bundle)
|
|
53
|
-
return undefined;
|
|
54
|
-
const all = new Map(committedPlaceActResults(storeOf(root), selected.trust, selected.selection.storageBudget).map(a => [a.identity, a])), kept = new Set(), contexts = [];
|
|
55
|
-
const visit = (id) => { if (kept.has(id))
|
|
56
|
-
return; const a = all.get(id); if (!a)
|
|
57
|
-
return; kept.add(id); const decoded = readPlaceActContext(a.bundle.context, selected.selection.budget); for (const p of decoded.places)
|
|
58
|
-
visit(p.previous); contexts.push({ identity: a.identity, context: a.bundle.context, receipts: a.bundle.receipts, authority: selected.authority(a.bundle.context) }); };
|
|
59
|
-
visit(identity);
|
|
60
|
-
return { profile: PLACE_ACT_CONTEXT, identity, context: bundle.context, receipts: bundle.receipts, contexts };
|
|
61
|
-
}
|
|
62
|
-
/** Carriers retain exact originals and authenticated context/receipts. Each
|
|
63
|
-
* namespace folds independently; labels assert no statistical independence. */
|
|
64
|
-
/** Native snapshot collection preserves every existing authentication boundary. */
|
|
65
|
-
export function contextualStandingSnapshot(root) {
|
|
66
|
-
const selected = declaredRootClockSource(root), acts = committedPlaceActResults(storeOf(root), selected.trust, selected.selection.storageBudget);
|
|
67
|
-
return { rootHistory: admissionHistoryAt(root, Number.MAX_SAFE_INTEGER), legacyPlaces: placesIn(root).map(place => ({ place: [place, 'TARGET.bound'].join('/'), history: appliedHistoryIn(root, place) })), contexts: acts.map(a => ({ identity: a.identity, context: a.bundle.context, receipts: a.bundle.receipts, authority: selected.authority(a.bundle.context) })) };
|
|
68
|
-
}
|
|
69
|
-
export function contextualStanding(root) {
|
|
70
|
-
const snapshot = contextualStandingSnapshot(root), selected = declaredRootClockSource(root);
|
|
71
|
-
return projectContextualStanding(publicStandingLines(root), snapshot.legacyPlaces, snapshot.contexts, snapshot.contexts.map(a => ({ identity: a.identity, context: readPlaceActContext(a.context, selected.selection.budget) })));
|
|
72
|
-
}
|
|
1
|
+
var S=Object.defineProperty;var r=(t,c)=>S(t,"name",{value:c,configurable:!0});import{openSync as A,fstatSync as C,readSync as x,closeSync as E}from"node:fs";import{library6_readPlaceActContext as y,library6_PLACE_ACT_CONTEXT as m}from"../vendor/runtime.js";import{declaredRootClockSource as d,hasRootClockSource as P}from"./root-clock-source.js";import{commitPlaceAct as T,placeActResult as _,committedPlaceActResults as g}from"./ports/place-act.js";import{placesIn as N}from"../fold/places.js";import{appliedHistoryIn as O}from"../fold/signed.js";import{storeOf as p}from"../land/ledger.js";import{publicStandingLines as R}from"./admitted-place.js";import{projectContextualStanding as w}from"./standing-carrier.js";import{admissionHistoryAt as B}from"../fold/admission-history.js";const u=r(t=>{throw Error("REFUSE\xB7contextual place "+t)},"fail");function k(t,c){const n=A(t,"r");try{const e=C(n);(!e.isFile()||e.size>c)&&u("batch byte budget");const o=Buffer.alloc(e.size);let i=0;for(;i<o.length;){const l=x(n,o,i,o.length-i,null);l||u("batch changed during read"),i+=l}return x(n,Buffer.alloc(1),0,1,null)&&u("batch changed during read"),new TextDecoder("utf8",{fatal:!0}).decode(o)}finally{E(n)}}r(k,"read");function U(t){return P(t)}r(U,"hasContextualPlace");async function q(t,c){const n=d(t),e=k(c,n.selection.budget.bytes);let o;try{o=JSON.parse(e)}catch{return u("invalid batch JSON")}return(!o||Object.keys(o).sort().join(",")!=="context,profile,receipts"||o.profile!==m||typeof o.context!="string"||!Array.isArray(o.receipts)||JSON.stringify(o)+`
|
|
2
|
+
`!==e)&&u("unsupported/noncanonical batch envelope"),T(p(t),o.context,o.receipts,n.trust,n.selection.storageBudget)}r(q,"landContextualPlace");function K(t,c){const n=d(t),e=_(p(t),c,n.trust,n.selection.storageBudget);if(!e)return;const o=new Map(g(p(t),n.trust,n.selection.storageBudget).map(s=>[s.identity,s])),i=new Set,l=[],f=r(s=>{if(i.has(s))return;const a=o.get(s);if(!a)return;i.add(s);const b=y(a.bundle.context,n.selection.budget);for(const h of b.places)f(h.previous);l.push({identity:a.identity,context:a.bundle.context,receipts:a.bundle.receipts,authority:n.authority(a.bundle.context)})},"visit");return f(c),{profile:m,identity:c,context:e.context,receipts:e.receipts,contexts:l}}r(K,"contextualAct");function j(t){const c=d(t),n=g(p(t),c.trust,c.selection.storageBudget);return{rootHistory:B(t,Number.MAX_SAFE_INTEGER),legacyPlaces:N(t).map(e=>({place:[e,"TARGET.bound"].join("/"),history:O(t,e)})),contexts:n.map(e=>({identity:e.identity,context:e.bundle.context,receipts:e.bundle.receipts,authority:c.authority(e.bundle.context)}))}}r(j,"contextualStandingSnapshot");function Q(t){const c=j(t),n=d(t);return w(R(t),c.legacyPlaces,c.contexts,c.contexts.map(e=>({identity:e.identity,context:y(e.context,n.selection.budget)})))}r(Q,"contextualStanding");export{K as contextualAct,Q as contextualStanding,j as contextualStandingSnapshot,U as hasContextualPlace,q as landContextualPlace};
|
package/dist/host/digest.js
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { selfName } from "../fold/claims.js";
|
|
4
|
-
/** Sorted by UTF-8 bytes; the algorithm is a field (`sha256:…`), never bare hex. */
|
|
5
|
-
export function fullDigest(input, algorithm) {
|
|
6
|
-
if (!algorithm)
|
|
7
|
-
throw new Error(`${selfName()}: REFUSE·runtime a digest was asked for before the lock said which algorithm`);
|
|
8
|
-
const text = typeof input === 'string' ? input : [...input].sort(byBytes).join('\n');
|
|
9
|
-
return `${algorithm}:${createHash(algorithm).update(text).digest('hex')}`;
|
|
10
|
-
}
|
|
11
|
-
export function bytesDigest(bytes, algorithm) {
|
|
12
|
-
if (!algorithm)
|
|
13
|
-
throw new Error(`${selfName()}: REFUSE·runtime a digest was asked for before the lock said which algorithm`);
|
|
14
|
-
return `${algorithm}:${createHash(algorithm).update(bytes).digest('hex')}`;
|
|
15
|
-
}
|
|
1
|
+
var f=Object.defineProperty;var t=(r,e)=>f(r,"name",{value:e,configurable:!0});import{createHash as o}from"node:crypto";import{library14_byBytes as a}from"../vendor/runtime.js";import{selfName as s}from"../fold/claims.js";function w(r,e){if(!e)throw new Error(`${s()}: REFUSE\xB7runtime a digest was asked for before the lock said which algorithm`);const i=typeof r=="string"?r:[...r].sort(a).join(`
|
|
2
|
+
`);return`${e}:${o(e).update(i).digest("hex")}`}t(w,"fullDigest");function m(r,e){if(!e)throw new Error(`${s()}: REFUSE\xB7runtime a digest was asked for before the lock said which algorithm`);return`${e}:${o(e).update(r).digest("hex")}`}t(m,"bytesDigest");export{m as bytesDigest,w as fullDigest};
|
package/dist/host/hash.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/** SHA-256 byte hashing for host formats that explicitly name this algorithm. */
|
|
3
|
-
export const sha = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
4
|
-
/** Typed digest spelling shared by fixed host boundaries; hashes identical bytes. */
|
|
5
|
-
export const sha256 = (bytes) => 'sha256:' + sha(bytes);
|
|
6
|
-
/** Length-delimited UTF-8 fields for existing host history identities. */
|
|
7
|
-
export function hashText(hash, value) { hash.update(String(Buffer.byteLength(value, 'utf8')) + ':'); hash.update(value, 'utf8'); }
|
|
8
|
-
/** Exact typed SHA-256 spelling used by fixed host declarations. */
|
|
9
|
-
export const isSha256 = (value) => typeof value === 'string' && /^sha256:[0-9a-f]{64}$/.test(value);
|
|
1
|
+
var o=Object.defineProperty;var e=(t,s)=>o(t,"name",{value:s,configurable:!0});import{createHash as a}from"node:crypto";const r=e(t=>a("sha256").update(t).digest("hex"),"sha"),f=e(t=>"sha256:"+r(t),"sha256");function n(t,s){t.update(String(Buffer.byteLength(s,"utf8"))+":"),t.update(s,"utf8")}e(n,"hashText");const i=e(t=>typeof t=="string"&&/^sha256:[0-9a-f]{64}$/.test(t),"isSha256");export{n as hashText,i as isSha256,r as sha,f as sha256};
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BoundRefusal } from "./refusals.js";
|
|
3
|
-
/** Shared host refusals preserve the public code and diagnostic at every port. */
|
|
4
|
-
export function refuseHost(code) {
|
|
5
|
-
throw new BoundRefusal('host/' + code, 'REFUSE·host/' + code);
|
|
6
|
-
}
|
|
7
|
-
export function assertHostNotCancelled(signal) {
|
|
8
|
-
if (signal?.aborted)
|
|
9
|
-
refuseHost('cancelled');
|
|
10
|
-
}
|
|
11
|
-
/** Clock validation is shared; each boundary keeps its own refusal producer. */
|
|
12
|
-
export function receiverClock(text, refuse) {
|
|
13
|
-
if (!/^(0|[1-9][0-9]*)$/.test(text) || !Number.isSafeInteger(Number(text)))
|
|
14
|
-
refuse('unknown receiver clock');
|
|
15
|
-
return Number(text);
|
|
16
|
-
}
|
|
17
|
-
/** Coordinates use the wire's lock name, never a second spelling in a host. */
|
|
18
|
-
export const isPlaceLockCoordinate = (coordinate) => typeof coordinate === 'string' && coordinate.endsWith('/' + LOCK) && !coordinate.startsWith('/') && !coordinate.split('/').some(part => !part || part === '.' || part === '..');
|
|
19
|
-
export const placeRegionOf = (coordinate) => coordinate === '.' ? '' : coordinate.slice(0, -(LOCK.length + 1));
|
|
1
|
+
var s=Object.defineProperty;var o=(e,t)=>s(e,"name",{value:t,configurable:!0});import{library14_LOCK as r}from"../vendor/runtime.js";import{BoundRefusal as n}from"./refusals.js";function i(e){throw new n("host/"+e,"REFUSE\xB7host/"+e)}o(i,"refuseHost");function u(e){e?.aborted&&i("cancelled")}o(u,"assertHostNotCancelled");function m(e,t){return(!/^(0|[1-9][0-9]*)$/.test(e)||!Number.isSafeInteger(Number(e)))&&t("unknown receiver clock"),Number(e)}o(m,"receiverClock");const p=o(e=>typeof e=="string"&&e.endsWith("/"+r)&&!e.startsWith("/")&&!e.split("/").some(t=>!t||t==="."||t===".."),"isPlaceLockCoordinate"),a=o(e=>e==="."?"":e.slice(0,-(r.length+1)),"placeRegionOf");export{u as assertHostNotCancelled,p as isPlaceLockCoordinate,a as placeRegionOf,m as receiverClock,i as refuseHost};
|
|
@@ -1,84 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { readContent, invokeFrameSigningPort } from "../engine/ports.js";
|
|
5
|
-
import { transactPlaceAct, PlaceActCommitUnknown } from "./place-act-transaction.js";
|
|
6
|
-
import { withActHost } from "../land/act.js";
|
|
7
|
-
import { sha256, isSha256 } from "./hash.js";
|
|
8
|
-
import { BoundRefusal } from "./refusals.js";
|
|
9
|
-
import { refuseHost as fail } from "./host-controls.js";
|
|
10
|
-
import { withHostInstrument } from "./call-context.js";
|
|
11
|
-
import { requireEffects } from "./read-only.js";
|
|
12
|
-
/** Signs receiver receipts through the bounded existing signer protocol. Exact
|
|
13
|
-
* original declarations/proofs remain unchanged. Replay is historical recovery,
|
|
14
|
-
* never a new permission. A refusal after visibility is not a rollback claim. */
|
|
15
|
-
export async function landPlaceActInProcess(context, ports) {
|
|
16
|
-
return withHostInstrument(ports.instrumentName, () => withActHost({ name: ports.instrumentName, report: () => { }, signal: context.signal }, async () => {
|
|
17
|
-
try {
|
|
18
|
-
requireEffects('contextual host admission');
|
|
19
|
-
const { place, source, identity, rootSnapshot, algorithm, signal } = context, reading = structuredClone(context.reading), contentLimits = { ...context.contentLimits }, signingLimits = { ...context.signingLimits }, storageLimits = { ...context.storageLimits };
|
|
20
|
-
if (typeof ports.instrumentName !== 'string' || !ports.instrumentName || !/[a-zA-Z0-9]/.test(ports.instrumentName) || !/^[a-zA-Z0-9._-]+$/.test(ports.instrumentName) || typeof place !== 'string' || !place || typeof source !== 'string' || !source || typeof algorithm !== 'string' || !algorithm)
|
|
21
|
-
fail('context');
|
|
22
|
-
if (storageLimits.acts > ports.limits.storage.acts || storageLimits.bytes > ports.limits.storage.bytes || signingLimits.timeoutMs > ports.limits.signing.timeoutMs || signingLimits.maxBytes > ports.limits.signing.maxBytes || contentLimits.timeoutMs > ports.limits.content.timeoutMs || contentLimits.maxBytes > ports.limits.content.maxBytes)
|
|
23
|
-
fail('budget');
|
|
24
|
-
const key = readingIdentity({ ...reading, inputs: [...reading.inputs, ['host/place', sha256(place)], ['host/snapshot', rootSnapshot], ['host/act', identity], ['host/operation', sha256(JSON.stringify([algorithm, contentLimits, signingLimits, storageLimits]))]] }, sha256);
|
|
25
|
-
const trust = ports.trust();
|
|
26
|
-
if (trust.contract.root.snapshot !== rootSnapshot)
|
|
27
|
-
fail('stale');
|
|
28
|
-
if (contentLimits.maxBytes > trust.contract.budget.bytes)
|
|
29
|
-
fail('budget');
|
|
30
|
-
const bytes = await readContent(source, identity, { read: ports.read, digestBytes: sha256 }, contentLimits, signal);
|
|
31
|
-
let encoded;
|
|
32
|
-
try {
|
|
33
|
-
encoded = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return fail('snapshot-format');
|
|
37
|
-
}
|
|
38
|
-
const decoded = readPlaceActContext(encoded, trust.contract.budget);
|
|
39
|
-
if (trust.contract.digest(encoded) !== identity)
|
|
40
|
-
fail('integrity');
|
|
41
|
-
const acquire = async () => {
|
|
42
|
-
const by = trust.contract.receiptSigner, signer = trust.contract.signers.find(s => s.id === by);
|
|
43
|
-
if (!signer || authorityAtEpoch({ scope: trust.contract.receiptScope, by }, signer, Number(trust.contract.root.epoch), trust.contract.receiptScope, 'authority').kind !== 'admitted')
|
|
44
|
-
fail('receiver-authority');
|
|
45
|
-
const signed = await invokeFrameSigningPort({ keyId: by, algorithm, bytes: decoded.places.map(p => placeReceiptBytes(identity, p, decoded.root, by, trust.contract.receiptScope, trust.contract.budget)) }, ports.sign, signingLimits, signal);
|
|
46
|
-
return decoded.places.map((p, i) => ({ place: p.place, by, signature: signed[i].signature }));
|
|
47
|
-
};
|
|
48
|
-
const act = await transactPlaceAct(encoded, acquire, trust, storageLimits, ports.persistence, signal);
|
|
49
|
-
const result = sha256(JSON.stringify(act) + '\n');
|
|
50
|
-
return { kind: 'fact', value: { place, act, reading: key, result, commitment: readingReceiptIdentity(key, result, sha256) } };
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
if (error instanceof PlaceActCommitUnknown)
|
|
54
|
-
return { kind: 'uncertain', identity: error.identity, code: error.code, diagnostic: error.message };
|
|
55
|
-
return { kind: 'refuse', code: error instanceof BoundRefusal ? error.code : 'host/failed', diagnostic: error instanceof Error ? error.message : 'REFUSE·host/failed' };
|
|
56
|
-
}
|
|
57
|
-
;
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
/** Historical recovery after a lost response. No signer, current authorization
|
|
61
|
-
* or publication callback is invoked and the result grants no new act. */
|
|
62
|
-
export function recoverPlaceActInProcess(context, ports) {
|
|
63
|
-
return withHostInstrument(ports.instrumentName, () => withActHost({ name: ports.instrumentName, report: () => { }, signal: context.signal }, () => {
|
|
64
|
-
try {
|
|
65
|
-
if (context.signal?.aborted)
|
|
66
|
-
fail('cancelled');
|
|
67
|
-
if (!context.place || !isSha256(context.identity))
|
|
68
|
-
fail('context');
|
|
69
|
-
const limits = { ...context.storageLimits };
|
|
70
|
-
if (limits.acts > ports.limits.storage.acts || limits.bytes > ports.limits.storage.bytes)
|
|
71
|
-
fail('budget');
|
|
72
|
-
const reading = readingIdentity({ ...structuredClone(context.reading), inputs: [...context.reading.inputs, ['host/place', sha256(context.place)], ['host/act', context.identity], ['host/operation', sha256('historical-recovery')]] }, sha256);
|
|
73
|
-
const act = ports.persistence.result(context.identity, ports.trust(), limits);
|
|
74
|
-
if (!act)
|
|
75
|
-
fail('act-unavailable');
|
|
76
|
-
const result = sha256(JSON.stringify(act) + '\n');
|
|
77
|
-
return { kind: 'fact', value: { place: context.place, identity: context.identity, act, historical: true, reading, result, commitment: readingReceiptIdentity(reading, result, sha256) } };
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
return { kind: 'refuse', code: error instanceof BoundRefusal ? error.code : 'host/failed', diagnostic: error instanceof Error ? error.message : 'REFUSE·host/failed' };
|
|
81
|
-
}
|
|
82
|
-
;
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
1
|
+
var _=Object.defineProperty;var o=(i,t)=>_(i,"name",{value:t,configurable:!0});import{library14_authorityAtEpoch as M}from"../vendor/runtime.js";import{library6_placeReceiptBytes as q,library6_readPlaceActContext as F}from"../vendor/runtime.js";import{library5_readingIdentity as E,library5_readingReceiptIdentity as P}from"../vendor/runtime.js";import{readContent as H,invokeFrameSigningPort as J}from"../engine/ports.js";import{transactPlaceAct as O,PlaceActCommitUnknown as U}from"./place-act-transaction.js";import{withActHost as I}from"../land/act.js";import{sha256 as a,isSha256 as z}from"./hash.js";import{BoundRefusal as v}from"./refusals.js";import{refuseHost as r}from"./host-controls.js";import{withHostInstrument as w}from"./call-context.js";import{requireEffects as Z}from"./read-only.js";async function et(i,t){return w(t.instrumentName,()=>I({name:t.instrumentName,report:o(()=>{},"report"),signal:i.signal},async()=>{try{Z("contextual host admission");const{place:e,source:c,identity:s,rootSnapshot:m,algorithm:g,signal:h}=i,N=structuredClone(i.reading),d={...i.contentLimits},y={...i.signingLimits},f={...i.storageLimits};(typeof t.instrumentName!="string"||!t.instrumentName||!/[a-zA-Z0-9]/.test(t.instrumentName)||!/^[a-zA-Z0-9._-]+$/.test(t.instrumentName)||typeof e!="string"||!e||typeof c!="string"||!c||typeof g!="string"||!g)&&r("context"),(f.acts>t.limits.storage.acts||f.bytes>t.limits.storage.bytes||y.timeoutMs>t.limits.signing.timeoutMs||y.maxBytes>t.limits.signing.maxBytes||d.timeoutMs>t.limits.content.timeoutMs||d.maxBytes>t.limits.content.maxBytes)&&r("budget");const S=E({...N,inputs:[...N.inputs,["host/place",a(e)],["host/snapshot",m],["host/act",s],["host/operation",a(JSON.stringify([g,d,y,f]))]]},a),n=t.trust();n.contract.root.snapshot!==m&&r("stale"),d.maxBytes>n.contract.budget.bytes&&r("budget");const L=await H(c,s,{read:t.read,digestBytes:a},d,h);let p;try{p=new TextDecoder("utf-8",{fatal:!0}).decode(L)}catch{return r("snapshot-format")}const b=F(p,n.contract.budget);n.contract.digest(p)!==s&&r("integrity");const A=await O(p,o(async()=>{const u=n.contract.receiptSigner,B=n.contract.signers.find(l=>l.id===u);(!B||M({scope:n.contract.receiptScope,by:u},B,Number(n.contract.root.epoch),n.contract.receiptScope,"authority").kind!=="admitted")&&r("receiver-authority");const R=await J({keyId:u,algorithm:g,bytes:b.places.map(l=>q(s,l,b.root,u,n.contract.receiptScope,n.contract.budget))},t.sign,y,h);return b.places.map((l,C)=>({place:l.place,by:u,signature:R[C].signature}))},"acquire"),n,f,t.persistence,h),k=a(JSON.stringify(A)+`
|
|
2
|
+
`);return{kind:"fact",value:{place:e,act:A,reading:S,result:k,commitment:P(S,k,a)}}}catch(e){return e instanceof U?{kind:"uncertain",identity:e.identity,code:e.code,diagnostic:e.message}:{kind:"refuse",code:e instanceof v?e.code:"host/failed",diagnostic:e instanceof Error?e.message:"REFUSE\xB7host/failed"}}}))}o(et,"landPlaceActInProcess");function it(i,t){return w(t.instrumentName,()=>I({name:t.instrumentName,report:o(()=>{},"report"),signal:i.signal},()=>{try{i.signal?.aborted&&r("cancelled"),(!i.place||!z(i.identity))&&r("context");const e={...i.storageLimits};(e.acts>t.limits.storage.acts||e.bytes>t.limits.storage.bytes)&&r("budget");const c=E({...structuredClone(i.reading),inputs:[...i.reading.inputs,["host/place",a(i.place)],["host/act",i.identity],["host/operation",a("historical-recovery")]]},a),s=t.persistence.result(i.identity,t.trust(),e);s||r("act-unavailable");const m=a(JSON.stringify(s)+`
|
|
3
|
+
`);return{kind:"fact",value:{place:i.place,identity:i.identity,act:s,historical:!0,reading:c,result:m,commitment:P(c,m,a)}}}catch(e){return{kind:"refuse",code:e instanceof v?e.code:"host/failed",diagnostic:e instanceof Error?e.message:"REFUSE\xB7host/failed"}}}))}o(it,"recoverPlaceActInProcess");export{et as landPlaceActInProcess,it as recoverPlaceActInProcess};
|
|
@@ -1,91 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { sha256 } from "./hash.js";
|
|
5
|
-
import { BoundRefusal } from "./refusals.js";
|
|
6
|
-
import { refuseHost as fail, isPlaceLockCoordinate, placeRegionOf } from "./host-controls.js";
|
|
7
|
-
import { publicStandingProjection, assertStandingView } from "./standing-projection.js";
|
|
8
|
-
import { rootClockSelectionOf, inspectPortablePlaceContexts } from "./root-clock-source.js";
|
|
9
|
-
import { projectContextualStanding } from "./standing-carrier.js";
|
|
10
|
-
import { authorityFor } from "../fold/signers.js";
|
|
11
|
-
import { ownRecordAdmitted } from "../fold/signed.js";
|
|
12
|
-
import { wordsOf } from "../fold/wire.js";
|
|
13
|
-
import { fieldOf, isConfig } from "../fold/claims.js";
|
|
14
|
-
import { signatureEraOf } from "./signature-era.js";
|
|
15
|
-
function authenticatedCarrier(snapshot, anchor, records) {
|
|
16
|
-
if (!snapshot || Object.keys(snapshot).sort().join(',') !== 'contexts,legacyPlaces,rootHistory' || !Array.isArray(snapshot.rootHistory) || !Array.isArray(snapshot.legacyPlaces) || !Array.isArray(snapshot.contexts))
|
|
17
|
-
fail('snapshot-format');
|
|
18
|
-
let count = snapshot.rootHistory.length;
|
|
19
|
-
if (count > records)
|
|
20
|
-
fail('budget');
|
|
21
|
-
const validLine = (line) => typeof line === 'string' && parse(line).kind === 'fact';
|
|
22
|
-
if (!snapshot.rootHistory.length || snapshot.rootHistory.some(l => !validLine(l)))
|
|
23
|
-
fail('snapshot-format');
|
|
24
|
-
const root = publicStandingProjection(snapshot.rootHistory, anchor), families = wordsOf(root, 'families');
|
|
25
|
-
// Unsupported vocabulary resolution must not discover a provider in the CLI host.
|
|
26
|
-
if (families.length && !families.includes('view'))
|
|
27
|
-
fail('vocabulary-unavailable');
|
|
28
|
-
assertStandingView(root);
|
|
29
|
-
const selection = rootClockSelectionOf(root, anchor), algorithms = signatureEraOf(root).admitted;
|
|
30
|
-
if (snapshot.legacyPlaces.length > selection.resources.places || snapshot.contexts.length > selection.resources.acts)
|
|
31
|
-
fail('budget');
|
|
32
|
-
const signers = authorityFor(snapshot.rootHistory, anchor, algorithms).admitted;
|
|
33
|
-
if (signers.some(s => !s.coverage.includes('*')) && !families.includes('region'))
|
|
34
|
-
fail('vocabulary-unavailable');
|
|
35
|
-
const names = new Set();
|
|
36
|
-
for (const place of snapshot.legacyPlaces) {
|
|
37
|
-
if (!place || !isPlaceLockCoordinate(place.place) || names.has(place.place) || !Array.isArray(place.history))
|
|
38
|
-
fail('snapshot-format');
|
|
39
|
-
names.add(place.place);
|
|
40
|
-
count += place.history.length;
|
|
41
|
-
if (count > records)
|
|
42
|
-
fail('budget');
|
|
43
|
-
const path = placeRegionOf(place.place);
|
|
44
|
-
if (place.history.some((l) => !validLine(l) || !ownRecordAdmitted(l, path, 'region', signers, algorithms)))
|
|
45
|
-
fail('legacy-authority');
|
|
46
|
-
}
|
|
47
|
-
for (const row of snapshot.contexts) {
|
|
48
|
-
if (!row || !row.authority || !Array.isArray(row.authority.history))
|
|
49
|
-
fail('snapshot-format');
|
|
50
|
-
count += row.authority.history.length;
|
|
51
|
-
if (count > records)
|
|
52
|
-
fail('budget');
|
|
53
|
-
// Historical authority must belong to this exact Root history, not a second
|
|
54
|
-
// signed Root fork silently substituted in the carrier.
|
|
55
|
-
const epoch = fieldOf(row.authority.checkpoint, 'epoch');
|
|
56
|
-
const expected = snapshot.rootHistory.filter(l => !isConfig(l) || Number(fieldOf(l, 'epoch')) <= Number(epoch));
|
|
57
|
-
if (JSON.stringify(expected) !== JSON.stringify(row.authority.history))
|
|
58
|
-
fail('historical-snapshot');
|
|
59
|
-
}
|
|
60
|
-
const decoded = inspectPortablePlaceContexts(JSON.stringify(snapshot.contexts), anchor, selection);
|
|
61
|
-
return projectContextualStanding(root, snapshot.legacyPlaces, snapshot.contexts, decoded);
|
|
62
|
-
}
|
|
63
|
-
/** Full contextual carrier, authenticated against receiver inputs only. It is a
|
|
64
|
-
* data projection, not a current admission permit or a signed receipt. */
|
|
65
|
-
export async function readContextualStandingInProcess(context, ports) {
|
|
66
|
-
try {
|
|
67
|
-
const { place, source, snapshot, signal } = context, anchor = structuredClone(context.anchor), reading = structuredClone(context.reading), limits = { ...context.limits };
|
|
68
|
-
if (!place || typeof place !== 'string' || !source || typeof source !== 'string' || !Number.isSafeInteger(limits.records) || limits.records < 1)
|
|
69
|
-
fail('context');
|
|
70
|
-
const identity = readingIdentity({ ...reading, inputs: [...reading.inputs, ['host/place', sha256(place)], ['host/anchor', sha256(JSON.stringify(anchor))], ['host/snapshot', snapshot]] }, sha256);
|
|
71
|
-
const bytes = await readContent(source, snapshot, { read: ports.read, digestBytes: sha256 }, limits, signal);
|
|
72
|
-
let text, value;
|
|
73
|
-
try {
|
|
74
|
-
text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
75
|
-
value = JSON.parse(text);
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
return fail('snapshot-format');
|
|
79
|
-
}
|
|
80
|
-
if (JSON.stringify(value) + '\n' !== text)
|
|
81
|
-
fail('snapshot-format');
|
|
82
|
-
if (signal?.aborted)
|
|
83
|
-
fail('cancelled');
|
|
84
|
-
const standing = authenticatedCarrier(value, anchor, limits.records), result = sha256(JSON.stringify(standing) + '\n');
|
|
85
|
-
return { kind: 'fact', value: { place, standing, reading: identity, result, commitment: readingReceiptIdentity(identity, result, sha256) } };
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
return { kind: 'refuse', code: error instanceof BoundRefusal ? error.code : 'host/failed', diagnostic: error instanceof Error ? error.message : 'REFUSE·host/failed' };
|
|
89
|
-
}
|
|
90
|
-
;
|
|
91
|
-
}
|
|
1
|
+
var O=Object.defineProperty;var h=(r,a)=>O(r,"name",{value:a,configurable:!0});import{library14_parse as x}from"../vendor/runtime.js";import{library5_readingIdentity as A,library5_readingReceiptIdentity as C}from"../vendor/runtime.js";import{readContent as N}from"../engine/ports.js";import{sha256 as y}from"./hash.js";import{BoundRefusal as P}from"./refusals.js";import{refuseHost as e,isPlaceLockCoordinate as v,placeRegionOf as H}from"./host-controls.js";import{publicStandingProjection as w,assertStandingView as k}from"./standing-projection.js";import{rootClockSelectionOf as J,inspectPortablePlaceContexts as I}from"./root-clock-source.js";import{projectContextualStanding as R}from"./standing-carrier.js";import{authorityFor as j}from"../fold/signers.js";import{ownRecordAdmitted as E}from"../fold/signed.js";import{wordsOf as _}from"../fold/wire.js";import{fieldOf as S,isConfig as B}from"../fold/claims.js";import{signatureEraOf as F}from"./signature-era.js";function L(r,a,o){(!r||Object.keys(r).sort().join(",")!=="contexts,legacyPlaces,rootHistory"||!Array.isArray(r.rootHistory)||!Array.isArray(r.legacyPlaces)||!Array.isArray(r.contexts))&&e("snapshot-format");let i=r.rootHistory.length;i>o&&e("budget");const m=h(t=>typeof t=="string"&&x(t).kind==="fact","validLine");(!r.rootHistory.length||r.rootHistory.some(t=>!m(t)))&&e("snapshot-format");const s=w(r.rootHistory,a),f=_(s,"families");f.length&&!f.includes("view")&&e("vocabulary-unavailable"),k(s);const l=J(s,a),n=F(s).admitted;(r.legacyPlaces.length>l.resources.places||r.contexts.length>l.resources.acts)&&e("budget");const g=j(r.rootHistory,a,n).admitted;g.some(t=>!t.coverage.includes("*"))&&!f.includes("region")&&e("vocabulary-unavailable");const p=new Set;for(const t of r.legacyPlaces){(!t||!v(t.place)||p.has(t.place)||!Array.isArray(t.history))&&e("snapshot-format"),p.add(t.place),i+=t.history.length,i>o&&e("budget");const d=H(t.place);t.history.some(c=>!m(c)||!E(c,d,"region",g,n))&&e("legacy-authority")}for(const t of r.contexts){(!t||!t.authority||!Array.isArray(t.authority.history))&&e("snapshot-format"),i+=t.authority.history.length,i>o&&e("budget");const d=S(t.authority.checkpoint,"epoch"),c=r.rootHistory.filter(b=>!B(b)||Number(S(b,"epoch"))<=Number(d));JSON.stringify(c)!==JSON.stringify(t.authority.history)&&e("historical-snapshot")}const u=I(JSON.stringify(r.contexts),a,l);return R(s,r.legacyPlaces,r.contexts,u)}h(L,"authenticatedCarrier");async function tt(r,a){try{const{place:o,source:i,snapshot:m,signal:s}=r,f=structuredClone(r.anchor),l=structuredClone(r.reading),n={...r.limits};(!o||typeof o!="string"||!i||typeof i!="string"||!Number.isSafeInteger(n.records)||n.records<1)&&e("context");const g=A({...l,inputs:[...l.inputs,["host/place",y(o)],["host/anchor",y(JSON.stringify(f))],["host/snapshot",m]]},y),p=await N(i,m,{read:a.read,digestBytes:y},n,s);let u,t;try{u=new TextDecoder("utf-8",{fatal:!0}).decode(p),t=JSON.parse(u)}catch{return e("snapshot-format")}JSON.stringify(t)+`
|
|
2
|
+
`!==u&&e("snapshot-format"),s?.aborted&&e("cancelled");const d=L(t,f,n.records),c=y(JSON.stringify(d)+`
|
|
3
|
+
`);return{kind:"fact",value:{place:o,standing:d,reading:g,result:c,commitment:C(g,c,y)}}}catch(o){return{kind:"refuse",code:o instanceof P?o.code:"host/failed",diagnostic:o instanceof Error?o.message:"REFUSE\xB7host/failed"}}}h(tt,"readContextualStandingInProcess");export{tt as readContextualStandingInProcess};
|
|
@@ -1,84 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { isConfig } from "../fold/claims.js";
|
|
8
|
-
import { sha256, isSha256 } from "./hash.js";
|
|
9
|
-
import { BoundRefusal } from "./refusals.js";
|
|
10
|
-
import { refuseHost as fail } from "./host-controls.js";
|
|
11
|
-
import { ActCommitUnknown } from "./commit-result.js";
|
|
12
|
-
import { requireEffects } from "./read-only.js";
|
|
13
|
-
import { withHostCall } from "./call-context.js";
|
|
14
|
-
import { withActHost } from "../land/act.js";
|
|
15
|
-
/** Snapshot identity, not a new wire, authority algorithm or current permit. */
|
|
16
|
-
export const rootLotSnapshot = (root) => sha256(admissionHistoryAt(root, Number.MAX_SAFE_INTEGER).join('\n') + '\n');
|
|
17
|
-
export async function landRootLotInProcess(context, ports) {
|
|
18
|
-
const diagnostics = [];
|
|
19
|
-
let size = 0;
|
|
20
|
-
let committed;
|
|
21
|
-
const runtime = structuredClone(ports.runtime), limits = { ...context.limits };
|
|
22
|
-
return withHostCall({ instrumentName: ports.instrumentName, runtime, output: (stream, text) => { size += new TextEncoder().encode(text).length; if (size > ports.limits.diagnostics)
|
|
23
|
-
fail('budget'); diagnostics.push({ stream, text }); } }, () => withActHost({ name: ports.instrumentName, report: text => { size += new TextEncoder().encode(text).length; if (size > ports.limits.diagnostics)
|
|
24
|
-
fail('budget'); diagnostics.push({ stream: 'error', text }); }, signal: context.signal }, async () => {
|
|
25
|
-
try {
|
|
26
|
-
requireEffects('Root lot admission');
|
|
27
|
-
if (!context.place || !ports.root || !ports.instrumentName || !runtime.root || !runtime.entry || !runtime.directory || !['.ts', '.js'].includes(runtime.extension) || !Array.isArray(runtime.lock) || !runtime.lock.length)
|
|
28
|
-
fail('context');
|
|
29
|
-
if (limits.records > ports.limits.records || limits.maxBytes > ports.limits.maxBytes || limits.timeoutMs > ports.limits.timeoutMs || !Number.isSafeInteger(limits.records) || limits.records < 1 || !Number.isSafeInteger(ports.limits.diagnostics) || ports.limits.diagnostics < 1)
|
|
30
|
-
fail('budget');
|
|
31
|
-
const { place, snapshot, source, digest, signal } = context, reading = structuredClone(context.reading);
|
|
32
|
-
if (!isSha256(snapshot) || rootLotSnapshot(ports.root) !== snapshot)
|
|
33
|
-
fail('stale');
|
|
34
|
-
const anchor = admissionAnchor(ports.root);
|
|
35
|
-
const identity = readingIdentity({ ...reading, inputs: [...reading.inputs, ['host/place', sha256(place)], ['host/snapshot', snapshot], ['host/anchor', sha256(JSON.stringify(anchor))], ['host/draft', digest], ['host/principal', sha256(ports.signer.keyId)], ['host/operation', sha256(JSON.stringify(['root-lot', limits]))]] }, sha256);
|
|
36
|
-
const bytes = await readContent(source, digest, { read: ports.read, digestBytes: sha256 }, limits, signal);
|
|
37
|
-
let text;
|
|
38
|
-
try {
|
|
39
|
-
text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
return fail('snapshot-format');
|
|
43
|
-
}
|
|
44
|
-
const records = text.endsWith('\n') ? text.slice(0, -1).split('\n') : [];
|
|
45
|
-
if (!records.length || records.length > limits.records)
|
|
46
|
-
fail('budget');
|
|
47
|
-
for (const line of records) {
|
|
48
|
-
const parsed = parse(line);
|
|
49
|
-
if (parsed.kind !== 'fact' || canonical(parsed.value.fields, parsed.value.version) !== line || !isConfig(line) || parsed.value.fields.by !== 'target' || parsed.value.fields.epoch !== undefined || parsed.value.fields.sig !== undefined)
|
|
50
|
-
fail('root-lot-format');
|
|
51
|
-
}
|
|
52
|
-
if (rootLotSnapshot(ports.root) !== snapshot)
|
|
53
|
-
fail('stale');
|
|
54
|
-
const code = await acceptRootRecords(ports.root, { records, keyId: ports.signer.keyId, signer: { name: ports.signer.name, sign: ports.signer.sign, signal }, signal, storage: ports.storage, prepared: ports.prepared, committed: (identity, bundle, status) => { committed = { identity, bundle, status }; } });
|
|
55
|
-
if (code !== 0 && !committed)
|
|
56
|
-
return { kind: 'refuse', code: 'host/act', diagnostics };
|
|
57
|
-
const value = { place, status: committed?.status ?? 'already-held', ...(committed ? { identity: committed.identity, act: verifiedLegacyActResult(ports.root, committed.identity).result } : {}), conformance: code === 0 ? 'complete' : 'refused', reading: identity };
|
|
58
|
-
const result = sha256(JSON.stringify(value) + '\n');
|
|
59
|
-
return { kind: 'fact', value: { ...value, result, commitment: readingReceiptIdentity(identity, result, sha256) }, diagnostics };
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
if (error instanceof ActCommitUnknown)
|
|
63
|
-
return { kind: 'uncertain', identity: error.identity, code: error.code, diagnostic: error.message, diagnostics };
|
|
64
|
-
if (committed)
|
|
65
|
-
return { kind: 'fact', value: { place: context.place, status: committed.status, identity: committed.identity, conformance: 'incomplete' }, diagnostic: error instanceof Error ? error.message : 'post-commit failure', diagnostics };
|
|
66
|
-
return { kind: 'refuse', code: error instanceof BoundRefusal ? error.code : 'host/failed', diagnostic: error instanceof Error ? error.message : 'REFUSE·host/failed', diagnostics };
|
|
67
|
-
}
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
/** Authenticated historical query only; never revives authority or signs. */
|
|
71
|
-
export function recoverRootActInProcess(identity, ports) {
|
|
72
|
-
return withHostCall({ instrumentName: ports.instrumentName, runtime: structuredClone(ports.runtime), output: () => { } }, () => {
|
|
73
|
-
try {
|
|
74
|
-
if (!isSha256(identity))
|
|
75
|
-
fail('context');
|
|
76
|
-
const recovered = verifiedLegacyActResult(ports.root, identity);
|
|
77
|
-
return { kind: 'fact', value: { historical: true, act: recovered.result, bundle: recovered.bundle } };
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
return { kind: 'refuse', code: error instanceof BoundRefusal ? error.code : 'host/failed', diagnostic: error instanceof Error ? error.message : 'REFUSE·host/failed' };
|
|
81
|
-
}
|
|
82
|
-
;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
1
|
+
var H=Object.defineProperty;var d=(n,e)=>H(n,"name",{value:e,configurable:!0});import{library14_canonical as T,library14_parse as F}from"../vendor/runtime.js";import{library5_readingIdentity as J,library5_readingReceiptIdentity as L}from"../vendor/runtime.js";import{readContent as M}from"../engine/ports.js";import{acceptRootRecords as O}from"../cli/accept.js";import{verifiedLegacyActResult as I}from"../cli/act-result.js";import{admissionHistoryAt as U,admissionAnchor as j}from"../fold/admission-history.js";import{isConfig as P}from"../fold/claims.js";import{sha256 as s,isSha256 as R}from"./hash.js";import{BoundRefusal as A}from"./refusals.js";import{refuseHost as r}from"./host-controls.js";import{ActCommitUnknown as q}from"./commit-result.js";import{requireEffects as z}from"./read-only.js";import{withHostCall as S}from"./call-context.js";import{withActHost as D}from"../land/act.js";const w=d(n=>s(U(n,Number.MAX_SAFE_INTEGER).join(`
|
|
2
|
+
`)+`
|
|
3
|
+
`),"rootLotSnapshot");async function se(n,e){const i=[];let f=0,o;const m=structuredClone(e.runtime),a={...n.limits};return S({instrumentName:e.instrumentName,runtime:m,output:d((t,l)=>{f+=new TextEncoder().encode(l).length,f>e.limits.diagnostics&&r("budget"),i.push({stream:t,text:l})},"output")},()=>D({name:e.instrumentName,report:d(t=>{f+=new TextEncoder().encode(t).length,f>e.limits.diagnostics&&r("budget"),i.push({stream:"error",text:t})},"report"),signal:n.signal},async()=>{try{z("Root lot admission"),(!n.place||!e.root||!e.instrumentName||!m.root||!m.entry||!m.directory||![".ts",".js"].includes(m.extension)||!Array.isArray(m.lock)||!m.lock.length)&&r("context"),(a.records>e.limits.records||a.maxBytes>e.limits.maxBytes||a.timeoutMs>e.limits.timeoutMs||!Number.isSafeInteger(a.records)||a.records<1||!Number.isSafeInteger(e.limits.diagnostics)||e.limits.diagnostics<1)&&r("budget");const{place:t,snapshot:l,source:C,digest:p,signal:y}=n,b=structuredClone(n.reading);(!R(l)||w(e.root)!==l)&&r("stale");const _=j(e.root),k=J({...b,inputs:[...b.inputs,["host/place",s(t)],["host/snapshot",l],["host/anchor",s(JSON.stringify(_))],["host/draft",p],["host/principal",s(e.signer.keyId)],["host/operation",s(JSON.stringify(["root-lot",a]))]]},s),x=await M(C,p,{read:e.read,digestBytes:s},a,y);let h;try{h=new TextDecoder("utf-8",{fatal:!0}).decode(x)}catch{return r("snapshot-format")}const g=h.endsWith(`
|
|
4
|
+
`)?h.slice(0,-1).split(`
|
|
5
|
+
`):[];(!g.length||g.length>a.records)&&r("budget");for(const u of g){const c=F(u);(c.kind!=="fact"||T(c.value.fields,c.value.version)!==u||!P(u)||c.value.fields.by!=="target"||c.value.fields.epoch!==void 0||c.value.fields.sig!==void 0)&&r("root-lot-format")}w(e.root)!==l&&r("stale");const v=await O(e.root,{records:g,keyId:e.signer.keyId,signer:{name:e.signer.name,sign:e.signer.sign,signal:y},signal:y,storage:e.storage,prepared:e.prepared,committed:d((u,c,B)=>{o={identity:u,bundle:c,status:B}},"committed")});if(v!==0&&!o)return{kind:"refuse",code:"host/act",diagnostics:i};const E={place:t,status:o?.status??"already-held",...o?{identity:o.identity,act:I(e.root,o.identity).result}:{},conformance:v===0?"complete":"refused",reading:k},N=s(JSON.stringify(E)+`
|
|
6
|
+
`);return{kind:"fact",value:{...E,result:N,commitment:L(k,N,s)},diagnostics:i}}catch(t){return t instanceof q?{kind:"uncertain",identity:t.identity,code:t.code,diagnostic:t.message,diagnostics:i}:o?{kind:"fact",value:{place:n.place,status:o.status,identity:o.identity,conformance:"incomplete"},diagnostic:t instanceof Error?t.message:"post-commit failure",diagnostics:i}:{kind:"refuse",code:t instanceof A?t.code:"host/failed",diagnostic:t instanceof Error?t.message:"REFUSE\xB7host/failed",diagnostics:i}}}))}d(se,"landRootLotInProcess");function ae(n,e){return S({instrumentName:e.instrumentName,runtime:structuredClone(e.runtime),output:d(()=>{},"output")},()=>{try{R(n)||r("context");const i=I(e.root,n);return{kind:"fact",value:{historical:!0,act:i.result,bundle:i.bundle}}}catch(i){return{kind:"refuse",code:i instanceof A?i.code:"host/failed",diagnostic:i instanceof Error?i.message:"REFUSE\xB7host/failed"}}})}d(ae,"recoverRootActInProcess");export{se as landRootLotInProcess,ae as recoverRootActInProcess,w as rootLotSnapshot};
|
package/dist/host/in-process.js
CHANGED
|
@@ -1,55 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { BoundRefusal } from "./refusals.js";
|
|
6
|
-
import { refuseHost as refuse } from "./host-controls.js";
|
|
7
|
-
import { assertStandingView, publicStandingProjection } from "./standing-projection.js";
|
|
8
|
-
/** Uses the existing bounded content port, authority evaluator and projection.
|
|
9
|
-
* It projects the Root component of a complete signed Root wire snapshot; it has no persistence callback,
|
|
10
|
-
* current-root global, console output, process entry point or CLI subprocess.
|
|
11
|
-
* Contextual places and their carriers are not this Root-only projection.
|
|
12
|
-
* The returned commitment is unsigned and is not a paid native receipt.
|
|
13
|
-
*/
|
|
14
|
-
export async function readRootStandingInProcess(context, ports) {
|
|
15
|
-
try {
|
|
16
|
-
if (!context || typeof context.place !== 'string' || !context.place || typeof context.source !== 'string' || !context.source || !isSha256(context.snapshot))
|
|
17
|
-
refuse('context');
|
|
18
|
-
if (context.signal?.aborted)
|
|
19
|
-
refuse('cancelled');
|
|
20
|
-
const { place, source, snapshot, signal } = context, limits = { ...context.limits };
|
|
21
|
-
if (!Number.isSafeInteger(limits.records) || limits.records < 1)
|
|
22
|
-
refuse('budget');
|
|
23
|
-
const anchor = structuredClone(context.anchor), reading = structuredClone(context.reading);
|
|
24
|
-
if (!anchor || anchor.keyClass !== 'authorize' || !anchor.id || !anchor.publicKey || !Array.isArray(anchor.coverage) || !anchor.coverage.length)
|
|
25
|
-
refuse('context');
|
|
26
|
-
// Validate the complete declared environment before invoking a host port.
|
|
27
|
-
readingIdentity(reading, sha256);
|
|
28
|
-
const identity = readingIdentity({ ...reading, inputs: [...reading.inputs, ['host/place', sha256(place)], ['host/anchor', sha256(JSON.stringify(anchor))], ['host/snapshot', snapshot]] }, sha256);
|
|
29
|
-
const bytes = await readContent(source, snapshot, { read: ports.read, digestBytes: sha256 }, limits, signal);
|
|
30
|
-
let text;
|
|
31
|
-
try {
|
|
32
|
-
text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return refuse('snapshot-format');
|
|
36
|
-
}
|
|
37
|
-
const history = text.split('\n').filter(line => line.length > 0);
|
|
38
|
-
if (history.length > limits.records)
|
|
39
|
-
refuse('budget');
|
|
40
|
-
if (!history.length || history.some(line => parse(line).kind !== 'fact'))
|
|
41
|
-
refuse('snapshot-format');
|
|
42
|
-
if (signal?.aborted)
|
|
43
|
-
refuse('cancelled');
|
|
44
|
-
const standing = publicStandingProjection(history, anchor);
|
|
45
|
-
assertStandingView(standing);
|
|
46
|
-
if (signal?.aborted)
|
|
47
|
-
refuse('cancelled');
|
|
48
|
-
const result = sha256(standing.join('\n') + (standing.length ? '\n' : ''));
|
|
49
|
-
return { kind: 'fact', value: { place, rootStanding: standing, reading: identity, result, commitment: readingReceiptIdentity(identity, result, sha256) } };
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
return { kind: 'refuse', code: error instanceof BoundRefusal ? error.code : 'host/failed', diagnostic: error instanceof Error ? error.message : 'REFUSE·host/failed' };
|
|
53
|
-
}
|
|
54
|
-
;
|
|
55
|
-
}
|
|
1
|
+
var I=Object.defineProperty;var m=(e,d)=>I(e,"name",{value:d,configurable:!0});import{library14_parse as R}from"../vendor/runtime.js";import{library5_readingIdentity as y,library5_readingReceiptIdentity as k}from"../vendor/runtime.js";import{readContent as C}from"../engine/ports.js";import{sha256 as a,isSha256 as v}from"./hash.js";import{BoundRefusal as w}from"./refusals.js";import{refuseHost as r}from"./host-controls.js";import{assertStandingView as E,publicStandingProjection as _}from"./standing-projection.js";async function H(e,d){try{(!e||typeof e.place!="string"||!e.place||typeof e.source!="string"||!e.source||!v(e.snapshot))&&r("context"),e.signal?.aborted&&r("cancelled");const{place:i,source:b,snapshot:g,signal:c}=e,s={...e.limits};(!Number.isSafeInteger(s.records)||s.records<1)&&r("budget");const t=structuredClone(e.anchor),l=structuredClone(e.reading);(!t||t.keyClass!=="authorize"||!t.id||!t.publicKey||!Array.isArray(t.coverage)||!t.coverage.length)&&r("context"),y(l,a);const p=y({...l,inputs:[...l.inputs,["host/place",a(i)],["host/anchor",a(JSON.stringify(t))],["host/snapshot",g]]},a),S=await C(b,g,{read:d.read,digestBytes:a},s,c);let u;try{u=new TextDecoder("utf-8",{fatal:!0}).decode(S)}catch{return r("snapshot-format")}const n=u.split(`
|
|
2
|
+
`).filter(f=>f.length>0);n.length>s.records&&r("budget"),(!n.length||n.some(f=>R(f).kind!=="fact"))&&r("snapshot-format"),c?.aborted&&r("cancelled");const o=_(n,t);E(o),c?.aborted&&r("cancelled");const h=a(o.join(`
|
|
3
|
+
`)+(o.length?`
|
|
4
|
+
`:""));return{kind:"fact",value:{place:i,rootStanding:o,reading:p,result:h,commitment:k(p,h,a)}}}catch(i){return{kind:"refuse",code:i instanceof w?i.code:"host/failed",diagnostic:i instanceof Error?i.message:"REFUSE\xB7host/failed"}}}m(H,"readRootStandingInProcess");export{H as readRootStandingInProcess};
|
package/dist/host/index.d.ts
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { readRootStandingInProcess } from './in-process.ts';
|
|
3
|
-
export type { RootStandingHostContext, RootStandingHostResult } from './in-process.ts';
|
|
4
|
-
export { readContextualStandingInProcess } from './in-process-context.ts';
|
|
5
|
-
export { landPlaceActInProcess, recoverPlaceActInProcess } from './in-process-act.ts';
|
|
6
|
-
export type { PlaceActHostContext, PlaceActHostPorts } from './in-process-act.ts';
|
|
7
|
-
export { landRootLotInProcess, recoverRootActInProcess, rootLotSnapshot } from './in-process-root.ts';
|
|
8
|
-
export type { RootLotContext, RootLotPorts } from './in-process-root.ts';
|
|
9
|
-
export { nativeHostInstrument, nativePlaceActReceiver } from './native-receiver.ts';
|
|
10
|
-
export type { NativeHostInstrument } from './native-receiver.ts';
|
|
11
|
-
export type { HostInstrumentRuntime } from './call-context.ts';
|
|
12
|
-
export { nativePlaceActPersistence } from './ports/place-act.ts';
|
|
13
|
-
export type { PlaceActTrust, PlaceActBudget } from './ports/place-act.ts';
|
|
14
|
-
export type { PlaceActPersistence } from './place-act-transaction.ts';
|
|
15
|
-
export type { PublicationStorage } from './ports/publication.ts';
|
|
1
|
+
export {public2_HostInstrumentRuntime as HostInstrumentRuntime,public2_InstalledPackageMember as InstalledPackageMember,public2_InstalledPackagePin as InstalledPackagePin,public2_InstalledPackageRequest as InstalledPackageRequest,public2_NativeAuthorityAction as NativeAuthorityAction,public2_NativeAuthorityCardContext as NativeAuthorityCardContext,public2_NativeAuthorityCardRequest as NativeAuthorityCardRequest,public2_NativeAuthorityCardValue as NativeAuthorityCardValue,public2_NativeAuthorityJudgment as NativeAuthorityJudgment,public2_NativeCommand as NativeCommand,public2_NativeCommandHost as NativeCommandHost,public2_NativeCommandResult as NativeCommandResult,public2_NativeHostInstrument as NativeHostInstrument,public2_NativeHostLimits as NativeHostLimits,public2_NativeHostOptions as NativeHostOptions,public2_NativeProbeContext as NativeProbeContext,public2_NativeProbeCounter as NativeProbeCounter,public2_NativeProbeForm as NativeProbeForm,public2_NativeProbePort as NativeProbePort,public2_NativeProbeResult as NativeProbeResult,public2_NativeReadingIdentityContext as NativeReadingIdentityContext,public2_NativeReadingIdentityResult as NativeReadingIdentityResult,public2_NativeViewIdentitiesContext as NativeViewIdentitiesContext,public2_NativeViewIdentitiesResult as NativeViewIdentitiesResult,public2_NativeViewIdentityContext as NativeViewIdentityContext,public2_NativeViewIdentityResult as NativeViewIdentityResult,public2_PhysicalLinesPlaceInput as PhysicalLinesPlaceInput,public2_PhysicalLinesPolicy as PhysicalLinesPolicy,public2_PhysicalLinesReading as PhysicalLinesReading,public2_PhysicalLinesRegion as PhysicalLinesRegion,public2_PhysicalLinesWitnessAuthority as PhysicalLinesWitnessAuthority,public2_PlaceActBudget as PlaceActBudget,public2_PlaceActHostContext as PlaceActHostContext,public2_PlaceActHostPorts as PlaceActHostPorts,public2_PlaceActPersistence as PlaceActPersistence,public2_PlaceActTrust as PlaceActTrust,public2_PreparedReading as PreparedReading,public2_ProfileCompositionRequest as ProfileCompositionRequest,public2_ProfileFieldBinding as ProfileFieldBinding,public2_PublicationStorage as PublicationStorage,public2_ReadingPreparationLimits as ReadingPreparationLimits,public2_ReadingPreparationResult as ReadingPreparationResult,public2_ReadingProducerPolicy as ReadingProducerPolicy,public2_ReleaseCategory as ReleaseCategory,public2_RootLotContext as RootLotContext,public2_RootLotPorts as RootLotPorts,public2_RootStandingHostContext as RootStandingHostContext,public2_RootStandingHostResult as RootStandingHostResult,public2_answerNativeAuthorityCard as answerNativeAuthorityCard,public2_authenticatePhysicalLinesWitness as authenticatePhysicalLinesWitness,public2_composeProfile as composeProfile,public2_installedHostInstrument as installedHostInstrument,public2_installedPackageIdentity as installedPackageIdentity,public2_judgePhysicalLines as judgePhysicalLines,public2_landPlaceActInProcess as landPlaceActInProcess,public2_landRootLotInProcess as landRootLotInProcess,public2_nativeAuthorityCardView as nativeAuthorityCardView,public2_nativeAuthorityRequestIdentity as nativeAuthorityRequestIdentity,public2_nativeHostEnvironment as nativeHostEnvironment,public2_nativeHostInstrument as nativeHostInstrument,public2_nativePlaceActPersistence as nativePlaceActPersistence,public2_nativePlaceActReceiver as nativePlaceActReceiver,public2_parseNativeAuthorityCardRequest as parseNativeAuthorityCardRequest,public2_physicalLinesRegions as physicalLinesRegions,public2_prepareNativeAuthorityCard as prepareNativeAuthorityCard,public2_prepareNativeProbe as prepareNativeProbe,public2_prepareNativeReadingIdentity as prepareNativeReadingIdentity,public2_prepareNativeViewIdentities as prepareNativeViewIdentities,public2_prepareNativeViewIdentity as prepareNativeViewIdentity,public2_profileDigest as profileDigest,public2_readContextualStandingInProcess as readContextualStandingInProcess,public2_readPlacePhysicalLines as readPlacePhysicalLines,public2_readRootStandingInProcess as readRootStandingInProcess,public2_recoverPlaceActInProcess as recoverPlaceActInProcess,public2_recoverRootActInProcess as recoverRootActInProcess,public2_releaseCategoryPins as releaseCategoryPins,public2_rootLotSnapshot as rootLotSnapshot,public2_startNativeHost as startNativeHost} from "../public-types.js";
|
package/dist/host/index.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { readRootStandingInProcess } from "./in-process.js";
|
|
3
|
-
export { readContextualStandingInProcess } from "./in-process-context.js";
|
|
4
|
-
export { landPlaceActInProcess, recoverPlaceActInProcess } from "./in-process-act.js";
|
|
5
|
-
export { landRootLotInProcess, recoverRootActInProcess, rootLotSnapshot } from "./in-process-root.js";
|
|
6
|
-
export { nativeHostInstrument, nativePlaceActReceiver } from "./native-receiver.js";
|
|
7
|
-
export { nativePlaceActPersistence } from "./ports/place-act.js";
|
|
1
|
+
import{readRootStandingInProcess as r}from"./in-process.js";import{readContextualStandingInProcess as a}from"./in-process-context.js";import{landPlaceActInProcess as n,recoverPlaceActInProcess as s}from"./in-process-act.js";import{landRootLotInProcess as c,recoverRootActInProcess as d,rootLotSnapshot as l}from"./in-process-root.js";import{nativeHostInstrument as m,installedHostInstrument as v,nativePlaceActReceiver as f}from"./native-receiver.js";import{nativePlaceActPersistence as y}from"./ports/place-act.js";import{prepareNativeReadingIdentity as u,prepareNativeViewIdentity as h,prepareNativeViewIdentities as A}from"./reading-identity.js";import{prepareNativeProbe as N}from"./native/probes.js";import{physicalLinesRegions as C,readPlacePhysicalLines as L,authenticatePhysicalLinesWitness as w,judgePhysicalLines as H}from"./physical-lines.js";import{composeProfile as V,profileDigest as q,releaseCategoryPins as b}from"./profile-composition.js";import{installedPackageIdentity as k}from"./native/installed-package.js";import{prepareNativeAuthorityCard as E,answerNativeAuthorityCard as W,nativeAuthorityRequestIdentity as z,parseNativeAuthorityCardRequest as B}from"./native/authority-card.js";import{nativeAuthorityCardView as G}from"./native/authority-card-view.js";import{startNativeHost as K,nativeHostEnvironment as M}from"./persistent-host.js";export{W as answerNativeAuthorityCard,w as authenticatePhysicalLinesWitness,V as composeProfile,v as installedHostInstrument,k as installedPackageIdentity,H as judgePhysicalLines,n as landPlaceActInProcess,c as landRootLotInProcess,G as nativeAuthorityCardView,z as nativeAuthorityRequestIdentity,M as nativeHostEnvironment,m as nativeHostInstrument,y as nativePlaceActPersistence,f as nativePlaceActReceiver,B as parseNativeAuthorityCardRequest,C as physicalLinesRegions,E as prepareNativeAuthorityCard,N as prepareNativeProbe,u as prepareNativeReadingIdentity,A as prepareNativeViewIdentities,h as prepareNativeViewIdentity,q as profileDigest,a as readContextualStandingInProcess,L as readPlacePhysicalLines,r as readRootStandingInProcess,s as recoverPlaceActInProcess,d as recoverRootActInProcess,b as releaseCategoryPins,l as rootLotSnapshot,K as startNativeHost};
|
package/dist/host/io.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { spawn, spawnSync } from 'node:child_process';
|
|
3
|
-
export { createHash } from 'node:crypto';
|
|
4
|
-
export { appendFileSync, closeSync, existsSync, linkSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync, } from 'node:fs';
|
|
5
|
-
export { tmpdir } from 'node:os';
|
|
6
|
-
export { basename, dirname, join, relative, resolve } from 'node:path';
|
|
7
|
-
export { fileURLToPath } from 'node:url';
|
|
8
|
-
export { parentPort, workerData } from 'node:worker_threads';
|
|
9
|
-
export { gzipSync } from 'node:zlib';
|
|
10
|
-
/** UTF-8 encoding is shared with host-free protocol ports. */
|
|
11
|
-
export { encodeUTF8 } from "../engine/encoding.js";
|
|
1
|
+
import{spawn as n,spawnSync as o}from"node:child_process";import{createHash as a}from"node:crypto";import{appendFileSync as p,closeSync as y,existsSync as S,linkSync as m,lstatSync as i,mkdirSync as d,mkdtempSync as f,openSync as l,readFileSync as s,readSync as x,readdirSync as k,realpathSync as w,renameSync as F,rmSync as h,statSync as v,writeFileSync as P}from"node:fs";import{tmpdir as U}from"node:os";import{basename as g,dirname as j,join as z,relative as D,resolve as H}from"node:path";import{fileURLToPath as R}from"node:url";import{parentPort as u,workerData as A}from"node:worker_threads";import{gzipSync as C}from"node:zlib";import{encodeUTF8 as G}from"../engine/encoding.js";export{p as appendFileSync,g as basename,y as closeSync,a as createHash,j as dirname,G as encodeUTF8,S as existsSync,R as fileURLToPath,C as gzipSync,z as join,m as linkSync,i as lstatSync,d as mkdirSync,f as mkdtempSync,l as openSync,u as parentPort,s as readFileSync,x as readSync,k as readdirSync,w as realpathSync,D as relative,F as renameSync,H as resolve,h as rmSync,n as spawn,o as spawnSync,v as statSync,U as tmpdir,A as workerData,P as writeFileSync};
|