Skip to content

feat(github): lead the PR comment with the gate roster - #201

Merged
veksen merged 1 commit into
mainfrom
feat-gates-first-comment
Jul 31, 2026
Merged

veksen merged 1 commit into
mainfrom
feat-gates-first-comment

Conversation

@veksen

@veksen veksen commented Jul 31, 2026 •

Copy link
Copy Markdown
Member

Goal

The PR comment should tell a developer whether Query Doctor is blocking their merge, and what to do about it. Today it cannot: gating runs after the comment renders, so the template has no access to its own check result.

This is the first of two PRs. The follow-up (#202) carries SQLCommenter tags through compareRuns, so rows can read ProjectQueriesRepository.findByHash instead of a hash.

What

Before: the comment listed findings by type (improvements, regressions, new queries, pre-existing recommendations) with no verdict anywhere. A run whose gates all passed still printed dozens of rows.

After: it leads with the gate roster.

### 1 failing and 5 successful checks

x **New query with index recommendation** — 2 new queries ship a high-impact index recommendation
      SELECT … FROM "ci_runs_queries" INNER JOIN "ci_runs"
      plans at 1,230, or 346 with these indexes (72% improvement)
      CREATE INDEX ON ci_runs_queries (hash, optimization, ci_run_id);
  **Cost regression** — 2 queries got more expensive
! **New query** — 4 new queries, none with a prior baseline
  **Untested data access** — No changed data-access file without a test

A condition that found nothing is one line. A condition that fired expands beneath its own line. A clean run is six lines and a footer.

How

Read src/gate/evaluate.ts first. evaluateGates returns one outcome per condition, including the ones that found nothing, which the existing gates cannot express because they return null. summarizeGates derives the heading counts from that same array, and main.ts drives its check annotations from it, so the heading and the check cannot disagree.

success.md.j2 loses the per-finding sections. The baseline-state guidance stays: it explains why a comparison is missing, which the roster does not replace.

Two things to know. Gate labels are duplicated from CI_CONDITIONS in @query-doctor/types, which the analyzer cannot depend on; the code marks the drift risk and says to collapse them when this repo merges into Site. Status glyphs are committed under assets/gate/ and fetched over HTTP, because GitHub strips inline <svg> — they resolve once this is on main.

Supersedes ADR-0003 on per-query rows (Query-Doctor/Site#3775). Its staleness argument still applies, bounded: only a firing condition renders rows, and triaging a query is what stops it firing.

Tests

src/gate/evaluate.test.ts covers the roster on a clean run, each condition firing from its own fact, off dropping a condition entirely, warn capping at neutral, the labels, the copy, and the roll-up. github.test.ts covers the heading, the condition lines, and detail appearing only for a gate that fired.

Tests asserting the removed sections were deleted rather than adjusted, since the behaviour is gone by design. Full suite: 380 passing, 39 files, typecheck clean.

@github-actions github-actions 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.

6 successful checks

 Cost regression — No query got more expensive than the threshold allows
 Untested data access — No changed data-access file without a test
 New query — No new queries
 New query with index recommendation — No new query ships an index recommendation
 Schema drift — No schema changes
 High-value nudge — No index or rewrite past the threshold


More details via MCP → get_ci_run({ runId: "019fb8e1-840d-7de7-bb2c-0655effdd9a4" }) · view run · docs
3 queries read against main on assumed statistics of 10,000,000 rows per table. Sync production stats for costs measured against your real data.

@veksen
veksen force-pushed the feat-gates-first-comment branch 3 times, most recently from c487582 to ede76d2 Compare July 31, 2026 15:27
The comment reported findings by type: improvements, regressions, new queries,
pre-existing recommendations. It never said whether the check passed, because
gating ran after the report and the template had no access to its own result.
A run whose gates all passed still printed a whole-repo dump.

Resolve every condition before rendering and lead with that roster. A condition
that found nothing is one line. A condition that fired expands beneath its own
line with the queries and the CREATE INDEX that clears it. The check annotations
read the same array, so the heading and the check cannot disagree.

Supersedes ADR-0003 on per-query rows.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant