← Back to Pull requests

test: guard enumerated sections against restating their own count #29

Closed
unknown closed this pull request without merging on Oct 03, 2026 23:36 UTC
View on GitHub
unknown unknown commented on Oct 03, 2026 21:16 UTC
Author

Why this is a separate PR

Follow-up to #28. That PR removed a hardcoded 六个问题 from the README Interviewer Guide preface because the section lists Q1–Q7. It fixed the instance and left the class unguarded, so this adds the guard.

The gap

Every existing check in scripts/check_repo_consistency.py validates evidence vocabulary, claim boundaries, offline subcommands or metric-series references. None of them cross-check a section's prose against the section's own contents. So the next question added to or removed from that list would drift the same way, silently, and nothing would fail.

This is not hypothetical for this repository — the drift shipped in f9e0aa9 and was only caught by reading.

What it adds

Two invariants, both derived from the text itself — no hardcoded count, heading name or document list:

1. Contiguous enumeration — an enumeration must be 1..N, so a skipped, duplicated or reordered marker is reported instead of reading as complete.
2. No restated count — a section that enumerates must not hardcode how many items it has, in either documented language (六个问题 / 7 个问题 / six questions).

False-positive control

Two deliberate restrictions keep this safe to run across every canonical document:

  • An enumeration item requires the bold marker Q1 ·, so an inline reference or a heading such as ## Q12 标准回答 in interview-architecture-baseline.md is not read as a list item.

  • A section that enumerates nothing is skipped entirely, so PRD prose that merely mentions 12 个问题 is never inspected.
  • Verified empirically that README.md is the only canonical document containing Q<n> markers, and that no canonical document has a count phrase without an enumerator.

    Proof it catches the original bug

    Reintroducing 六个问题 on this branch:

    README.md: section '2-minute Interviewer Guide' restates a hardcoded count of
    its own enumeration (['六个问题']) while listing 7 items; delete the number so
    the prose cannot drift out of sync
    

    Deleting a Q5 marker:

    README.md: section '2-minute Interviewer Guide' enumerates [1, 2, 3, 4, 6, 6, 7]
    instead of a contiguous 1..7 sequence
    

    ⚠️ Base branch is intentional

    This PR targets docs/fix-interviewer-guide-count, not main.

    The guard correctly fails on main, because main still says 六个问题 above Q1–Q7. Merging #28 first makes this branch green without duplicating the one-line fix. Review order: #28 → #29.

    Scope

  • 2 files changed, 185 insertions(+), 0 deletions(-) — guard and tests only, purely additive

  • scripts/check_repo_consistency.py + tests/test_check_repo_consistency.py

  • No capability, architecture, metric, evidence level, threshold or production claim touched

  • No hardcoded test count, PR number, date or SHA in the guard; it reads only the working tree
  • Verification

    | Check | Result |
    |---|---|
    | python scripts/check_repo_consistency.py | Repository consistency check passed. |
    | ruff check . | All checks passed! |
    | ruff format --check . | 259 files already formatted |
    | python -m pytest tests/ -q | 1718 passed, 15 skipped (1709 + exactly these 9 tests) |
    | tests/test_check_repo_consistency.py | 322 passed (313 + 9) |

    Diff: 406 lines (+304 / -102) across 5 files Reviewer: Xander-Xai Review duration: 140m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 406 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.359
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #29"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.8% (MEDIUM) · Higher = larger blast radius
    44.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.7% · Safe to merge
    17.7%