@nathapp/nax 0.18.1
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.
- package/.gitlab-ci.yml +96 -0
- package/BRIEF.md +140 -0
- package/CHANGELOG.md +60 -0
- package/CLAUDE.md +159 -0
- package/README.md +373 -0
- package/US-007-IMPLEMENTATION.md +139 -0
- package/bin/nax.ts +930 -0
- package/biome.json +14 -0
- package/bun.lock +168 -0
- package/bunfig.toml +11 -0
- package/docs/20260216-fix-plan-context-review.md +56 -0
- package/docs/20260216-relentless-vs-ngent-comparison.md +208 -0
- package/docs/20260216-v02-plan.md +136 -0
- package/docs/20260216-v02-review.md +685 -0
- package/docs/20260217-dogfood-findings.md +56 -0
- package/docs/20260217-p2-plus-plan.md +117 -0
- package/docs/20260217-partial-fixes-plan.md +62 -0
- package/docs/20260217-plan-analyze-spec.md +117 -0
- package/docs/20260217-post-impl-review.md +1137 -0
- package/docs/20260217-quick-wins-plan.md +66 -0
- package/docs/20260217-split-runner-plan.md +75 -0
- package/docs/20260217-v03-impl-plan.md +80 -0
- package/docs/20260217-v03-post-impl-review.md +589 -0
- package/docs/20260217-v04-impl-plan.md +86 -0
- package/docs/20260217-v05-post-impl-review.md +850 -0
- package/docs/20260217-v06-post-impl-review.md +817 -0
- package/docs/20260218-adr003-port-plan.md +151 -0
- package/docs/20260218-review-adr003-verification.md +175 -0
- package/docs/20260219-fix-plan-bug16-19.md +79 -0
- package/docs/20260219-fix-plan-bug20-22.md +114 -0
- package/docs/20260219-plan-llm-routing.md +116 -0
- package/docs/20260219-review-bug20-22-fixes.md +135 -0
- package/docs/20260219-routing-baseline-keyword.md +63 -0
- package/docs/20260220-plan-structured-logging-p1.md +80 -0
- package/docs/20260220-plan-structured-logging-p2.md +37 -0
- package/docs/20260220-review-llm-routing.md +180 -0
- package/docs/20260220-review-post-fix-llm-routing.md +70 -0
- package/docs/20260221-fix-plan-relevantfiles-split.md +101 -0
- package/docs/20260221-fix-plan-routing-mode.md +125 -0
- package/docs/20260221-review-v0.9-implementation.md +379 -0
- package/docs/20260222-fix-plan-v091-routing-isolation.md +197 -0
- package/docs/20260223-fix-plan-prompt-audit.md +62 -0
- package/docs/20260224-nax-roadmap-phases.md +189 -0
- package/docs/20260225-phase2-llm-service-layer.md +401 -0
- package/docs/20260225-review-v0.10.1.md +187 -0
- package/docs/20260303-v010-implementation-plan.md +165 -0
- package/docs/CLAUDE.md.bak +191 -0
- package/docs/ROADMAP.md +165 -0
- package/docs/SPEC-rectification.md +0 -0
- package/docs/SPEC.md +324 -0
- package/docs/US-001-plugin-loading-verification.md +152 -0
- package/docs/architecture-analysis.md +1076 -0
- package/docs/bugs/BUG-21-escalation-null-attempts.md +48 -0
- package/docs/bugs-from-dogfood-run-c.md +243 -0
- package/docs/code-review-20260228.md +612 -0
- package/docs/code-review-v0.15.0.md +629 -0
- package/docs/hook-lifecycle-test-plan.md +149 -0
- package/docs/releases/v0.11.0-and-earlier.md +20 -0
- package/docs/releases/v0.12.0.md +15 -0
- package/docs/releases/v0.13.0.md +14 -0
- package/docs/releases/v0.14.0.md +20 -0
- package/docs/releases/v0.14.1.md +36 -0
- package/docs/releases/v0.14.2.md +51 -0
- package/docs/releases/v0.14.3.md +174 -0
- package/docs/releases/v0.14.4.md +94 -0
- package/docs/releases/v0.15.0.md +502 -0
- package/docs/releases/v0.15.1.md +170 -0
- package/docs/releases/v0.15.3.md +193 -0
- package/docs/specs/status-file-v0.10.1.md +812 -0
- package/docs/v0.10-global-config.md +206 -0
- package/docs/v0.10-plugin-system.md +415 -0
- package/docs/v0.10-prompt-optimizer.md +234 -0
- package/docs/v0.3-spec.md +244 -0
- package/docs/v0.4-spec.md +140 -0
- package/docs/v0.5-spec.md +237 -0
- package/docs/v0.6-spec.md +371 -0
- package/docs/v0.7-spec.md +177 -0
- package/docs/v0.8-llm-routing.md +206 -0
- package/docs/v0.8-structured-logging.md +132 -0
- package/docs/v0.9.3-prompt-audit.md +112 -0
- package/examples/plugins/console-reporter/index.test.ts +207 -0
- package/examples/plugins/console-reporter/index.ts +110 -0
- package/nax/config.json +147 -0
- package/nax/features/bugfix-v0171/prd.json +52 -0
- package/nax/features/config-management/prd.json +108 -0
- package/nax/features/config-management/progress.txt +5 -0
- package/nax/features/diagnose/acceptance.test.ts +412 -0
- package/nax/features/diagnose/prd.json +41 -0
- package/nax/features/orchestration-fixes/prd.json +89 -0
- package/nax/features/orchestration-fixes/progress.txt +1 -0
- package/nax/features/plugin-integration/US-007-VERIFICATION.md +259 -0
- package/nax/features/plugin-integration/prd.json +208 -0
- package/nax/features/plugin-integration/progress.txt +5 -0
- package/nax/features/precheck/prd.json +205 -0
- package/nax/features/precheck/progress.txt +15 -0
- package/nax/features/structured-logging/prd.json +199 -0
- package/nax/features/unlock/prd.json +36 -0
- package/package.json +47 -0
- package/src/acceptance/fix-generator.ts +348 -0
- package/src/acceptance/generator.ts +282 -0
- package/src/acceptance/index.ts +30 -0
- package/src/acceptance/types.ts +79 -0
- package/src/agents/claude-decompose.ts +169 -0
- package/src/agents/claude-plan.ts +139 -0
- package/src/agents/claude.ts +324 -0
- package/src/agents/cost.ts +268 -0
- package/src/agents/index.ts +13 -0
- package/src/agents/registry.ts +48 -0
- package/src/agents/types-extended.ts +133 -0
- package/src/agents/types.ts +113 -0
- package/src/agents/validation.ts +69 -0
- package/src/analyze/classifier.ts +305 -0
- package/src/analyze/index.ts +16 -0
- package/src/analyze/scanner.ts +175 -0
- package/src/analyze/types.ts +51 -0
- package/src/cli/accept.ts +108 -0
- package/src/cli/analyze-parser.ts +284 -0
- package/src/cli/analyze.ts +207 -0
- package/src/cli/config.ts +561 -0
- package/src/cli/constitution.ts +109 -0
- package/src/cli/diagnose-analysis.ts +159 -0
- package/src/cli/diagnose-formatter.ts +87 -0
- package/src/cli/diagnose.ts +203 -0
- package/src/cli/generate.ts +127 -0
- package/src/cli/index.ts +37 -0
- package/src/cli/init.ts +188 -0
- package/src/cli/interact.ts +295 -0
- package/src/cli/plan.ts +198 -0
- package/src/cli/plugins.ts +111 -0
- package/src/cli/prompts.ts +295 -0
- package/src/cli/runs.ts +174 -0
- package/src/cli/status-cost.ts +151 -0
- package/src/cli/status-features.ts +338 -0
- package/src/cli/status.ts +13 -0
- package/src/commands/common.ts +171 -0
- package/src/commands/diagnose.ts +17 -0
- package/src/commands/index.ts +8 -0
- package/src/commands/logs.ts +384 -0
- package/src/commands/precheck.ts +86 -0
- package/src/commands/unlock.ts +96 -0
- package/src/config/defaults.ts +160 -0
- package/src/config/index.ts +22 -0
- package/src/config/loader.ts +121 -0
- package/src/config/merger.ts +147 -0
- package/src/config/path-security.ts +121 -0
- package/src/config/paths.ts +27 -0
- package/src/config/schema.ts +56 -0
- package/src/config/schemas.ts +286 -0
- package/src/config/types.ts +423 -0
- package/src/config/validate.ts +103 -0
- package/src/constitution/generator.ts +191 -0
- package/src/constitution/generators/aider.ts +41 -0
- package/src/constitution/generators/claude.ts +35 -0
- package/src/constitution/generators/cursor.ts +36 -0
- package/src/constitution/generators/opencode.ts +38 -0
- package/src/constitution/generators/types.ts +33 -0
- package/src/constitution/generators/windsurf.ts +36 -0
- package/src/constitution/index.ts +10 -0
- package/src/constitution/loader.ts +133 -0
- package/src/constitution/types.ts +31 -0
- package/src/context/auto-detect.ts +227 -0
- package/src/context/builder.ts +246 -0
- package/src/context/elements.ts +83 -0
- package/src/context/formatter.ts +107 -0
- package/src/context/generator.ts +129 -0
- package/src/context/generators/aider.ts +34 -0
- package/src/context/generators/claude.ts +28 -0
- package/src/context/generators/cursor.ts +28 -0
- package/src/context/generators/opencode.ts +30 -0
- package/src/context/generators/windsurf.ts +28 -0
- package/src/context/greenfield.ts +114 -0
- package/src/context/index.ts +33 -0
- package/src/context/injector.ts +279 -0
- package/src/context/test-scanner.ts +370 -0
- package/src/context/types.ts +98 -0
- package/src/errors.ts +67 -0
- package/src/execution/batching.ts +157 -0
- package/src/execution/crash-recovery.ts +373 -0
- package/src/execution/escalation/escalation.ts +44 -0
- package/src/execution/escalation/index.ts +13 -0
- package/src/execution/escalation/tier-escalation.ts +295 -0
- package/src/execution/escalation/tier-outcome.ts +158 -0
- package/src/execution/helpers.ts +38 -0
- package/src/execution/index.ts +45 -0
- package/src/execution/lifecycle/acceptance-loop.ts +272 -0
- package/src/execution/lifecycle/headless-formatter.ts +85 -0
- package/src/execution/lifecycle/index.ts +12 -0
- package/src/execution/lifecycle/parallel-lifecycle.ts +101 -0
- package/src/execution/lifecycle/precheck-runner.ts +140 -0
- package/src/execution/lifecycle/run-cleanup.ts +81 -0
- package/src/execution/lifecycle/run-completion.ts +129 -0
- package/src/execution/lifecycle/run-initialization.ts +141 -0
- package/src/execution/lifecycle/run-lifecycle.ts +312 -0
- package/src/execution/lifecycle/run-setup.ts +204 -0
- package/src/execution/lifecycle/story-hooks.ts +38 -0
- package/src/execution/lifecycle/story-size-prompts.ts +123 -0
- package/src/execution/lock.ts +115 -0
- package/src/execution/parallel-executor.ts +216 -0
- package/src/execution/parallel.ts +400 -0
- package/src/execution/pid-registry.ts +280 -0
- package/src/execution/pipeline-result-handler.ts +388 -0
- package/src/execution/post-verify-rectification.ts +188 -0
- package/src/execution/post-verify.ts +274 -0
- package/src/execution/progress.ts +25 -0
- package/src/execution/prompts.ts +127 -0
- package/src/execution/queue-handler.ts +109 -0
- package/src/execution/rectification.ts +13 -0
- package/src/execution/runner.ts +377 -0
- package/src/execution/sequential-executor.ts +388 -0
- package/src/execution/status-file.ts +264 -0
- package/src/execution/status-writer.ts +139 -0
- package/src/execution/story-context.ts +229 -0
- package/src/execution/test-output-parser.ts +14 -0
- package/src/execution/verification.ts +72 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/runner.ts +286 -0
- package/src/hooks/types.ts +67 -0
- package/src/interaction/chain.ts +154 -0
- package/src/interaction/index.ts +60 -0
- package/src/interaction/init.ts +83 -0
- package/src/interaction/plugins/auto.ts +217 -0
- package/src/interaction/plugins/cli.ts +300 -0
- package/src/interaction/plugins/telegram.ts +384 -0
- package/src/interaction/plugins/webhook.ts +258 -0
- package/src/interaction/state.ts +171 -0
- package/src/interaction/triggers.ts +229 -0
- package/src/interaction/types.ts +163 -0
- package/src/logger/formatters.ts +84 -0
- package/src/logger/index.ts +16 -0
- package/src/logger/logger.ts +298 -0
- package/src/logger/types.ts +48 -0
- package/src/logging/formatter.ts +355 -0
- package/src/logging/index.ts +22 -0
- package/src/logging/types.ts +93 -0
- package/src/metrics/aggregator.ts +190 -0
- package/src/metrics/index.ts +14 -0
- package/src/metrics/tracker.ts +200 -0
- package/src/metrics/types.ts +109 -0
- package/src/optimizer/index.ts +62 -0
- package/src/optimizer/noop.optimizer.ts +24 -0
- package/src/optimizer/rule-based.optimizer.ts +248 -0
- package/src/optimizer/types.ts +53 -0
- package/src/pipeline/events.ts +130 -0
- package/src/pipeline/index.ts +19 -0
- package/src/pipeline/runner.ts +161 -0
- package/src/pipeline/stages/acceptance.ts +197 -0
- package/src/pipeline/stages/completion.ts +99 -0
- package/src/pipeline/stages/constitution.ts +63 -0
- package/src/pipeline/stages/context.ts +117 -0
- package/src/pipeline/stages/execution.ts +194 -0
- package/src/pipeline/stages/index.ts +62 -0
- package/src/pipeline/stages/optimizer.ts +74 -0
- package/src/pipeline/stages/prompt.ts +57 -0
- package/src/pipeline/stages/queue-check.ts +103 -0
- package/src/pipeline/stages/review.ts +181 -0
- package/src/pipeline/stages/routing.ts +81 -0
- package/src/pipeline/stages/verify.ts +100 -0
- package/src/pipeline/types.ts +167 -0
- package/src/plugins/index.ts +31 -0
- package/src/plugins/loader.ts +287 -0
- package/src/plugins/registry.ts +168 -0
- package/src/plugins/types.ts +327 -0
- package/src/plugins/validator.ts +352 -0
- package/src/prd/index.ts +172 -0
- package/src/prd/types.ts +202 -0
- package/src/precheck/checks-blockers.ts +391 -0
- package/src/precheck/checks-warnings.ts +142 -0
- package/src/precheck/checks.ts +30 -0
- package/src/precheck/index.ts +247 -0
- package/src/precheck/story-size-gate.ts +144 -0
- package/src/precheck/types.ts +31 -0
- package/src/queue/index.ts +2 -0
- package/src/queue/manager.ts +254 -0
- package/src/queue/types.ts +54 -0
- package/src/review/index.ts +8 -0
- package/src/review/runner.ts +172 -0
- package/src/review/types.ts +66 -0
- package/src/routing/builder.ts +81 -0
- package/src/routing/chain.ts +74 -0
- package/src/routing/index.ts +16 -0
- package/src/routing/loader.ts +58 -0
- package/src/routing/router.ts +303 -0
- package/src/routing/strategies/adaptive.ts +215 -0
- package/src/routing/strategies/index.ts +8 -0
- package/src/routing/strategies/keyword.ts +163 -0
- package/src/routing/strategies/llm-prompts.ts +209 -0
- package/src/routing/strategies/llm.ts +235 -0
- package/src/routing/strategies/manual.ts +50 -0
- package/src/routing/strategy.ts +99 -0
- package/src/tdd/cleanup.ts +111 -0
- package/src/tdd/index.ts +23 -0
- package/src/tdd/isolation.ts +123 -0
- package/src/tdd/orchestrator.ts +383 -0
- package/src/tdd/prompts.ts +270 -0
- package/src/tdd/rectification-gate.ts +183 -0
- package/src/tdd/session-runner.ts +179 -0
- package/src/tdd/types.ts +81 -0
- package/src/tdd/verdict.ts +271 -0
- package/src/tui/App.tsx +265 -0
- package/src/tui/components/AgentPanel.tsx +75 -0
- package/src/tui/components/CostOverlay.tsx +118 -0
- package/src/tui/components/HelpOverlay.tsx +107 -0
- package/src/tui/components/StatusBar.tsx +63 -0
- package/src/tui/components/StoriesPanel.tsx +177 -0
- package/src/tui/hooks/useKeyboard.ts +142 -0
- package/src/tui/hooks/useLayout.ts +137 -0
- package/src/tui/hooks/usePipelineEvents.ts +183 -0
- package/src/tui/hooks/usePty.ts +194 -0
- package/src/tui/index.tsx +38 -0
- package/src/tui/types.ts +76 -0
- package/src/utils/git.ts +83 -0
- package/src/utils/queue-writer.ts +54 -0
- package/src/verification/executor.ts +235 -0
- package/src/verification/gate.ts +207 -0
- package/src/verification/index.ts +12 -0
- package/src/verification/parser.ts +230 -0
- package/src/verification/rectification.ts +108 -0
- package/src/verification/types.ts +113 -0
- package/src/worktree/dispatcher.ts +65 -0
- package/src/worktree/index.ts +2 -0
- package/src/worktree/manager.ts +187 -0
- package/src/worktree/merge.ts +301 -0
- package/src/worktree/types.ts +4 -0
- package/test/TEST_COVERAGE_US001.md +217 -0
- package/test/TEST_COVERAGE_US003.md +84 -0
- package/test/TEST_COVERAGE_US005.md +86 -0
- package/test/US-002-orchestrator.test.ts +246 -0
- package/test/acceptance/cm-003-default-view.test.ts +194 -0
- package/test/execution/pid-registry.test.ts +240 -0
- package/test/execution/post-verify.test.ts +224 -0
- package/test/helpers/timeout.ts +42 -0
- package/test/integration/US-002-TEST-SUMMARY.md +107 -0
- package/test/integration/US-003-TEST-SUMMARY.md +149 -0
- package/test/integration/US-004-TEST-SUMMARY.md +106 -0
- package/test/integration/US-005-TEST-SUMMARY.md +138 -0
- package/test/integration/US-007-TEST-SUMMARY.md +100 -0
- package/test/integration/agent-validation.test.ts +439 -0
- package/test/integration/analyze-integration.test.ts +261 -0
- package/test/integration/analyze-scanner.test.ts +131 -0
- package/test/integration/cli-config-default-edge-cases.test.ts +222 -0
- package/test/integration/cli-config-default-view.test.ts +229 -0
- package/test/integration/cli-config-diff.test.ts +460 -0
- package/test/integration/cli-config.test.ts +736 -0
- package/test/integration/cli-diagnose.test.ts +592 -0
- package/test/integration/cli-logs.test.ts +314 -0
- package/test/integration/cli-plugins.test.ts +678 -0
- package/test/integration/cli-precheck.test.ts +371 -0
- package/test/integration/cli-run-headless.test.ts +173 -0
- package/test/integration/cli.test.ts +75 -0
- package/test/integration/config/merger.test.ts +465 -0
- package/test/integration/config/paths.test.ts +51 -0
- package/test/integration/config-loader.test.ts +265 -0
- package/test/integration/config.test.ts +444 -0
- package/test/integration/context-integration.test.ts +702 -0
- package/test/integration/context-provider-injection.test.ts +506 -0
- package/test/integration/context-verification-integration.test.ts +295 -0
- package/test/integration/e2e.test.ts +896 -0
- package/test/integration/execution.test.ts +625 -0
- package/test/integration/helpers.test.ts +295 -0
- package/test/integration/hooks.test.ts +361 -0
- package/test/integration/interaction-chain-pipeline.test.ts +464 -0
- package/test/integration/isolation.test.ts +143 -0
- package/test/integration/logger.test.ts +461 -0
- package/test/integration/parallel.test.ts +250 -0
- package/test/integration/path-security.test.ts +173 -0
- package/test/integration/pipeline-acceptance.test.ts +302 -0
- package/test/integration/pipeline-events.test.ts +475 -0
- package/test/integration/pipeline.test.ts +658 -0
- package/test/integration/plan.test.ts +157 -0
- package/test/integration/plugin-routing.test.ts +921 -0
- package/test/integration/plugins/config-integration.test.ts +172 -0
- package/test/integration/plugins/config-resolution.test.ts +522 -0
- package/test/integration/plugins/loader.test.ts +641 -0
- package/test/integration/plugins/registry.test.ts +746 -0
- package/test/integration/plugins/validator.test.ts +563 -0
- package/test/integration/prd-pause.test.ts +205 -0
- package/test/integration/prd-resolvers.test.ts +185 -0
- package/test/integration/precheck-integration.test.ts +468 -0
- package/test/integration/precheck.test.ts +805 -0
- package/test/integration/progress.test.ts +34 -0
- package/test/integration/rectification-flow.test.ts +512 -0
- package/test/integration/reporter-lifecycle.test.ts +860 -0
- package/test/integration/review-config-commands.test.ts +319 -0
- package/test/integration/review-config-schema.test.ts +116 -0
- package/test/integration/review-plugin-integration.test.ts +722 -0
- package/test/integration/review.test.ts +149 -0
- package/test/integration/routing-stage-bug-021.test.ts +274 -0
- package/test/integration/routing-stage-greenfield.test.ts +286 -0
- package/test/integration/runner-config-plugins.test.ts +461 -0
- package/test/integration/runner-fixes.test.ts +399 -0
- package/test/integration/runner-plugin-integration.test.ts +543 -0
- package/test/integration/runner.test.ts +1679 -0
- package/test/integration/s5-greenfield-fallback.test.ts +297 -0
- package/test/integration/status-file-integration.test.ts +325 -0
- package/test/integration/status-file.test.ts +379 -0
- package/test/integration/status-writer.test.ts +345 -0
- package/test/integration/story-id-in-events.test.ts +273 -0
- package/test/integration/tdd-cleanup.test.ts +246 -0
- package/test/integration/tdd-orchestrator.test.ts +1762 -0
- package/test/integration/test-scanner.test.ts +403 -0
- package/test/integration/verification-asset-check.test.ts +142 -0
- package/test/integration/verify-stage.test.ts +275 -0
- package/test/integration/worktree/manager.test.ts +218 -0
- package/test/integration/worktree/merge.test.ts +341 -0
- package/test/manual/logging-formatter-demo.ts +158 -0
- package/test/ui/tui-agent-panel.test.tsx +99 -0
- package/test/ui/tui-controls.test.ts +334 -0
- package/test/ui/tui-cost-and-pty.test.ts +189 -0
- package/test/ui/tui-layout.test.ts +378 -0
- package/test/ui/tui-pty-integration.test.tsx +159 -0
- package/test/ui/tui-stories.test.ts +332 -0
- package/test/unit/acceptance.test.ts +186 -0
- package/test/unit/agent-stderr-capture.test.ts +146 -0
- package/test/unit/analyze-classifier.test.ts +215 -0
- package/test/unit/analyze.test.ts +224 -0
- package/test/unit/auto-detect.test.ts +249 -0
- package/test/unit/cli-status.test.ts +417 -0
- package/test/unit/commands/common.test.ts +320 -0
- package/test/unit/commands/logs.test.ts +416 -0
- package/test/unit/commands/unlock.test.ts +319 -0
- package/test/unit/constitution-generators.test.ts +160 -0
- package/test/unit/constitution.test.ts +209 -0
- package/test/unit/context.test.ts +1722 -0
- package/test/unit/cost.test.ts +231 -0
- package/test/unit/crash-recovery.test.ts +308 -0
- package/test/unit/escalation.test.ts +126 -0
- package/test/unit/execution-logging-stderr.test.ts +156 -0
- package/test/unit/execution-stage.test.ts +122 -0
- package/test/unit/fix-generator.test.ts +275 -0
- package/test/unit/formatters.test.ts +469 -0
- package/test/unit/greenfield.test.ts +179 -0
- package/test/unit/helpers.test.ts +317 -0
- package/test/unit/interaction/human-review-trigger.test.ts +164 -0
- package/test/unit/interaction-network-failures.test.ts +389 -0
- package/test/unit/interaction-plugins.test.ts +164 -0
- package/test/unit/isolation.test.ts +134 -0
- package/test/unit/logging/formatter.test.ts +455 -0
- package/test/unit/merge.test.ts +268 -0
- package/test/unit/metrics.test.ts +276 -0
- package/test/unit/optimizer/noop.optimizer.test.ts +125 -0
- package/test/unit/optimizer/rule-based.optimizer.test.ts +358 -0
- package/test/unit/prd-auto-default.test.ts +290 -0
- package/test/unit/prd-failure-category.test.ts +176 -0
- package/test/unit/prd-get-next-story.test.ts +186 -0
- package/test/unit/precheck-checks.test.ts +840 -0
- package/test/unit/precheck-story-size-gate.test.ts +287 -0
- package/test/unit/precheck-types.test.ts +142 -0
- package/test/unit/prompts.test.ts +475 -0
- package/test/unit/queue.test.ts +237 -0
- package/test/unit/rectification.test.ts +284 -0
- package/test/unit/registry.test.ts +287 -0
- package/test/unit/routing.test.ts +937 -0
- package/test/unit/run-lifecycle.test.ts +140 -0
- package/test/unit/storyid-events.test.ts +224 -0
- package/test/unit/tdd-verdict.test.ts +492 -0
- package/test/unit/test-output-parser.test.ts +377 -0
- package/test/unit/verdict.test.ts +324 -0
- package/test/unit/worktree-manager.test.ts +158 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,1076 @@
|
|
|
1
|
+
# NAX Architecture Deep Analysis
|
|
2
|
+
|
|
3
|
+
**Date:** 2026-02-28
|
|
4
|
+
**Version:** 0.14.1
|
|
5
|
+
**Codebase Size:** ~27,333 lines across 146 TypeScript files
|
|
6
|
+
**Analysis Method:** Complete source code review via Explore agent
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Executive Summary
|
|
11
|
+
|
|
12
|
+
NAX is a pipeline-based AI agent orchestrator with strong architectural foundations but one critical technical debt item: a 1,685-line god file (`execution/runner.ts`) that violates the project's 400-line guideline by 4x. Overall grade: **B+** (would be A- after refactoring the god file).
|
|
13
|
+
|
|
14
|
+
**Strengths:**
|
|
15
|
+
- Clean pipeline architecture with composable stages
|
|
16
|
+
- Excellent plugin system with 6 extension points
|
|
17
|
+
- Strong type safety (TypeScript + Zod)
|
|
18
|
+
- Good test coverage (105 test files)
|
|
19
|
+
- Well-isolated core modules
|
|
20
|
+
|
|
21
|
+
**Critical Issues:**
|
|
22
|
+
- `execution/runner.ts` is a 1,685-line god file handling 8+ concerns
|
|
23
|
+
- High coupling in execution module (imports from 15+ modules)
|
|
24
|
+
- Verification logic duplication across execution/tdd modules
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 1. Module Map
|
|
29
|
+
|
|
30
|
+
### Directory Structure
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
src/
|
|
34
|
+
├── acceptance/ [4 files, 739 lines] Acceptance test generation
|
|
35
|
+
├── agents/ [6 files, 1,577 lines] Agent adapter layer
|
|
36
|
+
├── analyze/ [4 files, 547 lines] PRD decomposition
|
|
37
|
+
├── cli/ [10 files, 2,809 lines] Command-line interface
|
|
38
|
+
├── commands/ [5 files, 666 lines] Command utilities
|
|
39
|
+
├── config/ [7 files, 1,333 lines] Configuration system
|
|
40
|
+
├── constitution/ [3 files, 169 lines] Coding standards
|
|
41
|
+
├── context/ [6 files, 1,354 lines] Context building
|
|
42
|
+
├── execution/ [20 files, 6,745 lines] ⚠️ Core orchestration (GOD MODULE)
|
|
43
|
+
├── hooks/ [3 files, 339 lines] Lifecycle hooks
|
|
44
|
+
├── logger/ [4 files, 452 lines] Structured logging
|
|
45
|
+
├── logging/ [3 files, 456 lines] Log formatters
|
|
46
|
+
├── metrics/ [4 files, 513 lines] Metrics tracking
|
|
47
|
+
├── optimizer/ [4 files, 387 lines] Prompt optimization
|
|
48
|
+
├── pipeline/ [16 files, 1,815 lines] ✅ Stage-based execution
|
|
49
|
+
├── plugins/ [5 files, 1,057 lines] ✅ Plugin system
|
|
50
|
+
├── prd/ [2 files, 354 lines] PRD types
|
|
51
|
+
├── precheck/ [3 files, 799 lines] Pre-execution validation
|
|
52
|
+
├── queue/ [3 files, 310 lines] Queue file handling
|
|
53
|
+
├── review/ [3 files, 246 lines] Quality gates
|
|
54
|
+
├── routing/ [11 files, 1,482 lines] Model routing
|
|
55
|
+
├── tdd/ [7 files, 1,614 lines] TDD orchestration
|
|
56
|
+
├── tui/ [5 files, 732 lines] Terminal UI
|
|
57
|
+
├── utils/ [2 files, ~100 lines] Git/queue utilities
|
|
58
|
+
└── worktree/ [5 files, 620 lines] Parallel execution
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Module Responsibility Matrix
|
|
62
|
+
|
|
63
|
+
| Module | Responsibility | Complexity | Quality |
|
|
64
|
+
|--------|---------------|------------|---------|
|
|
65
|
+
| **pipeline/** | Stage-based execution framework | Medium | ✅ Excellent |
|
|
66
|
+
| **execution/** | Core orchestration loop | High | ⚠️ God file |
|
|
67
|
+
| **routing/** | Complexity classification & model selection | Medium | ✅ Good |
|
|
68
|
+
| **agents/** | Agent adapter abstraction | Medium | ✅ Good |
|
|
69
|
+
| **tdd/** | Three-session TDD orchestration | High | ✅ Good |
|
|
70
|
+
| **plugins/** | Plugin system architecture | Medium | ✅ Excellent |
|
|
71
|
+
| **config/** | Configuration loading & validation | Medium | ⚠️ Large schema |
|
|
72
|
+
| **context/** | Story context building | Medium | ✅ Good |
|
|
73
|
+
| **cli/** | Command-line interface | Medium | ✅ Good |
|
|
74
|
+
| **acceptance/** | Acceptance test generation | Low | ✅ Good |
|
|
75
|
+
| **metrics/** | Story metrics tracking | Low | ✅ Good |
|
|
76
|
+
| **worktree/** | Git worktree management | Medium | ✅ Good |
|
|
77
|
+
| **review/** | Quality gate review | Low | ✅ Good |
|
|
78
|
+
| **queue/** | Queue file handling | Low | ✅ Good |
|
|
79
|
+
| **constitution/** | Coding standards loading | Low | ✅ Good |
|
|
80
|
+
| **logger/** | Structured logging | Low | ✅ Good |
|
|
81
|
+
| **optimizer/** | Prompt optimization | Low | ✅ Good |
|
|
82
|
+
| **analyze/** | PRD decomposition | Medium | ✅ Good |
|
|
83
|
+
| **precheck/** | Pre-execution validation | Medium | ✅ Good |
|
|
84
|
+
| **hooks/** | Lifecycle hooks | Low | ✅ Good |
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 2. Data Flow: PRD → Completion
|
|
89
|
+
|
|
90
|
+
### High-Level Flow
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
1. CLI Entry (bin/nax.ts)
|
|
94
|
+
↓
|
|
95
|
+
2. CLI Command (cli/index.ts)
|
|
96
|
+
↓
|
|
97
|
+
3. Runner Setup (execution/runner.ts)
|
|
98
|
+
↓
|
|
99
|
+
4. Load Plugins (plugins/loader.ts)
|
|
100
|
+
↓
|
|
101
|
+
5. For Each Story:
|
|
102
|
+
↓
|
|
103
|
+
Pipeline.execute() [pipeline/runner.ts]
|
|
104
|
+
├─ queue-check Check for PAUSE/ABORT/SKIP
|
|
105
|
+
├─ routing Classify complexity, select model
|
|
106
|
+
├─ constitution Load coding standards
|
|
107
|
+
├─ context Build story context (plugin providers)
|
|
108
|
+
├─ prompt Assemble final prompt
|
|
109
|
+
├─ optimizer Optimize prompt for tokens
|
|
110
|
+
├─ execution Spawn agent session (TDD or test-after)
|
|
111
|
+
├─ verify Run tests & quality checks
|
|
112
|
+
├─ review Run plugin reviewers
|
|
113
|
+
├─ acceptance Run acceptance tests
|
|
114
|
+
└─ completion Mark complete, fire hooks
|
|
115
|
+
↓
|
|
116
|
+
6. Reporter Events (plugins/registry.ts)
|
|
117
|
+
↓
|
|
118
|
+
7. Teardown (registry.teardownAll())
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Detailed Execution Flow
|
|
122
|
+
|
|
123
|
+
**Path 1: Test-After Strategy**
|
|
124
|
+
```
|
|
125
|
+
execution/runner.ts::run()
|
|
126
|
+
→ pipeline/runner.ts::execute()
|
|
127
|
+
→ stages/execution.ts
|
|
128
|
+
→ agents/claude.ts::run()
|
|
129
|
+
→ Spawn Claude Code process
|
|
130
|
+
→ Wait for completion
|
|
131
|
+
→ stages/verify.ts
|
|
132
|
+
→ execution/verification.ts::verify()
|
|
133
|
+
→ Run test commands
|
|
134
|
+
→ Parse results
|
|
135
|
+
→ Reporter.emit('storyComplete')
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Path 2: Three-Session TDD Strategy**
|
|
139
|
+
```
|
|
140
|
+
execution/runner.ts::run()
|
|
141
|
+
→ pipeline/runner.ts::execute()
|
|
142
|
+
→ stages/execution.ts
|
|
143
|
+
→ tdd/orchestrator.ts::orchestrate()
|
|
144
|
+
├─ Session 1: Scaffold (sonnet)
|
|
145
|
+
│ → agents/claude.ts::scaffold()
|
|
146
|
+
│ → tdd/isolation.ts::verify()
|
|
147
|
+
├─ Session 2: Implement (opus)
|
|
148
|
+
│ → agents/claude.ts::run()
|
|
149
|
+
│ → tdd/isolation.ts::verify()
|
|
150
|
+
└─ Session 3: Verify (haiku)
|
|
151
|
+
→ agents/claude.ts::run()
|
|
152
|
+
→ tdd/verdict.ts::parseVerdict()
|
|
153
|
+
→ execution/verification.ts::verify()
|
|
154
|
+
→ [IF FAIL] tdd/rectification.ts::retry()
|
|
155
|
+
→ stages/verify.ts
|
|
156
|
+
→ Reporter.emit('storyComplete')
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Path 3: Parallel Execution**
|
|
160
|
+
```
|
|
161
|
+
execution/runner.ts::run()
|
|
162
|
+
→ execution/batching.ts::shouldBatch()
|
|
163
|
+
→ execution/parallel.ts::executeParallel()
|
|
164
|
+
→ worktree/dispatcher.ts::dispatch()
|
|
165
|
+
├─ Story 1 → Worktree A → Pipeline.execute()
|
|
166
|
+
├─ Story 2 → Worktree B → Pipeline.execute()
|
|
167
|
+
└─ Story 3 → Worktree C → Pipeline.execute()
|
|
168
|
+
→ worktree/merge.ts::mergeAll()
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## 3. Dependency Graph
|
|
174
|
+
|
|
175
|
+
### Tier Architecture
|
|
176
|
+
|
|
177
|
+
**Tier 1 (Foundation):**
|
|
178
|
+
- `errors.ts` - Error types
|
|
179
|
+
- `logger/` - Logging
|
|
180
|
+
- `config/` - Configuration
|
|
181
|
+
- `prd/types.ts` - PRD data structures
|
|
182
|
+
|
|
183
|
+
**Tier 2 (Core Domain):**
|
|
184
|
+
- `agents/` - Agent adapters (imports: config)
|
|
185
|
+
- `routing/` - Routing strategies (imports: config, prd, plugins)
|
|
186
|
+
- `context/` - Context building (imports: config, prd, logger)
|
|
187
|
+
- `tdd/` - TDD orchestration (imports: agents, config, logger, prd)
|
|
188
|
+
|
|
189
|
+
**Tier 3 (Infrastructure):**
|
|
190
|
+
- `plugins/` - Plugin system (imports: agents, routing, optimizer, prd)
|
|
191
|
+
- `metrics/` - Metrics tracking (imports: prd)
|
|
192
|
+
- `hooks/` - Lifecycle hooks (imports: config)
|
|
193
|
+
- `worktree/` - Parallel execution (imports: config, logger)
|
|
194
|
+
|
|
195
|
+
**Tier 4 (Orchestration):**
|
|
196
|
+
- `pipeline/` - Stage-based execution (imports: tier 1-3 modules)
|
|
197
|
+
- `execution/` - Core runner (imports: tier 1-4 modules) ⚠️
|
|
198
|
+
|
|
199
|
+
**Tier 5 (Interface):**
|
|
200
|
+
- `cli/` - Command-line (imports: all tiers)
|
|
201
|
+
- `tui/` - Terminal UI (imports: pipeline events)
|
|
202
|
+
|
|
203
|
+
### Module Import Analysis
|
|
204
|
+
|
|
205
|
+
**Most Imported Modules (Used By):**
|
|
206
|
+
1. `config/` - Used by 90% of modules
|
|
207
|
+
2. `logger/` - Used by 80% of modules
|
|
208
|
+
3. `prd/types.ts` - Used by 70% of modules
|
|
209
|
+
4. `agents/` - Used by execution, pipeline, tdd, cli
|
|
210
|
+
|
|
211
|
+
**Highest Import Count (Imports From):**
|
|
212
|
+
1. `execution/runner.ts` - Imports from 15+ modules ⚠️
|
|
213
|
+
2. `pipeline/stages/` - Imports from 8-10 modules each
|
|
214
|
+
3. `cli/` commands - Imports from 6-8 modules each
|
|
215
|
+
|
|
216
|
+
**Well-Isolated Modules:**
|
|
217
|
+
- `agents/` - Only imports config
|
|
218
|
+
- `logger/` - No domain dependencies
|
|
219
|
+
- `metrics/` - Only imports prd types
|
|
220
|
+
- `routing/` - Only imports config, prd, plugins
|
|
221
|
+
|
|
222
|
+
### Coupling Matrix
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
agents config context exec pipeline plugins routing tdd
|
|
226
|
+
agents - ✓ ✗ ✗ ✗ ✗ ✗ ✗
|
|
227
|
+
config ✗ - ✗ ✗ ✗ ✗ ✗ ✗
|
|
228
|
+
context ✗ ✓ - ✗ ✗ ✗ ✗ ✗
|
|
229
|
+
execution ✓ ✓ ✓ - ✓ ✓ ✓ ✓ ⚠️
|
|
230
|
+
pipeline ✓ ✓ ✓ ✗ - ✓ ✓ ✓
|
|
231
|
+
plugins ✓ ✗ ✗ ✗ ✗ - ✓ ✗
|
|
232
|
+
routing ✗ ✓ ✗ ✗ ✗ ✓ - ✗
|
|
233
|
+
tdd ✓ ✓ ✗ ✓ ✗ ✗ ✗ -
|
|
234
|
+
|
|
235
|
+
Legend: ✓ = imports, ✗ = does not import, ⚠️ = excessive coupling
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Observation:** `execution/` module has the highest coupling (imports from 8/8 other modules).
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## 4. Code Smells & Technical Debt
|
|
243
|
+
|
|
244
|
+
### Critical Issues
|
|
245
|
+
|
|
246
|
+
#### 🔴 God File: `execution/runner.ts` (1,685 lines)
|
|
247
|
+
|
|
248
|
+
**Problem:** Violates 400-line guideline by **4.2x**
|
|
249
|
+
|
|
250
|
+
**Concerns Handled:**
|
|
251
|
+
1. Run lifecycle (start/end hooks)
|
|
252
|
+
2. Story dispatching
|
|
253
|
+
3. Sequential execution loop
|
|
254
|
+
4. Parallel execution coordination
|
|
255
|
+
5. Escalation logic (tier bumping)
|
|
256
|
+
6. Acceptance test retry loop
|
|
257
|
+
7. Crash recovery
|
|
258
|
+
8. Heartbeat monitoring
|
|
259
|
+
9. Status file writing
|
|
260
|
+
10. Reporter event emission
|
|
261
|
+
|
|
262
|
+
**Impact:**
|
|
263
|
+
- Difficult to test (requires mocking 15+ modules)
|
|
264
|
+
- High risk of merge conflicts
|
|
265
|
+
- Hard to onboard new contributors
|
|
266
|
+
- Violates single-responsibility principle
|
|
267
|
+
|
|
268
|
+
**Effort to Fix:** Large (L) - 2-3 days
|
|
269
|
+
|
|
270
|
+
**Recommendation:**
|
|
271
|
+
```
|
|
272
|
+
execution/
|
|
273
|
+
runner.ts (300 lines) Core sequential loop
|
|
274
|
+
parallel-runner.ts (300 lines) Parallel execution
|
|
275
|
+
lifecycle/
|
|
276
|
+
run-start.ts (100 lines) Run start hooks
|
|
277
|
+
run-end.ts (100 lines) Run end hooks
|
|
278
|
+
story-hooks.ts (100 lines) Story lifecycle
|
|
279
|
+
escalation/
|
|
280
|
+
tier-escalation.ts (200 lines) Tier bumping logic
|
|
281
|
+
attempt-tracking.ts (100 lines) Attempt counters
|
|
282
|
+
acceptance/
|
|
283
|
+
acceptance-loop.ts (400 lines) Acceptance retry
|
|
284
|
+
fix-generator.ts (200 lines) Fix story generation
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
### Major Issues
|
|
290
|
+
|
|
291
|
+
#### 🟠 Large Files Approaching Threshold
|
|
292
|
+
|
|
293
|
+
| File | Lines | Threshold | Over By |
|
|
294
|
+
|------|-------|-----------|---------|
|
|
295
|
+
| `config/schema.ts` | 792 | 800 | -8 (close) |
|
|
296
|
+
| `execution/story-dispatcher.ts` | 765 | 800 | -35 |
|
|
297
|
+
| `agents/claude.ts` | 751 | 800 | -49 |
|
|
298
|
+
| `tdd/orchestrator.ts` | 730 | 800 | -70 |
|
|
299
|
+
| `cli/diagnose.ts` | 658 | 800 | -142 |
|
|
300
|
+
|
|
301
|
+
**Analysis:**
|
|
302
|
+
- `config/schema.ts` should be split into domain-specific schemas
|
|
303
|
+
- `story-dispatcher.ts` is complex but focused (acceptable for now)
|
|
304
|
+
- `claude.ts` is an adapter - complexity is justified
|
|
305
|
+
- `tdd/orchestrator.ts` is complex but well-structured
|
|
306
|
+
- `diagnose.ts` could be split into check categories
|
|
307
|
+
|
|
308
|
+
**Effort to Fix:** Medium (M) - 1 day each
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
#### 🟠 High Coupling in Execution Module
|
|
313
|
+
|
|
314
|
+
**Problem:** `execution/runner.ts` imports from 15+ modules
|
|
315
|
+
|
|
316
|
+
**Dependencies:**
|
|
317
|
+
```typescript
|
|
318
|
+
// execution/runner.ts imports:
|
|
319
|
+
import { agents } from '../agents'
|
|
320
|
+
import { config } from '../config'
|
|
321
|
+
import { pipeline } from '../pipeline'
|
|
322
|
+
import { prd } from '../prd'
|
|
323
|
+
import { tdd } from '../tdd'
|
|
324
|
+
import { routing } from '../routing'
|
|
325
|
+
import { plugins } from '../plugins'
|
|
326
|
+
import { hooks } from '../hooks'
|
|
327
|
+
import { metrics } from '../metrics'
|
|
328
|
+
import { context } from '../context'
|
|
329
|
+
import { acceptance } from '../acceptance'
|
|
330
|
+
import { worktree } from '../worktree'
|
|
331
|
+
import { logger } from '../logger'
|
|
332
|
+
import { review } from '../review'
|
|
333
|
+
import { queue } from '../queue'
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**Impact:**
|
|
337
|
+
- Difficult to unit test (requires extensive mocking)
|
|
338
|
+
- High risk of circular dependencies
|
|
339
|
+
- Changes to any module ripple through execution
|
|
340
|
+
|
|
341
|
+
**Effort to Fix:** Large (L) - Requires god file refactoring
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
#### 🟠 Verification Logic Duplication
|
|
346
|
+
|
|
347
|
+
**Problem:** Test execution logic appears in 3 places:
|
|
348
|
+
|
|
349
|
+
1. `execution/verification.ts` (552 lines) - Full test suite verification
|
|
350
|
+
2. `tdd/orchestrator.ts` (lines 400-500) - Post-session verification
|
|
351
|
+
3. `pipeline/stages/verify.ts` (80 lines) - Pipeline verification stage
|
|
352
|
+
|
|
353
|
+
**Duplication:**
|
|
354
|
+
- Test command execution
|
|
355
|
+
- Test output parsing
|
|
356
|
+
- Rectification retry logic
|
|
357
|
+
- Scoped vs full-suite logic
|
|
358
|
+
|
|
359
|
+
**Impact:**
|
|
360
|
+
- Code maintenance burden
|
|
361
|
+
- Inconsistent behavior across paths
|
|
362
|
+
- Bugs fixed in one place but not others
|
|
363
|
+
|
|
364
|
+
**Effort to Fix:** Medium (M) - 1 day
|
|
365
|
+
|
|
366
|
+
**Recommendation:**
|
|
367
|
+
```
|
|
368
|
+
verification/
|
|
369
|
+
executor.ts Run test commands (Bun.spawn wrapper)
|
|
370
|
+
parser.ts Parse test output (shared parser)
|
|
371
|
+
gate.ts Verification gates (scoped/full/regression)
|
|
372
|
+
rectification.ts Retry logic with exponential backoff
|
|
373
|
+
types.ts Verification result types
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Used by:
|
|
377
|
+
- `execution/verification.ts` → `verification/gate.ts::fullSuite()`
|
|
378
|
+
- `tdd/orchestrator.ts` → `verification/gate.ts::scoped()`
|
|
379
|
+
- `pipeline/verify.ts` → `verification/gate.ts::regression()`
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
### Minor Issues
|
|
384
|
+
|
|
385
|
+
#### 🟡 Mixed Abstractions in `execution/helpers.ts` (435 lines)
|
|
386
|
+
|
|
387
|
+
**Problem:** Contains both high-level orchestration and low-level git utils
|
|
388
|
+
|
|
389
|
+
**Contents:**
|
|
390
|
+
- High-level: Story filtering, dependency resolution
|
|
391
|
+
- Low-level: Git branch operations, file writing
|
|
392
|
+
|
|
393
|
+
**Effort to Fix:** Small (S) - 2 hours
|
|
394
|
+
|
|
395
|
+
**Recommendation:**
|
|
396
|
+
```
|
|
397
|
+
execution/
|
|
398
|
+
helpers/
|
|
399
|
+
story-filtering.ts Story selection logic
|
|
400
|
+
dependency.ts Dependency resolution
|
|
401
|
+
utils/ (move to root)
|
|
402
|
+
git.ts Git operations
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
#### 🟡 Routing Duplication: `routeTask()` vs `routeStory()`
|
|
408
|
+
|
|
409
|
+
**Problem:** Two similar functions in `routing/router.ts`
|
|
410
|
+
|
|
411
|
+
```typescript
|
|
412
|
+
// Legacy API
|
|
413
|
+
export function routeTask(task: Task): RoutingResult
|
|
414
|
+
|
|
415
|
+
// New API
|
|
416
|
+
export function routeStory(story: Story): RoutingResult
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
**Impact:** Minor - both are maintained
|
|
420
|
+
|
|
421
|
+
**Effort to Fix:** Small (S) - 1 hour
|
|
422
|
+
|
|
423
|
+
**Recommendation:** Deprecate `routeTask()` and migrate all callers to `routeStory()`
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
#### 🟡 Large Config Schema (792 lines)
|
|
428
|
+
|
|
429
|
+
**Problem:** `config/schema.ts` contains all Zod schemas in one file
|
|
430
|
+
|
|
431
|
+
**Effort to Fix:** Small (S) - 3 hours
|
|
432
|
+
|
|
433
|
+
**Recommendation:**
|
|
434
|
+
```
|
|
435
|
+
config/
|
|
436
|
+
schema/
|
|
437
|
+
models.ts Model tier definitions
|
|
438
|
+
execution.ts Execution config
|
|
439
|
+
quality.ts Quality gate config
|
|
440
|
+
tdd.ts TDD config
|
|
441
|
+
routing.ts Routing config
|
|
442
|
+
plugins.ts Plugin config
|
|
443
|
+
precheck.ts Precheck config
|
|
444
|
+
schema.ts (200 lines) Main schema assembly
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
---
|
|
448
|
+
|
|
449
|
+
## 5. Extension Points
|
|
450
|
+
|
|
451
|
+
### Designed Extension Points ✅
|
|
452
|
+
|
|
453
|
+
The codebase has **6 well-designed extension points** via the plugin system:
|
|
454
|
+
|
|
455
|
+
| Extension Point | Interface | Integration | Quality |
|
|
456
|
+
|----------------|-----------|-------------|---------|
|
|
457
|
+
| **Context Provider** | `IContextProvider` | `pipeline/stages/context.ts` | ✅ Excellent |
|
|
458
|
+
| **Router** | `IRoutingStrategy` | `routing/chain.ts` | ✅ Excellent |
|
|
459
|
+
| **Optimizer** | `IOptimizer` | `pipeline/stages/optimizer.ts` | ✅ Excellent |
|
|
460
|
+
| **Reviewer** | `IReviewer` | `pipeline/stages/review.ts` | ✅ Excellent |
|
|
461
|
+
| **Reporter** | `IReporter` | `execution/runner.ts` | ✅ Excellent |
|
|
462
|
+
| **Hooks** | `IHook` | `execution/run-lifecycle.ts` | ✅ Excellent |
|
|
463
|
+
|
|
464
|
+
**Example Plugin Structure:**
|
|
465
|
+
```typescript
|
|
466
|
+
// plugins/types.ts
|
|
467
|
+
export interface IContextProvider {
|
|
468
|
+
name: string
|
|
469
|
+
shouldProvide(story: Story): boolean
|
|
470
|
+
provideContext(story: Story): Promise<string>
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// Integration in pipeline/stages/context.ts
|
|
474
|
+
for (const provider of registry.contextProviders) {
|
|
475
|
+
if (provider.shouldProvide(story)) {
|
|
476
|
+
const ctx = await provider.provideContext(story)
|
|
477
|
+
context.pluginContext.push(ctx)
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
**Strengths:**
|
|
483
|
+
- Clean interface-based design
|
|
484
|
+
- Dependency injection via registry
|
|
485
|
+
- Teardown lifecycle support
|
|
486
|
+
- Strong validation via `plugins/validator.ts`
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
### Missing Extension Points ⚠️
|
|
491
|
+
|
|
492
|
+
| Extension | Current State | Should Be Pluggable? |
|
|
493
|
+
|-----------|---------------|---------------------|
|
|
494
|
+
| **Agent Adapters** | Hardcoded Claude only | ✅ Yes - for Codex, Aider, Gemini |
|
|
495
|
+
| **Verification Strategies** | Hardcoded Bun test | ✅ Yes - for pytest, jest, cargo test |
|
|
496
|
+
| **PRD Parsers** | Hardcoded JSON | ⚠️ Maybe - for YAML, TOML |
|
|
497
|
+
| **Merge Strategies** | Hardcoded git merge | ⚠️ Maybe - for custom resolvers |
|
|
498
|
+
|
|
499
|
+
**Recommendation:**
|
|
500
|
+
|
|
501
|
+
1. **Agent Adapter Plugin (Priority: High)**
|
|
502
|
+
```typescript
|
|
503
|
+
export interface IAgentAdapter {
|
|
504
|
+
name: string
|
|
505
|
+
scaffold(prompt: string): Promise<AgentResult>
|
|
506
|
+
run(prompt: string): Promise<AgentResult>
|
|
507
|
+
decompose(prd: string): Promise<Story[]>
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
2. **Verification Plugin (Priority: Medium)**
|
|
512
|
+
```typescript
|
|
513
|
+
export interface IVerifier {
|
|
514
|
+
name: string
|
|
515
|
+
supports(project: ProjectInfo): boolean
|
|
516
|
+
verify(scope: VerificationScope): Promise<VerificationResult>
|
|
517
|
+
}
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
## 6. Test Coverage Map
|
|
523
|
+
|
|
524
|
+
### Test Organization
|
|
525
|
+
|
|
526
|
+
```
|
|
527
|
+
test/
|
|
528
|
+
├── unit/ [37 tests] Pure logic, no I/O
|
|
529
|
+
├── integration/ [64 tests] Cross-module integration
|
|
530
|
+
├── routing/ [8 tests] Routing strategies
|
|
531
|
+
├── execution/ [6 tests] Execution flows
|
|
532
|
+
└── ui/ [4 tests] TUI components
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
### Coverage by Module
|
|
536
|
+
|
|
537
|
+
| Module | Unit Tests | Integration Tests | Coverage Quality |
|
|
538
|
+
|--------|-----------|-------------------|------------------|
|
|
539
|
+
| **routing/** | ✅ Yes | ✅ Yes | ✅ Excellent |
|
|
540
|
+
| **context/** | ✅ Yes | ✅ Yes | ✅ Excellent |
|
|
541
|
+
| **plugins/** | ✅ Yes | ✅ Yes | ✅ Excellent |
|
|
542
|
+
| **config/** | ✅ Yes | ✅ Yes | ✅ Excellent |
|
|
543
|
+
| **metrics/** | ✅ Yes | ✅ Yes | ✅ Good |
|
|
544
|
+
| **worktree/** | ✅ Yes | ✅ Yes | ✅ Good |
|
|
545
|
+
| **acceptance/** | ✅ Yes | ✅ Yes | ✅ Good |
|
|
546
|
+
| **review/** | ✅ Yes | ✅ Yes | ✅ Good |
|
|
547
|
+
| **queue/** | ✅ Yes | ⚠️ Limited | ✅ Good |
|
|
548
|
+
| **analyze/** | ✅ Yes | ✅ Yes | ✅ Good |
|
|
549
|
+
| **precheck/** | ✅ Yes | ✅ Yes | ✅ Good |
|
|
550
|
+
| **constitution/** | ✅ Yes | ⚠️ Limited | ✅ Good |
|
|
551
|
+
| **logger/** | ✅ Yes | ✅ Yes | ✅ Good |
|
|
552
|
+
| **optimizer/** | ✅ Yes | ⚠️ Limited | ✅ Good |
|
|
553
|
+
| **agents/** | ⚠️ Limited | ✅ Yes | ⚠️ Needs improvement |
|
|
554
|
+
| **tdd/** | ⚠️ Limited | ⚠️ Limited | 🔴 **Gap** |
|
|
555
|
+
| **execution/** | ⚠️ Limited | ✅ Yes | 🔴 **Gap** |
|
|
556
|
+
| **pipeline/** | ⚠️ Limited | ✅ Yes | ⚠️ Needs improvement |
|
|
557
|
+
| **cli/** | ✅ Yes | ✅ Yes | ✅ Good |
|
|
558
|
+
| **tui/** | ✅ Yes | ✗ No | ⚠️ Acceptable |
|
|
559
|
+
|
|
560
|
+
### Critical Coverage Gaps
|
|
561
|
+
|
|
562
|
+
#### 🔴 TDD Orchestrator (730 lines, minimal tests)
|
|
563
|
+
|
|
564
|
+
**Missing Tests:**
|
|
565
|
+
- Three-session flow (scaffold → implement → verify)
|
|
566
|
+
- Isolation verification between sessions
|
|
567
|
+
- Rectification retry logic
|
|
568
|
+
- Greenfield vs existing project flows
|
|
569
|
+
- Verdict parsing edge cases
|
|
570
|
+
|
|
571
|
+
**Recommendation:** Add `test/integration/tdd-orchestrator.test.ts`
|
|
572
|
+
|
|
573
|
+
---
|
|
574
|
+
|
|
575
|
+
#### 🔴 Execution Runner (1,685 lines, minimal direct tests)
|
|
576
|
+
|
|
577
|
+
**Missing Tests:**
|
|
578
|
+
- Escalation logic (tier bumping)
|
|
579
|
+
- Acceptance retry loop
|
|
580
|
+
- Parallel execution coordination
|
|
581
|
+
- Crash recovery
|
|
582
|
+
- Heartbeat monitoring
|
|
583
|
+
|
|
584
|
+
**Recommendation:** Split god file first, then add focused unit tests
|
|
585
|
+
|
|
586
|
+
---
|
|
587
|
+
|
|
588
|
+
#### ⚠️ Agent Adapters (751 lines, limited tests)
|
|
589
|
+
|
|
590
|
+
**Missing Tests:**
|
|
591
|
+
- Claude Code adapter edge cases
|
|
592
|
+
- Timeout handling
|
|
593
|
+
- Process cleanup on error
|
|
594
|
+
- Plan/decompose/scaffold methods
|
|
595
|
+
|
|
596
|
+
**Recommendation:** Add `test/unit/agents/claude.test.ts`
|
|
597
|
+
|
|
598
|
+
---
|
|
599
|
+
|
|
600
|
+
### Test Quality Assessment
|
|
601
|
+
|
|
602
|
+
**Strengths:**
|
|
603
|
+
- Good unit test coverage for routing, context, plugins
|
|
604
|
+
- Integration tests for cross-module flows
|
|
605
|
+
- UI tests for TUI components
|
|
606
|
+
|
|
607
|
+
**Weaknesses:**
|
|
608
|
+
- Orchestration code (execution, tdd) has minimal coverage
|
|
609
|
+
- Missing tests for complex flows (escalation, rectification)
|
|
610
|
+
- Some tests skip prechecks, reducing realism
|
|
611
|
+
|
|
612
|
+
**Overall Test Quality:** B (would be A with orchestration coverage)
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
## 7. Re-architecture Recommendations
|
|
617
|
+
|
|
618
|
+
### Priority 1: Split `execution/runner.ts` (Effort: L, Impact: High)
|
|
619
|
+
|
|
620
|
+
**Current State:** 1,685-line god file handling 8+ concerns
|
|
621
|
+
|
|
622
|
+
**Target State:**
|
|
623
|
+
```
|
|
624
|
+
execution/
|
|
625
|
+
runner.ts (300 lines)
|
|
626
|
+
- Core sequential loop
|
|
627
|
+
- Story iteration
|
|
628
|
+
- Pipeline invocation
|
|
629
|
+
|
|
630
|
+
parallel-runner.ts (300 lines)
|
|
631
|
+
- Parallel execution via worktrees
|
|
632
|
+
- Batch coordination
|
|
633
|
+
- Merge orchestration
|
|
634
|
+
|
|
635
|
+
lifecycle/
|
|
636
|
+
run-start.ts (100 lines)
|
|
637
|
+
- Load plugins
|
|
638
|
+
- Initialize reporters
|
|
639
|
+
- Fire onRunStart hooks
|
|
640
|
+
run-end.ts (100 lines)
|
|
641
|
+
- Teardown plugins
|
|
642
|
+
- Fire onRunEnd hooks
|
|
643
|
+
- Write final metrics
|
|
644
|
+
story-hooks.ts (100 lines)
|
|
645
|
+
- Fire onStoryStart/Complete
|
|
646
|
+
- Emit reporter events
|
|
647
|
+
|
|
648
|
+
escalation/
|
|
649
|
+
tier-escalation.ts (200 lines)
|
|
650
|
+
- Tier bumping logic
|
|
651
|
+
- Attempt tracking
|
|
652
|
+
- Escalation strategy
|
|
653
|
+
attempt-tracking.ts (100 lines)
|
|
654
|
+
- Attempt counters
|
|
655
|
+
- Max attempt limits
|
|
656
|
+
|
|
657
|
+
acceptance/
|
|
658
|
+
acceptance-loop.ts (400 lines)
|
|
659
|
+
- Acceptance test retry
|
|
660
|
+
- Fix story generation
|
|
661
|
+
- Acceptance timeout
|
|
662
|
+
fix-generator.ts (200 lines)
|
|
663
|
+
- Generate fix stories
|
|
664
|
+
- Link to parent story
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
**Migration Plan:**
|
|
668
|
+
1. Extract lifecycle functions (low risk)
|
|
669
|
+
2. Extract escalation logic (medium risk)
|
|
670
|
+
3. Extract acceptance loop (high risk - complex)
|
|
671
|
+
4. Extract parallel execution (high risk - complex)
|
|
672
|
+
5. Add comprehensive tests for each module
|
|
673
|
+
6. Deprecate old runner.ts
|
|
674
|
+
|
|
675
|
+
**Benefits:**
|
|
676
|
+
- Each file < 400 lines
|
|
677
|
+
- Single-responsibility modules
|
|
678
|
+
- Easier to test
|
|
679
|
+
- Reduced coupling
|
|
680
|
+
- Easier to onboard contributors
|
|
681
|
+
|
|
682
|
+
---
|
|
683
|
+
|
|
684
|
+
### Priority 2: Create Unified Verification Layer (Effort: M, Impact: Medium)
|
|
685
|
+
|
|
686
|
+
**Current State:** Test execution logic duplicated across 3 modules
|
|
687
|
+
|
|
688
|
+
**Target State:**
|
|
689
|
+
```
|
|
690
|
+
verification/
|
|
691
|
+
executor.ts (150 lines)
|
|
692
|
+
- Run test commands via Bun.spawn
|
|
693
|
+
- Capture stdout/stderr
|
|
694
|
+
- Handle timeouts
|
|
695
|
+
|
|
696
|
+
parser.ts (200 lines)
|
|
697
|
+
- Parse Bun test output
|
|
698
|
+
- Extract pass/fail counts
|
|
699
|
+
- Parse error messages
|
|
700
|
+
|
|
701
|
+
gate.ts (250 lines)
|
|
702
|
+
- scoped() Run tests for modified files
|
|
703
|
+
- fullSuite() Run entire test suite
|
|
704
|
+
- regression() Run subset for sanity check
|
|
705
|
+
|
|
706
|
+
rectification.ts (200 lines)
|
|
707
|
+
- Retry logic with exponential backoff
|
|
708
|
+
- Max attempt tracking
|
|
709
|
+
- Failure categorization
|
|
710
|
+
|
|
711
|
+
types.ts (100 lines)
|
|
712
|
+
- VerificationResult
|
|
713
|
+
- VerificationScope
|
|
714
|
+
- VerificationStrategy
|
|
715
|
+
|
|
716
|
+
index.ts
|
|
717
|
+
- Barrel exports
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
**Migration:**
|
|
721
|
+
1. Extract common test execution logic
|
|
722
|
+
2. Create unified parser
|
|
723
|
+
3. Implement verification gates
|
|
724
|
+
4. Migrate `execution/verification.ts` to use new layer
|
|
725
|
+
5. Migrate `tdd/orchestrator.ts` to use new layer
|
|
726
|
+
6. Migrate `pipeline/verify.ts` to use new layer
|
|
727
|
+
|
|
728
|
+
**Benefits:**
|
|
729
|
+
- DRY - single test execution implementation
|
|
730
|
+
- Consistent behavior across paths
|
|
731
|
+
- Easier to add new test frameworks (jest, pytest)
|
|
732
|
+
- Better error handling
|
|
733
|
+
|
|
734
|
+
---
|
|
735
|
+
|
|
736
|
+
### Priority 3: Split Config Schema (Effort: S, Impact: Low)
|
|
737
|
+
|
|
738
|
+
**Current State:** `config/schema.ts` is 792 lines
|
|
739
|
+
|
|
740
|
+
**Target State:**
|
|
741
|
+
```
|
|
742
|
+
config/
|
|
743
|
+
schema/
|
|
744
|
+
models.ts (100 lines)
|
|
745
|
+
- ModelTier enum
|
|
746
|
+
- Model definitions
|
|
747
|
+
|
|
748
|
+
execution.ts (150 lines)
|
|
749
|
+
- Execution config
|
|
750
|
+
- Parallel execution
|
|
751
|
+
- Crash recovery
|
|
752
|
+
|
|
753
|
+
quality.ts (100 lines)
|
|
754
|
+
- Quality gate config
|
|
755
|
+
- Verification thresholds
|
|
756
|
+
|
|
757
|
+
tdd.ts (100 lines)
|
|
758
|
+
- TDD config
|
|
759
|
+
- Session prompts
|
|
760
|
+
- Isolation rules
|
|
761
|
+
|
|
762
|
+
routing.ts (100 lines)
|
|
763
|
+
- Routing config
|
|
764
|
+
- Complexity thresholds
|
|
765
|
+
- Strategy selection
|
|
766
|
+
|
|
767
|
+
plugins.ts (150 lines)
|
|
768
|
+
- Plugin config
|
|
769
|
+
- Plugin paths
|
|
770
|
+
- Plugin options
|
|
771
|
+
|
|
772
|
+
precheck.ts (50 lines)
|
|
773
|
+
- Precheck config
|
|
774
|
+
|
|
775
|
+
schema.ts (200 lines)
|
|
776
|
+
- Assemble all schemas
|
|
777
|
+
- Main Config type
|
|
778
|
+
- Default values
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
**Benefits:**
|
|
782
|
+
- Easier to navigate
|
|
783
|
+
- Domain-specific organization
|
|
784
|
+
- Faster IDE performance
|
|
785
|
+
|
|
786
|
+
---
|
|
787
|
+
|
|
788
|
+
### Priority 4: Add Agent Adapter Plugin System (Effort: M, Impact: Medium)
|
|
789
|
+
|
|
790
|
+
**Current State:** Only Claude Code is supported (hardcoded)
|
|
791
|
+
|
|
792
|
+
**Target State:**
|
|
793
|
+
```
|
|
794
|
+
agents/
|
|
795
|
+
types.ts
|
|
796
|
+
- IAgentAdapter interface
|
|
797
|
+
- AgentRegistry
|
|
798
|
+
|
|
799
|
+
registry.ts
|
|
800
|
+
- Register adapters
|
|
801
|
+
- Select adapter by name
|
|
802
|
+
|
|
803
|
+
adapters/
|
|
804
|
+
claude.ts (current implementation)
|
|
805
|
+
codex.ts (new)
|
|
806
|
+
aider.ts (new)
|
|
807
|
+
gemini.ts (new)
|
|
808
|
+
|
|
809
|
+
plugins/types.ts
|
|
810
|
+
- Add IAgentAdapterPlugin
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
**Migration:**
|
|
814
|
+
1. Define `IAgentAdapter` interface
|
|
815
|
+
2. Refactor `claude.ts` to implement interface
|
|
816
|
+
3. Add agent registry
|
|
817
|
+
4. Update config to support `agent: "claude" | "codex" | "aider"`
|
|
818
|
+
5. Add plugin extension point for custom agents
|
|
819
|
+
|
|
820
|
+
**Benefits:**
|
|
821
|
+
- Support multiple agents (Codex, Aider, Gemini)
|
|
822
|
+
- Users can choose agent per story
|
|
823
|
+
- Plugin authors can add custom agents
|
|
824
|
+
|
|
825
|
+
---
|
|
826
|
+
|
|
827
|
+
### Priority 5: Extract Business Logic from Orchestration (Effort: L, Impact: High)
|
|
828
|
+
|
|
829
|
+
**Current State:** Business rules embedded in runner/orchestrator
|
|
830
|
+
|
|
831
|
+
**Target State:**
|
|
832
|
+
```
|
|
833
|
+
domain/
|
|
834
|
+
escalation/
|
|
835
|
+
rules.ts
|
|
836
|
+
- When to escalate tier
|
|
837
|
+
- Max attempts per tier
|
|
838
|
+
- Escalation strategy
|
|
839
|
+
|
|
840
|
+
verification/
|
|
841
|
+
rules.ts
|
|
842
|
+
- When to run scoped vs full tests
|
|
843
|
+
- Verification thresholds
|
|
844
|
+
- Quality gates
|
|
845
|
+
|
|
846
|
+
acceptance/
|
|
847
|
+
rules.ts
|
|
848
|
+
- When to generate fix stories
|
|
849
|
+
- Max acceptance retries
|
|
850
|
+
- Acceptance timeout
|
|
851
|
+
|
|
852
|
+
routing/
|
|
853
|
+
rules.ts
|
|
854
|
+
- Complexity classification rules
|
|
855
|
+
- Model selection rules
|
|
856
|
+
- Strategy selection
|
|
857
|
+
|
|
858
|
+
execution/runner.ts
|
|
859
|
+
- Use domain/escalation/rules
|
|
860
|
+
- Use domain/verification/rules
|
|
861
|
+
- Pure orchestration, no business logic
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
**Benefits:**
|
|
865
|
+
- Testable business rules
|
|
866
|
+
- Centralized decision logic
|
|
867
|
+
- Easier to understand and modify
|
|
868
|
+
- Domain-driven design
|
|
869
|
+
|
|
870
|
+
---
|
|
871
|
+
|
|
872
|
+
## 8. Effort Estimates
|
|
873
|
+
|
|
874
|
+
| Recommendation | Priority | Effort | Impact | Risk |
|
|
875
|
+
|----------------|----------|--------|--------|------|
|
|
876
|
+
| Split `execution/runner.ts` | P1 | Large (2-3 days) | High | Medium |
|
|
877
|
+
| Unified verification layer | P2 | Medium (1 day) | Medium | Low |
|
|
878
|
+
| Split config schema | P3 | Small (3 hours) | Low | Low |
|
|
879
|
+
| Agent adapter plugins | P4 | Medium (1 day) | Medium | Medium |
|
|
880
|
+
| Extract business logic | P5 | Large (3-4 days) | High | High |
|
|
881
|
+
| Add TDD orchestrator tests | P2 | Medium (1 day) | High | Low |
|
|
882
|
+
| Add execution runner tests | P1 | Large (2 days) | High | Low |
|
|
883
|
+
| Split `tdd/orchestrator.ts` | P3 | Medium (1 day) | Low | Medium |
|
|
884
|
+
|
|
885
|
+
**Total Effort:** 12-15 days for all recommendations
|
|
886
|
+
|
|
887
|
+
**Recommended Phased Approach:**
|
|
888
|
+
|
|
889
|
+
**Phase 1 (Week 1):** Foundation
|
|
890
|
+
- Split `execution/runner.ts` (P1)
|
|
891
|
+
- Add execution runner tests (P1)
|
|
892
|
+
- Unified verification layer (P2)
|
|
893
|
+
|
|
894
|
+
**Phase 2 (Week 2):** Quality
|
|
895
|
+
- Add TDD orchestrator tests (P2)
|
|
896
|
+
- Split config schema (P3)
|
|
897
|
+
- Split `tdd/orchestrator.ts` (P3)
|
|
898
|
+
|
|
899
|
+
**Phase 3 (Week 3):** Extensions
|
|
900
|
+
- Agent adapter plugins (P4)
|
|
901
|
+
- Extract business logic (P5)
|
|
902
|
+
|
|
903
|
+
---
|
|
904
|
+
|
|
905
|
+
## 9. Architectural Strengths (Keep These)
|
|
906
|
+
|
|
907
|
+
### ✅ Pipeline Architecture
|
|
908
|
+
|
|
909
|
+
**Why It's Good:**
|
|
910
|
+
- Clean separation of concerns via stages
|
|
911
|
+
- Immutable context with explicit mutation contract
|
|
912
|
+
- Composable and testable
|
|
913
|
+
- Easy to add new stages
|
|
914
|
+
- Event-driven for TUI integration
|
|
915
|
+
|
|
916
|
+
**Example:**
|
|
917
|
+
```typescript
|
|
918
|
+
// pipeline/runner.ts - Clean, focused (162 lines)
|
|
919
|
+
export async function execute(story: Story): Promise<PipelineResult> {
|
|
920
|
+
const stages = [
|
|
921
|
+
queueCheckStage,
|
|
922
|
+
routingStage,
|
|
923
|
+
constitutionStage,
|
|
924
|
+
contextStage,
|
|
925
|
+
promptStage,
|
|
926
|
+
optimizerStage,
|
|
927
|
+
executionStage,
|
|
928
|
+
verifyStage,
|
|
929
|
+
reviewStage,
|
|
930
|
+
acceptanceStage,
|
|
931
|
+
completionStage,
|
|
932
|
+
]
|
|
933
|
+
|
|
934
|
+
let context = createContext(story)
|
|
935
|
+
|
|
936
|
+
for (const stage of stages) {
|
|
937
|
+
context = await stage.execute(context)
|
|
938
|
+
if (context.shouldAbort) break
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
return context.result
|
|
942
|
+
}
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
**Don't Change:** This is the backbone of the architecture.
|
|
946
|
+
|
|
947
|
+
---
|
|
948
|
+
|
|
949
|
+
### ✅ Plugin System
|
|
950
|
+
|
|
951
|
+
**Why It's Good:**
|
|
952
|
+
- 6 well-designed extension points
|
|
953
|
+
- Clean interface-based design
|
|
954
|
+
- Strong validation
|
|
955
|
+
- Teardown lifecycle
|
|
956
|
+
- Dependency injection via registry
|
|
957
|
+
|
|
958
|
+
**Example:**
|
|
959
|
+
```typescript
|
|
960
|
+
// plugins/types.ts - Clean interfaces
|
|
961
|
+
export interface IContextProvider {
|
|
962
|
+
name: string
|
|
963
|
+
shouldProvide(story: Story): boolean
|
|
964
|
+
provideContext(story: Story): Promise<string>
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
export interface IReviewer {
|
|
968
|
+
name: string
|
|
969
|
+
review(result: AgentResult): Promise<ReviewResult>
|
|
970
|
+
}
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
**Don't Change:** This is a major architectural strength.
|
|
974
|
+
|
|
975
|
+
---
|
|
976
|
+
|
|
977
|
+
### ✅ Type Safety
|
|
978
|
+
|
|
979
|
+
**Why It's Good:**
|
|
980
|
+
- Comprehensive TypeScript types
|
|
981
|
+
- Zod validation for config
|
|
982
|
+
- Type-safe event emitter
|
|
983
|
+
- Discriminated unions for result types
|
|
984
|
+
|
|
985
|
+
**Example:**
|
|
986
|
+
```typescript
|
|
987
|
+
// prd/types.ts - Strong typing
|
|
988
|
+
export type Story = {
|
|
989
|
+
id: string
|
|
990
|
+
title: string
|
|
991
|
+
description: string
|
|
992
|
+
acceptanceCriteria?: string[]
|
|
993
|
+
dependencies?: string[]
|
|
994
|
+
category?: FailureCategory
|
|
995
|
+
auto?: AutoDefault
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
export type RoutingResult = {
|
|
999
|
+
tier: ModelTier
|
|
1000
|
+
strategy: TestStrategy
|
|
1001
|
+
reason: string
|
|
1002
|
+
}
|
|
1003
|
+
```
|
|
1004
|
+
|
|
1005
|
+
**Don't Change:** Maintain strong typing throughout.
|
|
1006
|
+
|
|
1007
|
+
---
|
|
1008
|
+
|
|
1009
|
+
### ✅ Layered Configuration
|
|
1010
|
+
|
|
1011
|
+
**Why It's Good:**
|
|
1012
|
+
- Global + project config merging
|
|
1013
|
+
- Environment variable override
|
|
1014
|
+
- Strong validation
|
|
1015
|
+
- Path security
|
|
1016
|
+
|
|
1017
|
+
**Example:**
|
|
1018
|
+
```typescript
|
|
1019
|
+
// config/loader.ts - Clean layering
|
|
1020
|
+
export async function loadConfig(): Promise<Config> {
|
|
1021
|
+
const globalConfig = await loadGlobalConfig()
|
|
1022
|
+
const projectConfig = await loadProjectConfig()
|
|
1023
|
+
return mergeConfigs(globalConfig, projectConfig)
|
|
1024
|
+
}
|
|
1025
|
+
```
|
|
1026
|
+
|
|
1027
|
+
**Don't Change:** This is a solid foundation.
|
|
1028
|
+
|
|
1029
|
+
---
|
|
1030
|
+
|
|
1031
|
+
## 10. Final Recommendations
|
|
1032
|
+
|
|
1033
|
+
### Immediate Actions (This Sprint)
|
|
1034
|
+
|
|
1035
|
+
1. **Create Issue for God File:**
|
|
1036
|
+
- Title: "Refactor execution/runner.ts (1,685 lines → 300 lines)"
|
|
1037
|
+
- Priority: Critical
|
|
1038
|
+
- Label: technical-debt
|
|
1039
|
+
|
|
1040
|
+
2. **Add Missing Tests:**
|
|
1041
|
+
- `test/integration/tdd-orchestrator.test.ts`
|
|
1042
|
+
- `test/unit/agents/claude.test.ts`
|
|
1043
|
+
|
|
1044
|
+
3. **Document Extension Points:**
|
|
1045
|
+
- Add `docs/plugin-system.md`
|
|
1046
|
+
- Example plugins for each extension point
|
|
1047
|
+
|
|
1048
|
+
### Short-Term (Next 2 Sprints)
|
|
1049
|
+
|
|
1050
|
+
1. **Split `execution/runner.ts`** (see Priority 1 recommendation)
|
|
1051
|
+
2. **Create unified verification layer** (see Priority 2 recommendation)
|
|
1052
|
+
3. **Add comprehensive tests** for orchestration code
|
|
1053
|
+
|
|
1054
|
+
### Long-Term (Next Quarter)
|
|
1055
|
+
|
|
1056
|
+
1. **Agent adapter plugin system** (support Codex, Aider)
|
|
1057
|
+
2. **Extract business logic** to domain layer
|
|
1058
|
+
3. **Verification plugin system** (support jest, pytest)
|
|
1059
|
+
|
|
1060
|
+
---
|
|
1061
|
+
|
|
1062
|
+
## Conclusion
|
|
1063
|
+
|
|
1064
|
+
NAX has a **solid architectural foundation** with excellent plugin system, clean pipeline pattern, and strong type safety. The primary technical debt is the 1,685-line god file in `execution/runner.ts`, which should be split into focused modules.
|
|
1065
|
+
|
|
1066
|
+
**Current Grade: B+**
|
|
1067
|
+
**Potential Grade: A** (after refactoring god file and adding orchestration tests)
|
|
1068
|
+
|
|
1069
|
+
**Key Takeaway:** The architecture is well-designed overall. Focus refactoring efforts on the execution module to bring it up to the quality standards of the rest of the codebase.
|
|
1070
|
+
|
|
1071
|
+
---
|
|
1072
|
+
|
|
1073
|
+
**Analysis Date:** 2026-02-28
|
|
1074
|
+
**Analyzed By:** Claude Code Explore Agent
|
|
1075
|
+
**Review Status:** Internal Consumption
|
|
1076
|
+
**Next Review:** After execution module refactoring
|