Skip to content

feat(api): reapply accepts the failed remainder of a partially completed apply#592

Open
aparajon wants to merge 1 commit into
aparajon/reapply-api-strictfrom
aparajon/reapply-api
Open

feat(api): reapply accepts the failed remainder of a partially completed apply#592
aparajon wants to merge 1 commit into
aparajon/reapply-api-strictfrom
aparajon/reapply-api

Conversation

@aparajon

@aparajon aparajon commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Why this matters

The reapply endpoint (#698) requeues only a fully failed apply. Real failures are often partial — some tables completed before one failed — and forcing operators to hand-build a new apply for the remainder is exactly the toil reapply should remove.

What it does

  • Replaces the strict all-failed shape guard with remaining-work selection: reapply gathers the apply's failed tasks, failed operations, and failed group finalizers, filters the stored plan down to that remainder, and requeues it when the fresh re-plan matches the remaining work.
  • Completed work is never re-run: the plan comparison is against the failed remainder, so a re-plan that still includes completed tables is rejected as drift.
  • Keeps the existing safety rejections — failed work outside the plan's primary deployment, and the fail-closed error for a failed task referencing a missing operation row.

Stacked on #698 (strict reapply endpoint). PR 3 of 5 in the reapply stack: storage primitive (merged) → strict endpoint (#698) → this → lock ownership → CLI.

🤖 Generated with Claude Code

@aparajon
aparajon force-pushed the aparajon/reapply-api branch from 0d650f9 to 7d41999 Compare June 29, 2026 21:08
Base automatically changed from aparajon/reapply-storage to main June 29, 2026 21:50
@aparajon
aparajon force-pushed the aparajon/reapply-api branch from 7d41999 to 402785c Compare June 29, 2026 21:51
Copilot AI review requested due to automatic review settings June 30, 2026 14:30
@aparajon
aparajon force-pushed the aparajon/reapply-api branch from 402785c to 5f5e465 Compare June 30, 2026 14:30
@aparajon
aparajon marked this pull request as ready for review June 30, 2026 14:31
@aparajon
aparajon requested review from Kiran01bm and morgo as code owners June 30, 2026 14:31

Copilot AI 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.

Pull request overview

Adds an operator-facing reapply control path to safely retry a failed schema change by re-planning against the current world state and only re-queueing when the fresh plan is equivalent to the remaining failed work.

Changes:

  • Introduces POST /api/reapply route + handler wiring in the API service.
  • Adds ReapplyResponse API type for the new endpoint.
  • Implements reapply planning/equivalence logic plus unit tests around the core ExecuteReapply behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
pkg/apitypes/apitypes.go Extends control-operation API types with a dedicated ReapplyResponse.
pkg/api/service.go Wires the new POST /api/reapply handler into route registration and exported handler surface.
pkg/api/reapply_handlers.go Implements handleReapply + ExecuteReapply with plan re-generation and equivalence checks before re-queueing failed work.
pkg/api/reapply_handlers_test.go Adds tests covering reapply acceptance/rejection paths and plan filtering/equivalence helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/api/reapply_handlers.go Outdated
Comment thread pkg/api/reapply_handlers.go
Comment thread pkg/api/reapply_handlers.go
Comment thread pkg/api/reapply_handlers.go Outdated
@aparajon
aparajon force-pushed the aparajon/reapply-api branch from 00d8618 to 90fd136 Compare July 2, 2026 22:14
@aparajon
aparajon requested a review from jayjanssen as a code owner July 2, 2026 22:14
@aparajon
aparajon force-pushed the aparajon/reapply-api branch 3 times, most recently from 19272bb to 6b22230 Compare July 9, 2026 03:28
@aparajon aparajon changed the title feat(api): add the reapply endpoint for failed schema changes feat(api): reapply accepts the failed remainder of a partially completed apply Jul 9, 2026
@aparajon
aparajon changed the base branch from main to aparajon/reapply-api-strict July 9, 2026 03:29
…ted apply

A partially completed apply no longer has to be recreated by hand:
reapply now selects the apply's failed work (failed tasks, failed
operations, and failed group finalizers), filters the stored plan down
to that remainder, and requeues it when the fresh re-plan matches the
remaining work. Failed work outside the plan's primary deployment is
still rejected, and a failed task referencing a missing operation row
still fails closed for operator investigation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@aparajon
aparajon force-pushed the aparajon/reapply-api branch from 6b22230 to 7110ec1 Compare July 9, 2026 03:34
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.

2 participants