harnery 0.36.0 → 0.37.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 (311) hide show
  1. package/dist/commander.js +4 -0
  2. package/dist/commands/agents.d.ts.map +1 -1
  3. package/dist/commands/agents.js +87 -46
  4. package/dist/commands/artifacts.d.ts.map +1 -1
  5. package/dist/commands/artifacts.js +26 -1
  6. package/dist/commands/browse.d.ts.map +1 -1
  7. package/dist/commands/browse.js +11 -0
  8. package/dist/commands/diagnostics.d.ts +4 -0
  9. package/dist/commands/diagnostics.d.ts.map +1 -0
  10. package/dist/commands/diagnostics.js +229 -0
  11. package/dist/commands/files.d.ts +12 -0
  12. package/dist/commands/files.d.ts.map +1 -1
  13. package/dist/commands/files.js +54 -1
  14. package/dist/commands/governor.d.ts.map +1 -1
  15. package/dist/commands/governor.js +4 -0
  16. package/dist/commands/ledger-v3.d.ts.map +1 -1
  17. package/dist/commands/ledger-v3.js +71 -2
  18. package/dist/commands/qa-run.d.ts +4 -0
  19. package/dist/commands/qa-run.d.ts.map +1 -0
  20. package/dist/commands/qa-run.js +141 -0
  21. package/dist/commands/resources.d.ts +4 -0
  22. package/dist/commands/resources.d.ts.map +1 -0
  23. package/dist/commands/resources.js +29 -0
  24. package/dist/commands/supervisor.d.ts +4 -0
  25. package/dist/commands/supervisor.d.ts.map +1 -0
  26. package/dist/commands/supervisor.js +101 -0
  27. package/dist/commands/web.d.ts.map +1 -1
  28. package/dist/commands/web.js +17 -0
  29. package/dist/commands/workflow.d.ts.map +1 -1
  30. package/dist/commands/workflow.js +4 -0
  31. package/dist/core/agents/cli.js +7 -3
  32. package/dist/core/agents/health.d.ts +17 -0
  33. package/dist/core/agents/health.d.ts.map +1 -0
  34. package/dist/core/agents/health.js +109 -0
  35. package/dist/core/agents/mailbox.d.ts +92 -0
  36. package/dist/core/agents/mailbox.d.ts.map +1 -0
  37. package/dist/core/agents/mailbox.js +325 -0
  38. package/dist/core/agents/reconcile-coordination-v3.d.ts +44 -0
  39. package/dist/core/agents/reconcile-coordination-v3.d.ts.map +1 -0
  40. package/dist/core/agents/reconcile-coordination-v3.js +58 -0
  41. package/dist/core/agents/render/prompt-context.d.ts +5 -0
  42. package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
  43. package/dist/core/agents/render/prompt-context.js +34 -13
  44. package/dist/core/agents/render/session-context.d.ts +8 -0
  45. package/dist/core/agents/render/session-context.d.ts.map +1 -1
  46. package/dist/core/agents/render/session-context.js +34 -3
  47. package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
  48. package/dist/core/agents/rules/commit-conflict.js +50 -1
  49. package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
  50. package/dist/core/agents/rules/stop-hook.js +6 -10
  51. package/dist/core/agents/session-finalizer-v3.js +4 -1
  52. package/dist/core/artifacts/index.d.ts +26 -1
  53. package/dist/core/artifacts/index.d.ts.map +1 -1
  54. package/dist/core/artifacts/index.js +146 -6
  55. package/dist/core/config.d.ts +12 -0
  56. package/dist/core/config.d.ts.map +1 -1
  57. package/dist/core/config.js +43 -0
  58. package/dist/core/diagnostics/advice.d.ts +9 -0
  59. package/dist/core/diagnostics/advice.d.ts.map +1 -0
  60. package/dist/core/diagnostics/advice.js +112 -0
  61. package/dist/core/diagnostics/bundle.d.ts +35 -0
  62. package/dist/core/diagnostics/bundle.d.ts.map +1 -0
  63. package/dist/core/diagnostics/bundle.js +874 -0
  64. package/dist/core/diagnostics/comparison.d.ts +5 -0
  65. package/dist/core/diagnostics/comparison.d.ts.map +1 -0
  66. package/dist/core/diagnostics/comparison.js +444 -0
  67. package/dist/core/diagnostics/contract.d.ts +245 -0
  68. package/dist/core/diagnostics/contract.d.ts.map +1 -0
  69. package/dist/core/diagnostics/contract.js +18 -0
  70. package/dist/core/diagnostics/identity.d.ts +3 -0
  71. package/dist/core/diagnostics/identity.d.ts.map +1 -0
  72. package/dist/core/diagnostics/identity.js +10 -0
  73. package/dist/core/diagnostics/index.d.ts +8 -0
  74. package/dist/core/diagnostics/index.d.ts.map +1 -0
  75. package/dist/core/diagnostics/index.js +7 -0
  76. package/dist/core/diagnostics/replay.d.ts +8 -0
  77. package/dist/core/diagnostics/replay.d.ts.map +1 -0
  78. package/dist/core/diagnostics/replay.js +213 -0
  79. package/dist/core/diagnostics/sanitize.d.ts +9 -0
  80. package/dist/core/diagnostics/sanitize.d.ts.map +1 -0
  81. package/dist/core/diagnostics/sanitize.js +84 -0
  82. package/dist/core/events/legacy-storage/compression.d.ts +13 -0
  83. package/dist/core/events/legacy-storage/compression.d.ts.map +1 -0
  84. package/dist/core/events/legacy-storage/compression.js +107 -0
  85. package/dist/core/events/legacy-storage/index.d.ts +1 -0
  86. package/dist/core/events/legacy-storage/index.d.ts.map +1 -1
  87. package/dist/core/events/legacy-storage/index.js +1 -0
  88. package/dist/core/events/v3/archive-retention.d.ts +33 -0
  89. package/dist/core/events/v3/archive-retention.d.ts.map +1 -0
  90. package/dist/core/events/v3/archive-retention.js +195 -0
  91. package/dist/core/events/v3/capabilities.d.ts +1 -1
  92. package/dist/core/events/v3/capabilities.d.ts.map +1 -1
  93. package/dist/core/events/v3/capabilities.js +1 -0
  94. package/dist/core/events/v3/index.d.ts +1 -0
  95. package/dist/core/events/v3/index.d.ts.map +1 -1
  96. package/dist/core/events/v3/index.js +1 -0
  97. package/dist/core/events/v3/live-routing.d.ts.map +1 -1
  98. package/dist/core/events/v3/live-routing.js +1 -0
  99. package/dist/core/events/v3/producers/hook-base.d.ts +1 -1
  100. package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -1
  101. package/dist/core/events/v3/producers/hook-base.js +13 -2
  102. package/dist/core/events/v3/producers/intake.d.ts.map +1 -1
  103. package/dist/core/events/v3/producers/intake.js +1 -0
  104. package/dist/core/events/v3/producers/recorder.d.ts +16 -0
  105. package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
  106. package/dist/core/events/v3/producers/recorder.js +88 -1
  107. package/dist/core/hooks/adapter/output.d.ts +8 -0
  108. package/dist/core/hooks/adapter/output.d.ts.map +1 -1
  109. package/dist/core/hooks/adapter/output.js +11 -1
  110. package/dist/core/hooks/cli.js +183 -192
  111. package/dist/core/hooks/health.d.ts +59 -0
  112. package/dist/core/hooks/health.d.ts.map +1 -0
  113. package/dist/core/hooks/health.js +84 -0
  114. package/dist/core/resources/contract.d.ts +90 -0
  115. package/dist/core/resources/contract.d.ts.map +1 -0
  116. package/dist/core/resources/contract.js +2 -0
  117. package/dist/core/resources/index.d.ts +6 -0
  118. package/dist/core/resources/index.d.ts.map +1 -0
  119. package/dist/core/resources/index.js +5 -0
  120. package/dist/core/resources/sampler.d.ts +27 -0
  121. package/dist/core/resources/sampler.d.ts.map +1 -0
  122. package/dist/core/resources/sampler.js +357 -0
  123. package/dist/core/resources/service-status.d.ts +3 -0
  124. package/dist/core/resources/service-status.d.ts.map +1 -0
  125. package/dist/core/resources/service-status.js +48 -0
  126. package/dist/core/resources/service.d.ts +26 -0
  127. package/dist/core/resources/service.d.ts.map +1 -0
  128. package/dist/core/resources/service.js +292 -0
  129. package/dist/core/resources/storage.d.ts +13 -0
  130. package/dist/core/resources/storage.d.ts.map +1 -0
  131. package/dist/core/resources/storage.js +30 -0
  132. package/dist/core/storage/atomic-json.d.ts +3 -0
  133. package/dist/core/storage/atomic-json.d.ts.map +1 -0
  134. package/dist/core/storage/atomic-json.js +15 -0
  135. package/dist/core/storage/builtins.d.ts.map +1 -1
  136. package/dist/core/storage/builtins.js +45 -6
  137. package/dist/core/storage/logger.d.ts +2 -0
  138. package/dist/core/storage/logger.d.ts.map +1 -1
  139. package/dist/core/storage/logger.js +2 -0
  140. package/dist/core/storage/query.d.ts +14 -0
  141. package/dist/core/storage/query.d.ts.map +1 -1
  142. package/dist/core/storage/query.js +51 -0
  143. package/dist/core/supervisor/activity.d.ts +4 -0
  144. package/dist/core/supervisor/activity.d.ts.map +1 -0
  145. package/dist/core/supervisor/activity.js +141 -0
  146. package/dist/core/supervisor/contract.d.ts +268 -0
  147. package/dist/core/supervisor/contract.d.ts.map +1 -0
  148. package/dist/core/supervisor/contract.js +35 -0
  149. package/dist/core/supervisor/explanations.d.ts +4 -0
  150. package/dist/core/supervisor/explanations.d.ts.map +1 -0
  151. package/dist/core/supervisor/explanations.js +71 -0
  152. package/dist/core/supervisor/findings.d.ts +20 -0
  153. package/dist/core/supervisor/findings.d.ts.map +1 -0
  154. package/dist/core/supervisor/findings.js +399 -0
  155. package/dist/core/supervisor/history.d.ts +9 -0
  156. package/dist/core/supervisor/history.d.ts.map +1 -0
  157. package/dist/core/supervisor/history.js +46 -0
  158. package/dist/core/supervisor/hook-health-alerts.d.ts +14 -0
  159. package/dist/core/supervisor/hook-health-alerts.d.ts.map +1 -0
  160. package/dist/core/supervisor/hook-health-alerts.js +70 -0
  161. package/dist/core/supervisor/hook-health-storage.d.ts +5 -0
  162. package/dist/core/supervisor/hook-health-storage.d.ts.map +1 -0
  163. package/dist/core/supervisor/hook-health-storage.js +24 -0
  164. package/dist/core/supervisor/hook-health.d.ts +72 -0
  165. package/dist/core/supervisor/hook-health.d.ts.map +1 -0
  166. package/dist/core/supervisor/hook-health.js +203 -0
  167. package/dist/core/supervisor/hooks.d.ts +10 -0
  168. package/dist/core/supervisor/hooks.d.ts.map +1 -0
  169. package/dist/core/supervisor/hooks.js +28 -0
  170. package/dist/core/supervisor/index.d.ts +15 -0
  171. package/dist/core/supervisor/index.d.ts.map +1 -0
  172. package/dist/core/supervisor/index.js +14 -0
  173. package/dist/core/supervisor/log-feed.d.ts +9 -0
  174. package/dist/core/supervisor/log-feed.d.ts.map +1 -0
  175. package/dist/core/supervisor/log-feed.js +103 -0
  176. package/dist/core/supervisor/service.d.ts +29 -0
  177. package/dist/core/supervisor/service.d.ts.map +1 -0
  178. package/dist/core/supervisor/service.js +450 -0
  179. package/dist/core/supervisor/services.d.ts +11 -0
  180. package/dist/core/supervisor/services.d.ts.map +1 -0
  181. package/dist/core/supervisor/services.js +155 -0
  182. package/dist/core/supervisor/status.d.ts +3 -0
  183. package/dist/core/supervisor/status.d.ts.map +1 -0
  184. package/dist/core/supervisor/status.js +48 -0
  185. package/dist/core/supervisor/storage.d.ts +30 -0
  186. package/dist/core/supervisor/storage.d.ts.map +1 -0
  187. package/dist/core/supervisor/storage.js +73 -0
  188. package/dist/core/supervisor/timeline.d.ts +3 -0
  189. package/dist/core/supervisor/timeline.d.ts.map +1 -0
  190. package/dist/core/supervisor/timeline.js +87 -0
  191. package/dist/core/workflow/admission.d.ts +23 -0
  192. package/dist/core/workflow/admission.d.ts.map +1 -0
  193. package/dist/core/workflow/admission.js +136 -0
  194. package/dist/core/workflow/engine.d.ts.map +1 -1
  195. package/dist/core/workflow/engine.js +77 -2
  196. package/dist/core/workflow/index.d.ts +3 -2
  197. package/dist/core/workflow/index.d.ts.map +1 -1
  198. package/dist/core/workflow/index.js +2 -1
  199. package/dist/core/workflow/proof.d.ts +2 -1
  200. package/dist/core/workflow/proof.d.ts.map +1 -1
  201. package/dist/core/workflow/proof.js +39 -1
  202. package/dist/core/workflow/run-state.d.ts +3 -2
  203. package/dist/core/workflow/run-state.d.ts.map +1 -1
  204. package/dist/core/workflow/run-state.js +8 -1
  205. package/dist/core/workflow/types.d.ts +33 -1
  206. package/dist/core/workflow/types.d.ts.map +1 -1
  207. package/dist/core/workflow/types.js +2 -1
  208. package/dist/lib/browser/client.d.ts +5 -0
  209. package/dist/lib/browser/client.d.ts.map +1 -1
  210. package/dist/lib/browser/client.js +1 -0
  211. package/dist/lib/browser/index.d.ts +2 -0
  212. package/dist/lib/browser/index.d.ts.map +1 -1
  213. package/dist/lib/browser/index.js +2 -0
  214. package/dist/lib/browser/qa-run-contracts.d.ts +173 -0
  215. package/dist/lib/browser/qa-run-contracts.d.ts.map +1 -0
  216. package/dist/lib/browser/qa-run-contracts.js +226 -0
  217. package/dist/lib/browser/qa-run.d.ts +51 -0
  218. package/dist/lib/browser/qa-run.d.ts.map +1 -0
  219. package/dist/lib/browser/qa-run.js +684 -0
  220. package/dist/lib/coord-root-id.d.ts +9 -0
  221. package/dist/lib/coord-root-id.d.ts.map +1 -0
  222. package/dist/lib/coord-root-id.js +17 -0
  223. package/dist/lib/instructions/apply.d.ts +3 -1
  224. package/dist/lib/instructions/apply.d.ts.map +1 -1
  225. package/dist/lib/instructions/apply.js +74 -3
  226. package/dist/lib/instructions/templates.d.ts.map +1 -1
  227. package/dist/lib/instructions/templates.js +6 -0
  228. package/package.json +12 -1
  229. package/src/commander.ts +26 -0
  230. package/src/commands/agents.ts +102 -49
  231. package/src/commands/artifacts.ts +40 -2
  232. package/src/commands/browse.ts +15 -0
  233. package/src/commands/diagnostics.ts +271 -0
  234. package/src/commands/files.ts +102 -2
  235. package/src/commands/governor.ts +8 -0
  236. package/src/commands/ledger-v3.ts +82 -0
  237. package/src/commands/qa-run.ts +184 -0
  238. package/src/commands/resources.ts +38 -0
  239. package/src/commands/supervisor.ts +141 -0
  240. package/src/commands/web.ts +19 -0
  241. package/src/commands/workflow.ts +8 -0
  242. package/src/core/agents/cli.ts +7 -3
  243. package/src/core/agents/health.ts +142 -0
  244. package/src/core/agents/mailbox.ts +373 -0
  245. package/src/core/agents/reconcile-coordination-v3.ts +77 -0
  246. package/src/core/agents/render/prompt-context.ts +42 -12
  247. package/src/core/agents/render/session-context.ts +37 -3
  248. package/src/core/agents/rules/commit-conflict.ts +58 -1
  249. package/src/core/agents/rules/stop-hook.ts +6 -12
  250. package/src/core/agents/session-finalizer-v3.ts +4 -1
  251. package/src/core/artifacts/index.ts +196 -10
  252. package/src/core/config.ts +111 -2
  253. package/src/core/diagnostics/advice.ts +147 -0
  254. package/src/core/diagnostics/bundle.ts +1142 -0
  255. package/src/core/diagnostics/comparison.ts +565 -0
  256. package/src/core/diagnostics/contract.ts +311 -0
  257. package/src/core/diagnostics/identity.ts +11 -0
  258. package/src/core/diagnostics/index.ts +7 -0
  259. package/src/core/diagnostics/replay.ts +314 -0
  260. package/src/core/diagnostics/sanitize.ts +97 -0
  261. package/src/core/events/legacy-storage/compression.ts +130 -0
  262. package/src/core/events/legacy-storage/index.ts +1 -0
  263. package/src/core/events/v3/archive-retention.ts +251 -0
  264. package/src/core/events/v3/capabilities.ts +2 -0
  265. package/src/core/events/v3/index.ts +9 -0
  266. package/src/core/events/v3/live-routing.ts +1 -0
  267. package/src/core/events/v3/producers/hook-base.ts +14 -2
  268. package/src/core/events/v3/producers/intake.ts +1 -0
  269. package/src/core/events/v3/producers/recorder.ts +110 -1
  270. package/src/core/hooks/adapter/output.ts +12 -1
  271. package/src/core/hooks/cli.ts +192 -215
  272. package/src/core/hooks/health.ts +146 -0
  273. package/src/core/resources/contract.ts +98 -0
  274. package/src/core/resources/index.ts +5 -0
  275. package/src/core/resources/sampler.ts +458 -0
  276. package/src/core/resources/service-status.ts +62 -0
  277. package/src/core/resources/service.ts +337 -0
  278. package/src/core/resources/storage.ts +44 -0
  279. package/src/core/storage/atomic-json.ts +15 -0
  280. package/src/core/storage/builtins.ts +62 -6
  281. package/src/core/storage/logger.ts +2 -0
  282. package/src/core/storage/query.ts +58 -0
  283. package/src/core/supervisor/activity.ts +193 -0
  284. package/src/core/supervisor/contract.ts +312 -0
  285. package/src/core/supervisor/explanations.ts +104 -0
  286. package/src/core/supervisor/findings.ts +788 -0
  287. package/src/core/supervisor/history.ts +61 -0
  288. package/src/core/supervisor/hook-health-alerts.ts +108 -0
  289. package/src/core/supervisor/hook-health-storage.ts +25 -0
  290. package/src/core/supervisor/hook-health.ts +301 -0
  291. package/src/core/supervisor/hooks.ts +35 -0
  292. package/src/core/supervisor/index.ts +14 -0
  293. package/src/core/supervisor/log-feed.ts +131 -0
  294. package/src/core/supervisor/service.ts +511 -0
  295. package/src/core/supervisor/services.ts +203 -0
  296. package/src/core/supervisor/status.ts +59 -0
  297. package/src/core/supervisor/storage.ts +126 -0
  298. package/src/core/supervisor/timeline.ts +133 -0
  299. package/src/core/workflow/admission.ts +215 -0
  300. package/src/core/workflow/engine.ts +93 -1
  301. package/src/core/workflow/index.ts +10 -0
  302. package/src/core/workflow/proof.ts +54 -1
  303. package/src/core/workflow/run-state.ts +13 -1
  304. package/src/core/workflow/types.ts +39 -1
  305. package/src/lib/browser/client.ts +6 -0
  306. package/src/lib/browser/index.ts +29 -0
  307. package/src/lib/browser/qa-run-contracts.ts +380 -0
  308. package/src/lib/browser/qa-run.ts +784 -0
  309. package/src/lib/coord-root-id.ts +23 -0
  310. package/src/lib/instructions/apply.ts +81 -2
  311. package/src/lib/instructions/templates.ts +6 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../src/core/diagnostics/contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,gCAAgC,EAAG,CAAU,CAAC;AAC3D,eAAO,MAAM,iCAAiC,EAAG,CAAU,CAAC;AAC5D,eAAO,MAAM,+BAA+B,EAAG,CAAU,CAAC;AAC1D,eAAO,MAAM,kCAAkC,EAAG,CAAU,CAAC;AAC7D,eAAO,MAAM,iCAAiC,EAAG,CAAU,CAAC;AAC5D,eAAO,MAAM,gCAAgC,EAAG,CAAU,CAAC;AAC3D,eAAO,MAAM,oCAAoC,EAAG,CAAU,CAAC;AAE/D,eAAO,MAAM,wBAAwB;;;CAG3B,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAChF,MAAM,MAAM,8BAA8B,GACtC,SAAS,GACT,aAAa,GACb,mBAAmB,GACnB,SAAS,CAAC;AAEd,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,SAAS,GAAG,UAAU,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC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DIAGNOSTIC_INPUT_SCHEMA_VERSION = 2;
4
+ export const DIAGNOSTIC_EXPECTED_SCHEMA_VERSION = 3;
5
+ export const DIAGNOSTIC_SUMMARY_SCHEMA_VERSION = 1;
6
+ export const DIAGNOSTIC_ADVICE_SCHEMA_VERSION = 1;
7
+ export const DIAGNOSTIC_COMPARISON_SCHEMA_VERSION = 1;
8
+ export const DIAGNOSTIC_ADVICE_LIMITS = {
9
+ max_contributing_findings: 8,
10
+ max_reasons: 4,
11
+ };
12
+ export const DIAGNOSTIC_BUNDLE_FILES = [
13
+ "diagnostic-manifest.json",
14
+ "inputs/observations.json",
15
+ "inputs/thresholds.json",
16
+ "expected.json",
17
+ "summary.json",
18
+ ];
@@ -0,0 +1,3 @@
1
+ /** Stable within one machine label, but not reversible to that label. */
2
+ export declare function pseudonymousMachineId(machineLabel?: string): string;
3
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/core/diagnostics/identity.ts"],"names":[],"mappings":"AAGA,yEAAyE;AACzE,wBAAgB,qBAAqB,CAAC,YAAY,SAAwB,GAAG,MAAM,CAMlF"}
@@ -0,0 +1,10 @@
1
+ import { createHash } from "node:crypto";
2
+ import { resolveMachineLabel } from "../../lib/machine.js";
3
+ /** Stable within one machine label, but not reversible to that label. */
4
+ export function pseudonymousMachineId(machineLabel = resolveMachineLabel()) {
5
+ const digest = createHash("sha256")
6
+ .update("harnery-diagnostic-machine-v1\0")
7
+ .update(machineLabel)
8
+ .digest("hex");
9
+ return `machine_${digest}`;
10
+ }
@@ -0,0 +1,8 @@
1
+ export * from "./advice.js";
2
+ export * from "./bundle.js";
3
+ export * from "./comparison.js";
4
+ export * from "./contract.js";
5
+ export * from "./identity.js";
6
+ export * from "./replay.js";
7
+ export * from "./sanitize.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/diagnostics/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./advice.js";
2
+ export * from "./bundle.js";
3
+ export * from "./comparison.js";
4
+ export * from "./contract.js";
5
+ export * from "./identity.js";
6
+ export * from "./replay.js";
7
+ export * from "./sanitize.js";
@@ -0,0 +1,8 @@
1
+ import { type DiagnosticExpected, type DiagnosticObservations, type DiagnosticThresholds } from "./contract.js";
2
+ export declare function canonicalJson(value: unknown): string;
3
+ export declare function sha256(value: string | Buffer): string;
4
+ /** Record the live engine's frozen output. Replay never uses this as an input. */
5
+ export declare function deriveCapturedExpected(observations: DiagnosticObservations, thresholds: DiagnosticThresholds): DiagnosticExpected;
6
+ /** Re-run the pure finding engine from frozen source inputs only. */
7
+ export declare function replayDiagnosticInputs(observations: DiagnosticObservations, thresholds: DiagnosticThresholds): DiagnosticExpected;
8
+ //# sourceMappingURL=replay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../../src/core/diagnostics/replay.ts"],"names":[],"mappings":"AA0BA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAE3B,KAAK,oBAAoB,EAC1B,MAAM,eAAe,CAAC;AAEvB,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAErD;AAED,kFAAkF;AAClF,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,sBAAsB,EACpC,UAAU,EAAE,oBAAoB,GAC/B,kBAAkB,CAkBpB;AAED,qEAAqE;AACrE,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,sBAAsB,EACpC,UAAU,EAAE,oBAAoB,GAC/B,kBAAkB,CAiDpB"}
@@ -0,0 +1,213 @@
1
+ import { createHash } from "node:crypto";
2
+ import { RESOURCE_SNAPSHOT_SCHEMA_VERSION } from "../resources/contract.js";
3
+ import { SUPERVISOR_HISTORY_SCHEMA_VERSION, SUPERVISOR_LOG_FEED_SCHEMA_VERSION, SUPERVISOR_SNAPSHOT_SCHEMA_VERSION, } from "../supervisor/contract.js";
4
+ import { explainSupervisorFinding } from "../supervisor/explanations.js";
5
+ import { updateSupervisorFindings } from "../supervisor/findings.js";
6
+ import { projectHookHealth } from "../supervisor/hook-health.js";
7
+ import { buildSupervisorTimeline } from "../supervisor/timeline.js";
8
+ import { buildDiagnosticAdvice } from "./advice.js";
9
+ import { DIAGNOSTIC_EXPECTED_SCHEMA_VERSION, } from "./contract.js";
10
+ export function canonicalJson(value) {
11
+ return JSON.stringify(sortValue(value));
12
+ }
13
+ export function sha256(value) {
14
+ return createHash("sha256").update(value).digest("hex");
15
+ }
16
+ /** Record the live engine's frozen output. Replay never uses this as an input. */
17
+ export function deriveCapturedExpected(observations, thresholds) {
18
+ const selection = observations.selection;
19
+ const findings = filterFindings(findingsProjection(sourceValue(observations, "supervisor.findings")), selection);
20
+ const coordination = sourceValue(observations, "coordination.health");
21
+ const relatedSources = coordination?.recent_events ?? [];
22
+ return expected(thresholds, selection, findings, findings.map((finding) => diagnosticTimeline(finding, relatedSources)), findings.map(explainSupervisorFinding), observations);
23
+ }
24
+ /** Re-run the pure finding engine from frozen source inputs only. */
25
+ export function replayDiagnosticInputs(observations, thresholds) {
26
+ const resource = optionalSource(observations, "resources.snapshot") ??
27
+ neutralResource(observations.captured_at);
28
+ const supervisor = optionalSource(observations, "supervisor.snapshot") ??
29
+ neutralSupervisor(observations.captured_at);
30
+ const history = optionalSource(observations, "supervisor.history") ?? neutralHistory();
31
+ const logFeed = optionalSource(observations, "supervisor.log-feed") ??
32
+ neutralLogFeed(observations.captured_at);
33
+ const hookHealth = projectHookHealth(logFeed, new Date(observations.captured_at));
34
+ const coordination = optionalSource(observations, "coordination.health");
35
+ const activity = optionalSource(observations, "supervisor.activity");
36
+ const currentProjection = optionalSource(observations, "supervisor.findings");
37
+ const observedAt = currentProjection?.active[0]?.observed_at ??
38
+ currentProjection?.transitions.at(-1)?.observed_at ??
39
+ resource.sampled_at;
40
+ // The frozen projection supplies lifecycle state only. Candidates, severity,
41
+ // attribution, workload context, and evidence are all re-evaluated from the
42
+ // captured source observations. Without this prior state, a replay would
43
+ // mint fresh IDs and discard recurrence and peak history for open episodes.
44
+ const evaluated = updateSupervisorFindings({
45
+ previous: currentProjection,
46
+ resource,
47
+ services: supervisor.services,
48
+ hooks: supervisor.hooks,
49
+ history,
50
+ logFeed,
51
+ hookHealth,
52
+ coordination,
53
+ activity,
54
+ now: new Date(observedAt),
55
+ });
56
+ const findings = filterFindings(findingsProjection(evaluated), observations.selection);
57
+ const relatedSources = coordination?.recent_events ?? [];
58
+ return expected(thresholds, observations.selection, findings, findings.map((finding) => diagnosticTimeline(finding, relatedSources)), findings.map(explainSupervisorFinding), observations);
59
+ }
60
+ function diagnosticTimeline(finding, relatedSources) {
61
+ return buildSupervisorTimeline(finding, relatedSources.filter((source) => {
62
+ const delta = Math.abs(Date.parse(source.observed_at) - Date.parse(finding.observed_at));
63
+ return Number.isFinite(delta) && delta <= 5 * 60_000;
64
+ }));
65
+ }
66
+ function expected(thresholds, selection, findings, timelines, explanations, observations) {
67
+ return {
68
+ schema_version: DIAGNOSTIC_EXPECTED_SCHEMA_VERSION,
69
+ threshold_digest: sha256(canonicalJson(thresholds)),
70
+ selection,
71
+ findings,
72
+ timelines: [...timelines].sort((left, right) => left.finding_id.localeCompare(right.finding_id)),
73
+ explanations: [...explanations].sort((left, right) => left.finding_id.localeCompare(right.finding_id)),
74
+ advice: buildDiagnosticAdvice({
75
+ findings,
76
+ sourceCapability: capturedSourceCapability(observations, "supervisor.findings"),
77
+ evaluatedAt: observations.captured_at,
78
+ }),
79
+ };
80
+ }
81
+ function capturedSourceCapability(observations, sourceKind) {
82
+ const source = observations.sources.find((candidate) => candidate.source_kind === sourceKind);
83
+ return source
84
+ ? {
85
+ source_kind: sourceKind,
86
+ state: source.capability,
87
+ reason_code: source.reason_code,
88
+ }
89
+ : {
90
+ source_kind: sourceKind,
91
+ state: "unsupported",
92
+ reason_code: "source_missing",
93
+ };
94
+ }
95
+ function findingsProjection(value) {
96
+ const record = object(value);
97
+ return [
98
+ ...collectNamedRecords(record?.active),
99
+ ...collectNamedRecords(record?.transitions),
100
+ ];
101
+ }
102
+ function filterFindings(rows, selection) {
103
+ const deduped = new Map(rows.map((finding) => [finding.id, finding]));
104
+ return [...deduped.values()]
105
+ .filter((finding) => {
106
+ if (selection.finding_id)
107
+ return finding.id === selection.finding_id;
108
+ const observed = Date.parse(finding.observed_at);
109
+ return observed >= Date.parse(selection.start_at) && observed <= Date.parse(selection.end_at);
110
+ })
111
+ .sort((left, right) => left.observed_at.localeCompare(right.observed_at) || left.id.localeCompare(right.id));
112
+ }
113
+ function optionalSource(observations, sourceKind) {
114
+ const source = observations.sources.find((candidate) => candidate.source_kind === sourceKind);
115
+ return source?.capability === "supported" && source.value !== undefined
116
+ ? source.value
117
+ : undefined;
118
+ }
119
+ function neutralResource(sampledAt) {
120
+ return {
121
+ schema_version: RESOURCE_SNAPSHOT_SCHEMA_VERSION,
122
+ sampled_at: sampledAt,
123
+ interval_ms: null,
124
+ sample_duration_ms: 0,
125
+ collector_cpu_ms: 0,
126
+ platform: "linux",
127
+ namespace: "unknown",
128
+ support: {
129
+ state: "unsupported",
130
+ sampler: "unsupported",
131
+ reason: "captured-source-unavailable",
132
+ },
133
+ machine: {
134
+ cpu_percent: null,
135
+ cpu_logical_count: 0,
136
+ load_average: null,
137
+ memory_total_bytes: null,
138
+ memory_available_bytes: null,
139
+ memory_used_bytes: null,
140
+ memory_percent: null,
141
+ swap_total_bytes: null,
142
+ swap_used_bytes: null,
143
+ process_count: 0,
144
+ },
145
+ groups: [],
146
+ processes: [],
147
+ visible_process_count: 0,
148
+ omitted_process_count: 0,
149
+ unattributed_process_count: 0,
150
+ };
151
+ }
152
+ function neutralSupervisor(sampledAt) {
153
+ return {
154
+ schema_version: SUPERVISOR_SNAPSHOT_SCHEMA_VERSION,
155
+ sampled_at: sampledAt,
156
+ sequence: 0,
157
+ collector_duration_ms: 0,
158
+ resource_sample_duration_ms: 0,
159
+ services: [],
160
+ hooks: [],
161
+ active_finding_count: 0,
162
+ history_point_count: 0,
163
+ log_record_count: 0,
164
+ live_consumer_count: 0,
165
+ attributed_agent_count: 0,
166
+ };
167
+ }
168
+ function neutralHistory() {
169
+ return {
170
+ schema_version: SUPERVISOR_HISTORY_SCHEMA_VERSION,
171
+ interval_ms: 10_000,
172
+ max_points: 90,
173
+ points: [],
174
+ };
175
+ }
176
+ function neutralLogFeed(capturedAt) {
177
+ return {
178
+ schema_version: SUPERVISOR_LOG_FEED_SCHEMA_VERSION,
179
+ captured_at: capturedAt,
180
+ sequence: 0,
181
+ lanes: [],
182
+ total_records: 0,
183
+ unavailable_families: 0,
184
+ };
185
+ }
186
+ function sourceValue(observations, sourceKind) {
187
+ return observations.sources.find((source) => source.source_kind === sourceKind)?.value;
188
+ }
189
+ function collectNamedRecords(value) {
190
+ if (Array.isArray(value))
191
+ return value.filter(isObject);
192
+ const record = object(value);
193
+ if (!record)
194
+ return [];
195
+ if (Array.isArray(record.rows))
196
+ return record.rows.filter(isObject);
197
+ return Object.values(record).filter(isObject);
198
+ }
199
+ function sortValue(value) {
200
+ if (Array.isArray(value))
201
+ return value.map(sortValue);
202
+ if (!isObject(value))
203
+ return value;
204
+ return Object.fromEntries(Object.entries(value)
205
+ .sort(([left], [right]) => left.localeCompare(right))
206
+ .map(([key, item]) => [key, sortValue(item)]));
207
+ }
208
+ function object(value) {
209
+ return isObject(value) ? value : undefined;
210
+ }
211
+ function isObject(value) {
212
+ return !!value && typeof value === "object" && !Array.isArray(value);
213
+ }
@@ -0,0 +1,9 @@
1
+ export interface SanitizationStats {
2
+ sanitized_value_count: number;
3
+ omitted_value_count: number;
4
+ }
5
+ export declare function sanitizeDiagnosticValue(value: unknown): {
6
+ value: unknown;
7
+ stats: SanitizationStats;
8
+ };
9
+ //# sourceMappingURL=sanitize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/core/diagnostics/sanitize.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,iBAAiB;IAChC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG;IACvD,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,iBAAiB,CAAC;CAC1B,CAGA"}
@@ -0,0 +1,84 @@
1
+ const SENSITIVE_KEY = /(?:authorization|cookie|credential|password|passwd|private[_-]?key|secret|session[_-]?token|access[_-]?token|refresh[_-]?token|api[_-]?key)/i;
2
+ const OMITTED_CONTENT_KEY = /(?:^|[_-])(?:environment|env|prompt|prompts|tool[_-]?payload|tool[_-]?result|transcript|transcripts)(?:$|[_-])/i;
3
+ const HOME_PATH = /(?:[A-Za-z]:\\Users\\[^\\\s]+|\/home\/[^/\s]+|\/Users\/[^/\s]+)/g;
4
+ const BEARER_VALUE = /\bBearer\s+[A-Za-z0-9._~+/-]+=*/gi;
5
+ const URL_CREDENTIALS = /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/gi;
6
+ const PRIVATE_KEY = /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g;
7
+ const TOKENISH_VALUE = /\b(?:sk|pk|ghp|github_pat|xox[baprs])[-_][A-Za-z0-9_-]{16,}\b/g;
8
+ const AWS_ACCESS_KEY = /\bAKIA[A-Z0-9]{16,}\b/g;
9
+ const SENSITIVE_QUERY = /([?&](?:access_token|api_key|key|password|secret|token)=)[^&#\s]+/gi;
10
+ const SENSITIVE_ENV = /(\b[A-Z0-9_]*(?:API_KEY|PASSWORD|SECRET|TOKEN)=)[^\s]+/g;
11
+ const SENSITIVE_ARGUMENT = /(\B--?(?:access-token|api-key|password|secret|token)\s+)[^\s]+/gi;
12
+ export function sanitizeDiagnosticValue(value) {
13
+ const stats = { sanitized_value_count: 0, omitted_value_count: 0 };
14
+ return { value: sanitize(value, stats, 0), stats };
15
+ }
16
+ function sanitize(value, stats, depth) {
17
+ if (depth > 24) {
18
+ stats.omitted_value_count += 1;
19
+ return "[OMITTED:depth-limit]";
20
+ }
21
+ if (value === null || typeof value === "boolean" || typeof value === "number")
22
+ return value;
23
+ if (typeof value === "string")
24
+ return sanitizeString(value, stats);
25
+ if (Array.isArray(value)) {
26
+ const sliced = value.slice(0, 5_000);
27
+ const kept = sliced.map((item, index) => {
28
+ if (typeof sliced[index - 1] === "string" &&
29
+ /^(?:--?)(?:access-token|api-key|password|secret|token)$/i.test(sliced[index - 1])) {
30
+ stats.sanitized_value_count += 1;
31
+ return "[REDACTED:argument]";
32
+ }
33
+ return sanitize(item, stats, depth + 1);
34
+ });
35
+ if (kept.length !== value.length)
36
+ stats.omitted_value_count += value.length - kept.length;
37
+ return kept;
38
+ }
39
+ if (!value || typeof value !== "object")
40
+ return String(value);
41
+ const result = {};
42
+ const entries = Object.entries(value);
43
+ const namedSensitiveField = entries.some(([key, item]) => key === "name" && typeof item === "string" && SENSITIVE_KEY.test(item));
44
+ for (const [key, item] of entries) {
45
+ if (OMITTED_CONTENT_KEY.test(key)) {
46
+ result[key] = "[OMITTED:sensitive-content]";
47
+ stats.omitted_value_count += 1;
48
+ continue;
49
+ }
50
+ if (key === "value" && namedSensitiveField) {
51
+ result[key] = "[REDACTED:sensitive-field]";
52
+ stats.sanitized_value_count += 1;
53
+ continue;
54
+ }
55
+ if (SENSITIVE_KEY.test(key)) {
56
+ result[key] = "[REDACTED:sensitive-field]";
57
+ stats.sanitized_value_count += 1;
58
+ continue;
59
+ }
60
+ result[key] = sanitize(item, stats, depth + 1);
61
+ }
62
+ return result;
63
+ }
64
+ function sanitizeString(value, stats) {
65
+ let next = value;
66
+ const replacements = [
67
+ [PRIVATE_KEY, "[REDACTED:private-key]"],
68
+ [BEARER_VALUE, "Bearer [REDACTED:token]"],
69
+ [TOKENISH_VALUE, "[REDACTED:token]"],
70
+ [AWS_ACCESS_KEY, "[REDACTED:access-key]"],
71
+ [SENSITIVE_QUERY, "$1[REDACTED]"],
72
+ [SENSITIVE_ENV, "$1[REDACTED]"],
73
+ [SENSITIVE_ARGUMENT, "$1[REDACTED]"],
74
+ [URL_CREDENTIALS, (_match, scheme) => `${scheme}[REDACTED]@`],
75
+ [HOME_PATH, "[REDACTED:home]"],
76
+ ];
77
+ for (const [pattern, replacement] of replacements) {
78
+ const replaced = next.replace(pattern, replacement);
79
+ if (replaced !== next)
80
+ stats.sanitized_value_count += 1;
81
+ next = replaced;
82
+ }
83
+ return next;
84
+ }
@@ -0,0 +1,13 @@
1
+ /** Verified in-place compression for sealed, non-terminal legacy V1 shards. */
2
+ export interface LegacyV1CompressionEntry {
3
+ filename: string;
4
+ path: string;
5
+ bytes_before: number;
6
+ bytes_after: number | null;
7
+ action: "keep" | "would-compress" | "compressed";
8
+ reason: string;
9
+ }
10
+ export declare function compressSealedLegacyV1Segments(coordRoot: string, opts?: {
11
+ yes?: boolean;
12
+ }): Promise<LegacyV1CompressionEntry[]>;
13
+ //# sourceMappingURL=compression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compression.d.ts","sourceRoot":"","sources":["../../../../src/core/events/legacy-storage/compression.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAW/E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,gBAAgB,GAAG,YAAY,CAAC;IACjD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,8BAA8B,CAClD,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAA;CAAO,GAC3B,OAAO,CAAC,wBAAwB,EAAE,CAAC,CA0FrC"}
@@ -0,0 +1,107 @@
1
+ /** Verified in-place compression for sealed, non-terminal legacy V1 shards. */
2
+ import { createReadStream, createWriteStream } from "node:fs";
3
+ import { chmod, lstat, rename, rm } from "node:fs/promises";
4
+ import { basename } from "node:path";
5
+ import { pipeline } from "node:stream/promises";
6
+ import { createGzip } from "node:zlib";
7
+ import { verifyLegacyV1HardFence } from "./fence.js";
8
+ import { inventoryLegacyV1Segments } from "./inventory.js";
9
+ import { streamLegacyV1Rows } from "./reader.js";
10
+ export async function compressSealedLegacyV1Segments(coordRoot, opts = {}) {
11
+ const fence = await verifyLegacyV1HardFence(coordRoot);
12
+ const terminal = basename(fence.terminal_archive_path);
13
+ const inventory = await inventoryLegacyV1Segments(coordRoot);
14
+ const rows = inventory.map((entry) => {
15
+ if (entry.filename === terminal) {
16
+ return {
17
+ filename: entry.filename,
18
+ path: entry.path,
19
+ bytes_before: entry.bytes,
20
+ bytes_after: null,
21
+ action: "keep",
22
+ reason: "terminal shard is bound by the V1 hard-fence digest",
23
+ };
24
+ }
25
+ if (entry.compressed) {
26
+ return {
27
+ filename: entry.filename,
28
+ path: entry.path,
29
+ bytes_before: entry.bytes,
30
+ bytes_after: entry.bytes,
31
+ action: "keep",
32
+ reason: "already compressed",
33
+ };
34
+ }
35
+ return {
36
+ filename: entry.filename,
37
+ path: entry.path,
38
+ bytes_before: entry.bytes,
39
+ bytes_after: null,
40
+ action: "would-compress",
41
+ reason: "sealed non-terminal V1 shard",
42
+ };
43
+ });
44
+ if (!opts.yes)
45
+ return rows;
46
+ for (const row of rows) {
47
+ if (row.action !== "would-compress")
48
+ continue;
49
+ const expected = inventory.find((entry) => entry.path === row.path);
50
+ const current = (await inventoryLegacyV1Segments(coordRoot)).find((entry) => entry.path === row.path);
51
+ if (!current ||
52
+ current.bytes !== expected.bytes ||
53
+ current.digest !== expected.digest ||
54
+ current.compressed) {
55
+ throw new Error(`legacy_v1_segment_changed_before_compression:${row.filename}`);
56
+ }
57
+ const sourceStat = await lstat(row.path);
58
+ const destination = `${row.path}.gz`;
59
+ const temporary = `${row.path}.partial-${process.pid}.gz`;
60
+ try {
61
+ try {
62
+ await lstat(destination);
63
+ throw new Error(`legacy_v1_compressed_destination_exists:${row.filename}`);
64
+ }
65
+ catch (error) {
66
+ if (error.code !== "ENOENT")
67
+ throw error;
68
+ }
69
+ await pipeline(createReadStream(row.path), createGzip({ level: 9 }), createWriteStream(temporary, { flags: "wx", mode: 0o600 }));
70
+ await proveRowParity(row.path, temporary);
71
+ const unchanged = (await inventoryLegacyV1Segments(coordRoot)).find((entry) => entry.path === row.path);
72
+ if (!unchanged ||
73
+ unchanged.bytes !== expected.bytes ||
74
+ unchanged.digest !== expected.digest) {
75
+ throw new Error(`legacy_v1_segment_changed_during_compression:${row.filename}`);
76
+ }
77
+ await chmod(temporary, sourceStat.mode & 0o777);
78
+ await rename(temporary, destination);
79
+ await rm(row.path);
80
+ row.action = "compressed";
81
+ row.reason = "verified gzip replacement preserved every logical row";
82
+ row.bytes_after = (await lstat(destination)).size;
83
+ row.path = destination;
84
+ row.filename = basename(destination);
85
+ }
86
+ catch (error) {
87
+ await rm(temporary, { force: true });
88
+ throw error;
89
+ }
90
+ }
91
+ return rows;
92
+ }
93
+ async function proveRowParity(loose, compressed) {
94
+ const left = streamLegacyV1Rows(loose)[Symbol.asyncIterator]();
95
+ const right = streamLegacyV1Rows(compressed)[Symbol.asyncIterator]();
96
+ while (true) {
97
+ const [looseRow, packedRow] = await Promise.all([left.next(), right.next()]);
98
+ if (looseRow.done || packedRow.done) {
99
+ if (looseRow.done !== packedRow.done)
100
+ throw new Error("legacy_v1_compression_row_count_mismatch");
101
+ return;
102
+ }
103
+ if (!looseRow.value.bytes.equals(packedRow.value.bytes)) {
104
+ throw new Error(`legacy_v1_compression_row_mismatch:${looseRow.value.row_number}`);
105
+ }
106
+ }
107
+ }
@@ -1,4 +1,5 @@
1
1
  export * from "./canary.js";
2
+ export * from "./compression.js";
2
3
  export * from "./fence.js";
3
4
  export * from "./inventory.js";
4
5
  export * from "./manifest.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/events/legacy-storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/events/legacy-storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from "./canary.js";
2
+ export * from "./compression.js";
2
3
  export * from "./fence.js";
3
4
  export * from "./inventory.js";
4
5
  export * from "./manifest.js";
@@ -0,0 +1,33 @@
1
+ /** Bounded retention for complete, closed Event Ledger V3 epochs. */
2
+ import { type EventLedgerArchivePolicy } from "../../config.js";
3
+ export type EventV3ArchiveClassification = "retained" | "expired" | "over-budget" | "protected-minimum" | "unmanaged" | "symlink" | "unknown";
4
+ export interface EventV3ArchiveEntry {
5
+ name: string;
6
+ path: string;
7
+ relative_path: string;
8
+ classification: EventV3ArchiveClassification;
9
+ reason: string;
10
+ action: "keep" | "would-delete" | "deleted";
11
+ bytes: number | null;
12
+ last_modified_at: string | null;
13
+ }
14
+ export interface EventV3ArchiveAutoCleanResult {
15
+ ran: boolean;
16
+ reason: "swept" | "disabled" | "fresh" | "no-root";
17
+ deleted: number;
18
+ bytes: number;
19
+ }
20
+ export declare function eventV3ArchivesRoot(repoRoot: string): string;
21
+ export declare function inventoryEventV3Archives(repoRoot: string, opts?: {
22
+ now?: Date;
23
+ policy?: EventLedgerArchivePolicy;
24
+ }): EventV3ArchiveEntry[];
25
+ export declare function cleanEventV3Archives(repoRoot: string, opts?: {
26
+ yes?: boolean;
27
+ now?: Date;
28
+ policy?: EventLedgerArchivePolicy;
29
+ }): EventV3ArchiveEntry[];
30
+ export declare function autoCleanEventV3Archives(repoRoot: string, opts?: {
31
+ now?: Date;
32
+ }): EventV3ArchiveAutoCleanResult;
33
+ //# sourceMappingURL=archive-retention.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive-retention.d.ts","sourceRoot":"","sources":["../../../../src/core/events/v3/archive-retention.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAYrE,OAAO,EAEL,KAAK,wBAAwB,EAE9B,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,4BAA4B,GACpC,UAAU,GACV,SAAS,GACT,aAAa,GACb,mBAAmB,GACnB,WAAW,GACX,SAAS,GACT,SAAS,CAAC;AAEd,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,4BAA4B,CAAC;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IAC5C,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,6BAA6B;IAC5C,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;IACnD,OAA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