Skip to content

fix(batch): key each update on its branch, so group PRs with the same target stay apart - #198

Merged
sweepies merged 2 commits into
mainfrom
fix/batch-group-update-key
Nov 6, 2026
Merged

sweepies merged 2 commits into
mainfrom
fix/batch-group-update-key

Conversation

@sweepies

@sweepies sweepies commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Problem

#196: in a monorepo with one group per service, a shared dependency gets one PR per service, each bumping to the same version. Ticking "Add to the batch PR" on all three closed all three, but the batch carried only one service's change.

update_key hashed only the targets (source, package, value, version, digest), so the three PRs shared a key. It is used as a per-PR identity in several places, so the collision broke more than batching:

  • batch items replaced each other (items match on origin == key), so only the last survived
  • batch::apply skipped every plan whose key was an origin, so all three PRs closed as batched
  • unticking one batch item sent all three back
  • closing one service's PR suppressed the same update for the other services
  • the dashboard's "create it now" and "bring back" boxes acted on all three
  • the engine's control targets (catalogs.rs) kept one plan's dependencies per key

Change

  • update_key hashes the PR's branch together with its targets, so a key names exactly one PR and every consumer tells the groups apart without changes of its own. Closed-update suppression now belongs to the branch, as in Renovate (which matches closed PRs by branch and title), so departures.md needs no entry.
  • Docs: guide/batch.md (one item per PR, including groups with the same target) and guide/pull-requests.md (suppression is per branch; renaming a group, or changing prs.branch, starts branches afresh).

Upgrade effects (one time)

  • Every open update PR's body is rewritten once, because its marker key changes.
  • Updates closed before the upgrade are no longer suppressed and may reopen; closing them again suppresses them as before.
  • A batch PR open at upgrade keeps its items, but those items no longer match their plans, so the updates also reopen as their own PRs until the batch merges or they're closed. Merging or closing open batch PRs before upgrading avoids this.
  • Dashboard "create it now" and "bring back" boxes rendered before the upgrade hold old keys, so ticking one does nothing until the dashboard is next rendered (the first run after the upgrade).

Tests

  • batch::tests::groups_bumping_the_same_target_are_separate_items: three group plans on patchula/service-{a,b,c} with the same target get distinct keys, all three ticked PRs become batch items, and unticking one leaves two. It fails against the old key.
  • The CLI test that builds historical closed-PR markers by hand now hashes the branch too.
  • patchula-update, patchula-cli, patchula-engine and patchula-server tests pass on the boat VM.

Fixes #196

View guided diff Turn on auto-fix

… target stay apart

The update key hashed only the targets (source, package, value, version,
digest), but it is used as one PR's identity: batch items, the PRs a batch
closes, closed-update suppression, the batched-PR hold, dashboard controls and
the engine's control targets. Groups on separate branches that bump the same
dependency to the same version, such as one group per service in a monorepo,
shared a key. Ticking all three into the batch closed all three PRs but kept
one item; unticking one item sent all three back; closing one service's PR
suppressed the update for the others.

The key now hashes the PR's branch with its targets, so it names exactly one
PR and every consumer tells the groups apart.

Upgrading changes every key once: open PR bodies are rewritten once, updates
closed before the upgrade are no longer suppressed and may reopen, and items in
a batch PR open at upgrade no longer match their plans, so those updates also
reopen as their own PRs until the batch merges.

Fixes #196
@olivia-colomar-app

olivia-colomar-app Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

¡Oye! Sombra plugged in. Nice fix — I've seen exactly this bug bite monorepos before: two group PRs bumping shared to the same version used to collapse into one batch item, and closing one quietly suppressed them all. Keying update_key on (branch, targets) is the right shape, the serialization is unambiguous (a 2-element JSON tuple — escaping makes it collision-proof), and the new unit test covers the one-group-per-service scenario well. Pero… I found one skeleton in the closet.

Findings

P2 — The key-format change orphans every marker written by previous releases

(also flagged inline on pull_requests.rs)

Every update value already embedded in PR bodies, batch Item.origins and dashboard checkboxes was hashed the old way — targets only. Everywhere a stored key meets a computed key now mismatches:

  • Owner-closed updates resurrect. m.update == key in the closed-by-owner check in prepare_with_controls (pull_requests.rs:476) and closed_for (:283) won't match old markers → a new PR is created for every update an owner ever closed, bounded only by prs.concurrent/prs.perHour. The closed receipts lapse with them.
  • In-flight batches desync. origins.contains(&update_key(p)) (batch.rs:179) never matches a pre-upgrade batch's items, so those plans aren't marked batched. Their individual PRs were already closed with patchula-closed:batched — which suppresses() excludes — so each item gets a new individual PR while the batch still carries it. Those new PRs carry new keys, so close_batched won't touch them; they ride beside their batch items until the batch closes. Open ticked PRs still work, since both sides compare stored keys there — only the closed-into-batch items dupe.
  • Pre-rendered dashboard checkboxes go dead (Recreate/Create actions hold old keys) for one render cycle.
  • reusable_body fails on all open PRs → one extra body render + release-notes fetch each. Cosmetic.

It all converges after a run or two, so this is bounded — but for a fleet install it's a noisy upgrade: a burst of reopened PRs owners deliberately closed, plus duplicates in every live batch. Cheap bridges if you want one: keep a legacy_update_key with the old derivation and accept either at the stored-vs-computed comparisons (m.update == key || m.update == legacy, origins.contains(...)), or bump Marker.version to 2 and apply the old derivation to v1 markers. If the churn is intended, a line in the release notes ("closed updates reopen once; live batches may briefly duplicate items") would save someone a pager.

P3 — Suppression now resets on any branch rename, not just group renames

The docs call out "renaming a group starts its branch afresh", which is honest. Worth also noting that anything that renames branches globally — e.g. changing prs.branch prefix — drops every closed-update suppression at once, same mechanism as above. One more sentence in pull-requests.md would set expectations.

P4 — Marker.version stays 1 though the derivation changed

The marker schema didn't change, so this is defensible — but a bump would make stored keys self-describing when debugging mixed-version inventories (and pairs naturally with the migration option in P2).

What looks good

  • (branch, targets) as a serde tuple is injective — no hash-input ambiguity, no way for a branch name containing JSON metacharacters to forge a collision.
  • cli/src/tests.rs fixtures mirror the new derivation exactly (["patchula/{pkg}-2.x", [[...]]]), so the closed-suppression path is still genuinely exercised.
  • Maintenance plans keep their maintenance:{fingerprint} namespace — untouched, correctly.
  • items()/render()/removed all stay consistent because origins are always read from stored markers, never recomputed — the only seams that break are the four listed above.

Verification

Read-through review; CI covers the tests. Unit/integration jobs were still pending when I looked — worth a green run before merge given the fixture churn.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 6, 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 db20ea0 Commit Preview URL

Branch Preview URL
Nov 06 2026, 06:55 PM

.collect();
hash(
serde_json::to_string(&targets)
serde_json::to_string(&(&plan.action.branch, targets))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the key derivation invalidates every update value already stored in PR markers, batch Item.origins and dashboard checkboxes written by previous releases — every place a stored key meets a computed one now mismatches:

  • m.update == key in the closed-by-owner check (prepare_with_controls) and closed_for no longer match → every update an owner ever closed is recreated once (bounded only by prs.concurrent/perHour), and its closed receipt lapses.
  • origins.contains(&update_key(p)) in batch::apply never matches a pre-upgrade batch's items → their plans aren't marked batched; since patchula-closed:batched doesn't suppress, each in-flight item spawns a new individual PR while the batch still lists it. The new PRs carry new keys, so close_batched won't touch them — they live beside their batch items until the batch closes.
  • Dashboard Recreate/Create checkboxes rendered before the deploy contain old keys and silently no-op.

If the churn is intentional it's worth a release note. Otherwise a cheap bridge is a legacy_update_key (old derivation) accepted alongside the new key at the stored-vs-computed comparisons — or bump Marker.version and apply the old derivation to v1 markers.

@olivia-colomar-app olivia-colomar-app Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¡Oye! Sombra plugged in. Nice fix — I've seen exactly this bug bite monorepos before: two group PRs bumping shared to the same version used to collapse into one batch item, and closing one quietly suppressed them all. Keying update_key on (branch, targets) is the right shape, the serialization is unambiguous (a 2-element JSON tuple — escaping makes it collision-proof), and the new unit test covers the one-group-per-service scenario well. Pero… I found one skeleton in the closet.

Findings

P2 — The key-format change orphans every marker written by previous releases

(also flagged inline on pull_requests.rs)

Every update value already embedded in PR bodies, batch Item.origins and dashboard checkboxes was hashed the old way — targets only. Everywhere a stored key meets a computed key now mismatches:

  • Owner-closed updates resurrect. m.update == key in the closed-by-owner check in prepare_with_controls (pull_requests.rs:476) and closed_for (:283) won't match old markers → a new PR is created for every update an owner ever closed, bounded only by prs.concurrent/prs.perHour. The closed receipts lapse with them.
  • In-flight batches desync. origins.contains(&update_key(p)) (batch.rs:179) never matches a pre-upgrade batch's items, so those plans aren't marked batched. Their individual PRs were already closed with patchula-closed:batched — which suppresses() excludes — so each item gets a new individual PR while the batch still carries it. Those new PRs carry new keys, so close_batched won't touch them; they ride beside their batch items until the batch closes. Open ticked PRs still work, since both sides compare stored keys there — only the closed-into-batch items dupe.
  • Pre-rendered dashboard checkboxes go dead (Recreate/Create actions hold old keys) for one render cycle.
  • reusable_body fails on all open PRs → one extra body render + release-notes fetch each. Cosmetic.

It all converges after a run or two, so this is bounded — but for a fleet install it's a noisy upgrade: a burst of reopened PRs owners deliberately closed, plus duplicates in every live batch. Cheap bridges if you want one: keep a legacy_update_key with the old derivation and accept either at the stored-vs-computed comparisons (m.update == key || m.update == legacy, origins.contains(...)), or bump Marker.version to 2 and apply the old derivation to v1 markers. If the churn is intended, a line in the release notes ("closed updates reopen once; live batches may briefly duplicate items") would save someone a pager.

P4 — Marker.version stays 1 though the derivation changed

The marker schema didn't change, so this is defensible — but a bump would make stored keys self-describing when debugging mixed-version inventories (and pairs naturally with the migration option in P2).

Resolved

  • P3 — Suppression now resets on any branch rename, not just group renames. Fixed in db20ea018d: pull-requests.md now warns that changing prs.branch resets suppression fleet-wide, "updates closed before the change can come back once". Verified against config::model — prs.branch is the documented key and the claim matches the mechanism.

What looks good

  • (branch, targets) as a serde tuple is injective — no hash-input ambiguity, no way for a branch name containing JSON metacharacters to forge a collision.
  • cli/src/tests.rs fixtures mirror the new derivation exactly (["patchula/{pkg}-2.x", [[...]]]), so the closed-suppression path is still genuinely exercised.
  • Maintenance plans keep their maintenance:{fingerprint} namespace — untouched, correctly.
  • items()/render()/removed all stay consistent because origins are always read from stored markers, never recomputed — the only seams that break are the four listed above.

Verification

Read-through review; CI covers the tests. Unit/integration jobs were still pending when I looked — worth a green run before merge given the fixture churn.

@olivia-colomar-app olivia-colomar-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¡Bueno! Sombra sweeped the new commit — db20ea018d is docs-only and lands exactly on the P3: pull-requests.md now warns that changing prs.branch resets closed-update suppression across every branch. Checked it against config::model — that's the real key and the wording matches the mechanism. Marked resolved on my previous comment.

Still standing:

  • P2 (inline on pull_requests.rs) — the upgrade-time side of the same coin: markers written by previous releases orphan on deploy, so closed updates reopen once and live batches briefly duplicate items. The new doc covers config-triggered resets, not the one-shot churn this release itself causes. If that's intentional, it wants a line in the release notes rather than the guide.
  • P4 — Marker.version bump, optional, pairs with whatever you decide on P2.

No new issues introduced.

Verification

Read-through review; CI covers the tests.

@sweepies
sweepies merged commit 0c620ac into main Nov 6, 2026
12 checks passed
@sweepies
sweepies deleted the fix/batch-group-update-key branch November 6, 2026 19:05
This was referenced Nov 6, 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.

per-service group PRs that bump the same dependency close together, but only one service lands in the batch

1 participant