Skip to content

feat(#285): TDD enforcement — Iron Law, reviewers, Monitor gate, tdd.enforce config#337

Merged
azalio merged 1 commit into
mainfrom
claude/compassionate-cerf-5tugql
Jul 5, 2026
Merged

feat(#285): TDD enforcement — Iron Law, reviewers, Monitor gate, tdd.enforce config#337
azalio merged 1 commit into
mainfrom
claude/compassionate-cerf-5tugql

Conversation

@azalio

@azalio azalio commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #285.

Adds Superpowers-style mandatory TDD enforcement controlled by a tdd.enforce: true flag in .map/config.yaml.

Changes

MapConfig — config flag

  • New tdd_enforce: bool = False field with dotted YAML alias tdd.enforce wired into load_map_config
  • Defaults to False so existing workflows are unaffected

map-tdd SKILL.md — enforcement upgrade

  • The Iron Law: NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST — deletion, not refactoring, for code written before a failing test
  • RED-GREEN-REFACTOR mandatory cycle: each phase documented with explicit verification requirements; RED phase cannot be skipped
  • 14-item Red Flags list for self-detection (e.g. "This is different because...", "Just this once")
  • 11-item Rationalization Table with counters (sunk cost fallacy, "too simple to test", deadline pressure, etc.)
  • Config check in Step 0: reads tdd.enforce from .map/config.yaml and activates Iron Law enforcement
  • Spec Compliance Reviewer (adversarial subagent): adversarial framing ("the implementer finished suspiciously quickly — do NOT trust the summary"), checks every requirement with file:line evidence, uses SPEC-COMPLIANT: YES/NO verdict
  • Code Quality Reviewer (separate subagent): checks file responsibility, unit decomposition, plan conformance, size discipline, error handling, type safety — runs only AFTER spec reviewer passes
  • Sequential gate: spec compliance MUST pass before code quality review starts; running in parallel bypasses the gate

monitor.md — TDD violation detection gate

  • New TDD Violation Detection section that applies when tdd.enforce: true
  • Criteria: code before test, trivially-passing tests, no new test for new behavior
  • Rationalization detection patterns: flags "tests written simultaneously", "I added tests after", etc.
  • JSON output schema with tdd_check block and tdd_violation verdict
  • Verdict tdd_violation sets valid: false; directs deletion + restart, not "just add tests"

Tests (17 new tests)

  • TestVc7TddEnforce (6 tests): default False, YAML alias loads true/false, alias dead-toggle guard, field existence
  • TestVc8TddTemplateContent (11 tests): Iron Law text, RED-GREEN-REFACTOR, rationalization table, Red Flags, spec/code reviewers, sequential gate, tdd.enforce reference, Monitor violation section, tdd_violation verdict, rationalization detection
  • map-tdd body budget bumped to 545 in HIGH_TRAFFIC_SKILL_BODY_BUDGETS (irreducible enforcement control flow)

All changes go through the templates_srcmake render-templates single-source pipeline. make check passes: 3444 passed, 4 skipped, 0 failures.


Generated by Claude Code

…enforce config

Adds Superpowers-style mandatory TDD enforcement when tdd.enforce: true in
.map/config.yaml:

- MapConfig.tdd_enforce field with tdd.enforce YAML alias (dead-toggle guard)
- map-tdd SKILL.md: Iron Law ("NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST"),
  RED-GREEN-REFACTOR mandatory cycle, 14-item Red Flags list, 11-item
  Rationalization Table with counters, tdd.enforce config check in Step 0
- map-tdd SKILL.md: Spec Compliance Reviewer (adversarial, SPEC-COMPLIANT verdict)
  and Code Quality Reviewer (sequential gate: spec passes before code review starts)
- monitor.md: TDD Violation Detection section with tdd_violation verdict, criteria
  for detecting code-before-test, rationalization detection patterns, JSON output schema
- Tests: VC7 (6 tests for tdd_enforce field/alias), VC8 (11 tests for template content)
- map-tdd body budget bumped to 545 (irreducible enforcement control flow)
- All changes go through templates_src → make render-templates pipeline

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HZ3wHDow49xBGUwWFPH2mD
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@azalio, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 76d3137b-61ae-4751-9690-31a1b69380d3

📥 Commits

Reviewing files that changed from the base of the PR and between 5d448b0 and 9a997fd.

📒 Files selected for processing (9)
  • .claude/agents/monitor.md
  • .claude/skills/map-tdd/SKILL.md
  • src/mapify_cli/config/project_config.py
  • src/mapify_cli/templates/agents/monitor.md
  • src/mapify_cli/templates/skills/map-tdd/SKILL.md
  • src/mapify_cli/templates_src/agents/monitor.md.jinja
  • src/mapify_cli/templates_src/skills/map-tdd/SKILL.md.jinja
  • tests/test_project_config.py
  • tests/test_skills.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/compassionate-cerf-5tugql

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@azalio azalio merged commit 51afd96 into main Jul 5, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Superpowers-style TDD enforcement: delete code written before test, adversarial spec compliance

2 participants