@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.
- package/CHANGELOG.md +23 -2
- package/bin/nax.ts +2 -3
- package/dist/nax.js +72753 -0
- package/package.json +11 -3
- package/src/cli/analyze.ts +2 -7
- package/src/cli/config.ts +3 -1
- package/src/config/defaults.ts +1 -0
- package/src/config/schemas.ts +1 -0
- package/src/config/types.ts +1 -0
- package/src/context/builder.ts +10 -1
- package/src/execution/lifecycle/headless-formatter.ts +2 -4
- package/src/prompts/builder.ts +12 -69
- package/src/prompts/sections/isolation.ts +38 -8
- package/src/prompts/sections/role-task.ts +79 -17
- package/src/review/runner.ts +6 -1
- package/src/version.ts +2 -1
- package/.claude/rules/01-project-conventions.md +0 -34
- package/.claude/rules/02-test-architecture.md +0 -39
- package/.claude/rules/03-test-writing.md +0 -58
- package/.claude/rules/04-forbidden-patterns.md +0 -29
- package/.claude/settings.json +0 -15
- package/.githooks/pre-commit +0 -16
- package/.gitlab-ci.yml +0 -103
- package/.mcp.json +0 -8
- package/BRIEF.md +0 -140
- package/CLAUDE.md +0 -143
- package/US-007-IMPLEMENTATION.md +0 -139
- package/biome.json +0 -14
- package/bun.lock +0 -163
- package/bunfig.toml +0 -12
- package/docker-compose.test.yml +0 -15
- package/docs/20260216-fix-plan-context-review.md +0 -56
- package/docs/20260216-relentless-vs-ngent-comparison.md +0 -208
- package/docs/20260216-v02-plan.md +0 -136
- package/docs/20260216-v02-review.md +0 -685
- package/docs/20260217-dogfood-findings.md +0 -56
- package/docs/20260217-p2-plus-plan.md +0 -117
- package/docs/20260217-partial-fixes-plan.md +0 -62
- package/docs/20260217-plan-analyze-spec.md +0 -117
- package/docs/20260217-post-impl-review.md +0 -1137
- package/docs/20260217-quick-wins-plan.md +0 -66
- package/docs/20260217-split-runner-plan.md +0 -75
- package/docs/20260217-v03-impl-plan.md +0 -80
- package/docs/20260217-v03-post-impl-review.md +0 -589
- package/docs/20260217-v04-impl-plan.md +0 -86
- package/docs/20260217-v05-post-impl-review.md +0 -850
- package/docs/20260217-v06-post-impl-review.md +0 -817
- package/docs/20260218-adr003-port-plan.md +0 -151
- package/docs/20260218-review-adr003-verification.md +0 -175
- package/docs/20260219-fix-plan-bug16-19.md +0 -79
- package/docs/20260219-fix-plan-bug20-22.md +0 -114
- package/docs/20260219-plan-llm-routing.md +0 -116
- package/docs/20260219-review-bug20-22-fixes.md +0 -135
- package/docs/20260219-routing-baseline-keyword.md +0 -63
- package/docs/20260220-plan-structured-logging-p1.md +0 -80
- package/docs/20260220-plan-structured-logging-p2.md +0 -37
- package/docs/20260220-review-llm-routing.md +0 -180
- package/docs/20260220-review-post-fix-llm-routing.md +0 -70
- package/docs/20260221-fix-plan-relevantfiles-split.md +0 -101
- package/docs/20260221-fix-plan-routing-mode.md +0 -125
- package/docs/20260221-review-v0.9-implementation.md +0 -379
- package/docs/20260222-fix-plan-v091-routing-isolation.md +0 -197
- package/docs/20260223-fix-plan-prompt-audit.md +0 -62
- package/docs/20260224-nax-roadmap-phases.md +0 -189
- package/docs/20260225-phase2-llm-service-layer.md +0 -401
- package/docs/20260225-review-v0.10.1.md +0 -187
- package/docs/20260303-v010-implementation-plan.md +0 -165
- package/docs/20260304-review-nax.md +0 -492
- package/docs/CLAUDE.md.bak +0 -191
- package/docs/ROADMAP.md +0 -390
- package/docs/SPEC-rectification.md +0 -0
- package/docs/SPEC.md +0 -324
- package/docs/US-001-plugin-loading-verification.md +0 -152
- package/docs/adr/ADR-005-implementation-plan.md +0 -655
- package/docs/adr/ADR-005-pipeline-re-architecture.md +0 -464
- package/docs/architecture-analysis.md +0 -1076
- package/docs/bugs/BUG-21-escalation-null-attempts.md +0 -48
- package/docs/bugs-from-dogfood-run-c.md +0 -243
- package/docs/code-review-20260228.md +0 -612
- package/docs/code-review-v0.15.0.md +0 -629
- package/docs/hook-lifecycle-test-plan.md +0 -149
- package/docs/releases/v0.11.0-and-earlier.md +0 -20
- package/docs/releases/v0.12.0.md +0 -15
- package/docs/releases/v0.13.0.md +0 -14
- package/docs/releases/v0.14.0.md +0 -20
- package/docs/releases/v0.14.1.md +0 -36
- package/docs/releases/v0.14.2.md +0 -51
- package/docs/releases/v0.14.3.md +0 -174
- package/docs/releases/v0.14.4.md +0 -94
- package/docs/releases/v0.15.0.md +0 -502
- package/docs/releases/v0.15.1.md +0 -170
- package/docs/releases/v0.15.3.md +0 -193
- package/docs/specs/bug-039-orphan-processes.md +0 -131
- package/docs/specs/bug-040-review-rectification.md +0 -82
- package/docs/specs/bug-041-cross-story-test-isolation.md +0 -88
- package/docs/specs/bug-042-verifier-failure-capture.md +0 -117
- package/docs/specs/bun-pty-migration.md +0 -171
- package/docs/specs/central-run-registry.md +0 -116
- package/docs/specs/feat-010-smart-runner-git-history.md +0 -96
- package/docs/specs/feat-011-file-context-strategy.md +0 -73
- package/docs/specs/feat-012-tdd-writer-tier.md +0 -79
- package/docs/specs/feat-013-test-after-review.md +0 -89
- package/docs/specs/feat-014-heartbeat-observability.md +0 -127
- package/docs/specs/status-file-consolidation.md +0 -93
- package/docs/specs/status-file-v0.10.1.md +0 -812
- package/docs/specs/trigger-completion.md +0 -145
- package/docs/specs/verification-architecture-v2.md +0 -343
- package/docs/tdd/strategies.md +0 -97
- package/docs/v0.10-global-config.md +0 -206
- package/docs/v0.10-plugin-system.md +0 -415
- package/docs/v0.10-prompt-optimizer.md +0 -234
- package/docs/v0.3-spec.md +0 -244
- package/docs/v0.4-spec.md +0 -140
- package/docs/v0.5-spec.md +0 -237
- package/docs/v0.6-spec.md +0 -371
- package/docs/v0.7-spec.md +0 -177
- package/docs/v0.8-llm-routing.md +0 -206
- package/docs/v0.8-structured-logging.md +0 -132
- package/docs/v0.9.3-prompt-audit.md +0 -112
- package/examples/plugins/console-reporter/index.test.ts +0 -207
- package/examples/plugins/console-reporter/index.ts +0 -110
- package/memory/topic/feat-010-baseref.md +0 -28
- package/memory/topic/feat-013-test-after-deprecation.md +0 -22
- package/nax/config.json +0 -154
- package/nax/features/bug-039-medium/prd.json +0 -45
- package/nax/features/bugfix-v0171/prd.json +0 -52
- package/nax/features/central-run-registry/prd.json +0 -105
- package/nax/features/config-management/prd.json +0 -108
- package/nax/features/config-management/progress.txt +0 -5
- package/nax/features/diagnose/acceptance.test.ts +0 -414
- package/nax/features/diagnose/prd.json +0 -41
- package/nax/features/nax-compliance/prd.json +0 -52
- package/nax/features/nax-compliance/progress.txt +0 -1
- package/nax/features/orchestration-fixes/prd.json +0 -89
- package/nax/features/orchestration-fixes/progress.txt +0 -1
- package/nax/features/plugin-integration/US-007-VERIFICATION.md +0 -259
- package/nax/features/plugin-integration/prd.json +0 -208
- package/nax/features/plugin-integration/progress.txt +0 -5
- package/nax/features/post-rearch-bugfix/prd.json +0 -137
- package/nax/features/precheck/prd.json +0 -205
- package/nax/features/precheck/progress.txt +0 -15
- package/nax/features/prompt-builder/prd.json +0 -152
- package/nax/features/prompt-builder/progress.txt +0 -3
- package/nax/features/review-quality/prd.json +0 -55
- package/nax/features/routing-persistence/prd.json +0 -104
- package/nax/features/routing-persistence/progress.txt +0 -1
- package/nax/features/smart-test-runner/plan.md +0 -7
- package/nax/features/smart-test-runner/prd.json +0 -203
- package/nax/features/smart-test-runner/progress.txt +0 -13
- package/nax/features/smart-test-runner/spec.md +0 -7
- package/nax/features/smart-test-runner/tasks.md +0 -8
- package/nax/features/status-file-consolidation/prd.json +0 -106
- package/nax/features/structured-logging/prd.json +0 -199
- package/nax/features/trigger-completion/prd.json +0 -150
- package/nax/features/trigger-completion/progress.txt +0 -7
- package/nax/features/unlock/prd.json +0 -36
- package/nax/features/v0.18.3-execution-reliability/prd.json +0 -80
- package/nax/features/v0.18.3-execution-reliability/progress.txt +0 -3
- package/nax/features/v0.19.0-hardening/plan.md +0 -7
- package/nax/features/v0.19.0-hardening/prd.json +0 -84
- package/nax/features/v0.19.0-hardening/progress.txt +0 -7
- package/nax/features/v0.19.0-hardening/spec.md +0 -18
- package/nax/features/v0.19.0-hardening/tasks.md +0 -8
- package/nax/features/verify-v2/prd.json +0 -79
- package/nax/features/verify-v2/progress.txt +0 -3
- package/nax/status.json +0 -36
- package/src/prompts/templates/implementer.ts +0 -6
- package/src/prompts/templates/single-session.ts +0 -6
- package/src/prompts/templates/test-writer.ts +0 -6
- package/src/prompts/templates/verifier.ts +0 -6
- package/test/COVERAGE-GAPS.md +0 -333
- package/test/e2e/cm-003-default-view.test.ts +0 -195
- package/test/e2e/plan-analyze-run.test.ts +0 -902
- package/test/helpers/helpers.test.ts +0 -295
- package/test/helpers/timeout.ts +0 -42
- package/test/integration/US-002-TEST-SUMMARY.md +0 -107
- package/test/integration/US-003-TEST-SUMMARY.md +0 -149
- package/test/integration/US-004-TEST-SUMMARY.md +0 -106
- package/test/integration/US-005-TEST-SUMMARY.md +0 -138
- package/test/integration/US-007-TEST-SUMMARY.md +0 -100
- package/test/integration/cli/agent-validation.test.ts +0 -439
- package/test/integration/cli/cli-config-default-edge-cases.test.ts +0 -223
- package/test/integration/cli/cli-config-default-view.test.ts +0 -230
- package/test/integration/cli/cli-config-diff.test.ts +0 -461
- package/test/integration/cli/cli-config-prompts-explain.test.ts +0 -74
- package/test/integration/cli/cli-config.test.ts +0 -737
- package/test/integration/cli/cli-diagnose.test.ts +0 -595
- package/test/integration/cli/cli-logs.test.ts +0 -346
- package/test/integration/cli/cli-plugins.test.ts +0 -679
- package/test/integration/cli/cli-precheck.test.ts +0 -372
- package/test/integration/cli/cli-run-headless.test.ts +0 -174
- package/test/integration/cli/cli.test.ts +0 -76
- package/test/integration/cli/precheck-integration.test.ts +0 -476
- package/test/integration/cli/precheck-orchestrator.test.ts +0 -247
- package/test/integration/cli/precheck.test.ts +0 -806
- package/test/integration/config/config-loader.test.ts +0 -266
- package/test/integration/config/config.test.ts +0 -444
- package/test/integration/config/merger.test.ts +0 -466
- package/test/integration/config/paths.test.ts +0 -52
- package/test/integration/config/security-loader.test.ts +0 -83
- package/test/integration/context/context-integration.test.ts +0 -703
- package/test/integration/context/context-path-security.test.ts +0 -173
- package/test/integration/context/context-provider-injection.test.ts +0 -507
- package/test/integration/context/context-verification-integration.test.ts +0 -296
- package/test/integration/context/s5-greenfield-fallback.test.ts +0 -298
- package/test/integration/execution/execution-isolation.test.ts +0 -143
- package/test/integration/execution/execution.test.ts +0 -634
- package/test/integration/execution/feature-status-write.test.ts +0 -302
- package/test/integration/execution/parallel.test.ts +0 -251
- package/test/integration/execution/prd-pause.test.ts +0 -205
- package/test/integration/execution/prd-resolvers.test.ts +0 -186
- package/test/integration/execution/progress.test.ts +0 -34
- package/test/integration/execution/runner-batching.test.ts +0 -682
- package/test/integration/execution/runner-config-plugins.test.ts +0 -462
- package/test/integration/execution/runner-escalation.test.ts +0 -561
- package/test/integration/execution/runner-fixes.test.ts +0 -400
- package/test/integration/execution/runner-plugin-integration.test.ts +0 -544
- package/test/integration/execution/runner-queue-and-attempts.test.ts +0 -476
- package/test/integration/execution/status-file-integration.test.ts +0 -289
- package/test/integration/execution/status-file.test.ts +0 -380
- package/test/integration/execution/status-writer.test.ts +0 -447
- package/test/integration/execution/story-id-in-events.test.ts +0 -274
- package/test/integration/interaction/interaction-chain-pipeline.test.ts +0 -476
- package/test/integration/pipeline/hooks.test.ts +0 -363
- package/test/integration/pipeline/pipeline-acceptance.test.ts +0 -303
- package/test/integration/pipeline/pipeline-events.test.ts +0 -476
- package/test/integration/pipeline/pipeline.test.ts +0 -660
- package/test/integration/pipeline/reporter-lifecycle.test.ts +0 -862
- package/test/integration/pipeline/verify-stage.test.ts +0 -286
- package/test/integration/plan/analyze-integration.test.ts +0 -262
- package/test/integration/plan/analyze-scanner.test.ts +0 -132
- package/test/integration/plan/logger.test.ts +0 -461
- package/test/integration/plan/plan.test.ts +0 -157
- package/test/integration/plugins/config-integration.test.ts +0 -173
- package/test/integration/plugins/config-resolution.test.ts +0 -523
- package/test/integration/plugins/loader.test.ts +0 -644
- package/test/integration/plugins/plugins-registry.test.ts +0 -747
- package/test/integration/plugins/validator.test.ts +0 -564
- package/test/integration/prompts/pb-004-migration.test.ts +0 -523
- package/test/integration/review/review-config-commands.test.ts +0 -320
- package/test/integration/review/review-config-schema.test.ts +0 -117
- package/test/integration/review/review-plugin-integration.test.ts +0 -729
- package/test/integration/review/review.test.ts +0 -150
- package/test/integration/routing/plugin-routing-advanced.test.ts +0 -461
- package/test/integration/routing/plugin-routing-core.test.ts +0 -527
- package/test/integration/routing/routing-stage-bug-021.test.ts +0 -275
- package/test/integration/routing/routing-stage-greenfield.test.ts +0 -287
- package/test/integration/tdd/tdd-cleanup.test.ts +0 -246
- package/test/integration/tdd/tdd-orchestrator-core.test.ts +0 -565
- package/test/integration/tdd/tdd-orchestrator-failureCategory.test.ts +0 -355
- package/test/integration/tdd/tdd-orchestrator-fallback.test.ts +0 -311
- package/test/integration/tdd/tdd-orchestrator-lite.test.ts +0 -289
- package/test/integration/tdd/tdd-orchestrator-prompts.test.ts +0 -260
- package/test/integration/tdd/tdd-orchestrator-verdict.test.ts +0 -536
- package/test/integration/tmp/headless-test/test.jsonl +0 -30
- package/test/integration/verification/test-scanner.test.ts +0 -403
- package/test/integration/verification/verification-asset-check.test.ts +0 -143
- package/test/integration/worktree/manager.test.ts +0 -218
- package/test/integration/worktree/worktree-merge.test.ts +0 -341
- package/test/manual/logging-formatter-demo.ts +0 -158
- package/test/ui/tui-agent-panel.test.tsx +0 -99
- package/test/ui/tui-pty-integration.test.tsx +0 -146
- package/test/unit/acceptance.test.ts +0 -187
- package/test/unit/agent-stderr-capture.test.ts +0 -147
- package/test/unit/agents/claude.test.ts +0 -107
- package/test/unit/analyze-classifier.test.ts +0 -216
- package/test/unit/analyze.test.ts +0 -224
- package/test/unit/auto-detect.test.ts +0 -250
- package/test/unit/cli-status-project-level.test.ts +0 -283
- package/test/unit/cli-status.test.ts +0 -418
- package/test/unit/commands/common.test.ts +0 -321
- package/test/unit/commands/logs.test.ts +0 -458
- package/test/unit/commands/runs.test.ts +0 -303
- package/test/unit/commands/unlock.test.ts +0 -320
- package/test/unit/config/defaults.test.ts +0 -70
- package/test/unit/config/quality-commands-schema.test.ts +0 -72
- package/test/unit/config/regression-gate-schema.test.ts +0 -160
- package/test/unit/config/smart-runner-flag.test.ts +0 -250
- package/test/unit/constitution-generators.test.ts +0 -161
- package/test/unit/constitution.test.ts +0 -210
- package/test/unit/context/context-autodetect.test.ts +0 -297
- package/test/unit/context/context-build.test.ts +0 -575
- package/test/unit/context/context-coverage.test.ts +0 -236
- package/test/unit/context/context-error.test.ts +0 -93
- package/test/unit/context/context-estimate-tokens.test.ts +0 -201
- package/test/unit/context/context-format.test.ts +0 -302
- package/test/unit/context/context-isolation.test.ts +0 -267
- package/test/unit/context/context-sort.test.ts +0 -93
- package/test/unit/context/context-story.test.ts +0 -108
- package/test/unit/context/prior-failures.test.ts +0 -463
- package/test/unit/context.test.ts +0 -1726
- package/test/unit/cost.test.ts +0 -231
- package/test/unit/crash-recovery.test.ts +0 -309
- package/test/unit/escalation.test.ts +0 -127
- package/test/unit/execution/lifecycle/run-completion.test.ts +0 -240
- package/test/unit/execution/lifecycle/run-regression.test.ts +0 -420
- package/test/unit/execution/pid-registry.test.ts +0 -241
- package/test/unit/execution/sequential-executor.test.ts +0 -235
- package/test/unit/execution/sfc-004-dead-code-cleanup.test.ts +0 -89
- package/test/unit/execution/structured-failure.test.ts +0 -415
- package/test/unit/execution-logging-stderr.test.ts +0 -157
- package/test/unit/execution-stage.test.ts +0 -123
- package/test/unit/fix-generator.test.ts +0 -276
- package/test/unit/formatters.test.ts +0 -468
- package/test/unit/greenfield.test.ts +0 -180
- package/test/unit/hooks/shell-security.test.ts +0 -40
- package/test/unit/interaction/auto-plugin.test.ts +0 -162
- package/test/unit/interaction/human-review-trigger.test.ts +0 -165
- package/test/unit/interaction-network-failures.test.ts +0 -390
- package/test/unit/interaction-plugins.test.ts +0 -472
- package/test/unit/logging/formatter.test.ts +0 -456
- package/test/unit/merge.test.ts +0 -269
- package/test/unit/metrics/aggregator.test.ts +0 -164
- package/test/unit/metrics/tracker.test.ts +0 -186
- package/test/unit/metrics.test.ts +0 -276
- package/test/unit/optimizer/noop.optimizer.test.ts +0 -125
- package/test/unit/optimizer/rule-based.optimizer.test.ts +0 -358
- package/test/unit/pipeline/event-bus.test.ts +0 -105
- package/test/unit/pipeline/routing-partial-override.test.ts +0 -121
- package/test/unit/pipeline/runner-retry.test.ts +0 -89
- package/test/unit/pipeline/stages/autofix.test.ts +0 -97
- package/test/unit/pipeline/stages/completion-review-gate.test.ts +0 -218
- package/test/unit/pipeline/stages/execution-ambiguity.test.ts +0 -311
- package/test/unit/pipeline/stages/execution-merge-conflict.test.ts +0 -218
- package/test/unit/pipeline/stages/rectify.test.ts +0 -101
- package/test/unit/pipeline/stages/regression-stage.test.ts +0 -69
- package/test/unit/pipeline/stages/review.test.ts +0 -201
- package/test/unit/pipeline/stages/routing-idempotence.test.ts +0 -139
- package/test/unit/pipeline/stages/routing-initial-complexity.test.ts +0 -321
- package/test/unit/pipeline/stages/routing-persistence.test.ts +0 -380
- package/test/unit/pipeline/stages/verify.test.ts +0 -267
- package/test/unit/pipeline/subscribers/events-writer.test.ts +0 -227
- package/test/unit/pipeline/subscribers/hooks.test.ts +0 -84
- package/test/unit/pipeline/subscribers/interaction.test.ts +0 -313
- package/test/unit/pipeline/subscribers/registry.test.ts +0 -149
- package/test/unit/pipeline/subscribers/reporters.test.ts +0 -90
- package/test/unit/pipeline/verify-smart-runner.test.ts +0 -345
- package/test/unit/prd-auto-default.test.ts +0 -291
- package/test/unit/prd-failure-category.test.ts +0 -177
- package/test/unit/prd-get-next-story.test.ts +0 -215
- package/test/unit/precheck/checks-warnings.test.ts +0 -114
- package/test/unit/precheck-checks.test.ts +0 -841
- package/test/unit/precheck-story-size-gate.test.ts +0 -288
- package/test/unit/precheck-types.test.ts +0 -143
- package/test/unit/prompts/builder.test.ts +0 -258
- package/test/unit/prompts/loader.test.ts +0 -355
- package/test/unit/prompts/sections/conventions.test.ts +0 -30
- package/test/unit/prompts/sections/isolation.test.ts +0 -35
- package/test/unit/prompts/sections/role-task.test.ts +0 -40
- package/test/unit/prompts/sections/sections.test.ts +0 -238
- package/test/unit/prompts/sections/story.test.ts +0 -45
- package/test/unit/prompts/sections/verdict.test.ts +0 -58
- package/test/unit/prompts.test.ts +0 -476
- package/test/unit/queue.test.ts +0 -237
- package/test/unit/rectification.test.ts +0 -285
- package/test/unit/registry.test.ts +0 -288
- package/test/unit/review/runner.test.ts +0 -117
- package/test/unit/routing/content-hash.test.ts +0 -99
- package/test/unit/routing/routing-stability.test.ts +0 -208
- package/test/unit/routing/strategies/llm.test.ts +0 -306
- package/test/unit/routing-advanced.test.ts +0 -313
- package/test/unit/routing-core.test.ts +0 -341
- package/test/unit/routing-strategies.test.ts +0 -440
- package/test/unit/storyid-events.test.ts +0 -213
- package/test/unit/tdd-verdict.test.ts +0 -492
- package/test/unit/test-output-parser.test.ts +0 -377
- package/test/unit/ui/tui-controls.test.ts +0 -335
- package/test/unit/ui/tui-cost-and-pty.test.ts +0 -190
- package/test/unit/ui/tui-layout.test.ts +0 -379
- package/test/unit/ui/tui-stories.test.ts +0 -333
- package/test/unit/unit-isolation.test.ts +0 -135
- package/test/unit/utils/git.test.ts +0 -50
- package/test/unit/utils/path-security.test.ts +0 -47
- package/test/unit/utils-helpers.test.ts +0 -318
- package/test/unit/verdict.test.ts +0 -325
- package/test/unit/verification/orchestrator-types.test.ts +0 -54
- package/test/unit/verification/orchestrator.test.ts +0 -66
- package/test/unit/verification/smart-runner-config.test.ts +0 -163
- package/test/unit/verification/smart-runner-discovery.test.ts +0 -354
- package/test/unit/verification/smart-runner.test.ts +0 -262
- package/test/unit/verification/strategies/acceptance.test.ts +0 -33
- package/test/unit/verification/strategies/regression.test.ts +0 -87
- package/test/unit/verification/strategies/scoped.test.ts +0 -100
- package/test/unit/worktree-manager.test.ts +0 -159
- package/tsconfig.json +0 -27
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
// RE-ARCH: keep
|
|
2
|
-
/**
|
|
3
|
-
* Unit tests for StructuredFailure and priorFailures tracking
|
|
4
|
-
*
|
|
5
|
-
* Tests the structured failure context for escalated tiers to know exactly what failed.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, expect, test } from "bun:test";
|
|
9
|
-
import { loadPRD } from "../../../src/prd";
|
|
10
|
-
import type { StructuredFailure, TestFailureContext, UserStory } from "../../../src/prd";
|
|
11
|
-
|
|
12
|
-
describe("StructuredFailure Type", () => {
|
|
13
|
-
test("should have all required fields", () => {
|
|
14
|
-
const failure: StructuredFailure = {
|
|
15
|
-
attempt: 1,
|
|
16
|
-
modelTier: "balanced",
|
|
17
|
-
stage: "verify",
|
|
18
|
-
summary: "Test failed",
|
|
19
|
-
timestamp: new Date().toISOString(),
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
expect(failure.attempt).toBe(1);
|
|
23
|
-
expect(failure.modelTier).toBe("balanced");
|
|
24
|
-
expect(failure.stage).toBe("verify");
|
|
25
|
-
expect(failure.summary).toBe("Test failed");
|
|
26
|
-
expect(failure.timestamp).toBeDefined();
|
|
27
|
-
expect(typeof failure.timestamp).toBe("string");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test("should have optional testFailures field", () => {
|
|
31
|
-
const testFailure: TestFailureContext = {
|
|
32
|
-
file: "test/foo.test.ts",
|
|
33
|
-
testName: "should pass",
|
|
34
|
-
error: "Expected 1 to equal 2",
|
|
35
|
-
stackTrace: ["at foo.ts:10:15", "at Object.test (foo.ts:8:3)"],
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const failure: StructuredFailure = {
|
|
39
|
-
attempt: 1,
|
|
40
|
-
modelTier: "balanced",
|
|
41
|
-
stage: "verify",
|
|
42
|
-
summary: "Test failed",
|
|
43
|
-
testFailures: [testFailure],
|
|
44
|
-
timestamp: new Date().toISOString(),
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
expect(failure.testFailures).toBeDefined();
|
|
48
|
-
expect(failure.testFailures?.length).toBe(1);
|
|
49
|
-
expect(failure.testFailures?.[0].file).toBe("test/foo.test.ts");
|
|
50
|
-
expect(failure.testFailures?.[0].testName).toBe("should pass");
|
|
51
|
-
expect(failure.testFailures?.[0].error).toBe("Expected 1 to equal 2");
|
|
52
|
-
expect(failure.testFailures?.[0].stackTrace.length).toBe(2);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test("should support all verification stages", () => {
|
|
56
|
-
const stages: Array<StructuredFailure["stage"]> = [
|
|
57
|
-
"verify",
|
|
58
|
-
"review",
|
|
59
|
-
"regression",
|
|
60
|
-
"rectification",
|
|
61
|
-
"agent-session",
|
|
62
|
-
"escalation",
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
for (const stage of stages) {
|
|
66
|
-
const failure: StructuredFailure = {
|
|
67
|
-
attempt: 1,
|
|
68
|
-
modelTier: "balanced",
|
|
69
|
-
stage,
|
|
70
|
-
summary: "Test failed",
|
|
71
|
-
timestamp: new Date().toISOString(),
|
|
72
|
-
};
|
|
73
|
-
expect(failure.stage).toBe(stage);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test("should allow different model tiers", () => {
|
|
78
|
-
const tiers = ["fast", "balanced", "powerful"];
|
|
79
|
-
|
|
80
|
-
for (const tier of tiers) {
|
|
81
|
-
const failure: StructuredFailure = {
|
|
82
|
-
attempt: 1,
|
|
83
|
-
modelTier: tier,
|
|
84
|
-
stage: "verify",
|
|
85
|
-
summary: "Test failed",
|
|
86
|
-
timestamp: new Date().toISOString(),
|
|
87
|
-
};
|
|
88
|
-
expect(failure.modelTier).toBe(tier);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test("should track multiple test failures", () => {
|
|
93
|
-
const testFailures: TestFailureContext[] = [
|
|
94
|
-
{
|
|
95
|
-
file: "test/foo.test.ts",
|
|
96
|
-
testName: "test 1",
|
|
97
|
-
error: "Error 1",
|
|
98
|
-
stackTrace: ["at foo.ts:10"],
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
file: "test/bar.test.ts",
|
|
102
|
-
testName: "test 2",
|
|
103
|
-
error: "Error 2",
|
|
104
|
-
stackTrace: ["at bar.ts:20"],
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
file: "test/baz.test.ts",
|
|
108
|
-
testName: "test 3",
|
|
109
|
-
error: "Error 3",
|
|
110
|
-
stackTrace: ["at baz.ts:30"],
|
|
111
|
-
},
|
|
112
|
-
];
|
|
113
|
-
|
|
114
|
-
const failure: StructuredFailure = {
|
|
115
|
-
attempt: 2,
|
|
116
|
-
modelTier: "balanced",
|
|
117
|
-
stage: "regression",
|
|
118
|
-
summary: "Multiple test failures",
|
|
119
|
-
testFailures,
|
|
120
|
-
timestamp: new Date().toISOString(),
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
expect(failure.testFailures?.length).toBe(3);
|
|
124
|
-
expect(failure.testFailures?.[0].file).toBe("test/foo.test.ts");
|
|
125
|
-
expect(failure.testFailures?.[1].file).toBe("test/bar.test.ts");
|
|
126
|
-
expect(failure.testFailures?.[2].file).toBe("test/baz.test.ts");
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
describe("TestFailureContext Type", () => {
|
|
131
|
-
test("should have all required fields", () => {
|
|
132
|
-
const context: TestFailureContext = {
|
|
133
|
-
file: "test/example.test.ts",
|
|
134
|
-
testName: "should do something",
|
|
135
|
-
error: "AssertionError: expected true to be false",
|
|
136
|
-
stackTrace: ["at Object.test (example.test.ts:42:10)", "at async runTest (test.ts:100:5)"],
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
expect(context.file).toBe("test/example.test.ts");
|
|
140
|
-
expect(context.testName).toBe("should do something");
|
|
141
|
-
expect(context.error).toBe("AssertionError: expected true to be false");
|
|
142
|
-
expect(context.stackTrace.length).toBe(2);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test("should handle nested test names", () => {
|
|
146
|
-
const context: TestFailureContext = {
|
|
147
|
-
file: "test/example.test.ts",
|
|
148
|
-
testName: "describe block > nested block > test name",
|
|
149
|
-
error: "Error",
|
|
150
|
-
stackTrace: [],
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
expect(context.testName).toContain("describe block");
|
|
154
|
-
expect(context.testName).toContain("nested block");
|
|
155
|
-
expect(context.testName).toContain("test name");
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
test("should support empty stack traces", () => {
|
|
159
|
-
const context: TestFailureContext = {
|
|
160
|
-
file: "test/example.test.ts",
|
|
161
|
-
testName: "test",
|
|
162
|
-
error: "Error",
|
|
163
|
-
stackTrace: [],
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
expect(context.stackTrace.length).toBe(0);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
test("should support multiple stack trace lines", () => {
|
|
170
|
-
const context: TestFailureContext = {
|
|
171
|
-
file: "test/example.test.ts",
|
|
172
|
-
testName: "test",
|
|
173
|
-
error: "Error",
|
|
174
|
-
stackTrace: [
|
|
175
|
-
"at foo.ts:10:15",
|
|
176
|
-
"at bar.ts:20:10",
|
|
177
|
-
"at baz.ts:30:5",
|
|
178
|
-
"at Object.test (example.ts:40:3)",
|
|
179
|
-
"at async runTest (test.ts:50:5)",
|
|
180
|
-
],
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
expect(context.stackTrace.length).toBe(5);
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
describe("UserStory priorFailures Field", () => {
|
|
188
|
-
test("should have optional priorFailures field", () => {
|
|
189
|
-
const story: UserStory = {
|
|
190
|
-
id: "US-001",
|
|
191
|
-
title: "Test Story",
|
|
192
|
-
description: "A test story",
|
|
193
|
-
acceptanceCriteria: [],
|
|
194
|
-
tags: [],
|
|
195
|
-
dependencies: [],
|
|
196
|
-
status: "pending",
|
|
197
|
-
passes: false,
|
|
198
|
-
escalations: [],
|
|
199
|
-
attempts: 0,
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
expect(story.priorFailures).toBeUndefined();
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
test("should initialize priorFailures to empty array in loadPRD", async () => {
|
|
206
|
-
// Create a temporary PRD file without priorFailures
|
|
207
|
-
const prdContent = JSON.stringify({
|
|
208
|
-
project: "test",
|
|
209
|
-
feature: "test-feature",
|
|
210
|
-
branchName: "test-branch",
|
|
211
|
-
createdAt: new Date().toISOString(),
|
|
212
|
-
updatedAt: new Date().toISOString(),
|
|
213
|
-
userStories: [
|
|
214
|
-
{
|
|
215
|
-
id: "US-001",
|
|
216
|
-
title: "Test Story",
|
|
217
|
-
description: "Description",
|
|
218
|
-
acceptanceCriteria: [],
|
|
219
|
-
tags: [],
|
|
220
|
-
dependencies: [],
|
|
221
|
-
status: "pending",
|
|
222
|
-
passes: false,
|
|
223
|
-
escalations: [],
|
|
224
|
-
attempts: 0,
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
// Write to temp file
|
|
230
|
-
const tmpFile = "/tmp/test-prd-priorFailures.json";
|
|
231
|
-
await Bun.write(tmpFile, prdContent);
|
|
232
|
-
|
|
233
|
-
// Load and verify
|
|
234
|
-
const prd = await loadPRD(tmpFile);
|
|
235
|
-
expect(prd.userStories[0].priorFailures).toBeDefined();
|
|
236
|
-
expect(Array.isArray(prd.userStories[0].priorFailures)).toBe(true);
|
|
237
|
-
expect(prd.userStories[0].priorFailures?.length).toBe(0);
|
|
238
|
-
|
|
239
|
-
// Cleanup
|
|
240
|
-
await Bun.file(tmpFile).delete();
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
test("should preserve existing priorFailures when loading PRD", async () => {
|
|
244
|
-
const existingFailure: StructuredFailure = {
|
|
245
|
-
attempt: 1,
|
|
246
|
-
modelTier: "balanced",
|
|
247
|
-
stage: "verify",
|
|
248
|
-
summary: "Test failed",
|
|
249
|
-
timestamp: new Date().toISOString(),
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
const prdContent = JSON.stringify({
|
|
253
|
-
project: "test",
|
|
254
|
-
feature: "test-feature",
|
|
255
|
-
branchName: "test-branch",
|
|
256
|
-
createdAt: new Date().toISOString(),
|
|
257
|
-
updatedAt: new Date().toISOString(),
|
|
258
|
-
userStories: [
|
|
259
|
-
{
|
|
260
|
-
id: "US-001",
|
|
261
|
-
title: "Test Story",
|
|
262
|
-
description: "Description",
|
|
263
|
-
acceptanceCriteria: [],
|
|
264
|
-
tags: [],
|
|
265
|
-
dependencies: [],
|
|
266
|
-
status: "pending",
|
|
267
|
-
passes: false,
|
|
268
|
-
escalations: [],
|
|
269
|
-
attempts: 1,
|
|
270
|
-
priorFailures: [existingFailure],
|
|
271
|
-
},
|
|
272
|
-
],
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
const tmpFile = "/tmp/test-prd-existing-failures.json";
|
|
276
|
-
await Bun.write(tmpFile, prdContent);
|
|
277
|
-
|
|
278
|
-
const prd = await loadPRD(tmpFile);
|
|
279
|
-
expect(prd.userStories[0].priorFailures?.length).toBe(1);
|
|
280
|
-
expect(prd.userStories[0].priorFailures?.[0].attempt).toBe(1);
|
|
281
|
-
expect(prd.userStories[0].priorFailures?.[0].stage).toBe("verify");
|
|
282
|
-
|
|
283
|
-
await Bun.file(tmpFile).delete();
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
test("should allow adding multiple priorFailures to a story", () => {
|
|
287
|
-
const story: UserStory = {
|
|
288
|
-
id: "US-001",
|
|
289
|
-
title: "Test Story",
|
|
290
|
-
description: "Description",
|
|
291
|
-
acceptanceCriteria: [],
|
|
292
|
-
tags: [],
|
|
293
|
-
dependencies: [],
|
|
294
|
-
status: "failed",
|
|
295
|
-
passes: false,
|
|
296
|
-
escalations: [],
|
|
297
|
-
attempts: 3,
|
|
298
|
-
priorFailures: [
|
|
299
|
-
{
|
|
300
|
-
attempt: 1,
|
|
301
|
-
modelTier: "fast",
|
|
302
|
-
stage: "verify",
|
|
303
|
-
summary: "First failure",
|
|
304
|
-
timestamp: new Date().toISOString(),
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
attempt: 2,
|
|
308
|
-
modelTier: "balanced",
|
|
309
|
-
stage: "regression",
|
|
310
|
-
summary: "Second failure",
|
|
311
|
-
timestamp: new Date().toISOString(),
|
|
312
|
-
},
|
|
313
|
-
],
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
expect(story.priorFailures?.length).toBe(2);
|
|
317
|
-
expect(story.priorFailures?.[0].modelTier).toBe("fast");
|
|
318
|
-
expect(story.priorFailures?.[1].modelTier).toBe("balanced");
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
describe("StructuredFailure Attempt Tracking", () => {
|
|
323
|
-
test("should increment attempt number correctly", () => {
|
|
324
|
-
const failures: StructuredFailure[] = [];
|
|
325
|
-
|
|
326
|
-
for (let i = 1; i <= 3; i++) {
|
|
327
|
-
failures.push({
|
|
328
|
-
attempt: i,
|
|
329
|
-
modelTier: "balanced",
|
|
330
|
-
stage: "verify",
|
|
331
|
-
summary: `Attempt ${i} failed`,
|
|
332
|
-
timestamp: new Date().toISOString(),
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
expect(failures[0].attempt).toBe(1);
|
|
337
|
-
expect(failures[1].attempt).toBe(2);
|
|
338
|
-
expect(failures[2].attempt).toBe(3);
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
test("should track tier escalation in priorFailures", () => {
|
|
342
|
-
const failures: StructuredFailure[] = [
|
|
343
|
-
{
|
|
344
|
-
attempt: 1,
|
|
345
|
-
modelTier: "fast",
|
|
346
|
-
stage: "verify",
|
|
347
|
-
summary: "Failed on fast tier",
|
|
348
|
-
timestamp: new Date().toISOString(),
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
attempt: 2,
|
|
352
|
-
modelTier: "balanced",
|
|
353
|
-
stage: "escalation",
|
|
354
|
-
summary: "Escalated to balanced tier",
|
|
355
|
-
timestamp: new Date().toISOString(),
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
attempt: 3,
|
|
359
|
-
modelTier: "powerful",
|
|
360
|
-
stage: "escalation",
|
|
361
|
-
summary: "Escalated to powerful tier",
|
|
362
|
-
timestamp: new Date().toISOString(),
|
|
363
|
-
},
|
|
364
|
-
];
|
|
365
|
-
|
|
366
|
-
expect(failures.length).toBe(3);
|
|
367
|
-
expect(failures[0].modelTier).toBe("fast");
|
|
368
|
-
expect(failures[1].modelTier).toBe("balanced");
|
|
369
|
-
expect(failures[2].modelTier).toBe("powerful");
|
|
370
|
-
|
|
371
|
-
// Verify escalation stages
|
|
372
|
-
expect(failures[1].stage).toBe("escalation");
|
|
373
|
-
expect(failures[2].stage).toBe("escalation");
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
describe("StructuredFailure Timestamps", () => {
|
|
378
|
-
test("should use ISO format timestamps", () => {
|
|
379
|
-
const failure: StructuredFailure = {
|
|
380
|
-
attempt: 1,
|
|
381
|
-
modelTier: "balanced",
|
|
382
|
-
stage: "verify",
|
|
383
|
-
summary: "Test failed",
|
|
384
|
-
timestamp: new Date().toISOString(),
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
// ISO format: YYYY-MM-DDTHH:mm:ss.sssZ
|
|
388
|
-
expect(failure.timestamp).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/);
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
test("should have different timestamps for different failures", async () => {
|
|
392
|
-
const failure1: StructuredFailure = {
|
|
393
|
-
attempt: 1,
|
|
394
|
-
modelTier: "balanced",
|
|
395
|
-
stage: "verify",
|
|
396
|
-
summary: "First failure",
|
|
397
|
-
timestamp: new Date().toISOString(),
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
// Small delay to ensure different timestamp
|
|
401
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
402
|
-
|
|
403
|
-
const failure2: StructuredFailure = {
|
|
404
|
-
attempt: 2,
|
|
405
|
-
modelTier: "balanced",
|
|
406
|
-
stage: "verify",
|
|
407
|
-
summary: "Second failure",
|
|
408
|
-
timestamp: new Date().toISOString(),
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
// While millisecond precision should make them different, we just verify they're valid
|
|
412
|
-
expect(failure1.timestamp).toBeDefined();
|
|
413
|
-
expect(failure2.timestamp).toBeDefined();
|
|
414
|
-
});
|
|
415
|
-
});
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
// RE-ARCH: keep
|
|
2
|
-
/**
|
|
3
|
-
* Tests for exitCode and stderr in agent error scenarios
|
|
4
|
-
*
|
|
5
|
-
* Covers: AgentResult includes exitCode and stderr for debugging failures
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, expect, it } from "bun:test";
|
|
9
|
-
import type { AgentResult } from "../../src/agents/types";
|
|
10
|
-
|
|
11
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
12
|
-
// Test fixtures
|
|
13
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
14
|
-
|
|
15
|
-
function createFailedResult(overrides: Partial<AgentResult> = {}): AgentResult {
|
|
16
|
-
return {
|
|
17
|
-
success: false,
|
|
18
|
-
exitCode: 1,
|
|
19
|
-
output: "",
|
|
20
|
-
stderr: "",
|
|
21
|
-
rateLimited: false,
|
|
22
|
-
durationMs: 1000,
|
|
23
|
-
estimatedCost: 0.01,
|
|
24
|
-
...overrides,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
29
|
-
// Tests for AgentResult failure logging
|
|
30
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
31
|
-
|
|
32
|
-
describe("AgentResult failure logging fields", () => {
|
|
33
|
-
it("includes exitCode for diagnosing failures", () => {
|
|
34
|
-
const result = createFailedResult({
|
|
35
|
-
exitCode: 1,
|
|
36
|
-
stderr: "Error message",
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
expect(result.exitCode).toBe(1);
|
|
40
|
-
expect(result.success).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("captures stderr for root cause analysis", () => {
|
|
44
|
-
const result = createFailedResult({
|
|
45
|
-
exitCode: 401,
|
|
46
|
-
stderr: "401 Unauthorized: Invalid API key",
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
expect(result.exitCode).toBe(401);
|
|
50
|
-
expect(result.stderr).toContain("Unauthorized");
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("logs timeout with exit code 124", () => {
|
|
54
|
-
const result = createFailedResult({
|
|
55
|
-
exitCode: 124,
|
|
56
|
-
stderr: "SIGTERM: Process timeout",
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
expect(result.exitCode).toBe(124);
|
|
60
|
-
expect(result.stderr).toContain("timeout");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("handles rate limit failures with exit code and stderr", () => {
|
|
64
|
-
const result = createFailedResult({
|
|
65
|
-
exitCode: 429,
|
|
66
|
-
stderr: "Rate limit exceeded",
|
|
67
|
-
rateLimited: true,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
expect(result.exitCode).toBe(429);
|
|
71
|
-
expect(result.stderr).toContain("Rate limit");
|
|
72
|
-
expect(result.rateLimited).toBe(true);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("logs server errors with 500 exit code", () => {
|
|
76
|
-
const result = createFailedResult({
|
|
77
|
-
exitCode: 500,
|
|
78
|
-
stderr: "Internal server error: database connection failed",
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
expect(result.exitCode).toBe(500);
|
|
82
|
-
expect(result.stderr).toContain("database");
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("supports backward compatibility when stderr is undefined", () => {
|
|
86
|
-
const result: AgentResult = {
|
|
87
|
-
success: false,
|
|
88
|
-
exitCode: 1,
|
|
89
|
-
output: "output",
|
|
90
|
-
// stderr intentionally undefined for backward compat
|
|
91
|
-
rateLimited: false,
|
|
92
|
-
durationMs: 1000,
|
|
93
|
-
estimatedCost: 0.01,
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
expect(result.exitCode).toBe(1);
|
|
97
|
-
expect(result.stderr).toBeUndefined();
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("can serialize failure data to JSON for logging", () => {
|
|
101
|
-
const result = createFailedResult({
|
|
102
|
-
exitCode: 401,
|
|
103
|
-
stderr: "Authentication failed",
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const logData = {
|
|
107
|
-
exitCode: result.exitCode,
|
|
108
|
-
stderr: result.stderr || "",
|
|
109
|
-
rateLimited: result.rateLimited,
|
|
110
|
-
storyId: "story-001",
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const json = JSON.stringify(logData);
|
|
114
|
-
expect(json).toContain("401");
|
|
115
|
-
expect(json).toContain("Authentication");
|
|
116
|
-
|
|
117
|
-
const parsed = JSON.parse(json);
|
|
118
|
-
expect(parsed.exitCode).toBe(401);
|
|
119
|
-
expect(parsed.stderr).toBe("Authentication failed");
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("preserves special characters in stderr for JSONL format", () => {
|
|
123
|
-
const specialStderr = 'Error: "quoted" with\nnewline and \\backslash';
|
|
124
|
-
const result = createFailedResult({
|
|
125
|
-
stderr: specialStderr,
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const logData = JSON.stringify({ stderr: result.stderr });
|
|
129
|
-
const parsed = JSON.parse(logData);
|
|
130
|
-
expect(parsed.stderr).toBe(specialStderr);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("includes all critical fields for comprehensive failure logging", () => {
|
|
134
|
-
const result = createFailedResult({
|
|
135
|
-
success: false,
|
|
136
|
-
exitCode: 500,
|
|
137
|
-
output: "Last 5000 chars of stdout",
|
|
138
|
-
stderr: "Last 1000 chars of stderr",
|
|
139
|
-
rateLimited: false,
|
|
140
|
-
durationMs: 5000,
|
|
141
|
-
estimatedCost: 0.05,
|
|
142
|
-
pid: 12345,
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
// All fields should be available for logging
|
|
146
|
-
const logData = {
|
|
147
|
-
exitCode: result.exitCode,
|
|
148
|
-
stderr: result.stderr || "",
|
|
149
|
-
rateLimited: result.rateLimited,
|
|
150
|
-
storyId: "test",
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
expect(logData.exitCode).toBe(500);
|
|
154
|
-
expect(logData.stderr).toContain("stderr");
|
|
155
|
-
expect(logData.rateLimited).toBe(false);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
// RE-ARCH: keep
|
|
2
|
-
/**
|
|
3
|
-
* Tests for src/pipeline/stages/execution.ts
|
|
4
|
-
*
|
|
5
|
-
* Covers: routeTddFailure, execution stage critical paths
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, expect, it } from "bun:test";
|
|
9
|
-
import { routeTddFailure } from "../../src/pipeline/stages/execution";
|
|
10
|
-
import type { FailureCategory } from "../../src/tdd";
|
|
11
|
-
|
|
12
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
13
|
-
// Test fixtures
|
|
14
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
15
|
-
|
|
16
|
-
interface MockContext {
|
|
17
|
-
retryAsLite?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
21
|
-
// routeTddFailure
|
|
22
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
23
|
-
|
|
24
|
-
describe("routeTddFailure", () => {
|
|
25
|
-
it("escalates on isolation-violation in strict mode", () => {
|
|
26
|
-
const ctx: MockContext = {};
|
|
27
|
-
const result = routeTddFailure("isolation-violation", false, ctx);
|
|
28
|
-
|
|
29
|
-
expect(result.action).toBe("escalate");
|
|
30
|
-
expect(ctx.retryAsLite).toBe(true);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("escalates on isolation-violation in lite mode without setting retryAsLite", () => {
|
|
34
|
-
const ctx: MockContext = {};
|
|
35
|
-
const result = routeTddFailure("isolation-violation", true, ctx);
|
|
36
|
-
|
|
37
|
-
expect(result.action).toBe("escalate");
|
|
38
|
-
expect(ctx.retryAsLite).toBeUndefined();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("escalates on session-failure", () => {
|
|
42
|
-
const ctx: MockContext = {};
|
|
43
|
-
const result = routeTddFailure("session-failure", false, ctx);
|
|
44
|
-
|
|
45
|
-
expect(result.action).toBe("escalate");
|
|
46
|
-
expect(ctx.retryAsLite).toBeUndefined();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("escalates on tests-failing", () => {
|
|
50
|
-
const ctx: MockContext = {};
|
|
51
|
-
const result = routeTddFailure("tests-failing", false, ctx);
|
|
52
|
-
|
|
53
|
-
expect(result.action).toBe("escalate");
|
|
54
|
-
expect(ctx.retryAsLite).toBeUndefined();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("escalates on verifier-rejected", () => {
|
|
58
|
-
const ctx: MockContext = {};
|
|
59
|
-
const result = routeTddFailure("verifier-rejected", false, ctx);
|
|
60
|
-
|
|
61
|
-
expect(result.action).toBe("escalate");
|
|
62
|
-
expect(ctx.retryAsLite).toBeUndefined();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("pauses on undefined failureCategory", () => {
|
|
66
|
-
const ctx: MockContext = {};
|
|
67
|
-
const result = routeTddFailure(undefined, false, ctx, "Unknown failure");
|
|
68
|
-
|
|
69
|
-
expect(result.action).toBe("pause");
|
|
70
|
-
expect(result.reason).toBe("Unknown failure");
|
|
71
|
-
expect(ctx.retryAsLite).toBeUndefined();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("pauses on unknown failureCategory", () => {
|
|
75
|
-
const ctx: MockContext = {};
|
|
76
|
-
const result = routeTddFailure("unknown" as FailureCategory, false, ctx);
|
|
77
|
-
|
|
78
|
-
expect(result.action).toBe("pause");
|
|
79
|
-
expect(result.reason).toBe("Three-session TDD requires review");
|
|
80
|
-
expect(ctx.retryAsLite).toBeUndefined();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("uses custom reviewReason when pausing", () => {
|
|
84
|
-
const ctx: MockContext = {};
|
|
85
|
-
const result = routeTddFailure(undefined, false, ctx, "Custom reason for pause");
|
|
86
|
-
|
|
87
|
-
expect(result.action).toBe("pause");
|
|
88
|
-
expect(result.reason).toBe("Custom reason for pause");
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("defaults to generic pause message when no reviewReason provided", () => {
|
|
92
|
-
const ctx: MockContext = {};
|
|
93
|
-
const result = routeTddFailure(undefined, false, ctx);
|
|
94
|
-
|
|
95
|
-
expect(result.action).toBe("pause");
|
|
96
|
-
expect(result.reason).toBe("Three-session TDD requires review");
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("handles all known failure categories correctly", () => {
|
|
100
|
-
const categories: FailureCategory[] = [
|
|
101
|
-
"isolation-violation",
|
|
102
|
-
"session-failure",
|
|
103
|
-
"tests-failing",
|
|
104
|
-
"verifier-rejected",
|
|
105
|
-
];
|
|
106
|
-
|
|
107
|
-
for (const category of categories) {
|
|
108
|
-
const ctx: MockContext = {};
|
|
109
|
-
const result = routeTddFailure(category, false, ctx);
|
|
110
|
-
expect(result.action).toBe("escalate");
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("only sets retryAsLite for isolation-violation in strict mode", () => {
|
|
115
|
-
const categories: FailureCategory[] = ["session-failure", "tests-failing", "verifier-rejected"];
|
|
116
|
-
|
|
117
|
-
for (const category of categories) {
|
|
118
|
-
const ctx: MockContext = {};
|
|
119
|
-
routeTddFailure(category, false, ctx);
|
|
120
|
-
expect(ctx.retryAsLite).toBeUndefined();
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
});
|