unmerge deletes a relation an independent insert reasserted on the survivor (data loss)

Abierto
#385 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript

Línea de trabajo

Read src/selfgraph/resolution.py around unmerge (lines 1180–1305) and trace how rewritten relations, their versions, and evidence are restored before runner.delete_edges runs. Reproduce with the Kuzu example in the issue, then check existing unmerge tests for coverage. Done means unmerging removes only the merge’s contribution and preserves the independent survivor relation, matching the no-merge replay.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area: write bug effort: M P1

Summary

unmerge deletes a relation that an independent insert created on the survivor after the merge, causing silent data loss. The docs state that unmerging every merge of an insert leaves exactly what the inserts would have written without the merge, but here a relation written after the merge is removed entirely.

Reproduction (0.2.2, Kuzu backend)

g = SelfGraph(store=KuzuStore(path), namespace="e", resolver="exact")
await g.initialize()
await g.insert.facts({"entities": [{"type": "Person", "name": "Bob Ray"}, {"type": "Company", "name": "Zed Inc"}]}, source_id="seed")
r = await g.insert.facts(
    {"entities": [{"type": "Person", "name": "Bob Raye"}],
     "relations": [{"from_entity": "person:bob-raye", "type": "WORKS_AT", "to_entity": "company:zed"}]},
    resolver="fuzzy", source_id="s2")
# "Bob Raye" resolves and merges into person:bob-ray; the relation is rewritten onto person:bob-ray.
await g.insert.facts(
    {"relations": [{"from_entity": "person:bob-ray", "type": "WORKS_AT", "to_entity": "company:zed"}]}, source_id="s3")
# An independent, explicit bob-ray -> zed from a different source.
await g.entities.unmerge(r.merges[0].id)

# Observed: only person:bob-raye -> company:zed remains (carrying 2 sources). person:bob-ray -> company:zed is gone.
# Expected (what the same inserts produce with resolver="exact", no merge): both relations present,
#   person:bob-ray -> zed and person:bob-raye -> zed.

Cause

In src/selfgraph/resolution.py, unmerge (around lines 1180 to 1305) restores each rewritten relation by reading the survivor-side relation's current versions and evidence, then runner.delete_edges(ns, rw.id) removes every version of it and writes the relation back onto the absorbed endpoint. It cannot distinguish the merge's own contribution from an independent assertion made on the survivor after the merge, so the later write is deleted with it.

Expected

Unmerge removes only the merge's contribution and leaves relations written independently after the merge in place, so unmerge-all equals the no-merge replay.

Lenguaje dominante
TypeScript
Estrellas
173
Forks
58
Merge medio
6 h
PR fusionados (30 d)
120

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de hydra-db/selfgraph

Todos los issues de hydra-db/selfgraph

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.