@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
package/dist/cli/place.js CHANGED
@@ -1,6 +1,6 @@
1
- var Ae=Object.defineProperty;var m=(e,o)=>Ae(e,"name",{value:o,configurable:!0});import{hostOutput as me}from"../host/call-context.js";import{refreshRetainedJudgment as Ie}from"./retained-judgment.js";import{timing as Je}from"../host/timing.js";import{attestationObservations as ge}from"../fold/evidence.js";import{library11_parse as ue}from"../vendor/runtime.js";import{releasePolicy as he,releaseFaults as Ve}from"../fold/release-policy.js";import{library12_point as Ge,library12_region as Qe,library12_within as Ue}from"../vendor/runtime.js";import{basename as we,join as ye}from"node:path";import{observeText as I}from"../observe/files.js";import{placesOf as J,viewsOf as Xe}from"../fold/views.js";import{prerender as Ye,viewOf as Ze}from"../render/view.js";import{meets as V,instrumentKept as es}from"../fold/closed.js";import{foldPoints as ss,keepFold as ts,keptPlace as ke}from"../fold/kept.js";import{openCells as ns}from"../render/open.js";import{boundOf as is,packRegions as os,regionsNamed as rs,regionsOf as as,unlikeReplay as cs}from"../fold/region.js";import{answersElsewhere as fs,foldCeilings as ds,ceilingSummary as ve}from"../fold/ceilings.js";import{keyOf as ls,keyFor as ps,lockLines as ms,lockStanding as be}from"../fold/keys.js";import{wordFrom as Oe,wordOf as $e,wordOn as gs}from"../fold/wire.js";import{bytesDigest as us,instrumentOf as G,signaturesOf as hs}from"../fold/digests.js";import{claimKey as Se,fieldOf as d,fieldsOf as ws,isWire as Me}from"../fold/claims.js";import{library11_canonical as Q,library11_LOCK as ys,library11_parse as Re}from"../vendor/runtime.js";import{classDefaults as ks,kindsOf as vs,placesIn as U,spoken as bs}from"../fold/places.js";import{isCeiling as T}from"../fold/configures.js";import{observedClaims as X,placedReadings as Y}from"../fold/observed.js";import{capsuleReadingsOver as xe,currentReceiptObservations as Ce,retiredReceiptHistory as Os}from"../observe/regions.js";import{costReadings as $s,ownReadings as Fe,currentActReadings as Ss}from"../fold/own.js";import{paidOf as Ms}from"../fold/paid.js";import{rolesOf as We}from"../fold/roles.js";import{secondHead as Rs}from"../fold/second.js";import{authorityFor as xs,rootSigner as Cs,writerFor as Ne}from"../fold/signers.js";import{ledgerLines as q,storeOf as Z}from"../land/ledger.js";import{vouchedCoordinates as Fs}from"../land/vouched.js";import{ownLock as E,ownRoot as _e}from"../observe/runner.js";import{epochOf as ee,historyOf as Ws,renderedLock as Ns,standingDemands as _s}from"./owner.js";function Ds(e,o,s){const a=Ne(o,"fold"),r=m(n=>{const l=(a===void 0?[]:q(e,a)).filter(c=>d(c,"scope")===`beat/${s??"."}`&&d(c,"at")===`place:${n}`).map(c=>Number(d(c,"value").split("..")[0])).filter(c=>Number.isFinite(c)).slice(-10).sort((c,u)=>c-u);return l.length?l[Math.floor(l.length/2)]??0:0},"middle");return{kept:r("kept"),folded:r("folded")}}m(Ds,"beatsOf");const Es=m(e=>q(e,"take").filter(o=>d(o,"measure")==="ms").map(o=>Number(d(o,"value").split("..")[0])).filter(o=>Number.isFinite(o)).slice(-10),"costsOf");function Ls(e){return"none"}m(Ls,"effectStates");const De=new WeakMap,Ee=new WeakMap;function Ps(e,o,s,a){const r=Ee.get(a);if(r!==void 0)return r;const n=ls(o,"attest"),l=n===void 0?void 0:xs([...a,...q(o,n)],Cs(e),hs(o).admitted);return Ee.set(a,Rs(o,s,c=>l?.of(c).kind==="admitted",a)).get(a)}m(Ps,"secondOf");function js(e,o,s){const a=new Map,r=(()=>{try{return ps(e,"read")}catch{return}})();for(const n of o)a.set(d(n,"by"),(a.get(d(n,"by"))??0)+1);for(const n of o){const l=/^keys\/([^/]+)$/.exec(d(n,"scope"))?.[1],c=l===void 0||a.has(l)?void 0:l===r?s:q(e,l);l!==void 0&&c!==void 0&&a.set(l,De.get(c)??De.set(c,new Set(c.filter(u=>d(u,"sig")!=="")).size).get(c))}return a}m(js,"signedByKey");function Ks(e){const o=gs(e.standing,"region-leaf",E()),s=m(t=>ye(e.root,e.under??"",t),"at"),a=[...Xe(e.standing).values()].flatMap(t=>"regions"in t&&t.shape?[t]:[]).filter(t=>I(s(t.shape))!==void 0),r=m(t=>J(e.standing,t).includes(e.under??""),"named"),n=a.filter(t=>r(t)||!J(e.standing,t).length&&!a.some(h=>h.shape===t.shape&&r(h)));Ye(e,n);const l=new Set(n.filter(t=>I(s(t.shape))===Ze(e,t)).map(t=>t.name)),c=n.length-l.size,u=[...a.filter(t=>r(t)||!J(e.standing,t).length).reduce((t,h)=>t.set(h.shape,(t.get(h.shape)??0)+1),new Map).values()].filter(t=>t>1).length;return{readings:{[`rendered-${o}-differ`]:c,"rendered-coordinates-differ":c,[`${o}-with-two-views`]:u,"coordinates-with-two-views":u},same:l,here:new Set(n.map(t=>t.name))}}m(Ks,"viewReadings");const Bs=[],Le=new WeakMap,Hs=m((e,o)=>(s=>(a=>a.get(o)??a.set(o,[...s,...o]).get(o))(Le.get(s)??Le.set(s,new WeakMap).get(s)))(ms(e)),"ownedOf");function se(e,o,s=Bs){const a=Z(e),r=Hs(a,s),n=Ns(e,a,s),l=n.text.split(`
2
- `).filter(Me),c=bs(e);if(!c.length)return{standing:l,lock:l,rendered:n,owned:r};const u=`${$e(l,"families","view")}/`,t=m(f=>d(f,"scope").startsWith(u),"isView"),h=new Set(c.filter(f=>!t(f.line)).map(f=>Se(f.line))),p=new Map;for(const f of c.filter(O=>t(O.line)))p.set(d(f.line,"scope"),(p.get(d(f.line,"scope"))??new Set).add(`${f.place}/`));const w=l.flatMap(f=>{const O=t(f)?p.get(d(f,"scope")):void 0;if(O===void 0)return h.has(Se(f))?[]:[f];const S=d(f,"needs").split("|").filter(Boolean),x=S.filter(y=>![...O].some(F=>y.startsWith(F)));if(!S.length||x.length===S.length)return[f];const C=Re(f);return x.length&&C.kind==="fact"?[Q({...C.value.fields,needs:x.join("|")})]:[]}),v=o?.replace(/\/$/,""),R=c.filter(f=>f.place===v).map(f=>f.line),b=c.filter(f=>f.place!==v).map(f=>f.line),g=[...new Set([...R,...w,...b])];return{standing:[...g,...Ts(e,g)],lock:l,rendered:n,owned:r}}m(se,"standingOf");function Ts(e,o){const s=ks(e);if(!s.length)return[];const a=o.filter(T),r=[];for(const n of U(e)){const l=vs(e,n),c=`${n}/`,u=new Set(a.filter(t=>d(t,"scope").startsWith(c)).map(t=>d(t,"measure")));for(const t of s){if(!t.classes.includes("*")&&!t.classes.some(w=>l.includes(w)))continue;const h=d(t.line,"measure");if(u.has(h))continue;const p=Re(t.line);p.kind==="fact"&&(r.push(Q({...p.value.fields,scope:`${c}${d(t.line,"scope")}`})),u.add(h))}}return r}m(Ts,"inheritedOf");function Mt(e,o,s,a){const r=Z(e),{standing:n,rendered:l}=se(e);if(V(e,r,"")&&es(r)===G(r,o,n,e,E())){const g=ke(r);if(g!==void 0)return{standing:n,observed:g.observed,own:{...g.own,...Ss()},kept:!0}}const c=rs(n),u=a!==void 0&&a.length?[...a]:[...new Set(s.map(g=>is(c,g).region))],t=X(e,r,{wait:!1,...u.includes("")?{}:{reach:u}}),p=[...Ce({root:e,store:r,standing:n,observed:t}),...xe({root:e,store:r,standing:n,observed:t})],w={...Fe({root:e,store:r,entry:o,roleOf:We(r),standing:n,observed:p,unadmitted:l.grey.length+l.refused.length,orphans:0}),...$s(r,n)},v=new Set([...Object.keys(w),...Y(p).map(g=>g.measure),$e(n,"states","unread")]);if(s.every(g=>v.has(d(g,"measure"))||d(g,"scope")in w))return{standing:n,observed:p,own:w,kept:!0};const b=qs(e,o);return{...b,kept:b.kept??!1}}m(Mt,"coneOf");const Pe=m(e=>(o=>e===void 0||e===`${o}/`?E().filter(T).map(s=>Q({...ws(s),scope:`${o}/${d(s,"scope")}`})):[])(we(_e())),"ownCeilings");function qs(e,o,s,a=!0,r){const n=Z(e),l=Date.now(),c=V(e,n,s??""),u=Date.now()-l;if(c&&r?.free!==!0){const i=ke(n,s,G(n,o,se(e).standing,e,E()));if(i!==void 0)return me("error",`CLOSED ${s||"."} \xB7 digest ${u} ms
3
- `),Ie(i,[...i.standing.filter(k=>T(k)&&!(s&&d(k,"measure")==="unread")),...Pe(s)])}const{standing:t,lock:h,rendered:p,owned:w}=r?.standing??se(e,s),v=Ne(t,"fold"),R=r===void 0&&s?new Map:void 0,b=r?.observed??X(e,n,{wait:a,...s?{reach:[s],answered:R}:{}}),g=G(n,o,t,e,E()),f=m(i=>!s||Ue(Ge(i.replace(/\/\*$/,"")),Qe(s)),"inside"),O=Ws(e,n,_s(n)),S=O.live.filter(i=>(k=>!s||k.length>0&&k.every(f))(d(i,"needs").split("|").filter(Boolean))),x=s&&s!==`${we(_e())}/`?{owned:w,place:s,scopes:new Set(S.map(i=>d(i,"scope")))}:void 0,C=[],y=Je(C),F=r?.observed??(s?y("observe",()=>X(e,n,{wait:a})):b),L=[...Ce({root:e,store:n,...s?{under:s}:{},standing:t,observed:F}),...y("capsules",()=>xe({root:e,store:n,...s?{under:s}:{},standing:t,observed:F}))],te=ss(n,t,s,v,g,b,e,R,x),P=us(n,new TextEncoder().encode(te.join(`
4
- `))).replace(/^sha256:/,""),W=L.filter(i=>!/ measure=observed /.test(i)||f(d(i,"scope"))),ne=new Set(s?Y(L).filter(i=>!f(i.place)).map(i=>i.question):[]),je=O,j=S,z=[],M=[...t.filter(i=>T(i)&&!(s&&d(i,"measure")==="unread")),...Pe(s)],K=y("own",()=>Fe({root:e,store:n,entry:o,roleOf:We(n),standing:t,observed:L,unadmitted:p.grey.length+p.refused.length,orphans:z.length,...s?{under:s}:{}})),ie=y("regions",()=>as(t,M.filter(i=>!fs(i,K,s,new Set(U(e)))),Y(W))),oe=m(i=>ds({standing:t,ceilings:M,observed:W,own:{...K,...i},epoch:ee(w),...s?{under:s,places:new Set(U(e))}:{}}),"fold"),N=y("ceilings",()=>oe({})),{paid:re,missing:Ke}=y("paid",()=>Ms(n,j,W,`${Oe(t,"families","view",be(n))}/`)),Be=(I(ye(e,s??"",ys))??"").split(`
5
- `).filter(Me).length,B=Ps(e,n,h,w),H=t.filter(i=>!p.grey.includes(i)&&!p.refused.includes(i)),ae=Ve({forks:p.forks,refused:p.refused,grey:p.grey,orphans:z,second:B}),$={release:he({standing:H,demands:j,paid:re,ceilings:M,readings:N,faults:ae,verdicts:ge(H.map(i=>{const k=ue(i);return k.kind==="fact"?k.value.fields:{}}),B),snapshot:{fold:P,instrument:g}}),root:e,store:n,...s?{under:s}:{},epoch:ee(w),standing:t,claims:p.standing,forks:p.forks,grey:p.grey,refused:p.refused,vacuous:p.vacuous.length,demands:j,paid:re,missing:Ke,history:je.history.filter(i=>d(i,"needs").split("|").filter(Boolean).some(f)),observed:W,receiptHistory:Os({root:e,store:n,...s?{under:s}:{},standing:t,observed:F}),ceilings:ve(N,M.length,ne),orphans:z,lock:Be,signed:js(n,t,L),second:B,effects:Ls(n),key:P,instrument:g,own:K,open:ns({store:n,standing:t,observed:W,grey:p.grey,epoch:ee(w)}),regions:os(ie),beats:Ds(n,t,s),landed:[...Fs(n).keys()].filter(i=>!s||i.startsWith(s)).length,costs:Es(n)},{readings:He,same:Te,here:qe}=y("docs",()=>Ks($)),ce=`${Oe(t,"families","view",be(n))}/`,ze=new Set([...qe].map(i=>`${ce}${i}`)),_=m(i=>ze.has(d(i,"scope")),"writes"),D=m(i=>Te.has(d(i,"scope").slice(ce.length)),"holds"),fe=[...$.missing.filter(i=>!_(i)||!D(i)),...$.paid.filter(i=>_(i)&&!D(i))],de={...He,"payments-lost-on-equal-output":fe.filter(i=>_(i)&&D(i)).length,"poles-unlike-replay":cs(ie,new Set(N.over.map(i=>i.ceiling)),{...K,unread:N.unread.length+N.vacuous.length})},le=y("ceilings",()=>oe(de)),pe=[...$.paid.filter(i=>!_(i)||D(i)),...$.missing.filter(i=>_(i)&&D(i))],A={...$,paid:pe,release:he({standing:H,demands:j,paid:pe,ceilings:M,readings:le,faults:ae,verdicts:ge(H.map(i=>{const k=ue(i);return k.kind==="fact"?k.value.fields:{}}),B),snapshot:{fold:P,instrument:g}}),missing:fe,own:{...$.own,...de},ceilings:ve(le,M.length,ne)};return v!==void 0&&V(e,n,s??"",!0,A.observed)&&y("keep",()=>ts(n,P,A,te,g)),me("error",`SPENT fold ${C.join(" ms \xB7 ")} ms
6
- `),A}m(qs,"foldPlace");export{Mt as coneOf,qs as foldPlace,Pe as ownCeilings,se as standingOf};
1
+ var Ae=Object.defineProperty;var m=(e,o)=>Ae(e,"name",{value:o,configurable:!0});import{traceWork as Je}from"../host/work-trace.js";import{hostOutput as me}from"../host/call-context.js";import{refreshRetainedJudgment as Ie}from"./retained-judgment.js";import{timing as Ve}from"../host/timing.js";import{attestationObservations as ue}from"../fold/evidence.js";import{library14_parse as ge}from"../vendor/runtime.js";import{releasePolicy as he,releaseFaults as Ge}from"../fold/release-policy.js";import{library0_point as Qe,library0_region as Ue,library0_within as Xe}from"../vendor/runtime.js";import{basename as we,join as ye}from"node:path";import{observeText as J}from"../observe/files.js";import{placesOf as I,viewsOf as Ye}from"../fold/views.js";import{prerender as Ze}from"../render/view.js";import{meets as V,instrumentKept as et}from"../fold/closed.js";import{foldPoints as tt,keepFold as st,keptPlace as ke}from"../fold/kept.js";import{openCells as nt}from"../render/open.js";import{boundOf as it,packRegions as ot,regionsNamed as rt,regionsOf as at,unlikeReplay as ct}from"../fold/region.js";import{answersElsewhere as ft,foldCeilings as dt,ceilingSummary as be}from"../fold/ceilings.js";import{keyOf as lt,keyFor as pt,lockLines as mt,lockStanding as ve}from"../fold/keys.js";import{wordFrom as Oe,wordOf as $e,wordOn as ut}from"../fold/wire.js";import{bytesDigest as gt,instrumentOf as G,signaturesOf as ht}from"../fold/digests.js";import{claimKey as Se,fieldOf as l,fieldsOf as wt,isWire as Me}from"../fold/claims.js";import{library14_canonical as Q,library14_LOCK as yt,library14_parse as Re}from"../vendor/runtime.js";import{classDefaults as kt,kindsOf as bt,placesIn as U,spoken as vt}from"../fold/places.js";import{isCeiling as H}from"../fold/configures.js";import{observedClaims as X,placedReadings as Y}from"../fold/observed.js";import{capsuleReadingsOver as xe,currentReceiptObservations as Ce,retiredReceiptHistory as Ot}from"../observe/regions.js";import{costReadings as $t,ownReadings as We,currentActReadings as St}from"../fold/own.js";import{paidOf as Mt}from"../fold/paid.js";import{rolesOf as Fe}from"../fold/roles.js";import{secondHead as Rt}from"../fold/second.js";import{authorityFor as xt,rootSigner as Ct,writerFor as Ne}from"../fold/signers.js";import{ledgerLines as T,storeOf as Z}from"../land/ledger.js";import{vouchedCoordinates as Wt}from"../land/vouched.js";import{ownLock as P,ownRoot as _e}from"../observe/runner.js";import{epochOf as ee,historyOf as Ft,renderedLock as Nt,standingDemands as _t}from"./owner.js";function Pt(e,o,t){const c=Ne(o,"fold"),r=m(f=>{const i=(c===void 0?[]:T(e,c)).filter(s=>l(s,"scope")===`beat/${t??"."}`&&l(s,"at")===`place:${f}`).map(s=>Number(l(s,"value").split("..")[0])).filter(s=>Number.isFinite(s)).slice(-10).sort((s,h)=>s-h);return i.length?i[Math.floor(i.length/2)]??0:0},"middle");return{kept:r("kept"),folded:r("folded")}}m(Pt,"beatsOf");const Dt=m(e=>T(e,"take").filter(o=>l(o,"measure")==="ms").map(o=>Number(l(o,"value").split("..")[0])).filter(o=>Number.isFinite(o)).slice(-10),"costsOf");function Et(e){return"none"}m(Et,"effectStates");const Pe=new WeakMap,De=new WeakMap;function Lt(e,o,t,c){const r=De.get(c);if(r!==void 0)return r;const f=lt(o,"attest"),i=f===void 0?void 0:xt([...c,...T(o,f)],Ct(e),ht(o).admitted);return De.set(c,Rt(o,t,s=>i?.of(s).kind==="admitted",c)).get(c)}m(Lt,"secondOf");function jt(e,o,t){const c=new Map,r=(()=>{try{return pt(e,"read")}catch{return}})();for(const f of o)c.set(l(f,"by"),(c.get(l(f,"by"))??0)+1);for(const f of o){const i=/^keys\/([^/]+)$/.exec(l(f,"scope"))?.[1],s=i===void 0||c.has(i)?void 0:i===r?t:T(e,i);i!==void 0&&s!==void 0&&c.set(i,Pe.get(s)??Pe.set(s,new Set(s.filter(h=>l(h,"sig")!=="")).size).get(s))}return c}m(jt,"signedByKey");function Kt(e){const o=ut(e.standing,"region-leaf",P()),t=m(a=>ye(e.root,e.under??"",a),"at"),c=[...Ye(e.standing).values()].flatMap(a=>"regions"in a&&a.shape?[a]:[]).filter(a=>J(t(a.shape))!==void 0),r=m(a=>I(e.standing,a).includes(e.under??""),"named"),f=c.filter(a=>r(a)||!I(e.standing,a).length&&!c.some(d=>d.shape===a.shape&&r(d))),i=Ze(e,f),s=new Set(f.filter(a=>J(t(a.shape))===i.get(a)).map(a=>a.name)),h=f.length-s.size,u=[...c.filter(a=>r(a)||!I(e.standing,a).length).reduce((a,d)=>a.set(d.shape,(a.get(d.shape)??0)+1),new Map).values()].filter(a=>a>1).length;return{readings:{[`rendered-${o}-differ`]:h,"rendered-coordinates-differ":h,[`${o}-with-two-views`]:u,"coordinates-with-two-views":u},same:s,here:new Set(f.map(a=>a.name))}}m(Kt,"viewReadings");const Bt=[],Ee=new WeakMap,Ht=m((e,o)=>(t=>(c=>c.get(o)??c.set(o,[...t,...o]).get(o))(Ee.get(t)??Ee.set(t,new WeakMap).get(t)))(mt(e)),"ownedOf");function te(e,o,t=Bt){const c=Z(e),r=Ht(c,t),f=Nt(e,c,t),i=f.text.split(`
2
+ `).filter(Me),s=vt(e);if(!s.length)return{standing:i,lock:i,rendered:f,owned:r};const h=`${$e(i,"families","view")}/`,u=m(p=>l(p,"scope").startsWith(h),"isView"),a=new Set(s.filter(p=>!u(p.line)).map(p=>Se(p.line))),d=new Map;for(const p of s.filter(y=>u(y.line)))d.set(l(p.line,"scope"),(d.get(l(p.line,"scope"))??new Set).add(`${p.place}/`));const k=i.flatMap(p=>{const y=u(p)?d.get(l(p,"scope")):void 0;if(y===void 0)return a.has(Se(p))?[]:[p];const v=l(p,"needs").split("|").filter(Boolean),M=v.filter(q=>![...y].some(C=>q.startsWith(C)));if(!v.length||M.length===v.length)return[p];const x=Re(p);return M.length&&x.kind==="fact"?[Q({...x.value.fields,needs:M.join("|")})]:[]}),g=o?.replace(/\/$/,""),b=s.filter(p=>p.place===g).map(p=>p.line),$=s.filter(p=>p.place!==g).map(p=>p.line),w=[...new Set([...b,...k,...$])];return{standing:[...w,...Tt(e,w)],lock:i,rendered:f,owned:r}}m(te,"standingOf");function Tt(e,o){const t=kt(e);if(!t.length)return[];const c=o.filter(H),r=[];for(const f of U(e)){const i=bt(e,f),s=`${f}/`,h=new Set(c.filter(u=>l(u,"scope").startsWith(s)).map(u=>l(u,"measure")));for(const u of t){if(!u.classes.includes("*")&&!u.classes.some(k=>i.includes(k)))continue;const a=l(u.line,"measure");if(h.has(a))continue;const d=Re(u.line);d.kind==="fact"&&(r.push(Q({...d.value.fields,scope:`${s}${l(u.line,"scope")}`})),h.add(a))}}return r}m(Tt,"inheritedOf");function Cs(e,o,t,c){const r=Z(e),{standing:f,rendered:i}=te(e);if(V(e,r,"")&&et(r)===G(r,o,f,e,P())){const w=ke(r);if(w!==void 0)return{standing:f,observed:w.observed,own:{...w.own,...St()},kept:!0}}const s=rt(f),h=c!==void 0&&c.length?[...c]:[...new Set(t.map(w=>it(s,w).region))],u=X(e,r,{wait:!1,...h.includes("")?{}:{reach:h}}),d=[...Ce({root:e,store:r,standing:f,observed:u}),...xe({root:e,store:r,standing:f,observed:u})],k={...We({root:e,store:r,entry:o,roleOf:Fe(r),standing:f,observed:d,unadmitted:i.grey.length+i.refused.length,orphans:0}),...$t(r,f)},g=new Set([...Object.keys(k),...Y(d).map(w=>w.measure),$e(f,"states","unread")]);if(t.every(w=>g.has(l(w,"measure"))||l(w,"scope")in k))return{standing:f,observed:d,own:k,kept:!0};const $=zt(e,o);return{...$,kept:$.kept??!1}}m(Cs,"coneOf");const Le=m(e=>(o=>e===void 0||e===`${o}/`?P().filter(H).map(t=>Q({...wt(t),scope:`${o}/${l(t,"scope")}`})):[])(we(_e())),"ownCeilings");function qt(e){return Ie(e,[...e.standing.filter(o=>H(o)&&!(e.under&&l(o,"measure")==="unread")),...Le(e.under)])}m(qt,"currentJudgment");function zt(e,o,t,c=!0,r){return Je("fold/place",()=>At(e,o,t,c,r))}m(zt,"foldPlace");function At(e,o,t,c=!0,r){const f=[],i=Ve(f),s=Z(e),h=Date.now(),u=i("closure",()=>V(e,s,t??"")),a=Date.now()-h;if(u&&r?.free!==!0){const n=ke(s,t,G(s,o,te(e).standing,e,P()));if(n!==void 0)return me("error",`CLOSED ${t||"."} \xB7 digest ${a} ms
3
+ `),qt(n)}const{standing:d,lock:k,rendered:g,owned:b}=r?.standing??i("standing",()=>te(e,t)),$=Ne(d,"fold"),w=r===void 0&&t?new Map:void 0,p=r?.observed??i("observed",()=>X(e,s,{wait:c,...t?{reach:[t],answered:w}:{}})),y=i("instrument",()=>G(s,o,d,e,P())),v=m(n=>!t||Xe(Qe(n.replace(/\/\*$/,"")),Ue(t)),"inside"),M=i("history",()=>Ft(e,s,_t(s))),x=M.live.filter(n=>(O=>!t||O.length>0&&O.every(v))(l(n,"needs").split("|").filter(Boolean))),q=t&&t!==`${we(_e())}/`?{owned:b,place:t,scopes:new Set(x.map(n=>l(n,"scope")))}:void 0,C=r?.observed??(t?i("observe",()=>X(e,s,{wait:c})):p),D=[...i("current-receipts",()=>Ce({root:e,store:s,...t?{under:t}:{},standing:d,observed:C})),...i("capsules",()=>xe({root:e,store:s,...t?{under:t}:{},standing:d,observed:C}))],se=i("points",()=>tt(s,d,t,$,y,p,e,w,q)),E=i("point-digest",()=>gt(s,new TextEncoder().encode(se.join(`
4
+ `))).replace(/^sha256:/,"")),W=D.filter(n=>!/ measure=observed /.test(n)||v(l(n,"scope"))),ne=new Set(t?Y(D).filter(n=>!v(n.place)).map(n=>n.question):[]),je=M,L=x,z=[],R=[...d.filter(n=>H(n)&&!(t&&l(n,"measure")==="unread")),...Le(t)],j=i("own",()=>We({root:e,store:s,entry:o,roleOf:Fe(s),standing:d,observed:D,unadmitted:g.grey.length+g.refused.length,orphans:z.length,...t?{under:t}:{}})),ie=i("regions",()=>at(d,R.filter(n=>!ft(n,j,t,new Set(U(e)))),Y(W))),oe=m(n=>dt({standing:d,ceilings:R,observed:W,own:{...j,...n},epoch:ee(b),...t?{under:t,places:new Set(U(e))}:{}}),"fold"),F=i("ceilings",()=>oe({})),{paid:re,missing:Ke}=i("paid",()=>Mt(s,L,W,`${Oe(d,"families","view",ve(s))}/`)),Be=(J(ye(e,t??"",yt))??"").split(`
5
+ `).filter(Me).length,K=i("second",()=>Lt(e,s,k,b)),B=d.filter(n=>!g.grey.includes(n)&&!g.refused.includes(n)),ae=Ge({forks:g.forks,refused:g.refused,grey:g.grey,orphans:z,second:K}),S={release:he({standing:B,demands:L,paid:re,ceilings:R,readings:F,faults:ae,verdicts:ue(B.map(n=>{const O=ge(n);return O.kind==="fact"?O.value.fields:{}}),K),snapshot:{fold:E,instrument:y}}),root:e,store:s,...t?{under:t}:{},epoch:ee(b),standing:d,claims:g.standing,forks:g.forks,grey:g.grey,refused:g.refused,vacuous:g.vacuous.length,demands:L,paid:re,missing:Ke,history:je.history.filter(n=>l(n,"needs").split("|").filter(Boolean).some(v)),observed:W,receiptHistory:i("receipt-history",()=>Ot({root:e,store:s,...t?{under:t}:{},standing:d,observed:C})),ceilings:be(F,R.length,ne),orphans:z,lock:Be,signed:i("signatures",()=>jt(s,d,D)),second:K,effects:Et(s),key:E,instrument:y,own:j,open:nt({store:s,standing:d,observed:W,grey:g.grey,epoch:ee(b)}),regions:ot(ie),beats:i("beats",()=>Pt(s,d,t)),landed:[...Wt(s).keys()].filter(n=>!t||n.startsWith(t)).length,costs:i("cost-history",()=>Dt(s))},{readings:He,same:Te,here:qe}=i("docs",()=>Kt(S)),ce=`${Oe(d,"families","view",ve(s))}/`,ze=new Set([...qe].map(n=>`${ce}${n}`)),N=m(n=>ze.has(l(n,"scope")),"writes"),_=m(n=>Te.has(l(n,"scope").slice(ce.length)),"holds"),fe=[...S.missing.filter(n=>!N(n)||!_(n)),...S.paid.filter(n=>N(n)&&!_(n))],de={...He,"payments-lost-on-equal-output":fe.filter(n=>N(n)&&_(n)).length,"poles-unlike-replay":ct(ie,new Set(F.over.map(n=>n.ceiling)),{...j,unread:F.unread.length+F.vacuous.length})},le=i("ceilings",()=>oe(de)),pe=[...S.paid.filter(n=>!N(n)||_(n)),...S.missing.filter(n=>N(n)&&_(n))],A={...S,paid:pe,release:he({standing:B,demands:L,paid:pe,ceilings:R,readings:le,faults:ae,verdicts:ue(B.map(n=>{const O=ge(n);return O.kind==="fact"?O.value.fields:{}}),K),snapshot:{fold:E,instrument:y}}),missing:fe,own:{...S.own,...de},ceilings:be(le,R.length,ne)};return $!==void 0&&V(e,s,t??"",!0,A.observed)&&i("keep",()=>st(s,E,A,se,y)),me("error",`SPENT fold ${f.join(" ms \xB7 ")} ms
6
+ `),A}m(At,"foldPlaceCurrent");export{Cs as coneOf,qt as currentJudgment,zt as foldPlace,Le as ownCeilings,te as standingOf};
@@ -1,3 +1,3 @@
1
- var S=Object.defineProperty;var f=(n,o)=>S(n,"name",{value:o,configurable:!0});import{library11_parse as y}from"../vendor/runtime.js";import{authorityFor as b,writerFor as $,releaseSigner as x}from"../fold/signers.js";import{eraOf as k}from"../fold/digests.js";import{fieldOf as r,foldClaims as R}from"../fold/claims.js";import{observeText as L}from"../observe/files.js";import{claimLinesIn as A}from"./args.js";import{library11_LOCK as z}from"../vendor/runtime.js";import{join as O}from"node:path";function C(n,o){const a=R(n).standing,s=$(a,"authorize");if(!s)throw Error("REFUSE\xB7release place names no authorizer");const l=f((e,t,c)=>{const i=e.filter(h=>r(h,"scope")===t&&(!c||r(h,"measure")===c)&&r(h,"value")!=="withdraw");if(i.length!==1)throw Error(`REFUSE\xB7release ${t} needs one declaration`);return r(i[0],"value")},"one"),U={...x(a),id:s,publicKey:l(a,`keys/${s}`,"public-key"),coverage:l(a,`keys/${s}`,"coverage").split("|")};if(!o.length)throw Error("REFUSE\xB7release empty approval");for(const e of o){const t=y(e);if(t.kind!=="fact")throw Error("REFUSE\xB7release malformed approval");if(t.value.fields.by!==s||!t.value.fields.sig)throw Error(`REFUSE\xB7release approval must be signed by ${s}`)}const u=o.filter(e=>["wire/signature-algorithms","audit/wire/signature-algorithms","wire/era","audit/wire/era"].includes(r(e,"scope")));let m;try{m=k(u.length?R(u).standing:a)}catch{throw Error("REFUSE\xB7release signature era is absent or conflicting")}const F=b([],U,m.admitted);for(const e of o){const t=F.of(e);if(t.kind!=="admitted")throw Error(`REFUSE\xB7release ${r(e,"scope")}: ${t.why??t.kind}`)}const w=o.filter(e=>/^release\/[^/]+$/.test(r(e,"scope"))&&r(e,"measure")==="digest"&&r(e,"role")==="writes");if(w.length!==1)throw Error("REFUSE\xB7release needs one signed release/<tag> digest");const d=f((e,t)=>{const c=o.filter(i=>r(i,"scope")===e);if(c.some(i=>r(i,"role")!=="writes"||r(i,"form")!=="alphabet"||r(i,"measure")!==t))throw Error(`REFUSE\xB7release ${e} is not an approval declaration`);return l(c,e,t)},"required"),g=d(r(w[0],"scope"),"digest"),v=d("release/artifact","id"),E=d("sources/archive","id");if(!/^sha256:[a-f0-9]{64}$/.test(g))throw Error("REFUSE\xB7release archive needs sha256");if(!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(v))throw Error("REFUSE\xB7release artifact needs one safe filename");let p;try{p=new URL(E)}catch{throw Error("REFUSE\xB7release archive source needs an absolute URL")}if(p.username||p.password||/[\s\x00-\x1f\x7f]/.test(E))throw Error("REFUSE\xB7release archive source needs a credential-free absolute URL without whitespace");return`READY ${g} ${v} ${E}`}f(C,"releaseApproval");function B(n,o){const a=L(o);if(a===void 0)throw Error("REFUSE\xB7release approval file is absent");const s=a.split(`
2
- `).filter(l=>l.trim().length>0);process.stdout.write(C(A(O(n,z)),s)+`
3
- `)}f(B,"printReleaseApproval");export{B as printReleaseApproval,C as releaseApproval};
1
+ var S=Object.defineProperty;var f=(n,o)=>S(n,"name",{value:o,configurable:!0});import{hostOutput as y}from"../host/call-context.js";import{library14_parse as b}from"../vendor/runtime.js";import{authorityFor as $,writerFor as x,releaseSigner as k}from"../fold/signers.js";import{eraOf as L}from"../fold/digests.js";import{fieldOf as r,foldClaims as R}from"../fold/claims.js";import{observeText as A}from"../observe/files.js";import{claimLinesIn as O}from"./args.js";import{library14_LOCK as z}from"../vendor/runtime.js";import{join as C}from"node:path";function K(n,o){const a=R(n).standing,s=x(a,"authorize");if(!s)throw Error("REFUSE\xB7release place names no authorizer");const l=f((e,t,c)=>{const i=e.filter(h=>r(h,"scope")===t&&(!c||r(h,"measure")===c)&&r(h,"value")!=="withdraw");if(i.length!==1)throw Error(`REFUSE\xB7release ${t} needs one declaration`);return r(i[0],"value")},"one"),U={...k(a),id:s,publicKey:l(a,`keys/${s}`,"public-key"),coverage:l(a,`keys/${s}`,"coverage").split("|")};if(!o.length)throw Error("REFUSE\xB7release empty approval");for(const e of o){const t=b(e);if(t.kind!=="fact")throw Error("REFUSE\xB7release malformed approval");if(t.value.fields.by!==s||!t.value.fields.sig)throw Error(`REFUSE\xB7release approval must be signed by ${s}`)}const u=o.filter(e=>["wire/signature-algorithms","audit/wire/signature-algorithms","wire/era","audit/wire/era"].includes(r(e,"scope")));let m;try{m=L(u.length?R(u).standing:a)}catch{throw Error("REFUSE\xB7release signature era is absent or conflicting")}const F=$([],U,m.admitted);for(const e of o){const t=F.of(e);if(t.kind!=="admitted")throw Error(`REFUSE\xB7release ${r(e,"scope")}: ${t.why??t.kind}`)}const w=o.filter(e=>/^release\/[^/]+$/.test(r(e,"scope"))&&r(e,"measure")==="digest"&&r(e,"role")==="writes");if(w.length!==1)throw Error("REFUSE\xB7release needs one signed release/<tag> digest");const d=f((e,t)=>{const c=o.filter(i=>r(i,"scope")===e);if(c.some(i=>r(i,"role")!=="writes"||r(i,"form")!=="alphabet"||r(i,"measure")!==t))throw Error(`REFUSE\xB7release ${e} is not an approval declaration`);return l(c,e,t)},"required"),g=d(r(w[0],"scope"),"digest"),v=d("release/artifact","id"),E=d("sources/archive","id");if(!/^sha256:[a-f0-9]{64}$/.test(g))throw Error("REFUSE\xB7release archive needs sha256");if(!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(v))throw Error("REFUSE\xB7release artifact needs one safe filename");let p;try{p=new URL(E)}catch{throw Error("REFUSE\xB7release archive source needs an absolute URL")}if(p.username||p.password||/[\s\x00-\x1f\x7f]/.test(E))throw Error("REFUSE\xB7release archive source needs a credential-free absolute URL without whitespace");return`READY ${g} ${v} ${E}`}f(K,"releaseApproval");function H(n,o){const a=A(o);if(a===void 0)throw Error("REFUSE\xB7release approval file is absent");const s=a.split(`
2
+ `).filter(l=>l.trim().length>0);y("out",K(O(C(n,z)),s)+`
3
+ `)}f(H,"printReleaseApproval");export{H as printReleaseApproval,K as releaseApproval};
@@ -1 +1 @@
1
- var r=Object.defineProperty;var m=(e,t)=>r(e,"name",{value:t,configurable:!0});import{foldCeilings as u,ceilingSummary as c}from"../fold/ceilings.js";import{currentActReadings as f}from"../fold/own.js";import{placedReadings as g}from"../fold/observed.js";import{placesIn as b}from"../fold/places.js";import{releasePolicy as h,releaseFaults as y}from"../fold/release-policy.js";import{attestationObservations as p}from"../fold/evidence.js";import{library11_parse as v}from"../vendor/runtime.js";import{library12_point as w,library12_region as _,library12_within as k}from"../vendor/runtime.js";function O(e,t,o=f(e.under)){const s={...e.own,...o},a=u({standing:e.standing,ceilings:t,observed:e.observed,own:s,epoch:e.epoch,...e.under?{under:e.under,places:new Set(b(e.root))}:{}}),d=e.standing.filter(n=>!e.grey.includes(n)&&!e.refused.includes(n)),l=new Set(e.under?g(e.observed).filter(n=>!k(w(n.place.replace(/\/\*$/,"")),_(e.under))).map(n=>n.question):[]);return{...e,kept:!0,own:s,ceilings:c(a,t.length,l),release:h({standing:d,demands:e.demands,paid:e.paid,ceilings:t,readings:a,faults:y(e),verdicts:p(d.map(n=>{const i=v(n);return i.kind==="fact"?i.value.fields:{}}),e.second),snapshot:{fold:e.key,instrument:e.instrument}})}}m(O,"refreshRetainedJudgment");export{O as refreshRetainedJudgment};
1
+ var r=Object.defineProperty;var m=(e,t)=>r(e,"name",{value:t,configurable:!0});import{foldCeilings as u,ceilingSummary as c}from"../fold/ceilings.js";import{currentActReadings as f}from"../fold/own.js";import{placedReadings as g}from"../fold/observed.js";import{placesIn as b}from"../fold/places.js";import{releasePolicy as h,releaseFaults as y}from"../fold/release-policy.js";import{attestationObservations as p}from"../fold/evidence.js";import{library14_parse as v}from"../vendor/runtime.js";import{library0_point as w,library0_region as _,library0_within as k}from"../vendor/runtime.js";function O(e,t,o=f(e.under)){const s={...e.own,...o},a=u({standing:e.standing,ceilings:t,observed:e.observed,own:s,epoch:e.epoch,...e.under?{under:e.under,places:new Set(b(e.root))}:{}}),d=e.standing.filter(n=>!e.grey.includes(n)&&!e.refused.includes(n)),l=new Set(e.under?g(e.observed).filter(n=>!k(w(n.place.replace(/\/\*$/,"")),_(e.under))).map(n=>n.question):[]);return{...e,kept:!0,own:s,ceilings:c(a,t.length,l),release:h({standing:d,demands:e.demands,paid:e.paid,ceilings:t,readings:a,faults:y(e),verdicts:p(d.map(n=>{const i=v(n);return i.kind==="fact"?i.value.fields:{}}),e.second),snapshot:{fold:e.key,instrument:e.instrument}})}}m(O,"refreshRetainedJudgment");export{O as refreshRetainedJudgment};
@@ -1,4 +1,4 @@
1
- var o=Object.defineProperty;var r=(t,n)=>o(t,"name",{value:n,configurable:!0});import{hasContextualPlace as s,contextualStanding as e}from"../host/contextual-place.js";import{publicStandingLines as a}from"../host/admitted-place.js";import{assertStandingView as m}from"../host/standing-projection.js";import{lockStanding as p}from"../fold/keys.js";import{storeOf as c}from"../land/ledger.js";function w(t){const n=c(t);if(m(p(n)),s(t)){process.stdout.write(JSON.stringify(e(t))+`
2
- `);return}const i=a(t);process.stdout.write(i.length?i.join(`
1
+ var e=Object.defineProperty;var o=(t,n)=>e(t,"name",{value:n,configurable:!0});import{hostOutput as r}from"../host/call-context.js";import{hasContextualPlace as m,contextualStanding as s}from"../host/contextual-place.js";import{publicStandingLines as a}from"../host/admitted-place.js";import{assertStandingView as f}from"../host/standing-projection.js";import{lockStanding as p}from"../fold/keys.js";import{storeOf as u}from"../land/ledger.js";function O(t){const n=u(t);if(f(p(n)),m(t)){r("out",JSON.stringify(s(t))+`
2
+ `);return}const i=a(t);r("out",i.length?i.join(`
3
3
  `)+`
4
- `:"")}r(w,"printStandingResult");export{w as printStandingResult};
4
+ `:"")}o(O,"printStandingResult");export{O as printStandingResult};
package/dist/cli/takes.js CHANGED
@@ -1,10 +1,10 @@
1
- var N=Object.defineProperty;var g=(c,s)=>N(c,"name",{value:s,configurable:!0});import{hostOutput as E}from"../host/call-context.js";import{existsSync as x}from"node:fs";import{join as A}from"node:path";import{fullDigest as C}from"../fold/digests.js";import{library11_canonical as u}from"../vendor/runtime.js";import{fieldOf as i,foldClaims as D}from"../fold/claims.js";import{paidOf as R}from"../fold/paid.js";import{rolesOf as I}from"../fold/roles.js";import{writerFor as L}from"../fold/signers.js";import{judgeTake as V,sealed as W}from"../judge/take.js";import{land as $,landEnvelope as B,ledgerLines as G,storeOf as F}from"../land/ledger.js";import{wordOf as M}from"../fold/wire.js";import{hasVouchedTree as J,inside as P,landCoordinates as U,coordinatesOf as _,locationsOf as S,vouchedCoordinates as q,witnessOf as z}from"../land/vouched.js";import{ownerOf as H,forkedScopes as K,signedOwnerLines as T}from"./owner.js";function fe(c,s){const O=Date.now(),r=F(c),a=i(s,"scope"),p=g(e=>({kind:"refused",scope:a,why:e}),"refuse");if(!J(r))return p("no source is vouched; land the lock once");if(K(r).has(a))return p("it stands as a fork; the owner narrows or withdraws one line first");const m=i(s,"condition");if(m){const e=G(r,"judge").filter(f=>i(f,"scope")===m&&i(f,"value")==="present").pop();if(!e)return{kind:"owed",scope:a,why:`it rests on ${m}, which has no FACT: it stands owed until that is paid`};const n=S(i(s,"needs")).locations.filter(f=>!x(A(c,f.replace(/\/$/,""))));return n.length?p(`demanded locations absent: ${n.join(", ")}`):{kind:"conditioned",scope:a,demand:s,receipt:i(e,"at"),condition:m}}const{locations:d,refused:w}=S(i(s,"needs"));if(w.length)return p(`needs that are not locations: ${w.join(", ")}`);const k=I(r),t=new Map,j=g(e=>{const n=k(e);return n!=="source"&&t.set(n,(t.get(n)??0)+1),n},"walked"),v=new Map([...q(r)].filter(([e])=>d.some(n=>P(e,n))&&k(e)==="source")),l=new Map;for(const e of d)for(const[n,f]of _(c,e,j))l.set(n,f);const b=[a.split("/").pop()??a,i(s,"at").replace(/^witness:/,"")].filter(Boolean),h=D(T(r)).standing,y=R(r,[s],[],`${M(h,"families","view")}/`).missing.length===1,o=V({root:c,scope:a,value:i(s,"value"),locations:d,before:v,after:l,law:b,unpaid:y,shape:i(s,"shape"),restsOn:i(s,"restsOn"),witnessOf:g(e=>z(c,e),"witnessOf"),template:M(D(T(r)).standing,"templates","{roots}")});return{kind:"judged",scope:a,demand:s,locations:d,before:v,after:l,verdict:o,ignored:t,started:O}}g(fe,"judgeDemand");function ue(c,s,O){const r=F(c);if(s.kind==="refused")return;if(s.kind==="owed"){E("out",`OWED take ${s.scope} \xB7 ${s.why}
2
- `);return}if(s.kind==="conditioned"){const{scope:o,demand:e,receipt:n,condition:f}=s;$(r,"judge",[u({scope:o,role:"writes",form:"alphabet",measure:i(e,"measure")||"status",value:i(e,"value")||"present",by:"judge",at:n,condition:f})]),$(r,"take",[u({scope:`take/${o}`,role:"writes",form:"alphabet",measure:"status",value:"fact",by:"judge",at:n})]),E("out",`FACT take ${o} \xB7 paid by ${n} \xB7 condition ${f} \xB7 no moved set
3
- `);return}const{scope:a,demand:p,before:m,after:d,ignored:w,started:k}=s,t=W(c,s.verdict,O),j=L(T(r),"fold")??H(r),v=C(r,[...m].map(([o,e])=>`${o} ${e}`));$(r,"take",[u({scope:`take/${a}`,role:"writes",form:"alphabet",measure:"status",value:"open",by:j,at:`place:${v}`})]),B(r,t.digest,`${JSON.stringify(t.envelope,null,1)}
4
- `);const l=`receipt:${t.digest}`,b=C(r,[...d].sort().map(([o,e])=>`${o} ${e}`));if($(r,"judge",t.envelope.effects.map(o=>u({scope:`${o.kind}/${b}`,role:"writes",form:"alphabet",measure:"status",value:o.status,by:"judge",at:l}))),t.kind==="fact"){const o=new Map(t.changed.filter(n=>d.has(n)).map(n=>[n,d.get(n)??""])),e=t.changed.filter(n=>!d.has(n));U(r,o,e,l),$(r,"judge",[u({scope:a,role:"writes",form:"alphabet",measure:i(p,"measure")||"status",value:i(p,"value")||"present",by:"judge",at:l}),u({scope:a,role:"writes",form:"alphabet",measure:"cone",value:(t.changed.length?t.changed:[...d.keys()].sort()).join("|"),by:"judge",at:l})])}const h=Date.now()-k;$(r,"take",[u({scope:`take/${a}`,role:"writes",form:"alphabet",measure:"status",value:t.kind,by:"judge",at:l}),u({scope:`take/${a}`,role:"writes",form:"interval",measure:"ms",value:`${h}..${h}`,by:"judge",at:l})]);const y=t.envelope.effects.map(o=>`${o.kind}@${o.at||"."}:${o.admitted?o.status:`${o.status}\xB7grey`}(${o.ms} ms)`).join(" ")||"none";E("out",`${t.kind==="fact"?"FACT ":"REFUSE"} take ${a} \xB7 ${t.why}
5
- MOVED ${t.changed.length} sources: ${t.changed.join(" ")}
6
- IGNORED ${[...w].map(([o,e])=>`${e} ${o}`).join(" \xB7 ")||"none"} (not walked, never landed)
7
- ${t.notOwned.length?`NOT OWN ${t.notOwned.length} witnesses of other laws, left for them: ${t.notOwned.join(" ")}
8
- `:""}EFFECTS ${y}
9
- RECEIPT ${t.digest} \xB7 ${h} ms
10
- `)}g(ue,"landTake");export{fe as judgeDemand,ue as landTake};
1
+ var x=Object.defineProperty;var w=(l,o)=>x(l,"name",{value:o,configurable:!0});import{hostOutput as T}from"../host/call-context.js";import{existsSync as R}from"node:fs";import{join as A}from"node:path";import{fullDigest as F}from"../fold/digests.js";import{library14_canonical as p}from"../vendor/runtime.js";import{fieldOf as r,foldClaims as D}from"../fold/claims.js";import{paidOf as I}from"../fold/paid.js";import{rolesOf as L}from"../fold/roles.js";import{writerFor as U}from"../fold/signers.js";import{judgeTake as V,sealed as W}from"../judge/take.js";import{land as $,landEnvelope as B,ledgerLines as G,storeOf as S}from"../land/ledger.js";import{wordOf as M}from"../fold/wire.js";import{hasVouchedTree as J,inside as P,landCoordinates as _,coordinatesOf as q,locationsOf as N,vouchedCoordinates as z,witnessOf as H}from"../land/vouched.js";import{ownerOf as K,forkedScopes as Q,signedOwnerLines as C}from"./owner.js";function ue(l,o,b){if(b&&!Number.isSafeInteger(b.now))throw Error("REFUSE\xB7demand invalid explicit clock");const a=Date.now(),s=S(l),d=r(o,"scope"),m=w(e=>({kind:"refused",scope:d,why:e}),"refuse");if(!J(s))return m("no source is vouched; land the lock once");if(Q(s).has(d))return m("it stands as a fork; the owner narrows or withdraws one line first");const f=r(o,"condition");if(f){const e=G(s,"judge").filter(h=>r(h,"scope")===f&&r(h,"value")==="present").pop();if(!e)return{kind:"owed",scope:d,why:`it rests on ${f}, which has no FACT: it stands owed until that is paid`};const i=N(r(o,"needs")).locations.filter(h=>!R(A(l,h.replace(/\/$/,""))));return i.length?m(`demanded locations absent: ${i.join(", ")}`):{kind:"conditioned",scope:d,demand:o,receipt:r(e,"at"),condition:f}}const{locations:g,refused:j}=N(r(o,"needs"));if(j.length)return m(`needs that are not locations: ${j.join(", ")}`);const n=L(s),k=new Map,y=w(e=>{const i=n(e);return i!=="source"&&k.set(i,(k.get(i)??0)+1),i},"walked"),u=new Map([...z(s)].filter(([e])=>g.some(i=>P(e,i))&&n(e)==="source")),v=new Map;for(const e of g)for(const[i,h]of q(l,e,y))v.set(i,h);const O=[d.split("/").pop()??d,r(o,"at").replace(/^witness:/,"")].filter(Boolean),E=D(C(s)).standing,t=I(s,[o],[],`${M(E,"families","view")}/`).missing.length===1,c=V({root:l,scope:d,value:r(o,"value"),locations:g,before:u,after:v,law:O,unpaid:t,shape:r(o,"shape"),restsOn:r(o,"restsOn"),witnessOf:w(e=>H(l,e),"witnessOf"),template:M(D(C(s)).standing,"templates","{roots}")});return{kind:"judged",scope:d,demand:o,locations:g,before:u,after:v,verdict:c,ignored:k,started:a}}w(ue,"judgeDemand");function pe(l,o,b){const a=S(l);if(o.kind==="refused")return;if(o.kind==="owed"){T("out",`OWED take ${o.scope} \xB7 ${o.why}
2
+ `);return}if(o.kind==="conditioned"){const{scope:t,demand:c,receipt:e,condition:i}=o;$(a,"judge",[p({scope:t,role:"writes",form:"alphabet",measure:r(c,"measure")||"status",value:r(c,"value")||"present",by:"judge",at:e,condition:i})]),$(a,"take",[p({scope:`take/${t}`,role:"writes",form:"alphabet",measure:"status",value:"fact",by:"judge",at:e})]),T("out",`FACT take ${t} \xB7 paid by ${e} \xB7 condition ${i} \xB7 no moved set
3
+ `);return}const{scope:s,demand:d,before:m,after:f,ignored:g,started:j}=o,n=W(l,o.verdict,b),k=U(C(a),"fold")??K(a),y=F(a,[...m].map(([t,c])=>`${t} ${c}`));$(a,"take",[p({scope:`take/${s}`,role:"writes",form:"alphabet",measure:"status",value:"open",by:k,at:`place:${y}`})]),B(a,n.digest,`${JSON.stringify(n.envelope,null,1)}
4
+ `);const u=`receipt:${n.digest}`,v=F(a,[...f].sort().map(([t,c])=>`${t} ${c}`));if($(a,"judge",n.envelope.effects.map(t=>p({scope:`${t.kind}/${v}`,role:"writes",form:"alphabet",measure:"status",value:t.status,by:"judge",at:u}))),n.kind==="fact"){const t=new Map(n.changed.filter(e=>f.has(e)).map(e=>[e,f.get(e)??""])),c=n.changed.filter(e=>!f.has(e));_(a,t,c,u),$(a,"judge",[p({scope:s,role:"writes",form:"alphabet",measure:r(d,"measure")||"status",value:r(d,"value")||"present",by:"judge",at:u}),p({scope:s,role:"writes",form:"alphabet",measure:"cone",value:(n.changed.length?n.changed:[...f.keys()].sort()).join("|"),by:"judge",at:u})])}const O=Date.now()-j;$(a,"take",[p({scope:`take/${s}`,role:"writes",form:"alphabet",measure:"status",value:n.kind,by:"judge",at:u}),p({scope:`take/${s}`,role:"writes",form:"interval",measure:"ms",value:`${O}..${O}`,by:"judge",at:u})]);const E=n.envelope.effects.map(t=>`${t.kind}@${t.at||"."}:${t.admitted?t.status:`${t.status}\xB7grey`}(${t.ms} ms)`).join(" ")||"none";T("out",`${n.kind==="fact"?"FACT ":"REFUSE"} take ${s} \xB7 ${n.why}
5
+ MOVED ${n.changed.length} sources: ${n.changed.join(" ")}
6
+ IGNORED ${[...g].map(([t,c])=>`${c} ${t}`).join(" \xB7 ")||"none"} (not walked, never landed)
7
+ ${n.notOwned.length?`NOT OWN ${n.notOwned.length} witnesses of other laws, left for them: ${n.notOwned.join(" ")}
8
+ `:""}EFFECTS ${E}
9
+ RECEIPT ${n.digest} \xB7 ${O} ms
10
+ `)}w(pe,"landTake");export{ue as judgeDemand,pe as landTake};
package/dist/cli/verb.js CHANGED
@@ -1,84 +1,86 @@
1
1
  #!/usr/bin/env node
2
- var et=Object.defineProperty;var w=(e,t)=>et(e,"name",{value:t,configurable:!0});import{prepareNativeReadingIdentity as tt,prepareNativeViewIdentity as nt,declaredReadingIdentityLimits as st}from"../host/reading-identity.js";import{nativeHostInstrument as Re}from"../host/native-receiver.js";import{ownRoot as le,processOf as fe}from"../observe/runner.js";import{BoundRefusal as A,describeRefusal as it,readRefusalCatalog as rt}from"../host/refusals.js";import{readFileSync as ve}from"node:fs";import{sha256 as K}from"../host/hash.js";import{printReleaseApproval as ot}from"./release-result.js";import{inspectReference as ct}from"../host/reference.js";import{exportAuthenticatedReference as at}from"../host/reference-export.js";import{authenticatedReferenceSelected as dt,openAuthenticatedReference as lt}from"../host/reference-native.js";import{printActResult as ft}from"./act-result.js";import{printStandingResult as pt}from"./standing-result.js";import{withContentStore as Fe}from"../host/content-store.js";import{readOnly as Oe,withoutEffects as Ue}from"../host/read-only.js";import{layReleases as ut}from"../host/release.js";import{resolveSources as mt,resolveRequested as ht}from"../host/source-content.js";import{cellsWithReceipts as gt}from"../host/cell-receipts.js";import{library9_renderCells as wt}from"../vendor/runtime.js";import{releasePolicyLines as yt}from"../fold/release-policy.js";import{admittedObjects as xe}from"../host/objects.js";import{objectFold as Ie,executeComputation as Et}from"../engine/index.js";import{readingEnvironment as $t}from"../host/reading-context.js";import{verifyBytes as St}from"../host/adapters/keys/ed25519.js";import{instrumentDigest as bt}from"../fold/digests.js";import{library11_authorityAtEpoch as kt}from"../vendor/runtime.js";import{toposAt as Rt,contentAt as vt}from"../host/selected-topos.js";import{foldObjectsWithWasm as Ft,usesWasmObject as Ne}from"../wasm/object.js";import{library11_OBJECT_VIEW as Ot}from"../vendor/runtime.js";import{library7_toposStanding as Ut}from"../vendor/runtime.js";import{library11_wireAt as xt,library11_parse as Te}from"../vendor/runtime.js";import{lockStanding as pe}from"../fold/keys.js";import{ownStore as It,ownLock as je}from"../observe/runner.js";import{signedOwnerLines as te}from"./owner.js";import{existsSync as J,lstatSync as G,mkdirSync as Ce,writeFileSync as De}from"node:fs";import{basename as Nt,dirname as ue,join as ne,relative as me,resolve as $,sep as he}from"node:path";import{eraOf as Tt,signaturesOf as ge}from"../fold/digests.js";import{fullDigest as Ae}from"../host/digest.js";import{library11_canonical as Q}from"../vendor/runtime.js";import{EXTENSION as jt,LOCK as Le,fieldOf as L,foldClaims as Ct,isWire as We,selfName as j}from"../fold/claims.js";import{observedClaims as Dt,readerRefusals as Pe}from"../fold/observed.js";import{rolesOf as At}from"../fold/roles.js";import{authorityFor as se,releaseSigner as Be,rootSigner as we,writerFor as ye}from"../fold/signers.js";import{land as Z,ledgerLines as ie,storeOf as m}from"../land/ledger.js";import{lockLines as Ee,releaseOf as Lt}from"../fold/keys.js";import{signConsentLot as Wt}from"../land/sign.js";import{signerFor as Pt,frameSignerFor as Bt}from"../host/signing.js";import{admittedIn as _t,ownLockOf as Jt,tellOwn as Mt}from"../fold/signed.js";import{hasVouchedTree as Gt,landCoordinates as Vt,coordinatesOf as qt,locationsOf as zt,vouching as Ht,sourced as Kt}from"../land/vouched.js";import{observeText as $e}from"../observe/files.js";import{askWhy as Xt,unrendered as Yt,viewOf as Qt}from"../render/view.js";import{openCards as Zt}from"../render/open.js";import{foldPlace as _e,ownCeilings as Je,standingOf as V}from"./place.js";import{foldPoints as en,movedPoints as tn}from"../fold/kept.js";import{placesOf as nn,sharedShapes as sn,viewsOf as re}from"../fold/views.js";import{placesIn as rn}from"../fold/places.js";import{isCeiling as Se}from"../fold/configures.js";import{readingsIn as Me}from"../land/inert.js";import{pass as on}from"./pass.js";import{installActSignalHandler as cn,underTheLock as an,underTheRegions as dn,underRootAuthority as ln}from"../land/act.js";import{ownerOf as fn,renderInto as pn,signedDemands as un,targetFile as oe}from"./owner.js";import{claimLinesIn as ee,entryOf as be,namedPlaces as ke,positionalIndexes as mn,positionalsOf as W,valueOf as U}from"./args.js";import{EXIT as d,FLAGS as u,NAMED_VIEWS as X,helpLines as Ge}from"./names.js";import{accept as hn,signedBatch as Ve}from"./accept.js";import{renderWalk as gn,landWalk as wn,foreignWalkLines as yn}from"../host/walk.js";import{library10_isWalkHeader as En}from"../vendor/runtime.js";import{ingressBundles as $n,ingressReceipts as Sn}from"../host/ports/ingress.js";async function bn(e,t){const o=Date.now(),n=m(e),i=ee(oe(e)),s=$e(oe(e));let c,y,r,f=0,l;try{if(!i.length)throw new Error("REFUSE\xB7bootstrap the proposed lock holds no claims");const h=Tt(i),S=i.find(p=>["wire/digest-algorithms","audit/wire/digest-algorithms"].includes(L(p,"scope"))&&L(p,"value")!=="withdraw"),F=L(S??"","value").split("|").filter(Boolean)[0]?.split(":")[0]??"";if(!F)throw new Error("REFUSE\xB7bootstrap the proposed lock names no digest algorithm");if(c=ye(i,"authorize")??"",!c)throw new Error("REFUSE\xB7bootstrap the proposed lock declares no root authorizer");if(y=U(t,u.key)??c,ie(n,c).length)throw new Error("REFUSE\xB7bootstrap the owner ledger already holds claims; the first land happens once");const D=w(p=>{const O=new Set(i.filter(C=>L(C,"scope")===`keys/${c}`&&L(C,"measure")===p&&L(C,"value")!=="withdraw").map(C=>L(C,"value")));if(O.size!==1)throw new Error(`REFUSE\xB7bootstrap root key ${c} must declare one ${p}`);return[...O][0]},"said");if(D("class")!=="authorize")throw new Error("REFUSE\xB7bootstrap the root key must authorize");const g=D("public-key"),b=D("coverage").split("|").filter(Boolean);if(!g||!b.length)throw new Error("REFUSE\xB7bootstrap the root key must declare its public key and coverage");const I=i.filter(p=>!L(p,"sig"));if(I.length){const p=Pt(i,y,U(t,u.signer),U(t,u.keyFile)),O=await Wt(I,{epoch:1,by:y,algorithm:h.era},g,h.admitted,p);if(O.kind==="refuse")throw new Error(O.why);let C=0;i.splice(0,i.length,...i.map(R=>L(R,"sig")?R:O.lines[C++]))}const B=se(i,{...Be(i),id:c,publicKey:g,coverage:b},h.admitted);for(const p of i){const O=B.of(p);if(O.kind!=="admitted")throw new Error(`REFUSE\xB7bootstrap ${L(p,"scope")} is not admitted: ${O.why??O.kind}`);f+=1}Ht(i),Kt(i),r=Ae(i.map(p=>p.replace(/ sig="[^"]*"/,"")).sort(),F),l={[c]:{id:c,publicKey:g,coverage:b}}}catch(h){return process.stderr.write(`${j()}: ${h instanceof Error?h.message:String(h)}
3
- `),d.refuse}return an(n,"bootstrap",()=>{if(ie(n,c).length||$e(oe(e))!==s)return process.stderr.write(`${j()}: REFUSE\xB7bootstrap the proposed lock or owner ledger changed before commit
4
- `),d.refuse;const h=Z(n,c,i);y!==c&&Z(n,y,i);const S=ne(n,`${j()}.keys`);Ce(ue(S),{recursive:!0}),De(S,`${JSON.stringify(l,null,2)}
5
- `);const F=i.filter(b=>/\bsig=/.test(b)),D=F.length-f;Z(n,"land",[Q({scope:"bootstrap",role:"writes",form:"alphabet",measure:"status",value:"present",by:"land",at:`bootstrap:${r}`,about:"the lines this clone was born from: one land per clone, and a second is a fork of the same cell"})]);const g=pn(e,n);process.stdout.write(`FACT landed ${h.appended} unique lines from ${i.length} in TARGET \xB7 ${D} of ${F.length} signed lines fail admission by declared authority
6
- TARGET ${g.standing} claims \xB7 ${g.superseded.length} superseded \xB7 ${Date.now()-o} ms
7
- `);for(const b of g.superseded)process.stdout.write(`SUPERSEDED ${b}
8
- `);if(!Gt(n)){const b=new Set,I=new Set;for(const C of un(n)){const R=zt(L(C,"needs"));for(const M of R.locations)b.add(M);for(const M of R.refused)I.add(M)}const B=new Map,p=At(n);for(const C of b)for(const[R,M]of qt(e,C,p))B.set(R,M);const O=Vt(n,B,[],"origin:land");process.stdout.write(`FACT vouched \xB7 ${O} sources under ${b.size} locations \xB7 ${I.size} needs refused as globs
9
- `)}return d.closed})}w(bn,"firstLand");function ce(e,t,o){const n=ye(t.standing,"fold"),i=w(s=>`${(s/1e3).toFixed(s<100?2:1)} s`,"seconds");if(process.stderr.write(`BEAT fold ${t.key.slice(0,8)} ${t.kept?"kept":"folded"} ${i(o)}${t.beats.kept?` \xB7 ${i(t.beats.kept)} kept`:""}${t.beats.folded?` \xB7 ${i(t.beats.folded)} folded`:""}
10
- `),n!==void 0){if(!t.kept){const s=tn(m(e),en(m(e),t.standing,t.under,n,t.instrument),t.key),c=s===void 0?"no fold was kept before this one":`${s.gone.length} points gone \xB7 ${s.came.length} came \xB7 ${[...s.gone,...s.came].slice(0,3).map(y=>y.split(" ")[0]).join(" ")||"none"}`;process.stderr.write(`KEPT fold ${t.key.slice(0,8)} miss \xB7 ${c}
11
- `)}Z(m(e),n,[Q({scope:`beat/${t.under??"."}`,role:"writes",form:"interval",measure:"ms",value:`${o}..${o}`,by:n,at:`place:${t.kept?"kept":"folded"}`})])}}w(ce,"beat");async function Y(e,t,o,n=[],i,s,c=!0,y=!1){const[r=o,f,l,...h]=o.split("@");if(r===X.help)return process.stdout.write(`${Ge().join(`
2
+ var tt=Object.defineProperty;var $=(e,t)=>tt(e,"name",{value:t,configurable:!0});import{hostOutput as s,hostArguments as nt}from"../host/call-context.js";import{serveNativeCommands as it}from"../host/command-server.js";import{authenticatedStanding as rt}from"../host/admitted-place.js";import{prepareNativeProbe as ot}from"../host/native/probes.js";import{nativeAuthorityCardView as st}from"../host/native/authority-card-view.js";import{prepareNativeReadingIdentity as at,prepareNativeViewIdentity as ct,prepareNativeViewIdentities as lt,declaredReadingIdentityLimits as Fe}from"../host/reading-identity.js";import{nativeHostInstrument as te}from"../host/native-receiver.js";import{ownRoot as X,processOf as Y}from"../observe/runner.js";import{BoundRefusal as O,refusalRecord as dt}from"../host/refusals.js";import{readFileSync as Oe}from"node:fs";import{sha256 as Q}from"../host/hash.js";import{printReleaseApproval as ft}from"./release-result.js";import{inspectReference as ut}from"../host/reference.js";import{exportAuthenticatedReference as pt}from"../host/reference-export.js";import{authenticatedReferenceSelected as mt,openAuthenticatedReference as ht}from"../host/reference-native.js";import{printActResult as gt}from"./act-result.js";import{printStandingResult as wt}from"./standing-result.js";import{withContentStore as Ue}from"../host/content-store.js";import{readOnly as xe,withoutEffects as Ne}from"../host/read-only.js";import{layReleases as yt}from"../host/release.js";import{resolveSources as Et,resolveRequested as $t}from"../host/source-content.js";import{cellsWithReceipts as bt}from"../host/cell-receipts.js";import{library12_renderCells as kt}from"../vendor/runtime.js";import{releasePolicyLines as St}from"../fold/release-policy.js";import{admittedObjects as Ce}from"../host/objects.js";import{objectFold as De,executeComputation as vt}from"../engine/index.js";import{readingEnvironment as Rt}from"../host/reading-context.js";import{verifyBytes as Ft}from"../host/adapters/keys/ed25519.js";import{instrumentDigest as Ot}from"../fold/digests.js";import{library14_authorityAtEpoch as Ut}from"../vendor/runtime.js";import{toposAt as xt,contentAt as Nt}from"../host/selected-topos.js";import{foldObjectsWithWasm as Ct,usesWasmObject as Te}from"../wasm/object.js";import{library14_OBJECT_VIEW as Dt}from"../vendor/runtime.js";import{library10_toposStanding as Tt}from"../vendor/runtime.js";import{library14_wireAt as jt,library14_parse as je}from"../vendor/runtime.js";import{lockStanding as me}from"../fold/keys.js";import{ownStore as It,ownLock as Ie}from"../observe/runner.js";import{signedOwnerLines as oe}from"./owner.js";import{existsSync as _,lstatSync as V,mkdirSync as Ae,writeFileSync as Le}from"node:fs";import{basename as At,dirname as he,join as se,relative as ge,resolve as b,sep as we}from"node:path";import{eraOf as Lt,signaturesOf as ye}from"../fold/digests.js";import{fullDigest as We}from"../host/digest.js";import{library14_canonical as ne}from"../vendor/runtime.js";import{EXTENSION as Wt,LOCK as Be,fieldOf as W,foldClaims as Bt,isWire as Je,selfName as A}from"../fold/claims.js";import{observedClaims as Jt,readerRefusals as qe}from"../fold/observed.js";import{rolesOf as qt}from"../fold/roles.js";import{authorityFor as ae,releaseSigner as Me,rootSigner as Ee,writerFor as $e}from"../fold/signers.js";import{land as ie,ledgerLines as ce,storeOf as w}from"../land/ledger.js";import{lockLines as be,releaseOf as Mt}from"../fold/keys.js";import{signConsentLot as _t}from"../land/sign.js";import{signerFor as Pt,frameSignerFor as Vt}from"../host/signing.js";import{admittedIn as zt,ownLockOf as Gt,tellOwn as Ht}from"../fold/signed.js";import{hasVouchedTree as Kt,landCoordinates as Xt,coordinatesOf as Yt,locationsOf as Qt,vouching as Zt,sourced as en}from"../land/vouched.js";import{observeText as ke}from"../observe/files.js";import{askWhy as tn,unrendered as nn,viewOf as rn}from"../render/view.js";import{openCards as on}from"../render/open.js";import{foldPlace as _e,ownCeilings as Pe,standingOf as z}from"./place.js";import{foldPoints as sn,movedPoints as an}from"../fold/kept.js";import{placesOf as cn,sharedShapes as ln,viewsOf as le}from"../fold/views.js";import{placesIn as dn}from"../fold/places.js";import{isCeiling as Se}from"../fold/configures.js";import{readingsIn as Ve}from"../land/inert.js";import{pass as fn}from"./pass.js";import{installActSignalHandler as un,underTheLock as pn,underTheRegions as mn,underRootAuthority as hn}from"../land/act.js";import{ownerOf as gn,renderInto as wn,signedDemands as yn,targetFile as de}from"./owner.js";import{claimLinesIn as re,entryOf as ve,namedPlaces as Re,positionalIndexes as En,positionalsOf as B,valueOf as N}from"./args.js";import{EXIT as l,FLAGS as g,NAMED_VIEWS as Z,helpLines as ze}from"./names.js";import{accept as $n,signedBatch as Ge}from"./accept.js";import{renderWalk as bn,landWalk as kn,foreignWalkLines as Sn}from"../host/walk.js";import{library13_isWalkHeader as vn}from"../vendor/runtime.js";import{ingressBundles as Rn,ingressReceipts as Fn}from"../host/ports/ingress.js";async function On(e,t){const a=Date.now(),n=w(e),i=re(de(e)),c=ke(de(e));let d,E,r,u=0,f;try{if(!i.length)throw new Error("REFUSE\xB7bootstrap the proposed lock holds no claims");const m=Lt(i),k=i.find(p=>["wire/digest-algorithms","audit/wire/digest-algorithms"].includes(W(p,"scope"))&&W(p,"value")!=="withdraw"),U=W(k??"","value").split("|").filter(Boolean)[0]?.split(":")[0]??"";if(!U)throw new Error("REFUSE\xB7bootstrap the proposed lock names no digest algorithm");if(d=$e(i,"authorize")??"",!d)throw new Error("REFUSE\xB7bootstrap the proposed lock declares no root authorizer");if(E=N(t,g.key)??d,ce(n,d).length)throw new Error("REFUSE\xB7bootstrap the owner ledger already holds claims; the first land happens once");const L=$(p=>{const x=new Set(i.filter(I=>W(I,"scope")===`keys/${d}`&&W(I,"measure")===p&&W(I,"value")!=="withdraw").map(I=>W(I,"value")));if(x.size!==1)throw new Error(`REFUSE\xB7bootstrap root key ${d} must declare one ${p}`);return[...x][0]},"said");if(L("class")!=="authorize")throw new Error("REFUSE\xB7bootstrap the root key must authorize");const y=L("public-key"),S=L("coverage").split("|").filter(Boolean);if(!y||!S.length)throw new Error("REFUSE\xB7bootstrap the root key must declare its public key and coverage");const D=i.filter(p=>!W(p,"sig"));if(D.length){const p=Pt(i,E,N(t,g.signer),N(t,g.keyFile)),x=await _t(D,{epoch:1,by:E,algorithm:m.era},y,m.admitted,p);if(x.kind==="refuse")throw new Error(x.why);let I=0;i.splice(0,i.length,...i.map(R=>W(R,"sig")?R:x.lines[I++]))}const q=ae(i,{...Me(i),id:d,publicKey:y,coverage:S},m.admitted);for(const p of i){const x=q.of(p);if(x.kind!=="admitted")throw new Error(`REFUSE\xB7bootstrap ${W(p,"scope")} is not admitted: ${x.why??x.kind}`);u+=1}Zt(i),en(i),r=We(i.map(p=>p.replace(/ sig="[^"]*"/,"")).sort(),U),f={[d]:{id:d,publicKey:y,coverage:S}}}catch(m){if(m instanceof O)throw m;return s("error",`${A()}: ${m instanceof Error?m.message:String(m)}
3
+ `),l.refuse}return pn(n,"bootstrap",()=>{if(ce(n,d).length||ke(de(e))!==c)return s("error",`${A()}: REFUSE\xB7bootstrap the proposed lock or owner ledger changed before commit
4
+ `),l.refuse;const m=ie(n,d,i);E!==d&&ie(n,E,i);const k=se(n,`${A()}.keys`);Ae(he(k),{recursive:!0}),Le(k,`${JSON.stringify(f,null,2)}
5
+ `);const U=i.filter(S=>/\bsig=/.test(S)),L=U.length-u;ie(n,"land",[ne({scope:"bootstrap",role:"writes",form:"alphabet",measure:"status",value:"present",by:"land",at:`bootstrap:${r}`,about:"the lines this clone was born from: one land per clone, and a second is a fork of the same cell"})]);const y=wn(e,n);s("out",`FACT landed ${m.appended} unique lines from ${i.length} in TARGET \xB7 ${L} of ${U.length} signed lines fail admission by declared authority
6
+ TARGET ${y.standing} claims \xB7 ${y.superseded.length} superseded \xB7 ${Date.now()-a} ms
7
+ `);for(const S of y.superseded)s("out",`SUPERSEDED ${S}
8
+ `);if(!Kt(n)){const S=new Set,D=new Set;for(const I of yn(n)){const R=Qt(W(I,"needs"));for(const P of R.locations)S.add(P);for(const P of R.refused)D.add(P)}const q=new Map,p=qt(n);for(const I of S)for(const[R,P]of Yt(e,I,p))q.set(R,P);const x=Xt(n,q,[],"origin:land");s("out",`FACT vouched \xB7 ${x} sources under ${S.size} locations \xB7 ${D.size} needs refused as globs
9
+ `)}return l.closed})}$(On,"firstLand");function fe(e,t,a){const n=$e(t.standing,"fold"),i=$(c=>`${(c/1e3).toFixed(c<100?2:1)} s`,"seconds");if(s("error",`BEAT fold ${t.key.slice(0,8)} ${t.kept?"kept":"folded"} ${i(a)}${t.beats.kept?` \xB7 ${i(t.beats.kept)} kept`:""}${t.beats.folded?` \xB7 ${i(t.beats.folded)} folded`:""}
10
+ `),n!==void 0){if(!t.kept){const c=an(w(e),sn(w(e),t.standing,t.under,n,t.instrument),t.key),d=c===void 0?"no fold was kept before this one":`${c.gone.length} points gone \xB7 ${c.came.length} came \xB7 ${[...c.gone,...c.came].slice(0,3).map(E=>E.split(" ")[0]).join(" ")||"none"}`;s("error",`KEPT fold ${t.key.slice(0,8)} miss \xB7 ${d}
11
+ `)}ie(w(e),n,[ne({scope:`beat/${t.under??"."}`,role:"writes",form:"interval",measure:"ms",value:`${a}..${a}`,by:n,at:`place:${t.kept?"kept":"folded"}`})])}}$(fe,"beat");async function ee(e,t,a,n=[],i,c,d=!0,E=!1){const[r=a,u,f,...m]=a.split("@");if(r===Z.help)return s("out",`${ze().join(`
12
12
  `)}
13
- `),d.closed;if(r==="reading-identity"&&f!==void 0){if(t||n.length||i||h.length||l==="")throw new A("reading-identity/selection","REFUSE\xB7native view identity requires one local place and a declared selector");const a=nt({place:e,instrument:Re(le(),fe("verb")),view:f,...l?{expectedIdentity:l}:{}});if(a.kind==="refuse")throw new A(a.code,a.diagnostic);return process.stdout.write(JSON.stringify(l===void 0?{kind:a.kind,view:a.view,identity:a.identity}:a)+`
14
- `),d.closed}if(r==="reading-identity"){if(t||n.length||i||f!==void 0)throw new A("host/context","REFUSE\xB7reading identity requires one local admitted place");const a=st(pe(m(e))),E=await tt({place:e,instrument:Re(le(),fe("verb")),limits:a});if(E.kind==="refuse")throw new A(E.code,E.diagnostic);return process.stdout.write(JSON.stringify(E)+`
15
- `),d.closed}if(!y&&!n.length&&!Oe()&&pe(m(e)).some(a=>/^reader\/.+\/port$/.test(L(a,"scope"))&&L(a,"role")==="writes"&&L(a,"value")!=="withdraw"))return ln(m(e),"view reader authority",()=>Y(e,t,o,n,i,s,c,!0));if(!Ee(m(e)).length)return process.stderr.write(`${j()}: the owner ledger is empty; land it before rendering a view
16
- `),d.refuse;if(r==="act"){if(t||n.length)throw Error("REFUSE\xB7act committed identity query only");return ft(e,i),d.closed}if(r==="standing"){if(t||n.length||i||f!==void 0)throw new A("standing/query","REFUSE\xB7standing local committed projection only");return pt(e),d.closed}if(r==="evidence"&&!t&&!n.length&&$n(m(e)).length){const a=re(pe(m(e))).get(r);if(!a||a.shape||!a.regions.some(T=>T.name==="evidence"))throw Error("REFUSE\xB7view foreign evidence requires a declared evidence view");const E=await yn(e),N=se(Ee(m(e)),we(e),ge(m(e)).admitted),x=[...new Set(N.admitted.flatMap(T=>ie(m(e),T.id)))].filter(T=>N.of(T).kind==="admitted");for(const T of[...new Set([...x,...Sn(m(e)),...E])])process.stdout.write(T+`
17
- `);return process.stdout.write(`FACT authenticated histories \xB7 readings \xB7 no encounters computed
18
- `),d.closed}const S=Date.now(),F=t?.replace(/\/$/,""),D=Lt(m(e)),g=se([...D??Ee(m(e)),...n],D?Be(D):we(e),ge(m(e),n).admitted),b=n.filter(a=>g.of(a).kind==="admitted"),I=n.filter(a=>!b.includes(a));if(F&&I.length&&Mt(F,I),r===X.lines&&(n.length||f===void 0)){const a=V(e,t,b).standing.filter(We).join(`
19
- `);return process.stdout.write(a?`${a}
20
- `:""),d.closed}if(n.length){const a=re(V(e,t,b).standing).get(r);if(a&&!a.shape&&a.regions.some(E=>E.name==="cells")){const E=[...te(m(e)),...b],N=await xe(e,E);process.stdout.write(`TOLD ${n.length} lines folded as if landed \xB7 nothing written
21
- `);for(const x of wt(Ie(N.records,N.context)))process.stdout.write(x+`
22
- `);return d.closed}}const B=F?I.filter(a=>_t(e,F,a)):[];!n.length&&!Oe()&&ut(m(e),e,V(e,t).standing,m(e));const p=n.length?_e(e,be(e),t,!1,{standing:V(e,t,b),observed:Dt(e,m(e),{wait:!1}),free:!0}):_e(e,be(e),t,!0);if(!n.length&&Pe().length){for(const a of Pe())process.stderr.write(`${j()}: ${a}
23
- `);return d.refuse}if(i&&Xt(p,i),r===X.lines){n.length||ce(e,p,Date.now()-S);const a=p.standing.filter(We).join(`
24
- `);if(process.stdout.write(a?`${a}
25
- `:""),f==="1")for(const E of Me([...p.standing.filter(Se),...Je(t)],p))process.stdout.write(`${E}
26
- `);return d.closed}const O=re(p.standing),C=[...O.entries()].find(([,a])=>!a.shape&&a.regions.some(E=>E.name==="cells"));if(C&&r===C[0]){const a=te(m(e)),{objectHistory:E}=await import("../vendor/library11.js"),N=E(a);if(N.kind!=="fact")throw Error(`REFUSE\xB7wire ${N.why}`);if(N.value.objects.length){if(await gt(e,a,k=>process.stdout.write(k+`
27
- `)),c)for(const k of yt(p.release))process.stdout.write(k+`
28
- `);return n.length||ce(e,p,Date.now()-S),d.closed}n.length||ce(e,p,Date.now()-S);const x=p.open??[],T=s?x.filter(k=>k.origins.includes(s)):x,v=Zt(T);return s&&process.stdout.write(`KEY ${s}
29
- `),v.length&&process.stdout.write(`${v.join(`
13
+ `),l.closed;if(r==="authority-card"){if(t||n.length||i||!u||f!==void 0||m.length)throw new O("authority-card/selection","REFUSE\xB7authority-card/selection requires one admitted request scope");const o=await st(e,te(X(),Y("verb")),u);if(o.kind==="refuse")throw new O(o.code,o.diagnostic);return s("out",JSON.stringify(o)+`
14
+ `),l.closed}if(r==="probe"){if(t||n.length||i||!u||m.length||f==="")throw new O("reading-identity/selection","REFUSE\xB7probe requires one local native view");const o=Fe(rt(e)),h=ot({place:e,instrument:te(X(),Y("verb")),view:u,...f?{expectedIdentity:f}:{},port:{coordinate:"port/native-probe",probes:o.probes,responseBytes:o.bytes},counter:{used:new Map}});if(h.kind==="refuse")throw new O(h.code,h.diagnostic);return s("out",JSON.stringify(h)+`
15
+ `),l.closed}if(r==="reading-identities"){if(t||n.length||i||!u||f!==void 0||m.length)throw new O("reading-identity/selection","REFUSE\xB7native view identities require one local place and explicit views");const o=lt({place:e,instrument:te(X(),Y("verb")),views:u.split("+")});if(o.kind==="refuse")throw new O(o.code,o.diagnostic);return s("out",JSON.stringify(o)+`
16
+ `),l.closed}if(r==="reading-identity"&&u!==void 0){if(t||n.length||i||m.length||f==="")throw new O("reading-identity/selection","REFUSE\xB7native view identity requires one local place and a declared selector");const o=ct({place:e,instrument:te(X(),Y("verb")),view:u,...f?{expectedIdentity:f}:{}});if(o.kind==="refuse")throw new O(o.code,o.diagnostic);return s("out",JSON.stringify(f===void 0?{kind:o.kind,view:o.view,identity:o.identity}:o)+`
17
+ `),l.closed}if(r==="reading-identity"){if(t||n.length||i||u!==void 0)throw new O("host/context","REFUSE\xB7reading identity requires one local admitted place");const o=Fe(me(w(e))),h=await at({place:e,instrument:te(X(),Y("verb")),limits:o});if(h.kind==="refuse")throw new O(h.code,h.diagnostic);return s("out",JSON.stringify(h)+`
18
+ `),l.closed}if(!E&&!n.length&&!xe()&&me(w(e)).some(o=>/^reader\/.+\/port$/.test(W(o,"scope"))&&W(o,"role")==="writes"&&W(o,"value")!=="withdraw"))return hn(w(e),"view reader authority",()=>ee(e,t,a,n,i,c,d,!0));if(!be(w(e)).length)return s("error",`${A()}: the owner ledger is empty; land it before rendering a view
19
+ `),l.refuse;if(r==="act"){if(t||n.length)throw Error("REFUSE\xB7act committed identity query only");return gt(e,i),l.closed}if(r==="standing"){if(t||n.length||i||u!==void 0)throw new O("standing/query","REFUSE\xB7standing local committed projection only");return wt(e),l.closed}if(r==="evidence"&&!t&&!n.length&&Rn(w(e)).length){const o=le(me(w(e))).get(r);if(!o||o.shape||!o.regions.some(j=>j.name==="evidence"))throw Error("REFUSE\xB7view foreign evidence requires a declared evidence view");const h=await Sn(e),T=ae(be(w(e)),Ee(e),ye(w(e)).admitted),C=[...new Set(T.admitted.flatMap(j=>ce(w(e),j.id)))].filter(j=>T.of(j).kind==="admitted");for(const j of[...new Set([...C,...Fn(w(e)),...h])])s("out",j+`
20
+ `);return s("out",`FACT authenticated histories \xB7 readings \xB7 no encounters computed
21
+ `),l.closed}const k=Date.now(),U=t?.replace(/\/$/,""),L=Mt(w(e)),y=ae([...L??be(w(e)),...n],L?Me(L):Ee(e),ye(w(e),n).admitted),S=n.filter(o=>y.of(o).kind==="admitted"),D=n.filter(o=>!S.includes(o));if(U&&D.length&&Ht(U,D),r===Z.lines&&(n.length||u===void 0)){const o=z(e,t,S).standing.filter(Je).join(`
22
+ `);return s("out",o?`${o}
23
+ `:""),l.closed}if(n.length){const o=le(z(e,t,S).standing).get(r);if(o&&!o.shape&&o.regions.some(h=>h.name==="cells")){const h=[...oe(w(e)),...S],T=await Ce(e,h);s("out",`TOLD ${n.length} lines folded as if landed \xB7 nothing written
24
+ `);for(const C of kt(De(T.records,T.context)))s("out",C+`
25
+ `);return l.closed}}const q=U?D.filter(o=>zt(e,U,o)):[];!n.length&&!xe()&&yt(w(e),e,z(e,t).standing,w(e));const p=n.length?_e(e,ve(e),t,!1,{standing:z(e,t,S),observed:Jt(e,w(e),{wait:!1}),free:!0}):_e(e,ve(e),t,!0);if(!n.length&&qe().length){for(const o of qe())s("error",`${A()}: ${o}
26
+ `);return l.refuse}if(i&&tn(p,i),r===Z.lines){n.length||fe(e,p,Date.now()-k);const o=p.standing.filter(Je).join(`
27
+ `);if(s("out",o?`${o}
28
+ `:""),u==="1")for(const h of Ve([...p.standing.filter(Se),...Pe(t)],p))s("out",`${h}
29
+ `);return l.closed}const x=le(p.standing),I=[...x.entries()].find(([,o])=>!o.shape&&o.regions.some(h=>h.name==="cells"));if(I&&r===I[0]){const o=oe(w(e)),{objectHistory:h}=await import("../vendor/library14.js"),T=h(o);if(T.kind!=="fact")throw Error(`REFUSE\xB7wire ${T.why}`);if(T.value.objects.length){if(await bt(e,o,v=>s("out",v+`
30
+ `)),d)for(const v of St(p.release))s("out",v+`
31
+ `);return n.length||fe(e,p,Date.now()-k),l.closed}n.length||fe(e,p,Date.now()-k);const C=p.open??[],j=c?C.filter(v=>v.origins.includes(c)):C,F=on(j);return c&&s("out",`KEY ${c}
32
+ `),F.length&&s("out",`${F.join(`
30
33
  `)}
31
- `),d.closed}if(n.length||ce(e,p,Date.now()-S),r==="rank"){const E=(F?[F]:rn(e)).flatMap(N=>sn(Jt(e,N)).map(x=>`${N} ${x}`));if(E.length)return process.stderr.write(`${j()}: REFUSE\xB7rank ${E.join(" \xB7 ")}: two views naming the same shape in one place
32
- `),d.refuse}const R=O.get(r);if(!R)return process.stderr.write(`${j()}: no view/${r} is signed; the lock signs ${[...O.keys()].sort().map(a=>`view/${a}`).join(" \xB7 ")||"no view"}
33
- `),d.usage;const M=Yt(p,R);if(M.length)return process.stderr.write(`${j()}: REFUSE\xB7view view/${r} asks regions nothing renders: ${M.join(" ")} \xB7 none is the instrument's own and no capsule ${t??"the root"} can run declares it
34
- `),d.refuse;const q=nn(p.standing,R);if(q.length&&!q.includes(t??""))return process.stderr.write(`${j()}: view/${r} writes ${q.map(a=>`${a}${R.shape}`).join(" \xB7 ")}, and nothing of ${t??"this place"}
35
- `),d.usage;const z=ye(p.standing,"fold");if(z!==void 0&&!n.length){const a=Date.now()-S;Z(m(e),z,[Q({scope:`beat/${t??"."}`,role:"writes",form:"interval",measure:"ms",value:`${a}..${a}`,by:z,at:`place:command-${p.kept?"kept":"folded"}`})])}return w(a=>{const E=Qt(a,Number.isFinite(Number(f))&&f!==void 0?{...R,regions:R.regions.map(x=>x.called?{...x,at:Number(f)}:x)}:R);if(process.argv.includes(u.check)){const x=ne(e,t??"",R.shape||""),T=R.shape?$e(x):void 0;if(T!==void 0&&T===E)return process.stdout.write(`SAME ${R.shape||`view/${r}`}
36
- `),d.closed;const k=(T??"").split(`
37
- `),P=E.split(`
38
- `),H=k.findIndex((Qe,Ze)=>Qe!==P[Ze]),_=H<0?Math.min(k.length,P.length):H,Ye=(H<0?P[_]:k[_])??P[_]??"";return process.stdout.write(`DIFFERS ${R.shape||`view/${r}`}${T===void 0?" \xB7 this place holds no such region":` \xB7 line ${_+1} \xB7 ${Ye}`}
39
- `),d.refuse}if(!R.shape||n.length){if(n.length&&process.stdout.write(`TOLD ${n.length} lines folded as if landed \xB7 ${b.length} in the ledger \xB7 ${B.length} in ${F??"the root"}'s own lock${I.length-B.length?` \xB7 ${I.length-B.length} admitted nowhere`:""} \xB7 the batch lands nothing and nothing is written
40
- `),process.stdout.write(E),f==="1")for(const x of Me(n.length?n.filter(Se):[...a.standing.filter(Se),...Je(t)],a))process.stdout.write(`${x}
41
- `);return d.closed}const N=ne(e,t??"",R.shape);return dn(m(e),[t??""],`view/${r}`,()=>(Ce(ue(N),{recursive:!0}),De(N,E),process.stdout.write(`RENDERED ${me(e,N).split(he).join("/")} \xB7 view/${r} \xB7 ${E.split(`
34
+ `),l.closed}if(n.length||fe(e,p,Date.now()-k),r==="rank"){const h=(U?[U]:dn(e)).flatMap(T=>ln(Gt(e,T)).map(C=>`${T} ${C}`));if(h.length)return s("error",`${A()}: REFUSE\xB7rank ${h.join(" \xB7 ")}: two views naming the same shape in one place
35
+ `),l.refuse}const R=x.get(r);if(!R)return s("error",`${A()}: no view/${r} is signed; the lock signs ${[...x.keys()].sort().map(o=>`view/${o}`).join(" \xB7 ")||"no view"}
36
+ `),l.usage;const P=nn(p,R);if(P.length)return s("error",`${A()}: REFUSE\xB7view view/${r} asks regions nothing renders: ${P.join(" ")} \xB7 none is the instrument's own and no capsule ${t??"the root"} can run declares it
37
+ `),l.refuse;const G=cn(p.standing,R);if(G.length&&!G.includes(t??""))return s("error",`${A()}: view/${r} writes ${G.map(o=>`${o}${R.shape}`).join(" \xB7 ")}, and nothing of ${t??"this place"}
38
+ `),l.usage;const H=$e(p.standing,"fold");if(H!==void 0&&!n.length){const o=Date.now()-k;ie(w(e),H,[ne({scope:`beat/${t??"."}`,role:"writes",form:"interval",measure:"ms",value:`${o}..${o}`,by:H,at:`place:command-${p.kept?"kept":"folded"}`})])}return $(o=>{const h=rn(o,Number.isFinite(Number(u))&&u!==void 0?{...R,regions:R.regions.map(C=>C.called?{...C,at:Number(u)}:C)}:R);if((nt()??process.argv).includes(g.check)){const C=se(e,t??"",R.shape||""),j=R.shape?ke(C):void 0;if(j!==void 0&&j===h)return s("out",`SAME ${R.shape||`view/${r}`}
39
+ `),l.closed;const v=(j??"").split(`
40
+ `),J=h.split(`
41
+ `),K=v.findIndex((Ze,et)=>Ze!==J[et]),M=K<0?Math.min(v.length,J.length):K,Qe=(K<0?J[M]:v[M])??J[M]??"";return s("out",`DIFFERS ${R.shape||`view/${r}`}${j===void 0?" \xB7 this place holds no such region":` \xB7 line ${M+1} \xB7 ${Qe}`}
42
+ `),l.refuse}if(!R.shape||n.length){if(n.length&&s("out",`TOLD ${n.length} lines folded as if landed \xB7 ${S.length} in the ledger \xB7 ${q.length} in ${U??"the root"}'s own lock${D.length-q.length?` \xB7 ${D.length-q.length} admitted nowhere`:""} \xB7 the batch lands nothing and nothing is written
43
+ `),s("out",h),u==="1")for(const C of Ve(n.length?n.filter(Se):[...o.standing.filter(Se),...Pe(t)],o))s("out",`${C}
44
+ `);return l.closed}const T=se(e,t??"",R.shape);return mn(w(e),[t??""],`view/${r}`,()=>(Ae(he(T),{recursive:!0}),Le(T,h),s("out",`RENDERED ${ge(e,T).split(we).join("/")} \xB7 view/${r} \xB7 ${h.split(`
42
45
  `).length-1} lines
43
- `),d.closed))},"shown")(p)}w(Y,"view");async function kn(e,t){const o=U(t,u.as);if(o!==void 0){const i=W(t);if(o!=="reference"||i.length!==1||t.includes(u.check))throw new A("reference-export/usage","REFUSE\xB7reference-export usage: sign --as reference <source-url>");const s=await at(e,i[0],{key:U(t,u.key),keyFile:U(t,u.keyFile),signer:U(t,u.signer)});return process.stdout.write(JSON.stringify(s)+`
44
- `),d.closed}const n=await Ve(e,t,W(t));if(n.kind==="exit")return n.code;if(n.kind==="once")return process.stderr.write(`ONCE ${n.proposed.length} lines \xB7 every one already landed: nothing to sign
45
- `),d.closed;for(const i of ke(t))process.stdout.write(`# place ${i}
46
- `);for(const i of n.signed)process.stdout.write(`${i}
47
- `);return process.stderr.write(`SIGNED ${n.signed.length} lines \xB7 epoch ${n.epoch}${ke(t).length?` \xB7 own lines for ${ke(t).join(", ")}`:""} \xB7 they land together, before the lock moves
48
- `),d.closed}w(kn,"signVerb");async function Rn(e,t){const o=$(oe(e)),n=W(t).filter(s=>{const c=$(s);return J(c)&&!G(c).isDirectory()&&c!==o});if(!n.length){const s=m(e);return J(ne(s,"ledger"))&&ie(s,fn(s)).length?(process.stderr.write(`${j()}: REFUSE\xB7bootstrap the owner ledger already holds claims; provide an explicit signed batch to change it
49
- `),d.refuse):bn(e,t)}const i=w(s=>{process.stderr.write(`${j()}: ${s.startsWith("REFUSE\xB7")?s:`REFUSE\xB7crash ${s}`}
50
- `),process.exitCode=d.refuse},"die");process.once("SIGINT",()=>i("SIGINT")),process.once("SIGHUP",()=>i("SIGHUP")),process.once("uncaughtException",s=>i(s instanceof Error?s.message:String(s))),process.once("unhandledRejection",s=>i(s instanceof Error?s.message:String(s)));try{const s=n.flatMap(ee);if(s.some(En)){for(const c of await wn(e,s,U(t,u.key),U(t,u.keyFile),U(t,u.signer)))process.stdout.write(c+`
51
- `);return d.closed}return await hn(e,t)}catch(s){const c=s instanceof Error?s.message:String(s);return process.stderr.write(`${j()}: ${c.startsWith("REFUSE\xB7")?c:`REFUSE\xB7crash ${c}`}
52
- `),d.refuse}}w(Rn,"landVerb");function vn(e){const t=ee(e),o=Ct(t),i=o.standing.flatMap(c=>{const y=Te(c);return y.kind==="fact"?[y.value.fields]:[]}).some(c=>c.scope?.startsWith("region/")&&c.measure==="reads");if(i&&o.forks.length)throw Error("REFUSE\xB7topos incompatible live claims in declared fold");const s=i?Ut(o.standing):void 0;if(s!==void 0){const y=xt(je().flatMap(r=>{const f=Te(r);return f.kind==="fact"?[f.value.fields]:[]}),Number.MAX_SAFE_INTEGER)?.digests.values().next().value;if(!y)throw Error("REFUSE\xB7topos instrument names no digest algorithm");process.stdout.write(s.split(`
46
+ `),l.closed))},"shown")(p)}$(ee,"view");async function Un(e,t){const a=N(t,g.as);if(a!==void 0){const i=B(t);if(a!=="reference"||i.length!==1||t.includes(g.check))throw new O("reference-export/usage","REFUSE\xB7reference-export usage: sign --as reference <source-url>");const c=await pt(e,i[0],{key:N(t,g.key),keyFile:N(t,g.keyFile),signer:N(t,g.signer)});return s("out",JSON.stringify(c)+`
47
+ `),l.closed}const n=await Ge(e,t,B(t));if(n.kind==="exit")return n.code;if(n.kind==="once")return s("error",`ONCE ${n.proposed.length} lines \xB7 every one already landed: nothing to sign
48
+ `),l.closed;for(const i of Re(t))s("out",`# place ${i}
49
+ `);for(const i of n.signed)s("out",`${i}
50
+ `);return s("error",`SIGNED ${n.signed.length} lines \xB7 epoch ${n.epoch}${Re(t).length?` \xB7 own lines for ${Re(t).join(", ")}`:""} \xB7 they land together, before the lock moves
51
+ `),l.closed}$(Un,"signVerb");async function xn(e,t){const a=b(de(e)),n=B(t).filter(i=>{const c=b(i);return _(c)&&!V(c).isDirectory()&&c!==a});if(!n.length){const i=w(e);return _(se(i,"ledger"))&&ce(i,gn(i)).length?(s("error",`${A()}: REFUSE\xB7bootstrap the owner ledger already holds claims; provide an explicit signed batch to change it
52
+ `),l.refuse):On(e,t)}try{const i=n.flatMap(re);if(i.some(vn)){for(const c of await kn(e,i,N(t,g.key),N(t,g.keyFile),N(t,g.signer)))s("out",c+`
53
+ `);return l.closed}return await $n(e,t)}catch(i){if(i instanceof O)throw i;const c=i instanceof Error?i.message:String(i);return s("error",`${A()}: ${c.startsWith("REFUSE\xB7")?c:`REFUSE\xB7crash ${c}`}
54
+ `),l.refuse}}$(xn,"landVerb");function Nn(e){const t=re(e),a=Bt(t),i=a.standing.flatMap(d=>{const E=je(d);return E.kind==="fact"?[E.value.fields]:[]}).some(d=>d.scope?.startsWith("region/")&&d.measure==="reads");if(i&&a.forks.length)throw Error("REFUSE\xB7topos incompatible live claims in declared fold");const c=i?Tt(a.standing):void 0;if(c!==void 0){const E=jt(Ie().flatMap(r=>{const u=je(r);return u.kind==="fact"?[u.value.fields]:[]}),Number.MAX_SAFE_INTEGER)?.digests.values().next().value;if(!E)throw Error("REFUSE\xB7topos instrument names no digest algorithm");s("out",c.split(`
53
55
  `).filter(Boolean).map(r=>"TOPOS "+r).join(`
54
56
  `)+`
55
- `),process.stdout.write("PIN "+Ae([s],y)+`
56
- `)}for(const c of o.standing)process.stdout.write(`${c}
57
- `);for(const c of o.forks)process.stdout.write(`FORK ${c.key}${c.state?` \xB7 ${c.state}`:""}
58
- `);return process.stdout.write(`FACT ${o.standing.length} standing \xB7 ${o.forks.length} forks \xB7 ${Nt(e)} \xB7 readings \xB7 no encounters computed
59
- `),d.closed}w(vn,"foldFile");function Fn(e,t){const o=W(t).filter(r=>/^#bound(?::|$)/.test(r));if(o.length){if(o.length!==1||W(t).length!==1||t.some(r=>r.startsWith("--")))throw Error("REFUSE\xB7reference name one reference without view, check or signing options");return dt(V(e).standing)?lt(e,o[0]).then(r=>{process.stdout.write(`SOURCE ${r.reference.source}
60
- `);for(const f of r.semanticStanding.split(`
61
- `).filter(Boolean))process.stdout.write(`TOPOS ${f}
62
- `);for(const f of r.readings)process.stdout.write("CELL "+JSON.stringify(f)+`
63
- `);return process.stdout.write(`AUTHENTICATED standing ${r.semanticIdentity} \xB7 authority ${r.authorityContextIdentity} \xB7 no effects committed
64
- `),d.closed}):ct(o[0],V(e).standing).then(r=>{process.stdout.write(`SOURCE ${r.reference.source}
65
- `);for(const f of r.lines)process.stdout.write(`TOPOS ${f}
66
- `);return process.stdout.write(`INSPECT standing sha256:${r.reference.digest} \xB7 blob ${r.reference.blob} \xB7 no encounters computed \xB7 unauthenticated
67
- `),d.closed})}const n=W(t).filter(r=>J($(r))&&!G($(r)).isDirectory()&&r.endsWith(jt)),i=W(t).filter(r=>J($(r))&&G($(r)).isDirectory());if(n.length===1&&!i.length&&U(t,u.as)===void 0){const r=$(n[0]);return!r.endsWith(`/${Le}`)&&r!==Le?vn(r):ae(ue(r),void 0,t)}const s=i[0],c=n.length?e:$("."),y=s?me(c,$(s)).split(he).join("/"):"";return ae(c,y?`${y}/`:void 0,t)}w(Fn,"foldVerb");async function ae(e,t,o){return Fe(m(e),()=>On(e,t,o),()=>V(e,t).standing)}w(ae,"foldAt");async function On(e,t,o){const n=U(o,u.as),i=n!==void 0&&W(o).some(s=>J($(s))&&!G($(s)).isDirectory());if(n?.split("@")[0]==="reading-identity"&&(i||t||o.includes(u.check)))throw new A("reading-identity/selection","REFUSE\xB7reading-identity/selection preparation does not sign batches or check rendered output");return n?.split("@")[0]==="reading-identity"||n==="release"||n?.split("@")[0]==="act"||n===X.help||i||o.includes(u.check)?qe(e,t,o):ht(s=>mt(V(e,t).standing,[s]),()=>qe(e,t,o))}w(On,"foldRequested");async function qe(e,t,o){const n=U(o,u.as);if(n==="release"){const l=W(o).filter(h=>!(J($(h))&&G($(h)).isDirectory()));if(l.length!==1||o.includes(u.check))throw Error("REFUSE\xB7release name one approval file; check does not authorize delivery");return Ue(()=>(ot(t?$(e,t):e,$(l[0])),d.closed))}const i=W(o).filter(l=>J($(l))&&!G($(l)).isDirectory()),s=n===void 0&&o.includes(u.check);if(n?.split("@")[0]==="walk"){if(o.includes(u.check))throw Error("REFUSE\xB7walk check does not initiate or sign an exchange");if(t||i.length>1)throw Error("REFUSE\xB7walk one place and one authenticated peer inventory per fold");const l=n.split("@")[1];if(l!==void 0&&(!/^(0|[1-9][0-9]*)$/.test(l)||!Number.isSafeInteger(Number(l))))throw Error("REFUSE\xB7walk invalid resolution");const h=i.length?ee(i[0]):[];for(const S of await gn(e,l===void 0?void 0:Number(l),h,U(o,u.key),U(o,u.keyFile),U(o,u.signer)))process.stdout.write(S+`
68
- `);return d.closed}if(n===Ot||n==="computation"){const l=W(o).filter(g=>J($(g))&&!G($(g)).isDirectory());if(l.length>1)throw Error("REFUSE\xB7object one history snapshot per fold");const h=l.length?ee(l[0]):te(m(e)),S=await xe(e,h,g=>(n==="computation"?process.stderr:process.stdout).write(g+`
69
- `)),F=w(async()=>{if(Ne(S.configuration)){const g=new AbortController,b=w(()=>g.abort(),"interrupt");process.once("SIGINT",b);try{return await Ft(e,S.records,S.context,S.configuration,g.signal)}finally{process.removeListener("SIGINT",b)}}return Ie(S.records,S.context)},"project");if(n==="computation"){if(t||o.includes(u.check))throw new A("computation/context","REFUSE\xB7computation/context");const g=w(v=>{const k=S.configuration.filter(P=>P.scope===v&&P.value!=="withdraw");if(k.length!==1)throw new A("computation/context","REFUSE\xB7computation/context");return k[0].value},"one");if(g("view/computation")!=="computation@1")throw new A("computation/context","REFUSE\xB7computation/context");const b=w(v=>{const k=/^0\.\.([1-9][0-9]*)$/.exec(g(v)),P=Number(k?.[1]);if(!k||!Number.isSafeInteger(P))throw new A("computation/budget","REFUSE\xB7computation/budget");return P},"resource"),I=U(o,u.key),B=ge(m(e)),p=se(h,we(e),B.admitted),O=p.admitted.find(v=>v.id===I),C=Math.max(...h.map(v=>Number(L(v,"epoch")||0)));if(!I||!O||kt({scope:"computation",by:I},O,C,"computation","authority").kind!=="admitted")throw new A("computation/authority","REFUSE\xB7computation/authority");const R=new TextEncoder().encode(h.join(`
57
+ `),s("out","PIN "+We([c],E)+`
58
+ `)}for(const d of a.standing)s("out",`${d}
59
+ `);for(const d of a.forks)s("out",`FORK ${d.key}${d.state?` \xB7 ${d.state}`:""}
60
+ `);return s("out",`FACT ${a.standing.length} standing \xB7 ${a.forks.length} forks \xB7 ${At(e)} \xB7 readings \xB7 no encounters computed
61
+ `),l.closed}$(Nn,"foldFile");function Cn(e,t){const a=B(t).filter(r=>/^#(?:bound|topos-reference)(?::|$)/.test(r));if(a.length){if(a.length!==1||B(t).length!==1||t.some(r=>r.startsWith("--")))throw Error("REFUSE\xB7reference name one reference without view, check or signing options");if(mt(z(e).standing)){if(a[0].startsWith("#topos-reference:"))throw Error("REFUSE\xB7reference located profile is inspection only; authenticated opening requires its declared carrier");return ht(e,a[0]).then(r=>{s("out",`SOURCE ${r.reference.source}
62
+ `);for(const u of r.semanticStanding.split(`
63
+ `).filter(Boolean))s("out",`TOPOS ${u}
64
+ `);for(const u of r.readings)s("out","CELL "+JSON.stringify(u)+`
65
+ `);return s("out",`AUTHENTICATED standing ${r.semanticIdentity} \xB7 authority ${r.authorityContextIdentity} \xB7 no effects committed
66
+ `),l.closed})}return ut(a[0],z(e).standing).then(r=>{const u="source"in r.reference?r.reference.source:r.reference.location;if(u&&s("out",`SOURCE ${u}
67
+ `),"needs"in r)return s("out",`NEEDS ${r.needs} \xB7 unauthenticated inspection
68
+ `),l.closed;for(const f of r.lines)s("out",`TOPOS ${f}
69
+ `);return s("out",`INSPECT standing sha256:${r.reference.digest} \xB7 blob ${r.reference.blob} \xB7 no encounters computed \xB7 unauthenticated
70
+ `),l.closed})}const n=B(t).filter(r=>_(b(r))&&!V(b(r)).isDirectory()&&r.endsWith(Wt)),i=B(t).filter(r=>_(b(r))&&V(b(r)).isDirectory());if(n.length===1&&!i.length&&N(t,g.as)===void 0){const r=b(n[0]);return!r.endsWith(`/${Be}`)&&r!==Be?Nn(r):ue(he(r),void 0,t)}const c=i[0],d=n.length?e:b("."),E=c?ge(d,b(c)).split(we).join("/"):"";return ue(d,E?`${E}/`:void 0,t)}$(Cn,"foldVerb");async function ue(e,t,a){return Ue(w(e),()=>Dn(e,t,a),()=>z(e,t).standing)}$(ue,"foldAt");async function Dn(e,t,a){const n=N(a,g.as),i=n!==void 0&&B(a).some(c=>_(b(c))&&!V(b(c)).isDirectory());if(["reading-identity","reading-identities","probe","authority-card"].includes(n?.split("@")[0]??"")&&(i||t||a.includes(g.check)))throw new O("reading-identity/selection","REFUSE\xB7reading-identity/selection preparation does not sign batches or check rendered output");return["reading-identity","reading-identities","probe","authority-card"].includes(n?.split("@")[0]??"")||n==="release"||n?.split("@")[0]==="act"||n===Z.help||i||a.includes(g.check)?He(e,t,a):$t(c=>Et(z(e,t).standing,[c]),()=>He(e,t,a))}$(Dn,"foldRequested");async function He(e,t,a){const n=N(a,g.as);if(n==="release"){const f=B(a).filter(m=>!(_(b(m))&&V(b(m)).isDirectory()));if(f.length!==1||a.includes(g.check))throw Error("REFUSE\xB7release name one approval file; check does not authorize delivery");return Ne(()=>(ft(t?b(e,t):e,b(f[0])),l.closed))}const i=B(a).filter(f=>_(b(f))&&!V(b(f)).isDirectory()),c=n===void 0&&a.includes(g.check);if(n?.split("@")[0]==="walk"){if(a.includes(g.check))throw Error("REFUSE\xB7walk check does not initiate or sign an exchange");if(t||i.length>1)throw Error("REFUSE\xB7walk one place and one authenticated peer inventory per fold");const f=n.split("@")[1];if(f!==void 0&&(!/^(0|[1-9][0-9]*)$/.test(f)||!Number.isSafeInteger(Number(f))))throw Error("REFUSE\xB7walk invalid resolution");const m=i.length?re(i[0]):[];for(const k of await bn(e,f===void 0?void 0:Number(f),m,N(a,g.key),N(a,g.keyFile),N(a,g.signer)))s("out",k+`
71
+ `);return l.closed}if(n===Dt||n==="computation"){const f=B(a).filter(y=>_(b(y))&&!V(b(y)).isDirectory());if(f.length>1)throw Error("REFUSE\xB7object one history snapshot per fold");const m=f.length?re(f[0]):oe(w(e)),k=await Ce(e,m,y=>(n==="computation"?process.stderr:process.stdout).write(y+`
72
+ `)),U=$(async()=>{if(Te(k.configuration)){const y=new AbortController,S=$(()=>y.abort(),"interrupt");process.once("SIGINT",S);try{return await Ct(e,k.records,k.context,k.configuration,y.signal)}finally{process.removeListener("SIGINT",S)}}return De(k.records,k.context)},"project");if(n==="computation"){if(t||a.includes(g.check))throw new O("computation/context","REFUSE\xB7computation/context");const y=$(F=>{const v=k.configuration.filter(J=>J.scope===F&&J.value!=="withdraw");if(v.length!==1)throw new O("computation/context","REFUSE\xB7computation/context");return v[0].value},"one");if(y("view/computation")!=="computation@1")throw new O("computation/context","REFUSE\xB7computation/context");const S=$(F=>{const v=/^0\.\.([1-9][0-9]*)$/.exec(y(F)),J=Number(v?.[1]);if(!v||!Number.isSafeInteger(J))throw new O("computation/budget","REFUSE\xB7computation/budget");return J},"resource"),D=N(a,g.key),q=ye(w(e)),p=ae(m,Ee(e),q.admitted),x=p.admitted.find(F=>F.id===D),I=Math.max(...m.map(F=>Number(W(F,"epoch")||0)));if(!D||!x||Ut({scope:"computation",by:D},x,I,"computation","authority").kind!=="admitted")throw new O("computation/authority","REFUSE\xB7computation/authority");const R=new TextEncoder().encode(m.join(`
70
73
  `)+`
71
- `),M=K(S.configuration.map(v=>Q(v)).join(`
72
- `)),q=new Map;for(const v of new Set(S.records.filter(k=>k.record==="cell").map(k=>k.fields.topos))){q.set("form/"+v,v);const k=Rt(v),P=k.parts.find(H=>H.scope==="wire/topos/context-view")?.value;for(const H of k.parts.filter(_=>_.kind==="check"&&_.view===P))for(const _ of(H.restsOn??"").split("|").filter(Boolean))vt(_),q.set("form-module/"+_,_)}const z=bt(It(),fe("verb"),je(),le()),de=Ne(S.configuration)?["manifest.json","runtime.js","runtime.wasm","guest.js"].map(v=>[v,K(ve(new URL("../../assets/wasm/"+v,import.meta.url)))]):[],a=de.length?K(JSON.stringify([z,de])):z,E=Bt(S.configuration.map(v=>Q(v)),I,U(o,u.signer),U(o,u.keyFile)),N={maxBytes:b("computation/bytes"),timeoutMs:b("computation/milliseconds")},x={contract:g("computation/contract"),numericPolicy:g("computation/numeric-policy"),reading:{instrument:z,implementation:a,policy:M,inputs:[...q],environment:$t(K)},keyId:I,algorithm:B.era},T=await Et(x,R,{digest:K,evaluate:w(async()=>new TextEncoder().encode(JSON.stringify(await F())+`
73
- `),"evaluate"),sign:E,verify:w(async(v,k,P)=>k.keyId===I&&St(v,O.publicKey,k.signature,[P]),"verify")},N);return process.stdout.write(JSON.stringify({profile:"bound-computation-delivery@1",context:x,input:new TextDecoder().decode(R),statement:T.statement,output:new TextDecoder().decode(T.output)})+`
74
- `),d.closed}const D=await F();for(const g of D)process.stdout.write("CELL "+JSON.stringify(g)+`
75
- `);return process.stdout.write(`FACT object fold ${D.length} cells
76
- `),d.closed}const c=U(o,u.key);if(n===void 0){const l=await on(e,be(e),t,o.includes(u.check));if(s||l!==0)return l;const h=te(m(e)),{objectHistory:S}=await import("../vendor/library11.js"),F=S(h);if(F.kind!=="fact")throw Error(`REFUSE\xB7wire ${F.why}`);if(F.value.objects.length){const D=[...re(h).values()].find(g=>!g.shape&&g.regions.some(b=>b.name==="cells"));if(!D)throw Error("REFUSE\xB7view object cells require a signed cells view");return Y(e,t,D.name,[],void 0,void 0,!1)}return l}const y=i,r=W(o).find(l=>l!==t?.replace(/\/$/,"")&&!l.startsWith("-")&&!(J($(l))&&G($(l)).isDirectory()));if(n==="act"){if(W(o).length!==1)throw Error("REFUSE\xB7act name one committed identity");return Y(e,t,n,[],r)}if((n==="why"||n===X.because||n.split("@")[0]==="why")&&r!==void 0)return Y(e,t,n===X.because?"why":n,[],r,c);if(!y.length)return Y(e,t,n,[],void 0,c);const f=await Ve(e,o,y);return f.kind==="exit"?f.code:(f.kind==="once"&&process.stdout.write(`ONCE ${f.proposed.length} lines \xB7 every one already landed: the view folds the tree as it stands
77
- `),Ue(()=>Y(e,t,n,f.kind==="signed"?f.signed:f.proposed,void 0,c)))}w(qe,"foldResolved");const ze={fold:w((e,t)=>Fn(e,t),"fold"),land:w((e,t)=>Rn(e,t),"land"),sign:w((e,t)=>kn(e,t),"sign")};function Un(e){for(let s=0;s<e.length;s+=1){const c=e[s];if(c.startsWith("--")){if(!Object.values(u).includes(c))return process.stderr.write(`${j()}: REFUSE\xB7flag unknown option ${c}
78
- `),d.usage;if(c!==u.check){if(e[s+1]===void 0||e[s+1].startsWith("--"))return process.stderr.write(`${j()}: REFUSE\xB7flag ${c} needs a value
79
- `),d.usage;s+=1}}}const t=e[0]??"",o=t in ze?ze[t]:void 0,n=W(o===void 0?e:e.slice(1)).filter(s=>J($(s))&&G($(s)).isDirectory());if(o!==void 0){const s=e.slice(1),c=mn(s).filter(l=>{const h=$(s[l]);return J(h)&&G(h).isDirectory()});if(c.length>1)return process.stderr.write(`${j()}: REFUSE\xB7root name one acting directory
80
- `),d.usage;const y=c[0],r=$(y===void 0?".":s[y]),f=y===void 0?s:s.filter((l,h)=>h!==y);return Fe(m(r),()=>t==="fold"&&y!==void 0&&!W(f).some(l=>/^#bound(?::|$)/.test(l))?ae(r,void 0,f):o(r,f,[t,...f]),()=>V(r).standing)}const i=e[0]??"";if(i&&!i.startsWith("-")&&n.includes(i)){const s=$("."),c=me(s,$(i)).split(he).join("/");return ae(s,c?`${c}/`:void 0,e)}return process.stderr.write(`${j()}: ${Ge().join(" \xB7 ")}
81
- `),d.usage}w(Un,"main");function He(e){try{const t=ve(new URL("../../docs/contracts/refusals.bound",import.meta.url),"utf8"),o=it(e,rt(t));process.stderr.write(JSON.stringify({profile:"bound-refusal@1",...o,catalog:K(t)})+`
82
- `)}catch{process.stderr.write(JSON.stringify({profile:"bound-refusal@1",code:"catalog/invalid",unmeasured:["category","meaning","next","catalog"]})+`
83
- `)}}w(He,"printRefusal");function Ke(e){(e===d.refuse||e===d.usage)&&He(new A(e===d.usage?"operation/usage":"operation/failed","")),process.exitCode=e}w(Ke,"finished");const Xe=w(e=>{const t=e instanceof Error?e.message:String(e);process.stderr.write(`${j()}: ${t.startsWith("REFUSE\xB7")?t:`REFUSE\xB7crash ${t}`}
84
- `),He(e instanceof A?e:new A("operation/failed",t)),process.exitCode=d.refuse},"refused");cn();try{const e=Un(process.argv.slice(2));e instanceof Promise?e.then(Ke).catch(Xe):Ke(e)}catch(e){Xe(e)}
74
+ `),P=Q(k.configuration.map(F=>ne(F)).join(`
75
+ `)),G=new Map;for(const F of new Set(k.records.filter(v=>v.record==="cell").map(v=>v.fields.topos))){G.set("form/"+F,F);const v=xt(F),J=v.parts.find(K=>K.scope==="wire/topos/context-view")?.value;for(const K of v.parts.filter(M=>M.kind==="check"&&M.view===J))for(const M of(K.restsOn??"").split("|").filter(Boolean))Nt(M),G.set("form-module/"+M,M)}const H=Ot(It(),Y("verb"),Ie(),X()),pe=Te(k.configuration)?["manifest.json","runtime.js","runtime.wasm","guest.js"].map(F=>[F,Q(Oe(new URL("../../assets/wasm/"+F,import.meta.url)))]):[],o=pe.length?Q(JSON.stringify([H,pe])):H,h=Vt(k.configuration.map(F=>ne(F)),D,N(a,g.signer),N(a,g.keyFile)),T={maxBytes:S("computation/bytes"),timeoutMs:S("computation/milliseconds")},C={contract:y("computation/contract"),numericPolicy:y("computation/numeric-policy"),reading:{instrument:H,implementation:o,policy:P,inputs:[...G],environment:Rt(Q)},keyId:D,algorithm:q.era},j=await vt(C,R,{digest:Q,evaluate:$(async()=>new TextEncoder().encode(JSON.stringify(await U())+`
76
+ `),"evaluate"),sign:h,verify:$(async(F,v,J)=>v.keyId===D&&Ft(F,x.publicKey,v.signature,[J]),"verify")},T);return s("out",JSON.stringify({profile:"bound-computation-delivery@1",context:C,input:new TextDecoder().decode(R),statement:j.statement,output:new TextDecoder().decode(j.output)})+`
77
+ `),l.closed}const L=await U();for(const y of L)s("out","CELL "+JSON.stringify(y)+`
78
+ `);return s("out",`FACT object fold ${L.length} cells
79
+ `),l.closed}const d=N(a,g.key);if(n===void 0){const f=await fn(e,ve(e),t,a.includes(g.check));if(c||f!==0)return f;const m=oe(w(e)),{objectHistory:k}=await import("../vendor/library14.js"),U=k(m);if(U.kind!=="fact")throw Error(`REFUSE\xB7wire ${U.why}`);if(U.value.objects.length){const L=[...le(m).values()].find(y=>!y.shape&&y.regions.some(S=>S.name==="cells"));if(!L)throw Error("REFUSE\xB7view object cells require a signed cells view");return ee(e,t,L.name,[],void 0,void 0,!1)}return f}const E=i,r=B(a).find(f=>f!==t?.replace(/\/$/,"")&&!f.startsWith("-")&&!(_(b(f))&&V(b(f)).isDirectory()));if(n==="act"){if(B(a).length!==1)throw Error("REFUSE\xB7act name one committed identity");return ee(e,t,n,[],r)}if((n==="why"||n===Z.because||n.split("@")[0]==="why")&&r!==void 0)return ee(e,t,n===Z.because?"why":n,[],r,d);if(!E.length)return ee(e,t,n,[],void 0,d);const u=await Ge(e,a,E);return u.kind==="exit"?u.code:(u.kind==="once"&&s("out",`ONCE ${u.proposed.length} lines \xB7 every one already landed: the view folds the tree as it stands
80
+ `),Ne(()=>ee(e,t,n,u.kind==="signed"?u.signed:u.proposed,void 0,d)))}$(He,"foldResolved");const Ke={fold:$((e,t)=>Cn(e,t),"fold"),land:$((e,t)=>xn(e,t),"land"),sign:$((e,t)=>Un(e,t),"sign")};function Tn(e){for(let c=0;c<e.length;c+=1){const d=e[c];if(d.startsWith("--")){if(!Object.values(g).includes(d))return s("error",`${A()}: REFUSE\xB7flag unknown option ${d}
81
+ `),l.usage;if(d!==g.check){if(e[c+1]===void 0||e[c+1].startsWith("--"))return s("error",`${A()}: REFUSE\xB7flag ${d} needs a value
82
+ `),l.usage;c+=1}}}const t=e[0]??"",a=t in Ke?Ke[t]:void 0,n=B(a===void 0?e:e.slice(1)).filter(c=>_(b(c))&&V(b(c)).isDirectory());if(a!==void 0){const c=e.slice(1),d=En(c).filter(f=>{const m=b(c[f]);return _(m)&&V(m).isDirectory()});if(d.length>1)return s("error",`${A()}: REFUSE\xB7root name one acting directory
83
+ `),l.usage;const E=d[0],r=b(E===void 0?".":c[E]),u=E===void 0?c:c.filter((f,m)=>m!==E);return Ue(w(r),()=>t==="fold"&&E!==void 0&&!B(u).some(f=>/^#bound(?::|$)/.test(f))?ue(r,void 0,u):a(r,u,[t,...u]),()=>z(r).standing)}const i=e[0]??"";if(i&&!i.startsWith("-")&&n.includes(i)){const c=b("."),d=ge(c,b(i)).split(we).join("/");return ue(c,d?`${d}/`:void 0,e)}return s("error",`${A()}: ${ze().join(" \xB7 ")}
84
+ `),l.usage}$(Tn,"main");function Xe(e){let t="";try{t=Oe(new URL("../../docs/contracts/refusals.bound",import.meta.url),"utf8")}catch{}s("error",JSON.stringify(dt(e,t,Q))+`
85
+ `)}$(Xe,"printRefusal");function jn(e){return(e===l.refuse||e===l.usage)&&Xe(new O(e===l.usage?"operation/usage":"operation/failed","")),e}$(jn,"completed");async function Ye(e){try{return jn(await Tn(e))}catch(t){const a=t instanceof Error?t.message:String(t);return s("error",`${A()}: ${a.startsWith("REFUSE\xB7")?a:`REFUSE\xB7crash ${a}`}
86
+ `),Xe(t instanceof O?t:new O("operation/failed",a)),l.refuse}}$(Ye,"runNativeCommand"),process.send&&process.argv.length===2?it(Ye):(un(),Ye(process.argv.slice(2)).then(e=>{process.exitCode=e}));