feat(gate): let an approved migration clear the schema-drift check - #222
Merged
Conversation
The gate blocks a pull request that changes the schema so a person validates the migration. Site now records that validation (Site#3289) and reports it as schemaChange.approved. The gate reads it: a change nobody approved still blocks, an approved one passes. An absent field reads as unapproved, so a Site deployment that predates it keeps blocking rather than dropping the gate for every repo. The check's message named the setting that disables the gate, because that was the only way out when it was written. It now names the tool that clears it, and says an approval does not change a check that has already reported. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.

Query Doctor — 6 successful checks
More details via MCP → get_ci_run({ runId: "019fd2fe-f025-743e-afce-d88e04203454" }) · 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
A reviewer can clear the schema gate on a migration they have read. The
schema-driftgate blocks a pull request that changes the schema so that a person validates the migration, but until now nothing could clear it — a repo either failed every migration or turned the condition off. Query-Doctor/Site#3870 built the half that records the validation. This is the half that acts on it.That completes Query-Doctor/Site#3289. There is no next step in this repo.
What
Before: a pull request containing a migration failed this check, and the only way to get it green was to set
schema-driftto warn or off for the whole repo.After: a reviewer approves that pull request's migration, re-runs CI, and the check passes. A schema change nobody approved still blocks. Amending the migration withdraws the approval on the Site side, so the check blocks again on the next run.
The check's message changes too. It named the setting that disables the gate, because that was the only way out when it was written. It now names the tool that clears it.
How
Read
src/gate/schema-change.tsfirst; the rest follows from it.SchemaChangeSignalgainsapproved?: boolean, andgateSchemaChangereturnsnullwhen it is true. That is the line that makes an approval clear the check. It sits after thechangedguard and before the policy lookup, so an approved migration passes without the repo having to soften its policy.src/main.ts— theevaluateGatesroll-up countedschemaChange.changed. It now countschanged && !approved, so an approved migration is not drift in the summary either. The separategateSchemaChangecall below it already passes the whole signal, so it needed no change.src/reporters/site-api.ts—approved?: booleanon the run response type, optional in the same waychangeswas added.An absent
approvedreads as unapproved. A Site deployment that predates the field sends no such key, and reading that as approved would drop the gate for every repo on an older API. A test pins that.Note the field is on Site's
stagingand not yet onmain, so this has no effect against production until Site deploys. Merging it early is safe: without the field, every run behaves exactly as it does today.Tests
src/gate/schema-change.test.tsgains five cases: an approved migration passes, an unapproved one still fails, an absent field still fails, and the message namesapprove_schema_change. The existing five cases are unchanged, which is the evidence that the default path did not move.Two of the five failed before the change. Deleting the approval guard turns "passes once someone has approved the migration" red.
Full suite 440 passed,
tsc --noEmitclean,npm run buildsucceeds.The
src/main.tscall site is not covered.evaluateGatesis tested insrc/gate/evaluate.test.ts, but the wiring that feeds it lives inmain.ts, which has no test harness. ThegateSchemaChangepath that decides the check itself is fully covered.