Local cached quote engine and pinned signing (#1452) #1455

Merged
PlasticDigits merged 7 commits from fix/issue-1452-local-quotes into main 2026-10-09 11:57:40 +00:00
Owner

Swap requests previously waited for chain simulation and reference solves, then could select a thin route that failed the caller's protection. This change returns generation-bound local quotes, ranks delivered output subject to actual spread, and pins reviewed operations and positive floors through signing. It addresses #1452; full issue acceptance remains incomplete.

The indexer publishes independently scheduled, bounded snapshots of liquidity, books, identity/configuration, known actor context, hooks, wrapper conversion and independent references. Direct/two-hop candidates establish a baseline; bounded deeper local work can improve it. Amount/target results and topology skeletons are cached separately. Request middleware, cache hits, progress and quote preparation perform no chain validation or simulation. Unknown required semantics fail explicitly.

Swap/Trade consume the local metadata, preserve exact native gross authorization and receive-target floors, keep the baseline through failed refresh, and use offline gas budgets. Exact decimal protection handles 0.14% and 0.29%. Unsupported pay/10 advice and overlapping quote-related chain polling were removed. Escrow-backed book output can exceed AMM reserves; fully filled pure-book quotes support empty AMMs. Known wallet blocks survive census eviction and trigger bounded runtime quarantine on capacity exhaustion. A topology-cache lock regression is corrected. Existing 30% Expert handling, the nonwaivable 99% guard, wallet budgets and on-chain settlement controls remain.

Validation of the final source (commits bf056511 and 30ae2024):

  • make verify-issue-1452: 14 PASS, 0 FAIL, 0 source-check SKIP, including first run and retest with unchanged source fingerprint.
  • Each run: 613 library tests, the explicitly executed manual benchmark, 3 disposable-DB socket tests, 181 frontend tests, 40 controlled full-Chrome quotes. Types/formatting/docs checks passed; commit hooks and secret scanning passed.
  • Socket misses: maxima 12.584 / 11.937 ms; warm/concurrent maxima 46.926 / 45.324 ms. Useful baseline 2.300 / 2.161 ms, later improvement 5.007 / 5.471 ms. Zero quote-stage provider calls.
  • Controlled production-build browser: maximum 57.2 ms across desktop/phone Swap/Trade, zero chain requests or page errors. Native HTTP fixture, disconnected wallet, isolated full-Chrome lifecycle; this does not establish deployed production latency.
  • Contract workspace: 999 tests passed; contract source unchanged.

Issue checklist:

  • AC2: eligible cached direct/two-hop candidate search and throwing-provider proof; unsupported modes fail explicitly.
  • AC4: bounded deeper local improvement without delaying the useful baseline.
  • AC10: focused verifier/retest, current budget/optimality docs and agent invariants/crosslinks.
  • AC1: complete route corpus across all tax/actor/execution semantics.
  • AC3: deployed production-reference server/browser latency, including normal external transport.
  • AC5: complete ingestion/feed and connected-wallet network corpus.
  • AC6–AC7: full populated-book/tax/tier, dense-graph abuse and refresh coverage. Implemented exact-key caching/coalescing, reference/reserve/hook/pin/freeze invalidation and controlled age regressions pass locally.
  • AC8–AC9: complete wallet/device/settlement and every unavailable-mode acceptance scenario. Local display/preflight/signing guards, stale intent, 30/99 protections and removal of unsupported size advice are tested.

Remaining implementation scope: community-tax forwards, deducting-hook inverse, explicit manual-split POST and direct zero-hop wrap/unwrap remain unsupported. Unknown actor context uses conservative full fees and cannot represent fresh wallet-specific approval. The bounded retained-actor cache keeps 2,048 contexts and refreshes 120 recent plus 8 historical wallets per pass; quarantine recovery requires a complete authoritative inventory, presently unavailable. Large configuration populations can exceed the 180-second initialization budget; incremental admission is unfinished. Native retail routes retain pool-only semantics. Ancillary balance/account and actual broadcast network reads are outside the disconnected-browser corpus. Independent reserve-feed/provider recovery stays coordinated with #1453. Do not close #1452 or describe this branch as production-ready.

Agent review: follow the checklist, run make verify-issue-1452 in this worktree with isolated QA credentials, inspect meaningful selection/network/floor assertions, fix failures and retest. Unavailable checks may be explicit SKIP with reason and remaining scope while marking review PASS WITH SKIPS when executed checks pass. Failed assertions remain FAIL; skipped deployment is not deployment evidence. Results and failure receipts and LQ1452 agent invariants document the supported scope and source modules.

Swap requests previously waited for chain simulation and reference solves, then could select a thin route that failed the caller's protection. This change returns generation-bound local quotes, ranks delivered output subject to actual spread, and pins reviewed operations and positive floors through signing. It addresses #1452; full issue acceptance remains incomplete. The indexer publishes independently scheduled, bounded snapshots of liquidity, books, identity/configuration, known actor context, hooks, wrapper conversion and independent references. Direct/two-hop candidates establish a baseline; bounded deeper local work can improve it. Amount/target results and topology skeletons are cached separately. Request middleware, cache hits, progress and quote preparation perform no chain validation or simulation. Unknown required semantics fail explicitly. Swap/Trade consume the local metadata, preserve exact native gross authorization and receive-target floors, keep the baseline through failed refresh, and use offline gas budgets. Exact decimal protection handles 0.14% and 0.29%. Unsupported pay/10 advice and overlapping quote-related chain polling were removed. Escrow-backed book output can exceed AMM reserves; fully filled pure-book quotes support empty AMMs. Known wallet blocks survive census eviction and trigger bounded runtime quarantine on capacity exhaustion. A topology-cache lock regression is corrected. Existing 30% Expert handling, the nonwaivable 99% guard, wallet budgets and on-chain settlement controls remain. Validation of the final source (commits bf056511 and 30ae2024): - `make verify-issue-1452`: **14 PASS, 0 FAIL, 0 source-check SKIP**, including first run and retest with unchanged source fingerprint. - Each run: **613 library tests**, the explicitly executed manual benchmark, **3 disposable-DB socket tests**, **181 frontend tests**, **40 controlled full-Chrome quotes**. Types/formatting/docs checks passed; commit hooks and secret scanning passed. - Socket misses: maxima **12.584 / 11.937 ms**; warm/concurrent maxima **46.926 / 45.324 ms**. Useful baseline **2.300 / 2.161 ms**, later improvement **5.007 / 5.471 ms**. Zero quote-stage provider calls. - Controlled production-build browser: maximum **57.2 ms** across desktop/phone Swap/Trade, zero chain requests or page errors. Native HTTP fixture, disconnected wallet, isolated full-Chrome lifecycle; this does not establish deployed production latency. - Contract workspace: **999 tests passed**; contract source unchanged. Issue checklist: - [x] AC2: eligible cached direct/two-hop candidate search and throwing-provider proof; unsupported modes fail explicitly. - [x] AC4: bounded deeper local improvement without delaying the useful baseline. - [x] AC10: focused verifier/retest, current budget/optimality docs and agent invariants/crosslinks. - [ ] AC1: complete route corpus across all tax/actor/execution semantics. - [ ] AC3: deployed production-reference server/browser latency, including normal external transport. - [ ] AC5: complete ingestion/feed and connected-wallet network corpus. - [ ] AC6–AC7: full populated-book/tax/tier, dense-graph abuse and refresh coverage. Implemented exact-key caching/coalescing, reference/reserve/hook/pin/freeze invalidation and controlled age regressions pass locally. - [ ] AC8–AC9: complete wallet/device/settlement and every unavailable-mode acceptance scenario. Local display/preflight/signing guards, stale intent, 30/99 protections and removal of unsupported size advice are tested. Remaining implementation scope: community-tax forwards, deducting-hook inverse, explicit manual-split POST and direct zero-hop wrap/unwrap remain unsupported. Unknown actor context uses conservative full fees and cannot represent fresh wallet-specific approval. The bounded retained-actor cache keeps 2,048 contexts and refreshes 120 recent plus 8 historical wallets per pass; quarantine recovery requires a complete authoritative inventory, presently unavailable. Large configuration populations can exceed the 180-second initialization budget; incremental admission is unfinished. Native retail routes retain pool-only semantics. Ancillary balance/account and actual broadcast network reads are outside the disconnected-browser corpus. Independent reserve-feed/provider recovery stays coordinated with #1453. Do not close #1452 or describe this branch as production-ready. Agent review: follow [the checklist](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/fix/issue-1452-local-quotes/docs/qa/issue-1452/README.md), run `make verify-issue-1452` in this worktree with isolated QA credentials, inspect meaningful selection/network/floor assertions, fix failures and retest. Unavailable checks may be explicit **SKIP** with reason and remaining scope while marking review **PASS WITH SKIPS** when executed checks pass. Failed assertions remain **FAIL**; skipped deployment is not deployment evidence. [Results and failure receipts](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/fix/issue-1452-local-quotes/docs/qa/issue-1452/RESULTS.md) and [LQ1452 agent invariants](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/fix/issue-1452-local-quotes/skills/AGENTS_LOCAL_SWAP_QUOTES.md) document the supported scope and source modules.
fix: quote swaps from cached snapshots (#1452)
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
bf056511e9
Add bounded local route selection, scheduled observations and pinned execution floors. Record source verification and remaining acceptance scope.
fix: retain wallet blocks and admit escrow-backed book routes
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
30ae2024f6
Preserve bounded negative contexts and policy publication, support funded book output independently of AMM reserves, and avoid topology cache lock conflicts. Add regressions and final verification receipts.
PlasticDigits changed title from WIP: Local cached quote engine and pinned signing (#1452) to Local cached quote engine and pinned signing (#1452) 2026-10-09 11:38:07 +00:00
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!1455
No description provided.