fix: enforce trustworthy quality snapshots - #505
Conversation
Pin comparisons to the exact PR base, fail invalid or regressed performance and coverage snapshots, and harden the E2E JSONRPC client against buffered-output loss and stderr backpressure. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Test Coverage Report (Linux)Result: ✅ Within regression budget
|
Performance Report (macOS)Result: ✅ Within regression budgets
|
Performance Report (Linux)Result: ✅ Within regression budgets
|
Test Coverage Report (Windows)Result: ✅ Within regression budget
|
Performance Report (Windows)Result: ✅ Within regression budgets
|
There was a problem hiding this comment.
Pull request overview
This PR turns PET’s existing performance and coverage “quality snapshots” into enforceable CI gates by validating snapshot integrity, comparing PR results against artifacts from the exact PR base commit, and failing the workflow on regressions or invalid comparisons. It also hardens the E2E JSON-RPC client to avoid stdout/stderr handling artifacts that could skew latency measurements.
Changes:
- Add a centralized Python snapshot comparator (
scripts/quality_snapshot.py) with unit tests and markdown reporting for performance (P50/P95/TTFE) and coverage (line/function). - Update perf/coverage workflows to download baseline artifacts for the PR base SHA, validate comparator logic, and fail on malformed/missing snapshots, inventory mismatches, or budget regressions.
- Update the Rust E2E client to keep a single buffered stdout reader and continuously drain bounded stderr to prevent backpressure or buffered read-ahead loss.
Show a summary per file
| File | Description |
|---|---|
| scripts/tests/test_quality_snapshot.py | Adds unit coverage for snapshot parsing, comparison decisions, and CLI exit/report behavior. |
| scripts/quality_snapshot.py | Implements snapshot loading/validation, cross-platform budgeted comparisons, and report generation used by CI gates. |
| docs/QUALITY_SNAPSHOTS.md | Documents the new gating rules, budgets, and local validation commands. |
| crates/pet/tests/e2e_performance.rs | Fixes JSON-RPC client IO handling to preserve stdout buffering and drain stderr, improving measurement trustworthiness. |
| .github/workflows/perf-tests.yml | Enforces performance snapshot extraction/validation and compares against exact PR base artifacts (blocking on regressions/invalid snapshots). |
| .github/workflows/perf-baseline.yml | Ensures baseline artifacts are valid (and expands baseline triggers) so PR comparisons are trustworthy. |
| .github/workflows/coverage.yml | Enforces coverage comparisons against exact PR base artifacts and blocks on regressions/invalid snapshots. |
| .github/workflows/coverage-baseline.yml | Validates baseline coverage artifacts (and expands baseline triggers) to support enforceable gating. |
Review details
Tip
Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 8/8 changed files
- Comments generated: 2
- Review effort level: Lite
Convert internal budget-table drift into a reported SnapshotError and document the comparator's Python 3.10 minimum, with direct regression coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Review details
Suppressed comments (1)
scripts/quality_snapshot.py:206
parse_lcov()accepts negative summary counts (e.g.LF:-1,LH:-1). Those are invalid LCOV values and can lead to nonsensical percentages or incorrect pass/fail decisions; the snapshot validator should reject them explicitly.
if lines_found == 0 or functions_found == 0:
raise SnapshotError(f'Coverage file has no line/function summary data: {path}')
if lines_hit > lines_found or functions_hit > functions_found:
raise SnapshotError(f'Coverage file has invalid hit totals: {path}')
- Files reviewed: 8/8 changed files
- Comments generated: 0 new
- Review effort level: Lite
Treat negative LCOV summary counts as invalid snapshots and cover the failure contract directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Turn PET performance and coverage snapshots into trustworthy, enforceable quality gates instead of advisory comments.
Validation
python -B -m unittest discover -s scripts/tests -p 'test_*.py' -vcargo test --all./scripts/rust-precommit.ps1Fixes #503