fix(trading): remove generic quote validation errors, default USTC to CL8Y, and widen bidirectional tests #1473
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#1473
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?
Trading quote failures by amount/direction, deterministic USTC → CL8Y default, and broader regression coverage
Problem and required behavior
Valid trading inputs can replace a working output with a persistent generic “Route validation rejected this quote” error when only the amount or direction changes. Refreshing is not a useful remedy for a deterministic rejection. The default trading flow also selects CL8Y → ALPHA through catalog order rather than the intended native USTC (
uusd) → CL8Y direction.These are bundled trading-flow defects: quote pricing and execution eligibility need clear separate outcomes, defaults need an explicit product policy, and regression acceptance needs to cover both directions and substantially more amounts/pairs. For a supported, liquid, representable input, show a quick amount-specific net price estimate. When liquidity, amount, capability, or protection prevents execution, explain that specific condition without exposing an internal route-validation error. A generic validation rejection in the retail UI is a bug, even when rejecting the transaction is correct. Do not manufacture prices for unpriceable inputs or imply an indicative estimate is executable.
Investigation and reproducible evidence
Reviewed source:
72084767e3a85fcfedb94a83bb027b3454e0ad82, merged PR #1472. Read-only API probes independently attested that exact indexer revision before and after each run on 2026-10-11 UTC. No wallet, signing, broadcasts, production mutations, or screenshots were used. The frontend build must be attested separately; backend health is not frontend build provenance. A fresh disconnected browser independently confirmed the bare/entry selects CL8Y → ALPHA, while bare/tradeselected a genuine UST1/ALPHA factory pair. Neither entry defaults to native USTC → CL8Y.At
max_spread=0.05, the exact-input UST1/CL8Y reproduction at 05:08:55–05:09:33 UTC was:All three rejected sizes were requested again after more than 20 seconds, beyond the observation TTL, and still returned 422 with the fixed server text “No eligible route within the selected protection.” Total: 11 requests, 5 HTTP 200, 6 HTTP 422. An independent production browser trial also reproduced the 10 → 100 UST1 transition: 10 showed approximately 14.74393 CL8Y, 100 displayed the generic route-validation rejection, and returning to 10 restored output. The reverse browser flow also quoted 1, 10 and 100 CL8Y, displayed the same generic rejection at 1000 CL8Y, and recovered on returning to 100. The completed browser trial at 05:13:37–05:15:30 UTC checked nine amount transitions with 14 quote requests, two generic rejections, and zero non-read attempts. Prices vary by observation; automated expected outputs must derive from pinned observations rather than hardcode a displayed estimate.
A wider census at 05:07:00–05:08:51 UTC covered six unordered pairs in both directions, each at
0.000001,0.01,1,100, and10000human units: USTC/CL8Y, CL8Y/ALPHA, CL8Y/USTR, USTR/cUSTC, LUNC/cUSTC, and USTC/LUNC. Initial census: 60 requests, 41 HTTP 200, 19 HTTP 422. Three small CL8Y → USTC rejections subsequently became HTTP 200 after the TTL: 63 total, 44 HTTP 200, 19 HTTP 422. This recovery is retained and must not be described as a persistent failure. Large CL8Y → ALPHA and CL8Y → USTR sizes, tiny mixed-decimal inputs, and all initially tested cUSTC → LUNC sizes also rejected. These results establish wider coverage gaps; they do not prove every rejection should allow execution or establish the precise economic cause.The probes matched normal native-mode handling (
pool_only=trueif either end is native), used 5% protection and maker cap 8, and supplied no actor. API positive shape checks are not complete client validation, signing acceptance, or browser latency acceptance. Existing #1472 live evidence covered four directed paths with two size classes; it did not establish broad pair/amount coverage or the reverse direction for each pair. Independent cold HTTP timing is not comparable to initialized browser input-to-useful-output latency.Current codebase and confirmed failure pathways
indexer/src/api/route_solver.rs: current GET, best, and POST routes delegate to the local quote engine. HTTP 422 here is not proof of a failed on-chain router query; some OpenAPI descriptions still imply remote validation.indexer/src/api/local_quote.rs:eligible_error()emits a single 422. Candidate scoring returnsOption, losing the specific reason for spread, dust/zero output, reserve plausibility, tax credit, hook/split arithmetic, and reference-deviation rejection.indexer/src/api/local_quote/diagnostics.rs: any prerequisite-complete fresh path can cause unsuccessful scoring to be classified asProtection. This cannot distinguish all amount/direction-specific failures or explain whether pricing exists but execution is blocked.indexer/src/api/local_reference_quote.rs: raw-unit rounding and reference eligibility can change sharply with direction and 6/18-decimal amounts.frontend-dapp/src/services/indexer/client.ts: non-2xx responses are reduced to status/status text, discarding the server's reason.utils/humanizeOffChainError.tsmaps every 422 to generic route-validation rejection.utils/indexerErrors.tscorrectly prevents fallback after authoritative 422 and must retain that safety property.frontend-dapp/src/utils/localRouteQuote.tsandcw20RouteSolveQuote.ts: a separate HTTP-200 rejection path validates exact operations, metadata, actors, amount, tax funding, original expiry, spread and floors. It emits “Quote unavailable” and must not be confused with HTTP 422.frontend-dapp/src/pages/SwapPage.tsxandutils/pairCatalogRank.ts:defaultRetailSwapTokenPair()chooses the first two eligible IDs, depending on supplied catalog order.pages/TradePage.tsxauto-selectsfirstCatalogPairAddress()for bare/trade.frontend-dapp/src/utils/tradeQueryResolve.ts,tradePairRoute.ts,tradePairDisplayOrientation.ts, andcomponents/trade/TradeMarketOrderPanel.tsx: factory pair resolution, display orientation, and executable pay/receive direction are distinct. Changing a displayed pair label alone does not implement USTC → CL8Y funding.Root cause of each economic rejection is not yet established. Preserve the exact sampled inputs, add bounded reason evidence, and compare local integer economics against contract behavior before deciding whether the underlying scoring is incorrect, liquidity/protection genuinely blocks execution, or data/capability loss was mislabeled.
Recommended implementation direction
Option::None. Aggregate across eligible alternatives without allowing an unrelated broken route to erase the real outcome. Distinguish missing/stale observations, unsupported semantics, dust/amount limits, insufficient liquidity, arithmetic/accounting failures, and genuine selected-protection rejection. Keep technical diagnostics low cardinality and private; return a reviewed public reason contract./tradecannot represent native funding, support an explicit native-capable market-ticket path or navigation to that flow; do not invent a factory/virtual economic pair or silently relabel cUSTC as USTC. Specify deterministic behavior when configured identities or usable liquidity are absent.skills/instructions and a new agent QA checklist, crosslinked with this issue and the eventual fix.Constraints and guardrails
Preserve LQ1452, PR1464, LF1453, NE1398, RT1381, LG1390, GR1428, FRQ1422, PD1394, DB1396, oracle safety and quote-coverage #1459.
bao-execfrom openbao-tools for scoped credentials.Acceptance criteria
Temporary user instruction (2026-10-11 UTC): AC7 uses 750 ms for now. Earlier 500 ms FAIL receipts remain evidence; socket budgets and economic protection percentages are unchanged.
skills/, this issue and the fix. Attest deployed frontend and backend separately, inspect classified logs, and repeat live matrix checks beyond 20-second observation and 180-second configuration cycles.Test plan: all affected paths
Relevant existing tests to extend:
indexer/tests/route_local_quotes_1452.rs,scenarios/fee_generation_recovery_1464.rs;frontend-dapp/src/utils/localRouteQuote.test.ts,cw20RouteSolveQuote.test.ts,utils/__tests__/pairCatalogRank.issue562.test.ts,pages/SwapPage.queryParams.test.tsx,pages/TradePage.test.tsx,components/trade/__tests__/TradeMarketOrderPanel.submitSnapshot.test.tsx;frontend-dapp/e2e/swap-query-params.spec.ts,swap-direction-seam-659.spec.ts,swap-route-alignment-tx.spec.tsandtrade-market-route-solve-501-tx.spec.ts. Confirm filenames and extend appropriate existing suites rather than adding tests that mirror implementation branches.Security, attack and abuse test plan
Agent verification and release criteria
make verify-issue-1452,verify-issue-1464,verify-issue-1453and applicable floor/tax/guard/database/provider checks (1398,1381,1390,1399,1422,1394,1392,1396). Use owned fixtures and supported toolchain; fix executed failures and retest. Document any unavailable prerequisite instead of waiting on an unrelated hold.Related scope: #1464, #1452, #1459, #1456 and #1330. This is a new reproducible trading UX/coverage defect, not a claim that earlier narrow checks failed or that those broader rollout items are complete.
Sanitized reproduction artifacts
All three public receipts were privacy-checked and downloaded without credentials to verify identical bytes. Browser source revision is explicitly unattested; public asset filenames are recorded separately. These are baseline bug-reproduction results, not verification of a fix.
PRs #1474 and #1475 are merged. The deployed application revision is
ea627f7b0e8d5ebc9fde2bb5b243f451cf159f4d. The QA/CI follow-up #1476 is also merged, and main is pushed at2d1627ffa33eb3e08199acfff574a5b63fcfbd39; its product trees are byte-identical to the deployed application. No app redeployment was needed for the QA/CI changes. Hosted pipeline 410 passed all six required jobs with exit 0 on exact PR headff2ee8f8d71cf132de9d342eb918b486ba7f3d5d; backend and frontend separately completed deployment of the merged revision, with backend health and served frontend root artifacts independently attested.The fix computes amount-specific net quotes with exact selected UI tolerance, separate reviewed market-spread ceilings and positive rounded-up floors. Missing/stale observations now show an indeterminate loading bar until independently scheduled eligible data arrives. Original client expiry removes stale display/signing data promptly; unknown transport/client-validation forward failures retain ten-second cadence; typed deterministic local blockers stop interval retries, receive errors have no interval retries, and typed missing/stale recovery watches changed publication. No token-specific economics, request-triggered RPC, reference-floor reduction, extra price panel or invented completion/ETA was added.
Completed subitems:
90ae4cf2…, types/lint, and unchanged backend scopes tested separately.uusd→ configured CL8Y requests, bound native gross/wrapper/route metadata and independently validated visible net. All four pass with four quote GETs and unchanged before/after exact revision/root artifact matches; no wallet/signing/broadcast.Whole acceptance criteria (do not check a criterion from a passing subset):
The initial KENA 7/8 elapsed-budget trial remains FAIL; the zero-sample/zero-GET KENA phone retest setup timeout and native-default prerequisite attempt also remain FAIL. Narrower completed trials and the corrected private artifact parser do not relabel those earlier failures. The physical-wallet/device action is queued in the PM inbox as “Check KENA loading in the mobile wallet browser”; it is not a completed acceptance check. The card has four observation steps and requires no swap or signing. The inbox-assigner skill was used for this specific operator action required by the repository instructions. The dashboard could not link the DEX repository; the card uses its verified inbox-master association and includes this DEX issue URL in its body. Classified runtime logs are a bounded window with producer/oracle warnings, not proof of sustained pricing readiness or absence of all errors.
The current socket trial covered solve+best twice with a 181-second gap: 1,680 classified responses (997 executable, 683 blocked), no shape/classification failures, and 13 executable samples above the separate 500 ms limit. New transport: n=2, p50/p95/p99/max 849.585/1029.957/1029.957/1029.957 ms; reused: n=995, 287.625/452.714/750.397/825.929 ms. Overall FAIL remains.
The original capped live browser trial also remains FAIL: 426/1,680 rows, 420 first-desktop classified, 286 useful, 134 typed blocked/waiting, nine useful timing failures and six phone visibility failures; useful p50/p95/p99/max 353.1/383/942.6/987.2 ms. The six phone rows received prompt independently validated matching HTTP 200 results, but the receive/surface visibility check stayed false. The helper opened Settings and did not close it before input; expanded-state and exact offscreen versus opacity geometry were not recorded, so these are verification setup/visibility failures, not established product pricing timeouts. The helper's final-cycle/backend and final root-artifact checks were not reached. A separate official post-run attestation passed eight bounded reads for both deployed revisions and unchanged frontend root hashes; it does not complete the interrupted trial.
PR #1476 changes the verification helper/tests, trusted CI runner/tests, stale image-pin ledger records, public-key Docker copy permissions, and their documentation. The helper closes Settings and confirms both amount fields intersect before installing the original-input clock; invisible output still cannot pass. Eleven actual helper/DOM tests passed twice plus an independent root run, and the measurement closure remained byte-identical. App code has no diff. Measured QA tool head is
cf176c0ee426991b417341c277f19220bb2b4a5d, fingerprintb4c64d57d87ab7c064bc144564a088e50135d8be009c70794ceadab2f55c993e; the deployed app remainsea627f7b0e8d5ebc9fde2bb5b243f451cf159f4d.The corrected reproduction completed all 96 first/retest UST1↔CL8Y samples in both viewports across the 181-second gap. All 96 had independently validated matching visible useful output, zero visibility timeouts, 120 quote GETs and no writes/WebSockets. Five backend revision checks and both root-artifact boundary checks matched the unchanged app; tool head/fingerprint matched before/after and its owned browser was cleaned up. This is a bounded reproduction, not the expanded full matrix. Overall FAIL remains because two first-phone samples took 1008.4 and 1005.1 ms. All useful samples: p50/p95/p99/max 362.2/684.5/1008.4/1008.4 ms; desktop n=48: 355.6/431/690.7/690.7; phone n=48: 401.4/735.4/1008.4/1008.4. Cache misses n=39: 363.3/680.5/684.5/684.5; cache unobserved n=57: 362.2/735.4/1008.4/1008.4; hits n=0. All 96 transports were reused; no cold-transport browser acceptance is claimed.
QA CI413 and the single unchanged-source retry414 failed during canvas dependency installation, before frontend lint/test/build; downstream indexer jobs were skipped and completeness failed. Those remain actual FAIL. The native-build prerequisite repair is reviewed and the immutable policy is deployed at
28272783a171911e1b249381d0dbf7a4b48ca98d, health hash80da17a5428fe88f1803ab592a474a51b3a3e52a7c954284f59f6793dcf982b4. An independent two-read check confirmed the hash and exclusive signed/no-netrc settings. Required status checks were preserved.The CI repair keeps ordinary npm installation and all six mandatory jobs, adds the native compiler/Cairo/Pango/DejaVu prerequisites, then forces a fresh Canvas rebuild and checks nonempty objects/binding, exact RGBA and rendered Pango text. Installation, compilation or rendering failures cannot record PASS. The public Ed25519 key bytes are unchanged; Docker copies that public file read-only for the nonroot service independently of checkout permissions. Fifteen hermetic runner cases passed twice and all nine available #1400 groups passed; existing image references were verified against official registry bytes, with five stale ledger entries reconciled to their unchanged declarations. The attempted local exact-image native fixture remains unavailable and is not native proof.
The policy-only rollout completed from exact reviewed commit
28272783a171911e1b249381d0dbf7a4b48ca98d; its hash is80da17a5428fe88f1803ab592a474a51b3a3e52a7c954284f59f6793dcf982b4, independently read back with unchanged exclusive/no-netrc settings. Nonroot health passed and unsigned configuration requests returned 401. The previous pin/hash was preserved for rollback. No required context, signing key, job graph, image declaration or resource cap was weakened.Pipeline 416 passed all six real jobs with exit 0 and exact-head log markers on
80009d6f755abf59438ed9562fb34d5ed551ed08. A fresh independent API read also confirmed all six successful states. The actual pinned worker produced 17 Canvas CXX compile lines, linked the purged native binding, used two make jobs, and passed the anchored exact RGBA/DejaVu/Pango render check. Full frontend 3,240 tests/363 files plus lint/type/build, 999 contract tests, 774 indexer library tests and 84 Postgres tests passed. The one manual cache benchmark and one runtime-DDL credential fixture remain explicitly ignored; this is not complete database acceptance. Pipeline 415 was killed when superseded by the final documentation head, separately from the executed 413/414 failures.The normal server merge and local main fast-forward/push completed at
2d1627ffa33eb3e08199acfff574a5b63fcfbd39, with no incoming main commits and all three unrelated user files byte-preserved. Reviewed head is an ancestor and its tree matches the merged tree. Retained full live failures, corrected bounded reproduction, and CI repair/provenance are crosslinked with the invariants and agent instructions.Agent review: use the checklist and data-wait/cadence instructions. Verify each item's actual integer/result/identity assertion, original expiry, expected disabled signing state and source/artifact/UTC scope. Unavailable checks may be explicit SKIP with reason and prerequisites; an agent may mark the stated executed scope PASS WITH SKIPS when every executed check in that scope passes. Executed failures retain FAIL and incomplete acceptance remains unchecked.
The issue-body AC4 and AC5 boxes are checked after independent review and readback. #1473 remains open: not every current body/comment criterion passes. This comment records implemented functional improvements and their actual verification limits, not complete issue acceptance.
PlasticDigits referenced this issue2026-10-15 05:32:59 +00:00
Closed at the user's request as part of consolidating issues #1449–#1500.
Typed outcomes and deterministic defaults are implemented. The demonstrated native quote availability/recovery problem moves to #1504.
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.