On the seller side, the hard part is the gap between the offer and the payment. An agent can quote "3 GB in Japan", think, and pay a minute later after the wholesale price moved. We honour the quoted price until it expires, then answer with a fresh quote instead of a failure. How does the kit handle an offer that goes stale before payment?
Thanks, this was a real gap, and your question is why it's fixed. Until 17 November the kit kept no quoted price: the price was fixed at order time, and after the wholesaler refused an order over a price change, the node kept its old catalogue for up to 15 minutes, so a new quote could be refused again.
It now works the way you describe:
Every offer in a quote carries quote_token and price_valid_until (10 minutes by default, QUOTE_TTL_SECONDS). The token is an HMAC over the offer, the price and the expiry, so the node stores no quotes and a changed token is a 400.
An order that sends the token gets a 402 for at most the quoted price while it is valid, even if the wholesale price rose since. If the price fell, it pays the lower one.
When the price rose and the quote expired, the order is refused before any payment with 409 quote_expired and current_offer: the offer as it is now, with a fresh token. The agent can order that directly, without a new quote.
If the wholesaler still refuses (its price moved after the node's last catalogue read), nothing is charged, since the node settles only after the eSIM exists. It reads the catalogue again at once, and the 409 carries current_offer, which keeps the agent's quoted price when the new cost still allows it.
One difference from your rule: the kit never honours a quote below the seller's current wholesale cost (409 quote_below_cost, again with current_offer). Other operators run it with their own margins, and a stale quote shouldn't make them sell at a loss.
It's live on our reference node, which is in demo mode: it quotes and checks tokens but sells nothing.
curl -s -X POST https://modelmarket.dev/providers/esim/quote -H 'content-type: application/json' -d '{"country":"JP","limit":1}'
The code is rails/src/quote.js in github.com/alexar76/esim-operator-kit. rails/test/agent-buy.test.js runs the example buyer against a node whose wholesale price moves between the quote and the order.
Thanks for the full walk-through. Returning current_offer with the 409, so the agent can order without a new quote, is a cleaner step than ours: our expired quote answers with a fresh quote and a list of what changed, and the agent still has to read it and decide.
The below-cost rule makes sense for a reseller. When your test buyer gets current_offer at a higher price, does it take it straight away, or does it go back and compare other sellers first?
It took it straight away, within its spending cap, and your question showed that was the weak half. Both of our buyers now compare again.
The example buyer (rails/examples/agent-buy.mjs, esim-rails 0.5.1) treats a refusal that charged nothing as news, not as the end of the purchase. current_offer replaces that seller's quote, a seller that can only say no drops out, and the buyer orders the cheapest offer it now knows within --max-usd: the same seller at its new price, or another seller's quoted offer, which that seller still honours while its quote is valid. That needs no new round of quotes, because a kit seller's quote_token holds its price until price_valid_until.
Two details came out of the tests. The buyer signs no more than the offer it chose, so a seller without quote tokens can't ask more at the order than it quoted. And each seller gets its own X-Esim-Recovery value, so a seller the buyer tried never learns the value that recovers another seller's order.
ARGUS, our own agent, stops instead of switching. Its owner approves each purchase, and that approval covers one seller at one price. When the refused seller's price has gone up and is now above another seller's offer with at least the same data and days, ARGUS buys nothing and names the cheaper offer (cheaper_elsewhere), and the owner picks.
rails/test/agent-buy.test.js in github.com/alexar76/esim-operator-kit runs the example against two kit nodes behind a stub hub, with the wholesale price moving between the quote and the order. On the live network there's nothing to compare yet: our hub lists one eSIM seller, the demo reference node.
The ARGUS rule is the part I'd copy. An approval that names one seller at one price means a refusal can never turn into a purchase the owner didn't see. And cheaper_elsewhere hands the owner the reason to say yes again.
How long does a kit seller's quote_token hold its price by default, and did that window come from how fast wholesale prices moved in your tests?
Ten minutes: QUOTE_TTL_SECONDS=600. An operator can set anything from 0 to 86,400 seconds; 0 issues no tokens, and every order then pays the price of the moment.
It didn't come from price data. We picked ten minutes on 17 November, when we added the tokens after your first question, and nothing we've measured backs it. The tests move the wholesale price inside a stub, and our reference node runs in demo mode: it reads eSIM Access's live catalogue but sells nothing and keeps only its latest copy, so we have no record of how often or how far wholesale prices move.
What limits the risk is the rest of the design, not the number:
The node reads the wholesale catalogue again only when its copy is 15 minutes old, or at once after the wholesaler refuses an order. Its own view of a price can already be older than the quote window.
The kit never honours a quote below the current wholesale cost (quote_below_cost), so a rise inside the window can eat the seller's margin but never makes it sell below cost.
If the wholesaler refuses the order at its new price, nothing is charged: the node settles only after the eSIM exists.
How long does your quoted price hold, and did you set it from your own price history?
A correction to "we have no record". After we posted that, we found one: the node's latest catalogue copy goes into the host's nightly backup. Eighteen copies cover 19 October to 18 November, every few days until 5 November and daily after:
402 wholesale price changes on 377 of about 1,800 plans.
They come in batches, not as a drift. No price changed between the copies of 19 October and 5 November; since then, 7 of 13 days brought an update of 16 to 111 plans.
356 were cuts (median −14%). The 46 rises (median +25%, up to +88%) all came in one update between 15 and 16 November, in 16 countries and territories, Japan among them, and in two regional plans, North and South America.
So the risk to a quote isn't a slow drift that a shorter window would catch. It's an update landing inside the window, and then dozens of plans move at once. Daily copies can't say at what hour updates land, so since today a recorder reads the catalogue every 15 minutes and logs each change. In a few weeks we'll know whether ten minutes is about right, and whether updates cluster at a time of day a seller could plan around.
Do your suppliers' prices move in batches like this too?
Edited 18 November: the rises were in 16 countries and territories and two regional plans, not "17 countries"; the early copies were a few days apart, not weekly.
We're a place where coders share, stay up-to-date and grow their careers.
On the seller side, the hard part is the gap between the offer and the payment. An agent can quote "3 GB in Japan", think, and pay a minute later after the wholesale price moved. We honour the quoted price until it expires, then answer with a fresh quote instead of a failure. How does the kit handle an offer that goes stale before payment?
Thanks, this was a real gap, and your question is why it's fixed. Until 17 November the kit kept no quoted price: the price was fixed at order time, and after the wholesaler refused an order over a price change, the node kept its old catalogue for up to 15 minutes, so a new quote could be refused again.
It now works the way you describe:
quote_tokenandprice_valid_until(10 minutes by default,QUOTE_TTL_SECONDS). The token is an HMAC over the offer, the price and the expiry, so the node stores no quotes and a changed token is a 400.409 quote_expiredandcurrent_offer: the offer as it is now, with a fresh token. The agent can order that directly, without a new quote.current_offer, which keeps the agent's quoted price when the new cost still allows it.One difference from your rule: the kit never honours a quote below the seller's current wholesale cost (
409 quote_below_cost, again withcurrent_offer). Other operators run it with their own margins, and a stale quote shouldn't make them sell at a loss.It's live on our reference node, which is in demo mode: it quotes and checks tokens but sells nothing.
The code is
rails/src/quote.jsin github.com/alexar76/esim-operator-kit.rails/test/agent-buy.test.jsruns the example buyer against a node whose wholesale price moves between the quote and the order.Thanks for the full walk-through. Returning current_offer with the 409, so the agent can order without a new quote, is a cleaner step than ours: our expired quote answers with a fresh quote and a list of what changed, and the agent still has to read it and decide.
The below-cost rule makes sense for a reseller. When your test buyer gets current_offer at a higher price, does it take it straight away, or does it go back and compare other sellers first?
It took it straight away, within its spending cap, and your question showed that was the weak half. Both of our buyers now compare again.
The example buyer (
rails/examples/agent-buy.mjs, esim-rails 0.5.1) treats a refusal that charged nothing as news, not as the end of the purchase.current_offerreplaces that seller's quote, a seller that can only say no drops out, and the buyer orders the cheapest offer it now knows within--max-usd: the same seller at its new price, or another seller's quoted offer, which that seller still honours while its quote is valid. That needs no new round of quotes, because a kit seller'squote_tokenholds its price untilprice_valid_until.Two details came out of the tests. The buyer signs no more than the offer it chose, so a seller without quote tokens can't ask more at the order than it quoted. And each seller gets its own
X-Esim-Recoveryvalue, so a seller the buyer tried never learns the value that recovers another seller's order.ARGUS, our own agent, stops instead of switching. Its owner approves each purchase, and that approval covers one seller at one price. When the refused seller's price has gone up and is now above another seller's offer with at least the same data and days, ARGUS buys nothing and names the cheaper offer (
cheaper_elsewhere), and the owner picks.rails/test/agent-buy.test.jsin github.com/alexar76/esim-operator-kit runs the example against two kit nodes behind a stub hub, with the wholesale price moving between the quote and the order. On the live network there's nothing to compare yet: our hub lists one eSIM seller, the demo reference node.The ARGUS rule is the part I'd copy. An approval that names one seller at one price means a refusal can never turn into a purchase the owner didn't see. And cheaper_elsewhere hands the owner the reason to say yes again.
How long does a kit seller's quote_token hold its price by default, and did that window come from how fast wholesale prices moved in your tests?
Ten minutes:
QUOTE_TTL_SECONDS=600. An operator can set anything from 0 to 86,400 seconds;0issues no tokens, and every order then pays the price of the moment.It didn't come from price data. We picked ten minutes on 17 November, when we added the tokens after your first question, and nothing we've measured backs it. The tests move the wholesale price inside a stub, and our reference node runs in demo mode: it reads eSIM Access's live catalogue but sells nothing and keeps only its latest copy, so we have no record of how often or how far wholesale prices move.
What limits the risk is the rest of the design, not the number:
quote_below_cost), so a rise inside the window can eat the seller's margin but never makes it sell below cost.How long does your quoted price hold, and did you set it from your own price history?
A correction to "we have no record". After we posted that, we found one: the node's latest catalogue copy goes into the host's nightly backup. Eighteen copies cover 19 October to 18 November, every few days until 5 November and daily after:
So the risk to a quote isn't a slow drift that a shorter window would catch. It's an update landing inside the window, and then dozens of plans move at once. Daily copies can't say at what hour updates land, so since today a recorder reads the catalogue every 15 minutes and logs each change. In a few weeks we'll know whether ten minutes is about right, and whether updates cluster at a time of day a seller could plan around.
Do your suppliers' prices move in batches like this too?
Edited 18 November: the rises were in 16 countries and territories and two regional plans, not "17 countries"; the early copies were a few days apart, not weekly.