diff --git a/cmd/nomos/store.go b/cmd/nomos/store.go index 682eb83..7d4ec99 100644 --- a/cmd/nomos/store.go +++ b/cmd/nomos/store.go @@ -179,6 +179,15 @@ func (s *store) createTaskEntity(ctx context.Context, sessionID, title string) s `UPDATE agent_sessions SET entity_id = $1 WHERE id = $2`, entityID, sessionID); err != nil { slog.Warn("nomos: could not link task entity", "session", sessionID, "error", err) } + // Graph edge: task —involves→ agent:nomos (gives every task at least one + // edge from creation, even if no run calls are ever made). + s.pool.Exec(ctx, `INSERT INTO relationships (source_id, target_id, type, attributes, valid_from) + SELECT $1, id, 'involves', '{"by":"nomos"}'::jsonb, now() + FROM entities WHERE slug = 'agent:nomos' + AND NOT EXISTS ( + SELECT 1 FROM relationships r + WHERE r.source_id = $1 AND r.target_id = entities.id AND r.type = 'involves' AND r.valid_to IS NULL)`, + entityID) return entityID.String() }