@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
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var x=Object.defineProperty;var c=(t,i)=>x(t,"name",{value:i,configurable:!0});import{library5_readingIdentityBytes as w,library5_readingReceiptBytes as U}from"../vendor/runtime.js";import{encodeUTF8 as B}from"./encoding.js";import{invokeByteComputationPort as q,invokeFrameSigningPort as v,invokeSignatureVerificationPort as p}from"./ports.js";import{BoundRefusal as A}from"../host/refusals.js";const a=c(t=>{throw new A("computation/"+t,"REFUSE\xB7computation/"+t)},"refuse"),f=c(t=>{(typeof t!="string"||!/^sha256:[a-f0-9]{64}$/.test(t))&&a("context")},"pin"),d=c(async(t,i)=>{const n=await t(new Uint8Array(i));return f(n),n},"hash"),b="computation/request";async function k(t,i,n){(!t||!t.reading||!(i instanceof Uint8Array)||typeof t.keyId!="string"||!t.keyId||typeof t.algorithm!="string"||!t.algorithm)&&a("context");let e;try{e=structuredClone(t)}catch{return a("context")}f(e.contract),f(e.numericPolicy);try{w(e.reading)}catch{return a("context")}for(const r of[e.reading.instrument,e.reading.implementation,e.reading.policy])f(r);e.reading.inputs.some(([r])=>r===b)&&a("context");const s={...e.reading,inputs:[...e.reading.inputs,[b,await d(n,i)]]};let o;try{o=w(s)}catch{return a("context")}const g=JSON.parse(new TextDecoder().decode(o)),y=await d(n,B(JSON.stringify(["computation-request@1",e.contract,e.numericPolicy,g[3],g[4],g[5]])));return{held:e,question:y,reading:await d(n,o)}}c(k,"prepare");function m(t){return JSON.stringify([t.profile,t.question,t.reading,t.origin,t.result,t.commitment,t.keyId,t.algorithm])+`
|
|
2
|
+
`}c(m,"frame");async function I(t,i,n){const e=await d(n,i);return{profile:"bound-computation@1",question:t.question,reading:t.reading,origin:t.held.reading.implementation,result:e,commitment:await d(n,U(t.reading,e)),keyId:t.held.keyId,algorithm:t.held.algorithm}}c(I,"statement");async function R(t,i,n,e,s){(!(i instanceof Uint8Array)||i.byteLength>e.maxBytes)&&a("budget");const o=new Uint8Array(i),g=await k(t,o,n.digest),y=await q(o,n.evaluate,e,s),r=await I(g,y,n.digest),u=m(r),h=await v({bytes:[u],keyId:r.keyId,algorithm:r.algorithm},n.sign,e,s),l=h[0];return await p(u,l,r.algorithm,n.verify,e,s)||a("signature"),{statement:Object.freeze({...r,signature:l.signature}),output:y}}c(R,"executeComputation");async function z(t,i,n,e,s,o,g){(!(i instanceof Uint8Array)||!(n instanceof Uint8Array)||i.byteLength>o.maxBytes||n.byteLength>o.maxBytes)&&a("budget"),(!e||Object.keys(e).sort().join(",")!=="algorithm,commitment,keyId,origin,profile,question,reading,result,signature"||typeof e.signature!="string")&&a("signature");const y=await k(t,new Uint8Array(i),s.digest),r=await I(y,new Uint8Array(n),s.digest),{signature:u,...h}=e;return m(h)!==m(r)&&a("context"),await p(m(r),{keyId:r.keyId,signature:u},r.algorithm,s.verify,o,g)||a("signature"),Object.freeze({...r,signature:u})}c(z,"verifyComputation");export{R as executeComputation,z as verifyComputation};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var j=Object.defineProperty;var f=(t,c)=>j(t,"name",{value:c,configurable:!0});import{encodeUTF8 as u}from"./encoding.js";import{invokeByteComputationPort as q}from"./ports.js";import{BoundRefusal as d}from"../host/refusals.js";const o=f(t=>{throw new d("conformance/"+t,"REFUSE\xB7conformance/"+t)},"fail"),A=f(t=>{(typeof t!="string"||!/^sha256:[a-f0-9]{64}$/.test(t))&&o("context")},"pin"),C=f((t,c)=>t.length===c.length&&t.every((l,i)=>l===c[i]),"equal"),m=f(t=>Array.isArray(t)&&t.every(c=>typeof c=="string"&&c.length>0)&&new Set(t).size===t.length,"unique");async function k(t,c,l,i,p){(!(t instanceof Uint8Array)||!i||!Number.isSafeInteger(i.maxCases)||i.maxCases<1||t.byteLength>i.maxBytes)&&o("budget"),(!c||typeof c!="object")&&o("context");let n;try{n=structuredClone(c)}catch{return o("context")}for(const e of[n.suite,n.implementation,n.contract])A(e);(!m(n.rules)||!m(n.refusals))&&o("coverage");const y=f(async e=>{const r=await l.digest(new Uint8Array(e));return A(r),r},"hash"),w=new Uint8Array(t);await y(w)!==n.suite&&o("integrity");let a;try{a=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(w))}catch{return o("suite")}(!a||Object.keys(a).sort().join(",")!=="cases,contract,profile"||a.profile!=="bound-conformance@1"||a.contract!==n.contract||!Array.isArray(a.cases)||!a.cases.length||a.cases.length>i.maxCases)&&o("suite");const v=new Set,x=new Set,S=[...n.rules.map(e=>"rule/"+e),...n.refusals.map(e=>"refusal/"+e)];for(const e of a.cases){(!e||Object.keys(e).sort().join(",")!=="covers,expected,id,request"||typeof e.id!="string"||!e.id||v.has(e.id)||!m(e.covers)||!e.covers.length||typeof e.request!="string"||typeof e.expected!="string")&&o("suite"),v.add(e.id);let r;try{r=JSON.parse(e.expected)}catch{return o("suite")}if(!Array.isArray(r)||r.length!==2||!["fact","refuse"].includes(r[0]))return o("suite");for(const s of e.covers)S.includes(s)||o("coverage"),s.startsWith("refusal/")&&(r[0]!=="refuse"||r[1]!==s.slice(8))&&o("coverage"),x.add(s)}S.some(e=>!x.has(e))&&o("coverage");const h=[];for(const e of a.cases){if(p?.aborted)throw new d("host-port/cancelled","REFUSE\xB7host-port/cancelled");let r;try{r=await q(u(e.request),async(s,O)=>{try{return await l.evaluate(s,O)}catch(g){if(g instanceof d)return u(JSON.stringify(["refuse",g.code])+`
|
|
2
|
+
`);throw g}},i,p)}catch(s){if(p?.aborted||s instanceof d&&["host-port/cancelled","host-port/timeout","host-port/budget"].includes(s.code))throw s;r=u(JSON.stringify(["refuse",s instanceof d?s.code:"operation/failed"])+`
|
|
3
|
+
`)}h.push({id:e.id,met:C(r,u(e.expected)),response:await y(r)})}const b={profile:"bound-conformance-report@1",suite:n.suite,implementation:n.implementation,contract:n.contract,met:h.every(e=>e.met),cases:h};return Object.freeze({...b,commitment:await y(u(JSON.stringify(b)+`
|
|
4
|
+
`))})}f(k,"runConformance");export{k as runConformance};
|
package/dist/engine/encoding.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const encodeUTF8 = (text) => new TextEncoder().encode(text);
|
|
1
|
+
var c=Object.defineProperty;var o=(e,t)=>c(e,"name",{value:t,configurable:!0});const n=o(e=>new TextEncoder().encode(e),"encodeUTF8"),r=o(e=>new TextDecoder("utf-8",{fatal:!0}).decode(e),"decodeUTF8");export{r as decodeUTF8,n as encodeUTF8};
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Pure projection of already admitted typed-object records.
|
|
3
|
-
* Input is the effective history already admitted by the host, preserving cell
|
|
4
|
-
* declarations before uses within each epoch and a deterministic selected context.
|
|
5
|
-
* This API performs no admission,
|
|
6
|
-
* signature verification, storage, transport, clock selection or execution.
|
|
7
|
-
* Object operations delegate to the existing Obligations implementation.
|
|
8
|
-
*/
|
|
9
|
-
export { objectFold } from './object.ts';
|
|
10
|
-
export type { ObjectReading } from './object.ts';
|
|
11
|
-
export type { ObjectRecord, ObjectContext } from '@lapxo/topos/wire';
|
|
12
|
-
export { readContent, retainContent, invokeSigningPort } from './ports.ts';
|
|
13
|
-
export type { PortLimits, ContentReadPort, PersistencePort, DigestPort, SigningPort, SigningLot, SignatureRecord } from './ports.ts';
|
|
1
|
+
export {public1_ByteComputationPort as ByteComputationPort,public1_ComputationContext as ComputationContext,public1_ComputationStatement as ComputationStatement,public1_ConformanceCase as ConformanceCase,public1_ConformanceReceiver as ConformanceReceiver,public1_ConformanceReport as ConformanceReport,public1_ConformanceSuite as ConformanceSuite,public1_ContentReadPort as ContentReadPort,public1_DigestPort as DigestPort,public1_ObjectContext as ObjectContext,public1_ObjectReading as ObjectReading,public1_ObjectRecord as ObjectRecord,public1_PersistencePort as PersistencePort,public1_PortLimits as PortLimits,public1_RefusalEntry as RefusalEntry,public1_SignatureRecord as SignatureRecord,public1_SignatureVerificationPort as SignatureVerificationPort,public1_SigningLot as SigningLot,public1_SigningPort as SigningPort,public1_executeComputation as executeComputation,public1_invokeSigningPort as invokeSigningPort,public1_objectFold as objectFold,public1_objectFoldBytes as objectFoldBytes,public1_readContent as readContent,public1_readRefusalCatalog as readRefusalCatalog,public1_retainContent as retainContent,public1_runConformance as runConformance,public1_verifyComputation as verifyComputation} from "../public-types.js";
|
package/dist/engine/index.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Input is the effective history already admitted by the host, preserving cell
|
|
4
|
-
* declarations before uses within each epoch and a deterministic selected context.
|
|
5
|
-
* This API performs no admission,
|
|
6
|
-
* signature verification, storage, transport, clock selection or execution.
|
|
7
|
-
* Object operations delegate to the existing Obligations implementation.
|
|
8
|
-
*/
|
|
9
|
-
export { objectFold } from "./object.js";
|
|
10
|
-
// Optional host operations are explicit and injected; objectFold itself never invokes them.
|
|
11
|
-
export { readContent, retainContent, invokeSigningPort } from "./ports.js";
|
|
1
|
+
var a=Object.defineProperty;var i=(n,t)=>a(n,"name",{value:t,configurable:!0});import{objectFold as b}from"./object.js";import{readContent as C,retainContent as E,invokeSigningPort as h}from"./ports.js";import{executeComputation as S,verifyComputation as R}from"./computation.js";import{runConformance as v}from"./conformance.js";import{readRefusalCatalog as O}from"../host/refusals.js";import{library14_validateObjectContext as c}from"../vendor/runtime.js";import{objectFold as f}from"./object.js";import{BoundRefusal as o}from"../host/refusals.js";import{encodeUTF8 as p,decodeUTF8 as u}from"./encoding.js";function x(n,t){let e;try{e=JSON.parse(u(n))}catch{throw new o("engine/input","REFUSE\xB7engine/input")}if(!Array.isArray(e)||e.length!==2||e[0]!=="bound-object-request@1"||!Array.isArray(e[1]))throw new o("engine/input","REFUSE\xB7engine/input");let r;try{r=c(e[1],t)}catch{throw new o("engine/context","REFUSE\xB7engine/context")}if(r.kind!=="fact")throw new o("engine/context","REFUSE\xB7engine/context");return p(JSON.stringify(["fact",f(r.value,t)])+`
|
|
2
|
+
`)}i(x,"objectFoldBytes");export{S as executeComputation,h as invokeSigningPort,b as objectFold,x as objectFoldBytes,C as readContent,O as readRefusalCatalog,E as retainContent,v as runConformance,R as verifyComputation};
|
package/dist/engine/object.js
CHANGED
|
@@ -1,38 +1 @@
|
|
|
1
|
-
import { cell,
|
|
2
|
-
import { restCoordinates } from '@lapxo/topos/wire';
|
|
3
|
-
export function objectFold(records, context) {
|
|
4
|
-
let world = new Map();
|
|
5
|
-
const definitions = new Map(records.filter(r => r.record === 'cell').map(r => [r.fields.scope, r]));
|
|
6
|
-
const codecs = new Map([...definitions].map(([name, c]) => [name, context.resolve(c)]));
|
|
7
|
-
const ids = new Map(records.map(r => [r.fields.id, r]));
|
|
8
|
-
for (const record of [...records].sort((a, b) => Number(a.fields.epoch) - Number(b.fields.epoch))) {
|
|
9
|
-
const f = record.fields, name = f.scope, at = Number(f.epoch);
|
|
10
|
-
if (record.record === 'cell') {
|
|
11
|
-
world = new Map([...world, [name, cell(name, at, [], restCoordinates(f.restsOn))]]);
|
|
12
|
-
continue;
|
|
13
|
-
}
|
|
14
|
-
const codec = codecs.get(name), L = codec.form.lattice(codec.params), held = world.get(name);
|
|
15
|
-
if (record.record === 'claim') {
|
|
16
|
-
const target = f.sign === '-1' ? ids.get(f.takes).fields : f;
|
|
17
|
-
const changed = observe(held, { id: f.id, at, origin: target.origin, span: codec.form.parse(codec.params, target.value), ...(f.takes ? { takes: f.takes } : {}) }, f.sign === '-1' ? -1 : 1);
|
|
18
|
-
const seen = [...changed.seen];
|
|
19
|
-
seen[seen.length - 1] = { ...seen.at(-1), id: f.id };
|
|
20
|
-
world = new Map([...world, [name, { ...changed, seen }]]);
|
|
21
|
-
}
|
|
22
|
-
else if (f.sign === '-1') {
|
|
23
|
-
const target = ids.get(f.takes).fields;
|
|
24
|
-
world = new Map([...world, [name, { ...held, marks: [...(held.marks ?? []), mark({ id: f.id, at, takes: f.takes, pole: target.pole, reach: 'local', span: codec.form.parse(codec.params, target.value) })] }]]);
|
|
25
|
-
}
|
|
26
|
-
else if (f.widens !== undefined) {
|
|
27
|
-
const changed = join(L, held, codec.form.parse(codec.params, f.value), f.widens, at);
|
|
28
|
-
const marks = [...(changed.marks ?? [])];
|
|
29
|
-
marks[marks.length - 1] = { ...marks.at(-1), id: f.id };
|
|
30
|
-
world = new Map([...world, [name, { ...changed, marks }]]);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
const span = codec.form.parse(codec.params, f.value);
|
|
34
|
-
world = f.pole === 'floor' ? requireFloor(L, world, name, span, { id: f.id, at }) : sign(L, world, name, span, { id: f.id, at });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return [...world].map(([name, c]) => { const codec = codecs.get(name), L = codec.form.lattice(codec.params); return { cell: name, state: state(L, c, world), parts: parts(L, c, world), rest: restOf(c, world), ownMarks: live(c.marks ?? []).map(m => m.id), ownClaims: live(c.seen).map(s => ({ id: s.id, origin: s.origin })), marks: live(c.marks ?? []), claims: live(c.seen) }; });
|
|
38
|
-
}
|
|
1
|
+
var w=Object.defineProperty;var k=(l,m)=>w(l,"name",{value:m,configurable:!0});import{library2_cell as y,library2_sign as _,library2_join as h,library2_require as v,library2_observe as M,library2_mark as j,library2_parts as C,library2_state as N,library2_live as c,library2_restOf as O}from"../vendor/runtime.js";import{library14_restCoordinates as q}from"../vendor/runtime.js";function z(l,m){let a=new Map;const u=new Map(l.filter(s=>s.record==="cell").map(s=>[s.fields.scope,s])),g=new Map([...u].map(([s,e])=>[s,m.resolve(e)])),b=new Map(l.map(s=>[s.fields.id,s]));for(const s of[...l].sort((e,i)=>Number(e.fields.epoch)-Number(i.fields.epoch))){const e=s.fields,i=e.scope,o=Number(e.epoch);if(s.record==="cell"){a=new Map([...a,[i,y(i,o,[],q(e.restsOn))]]);continue}const r=g.get(i),f=r.form.lattice(r.params),d=a.get(i);if(s.record==="claim"){const t=e.sign==="-1"?b.get(e.takes).fields:e,n=M(d,{id:e.id,at:o,origin:t.origin,span:r.form.parse(r.params,t.value),...e.takes?{takes:e.takes}:{}},e.sign==="-1"?-1:1),p=[...n.seen];p[p.length-1]={...p.at(-1),id:e.id},a=new Map([...a,[i,{...n,seen:p}]])}else if(e.sign==="-1"){const t=b.get(e.takes).fields;a=new Map([...a,[i,{...d,marks:[...d.marks??[],j({id:e.id,at:o,takes:e.takes,pole:t.pole,reach:"local",span:r.form.parse(r.params,t.value)})]}]])}else if(e.widens!==void 0){const t=h(f,d,r.form.parse(r.params,e.value),e.widens,o),n=[...t.marks??[]];n[n.length-1]={...n.at(-1),id:e.id},a=new Map([...a,[i,{...t,marks:n}]])}else{const t=r.form.parse(r.params,e.value);a=e.pole==="floor"?v(f,a,i,t,{id:e.id,at:o}):_(f,a,i,t,{id:e.id,at:o})}}return[...a].map(([s,e])=>{const i=g.get(s),o=i.form.lattice(i.params);return{cell:s,state:N(o,e,a),parts:C(o,e,a),rest:O(e,a),ownMarks:c(e.marks??[]).map(r=>r.id),ownClaims:c(e.seen).map(r=>({id:r.id,origin:r.origin})),marks:c(e.marks??[]),claims:c(e.seen)}})}k(z,"objectFold");export{z as objectFold};
|
package/dist/engine/ports.js
CHANGED
|
@@ -1,117 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { encodeUTF8 as encoded } from "./encoding.js";
|
|
4
|
-
class PortFault extends BoundRefusal {
|
|
5
|
-
}
|
|
6
|
-
const fail = (code) => { throw new PortFault('host-port/' + code, 'REFUSE·host-port/' + code); };
|
|
7
|
-
function limitsOf(limits) { if (!limits || !Number.isSafeInteger(limits.timeoutMs) || limits.timeoutMs < 1 || limits.timeoutMs > 2147483647 || !Number.isSafeInteger(limits.maxBytes) || limits.maxBytes < 1)
|
|
8
|
-
fail('budget'); }
|
|
9
|
-
/** The callback must cooperate with cancellation; JavaScript callbacks are not a sandbox. */
|
|
10
|
-
async function bounded(limits, signal, run) {
|
|
11
|
-
limitsOf(limits);
|
|
12
|
-
if (signal?.aborted)
|
|
13
|
-
fail('cancelled');
|
|
14
|
-
return new Promise((resolve, reject) => {
|
|
15
|
-
const controller = new AbortController();
|
|
16
|
-
let done = false;
|
|
17
|
-
const finish = (code, value) => { if (done)
|
|
18
|
-
return; done = true; clearTimeout(timer); signal?.removeEventListener('abort', abort); if (code) {
|
|
19
|
-
controller.abort();
|
|
20
|
-
reject(new BoundRefusal('host-port/' + code, 'REFUSE·host-port/' + code));
|
|
21
|
-
}
|
|
22
|
-
else
|
|
23
|
-
resolve(value); };
|
|
24
|
-
const abort = () => finish('cancelled'), timer = setTimeout(() => finish('timeout'), limits.timeoutMs);
|
|
25
|
-
signal?.addEventListener('abort', abort, { once: true });
|
|
26
|
-
if (signal?.aborted) {
|
|
27
|
-
abort();
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
Promise.resolve().then(() => { if (done)
|
|
31
|
-
fail('cancelled'); return run(controller.signal); }).then(value => finish(undefined, value), error => finish(error instanceof PortFault ? error.code.slice('host-port/'.length) : 'failed'));
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function owned(bytes, maxBytes) { if (!(bytes instanceof Uint8Array))
|
|
35
|
-
fail('response'); if (bytes.byteLength > maxBytes)
|
|
36
|
-
fail('budget'); if (typeof SharedArrayBuffer !== 'undefined' && bytes.buffer instanceof SharedArrayBuffer)
|
|
37
|
-
fail('response'); return new Uint8Array(bytes); }
|
|
38
|
-
const identity = (digest) => { if (!/^sha256:[a-f0-9]{64}$/.test(digest))
|
|
39
|
-
fail('integrity'); };
|
|
40
|
-
export async function readContent(source, digest, ports, limits, signal) {
|
|
41
|
-
limitsOf(limits);
|
|
42
|
-
identity(digest);
|
|
43
|
-
return bounded(limits, signal, async (s) => { const bytes = owned(await ports.read(source, digest, s), limits.maxBytes); if (s.aborted)
|
|
44
|
-
fail('cancelled'); if (await ports.digestBytes(new Uint8Array(bytes)) !== digest)
|
|
45
|
-
fail('integrity'); if (s.aborted)
|
|
46
|
-
fail('cancelled'); return bytes; });
|
|
47
|
-
}
|
|
48
|
-
/** Verify before invoking retention; no operation automatically writes the projected result. */
|
|
49
|
-
export async function retainContent(digest, bytes, ports, limits, signal) {
|
|
50
|
-
limitsOf(limits);
|
|
51
|
-
identity(digest);
|
|
52
|
-
if (signal?.aborted)
|
|
53
|
-
fail('cancelled');
|
|
54
|
-
const copy = owned(bytes, limits.maxBytes);
|
|
55
|
-
return bounded(limits, signal, async (s) => { if (await ports.digestBytes(new Uint8Array(copy)) !== digest)
|
|
56
|
-
fail('integrity'); if (s.aborted)
|
|
57
|
-
fail('cancelled'); const result = await ports.retain(digest, copy, s); if (result !== undefined)
|
|
58
|
-
fail('response'); return Object.freeze({ digest, bytes: copy.byteLength }); });
|
|
59
|
-
}
|
|
60
|
-
/** Acquire canonical line signatures only. The line protocol is not widened
|
|
61
|
-
* for contextual receipt frames. Both operations share bounds and response checks. */
|
|
62
|
-
export async function invokeSigningPort(lot, sign, limits, signal) {
|
|
63
|
-
validateSigningLot(lot, limits);
|
|
64
|
-
let request;
|
|
65
|
-
try {
|
|
66
|
-
request = signerRequestBytes(lot);
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
return fail('response');
|
|
70
|
-
}
|
|
71
|
-
return invokeDeclaredSignatures(lot, request, sign, limits, signal);
|
|
72
|
-
}
|
|
73
|
-
/** Host-prepared signature frames. This acquires no authority: the contextual
|
|
74
|
-
* transaction validates the frame's domain/receiver and verifies every signature.
|
|
75
|
-
* A carrier cannot select this operation or supply a signature verifier. */
|
|
76
|
-
export async function invokeFrameSigningPort(lot, sign, limits, signal) {
|
|
77
|
-
validateSigningLot(lot, limits);
|
|
78
|
-
return invokeDeclaredSignatures(lot, JSON.stringify(lot) + '\n', sign, limits, signal);
|
|
79
|
-
}
|
|
80
|
-
function validateSigningLot(lot, limits) {
|
|
81
|
-
limitsOf(limits);
|
|
82
|
-
if (!lot || !Array.isArray(lot.bytes) || !lot.bytes.length || typeof lot.keyId !== 'string' || !lot.keyId || typeof lot.algorithm !== 'string' || !lot.algorithm)
|
|
83
|
-
fail('budget');
|
|
84
|
-
let size = 0;
|
|
85
|
-
for (const bytes of lot.bytes) {
|
|
86
|
-
if (typeof bytes !== 'string' || bytes.length > limits.maxBytes - size)
|
|
87
|
-
fail('budget');
|
|
88
|
-
size += encoded(bytes).length + 1;
|
|
89
|
-
if (size > limits.maxBytes)
|
|
90
|
-
fail('budget');
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function invokeDeclaredSignatures(lot, request, sign, limits, signal) {
|
|
94
|
-
if (encoded(request).length > limits.maxBytes)
|
|
95
|
-
fail('budget');
|
|
96
|
-
const input = Object.freeze({ ...lot, bytes: Object.freeze([...lot.bytes]) });
|
|
97
|
-
return bounded(limits, signal, async (s) => {
|
|
98
|
-
const records = await sign(input, s);
|
|
99
|
-
if (!Array.isArray(records) || records.length !== lot.bytes.length || records.some(r => !r || typeof r.signature !== 'string' || r.signature.length > limits.maxBytes))
|
|
100
|
-
fail('response');
|
|
101
|
-
let response;
|
|
102
|
-
try {
|
|
103
|
-
response = signerResponseBytes(records);
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
return fail('response');
|
|
107
|
-
}
|
|
108
|
-
if (encoded(response).length > limits.maxBytes)
|
|
109
|
-
fail('budget');
|
|
110
|
-
try {
|
|
111
|
-
return Object.freeze(signerResponseOf(response, lot).map(record => Object.freeze({ ...record })));
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
return fail('response');
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
1
|
+
var v=Object.defineProperty;var s=(e,t)=>v(e,"name",{value:t,configurable:!0});import{library14_signerRequestBytes as A,library14_signerResponseBytes as O,library14_signerResponseOf as R}from"../vendor/runtime.js";import{BoundRefusal as B}from"../host/refusals.js";import{encodeUTF8 as b}from"./encoding.js";function j(e,t,n,r){g(n);const a=h(e,n.maxBytes);return p(n,r,async i=>h(await t(a,i),n.maxBytes))}s(j,"invokeByteComputationPort");function E(e,t,n,r,a,i){return g(a),b(e).length+b(t.signature).length>a.maxBytes&&o("budget"),p(a,i,async f=>{const c=await r(e,Object.freeze({...t}),n,f);return typeof c!="boolean"&&o("response"),c})}s(E,"invokeSignatureVerificationPort");class x extends B{static{s(this,"PortFault")}}const o=s(e=>{throw new x("host-port/"+e,"REFUSE\xB7host-port/"+e)},"fail");function g(e){(!e||!Number.isSafeInteger(e.timeoutMs)||e.timeoutMs<1||e.timeoutMs>2147483647||!Number.isSafeInteger(e.maxBytes)||e.maxBytes<1)&&o("budget")}s(g,"limitsOf");async function p(e,t,n){return g(e),t?.aborted&&o("cancelled"),new Promise((r,a)=>{const i=new AbortController;let f=!1;const c=s((u,S)=>{f||(f=!0,clearTimeout(d),t?.removeEventListener("abort",y),u?(i.abort(),a(new B("host-port/"+u,"REFUSE\xB7host-port/"+u))):r(S))},"finish"),y=s(()=>c("cancelled"),"abort"),d=setTimeout(()=>c("timeout"),e.timeoutMs);if(t?.addEventListener("abort",y,{once:!0}),t?.aborted){y();return}Promise.resolve().then(()=>(f&&o("cancelled"),n(i.signal))).then(u=>c(void 0,u),u=>c(u instanceof x?u.code.slice(10):"failed"))})}s(p,"bounded");function h(e,t){return e instanceof Uint8Array||o("response"),e.byteLength>t&&o("budget"),typeof SharedArrayBuffer<"u"&&e.buffer instanceof SharedArrayBuffer&&o("response"),new Uint8Array(e)}s(h,"owned");const l=s(e=>{/^sha256:[a-f0-9]{64}$/.test(e)||o("integrity")},"identity");async function F(e,t,n,r,a){return g(r),l(t),p(r,a,async i=>{const f=h(await n.read(e,t,i),r.maxBytes);return i.aborted&&o("cancelled"),await n.digestBytes(new Uint8Array(f))!==t&&o("integrity"),i.aborted&&o("cancelled"),f})}s(F,"readContent");async function L(e,t,n,r,a){g(r),l(e),a?.aborted&&o("cancelled");const i=h(t,r.maxBytes);return p(r,a,async f=>(await n.digestBytes(new Uint8Array(i))!==e&&o("integrity"),f.aborted&&o("cancelled"),await n.retain(e,i,f)!==void 0&&o("response"),Object.freeze({digest:e,bytes:i.byteLength})))}s(L,"retainContent");async function C(e,t,n,r){m(e,n);let a;try{a=A(e)}catch{return o("response")}return w(e,a,t,n,r)}s(C,"invokeSigningPort");async function I(e,t,n,r){return m(e,n),w(e,JSON.stringify(e)+`
|
|
2
|
+
`,t,n,r)}s(I,"invokeFrameSigningPort");function m(e,t){g(t),(!e||!Array.isArray(e.bytes)||!e.bytes.length||typeof e.keyId!="string"||!e.keyId||typeof e.algorithm!="string"||!e.algorithm)&&o("budget");let n=0;for(const r of e.bytes)(typeof r!="string"||r.length>t.maxBytes-n)&&o("budget"),n+=b(r).length+1,n>t.maxBytes&&o("budget")}s(m,"validateSigningLot");function w(e,t,n,r,a){b(t).length>r.maxBytes&&o("budget");const i=Object.freeze({...e,bytes:Object.freeze([...e.bytes])});return p(r,a,async f=>{const c=await n(i,f);(!Array.isArray(c)||c.length!==e.bytes.length||c.some(d=>!d||typeof d.signature!="string"||d.signature.length>r.maxBytes))&&o("response");let y;try{y=O(c)}catch{return o("response")}b(y).length>r.maxBytes&&o("budget");try{return Object.freeze(R(y,e).map(d=>Object.freeze({...d})))}catch{return o("response")}})}s(w,"invokeDeclaredSignatures");export{j as invokeByteComputationPort,I as invokeFrameSigningPort,E as invokeSignatureVerificationPort,C as invokeSigningPort,F as readContent,L as retainContent};
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { rootLedgerLines, storeOf } from "../land/ledger.js";
|
|
3
|
-
import { fieldOf, isConfig } from "./claims.js";
|
|
4
|
-
/** Local admission history only. Foreign ingress is evidence, never coverage.
|
|
5
|
-
* The clock cutoff is meaningful for configuration; object clocks stay intact. */
|
|
6
|
-
export function admissionHistoryAt(root, epoch) {
|
|
7
|
-
const store = storeOf(root);
|
|
8
|
-
return [...new Set(rootLedgerLines(store))]
|
|
9
|
-
.filter(line => fieldOf(line, 'sig') !== '' && (!isConfig(line) || Number(fieldOf(line, 'epoch')) <= epoch));
|
|
10
|
-
}
|
|
11
|
-
/** The original local bootstrap, never today's key selection. */
|
|
12
|
-
export function admissionAnchor(root) {
|
|
13
|
-
const anchor = bootstrapAnchor(root);
|
|
14
|
-
if (!anchor)
|
|
15
|
-
throw Error('REFUSE·act historical admission requires one bootstrap anchor');
|
|
16
|
-
return { id: anchor.id, keyClass: 'authorize', publicKey: anchor.publicKey, coverage: anchor.coverage, depth: { lo: 1, hi: 16 }, admittedBy: [] };
|
|
17
|
-
}
|
|
1
|
+
var f=Object.defineProperty;var i=(o,e)=>f(o,"name",{value:e,configurable:!0});import{bootstrapAnchor as d}from"./bootstrap-anchor.js";import{rootLedgerLines as u,storeOf as h}from"../land/ledger.js";import{fieldOf as c,isConfig as m}from"./claims.js";const a=new WeakMap;function y(o,e){const r=u(h(o)),s=Object.isFrozen(r)?a.get(r):void 0;if(s?.epoch===e)return s.lines;const n=Object.freeze([...new Set(r)].filter(t=>c(t,"sig")!==""&&(!m(t)||Number(c(t,"epoch"))<=e)));return Object.isFrozen(r)&&a.set(r,{epoch:e,lines:n}),n}i(y,"admissionHistoryAt");function O(o){const e=d(o);if(!e)throw Error("REFUSE\xB7act historical admission requires one bootstrap anchor");return{id:e.id,keyClass:"authorize",publicKey:e.publicKey,coverage:e.coverage,depth:{lo:1,hi:16},admittedBy:[]}}i(O,"admissionAnchor");export{O as admissionAnchor,y as admissionHistoryAt};
|
|
@@ -1,28 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
3
|
-
import { storeOf } from "../land/ledger.js";
|
|
4
|
-
/** Read the existing place-local root of trust. Names and current claims select no authority. */
|
|
5
|
-
export function bootstrapAnchor(root) {
|
|
6
|
-
const store = storeOf(root);
|
|
7
|
-
const files = existsSync(store) ? readdirSync(store).filter(name => name.endsWith('.keys')).sort() : [];
|
|
8
|
-
if (!files.length)
|
|
9
|
-
return undefined;
|
|
10
|
-
const candidates = files.map(name => {
|
|
11
|
-
let keys;
|
|
12
|
-
try {
|
|
13
|
-
keys = JSON.parse(readFileSync(join(store, name), 'utf8'));
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
throw Error('REFUSE·act bootstrap anchor is unreadable');
|
|
17
|
-
}
|
|
18
|
-
const anchors = Object.values(keys ?? {}), anchor = anchors[0];
|
|
19
|
-
if (anchors.length !== 1 || !anchor || typeof anchor.id !== 'string' || !anchor.id || typeof anchor.publicKey !== 'string' || !anchor.publicKey || !Array.isArray(anchor.coverage) || !anchor.coverage.length || anchor.coverage.some(scope => typeof scope !== 'string' || !scope))
|
|
20
|
-
throw Error('REFUSE·act historical admission requires one bootstrap anchor');
|
|
21
|
-
return anchor;
|
|
22
|
-
});
|
|
23
|
-
const identities = new Set(candidates.map(anchor => JSON.stringify([anchor.id, anchor.publicKey, [...new Set(anchor.coverage)].sort()])));
|
|
24
|
-
if (identities.size !== 1)
|
|
25
|
-
throw Error('REFUSE·act conflicting bootstrap anchors');
|
|
26
|
-
const anchor = candidates[0];
|
|
27
|
-
return { id: anchor.id, publicKey: anchor.publicKey, coverage: anchor.coverage };
|
|
28
|
-
}
|
|
1
|
+
var y=Object.defineProperty;var f=(o,e)=>y(o,"name",{value:e,configurable:!0});import{viewInput as d}from"../host/reading-context.js";import{join as l}from"node:path";import{existsSync as h,readFileSync as u,readdirSync as g}from"node:fs";import{storeOf as b}from"../land/ledger.js";function F(o){const e=b(o),n=d("anchor-files:"+e,()=>h(e)?g(e).filter(t=>t.endsWith(".keys")).sort():[]);if(!n.length)return;const s=n.map(t=>{let c;try{c=JSON.parse(d("anchor:"+l(e,t),()=>u(l(e,t),"utf8")))}catch{throw Error("REFUSE\xB7act bootstrap anchor is unreadable")}const a=Object.values(c??{}),r=a[0];if(a.length!==1||!r||typeof r.id!="string"||!r.id||typeof r.publicKey!="string"||!r.publicKey||!Array.isArray(r.coverage)||!r.coverage.length||r.coverage.some(p=>typeof p!="string"||!p))throw Error("REFUSE\xB7act historical admission requires one bootstrap anchor");return r});if(new Set(s.map(t=>JSON.stringify([t.id,t.publicKey,[...new Set(t.coverage)].sort()]))).size!==1)throw Error("REFUSE\xB7act conflicting bootstrap anchors");const i=s[0];return{id:i.id,publicKey:i.publicKey,coverage:i.coverage}}f(F,"bootstrapAnchor");export{F as bootstrapAnchor};
|
package/dist/fold/ceilings.js
CHANGED
|
@@ -1,142 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fieldOf } from "./claims.js";
|
|
3
|
-
import { wordOf, wordsOf } from "./wire.js";
|
|
4
|
-
import { lockStanding } from "./keys.js";
|
|
5
|
-
import { ownLock, ownStore } from "../observe/runner.js";
|
|
6
|
-
import { ALPHABETS, idsOf, INTERVALS, spanOf } from '@lapxo/topos/forms';
|
|
7
|
-
import { placedReadings } from "./observed.js";
|
|
8
|
-
import { combine, matches } from '@lapxo/topos/wire';
|
|
9
|
-
function meeting(scope) {
|
|
10
|
-
const whole = region(scope);
|
|
11
|
-
const steps = scope.split('/');
|
|
12
|
-
const cuts = steps.slice(1).map((_, i) => ({ head: region(steps.slice(0, i + 1).join('/')), tail: region(steps.slice(i + 1).join('/')) }));
|
|
13
|
-
const globbed = steps.some((step) => step.includes('*') && step !== '*' && step !== '**');
|
|
14
|
-
return (reading) => within(reading.asked, whole)
|
|
15
|
-
|| cuts.some(({ head, tail }) => (within(reading.asked, head) && within(reading.where, tail))
|
|
16
|
-
|| (within(reading.where, head) && within(reading.asked, tail)))
|
|
17
|
-
|| (globbed && steps.slice(1).some((_, i) => matches(steps.slice(0, i + 1).join('/'), reading.question) && matches(steps.slice(i + 1).join('/'), reading.where.at.join('/'))));
|
|
18
|
-
}
|
|
19
|
-
export const answersElsewhere = (ceiling, own, under, places) => {
|
|
20
|
-
const measure = fieldOf(ceiling, 'measure');
|
|
21
|
-
const step = fieldOf(ceiling, 'scope').split('/')[0] ?? '';
|
|
22
|
-
const here = under?.split('/')[0];
|
|
23
|
-
return here !== undefined && step !== here && (places?.has(step) ?? false) && (own[measure] ?? (measure === 'count' ? own[fieldOf(ceiling, 'scope')] : undefined)) !== undefined;
|
|
24
|
-
};
|
|
25
|
-
export function foldCeilings(input) {
|
|
26
|
-
const readings = new Map();
|
|
27
|
-
for (const got of placedReadings(input.observed)) {
|
|
28
|
-
const mine = readings.get(got.measure) ?? [];
|
|
29
|
-
mine.push({ question: got.question, measure: got.measure, value: got.value, asked: point(got.question), where: point(got.place) });
|
|
30
|
-
readings.set(got.measure, mine);
|
|
31
|
-
}
|
|
32
|
-
const unreadOf = (standing) => wordsOf(standing, 'states').includes('unread') ? wordOf(standing, 'states', 'unread') : undefined;
|
|
33
|
-
const UNREAD = unreadOf(input.standing) ?? unreadOf(ownLock()) ?? unreadOf(lockStanding(ownStore()));
|
|
34
|
-
const read = [];
|
|
35
|
-
const over = [];
|
|
36
|
-
const unmet = [];
|
|
37
|
-
const lines = new Map();
|
|
38
|
-
for (const one of readings.get('line') ?? []) {
|
|
39
|
-
lines.set(`${one.question} ${one.where.at.join('/')}`, new Map(one.value.split('|').filter(Boolean).map((pair) => [pair.slice(0, pair.lastIndexOf(':')), pair.slice(pair.lastIndexOf(':') + 1)])));
|
|
40
|
-
}
|
|
41
|
-
const said = new Map();
|
|
42
|
-
const bound = (ceiling, question, met, at) => {
|
|
43
|
-
const scope = fieldOf(ceiling, 'scope');
|
|
44
|
-
const want = fieldOf(ceiling, 'value');
|
|
45
|
-
const heard = (got) => void said.set(scope, [...(said.get(scope) ?? []), question === scope ? got : `${question} ${got}`]);
|
|
46
|
-
if (fieldOf(ceiling, 'form') === 'interval') {
|
|
47
|
-
const span = spanOf(want);
|
|
48
|
-
if (!span)
|
|
49
|
-
return;
|
|
50
|
-
const lows = met.map((value) => spanOf(value)?.lo ?? 0);
|
|
51
|
-
let total;
|
|
52
|
-
try {
|
|
53
|
-
total = combine(fieldOf(ceiling, 'measure'), lows);
|
|
54
|
-
}
|
|
55
|
-
catch {
|
|
56
|
-
over.push({ ceiling: scope, question, got: `no combination for ${fieldOf(ceiling, 'measure')}, read ${lows.length} times`, side: 'over' });
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const at = { lo: total, hi: total };
|
|
60
|
-
heard(String(total));
|
|
61
|
-
if (!INTERVALS.leq(at, { lo: span.lo, hi: Infinity }))
|
|
62
|
-
over.push({ ceiling: scope, question, got: String(total), side: 'short' });
|
|
63
|
-
if (!INTERVALS.leq(at, { lo: -Infinity, hi: span.hi }))
|
|
64
|
-
over.push({ ceiling: scope, question, got: String(total), side: 'over' });
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const joined = new Set(met.flatMap((value) => [...idsOf(value).values]));
|
|
68
|
-
heard([...joined].sort().join('|') || 'none');
|
|
69
|
-
const allowed = idsOf(want);
|
|
70
|
-
if (!ALPHABETS.leq({ polarity: 'permit', values: joined }, allowed)) {
|
|
71
|
-
const outside = [...joined].filter((id) => allowed.values.has(id) === (allowed.polarity === 'forbid')).sort();
|
|
72
|
-
const line = (id) => (at === undefined || lines.get(at)?.get(id) === undefined ? id : `${id}:${lines.get(at).get(id)}`);
|
|
73
|
-
over.push({ ceiling: scope, question, got: outside.map(line).join('|'), side: 'over' });
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const own = (measure) => (measure === UNREAD ? undefined : input.own[measure]);
|
|
77
|
-
// A coordinate projected into this place is not a narrower question merely
|
|
78
|
-
// because its host prefix adds a segment.
|
|
79
|
-
const localScope = (scope) => input.under && scope.startsWith(input.under)
|
|
80
|
-
? scope.slice(input.under.length) : scope;
|
|
81
|
-
const literal = (scope) => localScope(scope).split('/').filter((step) => !step.includes('*')).length;
|
|
82
|
-
const last = [];
|
|
83
|
-
for (const ceiling of input.ceilings) {
|
|
84
|
-
const measure = fieldOf(ceiling, 'measure');
|
|
85
|
-
if (measure === UNREAD) {
|
|
86
|
-
last.push(ceiling);
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
const mine = own(measure) ?? (measure === 'count' ? input.own[fieldOf(ceiling, 'scope')] : undefined);
|
|
90
|
-
if (answersElsewhere(ceiling, input.own, input.under, input.places))
|
|
91
|
-
continue;
|
|
92
|
-
if (mine !== undefined) {
|
|
93
|
-
read.push(ceiling);
|
|
94
|
-
bound(ceiling, fieldOf(ceiling, 'scope'), [`${mine}..${mine}`]);
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
const byQuestion = new Map();
|
|
98
|
-
const where = new Map();
|
|
99
|
-
const meets = meeting(fieldOf(ceiling, 'scope'));
|
|
100
|
-
const alone = measure === 'per-file' || fieldOf(ceiling, 'scope').endsWith('/*') || fieldOf(ceiling, 'form') === 'alphabet';
|
|
101
|
-
const narrower = spanOf(fieldOf(ceiling, 'value')) ? input.ceilings.filter((other) => fieldOf(other, 'measure') === measure && spanOf(fieldOf(other, 'value')) && literal(fieldOf(other, 'scope')) > literal(fieldOf(ceiling, 'scope'))).map((other) => meeting(fieldOf(other, 'scope'))) : [];
|
|
102
|
-
for (const reading of readings.get(measure) ?? []) {
|
|
103
|
-
if (!meets(reading) || narrower.some((one) => one(reading)))
|
|
104
|
-
continue;
|
|
105
|
-
const question = alone ? reading.where.at.join('/') : reading.question;
|
|
106
|
-
byQuestion.set(question, [...(byQuestion.get(question) ?? []), reading.value]);
|
|
107
|
-
where.set(question, `${reading.question} ${reading.where.at.join('/')}`);
|
|
108
|
-
}
|
|
109
|
-
if (!byQuestion.size) {
|
|
110
|
-
unmet.push(ceiling);
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
read.push(ceiling);
|
|
114
|
-
for (const [question, met] of byQuestion)
|
|
115
|
-
bound(ceiling, question, met, where.get(question));
|
|
116
|
-
}
|
|
117
|
-
for (const ceiling of last) {
|
|
118
|
-
read.push(ceiling);
|
|
119
|
-
bound(ceiling, fieldOf(ceiling, 'scope'), [`${unmet.length}..${unmet.length}`]);
|
|
120
|
-
}
|
|
121
|
-
const epochOf = (line) => Number(fieldOf(line, 'epoch')) || 0;
|
|
122
|
-
return {
|
|
123
|
-
read,
|
|
124
|
-
over,
|
|
125
|
-
unread: unmet.filter((line) => epochOf(line) > input.epoch - 3),
|
|
126
|
-
vacuous: unmet.filter((line) => epochOf(line) <= input.epoch - 3),
|
|
127
|
-
readings: said,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function listed(misses) {
|
|
131
|
-
const by = new Map();
|
|
132
|
-
for (const o of misses)
|
|
133
|
-
by.set(o.ceiling, [...(by.get(o.ceiling) ?? []), o.question === o.ceiling ? o.got : `${o.question}=${o.got}`]);
|
|
134
|
-
return [...by].map(([scope, got]) => `${scope} · ${got.length > 4 ? `${got.slice(0, 4).join(' ')} +${got.length - 4}` : got.join(' ')}`);
|
|
135
|
-
}
|
|
136
|
-
/** One summary for fresh and retained judgments over the same declared bounds. */
|
|
137
|
-
export function ceilingSummary(fold, total, shared = new Set()) {
|
|
138
|
-
return { read: fold.read.length, total, unread: fold.unread.map(line => fieldOf(line, 'scope')),
|
|
139
|
-
vacuous: fold.vacuous.map(line => fieldOf(line, 'scope')),
|
|
140
|
-
short: listed(fold.over.filter(one => one.side === 'short' && !shared.has(one.question))),
|
|
141
|
-
over: listed(fold.over.filter(one => one.side === 'over')) };
|
|
142
|
-
}
|
|
1
|
+
var V=Object.defineProperty;var f=(o,a)=>V(o,"name",{value:a,configurable:!0});import{library0_point as I,library0_region as q,library0_within as $}from"../vendor/runtime.js";import{fieldOf as n}from"./claims.js";import{wordOf as W,wordsOf as z}from"./wire.js";import{lockStanding as C}from"./keys.js";import{ownLock as D,ownStore as Q}from"../observe/runner.js";import{library7_ALPHABETS as U,library7_idsOf as x,library7_INTERVALS as L,library7_spanOf as S}from"../vendor/runtime.js";import{placedReadings as F}from"./observed.js";import{library14_combine as G,library14_matches as N}from"../vendor/runtime.js";function R(o){const a=q(o),s=o.split("/"),r=s.slice(1).map((i,u)=>({head:q(s.slice(0,u+1).join("/")),tail:q(s.slice(u+1).join("/"))})),p=s.some(i=>i.includes("*")&&i!=="*"&&i!=="**");return i=>$(i.asked,a)||r.some(({head:u,tail:h})=>$(i.asked,u)&&$(i.where,h)||$(i.where,u)&&$(i.asked,h))||p&&s.slice(1).some((u,h)=>N(s.slice(0,h+1).join("/"),i.question)&&N(s.slice(h+1).join("/"),i.where.at.join("/")))}f(R,"meeting");const J=f((o,a,s,r)=>{const p=n(o,"measure"),i=n(o,"scope").split("/")[0]??"",u=s?.split("/")[0];return u!==void 0&&i!==u&&(r?.has(i)??!1)&&(a[p]??(p==="count"?a[n(o,"scope")]:void 0))!==void 0},"answersElsewhere");function ie(o){const a=new Map;for(const e of F(o.observed)){const t=a.get(e.measure)??[];t.push({question:e.question,measure:e.measure,value:e.value,asked:I(e.question),where:I(e.place)}),a.set(e.measure,t)}const s=f(e=>z(e,"states").includes("unread")?W(e,"states","unread"):void 0,"unreadOf"),r=s(o.standing)??s(D())??s(C(Q())),p=[],i=[],u=[],h=new Map;for(const e of a.get("line")??[])h.set(`${e.question} ${e.where.at.join("/")}`,new Map(e.value.split("|").filter(Boolean).map(t=>[t.slice(0,t.lastIndexOf(":")),t.slice(t.lastIndexOf(":")+1)])));const O=new Map,_=f((e,t,w,g)=>{const m=n(e,"scope"),y=n(e,"value"),j=f(l=>{O.set(m,[...O.get(m)??[],t===m?l:`${t} ${l}`])},"heard");if(n(e,"form")==="interval"){const l=S(y);if(!l)return;const v=w.map(P=>S(P)?.lo??0);let d;try{d=G(n(e,"measure"),v)}catch{i.push({ceiling:m,question:t,got:`no combination for ${n(e,"measure")}, read ${v.length} times`,side:"over"});return}const E={lo:d,hi:d};j(String(d)),L.leq(E,{lo:l.lo,hi:1/0})||i.push({ceiling:m,question:t,got:String(d),side:"short"}),L.leq(E,{lo:-1/0,hi:l.hi})||i.push({ceiling:m,question:t,got:String(d),side:"over"});return}const b=new Set(w.flatMap(l=>[...x(l).values]));j([...b].sort().join("|")||"none");const c=x(y);if(!U.leq({polarity:"permit",values:b},c)){const l=[...b].filter(d=>c.values.has(d)===(c.polarity==="forbid")).sort(),v=f(d=>g===void 0||h.get(g)?.get(d)===void 0?d:`${d}:${h.get(g).get(d)}`,"line");i.push({ceiling:m,question:t,got:l.map(v).join("|"),side:"over"})}},"bound"),B=f(e=>e===r?void 0:o.own[e],"own"),H=f(e=>o.under&&e.startsWith(o.under)?e.slice(o.under.length):e,"localScope"),M=f(e=>H(e).split("/").filter(t=>!t.includes("*")).length,"literal"),A=[];for(const e of o.ceilings){const t=n(e,"measure");if(t===r){A.push(e);continue}const w=B(t)??(t==="count"?o.own[n(e,"scope")]:void 0);if(J(e,o.own,o.under,o.places))continue;if(w!==void 0){p.push(e),_(e,n(e,"scope"),[`${w}..${w}`]);continue}const g=new Map,m=new Map,y=R(n(e,"scope")),j=t==="per-file"||n(e,"scope").endsWith("/*")||n(e,"form")==="alphabet",b=S(n(e,"value"))?o.ceilings.filter(c=>n(c,"measure")===t&&S(n(c,"value"))&&M(n(c,"scope"))>M(n(e,"scope"))).map(c=>R(n(c,"scope"))):[];for(const c of a.get(t)??[]){if(!y(c)||b.some(v=>v(c)))continue;const l=j?c.where.at.join("/"):c.question;g.set(l,[...g.get(l)??[],c.value]),m.set(l,`${c.question} ${c.where.at.join("/")}`)}if(!g.size){u.push(e);continue}p.push(e);for(const[c,l]of g)_(e,c,l,m.get(c))}for(const e of A)p.push(e),_(e,n(e,"scope"),[`${u.length}..${u.length}`]);const k=f(e=>Number(n(e,"epoch"))||0,"epochOf");return{read:p,over:i,unread:u.filter(e=>k(e)>o.epoch-3),vacuous:u.filter(e=>k(e)<=o.epoch-3),readings:O}}f(ie,"foldCeilings");function T(o){const a=new Map;for(const s of o)a.set(s.ceiling,[...a.get(s.ceiling)??[],s.question===s.ceiling?s.got:`${s.question}=${s.got}`]);return[...a].map(([s,r])=>`${s} \xB7 ${r.length>4?`${r.slice(0,4).join(" ")} +${r.length-4}`:r.join(" ")}`)}f(T,"listed");function re(o,a,s=new Set){return{read:o.read.length,total:a,unread:o.unread.map(r=>n(r,"scope")),vacuous:o.vacuous.map(r=>n(r,"scope")),short:T(o.over.filter(r=>r.side==="short"&&!s.has(r.question))),over:T(o.over.filter(r=>r.side==="over"))}}f(re,"ceilingSummary");export{J as answersElsewhere,re as ceilingSummary,ie as foldCeilings};
|
package/dist/fold/claims.js
CHANGED
|
@@ -1,132 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { ENVELOPE, PROTOCOL, recordKind, signedBytes, parse } from '@lapxo/topos/wire';
|
|
4
|
-
export { CAPSULE, EXTENSION, LOCK, RECEIPTS } from '@lapxo/topos/wire';
|
|
5
|
-
import { ownRoot } from "../observe/runner.js";
|
|
6
|
-
import { hostInstrumentName } from "../host/call-context.js";
|
|
7
|
-
const decoded = new Map();
|
|
8
|
-
const parsed = new Map();
|
|
9
|
-
const kinds = new Map();
|
|
10
|
-
/** Pure syntax is retained by the exact record bytes, never by a path, epoch or
|
|
11
|
-
* claimed digest. This does not retain admission, coverage or current grants. */
|
|
12
|
-
export function parsedLine(line) {
|
|
13
|
-
const held = parsed.get(line);
|
|
14
|
-
if (held !== undefined)
|
|
15
|
-
return held;
|
|
16
|
-
const got = parse(line);
|
|
17
|
-
if (got.kind === 'fact') {
|
|
18
|
-
Object.freeze(got.value.fields);
|
|
19
|
-
if (got.value.keys)
|
|
20
|
-
Object.freeze(got.value.keys);
|
|
21
|
-
Object.freeze(got.value);
|
|
22
|
-
}
|
|
23
|
-
Object.freeze(got);
|
|
24
|
-
parsed.set(line, got);
|
|
25
|
-
return got;
|
|
26
|
-
}
|
|
27
|
-
/** Field access uses the Topos wire parser; decoding is shared for this CLI process. */
|
|
28
|
-
function wireFields(line) {
|
|
29
|
-
const held = decoded.get(line);
|
|
30
|
-
if (held !== undefined)
|
|
31
|
-
return held;
|
|
32
|
-
const got = parsedLine(line);
|
|
33
|
-
const fields = got.kind === 'fact' ? got.value.fields : {};
|
|
34
|
-
decoded.set(line, fields);
|
|
35
|
-
return fields;
|
|
36
|
-
}
|
|
37
|
-
export const fieldOf = (line, name) => wireFields(line)[name] ?? '';
|
|
38
|
-
export const fieldsOf = (line) => ({ ...wireFields(line) });
|
|
39
|
-
export function selfName() { return hostInstrumentName() ?? basename(ownRoot()); }
|
|
40
|
-
export function isWire(line) { return line.startsWith(PROTOCOL); }
|
|
41
|
-
export const wireLinesOf = (text) => (text ?? '').split('\n').filter(isWire);
|
|
42
|
-
export const isConfig = (line) => { const held = kinds.get(line); if (held !== undefined)
|
|
43
|
-
return held; const k = recordKind(line), value = k.kind === 'fact' && k.value === 'config'; kinds.set(line, value); return value; };
|
|
44
|
-
export const sayingOf = (line) => !isConfig(line) ? ((p) => p.kind === 'fact' ? signedBytes(p.value.fields) : line)(parsedLine(line)) : Object.entries(fieldsOf(line)).filter(([k]) => !ENVELOPE.has(k)).sort(([a], [b]) => (a < b ? -1 : 1)).map(([k, v]) => `${k}=${v}`).join(' ');
|
|
45
|
-
/** One key per claim: scope, role and measure; what a line says, its envelope set aside, is one however often it landed. */
|
|
46
|
-
export function claimKey(line) {
|
|
47
|
-
const f = fieldsOf(line);
|
|
48
|
-
return `${f['scope'] ?? ''} ${f['role'] ?? ''} ${f['measure'] ?? ''}`;
|
|
49
|
-
}
|
|
50
|
-
function contentOf(fields, at = true) {
|
|
51
|
-
return Object.keys(fields)
|
|
52
|
-
.filter((k) => !ENVELOPE.has(k) && k !== 'value' && (at || k !== 'at'))
|
|
53
|
-
.sort()
|
|
54
|
-
.map((k) => `${k}=${fields[k]}`)
|
|
55
|
-
.join(' ');
|
|
56
|
-
}
|
|
57
|
-
function regionsOf(line) {
|
|
58
|
-
return (fieldsOf(line)['needs'] ?? '').split('|').filter(Boolean).map((need) => region(need));
|
|
59
|
-
}
|
|
60
|
-
function contracted(line, sides, receipts) {
|
|
61
|
-
const scope = fieldsOf(line)['scope'] ?? '';
|
|
62
|
-
const named = regionsOf(line);
|
|
63
|
-
// File receipts can discharge only declared file regions. No region is not an empty proof.
|
|
64
|
-
if (named.length === 0)
|
|
65
|
-
return false;
|
|
66
|
-
const mine = exclusive(named, sides.filter((other) => other !== line).map(regionsOf));
|
|
67
|
-
const touched = receipts.filter((r) => r.scope === scope).flatMap((r) => r.moved.map((coordinate) => point(coordinate)));
|
|
68
|
-
return contracts(mine, touched);
|
|
69
|
-
}
|
|
70
|
-
function retracts(withdraw, line) {
|
|
71
|
-
return Object.keys(withdraw)
|
|
72
|
-
.filter((k) => !ENVELOPE.has(k) && k !== 'value')
|
|
73
|
-
.every((k) => line[k] === withdraw[k]);
|
|
74
|
-
}
|
|
75
|
-
export function foldClaims(lines, receipts, _placed = false) {
|
|
76
|
-
const groups = new Map();
|
|
77
|
-
for (const line of lines.filter(isConfig)) {
|
|
78
|
-
const key = claimKey(line);
|
|
79
|
-
const group = groups.get(key) ?? [];
|
|
80
|
-
if (!group.includes(line))
|
|
81
|
-
group.push(line);
|
|
82
|
-
groups.set(key, group);
|
|
83
|
-
}
|
|
84
|
-
const standing = [...new Set(lines.filter(line => !isConfig(line)))];
|
|
85
|
-
const retracted = [];
|
|
86
|
-
const spent = [];
|
|
87
|
-
const vacuous = [];
|
|
88
|
-
const forks = [];
|
|
89
|
-
for (const [key, group] of groups) {
|
|
90
|
-
const parsed = group.map((line) => ({ line, fields: fieldsOf(line) }));
|
|
91
|
-
const withdraws = parsed.filter((p) => p.fields['value'] === 'withdraw');
|
|
92
|
-
const claims = parsed.filter((p) => p.fields['value'] !== 'withdraw');
|
|
93
|
-
const stands = new Set(claims.flatMap((p, i) => withdraws.some(w => retracts(w.fields, p.fields)) ? [] : [String(i)]));
|
|
94
|
-
retracted.push(...claims.filter((_, i) => !stands.has(String(i))).map((p) => p.line));
|
|
95
|
-
const kept = claims.filter((_, i) => stands.has(String(i)));
|
|
96
|
-
if (!kept.length) {
|
|
97
|
-
const lastByContent = new Map();
|
|
98
|
-
for (const w of withdraws)
|
|
99
|
-
lastByContent.set(contentOf(w.fields), w.line);
|
|
100
|
-
const shownWithdraws = [...lastByContent.values()];
|
|
101
|
-
standing.push(...shownWithdraws);
|
|
102
|
-
spent.push(...withdraws.map((w) => w.line).filter((line) => !shownWithdraws.includes(line)));
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
spent.push(...withdraws.map((w) => w.line));
|
|
106
|
-
const epochOf = (p) => Number(p.fields['epoch']) || 0;
|
|
107
|
-
const latestOf = new Map();
|
|
108
|
-
const who = (p) => `${p.fields['by'] ?? ''} ${contentOf(p.fields)}`;
|
|
109
|
-
for (const p of kept)
|
|
110
|
-
latestOf.set(who(p), Math.max(latestOf.get(who(p)) ?? 0, epochOf(p)));
|
|
111
|
-
const revised = kept.filter((p) => epochOf(p) < (latestOf.get(who(p)) ?? 0));
|
|
112
|
-
spent.push(...revised.map((p) => p.line));
|
|
113
|
-
// Epoch revisions are host history. Distinct origins remain separate inscriptions.
|
|
114
|
-
const values = kept.filter(p => !revised.includes(p));
|
|
115
|
-
const bySigner = new Map();
|
|
116
|
-
for (const p of values) {
|
|
117
|
-
const by = p.fields['by'] ?? '';
|
|
118
|
-
const identity = who(p);
|
|
119
|
-
const sayings = bySigner.get(identity) ?? new Set();
|
|
120
|
-
sayings.add(sayingOf(p.line));
|
|
121
|
-
bySigner.set(identity, sayings);
|
|
122
|
-
if (sayings.size > 1)
|
|
123
|
-
throw Error(`REFUSE·document ${key} · ${by} has two live inscriptions without withdrawal`);
|
|
124
|
-
}
|
|
125
|
-
const shown = [...new Set(values.map(p => p.line))];
|
|
126
|
-
const resting = receipts && shown.length > 1 ? shown.filter((line) => !contracted(line, shown, receipts)) : shown;
|
|
127
|
-
vacuous.push(...shown.filter((line) => !resting.includes(line)));
|
|
128
|
-
standing.push(...resting);
|
|
129
|
-
}
|
|
130
|
-
const accounted = new Set([...standing, ...retracted, ...spent, ...vacuous]);
|
|
131
|
-
return { standing, superseded: [...new Set([...spent, ...lines.filter((l) => !accounted.has(l))])], retracted, forks, vacuous };
|
|
132
|
-
}
|
|
1
|
+
var V=Object.defineProperty;var r=(e,t)=>V(e,"name",{value:t,configurable:!0});import{createHash as D}from"node:crypto";import{basename as H}from"../host/io.js";import{library0_contracts as J,library0_exclusive as X,library0_point as Y,library0_region as q}from"../vendor/runtime.js";import{library14_ENVELOPE as k,library14_PROTOCOL as G,library14_recordKind as Q,library14_signedBytes as Z,library14_parse as ee}from"../vendor/runtime.js";import{CAPSULE as xe,EXTENSION as Ee,LOCK as Se,RECEIPTS as _e}from"../vendor/library14.js";import{ownRoot as te}from"../observe/runner.js";import{hostInstrumentName as ne}from"../host/call-context.js";const z=new Map,F=new Map,R=new Map;function T(e){const t=F.get(e);if(t!==void 0)return t;const s=ee(e);return s.kind==="fact"&&(Object.freeze(s.value.fields),s.value.keys&&Object.freeze(s.value.keys),Object.freeze(s.value)),Object.freeze(s),F.set(e,s),s}r(T,"parsedLine");function L(e){const t=z.get(e);if(t!==void 0)return t;const s=T(e),o=s.kind==="fact"?s.value.fields:{};return z.set(e,o),o}r(L,"wireFields");const ge=r((e,t)=>L(e)[t]??"","fieldOf"),v=r(e=>({...L(e)}),"fieldsOf");function ye(){return ne()??H(te())}r(ye,"selfName");function se(e){return e.startsWith(G)}r(se,"isWire");const we=r(e=>(e??"").split(`
|
|
2
|
+
`).filter(se),"wireLinesOf"),M=r(e=>{const t=R.get(e);if(t!==void 0)return t;const s=Q(e),o=s.kind==="fact"&&s.value==="config";return R.set(e,o),o},"isConfig"),re=r(e=>M(e)?Object.entries(v(e)).filter(([t])=>!k.has(t)).sort(([t],[s])=>t<s?-1:1).map(([t,s])=>`${t}=${s}`).join(" "):(t=>t.kind==="fact"?Z(t.value.fields):e)(T(e)),"sayingOf");function oe(e){const t=L(e);return`${t.scope??""} ${t.role??""} ${t.measure??""}`}r(oe,"claimKey");function K(e,t=!0){return Object.keys(e).filter(s=>!k.has(s)&&s!=="value"&&(t||s!=="at")).sort().map(s=>`${s}=${e[s]}`).join(" ")}r(K,"contentOf");function U(e){return(v(e).needs??"").split("|").filter(Boolean).map(t=>q(t))}r(U,"regionsOf");function ie(e,t,s){const o=v(e).scope??"",a=U(e);if(a.length===0)return!1;const f=X(a,t.filter(i=>i!==e).map(U)),l=s.filter(i=>i.scope===o).flatMap(i=>i.moved.map(u=>Y(u)));return J(f,l)}r(ie,"contracted");function ae(e,t){return Object.keys(e).filter(s=>!k.has(s)&&s!=="value").every(s=>t[s]===e[s])}r(ae,"retracts");function ce(e,t,s=!1){const o=new Map;for(const p of e.filter(M)){const y=oe(p),m=o.get(y)??[];m.includes(p)||m.push(p),o.set(y,m)}const a=[...new Set(e.filter(p=>!M(p)))],f=[],l=[],i=[],u=[];for(const[p,y]of o){const m=y.map(n=>({line:n,fields:v(n)})),w=m.filter(n=>n.fields.value==="withdraw"),E=m.filter(n=>n.fields.value!=="withdraw"),$=new Set(E.flatMap((n,d)=>w.some(c=>ae(c.fields,n.fields))?[]:[String(d)]));f.push(...E.filter((n,d)=>!$.has(String(d))).map(n=>n.line));const b=E.filter((n,d)=>$.has(String(d)));if(!b.length){const n=new Map;for(const c of w)n.set(K(c.fields),c.line);const d=[...n.values()];a.push(...d),l.push(...w.map(c=>c.line).filter(c=>!d.includes(c)));continue}l.push(...w.map(n=>n.line));const j=r(n=>Number(n.fields.epoch)||0,"epochOf"),S=new Map,O=r(n=>`${n.fields.by??""} ${K(n.fields)}`,"who");for(const n of b)S.set(O(n),Math.max(S.get(O(n))??0,j(n)));const B=b.filter(n=>j(n)<(S.get(O(n))??0));l.push(...B.map(n=>n.line));const C=b.filter(n=>!B.includes(n)),N=new Map;for(const n of C){const d=n.fields.by??"",c=O(n),_=N.get(c)??new Set;if(_.add(re(n.line)),N.set(c,_),_.size>1)throw Error(`REFUSE\xB7document ${p} \xB7 ${d} has two live inscriptions without withdrawal`)}const g=[...new Set(C.map(n=>n.line))],P=t&&g.length>1?g.filter(n=>!ie(n,g,t)):g;i.push(...g.filter(n=>!P.includes(n))),a.push(...P)}const W=new Set([...a,...f,...l,...i]);return{standing:a,superseded:[...new Set([...l,...e.filter(p=>!W.has(p))])],retracted:f,forks:u,vacuous:i}}r(ce,"foldClaimsUncached");const h=new Map;let x=0;const A=32*1024*1024;function I(e){return{...e,standing:[...e.standing],superseded:[...e.superseded],retracted:[...e.retracted],vacuous:[...e.vacuous],forks:e.forks.map(t=>({...t,lines:[...t.lines]}))}}r(I,"copyFold");function be(e,t,s=!1){const o=JSON.stringify([Array.from(e),t===void 0?null:t.map(u=>[u.scope,Array.from(u.moved)]),s]),a=D("sha256").update(o).digest("hex"),f=h.get(a);if(f?.input===o)return I(f.result);const l=ce(e,t,s),i=Buffer.byteLength(o);if(i<=A){for(f&&(x-=Buffer.byteLength(f.input),h.delete(a));h.size>=8||x+i>A;){const u=h.keys().next().value;if(u===void 0)break;x-=Buffer.byteLength(h.get(u).input),h.delete(u)}h.set(a,{input:o,result:I(l)}),x+=i}return l}r(be,"foldClaims");export{xe as CAPSULE,Ee as EXTENSION,Se as LOCK,_e as RECEIPTS,oe as claimKey,ge as fieldOf,v as fieldsOf,be as foldClaims,M as isConfig,se as isWire,T as parsedLine,re as sayingOf,ye as selfName,we as wireLinesOf};
|