Repository navigation
Description
Found by: #802's pg_merge_group e2e (review merge dialog bundle)
What is wrong
GET /v1/orgs/{org}/datasets/{ds}/merge-plans shows nothing for the entity that
survives a steward/assertion merge — the exact entity a steward just pinned a
master on. After resolving a review as "match" (or merging a group via
POST /merges), the plans list stays empty of the merged result.
Mechanism
er_golden::merge_plans_sql scopes the read with
affected AS (SELECT DISTINCT entity_id FROM entity_events
WHERE event_type IN ('merged','member_added'))keyed on the entity_id the event names. In er-reconcile::reconcile_plan:
- a
mergedevent is recorded on the absorbed entity id (the one that
leavesentity_membership), with the survivor named only in
details.merged_into— which no read follows; member_addedfires on the survivor only for records that had no prior
entity (!entity_of_record.contains_key(m)). An assertion merge combines
records that were all already clustered, sojoinedis empty and the
survivor earns no event at all.
The absorbed ids then drop out of plan_groups (no members left), so the net
result is an empty plans list for the merge that just happened. The same shape
likely hides pure recluster moves (a split event names the receiver, but
split is not in the CTE).
pg_protect_master never hit this because its organic merge arrives with a
brand-new bridging record, which does earn the survivor a member_added.
Where the fix lives
rust/crates/er-golden/src/master.rs (merge_plans_sql, a governed generator
with plan-vector coverage in er-sql-check) and/or
rust/crates/er-reconcile/src/reconcile.rs (emit an event on the claimant when
it absorbs an entity — e.g. follow merged_into in affected, or record
member_added for members whose entity changed, not only for previously
unclustered records). Decide which layer owns the invariant before patching;
the event ledger is user-visible via write-back/webhooks.
Reproduce
DEDUPE_E2E_DUCKLAKE=1 ER_TEST_PG_DSN=... cargo test -p er-server --test main pg_merge_group
with a plan_master assertion against the merged survivor (the assertion this
ticket removed from that test, with a comment pointing here).
Product context (2026-11-26)
Why this matters for the API product: this affects results and merge-gate trust. GET …/merge-plans is in the public contract (viewer), and it is the read that tells a customer which record survives a merge. Because of this bug, the read is empty right after the customer's own merge through POST …/merges or reviews/{id}/resolve. Both of those are public, steward-level calls.
Current state: still unfixed on main.
er-golden/src/master.rs:206-208still keysaffectedonevent_type IN ('merged','member_added').er-golden/src/master.rshas not changed since chore(docs): remove the docs/ directory, moving each record to the skill that owns it #786.er-reconcile/src/reconcile.rs:362-376still recordsmergedonly on the absorbed id, with the survivor named indetails.merged_into.- The workaround comment is still in place at
er-server/tests/pg_merge_group.rs:309. - The ticket's mention of write-back and webhooks needs updating. Salesforce writeback is pruned. Webhooks (
/v1/orgs/{org}/webhooks) andruns/{id}/entity-eventsare public, so the event ledger is still customer-visible.
Definition of done: as above, plus:
- the
plan_masterassertion is restored inpg_merge_group; - a split/recluster case is covered;
- the er-sql-check plan vector is updated.
Dependencies / sequencing: none blocking. Fix it at the read layer by following merged_into in affected. That leaves the public event ledger unchanged, which avoids a contract change to entity-events.
Size: about 0.5 engineer-weeks.
Activity
fix(read): merge-plans shows the survivor of a merge and both sides o…