Repository navigation
Description
Summary
ConversionVerifier::issue_quote stores every issued quote with a bare
BTreeMap::insert, so a second issuance under an already-held quote_id
silently destroys the first quote. The record's own contract says the id is
gateway-generated, unique in the book — the code enforces neither half:
ids are caller-supplied and collisions overwrite with no error.
Evidence
pkgs/id/src/currency/conversion.rs:470-471—quote_id
(gateway-generated, unique in the gateway's store).pkgs/id/src/currency/conversion.rs:791-793— issuance stores the quote
under quote_id — a gateway-generated id, unique in the book, in the same caller-supplied-id shape as the pure layer's transfer ids. Caller-chosen
ids in a verifier-global namespace, with uniqueness only promised in prose.pkgs/id/src/currency/conversion.rs:845—
self.quotes.insert(quote_id, quote.clone()). Nocontains_keycheck,
no error arm;BTreeMap::insertoverwrites and the old quote is gone.- Readers (
:612-614quote(),:867-902verify_quoted) give no
hint a replacement happened: the first quoter's execution just starts
failing withQuoteMismatch(different auth/amount pinned under its id),
or silently inherits the second quote'sissued_at/quote_expires_at
window when auth and amount coincide. - Design context: Phase 3 of id: design: RateAuthorisation as a signed ID-graph object — schema, signing, revocation #2290, id(currency): quote issuance + binding for RateAuthorisation (Phase 3 of #2290) #3802 (commit
dbf76598b86).
Repro
Temporary in-module test, reverted afterwards, on scratch at origin/main
a77026ed:
let mut verifier = ConversionVerifier::new();
let first = issue_valid_quote(&mut verifier, 77); // x = 100
assert_eq!(first.x, 100);
let mut other = valid_submission();
other.amount = 200;
let second = verifier
.issue_quote(&eligible_control(), &other, 77, 0, 0)
.unwrap(); // Ok — no error
assert_eq!(second.x, 200);
assert_eq!(verifier.quote(77).unwrap().x, 200); // first quote lostcargo test --lib currency::conversion::tests::repro_quote_id_silent_overwrite
run in pkgs/id: test ... ok — the overwrite is confirmed, not
hypothesized. Tree reverted to clean afterwards.
Why it matters
Quote ids are caller-supplied into a verifier-global book with no ownership
or uniqueness enforcement. Any caller (or retry path) that reuses an id —
accidentally via collision, or maliciously — destroys someone else's
in-flight quote. The victim gets a confusing QuoteMismatch refusal at
execution time, inside its 60-second lifetime, for a quote that verified fine
at issuance. Same-auth/same-amount collisions are worse: execution succeeds
but under a different quote's expiry window, with no signal.
Acceptance criteria
- Issuance under a
quote_idthat already holds an unexpired quote is
refused with a typed pre-flight/store error (or an explicit, documented
replace-with-acknowledgement path) — never a silent overwrite. - Regression test: issue id 77 for x=100, re-issue id 77 for x=200 is
refused;quote(77).xstays 100; the first quoter'sverify_quoted
still passes. - Existing
currency::conversion::tests(all quote tests:
pinning, scale-awarecomputed_y, refusal propagation, expiry,
since-revoked, superseded-version, unknown-quote, amount mismatch,
exact-amount execution) keep passing.
Suggested direction (not implemented)
Check self.quotes for a live entry before inserting and return a typed
error (e.g. QuoteIdInUse); document the caller-supplies-id collision
semantics and whether retry-with-same-id+same-content is idempotent. Expired
entries could be allowed to be replaced or reaped, but that is a deliberate
policy choice, not the current silent behavior.
{
"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-23T22:24:27Z",
"session_id": "ses_e5df5938a8fffeCbU3SvuS76Zc",
"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-06",
"stamped_by": "fleet 0.1.0 (native)"
}
}
Activity
developing-today commentedon Nov 23, 2026
CODE-5074