feat: add ontology material ingestion

This commit is contained in:
user
2026-04-26 17:49:35 +09:00
parent a413f1ef15
commit 4936cdf4c9
19 changed files with 766 additions and 13 deletions

View File

@@ -0,0 +1,53 @@
package ontology
import "testing"
func TestIngestCreatesSourceBackedCandidates(t *testing.T) {
service := NewService(NewMemoryStore())
result, err := service.Ingest(IngestInput{
Title: "Backend interview notes",
SourceType: "markdown",
Body: "Idempotent API retries need transactions. Cache invalidation uses TTL tradeoffs.",
})
if err != nil {
t.Fatalf("Ingest error: %v", err)
}
if result.Material.ID == "" {
t.Fatal("expected material id")
}
if len(result.Snapshot.Concepts) == 0 {
t.Fatal("expected concept candidates")
}
for _, concept := range result.Snapshot.Concepts {
if concept.ReviewState != ReviewCandidate {
t.Fatalf("review state = %q", concept.ReviewState)
}
if len(concept.Evidence) == 0 {
t.Fatal("expected concept evidence")
}
}
if len(result.Snapshot.Edges) == 0 {
t.Fatal("expected prerequisite edge candidates")
}
}
func TestIngestMarksGapsAsCandidates(t *testing.T) {
service := NewService(NewMemoryStore())
result, err := service.Ingest(IngestInput{
Title: "Cache note",
Body: "Cache invalidation is hard.",
})
if err != nil {
t.Fatalf("Ingest error: %v", err)
}
if len(result.Snapshot.Gaps) == 0 {
t.Fatal("expected gaps")
}
for _, gap := range result.Snapshot.Gaps {
if gap.ReviewState != ReviewCandidate {
t.Fatalf("gap review state = %q", gap.ReviewState)
}
}
}