Skip to content

feat(gate): block PRs with schema changes (gate the API's signal)#188

Merged
veksen merged 1 commit into
mainfrom
feat-schema-change-gate
Jul 23, 2026
Merged

feat(gate): block PRs with schema changes (gate the API's signal)#188
veksen merged 1 commit into
mainfrom
feat-schema-change-gate

Conversation

@veksen

@veksen veksen commented Jul 22, 2026

Copy link
Copy Markdown
Member

Goal

External dogfooding feedback (Query-Doctor/Site#3289): a migration should force a human eyeball before merge. This adds the gate — the only missing piece. The analyzer already gets the real schema diff from the API (runMetadata.schemaChange) and renders it in the comment; nothing acted on it. Now a schema change blocks the check by default. Addresses Query-Doctor/Site#3289.

What

Before → after for a PR that changes the schema:

  • Before: the comment showed "N schema changes vs main", the check stayed green. A migration with no query regression sailed through.
  • After: the check fails by default with "validate the migration before merge". A repo softens it to warn (shown, non-blocking) or off via the schema-drift policy, which already exists in the condition catalog.

How

  • src/gate/schema-change.ts (new) — gateSchemaChange(schemaChange, policy) takes the API's existing runMetadata.schemaChange and routes { condition: "schema-drift", verdictClass: "finding" } through the shared resolveVerdict (taxonomy #3498 + policy #3500). Returns failure (block), neutral (soften), or null (no change / off). No detection — the API owns that.
  • src/main.ts — reads reportContext.runMetadata?.schemaChange, calls the gate, then core.setFailed / core.warning, alongside the test-presence gate.

Tests

src/gate/schema-change.test.ts — blocks by default, softens under warn, drops under off, passes when the run has no change or the API sent no signal.

Full suite green except one pre-existing site-api.test.ts failure (a local core-version skew, present on main without this change).

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

Query Doctor Analysis

3 queries analyzed

0 regressed · 0 improved · 0 new · 0 removed

2 pre-existing issues

Using assumed statistics (10000000 rows/table). For better results, sync production stats.

More detail → get_ci_run({ runId: "019f8f6b-6523-7348-b789-375ea1764520" }) · view run · docs

@veksen veksen changed the title feat(gate): block PRs with schema/migration changes feat(gate): block PRs with schema changes (gate the API's signal) Jul 22, 2026
@veksen
veksen force-pushed the feat-schema-change-gate branch from 1d1e3a1 to 051d8b9 Compare July 22, 2026 19:51
@veksen
veksen force-pushed the feat-schema-change-gate branch from 051d8b9 to 9bedb01 Compare July 22, 2026 20:08
veksen added a commit that referenced this pull request Jul 22, 2026
Cost-regression already blocks a PR, but through the analyzer's old inline
path, so a repo couldn't set it to warn/off the way it can for
untested-data-access (#183) and schema-drift (#188). Route the regression arm
through resolveVerdict/policyFor, matching those two conditions.

regression-beyond-threshold is a finding in the shared taxonomy and defaults
to fail, so a repo that sets nothing blocks exactly as before. warn caps it at
a surfaced, non-blocking neutral; off suppresses it.

The new-query gate is left on its inline setFailed: its default policy is warn,
so routing it through resolveVerdict would silently stop it blocking — a
behavior change that needs a separate human sign-off.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The API already computes the real schema diff (runMetadata.schemaChange) and the
comment renders it; nothing gated on it. gateSchemaChange reads that signal and
routes schema-drift through resolveVerdict (taxonomy #3498 + policy #3500): fail
by default so a person validates the migration, warn/off to soften. No detection
here — the API owns it. Addresses Query-Doctor/Site#3289.
@veksen
veksen force-pushed the feat-schema-change-gate branch from 9bedb01 to de49e66 Compare July 23, 2026 14:39
@veksen
veksen merged commit 411bbae into main Jul 23, 2026
6 checks passed
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