@oscharko-dev/keiko 1.0.5 → 1.1.0

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 (930) hide show
  1. package/README.md +11 -1
  2. package/dist/ui/csp-hashes.json +6 -6
  3. package/dist/ui/static/404.html +1 -1
  4. package/dist/ui/static/__next.__PAGE__.txt +16 -14
  5. package/dist/ui/static/__next._full.txt +21 -20
  6. package/dist/ui/static/__next._tree.txt +2 -2
  7. package/dist/ui/static/_next/static/chunks/000t9p2ysi3dv.css +1 -0
  8. package/dist/ui/static/_next/static/chunks/01_gc9m97_vw5.js +1 -0
  9. package/dist/ui/static/_next/static/chunks/02p2_qr2a9511.js +1 -0
  10. package/dist/ui/static/_next/static/chunks/02ug3u_si269z.js +1 -0
  11. package/dist/ui/static/_next/static/chunks/03deeo56ud39g.js +1 -0
  12. package/dist/ui/static/_next/static/chunks/0_8kv51rrhcg-.js +1 -0
  13. package/dist/ui/static/_next/static/chunks/0ahpt93l7-z9f.js +1 -0
  14. package/dist/ui/static/_next/static/chunks/0bbv42deftomm.js +1 -0
  15. package/dist/ui/static/_next/static/chunks/0c3w2ubla6ek6.js +1 -0
  16. package/dist/ui/static/_next/static/chunks/0e6em7dg4gr6q.js +1 -0
  17. package/dist/ui/static/_next/static/chunks/0gnizm29lk3ll.js +1 -0
  18. package/dist/ui/static/_next/static/chunks/0m0w3hleoejwg.js +1 -0
  19. package/dist/ui/static/_next/static/chunks/{2nubqp1hwandv.js → 0ojvvjnsf38bk.js} +1 -1
  20. package/dist/ui/static/_next/static/chunks/0we68cbpsgepq.css +1 -0
  21. package/dist/ui/static/_next/static/chunks/0xqxs7rppw_o5.css +5 -0
  22. package/dist/ui/static/_next/static/chunks/0z5be09yla9lp.js +1 -0
  23. package/dist/ui/static/_next/static/chunks/14aztwc0_78th.js +1 -0
  24. package/dist/ui/static/_next/static/chunks/18-rkk8vbltb8.js +1 -0
  25. package/dist/ui/static/_next/static/chunks/187yy--dlljjz.js +1 -0
  26. package/dist/ui/static/_next/static/chunks/1ep9f2fjv7oh7.js +1 -0
  27. package/dist/ui/static/_next/static/chunks/1hk335vrug1rc.js +1 -0
  28. package/dist/ui/static/_next/static/chunks/1kacubgk0y2ki.js +1 -0
  29. package/dist/ui/static/_next/static/chunks/1kxhf3ld28pzk.js +1 -0
  30. package/dist/ui/static/_next/static/chunks/1lb8ju8qa0d9m.js +1 -0
  31. package/dist/ui/static/_next/static/chunks/1lrj3d157kay1.js +5 -0
  32. package/dist/ui/static/_next/static/chunks/1mcajwmbse068.js +7 -0
  33. package/dist/ui/static/_next/static/chunks/{2l9r80s3qje3v.js → 1piodmepoegnw.js} +1 -1
  34. package/dist/ui/static/_next/static/chunks/1qsl7dx87n-af.js +1 -0
  35. package/dist/ui/static/_next/static/chunks/{0vywz1p6au4ri.js → 1uetvnnpa5z22.js} +1 -1
  36. package/dist/ui/static/_next/static/chunks/1uulmf99vtuyt.js +1 -0
  37. package/dist/ui/static/_next/static/chunks/202kx3p8axlmr.js +1 -0
  38. package/dist/ui/static/_next/static/chunks/{0hn7lj400e79p.js → 2179tism08tgt.js} +1 -1
  39. package/dist/ui/static/_next/static/chunks/21t1klb1thn76.js +1 -0
  40. package/dist/ui/static/_next/static/chunks/29nzymeooaepv.js +1 -0
  41. package/dist/ui/static/_next/static/chunks/2_o61-akoq549.js +1 -0
  42. package/dist/ui/static/_next/static/chunks/{064diuwddstj6.js → 2cn33khz2ae-h.js} +1 -1
  43. package/dist/ui/static/_next/static/chunks/{0b3klia_y6i3z.js → 2dbr8ufwv1hwn.js} +1 -1
  44. package/dist/ui/static/_next/static/chunks/2dpxapmdvqlh1.js +1 -0
  45. package/dist/ui/static/_next/static/chunks/2e4prtd3wmn0a.js +1 -0
  46. package/dist/ui/static/_next/static/chunks/2h_zvmb272ozs.js +1 -0
  47. package/dist/ui/static/_next/static/chunks/{3qtph5seqciux.css → 2l0gyhe4jpu23.css} +5 -5
  48. package/dist/ui/static/_next/static/chunks/2l9ens2l3tayx.js +1 -0
  49. package/dist/ui/static/_next/static/chunks/2oxvgl3qb19wf.js +1 -0
  50. package/dist/ui/static/_next/static/chunks/2s9-91g2jic6u.js +1 -0
  51. package/dist/ui/static/_next/static/chunks/2uoxlx30y60nf.js +1 -0
  52. package/dist/ui/static/_next/static/chunks/2vhgpp_064_st.js +1 -0
  53. package/dist/ui/static/_next/static/chunks/2xpud5k1hwfvf.js +1 -0
  54. package/dist/ui/static/_next/static/chunks/2ywqac8g8us1n.css +1 -0
  55. package/dist/ui/static/_next/static/chunks/3-htoy7v6gx51.js +1 -0
  56. package/dist/ui/static/_next/static/chunks/3-l-8qt163_y6.js +1 -0
  57. package/dist/ui/static/_next/static/chunks/3_rof9w-g14_v.js +3 -0
  58. package/dist/ui/static/_next/static/chunks/3aqtjd-a1ygis.js +1 -0
  59. package/dist/ui/static/_next/static/chunks/3d-10944zk2o9.js +1 -0
  60. package/dist/ui/static/_next/static/chunks/3f6svr_pokw6j.js +1 -0
  61. package/dist/ui/static/_next/static/chunks/3ibevys2o09xx.js +1 -0
  62. package/dist/ui/static/_next/static/chunks/3iv5llh4xg-7v.js +1 -0
  63. package/dist/ui/static/_next/static/chunks/3ly6-f_52vfie.js +1 -0
  64. package/dist/ui/static/_next/static/chunks/3pm8eiwwesd47.js +1 -0
  65. package/dist/ui/static/_next/static/chunks/3tr04kks52pjw.js +1 -0
  66. package/dist/ui/static/_next/static/chunks/3wwyidrm300kk.js +1 -0
  67. package/dist/ui/static/_next/static/chunks/3xw9gh9d5ngza.js +1 -0
  68. package/dist/ui/static/_next/static/chunks/3zbk4r-6rxn7j.css +2 -0
  69. package/dist/ui/static/_next/static/chunks/42y02tbxkub8f.js +1 -0
  70. package/dist/ui/static/_not-found/__next._full.txt +20 -18
  71. package/dist/ui/static/_not-found/__next._not-found.__PAGE__.txt +13 -11
  72. package/dist/ui/static/_not-found/__next._tree.txt +1 -1
  73. package/dist/ui/static/_not-found.html +1 -1
  74. package/dist/ui/static/_not-found.txt +20 -18
  75. package/dist/ui/static/atlassian-connectors/__next._full.txt +22 -20
  76. package/dist/ui/static/atlassian-connectors/__next._tree.txt +1 -1
  77. package/dist/ui/static/atlassian-connectors/__next.atlassian-connectors.__PAGE__.txt +15 -13
  78. package/dist/ui/static/atlassian-connectors.html +1 -1
  79. package/dist/ui/static/atlassian-connectors.txt +22 -20
  80. package/dist/ui/static/index.html +1 -1
  81. package/dist/ui/static/index.txt +21 -20
  82. package/dist/ui/static/launch/__next._full.txt +25 -23
  83. package/dist/ui/static/launch/__next._tree.txt +2 -2
  84. package/dist/ui/static/launch/__next.launch.__PAGE__.txt +16 -14
  85. package/dist/ui/static/launch.html +1 -1
  86. package/dist/ui/static/launch.txt +25 -23
  87. package/dist/ui/static/local-knowledge/__next._full.txt +25 -23
  88. package/dist/ui/static/local-knowledge/__next._tree.txt +2 -2
  89. package/dist/ui/static/local-knowledge/__next.local-knowledge.__PAGE__.txt +16 -14
  90. package/dist/ui/static/local-knowledge/capsule/__next._full.txt +23 -21
  91. package/dist/ui/static/local-knowledge/capsule/__next._tree.txt +1 -1
  92. package/dist/ui/static/local-knowledge/capsule/__next.local-knowledge.capsule.__PAGE__.txt +15 -13
  93. package/dist/ui/static/local-knowledge/capsule.html +1 -1
  94. package/dist/ui/static/local-knowledge/capsule.txt +23 -21
  95. package/dist/ui/static/local-knowledge.html +1 -1
  96. package/dist/ui/static/local-knowledge.txt +25 -23
  97. package/node_modules/@oscharko-dev/keiko-cli/dist/activity-log-line-reader.d.ts +30 -0
  98. package/node_modules/@oscharko-dev/keiko-cli/dist/activity-log-line-reader.d.ts.map +1 -0
  99. package/node_modules/@oscharko-dev/keiko-cli/dist/activity-log-line-reader.js +114 -0
  100. package/node_modules/@oscharko-dev/keiko-cli/dist/audit.d.ts.map +1 -1
  101. package/node_modules/@oscharko-dev/keiko-cli/dist/audit.js +108 -39
  102. package/node_modules/@oscharko-dev/keiko-cli/dist/cli-activity-log.d.ts +3 -0
  103. package/node_modules/@oscharko-dev/keiko-cli/dist/cli-activity-log.d.ts.map +1 -0
  104. package/node_modules/@oscharko-dev/keiko-cli/dist/cli-activity-log.js +14 -0
  105. package/node_modules/@oscharko-dev/keiko-cli/dist/cli-control-state.d.ts +1 -1
  106. package/node_modules/@oscharko-dev/keiko-cli/dist/cli-control-state.d.ts.map +1 -1
  107. package/node_modules/@oscharko-dev/keiko-cli/dist/cli-control-state.js +7 -4
  108. package/node_modules/@oscharko-dev/keiko-cli/dist/cli-model-resolution.d.ts.map +1 -1
  109. package/node_modules/@oscharko-dev/keiko-cli/dist/cli-model-resolution.js +3 -1
  110. package/node_modules/@oscharko-dev/keiko-cli/dist/evaluate.d.ts.map +1 -1
  111. package/node_modules/@oscharko-dev/keiko-cli/dist/evaluate.js +4 -2
  112. package/node_modules/@oscharko-dev/keiko-cli/dist/install-layout.d.ts +60 -7
  113. package/node_modules/@oscharko-dev/keiko-cli/dist/install-layout.d.ts.map +1 -1
  114. package/node_modules/@oscharko-dev/keiko-cli/dist/install-layout.js +32 -10
  115. package/node_modules/@oscharko-dev/keiko-cli/dist/launcher-state.js +1 -1
  116. package/node_modules/@oscharko-dev/keiko-cli/dist/lifecycle.d.ts.map +1 -1
  117. package/node_modules/@oscharko-dev/keiko-cli/dist/lifecycle.js +82 -103
  118. package/node_modules/@oscharko-dev/keiko-cli/dist/memory.d.ts.map +1 -1
  119. package/node_modules/@oscharko-dev/keiko-cli/dist/memory.js +14 -7
  120. package/node_modules/@oscharko-dev/keiko-cli/dist/portable-launch-notifier.d.ts.map +1 -1
  121. package/node_modules/@oscharko-dev/keiko-cli/dist/portable-launch-notifier.js +30 -7
  122. package/node_modules/@oscharko-dev/keiko-cli/dist/process-activity-log.d.ts +197 -0
  123. package/node_modules/@oscharko-dev/keiko-cli/dist/process-activity-log.d.ts.map +1 -0
  124. package/node_modules/@oscharko-dev/keiko-cli/dist/process-activity-log.js +147 -0
  125. package/node_modules/@oscharko-dev/keiko-cli/dist/process-guards.d.ts +3 -2
  126. package/node_modules/@oscharko-dev/keiko-cli/dist/process-guards.d.ts.map +1 -1
  127. package/node_modules/@oscharko-dev/keiko-cli/dist/process-guards.js +49 -36
  128. package/node_modules/@oscharko-dev/keiko-cli/dist/prompt-enhancer.d.ts.map +1 -1
  129. package/node_modules/@oscharko-dev/keiko-cli/dist/prompt-enhancer.js +9 -7
  130. package/node_modules/@oscharko-dev/keiko-cli/dist/repair.d.ts.map +1 -1
  131. package/node_modules/@oscharko-dev/keiko-cli/dist/repair.js +8 -3
  132. package/node_modules/@oscharko-dev/keiko-cli/dist/run.d.ts.map +1 -1
  133. package/node_modules/@oscharko-dev/keiko-cli/dist/run.js +3 -1
  134. package/node_modules/@oscharko-dev/keiko-cli/dist/runner.d.ts.map +1 -1
  135. package/node_modules/@oscharko-dev/keiko-cli/dist/runner.js +58 -18
  136. package/node_modules/@oscharko-dev/keiko-cli/dist/security-log.d.ts.map +1 -1
  137. package/node_modules/@oscharko-dev/keiko-cli/dist/security-log.js +126 -57
  138. package/node_modules/@oscharko-dev/keiko-cli/dist/state-paths.d.ts +1 -1
  139. package/node_modules/@oscharko-dev/keiko-cli/dist/state-paths.d.ts.map +1 -1
  140. package/node_modules/@oscharko-dev/keiko-cli/dist/state-paths.js +29 -6
  141. package/node_modules/@oscharko-dev/keiko-cli/dist/support-analyze-sufficiency.d.ts +52 -0
  142. package/node_modules/@oscharko-dev/keiko-cli/dist/support-analyze-sufficiency.d.ts.map +1 -0
  143. package/node_modules/@oscharko-dev/keiko-cli/dist/support-analyze-sufficiency.js +249 -0
  144. package/node_modules/@oscharko-dev/keiko-cli/dist/support-analyze.d.ts +85 -0
  145. package/node_modules/@oscharko-dev/keiko-cli/dist/support-analyze.d.ts.map +1 -1
  146. package/node_modules/@oscharko-dev/keiko-cli/dist/support-analyze.js +498 -56
  147. package/node_modules/@oscharko-dev/keiko-cli/dist/support-export.d.ts +12 -8
  148. package/node_modules/@oscharko-dev/keiko-cli/dist/support-export.d.ts.map +1 -1
  149. package/node_modules/@oscharko-dev/keiko-cli/dist/support-export.js +147 -99
  150. package/node_modules/@oscharko-dev/keiko-cli/dist/support-incident.d.ts +50 -0
  151. package/node_modules/@oscharko-dev/keiko-cli/dist/support-incident.d.ts.map +1 -0
  152. package/node_modules/@oscharko-dev/keiko-cli/dist/support-incident.js +317 -0
  153. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query-cli.d.ts +80 -0
  154. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query-cli.d.ts.map +1 -0
  155. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query-cli.js +462 -0
  156. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query-evidence.d.ts +480 -0
  157. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query-evidence.d.ts.map +1 -0
  158. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query-evidence.js +191 -0
  159. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query.d.ts +169 -0
  160. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query.d.ts.map +1 -0
  161. package/node_modules/@oscharko-dev/keiko-cli/dist/support-query.js +709 -0
  162. package/node_modules/@oscharko-dev/keiko-cli/dist/support-segment-manifest-names.d.ts +6 -0
  163. package/node_modules/@oscharko-dev/keiko-cli/dist/support-segment-manifest-names.d.ts.map +1 -0
  164. package/node_modules/@oscharko-dev/keiko-cli/dist/support-segment-manifest-names.js +27 -0
  165. package/node_modules/@oscharko-dev/keiko-cli/dist/support-segment-manifest.d.ts +164 -0
  166. package/node_modules/@oscharko-dev/keiko-cli/dist/support-segment-manifest.d.ts.map +1 -0
  167. package/node_modules/@oscharko-dev/keiko-cli/dist/support-segment-manifest.js +688 -0
  168. package/node_modules/@oscharko-dev/keiko-cli/dist/support-segment-scan.d.ts +78 -0
  169. package/node_modules/@oscharko-dev/keiko-cli/dist/support-segment-scan.d.ts.map +1 -0
  170. package/node_modules/@oscharko-dev/keiko-cli/dist/support-segment-scan.js +252 -0
  171. package/node_modules/@oscharko-dev/keiko-cli/dist/support-selective-export.d.ts +43 -0
  172. package/node_modules/@oscharko-dev/keiko-cli/dist/support-selective-export.d.ts.map +1 -0
  173. package/node_modules/@oscharko-dev/keiko-cli/dist/support-selective-export.js +115 -0
  174. package/node_modules/@oscharko-dev/keiko-cli/dist/support-tool-catalog.d.ts.map +1 -1
  175. package/node_modules/@oscharko-dev/keiko-cli/dist/support-tool-catalog.js +118 -4
  176. package/node_modules/@oscharko-dev/keiko-cli/dist/support.d.ts +21 -2
  177. package/node_modules/@oscharko-dev/keiko-cli/dist/support.d.ts.map +1 -1
  178. package/node_modules/@oscharko-dev/keiko-cli/dist/support.js +885 -177
  179. package/node_modules/@oscharko-dev/keiko-cli/dist/ui-process-stop.d.ts.map +1 -1
  180. package/node_modules/@oscharko-dev/keiko-cli/dist/ui-process-stop.js +95 -24
  181. package/node_modules/@oscharko-dev/keiko-cli/dist/ui.d.ts +13 -4
  182. package/node_modules/@oscharko-dev/keiko-cli/dist/ui.d.ts.map +1 -1
  183. package/node_modules/@oscharko-dev/keiko-cli/dist/ui.js +364 -109
  184. package/node_modules/@oscharko-dev/keiko-cli/dist/uninstall.d.ts.map +1 -1
  185. package/node_modules/@oscharko-dev/keiko-cli/dist/uninstall.js +123 -51
  186. package/node_modules/@oscharko-dev/keiko-cli/package.json +14 -14
  187. package/node_modules/@oscharko-dev/keiko-connectors/dist/version.d.ts +1 -1
  188. package/node_modules/@oscharko-dev/keiko-connectors/dist/version.js +1 -1
  189. package/node_modules/@oscharko-dev/keiko-connectors/package.json +3 -3
  190. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.d.ts +6322 -0
  191. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.d.ts.map +1 -0
  192. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-failure-class-contracts.js +8278 -0
  193. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-files.d.ts +54 -0
  194. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-files.d.ts.map +1 -0
  195. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-files.js +215 -0
  196. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-loss.d.ts +16 -0
  197. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-loss.d.ts.map +1 -0
  198. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-loss.js +82 -0
  199. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.d.ts +50926 -0
  200. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.d.ts.map +1 -0
  201. package/node_modules/@oscharko-dev/keiko-contracts/dist/activity-log-registry.generated.js +60264 -0
  202. package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.d.ts +19 -0
  203. package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.d.ts.map +1 -1
  204. package/node_modules/@oscharko-dev/keiko-contracts/dist/code-task-acceptance.d.ts +2 -2
  205. package/node_modules/@oscharko-dev/keiko-contracts/dist/code-task-acceptance.d.ts.map +1 -1
  206. package/node_modules/@oscharko-dev/keiko-contracts/dist/code-task-acceptance.js +1 -2
  207. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-api.d.ts +5 -0
  208. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-api.d.ts.map +1 -1
  209. package/node_modules/@oscharko-dev/keiko-contracts/dist/coding-workbench-runtime-api.js +15 -0
  210. package/node_modules/@oscharko-dev/keiko-contracts/dist/diagnostics.d.ts +145 -1
  211. package/node_modules/@oscharko-dev/keiko-contracts/dist/diagnostics.d.ts.map +1 -1
  212. package/node_modules/@oscharko-dev/keiko-contracts/dist/diagnostics.js +532 -6
  213. package/node_modules/@oscharko-dev/keiko-contracts/dist/gateway.d.ts +1 -1
  214. package/node_modules/@oscharko-dev/keiko-contracts/dist/gateway.d.ts.map +1 -1
  215. package/node_modules/@oscharko-dev/keiko-contracts/dist/gateway.js +1 -0
  216. package/node_modules/@oscharko-dev/keiko-contracts/dist/governed-tool-catalog.d.ts +1 -1
  217. package/node_modules/@oscharko-dev/keiko-contracts/dist/governed-tool-catalog.d.ts.map +1 -1
  218. package/node_modules/@oscharko-dev/keiko-contracts/dist/index.d.ts +1 -1
  219. package/node_modules/@oscharko-dev/keiko-contracts/dist/index.d.ts.map +1 -1
  220. package/node_modules/@oscharko-dev/keiko-contracts/dist/observability.d.ts +235 -0
  221. package/node_modules/@oscharko-dev/keiko-contracts/dist/observability.d.ts.map +1 -1
  222. package/node_modules/@oscharko-dev/keiko-contracts/dist/observability.js +743 -0
  223. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-incident.d.ts +216 -0
  224. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-incident.d.ts.map +1 -0
  225. package/node_modules/@oscharko-dev/keiko-contracts/dist/support-incident.js +403 -0
  226. package/node_modules/@oscharko-dev/keiko-contracts/dist/verification.d.ts +3 -0
  227. package/node_modules/@oscharko-dev/keiko-contracts/dist/verification.d.ts.map +1 -1
  228. package/node_modules/@oscharko-dev/keiko-contracts/dist/verification.js +18 -1
  229. package/node_modules/@oscharko-dev/keiko-contracts/dist/version.d.ts +2 -2
  230. package/node_modules/@oscharko-dev/keiko-contracts/dist/version.js +2 -2
  231. package/node_modules/@oscharko-dev/keiko-contracts/package.json +1 -1
  232. package/node_modules/@oscharko-dev/keiko-evaluations/dist/model-provider.d.ts +2 -1
  233. package/node_modules/@oscharko-dev/keiko-evaluations/dist/model-provider.d.ts.map +1 -1
  234. package/node_modules/@oscharko-dev/keiko-evaluations/dist/model-provider.js +1 -1
  235. package/node_modules/@oscharko-dev/keiko-evaluations/dist/runner.d.ts +2 -1
  236. package/node_modules/@oscharko-dev/keiko-evaluations/dist/runner.d.ts.map +1 -1
  237. package/node_modules/@oscharko-dev/keiko-evaluations/dist/runner.js +2 -1
  238. package/node_modules/@oscharko-dev/keiko-evaluations/package.json +9 -9
  239. package/node_modules/@oscharko-dev/keiko-evidence/dist/version.d.ts +1 -1
  240. package/node_modules/@oscharko-dev/keiko-evidence/dist/version.js +1 -1
  241. package/node_modules/@oscharko-dev/keiko-evidence/package.json +4 -4
  242. package/node_modules/@oscharko-dev/keiko-git/dist/types.d.ts +20 -0
  243. package/node_modules/@oscharko-dev/keiko-git/dist/types.d.ts.map +1 -1
  244. package/node_modules/@oscharko-dev/keiko-git/dist/version.d.ts +1 -1
  245. package/node_modules/@oscharko-dev/keiko-git/dist/version.js +1 -1
  246. package/node_modules/@oscharko-dev/keiko-git/package.json +1 -1
  247. package/node_modules/@oscharko-dev/keiko-harness/dist/version.d.ts +1 -1
  248. package/node_modules/@oscharko-dev/keiko-harness/dist/version.js +1 -1
  249. package/node_modules/@oscharko-dev/keiko-harness/package.json +7 -7
  250. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/embedding-activity-log.d.ts +68 -0
  251. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/embedding-activity-log.d.ts.map +1 -0
  252. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/embedding-activity-log.js +532 -0
  253. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/embedding-batcher.d.ts.map +1 -1
  254. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/embedding-batcher.js +93 -76
  255. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/orchestrator-activity-log.d.ts +120 -0
  256. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/orchestrator-activity-log.d.ts.map +1 -0
  257. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/orchestrator-activity-log.js +686 -0
  258. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/orchestrator.d.ts.map +1 -1
  259. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/orchestrator.js +150 -207
  260. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/preflight-activity-log.d.ts +36 -0
  261. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/preflight-activity-log.d.ts.map +1 -0
  262. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/preflight-activity-log.js +264 -0
  263. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/types.d.ts.map +1 -1
  264. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/knowledge-log.d.ts +1 -0
  265. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/knowledge-log.d.ts.map +1 -1
  266. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/knowledge-log.js +44 -12
  267. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/repository-pod.d.ts.map +1 -1
  268. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/repository-pod.js +30 -13
  269. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/local-vector-index-port.d.ts.map +1 -1
  270. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/local-vector-index-port.js +25 -6
  271. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/usearch-ann-index.d.ts.map +1 -1
  272. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/retrieval/usearch-ann-index.js +46 -10
  273. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store-content-encryption.d.ts.map +1 -1
  274. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store-content-encryption.js +71 -20
  275. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store.d.ts.map +1 -1
  276. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store.js +54 -17
  277. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.d.ts +1 -1
  278. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.js +1 -1
  279. package/node_modules/@oscharko-dev/keiko-local-knowledge/package.json +5 -5
  280. package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.d.ts +1 -1
  281. package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.js +1 -1
  282. package/node_modules/@oscharko-dev/keiko-memory-capture/package.json +3 -3
  283. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/consolidate.d.ts.map +1 -1
  284. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/consolidate.js +24 -5
  285. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/log-port.d.ts.map +1 -1
  286. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/log-port.js +35 -12
  287. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.d.ts +1 -1
  288. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.js +1 -1
  289. package/node_modules/@oscharko-dev/keiko-memory-consolidation/package.json +3 -3
  290. package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.d.ts +1 -1
  291. package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.js +1 -1
  292. package/node_modules/@oscharko-dev/keiko-memory-governance/package.json +3 -3
  293. package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.d.ts +1 -1
  294. package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.js +1 -1
  295. package/node_modules/@oscharko-dev/keiko-memory-retrieval/package.json +3 -3
  296. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/db.d.ts.map +1 -1
  297. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/db.js +25 -7
  298. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/migrate-encrypt.d.ts +4 -2
  299. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/migrate-encrypt.d.ts.map +1 -1
  300. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/migrate-encrypt.js +37 -12
  301. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/schema.d.ts.map +1 -1
  302. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/schema.js +34 -10
  303. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/vault-log.d.ts +3 -2
  304. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/vault-log.d.ts.map +1 -1
  305. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/vault-log.js +35 -12
  306. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/vault.d.ts.map +1 -1
  307. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/vault.js +24 -6
  308. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.d.ts +1 -1
  309. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.js +1 -1
  310. package/node_modules/@oscharko-dev/keiko-memory-vault/package.json +3 -3
  311. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.d.ts.map +1 -1
  312. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.js +408 -40
  313. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/http.d.ts.map +1 -1
  314. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/http.js +237 -61
  315. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/observability.d.ts +5 -0
  316. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/observability.d.ts.map +1 -1
  317. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/observability.js +72 -12
  318. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-adapter.d.ts.map +1 -1
  319. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-adapter.js +75 -17
  320. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-embedding-adapter.d.ts.map +1 -1
  321. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-embedding-adapter.js +404 -116
  322. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/prDescription/generate.d.ts.map +1 -1
  323. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/prDescription/generate.js +313 -92
  324. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.d.ts +2 -3
  325. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.d.ts.map +1 -1
  326. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.js +260 -54
  327. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/speech-to-text-adapter.d.ts.map +1 -1
  328. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/speech-to-text-adapter.js +31 -11
  329. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/text-to-speech-adapter.d.ts.map +1 -1
  330. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/text-to-speech-adapter.js +147 -21
  331. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/toolCatalogBridge.d.ts.map +1 -1
  332. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/toolCatalogBridge.js +190 -44
  333. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.d.ts +1 -1
  334. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.js +1 -1
  335. package/node_modules/@oscharko-dev/keiko-model-gateway/package.json +4 -4
  336. package/node_modules/@oscharko-dev/keiko-quality-intelligence/package.json +3 -3
  337. package/node_modules/@oscharko-dev/keiko-sandbox/package.json +2 -2
  338. package/node_modules/@oscharko-dev/keiko-sdk/package.json +9 -9
  339. package/node_modules/@oscharko-dev/keiko-security/dist/fs-atomic-rename.d.ts.map +1 -1
  340. package/node_modules/@oscharko-dev/keiko-security/dist/fs-atomic-rename.js +39 -14
  341. package/node_modules/@oscharko-dev/keiko-security/dist/fs-hardening.d.ts +107 -0
  342. package/node_modules/@oscharko-dev/keiko-security/dist/fs-hardening.d.ts.map +1 -1
  343. package/node_modules/@oscharko-dev/keiko-security/dist/fs-hardening.js +1998 -1
  344. package/node_modules/@oscharko-dev/keiko-security/dist/index.d.ts +2 -1
  345. package/node_modules/@oscharko-dev/keiko-security/dist/index.d.ts.map +1 -1
  346. package/node_modules/@oscharko-dev/keiko-security/dist/index.js +1 -3
  347. package/node_modules/@oscharko-dev/keiko-security/dist/log-port.d.ts.map +1 -1
  348. package/node_modules/@oscharko-dev/keiko-security/dist/log-port.js +36 -13
  349. package/node_modules/@oscharko-dev/keiko-security/dist/macos-keychain.d.ts.map +1 -1
  350. package/node_modules/@oscharko-dev/keiko-security/dist/macos-keychain.js +31 -15
  351. package/node_modules/@oscharko-dev/keiko-security/dist/portable-tree-attestation.d.ts +2 -1
  352. package/node_modules/@oscharko-dev/keiko-security/dist/portable-tree-attestation.d.ts.map +1 -1
  353. package/node_modules/@oscharko-dev/keiko-security/dist/portable-tree-attestation.js +46 -15
  354. package/node_modules/@oscharko-dev/keiko-security/dist/safe-artifact-directory-mutation-protocol.d.ts +23 -0
  355. package/node_modules/@oscharko-dev/keiko-security/dist/safe-artifact-directory-mutation-protocol.d.ts.map +1 -0
  356. package/node_modules/@oscharko-dev/keiko-security/dist/safe-artifact-directory-mutation-protocol.js +11 -0
  357. package/node_modules/@oscharko-dev/keiko-security/dist/safe-artifact-directory-mutation-runtime.d.ts +9 -0
  358. package/node_modules/@oscharko-dev/keiko-security/dist/safe-artifact-directory-mutation-runtime.d.ts.map +1 -0
  359. package/node_modules/@oscharko-dev/keiko-security/dist/safe-artifact-directory-mutation-runtime.js +115 -0
  360. package/node_modules/@oscharko-dev/keiko-security/dist/safe-artifact-directory-mutation.d.ts +2 -0
  361. package/node_modules/@oscharko-dev/keiko-security/dist/safe-artifact-directory-mutation.d.ts.map +1 -0
  362. package/node_modules/@oscharko-dev/keiko-security/dist/safe-artifact-directory-mutation.js +50 -0
  363. package/node_modules/@oscharko-dev/keiko-security/dist/secret-vault.d.ts.map +1 -1
  364. package/node_modules/@oscharko-dev/keiko-security/dist/secret-vault.js +260 -50
  365. package/node_modules/@oscharko-dev/keiko-security/dist/version.d.ts +1 -1
  366. package/node_modules/@oscharko-dev/keiko-security/dist/version.js +1 -1
  367. package/node_modules/@oscharko-dev/keiko-security/dist/windows-local-volume.d.ts.map +1 -1
  368. package/node_modules/@oscharko-dev/keiko-security/dist/windows-local-volume.js +32 -7
  369. package/node_modules/@oscharko-dev/keiko-security/dist/windows-shortcuts.d.ts.map +1 -1
  370. package/node_modules/@oscharko-dev/keiko-security/dist/windows-shortcuts.js +38 -14
  371. package/node_modules/@oscharko-dev/keiko-security/package.json +2 -2
  372. package/node_modules/@oscharko-dev/keiko-server/dist/atlassian/credentialRoutes.d.ts.map +1 -1
  373. package/node_modules/@oscharko-dev/keiko-server/dist/atlassian/credentialRoutes.js +47 -5
  374. package/node_modules/@oscharko-dev/keiko-server/dist/bounded-request-body.d.ts.map +1 -1
  375. package/node_modules/@oscharko-dev/keiko-server/dist/bounded-request-body.js +160 -37
  376. package/node_modules/@oscharko-dev/keiko-server/dist/chat-activity.d.ts +48 -0
  377. package/node_modules/@oscharko-dev/keiko-server/dist/chat-activity.d.ts.map +1 -0
  378. package/node_modules/@oscharko-dev/keiko-server/dist/chat-activity.js +336 -0
  379. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-model-summary.d.ts.map +1 -1
  380. package/node_modules/@oscharko-dev/keiko-server/dist/chat-compaction-model-summary.js +28 -10
  381. package/node_modules/@oscharko-dev/keiko-server/dist/chat-handlers.d.ts +5 -5
  382. package/node_modules/@oscharko-dev/keiko-server/dist/chat-handlers.d.ts.map +1 -1
  383. package/node_modules/@oscharko-dev/keiko-server/dist/chat-handlers.js +49 -66
  384. package/node_modules/@oscharko-dev/keiko-server/dist/chat-stream-handlers.d.ts.map +1 -1
  385. package/node_modules/@oscharko-dev/keiko-server/dist/chat-stream-handlers.js +5 -1
  386. package/node_modules/@oscharko-dev/keiko-server/dist/client-diagnostics-routes.d.ts +9 -1
  387. package/node_modules/@oscharko-dev/keiko-server/dist/client-diagnostics-routes.d.ts.map +1 -1
  388. package/node_modules/@oscharko-dev/keiko-server/dist/client-diagnostics-routes.js +1202 -50
  389. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/codingAppSessionRoutes.d.ts.map +1 -1
  390. package/node_modules/@oscharko-dev/keiko-server/dist/coding-app-session/codingAppSessionRoutes.js +98 -35
  391. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/activity-log.d.ts +22 -0
  392. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/activity-log.d.ts.map +1 -0
  393. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/activity-log.js +83 -0
  394. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/codeContextConnector.d.ts.map +1 -1
  395. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/codeContextConnector.js +10 -15
  396. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/codingRuntimeIssueIntake.d.ts.map +1 -1
  397. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/codingRuntimeIssueIntake.js +45 -23
  398. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/githubAuthorizationRoutes.d.ts.map +1 -1
  399. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/githubAuthorizationRoutes.js +21 -6
  400. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/githubCodeContextPort.d.ts.map +1 -1
  401. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/githubCodeContextPort.js +90 -12
  402. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/githubIssueReaderAuthorization.d.ts.map +1 -1
  403. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/githubIssueReaderAuthorization.js +85 -27
  404. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/githubIssueResolution.d.ts +2 -0
  405. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/githubIssueResolution.d.ts.map +1 -1
  406. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/githubIssueResolution.js +118 -14
  407. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/issuePreviewRoutes.d.ts.map +1 -1
  408. package/node_modules/@oscharko-dev/keiko-server/dist/coding-context/issuePreviewRoutes.js +53 -9
  409. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingHistoryRoutes.d.ts +7 -0
  410. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingHistoryRoutes.d.ts.map +1 -0
  411. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingHistoryRoutes.js +78 -0
  412. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRepositorySearchHandler.d.ts.map +1 -1
  413. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRepositorySearchHandler.js +126 -27
  414. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeActivityOperations.d.ts +857 -0
  415. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeActivityOperations.d.ts.map +1 -0
  416. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeActivityOperations.js +411 -0
  417. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeCiRepairBudgetStore.d.ts.map +1 -1
  418. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeCiRepairBudgetStore.js +49 -44
  419. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeCiRepairBudgetTypes.d.ts +2 -0
  420. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeCiRepairBudgetTypes.d.ts.map +1 -1
  421. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeCiRepairBudgetTypes.js +17 -0
  422. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeCiRepairController.d.ts +9 -1
  423. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeCiRepairController.d.ts.map +1 -1
  424. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeCiRepairController.js +38 -20
  425. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeControlPlane.d.ts +2 -0
  426. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeControlPlane.d.ts.map +1 -1
  427. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeControlPlane.js +4 -0
  428. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeHistory.d.ts +40 -0
  429. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeHistory.d.ts.map +1 -0
  430. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeHistory.js +372 -0
  431. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeIssueIntake.d.ts +2 -0
  432. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeIssueIntake.d.ts.map +1 -1
  433. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeIssueIntake.js +104 -20
  434. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeManager.d.ts.map +1 -1
  435. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeManager.js +0 -1
  436. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOperationCoordinator.d.ts.map +1 -1
  437. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOperationCoordinator.js +183 -27
  438. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestrator.d.ts +12 -3
  439. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestrator.d.ts.map +1 -1
  440. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestrator.js +963 -223
  441. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestratorTypes.d.ts +3 -0
  442. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeOrchestratorTypes.d.ts.map +1 -1
  443. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRoutes.d.ts.map +1 -1
  444. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeRoutes.js +123 -14
  445. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeSnapshotStore.d.ts +2 -0
  446. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeSnapshotStore.d.ts.map +1 -1
  447. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeSnapshotStore.js +33 -16
  448. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeVerifiedCommitAuthorityStore.d.ts.map +1 -1
  449. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingRuntimeVerifiedCommitAuthorityStore.js +23 -9
  450. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingSafeActivityProjection.d.ts +1 -1
  451. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingSafeActivityProjection.d.ts.map +1 -1
  452. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingSafeActivityProjection.js +66 -19
  453. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolAuthorityPort.d.ts.map +1 -1
  454. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolAuthorityPort.js +46 -5
  455. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacade.d.ts.map +1 -1
  456. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolFacade.js +13 -1
  457. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolGovernedDelegate.d.ts.map +1 -1
  458. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolGovernedDelegate.js +6 -5
  459. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolIpc.d.ts +8 -2
  460. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolIpc.d.ts.map +1 -1
  461. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolReadEditPorts.d.ts.map +1 -1
  462. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/codingToolReadEditPorts.js +130 -31
  463. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/devLanePortableCodingRuntime.js +3 -3
  464. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/devLaneRuntimeProcessBackend.d.ts +1 -1
  465. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/devLaneRuntimeProcessBackend.d.ts.map +1 -1
  466. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/devLaneRuntimeProcessBackend.js +54 -47
  467. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/nativeRuntimeProcessBackend.d.ts +1 -1
  468. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/nativeRuntimeProcessBackend.d.ts.map +1 -1
  469. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/nativeRuntimeProcessBackend.js +13 -16
  470. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeLaunchProfile.d.ts +5 -2
  471. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeLaunchProfile.d.ts.map +1 -1
  472. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeLaunchProfile.js +56 -4
  473. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeProtocolSurface.d.ts +4 -1
  474. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeProtocolSurface.d.ts.map +1 -1
  475. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeProtocolSurface.js +24 -4
  476. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeAdapter.d.ts +10 -1
  477. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeAdapter.d.ts.map +1 -1
  478. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeAdapter.js +244 -61
  479. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeComposition.d.ts +2 -1
  480. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeComposition.d.ts.map +1 -1
  481. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeRuntimeComposition.js +268 -368
  482. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeToolSchemas.d.ts +5 -13
  483. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeToolSchemas.d.ts.map +1 -1
  484. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeToolSchemas.js +15 -44
  485. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2ApprovalRequests.d.ts +16 -0
  486. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2ApprovalRequests.d.ts.map +1 -0
  487. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2ApprovalRequests.js +86 -0
  488. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2History.d.ts +22 -0
  489. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2History.d.ts.map +1 -0
  490. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2History.js +438 -0
  491. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2HttpClient.d.ts +30 -0
  492. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2HttpClient.d.ts.map +1 -0
  493. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2HttpClient.js +251 -0
  494. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2Questions.d.ts +7 -0
  495. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2Questions.d.ts.map +1 -0
  496. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/opencodeV2Questions.js +125 -0
  497. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionAuxiliaryPorts.d.ts.map +1 -1
  498. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionAuxiliaryPorts.js +42 -14
  499. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCiRepairRuntime.d.ts.map +1 -1
  500. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCiRepairRuntime.js +65 -36
  501. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCodingRuntimePorts.d.ts.map +1 -1
  502. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCodingRuntimePorts.js +109 -21
  503. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCodingRuntimeQuestionPort.d.ts.map +1 -1
  504. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCodingRuntimeQuestionPort.js +3 -6
  505. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCodingRuntimeResolver.d.ts +1 -1
  506. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCodingRuntimeResolver.d.ts.map +1 -1
  507. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionCodingRuntimeResolver.js +18 -8
  508. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionDraftDeliveryDependencies.d.ts.map +1 -1
  509. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionDraftDeliveryDependencies.js +160 -46
  510. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionManagedWorktreeTools.d.ts.map +1 -1
  511. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionManagedWorktreeTools.js +423 -106
  512. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeActivation.d.ts +2 -0
  513. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeActivation.d.ts.map +1 -1
  514. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeActivation.js +100 -18
  515. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeBackend.d.ts +6 -1
  516. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeBackend.d.ts.map +1 -1
  517. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionOpenCodeBackend.js +43 -16
  518. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionRuntimeGitPreparation.d.ts.map +1 -1
  519. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionRuntimeGitPreparation.js +51 -7
  520. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionVerifiedCommitDependencies.d.ts.map +1 -1
  521. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/productionVerifiedCommitDependencies.js +32 -9
  522. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/readOnlyChildOrchestrator.d.ts +1 -1
  523. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/readOnlyChildOrchestrator.d.ts.map +1 -1
  524. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/readOnlyChildOrchestrator.js +155 -22
  525. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/runtimeAuthorityService.d.ts +1 -1
  526. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/runtimeAuthorityService.d.ts.map +1 -1
  527. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/runtimeAuthorityService.js +300 -61
  528. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/windowsPortableAuthenticode.d.ts.map +1 -1
  529. package/node_modules/@oscharko-dev/keiko-server/dist/coding-runtime/windowsPortableAuthenticode.js +30 -11
  530. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-gateway.d.ts.map +1 -1
  531. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-gateway.js +240 -61
  532. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-tool-facade.d.ts.map +1 -1
  533. package/node_modules/@oscharko-dev/keiko-server/dist/coding-sidecar-tool-facade.js +45 -8
  534. package/node_modules/@oscharko-dev/keiko-server/dist/deps-activity.d.ts +40 -0
  535. package/node_modules/@oscharko-dev/keiko-server/dist/deps-activity.d.ts.map +1 -0
  536. package/node_modules/@oscharko-dev/keiko-server/dist/deps-activity.js +207 -0
  537. package/node_modules/@oscharko-dev/keiko-server/dist/deps.d.ts +7 -1
  538. package/node_modules/@oscharko-dev/keiko-server/dist/deps.d.ts.map +1 -1
  539. package/node_modules/@oscharko-dev/keiko-server/dist/deps.js +69 -58
  540. package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.d.ts +1 -1
  541. package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.d.ts.map +1 -1
  542. package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.js +194 -26
  543. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentProducerRoute.d.ts.map +1 -1
  544. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentProducerRoute.js +113 -17
  545. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentRoutes.d.ts.map +1 -1
  546. package/node_modules/@oscharko-dev/keiko-server/dist/editor/agentRoutes.js +7 -1
  547. package/node_modules/@oscharko-dev/keiko-server/dist/editor/dap/debugLaunchPlan.d.ts.map +1 -1
  548. package/node_modules/@oscharko-dev/keiko-server/dist/editor/dap/debugLaunchPlan.js +35 -11
  549. package/node_modules/@oscharko-dev/keiko-server/dist/editor/localHistory/localHistoryCapture.d.ts +1 -1
  550. package/node_modules/@oscharko-dev/keiko-server/dist/editor/localHistory/localHistoryCapture.d.ts.map +1 -1
  551. package/node_modules/@oscharko-dev/keiko-server/dist/editor/localHistory/localHistoryCapture.js +56 -15
  552. package/node_modules/@oscharko-dev/keiko-server/dist/editor/lsp/lspNodeAdapter.d.ts.map +1 -1
  553. package/node_modules/@oscharko-dev/keiko-server/dist/editor/lsp/lspNodeAdapter.js +201 -37
  554. package/node_modules/@oscharko-dev/keiko-server/dist/editor/lsp/lspProcessManager.d.ts.map +1 -1
  555. package/node_modules/@oscharko-dev/keiko-server/dist/editor/lsp/lspProcessManager.js +51 -11
  556. package/node_modules/@oscharko-dev/keiko-server/dist/editor/lsp/providers/javaProvider.d.ts.map +1 -1
  557. package/node_modules/@oscharko-dev/keiko-server/dist/editor/lsp/providers/javaProvider.js +78 -11
  558. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationExecution.d.ts +4 -1
  559. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationExecution.d.ts.map +1 -1
  560. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationExecution.js +55 -0
  561. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationRunner.d.ts.map +1 -1
  562. package/node_modules/@oscharko-dev/keiko-server/dist/editor/verificationRunner.js +211 -65
  563. package/node_modules/@oscharko-dev/keiko-server/dist/editor/watch/workspaceWatchRoutes.d.ts.map +1 -1
  564. package/node_modules/@oscharko-dev/keiko-server/dist/editor/watch/workspaceWatchRoutes.js +33 -6
  565. package/node_modules/@oscharko-dev/keiko-server/dist/evidence-retention-log.d.ts.map +1 -1
  566. package/node_modules/@oscharko-dev/keiko-server/dist/evidence-retention-log.js +36 -6
  567. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-instance-cache.d.ts.map +1 -1
  568. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-instance-cache.js +97 -22
  569. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.d.ts +5 -3
  570. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.d.ts.map +1 -1
  571. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-readiness.js +220 -39
  572. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.d.ts.map +1 -1
  573. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.js +283 -68
  574. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-spend-budget.d.ts.map +1 -1
  575. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-spend-budget.js +138 -45
  576. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeChatContext.d.ts.map +1 -1
  577. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeChatContext.js +97 -13
  578. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeRoutes.d.ts +5 -0
  579. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeRoutes.d.ts.map +1 -1
  580. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeRoutes.js +146 -30
  581. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeSnapshotReader.d.ts.map +1 -1
  582. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeSnapshotReader.js +13 -1
  583. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeSnapshotRegistry.d.ts.map +1 -1
  584. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeSnapshotRegistry.js +122 -32
  585. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeSnapshotService.d.ts.map +1 -1
  586. package/node_modules/@oscharko-dev/keiko-server/dist/gitChangeSnapshotService.js +140 -24
  587. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/approvalEvents.d.ts +6 -2
  588. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/approvalEvents.d.ts.map +1 -1
  589. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/approvalEvents.js +192 -8
  590. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/ciObservationService.d.ts.map +1 -1
  591. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/ciObservationService.js +154 -26
  592. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/commitRoutes.d.ts +2 -2
  593. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/commitRoutes.d.ts.map +1 -1
  594. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/commitRoutes.js +100 -46
  595. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryChecks.d.ts +21 -0
  596. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryChecks.d.ts.map +1 -1
  597. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryChecks.js +108 -13
  598. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryChecksRefresh.d.ts.map +1 -1
  599. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryChecksRefresh.js +23 -20
  600. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryFacts.d.ts.map +1 -1
  601. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryFacts.js +93 -18
  602. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryLedger.d.ts +28 -0
  603. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryLedger.d.ts.map +1 -1
  604. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryLedger.js +123 -33
  605. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryService.d.ts.map +1 -1
  606. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryService.js +33 -33
  607. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryTemplate.d.ts.map +1 -1
  608. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftDeliveryTemplate.js +97 -24
  609. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftRelatedIssuesActivity.d.ts +150 -0
  610. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftRelatedIssuesActivity.d.ts.map +1 -0
  611. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/draftRelatedIssuesActivity.js +64 -0
  612. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/execution.d.ts +226 -1
  613. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/execution.d.ts.map +1 -1
  614. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/execution.js +344 -70
  615. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/journeyObservationService.d.ts +25 -0
  616. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/journeyObservationService.d.ts.map +1 -1
  617. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/journeyObservationService.js +159 -26
  618. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/journeyRoutes.d.ts.map +1 -1
  619. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/journeyRoutes.js +238 -59
  620. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/localMutationRoutes.d.ts.map +1 -1
  621. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/localMutationRoutes.js +2 -9
  622. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/mergeExecution.d.ts.map +1 -1
  623. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/mergeExecution.js +79 -13
  624. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionPreparation.d.ts.map +1 -1
  625. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionPreparation.js +6 -2
  626. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionProjection.d.ts.map +1 -1
  627. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionProjection.js +133 -16
  628. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionReceiptStore.d.ts.map +1 -1
  629. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionReceiptStore.js +73 -19
  630. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionRoutes.d.ts.map +1 -1
  631. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionRoutes.js +147 -50
  632. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionService.d.ts.map +1 -1
  633. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionService.js +4 -3
  634. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionTypes.d.ts +12 -4
  635. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prDescriptionTypes.d.ts.map +1 -1
  636. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prMarkReadyExecution.d.ts +1 -1
  637. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prMarkReadyExecution.d.ts.map +1 -1
  638. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/prMarkReadyExecution.js +138 -42
  639. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/repositoryInitializationRoutes.d.ts.map +1 -1
  640. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/repositoryInitializationRoutes.js +51 -7
  641. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/requestPreparation.d.ts +4 -0
  642. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/requestPreparation.d.ts.map +1 -1
  643. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/requestPreparation.js +145 -26
  644. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/runtimeGitRead.d.ts.map +1 -1
  645. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/runtimeGitRead.js +43 -13
  646. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/runtimeGitService.d.ts.map +1 -1
  647. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/runtimeGitService.js +122 -11
  648. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/syncRoutes.d.ts.map +1 -1
  649. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/syncRoutes.js +4 -15
  650. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/verifiedCommitService.d.ts.map +1 -1
  651. package/node_modules/@oscharko-dev/keiko-server/dist/gitDelivery/verifiedCommitService.js +194 -11
  652. package/node_modules/@oscharko-dev/keiko-server/dist/gitProcessActivity.d.ts +5 -2
  653. package/node_modules/@oscharko-dev/keiko-server/dist/gitProcessActivity.d.ts.map +1 -1
  654. package/node_modules/@oscharko-dev/keiko-server/dist/gitProcessActivity.js +157 -31
  655. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-orchestrator.d.ts.map +1 -1
  656. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-orchestrator.js +514 -74
  657. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa.d.ts.map +1 -1
  658. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa.js +7 -2
  659. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank-facade.d.ts.map +1 -1
  660. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank-facade.js +84 -20
  661. package/node_modules/@oscharko-dev/keiko-server/dist/harness-context-compactor.d.ts.map +1 -1
  662. package/node_modules/@oscharko-dev/keiko-server/dist/harness-context-compactor.js +30 -9
  663. package/node_modules/@oscharko-dev/keiko-server/dist/index.d.ts +7 -0
  664. package/node_modules/@oscharko-dev/keiko-server/dist/index.d.ts.map +1 -1
  665. package/node_modules/@oscharko-dev/keiko-server/dist/index.js +20 -0
  666. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-handlers.d.ts.map +1 -1
  667. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-handlers.js +287 -68
  668. package/node_modules/@oscharko-dev/keiko-server/dist/memory-embedding.d.ts.map +1 -1
  669. package/node_modules/@oscharko-dev/keiko-server/dist/memory-embedding.js +219 -65
  670. package/node_modules/@oscharko-dev/keiko-server/dist/native-file-dialog/route.d.ts.map +1 -1
  671. package/node_modules/@oscharko-dev/keiko-server/dist/native-file-dialog/route.js +30 -10
  672. package/node_modules/@oscharko-dev/keiko-server/dist/observability/activity-log-loss-summary.d.ts +233 -0
  673. package/node_modules/@oscharko-dev/keiko-server/dist/observability/activity-log-loss-summary.d.ts.map +1 -0
  674. package/node_modules/@oscharko-dev/keiko-server/dist/observability/activity-log-loss-summary.js +124 -0
  675. package/node_modules/@oscharko-dev/keiko-server/dist/observability/activity-log-persistence.d.ts +8 -0
  676. package/node_modules/@oscharko-dev/keiko-server/dist/observability/activity-log-persistence.d.ts.map +1 -0
  677. package/node_modules/@oscharko-dev/keiko-server/dist/observability/activity-log-persistence.js +25 -0
  678. package/node_modules/@oscharko-dev/keiko-server/dist/observability/activity-log-readiness.d.ts +34 -0
  679. package/node_modules/@oscharko-dev/keiko-server/dist/observability/activity-log-readiness.d.ts.map +1 -0
  680. package/node_modules/@oscharko-dev/keiko-server/dist/observability/activity-log-readiness.js +301 -0
  681. package/node_modules/@oscharko-dev/keiko-server/dist/observability/activity-log-store.d.ts +215 -0
  682. package/node_modules/@oscharko-dev/keiko-server/dist/observability/activity-log-store.d.ts.map +1 -0
  683. package/node_modules/@oscharko-dev/keiko-server/dist/observability/activity-log-store.js +755 -0
  684. package/node_modules/@oscharko-dev/keiko-server/dist/observability/index.d.ts +4 -0
  685. package/node_modules/@oscharko-dev/keiko-server/dist/observability/index.d.ts.map +1 -1
  686. package/node_modules/@oscharko-dev/keiko-server/dist/observability/index.js +6 -2
  687. package/node_modules/@oscharko-dev/keiko-server/dist/observability/log-redaction.d.ts.map +1 -1
  688. package/node_modules/@oscharko-dev/keiko-server/dist/observability/log-redaction.js +25 -14
  689. package/node_modules/@oscharko-dev/keiko-server/dist/observability/model-id-evidence.d.ts +17 -0
  690. package/node_modules/@oscharko-dev/keiko-server/dist/observability/model-id-evidence.d.ts.map +1 -0
  691. package/node_modules/@oscharko-dev/keiko-server/dist/observability/model-id-evidence.js +35 -0
  692. package/node_modules/@oscharko-dev/keiko-server/dist/observability/runtime-state-dir.d.ts +6 -0
  693. package/node_modules/@oscharko-dev/keiko-server/dist/observability/runtime-state-dir.d.ts.map +1 -0
  694. package/node_modules/@oscharko-dev/keiko-server/dist/observability/runtime-state-dir.js +23 -0
  695. package/node_modules/@oscharko-dev/keiko-server/dist/observability/server-log.d.ts +106 -6
  696. package/node_modules/@oscharko-dev/keiko-server/dist/observability/server-log.d.ts.map +1 -1
  697. package/node_modules/@oscharko-dev/keiko-server/dist/observability/server-log.js +2504 -481
  698. package/node_modules/@oscharko-dev/keiko-server/dist/observability/server-logger.d.ts +38 -2
  699. package/node_modules/@oscharko-dev/keiko-server/dist/observability/server-logger.d.ts.map +1 -1
  700. package/node_modules/@oscharko-dev/keiko-server/dist/observability/server-logger.js +187 -39
  701. package/node_modules/@oscharko-dev/keiko-server/dist/observability/support-incident-store.d.ts +44 -0
  702. package/node_modules/@oscharko-dev/keiko-server/dist/observability/support-incident-store.d.ts.map +1 -0
  703. package/node_modules/@oscharko-dev/keiko-server/dist/observability/support-incident-store.js +255 -0
  704. package/node_modules/@oscharko-dev/keiko-server/dist/observability/support-incident.d.ts +107 -0
  705. package/node_modules/@oscharko-dev/keiko-server/dist/observability/support-incident.d.ts.map +1 -0
  706. package/node_modules/@oscharko-dev/keiko-server/dist/observability/support-incident.js +1052 -0
  707. package/node_modules/@oscharko-dev/keiko-server/dist/process-log-sink.d.ts.map +1 -1
  708. package/node_modules/@oscharko-dev/keiko-server/dist/process-log-sink.js +66 -17
  709. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/capsuleAdapter.d.ts +3 -2
  710. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/capsuleAdapter.d.ts.map +1 -1
  711. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/capsuleAdapter.js +35 -5
  712. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/figmaSnapshotRoutes.d.ts.map +1 -1
  713. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/figmaSnapshotRoutes.js +3 -1
  714. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/handoffRoutes.d.ts.map +1 -1
  715. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/handoffRoutes.js +7 -6
  716. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/reCheckRoutes.d.ts.map +1 -1
  717. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/reCheckRoutes.js +7 -2
  718. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/runRoutes.d.ts.map +1 -1
  719. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/runRoutes.js +7 -2
  720. package/node_modules/@oscharko-dev/keiko-server/dist/reference-id.d.ts +16 -0
  721. package/node_modules/@oscharko-dev/keiko-server/dist/reference-id.d.ts.map +1 -0
  722. package/node_modules/@oscharko-dev/keiko-server/dist/reference-id.js +90 -0
  723. package/node_modules/@oscharko-dev/keiko-server/dist/routes.d.ts.map +1 -1
  724. package/node_modules/@oscharko-dev/keiko-server/dist/routes.js +12 -7
  725. package/node_modules/@oscharko-dev/keiko-server/dist/run-engine.d.ts.map +1 -1
  726. package/node_modules/@oscharko-dev/keiko-server/dist/run-engine.js +3 -3
  727. package/node_modules/@oscharko-dev/keiko-server/dist/run-handlers.d.ts.map +1 -1
  728. package/node_modules/@oscharko-dev/keiko-server/dist/run-handlers.js +33 -9
  729. package/node_modules/@oscharko-dev/keiko-server/dist/server.d.ts.map +1 -1
  730. package/node_modules/@oscharko-dev/keiko-server/dist/server.js +50 -10
  731. package/node_modules/@oscharko-dev/keiko-server/dist/sse-write.d.ts.map +1 -1
  732. package/node_modules/@oscharko-dev/keiko-server/dist/sse-write.js +37 -9
  733. package/node_modules/@oscharko-dev/keiko-server/dist/store/chats.d.ts.map +1 -1
  734. package/node_modules/@oscharko-dev/keiko-server/dist/store/chats.js +3 -2
  735. package/node_modules/@oscharko-dev/keiko-server/dist/store/codingHistory.d.ts +36 -0
  736. package/node_modules/@oscharko-dev/keiko-server/dist/store/codingHistory.d.ts.map +1 -0
  737. package/node_modules/@oscharko-dev/keiko-server/dist/store/codingHistory.js +191 -0
  738. package/node_modules/@oscharko-dev/keiko-server/dist/store/codingHistoryIsolation.d.ts +5 -0
  739. package/node_modules/@oscharko-dev/keiko-server/dist/store/codingHistoryIsolation.d.ts.map +1 -0
  740. package/node_modules/@oscharko-dev/keiko-server/dist/store/codingHistoryIsolation.js +44 -0
  741. package/node_modules/@oscharko-dev/keiko-server/dist/store/db.d.ts +1 -1
  742. package/node_modules/@oscharko-dev/keiko-server/dist/store/db.d.ts.map +1 -1
  743. package/node_modules/@oscharko-dev/keiko-server/dist/store/db.js +61 -37
  744. package/node_modules/@oscharko-dev/keiko-server/dist/store/journeyOutcomeMigration.d.ts.map +1 -1
  745. package/node_modules/@oscharko-dev/keiko-server/dist/store/journeyOutcomeMigration.js +26 -5
  746. package/node_modules/@oscharko-dev/keiko-server/dist/store/legacySchemaTestFixture.d.ts.map +1 -1
  747. package/node_modules/@oscharko-dev/keiko-server/dist/store/legacySchemaTestFixture.js +9 -1
  748. package/node_modules/@oscharko-dev/keiko-server/dist/store/schema.d.ts +1 -1
  749. package/node_modules/@oscharko-dev/keiko-server/dist/store/schema.d.ts.map +1 -1
  750. package/node_modules/@oscharko-dev/keiko-server/dist/store/schema.js +31 -1
  751. package/node_modules/@oscharko-dev/keiko-server/dist/store/transaction.d.ts +4 -0
  752. package/node_modules/@oscharko-dev/keiko-server/dist/store/transaction.d.ts.map +1 -0
  753. package/node_modules/@oscharko-dev/keiko-server/dist/store/transaction.js +19 -0
  754. package/node_modules/@oscharko-dev/keiko-server/dist/store/types.d.ts +6 -1
  755. package/node_modules/@oscharko-dev/keiko-server/dist/store/types.d.ts.map +1 -1
  756. package/node_modules/@oscharko-dev/keiko-server/dist/store-handlers.d.ts.map +1 -1
  757. package/node_modules/@oscharko-dev/keiko-server/dist/store-handlers.js +34 -8
  758. package/node_modules/@oscharko-dev/keiko-server/dist/task-workspace/activity-log.d.ts.map +1 -1
  759. package/node_modules/@oscharko-dev/keiko-server/dist/task-workspace/activity-log.js +212 -13
  760. package/node_modules/@oscharko-dev/keiko-server/dist/task-workspace/workspace-root-access.d.ts.map +1 -1
  761. package/node_modules/@oscharko-dev/keiko-server/dist/task-workspace/workspace-root-access.js +31 -28
  762. package/node_modules/@oscharko-dev/keiko-server/dist/terminal-routes.d.ts.map +1 -1
  763. package/node_modules/@oscharko-dev/keiko-server/dist/terminal-routes.js +6 -10
  764. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolBinder.d.ts.map +1 -1
  765. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolBinder.js +18 -9
  766. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolFacadeBridge.d.ts.map +1 -1
  767. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolFacadeBridge.js +41 -5
  768. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolLifecycle.d.ts.map +1 -1
  769. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolLifecycle.js +401 -17
  770. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolSettlement.d.ts.map +1 -1
  771. package/node_modules/@oscharko-dev/keiko-server/dist/tool-catalog/catalogToolSettlement.js +1 -2
  772. package/node_modules/@oscharko-dev/keiko-server/dist/update-candidate-authority.d.ts +1 -1
  773. package/node_modules/@oscharko-dev/keiko-server/dist/update-candidate-authority.d.ts.map +1 -1
  774. package/node_modules/@oscharko-dev/keiko-server/dist/update-candidate-authority.js +170 -39
  775. package/node_modules/@oscharko-dev/keiko-server/dist/update-legacy-audit-import.d.ts.map +1 -1
  776. package/node_modules/@oscharko-dev/keiko-server/dist/update-legacy-audit-import.js +94 -66
  777. package/node_modules/@oscharko-dev/keiko-server/dist/update-local-state.d.ts +1 -1
  778. package/node_modules/@oscharko-dev/keiko-server/dist/update-local-state.d.ts.map +1 -1
  779. package/node_modules/@oscharko-dev/keiko-server/dist/update-local-state.js +70 -20
  780. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-normal-startup.d.ts.map +1 -1
  781. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-normal-startup.js +87 -13
  782. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-sidecar-verification.d.ts +2 -2
  783. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-sidecar-verification.d.ts.map +1 -1
  784. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-sidecar-verification.js +7 -7
  785. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-staging.d.ts.map +1 -1
  786. package/node_modules/@oscharko-dev/keiko-server/dist/update-portable-staging.js +4 -4
  787. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-activity.d.ts +16 -0
  788. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-activity.d.ts.map +1 -0
  789. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-activity.js +182 -0
  790. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-portable-assets.d.ts +1 -1
  791. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-portable-assets.d.ts.map +1 -1
  792. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-portable-assets.js +5 -15
  793. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-portable-evidence.d.ts +1 -1
  794. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-portable-evidence.d.ts.map +1 -1
  795. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-portable-evidence.js +21 -47
  796. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-routes.d.ts +5 -5
  797. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-routes.d.ts.map +1 -1
  798. package/node_modules/@oscharko-dev/keiko-server/dist/update-preflight-routes.js +21 -15
  799. package/node_modules/@oscharko-dev/keiko-server/dist/update-runtime-activity.d.ts +39 -0
  800. package/node_modules/@oscharko-dev/keiko-server/dist/update-runtime-activity.d.ts.map +1 -0
  801. package/node_modules/@oscharko-dev/keiko-server/dist/update-runtime-activity.js +266 -0
  802. package/node_modules/@oscharko-dev/keiko-server/dist/update-session.d.ts.map +1 -1
  803. package/node_modules/@oscharko-dev/keiko-server/dist/update-session.js +138 -20
  804. package/node_modules/@oscharko-dev/keiko-server/dist/voice-handlers.d.ts.map +1 -1
  805. package/node_modules/@oscharko-dev/keiko-server/dist/voice-handlers.js +5 -0
  806. package/node_modules/@oscharko-dev/keiko-server/dist/voice-live-dictation.d.ts.map +1 -1
  807. package/node_modules/@oscharko-dev/keiko-server/dist/voice-live-dictation.js +41 -11
  808. package/node_modules/@oscharko-dev/keiko-server/dist/voice-realtime.d.ts.map +1 -1
  809. package/node_modules/@oscharko-dev/keiko-server/dist/voice-realtime.js +70 -17
  810. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-root-denial-log.d.ts +11 -1
  811. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-root-denial-log.d.ts.map +1 -1
  812. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-root-denial-log.js +81 -26
  813. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-script-trust.d.ts +2 -2
  814. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-script-trust.d.ts.map +1 -1
  815. package/node_modules/@oscharko-dev/keiko-server/dist/workspace-script-trust.js +135 -37
  816. package/node_modules/@oscharko-dev/keiko-server/package.json +22 -22
  817. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/dialect.d.ts.map +1 -1
  818. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/dialect.js +4 -6
  819. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/opencode.d.ts +2 -2
  820. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/opencode.d.ts.map +1 -1
  821. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/opencode.js +30 -70
  822. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/profile.d.ts.map +1 -1
  823. package/node_modules/@oscharko-dev/keiko-tool-catalog/dist/profile.js +1 -1
  824. package/node_modules/@oscharko-dev/keiko-tool-catalog/package.json +3 -3
  825. package/node_modules/@oscharko-dev/keiko-tools/dist/version.d.ts +1 -1
  826. package/node_modules/@oscharko-dev/keiko-tools/dist/version.js +1 -1
  827. package/node_modules/@oscharko-dev/keiko-tools/package.json +7 -7
  828. package/node_modules/@oscharko-dev/keiko-verification/dist/dependencies.d.ts +7 -3
  829. package/node_modules/@oscharko-dev/keiko-verification/dist/dependencies.d.ts.map +1 -1
  830. package/node_modules/@oscharko-dev/keiko-verification/dist/dependencies.js +192 -14
  831. package/node_modules/@oscharko-dev/keiko-verification/dist/orchestrator.d.ts +2 -0
  832. package/node_modules/@oscharko-dev/keiko-verification/dist/orchestrator.d.ts.map +1 -1
  833. package/node_modules/@oscharko-dev/keiko-verification/dist/orchestrator.js +6 -2
  834. package/node_modules/@oscharko-dev/keiko-verification/package.json +5 -5
  835. package/node_modules/@oscharko-dev/keiko-workflows/package.json +10 -10
  836. package/node_modules/@oscharko-dev/keiko-workspace/dist/version.d.ts +1 -1
  837. package/node_modules/@oscharko-dev/keiko-workspace/dist/version.js +1 -1
  838. package/node_modules/@oscharko-dev/keiko-workspace/package.json +3 -3
  839. package/package.json +29 -26
  840. package/release-impact.catalog.json +74 -0
  841. package/scripts/lib/local-state-audit.mjs +94 -0
  842. package/vendor/oscharko-dev-keiko-cli-1.1.0.tgz +0 -0
  843. package/vendor/{oscharko-dev-keiko-connectors-1.0.5.tgz → oscharko-dev-keiko-connectors-1.1.0.tgz} +0 -0
  844. package/vendor/oscharko-dev-keiko-contracts-1.1.0.tgz +0 -0
  845. package/vendor/oscharko-dev-keiko-evaluations-1.1.0.tgz +0 -0
  846. package/vendor/{oscharko-dev-keiko-evidence-1.0.5.tgz → oscharko-dev-keiko-evidence-1.1.0.tgz} +0 -0
  847. package/vendor/oscharko-dev-keiko-git-1.1.0.tgz +0 -0
  848. package/vendor/{oscharko-dev-keiko-harness-1.0.5.tgz → oscharko-dev-keiko-harness-1.1.0.tgz} +0 -0
  849. package/vendor/oscharko-dev-keiko-local-knowledge-1.1.0.tgz +0 -0
  850. package/vendor/{oscharko-dev-keiko-memory-capture-1.0.5.tgz → oscharko-dev-keiko-memory-capture-1.1.0.tgz} +0 -0
  851. package/vendor/oscharko-dev-keiko-memory-consolidation-1.1.0.tgz +0 -0
  852. package/vendor/{oscharko-dev-keiko-memory-governance-1.0.5.tgz → oscharko-dev-keiko-memory-governance-1.1.0.tgz} +0 -0
  853. package/vendor/{oscharko-dev-keiko-memory-retrieval-1.0.5.tgz → oscharko-dev-keiko-memory-retrieval-1.1.0.tgz} +0 -0
  854. package/vendor/oscharko-dev-keiko-memory-vault-1.1.0.tgz +0 -0
  855. package/vendor/oscharko-dev-keiko-model-gateway-1.1.0.tgz +0 -0
  856. package/vendor/{oscharko-dev-keiko-quality-intelligence-1.0.5.tgz → oscharko-dev-keiko-quality-intelligence-1.1.0.tgz} +0 -0
  857. package/vendor/oscharko-dev-keiko-sandbox-1.1.0.tgz +0 -0
  858. package/vendor/oscharko-dev-keiko-sdk-1.1.0.tgz +0 -0
  859. package/vendor/oscharko-dev-keiko-security-1.1.0.tgz +0 -0
  860. package/vendor/oscharko-dev-keiko-server-1.1.0.tgz +0 -0
  861. package/vendor/oscharko-dev-keiko-tool-catalog-1.1.0.tgz +0 -0
  862. package/vendor/{oscharko-dev-keiko-tools-1.0.5.tgz → oscharko-dev-keiko-tools-1.1.0.tgz} +0 -0
  863. package/vendor/oscharko-dev-keiko-verification-1.1.0.tgz +0 -0
  864. package/vendor/{oscharko-dev-keiko-workflows-1.0.5.tgz → oscharko-dev-keiko-workflows-1.1.0.tgz} +0 -0
  865. package/vendor/{oscharko-dev-keiko-workspace-1.0.5.tgz → oscharko-dev-keiko-workspace-1.1.0.tgz} +0 -0
  866. package/dist/ui/static/_next/static/chunks/0-tss9mlvjuz4.js +0 -1
  867. package/dist/ui/static/_next/static/chunks/04lb-38e89aw8.js +0 -1
  868. package/dist/ui/static/_next/static/chunks/04t-d0js_hvfr.js +0 -1
  869. package/dist/ui/static/_next/static/chunks/086jxcgou7s_5.js +0 -1
  870. package/dist/ui/static/_next/static/chunks/08pxrik1lm06d.js +0 -5
  871. package/dist/ui/static/_next/static/chunks/093r62_9c_psx.js +0 -1
  872. package/dist/ui/static/_next/static/chunks/0_u5vd-_66bpj.js +0 -1
  873. package/dist/ui/static/_next/static/chunks/0gsb-naamu9g1.js +0 -1
  874. package/dist/ui/static/_next/static/chunks/0ix9hk8cnb0as.js +0 -1
  875. package/dist/ui/static/_next/static/chunks/0n9uef9g17pxd.js +0 -1
  876. package/dist/ui/static/_next/static/chunks/0o131urxtkbxj.js +0 -1
  877. package/dist/ui/static/_next/static/chunks/0pac-465ukeam.js +0 -1
  878. package/dist/ui/static/_next/static/chunks/0qzzopo8q0m1e.js +0 -1
  879. package/dist/ui/static/_next/static/chunks/0vvfq-eocx502.js +0 -1
  880. package/dist/ui/static/_next/static/chunks/15wh9-75zvro2.js +0 -1
  881. package/dist/ui/static/_next/static/chunks/160x2go4zkjhx.js +0 -1
  882. package/dist/ui/static/_next/static/chunks/17yrtbw7mk5py.css +0 -2
  883. package/dist/ui/static/_next/static/chunks/1kgbe4la7mty5.js +0 -1
  884. package/dist/ui/static/_next/static/chunks/1peg9ve597086.js +0 -1
  885. package/dist/ui/static/_next/static/chunks/1q6j3gd8d86-v.css +0 -2
  886. package/dist/ui/static/_next/static/chunks/1t_6hc_5pxuqd.js +0 -1
  887. package/dist/ui/static/_next/static/chunks/1v4mpk8t6w8_7.js +0 -1
  888. package/dist/ui/static/_next/static/chunks/1yj6x688jjk-a.js +0 -1
  889. package/dist/ui/static/_next/static/chunks/21djhsnzx069x.js +0 -1
  890. package/dist/ui/static/_next/static/chunks/23e-psiwdsaxk.js +0 -1
  891. package/dist/ui/static/_next/static/chunks/289h3-vke8o67.js +0 -1
  892. package/dist/ui/static/_next/static/chunks/2dxo0g3208ag1.js +0 -1
  893. package/dist/ui/static/_next/static/chunks/2jadbwshuwe_n.js +0 -1
  894. package/dist/ui/static/_next/static/chunks/2u9u5i8o6vd-w.js +0 -1
  895. package/dist/ui/static/_next/static/chunks/2vj6gqk9lh7yv.js +0 -1
  896. package/dist/ui/static/_next/static/chunks/3-k1y9vbxcms8.js +0 -3
  897. package/dist/ui/static/_next/static/chunks/3137i2nt475lq.js +0 -1
  898. package/dist/ui/static/_next/static/chunks/3_jzs5uvplshk.js +0 -1
  899. package/dist/ui/static/_next/static/chunks/3d-jscai6hb55.js +0 -1
  900. package/dist/ui/static/_next/static/chunks/3dkw81rui6ry8.js +0 -1
  901. package/dist/ui/static/_next/static/chunks/3f3ici8rsavir.js +0 -1
  902. package/dist/ui/static/_next/static/chunks/3f_-h2lm9ml4b.js +0 -1
  903. package/dist/ui/static/_next/static/chunks/3frfm_q9cqdtg.js +0 -1
  904. package/dist/ui/static/_next/static/chunks/3irz7sn3e2ix3.js +0 -1
  905. package/dist/ui/static/_next/static/chunks/3j1p83q4cv4cv.js +0 -1
  906. package/dist/ui/static/_next/static/chunks/3kgmrssgqwg_h.js +0 -1
  907. package/dist/ui/static/_next/static/chunks/3lc67g1jowxt_.js +0 -1
  908. package/dist/ui/static/_next/static/chunks/3pgmij812w0aa.css +0 -1
  909. package/dist/ui/static/_next/static/chunks/3q3ds5x5j4w7j.js +0 -1
  910. package/dist/ui/static/_next/static/chunks/3r2v5s5l7jkoj.js +0 -1
  911. package/dist/ui/static/_next/static/chunks/3w9c58yrtr4oj.js +0 -1
  912. package/dist/ui/static/_next/static/chunks/3wxm1wke5887n.js +0 -7
  913. package/dist/ui/static/_next/static/chunks/3ymz8bp4uzhhh.js +0 -1
  914. package/vendor/oscharko-dev-keiko-cli-1.0.5.tgz +0 -0
  915. package/vendor/oscharko-dev-keiko-contracts-1.0.5.tgz +0 -0
  916. package/vendor/oscharko-dev-keiko-evaluations-1.0.5.tgz +0 -0
  917. package/vendor/oscharko-dev-keiko-git-1.0.5.tgz +0 -0
  918. package/vendor/oscharko-dev-keiko-local-knowledge-1.0.5.tgz +0 -0
  919. package/vendor/oscharko-dev-keiko-memory-consolidation-1.0.5.tgz +0 -0
  920. package/vendor/oscharko-dev-keiko-memory-vault-1.0.5.tgz +0 -0
  921. package/vendor/oscharko-dev-keiko-model-gateway-1.0.5.tgz +0 -0
  922. package/vendor/oscharko-dev-keiko-sandbox-1.0.5.tgz +0 -0
  923. package/vendor/oscharko-dev-keiko-sdk-1.0.5.tgz +0 -0
  924. package/vendor/oscharko-dev-keiko-security-1.0.5.tgz +0 -0
  925. package/vendor/oscharko-dev-keiko-server-1.0.5.tgz +0 -0
  926. package/vendor/oscharko-dev-keiko-tool-catalog-1.0.5.tgz +0 -0
  927. package/vendor/oscharko-dev-keiko-verification-1.0.5.tgz +0 -0
  928. /package/dist/ui/static/_next/static/{IaAMlj5CIiO4E3RPp1TWn → pnaCuBv6v6k-xKyv71Bct}/_buildManifest.js +0 -0
  929. /package/dist/ui/static/_next/static/{IaAMlj5CIiO4E3RPp1TWn → pnaCuBv6v6k-xKyv71Bct}/_clientMiddlewareManifest.js +0 -0
  930. /package/dist/ui/static/_next/static/{IaAMlj5CIiO4E3RPp1TWn → pnaCuBv6v6k-xKyv71Bct}/_ssgManifest.js +0 -0
@@ -1,9 +1,23 @@
1
- // Server activity log — one JSON line per operation into `<stateDir>/logs/server.log`, with
2
- // day-based rotation and a rolling 7-day retention. Written unconditionally, no env-var opt-in:
3
- // operators facing a stuck run must not have to know a magic switch to see what the process is
4
- // doing. Redaction stays strict — endpoints, sizes, HTTP statuses, error kinds and correlation
5
- // ids only; request bodies, response bodies, tokens, api-keys and user text never appear, and
6
- // that is enforced structurally by `log-redaction.ts` rather than by caller discipline.
1
+ // Server activity log — one JSON line per operation into the one logical Activity Log under
2
+ // `<stateDir>/logs/`. Written unconditionally, no env-var opt-in: operators facing a stuck run must
3
+ // not have to know a magic switch to see what the process is doing. Redaction stays strict —
4
+ // endpoints, sizes, HTTP statuses, error kinds and correlation ids only; request bodies, response
5
+ // bodies, tokens, api-keys and user text never appear, and that is enforced structurally by
6
+ // `log-redaction.ts` rather than by caller discipline.
7
+ //
8
+ // BOUNDED IMMUTABLE SEGMENTS (#3530, ADR-0173 D14)
9
+ //
10
+ // The logical log is physically a sequence of small segments (`activity-log-files.ts` in the
11
+ // contracts leaf owns the closed name grammar). Every process instance appends only to its own
12
+ // active segment, created exclusively, so no process ever appends to or renames another process's
13
+ // open file. A segment is sealed — a final `activity-log.segment.sealed` line, fsync, a guarded
14
+ // same-directory rename that drops `.active`, and mode 0400 — when the next line would pass the
15
+ // configured byte bound, when it is older than the configured time bound, on close, and on a pin
16
+ // request. A sealed segment is never written again. Crash recovery seals an orphaned segment as it is
17
+ // and reports a partial final line; valid lines are never rewritten. Retention (byte budget and age,
18
+ // with a reserved pin quota) runs whenever a segment is opened, which is at startup and immediately
19
+ // after every rollover seal, and every outcome is registered, body-free evidence.
20
+ // `activity-log-store.ts` owns the arithmetic; this module owns the one writer and its evidence.
7
21
  //
8
22
  // WHY THE WRITE IS SYNCHRONOUS (and stays that way)
9
23
  //
@@ -15,26 +29,30 @@
15
29
  // file" and "the operation happened" cannot come apart.
16
30
  //
17
31
  // The cost is bounded and pinned by COUNTING, not by timing. The sink holds ONE append-mode
18
- // descriptor open for the life of the file, so a line costs a single `write(2)` rather than the
19
- // open/write/close triple `appendFileSync` pays per call. `server-log.test.ts` asserts exactly
20
- // that over a burst — one `openSync`, one `writeSync` per line, and a file whose size is the SUM of
21
- // each line's own byte length (lines are no longer byte-identical once `seq` is in the envelope: its
22
- // digit width grows at each power-of-ten boundary the burst crosses) — so a regression to per-write
23
- // open/close, or to a quadratic format path, fails the suite deterministically instead of showing up
24
- // as latency in production. A wall-clock budget would measure the runner's disk instead, and go red
25
- // on a diff that never touched this file.
32
+ // descriptor open for the life of a segment, so a line costs a single `write(2)` rather than the
33
+ // open/write/close triple `appendFileSync` pays per call. `server-log.test.ts` asserts that the
34
+ // fixed setup count does not grow over a burst — never one open per line — plus one `writeSync` per
35
+ // line and a segment whose size is the SUM of each line's own byte length (lines are no longer
36
+ // byte-identical once `seq` is in the envelope: its digit width grows at each power-of-ten boundary
37
+ // the burst crosses). A regression to per-write open/close, or to a quadratic format path,
38
+ // therefore fails deterministically instead of showing up as latency in production.
26
39
  //
27
40
  // Levels are the volume control instead: an event below the configured threshold returns before
28
41
  // any string or JSON work happens at all (`KEIKO_LOG_LEVEL`, default `info`).
29
- import { randomUUID } from "node:crypto";
30
- import { closeSync, constants, existsSync, fstatSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, readSync, readdirSync, renameSync, unlinkSync, writeSync, } from "node:fs";
42
+ import { randomBytes, randomUUID } from "node:crypto";
43
+ import { closeSync, constants, fchmodSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, realpathSync, writeSync, } from "node:fs";
31
44
  import { join, resolve as resolvePath } from "node:path";
32
- import { atomicPublishRename } from "@oscharko-dev/keiko-security/fs-atomic-rename";
33
- import { classifyErrorKind } from "@oscharko-dev/keiko-contracts/runtime/observability";
34
- import { isValidCorrelationId } from "../correlation.js";
45
+ import { performance } from "node:perf_hooks";
46
+ import { SAFE_ARTIFACT_FILE_FAILURE_KINDS, SafeArtifactFileError, archiveSafeArtifactFile, openSafeArtifactFile, safeArtifactContainmentAssurance, safeArtifactPermissionAssurance, } from "@oscharko-dev/keiko-security/fs-hardening";
47
+ import { ACTIVITY_LOG_CATALOG_DIGEST, ACTIVITY_LOG_REGISTRY_VERSION, ACTIVITY_LOG_SCHEMA_DIGEST, ActivityLogEventValidationError, activityLogErrorKindOr, activityLogEvent, activityLogSegmentFileName, classifyErrorKind, defineActivityLogOperation, formatActivityLogSegmentId, isActivityLogIdentityDigest, isActivityLogInstanceId, isActivityLogPlatformClass, isActivityLogProcessId, isActivityLogProductVersion, isActivityLogSequence, readableActivityLogFileNames, recordActivityLogLoss, validateRegisteredActivityLogEvent, } from "@oscharko-dev/keiko-contracts/runtime/observability";
48
+ import { KEIKO_PRODUCT_VERSION } from "@oscharko-dev/keiko-contracts/runtime/version";
49
+ import { correlationIdOrUnknown, isValidCorrelationId } from "../correlation.js";
50
+ import { MAX_ACTIVITY_LOG_PIN_DURATION_MS, MAX_ACTIVITY_LOG_PINS, MAX_LOG_LINE_BYTES, activeActivityLogPins, activityLogFreeBytes, activityLogLowDiskThresholdBytes, activityLogOrphanOwner, activityLogPinCovers, activityLogSegmentSeqSpan, applyActivityLogRetention, clampActivityLogSegmentBytes, inspectActivityLogSegmentTail, isActivityLogPinId, isActivityLogPinScope, isActivityLogSegmentEntry, listActivityLogDirectory, planActivityLogPinProtection, processIsAlive, readActivityLogPins, readActivityLogPolicyRecord, removeActivityLogFile, ACTIVITY_LOG_POLICY_SETTINGS, resolveActivityLogStorageConfig, resolveActivityLogStorePolicy, writeActivityLogPinRecord, } from "./activity-log-store.js";
35
51
  import { contentFreeErrorClass, machineToken, safeProperty } from "./error-classification.js";
36
52
  import { DEFAULT_SERVER_LOG_LEVEL, resolveServerLogThreshold, serverLogLevelEnabled, } from "./log-level.js";
37
53
  import { redactLogFields, redactLogLabel } from "./log-redaction.js";
54
+ import { observeSupportIncidentTrigger } from "./support-incident.js";
55
+ export { ACTIVITY_LOG_PIN_QUOTA_BYTES_ENV, ACTIVITY_LOG_RETENTION_BYTES_ENV, ACTIVITY_LOG_RETENTION_DAYS_ENV, ACTIVITY_LOG_SEGMENT_BYTES_ENV, ACTIVITY_LOG_SEGMENT_SECONDS_ENV, DEFAULT_ACTIVITY_LOG_PIN_QUOTA_BYTES, DEFAULT_ACTIVITY_LOG_RETENTION_BYTES, DEFAULT_ACTIVITY_LOG_RETENTION_DAYS, DEFAULT_ACTIVITY_LOG_SEGMENT_BYTES, DEFAULT_ACTIVITY_LOG_SEGMENT_SECONDS, MAX_ACTIVITY_LOG_PIN_DURATION_MS, MAX_ACTIVITY_LOG_PIN_SEGMENTS, MAX_ACTIVITY_LOG_PIN_WINDOW_MS, MAX_ACTIVITY_LOG_PINS, MAX_LOG_LINE_BYTES, MIN_ACTIVITY_LOG_RETENTION_BYTES, MIN_ACTIVITY_LOG_SEGMENT_BYTES, resolveActivityLogStorageConfig, } from "./activity-log-store.js";
38
56
  export { DEFAULT_SERVER_LOG_LEVEL, SERVER_LOG_LEVELS, SERVER_LOG_LEVEL_ENV, isServerLogLevel, isServerLogThreshold, parseServerLogThreshold, resolveServerLogThreshold, serverLogLevelEnabled, serverLogLevelRank, } from "./log-level.js";
39
57
  export { MAX_LOG_ARRAY_LENGTH, MAX_LOG_FIELD_COUNT, MAX_LOG_FIELD_DEPTH, MAX_LOG_STRING_LENGTH, REDACTED_KEY, REDACTED_LENGTH, REDACTED_PATH, REDACTED_PERSONAL, REDACTED_SECRET, REDACTED_SHAPE, DROPPED_DEPTH, DROPPED_LENGTH, closeReasonVocabulary, isDeniedLogFieldName, normalizeLogFieldName, redactLogFields, redactLogLabel, redactLogString, } from "./log-redaction.js";
40
58
  export { redactRoutePath } from "./route-template.js";
@@ -43,19 +61,62 @@ export { redactRoutePath } from "./route-template.js";
43
61
  export const SERVER_LOG_SCHEMA_VERSION = 2;
44
62
  // One instance id per process, computed once from a single `randomUUID()` call so every line this
45
63
  // process ever writes carries the SAME value. A pid alone is not a process-identity key: the OS
46
- // reuses pids across restarts, so two different process lifetimes can share one in a rotated
47
- // multi-day file. `pid` + `instanceId` together, never `pid` alone, is what an agent joins on.
64
+ // reuses pids across restarts, so two different process lifetimes can share one multi-day file.
65
+ // `pid` + `instanceId` together, never `pid` alone, is what an agent joins on.
48
66
  const INSTANCE_ID = randomUUID().replaceAll("-", "").slice(0, 8);
49
67
  // Exposed so a future consumer (the CLI's support-bundle manifest) can name the same instance the
50
68
  // running process is stamping onto its own lines, without recomputing or guessing at the value.
51
69
  export function serverLogInstanceId() {
52
70
  return INSTANCE_ID;
53
71
  }
54
- export const DEFAULT_LOG_RETENTION_DAYS = 7;
55
- // A hard ceiling on one serialised line. Every field guard runs first, so reaching this means a
56
- // caller passed an unexpected shape; the line is replaced rather than written, so one pathological
57
- // event cannot fill a disk or blow a log shipper's line limit.
58
- export const MAX_LOG_LINE_BYTES = 8192;
72
+ const ACTIVITY_LOG_RELEASE_CLASSES = new Set(["stable", "prerelease"]);
73
+ const PERSISTED_WRITER_CAPABILITIES = new Set(["active", "degraded"]);
74
+ const SUPPORTED_PLATFORMS = new Set(["darwin", "linux", "win32"]);
75
+ const SUPPORTED_ARCHITECTURES = new Set(["arm64", "x64"]);
76
+ function validRegistryIdentity(identity) {
77
+ return (identity.schemaVersion === SERVER_LOG_SCHEMA_VERSION &&
78
+ identity.registryVersion === ACTIVITY_LOG_REGISTRY_VERSION);
79
+ }
80
+ function validDigestIdentity(identity) {
81
+ return (isActivityLogIdentityDigest(identity.schemaDigest) &&
82
+ identity.schemaDigest === ACTIVITY_LOG_SCHEMA_DIGEST &&
83
+ isActivityLogIdentityDigest(identity.catalogDigest) &&
84
+ identity.catalogDigest === ACTIVITY_LOG_CATALOG_DIGEST);
85
+ }
86
+ function validBuildIdentity(identity) {
87
+ const buildClass = Reflect.get(identity, "buildClass");
88
+ const releaseClass = Reflect.get(identity, "releaseClass");
89
+ const platformClass = Reflect.get(identity, "platformClass");
90
+ return (buildClass === "node-esm" &&
91
+ ACTIVITY_LOG_RELEASE_CLASSES.has(releaseClass) &&
92
+ isActivityLogPlatformClass(platformClass));
93
+ }
94
+ function validProductIdentity(identity) {
95
+ return (isActivityLogProductVersion(identity.productVersion) &&
96
+ identity.productVersion === KEIKO_PRODUCT_VERSION);
97
+ }
98
+ function validWriterIdentity(identity) {
99
+ const compatibilityState = Reflect.get(identity, "compatibilityState");
100
+ const writerCapability = Reflect.get(identity, "writerCapability");
101
+ return compatibilityState === "supported" && PERSISTED_WRITER_CAPABILITIES.has(writerCapability);
102
+ }
103
+ function validServerLogIdentity(identity) {
104
+ return [
105
+ validRegistryIdentity(identity),
106
+ validDigestIdentity(identity),
107
+ validBuildIdentity(identity),
108
+ validProductIdentity(identity),
109
+ validWriterIdentity(identity),
110
+ isActivityLogProcessId(identity.pid),
111
+ isActivityLogInstanceId(identity.instanceId),
112
+ isActivityLogSequence(identity.seq),
113
+ ].every(Boolean);
114
+ }
115
+ function validateServerLogIdentity(identity) {
116
+ if (!validServerLogIdentity(identity)) {
117
+ throw new ActivityLogEventValidationError("invalid-identity");
118
+ }
119
+ }
59
120
  const NULL_SINK = {
60
121
  write(_event) {
61
122
  // Explicit noop for tests and for environments without a state directory.
@@ -93,6 +154,9 @@ export function nullServerLogSink() {
93
154
  // `Error`-name hardening above. Either branch still floors on the fixed string `"unknown"` for a
94
155
  // non-conforming candidate, pinned by `server-logger.test.ts`.
95
156
  export function errorKindOf(error) {
157
+ const safeArtifactKind = safeArtifactErrorKind(error);
158
+ if (safeArtifactKind !== undefined)
159
+ return safeArtifactKind;
96
160
  if (typeof error !== "object" || error === null)
97
161
  return "unknown";
98
162
  const code = machineToken(safeProperty(error, "code"));
@@ -102,6 +166,18 @@ export function errorKindOf(error) {
102
166
  return contentFreeErrorClass(error);
103
167
  return classifyErrorKind(safeProperty(error, "name")) ?? "unknown";
104
168
  }
169
+ const SAFE_ARTIFACT_ERROR_KINDS = new Set(SAFE_ARTIFACT_FILE_FAILURE_KINDS);
170
+ function safeArtifactErrorKind(error) {
171
+ try {
172
+ if (!(error instanceof SafeArtifactFileError))
173
+ return undefined;
174
+ }
175
+ catch {
176
+ return undefined;
177
+ }
178
+ const kind = safeProperty(error, "kind");
179
+ return typeof kind === "string" && SAFE_ARTIFACT_ERROR_KINDS.has(kind) ? kind : "open-failed";
180
+ }
105
181
  // LAST-RESORT FAILURE NOTICE
106
182
  //
107
183
  // Every layer below the caller swallows its own failures on purpose: a log line is evidence about
@@ -117,6 +193,110 @@ export function errorKindOf(error) {
117
193
  // throttle never hides the SCALE of the failure, only its repetition.
118
194
  const LOG_FAILURE_NOTICE_OP = "server-log.write-failed";
119
195
  export const LOG_FAILURE_NOTICE_WINDOW_MS = 60_000;
196
+ const SERVER_LOG_FAILURE_OPERATION = defineActivityLogOperation({
197
+ contractKind: "activity-log-operation",
198
+ schemaVersion: 1,
199
+ op: "server-log.write-failed",
200
+ category: "diagnostic",
201
+ owner: "keiko-server",
202
+ emitter: "observability/server-log.failureNoticeEvent",
203
+ fields: {
204
+ failedOp: { type: "string", dataClass: "opaque-id", required: false, maxLength: 160 },
205
+ rejectionKind: {
206
+ type: "string",
207
+ dataClass: "closed-enum",
208
+ required: false,
209
+ values: [
210
+ "unregistered-operation",
211
+ "registration-mismatch",
212
+ "missing-identity",
213
+ "invalid-identity",
214
+ "fields-not-object",
215
+ "missing-field",
216
+ "unknown-field",
217
+ "invalid-field-type",
218
+ "invalid-field-bound",
219
+ "invalid-field-vocabulary",
220
+ ],
221
+ },
222
+ completeness: { type: "string", dataClass: "completeness-state", required: true },
223
+ loss: { type: "string", dataClass: "loss-state", required: true },
224
+ reason: {
225
+ type: "string",
226
+ dataClass: "closed-enum",
227
+ required: false,
228
+ values: ["shutdown-flush"],
229
+ },
230
+ suppressedNotices: { type: "integer", dataClass: "count", required: false },
231
+ },
232
+ causal: "correlation",
233
+ lifecycle: "loss",
234
+ analyzerProjection: "failure-cluster",
235
+ failureClasses: ["activity-log-persistence", "activity-log-contract"],
236
+ proofIds: ["server-log.write-failed.stderr-line"],
237
+ releaseImpact: "patch",
238
+ });
239
+ const SERVER_LOG_LINE_DROPPED_OPERATION = defineActivityLogOperation({
240
+ contractKind: "activity-log-operation",
241
+ schemaVersion: 1,
242
+ op: "server-log.line-dropped",
243
+ category: "diagnostic",
244
+ owner: "keiko-server",
245
+ emitter: "observability/server-log.oversizedLine",
246
+ fields: {
247
+ failedOp: { type: "string", dataClass: "opaque-id", required: true, maxLength: 160 },
248
+ droppedLineBytes: { type: "integer", dataClass: "count", required: true },
249
+ completeness: { type: "string", dataClass: "completeness-state", required: true },
250
+ loss: { type: "string", dataClass: "loss-state", required: true },
251
+ },
252
+ causal: "correlation",
253
+ lifecycle: "loss",
254
+ analyzerProjection: "failure-cluster",
255
+ failureClasses: ["activity-log-contract"],
256
+ proofIds: ["server-log.line-dropped.registered-line"],
257
+ releaseImpact: "patch",
258
+ });
259
+ const SERVER_LOG_ARTIFACT_CLASS_FIELD = {
260
+ type: "string",
261
+ dataClass: "closed-enum",
262
+ required: true,
263
+ values: ["activity-log"],
264
+ };
265
+ const SERVER_LOG_TARGET_ASSURANCE_FIELDS = {
266
+ permissionAssurance: {
267
+ type: "string",
268
+ dataClass: "closed-enum",
269
+ required: true,
270
+ values: ["verified-private", "platform-inherited"],
271
+ },
272
+ containmentAssurance: {
273
+ type: "string",
274
+ dataClass: "closed-enum",
275
+ required: true,
276
+ values: ["private-root-guarded", "platform-inherited"],
277
+ },
278
+ completeness: { type: "string", dataClass: "completeness-state", required: true },
279
+ loss: { type: "string", dataClass: "loss-state", required: true },
280
+ };
281
+ const SERVER_LOG_TARGET_MUTATED_OPERATION = defineActivityLogOperation({
282
+ contractKind: "activity-log-operation",
283
+ schemaVersion: 1,
284
+ op: "server-log.target-mutated",
285
+ category: "diagnostic",
286
+ owner: "keiko-server",
287
+ emitter: "observability/server-log.mutationEvidence",
288
+ fields: {
289
+ failedOp: { type: "string", dataClass: "opaque-id", required: true, maxLength: 160 },
290
+ artifactClass: SERVER_LOG_ARTIFACT_CLASS_FIELD,
291
+ ...SERVER_LOG_TARGET_ASSURANCE_FIELDS,
292
+ },
293
+ causal: "correlation",
294
+ lifecycle: "loss",
295
+ analyzerProjection: "failure-cluster",
296
+ failureClasses: ["activity-log-persistence"],
297
+ proofIds: ["server-log.target-mutated.registered-line"],
298
+ releaseImpact: "patch",
299
+ });
120
300
  const failureNotice = { lastAt: null, suppressed: 0 };
121
301
  // Tests reset this so one suite's notice cannot silence the next suite's assertion; the server
122
302
  // resets it on shutdown for the same reason. Either caller is clearing `suppressed` — a count that
@@ -150,7 +330,7 @@ export function reportServerLogFailure(error, context = {}) {
150
330
  const suppressed = failureNotice.suppressed;
151
331
  failureNotice.lastAt = now;
152
332
  failureNotice.suppressed = 0;
153
- emitFailureNotice(error, context, suppressed, now);
333
+ emitFailureNotice(error, context, suppressed, now, context.identity ?? allocateServerLogIdentity());
154
334
  }
155
335
  // Shared by every stderr notice this module emits: a diagnostic that cannot itself be delivered
156
336
  // must not fail the operation (or the shutdown) it was describing. When stderr itself is
@@ -179,6 +359,11 @@ function emitLogNoticeFailedWarning(notice) {
179
359
  failedOp: notice.failedOp,
180
360
  correlationId: notice.correlationId,
181
361
  errorKind: notice.errorKind,
362
+ rejectionKind: notice.rejectionKind,
363
+ writerCapability: notice.writerCapability,
364
+ compatibilityState: notice.compatibilityState,
365
+ completeness: notice.completeness,
366
+ loss: notice.loss,
182
367
  suppressedNotices: notice.suppressedNotices,
183
368
  }),
184
369
  });
@@ -187,22 +372,84 @@ function emitLogNoticeFailedWarning(notice) {
187
372
  // No channel left to report through; nothing further to do.
188
373
  }
189
374
  }
190
- function emitFailureNotice(error, context, suppressed, now) {
191
- const notice = {
375
+ function emitFailureNotice(error, context, suppressed, now, identity) {
376
+ try {
377
+ const validationFailure = activityLogValidationFailure(error);
378
+ const event = failureNoticeEvent(error, context, suppressed, validationFailure);
379
+ writeStderrNotice(stderrEventRecord(event, identity, now));
380
+ }
381
+ catch {
382
+ writeStderrNotice(emergencyFailureNotice(identity, now));
383
+ }
384
+ }
385
+ function emergencyFailureNotice(identity, now) {
386
+ return {
192
387
  ts: new Date(now).toISOString(),
388
+ ...failureNoticeIdentity(identity),
193
389
  level: "error",
194
390
  category: "diagnostic",
195
391
  op: LOG_FAILURE_NOTICE_OP,
196
- errorKind: errorKindOf(error),
392
+ correlationId: correlationIdOrUnknown(undefined),
393
+ errorKind: "internal",
394
+ compatibilityState: "incomplete",
395
+ writerCapability: "unavailable",
396
+ completeness: "unknown",
397
+ loss: "event-dropped",
398
+ };
399
+ }
400
+ function failureNoticeEvent(error, context, suppressed, rejectionKind) {
401
+ return activityLogEvent(SERVER_LOG_FAILURE_OPERATION, {
402
+ level: "error",
403
+ correlationId: correlationIdOrUnknown(context.correlationId),
404
+ errorKind: closedFailureNoticeErrorKind(error),
405
+ }, {
406
+ ...(rejectionKind === undefined && context.op !== undefined
407
+ ? { failedOp: redactLogLabel(context.op) }
408
+ : {}),
409
+ ...(rejectionKind === undefined ? {} : { rejectionKind }),
410
+ completeness: "unknown",
411
+ loss: context.loss ?? "event-dropped",
412
+ ...(suppressed > 0 ? { suppressedNotices: suppressed } : {}),
413
+ });
414
+ }
415
+ function stderrEventRecord(event, identity, now) {
416
+ return {
417
+ ts: new Date(now).toISOString(),
418
+ ...failureNoticeIdentity(identity),
419
+ // The emergency line is written beside the log, never through it: the sink that would stamp these
420
+ // envelope states is the one that failed, so the notice states them itself.
421
+ compatibilityState: "incomplete",
422
+ writerCapability: "unavailable",
423
+ level: event.level,
424
+ category: event.category,
425
+ ["op"]: event.op,
426
+ correlationId: event.correlationId,
427
+ errorKind: event.errorKind,
428
+ ...event.extra,
429
+ };
430
+ }
431
+ function activityLogValidationFailure(error) {
432
+ return error instanceof ActivityLogEventValidationError ? error.kind : undefined;
433
+ }
434
+ function closedFailureNoticeErrorKind(error) {
435
+ if (error instanceof ActivityLogEventValidationError)
436
+ return "validation-failed";
437
+ return activityLogErrorKindOr(errorKindOf(error), "internal");
438
+ }
439
+ function failureNoticeIdentity(identity) {
440
+ return {
441
+ schemaVersion: identity.schemaVersion,
442
+ registryVersion: identity.registryVersion,
443
+ schemaDigest: identity.schemaDigest,
444
+ catalogDigest: identity.catalogDigest,
445
+ buildClass: identity.buildClass,
446
+ releaseClass: identity.releaseClass,
447
+ platformClass: identity.platformClass,
448
+ productVersion: identity.productVersion,
449
+ pid: identity.pid,
450
+ instanceId: identity.instanceId,
451
+ seq: identity.seq,
197
452
  };
198
- if (context.op !== undefined)
199
- notice.failedOp = redactLogLabel(context.op);
200
- if (context.correlationId !== undefined) {
201
- notice.correlationId = redactLogLabel(context.correlationId);
202
- }
203
- if (suppressed > 0)
204
- notice.suppressedNotices = suppressed;
205
- writeStderrNotice(notice);
206
453
  }
207
454
  // The last-resort flush: whatever `suppressed` count was still sitting unreported when the notice
208
455
  // state was reset (a clean process shutdown, or a suite boundary) is announced here, ONCE, before
@@ -215,14 +462,23 @@ function emitFailureNotice(error, context, suppressed, now) {
215
462
  // skips every other cleanup path. The `seq` gap for such a window still marks that a write failed;
216
463
  // only the count of how many is not recoverable after that kind of exit.
217
464
  function emitShutdownFlushNotice(suppressed, now) {
218
- writeStderrNotice({
219
- ts: new Date(now).toISOString(),
220
- level: "error",
221
- category: "diagnostic",
222
- op: LOG_FAILURE_NOTICE_OP,
223
- reason: "shutdown-flush",
224
- suppressedNotices: suppressed,
225
- });
465
+ const identity = allocateServerLogIdentity();
466
+ try {
467
+ const event = activityLogEvent(SERVER_LOG_FAILURE_OPERATION, {
468
+ level: "error",
469
+ correlationId: correlationIdOrUnknown(undefined),
470
+ errorKind: "unknown",
471
+ }, {
472
+ completeness: "unknown",
473
+ loss: "event-dropped",
474
+ reason: "shutdown-flush",
475
+ suppressedNotices: suppressed,
476
+ });
477
+ writeStderrNotice(stderrEventRecord(event, identity, now));
478
+ }
479
+ catch {
480
+ writeStderrNotice(emergencyFailureNotice(identity, now));
481
+ }
226
482
  }
227
483
  function eventLevel(event) {
228
484
  return event.level ?? DEFAULT_SERVER_LOG_LEVEL;
@@ -261,6 +517,15 @@ export function formatServerLogLine(event, now = new Date(), identity) {
261
517
  const record = { ts: now.toISOString() };
262
518
  if (identity !== undefined) {
263
519
  record.schemaVersion = identity.schemaVersion;
520
+ record.registryVersion = identity.registryVersion;
521
+ record.schemaDigest = identity.schemaDigest;
522
+ record.catalogDigest = identity.catalogDigest;
523
+ record.buildClass = identity.buildClass;
524
+ record.releaseClass = identity.releaseClass;
525
+ record.platformClass = identity.platformClass;
526
+ record.productVersion = identity.productVersion;
527
+ record.compatibilityState = identity.compatibilityState;
528
+ record.writerCapability = identity.writerCapability;
264
529
  record.pid = identity.pid;
265
530
  record.instanceId = identity.instanceId;
266
531
  record.seq = identity.seq;
@@ -276,6 +541,22 @@ export function formatServerLogLine(event, now = new Date(), identity) {
276
541
  // One byte measurement on the happy path; the second only on the line that is being replaced.
277
542
  return serverLogLineWithinCap(line) ? line : oversizedLine(record, serverLogLineBytes(line));
278
543
  }
544
+ export function formatRegisteredServerLogLine(event, now = new Date(), identity) {
545
+ if (identity === undefined) {
546
+ throw new ActivityLogEventValidationError("missing-identity");
547
+ }
548
+ validateServerLogIdentity(identity);
549
+ validateRegisteredActivityLogEvent(event);
550
+ return formatServerLogLine(event, now, identity);
551
+ }
552
+ function formatEventLine(event, now, identity) {
553
+ // Every production persistence path supplies an identity and therefore requires a typed
554
+ // registration. The identity-less branch exists only for the in-memory test sink's redacted
555
+ // line projection; it cannot write a production file.
556
+ return identity === undefined
557
+ ? formatServerLogLine(event, now)
558
+ : formatRegisteredServerLogLine(event, now, identity);
559
+ }
279
560
  // The cap is a cap on BYTES, because the write below encodes UTF-8 and a log shipper's line limit
280
561
  // counts bytes. `line.length` counts UTF-16 code units, so comparing it against the cap admitted a
281
562
  // line up to three times the stated size — and multi-byte text is exactly what makes a line
@@ -295,198 +576,153 @@ function oversizedLine(record, lineBytes) {
295
576
  // The identity fields ride along when present: an agent joining lines by (pid, instanceId, seq)
296
577
  // must not see a gap in that join key just because the ORIGINAL event happened to be oversized.
297
578
  const replacement = { ts: record.ts };
298
- if (record.schemaVersion !== undefined)
299
- replacement.schemaVersion = record.schemaVersion;
300
- if (record.pid !== undefined)
301
- replacement.pid = record.pid;
302
- if (record.instanceId !== undefined)
303
- replacement.instanceId = record.instanceId;
304
- if (record.seq !== undefined)
305
- replacement.seq = record.seq;
306
- replacement.level = record.level;
307
- replacement.category = record.category;
308
- replacement.op = record.op;
309
- replacement.errorKind = "log-line-oversized";
310
- replacement.droppedLineBytes = lineBytes;
579
+ for (const field of SERVER_LOG_IDENTITY_FIELDS) {
580
+ if (record[field] !== undefined)
581
+ replacement[field] = record[field];
582
+ }
583
+ const event = activityLogEvent(SERVER_LOG_LINE_DROPPED_OPERATION, {
584
+ level: "error",
585
+ correlationId: typeof record.correlationId === "string"
586
+ ? correlationIdOrUnknown(record.correlationId)
587
+ : correlationIdOrUnknown(undefined),
588
+ errorKind: "write-failed",
589
+ }, {
590
+ failedOp: typeof record.op === "string" ? redactLogLabel(record.op) : "unknown",
591
+ droppedLineBytes: lineBytes,
592
+ completeness: "unknown",
593
+ loss: "event-dropped",
594
+ });
595
+ replacement.level = event.level;
596
+ replacement.category = event.category;
597
+ replacement.op = event.op;
598
+ Object.assign(replacement, event.extra);
599
+ applyEnvelopeFields(replacement, event);
311
600
  return `${JSON.stringify(replacement)}\n`;
312
601
  }
602
+ const SERVER_LOG_IDENTITY_FIELDS = [
603
+ "schemaVersion",
604
+ "registryVersion",
605
+ "schemaDigest",
606
+ "catalogDigest",
607
+ "buildClass",
608
+ "releaseClass",
609
+ "platformClass",
610
+ "productVersion",
611
+ "compatibilityState",
612
+ "writerCapability",
613
+ "pid",
614
+ "instanceId",
615
+ "seq",
616
+ ];
313
617
  // PROCESS-WIDE `seq` ALLOCATOR — one counter, one module, for the life of the process.
314
618
  //
315
619
  // It must NOT live on `ActiveLog`. Two independent state directories in the same process (a CLI
316
620
  // pointed at a workspace-local state dir, and the server logger's own default) each resolve to a
317
621
  // DIFFERENT `ActiveLog`; a counter kept per `ActiveLog` restarts at 1 for each one, so two lines
318
622
  // written moments apart — one to each directory — can carry the identical `(pid, instanceId, seq)`
319
- // tuple. That tuple is the join key ADR-0173 (D2) promises an agent a total, gap-free order on, and
623
+ // tuple. That tuple is the join key ADR-0173 (D2) promises an agent a total monotonic order on, and
320
624
  // a duplicate breaks the promise regardless of how many log directories the process happens to
321
- // have open. One allocator shared by every `ActiveLog`, every rotation, and every sink built on top
322
- // of any of them is what keeps the tuple unique process-wide.
625
+ // have open. One allocator shared by every `ActiveLog` and every sink built on top of any of them
626
+ // is what keeps the tuple unique process-wide while gaps expose failed persistence attempts.
323
627
  //
324
- // Claimed as soon as an event clears the level gate, in `createFileSinkFacade.write`, BEFORE the
325
- // write is attempted — never rolled back if that write then throws. The alternative, claiming only
326
- // after a successful write, would let two callers racing the same failure both observe the same
327
- // pre-failure counter value and then both claim the number that follows it, silently reusing a
328
- // sequence number for two different lines. A gap is not a bug in this counter: it is the evidence
329
- // that a line was not persisted, and `reportServerLogFailure`'s suppressed-notice count accounts
330
- // for the writes a gap represents. Monotonic per process; a gap marks a line the sink could not
331
- // persist.
628
+ // Each non-filtered facade call claims one identity before boundary handling or opening. Its first
629
+ // persisted record uses that identity; further records claim in physical-write order. Claims are
630
+ // never rolled back after failure. A gap is therefore not a counter bug: it marks a facade call or
631
+ // subsequent evidence record that could not persist its next line. Monotonic per process; never
632
+ // reused.
332
633
  let nextProcessSeq = 1;
634
+ function resolvePlatformClass() {
635
+ const platform = SUPPORTED_PLATFORMS.has(process.platform) ? process.platform : "other";
636
+ const architecture = SUPPORTED_ARCHITECTURES.has(process.arch) ? process.arch : "other";
637
+ return `${platform}-${architecture}`;
638
+ }
639
+ const PLATFORM_CLASS = resolvePlatformClass();
333
640
  function allocateServerLogSeq() {
334
641
  const seq = nextProcessSeq;
335
642
  nextProcessSeq += 1;
336
643
  return seq;
337
644
  }
338
- function todayUtc(now = new Date()) {
339
- return now.toISOString().slice(0, 10);
645
+ /**
646
+ * The identity every line of this process carries, without the per-line `seq`. Exported so a test
647
+ * fixture derives the release and platform classes from here instead of restating their rules.
648
+ */
649
+ export function serverLogProcessIdentity(writerCapability = "active") {
650
+ return {
651
+ schemaVersion: SERVER_LOG_SCHEMA_VERSION,
652
+ registryVersion: ACTIVITY_LOG_REGISTRY_VERSION,
653
+ schemaDigest: ACTIVITY_LOG_SCHEMA_DIGEST,
654
+ catalogDigest: ACTIVITY_LOG_CATALOG_DIGEST,
655
+ buildClass: "node-esm",
656
+ releaseClass: KEIKO_PRODUCT_VERSION.includes("-") ? "prerelease" : "stable",
657
+ platformClass: PLATFORM_CLASS,
658
+ productVersion: KEIKO_PRODUCT_VERSION,
659
+ compatibilityState: "supported",
660
+ writerCapability,
661
+ pid: process.pid,
662
+ instanceId: INSTANCE_ID,
663
+ };
664
+ }
665
+ function allocateServerLogIdentity(writerCapability = "active") {
666
+ return { ...serverLogProcessIdentity(writerCapability), seq: allocateServerLogSeq() };
340
667
  }
341
- function closeHandle(active) {
342
- if (active.handle === null)
343
- return;
344
- try {
345
- closeSync(active.handle);
346
- }
347
- catch {
348
- // A descriptor we can no longer close is a descriptor we must stop using either way.
349
- }
350
- active.handle = null;
351
- }
352
- // Throws rather than returning null: a descriptor we cannot open is a failure an operator has to
353
- // hear about, and the caller's catch is the one place that both closes and reports.
354
- function ensureHandle(active) {
355
- if (active.handle !== null)
356
- return active.handle;
357
- active.handle = openSync(active.currentPath, "a", 0o600);
358
- return active.handle;
359
- }
360
- function errorCode(error) {
361
- if (typeof error !== "object" || error === null || !("code" in error))
362
- return "";
363
- const { code } = error;
364
- return typeof code === "string" ? code : "";
365
- }
366
- // Names old files with their calendar day, e.g. `server-2026-08-20.log`, and keeps at most
367
- // `retentionDays` of them. A fresh install starts empty. This is the whole rotation policy.
368
- function rotateIfNeeded(active) {
369
- const day = todayUtc();
370
- if (day === active.currentDay)
371
- return;
372
- closeHandle(active);
373
- // A successful archive means the file we were mid-record in is no longer the file we append to,
374
- // so the partial-record debt does not travel to the fresh one.
375
- if (archiveCurrentDay(active))
376
- active.pendingNewline = false;
377
- active.currentDay = day;
378
- pruneOldFiles(active.directory, active.retentionDays);
379
- }
380
- // Rotation has to be atomic ACROSS PROCESSES, not merely within one. `renameSync` REPLACES an
381
- // existing destination, so two Keiko processes sharing a state directory that both reach the UTC
382
- // boundary destroy the finished day: the first archives it, the second renames its own fresh file
383
- // over that archive. An `existsSync` guard does not close that window — it is a check, and the
384
- // window is between the check and the rename. The in-process registry below cannot help either;
385
- // by construction it coordinates only one process.
386
- //
387
- // `link(2)` has no such window: it fails with EEXIST when the destination already exists, so
388
- // exactly one process can ever create `server-<day>.log`. The loser leaves the archive alone and
389
- // only advances its own day; only the winner unlinks the current path, so a fresh file another
390
- // process is already appending to can never be moved on top of a finished day.
391
- // `link(2)` reports "not supported by this filesystem" through these. EPERM is ambiguous — it is
392
- // also plain permission denial — but the state directory is created by this process at 0700, so a
393
- // permission failure on it is not the reachable case, and treating it as unsupported keeps
394
- // removable-media installs rotating.
395
- const NO_HARD_LINK_SUPPORT = new Set(["EPERM", "ENOSYS", "EOPNOTSUPP", "ENOTSUP"]);
396
- function archiveCurrentDay(active) {
397
- const rolled = join(active.directory, `server-${active.currentDay}.log`);
398
- try {
399
- linkSync(active.currentPath, rolled);
400
- }
401
- catch (error) {
402
- const code = errorCode(error);
403
- // EEXIST: a peer already archived this day, and leaving its file untouched is the whole point.
404
- // ENOENT: there is nothing to archive (a fresh install, or a peer that has already moved it).
405
- if (code === "EEXIST" || code === "ENOENT")
406
- return false;
407
- // ONLY "this filesystem has no hard links" may fall back to the destination-replacing rename.
408
- // EACCES, EMLINK, EIO and friends are real failures, and for them the safe outcome is to NOT
409
- // rotate: one file growing is a nuisance, overwriting a peer's finished archive is data loss.
410
- // Choose the nuisance. Without this narrowing the fallback re-opened the exact race the
411
- // hard-link rotation exists to close.
412
- if (!NO_HARD_LINK_SUPPORT.has(code))
413
- return false;
414
- return archiveWithoutHardLinks(active, rolled);
668
+ // ─── Physical write primitives ─────────────────────────────────────────────────────────────────
669
+ class PostWriteMutationError extends SafeArtifactFileError {
670
+ constructor() {
671
+ super("activity-log", "target-mutated");
415
672
  }
416
- return unlinkCurrentPath(active);
417
673
  }
418
- // A filesystem that cannot hard-link at all (FAT/exFAT under a state directory on removable
419
- // media). No atomic primitive is left, so this falls back to the guarded rename rather than never
420
- // rotating and letting one file grow without bound — the cross-process window exists only here,
421
- // and only where nothing better is available.
422
- function archiveWithoutHardLinks(active, rolled) {
423
- if (existsSync(rolled) || !existsSync(active.currentPath))
424
- return false;
425
- try {
426
- atomicPublishRename(active.currentPath, rolled, { rename: renameSync });
427
- return true;
428
- }
429
- catch {
430
- // Windows file-busy and friends: keep appending to the current file — rotation is a
431
- // convenience, not a correctness requirement.
432
- return false;
674
+ // A descriptor that stopped accepting bytes (a zero-byte write or EAGAIN): write backpressure.
675
+ class ActivityLogBackpressureError extends SafeArtifactFileError {
676
+ constructor() {
677
+ super("activity-log", "write-failed");
433
678
  }
434
679
  }
435
- function unlinkCurrentPath(active) {
436
- try {
437
- unlinkSync(active.currentPath);
438
- return true;
680
+ // The filesystem refused the bytes (ENOSPC, EDQUOT, EFBIG): the disk or quota is full.
681
+ class ActivityLogDiskFullError extends SafeArtifactFileError {
682
+ constructor() {
683
+ super("activity-log", "write-failed");
439
684
  }
440
- catch {
441
- // The archive is written, which is the part that matters. This process keeps appending to the
442
- // still-linked current file, and the next boundary finds the archive present and leaves it be.
443
- return false;
685
+ }
686
+ // Retention could not make room for a new segment inside the byte budget: the event is dropped
687
+ // rather than let the Activity Log exceed its bound.
688
+ class ActivityLogBudgetError extends Error {
689
+ name = "ActivityLogBudgetError";
690
+ code = "unavailable";
691
+ constructor() {
692
+ super("activity log byte budget exhausted");
444
693
  }
445
694
  }
446
- function pruneOldFiles(directory, retentionDays) {
695
+ const DISK_FULL_CODES = new Set(["ENOSPC", "EDQUOT", "EFBIG"]);
696
+ function writeChunk(handle, payload, offset) {
447
697
  try {
448
- const entries = readdirSync(directory).filter((name) => /^server-\d{4}-\d{2}-\d{2}\.log$/.test(name));
449
- if (entries.length <= retentionDays)
450
- return;
451
- // Explicit collator, not the default lexicographic sort: the names are ISO-dated, so the
452
- // ordering decides which files rotation deletes.
453
- entries.sort((left, right) => left.localeCompare(right, "en-US"));
454
- for (const stale of entries.slice(0, entries.length - retentionDays)) {
455
- try {
456
- unlinkSync(join(directory, stale));
457
- }
458
- catch {
459
- // Best effort; a locked file will be retried on the next rotation.
460
- }
461
- }
698
+ return writeSync(handle, payload, offset, payload.length - offset);
462
699
  }
463
- catch {
464
- // Directory unreadable is not a reason to fail the server; the next write recreates it.
700
+ catch (error) {
701
+ const code = machineToken(safeProperty(error, "code"));
702
+ if (code !== undefined && DISK_FULL_CODES.has(code))
703
+ throw new ActivityLogDiskFullError();
704
+ if (code === "EAGAIN")
705
+ throw new ActivityLogBackpressureError();
706
+ throw error;
465
707
  }
466
708
  }
467
- // The descriptor is opened `a`, so every write is an atomic O_APPEND write at the current end of
468
- // file. Inside one process the registry above already gives every sink on a file the same
469
- // descriptor; O_APPEND is what additionally makes it safe for a SECOND Keiko process sharing the
470
- // same state directory, which no in-process registry can coordinate. `writeSync` may still report
471
- // a short write, so loop until the whole line has landed.
472
- //
473
- // A descriptor that reports ZERO bytes has stopped accepting them: looping would spin, and simply
474
- // returning would leave a partial JSON record behind whose bytes then merge with the NEXT record —
475
- // one stalled line silently costing two, and a reader that splits on newlines losing both. So the
476
- // stall throws: the caller closes the descriptor, and the line is dropped. A dropped line is the
477
- // honest outcome; a truncated one is not, because it damages a record that was never in trouble.
709
+ // `writeSync` may report a short write, so loop until the whole line has landed. A descriptor that
710
+ // reports ZERO bytes has stopped accepting them: looping would spin, and simply returning would
711
+ // leave a partial JSON record behind whose bytes then merge with the NEXT record — one stalled line
712
+ // silently costing two. So the stall throws and the line is dropped. A dropped line is the honest
713
+ // outcome; a truncated one is not, because it damages a record that was never in trouble.
478
714
  function writeAll(handle, payload) {
479
715
  let offset = 0;
480
716
  while (offset < payload.length) {
481
- const written = writeSync(handle, payload, offset, payload.length - offset);
717
+ const written = writeChunk(handle, payload, offset);
482
718
  if (written <= 0)
483
- throw new Error("activity log descriptor accepted no bytes");
719
+ throw new ActivityLogBackpressureError();
484
720
  offset += written;
485
721
  }
486
722
  }
487
723
  // The bytes a stalled write already handed to the kernel cannot be recalled, so the damage is
488
- // bounded from the other side: the ActiveLog remembers that the file ends mid-record and the next
489
- // record opens with a newline. That is deterministic — unlike writing a terminator, which asks a
724
+ // bounded from the other side: the store remembers that its active segment ends mid-record and the
725
+ // next record opens with a newline. That is deterministic — unlike writing a terminator, which asks a
490
726
  // descriptor that is refusing bytes to accept one more.
491
727
  function writeRecord(active, handle, line) {
492
728
  const payload = Buffer.from(active.pendingNewline ? `\n${line}` : line, "utf8");
@@ -495,14 +731,495 @@ function writeRecord(active, handle, line) {
495
731
  writeAll(handle, payload);
496
732
  active.pendingNewline = false;
497
733
  }
498
- function sameLogIdentity(left, right) {
499
- return (left.dev === right.dev &&
500
- left.ino === right.ino &&
501
- left.size === right.size &&
502
- left.mtimeMs === right.mtimeMs);
734
+ // ─── Registered storage evidence ───────────────────────────────────────────────────────────────
735
+ const SERVER_LOG_SAFE_OPEN_OPERATION = defineActivityLogOperation({
736
+ contractKind: "activity-log-operation",
737
+ schemaVersion: 1,
738
+ op: "server-log.safe-open",
739
+ category: "diagnostic",
740
+ owner: "keiko-server",
741
+ emitter: "observability/server-log.safeOpenEvidence",
742
+ fields: {
743
+ artifactClass: SERVER_LOG_ARTIFACT_CLASS_FIELD,
744
+ persistenceStatus: {
745
+ type: "string",
746
+ dataClass: "closed-enum",
747
+ required: true,
748
+ values: ["opened"],
749
+ },
750
+ ...SERVER_LOG_TARGET_ASSURANCE_FIELDS,
751
+ },
752
+ causal: "correlation",
753
+ lifecycle: "state",
754
+ analyzerProjection: "capability",
755
+ failureClasses: ["activity-log-persistence"],
756
+ proofIds: ["server-log.safe-open.emitted-line"],
757
+ releaseImpact: "patch",
758
+ });
759
+ const ACTIVITY_LOG_SEGMENT_SEALED_OPERATION = defineActivityLogOperation({
760
+ contractKind: "activity-log-operation",
761
+ schemaVersion: 1,
762
+ op: "activity-log.segment.sealed",
763
+ category: "diagnostic",
764
+ owner: "keiko-server",
765
+ emitter: "observability/server-log.segmentSealedEvidence",
766
+ fields: {
767
+ sealReason: {
768
+ type: "string",
769
+ dataClass: "closed-enum",
770
+ required: true,
771
+ values: ["size-limit", "age-limit", "clock-change", "close", "pin-request"],
772
+ },
773
+ segmentIndex: { type: "integer", dataClass: "count", required: true },
774
+ segmentFirstSeq: { type: "integer", dataClass: "count", required: true },
775
+ segmentLastSeq: { type: "integer", dataClass: "count", required: true },
776
+ segmentLineCount: { type: "integer", dataClass: "count", required: true },
777
+ segmentBytes: { type: "integer", dataClass: "count", required: true },
778
+ segmentDurationMs: { type: "integer", dataClass: "duration", required: true },
779
+ droppedEventCount: { type: "integer", dataClass: "count", required: true },
780
+ segmentByteLimit: { type: "integer", dataClass: "count", required: true },
781
+ segmentSecondsLimit: { type: "integer", dataClass: "count", required: true },
782
+ },
783
+ causal: "correlation",
784
+ lifecycle: "end",
785
+ analyzerProjection: "capability",
786
+ failureClasses: ["activity-log-segment"],
787
+ proofIds: ["activity-log.segment.sealed.emitted-line"],
788
+ releaseImpact: "patch",
789
+ });
790
+ const ACTIVITY_LOG_SEGMENT_RECOVERED_OPERATION = defineActivityLogOperation({
791
+ contractKind: "activity-log-operation",
792
+ schemaVersion: 1,
793
+ op: "activity-log.segment.recovered",
794
+ category: "diagnostic",
795
+ owner: "keiko-server",
796
+ emitter: "observability/server-log.segmentRecoveredEvidence",
797
+ fields: {
798
+ recoveryStatus: {
799
+ type: "string",
800
+ dataClass: "closed-enum",
801
+ required: true,
802
+ values: ["sealed", "failed"],
803
+ },
804
+ recoveryKind: {
805
+ type: "string",
806
+ dataClass: "closed-enum",
807
+ required: true,
808
+ values: ["unsealed", "interrupted-seal"],
809
+ },
810
+ ownerState: {
811
+ type: "string",
812
+ dataClass: "closed-enum",
813
+ required: true,
814
+ values: ["exited", "stale", "same-process"],
815
+ },
816
+ tailState: {
817
+ type: "string",
818
+ dataClass: "closed-enum",
819
+ required: true,
820
+ values: ["terminated", "truncated", "unknown"],
821
+ },
822
+ truncatedBytes: { type: "integer", dataClass: "count", required: true },
823
+ segmentBytes: { type: "integer", dataClass: "count", required: true },
824
+ segmentIndex: { type: "integer", dataClass: "count", required: true },
825
+ recoveredInstanceId: {
826
+ type: "string",
827
+ dataClass: "opaque-id",
828
+ required: true,
829
+ maxLength: 8,
830
+ },
831
+ },
832
+ causal: "correlation",
833
+ lifecycle: "loss",
834
+ analyzerProjection: "failure-cluster",
835
+ failureClasses: ["activity-log-segment"],
836
+ proofIds: ["activity-log.segment.recovered.emitted-line"],
837
+ releaseImpact: "patch",
838
+ });
839
+ const ACTIVITY_LOG_RETENTION_PRUNED_OPERATION = defineActivityLogOperation({
840
+ contractKind: "activity-log-operation",
841
+ schemaVersion: 1,
842
+ op: "activity-log.retention.pruned",
843
+ category: "diagnostic",
844
+ owner: "keiko-server",
845
+ emitter: "observability/server-log.retentionPrunedEvidence",
846
+ fields: {
847
+ retentionStatus: {
848
+ type: "string",
849
+ dataClass: "closed-enum",
850
+ required: true,
851
+ values: ["pruned", "partial", "failed"],
852
+ },
853
+ prunedSegmentCount: { type: "integer", dataClass: "count", required: true },
854
+ prunedLegacyFileCount: { type: "integer", dataClass: "count", required: true },
855
+ prunedBytes: { type: "integer", dataClass: "count", required: true },
856
+ prunedByAgeCount: { type: "integer", dataClass: "count", required: true },
857
+ prunedByBudgetCount: { type: "integer", dataClass: "count", required: true },
858
+ failedDeletionCount: { type: "integer", dataClass: "count", required: true },
859
+ retainedFileCount: { type: "integer", dataClass: "count", required: true },
860
+ retainedBytes: { type: "integer", dataClass: "count", required: true },
861
+ protectedPinnedBytes: { type: "integer", dataClass: "count", required: true },
862
+ retentionBudgetBytes: { type: "integer", dataClass: "count", required: true },
863
+ retentionDays: { type: "integer", dataClass: "count", required: true },
864
+ },
865
+ causal: "correlation",
866
+ lifecycle: "state",
867
+ analyzerProjection: "capability",
868
+ failureClasses: ["activity-log-retention"],
869
+ proofIds: ["activity-log.retention.pruned.emitted-line"],
870
+ releaseImpact: "patch",
871
+ });
872
+ const ACTIVITY_LOG_PRESSURE_OPERATION = defineActivityLogOperation({
873
+ contractKind: "activity-log-operation",
874
+ schemaVersion: 1,
875
+ op: "activity-log.pressure",
876
+ category: "diagnostic",
877
+ owner: "keiko-server",
878
+ emitter: "observability/server-log.pressureEvidence",
879
+ fields: {
880
+ pressureState: {
881
+ type: "string",
882
+ dataClass: "closed-enum",
883
+ required: true,
884
+ values: [
885
+ "low-disk-space",
886
+ "disk-full",
887
+ "backpressure",
888
+ "budget-exceeded",
889
+ "retention-blocked",
890
+ "cleared",
891
+ ],
892
+ },
893
+ previousState: {
894
+ type: "string",
895
+ dataClass: "closed-enum",
896
+ required: false,
897
+ values: ["low-disk-space", "retention-blocked"],
898
+ },
899
+ droppedEventCount: { type: "integer", dataClass: "count", required: true },
900
+ usedBytes: { type: "integer", dataClass: "count", required: false },
901
+ budgetBytes: { type: "integer", dataClass: "count", required: true },
902
+ pinQuotaBytes: { type: "integer", dataClass: "count", required: true },
903
+ freeBytes: { type: "integer", dataClass: "count", required: false },
904
+ },
905
+ causal: "correlation",
906
+ lifecycle: "state",
907
+ analyzerProjection: "capability",
908
+ failureClasses: ["activity-log-pressure"],
909
+ proofIds: ["activity-log.pressure.emitted-line"],
910
+ releaseImpact: "patch",
911
+ });
912
+ const ACTIVITY_LOG_PIN_CREATED_OPERATION = defineActivityLogOperation({
913
+ contractKind: "activity-log-operation",
914
+ schemaVersion: 1,
915
+ op: "activity-log.pin.created",
916
+ category: "diagnostic",
917
+ owner: "keiko-server",
918
+ emitter: "observability/server-log.pinCreatedEvidence",
919
+ fields: {
920
+ pinId: { type: "string", dataClass: "opaque-id", required: false, maxLength: 24 },
921
+ pinStatus: {
922
+ type: "string",
923
+ dataClass: "closed-enum",
924
+ required: true,
925
+ values: ["created", "rejected"],
926
+ },
927
+ rejectionReason: {
928
+ type: "string",
929
+ dataClass: "closed-enum",
930
+ required: false,
931
+ values: ["invalid-request", "pin-limit-reached", "storage-unavailable"],
932
+ },
933
+ pinKind: {
934
+ type: "string",
935
+ dataClass: "closed-enum",
936
+ required: true,
937
+ values: ["window", "segments"],
938
+ },
939
+ pinReason: {
940
+ type: "string",
941
+ dataClass: "closed-enum",
942
+ required: true,
943
+ values: ["incident", "durable-batch"],
944
+ },
945
+ pinnedSegmentCount: { type: "integer", dataClass: "count", required: true },
946
+ pinnedBytes: { type: "integer", dataClass: "count", required: true },
947
+ windowSeconds: { type: "integer", dataClass: "count", required: false },
948
+ expiresInSeconds: { type: "integer", dataClass: "count", required: true },
949
+ quotaStatus: {
950
+ type: "string",
951
+ dataClass: "closed-enum",
952
+ required: false,
953
+ values: ["within-quota", "exceeded"],
954
+ },
955
+ },
956
+ causal: "correlation",
957
+ lifecycle: "start",
958
+ analyzerProjection: "capability",
959
+ failureClasses: ["activity-log-pin"],
960
+ proofIds: ["activity-log.pin.created.emitted-line"],
961
+ releaseImpact: "patch",
962
+ });
963
+ const ACTIVITY_LOG_PIN_EXPIRED_OPERATION = defineActivityLogOperation({
964
+ contractKind: "activity-log-operation",
965
+ schemaVersion: 1,
966
+ op: "activity-log.pin.expired",
967
+ category: "diagnostic",
968
+ owner: "keiko-server",
969
+ emitter: "observability/server-log.pinExpiredEvidence",
970
+ fields: {
971
+ pinId: { type: "string", dataClass: "opaque-id", required: true, maxLength: 24 },
972
+ expiryReason: {
973
+ type: "string",
974
+ dataClass: "closed-enum",
975
+ required: true,
976
+ values: ["expired", "invalid-record", "released"],
977
+ },
978
+ removalStatus: {
979
+ type: "string",
980
+ dataClass: "closed-enum",
981
+ required: true,
982
+ values: ["removed", "failed"],
983
+ },
984
+ releasedSegmentCount: { type: "integer", dataClass: "count", required: true },
985
+ releasedBytes: { type: "integer", dataClass: "count", required: true },
986
+ },
987
+ causal: "correlation",
988
+ lifecycle: "end",
989
+ analyzerProjection: "capability",
990
+ failureClasses: ["activity-log-pin"],
991
+ proofIds: ["activity-log.pin.expired.emitted-line"],
992
+ releaseImpact: "patch",
993
+ });
994
+ const ACTIVITY_LOG_PIN_QUOTA_EXHAUSTED_OPERATION = defineActivityLogOperation({
995
+ contractKind: "activity-log-operation",
996
+ schemaVersion: 1,
997
+ op: "activity-log.pin.quota-exhausted",
998
+ category: "diagnostic",
999
+ owner: "keiko-server",
1000
+ emitter: "observability/server-log.pinQuotaExhaustedEvidence",
1001
+ fields: {
1002
+ pinQuotaBytes: { type: "integer", dataClass: "count", required: true },
1003
+ requestedPinnedBytes: { type: "integer", dataClass: "count", required: true },
1004
+ protectedPinnedBytes: { type: "integer", dataClass: "count", required: true },
1005
+ protectedSegmentCount: { type: "integer", dataClass: "count", required: true },
1006
+ unprotectedSegmentCount: { type: "integer", dataClass: "count", required: true },
1007
+ unprotectedBytes: { type: "integer", dataClass: "count", required: true },
1008
+ unprotectedSeqSpan: { type: "integer", dataClass: "count", required: true },
1009
+ unknownSpanSegmentCount: { type: "integer", dataClass: "count", required: true },
1010
+ activePinCount: { type: "integer", dataClass: "count", required: true },
1011
+ },
1012
+ causal: "correlation",
1013
+ lifecycle: "loss",
1014
+ analyzerProjection: "failure-cluster",
1015
+ failureClasses: ["activity-log-pin"],
1016
+ proofIds: ["activity-log.pin.quota-exhausted.emitted-line"],
1017
+ releaseImpact: "patch",
1018
+ });
1019
+ // A cooperating process's own env disagreed with the store's governing policy (#3554): it either
1020
+ // adopted the stored bounds, or — the sole live writer, e.g. a clean restart with a changed env —
1021
+ // replaced them. Never fired when nothing disagreed.
1022
+ const ACTIVITY_LOG_POLICY_CONFLICT_OPERATION = defineActivityLogOperation({
1023
+ contractKind: "activity-log-operation",
1024
+ schemaVersion: 1,
1025
+ op: "activity-log.policy.conflict",
1026
+ category: "diagnostic",
1027
+ owner: "keiko-server",
1028
+ emitter: "observability/server-log.policyConflictEvidence",
1029
+ fields: {
1030
+ policyResolution: {
1031
+ type: "string",
1032
+ dataClass: "closed-enum",
1033
+ required: true,
1034
+ values: ["adopted", "replaced"],
1035
+ },
1036
+ conflictingSettings: {
1037
+ type: "string-array",
1038
+ dataClass: "closed-enum",
1039
+ required: true,
1040
+ values: ["retentionBytes", "retentionDays", "pinQuotaBytes"],
1041
+ maxItems: 3,
1042
+ },
1043
+ storedRetentionBytes: { type: "integer", dataClass: "count", required: true },
1044
+ requestedRetentionBytes: { type: "integer", dataClass: "count", required: true },
1045
+ storedRetentionDays: { type: "integer", dataClass: "count", required: true },
1046
+ requestedRetentionDays: { type: "integer", dataClass: "count", required: true },
1047
+ storedPinQuotaBytes: { type: "integer", dataClass: "count", required: true },
1048
+ requestedPinQuotaBytes: { type: "integer", dataClass: "count", required: true },
1049
+ },
1050
+ causal: "correlation",
1051
+ lifecycle: "state",
1052
+ analyzerProjection: "capability",
1053
+ failureClasses: ["activity-log-policy"],
1054
+ proofIds: ["activity-log.policy.conflict.emitted-line"],
1055
+ releaseImpact: "patch",
1056
+ });
1057
+ /**
1058
+ * The operations the Activity Log store writes about itself (opening, sealing, recovering, pruning,
1059
+ * pressure, pins, policy), derived from their registrations. A reader that wants only the
1060
+ * producers' evidence filters these out instead of restating the list.
1061
+ */
1062
+ export const ACTIVITY_LOG_STORAGE_OPERATIONS = new Set([
1063
+ SERVER_LOG_SAFE_OPEN_OPERATION.op,
1064
+ ACTIVITY_LOG_SEGMENT_SEALED_OPERATION.op,
1065
+ ACTIVITY_LOG_SEGMENT_RECOVERED_OPERATION.op,
1066
+ ACTIVITY_LOG_RETENTION_PRUNED_OPERATION.op,
1067
+ ACTIVITY_LOG_PRESSURE_OPERATION.op,
1068
+ ACTIVITY_LOG_PIN_CREATED_OPERATION.op,
1069
+ ACTIVITY_LOG_PIN_EXPIRED_OPERATION.op,
1070
+ ACTIVITY_LOG_PIN_QUOTA_EXHAUSTED_OPERATION.op,
1071
+ ACTIVITY_LOG_POLICY_CONFLICT_OPERATION.op,
1072
+ ]);
1073
+ const SEAL_RESERVE_BYTES = MAX_LOG_LINE_BYTES + 1;
1074
+ // `seq` can gain digits between measuring a line and writing it; never more than this many.
1075
+ const SEQ_GROWTH_MARGIN_BYTES = 16;
1076
+ const MAX_ROLLOVERS_PER_WRITE = 8;
1077
+ const MAX_QUEUED_EVIDENCE = 256;
1078
+ const CLOCK_TOLERANCE_MS = 5_000;
1079
+ const ADMISSION_RETRY_MS = 1_000;
1080
+ const SEALED_SEGMENT_MODE = 0o400;
1081
+ const activeLogs = new Map();
1082
+ function activeLogKey(directory) {
1083
+ try {
1084
+ return realpathSync(directory);
1085
+ }
1086
+ catch {
1087
+ return resolvePath(directory);
1088
+ }
1089
+ }
1090
+ // Merges the store's governing policy outcome into a per-process, env-resolved config: segment
1091
+ // size/age stay per-writer, but retention bytes/days and the pin quota are always the GOVERNED
1092
+ // values, re-clamping segmentBytes against them with the exact invariant
1093
+ // `resolveActivityLogStorageConfig` itself applies (never restated — #3554).
1094
+ function applyGovernedPolicy(envConfig, governed) {
1095
+ return {
1096
+ ...envConfig,
1097
+ retentionBytes: governed.retentionBytes,
1098
+ retentionDays: governed.retentionDays,
1099
+ pinQuotaBytes: governed.pinQuotaBytes,
1100
+ segmentBytes: clampActivityLogSegmentBytes(envConfig.segmentBytes, governed.retentionBytes),
1101
+ };
503
1102
  }
504
- function sameLogNode(left, right) {
505
- return left.dev === right.dev && left.ino === right.ino && left.size === right.size;
1103
+ function resolveActiveLog(directory, config) {
1104
+ const key = activeLogKey(directory);
1105
+ const existing = activeLogs.get(key);
1106
+ if (existing !== undefined)
1107
+ return existing;
1108
+ const created = {
1109
+ directory,
1110
+ trustedRoot: directory,
1111
+ config,
1112
+ envConfig: config,
1113
+ policyResolved: false,
1114
+ governed: undefined,
1115
+ segment: undefined,
1116
+ nextIndex: 1,
1117
+ lastStartMs: 0,
1118
+ pendingNewline: false,
1119
+ pendingEvidence: [],
1120
+ blocked: new Map(),
1121
+ admissionRetryAtMs: 0,
1122
+ standingPressure: undefined,
1123
+ quotaExhaustedReported: false,
1124
+ recoveredSegments: 0,
1125
+ failedDeletions: new Map(),
1126
+ failedPinRemovals: new Map(),
1127
+ failedRecoveries: new Map(),
1128
+ sealTimer: undefined,
1129
+ };
1130
+ activeLogs.set(key, created);
1131
+ return created;
1132
+ }
1133
+ // Merges the store's ONE governing policy (#3554) into this directory's config, evidencing a
1134
+ // disagreement, the first time real storage work is imminent for it in this process — never at
1135
+ // sink creation, so a sink that never logs a passing-threshold event never touches the policy
1136
+ // file (the below-threshold burst-cost invariant this file's own header documents). Idempotent:
1137
+ // a pin request or durable batch append calls this eagerly (never speculative, unlike sink
1138
+ // creation), and an ordinary write calls it once its threshold check has already passed.
1139
+ function ensureGovernedPolicy(active, correlationId) {
1140
+ if (active.policyResolved)
1141
+ return;
1142
+ active.policyResolved = true;
1143
+ const outcome = resolveActivityLogStorePolicy(active.directory, active.trustedRoot, {
1144
+ retentionBytes: active.config.retentionBytes,
1145
+ retentionDays: active.config.retentionDays,
1146
+ pinQuotaBytes: active.config.pinQuotaBytes,
1147
+ }, { pid: process.pid, instanceId: INSTANCE_ID, isAlive: processIsAlive });
1148
+ active.governed = governedValues(outcome);
1149
+ active.config = applyGovernedPolicy(active.envConfig, outcome);
1150
+ if (outcome.conflict !== undefined) {
1151
+ queueEvidence(active, policyConflictEvidence(outcome.conflict, correlationId));
1152
+ }
1153
+ }
1154
+ function governedValues(values) {
1155
+ return {
1156
+ retentionBytes: values.retentionBytes,
1157
+ retentionDays: values.retentionDays,
1158
+ pinQuotaBytes: values.pinQuotaBytes,
1159
+ };
1160
+ }
1161
+ // Every maintenance pass re-applies the store's CURRENT governing policy before it deletes anything
1162
+ // (#3554). A record another process replaced after this one resolved it (a sole-writer restart while
1163
+ // this process held no active segment) governs this process's retention from its next pass on, so
1164
+ // no two processes prune under different budgets beyond one pass, and a disagreement with this
1165
+ // process's own env is evidenced again.
1166
+ function refreshGovernedPolicy(active, correlationId) {
1167
+ if (active.governed === undefined)
1168
+ return;
1169
+ const stored = readActivityLogPolicyRecord(active.directory, active.trustedRoot);
1170
+ const current = active.governed;
1171
+ if (stored === undefined ||
1172
+ ACTIVITY_LOG_POLICY_SETTINGS.every((key) => stored[key] === current[key])) {
1173
+ return;
1174
+ }
1175
+ active.governed = governedValues(stored);
1176
+ active.config = applyGovernedPolicy(active.envConfig, stored);
1177
+ const requested = governedValues(active.envConfig);
1178
+ const conflictingSettings = ACTIVITY_LOG_POLICY_SETTINGS.filter((key) => stored[key] !== requested[key]);
1179
+ if (conflictingSettings.length === 0)
1180
+ return;
1181
+ queueEvidence(active, policyConflictEvidence({ resolution: "adopted", conflictingSettings, stored: active.governed, requested }, correlationId));
1182
+ }
1183
+ // Real storage work is never speculative here (a pin request or a durable batch append IS the
1184
+ // work), so this resolves the store's governing policy eagerly instead of waiting for a write that
1185
+ // always follows at once.
1186
+ function resolveGovernedActiveLog(directory, env) {
1187
+ const active = resolveActiveLog(directory, resolveActivityLogStorageConfig(env));
1188
+ ensureGovernedPolicy(active, undefined);
1189
+ return active;
1190
+ }
1191
+ function peekIdentity(cursor, capability) {
1192
+ const claimed = cursor.claimed;
1193
+ if (claimed !== undefined)
1194
+ return { ...claimed, writerCapability: capability };
1195
+ return { ...serverLogProcessIdentity(capability), seq: nextProcessSeq };
1196
+ }
1197
+ function nextIdentity(cursor, capability) {
1198
+ const claimed = cursor.claimed;
1199
+ if (claimed === undefined)
1200
+ return allocateServerLogIdentity(capability);
1201
+ cursor.claimed = undefined;
1202
+ return { ...claimed, writerCapability: capability };
1203
+ }
1204
+ function queueEvidence(active, event, capability = "active") {
1205
+ if (active.pendingEvidence.length >= MAX_QUEUED_EVIDENCE) {
1206
+ recordActivityLogLoss("persistence-failed");
1207
+ reportServerLogFailure(new SafeArtifactFileError("activity-log", "write-failed"), {
1208
+ op: event.op,
1209
+ correlationId: event.correlationId,
1210
+ loss: "event-dropped",
1211
+ });
1212
+ return;
1213
+ }
1214
+ active.pendingEvidence.push({ event, capability });
1215
+ }
1216
+ function closeQuietly(handle) {
1217
+ try {
1218
+ closeSync(handle);
1219
+ }
1220
+ catch {
1221
+ // A descriptor we can no longer close is a descriptor we must stop using either way.
1222
+ }
506
1223
  }
507
1224
  function trustedLogIdentity(stat) {
508
1225
  if (!stat.isFile() || stat.nlink !== 1 || !Number.isSafeInteger(stat.size) || stat.size < 0) {
@@ -520,71 +1237,1508 @@ function pathLogIdentity(path) {
520
1237
  if (!stat.isFile() || stat.nlink !== 1 || !Number.isSafeInteger(stat.size) || stat.size < 0) {
521
1238
  return undefined;
522
1239
  }
523
- return {
524
- dev: stat.dev,
525
- ino: stat.ino,
526
- size: stat.size,
527
- mtimeMs: stat.mtimeMs,
528
- };
1240
+ return { dev: stat.dev, ino: stat.ino, size: stat.size, mtimeMs: stat.mtimeMs };
1241
+ }
1242
+ function sameLogNode(left, right) {
1243
+ return left.dev === right.dev && left.ino === right.ino && left.size === right.size;
529
1244
  }
530
- function currentHandleIdentity(active) {
531
- if (active.handle === null)
1245
+ // The segment's current size when its cached descriptor still names the inode at its active path,
1246
+ // else `undefined`. Checked before and after every append, so a peer or operator that replaced or
1247
+ // removed the path forces a new segment instead of bytes landing on a stale or unlinked inode.
1248
+ function currentSegmentSize(segment) {
1249
+ if (segment.handle === null)
532
1250
  return undefined;
533
- const descriptor = trustedLogIdentity(fstatSync(active.handle));
534
- if (descriptor === undefined)
1251
+ try {
1252
+ const opened = trustedLogIdentity(fstatSync(segment.handle));
1253
+ const pathname = pathLogIdentity(segment.activePath);
1254
+ return opened !== undefined && pathname !== undefined && sameLogNode(opened, pathname)
1255
+ ? opened.size
1256
+ : undefined;
1257
+ }
1258
+ catch {
535
1259
  return undefined;
536
- const pathname = pathLogIdentity(active.currentPath);
537
- return pathname !== undefined && sameLogNode(descriptor, pathname) ? descriptor : undefined;
1260
+ }
538
1261
  }
539
- function openTrustedDurableHandle(active) {
540
- const existing = currentHandleIdentity(active);
541
- if (existing !== undefined)
542
- return existing;
543
- closeHandle(active);
544
- const secureFlags = constants.O_WRONLY | constants.O_APPEND | constants.O_NONBLOCK | constants.O_NOFOLLOW;
1262
+ function stopSealTimer(active) {
1263
+ if (active.sealTimer === undefined)
1264
+ return;
1265
+ clearInterval(active.sealTimer);
1266
+ active.sealTimer = undefined;
1267
+ }
1268
+ // A live owner seals its own idle segment within one segment window, which is what lets another
1269
+ // process treat an active segment older than two windows as abandoned (pid reuse) without ever
1270
+ // taking over a healthy writer's file.
1271
+ function startSealTimer(active) {
1272
+ stopSealTimer(active);
1273
+ const periodMs = Math.max(1_000, Math.min(60_000, active.config.segmentSeconds * 250));
1274
+ const timer = setInterval(() => {
1275
+ sealIfExpired(active, { claimed: undefined, correlationId: undefined });
1276
+ }, periodMs);
1277
+ timer.unref();
1278
+ active.sealTimer = timer;
1279
+ }
1280
+ function abandonSegment(active) {
1281
+ const segment = active.segment;
1282
+ if (segment === undefined)
1283
+ return;
1284
+ active.segment = undefined;
1285
+ stopSealTimer(active);
1286
+ if (segment.handle !== null)
1287
+ closeQuietly(segment.handle);
1288
+ segment.handle = null;
1289
+ active.pendingNewline = false;
1290
+ }
1291
+ function noteSegmentLine(segment, seq) {
1292
+ segment.firstSeq ??= seq;
1293
+ segment.lastSeq = seq;
1294
+ segment.lineCount += 1;
1295
+ }
1296
+ // ─── Evidence builders ─────────────────────────────────────────────────────────────────────────
1297
+ function safeOpenEvidence(correlationId) {
1298
+ return activityLogEvent(SERVER_LOG_SAFE_OPEN_OPERATION, { correlationId: correlationIdOrUnknown(correlationId) }, {
1299
+ artifactClass: "activity-log",
1300
+ persistenceStatus: "opened",
1301
+ permissionAssurance: safeArtifactPermissionAssurance(),
1302
+ containmentAssurance: safeArtifactContainmentAssurance(),
1303
+ completeness: "complete",
1304
+ loss: "none",
1305
+ });
1306
+ }
1307
+ function mutationEvidence(event) {
1308
+ return activityLogEvent(SERVER_LOG_TARGET_MUTATED_OPERATION, {
1309
+ level: "error",
1310
+ correlationId: correlationIdOrUnknown(event.correlationId),
1311
+ errorKind: "target-mutated",
1312
+ }, {
1313
+ failedOp: redactLogLabel(event.op),
1314
+ artifactClass: "activity-log",
1315
+ permissionAssurance: safeArtifactPermissionAssurance(),
1316
+ containmentAssurance: safeArtifactContainmentAssurance(),
1317
+ completeness: "unknown",
1318
+ loss: "event-location-unknown",
1319
+ });
1320
+ }
1321
+ function segmentSealedEvidence(segment, facts, config) {
1322
+ const dropped = segment.droppedEvents;
1323
+ return activityLogEvent(ACTIVITY_LOG_SEGMENT_SEALED_OPERATION, { correlationId: correlationIdOrUnknown(facts.correlationId) }, {
1324
+ sealReason: facts.reason,
1325
+ segmentIndex: segment.identity.index,
1326
+ segmentFirstSeq: segment.firstSeq ?? facts.seq,
1327
+ segmentLastSeq: facts.seq,
1328
+ segmentLineCount: segment.lineCount,
1329
+ segmentBytes: facts.segmentBytes,
1330
+ segmentDurationMs: Math.max(0, Math.round(performance.now() - segment.monotonicStartMs)),
1331
+ droppedEventCount: dropped,
1332
+ segmentByteLimit: config.segmentBytes,
1333
+ segmentSecondsLimit: config.segmentSeconds,
1334
+ completeness: dropped > 0 ? "partial" : "complete",
1335
+ loss: dropped > 0 ? "event-dropped" : "none",
1336
+ });
1337
+ }
1338
+ function recoveryLoss(outcome) {
1339
+ return outcome.tail?.tailState === "truncated" ? "event-dropped" : "none";
1340
+ }
1341
+ function recoveredTailFields(outcome) {
1342
+ const tail = outcome.tail;
1343
+ return tail === undefined
1344
+ ? { tailState: "unknown", truncatedBytes: 0, segmentBytes: outcome.segmentBytes }
1345
+ : {
1346
+ tailState: tail.tailState,
1347
+ truncatedBytes: tail.truncatedBytes,
1348
+ segmentBytes: tail.sizeBytes,
1349
+ };
1350
+ }
1351
+ function segmentRecoveredEvidence(outcome, correlationId) {
1352
+ const failed = outcome.status === "failed";
1353
+ const tail = recoveredTailFields(outcome);
1354
+ return activityLogEvent(ACTIVITY_LOG_SEGMENT_RECOVERED_OPERATION, {
1355
+ level: failed ? "error" : "warn",
1356
+ correlationId: correlationIdOrUnknown(correlationId),
1357
+ ...(outcome.errorKind === undefined ? {} : { errorKind: outcome.errorKind }),
1358
+ }, {
1359
+ recoveryStatus: outcome.status,
1360
+ recoveryKind: outcome.kind,
1361
+ ownerState: outcome.owner,
1362
+ tailState: tail.tailState,
1363
+ truncatedBytes: tail.truncatedBytes,
1364
+ segmentBytes: tail.segmentBytes,
1365
+ segmentIndex: outcome.segment.index,
1366
+ recoveredInstanceId: outcome.segment.instanceId,
1367
+ // An orphan's owner never recorded its own end, so its completeness cannot be proven; only a
1368
+ // seal whose rename alone was interrupted carries the owner's own complete seal line.
1369
+ completeness: outcome.kind === "interrupted-seal" && !failed ? "complete" : "unknown",
1370
+ loss: recoveryLoss(outcome),
1371
+ });
1372
+ }
1373
+ function retentionStatus(outcome) {
1374
+ if (outcome.failedNames.length === 0)
1375
+ return "pruned";
1376
+ return outcome.prunedSegmentCount + outcome.prunedLegacyFileCount > 0 ? "partial" : "failed";
1377
+ }
1378
+ function retentionPrunedEvidence(outcome, config, correlationId) {
1379
+ const status = retentionStatus(outcome);
1380
+ return activityLogEvent(ACTIVITY_LOG_RETENTION_PRUNED_OPERATION, {
1381
+ level: status === "pruned" ? "info" : "warn",
1382
+ correlationId: correlationIdOrUnknown(correlationId),
1383
+ ...(status === "pruned" ? {} : { errorKind: "durability-failed" }),
1384
+ }, {
1385
+ retentionStatus: status,
1386
+ prunedSegmentCount: outcome.prunedSegmentCount,
1387
+ prunedLegacyFileCount: outcome.prunedLegacyFileCount,
1388
+ prunedBytes: outcome.prunedBytes,
1389
+ prunedByAgeCount: outcome.prunedByAgeCount,
1390
+ prunedByBudgetCount: outcome.prunedByBudgetCount,
1391
+ failedDeletionCount: outcome.failedNames.length,
1392
+ retainedFileCount: outcome.retainedFileCount,
1393
+ retainedBytes: outcome.retainedBytes,
1394
+ protectedPinnedBytes: outcome.protection.protectedBytes,
1395
+ retentionBudgetBytes: config.retentionBytes,
1396
+ retentionDays: config.retentionDays,
1397
+ completeness: status === "pruned" ? "complete" : "partial",
1398
+ loss: "none",
1399
+ });
1400
+ }
1401
+ const PRESSURE_ERROR_KIND = {
1402
+ "low-disk-space": "unavailable",
1403
+ "disk-full": "write-failed",
1404
+ backpressure: "write-failed",
1405
+ "budget-exceeded": "unavailable",
1406
+ "retention-blocked": "durability-failed",
1407
+ };
1408
+ function pressureEvidence(facts, config, correlationId) {
1409
+ const lost = facts.droppedEventCount > 0;
1410
+ return activityLogEvent(ACTIVITY_LOG_PRESSURE_OPERATION, {
1411
+ level: facts.state === "cleared" ? "info" : "warn",
1412
+ correlationId: correlationIdOrUnknown(correlationId),
1413
+ ...(facts.state === "cleared" ? {} : { errorKind: PRESSURE_ERROR_KIND[facts.state] }),
1414
+ }, {
1415
+ pressureState: facts.state,
1416
+ ...(facts.previousState === undefined ? {} : { previousState: facts.previousState }),
1417
+ droppedEventCount: facts.droppedEventCount,
1418
+ ...(facts.usedBytes === undefined ? {} : { usedBytes: facts.usedBytes }),
1419
+ budgetBytes: config.retentionBytes,
1420
+ pinQuotaBytes: config.pinQuotaBytes,
1421
+ ...(facts.freeBytes === undefined ? {} : { freeBytes: facts.freeBytes }),
1422
+ completeness: lost ? "partial" : "complete",
1423
+ loss: lost ? "event-dropped" : "none",
1424
+ });
1425
+ }
1426
+ function pinWindowSeconds(scope) {
1427
+ return scope?.kind === "window" ? Math.ceil((scope.toMs - scope.fromMs) / 1000) : undefined;
1428
+ }
1429
+ function pinOptionalFields(facts) {
1430
+ const windowSeconds = pinWindowSeconds(facts.scope);
1431
+ return {
1432
+ ...(facts.pinId === undefined ? {} : { pinId: facts.pinId }),
1433
+ ...(facts.rejectionReason === undefined ? {} : { rejectionReason: facts.rejectionReason }),
1434
+ ...(windowSeconds === undefined ? {} : { windowSeconds }),
1435
+ ...(facts.quotaStatus === undefined ? {} : { quotaStatus: facts.quotaStatus }),
1436
+ };
1437
+ }
1438
+ function pinCreatedEvidence(facts, correlationId) {
1439
+ const rejected = facts.status === "rejected";
1440
+ const degraded = rejected || facts.quotaStatus === "exceeded";
1441
+ return activityLogEvent(ACTIVITY_LOG_PIN_CREATED_OPERATION, {
1442
+ level: degraded ? "warn" : "info",
1443
+ correlationId: correlationIdOrUnknown(correlationId),
1444
+ ...(rejected ? { errorKind: pinRejectionErrorKind(facts.rejectionReason) } : {}),
1445
+ }, {
1446
+ ...pinOptionalFields(facts),
1447
+ pinStatus: facts.status,
1448
+ pinKind: facts.scope?.kind === "window" ? "window" : "segments",
1449
+ pinReason: facts.reason,
1450
+ pinnedSegmentCount: facts.pinnedSegmentCount,
1451
+ pinnedBytes: facts.pinnedBytes,
1452
+ expiresInSeconds: facts.expiresInSeconds,
1453
+ completeness: degraded ? "partial" : "complete",
1454
+ loss: "none",
1455
+ });
1456
+ }
1457
+ function pinRejectionErrorKind(reason) {
1458
+ if (reason === "invalid-request")
1459
+ return "invalid-request";
1460
+ return reason === "pin-limit-reached" ? "rate-limited" : "unavailable";
1461
+ }
1462
+ function pinExpiredEvidence(facts, correlationId) {
1463
+ return activityLogEvent(ACTIVITY_LOG_PIN_EXPIRED_OPERATION, {
1464
+ level: facts.removed ? "info" : "warn",
1465
+ correlationId: correlationIdOrUnknown(correlationId),
1466
+ ...(facts.removed ? {} : { errorKind: "durability-failed" }),
1467
+ }, {
1468
+ pinId: facts.pinId,
1469
+ expiryReason: facts.reason,
1470
+ removalStatus: facts.removed ? "removed" : "failed",
1471
+ releasedSegmentCount: facts.releasedSegmentCount,
1472
+ releasedBytes: facts.releasedBytes,
1473
+ completeness: facts.removed ? "complete" : "partial",
1474
+ loss: "none",
1475
+ });
1476
+ }
1477
+ function pinQuotaExhaustedEvidence(facts, config, correlationId) {
1478
+ const protection = facts.protection;
1479
+ return activityLogEvent(ACTIVITY_LOG_PIN_QUOTA_EXHAUSTED_OPERATION, {
1480
+ level: "error",
1481
+ correlationId: correlationIdOrUnknown(correlationId),
1482
+ errorKind: "unavailable",
1483
+ }, {
1484
+ pinQuotaBytes: config.pinQuotaBytes,
1485
+ requestedPinnedBytes: protection.requestedBytes,
1486
+ protectedPinnedBytes: protection.protectedBytes,
1487
+ protectedSegmentCount: protection.protectedNames.size,
1488
+ unprotectedSegmentCount: protection.unprotected.length,
1489
+ unprotectedBytes: protection.unprotected.reduce((sum, entry) => sum + entry.sizeBytes, 0),
1490
+ unprotectedSeqSpan: facts.seqSpan,
1491
+ unknownSpanSegmentCount: facts.unknownSpanSegmentCount,
1492
+ activePinCount: facts.pinCount,
1493
+ completeness: "partial",
1494
+ loss: "event-dropped",
1495
+ });
1496
+ }
1497
+ // A cooperating process's own env disagreed with the store's one governing policy: "adopted" means
1498
+ // the stored bounds won (this process's own view is overridden); "replaced" means this process was
1499
+ // the store's sole live writer and its own bounds now govern (e.g. a clean restart with a changed
1500
+ // `KEIKO_LOG_RETENTION_BYTES`).
1501
+ function policyConflictEvidence(conflict, correlationId) {
1502
+ const replaced = conflict.resolution === "replaced";
1503
+ return activityLogEvent(ACTIVITY_LOG_POLICY_CONFLICT_OPERATION, {
1504
+ level: replaced ? "info" : "warn",
1505
+ correlationId: correlationIdOrUnknown(correlationId),
1506
+ ...(replaced ? {} : { errorKind: "conflict" }),
1507
+ }, {
1508
+ policyResolution: conflict.resolution,
1509
+ conflictingSettings: conflict.conflictingSettings,
1510
+ storedRetentionBytes: conflict.stored.retentionBytes,
1511
+ requestedRetentionBytes: conflict.requested.retentionBytes,
1512
+ storedRetentionDays: conflict.stored.retentionDays,
1513
+ requestedRetentionDays: conflict.requested.retentionDays,
1514
+ storedPinQuotaBytes: conflict.stored.pinQuotaBytes,
1515
+ requestedPinQuotaBytes: conflict.requested.pinQuotaBytes,
1516
+ completeness: "complete",
1517
+ loss: "none",
1518
+ });
1519
+ }
1520
+ // ─── Maintenance: recovery, pin expiry, retention, quota, pressure ─────────────────────────────
1521
+ function sharesInode(left, right) {
1522
+ try {
1523
+ const a = lstatSync(left);
1524
+ const b = lstatSync(right);
1525
+ return a.isFile() && b.isFile() && a.dev === b.dev && a.ino === b.ino;
1526
+ }
1527
+ catch {
1528
+ return false;
1529
+ }
1530
+ }
1531
+ function pathMissing(path) {
545
1532
  try {
546
- active.handle = openSync(active.currentPath, secureFlags);
1533
+ lstatSync(path);
1534
+ return false;
547
1535
  }
548
1536
  catch (error) {
549
- if (errorCode(error) !== "ENOENT")
550
- return undefined;
551
- try {
552
- active.handle = openSync(active.currentPath, secureFlags | constants.O_CREAT | constants.O_EXCL, 0o600);
553
- }
554
- catch {
555
- return undefined;
556
- }
1537
+ return machineToken(safeProperty(error, "code")) === "ENOENT";
557
1538
  }
558
- return currentHandleIdentity(active);
559
1539
  }
560
- function durableLogDirectory(directory) {
1540
+ function closedErrorKind(error) {
1541
+ return activityLogErrorKindOr(errorKindOf(error), "internal");
1542
+ }
1543
+ function sealedTwinPath(active, segment) {
1544
+ return join(active.directory, activityLogSegmentFileName(segment, "sealed"));
1545
+ }
1546
+ function readSealedTail(path, trustedRoot) {
1547
+ let descriptor;
561
1548
  try {
562
- const stat = lstatSync(directory);
563
- return stat.isDirectory() && !stat.isSymbolicLink();
1549
+ descriptor = openSafeArtifactFile(path, {
1550
+ artifactClass: "activity-log",
1551
+ mode: "read",
1552
+ trustedRoot,
1553
+ });
1554
+ return inspectActivityLogSegmentTail(descriptor, ACTIVITY_LOG_SEGMENT_SEALED_OPERATION.op);
564
1555
  }
565
1556
  catch {
566
- return false;
1557
+ return undefined;
1558
+ }
1559
+ finally {
1560
+ if (descriptor !== undefined)
1561
+ closeQuietly(descriptor);
567
1562
  }
568
1563
  }
569
- function openLogDirectoryGuard(path) {
570
- const before = lstatSync(path);
571
- if (!before.isDirectory() || before.isSymbolicLink())
572
- return undefined;
573
- let handle;
1564
+ function archiveOptions(active) {
1565
+ return { artifactClass: "activity-log", trustedRoot: active.trustedRoot };
1566
+ }
1567
+ // A crash between the hard link and the unlink of a seal leaves both names on one inode; finishing
1568
+ // the archive removes only the active name, and the sealed segment is then inspected as it stands.
1569
+ function finishInterruptedSeal(active, entry, owner, sealedPath) {
1570
+ const base = { owner, segment: entry.file, segmentBytes: entry.sizeBytes };
574
1571
  try {
575
- const directoryFlag = typeof constants.O_DIRECTORY === "number" ? constants.O_DIRECTORY : 0;
576
- const noFollowFlag = typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
577
- handle = openSync(path, constants.O_RDONLY | directoryFlag | noFollowFlag);
578
- return validateOpenedLogDirectory(path, before.dev, before.ino, handle);
1572
+ archiveSafeArtifactFile(entry.path, sealedPath, archiveOptions(active));
1573
+ const tail = readSealedTail(sealedPath, active.trustedRoot);
1574
+ return { ...base, status: "sealed", kind: "interrupted-seal", tail, errorKind: undefined };
579
1575
  }
580
- catch {
581
- if (handle !== undefined)
582
- closeSync(handle);
583
- return windowsLogDirectoryGuard(path, before.dev, before.ino);
1576
+ catch (error) {
1577
+ return {
1578
+ ...base,
1579
+ status: "failed",
1580
+ kind: "interrupted-seal",
1581
+ tail: undefined,
1582
+ errorKind: closedErrorKind(error),
1583
+ };
584
1584
  }
585
1585
  }
586
- function validateOpenedLogDirectory(path, dev, ino, handle) {
587
- const opened = fstatSync(handle);
1586
+ // Durability and read-only mode are best effort for a file another process wrote: the content is
1587
+ // never modified, and a platform that cannot apply either still leaves a private sealed segment.
1588
+ function settleOrphanDescriptor(descriptor) {
1589
+ try {
1590
+ fsyncSync(descriptor);
1591
+ }
1592
+ catch {
1593
+ // Some platforms refuse fsync on a read-only descriptor; the sealing rename still proceeds.
1594
+ }
1595
+ try {
1596
+ fchmodSync(descriptor, SEALED_SEGMENT_MODE);
1597
+ }
1598
+ catch {
1599
+ // The segment stays owner-private (0600); retention and readers accept that mode.
1600
+ }
1601
+ }
1602
+ function sealOrphanDescriptor(active, entry, descriptor, sealedPath) {
1603
+ const tail = inspectActivityLogSegmentTail(descriptor, ACTIVITY_LOG_SEGMENT_SEALED_OPERATION.op);
1604
+ settleOrphanDescriptor(descriptor);
1605
+ const result = archiveSafeArtifactFile(entry.path, sealedPath, archiveOptions(active));
1606
+ if (result === "archive-exists")
1607
+ throw new SafeArtifactFileError("activity-log", "target-exists");
1608
+ return { tail, archived: result !== "source-missing" };
1609
+ }
1610
+ function recoverOrphanedSegment(active, entry, owner) {
1611
+ const sealedPath = sealedTwinPath(active, entry.file);
1612
+ if (sharesInode(entry.path, sealedPath)) {
1613
+ return finishInterruptedSeal(active, entry, owner, sealedPath);
1614
+ }
1615
+ const base = { owner, segment: entry.file, segmentBytes: entry.sizeBytes };
1616
+ let descriptor;
1617
+ try {
1618
+ descriptor = openSafeArtifactFile(entry.path, { ...archiveOptions(active), mode: "read" });
1619
+ }
1620
+ catch (error) {
1621
+ if (pathMissing(entry.path))
1622
+ return undefined;
1623
+ const errorKind = closedErrorKind(error);
1624
+ return { ...base, status: "failed", kind: "unsealed", tail: undefined, errorKind };
1625
+ }
1626
+ try {
1627
+ const sealed = sealOrphanDescriptor(active, entry, descriptor, sealedPath);
1628
+ if (!sealed.archived)
1629
+ return undefined;
1630
+ const kind = sealed.tail.sealLinePresent ? "interrupted-seal" : "unsealed";
1631
+ return { ...base, status: "sealed", kind, tail: sealed.tail, errorKind: undefined };
1632
+ }
1633
+ catch (error) {
1634
+ const errorKind = closedErrorKind(error);
1635
+ return { ...base, status: "failed", kind: "unsealed", tail: undefined, errorKind };
1636
+ }
1637
+ finally {
1638
+ closeQuietly(descriptor);
1639
+ }
1640
+ }
1641
+ // A failed seal, recovery, or deletion is retried after this backoff, never skipped for the life of
1642
+ // the process: a transient lock or permission blip must not strand bytes the budget keeps counting.
1643
+ // Only the first failure of a name is evidenced; its retries stay quiet until one succeeds.
1644
+ const FAILED_MUTATION_RETRY_MS = 60_000;
1645
+ function retryDue(failures, key, nowMs) {
1646
+ const retryAtMs = failures.get(key);
1647
+ return retryAtMs === undefined || retryAtMs <= nowMs;
1648
+ }
1649
+ // Records a failure and returns whether it is the first one for `key`.
1650
+ function recordMutationFailure(failures, key, nowMs) {
1651
+ const first = !failures.has(key);
1652
+ failures.set(key, nowMs + FAILED_MUTATION_RETRY_MS);
1653
+ return first;
1654
+ }
1655
+ // Forgets failures whose target no longer exists (a peer or an operator removed it).
1656
+ function forgetVanished(failures, present) {
1657
+ for (const key of failures.keys()) {
1658
+ if (!present.has(key))
1659
+ failures.delete(key);
1660
+ }
1661
+ }
1662
+ // Whether a recovery outcome is evidenced: every success, and the first failure of a segment.
1663
+ function noteRecoveryOutcome(active, name, outcome, nowMs) {
1664
+ if (outcome.status === "failed")
1665
+ return recordMutationFailure(active.failedRecoveries, name, nowMs);
1666
+ active.failedRecoveries.delete(name);
1667
+ active.recoveredSegments += 1;
1668
+ return true;
1669
+ }
1670
+ function recoverOrphanedSegments(active, cursor, listing, nowMs) {
1671
+ const context = {
1672
+ pid: process.pid,
1673
+ instanceId: INSTANCE_ID,
1674
+ currentName: active.segment?.activeName,
1675
+ nowMs,
1676
+ segmentSeconds: active.config.segmentSeconds,
1677
+ isAlive: processIsAlive,
1678
+ };
1679
+ forgetVanished(active.failedRecoveries, new Set(listing.files.map((entry) => entry.file.name)));
1680
+ let changed = false;
1681
+ for (const entry of listing.files) {
1682
+ if (!isActivityLogSegmentEntry(entry))
1683
+ continue;
1684
+ if (!retryDue(active.failedRecoveries, entry.file.name, nowMs))
1685
+ continue;
1686
+ const owner = activityLogOrphanOwner(entry, context);
1687
+ if (owner === undefined)
1688
+ continue;
1689
+ const outcome = recoverOrphanedSegment(active, entry, owner);
1690
+ if (outcome === undefined)
1691
+ continue;
1692
+ changed = true;
1693
+ if (noteRecoveryOutcome(active, entry.file.name, outcome, nowMs)) {
1694
+ queueEvidence(active, segmentRecoveredEvidence(outcome, cursor.correlationId));
1695
+ }
1696
+ }
1697
+ return changed;
1698
+ }
1699
+ function pinCoverage(pin, files) {
1700
+ let count = 0;
1701
+ let bytes = 0;
1702
+ if (pin === undefined)
1703
+ return { count, bytes };
1704
+ for (const entry of files) {
1705
+ if (entry.file.kind !== "sealed" || !isActivityLogSegmentEntry(entry))
1706
+ continue;
1707
+ if (!activityLogPinCovers(pin, entry))
1708
+ continue;
1709
+ count += 1;
1710
+ bytes += entry.sizeBytes;
1711
+ }
1712
+ return { count, bytes };
1713
+ }
1714
+ function removePinRecordQuietly(active, read) {
1715
+ try {
1716
+ removeActivityLogFile(read.entry.path, active.trustedRoot);
1717
+ active.failedPinRemovals.delete(read.entry.path);
1718
+ return true;
1719
+ }
1720
+ catch {
1721
+ return false;
1722
+ }
1723
+ }
1724
+ // Expired and unreadable pin records protect nothing; removing them is bounded cleanup. A removal
1725
+ // that fails is retried after the backoff; each record's removal and first failure are evidenced.
1726
+ // Returns the paths removed in this pass.
1727
+ function expireActivityLogPins(active, cursor, listing, reads, nowMs) {
1728
+ const removedPaths = new Set();
1729
+ forgetVanished(active.failedPinRemovals, new Set(reads.map((read) => read.entry.path)));
1730
+ for (const read of reads) {
1731
+ if (read.record !== undefined && read.record.expiresAtMs > nowMs)
1732
+ continue;
1733
+ if (!retryDue(active.failedPinRemovals, read.entry.path, nowMs))
1734
+ continue;
1735
+ const coverage = pinCoverage(read.record, listing.files);
1736
+ const removed = removePinRecordQuietly(active, read);
1737
+ if (removed)
1738
+ removedPaths.add(read.entry.path);
1739
+ else if (!recordMutationFailure(active.failedPinRemovals, read.entry.path, nowMs))
1740
+ continue;
1741
+ const facts = {
1742
+ pinId: read.entry.pinId,
1743
+ reason: read.record === undefined ? "invalid-record" : "expired",
1744
+ removed,
1745
+ releasedSegmentCount: coverage.count,
1746
+ releasedBytes: coverage.bytes,
1747
+ };
1748
+ queueEvidence(active, pinExpiredEvidence(facts, cursor.correlationId));
1749
+ }
1750
+ return removedPaths;
1751
+ }
1752
+ function tightenLegacyFile(path, trustedRoot) {
1753
+ try {
1754
+ // The shared open primitive narrows a non-private owned file to 0600 before handing back a
1755
+ // verified descriptor; no byte is read or written.
1756
+ closeSync(openSafeArtifactFile(path, {
1757
+ artifactClass: "activity-log",
1758
+ mode: "read-write-existing",
1759
+ trustedRoot,
1760
+ }));
1761
+ return true;
1762
+ }
1763
+ catch {
1764
+ return false;
1765
+ }
1766
+ }
1767
+ function removeRetentionTarget(active, entry) {
1768
+ try {
1769
+ removeActivityLogFile(entry.path, active.trustedRoot);
1770
+ active.failedDeletions.delete(entry.file.name);
1771
+ return true;
1772
+ }
1773
+ catch (error) {
1774
+ const permissionUnsafe = error instanceof SafeArtifactFileError && error.kind === "permission-unsafe";
1775
+ if (!permissionUnsafe || !tightenLegacyFile(entry.path, active.trustedRoot))
1776
+ return false;
1777
+ }
1778
+ try {
1779
+ removeActivityLogFile(entry.path, active.trustedRoot);
1780
+ active.failedDeletions.delete(entry.file.name);
1781
+ return true;
1782
+ }
1783
+ catch {
1784
+ return false;
1785
+ }
1786
+ }
1787
+ function queueRetentionEvidence(active, cursor, outcome, firstFailures) {
1788
+ const pruned = outcome.prunedSegmentCount + outcome.prunedLegacyFileCount;
1789
+ if (pruned === 0 && firstFailures === 0)
1790
+ return;
1791
+ queueEvidence(active, retentionPrunedEvidence(outcome, active.config, cursor.correlationId));
1792
+ }
1793
+ function unprotectedSpan(active, protection) {
1794
+ let seqSpan = 0;
1795
+ let unknown = 0;
1796
+ for (const entry of protection.unprotected) {
1797
+ const span = activityLogSegmentSeqSpan(entry.path, active.trustedRoot);
1798
+ if (span === undefined)
1799
+ unknown += 1;
1800
+ else
1801
+ seqSpan += span;
1802
+ }
1803
+ return { seqSpan, unknown };
1804
+ }
1805
+ // Exactly one loss marker per exhaustion episode: the first pass that finds pinned evidence the
1806
+ // quota cannot hold reports it — measured before retention may delete those segments — and later
1807
+ // passes stay quiet until the quota holds every pin again.
1808
+ function queueQuotaEvidence(active, cursor, protection, pinCount) {
1809
+ if (protection.unprotected.length === 0) {
1810
+ active.quotaExhaustedReported = false;
1811
+ return;
1812
+ }
1813
+ if (active.quotaExhaustedReported)
1814
+ return;
1815
+ active.quotaExhaustedReported = true;
1816
+ const span = unprotectedSpan(active, protection);
1817
+ const facts = {
1818
+ protection,
1819
+ pinCount,
1820
+ seqSpan: span.seqSpan,
1821
+ unknownSpanSegmentCount: span.unknown,
1822
+ };
1823
+ queueEvidence(active, pinQuotaExhaustedEvidence(facts, active.config, cursor.correlationId));
1824
+ }
1825
+ // Blocked while any deletion is still pending retry, not only in the pass that first failed.
1826
+ function standingPressure(active, freeBytes) {
1827
+ if (active.failedDeletions.size > 0)
1828
+ return "retention-blocked";
1829
+ const lowDisk = activityLogLowDiskThresholdBytes(active.config);
1830
+ return freeBytes !== undefined && freeBytes < lowDisk ? "low-disk-space" : undefined;
1831
+ }
1832
+ // Standing conditions are reported on entry and once more when they clear; conditions that block
1833
+ // writing (disk full, backpressure, an exhausted budget) are reported when writing resumes, with the
1834
+ // exact number of events they cost.
1835
+ function queuePressureTransition(active, cursor, outcome) {
1836
+ const freeBytes = activityLogFreeBytes(active.directory);
1837
+ const state = standingPressure(active, freeBytes);
1838
+ const previous = active.standingPressure;
1839
+ if (state === previous)
1840
+ return;
1841
+ active.standingPressure = state;
1842
+ const facts = state === undefined
1843
+ ? { state: "cleared", previousState: previous, droppedEventCount: 0, freeBytes }
1844
+ : { state, droppedEventCount: 0, usedBytes: outcome.usageBytes, freeBytes };
1845
+ queueEvidence(active, pressureEvidence(facts, active.config, cursor.correlationId));
1846
+ }
1847
+ // Every pin record still on disk counts toward the byte budget, including one this process could
1848
+ // not remove; only the records removed in this pass are gone.
1849
+ function remainingPinRecordBytes(reads, removed) {
1850
+ return reads
1851
+ .filter((read) => !removed.has(read.entry.path))
1852
+ .reduce((sum, read) => sum + read.entry.sizeBytes, 0);
1853
+ }
1854
+ // Names whose failed deletion is not yet due for a retry; failures of files that no longer exist are
1855
+ // forgotten first, so the set only ever holds real, still-present targets.
1856
+ function pendingRetries(failures, listing, nowMs) {
1857
+ forgetVanished(failures, new Set(listing.files.map((entry) => entry.file.name)));
1858
+ return new Set([...failures.entries()].filter(([, retryAtMs]) => retryAtMs > nowMs).map(([name]) => name));
1859
+ }
1860
+ function applyRetention(active, cursor, nowMs, reserveBytes) {
1861
+ const listing = listActivityLogDirectory(active.directory);
1862
+ const reads = readActivityLogPins(listing, active.trustedRoot);
1863
+ const removedPins = expireActivityLogPins(active, cursor, listing, reads, nowMs);
1864
+ const pins = activeActivityLogPins(reads, nowMs);
1865
+ queueQuotaEvidence(active, cursor, planActivityLogPinProtection(listing.files, pins, active.config.pinQuotaBytes), pins.length);
1866
+ const outcome = applyActivityLogRetention({
1867
+ files: listing.files,
1868
+ pins,
1869
+ pinRecordBytes: remainingPinRecordBytes(reads, removedPins),
1870
+ config: active.config,
1871
+ nowMs,
1872
+ reserveBytes,
1873
+ skipNames: pendingRetries(active.failedDeletions, listing, nowMs),
1874
+ ownInstanceId: INSTANCE_ID,
1875
+ }, (entry) => removeRetentionTarget(active, entry));
1876
+ const firstFailures = outcome.failedNames.filter((name) => recordMutationFailure(active.failedDeletions, name, nowMs)).length;
1877
+ queueRetentionEvidence(active, cursor, outcome, firstFailures);
1878
+ queuePressureTransition(active, cursor, outcome);
1879
+ return outcome;
1880
+ }
1881
+ // Runs before every new segment: recover orphans, expire pins, apply retention with the new
1882
+ // segment's reservation, and report quota and pressure. Returns whether the reservation fits.
1883
+ function runMaintenance(active, cursor, reserveBytes) {
1884
+ // Never list, recover, or prune through a redirected directory: a symlink at the log path is
1885
+ // refused before one name behind it is read.
1886
+ if (!durableLogDirectory(active.directory)) {
1887
+ throw new SafeArtifactFileError("activity-log", "unsafe-ancestor");
1888
+ }
1889
+ refreshGovernedPolicy(active, cursor.correlationId);
1890
+ const nowMs = Date.now();
1891
+ recoverOrphanedSegments(active, cursor, listActivityLogDirectory(active.directory), nowMs);
1892
+ return applyRetention(active, cursor, nowMs, reserveBytes).admitted;
1893
+ }
1894
+ // ─── Segment lifecycle ─────────────────────────────────────────────────────────────────────────
1895
+ function nextSegmentIdentity(active) {
1896
+ // Monotonic per instance even when the wall clock steps backwards, so an instance's segments
1897
+ // never sort out of index order.
1898
+ const startMs = Math.max(Date.now(), active.lastStartMs);
1899
+ active.lastStartMs = startMs;
1900
+ const index = active.nextIndex;
1901
+ active.nextIndex += 1;
1902
+ return { startMs, pid: process.pid, instanceId: INSTANCE_ID, index };
1903
+ }
1904
+ function installSegment(active, identity, handle, cursor) {
1905
+ const activeName = activityLogSegmentFileName(identity, "active");
1906
+ const segment = {
1907
+ identity,
1908
+ segmentId: formatActivityLogSegmentId(identity),
1909
+ activeName,
1910
+ activePath: join(active.directory, activeName),
1911
+ sealedPath: sealedTwinPath(active, identity),
1912
+ wallStartMs: Date.now(),
1913
+ monotonicStartMs: performance.now(),
1914
+ handle,
1915
+ firstSeq: undefined,
1916
+ lastSeq: undefined,
1917
+ lineCount: 0,
1918
+ droppedEvents: 0,
1919
+ };
1920
+ active.segment = segment;
1921
+ active.pendingNewline = false;
1922
+ // The segment's first line is its own safe-open evidence, ahead of any queued maintenance record.
1923
+ active.pendingEvidence.unshift({
1924
+ event: safeOpenEvidence(cursor.correlationId),
1925
+ capability: "active",
1926
+ });
1927
+ startSealTimer(active);
1928
+ return segment;
1929
+ }
1930
+ function admissionBlocked(active, nowMs) {
1931
+ return active.blocked.has("budget-exceeded") && nowMs < active.admissionRetryAtMs;
1932
+ }
1933
+ function admitNewSegment(active, cursor) {
1934
+ const nowMs = Date.now();
1935
+ if (admissionBlocked(active, nowMs))
1936
+ throw new ActivityLogBudgetError();
1937
+ if (runMaintenance(active, cursor, active.config.segmentBytes))
1938
+ return;
1939
+ active.admissionRetryAtMs = nowMs + ADMISSION_RETRY_MS;
1940
+ throw new ActivityLogBudgetError();
1941
+ }
1942
+ // Creates the next segment's file under its active name, empty and not yet installed.
1943
+ function createSegmentHandle(active) {
1944
+ for (let attempt = 0; attempt < 3; attempt += 1) {
1945
+ const identity = nextSegmentIdentity(active);
1946
+ const path = join(active.directory, activityLogSegmentFileName(identity, "active"));
1947
+ try {
1948
+ const handle = openSafeArtifactFile(path, {
1949
+ artifactClass: "activity-log",
1950
+ mode: "exclusive-create",
1951
+ trustedRoot: active.trustedRoot,
1952
+ });
1953
+ return { identity, handle };
1954
+ }
1955
+ catch (error) {
1956
+ // Only a leftover of this very instance can own the name; skip to the next index.
1957
+ if (!(error instanceof SafeArtifactFileError) || error.kind !== "target-exists")
1958
+ throw error;
1959
+ }
1960
+ }
1961
+ throw new SafeArtifactFileError("activity-log", "target-exists");
1962
+ }
1963
+ function createSegmentFile(active, cursor) {
1964
+ const created = createSegmentHandle(active);
1965
+ return installSegment(active, created.identity, created.handle, cursor);
1966
+ }
1967
+ // Gives back a segment whose admission a concurrent process invalidated. It is still empty, so the
1968
+ // store never held more bytes than its budget; its queued safe-open line is withdrawn with it.
1969
+ function withdrawSegment(active, segment, safeOpen) {
1970
+ abandonSegment(active);
1971
+ const queued = active.pendingEvidence.indexOf(safeOpen);
1972
+ if (queued >= 0)
1973
+ active.pendingEvidence.splice(queued, 1);
1974
+ try {
1975
+ removeActivityLogFile(segment.activePath, active.trustedRoot);
1976
+ }
1977
+ catch {
1978
+ // Left in place, it is this process's own abandoned segment and the next maintenance seals it.
1979
+ }
1980
+ }
1981
+ // The re-check once a new segment exists: it sees every peer's new segment, and this one, at its
1982
+ // full reservation and prunes further or withdraws this still empty segment, so the bytes on disk
1983
+ // never exceed the budget.
1984
+ // A re-check that throws (a redirected directory, a failed listing) admitted nothing either: the
1985
+ // still empty segment is withdrawn before the error propagates, so no later write lands in a
1986
+ // segment whose reservation was never confirmed (#3557 review).
1987
+ function confirmAdmission(active, cursor, segment) {
1988
+ const safeOpen = active.pendingEvidence[0];
1989
+ let admitted;
1990
+ try {
1991
+ admitted = runMaintenance(active, cursor, 0);
1992
+ }
1993
+ catch (error) {
1994
+ if (safeOpen !== undefined)
1995
+ withdrawSegment(active, segment, safeOpen);
1996
+ throw error;
1997
+ }
1998
+ if (admitted)
1999
+ return;
2000
+ if (safeOpen !== undefined)
2001
+ withdrawSegment(active, segment, safeOpen);
2002
+ active.admissionRetryAtMs = Date.now() + ADMISSION_RETRY_MS;
2003
+ throw new ActivityLogBudgetError();
2004
+ }
2005
+ // Admission is checked before the exclusive create and again after it: two processes can observe
2006
+ // the same free reservation, but only while their new segments are still empty.
2007
+ function openSegment(active, cursor) {
2008
+ admitNewSegment(active, cursor);
2009
+ const segment = createSegmentFile(active, cursor);
2010
+ confirmAdmission(active, cursor, segment);
2011
+ return segment;
2012
+ }
2013
+ // Replaces a full or expired segment make-before-break (#3557): the next segment's file exists
2014
+ // before the full one gives up its active name, so a process that keeps writing always holds an
2015
+ // active segment. That file is the one sign of a live writer a starting peer can see when it decides
2016
+ // whether it may replace the store's governing policy (`isSoleActivityLogWriter`); sealing first and
2017
+ // opening only after a maintenance pass left a busy writer invisible for that whole pass. The new
2018
+ // file stays empty until the re-check admits it, so the byte bound is unchanged.
2019
+ function rotateSegment(active, cursor, reason) {
2020
+ let next;
2021
+ try {
2022
+ if (!admissionBlocked(active, Date.now()))
2023
+ next = createSegmentHandle(active);
2024
+ }
2025
+ finally {
2026
+ // Sealed whether or not the next segment could be created, exactly as before.
2027
+ sealSegment(active, cursor, reason);
2028
+ }
2029
+ if (next === undefined)
2030
+ throw new ActivityLogBudgetError();
2031
+ confirmAdmission(active, cursor, installSegment(active, next.identity, next.handle, cursor));
2032
+ }
2033
+ function ensureSegment(active, cursor) {
2034
+ const current = active.segment;
2035
+ if (current !== undefined) {
2036
+ const sizeBytes = currentSegmentSize(current);
2037
+ if (sizeBytes !== undefined)
2038
+ return { segment: current, sizeBytes };
2039
+ abandonSegment(active);
2040
+ }
2041
+ const segment = openSegment(active, cursor);
2042
+ return { segment, sizeBytes: currentSegmentSize(segment) ?? 0 };
2043
+ }
2044
+ function restrictSealedMode(handle) {
2045
+ try {
2046
+ fchmodSync(handle, SEALED_SEGMENT_MODE);
2047
+ }
2048
+ catch {
2049
+ // The sealed segment stays owner-private (0600); it is still never opened for writing again.
2050
+ }
2051
+ }
2052
+ function descriptorAtPath(handle, path) {
2053
+ try {
2054
+ const opened = fstatSync(handle);
2055
+ const pathname = lstatSync(path);
2056
+ return pathname.isFile() && opened.dev === pathname.dev && opened.ino === pathname.ino;
2057
+ }
2058
+ catch {
2059
+ return false;
2060
+ }
2061
+ }
2062
+ function writeSealLine(active, segment, handle, cursor, reason) {
2063
+ const segmentBytes = currentSegmentSize(segment);
2064
+ if (segmentBytes === undefined)
2065
+ throw new SafeArtifactFileError("activity-log", "target-mutated");
2066
+ const identity = nextIdentity(cursor, "active");
2067
+ const facts = {
2068
+ reason,
2069
+ seq: identity.seq,
2070
+ segmentBytes,
2071
+ correlationId: cursor.correlationId,
2072
+ };
2073
+ const event = segmentSealedEvidence(segment, facts, active.config);
2074
+ writeRecord(active, handle, formatRegisteredServerLogLine(event, new Date(), identity));
2075
+ noteSegmentLine(segment, identity.seq);
2076
+ }
2077
+ function publishSealedSegment(active, segment, handle) {
2078
+ fsyncSync(handle);
2079
+ archiveSafeArtifactFile(segment.activePath, segment.sealedPath, archiveOptions(active));
2080
+ if (!descriptorAtPath(handle, segment.sealedPath)) {
2081
+ throw new SafeArtifactFileError("activity-log", "target-mutated");
2082
+ }
2083
+ // Applied after the rename: on Windows the read-only attribute would otherwise follow the inode
2084
+ // into the unlink of the active name.
2085
+ restrictSealedMode(handle);
2086
+ }
2087
+ // Seals the active segment: a final registered seal line, fsync, the guarded rename that drops
2088
+ // `.active`, then read-only mode. On any failure the file keeps its active name and this process's
2089
+ // next maintenance pass seals it as its own abandoned segment; the writer never appends to it again.
2090
+ function sealSegment(active, cursor, reason) {
2091
+ const segment = active.segment;
2092
+ if (segment === undefined)
2093
+ return;
2094
+ active.segment = undefined;
2095
+ stopSealTimer(active);
2096
+ const handle = segment.handle;
2097
+ let sealLineWritten = false;
2098
+ try {
2099
+ if (handle === null)
2100
+ throw new SafeArtifactFileError("activity-log", "target-mutated");
2101
+ writeSealLine(active, segment, handle, cursor, reason);
2102
+ sealLineWritten = true;
2103
+ publishSealedSegment(active, segment, handle);
2104
+ }
2105
+ catch (error) {
2106
+ // A seal line already on disk is not lost: recovery completes the interrupted seal later.
2107
+ if (!sealLineWritten)
2108
+ recordPersistenceLoss(error);
2109
+ reportServerLogFailure(error, {
2110
+ op: ACTIVITY_LOG_SEGMENT_SEALED_OPERATION.op,
2111
+ correlationId: cursor.correlationId,
2112
+ loss: sealLineWritten ? "event-location-unknown" : "event-dropped",
2113
+ });
2114
+ }
2115
+ finally {
2116
+ segment.handle = null;
2117
+ if (handle !== null)
2118
+ closeQuietly(handle);
2119
+ active.pendingNewline = false;
2120
+ }
2121
+ }
2122
+ function segmentExpiryReason(segment, config) {
2123
+ const wallElapsed = Date.now() - segment.wallStartMs;
2124
+ if (wallElapsed < -CLOCK_TOLERANCE_MS)
2125
+ return "clock-change";
2126
+ const elapsed = Math.max(wallElapsed, performance.now() - segment.monotonicStartMs);
2127
+ return elapsed >= config.segmentSeconds * 1000 ? "age-limit" : undefined;
2128
+ }
2129
+ function sealIfExpired(active, cursor) {
2130
+ const segment = active.segment;
2131
+ if (segment === undefined)
2132
+ return;
2133
+ const reason = segmentExpiryReason(segment, active.config);
2134
+ if (reason !== undefined)
2135
+ sealSegment(active, cursor, reason);
2136
+ }
2137
+ function persistPostWriteMutation(active, event, cursor) {
2138
+ abandonSegment(active);
2139
+ queueEvidence(active, mutationEvidence(event));
2140
+ try {
2141
+ writeQueued(active, cursor, undefined);
2142
+ }
2143
+ catch {
2144
+ // The caller reports the event whose location is unknown; the evidence stays queued.
2145
+ }
2146
+ }
2147
+ // Appends `record` when it fits below the byte bound with room for the seal line; returns the bytes
2148
+ // it added, or 0 when the segment must be sealed first. The line is formatted once with the
2149
+ // identity it will carry: nothing can claim a `seq` between measuring and writing it.
2150
+ function appendIfFits(active, open, cursor, record) {
2151
+ const identity = peekIdentity(cursor, record.capability);
2152
+ const line = formatEventLine(record.event, undefined, identity);
2153
+ const bytes = serverLogLineBytes(line) + (active.pendingNewline ? 1 : 0);
2154
+ if (open.sizeBytes + bytes + SEQ_GROWTH_MARGIN_BYTES + SEAL_RESERVE_BYTES >
2155
+ active.config.segmentBytes) {
2156
+ return 0;
2157
+ }
2158
+ const claimed = nextIdentity(cursor, record.capability);
2159
+ const handle = open.segment.handle;
2160
+ if (handle === null)
2161
+ throw new SafeArtifactFileError("activity-log", "target-mutated");
2162
+ writeRecord(active, handle, claimed.seq === identity.seq ? line : formatEventLine(record.event, undefined, claimed));
2163
+ noteSegmentLine(open.segment, claimed.seq);
2164
+ if (currentSegmentSize(open.segment) === undefined) {
2165
+ persistPostWriteMutation(active, record.event, cursor);
2166
+ throw new PostWriteMutationError();
2167
+ }
2168
+ return bytes;
2169
+ }
2170
+ // Order inside one segment: queued storage evidence (safe-open first), then the loss a blocking
2171
+ // condition caused while writing was impossible, then the caller's own record. A blocking count is
2172
+ // cleared only once its line is on disk, so a still-full disk accumulates one exact count instead of
2173
+ // queueing a line per failed attempt.
2174
+ function nextRecord(active, cursor, caller) {
2175
+ const queued = active.pendingEvidence[0];
2176
+ if (queued !== undefined)
2177
+ return { kind: "queued", record: queued };
2178
+ const blocked = [...active.blocked.entries()][0];
2179
+ if (blocked !== undefined) {
2180
+ const [state, droppedEventCount] = blocked;
2181
+ const event = pressureEvidence({ state, droppedEventCount }, active.config, cursor.correlationId);
2182
+ return { kind: "blocked", state, record: { event, capability: "degraded" } };
2183
+ }
2184
+ return caller === undefined
2185
+ ? undefined
2186
+ : { kind: "caller", record: { event: caller, capability: "active" } };
2187
+ }
2188
+ function consumeRecord(active, source) {
2189
+ if (source.kind === "queued")
2190
+ active.pendingEvidence.shift();
2191
+ else if (source.kind === "blocked")
2192
+ active.blocked.delete(source.state);
2193
+ }
2194
+ function placeRecord(active, open, cursor, source) {
2195
+ let bytes;
2196
+ try {
2197
+ bytes = appendIfFits(active, open, cursor, source.record);
2198
+ }
2199
+ catch (error) {
2200
+ if (source.kind === "caller" || !(error instanceof ActivityLogEventValidationError))
2201
+ throw error;
2202
+ // A storage-evidence record the registry rejects is dropped and reported; it must never block
2203
+ // every later write behind it.
2204
+ consumeRecord(active, source);
2205
+ recordActivityLogLoss("schema-rejected");
2206
+ reportServerLogFailure(error, { op: source.record.event.op, loss: "event-dropped" });
2207
+ return { status: "skipped" };
2208
+ }
2209
+ if (bytes === 0)
2210
+ return { status: "full" };
2211
+ consumeRecord(active, source);
2212
+ return { status: "placed", bytes };
2213
+ }
2214
+ function rollOver(active, cursor, rollovers) {
2215
+ if (rollovers >= MAX_ROLLOVERS_PER_WRITE)
2216
+ throw new ActivityLogBackpressureError();
2217
+ rotateSegment(active, cursor, "size-limit");
2218
+ return rollovers + 1;
2219
+ }
2220
+ // Writes every queued evidence record and blocking-loss count, then `caller`, rolling over to a new
2221
+ // segment whenever the next record would pass the byte bound. Bounded: a write that cannot be placed
2222
+ // after a handful of rollovers is dropped and reported rather than looping.
2223
+ function writeQueued(active, cursor, caller) {
2224
+ let pendingCaller = caller;
2225
+ let rollovers = 0;
2226
+ let open;
2227
+ for (;;) {
2228
+ open ??= ensureSegment(active, cursor);
2229
+ const source = nextRecord(active, cursor, pendingCaller);
2230
+ if (source === undefined)
2231
+ return;
2232
+ const placement = placeRecord(active, open, cursor, source);
2233
+ if (placement.status === "full") {
2234
+ rollovers = rollOver(active, cursor, rollovers);
2235
+ open = undefined;
2236
+ continue;
2237
+ }
2238
+ if (placement.status === "placed") {
2239
+ open = { segment: open.segment, sizeBytes: open.sizeBytes + placement.bytes };
2240
+ }
2241
+ if (source.kind === "caller")
2242
+ pendingCaller = undefined;
2243
+ }
2244
+ }
2245
+ function blockingPressure(error) {
2246
+ if (error instanceof ActivityLogDiskFullError)
2247
+ return "disk-full";
2248
+ if (error instanceof ActivityLogBackpressureError)
2249
+ return "backpressure";
2250
+ return error instanceof ActivityLogBudgetError ? "budget-exceeded" : undefined;
2251
+ }
2252
+ // Counts lost events in the process-wide loss ledger (#3532) that the loss summary and readiness
2253
+ // read: a registry rejection as schema-rejected, every other failure as persistence-failed.
2254
+ function recordPersistenceLoss(error, count = 1) {
2255
+ recordActivityLogLoss(error instanceof ActivityLogEventValidationError ? "schema-rejected" : "persistence-failed", count);
2256
+ }
2257
+ function recordDroppedEvent(active, error) {
2258
+ recordPersistenceLoss(error);
2259
+ if (active.segment !== undefined)
2260
+ active.segment.droppedEvents += 1;
2261
+ const state = blockingPressure(error);
2262
+ if (state === undefined)
2263
+ return;
2264
+ active.blocked.set(state, (active.blocked.get(state) ?? 0) + 1);
2265
+ }
2266
+ // A write rotates an expired segment make-before-break; only the idle-segment timer seals one
2267
+ // without opening the next.
2268
+ function rotateIfExpired(active, cursor) {
2269
+ const segment = active.segment;
2270
+ if (segment === undefined)
2271
+ return;
2272
+ const reason = segmentExpiryReason(segment, active.config);
2273
+ if (reason !== undefined)
2274
+ rotateSegment(active, cursor, reason);
2275
+ }
2276
+ function persistCallerEvent(active, event, cursor) {
2277
+ rotateIfExpired(active, cursor);
2278
+ writeQueued(active, cursor, event);
2279
+ }
2280
+ function closeActiveLog(active) {
2281
+ const cursor = { claimed: undefined, correlationId: undefined };
2282
+ if (active.pendingEvidence.length > 0 || active.blocked.size > 0) {
2283
+ try {
2284
+ writeQueued(active, cursor, undefined);
2285
+ }
2286
+ catch (error) {
2287
+ // Nothing can be persisted for this directory now; the loss is reported once, not retried at
2288
+ // every later close. Each queued record and each blocked-loss line is one lost event.
2289
+ recordPersistenceLoss(error, active.pendingEvidence.length + active.blocked.size);
2290
+ active.pendingEvidence.length = 0;
2291
+ active.blocked.clear();
2292
+ reportServerLogFailure(error, {
2293
+ op: SERVER_LOG_SAFE_OPEN_OPERATION.op,
2294
+ loss: "event-dropped",
2295
+ });
2296
+ }
2297
+ }
2298
+ sealSegment(active, cursor, "close");
2299
+ }
2300
+ // Seals every open Activity Log segment. Called by the server logger's shutdown/reset path, and by
2301
+ // tests so a suite does not leave descriptors behind. A subsequent write opens a new segment:
2302
+ // closing releases an OS resource and completes a segment, it never disables the log.
2303
+ //
2304
+ // The registry entries themselves are KEPT so a sink created after a shutdown shares the same
2305
+ // per-directory state (segment index, pressure, failure memory) instead of building a second one.
2306
+ export function closeFileServerLogSinks() {
2307
+ for (const active of activeLogs.values())
2308
+ closeActiveLog(active);
2309
+ }
2310
+ export function createFileServerLogSink(stateDir, options = {}) {
2311
+ const directory = join(stateDir, "logs");
2312
+ try {
2313
+ mkdirSync(directory, { recursive: true, mode: 0o700 });
2314
+ }
2315
+ catch {
2316
+ // A configured production Activity Log is mandatory reconstruction evidence. Returning the
2317
+ // null sink here made startup appear healthy while every later operation was silently
2318
+ // unevidenced. Fail with the existing closed filesystem classification instead; callers that
2319
+ // intentionally need no persistence must choose nullServerLogSink() explicitly.
2320
+ throw new SafeArtifactFileError("activity-log", "open-failed");
2321
+ }
2322
+ const env = options.env ?? process.env;
2323
+ const active = resolveActiveLog(directory, resolveActivityLogStorageConfig(env));
2324
+ const threshold = options.level ?? resolveServerLogThreshold(env);
2325
+ return createFileSinkFacade(active, threshold, stateDir);
2326
+ }
2327
+ function failureLoss(error) {
2328
+ return error instanceof PostWriteMutationError ? "event-location-unknown" : "event-dropped";
2329
+ }
2330
+ // Split out so `createFileServerLogSink` stays inside the 50-line ceiling.
2331
+ function createFileSinkFacade(active, threshold, stateDir) {
2332
+ return {
2333
+ write(event) {
2334
+ // The threshold check comes before any formatting: a filtered event costs one comparison.
2335
+ if (!serverLogLevelEnabled(eventLevel(event), threshold))
2336
+ return;
2337
+ ensureGovernedPolicy(active, event.correlationId);
2338
+ const identity = allocateServerLogIdentity();
2339
+ try {
2340
+ persistCallerEvent(active, event, {
2341
+ claimed: identity,
2342
+ correlationId: event.correlationId,
2343
+ });
2344
+ }
2345
+ catch (error) {
2346
+ // Writing must never take the server down; a full disk, an exhausted budget or a file
2347
+ // removed under us drops the line. It does NOT drop the fact that it happened: a log that
2348
+ // has stopped working is exactly the condition an operator cannot infer from the absence
2349
+ // of lines, so the loss is counted for the next persisted pressure line and announced on
2350
+ // the independent stderr channel now.
2351
+ recordDroppedEvent(active, error);
2352
+ reportServerLogFailure(error, {
2353
+ op: event.op,
2354
+ correlationId: event.correlationId,
2355
+ identity,
2356
+ loss: failureLoss(error),
2357
+ });
2358
+ return;
2359
+ }
2360
+ // #3533: a persisted, eligible failure becomes a local incident candidate. Never throws; a
2361
+ // dropped line (above) never triggers, so a failing store cannot amplify its own failure.
2362
+ observeSupportIncidentTrigger(stateDir, event);
2363
+ },
2364
+ flush() {
2365
+ // `writeSync` leaves nothing in user space, so a flush is already complete on return.
2366
+ },
2367
+ close() {
2368
+ // The segment belongs to the shared per-directory store, so this seals it for every sink on
2369
+ // the directory. That is correct for a shutdown path and harmless otherwise: the next write
2370
+ // opens a new segment.
2371
+ closeActiveLog(active);
2372
+ },
2373
+ };
2374
+ }
2375
+ function validPinRequest(request, nowMs) {
2376
+ const expiresAtMs = Reflect.get(request, "expiresAtMs");
2377
+ const reason = Reflect.get(request, "reason");
2378
+ return (isActivityLogPinScope(Reflect.get(request, "scope")) &&
2379
+ typeof expiresAtMs === "number" &&
2380
+ Number.isSafeInteger(expiresAtMs) &&
2381
+ expiresAtMs > nowMs &&
2382
+ expiresAtMs - nowMs <= MAX_ACTIVITY_LOG_PIN_DURATION_MS &&
2383
+ (reason === undefined || reason === "incident" || reason === "durable-batch"));
2384
+ }
2385
+ function copyPinScope(scope) {
2386
+ return scope.kind === "window"
2387
+ ? { kind: "window", fromMs: scope.fromMs, toMs: scope.toMs }
2388
+ : { kind: "segments", segmentIds: [...scope.segmentIds] };
2389
+ }
2390
+ function rejectedPin(request, reason, scope) {
2391
+ return {
2392
+ result: { status: "rejected", reason },
2393
+ facts: {
2394
+ pinId: undefined,
2395
+ status: "rejected",
2396
+ rejectionReason: reason,
2397
+ scope,
2398
+ reason: request.reason === "durable-batch" ? "durable-batch" : "incident",
2399
+ pinnedSegmentCount: 0,
2400
+ pinnedBytes: 0,
2401
+ expiresInSeconds: 0,
2402
+ quotaStatus: undefined,
2403
+ },
2404
+ };
2405
+ }
2406
+ // The pin API is reachable from a sink's own write path, which never throws, so a directory that
2407
+ // cannot be listed (EACCES, EMFILE, …) becomes a closed outcome here instead of an exception.
2408
+ function listingOrUndefined(directory) {
2409
+ try {
2410
+ return listActivityLogDirectory(directory);
2411
+ }
2412
+ catch {
2413
+ return undefined;
2414
+ }
2415
+ }
2416
+ function pinOutcome(active, record, nowMs, preSealListing) {
2417
+ // The record is already published, so a listing that fails after the seal still reports the pin,
2418
+ // from the listing taken before it.
2419
+ const listing = listingOrUndefined(active.directory) ?? preSealListing;
2420
+ const reads = readActivityLogPins(listing, active.trustedRoot);
2421
+ const protection = planActivityLogPinProtection(listing.files, activeActivityLogPins(reads, nowMs), active.config.pinQuotaBytes);
2422
+ const covered = listing.files.filter((entry) => entry.file.kind === "sealed" &&
2423
+ isActivityLogSegmentEntry(entry) &&
2424
+ activityLogPinCovers(record, entry));
2425
+ const quotaStatus = covered.every((entry) => protection.protectedNames.has(entry.file.name))
2426
+ ? "within-quota"
2427
+ : "exceeded";
2428
+ const pinnedBytes = covered.reduce((sum, entry) => sum + entry.sizeBytes, 0);
2429
+ return {
2430
+ result: {
2431
+ status: "pinned",
2432
+ pinId: record.pinId,
2433
+ pinnedSegmentCount: covered.length,
2434
+ pinnedBytes,
2435
+ quotaStatus,
2436
+ },
2437
+ facts: {
2438
+ pinId: record.pinId,
2439
+ status: "created",
2440
+ rejectionReason: undefined,
2441
+ scope: record.scope,
2442
+ reason: record.reason,
2443
+ pinnedSegmentCount: covered.length,
2444
+ pinnedBytes,
2445
+ expiresInSeconds: Math.ceil((record.expiresAtMs - nowMs) / 1000),
2446
+ quotaStatus,
2447
+ },
2448
+ };
2449
+ }
2450
+ function createPin(active, request, cursor, nowMs) {
2451
+ if (!validPinRequest(request, nowMs))
2452
+ return rejectedPin(request, "invalid-request", undefined);
2453
+ const scope = copyPinScope(request.scope);
2454
+ const listing = listingOrUndefined(active.directory);
2455
+ if (listing === undefined)
2456
+ return rejectedPin(request, "storage-unavailable", scope);
2457
+ const pins = activeActivityLogPins(readActivityLogPins(listing, active.trustedRoot), nowMs);
2458
+ if (pins.length >= MAX_ACTIVITY_LOG_PINS)
2459
+ return rejectedPin(request, "pin-limit-reached", scope);
2460
+ const record = {
2461
+ schemaVersion: 1,
2462
+ pinId: randomBytes(12).toString("hex"),
2463
+ reason: request.reason ?? "incident",
2464
+ createdAtMs: nowMs,
2465
+ expiresAtMs: request.expiresAtMs,
2466
+ scope,
2467
+ };
2468
+ try {
2469
+ // Published before the seal, so the retention pass the next segment runs already honors it.
2470
+ writeActivityLogPinRecord(active.directory, active.trustedRoot, record);
2471
+ }
2472
+ catch {
2473
+ return rejectedPin(request, "storage-unavailable", scope);
2474
+ }
2475
+ sealSegment(active, cursor, "pin-request");
2476
+ return pinOutcome(active, record, nowMs, listing);
2477
+ }
2478
+ function storeForStateDir(stateDir, env) {
2479
+ const directory = join(stateDir, "logs");
2480
+ mkdirSync(directory, { recursive: true, mode: 0o700 });
2481
+ return resolveGovernedActiveLog(directory, env);
2482
+ }
2483
+ function persistPinLine(active, cursor, op, build) {
2484
+ let queued = false;
2485
+ try {
2486
+ queueEvidence(active, build());
2487
+ queued = true;
2488
+ writeQueued(active, cursor, undefined);
2489
+ }
2490
+ catch (error) {
2491
+ // Queued evidence survives a failed write: the next write persists it, and a close that still
2492
+ // cannot write counts and reports it as lost. Only evidence that never reached the queue is lost.
2493
+ if (queued)
2494
+ return;
2495
+ recordPersistenceLoss(error);
2496
+ reportServerLogFailure(error, {
2497
+ op,
2498
+ correlationId: cursor.correlationId,
2499
+ loss: failureLoss(error),
2500
+ });
2501
+ }
2502
+ }
2503
+ function persistPinEvidence(active, cursor, facts) {
2504
+ persistPinLine(active, cursor, ACTIVITY_LOG_PIN_CREATED_OPERATION.op, () => pinCreatedEvidence(facts, cursor.correlationId));
2505
+ }
2506
+ /**
2507
+ * Pins a bounded time window (across every process instance, including segments sealed later
2508
+ * inside it) or an explicit set of segments against retention until `expiresAtMs`. Seals this
2509
+ * process's active segment, publishes one closed-grammar pin record, and evidences the request.
2510
+ * Pinned segments are protected only within the reserved pin quota; a pin the quota cannot hold is
2511
+ * still recorded, reports `quotaStatus: "exceeded"`, and produces one quota-exhaustion loss marker.
2512
+ */
2513
+ export function pinActivityLogWindow(stateDir, request, env = process.env) {
2514
+ let active;
2515
+ try {
2516
+ active = storeForStateDir(stateDir, env);
2517
+ }
2518
+ catch (error) {
2519
+ recordActivityLogLoss("persistence-failed");
2520
+ reportServerLogFailure(error, {
2521
+ op: ACTIVITY_LOG_PIN_CREATED_OPERATION.op,
2522
+ correlationId: request.correlationId,
2523
+ loss: "event-dropped",
2524
+ });
2525
+ return { status: "rejected", reason: "storage-unavailable" };
2526
+ }
2527
+ const cursor = { claimed: undefined, correlationId: request.correlationId };
2528
+ const attempt = createPin(active, request, cursor, Date.now());
2529
+ persistPinEvidence(active, cursor, attempt.facts);
2530
+ return attempt.result;
2531
+ }
2532
+ function persistPinExpiry(active, cursor, facts) {
2533
+ persistPinLine(active, cursor, ACTIVITY_LOG_PIN_EXPIRED_OPERATION.op, () => pinExpiredEvidence(facts, cursor.correlationId));
2534
+ }
2535
+ function releaseFacts(pinId, removed, coverage) {
2536
+ return {
2537
+ pinId,
2538
+ reason: "released",
2539
+ removed,
2540
+ releasedSegmentCount: coverage.count,
2541
+ releasedBytes: coverage.bytes,
2542
+ };
2543
+ }
2544
+ function releaseListedPin(active, cursor, pinId) {
2545
+ const listing = listingOrUndefined(active.directory);
2546
+ if (listing === undefined) {
2547
+ persistPinExpiry(active, cursor, releaseFacts(pinId, false, { count: 0, bytes: 0 }));
2548
+ return { status: "rejected", reason: "storage-unavailable" };
2549
+ }
2550
+ const read = readActivityLogPins(listing, active.trustedRoot).find((candidate) => candidate.entry.pinId === pinId);
2551
+ if (read === undefined)
2552
+ return { status: "rejected", reason: "not-found" };
2553
+ const coverage = pinCoverage(read.record, listing.files);
2554
+ const removed = removePinRecordQuietly(active, read);
2555
+ persistPinExpiry(active, cursor, releaseFacts(pinId, removed, coverage));
2556
+ return removed
2557
+ ? { status: "released", releasedSegmentCount: coverage.count, releasedBytes: coverage.bytes }
2558
+ : { status: "rejected", reason: "removal-failed" };
2559
+ }
2560
+ /**
2561
+ * Releases one retention pin before its expiry, for example once the incident it protected was
2562
+ * reported or dismissed (#3533). The closed-grammar record is removed through the guarded,
2563
+ * identity-bound unlink and evidenced as `activity-log.pin.expired` with `expiryReason:
2564
+ * "released"`; the segments it protected return to normal retention. Never throws: an unknown pin
2565
+ * is `not-found`, and an unlistable directory or a failed removal is a closed, evidenced rejection.
2566
+ */
2567
+ export function releaseActivityLogPin(stateDir, request, env = process.env) {
2568
+ if (!isActivityLogPinId(Reflect.get(request, "pinId"))) {
2569
+ return { status: "rejected", reason: "invalid-request" };
2570
+ }
2571
+ let active;
2572
+ try {
2573
+ active = storeForStateDir(stateDir, env);
2574
+ }
2575
+ catch (error) {
2576
+ recordActivityLogLoss("persistence-failed");
2577
+ reportServerLogFailure(error, {
2578
+ op: ACTIVITY_LOG_PIN_EXPIRED_OPERATION.op,
2579
+ correlationId: request.correlationId,
2580
+ loss: "event-dropped",
2581
+ });
2582
+ return { status: "rejected", reason: "storage-unavailable" };
2583
+ }
2584
+ const cursor = { claimed: undefined, correlationId: request.correlationId };
2585
+ return releaseListedPin(active, cursor, request.pinId);
2586
+ }
2587
+ const PRESSURE_SEVERITY = {
2588
+ none: "none",
2589
+ "low-disk-space": "elevated",
2590
+ "retention-blocked": "elevated",
2591
+ backpressure: "elevated",
2592
+ "disk-full": "critical",
2593
+ "budget-exceeded": "critical",
2594
+ };
2595
+ function ownedDirectory(path, requireOwnerOnly) {
2596
+ try {
2597
+ const stat = lstatSync(path);
2598
+ if (!stat.isDirectory() || stat.isSymbolicLink())
2599
+ return false;
2600
+ if (process.platform === "win32")
2601
+ return true;
2602
+ const owner = process.geteuid?.();
2603
+ if (owner === undefined || stat.uid !== owner)
2604
+ return false;
2605
+ return !requireOwnerOnly || (stat.mode & 0o777) === 0o700;
2606
+ }
2607
+ catch {
2608
+ return false;
2609
+ }
2610
+ }
2611
+ function storageWritable(stateDir, directory) {
2612
+ return pathMissing(directory) ? ownedDirectory(stateDir, false) : ownedDirectory(directory, true);
2613
+ }
2614
+ function orphanedSegmentCount(files, config, currentName) {
2615
+ const context = {
2616
+ pid: process.pid,
2617
+ instanceId: INSTANCE_ID,
2618
+ currentName,
2619
+ nowMs: Date.now(),
2620
+ segmentSeconds: config.segmentSeconds,
2621
+ isAlive: processIsAlive,
2622
+ };
2623
+ return files.filter((entry) => isActivityLogSegmentEntry(entry) && activityLogOrphanOwner(entry, context) !== undefined).length;
2624
+ }
2625
+ function derivedPressure(active, unprotectedBytes, config, freeBytes) {
2626
+ const blocked = active === undefined ? undefined : [...active.blocked.keys()][0];
2627
+ if (blocked !== undefined)
2628
+ return blocked;
2629
+ if (active?.standingPressure !== undefined)
2630
+ return active.standingPressure;
2631
+ if (unprotectedBytes > config.retentionBytes)
2632
+ return "budget-exceeded";
2633
+ return freeBytes !== undefined && freeBytes < activityLogLowDiskThresholdBytes(config)
2634
+ ? "low-disk-space"
2635
+ : "none";
2636
+ }
2637
+ function countKind(files, kinds) {
2638
+ return files.filter((entry) => kinds.has(entry.file.kind)).length;
2639
+ }
2640
+ function storageSnapshot(stateDir, directory, config) {
2641
+ const listing = listActivityLogDirectory(directory);
2642
+ const reads = readActivityLogPins(listing, directory);
2643
+ const protection = planActivityLogPinProtection(listing.files, activeActivityLogPins(reads, Date.now()), config.pinQuotaBytes);
2644
+ const pinRecordSize = reads.reduce((sum, read) => sum + read.entry.sizeBytes, 0);
2645
+ return {
2646
+ listing,
2647
+ usedBytes: listing.files.reduce((sum, entry) => sum + entry.sizeBytes, 0) + pinRecordSize,
2648
+ pinnedBytes: protection.protectedBytes,
2649
+ freeBytes: activityLogFreeBytes(pathMissing(directory) ? stateDir : directory),
2650
+ };
2651
+ }
2652
+ /**
2653
+ * A cheap, read-only snapshot of the Activity Log store: one directory listing, the small pin
2654
+ * records, and one `statfs`. Never creates, seals, or deletes anything.
2655
+ */
2656
+ // Read-only: never publishes or replaces the stored policy, only prefers it when present so a
2657
+ // probe run before this process has become a writer (e.g. `keiko status`) still reports the
2658
+ // governing budget instead of this process's own unreconciled env view.
2659
+ function peekGovernedStorageConfig(directory, env) {
2660
+ const envConfig = resolveActivityLogStorageConfig(env);
2661
+ const stored = readActivityLogPolicyRecord(directory, directory);
2662
+ return stored === undefined ? envConfig : applyGovernedPolicy(envConfig, stored);
2663
+ }
2664
+ export function activityLogStorageHealth(stateDir, env = process.env) {
2665
+ const directory = join(stateDir, "logs");
2666
+ const active = activeLogs.get(activeLogKey(directory));
2667
+ const config = active?.config ?? peekGovernedStorageConfig(directory, env);
2668
+ const snapshot = storageSnapshot(stateDir, directory, config);
2669
+ const writer = writerView(active);
2670
+ const files = snapshot.listing.files;
2671
+ const unprotectedBytes = snapshot.usedBytes - snapshot.pinnedBytes;
2672
+ const pressureState = derivedPressure(active, unprotectedBytes, config, snapshot.freeBytes);
2673
+ return {
2674
+ writable: storageWritable(stateDir, directory) && !writer.blocked,
2675
+ usedBytes: snapshot.usedBytes,
2676
+ budgetBytes: config.retentionBytes,
2677
+ pinQuotaBytes: config.pinQuotaBytes,
2678
+ pinnedBytes: snapshot.pinnedBytes,
2679
+ ...(snapshot.freeBytes === undefined ? {} : { freeBytes: snapshot.freeBytes }),
2680
+ activeSegments: countKind(files, new Set(["active"])),
2681
+ sealedSegments: countKind(files, new Set(["sealed"])),
2682
+ legacyFiles: countKind(files, new Set(["legacy-archive", "legacy-current"])),
2683
+ orphanedSegments: orphanedSegmentCount(files, config, writer.currentName),
2684
+ pressure: PRESSURE_SEVERITY[pressureState],
2685
+ pressureState,
2686
+ recoveredSegments: writer.recoveredSegments,
2687
+ };
2688
+ }
2689
+ function writerView(active) {
2690
+ if (active === undefined)
2691
+ return { blocked: false, currentName: undefined, recoveredSegments: 0 };
2692
+ return {
2693
+ blocked: active.blocked.size > 0,
2694
+ currentName: active.segment?.activeName,
2695
+ recoveredSegments: active.recoveredSegments,
2696
+ };
2697
+ }
2698
+ /**
2699
+ * Every Activity Log file of `stateDir` a reader reads, legacy and segmented, in logical-log order:
2700
+ * one name per segment, so a seal caught between its link and unlink is never read twice.
2701
+ */
2702
+ export function listActivityLogFiles(stateDir) {
2703
+ const entries = listActivityLogDirectory(join(stateDir, "logs")).files;
2704
+ const readable = new Set(readableActivityLogFileNames(entries.map((entry) => entry.file)));
2705
+ return entries
2706
+ .filter((entry) => readable.has(entry.file))
2707
+ .map((entry) => ({
2708
+ name: entry.file.name,
2709
+ path: entry.path,
2710
+ kind: entry.file.kind,
2711
+ sizeBytes: entry.sizeBytes,
2712
+ }));
2713
+ }
2714
+ function durableLogDirectory(directory) {
2715
+ try {
2716
+ const stat = lstatSync(directory);
2717
+ return stat.isDirectory() && !stat.isSymbolicLink();
2718
+ }
2719
+ catch {
2720
+ return false;
2721
+ }
2722
+ }
2723
+ function openLogDirectoryGuard(path) {
2724
+ const before = lstatSync(path);
2725
+ if (!before.isDirectory() || before.isSymbolicLink())
2726
+ return undefined;
2727
+ let handle;
2728
+ try {
2729
+ const directoryFlag = typeof constants.O_DIRECTORY === "number" ? constants.O_DIRECTORY : 0;
2730
+ const noFollowFlag = typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
2731
+ handle = openSync(path, constants.O_RDONLY | directoryFlag | noFollowFlag);
2732
+ return validateOpenedLogDirectory(path, before.dev, before.ino, handle);
2733
+ }
2734
+ catch {
2735
+ if (handle !== undefined)
2736
+ closeSync(handle);
2737
+ return windowsLogDirectoryGuard(path, before.dev, before.ino);
2738
+ }
2739
+ }
2740
+ function validateOpenedLogDirectory(path, dev, ino, handle) {
2741
+ const opened = fstatSync(handle);
588
2742
  const pathname = lstatSync(path);
589
2743
  if (!opened.isDirectory() ||
590
2744
  !pathname.isDirectory() ||
@@ -630,185 +2784,140 @@ function closeLogDirectoryGuards(guards) {
630
2784
  closeSync(guard.handle);
631
2785
  }
632
2786
  }
633
- function batchLines(events) {
634
- const lines = [];
635
- for (const event of events) {
636
- const seq = allocateServerLogSeq();
637
- const line = formatServerLogLine(event, undefined, {
638
- schemaVersion: SERVER_LOG_SCHEMA_VERSION,
639
- pid: process.pid,
640
- instanceId: INSTANCE_ID,
641
- seq,
642
- });
643
- if (Buffer.byteLength(line, "utf8") > MAX_LOG_LINE_BYTES)
644
- return undefined;
645
- lines.push(line);
2787
+ // Legacy files and segments pinned for durable batches: the only places a completed earlier batch
2788
+ // can live, and a set whose size is bounded by the legacy window and the pin quota.
2789
+ function durableBatchScope(active, nowMs) {
2790
+ const listing = listActivityLogDirectory(active.directory);
2791
+ const pinned = new Set();
2792
+ for (const pin of activeActivityLogPins(readActivityLogPins(listing, active.trustedRoot), nowMs)) {
2793
+ if (pin.reason !== "durable-batch" || pin.scope.kind !== "segments")
2794
+ continue;
2795
+ for (const segmentId of pin.scope.segmentIds)
2796
+ pinned.add(segmentId);
646
2797
  }
647
- return lines;
2798
+ return listing.files
2799
+ .filter((entry) => !isActivityLogSegmentEntry(entry) || pinned.has(entry.file.segmentId))
2800
+ .map((entry) => entry.file.name);
648
2801
  }
649
- function repairPendingRecord(active) {
650
- if (!active.pendingNewline)
651
- return true;
652
- const before = currentHandleIdentity(active);
653
- if (before === undefined || active.handle === null)
654
- return false;
655
- if (!writeBatchRecords(active, [""]))
656
- return false;
657
- if (!syncBatch(active))
658
- return false;
659
- return completedBatchMatches(active, before, before.size + 1);
660
- }
661
- function currentLogReadStillMatches(active, handle, expected, guards) {
662
- const after = trustedLogIdentity(fstatSync(handle));
663
- const pathname = pathLogIdentity(active.currentPath);
664
- const filesMatch = [after, pathname].every((identity) => identity !== undefined && sameLogIdentity(expected, identity));
665
- return filesMatch && guards.every(logDirectoryStillSame);
666
- }
667
- function currentLogHasDelimiter(active, expected, guards) {
668
- if (expected.size === 0)
669
- return true;
670
- let handle;
2802
+ // Formats every event once with a provisional identity before anything is written, so an invalid or
2803
+ // oversized event defers the whole batch instead of leaving half of it in the log.
2804
+ function batchIsWritable(events) {
671
2805
  try {
672
- const noFollowFlag = typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
673
- handle = openSync(active.currentPath, constants.O_RDONLY | constants.O_NONBLOCK | noFollowFlag);
674
- const before = trustedLogIdentity(fstatSync(handle));
675
- if (before === undefined || !sameLogIdentity(expected, before))
676
- return undefined;
677
- const last = Buffer.allocUnsafe(1);
678
- if (readSync(handle, last, 0, 1, expected.size - 1) !== 1)
679
- return undefined;
680
- if (!currentLogReadStillMatches(active, handle, expected, guards))
681
- return undefined;
682
- return last[0] === 0x0a;
2806
+ return events.every((event) => {
2807
+ const line = formatEventLine(event, undefined, {
2808
+ ...serverLogProcessIdentity(),
2809
+ seq: nextProcessSeq,
2810
+ });
2811
+ return serverLogLineWithinCap(line) && line.includes(`"op":"${redactLogLabel(event.op)}"`);
2812
+ });
683
2813
  }
684
2814
  catch {
685
- return undefined;
686
- }
687
- finally {
688
- if (handle !== undefined)
689
- closeSync(handle);
690
- }
691
- }
692
- function repairCurrentLogTail(active, initial, guards) {
693
- const terminated = currentLogHasDelimiter(active, initial, guards);
694
- if (terminated === undefined)
695
- return undefined;
696
- if (!terminated)
697
- active.pendingNewline = true;
698
- if (!repairPendingRecord(active))
699
- return undefined;
700
- const repaired = currentHandleIdentity(active);
701
- return repaired !== undefined && guards.every(logDirectoryStillSame) ? repaired : undefined;
702
- }
703
- function prepareDurableLog(stateDir, guards) {
704
- const stateGuard = openLogDirectoryGuard(stateDir);
705
- if (stateGuard === undefined)
706
- return undefined;
707
- guards.push(stateGuard);
708
- const directory = join(stateDir, "logs");
709
- mkdirSync(directory, { recursive: true, mode: 0o700 });
710
- if (!durableLogDirectory(directory))
711
- return undefined;
712
- const logGuard = openLogDirectoryGuard(directory);
713
- if (logGuard === undefined)
714
- return undefined;
715
- guards.push(logGuard);
716
- const active = resolveActiveLog(directory, DEFAULT_LOG_RETENTION_DAYS);
717
- rotateIfNeeded(active);
718
- let initial = openTrustedDurableHandle(active);
719
- if (initial === undefined || active.handle === null) {
720
- closeHandle(active);
721
- return undefined;
2815
+ return false;
722
2816
  }
723
- initial = repairCurrentLogTail(active, initial, guards);
724
- if (initial === undefined)
725
- return undefined;
726
- return { active, initial, directory };
727
- }
728
- function stableBeforeBatch(prepared, guards) {
729
- if (!guards.every(logDirectoryStillSame))
730
- return undefined;
731
- const current = currentHandleIdentity(prepared.active);
732
- return current !== undefined && sameLogIdentity(prepared.initial, current) ? current : undefined;
733
2817
  }
734
- function writeBatchRecords(active, lines) {
2818
+ function syncActiveSegment(active) {
2819
+ const handle = active.segment?.handle;
2820
+ if (handle === undefined || handle === null)
2821
+ return false;
735
2822
  try {
736
- if (active.handle === null)
737
- return false;
738
- for (const line of lines)
739
- writeRecord(active, active.handle, line);
2823
+ fsyncSync(handle);
740
2824
  return true;
741
2825
  }
742
2826
  catch {
743
- closeHandle(active);
744
2827
  return false;
745
2828
  }
746
2829
  }
747
- function syncBatch(active) {
748
- try {
749
- if (active.handle === null)
2830
+ function writeDurableEvents(active, events, segmentIds) {
2831
+ for (const event of events) {
2832
+ const cursor = { claimed: undefined, correlationId: event.correlationId };
2833
+ try {
2834
+ writeQueued(active, cursor, event);
2835
+ }
2836
+ catch (error) {
2837
+ recordDroppedEvent(active, error);
750
2838
  return false;
751
- fsyncSync(active.handle);
752
- return true;
753
- }
754
- catch {
755
- closeHandle(active);
756
- return false;
2839
+ }
2840
+ const segmentId = active.segment?.segmentId;
2841
+ if (segmentId !== undefined)
2842
+ segmentIds.add(segmentId);
757
2843
  }
2844
+ return true;
758
2845
  }
759
- function completedBatchMatches(active, before, expectedSize) {
760
- const completed = currentHandleIdentity(active);
761
- return (completed?.dev === before.dev && completed.ino === before.ino && completed.size === expectedSize);
2846
+ function pinDurableBatch(active, segmentIds, correlationId) {
2847
+ const cursor = { claimed: undefined, correlationId };
2848
+ const pinned = createPin(active, {
2849
+ scope: { kind: "segments", segmentIds: [...segmentIds] },
2850
+ expiresAtMs: Date.now() + MAX_ACTIVITY_LOG_PIN_DURATION_MS,
2851
+ reason: "durable-batch",
2852
+ }, cursor, Date.now());
2853
+ persistPinEvidence(active, cursor, pinned.facts);
2854
+ return pinned.result.status === "pinned";
762
2855
  }
763
- function appendInspectedBatch(prepared, inspection, before, guards, threshold) {
764
- if (inspection.events.some((event) => !serverLogLevelEnabled(eventLevel(event), threshold))) {
2856
+ function appendInspectedBatch(active, events, guards, options) {
2857
+ if (events.some((event) => !serverLogLevelEnabled(eventLevel(event), options.level))) {
765
2858
  return { status: "deferred", reason: "level-filtered" };
766
2859
  }
767
- const lines = batchLines(inspection.events);
768
- if (lines === undefined)
2860
+ if (events.length === 0)
2861
+ return { status: "appended", appendedCount: 0 };
2862
+ if (!batchIsWritable(events))
769
2863
  return { status: "deferred", reason: "append-failed" };
770
- const addedBytes = lines.reduce((total, line) => total + Buffer.byteLength(line, "utf8"), 0);
771
- if (!writeBatchRecords(prepared.active, lines)) {
2864
+ const segmentIds = new Set();
2865
+ if (!writeDurableEvents(active, events, segmentIds)) {
772
2866
  return { status: "deferred", reason: "append-failed" };
773
2867
  }
774
- if (!syncBatch(prepared.active)) {
2868
+ if (!syncActiveSegment(active))
775
2869
  return { status: "deferred", reason: "durability-uncertain" };
776
- }
777
- if (!completedBatchMatches(prepared.active, before, before.size + addedBytes) ||
778
- !guards.every(logDirectoryStillSame)) {
779
- closeHandle(prepared.active);
2870
+ if (!guards.every(logDirectoryStillSame)) {
780
2871
  return { status: "deferred", reason: "destination-mutated" };
781
2872
  }
782
- return { status: "appended", appendedCount: lines.length };
2873
+ if (options.retention === "pinned" &&
2874
+ !pinDurableBatch(active, segmentIds, events[0]?.correlationId)) {
2875
+ return { status: "deferred", reason: "durability-uncertain" };
2876
+ }
2877
+ return { status: "appended", appendedCount: events.length };
2878
+ }
2879
+ function prepareDurableDirectory(stateDir, guards) {
2880
+ const stateGuard = openLogDirectoryGuard(stateDir);
2881
+ if (stateGuard === undefined)
2882
+ return undefined;
2883
+ guards.push(stateGuard);
2884
+ const directory = join(stateDir, "logs");
2885
+ mkdirSync(directory, { recursive: true, mode: 0o700 });
2886
+ if (!durableLogDirectory(directory))
2887
+ return undefined;
2888
+ const logGuard = openLogDirectoryGuard(directory);
2889
+ if (logGuard === undefined)
2890
+ return undefined;
2891
+ guards.push(logGuard);
2892
+ return resolveGovernedActiveLog(directory, process.env);
783
2893
  }
784
- function inspectAndAppendDurableBatch(prepared, guards, options) {
785
- const inspection = options.inspect(prepared.directory);
786
- const before = stableBeforeBatch(prepared, guards);
787
- if (before === undefined) {
788
- closeHandle(prepared.active);
2894
+ function inspectAndAppendDurableBatch(active, guards, options) {
2895
+ const inspection = options.inspect(active.directory, durableBatchScope(active, Date.now()));
2896
+ if (!guards.every(logDirectoryStillSame)) {
789
2897
  return { status: "deferred", reason: "destination-mutated" };
790
2898
  }
791
2899
  if (inspection.status === "already-complete")
792
2900
  return { status: "already-complete" };
793
2901
  if (inspection.status === "deferred")
794
2902
  return { status: "inspection-deferred" };
795
- return appendInspectedBatch(prepared, inspection, before, guards, options.level);
2903
+ return appendInspectedBatch(active, inspection.events, guards, options);
796
2904
  }
797
- // Synchronous by design: `inspect` and the append share the process-wide ActiveLog critical
798
- // section (one JavaScript stack), while descriptor/path/size checks expose interference from a
799
- // second process as `deferred`. O_APPEND can still leave duplicate physical records when two
800
- // processes import concurrently; callers obtain semantic deduplication from their stable record
801
- // identities, never an exactly-once filesystem claim.
2905
+ // Synchronous by design: `inspect` and the append share one JavaScript stack. The batch is written
2906
+ // through the ordinary segment writer (bounds, rollover and evidence apply unchanged), fsynced, and
2907
+ // its segments are then pinned with reason `durable-batch`, so a later inspection finds the
2908
+ // completed batch among a bounded set of files and retention can never age it out. Concurrent
2909
+ // imports by two processes can still append duplicate physical records; callers obtain semantic
2910
+ // deduplication from their stable record identities, never an exactly-once filesystem claim.
802
2911
  export function appendDurableServerLogBatch(stateDir, options) {
803
2912
  if (!serverLogLevelEnabled("info", options.level)) {
804
2913
  return { status: "deferred", reason: "level-filtered" };
805
2914
  }
806
2915
  const guards = [];
807
2916
  try {
808
- const prepared = prepareDurableLog(stateDir, guards);
809
- return prepared === undefined
2917
+ const active = prepareDurableDirectory(stateDir, guards);
2918
+ return active === undefined
810
2919
  ? { status: "deferred", reason: "destination-unsafe" }
811
- : inspectAndAppendDurableBatch(prepared, guards, options);
2920
+ : inspectAndAppendDurableBatch(active, guards, options);
812
2921
  }
813
2922
  catch {
814
2923
  return { status: "deferred", reason: "destination-unsafe" };
@@ -817,92 +2926,6 @@ export function appendDurableServerLogBatch(stateDir, options) {
817
2926
  closeLogDirectoryGuards(guards);
818
2927
  }
819
2928
  }
820
- // The process-wide registry that makes the file sink a singleton per resolved log directory. Every
821
- // consumer of the same file shares one descriptor and one rotation state; the threshold stays
822
- // per-consumer, because that is a caller's own volume control and cannot lose data.
823
- const activeLogs = new Map();
824
- function resolveActiveLog(directory, retentionDays) {
825
- const key = resolvePath(directory);
826
- const existing = activeLogs.get(key);
827
- // The first caller's retention wins: a second sink on the same file is the same file, and two
828
- // retention policies over one directory is not a thing that can be honoured anyway.
829
- if (existing !== undefined)
830
- return existing;
831
- const created = {
832
- directory,
833
- currentPath: join(directory, "server.log"),
834
- retentionDays,
835
- currentDay: todayUtc(),
836
- handle: null,
837
- pendingNewline: false,
838
- };
839
- activeLogs.set(key, created);
840
- return created;
841
- }
842
- // Closes every open activity-log descriptor. Called by the server logger's shutdown/reset path,
843
- // and by tests so a suite does not leave descriptors behind. A subsequent write reopens: closing
844
- // releases an OS resource, it never disables the log.
845
- //
846
- // The registry entries themselves are KEPT. Dropping them would let a sink created after a
847
- // shutdown build a second ActiveLog over a file some retained sink still writes to — which is the
848
- // two-rotation-states data loss this registry exists to make impossible.
849
- export function closeFileServerLogSinks() {
850
- for (const active of activeLogs.values())
851
- closeHandle(active);
852
- }
853
- export function createFileServerLogSink(stateDir, options = {}) {
854
- const directory = join(stateDir, "logs");
855
- try {
856
- mkdirSync(directory, { recursive: true, mode: 0o700 });
857
- }
858
- catch {
859
- // If we cannot create the directory we return a null sink rather than crashing the
860
- // server; the caller keeps running and the operator sees a missing file, not a hang.
861
- return NULL_SINK;
862
- }
863
- const active = resolveActiveLog(directory, options.retentionDays ?? DEFAULT_LOG_RETENTION_DAYS);
864
- const threshold = options.level ?? resolveServerLogThreshold(options.env ?? process.env);
865
- return createFileSinkFacade(active, threshold);
866
- }
867
- // Split out so `createFileServerLogSink` stays inside the 50-line ceiling.
868
- function createFileSinkFacade(active, threshold) {
869
- return {
870
- write(event) {
871
- // The threshold check comes before any formatting: a filtered event costs one comparison.
872
- if (!serverLogLevelEnabled(eventLevel(event), threshold))
873
- return;
874
- try {
875
- rotateIfNeeded(active);
876
- // Claimed as soon as the event clears the gate, before the write is attempted: see
877
- // `allocateServerLogSeq` for why a dropped write must not roll this number back.
878
- const seq = allocateServerLogSeq();
879
- const identity = {
880
- schemaVersion: SERVER_LOG_SCHEMA_VERSION,
881
- pid: process.pid,
882
- instanceId: INSTANCE_ID,
883
- seq,
884
- };
885
- writeRecord(active, ensureHandle(active), formatServerLogLine(event, undefined, identity));
886
- }
887
- catch (error) {
888
- // Writing must never take the server down; a full disk, a permission change or a file
889
- // removed under us drops the line and forces a reopen on the next write. It does NOT drop
890
- // the fact that it happened: a log that has stopped working is exactly the condition an
891
- // operator cannot infer from the absence of lines.
892
- closeHandle(active);
893
- reportServerLogFailure(error, { op: event.op, correlationId: event.correlationId });
894
- }
895
- },
896
- flush() {
897
- // `writeSync` leaves nothing in user space, so a flush is already complete on return.
898
- },
899
- close() {
900
- // The descriptor belongs to the shared ActiveLog, so this releases it for every sink on the
901
- // file. That is correct for a shutdown path and harmless otherwise: the next write reopens.
902
- closeHandle(active);
903
- },
904
- };
905
- }
906
2929
  // Test-only helper: buffered sink that keeps every event in memory so tests can assert on
907
2930
  // order and content without touching the filesystem. It captures RAW events and applies no
908
2931
  // threshold of its own, so a test can tell "the logger filtered this" from "the sink did".
@@ -919,7 +2942,7 @@ export function createBufferedServerLogSink() {
919
2942
  events.push(event);
920
2943
  },
921
2944
  lines() {
922
- return events.map((event) => formatServerLogLine(event));
2945
+ return events.map((event) => formatEventLine(event));
923
2946
  },
924
2947
  clear() {
925
2948
  events.length = 0;