fix(routing): hop-0-only hybrid on retail GET (#1280) #1281
No reviewers
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!1281
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/1280-hybrid-hop-offer"
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
GET /route/solveemits declaredhybridon hop 0 only; hops 1+ arehybrid: nullso execute cannot freeze quote-time interior splits against realizedhop_output. Wasm keepspool_input + book_input == hop offer.POST hybrid_by_hopstill allows interior splits that partition that hop.wrap_plus_send_2hop_ustc+ wrap-swap E10. Combo gas is not raised (columbus-5 AC1 still unmeasured; no trading wallet in workstation inventory).Playbook:
skills/AGENTS_HYBRID_HOP_OFFER.md(invariants H1280-1–H1280-8).Closes #1280
Test plan
make verify-issue-1280(indexer hop0-only unit, wasm hop0 + interior mismatch reverts, frontend strip/preflight/humanize, docs; first pass + retest)make verify-issue-1264(wrap+2hop 2.71M fixture, wrap hops omit hybrid, docs; first pass + retest)VERIFY_ISSUE_1280_CHAIN=1 make verify-issue-1280(LocalTerra Playwrightmultihop-hybrid-tx)VERIFY_ISSUE_1264_CHAIN=1 make verify-issue-1264(LocalTerra wrap-swap E10)gas_wanted/gas_used/ fee / wallet rewrite (A/B/C). Do not raiseWRAP_ROUTER_COMBO_OVERHEAD_GASwithout that measurement.drain skip: no occupying job for rebase/fix-pr/CI-wait; remaining continue
/agent review
/agent review
cl8y-agent-control: queued
bug_reviewjob55e2dfad-bf66-4f3f-ba78-de861b055fb1(not executed; no Hetzner VM).RECOMMEND: FIX
Frozen SHA:
b0dade6b7ff114501b110d27c456e6ac0ec7ab21(PR 1281 HEADfix/1280-hybrid-hop-offer; prompt frozen SHA was unset). Independent review in an isolated worktree vsorigin/maincf1eff3252a29e07c42f1544dd9e500a53e5c4b9. Does not replace test-only verify or the Kimi security gate.Policy A itself is the right product lock: wasm still fail-closes
pool_input + book_input == hop offer; retail GET nulls hops 1+; POSThybrid_by_hopinteriors remain; wrap/native BFS still omitshybrid(H596-7).estimated_amount_outafter the strip is LCD-sim of emitted ops, and the dApp strips again plus hop-0 preflight before sign. That part matches #1280 AC1–AC6 / H1280-1–H1280-8.One actionable regression blocks ACCEPT.
Findings
1. Medium — DB fidelity compares unstripped joint grid to hop-0-only LCD sim
indexer/src/api/best_execution.rs:405-419(strip + keep pre-stripgrid_outin DB mode),indexer/src/api/best_execution.rs:209-251(apply_fidelity_guard),indexer/src/api/best_execution.rs:945-952(winner fidelity), UIfrontend-dapp/src/utils/swapDisclosure.ts:152-161.ROUTE_SOLVER_DB_HYBRID=1(global_v4, defaultROUTE_FIDELITY_DRIFT_BPS=100), joint optimize still scores interior books, then Policy A nulls hops 1+ beforemaybe_simulate. Fidelity still treats the unstripped mirrorgrid_outasdb_out. If interior books beat pool-only interiors by >1%, a healthy quote is markedfidelity_check=drift,degraded=true,quote_kind=indexer_hybrid_db_degraded. The Swap/Trade chrome then says market data was partially unavailable. The poisoned-mirror guard becomes a Policy A false positive on common ≥2-hop paths (intermediate UST1/USTR books). Execute amount is still the stripped LCD sim (not a fund-theft path), but quote_kind / operatorfidelity_drifttelemetry are wrong, andquote_kind_forcan show hybrid-degraded even afterany_book_legwas recomputed false.ROUTE_SOLVER_DB_HYBRID=1,ROUTE_FIDELITY_DRIFT_BPS=100, router LCD mock.book_input > 0).GET /api/v1/route/solve?token_in=A&token_out=C&amount_in=<hop0 offer>.hybridis null (Policy A) and hop 0 still partitions the offer.(grid_out - lcd_sim) * 10000 / lcd_sim > 100, response isfidelity_check=drift/indexer_hybrid_db_degradeddespite emitted ops matching execute.indexer/tests/api_route_solve_db_hybrid.rshas no 2-hop interior-book case assertingfidelity_check=passedafter hop-0-only emit. LCD 2-hop tests hide this becausegrid_outis replaced without_uwhendb_modeis false (best_execution.rs:419).retail_declared_hybrid_plan_hop0_only, recomputegrid_outwithpropagate_offer_through_plan(or equivalent) on the stripped plan so fidelity compares DB-sim of emitted ops to LCD-sim of emitted ops. Add a DB 2-hop live-book test that stayspassedwhen those two numbers agree.Residuals (not merge-blocking by themselves)
SwapPage.tsx:753-756swallowsHybridHopOfferPartitionErrorfrom quote into pool-only fallback (noteIndexerFailure).executeMultiHopSwapstill fail-closes before sign. Prefer surfacingHYBRID_HOP0_PARTITION_USER_MESSAGEinstead of a silent worse quote.executeMultiHopSwapasserts hop 0 but does not re-strip interiors. Retail GET + quote already strip; wasm still reverts interiors (H1280-8). Optional defense in depth.VERIFY_ISSUE_1280_CHAIN/VERIFY_ISSUE_1264_CHAIN) and columbus-5 #1264 AC1 are unchecked as disclosed. Not a code defect in this SHA.fidelity_driftafter land would be the live check for finding 1.Subagent summary
What looks correct on this SHA
retail_declared_hybrid_plan_hop0_only+ GET testsassert_retail_get_hybrid_hop0_only; POST 3-hop interiors still merge (AC5 / H1280-4).stripInteriorDeclaredHybrid+assertHop0DeclaredHybridPartitionsOfferon quote andexecuteMultiHopSwap; wrap path still serializes pool-only hops (router.ts:380-389).router_declared_split_mismatch_reverts_hop0,router_two_hop_interior_hybrid_mismatch_reverts; existingrouter_two_hop_first_leg_hybrid_matches_simulateis T5 (hop 1hybrid: Noneexecutes).Repair: recompute stripped-plan
grid_outbeforeapply_fidelity_guardand add the DB 2-hop fidelity test. Then re-review this SHA’s successor.