Replaying two same-time max_count rivals flips the current relation under supersede
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- databases
Direzione di ricerca
Start in src/selfgraph/_ops.py at _reasserts and trace how replayed relations with equal effective and invalidation times are handled; then check how Contradictions.settle ranks the tied rivals. Reproduce with the supplied script for both omitted and shared event_time. Done when repeated identical inserts keep the same relation current, with a regression test covering both cases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happens
Under contradiction="supersede", inserting the same facts again flips which relation is current at a max_count endpoint when two rival relations in the batch share an effective time. Each replay writes a new revision of the loser, which then wins, so the current fact alternates between runs.
This happens both when the relations have no event_time (the usual case for extracted text) and when they share one through the insert's event_time. With distinct event times the replay is stable.
docs/schema.md, "Reading and reasserting a retired relation", says replaying the same inputs is idempotent. Related to #48, but here nothing is restated with a different date: the input is identical every time.
Reproduce
On main (5a277c9), embedded Kuzu:
import asyncio, tempfile
from selfgraph import KuzuStore, SelfGraph
SCHEMA = {
"entities": [{"name": "Person"}, {"name": "Company"}],
"relations": [{"type": "WORKS_AT", "from": {"types": ["Person"], "max_count": 1}, "to": {"types": ["Company"]}}],
}
FACTS = {
"entities": [{"type": "Person", "name": "Ann"}, {"type": "Company", "name": "Acme"},
{"type": "Company", "name": "Globex"}],
"relations": [
{"from_entity": "person:ann", "type": "WORKS_AT", "to_entity": "company:acme"},
{"from_entity": "person:ann", "type": "WORKS_AT", "to_entity": "company:globex"},
],
}
async def main():
with tempfile.TemporaryDirectory() as tmp:
async with SelfGraph(store=KuzuStore(f"{tmp}/g.kuzu"), schema=SCHEMA, contradiction="supersede") as g:
for i in range(3):
await g.insert.facts(FACTS)
rels = (await g.relations.list(include_invalidated=True)).items
print(i, sorted((r.to_entity, r.revision, r.is_current) for r in rels))
asyncio.run(main())
Output:
0 [('company:acme', 1, False), ('company:globex', 1, True)]
1 [('company:acme', 2, True), ('company:globex', 1, False)]
2 [('company:acme', 2, False), ('company:globex', 2, True)]
insert.facts(FACTS, event_time="2024-01-01") prints the same sequence.
Cause
src/selfgraph/_ops.py, _reasserts: effective >= prev.invalidated_at counts a replay at the same time as a reassertion, so the retired rival comes back as a new revision. Contradictions.settle then ranks the tie the other way and retires the other one.
- Lingua principale
- TypeScript
- Stelle
- 173
- Fork
- 58
- Merge medio
- 6h
- PR unite (30g)
- 120
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hydra-db/selfgraph
-
approved-for-pr area: cli-mcp area: errors bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
hydra-db/selfgraph#401 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: errors area: store bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
hydra-db/selfgraph#398 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: errors area: write bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
hydra-db/selfgraph#392 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: parity area: write bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
hydra-db/selfgraph#391 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di hydra-db/selfgraph
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
code-yeongyu/senpi#7139 ·
I maintainer di solito rispondono entro 1 giorno
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
lingdojo/kana-dojo#34395 · 1 commento · 5 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
bug status: needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mastra-ai/mastra#31093 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area:web p2 product:business triage:active type:bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 89/100
cuadrao-ai/argus#2328 ·
I maintainer di solito rispondono entro 1 giorno
-
bug frontend good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
nikhilb2/simple_invoicing#907 ·