Dropped extracted decisions and preferences still write their steps and entities

Abierto
#342 2 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
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
66/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python, typescript

Línea de trabajo

Start with _assemble in src/selfgraph/extraction/extractor.py, focusing on the decision and preference loops and how add_relation and resolve() register writes. Reproduce both cases from the issue against embedded Kuzu, then inspect the relevant extraction tests. Done when dropped items leave no relations or fallback entities in the graph, while valid items still persist.

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

Descripción

approved-for-pr area: extraction bug effort: S P2

What happens

When insert.text drops an extracted decision or preference as invalid, parts of it are still written:

  • A decision dropped for an empty or control-character title still writes the relations its steps named.
  • A preference dropped for a bad strength or key still creates its subject and value as Thing entities.

The warning says the item was dropped, but the graph holds what the item created.

Reproduce

On main (5a277c9), embedded Kuzu:

import asyncio, tempfile
from selfgraph import KuzuStore, SelfGraph

class LLM:
    def __init__(self, **replies):
        self.replies = replies

    async def generate(self, *, system, user, output):
        kind = next(iter(output.model_fields))
        return {kind: self.replies.get(kind, [])}

async def run(llm):
    with tempfile.TemporaryDirectory() as tmp:
        async with SelfGraph(store=KuzuStore(f"{tmp}/g.kuzu"), llm=llm) as g:
            r = await g.insert.text("x")
            print([w.message for w in r.warnings])
            print([e.id for e in r.entities], [(x.from_entity, x.type, x.to_entity) for x in r.relations])

asyncio.run(run(LLM(
    entities=[{"type": "Person", "name": "Ann"}, {"type": "Company", "name": "Acme"}],
    decisions=[{"title": "", "actor_name": "Ann", "steps": [{"from_name": "Ann", "type": "CHOSE", "to_name": "Acme"}]}],
)))
asyncio.run(run(LLM(
    preferences=[{"subject_name": "Zed", "key": "food", "value_name": "Pizza", "strength": 5.0}],
)))

The first run warns dropped an extracted decision: decision title cannot be empty and stores person:ann -CHOSE-> company:acme. The second warns about the strength and stores thing:zed and thing:pizza.

Cause

src/selfgraph/extraction/extractor.py, _assemble: the decision loop calls add_relation for each step, and the preference loop calls resolve() (which registers fallback entities), before the item's own checks run. Validating the item first, or registering its writes only once it is accepted, would fix both.

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.