Patterns and Anti-Patterns
This guide defines recommended patterns and anti-patterns for working with RTMX. Following these patterns ensures requirements remain traceable, verifiable, and trustworthy.
Core Principle: Closed-Loop Verification
Section titled “Core Principle: Closed-Loop Verification”RTMX is built on a fundamental principle: requirement status must be derived from evidence, not opinion.
┌─────────────────────────────────────────────────────────────────┐│ CLOSED-LOOP VERIFICATION ││ ││ Requirements ──→ Tests ──→ Execution ──→ Status Update ││ ↑ │ ││ └────────────────────────────────────────┘ ││ ││ Status reflects reality. Tests are the arbiter of truth. │└─────────────────────────────────────────────────────────────────┘Verification Patterns
Section titled “Verification Patterns”Pattern: Automated Status Updates
Section titled “Pattern: Automated Status Updates”Use rtmx verify --update to derive status from test results.
# In CI/CD pipelinertmx verify --update
# Local development (dry-run first)rtmx verify --dry-runrtmx verify --updateThe verify command:
- Runs all tests with
@pytest.mark.req()markers - Maps test outcomes to requirements
- Updates status based on pass/fail results
| Test Result | Status Transition |
|---|---|
| All pass | → COMPLETE |
| Some pass, none fail | → PARTIAL |
| Any fail | COMPLETE → PARTIAL (regression) |
| No tests | Status unchanged |
Why this matters: Status reflects what the code actually does, not what someone hopes it does.
Anti-Pattern: Manual Status Edits
Section titled “Anti-Pattern: Manual Status Edits”Never manually edit the status field in the RTM database.
# WRONG: Agent or human manually sets statusREQ-AUTH-001,AUTH,Login,User can log in,COMPLETE,...
# RIGHT: Let rtmx verify determine status from testsrtmx verify --updateSymptoms of this anti-pattern:
- Status says COMPLETE but tests fail
- No test coverage for “complete” requirements
- Status changes without corresponding code changes
- Requirements marked complete before implementation
Why it’s harmful: Manual status updates break the feedback loop. The RTM becomes a wish list instead of a verification record.
Pattern: Test-Linked Requirements
Section titled “Pattern: Test-Linked Requirements”Every requirement should have at least one test with @pytest.mark.req().
@pytest.mark.req("REQ-AUTH-001")@pytest.mark.scope_unit@pytest.mark.technique_nominal@pytest.mark.env_simulationdef test_user_can_login(): """Verify REQ-AUTH-001: User can log in.""" user = create_test_user() result = login(user.email, user.password) assert result.success assert result.session_token is not NoneSync test metadata to RTM:
rtmx from-tests --updateThis populates test_module and test_function columns, creating bidirectional traceability.
Anti-Pattern: Orphan Tests
Section titled “Anti-Pattern: Orphan Tests”Tests without requirement markers are untraceable.
# WRONG: No requirement linkagedef test_login_works(): assert login("user", "pass").success
# RIGHT: Linked to requirement@pytest.mark.req("REQ-AUTH-001")def test_login_works(): assert login("user", "pass").successWhy it’s harmful: Orphan tests provide no evidence for requirement completion. They may test important functionality, but that functionality isn’t tracked in the RTM.
Detection:
rtmx from-tests --missing # Shows tests not linked to RTM requirementsDevelopment Workflow Patterns
Section titled “Development Workflow Patterns”Pattern: Spec-First Development
Section titled “Pattern: Spec-First Development”Write the requirement specification before writing code.
1. Define requirement in RTM database2. Create specification file (docs/requirements/CATEGORY/REQ-XXX.md)3. Write acceptance criteria4. Write failing tests5. Implement to pass tests6. Run rtmx verify --updateSpecification template:
# REQ-XXX-NNN: Requirement Title
## DescriptionClear statement of what the system shall do.
## Acceptance Criteria- [ ] Criterion 1- [ ] Criterion 2- [ ] Criterion 3
## Test Cases1. Nominal case2. Edge case3. Error caseAnti-Pattern: Code-First, Spec-Never
Section titled “Anti-Pattern: Code-First, Spec-Never”Writing code without defining requirements creates untraceable features.
# WRONG workflow1. Write code2. Maybe write tests3. Never create requirement4. Feature exists but isn't tracked
# RIGHT workflow1. Define requirement2. Write spec3. Write failing test4. Write code5. VerifyWhy it’s harmful: Features without requirements can’t be verified, prioritized, or traced. When asked “what does the system do?”, the answer becomes “read the code.”
Pattern: Phase Gates in CI
Section titled “Pattern: Phase Gates in CI”Block releases until phase requirements are verified.
# .github/workflows/release.yml- name: Verify Phase Requirements run: | rtmx verify --update rtmx status --json | jq -e '.phases["1"].complete == true'Phase progression:
Phase 1: Core functionality (must be COMPLETE to release v0.1)Phase 2: Extended features (must be COMPLETE to release v0.2)Phase 3: Polish and optimization (must be COMPLETE to release v1.0)Anti-Pattern: Phase as Suggestion
Section titled “Anti-Pattern: Phase as Suggestion”Treating phases as optional guidance rather than gates.
# WRONG: Ignore phase gatesgit tag v1.0.0 # Released with Phase 1 incomplete
# RIGHT: Enforce phase completionrtmx status --phase 1 # Verify 100% before releaseWhy it’s harmful: Releasing with incomplete phases means shipping unverified functionality. Phases exist to ensure quality gates.
Agent Integration Patterns
Section titled “Agent Integration Patterns”Pattern: Agent as Implementer, RTMX as Verifier
Section titled “Pattern: Agent as Implementer, RTMX as Verifier”Agents write code. rtmx verify determines completion.
Agent Workflow:1. Read requirement spec: docs/requirements/CATEGORY/REQ-XXX.md2. Read existing tests3. Implement code to pass tests4. Run: rtmx verify --dry-run5. If passing: rtmx verify --update6. Commit changesAgent prompt guidance:
When implementing requirements:- Never manually edit the status field in rtm_database.csv- Always run `rtmx verify --update` after implementation- Status is determined by test results, not by completion claimsAnti-Pattern: Agent Status Claims
Section titled “Anti-Pattern: Agent Status Claims”Agents claiming completion without verification.
# WRONG: Agent edits CSV directlydb = RTMDatabase.load("docs/rtm_database.csv")db.update("REQ-AUTH-001", status=Status.COMPLETE) # Opinion-baseddb.save()
# RIGHT: Agent runs verificationsubprocess.run(["rtmx", "verify", "--update"]) # Evidence-basedWhy it’s harmful: Agent opinions about completion are unreliable. Tests may not exist, may fail, or may not cover the requirement. Only rtmx verify provides evidence-based status.
Pattern: RTM as Development Contract
Section titled “Pattern: RTM as Development Contract”Agents should read the RTM to understand what to build.
# Agent discovers next taskrtmx backlog --phase 2 --limit 1
# Agent reads specificationcat docs/requirements/CATEGORY/REQ-XXX.md
# Agent checks dependenciesrtmx deps --req REQ-XXX
# Agent implements, then verifiesrtmx verify --updateThe RTM provides:
- What to build (requirement text)
- How to verify (linked tests)
- What’s blocking (dependencies)
- Priority order (phase, priority)
Anti-Pattern: Ignoring Dependencies
Section titled “Anti-Pattern: Ignoring Dependencies”Implementing requirements before their dependencies are complete.
# WRONG: Ignore blockedByrtmx backlog # Shows REQ-B blocked by REQ-A# Agent implements REQ-B anyway
# RIGHT: Respect dependenciesrtmx deps --req REQ-B # Check what blocks this# Implement REQ-A first, then REQ-BWhy it’s harmful: Implementing blocked requirements often requires rework when the blocking requirement is completed. Dependencies exist for a reason.
Continuous Integration Patterns
Section titled “Continuous Integration Patterns”Pattern: Verify on Every PR
Section titled “Pattern: Verify on Every PR”Run rtmx verify in CI to catch regressions.
# .github/workflows/ci.ymljobs: verify: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install RTMX run: pip install rtmx - name: Verify Requirements run: rtmx verify --update - name: Check for Regressions run: | git diff --exit-code docs/rtm_database.csv || \ echo "::warning::RTM status changed - review before merging"Pattern: RTM Diff in PRs
Section titled “Pattern: RTM Diff in PRs”Show requirement status changes in pull requests.
- name: RTM Diff run: | git fetch origin main rtmx diff origin/main HEAD --format markdown >> $GITHUB_STEP_SUMMARYThis surfaces:
- New requirements added
- Requirements completed
- Regressions (COMPLETE → PARTIAL)
Quick Reference
Section titled “Quick Reference”Commands for Closed-Loop Verification
Section titled “Commands for Closed-Loop Verification”| Command | Purpose | When to Use |
|---|---|---|
rtmx verify --dry-run | Preview status changes | Before updating |
rtmx verify --update | Update status from tests | After implementation |
rtmx from-tests --update | Sync test metadata | After adding tests |
rtmx health | Validate RTM integrity | Before releases |
Status Sources
Section titled “Status Sources”| Status Source | Trustworthy? | Notes |
|---|---|---|
rtmx verify --update | Yes | Evidence-based |
| Manual CSV edit | No | Opinion-based |
| Agent claim | No | Unverified |
| CI pipeline | Yes | Automated verification |
Verification Checklist
Section titled “Verification Checklist”Before claiming a requirement is complete:
- Test exists with
@pytest.mark.req("REQ-XXX") - Test passes locally
-
rtmx verify --updateshows COMPLETE - CI pipeline passes
- Specification acceptance criteria met
Summary
Section titled “Summary”| Do This (Pattern) | Not This (Anti-Pattern) |
|---|---|
rtmx verify --update | Manual status edits |
@pytest.mark.req() on all tests | Orphan tests |
| Spec-first development | Code-first, spec-never |
| Phase gates in CI | Phase as suggestion |
| Agent implements, RTMX verifies | Agent claims completion |
| Respect dependencies | Ignore blockedBy |
Remember: The RTM is a verification record, not a wish list. Status must be earned through passing tests, not claimed through manual edits.