feat: persist reconcile orphans and keep them visible until resolved #68

Sammanfogat
supernaut sammanfogade 2 incheckningar från feat/66-orphan-visibility in i main 2026-10-01 21:23:30 +00:00
Ägare

What

Keep reconcile orphans visible until resolved, without log floods. No grant, refund, cancel or charge logic changes.

  • Quiet replay: handleWebhook(deps, body, quiet). Reconcile passes true, which silences the two [webhook] ... left unprocessed lines. Real webhooks log as before.
  • Persistent marker: new reconcile_orphan(payment_ref pk, first_seen, reason, resolved_at), migration 0005. The alert line [reconcile] <id> is paid at the provider with no settled local charge; needs manual review (text unchanged) is logged only when the row is inserted (ON CONFLICT DO NOTHING RETURNING), so a restart does not re-alert and overlapping sweeps log once.
  • Past the window: unresolved rows outside the 14-day window are re-checked against local charges and resolved once settled. They are never replayed, since a late replay would date the first renewal in the past.
  • Summary line: every pass with unresolved orphans logs [reconcile] <n> unresolved orphan(s), oldest <ref> since <first_seen>; needs manual review. The infra alert matches both lines, so it stays firing until all orphans are resolved. This also covers a lost first line.
  • Manual resolve: README SQL statement, after the Mollie dashboard review step.

Verification

  • Postgres 17: 265/265. Each new test fails with the change reverted.
  • Independent review: safe to push, quiet is logging-only, exactly-once insert holds under overlapping sweeps, migration matches conventions.

Not done

  • Listing Mollie subscriptions to catch orphan subscriptions before they charge.
  • #67: settled() treats a failed local charge as settled (pre-existing, found in review).

Closes #66

## What Keep reconcile orphans visible until resolved, without log floods. No grant, refund, cancel or charge logic changes. - **Quiet replay:** `handleWebhook(deps, body, quiet)`. Reconcile passes `true`, which silences the two `[webhook] ... left unprocessed` lines. Real webhooks log as before. - **Persistent marker:** new `reconcile_orphan(payment_ref pk, first_seen, reason, resolved_at)`, migration 0005. The alert line `[reconcile] <id> is paid at the provider with no settled local charge; needs manual review` (text unchanged) is logged only when the row is inserted (`ON CONFLICT DO NOTHING RETURNING`), so a restart does not re-alert and overlapping sweeps log once. - **Past the window:** unresolved rows outside the 14-day window are re-checked against local charges and resolved once settled. They are never replayed, since a late replay would date the first renewal in the past. - **Summary line:** every pass with unresolved orphans logs `[reconcile] <n> unresolved orphan(s), oldest <ref> since <first_seen>; needs manual review`. The infra alert matches both lines, so it stays firing until all orphans are resolved. This also covers a lost first line. - **Manual resolve:** README SQL statement, after the Mollie dashboard review step. ## Verification - Postgres 17: 265/265. Each new test fails with the change reverted. - Independent review: safe to push, `quiet` is logging-only, exactly-once insert holds under overlapping sweeps, migration matches conventions. ## Not done - Listing Mollie subscriptions to catch orphan subscriptions before they charge. - #67: `settled()` treats a `failed` local charge as settled (pre-existing, found in review). Closes #66
supernaut lade till 2 incheckningar 2026-10-01 21:17:29 +00:00
Reconcile passes no longer repeat the [webhook] unprocessed lines.
Orphans are recorded in reconcile_orphan, so the [reconcile] alert fires
once across restarts and an orphan stays listed past the 14-day window
until it settles or an operator sets resolved_at.

Closes #66
feat: log an unresolved orphan summary on every reconcile pass
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m6s
14fff84d4f
The first-seen line fires once. A summary line each pass keeps an
aged-out or unalerted orphan visible until it is resolved.
supernaut sammanfogade incheckning 3c6506da29 till main 2026-10-01 21:23:30 +00:00
supernaut tog bort grenen feat/66-orphan-visibility 2026-10-01 21:23:30 +00:00
supernaut refererade denna ändringsförfrågan från en incheckning 2026-10-01 21:26:09 +00:00
supernaut refererade denna ändringsförfrågan från en incheckning 2026-10-01 21:45:03 +00:00
supernaut refererade denna ändringsförfrågan från en incheckning 2026-10-02 17:57:02 +00:00
Logga in för att delta i denna konversation.
Inga granskare
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-payment!68
Ingen beskrivning angiven.