Skip to content

Commit 701b6aa

Browse files
Copilotmrjf
andauthored
Merge origin/main and resolve marketplace conflict
Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
2 parents bf5ad77 + ff3334a commit 701b6aa

28 files changed

Lines changed: 14632 additions & 30837 deletions

.crane/scripts/score.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ type CutoverGates struct {
6464
FunctionalContracts float64 `json:"functional_contracts"`
6565
StateDiffContracts float64 `json:"state_diff_contracts"`
6666
PythonBehaviorContracts float64 `json:"python_behavior_contracts"`
67+
UpstreamFreshness string `json:"upstream_freshness"`
68+
UpstreamContracts float64 `json:"upstream_contracts"`
6769
GoldenFixtureCorpus string `json:"golden_fixture_corpus"`
6870
AllGoGoldenTests string `json:"all_go_golden_tests"`
6971
NoPythonRuntime string `json:"no_python_runtime_dependency"`
@@ -104,6 +106,8 @@ type Score struct {
104106
PythonTestsPassing bool `json:"python_tests_passing"`
105107
GoTestsPassing bool `json:"go_tests_passing"`
106108
BenchmarksPassing bool `json:"benchmarks_passing"`
109+
UpstreamFreshness bool `json:"upstream_freshness"`
110+
UpstreamContracts float64 `json:"upstream_contracts"`
107111
GoldenFixtureCorpus bool `json:"golden_fixture_corpus"`
108112
AllGoGoldenTests bool `json:"all_go_golden_tests"`
109113
NoPythonRuntime bool `json:"no_python_runtime_dependency"`
@@ -152,6 +156,8 @@ func computeScore(input scanInput, getenv getenvFunc) (Score, error) {
152156
functional := RatioGate{}
153157
stateDiff := RatioGate{}
154158
behaviorContracts := RatioGate{}
159+
upstreamFreshness := BoolGate{}
160+
upstreamContracts := RatioGate{}
155161
goldenFixtureCorpus := BoolGate{}
156162
allGoGoldenTests := BoolGate{}
157163
noPythonRuntime := BoolGate{}
@@ -172,6 +178,8 @@ func computeScore(input scanInput, getenv getenvFunc) (Score, error) {
172178
&functional,
173179
&stateDiff,
174180
&behaviorContracts,
181+
&upstreamFreshness,
182+
&upstreamContracts,
175183
&goldenFixtureCorpus,
176184
&allGoGoldenTests,
177185
&noPythonRuntime,
@@ -199,6 +207,8 @@ func computeScore(input scanInput, getenv getenvFunc) (Score, error) {
199207
&functional,
200208
&stateDiff,
201209
&behaviorContracts,
210+
&upstreamFreshness,
211+
&upstreamContracts,
202212
&goldenFixtureCorpus,
203213
&allGoGoldenTests,
204214
&noPythonRuntime,
@@ -283,6 +293,12 @@ func computeScore(input scanInput, getenv getenvFunc) (Score, error) {
283293
if !behaviorContracts.Seen {
284294
behaviorContracts = missingRatioGate()
285295
}
296+
if !upstreamFreshness.Seen {
297+
upstreamFreshness = BoolGate{Seen: true, Passed: false}
298+
}
299+
if !upstreamContracts.Seen {
300+
upstreamContracts = missingRatioGate()
301+
}
286302
if !pythonTests.Seen {
287303
pythonTests = BoolGate{Seen: true, Passed: testPassed(passed, failed, "TestParityCompletionPythonSuite")}
288304
}
@@ -302,6 +318,8 @@ func computeScore(input scanInput, getenv getenvFunc) (Score, error) {
302318
FunctionalContracts: functional.Percent(),
303319
StateDiffContracts: stateDiff.Percent(),
304320
PythonBehaviorContracts: behaviorContracts.Percent(),
321+
UpstreamFreshness: passFail(upstreamFreshness.OK()),
322+
UpstreamContracts: upstreamContracts.Percent(),
305323
GoldenFixtureCorpus: passFail(goldenFixtureCorpus.OK()),
306324
AllGoGoldenTests: passFail(allGoGoldenTests.OK()),
307325
NoPythonRuntime: passFail(noPythonRuntime.OK()),
@@ -328,6 +346,8 @@ func computeScore(input scanInput, getenv getenvFunc) (Score, error) {
328346
gates.FunctionalContracts == 1.0 &&
329347
gates.StateDiffContracts == 1.0 &&
330348
gates.PythonBehaviorContracts == 1.0 &&
349+
gates.UpstreamFreshness == "pass" &&
350+
gates.UpstreamContracts == 1.0 &&
331351
gates.GoldenFixtureCorpus == "pass" &&
332352
gates.AllGoGoldenTests == "pass" &&
333353
gates.NoPythonRuntime == "pass" &&
@@ -372,6 +392,8 @@ func computeScore(input scanInput, getenv getenvFunc) (Score, error) {
372392
PythonTestsPassing: gates.PythonTests == "pass",
373393
GoTestsPassing: gates.GoTests == "pass",
374394
BenchmarksPassing: gates.Benchmarks == "pass",
395+
UpstreamFreshness: gates.UpstreamFreshness == "pass",
396+
UpstreamContracts: gates.UpstreamContracts,
375397
GoldenFixtureCorpus: gates.GoldenFixtureCorpus == "pass",
376398
AllGoGoldenTests: gates.AllGoGoldenTests == "pass",
377399
NoPythonRuntime: gates.NoPythonRuntime == "pass",
@@ -405,6 +427,8 @@ func applyGateEvent(
405427
functional *RatioGate,
406428
stateDiff *RatioGate,
407429
behaviorContracts *RatioGate,
430+
upstreamFreshness *BoolGate,
431+
upstreamContracts *RatioGate,
408432
goldenFixtureCorpus *BoolGate,
409433
allGoGoldenTests *BoolGate,
410434
noPythonRuntime *BoolGate,
@@ -427,6 +451,10 @@ func applyGateEvent(
427451
*stateDiff = RatioGate{Seen: true, Passing: gate.Passing, Total: gate.Total}
428452
case "python_behavior_contracts":
429453
*behaviorContracts = RatioGate{Seen: true, Passing: gate.Passing, Total: gate.Total}
454+
case "upstream_freshness":
455+
*upstreamFreshness = BoolGate{Seen: true, Passed: gate.Passed}
456+
case "upstream_contracts":
457+
*upstreamContracts = RatioGate{Seen: true, Passing: gate.Passing, Total: gate.Total}
430458
case "golden_fixture_corpus":
431459
*goldenFixtureCorpus = BoolGate{Seen: true, Passed: gate.Passed}
432460
case "all_go_golden_tests":
@@ -485,6 +513,8 @@ func gateResults(gates CutoverGates) []GateResult {
485513
{Name: "functional_contracts", Passing: gates.FunctionalContracts == 1.0},
486514
{Name: "state_diff_contracts", Passing: gates.StateDiffContracts == 1.0},
487515
{Name: "python_behavior_contracts", Passing: gates.PythonBehaviorContracts == 1.0},
516+
{Name: "upstream_freshness", Passing: gates.UpstreamFreshness == "pass"},
517+
{Name: "upstream_contracts", Passing: gates.UpstreamContracts == 1.0},
488518
{Name: "golden_fixture_corpus", Passing: gates.GoldenFixtureCorpus == "pass"},
489519
{Name: "all_go_golden_tests", Passing: gates.AllGoGoldenTests == "pass"},
490520
{Name: "no_python_runtime_dependency", Passing: gates.NoPythonRuntime == "pass"},

.github/aw/actions-lock.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@
3535
"version": "v7",
3636
"sha": "043fb46d1a93c77aae656e7c1c64a875d1fc6a0a"
3737
},
38-
"github/gh-aw-actions/setup-cli@v0.74.4": {
39-
"repo": "github/gh-aw-actions/setup-cli",
40-
"version": "v0.74.4",
41-
"sha": "d3abfe96a194bce3a523ed2093ddedd5704cdf62"
42-
},
4338
"github/gh-aw-actions/setup@v0.74.4": {
4439
"repo": "github/gh-aw-actions/setup",
4540
"version": "v0.74.4",

.github/workflows/crane.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ The pre-step fetches open issues with the `crane-migration` label via the GitHub
247247
When a migration is issue-based, `/tmp/gh-aw/crane.json` includes:
248248
- **`selected_issue`**: The issue number (e.g., `42`) if the selected migration came from an issue, or `null` if it came from a file.
249249
- **`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.
251251

252252
### Reading Migrations
253253

@@ -261,7 +261,7 @@ The pre-step has already determined which migration to run. Read `/tmp/gh-aw/cra
261261
- **`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.
262262
- **`state_file_size_bytes`** / **`state_file_max_bytes`**: For rolling-compaction decisions (see [Update Rules](#update-rules)).
263263
- **`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.
265265
- **`deferred`**: Other migrations that were due but will be handled in future runs.
266266
- **`unconfigured`**: Migrations that still have the sentinel or placeholder content.
267267
- **`skipped`**: Migrations not due yet based on their per-migration schedule, or completed/paused.
@@ -277,7 +277,7 @@ If `selected` is not null:
277277
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.
278278
5. If `selected_issue` is not null, also read the issue comments for any human steering input.
279279
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`.
281281

282282
## Multiple Migrations
283283

@@ -617,7 +617,7 @@ If `status == "failure"`, **fix and retry -- do not revert, do not accept**:
617617
- Update **[docs] Lessons Learned** if this iteration revealed something new (e.g. a bridging trick, a parity surprise, a perf trap).
618618
- Update **[scope] Future Work** if this iteration opened new threads.
619619
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.
621621

622622
**If the score did not improve**:
623623
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**
727727

728728
## Halting Condition
729729

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.
731731

732732
### How It Works
733733

@@ -737,29 +737,30 @@ Migrations are usually **goal-oriented** -- you want to finish. Set `target-metr
737737
4. For `lower` direction: the target is reached when `best_metric <= target-metric`.
738738
5. When the target is reached, create a completion candidate instead of completing immediately:
739739
- Set `Completion Candidate: true`.
740-
- Set `Completion Gate: pr-head-checks`.
740+
- Set `Completion Gate: up-to-date-pr-head-checks`.
741741
- Set `Completion Gate Status: pending`.
742742
- Keep `Completed: false` and `Completed Reason: --`.
743743
- For issue-based migrations, keep the `crane-migration` label and do not add `crane-completed`.
744744
- Update the status comment to Active with a note that the migration is waiting on deterministic PR-head checks.
745745
6. On the next run while `Completion Candidate: true`, run the deterministic completion gate before making code changes:
746746
- 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.
748749
- 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.
750751
- 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.
751752
- 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.
752753
7. Only when the deterministic completion gate passes:
753754
- 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`).
755756
- Set `Completion Candidate: false`.
756757
- Set `Completion Gate Status: passed:<sha>`.
757758
- **For issue-based migrations**: remove the `crane-migration` label, add the `crane-completed` label.
758759
- Update the status comment to [+] Completed.
759760
- Post a celebratory per-iteration comment: `[+] **Migration complete!** {source} -> {target} finished after {N} iterations.`
760761
- The migration will not be selected for future runs.
761762

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.
763764

764765
### Open-Ended Migrations
765766

@@ -810,7 +811,7 @@ When creating or updating a migration's state file, use this structure:
810811
| Completed | false |
811812
| Completed Reason | -- |
812813
| Completion Candidate | false |
813-
| Completion Gate | pr-head-checks |
814+
| Completion Gate | up-to-date-pr-head-checks |
814815
| Completion Gate Status | -- |
815816
| Consecutive Errors | 0 |
816817
| Recent Statuses | -- |
@@ -911,7 +912,7 @@ All iterations in reverse chronological order (newest first).
911912
| Completed | `true` or `false` | Whether the deterministic completion gate has passed and the migration is final |
912913
| Completed Reason | text or `--` | e.g., `target metric 1.0 reached; PR #123 head abc1234 checks passed` |
913914
| 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` |
915916
| Completion Gate Status | text or `--` | Latest gate result, such as `pending:<sha>`, `failing:<signature>`, or `passed:<sha>` |
916917
| Consecutive Errors | integer | Count of consecutive verification failures |
917918
| Recent Statuses | comma-separated | Last 10 outcomes: `accepted`, `rejected`, `error`, or `ci-fix-exhausted` |

0 commit comments

Comments
 (0)