\set ON_ERROR_STOP on
begin;

do $$
declare
  restored int;
begin
  update public.strategy_node_anchors
     set claim_id = 'd0000000-0000-0000-0000-000000000005'::uuid,
         source_id = null,
         weight = 0.7,
         note = 'Telos/policy grounding approved by m3ta: capital allocation expresses priorities and must be coordinated with collective intelligence.'
   where id = '47f128a0-36c5-4b60-97d4-48c32fa48bc7'::uuid
     and from_node_id = '52bc4264-330e-489d-920c-a493fd2d985a'::uuid
     and anchor_role = 'justified_by'
     and claim_id = 'e6ce4e36-15d2-53bc-8b74-dda0efc095c1'::uuid;

  get diagnostics restored = row_count;
  if restored <> 1 then
    raise exception 'cross-surface anchor rollback affected % row(s), expected 1; anchor was not at Claim D state', restored;
  end if;
end $$;

commit;
