Skip to content

feat(update): show a rebasing banner while the Count rebuilds a branch - #361

Merged
sweepies merged 9 commits into
mainfrom
feat/rebasing-banner
Nov 23, 2026
Merged

sweepies merged 9 commits into
mainfrom
feat/rebasing-banner

Conversation

@sweepies

@sweepies sweepies commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Behaviour

While a rebuild takes long enough to notice, the Count shows a banner at the top of his part of the PR description, between <!-- patchula-begin --> and the ownership marker. Text outside his part is kept byte for byte. The banner is wrapped in <!-- patchula-rebasing --> … <!-- patchula-rebasing-end --> lines:

🦇 The Count is sinking his teeth into this branch: re-checking it against main…

The image is an <img width="80" height="32" alt="🦷 rebasing…"> (the Count's animated bat), so the alt text carries the meaning on its own. There is no timestamp; GitHub's "edited" note on the description gives the relative time.

Triggers

  • Re-check tick, server: the webhook handler spots an edit that newly ticks the re-check box of an open PR not yet showing a banner (acknowledgeable(before, pr)). Once the delivery is queued (not on duplicate deliveries), it starts a tracked acknowledgement task.
    • Ticks on the same PR take turns, so the second finds the banner up.
    • The task skips if a batch or remote run holds the repository or is waiting for it; that run, or the follow-up batch the tick queued, shows the banner.
    • Otherwise it shares the repository's lock (runs take it exclusively) while it reads the PR fresh and writes the banner. Acknowledgements of other PRs in the repository run alongside. The box stays ticked for the batch that does the work.
  • Re-check tick, CLI or Action: Lifecycle::announce runs right after the lifecycle is prepared and before lockfile generation. It shows the banner for planned plans whose open PR is ticked. Wording: "re-checking it against <base>…".
  • Lockfile regeneration: the same pass covers plans that still owe lockfile jobs and have an open PR. Wording: "rebuilding it on <base> and regenerating its lockfiles…".
  • Plain fast rebuilds: no banner. The final rewrite is still the only write.
  • A PR that already shows a banner gets no second one.

Clearing

  • Success: the end-of-rebuild rewrite replaces the banner. When the body could otherwise be reused, render reuses it without the banner, so the body hash differs and the PR gets one write.
  • Failed, held or protected rebuild: Lifecycle::acknowledge (formerly acknowledge_rechecks) takes the banner down and unticks the box. It tries every PR and returns the first error after the rest. If it fails, the repository fails, so no quiet-run answer is recorded and the server retries.
  • Run fails before rebuilding (cleanup error after announcing): Lifecycle::withdraw takes the banners down and leaves the ticks for the next run.
  • Count closes the PR (obsolete or batched): body::closure strips the banner.
  • Someone closes or merges a PR mid-rebuild while it shows a banner: this covers a banner this run wrote, one the server's acknowledgement wrote, or one left by a stopped run. The PR gets one body-only cleanup write on both the normal and the withdraw path, and stays closed.
  • A run that stopped mid-rebuild: that PR's own receipt is refused (rebasing-banner in restore_write), and the run isn't settled from receipts alone. Every other receipt still restores, and the acknowledgement pass clears the banner.

Pacing cost

Every banner write is a normal Client::patch, preceded by a fresh read, and both go through the existing write pacing. A slow rebuild costs one extra description write when its result rewrites the description anyway, and two when it would otherwise have left the description alone.

The server's acknowledgement writes through a clone of the installation engine's own GitHub client (Engine::github()), published next to the engine with the key it was built from. That way it shares the same write budget even while a batch holds the engine.

  • A discarded slot (panic or remote timeout) drops its client.
  • A client whose key no longer matches the settings isn't used; the engine is rebuilt first.

No new client type and no new write path.

Request counts in targeted_clicks_…:

  • CLI-style PR tick: 13 → 15 (the run's banner read and PATCH).
  • PR tick whose server banner is already up (new banner origin, beside unrelated open and owner-closed PRs): 13, with a single body PATCH.

Image URL

https://raw.githubusercontent.com/sweepies/count-patchula/v<version>/assets/rebasing.svg. <version> is env!("CARGO_PKG_VERSION"), the workspace version; it is not hard-coded and was not bumped.

I checked with curl -sI against an existing SVG in a public repository: raw.githubusercontent.com answers content-type: image/svg+xml with x-content-type-options: nosniff, which GitHub's image proxy accepts. The github.com/…/raw/… form only redirects there, so the raw URL is used directly.

On GitHub Enterprise Server without access to github.com, or offline, only the alt text shows; the docs say so.

Test transcripts mask /count-patchula/v<version>/assets/, so a release bump doesn't move the snapshots.

Image

assets/rebasing.svg is the animated bat; it replaced the first commit's static placeholder.

After review

An adversarial review found the following; all are fixed in d181d12, except finding 4, which was fixed earlier.

  1. A banner anywhere discarded every receipt in the repository. Now only the bannered PR's own receipt is refused (rebasing-banner), and complete also requires no banner, following the obsolete pattern. The test is a new banner origin in targeted_clicks_keep_unrelated_open_and_closed_receipts_fast: unrelated open and closed PRs stay restored (no extra requests between 3 and 6 dependencies, no unrelated PR fetched), no PR gets a banner, and there is one body PATCH.
  2. The server acknowledgement could overwrite a finished run's body. The original follow-up claim that this would self-heal was wrong: the server drops its own bot's edit webhooks, and the quiet sweep can hide the result for up to six hours. The fix makes it impossible:
    • Batches and remote runs hold a per-(installation, repository) lock for their whole run.
    • The acknowledgement try_locks it and skips if a run holds it. Otherwise it holds the lock across its fresh read and its write, so no run's write can land between them.
    • Concurrent ticks on the same PR serialize, and the second finds the banner up.
    • Acknowledgement tasks live in a tracked JoinSet, reaped as new ones start, drained at shutdown for up to 10 seconds, then aborted.
    • Test: acknowledgements_use_the_engine_client_and_never_race_a_run (server, real Engines with FakeGitHub).
  3. CRLF: insertion takes the start line's line ending, so a CRLF body gets a CRLF banner, and removal handles \r\n everywhere. Round-trip tests cover CRLF, LF, and an LF banner that GitHub turned into CRLF.
  4. Closures and mid-rebuild closes: closure strips the banner (unit test). PRs this run announced that someone closed or merged meanwhile get a body-only cleanup (a_banner_comes_down_when_the_pr_closes_mid_rebuild_or_the_run_stops).
  5. Leaks on failure:
    • On a cleanup failure, withdraw takes the banners down and keeps the ticks.
    • acknowledge tries every PR.
    • Settlement.acknowledged carries a failure, and the engine fails the repository on it, so record_quiet doesn't run and the server retries.
  6. Marker handling: markers match only as whole lines.
    • Every banner block (opening line, one > line, closing line, plus the blank line after) comes off.
    • Lone marker lines come off on their own, so text between stray markers is never removed.
    • A marker inside prose isn't a banner.
    • Tests in pr/banner.rs.
  7. Server costs and stale clients:
    • No acknowledgement task or read for a closed or already-bannered PR (checked from the payload).
    • Stale Engines.writers entries are dropped on slot discard and ignored on a key mismatch.
    • Engines::writer and acknowledge_tick are tested as above.

Housekeeping: catalog-controls stays at 27 (bumped once in this PR); only its hash changed.

Re-check (a8701df)

A second review confirmed the seven fixes above and found five more problems:

  • N1. The cleanup of PRs closed or merged mid-rebuild only covered banners this run had written. Banners the server wrote, or a stopped run left behind, stayed on the closed PR.
    • The lifecycle now tracks every open PR of his that shows a banner when it is prepared, plus those its announcement writes.
    • A PR leaves that set once a clean body is written to it or the Count closes it.
    • The acknowledgement and withdrawal passes take the banner down on any PR in the set that was closed or merged meanwhile.
    • Tests:
      • a_server_banner_comes_down_when_the_pr_closes_mid_run_or_the_repository_fails (engine, normal path).
      • a_cleanup_failure_withdraws_the_banner_and_keeps_the_tick, open and closed variants (engine, withdraw path).
  • N2. At shutdown, acknowledgements were only drained after the worker had finished. They now drain beside the worker once the HTTP listener stops, so a stuck one is bounded by its own 10 seconds and can't hold up a batch waiting for its repository. After the outer deadline, any left are aborted and joined before work is released. The task set stays behind an async lock, so a drain that gets cut short leaves its tasks for the final abort. Test: acknowledgements_drain_within_their_bound (completion, and abort at exactly 10 seconds).
  • N3. The per-repository lock was a mutex, so an acknowledgement for one PR could make another PR's acknowledgement in the same repository skip. The fix:
    • Each repository has a read/write lock: runs take it exclusively, acknowledgements try to share it.
    • Each PR has its own lock, so two ticks on the same PR really wait for each other; unused PR locks are dropped.
    • The engine-client test covers two quick ticks on two PRs (both get a banner) and two on the same PR (one write).
  • N4. When the start marker had lost its line break, with_banner glued the banner marker onto it. The banner now always starts on its own line; removing it leaves the start marker on its own line, and from then on the round trip is exact. Unit test.
  • N5. Test gaps:

Second re-check (7329bec)

A third review confirmed N1–N5 and found two remaining problems:

  • R1. A run that didn't complete left the earlier quiet-run row in place, so the scheduled sweep could skip a repository with a stuck banner for up to six hours.
    • record_runs now clears the repository's quiet-run row (Engine::clear_quiet, built on Cache::clear_state) on every outcome other than Complete.
    • The engine test didn't actually check this: it used a config override, so the sweep could never find a stored answer either way. It now reads the repository's own patchula.pkl and asserts that the sweep skips the repository after the successful run and runs it in full after the failed one.
    • internals/engine.md and guide/pull-requests.md say so.
  • R2. An obsolete PR showing a banner, closed by its owner between the open listing and the closure's fresh read, dropped out of bannered and kept its banner.
    • bannered is now filled right after the open listing, before any fresh read.
    • The Count's own obsolete closure removes the PR from bannered, as close_batched does.
    • Test: an_obsolete_bannered_pr_never_keeps_its_banner_however_it_closes. In the Count-closes case, the closure has no banner and nothing more is written. In the owner-closes case, the acknowledgement pass strips the banner and the PR stays closed.

The catalog-controls hash was updated (still version 27).

Third re-check (28fe47a)

  • R3. A run stopped after announce wrote a banner never reached record_runs; this covers a remote run hitting its time limit, an OOM, a panic, or a killed server. Remote jobs aren't requeued, so the earlier quiet-run row survived and the sweep could skip the stuck banner for up to six hours.
    • Write::repository now clears the repository's quiet-run row before the first banner goes up.
    • The clear runs only when the run will announce or its PRs already carry a banner (Lifecycle::may_leave_banners, which shares announce's selection), so plain fast runs and receipt-restored runs write nothing extra.
    • If the row can't be cleared, the run shows no banner and adds a warning.
    • A completing run records a fresh row at the end as before.
    • Test: a_run_stopped_after_its_banner_leaves_the_sweep_no_answer_to_skip_with. Each stopped run gets its own engine over the shared cache, through a transport that stops answering for good after a chosen request.
      • A repository-wide re-check (no banner), stopped at its PR read, leaves the sweep's answer standing.
      • A ticked PR, stopped right after its banner write, leaves the banner up and no answer for the sweep.
      • With the clear disabled, the test fails.
    • guide/pull-requests.md and internals/engine.md say so.

The catalog-controls hash was updated (still version 27).

Follow-ups

  • A lockfile rebuild that would leave the branch and description unchanged still shows and clears the banner, because the Count can't know the result before the tools run.

Fourth re-check

R3 verified fixed: may_leave_banners and announce share one selection, so the clear before the first banner can't drift from what's written. Nothing else remained except R4, a race in the new stopped-run test: the release-notes prefetch runs beside the banner write, so a stop right after that write could vary the recorded requests. That test now turns release notes off. It passed 10 times in a row on the same transcript hash, and the engine suite and parity are green.

A ticked re-check box or a rebuild that regenerates lockfiles now puts a
banner at the top of the Count's part of the PR description, with an
animated image pinned to the running release. The server shows it as soon
as the tick arrives; a CLI or Action run shows it when it reaches the PR.
The final rewrite takes it down, a failed or held rebuild's
acknowledgement pass does too, and a banner left by a stopped run keeps
the next run off the receipts path until it is gone.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula 28fe47a Commit Preview URL

Branch Preview URL
Nov 23 2026, 12:19 AM

…everywhere

A banner refuses only its own PR's receipt instead of every receipt in
the repository. The server's acknowledgement holds the repository across
its read and write and skips while a run holds it, its tasks are drained
at shutdown, and a closed or already bannered PR costs no read. Banner
markers are matched as whole CRLF-aware lines, every block comes off and
stray markers never take text with them. Closures, PRs closed mid-rebuild
and runs that stop before rebuilding take the banner down, the
acknowledgement pass tries every PR, and its failure fails the repository
so no quiet-run answer hides a banner left up.
…nowledgements run side by side

The lifecycle tracks every open PR showing a banner when it is prepared,
not only the ones its announcement wrote, so a banner the server put up
comes down when someone closes or merges the PR mid-run, on the normal
and the withdraw path. Server acknowledgements share a per-repository
read lock that runs take exclusively, take turns per PR, and drain beside
the worker at shutdown, aborted and joined when the deadline passes. The
banner always opens its own line after the start marker.
A failed or stale run now removes the repository's quiet-run row, so the
sweep cannot skip a repository whose banner a failed run left up. The
lifecycle records bannered PRs off the open listing, before any fresh
read, and drops one only after the Count's own closure, so an obsolete
PR its owner closes during preparation still loses its banner.
…er goes up

A run that may leave a banner up — one that will announce, or whose PRs
already carry one — removes the repository's quiet-run row before the
banner is written, so a run killed or timed out before record_runs never
leaves the sweep an earlier answer to skip a stuck banner with. Plain and
receipt-restored runs write nothing extra; a run that cannot remove the
row shows no banner.
@sweepies
sweepies merged commit 5ac90fe into main Nov 23, 2026
12 checks passed
@sweepies
sweepies deleted the feat/rebasing-banner branch November 23, 2026 00:42
@sweepies-ops sweepies-ops Bot mentioned this pull request Nov 23, 2026
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