fix(indexer): isolate rejection caches and bound pair discovery (#1394) #1405

Merged
PlasticDigits merged 3 commits from fix/issue-1394-pair-discovery into main 2026-10-06 02:05:58 +00:00
Owner

Foreign swap-event rejections could suppress legitimate pairs in independent LCD/factory contexts, and cache lookups scanned up to 10,000 entries. Pair discovery now owns rejection and admission state inside each LCD client, with isolated factory budgets and bounded targeted lookup/FIFO eviction. Client clones share state; rebuilding the client starts a fresh namespace.

The cache retains at most 16 factories × 512 entries (8,192 total), with a fixed one-hour TTL. Each factory admits a burst of 32 discoveries, replenishes eight per second, and permits four in flight. Known pairs bypass discovery; temporary admission pressure waits and rechecks the DB. Canonical Terra Bech32 validation and 64 KiB discovery response limits reject pollution before expensive work. Only deterministic contract/provenance rejection is cached, cached reasons remain distinct, and fixed outcome counters are exposed and logged in aggregate.

Closes #1394.

Completed issue criteria

  • AC1: an LCD/factory rejection cannot suppress a different namespace's legitimate pair.
  • AC2: parallel discovery tests pass without global clears or serialization of library tests.
  • AC3: cache memory/work stays bounded under churn; cached foreign pairs avoid repeated pair/factory queries.
  • AC4: timeout/failover never creates a negative entry; direct typed errors, cached reasons and admission outcomes remain observable.

Verification

make verify-issue-1394 on tested revision d5ee494c9f0db4ec295d6c8b4ebb06e2e993f160: 23 checks passed, zero failed, zero skipped. Final documentation commit adds only the receipt.

  • Full default-parallel library: 491 passed; manual benchmark executed separately.
  • Focused discovery: eight default + eight 32-thread runs, seven tests per run, zero failures.
  • Discovery/cache/admission regression and high-thread retest: 29 passed each.
  • Postgres persistence/failover/coalescing: nine passed twice on a dedicated memory-backed local Postgres 16 fixture.
  • Hot lookup and 100,000-entry churn benchmarks passed; per-factory queue/map ceiling and full namespace capacity assertions passed.
  • Indexer Clippy exited zero with existing unrelated warnings. Normal commit hooks passed contract formatting/Clippy, message policy and Gitleaks. Frontend hook stage skipped because the isolated worktree has no frontend dependencies and no frontend source changed.

A post-commit retest found an overly short recovery timeout in a new fixture. Its failed receipt is retained in the results; the fixture was corrected and the complete verifier passed twice afterward, including the exact tested revision above.

Agent review and scope

Invariants: PD1394-1–10. Agent instructions: review checklist and skip policy. UTC timestamps, exact commands, benchmark measurements, completed criteria and failed attempts: accepted receipts. These documents crosslink AGENTS, indexer invariants, testing and the implementation.

Agents should run every available checklist item first. Unavailable checks may be marked SKIP with a concrete reason/evidence and left unchecked while reporting PASS with explicit skips; executed failures remain FAIL until corrected and retested. The verifier supports an explicit unavailable-Postgres reason.

Production deployment/flood, remote chain attestation, device/wallet QA and crash durability remain unverified and are outside this source-fix acceptance. Configured LCD failover endpoints must serve the same chain. The getter retains its existing warning/soft-skip policy for transient discovery failures; later events retry without poisoned evidence, but replay of an already soft-skipped event is not added.

Foreign swap-event rejections could suppress legitimate pairs in independent LCD/factory contexts, and cache lookups scanned up to 10,000 entries. Pair discovery now owns rejection and admission state inside each LCD client, with isolated factory budgets and bounded targeted lookup/FIFO eviction. Client clones share state; rebuilding the client starts a fresh namespace. The cache retains at most 16 factories × 512 entries (8,192 total), with a fixed one-hour TTL. Each factory admits a burst of 32 discoveries, replenishes eight per second, and permits four in flight. Known pairs bypass discovery; temporary admission pressure waits and rechecks the DB. Canonical Terra Bech32 validation and 64 KiB discovery response limits reject pollution before expensive work. Only deterministic contract/provenance rejection is cached, cached reasons remain distinct, and fixed outcome counters are exposed and logged in aggregate. Closes #1394. ## Completed issue criteria - [x] AC1: an LCD/factory rejection cannot suppress a different namespace's legitimate pair. - [x] AC2: parallel discovery tests pass without global clears or serialization of library tests. - [x] AC3: cache memory/work stays bounded under churn; cached foreign pairs avoid repeated pair/factory queries. - [x] AC4: timeout/failover never creates a negative entry; direct typed errors, cached reasons and admission outcomes remain observable. ## Verification `make verify-issue-1394` on tested revision `d5ee494c9f0db4ec295d6c8b4ebb06e2e993f160`: **23 checks passed, zero failed, zero skipped**. Final documentation commit adds only the receipt. - Full default-parallel library: **491 passed**; manual benchmark executed separately. - Focused discovery: **eight default + eight 32-thread runs**, seven tests per run, zero failures. - Discovery/cache/admission regression and high-thread retest: **29 passed** each. - Postgres persistence/failover/coalescing: **nine passed twice** on a dedicated memory-backed local Postgres 16 fixture. - Hot lookup and 100,000-entry churn benchmarks passed; per-factory queue/map ceiling and full namespace capacity assertions passed. - Indexer Clippy exited zero with existing unrelated warnings. Normal commit hooks passed contract formatting/Clippy, message policy and Gitleaks. Frontend hook stage skipped because the isolated worktree has no frontend dependencies and no frontend source changed. A post-commit retest found an overly short recovery timeout in a new fixture. Its failed receipt is retained in the results; the fixture was corrected and the complete verifier passed twice afterward, including the exact tested revision above. ## Agent review and scope Invariants: [PD1394-1–10](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/f8a951490cf1214725e92f9905216fb72ed9fdf7/skills/AGENTS_PAIR_DISCOVERY_CACHE.md). Agent instructions: [review checklist and skip policy](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/f8a951490cf1214725e92f9905216fb72ed9fdf7/docs/qa/issue-1394/README.md). UTC timestamps, exact commands, benchmark measurements, completed criteria and failed attempts: [accepted receipts](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/f8a951490cf1214725e92f9905216fb72ed9fdf7/docs/qa/issue-1394/RESULTS.md). These documents crosslink AGENTS, indexer invariants, testing and the implementation. Agents should run every available checklist item first. Unavailable checks may be marked **SKIP** with a concrete reason/evidence and left unchecked while reporting **PASS with explicit skips**; executed failures remain **FAIL** until corrected and retested. The verifier supports an explicit unavailable-Postgres reason. Production deployment/flood, remote chain attestation, device/wallet QA and crash durability remain unverified and are outside this source-fix acceptance. Configured LCD failover endpoints must serve the same chain. The getter retains its existing warning/soft-skip policy for transient discovery failures; later events retry without poisoned evidence, but replay of an already soft-skipped event is not added.
Scope rejection evidence and work admission to LCD clients and factories. Preserve deterministic provenance, typed transient errors, bounded telemetry, and event recovery under admission pressure.
Separate forced timeouts from healthy response budgets. Assert flood work against elapsed admission capacity without assuming scheduler speed.
docs(indexer): record issue 1394 verification receipts
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
f8a951490c
Record repeated parallel tests, bounded cache measurements, Postgres recovery tests, and verification scope.
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!1405
No description provided.