fix(github): explain empty-diff apply reconciliation#335
Draft
aparajon wants to merge 4 commits into
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
Adds explicit “empty diff” reconciliation behavior for SchemaBot PR commands so that when a schema apply has started (or completed) but the current PR no longer contains managed schema files, SchemaBot fails closed with actionable guidance rather than falling back to broad repository discovery.
Changes:
- Introduces reconciliation templates for “no managed schema changes” and “reconciliation required” (in-progress vs completed apply).
- Adds a webhook guard (
handleNoManagedSchemaChangesForCommand) used byplan,apply, andapply-confirmto detect empty-diff + apply-owned state and post guidance. - Extends preview scenarios/templates and adds E2E/unit tests for the new empty-diff behaviors (plan/apply covered).
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| TEMPLATES.md | Adds rendered template snapshots for no-managed and reconciliation-required scenarios. |
| pkg/webhook/webhook_e2e_test.go | Adds E2E coverage for empty-diff reconciliation behavior (plan/apply). |
| pkg/webhook/templates/reconciliation.go | Implements new comment renderers for no-managed changes and reconciliation-required guidance. |
| pkg/webhook/templates/reconciliation_test.go | Unit tests for the reconciliation templates. |
| pkg/webhook/templates/preview.go | Adds preview helpers for the new reconciliation comment scenarios. |
| pkg/webhook/schema_reconciliation.go | Adds the empty-diff guard + stored-state lookup to decide between “no managed changes” vs “reconcile”. |
| pkg/webhook/schema_reconciliation_test.go | Unit tests for PR-file detection and reconciliation item derivation. |
| pkg/webhook/plan.go | Runs the empty-diff reconciliation guard before schema discovery for plan. |
| pkg/webhook/apply_handlers.go | Runs the empty-diff reconciliation guard before schema discovery for apply and apply-confirm. |
| pkg/webhook/check_runs.go | Updates the user-facing block message for schema-removed-after-apply state. |
| pkg/cmd/internal/templates/preview.go | Adds new preview type constants for the reconciliation scenarios. |
| pkg/cmd/internal/templates/preview_dispatch.go | Dispatches the new preview types to the webhook template previews. |
| pkg/cmd/internal/templates/preview_comment.go | Includes the new previews in “all comment previews” output. |
| pkg/cmd/commands/preview.go | Wires the new preview types into CLI help and routing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019eb380-ca81-749e-94a2-cb4982ed90dd
9541932 to
3c13cae
Compare
Amp-Thread-ID: https://ampcode.com/threads/T-019eb380-ca81-749e-94a2-cb4982ed90dd Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019eb380-ca81-749e-94a2-cb4982ed90dd Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019eb380-ca81-749e-94a2-cb4982ed90dd Co-authored-by: Amp <amp@ampcode.com>
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.
Why
When a PR no longer contains managed schema files after an apply has started, SchemaBot should fail closed with clear reconciliation guidance instead of falling through to broad repository discovery or implying the PR is clean.
What
Risk Assessment
Medium — this changes GitHub PR-command behavior for a safety-gate edge case, but only when the current PR has no managed schema files and stored apply-owned state exists.
Generated with Amp