@lapxo/bound 0.2.5 → 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.
Files changed (237) hide show
  1. package/CITATION.cff +1 -1
  2. package/README.md +20 -3
  3. package/TARGET.bound +75 -42
  4. package/dist/cli/accept.js +59 -70
  5. package/dist/cli/act-result.js +3 -3
  6. package/dist/cli/args.js +1 -1
  7. package/dist/cli/host.js +1 -1
  8. package/dist/cli/native.js +1 -1
  9. package/dist/cli/pass.js +22 -21
  10. package/dist/cli/place.js +6 -6
  11. package/dist/cli/release-result.js +3 -3
  12. package/dist/cli/retained-judgment.js +1 -1
  13. package/dist/cli/standing-result.js +3 -3
  14. package/dist/cli/takes.js +10 -10
  15. package/dist/cli/verb.js +79 -77
  16. package/dist/engine/computation.js +1 -1
  17. package/dist/engine/index.js +1 -1
  18. package/dist/engine/object.js +1 -1
  19. package/dist/engine/ports.js +1 -1
  20. package/dist/fold/admission-history.js +1 -1
  21. package/dist/fold/ceilings.js +1 -1
  22. package/dist/fold/claims.js +2 -2
  23. package/dist/fold/closed.js +1 -1
  24. package/dist/fold/configures.js +1 -1
  25. package/dist/fold/digests.js +10 -10
  26. package/dist/fold/evidence.js +1 -1
  27. package/dist/fold/keys.js +3 -3
  28. package/dist/fold/laid.js +1 -1
  29. package/dist/fold/observed.js +27 -26
  30. package/dist/fold/opened.js +1 -1
  31. package/dist/fold/own.js +3 -3
  32. package/dist/fold/paid.js +1 -1
  33. package/dist/fold/place-inputs.js +1 -1
  34. package/dist/fold/places.js +1 -1
  35. package/dist/fold/reach.js +1 -1
  36. package/dist/fold/readers.js +1 -1
  37. package/dist/fold/region.js +1 -1
  38. package/dist/fold/release-policy.js +1 -1
  39. package/dist/fold/resolved.js +1 -1
  40. package/dist/fold/roles.js +1 -1
  41. package/dist/fold/shards.js +8 -8
  42. package/dist/fold/signed.js +3 -3
  43. package/dist/fold/signers.js +1 -1
  44. package/dist/fold/stranger.js +6 -6
  45. package/dist/fold/wire.js +1 -1
  46. package/dist/fold/zoom.js +1 -1
  47. package/dist/host/act-cost.js +1 -1
  48. package/dist/host/adapters/keys/ed25519.js +1 -1
  49. package/dist/host/adapters/transport/http.js +1 -1
  50. package/dist/host/admitted-place.js +1 -1
  51. package/dist/host/call-context.js +1 -1
  52. package/dist/host/capsule-process.js +1 -1
  53. package/dist/host/capsule.js +1 -1
  54. package/dist/host/cell-receipts.js +1 -1
  55. package/dist/host/command-server.js +4 -0
  56. package/dist/host/content-store.js +1 -1
  57. package/dist/host/contextual-place.js +1 -1
  58. package/dist/host/digest.js +1 -1
  59. package/dist/host/host-controls.js +1 -1
  60. package/dist/host/in-process-act.js +1 -1
  61. package/dist/host/in-process-context.js +1 -1
  62. package/dist/host/in-process-root.js +1 -1
  63. package/dist/host/in-process.js +1 -1
  64. package/dist/host/index.d.ts +1 -1
  65. package/dist/host/index.js +1 -1
  66. package/dist/host/located.js +6 -6
  67. package/dist/host/native/authority-card-view.js +5 -0
  68. package/dist/host/native/authority-card.js +1 -0
  69. package/dist/host/native/command.js +1 -1
  70. package/dist/host/native/custody.js +1 -1
  71. package/dist/host/native/generated-custodian.js +1 -1
  72. package/dist/host/native/installed-package.d.ts +1 -0
  73. package/dist/host/native/installed-package.js +5 -0
  74. package/dist/host/native/module-delivery.d.ts +1 -1
  75. package/dist/host/native/module-delivery.js +1 -1
  76. package/dist/host/native/module-inventory.js +2 -0
  77. package/dist/host/native/module-syntax.js +1 -1
  78. package/dist/host/native/native-binary.js +1 -1
  79. package/dist/host/native/probes.js +1 -0
  80. package/dist/host/native/reading-witness-admission.js +5 -0
  81. package/dist/host/native/reading.js +1 -1
  82. package/dist/host/native/route.js +1 -1
  83. package/dist/host/native-place-state.js +1 -0
  84. package/dist/host/native-receiver.js +1 -1
  85. package/dist/host/objects.js +1 -1
  86. package/dist/host/persistent-host.js +1 -0
  87. package/dist/host/physical-lines.d.ts +1 -0
  88. package/dist/host/physical-lines.js +1 -0
  89. package/dist/host/place-act-transaction.js +1 -1
  90. package/dist/host/place-clock-selection.js +1 -1
  91. package/dist/host/ports/local-act.js +1 -1
  92. package/dist/host/ports/place-act.js +1 -1
  93. package/dist/host/ports/store.js +1 -1
  94. package/dist/host/ports/transport.js +1 -1
  95. package/dist/host/profile-composition.d.ts +1 -0
  96. package/dist/host/profile-composition.js +2 -0
  97. package/dist/host/reading-closures.js +6 -6
  98. package/dist/host/reading-context.js +1 -1
  99. package/dist/host/reading-identity.js +2 -2
  100. package/dist/host/reading-preparation.js +1 -1
  101. package/dist/host/reference-authenticated.d.ts +1 -1
  102. package/dist/host/reference-authenticated.js +1 -1
  103. package/dist/host/reference-export.js +1 -1
  104. package/dist/host/reference-native-api.d.ts +1 -1
  105. package/dist/host/reference-native-api.js +1 -1
  106. package/dist/host/reference-native.js +1 -1
  107. package/dist/host/reference-standing.js +1 -1
  108. package/dist/host/reference.js +1 -1
  109. package/dist/host/refusals.js +2 -2
  110. package/dist/host/release.js +1 -1
  111. package/dist/host/root-clock-source.js +1 -1
  112. package/dist/host/selected-capsules.js +1 -1
  113. package/dist/host/selected-topos.js +1 -1
  114. package/dist/host/signing.js +2 -2
  115. package/dist/host/source-content.js +1 -1
  116. package/dist/host/standing-carrier.js +1 -1
  117. package/dist/host/standing-projection.js +1 -1
  118. package/dist/host/timing.js +1 -1
  119. package/dist/host/walk.js +1 -1
  120. package/dist/host/work-trace.js +1 -0
  121. package/dist/judge/late.js +1 -1
  122. package/dist/judge/take.js +1 -1
  123. package/dist/judge/widening.js +1 -1
  124. package/dist/land/act.js +6 -6
  125. package/dist/land/alias.js +1 -1
  126. package/dist/land/held.js +1 -1
  127. package/dist/land/ledger.js +5 -6
  128. package/dist/land/sign.js +1 -1
  129. package/dist/land/standing-pin.js +1 -1
  130. package/dist/land/vouched.js +1 -1
  131. package/dist/land/withdraw.js +1 -1
  132. package/dist/observe/files.js +1 -1
  133. package/dist/observe/identity.js +1 -1
  134. package/dist/observe/match.js +1 -1
  135. package/dist/observe/regions.js +1 -1
  136. package/dist/observe/run.js +1 -2
  137. package/dist/observe/runner.js +1 -1
  138. package/dist/public-types.d.ts +945 -40
  139. package/dist/render/capsule.js +1 -1
  140. package/dist/render/field.js +1 -1
  141. package/dist/render/open.js +1 -1
  142. package/dist/render/page.js +1 -1
  143. package/dist/render/receipt-projection.js +1 -0
  144. package/dist/render/receipts.js +1 -1
  145. package/dist/render/shape.js +1 -1
  146. package/dist/render/target.js +4 -4
  147. package/dist/render/view.js +5 -5
  148. package/dist/vendor/bundle.json +1 -1
  149. package/dist/vendor/library14.js +1 -0
  150. package/dist/vendor/runtime.js +53 -30
  151. package/dist/wasm/adapter.d.ts +1 -1
  152. package/docs/contracts/authenticated-reference.publication.json +1 -1
  153. package/docs/contracts/authority-preflight.md +17 -0
  154. package/docs/contracts/authority-preflight.publication.json +25 -0
  155. package/docs/contracts/installed-package.md +21 -0
  156. package/docs/contracts/installed-package.publication.json +25 -0
  157. package/docs/contracts/materialized-leaf-sequence.md +15 -0
  158. package/docs/contracts/materialized-leaf-sequence.publication.json +25 -0
  159. package/docs/contracts/module-inventory.md +15 -0
  160. package/docs/contracts/module-inventory.publication.json +25 -0
  161. package/docs/contracts/native-host.md +29 -1
  162. package/docs/contracts/native-host.publication.json +4 -4
  163. package/docs/contracts/native-probes.md +13 -0
  164. package/docs/contracts/native-probes.publication.json +25 -0
  165. package/docs/contracts/native-publication.inventory.json +9 -1
  166. package/docs/contracts/native-view-batch.md +17 -0
  167. package/docs/contracts/native-view-batch.publication.json +25 -0
  168. package/docs/contracts/physical-lines.md +19 -0
  169. package/docs/contracts/physical-lines.publication.json +25 -0
  170. package/docs/contracts/profile-composition.md +17 -0
  171. package/docs/contracts/profile-composition.publication.json +25 -0
  172. package/docs/contracts/profile-preparation-native-meaning.md +9 -0
  173. package/docs/contracts/publication.md +12 -0
  174. package/docs/contracts/reading-identity.md +26 -2
  175. package/docs/contracts/reading-identity.publication.json +4 -4
  176. package/docs/contracts/reading-witness-admission.md +49 -0
  177. package/docs/contracts/readme.publication.json +1 -1
  178. package/docs/contracts/reference-port.md +11 -0
  179. package/docs/contracts/reference-port.publication.json +1 -1
  180. package/docs/contracts/refusals.bound +346 -145
  181. package/docs/contracts/refusals.md +119 -54
  182. package/docs/contracts/refusals.publication.json +2 -2
  183. package/docs/reference.md +8 -0
  184. package/licenses/wasm/{fast-text-encoding.txt → NOTICE.txt} +111 -0
  185. package/package.json +69 -8
  186. package/receipts.bound +12921 -11722
  187. package/samples/authority-preflight/no.json +6 -0
  188. package/samples/authority-preflight/yes.json +30 -0
  189. package/samples/engine-alphabet/reader.js +3 -1457
  190. package/samples/engine-alphabet/receipts.bound +7 -7
  191. package/samples/engine-interval/reader.js +3 -1457
  192. package/samples/engine-interval/receipts.bound +7 -7
  193. package/samples/installed-package/consumer.mjs +29 -0
  194. package/samples/installed-package/fixture.json +48 -0
  195. package/samples/installed-package/no.json +10 -0
  196. package/samples/installed-package/yes.json +52 -0
  197. package/samples/materialized-leaf-sequence/no.json +11 -0
  198. package/samples/materialized-leaf-sequence/yes.json +10 -0
  199. package/samples/module-inventory/yes.json +28 -0
  200. package/samples/native/physical-line-reader.mjs +1 -0
  201. package/samples/native/physical-line-reader.source.mjs +13 -0
  202. package/samples/native-host/no.json +6 -1
  203. package/samples/native-host/yes.json +18 -1
  204. package/samples/native-probes/inputs/inspection.json +28 -0
  205. package/samples/native-probes/no.json +7 -0
  206. package/samples/native-probes/yes.json +28 -0
  207. package/samples/native-view-batch/no.json +14 -0
  208. package/samples/native-view-batch/yes.json +10 -0
  209. package/samples/no/engine-order/reader.js +3 -1457
  210. package/samples/no/module-inventory/no.json +10 -0
  211. package/samples/physical-lines/no.json +5 -0
  212. package/samples/physical-lines/yes.json +9 -0
  213. package/samples/profile-composition/no.json +6 -0
  214. package/samples/profile-composition/yes.json +14 -0
  215. package/samples/reading-identity/no.json +7 -1
  216. package/samples/reading-identity/yes.json +24 -1
  217. package/vectors/native/authority-preflight.vector.json +55 -0
  218. package/vectors/native/installed-package.vector.json +31 -0
  219. package/vectors/native/materialized-leaf-sequence.vector.json +31 -0
  220. package/vectors/native/module-inventory.vector.json +56 -0
  221. package/vectors/native/native-host.vector.json +214 -0
  222. package/vectors/native/native-probes.vector.json +31 -0
  223. package/vectors/native/native-view-batch.vector.json +31 -0
  224. package/vectors/native/physical-lines.vector.json +105 -0
  225. package/vectors/native/profile-composition.vector.json +53 -0
  226. package/vectors/native/reading-identity.vector.json +38 -0
  227. package/vectors/native/refusals.vector.json +36 -2
  228. package/dist/vendor/library11.js +0 -1
  229. package/dist/vendor/sources.json +0 -1
  230. package/licenses/wasm/bound.txt +0 -21
  231. package/licenses/wasm/jitl-quickjs-ffi-types.txt +0 -21
  232. package/licenses/wasm/jitl-quickjs-wasmfile-release-sync.txt +0 -47
  233. package/licenses/wasm/obligations.txt +0 -21
  234. package/licenses/wasm/quickjs-emscripten-core.txt +0 -21
  235. package/licenses/wasm/topos.txt +0 -21
  236. /package/dist/vendor/{50086958553b9376d600583f7dff354196bfeb41170fc6d1482ca7bea7c493e2.LICENSE → 28cba430228db1c04f446c93f81b09a2705d6bf3e222d35adbe5a4cee4061884.LICENSE} +0 -0
  237. /package/dist/vendor/{b3e938d28f88a1851af303a40c749e12ebd5a686daac4f0b343b5cdd2e040419.LICENSE → 7aca161279d14bc0e054dcc281cd110aeb95be2e026b42fdf527a260e58b2aae.LICENSE} +0 -0
@@ -1 +1 @@
1
- var b=Object.defineProperty;var e=(r,i)=>b(r,"name",{value:i,configurable:!0});import{library11_canonical as n,library11_parse as p,library11_objectHistory as y,library11_validateObjectContext as v}from"../vendor/runtime.js";import{objectProvider as g}from"../vendor/object-provider.js";import{authorityFor as h,rootSigner as j}from"../fold/signers.js";import{signaturesOf as x}from"../fold/digests.js";import{storeOf as d}from"../land/ledger.js";import{contextProviderServices as k}from"./selected-topos.js";import{foldClaims as w}from"../fold/claims.js";async function U(r,i,m=()=>{},C=!1){const o=y(i);if(o.kind!=="fact")throw Error(`REFUSE\xB7wire ${o.why}`);const c=h(i,j(r),x(d(r)).admitted),l=o.value.configuration.filter(t=>c.of(n(t)).kind==="admitted").map(t=>n(t)),u=w(l).standing.flatMap(t=>{const f=p(t);return f.kind==="fact"?[f.value.fields]:[]}),s=await g(o.value.objects,o.value.configuration,{admit:e(t=>c.of(n(t)).kind==="admitted","admit"),emit:m,...k(d(r))}),a=v(o.value.objects,s);if(a.kind!=="fact")throw Error(`REFUSE\xB7context ${a.why}`);return{records:a.value,context:s,configuration:u}}e(U,"admittedObjects");export{U as admittedObjects};
1
+ var b=Object.defineProperty;var e=(r,i)=>b(r,"name",{value:i,configurable:!0});import{library14_canonical as n,library14_parse as p,library14_objectHistory as y,library14_validateObjectContext as v}from"../vendor/runtime.js";import{objectProvider as g}from"../vendor/object-provider.js";import{authorityFor as h,rootSigner as j}from"../fold/signers.js";import{signaturesOf as x}from"../fold/digests.js";import{storeOf as d}from"../land/ledger.js";import{contextProviderServices as k}from"./selected-topos.js";import{foldClaims as w}from"../fold/claims.js";async function U(r,i,m=()=>{},C=!1){const o=y(i);if(o.kind!=="fact")throw Error(`REFUSE\xB7wire ${o.why}`);const c=h(i,j(r),x(d(r)).admitted),l=o.value.configuration.filter(t=>c.of(n(t)).kind==="admitted").map(t=>n(t)),u=w(l).standing.flatMap(t=>{const f=p(t);return f.kind==="fact"?[f.value.fields]:[]}),s=await g(o.value.objects,o.value.configuration,{admit:e(t=>c.of(n(t)).kind==="admitted","admit"),emit:m,...k(d(r))}),a=v(o.value.objects,s);if(a.kind!=="fact")throw Error(`REFUSE\xB7context ${a.why}`);return{records:a.value,context:s,configuration:u}}e(U,"admittedObjects");export{U as admittedObjects};
@@ -0,0 +1 @@
1
+ var A=Object.defineProperty;var u=(t,i)=>A(t,"name",{value:i,configurable:!0});import{spawn as C}from"node:child_process";import{mkdtempSync as D,rmSync as N,realpathSync as V}from"node:fs";import{tmpdir as K}from"node:os";import{join as Q,basename as W}from"node:path";import{BoundRefusal as s}from"./refusals.js";import{nativePlaceState as X}from"./native-place-state.js";import{invokeSigningPort as Y}from"../engine/ports.js";import{verifyHostInstrument as T}from"./native-receiver.js";function Z(t){return Object.fromEntries(Object.entries(t).filter(i=>i[1]!==void 0&&!/^(NODE_|UV_)/.test(i[0])))}u(Z,"nativeHostEnvironment");const b=new Set;async function ce(t){T(t.instrument,t.expectedInstrument);const i=V(t.place),o={...t.limits};X(i);const a=new Map(t.signers??[]);if(t.signer){if(a.has(t.signer.keyId))throw new s("host/context","REFUSE\xB7host/context");a.set(t.signer.keyId,{name:t.signer.name,sign:t.signer.sign})}for(const[e,r]of a)if(typeof e!="string"||!e||typeof r.name!="string"||!r.name||typeof r.sign!="function")throw new s("host/context","REFUSE\xB7host/context");for(const e of Object.values(o))if(!Number.isSafeInteger(e)||e<1)throw new s("host/budget","REFUSE\xB7host/budget");if(o.timeoutMs>2147483647||o.heapMiB<16||o.heapMiB>4096)throw new s("host/budget","REFUSE\xB7host/budget");if(b.has(i))throw new s("host/busy","REFUSE\xB7host/busy");b.add(i);const R=Object.freeze(Z(t.environment)),v=Object.freeze(["--max-old-space-size="+o.heapMiB]),g=D(Q(t.scratchParent??K(),"bound-native-host-"));let n;try{n=C(process.execPath,[...v,t.instrument.runtime.entry],{cwd:i,env:R,stdio:["ignore","pipe","pipe","ipc"],serialization:"advanced",shell:!1})}catch(e){throw b.delete(i),N(g,{recursive:!0,force:!0}),e}let m=!1,z=0,y=0,w=0,k=Promise.resolve(),d,U,h;const L=new Promise((e,r)=>{U=e,h=r});let x;const F=new Promise(e=>{x=e}),B=u(()=>{m=!0,b.delete(i),N(g,{recursive:!0,force:!0}),d?.abort.abort(),d?.dispose(),d?.reject(new s("host/closed","REFUSE\xB7host/closed")),d=void 0,x()},"cleanup");n.once("error",e=>{h(e),B()}),n.once("exit",()=>{h(new s("host/closed","REFUSE\xB7host/closed")),B()});let I=0;const M=u(e=>{I+=e.length,I>o.responseBytes&&n.kill("SIGTERM")},"drain");n.stdout.on("data",M),n.stderr.on("data",M),n.on("message",async e=>{if(e?.kind==="ready"){U();return}const r=d;if(!(!r||e?.id!==r.id)){if(e.kind==="sign"){try{if(e.lot?.keyId!==r.signer)throw new s("host/signer-mismatch","REFUSE\xB7host/signer-mismatch");const c=r.signer===void 0?void 0:a.get(r.signer);if(!c)throw new s("host/unbound-signer","REFUSE\xB7host/unbound-signer");const f=await Y(e.lot,c.sign,{timeoutMs:o.timeoutMs,maxBytes:o.responseBytes},r.abort.signal);n.connected&&n.send({kind:"signed",id:r.id,records:f})}catch(c){n.connected&&n.send({kind:"signed",id:r.id,error:{code:c instanceof s?c.code:"host-port/failed"}})}return}if(e.kind==="result"){if(r.dispose(),d=void 0,typeof e.stdout!="string"||typeof e.stderr!="string"||!Number.isSafeInteger(e.status)||Buffer.byteLength(e.stdout)+Buffer.byteLength(e.stderr)>o.responseBytes){r.reject(new s("host/budget","REFUSE\xB7host/budget"));return}r.resolve({status:e.status,stdout:e.stdout,stderr:e.stderr})}}});const G=setTimeout(()=>{h(new s("host/timeout","REFUSE\xB7host/timeout")),n.kill("SIGTERM")},o.timeoutMs);n.send({kind:"configure",place:i,scratch:g,limits:o,instrumentName:W(t.instrument.runtime.root),instrumentRoot:t.instrument.runtime.root});try{await L,T(t.instrument,t.expectedInstrument)}catch(e){throw n.kill("SIGTERM"),await F,e}finally{clearTimeout(G)}return{pid:n.pid,environment:R,flags:v,request(e,r){const c=JSON.stringify(e),f=Buffer.byteLength(c);if(y>=o.queuedRequests||w+f>o.requestBytes)return Promise.reject(new s("host/budget","REFUSE\xB7host/budget"));const q=JSON.parse(c);y++,w+=f;const H=u(()=>new Promise((J,E)=>{if(m||!n.connected){E(new s("host/closed","REFUSE\xB7host/closed"));return}if(r?.aborted){E(new s("host/cancelled","REFUSE\xB7host/cancelled"));return}const p=++z,j=new AbortController,S=u(()=>{j.abort(),n.connected&&n.send({kind:"cancel",id:p})},"cancel"),_=setTimeout(S,o.timeoutMs);r?.addEventListener("abort",S,{once:!0});const l=q.signer,O=l===void 0?void 0:a.get(l);d={id:p,signer:l,resolve:J,reject:E,abort:j,dispose:u(()=>{clearTimeout(_),r?.removeEventListener("abort",S)},"dispose")},n.send({kind:"request",id:p,command:q,...l!==void 0||a.size?{signer:{keyId:l??"",name:O?.name??"",bound:!!O}}:{}})}),"run"),P=k.then(H).finally(()=>{y--,w-=f});return k=P.catch(()=>{}),P},async close(){m||(m=!0,d?.abort.abort(),n.connected&&n.send({kind:"close"})),await F}}}u(ce,"startNativeHost");export{Z as nativeHostEnvironment,ce as startNativeHost};
@@ -0,0 +1 @@
1
+ export {public5_PhysicalLinesPlaceInput as PhysicalLinesPlaceInput,public5_PhysicalLinesPolicy as PhysicalLinesPolicy,public5_PhysicalLinesReading as PhysicalLinesReading,public5_PhysicalLinesRegion as PhysicalLinesRegion,public5_PhysicalLinesWitnessAuthority as PhysicalLinesWitnessAuthority,public5_ReadingProducerPolicy as ReadingProducerPolicy,public5_authenticatePhysicalLinesWitness as authenticatePhysicalLinesWitness,public5_judgePhysicalLines as judgePhysicalLines,public5_physicalLinesRegions as physicalLinesRegions,public5_readPlacePhysicalLines as readPlacePhysicalLines} from "../public-types.js";
@@ -0,0 +1 @@
1
+ var $=Object.defineProperty;var w=(e,t)=>$(e,"name",{value:t,configurable:!0});import{BoundRefusal as k}from"./refusals.js";import{sha256 as h,isSha256 as G}from"./hash.js";import{lstatSync as j,opendirSync as K,readSync as T,realpathSync as A,openSync as X,closeSync as Q,fstatSync as V,constants as M}from"node:fs";import{join as W,relative as Z,resolve as ee,sep as R}from"node:path";import{library5_PHYSICAL_LINES_PROFILE as D,library5_PHYSICAL_LINES_MODEL as C,library5_readPhysicalLines as J,library5_encodeReadingWitness as te,library5_decodeReadingWitness as ne,library5_readingWitnessStatementBytes as re}from"../vendor/runtime.js";import{library14_canonical as se,library14_byBytes as P,library14_steps as Y}from"../vendor/runtime.js";import{fieldOf as c,fieldsOf as ie}from"../fold/claims.js";import{foldCeilings as oe}from"../fold/ceilings.js";import{widenedWithoutWitness as ae}from"../judge/widening.js";const x=new WeakSet;function U(e){if(e&&typeof e=="object"){Object.freeze(e);for(const t of Object.values(e))U(t)}return e}w(U,"freeze");const a=w(e=>{const t=e.split("/")[0],o=["inventory-policy","inventory-boundary","context","run","outside-inventory","inventory-size"].includes(t)?"context":["region-declaration","region-selectors"].includes(t)?"selection":["inventory-moved","per-file-reading","witness-binding"].includes(t)?"integrity":t==="actual-reading-required"||t.startsWith("witness-")?"witness":"failed";throw new k("physical-lines/"+o,"REFUSE\xB7physical-lines/"+e)},"fail"),ce=w(e=>typeof e=="string"&&e.length>0&&!e.includes("\\")&&!/[\u0000-\u001f\u007f]/.test(e)&&e.split("/").every(t=>t!==""&&t!=="."&&t!==".."&&!t.includes("*")),"named");function Se(e){const t=e.filter(o=>c(o,"scope").startsWith("region/")&&c(o,"measure")==="coordinates"&&c(o,"value")!=="withdraw");return e.filter(o=>c(o,"role")==="reads"&&c(o,"form")==="interval"&&["lines","file-lines"].includes(c(o,"measure"))).map(o=>{const r=c(o,"scope"),u=Y(r),i=u.length>1&&u.at(-1)==="lines"?Y(u.slice(0,-1)):r,l=t.filter(s=>c(s,"scope")==="region/"+i);if(l.length!==1)return a("region-declaration/"+r);const B=c(l[0],"value").split("|").filter(Boolean);return B.length?{scope:r,selectors:B}:a("region-selectors/"+r)})}w(Se,"physicalLinesRegions");function Be(e){try{return le(e)}catch(t){throw t instanceof k?t:new k("physical-lines/failed","REFUSE\xB7physical-lines/failed "+(t instanceof Error?t.message:"native inventory unavailable"))}}w(Be,"readPlacePhysicalLines");function le(e){if(!e||!e.policy||!Number.isSafeInteger(e.policy.entryBudget)||e.policy.entryBudget<0||!/^\d+$/.test(e.policy.byteBudget)||!/^\d+$/.test(e.policy.rowBudget))return a("inventory-policy");if(!Array.isArray(e.inventory)||!e.inventory.length||!e.inventory.every(ce)||new Set(e.inventory).size!==e.inventory.length)return a("inventory-boundary");for(const n of[e.context,e.reader,e.implementation])if(!G(n))return a("context");if(typeof e.run!="string"||!e.run||/\s/.test(e.run))return a("run");const t=A(e.root),o=[],r=new Set;let u=0,i=0n;const l=[];function B(n){if(r.has(n))return;if(r.add(n),++u>e.policy.entryBudget){l.push({name:n,cause:"entry-budget"});return}const g=ee(t,n),N=Z(t,g);if(N===".."||N.startsWith(".."+R))return a("outside-inventory");let d;try{d=j(g)}catch{l.push({name:n,cause:"inventory-absent"});return}if(d.isSymbolicLink()){l.push({name:n,cause:"inventory-link"});return}if(d.isDirectory()){const O=K(g),S=[];try{let b;for(;(b=O.readSync())!==null;){if(S.length>=e.policy.entryBudget-u){l.push({name:W(n,b.name).split(R).join("/"),cause:"entry-budget"});return}S.push(b.name)}}finally{O.closeSync()}S.sort(P);for(const b of S){if(u>=e.policy.entryBudget){l.push({name:W(n,b).split(R).join("/"),cause:"entry-budget"});break}B(W(n,b).split(R).join("/"))}const m=j(g);if(m.isSymbolicLink()||d.dev!==m.dev||d.ino!==m.ino||d.mtimeMs!==m.mtimeMs)return a("inventory-moved")}else if(d.isFile()){if(!Number.isSafeInteger(d.size)||d.size<0)return a("inventory-size");if(i+BigInt(d.size)>BigInt(e.policy.byteBudget)){l.push({name:n,cause:"byte-budget"});return}if(A(g)!==g)return a("inventory-link");const O=X(g,M.O_RDONLY|M.O_NOFOLLOW);let S,m;try{const b=Buffer.alloc(d.size+1);let _=0,F=0;for(;_<b.length&&(F=T(O,b,_,b.length-_,null))>0;)_+=F;S=b.subarray(0,_),m=V(O)}finally{Q(O)}if(m.isSymbolicLink()||d.dev!==m.dev||d.ino!==m.ino||d.size!==m.size||d.mtimeMs!==m.mtimeMs||S.length!==m.size||(i+=BigInt(S.length),i>BigInt(e.policy.byteBudget)))return a("inventory-moved");o.push({name:n,digest:h(S),bytes:S})}else l.push({name:n,cause:"inventory-special-file"})}w(B,"visit");for(const n of[...e.inventory].sort(P))B(n);if(l.length)return{status:"unmeasured",cause:"inventory-incomplete",unavailable:l};o.sort((n,g)=>P(n.name,g.name));const s=h(JSON.stringify(o.map(({name:n,digest:g})=>({name:n,digest:g})))),f=J({profile:D,snapshot:s,files:o,regions:e.regions,policy:{byteBudget:e.policy.byteBudget,rowBudget:e.policy.rowBudget}},h);if(f.status!=="read")return f;const p=h(JSON.stringify(f.regions.map(({scope:n,selectors:g,selections:N,members:d})=>({scope:n,selectors:g,selections:N,members:d})))),L=h(JSON.stringify({inventory:[...e.inventory].sort(P),policy:e.policy,textDomain:f.textDomain})),E=J({profile:D,snapshot:s,files:o,regions:o.map(n=>({scope:n.name,selectors:[n.name]})),policy:{byteBudget:e.policy.byteBudget,rowBudget:e.policy.rowBudget}},h);if(E.status!=="read")return E;const y=h(JSON.stringify({reading:f,perFile:E})),v={contract:C.contract,model:h(JSON.stringify(C)),params:L,inputs:s,selection:p,unit:"physical-lines/utf8-lf@1",scale:h("finite-nonnegative-atomic-valuation@1"),resolution:h("whole-physical-lines@1"),reader:e.reader,implementation:e.implementation,context:e.context,run:e.run,result:y},I=h(JSON.stringify(v)),H=new Set(f.regions.flatMap(n=>n.members)),q=f.inputFiles.filter(n=>!H.has(n.name)).map(n=>n.name),z=U({status:"read",identity:I,bindings:{reading:I,...v},reading:f,perFile:E,stray:q});return x.add(z),z}w(le,"readPhysicalLinesInPlace");function de(e,t,o){if(!x.has(e))return a("actual-reading-required");let r;try{r=ne(t)}catch(i){throw new k("physical-lines/witness","REFUSE\xB7physical-lines/witness "+(i instanceof Error?i.message:"invalid witness record"))}for(const[i,l]of Object.entries(e.bindings))if(r[i]!==l)return a("witness-binding/"+i);const u=o.producers.find(i=>i.authentication!==r.authentication?!1:i.authentication==="key-covered"&&r.authentication==="key-covered"?i.key===r.key&&i.coverage===r.coverage:i.authentication==="ci-run-unkeyed"&&r.authentication==="ci-run-unkeyed"?i.repository===r.repository&&i.commit===r.commit&&i.workflow===r.workflow&&i.run===r.run&&i.attempt===r.attempt:!1);return u?o.verify({witness:r,statementBytes:re(r),producer:u})!==!0?a("witness-authentication"):"attest:"+h(te(r)):a("witness-producer-not-admitted")}w(de,"authenticatePhysicalLinesWitness");function Le(e){if(!x.has(e.reading))return a("actual-reading-required");const t=w(s=>c(s,"form")==="interval"&&c(s,"role")==="reads"&&["lines","file-lines"].includes(c(s,"measure")),"isLineCeiling");let o;if(e.witness!==void 0){if(!e.authority)return a("witness-authority-absent");o=de(e.reading,e.witness,e.authority)}const r=e.proposed.filter(s=>{const f=e.standing.find(L=>c(L,"scope")===c(s,"scope"));if(!f||!t(s))return!1;const p=se({...ie(s),at:"none"});return ae([p],[f],t,"attest").length>0&&(!o||c(s,"at")!==o)}),u=new Map(e.standing.filter(t).map(s=>[c(s,"scope"),s]));for(const s of e.proposed.filter(t))r.includes(s)||u.set(c(s,"scope"),s);const i=[],l=[],B=[];for(const s of u.values()){const f=c(s,"scope"),p=e.reading.reading.regions.find(y=>y.scope===f);if(!p||p.status!=="measured"||p.selections.some(y=>y.status==="unmeasured")){B.push({scope:f,cause:"selector-no-match",selectors:p?.selections.filter(y=>y.status==="unmeasured").map(y=>y.selector)??[]});continue}const L=c(s,"measure"),E=L==="file-lines"?p.members.map(y=>{const v=e.reading.perFile.regions.find(I=>I.scope===y);return!v||v.status!=="measured"?a("per-file-reading"):v.value}):[p.value];for(const[y,v]of E.entries()){if(l.push({scope:f,...L==="file-lines"?{file:p.members[y]}:{},value:v.numerator}),v.denominator!=="1"||BigInt(v.numerator)>BigInt(Number.MAX_SAFE_INTEGER))return a("threshold-number-resolution");i.push(oe({standing:e.standing,ceilings:[s],observed:[],own:{[L]:Number(v.numerator)},epoch:0}))}}return{status:r.length||i.some(s=>s.over.length)?"BLOCK":!u.size||B.length||e.reading.stray.length?"UNMEASURED":"READY",rejected:r,unmeasured:B,stray:e.reading.stray,observations:l,thresholds:i,reading:e.reading.identity}}w(Le,"judgePhysicalLines");export{de as authenticatePhysicalLinesWitness,Le as judgePhysicalLines,Se as physicalLinesRegions,Be as readPlacePhysicalLines};
@@ -1,4 +1,4 @@
1
- var R=Object.defineProperty;var r=(e,i)=>R(e,"name",{value:i,configurable:!0});import{library3_readPlaceActContext as E,library3_verifyPlaceActContext as J,library3_placeActReceiptsOf as S}from"../vendor/runtime.js";import{requireEffects as U}from"./read-only.js";import{BoundRefusal as I}from"./refusals.js";import{ActCommitUnknown as _}from"./commit-result.js";import{assertHostNotCancelled as h,receiverClock as N,placeRegionOf as z}from"./host-controls.js";import{ActCommitUnknown as M}from"./commit-result.js";const n=r(e=>{throw new I("host/act","REFUSE\xB7place act "+e)},"fail"),j=r(e=>JSON.stringify([e.namespace,e.snapshot,e.epoch,e.prefix,e.head,e.policies]),"rootBytes");async function G(e,i,a,o,p,f){U("place act commitment"),h(f),(!o||!Number.isSafeInteger(o.acts)||o.acts<1||!Number.isSafeInteger(o.bytes)||o.bytes<1)&&n("missing storage budget");const m=E(e,a.contract.budget),l=a.contract.digest(e),k=m.places.map(y=>z(y.place));return p.exclusive(k,async()=>{h(f);const y=p.result(l,a,o);if(y)return y.context!==e&&n("replay bytes differ"),typeof i!="function"&&S(e,i,a.historical(e)),{...y,identity:l,kind:"once"};const P=J(e,a.contract),b=m.places.map(t=>t.records),v=r(t=>{const s=p.inventory(o);s.bytes+t>o.bytes&&n("publication byte budget"),s.names.length>=o.acts&&n("publication act budget")},"capacity"),C=r(t=>Object.values(t).reduce((s,c)=>s+new TextEncoder().encode(c).length,0),"sizeOf");v(C({"context.json":e,"originals.json":JSON.stringify(b)+`
1
+ var R=Object.defineProperty;var r=(e,i)=>R(e,"name",{value:i,configurable:!0});import{library6_readPlaceActContext as E,library6_verifyPlaceActContext as J,library6_placeActReceiptsOf as S}from"../vendor/runtime.js";import{requireEffects as U}from"./read-only.js";import{BoundRefusal as I}from"./refusals.js";import{ActCommitUnknown as _}from"./commit-result.js";import{assertHostNotCancelled as h,receiverClock as N,placeRegionOf as z}from"./host-controls.js";import{ActCommitUnknown as M}from"./commit-result.js";const n=r(e=>{throw new I("host/act","REFUSE\xB7place act "+e)},"fail"),j=r(e=>JSON.stringify([e.namespace,e.snapshot,e.epoch,e.prefix,e.head,e.policies]),"rootBytes");async function G(e,i,a,o,p,f){U("place act commitment"),h(f),(!o||!Number.isSafeInteger(o.acts)||o.acts<1||!Number.isSafeInteger(o.bytes)||o.bytes<1)&&n("missing storage budget");const m=E(e,a.contract.budget),l=a.contract.digest(e),k=m.places.map(y=>z(y.place));return p.exclusive(k,async()=>{h(f);const y=p.result(l,a,o);if(y)return y.context!==e&&n("replay bytes differ"),typeof i!="function"&&S(e,i,a.historical(e)),{...y,identity:l,kind:"once"};const P=J(e,a.contract),b=m.places.map(t=>t.records),v=r(t=>{const s=p.inventory(o);s.bytes+t>o.bytes&&n("publication byte budget"),s.names.length>=o.acts&&n("publication act budget")},"capacity"),C=r(t=>Object.values(t).reduce((s,c)=>s+new TextEncoder().encode(c).length,0),"sizeOf");v(C({"context.json":e,"originals.json":JSON.stringify(b)+`
2
2
  `}));const w=r(()=>{const t=a.current();j(t.root)!==j(P.dependencies)&&n("authority changed before publication"),new Set(t.heads.map(c=>c.place)).size!==t.heads.length&&n("ambiguous receiver heads");const s=p.heads(a,o);for(const c of m.places){const g=s.find(x=>x.place===c.place),d=t.heads.find(x=>x.place===c.place);(!g||!d||g.identity!==d.identity||g.epoch!==d.epoch)&&n("receiver snapshot is not committed head "+c.place),d.identity!==c.previous&&n("receiver head moved "+c.place);const O=N(d.epoch,n)+1;(!Number.isSafeInteger(O)||N(c.epoch,n)!==O)&&n("receiver epoch not next "+c.place)}},"assertCurrent");w(),h(f);const u=structuredClone(typeof i=="function"?await i():i);h(f),S(e,u,a.contract);const A={"context.json":e,"receipts.json":JSON.stringify(u)+`
3
3
  `,"originals.json":JSON.stringify(b)+`
4
4
  `};v(C(A)),w(),h(f);try{p.publish(l,A)}catch(t){throw new _(l,t)}return{context:e,receipts:u,originals:b,identity:l,kind:"landed"}})}r(G,"transactPlaceAct");export{M as PlaceActCommitUnknown,G as transactPlaceAct};
@@ -1,4 +1,4 @@
1
- var U=Object.defineProperty;var l=(t,s)=>U(t,"name",{value:s,configurable:!0});import{createHash as V}from"node:crypto";import{library3_PLACE_ACT_CONTEXT as _}from"../vendor/runtime.js";import{library11_canonical as $,library11_signedBytes as F,library11_wireAt as q}from"../vendor/runtime.js";import{foldClaims as J,isConfig as S,fieldOf as H,parsedLine as D}from"../fold/claims.js";import{signatureEraOf as Q}from"./signature-era.js";import{authorityFor as I}from"../fold/signers.js";import{verifyBytes as Y}from"./adapters/keys/ed25519.js";import{verifiesOwnerLine as L}from"../land/sign.js";import{placeActHeads as P}from"./ports/place-act.js";const i=l(t=>{throw Error("REFUSE\xB7clock selection "+t)},"fail"),y=l(t=>"sha256:"+V("sha256").update(t).digest("hex"),"digest"),m=l(t=>typeof t=="string"&&t.length>0,"text"),h=l(t=>((typeof t!="string"||!/^(0|[1-9][0-9]*)$/.test(t)||!Number.isSafeInteger(Number(t)))&&i("unknown clock"),Number(t)),"clock"),G=new WeakSet,c=l(t=>{const s=D(t);return s.kind!=="fact"?i("noncanonical history"):(G.has(s.value)||($(s.value.fields,s.value.version)!==t&&i("noncanonical history"),G.add(s.value)),s.value.fields)},"f");function Z(t){const s=t.resources;(!s||Object.keys(s).sort().join(",")!=="bytes,lines,places"||Object.values(s).some(e=>!Number.isSafeInteger(e)||e<1))&&i("missing input resources");const f=t.inherited;(!f?.clock||Object.keys(f.clock).sort().join(",")!=="bytes,placements,policies,proofs,records,signers"||!f.storage||Object.keys(f.storage).sort().join(",")!=="acts,bytes"||[...Object.values(f.clock),...Object.values(f.storage)].some(e=>!Number.isSafeInteger(e)||e<1))&&i("missing inherited resource authority"),t.history.length+t.legacyOriginals.length>s.lines&&i("input line budget");let K=0;for(const e of[...t.history,...t.legacyOriginals])(typeof e!="string"||e.length>s.bytes||(K+=Buffer.byteLength(e))>s.bytes)&&i("input byte budget");const O=new Map;for(const e of t.history){const r=h(c(e).epoch??i("history clock absent"));let a=O.get(r);if(!a){const p=t.history.filter(n=>!S(n)||h(c(n).epoch??i("history clock absent"))<=r);a=I(p,t.anchor,Q(J(p.filter(n=>H(n,"scope").startsWith("wire/"))).standing).admitted),O.set(r,a)}a.of(e).kind!=="admitted"&&i("history not authenticated at admission")}const u=J(t.history.filter(S)).standing.filter(e=>H(e,"value")!=="withdraw"),b=u.filter(e=>{const r=c(e);return r.scope===t.profileSelector&&r.measure==="id"});(b.length!==1||c(b[0]).value!==_||c(b[0]).role!=="writes"||c(b[0]).form!=="alphabet"||c(b[0]).by!==t.anchor.id)&&i("missing/ambiguous clock profile id");const j=u.filter(e=>{const r=c(e);return r.scope===t.selector&&r.measure==="text"});j.length!==1&&i("missing/ambiguous Root selector");const N=j[0],d=c(N);(d.by!==t.anchor.id||d.role!=="writes"||d.form!=="alphabet"||d.value!=="lock"||!L(N,t.anchor.publicKey,t.algorithms))&&i("selector is not Root signed"),(!d.about||d.about.length>s.bytes)&&i("missing selector body");let o;try{o=JSON.parse(d.about)}catch{return i("selector JSON")}(!o||Object.keys(o).sort().join(",")!=="budget,digestAlgorithm,initial,namespace,profile,receiptScope,receiptSigner,regionFamily,storageBudget"||o.profile!==_||o.digestAlgorithm!=="sha256"||!m(o.namespace)||!m(o.regionFamily)||!m(o.receiptSigner)||!m(o.receiptScope)||!Array.isArray(o.initial)||!o.initial.length||o.initial.length>s.places)&&i("unsupported selector shape"),JSON.stringify(o)!==d.about&&i("noncanonical selector JSON"),(!o.budget||Object.keys(o.budget).sort().join(",")!=="bytes,placements,policies,proofs,records,signers"||Object.values(o.budget).some(e=>!Number.isSafeInteger(e)||e<1)||!o.storageBudget||Object.keys(o.storageBudget).sort().join(",")!=="acts,bytes"||Object.values(o.storageBudget).some(e=>!Number.isSafeInteger(e)||e<1))&&i("missing selected resources");for(const e of["bytes","records","placements","policies","proofs","signers"])o.budget[e]>f.clock[e]&&i("clock resource exceeds inherited "+e);for(const e of["acts","bytes"])o.storageBudget[e]>f.storage[e]&&i("storage resource exceeds inherited "+e);(o.budget.bytes>s.bytes||o.storageBudget.bytes>s.bytes||o.budget.records>s.lines||o.budget.placements>s.places)&&i("selected resources exceed input authority");const A=q(u.map(c),Number.MAX_SAFE_INTEGER);(!A||!A.digests.has(o.digestAlgorithm))&&i("digest algorithm not declared");const X=I(t.history,t.anchor,t.algorithms);(!t.history.includes(t.authorityCheckpoint)||!S(t.authorityCheckpoint))&&i("missing authenticated Root authority checkpoint");const M=h(c(t.authorityCheckpoint).epoch??i("Root authority clock absent"));O.get(M)?.of(t.authorityCheckpoint).kind!=="admitted"&&i("Root checkpoint not admitted at original epoch");const w=h(c(t.authorityCheckpoint).epoch??i("Root authority clock absent"));t.history.filter(S).some(e=>h(c(e).epoch??i("history clock absent"))>w)&&i("authority checkpoint precedes Root configuration");const C=y(t.history.join(`
1
+ var U=Object.defineProperty;var l=(t,s)=>U(t,"name",{value:s,configurable:!0});import{createHash as V}from"node:crypto";import{library6_PLACE_ACT_CONTEXT as _}from"../vendor/runtime.js";import{library14_canonical as $,library14_signedBytes as F,library14_wireAt as q}from"../vendor/runtime.js";import{foldClaims as J,isConfig as S,fieldOf as H,parsedLine as D}from"../fold/claims.js";import{signatureEraOf as Q}from"./signature-era.js";import{authorityFor as I}from"../fold/signers.js";import{verifyBytes as Y}from"./adapters/keys/ed25519.js";import{verifiesOwnerLine as L}from"../land/sign.js";import{placeActHeads as P}from"./ports/place-act.js";const i=l(t=>{throw Error("REFUSE\xB7clock selection "+t)},"fail"),y=l(t=>"sha256:"+V("sha256").update(t).digest("hex"),"digest"),m=l(t=>typeof t=="string"&&t.length>0,"text"),h=l(t=>((typeof t!="string"||!/^(0|[1-9][0-9]*)$/.test(t)||!Number.isSafeInteger(Number(t)))&&i("unknown clock"),Number(t)),"clock"),G=new WeakSet,c=l(t=>{const s=D(t);return s.kind!=="fact"?i("noncanonical history"):(G.has(s.value)||($(s.value.fields,s.value.version)!==t&&i("noncanonical history"),G.add(s.value)),s.value.fields)},"f");function Z(t){const s=t.resources;(!s||Object.keys(s).sort().join(",")!=="bytes,lines,places"||Object.values(s).some(e=>!Number.isSafeInteger(e)||e<1))&&i("missing input resources");const f=t.inherited;(!f?.clock||Object.keys(f.clock).sort().join(",")!=="bytes,placements,policies,proofs,records,signers"||!f.storage||Object.keys(f.storage).sort().join(",")!=="acts,bytes"||[...Object.values(f.clock),...Object.values(f.storage)].some(e=>!Number.isSafeInteger(e)||e<1))&&i("missing inherited resource authority"),t.history.length+t.legacyOriginals.length>s.lines&&i("input line budget");let K=0;for(const e of[...t.history,...t.legacyOriginals])(typeof e!="string"||e.length>s.bytes||(K+=Buffer.byteLength(e))>s.bytes)&&i("input byte budget");const O=new Map;for(const e of t.history){const r=h(c(e).epoch??i("history clock absent"));let a=O.get(r);if(!a){const p=t.history.filter(n=>!S(n)||h(c(n).epoch??i("history clock absent"))<=r);a=I(p,t.anchor,Q(J(p.filter(n=>H(n,"scope").startsWith("wire/"))).standing).admitted),O.set(r,a)}a.of(e).kind!=="admitted"&&i("history not authenticated at admission")}const u=J(t.history.filter(S)).standing.filter(e=>H(e,"value")!=="withdraw"),b=u.filter(e=>{const r=c(e);return r.scope===t.profileSelector&&r.measure==="id"});(b.length!==1||c(b[0]).value!==_||c(b[0]).role!=="writes"||c(b[0]).form!=="alphabet"||c(b[0]).by!==t.anchor.id)&&i("missing/ambiguous clock profile id");const j=u.filter(e=>{const r=c(e);return r.scope===t.selector&&r.measure==="text"});j.length!==1&&i("missing/ambiguous Root selector");const N=j[0],d=c(N);(d.by!==t.anchor.id||d.role!=="writes"||d.form!=="alphabet"||d.value!=="lock"||!L(N,t.anchor.publicKey,t.algorithms))&&i("selector is not Root signed"),(!d.about||d.about.length>s.bytes)&&i("missing selector body");let o;try{o=JSON.parse(d.about)}catch{return i("selector JSON")}(!o||Object.keys(o).sort().join(",")!=="budget,digestAlgorithm,initial,namespace,profile,receiptScope,receiptSigner,regionFamily,storageBudget"||o.profile!==_||o.digestAlgorithm!=="sha256"||!m(o.namespace)||!m(o.regionFamily)||!m(o.receiptSigner)||!m(o.receiptScope)||!Array.isArray(o.initial)||!o.initial.length||o.initial.length>s.places)&&i("unsupported selector shape"),JSON.stringify(o)!==d.about&&i("noncanonical selector JSON"),(!o.budget||Object.keys(o.budget).sort().join(",")!=="bytes,placements,policies,proofs,records,signers"||Object.values(o.budget).some(e=>!Number.isSafeInteger(e)||e<1)||!o.storageBudget||Object.keys(o.storageBudget).sort().join(",")!=="acts,bytes"||Object.values(o.storageBudget).some(e=>!Number.isSafeInteger(e)||e<1))&&i("missing selected resources");for(const e of["bytes","records","placements","policies","proofs","signers"])o.budget[e]>f.clock[e]&&i("clock resource exceeds inherited "+e);for(const e of["acts","bytes"])o.storageBudget[e]>f.storage[e]&&i("storage resource exceeds inherited "+e);(o.budget.bytes>s.bytes||o.storageBudget.bytes>s.bytes||o.budget.records>s.lines||o.budget.placements>s.places)&&i("selected resources exceed input authority");const A=q(u.map(c),Number.MAX_SAFE_INTEGER);(!A||!A.digests.has(o.digestAlgorithm))&&i("digest algorithm not declared");const X=I(t.history,t.anchor,t.algorithms);(!t.history.includes(t.authorityCheckpoint)||!S(t.authorityCheckpoint))&&i("missing authenticated Root authority checkpoint");const M=h(c(t.authorityCheckpoint).epoch??i("Root authority clock absent"));O.get(M)?.of(t.authorityCheckpoint).kind!=="admitted"&&i("Root checkpoint not admitted at original epoch");const w=h(c(t.authorityCheckpoint).epoch??i("Root authority clock absent"));t.history.filter(S).some(e=>h(c(e).epoch??i("history clock absent"))>w)&&i("authority checkpoint precedes Root configuration");const C=y(t.history.join(`
2
2
  `)+`
3
3
  `),E=y(u.join(`
4
4
  `)+`
@@ -1,4 +1,4 @@
1
- var U=Object.defineProperty;var i=(t,e)=>U(t,"name",{value:e,configurable:!0});import{hashText as F}from"../hash.js";import{ActCommitUnknown as I}from"../commit-result.js";import{assertHostNotCancelled as u}from"../host-controls.js";import{existsSync as E,readFileSync as m,readdirSync as y}from"node:fs";import{join as d}from"node:path";import{createHash as O}from"node:crypto";import{requireEffects as j}from"../read-only.js";import{underTheRegions as A}from"../../land/act.js";import{publishBundle as C,nativePublicationStorage as L}from"./publication.js";import{library11_actIdentity as k,library11_parse as g,library11_canonical as z}from"../../vendor/runtime.js";import{fullDigest as W}from"../digest.js";const v=i((t,e)=>{if(!e||e.includes("\0"))throw Error("REFUSE\xB7act missing identity");return d(t,"ledger","acts","committed-"+encodeURIComponent(e))},"atOf"),w=i(t=>{try{const e=y(t).filter(r=>r.startsWith("place-")&&r.endsWith(".bound")).map(r=>({place:decodeURIComponent(r.slice(6,-6)),records:m(d(t,r),"utf8")}));return{records:m(d(t,"records.bound"),"utf8"),receipt:m(d(t,"receipt.bound"),"utf8"),...e.length?{placements:e}:{}}}catch(e){throw Error(`REFUSE\xB7act committed result unreadable \xB7 ${e.code??"read failed"}`)}},"read"),x=i(t=>{if(!t.endsWith(`
1
+ var U=Object.defineProperty;var i=(t,e)=>U(t,"name",{value:e,configurable:!0});import{hashText as F}from"../hash.js";import{ActCommitUnknown as I}from"../commit-result.js";import{assertHostNotCancelled as u}from"../host-controls.js";import{existsSync as E,readFileSync as m,readdirSync as y}from"node:fs";import{join as d}from"node:path";import{createHash as O}from"node:crypto";import{requireEffects as j}from"../read-only.js";import{underTheRegions as A}from"../../land/act.js";import{publishBundle as C,nativePublicationStorage as L}from"./publication.js";import{library14_actIdentity as k,library14_parse as g,library14_canonical as z}from"../../vendor/runtime.js";import{fullDigest as W}from"../digest.js";const v=i((t,e)=>{if(!e||e.includes("\0"))throw Error("REFUSE\xB7act missing identity");return d(t,"ledger","acts","committed-"+encodeURIComponent(e))},"atOf"),w=i(t=>{try{const e=y(t).filter(r=>r.startsWith("place-")&&r.endsWith(".bound")).map(r=>({place:decodeURIComponent(r.slice(6,-6)),records:m(d(t,r),"utf8")}));return{records:m(d(t,"records.bound"),"utf8"),receipt:m(d(t,"receipt.bound"),"utf8"),...e.length?{placements:e}:{}}}catch(e){throw Error(`REFUSE\xB7act committed result unreadable \xB7 ${e.code??"read failed"}`)}},"read"),x=i(t=>{if(!t.endsWith(`
2
2
  `))throw Error("REFUSE\xB7act truncated committed lines");return t.slice(0,-1).split(`
3
3
  `)},"actLines");function N(t,e){if(!e.receipt.endsWith(`
4
4
  `)||e.receipt.slice(0,-1).includes(`
@@ -1 +1 @@
1
- var j=Object.defineProperty;var i=(e,c)=>j(e,"name",{value:c,configurable:!0});import{existsSync as g,readdirSync as I,statSync as E,openSync as N,fstatSync as C,readSync as S,closeSync as O}from"node:fs";import{join as f}from"node:path";import{library3_readPlaceActContext as z,library3_placeActReceiptsOf as U}from"../../vendor/runtime.js";import{transactPlaceAct as k}from"../place-act-transaction.js";import{canonicalActStore as B,underAuthorityRegions as F,underTheRegions as J,underRootProjection as H}from"../../land/act.js";import{requireEffects as T}from"../read-only.js";import{receiverClock as h}from"../host-controls.js";import{publishBundle as W,nativePublicationStorage as v}from"./publication.js";const s=i(e=>{throw Error("REFUSE\xB7place act "+e)},"fail"),y=i(e=>{(!e||!Number.isSafeInteger(e.acts)||e.acts<1||!Number.isSafeInteger(e.bytes)||e.bytes<1)&&s("missing storage budget")},"budget"),m=i(e=>f(e,"ledger","place-acts"),"base"),A=i((e,c)=>((!c||c.includes("\0"))&&s("missing identity"),f(m(e),"committed-"+encodeURIComponent(c))),"at");function b(e,c){if(y(c),!g(m(e)))return{names:[],bytes:0};const t=I(m(e)).filter(n=>n.startsWith("committed-"));t.length>c.acts&&s("stored act budget");let o=0;for(const n of t)for(const r of["context.json","receipts.json","originals.json"]){const l=E(f(m(e),n,r));(!l.isFile()||(o+=l.size)>c.bytes)&&s("stored aggregate byte budget")}return{names:t,bytes:o}}i(b,"storedInventory");function R(e,c){y(c);let t=0;const o=i(n=>{const r=N(f(e,n),"r");try{const l=C(r);(!l.isFile()||l.size>c.bytes-t)&&s("stored byte budget");const a=Buffer.alloc(l.size);let p=0;for(;p<a.length;){const d=S(r,a,p,a.length-p,null);d||s("stored member changed while reading"),p+=d}return S(r,Buffer.alloc(1),0,1,null)!==0&&s("stored member changed while reading"),t+=p,new TextDecoder("utf-8",{fatal:!0}).decode(a)}finally{O(r)}},"read");try{const n=o("context.json"),r=JSON.parse(o("receipts.json")),l=JSON.parse(o("originals.json"));return{context:n,receipts:r,originals:l}}catch(n){if(n instanceof Error&&n.message.startsWith("REFUSE\xB7"))throw n;return s("committed bundle unreadable")}}i(R,"readBundle");function w(e,c,t){const o=U(e.context,e.receipts,t),n=z(e.context,t.budget);return(o.identity!==c||JSON.stringify(e.originals)!==JSON.stringify(n.places.map(r=>r.records)))&&s("stored original/context identity mismatch"),n}i(w,"authenticated");function P(e,c,t,o){const n=A(e,c);if(!g(n))return;const r=R(n,o);return w(r,c,t.historical(r.context)),r}i(P,"placeActResult");function _(e,c,t,o){y(o),(!c.length||new Set(c.map(a=>a.place)).size!==c.length)&&s("missing/ambiguous initial heads");const n=new Map(c.map(a=>(h(a.epoch,s),a.identity||s("missing initial head"),[a.place,{...a}])));if(!g(m(e)))return[...n.values()];const{names:r}=b(e,o),l=r.map(a=>{const p=decodeURIComponent(a.slice(10)),d=R(f(m(e),a),o),u=w(d,p,t.historical(d.context));return u.root.namespace!==t.contract.root.namespace&&s("stored clock namespace mismatch"),{id:p,context:u}});for(;l.length;){const a=l.findIndex(d=>d.context.places.every(u=>n.get(u.place)?.identity===u.previous));a<0&&s("receiver chain fork or missing predecessor");const p=l.splice(a,1)[0];for(const d of p.context.places){const u=n.get(d.place),x=h(u.epoch,s)+1;(!Number.isSafeInteger(x)||h(d.epoch,s)!==x)&&s("receiver chain clock mismatch"),n.set(d.place,{place:d.place,identity:p.id,epoch:d.epoch})}}return[...n.values()]}i(_,"placeActHeads");function q(e,c=v){return e=B(e),{exclusive:i((t,o)=>(t.includes("")?J:F)(e,t,"place act",()=>H(e,"place act publication",o)),"exclusive"),result:i((t,o,n)=>P(e,t,o,n),"result"),inventory:i(t=>b(e,t),"inventory"),heads:i((t,o)=>_(e,t.initialHeads,t,o),"heads"),publish:i((t,o)=>W(A(e,t),o,c),"publish")}}i(q,"nativePlaceActPersistence");async function Z(e,c,t,o,n,r=v){return T("place act commitment"),k(c,t,o,n,q(e,r))}i(Z,"commitPlaceAct");function $(e,c,t){const{names:o}=b(e,t);return o.map(n=>{const r=decodeURIComponent(n.slice(10)),l=P(e,r,c,t);return l||s("committed carrier vanished"),{identity:r,bundle:l}})}i($,"committedPlaceActResults");export{Z as commitPlaceAct,$ as committedPlaceActResults,q as nativePlaceActPersistence,_ as placeActHeads,P as placeActResult};
1
+ var j=Object.defineProperty;var i=(e,c)=>j(e,"name",{value:c,configurable:!0});import{existsSync as g,readdirSync as I,statSync as E,openSync as N,fstatSync as C,readSync as S,closeSync as O}from"node:fs";import{join as f}from"node:path";import{library6_readPlaceActContext as z,library6_placeActReceiptsOf as U}from"../../vendor/runtime.js";import{transactPlaceAct as k}from"../place-act-transaction.js";import{canonicalActStore as B,underAuthorityRegions as F,underTheRegions as J,underRootProjection as H}from"../../land/act.js";import{requireEffects as T}from"../read-only.js";import{receiverClock as h}from"../host-controls.js";import{publishBundle as W,nativePublicationStorage as v}from"./publication.js";const s=i(e=>{throw Error("REFUSE\xB7place act "+e)},"fail"),y=i(e=>{(!e||!Number.isSafeInteger(e.acts)||e.acts<1||!Number.isSafeInteger(e.bytes)||e.bytes<1)&&s("missing storage budget")},"budget"),m=i(e=>f(e,"ledger","place-acts"),"base"),A=i((e,c)=>((!c||c.includes("\0"))&&s("missing identity"),f(m(e),"committed-"+encodeURIComponent(c))),"at");function b(e,c){if(y(c),!g(m(e)))return{names:[],bytes:0};const t=I(m(e)).filter(n=>n.startsWith("committed-"));t.length>c.acts&&s("stored act budget");let o=0;for(const n of t)for(const r of["context.json","receipts.json","originals.json"]){const l=E(f(m(e),n,r));(!l.isFile()||(o+=l.size)>c.bytes)&&s("stored aggregate byte budget")}return{names:t,bytes:o}}i(b,"storedInventory");function R(e,c){y(c);let t=0;const o=i(n=>{const r=N(f(e,n),"r");try{const l=C(r);(!l.isFile()||l.size>c.bytes-t)&&s("stored byte budget");const a=Buffer.alloc(l.size);let p=0;for(;p<a.length;){const d=S(r,a,p,a.length-p,null);d||s("stored member changed while reading"),p+=d}return S(r,Buffer.alloc(1),0,1,null)!==0&&s("stored member changed while reading"),t+=p,new TextDecoder("utf-8",{fatal:!0}).decode(a)}finally{O(r)}},"read");try{const n=o("context.json"),r=JSON.parse(o("receipts.json")),l=JSON.parse(o("originals.json"));return{context:n,receipts:r,originals:l}}catch(n){if(n instanceof Error&&n.message.startsWith("REFUSE\xB7"))throw n;return s("committed bundle unreadable")}}i(R,"readBundle");function w(e,c,t){const o=U(e.context,e.receipts,t),n=z(e.context,t.budget);return(o.identity!==c||JSON.stringify(e.originals)!==JSON.stringify(n.places.map(r=>r.records)))&&s("stored original/context identity mismatch"),n}i(w,"authenticated");function P(e,c,t,o){const n=A(e,c);if(!g(n))return;const r=R(n,o);return w(r,c,t.historical(r.context)),r}i(P,"placeActResult");function _(e,c,t,o){y(o),(!c.length||new Set(c.map(a=>a.place)).size!==c.length)&&s("missing/ambiguous initial heads");const n=new Map(c.map(a=>(h(a.epoch,s),a.identity||s("missing initial head"),[a.place,{...a}])));if(!g(m(e)))return[...n.values()];const{names:r}=b(e,o),l=r.map(a=>{const p=decodeURIComponent(a.slice(10)),d=R(f(m(e),a),o),u=w(d,p,t.historical(d.context));return u.root.namespace!==t.contract.root.namespace&&s("stored clock namespace mismatch"),{id:p,context:u}});for(;l.length;){const a=l.findIndex(d=>d.context.places.every(u=>n.get(u.place)?.identity===u.previous));a<0&&s("receiver chain fork or missing predecessor");const p=l.splice(a,1)[0];for(const d of p.context.places){const u=n.get(d.place),x=h(u.epoch,s)+1;(!Number.isSafeInteger(x)||h(d.epoch,s)!==x)&&s("receiver chain clock mismatch"),n.set(d.place,{place:d.place,identity:p.id,epoch:d.epoch})}}return[...n.values()]}i(_,"placeActHeads");function q(e,c=v){return e=B(e),{exclusive:i((t,o)=>(t.includes("")?J:F)(e,t,"place act",()=>H(e,"place act publication",o)),"exclusive"),result:i((t,o,n)=>P(e,t,o,n),"result"),inventory:i(t=>b(e,t),"inventory"),heads:i((t,o)=>_(e,t.initialHeads,t,o),"heads"),publish:i((t,o)=>W(A(e,t),o,c),"publish")}}i(q,"nativePlaceActPersistence");async function Z(e,c,t,o,n,r=v){return T("place act commitment"),k(c,t,o,n,q(e,r))}i(Z,"commitPlaceAct");function $(e,c,t){const{names:o}=b(e,t);return o.map(n=>{const r=decodeURIComponent(n.slice(10)),l=P(e,r,c,t);return l||s("committed carrier vanished"),{identity:r,bundle:l}})}i($,"committedPlaceActResults");export{Z as commitPlaceAct,$ as committedPlaceActResults,q as nativePlaceActPersistence,_ as placeActHeads,P as placeActResult};
@@ -1 +1 @@
1
- var f=Object.defineProperty;var i=(r,t)=>f(r,"name",{value:t,configurable:!0});import{existsSync as o,readdirSync as l}from"node:fs";import{dirname as c,join as a,resolve as m}from"node:path";import{library11_EXTENSION as p,library11_LOCK as y}from"../../vendor/runtime.js";function O(r){const t=m(r||".");let e=t;for(let n=0;n<64;n+=1){if(o(a(e,y))&&o(a(e,p)))return e;const s=c(e);if(s===e)break;e=s}return t}i(O,"storeRoot");const S=i(r=>o(r)?l(r,{withFileTypes:!0}).filter(t=>t.isDirectory()).length:0,"storeDirs");export{S as storeDirs,O as storeRoot};
1
+ var f=Object.defineProperty;var i=(r,t)=>f(r,"name",{value:t,configurable:!0});import{existsSync as o,readdirSync as l}from"node:fs";import{dirname as c,join as a,resolve as m}from"node:path";import{library14_EXTENSION as p,library14_LOCK as y}from"../../vendor/runtime.js";function O(r){const t=m(r||".");let e=t;for(let n=0;n<64;n+=1){if(o(a(e,y))&&o(a(e,p)))return e;const s=c(e);if(s===e)break;e=s}return t}i(O,"storeRoot");const S=i(r=>o(r)?l(r,{withFileTypes:!0}).filter(t=>t.isDirectory()).length:0,"storeDirs");export{S as storeDirs,O as storeRoot};
@@ -1 +1 @@
1
- var h=Object.defineProperty;var u=(a,f)=>h(a,"name",{value:f,configurable:!0});import{readFileSync as E}from"node:fs";import{library11_contentRequest as b,library11_transportSelection as v,library11_parse as g}from"../../vendor/runtime.js";import{boundedProcess as w}from"../process-lifetime.js";import{fetchBytes as S}from"../adapters/transport/http.js";async function x(a,f,d){const t=new URL(a).protocol.slice(0,-1),y=d.flatMap(o=>{const s=g(o);return s.kind==="fact"?[s.value.fields]:[]}),e=v(y,t);if(e===void 0)throw Error(`REFUSE\xB7transport ${t} no admitted content-request/1 policy`);if(e.name==="fetch"){if(!["http","https"].includes(t))throw Error(`REFUSE\xB7transport ${t} is not supported by this host adapter`);return S(a,e)}const l=process.env.BOUND_TRANSPORTS;if(!l)throw Error(`REFUSE\xB7transport ${t} no host binding for ${e.name}`);let c;try{const o=JSON.parse(E(l,"utf8"));if(!o||typeof o!="object"||!Object.prototype.hasOwnProperty.call(o,e.name))throw Error();const s=o[e.name];if(!s||typeof s!="object")throw Error();const r=s;if(r.kind!=="command"||typeof r.executable!="string"||!r.executable||!Array.isArray(r.args)||!r.args.every(n=>typeof n=="string")||r.environment!==void 0&&(!Array.isArray(r.environment)||!r.environment.every(n=>typeof n=="string")))throw Error();const m=r.environment??[],p={};process.env.PATH!==void 0&&(p.PATH=process.env.PATH);for(const n of m)process.env[n]!==void 0&&(p[n]=process.env[n]);c={executable:r.executable,args:r.args,env:p}}catch{throw Error(`REFUSE\xB7transport ${t} host binding unavailable or invalid`)}const i=w(c.executable,c.args,b(a,f,e),e,void 0,c.env);if(i.status!==0||i.signal!==null)throw Error(`REFUSE\xB7transport ${t} failed \xB7 status ${i.status??i.signal}`);return Buffer.from(i.stdoutBytes??"","base64")}u(x,"transportBytes");export{x as transportBytes};
1
+ var g=Object.defineProperty;var u=(o,l)=>g(o,"name",{value:l,configurable:!0});import{readFileSync as w}from"node:fs";import{library14_contentRequest as b,library14_transportSelection as v,library14_parse as R}from"../../vendor/runtime.js";import{boundedProcess as S}from"../process-lifetime.js";import{BoundRefusal as y}from"../refusals.js";import{fetchBytes as U}from"../adapters/transport/http.js";async function B(o,l,m,c={}){const t=new URL(o).protocol.slice(0,-1);if(c.allowedOrigins&&!c.allowedOrigins.includes(new URL(o).origin))throw new y("reference/transport","REFUSE\xB7transport origin is not allowed");if(c.signal?.aborted)throw new y("reference/cancelled","REFUSE\xB7reference cancelled");const h=m.flatMap(s=>{const a=R(s);return a.kind==="fact"?[a.value.fields]:[]}),e=v(h,t);if(e===void 0)throw Error(`REFUSE\xB7transport ${t} no admitted content-request/1 policy`);if(e.name==="fetch"){if(!["http","https"].includes(t))throw Error(`REFUSE\xB7transport ${t} is not supported by this host adapter`);return U(o,e,c)}const p=process.env.BOUND_TRANSPORTS;if(!p)throw Error(`REFUSE\xB7transport ${t} no host binding for ${e.name}`);let f;try{const s=JSON.parse(w(p,"utf8"));if(!s||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,e.name))throw Error();const a=s[e.name];if(!a||typeof a!="object")throw Error();const r=a;if(r.kind!=="command"||typeof r.executable!="string"||!r.executable||!Array.isArray(r.args)||!r.args.every(n=>typeof n=="string")||r.environment!==void 0&&(!Array.isArray(r.environment)||!r.environment.every(n=>typeof n=="string")))throw Error();const E=r.environment??[],d={};process.env.PATH!==void 0&&(d.PATH=process.env.PATH);for(const n of E)process.env[n]!==void 0&&(d[n]=process.env[n]);f={executable:r.executable,args:r.args,env:d}}catch{throw Error(`REFUSE\xB7transport ${t} host binding unavailable or invalid`)}const i=S(f.executable,f.args,b(o,l,e),e,void 0,f.env);if(i.status!==0||i.signal!==null)throw Error(`REFUSE\xB7transport ${t} failed \xB7 status ${i.status??i.signal}`);return Buffer.from(i.stdoutBytes??"","base64")}u(B,"transportBytes");export{B as transportBytes};
@@ -0,0 +1 @@
1
+ export {public6_ProfileCompositionRequest as ProfileCompositionRequest,public6_ProfileFieldBinding as ProfileFieldBinding,public6_ReleaseCategory as ReleaseCategory,public6_composeProfile as composeProfile,public6_profileDigest as profileDigest,public6_releaseCategoryPins as releaseCategoryPins} from "../public-types.js";
@@ -0,0 +1,2 @@
1
+ var z=Object.defineProperty;var u=(o,n)=>z(o,"name",{value:n,configurable:!0});import{sha256 as S}from"./hash.js";import{library5_decodeProfileComposition as B,library5_encodeProfileComposition as W,library5_inspectProfileComposition as A}from"../vendor/runtime.js";import{fieldOf as r}from"../fold/claims.js";import{lockLines as D,lockStanding as L}from"../fold/keys.js";import{authorityFor as T,rootSigner as U}from"../fold/signers.js";import{ownRecordAdmitted as j}from"../fold/signed.js";import{signaturesOf as G}from"../fold/digests.js";import{wordOf as x}from"../fold/wire.js";import{storeOf as H}from"../land/ledger.js";import{widenedWithoutWitness as I}from"../judge/widening.js";import{BoundRefusal as J,refuseBound as t}from"./refusals.js";const K=u(o=>S(o+`
2
+ `),"profileDigest");function se(o){const{profile:n,profiles:h,budget:m}=o,a=new Map(o.fields.map(e=>[e.contract,e]));a.size!==o.fields.length&&t("profile/ambiguous-field");let s;try{s=A(n,{profiles:h,fields:new Map(o.fields.map(e=>[e.contract,e.field])),digest:S},m)}catch(e){throw new J("profile/declaration","REFUSE\xB7profile/declaration "+(e instanceof Error?e.message:"Topos declaration refused"))}s.status==="open"&&t("profile/missing-parent"),s.fields.some(e=>e.composition!=="compatible")&&t("profile/incompatible");const l=H(o.root),d=D(l),f=L(l),w=G(l).admitted,P=T(d,U(o.root),w).admitted,E=P.some(e=>!e.coverage.includes("*"))?x(f,"families","region"):"",C=o.statements.filter(e=>j(e,o.place,E,P,w)),y=new Map;function v(e){if(y.has(e))return;const c=h.get(e);c===void 0&&t("profile/missing-parent");const i=B(c,m);y.set(e,i);for(const p of i.parents)v(p)}u(v,"visit");for(const e of n.parents)v(e);const b=K(W(n,m));y.set(b,n);const O=u((e,c)=>{const i=a.get(e.contract);if(!i||i.field.coordinate!==e.coordinate)return t("profile/undeclared-field");const p=C.filter(g=>r(g,"scope")===i.scope&&r(g,"role")===i.role&&r(g,"form")===i.form&&r(g,"measure")===i.measure&&r(g,"value")===e.value&&r(g,"restsOn")===c);return p.length!==1?t(p.length?"profile/ambiguous-authority":"profile/authority-required"):p[0]},"lineFor"),F=[...y].filter(([e])=>e!==b).flatMap(([e,c])=>c.fields.map(i=>O(i,e))),M=n.fields.map(e=>O(e,b)),R=x(f,"at-classes","witness");for(const e of F){const c=M.filter(i=>["scope","role","form","measure"].every(p=>r(i,p)===r(e,p)));I(c,[e],()=>!0,R).length&&t("profile/widening-witness-required")}const _=[...F,...M],k=N(s.pins,o.categories,C);return{status:"prepared",digest:b,inspection:s,lines:_,pins:s.pins,releases:k}}u(se,"composeProfile");function N(o,n,h){const m=[];for(const a of o){const s=n.filter(f=>f.category===a.category);s.length||t("release/category-missing"),s.length!==1&&t("release/category-ambiguous");const l=s[0];(l.class!==a.class||a.algorithm!=="sha256")&&t("release/category-class");const d=h.filter(f=>r(f,"scope")===l.scope&&r(f,"role")===l.role&&r(f,"form")==="alphabet"&&r(f,"measure")===l.measure);d.length||t("release/pin-missing"),d.length!==1&&t("release/pin-ambiguous"),r(d[0],"value")!==a.digest&&t("release/pin-integrity"),m.push(d[0])}return new Set(o.map(a=>a.category)).size!==o.length&&t("release/category-ambiguous"),m}u(N,"releaseCategoryPins");export{se as composeProfile,K as profileDigest,N as releaseCategoryPins};
@@ -1,7 +1,7 @@
1
- var Z=Object.defineProperty;var B=(s,c)=>Z(s,"name",{value:c,configurable:!0});import{actCosts as k}from"./act-cost.js";import{readFileSync as ee,existsSync as re}from"node:fs";import{join as te}from"node:path";import{library11_canonical as u,library11_parse as se,library11_PROTOCOL as ae,library11_byBytes as X}from"../vendor/runtime.js";import{landShard as oe,shardLines as ie}from"../land/ledger.js";import{fieldOf as e}from"../fold/claims.js";import{readOnly as ne}from"./read-only.js";import{library2_readingIdentityBytes as le,library2_readingReceiptIdentity as q}from"../vendor/runtime.js";import{readingPreparation as ce,inputLines as pe,readingFields as Y}from"./reading-preparation.js";import{inputLines as $e}from"./reading-preparation.js";const z=B(s=>[s,"identity"].join("/"),"receiptScope");function de(s,c,m,y,b,v=!0,$=[]){const t=b(m),i=b(y),f=y.split(`
2
- `).filter(Boolean);return[...v?[u({scope:z(s),role:"writes",form:"alphabet",measure:"digest",value:q(t,i,p=>b(new TextDecoder().decode(p))),by:c,at:"place:"+t})]:[],u({scope:s,role:"writes",form:"alphabet",measure:"observed",value:i,by:c,at:"place:"+i}),u({scope:s,role:"writes",form:"alphabet",measure:"bytes",value:t,by:c,at:"place:"+t,about:m}),u({scope:s,role:"writes",form:"interval",measure:"count",value:`${f.length}..${f.length}`,by:c,at:"place:"+i,about:y}),...$]}B(de,"portableReadingReceipt");function xe(s){const{root:c,store:m,reader:y,speaker:b,digest:v,capsule:$,region:t,projection:i,files:f}=s,p=s.emit??(()=>{}),{ordered:S,identity:w,by:d,journal:E,prior:j,prepare:r,retained:A,verify:C,ask:L,load:l,saved:U,handed:_,readingPlace:G}=ce(s),P=new Map,I=[];let D=0,N=0,H=0;for(const a of S)k.measure(()=>{s.assertCurrent?.();const{context:T,closure:J,input:n,scope:R}=r(a,P),W=A({context:T,closure:J,input:n,scope:R});let g,O;if(W)g=W.lines,O=W.payload;else{if(ne())throw Error("REFUSE\xB7preview reading closure is unpaid "+a.scope);const h=process.hrtime.bigint(),M=a.needs.flatMap(o=>P.get(o).lines),x=L(n,[{...G?{place:G}:{},protocol:ae,verb:"read",rootScope:a.scope,name:a.scope,region:t,at:a.resolution,reads:["**"],lines:[...pe(a.inputs.map(o=>({place:o,text:_.get(o)}))),...M],files:[]}],T)[0];if(x?.kind!=="fact"||!Array.isArray(x.claims))throw Error("REFUSE\xB7reading "+a.scope+" \xB7 "+(x?.why??"no claims"));if(g=x.claims.map(o=>{if(typeof o?.scope!="string"||typeof o?.measure!="string"||typeof o?.role!="string"||!o.bound||!["interval","enumerated"].includes(o.bound.kind))throw Error("REFUSE\xB7reading malformed claim "+a.scope);const F=o.bound,V=u({scope:o.scope,measure:o.measure,role:o.role,form:F.kind==="interval"?"interval":"alphabet",value:F.kind==="interval"?`${F.lo}..${F.hi}`:Array.isArray(F.values)?F.values.join("|"):"",by:d,at:"place:"+n});return Y(V),V}),!g.length&&!s.allowsEmpty)throw Error("REFUSE\xB7reading empty response is not admitted "+a.scope);if(H++,C(),s.assertCurrent?.(),O=U(g.length?[...g].sort(X).join(`
1
+ var q=Object.defineProperty;var R=(o,g)=>q(o,"name",{value:g,configurable:!0});import{actCosts as ee}from"./act-cost.js";import{readFileSync as te,existsSync as re}from"node:fs";import{join as se}from"node:path";import{library14_canonical as u,library14_parse as ie,library14_PROTOCOL as ae,library14_byBytes as Y}from"../vendor/runtime.js";import{landShard as oe,shardLines as ne}from"../land/ledger.js";import{fieldOf as s}from"../fold/claims.js";import{readOnly as le}from"./read-only.js";import{library5_readingIdentityBytes as ce,library5_readingReceiptIdentity as G}from"../vendor/runtime.js";import{readingPreparation as pe,inputLines as de,readingFields as Z}from"./reading-preparation.js";import{inputLines as Fe}from"./reading-preparation.js";const W=R(o=>[o,"identity"].join("/"),"receiptScope");function ue(o,g,f,m,h,b=!0,j=[]){const y=h(f),p=h(m),B=m.split(`
2
+ `).filter(Boolean);return[...b?[u({scope:W(o),role:"writes",form:"alphabet",measure:"digest",value:G(y,p,F=>h(new TextDecoder().decode(F))),by:g,at:"place:"+y})]:[],u({scope:o,role:"writes",form:"alphabet",measure:"observed",value:p,by:g,at:"place:"+p}),u({scope:o,role:"writes",form:"alphabet",measure:"bytes",value:y,by:g,at:"place:"+y,about:f}),u({scope:o,role:"writes",form:"interval",measure:"count",value:`${B.length}..${B.length}`,by:g,at:"place:"+p,about:m}),...j]}R(ue,"portableReadingReceipt");function Re(o){const{root:g,store:f,reader:m,speaker:h,digest:b,capsule:j,region:y,projection:p,files:B}=o,F=o.emit??(()=>{}),{ordered:t,identity:r,by:e,journal:i,prior:I,prepare:d,retained:E,verify:A,ask:z,load:T,saved:U,handed:a,readingPlace:L}=pe(o),_=new Map,C=[];let x=0,D=0,P=0;for(const n of t)ee.measure(()=>{o.assertCurrent?.();const{context:J,closure:K,input:c,scope:O}=d(n,_),V=E({context:J,closure:K,input:c,scope:O});let v,$;if(V)v=V.lines,$=V.payload;else{if(le())throw Error("REFUSE\xB7preview reading closure is unpaid "+n.scope);const w=process.hrtime.bigint(),k=n.needs.flatMap(l=>_.get(l).lines),S=z(c,[{...L?{place:L}:{},protocol:ae,verb:"read",rootScope:n.scope,name:n.scope,region:y,at:n.resolution,reads:["**"],lines:[...de(n.inputs.map(l=>({place:l,text:a.get(l)}))),...k],files:[]}],J)[0];if(S?.kind!=="fact"||!Array.isArray(S.claims))throw Error("REFUSE\xB7reading "+n.scope+" \xB7 "+(S?.why??"no claims"));if(v=S.claims.map(l=>{if(typeof l?.scope!="string"||typeof l?.measure!="string"||typeof l?.role!="string"||!l.bound||!["interval","enumerated"].includes(l.bound.kind))throw Error("REFUSE\xB7reading malformed claim "+n.scope);const N=l.bound,X=u({scope:l.scope,measure:l.measure,role:l.role,form:N.kind==="interval"?"interval":"alphabet",value:N.kind==="interval"?`${N.lo}..${N.hi}`:Array.isArray(N.values)?N.values.join("|"):"",by:e,at:"place:"+c});return Z(X),X}),!v.length&&!o.allowsEmpty)throw Error("REFUSE\xB7reading empty response is not admitted "+n.scope);if(P++,A(),o.assertCurrent?.(),$=U(v.length?[...v].sort(Y).join(`
3
3
  `)+`
4
- `:""),U(J)!==n)throw Error("REFUSE\xB7receipt input closure mismatch");const Q=(Number(process.hrtime.bigint()-h)/1e9).toFixed(6);oe(m,b,E,[u({scope:R,role:"writes",form:"interval",measure:"count",value:`${g.length}..${g.length}`,by:d,at:"place:"+O}),u({scope:R,role:"writes",form:"alphabet",measure:"bytes",value:n,by:d,at:"place:"+n}),u({scope:R,role:"writes",form:"interval",measure:"s",value:Q+".."+Q,by:d,at:"place:"+n})]),a.resolution===1&&N++}const K=T?q(n,O,h=>v(new TextDecoder().decode(h))):O;if(T&&a.resolution!==1&&I.push(u({scope:z(R),role:"writes",form:"alphabet",measure:"digest",value:K,by:d,at:"place:"+n})),P.set(a.scope,{digest:K,lines:g}),I.push(u({scope:a.scope,role:"writes",form:"alphabet",measure:"observed",value:n,by:d,at:"place:"+n}),...a.inputs.map(h=>u({scope:h,role:"writes",form:"alphabet",measure:"observed",value:v(_.get(h)),by:d,at:"witness:"+n})),...g),a.resolution===1){D++;const h=l(O);if(h===void 0)throw Error("REFUSE\xB7receipt missing verified carrier "+O);const M=ie(m,b,E).filter(x=>e(x,"scope")===R&&e(x,"measure")==="s"&&e(x,"at")==="place:"+n);I.push(...de(R,d,J,h,v,!!T,M))}});return C(),p(`RECEIPTS ${D} read \xB7 ${N} opened \xB7 reading closures`),{lines:I,read:D,opened:N,executed:H}}B(xe,"readingClosures");function Se(s,c,m,y,b=!1){const v=c.filter(t=>e(t,"scope").startsWith("receipts/readings/")&&e(t,"measure")==="bytes"&&e(t,"role")==="writes"),$=B((t,i)=>{const f=t.split(":")[1];if(!f||!/^[a-f0-9]+$/.test(f))return;const p=Y(i).about;if(p!==void 0)return m(p)===t?p:void 0;const S=te(s,"cas","carried",f);if(!re(S))return;const w=ee(S,"utf8");return m(w)===t?w:void 0},"load");for(const t of v){const i=e(t,"value"),f=e(t,"scope"),p=e(t,"by"),S=c.filter(r=>e(r,"scope")===f&&e(r,"measure")==="count"&&e(r,"by")===p&&e(r,"role")==="writes");if(S.length!==1||$(i,t)===void 0)return;const w=S[0],d=$(e(w,"at").replace(/^place:/,""),w);if(d===void 0)return;const E=$(i,t);if(E.trimStart().startsWith("[")){let r;try{r=JSON.parse(E)}catch{return}if(!Array.isArray(r)||r.length!==6||r[0]!=="reading-context@1")return;const A={instrument:r[1],implementation:r[2],policy:r[3],inputs:r[4],environment:r[5]};try{if(new TextDecoder().decode(le(A))!==E)return}catch{return}if(y){const l=typeof y=="function"?y(A):y;if(l===void 0||JSON.stringify([...l].sort((U,_)=>X(U[0],_[0])))!==JSON.stringify(r[5]))return}const C=c.filter(l=>e(l,"scope")===z(f)&&e(l,"measure")==="digest"&&e(l,"by")===p&&e(l,"role")==="writes"&&e(l,"at")==="place:"+i),L=q(i,e(w,"at").replace(/^place:/,""),l=>m(new TextDecoder().decode(l)));if(C.length!==1||e(C[0],"value")!==L)return}else if(b||!E.endsWith(`
5
- `)||E.split(`
6
- `).filter(Boolean).some(r=>se(r).kind!=="fact"))return;const j=d.split(`
7
- `).filter(Boolean);if(e(w,"value")!==`${j.length}..${j.length}`||j.some(r=>e(r,"by")!==p||e(r,"at")!=="place:"+i))return}return v.length}B(Se,"verifiedReadingReceipts");export{$e as inputLines,de as portableReadingReceipt,xe as readingClosures,Se as verifiedReadingReceipts};
4
+ `:""),U(K)!==c)throw Error("REFUSE\xB7receipt input closure mismatch");const Q=(Number(process.hrtime.bigint()-w)/1e9).toFixed(6);oe(f,h,i,[u({scope:O,role:"writes",form:"interval",measure:"count",value:`${v.length}..${v.length}`,by:e,at:"place:"+$}),u({scope:O,role:"writes",form:"alphabet",measure:"bytes",value:c,by:e,at:"place:"+c}),u({scope:O,role:"writes",form:"interval",measure:"s",value:Q+".."+Q,by:e,at:"place:"+c})]),n.resolution===1&&D++}const H=J?G(c,$,w=>b(new TextDecoder().decode(w))):$;if(J&&n.resolution!==1&&C.push(u({scope:W(O),role:"writes",form:"alphabet",measure:"digest",value:H,by:e,at:"place:"+c})),_.set(n.scope,{digest:H,lines:v}),C.push(u({scope:n.scope,role:"writes",form:"alphabet",measure:"observed",value:c,by:e,at:"place:"+c}),...n.inputs.map(w=>u({scope:w,role:"writes",form:"alphabet",measure:"observed",value:b(a.get(w)),by:e,at:"witness:"+c})),...v),n.resolution===1){x++;const w=T($);if(w===void 0)throw Error("REFUSE\xB7receipt missing verified carrier "+$);const k=ne(f,h,i).filter(S=>s(S,"scope")===O&&s(S,"measure")==="s"&&s(S,"at")==="place:"+c);C.push(...ue(O,e,K,w,b,!!J,k))}});return A(),F(`RECEIPTS ${x} read \xB7 ${D} opened \xB7 reading closures`),{lines:C,read:x,opened:D,executed:P}}R(Re,"readingClosures");const M=new Set,fe=1024;function Oe(o,g,f,m,h=!1){const b=[],j=new Map,y=new Map,p=R((t,r,e)=>JSON.stringify(e===void 0?[t,r]:[t,r,e]),"key"),B=R((t,r,e)=>{const i=t.get(r);i?i.push(e):t.set(r,[e])},"add");for(const t of g){const r=s(t,"scope");if(!r.startsWith("receipts/readings/")||s(t,"role")!=="writes")continue;const e=s(t,"measure"),i=s(t,"by");e==="bytes"?b.push(t):e==="count"?B(j,p(r,i),t):e==="digest"&&B(y,p(r,i,s(t,"at")),t)}const F=R((t,r)=>{const e=t.split(":")[1];if(!e||!/^[a-f0-9]+$/.test(e))return;const i=Z(r).about;if(i!==void 0)return f(i)===t?i:void 0;const I=se(o,"cas","carried",e);if(!re(I))return;const d=te(I,"utf8");return f(d)===t?d:void 0},"load");for(const t of b){const r=s(t,"value"),e=s(t,"scope"),i=s(t,"by"),I=j.get(p(e,i))??[],d=F(r,t);if(I.length!==1||d===void 0)return;const E=I[0],A=F(s(E,"at").replace(/^place:/,""),E);if(A===void 0)return;const z=y.get(p(W(e),i,"place:"+r))??[],T=m?void 0:f(JSON.stringify([r,s(E,"at"),e,i,s(E,"value"),z,h]));if(T&&M.has(T))continue;if(d.trimStart().startsWith("[")){let a;try{a=JSON.parse(d)}catch{return}if(!Array.isArray(a)||a.length!==6||a[0]!=="reading-context@1")return;const L={instrument:a[1],implementation:a[2],policy:a[3],inputs:a[4],environment:a[5]};try{if(new TextDecoder().decode(ce(L))!==d)return}catch{return}if(m){const x=typeof m=="function"?m(L):m;if(x===void 0||JSON.stringify([...x].sort((D,P)=>Y(D[0],P[0])))!==JSON.stringify(a[5]))return}const _=y.get(p(W(e),i,"place:"+r))??[],C=G(r,s(E,"at").replace(/^place:/,""),x=>f(new TextDecoder().decode(x)));if(_.length!==1||s(_[0],"value")!==C)return}else if(h||!d.endsWith(`
5
+ `)||d.split(`
6
+ `).filter(Boolean).some(a=>ie(a).kind!=="fact"))return;const U=A.split(`
7
+ `).filter(Boolean);if(s(E,"value")!==`${U.length}..${U.length}`||U.some(a=>s(a,"by")!==i||s(a,"at")!=="place:"+r))return;T&&(M.size>=fe&&M.delete(M.values().next().value),M.add(T))}return b.length}R(Oe,"verifiedReadingReceipts");export{Fe as inputLines,ue as portableReadingReceipt,Re as readingClosures,Oe as verifiedReadingReceipts};
@@ -1 +1 @@
1
- var v=Object.defineProperty;var c=(t,e)=>v(t,"name",{value:e,configurable:!0});import{BoundRefusal as d}from"./refusals.js";import{sha256 as y}from"./hash.js";import{AsyncLocalStorage as g}from"node:async_hooks";import{createHash as l}from"node:crypto";import{readFileSync as x,realpathSync as S}from"node:fs";import{release as h}from"node:os";import{library2_readingIdentityBytes as B}from"../vendor/runtime.js";const a=new g,U=a.getStore.bind(a);function z(t,e,i){if(e){const r=t.split(":")[0],o=w(c(f=>r+":"+l(r).update(f).digest("hex"),"hash"),e.env,e.cwd,e.flags),s=[...e.context.environment].sort(([f],[p])=>Buffer.compare(Buffer.from(f),Buffer.from(p)));if(JSON.stringify([...o].sort(([f],[p])=>Buffer.compare(Buffer.from(f),Buffer.from(p))))!==JSON.stringify(s))throw Error("REFUSE\xB7reading execution environment differs from its identity")}return a.run({identity:t,execution:e},i)}c(z,"withReadingBoundary");const m=new Map,E=c(t=>{const e=m.get(t);if(e)return e;const i=t+":"+l(t).update(x(process.execPath)).digest("hex");return m.set(t,i),i},"runtimeOf");function w(t,e=process.env,i=process.cwd(),r=process.execArgv){const n=Object.entries(e).filter(o=>o[1]!==void 0);return[["variables",t(JSON.stringify(n.sort(([o],[s])=>Buffer.compare(Buffer.from(o),Buffer.from(s)))))],["cwd",t(S(i))],["flags",t(JSON.stringify(r))],["runtime",E(t("").split(":")[0])],["platform",t(JSON.stringify([process.platform,process.arch,process.versions,h()]))]]}c(w,"readingEnvironment");function A(t,e){const i=c(o=>t.filter(s=>e(s,"scope")===o&&e(s,"role")==="writes"&&e(s,"value")!=="withdraw"),"values"),r=i("wire/reading-context"),n=i("wire/reading-receipt");if(!r.length&&!n.length)return!1;if(r.length!==1||n.length!==1||e(r[0],"value")!=="reading-context@1"||e(n[0],"value")!=="reading-receipt@1")throw Error("REFUSE\xB7reading identity ambiguous or incomplete profiles");return!0}c(A,"readingProfile");function L(t,e,i={env:process.env,cwd:process.cwd(),flags:process.execArgv}){const r=Object.fromEntries(Object.entries(i.env).filter(f=>f[1]!==void 0)),n=i.cwd,o=Object.freeze([...i.flags]);Object.freeze(r);const s={...t,environment:w(e,r,n,o)};return B(s),{context:s,env:r,cwd:n,flags:o}}c(L,"readingExecution");const u=new g,M=c(()=>u.getStore()!==void 0,"preparingView");function P(t,e,i=!0){const r=u.getStore();if(!r)return e();const n=r.inputs.get(t);if(n)return n.value;const o=e(),s=JSON.stringify(o)??"null";if(r.inputs.size>=r.files||(r.used+=Buffer.byteLength(t)+Buffer.byteLength(s))>r.bytes)throw new d("reading-identity/budget","REFUSE\xB7reading-identity/budget view inputs");return r.inputs.set(t,{value:o,encoded:s,read:e,identity:i}),o}c(P,"viewInput");function V(t,e){const i={inputs:new Map,...t,used:0};return u.run(i,()=>{const r=e();for(const n of i.inputs.values())if((JSON.stringify(u.exit(n.read))??"null")!==n.encoded)throw new d("reading-identity/context","REFUSE\xB7reading-identity/context view inputs changed during preparation");return{value:r,inputs:[...i.inputs].filter(([,n])=>n.identity).map(([n,o])=>[n,y(o.encoded)]).sort(([n],[o])=>n<o?-1:n>o?1:0)}})}c(V,"captureViewInputs");export{V as captureViewInputs,M as preparingView,U as readingBoundary,w as readingEnvironment,L as readingExecution,A as readingProfile,P as viewInput,z as withReadingBoundary};
1
+ var N=Object.defineProperty;var f=(e,t)=>N(e,"name",{value:t,configurable:!0});import{BoundRefusal as a}from"./refusals.js";import{sha256 as R}from"./hash.js";import{AsyncLocalStorage as y}from"node:async_hooks";import{createHash as v}from"node:crypto";import{readFileSync as J,realpathSync as j}from"node:fs";import{release as F}from"node:os";import{library5_readingIdentityBytes as A}from"../vendor/runtime.js";const w=new y,H=w.getStore.bind(w);function K(e,t,n){if(t){const r=e.split(":")[0],i=b(f(c=>r+":"+v(r).update(c).digest("hex"),"hash"),t.env,t.cwd,t.flags),s=[...t.context.environment].sort(([c],[u])=>Buffer.compare(Buffer.from(c),Buffer.from(u)));if(JSON.stringify([...i].sort(([c],[u])=>Buffer.compare(Buffer.from(c),Buffer.from(u))))!==JSON.stringify(s))throw Error("REFUSE\xB7reading execution environment differs from its identity")}return w.run({identity:e,execution:t},n)}f(K,"withReadingBoundary");const x=new Map,z=f(e=>{const t=x.get(e);if(t)return t;const n=e+":"+v(e).update(J(process.execPath)).digest("hex");return x.set(e,n),n},"runtimeOf");function b(e,t=process.env,n=process.cwd(),r=process.execArgv){const o=Object.entries(t).filter(i=>i[1]!==void 0);return[["variables",e(JSON.stringify(o.sort(([i],[s])=>Buffer.compare(Buffer.from(i),Buffer.from(s)))))],["cwd",e(j(n))],["flags",e(JSON.stringify(r))],["runtime",z(e("").split(":")[0])],["platform",e(JSON.stringify([process.platform,process.arch,process.versions,F()]))]]}f(b,"readingEnvironment");function W(e,t){const n=f(i=>e.filter(s=>t(s,"scope")===i&&t(s,"role")==="writes"&&t(s,"value")!=="withdraw"),"values"),r=n("wire/reading-context"),o=n("wire/reading-receipt");if(!r.length&&!o.length)return!1;if(r.length!==1||o.length!==1||t(r[0],"value")!=="reading-context@1"||t(o[0],"value")!=="reading-receipt@1")throw Error("REFUSE\xB7reading identity ambiguous or incomplete profiles");return!0}f(W,"readingProfile");function q(e,t,n={env:process.env,cwd:process.cwd(),flags:process.execArgv}){const r=Object.fromEntries(Object.entries(n.env).filter(c=>c[1]!==void 0)),o=n.cwd,i=Object.freeze([...n.flags]);Object.freeze(r);const s={...e,environment:b(t,r,o,i)};return A(s),{context:s,env:r,cwd:o,flags:i}}f(q,"readingExecution");const g=new y,p=new y,l=new y,E=new WeakMap,d=new Map;let m=0;const O=16*1024*1024,L=512;function h(e){return{encoded:e,digest:R(e),cost:Buffer.byteLength(e)}}f(h,"encoding");function B(e){if(typeof e=="string"){const t=d.get(e);if(t)return t;const n=h(JSON.stringify(e)),r=Buffer.byteLength(e)+n.cost;if(r<=O){for(;d.size>=L||m+r>O;){const o=d.keys().next().value;m-=Buffer.byteLength(o)+d.get(o).cost,d.delete(o)}d.set(e,n),m+=r}return n}if(Array.isArray(e)&&Object.isFrozen(e)&&Object.getPrototypeOf(e)===Array.prototype&&e.toJSON===void 0){const t=E.get(e);if(t)return t;if(Reflect.ownKeys(e).length===e.length+1&&Array.from({length:e.length},(n,r)=>Object.getOwnPropertyDescriptor(e,String(r))).every(n=>n&&"value"in n&&typeof n.value=="string")){const n=h(JSON.stringify(e));return E.set(e,n),n}}return h(JSON.stringify(e)??"null")}f(B,"encodeObserved");const M=f(e=>B(e()).encoded,"encodedInput"),I=f(e=>{if(g.exit(()=>p.exit(()=>M(e.read)))!==e.encoded)throw new a("reading-identity/context","REFUSE\xB7reading-identity/context view inputs changed during preparation")},"verifyInput");function Q(e){if(p.getStore())return e();const t=new Map;return p.run(t,()=>{const n=e();if(n&&typeof n.then=="function")throw new a("reading-identity/context","REFUSE\xB7reading-identity/context input observation must be synchronous");for(const r of t.values())I(r);return n})}f(Q,"withViewInputObservation");const X=f(()=>g.getStore()!==void 0,"preparingView");function U(e,t,n=!0){const r=g.getStore();if(!r)return t();l.getStore()?.add(e);const o=r.inputs.get(e);if(o)return o.value;const i=p.getStore(),s=i?.get(e),c=s?s.value:t(),u=s??B(c);if(r.inputs.size>=r.files||(r.used+=Buffer.byteLength(e)+u.cost)>r.bytes)throw new a("reading-identity/budget","REFUSE\xB7reading-identity/budget view inputs");const S={value:c,encoded:u.encoded,digest:u.digest,cost:u.cost,read:t,identity:n};return r.inputs.set(e,S),i&&!s&&i.set(e,S),c}f(U,"viewInput");function Y(e,t){const n={inputs:new Map,...e,used:0};return g.run(n,()=>{const r=t();if(!p.getStore())for(const o of n.inputs.values())I(o);return{value:r,inputs:[...n.inputs].filter(([,o])=>o.identity).map(([o,i])=>[o,i.digest]).sort(([o],[i])=>o<i?-1:o>i?1:0)}})}f(Y,"captureViewInputs");function Z(e){let t;return()=>{const n=g.getStore(),r=p.getStore();if(!n||!r)return e();if(t?.observation===r){for(const[c,u]of t.inputs)U(c,u.read,u.identity);return t.value}const o=new Set,i=l.getStore(),s=l.run(o,e);if(s&&typeof s.then=="function")throw new a("reading-identity/context","REFUSE\xB7reading-identity/context shared preparation must be synchronous");for(const c of o)i?.add(c);return t={value:s,inputs:[...o].map(c=>[c,n.inputs.get(c)]),observation:r},s}}f(Z,"sharedViewInputs");export{Y as captureViewInputs,X as preparingView,H as readingBoundary,b as readingEnvironment,q as readingExecution,W as readingProfile,Z as sharedViewInputs,U as viewInput,K as withReadingBoundary,Q as withViewInputObservation};
@@ -1,3 +1,3 @@
1
- var k=Object.defineProperty;var a=(t,e)=>k(t,"name",{value:e,configurable:!0});import{readFileSync as J}from"node:fs";import{sha256 as u}from"./hash.js";import{captureViewInputs as j,viewInput as y,readingEnvironment as b}from"./reading-context.js";import{withoutEffects as q}from"./read-only.js";import{committedInventoryFingerprint as R,committedLocalActs as F,withCommittedLocalActObservation as x}from"./ports/local-act.js";import{ingressBundles as A}from"./ports/ingress.js";import{instrumentCoordinates as B}from"../fold/digests.js";import{viewsOf as D}from"../fold/views.js";import{standingOf as K}from"../cli/place.js";import{evidenceLines as V}from"../render/view.js";import{resolve as O,join as H}from"node:path";import{library11_LOCK as M}from"../vendor/runtime.js";import{fieldOf as p,isWire as W}from"../fold/claims.js";import{storeOf as U}from"../land/ledger.js";import{underRootAuthority as _}from"../land/act.js";import{prepareObservedReadings as $}from"../fold/observed.js";import{authenticatedStanding as g}from"./admitted-place.js";import{withHostCall as I}from"./call-context.js";import{withContentStore as z}from"./content-store.js";import{BoundRefusal as n}from"./refusals.js";async function ge(t){try{if(!t||typeof t.place!="string"||!t.place||!t.instrument?.runtime)throw new n("host/context","REFUSE\xB7host/context");const e={...t.limits};for(const s of[e.bytes,e.files,e.readings,e.probes])if(!Number.isSafeInteger(s)||s<1)throw new n("host/budget","REFUSE\xB7host/budget");if(e.signal?.aborted)throw new n("host/cancelled","REFUSE\xB7host/cancelled");const i=O(t.place),r=U(i),o=structuredClone(t.instrument),d=t.reader;return await I({instrumentName:o.name,runtime:o.runtime,output:a(()=>{},"output")},()=>z(r,()=>_(r,"prepare reading identity",()=>{const s=w(g(i));for(const m of["bytes","files","readings","probes"])e[m]=Math.min(e[m],s[m]);return{kind:"fact",preparations:$(i,r,e,d)}}),()=>g(i)))}catch(e){return{kind:"refuse",code:e instanceof n?e.code:"reading-identity/failed",diagnostic:e instanceof Error?e.message:"REFUSE\xB7reading identity failed"}}}a(ge,"prepareNativeReadingIdentity");function w(t){const e=a(i=>{const r=t.filter(s=>p(s,"scope")==="reading-identity/"+i&&p(s,"role")==="writes"&&p(s,"value")!=="withdraw");if(r.length!==1)throw new n("reading-identity/budget","REFUSE\xB7reading identity requires one declared "+i+" limit");const o=/^0\.\.([1-9][0-9]*)$/.exec(p(r[0],"value")),d=Number(o?.[1]);if(!o||!Number.isSafeInteger(d))throw new n("reading-identity/budget","REFUSE\xB7invalid reading identity "+i+" limit");return d},"limit");return{bytes:e("bytes"),files:e("files"),readings:e("readings"),probes:e("probes")}}a(w,"declaredReadingIdentityLimits");function le(t){try{if(!t||!t.instrument?.runtime||typeof t.place!="string"||!t.place)throw new n("host/context","REFUSE\xB7host/context");if(t.view!=="lines"&&t.view!=="evidence")throw new n("reading-identity/selection","REFUSE\xB7reading-identity/selection supports lines and evidence");const e=t.view,i=O(t.place),r=U(i),o=t.instrument;return I({instrumentName:o.name,runtime:structuredClone(o.runtime),output:a(()=>{},"output")},()=>q(()=>{const d=R(F(r)),s=w(g(i)),l=new Date().toISOString().slice(0,10),m=b(u),f=j(s,()=>x(r,()=>{const C=w(y("authenticated-configuration:"+i,()=>g(i)));if(JSON.stringify(C)!==JSON.stringify(s))throw new n("reading-identity/context","REFUSE\xB7reading-identity/context identity budget changed");if(e==="evidence"&&y("foreign-ingress:"+r,()=>A(r)).length)throw new n("reading-identity/selection","REFUSE\xB7reading-identity/selection foreign view identity requires a transport snapshot");const v=K(i).standing;if(e==="evidence"){const c=D(v).get(e);if(!c||c.shape||c.regions.length!==1||c.regions[0]?.name!=="evidence")throw new n("reading-identity/selection","REFUSE\xB7reading-identity/selection requires the native evidence projection")}const E=e==="lines"?v.filter(W):V(i,r),S=[...B(r,o.runtime.entry,[],o.runtime.root,[],!0)].map(([c,L])=>[c,L]);if(!S.length)throw new n("reading-identity/failed","REFUSE\xB7reading-identity/failed is unavailable");return{text:E.length?E.join(`
1
+ var V=Object.defineProperty;var c=(e,t)=>V(e,"name",{value:t,configurable:!0});import{readFileSync as j}from"node:fs";import{sha256 as w}from"./hash.js";import{captureViewInputs as q,viewInput as E,readingEnvironment as F,withViewInputObservation as B,sharedViewInputs as D}from"./reading-context.js";import{withoutEffects as K}from"./read-only.js";import{committedInventoryFingerprint as I,committedLocalActs as O,withCommittedLocalActObservation as z}from"./ports/local-act.js";import{ingressBundles as H}from"./ports/ingress.js";import{instrumentCoordinates as M}from"../fold/digests.js";import{viewsOf as W}from"../fold/views.js";import{standingOf as _}from"../cli/place.js";import{evidenceLines as $}from"../render/view.js";import{resolve as U,join as x}from"node:path";import{library14_LOCK as G}from"../vendor/runtime.js";import{fieldOf as y,isWire as P}from"../fold/claims.js";import{storeOf as N}from"../land/ledger.js";import{underRootAuthority as Q}from"../land/act.js";import{prepareObservedReadings as T}from"../fold/observed.js";import{authenticatedStanding as h}from"./admitted-place.js";import{withHostCall as k}from"./call-context.js";import{withContentStore as X}from"./content-store.js";import{BoundRefusal as i}from"./refusals.js";async function Se(e){try{if(!e||typeof e.place!="string"||!e.place||!e.instrument?.runtime)throw new i("host/context","REFUSE\xB7host/context");const t={...e.limits};for(const n of[t.bytes,t.files,t.readings,t.probes])if(!Number.isSafeInteger(n)||n<1)throw new i("host/budget","REFUSE\xB7host/budget");if(t.signal?.aborted)throw new i("host/cancelled","REFUSE\xB7host/cancelled");const d=U(e.place),r=N(d),s=structuredClone(e.instrument),a=e.reader;return await k({instrumentName:s.name,runtime:s.runtime,output:c(()=>{},"output")},()=>X(r,()=>Q(r,"prepare reading identity",()=>{const n=S(h(d));for(const u of["bytes","files","readings","probes"])t[u]=Math.min(t[u],n[u]);return{kind:"fact",preparations:T(d,r,t,a)}}),()=>h(d)))}catch(t){return{kind:"refuse",code:t instanceof i?t.code:"reading-identity/failed",diagnostic:t instanceof Error?t.message:"REFUSE\xB7reading identity failed"}}}c(Se,"prepareNativeReadingIdentity");function S(e){const t=c(d=>{const r=e.filter(n=>y(n,"scope")==="reading-identity/"+d&&y(n,"role")==="writes"&&y(n,"value")!=="withdraw");if(r.length!==1)throw new i("reading-identity/budget","REFUSE\xB7reading identity requires one declared "+d+" limit");const s=/^0\.\.([1-9][0-9]*)$/.exec(y(r[0],"value")),a=Number(s?.[1]);if(!s||!Number.isSafeInteger(a))throw new i("reading-identity/budget","REFUSE\xB7invalid reading identity "+d+" limit");return a},"limit");return{bytes:t("bytes"),files:t("files"),readings:t("readings"),probes:t("probes")}}c(S,"declaredReadingIdentityLimits");function be(e){const t=Y(e&&{place:e.place,instrument:e.instrument,views:[e.view],...e.expectedIdentity===void 0?{}:{expectedIdentities:{[e.view]:e.expectedIdentity}}});return t.kind==="refuse"?t:t.views[0]}c(be,"prepareNativeViewIdentity");function Y(e){try{if(!e||!e.instrument?.runtime||typeof e.place!="string"||!e.place)throw new i("host/context","REFUSE\xB7host/context");if(!Array.isArray(e.views)||!e.views.length||new Set(e.views).size!==e.views.length||e.views.some(n=>n!=="lines"&&n!=="evidence"))throw new i("reading-identity/selection","REFUSE\xB7reading-identity/selection requires distinct supported native views");if(e.expectedIdentities&&Object.keys(e.expectedIdentities).some(n=>!e.views.includes(n)))throw new i("reading-identity/selection","REFUSE\xB7reading-identity/selection expected identity names an unselected view");const t=[...e.views],d={...e.expectedIdentities},r=U(e.place),s=N(r),a=structuredClone(e.instrument);return k({instrumentName:a.name,runtime:a.runtime,output:c(()=>{},"output")},()=>K(()=>{const n=I(O(s)),p=S(h(r)),u=new Date().toISOString().slice(0,10),b=F(w);if(t.length>p.readings)throw new i("reading-identity/budget","REFUSE\xB7reading-identity/budget selected views exceed admitted readings");const L=D(()=>{const o=_(r).standing,m=[...M(s,a.runtime.entry,[],a.runtime.root,[],!0)].map(([g,v])=>[g,v]);if(!m.length)throw new i("reading-identity/failed","REFUSE\xB7reading-identity/failed is unavailable");const f=w(E("instrument-lock:"+a.runtime.root,()=>j(x(a.runtime.root,G),"utf8")));return{standing:o,implementation:m,instrumentLock:f}}),C=B(()=>z(s,()=>t.map(o=>{const m=q(p,()=>{const f=S(E("authenticated-configuration:"+r,()=>h(r)));if(JSON.stringify(f)!==JSON.stringify(p))throw new i("reading-identity/context","REFUSE\xB7reading-identity/context identity budget changed");if(o==="evidence"&&E("foreign-ingress:"+s,()=>H(s)).length)throw new i("reading-identity/selection","REFUSE\xB7reading-identity/selection foreign view identity requires a transport snapshot");const{standing:g,implementation:v,instrumentLock:J}=L();if(o==="evidence"){const l=W(g).get(o);if(!l||l.shape||l.regions.length!==1||l.regions[0]?.name!=="evidence")throw new i("reading-identity/selection","REFUSE\xB7reading-identity/selection requires the native evidence projection")}const R=o==="lines"?g.filter(P):$(r,s);return{text:R.length?R.join(`
2
2
  `)+`
3
- `:"",implementation:S,instrumentLock:u(y("instrument-lock:"+o.runtime.root,()=>J(H(o.runtime.root,M),"utf8")))}})),N=R(F(r));if(d!==N||l!==new Date().toISOString().slice(0,10)||JSON.stringify(m)!==JSON.stringify(b(u)))throw new n("reading-identity/context","REFUSE\xB7reading-identity/context committed inputs changed during preparation");const h=u(JSON.stringify(["native-view-inputs@1",i,e,d,f.inputs,f.value.implementation,f.value.instrumentLock,m,l]));if(t.expectedIdentity!==void 0&&t.expectedIdentity!==h)throw new n("reading-identity/context","REFUSE\xB7reading-identity/context view identity differs from the expected snapshot");return{kind:"fact",view:e,identity:h,text:f.value.text}}))}catch(e){return{kind:"refuse",code:e instanceof n?e.code:"reading-identity/failed",diagnostic:e instanceof Error?e.message:"REFUSE\xB7view identity failed"}}}a(le,"prepareNativeViewIdentity");export{w as declaredReadingIdentityLimits,ge as prepareNativeReadingIdentity,le as prepareNativeViewIdentity};
3
+ `:"",implementation:v,instrumentLock:J}});return{view:o,captured:m}}))),A=I(O(s));if(n!==A||u!==new Date().toISOString().slice(0,10)||JSON.stringify(b)!==JSON.stringify(F(w)))throw new i("reading-identity/context","REFUSE\xB7reading-identity/context committed inputs changed during preparation");return{kind:"fact",views:C.map(({view:o,captured:m})=>{const f=w(JSON.stringify(["native-view-inputs@1",r,o,n,m.inputs,m.value.implementation,m.value.instrumentLock,b,u]));if(d[o]!==void 0&&d[o]!==f)throw new i("reading-identity/context","REFUSE\xB7reading-identity/context view identity differs from the expected snapshot");return{kind:"fact",view:o,identity:f,text:m.value.text}})}}))}catch(t){return{kind:"refuse",code:t instanceof i?t.code:"reading-identity/failed",diagnostic:t instanceof Error?t.message:"REFUSE\xB7view identity failed"}}}c(Y,"prepareNativeViewIdentities");export{S as declaredReadingIdentityLimits,Se as prepareNativeReadingIdentity,Y as prepareNativeViewIdentities,be as prepareNativeViewIdentity};
@@ -1,4 +1,4 @@
1
- var ae=Object.defineProperty;var d=(t,r)=>ae(t,"name",{value:r,configurable:!0});import{mkdirSync as ce,readFileSync as T,existsSync as $}from"node:fs";import{join as W,dirname as de}from"node:path";import{library11_canonical as j,library11_parse as le,library11_PROTOCOL as ue,library11_byBytes as fe}from"../vendor/runtime.js";import{replaceWhole as pe,shardLines as he}from"../land/ledger.js";import{fieldOf as g}from"../fold/claims.js";import{library2_readingIdentityBytes as O,library2_readingReceiptIdentity as ge,library2_responseIdentity as ye,library2_snapshotAccess as me,library2_placeInputs as Ee,library2_withPlaceInputs as we}from"../vendor/runtime.js";import{withReadingBoundary as be}from"./reading-context.js";import{BoundRefusal as y}from"./refusals.js";class ee extends Error{static{d(this,"ReadingNeeds")}constructor(r){super("Reading inputs missing"),this.coordinates=r}}const te=d(t=>t.reduce((r,m)=>r+Buffer.byteLength(m.text,"utf8"),0),"filesBytes"),q=d(t=>{const r=le(t);if(r.kind!=="fact")throw Error("REFUSE\xB7input projection contains a non-wire line");return r.value.fields},"readingFields"),xe=d(t=>t.map(r=>j({scope:r.place,form:"alphabet",measure:"text",role:"writes",value:"lock",shape:r.place,about:r.text,by:"host",at:"policy:handed-input"})),"inputLines");function Se(t){const r=t.preparationLimits;if(r){for(const e of[r.bytes,r.files,r.readings,r.probes])if(!Number.isSafeInteger(e)||e<1)throw new y("host/budget","REFUSE\xB7host/budget");if(te(t.files)>r.bytes||t.files.length>r.files||r.probes<1)throw new y("host/budget","REFUSE\xB7host/budget")}const{root:m,store:b,speaker:S,digest:s,capsule:f,region:E,projection:h,files:w}=t;t.assertCurrent?.(),t.context&&O(t.context);let z=[];if(t.current){if(!t.context)throw Error("REFUSE\xB7current reading requires a declared identity");const{snapshot:e,kept:n,current:i,permission:o}=t.current;if(i.implementation!==t.context.implementation)throw Error("REFUSE\xB7current reading implementation differs from its verified context");const a=ye(e,i,s),u=me(e,n,i,o,s);if(!u.inspect||!u.reuse)throw Error("REFUSE\xB7current reading is not admitted for reuse");z=[["response",a],["permission",s(JSON.stringify([o.inspect,o.reuse,o.freshness]))]]}if(t.execution&&(!t.context||JSON.stringify(O(t.execution.context))!==JSON.stringify(O(t.context))))throw Error("REFUSE\xB7reading execution differs from declared context");const A=d(e=>{if(!f.selectedWorld)return;const{standing:n,offer:i}=f.selectedWorld;if(n.parts.some(a=>a.scope===`${i}/place-inputs/${e}`&&a.measure==="reads")){if(!t.context||!t.execution||!t.livePlace)throw Error("REFUSE\xB7place inputs require authenticated shadow and reading context "+e);return Ee(n,i,e,t.livePlace(),a=>s(new TextDecoder().decode(a)))}},"projectionFor"),k=A(h),D=A(E),M=d((e,n,i)=>i&&e?we(e,JSON.stringify(["place-inputs",f.selectedWorld.offer,n]),i):e,"commit"),G=d((e,n,i=t.context)=>be(e,t.execution&&i?{...t.execution,context:i}:t.execution,()=>f.ask(n,t.readerReference)),"ask"),N=M(t.context,h,k),re=N?s(new TextDecoder().decode(O(N))):"",ne=s("").split(":")[0],R=new Map(w.map(e=>[e.place,e.text]));if(R.size!==w.length)throw Error("REFUSE\xB7input projection has duplicate handed coordinates");const I=d(()=>{if(r?.signal?.aborted)throw new y("host/cancelled","REFUSE\xB7host/cancelled");for(const e of w){if(!$(W(m,e.place)))throw new ee([e.place]);if(!T(W(m,e.place)).equals(Buffer.from(e.text)))throw new y("reading-identity/integrity","REFUSE\xB7input changed "+e.place)}},"verify");if(I(),r?.signal?.aborted)throw new y("host/cancelled","REFUSE\xB7host/cancelled");const F=G(re,[{...k?{place:k}:{},protocol:ue,verb:"render",rootScope:"",region:h,at:1,reads:["**"],lines:xe(w),files:[]}],N)[0];if(F?.kind!=="fact"||!Array.isArray(F.lines))throw Error("REFUSE\xB7input projection "+(F?.why??"no lines"));if(r&&F.lines.length>r.readings)throw new y("host/budget","REFUSE\xB7host/budget");const v=new Map;for(const e of F.lines){const n=q(e),i=n.scope??"",o=/^receipt:(\d+)$/.exec(n.at??"");if(!i||v.has(i)||n.form!=="alphabet"||n.measure!=="reads"||n.role!=="reads"||!o)throw Error("REFUSE\xB7input projection ambiguous reading "+i);const a=(n.value??"").split("|").filter(Boolean),u=(n.needs??"").split("|").filter(Boolean);if(!a.length&&!u.length||new Set(a).size!==a.length||a.some(x=>!R.has(x))||new Set(u).size!==u.length)throw Error("REFUSE\xB7input projection has unhanded or duplicate dependencies "+i);const p=Number(o[1]);if(!Number.isSafeInteger(p))throw Error("REFUSE\xB7input projection invalid resolution "+i);v.set(i,{scope:i,inputs:a,needs:u,resolution:p,line:j({scope:i,form:n.form,measure:n.measure,role:n.role,value:a.join("|"),needs:u.join("|"),at:n.at})})}if(!v.size)throw Error("REFUSE\xB7input projection returned no readings");const H=[],J=new Set,K=new Set,Q=d(e=>{if(K.has(e))return;if(J.has(e))throw Error("REFUSE\xB7input projection dependency cycle "+e);const n=v.get(e);if(!n)throw Error("REFUSE\xB7input projection missing reading "+e);J.add(e);for(const i of n.needs)Q(i);J.delete(e),K.add(e),H.push(n)},"visit");for(const e of v.keys())Q(e);const B=s([f.selection??"",f.digest,E,h,...t.lifetime===void 0?[]:[JSON.stringify(t.lifetime)]].join(`
1
+ var ae=Object.defineProperty;var d=(t,r)=>ae(t,"name",{value:r,configurable:!0});import{mkdirSync as ce,readFileSync as T,existsSync as $}from"node:fs";import{join as W,dirname as de}from"node:path";import{library14_canonical as j,library14_parse as le,library14_PROTOCOL as ue,library14_byBytes as fe}from"../vendor/runtime.js";import{replaceWhole as pe,shardLines as he}from"../land/ledger.js";import{fieldOf as g}from"../fold/claims.js";import{library5_readingIdentityBytes as O,library5_readingReceiptIdentity as ge,library5_responseIdentity as ye,library5_snapshotAccess as me,library5_placeInputs as Ee,library5_withPlaceInputs as we}from"../vendor/runtime.js";import{withReadingBoundary as be}from"./reading-context.js";import{BoundRefusal as y}from"./refusals.js";class ee extends Error{static{d(this,"ReadingNeeds")}constructor(r){super("Reading inputs missing"),this.coordinates=r}}const te=d(t=>t.reduce((r,m)=>r+Buffer.byteLength(m.text,"utf8"),0),"filesBytes"),q=d(t=>{const r=le(t);if(r.kind!=="fact")throw Error("REFUSE\xB7input projection contains a non-wire line");return r.value.fields},"readingFields"),xe=d(t=>t.map(r=>j({scope:r.place,form:"alphabet",measure:"text",role:"writes",value:"lock",shape:r.place,about:r.text,by:"host",at:"policy:handed-input"})),"inputLines");function Se(t){const r=t.preparationLimits;if(r){for(const e of[r.bytes,r.files,r.readings,r.probes])if(!Number.isSafeInteger(e)||e<1)throw new y("host/budget","REFUSE\xB7host/budget");if(te(t.files)>r.bytes||t.files.length>r.files||r.probes<1)throw new y("host/budget","REFUSE\xB7host/budget")}const{root:m,store:b,speaker:S,digest:s,capsule:f,region:E,projection:h,files:w}=t;t.assertCurrent?.(),t.context&&O(t.context);let z=[];if(t.current){if(!t.context)throw Error("REFUSE\xB7current reading requires a declared identity");const{snapshot:e,kept:n,current:i,permission:o}=t.current;if(i.implementation!==t.context.implementation)throw Error("REFUSE\xB7current reading implementation differs from its verified context");const a=ye(e,i,s),u=me(e,n,i,o,s);if(!u.inspect||!u.reuse)throw Error("REFUSE\xB7current reading is not admitted for reuse");z=[["response",a],["permission",s(JSON.stringify([o.inspect,o.reuse,o.freshness]))]]}if(t.execution&&(!t.context||JSON.stringify(O(t.execution.context))!==JSON.stringify(O(t.context))))throw Error("REFUSE\xB7reading execution differs from declared context");const A=d(e=>{if(!f.selectedWorld)return;const{standing:n,offer:i}=f.selectedWorld;if(n.parts.some(a=>a.scope===`${i}/place-inputs/${e}`&&a.measure==="reads")){if(!t.context||!t.execution||!t.livePlace)throw Error("REFUSE\xB7place inputs require authenticated shadow and reading context "+e);return Ee(n,i,e,t.livePlace(),a=>s(new TextDecoder().decode(a)))}},"projectionFor"),k=A(h),D=A(E),M=d((e,n,i)=>i&&e?we(e,JSON.stringify(["place-inputs",f.selectedWorld.offer,n]),i):e,"commit"),G=d((e,n,i=t.context)=>be(e,t.execution&&i?{...t.execution,context:i}:t.execution,()=>f.ask(n,t.readerReference)),"ask"),N=M(t.context,h,k),re=N?s(new TextDecoder().decode(O(N))):"",ne=s("").split(":")[0],R=new Map(w.map(e=>[e.place,e.text]));if(R.size!==w.length)throw Error("REFUSE\xB7input projection has duplicate handed coordinates");const I=d(()=>{if(r?.signal?.aborted)throw new y("host/cancelled","REFUSE\xB7host/cancelled");for(const e of w){if(!$(W(m,e.place)))throw new ee([e.place]);if(!T(W(m,e.place)).equals(Buffer.from(e.text)))throw new y("reading-identity/integrity","REFUSE\xB7input changed "+e.place)}},"verify");if(I(),r?.signal?.aborted)throw new y("host/cancelled","REFUSE\xB7host/cancelled");const F=G(re,[{...k?{place:k}:{},protocol:ue,verb:"render",rootScope:"",region:h,at:1,reads:["**"],lines:xe(w),files:[]}],N)[0];if(F?.kind!=="fact"||!Array.isArray(F.lines))throw Error("REFUSE\xB7input projection "+(F?.why??"no lines"));if(r&&F.lines.length>r.readings)throw new y("host/budget","REFUSE\xB7host/budget");const v=new Map;for(const e of F.lines){const n=q(e),i=n.scope??"",o=/^receipt:(\d+)$/.exec(n.at??"");if(!i||v.has(i)||n.form!=="alphabet"||n.measure!=="reads"||n.role!=="reads"||!o)throw Error("REFUSE\xB7input projection ambiguous reading "+i);const a=(n.value??"").split("|").filter(Boolean),u=(n.needs??"").split("|").filter(Boolean);if(!a.length&&!u.length||new Set(a).size!==a.length||a.some(x=>!R.has(x))||new Set(u).size!==u.length)throw Error("REFUSE\xB7input projection has unhanded or duplicate dependencies "+i);const p=Number(o[1]);if(!Number.isSafeInteger(p))throw Error("REFUSE\xB7input projection invalid resolution "+i);v.set(i,{scope:i,inputs:a,needs:u,resolution:p,line:j({scope:i,form:n.form,measure:n.measure,role:n.role,value:a.join("|"),needs:u.join("|"),at:n.at})})}if(!v.size)throw Error("REFUSE\xB7input projection returned no readings");const H=[],J=new Set,K=new Set,Q=d(e=>{if(K.has(e))return;if(J.has(e))throw Error("REFUSE\xB7input projection dependency cycle "+e);const n=v.get(e);if(!n)throw Error("REFUSE\xB7input projection missing reading "+e);J.add(e);for(const i of n.needs)Q(i);J.delete(e),K.add(e),H.push(n)},"visit");for(const e of v.keys())Q(e);const B=s([f.selection??"",f.digest,E,h,...t.lifetime===void 0?[]:[JSON.stringify(t.lifetime)]].join(`
2
2
  `)),_=S+":"+B.split(":")[1].slice(0,12),V="reading-closures/"+B.split(":")[1],P=he(b,S,V),X=d(e=>W(b,"cas","carried",e.split(":")[1]??""),"carried"),ie=d(e=>{const n=s(e),i=X(n);return ce(de(i),{recursive:!0}),(!$(i)||s(T(i,"utf8"))!==n)&&pe(i,e),n},"saved"),C=d((e,n=!1)=>{if(!e.startsWith(ne+":")||!/^[a-f0-9]+$/.test(e.split(":")[1]??""))return;const i=X(e);if(!$(i))return;const o=T(i,"utf8");if(s(o)!==e){if(n)throw new y("reading-identity/integrity","REFUSE\xB7reading carrier bytes differ");return}return o},"load"),se=d((e,n)=>{const i=[e.line,j({scope:"implementation",role:"writes",form:"alphabet",measure:"digest",value:B,by:"host",at:"policy:input-identity"}),...e.inputs.map(c=>j({scope:c,role:"writes",form:"alphabet",measure:"digest",value:s(R.get(c)),by:"host",at:"policy:input-identity"})),...e.needs.map(c=>j({scope:c,role:"writes",form:"alphabet",measure:"digest",value:n.get(c).digest,by:"host",at:"policy:input-identity"}))].sort(fe).join(`
3
3
  `)+`
4
4
  `,o=M(t.context,E,D),a=o&&{...o,policy:s(JSON.stringify([o.policy,t.allowsEmpty===!0,t.lifetime??null,t.readerReference??null,f.selection??null,f.lines])),inputs:[...[...o.inputs,...z].map(([c,U])=>[JSON.stringify(["context",c]),U]),[JSON.stringify(["plan"]),s(e.line)],...e.inputs.map(c=>[JSON.stringify(["file",c]),s(R.get(c))]),...e.needs.map(c=>[JSON.stringify(["receipt",c]),n.get(c).digest])]},u=a?new TextDecoder().decode(O(a)):i,p=s(u),x="receipts/readings/"+s(e.scope).split(":")[1]+"/"+p.split(":")[1];return{context:a,closure:u,input:p,scope:x}},"prepare"),oe=d((e,n=!1)=>{const{scope:i,input:o,closure:a}=e,p=P.filter(l=>g(l,"scope")===i&&g(l,"measure")==="bytes"&&g(l,"value")===o).at(-1)&&P.filter(l=>g(l,"scope")===i&&g(l,"measure")==="count"&&g(l,"by")===_).at(-1),x=p&&C(g(p,"at").replace(/^place:/,""),n),c=x?.split(`
@@ -1 +1 @@
1
- export {public4_BoundRefusal as BoundRefusal,public4_ContentReadPort as ContentReadPort,public4_DigestPort as DigestPort,public4_PersistencePort as PersistencePort,public4_PortLimits as PortLimits,public4_ReferenceTrust as ReferenceTrust,public4_RefusalEntry as RefusalEntry,public4_SignatureRecord as SignatureRecord,public4_SigningLot as SigningLot,public4_SigningPort as SigningPort,public4_decodeReference as decodeReference,public4_describeRefusal as describeRefusal,public4_encodeReference as encodeReference,public4_inspectAuthenticatedReference as inspectAuthenticatedReference,public4_invokeSigningPort as invokeSigningPort,public4_readContent as readContent,public4_readRefusalCatalog as readRefusalCatalog,public4_retainContent as retainContent} from "../public-types.js";
1
+ export {public7_BoundRefusal as BoundRefusal,public7_ContentReadPort as ContentReadPort,public7_DigestPort as DigestPort,public7_PersistencePort as PersistencePort,public7_PortLimits as PortLimits,public7_ReferenceTrust as ReferenceTrust,public7_RefusalEntry as RefusalEntry,public7_SignatureRecord as SignatureRecord,public7_SigningLot as SigningLot,public7_SigningPort as SigningPort,public7_decodeReference as decodeReference,public7_describeRefusal as describeRefusal,public7_encodeReference as encodeReference,public7_inspectAuthenticatedReference as inspectAuthenticatedReference,public7_invokeSigningPort as invokeSigningPort,public7_readContent as readContent,public7_readRefusalCatalog as readRefusalCatalog,public7_retainContent as retainContent} from "../public-types.js";
@@ -1,3 +1,3 @@
1
- var _=Object.defineProperty;var s=(r,e)=>_(r,"name",{value:e,configurable:!0});import{BoundRefusal as A}from"./refusals.js";import{library11_parse as J,library11_canonical as C,library11_authorityOf as O,library11_authorityAtEpoch as U,library11_signedBytes as j,library11_objectHistory as F,library11_validateObjectContext as T}from"../vendor/runtime.js";import{decodeReference as H}from"./reference-profile.js";import{referenceStanding as K,referenceContracts as L,referenceContextBytes as q}from"./reference-standing.js";function t(r,e){throw new A("authenticated-reference/"+r,"REFUSE\xB7authenticated-reference "+e)}s(t,"fail");const b=s(r=>new TextEncoder().encode(r),"utf8");async function Q(r,e){new Set(e.signers.map(i=>i.id)).size!==e.signers.length&&t("context","duplicate host signer");const f=H(r);(!Number.isSafeInteger(e.maxBytes)||e.maxBytes<1||!Number.isSafeInteger(e.maxRecords)||e.maxRecords<1)&&t("budget","resource budget"),e.contracts!==void 0&&(L(e.contracts)||t("context","contract identities"),await e.digestBytes(q({...e,semanticIdentity:"sha256:"+f.digest,contracts:e.contracts}))!==e.snapshot&&t("context","context snapshot"));let d;try{d=await e.fetchBytes(f.source,f.blob)}catch{return t("transport","content port failed")}d.byteLength>e.maxBytes&&t("budget","bytes budget"),typeof SharedArrayBuffer<"u"&&d.buffer instanceof SharedArrayBuffer&&t("transport","shared transport bytes");const w=new Uint8Array(d);await e.digestBytes(w)!==f.blob&&t("integrity","blob integrity");let p;try{p=new TextDecoder("utf-8",{fatal:!0}).decode(w)}catch{return t("framing","carrier UTF-8")}let o;try{o=JSON.parse(p)}catch{t("framing","carrier framing")}(!Array.isArray(o)||o.length!==3||o[0]!=="authenticated-standing@1"||!Array.isArray(o[1])||o[1].length<1||o[1].length>e.maxRecords||o[1].some(i=>typeof i!="string")||typeof o[2]!="string"||JSON.stringify(o)+`
1
+ var _=Object.defineProperty;var s=(r,e)=>_(r,"name",{value:e,configurable:!0});import{BoundRefusal as A}from"./refusals.js";import{library14_parse as J,library14_canonical as C,library14_authorityOf as O,library14_authorityAtEpoch as U,library14_signedBytes as j,library14_objectHistory as F,library14_validateObjectContext as T}from"../vendor/runtime.js";import{decodeReference as H}from"./reference-profile.js";import{referenceStanding as K,referenceContracts as L,referenceContextBytes as q}from"./reference-standing.js";function t(r,e){throw new A("authenticated-reference/"+r,"REFUSE\xB7authenticated-reference "+e)}s(t,"fail");const b=s(r=>new TextEncoder().encode(r),"utf8");async function Q(r,e){new Set(e.signers.map(i=>i.id)).size!==e.signers.length&&t("context","duplicate host signer");const f=H(r);(!Number.isSafeInteger(e.maxBytes)||e.maxBytes<1||!Number.isSafeInteger(e.maxRecords)||e.maxRecords<1)&&t("budget","resource budget"),e.contracts!==void 0&&(L(e.contracts)||t("context","contract identities"),await e.digestBytes(q({...e,semanticIdentity:"sha256:"+f.digest,contracts:e.contracts}))!==e.snapshot&&t("context","context snapshot"));let d;try{d=await e.fetchBytes(f.source,f.blob)}catch{return t("transport","content port failed")}d.byteLength>e.maxBytes&&t("budget","bytes budget"),typeof SharedArrayBuffer<"u"&&d.buffer instanceof SharedArrayBuffer&&t("transport","shared transport bytes");const w=new Uint8Array(d);await e.digestBytes(w)!==f.blob&&t("integrity","blob integrity");let p;try{p=new TextDecoder("utf-8",{fatal:!0}).decode(w)}catch{return t("framing","carrier UTF-8")}let o;try{o=JSON.parse(p)}catch{t("framing","carrier framing")}(!Array.isArray(o)||o.length!==3||o[0]!=="authenticated-standing@1"||!Array.isArray(o[1])||o[1].length<1||o[1].length>e.maxRecords||o[1].some(i=>typeof i!="string")||typeof o[2]!="string"||JSON.stringify(o)+`
2
2
  `!==p)&&t("framing","carrier framing");const c=o[1],E=o[2],y=[...c,E].map(i=>{const n=J(i);return(n.kind!=="fact"||C(n.value.fields)!==i)&&t("wire","original canonical"),n.value.fields}),a=y[y.length-1];(a.scope!==e.proofScope||a.at!=="witness:"+e.snapshot||a.role!=="writes"||a.form!=="alphabet"||a.measure!=="digest"||a.epoch!==String(e.epoch))&&t("context","untrusted snapshot binding"),a.value!==await e.digestBytes(b(JSON.stringify(["authenticated-standing@1",c])+`
3
3
  `))&&t("integrity","snapshot commitment");const x=new Set,S=s((i,n)=>JSON.stringify([j(i),n,i.sig,e.algorithms]),"key");for(const i of y)for(const n of e.signers)n.id===i.by&&await e.verifyBytes(j(i),n.publicKey,i.sig,e.algorithms)&&x.add(S(i,n.publicKey));const B=s((i,n)=>x.has(S(i,n)),"verifies"),l=O(a,e.signers,B);l.kind!=="admitted"&&t("authority","proof "+l.kind+" "+l.why);const u=e.signers.find(i=>i.id===a.by);u||t("authority","proof signer");const m=U(a,u,e.epoch,e.proofScope,"authority");m.kind!=="admitted"&&t("authority","current proof "+m.kind+" "+m.why);const v=new Set;for(let i=0;i<c.length;i++){const n=O(y[i],e.signers,B);n.kind!=="admitted"&&t("authority","original "+n.kind+" "+n.why),v.add(c[i])}const g=F(c);g.kind!=="fact"&&t("wire","wire "+g.why),g.value.configuration.some(i=>i.value==="withdraw")&&t("history","configuration history requires admitted standing fold");const I={...e.objects,admit:s(i=>v.has(C(i.fields))&&e.objects.admit(i),"admit")},h=T(g.value.objects,I);if(h.kind!=="fact")throw new A("authenticated-reference/object-context","REFUSE\xB7"+h.why);const R=K(c,h.value),k=await e.digestBytes(b(R));k!=="sha256:"+f.digest&&t("identity","standing identity");const N=await e.digestBytes(b(JSON.stringify(e.contracts?["reference-inspection-trust@2",e.snapshot,e.epoch,e.proofScope,e.policy,e.formImplementation,e.signers,e.algorithms,e.contracts]:["reference-inspection-trust@1",e.snapshot,e.epoch,e.proofScope,e.policy,e.formImplementation,e.signers,e.algorithms])));return{reference:f,records:h.value,semanticIdentity:k,authorityContextIdentity:N,semanticStanding:R,originalRecords:c,...e.contracts?{contracts:{...e.contracts}}:{}}}s(Q,"inspectAuthenticatedReference");import{encodeReference as X,decodeReference as Y}from"./reference-profile.js";import{BoundRefusal as $,readRefusalCatalog as ee,describeRefusal as ie}from"./refusals.js";import{readContent as ne,retainContent as oe,invokeSigningPort as ae}from"../engine/ports.js";export{$ as BoundRefusal,Y as decodeReference,ie as describeRefusal,X as encodeReference,Q as inspectAuthenticatedReference,ae as invokeSigningPort,ne as readContent,ee as readRefusalCatalog,oe as retainContent};
@@ -1,4 +1,4 @@
1
- var M=Object.defineProperty;var m=(t,a)=>M(t,"name",{value:a,configurable:!0});import{installedReferenceContracts as T}from"./reference-contracts.js";import{BoundRefusal as _,describeRefusal as X,readRefusalCatalog as q}from"./refusals.js";import{readFileSync as z}from"node:fs";import{library11_authorityAtEpoch as D,library11_canonical as J,library11_parse as P}from"../vendor/runtime.js";import{sha256 as x}from"./hash.js";import{signerFor as Q}from"./signing.js";import{signConsentLot as V}from"../land/sign.js";import{underRootAuthority as W}from"../land/act.js";import{storeOf as Y}from"../land/ledger.js";import{authorityFor as Z,rootSigner as ee}from"../fold/signers.js";import{admissionAnchor as te,admissionHistoryAt as re}from"../fold/admission-history.js";import{authenticatedRootStanding as ne}from"./admitted-place.js";import{eraOf as oe}from"../fold/digests.js";import{epochOf as ie}from"../cli/owner.js";import{fieldOf as i}from"../fold/claims.js";import{prepareNativeReference as ae}from"./reference-native.js";import{referenceContextBytes as se,referenceContracts as ce,referenceStanding as fe}from"./reference-standing.js";import{encodeReference as U}from"./reference-profile.js";const me=m(()=>z(new URL("../../docs/contracts/refusals.bound",import.meta.url),"utf8"),"catalog");import{BoundRefusal as _e}from"./refusals.js";function e(t){const a=new _("reference-export/"+t,"REFUSE\xB7reference-export/"+t),r=X(a,q(me()));throw new _(r.code,"REFUSE\xB7"+r.code+" "+r.meaning)}m(e,"fail");async function Ie(t,a,r={}){try{U({class:"standing",algorithm:"sha256",digest:"0".repeat(64),blob:"sha256:"+"0".repeat(64),source:a})}catch{e("source")}return W(Y(t),"reference export",async()=>{const A=re(t,Number.MAX_SAFE_INTEGER),d=ne(t),l=ie(A),u=oe(d),p=Z(A,te(t),u.admitted),s=m((o,H="id",K="alphabet")=>{const f=d.filter(L=>i(L,"scope")===o&&i(L,"value")!=="withdraw");return(f.length!==1||i(f[0],"role")!=="writes"||i(f[0],"measure")!==H||i(f[0],"form")!==K||p.of(f[0]).kind!=="admitted")&&e("context"),i(f[0],"value")},"one");s("reference/authentication")!=="authenticated-standing@1"&&e("context");const R=s("reference/proof-scope"),g={refusals:s("reference/contracts/refusals"),standing:s("reference/contracts/standing")},O=T();(!ce(g)||g.refusals!==O.refusals||g.standing!==O.standing)&&e("context");const B=s("reference/records"),h=Number(B),c=/^(0|[1-9][0-9]*)\.\.(0|[1-9][0-9]*)$/.exec(s("reference/export-bytes","bytes","interval"));(!/^(0|[1-9][0-9]*)$/.test(B)||!Number.isSafeInteger(h)||h<1||!c||Number(c[1])>Number(c[2])||!Number.isSafeInteger(Number(c[2]))||Number(c[2])<1)&&e("budget");const y=Number(c[2]),n=d.filter(o=>i(o,"value")!=="withdraw"||i(o,"type")!=="");(!n.length||n.length>h||Buffer.byteLength(n.join(`
1
+ var M=Object.defineProperty;var m=(t,a)=>M(t,"name",{value:a,configurable:!0});import{installedReferenceContracts as T}from"./reference-contracts.js";import{BoundRefusal as _,describeRefusal as X,readRefusalCatalog as q}from"./refusals.js";import{readFileSync as z}from"node:fs";import{library14_authorityAtEpoch as D,library14_canonical as J,library14_parse as P}from"../vendor/runtime.js";import{sha256 as x}from"./hash.js";import{signerFor as Q}from"./signing.js";import{signConsentLot as V}from"../land/sign.js";import{underRootAuthority as W}from"../land/act.js";import{storeOf as Y}from"../land/ledger.js";import{authorityFor as Z,rootSigner as ee}from"../fold/signers.js";import{admissionAnchor as te,admissionHistoryAt as re}from"../fold/admission-history.js";import{authenticatedRootStanding as ne}from"./admitted-place.js";import{eraOf as oe}from"../fold/digests.js";import{epochOf as ie}from"../cli/owner.js";import{fieldOf as i}from"../fold/claims.js";import{prepareNativeReference as ae}from"./reference-native.js";import{referenceContextBytes as se,referenceContracts as ce,referenceStanding as fe}from"./reference-standing.js";import{encodeReference as U}from"./reference-profile.js";const me=m(()=>z(new URL("../../docs/contracts/refusals.bound",import.meta.url),"utf8"),"catalog");import{BoundRefusal as _e}from"./refusals.js";function e(t){const a=new _("reference-export/"+t,"REFUSE\xB7reference-export/"+t),r=X(a,q(me()));throw new _(r.code,"REFUSE\xB7"+r.code+" "+r.meaning)}m(e,"fail");async function Ie(t,a,r={}){try{U({class:"standing",algorithm:"sha256",digest:"0".repeat(64),blob:"sha256:"+"0".repeat(64),source:a})}catch{e("source")}return W(Y(t),"reference export",async()=>{const A=re(t,Number.MAX_SAFE_INTEGER),d=ne(t),l=ie(A),u=oe(d),p=Z(A,te(t),u.admitted),s=m((o,H="id",K="alphabet")=>{const f=d.filter(L=>i(L,"scope")===o&&i(L,"value")!=="withdraw");return(f.length!==1||i(f[0],"role")!=="writes"||i(f[0],"measure")!==H||i(f[0],"form")!==K||p.of(f[0]).kind!=="admitted")&&e("context"),i(f[0],"value")},"one");s("reference/authentication")!=="authenticated-standing@1"&&e("context");const R=s("reference/proof-scope"),g={refusals:s("reference/contracts/refusals"),standing:s("reference/contracts/standing")},O=T();(!ce(g)||g.refusals!==O.refusals||g.standing!==O.standing)&&e("context");const B=s("reference/records"),h=Number(B),c=/^(0|[1-9][0-9]*)\.\.(0|[1-9][0-9]*)$/.exec(s("reference/export-bytes","bytes","interval"));(!/^(0|[1-9][0-9]*)$/.test(B)||!Number.isSafeInteger(h)||h<1||!c||Number(c[1])>Number(c[2])||!Number.isSafeInteger(Number(c[2]))||Number(c[2])<1)&&e("budget");const y=Number(c[2]),n=d.filter(o=>i(o,"value")!=="withdraw"||i(o,"type")!=="");(!n.length||n.length>h||Buffer.byteLength(n.join(`
2
2
  `))>y)&&e("budget"),n.some(o=>p.of(o).kind!=="admitted")&&e("history");const b=r.key??ee(t).id,S=p.admitted.find(o=>o.id===b),$=J({scope:R,role:"writes",form:"alphabet",measure:"digest",value:x(JSON.stringify(["authenticated-standing@1",n])+`
3
3
  `),by:"target",at:"witness:sha256:"+"0".repeat(64)}),w=P($);(!S||w.kind!=="fact"||D({...w.value.fields,by:b,epoch:String(l)},S,l,R,"authority").kind!=="admitted")&&e("authority");const N=await ae(t),j=fe(n,N.records),F=x(j),E={profile:"reference-export-context@1",semanticIdentity:F,epoch:l,proofScope:R,policy:N.policy,formImplementation:N.formImplementation,signers:p.admitted,algorithms:u.admitted,contracts:g,maxBytes:y,maxRecords:h},k=x(se(E));Buffer.byteLength(JSON.stringify({originals:n,context:E,snapshot:k})+`
4
4
  `)>y&&e("budget");const G=J({...w.value.fields,at:"witness:"+k});let v;try{v=await V([G],{epoch:l,by:b,algorithm:u.era},S.publicKey,u.admitted,Q(d,b,r.signer,r.keyFile,r.hostSigner))}catch{e("signer")}v.kind!=="fact"&&e("signer");const I=JSON.stringify(["authenticated-standing@1",n,v.lines[0]])+`
@@ -1 +1 @@
1
- export {public5_exportAuthenticatedReference as exportAuthenticatedReference,public5_inspectReference as inspectReference,public5_openAuthenticatedReference as openAuthenticatedReference} from "../public-types.js";
1
+ export {public8_exportAuthenticatedReference as exportAuthenticatedReference,public8_inspectReference as inspectReference,public8_inspectReferencePreview as inspectReferencePreview,public8_openAuthenticatedReference as openAuthenticatedReference} from "../public-types.js";
@@ -1 +1 @@
1
- import{openAuthenticatedReference as r}from"./reference-native.js";import{exportAuthenticatedReference as n}from"./reference-export.js";import{inspectReference as f}from"./reference.js";export{n as exportAuthenticatedReference,f as inspectReference,r as openAuthenticatedReference};
1
+ import{openAuthenticatedReference as t}from"./reference-native.js";import{exportAuthenticatedReference as c}from"./reference-export.js";import{inspectReference as f,inspectReferencePreview as p}from"./reference.js";export{c as exportAuthenticatedReference,f as inspectReference,p as inspectReferencePreview,t as openAuthenticatedReference};
@@ -1 +1 @@
1
- var _=Object.defineProperty;var d=(n,r)=>_(n,"name",{value:r,configurable:!0});import{readContent as L}from"../engine/ports.js";import{installedReferenceContracts as C}from"./reference-contracts.js";import{BoundRefusal as m}from"./refusals.js";import{foldObjectsWithWasm as T}from"../wasm/object.js";import{sha256 as E,isSha256 as v}from"./hash.js";import{library11_canonical as N,library11_parse as j,library11_transportSelection as W}from"../vendor/runtime.js";import{library7_semanticStandingBytes as $}from"../vendor/runtime.js";import{authorityFor as J,rootSigner as P}from"../fold/signers.js";import{eraOf as q}from"../fold/digests.js";import{lockStanding as z,lockLines as D}from"../fold/keys.js";import{signedOwnerLines as G}from"../cli/owner.js";import{admittedObjects as H}from"./objects.js";import{storeOf as O}from"../land/ledger.js";import{objectFold as K}from"../engine/index.js";import{toposAt as Q,contentAt as V}from"./selected-topos.js";import{transportBytes as X}from"./ports/transport.js";import{decodeReference as Y}from"./reference-profile.js";import{inspectAuthenticatedReference as Z}from"./reference-authenticated.js";import{verifyBytes as ee}from"./adapters/keys/ed25519.js";function te(n){const r=n.flatMap(e=>{const s=j(e);return s.kind==="fact"&&s.value.fields.scope==="reference/authentication"?[s.value.fields]:[]});if(!r.length)return!1;if(r.length!==1||r[0].value!=="authenticated-standing@1")throw Error("REFUSE\xB7reference conflicting or unknown authentication profile");return!0}d(te,"authenticatedReferenceSelected");async function re(n){const r=O(n),e=await H(n,G(r),()=>{},!0),s=e.configuration.map(o=>N(o)),p=[...new Set(e.records.filter(o=>o.record==="cell").map(o=>o.fields.topos))].sort().map(o=>{const u=Q(o,r),t=u.parts.filter(c=>c.scope==="wire/topos/context-view");if(t.length!==1)throw Error("REFUSE\xB7reference host context selector");const h=u.parts.filter(c=>c.kind==="check"&&c.view===t[0].value);if(h.length!==1)throw Error("REFUSE\xB7reference host context offer");const f=h[0],g=[...new Set((f.restsOn??"").split("|").filter(Boolean))].sort();for(const c of g)V(c,r);return[o,f.value,g]});return{...e,policy:E($(s)),formImplementation:E(JSON.stringify(p))}}d(re,"prepareNativeReference");async function xe(n,r,e={}){const s=O(n),p=z(s),o=q(p),u=J(D(s),P(n),o.admitted);if(!te(p))throw Error("REFUSE\xB7reference no admitted authenticated-standing@1 profile");const t=d(i=>{const a=p.flatMap(k=>{const x=j(k);return x.kind==="fact"&&x.value.fields.scope===i?[{line:k,fields:x.value.fields}]:[]});if(a.length!==1||a[0].fields.role!=="writes"||a[0].fields.measure!=="id"||a[0].fields.form!=="alphabet"||u.of(a[0].line).kind!=="admitted")throw new m(i==="engine/object"?"reference/backend":"authenticated-reference/context","REFUSE\xB7reference missing, conflicting or unauthenticated "+i);return a[0].fields.value},"one");if(t("reference/authentication")!=="authenticated-standing@1")throw Error("REFUSE\xB7reference authentication profile");const h=t("reference/snapshot"),f=t("reference/epoch"),g=t("reference/proof-scope"),c=t("reference/records");if(!v(h)||!/^\d+$/.test(f)||!Number.isSafeInteger(Number(f))||!/^\d+$/.test(c)||!Number.isSafeInteger(Number(c))||Number(c)<1||!g)throw Error("REFUSE\xB7reference authority snapshot or resource contract");const y=t("engine/object");if(!["esm@1","wasm@1"].includes(y))throw new m("reference/backend","REFUSE\xB7reference unsupported declared backend");if(e.signal?.aborted)throw new m("reference/cancelled","REFUSE\xB7reference cancelled");const I=Y(r),l=await re(n);if(!l.records.some(i=>i.record==="cell"))throw Error("REFUSE\xB7reference host has no declared object interpretation");const S=l.context,A=l.configuration.map(i=>N(i)),w=W(l.configuration,new URL(I.source).protocol.slice(0,-1));if(!w)throw Error("REFUSE\xB7reference no admitted transport policy");if(e.content&&e.content.name!==w.name)throw new m("authenticated-reference/transport","REFUSE\xB7reference injected content binding conflicts with declaration");const b={refusals:t("reference/contracts/refusals"),standing:t("reference/contracts/standing")},F=t("reference/policy"),U=t("reference/form-implementation"),B=C();if(b.refusals!==B.refusals||b.standing!==B.standing||!v(F)||U!==l.formImplementation)throw new m("authenticated-reference/context","REFUSE\xB7reference expected interpretation differs");const R=await Z(r,{snapshot:h,epoch:Number(f),proofScope:g,contracts:b,policy:F,formImplementation:U,signers:u.admitted,algorithms:o.admitted,objects:S,maxBytes:w.responseBytes,maxRecords:Number(c),digestBytes:E,verifyBytes:ee,fetchBytes:d((i,a)=>e.content?L(i,a,{read:e.content.read,digestBytes:E},{timeoutMs:w.timeoutMs,maxBytes:w.responseBytes},e.signal):X(i,a,A),"fetchBytes")});if(e.signal?.aborted)throw new m("reference/cancelled","REFUSE\xB7reference cancelled");const M=y==="wasm@1"?await T(n,R.records,S,l.configuration,e.signal):K(R.records,S);return{...R,backend:y,readings:M}}d(xe,"openAuthenticatedReference");export{te as authenticatedReferenceSelected,xe as openAuthenticatedReference,re as prepareNativeReference};
1
+ var _=Object.defineProperty;var d=(n,r)=>_(n,"name",{value:r,configurable:!0});import{readContent as L}from"../engine/ports.js";import{installedReferenceContracts as C}from"./reference-contracts.js";import{BoundRefusal as m}from"./refusals.js";import{foldObjectsWithWasm as T}from"../wasm/object.js";import{sha256 as E,isSha256 as v}from"./hash.js";import{library14_canonical as N,library14_parse as j,library14_transportSelection as W}from"../vendor/runtime.js";import{library10_semanticStandingBytes as $}from"../vendor/runtime.js";import{authorityFor as J,rootSigner as P}from"../fold/signers.js";import{eraOf as q}from"../fold/digests.js";import{lockStanding as z,lockLines as D}from"../fold/keys.js";import{signedOwnerLines as G}from"../cli/owner.js";import{admittedObjects as H}from"./objects.js";import{storeOf as O}from"../land/ledger.js";import{objectFold as K}from"../engine/index.js";import{toposAt as Q,contentAt as V}from"./selected-topos.js";import{transportBytes as X}from"./ports/transport.js";import{decodeReference as Y}from"./reference-profile.js";import{inspectAuthenticatedReference as Z}from"./reference-authenticated.js";import{verifyBytes as ee}from"./adapters/keys/ed25519.js";function te(n){const r=n.flatMap(e=>{const s=j(e);return s.kind==="fact"&&s.value.fields.scope==="reference/authentication"?[s.value.fields]:[]});if(!r.length)return!1;if(r.length!==1||r[0].value!=="authenticated-standing@1")throw Error("REFUSE\xB7reference conflicting or unknown authentication profile");return!0}d(te,"authenticatedReferenceSelected");async function re(n){const r=O(n),e=await H(n,G(r),()=>{},!0),s=e.configuration.map(o=>N(o)),p=[...new Set(e.records.filter(o=>o.record==="cell").map(o=>o.fields.topos))].sort().map(o=>{const u=Q(o,r),t=u.parts.filter(c=>c.scope==="wire/topos/context-view");if(t.length!==1)throw Error("REFUSE\xB7reference host context selector");const h=u.parts.filter(c=>c.kind==="check"&&c.view===t[0].value);if(h.length!==1)throw Error("REFUSE\xB7reference host context offer");const f=h[0],g=[...new Set((f.restsOn??"").split("|").filter(Boolean))].sort();for(const c of g)V(c,r);return[o,f.value,g]});return{...e,policy:E($(s)),formImplementation:E(JSON.stringify(p))}}d(re,"prepareNativeReference");async function xe(n,r,e={}){const s=O(n),p=z(s),o=q(p),u=J(D(s),P(n),o.admitted);if(!te(p))throw Error("REFUSE\xB7reference no admitted authenticated-standing@1 profile");const t=d(i=>{const a=p.flatMap(k=>{const x=j(k);return x.kind==="fact"&&x.value.fields.scope===i?[{line:k,fields:x.value.fields}]:[]});if(a.length!==1||a[0].fields.role!=="writes"||a[0].fields.measure!=="id"||a[0].fields.form!=="alphabet"||u.of(a[0].line).kind!=="admitted")throw new m(i==="engine/object"?"reference/backend":"authenticated-reference/context","REFUSE\xB7reference missing, conflicting or unauthenticated "+i);return a[0].fields.value},"one");if(t("reference/authentication")!=="authenticated-standing@1")throw Error("REFUSE\xB7reference authentication profile");const h=t("reference/snapshot"),f=t("reference/epoch"),g=t("reference/proof-scope"),c=t("reference/records");if(!v(h)||!/^\d+$/.test(f)||!Number.isSafeInteger(Number(f))||!/^\d+$/.test(c)||!Number.isSafeInteger(Number(c))||Number(c)<1||!g)throw Error("REFUSE\xB7reference authority snapshot or resource contract");const y=t("engine/object");if(!["esm@1","wasm@1"].includes(y))throw new m("reference/backend","REFUSE\xB7reference unsupported declared backend");if(e.signal?.aborted)throw new m("reference/cancelled","REFUSE\xB7reference cancelled");const I=Y(r),l=await re(n);if(!l.records.some(i=>i.record==="cell"))throw Error("REFUSE\xB7reference host has no declared object interpretation");const S=l.context,A=l.configuration.map(i=>N(i)),w=W(l.configuration,new URL(I.source).protocol.slice(0,-1));if(!w)throw Error("REFUSE\xB7reference no admitted transport policy");if(e.content&&e.content.name!==w.name)throw new m("authenticated-reference/transport","REFUSE\xB7reference injected content binding conflicts with declaration");const b={refusals:t("reference/contracts/refusals"),standing:t("reference/contracts/standing")},F=t("reference/policy"),U=t("reference/form-implementation"),B=C();if(b.refusals!==B.refusals||b.standing!==B.standing||!v(F)||U!==l.formImplementation)throw new m("authenticated-reference/context","REFUSE\xB7reference expected interpretation differs");const R=await Z(r,{snapshot:h,epoch:Number(f),proofScope:g,contracts:b,policy:F,formImplementation:U,signers:u.admitted,algorithms:o.admitted,objects:S,maxBytes:w.responseBytes,maxRecords:Number(c),digestBytes:E,verifyBytes:ee,fetchBytes:d((i,a)=>e.content?L(i,a,{read:e.content.read,digestBytes:E},{timeoutMs:w.timeoutMs,maxBytes:w.responseBytes},e.signal):X(i,a,A,{signal:e.signal}),"fetchBytes")});if(e.signal?.aborted)throw new m("reference/cancelled","REFUSE\xB7reference cancelled");const M=y==="wasm@1"?await T(n,R.records,S,l.configuration,e.signal):K(R.records,S);return{...R,backend:y,readings:M}}d(xe,"openAuthenticatedReference");export{te as authenticatedReferenceSelected,xe as openAuthenticatedReference,re as prepareNativeReference};
@@ -1,2 +1,2 @@
1
- var c=Object.defineProperty;var t=(e,s)=>c(e,"name",{value:s,configurable:!0});import{library11_parse as p}from"../vendor/runtime.js";import{library8_cellInputs as m}from"../vendor/runtime.js";import{library7_semanticStandingBytes as i}from"../vendor/runtime.js";function h(e,s){const o=new Set([...m(s,"semantic-live@2").values()].flat().map(r=>i([r]))),a=t(r=>{const n=p(r);if(n.kind!=="fact")throw Error("REFUSE\xB7authenticated-reference original parse");return n.value.fields},"fields"),f=[...e].sort((r,n)=>Number(a(r).epoch)-Number(a(n).epoch));return i(f.filter(r=>a(r).type===void 0||o.has(i([r]))))}t(h,"referenceStanding");function g(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===2&&/^sha256:[a-f0-9]{64}$/.test(e.refusals)&&/^sha256:[a-f0-9]{64}$/.test(e.standing)}t(g,"referenceContracts");function b(e){return new TextEncoder().encode(JSON.stringify(["reference-export-context@1",e.semanticIdentity,e.epoch,e.proofScope,e.policy,e.formImplementation,e.signers,e.algorithms,e.contracts.refusals,e.contracts.standing,e.maxBytes,e.maxRecords])+`
1
+ var c=Object.defineProperty;var t=(e,s)=>c(e,"name",{value:s,configurable:!0});import{library14_parse as p}from"../vendor/runtime.js";import{library11_cellInputs as m}from"../vendor/runtime.js";import{library10_semanticStandingBytes as i}from"../vendor/runtime.js";function h(e,s){const o=new Set([...m(s,"semantic-live@2").values()].flat().map(r=>i([r]))),a=t(r=>{const n=p(r);if(n.kind!=="fact")throw Error("REFUSE\xB7authenticated-reference original parse");return n.value.fields},"fields"),f=[...e].sort((r,n)=>Number(a(r).epoch)-Number(a(n).epoch));return i(f.filter(r=>a(r).type===void 0||o.has(i([r]))))}t(h,"referenceStanding");function g(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===2&&/^sha256:[a-f0-9]{64}$/.test(e.refusals)&&/^sha256:[a-f0-9]{64}$/.test(e.standing)}t(g,"referenceContracts");function b(e){return new TextEncoder().encode(JSON.stringify(["reference-export-context@1",e.semanticIdentity,e.epoch,e.proofScope,e.policy,e.formImplementation,e.signers,e.algorithms,e.contracts.refusals,e.contracts.standing,e.maxBytes,e.maxRecords])+`
2
2
  `)}t(b,"referenceContextBytes");export{b as referenceContextBytes,g as referenceContracts,h as referenceStanding};
@@ -1 +1 @@
1
- var p=Object.defineProperty;var o=(n,r)=>p(n,"name",{value:r,configurable:!0});import{createHash as f}from"node:crypto";import{library3_readSemanticStanding as m,library3_semanticStandingBytes as l}from"../vendor/runtime.js";import{library11_parse as y,library11_transportSelection as S}from"../vendor/runtime.js";import{transportBytes as u}from"./ports/transport.js";import{decodeReference as h,inspectReferenceBytes as E}from"./reference-profile.js";async function _(n,r){const s=h(n),a=new URL(s.source).protocol.slice(0,-1),d=r.flatMap(e=>{const t=y(e);return t.kind==="fact"?[t.value.fields]:[]}),i=S(d,a);if(i===void 0)throw Error(`REFUSE\xB7transport ${a} no admitted content-request/1 policy`);let c;try{c=await u(s.source,s.blob,r)}catch(e){const t=e instanceof Error?e.message:"transport failed";throw t.startsWith("REFUSE\xB7")?e:Error(`REFUSE\xB7transport ${a} ${t}`)}return E(s,c,{maxBytes:i.responseBytes,readSemanticStanding:m,semanticStandingBytes:l,digestBytes:o(e=>f("sha256").update(e).digest("hex"),"digestBytes")})}o(_,"inspectReference");export{_ as inspectReference};
1
+ var E=Object.defineProperty;var a=(o,r)=>E(o,"name",{value:r,configurable:!0});import{createHash as f}from"node:crypto";import{library6_readSemanticStanding as _,library6_semanticStandingBytes as U}from"../vendor/runtime.js";import{library14_parse as w,library14_transportSelection as b}from"../vendor/runtime.js";import{library5_decodeLocatedReference as x,library5_locatedReferenceIdentity as L,library5_inspectLocatedReference as v}from"../vendor/runtime.js";import{ContentUnavailable as P}from"./adapters/transport/http.js";import{library5_decodeReferenceProjection as j,library5_inspectReferenceProjection as F}from"../vendor/runtime.js";import{BoundRefusal as i}from"./refusals.js";import{transportBytes as S}from"./ports/transport.js";import{decodeReference as $,inspectReferenceBytes as k}from"./reference-profile.js";async function J(o,r,c={}){if(o.startsWith("#topos-reference:")){let e;try{e=x(o)}catch(t){throw new i("reference/format",String(t))}const s=L(e),m=a(()=>({kind:"needs",reference:e,identity:s,needs:"needs/bytes/"+e.blob,authentication:"not demonstrated; inspect only"}),"needs");if(!e.location||e["location-class"]==="viewer")return m();const y=new URL(e.location).protocol.slice(0,-1),B=r.flatMap(t=>{const R=w(t);return R.kind==="fact"?[R.value.fields]:[]}),h=b(B,y);if(!h)throw new i("reference/transport",`REFUSE\xB7transport ${y} no admitted content-request/1 policy`);let u;try{u=await S(e.location,e.blob,r,c)}catch(t){if(t instanceof P)return m();throw t}try{return{...v(e,u,{maxBytes:h.responseBytes,digestBytes:a(t=>f("sha256").update(t).digest("hex"),"digestBytes")}),reference:e,authentication:"not demonstrated; inspect only"}}catch(t){throw new i("reference/format",String(t))}}const n=$(o),d=new URL(n.source).protocol.slice(0,-1),g=r.flatMap(e=>{const s=w(e);return s.kind==="fact"?[s.value.fields]:[]}),l=b(g,d);if(l===void 0)throw new i("reference/transport",`REFUSE\xB7transport ${d} no admitted content-request/1 policy`);let p;try{p=await S(n.source,n.blob,r,c)}catch(e){const s=e instanceof Error?e.message:"transport failed";throw s.startsWith("REFUSE\xB7")?e:Error(`REFUSE\xB7transport ${d} ${s}`)}return k(n,p,{maxBytes:l.responseBytes,readSemanticStanding:_,semanticStandingBytes:U,digestBytes:a(e=>f("sha256").update(e).digest("hex"),"digestBytes")})}a(J,"inspectReference");function K(o,r,c){try{return F(j(o,r,c),n=>"sha256:"+f("sha256").update(n).digest("hex"),r,c)}catch(n){throw new i("reference/format",String(n))}}a(K,"inspectReferencePreview");export{J as inspectReference,K as inspectReferencePreview};
@@ -1,2 +1,2 @@
1
- var d=Object.defineProperty;var c=(s,a)=>d(s,"name",{value:a,configurable:!0});import{library11_parse as p,library11_canonical as g}from"../vendor/runtime.js";class l extends Error{static{c(this,"BoundRefusal")}constructor(a,o){super(o),this.name="BoundRefusal",this.code=a}}function v(s){const a=new Map;let o=!1;for(const i of s.trimEnd().split(`
2
- `)){const t=p(i);if(t.kind!=="fact"||g(t.value.fields)!==i)throw new l("catalog/invalid","REFUSE\xB7invalid refusal catalog line");const e=t.value.fields;if(e.scope==="refusal/catalog"&&e.measure==="id"&&e.value==="bound-refusals@1"&&e.role==="writes"&&e.form==="alphabet"&&!o){o=!0;continue}if(e.role!=="writes"||e.form!=="alphabet"||!e.scope?.startsWith("refusal/")||!["code","class","next"].includes(e.measure??""))throw new l("catalog/invalid","REFUSE\xB7invalid refusal catalog record");const r=a.get(e.scope)??new Map;if(r.has(e.measure))throw new l("catalog/invalid","REFUSE\xB7duplicate refusal catalog field");r.set(e.measure,e),a.set(e.scope,r)}const n=[];for(const[i,t]of a){const e=t.get("code")?.value,r=t.get("class")?.value,u=t.get("class")?.about,f=t.get("next")?.value;if(t.size!==3||!e||i!=="refusal/"+e||!r||!u||!f)throw new l("catalog/invalid","REFUSE\xB7incomplete refusal catalog entry");n.push(Object.freeze({code:e,category:r,meaning:u,next:f}))}if(!o||!n.length)throw new l("catalog/invalid","REFUSE\xB7missing refusal catalog profile");return Object.freeze(n)}c(v,"readRefusalCatalog");function E(s,a){const o=a.find(n=>n.code===s.code);if(!o)throw new l("catalog/invalid","REFUSE\xB7undeclared refusal code");return o}c(E,"describeRefusal");export{l as BoundRefusal,E as describeRefusal,v as readRefusalCatalog};
1
+ var d=Object.defineProperty;var s=(o,a)=>d(o,"name",{value:a,configurable:!0});import{library14_parse as g,library14_canonical as p}from"../vendor/runtime.js";class l extends Error{static{s(this,"BoundRefusal")}constructor(a,r){super(r),this.name="BoundRefusal",this.code=a}}function v(o){throw new l(o,"REFUSE\xB7"+o)}s(v,"refuseBound");function w(o){const a=new Map;let r=!1;for(const i of o.trimEnd().split(`
2
+ `)){const t=g(i);if(t.kind!=="fact"||p(t.value.fields)!==i)throw new l("catalog/invalid","REFUSE\xB7invalid refusal catalog line");const e=t.value.fields;if(e.scope==="refusal/catalog"&&e.measure==="id"&&e.value==="bound-refusals@1"&&e.role==="writes"&&e.form==="alphabet"&&!r){r=!0;continue}if(e.role!=="writes"||e.form!=="alphabet"||!e.scope?.startsWith("refusal/")||!["code","class","next"].includes(e.measure??""))throw new l("catalog/invalid","REFUSE\xB7invalid refusal catalog record");const n=a.get(e.scope)??new Map;if(n.has(e.measure))throw new l("catalog/invalid","REFUSE\xB7duplicate refusal catalog field");n.set(e.measure,e),a.set(e.scope,n)}const c=[];for(const[i,t]of a){const e=t.get("code")?.value,n=t.get("class")?.value,u=t.get("class")?.about,f=t.get("next")?.value;if(t.size!==3||!e||i!=="refusal/"+e||!n||!u||!f)throw new l("catalog/invalid","REFUSE\xB7incomplete refusal catalog entry");c.push(Object.freeze({code:e,category:n,meaning:u,next:f}))}if(!r||!c.length)throw new l("catalog/invalid","REFUSE\xB7missing refusal catalog profile");return Object.freeze(c)}s(w,"readRefusalCatalog");function h(o,a){const r=a.find(c=>c.code===o.code);if(!r)throw new l("catalog/invalid","REFUSE\xB7undeclared refusal code");return r}s(h,"describeRefusal");function R(o,a,r){try{return{profile:"bound-refusal@1",...h(o,w(a)),catalog:r(a)}}catch{return{profile:"bound-refusal@1",code:"catalog/invalid",unmeasured:["category","meaning","next","catalog"]}}}s(R,"refusalRecord");export{l as BoundRefusal,h as describeRefusal,w as readRefusalCatalog,R as refusalRecord,v as refuseBound};
@@ -1,4 +1,4 @@
1
- var te=Object.defineProperty;var l=(e,r)=>te(e,"name",{value:r,configurable:!0});import{ContentNeeded as ne}from"./content-needed.js";import{createHash as _}from"node:crypto";import{existsSync as I,lstatSync as y,mkdirSync as D,realpathSync as z,renameSync as L,rmSync as F,writeFileSync as B}from"node:fs";import{dirname as C,join as m,sep as P}from"node:path";import{library11_canonical as G}from"../vendor/runtime.js";import{fieldOf as u,isWire as oe,isConfig as se}from"../fold/claims.js";import{archiveCoordinate as w,archiveDestination as J,members as g}from"./archive.js";import{blobAt as k,holdStore as ie,landBlob as K,replaceWhole as ce,storeAt as Q}from"../land/ledger.js";import{coordinatesUnder as ae,observeFile as R,observeText as b}from"../observe/files.js";const Z=l((e,r)=>Q(e,"cas","laid",r.replace(/^[^:]*:/,"")),"laidAt"),fe=l(e=>se(e)&&u(e,"scope").startsWith("dep/")&&u(e,"role")==="reads"&&u(e,"value")!=="withdraw"&&(u(e,"measure")==="digest"||/^[a-zA-Z][a-zA-Z0-9-]*:[a-f0-9]+$/.test(u(e,"value"))),"isReleaseBinding"),V=l(e=>e.filter(fe),"releasesOf"),$=".laid",S=l(e=>`sha256:${_("sha256").update(e).digest("hex")}`,"digestOf"),A=l((e,r)=>_(e.includes(":")?e.slice(0,e.indexOf(":")):"sha256").update(r).digest("hex")===e.replace(/^[^:]*:/,""),"hashed"),j=l(e=>e.split(`
1
+ var te=Object.defineProperty;var l=(e,r)=>te(e,"name",{value:r,configurable:!0});import{ContentNeeded as ne}from"./content-needed.js";import{createHash as _}from"node:crypto";import{existsSync as I,lstatSync as y,mkdirSync as D,realpathSync as z,renameSync as L,rmSync as F,writeFileSync as B}from"node:fs";import{dirname as C,join as m,sep as P}from"node:path";import{library14_canonical as G}from"../vendor/runtime.js";import{fieldOf as u,isWire as oe,isConfig as se}from"../fold/claims.js";import{archiveCoordinate as w,archiveDestination as J,members as g}from"./archive.js";import{blobAt as k,holdStore as ie,landBlob as K,replaceWhole as ce,storeAt as Q}from"../land/ledger.js";import{coordinatesUnder as ae,observeFile as R,observeText as b}from"../observe/files.js";const Z=l((e,r)=>Q(e,"cas","laid",r.replace(/^[^:]*:/,"")),"laidAt"),fe=l(e=>se(e)&&u(e,"scope").startsWith("dep/")&&u(e,"role")==="reads"&&u(e,"value")!=="withdraw"&&(u(e,"measure")==="digest"||/^[a-zA-Z][a-zA-Z0-9-]*:[a-f0-9]+$/.test(u(e,"value"))),"isReleaseBinding"),V=l(e=>e.filter(fe),"releasesOf"),$=".laid",S=l(e=>`sha256:${_("sha256").update(e).digest("hex")}`,"digestOf"),A=l((e,r)=>_(e.includes(":")?e.slice(0,e.indexOf(":")):"sha256").update(r).digest("hex")===e.replace(/^[^:]*:/,""),"hashed"),j=l(e=>e.split(`
2
2
  `).filter(oe).filter(r=>u(r,"measure")==="digest"&&u(r,"scope").startsWith("file/")).map(r=>[u(r,"scope").slice(5),u(r,"value")]),"snapshotOf");function M(e,r){if(!r)return e;const t=w(r)+"/";if(!e.length||e.some(([c])=>!c.startsWith(t)))throw new Error(`REFUSE\xB7release archive root ${r} does not contain every member`);return e.map(([c,n])=>[w(c.slice(t.length)),n])}l(M,"mountedFiles");function le(e){return e.map(([r,t])=>G({scope:`file/${r}`,role:"writes",form:"alphabet",measure:"digest",value:t,at:`place:${t}`,by:"target"})).join(`
3
3
  `)+(e.length?`
4
4
  `:"")}l(le,"snapshotLines");function ue(e,r){for(const t of ae(e,e)){if(t===$)continue;const c=m(e,t),n=J(r,t);if(D(C(n),{recursive:!0}),I(n))continue;const o=R(c);if(o===void 0)throw new Error(`REFUSE\xB7release unreadable historical member ${t}`);B(n,o,{flag:"wx"})}}l(ue,"layDir");function q(e,r,t,c){const n=`${r}.old`;if(y(n,{throwIfNoEntry:!1})!==void 0)throw new Error(`REFUSE\xB7release recovery required for ${n}`);if(B(m(r,$),t,{flag:"wx"}),c!==void 0){if(c()){F(r,{recursive:!0,force:!0});return}try{L(r,e);return}catch(s){const i=s.code;if(i!=="EEXIST"&&i!=="ENOTEMPTY")throw s;if(c()){F(r,{recursive:!0,force:!0});return}}}let o=!1;try{y(e,{throwIfNoEntry:!1})!==void 0&&(L(e,n),o=!0),L(r,e)}catch(s){throw o&&y(e,{throwIfNoEntry:!1})===void 0&&L(n,e),s}o&&F(n,{recursive:!0,force:!0})}l(q,"swapPlace");function H(e){const r=`${e}.${process.pid}`;return D(C(e),{recursive:!0}),D(r),r}l(H,"nextPlace");function ee(e,r,t,c){const n=t.map(([o,s])=>{const i=w(o),f=J(c,i),d=[k(r,s),k(e,s)].find(I);if(d===void 0)throw new Error(`REFUSE\xB7release missing blob ${s} for ${i}`);const a=R(d);if(a===void 0||!A(s,a))throw new Error(`REFUSE\xB7release blob ${s} for ${i} does not hold`);return{dest:f,bytes:a}});for(const{dest:o,bytes:s}of n)D(C(o),{recursive:!0}),B(o,s,{flag:"wx"})}l(ee,"layFiles");function U(e,r){return r.every(([t,c])=>{const n=m(e,w(t)),s=y(n,{throwIfNoEntry:!1})?.isFile()?R(n):void 0;return s!==void 0&&A(c,s)})}l(U,"layoutMatches");function re(e,r){const t=new Map(e);return t.size===e.length&&e.length===r.length&&r.every(([c,n])=>t.get(c)===n)}l(re,"sameSnapshot");function de(e,r,t){const c=g(t).map(o=>{const s=S(o.bytes);return K(e,s,o.bytes),[o.name,s]}),n=le(c);return ce(Z(e,r),n),ie(e,"laid",r,Buffer.byteLength(n)),c}l(de,"keepSnapshot");function xe(e,r,t,c=r){let n=0;for(const o of V(t)){const s=u(o,"needs");if(!s)continue;const i=u(o,"value"),f=Z(e,i),d=y(f,{throwIfNoEntry:!1})?.isDirectory()??!1,a=R(k(c,i)),p=i.replace(/^[^:]*:/,"");if(a!==void 0&&!A(i,a))throw new Error(`REFUSE\xB7release ${u(o,"scope")} \xB7 blob ${p.slice(0,12)} hashes to ${S(a).slice(7,19)} \xB7 not laid`);a!==void 0&&!d&&b(f)===void 0&&de(e,i,a);const E=b(f);if(a!==void 0&&E!==void 0&&!d&&!re(j(E),g(a).map(v=>[v.name,S(v.bytes)])))throw new Error(`REFUSE\xB7release snapshot for ${i} omits or changes archive members; explicit rebuild required`);if(a===void 0&&!d&&E===void 0)throw new ne(i,`REFUSE\xB7release ${u(o,"scope")} has no available archive or snapshot`);const x=u(o,"shape"),h=m(r,w(s));if(y(h,{throwIfNoEntry:!1})?.isSymbolicLink()&&!z(h).includes(`${P}cas${P}laid${P}`))continue;if(d){const v=a===void 0?void 0:M(g(a).map(O=>[O.name,S(O.bytes)]),x);if(!y(h,{throwIfNoEntry:!1})?.isSymbolicLink()&&b(m(h,$))===i&&v!==void 0&&U(h,v))continue;const W=H(h);try{ue(x?m(f,w(x)):f,W),q(h,W,i)}catch(O){throw F(W,{recursive:!0,force:!0}),O}n+=1;continue}const N=b(f);if(N===void 0)throw new Error(`REFUSE\xB7release ${u(o,"scope")} has no available snapshot`);const Y=M(j(N),x);if(!y(h,{throwIfNoEntry:!1})?.isSymbolicLink()&&b(m(h,$))===i&&U(h,Y))continue;const T=H(h);try{ee(e,c,Y,T),q(h,T,i)}catch(v){throw F(T,{recursive:!0,force:!0}),v}n+=1}return n}l(xe,"layReleases");const Fe=l((e,r,t,c=r)=>V(t).flatMap(n=>{const o=u(n,"value"),s=R(k(c,o)),i=s!==void 0&&A(o,s),f=u(n,"needs"),d=f?m(r,w(f)):"",a=Z(e,o),p=f?b(m(d,$))===o||I(d)&&I(a)&&z(d)===z(a):I(a),E=i?g(s).map(N=>[N.name,S(N.bytes)]):void 0,x=y(a,{throwIfNoEntry:!1})?.isDirectory()===!0,h=b(a),X=E!==void 0&&(f?U(d,M(E,u(n,"shape"))):x?U(a,E):h!==void 0&&re(j(h),E));return i&&p&&X?[G({scope:`resolved/${u(n,"scope").slice(4)}`,role:"writes",form:"alphabet",measure:"digest",value:o,at:`place:${o}`,by:"target"})]:[]}),"resolvedOf");function ge(e,r,t,c=r,n=""){const o=/^([a-zA-Z0-9-]+):([a-fA-F0-9]+)$/.exec(t);if(o===null)throw new Error(`REFUSE\xB7release invalid digest ${t}`);const s=R(k(c,t));if(s===void 0)return;if(!A(t,s))throw new Error(`REFUSE\xB7release ${t} does not name its available bytes`);const i=g(s).map(p=>[p.name,S(p.bytes)]);M(i,n);const f=Q(e,"cas","runtime",o[1],o[2]),d=n?m(f,w(n)):f;if(b(m(f,$))===t&&U(f,i))return d;for(const p of g(s))K(e,S(p.bytes),p.bytes);const a=H(f);try{ee(e,r,i,a),q(f,a,t,()=>b(m(f,$))===t&&U(f,i))}catch(p){throw F(a,{recursive:!0,force:!0}),p}return d}l(ge,"runtimeTreeAt");export{fe as isReleaseBinding,Z as laidAt,xe as layReleases,V as releasesOf,Fe as resolvedOf,ge as runtimeTreeAt};