@lapxo/bound 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/CITATION.cff +1 -1
  2. package/README.md +20 -3
  3. package/TARGET.bound +75 -42
  4. package/dist/cli/accept.js +59 -70
  5. package/dist/cli/act-result.js +3 -3
  6. package/dist/cli/args.js +1 -1
  7. package/dist/cli/host.js +1 -1
  8. package/dist/cli/native.js +1 -1
  9. package/dist/cli/pass.js +22 -21
  10. package/dist/cli/place.js +6 -6
  11. package/dist/cli/release-result.js +3 -3
  12. package/dist/cli/retained-judgment.js +1 -1
  13. package/dist/cli/standing-result.js +3 -3
  14. package/dist/cli/takes.js +10 -10
  15. package/dist/cli/verb.js +79 -77
  16. package/dist/engine/computation.js +1 -1
  17. package/dist/engine/index.js +1 -1
  18. package/dist/engine/object.js +1 -1
  19. package/dist/engine/ports.js +1 -1
  20. package/dist/fold/admission-history.js +1 -1
  21. package/dist/fold/ceilings.js +1 -1
  22. package/dist/fold/claims.js +2 -2
  23. package/dist/fold/closed.js +1 -1
  24. package/dist/fold/configures.js +1 -1
  25. package/dist/fold/digests.js +10 -10
  26. package/dist/fold/evidence.js +1 -1
  27. package/dist/fold/keys.js +3 -3
  28. package/dist/fold/laid.js +1 -1
  29. package/dist/fold/observed.js +27 -26
  30. package/dist/fold/opened.js +1 -1
  31. package/dist/fold/own.js +3 -3
  32. package/dist/fold/paid.js +1 -1
  33. package/dist/fold/place-inputs.js +1 -1
  34. package/dist/fold/places.js +1 -1
  35. package/dist/fold/reach.js +1 -1
  36. package/dist/fold/readers.js +1 -1
  37. package/dist/fold/region.js +1 -1
  38. package/dist/fold/release-policy.js +1 -1
  39. package/dist/fold/resolved.js +1 -1
  40. package/dist/fold/roles.js +1 -1
  41. package/dist/fold/shards.js +8 -8
  42. package/dist/fold/signed.js +3 -3
  43. package/dist/fold/signers.js +1 -1
  44. package/dist/fold/stranger.js +6 -6
  45. package/dist/fold/wire.js +1 -1
  46. package/dist/fold/zoom.js +1 -1
  47. package/dist/host/act-cost.js +1 -1
  48. package/dist/host/adapters/keys/ed25519.js +1 -1
  49. package/dist/host/adapters/transport/http.js +1 -1
  50. package/dist/host/admitted-place.js +1 -1
  51. package/dist/host/call-context.js +1 -1
  52. package/dist/host/capsule-process.js +1 -1
  53. package/dist/host/capsule.js +1 -1
  54. package/dist/host/cell-receipts.js +1 -1
  55. package/dist/host/command-server.js +4 -0
  56. package/dist/host/content-store.js +1 -1
  57. package/dist/host/contextual-place.js +1 -1
  58. package/dist/host/digest.js +1 -1
  59. package/dist/host/host-controls.js +1 -1
  60. package/dist/host/in-process-act.js +1 -1
  61. package/dist/host/in-process-context.js +1 -1
  62. package/dist/host/in-process-root.js +1 -1
  63. package/dist/host/in-process.js +1 -1
  64. package/dist/host/index.d.ts +1 -1
  65. package/dist/host/index.js +1 -1
  66. package/dist/host/located.js +6 -6
  67. package/dist/host/native/authority-card-view.js +5 -0
  68. package/dist/host/native/authority-card.js +1 -0
  69. package/dist/host/native/command.js +1 -1
  70. package/dist/host/native/custody.js +1 -1
  71. package/dist/host/native/generated-custodian.js +1 -1
  72. package/dist/host/native/installed-package.d.ts +1 -0
  73. package/dist/host/native/installed-package.js +5 -0
  74. package/dist/host/native/module-delivery.d.ts +1 -1
  75. package/dist/host/native/module-delivery.js +1 -1
  76. package/dist/host/native/module-inventory.js +2 -0
  77. package/dist/host/native/module-syntax.js +1 -1
  78. package/dist/host/native/native-binary.js +1 -1
  79. package/dist/host/native/probes.js +1 -0
  80. package/dist/host/native/reading-witness-admission.js +5 -0
  81. package/dist/host/native/reading.js +1 -1
  82. package/dist/host/native/route.js +1 -1
  83. package/dist/host/native-place-state.js +1 -0
  84. package/dist/host/native-receiver.js +1 -1
  85. package/dist/host/objects.js +1 -1
  86. package/dist/host/persistent-host.js +1 -0
  87. package/dist/host/physical-lines.d.ts +1 -0
  88. package/dist/host/physical-lines.js +1 -0
  89. package/dist/host/place-act-transaction.js +1 -1
  90. package/dist/host/place-clock-selection.js +1 -1
  91. package/dist/host/ports/local-act.js +1 -1
  92. package/dist/host/ports/place-act.js +1 -1
  93. package/dist/host/ports/store.js +1 -1
  94. package/dist/host/ports/transport.js +1 -1
  95. package/dist/host/profile-composition.d.ts +1 -0
  96. package/dist/host/profile-composition.js +2 -0
  97. package/dist/host/reading-closures.js +6 -6
  98. package/dist/host/reading-context.js +1 -1
  99. package/dist/host/reading-identity.js +2 -2
  100. package/dist/host/reading-preparation.js +1 -1
  101. package/dist/host/reference-authenticated.d.ts +1 -1
  102. package/dist/host/reference-authenticated.js +1 -1
  103. package/dist/host/reference-export.js +1 -1
  104. package/dist/host/reference-native-api.d.ts +1 -1
  105. package/dist/host/reference-native-api.js +1 -1
  106. package/dist/host/reference-native.js +1 -1
  107. package/dist/host/reference-standing.js +1 -1
  108. package/dist/host/reference.js +1 -1
  109. package/dist/host/refusals.js +2 -2
  110. package/dist/host/release.js +1 -1
  111. package/dist/host/root-clock-source.js +1 -1
  112. package/dist/host/selected-capsules.js +1 -1
  113. package/dist/host/selected-topos.js +1 -1
  114. package/dist/host/signing.js +2 -2
  115. package/dist/host/source-content.js +1 -1
  116. package/dist/host/standing-carrier.js +1 -1
  117. package/dist/host/standing-projection.js +1 -1
  118. package/dist/host/timing.js +1 -1
  119. package/dist/host/walk.js +1 -1
  120. package/dist/host/work-trace.js +1 -0
  121. package/dist/judge/late.js +1 -1
  122. package/dist/judge/take.js +1 -1
  123. package/dist/judge/widening.js +1 -1
  124. package/dist/land/act.js +6 -6
  125. package/dist/land/alias.js +1 -1
  126. package/dist/land/held.js +1 -1
  127. package/dist/land/ledger.js +5 -6
  128. package/dist/land/sign.js +1 -1
  129. package/dist/land/standing-pin.js +1 -1
  130. package/dist/land/vouched.js +1 -1
  131. package/dist/land/withdraw.js +1 -1
  132. package/dist/observe/files.js +1 -1
  133. package/dist/observe/identity.js +1 -1
  134. package/dist/observe/match.js +1 -1
  135. package/dist/observe/regions.js +1 -1
  136. package/dist/observe/run.js +1 -2
  137. package/dist/observe/runner.js +1 -1
  138. package/dist/public-types.d.ts +945 -40
  139. package/dist/render/capsule.js +1 -1
  140. package/dist/render/field.js +1 -1
  141. package/dist/render/open.js +1 -1
  142. package/dist/render/page.js +1 -1
  143. package/dist/render/receipt-projection.js +1 -0
  144. package/dist/render/receipts.js +1 -1
  145. package/dist/render/shape.js +1 -1
  146. package/dist/render/target.js +4 -4
  147. package/dist/render/view.js +5 -5
  148. package/dist/vendor/bundle.json +1 -1
  149. package/dist/vendor/library14.js +1 -0
  150. package/dist/vendor/runtime.js +53 -30
  151. package/dist/wasm/adapter.d.ts +1 -1
  152. package/docs/contracts/authenticated-reference.publication.json +1 -1
  153. package/docs/contracts/authority-preflight.md +17 -0
  154. package/docs/contracts/authority-preflight.publication.json +25 -0
  155. package/docs/contracts/installed-package.md +21 -0
  156. package/docs/contracts/installed-package.publication.json +25 -0
  157. package/docs/contracts/materialized-leaf-sequence.md +15 -0
  158. package/docs/contracts/materialized-leaf-sequence.publication.json +25 -0
  159. package/docs/contracts/module-inventory.md +15 -0
  160. package/docs/contracts/module-inventory.publication.json +25 -0
  161. package/docs/contracts/native-host.md +29 -1
  162. package/docs/contracts/native-host.publication.json +4 -4
  163. package/docs/contracts/native-probes.md +13 -0
  164. package/docs/contracts/native-probes.publication.json +25 -0
  165. package/docs/contracts/native-publication.inventory.json +9 -1
  166. package/docs/contracts/native-view-batch.md +17 -0
  167. package/docs/contracts/native-view-batch.publication.json +25 -0
  168. package/docs/contracts/physical-lines.md +19 -0
  169. package/docs/contracts/physical-lines.publication.json +25 -0
  170. package/docs/contracts/profile-composition.md +17 -0
  171. package/docs/contracts/profile-composition.publication.json +25 -0
  172. package/docs/contracts/profile-preparation-native-meaning.md +9 -0
  173. package/docs/contracts/publication.md +12 -0
  174. package/docs/contracts/reading-identity.md +26 -2
  175. package/docs/contracts/reading-identity.publication.json +4 -4
  176. package/docs/contracts/reading-witness-admission.md +49 -0
  177. package/docs/contracts/readme.publication.json +1 -1
  178. package/docs/contracts/reference-port.md +11 -0
  179. package/docs/contracts/reference-port.publication.json +1 -1
  180. package/docs/contracts/refusals.bound +346 -145
  181. package/docs/contracts/refusals.md +119 -54
  182. package/docs/contracts/refusals.publication.json +2 -2
  183. package/docs/reference.md +8 -0
  184. package/licenses/wasm/{fast-text-encoding.txt → NOTICE.txt} +111 -0
  185. package/package.json +69 -8
  186. package/receipts.bound +12921 -11722
  187. package/samples/authority-preflight/no.json +6 -0
  188. package/samples/authority-preflight/yes.json +30 -0
  189. package/samples/engine-alphabet/reader.js +3 -1457
  190. package/samples/engine-alphabet/receipts.bound +7 -7
  191. package/samples/engine-interval/reader.js +3 -1457
  192. package/samples/engine-interval/receipts.bound +7 -7
  193. package/samples/installed-package/consumer.mjs +29 -0
  194. package/samples/installed-package/fixture.json +48 -0
  195. package/samples/installed-package/no.json +10 -0
  196. package/samples/installed-package/yes.json +52 -0
  197. package/samples/materialized-leaf-sequence/no.json +11 -0
  198. package/samples/materialized-leaf-sequence/yes.json +10 -0
  199. package/samples/module-inventory/yes.json +28 -0
  200. package/samples/native/physical-line-reader.mjs +1 -0
  201. package/samples/native/physical-line-reader.source.mjs +13 -0
  202. package/samples/native-host/no.json +6 -1
  203. package/samples/native-host/yes.json +18 -1
  204. package/samples/native-probes/inputs/inspection.json +28 -0
  205. package/samples/native-probes/no.json +7 -0
  206. package/samples/native-probes/yes.json +28 -0
  207. package/samples/native-view-batch/no.json +14 -0
  208. package/samples/native-view-batch/yes.json +10 -0
  209. package/samples/no/engine-order/reader.js +3 -1457
  210. package/samples/no/module-inventory/no.json +10 -0
  211. package/samples/physical-lines/no.json +5 -0
  212. package/samples/physical-lines/yes.json +9 -0
  213. package/samples/profile-composition/no.json +6 -0
  214. package/samples/profile-composition/yes.json +14 -0
  215. package/samples/reading-identity/no.json +7 -1
  216. package/samples/reading-identity/yes.json +24 -1
  217. package/vectors/native/authority-preflight.vector.json +55 -0
  218. package/vectors/native/installed-package.vector.json +31 -0
  219. package/vectors/native/materialized-leaf-sequence.vector.json +31 -0
  220. package/vectors/native/module-inventory.vector.json +56 -0
  221. package/vectors/native/native-host.vector.json +214 -0
  222. package/vectors/native/native-probes.vector.json +31 -0
  223. package/vectors/native/native-view-batch.vector.json +31 -0
  224. package/vectors/native/physical-lines.vector.json +105 -0
  225. package/vectors/native/profile-composition.vector.json +53 -0
  226. package/vectors/native/reading-identity.vector.json +38 -0
  227. package/vectors/native/refusals.vector.json +36 -2
  228. package/dist/vendor/library11.js +0 -1
  229. package/dist/vendor/sources.json +0 -1
  230. package/licenses/wasm/bound.txt +0 -21
  231. package/licenses/wasm/jitl-quickjs-ffi-types.txt +0 -21
  232. package/licenses/wasm/jitl-quickjs-wasmfile-release-sync.txt +0 -47
  233. package/licenses/wasm/obligations.txt +0 -21
  234. package/licenses/wasm/quickjs-emscripten-core.txt +0 -21
  235. package/licenses/wasm/topos.txt +0 -21
  236. /package/dist/vendor/{50086958553b9376d600583f7dff354196bfeb41170fc6d1482ca7bea7c493e2.LICENSE → 28cba430228db1c04f446c93f81b09a2705d6bf3e222d35adbe5a4cee4061884.LICENSE} +0 -0
  237. /package/dist/vendor/{b3e938d28f88a1851af303a40c749e12ebd5a686daac4f0b343b5cdd2e040419.LICENSE → 7aca161279d14bc0e054dcc281cd110aeb95be2e026b42fdf527a260e58b2aae.LICENSE} +0 -0
@@ -1,72 +1,61 @@
1
- var _e=Object.defineProperty;var F=(n,r)=>_e(n,"name",{value:r,configurable:!0});import{BoundRefusal as $e}from"../host/refusals.js";import{assertHostNotCancelled as oe}from"../host/host-controls.js";import{library11_authorityAtEpoch as He}from"../vendor/runtime.js";import{requireEffects as qe}from"../host/read-only.js";import{hostOutput as o}from"../host/call-context.js";import{assertProspectiveRootClockSelection as ke}from"../host/root-clock-source.js";import{hasContextualPlace as ze,landContextualPlace as Ve}from"../host/contextual-place.js";import{commitLocalAct as Je,intactLocalAct as Xe,committedLocalActs as Qe}from"../host/ports/local-act.js";import{withoutEffects as Ye}from"../host/read-only.js";import{admittedLine as Ze}from"../host/selected-topos.js";import{timing as en}from"../host/timing.js";import{admittedObjects as le}from"../host/objects.js";import{existsSync as ye,rmdirSync as nn,rmSync as tn}from"node:fs";import{dirname as Ee,join as H,basename as rn}from"node:path";import{closeReceipts as on,instrumentKeep as sn,instrumentKept as an}from"../fold/closed.js";import{bytesDigest as ve,fullDigest as Y,instrumentOf as dn,signaturesOf as I}from"../fold/digests.js";import{library11_canonical as be,library11_LOCK as fe,library11_parse as Se,library11_actIdentity as cn,library11_actResultProfile as Re}from"../vendor/runtime.js";import{fieldOf as t,isConfig as q,foldClaims as Fe,sayingOf as D,selfName as k}from"../fold/claims.js";import{isReaderLock as ln}from"../fold/observed.js";import{authorityFor as Z,publicKeyOf as xe,rootSigner as ee,writerFor as ie}from"../fold/signers.js";import{lockLines as C,lockStanding as z}from"../fold/keys.js";import{keepVerdict as fn,keptVerdict as un,land as se,landBlob as hn,ledgerLines as mn,storeOf as N}from"../land/ledger.js";import{signConsentLot as pn,verifiesOwnerLine as gn}from"../land/sign.js";import{signerFor as wn}from"../host/signing.js";import{appliedIn as $n,ownLockOf as kn}from"../fold/signed.js";import{wordOf as V}from"../fold/wire.js";import{hasVouchedTree as yn,landCoordinates as En,locationsOf as vn,vouchedCoordinates as bn}from"../land/vouched.js";import{entriesIn as Sn,observeFile as Rn}from"../observe/files.js";import{coneOf as Fn,standingOf as ue}from"./place.js";import{ownLock as xn,ownRoot as jn}from"../observe/runner.js";import{widenedWithoutWitness as On}from"../judge/widening.js";import{retractedTogether as Un,withdrawal as An}from"../land/withdraw.js";import{isCeiling as ae}from"../fold/configures.js";import{inertIn as Dn}from"../land/inert.js";import{landSaid as je}from"./pass.js";import{underTheLock as Ln,underTheRegions as Tn,underAuthorityRegions as Cn,underRootProjection as In}from"../land/act.js";import{openedBy as Nn}from"../fold/opened.js";import{touchedBy as Mn}from"../fold/reach.js";import{landOwned as Wn,ownedOf as Oe}from"../land/owned.js";import{layReleases as Pn}from"../host/release.js";import{foundableIn as Bn,placesIn as he}from"../fold/places.js";import{outsideTheirCapsule as Kn}from"../fold/own.js";import{lateFacts as Ue}from"../judge/late.js";import{paidOf as me}from"../fold/paid.js";import{aliasPinned as Gn}from"../land/alias.js";import{admitStandingPins as _n}from"../land/standing-pin.js";import{coordinatesWithdrawn as Hn}from"../land/leaving.js";import{ownerOf as qn,epochOf as Ae,localActLines as De,forksItself as zn,forksJoinedBy as Vn,renderInto as Le,sideOf as Jn,signedDemands as Xn,signedOwnerLines as J}from"./owner.js";import{claimLinesIn as pe,entryOf as Te,namedPlaces as ne,placesOfFile as Ce,positionalsOf as ge,valueOf as X}from"./args.js";import{FLAGS as Q}from"./names.js";import{judgeDemand as Ie,landTake as we}from"./takes.js";function Ne(n,r,c){return Ye(()=>{const i=N(n);ke(n,r);const S=!r.some(ln)&&r.some(ae),y=S?Fn(n,Te(n),r.filter(ae)):{standing:c,observed:[],own:{},kept:!0};if(Dn(r,{standing:y.standing,ceiling:ae,signsReader:!S,observed:y.observed,own:y.own,epoch:Ae([...C(i),...r])}).length)throw Error("REFUSE\xB7inert no existing reading meets these ceilings; fold the declared inputs first");const m=Hn(n,i,r,[...r,...c]);if(m.refused.length)throw Error(`REFUSE\xB7withdraw a file is still read: ${m.refused.map(d=>`${d.path} by ${d.by}`).join(" \xB7 ")}`);const l=`${V(c,"families","view")}/`,g=r.filter(d=>q(d)&&t(d,"role")==="demands"&&t(d,"value")!=="withdraw"&&!t(d,"scope").startsWith(l)).map(d=>{const h=t(d,"scope");return c.some($=>q($)&&t($,"role")==="demands"&&t($,"value")!=="withdraw"&&t($,"scope")===h&&t($,"form")===t(d,"form")&&t($,"measure")===t(d,"measure"))?Ie(n,d):{kind:"owed",scope:h,why:"new demand declared; no conformance reading is claimed"}}),f=g.filter(d=>d.kind==="refused"||d.kind==="judged"&&d.verdict.kind==="refuse");if(f.length)throw Error(`REFUSE\xB7takes ${f.map(d=>`${d.scope}: ${d.kind==="judged"?d.verdict.why:d.kind==="refused"?d.why:""}`).join(" \xB7 ")}`);return{coordinates:m,judged:g,fold:y}})}F(Ne,"admissionEvidence");function Qn(n,r){const c=On(n,r,ae,V(r,"at-classes","witness"));if(c.length){for(const i of c)o("error",`WIDER ${t(i,"scope")} \xB7 ${t(i,"value")}
2
- `);return o("error",`${k()}: REFUSE\xB7widening nothing landed \xB7 a ceiling that admits more than it did gives back freedom the lock had spent: sign it under a witness that names what made the old ceiling wrong
3
- `),!0}return!1}F(Qn,"refusesWidening");function Me(n,r,c){if(Qn(r,c))return!0;const i=N(n),S=Kn(n,c,r);for(const m of S)o("error",`OUTSIDE ${t(m,"scope")} \xB7 ${t(m,"value")}
4
- `);if(S.length)return o("error",`${k()}: REFUSE\xB7outside nothing landed \xB7 a reader or a capsule lands in the capsule of its world, never in the wire or the instrument
5
- `),!0;const y=Vn(i,r).filter(m=>zn(m.lines)||m.lines.filter(l=>r.includes(l)).length>1);if(y.length){for(const m of y){o("error",`FORK ${m.key}
6
- `);for(const l of m.lines)o("error",` ${r.includes(l)?"new ":"held"} by=${t(l,"by")} ${Jn(l,C(i))}
7
- `)}return o("error",`${k()}: REFUSE\xB7fork nothing landed \xB7 one signer never forks itself, and one act never forks itself: withdraw the held side in this batch, or sign the other reading under its own scope
8
- `),!0}const w=Gn(n,r);if(w.length){for(const m of w)o("error",`ALIAS ${m.scope} \xB7 ${m.digest} \xB7 ${m.by.join(" ")}
9
- `);return o("error",`${k()}: REFUSE\xB7alias nothing landed \xB7 an alias is withdrawn only when no pin names its digest
10
- `),!0}return!1}F(Me,"refusesAdmission");function We(n,r){try{return _n(n,r),!1}catch(c){return o("error",`${k()}: ${c instanceof Error?c.message:String(c)}
11
- `),!0}}F(We,"refusesStandingPins");async function Pe(n,r,c,i){const S=i?[[[],i.records]]:c.map(e=>[Ce(e),pe(e)]),y=S.flatMap(([,e])=>e);if(!y.length)return o("error",`${k()}: a batch is a file with claim lines
12
- `),{kind:"exit",code:2};const w=y.filter(e=>!t(e,"sig")),m=w.filter(e=>t(e,"epoch")||!["","target"].includes(t(e,"by")));if(m.length){for(const e of m)o("error",`BARE ${t(e,"scope")} \xB7 by=${t(e,"by")||"\u2205"}${t(e,"epoch")?` epoch=${t(e,"epoch")}`:""}
13
- `);return o("error",`${k()}: REFUSE\xB7bare nothing landed \xB7 ${m.length} lines name a signer or an epoch they were not signed with: a drafted line proposes by=target and sign signs it, a line a lane signed carries its sig
14
- `),{kind:"exit",code:1}}const l=N(n),g=[...new Set([...ne(r),...S.flatMap(([e])=>e)])],f=z(l),d=g.filter(e=>!he(n).includes(e)&&!Bn(n,f,V(f,"families","region"),e));if(d.length)return o("error",`${k()}: REFUSE\xB7place nothing landed \xB7 ${d.join(", ")} is no place of the tree, and no line of the root founds it: --place names the own lock a line lands in
15
- `),{kind:"exit",code:2};const h=De(n,g),L={digest:Y(l,h),places:g},$=Ae(h)+1,x=y.filter(e=>t(e,"sig")).flatMap(e=>((p,b)=>b===void 0||!gn(e,b,I(l).admitted)?[`${t(e,"scope")} \xB7 the signature does not hold for ${p||"\u2205"}`]:[])(t(e,"by"),xe(n,t(e,"by"))));if(x.length){for(const e of x)o("error",`SIGNED ${e}
16
- `);return o("error",`${k()}: REFUSE\xB7signed nothing landed \xB7 ${x.length} lines a lane signed stand at no epoch this act
17
- `),{kind:"exit",code:1}}const[s,T]=[ne(r),he(n)],M=new Set(C(l).map(D)),v=new Map(T.map(e=>[e,new Set($n(n,e).map(D))])),U=Z(C(l),ee(n),I(l).admitted),de=F(e=>!!t(e,"sig")&&U.of(e).kind==="admitted"&&mn(l,t(e,"by")).includes(e),"delivered"),te=F((e,p=s.length?s:S.flatMap(([b,j])=>j.includes(e)?b:[]))=>p.length?p.every(b=>v.get(b)?.has(D(e))):de(e)||M.has(D(e))||T.some(b=>v.get(b)?.has(D(e))),"held");if(y.every(e=>te(e))){if(y.some(e=>!q(e)))try{await le(n,[...J(l),...y])}catch(e){return o("error",`${k()}: ${String(e)} \xB7 nothing landed
18
- `),{kind:"exit",code:1}}return{kind:"once",proposed:y}}const K=y.filter(e=>t(e,"sig")&&q(e)&&Number(t(e,"epoch"))!==$);if(K.length){for(const e of K)o("error",`SIGNED ${t(e,"scope")} \xB7 signed by ${t(e,"by")} at epoch ${t(e,"epoch")}, and this act lands at ${$}: sign it again
19
- `);return o("error",`${k()}: REFUSE\xB7signed nothing landed \xB7 ${K.length} lines a lane signed stand at no epoch this act
20
- `),{kind:"exit",code:1}}const re=i?void 0:X(r,Q.keyFile),A=i?.keyId??X(r,Q.key)??qn(l),G=w.length?xe(n,A):void 0;if(w.length&&!G)return o("error",`${k()}: unknown key ${A} \u2014 name it in ${k()}.keys
21
- `),{kind:"exit",code:2};let O=y.filter(e=>t(e,"sig"));if(i&&w.length){oe(i.signal);const e=Z(C(l),ee(n),I(l).admitted).admitted.find(p=>p.id===A);for(const p of w){const b=Se(p);if(b.kind!=="fact"||!e||He({...b.value.fields,by:A,epoch:String($)},e,$,t(p,"scope"),"authority").kind!=="admitted")throw new $e("host/receiver-authority","REFUSE\xB7host/receiver-authority")}}if(w.length){let e;try{e=wn([...z(l),...g.flatMap(j=>kn(n,j))],A,i?.signer.name??X(r,Q.signer),re,i?.signer)}catch(j){return o("error",`${k()}: ${j instanceof Error?j.message:"REFUSE\xB7signer unavailable"}
22
- `),{kind:"exit",code:1}}const p=await pn(w,{epoch:$,by:A,algorithm:I(l).era},G,I(l).admitted,e);if(p.kind==="refuse")return o("error",`${k()}: ${p.why}
23
- `),{kind:"exit",code:1};let b=0;O=y.map(j=>t(j,"sig")?j:p.lines[b++])}const W=[...J(l),...O].flatMap(e=>{const p=Se(e);return p.kind==="fact"?[p.value.fields]:[]});for(const e of O){const p=Ze(e,W,Number(t(e,"epoch")),Fe(J(l)).standing.filter(b=>t(b,"scope").startsWith("uses/")&&t(b,"value")!=="withdraw"));if(p.kind!=="fact")return o("error",`${k()}: REFUSE\xB7wire ${t(e,"scope")} \xB7 ${p.why} \xB7 nothing landed
24
- `),{kind:"exit",code:1}}if(We(n,O))return{kind:"exit",code:1};const P=Un(O);if(P.length){for(const e of P)o("error",`WITHDRAW ${D(e.withdraw)}
25
- `),o("error",`NEW ${D(e.line)}
26
- `);return o("error",`${k()}: REFUSE\xB7withdraw nothing landed \xB7 a withdraw matches a new line in this batch, so it takes that line too
27
- `),{kind:"exit",code:1}}const a=Z([...C(l),...O],ee(n),I(l).admitted),E=Oe(n,O,e=>a.of(e).kind==="admitted",e=>a.admitted.find(p=>p.id===e)?.coverage??[],s,e=>{const p=S.flatMap(([b,j])=>j.some(B=>D(B)===D(e))?b:[]);return p.length?p:void 0});if(E.nowhere.length){for(const e of E.nowhere)o("error",`${k()}: REFUSE\xB7signer ${A} uncovered ${t(e,"scope")} \xB7 nothing signed for delivery
28
- `);return{kind:"exit",code:1}}if(E.forked.length){for(const e of E.forked)o("error",`FORKED ${e.place}/${fe} \xB7 ${e.key} \xB7 the lot would leave two standing claims where the lock had one
29
- `);return o("error",`${k()}: REFUSE\xB7forked nothing landed \xB7 ${E.forked.length} claims an own lot would fork: a lot for many places lands the same lines at each, and lines meant for one place go in a lot of their own
30
- `),{kind:"exit",code:1}}if(Me(n,E.ledger,z(l)))return{kind:"exit",code:1};if(O.some(e=>!q(e)))try{await le(n,[...J(l),...O],e=>o("out",e+`
31
- `))}catch(e){return o("error",`${k()}: ${e instanceof Error?e.message:String(e)} \xB7 nothing landed
32
- `),{kind:"exit",code:1}}try{Ne(n,E.ledger,z(l))}catch(e){return o("error",`${k()}: ${e instanceof Error?e.message:String(e)} \xB7 nothing landed
33
- `),{kind:"exit",code:1}}return{kind:"signed",signed:O,epoch:$,base:L,...w.length?{keyId:A}:{}}}F(Pe,"signedBatch");async function er(n,r){const c=Date.now(),i=ge(r);if(i.length===1&&ze(n)&&!pe(i[0]).length){if(ne(r).length||X(r,Q.key)||X(r,Q.keyFile)||X(r,Q.signer))throw Error("REFUSE\xB7contextual place accepts one already signed context envelope");const m=await Ve(n,i[0]);return o("out",JSON.stringify({profile:"place-act-context@1",identity:m.identity,status:m.kind,context:m.context,receipts:m.receipts})+`
34
- `),0}const S=ne(r),y=ge(r).reduce((m,l)=>(g=>g.length?pe(l).reduce((f,d)=>f.set(D(d),[...new Set([...f.get(D(d))??[],...g])]),m):m)(Ce(l)),new Map),w=await Pe(n,r,ge(r));return Be(n,r,w,y,c)}F(er,"accept");async function nr(n,r){if(qe("Root lot admission"),oe(r.signal),!Re(z(N(n))))throw new $e("host/act","REFUSE\xB7Root host requires the admitted atomic result profile");const c=Date.now(),i=await Pe(n,[],[],r);return Be(n,[],i,new Map,c,r)}F(nr,"acceptRootRecords");async function Be(n,r,c,i,S,y){const w=ne(r);if(c.kind==="exit")return c.code;if(c.kind==="once")return Ln(N(n),"land",()=>Zn(n,c.proposed,S));const m=N(n),l=Z([...C(m),...c.signed],ee(n),I(m).admitted),g=Oe(n,c.signed,v=>l.of(v).kind==="admitted",v=>l.admitted.find(U=>U.id===v)?.coverage??[],w,v=>i.get(D(v)));if(g.nowhere.length){for(const v of g.nowhere)o("error",`NOWHERE ${t(v,"scope")} \xB7 ${(U=>U.kind==="admitted"?"admitted":U.why)(l.of(v))}, and ${w.length?`no place of ${w.join(", ")} takes it`:"no one own lock it covers takes it: name the places with --place"}
35
- `);return o("error",`${k()}: REFUSE\xB7nowhere nothing landed \xB7 ${g.nowhere.length} lines neither the ledger nor an own lock admits: a line is landed signed where it stands, never written in bare
36
- `),1}const f=he(n),d=[...new Set([...g.own.keys(),...w])],h=d.length===0&&g.ledger.length?Mn(n,f,g.ledger,z(m)):[],L=d.length===0&&h.length===f.length&&f.length>0,$=(d.length?d:L?f:h).filter(v=>f.includes(v)),x=L?"every place \xB7 then the root, where the places join":$.length?$.map(v=>`${v}/`).join(" \xB7 "):"the root alone, where the places join";o("out",`ACTS ${x} \xB7 ${g.ledger.length} lines to the ledger${[...g.own].map(([v,U])=>` \xB7 ${U.length} to ${v}'s own lock`).join("")} \xB7 before the lock
37
- `);const s=Date.now(),T=g.ledger.length>0||L||$.length===0;return(T?Tn:Cn)(m,T?[...$,""]:$,"land",()=>Yn(n,{...c,signed:g.ledger,records:c.signed},S,g,s,$,y))}F(Be,"finishAcceptance");async function Yn(n,r,c,i,S=c,y=[],w){const m=Date.now()-S;m>6e4&&o("out",`RED wait ${Math.round(m/1e3)} s for the lock before the act \xB7 a wait over a minute is a red
38
- `);const l=[`sign ${S-c}`,`wait ${m}`],g=en(l),{signed:f,epoch:d}=r;if(We(n,r.records??f))return 1;const h=N(n),L=Y(h,De(n,r.base.places));if(L!==r.base.digest)return o("error",`${k()}: REFUSE\xB7base moved ${r.base.digest} \u2192 ${L} \xB7 nothing landed
39
- `),1;try{ke(n,f)}catch(a){return o("error",`${k()}: ${a instanceof Error?a.message:String(a)} \xB7 nothing landed
40
- `),1}if(f.some(a=>!q(a)))try{await le(n,[...J(h),...f])}catch(a){return o("error",`${k()}: ${a instanceof Error?a.message:String(a)} \xB7 nothing landed
41
- `),1}const $=g("lines",()=>ue(n));if(Me(n,f,$.standing))return 1;let x;try{x=g("evidence",()=>Ne(n,f,$.standing))}catch(a){return o("error",`${k()}: ${a instanceof Error?a.message:String(a)} \xB7 nothing landed
42
- `),1}const s=x.fold,T=g("authority",()=>Z([...C(h),...f],ee(n),I(h).admitted));for(const a of f){const E=T.of(a);if(E.kind!=="admitted")return o("error",`${k()}: ${E.kind==="refuse"?E.why:`REFUSE\xB7authority grey: ${E.why}`}
43
- `),1}const M=f.filter(a=>t(a,"value")==="withdraw"),v=x.coordinates,U=M.length?An(M,C(h)):null,de=`${V(s.standing,"families","view")}/`,te=Y(h,f),K=yn(h)?Y(h,[...bn(h)].sort(([a],[E])=>a.localeCompare(E)).map(([a,E])=>`${a} ${E}`)):"key"in s&&typeof s.key=="string"?s.key:Y(h,s.standing),re=nt(un(h,K,te)),A=re??x.judged;re||fn(h,K,te,A.map(et));const G=A.filter(a=>a.kind==="refused"||a.kind==="judged"&&a.verdict.kind==="refuse");if(G.length){for(const a of G)o("out",`REFUSE take ${a.scope} \xB7 ${a.kind==="judged"?a.verdict.why:a.kind==="refused"?a.why:""}
44
- `);return o("error",`${k()}: REFUSE\xB7takes nothing landed \xB7 ${G.length} takes refused: a batch lands whole or not at all
45
- `),1}const O=g("told",()=>ue(n,void 0,f));for(const a of Nn(y,O.standing,f))o("error",`OPEN ${a}
46
- `);i.own.size&&Pn(h,n,O.standing,h);const W=Re($.standing);let P=[];if(W){const a=r.records??f,E=[...f.length?[{place:".",records:f}]:[],...[...i.own].map(([u,R])=>({place:`${u}/${fe}`,records:R}))],p=cn(a,{...W,digest:F(u=>ve(h,new TextEncoder().encode(u)),"digest"),placements:E,localEpoch:d}),b=ie($.standing,"fold");if(!b)throw Error("REFUSE\xB7act native result requires a declared fold identity");const j=be({scope:W.scope,at:W.context,role:"writes",form:"alphabet",measure:"digest",value:p,by:b,epoch:String(d)}),B={records:a.join(`
1
+ var ze=Object.defineProperty;var S=(n,t)=>ze(n,"name",{value:t,configurable:!0});import{readingWitnessAdmission as He}from"../host/native/reading-witness-admission.js";import{BoundRefusal as I}from"../host/refusals.js";import{assertHostNotCancelled as de}from"../host/host-controls.js";import{library14_authorityAtEpoch as Ve}from"../vendor/runtime.js";import{requireEffects as Je}from"../host/read-only.js";import{hostOutput as s}from"../host/call-context.js";import{assertProspectiveRootClockSelection as ye}from"../host/root-clock-source.js";import{hasContextualPlace as Xe,landContextualPlace as Qe}from"../host/contextual-place.js";import{commitLocalAct as Ye,intactLocalAct as Ze,committedLocalActs as en}from"../host/ports/local-act.js";import{withoutEffects as nn}from"../host/read-only.js";import{admittedLine as tn}from"../host/selected-topos.js";import{timing as rn}from"../host/timing.js";import{admittedObjects as ue}from"../host/objects.js";import{existsSync as ve,rmdirSync as on,rmSync as sn}from"node:fs";import{dirname as Ee,join as H,basename as dn}from"node:path";import{closeReceipts as an,instrumentKeep as cn,instrumentKept as ln}from"../fold/closed.js";import{bytesDigest as be,fullDigest as Z,instrumentOf as fn,signaturesOf as N}from"../fold/digests.js";import{library14_canonical as Se,library14_LOCK as Re,library14_parse as xe,library14_actIdentity as un,library14_actResultProfile as Fe}from"../vendor/runtime.js";import{fieldOf as o,isConfig as V,foldClaims as je,sayingOf as C,selfName as y}from"../fold/claims.js";import{isReaderLock as mn}from"../fold/observed.js";import{authorityFor as ee,publicKeyOf as Oe,rootSigner as ne,writerFor as ae}from"../fold/signers.js";import{lockLines as M,lockStanding as G}from"../fold/keys.js";import{keepVerdict as hn,keptVerdict as gn,land as ce,landBlob as pn,ledgerLines as wn,storeOf as L}from"../land/ledger.js";import{signConsentLot as kn,verifiesOwnerLine as $n}from"../land/sign.js";import{signerFor as yn}from"../host/signing.js";import{appliedIn as vn,ownLockOf as En,withOwnPreview as bn}from"../fold/signed.js";import{wordOf as J}from"../fold/wire.js";import{hasVouchedTree as Sn,landCoordinates as Rn,locationsOf as xn,vouchedCoordinates as Fn}from"../land/vouched.js";import{entriesIn as jn,observeFile as On}from"../observe/files.js";import{coneOf as An,standingOf as me}from"./place.js";import{ownLock as Cn,ownRoot as Dn}from"../observe/runner.js";import{widenedWithoutWitness as Un}from"../judge/widening.js";import{retractedTogether as Ln,withdrawal as Tn}from"../land/withdraw.js";import{isCeiling as le}from"../fold/configures.js";import{inertIn as In}from"../land/inert.js";import{landSaid as Ae}from"./pass.js";import{currentActSignal as he,underTheLock as Nn,underTheRegions as Mn,underAuthorityRegions as Pn,underRootProjection as Wn,underRootAuthority as Bn}from"../land/act.js";import{openedBy as Gn}from"../fold/opened.js";import{touchedBy as Kn}from"../fold/reach.js";import{landOwned as _n,ownedOf as Ce}from"../land/owned.js";import{layReleases as qn}from"../host/release.js";import{foundableIn as zn,placesIn as ge}from"../fold/places.js";import{outsideTheirCapsule as Hn}from"../fold/own.js";import{lateFacts as De}from"../judge/late.js";import{paidOf as pe}from"../fold/paid.js";import{aliasPinned as Vn}from"../land/alias.js";import{admitStandingPins as Ue}from"../land/standing-pin.js";import{coordinatesWithdrawn as Jn}from"../land/leaving.js";import{ownerOf as Xn,epochOf as Le,localActLines as Te,forksItself as Qn,forksJoinedBy as Yn,renderInto as Ie,signedDemands as Zn,signedOwnerLines as te}from"./owner.js";import{claimLinesIn as we,entryOf as Ne,namedPlaces as ie,placesOfFile as Me,positionalsOf as ke,valueOf as X}from"./args.js";import{FLAGS as Q}from"./names.js";import{judgeDemand as Pe,landTake as $e}from"./takes.js";function et(n,t,d,r){if(!Number.isSafeInteger(r))throw new I("admission/clock","REFUSE\xB7admission clock is required");return nn(()=>{const m=L(n);ye(n,t);const p=!t.some(mn)&&t.some(le),u=p?An(n,Ne(n),t.filter(le)):{standing:d,observed:[],own:{},kept:!0};if(In(t,{standing:u.standing,ceiling:le,signsReader:!p,observed:u.observed,own:u.own,epoch:Le([...M(m),...t])}).length)throw new I("admission/inert","REFUSE\xB7inert no existing reading meets these ceilings; fold the declared inputs first");const f=Jn(n,m,t,[...t,...d]);if(f.refused.length)throw new I("admission/withdraw",`REFUSE\xB7withdraw a file is still read: ${f.refused.map(i=>`${i.path} by ${i.by}`).join(" \xB7 ")}`);const h=`${J(G(m),"families","view")}/`,a=t.filter(i=>V(i)&&o(i,"role")==="demands"&&o(i,"value")!=="withdraw"&&!o(i,"scope").startsWith(h)).map(i=>{const j=o(i,"scope");return d.some(E=>V(E)&&o(E,"role")==="demands"&&o(E,"value")!=="withdraw"&&o(E,"scope")===j&&o(E,"form")===o(i,"form")&&o(E,"measure")===o(i,"measure"))?Pe(n,i,{now:r}):{kind:"owed",scope:j,why:"new demand declared; no conformance reading is claimed"}}),g=a.filter(i=>i.kind==="refused"||i.kind==="judged"&&i.verdict.kind==="refuse");if(g.length)throw new I("admission/takes",`REFUSE\xB7takes ${g.map(i=>`${i.scope}: ${i.kind==="judged"?i.verdict.why:i.kind==="refused"?i.why:""}`).join(" \xB7 ")}`);return{coordinates:f,judged:a,fold:u}})}S(et,"admissionEvidence");function We(n,t,d,r){try{return{kind:"fact",evidence:et(n,t,d,r)}}catch(m){return{kind:"refuse",code:m instanceof I?m.code:"admission/evidence",diagnostic:m instanceof Error?m.message:String(m)}}}S(We,"admissionEvidenceResult");function nt(n,t,d){return n.every(d)?[]:n.filter(r=>o(r,"sig")&&V(r)&&Number(o(r,"epoch"))!==t)}S(nt,"configurationEpochCheck");function tt(n,t,d=[],r){const m=L(n),p=te(m),u=je(p).standing,k=[...p,...t].flatMap(g=>{const i=xe(g);return i.kind==="fact"?[i.value.fields]:[]});for(const g of t){const i=tn(g,k,Number(o(g,"epoch")),u.filter(j=>o(j,"scope").startsWith("uses/")&&o(j,"value")!=="withdraw"));if(i.kind!=="fact")return{kind:"refuse",code:"wire",evidence:[g,i],diagnostic:i.why}}try{Ue(n,t)}catch(g){return{kind:"refuse",code:"standing-pin",evidence:t,diagnostic:g instanceof Error?g.message:String(g)}}const f=Ln(t);if(f.length)return{kind:"refuse",code:"withdraw",evidence:f,diagnostic:"a withdrawal takes a new line in the same batch"};const h=ee([...M(m),...t],ne(n),N(m).admitted),a=bn(n,()=>Ce(n,t,g=>h.of(g).kind==="admitted",g=>h.admitted.find(i=>i.id===g)?.coverage??[],d,r));return a.nowhere.length?{kind:"refuse",code:"signer",evidence:a.nowhere,diagnostic:"the requested records are not covered at their selected destination"}:a.forked.length?{kind:"refuse",code:"forked",evidence:a.forked,diagnostic:"the lot would fork a selected own lock"}:{kind:"fact",ownership:a}}S(tt,"configurationAdmissionGuards");function it(n,t,d,r=d,m="."){const p=He(n,t,d,r,m);if(p.kind==="ask")return p;if(p.kind==="refuse")return{kind:"refuse",code:p.code,evidence:p.evidence,diagnostic:p.why};const u=Un(t,d,le,J(r,"at-classes","witness"));return u.length?{kind:"ask",code:"widening",evidence:u,needs:u.map(k=>"witness:"+o(k,"scope"))}:{kind:"fact",evidence:p.evidence}}S(it,"admissionWideningChecks");function rt(n,t,d){const r=it(n,t,d);if(r.kind!=="fact")return r;const m=L(n),p=Hn(n,d,t);if(p.length)return{kind:"refuse",code:"outside",evidence:p,diagnostic:"a reader or capsule lands in its own world"};const u=Yn(m,t).filter(f=>Qn(f.lines)||f.lines.filter(h=>t.includes(h)).length>1);if(u.length)return{kind:"refuse",code:"fork",evidence:u,diagnostic:"one signer and one act cannot fork themselves"};const k=Vn(n,t);return k.length?{kind:"refuse",code:"alias",evidence:k,diagnostic:"an alias is still named by a pin"}:{kind:"fact",evidence:r.evidence}}S(rt,"admissionChecks");function Be(n,t,d){const r=rt(n,t,d);if(r.kind==="fact")return!1;if(r.kind==="ask"&&r.code==="reading-witness")s("error",`${y()}: REFUSE\xB7reading-witness ${r.needs.join(" \xB7 ")} \xB7 nothing landed
2
+ `);else if(r.kind==="ask"){for(const m of r.evidence)s("error",`WIDER ${o(m,"scope")} \xB7 ${o(m,"value")}
3
+ `);s("error",`${y()}: REFUSE\xB7widening nothing landed \xB7 a ceiling that admits more than it did gives back freedom the lock had spent: sign it under a witness that names what made the old ceiling wrong
4
+ `)}else s("error",`${y()}: REFUSE\xB7${r.code} nothing landed \xB7 ${r.diagnostic}
5
+ `);return!0}S(Be,"refusesAdmission");function ot(n,t){try{return Ue(n,t),!1}catch(d){return s("error",`${y()}: ${d instanceof Error?d.message:String(d)}
6
+ `),!0}}S(ot,"refusesStandingPins");async function Ge(n,t,d,r){const m=r?[[[],r.records]]:d.map(e=>[Me(e),we(e)]),p=m.flatMap(([,e])=>e);if(!p.length)return s("error",`${y()}: a batch is a file with claim lines
7
+ `),{kind:"exit",code:2};const u=p.filter(e=>!o(e,"sig")),k=u.filter(e=>o(e,"epoch")||!["","target"].includes(o(e,"by")));if(k.length){for(const e of k)s("error",`BARE ${o(e,"scope")} \xB7 by=${o(e,"by")||"\u2205"}${o(e,"epoch")?` epoch=${o(e,"epoch")}`:""}
8
+ `);return s("error",`${y()}: REFUSE\xB7bare nothing landed \xB7 ${k.length} lines name a signer or an epoch they were not signed with: a drafted line proposes by=target and sign signs it, a line a lane signed carries its sig
9
+ `),{kind:"exit",code:1}}const f=L(n),h=[...new Set([...ie(t),...m.flatMap(([e])=>e)])],a=G(f),g=h.filter(e=>!ge(n).includes(e)&&!zn(n,a,J(a,"families","region"),e));if(g.length)return s("error",`${y()}: REFUSE\xB7place nothing landed \xB7 ${g.join(", ")} is no place of the tree, and no line of the root founds it: --place names the own lock a line lands in
10
+ `),{kind:"exit",code:2};const i=Te(n,h),j={digest:Z(f,i),places:h},v=Le(i)+1,E=p.filter(e=>o(e,"sig")).flatMap(e=>((w,R)=>R===void 0||!$n(e,R,N(f).admitted)?[`${o(e,"scope")} \xB7 the signature does not hold for ${w||"\u2205"}`]:[])(o(e,"by"),Oe(n,o(e,"by"))));if(E.length){for(const e of E)s("error",`SIGNED ${e}
11
+ `);return s("error",`${y()}: REFUSE\xB7signed nothing landed \xB7 ${E.length} lines a lane signed stand at no epoch this act
12
+ `),{kind:"exit",code:1}}const[c,x]=[ie(t),ge(n)],K=new Set(M(f).map(C)),b=new Map(x.map(e=>[e,new Set(vn(n,e).map(C))])),O=ee(M(f),ne(n),N(f).admitted),P=S(e=>!!o(e,"sig")&&O.of(e).kind==="admitted"&&wn(f,o(e,"by")).includes(e),"delivered"),re=S((e,w=c.length?c:m.flatMap(([R,$])=>$.includes(e)?R:[]))=>w.length?w.every(R=>b.get(R)?.has(C(e))):P(e)||K.has(C(e))||x.some(R=>b.get(R)?.has(C(e))),"held");if(p.every(e=>re(e))){if(p.some(e=>!V(e)))try{await ue(n,[...te(f),...p])}catch(e){return s("error",`${y()}: ${String(e)} \xB7 nothing landed
13
+ `),{kind:"exit",code:1}}return{kind:"once",proposed:p}}const _=nt(p,v,re);if(_.length){for(const e of _)s("error",`SIGNED ${o(e,"scope")} \xB7 signed by ${o(e,"by")} at epoch ${o(e,"epoch")}, and this act lands at ${v}: sign it again
14
+ `);return s("error",`${y()}: REFUSE\xB7signed nothing landed \xB7 ${_.length} lines a lane signed stand at no epoch this act
15
+ `),{kind:"exit",code:1}}const oe=r?void 0:X(t,Q.keyFile),A=r?.keyId??X(t,Q.key)??Xn(f),q=u.length?Oe(n,A):void 0;if(u.length&&!q)return s("error",`${y()}: unknown key ${A} \u2014 name it in ${y()}.keys
16
+ `),{kind:"exit",code:2};let D=p.filter(e=>o(e,"sig"));if(r&&u.length){de(r.signal);const e=ee(M(f),ne(n),N(f).admitted).admitted.find(w=>w.id===A);for(const w of u){const R=xe(w);if(R.kind!=="fact"||!e||Ve({...R.value.fields,by:A,epoch:String(v)},e,v,o(w,"scope"),"authority").kind!=="admitted")throw new I("host/receiver-authority","REFUSE\xB7host/receiver-authority")}}if(u.length){let e;try{e=yn([...G(f),...h.flatMap($=>En(n,$))],A,r?.signer.name??X(t,Q.signer),oe,r?.signer)}catch($){if($ instanceof I)throw $;return s("error",`${y()}: ${$ instanceof Error?$.message:"REFUSE\xB7signer unavailable"}
17
+ `),{kind:"exit",code:1}}const w=await kn(u,{epoch:v,by:A,algorithm:N(f).era},q,N(f).admitted,e);if(w.kind==="refuse")return s("error",`${y()}: ${w.why}
18
+ `),{kind:"exit",code:1};let R=0;D=p.map($=>o($,"sig")?$:w.lines[R++])}const U=tt(n,D,c,e=>{const w=m.flatMap(([R,$])=>$.some(B=>C(B)===C(e))?R:[]);return w.length?w:void 0});if(U.kind==="refuse")return s("error",`${y()}: REFUSE\xB7${U.code} ${U.diagnostic} \xB7 nothing landed
19
+ `),{kind:"exit",code:1};const T=U.ownership;if(Be(n,T.ledger,G(f)))return{kind:"exit",code:1};if(D.some(e=>!V(e)))try{await ue(n,[...te(f),...D],e=>s("out",e+`
20
+ `))}catch(e){return s("error",`${y()}: ${e instanceof Error?e.message:String(e)} \xB7 nothing landed
21
+ `),{kind:"exit",code:1}}const W=await Bn(f,"prospective admission evidence",()=>We(n,T.ledger,G(f),Date.now()));return W.kind==="refuse"?(s("error",`${y()}: ${W.diagnostic} \xB7 nothing landed
22
+ `),{kind:"exit",code:1}):{kind:"signed",signed:D,epoch:v,base:j,...u.length?{keyId:A}:{}}}S(Ge,"signedBatch");async function ci(n,t){const d=Date.now(),r=ke(t);if(r.length===1&&Xe(n)&&!we(r[0]).length){if(ie(t).length||X(t,Q.key)||X(t,Q.keyFile)||X(t,Q.signer))throw Error("REFUSE\xB7contextual place accepts one already signed context envelope");const k=await Qe(n,r[0]);return s("out",JSON.stringify({profile:"place-act-context@1",identity:k.identity,status:k.kind,context:k.context,receipts:k.receipts})+`
23
+ `),0}const m=ie(t),p=ke(t).reduce((k,f)=>(h=>h.length?we(f).reduce((a,g)=>a.set(C(g),[...new Set([...a.get(C(g))??[],...h])]),k):k)(Me(f)),new Map),u=await Ge(n,t,ke(t));return Ke(n,t,u,p,d)}S(ci,"accept");async function li(n,t){if(Je("Root lot admission"),de(t.signal),!Fe(G(L(n))))throw new I("host/act","REFUSE\xB7Root host requires the admitted atomic result profile");const d=Date.now(),r=await Ge(n,[],[],t);return Ke(n,[],r,new Map,d,t)}S(li,"acceptRootRecords");async function Ke(n,t,d,r,m,p){const u=ie(t);if(d.kind==="exit")return d.code;if(d.kind==="once")return Nn(L(n),"land",()=>dt(n,d.proposed,m));const k=L(n),f=ee([...M(k),...d.signed],ne(n),N(k).admitted),h=Ce(n,d.signed,b=>f.of(b).kind==="admitted",b=>f.admitted.find(O=>O.id===b)?.coverage??[],u,b=>r.get(C(b)));if(h.nowhere.length){for(const b of h.nowhere)s("error",`NOWHERE ${o(b,"scope")} \xB7 ${(O=>O.kind==="admitted"?"admitted":O.why)(f.of(b))}, and ${u.length?`no place of ${u.join(", ")} takes it`:"no one own lock it covers takes it: name the places with --place"}
24
+ `);return s("error",`${y()}: REFUSE\xB7nowhere nothing landed \xB7 ${h.nowhere.length} lines neither the ledger nor an own lock admits: a line is landed signed where it stands, never written in bare
25
+ `),1}const a=ge(n),g=[...new Set([...h.own.keys(),...u])],i=g.length===0&&h.ledger.length?Kn(n,a,h.ledger,G(k)):[],j=g.length===0&&i.length===a.length&&a.length>0,v=(g.length?g:j?a:i).filter(b=>a.includes(b)),E=j?"every place \xB7 then the root, where the places join":v.length?v.map(b=>`${b}/`).join(" \xB7 "):"the root alone, where the places join";s("out",`ACTS ${E} \xB7 ${h.ledger.length} lines to the ledger${[...h.own].map(([b,O])=>` \xB7 ${O.length} to ${b}'s own lock`).join("")} \xB7 before the lock
26
+ `);const c=Date.now(),x=h.ledger.length>0||j||v.length===0;return(x?Mn:Pn)(k,x?[...v,""]:v,"land",()=>st(n,{...d,signed:h.ledger,records:d.signed},m,h,c,v,p))}S(Ke,"finishAcceptance");async function st(n,t,d,r,m=d,p=[],u){const k=Date.now()-m;k>6e4&&s("out",`RED wait ${Math.round(k/1e3)} s for the lock before the act \xB7 a wait over a minute is a red
27
+ `);const f=[`sign ${m-d}`,`wait ${k}`],h=rn(f),{signed:a,epoch:g}=t;if(ot(n,t.records??a))return 1;const i=L(n),j=Z(i,Te(n,t.base.places));if(j!==t.base.digest)return s("error",`${y()}: REFUSE\xB7base moved ${t.base.digest} \u2192 ${j} \xB7 nothing landed
28
+ `),1;try{ye(n,a)}catch(e){return s("error",`${y()}: ${e instanceof Error?e.message:String(e)} \xB7 nothing landed
29
+ `),1}if(a.some(e=>!V(e)))try{await ue(n,[...te(i),...a])}catch(e){return s("error",`${y()}: ${e instanceof Error?e.message:String(e)} \xB7 nothing landed
30
+ `),1}const v=h("lines",()=>me(n));if(Be(n,a,v.standing))return 1;let E;const c=h("evidence",()=>We(n,a,v.standing,Date.now()));if(c.kind==="refuse")return s("error",`${y()}: ${c.diagnostic} \xB7 nothing landed
31
+ `),1;E=c.evidence;const x=E.fold,K=h("authority",()=>ee([...M(i),...a],ne(n),N(i).admitted));for(const e of a){const w=K.of(e);if(w.kind!=="admitted")return s("error",`${y()}: ${w.kind==="refuse"?w.why:`REFUSE\xB7authority grey: ${w.why}`}
32
+ `),1}const b=a.filter(e=>o(e,"value")==="withdraw"),O=E.coordinates,P=b.length?Tn(b,M(i)):null,re=`${J(x.standing,"families","view")}/`,_=Z(i,a),oe=Sn(i)?Z(i,[...Fn(i)].sort(([e],[w])=>e.localeCompare(w)).map(([e,w])=>`${e} ${w}`)):"key"in x&&typeof x.key=="string"?x.key:Z(i,x.standing),A=ct(gn(i,oe,_)),q=A??E.judged;A||hn(i,oe,_,q.map(at));const D=q.filter(e=>e.kind==="refused"||e.kind==="judged"&&e.verdict.kind==="refuse");if(D.length){for(const e of D)s("out",`REFUSE take ${e.scope} \xB7 ${e.kind==="judged"?e.verdict.why:e.kind==="refused"?e.why:""}
33
+ `);return s("error",`${y()}: REFUSE\xB7takes nothing landed \xB7 ${D.length} takes refused: a batch lands whole or not at all
34
+ `),1}const U=h("told",()=>me(n,void 0,a));for(const e of Gn(p,U.standing,a))s("error",`OPEN ${e}
35
+ `);r.own.size&&qn(i,n,U.standing,i);const T=Fe(v.standing);let W=[];if(T){const e=t.records??a,w=[...a.length?[{place:".",records:a}]:[],...[...r.own].map(([l,F])=>({place:`${l}/${Re}`,records:F}))],$=un(e,{...T,digest:S(l=>be(i,new TextEncoder().encode(l)),"digest"),placements:w,localEpoch:g}),B=ae(v.standing,"fold");if(!B)throw Error("REFUSE\xB7act native result requires a declared fold identity");const se=Se({scope:T.scope,at:T.context,role:"writes",form:"alphabet",measure:"digest",value:$,by:B,epoch:String(g)}),Y={records:e.join(`
47
36
  `)+`
48
- `,receipt:j+`
49
- `,placements:E.map(u=>({place:u.place,records:u.records.join(`
37
+ `,receipt:se+`
38
+ `,placements:w.map(l=>({place:l.place,records:l.records.join(`
50
39
  `)+`
51
- `}))};oe(w?.signal),w?.prepared?.(p),oe(w?.signal);const _=await Je(h,p,y,async()=>B,Xe,w?.storage,w?.signal);w?.committed?.(p,_,_.kind),o("out",`ACT ${p} \xB7 epoch ${d} \xB7 admitted \xB7 conformance not asserted
52
- `);for(const u of a)o("out",u+`
53
- `);o("out",j+`
54
- `),P=[{at:"committed act "+p,appended:a.length}]}else P=g("land",()=>[...new Set(f.map(a=>t(a,"by")))].map(a=>se(h,a,f.filter(E=>t(E,"by")===a))));for(const[a,E]of i.own)Wn(n,a,E,W!==void 0);return In(h,"projection",async()=>{je(h,ie(O.standing,"fold"),[]);for(const u of f){const R=t(u,"value");if(/^[a-z0-9-]+:[0-9a-f]{32,}$/.test(R))for(const Ke of vn(t(u,"needs")).locations){const Ge=H(n,Ke),ce=Rn(Ge);ce!==void 0&&ve(h,ce)===R&&hn(h,R,ce)}}if(v.taken.length){for(const u of v.taken){ye(H(n,u))&&tn(H(n,u),{recursive:!0});for(let R=Ee(u);R!=="."&&ye(H(n,R))&&!Sn(H(n,R)).length;R=Ee(R))nn(H(n,R))}En(h,new Map,v.taken,`withdraw:epoch-${d}`);for(const u of v.taken)o("out",`GONE ${u} \xB7 withdrawn by its line
55
- `)}for(const u of A)we(n,u,[]);const a=[...f,...s.standing].filter(u=>t(u,"role")==="demands"&&t(u,"value")!=="withdraw"),E=new Set(me(h,a,s.observed,de).paid.map(u=>t(u,"scope"))),e=Ue(h,[...f,...s.standing],E);if(e.length){se(h,"judge",e);for(const u of e)t(u,"measure")!=="cone"&&o("out",`LATE ${t(u,"scope")} \xB7 answered from the landed cone
56
- `)}if(f.some(u=>t(u,"scope").startsWith(`${rn(jn())}/`)&&!t(u,"scope").split("/").slice(1,-1).includes("uses"))){const u=dn(h,Te(n),O.standing,n,xn());if(an(h)!==u){const R=await on(n,h);sn(h,u),o("error",`open by instrument \xB7 ${R.length}
57
- `)}}const p=g("render",()=>Le(n,h));o("out",`RENDER 0
58
- `);const b=new Set([...i.own.values()].flat()).size,j=Math.round((Date.now()-c)/Math.max(1,f.length+b)),B=ie(s.standing,"fold"),_=F((u,R)=>be({scope:"beat/accept",role:"writes",form:"interval",measure:"ms",value:`${u}..${u}`,by:B??"",at:`place:${R}`}),"beat");if(B!==void 0&&se(h,B,[_(j,"line"),_(1,s.kept?"kept":"folded"),_(Date.now()-c,"total")]),o("out",`FACT signed ${f.length+b} \xB7 landed ${P.length?P.map(u=>`${u.appended} in ${u.at}`).join(" \xB7 "):"0"}${[...i.own].map(([u,R])=>` \xB7 ${R.length} in ${u}/${fe}`).join("")} \xB7 epoch ${d}
59
- TARGET ${p.standing} claims \xB7 ${p.forks.length} forks \xB7 ${p.vacuous.length} vacuous \xB7 ${p.grey.length} grey \xB7 ${p.refused.length} refused \xB7 readings \xB7 no encounters computed \xB7 ${Date.now()-c} ms
60
- SPENT ${l.join(" ms \xB7 ")} ms \xB7 ${f.length} lines
61
- `),U){o("out",`WITHDRAW ${U.taken.length} taken \xB7 ${U.exact.length} exact on distributive scales \xB7 ${U.open.length} on open scales, not computed
62
- `);for(const u of U.inexact)o("out",`INEXACT ${t(u,"scope")} \xB7 its scale is not distributive: what the others hold is not what they held without it
63
- `)}return 0})}F(Yn,"acceptNow");function Zn(n,r,c){const i=N(n),S=Qe(i).find(s=>{const T=s.bundle.records.trimEnd().split(`
64
- `);return T.length===r.length&&T.every((M,v)=>M===r[v])});S&&o("out",`ACT ${S.identity} \xB7 epoch ${t(S.bundle.receipt.trim(),"epoch")} \xB7 admitted \xB7 replay
65
- `+S.bundle.records+S.bundle.receipt);const y=new Set(r.filter(s=>t(s,"role")==="demands").map(s=>t(s,"scope"))),w=`${V(Fe(J(i)).standing,"families","view")}/`,m=Xn(i).filter(s=>y.has(t(s,"scope"))&&!t(s,"scope").startsWith(w)),l=me(i,m,[],w).missing;if(!l.length)return o("out",`ONCE ${r.length} lines \xB7 every one already landed and every demand of it paid: a batch landed twice is one, nothing landed
66
- `),0;const g=l.map(s=>Ie(n,s));if(o("out",`ONCE ${r.length} lines \xB7 every one already landed \xB7 ${l.length} of its demands unpaid, judged again
67
- `),g.every(s=>s.kind==="owed")){for(const s of g)we(n,s,[]);return 0}const f=g.filter(s=>s.kind==="refused"||s.kind==="judged"&&s.verdict.kind==="refuse");if(f.length){for(const s of f)o("out",`REFUSE take ${s.scope} \xB7 ${s.kind==="judged"?s.verdict.why:s.kind==="refused"?s.why:""}
68
- `);return o("error",`${k()}: REFUSE\xB7takes nothing landed \xB7 ${f.length} takes refused: what a batch left unpaid is paid whole or not at all
69
- `),1}const d=ue(n);for(const s of g)we(n,s,[]);je(i,ie(d.standing,"fold"),[]);const h=d.standing.filter(s=>t(s,"role")==="demands"&&t(s,"value")!=="withdraw"),L=new Set(me(i,h,[],`${V(d.standing,"families","view")}/`).paid.map(s=>t(s,"scope"))),$=Ue(i,d.standing,L);if($.length){se(i,"judge",$);for(const s of $)t(s,"measure")!=="cone"&&o("out",`LATE ${t(s,"scope")} \xB7 answered from the landed cone
70
- `)}const x=Le(n,i);return o("out",`RENDER 0
71
- `),o("out",`TARGET ${x.standing} claims \xB7 ${x.forks.length} forks \xB7 ${x.vacuous.length} vacuous \xB7 ${x.grey.length} grey \xB7 ${x.refused.length} refused \xB7 readings \xB7 no encounters computed \xB7 ${Date.now()-c} ms
72
- `),0}F(Zn,"repaid");function et(n){return n.kind==="judged"?{kind:n.kind,scope:n.scope,demand:n.demand,locations:n.locations,before:[...n.before],after:[...n.after],verdict:n.verdict,ignored:[...n.ignored]}:n}F(et,"packTake");function nt(n){if(n===void 0)return;const r=[];for(const c of n){if(c===null||typeof c!="object"||!("kind"in c)||!("scope"in c))return;const i=c;if(i.kind!=="judged"){r.push(i);continue}r.push({kind:"judged",scope:i.scope,demand:i.demand,locations:i.locations,before:new Map(i.before),after:new Map(i.after),verdict:i.verdict,ignored:new Map(i.ignored),started:Date.now()})}return r}F(nt,"keptTakes");export{er as accept,nr as acceptRootRecords,Pe as signedBatch};
40
+ `}))};de(u?.signal??he()),u?.prepared?.($),de(u?.signal??he());const z=await Ye(i,$,p,async()=>Y,Ze,u?.storage,u?.signal??he());u?.committed?.($,z,z.kind),s("out",`ACT ${$} \xB7 epoch ${g} \xB7 admitted \xB7 conformance not asserted
41
+ `);for(const l of e)s("out",l+`
42
+ `);s("out",se+`
43
+ `),W=[{at:"committed act "+$,appended:e.length}]}else W=h("land",()=>[...new Set(a.map(e=>o(e,"by")))].map(e=>ce(i,e,a.filter(w=>o(w,"by")===e))));for(const[e,w]of r.own)_n(n,e,w,T!==void 0);return Wn(i,"projection",async()=>{Ae(i,ae(U.standing,"fold"),[]);for(const l of a){const F=o(l,"value");if(/^[a-z0-9-]+:[0-9a-f]{32,}$/.test(F))for(const _e of xn(o(l,"needs")).locations){const qe=H(n,_e),fe=On(qe);fe!==void 0&&be(i,fe)===F&&pn(i,F,fe)}}if(O.taken.length){for(const l of O.taken){ve(H(n,l))&&sn(H(n,l),{recursive:!0});for(let F=Ee(l);F!=="."&&ve(H(n,F))&&!jn(H(n,F)).length;F=Ee(F))on(H(n,F))}Rn(i,new Map,O.taken,`withdraw:epoch-${g}`);for(const l of O.taken)s("out",`GONE ${l} \xB7 withdrawn by its line
44
+ `)}for(const l of q)$e(n,l,[]);const e=[...a,...x.standing].filter(l=>o(l,"role")==="demands"&&o(l,"value")!=="withdraw"),w=new Set(pe(i,e,x.observed,re).paid.map(l=>o(l,"scope"))),R=De(i,[...a,...x.standing],w);if(R.length){ce(i,"judge",R);for(const l of R)o(l,"measure")!=="cone"&&s("out",`LATE ${o(l,"scope")} \xB7 answered from the landed cone
45
+ `)}if(a.some(l=>o(l,"scope").startsWith(`${dn(Dn())}/`)&&!o(l,"scope").split("/").slice(1,-1).includes("uses"))){const l=fn(i,Ne(n),U.standing,n,Cn());if(ln(i)!==l){const F=await an(n,i);cn(i,l),s("error",`open by instrument \xB7 ${F.length}
46
+ `)}}const $=h("render",()=>Ie(n,i));s("out",`RENDER 0
47
+ `);const B=new Set([...r.own.values()].flat()).size,se=Math.round((Date.now()-d)/Math.max(1,a.length+B)),Y=ae(x.standing,"fold"),z=S((l,F)=>Se({scope:"beat/accept",role:"writes",form:"interval",measure:"ms",value:`${l}..${l}`,by:Y??"",at:`place:${F}`}),"beat");if(Y!==void 0&&ce(i,Y,[z(se,"line"),z(1,x.kept?"kept":"folded"),z(Date.now()-d,"total")]),s("out",`FACT signed ${a.length+B} \xB7 landed ${W.length?W.map(l=>`${l.appended} in ${l.at}`).join(" \xB7 "):"0"}${[...r.own].map(([l,F])=>` \xB7 ${F.length} in ${l}/${Re}`).join("")} \xB7 epoch ${g}
48
+ TARGET ${$.standing} claims \xB7 ${$.forks.length} forks \xB7 ${$.vacuous.length} vacuous \xB7 ${$.grey.length} grey \xB7 ${$.refused.length} refused \xB7 readings \xB7 no encounters computed \xB7 ${Date.now()-d} ms
49
+ SPENT ${f.join(" ms \xB7 ")} ms \xB7 ${a.length} lines
50
+ `),P){s("out",`WITHDRAW ${P.taken.length} taken \xB7 ${P.exact.length} exact on distributive scales \xB7 ${P.open.length} on open scales, not computed
51
+ `);for(const l of P.inexact)s("out",`INEXACT ${o(l,"scope")} \xB7 its scale is not distributive: what the others hold is not what they held without it
52
+ `)}return 0})}S(st,"acceptNow");function dt(n,t,d){const r=L(n),m=en(r).find(c=>{const x=c.bundle.records.trimEnd().split(`
53
+ `);return x.length===t.length&&x.every((K,b)=>K===t[b])});m&&s("out",`ACT ${m.identity} \xB7 epoch ${o(m.bundle.receipt.trim(),"epoch")} \xB7 admitted \xB7 replay
54
+ `+m.bundle.records+m.bundle.receipt);const p=new Set(t.filter(c=>o(c,"role")==="demands").map(c=>o(c,"scope"))),u=`${J(je(te(r)).standing,"families","view")}/`,k=Zn(r).filter(c=>p.has(o(c,"scope"))&&!o(c,"scope").startsWith(u)),f=pe(r,k,[],u).missing;if(!f.length)return s("out",`ONCE ${t.length} lines \xB7 every one already landed and every demand of it paid: a batch landed twice is one, nothing landed
55
+ `),0;const h=f.map(c=>Pe(n,c));if(s("out",`ONCE ${t.length} lines \xB7 every one already landed \xB7 ${f.length} of its demands unpaid, judged again
56
+ `),h.every(c=>c.kind==="owed")){for(const c of h)$e(n,c,[]);return 0}const a=h.filter(c=>c.kind==="refused"||c.kind==="judged"&&c.verdict.kind==="refuse");if(a.length){for(const c of a)s("out",`REFUSE take ${c.scope} \xB7 ${c.kind==="judged"?c.verdict.why:c.kind==="refused"?c.why:""}
57
+ `);return s("error",`${y()}: REFUSE\xB7takes nothing landed \xB7 ${a.length} takes refused: what a batch left unpaid is paid whole or not at all
58
+ `),1}const g=me(n);for(const c of h)$e(n,c,[]);Ae(r,ae(g.standing,"fold"),[]);const i=g.standing.filter(c=>o(c,"role")==="demands"&&o(c,"value")!=="withdraw"),j=new Set(pe(r,i,[],`${J(g.standing,"families","view")}/`).paid.map(c=>o(c,"scope"))),v=De(r,g.standing,j);if(v.length){ce(r,"judge",v);for(const c of v)o(c,"measure")!=="cone"&&s("out",`LATE ${o(c,"scope")} \xB7 answered from the landed cone
59
+ `)}const E=Ie(n,r);return s("out",`RENDER 0
60
+ `),s("out",`TARGET ${E.standing} claims \xB7 ${E.forks.length} forks \xB7 ${E.vacuous.length} vacuous \xB7 ${E.grey.length} grey \xB7 ${E.refused.length} refused \xB7 readings \xB7 no encounters computed \xB7 ${Date.now()-d} ms
61
+ `),0}S(dt,"repaid");function at(n){return n.kind==="judged"?{kind:n.kind,scope:n.scope,demand:n.demand,locations:n.locations,before:[...n.before],after:[...n.after],verdict:n.verdict,ignored:[...n.ignored]}:n}S(at,"packTake");function ct(n){if(n===void 0)return;const t=[];for(const d of n){if(d===null||typeof d!="object"||!("kind"in d)||!("scope"in d))return;const r=d;if(r.kind!=="judged"){t.push(r);continue}t.push({kind:"judged",scope:r.scope,demand:r.demand,locations:r.locations,before:new Map(r.before),after:new Map(r.after),verdict:r.verdict,ignored:new Map(r.ignored),started:Date.now()})}return t}S(ct,"keptTakes");export{ci as accept,li as acceptRootRecords,rt as admissionChecks,et as admissionEvidence,We as admissionEvidenceResult,it as admissionWideningChecks,tt as configurationAdmissionGuards,nt as configurationEpochCheck,Ge as signedBatch};
@@ -1,3 +1,3 @@
1
- var $=Object.defineProperty;var f=(o,r)=>$(o,"name",{value:r,configurable:!0});import{hashText as q}from"../host/hash.js";import{hasContextualPlace as B,contextualAct as D}from"../host/contextual-place.js";import{createHash as I}from"node:crypto";import{library11_actResultOf as M,library11_actResultProfile as W}from"../vendor/runtime.js";import{actLines as w,intactLocalAct as R,localActResult as G}from"../host/ports/local-act.js";import{storeOf as C}from"../land/ledger.js";import{lockStanding as K}from"../fold/keys.js";import{authorityFor as Q,writerFor as V}from"../fold/signers.js";import{eraOf as X}from"../fold/digests.js";import{fieldOf as l,isConfig as P,foldClaims as j,parsedLine as Y}from"../fold/claims.js";import{ownRecordAdmitted as Z}from"../fold/signed.js";import{admissionAnchor as ee,admissionHistoryAt as te}from"../fold/admission-history.js";import{fullDigest as re}from"../host/digest.js";import{wordOf as oe,wireLine as ie}from"../fold/wire.js";import{viewsOf as se}from"../fold/views.js";const z=new WeakMap;function ce(o,r,m,n,i){const a=I("sha256"),t=q.bind(void 0,a);t("legacy-act-historical-proof/1"),t(o),t(r.records),t(r.receipt),t(r.placements===void 0?"absent":"present"),t(String(r.placements?.length??0));for(const s of r.placements??[])t(s.place),t(s.records);t(String(m.length));for(const s of m)t(s);t(JSON.stringify(n)),t(String(i.length));for(const s of i)t(s);return a.digest("hex")}f(ce,"proofFingerprint");const H=f(o=>({...o,records:[...o.records]}),"freshResult");function ne(o,r){const m=C(o);let n;const i=G(m,r,(e,c)=>{const u=Y(c.receipt.trim());if(u.kind!=="fact")return R(e,c);const h=Number(l(c.receipt.trim(),"epoch")),g=te(o,h),A=g.filter(N=>!P(N)||Number(l(N,"epoch"))<h),F=X(j(A).standing).admitted,k=ee(o),U=ce(e,c,g,k,F),L=z.get(u.value),E=L?.fingerprint===U?L.result:void 0;return n={epoch:h,history:g,before:A,algorithms:F,anchor:k,key:u.value,fingerprint:U,...E?{retained:E}:{}},E!==void 0||R(e,c)});if(!i)throw Error("REFUSE\xB7act no committed result "+r);if(!n)throw Error("REFUSE\xB7act historical proof observation absent");const a=w(i.records),{epoch:t,history:s,before:J,algorithms:b,anchor:T,retained:O}=n;if(O)return{result:H(O),bundle:i,records:a,epoch:t,history:s};const d=Q(s,T,b),p=j(J.filter(e=>d.of(e).kind==="admitted")).standing,v=W(p);if(!v)throw Error("REFUSE\xB7act no result profile at admission");const _=d.admitted.some(e=>!e.coverage.includes("*"))?oe(p,"families","region"):"",S=r.slice(0,r.indexOf(":"));if(!l(ie(p,"digest-algorithms")??"","value").split("|").map(e=>e.split(":")[0]).includes(S))throw Error("REFUSE\xB7act digest algorithm was not admitted at commitment");const x=M(a,i.receipt.trim(),{...v,localEpoch:t,digest:f(e=>re(e,S),"digest"),placements:i.placements.map(e=>({place:e.place,records:w(e.records)})),admitsRecord:f(e=>P(e)&&Number(l(e,"epoch"))!==t?!1:i.placements.some(c=>w(c.records).includes(e)&&(c.place==="."?d.of(e).kind==="admitted":Z(e,c.place.slice(0,c.place.lastIndexOf("/")),_,d.admitted,b))),"admitsRecord"),verifiesReceipt:f(e=>l(e,"by")===V(p,"fold")&&R(r,i),"verifiesReceipt")}),y=Object.freeze({...x,records:Object.freeze([...x.records])});return z.set(n.key,{fingerprint:n.fingerprint,result:y}),{result:H(y),bundle:i,records:a,epoch:t,history:s}}f(ne,"verifiedLegacyActResult");function ye(o,r){const m=C(o),n=K(m),i=se(n).get("act");if(!i||i.shape||!i.regions.some(s=>s.name==="act"))throw Error("REFUSE\xB7view act requires an admitted result profile and act view");if(!r)throw Error("REFUSE\xB7act name one committed identity");if(B(o)){const s=D(o,r);if(s){process.stdout.write(JSON.stringify(s)+`
2
- `);return}}const{result:a,bundle:t}=ne(o,r);process.stdout.write(`ACT ${a.identity} \xB7 epoch ${a.epoch} \xB7 admitted \xB7 conformance not asserted
3
- `+t.records+t.receipt)}f(ye,"printActResult");export{ye as printActResult,ne as verifiedLegacyActResult};
1
+ var q=Object.defineProperty;var f=(o,r)=>q(o,"name",{value:r,configurable:!0});import{hostOutput as C}from"../host/call-context.js";import{hashText as B}from"../host/hash.js";import{hasContextualPlace as D,contextualAct as I}from"../host/contextual-place.js";import{createHash as M}from"node:crypto";import{library14_actResultOf as W,library14_actResultProfile as G}from"../vendor/runtime.js";import{actLines as R,intactLocalAct as w,localActResult as K}from"../host/ports/local-act.js";import{storeOf as P}from"../land/ledger.js";import{lockStanding as Q}from"../fold/keys.js";import{authorityFor as V,writerFor as X}from"../fold/signers.js";import{eraOf as Y}from"../fold/digests.js";import{fieldOf as l,isConfig as j,foldClaims as z,parsedLine as Z}from"../fold/claims.js";import{ownRecordAdmitted as tt}from"../fold/signed.js";import{admissionAnchor as et,admissionHistoryAt as rt}from"../fold/admission-history.js";import{fullDigest as ot}from"../host/digest.js";import{wordOf as it,wireLine as st}from"../fold/wire.js";import{viewsOf as ct}from"../fold/views.js";const H=new WeakMap;function nt(o,r,m,n,i){const a=M("sha256"),e=B.bind(void 0,a);e("legacy-act-historical-proof/1"),e(o),e(r.records),e(r.receipt),e(r.placements===void 0?"absent":"present"),e(String(r.placements?.length??0));for(const s of r.placements??[])e(s.place),e(s.records);e(String(m.length));for(const s of m)e(s);e(JSON.stringify(n)),e(String(i.length));for(const s of i)e(s);return a.digest("hex")}f(nt,"proofFingerprint");const J=f(o=>({...o,records:[...o.records]}),"freshResult");function at(o,r){const m=P(o);let n;const i=K(m,r,(t,c)=>{const u=Z(c.receipt.trim());if(u.kind!=="fact")return w(t,c);const h=Number(l(c.receipt.trim(),"epoch")),g=rt(o,h),A=g.filter(N=>!j(N)||Number(l(N,"epoch"))<h),F=Y(z(A).standing).admitted,k=et(o),U=nt(t,c,g,k,F),L=H.get(u.value),E=L?.fingerprint===U?L.result:void 0;return n={epoch:h,history:g,before:A,algorithms:F,anchor:k,key:u.value,fingerprint:U,...E?{retained:E}:{}},E!==void 0||w(t,c)});if(!i)throw Error("REFUSE\xB7act no committed result "+r);if(!n)throw Error("REFUSE\xB7act historical proof observation absent");const a=R(i.records),{epoch:e,history:s,before:T,algorithms:O,anchor:_,retained:b}=n;if(b)return{result:J(b),bundle:i,records:a,epoch:e,history:s};const d=V(s,_,O),p=z(T.filter(t=>d.of(t).kind==="admitted")).standing,v=G(p);if(!v)throw Error("REFUSE\xB7act no result profile at admission");const $=d.admitted.some(t=>!t.coverage.includes("*"))?it(p,"families","region"):"",S=r.slice(0,r.indexOf(":"));if(!l(st(p,"digest-algorithms")??"","value").split("|").map(t=>t.split(":")[0]).includes(S))throw Error("REFUSE\xB7act digest algorithm was not admitted at commitment");const x=W(a,i.receipt.trim(),{...v,localEpoch:e,digest:f(t=>ot(t,S),"digest"),placements:i.placements.map(t=>({place:t.place,records:R(t.records)})),admitsRecord:f(t=>j(t)&&Number(l(t,"epoch"))!==e?!1:i.placements.some(c=>R(c.records).includes(t)&&(c.place==="."?d.of(t).kind==="admitted":tt(t,c.place.slice(0,c.place.lastIndexOf("/")),$,d.admitted,O))),"admitsRecord"),verifiesReceipt:f(t=>l(t,"by")===X(p,"fold")&&w(r,i),"verifiesReceipt")}),y=Object.freeze({...x,records:Object.freeze([...x.records])});return H.set(n.key,{fingerprint:n.fingerprint,result:y}),{result:J(y),bundle:i,records:a,epoch:e,history:s}}f(at,"verifiedLegacyActResult");function Ft(o,r){const m=P(o),n=Q(m),i=ct(n).get("act");if(!i||i.shape||!i.regions.some(s=>s.name==="act"))throw Error("REFUSE\xB7view act requires an admitted result profile and act view");if(!r)throw Error("REFUSE\xB7act name one committed identity");if(D(o)){const s=I(o,r);if(s){C("out",JSON.stringify(s)+`
2
+ `);return}}const{result:a,bundle:e}=at(o,r);C("out",`ACT ${a.identity} \xB7 epoch ${a.epoch} \xB7 admitted \xB7 conformance not asserted
3
+ `+e.records+e.receipt)}f(Ft,"printActResult");export{Ft as printActResult,at as verifiedLegacyActResult};
package/dist/cli/args.js CHANGED
@@ -1,3 +1,3 @@
1
- var s=Object.defineProperty;var n=(t,e)=>s(t,"name",{value:e,configurable:!0});import{relative as l,sep as a}from"node:path";import{observeText as i}from"../observe/files.js";import{sourceOf as f}from"../observe/runner.js";import{library11_PROTOCOL as c,library11_parse as m}from"../vendor/runtime.js";import{FLAGS as u,VALUED as p}from"./names.js";function y(t){return l(t,f()).split(a).join("/")}n(y,"entryOf");function E(t,e){const r=t.indexOf(e);return r>=0?t[r+1]:void 0}n(E,"valueOf");const O=n((t,e)=>t.flatMap((r,o)=>r===e&&t[o+1]!==void 0?[t[o+1]]:[]),"valuesOf"),$=n(t=>O(t,u.place).map(e=>e.replace(/\/$/,"")),"namedPlaces");function d(t){const e=[];for(let r=0;r<t.length;r+=1){const o=t[r]??"";if(p.includes(o)){r+=1;continue}o.startsWith("--")||e.push(r)}return e}n(d,"positionalIndexes");function F(t){return d(t).map(e=>t[e])}n(F,"positionalsOf");const P=n(t=>(i(t)??"").split(`
1
+ var s=Object.defineProperty;var n=(t,e)=>s(t,"name",{value:e,configurable:!0});import{relative as l,sep as a}from"node:path";import{observeText as i}from"../observe/files.js";import{sourceOf as f}from"../observe/runner.js";import{library14_PROTOCOL as c,library14_parse as m}from"../vendor/runtime.js";import{FLAGS as u,VALUED as p}from"./names.js";function y(t){return l(t,f()).split(a).join("/")}n(y,"entryOf");function E(t,e){const r=t.indexOf(e);return r>=0?t[r+1]:void 0}n(E,"valueOf");const O=n((t,e)=>t.flatMap((r,o)=>r===e&&t[o+1]!==void 0?[t[o+1]]:[]),"valuesOf"),$=n(t=>O(t,u.place).map(e=>e.replace(/\/$/,"")),"namedPlaces");function d(t){const e=[];for(let r=0;r<t.length;r+=1){const o=t[r]??"";if(p.includes(o)){r+=1;continue}o.startsWith("--")||e.push(r)}return e}n(d,"positionalIndexes");function F(t){return d(t).map(e=>t[e])}n(F,"positionalsOf");const P=n(t=>(i(t)??"").split(`
2
2
  `).map(e=>e.trim()).filter(e=>e.startsWith("# place ")).map(e=>e.slice(8).trim().replace(/\/$/,"")).filter(Boolean),"placesOfFile");function R(t){const e=(i(t)??"").split(`
3
3
  `).map(r=>r.trim()).filter(r=>r.startsWith(`${c.split("/")[0]}/`));for(const r of e){const o=m(r);if(o.kind!=="fact")throw new Error(`REFUSE\xB7wire batch ${o.why} \xB7 nothing signed or landed`)}return e}n(R,"claimLinesIn");export{p as VALUED,R as claimLinesIn,y as entryOf,$ as namedPlaces,P as placesOfFile,d as positionalIndexes,F as positionalsOf,E as valueOf,O as valuesOf};
package/dist/cli/host.js CHANGED
@@ -1,4 +1,4 @@
1
- var m=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(o){throw e=0,o}};import{readFileSync as f}from"node:fs";import{resolve as a}from"node:path";import{pathToFileURL as d}from"node:url";import{library2_respond as l}from"../vendor/runtime.js";import{provide as u}from"../host/provide.js";var v=m(t=>{var p=t&&t.__rewriteRelativeImportExtension||function(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(o,c,s,i,n){return c?e?".jsx":".js":s&&(!i||!n)?o:s+i+"."+n.toLowerCase()+"js"}):r};(async()=>{try{u();const r=await import(p(d(a(process.argv[2]??"")).href)),e=a(process.argv[3]??process.argv[2]??"");process.stdout.write(`
1
+ var m=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(o){throw e=0,o}};import{readFileSync as f}from"node:fs";import{resolve as a}from"node:path";import{pathToFileURL as d}from"node:url";import{library5_respond as l}from"../vendor/runtime.js";import{provide as u}from"../host/provide.js";var v=m(t=>{var p=t&&t.__rewriteRelativeImportExtension||function(r,e){return typeof r=="string"&&/^\.\.?\//.test(r)?r.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(o,c,s,i,n){return c?e?".jsx":".js":s&&(!i||!n)?o:s+i+"."+n.toLowerCase()+"js"}):r};(async()=>{try{u();const r=await import(p(d(a(process.argv[2]??"")).href)),e=a(process.argv[3]??process.argv[2]??"");process.stdout.write(`
2
2
  ${l(typeof r.load=="function"?await r.load():r,f(0,"utf8"),e)}
3
3
  `)}catch(r){const e=(r instanceof Error?r.message:String(r)).replace(/\s+/g," ").trim();process.stderr.write(`LOAD index \xB7 module error \xB7 ${e}
4
4
  `),process.exitCode=1}})()});export default v();
@@ -1,3 +1,3 @@
1
- var k=Object.defineProperty;var d=(i,a)=>k(i,"name",{value:a,configurable:!0});import{sha256 as m}from"../host/hash.js";import{realpathSync as x}from"node:fs";import{library2_readingIdentityBytes as M}from"../vendor/runtime.js";import{readBoundedBatch as U}from"../host/native/bounded-file.js";import{inheritedNativeGuard as q,inheritedNativeRoot as C}from"../host/native/root.js";import{authenticateNativeProfile as F,loadSignedNativeReading as G,answerNativeReading as L}from"../host/native/reading.js";import{readingEnvironment as N}from"../host/reading-context.js";import{assertNativeRuntime as _}from"../host/native/runtime.js";import{nativeReferenceInputs as j}from"../host/native/references.js";const r=d(i=>{throw Error("REFUSE\xB7native dispatcher "+i)},"fail"),f=d(i=>[...i].sort(([a],[c])=>Buffer.compare(Buffer.from(a),Buffer.from(c))),"ordered");async function z(){const i={store:process.argv[2],parent:Number(process.argv[8]),expected:JSON.parse(process.argv[4])},a=process.argv[3],c=Number(process.argv[6]),p=process.argv[7],t=JSON.parse(process.argv[9]);p!=="act"&&r("effects forbidden during "+p),(!Number.isSafeInteger(c)||c<1)&&r("missing inherited input limit"),(!t?.context||!t.env||!Array.isArray(t.flags)||!t.cwd)&&r("missing complete inherited reading identity"),_(process.env,process.execArgv);const S=m(M(t.context));JSON.stringify(f(N(m,t.env,t.cwd,t.flags)))!==JSON.stringify(f(t.context.environment))&&r("inherited execution differs from context"),JSON.stringify(f(N(m)))!==JSON.stringify(f(t.context.environment))&&r("actual child environment differs from inherited identity");const l=[];let u=0;for await(const n of process.stdin){const s=Buffer.from(n);u+=s.length,u>c&&r("input bytes exceeded"),l.push(s)}const o=JSON.parse(Buffer.concat(l).toString("utf8")),w=C(i,o.proof),g=q(i,o.proof),h=F(w,a),e=h.profile,B=h.selection;t.context.implementation!==e.selection.archive&&r("reading implementation differs from selected archive"),(!Array.isArray(o.locations)||o.locations.length!==e.selection.members.length||o.locations.length>e.selection.budget.members)&&r("image member budget/count");const v=o.locations.find(n=>n.member===e.selection.runtime);(!v||x(v.path)!==x(process.execPath))&&r("runtime differs from executing interpreter"),j(t.context.inputs,e.selection.members.map(n=>["native/"+n.coordinate,n.digest]));const J=e.selection.members.map(n=>{const s=o.locations.filter(I=>I.member===n.coordinate);return s.length!==1?r("missing/ambiguous actual member "+n.coordinate):{path:s[0].path,coordinate:n.coordinate}}),y=U([...J,{path:o.archive,coordinate:"implementation archive"}],e.selection.budget.bytes),b=y.at(-1),O=e.selection.members.map((n,s)=>({...n,bytes:new Uint8Array(y[s])}));m(b)!==e.selection.archive&&r("implementation archive differs");const A={place:i.expected.namespace,instrument:t.context.instrument,policy:t.context.policy,authoritySnapshot:S,budget:e.selection.budget,members:O,bindings:e.selection.bindings,loads:e.selection.loads},P={cwd:t.cwd,locations:o.locations,runtime:e.selection.runtime,preload:e.selection.preload??void 0,nativePreloadMembers:e.selection.nativePreloadMembers,condition:e.selection.condition,commandPort:e.port},R=await G(B,{profile:e,handoff:A,image:P,archive:b},g),E=await L(R,o.requests,e.selection.reader,{phase:"act",guard:g});process.stdout.write(JSON.stringify(E)+`
1
+ var k=Object.defineProperty;var d=(i,a)=>k(i,"name",{value:a,configurable:!0});import{sha256 as m}from"../host/hash.js";import{realpathSync as x}from"node:fs";import{library5_readingIdentityBytes as M}from"../vendor/runtime.js";import{readBoundedBatch as U}from"../host/native/bounded-file.js";import{inheritedNativeGuard as q,inheritedNativeRoot as C}from"../host/native/root.js";import{authenticateNativeProfile as F,loadSignedNativeReading as G,answerNativeReading as L}from"../host/native/reading.js";import{readingEnvironment as N}from"../host/reading-context.js";import{assertNativeRuntime as _}from"../host/native/runtime.js";import{nativeReferenceInputs as j}from"../host/native/references.js";const r=d(i=>{throw Error("REFUSE\xB7native dispatcher "+i)},"fail"),f=d(i=>[...i].sort(([a],[c])=>Buffer.compare(Buffer.from(a),Buffer.from(c))),"ordered");async function z(){const i={store:process.argv[2],parent:Number(process.argv[8]),expected:JSON.parse(process.argv[4])},a=process.argv[3],c=Number(process.argv[6]),p=process.argv[7],t=JSON.parse(process.argv[9]);p!=="act"&&r("effects forbidden during "+p),(!Number.isSafeInteger(c)||c<1)&&r("missing inherited input limit"),(!t?.context||!t.env||!Array.isArray(t.flags)||!t.cwd)&&r("missing complete inherited reading identity"),_(process.env,process.execArgv);const S=m(M(t.context));JSON.stringify(f(N(m,t.env,t.cwd,t.flags)))!==JSON.stringify(f(t.context.environment))&&r("inherited execution differs from context"),JSON.stringify(f(N(m)))!==JSON.stringify(f(t.context.environment))&&r("actual child environment differs from inherited identity");const l=[];let u=0;for await(const n of process.stdin){const s=Buffer.from(n);u+=s.length,u>c&&r("input bytes exceeded"),l.push(s)}const o=JSON.parse(Buffer.concat(l).toString("utf8")),w=C(i,o.proof),g=q(i,o.proof),h=F(w,a),e=h.profile,B=h.selection;t.context.implementation!==e.selection.archive&&r("reading implementation differs from selected archive"),(!Array.isArray(o.locations)||o.locations.length!==e.selection.members.length||o.locations.length>e.selection.budget.members)&&r("image member budget/count");const v=o.locations.find(n=>n.member===e.selection.runtime);(!v||x(v.path)!==x(process.execPath))&&r("runtime differs from executing interpreter"),j(t.context.inputs,e.selection.members.map(n=>["native/"+n.coordinate,n.digest]));const J=e.selection.members.map(n=>{const s=o.locations.filter(I=>I.member===n.coordinate);return s.length!==1?r("missing/ambiguous actual member "+n.coordinate):{path:s[0].path,coordinate:n.coordinate}}),y=U([...J,{path:o.archive,coordinate:"implementation archive"}],e.selection.budget.bytes),b=y.at(-1),O=e.selection.members.map((n,s)=>({...n,bytes:new Uint8Array(y[s])}));m(b)!==e.selection.archive&&r("implementation archive differs");const A={place:i.expected.namespace,instrument:t.context.instrument,policy:t.context.policy,authoritySnapshot:S,budget:e.selection.budget,members:O,bindings:e.selection.bindings,loads:e.selection.loads},P={cwd:t.cwd,locations:o.locations,runtime:e.selection.runtime,preload:e.selection.preload??void 0,nativePreloadMembers:e.selection.nativePreloadMembers,condition:e.selection.condition,commandPort:e.port},R=await G(B,{profile:e,handoff:A,image:P,archive:b},g),E=await L(R,o.requests,e.selection.reader,{phase:"act",guard:g});process.stdout.write(JSON.stringify(E)+`
2
2
  `)}d(z,"run"),z().catch(i=>{process.stderr.write((i instanceof Error?i.message:String(i))+`
3
3
  `),process.exitCode=1});
package/dist/cli/pass.js CHANGED
@@ -1,21 +1,22 @@
1
- var Re=Object.defineProperty;var w=(e,d)=>Re(e,"name",{value:d,configurable:!0});import{mkdirSync as De,rmSync as Pe}from"node:fs";import{dirname as xe,join as C,resolve as Le}from"node:path";import{Worker as Ce}from"node:worker_threads";import{library11_ENVELOPE as ye,library11_canonical as re,library11_parse as ie}from"../vendor/runtime.js";import{foldPlace as oe,standingOf as b}from"./place.js";import{fieldOf as k,selfName as j}from"../fold/claims.js";import{observedClaims as ae}from"../fold/observed.js";import{layReleases as Ie,resolvedOf as Me}from"../host/release.js";import{ownLock as P,ownRoot as Ae,processOf as Fe}from"../observe/runner.js";import{landLaid as Te}from"../fold/laid.js";import{actSeconds as de,closeReceipts as We,idleCount as Ne,instrumentKeep as Ue,instrumentKept as ce,meets as x,noteIdle as Ve,receiptPlaces as fe,receiptsSeen as F}from"../fold/closed.js";import{algorithmCost as _e,instrumentOf as q,instrumentDigest as Ke}from"../fold/digests.js";import{writerFor as le}from"../fold/signers.js";import{defaulted as Ge,placesOf as z,viewsOf as B}from"../fold/views.js";import{ownLockOf as me}from"../fold/signed.js";import{localDirectoriesIn as je,worldAt as pe,worldsIn as qe}from"../fold/places.js";import{wordsOf as ue}from"../fold/wire.js";import{land as ze,ledgerLines as Be,replaceWhole as He,storeOf as E}from"../land/ledger.js";import{holdRoot as Je,holds as Qe,underTheLock as he}from"../land/act.js";import{emptyLedger as H,sayStranger as Xe}from"../fold/stranger.js";import{observeFile as Ye,observeText as R}from"../observe/files.js";import{render as Ze,renderedOf as es,unrendered as ss,viewOf as ts}from"../render/view.js";import{releasePolicyLines as ns}from"../fold/release-policy.js";import{carriedFrom as rs}from"../fold/resolved.js";import{wireLine as is}from"../fold/wire.js";import{isWire as os,RECEIPTS as as}from"../fold/claims.js";import{withoutEffects as ds}from"../host/read-only.js";import{assertNativeReaderGrantsCurrent as cs}from"../host/native/route.js";async function we(e,d,t){const m=Date.now(),c=E(e);if(!x(e,c,t??"",!1))return process.stderr.write(`${j()}: REFUSE\xB7check receipts are open; a fold must close them
2
- `),1;const u=is(P(),"receipt-instrument"),r=rs(c,(R(C(e,t??"",as))??"").split(`
3
- `).filter(os)),f=u===void 0?void 0:r?.find(W=>k(W,"scope")===k(u,"value")&&k(W,"measure")==="digest"),l=f===void 0?ce(c):k(f,"value");if(!l)return process.stderr.write(`${j()}: REFUSE\xB7check no verified instrument identity is available for these receipts
4
- `),1;const o=H(c)?me(e,t?.replace(/\/$/,"")??""):b(e).standing,S=f===void 0?q(c,d,o,e,P()):Ke(c,Le(e,d),[],Ae(),P());if(l!==S)return process.stderr.write(`${j()}: REFUSE\xB7check receipt instrument differs; a fold must close it
5
- `),1;const T=F(),D=Date.now()-m;t===void 0?process.stderr.write(`RECEIPTS ${T.count||fe(e,c).length} read \xB7 0 opened \xB7 ${D} ms
6
- `):process.stderr.write(`CLOSED ${t} \xB7 ${D} ms
7
- `);const J=de();return process.stderr.write(`COST act ${J} s
8
- `),process.stdout.write(`PASS closed \xB7 ${t?1:fe(e,c).length} places \xB7 ${D} ms
9
- `),0}w(we,"checked");async function Ks(e,d,t,m){if(m)return ds(()=>H(E(e))?we(e,d,t):he(E(e),"check",()=>we(e,d,t)));if(!t&&H(E(e)))return Xe(e),0;const c=Date.now(),u=w(async()=>{const r=await ls(e,d,t,m,[]);for(const o of m?r.written:[])process.stdout.write(`DIFFERS ${o}
10
- `);r.written.length||await We(e,E(e));const f=oe(e,d,t,!1,{standing:r.standingAt.get(t??"")??b(e,t),...r.settled?{}:{observed:r.observed.length?r.observed:ae(e,E(e),{wait:!1})},free:!r.settled}),l=x(e,E(e),t??"",!0,f.observed)&&!r.written.length;for(const o of ns(f.release))process.stdout.write(`${o}
11
- `);return l?(Ue(E(e),q(E(e),d,b(e).standing,e,P())),process.stdout.write(`PASS closed \xB7 ${r.places} places \xB7 ${Date.now()-c} ms
12
- `),0):(process.stdout.write(`PASS ${r.same+r.written.length} renders \xB7 ${r.same} same${r.written.length?` \xB7 ${r.written.length} ${m?"differ":"still written after three rounds"}`:""} \xB7 ${r.places} places \xB7 ${Date.now()-c} ms
13
- `),process.stdout.write(Ze(f,[{name:"programs",at:1}])),r.written.length?1:0)},"run");return he(E(e),"pass",u)}w(Ks,"pass");function fs(e,d,t){if(d===void 0||!t.length)return;const m=w(r=>(f=>f.kind==="fact"?re(Object.fromEntries(Object.entries(f.value.fields).filter(([l])=>!ye.has(l)&&l!=="by"))):r)(ie(r)),"bare"),c=new Set(Be(e,d).filter(r=>/(?:^|\s)scope=re(?:ndered|solved)\//.test(r)).map(m)),u=[...new Set(t.filter(r=>!c.has(m(r))).map(r=>(f=>f.kind==="fact"?re({...f.value.fields,by:d}):r)(ie(r))))];u.length&&ze(e,d,u)}w(fs,"landSaid");async function ls(e,d,t,m,c,u,r,f,l){const o=E(e),S=Date.now(),T=c.length===0&&l===void 0&&x(e,o,t??""),D=ce(o)===q(o,d,b(e).standing,e,P());if(T&&D&&!w(()=>{if(!t||!pe(e,t.replace(/\/$/,"")))return!1;const s=b(e,t),a=B(s.standing);return ue(s.standing,"views/world").some(h=>{const i=a.get(h);return i?.shape!==void 0&&i.shape!==""&&R(C(e,t,i.shape))===void 0})},"missingView")()){cs(o);const s=Date.now()-S,a=F(),h=_e(),i=Math.max(0,s-h);h>0&&(Ve(),process.stderr.write(`RED fold/idle \xB7 ${Ne()} \xB7 lock ${h} ms \xB7 hash ${i} ms \xB7 a fold over a closed region
14
- `)),t===void 0?process.stderr.write(`RECEIPTS ${a.count} read \xB7 0 opened \xB7 ${s} ms
15
- `):process.stderr.write(`CLOSED ${t} \xB7 lock ${h} ms \xB7 hash ${i} ms
16
- `);const p=de();return process.stderr.write(`COST act ${p} s
17
- `),{same:0,written:[],places:t===void 0?a.count:1,observed:[],standingAt:new Map,folds:new Map,said:[],settled:!0}}const g=b(e,void 0,c);Ie(o,e,g.standing,o);const O=l??(t?[t.replace(/\/$/,"")]:void 0),y=O!==void 0,N=r??ae(e,o,{wait:!0,...O!==void 0?{reach:O}:{}});Te(o,e,g.standing,le(g.standing,"fold"));const Q=w(s=>[...B(s).values()].flatMap(a=>"regions"in a&&a.shape?[a]:[]),"shaped"),X=Q(g.standing),ge=B(g.lock),U=ue(g.standing,"views/world"),Y=new Set(qe(e).map(s=>`${s}/`)),$e=w(s=>{const a=z(g.standing,s);if(!U.includes(s.name))return a;const h=a.filter(i=>Y.has(i));return h.length?h:[...Y]},"resolved"),Ee=X.filter(s=>!U.includes(s.name)&&!z(g.standing,s).length),Se=je(e).filter(s=>Ee.some(a=>R(C(e,s,a.shape))!==void 0)).map(s=>`${s}/`),Z=w(s=>!y||O.some(a=>a===""||s===`${a}/`||s.startsWith(`${a}/`)),"descended"),ve=y?O.filter(s=>s!=="").map(s=>s.endsWith("/")?s:`${s}/`):[],V=[...new Set([...X.flatMap($e),...Se,...ve])].filter(s=>s!==""&&(!t||s.startsWith(t))&&Z(s)).sort(),_=new Map([...V,""].map(s=>[s,s?b(e,s,c):g])),K=w(s=>{const{standing:a}=_.get(s)??g,h=Q(a),i=pe(e,s.slice(0,-1))?me(e,s.slice(0,-1)):[],p=w($=>z(a,$),"namedOf");return h.filter($=>p($).includes(s)||i.length>0&&Ge(a,$,i,ge)||!U.includes($.name)&&!p($).length&&R(C(e,s,$.shape))!==void 0&&!h.some(n=>n.shape===$.shape&&p(n).includes(s)))},"writes");let L=0,v=[];const Oe=new Set(P().filter(s=>k(s,"scope").startsWith("region/")&&k(s,"measure")==="lines").flatMap(s=>k(s,"value").split("|"))),be=w(s=>y?Z(s):!D||!x(e,o,s),"free"),ee=new Map,se=new Map,te=w((s,a,h)=>{for(const i of a){if(i.missing.length)throw new Error(`REFUSE\xB7view at ${s||"."} \xB7 asks regions nothing renders: ${i.missing.join(" ")}`);!m&&i.said.length&&se.set(`${s}${i.shape}`,i.said);const p=C(e,s,i.shape),$=["s","v","g"].join("");if(i.shape.endsWith(`.${$}`)&&!i.text.includes(`<${$}`)){!m&&R(p)!==void 0&&(Pe(p,{force:!0}),v.push(`${s}${i.shape}`));continue}if(R(p)===i.text)L+=1;else if(m)v.push(`${s}${i.shape}`);else{h.at||(h.at=R(p)===void 0||Oe.has(i.shape));const n=u!==void 0&&!u.has(p)?Ye(p):void 0,I=De(xe(p),{recursive:!0});u!==void 0&&!u.has(p)&&u.set(p,{held:n,made:I}),He(p,i.text),v.push(`${s}${i.shape}`)}}},"paint");for(let s=1;s<=3;s+=1){v=[],L=0;const a={at:!1},h=[...V,...t||y&&O.length>0&&!O.includes("")?[]:[""]],i=h.filter(n=>be(n));for(const n of h)i.includes(n)||(L+=K(n).length);if(!t&&s===1){F().count||x(e,o,"");const n=F();process.stderr.write(`RECEIPTS ${n.count} read \xB7 ${i.length} opened \xB7 ${n.ms} ms
18
- `)}i.length&&process.stderr.write(`OPEN ${i.map(n=>n||".").join(" ")}
19
- `);const p=i.filter(n=>n!==""&&!f?.has(n)&&!x(e,o,n)),$=p.length>1?await ms(p.map(n=>({root:e,entry:d,place:n,told:c,observed:N,views:K(n)}))):new Map;for(const n of i){if(!m&&n===""&&await Je(o,"join"),!m&&!Qe(o,n)){process.stderr.write(`OUTSIDE ${n} \xB7 not settled, and no region this act holds: the next pass renders it
20
- `);continue}const I=$.get(n);if(I!==void 0){te(n,I,a);continue}const ke=_.get(n)??g,M=oe(e,d,n||void 0,!1,{standing:ke,observed:N,free:!0});f?.has(n)&&ee.set(n,M),te(n,K(n).map(A=>{const G=ss(M,A);return{shape:A.shape,missing:G,text:G.length?"":ts(M,A),said:G.length?[]:es(M,A)}}),a)}if(m||!v.length)break;for(const n of v)process.stdout.write(`RENDERED ${n} \xB7 round ${s}
21
- `);if(!a.at){L+=v.length,v=[];break}}const ne=[...se.values()].flat();return!m&&u===void 0&&fs(o,le(g.standing,"fold"),[...Me(o,e,g.standing,o),...ne]),{same:L,written:v,places:V.length+(t?0:1),observed:N,standingAt:_,folds:ee,said:u===void 0?[]:ne,settled:!1}}w(ls,"sweep");function ms(e){const d=new Map;return e.length<2?Promise.resolve(d):new Promise((t,m)=>{const c=[];let u=e.length,r=!1;const f=w(l=>{if(!r){r=!0,m(l);for(const o of c)o.terminate()}},"refuse");try{for(const l of e){const o=new Ce(Fe("fold-worker","fold"),{execArgv:process.execArgv,workerData:l});c.push(o),o.on("message",S=>d.set(S.place,S.texts)),o.on("error",f),o.on("exit",S=>{if(!r){if(S!==0||!d.has(l.place)){f(new Error(`REFUSE\xB7worker ${l.place} \xB7 exit ${S} \xB7 no completed render`));return}u-=1,u===0&&t(d)}})}}catch(l){f(l instanceof Error?l:new Error(String(l)))}})}w(ms,"drawParallel");export{fs as landSaid,Ks as pass};
1
+ var ye=Object.defineProperty;var h=(e,c)=>ye(e,"name",{value:c,configurable:!0});import{traceWork as I,withWorkTrace as Ce}from"../host/work-trace.js";import{actCosts as Le}from"../host/act-cost.js";import{hostOutput as m}from"../host/call-context.js";import{mkdirSync as Ae,rmSync as Ie}from"node:fs";import{dirname as Te,join as T,resolve as Fe}from"node:path";import{Worker as We}from"node:worker_threads";import{library14_ENVELOPE as Ne,library14_canonical as fe,library14_parse as le}from"../vendor/runtime.js";import{foldPlace as me,standingOf as P,currentJudgment as Ue}from"./place.js";import{fieldOf as R,selfName as z}from"../fold/claims.js";import{observedClaims as pe}from"../fold/observed.js";import{layReleases as Ve,resolvedOf as _e}from"../host/release.js";import{ownLock as M,ownRoot as Je,processOf as Ke}from"../observe/runner.js";import{landLaid as je}from"../fold/laid.js";import{actSeconds as ue,closeReceipts as Ge,idleCount as qe,instrumentKeep as ze,instrumentKept as he,meets as y,noteIdle as Be,receiptPlaces as ge,receiptsSeen as N}from"../fold/closed.js";import{algorithmCost as He,instrumentOf as B,instrumentDigest as Qe}from"../fold/digests.js";import{writerFor as we}from"../fold/signers.js";import{defaulted as Xe,placesOf as H,viewsOf as Q}from"../fold/views.js";import{ownLockOf as $e}from"../fold/signed.js";import{localDirectoriesIn as Ye,worldAt as Ee,worldsIn as Ze}from"../fold/places.js";import{wordsOf as ve}from"../fold/wire.js";import{land as es,ledgerLines as ss,replaceWhole as ns,storeOf as v}from"../land/ledger.js";import{holdRoot as ts,holds as rs,underTheLock as Se}from"../land/act.js";import{emptyLedger as X,sayStranger as is}from"../fold/stranger.js";import{observeFile as as,observeText as x}from"../observe/files.js";import{render as os,renderedOf as ds,unrendered as cs,viewOf as fs}from"../render/view.js";import{releasePolicyLines as ls}from"../fold/release-policy.js";import{carriedFrom as ms}from"../fold/resolved.js";import{wireLine as ps}from"../fold/wire.js";import{isWire as us,RECEIPTS as hs}from"../fold/claims.js";import{withoutEffects as gs}from"../host/read-only.js";import{assertNativeReaderGrantsCurrent as ws}from"../host/native/route.js";async function Oe(e,c,t){const p=Date.now(),l=v(e);if(!y(e,l,t??"",!1))return m("error",`${z()}: REFUSE\xB7check receipts are open; a fold must close them
2
+ `),1;const g=ps(M(),"receipt-instrument"),n=ms(l,(x(T(e,t??"",hs))??"").split(`
3
+ `).filter(us)),d=g===void 0?void 0:n?.find(V=>R(V,"scope")===R(g,"value")&&R(V,"measure")==="digest"),f=d===void 0?he(l):R(d,"value");if(!f)return m("error",`${z()}: REFUSE\xB7check no verified instrument identity is available for these receipts
4
+ `),1;const a=X(l)?$e(e,t?.replace(/\/$/,"")??""):P(e).standing,S=d===void 0?B(l,c,a,e,M()):Qe(l,Fe(e,c),[],Je(),M());if(f!==S)return m("error",`${z()}: REFUSE\xB7check receipt instrument differs; a fold must close it
5
+ `),1;const U=N(),D=Date.now()-p;t===void 0?m("error",`RECEIPTS ${U.count||ge(e,l).length} read \xB7 0 opened \xB7 ${D} ms
6
+ `):m("error",`CLOSED ${t} \xB7 ${D} ms
7
+ `);const Y=ue();return m("error",`COST act ${Y} s
8
+ `),m("out",`PASS closed \xB7 ${t?1:ge(e,l).length} places \xB7 ${D} ms
9
+ `),0}h(Oe,"checked");async function Zs(e,c,t,p){if(p)return gs(()=>X(v(e))?Oe(e,c,t):Se(v(e),"check",()=>Oe(e,c,t)));if(!t&&X(v(e)))return is(e),0;const l=Date.now(),g=h(async()=>{const n=await I("pass/sweep",()=>Es(e,c,t,p,[]));for(const a of p?n.written:[])m("out",`DIFFERS ${a}
10
+ `);n.written.length||await I("pass/seal",()=>Ge(e,v(e)));let d=me(e,c,t,!1,{standing:n.standingAt.get(t??"")??P(e,t),...n.settled?{}:{observed:n.observed.length?n.observed:pe(e,v(e),{wait:!1})},free:!n.settled});const f=y(e,v(e),t??"",!0,d.observed)&&!n.written.length;d=I("pass/final-judgement",()=>({...Ue(d),kept:d.kept}));for(const a of ls(d.release))m("out",`${a}
11
+ `);return f?(ze(v(e),B(v(e),c,P(e).standing,e,M())),m("out",`PASS closed \xB7 ${n.places} places \xB7 ${Date.now()-l} ms
12
+ `),0):(m("out",`PASS ${n.same+n.written.length} renders \xB7 ${n.same} same${n.written.length?` \xB7 ${n.written.length} ${p?"differ":"still written after three rounds"}`:""} \xB7 ${n.places} places \xB7 ${Date.now()-l} ms
13
+ `),m("out",os(d,[{name:"programs",at:1}])),n.written.length?1:0)},"run");return Ce(()=>Se(v(e),"pass",g),n=>{const d=Le.measurement(),f=Math.max(0,d.elapsedMilliseconds-n.totalMilliseconds);m("error","SPENT pass "+JSON.stringify({...n,scope:"full native pass; read-only views and check remain unchanged",beforePassMilliseconds:f,accountedActElapsedMilliseconds:n.exclusiveMilliseconds+f,act:d})+`
14
+ `)})}h(Zs,"pass");function $s(e,c,t){if(c===void 0||!t.length)return;const p=h(n=>(d=>d.kind==="fact"?fe(Object.fromEntries(Object.entries(d.value.fields).filter(([f])=>!Ne.has(f)&&f!=="by"))):n)(le(n)),"bare"),l=new Set(ss(e,c).filter(n=>/(?:^|\s)scope=re(?:ndered|solved)\//.test(n)).map(p)),g=[...new Set(t.filter(n=>!l.has(p(n))).map(n=>(d=>d.kind==="fact"?fe({...d.value.fields,by:c}):n)(le(n))))];g.length&&es(e,c,g)}h($s,"landSaid");async function Es(e,c,t,p,l,g,n,d,f){const a=v(e),S=Date.now(),U=l.length===0&&f===void 0&&y(e,a,t??""),D=he(a)===B(a,c,P(e).standing,e,M());if(U&&D&&!h(()=>{if(!t||!Ee(e,t.replace(/\/$/,"")))return!1;const s=P(e,t),o=Q(s.standing);return ve(s.standing,"views/world").some(w=>{const i=o.get(w);return i?.shape!==void 0&&i.shape!==""&&x(T(e,t,i.shape))===void 0})},"missingView")()){ws(a);const s=Date.now()-S,o=N(),w=He(),i=Math.max(0,s-w);w>0&&(Be(),m("error",`RED fold/idle \xB7 ${qe()} \xB7 lock ${w} ms \xB7 hash ${i} ms \xB7 a fold over a closed region
15
+ `)),t===void 0?m("error",`RECEIPTS ${o.count} read \xB7 0 opened \xB7 ${s} ms
16
+ `):m("error",`CLOSED ${t} \xB7 lock ${w} ms \xB7 hash ${i} ms
17
+ `);const u=ue();return m("error",`COST act ${u} s
18
+ `),{same:0,written:[],places:t===void 0?o.count:1,observed:[],standingAt:new Map,folds:new Map,said:[],settled:!0}}const $=P(e,void 0,l);Ve(a,e,$.standing,a);const b=f??(t?[t.replace(/\/$/,"")]:void 0),F=b!==void 0,_=n??pe(e,a,{wait:!0,...b!==void 0?{reach:b}:{}});je(a,e,$.standing,we($.standing,"fold"));const Z=h(s=>[...Q(s).values()].flatMap(o=>"regions"in o&&o.shape?[o]:[]),"shaped"),ee=Z($.standing),ke=Q($.lock),J=ve($.standing,"views/world"),se=new Set(Ze(e).map(s=>`${s}/`)),be=h(s=>{const o=H($.standing,s);if(!J.includes(s.name))return o;const w=o.filter(i=>se.has(i));return w.length?w:[...se]},"resolved"),Pe=ee.filter(s=>!J.includes(s.name)&&!H($.standing,s).length),Re=Ye(e).filter(s=>Pe.some(o=>x(T(e,s,o.shape))!==void 0)).map(s=>`${s}/`),ne=h(s=>!F||b.some(o=>o===""||s===`${o}/`||s.startsWith(`${o}/`)),"descended"),xe=F?b.filter(s=>s!=="").map(s=>s.endsWith("/")?s:`${s}/`):[],K=[...new Set([...ee.flatMap(be),...Re,...xe])].filter(s=>s!==""&&(!t||s.startsWith(t))&&ne(s)).sort(),j=new Map([...K,""].map(s=>[s,s?P(e,s,l):$])),G=h(s=>{const{standing:o}=j.get(s)??$,w=Z(o),i=Ee(e,s.slice(0,-1))?$e(e,s.slice(0,-1)):[],u=h(E=>H(o,E),"namedOf");return w.filter(E=>u(E).includes(s)||i.length>0&&Xe(o,E,i,ke)||!J.includes(E.name)&&!u(E).length&&x(T(e,s,E.shape))!==void 0&&!w.some(r=>r.shape===E.shape&&u(r).includes(s)))},"writes");let C=0,O=[];const De=new Set(M().filter(s=>R(s,"scope").startsWith("region/")&&R(s,"measure")==="lines").flatMap(s=>R(s,"value").split("|"))),Me=h(s=>F?ne(s):!D||!y(e,a,s),"free"),te=new Map,re=new Map,ie=h((s,o,w)=>{for(const i of o){if(i.missing.length)throw new Error(`REFUSE\xB7view at ${s||"."} \xB7 asks regions nothing renders: ${i.missing.join(" ")}`);!p&&i.said.length&&re.set(`${s}${i.shape}`,i.said);const u=T(e,s,i.shape),E=["s","v","g"].join("");if(i.shape.endsWith(`.${E}`)&&!i.text.includes(`<${E}`)){!p&&x(u)!==void 0&&(Ie(u,{force:!0}),O.push(`${s}${i.shape}`));continue}if(x(u)===i.text)C+=1;else if(p)O.push(`${s}${i.shape}`);else{w.at||(w.at=x(u)===void 0||De.has(i.shape));const r=g!==void 0&&!g.has(u)?as(u):void 0,L=Ae(Te(u),{recursive:!0});g!==void 0&&!g.has(u)&&g.set(u,{held:r,made:L}),ns(u,i.text),O.push(`${s}${i.shape}`)}}},"paint");for(let s=1;s<=3;s+=1){O=[],C=0;const o={at:!1},w=[...K,...t||F&&b.length>0&&!b.includes("")?[]:[""]],i=w.filter(r=>Me(r));for(const r of w)i.includes(r)||(C+=G(r).length);if(!t&&s===1){N().count||y(e,a,"");const r=N();m("error",`RECEIPTS ${r.count} read \xB7 ${i.length} opened \xB7 ${r.ms} ms
19
+ `)}i.length&&m("error",`OPEN ${i.map(r=>r||".").join(" ")}
20
+ `);const u=i.filter(r=>r!==""&&!d?.has(r)&&!y(e,a,r)),E=u.length>1?await vs(u.map(r=>({root:e,entry:c,place:r,told:l,observed:_,views:G(r).filter(L=>!L.regions.some(q=>q.name==="receipts"))}))):new Map;for(const r of i){if(!p&&r===""&&await ts(a,"join"),!p&&!rs(a,r)){m("error",`OUTSIDE ${r} \xB7 not settled, and no region this act holds: the next pass renders it
21
+ `);continue}const L=E.get(r),q=j.get(r)??$,W=me(e,c,r||void 0,!1,{standing:q,observed:_,free:!0});d?.has(r)&&te.set(r,W);const oe=G(r),de=h(k=>k.regions.some(A=>A.name==="receipts"),"isReceipt"),ce=h(k=>{const A=cs(W,k);return{shape:k.shape,missing:A,text:A.length?"":fs(W,k),said:A.length?[]:ds(W,k)}},"draw");I("pass/ordinary-leaves",()=>ie(r,L??oe.filter(k=>!de(k)).map(ce),o)),I("pass/receipt-leaves",()=>ie(r,oe.filter(de).map(ce),o))}if(p||!O.length)break;for(const r of O)m("out",`RENDERED ${r} \xB7 round ${s}
22
+ `);if(!o.at){C+=O.length,O=[];break}}const ae=[...re.values()].flat();return!p&&g===void 0&&$s(a,we($.standing,"fold"),[..._e(a,e,$.standing,a),...ae]),{same:C,written:O,places:K.length+(t?0:1),observed:_,standingAt:j,folds:te,said:g===void 0?[]:ae,settled:!1}}h(Es,"sweep");function vs(e){const c=new Map;return e.length<2?Promise.resolve(c):new Promise((t,p)=>{const l=[];let g=e.length,n=!1;const d=h(f=>{if(!n){n=!0,p(f);for(const a of l)a.terminate()}},"refuse");try{for(const f of e){const a=new We(Ke("fold-worker","fold"),{execArgv:process.execArgv,workerData:f});l.push(a),a.on("message",S=>c.set(S.place,S.texts)),a.on("error",d),a.on("exit",S=>{if(!n){if(S!==0||!c.has(f.place)){d(new Error(`REFUSE\xB7worker ${f.place} \xB7 exit ${S} \xB7 no completed render`));return}g-=1,g===0&&t(c)}})}}catch(f){d(f instanceof Error?f:new Error(String(f)))}})}h(vs,"drawParallel");export{$s as landSaid,Zs as pass};