@nathapp/nax 0.28.0 → 0.30.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 (385) hide show
  1. package/CHANGELOG.md +23 -2
  2. package/bin/nax.ts +2 -3
  3. package/dist/nax.js +72753 -0
  4. package/package.json +11 -3
  5. package/src/cli/analyze.ts +2 -7
  6. package/src/cli/config.ts +3 -1
  7. package/src/config/defaults.ts +1 -0
  8. package/src/config/schemas.ts +1 -0
  9. package/src/config/types.ts +1 -0
  10. package/src/context/builder.ts +10 -1
  11. package/src/execution/lifecycle/headless-formatter.ts +2 -4
  12. package/src/prompts/builder.ts +12 -69
  13. package/src/prompts/sections/isolation.ts +38 -8
  14. package/src/prompts/sections/role-task.ts +79 -17
  15. package/src/review/runner.ts +6 -1
  16. package/src/version.ts +2 -1
  17. package/.claude/rules/01-project-conventions.md +0 -34
  18. package/.claude/rules/02-test-architecture.md +0 -39
  19. package/.claude/rules/03-test-writing.md +0 -58
  20. package/.claude/rules/04-forbidden-patterns.md +0 -29
  21. package/.claude/settings.json +0 -15
  22. package/.githooks/pre-commit +0 -16
  23. package/.gitlab-ci.yml +0 -103
  24. package/.mcp.json +0 -8
  25. package/BRIEF.md +0 -140
  26. package/CLAUDE.md +0 -143
  27. package/US-007-IMPLEMENTATION.md +0 -139
  28. package/biome.json +0 -14
  29. package/bun.lock +0 -163
  30. package/bunfig.toml +0 -12
  31. package/docker-compose.test.yml +0 -15
  32. package/docs/20260216-fix-plan-context-review.md +0 -56
  33. package/docs/20260216-relentless-vs-ngent-comparison.md +0 -208
  34. package/docs/20260216-v02-plan.md +0 -136
  35. package/docs/20260216-v02-review.md +0 -685
  36. package/docs/20260217-dogfood-findings.md +0 -56
  37. package/docs/20260217-p2-plus-plan.md +0 -117
  38. package/docs/20260217-partial-fixes-plan.md +0 -62
  39. package/docs/20260217-plan-analyze-spec.md +0 -117
  40. package/docs/20260217-post-impl-review.md +0 -1137
  41. package/docs/20260217-quick-wins-plan.md +0 -66
  42. package/docs/20260217-split-runner-plan.md +0 -75
  43. package/docs/20260217-v03-impl-plan.md +0 -80
  44. package/docs/20260217-v03-post-impl-review.md +0 -589
  45. package/docs/20260217-v04-impl-plan.md +0 -86
  46. package/docs/20260217-v05-post-impl-review.md +0 -850
  47. package/docs/20260217-v06-post-impl-review.md +0 -817
  48. package/docs/20260218-adr003-port-plan.md +0 -151
  49. package/docs/20260218-review-adr003-verification.md +0 -175
  50. package/docs/20260219-fix-plan-bug16-19.md +0 -79
  51. package/docs/20260219-fix-plan-bug20-22.md +0 -114
  52. package/docs/20260219-plan-llm-routing.md +0 -116
  53. package/docs/20260219-review-bug20-22-fixes.md +0 -135
  54. package/docs/20260219-routing-baseline-keyword.md +0 -63
  55. package/docs/20260220-plan-structured-logging-p1.md +0 -80
  56. package/docs/20260220-plan-structured-logging-p2.md +0 -37
  57. package/docs/20260220-review-llm-routing.md +0 -180
  58. package/docs/20260220-review-post-fix-llm-routing.md +0 -70
  59. package/docs/20260221-fix-plan-relevantfiles-split.md +0 -101
  60. package/docs/20260221-fix-plan-routing-mode.md +0 -125
  61. package/docs/20260221-review-v0.9-implementation.md +0 -379
  62. package/docs/20260222-fix-plan-v091-routing-isolation.md +0 -197
  63. package/docs/20260223-fix-plan-prompt-audit.md +0 -62
  64. package/docs/20260224-nax-roadmap-phases.md +0 -189
  65. package/docs/20260225-phase2-llm-service-layer.md +0 -401
  66. package/docs/20260225-review-v0.10.1.md +0 -187
  67. package/docs/20260303-v010-implementation-plan.md +0 -165
  68. package/docs/20260304-review-nax.md +0 -492
  69. package/docs/CLAUDE.md.bak +0 -191
  70. package/docs/ROADMAP.md +0 -390
  71. package/docs/SPEC-rectification.md +0 -0
  72. package/docs/SPEC.md +0 -324
  73. package/docs/US-001-plugin-loading-verification.md +0 -152
  74. package/docs/adr/ADR-005-implementation-plan.md +0 -655
  75. package/docs/adr/ADR-005-pipeline-re-architecture.md +0 -464
  76. package/docs/architecture-analysis.md +0 -1076
  77. package/docs/bugs/BUG-21-escalation-null-attempts.md +0 -48
  78. package/docs/bugs-from-dogfood-run-c.md +0 -243
  79. package/docs/code-review-20260228.md +0 -612
  80. package/docs/code-review-v0.15.0.md +0 -629
  81. package/docs/hook-lifecycle-test-plan.md +0 -149
  82. package/docs/releases/v0.11.0-and-earlier.md +0 -20
  83. package/docs/releases/v0.12.0.md +0 -15
  84. package/docs/releases/v0.13.0.md +0 -14
  85. package/docs/releases/v0.14.0.md +0 -20
  86. package/docs/releases/v0.14.1.md +0 -36
  87. package/docs/releases/v0.14.2.md +0 -51
  88. package/docs/releases/v0.14.3.md +0 -174
  89. package/docs/releases/v0.14.4.md +0 -94
  90. package/docs/releases/v0.15.0.md +0 -502
  91. package/docs/releases/v0.15.1.md +0 -170
  92. package/docs/releases/v0.15.3.md +0 -193
  93. package/docs/specs/bug-039-orphan-processes.md +0 -131
  94. package/docs/specs/bug-040-review-rectification.md +0 -82
  95. package/docs/specs/bug-041-cross-story-test-isolation.md +0 -88
  96. package/docs/specs/bug-042-verifier-failure-capture.md +0 -117
  97. package/docs/specs/bun-pty-migration.md +0 -171
  98. package/docs/specs/central-run-registry.md +0 -116
  99. package/docs/specs/feat-010-smart-runner-git-history.md +0 -96
  100. package/docs/specs/feat-011-file-context-strategy.md +0 -73
  101. package/docs/specs/feat-012-tdd-writer-tier.md +0 -79
  102. package/docs/specs/feat-013-test-after-review.md +0 -89
  103. package/docs/specs/feat-014-heartbeat-observability.md +0 -127
  104. package/docs/specs/status-file-consolidation.md +0 -93
  105. package/docs/specs/status-file-v0.10.1.md +0 -812
  106. package/docs/specs/trigger-completion.md +0 -145
  107. package/docs/specs/verification-architecture-v2.md +0 -343
  108. package/docs/tdd/strategies.md +0 -97
  109. package/docs/v0.10-global-config.md +0 -206
  110. package/docs/v0.10-plugin-system.md +0 -415
  111. package/docs/v0.10-prompt-optimizer.md +0 -234
  112. package/docs/v0.3-spec.md +0 -244
  113. package/docs/v0.4-spec.md +0 -140
  114. package/docs/v0.5-spec.md +0 -237
  115. package/docs/v0.6-spec.md +0 -371
  116. package/docs/v0.7-spec.md +0 -177
  117. package/docs/v0.8-llm-routing.md +0 -206
  118. package/docs/v0.8-structured-logging.md +0 -132
  119. package/docs/v0.9.3-prompt-audit.md +0 -112
  120. package/examples/plugins/console-reporter/index.test.ts +0 -207
  121. package/examples/plugins/console-reporter/index.ts +0 -110
  122. package/memory/topic/feat-010-baseref.md +0 -28
  123. package/memory/topic/feat-013-test-after-deprecation.md +0 -22
  124. package/nax/config.json +0 -154
  125. package/nax/features/bug-039-medium/prd.json +0 -45
  126. package/nax/features/bugfix-v0171/prd.json +0 -52
  127. package/nax/features/central-run-registry/prd.json +0 -105
  128. package/nax/features/config-management/prd.json +0 -108
  129. package/nax/features/config-management/progress.txt +0 -5
  130. package/nax/features/diagnose/acceptance.test.ts +0 -414
  131. package/nax/features/diagnose/prd.json +0 -41
  132. package/nax/features/nax-compliance/prd.json +0 -52
  133. package/nax/features/nax-compliance/progress.txt +0 -1
  134. package/nax/features/orchestration-fixes/prd.json +0 -89
  135. package/nax/features/orchestration-fixes/progress.txt +0 -1
  136. package/nax/features/plugin-integration/US-007-VERIFICATION.md +0 -259
  137. package/nax/features/plugin-integration/prd.json +0 -208
  138. package/nax/features/plugin-integration/progress.txt +0 -5
  139. package/nax/features/post-rearch-bugfix/prd.json +0 -137
  140. package/nax/features/precheck/prd.json +0 -205
  141. package/nax/features/precheck/progress.txt +0 -15
  142. package/nax/features/prompt-builder/prd.json +0 -152
  143. package/nax/features/prompt-builder/progress.txt +0 -3
  144. package/nax/features/review-quality/prd.json +0 -55
  145. package/nax/features/routing-persistence/prd.json +0 -104
  146. package/nax/features/routing-persistence/progress.txt +0 -1
  147. package/nax/features/smart-test-runner/plan.md +0 -7
  148. package/nax/features/smart-test-runner/prd.json +0 -203
  149. package/nax/features/smart-test-runner/progress.txt +0 -13
  150. package/nax/features/smart-test-runner/spec.md +0 -7
  151. package/nax/features/smart-test-runner/tasks.md +0 -8
  152. package/nax/features/status-file-consolidation/prd.json +0 -106
  153. package/nax/features/structured-logging/prd.json +0 -199
  154. package/nax/features/trigger-completion/prd.json +0 -150
  155. package/nax/features/trigger-completion/progress.txt +0 -7
  156. package/nax/features/unlock/prd.json +0 -36
  157. package/nax/features/v0.18.3-execution-reliability/prd.json +0 -80
  158. package/nax/features/v0.18.3-execution-reliability/progress.txt +0 -3
  159. package/nax/features/v0.19.0-hardening/plan.md +0 -7
  160. package/nax/features/v0.19.0-hardening/prd.json +0 -84
  161. package/nax/features/v0.19.0-hardening/progress.txt +0 -7
  162. package/nax/features/v0.19.0-hardening/spec.md +0 -18
  163. package/nax/features/v0.19.0-hardening/tasks.md +0 -8
  164. package/nax/features/verify-v2/prd.json +0 -79
  165. package/nax/features/verify-v2/progress.txt +0 -3
  166. package/nax/status.json +0 -36
  167. package/src/prompts/templates/implementer.ts +0 -6
  168. package/src/prompts/templates/single-session.ts +0 -6
  169. package/src/prompts/templates/test-writer.ts +0 -6
  170. package/src/prompts/templates/verifier.ts +0 -6
  171. package/test/COVERAGE-GAPS.md +0 -333
  172. package/test/e2e/cm-003-default-view.test.ts +0 -195
  173. package/test/e2e/plan-analyze-run.test.ts +0 -902
  174. package/test/helpers/helpers.test.ts +0 -295
  175. package/test/helpers/timeout.ts +0 -42
  176. package/test/integration/US-002-TEST-SUMMARY.md +0 -107
  177. package/test/integration/US-003-TEST-SUMMARY.md +0 -149
  178. package/test/integration/US-004-TEST-SUMMARY.md +0 -106
  179. package/test/integration/US-005-TEST-SUMMARY.md +0 -138
  180. package/test/integration/US-007-TEST-SUMMARY.md +0 -100
  181. package/test/integration/cli/agent-validation.test.ts +0 -439
  182. package/test/integration/cli/cli-config-default-edge-cases.test.ts +0 -223
  183. package/test/integration/cli/cli-config-default-view.test.ts +0 -230
  184. package/test/integration/cli/cli-config-diff.test.ts +0 -461
  185. package/test/integration/cli/cli-config-prompts-explain.test.ts +0 -74
  186. package/test/integration/cli/cli-config.test.ts +0 -737
  187. package/test/integration/cli/cli-diagnose.test.ts +0 -595
  188. package/test/integration/cli/cli-logs.test.ts +0 -346
  189. package/test/integration/cli/cli-plugins.test.ts +0 -679
  190. package/test/integration/cli/cli-precheck.test.ts +0 -372
  191. package/test/integration/cli/cli-run-headless.test.ts +0 -174
  192. package/test/integration/cli/cli.test.ts +0 -76
  193. package/test/integration/cli/precheck-integration.test.ts +0 -476
  194. package/test/integration/cli/precheck-orchestrator.test.ts +0 -247
  195. package/test/integration/cli/precheck.test.ts +0 -806
  196. package/test/integration/config/config-loader.test.ts +0 -266
  197. package/test/integration/config/config.test.ts +0 -444
  198. package/test/integration/config/merger.test.ts +0 -466
  199. package/test/integration/config/paths.test.ts +0 -52
  200. package/test/integration/config/security-loader.test.ts +0 -83
  201. package/test/integration/context/context-integration.test.ts +0 -703
  202. package/test/integration/context/context-path-security.test.ts +0 -173
  203. package/test/integration/context/context-provider-injection.test.ts +0 -507
  204. package/test/integration/context/context-verification-integration.test.ts +0 -296
  205. package/test/integration/context/s5-greenfield-fallback.test.ts +0 -298
  206. package/test/integration/execution/execution-isolation.test.ts +0 -143
  207. package/test/integration/execution/execution.test.ts +0 -634
  208. package/test/integration/execution/feature-status-write.test.ts +0 -302
  209. package/test/integration/execution/parallel.test.ts +0 -251
  210. package/test/integration/execution/prd-pause.test.ts +0 -205
  211. package/test/integration/execution/prd-resolvers.test.ts +0 -186
  212. package/test/integration/execution/progress.test.ts +0 -34
  213. package/test/integration/execution/runner-batching.test.ts +0 -682
  214. package/test/integration/execution/runner-config-plugins.test.ts +0 -462
  215. package/test/integration/execution/runner-escalation.test.ts +0 -561
  216. package/test/integration/execution/runner-fixes.test.ts +0 -400
  217. package/test/integration/execution/runner-plugin-integration.test.ts +0 -544
  218. package/test/integration/execution/runner-queue-and-attempts.test.ts +0 -476
  219. package/test/integration/execution/status-file-integration.test.ts +0 -289
  220. package/test/integration/execution/status-file.test.ts +0 -380
  221. package/test/integration/execution/status-writer.test.ts +0 -447
  222. package/test/integration/execution/story-id-in-events.test.ts +0 -274
  223. package/test/integration/interaction/interaction-chain-pipeline.test.ts +0 -476
  224. package/test/integration/pipeline/hooks.test.ts +0 -363
  225. package/test/integration/pipeline/pipeline-acceptance.test.ts +0 -303
  226. package/test/integration/pipeline/pipeline-events.test.ts +0 -476
  227. package/test/integration/pipeline/pipeline.test.ts +0 -660
  228. package/test/integration/pipeline/reporter-lifecycle.test.ts +0 -862
  229. package/test/integration/pipeline/verify-stage.test.ts +0 -286
  230. package/test/integration/plan/analyze-integration.test.ts +0 -262
  231. package/test/integration/plan/analyze-scanner.test.ts +0 -132
  232. package/test/integration/plan/logger.test.ts +0 -461
  233. package/test/integration/plan/plan.test.ts +0 -157
  234. package/test/integration/plugins/config-integration.test.ts +0 -173
  235. package/test/integration/plugins/config-resolution.test.ts +0 -523
  236. package/test/integration/plugins/loader.test.ts +0 -644
  237. package/test/integration/plugins/plugins-registry.test.ts +0 -747
  238. package/test/integration/plugins/validator.test.ts +0 -564
  239. package/test/integration/prompts/pb-004-migration.test.ts +0 -523
  240. package/test/integration/review/review-config-commands.test.ts +0 -320
  241. package/test/integration/review/review-config-schema.test.ts +0 -117
  242. package/test/integration/review/review-plugin-integration.test.ts +0 -729
  243. package/test/integration/review/review.test.ts +0 -150
  244. package/test/integration/routing/plugin-routing-advanced.test.ts +0 -461
  245. package/test/integration/routing/plugin-routing-core.test.ts +0 -527
  246. package/test/integration/routing/routing-stage-bug-021.test.ts +0 -275
  247. package/test/integration/routing/routing-stage-greenfield.test.ts +0 -287
  248. package/test/integration/tdd/tdd-cleanup.test.ts +0 -246
  249. package/test/integration/tdd/tdd-orchestrator-core.test.ts +0 -565
  250. package/test/integration/tdd/tdd-orchestrator-failureCategory.test.ts +0 -355
  251. package/test/integration/tdd/tdd-orchestrator-fallback.test.ts +0 -311
  252. package/test/integration/tdd/tdd-orchestrator-lite.test.ts +0 -289
  253. package/test/integration/tdd/tdd-orchestrator-prompts.test.ts +0 -260
  254. package/test/integration/tdd/tdd-orchestrator-verdict.test.ts +0 -536
  255. package/test/integration/tmp/headless-test/test.jsonl +0 -30
  256. package/test/integration/verification/test-scanner.test.ts +0 -403
  257. package/test/integration/verification/verification-asset-check.test.ts +0 -143
  258. package/test/integration/worktree/manager.test.ts +0 -218
  259. package/test/integration/worktree/worktree-merge.test.ts +0 -341
  260. package/test/manual/logging-formatter-demo.ts +0 -158
  261. package/test/ui/tui-agent-panel.test.tsx +0 -99
  262. package/test/ui/tui-pty-integration.test.tsx +0 -146
  263. package/test/unit/acceptance.test.ts +0 -187
  264. package/test/unit/agent-stderr-capture.test.ts +0 -147
  265. package/test/unit/agents/claude.test.ts +0 -107
  266. package/test/unit/analyze-classifier.test.ts +0 -216
  267. package/test/unit/analyze.test.ts +0 -224
  268. package/test/unit/auto-detect.test.ts +0 -250
  269. package/test/unit/cli-status-project-level.test.ts +0 -283
  270. package/test/unit/cli-status.test.ts +0 -418
  271. package/test/unit/commands/common.test.ts +0 -321
  272. package/test/unit/commands/logs.test.ts +0 -458
  273. package/test/unit/commands/runs.test.ts +0 -303
  274. package/test/unit/commands/unlock.test.ts +0 -320
  275. package/test/unit/config/defaults.test.ts +0 -70
  276. package/test/unit/config/quality-commands-schema.test.ts +0 -72
  277. package/test/unit/config/regression-gate-schema.test.ts +0 -160
  278. package/test/unit/config/smart-runner-flag.test.ts +0 -250
  279. package/test/unit/constitution-generators.test.ts +0 -161
  280. package/test/unit/constitution.test.ts +0 -210
  281. package/test/unit/context/context-autodetect.test.ts +0 -297
  282. package/test/unit/context/context-build.test.ts +0 -575
  283. package/test/unit/context/context-coverage.test.ts +0 -236
  284. package/test/unit/context/context-error.test.ts +0 -93
  285. package/test/unit/context/context-estimate-tokens.test.ts +0 -201
  286. package/test/unit/context/context-format.test.ts +0 -302
  287. package/test/unit/context/context-isolation.test.ts +0 -267
  288. package/test/unit/context/context-sort.test.ts +0 -93
  289. package/test/unit/context/context-story.test.ts +0 -108
  290. package/test/unit/context/prior-failures.test.ts +0 -463
  291. package/test/unit/context.test.ts +0 -1726
  292. package/test/unit/cost.test.ts +0 -231
  293. package/test/unit/crash-recovery.test.ts +0 -309
  294. package/test/unit/escalation.test.ts +0 -127
  295. package/test/unit/execution/lifecycle/run-completion.test.ts +0 -240
  296. package/test/unit/execution/lifecycle/run-regression.test.ts +0 -420
  297. package/test/unit/execution/pid-registry.test.ts +0 -241
  298. package/test/unit/execution/sequential-executor.test.ts +0 -235
  299. package/test/unit/execution/sfc-004-dead-code-cleanup.test.ts +0 -89
  300. package/test/unit/execution/structured-failure.test.ts +0 -415
  301. package/test/unit/execution-logging-stderr.test.ts +0 -157
  302. package/test/unit/execution-stage.test.ts +0 -123
  303. package/test/unit/fix-generator.test.ts +0 -276
  304. package/test/unit/formatters.test.ts +0 -468
  305. package/test/unit/greenfield.test.ts +0 -180
  306. package/test/unit/hooks/shell-security.test.ts +0 -40
  307. package/test/unit/interaction/auto-plugin.test.ts +0 -162
  308. package/test/unit/interaction/human-review-trigger.test.ts +0 -165
  309. package/test/unit/interaction-network-failures.test.ts +0 -390
  310. package/test/unit/interaction-plugins.test.ts +0 -472
  311. package/test/unit/logging/formatter.test.ts +0 -456
  312. package/test/unit/merge.test.ts +0 -269
  313. package/test/unit/metrics/aggregator.test.ts +0 -164
  314. package/test/unit/metrics/tracker.test.ts +0 -186
  315. package/test/unit/metrics.test.ts +0 -276
  316. package/test/unit/optimizer/noop.optimizer.test.ts +0 -125
  317. package/test/unit/optimizer/rule-based.optimizer.test.ts +0 -358
  318. package/test/unit/pipeline/event-bus.test.ts +0 -105
  319. package/test/unit/pipeline/routing-partial-override.test.ts +0 -121
  320. package/test/unit/pipeline/runner-retry.test.ts +0 -89
  321. package/test/unit/pipeline/stages/autofix.test.ts +0 -97
  322. package/test/unit/pipeline/stages/completion-review-gate.test.ts +0 -218
  323. package/test/unit/pipeline/stages/execution-ambiguity.test.ts +0 -311
  324. package/test/unit/pipeline/stages/execution-merge-conflict.test.ts +0 -218
  325. package/test/unit/pipeline/stages/rectify.test.ts +0 -101
  326. package/test/unit/pipeline/stages/regression-stage.test.ts +0 -69
  327. package/test/unit/pipeline/stages/review.test.ts +0 -201
  328. package/test/unit/pipeline/stages/routing-idempotence.test.ts +0 -139
  329. package/test/unit/pipeline/stages/routing-initial-complexity.test.ts +0 -321
  330. package/test/unit/pipeline/stages/routing-persistence.test.ts +0 -380
  331. package/test/unit/pipeline/stages/verify.test.ts +0 -267
  332. package/test/unit/pipeline/subscribers/events-writer.test.ts +0 -227
  333. package/test/unit/pipeline/subscribers/hooks.test.ts +0 -84
  334. package/test/unit/pipeline/subscribers/interaction.test.ts +0 -313
  335. package/test/unit/pipeline/subscribers/registry.test.ts +0 -149
  336. package/test/unit/pipeline/subscribers/reporters.test.ts +0 -90
  337. package/test/unit/pipeline/verify-smart-runner.test.ts +0 -345
  338. package/test/unit/prd-auto-default.test.ts +0 -291
  339. package/test/unit/prd-failure-category.test.ts +0 -177
  340. package/test/unit/prd-get-next-story.test.ts +0 -215
  341. package/test/unit/precheck/checks-warnings.test.ts +0 -114
  342. package/test/unit/precheck-checks.test.ts +0 -841
  343. package/test/unit/precheck-story-size-gate.test.ts +0 -288
  344. package/test/unit/precheck-types.test.ts +0 -143
  345. package/test/unit/prompts/builder.test.ts +0 -258
  346. package/test/unit/prompts/loader.test.ts +0 -355
  347. package/test/unit/prompts/sections/conventions.test.ts +0 -30
  348. package/test/unit/prompts/sections/isolation.test.ts +0 -35
  349. package/test/unit/prompts/sections/role-task.test.ts +0 -40
  350. package/test/unit/prompts/sections/sections.test.ts +0 -238
  351. package/test/unit/prompts/sections/story.test.ts +0 -45
  352. package/test/unit/prompts/sections/verdict.test.ts +0 -58
  353. package/test/unit/prompts.test.ts +0 -476
  354. package/test/unit/queue.test.ts +0 -237
  355. package/test/unit/rectification.test.ts +0 -285
  356. package/test/unit/registry.test.ts +0 -288
  357. package/test/unit/review/runner.test.ts +0 -117
  358. package/test/unit/routing/content-hash.test.ts +0 -99
  359. package/test/unit/routing/routing-stability.test.ts +0 -208
  360. package/test/unit/routing/strategies/llm.test.ts +0 -306
  361. package/test/unit/routing-advanced.test.ts +0 -313
  362. package/test/unit/routing-core.test.ts +0 -341
  363. package/test/unit/routing-strategies.test.ts +0 -440
  364. package/test/unit/storyid-events.test.ts +0 -213
  365. package/test/unit/tdd-verdict.test.ts +0 -492
  366. package/test/unit/test-output-parser.test.ts +0 -377
  367. package/test/unit/ui/tui-controls.test.ts +0 -335
  368. package/test/unit/ui/tui-cost-and-pty.test.ts +0 -190
  369. package/test/unit/ui/tui-layout.test.ts +0 -379
  370. package/test/unit/ui/tui-stories.test.ts +0 -333
  371. package/test/unit/unit-isolation.test.ts +0 -135
  372. package/test/unit/utils/git.test.ts +0 -50
  373. package/test/unit/utils/path-security.test.ts +0 -47
  374. package/test/unit/utils-helpers.test.ts +0 -318
  375. package/test/unit/verdict.test.ts +0 -325
  376. package/test/unit/verification/orchestrator-types.test.ts +0 -54
  377. package/test/unit/verification/orchestrator.test.ts +0 -66
  378. package/test/unit/verification/smart-runner-config.test.ts +0 -163
  379. package/test/unit/verification/smart-runner-discovery.test.ts +0 -354
  380. package/test/unit/verification/smart-runner.test.ts +0 -262
  381. package/test/unit/verification/strategies/acceptance.test.ts +0 -33
  382. package/test/unit/verification/strategies/regression.test.ts +0 -87
  383. package/test/unit/verification/strategies/scoped.test.ts +0 -100
  384. package/test/unit/worktree-manager.test.ts +0 -159
  385. package/tsconfig.json +0 -27
@@ -1,629 +0,0 @@
1
- # Code Review: v0.15.0 Interactive Pipeline
2
-
3
- **Review Date:** 2026-02-28
4
- **Reviewed By:** Claude Code (Sonnet 4.5)
5
- **Scope:** All files changed between v0.14.4 (6d27bd7) and HEAD (6fe168a)
6
-
7
- ---
8
-
9
- ## Overall Grade: B+
10
-
11
- **Summary:** The v0.15.0 Interactive Pipeline implementation is well-structured with good separation of concerns. The interaction module follows clean architecture principles with a plugin-based design. However, there are several CRITICAL security and reliability issues that must be fixed immediately, plus architectural violations (files over 400 lines) that need addressing.
12
-
13
- **Strengths:**
14
- - Clean plugin architecture for interaction system
15
- - Good type safety throughout interaction module
16
- - Proper separation between CLI, Telegram, Webhook, and Auto plugins
17
- - Unified verification layer eliminates duplication
18
- - Test coverage for critical paths
19
-
20
- **Weaknesses:**
21
- - Multiple files exceed 400-line limit (violates CLAUDE.md)
22
- - Missing error handling for network failures in Telegram/Webhook plugins
23
- - No input validation for malformed webhook callbacks
24
- - JSON.parse without try-catch in several locations
25
- - Auto plugin security rule not enforced via config validation
26
- - Missing tests for edge cases (network failures, malformed input, race conditions)
27
-
28
- ---
29
-
30
- ## Critical Findings
31
-
32
- | ID | Severity | File | Line | Description | Fix |
33
- |:---|:---|:---|:---|:---|:---|
34
- | SEC-001 | CRITICAL | `src/interaction/plugins/webhook.ts` | 158 | JSON.parse without try-catch when handling webhook callbacks. Malformed JSON can crash the server. | Wrap in try-catch, return 400 Bad Request on parse error |
35
- | SEC-002 | CRITICAL | `src/interaction/plugins/telegram.ts` | 79 | No error handling for fetch failure when sending messages. Network errors can crash the plugin. | Add try-catch, throw descriptive error |
36
- | SEC-003 | CRITICAL | `src/interaction/plugins/telegram.ts` | 244 | No error handling for getUpdates fetch failure. Can cause infinite loop on network errors. | Add try-catch with exponential backoff |
37
- | SEC-004 | CRITICAL | `src/interaction/plugins/auto.ts` | 72-73 | Security-review never-auto-approve rule is code-based, not config-enforced. Can be accidentally removed. | Add to config schema validation, enforce at chain level |
38
- | REL-001 | CRITICAL | `src/interaction/chain.ts` | 74-82 | Catch block swallows ALL errors (not just timeout). Plugin crashes are silently converted to timeout responses. | Only catch timeout-specific errors, re-throw others |
39
- | REL-002 | HIGH | `src/interaction/plugins/webhook.ts` | 80-90 | Polling loop has no exponential backoff. Can cause high CPU usage on stuck requests. | Add exponential backoff with max delay |
40
- | REL-003 | HIGH | `src/interaction/plugins/telegram.ts` | 96-111 | Polling loop has no exponential backoff. Can hammer Telegram API and get rate limited. | Add exponential backoff (start 1s, max 5s) |
41
- | TYPE-001 | HIGH | `src/interaction/plugins/webhook.ts` | 117, 127 | Double `as unknown as` casts to work around Bun.serve typing. Loses type safety. | Add proper type definitions for Bun.serve return type |
42
- | ARCH-001 | HIGH | Multiple files | - | 15 files exceed 400-line limit, violating CLAUDE.md hard requirement. | Split files as documented below |
43
- | LOG-001 | MEDIUM | `src/interaction/plugins/telegram.ts` | 79-82 | Telegram API error response not logged. Silent failures are hard to debug. | Log error response body before throwing |
44
- | LOG-002 | MEDIUM | `src/interaction/plugins/webhook.ts` | 72-74 | Webhook POST failure not logged with response body. | Log response body before throwing |
45
- | TEST-001 | MEDIUM | `test/unit/interaction-plugins.test.ts` | - | No tests for network failures, malformed input, or timeout edge cases. | Add failure scenario tests |
46
- | TEST-002 | MEDIUM | `test/unit/interaction-plugins.test.ts` | - | Auto plugin LLM call not mocked. Real LLM calls in tests are slow and flaky. | Mock Bun.spawn for LLM calls |
47
- | MEM-001 | LOW | `src/interaction/plugins/telegram.ts` | 43 | `pendingMessages` Map grows unbounded. Never cleaned up on timeout. | Add cleanup in sendTimeoutMessage |
48
- | MEM-002 | LOW | `src/interaction/plugins/webhook.ts` | 29 | `pendingResponses` Map grows unbounded. | Add cleanup in cancel() method |
49
-
50
- ---
51
-
52
- ## Files Exceeding 400-Line Limit (ARCH-001)
53
-
54
- **CRITICAL:** CLAUDE.md mandates **400 lines maximum** per file. The following files violate this:
55
-
56
- | File | Lines | Recommended Split |
57
- |:---|---:|:---|
58
- | `src/config/schema.ts` | 853 | Split into: `schema-core.ts` (types), `schema-routing.ts`, `schema-interaction.ts`, `schema-validation.ts` |
59
- | `src/agents/claude.ts` | 820 | Split into: `claude-adapter.ts`, `claude-session.ts`, `claude-parser.ts` |
60
- | `src/tdd/orchestrator.ts` | 743 | Split into: `orchestrator.ts` (main loop), `session-manager.ts`, `verdict-handler.ts` |
61
- | `src/execution/sequential-executor.ts` | 648 | Split into: `executor.ts`, `story-runner.ts`, `retry-handler.ts` |
62
- | `src/cli/diagnose.ts` | 638 | Split into: `diagnose.ts`, `checks.ts`, `formatters.ts` |
63
- | `src/execution/post-verify.ts` | 584 | Split into: `post-verify.ts`, `rectification.ts`, `escalation-decision.ts` |
64
- | `src/context/builder.ts` | 576 | Split into: `builder.ts`, `providers.ts`, `test-coverage.ts` |
65
- | `src/cli/analyze.ts` | 568 | Split into: `analyze.ts`, `metrics.ts`, `reports.ts` |
66
- | `src/precheck/checks.ts` | 548 | Split into: `checks.ts`, `validators.ts`, `git-checks.ts` |
67
- | `src/cli/status.ts` | 519 | Split into: `status.ts`, `formatters.ts`, `progress.ts` |
68
- | `src/execution/helpers.ts` | 450 | Split into: `story-filters.ts`, `batch-helpers.ts`, `status-helpers.ts` |
69
- | `src/execution/escalation/tier-escalation.ts` | 439 | Split into: `tier-escalation.ts`, `cost-calculator.ts` |
70
- | `src/routing/strategies/llm.ts` | 432 | Split into: `llm-router.ts`, `batch-router.ts`, `cache.ts` |
71
- | `src/agents/types.ts` | 430 | Split into: `agent-types.ts`, `session-types.ts`, `result-types.ts` |
72
- | `src/execution/parallel.ts` | 404 | OK (close to limit, watch carefully) |
73
-
74
- **Action Required:** These files MUST be split before v0.15.0 release. This is a blocking requirement per CLAUDE.md.
75
-
76
- ---
77
-
78
- ## Security Analysis
79
-
80
- ### Input Validation
81
-
82
- **FAIL:** Webhook plugin does not validate incoming callback structure.
83
-
84
- ```typescript
85
- // src/interaction/plugins/webhook.ts:158 (VULNERABLE)
86
- const response = JSON.parse(body) as InteractionResponse;
87
- this.pendingResponses.set(requestId, response);
88
- ```
89
-
90
- **Attack Vector:**
91
- - Attacker sends `{"malicious": "payload"}` to webhook callback
92
- - JSON.parse succeeds but object doesn't match InteractionResponse
93
- - Type assertion `as InteractionResponse` bypasses type checking
94
- - Invalid response stored in Map, causes undefined behavior later
95
-
96
- **Fix:** Add Zod schema validation:
97
-
98
- ```typescript
99
- import { z } from "zod";
100
-
101
- const InteractionResponseSchema = z.object({
102
- requestId: z.string(),
103
- action: z.enum(["approve", "reject", "choose", "input", "skip", "abort"]),
104
- value: z.string().optional(),
105
- respondedBy: z.string().optional(),
106
- respondedAt: z.number(),
107
- });
108
-
109
- // In handleRequest():
110
- try {
111
- const parsed = JSON.parse(body);
112
- const response = InteractionResponseSchema.parse(parsed);
113
- this.pendingResponses.set(requestId, response);
114
- } catch (err) {
115
- return new Response("Bad Request: Invalid response format", { status: 400 });
116
- }
117
- ```
118
-
119
- ### Credential Handling
120
-
121
- **PASS:** Telegram bot token and webhook secrets are stored correctly:
122
- - Read from env vars or config (never hardcoded)
123
- - HMAC verification uses timing-safe comparison
124
- - Secrets not logged
125
-
126
- **Recommendation:** Add config validation to reject empty secrets:
127
-
128
- ```typescript
129
- // src/config/schema.ts
130
- interaction: {
131
- config: {
132
- secret: z.string().min(32).optional(), // Enforce minimum secret length
133
- }
134
- }
135
- ```
136
-
137
- ### SSRF Protection
138
-
139
- **N/A:** Webhook URL is user-configured (not from untrusted input). No SSRF risk.
140
-
141
- ### Auto Plugin Security Rule
142
-
143
- **FAIL:** Security-review never-auto-approve rule is enforced in code only:
144
-
145
- ```typescript
146
- // src/interaction/plugins/auto.ts:72-74
147
- if (request.metadata?.trigger === "security-review") {
148
- return undefined; // Escalate to human
149
- }
150
- ```
151
-
152
- **Issue:** This can be accidentally removed during refactoring.
153
-
154
- **Fix:** Enforce at config schema level:
155
-
156
- ```typescript
157
- // src/config/schema.ts
158
- triggers: {
159
- "security-review": z.object({
160
- enabled: z.boolean(),
161
- autoApprove: z.literal(false), // NEVER allow auto-approve for security
162
- })
163
- }
164
- ```
165
-
166
- ---
167
-
168
- ## Reliability Analysis
169
-
170
- ### Error Handling
171
-
172
- **FAIL:** Network errors are not handled properly.
173
-
174
- **Telegram Plugin (Critical):**
175
-
176
- ```typescript
177
- // src/interaction/plugins/telegram.ts:68 (VULNERABLE)
178
- const response = await fetch(`https://api.telegram.org/bot${this.botToken}/sendMessage`, {
179
- method: "POST",
180
- headers: { "Content-Type": "application/json" },
181
- body: JSON.stringify({...}),
182
- });
183
-
184
- const data = (await response.json()) as { ok: boolean; result: TelegramMessage };
185
- if (!data.ok) {
186
- throw new Error("Failed to send Telegram message");
187
- }
188
- ```
189
-
190
- **Issues:**
191
- 1. `fetch()` can throw on network errors (connection refused, DNS failure, timeout)
192
- 2. `response.json()` can throw on malformed JSON
193
- 3. `data.ok` check assumes `data` is defined
194
- 4. No retry logic for transient failures
195
-
196
- **Fix:**
197
-
198
- ```typescript
199
- try {
200
- const response = await fetch(`https://api.telegram.org/bot${this.botToken}/sendMessage`, {
201
- method: "POST",
202
- headers: { "Content-Type": "application/json" },
203
- body: JSON.stringify({...}),
204
- });
205
-
206
- if (!response.ok) {
207
- const errorBody = await response.text();
208
- throw new Error(`Telegram API error (${response.status}): ${errorBody}`);
209
- }
210
-
211
- const data = await response.json();
212
- if (!data.ok) {
213
- throw new Error(`Telegram API returned ok=false: ${JSON.stringify(data)}`);
214
- }
215
-
216
- this.pendingMessages.set(request.id, data.result.message_id);
217
- } catch (err) {
218
- const msg = err instanceof Error ? err.message : String(err);
219
- throw new Error(`Failed to send Telegram message: ${msg}`);
220
- }
221
- ```
222
-
223
- **Webhook Plugin (Critical):**
224
-
225
- Same issues as Telegram. Apply similar fix pattern.
226
-
227
- ### Race Conditions
228
-
229
- **PASS:** No obvious race conditions found. Interaction chain is single-threaded per request.
230
-
231
- **Potential Issue:** Webhook server starts on first `receive()` call, but multiple concurrent calls could race:
232
-
233
- ```typescript
234
- // src/interaction/plugins/webhook.ts:109
235
- private async startServer(): Promise<void> {
236
- if (this.server) return; // Already running
237
-
238
- const port = this.config.callbackPort ?? 8765;
239
- this.server = Bun.serve({...}) as unknown as Server;
240
- }
241
- ```
242
-
243
- **Race:** Two concurrent `receive()` calls could both check `if (this.server)` before either sets it.
244
-
245
- **Fix:** Use a mutex or Promise-based lock:
246
-
247
- ```typescript
248
- private serverStartPromise: Promise<void> | null = null;
249
-
250
- private async startServer(): Promise<void> {
251
- if (this.server) return;
252
- if (this.serverStartPromise) {
253
- await this.serverStartPromise;
254
- return;
255
- }
256
-
257
- this.serverStartPromise = (async () => {
258
- const port = this.config.callbackPort ?? 8765;
259
- this.server = Bun.serve({...}) as unknown as Server;
260
- })();
261
-
262
- await this.serverStartPromise;
263
- this.serverStartPromise = null;
264
- }
265
- ```
266
-
267
- ### Memory Leaks
268
-
269
- **MEDIUM:** Two Maps grow unbounded:
270
- - `TelegramInteractionPlugin.pendingMessages` (Line 42)
271
- - `WebhookInteractionPlugin.pendingResponses` (Line 29)
272
-
273
- **Issue:** When a request times out, the entry is never removed from the Map.
274
-
275
- **Fix:**
276
-
277
- ```typescript
278
- // In sendTimeoutMessage() / cancel():
279
- this.pendingMessages.delete(requestId);
280
- this.pendingResponses.delete(requestId);
281
- ```
282
-
283
- Already implemented in `sendTimeoutMessage()` for Telegram (line 331), but not in `cancel()` for Webhook.
284
-
285
- ---
286
-
287
- ## Test Coverage Gaps
288
-
289
- ### Current Coverage
290
-
291
- **Good:**
292
- - ✅ Plugin initialization (with/without config, env vars)
293
- - ✅ Config validation (missing required fields)
294
- - ✅ Auto plugin security-review rejection
295
-
296
- **Missing:**
297
- - ❌ Network failure scenarios (Telegram API down, webhook unreachable)
298
- - ❌ Malformed responses (invalid JSON, wrong structure)
299
- - ❌ Timeout edge cases (request expires during polling)
300
- - ❌ Concurrent request handling
301
- - ❌ Memory leak verification (Map cleanup)
302
- - ❌ Auto plugin LLM call (currently untested, would make real API calls)
303
-
304
- ### Recommended Additional Tests
305
-
306
- ```typescript
307
- describe("TelegramInteractionPlugin - Error Handling", () => {
308
- test("should handle network failure gracefully", async () => {
309
- const plugin = new TelegramInteractionPlugin();
310
- await plugin.init({ botToken: "token", chatId: "123" });
311
-
312
- // Mock fetch to throw network error
313
- global.fetch = async () => { throw new Error("ECONNREFUSED") };
314
-
315
- const request = { /* ... */ };
316
- await expect(plugin.send(request)).rejects.toThrow("Failed to send Telegram message");
317
- });
318
-
319
- test("should handle malformed API response", async () => {
320
- // Mock fetch to return invalid JSON
321
- global.fetch = async () => new Response("not json");
322
- // ... test
323
- });
324
-
325
- test("should clean up pendingMessages on timeout", async () => {
326
- // ... verify Map is empty after timeout
327
- });
328
- });
329
-
330
- describe("WebhookInteractionPlugin - Security", () => {
331
- test("should reject malformed callback payload", async () => {
332
- const plugin = new WebhookInteractionPlugin();
333
- await plugin.init({ url: "http://example.com" });
334
-
335
- const malformed = { malicious: "payload" };
336
- const response = await plugin.handleRequest(
337
- new Request("http://localhost:8765/nax/interact/test-id", {
338
- method: "POST",
339
- body: JSON.stringify(malformed),
340
- })
341
- );
342
-
343
- expect(response.status).toBe(400);
344
- });
345
-
346
- test("should reject callback without HMAC when secret configured", async () => {
347
- // ... test
348
- });
349
- });
350
-
351
- describe("AutoInteractionPlugin - LLM", () => {
352
- test("should make correct LLM decision (mocked)", async () => {
353
- // Mock Bun.spawn to return fake LLM response
354
- const originalSpawn = Bun.spawn;
355
- Bun.spawn = (cmd, opts) => {
356
- const mockStdout = new ReadableStream({
357
- start(controller) {
358
- controller.enqueue(new TextEncoder().encode(
359
- JSON.stringify({
360
- action: "approve",
361
- confidence: 0.8,
362
- reasoning: "test"
363
- })
364
- ));
365
- controller.close();
366
- }
367
- });
368
- return { stdout: mockStdout, stderr: new ReadableStream(), exited: Promise.resolve(0) };
369
- };
370
-
371
- // ... test decision logic
372
-
373
- Bun.spawn = originalSpawn; // Restore
374
- });
375
- });
376
- ```
377
-
378
- ---
379
-
380
- ## Architecture Compliance
381
-
382
- ### Plugin Chain Escalation
383
-
384
- **Question:** Does the plugin chain correctly handle escalation when all plugins fail?
385
-
386
- **Answer:** **PARTIAL FAIL**
387
-
388
- Current behavior:
389
- - `InteractionChain.receive()` catches ALL errors and returns timeout response
390
- - If primary plugin throws, it's converted to timeout (action: "skip")
391
- - No escalation to secondary plugins
392
-
393
- **Expected behavior:**
394
- - Try primary plugin
395
- - On failure, try next plugin in chain (by priority)
396
- - Only return timeout if all plugins fail OR timeout reached
397
-
398
- **Current code:**
399
- ```typescript
400
- // src/interaction/chain.ts:63-82
401
- async receive(requestId: string, timeout?: number): Promise<InteractionResponse> {
402
- const plugin = this.getPrimary();
403
- if (!plugin) {
404
- throw new Error("No interaction plugin registered");
405
- }
406
-
407
- const timeoutMs = timeout ?? this.config.defaultTimeout;
408
-
409
- try {
410
- const response = await plugin.receive(requestId, timeoutMs);
411
- return response;
412
- } catch (err) {
413
- // BUG: All errors converted to timeout, no fallback to other plugins
414
- return {
415
- requestId,
416
- action: "skip",
417
- respondedBy: "timeout",
418
- respondedAt: Date.now(),
419
- };
420
- }
421
- }
422
- ```
423
-
424
- **Fix:** Implement plugin fallback cascade:
425
-
426
- ```typescript
427
- async receive(requestId: string, timeout?: number): Promise<InteractionResponse> {
428
- const timeoutMs = timeout ?? this.config.defaultTimeout;
429
- const errors: Error[] = [];
430
-
431
- // Try each plugin in priority order
432
- for (const entry of this.plugins) {
433
- try {
434
- const response = await entry.plugin.receive(requestId, timeoutMs);
435
- return response;
436
- } catch (err) {
437
- errors.push(err instanceof Error ? err : new Error(String(err)));
438
- // Continue to next plugin
439
- }
440
- }
441
-
442
- // All plugins failed
443
- throw new Error(
444
- `All interaction plugins failed: ${errors.map(e => e.message).join("; ")}`
445
- );
446
- }
447
- ```
448
-
449
- ### State Persistence
450
-
451
- **Question:** Does state persistence correctly serialize/deserialize all runner state?
452
-
453
- **Answer:** **PASS**
454
-
455
- - `RunState` interface covers all necessary fields (line 11-41)
456
- - Serialization uses JSON.stringify with pretty-printing (line 48)
457
- - Deserialization has error handling for corrupted files (line 68-70)
458
- - File operations use Bun-native APIs correctly
459
-
460
- **Recommendation:** Add Zod schema validation for loaded state:
461
-
462
- ```typescript
463
- import { z } from "zod";
464
-
465
- const RunStateSchema = z.object({
466
- feature: z.string(),
467
- prdPath: z.string(),
468
- iteration: z.number(),
469
- totalCost: z.number(),
470
- storiesCompleted: z.number(),
471
- pendingInteractions: z.array(z.any()), // Use InteractionRequestSchema
472
- completedInteractions: z.array(z.any()),
473
- pausedAt: z.number(),
474
- pauseReason: z.string(),
475
- currentStoryId: z.string().optional(),
476
- currentTier: z.string().optional(),
477
- currentModel: z.string().optional(),
478
- metadata: z.record(z.unknown()).optional(),
479
- });
480
-
481
- export async function deserializeRunState(featureDir: string): Promise<RunState | null> {
482
- try {
483
- const file = Bun.file(stateFile);
484
- const exists = await file.exists();
485
- if (!exists) return null;
486
-
487
- const json = await file.text();
488
- const parsed = JSON.parse(json);
489
- const state = RunStateSchema.parse(parsed); // Validate before returning
490
- return state as RunState;
491
- } catch (err) {
492
- // Log validation error for debugging
493
- console.error("Invalid run state file:", err);
494
- return null;
495
- }
496
- }
497
- ```
498
-
499
- ### Config Schema Validation
500
-
501
- **Question:** Are all config schema additions validated with Zod?
502
-
503
- **Answer:** **PARTIAL PASS**
504
-
505
- New `InteractionConfig` interface exists (line 289-304) but NOT in Zod schema.
506
-
507
- **Current issue:**
508
- ```typescript
509
- // src/config/schema.ts:289-304
510
- export interface InteractionConfig {
511
- plugin: string;
512
- config?: Record<string, unknown>;
513
- defaults: { timeout: number; fallback: string };
514
- triggers: Partial<Record<string, boolean | { enabled: boolean; fallback?: string; timeout?: number }>>;
515
- }
516
- ```
517
-
518
- This is a **TypeScript interface only** — no runtime validation!
519
-
520
- **Fix:** Add Zod schema:
521
-
522
- ```typescript
523
- const InteractionConfigSchema = z.object({
524
- plugin: z.enum(["cli", "telegram", "webhook", "auto"]),
525
- config: z.record(z.unknown()).optional(),
526
- defaults: z.object({
527
- timeout: z.number().min(1000).max(3600000), // 1s to 1hr
528
- fallback: z.enum(["continue", "skip", "escalate", "abort"]),
529
- }),
530
- triggers: z.record(
531
- z.union([
532
- z.boolean(),
533
- z.object({
534
- enabled: z.boolean(),
535
- fallback: z.enum(["continue", "skip", "escalate", "abort"]).optional(),
536
- timeout: z.number().min(1000).optional(),
537
- }),
538
- ])
539
- ).partial(),
540
- });
541
-
542
- // In main config schema:
543
- export const NaxConfigSchema = z.object({
544
- // ... existing fields
545
- interaction: InteractionConfigSchema.optional(),
546
- });
547
- ```
548
-
549
- ---
550
-
551
- ## Top 5 Fixes (Priority Order)
552
-
553
- ### 1. Fix Webhook JSON.parse Vulnerability (SEC-001)
554
- **File:** `src/interaction/plugins/webhook.ts:158`
555
- **Impact:** CRITICAL — Can crash server on malformed input
556
- **Effort:** 15 minutes
557
-
558
- Add try-catch + Zod validation:
559
- ```typescript
560
- try {
561
- const parsed = JSON.parse(body);
562
- const response = InteractionResponseSchema.parse(parsed);
563
- this.pendingResponses.set(requestId, response);
564
- } catch (err) {
565
- return new Response("Bad Request", { status: 400 });
566
- }
567
- ```
568
-
569
- ### 2. Add Network Error Handling to Telegram Plugin (SEC-002, SEC-003)
570
- **File:** `src/interaction/plugins/telegram.ts:68, 235`
571
- **Impact:** CRITICAL — Can crash plugin on network failures
572
- **Effort:** 30 minutes
573
-
574
- Wrap all fetch() calls in try-catch with descriptive errors.
575
-
576
- ### 3. Fix InteractionChain Error Swallowing (REL-001)
577
- **File:** `src/interaction/chain.ts:74-82`
578
- **Impact:** CRITICAL — Masks real errors as timeouts
579
- **Effort:** 20 minutes
580
-
581
- Implement plugin fallback cascade (see Architecture section).
582
-
583
- ### 4. Add Config Schema Validation for Interaction (SEC-004)
584
- **File:** `src/config/schema.ts`
585
- **Impact:** HIGH — Runtime validation missing
586
- **Effort:** 30 minutes
587
-
588
- Add Zod schemas for InteractionConfig and all trigger configs.
589
-
590
- ### 5. Split Files Over 400 Lines (ARCH-001)
591
- **Files:** 14 files (see table above)
592
- **Impact:** HIGH — Violates CLAUDE.md hard requirement
593
- **Effort:** 4-6 hours
594
-
595
- Start with largest offenders:
596
- 1. `config/schema.ts` (853 lines) → 4 files
597
- 2. `agents/claude.ts` (820 lines) → 3 files
598
- 3. `tdd/orchestrator.ts` (743 lines) → 3 files
599
-
600
- ---
601
-
602
- ## Conclusion
603
-
604
- The v0.15.0 Interactive Pipeline implementation demonstrates solid engineering with clean separation of concerns and a well-designed plugin architecture. However, **several CRITICAL security and reliability issues must be fixed before release**.
605
-
606
- **Blocking Issues for Release:**
607
- 1. ✅ Test coverage is adequate (10/10 tests pass)
608
- 2. ❌ **SEC-001, SEC-002, SEC-003** — Network error handling (CRITICAL)
609
- 3. ❌ **REL-001** — Error swallowing in chain (CRITICAL)
610
- 4. ❌ **ARCH-001** — 14 files exceed 400 lines (CRITICAL per CLAUDE.md)
611
-
612
- **Recommended Release Plan:**
613
- 1. Fix all CRITICAL findings (1-3 above) — **2 hours**
614
- 2. Fix HIGH findings (config validation, type casts) — **1 hour**
615
- 3. Split 3 largest files (config, agents, tdd) — **3 hours**
616
- 4. Add missing tests for network failures — **2 hours**
617
- 5. Re-run full test suite + typecheck — **30 minutes**
618
- 6. **Total:** ~8-9 hours to production-ready
619
-
620
- **Post-Release Backlog:**
621
- - Split remaining 11 files over 400 lines
622
- - Add comprehensive integration tests
623
- - Implement exponential backoff for polling loops
624
- - Add Prometheus metrics for interaction success/failure rates
625
-
626
- ---
627
-
628
- **Reviewer Signature:** Claude Sonnet 4.5
629
- **Review Completed:** 2026-02-28