claude-memory-layer 1.0.30 → 1.0.32

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 (338) hide show
  1. package/README.md +12 -5
  2. package/dist/cli/index.js +4 -3
  3. package/dist/cli/index.js.map +2 -2
  4. package/dist/core/index.js +3 -2
  5. package/dist/core/index.js.map +2 -2
  6. package/dist/hooks/post-tool-use.js +3 -2
  7. package/dist/hooks/post-tool-use.js.map +2 -2
  8. package/dist/hooks/semantic-daemon.js +3 -2
  9. package/dist/hooks/semantic-daemon.js.map +2 -2
  10. package/dist/hooks/session-end.js +3 -2
  11. package/dist/hooks/session-end.js.map +2 -2
  12. package/dist/hooks/session-start.js +3 -2
  13. package/dist/hooks/session-start.js.map +2 -2
  14. package/dist/hooks/stop.js +3 -2
  15. package/dist/hooks/stop.js.map +2 -2
  16. package/dist/hooks/user-prompt-submit.js +3 -2
  17. package/dist/hooks/user-prompt-submit.js.map +2 -2
  18. package/dist/index.js +3 -2
  19. package/dist/index.js.map +2 -2
  20. package/dist/mcp/index.js +3 -2
  21. package/dist/mcp/index.js.map +2 -2
  22. package/dist/server/api/index.js +3 -2
  23. package/dist/server/api/index.js.map +2 -2
  24. package/dist/server/index.js +3 -2
  25. package/dist/server/index.js.map +2 -2
  26. package/dist/services/memory-service.js +3 -2
  27. package/dist/services/memory-service.js.map +2 -2
  28. package/package.json +10 -3
  29. package/scripts/postinstall-embedding-backend.cjs +18 -16
  30. package/AGENTS.md +0 -71
  31. package/CLAUDE.md +0 -30
  32. package/HANDOFF.md +0 -92
  33. package/Memo.txt +0 -558
  34. package/benchmarks/replay/anonymized-real-sessions.json +0 -48
  35. package/config/kpi-thresholds.json +0 -7
  36. package/context.md +0 -636
  37. package/docs/ARCHITECTURE_COMPARISON_AND_RECOMMENDATIONS.md +0 -627
  38. package/docs/HERMES_MEMORY_INGESTION_ANALYSIS.md +0 -440
  39. package/docs/MCP_MEMORY_SERVICE_COMPARATIVE_REVIEW.md +0 -271
  40. package/docs/MEMORY_USEFULNESS_AUDIT.md +0 -371
  41. package/docs/MEMORY_USEFULNESS_AUDIT_RAW.json +0 -80
  42. package/docs/MEMSEARCH_PROJECT_STRUCTURE_ANALYSIS.md +0 -333
  43. package/docs/MEMU_ADOPTION.md +0 -40
  44. package/docs/OPERATIONS.md +0 -18
  45. package/docs/PRODUCT_VALIDATION_MATRIX.md +0 -82
  46. package/docs/PROJECT_STRUCTURE_ANALYSIS.md +0 -421
  47. package/docs/REFACTORING_MILESTONES_AND_ISSUES.md +0 -501
  48. package/docs/REFACTORING_PLAN_THIN_CORE.md +0 -414
  49. package/docs/REFERENCE_PROJECT_ANALYSES.md +0 -25
  50. package/docs/SUPERLOCALMEMORY_PROJECT_STRUCTURE_ANALYSIS.md +0 -452
  51. package/docs/TARGET_ARCHITECTURE_AND_FOLDER_STRUCTURE.md +0 -446
  52. package/docs/architecture/comparison-index.md +0 -47
  53. package/docs/reports/codex-real-data-validation-20260505T040447Z.md +0 -46
  54. package/plan.md +0 -1642
  55. package/scripts/build.ts +0 -159
  56. package/scripts/bump-patch-version.sh +0 -18
  57. package/scripts/delete-unknown-projects.js +0 -154
  58. package/scripts/fix-sync-gap.js +0 -32
  59. package/scripts/generate-session-qrels.ts +0 -126
  60. package/scripts/heartbeat-memory-orchestrator.sh +0 -28
  61. package/scripts/replay-retrieval-benchmark.ts +0 -69
  62. package/scripts/report-sync-gap.js +0 -26
  63. package/scripts/review-queue-auto-resolve.js +0 -21
  64. package/scripts/sync-gap-auto-heal.sh +0 -17
  65. package/spec.md +0 -624
  66. package/specs/20260207-dashboard-upgrade/context.md +0 -38
  67. package/specs/20260207-dashboard-upgrade/spec.md +0 -96
  68. package/specs/citations-system/context.md +0 -243
  69. package/specs/citations-system/plan.md +0 -495
  70. package/specs/citations-system/spec.md +0 -371
  71. package/specs/endless-mode/context.md +0 -305
  72. package/specs/endless-mode/plan.md +0 -620
  73. package/specs/endless-mode/spec.md +0 -455
  74. package/specs/entity-edge-model/context.md +0 -401
  75. package/specs/entity-edge-model/plan.md +0 -459
  76. package/specs/entity-edge-model/spec.md +0 -391
  77. package/specs/evidence-aligner-v2/context.md +0 -401
  78. package/specs/evidence-aligner-v2/plan.md +0 -303
  79. package/specs/evidence-aligner-v2/spec.md +0 -312
  80. package/specs/mcp-desktop-integration/context.md +0 -278
  81. package/specs/mcp-desktop-integration/plan.md +0 -550
  82. package/specs/mcp-desktop-integration/spec.md +0 -494
  83. package/specs/memory-utilization-improvements/context.md +0 -145
  84. package/specs/memory-utilization-improvements/plan.md +0 -361
  85. package/specs/memory-utilization-improvements/spec.md +0 -361
  86. package/specs/post-tool-use-hook/context.md +0 -319
  87. package/specs/post-tool-use-hook/plan.md +0 -469
  88. package/specs/post-tool-use-hook/spec.md +0 -364
  89. package/specs/private-tags/context.md +0 -288
  90. package/specs/private-tags/plan.md +0 -412
  91. package/specs/private-tags/spec.md +0 -345
  92. package/specs/progressive-disclosure/context.md +0 -346
  93. package/specs/progressive-disclosure/plan.md +0 -663
  94. package/specs/progressive-disclosure/spec.md +0 -415
  95. package/specs/selective-tool-observation/context.md +0 -100
  96. package/specs/selective-tool-observation/plan.md +0 -158
  97. package/specs/selective-tool-observation/spec.md +0 -127
  98. package/specs/task-entity-system/context.md +0 -297
  99. package/specs/task-entity-system/plan.md +0 -301
  100. package/specs/task-entity-system/spec.md +0 -314
  101. package/specs/thin-core-refactor/context.md +0 -275
  102. package/specs/thin-core-refactor/plan.md +0 -536
  103. package/specs/thin-core-refactor/spec.md +0 -465
  104. package/specs/vector-outbox-v2/context.md +0 -470
  105. package/specs/vector-outbox-v2/plan.md +0 -562
  106. package/specs/vector-outbox-v2/spec.md +0 -466
  107. package/specs/web-viewer-ui/context.md +0 -384
  108. package/specs/web-viewer-ui/plan.md +0 -797
  109. package/specs/web-viewer-ui/spec.md +0 -516
  110. package/src/adapters/claude/capture/index.ts +0 -3
  111. package/src/adapters/claude/context/index.ts +0 -3
  112. package/src/adapters/claude/hooks/index.ts +0 -21
  113. package/src/adapters/claude/hooks/post-tool-use.ts +0 -239
  114. package/src/adapters/claude/hooks/prompt-injection-policy.ts +0 -104
  115. package/src/adapters/claude/hooks/semantic-daemon-client.ts +0 -209
  116. package/src/adapters/claude/hooks/semantic-daemon.ts +0 -283
  117. package/src/adapters/claude/hooks/session-end.ts +0 -59
  118. package/src/adapters/claude/hooks/session-start.ts +0 -73
  119. package/src/adapters/claude/hooks/stop.ts +0 -128
  120. package/src/adapters/claude/hooks/user-prompt-submit.ts +0 -361
  121. package/src/adapters/claude/index.ts +0 -4
  122. package/src/adapters/claude/transcript/index.ts +0 -4
  123. package/src/adapters/claude/transcript/transcript-reader.ts +0 -57
  124. package/src/adapters/claude/transcript/turn-reconstructor.ts +0 -65
  125. package/src/apps/cli/claude-settings-hooks.ts +0 -138
  126. package/src/apps/cli/codex-import-runner.ts +0 -125
  127. package/src/apps/cli/codex-validation-output.ts +0 -95
  128. package/src/apps/cli/hermes-import-runner.ts +0 -130
  129. package/src/apps/cli/hermes-validation-output.ts +0 -91
  130. package/src/apps/cli/index.ts +0 -1735
  131. package/src/apps/cli/mcp-install.ts +0 -106
  132. package/src/apps/cli/retrieval-disclosure-output.ts +0 -196
  133. package/src/apps/dashboard/assets/js/bootstrap.js +0 -244
  134. package/src/apps/dashboard/assets/js/chat.js +0 -373
  135. package/src/apps/dashboard/assets/js/disclosure.js +0 -232
  136. package/src/apps/dashboard/assets/js/modals.js +0 -298
  137. package/src/apps/dashboard/assets/js/overview.js +0 -655
  138. package/src/apps/dashboard/assets/js/state.js +0 -72
  139. package/src/apps/dashboard/assets/js/views.js +0 -468
  140. package/src/apps/dashboard/index.html +0 -543
  141. package/src/apps/dashboard/index.ts +0 -3
  142. package/src/apps/dashboard/style.css +0 -1750
  143. package/src/apps/index.ts +0 -5
  144. package/src/apps/server/api/chat.ts +0 -244
  145. package/src/apps/server/api/citations.ts +0 -105
  146. package/src/apps/server/api/events.ts +0 -137
  147. package/src/apps/server/api/health.ts +0 -53
  148. package/src/apps/server/api/index.ts +0 -26
  149. package/src/apps/server/api/projects.ts +0 -74
  150. package/src/apps/server/api/search.ts +0 -184
  151. package/src/apps/server/api/sessions.ts +0 -115
  152. package/src/apps/server/api/stats.ts +0 -723
  153. package/src/apps/server/api/turns.ts +0 -143
  154. package/src/apps/server/api/utils.ts +0 -65
  155. package/src/apps/server/index.ts +0 -111
  156. package/src/cli/index.ts +0 -3
  157. package/src/cli/retrieval-disclosure-output.ts +0 -2
  158. package/src/compat/index.ts +0 -5
  159. package/src/core/canonical-key.ts +0 -186
  160. package/src/core/citation-generator.ts +0 -63
  161. package/src/core/consolidated-store.ts +0 -356
  162. package/src/core/consolidation-worker.ts +0 -493
  163. package/src/core/context-formatter.ts +0 -276
  164. package/src/core/continuity-manager.ts +0 -341
  165. package/src/core/db-wrapper.ts +0 -64
  166. package/src/core/derive/fact-deriver.ts +0 -170
  167. package/src/core/derive/index.ts +0 -2
  168. package/src/core/derive/summary-deriver.ts +0 -76
  169. package/src/core/edge-repo.ts +0 -333
  170. package/src/core/embedder.ts +0 -4
  171. package/src/core/engine/embedding-maintenance-service.ts +0 -187
  172. package/src/core/engine/endless-memory-services.ts +0 -4
  173. package/src/core/engine/index.ts +0 -19
  174. package/src/core/engine/memory-engine-services.ts +0 -170
  175. package/src/core/engine/memory-ingest-service.ts +0 -317
  176. package/src/core/engine/memory-query-service.ts +0 -173
  177. package/src/core/engine/memory-runtime-service.ts +0 -162
  178. package/src/core/engine/memory-service-composition.ts +0 -231
  179. package/src/core/engine/retrieval-analytics-service.ts +0 -181
  180. package/src/core/engine/retrieval-disclosure-service.ts +0 -420
  181. package/src/core/engine/retrieval-orchestrator.ts +0 -377
  182. package/src/core/engine/retrieval-services.ts +0 -176
  183. package/src/core/engine/shared-memory-services.ts +0 -4
  184. package/src/core/entity-repo.ts +0 -349
  185. package/src/core/event-store.ts +0 -779
  186. package/src/core/evidence-aligner.ts +0 -635
  187. package/src/core/external-market-context.ts +0 -582
  188. package/src/core/graduation-worker.ts +0 -171
  189. package/src/core/graduation.ts +0 -377
  190. package/src/core/index.ts +0 -64
  191. package/src/core/ingest-interceptor.ts +0 -80
  192. package/src/core/markdown-mirror.ts +0 -70
  193. package/src/core/matcher.ts +0 -208
  194. package/src/core/md-mirror.ts +0 -92
  195. package/src/core/metadata-extractor.ts +0 -203
  196. package/src/core/model/memory-fact.ts +0 -30
  197. package/src/core/model/memory-rule.ts +0 -14
  198. package/src/core/model/memory-summary.ts +0 -21
  199. package/src/core/model/raw-event.ts +0 -28
  200. package/src/core/model/retrieval-result.ts +0 -35
  201. package/src/core/mongo-sync-config.ts +0 -165
  202. package/src/core/mongo-sync-worker.ts +0 -381
  203. package/src/core/privacy/filter.ts +0 -190
  204. package/src/core/privacy/index.ts +0 -20
  205. package/src/core/privacy/tag-parser.ts +0 -145
  206. package/src/core/product-validation-matrix.ts +0 -314
  207. package/src/core/progressive-retriever.ts +0 -414
  208. package/src/core/registry/project-path.ts +0 -54
  209. package/src/core/registry/session-registry.ts +0 -69
  210. package/src/core/replay-evaluator.ts +0 -625
  211. package/src/core/retrieval-benchmark.ts +0 -117
  212. package/src/core/retrieval-quality.ts +0 -109
  213. package/src/core/retriever.ts +0 -800
  214. package/src/core/session-qrels.ts +0 -360
  215. package/src/core/shared-event-store.ts +0 -114
  216. package/src/core/shared-promoter.ts +0 -249
  217. package/src/core/shared-store.ts +0 -289
  218. package/src/core/shared-vector-store.ts +0 -203
  219. package/src/core/sqlite-event-store.ts +0 -1846
  220. package/src/core/sqlite-wrapper.ts +0 -116
  221. package/src/core/sync-worker.ts +0 -228
  222. package/src/core/tag-taxonomy.ts +0 -51
  223. package/src/core/task/blocker-resolver.ts +0 -333
  224. package/src/core/task/index.ts +0 -9
  225. package/src/core/task/task-matcher.ts +0 -240
  226. package/src/core/task/task-projector.ts +0 -358
  227. package/src/core/task/task-resolver.ts +0 -421
  228. package/src/core/turn-state.ts +0 -207
  229. package/src/core/types.ts +0 -952
  230. package/src/core/vector-outbox.ts +0 -299
  231. package/src/core/vector-store.ts +0 -231
  232. package/src/core/vector-worker.ts +0 -521
  233. package/src/core/working-set-store.ts +0 -257
  234. package/src/extensions/endless-memory/endless-memory-services.ts +0 -350
  235. package/src/extensions/endless-memory/index.ts +0 -1
  236. package/src/extensions/index.ts +0 -5
  237. package/src/extensions/mcp/handlers.ts +0 -960
  238. package/src/extensions/mcp/index.ts +0 -48
  239. package/src/extensions/mcp/tools.ts +0 -252
  240. package/src/extensions/shared-memory/index.ts +0 -1
  241. package/src/extensions/shared-memory/shared-memory-services.ts +0 -211
  242. package/src/extensions/vector/embedder.ts +0 -233
  243. package/src/extensions/vector/index.ts +0 -1
  244. package/src/hooks/post-tool-use.ts +0 -9
  245. package/src/hooks/semantic-daemon-client.ts +0 -1
  246. package/src/hooks/semantic-daemon.ts +0 -11
  247. package/src/hooks/session-end.ts +0 -9
  248. package/src/hooks/session-start.ts +0 -9
  249. package/src/hooks/stop.ts +0 -9
  250. package/src/hooks/user-prompt-submit.ts +0 -9
  251. package/src/index.ts +0 -13
  252. package/src/mcp/handlers.ts +0 -2
  253. package/src/mcp/index.ts +0 -4
  254. package/src/mcp/tools.ts +0 -2
  255. package/src/server/api/chat.ts +0 -2
  256. package/src/server/api/citations.ts +0 -2
  257. package/src/server/api/events.ts +0 -2
  258. package/src/server/api/health.ts +0 -2
  259. package/src/server/api/index.ts +0 -2
  260. package/src/server/api/projects.ts +0 -2
  261. package/src/server/api/search.ts +0 -2
  262. package/src/server/api/sessions.ts +0 -2
  263. package/src/server/api/stats.ts +0 -2
  264. package/src/server/api/turns.ts +0 -2
  265. package/src/server/api/utils.ts +0 -2
  266. package/src/server/index.ts +0 -2
  267. package/src/services/bootstrap-organizer.ts +0 -463
  268. package/src/services/codex-session-history-importer.ts +0 -966
  269. package/src/services/hermes-session-history-importer.ts +0 -733
  270. package/src/services/memory-service-config.ts +0 -36
  271. package/src/services/memory-service-registry.ts +0 -150
  272. package/src/services/memory-service.ts +0 -688
  273. package/src/services/session-history-importer.ts +0 -629
  274. package/tests/README.md +0 -23
  275. package/tests/adapters/claude/claude-semantic-daemon-adapter.test.ts +0 -54
  276. package/tests/adapters/claude/claude-transcript-reconstructor.test.ts +0 -98
  277. package/tests/adapters/claude-hook-prompt-injection-policy.test.ts +0 -99
  278. package/tests/apps/app-layer-boundary.test.ts +0 -48
  279. package/tests/apps/claude-settings-hooks.test.ts +0 -107
  280. package/tests/apps/cli-disclosure-output.test.ts +0 -212
  281. package/tests/apps/codex-import-runner.test.ts +0 -99
  282. package/tests/apps/codex-validation-output.test.ts +0 -100
  283. package/tests/apps/hermes-import-runner.test.ts +0 -99
  284. package/tests/apps/mcp-install-command.test.ts +0 -59
  285. package/tests/apps/package-build-entrypoints.test.ts +0 -30
  286. package/tests/apps/postinstall-embedding-backend.test.ts +0 -175
  287. package/tests/apps/search-api-disclosure.test.ts +0 -162
  288. package/tests/apps/stats-api-lightweight.test.ts +0 -67
  289. package/tests/apps/ui-disclosure-output.test.ts +0 -140
  290. package/tests/core/bootstrap-organizer.test.ts +0 -111
  291. package/tests/core/canonical-key.test.ts +0 -101
  292. package/tests/core/codex-session-history-importer-validation.test.ts +0 -185
  293. package/tests/core/consolidation-worker.test.ts +0 -75
  294. package/tests/core/embedding-maintenance-service.test.ts +0 -282
  295. package/tests/core/evidence-aligner.test.ts +0 -152
  296. package/tests/core/external-market-context.test.ts +0 -209
  297. package/tests/core/fact-deriver.test.ts +0 -79
  298. package/tests/core/hermes-session-history-importer-validation.test.ts +0 -609
  299. package/tests/core/ingest-interceptor.test.ts +0 -38
  300. package/tests/core/markdown-mirror.test.ts +0 -85
  301. package/tests/core/matcher.test.ts +0 -112
  302. package/tests/core/md-mirror.test.ts +0 -50
  303. package/tests/core/memory-engine-services.test.ts +0 -240
  304. package/tests/core/memory-ingest-service.test.ts +0 -296
  305. package/tests/core/memory-query-service.test.ts +0 -129
  306. package/tests/core/memory-runtime-service.test.ts +0 -201
  307. package/tests/core/memory-service-composition.test.ts +0 -192
  308. package/tests/core/memory-service-config.test.ts +0 -41
  309. package/tests/core/memory-service-facade.test.ts +0 -30
  310. package/tests/core/memory-service-registry.test.ts +0 -206
  311. package/tests/core/product-validation-matrix.test.ts +0 -61
  312. package/tests/core/project-registry.test.ts +0 -78
  313. package/tests/core/replay-evaluator.test.ts +0 -181
  314. package/tests/core/retrieval-analytics-service.test.ts +0 -210
  315. package/tests/core/retrieval-benchmark.test.ts +0 -93
  316. package/tests/core/retrieval-disclosure-service.test.ts +0 -264
  317. package/tests/core/retrieval-orchestrator.test.ts +0 -403
  318. package/tests/core/retrieval-quality.test.ts +0 -31
  319. package/tests/core/retrieval-services.test.ts +0 -185
  320. package/tests/core/retriever-fallback-chain.test.ts +0 -223
  321. package/tests/core/retriever-strategy-scope.test.ts +0 -164
  322. package/tests/core/retriever.memu-adoption.test.ts +0 -122
  323. package/tests/core/session-history-importer-filter.test.ts +0 -78
  324. package/tests/core/session-qrels.test.ts +0 -250
  325. package/tests/core/sqlite-event-store-replication.test.ts +0 -127
  326. package/tests/core/summary-deriver.test.ts +0 -66
  327. package/tests/extensions/embedder-warning-suppression.test.ts +0 -83
  328. package/tests/extensions/endless-memory-extension-boundary.test.ts +0 -17
  329. package/tests/extensions/endless-memory-services.test.ts +0 -325
  330. package/tests/extensions/mcp-context-tools.test.ts +0 -905
  331. package/tests/extensions/mcp-extension-boundary.test.ts +0 -21
  332. package/tests/extensions/mcp-package-build.test.ts +0 -22
  333. package/tests/extensions/mcp-project-aware-tools.test.ts +0 -102
  334. package/tests/extensions/shared-memory-extension-boundary.test.ts +0 -24
  335. package/tests/extensions/shared-memory-services.test.ts +0 -309
  336. package/tests/extensions/vector-extension-boundary.test.ts +0 -21
  337. package/tsconfig.json +0 -24
  338. package/vitest.config.ts +0 -15
@@ -1,190 +0,0 @@
1
- /**
2
- * Privacy Filter
3
- * Combines pattern-based filtering with private tag parsing
4
- */
5
-
6
- import { parsePrivateTagsSafe, hasUnmatchedOpenTag } from './tag-parser.js';
7
- import type { Config } from '../types.js';
8
-
9
- export interface FilterResult {
10
- content: string;
11
- metadata: {
12
- hasPrivateTags: boolean;
13
- privateTagCount: number;
14
- patternMatchCount: number;
15
- originalLength: number;
16
- filteredLength: number;
17
- hasUnmatchedTags: boolean;
18
- };
19
- }
20
-
21
- // Sensitive data patterns
22
- const SENSITIVE_PATTERNS = [
23
- // Credential-bearing URLs/connection strings with userinfo before the host.
24
- // Redact the whole URI so usernames, credentials, hosts, paths, and query
25
- // params do not leak either.
26
- /\b[a-z][a-z0-9+.-]*:\/\/[^\s'"`<>/@]+@[^\s'"`<>]+/gi,
27
- /password\s*[:=]\s*['"]?[^\s'"]+/gi,
28
- /api[_-]?key\s*[:=]\s*['"]?[^\s'"]+/gi,
29
- /secret\s*[:=]\s*['"]?[^\s'"]+/gi,
30
- /token\s*[:=]\s*['"]?[^\s'"]+/gi,
31
- /bearer\s+[a-zA-Z0-9\-_.]+/gi,
32
- /AWS[_-]?ACCESS[_-]?KEY[_-]?ID\s*[:=]\s*['"]?[A-Z0-9]+/gi,
33
- /AWS[_-]?SECRET[_-]?ACCESS[_-]?KEY\s*[:=]\s*['"]?[^\s'"]+/gi,
34
- /-----BEGIN\s+(RSA\s+)?PRIVATE\s+KEY-----[\s\S]*?-----END\s+(RSA\s+)?PRIVATE\s+KEY-----/g,
35
- /ghp_[a-zA-Z0-9]{36}/g, // GitHub Personal Access Token
36
- /sk-[a-zA-Z0-9]{48}/g, // OpenAI API Key
37
- ];
38
-
39
- function maskSensitiveString(value: string): string {
40
- let filtered = value;
41
- for (const pattern of SENSITIVE_PATTERNS) {
42
- pattern.lastIndex = 0;
43
- filtered = filtered.replace(pattern, '[REDACTED]');
44
- }
45
- return filtered;
46
- }
47
-
48
- /**
49
- * Apply privacy filter to content
50
- */
51
- export function applyPrivacyFilter(
52
- content: string,
53
- config: Config['privacy']
54
- ): FilterResult {
55
- let filtered = content;
56
- let privateTagCount = 0;
57
- let patternMatchCount = 0;
58
- const hasUnmatchedTags = hasUnmatchedOpenTag(content);
59
-
60
- // 1. Private tag filtering
61
- if (config.privateTags?.enabled !== false) {
62
- const tagResult = parsePrivateTagsSafe(filtered, {
63
- formats: config.privateTags?.supportedFormats || ['xml'],
64
- marker: config.privateTags?.marker || '[PRIVATE]'
65
- });
66
- filtered = tagResult.filtered;
67
- privateTagCount = tagResult.stats.count;
68
- }
69
-
70
- // 2. Built-in sensitive pattern filtering
71
- for (const pattern of SENSITIVE_PATTERNS) {
72
- // Reset lastIndex for global regex
73
- pattern.lastIndex = 0;
74
- const matches = filtered.match(pattern);
75
- if (matches) {
76
- patternMatchCount += matches.length;
77
- filtered = filtered.replace(pattern, '[REDACTED]');
78
- }
79
- }
80
-
81
- // 3. Custom pattern filtering from config
82
- for (const patternStr of config.excludePatterns || []) {
83
- try {
84
- const regex = new RegExp(
85
- `(${patternStr})\\s*[:=]\\s*['"]?[^\\s'"]+`,
86
- 'gi'
87
- );
88
- const matches = filtered.match(regex);
89
- if (matches) {
90
- patternMatchCount += matches.length;
91
- filtered = filtered.replace(regex, '[REDACTED]');
92
- }
93
- } catch {
94
- // Invalid regex pattern, skip
95
- }
96
- }
97
-
98
- // 4. Clean up consecutive markers
99
- filtered = filtered.replace(/(\[PRIVATE\]\s*)+/g, '[PRIVATE]\n');
100
- filtered = filtered.replace(/(\[REDACTED\]\s*)+/g, '[REDACTED] ');
101
-
102
- return {
103
- content: filtered,
104
- metadata: {
105
- hasPrivateTags: privateTagCount > 0,
106
- privateTagCount,
107
- patternMatchCount,
108
- originalLength: content.length,
109
- filteredLength: filtered.length,
110
- hasUnmatchedTags
111
- }
112
- };
113
- }
114
-
115
- /**
116
- * Mask sensitive data in tool input (recursively)
117
- */
118
- export function maskSensitiveInput(
119
- input: Record<string, unknown>
120
- ): Record<string, unknown> {
121
- const result: Record<string, unknown> = {};
122
-
123
- for (const [key, value] of Object.entries(input)) {
124
- // Check if key suggests sensitive data
125
- const sensitiveKeys = ['password', 'secret', 'key', 'token', 'auth', 'credential'];
126
- const isSensitiveKey = sensitiveKeys.some(k =>
127
- key.toLowerCase().includes(k)
128
- );
129
-
130
- if (isSensitiveKey && typeof value === 'string') {
131
- result[key] = '[REDACTED]';
132
- } else if (typeof value === 'string') {
133
- // Apply pattern filtering to string values
134
- result[key] = maskSensitiveString(value);
135
- } else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
136
- result[key] = maskSensitiveInput(value as Record<string, unknown>);
137
- } else if (Array.isArray(value)) {
138
- result[key] = value.map(item => {
139
- if (typeof item === 'string') {
140
- return isSensitiveKey ? '[REDACTED]' : maskSensitiveString(item);
141
- }
142
- return typeof item === 'object' && item !== null
143
- ? maskSensitiveInput(item as Record<string, unknown>)
144
- : item;
145
- });
146
- } else {
147
- result[key] = value;
148
- }
149
- }
150
-
151
- return result;
152
- }
153
-
154
- /**
155
- * Truncate output with head + tail strategy
156
- */
157
- export function truncateOutput(
158
- output: string,
159
- options: { maxLength?: number; maxLines?: number }
160
- ): string {
161
- const { maxLength = 10000, maxLines = 100 } = options;
162
-
163
- // Split into lines
164
- const lines = output.split('\n');
165
-
166
- // Apply line limit first
167
- if (lines.length > maxLines) {
168
- const headLines = Math.ceil(maxLines / 2);
169
- const tailLines = Math.floor(maxLines / 2);
170
- const head = lines.slice(0, headLines);
171
- const tail = lines.slice(-tailLines);
172
- const truncatedLines = [
173
- ...head,
174
- `\n... [${lines.length - maxLines} lines truncated] ...\n`,
175
- ...tail
176
- ];
177
- output = truncatedLines.join('\n');
178
- }
179
-
180
- // Apply character limit
181
- if (output.length > maxLength) {
182
- const headChars = Math.ceil(maxLength / 2);
183
- const tailChars = Math.floor(maxLength / 2);
184
- output = output.slice(0, headChars) +
185
- `\n... [${output.length - maxLength} characters truncated] ...\n` +
186
- output.slice(-tailChars);
187
- }
188
-
189
- return output;
190
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Privacy Module
3
- * Exports privacy-related utilities
4
- */
5
-
6
- export {
7
- parsePrivateTags,
8
- parsePrivateTagsSafe,
9
- hasUnmatchedOpenTag,
10
- type PrivateSection,
11
- type ParseResult,
12
- type ParseOptions
13
- } from './tag-parser.js';
14
-
15
- export {
16
- applyPrivacyFilter,
17
- maskSensitiveInput,
18
- truncateOutput,
19
- type FilterResult
20
- } from './filter.js';
@@ -1,145 +0,0 @@
1
- /**
2
- * Private Tag Parser
3
- * Parses and removes <private> tags from content
4
- */
5
-
6
- export interface PrivateSection {
7
- start: number;
8
- end: number;
9
- content: string;
10
- format: 'xml' | 'bracket' | 'comment';
11
- }
12
-
13
- export interface ParseResult {
14
- filtered: string;
15
- sections: PrivateSection[];
16
- stats: {
17
- count: number;
18
- totalLength: number;
19
- };
20
- }
21
-
22
- export interface ParseOptions {
23
- formats: Array<'xml' | 'bracket' | 'comment'>;
24
- marker: string;
25
- }
26
-
27
- // Tag patterns for different formats
28
- const TAG_PATTERNS: Record<string, RegExp> = {
29
- xml: /<private>([\s\S]*?)<\/private>/gi,
30
- bracket: /\[private\]([\s\S]*?)\[\/private\]/gi,
31
- comment: /<!--\s*private\s*-->([\s\S]*?)<!--\s*\/private\s*-->/gi
32
- };
33
-
34
- /**
35
- * Parse and remove private tags from text
36
- */
37
- export function parsePrivateTags(
38
- text: string,
39
- options: ParseOptions
40
- ): ParseResult {
41
- const sections: PrivateSection[] = [];
42
- let filtered = text;
43
-
44
- // Find all private sections for each format
45
- for (const format of options.formats) {
46
- const pattern = TAG_PATTERNS[format];
47
- if (!pattern) continue;
48
-
49
- // Reset lastIndex for global regex
50
- pattern.lastIndex = 0;
51
-
52
- let match;
53
- while ((match = pattern.exec(text)) !== null) {
54
- sections.push({
55
- start: match.index,
56
- end: match.index + match[0].length,
57
- content: match[1],
58
- format: format as PrivateSection['format']
59
- });
60
- }
61
- }
62
-
63
- // Remove all tags and replace with marker
64
- for (const format of options.formats) {
65
- const pattern = TAG_PATTERNS[format];
66
- if (!pattern) continue;
67
-
68
- // Need to create new regex for replacement (global flag issues)
69
- const replacePattern = new RegExp(pattern.source, 'gi');
70
-
71
- filtered = filtered.replace(replacePattern, (_match, content: string) => {
72
- // Empty tags are completely removed
73
- if (!content.trim()) return '';
74
- return options.marker;
75
- });
76
- }
77
-
78
- return {
79
- filtered,
80
- sections,
81
- stats: {
82
- count: sections.length,
83
- totalLength: sections.reduce((sum, s) => sum + s.content.length, 0)
84
- }
85
- };
86
- }
87
-
88
- /**
89
- * Parse private tags safely, protecting code blocks
90
- */
91
- export function parsePrivateTagsSafe(
92
- text: string,
93
- options: ParseOptions
94
- ): ParseResult {
95
- // 1. Extract and protect code blocks
96
- const codeBlocks: string[] = [];
97
- const textWithPlaceholders = text.replace(
98
- /```[\s\S]*?```/g,
99
- (match) => {
100
- codeBlocks.push(match);
101
- return `__CODE_BLOCK_${codeBlocks.length - 1}__`;
102
- }
103
- );
104
-
105
- // Also protect inline code
106
- const inlineCode: string[] = [];
107
- const textWithAllPlaceholders = textWithPlaceholders.replace(
108
- /`[^`]+`/g,
109
- (match) => {
110
- inlineCode.push(match);
111
- return `__INLINE_CODE_${inlineCode.length - 1}__`;
112
- }
113
- );
114
-
115
- // 2. Parse private tags
116
- const result = parsePrivateTags(textWithAllPlaceholders, options);
117
-
118
- // 3. Restore inline code
119
- result.filtered = result.filtered.replace(
120
- /__INLINE_CODE_(\d+)__/g,
121
- (_, idx) => inlineCode[Number(idx)]
122
- );
123
-
124
- // 4. Restore code blocks
125
- result.filtered = result.filtered.replace(
126
- /__CODE_BLOCK_(\d+)__/g,
127
- (_, idx) => codeBlocks[Number(idx)]
128
- );
129
-
130
- return result;
131
- }
132
-
133
- /**
134
- * Check if text has unclosed private tags
135
- */
136
- export function hasUnmatchedOpenTag(text: string): boolean {
137
- // Check for opening tags without closing
138
- const openXml = (text.match(/<private>/gi) || []).length;
139
- const closeXml = (text.match(/<\/private>/gi) || []).length;
140
-
141
- const openBracket = (text.match(/\[private\]/gi) || []).length;
142
- const closeBracket = (text.match(/\[\/private\]/gi) || []).length;
143
-
144
- return openXml !== closeXml || openBracket !== closeBracket;
145
- }
@@ -1,314 +0,0 @@
1
- /**
2
- * Product-level validation matrix for claude-memory-layer.
3
- *
4
- * This module is intentionally data-first so CLI/reporting/docs can reuse the
5
- * same surface -> requirement -> evidence map that tests assert stays covered.
6
- */
7
-
8
- export type ProductValidationArea = 'claude' | 'codex' | 'hermes' | 'mcp' | 'cli' | 'safety';
9
- export type ProductValidationStatus = 'ready' | 'covered' | 'partial' | 'planned';
10
- export type ProductValidationEvidenceKind = 'test' | 'source' | 'command' | 'doc';
11
-
12
- export interface ProductValidationEvidence {
13
- kind: ProductValidationEvidenceKind;
14
- ref: string;
15
- note: string;
16
- }
17
-
18
- export interface ProductValidationSurface {
19
- id: string;
20
- area: ProductValidationArea;
21
- title: string;
22
- status: ProductValidationStatus;
23
- requirements: string[];
24
- evidence: ProductValidationEvidence[];
25
- }
26
-
27
- export interface ProductValidationMatrixSummary {
28
- totalSurfaces: number;
29
- requirementCount: number;
30
- evidenceCount: number;
31
- surfacesByArea: Record<ProductValidationArea, number>;
32
- statusCounts: Record<ProductValidationStatus, number>;
33
- }
34
-
35
- export const productValidationMatrix: readonly ProductValidationSurface[] = [
36
- {
37
- id: 'claude.adapter.import',
38
- area: 'claude',
39
- title: 'Claude adapter import',
40
- status: 'covered',
41
- requirements: [
42
- 'Import Claude Code JSONL transcripts without storing tool-result noise as user prompts.',
43
- 'Preserve session/project mapping and turn grouping for retrieval continuity.'
44
- ],
45
- evidence: [
46
- { kind: 'test', ref: 'tests/core/session-history-importer-filter.test.ts', note: 'Filters local-command artifacts and keeps substantive prompts.' },
47
- { kind: 'source', ref: 'src/services/session-history-importer.ts', note: 'Claude JSONL import pipeline and project/session registration.' }
48
- ]
49
- },
50
- {
51
- id: 'claude.adapter.search',
52
- area: 'claude',
53
- title: 'Claude adapter search',
54
- status: 'covered',
55
- requirements: [
56
- 'Expose semantic memory search with project/session scoping and fast/deep strategies.',
57
- 'Return plain and disclosure-aware search output without mutating memory.'
58
- ],
59
- evidence: [
60
- { kind: 'test', ref: 'tests/core/retrieval-services.test.ts', note: 'Core retrieval service behavior.' },
61
- { kind: 'test', ref: 'tests/apps/cli-disclosure-output.test.ts', note: 'CLI disclosure output formatting.' },
62
- { kind: 'source', ref: 'src/apps/cli/index.ts', note: 'search command supports disclosure, scope, and strategy flags.' }
63
- ]
64
- },
65
- {
66
- id: 'claude.adapter.disclosure',
67
- area: 'claude',
68
- title: 'Claude adapter disclosure',
69
- status: 'covered',
70
- requirements: [
71
- 'Support progressive search -> expand -> source disclosure flow.',
72
- 'Render source/citation evidence for retrieved memories.'
73
- ],
74
- evidence: [
75
- { kind: 'test', ref: 'tests/core/retrieval-disclosure-service.test.ts', note: 'Disclosure service search/expand/source flow.' },
76
- { kind: 'test', ref: 'tests/apps/ui-disclosure-output.test.ts', note: 'Dashboard disclosure formatting.' },
77
- { kind: 'source', ref: 'src/core/engine/retrieval-disclosure-service.ts', note: 'Core disclosure orchestration.' }
78
- ]
79
- },
80
- {
81
- id: 'codex.adapter.scan',
82
- area: 'codex',
83
- title: 'Codex adapter scan',
84
- status: 'ready',
85
- requirements: [
86
- 'Read ~/.codex/sessions recursively without writes by default.',
87
- 'Match sessions to a project via session_meta.payload.cwd when available and summarize all sessions otherwise.',
88
- 'Count missing cwd, malformed JSONL lines, and unsupported/tool-ish records.'
89
- ],
90
- evidence: [
91
- { kind: 'test', ref: 'tests/core/codex-session-history-importer-validation.test.ts', note: 'Dry-run scan, cwd matching, missing cwd, malformed and unsupported counts.' },
92
- { kind: 'source', ref: 'src/services/codex-session-history-importer.ts', note: 'validateCodexSessions and normalizeCodexSessionFile.' }
93
- ]
94
- },
95
- {
96
- id: 'codex.adapter.import',
97
- area: 'codex',
98
- title: 'Codex adapter import',
99
- status: 'covered',
100
- requirements: [
101
- 'Import explicit Codex session files/project sessions into memory only through import APIs.',
102
- 'Expose a user-facing codex import command for project, session, and all-session imports.',
103
- 'Preserve turn grouping and truncate oversized assistant content before storage.'
104
- ],
105
- evidence: [
106
- { kind: 'test', ref: 'tests/apps/codex-import-runner.test.ts', note: 'Asserts project-scoped, session, and explicit global all-session import routing.' },
107
- { kind: 'source', ref: 'src/apps/cli/codex-import-runner.ts', note: 'Safe Codex import command runner with project/default/global storage decisions.' },
108
- { kind: 'source', ref: 'src/services/codex-session-history-importer.ts', note: 'CodexSessionHistoryImporter importProject/importAll/importSessionFile.' },
109
- { kind: 'doc', ref: 'docs/PRODUCT_VALIDATION_MATRIX.md', note: 'Documents that validation/replay is read-only; mutation remains explicit import-only.' }
110
- ]
111
- },
112
- {
113
- id: 'codex.adapter.replay',
114
- area: 'codex',
115
- title: 'Codex adapter replay',
116
- status: 'ready',
117
- requirements: [
118
- 'Normalize response_item message records with user/assistant roles and text/input_text/output_text blocks.',
119
- 'Handle string content, empty assistant turns, large/truncated content, malformed lines, and tool-ish records robustly.',
120
- 'Emit aggregate replay counts without transcript content.'
121
- ],
122
- evidence: [
123
- { kind: 'test', ref: 'tests/core/codex-session-history-importer-validation.test.ts', note: 'Realistic fixture replay covers supported and malformed Codex JSONL shapes.' },
124
- { kind: 'source', ref: 'src/services/codex-session-history-importer.ts', note: 'normalizeCodexSessionFile parses and counts replay records.' }
125
- ]
126
- },
127
- {
128
- id: 'hermes.adapter.scan',
129
- area: 'hermes',
130
- title: 'Hermes adapter scan',
131
- status: 'ready',
132
- requirements: [
133
- 'Read Hermes ~/.hermes/state.db in read-only mode by default.',
134
- 'Match sessions to a project via Hermes session context/title when available.',
135
- 'Count unsupported/tool messages, empty assistant messages, missing project context, and truncated content without exposing transcript text.'
136
- ],
137
- evidence: [
138
- { kind: 'test', ref: 'tests/core/hermes-session-history-importer-validation.test.ts', note: 'Dry-run SessionDB fixture covers project matching, unsupported/tool skipping, empty assistant messages, and transcript exclusion.' },
139
- { kind: 'source', ref: 'src/services/hermes-session-history-importer.ts', note: 'validateHermesSessions reads SessionDB and emits aggregate replay reports.' }
140
- ]
141
- },
142
- {
143
- id: 'hermes.adapter.import',
144
- area: 'hermes',
145
- title: 'Hermes adapter import',
146
- status: 'covered',
147
- requirements: [
148
- 'Import explicit Hermes SessionDB project/session/all selections into memory only through import APIs.',
149
- 'Default to project-scoped memory for current-project imports and require --all for intentional global imports.',
150
- 'Skip tool/system records and redact sensitive user/assistant content before storage.'
151
- ],
152
- evidence: [
153
- { kind: 'test', ref: 'tests/core/hermes-session-history-importer-validation.test.ts', note: 'Imports only matched user/assistant turns, redacts secrets, and skips tool messages.' },
154
- { kind: 'test', ref: 'tests/apps/hermes-import-runner.test.ts', note: 'Asserts project-scoped, session, and explicit global all-session import routing.' },
155
- { kind: 'source', ref: 'src/apps/cli/hermes-import-runner.ts', note: 'Safe Hermes import command runner with project/default/global storage decisions.' },
156
- { kind: 'source', ref: 'src/services/hermes-session-history-importer.ts', note: 'HermesSessionHistoryImporter importProject/importAll/importSession.' }
157
- ]
158
- },
159
- {
160
- id: 'hermes.adapter.replay',
161
- area: 'hermes',
162
- title: 'Hermes adapter replay',
163
- status: 'ready',
164
- requirements: [
165
- 'Normalize Hermes SessionDB user/assistant rows into aggregate replay counts.',
166
- 'Keep Hermes raw transcript source-of-truth in SessionDB and treat CML as explicit derived memory.',
167
- 'Emit validation reports without transcript content or secrets.'
168
- ],
169
- evidence: [
170
- { kind: 'test', ref: 'tests/core/hermes-session-history-importer-validation.test.ts', note: 'Validation report excludes prompt/response text and synthetic secrets.' },
171
- { kind: 'source', ref: 'src/apps/cli/hermes-validation-output.ts', note: 'JSON/Markdown report output helpers for Hermes aggregate replay.' },
172
- { kind: 'doc', ref: 'docs/HERMES_MEMORY_INGESTION_ANALYSIS.md', note: 'Documents explicit import first; live sync later if needed.' }
173
- ]
174
- },
175
- {
176
- id: 'mcp.context.pack',
177
- area: 'mcp',
178
- title: 'MCP context pack',
179
- status: 'covered',
180
- requirements: [
181
- 'Expose an agent-ready project context pack that combines relevant retrieval results with recent project timeline.',
182
- 'Support projectPath scoping so Hermes, Codex, and Claude Code can share the same project memory backend.',
183
- 'Keep output compact and citation-oriented so agents can follow up with source-ref or timeline tools.'
184
- ],
185
- evidence: [
186
- { kind: 'test', ref: 'tests/extensions/mcp-context-tools.test.ts', note: 'Asserts context-pack output, projectPath routing, compact relevant memory citations, and recent timeline inclusion.' },
187
- { kind: 'source', ref: 'src/extensions/mcp/handlers.ts', note: 'mem-context-pack handler formats relevant memories plus session summaries.' },
188
- { kind: 'source', ref: 'src/extensions/mcp/tools.ts', note: 'MCP tool schema advertises projectPath, topK, recentLimit, and sessionLimit options.' }
189
- ]
190
- },
191
- {
192
- id: 'mcp.project.timeline',
193
- area: 'mcp',
194
- title: 'MCP project timeline',
195
- status: 'covered',
196
- requirements: [
197
- 'Summarize recent project memories by session, source agent, event counts, and last safe preview.',
198
- 'Avoid raw transcript dumps while still giving enough continuity for another agent to resume work.'
199
- ],
200
- evidence: [
201
- { kind: 'test', ref: 'tests/extensions/mcp-context-tools.test.ts', note: 'Asserts session grouping, source-agent metadata, and event type counts.' },
202
- { kind: 'source', ref: 'src/extensions/mcp/handlers.ts', note: 'mem-project-timeline groups recent events by session and source.' },
203
- { kind: 'source', ref: 'src/extensions/mcp/tools.ts', note: 'MCP tool schema advertises limit/sessionLimit/projectPath options.' }
204
- ]
205
- },
206
- {
207
- id: 'mcp.source.ref',
208
- area: 'mcp',
209
- title: 'MCP source reference',
210
- status: 'covered',
211
- requirements: [
212
- 'Resolve event IDs, event: references, and mem citation IDs into source references.',
213
- 'Return privacy-safe redacted previews and a narrow allowlist of metadata instead of raw transcript content.',
214
- 'Support projectPath scoping for project-specific memory stores.'
215
- ],
216
- evidence: [
217
- { kind: 'test', ref: 'tests/extensions/mcp-context-tools.test.ts', note: 'Asserts citation lookup, secret redaction, and safe metadata allowlist.' },
218
- { kind: 'source', ref: 'src/extensions/mcp/handlers.ts', note: 'mem-source-ref applies privacy filtering and safe metadata selection.' },
219
- { kind: 'source', ref: 'src/core/privacy/filter.ts', note: 'Shared privacy filter masks sensitive patterns before output.' }
220
- ]
221
- },
222
- {
223
- id: 'cli.api.reporting',
224
- area: 'cli',
225
- title: 'CLI / API / reporting',
226
- status: 'ready',
227
- requirements: [
228
- 'Expose user-facing Codex validation commands with --project, --sessions-dir, --limit, --format, --output, and --dry-run options.',
229
- 'Expose user-facing Hermes validation commands with --project, --state-db, --limit, --format, --output, and --dry-run options.',
230
- 'Expose explicit Codex and Hermes import commands with project, session, all-session, limit, force, and no-process-embeddings options.',
231
- 'Render JSON and Markdown reports with totals, warnings, top projects/sources, and source paths.'
232
- ],
233
- evidence: [
234
- { kind: 'test', ref: 'tests/apps/codex-validation-output.test.ts', note: 'Codex JSON/Markdown report formatting.' },
235
- { kind: 'test', ref: 'tests/apps/codex-import-runner.test.ts', note: 'Codex import CLI runner behavior and storage-scope routing.' },
236
- { kind: 'test', ref: 'tests/apps/hermes-import-runner.test.ts', note: 'Hermes import CLI runner behavior and storage-scope routing.' },
237
- { kind: 'source', ref: 'src/apps/cli/index.ts', note: 'codex and hermes validate/replay/import commands.' },
238
- { kind: 'source', ref: 'src/apps/cli/codex-validation-output.ts', note: 'Codex report output helpers.' },
239
- { kind: 'source', ref: 'src/apps/cli/hermes-validation-output.ts', note: 'Hermes report output helpers.' },
240
- { kind: 'source', ref: 'src/apps/cli/codex-import-runner.ts', note: 'Codex import runner.' },
241
- { kind: 'source', ref: 'src/apps/cli/hermes-import-runner.ts', note: 'Hermes import runner.' }
242
- ]
243
- },
244
- {
245
- id: 'safety.dryRun',
246
- area: 'safety',
247
- title: 'Safety / dry-run',
248
- status: 'ready',
249
- requirements: [
250
- 'Codex validation/replay is read-only by default and never initializes memory storage or changes Claude settings.',
251
- 'Reports exclude transcript content and can anonymize project paths for real-data validation artifacts.'
252
- ],
253
- evidence: [
254
- { kind: 'test', ref: 'tests/core/codex-session-history-importer-validation.test.ts', note: 'Asserts dryRun=true, willMutate=false, and no transcript content in reports.' },
255
- { kind: 'command', ref: 'claude-memory-layer codex validate --dry-run', note: 'User-facing dry-run validation command.' },
256
- { kind: 'doc', ref: 'docs/PRODUCT_VALIDATION_MATRIX.md', note: 'Documents safety expectations and read-only validation scope.' }
257
- ]
258
- }
259
- ];
260
-
261
- function emptyAreaCounts(): Record<ProductValidationArea, number> {
262
- return { claude: 0, codex: 0, hermes: 0, mcp: 0, cli: 0, safety: 0 };
263
- }
264
-
265
- function emptyStatusCounts(): Record<ProductValidationStatus, number> {
266
- return { ready: 0, covered: 0, partial: 0, planned: 0 };
267
- }
268
-
269
- export function getProductValidationMatrixSummary(
270
- matrix: readonly ProductValidationSurface[] = productValidationMatrix
271
- ): ProductValidationMatrixSummary {
272
- const summary: ProductValidationMatrixSummary = {
273
- totalSurfaces: matrix.length,
274
- requirementCount: 0,
275
- evidenceCount: 0,
276
- surfacesByArea: emptyAreaCounts(),
277
- statusCounts: emptyStatusCounts()
278
- };
279
-
280
- for (const surface of matrix) {
281
- summary.surfacesByArea[surface.area] += 1;
282
- summary.statusCounts[surface.status] += 1;
283
- summary.requirementCount += surface.requirements.length;
284
- summary.evidenceCount += surface.evidence.length;
285
- }
286
-
287
- return summary;
288
- }
289
-
290
- export function renderProductValidationMatrixMarkdown(
291
- matrix: readonly ProductValidationSurface[] = productValidationMatrix
292
- ): string {
293
- const summary = getProductValidationMatrixSummary(matrix);
294
- const lines: string[] = [
295
- '# Product Validation Matrix',
296
- '',
297
- `Surfaces: ${summary.totalSurfaces}`,
298
- `Requirements: ${summary.requirementCount}`,
299
- `Evidence items: ${summary.evidenceCount}`,
300
- '',
301
- '| Area | Surface | Status | Requirements | Evidence |',
302
- '| --- | --- | --- | --- | --- |'
303
- ];
304
-
305
- for (const surface of matrix) {
306
- const requirements = surface.requirements.map((requirement) => requirement.replace(/\|/g, '\\|')).join('<br>');
307
- const evidence = surface.evidence
308
- .map((item) => `${item.kind}: ${item.ref}`.replace(/\|/g, '\\|'))
309
- .join('<br>');
310
- lines.push(`| ${surface.area} | ${surface.title} | ${surface.status} | ${requirements} | ${evidence} |`);
311
- }
312
-
313
- return `${lines.join('\n')}\n`;
314
- }