\set ON_ERROR_STOP on
-- Cross-surface companion preflight. Read-only.
-- Run after the mapped rich proposal claim/source packet has been applied.

select 'policy_anchor_current' as check_name,
       id::text,
       from_node_id::text,
       anchor_role,
       claim_id::text,
       source_id::text,
       left(note, 220) as note
from public.strategy_node_anchors
where id = '47f128a0-36c5-4b60-97d4-48c32fa48bc7'::uuid;

select 'base_claim_d_exists' as check_name,
       id::text,
       status,
       left(text, 220) as text
from public.claims
where id = 'e6ce4e36-15d2-53bc-8b74-dda0efc095c1'::uuid;

select 'approval_source_exists' as check_name,
       id::text,
       source_type,
       left(coalesce(excerpt, ''), 220) as excerpt
from public.sources
where id = '9a0d2429-b98b-585a-980c-0176db7f9fe7'::uuid;

select 'telos_anchor_already_exists' as check_name,
       id::text,
       from_node_id::text,
       anchor_role,
       to_shared_root_id::text,
       left(note, 220) as note
from public.strategy_node_anchors
where id = 'c7dd984c-ac1b-43f9-9996-576ddf61c6d2'::uuid;

select 'governance_gate_known' as check_name,
       id::text,
       name,
       left(criteria, 180) as criteria,
       left(evidence_bar, 180) as evidence_bar
from public.governance_gates
where id in (select id from (values
    ('fa88e31b-6fca-4801-bf72-f5db81950a11'::uuid),
    ('45695897-2a9c-4279-ac25-e59f166dec6a'::uuid)
  ) as v(id))
order by name;
