Refresh proposal lifecycle proof on current main

This commit is contained in:
twentyOne2x 2026-07-15 06:00:12 +02:00
parent d089fd9804
commit c216e0cbb5
3 changed files with 546 additions and 546 deletions

View file

@ -1,7 +1,7 @@
begin;
set local standard_conforming_strings = on;
set local lock_timeout = '5s';
select pg_advisory_xact_lock(hashtextextended('proposal-rollback:' || E'0b5cfd03-8c1f-509a-b1e1-a05e45164d8d', 0));
select pg_advisory_xact_lock(hashtextextended('proposal-rollback:' || E'edaf2c90-af15-5a2f-b6b9-fe08ab9ae81b', 0));
do $rollback$
declare
affected integer;
@ -9,24 +9,24 @@ declare
downstream_dependency_count integer;
begin
perform 1 from kb_stage.kb_proposals
where id = E'0b5cfd03-8c1f-509a-b1e1-a05e45164d8d'::uuid
where id = E'edaf2c90-af15-5a2f-b6b9-fe08ab9ae81b'::uuid
for update;
if not found then
raise exception 'proposal rollback: proposal row missing';
end if;
if not exists (
select 1 from kb_stage.kb_proposals
where id = E'0b5cfd03-8c1f-509a-b1e1-a05e45164d8d'::uuid
where id = E'edaf2c90-af15-5a2f-b6b9-fe08ab9ae81b'::uuid
and proposal_type = 'approve_claim'
and status = 'applied'
and payload = E'{"apply_payload":{"agent_id":null,"claims":[{"confidence":0.9,"created_by":null,"id":"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb","status":"open","superseded_by":null,"tags":["working-leo","clone-canary"],"text":"An approved strict proposal can create exact canonical rows atomically.","type":"structural"},{"confidence":0.85,"created_by":null,"id":"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95","status":"open","superseded_by":null,"tags":["working-leo","row-proof"],"text":"Row-level proof is the authority for canonical KB state.","type":"concept"}],"contract_version":2,"edges":[{"created_by":null,"edge_type":"supports","from_claim":"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb","to_claim":"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95","weight":0.75}],"evidence":[{"claim_id":"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb","created_by":null,"role":"grounds","source_id":"bf697d93-8b77-5e2b-a6c0-0825e5ba76fd","weight":0.9},{"claim_id":"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95","created_by":null,"role":"illustrates","source_id":"7a2198b6-16b2-52c6-a641-7ad59826e5bf","weight":0.8}],"reasoning_tools":[{"agent_id":null,"category":"verification","description":"Verify approved proposal to canonical graph lifecycle in a disposable clone.","id":"41b58d96-37f6-526c-b021-58f1dbcfdb6c","name":"Canonical row proof canary"}],"sources":[{"created_by":null,"excerpt":"Disposable clone lifecycle canary source A.","hash":"approve-claim-canary-4d6107db5d-a","id":"bf697d93-8b77-5e2b-a6c0-0825e5ba76fd","source_type":"observation","storage_path":null,"url":null},{"created_by":null,"excerpt":"Disposable clone lifecycle canary source B.","hash":"approve-claim-canary-4d6107db5d-b","id":"7a2198b6-16b2-52c6-a641-7ad59826e5bf","source_type":"observation","storage_path":null,"url":null}]}}'::jsonb
and payload = E'{"apply_payload":{"agent_id":null,"claims":[{"confidence":0.9,"created_by":null,"id":"b4d0a944-8f11-5516-80ca-bc680f0059ad","status":"open","superseded_by":null,"tags":["working-leo","clone-canary"],"text":"An approved strict proposal can create exact canonical rows atomically.","type":"structural"},{"confidence":0.85,"created_by":null,"id":"a9dd972a-b867-56f7-b3c9-3913dd9a0abe","status":"open","superseded_by":null,"tags":["working-leo","row-proof"],"text":"Row-level proof is the authority for canonical KB state.","type":"concept"}],"contract_version":2,"edges":[{"created_by":null,"edge_type":"supports","from_claim":"b4d0a944-8f11-5516-80ca-bc680f0059ad","to_claim":"a9dd972a-b867-56f7-b3c9-3913dd9a0abe","weight":0.75}],"evidence":[{"claim_id":"b4d0a944-8f11-5516-80ca-bc680f0059ad","created_by":null,"role":"grounds","source_id":"3953271f-7df5-5674-99b0-980b1b3534e6","weight":0.9},{"claim_id":"a9dd972a-b867-56f7-b3c9-3913dd9a0abe","created_by":null,"role":"illustrates","source_id":"3d31345d-a4f7-52a7-af4a-0034f99a8123","weight":0.8}],"reasoning_tools":[{"agent_id":null,"category":"verification","description":"Verify approved proposal to canonical graph lifecycle in a disposable clone.","id":"a32a7252-d39f-5ee9-873a-a82b56a6bb08","name":"Canonical row proof canary"}],"sources":[{"created_by":null,"excerpt":"Disposable clone lifecycle canary source A.","hash":"approve-claim-canary-e315c2518c-a","id":"3953271f-7df5-5674-99b0-980b1b3534e6","source_type":"observation","storage_path":null,"url":null},{"created_by":null,"excerpt":"Disposable clone lifecycle canary source B.","hash":"approve-claim-canary-e315c2518c-b","id":"3d31345d-a4f7-52a7-af4a-0034f99a8123","source_type":"observation","storage_path":null,"url":null}]}}'::jsonb
and reviewed_by_handle is not distinct from E'm3ta'
and reviewed_by_agent_id is not distinct from E'99999999-9999-9999-9999-999999999999'::uuid
and reviewed_at is not distinct from E'2026-07-15 03:30:07.092864+00'::timestamptz
and reviewed_at is not distinct from E'2026-07-15 03:59:09.091704+00'::timestamptz
and review_note is not distinct from E'Reviewed exact strict payload inside the disposable clone.'
and applied_by_handle is not distinct from E'kb-apply'
and applied_by_agent_id is not distinct from E'44444444-4444-4444-4444-444444444444'::uuid
and applied_at is not distinct from E'2026-07-15 03:30:10.578016+00'::timestamptz
and applied_at is not distinct from E'2026-07-15 03:59:12.452878+00'::timestamptz
) then
raise exception 'proposal rollback: applied ledger does not match apply receipt';
end if;
@ -41,83 +41,83 @@ begin
'review_note', review_note
) into approval_now
from kb_stage.kb_proposal_approvals
where proposal_id = E'0b5cfd03-8c1f-509a-b1e1-a05e45164d8d'::uuid;
if approval_now is distinct from E'{"payload":{"apply_payload":{"agent_id":null,"claims":[{"confidence":0.9,"created_by":null,"id":"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb","status":"open","superseded_by":null,"tags":["working-leo","clone-canary"],"text":"An approved strict proposal can create exact canonical rows atomically.","type":"structural"},{"confidence":0.85,"created_by":null,"id":"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95","status":"open","superseded_by":null,"tags":["working-leo","row-proof"],"text":"Row-level proof is the authority for canonical KB state.","type":"concept"}],"contract_version":2,"edges":[{"created_by":null,"edge_type":"supports","from_claim":"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb","to_claim":"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95","weight":0.75}],"evidence":[{"claim_id":"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb","created_by":null,"role":"grounds","source_id":"bf697d93-8b77-5e2b-a6c0-0825e5ba76fd","weight":0.9},{"claim_id":"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95","created_by":null,"role":"illustrates","source_id":"7a2198b6-16b2-52c6-a641-7ad59826e5bf","weight":0.8}],"reasoning_tools":[{"agent_id":null,"category":"verification","description":"Verify approved proposal to canonical graph lifecycle in a disposable clone.","id":"41b58d96-37f6-526c-b021-58f1dbcfdb6c","name":"Canonical row proof canary"}],"sources":[{"created_by":null,"excerpt":"Disposable clone lifecycle canary source A.","hash":"approve-claim-canary-4d6107db5d-a","id":"bf697d93-8b77-5e2b-a6c0-0825e5ba76fd","source_type":"observation","storage_path":null,"url":null},{"created_by":null,"excerpt":"Disposable clone lifecycle canary source B.","hash":"approve-claim-canary-4d6107db5d-b","id":"7a2198b6-16b2-52c6-a641-7ad59826e5bf","source_type":"observation","storage_path":null,"url":null}]}},"proposal_id":"0b5cfd03-8c1f-509a-b1e1-a05e45164d8d","proposal_type":"approve_claim","review_note":"Reviewed exact strict payload inside the disposable clone.","reviewed_at":"2026-07-15 03:30:07.092864+00","reviewed_by_agent_id":"99999999-9999-9999-9999-999999999999","reviewed_by_db_role":"kb_review","reviewed_by_handle":"m3ta"}'::jsonb then
where proposal_id = E'edaf2c90-af15-5a2f-b6b9-fe08ab9ae81b'::uuid;
if approval_now is distinct from E'{"payload":{"apply_payload":{"agent_id":null,"claims":[{"confidence":0.9,"created_by":null,"id":"b4d0a944-8f11-5516-80ca-bc680f0059ad","status":"open","superseded_by":null,"tags":["working-leo","clone-canary"],"text":"An approved strict proposal can create exact canonical rows atomically.","type":"structural"},{"confidence":0.85,"created_by":null,"id":"a9dd972a-b867-56f7-b3c9-3913dd9a0abe","status":"open","superseded_by":null,"tags":["working-leo","row-proof"],"text":"Row-level proof is the authority for canonical KB state.","type":"concept"}],"contract_version":2,"edges":[{"created_by":null,"edge_type":"supports","from_claim":"b4d0a944-8f11-5516-80ca-bc680f0059ad","to_claim":"a9dd972a-b867-56f7-b3c9-3913dd9a0abe","weight":0.75}],"evidence":[{"claim_id":"b4d0a944-8f11-5516-80ca-bc680f0059ad","created_by":null,"role":"grounds","source_id":"3953271f-7df5-5674-99b0-980b1b3534e6","weight":0.9},{"claim_id":"a9dd972a-b867-56f7-b3c9-3913dd9a0abe","created_by":null,"role":"illustrates","source_id":"3d31345d-a4f7-52a7-af4a-0034f99a8123","weight":0.8}],"reasoning_tools":[{"agent_id":null,"category":"verification","description":"Verify approved proposal to canonical graph lifecycle in a disposable clone.","id":"a32a7252-d39f-5ee9-873a-a82b56a6bb08","name":"Canonical row proof canary"}],"sources":[{"created_by":null,"excerpt":"Disposable clone lifecycle canary source A.","hash":"approve-claim-canary-e315c2518c-a","id":"3953271f-7df5-5674-99b0-980b1b3534e6","source_type":"observation","storage_path":null,"url":null},{"created_by":null,"excerpt":"Disposable clone lifecycle canary source B.","hash":"approve-claim-canary-e315c2518c-b","id":"3d31345d-a4f7-52a7-af4a-0034f99a8123","source_type":"observation","storage_path":null,"url":null}]}},"proposal_id":"edaf2c90-af15-5a2f-b6b9-fe08ab9ae81b","proposal_type":"approve_claim","review_note":"Reviewed exact strict payload inside the disposable clone.","reviewed_at":"2026-07-15 03:59:09.091704+00","reviewed_by_agent_id":"99999999-9999-9999-9999-999999999999","reviewed_by_db_role":"kb_review","reviewed_by_handle":"m3ta"}'::jsonb then
raise exception 'proposal rollback: immutable approval snapshot drifted';
end if;
select count(*) into downstream_dependency_count
from (
select ce.claim_id
from public.claim_evidence ce
where (ce.claim_id = any(array[E'4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95'::uuid, E'32cc5b57-0d89-58aa-9cc1-f9e0c63947fb'::uuid]::uuid[]) or ce.source_id = any(array[E'bf697d93-8b77-5e2b-a6c0-0825e5ba76fd'::uuid, E'7a2198b6-16b2-52c6-a641-7ad59826e5bf'::uuid]::uuid[]))
and not (((ce.claim_id = E'32cc5b57-0d89-58aa-9cc1-f9e0c63947fb'::uuid and ce.source_id = E'bf697d93-8b77-5e2b-a6c0-0825e5ba76fd'::uuid and ce.role = E'grounds'::evidence_role) or (ce.claim_id = E'4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95'::uuid and ce.source_id = E'7a2198b6-16b2-52c6-a641-7ad59826e5bf'::uuid and ce.role = E'illustrates'::evidence_role)))
where (ce.claim_id = any(array[E'a9dd972a-b867-56f7-b3c9-3913dd9a0abe'::uuid, E'b4d0a944-8f11-5516-80ca-bc680f0059ad'::uuid]::uuid[]) or ce.source_id = any(array[E'3953271f-7df5-5674-99b0-980b1b3534e6'::uuid, E'3d31345d-a4f7-52a7-af4a-0034f99a8123'::uuid]::uuid[]))
and not (((ce.claim_id = E'a9dd972a-b867-56f7-b3c9-3913dd9a0abe'::uuid and ce.source_id = E'3d31345d-a4f7-52a7-af4a-0034f99a8123'::uuid and ce.role = E'illustrates'::evidence_role) or (ce.claim_id = E'b4d0a944-8f11-5516-80ca-bc680f0059ad'::uuid and ce.source_id = E'3953271f-7df5-5674-99b0-980b1b3534e6'::uuid and ce.role = E'grounds'::evidence_role)))
union all
select edge.id
from public.claim_edges edge
where (edge.from_claim = any(array[E'4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95'::uuid, E'32cc5b57-0d89-58aa-9cc1-f9e0c63947fb'::uuid]::uuid[]) or edge.to_claim = any(array[E'4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95'::uuid, E'32cc5b57-0d89-58aa-9cc1-f9e0c63947fb'::uuid]::uuid[]))
and edge.id <> all(array[E'3ff15dc5-f9e8-5079-8e70-dc51d6f3e4c8'::uuid]::uuid[])
where (edge.from_claim = any(array[E'a9dd972a-b867-56f7-b3c9-3913dd9a0abe'::uuid, E'b4d0a944-8f11-5516-80ca-bc680f0059ad'::uuid]::uuid[]) or edge.to_claim = any(array[E'a9dd972a-b867-56f7-b3c9-3913dd9a0abe'::uuid, E'b4d0a944-8f11-5516-80ca-bc680f0059ad'::uuid]::uuid[]))
and edge.id <> all(array[E'cd799806-18e8-5e8c-959c-5f9c267654a7'::uuid]::uuid[])
union all
select claim.id
from public.claims claim
where claim.superseded_by = any(array[E'4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95'::uuid, E'32cc5b57-0d89-58aa-9cc1-f9e0c63947fb'::uuid]::uuid[])
and claim.id <> all(array[E'4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95'::uuid, E'32cc5b57-0d89-58aa-9cc1-f9e0c63947fb'::uuid]::uuid[])
where claim.superseded_by = any(array[E'a9dd972a-b867-56f7-b3c9-3913dd9a0abe'::uuid, E'b4d0a944-8f11-5516-80ca-bc680f0059ad'::uuid]::uuid[])
and claim.id <> all(array[E'a9dd972a-b867-56f7-b3c9-3913dd9a0abe'::uuid, E'b4d0a944-8f11-5516-80ca-bc680f0059ad'::uuid]::uuid[])
) external_dependencies;
if downstream_dependency_count <> 0 then
raise exception 'proposal rollback: % downstream dependenc(ies) exist; rollback quarantined', downstream_dependency_count;
end if;
if (select count(*) from public.claim_evidence t
where ((t.claim_id = E'32cc5b57-0d89-58aa-9cc1-f9e0c63947fb'::uuid and t.source_id = E'bf697d93-8b77-5e2b-a6c0-0825e5ba76fd'::uuid and t.role = E'grounds'::evidence_role)) and to_jsonb(t) = E'{"claim_id":"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb","created_at":"2026-07-15T03:30:10.562997+00:00","created_by":null,"role":"grounds","source_id":"bf697d93-8b77-5e2b-a6c0-0825e5ba76fd","weight":0.9}'::jsonb) <> 1 then
where ((t.claim_id = E'a9dd972a-b867-56f7-b3c9-3913dd9a0abe'::uuid and t.source_id = E'3d31345d-a4f7-52a7-af4a-0034f99a8123'::uuid and t.role = E'illustrates'::evidence_role)) and to_jsonb(t) = E'{"claim_id":"a9dd972a-b867-56f7-b3c9-3913dd9a0abe","created_at":"2026-07-15T03:59:12.43629+00:00","created_by":null,"role":"illustrates","source_id":"3d31345d-a4f7-52a7-af4a-0034f99a8123","weight":0.8}'::jsonb) <> 1 then
raise exception 'proposal rollback drift: claim_evidence[0] row does not match apply receipt';
end if;
if (select count(*) from public.claim_evidence t
where ((t.claim_id = E'4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95'::uuid and t.source_id = E'7a2198b6-16b2-52c6-a641-7ad59826e5bf'::uuid and t.role = E'illustrates'::evidence_role)) and to_jsonb(t) = E'{"claim_id":"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95","created_at":"2026-07-15T03:30:10.562997+00:00","created_by":null,"role":"illustrates","source_id":"7a2198b6-16b2-52c6-a641-7ad59826e5bf","weight":0.8}'::jsonb) <> 1 then
where ((t.claim_id = E'b4d0a944-8f11-5516-80ca-bc680f0059ad'::uuid and t.source_id = E'3953271f-7df5-5674-99b0-980b1b3534e6'::uuid and t.role = E'grounds'::evidence_role)) and to_jsonb(t) = E'{"claim_id":"b4d0a944-8f11-5516-80ca-bc680f0059ad","created_at":"2026-07-15T03:59:12.43629+00:00","created_by":null,"role":"grounds","source_id":"3953271f-7df5-5674-99b0-980b1b3534e6","weight":0.9}'::jsonb) <> 1 then
raise exception 'proposal rollback drift: claim_evidence[1] row does not match apply receipt';
end if;
if (select count(*) from public.claim_edges t
where t.id = E'3ff15dc5-f9e8-5079-8e70-dc51d6f3e4c8'::uuid and to_jsonb(t) = E'{"created_at":"2026-07-15T03:30:10.562997+00:00","created_by":null,"edge_type":"supports","from_claim":"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb","id":"3ff15dc5-f9e8-5079-8e70-dc51d6f3e4c8","to_claim":"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95","weight":0.75}'::jsonb) <> 1 then
where t.id = E'cd799806-18e8-5e8c-959c-5f9c267654a7'::uuid and to_jsonb(t) = E'{"created_at":"2026-07-15T03:59:12.43629+00:00","created_by":null,"edge_type":"supports","from_claim":"b4d0a944-8f11-5516-80ca-bc680f0059ad","id":"cd799806-18e8-5e8c-959c-5f9c267654a7","to_claim":"a9dd972a-b867-56f7-b3c9-3913dd9a0abe","weight":0.75}'::jsonb) <> 1 then
raise exception 'proposal rollback drift: claim_edges[0] row does not match apply receipt';
end if;
if (select count(*) from public.reasoning_tools t
where t.id = E'41b58d96-37f6-526c-b021-58f1dbcfdb6c'::uuid and to_jsonb(t) = E'{"agent_id":null,"category":"verification","created_at":"2026-07-15T03:30:10.562997+00:00","description":"Verify approved proposal to canonical graph lifecycle in a disposable clone.","id":"41b58d96-37f6-526c-b021-58f1dbcfdb6c","name":"Canonical row proof canary"}'::jsonb) <> 1 then
where t.id = E'a32a7252-d39f-5ee9-873a-a82b56a6bb08'::uuid and to_jsonb(t) = E'{"agent_id":null,"category":"verification","created_at":"2026-07-15T03:59:12.43629+00:00","description":"Verify approved proposal to canonical graph lifecycle in a disposable clone.","id":"a32a7252-d39f-5ee9-873a-a82b56a6bb08","name":"Canonical row proof canary"}'::jsonb) <> 1 then
raise exception 'proposal rollback drift: reasoning_tools[0] row does not match apply receipt';
end if;
if (select count(*) from public.sources t
where t.id = E'bf697d93-8b77-5e2b-a6c0-0825e5ba76fd'::uuid and to_jsonb(t) = E'{"captured_at":null,"created_at":"2026-07-15T03:30:10.562997+00:00","created_by":null,"excerpt":"Disposable clone lifecycle canary source A.","hash":"approve-claim-canary-4d6107db5d-a","id":"bf697d93-8b77-5e2b-a6c0-0825e5ba76fd","source_type":"observation","storage_path":null,"url":null}'::jsonb) <> 1 then
where t.id = E'3953271f-7df5-5674-99b0-980b1b3534e6'::uuid and to_jsonb(t) = E'{"captured_at":null,"created_at":"2026-07-15T03:59:12.43629+00:00","created_by":null,"excerpt":"Disposable clone lifecycle canary source A.","hash":"approve-claim-canary-e315c2518c-a","id":"3953271f-7df5-5674-99b0-980b1b3534e6","source_type":"observation","storage_path":null,"url":null}'::jsonb) <> 1 then
raise exception 'proposal rollback drift: sources[0] row does not match apply receipt';
end if;
if (select count(*) from public.sources t
where t.id = E'7a2198b6-16b2-52c6-a641-7ad59826e5bf'::uuid and to_jsonb(t) = E'{"captured_at":null,"created_at":"2026-07-15T03:30:10.562997+00:00","created_by":null,"excerpt":"Disposable clone lifecycle canary source B.","hash":"approve-claim-canary-4d6107db5d-b","id":"7a2198b6-16b2-52c6-a641-7ad59826e5bf","source_type":"observation","storage_path":null,"url":null}'::jsonb) <> 1 then
where t.id = E'3d31345d-a4f7-52a7-af4a-0034f99a8123'::uuid and to_jsonb(t) = E'{"captured_at":null,"created_at":"2026-07-15T03:59:12.43629+00:00","created_by":null,"excerpt":"Disposable clone lifecycle canary source B.","hash":"approve-claim-canary-e315c2518c-b","id":"3d31345d-a4f7-52a7-af4a-0034f99a8123","source_type":"observation","storage_path":null,"url":null}'::jsonb) <> 1 then
raise exception 'proposal rollback drift: sources[1] row does not match apply receipt';
end if;
if (select count(*) from public.claims t
where t.id = E'4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95'::uuid and to_jsonb(t) = E'{"confidence":0.85,"created_at":"2026-07-15T03:30:10.562997+00:00","created_by":null,"id":"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95","status":"open","superseded_by":null,"tags":["working-leo","row-proof"],"text":"Row-level proof is the authority for canonical KB state.","type":"concept","updated_at":"2026-07-15T03:30:10.562997+00:00"}'::jsonb) <> 1 then
where t.id = E'a9dd972a-b867-56f7-b3c9-3913dd9a0abe'::uuid and to_jsonb(t) = E'{"confidence":0.85,"created_at":"2026-07-15T03:59:12.43629+00:00","created_by":null,"id":"a9dd972a-b867-56f7-b3c9-3913dd9a0abe","status":"open","superseded_by":null,"tags":["working-leo","row-proof"],"text":"Row-level proof is the authority for canonical KB state.","type":"concept","updated_at":"2026-07-15T03:59:12.43629+00:00"}'::jsonb) <> 1 then
raise exception 'proposal rollback drift: claims[0] row does not match apply receipt';
end if;
if (select count(*) from public.claims t
where t.id = E'32cc5b57-0d89-58aa-9cc1-f9e0c63947fb'::uuid and to_jsonb(t) = E'{"confidence":0.9,"created_at":"2026-07-15T03:30:10.562997+00:00","created_by":null,"id":"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb","status":"open","superseded_by":null,"tags":["working-leo","clone-canary"],"text":"An approved strict proposal can create exact canonical rows atomically.","type":"structural","updated_at":"2026-07-15T03:30:10.562997+00:00"}'::jsonb) <> 1 then
where t.id = E'b4d0a944-8f11-5516-80ca-bc680f0059ad'::uuid and to_jsonb(t) = E'{"confidence":0.9,"created_at":"2026-07-15T03:59:12.43629+00:00","created_by":null,"id":"b4d0a944-8f11-5516-80ca-bc680f0059ad","status":"open","superseded_by":null,"tags":["working-leo","clone-canary"],"text":"An approved strict proposal can create exact canonical rows atomically.","type":"structural","updated_at":"2026-07-15T03:59:12.43629+00:00"}'::jsonb) <> 1 then
raise exception 'proposal rollback drift: claims[1] row does not match apply receipt';
end if;
delete from public.claim_evidence target where ((target.claim_id = E'32cc5b57-0d89-58aa-9cc1-f9e0c63947fb'::uuid and target.source_id = E'bf697d93-8b77-5e2b-a6c0-0825e5ba76fd'::uuid and target.role = E'grounds'::evidence_role) or (target.claim_id = E'4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95'::uuid and target.source_id = E'7a2198b6-16b2-52c6-a641-7ad59826e5bf'::uuid and target.role = E'illustrates'::evidence_role));
delete from public.claim_evidence target where ((target.claim_id = E'a9dd972a-b867-56f7-b3c9-3913dd9a0abe'::uuid and target.source_id = E'3d31345d-a4f7-52a7-af4a-0034f99a8123'::uuid and target.role = E'illustrates'::evidence_role) or (target.claim_id = E'b4d0a944-8f11-5516-80ca-bc680f0059ad'::uuid and target.source_id = E'3953271f-7df5-5674-99b0-980b1b3534e6'::uuid and target.role = E'grounds'::evidence_role));
get diagnostics affected = row_count;
if affected <> 2 then
raise exception 'proposal rollback count mismatch for claim_evidence: expected 2, got %', affected;
end if;
delete from public.claim_edges where id in (E'3ff15dc5-f9e8-5079-8e70-dc51d6f3e4c8'::uuid);
delete from public.claim_edges where id in (E'cd799806-18e8-5e8c-959c-5f9c267654a7'::uuid);
get diagnostics affected = row_count;
if affected <> 1 then
raise exception 'proposal rollback count mismatch for claim_edges: expected 1, got %', affected;
end if;
delete from public.reasoning_tools where id in (E'41b58d96-37f6-526c-b021-58f1dbcfdb6c'::uuid);
delete from public.reasoning_tools where id in (E'a32a7252-d39f-5ee9-873a-a82b56a6bb08'::uuid);
get diagnostics affected = row_count;
if affected <> 1 then
raise exception 'proposal rollback count mismatch for reasoning_tools: expected 1, got %', affected;
end if;
delete from public.sources where id in (E'bf697d93-8b77-5e2b-a6c0-0825e5ba76fd'::uuid, E'7a2198b6-16b2-52c6-a641-7ad59826e5bf'::uuid);
delete from public.sources where id in (E'3953271f-7df5-5674-99b0-980b1b3534e6'::uuid, E'3d31345d-a4f7-52a7-af4a-0034f99a8123'::uuid);
get diagnostics affected = row_count;
if affected <> 2 then
raise exception 'proposal rollback count mismatch for sources: expected 2, got %', affected;
end if;
delete from public.claims where id in (E'4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95'::uuid, E'32cc5b57-0d89-58aa-9cc1-f9e0c63947fb'::uuid);
delete from public.claims where id in (E'a9dd972a-b867-56f7-b3c9-3913dd9a0abe'::uuid, E'b4d0a944-8f11-5516-80ca-bc680f0059ad'::uuid);
get diagnostics affected = row_count;
if affected <> 2 then
raise exception 'proposal rollback count mismatch for claims: expected 2, got %', affected;
@ -128,10 +128,10 @@ begin
applied_by_agent_id = null,
applied_at = null,
updated_at = now()
where id = E'0b5cfd03-8c1f-509a-b1e1-a05e45164d8d'::uuid
where id = E'edaf2c90-af15-5a2f-b6b9-fe08ab9ae81b'::uuid
and status = 'applied'
and payload = E'{"apply_payload":{"agent_id":null,"claims":[{"confidence":0.9,"created_by":null,"id":"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb","status":"open","superseded_by":null,"tags":["working-leo","clone-canary"],"text":"An approved strict proposal can create exact canonical rows atomically.","type":"structural"},{"confidence":0.85,"created_by":null,"id":"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95","status":"open","superseded_by":null,"tags":["working-leo","row-proof"],"text":"Row-level proof is the authority for canonical KB state.","type":"concept"}],"contract_version":2,"edges":[{"created_by":null,"edge_type":"supports","from_claim":"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb","to_claim":"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95","weight":0.75}],"evidence":[{"claim_id":"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb","created_by":null,"role":"grounds","source_id":"bf697d93-8b77-5e2b-a6c0-0825e5ba76fd","weight":0.9},{"claim_id":"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95","created_by":null,"role":"illustrates","source_id":"7a2198b6-16b2-52c6-a641-7ad59826e5bf","weight":0.8}],"reasoning_tools":[{"agent_id":null,"category":"verification","description":"Verify approved proposal to canonical graph lifecycle in a disposable clone.","id":"41b58d96-37f6-526c-b021-58f1dbcfdb6c","name":"Canonical row proof canary"}],"sources":[{"created_by":null,"excerpt":"Disposable clone lifecycle canary source A.","hash":"approve-claim-canary-4d6107db5d-a","id":"bf697d93-8b77-5e2b-a6c0-0825e5ba76fd","source_type":"observation","storage_path":null,"url":null},{"created_by":null,"excerpt":"Disposable clone lifecycle canary source B.","hash":"approve-claim-canary-4d6107db5d-b","id":"7a2198b6-16b2-52c6-a641-7ad59826e5bf","source_type":"observation","storage_path":null,"url":null}]}}'::jsonb
and applied_at is not distinct from E'2026-07-15 03:30:10.578016+00'::timestamptz;
and payload = E'{"apply_payload":{"agent_id":null,"claims":[{"confidence":0.9,"created_by":null,"id":"b4d0a944-8f11-5516-80ca-bc680f0059ad","status":"open","superseded_by":null,"tags":["working-leo","clone-canary"],"text":"An approved strict proposal can create exact canonical rows atomically.","type":"structural"},{"confidence":0.85,"created_by":null,"id":"a9dd972a-b867-56f7-b3c9-3913dd9a0abe","status":"open","superseded_by":null,"tags":["working-leo","row-proof"],"text":"Row-level proof is the authority for canonical KB state.","type":"concept"}],"contract_version":2,"edges":[{"created_by":null,"edge_type":"supports","from_claim":"b4d0a944-8f11-5516-80ca-bc680f0059ad","to_claim":"a9dd972a-b867-56f7-b3c9-3913dd9a0abe","weight":0.75}],"evidence":[{"claim_id":"b4d0a944-8f11-5516-80ca-bc680f0059ad","created_by":null,"role":"grounds","source_id":"3953271f-7df5-5674-99b0-980b1b3534e6","weight":0.9},{"claim_id":"a9dd972a-b867-56f7-b3c9-3913dd9a0abe","created_by":null,"role":"illustrates","source_id":"3d31345d-a4f7-52a7-af4a-0034f99a8123","weight":0.8}],"reasoning_tools":[{"agent_id":null,"category":"verification","description":"Verify approved proposal to canonical graph lifecycle in a disposable clone.","id":"a32a7252-d39f-5ee9-873a-a82b56a6bb08","name":"Canonical row proof canary"}],"sources":[{"created_by":null,"excerpt":"Disposable clone lifecycle canary source A.","hash":"approve-claim-canary-e315c2518c-a","id":"3953271f-7df5-5674-99b0-980b1b3534e6","source_type":"observation","storage_path":null,"url":null},{"created_by":null,"excerpt":"Disposable clone lifecycle canary source B.","hash":"approve-claim-canary-e315c2518c-b","id":"3d31345d-a4f7-52a7-af4a-0034f99a8123","source_type":"observation","storage_path":null,"url":null}]}}'::jsonb
and applied_at is not distinct from E'2026-07-15 03:59:12.452878+00'::timestamptz;
get diagnostics affected = row_count;
if affected <> 1 then
raise exception 'proposal rollback: expected one applied ledger row, got %', affected;

View file

@ -1,48 +1,48 @@
{
"applied_row_keys": {
"claim_edges": [
"3ff15dc5-f9e8-5079-8e70-dc51d6f3e4c8"
"cd799806-18e8-5e8c-959c-5f9c267654a7"
],
"claim_evidence": [
"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb|bf697d93-8b77-5e2b-a6c0-0825e5ba76fd|grounds",
"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95|7a2198b6-16b2-52c6-a641-7ad59826e5bf|illustrates"
"a9dd972a-b867-56f7-b3c9-3913dd9a0abe|3d31345d-a4f7-52a7-af4a-0034f99a8123|illustrates",
"b4d0a944-8f11-5516-80ca-bc680f0059ad|3953271f-7df5-5674-99b0-980b1b3534e6|grounds"
],
"claims": [
"32cc5b57-0d89-58aa-9cc1-f9e0c63947fb",
"4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95"
"a9dd972a-b867-56f7-b3c9-3913dd9a0abe",
"b4d0a944-8f11-5516-80ca-bc680f0059ad"
],
"reasoning_tools": [
"41b58d96-37f6-526c-b021-58f1dbcfdb6c"
"a32a7252-d39f-5ee9-873a-a82b56a6bb08"
],
"sources": [
"7a2198b6-16b2-52c6-a641-7ad59826e5bf",
"bf697d93-8b77-5e2b-a6c0-0825e5ba76fd"
"3953271f-7df5-5674-99b0-980b1b3534e6",
"3d31345d-a4f7-52a7-af4a-0034f99a8123"
]
},
"applied_row_sha256": {
"claim_edges": [
"65e5186be950498bd8ff8ef2043804181ec5bef02c9c1bb36a965dd9410e8b5b"
"aae7ed87c66cf58136f2b0027ae1cddc9092cd64bfc8e617cd7746b2306274c5"
],
"claim_evidence": [
"9164b7c63641e5cbf5422f50299490053d547ba6ce1108c970b1ebfb89dc8e25",
"c098ddaadc9b7d14e3f0d48f844b88750fc7529813a20762240557abcdb1391b"
"388f3363173efda00f0688fab77fe0ce2baf62035220b843be1adea1f1c70f7f",
"55838cb722f7158cbdbdc3b79212e764f9fa6014771985aec3c1c7856967db07"
],
"claims": [
"e8cb8a99124bcc1f98fb0316132155c4db6d9dd12879f40a0ece82cc97e54085",
"4ffd395e8534ab7c9d565147667c8e207eacf70dbfcae6e8959e9b9203e4429f"
"75fe4543c9c3194612b1cf98b074ff7e361da17c9bcd59f9b6f085c2c0861277",
"5914923936817eff6d7e5c824c94c18ae6392b7a6e80c87ace2e547865b173eb"
],
"reasoning_tools": [
"355dee4df27c89809daa214fde69fdfb9f15fc2a29f3985582fe69d7bd797598"
"990dacb7b77cec117d9ee4a7630625a8782d06dfd549340b3269b8332c170576"
],
"sources": [
"cea718e74eb3d2c2672491e2e6fc523c4c4a4ae3060babbb24652f8004a2c7fd",
"d31a88fff760ed8d5985a2557f20524a372a0ea94893b7ad1aa1d24e6fe58050"
"585edbec2f98ec127041cdd662506a1494ea402f7e25ac0082dbda98197bf130",
"a8d2eead7cb3e563869978570173e2af753dfe131d4b7cfcf6dd419ffbb427e5"
]
},
"apply_payload_sha256": "89faf1f2fc9481574934de0eefb91cb8056e10784ec0f966c621621ff4f91b02",
"apply_receipt_sha256": "456247af33d4222f76c47c0a4e9228135d7a46c2c04c0f9c928b6bae5f30cde8",
"apply_sql_sha256": "5e93caad9e259d34b2ed02f98825a41b48cff4cfe0678d60a43ed1d08298ce7a",
"approval_snapshot_sha256": "ae28ff3694a19603b562f3233772ea68371702f22732026c75c33af944428dab",
"apply_payload_sha256": "e033bd4e742dfa0dad7d26e2f2b1f18eb71996541cdbc575bb2d4504c045e36f",
"apply_receipt_sha256": "ac99a2a315cc8e6e214e0f2f69d1a23413da9cfd8629c202b61a678ffda6d7ca",
"apply_sql_sha256": "b52cd47182dc0f542a394147201bb3a125518f8a4bc1a7fc44f2b0caa39c4a1b",
"approval_snapshot_sha256": "1f9d0a58ad236908da931c7489fe14ee855d0f13c4d72eb5b218370e116e2096",
"artifact": "proposal_apply_lifecycle_receipt",
"checks": {
"apply_receipt_replay_ready": true,
@ -58,11 +58,11 @@
"unrelated_rows_unchanged": true
},
"current_tier": "T2_runtime",
"fresh_owned_apply_sql_sha256": "5e93caad9e259d34b2ed02f98825a41b48cff4cfe0678d60a43ed1d08298ce7a",
"fresh_preflight_artifact_sha256": "33ae0ebf83cb0d29c0f07e45587b912f7716faa7360ec585c46b65e593723dee",
"fresh_preflight_sha256": "3c4a6b90e6cbb7aa9f93966465f26ada386c2e3bd8326a8bfb23c2efb0c142b8",
"generated_at_utc": "2026-07-15T03:30:13.458916+00:00",
"lifecycle_receipt_sha256": "6a94df2a04b9b71f931d23d5e5fba3aa295395f9ef636f490bcffdd43d1af697",
"fresh_owned_apply_sql_sha256": "b52cd47182dc0f542a394147201bb3a125518f8a4bc1a7fc44f2b0caa39c4a1b",
"fresh_preflight_artifact_sha256": "2312c91d82ee378d4a53136b8e307900c97d0611d9f12098e799cb6de5d30077",
"fresh_preflight_sha256": "90facb2ca62feb1d3c7a242e84427ab402cf57148eaba40ec700f3cc4896d20f",
"generated_at_utc": "2026-07-15T03:59:15.412413+00:00",
"lifecycle_receipt_sha256": "4254f363b0c6115ecf07856c6e6a9879b43840e688aa73211cb9eff893b36c06",
"pass": true,
"production_apply_authorization_present": false,
"production_apply_executed": false,
@ -70,7 +70,7 @@
"applied_at": null,
"applied_by_agent_id": null,
"applied_by_handle": null,
"id": "0b5cfd03-8c1f-509a-b1e1-a05e45164d8d",
"id": "edaf2c90-af15-5a2f-b6b9-fe08ab9ae81b",
"payload": {
"apply_payload": {
"agent_id": null,
@ -78,7 +78,7 @@
{
"confidence": 0.9,
"created_by": null,
"id": "32cc5b57-0d89-58aa-9cc1-f9e0c63947fb",
"id": "b4d0a944-8f11-5516-80ca-bc680f0059ad",
"status": "open",
"superseded_by": null,
"tags": [
@ -91,7 +91,7 @@
{
"confidence": 0.85,
"created_by": null,
"id": "4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95",
"id": "a9dd972a-b867-56f7-b3c9-3913dd9a0abe",
"status": "open",
"superseded_by": null,
"tags": [
@ -107,24 +107,24 @@
{
"created_by": null,
"edge_type": "supports",
"from_claim": "32cc5b57-0d89-58aa-9cc1-f9e0c63947fb",
"to_claim": "4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95",
"from_claim": "b4d0a944-8f11-5516-80ca-bc680f0059ad",
"to_claim": "a9dd972a-b867-56f7-b3c9-3913dd9a0abe",
"weight": 0.75
}
],
"evidence": [
{
"claim_id": "32cc5b57-0d89-58aa-9cc1-f9e0c63947fb",
"claim_id": "b4d0a944-8f11-5516-80ca-bc680f0059ad",
"created_by": null,
"role": "grounds",
"source_id": "bf697d93-8b77-5e2b-a6c0-0825e5ba76fd",
"source_id": "3953271f-7df5-5674-99b0-980b1b3534e6",
"weight": 0.9
},
{
"claim_id": "4d8f5ef5-d1a3-5043-a9e8-fdc202c10d95",
"claim_id": "a9dd972a-b867-56f7-b3c9-3913dd9a0abe",
"created_by": null,
"role": "illustrates",
"source_id": "7a2198b6-16b2-52c6-a641-7ad59826e5bf",
"source_id": "3d31345d-a4f7-52a7-af4a-0034f99a8123",
"weight": 0.8
}
],
@ -133,7 +133,7 @@
"agent_id": null,
"category": "verification",
"description": "Verify approved proposal to canonical graph lifecycle in a disposable clone.",
"id": "41b58d96-37f6-526c-b021-58f1dbcfdb6c",
"id": "a32a7252-d39f-5ee9-873a-a82b56a6bb08",
"name": "Canonical row proof canary"
}
],
@ -141,8 +141,8 @@
{
"created_by": null,
"excerpt": "Disposable clone lifecycle canary source A.",
"hash": "approve-claim-canary-4d6107db5d-a",
"id": "bf697d93-8b77-5e2b-a6c0-0825e5ba76fd",
"hash": "approve-claim-canary-e315c2518c-a",
"id": "3953271f-7df5-5674-99b0-980b1b3534e6",
"source_type": "observation",
"storage_path": null,
"url": null
@ -150,8 +150,8 @@
{
"created_by": null,
"excerpt": "Disposable clone lifecycle canary source B.",
"hash": "approve-claim-canary-4d6107db5d-b",
"id": "7a2198b6-16b2-52c6-a641-7ad59826e5bf",
"hash": "approve-claim-canary-e315c2518c-b",
"id": "3d31345d-a4f7-52a7-af4a-0034f99a8123",
"source_type": "observation",
"storage_path": null,
"url": null
@ -161,12 +161,12 @@
},
"proposal_type": "approve_claim",
"review_note": "Reviewed exact strict payload inside the disposable clone.",
"reviewed_at": "2026-07-15 03:30:07.092864+00",
"reviewed_at": "2026-07-15 03:59:09.091704+00",
"reviewed_by_agent_id": "99999999-9999-9999-9999-999999999999",
"reviewed_by_handle": "m3ta",
"status": "approved"
},
"proposal_payload_sha256": "3e499f82baa1fa80dba0fdeee7133dfec9c92f111a9cd1aa0b77fe0a3c12c112",
"proposal_payload_sha256": "cf2676db5a64142d07a7b46f02f1ba38bfa8cca69d03484bbcaa5eeb7002af71",
"required_tier": "T2_runtime",
"rollback": {
"counts_after_rollback": {
@ -196,15 +196,15 @@
"applied_at": null,
"applied_by_agent_id": null,
"applied_by_handle": null,
"id": "0b5cfd03-8c1f-509a-b1e1-a05e45164d8d",
"id": "edaf2c90-af15-5a2f-b6b9-fe08ab9ae81b",
"proposal_type": "approve_claim",
"review_note": "Reviewed exact strict payload inside the disposable clone.",
"reviewed_at": "2026-07-15 03:30:07.092864+00",
"reviewed_at": "2026-07-15 03:59:09.091704+00",
"reviewed_by_agent_id": "99999999-9999-9999-9999-999999999999",
"reviewed_by_handle": "m3ta",
"status": "canceled"
},
"rollback_sql_sha256": "5b184fc6a65373549b257c3dd40abac91bb90bd4c75b890798fcabc4174dee7b",
"rollback_sql_sha256": "50758dab3f998289a879cedb4a3f4535814e70c7f4dde417812092b9fe194901",
"schema": "livingip.proposalApplyRollback.v2",
"target_rows_after": {
"claim_edges": [],