@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 D=Object.defineProperty;var y=(e,t)=>D(e,"name",{value:t,configurable:!0});import{existsSync as U,opendirSync as Q,statSync as V}from"node:fs";import{join as _,basename as Y}from"node:path";import{committedLocalActs as Z,actLines as K}from"./ports/local-act.js";import{verifiedLegacyActResult as $}from"../cli/act-result.js";import{admissionAnchor as I,admissionHistoryAt as L}from"../fold/admission-history.js";import{authorityFor as ee}from"../fold/signers.js";import{signatureEraOf as H}from"./signature-era.js";import{fieldOf as i,foldClaims as F,isConfig as A,selfName as te}from"../fold/claims.js";import{authenticatedRootStanding as W}from"./admitted-place.js";import{verifiesOwnerLine as q}from"../land/sign.js";import{placesIn as G}from"../fold/places.js";import{appliedHistoryIn as T}from"../fold/signed.js";import{storeOf as M}from"../land/ledger.js";import{hostClockSelection as J}from"./place-clock-selection.js";import{library3_readPlaceActContext as B,library3_placeActReceiptsOf as re}from"../vendor/runtime.js";import{placeActResult as oe,placeActHeads as ie}from"./ports/place-act.js";import{rootAuthorityProtection as se}from"../land/act.js";import{readOnly as ce}from"./read-only.js";const o=y(e=>{throw Error("REFUSE\xB7Root cursor "+e)},"fail");function z(e){const t=e?.resources;return(!t||Object.keys(t).sort().join(",")!=="acts,bytes,lines,places"||Object.values(t).some(r=>!Number.isSafeInteger(r)||r<1)||typeof e.selector!="string"||!e.selector||typeof e.profileSelector!="string"||!e.profileSelector||!e.bootstrapCheckpoint||Object.keys(e.bootstrapCheckpoint).sort().join(",")!=="measure,scope"||typeof e.bootstrapCheckpoint.scope!="string"||!e.bootstrapCheckpoint.scope||typeof e.bootstrapCheckpoint.measure!="string"||!e.bootstrapCheckpoint.measure)&&o("missing admitted source selection"),(!e.inherited?.clock||Object.keys(e.inherited.clock).sort().join(",")!=="bytes,placements,policies,proofs,records,signers"||!e.inherited.storage||Object.keys(e.inherited.storage).sort().join(",")!=="acts,bytes"||[...Object.values(e.inherited.clock),...Object.values(e.inherited.storage)].some(r=>!Number.isSafeInteger(r)||r<1))&&o("missing inherited source budgets"),t}y(z,"sourceSelection");function ne(e,t){const r=z(t),p=M(e);let k=0,g=0,a=0;const b=r.acts*(r.places+2)+r.lines;Number.isSafeInteger(b)||o("source file bound");const n=y(d=>{if(!U(d))return;const l=V(d);if(l.isDirectory()){const f=Q(d);try{for(let m=f.readSync();m;m=f.readSync())++a>b&&o("source entry budget"),!(Y(d)==="ledger"&&m.name==="place-acts")&&n(_(d,m.name))}finally{f.closeSync()}}else(!l.isFile()||++g>b||(k+=l.size)>r.bytes)&&o("source file/byte budget")},"visit");n(_(p,"ledger")),n(_(p,te()+".keys"))}y(ne,"boundedInventory");function P(e,t){const r=z(t);ne(e,t);const p=L(e,Number.MAX_SAFE_INTEGER);p.length>r.lines&&o("history line budget");let k=0;for(const c of p)(k+=Buffer.byteLength(c))>r.bytes&&o("history byte budget");const g=Z(M(e));g.length>r.acts&&o("act inventory budget");const a=g.flatMap(c=>{const h=c.bundle.placements?.filter(v=>v.place===".")??[];return h.some(v=>K(v.records).some(A))?[{...$(e,c.identity),identity:c.identity,roots:h}]:[]});a.sort((c,h)=>c.epoch-h.epoch),a.some((c,h)=>h>0&&c.epoch===a[h-1].epoch&&c.identity!==a[h-1].identity)&&o("ambiguous committed Root cursor");const b=a.at(-1),n=I(e);let d;if(b){const c=b.roots.flatMap(h=>K(h.records)).filter(A);c.length||o("verified Root act has no configuration checkpoint"),d=c[0]}else{const c=p.filter(h=>i(h,"scope")===t.bootstrapCheckpoint.scope&&i(h,"measure")===t.bootstrapCheckpoint.measure);c.length!==1&&o("bootstrap checkpoint missing/ambiguous"),d=c[0]}const l=Number(i(d,"epoch"));(!Number.isSafeInteger(l)||l<0)&&o("unknown committed Root epoch");const f=p.filter(c=>!A(c)||Number(i(c,"epoch"))<=l),m=H(F(f.filter(c=>i(c,"scope").startsWith("wire/"))).standing).admitted;ee(f,n,m).of(d).kind!=="admitted"&&o("checkpoint is not authenticated");const w=G(e);w.length>r.places&&o("legacy namespace inventory budget");const u=[...new Set([...p,...w.flatMap(c=>T(e,c))])];return(u.length+f.length>r.lines||u.reduce((c,h)=>c+Buffer.byteLength(h),0)+f.reduce((c,h)=>c+Buffer.byteLength(h),0)>r.bytes)&&o("legacy origin inventory budget"),{history:f,anchor:n,algorithms:m,authorityCheckpoint:d,legacyOriginals:u}}y(P,"current");function ae(e,t){const r=P(e,t),p=new Set,k=new Map,g=y(l=>{const f=k.get(l);if(f)return f;(p.has(l)||p.size>=t.resources.acts)&&o("historical predecessor cycle/budget"),p.add(l);try{const m=B(l,t.inherited.clock),O=m.root.epoch,w=L(e,Number(O)),u=w.filter(v=>A(v)&&i(v,"epoch")===O);u.length||o("historical checkpoint absent");const c=J({...a,history:w,authorityCheckpoint:u[0],legacyOriginals:w,authenticatedReceiverHeads:[],readCurrent:y(()=>P(e,t),"readCurrent")}),h=m.places.map(v=>{const N=c.trust.initialHeads.find(s=>s.place===v.place);if(N?.identity===v.previous)return N;const x=oe(a.store,v.previous,{historical:g},c.selection.storageBudget);x||o("historical predecessor absent");const j=B(x.context,t.inherited.clock),E=j.places.find(s=>s.place===v.place);return E||o("historical predecessor namespace absent"),{place:v.place,identity:v.previous,epoch:E.epoch}}),S=J({...a,history:w,authorityCheckpoint:u[0],legacyOriginals:w,authenticatedReceiverHeads:h,readCurrent:y(()=>P(e,t),"readCurrent")}).trust.contract;return k.set(l,S),S}finally{p.delete(l)}},"historical"),a={store:M(e),selector:t.selector,profileSelector:t.profileSelector,...r,resources:{bytes:t.resources.bytes,lines:t.resources.lines,places:t.resources.places},inherited:t.inherited,readCurrent:y(()=>P(e,t),"readCurrent"),historical:g},b=J(a),n=Object.freeze({...r.anchor,coverage:Object.freeze([...r.anchor.coverage]),depth:Object.freeze({...r.anchor.depth}),admittedBy:Object.freeze([...r.anchor.admittedBy])}),d=Object.freeze({history:Object.freeze([...r.history]),anchor:n,algorithms:Object.freeze([...r.algorithms])});return{...b,observation:d,resources:Object.freeze({...t.resources}),authority:y(l=>{const f=B(l,t.inherited.clock),m=L(e,Number(f.root.epoch)),O=m.filter(w=>A(w)&&i(w,"epoch")===f.root.epoch);return O.length||o("public historical checkpoint absent"),{anchor:r.anchor,history:m,checkpoint:O[0]}},"authority")}}y(ae,"rootClockSource");function pe(e,t){const r=e.filter(b=>i(b,"scope")==="wire/place-act-context-source"&&i(b,"measure")==="text"&&i(b,"value")!=="withdraw");r.length!==1&&o("requires one admitted source mapping");const p=r[0],k=H(e).admitted;(i(p,"by")!==t.id||i(p,"role")!=="writes"||i(p,"form")!=="alphabet"||i(p,"value")!=="lock"||!q(p,t.publicKey,k))&&o("mapping is not Root signed");const g=i(p,"about");let a;try{a=JSON.parse(g)}catch{return o("mapping JSON invalid")}return(!a||Object.keys(a).sort().join(",")!=="bootstrapCheckpoint,inherited,profile,profileSelector,resources,selector"||a.profile!=="place-act-context@1"||JSON.stringify(a)!==g)&&o("unknown/noncanonical mapping"),z(a),a}y(pe,"rootClockSelectionOf");function le(e){return ae(e,pe(W(e),I(e)))}y(le,"declaredRootClockSource");function Je(e){return W(e).some(t=>i(t,"scope")==="wire/place-act-context-source"&&i(t,"measure")==="text"&&i(t,"value")!=="withdraw")}y(Je,"hasRootClockSource");function He(e,t,r){z(r),(typeof e!="string"||Buffer.byteLength(e)>r.resources.bytes)&&o("portable byte budget");let p;try{p=JSON.parse(e)}catch{return o("portable JSON")}(!Array.isArray(p)||p.length>r.resources.acts)&&o("portable context inventory budget");const k=new Map;for(const n of p)(!n||typeof n.identity!="string"||typeof n.context!="string"||!n.authority||JSON.stringify(n.authority.anchor)!==JSON.stringify(t)||!Array.isArray(n.authority.history)||!Array.isArray(n.receipts)||k.has(n.identity))&&o("portable anchor/shape/identity"),k.set(n.identity,n);const g=new Map,a=new Set,b=y(n=>{const d=g.get(n);if(d)return d;const l=k.get(n);(!l||a.has(n))&&o("portable predecessor missing/cyclic"),a.add(n);try{const f=B(l.context,r.inherited.clock),m={store:"",selector:r.selector,profileSelector:r.profileSelector,history:l.authority.history,anchor:t,algorithms:H(F(l.authority.history.filter(S=>i(S,"scope").startsWith("wire/"))).standing).admitted,legacyOriginals:l.authority.history,authorityCheckpoint:l.authority.checkpoint,resources:{bytes:r.resources.bytes,lines:r.resources.lines,places:r.resources.places},inherited:r.inherited,authenticatedReceiverHeads:[],readCurrent:y(()=>o("portable inspection has no current Root authority"),"readCurrent"),historical:y(()=>o("portable inspection uses declared predecessor graph"),"historical")},O=J(m),w=f.places.map(S=>{const v=O.trust.initialHeads.find(j=>j.place===S.place);if(v?.identity===S.previous)return v;const N=b(S.previous),x=N.context.places.find(j=>j.place===S.place);return x||o("portable predecessor namespace"),{place:S.place,identity:S.previous,epoch:x.epoch}}),u=J({...m,authenticatedReceiverHeads:w}).trust.contract;re(l.context,l.receipts,u).identity!==n&&o("portable identity differs");const h={contract:u,context:f};return g.set(n,h),h}finally{a.delete(n)}},"inspect");for(const n of k.keys())b(n);return[...g].map(([n,d])=>({identity:n,context:d.context}))}y(He,"inspectPortablePlaceContexts");function ze(e,t){const r="wire/place-act-context-source",p=L(e,Number.MAX_SAFE_INTEGER),k=[r,"wire/place-act-context-selection","wire/place-act-context"];if(!p.some(s=>i(s,"scope")===r)&&!t.some(s=>k.includes(i(s,"scope"))))return;const g=W(e).filter(s=>i(s,"value")!=="withdraw"),a=g.find(s=>i(s,"scope")===r&&i(s,"measure")==="text");if(a){const s=I(e),R=H(g.filter(X=>i(X,"scope").startsWith("wire/"))).admitted;(i(a,"by")!==s.id||!q(a,s.publicKey,R))&&o("existing source mapping is not Root signed");let C;try{C=JSON.parse(i(a,"about"))}catch{return o("existing source mapping JSON invalid")}k.push(C.selector,C.profileSelector)}if(!t.some(s=>k.includes(i(s,"scope")))||t.every(s=>p.includes(s)))return;const b=M(e);ce()||se(b);const n=[...new Set([...p,...t])],d=F([...g,...t].filter(A)).standing.filter(s=>i(s,"value")!=="withdraw"),l=d.filter(s=>i(s,"scope")===r&&i(s,"measure")==="text");if(!l.length)return t.some(s=>i(s,"scope")===r&&i(s,"value")==="withdraw")?void 0:o("activation requires source and selection together");l.length!==1&&o("prospective source mapping ambiguous");const f=l[0],m=I(e),O=H(d.filter(s=>i(s,"scope").startsWith("wire/"))).admitted;(i(f,"by")!==m.id||i(f,"role")!=="writes"||i(f,"form")!=="alphabet"||i(f,"value")!=="lock"||!q(f,m.publicKey,O))&&o("prospective mapping is not Root signed");const w=i(f,"about");let u;try{u=JSON.parse(w)}catch{return o("prospective source mapping JSON invalid")}(!u||Object.keys(u).sort().join(",")!=="bootstrapCheckpoint,inherited,profile,profileSelector,resources,selector"||u.profile!=="place-act-context@1"||JSON.stringify(u)!==w)&&o("unsupported prospective source mapping"),z(u);const c=y((s,R)=>t.filter(C=>i(C,"scope")===s&&i(C,"measure")===R&&i(C,"value")!=="withdraw"),"positive");!a&&(c(r,"text").length!==1||c(u.selector,"text").length!==1)&&o("activation requires source and selection together");const h=t.filter(A).at(-1)??o("prospective authority checkpoint absent");!a&&c(u.bootstrapCheckpoint.scope,u.bootstrapCheckpoint.measure).length!==1&&o("initial authority checkpoint must land with selection");const S=a?le(e):void 0,v=[...new Set([...p,...G(e).flatMap(s=>T(e,s))])],N={history:n,anchor:m,algorithms:O,authorityCheckpoint:h,legacyOriginals:v},x=J({store:b,selector:u.selector,profileSelector:u.profileSelector,...N,resources:{bytes:u.resources.bytes,lines:u.resources.lines,places:u.resources.places},inherited:u.inherited,readCurrent:y(()=>N,"readCurrent"),historical:y(s=>S?S.trust.historical(s):o("committed receiver history precedes initial selection"),"historical")}),j=ie(b,x.trust.initialHeads,x.trust,x.selection.storageBudget),E=S?S.trust.current().heads:x.trust.initialHeads;for(const s of E){const R=j.find(C=>C.place===s.place);(!R||R.identity!==s.identity||R.epoch!==s.epoch)&&o("prospective selection resets committed receiver "+s.place)}}y(ze,"assertProspectiveRootClockSelection");export{ze as assertProspectiveRootClockSelection,le as declaredRootClockSource,Je as hasRootClockSource,He as inspectPortablePlaceContexts,pe as rootClockSelectionOf,ae as rootClockSource};
1
+ var D=Object.defineProperty;var y=(e,t)=>D(e,"name",{value:t,configurable:!0});import{existsSync as U,opendirSync as Q,statSync as V}from"node:fs";import{join as _,basename as Y}from"node:path";import{committedLocalActs as Z,actLines as K}from"./ports/local-act.js";import{verifiedLegacyActResult as $}from"../cli/act-result.js";import{admissionAnchor as I,admissionHistoryAt as L}from"../fold/admission-history.js";import{authorityFor as ee}from"../fold/signers.js";import{signatureEraOf as H}from"./signature-era.js";import{fieldOf as i,foldClaims as F,isConfig as A,selfName as te}from"../fold/claims.js";import{authenticatedRootStanding as W}from"./admitted-place.js";import{verifiesOwnerLine as q}from"../land/sign.js";import{placesIn as G}from"../fold/places.js";import{appliedHistoryIn as T}from"../fold/signed.js";import{storeOf as M}from"../land/ledger.js";import{hostClockSelection as J}from"./place-clock-selection.js";import{library6_readPlaceActContext as B,library6_placeActReceiptsOf as re}from"../vendor/runtime.js";import{placeActResult as oe,placeActHeads as ie}from"./ports/place-act.js";import{rootAuthorityProtection as se}from"../land/act.js";import{readOnly as ce}from"./read-only.js";const o=y(e=>{throw Error("REFUSE\xB7Root cursor "+e)},"fail");function z(e){const t=e?.resources;return(!t||Object.keys(t).sort().join(",")!=="acts,bytes,lines,places"||Object.values(t).some(r=>!Number.isSafeInteger(r)||r<1)||typeof e.selector!="string"||!e.selector||typeof e.profileSelector!="string"||!e.profileSelector||!e.bootstrapCheckpoint||Object.keys(e.bootstrapCheckpoint).sort().join(",")!=="measure,scope"||typeof e.bootstrapCheckpoint.scope!="string"||!e.bootstrapCheckpoint.scope||typeof e.bootstrapCheckpoint.measure!="string"||!e.bootstrapCheckpoint.measure)&&o("missing admitted source selection"),(!e.inherited?.clock||Object.keys(e.inherited.clock).sort().join(",")!=="bytes,placements,policies,proofs,records,signers"||!e.inherited.storage||Object.keys(e.inherited.storage).sort().join(",")!=="acts,bytes"||[...Object.values(e.inherited.clock),...Object.values(e.inherited.storage)].some(r=>!Number.isSafeInteger(r)||r<1))&&o("missing inherited source budgets"),t}y(z,"sourceSelection");function ne(e,t){const r=z(t),p=M(e);let k=0,g=0,a=0;const b=r.acts*(r.places+2)+r.lines;Number.isSafeInteger(b)||o("source file bound");const n=y(d=>{if(!U(d))return;const l=V(d);if(l.isDirectory()){const f=Q(d);try{for(let m=f.readSync();m;m=f.readSync())++a>b&&o("source entry budget"),!(Y(d)==="ledger"&&m.name==="place-acts")&&n(_(d,m.name))}finally{f.closeSync()}}else(!l.isFile()||++g>b||(k+=l.size)>r.bytes)&&o("source file/byte budget")},"visit");n(_(p,"ledger")),n(_(p,te()+".keys"))}y(ne,"boundedInventory");function P(e,t){const r=z(t);ne(e,t);const p=L(e,Number.MAX_SAFE_INTEGER);p.length>r.lines&&o("history line budget");let k=0;for(const c of p)(k+=Buffer.byteLength(c))>r.bytes&&o("history byte budget");const g=Z(M(e));g.length>r.acts&&o("act inventory budget");const a=g.flatMap(c=>{const h=c.bundle.placements?.filter(v=>v.place===".")??[];return h.some(v=>K(v.records).some(A))?[{...$(e,c.identity),identity:c.identity,roots:h}]:[]});a.sort((c,h)=>c.epoch-h.epoch),a.some((c,h)=>h>0&&c.epoch===a[h-1].epoch&&c.identity!==a[h-1].identity)&&o("ambiguous committed Root cursor");const b=a.at(-1),n=I(e);let d;if(b){const c=b.roots.flatMap(h=>K(h.records)).filter(A);c.length||o("verified Root act has no configuration checkpoint"),d=c[0]}else{const c=p.filter(h=>i(h,"scope")===t.bootstrapCheckpoint.scope&&i(h,"measure")===t.bootstrapCheckpoint.measure);c.length!==1&&o("bootstrap checkpoint missing/ambiguous"),d=c[0]}const l=Number(i(d,"epoch"));(!Number.isSafeInteger(l)||l<0)&&o("unknown committed Root epoch");const f=p.filter(c=>!A(c)||Number(i(c,"epoch"))<=l),m=H(F(f.filter(c=>i(c,"scope").startsWith("wire/"))).standing).admitted;ee(f,n,m).of(d).kind!=="admitted"&&o("checkpoint is not authenticated");const w=G(e);w.length>r.places&&o("legacy namespace inventory budget");const u=[...new Set([...p,...w.flatMap(c=>T(e,c))])];return(u.length+f.length>r.lines||u.reduce((c,h)=>c+Buffer.byteLength(h),0)+f.reduce((c,h)=>c+Buffer.byteLength(h),0)>r.bytes)&&o("legacy origin inventory budget"),{history:f,anchor:n,algorithms:m,authorityCheckpoint:d,legacyOriginals:u}}y(P,"current");function ae(e,t){const r=P(e,t),p=new Set,k=new Map,g=y(l=>{const f=k.get(l);if(f)return f;(p.has(l)||p.size>=t.resources.acts)&&o("historical predecessor cycle/budget"),p.add(l);try{const m=B(l,t.inherited.clock),O=m.root.epoch,w=L(e,Number(O)),u=w.filter(v=>A(v)&&i(v,"epoch")===O);u.length||o("historical checkpoint absent");const c=J({...a,history:w,authorityCheckpoint:u[0],legacyOriginals:w,authenticatedReceiverHeads:[],readCurrent:y(()=>P(e,t),"readCurrent")}),h=m.places.map(v=>{const N=c.trust.initialHeads.find(s=>s.place===v.place);if(N?.identity===v.previous)return N;const x=oe(a.store,v.previous,{historical:g},c.selection.storageBudget);x||o("historical predecessor absent");const j=B(x.context,t.inherited.clock),E=j.places.find(s=>s.place===v.place);return E||o("historical predecessor namespace absent"),{place:v.place,identity:v.previous,epoch:E.epoch}}),S=J({...a,history:w,authorityCheckpoint:u[0],legacyOriginals:w,authenticatedReceiverHeads:h,readCurrent:y(()=>P(e,t),"readCurrent")}).trust.contract;return k.set(l,S),S}finally{p.delete(l)}},"historical"),a={store:M(e),selector:t.selector,profileSelector:t.profileSelector,...r,resources:{bytes:t.resources.bytes,lines:t.resources.lines,places:t.resources.places},inherited:t.inherited,readCurrent:y(()=>P(e,t),"readCurrent"),historical:g},b=J(a),n=Object.freeze({...r.anchor,coverage:Object.freeze([...r.anchor.coverage]),depth:Object.freeze({...r.anchor.depth}),admittedBy:Object.freeze([...r.anchor.admittedBy])}),d=Object.freeze({history:Object.freeze([...r.history]),anchor:n,algorithms:Object.freeze([...r.algorithms])});return{...b,observation:d,resources:Object.freeze({...t.resources}),authority:y(l=>{const f=B(l,t.inherited.clock),m=L(e,Number(f.root.epoch)),O=m.filter(w=>A(w)&&i(w,"epoch")===f.root.epoch);return O.length||o("public historical checkpoint absent"),{anchor:r.anchor,history:m,checkpoint:O[0]}},"authority")}}y(ae,"rootClockSource");function pe(e,t){const r=e.filter(b=>i(b,"scope")==="wire/place-act-context-source"&&i(b,"measure")==="text"&&i(b,"value")!=="withdraw");r.length!==1&&o("requires one admitted source mapping");const p=r[0],k=H(e).admitted;(i(p,"by")!==t.id||i(p,"role")!=="writes"||i(p,"form")!=="alphabet"||i(p,"value")!=="lock"||!q(p,t.publicKey,k))&&o("mapping is not Root signed");const g=i(p,"about");let a;try{a=JSON.parse(g)}catch{return o("mapping JSON invalid")}return(!a||Object.keys(a).sort().join(",")!=="bootstrapCheckpoint,inherited,profile,profileSelector,resources,selector"||a.profile!=="place-act-context@1"||JSON.stringify(a)!==g)&&o("unknown/noncanonical mapping"),z(a),a}y(pe,"rootClockSelectionOf");function le(e){return ae(e,pe(W(e),I(e)))}y(le,"declaredRootClockSource");function Je(e){return W(e).some(t=>i(t,"scope")==="wire/place-act-context-source"&&i(t,"measure")==="text"&&i(t,"value")!=="withdraw")}y(Je,"hasRootClockSource");function He(e,t,r){z(r),(typeof e!="string"||Buffer.byteLength(e)>r.resources.bytes)&&o("portable byte budget");let p;try{p=JSON.parse(e)}catch{return o("portable JSON")}(!Array.isArray(p)||p.length>r.resources.acts)&&o("portable context inventory budget");const k=new Map;for(const n of p)(!n||typeof n.identity!="string"||typeof n.context!="string"||!n.authority||JSON.stringify(n.authority.anchor)!==JSON.stringify(t)||!Array.isArray(n.authority.history)||!Array.isArray(n.receipts)||k.has(n.identity))&&o("portable anchor/shape/identity"),k.set(n.identity,n);const g=new Map,a=new Set,b=y(n=>{const d=g.get(n);if(d)return d;const l=k.get(n);(!l||a.has(n))&&o("portable predecessor missing/cyclic"),a.add(n);try{const f=B(l.context,r.inherited.clock),m={store:"",selector:r.selector,profileSelector:r.profileSelector,history:l.authority.history,anchor:t,algorithms:H(F(l.authority.history.filter(S=>i(S,"scope").startsWith("wire/"))).standing).admitted,legacyOriginals:l.authority.history,authorityCheckpoint:l.authority.checkpoint,resources:{bytes:r.resources.bytes,lines:r.resources.lines,places:r.resources.places},inherited:r.inherited,authenticatedReceiverHeads:[],readCurrent:y(()=>o("portable inspection has no current Root authority"),"readCurrent"),historical:y(()=>o("portable inspection uses declared predecessor graph"),"historical")},O=J(m),w=f.places.map(S=>{const v=O.trust.initialHeads.find(j=>j.place===S.place);if(v?.identity===S.previous)return v;const N=b(S.previous),x=N.context.places.find(j=>j.place===S.place);return x||o("portable predecessor namespace"),{place:S.place,identity:S.previous,epoch:x.epoch}}),u=J({...m,authenticatedReceiverHeads:w}).trust.contract;re(l.context,l.receipts,u).identity!==n&&o("portable identity differs");const h={contract:u,context:f};return g.set(n,h),h}finally{a.delete(n)}},"inspect");for(const n of k.keys())b(n);return[...g].map(([n,d])=>({identity:n,context:d.context}))}y(He,"inspectPortablePlaceContexts");function ze(e,t){const r="wire/place-act-context-source",p=L(e,Number.MAX_SAFE_INTEGER),k=[r,"wire/place-act-context-selection","wire/place-act-context"];if(!p.some(s=>i(s,"scope")===r)&&!t.some(s=>k.includes(i(s,"scope"))))return;const g=W(e).filter(s=>i(s,"value")!=="withdraw"),a=g.find(s=>i(s,"scope")===r&&i(s,"measure")==="text");if(a){const s=I(e),R=H(g.filter(X=>i(X,"scope").startsWith("wire/"))).admitted;(i(a,"by")!==s.id||!q(a,s.publicKey,R))&&o("existing source mapping is not Root signed");let C;try{C=JSON.parse(i(a,"about"))}catch{return o("existing source mapping JSON invalid")}k.push(C.selector,C.profileSelector)}if(!t.some(s=>k.includes(i(s,"scope")))||t.every(s=>p.includes(s)))return;const b=M(e);ce()||se(b);const n=[...new Set([...p,...t])],d=F([...g,...t].filter(A)).standing.filter(s=>i(s,"value")!=="withdraw"),l=d.filter(s=>i(s,"scope")===r&&i(s,"measure")==="text");if(!l.length)return t.some(s=>i(s,"scope")===r&&i(s,"value")==="withdraw")?void 0:o("activation requires source and selection together");l.length!==1&&o("prospective source mapping ambiguous");const f=l[0],m=I(e),O=H(d.filter(s=>i(s,"scope").startsWith("wire/"))).admitted;(i(f,"by")!==m.id||i(f,"role")!=="writes"||i(f,"form")!=="alphabet"||i(f,"value")!=="lock"||!q(f,m.publicKey,O))&&o("prospective mapping is not Root signed");const w=i(f,"about");let u;try{u=JSON.parse(w)}catch{return o("prospective source mapping JSON invalid")}(!u||Object.keys(u).sort().join(",")!=="bootstrapCheckpoint,inherited,profile,profileSelector,resources,selector"||u.profile!=="place-act-context@1"||JSON.stringify(u)!==w)&&o("unsupported prospective source mapping"),z(u);const c=y((s,R)=>t.filter(C=>i(C,"scope")===s&&i(C,"measure")===R&&i(C,"value")!=="withdraw"),"positive");!a&&(c(r,"text").length!==1||c(u.selector,"text").length!==1)&&o("activation requires source and selection together");const h=t.filter(A).at(-1)??o("prospective authority checkpoint absent");!a&&c(u.bootstrapCheckpoint.scope,u.bootstrapCheckpoint.measure).length!==1&&o("initial authority checkpoint must land with selection");const S=a?le(e):void 0,v=[...new Set([...p,...G(e).flatMap(s=>T(e,s))])],N={history:n,anchor:m,algorithms:O,authorityCheckpoint:h,legacyOriginals:v},x=J({store:b,selector:u.selector,profileSelector:u.profileSelector,...N,resources:{bytes:u.resources.bytes,lines:u.resources.lines,places:u.resources.places},inherited:u.inherited,readCurrent:y(()=>N,"readCurrent"),historical:y(s=>S?S.trust.historical(s):o("committed receiver history precedes initial selection"),"historical")}),j=ie(b,x.trust.initialHeads,x.trust,x.selection.storageBudget),E=S?S.trust.current().heads:x.trust.initialHeads;for(const s of E){const R=j.find(C=>C.place===s.place);(!R||R.identity!==s.identity||R.epoch!==s.epoch)&&o("prospective selection resets committed receiver "+s.place)}}y(ze,"assertProspectiveRootClockSelection");export{ze as assertProspectiveRootClockSelection,le as declaredRootClockSource,Je as hasRootClockSource,He as inspectPortablePlaceContexts,pe as rootClockSelectionOf,ae as rootClockSource};
@@ -1 +1 @@
1
- var R=Object.defineProperty;var n=(l,c)=>R(l,"name",{value:c,configurable:!0});import{capsuleAt as k}from"./capsule.js";import{library7_capsuleOffers as A,library7_providerInputs as S,library7_providerInputRegions as D,library7_capsuleDescriptor as F,library7_assertCapsuleDescriptor as I}from"../vendor/runtime.js";import{fullDigest as j}from"./digest.js";import{library11_wireAt as C,library11_parse as U}from"../vendor/runtime.js";import{selectedTopoi as M,toposAt as O}from"./selected-topos.js";import{library11_canonical as $}from"../vendor/runtime.js";import{fieldOf as p}from"../fold/claims.js";import{ownLock as b}from"../observe/runner.js";import{archiveCoordinate as N}from"./archive.js";function Q(l,c=k,w=O,_=b()){return M(l,w).flatMap(({digest:o,topos:i})=>A(i).map(e=>{const h=n(()=>{const r=_.filter(t=>p(t,"scope").startsWith("dep/")&&p(t,"role")==="writes"&&p(t,"value")===e.value);if(!r.length||r.some(t=>!p(t,"shape")))throw Error(`REFUSE\xB7pin ${o} capsule ${e.value} needs one host projection`);const s=[...new Set(r.map(t=>N(p(t,"shape"))))];if(s.length!==1)throw Error(`REFUSE\xB7pin ${o} capsule ${e.value} has conflicting host projections`);const a=c(e.value,s[0]);if(a===void 0)throw Error(`REFUSE\xB7pin ${o} \xB7 ${e.scope} \xB7 offered capsule ${e.value} unavailable`);return{capsule:a,offer:$({...e,shape:s[0]})}},"load"),u=F(i,e.scope??""),d=u===void 0?h():void 0,m={...d===void 0?{digest:e.value,selection:`${o} ${e.scope}`,...u,ask:n((r,s)=>{if(!r.length)return[];const a=h();return I(u.lines,a.capsule.lines),a.capsule.ask(r,s)},"ask")}:{...d.capsule,selection:`${o} ${e.scope}`},selectedWorld:{standing:i,offer:e.scope??""}},v=d?.offer??$(e);if(!D(i,e.scope??"").length)return{capsule:m,offer:v};const g=b().flatMap(r=>{const s=U(r);return s.kind==="fact"?[s.value.fields]:[]}),f=C(g,Number.MAX_SAFE_INTEGER),E=f&&[...f.digests][0];if(!E)throw Error("REFUSE\xB7input instrument has no admitted digest algorithm");return{capsule:{...m,selection:`${o} ${e.scope}`,ask:n((r,s)=>m.ask(r.map(a=>{const t=S(i,o,e.scope??"",e.value,a.region??"",y=>j(y,E));return t===void 0?a:{...a,provider:t}}),s),"ask")},offer:v}}))}n(Q,"selectedCapsules");export{Q as selectedCapsules};
1
+ var R=Object.defineProperty;var n=(l,c)=>R(l,"name",{value:c,configurable:!0});import{capsuleAt as k}from"./capsule.js";import{library10_capsuleOffers as A,library10_providerInputs as S,library10_providerInputRegions as D,library10_capsuleDescriptor as F,library10_assertCapsuleDescriptor as I}from"../vendor/runtime.js";import{fullDigest as j}from"./digest.js";import{library14_wireAt as C,library14_parse as U}from"../vendor/runtime.js";import{selectedTopoi as M,toposAt as O}from"./selected-topos.js";import{library14_canonical as $}from"../vendor/runtime.js";import{fieldOf as p}from"../fold/claims.js";import{ownLock as b}from"../observe/runner.js";import{archiveCoordinate as N}from"./archive.js";function Q(l,c=k,w=O,_=b()){return M(l,w).flatMap(({digest:o,topos:i})=>A(i).map(e=>{const h=n(()=>{const r=_.filter(t=>p(t,"scope").startsWith("dep/")&&p(t,"role")==="writes"&&p(t,"value")===e.value);if(!r.length||r.some(t=>!p(t,"shape")))throw Error(`REFUSE\xB7pin ${o} capsule ${e.value} needs one host projection`);const s=[...new Set(r.map(t=>N(p(t,"shape"))))];if(s.length!==1)throw Error(`REFUSE\xB7pin ${o} capsule ${e.value} has conflicting host projections`);const a=c(e.value,s[0]);if(a===void 0)throw Error(`REFUSE\xB7pin ${o} \xB7 ${e.scope} \xB7 offered capsule ${e.value} unavailable`);return{capsule:a,offer:$({...e,shape:s[0]})}},"load"),u=F(i,e.scope??""),d=u===void 0?h():void 0,m={...d===void 0?{digest:e.value,selection:`${o} ${e.scope}`,...u,ask:n((r,s)=>{if(!r.length)return[];const a=h();return I(u.lines,a.capsule.lines),a.capsule.ask(r,s)},"ask")}:{...d.capsule,selection:`${o} ${e.scope}`},selectedWorld:{standing:i,offer:e.scope??""}},v=d?.offer??$(e);if(!D(i,e.scope??"").length)return{capsule:m,offer:v};const g=b().flatMap(r=>{const s=U(r);return s.kind==="fact"?[s.value.fields]:[]}),f=C(g,Number.MAX_SAFE_INTEGER),E=f&&[...f.digests][0];if(!E)throw Error("REFUSE\xB7input instrument has no admitted digest algorithm");return{capsule:{...m,selection:`${o} ${e.scope}`,ask:n((r,s)=>m.ask(r.map(a=>{const t=S(i,o,e.scope??"",e.value,a.region??"",y=>j(y,E));return t===void 0?a:{...a,provider:t}}),s),"ask")},offer:v}}))}n(Q,"selectedCapsules");export{Q as selectedCapsules};
@@ -1 +1 @@
1
- var b=Object.defineProperty;var a=(t,r)=>b(t,"name",{value:r,configurable:!0});import{verifiedContent as S}from"./content-store.js";import{library7_readStanding as O}from"../vendor/runtime.js";import{library11_parse as F,library11_wireAt as m,library11_fromLine as g}from"../vendor/runtime.js";import{fieldOf as x}from"../fold/claims.js";import{moduleClosure as M}from"./native/module-closure.js";import{sha256 as N,isSha256 as y}from"./hash.js";function J(t,r,o,s,f=p){const n=m(r,o);if(n&&["fields","required","roles","forms","at-classes"].every(i=>n.lists.has(i))){const i=g(t,n),u=x(t,"type")!==""&&!n.object;if(i.kind==="fact"||i.kind==="refuse"&&!u)return i}return g(t,_(r,o,s,f))}a(J,"admittedLine");function p(t,r){return O(Buffer.from(v(t,r)).toString("utf8"))}a(p,"toposAt");function v(t,r){return S(t,r).bytes}a(v,"contentAt");function R(t,r,o){if(!Array.isArray(o)||!y(t)||!o.includes(t)||o.some(n=>!y(n)))throw Error("REFUSE\xB7context module closure requires declared SHA-256 members");const s=[...new Set(o)].sort(),f=new Map(s.map(n=>[n.slice(n.indexOf(":")+1),{digest:n,source:new TextDecoder("utf-8",{fatal:!0}).decode(v(n,r))}]));return M({identity:N(JSON.stringify(s)),entry:t.slice(t.indexOf(":")+1),members:f},()=>{},{esmOnly:!0}),S(t,r).path}a(R,"contextModuleAt");function q(t){const r=new Map;return{topos:a(o=>{const s=p(o,t);for(const f of s.parts.filter(n=>n.kind==="check"&&n.value)){const n=[...new Set((f.restsOn??"").split("|").filter(Boolean))].sort(),i=r.get(f.value);if(i&&JSON.stringify(i)!==JSON.stringify(n))throw Error("REFUSE\xB7context module has conflicting declared closures");r.set(f.value,n)}return s},"topos"),module:a(o=>{const s=r.get(o);if(s===void 0)throw Error("REFUSE\xB7context module has no declared closure");return R(o,t,s)},"module")}}a(q,"contextProviderServices");function A(t,r=p){return[...new Set(t.map(o=>x(o,"value")))].map(o=>({digest:o,topos:r(o)}))}a(A,"selectedTopoi");function B(t,r,o,s,f=p){const n=t.flatMap(c=>{const e=F(c);return e.kind==="fact"?[e.value.fields]:[]}),i=[{name:"place",wire:m(n,r)},...A(o,f).map(({digest:c,topos:e})=>({name:c,wire:m(e.parts,Number.MAX_SAFE_INTEGER)}))].flatMap(({name:c,wire:e})=>{const d=e?.lists.get(s);return d===void 0?[]:[{name:c,words:[...d]}]});if(!i.length)throw Error(`REFUSE\xB7wire wire/${s} has no declared contract in the place or its selected topoi`);const u=i[0];if(i.some(({words:c})=>c.length!==u.words.length||c.some(e=>!u.words.includes(e))))throw Error(`REFUSE\xB7wire wire/${s} has conflicting contracts \xB7 ${i.map(c=>c.name).join(" \xB7 ")}`);return u.words}a(B,"selectedWireList");function _(t,r,o,s=p){const f=m(t,r),n=A(o,s).map(({digest:e,topos:d})=>({digest:e,parts:d.parts,wire:m(d.parts,Number.MAX_SAFE_INTEGER)})),i=a(e=>e.startsWith("wire/")?e.slice(5):e.startsWith("audit/wire/")?e.slice(11):void 0,"key"),u=new Set(t.filter(e=>Number(e.epoch??0)<=r).map(e=>i(e.scope??"")).filter(e=>e!==void 0)),c=new Map;for(const e of n)for(const d of e.parts){const l=i(d.scope??"");if(l===void 0||u.has(l))continue;const E=e.wire?.lists.get(l),h=E?[...E].sort().join("|"):d.value??"",w=c.get(l);if(w&&w.value!==h)throw Error(`REFUSE\xB7wire wire/${l} has conflicting selected contracts \xB7 ${w.digest} \xB7 ${e.digest}`);w||c.set(l,{value:h,fields:d,digest:e.digest})}return c.size?m([...c.values()].map(e=>e.fields).concat(t),r):f}a(_,"selectedWireAt");export{J as admittedLine,v as contentAt,R as contextModuleAt,q as contextProviderServices,A as selectedTopoi,_ as selectedWireAt,B as selectedWireList,p as toposAt};
1
+ var b=Object.defineProperty;var a=(t,r)=>b(t,"name",{value:r,configurable:!0});import{verifiedContent as S}from"./content-store.js";import{library10_readStanding as O}from"../vendor/runtime.js";import{library14_parse as F,library14_wireAt as m,library14_fromLine as g}from"../vendor/runtime.js";import{fieldOf as x}from"../fold/claims.js";import{moduleClosure as M}from"./native/module-closure.js";import{sha256 as N,isSha256 as y}from"./hash.js";function J(t,r,o,s,f=p){const n=m(r,o);if(n&&["fields","required","roles","forms","at-classes"].every(i=>n.lists.has(i))){const i=g(t,n),u=x(t,"type")!==""&&!n.object;if(i.kind==="fact"||i.kind==="refuse"&&!u)return i}return g(t,_(r,o,s,f))}a(J,"admittedLine");function p(t,r){return O(Buffer.from(v(t,r)).toString("utf8"))}a(p,"toposAt");function v(t,r){return S(t,r).bytes}a(v,"contentAt");function R(t,r,o){if(!Array.isArray(o)||!y(t)||!o.includes(t)||o.some(n=>!y(n)))throw Error("REFUSE\xB7context module closure requires declared SHA-256 members");const s=[...new Set(o)].sort(),f=new Map(s.map(n=>[n.slice(n.indexOf(":")+1),{digest:n,source:new TextDecoder("utf-8",{fatal:!0}).decode(v(n,r))}]));return M({identity:N(JSON.stringify(s)),entry:t.slice(t.indexOf(":")+1),members:f},()=>{},{esmOnly:!0}),S(t,r).path}a(R,"contextModuleAt");function q(t){const r=new Map;return{topos:a(o=>{const s=p(o,t);for(const f of s.parts.filter(n=>n.kind==="check"&&n.value)){const n=[...new Set((f.restsOn??"").split("|").filter(Boolean))].sort(),i=r.get(f.value);if(i&&JSON.stringify(i)!==JSON.stringify(n))throw Error("REFUSE\xB7context module has conflicting declared closures");r.set(f.value,n)}return s},"topos"),module:a(o=>{const s=r.get(o);if(s===void 0)throw Error("REFUSE\xB7context module has no declared closure");return R(o,t,s)},"module")}}a(q,"contextProviderServices");function A(t,r=p){return[...new Set(t.map(o=>x(o,"value")))].map(o=>({digest:o,topos:r(o)}))}a(A,"selectedTopoi");function B(t,r,o,s,f=p){const n=t.flatMap(c=>{const e=F(c);return e.kind==="fact"?[e.value.fields]:[]}),i=[{name:"place",wire:m(n,r)},...A(o,f).map(({digest:c,topos:e})=>({name:c,wire:m(e.parts,Number.MAX_SAFE_INTEGER)}))].flatMap(({name:c,wire:e})=>{const d=e?.lists.get(s);return d===void 0?[]:[{name:c,words:[...d]}]});if(!i.length)throw Error(`REFUSE\xB7wire wire/${s} has no declared contract in the place or its selected topoi`);const u=i[0];if(i.some(({words:c})=>c.length!==u.words.length||c.some(e=>!u.words.includes(e))))throw Error(`REFUSE\xB7wire wire/${s} has conflicting contracts \xB7 ${i.map(c=>c.name).join(" \xB7 ")}`);return u.words}a(B,"selectedWireList");function _(t,r,o,s=p){const f=m(t,r),n=A(o,s).map(({digest:e,topos:d})=>({digest:e,parts:d.parts,wire:m(d.parts,Number.MAX_SAFE_INTEGER)})),i=a(e=>e.startsWith("wire/")?e.slice(5):e.startsWith("audit/wire/")?e.slice(11):void 0,"key"),u=new Set(t.filter(e=>Number(e.epoch??0)<=r).map(e=>i(e.scope??"")).filter(e=>e!==void 0)),c=new Map;for(const e of n)for(const d of e.parts){const l=i(d.scope??"");if(l===void 0||u.has(l))continue;const E=e.wire?.lists.get(l),h=E?[...E].sort().join("|"):d.value??"",w=c.get(l);if(w&&w.value!==h)throw Error(`REFUSE\xB7wire wire/${l} has conflicting selected contracts \xB7 ${w.digest} \xB7 ${e.digest}`);w||c.set(l,{value:h,fields:d,digest:e.digest})}return c.size?m([...c.values()].map(e=>e.fields).concat(t),r):f}a(_,"selectedWireAt");export{J as admittedLine,v as contentAt,R as contextModuleAt,q as contextProviderServices,A as selectedTopoi,_ as selectedWireAt,B as selectedWireList,p as toposAt};
@@ -1,2 +1,2 @@
1
- var d=Object.defineProperty;var a=(t,n)=>d(t,"name",{value:n,configurable:!0});import{invokeSigningPort as h}from"../engine/ports.js";import{readFileSync as w}from"node:fs";import{library11_parse as S,library11_signerSelection as b,library11_signerRequestBytes as E,library11_signerResponseBytes as l,library11_signerResponseOf as p}from"../vendor/runtime.js";import{invokeSigner as u,SigningFailure as c}from"./ports/signing.js";function y(t,n){if(t==="file"){if(!n)throw new c("REFUSE\xB7signer file needs --key-file");return{kind:"file",path:n}}if(n)throw new c("REFUSE\xB7signer command cannot use --key-file");const o=process.env.BOUND_SIGNERS;if(!o)throw new c("REFUSE\xB7signer no host binding registry");try{const i=JSON.parse(w(o,"utf8"));if(!i||typeof i!="object"||!Object.prototype.hasOwnProperty.call(i,t))throw Error();const r=i[t];if(!r||typeof r!="object")throw Error();const e=r;if(e.kind!=="command"||typeof e.executable!="string"||!e.executable||!Array.isArray(e.args)||!e.args.every(s=>typeof s=="string"))throw Error();return{kind:"command",executable:e.executable,args:e.args}}catch{throw new c("REFUSE\xB7signer host binding unavailable or invalid")}}a(y,"binding");function m(t,n,o){const i=t.flatMap(e=>{const s=S(e);return s.kind==="fact"?[s.value.fields]:[]}),r=b(i,n);if(o!==void 0&&o!==r.name)throw new c(`REFUSE\xB7signer ${n} CLI selection conflicts with declaration`);return r}a(m,"declaredSigner");function O(t,n,o,i,r){const e=m(t,n,o);if(r){if(r.name!==e.name||i)throw new c("REFUSE\xB7signer injected host binding conflicts with declaration or key file");return g=>h(g,r.sign,{timeoutMs:e.timeoutMs,maxBytes:e.responseBytes},r.signal)}const s=y(e.name,i),f={request:E,response:l,reply:p};return g=>u(g,s,f,e)}a(O,"signerFor");function U(t,n,o,i){const r=m(t,n,o),e=y(r.name,i),s={request:a(f=>JSON.stringify(f)+`
2
- `,"request"),response:l,reply:p};return f=>u(f,e,s,r)}a(U,"frameSignerFor");export{U as frameSignerFor,O as signerFor};
1
+ var S=Object.defineProperty;var a=(t,n)=>S(t,"name",{value:n,configurable:!0});import{AsyncLocalStorage as b}from"node:async_hooks";import{BoundRefusal as l}from"./refusals.js";import{invokeSigningPort as E}from"../engine/ports.js";import{readFileSync as R}from"node:fs";import{library14_parse as v,library14_signerSelection as F,library14_signerRequestBytes as U,library14_signerResponseBytes as u,library14_signerResponseOf as p}from"../vendor/runtime.js";import{invokeSigner as m,SigningFailure as c}from"./ports/signing.js";const h=new b,A=a((t,n)=>h.run(t,n),"withNativeSigning");function y(t,n){if(t==="file"){if(!n)throw new c("REFUSE\xB7signer file needs --key-file");return{kind:"file",path:n}}if(n)throw new c("REFUSE\xB7signer command cannot use --key-file");const s=process.env.BOUND_SIGNERS;if(!s)throw new c("REFUSE\xB7signer no host binding registry");try{const i=JSON.parse(R(s,"utf8"));if(!i||typeof i!="object"||!Object.prototype.hasOwnProperty.call(i,t))throw Error();const e=i[t];if(!e||typeof e!="object")throw Error();const r=e;if(r.kind!=="command"||typeof r.executable!="string"||!r.executable||!Array.isArray(r.args)||!r.args.every(o=>typeof o=="string"))throw Error();return{kind:"command",executable:r.executable,args:r.args}}catch{throw new c("REFUSE\xB7signer host binding unavailable or invalid")}}a(y,"binding");function d(t,n,s){const i=t.flatMap(r=>{const o=v(r);return o.kind==="fact"?[o.value.fields]:[]}),e=F(i,n);if(s!==void 0&&s!==e.name)throw new c(`REFUSE\xB7signer ${n} CLI selection conflicts with declaration`);return e}a(d,"declaredSigner");function M(t,n,s,i,e){const r=h.getStore();if(!e&&r){if(r.bound===!1)throw new l("host/unbound-signer","REFUSE\xB7host/unbound-signer");if(r.keyId!==n)throw new l("host/signer-mismatch","REFUSE\xB7host/signer-mismatch");e=r}const o=d(t,n,s);if(e){if(e.name!==o.name||i)throw new c("REFUSE\xB7signer injected host binding conflicts with declaration or key file");return g=>E(g,e.sign,{timeoutMs:o.timeoutMs,maxBytes:o.responseBytes},e.signal)}const f=y(o.name,i),w={request:U,response:u,reply:p};return g=>m(g,f,w,o)}a(M,"signerFor");function J(t,n,s,i){const e=d(t,n,s),r=y(e.name,i),o={request:a(f=>JSON.stringify(f)+`
2
+ `,"request"),response:u,reply:p};return f=>m(f,r,o,e)}a(J,"frameSignerFor");export{J as frameSignerFor,M as signerFor,A as withNativeSigning};
@@ -1,2 +1,2 @@
1
- var $=Object.defineProperty;var s=(c,i)=>$(c,"name",{value:i,configurable:!0});import{hostOutput as F}from"./call-context.js";import{transportBytes as R}from"./ports/transport.js";import{contentStore as A,verifiedContent as U}from"./content-store.js";import{ContentNeeded as x}from"./content-needed.js";import{createHash as k}from"node:crypto";import{library11_parse as y,library11_wireAt as C}from"../vendor/runtime.js";import{landBlob as M}from"../land/ledger.js";import{ownLock as S}from"../observe/runner.js";async function _(c,i,u){const n=c.flatMap(e=>{const t=y(e);return t.kind==="fact"&&t.value.fields.value!=="withdraw"?[t.value.fields]:[]}),h=s(e=>{const t=/(^|\/)uses\//.exec(e);return t===null?-1:t.index+t[1].length},"selectionIndex"),E=n.filter(e=>h(e.scope??"")>=0||e.scope?.startsWith("dep/")&&(e.measure==="digest"||/^[a-zA-Z][a-zA-Z0-9-]*:[a-f0-9]+$/.test(e.value??""))),r=new Map;for(const e of E){const t=e.scope??"",a=h(t),l=a>=0?t.slice(0,a)+"sources/"+t.slice(a+5):"sources/"+t.slice(4),d=n.filter(f=>f.scope===l).map(f=>f.value??"");d.length&&r.set(e.value??"",[...new Set([...r.get(e.value??"")??[],...d])])}const o=[],p=s(e=>{const t=e.indexOf(":"),a=e.slice(0,t),l=e.slice(t+1);if(t<1||!i.algorithms.has(a)||!/^[a-f0-9]+$/.test(l))throw Error(`REFUSE\xB7pin ${e} digest is not admitted`);return{algorithm:a,hex:l}},"validate"),b=s(async e=>{const{algorithm:t,hex:a}=p(e),l=s(m=>{if(k(t).update(m).digest("hex")!==a)throw Error(`REFUSE\xB7pin ${e} content hash mismatch \xB7 not laid`);return m},"verify"),d=i.read(e);if(d!==void 0)return l(d);const f=r.get(e)??[];if(!f.length)throw Error(`REFUSE\xB7pin ${e} content unavailable \xB7 no declared source \xB7 not laid`);let v;for(const m of f){let w;try{w=await i.fetch(m,e)}catch(g){v=g;continue}return l(w),i.write(e,w),o.push(e),w}throw Error(`REFUSE\xB7source ${e} ${v instanceof Error?v.message:"declared sources unavailable"}`)},"ensure");for(const e of new Set(u))await b(e);return o}s(_,"resolveSelectedContent");async function q(c,i){const u=S().flatMap(r=>{const o=y(r);return o.kind==="fact"?[o.value.fields]:[]}),n=C(u,Number.MAX_SAFE_INTEGER);if(n===null)throw Error("REFUSE\xB7pin instrument has no admitted wire");const h=S().filter(r=>{const o=y(r);if(o.kind!=="fact")return!1;const p=o.value.fields;return p.scope?.startsWith("sources/")||p.scope?.startsWith("dep/")}),E=await _([...c,...h],{algorithms:n.digests,read:s(r=>{try{return U(r).bytes}catch(o){if(o instanceof x)return;throw o}},"read"),write:s((r,o)=>{M(A(),r,o)},"write"),fetch:s(async(r,o)=>R(r,o,[...S(),...c]),"fetch")},i);for(const r of E)F("out",`FETCHED ${r} \xB7 verified
1
+ var $=Object.defineProperty;var s=(c,i)=>$(c,"name",{value:i,configurable:!0});import{hostOutput as F}from"./call-context.js";import{transportBytes as R}from"./ports/transport.js";import{contentStore as A,verifiedContent as U}from"./content-store.js";import{ContentNeeded as x}from"./content-needed.js";import{createHash as k}from"node:crypto";import{library14_parse as y,library14_wireAt as C}from"../vendor/runtime.js";import{landBlob as M}from"../land/ledger.js";import{ownLock as S}from"../observe/runner.js";async function _(c,i,u){const n=c.flatMap(e=>{const t=y(e);return t.kind==="fact"&&t.value.fields.value!=="withdraw"?[t.value.fields]:[]}),h=s(e=>{const t=/(^|\/)uses\//.exec(e);return t===null?-1:t.index+t[1].length},"selectionIndex"),E=n.filter(e=>h(e.scope??"")>=0||e.scope?.startsWith("dep/")&&(e.measure==="digest"||/^[a-zA-Z][a-zA-Z0-9-]*:[a-f0-9]+$/.test(e.value??""))),r=new Map;for(const e of E){const t=e.scope??"",a=h(t),l=a>=0?t.slice(0,a)+"sources/"+t.slice(a+5):"sources/"+t.slice(4),d=n.filter(f=>f.scope===l).map(f=>f.value??"");d.length&&r.set(e.value??"",[...new Set([...r.get(e.value??"")??[],...d])])}const o=[],p=s(e=>{const t=e.indexOf(":"),a=e.slice(0,t),l=e.slice(t+1);if(t<1||!i.algorithms.has(a)||!/^[a-f0-9]+$/.test(l))throw Error(`REFUSE\xB7pin ${e} digest is not admitted`);return{algorithm:a,hex:l}},"validate"),b=s(async e=>{const{algorithm:t,hex:a}=p(e),l=s(m=>{if(k(t).update(m).digest("hex")!==a)throw Error(`REFUSE\xB7pin ${e} content hash mismatch \xB7 not laid`);return m},"verify"),d=i.read(e);if(d!==void 0)return l(d);const f=r.get(e)??[];if(!f.length)throw Error(`REFUSE\xB7pin ${e} content unavailable \xB7 no declared source \xB7 not laid`);let v;for(const m of f){let w;try{w=await i.fetch(m,e)}catch(g){v=g;continue}return l(w),i.write(e,w),o.push(e),w}throw Error(`REFUSE\xB7source ${e} ${v instanceof Error?v.message:"declared sources unavailable"}`)},"ensure");for(const e of new Set(u))await b(e);return o}s(_,"resolveSelectedContent");async function q(c,i){const u=S().flatMap(r=>{const o=y(r);return o.kind==="fact"?[o.value.fields]:[]}),n=C(u,Number.MAX_SAFE_INTEGER);if(n===null)throw Error("REFUSE\xB7pin instrument has no admitted wire");const h=S().filter(r=>{const o=y(r);if(o.kind!=="fact")return!1;const p=o.value.fields;return p.scope?.startsWith("sources/")||p.scope?.startsWith("dep/")}),E=await _([...c,...h],{algorithms:n.digests,read:s(r=>{try{return U(r).bytes}catch(o){if(o instanceof x)return;throw o}},"read"),write:s((r,o)=>{M(A(),r,o)},"write"),fetch:s(async(r,o)=>R(r,o,[...S(),...c]),"fetch")},i);for(const r of E)F("out",`FETCHED ${r} \xB7 verified
2
2
  `)}s(q,"resolveSources");async function D(c,i){const u=new Set;for(;;)try{return await i()}catch(n){if(!(n instanceof x)||u.has(n.digest))throw n;u.add(n.digest),await c(n.digest)}}s(D,"resolveRequested");export{D as resolveRequested,_ as resolveSelectedContent,q as resolveSources};
@@ -1 +1 @@
1
- var y=Object.defineProperty;var l=(n,a)=>y(n,"name",{value:a,configurable:!0});import{library3_PLACE_ACT_CONTEXT as u}from"../vendor/runtime.js";import{foldClaims as p,fieldOf as d}from"../fold/claims.js";function h(n,a,r,f){const o=new Map;for(const e of r){const t=f.find(s=>s.identity===e.identity).context;for(const s of t.places){const i=JSON.stringify([t.root.namespace,s.place]),c=o.get(i)??{namespace:t.root.namespace,place:s.place,lines:[],contexts:[]};c.lines.push(...s.records),c.contexts.push({identity:e.identity,context:e.context,receipts:e.receipts}),o.set(i,c)}}const m=a.map(e=>({namespace:"legacy-global",place:e.place,standing:p(e.history).standing.filter(t=>d(t,"value")!=="withdraw"),history:e.history}));return{profile:u,root:n,legacyPlaces:m,contexts:r,places:[...o.values()].map(e=>{const t=p(e.lines);return{namespace:e.namespace,place:e.place,standing:t.standing.filter(s=>d(s,"value")!=="withdraw"),retracted:t.retracted,superseded:t.superseded,forks:t.forks,contexts:e.contexts}})}}l(h,"projectContextualStanding");export{h as projectContextualStanding};
1
+ var y=Object.defineProperty;var l=(n,a)=>y(n,"name",{value:a,configurable:!0});import{library6_PLACE_ACT_CONTEXT as u}from"../vendor/runtime.js";import{foldClaims as p,fieldOf as d}from"../fold/claims.js";function h(n,a,r,f){const o=new Map;for(const e of r){const t=f.find(s=>s.identity===e.identity).context;for(const s of t.places){const i=JSON.stringify([t.root.namespace,s.place]),c=o.get(i)??{namespace:t.root.namespace,place:s.place,lines:[],contexts:[]};c.lines.push(...s.records),c.contexts.push({identity:e.identity,context:e.context,receipts:e.receipts}),o.set(i,c)}}const m=a.map(e=>({namespace:"legacy-global",place:e.place,standing:p(e.history).standing.filter(t=>d(t,"value")!=="withdraw"),history:e.history}));return{profile:u,root:n,legacyPlaces:m,contexts:r,places:[...o.values()].map(e=>{const t=p(e.lines);return{namespace:e.namespace,place:e.place,standing:t.standing.filter(s=>d(s,"value")!=="withdraw"),retracted:t.retracted,superseded:t.superseded,forks:t.forks,contexts:e.contexts}})}}l(h,"projectContextualStanding");export{h as projectContextualStanding};
@@ -1 +1 @@
1
- var w=Object.defineProperty;var e=(i,t)=>w(i,"name",{value:t,configurable:!0});import{viewsOf as h}from"../fold/views.js";import{BoundRefusal as v}from"./refusals.js";import{authorityFor as b}from"../fold/signers.js";import{signatureEraOf as E}from"./signature-era.js";import{fieldOf as a,foldClaims as p,isConfig as u}from"../fold/claims.js";import{library2_foldedEvidence as S}from"../vendor/runtime.js";function x(i,t){const n=new Map,m=i.filter(o=>{const d=Number(a(o,"epoch"))||0;let r=n.get(d);if(!r){const f=i.filter(s=>!u(s)||Number(a(s,"epoch"))<=d),g=f.filter(s=>{const c=a(s,"scope");return c.startsWith("wire/")||c.startsWith("audit/wire/")});r=b(f,t,E(p(g).standing).admitted),n.set(d,r)}return r.of(o).kind==="admitted"}),{standing:l}=S(m,{classification:e(()=>"local","classification"),fold:e(o=>p(o).standing,"fold")});return[...l]}e(x,"projectAuthenticatedStanding");function k(i){const t=h(i).get("standing");if(!t||t.shape||!t.regions.some(n=>n.name==="standing"))throw new v("standing/view","REFUSE\xB7view standing requires a declared standing view")}e(k,"assertStandingView");function q(i,t){return O(x(i,t))}e(q,"publicStandingProjection");function O(i){return i.filter(t=>!u(t)||a(t,"value")!=="withdraw")}e(O,"publishedStandingLines");export{k as assertStandingView,x as projectAuthenticatedStanding,q as publicStandingProjection,O as publishedStandingLines};
1
+ var w=Object.defineProperty;var e=(i,t)=>w(i,"name",{value:t,configurable:!0});import{viewsOf as h}from"../fold/views.js";import{BoundRefusal as v}from"./refusals.js";import{authorityFor as b}from"../fold/signers.js";import{signatureEraOf as E}from"./signature-era.js";import{fieldOf as a,foldClaims as p,isConfig as u}from"../fold/claims.js";import{library5_foldedEvidence as S}from"../vendor/runtime.js";function x(i,t){const n=new Map,m=i.filter(o=>{const d=Number(a(o,"epoch"))||0;let r=n.get(d);if(!r){const f=i.filter(s=>!u(s)||Number(a(s,"epoch"))<=d),g=f.filter(s=>{const c=a(s,"scope");return c.startsWith("wire/")||c.startsWith("audit/wire/")});r=b(f,t,E(p(g).standing).admitted),n.set(d,r)}return r.of(o).kind==="admitted"}),{standing:l}=S(m,{classification:e(()=>"local","classification"),fold:e(o=>p(o).standing,"fold")});return[...l]}e(x,"projectAuthenticatedStanding");function k(i){const t=h(i).get("standing");if(!t||t.shape||!t.regions.some(n=>n.name==="standing"))throw new v("standing/view","REFUSE\xB7view standing requires a declared standing view")}e(k,"assertStandingView");function q(i,t){return O(x(i,t))}e(q,"publicStandingProjection");function O(i){return i.filter(t=>!u(t)||a(t,"value")!=="withdraw")}e(O,"publishedStandingLines");export{k as assertStandingView,x as projectAuthenticatedStanding,q as publicStandingProjection,O as publishedStandingLines};
@@ -1 +1 @@
1
- var c=Object.defineProperty;var o=(t,n)=>c(t,"name",{value:n,configurable:!0});const g=o(t=>(n,e)=>{const s=Date.now(),a=e();return t.push(`${n} ${Date.now()-s}`),a},"timing");export{g as timing};
1
+ var s=Object.defineProperty;var n=(o,t)=>s(o,"name",{value:t,configurable:!0});import{traceWork as a}from"./work-trace.js";const p=n(o=>(t,r)=>{const e=Date.now(),c=a(t,r);return o.push(`${t} ${Date.now()-e}`),c},"timing");export{p as timing};
package/dist/host/walk.js CHANGED
@@ -1,4 +1,4 @@
1
- var it=Object.defineProperty;var l=(t,e)=>it(t,"name",{value:e,configurable:!0});import{library10_walkProjection as nt,library10_walkAt as rt,library10_walkSnapshot as M,library10_walkHeaders as ot,library10_readWalkHeaders as U,library10_readForeignWalk as $,library10_walkAuthority as at,library10_walkOrigin as st,library10_walkInventory as ct,library10_walkSelection as z,library10_isWalkHeader as G}from"../vendor/runtime.js";import{library11_canonical as R,library11_parse as dt,library11_fromLine as J,library11_wireAt as X,library11_matches as lt,library11_objectHistory as ft,library11_validateObjectContext as pt}from"../vendor/runtime.js";import{objectProvider as gt}from"../vendor/object-provider.js";import{library7_standingBytes as ut}from"../vendor/runtime.js";import{fieldOf as p}from"../fold/claims.js";import{lockStanding as ht,lockLines as L}from"../fold/keys.js";import{authorityFor as W,rootSigner as I}from"../fold/signers.js";import{publicKeyOf as Q}from"../fold/signers.js";import{signaturesOf as v}from"../fold/digests.js";import{fullDigest as yt}from"./digest.js";import{toposAt as wt,contextProviderServices as mt}from"./selected-topos.js";import{signerFor as V}from"./signing.js";import{signConsentLot as Y,verifiesFields as kt}from"../land/sign.js";import{storeOf as K}from"../land/ledger.js";import{signedOwnerLines as bt,epochOf as C,localActLines as Z,ownerOf as tt}from"../cli/owner.js";import{commitIngress as vt,ingressBundles as xt,ingressCost as Et}from"./ports/ingress.js";const d=l(t=>{throw Error("REFUSE\xB7walk "+t)},"refuse"),q=l(t=>{const e=dt(t);return e.kind!=="fact"?d("not a wire line"):e.value.fields},"fields"),N=l((t,e,a)=>{const c=t.filter(o=>p(o,"scope")===e&&p(o,"measure")===a&&p(o,"value")!=="withdraw");return c.length!==1?d("missing or conflicting "+e+" "+a):p(c[0],"value")},"one");function O(t){const e=K(t),a=ht(e),c=z(a);N(a,"view/walk","id")!=="walk@*"&&d("view/walk must declare walk@*");const r=a.filter(s=>p(s,"scope")==="view/walk").flatMap(s=>p(s,"needs").split("|")).filter(Boolean);r.length||d("view/walk has no declared history inputs");const i=X(a.map(q),Number.MAX_SAFE_INTEGER),n=i?.digests.values().next().value;return n||d("no admitted digest algorithm"),{store:e,standing:a,contract:c,masks:r,digest:l(s=>yt(s,n),"digest")}}l(O,"policy");function E(t,e,a=!1){const c=O(t);!a&&!c.standing.some(n=>p(n,"scope").startsWith("uses/")&&p(n,"value")===e)&&d("origin context is not selected by digest");const o=wt(e,c.store),r=at(o.parts,kt),i=o.parts.map(n=>R({...n,by:"target",epoch:"0"}));return{pin:e,topos:o,authority:r,configuration:i,origin:st(o.parts),contract:z(o.lines)}}l(E,"context");function et(t){const e=O(t),a=W(L(e.store),I(t),v(e.store).admitted),c=bt(e.store).filter(r=>e.masks.some(i=>lt(i,p(r,"scope"))));c.some(r=>a.of(r).kind!=="admitted")&&d("local history is not authenticated");const o=E(t,N(e.standing,"walk/context","digest"),!0);return M(c,o.contract.fields,e.digest,o.origin,o.contract.partition)}l(et,"local");const B=l(t=>{const e=t.filter(c=>G(c)&&p(c,"scope")==="walk/root");if(e.length!==1)return d("one signed root is required");const a=p(e[0],"at");return a.startsWith("receipt:")?{pin:a.slice(8),base:p(e[0],"condition")}:d("root has no declared context")},"headerInfo");async function D(t,e,a){e.authority.authenticate(a)||d("origin history is not authenticated");for(const s of a){const g=q(s),y=J(s,X(e.topos.parts,Number(g.epoch)));y.kind!=="fact"&&d("origin wire "+y.why)}const c=ft([...e.configuration,...a]);if(c.kind!=="fact")return d("origin history "+c.why);if(!c.value.objects.length)return;const o=new Set(e.topos.lines),r=l(s=>s.sig?e.authority.of(R(s)).kind==="admitted":o.has(ut([R(s)]).trim()),"admit"),i=await gt(c.value.objects,c.value.configuration,{admit:r,emit:l(()=>{},"emit"),...mt(K(t))}),n=pt(c.value.objects,i);n.kind!=="fact"&&d("origin context "+n.why)}l(D,"validateHistory");async function _t(t,e,a=[]){const c=e.evidence.split(`
1
+ var it=Object.defineProperty;var l=(t,e)=>it(t,"name",{value:e,configurable:!0});import{library13_walkProjection as nt,library13_walkAt as rt,library13_walkSnapshot as M,library13_walkHeaders as ot,library13_readWalkHeaders as U,library13_readForeignWalk as $,library13_walkAuthority as at,library13_walkOrigin as st,library13_walkInventory as ct,library13_walkSelection as z,library13_isWalkHeader as G}from"../vendor/runtime.js";import{library14_canonical as R,library14_parse as dt,library14_fromLine as J,library14_wireAt as X,library14_matches as lt,library14_objectHistory as ft,library14_validateObjectContext as pt}from"../vendor/runtime.js";import{objectProvider as gt}from"../vendor/object-provider.js";import{library10_standingBytes as ut}from"../vendor/runtime.js";import{fieldOf as p}from"../fold/claims.js";import{lockStanding as ht,lockLines as L}from"../fold/keys.js";import{authorityFor as W,rootSigner as I}from"../fold/signers.js";import{publicKeyOf as Q}from"../fold/signers.js";import{signaturesOf as v}from"../fold/digests.js";import{fullDigest as yt}from"./digest.js";import{toposAt as wt,contextProviderServices as mt}from"./selected-topos.js";import{signerFor as V}from"./signing.js";import{signConsentLot as Y,verifiesFields as kt}from"../land/sign.js";import{storeOf as K}from"../land/ledger.js";import{signedOwnerLines as bt,epochOf as C,localActLines as Z,ownerOf as tt}from"../cli/owner.js";import{commitIngress as vt,ingressBundles as xt,ingressCost as Et}from"./ports/ingress.js";const d=l(t=>{throw Error("REFUSE\xB7walk "+t)},"refuse"),q=l(t=>{const e=dt(t);return e.kind!=="fact"?d("not a wire line"):e.value.fields},"fields"),N=l((t,e,a)=>{const c=t.filter(o=>p(o,"scope")===e&&p(o,"measure")===a&&p(o,"value")!=="withdraw");return c.length!==1?d("missing or conflicting "+e+" "+a):p(c[0],"value")},"one");function O(t){const e=K(t),a=ht(e),c=z(a);N(a,"view/walk","id")!=="walk@*"&&d("view/walk must declare walk@*");const r=a.filter(s=>p(s,"scope")==="view/walk").flatMap(s=>p(s,"needs").split("|")).filter(Boolean);r.length||d("view/walk has no declared history inputs");const i=X(a.map(q),Number.MAX_SAFE_INTEGER),n=i?.digests.values().next().value;return n||d("no admitted digest algorithm"),{store:e,standing:a,contract:c,masks:r,digest:l(s=>yt(s,n),"digest")}}l(O,"policy");function E(t,e,a=!1){const c=O(t);!a&&!c.standing.some(n=>p(n,"scope").startsWith("uses/")&&p(n,"value")===e)&&d("origin context is not selected by digest");const o=wt(e,c.store),r=at(o.parts,kt),i=o.parts.map(n=>R({...n,by:"target",epoch:"0"}));return{pin:e,topos:o,authority:r,configuration:i,origin:st(o.parts),contract:z(o.lines)}}l(E,"context");function et(t){const e=O(t),a=W(L(e.store),I(t),v(e.store).admitted),c=bt(e.store).filter(r=>e.masks.some(i=>lt(i,p(r,"scope"))));c.some(r=>a.of(r).kind!=="admitted")&&d("local history is not authenticated");const o=E(t,N(e.standing,"walk/context","digest"),!0);return M(c,o.contract.fields,e.digest,o.origin,o.contract.partition)}l(et,"local");const B=l(t=>{const e=t.filter(c=>G(c)&&p(c,"scope")==="walk/root");if(e.length!==1)return d("one signed root is required");const a=p(e[0],"at");return a.startsWith("receipt:")?{pin:a.slice(8),base:p(e[0],"condition")}:d("root has no declared context")},"headerInfo");async function D(t,e,a){e.authority.authenticate(a)||d("origin history is not authenticated");for(const s of a){const g=q(s),y=J(s,X(e.topos.parts,Number(g.epoch)));y.kind!=="fact"&&d("origin wire "+y.why)}const c=ft([...e.configuration,...a]);if(c.kind!=="fact")return d("origin history "+c.why);if(!c.value.objects.length)return;const o=new Set(e.topos.lines),r=l(s=>s.sig?e.authority.of(R(s)).kind==="admitted":o.has(ut([R(s)]).trim()),"admit"),i=await gt(c.value.objects,c.value.configuration,{admit:r,emit:l(()=>{},"emit"),...mt(K(t))}),n=pt(c.value.objects,i);n.kind!=="fact"&&d("origin context "+n.why)}l(D,"validateHistory");async function _t(t,e,a=[]){const c=e.evidence.split(`
2
2
  `).filter(Boolean),o=B(c),r=O(t),i=e.receipt.split(`
3
3
  `).filter(Boolean),n=W(L(r.store),I(t),v(r.store).admitted);(i.length!==1||p(i[0],"scope")!=="receipts"||p(i[0],"role")!=="writes"||p(i[0],"form")!=="alphabet"||p(i[0],"measure")!=="digest"||p(i[0],"at")!=="receipt:"+o.pin||n.of(i[0]).kind!=="admitted")&&d("retained import receipt is not authenticated");const s=E(t,o.pin),g=$(c,{origin:s.origin,regionOrigin:s.origin,context:o.pin,base:o.base,fields:s.contract.fields,partition:s.contract.partition,digest:r.digest,previousPrefixes:[],authenticatePrefix:s.authority.authenticate,authenticateEvidence:s.authority.authenticate,validateOriginHistory:l(()=>!0,"validateOriginHistory")});return p(i[0],"value")!==g.identity&&d("retained import receipt does not authenticate this ingress"),await D(t,s,[...new Set([...a,...g.records])]),{...g,context:o.pin,regions:M(g.records,s.contract.fields,r.digest,g.origin,s.contract.partition).regions}}l(_t,"readBundle");async function F(t){const e=[],a=new Map,c=[...xt(K(t))].sort((o,r)=>C(o.receipt.split(`
4
4
  `))-C(r.receipt.split(`
@@ -0,0 +1 @@
1
+ var v=Object.defineProperty;var d=(r,o)=>v(r,"name",{value:o,configurable:!0});import{AsyncLocalStorage as y}from"node:async_hooks";const f=new y,M=1e4;function S(r,o){const i=f.getStore();if(!i)return o();const{trace:e,parent:c}=i;if(e.spans.length>=M)return e.truncated=!0,o();const l={id:e.spans.length,parent:c,name:r,start:e.clock()};e.spans.push(l);const m=d(()=>{l.end=e.clock()},"close");return f.run({trace:e,parent:l.id},()=>{try{const s=o();return s&&typeof s.then=="function"?Promise.resolve(s).finally(m):(m(),s)}catch(s){throw m(),s}})}d(S,"traceWork");function g(r,o,i=!1){const e=r[0],c=r.flatMap(t=>[{time:t.start,id:t.id,start:!0},{time:t.end??o,id:t.id,start:!1}]).sort((t,n)=>t.time-n.time||Number(t.start)-Number(n.start)),l=new Set,m=new Map,s=r.map(t=>{let n=0,a=t.parent;for(;a>=0;)n++,a=r[a].parent;return n});let p=e.start;for(const t of c){const n=Math.min(o,Math.max(e.start,t.time));if(n>p){let a=0;for(const u of l)(s[u]>s[a]||s[u]===s[a]&&u>a)&&(a=u);const w=r[a].name;m.set(w,(m.get(w)??0)+n-p),p=n}t.start?l.add(t.id):l.delete(t.id)}const h=[...m].map(([t,n])=>({name:t,milliseconds:n}));return{profile:"bound-work-trace@1",clock:"performance.now monotonic milliseconds",totalMilliseconds:o-e.start,exclusiveMilliseconds:h.reduce((t,n)=>t+n.milliseconds,0),phases:h,inclusive:r.map(t=>({name:t.name,milliseconds:(t.end??o)-t.start})),complete:!i}}d(g,"workReport");async function b(r,o,i=()=>performance.now()){if(f.getStore())return r();const e={id:0,parent:-1,name:"command/dispatch",start:i()},c={clock:i,spans:[e],truncated:!1};try{return await f.run({trace:c,parent:0},r)}finally{e.end=i(),o(g(c.spans,e.end,c.truncated))}}d(b,"withWorkTrace");export{S as traceWork,b as withWorkTrace,g as workReport};
@@ -1 +1 @@
1
- var b=Object.defineProperty;var p=(s,a)=>b(s,"name",{value:a,configurable:!0});import{library11_canonical as d}from"../vendor/runtime.js";import{fieldOf as t}from"../fold/claims.js";import{fullDigest as g}from"../fold/digests.js";import{inside as $,locationsOf as j,vouchedCoordinates as y}from"../land/vouched.js";import{wordOf as O}from"../fold/wire.js";import{holdsCases as C}from"../fold/paid.js";function z(s,a,h){const v=[...y(s)],w=`${O(a,"families","view")}/`,c=[];for(const e of a){const n=t(e,"scope"),l=t(e,"value")||"present";if(t(e,"role")!=="demands"||l==="withdraw"||h.has(n))continue;const r=j(t(e,"needs")).locations;if(!r.length||!n.startsWith(w)&&!r.some(C))continue;const m=r.map(o=>v.filter(([i])=>$(i,o)));if(m.some(o=>!o.length))continue;const f=m.flat(),u=`cone:${g(s,f.map(([o,i])=>`${o} ${i}`).sort()).replace(/^sha256:/,"")}`;c.push(d({scope:n,role:"writes",form:"alphabet",measure:t(e,"measure")||"status",value:l,by:"judge",at:u}),d({scope:n,role:"writes",form:"alphabet",measure:"cone",value:f.map(([o])=>o).join("|"),by:"judge",at:u}))}return c}p(z,"lateFacts");export{z as lateFacts};
1
+ var b=Object.defineProperty;var p=(s,a)=>b(s,"name",{value:a,configurable:!0});import{library14_canonical as d}from"../vendor/runtime.js";import{fieldOf as t}from"../fold/claims.js";import{fullDigest as g}from"../fold/digests.js";import{inside as $,locationsOf as j,vouchedCoordinates as y}from"../land/vouched.js";import{wordOf as O}from"../fold/wire.js";import{holdsCases as C}from"../fold/paid.js";function z(s,a,h){const v=[...y(s)],w=`${O(a,"families","view")}/`,c=[];for(const e of a){const n=t(e,"scope"),l=t(e,"value")||"present";if(t(e,"role")!=="demands"||l==="withdraw"||h.has(n))continue;const r=j(t(e,"needs")).locations;if(!r.length||!n.startsWith(w)&&!r.some(C))continue;const m=r.map(o=>v.filter(([i])=>$(i,o)));if(m.some(o=>!o.length))continue;const f=m.flat(),u=`cone:${g(s,f.map(([o,i])=>`${o} ${i}`).sort()).replace(/^sha256:/,"")}`;c.push(d({scope:n,role:"writes",form:"alphabet",measure:t(e,"measure")||"status",value:l,by:"judge",at:u}),d({scope:n,role:"writes",form:"alphabet",measure:"cone",value:f.map(([o])=>o).join("|"),by:"judge",at:u}))}return c}p(z,"lateFacts");export{z as lateFacts};
@@ -1,2 +1,2 @@
1
- var L=Object.defineProperty;var i=(t,s)=>L(t,"name",{value:s,configurable:!0});import{createHash as N,existsSync as P,join as S}from"../host/io.js";import{fullDigest as T}from"../fold/digests.js";import{library12_answers as D,library12_point as H,library12_region as M}from"../vendor/runtime.js";import{library11_parse as W,library11_PROTOCOL as q}from"../vendor/runtime.js";import{observeText as z}from"../observe/files.js";import{storeOf as C}from"../land/ledger.js";import{holdsCases as A}from"../fold/paid.js";function E(t,s){return P(S(t,s.replace(/\/+$/,"")))}i(E,"located");function B(t,s,g){return[]}i(B,"namedEffects");function Z(t){const{root:s,scope:g,value:l,locations:o,before:r,after:d}=t,u=[...new Set([...r.keys(),...d.keys()])].sort().filter(e=>r.get(e)!==d.get(e)),f=u.filter(e=>{if(r.has(e)||o.includes(e)||!t.witnessOf||!t.law)return!1;const h=t.witnessOf(e);return h!==void 0&&!t.law.includes(h)}),c=u.filter(e=>!f.includes(e)),k=l==="present"?o.filter(e=>!E(s,e)):[],O=c.length&&!k.length?B(s,c,t.template):[],b={scope:g,cone:[...o],before:Object.fromEntries([...r].sort()),after:Object.fromEntries([...d].filter(([e])=>!f.includes(e)).sort()),effects:O},v=T(C(s),JSON.stringify({...b,effects:O.map(e=>({kind:e.kind,status:e.status,at:e.at}))})),a=i(e=>({kind:"refuse",why:e,envelope:b,digest:v,changed:c,notOwned:f}),"refuse"),w=i(e=>({kind:"fact",why:e,envelope:b,digest:v,changed:c,notOwned:f}),"met");if(!c.length&&!t.unpaid)return a("nothing in the cone moved against what was vouched");const R=o.map(e=>M(e)),x=c.filter(e=>!D([H(e)],R));if(x.length)return a(`outside the cone: ${x.join(", ")}`);if(k.length)return a(`demanded locations absent: ${k.join(", ")}`);if(t.shape==="lock"||t.shape==="render"){const e=o.map(n=>({at:n,text:z(S(s,n))})),h=e.filter(n=>n.text===void 0).map(n=>n.at);if(h.length)return a(`a lock the demand names is not here: ${h.join(", ")}`);const p=e.flatMap(n=>(n.text??"").split(`
1
+ var L=Object.defineProperty;var i=(t,s)=>L(t,"name",{value:s,configurable:!0});import{createHash as N,existsSync as P,join as S}from"../host/io.js";import{fullDigest as T}from"../fold/digests.js";import{library0_answers as D,library0_point as H,library0_region as M}from"../vendor/runtime.js";import{library14_parse as W,library14_PROTOCOL as q}from"../vendor/runtime.js";import{observeText as z}from"../observe/files.js";import{storeOf as C}from"../land/ledger.js";import{holdsCases as A}from"../fold/paid.js";function E(t,s){return P(S(t,s.replace(/\/+$/,"")))}i(E,"located");function B(t,s,g){return[]}i(B,"namedEffects");function Z(t){const{root:s,scope:g,value:l,locations:o,before:r,after:d}=t,u=[...new Set([...r.keys(),...d.keys()])].sort().filter(e=>r.get(e)!==d.get(e)),f=u.filter(e=>{if(r.has(e)||o.includes(e)||!t.witnessOf||!t.law)return!1;const h=t.witnessOf(e);return h!==void 0&&!t.law.includes(h)}),c=u.filter(e=>!f.includes(e)),k=l==="present"?o.filter(e=>!E(s,e)):[],O=c.length&&!k.length?B(s,c,t.template):[],b={scope:g,cone:[...o],before:Object.fromEntries([...r].sort()),after:Object.fromEntries([...d].filter(([e])=>!f.includes(e)).sort()),effects:O},v=T(C(s),JSON.stringify({...b,effects:O.map(e=>({kind:e.kind,status:e.status,at:e.at}))})),a=i(e=>({kind:"refuse",why:e,envelope:b,digest:v,changed:c,notOwned:f}),"refuse"),w=i(e=>({kind:"fact",why:e,envelope:b,digest:v,changed:c,notOwned:f}),"met");if(!c.length&&!t.unpaid)return a("nothing in the cone moved against what was vouched");const R=o.map(e=>M(e)),x=c.filter(e=>!D([H(e)],R));if(x.length)return a(`outside the cone: ${x.join(", ")}`);if(k.length)return a(`demanded locations absent: ${k.join(", ")}`);if(t.shape==="lock"||t.shape==="render"){const e=o.map(n=>({at:n,text:z(S(s,n))})),h=e.filter(n=>n.text===void 0).map(n=>n.at);if(h.length)return a(`a lock the demand names is not here: ${h.join(", ")}`);const p=e.flatMap(n=>(n.text??"").split(`
2
2
  `).filter(J=>J.startsWith(q))),j=p.filter(n=>W(n).kind!=="fact");if(t.shape==="lock"&&(!p.length||j.length))return a(`a lock the demand names holds ${p.length?`${j.length} lines the wire does not read`:"no claim"}`);const m=t.restsOn??"",_=m&&`sha256:${N("sha256").update(e.map(n=>n.text??"").join("")).digest("hex")}`;return m&&_!==m?a(`the lock moved: it rests on ${m} and is ${_}`):w(t.shape==="lock"?`${p.length} lines of the lock read, at the digest it rests on`:"the region is here, at the digest it rests on")}if(!o.filter(e=>A(e)&&E(s,e)).length)return a("no vector location in the cone exists");const y=O.filter(e=>e.status==="red"&&e.admitted);return y.length?a(`effects red: ${y.map(e=>`${e.kind}@${e.at}`).join(", ")}`):w("demand met in its cone")}i(Z,"judgeTake");function ee(t,s,g){const l={...s.envelope,effects:[...s.envelope.effects,...g.map(({kind:r,status:d,ms:$,at:u,admitted:f})=>({kind:r,status:d,ms:$,at:u,admitted:f}))]},o=T(C(t),JSON.stringify({...l,effects:l.effects.map(r=>({kind:r.kind,status:r.status,at:r.at}))}));return{...s,envelope:l,digest:o}}i(ee,"sealed");export{Z as judgeTake,ee as sealed};
@@ -1 +1 @@
1
- var c=Object.defineProperty;var o=(e,a)=>c(e,"name",{value:a,configurable:!0});import{fieldOf as t}from"../fold/claims.js";import{library4_ALPHABETS as n,library4_idsOf as u,library4_INTERVALS as p,library4_spanOf as d}from"../vendor/runtime.js";function y(e,a){const[s,f]=[d(t(a,"value")),d(t(e,"value"))];if(s&&f)return p.leq(s,f)&&!p.leq(f,s);const[l,r]=[u(t(a,"value")),u(t(e,"value"))];return l.polarity===r.polarity&&n.leq(l,r)&&!n.leq(r,l)}o(y,"widens");function O(e,a,s,f){const l=new Map(a.filter(s).map(r=>[t(r,"scope"),r]));return e.filter(r=>{const i=l.get(t(r,"scope"));return!i||!s(r)||!y(r,i)?!1:!t(r,"at").startsWith(`${f}:`)})}o(O,"widenedWithoutWitness");export{O as widenedWithoutWitness};
1
+ var c=Object.defineProperty;var o=(e,a)=>c(e,"name",{value:a,configurable:!0});import{fieldOf as t}from"../fold/claims.js";import{library7_ALPHABETS as n,library7_idsOf as u,library7_INTERVALS as p,library7_spanOf as d}from"../vendor/runtime.js";function y(e,a){const[s,f]=[d(t(a,"value")),d(t(e,"value"))];if(s&&f)return p.leq(s,f)&&!p.leq(f,s);const[l,r]=[u(t(a,"value")),u(t(e,"value"))];return l.polarity===r.polarity&&n.leq(l,r)&&!n.leq(r,l)}o(y,"widens");function O(e,a,s,f){const l=new Map(a.filter(s).map(r=>[t(r,"scope"),r]));return e.filter(r=>{const i=l.get(t(r,"scope"));return!i||!s(r)||!y(r,i)?!1:!t(r,"at").startsWith(`${f}:`)})}o(O,"widenedWithoutWitness");export{O as widenedWithoutWitness};
package/dist/land/act.js CHANGED
@@ -1,8 +1,8 @@
1
- var J=Object.defineProperty;var r=(e,t)=>J(e,"name",{value:t,configurable:!0});import{AsyncLocalStorage as q}from"node:async_hooks";import{randomUUID as D}from"node:crypto";import{basename as p,dirname as $,existsSync as L,join as a,mkdirSync as _,rmSync as K,writeFileSync as Q,realpathSync as V,resolve as Y}from"../host/io.js";import{BoundRefusal as Z}from"../host/refusals.js";import{selfName as ee}from"../fold/claims.js";import{placesIn as te}from"../fold/places.js";import{coordinatesUnder as ne,observeText as oe}from"../observe/files.js";const v=new q,we=r((e,t)=>v.run(e,t),"withActHost"),d=r(()=>v.getStore()?.name??ee(),"actName"),b=r(e=>{const t=v.getStore();t?t.report(e):process.stderr.write(e)},"report"),A=r(()=>{if(v.getStore()?.signal?.aborted)throw new Z("host/cancelled","REFUSE\xB7host/cancelled")},"checkCancellation");function E(e){let t=Y(e);const n=[];for(;!L(t);){const o=$(t);if(o===t)break;n.unshift(p(t)),t=o}return a(V(t),...n)}r(E,"canonicalActStore");const F=new q,y=new Map,B=r(e=>new Promise(t=>{setTimeout(t,e)}),"pauseFor"),j="_root",re=6e4,S=r(e=>{const t=oe(e);if(t===void 0)return;const[n,o,i,c]=t.trim().split(" ");return{pid:Number(n),what:o??"",since:i??"",token:c??""}},"holderOf");function z(e,t,n){if(Date.now()-t<re)return;const o=n===void 0?"a process":`${n.pid} \xB7 ${n.what} since ${n.since}`;throw b(`RED wait \xB7 ${R(e)} is held by ${o} \xB7 a wait over a minute is a red, not a pause
2
- `),new Error(`${d()}: REFUSE\xB7stale nothing landed \xB7 a wait over a minute is a red, not a pause`)}r(z,"overAMinute");const N=r(e=>{if(!Number.isSafeInteger(e)||e<=0)return!0;try{return process.kill(e,0),!0}catch(t){return t.code!=="ESRCH"}},"alive"),k=r((e,t)=>{const n=t.replace(/\/+$/,"");if(n&&n.split("/").some(o=>o===".."||o==="."||o==="")||n.startsWith("/"))throw new Error(`${d()}: REFUSE\xB7lock invalid region coordinate`);return a(e,"locks",n?encodeURIComponent(n).replace(/^\./,"%2E").replace(/^_root$/,"%5Froot"):j)},"regionAt"),ie=r(e=>{if(e===j)return"";try{return decodeURIComponent(e)}catch{return e}},"coordinateOf"),G=r(e=>ne(e,e).filter(t=>{if(t!==".act")return!0;const n=S(a(e,t));return n!==void 0&&Number.isSafeInteger(n.pid)&&n.pid>0}),"lockFiles"),P=r((e,t)=>!e||!t||e===t||e.startsWith(`${t}/`)||t.startsWith(`${e}/`),"overlaps"),w=r(e=>a(e,"lock"),"treeAt"),R=r(e=>p(e)==="lock"?"the store":p(e).startsWith("@authority-")?"root authority":p(e)==="@projection"?"root projection":`region ${p(e)===j?".":p(e)}`,"named"),l=r(e=>{for(let t=F.getStore();t!==void 0;t=t.parent){const n=t.locks.get(e);if(n!==void 0&&y.get(e)===n)return!0}return!1},"owns"),x=r(e=>[...y.keys()].some(t=>t.startsWith(`${a(e,"locks")}/`)&&l(t)),"ownsRegion"),O=r(e=>[...y.keys()].some(t=>$(t)===a(e,"locks")&&p(t).startsWith("@authority-")&&l(t)),"ownsAuthority"),ce=r(e=>a(e,"locks","@projection"),"projectionAt");async function h(e,t){if(l(e))return;const n=F.getStore();if(n===void 0)throw new Error(`${d()}: REFUSE\xB7lock no act owns this request`);const o=Date.now(),i=D();let c=!1;for(_($(e),{recursive:!0});;){A();try{Q(e,`${process.pid} ${t.replace(/\s+/g,"_")} ${new Date().toISOString()} ${i}
3
- `,{flag:"wx"});break}catch(g){const u=g.code;if(u==="ENOENT")_($(e),{recursive:!0});else if(u!=="EEXIST")throw g}const s=S(e);if(s!==void 0&&!N(s.pid))throw new Error(`${d()}: REFUSE\xB7stale ${R(e)} belongs to exited process ${s.pid}; host recovery required`);z(e,o,s),!c&&s!==void 0&&(b(`WAIT ${R(e)} is held by ${s.pid} \xB7 ${s.what} since ${s.since}
1
+ var J=Object.defineProperty;var r=(e,t)=>J(e,"name",{value:t,configurable:!0});import{AsyncLocalStorage as q}from"node:async_hooks";import{randomUUID as D}from"node:crypto";import{basename as w,dirname as $,existsSync as L,join as a,mkdirSync as _,rmSync as K,writeFileSync as Q,realpathSync as V,resolve as Y}from"../host/io.js";import{BoundRefusal as Z}from"../host/refusals.js";import{selfName as ee}from"../fold/claims.js";import{placesIn as te}from"../fold/places.js";import{coordinatesUnder as ne,observeText as oe}from"../observe/files.js";const v=new q,pe=r((e,t)=>v.run(e,t),"withActHost"),d=r(()=>v.getStore()?.name??ee(),"actName"),b=r(e=>{const t=v.getStore();t?t.report(e):process.stderr.write(e)},"report"),we=r(()=>v.getStore()?.signal,"currentActSignal"),A=r(()=>{if(v.getStore()?.signal?.aborted)throw new Z("host/cancelled","REFUSE\xB7host/cancelled")},"checkCancellation");function E(e){let t=Y(e);const n=[];for(;!L(t);){const o=$(t);if(o===t)break;n.unshift(w(t)),t=o}return a(V(t),...n)}r(E,"canonicalActStore");const F=new q,g=new Map,B=r(e=>new Promise(t=>{setTimeout(t,e)}),"pauseFor"),j="_root",re=6e4,S=r(e=>{const t=oe(e);if(t===void 0)return;const[n,o,i,c]=t.trim().split(" ");return{pid:Number(n),what:o??"",since:i??"",token:c??""}},"holderOf");function z(e,t,n){if(Date.now()-t<re)return;const o=n===void 0?"a process":`${n.pid} \xB7 ${n.what} since ${n.since}`;throw b(`RED wait \xB7 ${R(e)} is held by ${o} \xB7 a wait over a minute is a red, not a pause
2
+ `),new Error(`${d()}: REFUSE\xB7stale nothing landed \xB7 a wait over a minute is a red, not a pause`)}r(z,"overAMinute");const N=r(e=>{if(!Number.isSafeInteger(e)||e<=0)return!0;try{return process.kill(e,0),!0}catch(t){return t.code!=="ESRCH"}},"alive"),k=r((e,t)=>{const n=t.replace(/\/+$/,"");if(n&&n.split("/").some(o=>o===".."||o==="."||o==="")||n.startsWith("/"))throw new Error(`${d()}: REFUSE\xB7lock invalid region coordinate`);return a(e,"locks",n?encodeURIComponent(n).replace(/^\./,"%2E").replace(/^_root$/,"%5Froot"):j)},"regionAt"),ie=r(e=>{if(e===j)return"";try{return decodeURIComponent(e)}catch{return e}},"coordinateOf"),G=r(e=>ne(e,e).filter(t=>{if(t!==".act")return!0;const n=S(a(e,t));return n!==void 0&&Number.isSafeInteger(n.pid)&&n.pid>0}),"lockFiles"),P=r((e,t)=>!e||!t||e===t||e.startsWith(`${t}/`)||t.startsWith(`${e}/`),"overlaps"),p=r(e=>a(e,"lock"),"treeAt"),R=r(e=>w(e)==="lock"?"the store":w(e).startsWith("@authority-")?"root authority":w(e)==="@projection"?"root projection":`region ${w(e)===j?".":w(e)}`,"named"),l=r(e=>{for(let t=F.getStore();t!==void 0;t=t.parent){const n=t.locks.get(e);if(n!==void 0&&g.get(e)===n)return!0}return!1},"owns"),x=r(e=>[...g.keys()].some(t=>t.startsWith(`${a(e,"locks")}/`)&&l(t)),"ownsRegion"),O=r(e=>[...g.keys()].some(t=>$(t)===a(e,"locks")&&w(t).startsWith("@authority-")&&l(t)),"ownsAuthority"),ce=r(e=>a(e,"locks","@projection"),"projectionAt");async function h(e,t){if(l(e))return;const n=F.getStore();if(n===void 0)throw new Error(`${d()}: REFUSE\xB7lock no act owns this request`);const o=Date.now(),i=D();let c=!1;for(_($(e),{recursive:!0});;){A();try{Q(e,`${process.pid} ${t.replace(/\s+/g,"_")} ${new Date().toISOString()} ${i}
3
+ `,{flag:"wx"});break}catch(y){const u=y.code;if(u==="ENOENT")_($(e),{recursive:!0});else if(u!=="EEXIST")throw y}const s=S(e);if(s!==void 0&&!N(s.pid))throw new Error(`${d()}: REFUSE\xB7stale ${R(e)} belongs to exited process ${s.pid}; host recovery required`);z(e,o,s),!c&&s!==void 0&&(b(`WAIT ${R(e)} is held by ${s.pid} \xB7 ${s.what} since ${s.since}
4
4
  `),c=!0),await B(250)}c&&b(`HELD ${R(e)} after ${Date.now()-o} ms waiting
5
- `),y.set(e,i),n.locks.set(e,i),process.listeners("exit").includes(C)||process.once("exit",C)}r(h,"hold");function I(e,t){if(y.get(e)!==t)return;y.delete(e);const n=S(e);n?.pid===process.pid&&n.token===t&&L(e)&&K(e,{force:!0})}r(I,"release");function C(){for(const[e,t]of[...y])I(e,t)}r(C,"releaseAll");function pe(){process.once("SIGTERM",()=>{b(`${d()}: REFUSE\xB7crash signal
6
- `),C(),process.exit(1)})}r(pe,"installActSignalHandler");async function T(e,t){const n={parent:F.getStore(),locks:new Map};return F.run(n,async()=>{try{return A(),await e(),A(),await t()}finally{for(const[o,i]of[...n.locks].reverse())I(o,i);n.locks.clear()}})}r(T,"framed");function X(e,t,n,o,i){return T(async()=>{const c=w(e),s=[...new Set((t.length?t:[""]).map(u=>u.replace(/\/+$/,"")))];if(i&&(s.includes("")||x(e)&&!l(c)&&!O(e)))throw new Error(`${d()}: REFUSE\xB7lock authority dependencies and child regions must be declared together`);if(l(c)||s.every(u=>l(k(e,u)))){for(const u of s)await h(k(e,u),n);return}if(x(e))throw new Error(`${d()}: REFUSE\xB7lock declare every region before entering an act`);const g=l(c);await h(c,n);try{const u=a(e,"locks");for(;;){const m=G(u).find(f=>!l(a(u,f))&&(f.startsWith("@authority-")||f==="@projection"?s.includes(""):s.some(M=>P(M,f)||P(M,ie(f)))));if(m===void 0)break;const U=a(u,m),H=Date.now();let W=!1;for(let f=S(U);f!==void 0;f=S(U)){if(A(),!N(f.pid))throw new Error(`${d()}: REFUSE\xB7stale ${R(U)} belongs to exited process ${f.pid}; host recovery required`);z(U,H,f),W||(b(`WAIT ${R(U)} is held by ${f.pid} \xB7 ${f.what} since ${f.since}
5
+ `),g.set(e,i),n.locks.set(e,i),process.listeners("exit").includes(C)||process.once("exit",C)}r(h,"hold");function I(e,t){if(g.get(e)!==t)return;g.delete(e);const n=S(e);n?.pid===process.pid&&n.token===t&&L(e)&&K(e,{force:!0})}r(I,"release");function C(){for(const[e,t]of[...g])I(e,t)}r(C,"releaseAll");function Ee(){process.once("SIGTERM",()=>{b(`${d()}: REFUSE\xB7crash signal
6
+ `),C(),process.exit(1)})}r(Ee,"installActSignalHandler");async function T(e,t){const n={parent:F.getStore(),locks:new Map};return F.run(n,async()=>{try{return A(),await e(),A(),await t()}finally{for(const[o,i]of[...n.locks].reverse())I(o,i);n.locks.clear()}})}r(T,"framed");function X(e,t,n,o,i){return T(async()=>{const c=p(e),s=[...new Set((t.length?t:[""]).map(u=>u.replace(/\/+$/,"")))];if(i&&(s.includes("")||x(e)&&!l(c)&&!O(e)))throw new Error(`${d()}: REFUSE\xB7lock authority dependencies and child regions must be declared together`);if(l(c)||s.every(u=>l(k(e,u)))){for(const u of s)await h(k(e,u),n);return}if(x(e))throw new Error(`${d()}: REFUSE\xB7lock declare every region before entering an act`);const y=l(c);await h(c,n);try{const u=a(e,"locks");for(;;){const m=G(u).find(f=>!l(a(u,f))&&(f.startsWith("@authority-")||f==="@projection"?s.includes(""):s.some(M=>P(M,f)||P(M,ie(f)))));if(m===void 0)break;const U=a(u,m),H=Date.now();let W=!1;for(let f=S(U);f!==void 0;f=S(U)){if(A(),!N(f.pid))throw new Error(`${d()}: REFUSE\xB7stale ${R(U)} belongs to exited process ${f.pid}; host recovery required`);z(U,H,f),W||(b(`WAIT ${R(U)} is held by ${f.pid} \xB7 ${f.what} since ${f.since}
7
7
  `),W=!0),await B(250)}W&&b(`HELD ${R(U)} after ${Date.now()-H} ms waiting
8
- `)}i&&await h(a(e,"locks",`@authority-${D()}`),n);for(const m of s.filter(Boolean).sort())await h(k(e,m),n);s.includes("")&&await h(k(e,""),n)}finally{if(!g){const u=F.getStore(),m=u.locks.get(c);m!==void 0&&(I(c,m),u.locks.delete(c))}}},o)}r(X,"guardedRegions");function Ee(e,t,n,o){return e=E(e),X(e,t,n,o,!1)}r(Ee,"underTheRegions");function ye(e,t,n,o){return e=E(e),X(e,t,n,o,!0)}r(ye,"underAuthorityRegions");function ge(e,t,n){return e=E(e),T(async()=>{const o=w(e),i=k(e,"");if(!(l(o)||l(i)||O(e))){if(x(e))throw new Error(`${d()}: REFUSE\xB7lock authority dependencies must be declared before entering a region act`);await h(o,t);try{await h(i,t),await h(a(e,"locks",`@authority-${D()}`),t)}finally{const c=F.getStore();for(const s of[i,o]){const g=c.locks.get(s);g!==void 0&&(I(s,g),c.locks.delete(s))}}}},n)}r(ge,"underRootAuthority");function me(e){e=E(e);const n=[w(e),k(e,""),...y.keys()].filter(i=>i===w(e)||i===k(e,"")||$(i)===a(e,"locks")&&p(i).startsWith("@authority-")).find(l);if(n===void 0)throw Error(`${d()}: REFUSE\xB7lock root authority is not protected`);const o=S(n);if(o?.pid!==process.pid||o.token!==y.get(n))throw Error(`${d()}: REFUSE\xB7lock authority protection changed`);return Object.freeze({store:e,lock:n,pid:o.pid,token:o.token})}r(me,"rootAuthorityProtection");function $e(e,t,n){if(t=E(t),!e||e.store!==t||!Number.isSafeInteger(n)||n<=0||e.pid!==n||typeof e.lock!="string"||typeof e.token!="string"||!e.token||!(e.lock===w(t)||e.lock===k(t,"")||$(e.lock)===a(t,"locks")&&p(e.lock).startsWith("@authority-")))throw Error(`${d()}: REFUSE\xB7lock invalid inherited authority protection`);const o=S(e.lock);if(!N(n)||o?.pid!==e.pid||o.token!==e.token)throw Error(`${d()}: REFUSE\xB7lock inherited authority protection ended`)}r($e,"assertRootAuthorityProtection");function Se(e,t,n){return e=E(e),T(async()=>{if(!(l(w(e))||l(k(e,"")))){if(!O(e))throw new Error(`${d()}: REFUSE\xB7lock root projection requires authority protection`);await h(ce(e),t)}},n)}r(Se,"underRootProjection");const Re=r(async(e,t)=>{e=E(e),l(w(e))||await h(k(e,""),t)},"holdRoot");function Ue(e,t,n){return e=E(e),T(async()=>{if(!l(w(e))&&x(e))throw new Error(`${d()}: REFUSE\xB7lock a region act cannot upgrade to the tree; declare the tree before entering`);await h(w(e),t);const o=a(e,"locks"),i=G(o);for(const c of[...i].sort())await h(a(o,c),t);for(const c of[...te($(e))].sort())await h(k(e,c),t);await h(k(e,""),t)},n)}r(Ue,"underTheLock");const be=r((e,t)=>(e=E(e),[w(e),k(e,t)].some(l)),"holds");export{$e as assertRootAuthorityProtection,E as canonicalActStore,Re as holdRoot,be as holds,pe as installActSignalHandler,me as rootAuthorityProtection,ye as underAuthorityRegions,ge as underRootAuthority,Se as underRootProjection,Ue as underTheLock,Ee as underTheRegions,we as withActHost};
8
+ `)}i&&await h(a(e,"locks",`@authority-${D()}`),n);for(const m of s.filter(Boolean).sort())await h(k(e,m),n);s.includes("")&&await h(k(e,""),n)}finally{if(!y){const u=F.getStore(),m=u.locks.get(c);m!==void 0&&(I(c,m),u.locks.delete(c))}}},o)}r(X,"guardedRegions");function ge(e,t,n,o){return e=E(e),X(e,t,n,o,!1)}r(ge,"underTheRegions");function ye(e,t,n,o){return e=E(e),X(e,t,n,o,!0)}r(ye,"underAuthorityRegions");function me(e,t,n){return e=E(e),T(async()=>{const o=p(e),i=k(e,"");if(!(l(o)||l(i)||O(e))){if(x(e))throw new Error(`${d()}: REFUSE\xB7lock authority dependencies must be declared before entering a region act`);await h(o,t);try{await h(i,t),await h(a(e,"locks",`@authority-${D()}`),t)}finally{const c=F.getStore();for(const s of[i,o]){const y=c.locks.get(s);y!==void 0&&(I(s,y),c.locks.delete(s))}}}},n)}r(me,"underRootAuthority");function $e(e){e=E(e);const n=[p(e),k(e,""),...g.keys()].filter(i=>i===p(e)||i===k(e,"")||$(i)===a(e,"locks")&&w(i).startsWith("@authority-")).find(l);if(n===void 0)throw Error(`${d()}: REFUSE\xB7lock root authority is not protected`);const o=S(n);if(o?.pid!==process.pid||o.token!==g.get(n))throw Error(`${d()}: REFUSE\xB7lock authority protection changed`);return Object.freeze({store:e,lock:n,pid:o.pid,token:o.token})}r($e,"rootAuthorityProtection");function Se(e,t,n){if(t=E(t),!e||e.store!==t||!Number.isSafeInteger(n)||n<=0||e.pid!==n||typeof e.lock!="string"||typeof e.token!="string"||!e.token||!(e.lock===p(t)||e.lock===k(t,"")||$(e.lock)===a(t,"locks")&&w(e.lock).startsWith("@authority-")))throw Error(`${d()}: REFUSE\xB7lock invalid inherited authority protection`);const o=S(e.lock);if(!N(n)||o?.pid!==e.pid||o.token!==e.token)throw Error(`${d()}: REFUSE\xB7lock inherited authority protection ended`)}r(Se,"assertRootAuthorityProtection");function Re(e,t,n){return e=E(e),T(async()=>{if(!(l(p(e))||l(k(e,"")))){if(!O(e))throw new Error(`${d()}: REFUSE\xB7lock root projection requires authority protection`);await h(ce(e),t)}},n)}r(Re,"underRootProjection");const Ue=r(async(e,t)=>{e=E(e),l(p(e))||await h(k(e,""),t)},"holdRoot");function be(e,t,n){return e=E(e),T(async()=>{if(!l(p(e))&&x(e))throw new Error(`${d()}: REFUSE\xB7lock a region act cannot upgrade to the tree; declare the tree before entering`);await h(p(e),t);const o=a(e,"locks"),i=G(o);for(const c of[...i].sort())await h(a(o,c),t);for(const c of[...te($(e))].sort())await h(k(e,c),t);await h(k(e,""),t)},n)}r(be,"underTheLock");const Fe=r((e,t)=>(e=E(e),[p(e),k(e,t)].some(l)),"holds");export{Se as assertRootAuthorityProtection,E as canonicalActStore,we as currentActSignal,Ue as holdRoot,Fe as holds,Ee as installActSignalHandler,$e as rootAuthorityProtection,ye as underAuthorityRegions,me as underRootAuthority,Re as underRootProjection,be as underTheLock,ge as underTheRegions,pe as withActHost};
@@ -1 +1 @@
1
- var O=Object.defineProperty;var p=(t,a)=>O(t,"name",{value:a,configurable:!0});import{library11_ENVELOPE as E}from"../vendor/runtime.js";import{fieldOf as s,fieldsOf as i}from"../fold/claims.js";import{lockStanding as m}from"../fold/keys.js";import{worldsIn as g}from"../fold/places.js";import{ownLockOf as W}from"../fold/signed.js";import{storeOf as v}from"./ledger.js";const n=p((t,a)=>Object.keys(t).filter(c=>!E.has(c)&&c!=="value").every(c=>a[c]===t[c]),"retracts"),d=p(t=>t==="uses"||t.startsWith("uses/")||t.split("/").slice(1,-1).includes("uses"),"pinScope"),$=p(t=>s(t,"value")==="withdraw"&&s(t,"scope").startsWith("dep/")&&s(t,"role")!=="reads","aliasWithdraw");function j(t,a){const c=m(v(t)).filter(e=>s(e,"scope").startsWith("dep/")&&s(e,"role")!=="reads"&&s(e,"value")!=="withdraw"),f=new Map;for(const e of a.filter($)){const o=i(e);for(const r of c){if(!n(o,i(r)))continue;const l=s(r,"value");a.some(u=>s(u,"scope")===s(r,"scope")&&s(u,"value")===l)||f.set(`${s(r,"scope")}\0${l}`,{scope:s(r,"scope"),digest:l})}}if(!f.size)return[];const w=[...m(v(t)).filter(e=>d(s(e,"scope"))&&s(e,"value")!=="withdraw").map(e=>({scope:s(e,"scope"),value:s(e,"value"),fields:i(e)})),...g(t).flatMap(e=>W(t,e).filter(o=>d(s(o,"scope"))&&s(o,"value")!=="withdraw").map(o=>({scope:`${e}/${s(o,"scope")}`,value:s(o,"value"),fields:i(o)})))].filter(e=>!a.some(o=>s(o,"value")==="withdraw"&&n(i(o),e.fields))),h=a.filter(e=>d(s(e,"scope"))&&s(e,"value")!=="withdraw").map(e=>({scope:s(e,"scope"),value:s(e,"value")}));return[...f.values()].flatMap(e=>{const o=[...w.filter(r=>r.value===e.digest).map(r=>r.scope),...h.filter(r=>r.value===e.digest).map(r=>r.scope)];return o.length?[{scope:e.scope,digest:e.digest,by:o}]:[]})}p(j,"aliasPinned");export{j as aliasPinned};
1
+ var O=Object.defineProperty;var p=(t,a)=>O(t,"name",{value:a,configurable:!0});import{library14_ENVELOPE as E}from"../vendor/runtime.js";import{fieldOf as s,fieldsOf as i}from"../fold/claims.js";import{lockStanding as m}from"../fold/keys.js";import{worldsIn as g}from"../fold/places.js";import{ownLockOf as W}from"../fold/signed.js";import{storeOf as v}from"./ledger.js";const n=p((t,a)=>Object.keys(t).filter(c=>!E.has(c)&&c!=="value").every(c=>a[c]===t[c]),"retracts"),d=p(t=>t==="uses"||t.startsWith("uses/")||t.split("/").slice(1,-1).includes("uses"),"pinScope"),$=p(t=>s(t,"value")==="withdraw"&&s(t,"scope").startsWith("dep/")&&s(t,"role")!=="reads","aliasWithdraw");function j(t,a){const c=m(v(t)).filter(e=>s(e,"scope").startsWith("dep/")&&s(e,"role")!=="reads"&&s(e,"value")!=="withdraw"),f=new Map;for(const e of a.filter($)){const o=i(e);for(const r of c){if(!n(o,i(r)))continue;const l=s(r,"value");a.some(u=>s(u,"scope")===s(r,"scope")&&s(u,"value")===l)||f.set(`${s(r,"scope")}\0${l}`,{scope:s(r,"scope"),digest:l})}}if(!f.size)return[];const w=[...m(v(t)).filter(e=>d(s(e,"scope"))&&s(e,"value")!=="withdraw").map(e=>({scope:s(e,"scope"),value:s(e,"value"),fields:i(e)})),...g(t).flatMap(e=>W(t,e).filter(o=>d(s(o,"scope"))&&s(o,"value")!=="withdraw").map(o=>({scope:`${e}/${s(o,"scope")}`,value:s(o,"value"),fields:i(o)})))].filter(e=>!a.some(o=>s(o,"value")==="withdraw"&&n(i(o),e.fields))),h=a.filter(e=>d(s(e,"scope"))&&s(e,"value")!=="withdraw").map(e=>({scope:s(e,"scope"),value:s(e,"value")}));return[...f.values()].flatMap(e=>{const o=[...w.filter(r=>r.value===e.digest).map(r=>r.scope),...h.filter(r=>r.value===e.digest).map(r=>r.scope)];return o.length?[{scope:e.scope,digest:e.digest,by:o}]:[]})}p(j,"aliasPinned");export{j as aliasPinned};
package/dist/land/held.js CHANGED
@@ -1 +1 @@
1
- var f=Object.defineProperty;var a=(r,t)=>f(r,"name",{value:t,configurable:!0});import{fieldOf as n}from"../fold/claims.js";import{library4_spanOf as l}from"../vendor/runtime.js";import{blobAt as c,ledgerLines as p,storeAt as i}from"./ledger.js";const u="store",d=a((r,t)=>{const s=t.split("/").pop()??"";return t.startsWith("cas/blobs/")?c(r,s):t.startsWith("cas/laid/")?i(r,"cas","laid",s):t.startsWith("cas/answers/")?i(r,"cas","answers",s):i(r,...t.split("/"))},"pathOf"),m=a(r=>l(n(r,"value"))?.hi??0,"sizeOf");function b(r){return p(r,u).filter(t=>n(t,"value")!=="withdraw").map(t=>{const s=n(t,"scope");return{scope:s,bytes:m(t),at:d(r,s)}})}a(b,"inventory");const v=a((r,t,s)=>b(t).reduce((e,o)=>e+o.bytes,0),"heldBytes");export{v as heldBytes};
1
+ var f=Object.defineProperty;var a=(r,t)=>f(r,"name",{value:t,configurable:!0});import{fieldOf as n}from"../fold/claims.js";import{library7_spanOf as l}from"../vendor/runtime.js";import{blobAt as c,ledgerLines as p,storeAt as i}from"./ledger.js";const u="store",d=a((r,t)=>{const s=t.split("/").pop()??"";return t.startsWith("cas/blobs/")?c(r,s):t.startsWith("cas/laid/")?i(r,"cas","laid",s):t.startsWith("cas/answers/")?i(r,"cas","answers",s):i(r,...t.split("/"))},"pathOf"),m=a(r=>l(n(r,"value"))?.hi??0,"sizeOf");function b(r){return p(r,u).filter(t=>n(t,"value")!=="withdraw").map(t=>{const s=n(t,"scope");return{scope:s,bytes:m(t),at:d(r,s)}})}a(b,"inventory");const v=a((r,t,s)=>b(t).reduce((e,o)=>e+o.bytes,0),"heldBytes");export{v as heldBytes};
@@ -1,7 +1,6 @@
1
- var Z=Object.defineProperty;var i=(e,t)=>Z(e,"name",{value:t,configurable:!0});import{preparingView as R,viewInput as M}from"../host/reading-context.js";import{actLines as g,committedLocalActs as x}from"../host/ports/local-act.js";import{readdirSync as V}from"node:fs";import{requireEffects as z}from"../host/read-only.js";import{appendFileSync as X,closeSync as B,dirname as S,existsSync as u,join as $,linkSync as C,mkdirSync as b,openSync as J,readFileSync as w,readSync as P,renameSync as q,rmSync as D,statSync as G,writeFileSync as A}from"../host/io.js";import{storeRoot as H}from"../host/ports/store.js";import{library11_canonical as K,library11_EXTENSION as d,library11_PROTOCOL as m}from"../vendor/runtime.js";import{fieldOf as p}from"../fold/claims.js";import{observeText as Q}from"../observe/files.js";function he(e){return $(H(e),d)}i(he,"storeOf");function h(e,...t){return $(e,...t)}i(h,"storeAt");function O(e,t){return h(e,"ledger",`${t.replace(/[^a-zA-Z0-9_-]/g,"")}${d}`)}i(O,"writerFile");const L=new Map;function E(e,t){return N(e,t,".",v(O(e,t)))}i(E,"ledgerLines");function W(e,t,n){return h(e,"ledger",t.replace(/[^a-zA-Z0-9_-]/g,""),`${n.replace(/\/+$/,"")||"@"}${d}`)}i(W,"shardFile");const ye=i((e,t,n)=>N(e,t,n,v(W(e,t,n))),"shardLines"),_=new Map;function N(e,t,n,r){const o=x(e).flatMap(f=>f.bundle.placements?.filter(l=>l.place===n).flatMap(l=>g(l.records).filter(k=>p(k,"by")===t))??[]);if(!o.length)return r;const s=[...new Set([...r,...o])],c=e+"\0"+t+"\0"+n,a=_.get(c);return a?.length===s.length&&a.every((f,l)=>f===s[l])?a:(_.set(c,s),s)}i(N,"journalLines");function T(e){const t=$(e,"ledger");return M("ledger-writers:"+t,()=>u(t)?V(t).filter(n=>n.endsWith(d)).map(n=>n.slice(0,-d.length)):[],!1)}i(T,"legacyWriters");function ge(e){const t=T(e),n=x(e).flatMap(r=>r.bundle.placements?.filter(o=>o.place===".").flatMap(o=>g(o.records).map(s=>p(s,"by")))??[]);return[...new Set([...t,...n])]}i(ge,"ledgerWriters");function xe(e){const t=T(e),r=x(e).flatMap(s=>s.bundle.placements?.filter(c=>c.place===".").flatMap(c=>g(c.records))??[]);return[...new Set([...t,...r.map(s=>p(s,"by"))])].flatMap(s=>{const c=O(e,s),a=u(c)?w(c,"utf8").split(`
2
- `).filter(l=>l.startsWith(m)):[],f=r.filter(l=>p(l,"by")===s);return f.length?[...new Set([...a,...f])]:a})}i(xe,"rootLedgerLines");function Se(e,t,n,r){return j(W(e,t,n),r)}i(Se,"landShard");function v(e){if(R())return M("ledger:"+e,()=>u(e)?w(e,"utf8").split(`
3
- `).filter(c=>c.startsWith(m)):[],!1);const t=G(e,{throwIfNoEntry:!1});if(!t)return[];const n=`${Math.floor(t.mtimeMs)}-${t.size}`,r=L.get(e);if(r?.stamp===n)return r.lines;const o=r!==void 0&&r.size>0&&t.size>r.size?U(e,r.size,t.size):void 0,s=o!==void 0&&r!==void 0?[...r.lines,...o.split(`
4
- `).filter(c=>c.startsWith(m))]:w(e,"utf8").split(`
5
- `).filter(c=>c.startsWith(m));return L.set(e,{stamp:n,size:t.size,lines:s}),s}i(v,"linesAt");function U(e,t,n){const r=J(e,"r");try{const o=Buffer.alloc(n-t+1);return P(r,o,0,o.length,t-1),o[0]===10?o.subarray(1).toString("utf8"):void 0}finally{B(r)}}i(U,"tailOf");function j(e,t){const n=new Set(v(e)),r=[...new Set(t)].filter(o=>o.startsWith(m)&&!n.has(o));return r.length&&(b(S(e),{recursive:!0}),X(e,`${r.join(`
1
+ var X=Object.defineProperty;var o=(e,t)=>X(e,"name",{value:t,configurable:!0});import{hostRequiresFreshBytes as q}from"../host/call-context.js";import{preparingView as C,viewInput as M}from"../host/reading-context.js";import{actLines as w,committedLocalActs as $}from"../host/ports/local-act.js";import{readdirSync as J}from"node:fs";import{requireEffects as A}from"../host/read-only.js";import{appendFileSync as P,closeSync as H,dirname as v,existsSync as h,join as O,linkSync as D,mkdirSync as z,openSync as G,readFileSync as E,readSync as K,renameSync as Q,rmSync as U,statSync as Y,writeFileSync as T}from"../host/io.js";import{storeRoot as ee}from"../host/ports/store.js";import{library14_canonical as te,library14_EXTENSION as d,library14_PROTOCOL as y}from"../vendor/runtime.js";import{fieldOf as p}from"../fold/claims.js";import{observeText as re}from"../observe/files.js";function we(e){return O(ee(e),d)}o(we,"storeOf");function m(e,...t){return O(e,...t)}o(m,"storeAt");function g(e,t){return m(e,"ledger",`${t.replace(/[^a-zA-Z0-9_-]/g,"")}${d}`)}o(g,"writerFile");const W=new Map,u=new Map;let x=0;function b(e){const t=h(e)?E(e,"utf8"):"",r=u.get(e);if(r?.text===t)return r.lines;const n=Object.freeze(t.split(`
2
+ `).filter(s=>s.startsWith(y))),i=Buffer.byteLength(t);if(r&&(x-=Buffer.byteLength(r.text),u.delete(e)),i<=32*1024*1024){for(;u.size>=32||x+i>32*1024*1024;){const s=u.keys().next().value;if(s===void 0)break;x-=Buffer.byteLength(u.get(s).text),u.delete(s)}u.set(e,{text:t,lines:n}),x+=i}return n}o(b,"currentLinesAt");function _(e,t){return B(e,t,".",L(g(e,t)))}o(_,"ledgerLines");function N(e,t,r){return m(e,"ledger",t.replace(/[^a-zA-Z0-9_-]/g,""),`${r.replace(/\/+$/,"")||"@"}${d}`)}o(N,"shardFile");const $e=o((e,t,r)=>B(e,t,r,L(N(e,t,r))),"shardLines"),j=new Map;function B(e,t,r,n){const i=$(e).flatMap(l=>l.bundle.placements?.filter(a=>a.place===r).flatMap(a=>w(a.records).filter(V=>p(V,"by")===t))??[]);if(!i.length)return n;const s=[...new Set([...n,...i])],c=e+"\0"+t+"\0"+r,f=j.get(c);return f?.length===s.length&&f.every((l,a)=>l===s[a])?f:(j.set(c,s),s)}o(B,"journalLines");function k(e){const t=O(e,"ledger");return M("ledger-writers:"+t,()=>h(t)?J(t).filter(r=>r.endsWith(d)).map(r=>r.slice(0,-d.length)):[],!1)}o(k,"legacyWriters");function ve(e){const t=k(e),r=$(e).flatMap(n=>n.bundle.placements?.filter(i=>i.place===".").flatMap(i=>w(i.records).map(s=>p(s,"by")))??[]);return[...new Set([...t,...r])]}o(ve,"ledgerWriters");let F;function Oe(e){const t=k(e),r=$(e);if(!r.length){const s=t.map(l=>b(g(e,l))),c=F;if(c?.store===e&&c.writers.length===t.length&&c.writers.every((l,a)=>l===t[a])&&c.parts.every((l,a)=>l===s[a]))return c.lines;const f=Object.freeze(s.flat());return F={store:e,writers:[...t],parts:s,lines:f},f}const n=r.flatMap(s=>s.bundle.placements?.filter(c=>c.place===".").flatMap(c=>w(c.records))??[]);return[...new Set([...t,...n.map(s=>p(s,"by"))])].flatMap(s=>{const c=g(e,s),f=b(c),l=n.filter(a=>p(a,"by")===s);return l.length?[...new Set([...f,...l])]:f})}o(Oe,"rootLedgerLines");function ze(e,t,r,n){return I(N(e,t,r),n)}o(ze,"landShard");function L(e){if(C())return M("ledger:"+e,()=>b(e),!1);if(q())return b(e);const t=Y(e,{throwIfNoEntry:!1});if(!t)return[];const r=`${Math.floor(t.mtimeMs)}-${t.size}`,n=W.get(e);if(n?.stamp===r)return n.lines;const i=n!==void 0&&n.size>0&&t.size>n.size?ne(e,n.size,t.size):void 0,s=i!==void 0&&n!==void 0?[...n.lines,...i.split(`
3
+ `).filter(c=>c.startsWith(y))]:E(e,"utf8").split(`
4
+ `).filter(c=>c.startsWith(y));return W.set(e,{stamp:r,size:t.size,lines:s}),s}o(L,"linesAt");function ne(e,t,r){const n=G(e,"r");try{const i=Buffer.alloc(r-t+1);return K(n,i,0,i.length,t-1),i[0]===10?i.subarray(1).toString("utf8"):void 0}finally{H(n)}}o(ne,"tailOf");function I(e,t){const r=new Set(L(e)),n=[...new Set(t)].filter(i=>i.startsWith(y)&&!r.has(i));return n.length&&(z(v(e),{recursive:!0}),P(e,`${n.join(`
6
5
  `)}
7
- `)),r.length}i(j,"appendNew");function $e(e,t){return E(e,t).filter(n=>n.includes(`by=${t}`)&&/\bsig=/.test(n))}i($e,"signedLines");function Y(e,t){return h(e,"cas","blobs",t.slice(t.indexOf(":")+1))}i(Y,"blobAt");function F(e,t){return u(e)||ee(e,t),e}i(F,"landWhole");function ee(e,t){z("persistent replacement"),b(S(e),{recursive:!0});const n=`${e}.${process.pid}.part`;A(n,t),q(n,e)}i(ee,"replaceWhole");const be=i((e,t,n)=>{const r=F(Y(e,t),n);return te(e,"blobs",t,n.byteLength),r},"landBlob");function te(e,t,n,r){const o=n.replace(/^[^:]*:/,""),s=`cas/${t}/${o}`,c=E(e,"store").filter(a=>p(a,"scope")===s);c.length&&p(c[c.length-1],"value")!=="withdraw"||re(e,"store",[K({scope:s,role:"writes",form:"interval",measure:"bytes",value:`${r}..${r}`,at:`place:${t==="answers"?o:`sha256:${o}`}`,by:"store"})])}i(te,"holdStore");const I=i((e,t)=>h(e,"cas","memo",...t.split("/").map(n=>n.replace(/[^a-zA-Z0-9._@-]/g,"_"))),"memoAt");function ne(e,t,n){const r=I(e,t);if(u(r))return r;b(S(r),{recursive:!0});const o=`${r}.${process.pid}.part`;A(o,n);try{C(o,r)}catch(s){if(s.code!=="EEXIST")throw s}finally{D(o,{force:!0})}return r}i(ne,"landMemo");const we=i((e,t,n)=>F(h(e,"cas","envelopes",`${t.slice(t.indexOf(":")+1)}.json`),n),"landEnvelope");function re(e,t,n){z("ledger admission");const r=O(e,t);return{at:r,appended:j(r,n)}}i(re,"land");const y=i(e=>e.replace(/[^a-zA-Z0-9._@-]/g,"_"),"step");function oe(e,t,n){return I(e,`verdict/${y(t)}/${y(n)}`)}i(oe,"verdictAt");function Oe(e,t,n){const r=Q(oe(e,t,n));if(r!==void 0)try{const o=JSON.parse(r);return Array.isArray(o)?o:void 0}catch{return}}i(Oe,"keptVerdict");function ve(e,t,n,r){ne(e,`verdict/${y(t)}/${y(n)}`,new TextEncoder().encode(JSON.stringify(r)))}i(ve,"keepVerdict");export{Y as blobAt,te as holdStore,ve as keepVerdict,Oe as keptVerdict,re as land,be as landBlob,we as landEnvelope,ne as landMemo,Se as landShard,E as ledgerLines,ge as ledgerWriters,I as memoAt,ee as replaceWhole,xe as rootLedgerLines,W as shardFile,ye as shardLines,$e as signedLines,h as storeAt,he as storeOf,O as writerFile};
6
+ `)),n.length}o(I,"appendNew");function Le(e,t){return _(e,t).filter(r=>r.includes(`by=${t}`)&&/\bsig=/.test(r))}o(Le,"signedLines");function ie(e,t){return m(e,"cas","blobs",t.slice(t.indexOf(":")+1))}o(ie,"blobAt");function R(e,t){return h(e)||se(e,t),e}o(R,"landWhole");function se(e,t){A("persistent replacement"),z(v(e),{recursive:!0});const r=`${e}.${process.pid}.part`;T(r,t),Q(r,e)}o(se,"replaceWhole");const Me=o((e,t,r)=>{const n=R(ie(e,t),r);return oe(e,"blobs",t,r.byteLength),n},"landBlob");function oe(e,t,r,n){const i=r.replace(/^[^:]*:/,""),s=`cas/${t}/${i}`,c=_(e,"store").filter(f=>p(f,"scope")===s);c.length&&p(c[c.length-1],"value")!=="withdraw"||le(e,"store",[te({scope:s,role:"writes",form:"interval",measure:"bytes",value:`${n}..${n}`,at:`place:${t==="answers"?i:`sha256:${i}`}`,by:"store"})])}o(oe,"holdStore");const Z=o((e,t)=>m(e,"cas","memo",...t.split("/").map(r=>r.replace(/[^a-zA-Z0-9._@-]/g,"_"))),"memoAt");function ce(e,t,r){const n=Z(e,t);if(h(n))return n;z(v(n),{recursive:!0});const i=`${n}.${process.pid}.part`;T(i,r);try{D(i,n)}catch(s){if(s.code!=="EEXIST")throw s}finally{U(i,{force:!0})}return n}o(ce,"landMemo");const Ae=o((e,t,r)=>R(m(e,"cas","envelopes",`${t.slice(t.indexOf(":")+1)}.json`),r),"landEnvelope");function le(e,t,r){A("ledger admission");const n=g(e,t);return{at:n,appended:I(n,r)}}o(le,"land");const S=o(e=>e.replace(/[^a-zA-Z0-9._@-]/g,"_"),"step");function fe(e,t,r){return Z(e,`verdict/${S(t)}/${S(r)}`)}o(fe,"verdictAt");function Ee(e,t,r){const n=re(fe(e,t,r));if(n!==void 0)try{const i=JSON.parse(n);return Array.isArray(i)?i:void 0}catch{return}}o(Ee,"keptVerdict");function Te(e,t,r,n){ce(e,`verdict/${S(t)}/${S(r)}`,new TextEncoder().encode(JSON.stringify(n)))}o(Te,"keepVerdict");export{ie as blobAt,oe as holdStore,Te as keepVerdict,Ee as keptVerdict,le as land,Me as landBlob,Ae as landEnvelope,ce as landMemo,ze as landShard,_ as ledgerLines,ve as ledgerWriters,Z as memoAt,se as replaceWhole,Oe as rootLedgerLines,N as shardFile,$e as shardLines,Le as signedLines,m as storeAt,we as storeOf,g as writerFile};
package/dist/land/sign.js CHANGED
@@ -1 +1 @@
1
- var u=Object.defineProperty;var a=(t,e)=>u(t,"name",{value:e,configurable:!0});import{library11_canonical as l,library11_parse as y,library11_parseForSigning as p,library11_signedBytes as d,library11_signedFieldsOf as h}from"../vendor/runtime.js";import{verifyBytes as g}from"../host/adapters/keys/ed25519.js";import{SigningFailure as b}from"../host/ports/signing.js";function k(t,e){const o=p(t);if(o.kind!=="fact")return{kind:"refuse",why:"REFUSE\xB7accept not a claim line"};const i=o.value.fields,s=i.scope??"?";if(i.sig!==void 0)return{kind:"refuse",why:`REFUSE\xB7accept ${s} is already signed`};if(i.by!=="target")return{kind:"refuse",why:`REFUSE\xB7accept ${s} must be drafted by=target`};const n=h(i,e.by);return e.epoch!==void 0&&(n.epoch=String(e.epoch)),{kind:"fact",fields:n}}a(k,"prepareConsentLine");async function m(t,e,o,i,s){const n=[];for(const r of t){const f=k(r,e);if(f.kind==="refuse")return f;n.push(f.fields)}if(!n.length)return{kind:"refuse",why:`REFUSE\xB7signer ${e.by} empty lot`};let c;try{c=await s({bytes:n.map(r=>d(r)),keyId:e.by,algorithm:e.algorithm})}catch(r){return{kind:"refuse",why:r instanceof b?r.message:`REFUSE\xB7signer ${e.by} acquisition failed`}}return c.length!==n.length||c.some((r,f)=>r.keyId!==e.by||!g(d(n[f]),o,r.signature,i))?{kind:"refuse",why:`REFUSE\xB7signer ${e.by} signature does not verify`}:{kind:"fact",lines:n.map((r,f)=>l({...r,sig:c[f].signature}))}}a(m,"signConsentLot");function v(t,e,o){const i=y(t);if(i.kind!=="fact")return!1;const{sig:s,...n}=i.value.fields;return typeof s=="string"&&g(d(n),e,s,o)}a(v,"verifiesOwnerLine");function R(t,e,o){const{sig:i,...s}=t;return typeof i=="string"&&g(d(s),e,i,o)}a(R,"verifiesFields");export{m as signConsentLot,R as verifiesFields,v as verifiesOwnerLine};
1
+ var d=Object.defineProperty;var f=(r,e)=>d(r,"name",{value:e,configurable:!0});import{library14_canonical as p,library14_parse as h,library14_parseForSigning as b,library14_signedBytes as g,library14_signedFieldsOf as k}from"../vendor/runtime.js";import{verifyBytes as u}from"../host/adapters/keys/ed25519.js";import{SigningFailure as v}from"../host/ports/signing.js";function F(r,e){const a=b(r);if(a.kind!=="fact")return{kind:"refuse",why:"REFUSE\xB7accept not a claim line"};const s=a.value.fields,n=s.scope??"?";if(s.sig!==void 0)return{kind:"refuse",why:`REFUSE\xB7accept ${n} is already signed`};if(s.by!=="target")return{kind:"refuse",why:`REFUSE\xB7accept ${n} must be drafted by=target`};const i=k(s,e.by);return e.epoch!==void 0&&(i.epoch=String(e.epoch)),{kind:"fact",fields:i}}f(F,"prepareConsentLine");async function O(r,e,a,s,n){const i=[];for(const t of r){const o=F(t,e);if(o.kind==="refuse")return o;i.push(o.fields)}if(!i.length)return{kind:"refuse",why:`REFUSE\xB7signer ${e.by} empty lot`};let c;try{c=await n({bytes:i.map(t=>g(t)),keyId:e.by,algorithm:e.algorithm})}catch(t){return{kind:"refuse",why:t instanceof v?t.message:`REFUSE\xB7signer ${e.by} acquisition failed`}}return c.length!==i.length||c.some((t,o)=>t.keyId!==e.by||!u(g(i[o]),a,t.signature,s))?{kind:"refuse",why:`REFUSE\xB7signer ${e.by} signature does not verify`}:{kind:"fact",lines:i.map((t,o)=>p({...t,sig:c[o].signature}))}}f(O,"signConsentLot");function R(r,e,a){const s=h(r);if(s.kind!=="fact")return!1;const{sig:n,...i}=s.value.fields;return typeof n=="string"&&u(g(i),e,n,a)}f(R,"verifiesOwnerLine");const y=new WeakMap;function U(r,e,a){const s=JSON.stringify(a),n=y.get(r);if(n&&n.publicKey===e&&n.algorithms===s)return n.valid;const i=n!==void 0||Object.isFrozen(r)&&Object.prototype.hasOwnProperty.call(r,"sig")&&Object.values(Object.getOwnPropertyDescriptors(r)).every(l=>"value"in l&&typeof l.value=="string"),{sig:c,...t}=r,o=typeof c=="string"&&u(g(t),e,c,a);return i&&y.set(r,{publicKey:e,algorithms:s,valid:o}),o}f(U,"verifiesFields");export{O as signConsentLot,U as verifiesFields,R as verifiesOwnerLine};
@@ -1 +1 @@
1
- var u=Object.defineProperty;var d=(r,n)=>u(r,"name",{value:n,configurable:!0});import{library7_readStanding as g}from"../vendor/runtime.js";import{fieldOf as c}from"../fold/claims.js";import{contentAt as w}from"../host/selected-topos.js";import{storeOf as v}from"./ledger.js";import{ContentNeeded as f}from"../host/content-needed.js";import{observeFile as E}from"../observe/files.js";import{createHash as S}from"node:crypto";import{resolve as m,relative as x}from"node:path";function y(r,n){const t=c(n,"value");try{return w(t,v(r))}catch(l){if(!(l instanceof f))throw l}const e=c(n,"needs");if(!e||e.includes("|")||e.includes("*"))throw new f(t);const i=m(r,e),o=x(m(r),i);if(!o||o===".."||o.startsWith("../"))throw Error("standing coordinate is outside the place");const a=E(i);if(a===void 0)throw new f(t);const s=t.indexOf(":"),h=t.slice(0,s),p=t.slice(s+1);if(S(h).update(a).digest("hex")!==p)throw Error("standing coordinate content hash mismatch");return a}d(y,"heldStanding");function P(r,n,t){for(const e of n){const i=c(e,"scope"),o=c(e,"value"),a=i.split("/");if(!(!(i==="uses"||a.slice(0,-1).includes("uses"))||o==="withdraw"))try{g(new TextDecoder("utf-8",{fatal:!0}).decode(t?t(o):y(r,e)))}catch(s){throw Error(`REFUSE\xB7pin ${i} ${o} \xB7 ${s instanceof Error?s.message:String(s)} \xB7 nothing landed`)}}}d(P,"admitStandingPins");export{P as admitStandingPins};
1
+ var u=Object.defineProperty;var d=(r,n)=>u(r,"name",{value:n,configurable:!0});import{library10_readStanding as g}from"../vendor/runtime.js";import{fieldOf as c}from"../fold/claims.js";import{contentAt as w}from"../host/selected-topos.js";import{storeOf as v}from"./ledger.js";import{ContentNeeded as f}from"../host/content-needed.js";import{observeFile as E}from"../observe/files.js";import{createHash as S}from"node:crypto";import{resolve as m,relative as x}from"node:path";function y(r,n){const t=c(n,"value");try{return w(t,v(r))}catch(l){if(!(l instanceof f))throw l}const e=c(n,"needs");if(!e||e.includes("|")||e.includes("*"))throw new f(t);const i=m(r,e),o=x(m(r),i);if(!o||o===".."||o.startsWith("../"))throw Error("standing coordinate is outside the place");const a=E(i);if(a===void 0)throw new f(t);const s=t.indexOf(":"),h=t.slice(0,s),p=t.slice(s+1);if(S(h).update(a).digest("hex")!==p)throw Error("standing coordinate content hash mismatch");return a}d(y,"heldStanding");function P(r,n,t){for(const e of n){const i=c(e,"scope"),o=c(e,"value"),a=i.split("/");if(!(!(i==="uses"||a.slice(0,-1).includes("uses"))||o==="withdraw"))try{g(new TextDecoder("utf-8",{fatal:!0}).decode(t?t(o):y(r,e)))}catch(s){throw Error(`REFUSE\xB7pin ${i} ${o} \xB7 ${s instanceof Error?s.message:String(s)} \xB7 nothing landed`)}}}d(P,"admitStandingPins");export{P as admitStandingPins};
@@ -1 +1 @@
1
- var v=Object.defineProperty;var r=(e,n)=>v(e,"name",{value:n,configurable:!0});import{createHash as y,join as u}from"../host/io.js";import{said as $,wordOf as d,wordsOf as h}from"../fold/wire.js";import{fieldOf as f}from"../fold/claims.js";import{library12_point as _,library12_region as B,library12_within as E}from"../vendor/runtime.js";import{library11_canonical as F}from"../vendor/runtime.js";import{land as L,ledgerLines as m}from"./ledger.js";import{lockStanding as p}from"../fold/keys.js";import{ownLock as S}from"../observe/runner.js";import{entriesIn as j,linkOf as C,observeFile as M,observeText as T,stampOf as g}from"../observe/files.js";function K(e){const n=[],o=[];for(const i of e.split("|").map(t=>t.trim()).filter(Boolean)){const t=i.split("/").filter(Boolean);for(;t[t.length-1]==="*"||t[t.length-1]==="**";)t.pop();if(!t.length||i.includes("#")||t.some(s=>s.includes("*"))){o.push(i);continue}n.push(t.join("/"))}return{locations:n,refused:o}}r(K,"locationsOf");function w(e){return`sha256:${y("sha256").update(e).digest("hex")}`}r(w,"digestOf");function N(e,n,o){const i=new Map,t=r(s=>{if(o(s)!=="source")return;const a=u(e,s),c=g(a);if(c){if(c.kind==="link"){i.set(s,w(`link:${C(a)}`));return}if(c.kind==="dir"){for(const O of j(a).map(k=>k.name).sort())t(u(s,O));return}c.kind==="file"&&i.set(s,w(Buffer.from(M(a)??new Uint8Array)))}},"visit");return t(n.replace(/\/$/,"")),i}r(N,"coordinatesOf");function P(e,n){if(g(u(e,n))?.kind!=="file")return;const o=T(u(e,n))??"";return/^witness=([^\s]+)/m.exec(o)?.[1]??/"witness"\s*:\s*"([^"]+)"/.exec(o)?.[1]}r(P,"witnessOf");function x(e,n){const o=$(S(),n);if(!o.length)throw new Error(`REFUSE\xB7instrument ${n} has no admitted declaration in the instrument lock`);return h(e,"families").length?d(e,"families",o):o[0]}r(x,"storeFamily");const l=r(e=>x(e,"store/vouches"),"vouching"),U=r(e=>x(e,"store/source"),"sourced"),b=r(e=>f(e,"measure")==="digest"&&f(e,"scope").includes("/")?f(e,"scope").slice(f(e,"scope").indexOf("/")+1):void 0,"sourceOf");function Q(e,n){return E(_(e),B(n))}r(Q,"inside");function W(e){const n=new Map,o=p(e);if(!h(o,"states").length)return n;const i=d(o,"states","absent");for(const t of m(e,l(o))){const s=b(t),a=f(t,"value");!s||!a||(a===i?n.delete(s):n.set(s,a))}return n}r(W,"vouchedCoordinates");function X(e){const n=new Set;for(const o of m(e,l(p(e)))){const i=b(o);i&&n.add(i)}return n}r(X,"everLanded");function Y(e){return m(e,l(p(e))).length>0}r(Y,"hasVouchedTree");function Z(e,n,o,i){const t=p(e),s=r((a,c)=>F({scope:`${U(t)}/${a}`,role:"writes",form:"alphabet",measure:"digest",value:c,by:"land",at:i}),"line");return L(e,l(t),[...[...n].map(([a,c])=>s(a,c)),...o.map(a=>s(a,d(t,"states","absent")))]).appended}r(Z,"landCoordinates");export{N as coordinatesOf,X as everLanded,Y as hasVouchedTree,Q as inside,Z as landCoordinates,K as locationsOf,b as sourceOf,U as sourced,W as vouchedCoordinates,l as vouching,P as witnessOf};
1
+ var v=Object.defineProperty;var r=(e,n)=>v(e,"name",{value:n,configurable:!0});import{createHash as y,join as u}from"../host/io.js";import{said as $,wordOf as d,wordsOf as h}from"../fold/wire.js";import{fieldOf as f}from"../fold/claims.js";import{library0_point as _,library0_region as B,library0_within as E}from"../vendor/runtime.js";import{library14_canonical as F}from"../vendor/runtime.js";import{land as L,ledgerLines as m}from"./ledger.js";import{lockStanding as p}from"../fold/keys.js";import{ownLock as S}from"../observe/runner.js";import{entriesIn as j,linkOf as C,observeFile as M,observeText as T,stampOf as g}from"../observe/files.js";function K(e){const n=[],o=[];for(const i of e.split("|").map(t=>t.trim()).filter(Boolean)){const t=i.split("/").filter(Boolean);for(;t[t.length-1]==="*"||t[t.length-1]==="**";)t.pop();if(!t.length||i.includes("#")||t.some(s=>s.includes("*"))){o.push(i);continue}n.push(t.join("/"))}return{locations:n,refused:o}}r(K,"locationsOf");function w(e){return`sha256:${y("sha256").update(e).digest("hex")}`}r(w,"digestOf");function N(e,n,o){const i=new Map,t=r(s=>{if(o(s)!=="source")return;const a=u(e,s),c=g(a);if(c){if(c.kind==="link"){i.set(s,w(`link:${C(a)}`));return}if(c.kind==="dir"){for(const O of j(a).map(k=>k.name).sort())t(u(s,O));return}c.kind==="file"&&i.set(s,w(Buffer.from(M(a)??new Uint8Array)))}},"visit");return t(n.replace(/\/$/,"")),i}r(N,"coordinatesOf");function P(e,n){if(g(u(e,n))?.kind!=="file")return;const o=T(u(e,n))??"";return/^witness=([^\s]+)/m.exec(o)?.[1]??/"witness"\s*:\s*"([^"]+)"/.exec(o)?.[1]}r(P,"witnessOf");function x(e,n){const o=$(S(),n);if(!o.length)throw new Error(`REFUSE\xB7instrument ${n} has no admitted declaration in the instrument lock`);return h(e,"families").length?d(e,"families",o):o[0]}r(x,"storeFamily");const l=r(e=>x(e,"store/vouches"),"vouching"),U=r(e=>x(e,"store/source"),"sourced"),b=r(e=>f(e,"measure")==="digest"&&f(e,"scope").includes("/")?f(e,"scope").slice(f(e,"scope").indexOf("/")+1):void 0,"sourceOf");function Q(e,n){return E(_(e),B(n))}r(Q,"inside");function W(e){const n=new Map,o=p(e);if(!h(o,"states").length)return n;const i=d(o,"states","absent");for(const t of m(e,l(o))){const s=b(t),a=f(t,"value");!s||!a||(a===i?n.delete(s):n.set(s,a))}return n}r(W,"vouchedCoordinates");function X(e){const n=new Set;for(const o of m(e,l(p(e)))){const i=b(o);i&&n.add(i)}return n}r(X,"everLanded");function Y(e){return m(e,l(p(e))).length>0}r(Y,"hasVouchedTree");function Z(e,n,o,i){const t=p(e),s=r((a,c)=>F({scope:`${U(t)}/${a}`,role:"writes",form:"alphabet",measure:"digest",value:c,by:"land",at:i}),"line");return L(e,l(t),[...[...n].map(([a,c])=>s(a,c)),...o.map(a=>s(a,d(t,"states","absent")))]).appended}r(Z,"landCoordinates");export{N as coordinatesOf,X as everLanded,Y as hasVouchedTree,Q as inside,Z as landCoordinates,K as locationsOf,b as sourceOf,U as sourced,W as vouchedCoordinates,l as vouching,P as witnessOf};
@@ -1 +1 @@
1
- var s=Object.defineProperty;var o=(r,i)=>s(r,"name",{value:i,configurable:!0});import{library11_ENVELOPE as c}from"../vendor/runtime.js";import{fieldsOf as l}from"../fold/claims.js";import{library4_declaredConfig as u}from"../vendor/runtime.js";function f(r,i){const a=l(r),e=l(i);return Object.keys(a).filter(t=>!c.has(t)&&t!=="value").every(t=>e[t]===a[t])}o(f,"takes");function v(r){const i=r.filter(e=>l(e).value==="withdraw"),a=r.filter(e=>l(e).value!=="withdraw");return i.flatMap(e=>a.filter(t=>f(e,t)).map(t=>({withdraw:e,line:t})))}o(v,"retractedTogether");function b(r,i){const a=i.filter(t=>l(t).value!=="withdraw"&&r.some(n=>f(n,t))),e=a.map(t=>({line:t,got:u(t)}));return{taken:a,exact:e.filter(t=>t.got.distributive===!0).map(t=>t.line),inexact:e.filter(t=>t.got.distributive===!1).map(t=>t.line),open:e.filter(t=>t.got.distributive===null).map(t=>t.line)}}o(b,"withdrawal");export{v as retractedTogether,b as withdrawal};
1
+ var s=Object.defineProperty;var o=(r,i)=>s(r,"name",{value:i,configurable:!0});import{library14_ENVELOPE as c}from"../vendor/runtime.js";import{fieldsOf as l}from"../fold/claims.js";import{library7_declaredConfig as u}from"../vendor/runtime.js";function f(r,i){const a=l(r),e=l(i);return Object.keys(a).filter(t=>!c.has(t)&&t!=="value").every(t=>e[t]===a[t])}o(f,"takes");function v(r){const i=r.filter(e=>l(e).value==="withdraw"),a=r.filter(e=>l(e).value!=="withdraw");return i.flatMap(e=>a.filter(t=>f(e,t)).map(t=>({withdraw:e,line:t})))}o(v,"retractedTogether");function b(r,i){const a=i.filter(t=>l(t).value!=="withdraw"&&r.some(n=>f(n,t))),e=a.map(t=>({line:t,got:u(t)}));return{taken:a,exact:e.filter(t=>t.got.distributive===!0).map(t=>t.line),inexact:e.filter(t=>t.got.distributive===!1).map(t=>t.line),open:e.filter(t=>t.got.distributive===null).map(t=>t.line)}}o(b,"withdrawal");export{v as retractedTogether,b as withdrawal};
@@ -1 +1 @@
1
- var k=Object.defineProperty;var i=(e,n)=>k(e,"name",{value:n,configurable:!0});import{preparingView as w,viewInput as m}from"../host/reading-context.js";import{existsSync as p,lstatSync as x,statSync as D,readFileSync as a,readdirSync as h,readlinkSync as F}from"node:fs";import{join as v,relative as E,sep as T}from"node:path";const y=new Map;function $(e){let n=d(e);if(n?.isSymbolicLink())try{n=D(e)}catch{return}if(n===void 0||n.isDirectory()||!p(e))return;const r=`${n.ino}-${n.size}-${n.mtimeMs}`,s=y.get(e);if(s?.stamp===r)return s.bytes;let t;try{t=a(e)}catch(c){if(c.code!=="ENOENT")throw c;y.delete(e);return}return y.set(e,{stamp:r,bytes:t}),t}i($,"bytesAt");function S(e){if(!w())return $(e);const n=m("file:"+e,()=>{try{return a(e).toString("base64")}catch(r){if(["ENOENT","EISDIR"].includes(r.code??""))return;throw r}});return n===void 0?void 0:Buffer.from(n,"base64")}i(S,"viewBytes");const N=i(e=>(n=>n===void 0?void 0:new Uint8Array(n))(S(e)),"observeFile"),O=i(e=>S(e)?.toString("utf8"),"observeText"),j=i(e=>p(e),"exists");function z(e){const n=d(e);return n?{kind:n.isSymbolicLink()?"link":n.isDirectory()?"dir":n.isFile()?"file":"other",stamp:`${Math.floor(n.mtimeMs)}-${n.size}`}:void 0}i(z,"stampOf");function d(e){try{return x(e)}catch{return}}i(d,"stampable");const A=i(e=>F(e),"linkOf");function B(e){return d(e)?.isDirectory()?m("entries:"+e,()=>h(e,{withFileTypes:!0}).map(n=>({name:n.name,dir:n.isDirectory()}))):[]}i(B,"entriesIn");function U(e,n,r=()=>!0){const s=[],t=i(o=>E(n,o).split(T).join("/"),"name"),c=i((o,l)=>{if(l!=="link"){if(l==="file"){s.push(t(o));return}if(!(l!=="dir"||!r(t(o))))for(const u of h(o,{withFileTypes:!0})){const b=v(o,u.name);u.isSymbolicLink()||c(b,u.isFile()?"file":u.isDirectory()?"dir":"other")}}},"walk"),f=d(e);return c(e,f?f.isSymbolicLink()?"link":f.isDirectory()?"dir":f.isFile()?"file":"other":"other"),s}i(U,"coordinatesUnder");export{U as coordinatesUnder,B as entriesIn,j as exists,A as linkOf,N as observeFile,O as observeText,z as stampOf};
1
+ var F=Object.defineProperty;var r=(e,t)=>F(e,"name",{value:t,configurable:!0});import{hostRequiresFreshBytes as T}from"../host/call-context.js";import{preparingView as E,viewInput as p}from"../host/reading-context.js";import{existsSync as b,lstatSync as I,statSync as v,readFileSync as a,readdirSync as g,readlinkSync as D}from"node:fs";import{join as L,relative as M,sep as B}from"node:path";const m=new Map;function N(e){let t=y(e);if(t?.isSymbolicLink())try{t=v(e)}catch{return}if(t===void 0||t.isDirectory()||!b(e))return;const n=`${t.ino}-${t.size}-${t.mtimeMs}`,o=m.get(e);if(o?.stamp===n)return o.bytes;let i;try{i=a(e)}catch(c){if(c.code!=="ENOENT")throw c;m.delete(e);return}return m.set(e,{stamp:n,bytes:i}),i}r(N,"bytesAt");const s=new Map;let f=0;const S=16*1024*1024,R=256;function w(e){let t;try{t=a(e)}catch(i){if(!["ENOENT","EISDIR"].includes(i.code??""))throw i;const c=s.get(e);c&&(f-=c.bytes.length,s.delete(e));return}const n=s.get(e);if(n&&t.equals(n.bytes))return n;n&&(f-=n.bytes.length,s.delete(e));const o={bytes:t,encoded:t.toString("base64")};if(t.length<=S){for(;s.size>=R||f+t.length>S;){const i=s.keys().next().value;f-=s.get(i).bytes.length,s.delete(i)}s.set(e,o),f+=t.length}return o}r(w,"currentFile");function k(e){if(!E())return T()?w(e)?.bytes:N(e);const t=p("file:"+e,()=>w(e)?.encoded);if(t===void 0)return;const n=s.get(e);return n?.encoded===t?n.bytes:Buffer.from(t,"base64")}r(k,"viewBytes");const j=r(e=>(t=>t===void 0?void 0:new Uint8Array(t))(k(e)),"observeFile"),q=r(e=>k(e)?.toString("utf8"),"observeText"),A=r(e=>b(e),"exists");function C(e){const t=y(e);return t?{kind:t.isSymbolicLink()?"link":t.isDirectory()?"dir":t.isFile()?"file":"other",stamp:`${Math.floor(t.mtimeMs)}-${t.size}`}:void 0}r(C,"stampOf");function y(e){try{return I(e)}catch{return}}r(y,"stampable");const V=r(e=>D(e),"linkOf");function Y(e){return y(e)?.isDirectory()?p("entries:"+e,()=>g(e,{withFileTypes:!0}).map(t=>({name:t.name,dir:t.isDirectory()}))):[]}r(Y,"entriesIn");function G(e,t,n=()=>!0){const o=[],i=r(u=>M(t,u).split(B).join("/"),"name"),c=r((u,h)=>{if(h!=="link"){if(h==="file"){o.push(i(u));return}if(!(h!=="dir"||!n(i(u))))for(const l of g(u,{withFileTypes:!0})){const x=L(u,l.name);l.isSymbolicLink()||c(x,l.isFile()?"file":l.isDirectory()?"dir":"other")}}},"walk"),d=y(e);return c(e,d?d.isSymbolicLink()?"link":d.isDirectory()?"dir":d.isFile()?"file":"other":"other"),o}r(G,"coordinatesUnder");export{G as coordinatesUnder,Y as entriesIn,A as exists,V as linkOf,j as observeFile,q as observeText,C as stampOf};
@@ -1 +1 @@
1
- var b=Object.defineProperty;var i=(e,o)=>b(e,"name",{value:o,configurable:!0});import{mkdirSync as w,mkdtempSync as S,rmSync as g,writeFileSync as O}from"node:fs";import{tmpdir as h}from"node:os";import{basename as k,dirname as j,join as p,resolve as $}from"node:path";import{library11_canonical as E}from"../vendor/runtime.js";import{bytesDigest as u}from"../fold/digests.js";import{fieldOf as m,selfName as N}from"../fold/claims.js";import{observeText as v}from"./files.js";import{runReader as J}from"./run.js";import{wordOf as T}from"../fold/wire.js";import{lockStanding as q}from"../fold/keys.js";const x=i((e,o)=>p(e.split("/")[0]??"",`${T(o,"families","vector")}s`,`${k(e).replace(/\.[^.]+$/,"")}.json`),"vectorsOf"),I=i((e,o,s)=>[...new Set(o)].filter(t=>v($(e,x(t,s)))===void 0).length,"withoutVectors");function K(e){const o=new Map;for(const s of e.filter(t=>m(t,"measure")==="emits")){const t=`${m(s,"scope")} ${m(s,"value")}`;o.set(t,(o.get(t)??new Set).add(m(s,"at")))}return[...o.values()].filter(s=>s.size>1).length}i(K,"resetsOnEqualEmits");function z(e,o,s,t,l,a){const n=t==="process"?S(p(h(),`${N()}-vectors-`)):o;try{for(const r of t==="process"?l:[])for(const[c,y]of Object.entries(r.files??{}))w(j(p(n,r.place,c)),{recursive:!0}),O(p(n,r.place,c),y);const f=J($(o,s),n,l.map(r=>({place:r.place,...t==="js"?{text:r.text??""}:{}})),a);if(l.length&&f.every(r=>!r.length))return;const d=f.map(r=>r.filter(c=>!/^(cost|derived|vector-memo)\//.test(c.scope)).map(c=>JSON.stringify(c)).sort());return u(e,new TextEncoder().encode(JSON.stringify(d))).replace(/^[^:]*:/,"")}finally{n!==o&&g(n,{recursive:!0,force:!0})}}i(z,"emitted");function L(e){const o=v($(e.root,x(e.module,q(e.store))));if(o===void 0)return{by:e.code,lines:[]};const s=i(r=>u(e.store,new TextEncoder().encode(r)).replace(/^[^:]*:/,"").slice(0,12),"short"),t=s(`${e.code} ${s(o)}`),a=e.kept.filter(r=>m(r,"scope")===`reader/${e.module}`).find(r=>m(r,"measure")==="extension"&&m(r,"at")===`place:${t}`);if(a!==void 0&&m(a,"value")===e.code)return{by:e.code,lines:[]};const n=z(e.store,e.root,e.module,e.kind,JSON.parse(o).cases??[],e.lifetime);if(n===void 0)return{by:e.code,lines:[]};const f=e.code,d=i((r,c,y)=>E({scope:`reader/${e.module}`,role:"writes",form:"alphabet",measure:r,value:c,by:`${e.speaker}:${f}`,at:`place:${y}`}),"line");return{by:f,lines:[d("extension",f,t),d("emits",n,f)]}}i(L,"identityOf");export{L as identityOf,K as resetsOnEqualEmits,x as vectorsOf,I as withoutVectors};
1
+ var b=Object.defineProperty;var i=(e,o)=>b(e,"name",{value:o,configurable:!0});import{mkdirSync as w,mkdtempSync as S,rmSync as g,writeFileSync as O}from"node:fs";import{tmpdir as h}from"node:os";import{basename as k,dirname as j,join as p,resolve as $}from"node:path";import{library14_canonical as E}from"../vendor/runtime.js";import{bytesDigest as u}from"../fold/digests.js";import{fieldOf as m,selfName as N}from"../fold/claims.js";import{observeText as v}from"./files.js";import{runReader as J}from"./run.js";import{wordOf as T}from"../fold/wire.js";import{lockStanding as q}from"../fold/keys.js";const x=i((e,o)=>p(e.split("/")[0]??"",`${T(o,"families","vector")}s`,`${k(e).replace(/\.[^.]+$/,"")}.json`),"vectorsOf"),I=i((e,o,s)=>[...new Set(o)].filter(t=>v($(e,x(t,s)))===void 0).length,"withoutVectors");function K(e){const o=new Map;for(const s of e.filter(t=>m(t,"measure")==="emits")){const t=`${m(s,"scope")} ${m(s,"value")}`;o.set(t,(o.get(t)??new Set).add(m(s,"at")))}return[...o.values()].filter(s=>s.size>1).length}i(K,"resetsOnEqualEmits");function z(e,o,s,t,l,a){const n=t==="process"?S(p(h(),`${N()}-vectors-`)):o;try{for(const r of t==="process"?l:[])for(const[c,y]of Object.entries(r.files??{}))w(j(p(n,r.place,c)),{recursive:!0}),O(p(n,r.place,c),y);const f=J($(o,s),n,l.map(r=>({place:r.place,...t==="js"?{text:r.text??""}:{}})),a);if(l.length&&f.every(r=>!r.length))return;const d=f.map(r=>r.filter(c=>!/^(cost|derived|vector-memo)\//.test(c.scope)).map(c=>JSON.stringify(c)).sort());return u(e,new TextEncoder().encode(JSON.stringify(d))).replace(/^[^:]*:/,"")}finally{n!==o&&g(n,{recursive:!0,force:!0})}}i(z,"emitted");function L(e){const o=v($(e.root,x(e.module,q(e.store))));if(o===void 0)return{by:e.code,lines:[]};const s=i(r=>u(e.store,new TextEncoder().encode(r)).replace(/^[^:]*:/,"").slice(0,12),"short"),t=s(`${e.code} ${s(o)}`),a=e.kept.filter(r=>m(r,"scope")===`reader/${e.module}`).find(r=>m(r,"measure")==="extension"&&m(r,"at")===`place:${t}`);if(a!==void 0&&m(a,"value")===e.code)return{by:e.code,lines:[]};const n=z(e.store,e.root,e.module,e.kind,JSON.parse(o).cases??[],e.lifetime);if(n===void 0)return{by:e.code,lines:[]};const f=e.code,d=i((r,c,y)=>E({scope:`reader/${e.module}`,role:"writes",form:"alphabet",measure:r,value:c,by:`${e.speaker}:${f}`,at:`place:${y}`}),"line");return{by:f,lines:[d("extension",f,t),d("emits",n,f)]}}i(L,"identityOf");export{L as identityOf,K as resetsOnEqualEmits,x as vectorsOf,I as withoutVectors};
@@ -1 +1 @@
1
- var m=Object.defineProperty;var c=(s,t)=>m(s,"name",{value:t,configurable:!0});import*as p from"../vendor/library11.js";const{matches:f}=p,r=c((s,t)=>{const e=s.includes("@")?s.slice(0,s.indexOf("@")):s,[n,l]=t.endsWith("/")?[t.slice(0,-1),"/"]:[t,""],i=n.split("/");return i.some((b,o)=>f(e,`${i.slice(o).join("/")}${l}`))},"fits");export{r as fits};
1
+ var m=Object.defineProperty;var c=(s,t)=>m(s,"name",{value:t,configurable:!0});import*as p from"../vendor/library14.js";const{matches:f}=p,r=c((s,t)=>{const e=s.includes("@")?s.slice(0,s.indexOf("@")):s,[n,l]=t.endsWith("/")?[t.slice(0,-1),"/"]:[t,""],i=n.split("/");return i.some((b,o)=>f(e,`${i.slice(o).join("/")}${l}`))},"fits");export{r as fits};
@@ -1,4 +1,4 @@
1
- var pe=Object.defineProperty;var l=(e,r)=>pe(e,"name",{value:r,configurable:!0});import{childFlags as ue}from"../host/capsule.js";import{readingProfile as G,readingExecution as le,withReadingBoundary as de}from"../host/reading-context.js";import{library2_readingIdentityBytes as me}from"../vendor/runtime.js";import{portableReadingReceipt as ge,verifiedReadingReceipts as he}from"../host/reading-closures.js";import{bytesDigest as fe,instrumentCoordinates as be}from"../fold/digests.js";import{ownRoot as Q,processOf as we}from"./runner.js";import{contentPolicy as ye}from"../host/content-store.js";import{carriedFrom as ve}from"../fold/resolved.js";import{selectedCapsules as $e}from"../host/selected-capsules.js";import{selectionLines as Oe,projectionLines as ke}from"../fold/reach.js";import{selectionLines as Jt}from"../fold/reach.js";import{createHash as Se}from"node:crypto";import{basename as A,dirname as V,join as E,relative as P}from"node:path";import{library11_CAPSULE as X,library11_LOCK as Ee,library11_canonical as x,library11_matches as W,library11_PROTOCOL as Me}from"../vendor/runtime.js";import{library1_handed as I,library1_readsOf as xe}from"../vendor/runtime.js";import{foldCeilings as Re}from"../fold/ceilings.js";import{fieldOf as i,wireLinesOf as B}from"../fold/claims.js";import{isCeiling as We}from"../fold/configures.js";import{keyFor as Y}from"../fold/keys.js";import{casesHeld as je,placedReadings as Le}from"../fold/observed.js";import{capsuleAt as Fe,placesIn as Ce,spoken as Ne}from"../fold/places.js";import{rolesOf as Z}from"../fold/roles.js";import{ownLockOf as Ue}from"../fold/signed.js";import{wordOn as Ae}from"../fold/wire.js";import{placesOf as H,viewsOf as ee}from"../fold/views.js";import{zoomed as _e}from"../fold/zoom.js";import{sourced as Be}from"../land/vouched.js";import{coordinatesUnder as te,observeText as C}from"./files.js";import{ownLock as z}from"./runner.js";import{nameOf as _}from"../render/page.js";import{placeLines as Je,takenFor as Te}from"../fold/place-inputs.js";import{isRegionDeclaration as Pe}from"../fold/region-declarations.js";const re=l(e=>r=>fe(e,new TextEncoder().encode(r)),"receiptHasher"),$=l((e,r,s="alphabet",t="fact")=>x({scope:e,role:"writes",form:s,measure:t,value:r,by:"fold",at:"place:fold"}),"fact"),se=l((e=[])=>{const r=z(),s=l(o=>Pe(o,r),"eligible"),t=l(o=>`${i(o,"scope")} ${i(o,"measure")}`,"key"),a=e.filter(s),n=new Set(a.map(t));return[...r.filter(s).filter(o=>!n.has(t(o))),...a]},"described");function Ie(e,r){return[...new Set(r.map(t=>i(t,"scope")).filter(t=>t.startsWith("region/")&&!/[?*]/.test(t)))].filter(t=>e.some(a=>a.startsWith("region/")&&W(a,t))).map(t=>t.slice(7))}l(Ie,"regionNames");const Ft=l(()=>se().filter(e=>i(e,"measure")==="receipts").flatMap(e=>i(e,"value").split("|").filter(Boolean)),"describedReceipts");function He(e){const r=E(e.root,e.under??""),s=[...ee(e.standing).values()].flatMap(t=>"regions"in t&&t.shape&&C(E(r,t.shape))!==void 0?[t.shape]:[]);return[$("cases/held",String(je(e.observed))),...e.second?[$("second/verdict",e.second.verdict)]:[],...[...new Set(s)].map(t=>$(`${Be(e.standing)}/${t}`,"present")),..."ceilings"in e?[...ze(e),...Ve(e),...ne(e)?[]:Qe(e)]:[],...qe(e)]}l(He,"factsOf");function ze(e){const r=e.standing.filter(n=>i(n,"value")!=="withdraw"),s=r.filter(n=>We(n)&&(!e.under||Te(r,`${_(e)}/`)(n))),t=Re({standing:e.standing,ceilings:s,observed:e.observed,own:e.own,epoch:e.epoch}).readings,a=l(n=>n.map(o=>(o.split(" ").at(-1)??"").split("..").map(Number)).filter(o=>o.every(Number.isFinite)),"spans");return s.flatMap(n=>(o=>o===void 0?[]:[x({scope:i(e.under?_e(n,_(e)):n,"scope"),role:"reads",measure:i(n,"measure"),by:"fold",at:"place:fold",...a(o).length===o.length?{form:"interval",value:`${Math.min(...a(o).map(w=>w[0]))}..${Math.max(...a(o).map(w=>w.at(-1)))}`}:{form:"alphabet",value:[...new Set(o)].join("|")}})])(t.get(i(n,"scope"))))}l(ze,"readingsOf");const ne=l(e=>e.standing.some(r=>[`publish/${_(e)}/bootstrap`,"publish/bootstrap"].includes(i(r,"scope"))&&i(r,"value")!=="withdraw"),"released"),De=l(e=>[...new Set(e.standing.filter(r=>i(r,"value")!=="withdraw").flatMap(r=>(s=>s.length===3&&s[1]==="uses"&&s[2]===_(e)?[s[0]]:[])(i(r,"scope").split("/"))))],"pinnersOf"),Ke=l(e=>[X,Ee].map(r=>B(C(E(e.root,e.under??"",r)))).find(r=>r.some(s=>i(s,"scope").startsWith("capsule/")))??[],"capsuleOf"),qe=l(e=>((r,s)=>!Fe(e.root,(e.under??"").replace(/\/$/,""))||e.under===void 0&&!ne(e)?[]:te(r,r,t=>t===""||!A(t).startsWith(".")&&s(P(V(e.store),E(r,t)))!=="foreign").map(t=>$(`coordinate/${t}`,Ge(e.standing,e.under??"",t)?"needed":"present")))(E(e.root,e.under??""),Z(e.store)),"coordinatesOf"),Ge=l((e,r,s)=>e.some(t=>i(t,"value")!=="withdraw"&&i(t,"measure")!=="reader"&&i(t,"needs").split("|").some(a=>!["","./",r].includes(a)&&(a===`${r}${s}`||a.endsWith("/")&&`${r}${s}`.startsWith(a)||W(a,`${r}${s}`)))),"neededBy");function Qe(e){const r=l(s=>(t=>(a=>new Set(a.filter(n=>H(t,n).includes(`${s}/`)||!H(t,n).length&&C(E(e.root,s,n.shape))!==void 0&&!a.some(o=>o.shape===n.shape&&H(t,o).includes(`${s}/`))).flatMap(n=>n.regions.map(o=>o.name))))([...ee(t).values()].flatMap(a=>"regions"in a&&a.shape?[a]:[])))([...Ue(e.root,s,!0),...e.standing]),"at");return e.under?[...new Set(Ke(e).filter(s=>i(s,"scope").startsWith("region/")&&i(s,"role")==="render").map(s=>i(s,"scope").slice(7)))].map(s=>(t=>$(`asked/${s}`,`${t}..${t}`,"interval","count"))(De(e).map(r).filter(t=>t.has(s)).length)):[]}l(Qe,"askedOf");function Ve(e){const r=l(n=>(o=>[n.slice(0,o<0?n.length:o).trim(),n.slice(o<0?n.length:o+3).trim()||n])(n.indexOf(" \xB7 ")),"named"),s=(e.under??"").replace(/\/$/,""),t=new Set(s?Ce(e.root).filter(n=>n!==s):[]),a=l(n=>{if(!s||n===s||n.startsWith(`${s}/`))return!0;const o=n.split("/")[0]??"";return!t.has(o)},"mine");return[["claims",e.claims],["forks",e.forks.length+(e.second.verdict==="forks"?1:0)],["refused",e.refused.length],["vacuous",e.vacuous],["history",e.history.length],["met",e.ceilings.read],["short",e.ceilings.short.length],["over",e.ceilings.over.length]].map(([n,o])=>$(`verdict/${n}`,`${o}..${o}`,"interval","count")).concat([$("verdict/computation","readings"),$("verdict/encounters","uncomputed")]).concat(e.ceilings.short.filter(n=>a(r(n)[0])).map(n=>(([o,w])=>$(`unpaid/${o}`,w))(r(n)))).concat(e.ceilings.over.filter(n=>a(r(n)[0])).map(n=>(([o,w])=>$(`outside/${o}`,w))(r(n)))).concat(e.ceilings.unread.filter(a).map(n=>$(`unpaid/${n}`,"unread"))).concat(e.missing.filter(n=>a(i(n,"scope"))).map(n=>$(`unpaid/${i(n,"scope")}`,"unpaid"))).concat([$("walk/read",`${e.own["walk-read"]??0}..${e.own["walk-read"]??0}`,"interval","count"),$("walk/ms",`${e.own["walk-ms"]??0}..${e.own["walk-ms"]??0}`,"interval","count")])}l(Ve,"verdictOf");function Xe(e,r,s,t){const a=e.under??"",n=l(c=>I([`region/${r}`],s).filter(g=>g.measure===c).flatMap(g=>(g.value??"").split("|").filter(Boolean)),"said"),o=n("receipts"),w=Le(e.observed).filter(c=>c.place.startsWith(a)&&o.some(g=>W(g,c.question))).map(c=>x({scope:c.question,role:"reads",form:"alphabet",measure:c.measure,value:c.value,by:c.by,evidence:c.at,at:`place:${c.place.slice(a.length).replace(/^\.\/$/,"")}`})),m=Z(e.store),j=te(E(e.root,a),e.root,c=>c===""||!A(c).startsWith(".")&&m(P(V(e.store),E(e.root,c)))!=="foreign"),d=Ae(e.standing,"region-coordinate",z()),p=n(d).flatMap(c=>j.filter(g=>W(c,g.slice(a.length))||W(c,g))).flatMap(c=>{if(A(c)==="TARGET.bound"||A(c)==="receipts.bound")return[];const g=B(C(E(e.root,c)));return g.length?[x({scope:"said/lines",role:"reads",form:"alphabet",measure:"lines",value:g.join(`
1
+ var pe=Object.defineProperty;var l=(e,r)=>pe(e,"name",{value:r,configurable:!0});import{childFlags as ue}from"../host/capsule.js";import{readingProfile as G,readingExecution as le,withReadingBoundary as de}from"../host/reading-context.js";import{library5_readingIdentityBytes as me}from"../vendor/runtime.js";import{portableReadingReceipt as ge,verifiedReadingReceipts as he}from"../host/reading-closures.js";import{bytesDigest as fe,instrumentCoordinates as be}from"../fold/digests.js";import{ownRoot as Q,processOf as we}from"./runner.js";import{contentPolicy as ye}from"../host/content-store.js";import{carriedFrom as ve}from"../fold/resolved.js";import{selectedCapsules as $e}from"../host/selected-capsules.js";import{selectionLines as Oe,projectionLines as ke}from"../fold/reach.js";import{selectionLines as Jt}from"../fold/reach.js";import{createHash as Se}from"node:crypto";import{basename as A,dirname as V,join as E,relative as P}from"node:path";import{library14_CAPSULE as X,library14_LOCK as Ee,library14_canonical as x,library14_matches as W,library14_PROTOCOL as Me}from"../vendor/runtime.js";import{library4_handed as I,library4_readsOf as xe}from"../vendor/runtime.js";import{foldCeilings as Re}from"../fold/ceilings.js";import{fieldOf as i,wireLinesOf as B}from"../fold/claims.js";import{isCeiling as We}from"../fold/configures.js";import{keyFor as Y}from"../fold/keys.js";import{casesHeld as je,placedReadings as Le}from"../fold/observed.js";import{capsuleAt as Fe,placesIn as Ce,spoken as Ne}from"../fold/places.js";import{rolesOf as Z}from"../fold/roles.js";import{ownLockOf as Ue}from"../fold/signed.js";import{wordOn as Ae}from"../fold/wire.js";import{placesOf as H,viewsOf as ee}from"../fold/views.js";import{zoomed as _e}from"../fold/zoom.js";import{sourced as Be}from"../land/vouched.js";import{coordinatesUnder as te,observeText as C}from"./files.js";import{ownLock as z}from"./runner.js";import{nameOf as _}from"../render/page.js";import{placeLines as Je,takenFor as Te}from"../fold/place-inputs.js";import{isRegionDeclaration as Pe}from"../fold/region-declarations.js";const re=l(e=>r=>fe(e,new TextEncoder().encode(r)),"receiptHasher"),$=l((e,r,s="alphabet",t="fact")=>x({scope:e,role:"writes",form:s,measure:t,value:r,by:"fold",at:"place:fold"}),"fact"),se=l((e=[])=>{const r=z(),s=l(o=>Pe(o,r),"eligible"),t=l(o=>`${i(o,"scope")} ${i(o,"measure")}`,"key"),a=e.filter(s),n=new Set(a.map(t));return[...r.filter(s).filter(o=>!n.has(t(o))),...a]},"described");function Ie(e,r){return[...new Set(r.map(t=>i(t,"scope")).filter(t=>t.startsWith("region/")&&!/[?*]/.test(t)))].filter(t=>e.some(a=>a.startsWith("region/")&&W(a,t))).map(t=>t.slice(7))}l(Ie,"regionNames");const Ft=l(()=>se().filter(e=>i(e,"measure")==="receipts").flatMap(e=>i(e,"value").split("|").filter(Boolean)),"describedReceipts");function He(e){const r=E(e.root,e.under??""),s=[...ee(e.standing).values()].flatMap(t=>"regions"in t&&t.shape&&C(E(r,t.shape))!==void 0?[t.shape]:[]);return[$("cases/held",String(je(e.observed))),...e.second?[$("second/verdict",e.second.verdict)]:[],...[...new Set(s)].map(t=>$(`${Be(e.standing)}/${t}`,"present")),..."ceilings"in e?[...ze(e),...Ve(e),...ne(e)?[]:Qe(e)]:[],...qe(e)]}l(He,"factsOf");function ze(e){const r=e.standing.filter(n=>i(n,"value")!=="withdraw"),s=r.filter(n=>We(n)&&(!e.under||Te(r,`${_(e)}/`)(n))),t=Re({standing:e.standing,ceilings:s,observed:e.observed,own:e.own,epoch:e.epoch}).readings,a=l(n=>n.map(o=>(o.split(" ").at(-1)??"").split("..").map(Number)).filter(o=>o.every(Number.isFinite)),"spans");return s.flatMap(n=>(o=>o===void 0?[]:[x({scope:i(e.under?_e(n,_(e)):n,"scope"),role:"reads",measure:i(n,"measure"),by:"fold",at:"place:fold",...a(o).length===o.length?{form:"interval",value:`${Math.min(...a(o).map(w=>w[0]))}..${Math.max(...a(o).map(w=>w.at(-1)))}`}:{form:"alphabet",value:[...new Set(o)].join("|")}})])(t.get(i(n,"scope"))))}l(ze,"readingsOf");const ne=l(e=>e.standing.some(r=>[`publish/${_(e)}/bootstrap`,"publish/bootstrap"].includes(i(r,"scope"))&&i(r,"value")!=="withdraw"),"released"),De=l(e=>[...new Set(e.standing.filter(r=>i(r,"value")!=="withdraw").flatMap(r=>(s=>s.length===3&&s[1]==="uses"&&s[2]===_(e)?[s[0]]:[])(i(r,"scope").split("/"))))],"pinnersOf"),Ke=l(e=>[X,Ee].map(r=>B(C(E(e.root,e.under??"",r)))).find(r=>r.some(s=>i(s,"scope").startsWith("capsule/")))??[],"capsuleOf"),qe=l(e=>((r,s)=>!Fe(e.root,(e.under??"").replace(/\/$/,""))||e.under===void 0&&!ne(e)?[]:te(r,r,t=>t===""||!A(t).startsWith(".")&&s(P(V(e.store),E(r,t)))!=="foreign").map(t=>$(`coordinate/${t}`,Ge(e.standing,e.under??"",t)?"needed":"present")))(E(e.root,e.under??""),Z(e.store)),"coordinatesOf"),Ge=l((e,r,s)=>e.some(t=>i(t,"value")!=="withdraw"&&i(t,"measure")!=="reader"&&i(t,"needs").split("|").some(a=>!["","./",r].includes(a)&&(a===`${r}${s}`||a.endsWith("/")&&`${r}${s}`.startsWith(a)||W(a,`${r}${s}`)))),"neededBy");function Qe(e){const r=l(s=>(t=>(a=>new Set(a.filter(n=>H(t,n).includes(`${s}/`)||!H(t,n).length&&C(E(e.root,s,n.shape))!==void 0&&!a.some(o=>o.shape===n.shape&&H(t,o).includes(`${s}/`))).flatMap(n=>n.regions.map(o=>o.name))))([...ee(t).values()].flatMap(a=>"regions"in a&&a.shape?[a]:[])))([...Ue(e.root,s,!0),...e.standing]),"at");return e.under?[...new Set(Ke(e).filter(s=>i(s,"scope").startsWith("region/")&&i(s,"role")==="render").map(s=>i(s,"scope").slice(7)))].map(s=>(t=>$(`asked/${s}`,`${t}..${t}`,"interval","count"))(De(e).map(r).filter(t=>t.has(s)).length)):[]}l(Qe,"askedOf");function Ve(e){const r=l(n=>(o=>[n.slice(0,o<0?n.length:o).trim(),n.slice(o<0?n.length:o+3).trim()||n])(n.indexOf(" \xB7 ")),"named"),s=(e.under??"").replace(/\/$/,""),t=new Set(s?Ce(e.root).filter(n=>n!==s):[]),a=l(n=>{if(!s||n===s||n.startsWith(`${s}/`))return!0;const o=n.split("/")[0]??"";return!t.has(o)},"mine");return[["claims",e.claims],["forks",e.forks.length+(e.second.verdict==="forks"?1:0)],["refused",e.refused.length],["vacuous",e.vacuous],["history",e.history.length],["met",e.ceilings.read],["short",e.ceilings.short.length],["over",e.ceilings.over.length]].map(([n,o])=>$(`verdict/${n}`,`${o}..${o}`,"interval","count")).concat([$("verdict/computation","readings"),$("verdict/encounters","uncomputed")]).concat(e.ceilings.short.filter(n=>a(r(n)[0])).map(n=>(([o,w])=>$(`unpaid/${o}`,w))(r(n)))).concat(e.ceilings.over.filter(n=>a(r(n)[0])).map(n=>(([o,w])=>$(`outside/${o}`,w))(r(n)))).concat(e.ceilings.unread.filter(a).map(n=>$(`unpaid/${n}`,"unread"))).concat(e.missing.filter(n=>a(i(n,"scope"))).map(n=>$(`unpaid/${i(n,"scope")}`,"unpaid"))).concat([$("walk/read",`${e.own["walk-read"]??0}..${e.own["walk-read"]??0}`,"interval","count"),$("walk/ms",`${e.own["walk-ms"]??0}..${e.own["walk-ms"]??0}`,"interval","count")])}l(Ve,"verdictOf");function Xe(e,r,s,t){const a=e.under??"",n=l(c=>I([`region/${r}`],s).filter(g=>g.measure===c).flatMap(g=>(g.value??"").split("|").filter(Boolean)),"said"),o=n("receipts"),w=Le(e.observed).filter(c=>c.place.startsWith(a)&&o.some(g=>W(g,c.question))).map(c=>x({scope:c.question,role:"reads",form:"alphabet",measure:c.measure,value:c.value,by:c.by,evidence:c.at,at:`place:${c.place.slice(a.length).replace(/^\.\/$/,"")}`})),m=Z(e.store),j=te(E(e.root,a),e.root,c=>c===""||!A(c).startsWith(".")&&m(P(V(e.store),E(e.root,c)))!=="foreign"),d=Ae(e.standing,"region-coordinate",z()),p=n(d).flatMap(c=>j.filter(g=>W(c,g.slice(a.length))||W(c,g))).flatMap(c=>{if(A(c)==="TARGET.bound"||A(c)==="receipts.bound")return[];const g=B(C(E(e.root,c)));return g.length?[x({scope:"said/lines",role:"reads",form:"alphabet",measure:"lines",value:g.join(`
2
2
  `),by:"reader",at:`place:${c}`})]:[]});return{lines:n("lines").flatMap(c=>B(C(E(e.root,a,c)))),receipts:[...w,...p,...(o.length?t():[]).filter(c=>o.some(g=>W(g,i(c,"scope"))))]}}l(Xe,"regionOf");const ie=new WeakMap;function D(e){const r=ie.get(e);if(r!==void 0)return r;const s=$e(Oe(e),void 0,void 0,ke(e)).map(t=>t.capsule);return ie.set(e,s),s}l(D,"capsulesOf");const Ct=l(e=>[...new Set(D(e).flatMap(r=>r.declaration.renders))],"declaredBy"),ae=new WeakMap,oe=l(e=>ae.get(e)??ae.set(e,Ye(e)).get(e),"askingOf");function Ye(e){const r=B(C(E(e.root,e.under??"",X))).filter(m=>i(m,"scope").startsWith("region/")),s=I(["**"],e.under?Je(e):e.standing),t=se(s.map(m=>x(m)));let a;const n=l(()=>a??(a=He(e)),"facts"),o=new Map,w=l(m=>o.get(m)??o.set(m,Xe(e,m,t,n)).get(m),"region");return(m,j,d,v)=>{const p=xe(m,j.name);if(p===void 0)return;const c=p.filter(b=>!b.startsWith("region/")||I([b],t).length>0||W(b,"region/capsule")&&r.length>0),g=[...new Set([...Ie(c,t),...r.length&&c.some(b=>W(b,"region/capsule"))?["capsule"]:[]])];return{protocol:Me,verb:d,rootScope:e.under??"",files:[],region:j.name,at:j.at,shape:v,name:_(e)||A(e.root),lines:s.filter(b=>c.some(R=>W(R,b.scope??""))).map(b=>x(b)),reads:c,regions:Object.fromEntries(g.map(b=>[b,b==="capsule"&&r.length?{lines:r,receipts:[]}:w(b)]))}}}l(Ye,"handing");const ce=new WeakMap;function K(e){const r=e.under||"./",s=ce.get(e.observed)??ce.set(e.observed,new Map).get(e.observed);return s.get(r)??s.set(r,Ze(e,r)).get(r)}l(K,"capsuleReadings");function Ze(e,r){const s=Y(e.store,"read");return D(e).flatMap(t=>{const a=new Set(t.lines.filter(p=>i(p,"scope").startsWith("region/")&&i(p,"measure")==="writes").map(p=>i(p,"scope").slice(7))),n=Object.keys(t.declaration.writes).filter(p=>t.declaration.writes[p]==="receipt"&&!a.has(p)).sort(),o=q(e,t.selection??t.digest),w=oe({...e,observed:o.current}),m=n.flatMap(p=>(c=>c===void 0?[]:[c])(w(t.declaration,{name:p,at:3},"read","")));if(G(e.standing,i)&&m.length){const p=re(e.store),c=p(JSON.stringify([t.selection??t.digest,t.digest,n])),g=be(e.store,we("verb"),[],Q(),z(),!0),b=p([...g.values()].sort().join(`
3
3
  `)),R=o.legacy;return m.flatMap(S=>{const u=le({instrument:b,implementation:t.digest,policy:p(JSON.stringify([ye(),t.selection??null,t.lines])),inputs:[["world",t.selection??t.digest],["batch",c],["request",p(JSON.stringify(S))],...R,...[...g].map(([k,T])=>["host/"+P(Q(),k),T])]},p,{env:process.env,cwd:e.root,flags:ue()}),f=new TextDecoder().decode(me(u.context)),y=p(f),O=de(y,u,()=>t.ask([S]))[0];if(O?.kind!=="fact")throw Error(`REFUSE\xB7capsule ${t.digest} \xB7 ${S.region} \xB7 ${O?.why??"no answer"}`);const M=s+":"+c.slice(7),L="place:"+y,N=(O.claims??[]).map(k=>x({scope:k.scope,role:k.role,measure:k.measure,form:k.bound.kind==="interval"?"interval":"alphabet",value:k.bound.kind==="interval"?`${k.bound.lo??0}..${k.bound.hi??0}`:(k.bound.values??[]).join("|"),by:M,at:L})),J=N.join(`
4
4
  `)+(N.length?`
@@ -1,2 +1 @@
1
- var d=Object.defineProperty;var s=(t,o)=>d(t,"name",{value:o,configurable:!0});import{hostOutput as p}from"../host/call-context.js";import{boundedProcess as h}from"../host/process-lifetime.js";import{spawnSync as g}from"node:child_process";import{existsSync as l}from"node:fs";import{library11_PROTOCOL as O}from"../vendor/runtime.js";import{library2_responsesOf as m}from"../vendor/runtime.js";import{processOf as w,readerOf as x}from"./runner.js";const j=s(t=>t==="js"||t==="process","runs"),$=s(()=>w("host"),"hostOf");function C(t,o,a,i){if(!a.length)return[];const c=a.map(e=>({protocol:O,verb:"read",rootScope:e.place,files:e.text===void 0?[]:[{place:e.place,text:e.text}],...e.held?{held:e.held}:{},...e.region?{region:e.region}:{}})),n=x(t);if(!l(n.path))throw new Error(`REFUSE\xB7reader ${t} unavailable; its declared capability needs an admitted provider`);const f=[...n.flags,$(),n.path,t],r=i===void 0?g(process.execPath,f,{cwd:o,input:JSON.stringify(c),encoding:"utf8",maxBuffer:1<<28}):h(process.execPath,f,JSON.stringify(c),i,o);if("error"in r&&r.error)throw Object.assign(new Error(`${t}: reader process failed: ${r.error.message}`),{cause:r.error});if(r.status!==0)throw new Error(`${t}: reader exited ${r.status??`with signal ${r.signal}`}
2
- ${r.stderr??""}${r.stdout??""}`);return r.stderr&&p("error",r.stderr),m(r.stdout??"",a.length).map(e=>{if(e.kind!=="fact")throw new Error(`REFUSE\xB7reader ${t} \xB7 ${e.why??"no reading answered"}`);return e.claims??[]})}s(C,"runReader");export{$ as hostOf,C as runReader,j as runs};
1
+ var p=Object.defineProperty;var o=(r,t)=>p(r,"name",{value:t,configurable:!0});import{executeCapsule as l}from"../host/capsule-process.js";import{BoundRefusal as n}from"../host/refusals.js";import{existsSync as h}from"node:fs";import{library14_PROTOCOL as m}from"../vendor/runtime.js";import{processOf as x,readerOf as g}from"./runner.js";const b=o(r=>r==="js"||r==="process","runs"),O=o(()=>x("host"),"hostOf");function v(r,t,s,d){if(!s.length)return[];const f=s.map(e=>({protocol:m,verb:"read",rootScope:e.place,files:e.text===void 0?[]:[{place:e.place,text:e.text}],...e.held?{held:e.held}:{},...e.region?{region:e.region}:{}})),a=g(r);if(!h(a.path))throw new Error(`REFUSE\xB7reader ${r} unavailable; its declared capability needs an admitted provider`);const i=[...a.flags,O(),a.path,r];let c;try{c=l(process.execPath,i,f,{cwd:t,maxBuffer:1<<28},d)}catch(e){throw new n("reader/response",`REFUSE\xB7reader ${r} \xB7 ${e instanceof Error?e.message:String(e)}`)}return c.map(e=>{if(e.kind!=="fact")throw new n("reader/response",`REFUSE\xB7reader ${r} \xB7 ${e.why??"no reading answered"}`);return e.claims})}o(v,"runReader");export{O as hostOf,v as runReader,b as runs};