@iowarp/clio-coder 0.3.6 → 0.3.8

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 (323) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +22 -6
  3. package/dist/{acp-2BEHC4DL.js → acp-U67UHUK2.js} +14 -14
  4. package/dist/{agents-LNNFTM53.js → agents-YU6SGALZ.js} +42 -35
  5. package/dist/assets/codewiki.json +1 -1
  6. package/dist/{auth-KXXFI2VS.js → auth-5ZPJOIVG.js} +32 -24
  7. package/dist/builtins-C6JMZVV6.js +17 -0
  8. package/dist/{chunk-E25LMLRW.js → chunk-26LEYJZH.js} +2 -2
  9. package/dist/{chunk-TSHXZTOQ.js → chunk-2HEJ2F35.js} +5 -5
  10. package/dist/{chunk-PBTHKCPN.js → chunk-2HFZQUHL.js} +7 -7
  11. package/dist/{chunk-FO5ZOVUY.js → chunk-3BINW3FP.js} +5 -5
  12. package/dist/{chunk-4OC57DA6.js → chunk-4DGYLA73.js} +53 -2
  13. package/dist/{chunk-CKXWIANG.js → chunk-4SPRNWDE.js} +18 -16
  14. package/dist/{chunk-E2ER4LJF.js → chunk-5C3AQNDW.js} +25 -1
  15. package/dist/{chunk-XF5N4U5A.js → chunk-5DHKRSMQ.js} +9 -8
  16. package/dist/{chunk-43AOLP7E.js → chunk-5FR74PWO.js} +2 -1
  17. package/dist/{chunk-EKY57CSP.js → chunk-5H3GB5BO.js} +68 -772
  18. package/dist/{chunk-6XXKFVSN.js → chunk-5Q2VVUKB.js} +4 -4
  19. package/dist/{chunk-DJVECN66.js → chunk-7RFXX52T.js} +295 -3705
  20. package/dist/{chunk-ZXF4XRKW.js → chunk-7RGZWPB6.js} +158 -8
  21. package/dist/{chunk-FYYLNIL5.js → chunk-A2NJGIB3.js} +2 -2
  22. package/dist/{chunk-XXQNGV4M.js → chunk-A3WNZD3P.js} +548 -72
  23. package/dist/{chunk-VEZEGCGW.js → chunk-B5CSFE7B.js} +23 -21
  24. package/dist/{chunk-2SFS6XQE.js → chunk-DGSYXYMX.js} +3 -2
  25. package/dist/chunk-DR52UMZW.js +21 -0
  26. package/dist/{chunk-ZWLZP4ZT.js → chunk-DYIM5TJT.js} +98 -12
  27. package/dist/{chunk-QKMUKYO7.js → chunk-E77JEWSD.js} +270 -125
  28. package/dist/{chunk-LYF7OHWH.js → chunk-EMYUUSFG.js} +12 -467
  29. package/dist/{chunk-4VP4KH3K.js → chunk-EQ63NRB7.js} +8 -8
  30. package/dist/chunk-FBVTI2TJ.js +518 -0
  31. package/dist/{chunk-R46L2BIR.js → chunk-FHJEP5SW.js} +19 -25
  32. package/dist/{chunk-WR67VIZY.js → chunk-GN57SG4G.js} +66 -8
  33. package/dist/{chunk-RD5U66HV.js → chunk-GPIEI3LY.js} +9 -9
  34. package/dist/{chunk-PCZJO5TI.js → chunk-GU2UIAFZ.js} +13 -178
  35. package/dist/chunk-GWS3VEIW.js +195 -0
  36. package/dist/chunk-H7IXIC72.js +103 -0
  37. package/dist/{chunk-3BPUFZDL.js → chunk-HLE42MG7.js} +3 -3
  38. package/dist/{chunk-24I7BN55.js → chunk-IFBNV6H6.js} +3 -3
  39. package/dist/{chunk-QNQHSOLF.js → chunk-IGWKHNIQ.js} +114 -55
  40. package/dist/chunk-IIZWH4XA.js +172 -0
  41. package/dist/{chunk-AD2SYQYC.js → chunk-IJ7RPIYJ.js} +124 -6
  42. package/dist/chunk-J3YUBZWY.js +382 -0
  43. package/dist/{chunk-5JGRAMKL.js → chunk-JOZYP4GM.js} +8 -6
  44. package/dist/{chunk-OH3TOQTB.js → chunk-K4XHGFR5.js} +751 -15
  45. package/dist/{chunk-EYPA3EGJ.js → chunk-KTYTFRMB.js} +178 -14
  46. package/dist/chunk-LU7P4LHA.js +33 -0
  47. package/dist/chunk-ME6CCNFO.js +108 -0
  48. package/dist/chunk-MXKJU4JB.js +1100 -0
  49. package/dist/{chunk-RY3LY4J5.js → chunk-N22QMJKY.js} +21 -18
  50. package/dist/chunk-NMPKI6XL.js +3006 -0
  51. package/dist/chunk-NUGM5KR6.js +165 -0
  52. package/dist/{chunk-22NAGB7X.js → chunk-P43ETTHK.js} +5 -94
  53. package/dist/{chunk-NILBFAPG.js → chunk-PMDBGQSJ.js} +2 -2
  54. package/dist/chunk-PT7HYKEM.js +165 -0
  55. package/dist/chunk-RVG5JXAL.js +41 -0
  56. package/dist/{chunk-GEYXPTRF.js → chunk-RWSI4YD7.js} +2 -2
  57. package/dist/{chunk-4BPJXDWC.js → chunk-TANS5ZJS.js} +35 -19
  58. package/dist/{verifiers-NCBTHHN2.js → chunk-TB5666IT.js} +67 -324
  59. package/dist/{chunk-QM3F2GKX.js → chunk-TLQJPP24.js} +7927 -8088
  60. package/dist/{chunk-G7MUEIGA.js → chunk-TT36MB5S.js} +2 -1
  61. package/dist/chunk-TTHACPOM.js +961 -0
  62. package/dist/{chunk-6US73PDB.js → chunk-TYPGUK6W.js} +7 -7
  63. package/dist/{chunk-MFFY33HR.js → chunk-U6MBIEMB.js} +554 -209
  64. package/dist/chunk-VAWNZU7Z.js +242 -0
  65. package/dist/{chunk-IR4CFBFN.js → chunk-VCBR6CU7.js} +12 -12
  66. package/dist/{chunk-WHJYKASB.js → chunk-VHN4MY6O.js} +2 -2
  67. package/dist/{chunk-XYDYPRZI.js → chunk-VWZOAB7K.js} +10 -10
  68. package/dist/{chunk-ZRGEBJ4T.js → chunk-WLFILSD5.js} +48 -48
  69. package/dist/{chunk-K7T3E2SR.js → chunk-WNIJTQQK.js} +12 -11
  70. package/dist/{chunk-CYQKWTG3.js → chunk-WSB3FPX7.js} +68 -20
  71. package/dist/{chunk-KHSFENX2.js → chunk-WWCZ5F23.js} +116 -14
  72. package/dist/{chunk-XE2VEJHX.js → chunk-WXY7KU3G.js} +2 -2
  73. package/dist/{chunk-PPAMZ32Z.js → chunk-XK56QHLX.js} +6 -1
  74. package/dist/{chunk-KOHPCX4K.js → chunk-XWSF374K.js} +5 -5
  75. package/dist/{chunk-CJUB2JJ2.js → chunk-YS5VLNH5.js} +10 -10
  76. package/dist/{chunk-ZZMN5OM4.js → chunk-ZNLWCMVZ.js} +2 -2
  77. package/dist/{chunk-WHGPSPT5.js → chunk-ZVJ5BLO2.js} +2 -2
  78. package/dist/cli/index.js +33 -31
  79. package/dist/{clio-M2KGYUFZ.js → clio-QVTYJ57A.js} +10 -10
  80. package/dist/{code-nav-GQNL7XA6.js → code-nav-FGGFIE7L.js} +5 -5
  81. package/dist/codewiki/build-worker.js +4 -4
  82. package/dist/{components-5TTYYX6G.js → components-ZFA3SAER.js} +9 -9
  83. package/dist/{config-XUUYQIWO.js → config-LW5IJFQN.js} +65 -55
  84. package/dist/{configure-IHJ7YOMV.js → configure-7XIZCOU4.js} +29 -24
  85. package/dist/{context-75MIWW3U.js → context-L3WL3X7K.js} +54 -43
  86. package/dist/{context-ZQ7SIFJV.js → context-N52ZA626.js} +30 -14
  87. package/dist/{context-74JLXAWD.js → context-Y6Y7QPR6.js} +12 -12
  88. package/dist/{context-clear-GYKWNUML.js → context-clear-MBQRLSDQ.js} +54 -43
  89. package/dist/{context-index-SSR5ECNE.js → context-index-HVMFQHK3.js} +5 -5
  90. package/dist/{context-working-set-UX5KEP4J.js → context-working-set-GS6DSO7F.js} +18 -18
  91. package/dist/{dispatch-runner-GIJBHNFL.js → dispatch-runner-22ZCNOM3.js} +367 -79
  92. package/dist/{docs-6FZSCG5B.js → docs-7LQ23DLM.js} +9 -9
  93. package/dist/{doctor-SVJ5BZCW.js → doctor-M7YEDGAE.js} +27 -23
  94. package/dist/{eval-CG6LLBLD.js → eval-BEC2WHDA.js} +73 -20
  95. package/dist/{evidence-ZYFIEN42.js → evidence-REJUMSKM.js} +70 -59
  96. package/dist/{evolve-QGEXEMDW.js → evolve-PY5ZBA5K.js} +50 -39
  97. package/dist/{extensions-ADGNCJJD.js → extensions-HVKU65YU.js} +7 -7
  98. package/dist/{fleet-S5R4ZOQY.js → fleet-7WZEWRFA.js} +236 -377
  99. package/dist/fleet-commands-UVHWM76J.js +70 -0
  100. package/dist/fleet-graph-6ULH7PES.js +125 -0
  101. package/dist/fleet-new-RDVJLHHH.js +48 -0
  102. package/dist/{fleet-preflight-BHSNPBMH.js → fleet-preflight-J53T6CCE.js} +5 -5
  103. package/dist/fleet-validate-72PC4SLA.js +79 -0
  104. package/dist/{init-5DRU55YR.js → init-OG3TPGQG.js} +69 -57
  105. package/dist/library-CNTMPLRF.js +217 -0
  106. package/dist/{memory-7YKKR6UC.js → memory-6IS7F275.js} +52 -41
  107. package/dist/{models-ZPOLRU2C.js → models-ENRJDA5W.js} +37 -31
  108. package/dist/{monitor-US5F5YGZ.js → monitor-XLDVO7TN.js} +79 -42
  109. package/dist/{orchestrator-E2AL4T5N.js → orchestrator-6KSPYRHA.js} +4126 -762
  110. package/dist/{paths-E7KYAQWE.js → paths-DBXMZMDU.js} +6 -6
  111. package/dist/registry-LG64LTF4.js +11 -0
  112. package/dist/{reset-KZ652EK6.js → reset-RZ4ER727.js} +12 -12
  113. package/dist/{run-SRNBKDWD.js → run-Y2CNK5RU.js} +89 -76
  114. package/dist/{share-CGZE33UP.js → share-A55GYP6Z.js} +37 -13
  115. package/dist/{skills-S2X4DLY5.js → skills-ALC5J6AT.js} +29 -13
  116. package/dist/{skills-eval-W2GGIC4R.js → skills-eval-JPBEBYQU.js} +60 -48
  117. package/dist/support-MIETYA5E.js +38 -0
  118. package/dist/{targets-54SWINWB.js → targets-VGNXIR3S.js} +46 -36
  119. package/dist/{terminal-lease-SAIF2OGY.js → terminal-lease-WOBR64YA.js} +4 -4
  120. package/dist/{uninstall-BVLWXKBT.js → uninstall-ZJF5H5ZN.js} +9 -9
  121. package/dist/{upgrade-JKAR27XC.js → upgrade-FUSUAGHR.js} +31 -28
  122. package/dist/{usage-MSAWCLX4.js → usage-N4MKVHKD.js} +140 -68
  123. package/dist/verifiers-YAWOJ3H2.js +336 -0
  124. package/dist/{verify-X5HDROLA.js → verify-LTDHYBGY.js} +10 -9
  125. package/dist/{wiki-generate-GUSOQ6ZP.js → wiki-generate-6M7GHTBJ.js} +75 -62
  126. package/dist/worker/entry.js +67 -57
  127. package/docs/README.md +3 -2
  128. package/docs/acp.md +1 -1
  129. package/docs/alcf-provider.md +1 -1
  130. package/docs/architecture.md +2 -2
  131. package/docs/artifact-versions.md +11 -6
  132. package/docs/built-in-agents.md +26 -2
  133. package/docs/capacity-and-scheduling.md +1 -1
  134. package/docs/commands-and-modes.md +83 -3
  135. package/docs/configuration-and-targets.md +86 -4
  136. package/docs/context-engine.md +1 -1
  137. package/docs/development-pipeline.md +1 -1
  138. package/docs/dispatch-architecture-rationale.md +1 -1
  139. package/docs/documentation-coverage.md +3 -3
  140. package/docs/documentation-guide.md +3 -3
  141. package/docs/eval-runner.md +1 -1
  142. package/docs/evals-internal.md +1 -1
  143. package/docs/evidence-and-memory.md +74 -10
  144. package/docs/evolution.md +1 -1
  145. package/docs/exit-codes-and-output.md +4 -1
  146. package/docs/extensions-and-sharing.md +6 -2
  147. package/docs/fleet-demo-runbook.md +2 -2
  148. package/docs/fleet-dispatch.md +228 -16
  149. package/docs/git-commit-provenance.md +2 -2
  150. package/docs/glossary.md +22 -2
  151. package/docs/installation-and-lifecycle.md +2 -2
  152. package/docs/middleware-and-components.md +2 -1
  153. package/docs/model-catalog.md +1 -1
  154. package/docs/observability.md +56 -9
  155. package/docs/proactive-memory.md +1 -1
  156. package/docs/prompt-envelope-and-tools.md +4 -2
  157. package/docs/provider-adapter-cookbook.md +1 -1
  158. package/docs/release-cut-checklist.md +83 -65
  159. package/docs/resource-library.md +59 -0
  160. package/docs/safety-model.md +2 -2
  161. package/docs/scientific-validation.md +3 -3
  162. package/docs/session-lifecycle.md +37 -1
  163. package/docs/skills-marketplace.md +16 -3
  164. package/docs/tool-usage.md +14 -7
  165. package/docs/trace-store.md +1 -1
  166. package/docs/troubleshooting.md +1 -1
  167. package/docs/tui-design.md +1 -1
  168. package/docs/worker-dispatch-mechanics.md +3 -3
  169. package/package.json +1 -2
  170. package/src/cli/argv.ts +5 -0
  171. package/src/cli/configure.ts +107 -23
  172. package/src/cli/doctor.ts +5 -1
  173. package/src/cli/evidence.ts +30 -25
  174. package/src/cli/fleet-commands.ts +37 -0
  175. package/src/cli/fleet-graph.ts +102 -0
  176. package/src/cli/fleet-new.ts +36 -0
  177. package/src/cli/fleet-preflight.ts +111 -0
  178. package/src/cli/fleet-validate.ts +30 -0
  179. package/src/cli/fleet.ts +173 -335
  180. package/src/cli/index.ts +3 -1
  181. package/src/cli/library.ts +190 -0
  182. package/src/cli/share.ts +13 -1
  183. package/src/cli/shared.ts +1 -0
  184. package/src/cli/targets.ts +4 -1
  185. package/src/cli/usage.ts +111 -19
  186. package/src/cli/validate-model.ts +60 -5
  187. package/src/core/bus-events.ts +29 -0
  188. package/src/core/commit-attribution.ts +4 -4
  189. package/src/core/config.ts +130 -0
  190. package/src/core/defaults.ts +81 -0
  191. package/src/core/path-boundary.ts +100 -0
  192. package/src/domains/agents/builtins/architect.md +1 -0
  193. package/src/domains/agents/builtins/oracle.md +33 -0
  194. package/src/domains/agents/catalog.ts +13 -1
  195. package/src/domains/agents/extension.ts +2 -11
  196. package/src/domains/agents/fleet-contract.ts +304 -24
  197. package/src/domains/agents/index.ts +14 -0
  198. package/src/domains/agents/recipe.ts +7 -1
  199. package/src/domains/agents/registry.ts +73 -5
  200. package/src/domains/agents/result-contract.ts +360 -15
  201. package/src/domains/agents/write-boundary.ts +15 -50
  202. package/src/domains/config/classify.ts +4 -0
  203. package/src/domains/context/project-rules.ts +51 -1
  204. package/src/domains/dispatch/active-route-planner.ts +14 -0
  205. package/src/domains/dispatch/assignment-reconcile.ts +22 -5
  206. package/src/domains/dispatch/assignment-store.ts +151 -14
  207. package/src/domains/dispatch/backoff.ts +2 -1
  208. package/src/domains/dispatch/capability-match.ts +1 -0
  209. package/src/domains/dispatch/checkout-writer-lease.ts +175 -0
  210. package/src/domains/dispatch/contract.ts +48 -0
  211. package/src/domains/dispatch/delegation-plan.ts +164 -0
  212. package/src/domains/dispatch/execution-plan.ts +76 -5
  213. package/src/domains/dispatch/execution-role.ts +12 -2
  214. package/src/domains/dispatch/execution-scheduler.ts +183 -67
  215. package/src/domains/dispatch/extension.ts +412 -74
  216. package/src/domains/dispatch/fleet-gate.ts +14 -0
  217. package/src/domains/dispatch/fleet-plan.ts +63 -3
  218. package/src/domains/dispatch/fleet-run.ts +791 -0
  219. package/src/domains/dispatch/gate-role-prompts.ts +47 -0
  220. package/src/domains/dispatch/host-verification.ts +178 -0
  221. package/src/domains/dispatch/index.ts +41 -1
  222. package/src/domains/dispatch/intent-requirements.ts +40 -0
  223. package/src/domains/dispatch/intent.ts +235 -0
  224. package/src/domains/dispatch/path-scope.ts +370 -0
  225. package/src/domains/dispatch/receipt-integrity.ts +9 -4
  226. package/src/domains/dispatch/state.ts +36 -3
  227. package/src/domains/dispatch/types.ts +64 -12
  228. package/src/domains/dispatch/validation.ts +69 -6
  229. package/src/domains/dispatch/write-boundary-enforcer.ts +45 -0
  230. package/src/domains/dispatch/write-boundary.ts +201 -22
  231. package/src/domains/eval/metrics/evidence.ts +79 -2
  232. package/src/domains/eval/runners/clio-run.ts +12 -2
  233. package/src/domains/evidence/build.ts +69 -11
  234. package/src/domains/evidence/index.ts +21 -0
  235. package/src/domains/evidence/provenance.ts +46 -11
  236. package/src/domains/evidence/trust-projection.ts +274 -0
  237. package/src/domains/evidence/trust-status.ts +155 -18
  238. package/src/domains/evidence/types.ts +4 -0
  239. package/src/domains/extensions/discovery.ts +88 -1
  240. package/src/domains/extensions/resources.ts +20 -8
  241. package/src/domains/extensions/state.ts +6 -2
  242. package/src/domains/extensions/types.ts +4 -1
  243. package/src/domains/lifecycle/doctor.ts +140 -1
  244. package/src/domains/middleware/index.ts +15 -0
  245. package/src/domains/middleware/watchdog.ts +281 -0
  246. package/src/domains/observability/contract.ts +3 -1
  247. package/src/domains/observability/cost.ts +12 -1
  248. package/src/domains/observability/extension.ts +2 -2
  249. package/src/domains/observability/index.ts +10 -0
  250. package/src/domains/observability/out-of-turn-usage.ts +223 -0
  251. package/src/domains/prompts/contract.ts +3 -5
  252. package/src/domains/providers/extension.ts +30 -2
  253. package/src/domains/resources/common-loader.ts +3 -0
  254. package/src/domains/resources/index.ts +20 -0
  255. package/src/domains/resources/library.ts +326 -0
  256. package/src/domains/resources/prompts/loader.ts +119 -14
  257. package/src/domains/resources/skills/marketplace.ts +37 -12
  258. package/src/domains/safety/policy-engine.ts +5 -5
  259. package/src/domains/safety/run-effects.ts +64 -1
  260. package/src/domains/safety/scope.ts +7 -12
  261. package/src/domains/session/handoff.ts +629 -0
  262. package/src/domains/share/archive.ts +67 -2
  263. package/src/engine/acp/server.ts +4 -1
  264. package/src/engine/prompt-templates.ts +18 -1
  265. package/src/engine/worker-runtime.ts +6 -3
  266. package/src/entry/orchestrator.ts +37 -0
  267. package/src/interactive/bus-notices.ts +26 -0
  268. package/src/interactive/chat-loop.ts +235 -1
  269. package/src/interactive/chat-renderer.ts +22 -0
  270. package/src/interactive/cost-overlay.ts +31 -3
  271. package/src/interactive/council-dispatch.ts +30 -0
  272. package/src/interactive/council-grid.ts +213 -0
  273. package/src/interactive/council.ts +99 -0
  274. package/src/interactive/dispatch-board.ts +311 -17
  275. package/src/interactive/fleet-run-preview.ts +307 -0
  276. package/src/interactive/footer/notifications.ts +219 -0
  277. package/src/interactive/handoff-round.ts +56 -0
  278. package/src/interactive/interactive-application.ts +43 -1
  279. package/src/interactive/interactive-event-projection.ts +23 -1
  280. package/src/interactive/interactive-slash-runtime.ts +52 -2
  281. package/src/interactive/interactive-subscriptions.ts +14 -2
  282. package/src/interactive/oracle.ts +179 -0
  283. package/src/interactive/overlay-ask-user-lifecycle.ts +6 -0
  284. package/src/interactive/overlay-general-openers.ts +190 -1
  285. package/src/interactive/overlay-key-routing.ts +17 -1
  286. package/src/interactive/overlay-lifecycle.ts +41 -1
  287. package/src/interactive/overlay-permission-lifecycle.ts +10 -0
  288. package/src/interactive/overlay-resource-openers.ts +11 -3
  289. package/src/interactive/overlay-session-lifecycle.ts +234 -2
  290. package/src/interactive/overlays/fleet-run-approval.ts +208 -0
  291. package/src/interactive/overlays/handoff-review.ts +185 -0
  292. package/src/interactive/overlays/library-install-confirm.ts +151 -0
  293. package/src/interactive/overlays/list-overlay.ts +168 -2
  294. package/src/interactive/overlays/settings.ts +221 -30
  295. package/src/interactive/overlays/side-question.ts +139 -0
  296. package/src/interactive/overlays/skills-hub.ts +401 -15
  297. package/src/interactive/side-question.ts +171 -0
  298. package/src/interactive/slash-commands.ts +439 -7
  299. package/src/interactive/slash-spec.ts +19 -6
  300. package/src/interactive/theme/tokens.ts +30 -0
  301. package/src/interactive/turn-middleware.ts +15 -1
  302. package/src/interactive/view/artifacts.ts +42 -9
  303. package/src/interactive/view/view-overlay.ts +15 -3
  304. package/src/interactive/watchdog-run.ts +75 -0
  305. package/src/interactive/worker-receipts.ts +14 -2
  306. package/src/interactive/worker-share.ts +56 -1
  307. package/src/interactive/worker-stream.ts +15 -0
  308. package/src/tools/bootstrap.ts +3 -0
  309. package/src/tools/compete-worktrees.ts +13 -79
  310. package/src/tools/dispatch-admission.ts +251 -18
  311. package/src/tools/dispatch-arguments.ts +84 -1
  312. package/src/tools/dispatch-plan.ts +165 -6
  313. package/src/tools/dispatch-runner.ts +364 -23
  314. package/src/tools/dispatch-types.ts +20 -1
  315. package/src/tools/dispatch.ts +72 -2
  316. package/src/tools/monitor.ts +29 -0
  317. package/src/tools/profiles.ts +18 -4
  318. package/src/tools/task-worktree.ts +238 -0
  319. package/src/tools/verify/authoring.ts +61 -1
  320. package/src/tools/verify/scripts.ts +62 -0
  321. package/src/tools/worker-evidence.ts +21 -14
  322. package/src/worker/spec-contract.ts +3 -1
  323. package/dist/chunk-HC4CLZ2Y.js +0 -68
@@ -1,23 +1,25 @@
1
1
  import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
2
  import {
3
3
  ROUTE_POLICY_VERSION,
4
- isExecutionRole,
5
4
  isRouteDecisionAgentSelection,
6
5
  isRoutingIntent
7
- } from "./chunk-22NAGB7X.js";
6
+ } from "./chunk-P43ETTHK.js";
7
+ import {
8
+ isExecutionRole
9
+ } from "./chunk-H7IXIC72.js";
8
10
  import {
9
11
  assertSafeId
10
12
  } from "./chunk-R346GLFC.js";
13
+ import {
14
+ readClioVersion,
15
+ resolvePackageRoot
16
+ } from "./chunk-IWHMRKLL.js";
11
17
  import {
12
18
  require_dist
13
19
  } from "./chunk-APJ265NV.js";
14
20
  import {
15
21
  safeResourceWrite
16
22
  } from "./chunk-WEPFGWHJ.js";
17
- import {
18
- readClioVersion,
19
- resolvePackageRoot
20
- } from "./chunk-IWHMRKLL.js";
21
23
  import {
22
24
  __toESM,
23
25
  init_esm_shims
@@ -26,7 +28,7 @@ import {
26
28
  // src/domains/dispatch/receipt-integrity.ts
27
29
  init_esm_shims();
28
30
  import { createHash } from "node:crypto";
29
- var RUN_RECEIPT_INTEGRITY_VERSION = 15;
31
+ var RUN_RECEIPT_INTEGRITY_VERSION = 20;
30
32
  var RUN_RECEIPT_INTEGRITY_ALGORITHM = "sha256";
31
33
  function sha256(input) {
32
34
  return createHash("sha256").update(input, "utf8").digest("hex");
@@ -79,6 +81,8 @@ var RECEIPT_INTEGRITY_FIELD_COVERAGE = {
79
81
  agentAudience: true,
80
82
  requestOrigin: true,
81
83
  task: true,
84
+ intent: true,
85
+ pathScope: true,
82
86
  // Historical receipts omit this field, so their receipt and ledger payloads remain unchanged.
83
87
  budget: true,
84
88
  targetId: true,
@@ -96,12 +100,13 @@ var RECEIPT_INTEGRITY_FIELD_COVERAGE = {
96
100
  reroutes: true,
97
101
  pipeline: true,
98
102
  gate: true,
103
+ council: true,
99
104
  plan: true,
105
+ fleetGate: true,
100
106
  personaOverride: true,
101
107
  projectContext: true,
102
108
  // Always set on receipts written after #104 landed; absent only on older
103
- // receipts, which digest exactly as they did before these fields existed,
104
- // so the integrity version stays where it is.
109
+ // receipts, which omit these fields from canonical serialization.
105
110
  rulesApplied: true,
106
111
  operatorProfileApplied: true,
107
112
  exitCode: true,
@@ -131,6 +136,8 @@ var RECEIPT_INTEGRITY_FIELD_COVERAGE = {
131
136
  toolStats: true,
132
137
  toolActivity: true,
133
138
  verification: true,
139
+ hostVerification: true,
140
+ worktree: true,
134
141
  routingIntent: true,
135
142
  quality: true,
136
143
  skillActivations: true,
@@ -146,7 +153,7 @@ var RECEIPT_INTEGRITY_FIELD_COVERAGE = {
146
153
  validationGrounding: true,
147
154
  capabilityMismatch: true,
148
155
  // Same reasoning: absent unless the run had an agent ledger, so a receipt
149
- // without one digests byte-identically to one produced before it existed.
156
+ // without one omits the field from canonical serialization.
150
157
  ledgerContribution: true,
151
158
  sessionId: true,
152
159
  briefing: true,
@@ -863,6 +870,574 @@ function readArray2(record, source, field) {
863
870
  return value;
864
871
  }
865
872
 
873
+ // src/domains/evidence/trust-status.ts
874
+ init_esm_shims();
875
+ var TRUST_STATUS_VERSION = 1;
876
+ var TRUST_STATUS_MAX_ARTIFACT_REFERENCES = 16;
877
+ var TRUST_STATUS_MAX_IDENTIFIER_LENGTH = 512;
878
+ var TRUST_STATUS_AXES = [
879
+ "artifactIntegrity",
880
+ "validationGrounding",
881
+ "independentReview",
882
+ "contextProvenance",
883
+ "autonomyEnforcement",
884
+ "completionEvidence"
885
+ ];
886
+ var TRUST_STATUS_STATES = {
887
+ artifactIntegrity: ["verified", "failed", "absent", "unknown", "not_applicable"],
888
+ validationGrounding: ["validated", "failed", "ungrounded", "absent", "unknown", "not_applicable"],
889
+ independentReview: ["passed", "failed", "inconclusive", "not_independent", "absent", "unknown", "not_applicable"],
890
+ contextProvenance: ["recorded", "invalid", "absent", "unknown", "not_applicable"],
891
+ autonomyEnforcement: ["enforced", "approximated", "bypassed", "absent", "unknown", "not_applicable"],
892
+ completionEvidence: ["evidenced", "incomplete", "limited", "absent", "unknown", "not_applicable"]
893
+ };
894
+ var SELF_REPORTED_ARTIFACT_KINDS = /* @__PURE__ */ new Set([
895
+ "finish_contract_evidence",
896
+ "run_receipt"
897
+ ]);
898
+ var AXIS_STATES = {
899
+ artifactIntegrity: new Set(TRUST_STATUS_STATES.artifactIntegrity),
900
+ validationGrounding: new Set(TRUST_STATUS_STATES.validationGrounding),
901
+ independentReview: new Set(TRUST_STATUS_STATES.independentReview),
902
+ contextProvenance: new Set(TRUST_STATUS_STATES.contextProvenance),
903
+ autonomyEnforcement: new Set(TRUST_STATUS_STATES.autonomyEnforcement),
904
+ completionEvidence: new Set(TRUST_STATUS_STATES.completionEvidence)
905
+ };
906
+ var AXIS_SOURCES = {
907
+ artifactIntegrity: /* @__PURE__ */ new Set(["receipt_integrity_verification", "compatibility"]),
908
+ validationGrounding: /* @__PURE__ */ new Set(["run_receipt", "evidence_bundle", "compatibility"]),
909
+ independentReview: /* @__PURE__ */ new Set(["gate_decision", "compatibility"]),
910
+ contextProvenance: /* @__PURE__ */ new Set(["run_receipt", "evidence_bundle", "compatibility"]),
911
+ autonomyEnforcement: /* @__PURE__ */ new Set(["run_receipt", "compatibility"]),
912
+ completionEvidence: /* @__PURE__ */ new Set(["finish_contract", "compatibility"])
913
+ };
914
+ var SOURCE_AUTHORITIES = {
915
+ receipt_integrity_verification: /* @__PURE__ */ new Set(["clio"]),
916
+ run_receipt: /* @__PURE__ */ new Set(["clio", "validator", "runtime", "external_system", "unknown"]),
917
+ gate_decision: /* @__PURE__ */ new Set(["clio", "reviewer", "operator", "unknown"]),
918
+ evidence_bundle: /* @__PURE__ */ new Set(["clio"]),
919
+ finish_contract: /* @__PURE__ */ new Set(["clio"]),
920
+ compatibility: /* @__PURE__ */ new Set(["clio", "unknown"])
921
+ };
922
+ var ABSENCE_REASONS = /* @__PURE__ */ new Set([
923
+ "not_recorded",
924
+ "not_observed",
925
+ "artifact_missing",
926
+ "historical_format"
927
+ ]);
928
+ var SOURCE_KINDS = /* @__PURE__ */ new Set([
929
+ "receipt_integrity_verification",
930
+ "run_receipt",
931
+ "gate_decision",
932
+ "evidence_bundle",
933
+ "finish_contract",
934
+ "compatibility"
935
+ ]);
936
+ var AUTHORITY_KINDS = /* @__PURE__ */ new Set([
937
+ "clio",
938
+ "validator",
939
+ "reviewer",
940
+ "operator",
941
+ "runtime",
942
+ "external_system",
943
+ "unknown"
944
+ ]);
945
+ var ARTIFACT_KINDS = /* @__PURE__ */ new Set([
946
+ "run_receipt",
947
+ "validation_result",
948
+ "gate_decision",
949
+ "briefing",
950
+ "project_context",
951
+ "autonomy_policy",
952
+ "finish_contract_evidence",
953
+ "evidence_bundle",
954
+ "session_entry"
955
+ ]);
956
+ function isRecord3(value) {
957
+ return typeof value === "object" && value !== null && !Array.isArray(value);
958
+ }
959
+ function hasExactKeys(value, keys) {
960
+ const expected = new Set(keys);
961
+ return Object.keys(value).length === expected.size && Object.keys(value).every((key) => expected.has(key));
962
+ }
963
+ function isTrustStatusIdentifier(value) {
964
+ if (typeof value !== "string" || value.trim().length === 0 || value.length > TRUST_STATUS_MAX_IDENTIFIER_LENGTH) {
965
+ return false;
966
+ }
967
+ for (const character of value) {
968
+ const codePoint = character.codePointAt(0);
969
+ if (codePoint !== void 0 && (codePoint < 32 || codePoint === 127)) return false;
970
+ }
971
+ return true;
972
+ }
973
+ function compareArtifactReferences(left, right) {
974
+ const leftKey = `${left.kind}\0${left.id}\0${left.digest?.value ?? ""}`;
975
+ const rightKey = `${right.kind}\0${right.id}\0${right.digest?.value ?? ""}`;
976
+ return leftKey < rightKey ? -1 : leftKey > rightKey ? 1 : 0;
977
+ }
978
+ function normalizeArtifactReference(value, path) {
979
+ if (!isRecord3(value)) throw new Error(`${path} must be an object`);
980
+ if (!hasExactKeys(value, value.digest === void 0 ? ["kind", "id"] : ["kind", "id", "digest"])) {
981
+ throw new Error(`${path} has unknown or missing fields`);
982
+ }
983
+ if (typeof value.kind !== "string" || !ARTIFACT_KINDS.has(value.kind)) {
984
+ throw new Error(`${path}.kind is invalid`);
985
+ }
986
+ if (!isTrustStatusIdentifier(value.id)) throw new Error(`${path}.id is invalid`);
987
+ const reference = { kind: value.kind, id: value.id };
988
+ if (value.digest !== void 0) {
989
+ if (!isRecord3(value.digest) || !hasExactKeys(value.digest, ["algorithm", "value"]) || value.digest.algorithm !== "sha256" || typeof value.digest.value !== "string" || !/^[a-f0-9]{64}$/u.test(value.digest.value)) {
990
+ throw new Error(`${path}.digest is invalid`);
991
+ }
992
+ reference.digest = { algorithm: "sha256", value: value.digest.value };
993
+ }
994
+ return reference;
995
+ }
996
+ function normalizeAttributedStatus(axis, value) {
997
+ if (!hasExactKeys(value, ["state", "source", "authority", "artifacts"])) {
998
+ throw new Error(`${axis} has unknown or missing fields`);
999
+ }
1000
+ if (!isRecord3(value.source) || !hasExactKeys(value.source, ["kind", "id"])) {
1001
+ throw new Error(`${axis}.source is invalid`);
1002
+ }
1003
+ if (typeof value.source.kind !== "string" || !SOURCE_KINDS.has(value.source.kind) || !AXIS_SOURCES[axis].has(value.source.kind) || !isTrustStatusIdentifier(value.source.id)) {
1004
+ throw new Error(`${axis}.source is invalid`);
1005
+ }
1006
+ if (!isRecord3(value.authority) || !hasExactKeys(value.authority, ["kind", "id"])) {
1007
+ throw new Error(`${axis}.authority is invalid`);
1008
+ }
1009
+ if (typeof value.authority.kind !== "string" || !AUTHORITY_KINDS.has(value.authority.kind) || !SOURCE_AUTHORITIES[value.source.kind].has(
1010
+ value.authority.kind
1011
+ ) || !isTrustStatusIdentifier(value.authority.id)) {
1012
+ throw new Error(`${axis}.authority is invalid`);
1013
+ }
1014
+ if (value.source.kind === "compatibility" && value.state !== "unknown" && value.state !== "not_applicable") {
1015
+ throw new Error(`${axis} compatibility source cannot establish ${value.state}`);
1016
+ }
1017
+ if (!Array.isArray(value.artifacts) || value.artifacts.length > TRUST_STATUS_MAX_ARTIFACT_REFERENCES) {
1018
+ throw new Error(`${axis}.artifacts exceeds the bounded reference list`);
1019
+ }
1020
+ const artifacts = value.artifacts.map(
1021
+ (entry, index) => normalizeArtifactReference(entry, `${axis}.artifacts[${index}]`)
1022
+ );
1023
+ artifacts.sort(compareArtifactReferences);
1024
+ for (let index = 1; index < artifacts.length; index += 1) {
1025
+ if (compareArtifactReferences(
1026
+ artifacts[index - 1],
1027
+ artifacts[index]
1028
+ ) === 0) {
1029
+ throw new Error(`${axis}.artifacts contains a duplicate reference`);
1030
+ }
1031
+ }
1032
+ return {
1033
+ state: value.state,
1034
+ source: { kind: value.source.kind, id: value.source.id },
1035
+ authority: { kind: value.authority.kind, id: value.authority.id },
1036
+ artifacts
1037
+ };
1038
+ }
1039
+ function normalizeAxis(axis, value) {
1040
+ if (!isRecord3(value) || typeof value.state !== "string" || !AXIS_STATES[axis].has(value.state)) {
1041
+ throw new Error(`${axis}.state is invalid`);
1042
+ }
1043
+ if (value.state === "absent") {
1044
+ if (!hasExactKeys(value, ["state", "reason"]) || typeof value.reason !== "string" || !ABSENCE_REASONS.has(value.reason)) {
1045
+ throw new Error(`${axis} absent state is invalid`);
1046
+ }
1047
+ return { state: "absent", reason: value.reason };
1048
+ }
1049
+ return normalizeAttributedStatus(axis, value);
1050
+ }
1051
+ function normalizeTrustStatus(value) {
1052
+ if (!isRecord3(value) || !hasExactKeys(value, ["version", ...TRUST_STATUS_AXES])) {
1053
+ throw new Error("trust status has unknown or missing fields");
1054
+ }
1055
+ if (value.version !== TRUST_STATUS_VERSION) throw new Error("trust status version is invalid");
1056
+ return {
1057
+ version: TRUST_STATUS_VERSION,
1058
+ artifactIntegrity: normalizeAxis("artifactIntegrity", value.artifactIntegrity),
1059
+ validationGrounding: normalizeAxis("validationGrounding", value.validationGrounding),
1060
+ independentReview: normalizeAxis("independentReview", value.independentReview),
1061
+ contextProvenance: normalizeAxis("contextProvenance", value.contextProvenance),
1062
+ autonomyEnforcement: normalizeAxis("autonomyEnforcement", value.autonomyEnforcement),
1063
+ completionEvidence: normalizeAxis("completionEvidence", value.completionEvidence)
1064
+ };
1065
+ }
1066
+ function absentTrustStatus(reason) {
1067
+ return { state: "absent", reason };
1068
+ }
1069
+ function composeTrustStatus(...projections) {
1070
+ const axes = {
1071
+ artifactIntegrity: absentTrustStatus("not_recorded"),
1072
+ validationGrounding: absentTrustStatus("not_recorded"),
1073
+ independentReview: absentTrustStatus("not_recorded"),
1074
+ contextProvenance: absentTrustStatus("not_recorded"),
1075
+ autonomyEnforcement: absentTrustStatus("not_recorded"),
1076
+ completionEvidence: absentTrustStatus("not_recorded")
1077
+ };
1078
+ for (const projection of projections) {
1079
+ if (projection.artifactIntegrity !== void 0) axes.artifactIntegrity = projection.artifactIntegrity;
1080
+ if (projection.validationGrounding !== void 0) axes.validationGrounding = projection.validationGrounding;
1081
+ if (projection.independentReview !== void 0) axes.independentReview = projection.independentReview;
1082
+ if (projection.contextProvenance !== void 0) axes.contextProvenance = projection.contextProvenance;
1083
+ if (projection.autonomyEnforcement !== void 0) axes.autonomyEnforcement = projection.autonomyEnforcement;
1084
+ if (projection.completionEvidence !== void 0) axes.completionEvidence = projection.completionEvidence;
1085
+ }
1086
+ return normalizeTrustStatus({ version: TRUST_STATUS_VERSION, ...axes });
1087
+ }
1088
+ function sha256Reference(kind, id, digest) {
1089
+ const reference = { kind, id };
1090
+ if (digest !== void 0 && /^[a-f0-9]{64}$/u.test(digest)) {
1091
+ reference.digest = { algorithm: "sha256", value: digest };
1092
+ }
1093
+ return reference;
1094
+ }
1095
+ function receiptReference(receipt) {
1096
+ return sha256Reference("run_receipt", receipt.runId, receipt.integrity?.digest);
1097
+ }
1098
+ function attributed(state, source, authority, artifacts) {
1099
+ return { state, source, authority, artifacts: [...artifacts].sort(compareArtifactReferences) };
1100
+ }
1101
+ function receiptSource(receipt) {
1102
+ return { kind: "run_receipt", id: receipt.runId };
1103
+ }
1104
+ function compatibilitySource(receipt, field) {
1105
+ return { kind: "compatibility", id: `run_receipt:${receipt.runId}:${field}` };
1106
+ }
1107
+ var DISPATCH_AUTHORITY = { kind: "clio", id: "dispatch" };
1108
+ var COMPATIBILITY_AUTHORITY = { kind: "unknown", id: "historical-persisted-format" };
1109
+ function retiredReceiptIntegrity(integrity) {
1110
+ if (!isRecord3(integrity)) return null;
1111
+ const version = integrity.version;
1112
+ if (typeof version !== "number" || !Number.isInteger(version) || version < 1) return null;
1113
+ if (version >= RUN_RECEIPT_INTEGRITY_VERSION) return null;
1114
+ return { receiptVersion: version, supportedVersion: RUN_RECEIPT_INTEGRITY_VERSION };
1115
+ }
1116
+ function retiredReceiptIntegrityReason(retired) {
1117
+ return `receipt integrity v${retired.receiptVersion} is retired; this build verifies v${retired.supportedVersion}; the receipt is not read as evidence`;
1118
+ }
1119
+ function verifyReceiptIntegrityOutcome(receipt, envelope) {
1120
+ const retired = retiredReceiptIntegrity(receipt.integrity);
1121
+ if (retired !== null) return { ok: false, reason: retiredReceiptIntegrityReason(retired), retired };
1122
+ return verifyReceiptIntegrity(receipt, envelope);
1123
+ }
1124
+ var RETIRED_INTEGRITY_SOURCE = /:integrity-v(\d+)-retired$/u;
1125
+ function retiredIntegritySourceId(runId, receiptVersion) {
1126
+ return `run_receipt:${runId}:integrity-v${receiptVersion}-retired`;
1127
+ }
1128
+ function retiredIntegrityVersionOf(status) {
1129
+ if (status.state !== "unknown" || status.source.kind !== "compatibility") return null;
1130
+ const match = RETIRED_INTEGRITY_SOURCE.exec(status.source.id);
1131
+ return match === null ? null : Number(match[1]);
1132
+ }
1133
+ function adaptReceiptIntegrityStatus(receipt, verification) {
1134
+ if (receipt === null || receipt === void 0) return absentTrustStatus("artifact_missing");
1135
+ const artifacts = [receiptReference(receipt)];
1136
+ if (verification !== void 0 && !verification.ok && verification.retired !== void 0) {
1137
+ return attributed(
1138
+ "unknown",
1139
+ { kind: "compatibility", id: retiredIntegritySourceId(receipt.runId, verification.retired.receiptVersion) },
1140
+ COMPATIBILITY_AUTHORITY,
1141
+ artifacts
1142
+ );
1143
+ }
1144
+ if (verification === void 0 || verification.ok && receipt.integrity === void 0) {
1145
+ return attributed(
1146
+ "unknown",
1147
+ {
1148
+ kind: "compatibility",
1149
+ id: `run_receipt:${receipt.runId}:${receipt.integrity === void 0 ? "integrity-missing" : "integrity-unchecked"}`
1150
+ },
1151
+ COMPATIBILITY_AUTHORITY,
1152
+ artifacts
1153
+ );
1154
+ }
1155
+ return attributed(
1156
+ verification.ok ? "verified" : "failed",
1157
+ { kind: "receipt_integrity_verification", id: receipt.runId },
1158
+ { kind: "clio", id: "receipt-integrity" },
1159
+ artifacts
1160
+ );
1161
+ }
1162
+ function validationArtifacts(receipt) {
1163
+ const artifacts = [receiptReference(receipt)];
1164
+ for (const fact of receipt.quality?.typedValidations ?? []) {
1165
+ artifacts.push(sha256Reference("validation_result", fact.sourceId, fact.validatorDigest));
1166
+ }
1167
+ const resultContract = receipt.quality?.resultContract;
1168
+ if (resultContract !== null && resultContract !== void 0) {
1169
+ artifacts.push(sha256Reference("validation_result", resultContract.sourceId, resultContract.validatorDigest));
1170
+ }
1171
+ return uniqueBoundedReferences(artifacts);
1172
+ }
1173
+ function qualityHasFailure(quality) {
1174
+ if (quality === void 0) return false;
1175
+ if (quality.typedValidations.some((fact) => !fact.passed)) return true;
1176
+ return quality.resultContract?.conformance === "fail" || quality.resultContract?.quality === "fail";
1177
+ }
1178
+ function qualityHasValidation(quality) {
1179
+ if (quality === void 0) return false;
1180
+ if (quality.typedValidations.some((fact) => fact.passed)) return true;
1181
+ return quality.resultContract?.quality === "pass";
1182
+ }
1183
+ function verificationStatus(verification, receipt, artifacts) {
1184
+ if (verification.state === "verified") {
1185
+ return attributed("validated", receiptSource(receipt), { kind: "validator", id: verification.basis }, artifacts);
1186
+ }
1187
+ if (verification.state === "unverified") return absentTrustStatus("not_observed");
1188
+ if (verification.state === "not_applicable") {
1189
+ return attributed("not_applicable", receiptSource(receipt), DISPATCH_AUTHORITY, artifacts);
1190
+ }
1191
+ return attributed(
1192
+ "unknown",
1193
+ receiptSource(receipt),
1194
+ verification.basis === "acp-external-unobserved" ? { kind: "external_system", id: "acp-delegation" } : COMPATIBILITY_AUTHORITY,
1195
+ artifacts
1196
+ );
1197
+ }
1198
+ function adaptRunReceiptValidationStatus(receipt) {
1199
+ if (receipt === null || receipt === void 0) return absentTrustStatus("artifact_missing");
1200
+ const artifacts = validationArtifacts(receipt);
1201
+ if (receipt.hostVerification?.status === "rejected") {
1202
+ return attributed("failed", receiptSource(receipt), { kind: "validator", id: "host-verification" }, artifacts);
1203
+ }
1204
+ if (receipt.hostVerification?.status === "verified") {
1205
+ return attributed("validated", receiptSource(receipt), { kind: "validator", id: "host-verification" }, artifacts);
1206
+ }
1207
+ if (qualityHasFailure(receipt.quality)) {
1208
+ return attributed("failed", receiptSource(receipt), { kind: "validator", id: "receipt-quality" }, artifacts);
1209
+ }
1210
+ if ((receipt.validationGrounding?.ungrounded.length ?? 0) > 0 || receipt.validationGrounding !== void 0 && receipt.validationGrounding.claimed > receipt.validationGrounding.grounded) {
1211
+ return attributed("ungrounded", receiptSource(receipt), { kind: "validator", id: "command-grounding" }, artifacts);
1212
+ }
1213
+ if (qualityHasValidation(receipt.quality)) {
1214
+ return attributed("validated", receiptSource(receipt), { kind: "validator", id: "receipt-quality" }, artifacts);
1215
+ }
1216
+ if (receipt.verification !== void 0) {
1217
+ return verificationStatus(receipt.verification, receipt, artifacts);
1218
+ }
1219
+ return attributed("unknown", compatibilitySource(receipt, "verification"), COMPATIBILITY_AUTHORITY, artifacts);
1220
+ }
1221
+ function validBriefing(briefing) {
1222
+ return Number.isSafeInteger(briefing.bytes) && briefing.bytes >= 0 && /^[a-f0-9]{64}$/u.test(briefing.contentHash);
1223
+ }
1224
+ function validBoundedProjectContext(context) {
1225
+ return context.tier === "bounded" && Number.isSafeInteger(context.chars) && (context.chars ?? -1) >= 0 && typeof context.contentHash === "string" && /^[a-f0-9]{64}$/u.test(context.contentHash);
1226
+ }
1227
+ var NONE_TIER_SECTIONS = ["workspace-root"];
1228
+ function validNoneTierProjectContext(context) {
1229
+ return context.tier === "none" && context.sections !== void 0 && context.sections.length === NONE_TIER_SECTIONS.length && context.sections.every((section) => NONE_TIER_SECTIONS.includes(section)) && Number.isSafeInteger(context.chars) && (context.chars ?? -1) >= 0 && typeof context.contentHash === "string" && /^[a-f0-9]{64}$/u.test(context.contentHash);
1230
+ }
1231
+ function recordedProjectContextHash(context) {
1232
+ if (context === void 0) return void 0;
1233
+ if (context.tier === "bounded") return validBoundedProjectContext(context) ? context.contentHash : void 0;
1234
+ return validNoneTierProjectContext(context) ? context.contentHash : void 0;
1235
+ }
1236
+ function contextArtifacts(receipt) {
1237
+ const artifacts = [receiptReference(receipt)];
1238
+ if (receipt.briefing !== void 0 && validBriefing(receipt.briefing)) {
1239
+ artifacts.push(sha256Reference("briefing", `${receipt.runId}:briefing`, receipt.briefing.contentHash));
1240
+ }
1241
+ const recordedHash = recordedProjectContextHash(receipt.projectContext);
1242
+ if (recordedHash !== void 0) {
1243
+ artifacts.push(sha256Reference("project_context", `${receipt.runId}:project-context`, recordedHash));
1244
+ }
1245
+ return uniqueBoundedReferences(artifacts);
1246
+ }
1247
+ function adaptRunReceiptContextStatus(receipt) {
1248
+ if (receipt === null || receipt === void 0) return absentTrustStatus("artifact_missing");
1249
+ const artifacts = contextArtifacts(receipt);
1250
+ const source = receiptSource(receipt);
1251
+ const briefingInvalid = receipt.briefing !== void 0 && !validBriefing(receipt.briefing);
1252
+ if (briefingInvalid) return attributed("invalid", source, DISPATCH_AUTHORITY, artifacts);
1253
+ const context = receipt.projectContext;
1254
+ if (context === void 0) {
1255
+ if (receipt.briefing !== void 0) return attributed("recorded", source, DISPATCH_AUTHORITY, artifacts);
1256
+ return attributed("unknown", compatibilitySource(receipt, "projectContext"), COMPATIBILITY_AUTHORITY, artifacts);
1257
+ }
1258
+ if (context.tier === "none") {
1259
+ const bare = context.chars === void 0 && context.contentHash === void 0 && context.sections === void 0;
1260
+ if (bare) {
1261
+ return receipt.briefing === void 0 ? attributed("not_applicable", source, DISPATCH_AUTHORITY, artifacts) : attributed("recorded", source, DISPATCH_AUTHORITY, artifacts);
1262
+ }
1263
+ return attributed(
1264
+ validNoneTierProjectContext(context) ? "recorded" : "invalid",
1265
+ source,
1266
+ DISPATCH_AUTHORITY,
1267
+ artifacts
1268
+ );
1269
+ }
1270
+ return attributed(validBoundedProjectContext(context) ? "recorded" : "invalid", source, DISPATCH_AUTHORITY, artifacts);
1271
+ }
1272
+ function adaptRunReceiptAutonomyStatus(receipt) {
1273
+ if (receipt === null || receipt === void 0) return absentTrustStatus("artifact_missing");
1274
+ const enforcement = receipt.autonomyEnforcement;
1275
+ const artifacts = [receiptReference(receipt)];
1276
+ if (enforcement === void 0) {
1277
+ return attributed("unknown", compatibilitySource(receipt, "autonomyEnforcement"), COMPATIBILITY_AUTHORITY, artifacts);
1278
+ }
1279
+ artifacts.push({ kind: "autonomy_policy", id: `${receipt.runId}:${enforcement.autonomy}` });
1280
+ const authority = enforcement.grade === "mediated" ? { kind: "clio", id: "safety-autonomy" } : { kind: "runtime", id: enforcement.externalMode ?? "external-runtime" };
1281
+ const state = enforcement.dangerousBypass === true || enforcement.grade === "bypassed" ? "bypassed" : enforcement.grade === "approximated" ? "approximated" : "enforced";
1282
+ return attributed(state, receiptSource(receipt), authority, artifacts);
1283
+ }
1284
+ function receiptClaimsAreAuthenticated(receipt, integrity) {
1285
+ return receipt?.integrity !== void 0 && integrity?.ok === true;
1286
+ }
1287
+ function unauthenticatedReceiptProjection(receipt, integrity) {
1288
+ if (receipt === null || receipt === void 0) {
1289
+ return {
1290
+ validationGrounding: absentTrustStatus("artifact_missing"),
1291
+ contextProvenance: absentTrustStatus("artifact_missing"),
1292
+ autonomyEnforcement: absentTrustStatus("artifact_missing")
1293
+ };
1294
+ }
1295
+ if (receipt.integrity === void 0) {
1296
+ const artifacts = [receiptReference(receipt)];
1297
+ return {
1298
+ validationGrounding: attributed(
1299
+ "unknown",
1300
+ compatibilitySource(receipt, "canonical-projection"),
1301
+ COMPATIBILITY_AUTHORITY,
1302
+ artifacts
1303
+ ),
1304
+ contextProvenance: attributed(
1305
+ "unknown",
1306
+ compatibilitySource(receipt, "canonical-projection"),
1307
+ COMPATIBILITY_AUTHORITY,
1308
+ artifacts
1309
+ ),
1310
+ autonomyEnforcement: attributed(
1311
+ "unknown",
1312
+ compatibilitySource(receipt, "canonical-projection"),
1313
+ COMPATIBILITY_AUTHORITY,
1314
+ artifacts
1315
+ )
1316
+ };
1317
+ }
1318
+ if (integrity !== void 0 && !integrity.ok && integrity.retired !== void 0) {
1319
+ return {
1320
+ validationGrounding: absentTrustStatus("historical_format"),
1321
+ contextProvenance: absentTrustStatus("historical_format"),
1322
+ autonomyEnforcement: absentTrustStatus("historical_format")
1323
+ };
1324
+ }
1325
+ return {
1326
+ validationGrounding: absentTrustStatus("not_observed"),
1327
+ contextProvenance: absentTrustStatus("not_observed"),
1328
+ autonomyEnforcement: absentTrustStatus("not_observed")
1329
+ };
1330
+ }
1331
+ function adaptRunReceiptTrustStatus(receipt, options = {}) {
1332
+ const authenticated = receiptClaimsAreAuthenticated(receipt, options.integrity);
1333
+ const receiptProjection = authenticated ? {
1334
+ validationGrounding: adaptRunReceiptValidationStatus(receipt),
1335
+ contextProvenance: adaptRunReceiptContextStatus(receipt),
1336
+ autonomyEnforcement: adaptRunReceiptAutonomyStatus(receipt)
1337
+ } : unauthenticatedReceiptProjection(receipt, options.integrity);
1338
+ return composeTrustStatus({
1339
+ artifactIntegrity: adaptReceiptIntegrityStatus(receipt, options.integrity),
1340
+ ...receiptProjection,
1341
+ independentReview: absentTrustStatus(receipt === null || receipt === void 0 ? "artifact_missing" : "not_recorded"),
1342
+ completionEvidence: absentTrustStatus(
1343
+ receipt === null || receipt === void 0 ? "artifact_missing" : "not_recorded"
1344
+ )
1345
+ });
1346
+ }
1347
+ function inspectRunReceiptTrustStatus(receipt, envelope) {
1348
+ let integrity;
1349
+ if (receipt === null || receipt === void 0) {
1350
+ integrity = { ok: false, reason: "receipt unavailable" };
1351
+ } else if (envelope === null || envelope === void 0) {
1352
+ integrity = { ok: false, reason: "run ledger envelope unavailable" };
1353
+ } else {
1354
+ try {
1355
+ integrity = verifyReceiptIntegrityOutcome(receipt, envelope);
1356
+ } catch (error) {
1357
+ integrity = {
1358
+ ok: false,
1359
+ reason: `receipt invalid: ${error instanceof Error ? error.message : String(error)}`
1360
+ };
1361
+ }
1362
+ }
1363
+ return {
1364
+ integrity,
1365
+ status: adaptRunReceiptTrustStatus(receipt, { integrity })
1366
+ };
1367
+ }
1368
+ function gateReference(artifact) {
1369
+ return sha256Reference("gate_decision", artifact.id, artifact.integrity.digest);
1370
+ }
1371
+ function gateAuthority(artifact) {
1372
+ if (artifact.outcome === "operator-confirmed") return { kind: "operator", id: "gate-confirmation" };
1373
+ if (artifact.outcome === "full-auto-applied") return { kind: "clio", id: "full-auto-gate-policy" };
1374
+ return { kind: "reviewer", id: artifact.decider?.runId ?? "unavailable-decider" };
1375
+ }
1376
+ function adaptGateDecisionReviewStatus(artifact, subjectRunId, verification) {
1377
+ if (artifact === null || artifact === void 0) return absentTrustStatus("artifact_missing");
1378
+ const source = { kind: "gate_decision", id: artifact.id };
1379
+ const artifacts = [gateReference(artifact)];
1380
+ const authority = gateAuthority(artifact);
1381
+ if (!artifact.subjects.some((subject) => subject.runId === subjectRunId)) return absentTrustStatus("not_recorded");
1382
+ if (verification === void 0 || !verification.ok) {
1383
+ return attributed(
1384
+ "unknown",
1385
+ source,
1386
+ verification === void 0 ? COMPATIBILITY_AUTHORITY : { kind: "unknown", id: "unauthenticated-gate-artifact" },
1387
+ artifacts
1388
+ );
1389
+ }
1390
+ if (artifact.decider === void 0 || artifact.correlation === void 0) {
1391
+ if (artifact.outcome === "operator-confirmed" || artifact.outcome === "full-auto-applied") {
1392
+ return attributed("not_applicable", source, authority, artifacts);
1393
+ }
1394
+ return attributed("inconclusive", source, authority, artifacts);
1395
+ }
1396
+ if (!artifact.correlation.independent) return attributed("not_independent", source, authority, artifacts);
1397
+ if (artifact.outcome === "pass") return attributed("passed", source, authority, artifacts);
1398
+ if (artifact.outcome === "fail") return attributed("failed", source, authority, artifacts);
1399
+ if (artifact.outcome === "winner") {
1400
+ return attributed(
1401
+ artifact.winner?.subject.runId === subjectRunId ? "passed" : "failed",
1402
+ source,
1403
+ authority,
1404
+ artifacts
1405
+ );
1406
+ }
1407
+ return attributed("inconclusive", source, authority, artifacts);
1408
+ }
1409
+ function adaptGroundedEvidenceValidationStatus(input) {
1410
+ const observed = (input.artifacts ?? []).filter((artifact) => !SELF_REPORTED_ARTIFACT_KINDS.has(artifact.kind));
1411
+ if (observed.length === 0) return absentTrustStatus("not_observed");
1412
+ return attributed(
1413
+ "validated",
1414
+ { kind: "evidence_bundle", id: `${input.evidenceId}:${input.runId}` },
1415
+ { kind: "clio", id: "evidence-grounding" },
1416
+ uniqueBoundedReferences([{ kind: "evidence_bundle", id: input.evidenceId }, ...observed])
1417
+ );
1418
+ }
1419
+ function adaptFinishContractCompletionStatus(assessment, options = {}) {
1420
+ const artifacts = uniqueBoundedReferences(
1421
+ options.artifacts ?? assessment.evidence.map((evidence, index) => ({
1422
+ kind: evidence.turnId === void 0 ? "finish_contract_evidence" : "session_entry",
1423
+ id: evidence.turnId ?? `${evidence.kind}:${index + 1}`
1424
+ }))
1425
+ );
1426
+ const source = { kind: "finish_contract", id: options.sourceId ?? assessment.reason };
1427
+ const authority = { kind: "clio", id: "finish-contract" };
1428
+ if (assessment.reason === "no_mutation") return attributed("not_applicable", source, authority, artifacts);
1429
+ if (assessment.reason === "validation_evidence") return attributed("evidenced", source, authority, artifacts);
1430
+ if (assessment.reason === "explicit_limitation") return attributed("limited", source, authority, artifacts);
1431
+ return attributed("incomplete", source, authority, artifacts);
1432
+ }
1433
+ function uniqueBoundedReferences(references) {
1434
+ const sorted = [...references].sort(compareArtifactReferences);
1435
+ const unique = sorted.filter(
1436
+ (reference, index) => index === 0 || compareArtifactReferences(sorted[index - 1], reference) !== 0
1437
+ );
1438
+ return unique.slice(0, TRUST_STATUS_MAX_ARTIFACT_REFERENCES);
1439
+ }
1440
+
866
1441
  // src/domains/eval/provenance.ts
867
1442
  init_esm_shims();
868
1443
  import { spawnSync } from "node:child_process";
@@ -933,7 +1508,7 @@ function parseEvalTaskFileYaml(raw) {
933
1508
  }
934
1509
  function validateEvalTaskFile(value) {
935
1510
  const issues = [];
936
- if (!isRecord3(value)) {
1511
+ if (!isRecord4(value)) {
937
1512
  return { valid: false, issues: [{ path: "$", message: "expected object" }] };
938
1513
  }
939
1514
  if (value.version !== EVAL_TASK_FILE_VERSION) {
@@ -969,7 +1544,7 @@ var EvalTaskFileError = class extends Error {
969
1544
  }
970
1545
  };
971
1546
  function parseTask(value, path, issues) {
972
- if (!isRecord3(value)) {
1547
+ if (!isRecord4(value)) {
973
1548
  issues.push({ path, message: "expected object" });
974
1549
  return null;
975
1550
  }
@@ -1043,13 +1618,158 @@ function readPositiveInteger(record, path, field, issues) {
1043
1618
  }
1044
1619
  return value;
1045
1620
  }
1046
- function isRecord3(value) {
1621
+ function isRecord4(value) {
1047
1622
  return typeof value === "object" && value !== null && !Array.isArray(value);
1048
1623
  }
1049
1624
  function sha256Hex(content) {
1050
1625
  return createHash3("sha256").update(content, "utf8").digest("hex");
1051
1626
  }
1052
1627
 
1628
+ // src/domains/evidence/trust-projection.ts
1629
+ init_esm_shims();
1630
+ var TRUST_SUMMARY_VERSION = 1;
1631
+ var TRUST_SUMMARY_MAX_REFS = 8;
1632
+ var TRUST_STATE_WORDS = {
1633
+ artifactIntegrity: {
1634
+ verified: "sealed",
1635
+ failed: "seal broken",
1636
+ absent: "no receipt",
1637
+ unknown: "seal unchecked",
1638
+ not_applicable: "seal not applicable"
1639
+ },
1640
+ validationGrounding: {
1641
+ validated: "grounded",
1642
+ failed: "validation failed",
1643
+ ungrounded: "inferred: validation claimed, none observed",
1644
+ absent: "no validation observed",
1645
+ unknown: "validation unknown",
1646
+ not_applicable: "validation not applicable"
1647
+ },
1648
+ independentReview: {
1649
+ passed: "independently reviewed: pass",
1650
+ failed: "independently reviewed: fail",
1651
+ inconclusive: "independent review inconclusive",
1652
+ not_independent: "review not independent",
1653
+ absent: "not independently reviewed",
1654
+ unknown: "independent review unknown",
1655
+ not_applicable: "independent review not applicable"
1656
+ },
1657
+ contextProvenance: {
1658
+ recorded: "context recorded",
1659
+ invalid: "context record invalid",
1660
+ absent: "context not recorded",
1661
+ unknown: "context unknown",
1662
+ not_applicable: "context not applicable"
1663
+ },
1664
+ autonomyEnforcement: {
1665
+ enforced: "mediated",
1666
+ approximated: "approximated",
1667
+ bypassed: "bypassed",
1668
+ absent: "autonomy not recorded",
1669
+ unknown: "autonomy unknown",
1670
+ not_applicable: "autonomy not applicable"
1671
+ },
1672
+ completionEvidence: {
1673
+ evidenced: "completion evidenced",
1674
+ incomplete: "completion unevidenced",
1675
+ limited: "completion limited",
1676
+ absent: "completion not recorded",
1677
+ unknown: "completion unknown",
1678
+ not_applicable: "completion not applicable"
1679
+ }
1680
+ };
1681
+ function trustStateWord(axis, state) {
1682
+ const words = TRUST_STATE_WORDS[axis];
1683
+ return words[state] ?? words.unknown ?? "unknown";
1684
+ }
1685
+ function authorityOf(status, axis) {
1686
+ const entry = status[axis];
1687
+ return entry.state === "absent" ? null : `${entry.authority.kind}:${entry.authority.id}`;
1688
+ }
1689
+ function integrityClause(status) {
1690
+ const retired = retiredIntegrityVersionOf(status.artifactIntegrity);
1691
+ if (retired !== null) return `seal v${retired} retired (this build verifies v${RUN_RECEIPT_INTEGRITY_VERSION})`;
1692
+ return trustStateWord("artifactIntegrity", status.artifactIntegrity.state);
1693
+ }
1694
+ function validationClause(status) {
1695
+ const entry = status.validationGrounding;
1696
+ const word = trustStateWord("validationGrounding", entry.state);
1697
+ if (entry.state === "absent") return word;
1698
+ if (entry.state === "validated" || entry.state === "failed") return `${word} by ${entry.authority.id}`;
1699
+ if (entry.state === "unknown" && entry.authority.kind !== "unknown") return `${word} (${entry.authority.id})`;
1700
+ return word;
1701
+ }
1702
+ function autonomyClause(status) {
1703
+ const entry = status.autonomyEnforcement;
1704
+ const word = trustStateWord("autonomyEnforcement", entry.state);
1705
+ if (entry.state !== "approximated" && entry.state !== "bypassed") return word;
1706
+ return `${word} (${entry.authority.id})`;
1707
+ }
1708
+ function formatTrustSummary(status) {
1709
+ return [
1710
+ integrityClause(status),
1711
+ validationClause(status),
1712
+ trustStateWord("independentReview", status.independentReview.state),
1713
+ autonomyClause(status),
1714
+ trustStateWord("contextProvenance", status.contextProvenance.state),
1715
+ trustStateWord("completionEvidence", status.completionEvidence.state)
1716
+ ].join("; ");
1717
+ }
1718
+ function formatTrustSummaryLine(status) {
1719
+ return `trust v${TRUST_SUMMARY_VERSION}: ${formatTrustSummary(status)}`;
1720
+ }
1721
+ function formatTrustAxes(status) {
1722
+ return [`trust_status=v${status.version}`, ...TRUST_STATUS_AXES.map((axis) => `${axis}:${status[axis].state}`)].join(
1723
+ " "
1724
+ );
1725
+ }
1726
+ function isUnanswered(status, axis) {
1727
+ const state = status[axis].state;
1728
+ return state === "absent" || state === "unknown";
1729
+ }
1730
+ function trustVerdict(status) {
1731
+ const integrity = status.artifactIntegrity.state;
1732
+ const validation = status.validationGrounding.state;
1733
+ const review = status.independentReview.state;
1734
+ const autonomy = status.autonomyEnforcement.state;
1735
+ if (integrity === "failed" || autonomy === "bypassed" || validation === "failed" || validation === "ungrounded" || review === "failed" || review === "not_independent" || status.contextProvenance.state === "invalid") {
1736
+ return "compromised";
1737
+ }
1738
+ if (integrity !== "verified") return "unknown";
1739
+ if (review === "passed") return "reviewed";
1740
+ if (validation === "validated") return "grounded";
1741
+ return "unverified";
1742
+ }
1743
+ function claimantOf(status) {
1744
+ const state = status.validationGrounding.state;
1745
+ if (state === "absent" || state === "ungrounded") return "worker";
1746
+ return authorityOf(status, "validationGrounding") ?? "worker";
1747
+ }
1748
+ function referenceKey(reference) {
1749
+ return `${reference.kind}:${reference.id}`;
1750
+ }
1751
+ function trustSummaryReferences(status) {
1752
+ const keys = /* @__PURE__ */ new Set();
1753
+ for (const axis of TRUST_STATUS_AXES) {
1754
+ const entry = status[axis];
1755
+ if (entry.state === "absent") continue;
1756
+ for (const reference of entry.artifacts) keys.add(referenceKey(reference));
1757
+ }
1758
+ return [...keys].sort().slice(0, TRUST_SUMMARY_MAX_REFS);
1759
+ }
1760
+ function summarizeTrustStatus(status) {
1761
+ const axes = Object.fromEntries(TRUST_STATUS_AXES.map((axis) => [axis, status[axis].state]));
1762
+ return {
1763
+ version: TRUST_SUMMARY_VERSION,
1764
+ verdict: trustVerdict(status),
1765
+ text: formatTrustSummary(status),
1766
+ axes,
1767
+ claimant: claimantOf(status),
1768
+ unknown: TRUST_STATUS_AXES.filter((axis) => isUnanswered(status, axis)),
1769
+ refs: trustSummaryReferences(status)
1770
+ };
1771
+ }
1772
+
1053
1773
  export {
1054
1774
  RUN_RECEIPT_INTEGRITY_VERSION,
1055
1775
  RUN_RECEIPT_INTEGRITY_ALGORITHM,
@@ -1065,9 +1785,25 @@ export {
1065
1785
  writeEvalArtifactV4,
1066
1786
  loadEvalArtifactV4,
1067
1787
  parseEvalArtifactV4,
1788
+ TRUST_STATUS_AXES,
1789
+ isTrustStatusIdentifier,
1790
+ normalizeTrustStatus,
1791
+ composeTrustStatus,
1792
+ retiredReceiptIntegrity,
1793
+ retiredReceiptIntegrityReason,
1794
+ retiredIntegrityVersionOf,
1795
+ adaptRunReceiptTrustStatus,
1796
+ inspectRunReceiptTrustStatus,
1797
+ adaptGateDecisionReviewStatus,
1798
+ adaptGroundedEvidenceValidationStatus,
1799
+ adaptFinishContractCompletionStatus,
1068
1800
  evalClioProvenance,
1069
1801
  evalEnvironmentProvenance,
1070
1802
  loadEvalTaskFile,
1071
- EvalTaskFileError
1803
+ EvalTaskFileError,
1804
+ formatTrustSummary,
1805
+ formatTrustSummaryLine,
1806
+ formatTrustAxes,
1807
+ summarizeTrustStatus
1072
1808
  };
1073
- //# sourceMappingURL=chunk-OH3TOQTB.js.map
1809
+ //# sourceMappingURL=chunk-K4XHGFR5.js.map