feat(github): add PR comment cutover command + cutover fixes#97
Draft
aparajon wants to merge 1 commit into
Draft
feat(github): add PR comment cutover command + cutover fixes#97aparajon wants to merge 1 commit into
aparajon wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes progress/cutover state reporting across the Progress API and PR comment rendering, ensuring engine-reported states (including Spirit camelCase) are normalized to canonical task states and that tasks in waiting_for_cutover are counted as ready for cutover.
Changes:
- Prevent Progress polling from overwriting storage states beyond
pending/running(avoids downgrades after restart when the engine reportspending/no active migration). - Add
ready_to_completetoTableProgress(proto + server population) and setReadyToCompletewhen tasks enterwaiting_for_cutover(atomic path). - Normalize per-table engine progress states via
state.NormalizeTaskStatusinstead ofstrings.ToUpper.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/tern/local_client.go | Adjusts Progress polling state update rules; normalizes engine per-table states; returns ReadyToComplete in TableProgress. |
| pkg/tern/local_client_integration_test.go | Adds an integration test intended to validate Progress state normalization and ReadyToComplete behavior. |
| pkg/tern/local_apply.go | Sets Task.ReadyToComplete when atomic progress transitions to waiting_for_cutover. |
| pkg/proto/ternv1/tern.pb.go | Regenerated Go proto to include TableProgress.ready_to_complete. |
| pkg/proto/tern.proto | Adds ready_to_complete field to TableProgress message. |
Files not reviewed (1)
- pkg/proto/ternv1/tern.pb.go: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aea885c to
402e787
Compare
402e787 to
6bfea64
Compare
87f05b7 to
d5d6d2d
Compare
8b81deb to
80970f7
Compare
46c9090 to
09ff60c
Compare
5137bf5 to
d91122e
Compare
Add PR comment cutover command (schemabot cutover <apply-id> -e <env>), sentinel-based crash recovery for deferred cutover, and cutover comment lifecycle improvements. Key changes: - Cutover command handler with environment validation - Recovering state with sentinel table check for crash recovery - Cutover comment UX: progress freezes, cutover comment serves as summary - Progress tombstone differentiates from summary comment - Cutover and recovering state rendering in CLI and PR comments - Integration tests for sentinel recovery and cutover flows Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d91122e to
49b12d1
Compare
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.
Summary
Add cutover via PR comment command, sentinel-based crash recovery, and cutover state fixes.
Cutover via PR comment — new `schemabot cutover -e ` command. Validates apply state, resolves tern client via stored deployment, triggers cutover, posts acknowledgment comment. Error handling for missing apply ID, missing environment, and environment-based instance routing.
Sentinel-based crash recovery — when a container restarts while a task is in `waiting_for_cutover`, check whether Spirit's `_spirit_sentinel` table exists in the target database. If it does, transition to a new `recovering` state that blocks cutover until Spirit re-reaches `WaitingOnSentinelTable` from its checkpoint. Replaces the previous blanket `CanEngineOverrideTaskState` guard with evidence-based recovery. Future: block/spirit#844 will add a `resume` field to replace the sentinel check.
ReadyToComplete centralized — set in `transitionTaskState` so both atomic and sequential modes mark tasks ready when entering `waiting_for_cutover`.
Engine state normalization — `NormalizeTaskStatus` converts camelCase Spirit states to canonical snake_case. Fixes CLI and PR comment rendering.
State downgrade prevention — Progress API only overwrites task state when the task is still pending or running, using sentinel-aware reconciliation.
Cutover UX — yellow progress bars and `⏸️ Ready for cutover` (green reserved for completions). Cutover footer includes apply ID and environment. Recovering state shows `🔄 Recovering...` with last known progress bar.
Templates — all cutover PR comments rendered via `pkg/webhook/templates/cutover.go`. AGENTS.md guideline: all PR comments must use templates.
Documentation — new `docs/cutover.md` covering the cutover lifecycle, sentinel table mechanism, Spirit's rename-under-lock algorithm, force-kill behavior, and recovery state. Updated `pkg/state/README.md` with recovering state.