-- 014_rename_agent_hermes_to_nomos.up.sql
-- Rename the Hermes agent entity to Nomos (N0 milestone).
-- Identity-preserving: the UUID, relationships, and audit history survive.
-- The matching seed upsert will no-op because it upserts by slug.

DO $$
BEGIN
    IF EXISTS (SELECT 1 FROM entities WHERE slug = 'agent:hermes') THEN
        UPDATE entities
        SET slug = 'agent:nomos',
            name = 'nomos',
            attributes = jsonb_set(attributes, '{name}', '"nomos"'),
            updated_at = now()
        WHERE slug = 'agent:hermes'
          AND NOT EXISTS (SELECT 1 FROM entities WHERE slug = 'agent:nomos');
    END IF;
END
$$;
