Skip to content

Fix stale Crane completion recovery#109

Merged
mrjf merged 1 commit into
mainfrom
codex/crane-stale-completed-gate
Jun 5, 2026
Merged

Fix stale Crane completion recovery#109
mrjf merged 1 commit into
mainfrom
codex/crane-stale-completed-gate

Conversation

@mrjf
Copy link
Copy Markdown
Contributor

@mrjf mrjf commented Jun 5, 2026

fix(crane): recover stale completed-label migrations

TL;DR

This fixes the scheduler path that let issue #78 stay marked complete even after the new deterministic Go cutover gate landed. The scheduler now treats crane-completed plus Completed: true as trustworthy only when it can positively confirm the current PR-head gate; no open migration PR, pending checks, failing checks, or unavailable check evidence makes the completion stale and selects the migration again.

Problem

  • Issue Crane Migration: Python to Go -- Full APM CLI Rewrite #78 had crane-completed and repo-memory Completed: true, but there was no open migration PR to validate.
  • The scheduler logged “no open migration PR was found” but did not mark the completion stale, so check_skip_conditions could still skip it as completed.
  • The real repo-memory heading is ## [*] Machine State; the parser treated [*] as a regex character class and could parse that file as empty in local reproduction.

Approach

Area Change
State parsing Parse the literal ## [*] Machine State heading and skip markdown separator rows.
Stale recovery Add evaluate_completed_label_recovery so completed-label issues require an affirmative PR-head gate.
Scheduler selection Treat no PR or unknown/failing gate as stale, add the migration to stale_completed_state, and keep it due.
Tests Add regression coverage for the real heading, no-open-PR stale recovery, and unknown-gate stale recovery.

Validation

.venv/bin/python -m pytest tests/unit/test_crane_scheduler.py -q
..........                                                               [100%]
10 passed in 0.43s

.venv/bin/python -m pytest tests/unit/test_crane_scheduler.py tests/unit/test_crane_workflow_prompt.py -q
...............                                                          [100%]
15 passed in 0.39s

python3 -m py_compile .github/workflows/scripts/crane_scheduler.py
git diff --check

Production-shaped local simulation against issue #78 and the current memory/crane state now emits:

{
  "selected": "crane-migration-python-to-go-full-apm-cli-rewrite",
  "selected_issue": 78,
  "stale_completed_state": [
    "crane-migration-python-to-go-full-apm-cli-rewrite"
  ],
  "skipped": [],
  "existing_pr": null
}

How to test

  1. Run pytest tests/unit/test_crane_scheduler.py -q.
  2. With Crane Migration: Python to Go -- Full APM CLI Rewrite #78 still labeled crane-completed and no open migration PR, run the scheduler with GITHUB_REPOSITORY=githubnext/apm.
  3. Confirm /tmp/gh-aw/crane.json contains the migration in stale_completed_state and does not list it under skipped.

Trade-offs

  • This errs on the side of reopening work when completion cannot be verified. That is intentional for Crane: missing deterministic evidence must not count as done.
  • I did not change workflow markdown, so gh aw compile is not required for this PR.

@mrjf mrjf merged commit 8347a32 into main Jun 5, 2026
13 checks passed
@mrjf mrjf deleted the codex/crane-stale-completed-gate branch June 5, 2026 16:27
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.

1 participant