Reconciliation Runbook
The reconciliation engine (financial_integrity, migration 017/021/022) evaluates invariant checks over D1 and records findings + deduplicated exceptions. It never auto-repairs money — only state-surfacing fixes (stale lease release) are automatic; everything else stays needs_review/exception until an operator acts.
Running a scan
http
POST /api/v1/admin/reconciliation/run # start/resume {run_id?}
GET /api/v1/admin/reconciliation/reports
GET /api/v1/admin/reconciliation/report/:id1
2
3
2
3
- A run is
running(resumable via cursor),completed,degraded(some check ERROR/INCOMPLETE — partial coverage, never reported as completed), orfailed. - The 5-minute cron also runs: outbox dispatch → settlement sweep → one recon run → audit assurance.
yp integrity status|report|verify(devpay-cli) is a read-only wrapper over these endpoints.
Check findings → exceptions
Each check maps findings to reconciliation_findings rows; the engine then syncs them into reconciliation_exceptions by fingerprint:
- New fingerprint →
OPENexception + event. - Re-observed →
occurrence_count+1(no new row); fromREVERIFYING/terminal →REOPENED. - Absent + producing check completed while
REVERIFYING→RESOLVED.
Triage workflow
http
GET /api/v1/admin/financial-integrity/summary # severity counts, stale items
GET /api/v1/admin/financial-integrity/exceptions?status=OPEN
POST .../exceptions/:id/transition {to_status:"TRIAGED", reason:"..."}1
2
3
2
3
auto_fixedfindings (stale outbox/inbox lease, orphan settlement claim release) — verify follow-on delivery, then close viaCLOSED_AS_FALSE_POSITIVEonly if truly benign; otherwise continue the state machine.needs_reviewfindings (money/entitlement drift) — pick a recovery op from financial-integrity or fix manually, then moveREMEDIATING → REVERIFYINGand re-run recon orRUN_RECON_VERIFY.- Alert stub: ≥3 consecutive
failed/degradedruns produce analert:recon_failuresaudit evidence record (external notification is PLANNED — checkaudit_evidencevia admin endpoints, not email/Slack).
Fail-closed guarantees
- A missing DB row or query error is never treated as clean — checks report
ERROR, runs reportdegraded. INCOMPLETEchecks reportremaining>0— never silently pass partial scans.
S1 stabilization notes (main, 85f113b / 45ffde5 / cc75724 — after 45e270c)
- Audit chain strict everywhere —
audit_prevresolution was made strict (85f113b) and the compatibility wrapper deleted (45ffde5); a chain-write failure fails the request instead of writing an unsealed record. Applies to recon/exception/recovery evidence writes too. {e}-leak fixes — public error bodies on the fixed sites no longer leak{e}literals (45ffde5); the sweep of pre-existing sites is a non-blocking S2 follow-up.- Suite status (local loopback) — integrity 22/22 and the new
failclosedsuite 20/20 at45ffde5; exceptions-ops 38/38 and audit-evidence 47/47 are prior-wave numbers not re-run in S1. - CI reporting — the
financial-integrityjob summary now derives PASS/FAIL/SKIPPED/BLOCKED/NOT_VERIFIED from realsteps.*.outcome(cc75724); an actual GitHub Actions run of it isNOT_VERIFIED. - Alerts still stub-only —
alert:recon_failuresaudit records remain the whole alert path; external notification is stillPLANNED/NOT_VERIFIED(unchanged).
S2 assurance notes (main cabbc7f–940fd75)
- New finding types (s2-02
e6a05cf).settlement_consistencynow also emitssettlement_membership(bidirectionalorder_ids_json↔orders.settlement_id, dup/broken JSON),post_settlement_refund(post-commit refunds on member orders — surfaced, not absorbed into gross),settlement_fee_mismatch(fee recompute from the stored bp snapshot), andsettlement_run_mismatch(settlement ↔settlement_runscross-check).reference_integritygained the payments-orphan leg (payment row with no order). All areneeds_review— manual triage per the workflow above. settlement_consistencyfalse positive fixed (s2-02). Recon's authority forgrossis now the pipeline's committedΣ(amount_krw − refunded_krw); a committed settlement containing apartially_refundedorder no longer trips permanentog<>gfindings. Previously-recorded such findings were true false positives and can beCLOSED_AS_FALSE_POSITIVEafter a clean run.- Cron run lifecycle (s2-10
1daf526). The scheduled tick now reaps stalerunningruns (→failed+INCOMPLETEchecks) and resumes a liverunningrun at its cursor instead of always creating a new run — a budget-paused run can no longer stall forever between ticks. alert:evidence_gaps(s2-10).scheduled_assurancealso folds sealed-without-evidence / burned-sequence residue into a chain-sealedalert:evidence_gapsrecord — same evidence-only alert channel asalert:recon_failures(external delivery stillPLANNED).recon.persistFI probe (s2-02, test seam).recon.persist/recon.persist.<run_id>injected-failure probes drive targeted run-failure legs — gatedDEV_AUTH+ non-prodPAYMENT_MODE, inert in production config.- Suite status (local loopback): recon2 39 legs (
run-recon2.sh); wired into thefinancial-integrityCI job at1b4f139— first real CI runNOT_VERIFIED.