Skip to content

test(witnesses): automated witness coverage audit (#1227) - #1279

Merged
Sinity merged 1 commit into
masterfrom
feature/test/witness-audit-1227-v2
May 18, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/test/witness-audit-1227-v2

Conversation

@Sinity

@Sinity Sinity commented May 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Add devtools verify-witness-coverage, which scans merged fix: PRs
from the last 90 days via gh pr list and flags any that modified
polylogue/ source without adding or modifying a file under
tests/witnesses/. Wired into devtools verify as a recommended
(soft) gate so missing-witness findings surface without blocking PR
readiness.

Problem

tests/witnesses/ is the durable failure-case corpus for closed bugs,
but nothing checks that every bug-fix PR contributed a witness. Bugs
quietly close without a regression artifact, eroding the corpus's
value over time (issue #1227).

Solution

  • devtools/verify_witness_coverage.py — new audit module. Calls
    gh pr list --state merged --search "is:pr is:merged merged:>=…",
    with PR title + labels (bug) used to identify fix PRs and a
    filename heuristic (polylogue/ source touched, no
    tests/witnesses/ entry added) used to flag PRs. --soft returns
    zero on flag (used inside devtools verify); the default exits 1.
    Skips cleanly with rc=0 in soft mode when gh is unavailable, so
    the local baseline does not regress in offline environments.
  • docs/plans/witness-coverage-suppressions.yaml — narrow opt-out
    registry (PR number + rationale) for PRs that genuinely do not need
    a witness.
  • devtools/command_catalog.py — registers the new verification
    command so it shows in --list-commands and docs/devtools.md.
  • devtools/verify.py — added as a recommended step
    (devtools verify-witness-coverage --soft) in the non-commit
    baseline. The --soft flag means a flagged PR will not block the
    local baseline; nightly jobs invoke the command without --soft
    for the hard gate.
  • tests/unit/devtools/test_verify_witness_coverage.py — 23 unit
    tests covering the fix-PR heuristic, suppression parsing, audit
    decisions, soft vs strict mode, and command registration.
  • Generated docs/devtools.md and AGENTS.md refreshed via
    devtools render-all.

Heuristic chosen deliberately broad: fix: / fix(...) subject prefix
OR bug label, and any added file under tests/witnesses/ clears the
flag (we do not enforce a specific witness-per-PR linkage to keep the
audit cheap to satisfy).

Verification

$ nix develop -c pytest tests/unit/devtools/test_verify_witness_coverage.py -q
23 passed in 9.43s

$ nix develop -c devtools verify-witness-coverage --soft --json
{"window_days":90,"examined":39,"flagged":[…],"suppressed":[],"skipped_reason":null}
# Exits 0; flags real inherited debt (the corpus problem #1227 motivates).

$ nix develop -c devtools verify --quick
# all steps green except a pre-existing render-pages cache flake on
# master (unrelated; resolved by re-running devtools render-pages).

Closes #1227

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added verify-witness-coverage command to audit merged PRs for missing regression test witnesses, with soft (non-blocking) and strict (blocking) modes.
    • Supports JSON output format and configurable suppression lists.
  • Documentation

    • Updated command reference documentation.
  • Tests

    • Added comprehensive test coverage for the new verification command.

Review Change Stack

Add devtools verify-witness-coverage which scans merged fix PRs from
the last 90 days via gh and flags any that modified polylogue/ source
without adding (or modifying) a file under tests/witnesses/. Wired
into devtools verify as a recommended (soft) gate so missing-witness
findings surface without blocking PR readiness; nightly jobs invoke
the command without --soft for the hard gate.

A suppression list at docs/plans/witness-coverage-suppressions.yaml
covers PRs that genuinely do not need a witness.

Closes #1227

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 18, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR adds devtools verify-witness-coverage, a new audit command that scans recently merged "fix" PRs for missing regression witness files. The command queries GitHub for merged PRs within a configurable window, identifies those labeled or titled as fixes, flags ones that modify polylogue/ source without adding witness files, and supports suppression lists for false positives. It integrates into the verification pipeline in soft mode and includes comprehensive tests.

Changes

Witness Coverage Audit Tool

Layer / File(s) Summary
Core audit data model and logic
devtools/verify_witness_coverage.py (lines 1–229)
Introduces FlaggedPR and AuditResult dataclasses, loads suppression lists from YAML, classifies PRs as "fix" candidates by subject/label patterns, wraps gh GitHub queries, fetches recent merged PRs with file details, and implements the core audit logic that flags PRs touching polylogue/ source without witness files.
CLI interface and execution
devtools/verify_witness_coverage.py (lines 231–332)
Builds argument parser for --days, --limit, --json, and --soft options, implements main() to load suppressions, handle missing or failed GitHub queries, dispatch the audit, return appropriate exit codes, and emit JSON or human-readable reports to stdout/stderr.
Command registration and verification integration
devtools/command_catalog.py, devtools/verify.py
Registers verify-witness-coverage in the command catalog under verification category pointing to devtools.verify_witness_coverage, and wires it into build_verify_steps() as a soft-mode recommended check that does not block verification.
Configuration and documentation
docs/plans/witness-coverage-suppressions.yaml, docs/devtools.md, AGENTS.md
Adds suppressions configuration file with documented structure for opting out false-positive flags, and updates auto-generated command catalogs to list the new verify-witness-coverage command.
Comprehensive test coverage
tests/unit/devtools/test_verify_witness_coverage.py
Covers fix-PR classification (subject/label heuristics including case-insensitive matching), audit logic for witness presence/absence and suppression handling, suppression file parsing with multiple YAML formats, CLI exit codes in soft vs strict modes, and command registration validation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Sinity/polylogue#450: Wires a new verification command (verify-test-ownership) into devtools/verify.py::build_verify_steps() using the same integration pattern.
  • Sinity/polylogue#1191: Adds new verify-* command specs to devtools/command_catalog.py and integrates them into build_verify_steps().
  • Sinity/polylogue#438: Modifies devtools/verify.py's verification sequence to add a new verify-topology command.

Suggested labels

area:qa, area:docs

🐰 A witness to every fix,
No regression shall slip through the mix!
The audit hops and bounds,
To close the corpus gaps—
Fittest tests forever found. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding an automated witness coverage audit for bug-fix PRs.
Description check ✅ Passed The description provides all required sections: Summary, Problem, Solution, Verification, and includes a reference to the closed issue. Changelog section is appropriately omitted as this is test/internal tooling.
Linked Issues check ✅ Passed All acceptance criteria from issue #1227 are met: command registered in catalog, uses gh to enumerate fix PRs, heuristic flags PRs modifying polylogue/ without witness, suppression list provided, soft/strict mode implemented, and documentation updated.
Out of Scope Changes check ✅ Passed All changes directly support the witness coverage audit objective. The new module, catalog registration, verify integration, suppressions file, tests, and documentation regeneration are all in scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/test/witness-audit-1227-v2

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 and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd7979bc46

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread devtools/verify_witness_coverage.py Resolved
@Sinity
Sinity merged commit a970742 into master May 18, 2026
3 of 4 checks passed
@Sinity
Sinity deleted the feature/test/witness-audit-1227-v2 branch May 18, 2026 13:25
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

Only the rows listed above are dispositioned. Held findings remain open.

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.

test(witnesses): automated audit ensuring closed bug-fix PRs have witnesses

1 participant