You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/crane.md
+13-12Lines changed: 13 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -247,7 +247,7 @@ The pre-step fetches open issues with the `crane-migration` label via the GitHub
247
247
When a migration is issue-based, `/tmp/gh-aw/crane.json` includes:
248
248
-**`selected_issue`**: The issue number (e.g., `42`) if the selected migration came from an issue, or `null` if it came from a file.
249
249
-**`issue_migrations`**: A mapping of migration name -> issue number for all issue-based migrations found.
250
-
-**`stale_completed_state`**: Issue-based migrations whose completion state is not trustworthy. This includes active issues that still have `crane-migration` even though repo-memory says `Completed: true`, and completed-label issues whose current PR-head completion gate did not pass.
250
+
-**`stale_completed_state`**: Issue-based migrations whose completion state is not trustworthy. This includes active issues that still have `crane-migration` even though repo-memory says `Completed: true`, and completed-label issues whose current up-to-date PR-head completion gate did not pass.
251
251
252
252
### Reading Migrations
253
253
@@ -261,7 +261,7 @@ The pre-step has already determined which migration to run. Read `/tmp/gh-aw/cra
261
261
-**`selected_strategy`**: The `strategy` value from the migration's frontmatter -- one of `"in-place"`, `"greenfield"`, or `"auto"`. If `"auto"`, the agent must pick on the first iteration and write the chosen strategy back into the state file's Machine State table.
262
262
-**`state_file_size_bytes`** / **`state_file_max_bytes`**: For rolling-compaction decisions (see [Update Rules](#update-rules)).
263
263
-**`issue_migrations`**: A mapping of migration name -> issue number for all discovered issue-based migrations.
264
-
-**`stale_completed_state`**: A list of issue-based migrations where repo-memory still says `Completed: true`, but the issue label state or PR-head completion gate says the migration is not safely complete; treat this as stale memory, not as permission to finish.
264
+
-**`stale_completed_state`**: A list of issue-based migrations where repo-memory still says `Completed: true`, but the issue label state or up-to-date PR-head completion gate says the migration is not safely complete; treat this as stale memory, not as permission to finish.
265
265
-**`deferred`**: Other migrations that were due but will be handled in future runs.
266
266
-**`unconfigured`**: Migrations that still have the sentinel or placeholder content.
267
267
-**`skipped`**: Migrations not due yet based on their per-migration schedule, or completed/paused.
@@ -277,7 +277,7 @@ If `selected` is not null:
277
277
4. Read the state file `{selected}.md` from the repo-memory folder. This contains the Machine State table, the Migration Plan, lessons, blockers, and iteration history.
278
278
5. If `selected_issue` is not null, also read the issue comments for any human steering input.
279
279
6. If `selected` appears in `stale_completed_state`, ignore any pre-existing `Completed: true`, `Completed Reason`, target-satisfying `best_metric`, or `crane-completed` label as a completion signal. Restore the issue to active migration state by ensuring `crane-migration` is present and `crane-completed` is absent unless the deterministic completion gate passes later in this run. First run the current verification contract and only enter the completion-candidate path after a fresh accepted iteration satisfies the target metric.
280
-
7. Before making code changes, inspect the state file's `Completion Candidate` field. If it is `true`, run the deterministic completion gate in [Halting Condition](#halting-condition). Only finalize completion if the current PR head checks pass. If the gate is failing, fix the failing PR checks instead of starting unrelated migration work. If the gate is pending or unavailable, leave the issue active and update `Completion Gate Status`.
280
+
7. Before making code changes, inspect the state file's `Completion Candidate` field. If it is `true`, run the deterministic completion gate in [Halting Condition](#halting-condition). Only finalize completion if the current PR head contains the current base branch SHA and the current PR head checks pass. If the gate is failing, stale, behind, or diverged, fix the PR branch/checks instead of starting unrelated migration work. If the gate is pending or unavailable, leave the issue active and update `Completion Gate Status`.
281
281
282
282
## Multiple Migrations
283
283
@@ -617,7 +617,7 @@ If `status == "failure"`, **fix and retry -- do not revert, do not accept**:
617
617
- Update **[docs] Lessons Learned** if this iteration revealed something new (e.g. a bridging trick, a parity surprise, a perf trap).
618
618
- Update **[scope] Future Work** if this iteration opened new threads.
619
619
5.**Update the migration issue**: edit the status comment and post a per-iteration comment using the same shared accepted iteration summary.
620
-
6.**Check halting condition** (see [Halting Condition](#halting-condition)): if `target-metric` is set, compare the new `best_metric` from this accepted iteration against it. For `higher` direction, the target is reached when `best_metric >= target-metric`. Reaching the target metric does **not** complete the migration in this run. It creates a completion candidate: set `Completion Candidate: true`, set `Completion Gate: pr-head-checks`, set `Completion Gate Status: pending`, keep `Completed: false`, keep `Completed Reason: --`, and leave the `crane-migration` label on the issue. Completion is finalized only by a later run after the pushed PR head's deterministic checks are observed green.
620
+
6.**Check halting condition** (see [Halting Condition](#halting-condition)): if `target-metric` is set, compare the new `best_metric` from this accepted iteration against it. For `higher` direction, the target is reached when `best_metric >= target-metric`. Reaching the target metric does **not** complete the migration in this run. It creates a completion candidate: set `Completion Candidate: true`, set `Completion Gate: up-to-date-pr-head-checks`, set `Completion Gate Status: pending`, keep `Completed: false`, keep `Completed Reason: --`, and leave the `crane-migration` label on the issue. Completion is finalized only by a later run after the pushed PR head contains the current base SHA and its deterministic checks are observed green.
621
621
622
622
**If the score did not improve**:
623
623
1. Discard the code changes (do not commit them to the long-running branch).
@@ -727,7 +727,7 @@ After **every iteration** (accepted, rejected, or error), post a **new comment**
727
727
728
728
## Halting Condition
729
729
730
-
Migrations are usually **goal-oriented** -- you want to finish. Set `target-metric: 1.0` in the frontmatter to nominate a migration for completion once the health score reaches 1.0 (which, with the recommended `correctness x progress` convention, means "fully migrated and verified"). The metric is necessary but not sufficient: final completion always requires a deterministic PR-head completion gate.
730
+
Migrations are usually **goal-oriented** -- you want to finish. Set `target-metric: 1.0` in the frontmatter to nominate a migration for completion once the health score reaches 1.0 (which, with the recommended `correctness x progress` convention, means "fully migrated and verified"). The metric is necessary but not sufficient: final completion always requires a deterministic up-to-date PR-head completion gate.
731
731
732
732
### How It Works
733
733
@@ -737,29 +737,30 @@ Migrations are usually **goal-oriented** -- you want to finish. Set `target-metr
737
737
4. For `lower` direction: the target is reached when `best_metric <= target-metric`.
738
738
5. When the target is reached, create a completion candidate instead of completing immediately:
739
739
- Set `Completion Candidate: true`.
740
-
- Set `Completion Gate: pr-head-checks`.
740
+
- Set `Completion Gate: up-to-date-pr-head-checks`.
741
741
- Set `Completion Gate Status: pending`.
742
742
- Keep `Completed: false` and `Completed Reason: --`.
743
743
- For issue-based migrations, keep the `crane-migration` label and do not add `crane-completed`.
744
744
- Update the status comment to Active with a note that the migration is waiting on deterministic PR-head checks.
745
745
6. On the next run while `Completion Candidate: true`, run the deterministic completion gate before making code changes:
746
746
- Resolve the migration PR from `existing_pr` or the state file's `PR` field.
747
-
- Query the PR's current head SHA via the GitHub API.
747
+
- Query the PR's current head SHA and current base SHA via the GitHub API.
748
+
- Query `GET /repos/{owner}/{repo}/compare/{base_sha}...{head_sha}`. The gate is stale unless the compare status is `ahead` or `identical`. If it is `behind`, `diverged`, or unavailable, merge/rebase the current base into the PR branch, push the PR branch, and wait for fresh checks. Do not mark the migration complete from checks produced before the current base SHA was included.
748
749
- Query check-runs/check-suites for that exact PR head SHA, or use `gh pr checks "$PR" --json name,conclusion,state,startedAt,completedAt`.
749
-
- The gate passes only if every check for the current PR head is terminal success. Treat missing checks, pending checks, queued checks, failing checks, cancelled checks, timed-out checks, stale checks, and action-required checks as not passing.
750
+
- The gate passes only if every check for the current up-to-date PR head is terminal success. Treat missing checks, pending checks, queued checks, failing checks, cancelled checks, timed-out checks, stale checks, report-mode migration checks, and action-required checks as not passing.
750
751
- If the gate is pending or missing, leave `Completion Candidate: true`, keep `Completed: false`, ensure `crane-migration` is present, ensure `crane-completed` is absent, set `Completion Gate Status: pending:<sha or reason>`, and end without completing.
751
752
- If the gate fails, leave `Completion Candidate: true`, keep `Completed: false`, ensure `crane-migration` is present, ensure `crane-completed` is absent, set `Completion Gate Status: failing:<signature>`, and fix the failing PR checks.
752
753
7. Only when the deterministic completion gate passes:
753
754
- Set `Completed: true` in the Machine State table.
754
-
- Set `Completed Reason` to a human-readable message that includes both the target metric and PR-head check evidence (e.g., `target metric 1.0 reached; PR #123 head abc1234 checks passed`).
755
+
- Set `Completed Reason` to a human-readable message that includes the target metric, PR head SHA, current base SHA, and check evidence (e.g., `target metric 1.0 reached; PR #123 head abc1234 contains base def5678 and strict checks passed`).
755
756
- Set `Completion Candidate: false`.
756
757
- Set `Completion Gate Status: passed:<sha>`.
757
758
-**For issue-based migrations**: remove the `crane-migration` label, add the `crane-completed` label.
758
759
- Update the status comment to [+] Completed.
759
760
- Post a celebratory per-iteration comment: `[+] **Migration complete!** {source} -> {target} finished after {N} iterations.`
760
761
- The migration will not be selected for future runs.
761
762
762
-
Do not enter final completion from repo-memory alone. A stored `Completed: true`, old `Completed Reason`, historical `best_metric`, or same-run sandbox score is only evidence about a previous or local run. Final completion requires deterministic evidence from the current PR head after safe outputs have pushed the branch and GitHub Actions has reported the head checks.
763
+
Do not enter final completion from repo-memory alone. A stored `Completed: true`, old `Completed Reason`, historical `best_metric`, or same-run sandbox score is only evidence about a previous or local run. Final completion requires deterministic evidence from the current PR head after safe outputs have pushed a branch that contains the current base SHA and GitHub Actions has reported strict checks for that up-to-date head.
763
764
764
765
### Open-Ended Migrations
765
766
@@ -810,7 +811,7 @@ When creating or updating a migration's state file, use this structure:
810
811
| Completed | false |
811
812
| Completed Reason | -- |
812
813
| Completion Candidate | false |
813
-
| Completion Gate | pr-head-checks |
814
+
| Completion Gate |up-to-date-pr-head-checks |
814
815
| Completion Gate Status | -- |
815
816
| Consecutive Errors | 0 |
816
817
| Recent Statuses | -- |
@@ -911,7 +912,7 @@ All iterations in reverse chronological order (newest first).
911
912
| Completed |`true` or `false`| Whether the deterministic completion gate has passed and the migration is final |
912
913
| Completed Reason | text or `--`| e.g., `target metric 1.0 reached; PR #123 head abc1234 checks passed`|
913
914
| Completion Candidate |`true` or `false`| Whether the target metric has been reached and the migration is waiting for deterministic PR-head checks |
914
-
| Completion Gate | text | Deterministic gate required for final completion. Default: `pr-head-checks`|
915
+
| Completion Gate | text | Deterministic gate required for final completion. Default: `up-to-date-pr-head-checks`|
915
916
| Completion Gate Status | text or `--`| Latest gate result, such as `pending:<sha>`, `failing:<signature>`, or `passed:<sha>`|
0 commit comments