Skip to content

Fix autoloop scheduler starvation: clone repo-memory before pre-step, deterministic tiebreak#163

Merged
mrjf merged 3 commits intomainfrom
copilot/fix-autoloop-pre-step-state-files
Apr 21, 2026
Merged

Fix autoloop scheduler starvation: clone repo-memory before pre-step, deterministic tiebreak#163
mrjf merged 3 commits intomainfrom
copilot/fix-autoloop-pre-step-state-files

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

The autoloop pre-step reads program state from /tmp/gh-aw/repo-memory/autoloop/, but gh-aw's built-in repo-memory clone runs after the pre-step (and into a different directory). Every program looks like a "first run", and the implicit insertion-order tiebreaker permanently starved build-tsb-pandas-typescript-migration behind perf-comparison for 8+ days.

Changes to .github/workflows/autoloop.md

  • Clone memory/autoloop before the scheduler runs. New first step in steps: clones the branch into /tmp/gh-aw/repo-memory/autoloop/ so the existing Python pre-step actually finds state files. Idempotent (skips if .git already present); falls back to an empty dir when the branch doesn't exist (genuine first run).

  • Auth via http.extraHeader instead of token-in-URL to keep the token out of process listings and any logged remote URLs.

  • Deterministic tiebreaker for the due-list sort. Replaces due.sort(key=lambda p: p["last_run"] or ""), which fell back to insertion order when last_run was absent. New key:

    • never-run programs sort before ever-run programs;
    • among never-run, shortest schedule wins, then alphabetical by name (programs without a parseable schedule fall back to +inf);
    • ever-run programs continue to sort by oldest last_run, then name.

    Each due entry now carries schedule_seconds to support this.

def _due_sort_key(p):
    if p["last_run"]:
        return (1, p["last_run"], p["name"])
    sched = p.get("schedule_seconds")
    return (0, sched if sched is not None else float("inf"), p["name"])
due.sort(key=_due_sort_key)

Effect

After merge, the pre-step should log build-tsb-pandas-typescript-migration: last_run=2026-04-12T11:15:07Z, iteration_count=230, that program wins the next selection on most-overdue, and ordinary last_run ordering takes over. The tiebreaker change is defense-in-depth: even if state goes missing again, every 30m beats every 6h instead of insertion order deciding.

Copilot AI changed the title [WIP] Fix autoloop pre-step to read state files correctly Fix autoloop scheduler starvation: clone repo-memory before pre-step, deterministic tiebreak Apr 21, 2026
Copilot finished work on behalf of mrjf April 21, 2026 04:33
Copilot AI requested a review from mrjf April 21, 2026 04:33
@mrjf mrjf marked this pull request as ready for review April 21, 2026 15:02
@mrjf mrjf merged commit c7e4339 into main Apr 21, 2026
17 checks passed
@mrjf mrjf deleted the copilot/fix-autoloop-pre-step-state-files branch April 21, 2026 15:07
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.

Autoloop pre-step can't read state files — build-tsb starved since 2026-04-12

2 participants