Skip to content

Commit 71a9ad9

Browse files
lexwhitingclaude
andcommitted
docs(circle-nano): backfill runbook — cut on settled_at (not created_at) + record confirmed prod env
Correctness fix to the uncredited-/settle backfill cutoff. A row CREATED pre-deploy that FLIPS to settled post-deploy is credited by the new code (in-request or the reconciler tail), so a created_at cutoff would double-credit it. markSettlementSettled stamps settled_at on every flip, so `settled_at < prod_live_ts` selects exactly the rows that reached terminal 'settled' before the new crediting code existed — the only uncredited set. Also records the 2026-06-02 prod-env confirmation (recipient set → kernel /settle was live; CIRCLE_NANO_API_KEY unset → proxy was dark). Local-only docs fix (no runtime impact; not pushed unless bundled with a later change). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 130fa7b commit 71a9ad9

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

docs/tech-debt/circle-nano-uncredited-backfill-runbook-2026-06-02.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,24 @@ one, and the pre-chunk reconciler credited only x402 — so EVERY circle-nano `s
1717
before the Phase-2 deploy is uncredited.
1818

1919
## Sequencing
20-
Run AFTER: (1) prod env confirmed, (2) Phase-2 deployed. Use the **deploy timestamp (UTC)** as the
21-
cutoff so post-deploy settles (which now credit in-request) are excluded — no double-credit.
20+
Run AFTER: (1) prod env confirmed ✅ (2026-06-02: recipient SET → kernel `/settle` was live; API key
21+
unset → proxy was dark), (2) Phase-2 deployed + Ready in production.
22+
23+
**Cutoff = `settled_at` < the production-live timestamp (UTC), NOT `created_at`.** Why: a row *created*
24+
pre-deploy that only *flips to settled* post-deploy is credited by the new code (in-request or the
25+
reconciler tail), so a `created_at` cutoff would double-credit it. `markSettlementSettled` stamps
26+
`settled_at` on every flip, so `settled_at < deploy_live` selects exactly the rows that reached terminal
27+
`settled` BEFORE the new crediting code existed — the only ones that are (and stay) uncredited. A
28+
boundary row settled right at the cutoff is excluded (errs toward under-credit = safe; inspect any
29+
`settled_at` near the cutoff by hand). Get the production-live timestamp from the Vercel dashboard
30+
(the production deployment's "Ready"/promoted time).
2231

2332
## Step 1 — inspect a sample (confirm row shape)
2433
```sql
25-
SELECT id, account_id, amount_cents, operation_id, settlement_status, created_at, metadata
34+
SELECT id, account_id, amount_cents, operation_id, settlement_status, settled_at, created_at, metadata
2635
FROM ledger_entries
2736
WHERE rail = 'circle-nano' AND settlement_status = 'settled'
28-
ORDER BY created_at
37+
ORDER BY settled_at
2938
LIMIT 10;
3039
```
3140

@@ -35,13 +44,13 @@ SELECT
3544
account_id AS developer_id,
3645
COUNT(*) AS settled_rows,
3746
SUM(amount_cents) AS uncredited_cents,
38-
MIN(created_at) AS earliest,
39-
MAX(created_at) AS latest
47+
MIN(settled_at) AS earliest_settled,
48+
MAX(settled_at) AS latest_settled
4049
FROM ledger_entries
4150
WHERE rail = 'circle-nano'
4251
AND settlement_status = 'settled'
4352
AND amount_cents > 0
44-
AND created_at < '<PHASE2_DEPLOY_TS_UTC>' -- e.g. '2026-06-02 21:00:00+00'
53+
AND settled_at < '<PROD_LIVE_TS_UTC>' -- the Vercel production-live time, e.g. '2026-06-02 21:00:00+00'
4554
GROUP BY account_id
4655
ORDER BY uncredited_cents DESC;
4756
```
@@ -64,7 +73,7 @@ FROM (
6473
WHERE rail = 'circle-nano'
6574
AND settlement_status = 'settled'
6675
AND amount_cents > 0
67-
AND created_at < '<PHASE2_DEPLOY_TS_UTC>' -- SAME cutoff as Step 2
76+
AND settled_at < '<PROD_LIVE_TS_UTC>' -- SAME cutoff as Step 2
6877
GROUP BY account_id
6978
) agg
7079
WHERE d.id = agg.account_id;

0 commit comments

Comments
 (0)