bug(routes): automatic LUNC to USTR intermittently misses an eligible cUSTC route #1489
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/cl8y-dex-terraclassic#1489
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Automatic native LUNC→USTR routing intermittently retains a materially worse two-pool-hop route even when the existing quote API admits a better three-pool-hop cUSTC corridor on the same generation, fair reference, observation time and expiry. This is a route-discovery/promotion bug, with constraint scope and retry fairness to investigate; suppressing the warning or loosening signing protections would not fix it.
Public reproduction: https://dex.cl8y.com/?from=LUNC&to=USTR&exactAmount=10000
Bundle candidate discovery, generation/cache/job constraints, progress/refetch consistency and truthful selected-route explanation in this issue. Follow-up to #1483, #1484, #1485. External DEX integration, route splitting and gas calibration remain separate (#1330/#1203/#1480).
Only independently collected public, anonymous technical observations are included. No conversation, screenshot, reporter identity, wallet/account information, actor-linked history, secrets or private endpoints are published.
Current codebase and independently reproduced evidence
Reviewed source and attested deployed frontend/backend:
4cb5736574072130e8e14a5ea2e297d3062e8212. Backend health matched before/after both API probes. Independent Coolify deployment/served-root attestation passed at 2026-10-13 02:39:41 UTC, including both bootstrap scripts and the app bundle.Actual anonymous browser observation, 02:37:30–02:38:03 UTC: exact 10,000 LUNC input (
10000000000raw), LUNC→cLUNC→UST1→USTR, receive 63.386134401366040994 USTR, one “Price difference” notice around 26.17–26.18%, attributed to limited liquidity. Four successful solve refreshes did not improve the route/output. Ten API reads included four solve and four progress responses, all HTTP200; no best request, writes, wallet, actors or provider requests. No max-hops parameter was sent.An initial bounded 12-GET probe independently reproduced the shorter route at ~26.2–26.3% and quoted the three proposed corridor legs individually. Those sequential leg outputs are not evidence of atomic route eligibility. The stronger test below establishes joint eligibility through an actual native quote response.
Complete three-hop quote discriminator
The existing read-only quote-planning
POST /api/v1/route/solveaccepts:The three null entries constrain evaluation to three pool hops; they do not force a token identity or disable admission. All three POSTs naturally selected cLUNC→cUSTC→UST1→USTR, with native wrapping preserved. This is an investigation discriminator, not a signing workaround or production settlement claim.
At 02:41 UTC, eleven anonymous quote/health requests covered three rounds of GET solve → three-hop POST → GET best. All nine quotes passed the existing strict executable-shape/context/floor validator, and attribution reconciled exactly. Same-generation comparisons:
235060f93b905087491196e4b59b98c8ed4c3f8e9c820211Each comparison matched full generation, observation time, original expiry, authorized gross 10000000000 uluna and credited 9800000000 cLUNC. The three-hop result delivers 33.467896% more net USTR. In round 0 the corresponding fair-reference deviations are 25.9753% versus 1.2008%; rounding/reference updates explain changing percentages, not the raw net-output gap. Three-hop positive final floor:
80370133033555422738; shorter floor:60216827681297738945. Operations are pool-only. The POST reported five structural paths considered; automatic shorter results reported one.A normal GET briefly returned the better route during round 1, then later normal/best requests returned the shorter route again. Promotion is intermittent; this is not a permanent unsupported-hop rejection. Matching a published generation is strong API evidence, but independent atomic production SQL/contract reserves and funded settlement have not been attested.
A separate public catalog read showed active, non-frozen corridor pairs and approximate published TVL: cLUNC/cUSTC $65,836, cUSTC/UST1 $92,293, UST1/USTR $36,902, versus cLUNC/UST1 $3.16. These are reporting marks, not independent usable directional-depth or price certificates; routing must use checked exact economics rather than TVL rankings.
Constraint and bug investigation
local_quote.rsinitially evaluates paths up to two hops. If a useful short route exists, longer paths are evaluated by a background job. Both GET solve and GET best use this local mechanism.admission_generationincludes the global fee-phase revision;FeePhaseGuard::finish(Validated)advances it after successful producer validation, including unchanged observations on unrelated pairs. Such churn can discard deeper results without changing selected-route observation timestamps. Configuration publication and wrapper observations also change generations. These are source-confirmed invalidation mechanisms; which caused these particular live results needs bounded instrumentation/reproduction.MAX_JOBS=4is a necessary capacity bound, but a short result cached when no slot is available returns on later cache hits before deeper scheduling. Audit bounded retry/fairness and cancellation, not just the numeric cap.Why implementation is needed / recommended direction
The current quote can be arithmetically valid yet financially inferior. Exact-amount cache keys and the earlier <0.1% publication-cutoff fix do not ensure longer-route discovery converges under scheduled ingestion and job contention.
Pin one compatible original economics/policy cohort and reproduce the counterexample deterministically. Trace bounded enumeration → admission → evaluation → job scheduling → invalidation/publication → client adoption. Separate true dependencies from unrelated producer revisions only with proof that relevant fee/policy/freeze/reference changes still invalidate unsafe work. Make deferred deeper work retry fairly within existing budgets; preserve useful first output and reviewed-transaction pinning. Ensure solve/best/POST/receive and progress refer to the actual intent. Do not hardcode cUSTC, lower reference floors, remove generation checks or choose a route because its displayed percentage is smaller.
Relevant files
indexer/src/api/local_quote.rs(initial selection ~1774, cache hits ~1740, job admission/publication ~1898–1929, generation ~1097, review binding ~1156).indexer/src/api/local_quote/{skeletons,admission,ingestion,diagnostics,reverse,protection,attribution}.rs;indexer/src/api/{route_paths,route_solver,route_solve_progress}.rs.indexer/src/indexer/fee_phase.rs(validated-producer revision ~682),indexer/src/api/local_wrapper_quote.rs,local_reference_quote.rs,db_orderbook_sim.rs.frontend-dapp/src/pages/SwapPage.tsx,hooks/useRouteSolveProgress.ts,utils/{nativeWrapRouteSolve,routeSolveProgress,routeEconomicExplanation,swapQueryParams,localRouteQuote}.ts,components/swap/SwapImpactAside.tsx,components/trade/TradeMarketOrderPanel.tsx.frontend-dapp/src/services/terraclassic/{offlineSwapBudget,router}.ts,smartcontracts/contracts/router/src/contract.rs.indexer/tests/scenarios/route_cost_attribution_1483.rs,indexer/tests/route_local_quotes_1452.rs, existing frontend/progress/quote tests;docs/route-solver.md,docs/indexer-invariants.md,docs/qa/issue-1483/,skills/AGENTS_ROUTE_COST_ATTRIBUTION.mdand related LQ1452/PR1464 guidance.Guardrails
Preserve offline quote/review/signing, independently scheduled ingestion, original observation/expiry/context, exact gross funding, checked raw integer math, positive upward-rounded hop/final floors, native pool-only policy, 5/30/99 safeguards and unknown-budget signing refusal. Keep independent $10 economic/$100 hub-depth reference floors and original reference quality. Preserve freeze/pause/blacklist, taxes/hooks, repeated-capable-asset/refund guards and bounded work/concurrency. A higher-net candidate must actually satisfy the same supported execution policy. Network fees remain separate. No production reset, shared database mutation, hidden RPC fallback, automatic signing or resend. Advisory explanation/progress never authorizes execution.
Acceptance criteria
./skills/agent guidance, crosslinked to this issue/fix and #1483. Do not equate existing tests, quote HTTP200 or generation equality alone with production settlement.Test plan: supported, boundary and failure paths
Attack, hack and abuse tests
Investigation verification / implementation verification
Executed on unchanged reviewed source:
make verify-issue-1483returned 21 PASS, 0 FAIL, 2 acceptance SKIPs, including first/retest 286 frontend tests per round, raw attribution tests and exact-cohort sockets. Independent deployed frontend/backend/root attestation passed. These tests miss the live counterexample: current native fixture covers direct/two-hop alternatives and the deeper three-hop regression is wrapped on a static generation; concurrent producer/job-cap/native-three-hop cases are absent. The live automatic-ranking counterexample remains FAIL, regardless of this existing source suite's PASS.Bounded Grafana/Loki collection at 02:43:10 UTC covered the previous 15 minutes: no indexer error-pattern matches; all three frontend matches classified as HTTP200 access entries, with no nginx error/404/5xx matches. Capacity-pattern entries remain diagnostic, not proof of a cause. Prometheus is explicitly SKIP because no datasource is provisioned. These logs do not explain candidate publication; bounded per-stage evidence is still needed.
Complete feasible verification before claiming acceptance. Add the meaningful independent regressions above, run the new verifier plus
verify-issue-1483,1452,1473,1479,1480and applicable1464,1453,1391,1398,1381,1390,1396. Fix executed failures, reset only owned affected fixtures and retest stable final source. Record exact UTC/revisions/tool hashes/cohorts/raw outputs/counts and p50/p95/p99/max; separately attest deployment/contracts. Existing source checks or a manually constrained quote cannot certify automatic routing, independent reserves, physical-wallet signing or production settlement. Human-only signing/device actions belong in concise cl8y-pm cards. Unavailable checks may be explicit SKIP, but never check incomplete acceptance or close the issue.Implemented in PR #1490, merged revision
74e7ad03629832076f59614e6b37ee868fe62c9c. Genuine Woodpecker pipeline 441 passed all required jobs on PR headef944f54cf07f89cebe120d6450be575441276b8. Deployment and final live acceptance are in progress; this comment does not claim production settlement.The fix preserves useful short quotes while coalesced FIFO discovery retries within the existing four-worker limit. Unchanged successful producer validation no longer invalidates compatible deeper work; real economic changes and original expiry still revoke unsafe results. Exact eligible delivered net drives promotion, native wrapping remains separate from the four pool hops, and truncated search is explicit. Swap/Trade progress follows the exact intent and reviewed transactions remain pinned. A separately reproduced presentation defect is fixed: an unchanged fresh quote keeps its >5% notice during background refresh while signing remains blocked. Genuine economics and threshold changes still update the notice.
Completed verification subsets:
Detailed checklist and receipts distinguish verified subsets from incomplete acceptance. The issue stays open until all body/comment requirements have evidence.
Independent live verification on merged/deployed
74e7ad03629832076f59614e6b37ee868fe62c9cfound an additional entry-state defect: fresh default Swap shows “Wrapping is temporarily unavailable.” before any amount is entered. Desktop and phone layouts both retained this false notice at 0 and 5 seconds. The bounded browser capture made four API reads and zero writes, actor requests, provider reads or WebSockets; it captured no screenshots. Independent backend/frontend/root-script attestation passed for this baseline.The implement → verify → deploy loop continues in a follow-up branch. PR #1490 remains the routing/notice-refresh implementation; this baseline does not establish the new entry-state fix or final acceptance. #1489 stays open.
The neutral native-entry follow-up is merged in PR #1492, main revision
af79043096ecf80b0d85fab443f60e3f9c7c5eed. Genuine pipeline 446 passed all required jobs on final PR headc00d6cba6f8238018afb3496112e0c84728b5404, including 3,397 frontend tests, the production build, indexer library and isolated Postgres integration. Both Coolify deployments have started; final live-entry acceptance is pending.Broader #1489 acceptance remains open. The separate canonical-generation follow-up is still undergoing performance, cancellation, known-negative guard and related source verification; this UI-only merge does not certify it or production settlement. The retained deployed
74e7ad03empty-state failure and earlier API/monitoring failures are not rewritten as passes.Live neutral-entry verification is PASS on
af79043096ecf80b0d85fab443f60e3f9c7c5eed(PR #1492). Both Coolify deployments completed at that revision with zero fatal log patterns; an independent attester verified backend health, frontend HTML and every served bootstrap/app root script.The prior deployed
74e7ad03entry failure remains recorded (four checks, all failed). The focused checklist links the implementation and source tests; this comment supplies its deployed acceptance receipt.This passes the neutral-entry follow-up, not whole #1489 acceptance or production settlement. The separate canonical-generation/performance/known-negative follow-up is still being implemented and verified. Independent atomic production SQL/reserves, mapper/treasury artifact correspondence and physical signing remain unchecked; the issue stays open.
The canonical-publication follow-up is merged in PR #1493, main revision
8500370c2d4475accca879064ad61fe186ccfd18. Genuine Woodpecker pipeline 449 passed all eight mandatory jobs on final PR headc23f9b314f5dc29b62031802094ecc7495ee709f. Both Coolify deployments are starting; final deployed acceptance remains pending.The fix makes identical effective qualified observations produce stable generations after newer-view preservation. Full immutable-book hashing runs in at most two bounded CPU jobs outside the quote lock; cancelled callers cannot publish. Actor proofs bind completed blacklist observations before optional fee enrichment, preserve newer blocks/conservative unblocks and revoke stale discounts after authoritative inventory resets or record recycling. Original expiry, qualification, references, four quote workers, queue/search limits, offline requests and signing/funding/floor guards remain enforced.
Completed verification subsets:
skills/guidance crosslink this issue, PR #1493, the earlier fixes and #1483.The current-source receipt and checklist retain original failures and separate source/owned-fixture evidence from production settlement. The already live empty-entry UI fix is PR #1492; this follow-up does not rewrite its earlier deployment receipts. #1489 stays open until its complete body/comment acceptance has evidence.
Live verification on merged/deployed
8500370c2d4475accca879064ad61fe186ccfd18is incomplete. Both Coolify deployments finished with zero fatal patterns, and independent backend/frontend/all-root attestation passed. The implement → verify → deploy loop continues in a follow-up.Additional deterministic source tests reproduce a real refresh fault: the same “not blocked” result and same verified discount can change an anonymous quote generation without changing its original expiry. Overlapping fee responses and an older false blacklist response also require stronger ordering authority. Those regressions are being fixed and retested with the browser-tool corrections; no cause is inferred for the historical production counterexample or any private report.
The prior source/CI/deployment passes and all failed/unverified live receipts remain separate. #1489 stays open; no incomplete acceptance criterion is checked or replaced by a source-only pass.
The final combined follow-up is merged in PR #1494, main revision
efb5fba29d3dc401d0d026d8b683db8054458920. Genuine Woodpecker pipeline 452 passed all eight required jobs on final PR head72fb044e28342b0591ee0309956d92ecba25ec1e; main and the worktrees were synchronized without discarding changes.The fixes retain unchanged qualified economics and verified actor fees through refresh, reject out-of-order guard/fee responses, retry bounded deeper discovery fairly, and preserve the exact progress intent and reviewed transaction. The startup empty/zero/cleared wrapping notice is neutral; positive quotes still enforce wrapper and execution admission. Component first/retest controls verify that a fresh unchanged price-difference notice remains present during background refresh. No safeguard, original expiry, resource cap or signing refusal was relaxed.
skills/instructions crosslink the fix, this issue and #1483. Current checklist, actor-refresh receipt and browser lifecycle distinguish source evidence from production acceptance.Deployed/live verification on the final main revision:
Both Coolify deployments finished at the exact main revision; deployment logs contain 58 frontend / 295 backend rows with zero fatal patterns. Independent backend/frontend/HTML/all-root-script attestation passes.
API first/retest: 92 anonymous read-only quote-planning requests, 78 strictly validated useful executable quotes, maximum initialized response 290.436ms within the original 500ms limit; original context, floors and attribution checks remain enforced.
AC2/AC3 complete live convergence: UNVERIFIED. Five final same-original-cohort comparisons pass, but zero of six original windows fully establish solve/best convergence and automatic POST agreement. No proven three-second miss is inferred from unavailable cohorts.
AC4/AC6 complete sustained actual-browser evidence: the #1489 FIRST has all 12 useful/adopted/exact-progress samples but two native 185-second samples exceed 750ms (791.7/792.8ms). Unchanged RETEST passes 12/12, maximum 743ms. Passive RETEST measurements directly show a roughly 300ms idle connection/TLS phase on desktop native Swap; the original FIRST had no connection-phase capture, so its cause remains unproved. The FIRST failures remain FAIL.
Complete #1483 actual-browser corpus: both runs reach the unchanged 100-admitted-read guard after 15/18 cases. All 30 observed cases are useful within 750ms (FIRST maximum 444.2ms; RETEST 418.3ms), but both full runs remain ReadBudget FAIL. Attempted/admitted reads are 144/100 and 120/100; denied requests are not executed provider calls or proven latency failures. No page leak or safe cleanup is established by aggregate counts, and the cap is not raised.
Startup wrapping presentation: 32 actual desktop/phone empty/zero/cleared samples across four bounded rounds have zero false wrapping-unavailable notices. The additional passive-expiry FIRST/RETEST also pass four positive native 1,000 USTC controls with original context/floors/available attribution, unexpired at the unchanged 500ms sample; 20 reads and zero writes/actors/providers/WebSockets. The earlier positive-control RETEST remains FAIL: a desktop empty display has no captured expiry proof, and a phone
missing_observationsHTTP503 recovered to a valid quote. Additional passes do not erase those observations.Clean complete monitoring: original 900-second post-traffic FIRST/RETEST remain FAIL with 2/5 ANSI-confirmed ERROR entries, all HTTP503 traces. Readiness is caught up/HTTP200 at the exact revision; frontend 404/5xx/nginx-error and integrity checks are clear. Four RETEST entries are new after all owned quote traffic ended; one earlier entry aged out. Trace entries omit request paths/IDs, so endpoint and cause remain unverified; one FIRST timestamp overlaps the recorded positive-control failure, which alone does not prove request identity. Earlier 17 ERROR entries and the misleading plain-severity-zero predicates are retained; those zeros are insufficient evidence. Discovery-stage counts remain zero/unverified and Prometheus is unavailable.
Human-only wallet handoff: tested read-only preparation is PREPARED at the final revision (13 reads, no signing/broadcast), native 10,000 LUNC and matched-credit 9,800 cLUNC quotes have positive floors and available attribution. Both automatic controls currently use two pool hops; preparation is neither atomic-cohort nor three-hop settlement proof. One desktop inbox card, “Verify an automatic native quote in your wallet” (
56ac9d8f-75af-4567-a03c-5dbedc7496a8), is queued and independently GET-verified. Its one command reads scoped OpenBao credentials without printing them and obtains fresh quotes before opening the wallet pages. The direct DEX structured link was rejected; the same card was accepted with the existing physical-wallet tracker link and the direct #1489 URL in its body. It does not complete that tracker's separate #1480 fee-review criteria.Copy-paste preparation command (no automatic signing):
Only AC7 is checked in the issue body. AC1–AC6 remain unchecked and #1489 stays open. Follow-up evidence is needed for complete same-cohort promotion, stable browser deadlines/full bounded corpus, the current HTTP503 causes, and independent production/wallet scope. Original deployed failures, budget-denied browser runs and unavailable cohort windows are not rewritten as passes.
PlasticDigits referenced this issue2026-10-15 05:32:59 +00:00
Closed at the user's request as part of consolidating issues #1449–#1500.
Bounded discovery, producer invalidation/fairness, exact-net promotion, stable publication and progress/entry follow-ups are merged and deployed. The demonstrated remaining native recovery/503 problem moves to #1504; missing historical acceptance evidence alone is not a new task.
Replacement: #1504
Wallet/device chores and verification-only holds are intentionally excluded. Historical failed receipts remain unchanged; this closure does not claim every old acceptance checkbox passed.
The 2026-10-15 repository reconciliation recovered the remaining local branch history and inspected the stale worktrees/stash. The browser lifecycle and execution-readiness merge commits introduce no new product changes relative to current main; newer policies and issue links are retained. The route-discovery stash is already incorporated by
1536631292and subsequent actor-inventory safety corrections, so the stale snapshot was not reapplied.Four differing historical QA records are preserved separately in docs/qa/merge-reconciliation-2026-10-15/recovered, with provenance/checksums in recovery-manifest.json. Current canonical receipts and artifact checksum lists remain in place. Private ignored configuration/artifacts and original recovery files were saved outside Git before the merged worktrees/branches/stash were removed. No production or shared database was reset, and no deployment/settlement claims are added. This completed implementation issue remains closed; outstanding live implementation work stays in its existing follow-up issues.
Final local verifiers passed: #1489 = 20 PASS / 0 FAIL / 2 explicit acceptance SKIP; #1483 = 21 PASS / 0 FAIL / 2 explicit acceptance SKIP. The first runs retained stale-database PoolTimedOut failures; complete reruns on a fresh owned fixture passed. The fixture was removed afterward. CI was explicitly skipped; details are in docs/qa/merge-reconciliation-2026-10-15/verification.json.