Repository navigation
fix(modal): fail closed without a price, report the settled charge, terminate refunds nothing (v3.49.29) - #249
Merged
Merged
Conversation
added 2 commits
November 14, 2026 02:37
…erminate refunds nothing Follow-ups from the GLM 5.3 review of #248. - ModalTerminate's text said Modal bills wall-clock GPU time until terminate. The whole lifetime is charged upfront at create and terminate refunds nothing; the text now says so, and drops the claim that session-end cleanup terminates forgotten sandboxes (terminateAllSessionSandboxes has no caller). Same fix in the tool-guard and tracker comments. - gpu "" (or blank / null) priced tier "" as undefined: the confirm dialog threw, and headless the hold threw inside a swallowed catch, so the call ran with no reservation and no quote ceiling. Blank gpu is now CPU; a non-string or unknown gpu is rejected. modalCreatePricing throws on an unknown tier, maxSignableAtomic on a non-finite or negative price, hold() on a non-finite amount (a NaN hold was granted and poisoned the reserved total), ModalCreate computes price and ceiling before the dialog and refuses if either fails, and postWithPayment requires maxPriceUsd and refuses to sign without a computable ceiling. - The "charged:" line and recordUsage reported the sol list price. They now use x-blockrun-cost-usd, else the 402 quote that was signed, else the list price labeled as an estimate (Base A100 600 s: $0.667667, not $1.17). - exec / status / terminate hold the ceiling the guard may sign (list + fee + 1 unit), as create does. - A create that is not flat-eligible but priced at the flat floor says "flat floor" instead of quoting the flat-eligibility rule it breaks. - A 402 (quote refusal, failed signing) or 5xx on ModalTerminate is an error and the sandbox stays tracked; other 4xx stay benign.
…the settled charge, terminate refunds nothing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-ups from the GLM 5.3 review of #248. Each finding was checked against the code before it was fixed; all six held up.
Fixes
terminateAllSessionSandboxesdocstring had it too, and all are fixed. The old text also said "Session-end auto-cleanup also calls this". That is false:terminateAllSessionSandboxeshas no caller, because thevscode-session.tshook it was written for no longer exists. The claim is removed. Wiring that cleanup up is not part of this PR.gpu: "". Tier""had no price, so the confirm dialog threw a TypeError. With no dialog,hold(maxSignableUsd(undefined))threw inside a swallowed catch, and the call went out with no reservation and no quote ceiling. Fixed by failing closed at every layer:0,false,"cpu","B200") is rejected before any request.modalCreatePricingthrows on an unknown tier.maxSignableAtomicthrows on a non-finite or negative price.hold()is now a refusal instead of a fall-through.postWithPaymenttakesmaxPriceUsdas required, and refuses to sign (quote_exceeds_expected) when no ceiling can be computed. The oldmaxPriceUsd !== undefinedskip is gone.walletReservation.hold(NaN)was granted, because every comparison with NaN is false. The NaN then poisoned the reserved total, so every later hold passed whatever the balance.hold()now throws on a non-finite amount.x-blockrun-cost-usdfirst, then the 402 quote that was signed, then the list price labeled as an estimate (~$1.17 estimated (list price; ...), recorded withestimated=true). Base A100 600 s now reports$0.667667. Exec, status and terminate record the same way.maxSignableUsd(price), which is the ceiling the guard may sign (list + $0.001 fee + 1 unit). This matches create.modalCreatePricingreturnsflatFloor: truewhen a request is not flat-eligible but its hourly price is below the flat rate. The line then reads "flat floor: the hourly price for this size and lifetime is below the flat rate, ..." instead of quoting the flat-eligibility rule the request breaks.isError: true, and the sandbox stays tracked. Other 4xx (already gone) are still benign and drop the sandbox from the tracker.Not changed: the review also noted that create over-holds by the $0.001 Base fee on Solana. That is the intended err-tight behavior from #248, and an existing test pins it.
Tests
test/reservation.local.mjsadds 10 tests, one or more per finding. I revert-checked each fix: I reverted it in the source, rebuilt, confirmed the named test went red, then restored the file and confirmed it was byte-identical. All 10 reverts went red: terminate text; blank gpu reaching tier""; skipping the guard without a price; a granted NaN hold; reporting the list price; the bare hold on exec, status and terminate, each reverted separately; the flat-floor wording; and a benign terminate refusal.npm test: 980/980 passnpx tsc --noEmit: clean