atdd 0.3.3__py3-none-any.whl → 0.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. atdd/cli.py +223 -76
  2. atdd/coach/commands/add_persistence_metadata.py +3 -1
  3. atdd/coach/commands/infer_governance_status.py +3 -1
  4. atdd/coach/commands/interface.py +3 -1
  5. atdd/coach/commands/inventory.py +2 -2
  6. atdd/coach/commands/migration.py +11 -6
  7. atdd/coach/commands/test_runner.py +66 -27
  8. atdd/coach/commands/traceability.py +3 -1
  9. atdd/coach/conventions/session.convention.yaml +26 -26
  10. atdd/coach/templates/ATDD.md +15 -15
  11. atdd/coach/templates/SESSION-TEMPLATE.md +12 -12
  12. atdd/coach/utils/repo.py +24 -8
  13. atdd/coach/validators/shared_fixtures.py +27 -14
  14. atdd/coach/validators/test_session_validation.py +4 -4
  15. atdd/coder/conventions/commons.convention.yaml +1 -1
  16. atdd/coder/conventions/tests/test_component_taxonomy.py +4 -3
  17. atdd/coder/conventions/tests/test_component_urn_naming.py +9 -3
  18. atdd/coder/validators/test_commons_structure.py +9 -2
  19. atdd/coder/validators/test_complexity.py +3 -1
  20. atdd/coder/validators/test_cross_language_consistency.py +3 -1
  21. atdd/coder/validators/test_design_system_compliance.py +3 -1
  22. atdd/coder/validators/test_dto_testing_patterns.py +10 -3
  23. atdd/coder/validators/test_green_cross_stack_layers.py +9 -3
  24. atdd/coder/validators/test_green_layer_dependencies.py +9 -3
  25. atdd/coder/validators/test_green_python_layer_structure.py +8 -2
  26. atdd/coder/validators/test_green_supabase_layer_structure.py +8 -3
  27. atdd/coder/validators/test_import_boundaries.py +3 -1
  28. atdd/coder/validators/test_init_file_urns.py +3 -1
  29. atdd/coder/validators/test_preact_layer_boundaries.py +3 -1
  30. atdd/coder/validators/test_presentation_convention.py +3 -1
  31. atdd/coder/validators/test_python_architecture.py +9 -2
  32. atdd/coder/validators/test_quality_metrics.py +2 -1
  33. atdd/coder/validators/test_station_master_pattern.py +4 -2
  34. atdd/coder/validators/test_train_infrastructure.py +9 -2
  35. atdd/coder/validators/test_train_urns.py +9 -2
  36. atdd/coder/validators/test_typescript_architecture.py +10 -3
  37. atdd/coder/validators/test_usecase_structure.py +3 -1
  38. atdd/coder/validators/test_wagon_boundaries.py +8 -2
  39. atdd/planner/validators/test_plan_urn_resolution.py +3 -1
  40. atdd/planner/validators/test_wagon_urn_chain.py +3 -1
  41. atdd/planner/validators/test_wmbt_consistency.py +3 -1
  42. atdd/planner/validators/test_wmbt_vocabulary.py +8 -2
  43. atdd/tester/conventions/contract.convention.yaml +1 -1
  44. atdd/tester/conventions/migration.convention.yaml +5 -5
  45. atdd/tester/validators/cleanup_duplicate_headers.py +3 -1
  46. atdd/tester/validators/cleanup_duplicate_headers_v2.py +3 -1
  47. atdd/tester/validators/coverage_gap_report.py +3 -1
  48. atdd/tester/validators/fix_dual_ac_references.py +3 -1
  49. atdd/tester/validators/remove_duplicate_lines.py +3 -1
  50. atdd/tester/validators/test_acceptance_urn_filename_mapping.py +9 -3
  51. atdd/tester/validators/test_acceptance_urn_separator.py +9 -3
  52. atdd/tester/validators/test_contract_schema_compliance.py +9 -2
  53. atdd/tester/validators/test_contracts_structure.py +3 -1
  54. atdd/tester/validators/test_coverage_adequacy.py +3 -1
  55. atdd/tester/validators/test_dual_ac_reference.py +6 -2
  56. atdd/tester/validators/test_fixture_validity.py +2 -1
  57. atdd/tester/validators/test_isolation.py +9 -2
  58. atdd/tester/validators/test_migration_coverage.py +4 -2
  59. atdd/tester/validators/test_migration_generation.py +3 -1
  60. atdd/tester/validators/test_python_test_naming.py +3 -1
  61. atdd/tester/validators/test_red_layer_validation.py +7 -2
  62. atdd/tester/validators/test_red_python_layer_structure.py +7 -2
  63. atdd/tester/validators/test_red_supabase_layer_structure.py +8 -2
  64. atdd/tester/validators/test_telemetry_structure.py +9 -2
  65. {atdd-0.3.3.dist-info → atdd-0.4.1.dist-info}/METADATA +41 -12
  66. {atdd-0.3.3.dist-info → atdd-0.4.1.dist-info}/RECORD +70 -70
  67. {atdd-0.3.3.dist-info → atdd-0.4.1.dist-info}/WHEEL +0 -0
  68. {atdd-0.3.3.dist-info → atdd-0.4.1.dist-info}/entry_points.txt +0 -0
  69. {atdd-0.3.3.dist-info → atdd-0.4.1.dist-info}/licenses/LICENSE +0 -0
  70. {atdd-0.3.3.dist-info → atdd-0.4.1.dist-info}/top_level.txt +0 -0
@@ -1,8 +1,15 @@
1
1
  #!/usr/bin/env python3
2
2
  """
3
- Test runner for ATDD meta-tests.
3
+ Validator runner for ATDD.
4
4
 
5
- Replaces run_all_tests.sh with a more flexible Python-based test runner.
5
+ Executes validators from the installed atdd package against the current
6
+ consumer repository. Validators are discovered from the package's
7
+ planner/tester/coder/coach validator directories.
8
+
9
+ Usage:
10
+ atdd validate # Run all validators
11
+ atdd validate planner # Run planner validators only
12
+ atdd validate --quick # Quick smoke test
6
13
  """
7
14
 
8
15
  import subprocess
@@ -10,13 +17,26 @@ import sys
10
17
  from pathlib import Path
11
18
  from typing import List, Optional
12
19
 
20
+ import atdd
21
+ from atdd.coach.utils.repo import find_repo_root
22
+
23
+
24
+ def _xdist_available() -> bool:
25
+ """Check if pytest-xdist is installed."""
26
+ try:
27
+ import xdist # noqa: F401
28
+ return True
29
+ except ImportError:
30
+ return False
31
+
13
32
 
14
33
  class TestRunner:
15
- """Run ATDD meta-tests with various configurations."""
34
+ """Run ATDD validators with various configurations."""
16
35
 
17
36
  def __init__(self, repo_root: Path = None):
18
- self.repo_root = repo_root or Path.cwd()
19
- self.atdd_dir = self.repo_root / "atdd"
37
+ self.repo_root = repo_root or find_repo_root()
38
+ # Point to the installed atdd package validators, not a local atdd/ dir
39
+ self.atdd_pkg_dir = Path(atdd.__file__).resolve().parent
20
40
 
21
41
  def run_tests(
22
42
  self,
@@ -28,15 +48,15 @@ class TestRunner:
28
48
  parallel: bool = True,
29
49
  ) -> int:
30
50
  """
31
- Run ATDD tests with specified options.
51
+ Run ATDD validators with specified options.
32
52
 
33
53
  Args:
34
- phase: Test phase to run (planner, tester, coder, all, None=all)
54
+ phase: Validator phase to run (planner, tester, coder, coach, all, None=all)
35
55
  verbose: Enable verbose output
36
56
  coverage: Generate coverage report
37
57
  html_report: Generate HTML report
38
58
  markers: Additional pytest markers to filter
39
- parallel: Run tests in parallel (uses pytest-xdist)
59
+ parallel: Run validators in parallel (uses pytest-xdist if available)
40
60
 
41
61
  Returns:
42
62
  Exit code from pytest
@@ -44,16 +64,25 @@ class TestRunner:
44
64
  # Build pytest command
45
65
  cmd = ["pytest"]
46
66
 
47
- # Determine test path
67
+ # Determine test path from installed package
48
68
  if phase and phase != "all":
49
- test_path = self.atdd_dir / phase
69
+ test_path = self.atdd_pkg_dir / phase / "validators"
50
70
  if not test_path.exists():
51
71
  print(f"❌ Error: Test phase '{phase}' not found at {test_path}")
52
72
  return 1
53
73
  cmd.append(str(test_path))
54
74
  else:
55
- # Run all atdd tests
56
- cmd.append(str(self.atdd_dir))
75
+ # Run all validator tests from the package
76
+ # Include validators from all phases
77
+ validator_dirs = []
78
+ for subdir in ["planner", "tester", "coder", "coach"]:
79
+ validators_path = self.atdd_pkg_dir / subdir / "validators"
80
+ if validators_path.exists():
81
+ validator_dirs.append(str(validators_path))
82
+ if not validator_dirs:
83
+ print("❌ Error: No validator directories found in atdd package")
84
+ return 1
85
+ cmd.extend(validator_dirs)
57
86
 
58
87
  # Add verbosity
59
88
  if verbose:
@@ -66,46 +95,56 @@ class TestRunner:
66
95
  for marker in markers:
67
96
  cmd.extend(["-m", marker])
68
97
 
69
- # Add coverage
98
+ # Add coverage (coverage reports go to consumer repo's .atdd/ dir)
70
99
  if coverage:
100
+ htmlcov_path = self.repo_root / ".atdd" / "htmlcov"
71
101
  cmd.extend([
72
102
  "--cov=atdd",
73
103
  "--cov-report=term-missing",
74
- "--cov-report=html:atdd/htmlcov"
104
+ f"--cov-report=html:{htmlcov_path}"
75
105
  ])
76
106
 
77
- # Add HTML report
107
+ # Add HTML report (reports go to consumer repo's .atdd/ dir)
78
108
  if html_report:
109
+ report_path = self.repo_root / ".atdd" / "test_report.html"
79
110
  cmd.extend([
80
- "--html=atdd/test_report.html",
111
+ f"--html={report_path}",
81
112
  "--self-contained-html"
82
113
  ])
83
114
 
84
- # Add parallel execution
85
- if parallel:
115
+ # Add parallel execution (only if pytest-xdist is available)
116
+ if parallel and _xdist_available():
86
117
  cmd.extend(["-n", "auto"])
118
+ elif parallel and not _xdist_available():
119
+ print("⚠️ pytest-xdist not installed, running validators sequentially")
87
120
 
88
121
  # Show collected tests summary
89
122
  cmd.append("--tb=short")
90
123
 
91
- # Run pytest from current directory (consumer repo)
124
+ # Set up environment with repo root for validators
125
+ import os
126
+ env = os.environ.copy()
127
+ env["ATDD_REPO_ROOT"] = str(self.repo_root)
128
+
129
+ # Run pytest with consumer repo as cwd
92
130
  print(f"🧪 Running: {' '.join(cmd)}")
131
+ print(f"📁 Repo root: {self.repo_root}")
93
132
  print("=" * 60)
94
133
 
95
- result = subprocess.run(cmd)
134
+ result = subprocess.run(cmd, env=env, cwd=str(self.repo_root))
96
135
  return result.returncode
97
136
 
98
137
  def run_phase(self, phase: str, **kwargs) -> int:
99
- """Run tests for a specific phase."""
138
+ """Run validators for a specific phase."""
100
139
  return self.run_tests(phase=phase, **kwargs)
101
140
 
102
141
  def run_all(self, **kwargs) -> int:
103
- """Run all ATDD meta-tests."""
142
+ """Run all ATDD validators."""
104
143
  return self.run_tests(phase="all", **kwargs)
105
144
 
106
145
  def quick_check(self) -> int:
107
- """Quick smoke test - run without parallelization."""
108
- print("🚀 Running quick check (no parallel)...")
146
+ """Quick smoke validation - run without parallelization."""
147
+ print("🚀 Running quick validation (no parallel)...")
109
148
  return self.run_tests(
110
149
  phase="all",
111
150
  verbose=False,
@@ -114,8 +153,8 @@ class TestRunner:
114
153
  )
115
154
 
116
155
  def full_suite(self) -> int:
117
- """Full test suite with coverage and HTML report."""
118
- print("🎯 Running full test suite...")
156
+ """Full validation suite with coverage and HTML report."""
157
+ print("🎯 Running full validation suite...")
119
158
  return self.run_tests(
120
159
  phase="all",
121
160
  verbose=True,
@@ -126,7 +165,7 @@ class TestRunner:
126
165
 
127
166
 
128
167
  def main():
129
- """CLI entry point for test runner."""
168
+ """CLI entry point for validator runner."""
130
169
  runner = TestRunner()
131
170
 
132
171
  # Simple usage for now - can be enhanced with argparse
@@ -26,9 +26,11 @@ from typing import Dict, List, Optional, Tuple, Union
26
26
  from dataclasses import dataclass, field
27
27
  from collections import defaultdict
28
28
 
29
+ from atdd.coach.utils.repo import find_repo_root
30
+
29
31
 
30
32
  # Path constants
31
- REPO_ROOT = Path(__file__).resolve().parents[4]
33
+ REPO_ROOT = find_repo_root()
32
34
  PLAN_DIR = REPO_ROOT / "plan"
33
35
  CONTRACTS_DIR = REPO_ROOT / "contracts"
34
36
  TELEMETRY_DIR = REPO_ROOT / "telemetry"
@@ -43,7 +43,7 @@ workflow:
43
43
  - "atdd/planner/validators/test_wagon_urn_chain.py"
44
44
  - "atdd/planner/validators/test_wmbt_consistency.py"
45
45
  - "atdd/planner/validators/test_wmbt_vocabulary.py"
46
- gate_command: "python3 -m pytest atdd/planner/validators/ -v"
46
+ gate_command: "atdd validate planner"
47
47
  gate_expected: "PASS"
48
48
  completion_criteria:
49
49
  - "Train manifest exists and is valid"
@@ -73,7 +73,7 @@ workflow:
73
73
  - "atdd/tester/validators/test_acceptance_urn_filename_mapping.py"
74
74
  - "atdd/tester/validators/test_python_test_naming.py"
75
75
  - "atdd/tester/validators/test_typescript_test_naming.py"
76
- gate_command: "python3 -m pytest atdd/tester/validators/ -v"
76
+ gate_command: "atdd validate tester"
77
77
  gate_expected: "PASS"
78
78
  red_phase:
79
79
  description: "Write failing tests BEFORE any implementation"
@@ -104,7 +104,7 @@ workflow:
104
104
  - "atdd/coder/validators/test_typescript_architecture.py"
105
105
  - "atdd/coder/validators/test_import_boundaries.py"
106
106
  - "atdd/coder/validators/test_wagon_boundaries.py"
107
- gate_command: "python3 -m pytest atdd/coder/validators/ -v"
107
+ gate_command: "atdd validate coder"
108
108
  gate_expected: "PASS"
109
109
  green_phase:
110
110
  description: "Make tests pass with minimal implementation"
@@ -116,7 +116,7 @@ workflow:
116
116
  description: "Clean architecture, convention compliance"
117
117
  rule: "All coder validators must pass after GREEN"
118
118
  convention: "atdd/coder/conventions/refactor.convention.yaml"
119
- gate_command: "python3 -m pytest atdd/coder/validators/ -v"
119
+ gate_command: "atdd validate coder"
120
120
  gate_expected: "PASS"
121
121
  completion_criteria:
122
122
  - "All acceptance tests pass"
@@ -289,7 +289,7 @@ archetypes:
289
289
  - "Application: Use cases, orchestration"
290
290
  - "Integration: Adapters, clients, repositories"
291
291
  - "Presentation: Controllers, DTOs"
292
- validation: "python3 -m pytest atdd/coder/validators/test_python_architecture.py -v"
292
+ validation: "atdd validate coder"
293
293
 
294
294
  frontend:
295
295
  id: "fe"
@@ -315,7 +315,7 @@ archetypes:
315
315
  - "Schema-first design"
316
316
  - "Version in filename if breaking changes"
317
317
  - "Shared via contracts/ directory"
318
- validation: "python3 -m pytest atdd/tester/validators/test_contract_*.py -v"
318
+ validation: "atdd validate tester"
319
319
 
320
320
  wmbt:
321
321
  id: "wmbt"
@@ -326,7 +326,7 @@ archetypes:
326
326
  - "URN: wmbt:{wagon}:{STEP_CODE}{NNN}"
327
327
  - "Step codes: D=define, L=locate, P=prepare, C=confirm, E=execute, M=monitor, Y=modify, R=resolve, K=conclude"
328
328
  - "Max 5 acceptances per WMBT"
329
- validation: "python3 -m pytest atdd/planner/validators/test_wmbt_*.py -v"
329
+ validation: "atdd validate planner"
330
330
 
331
331
  wagon:
332
332
  id: "wagon"
@@ -338,7 +338,7 @@ archetypes:
338
338
  - "Manifest: plan/{wagon}/_{wagon}.yaml"
339
339
  - "Features: plan/{wagon}/features/{feature}.yaml"
340
340
  - "Registered in plan/_wagons.yaml"
341
- validation: "python3 -m pytest atdd/planner/validators/test_wagon_*.py -v"
341
+ validation: "atdd validate planner"
342
342
 
343
343
  train:
344
344
  id: "train"
@@ -348,7 +348,7 @@ archetypes:
348
348
  patterns:
349
349
  - "Train = release with multiple wagons"
350
350
  - "Defines deployment order and dependencies"
351
- validation: "python3 -m pytest atdd/planner/validators/test_train_*.py -v"
351
+ validation: "atdd validate planner"
352
352
 
353
353
  telemetry:
354
354
  id: "telemetry"
@@ -360,7 +360,7 @@ archetypes:
360
360
  - "Metrics: telemetry:metric:{layer}:{wagon}:{name}"
361
361
  - "Logs: Structured with URN attributes"
362
362
  - "Traces: Span context propagation"
363
- validation: "python3 -m pytest atdd/tester/validators/test_telemetry_*.py -v"
363
+ validation: "atdd validate tester"
364
364
 
365
365
  migrations:
366
366
  id: "migrations"
@@ -503,7 +503,7 @@ sections:
503
503
  gate: "pytest {test-path} -v (expect PASS)"
504
504
  REFACTOR:
505
505
  description: "Clean architecture, 4-layer compliance"
506
- gate: "pytest atdd/coder/validators/ -v"
506
+ gate: "atdd validate coder"
507
507
 
508
508
  validation:
509
509
  required: true
@@ -645,47 +645,47 @@ gate_tests:
645
645
  db:
646
646
  - command: "supabase db push --dry-run"
647
647
  atdd_validator: "manual"
648
- - command: "python3 -m pytest atdd/tester/validators/test_migration_*.py -v"
648
+ - command: "atdd validate tester"
649
649
  atdd_validator: "atdd/tester/validators/test_migration_coverage.py"
650
650
 
651
651
  be:
652
- - command: "python3 -m pytest atdd/coder/validators/test_python_architecture.py -v"
652
+ - command: "atdd validate coder"
653
653
  atdd_validator: "atdd/coder/validators/test_python_architecture.py"
654
- - command: "python3 -m pytest atdd/coder/validators/test_import_boundaries.py -v"
654
+ - command: "atdd validate coder"
655
655
  atdd_validator: "atdd/coder/validators/test_import_boundaries.py"
656
656
 
657
657
  fe:
658
658
  - command: "cd web && npm run typecheck"
659
659
  atdd_validator: "manual"
660
- - command: "python3 -m pytest atdd/coder/validators/test_typescript_architecture.py -v"
660
+ - command: "atdd validate coder"
661
661
  atdd_validator: "atdd/coder/validators/test_typescript_architecture.py"
662
662
 
663
663
  contracts:
664
- - command: "python3 -m pytest atdd/tester/validators/test_contract_*.py -v"
664
+ - command: "atdd validate tester"
665
665
  atdd_validator: "atdd/tester/validators/test_contract_schema_compliance.py"
666
666
 
667
667
  wmbt:
668
- - command: "python3 -m pytest atdd/planner/validators/test_wmbt_*.py -v"
668
+ - command: "atdd validate planner"
669
669
  atdd_validator: "atdd/planner/validators/test_wmbt_consistency.py"
670
670
 
671
671
  wagon:
672
- - command: "python3 -m pytest atdd/planner/validators/test_wagon_*.py -v"
672
+ - command: "atdd validate planner"
673
673
  atdd_validator: "atdd/planner/validators/test_wagon_urn_chain.py"
674
- - command: "python3 -m pytest atdd/coder/validators/test_wagon_boundaries.py -v"
674
+ - command: "atdd validate coder"
675
675
  atdd_validator: "atdd/coder/validators/test_wagon_boundaries.py"
676
676
 
677
677
  train:
678
- - command: "python3 -m pytest atdd/planner/validators/test_train_*.py -v"
678
+ - command: "atdd validate planner"
679
679
  atdd_validator: "atdd/planner/validators/test_train_validation.py"
680
680
 
681
681
  telemetry:
682
- - command: "python3 -m pytest atdd/tester/validators/test_telemetry_*.py -v"
682
+ - command: "atdd validate tester"
683
683
  atdd_validator: "atdd/tester/validators/test_telemetry_structure.py"
684
684
 
685
685
  migrations:
686
686
  - command: "supabase db push --dry-run"
687
687
  atdd_validator: "manual"
688
- - command: "python3 -m pytest atdd/tester/validators/test_migration_*.py -v"
688
+ - command: "atdd validate tester"
689
689
  atdd_validator: "atdd/tester/validators/test_migration_coverage.py"
690
690
 
691
691
  # Universal gates (all sessions)
@@ -694,7 +694,7 @@ gate_tests:
694
694
  - id: "GT-001"
695
695
  phase: "design"
696
696
  archetype: "all"
697
- command: "python3 -m pytest atdd/coach/validators/test_session_validation.py -v"
697
+ command: "atdd validate coach"
698
698
  expected: "PASS"
699
699
  atdd_validator: "atdd/coach/validators/test_session_validation.py"
700
700
  description: "Session structure compliance"
@@ -703,7 +703,7 @@ gate_tests:
703
703
  - id: "GT-900"
704
704
  phase: "completion"
705
705
  archetype: "all"
706
- command: "python3 -m pytest atdd/ -v --tb=short"
706
+ command: "atdd validate"
707
707
  expected: "PASS"
708
708
  atdd_validator: "atdd/"
709
709
  description: "Full ATDD validator suite"
@@ -735,14 +735,14 @@ gate_tests:
735
735
  gates:
736
736
  - id: "GT-300"
737
737
  phase: "implementation"
738
- command: "python3 -m pytest atdd/coder/validators/ -v"
738
+ command: "atdd validate coder"
739
739
  expected: "PASS"
740
740
  atdd_validator: "atdd/coder/validators/"
741
741
  description: "Architecture conventions met"
742
742
 
743
743
  # Validation
744
744
  validation:
745
- command: "python3 -m pytest atdd/coach/validators/test_session_*.py -v"
745
+ command: "atdd validate coach"
746
746
  checks:
747
747
  - "All required sections present"
748
748
  - "Status is valid value"
@@ -85,30 +85,30 @@ dev_servers:
85
85
  # Audits & Validation (Give context, pinpoint issues, validate compliance)
86
86
  audits:
87
87
  cli: "atdd"
88
- purpose: "Meta-tests that validate ATDD artifacts against conventions"
88
+ purpose: "Validators that check ATDD artifacts against conventions"
89
89
 
90
90
  commands:
91
- inventory: "atdd --inventory"
92
- status: "atdd --status"
93
- quick_check: "atdd --quick"
94
- validate_all: "atdd --test all"
95
- validate_planner: "atdd --test planner"
96
- validate_tester: "atdd --test tester"
97
- validate_coder: "atdd --test coder"
98
- with_coverage: "atdd --test all --coverage"
99
- with_html: "atdd --test all --html"
91
+ validate_all: "atdd validate"
92
+ validate_planner: "atdd validate planner"
93
+ validate_tester: "atdd validate tester"
94
+ validate_coder: "atdd validate coder"
95
+ quick_check: "atdd validate --quick"
96
+ with_coverage: "atdd validate --coverage"
97
+ with_html: "atdd validate --html"
98
+ inventory: "atdd inventory"
99
+ status: "atdd status"
100
100
 
101
101
  workflow:
102
- before_init: "Run planner audits to validate plan structure"
102
+ before_init: "Run planner validators to check plan structure"
103
103
  after_init: "Validate wagon URNs, cross-refs, uniqueness"
104
- before_planned: "Run tester audits to validate test prerequisites"
104
+ before_planned: "Run tester validators to check test prerequisites"
105
105
  after_planned: "Validate test naming, contracts, coverage"
106
106
  before_red: "Validate layer structure expectations"
107
107
  after_red: "Validate tests are RED and properly structured"
108
- before_green: "Run coder audits for architecture readiness"
108
+ before_green: "Run coder validators for architecture readiness"
109
109
  after_green: "Validate layer dependencies, boundaries"
110
110
  after_refactor: "Validate architecture compliance, quality metrics"
111
- continuous: "CI runs 'atdd --test all' on every commit"
111
+ continuous: "CI runs 'atdd validate' on every commit"
112
112
 
113
113
  audit_scope:
114
114
  planner: "src/atdd/planner/validators/*.py (wagons, trains, URNs, cross-refs, WMBT)"
@@ -291,7 +291,7 @@ sessions:
291
291
  create: "Run 'atdd session new <slug>' to create new session from template"
292
292
  fill: "Fill ALL sections - write 'N/A' if not applicable, never omit"
293
293
  track: "Update Progress Tracker and Session Log after each work item"
294
- validate: "python3 -m pytest src/atdd/coach/validators/test_session_*.py -v"
294
+ validate: "atdd validate coach"
295
295
 
296
296
  archetypes:
297
297
  db: "Supabase PostgreSQL + JSONB"
@@ -42,7 +42,7 @@ workflow_phases:
42
42
  wagon: false # plan/{wagon}/_{wagon}.yaml exists
43
43
  feature: false # plan/{wagon}/features/{feature}.yaml exists
44
44
  wmbt: false # WMBTs defined in feature YAML
45
- gate: "python3 -m pytest src/src/atdd/planner/validators/ -v"
45
+ gate: "atdd validate planner"
46
46
  gate_status: "TODO"
47
47
 
48
48
  tester:
@@ -51,7 +51,7 @@ workflow_phases:
51
51
  artifacts:
52
52
  contracts: false # contracts/{domain}/{resource}.schema.json exists
53
53
  red_tests: false # Failing tests exist for all WMBTs
54
- gate: "python3 -m pytest src/src/atdd/tester/validators/ -v"
54
+ gate: "atdd validate tester"
55
55
  gate_status: "TODO"
56
56
  red_gate: "pytest {test_path} -v (expect FAIL)"
57
57
  red_gate_status: "TODO"
@@ -61,11 +61,11 @@ workflow_phases:
61
61
  depends_on: "tester"
62
62
  artifacts:
63
63
  implementation: false # Code exists in {runtime}/{wagon}/{feature}/src/
64
- gate: "python3 -m pytest src/atdd/coder/validators/ -v"
64
+ gate: "atdd validate coder"
65
65
  gate_status: "TODO"
66
66
  green_gate: "pytest {test_path} -v (expect PASS)"
67
67
  green_gate_status: "TODO"
68
- refactor_gate: "python3 -m pytest src/atdd/coder/validators/ -v"
68
+ refactor_gate: "atdd validate coder"
69
69
  refactor_gate_status: "TODO"
70
70
 
71
71
  # Progress tracking (machine-readable)
@@ -103,7 +103,7 @@ progress:
103
103
  gate: "pytest {test-path} -v (expect PASS)"
104
104
  refactor:
105
105
  status: "TODO"
106
- gate: "pytest src/atdd/coder/validators/ -v"
106
+ gate: "atdd validate coder"
107
107
 
108
108
  # Gate Tests - Required validation gates with ATDD validators
109
109
  # See: src/atdd/coach/conventions/session.convention.yaml for required gates per archetype
@@ -112,7 +112,7 @@ gate_tests:
112
112
  - id: "GT-001"
113
113
  phase: "design"
114
114
  archetype: "all"
115
- command: "python3 -m pytest src/atdd/coach/validators/test_session_validation.py -v"
115
+ command: "atdd validate coach"
116
116
  expected: "PASS"
117
117
  atdd_validator: "src/atdd/coach/validators/test_session_validation.py"
118
118
  status: "TODO"
@@ -122,7 +122,7 @@ gate_tests:
122
122
  # - id: "GT-010"
123
123
  # phase: "implementation"
124
124
  # archetype: "be"
125
- # command: "python3 -m pytest src/atdd/coder/validators/test_python_architecture.py -v"
125
+ # command: "atdd validate coder"
126
126
  # expected: "PASS"
127
127
  # atdd_validator: "src/atdd/coder/validators/test_python_architecture.py"
128
128
  # status: "TODO"
@@ -131,7 +131,7 @@ gate_tests:
131
131
  # - id: "GT-020"
132
132
  # phase: "implementation"
133
133
  # archetype: "fe"
134
- # command: "python3 -m pytest src/atdd/coder/validators/test_typescript_architecture.py -v"
134
+ # command: "atdd validate coder"
135
135
  # expected: "PASS"
136
136
  # atdd_validator: "src/atdd/coder/validators/test_typescript_architecture.py"
137
137
  # status: "TODO"
@@ -140,7 +140,7 @@ gate_tests:
140
140
  - id: "GT-900"
141
141
  phase: "completion"
142
142
  archetype: "all"
143
- command: "python3 -m pytest src/atdd/ -v --tb=short"
143
+ command: "atdd validate"
144
144
  expected: "PASS"
145
145
  atdd_validator: "src/atdd/"
146
146
  status: "TODO"
@@ -180,7 +180,7 @@ IMPLEMENTATION RULES:
180
180
  3. New files MUST match patterns of similar existing files
181
181
  4. When in doubt: find 2-3 similar files and replicate their structure
182
182
  5. NEVER introduce new patterns without explicit decision documented
183
- 6. Validate: python3 -m pytest src/atdd/ -v --tb=short
183
+ 6. Validate: atdd validate
184
184
  -->
185
185
 
186
186
  # SESSION-{NN}: {Title}
@@ -288,9 +288,9 @@ Reference: src/atdd/coach/conventions/session.convention.yaml
288
288
 
289
289
  | ID | Phase | Archetype | Command | Expected | ATDD Validator | Status |
290
290
  |----|-------|-----------|---------|----------|----------------|--------|
291
- | GT-001 | design | all | `python3 -m pytest src/atdd/coach/validators/test_session_validation.py -v` | PASS | `src/atdd/coach/validators/test_session_validation.py` | TODO |
291
+ | GT-001 | design | all | `atdd validate coach` | PASS | `src/atdd/coach/validators/test_session_validation.py` | TODO |
292
292
  | GT-010 | implementation | {archetype} | `{command}` | PASS | `{atdd_validator_path}` | TODO |
293
- | GT-900 | completion | all | `python3 -m pytest src/atdd/ -v --tb=short` | PASS | `src/atdd/` | TODO |
293
+ | GT-900 | completion | all | `atdd validate` | PASS | `src/atdd/` | TODO |
294
294
 
295
295
  ### Phase Gates
296
296
 
atdd/coach/utils/repo.py CHANGED
@@ -2,14 +2,19 @@
2
2
  Repository root detection utility.
3
3
 
4
4
  Finds the consumer repository root using multiple detection strategies:
5
- 1. .atdd/manifest.yaml (preferred - explicit ATDD project marker)
6
- 2. plan/ AND contracts/ both exist (ATDD project structure)
7
- 3. .git/ directory (fallback - any git repo)
8
- 4. cwd (last resort - allows commands to work on uninitialized repos)
5
+ 1. ATDD_REPO_ROOT env var (set by test runner for validators)
6
+ 2. .atdd/manifest.yaml (preferred - explicit ATDD project marker)
7
+ 3. plan/ AND contracts/ both exist (ATDD project structure)
8
+ 4. .git/ directory (fallback - any git repo)
9
+ 5. cwd (last resort - allows commands to work on uninitialized repos)
9
10
 
10
11
  This ensures ATDD commands operate on the user's repo, not the package root.
12
+
13
+ For validators running from the installed package, the test runner sets
14
+ ATDD_REPO_ROOT to point to the consumer repo being validated.
11
15
  """
12
16
 
17
+ import os
13
18
  from functools import lru_cache
14
19
  from pathlib import Path
15
20
  from typing import Optional
@@ -21,10 +26,11 @@ def find_repo_root(start: Optional[Path] = None) -> Path:
21
26
  Find repo root by searching upward for ATDD project markers.
22
27
 
23
28
  Detection order (first match wins):
24
- 1. .atdd/manifest.yaml - explicit ATDD project marker
25
- 2. plan/ AND contracts/ both exist - ATDD project structure
26
- 3. .git/ directory - fallback for any git repository
27
- 4. cwd - last resort if no markers found
29
+ 1. ATDD_REPO_ROOT env var - set by test runner for validators
30
+ 2. .atdd/manifest.yaml - explicit ATDD project marker
31
+ 3. plan/ AND contracts/ both exist - ATDD project structure
32
+ 4. .git/ directory - fallback for any git repository
33
+ 5. cwd - last resort if no markers found
28
34
 
29
35
  Args:
30
36
  start: Starting directory (default: cwd)
@@ -35,7 +41,17 @@ def find_repo_root(start: Optional[Path] = None) -> Path:
35
41
  Note:
36
42
  Results are cached for performance. If .atdd/manifest.yaml is not found,
37
43
  commands may operate in a degraded mode.
44
+
45
+ For validators running from installed package, ATDD_REPO_ROOT env var
46
+ is set by the test runner to point to the consumer repo.
38
47
  """
48
+ # Strategy 0: Check ATDD_REPO_ROOT env var (set by test runner)
49
+ env_root = os.environ.get("ATDD_REPO_ROOT")
50
+ if env_root:
51
+ env_path = Path(env_root).resolve()
52
+ if env_path.is_dir():
53
+ return env_path
54
+
39
55
  current = start or Path.cwd()
40
56
  current = current.resolve()
41
57