Skip to content

Extract Autoloop scheduler from inline heredoc into a committed Python script#40

Merged
mrjf merged 4 commits intomainfrom
copilot/extract-scheduler-script
Apr 23, 2026
Merged

Extract Autoloop scheduler from inline heredoc into a committed Python script#40
mrjf merged 4 commits intomainfrom
copilot/extract-scheduler-script

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

The ~470-line inline node - << 'JSEOF' scheduler in workflows/autoloop.md is approaching GitHub Actions' compiled run: expression size limit, and is unreachable to linters, type-checkers, and unit tests. Sibling proposals add ~30–60 LOC each to the scheduler — extraction is a prerequisite.

Changes

  • New workflows/scripts/autoloop_scheduler.py — stdlib-only Python (os, re, json, glob, urllib, datetime) with named, importable helpers: parse_machine_state, parse_schedule, parse_program_frontmatter, is_unconfigured, check_skip_conditions, select_program, slugify_issue_title, parse_link_header, plus a main() entry point.
  • Workflow shrinksworkflows/autoloop.md "Check which programs are due" step is now a one-liner; lock file and dogfooded .github/workflows/autoloop.md updated in lockstep, and a byte-identical copy of the script lives at .github/workflows/scripts/ so the install copy step (cp -r workflows/ .github/workflows/) needs no change.
  • Tests rewiredtests/conftest.py imports the script directly via importlib (replacing JS-extraction-via-Node.js subprocess). Existing 100 tests in test_scheduling.py preserved via thin shims for shape differences.
  • New tests/test_scheduler_e2e.py — 9 fixture-based subprocess tests exercising main(): more-overdue selection, never-run priority, missing state file → first run, paused/completed → skipped, AUTOLOOP_PROGRAM=<name> forced bypass (incl. forcing a paused program), unknown forced name → error, no programs found.
  • AGENTS.md documents the new workflows/scripts/ directory in the repo layout and deployment steps.
  - name: Check which programs are due
    env:
      GITHUB_TOKEN: ${{ github.token }}
      GITHUB_REPOSITORY: ${{ github.repository }}
      AUTOLOOP_PROGRAM: ${{ github.event.inputs.program }}
    run: |
      python3 .github/workflows/scripts/autoloop_scheduler.py

Net diff: workflows/autoloop.md 1179 → 717 lines; .github/workflows/autoloop.md 837 → 694 lines; lock file's inline scheduler collapses to one shell line. 109/109 tests pass; CodeQL clean.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/bogus.invalid/bogus/issues
    • Triggering command: /usr/bin/python /usr/bin/python /home/REDACTED/work/autoloop/autoloop/workflows/scripts/autoloop_scheduler.py (http block)
    • Triggering command: /usr/bin/python /usr/bin/python /home/REDACTED/work/autoloop/autoloop/workflows/scripts/autoloop_scheduler.py _ _ _ _ -- /tmp/codeql-scratch-dfc165ae3c2123cd/dbs/actions/db-actions /tmp/codeql-scratch-dfc165ae3c2123cd/dbs/actions/trap/actions (http block)
    • Triggering command: /usr/bin/python /usr/bin/python /home/REDACTED/work/autoloop/autoloop/workflows/scripts/autoloop_scheduler.py /tmp/codeql-tNmmIe/pr-diff-range --extension-packs codeql-action/pr-diff-range /tmp/codeql-scratch-dfc165ae3c2123cd/dbs/actions codeql/actions-queries (http block)
  • https://api.github.com/repos/test/test/issues
    • Triggering command: /usr/bin/python3 python3 /home/REDACTED/work/autoloop/autoloop/workflows/scripts/autoloop_scheduler.py (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Extract the scheduler into a committed script Extract Autoloop scheduler from inline heredoc into a committed Python script Apr 22, 2026
Copilot finished work on behalf of mrjf April 22, 2026 22:29
Copilot AI requested a review from mrjf April 22, 2026 22:29
@mrjf mrjf marked this pull request as ready for review April 23, 2026 00:31
@mrjf
Copy link
Copy Markdown
Contributor

mrjf commented Apr 23, 2026

@copilot fix failing tests

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 23, 2026

@copilot fix failing tests

Fixed in 53ce1c2 — CI was missing pyyaml, which the pre-existing test_lock_creds_before_merge test imports. Added it to the pip install step in .github/workflows/tests.yml.

Copilot finished work on behalf of mrjf April 23, 2026 00:34
@mrjf mrjf merged commit e3eecbf into main Apr 23, 2026
1 check passed
@mrjf mrjf deleted the copilot/extract-scheduler-script branch April 23, 2026 00:34
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.

Extract the scheduler from the inline heredoc into a committed script

2 participants