Skip to content

[Phase 5] PROOF9: Quality Memory System with Evidence-Based Verification #422

Description

@frankbria

Summary

Implement PROOF9 — a quality memory system that turns every failure into a permanent proof obligation with evidence-based verification. Unlike traditional test runners, PROOF9 maintains a requirements ledger where glitches become codified requirements, each with specific proof obligations that are enforced on every subsequent run.

The Core Idea

Quality compounding interest: Every bug found in production, QA, or dogfooding becomes a REQ (requirement) with attached proof obligations. Those obligations are enforced forever. Over time, the system becomes harder to break in ways you've already been burned.

This is the "AFTER" layer in CodeFrame's pipeline:

PRD → Tech Spec → Tasks → Agent Execution → PROOF9 → Deploy
                                                ↑         │
                                                └─────────┘
                                           Glitch → New REQ
                                           (the closed loop)

The 9 Gates

Gate What It Proves Tool/Method
UNIT Logic correctness pytest / jest
CONTRACT API/integration contracts hold Schema validation, contract tests
E2E User journeys work end-to-end Playwright
VISUAL UI renders correctly Visual snapshot comparison
A11Y Accessible to all users axe-core, lighthouse
PERF Performance within budget Lighthouse, custom benchmarks
SEC No security vulnerabilities OWASP scans, dependency audit
DEMO Feature demonstrably works Automated walkthrough with screenshots
MANUAL Human-verified (waivered automation) Tracked checklist with expiry

The Requirements Ledger

REQ Schema v0

Each requirement has:

@dataclass
class Requirement:
    id: str                          # REQ-0001
    title: str                       # "Login form rejects empty password"
    description: str                 # What happened, expected vs actual
    severity: Severity               # critical, high, medium, low
    source: Source                    # production, qa, dogfooding, monitoring, user_report
    
    # Scope selector — what does this REQ apply to?
    scope: RequirementScope
    #   routes: ["/login", "/register"]
    #   components: ["LoginForm"]
    #   apis: ["POST /auth/login"]
    #   files: ["src/auth/validator.py"]
    #   tags: ["authentication"]
    
    # Proof obligations — which gates must prove this can't happen again?
    obligations: list[Obligation]
    #   e.g., [UNIT, E2E] for a logic + flow bug
    
    # Evidence rules — what counts as satisfied?
    evidence_rules: list[EvidenceRule]
    #   e.g., test_id="test_login_rejects_empty", must_pass=True
    
    # Lifecycle
    status: ReqStatus               # open, satisfied, waived
    waiver: Waiver | None           # reason, expiry, manual_checklist
    created_at: datetime
    satisfied_at: datetime | None
    
    # Traceability
    created_by: str                 # human or capture agent
    source_issue: str | None        # GitHub issue / bug report link
    related_reqs: list[str]         # REQ IDs this relates to

Obligation Mapping (Glitch Type → Gate Set)

OBLIGATION_MAP = {
    "logic_bug":       [Gate.UNIT, Gate.CONTRACT],
    "integration_bug": [Gate.CONTRACT, Gate.E2E],
    "ui_wiring_bug":   [Gate.E2E, Gate.DEMO],
    "ui_layout_bug":   [Gate.VISUAL, Gate.E2E],
    "a11y_bug":        [Gate.A11Y, Gate.E2E],
    "perf_regression": [Gate.PERF, Gate.E2E],
    "security_issue":  [Gate.SEC],
}

Rule: add the smallest set of obligations that would have caught it. Minimize gate bloat.

The Closed Loop

Capture Flow

Detect glitch → cf proof capture → REQ created → Obligations attached → Artifacts generated

cf proof capture input (minimal, human-friendly):

  • What happened? (1-3 sentences)
  • Expected vs actual
  • Where (URL/screen/API)
  • Severity
  • Repro steps (optional)
  • Screenshot/video (optional)

cf proof capture output (automatic):

  • New REQ-#### in requirements ledger
  • Suggested gate obligations (with defaults from obligation map)
  • Starter pack of test stubs:
    • Unit test skeleton
    • Playwright test from repro steps
    • Visual snapshot target
    • a11y assertion if relevant
    • Perf budget entry if relevant

Enforcement Flow

On every PR / cf proof run:

  1. Determine what changed (files, routes, components)
  2. Find REQs whose scope intersects the change
  3. For intersecting REQs, run relevant obligations
  4. Attach evidence artifacts (test results, snapshots, metrics)
  5. Mark obligations satisfied or failing
  6. Block merge if any required obligation fails

Evidence Attachment Format

@dataclass
class Evidence:
    req_id: str
    gate: Gate
    satisfied: bool
    artifact_path: str          # relative path to test output / screenshot / report
    artifact_checksum: str      # SHA-256 for integrity
    timestamp: datetime
    run_id: str                 # CodeFrame run that produced this

Agent Integration

Two agent roles (used with CodeFrame's agent adapter architecture, #408):

Capture Agent

  • Turns bug report + artifacts into a REQ
  • Suggests obligations and scope via obligation mapping
  • Generates skeleton tests (not full implementations unless trivial)
  • Does NOT claim the bug is fixed

Proof Agent

  • Picks failing obligations (like "ready" tasks in CodeFrame)
  • Implements/fixes tests and code
  • Attaches evidence artifacts
  • The evidence is what closes the loop, not the agent's claim

This avoids the "agent says it fixed it" problem — PROOF9 doesn't trust claims, it trusts evidence.

Sub-Issues

This is a large feature that will need breakdown once implementation begins. Likely sub-issues:

  • REQ schema and ledger storage (SQLite)
  • cf proof capture CLI command with AI-assisted classification
  • Obligation mapping engine (glitch type → gates)
  • Test stub generator (per gate type)
  • Scope intersection engine (what changed → which REQs apply)
  • cf proof run command (execute relevant obligations, collect evidence)
  • Evidence attachment and artifact management
  • Waiver system with expiry tracking
  • Integration with CodeFrame's existing gates (core/gates.py)
  • cf proof status / cf proof report for dashboard view

CLI Commands

# Capture
cf proof capture                      # Interactive glitch capture
cf proof capture --from-issue GH-123  # Import from GitHub issue

# Run
cf proof run                          # Run obligations for current changes
cf proof run --full                   # Run all obligations (release mode)
cf proof run --gate unit              # Run only UNIT gate

# Manage
cf proof list                         # List all REQs
cf proof show REQ-0001                # Show REQ with obligation status
cf proof waive REQ-0001 --reason "..." --expires 2026-04-01
cf proof status                       # Dashboard: satisfied/failing/waived counts
cf proof report                       # Full evidence report

Waivers Are First-Class

Sometimes you can't automate yet. Fine — but it's tracked:

@dataclass
class Waiver:
    reason: str
    expires: date | None            # None = permanent waiver (rare, needs approval)
    manual_checklist: list[str]     # Manual verification steps
    approved_by: str

Waived REQs show up in cf proof status as a distinct category. Expired waivers revert to failing.

Acceptance Criteria

  • REQ schema defined and stored in SQLite
  • cf proof capture creates REQ with obligations from glitch description
  • Obligation mapping classifies glitch type → gate set
  • Test stubs generated for each obligation
  • cf proof run executes relevant obligations based on changed files
  • Evidence artifacts attached with checksums
  • Failing obligations block (or warn) on merge
  • Waiver system with expiry
  • REQs accumulate across sessions (the "memory" property)
  • cf proof status shows satisfied/failing/waived counts

Dependencies

The Elevator Pitch

PROOF9 is:

  • A standard for what must be proven
  • A runner that produces evidence
  • A loop that turns real-world glitches into permanent proof obligations

That's not just quality gates. That's a quality memory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureSystem architecture and design patternsenhancementNew feature or requestphase-5Phase 5: Advanced Features & Polishphase-5.2Phase 5.2: Quality & Intelligence (PROOF9, PRD stress test, unified config)quality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions