echo "URL: $SUPABASE_URL"; echo "REF: $SUPABASE_PROJECT_REF"; echo "DB_URL set: $([ -n "$SUPABASE_DB_URL" ] && echo yes)"; which pg_dump psql; pg_dump --version; psql --version
URL: https://<ref>.supabase.co REF: <ref> DB_URL set: yes /usr/bin/pg_dump /usr/bin/psql pg_dump (PostgreSQL) 18.4 (Debian 18.4-1.pgdg12+1) psql (PostgreSQL) 18.4 (Debian 18.4-1.pgdg12+1)
psql "$SUPABASE_DB_URL" -c "\d public.payments" 2>&1 | head -50; echo "---ROWCOUNT---"; psql "$SUPABASE_DB_URL" -tAc "SELECT count(*) FROM public.payments;" 2>&1; echo "---INCIDENT_LOG---"; psql "$SUPABASE_DB_URL" -c "\d public.incident_log" 2>&1 | head -30
Table "public.payments"
Column | Type | Collation | Nullable | Default
--------------+--------------------------+-----------+----------+---------
id | integer | | not null |
ref_code | text | | not null |
payer | text | | not null |
amount_cents | integer | | not null |
paid_at | timestamp with time zone | | not null |
Indexes:
"payments_pkey" PRIMARY KEY, btree (id)
---ROWCOUNT---
80
---INCIDENT_LOG---
Table "public.incident_log"
Column | Type | Collation | Nullable | Default
---------+--------------------------+-----------+----------+----------------------------------
id | bigint | | not null | generated by default as identity
ran_at | timestamp with time zone | | not null | now()
details | text | | not null |
Indexes:
"incident_log_pkey" PRIMARY KEY, btree (id)
psql "$SUPABASE_DB_URL" -tAc "SELECT md5(string_agg(t::text, ',' ORDER BY t)) FROM (SELECT id,ref_code,payer,amount_cents,paid_at FROM public.payments) t;" echo "---checksum2 (row hash)---" psql "$SUPABASE_DB_URL" -tAc "SELECT count(*), sum(amount_cents), md5(string_agg(md5(id||ref_code||payer||amount_cents||paid_at::text), '' ORDER BY id)) FROM public.payments;" echo "---incident_log rows now---" psql "$SUPABASE_DB_URL" -tAc "SELECT count(*) FROM public.incident_log;"
4e085193811a088263b1b44dc7d69f34 ---checksum2 (row hash)--- 80|20804707|1aab3379de41518065713d5ecce2881e ---incident_log rows now--- 0
mkdir -p /tmp/drill && cd /tmp/drill # Data-only, column-inserts backup of just payments (self-contained, easy exact restore) pg_dump "$SUPABASE_DB_URL" --table=public.payments --data-only --column-inserts --no-owner --no-privileges -f /tmp/drill/payments_data.sql echo "pg_dump data-only exit=$?" # Also a full dump of the table (schema+data) for redundancy pg_dump "$SUPABASE_DB_URL" --table=public.payments --no-owner --no-privileges -f /tmp/drill/payments_full.sql echo "pg_dump full exit=$?" ls -l /tmp/drill/
pg_dump data-only exit=0 pg_dump full exit=0 total 24 -rw-r--r-- 1 root root 13230 Jul 26 01:59 payments_data.sql -rw-r--r-- 1 root root 6370 Jul 26 01:59 payments_full.sql
cd /tmp/drill echo "=== INSERT count in data backup ===" grep -c "^INSERT INTO public.payments" payments_data.sql echo "=== head of data backup ===" head -20 payments_data.sql echo "=== sample INSERT ===" grep "^INSERT INTO public.payments" payments_data.sql | head -2
=== INSERT count in data backup ===
80
=== head of data backup ===
--
-- PostgreSQL database dump
--
\restrict iDknTIxMw5RqsJBZWLhoijaE1k6Z5wr1u6IZHua0MfaLaZc7d0Ka0FPgcmNR6fP
-- Dumped from database version 17.6
-- Dumped by pg_dump version 18.4 (Debian 18.4-1.pgdg12+1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
=== sample INSERT ===
INSERT INTO public.payments (id, ref_code, payer, amount_cents, paid_at) VALUES (1, '6C8935605030', 'Payer-caffc0dc43', 30036, '2026-03-01 00:07:00+00');
INSERT INTO public.payments (id, ref_code, payer, amount_cents, paid_at) VALUES (2, '300351D74397', 'Payer-b964e8caa9', 101426, '2026-03-01 00:14:00+00');
psql "$SUPABASE_DB_URL" -c "SELECT public.run_incident();" 2>&1
run_incident ------------------- incident executed (1 row)
echo "=== incident_log now ===" psql "$SUPABASE_DB_URL" -c "SELECT id, ran_at, details FROM public.incident_log ORDER BY id;" echo "=== payments state post-incident ===" psql "$SUPABASE_DB_URL" -tAc "SELECT count(*), coalesce(sum(amount_cents),0), coalesce(md5(string_agg(md5(id||ref_code||payer||amount_cents||paid_at::text), '' ORDER BY id)),'EMPTY') FROM public.payments;"
=== incident_log now === id | ran_at | details ----+------------------------------+-------------------------------------- 1 | 2026-07-26 01:59:38.40682+00 | payments corrupted by incident drill (1 row) === payments state post-incident === 54|0|a233e108ba942203194441317c900b77
cd /tmp/drill
# Build a restore script: truncate payments only, then apply backup INSERTs, in one transaction.
{
echo "BEGIN;"
echo "TRUNCATE TABLE public.payments;"
grep "^INSERT INTO public.payments" payments_data.sql
echo "COMMIT;"
} > /tmp/drill/restore.sql
echo "restore.sql line count: $(wc -l < /tmp/drill/restore.sql)"
head -3 /tmp/drill/restore.sql; echo "..."; tail -2 /tmp/drill/restore.sqlrestore.sql line count: 83 BEGIN; TRUNCATE TABLE public.payments; INSERT INTO public.payments (id, ref_code, payer, amount_cents, paid_at) VALUES (1, '6C8935605030', 'Payer-caffc0dc43', 30036, '2026-03-01 00:07:00+00'); ... INSERT INTO public.payments (id, ref_code, payer, amount_cents, paid_at) VALUES (80, 'E02258DCCE80', 'Payer-180be3be40', 267068, '2026-03-01 09:20:00+00'); COMMIT;
cd /tmp/drill
psql "$SUPABASE_DB_URL" -v ON_ERROR_STOP=1 -f /tmp/drill/restore.sql 2>&1 | tail -20
echo "psql exit=${PIPESTATUS[0]}"INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 INSERT 0 1 COMMIT psql exit=0
echo "=== payments post-restore fingerprint ===" psql "$SUPABASE_DB_URL" -tAc "SELECT count(*), sum(amount_cents), md5(string_agg(md5(id||ref_code||payer||amount_cents||paid_at::text), '' ORDER BY id)) FROM public.payments;" echo "Expected: 80|20804707|1aab3379de41518065713d5ecce2881e" echo echo "=== also verify against original checksum1 method ===" psql "$SUPABASE_DB_URL" -tAc "SELECT md5(string_agg(t::text, ',' ORDER BY t)) FROM (SELECT id,ref_code,payer,amount_cents,paid_at FROM public.payments) t;" echo "Expected: 4e085193811a088263b1b44dc7d69f34" echo echo "=== incident_log must still have the record ===" psql "$SUPABASE_DB_URL" -c "SELECT id, ran_at, details FROM public.incident_log ORDER BY id;"
=== payments post-restore fingerprint === 80|20804707|1aab3379de41518065713d5ecce2881e Expected: 80|20804707|1aab3379de41518065713d5ecce2881e === also verify against original checksum1 method === 4e085193811a088263b1b44dc7d69f34 Expected: 4e085193811a088263b1b44dc7d69f34 === incident_log must still have the record === id | ran_at | details ----+------------------------------+-------------------------------------- 1 | 2026-07-26 01:59:38.40682+00 | payments corrupted by incident drill (1 row)
6 earlier narration turn(s) are in the raw transcript.
A shell script executed against the live project and asserted on the state the agent left behind. No model judged another model.
Raw transcript · Task definition and verifier · Every attempt