feat(graph): association is not causation

Adds co_occurs_with, temporally_precedes, possibly_caused_by and
asserted_by to the relation vocabulary with Causal and Hypothetical
predicates. Entities mentioned together now co-occur rather than being
'related'; association hypotheses record possibly_caused_by and their
basis (temporal association only); caused_by is reserved for explicit
operator statements and nothing automatic writes it. Documented in
docs/graph.md and checked end to end.
This commit is contained in:
Andy Dixon
2026-08-19 19:16:15 +01:00
parent 814057b680
commit 37b9f0e2f5
6 changed files with 60 additions and 5 deletions
+8
View File
@@ -136,6 +136,14 @@ func TestAssertionsAreNotBeliefs(t *testing.T) {
if gb, ok := beliefFor(genius.BeliefID); ok && gb.Confidence > sb.Confidence {
t.Fatalf("sarcastic remark believed more than a plain one: %.2f vs %.2f", gb.Confidence, sb.Confidence)
}
// Co-mention produces association edges, never causal ones.
var causal int
h.Deps.DB.QueryRow(ctx, `SELECT count(*) FROM entity_relationships WHERE mind_id=$1 AND relation IN ('caused_by')`, m.ID).Scan(&causal) //nolint:errcheck
var cooccur int
h.Deps.DB.QueryRow(ctx, `SELECT count(*) FROM entity_relationships WHERE mind_id=$1 AND relation='co_occurs_with'`, m.ID).Scan(&cooccur) //nolint:errcheck
if causal != 0 || cooccur == 0 {
t.Fatalf("relations: caused_by=%d co_occurs_with=%d", causal, cooccur)
}
// Assertions are append-only.
if _, err := h.Deps.DB.Exec(ctx, `UPDATE assertions SET proposition='x' WHERE id=$1`, steve.ID); err == nil {
t.Fatal("assertion row was mutable")