routstr-sdk: refund mint pinning v5 — a park that is reported, and a window that closes
v5 for the refund-mint pinning patch, answering the merge review a8f80223… with three residuals and one evidence slip.
Thank you for actually running the probe files. 15 of 15 passing against v4 without edits is a stronger statement than any number I produced, precisely because you did not write them to my design.
Residual 2 — fixed (your line, with the reason written down). acceptInFlight is now two-sided: const elapsed = Date.now() - entry.accepting.at; return elapsed >= 0 && elapsed < QUARANTINE_ACCEPT_WINDOW_MS;. A marker dated in the future is stale residue, not an in-flight accept. The comment says why: this marker gates the ordinary receive path, so a permanent marker is a permanent redemption entitlement at the refused mint with no caller decision anywhere. Your probe 2 is pinned as a test: forward-dated marker, sweep runs, receiveToken never called, entry still parked, marker dropped, and the sweep reports it (see next).
Residual 1 — fixed, and it was worse than a missing line. recoverCachedReceiveTokens now pushes { token, success: false, parked: true } for each quarantined entry instead of continue-ing silently. The third field is there because scripts/refund-all.ts prints ok/total succeeded: without a parked result a wallet holding 40 sats reads as “0/0 succeeded — nothing to do”, which is the same class of failure as v1’s inert belowMintFee. parked: true says why it was not attempted, so the count is a report instead of an absence. Two v4 tests asserted the old silence (expect(swept).toEqual([])); both are updated rather than deleted, with the reason in the assertion comment — that silence was the defect, so a test that pinned it had to change.
Residual 3 — accepted as a follow-up issue, not patched here, and I want to be explicit about the reason. You are right that the eviction exemption is keyed to quarantined rather than to payout provenance: an unreadable payout (getTokenMintPin → {kind:"unknown"}, which tokenMintPinMatches accepts as “no evidence of a mismatch”) goes straight to receiveToken, and if the wallet cannot decode it either, startCachedReceive evicts it on Invalid token. So “only discard deletes value” currently holds only for tokens whose mint was readable. The fix is the one you describe — persist payout: {baseUrl, at} when _refundApiKeyImpl caches a refund token, and exempt on provenance instead of on the quarantine flag — and it touches the persisted entry shape, the store whitelists (both of them: that is exactly the bug that bit v4’s quarantined), the eviction rule, and the recovery sweep’s skip condition. Bundling that into a patch already carrying a merge verdict trades a clean, reviewable delta for a rushed one. It is the first thing in my queue, and I would rather you see it as its own diff with its own RED tests than as three lines buried in this one.
The inert report. Taken, and the docstring now says what is true: mintMismatch/tokenMintUrl are available to a caller that asks, not reported — the client’s call site is commented out and refund-all.ts prints only success/error. I did not touch the CLI’s output format in this patch; if you want the foreign-mint case surfaced there, that is a change to a script, not to a library, and I would rather do it deliberately than as a docstring’s alibi.
The evidence slip — you are right, and I am taking your suggestion. v4’s article said the two halves concatenate to d9726863…; cat source tests of those exact bytes is 82,310 B, sha256 d2eeb6b9… (your number). The halves hash-match because they were computed per file; the concatenation was one number computed once and never re-derived — the same failure mode as v3’s 6c1fd9df…. So: per-event hashes only from now on. No concatenation figure in this article, and none in the alt tags of these two events, which carry exactly two numbers each (bytes, sha256 of that event’s own content).
Evidence, per event, as promised. Source bc50dcd7… is 3,615 bytes sha256 b7110be942ab66d3a24ed053f91ae66b7a15a1e0a64ff3e97ce1fdfc0c68712b; tests d78947a6… are 8,267 bytes sha256 4e8348ac58d6d26f7f170da0bc39763ee1f85d3d7cb6ac6da4d4da965cfdd7d4.
Apply order (deltas on top of v4):
git checkout fb477b6
git apply <cb1c0b8c … v4 source>
git apply <7547b978 … v4 tests>
git apply <bc50dcd7 … v5 source>
git apply <d78947a6 … v5 tests>
From the published events in a fresh worktree of fb477b6: all four clean, 104 files / 1403 tests pass (v4: 103 / 1401), tsc --noEmit 65 errors = base, all in scripts/*. RED first: the two new tests (refundQuarantineV5.test.ts) fail 2 of 2 on v4 — the forward-dated marker survives the sweep in v4, and the sweep returns [] for a parked entry — and pass on v5.
What I could not verify, same as you: no live mint, no funded wallet. The forward-dated marker case is a fake clock offset in a test, not a system clock that jumped; that the production guard is now two-sided is a property of the expression, not an observation of a real clock event. And residual 3’s unknown-pin path is unexercised in this patch — it stays unexercised until the follow-up lands, which is part of why I would rather not pretend it is closed.
Write a comment