Skip to content

schedule-kick keep-on: an "every" entry keeps all workflows on but the ones meant to be off (#867) - #1276

Merged
scuttletoby merged 3 commits into
mainfrom
fork/867-keep-on-every
Nov 29, 2026
Merged

scuttletoby merged 3 commits into
mainfrom
fork/867-keep-on-every

Conversation

@scuttletoby

Copy link
Copy Markdown
Owner

What

Part 1 of #867: schedule-kick keep-on can keep every workflow of a repository on, not only named ones.

  • "every": true entries. A keepOn entry with "every": true and an off object, in place of workflows, turns back on every workflow of the repository that is disabled_manually or disabled_inactivity, except the ones off names. Each off name needs the reason it is meant to be off (1 to 200 characters, at most 100 names). off is required: {} is the owner's word that none is meant to be off. off without every, or every with workflows, is refused.
  • Never switches one off. A workflow in off is left as it is. If it is on, the status says listed as off but active. A workflow GitHub lists as deleted is skipped.
  • The owner hears of a surprise. The first re-enable of each workflow under every also sends an alert-channel message ("if it is meant to be off, add it to off with the reason"). That way a workflow switched off on purpose but left out of off gets noticed instead of being kept on silently. Later re-enables are journal lines, as for named entries.
  • Fails closed on a full page. The entry reads one page of the list (100 workflows). A full page is an error and nothing is turned on, because it cannot tell it saw them all.
  • Who switched it off, where GitHub says so. Every re-enable line (named entries too) now says what GitHub's state tells: disabled_manually is a person or a token (the repository API does not say which; the owner's security log does, action:workflows.disable_workflow), and disabled_inactivity is GitHub itself after 60 days without activity.
  • schedule-kick check prints an every entry with its off names. README: the Keep-on section (renamed "Keep-on: turn workflows back on") and the config example.

Nothing changes for an existing config: named entries work as before, and only their re-enable line gets the "who" part at the end.

Before switching this fork to every: 29 of its 46 workflows are disabled_manually today (upstream's CI, release, mobile and preview workflows, plus a few old canary or scratch files that GitHub still lists). Each needs an off line, or the first pass turns it on (and sends one alert each). The machine's config is private, so this PR does not write it.

Left for later parts of #867: an entry for each project repository (config only, once this lands), and a single place that shows the status of every entry.

Tests (red, then green)

fork-kit/schedule-kick/tests/keepon.test.py. Run against origin/main's lib/, the 6 new tests fail (5 errors, 1 failure) and so does RedCheck. With the change, all 27 pass. The other schedule-kick test files (kick, heads, cron, install, late) pass too.

  • Every.test_every_workflow_is_kept_on_but_the_ones_meant_to_be_off: are the off workflows not named in off turned back on, while an off workflow stays off, an off workflow that is on is never switched off, and a deleted one is skipped?
  • Every.test_the_owner_hears_of_the_first_re_enable_of_each_workflow_only: does the first re-enable send one alert, and a second switch-off of the same workflow only a journal line?
  • Every.test_a_full_page_is_an_error_since_it_cannot_tell_it_saw_every_workflow: with 100 rows, is nothing turned on and the entry an error with an alert?
  • Every.test_a_list_error_names_the_whole_entry: does a list error show as OWNER/REPO (every workflow)?
  • Every.test_the_config_needs_the_off_list_and_a_reason_for_each: are a missing off, an empty or non-text reason, a bad file name, every with workflows, off without every, and a non-boolean every all refused, and does check print the entry?
  • KeepOn.test_a_re_enable_says_what_github_tells_about_who_switched_it_off: does each re-enable line say who switched it off, for both off states?
  • RedCheck gets 5 rows: the off list, the deleted skip, first re-enable only, the full page, and the reasons. Each shows its test fails without the rule.

.github/fork-ci-tests.txt: unchanged. The file still runs in about 1 s.

Checks

vp fmt / vp lint on the changed files. The fork-checks scripts (schema, upstream files, seams) pass against origin/main.

Part of #867

🤖 Generated with Claude Code

…e ones meant to be off (#867)

A keepOn entry with "every": true and an "off" list (each workflow with the
reason it is meant to be off) keeps every workflow of the repository on, not
only named ones. Its first re-enable of a workflow also tells the owner over
the alert channel. A full page of workflows is an error, since it cannot tell
it saw them all. Each re-enable line says what GitHub's state tells about who
switched it off (a person or a token, or GitHub for inactivity).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: code · reviewer: Claude Opus 5.5 (code lens) · read at: 3acc202

blocker: none
major: no guard against a mass re-enable. Reproduced: an every entry with "off": {} and 29 disabled_manually workflows (this fork today) turns on all 29 in its first pass, exit 0, 29 alerts. A stale or half-written off list does the same for whatever it misses. Keep-on never switches anything off, and the machine guards refuse agent disables, so undoing it is 29 owner-only steps, while upstream's CI, release, mobile and preview workflows start running on every push. Guard to add: the first pass of an every entry (no state under the repo yet) only reports, listing what it would turn on, and turns nothing on until the owner confirms (for example "confirmed": true, or the list written to state and a second pass). Also add a cap per pass (for example more than 3 re-enables in one every pass is an error with one alert, and nothing is turned on).
major: the "first re-enable" message is never sent if the first try fails. Reproduced: send returns (False, 'alert command exit 1') on the first re-enable, so reenabled becomes 1. The workflow is switched off again two hours later and the send now works, but it is re-enable number 2, so no alert. A failed alert command means the owner is never told. The same happens when the pass stops between api.enable and write_json: the next pass finds the workflow active and never tells. Fix: keep a told flag that is set only when send returns True, and alert on every pass (at most once an hour) while a re-enabled workflow under every has told false. Set a pending mark in state before enable, so a stop half-way is still reported.
minor: an off name that no longer matches a workflow (renamed or deleted) shows only in keep-on-status.json, as result off. Reproduced: exit 0, ok: true, nothing printed, no alert. That is reported, but nobody will look. Print it to the journal, or make status --keep-on show it.
minor: off names are matched by exact case. Reproduced: "ci.yml" in off with the repository's CI.yml disabled turns CI.yml on. The alert does fire, so it is noticed, but a name that matches only without case could be refused or warned about.
minor: when the list works, the prune drops the OWNER/REPO * key and its alertedAt (it is not in kept). A list error that comes and goes then alerts on every failing pass, not once an hour. Keep the * key in the prune.

Checked and fine: a missing, wrong-type or reasonless off, every together with workflows, and off without every are all refused at config load, so nothing runs (fails closed). A list error, a rate limit or a full page of 100 turns nothing on. Manual and inactivity are read from GitHub's state field. A deleted workflow and paths outside .github/workflows/ (dynamic workflows) are skipped. An off workflow that is on is never switched off. One entry per repository is enforced, so named and every entries cannot fight over state keys. No token reaches any output: the error paths are unchanged, and the new lines carry only states and names.

Tests: I ran the PR's keepon.test.py against origin/main's lib through the fork test runner. The 5 Every tests error in setUp and test_a_re_enable_says_what_github_tells_about_who_switched_it_off fails; the 5 new RedCheck rows fail too ("text is not in keepon.py"). On the branch the fork-kit test shards are green on 3acc202. So all 6 new tests are red on main and green on the branch.

State question:

  • Runs again: one list call per entry, and an active workflow gets no call. The first-re-enable alert is keyed on the reenabled counter in keep-on.json, so it is once per workflow across runs and restarts. If the send fails, it is never (major 2).
  • Stops half-way: the state is written whole at the end, so a stop after enable loses the counter. The next pass sees it active, so it is not enabled twice, but the owner is never told (major 2).
  • Old or empty state: keep-on.json that is broken or from another version reads as empty, so every later re-enable alerts again as a "first" one. That is noisy but safe. Moving a repository from named entries to every keeps the named targets' counters, so those are not re-announced (fine).
  • Empty off ({}) means "none meant to be off" by design. On this fork, with no first-pass guard, that is the mass re-enable in major 1.

🤖 Generated with Claude Code

… told only after a send (#867)

Fix round 1 for the code lens on #1276.

- An `every` entry's first pass (no `OWNER/REPO *` record yet) turns nothing on: it holds the workflows it
  would turn on, shows them as `held`, and sends one alert listing them. Later passes turn on only workflows
  that go off after it. `schedule-kick keep-on --accept OWNER/REPO` clears the held list; an `off` line, or the
  workflow coming on by other means, drops one from it. Broken or missing state is a first pass again.
- `maxPerPass` (every entries, default 3, 1 to 20): a pass that would turn on more turns on none, is an error,
  and alerts at most once an hour while it lasts.
- The first-re-enable message: a `pending` mark is written before the enable call, `told` is set only after the
  send works; a failed send or a pass that stops after the enable tells on the next pass.
- `off` names match file names without case; a case-only or stale name is a status warning (`ok` stays true),
  printed by `check` from the last pass's status file.
- The `OWNER/REPO *` record survives the prune, so a list error that comes and goes alerts once an hour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

Fix

Round 1 for the code lens (#1276 (comment)). Head 111bd80558.

Major 1: mass re-enable guard.

  • First pass only reports. An every entry's first pass (no OWNER/REPO * record in keep-on.json yet) turns nothing on. It records what it would turn on as held, shows each one as held in the status (plus a warnings line), and sends one alert that lists them. Later passes turn on only workflows that go off after that first pass.
  • How a workflow leaves held. It is listed in off (then it is left off), it comes on by other means (then it is kept on like the rest), or the owner runs schedule-kick keep-on --accept OWNER/REPO, which clears the held list. --accept before any first pass, or for a repository without an every entry, does nothing and exits 1. On this fork with "off": {}, the first pass now sends one message naming the 29 workflows and turns none of them on.
  • maxPerPass (an every entry's key, 1 to 20, default 3). A pass that would turn on more turns on none: the entry is an error (exit 1), the workflows show as held, and one alert names them, at most once an hour while it lasts (its own capAlertedAt, so a list-error alert does not hide it). --accept warns when the held list is bigger than the cap.

Major 2: the owner is told. Before the enable call, keep-on.json gets a pending mark (told: false), written at once. told: true is set, and pending cleared, only when the send returns True. Any later pass that sees pending on a workflow tells the owner then: after a failed send, or when a pass stopped after the enable. If the enable call fails, the mark is dropped. A target with re-enables from a named entry and no told field counts as told, since it was named to be kept on.

Minors.

  • A stale off name, or one that matches a file name only without case, goes into the status's warnings; ok stays true. schedule-kick check prints the last pass's warnings (it still makes no call itself).
  • off names match file names without case: ci.yml covers CI.yml, and a warning asks for the exact case.
  • The prune keeps the OWNER/REPO * record, so a list error that comes and goes alerts at most once an hour.

State question.

  • Runs again: the held list, told and pending live in keep-on.json, so nothing is turned on or announced twice. An active workflow still needs no call. The held list is sent once, and resent only if that send failed.
  • Stops half-way:
    • Stopped after the enable but before the final write: the pending mark is already on disk, so the next pass finds the workflow active and tells the owner.
    • Stopped before the enable: the next pass enables it and tells.
    • Stopped after a first pass recorded its held list in memory but before writing it: the next pass is a first pass again, which only reports. The worst case is the held-list message twice.
  • Old, empty or missing state: read as empty, so the next pass is a first pass. It turns nothing on and lists what is off. That is the safe side: a lost held list never turns on everything. A * record from this PR's previous version (alert times only, no held) also counts as no first pass. Named entries are unchanged.

Tests (fork-kit/schedule-kick/tests/keepon.test.py, 36 pass). There are 10 new or changed Every tests: first pass only reports (29 off), --accept and off release held ones, the cap, a failed held-list send, a failed re-enable send, a stop after the enable, a named counter counts as told, broken state is a first pass, case-insensitive and stale off with check output, and a list error once an hour. Against this PR's previous lib/, 9 of them fail (7 failures, 2 errors). The tenth, "named counter counts as told", keeps the old behaviour, so it passes on both. RedCheck has 9 new rows, and each one's test fails without its rule.

The other schedule-kick files: heads, cron and install pass, and so do kick's Config, Tick, Grace, Faults and Command classes (57 tests). Not run here: kick.test.py's Transports and RedCheck, and late.test.py. They serve on 127.0.0.1, which this machine blocks, so CI runs them. vp fmt / vp lint ran on the changed files (pre-commit hook too). The README Keep-on section and its config example are updated.

🤖 Generated with Claude Code

@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: code · reviewer: Claude Opus 5.5 (code lens, round 2) · read at: 111bd80

blocker: none
major: a failed tell or held-list send is retried on every pass (every 15 s), with no once-an-hour limit. Reproduced: two re-enabled workflows and a send that fails give 8 send attempts in 4 passes (45 s); a failed held-list send is tried on all 4 passes. On a machine with no alert channel (journal only, which channel_alert allows), told never becomes true, so pending stays for good and each such workflow prints an error line every 15 s for good (5760 a day). Worse, when the alert command hangs (timeoutSeconds defaults to 60, and the keep-on service has TimeoutStartSec=2min), two pending tells use up the whole pass. systemd kills it before the later targets and the final write, and the pending marks on disk make the next pass do the same. So while the alert channel is down, keep-on stops turning workflows back on, which is its main job. Fix: limit retries as problem() does, for example a tellTriedAt / heldTriedAt time with ALERT_EVERY, so a failed send is tried again at most once an hour; pending still makes sure the owner is told in the end.
minor: --accept with more held workflows than maxPerPass can never turn them on, since maxPerPass is at most 20. Reproduced: 29 held, maxPerPass 20, --accept (exit 0, with the warning), then 3 passes: 0 enables, exit 1 on each. The warning says to raise maxPerPass, which cannot get past 20. Say instead to put some in off for now, or to switch them on by hand.
minor: a workflow kept on by a named entry, which happens to be off at the first pass after the repository moves to every, is held, not turned on. Reproduced: named fork-tests.yml with a counter, switched off, then the first every pass gives result held and 0 enables. The owner is alerted and the window is short (the grid switches it off every 20 minutes, and keep-on runs every 15 s), but a target that already has a re-enable counter could be left out of the first pass's held list.

Round 1, fixed: the mass re-enable (the first pass only reports, held plus one alert, --accept, and the maxPerPass cap). With "off": {} and 29 off workflows, nothing is turned on and one message names them. Round 1, fixed: "told" before the send (pending is written before the enable, and told is set only after the send works). Round 1, fixed: the minors (stale or case-only off names go into the warnings, off matches without case, and the prune keeps the * record).

Checked and fine: an old * record (alert times only) or a list-error record counts as no first pass. A full page or a list error returns before the held logic, so held is kept. An enable failure drops pending but keeps told: false, so the next re-enable is told. A held workflow that comes on, or goes into off, leaves the held list. The cap's extra workflows are held for that pass only, not written to the held list. --accept takes the blocking lock and refuses a missing first pass or an entry without every. check reads the same status file that keep-on writes. Config validation is unchanged and still fails closed.

State question:

  • Runs again: the held list, heldTold, told and pending are in keep-on.json, so nothing is turned on or announced twice when sends work. When a send fails, it is retried on every pass with no limit (the major above).
  • Stops half-way: pending is written before the enable, so a stop after the enable is told on the next pass. A first pass stopped before its write is a first pass again, which only reports. A stop caused by a hanging alert command repeats on every pass (the major above).
  • Old, broken or missing keep-on.json: read as empty, so the next pass is a first pass. That is the safe side: everything off at that moment is held, and one alert is sent. That includes workflows that named entries used to keep on (minor 2).

Tests: I ran only a probe of 4 tests against the PR head, built on the PR's own Every fixture: the retry counts, the cap after --accept, and named-to-every. I did not re-run what CI runs.

🤖 Generated with Claude Code

… hour

- Alert-channel messages (errors, the held list, first re-enables) are queued
  and sent only after every entry's enables are done and written. Each target
  tries one at most once an hour, sent or not (tellTriedAt, heldTriedAt, and
  the existing alertedAt/capAlertedAt), and a pass stops at its first failed
  send, so no alert channel, or a hanging alert command, never stops keep-on
  from turning workflows back on and logs one line an hour, not one a pass.
- --accept with more held than maxPerPass no longer says to raise maxPerPass
  (at most 20): it says to turn the rest on by hand or release them via "off".
- The first "every" pass no longer holds a workflow a named entry kept on (its
  re-enable counter): it is turned on as before the move.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

Round-2 fixes (9e1342e):

  • major, failed sends retried every pass and able to starve the enables: alert-channel messages (errors, held list, first re-enables) are now queued and sent after every entry's enables are done and written. Each target tries one at most once an hour, sent or not (tellTriedAt, heldTriedAt, same limiter as alertedAt), and a pass stops at its first failed send. The try time is written before the send, so a hanging command stopped by systemd also waits its hour. Tests: Every.test_a_failed_send_is_tried_again_once_an_hour, Every.test_a_failed_held_list_message_is_tried_again_once_an_hour, Every.test_a_hanging_alert_command_never_holds_up_the_enables. All three failed before the fix.
  • minor, --accept with more than maxPerPass held: the warning no longer says to raise maxPerPass (at most 20). It says to turn the rest on by hand (gh workflow enable), or put some in off for now and take them out a few at a time. The README says the same. Test: Every.test_accepting_more_than_max_per_pass_says_what_works.
  • minor, named to every: the first pass does not hold a workflow that has a named entry's re-enable counter (told()), so it is turned on. Test: Every.test_moving_from_named_entries_to_every_turns_the_named_ones_on_at_the_first_pass.

RedCheck: updated the mutations for the moved code, and added mutations for the named-entry rule, one failed send a pass, and the try being written before a send. keepon.test.py: 39 tests OK locally. kick.test.py is unchanged and was not run here (it hangs on this machine's blocked local TCP).

🤖 Generated with Claude Code

@scuttletoby scuttletoby added the fork:merge-ready Merge conveyor: lenses done, merge when green (PRs) label Nov 29, 2026
@scuttletoby

Copy link
Copy Markdown
Owner Author

override for head 9e1342e: round-2 fix diff read by the orchestrator (last round, no round 3): outbox runs after the enables, the hourly tried-at is saved before the send, and the loop stops on the first failed send. Fixed as the round-2 lens asked.

@scuttletoby
scuttletoby merged commit 434eb33 into main Nov 29, 2026
27 checks passed
@scuttletoby
scuttletoby deleted the fork/867-keep-on-every branch November 29, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork:merge-ready Merge conveyor: lenses done, merge when green (PRs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant