Skip to content

id(currency): issued conversion quotes are never evicted — expired quotes accumulate in the gateway verifier forever #13864

Backlog

Description

@dezren39

Evidence

pkgs/id/src/currency/conversion.rs on origin/main (1edf803aa5c79b8bbf4c14292ce2fe1d2861ffab):

  • ConversionVerifier holds quotes: BTreeMap<u128, ConversionQuote> (:594). The struct docs say one instance is the gateway's single consult point at submission time (:586-589) — i.e. this map lives as long as the gateway.
  • The only mutation of that map anywhere in the id crate is self.quotes.insert(quote_id, quote.clone()) in issue_quote (:845). Crate-wide grep for quotes.remove / retain / clear / take finds nothing.
  • verify_quoted only gets (:874); an expired quote is refused with QuoteExpired (:877-881) but left in the map.
  • Every quote dies 60 s after issuance (QUOTE_LIFETIME_SECS = 60, :457), yet nothing ever sweeps dead entries.

So each issuance permanently grows the verifier's map: after N quotes the gateway holds N entries, N-minus-live of them unusable expired weight. This is verification by code read — there is no removal path to exercise, so no runtime repro can show anything else.

Secondary observation for triage (same root cause, no lifecycle after issuance): verify_quoted takes &self and never consumes the quote, so one quote_id can back repeated executions for its whole 60 s lifetime. Issuance commits no usage and execution re-checks the cap, so the cap bounds the damage, but the docs ('a quote pays exactly the quoted computed_y and fee') read single-use. Triage should decide whether quotes are single-use (consume on execute) or intentionally multi-use within their lifetime.

Why it matters

Unbounded state growth in a long-lived gateway singleton: memory grows linearly with cumulative quote volume, and every lookup/insert pays for a map full of dead entries. At gateway traffic this is a slow leak with no operator-visible signal until it hurts.

Acceptance criteria

  • Expired quotes do not accumulate: e.g. evict entries past quote_expires_at on issue_quote/verify_quoted (clock available via submission.now), or a bounded book with explicit eviction.
  • Decide and document the single-use vs multi-use question above; if single-use, consume the quote on successful execution.
  • Regression test: issue quotes, advance past expiry, show the book no longer retains them (and, if single-use, that a second execution under the same id is refused).

Suggested fix shape

Sweep self.quotes against submission.now at the top of issue_quote and verify_quoted (both already take a now-carrying submission), and consider remove-on-successful-execute if triage lands on single-use. Keep it in the verifier — no new background task.

Dedupe

Distinct from #13822 (overwrite on reused id — same map, opposite end: that one is about insert clobbering a live entry, this one is about entries never leaving), #13698 / PRs #13814 + #13820 (usage-book keying, not the quote book), and closed design #3802 (no eviction requirement stated there). No open PR touches the quote book.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-23T23:47:40Z",
    "session_id": "ses_e5df5338bfbffe86d56tbi0dKu",
    "lane": null,
    "host": "amd",
    "worktree": "/home/user/git/code",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/user/git/code",
      "repo": "developing-today/code",
      "branch": "main",
      "sha": "57597b8540ac0aa94d347a1b9609a6f29abee6ac"
    },
    "auth_subject": "oc-code-04",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Activity

  1. developing-today commented on Nov 23, 2026

    @developing-today
    Contributor
  2. added
    epic/id-maintenance
    primary-parent/id-maintenance
    stray-work
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    epic/id-maintenanceprimary-parent/id-maintenancestray-work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions