fix(protocol): prevent false liquidity collapses from lost coverage #1382

Merged
PlasticDigits merged 3 commits from fix/issue-1380-liquidity-quality into main 2026-10-04 10:56:00 +00:00
Owner

When reserve or price coverage disappears, Protocol currently publishes incomplete AMM TVL as a complete zero/low value, contaminating charts and percentage baselines. This change publishes explicit quality, original input time, supported-pool membership and a monotonic generation; unavailable values are null and partial sums are labeled lower bounds. Genuine validated zero and real valuation changes remain visible.

Both refresh entry points serialize before reads and atomically publish the headline, per-pair stamps, bounded terminal source observations and all three grains. Baselines require comparable membership. Reserve work has bounded concurrency, deadlines, book walks and response sizes. The frontend exposes quality with keyboard/mobile access and treats unqualified legacy history as unknown. Scoped historical repair preserves original evidence, survives replay after recovery, and never copies today's TVL into history.

Implements #1380. The issue remains open for production release/history acceptance.

Acceptance checklist:

  • AC1: unchanged positive inputs → stale/missing-price outage → recovery never manufacture fresh zero, -100% or a complete zero chart point.
  • AC2: material supported-pool loss/missing reserve rows are explicitly degraded; permanently unsupported pairs do not block valid catalog coverage.
  • AC3 implementation controls: genuine drained pools and observed empty inventory can show zero; withdrawals and price changes are recomputed without smoothing. Live funded withdrawal is separately skipped below.
  • AC4: coherent atomic generations, interleaved writers, rollback at every persistence stage, replay rejection, restart/cold reads (including a populated incomplete first enumeration) and independent cached age.
  • AC5 production acceptance: all grains/baselines and idempotent scoped repair pass fixtures; applying/reconciling the cited production hours remains unverified.
  • AC6: honest quality/age, legacy payload safety, accessible chart gaps and unchanged Volume/Fees and TVL consumers.

Validation:

  • Full indexer library: 461 tests passed.
  • New valuation/reserve and 43 PostgreSQL/API/reserve tests per aggregate pass; repeated twice, including all 29 liquidity integration cases.
  • 88 targeted frontend tests passed twice, plus 200 consumer tests; TypeScript, ESLint, source formatting and gitleaks passed.
  • 3 new quality and 13 existing Protocol browser tests passed together, including 390px/1280px, keyboard/tap, independent expiry, legacy gaps and true zero.
  • Aggregate verifier also runs verify-issue-569, 689, 655, 664, 1263; final results are recorded in the linked receipt.
  • Materialized query plans and redacted public before/health evidence are committed. Production health still reports the pre-fix revision.

Agent review: follow docs/qa/issue-1380/README.md and skills/AGENTS_PROTOCOL_LIQUIDITY_QUALITY.md, record the tested SHA, run make verify-issue-1380, inspect assertions and the repair evidence, and preserve PASS/FAIL/SKIP separately. An agent may mark overall PASS with explicit skips for unavailable checks when every completed check passes; skipped checks are never counted as completed criteria, and an executed failure remains FAIL.

Explicit skips: this PR is not deployed, so production revision/repair/after-evidence is unverified; LocalTerra is running and public reserves were captured/replayed, but an isolated funded live LP-withdrawal/outage control was not performed. These do not block implementation review under the task instruction. Deploy the nullable API and frontend together, apply the SQLx quality migrations, then run the read-only probe with --expect-quality. No contract migration or production signing is required for this fix.

Review links: checklist, verification receipt, agent playbook.

When reserve or price coverage disappears, Protocol currently publishes incomplete AMM TVL as a complete zero/low value, contaminating charts and percentage baselines. This change publishes explicit quality, original input time, supported-pool membership and a monotonic generation; unavailable values are null and partial sums are labeled lower bounds. Genuine validated zero and real valuation changes remain visible. Both refresh entry points serialize before reads and atomically publish the headline, per-pair stamps, bounded terminal source observations and all three grains. Baselines require comparable membership. Reserve work has bounded concurrency, deadlines, book walks and response sizes. The frontend exposes quality with keyboard/mobile access and treats unqualified legacy history as unknown. Scoped historical repair preserves original evidence, survives replay after recovery, and never copies today's TVL into history. Implements #1380. The issue remains open for production release/history acceptance. Acceptance checklist: - [x] AC1: unchanged positive inputs → stale/missing-price outage → recovery never manufacture fresh zero, -100% or a complete zero chart point. - [x] AC2: material supported-pool loss/missing reserve rows are explicitly degraded; permanently unsupported pairs do not block valid catalog coverage. - [x] AC3 implementation controls: genuine drained pools and observed empty inventory can show zero; withdrawals and price changes are recomputed without smoothing. Live funded withdrawal is separately skipped below. - [x] AC4: coherent atomic generations, interleaved writers, rollback at every persistence stage, replay rejection, restart/cold reads (including a populated incomplete first enumeration) and independent cached age. - [ ] AC5 production acceptance: all grains/baselines and idempotent scoped repair pass fixtures; applying/reconciling the cited production hours remains unverified. - [x] AC6: honest quality/age, legacy payload safety, accessible chart gaps and unchanged Volume/Fees and TVL consumers. Validation: - Full indexer library: 461 tests passed. - New valuation/reserve and 43 PostgreSQL/API/reserve tests per aggregate pass; repeated twice, including all 29 liquidity integration cases. - 88 targeted frontend tests passed twice, plus 200 consumer tests; TypeScript, ESLint, source formatting and gitleaks passed. - 3 new quality and 13 existing Protocol browser tests passed together, including 390px/1280px, keyboard/tap, independent expiry, legacy gaps and true zero. - Aggregate verifier also runs `verify-issue-569`, `689`, `655`, `664`, `1263`; final results are recorded in the linked receipt. - Materialized query plans and redacted public before/health evidence are committed. Production health still reports the pre-fix revision. Agent review: follow `docs/qa/issue-1380/README.md` and `skills/AGENTS_PROTOCOL_LIQUIDITY_QUALITY.md`, record the tested SHA, run `make verify-issue-1380`, inspect assertions and the repair evidence, and preserve PASS/FAIL/SKIP separately. An agent may mark overall PASS with explicit skips for unavailable checks when every completed check passes; skipped checks are never counted as completed criteria, and an executed failure remains FAIL. Explicit skips: this PR is not deployed, so production revision/repair/after-evidence is unverified; LocalTerra is running and public reserves were captured/replayed, but an isolated funded live LP-withdrawal/outage control was not performed. These do not block implementation review under the task instruction. Deploy the nullable API and frontend together, apply the SQLx quality migrations, then run the read-only probe with `--expect-quality`. No contract migration or production signing is required for this fix. Review links: [checklist](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/fix%2Fissue-1380-liquidity-quality/docs/qa/issue-1380/README.md), [verification receipt](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/fix%2Fissue-1380-liquidity-quality/docs/qa/issue-1380/verification.md), [agent playbook](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/fix%2Fissue-1380-liquidity-quality/skills/AGENTS_PROTOCOL_LIQUIDITY_QUALITY.md).
fix(protocol): qualify liquidity coverage and terminal history
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline was canceled
a18e5db3da
Publish atomic TVL generations with nullable quality, bounded reserve refresh, comparable baselines and scoped evidence-preserving repair. Add accessible quality displays, failure controls and agent verification guidance.
docs(protocol): link liquidity quality review and verification
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
b9a50bb49c
Merge main and preserve liquidity and receive sizing guidance
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
4934d71758
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code/cl8y-dex-terraclassic!1382
No description provided.