← Back to Pull requests

test: turn performance scratch notes into a reproducible regression baseline #127

Open
unknown opened this pull request with 408 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 30, 2026 15:12 UTC
Author

Closes #115

What changed

  • Migrated the durable findings from tests/performance/todo.md and hidden_info.md into the maintained [performance baselines doc](docs/code-maintainability/performance-baselines.md): the raw EXPLAIN captures are preserved as evidence under docs/code-maintainability/performance-evidence/explain-13/, and the scratch files are deleted with a pointer left in tests/performance/README.md.

  • Chose the shared reciprocal_rank_fusion capability as the representative operation. It is pure, synchronous, deterministic, and needs no external services.

  • Added an in-process harness (tools/operations/performance/rrf_baseline.py) and a committed measured baseline (tests/performance/baseline/rrf_fusion.json) with environment, command, and method recorded.
  • Measured baseline and budget

    On CPython 3.12.13 / Linux x86_64 at b72b7409: fusion min 170,043.57 ns/op, plain-dict reference min 104,437.38 ns/op, ratio 1.6282. Budget = 4x ratio (limit 6.5127). The ratio cancels machine-speed differences; the min-of-9 estimator ignores additive scheduler noise; 4x headroom absorbs interpreter/CI variance while still catching the 10–50x regression class (e.g. Pydantic construction drifting into the inner loop). Median/p95 are recorded for diagnosis, not asserted.

    Enforcement

    make perf-gate (uv run pytest tests/performance/ -q) is wired into make selfcheck and CI. The live test passes; sabotage paths fail: --check --budget-multiplier 0.01 exits 1 with REGRESSION, and a unit test injects a 2000x-slowed fusion and asserts the gate fails.

    Verification

  • uv run ruff check apps/api/src/ tests/ and uv run ruff format --check apps/api/src/ tests/: clean (harness also ruff-clean).

  • uv run ty check apps/api/src/: clean; uv run lint-imports: 22 contracts kept; ast-grep scan apps/api/src/: clean.

  • make perf-gate: 8 passed; fusion unit + property tests: 13 passed; gate also passes under coverage instrumentation.

  • Pre-existing environment limitations (not introduced here): make context needs the gitignored .testing-credentials.json; the full suite has known missing .env/API-key/Postgres-DNS failures documented in docs/coverage-gate.md. No full-suite fix attempted.
  • Not merged by the author — awaiting review.

    Summary by Sourcery

    Establish a reproducible regression baseline for reciprocal-rank fusion and enforce its performance budget in local self-checks and CI.

    New Features:

  • Add a reproducible, service-free performance regression gate for reciprocal-rank fusion with a committed baseline and documented budget.
  • Enhancements:

  • Wire the performance gate into make selfcheck and CI, and document the make perf-gate command.
  • CI:

  • Run the performance budget check in the test workflow.
  • Documentation:

  • Document the measured baseline, methodology, retrieval query-plan findings, and migrated operational guidance; preserve the raw EXPLAIN captures in the maintained documentation area.
  • Tests:

  • Add focused checks for baseline statistics, budget enforcement, deliberate regressions, and local/CI gate wiring.
  • Chores:

  • Retire the performance scratch-note files and add a README pointing contributors to the maintained baseline documentation.
  • Diff: 408 lines (+306 / -102) across 5 files Reviewer: coderabbitai[bot] Review duration: 6m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.45) × (1 − Review Confidence (0.32)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 408 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 59% · Reviewer familiarity: 35%
    32%
    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.360
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #127"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 32.1% 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: 32.1% · Lower = rushed or shallow review
    32.1%
    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: 30.4% · Safe to merge
    30.4%