Repository navigation
fix(batch): key each update on its branch, so group PRs with the same target stay apart - #198
Conversation
… 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
|
¡Oye! Sombra plugged in. Nice fix — I've seen exactly this bug bite monorepos before: two group PRs bumping FindingsP2 — The key-format change orphans every marker written by previous releases(also flagged inline on Every
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 P3 — Suppression now resets on any branch rename, not just group renamesThe 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 P4 —
|
Deploying with
|
| 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)) |
There was a problem hiding this comment.
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 == keyin the closed-by-owner check (prepare_with_controls) andclosed_forno longer match → every update an owner ever closed is recreated once (bounded only byprs.concurrent/perHour), and its closed receipt lapses.origins.contains(&update_key(p))inbatch::applynever matches a pre-upgrade batch's items → their plans aren't markedbatched; sincepatchula-closed:batcheddoesn't suppress, each in-flight item spawns a new individual PR while the batch still lists it. The new PRs carry new keys, soclose_batchedwon't touch them — they live beside their batch items until the batch closes.- Dashboard
Recreate/Createcheckboxes 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.
There was a problem hiding this comment.
¡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 == keyin the closed-by-owner check inprepare_with_controls(pull_requests.rs:476) andclosed_for(:283) won't match old markers → a new PR is created for every update an owner ever closed, bounded only byprs.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 markedbatched. Their individual PRs were already closed withpatchula-closed:batched— whichsuppresses()excludes — so each item gets a new individual PR while the batch still carries it. Those new PRs carry new keys, soclose_batchedwon'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/Createactions hold old keys) for one render cycle. reusable_bodyfails 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.mdnow warns that changingprs.branchresets suppression fleet-wide, "updates closed before the change can come back once". Verified againstconfig::model—prs.branchis 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.rsfixtures 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()/removedall 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.
There was a problem hiding this comment.
¡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.versionbump, optional, pairs with whatever you decide on P2.
No new issues introduced.
Verification
Read-through review; CI covers the tests.
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_keyhashed 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:origin == key), so only the last survivedbatch::applyskipped every plan whose key was an origin, so all three PRs closed as batchedcatalogs.rs) kept one plan's dependencies per keyChange
update_keyhashes 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), sodepartures.mdneeds no entry.guide/batch.md(one item per PR, including groups with the same target) andguide/pull-requests.md(suppression is per branch; renaming a group, or changingprs.branch, starts branches afresh).Upgrade effects (one time)
Tests
batch::tests::groups_bumping_the_same_target_are_separate_items: three group plans onpatchula/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.patchula-update,patchula-cli,patchula-engineandpatchula-servertests pass on the boat VM.Fixes #196