echo "SUPABASE_URL=$SUPABASE_URL"; echo "SUPABASE_PROJECT_REF=$SUPABASE_PROJECT_REF"; echo "SUPABASE_ANON_KEY_LEN=${#SUPABASE_ANON_KEY}"; echo "SUPABASE_SERVICE_ROLE_KEY_LEN=${#SUPABASE_SERVICE_ROLE_KEY}"; echo "SUPABASE_DB_URL=$SUPABASE_DB_URL"; echo "SUPABASE_DB_PASSWORD_LEN=${#SUPABASE_DB_PASSWORD}"SUPABASE_URL=https://<ref>.supabase.co SUPABASE_PROJECT_REF=<ref> SUPABASE_ANON_KEY_LEN=208 SUPABASE_SERVICE_ROLE_KEY_LEN=219 SUPABASE_DB_URL=<redacted:SUPABASE_DB_URL> SUPABASE_DB_PASSWORD_LEN=48
which psql; psql --version; which xargs
/usr/bin/psql psql (PostgreSQL) 18.4 (Debian 18.4-1.pgdg12+1) /usr/bin/xargs
cat <<'EOF' > /tmp/check_pool.sh
#!/usr/bin/env bash
# Verify the pooling setup.
# - Connect through the TRANSACTION-MODE pooler (port 6543 by default for Supabase)
# - DB URL provided via $SUPABASE_DB_URL is "session-mode" (5432), so rewrite
# the port to 6543 to use transaction-mode pooling.
# - Run 20 concurrent one-shot queries of SELECT pg_backend_pid().
# - On full success, print "POOL OK 20/20" and exit 0.
set -u
: "${SUPABASE_DB_URL:?SUPABASE_DB_URL not set}"
: "${SUPABASE_DB_PASSWORD:?SUPABASE_DB_PASSWORD not set}"
# Rewrite the URL to transaction-mode by swapping the port to 6543.
TX_URL=$(printf '%s' "$SUPABASE_DB_URL" | sed -E 's#:([0-9]+)/#:6543/#' | sed -E 's#:5432/#:6543/#')
echo "Connecting through: $TX_URL" >&2
export PGPASSWORD="$SUPABASE_DB_PASSWORD"
run_one() {
psql "$TX_URL" -tA -c "SELECT pg_backend_pid();" >/dev/null 2>&1
}
mkdir -p /tmp/pool_out
rm -f /tmp/pool_out/*
pids=()
for i in $(seq 1 20); do
( run_one && echo ok >/tmp/pool_out/$i.ok || echo fail >/tmp/pool_out/$i.ok ) &
pids+=($!)
done
fail=0
for p in "${pids[@]}"; do
wait "$p" || fail=1
done
ok=$(grep -l '^ok$' /tmp/pool_out/* 2>/dev/null | wc -l)
fail_count=$(grep -l '^fail$' /tmp/pool_out/* 2>/dev/null | wc -l)
echo "successful=$ok failed=$fail_count" >&2
if [ "$fail" -eq 0 ] && [ "$ok" -eq 20 ]; then
echo "POOL OK 20/20"
exit 0
else
echo "POOL FAIL $ok/20" >&2
exit 1
fi
EOF
chmod +x /tmp/check_pool.sh
/tmp/check_pool.shPOOL OK 20/20
Connecting through: postgresql://postgres.<ref>:<redacted:SUPABASE_DB_PASSWORD>@aws-0-us-east-1.pooler.supabase.com:6543/postgres successful=20 failed=0
cat <<'EOF' > pool_smoke.sh
#!/usr/bin/env bash
# pool_smoke.sh - prove the Supabase project is reachable through its
# TRANSACTION-MODE connection pooler (not the session-mode port, and not
# a direct database connection).
#
# What it does:
# 1. Reads the database URL from $SUPABASE_DB_URL. That URL points at the
# session-mode pooler (port 5432). This script rewrites the port to
# 6543 so the connection actually goes through Supabase's
# transaction-mode pooler (pgbouncer in transaction-pooling mode).
# 2. Reads the database password from $SUPABASE_DB_PASSWORD and exports
# it as PGPASSWORD so psql can authenticate without the password
# ever appearing in the script, on the command line, or in process
# listings.
# 3. Spawns 20 concurrent one-shot psql connections, each executing
# "SELECT pg_backend_pid();" - a query that is trivially cheap but
# forces a real round-trip per backend, demonstrating that the
# pooler is happy serving many concurrent transactions.
# 4. Waits for all 20 to finish. If every one succeeded, prints
# "POOL OK 20/20" on stdout and exits 0. Otherwise it prints the
# failure summary to stderr and exits non-zero.
#
# Required environment variables:
# SUPABASE_DB_URL - the session-mode pooler URL
# (e.g. postgres://...@aws-0-<region>.pooler.supabase.com:5432/postgres)
# SUPABASE_DB_PASSWORD - the database password; never hardcoded.
#
# Exit codes:
# 0 - all 20 concurrent queries succeeded via the transaction-mode pooler.
# 1 - any query failed, or the pool could not be reached.
set -u
set -o pipefail
# --- validate environment ----------------------------------------------------
: "${SUPABASE_DB_URL:?SUPABASE_DB_URL is required (export it in your shell)}"
: "${SUPABASE_DB_PASSWORD:?SUPABASE_DB_PASSWORD is required (export it in your shell; never hardcode)}"
# --- rewrite the URL to TRANSACTION-MODE (port 6543) -----------------------
# Supabase exposes two poolers on the pooler host:
# * port 5432 -> session-mode (a dedicated session per connection)
# * port 6543 -> transaction-mode (the one we want for serverless workers)
# The pooler hostname is identical; only the port differs. We swap
# :5432/ -> :6543/ in the URL, while leaving scheme, host, user, db
# name, and password query string untouched.
TX_URL=$(printf '%s\n' "$SUPABASE_DB_URL" \
| sed -E 's#:5432/#:6543/#')
# Belt-and-braces guard: refuse to run if we accidentally didn't get the
# transaction-mode port. This makes the intent of the script explicit.
case "$TX_URL" in
*:6543/*) ;;
*) printf 'refusing to run: TX_URL does not target transaction-mode port 6543: %s\n' "$TX_URL" >&2
exit 1 ;;
esac
# --- hand the password to psql via the env, never argv ------------------------
export PGPASSWORD="$SUPABASE_DB_PASSWORD"
# --- run 20 concurrent one-shot queries -------------------------------------
WORKDIR=$(mktemp -d -t pool_smoke.XXXXXX)
trap 'rm -rf "$WORKDIR"' EXIT
# Each psql is a fresh client connection that:
# * connects through the transaction-mode pooler;
# * runs a single trivial query that requires a backend;
# * exits, returning its connection to the pool.
# All 20 fire in parallel via background jobs; we wait for them all.
run_one() {
# -tA : tuples-only, unaligned -> just the pid, no noise
# -v ON_ERROR_STOP=1 : make psql exit non-zero on SQL error
if psql "$TX_URL" \
-tA \
-v ON_ERROR_STOP=1 \
-c "SELECT pg_backend_pid();" \
>"$WORKDIR/$1.out" 2>"$WORKDIR/$1.err"
then
echo ok >"$WORKDIR/$1.status"
else
echo fail >"$WORKDIR/$1.status"
fi
}
pids=()
for i in $(seq 1 20); do
run_one "$i" &
pids+=($!)
done
# Wait for every background job. Track whether any wait returned non-zero.
wait_fail=0
for p in "${pids[@]}"; do
if ! wait "$p"; then
wait_fail=1
fi
done
ok=0
fail=0
for f in "$WORKDIR"/*.status; do
case "$(cat "$f")" in
-rwxr-xr-x 1 root root 4735 Jul 26 02:47 pool_smoke.sh
./pool_smoke.sh echo "exit=$?"
POOL OK 20/20 exit=0
2 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