Skip to content

flake_history: refresh saves day by day under a time budget (port of gitgalaxy #5793) - #15

Merged
squid-protocol merged 1 commit into
mainfrom
port/flake-cache-budget
Oct 21, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
port/flake-cache-budget

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Port of squid-protocol/gitgalaxy#5793. I applied it as a patch from that branch with paths renamed, not with sync.py push.

Cause

In GitGalaxy, a cold 14-day refresh took about 2 minutes per day, but refresh() wrote the cache only after the last day. The step's timeout killed it first, nothing was saved, and the next pass started over. On 2026-10-20 that happened on 78 of 79 shepherd reconcile passes, at 12.2 minutes and one runner slot each.

Change

src/squid_bot/flake_history.py:

  • Fetches missing days first (newest first), then today and yesterday again.
  • Saves after every day.
  • --budget-s N starts no new day after N seconds.
  • updated is set only when the whole window is in, so an unfinished cache still reads as stale and the next refresh carries on.

save() and refresh() now match GitGalaxy's word for word. templates/workflows/shepherd-reconcile.yml has no flake-refresh step, so it needs no change.

Tests

tests/test_flake_history.py gets two new tests:

  • A refresh that runs out of time keeps its days, stays stale, and the next one carries on in the right order.
  • A refresh killed partway keeps every finished day.

pytest -q tests: 133 passed, 5 skipped. Ruff shows the same 3 findings as main, none new.

🤖 Generated with Claude Code

…gitgalaxy #5793)

A cold 14-day refresh (~2 min a day on GitGalaxy) wrote the cache only at the
end; killed by its step's timeout it saved nothing and the next pass started
over (2026-10-20: 78 of 79 reconcile passes spent 12.2 min there). Now missing
days come first (newest first), then today and yesterday; the cache is saved
after every day; --budget-s starts no new day after the budget; `updated` is
set only when the whole window is in, so an unfinished cache stays stale.

The shepherd-reconcile template has no flake refresh step, so no workflow change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@squid-protocol
squid-protocol merged commit 53b95fe into main Oct 21, 2026
1 check passed
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