unmerge discards survivor and decision writes made after the merge

Aperta
#386 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
database

Direzione di ricerca

Start with src/selfgraph/resolution.ts, reading unmerge around the cited lines and trace how it uses the merge record and current entity or decision state. Reproduce both cases with the Kuzu backend, then run the relevant tests or add focused regressions. Done means unmerge removes only merge additions, preserves later writes and decision edits, and matches the no-merge replay.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: write bug effort: M P1

Summary

unmerge reverts the survivor entity and a touched decision to the state captured in the merge record, discarding writes made to them after the merge. The docs say unmerging leaves exactly what the inserts would have written without the merge, and that a decision keeps edits made after the merge, but later writes are lost.

Reproductions (0.2.2, Kuzu backend)

Survivor aliases and properties re-added by a later write are stripped
g = SelfGraph(store=KuzuStore(path), namespace="e", resolver="exact")
await g.initialize()
await g.insert.facts({"entities": [{"type": "Person", "name": "Ann Lee", "aliases": ["AL"]}]})
r = await g.insert.facts({"entities": [{"type": "Person", "name": "AL", "aliases": ["Annie"], "properties": {"k": 1}}]}, resolver="default")
# "AL" merges into person:ann-lee, adding alias "Annie" and k=1.
await g.insert.facts({"entities": [{"type": "Person", "name": "Ann Lee", "aliases": ["Annie"], "properties": {"k": 2}}]})
# A later explicit write that also sets alias "Annie" and k=2.
await g.entities.unmerge(r.merges[0].id)

e = await g.entities.get("person:ann-lee")
# Observed: aliases ['AL'], properties {}.  Expected: aliases ['AL', 'Annie'], properties {'k': 2}.
Decision outcome and alternatives revert to the pre-merge snapshot
# Insert 1 merges and records decision d with outcome person:xavier.
# Insert 2 upserts the same decision id with outcome person:yolanda.
# After unmerge: outcome reverts to person:xavier (expected: person:yolanda).

Cause

In src/selfgraph/resolution.py, unmerge:

  • removes survivor aliases and properties by name with remove_aliases=list(rec.added_aliases) / remove_properties=list(rec.added_properties) (around lines 1419 to 1420), so a key re-added by a later write is stripped;
  • rebuilds a decision's outcome_entity and alternative_entities from the merge record's original / rewritten snapshot (around lines 1344 to 1370) instead of the decision's current version, while it does take the other fields from the current version.

Expected

Unmerge removes only the merge's own additions and keeps any value a later write set, and a decision keeps its post-merge outcome and alternatives, so unmerge-all equals the no-merge replay.

Lingua principale
TypeScript
Stelle
173
Fork
58
Merge medio
6h
PR unite (30g)
120

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hydra-db/selfgraph

Tutte le issue di hydra-db/selfgraph

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.