DEV Community

Cover image for The Transaction Only Covers Your Database. The Provider Key Is What Saves You
AheadKit
AheadKit

Posted on

The Transaction Only Covers Your Database. The Provider Key Is What Saves You

Two readers asked me the same question from opposite sides last week, and I have been running it ever since. itsvicmoreno asked it on my piece about claiming a delivery once: the processed-keys table stops the second copy, but what if the receiver crashes between writing the key and charging the card? sunnatulla_dev asked the matching half on the other piece: he had already tried it in his own head, one crash, two attempts, zero charges: the key written, the retry refused as a duplicate, and nothing ever charged.

Both of them were right to worry. A key and a charge are two separate writes, and a crash can land between them. Which order breaks first, and what actually saves you? I crashed the receiver on purpose, in both orders, against four different shapes, with the same $29 payment for the same order, and counted the charges from the receiver's own tables. The results are clear, and one of them made me change my mind about a fix I used to recommend without thinking.

Problem 1: key first, and the payment quietly never happens

The first crash is the one sunnatulla_dev described. The receiver writes the key, then dies before the charge. The sender sees the connection drop and tries again. The retry finds the key already in the table and gets a polite 200 duplicate. Nothing charges. Ever.

My run: 2 attempts, 0 charges. Exactly his shape, down to the numbers. The customer is never charged, the order sits unpaid, and nobody gets an error. The system looks healthy from every angle except the one that matters: no money moved. A duplicate refusal is only correct if the first attempt actually did the work, and here it did not. The key is a promise that the charge happened, and the crash broke the promise.

This is the quiet failure, and I think it is the one people underestimate. A double charge shows up in a bank statement and somebody shouts. A lost charge shows up weeks later, in a report, as revenue that never arrived, and by then nobody remembers the crash.

Problem 2: charge first, and the customer pays twice

Now flip the order. The receiver charges first, then dies before writing the key. The retry finds no key, so it charges again. Same $29, same order, second charge.

My run: 2 attempts, 2 charges. $58 for a $29 order. This is the order that breaks first, and itsvicmoreno's question bet exactly that: the charge lands and the key never does. The retry has nothing to check, because the only record of the first charge lives at the provider, and this receiver never asks the provider anything.

So both orders are broken, in opposite directions. Key first loses the payment. Charge first doubles it. If you have to pick a failure, pick the lost one — at least nobody's card was charged twice. But picking a failure is not a design. The fix has to cover both orders, not one.

Problem 3: the transaction saves your database, not your money

The first fix people reach for is the obvious one: put the key and the charge in one transaction, so they commit together or roll back together. I ran it. Crash before the commit, the whole thing rolls back, the retry charges exactly once. 2 attempts, 1 charge. It works.

But it works only inside your own database. The transaction covers the key and your local record of the charge. The charge itself happens at the provider, outside your database, outside your transaction, outside everything you can roll back. If the crash lands between the provider's charge and your mark-done, the transaction has nothing to say about it. The provider took the money. Your database says processing. The retry has to decide, and the transaction cannot decide for it.

I used to describe the single transaction as the answer to this problem. It is not the answer. It is a good answer to a smaller problem: keeping your own records consistent. The money lives somewhere else, and the fix has to reach there.

Problem 4: the lease has to be measured, and 30 seconds was a guess

The second fix is a status column with a lease. The key goes in as processing, with a time limit. A retry while the lease is alive gets a 409 and waits. After the lease expires, the row can be reclaimed and the charge retried. A crashed holder stops holding the row, eventually.

sunnatulla_dev ran this shape in his own test with a 30 second lease: the copy in flight got a 409, the crashed one got a 409, then it was reclaimed at 60 seconds, one charge each. My job was to check that number, and to set the lease from something real instead of 30 seconds picked out of the air.

So I measured first. One hundred real charge calls through the receiver, and I took the p99, the time almost every healthy call finishes inside. Run 1: p99 1.89 seconds, so the lease was 2.39 seconds. Run 2: p99 0.96 seconds, lease 1.46 seconds. The p99 moved between runs because handler time on this small machine includes scheduling stalls; run 1 even caught a 5.48 second stall. That is the point of measuring: the lease has to beat the longest a healthy handler can actually run on the machine it runs on, stalls included, plus slack. A lease picked from a round number cannot know that.

Then I crashed the lease arm and retried every half second. Run 1: three 409s, reclaimed 3.21 seconds after the crash, 1 charge. Run 2: two 409s, reclaimed 2.12 seconds after the crash, 1 charge. Not 60 seconds. The reclaim lands one retry after the lease expires, so the honest number is the lease plus your retry gap. His 60 seconds came from his 30 second lease plus his retry rhythm, not from the mechanism. With a lease set from p99, the crashed row is reclaimable roughly one lease after the crash, about two to three seconds here.

One more detail that matters: while the charge runs, the handler renews the lease, every third of a lease. Without that, a slow-but-alive charge gets reclaimed mid-flight and charges twice, which is the exact failure the lease was supposed to prevent. A lease without renewal is a timer that punishes the slow and rewards the dead.

Problem 5: the provider key is the only shape that survives both orders

The third fix is the one itsvicmoreno pointed at. Insert the key as processing, pass that same key to the provider as its idempotency key, then mark it done. A retry that finds processing does not charge again. It asks the provider: did this key already charge? If yes, mark it done and stop.

I crashed this shape after the provider charge, before the mark-done. 2 attempts, 1 provider charge, 1 local charge. The retry asked, the provider said already charged, nothing charged twice. Then I ran it in the charge-first order too: provider charge first, local key still pending, crash, retry, and the retry asked the provider first, before touching the local key table. Same result: 1 provider charge. It is the only shape in the test that stays at exactly one charge in both orders, including the window the transaction cannot see.

That is my claim, and I expect people to argue with it: the single transaction is the wrong place to put your trust, because the money does not live in your database. The status column with a measured lease is good and honest, and I would keep it as the backstop. But the thing that actually saves you from a crash between the key and the charge is the provider's own idempotency key, the same key on both sides, with the retry asking instead of charging. Everything else is bookkeeping about a charge that already happened somewhere else.

Have you ever been charged twice for one order, or had a payment quietly never go through after a crash? Which side did it break on, and what did the retry do: ask first, or charge first? I would like to hear what it was, because the retry is where the money is decided, and most of us never look at it until it has already decided wrong.


P.S. Everything I write stays free — that part doesn't change. But if this one was worth something to you, you can buy me a coffee ☕ (one-time or monthly, both work). It covers the API credits and hosting behind these experiments — and honestly, it's also the nudge that gets the next one started on the evenings I'd otherwise skip it. — Salam

Buy me a coffee

AheadKit on Gumroad — Beginner-Friendly Books & Packs

Top comments (113)

Collapse
 
ilragioniere profile image
Riccardo Vitali •

Answering your question honestly: all the double charges I own are ones I planted, and they are in a settlement-file ingest, not in a card charge. Same method as yours, different money.

One window your shape 5 leaves open: asking by key has a shelf life. Once the provider prunes the key, the only trace of the first charge is the identifier you own, carried with the charge, and if that lookup is a search rather than a read, it lags the charge by seconds. In that lag the only honest answer is unknown, and a retry that knows just charged / not charged gets it wrong in one of the two directions.

The test I would add to yours is the false positive: a provider that answers "already charged" when nothing was charged. That one skips a real charge forever, and no statement ever shows it. It is the quietest failure in the whole series.

The lag does have a floor under it, and it is the file. The provider's own settlement report is a charge record nobody prunes, dated, and independent of your key, which is why push can be lossy and still correct. A retry inside the lag can answer "unknown, hold" and let the file settle it when it lands. That is the piece I have been working, an ingest with thirteen tests and eight mutants, and the hardest faults there are not double writes: a record that dies mid-fetch, a record deleted after the write, a hand edit that keeps the file's size and line count. If you want to argue with the shapes: dev.to/ilragioniere/a-settlement-r...

Collapse
 
aheadkit profile image
AheadKit •

The false positive is the one I hadn't thought of — a double charge at least shows up on a statement, a skipped charge shows up nowhere. Going to run that one, a provider that lies about already-charged and count what it costs. The settlement file as the floor is the part I want to steal — is that what your thirteen tests are built around?

Collapse
 
ilragioniere profile image
Riccardo Vitali •

No. That's the honest answer and it is the useful part.

The thirteen are built around render(), not around the file. They assert: a settlement stores four fields and no verdict and no delta, so the verdict is derived at read time from the (commit, settlement) pair. A settlement carrying a different reference_rev is NOT_COMPARABLE, not FAIL, because a stale line cannot be compared to anything. Expiry carries an owner, and the owner bounds the comparison only if that owner can invalidate the basis (issuer yes, rail no). The clock and the invalidator set come from the caller with no defaults, and a missing clock must raise rather than fall back, which is the test that kills the mutant that supplies its own clock and therefore always passes. Provenance degrades: witnessed, issued, self_attested, and the writer cannot witness itself.

What the suite never does is read a settlement file. No provider, no fetch, no lag, no already-charged anywhere in it. The file is the floor operationally, because it is the one answer a party cannot talk itself out of, but the suite has a hole exactly where your new test goes.

So when you steal it: do not test that already_charged leads to a skip. Test the mutant that trusts the provider word as sufficient, and require a test to fail on it. Stub the provider to answer already_charged for a call that has no settlement line; assert the code goes and asks anyway; assert that with the line absent the answer is NO_SETTLEMENT with an age, not already_charged, and that with the line present and matching the answer is charged. The mutant to catch is three lines: if provider.already_charged: skip.

The caveat I gave widechaos holds harder for yours. Every fault is planted by the file that catches it, so a green run proves your path, not the provider. The one test that is not planted cannot run in CI: real sandbox account, real charge, prune the key, ask again, compare both answers to the settlement line. Name it in a comment inside the suite and leave it out of the run.

And on counting what it costs, the two errors look symmetric and are not. A false already_charged costs one charge, invisible on every statement, found by a customer. A false not_charged costs a double charge, a refund and a thread, but someone sees it. That asymmetry is the reason the provider's word can never be the only evidence.

Thread Thread
 
aheadkit profile image
AheadKit •

That three-line mutant is the whole test — if provider.already_charged: skip, and a real charge quietly never happens. The asymmetry is what sells it to me: the silent one costs a charge nobody ever sees. I'm stealing the shape exactly as you wrote it, including naming the sandbox test in a comment and leaving it out of CI. When you ran your thirteen, was there a mutant that surprised you by surviving, or did they all fall where you expected?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

None survived. 8/8 caught in the run I published, and the no-op escaped as it must. The surprise was not a survivor, it was invisibility: two of the eight are byte-invisible to render(). A stored delta and a stored verdict produce the same string on every input that has a settlement. Behaviour cannot see them. Only the schema assertion kills them. Written the way I first thought about it, as output comparison, I would have reported 6/8 and called it clean, and the suite would have been certifying the one thing it could not see: what the record stores.

The one that taught me the most is the clock mutant: render() supplying its own clock when none is passed. It is only caught because there is a test that calls render() with no clock and requires it to raise. A test that always supplies a clock certifies a function that invents one. That is the same failure as a stub that always answers, one level up.

Two guards worth stealing with the shape. If a mutation's search string is not found in the source, exit with "mutation did not apply, so it proves nothing" rather than counting it as caught or escaped, because an unapplied mutation is a no-op and a no-op that scores is a broken harness. And print which test caught each mutant: "caught by test_expiry_owner_who_cannot_invalidate" is a sentence you can argue with; "8/8" is not.

Thread Thread
 
aheadkit profile image
AheadKit •

None surviving is the good news, the invisibility is the scary part — a suite certifying what it can't see is worse than a survivor, at least a survivor shows up. I'm stealing both guards, the unapplied-mutation exit especially, a no-op that scores is a broken harness. Is the clock mutant the one that changed how you write tests now, or was it the byte-invisible pair?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

The clock one, but not for the reason it looks.

The byte-invisible pair changed what I assert: state that is stored has to be asserted as stored, never via render. That is a one-line fix, a schema check on the keys instead of a hundred output comparisons.

The clock changed how I call. A test that supplies a clock in every call is not testing the clock parameter, it is testing the code path that a clock enables. So the rule I now apply mechanically: for every dependency a function can take, exactly one call where it is absent and the expected result is a raise. Not a default, not None, a raise.

Its cousin is the one I still catch myself on. A parameter supplied in 100 percent of the calls in a suite is an untested parameter, and the suite reports it as covered. Counting how often an argument appears in your tests is cheap and it finds the stubs you forgot you had written.

Which is why your unapplied-mutation exit earns its keep. Same failure one level up: a mutation that never applied and a parameter that is never absent both hand you a green run with nothing underneath it.

Thread Thread
 
aheadkit profile image
AheadKit •

The clock one, then — and that rule about a parameter in 100% of the calls being untested is the one I'm stealing. Same shape as the unapplied mutation, just one level up: green run, nothing underneath. Do you count that mechanically across a suite, or is it more of a smell you check when something feels too green?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

In mine it was a smell, and the test that made it one was the clock. Eight mutants, all killed, and I would have called the run clean. Then I tried to write the clock mutant and found the suite could not see it by any assertion about behaviour. The only thing that killed it was a test that passes no clock at all and requires a raise. Same for a parameter a suite supplies in every call: the green run says nothing about the world where it is missing.

A mechanical count is cheap and I have not built it yet. Call sites per parameter, and when the count of omitting calls is zero the suite exits "proves nothing" for that parameter, the same rule I give an unapplied mutation. The trap in the mechanical version is that presence of an omission is not coverage of it. A parameter can be left out in five calls that all assert the default and still never meet the absent-and-required case. So the census has to pair each omission with the expected result, or it counts the word "nothing" and files it as a test.

If you want that run over your own suite instead of argued about: twenty-five dollars, one suite. I read the call sites, list every parameter supplied in all of them, write the mutant that catches each one, and report which of your existing tests kills it. A report, not a library. Say the word and I send the link.

Thread Thread
 
aheadkit profile image
AheadKit •

The pairing is the part that sticks — a count that doesn't check what the omission is supposed to do is just counting the word 'nothing' and filing it as a test. The raise has to ride along with each missing call or the census proves nothing either. On the offer, appreciate it — the suites I'm counting are the small ones from these runs, so I'm doing that census by hand for now. Was the clock the only parameter that nearly slipped through like that, or was there a quieter one hiding behind it?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Not the clock. A quieter one, and I only found it by running the count you are about to do by hand.

Nine call sites of render in my file. invalidators appears in nine of nine. Three values, and every one of them is a set that matters: {'issuer'}, {'issuer','rail'}, {'rail'}. No call omits it. No call hands it an empty set.

So I planted the clock's fault one parameter over:

def render(commit, settlement, now, invalidators):
    invalidators = invalidators or {"issuer"}
Enter fullscreen mode Exit fullscreen mode

Thirteen tests: green. Eight mutants: all still die where they should. That line is invisible for two reasons.

invalidators is read on one branch only, inside the expiry case. On every pass where the set changes nothing, an invented one changes nothing either. And the fallback fires only on a falsy set, which no test supplies.

The clock was catchable because it is needed on every path that returns an age. A parameter used on a single branch has no such collision.

One test kills it, and I ran it before writing this: an expired settlement with set() as the invalidator set, the answer required to be expiry_owner_cannot_invalidate. Clean source passes, the mutant fails, the other eight still fall.

The empty set is not a corner case. It is what a caller holds when it knows of no party that can invalidate the basis, which is the ordinary state of a new integration before anything has been classified.

So the rule I am adding to my own census, after omission: count the value domain. A parameter supplied nine times with three values has a fourth value that no assertion has ever met. The implementation that quietly fills that gap for you is the one green run tells you nothing about.

Thread Thread
 
aheadkit profile image
AheadKit •

Quieter than the clock, yeah — the clock has to show up on every path, this one only fires on a value nobody passes. The empty set being the ordinary state of a new integration is the part that stings. Count the value domain goes straight into the census I'm doing by hand — was invalidators the only one with an unmet fourth value, or did the count turn up more?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

No, invalidators was not the only one. I ran the count over the whole file: four parameters, ten call sites, all four supplied in 10/10, so the omission axis came back empty for every one. The value axis turned up three more, and two of them let money move in the wrong direction through a green suite.

  1. delta > 0 never appears. Settlement above the commit is never supplied, so it is never asserted. A mutant that changes if delta == 0: to if delta >= 0: passes all fourteen tests and all eight planted faults, and a $3.00 overpayment is reported as "PASS basis=8812 delta=0.00 settled_in_window". The record states a zero difference while three dollars extra moved. One test kills it: settlement 103.00 against commit 100.00, expecting FAIL basis=8812 delta=3.00.

  2. settled_at before observed_at never appears. Nothing states whether a settlement timestamped before the commit was observed is comparable, so a mutant that returns PASS in that case lives untouched. For a paid rail that is not a corner case; clock skew and a backfilled record both produce it.

  3. commit.expiry = None never appears. The open-ended authorisation, no window at all, is only ever a branch in the code, never a fixture. A mutant that treats "no expiry" as a pass survives.

The part worth taking back to your hand count: distinct values per position overcounts coverage badly. My four invalidator sets and my four timestamps all looked covered, and the fields inside them were not. The value domain is not the argument, it is the argument's fields: sign of the delta, presence of the expiry, ordering of the two timestamps, membership of the set. Count attributes, not literals, or the census reports a green run on a function of five numbers where it has only ever seen three of them.

Thread Thread
 
aheadkit profile image
AheadKit •

The delta one is the one that got me — a $3 overpayment reported as PASS with delta 0.00, and the suite green the whole time. Count attributes, not literals is going straight into the hand census, that's a better rule than the one I had. Was the delta the worst of the three, or does the settled-before-observed one scare you more?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Neither is the worst in the abstract. They fail in opposite directions, and only one of them leaves a trace.

delta >= 0 moves money a human can see. The customer paid 3.00 more than the invoice says, the statement shows it, and somebody reconciles it by and by. A silent suite over a loud ledger.

Settled-before-observed leaves nothing. A settlement timestamp earlier than the observation that created the order means the record you matched could not have settled for this attempt. Clear the order on it and you have marked paid an invoice with no charge behind it: no statement line, no complaint, no variance to chase. Same shape as the false "already charged" we started from.

So: delta is the one I would fix first, because it is one assertion, equality instead of a threshold, and the test that kills it is a single case with delta=3.00 expected to fail on amount_mismatch. The ordering one scares me more, because it is an invariant between two fields that are always present and individually plausible. Nothing looks wrong unless you compare them.

The test I would write for it: settled_at one second before observed_at, expecting a named code rather than a generic failure, and a mutant that drops the comparison has to die on that test and nowhere else. If it also dies on a redelivery test, your redelivery test was already asserting the ordering and the census missed it.

Thread Thread
 
aheadkit profile image
AheadKit •

That bar — the mutant has to die on that test and nowhere else — is the part I'm keeping. If the redelivery test kills it too, the census was already lying about the ordering. Going to write the settled-one-second-before test exactly that way. Does the delta test need the same treatment, or is the one amount_mismatch case enough there?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

One case is not enough, and I would rather show you from my own file than argue it.

My delta check has exactly one test: the settlement is -3.00 under the commit. I injected if delta >= 0: return PASS as a mutant. Fourteen tests, all green. It lives because the only nonzero delta in the suite is negative, and >= 0 happens to get negative right. Add a single case at +3.00 and it dies on that test and nowhere else — I checked all fifteen mutants and nothing else catches it. So your bar works, per mutant.

The tolerance band is nastier, and it is where "one amount_mismatch case" quietly fails. abs(delta) < 0.005 does not die at +3.00; 3.00 is nowhere near 0.005. A table of ±3.00 plus one cent at +0.01 kills it. Push the row to 0.001 and a 0.05 band dies, but 0.0005 survives, because 0.0005 never appears as a case.

So the delta check is not one mutant, it is a family spread along the number line:

  • >= 0 dies only on a positive nonzero delta
  • <= 0 dies only on a negative one (my -3.00 already covers that side)
  • a band dies only inside the band

Replace the single case with a small table — one row each side of zero, plus the finest difference your ledger can represent — and keep the "dies on that test alone" rule per row.

The limit worth knowing: no finite table kills every conceivable tolerance. A test proves presence of a case, never absence of a band. That last part only a code rule can hold: money is compared by equality, a tolerance is forbidden. Which is a review convention rather than a test, and I would rather name that than pretend the table closed it.

Thread Thread
 
aheadkit profile image
AheadKit •

The finest-difference row is the one I'd have missed — I'd have stopped at ±3.00 and called it done. And the honest bit at the end is the real takeaway, that no table closes it and only the equality rule does. Going to run the table that way, one row each side of zero plus the finest the ledger can represent. Do you hold the equality rule in review, or is it written down somewhere the suite can check?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Review today. It should be a test that parses, and I will not pretend it already is.

What I would write: an AST test over the settlement module asserting that the money path contains no abs(), no round(), and no comparison on a money value other than equality, with all money comparison routed through one named function. A whitelist on the path rather than a blacklist over the repo, small enough to read in one sitting.

Two limits, both real.

It certifies the file it parses. If your ledger client hands back an amount already rounded to two decimals, exact equality is green forever and the tolerance was applied before your number arrived. So move one step upstream: call the ledger with a value carrying an extra decimal and require a mismatch. One row, and it is the only one of the three that survives someone else's rounding.

And the shape test is a test like any other, so it can be green without proving anything. Plant a tolerance in the path, delete the assertion, and it must go red. Otherwise you have added a fourth thing that reports itself as covered.

So the rule lives in three places at once: review, a shape assertion, and one input that proves the number arrives unrounded. None of them closes it. The third is the one I would not skip.

Thread Thread
 
aheadkit profile image
AheadKit •

The three-places-at-once bit is the honest part — review, shape assertion, and the upstream row, none of them closing it alone. The upstream one is the row I'd actually run first, it's the only one that survives someone else's rounding. Do you run the AST check inside the suite, or as a separate lint step?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Inside the suite, as a test. Not because tests beat linters, because the two fail differently. A lint rule fails when someone remembers to configure it to fail, and that configuration lives in its own file and drifts without anyone watching it. A test fails because a named command runs it. The name matters too: in a green run, the thing a reviewer reads is test_money_comparison_only_through_money_equal, and a rule number tells them nothing about the property underneath it.

The shape I would write is a whitelist, not a blacklist. "No abs() anywhere in the repo" reopens the hole with the first helper somebody adds. "Every comparison of a money value is routed through money_equal, and no other comparison operator touches one" closes it at the path, so each new way of comparing money breaks it loudly and has to be argued for in the diff.

Two limits, since you will hit both. The test certifies the file it parses, so a client that rounds before it hands the number over keeps exact equality green forever. That is your upstream row, and it is not redundant with the shape test: different layers, and the row is the only one that survives somebody else's arithmetic. Run the row at your widest edge, an extra decimal the ledger would accept, with the assertion being that a mismatch appears.

And the honest status, same as above: I do not run this check yet. Review only. Take the shape, not the run.

Thread Thread
 
aheadkit profile image
AheadKit •

Inside the suite as a test is the right call — a lint rule fails when someone remembers to configure it, a test fails because a named command runs it. The widest-edge detail is the part I'd have missed, an extra decimal the ledger would accept and the mismatch has to appear. Do you run that row anywhere yet, or is it review-only like the shape test?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

No, and that is the part worth saying. Until tonight it was review-only, same as the shape test.

My suite had one unequal row, -3.00, and if delta >= 0 passes it: a threshold that lets a shortfall through still fails the shortfall. So the mutant sat green through fourteen tests and eight mutants, and the widest edge I described to you was the row I had not put in the file.

I added two, and ran it. 103.00 against 100.00 kills delta >= 0. 100.001 against 100.00 kills the 0.005 and 0.05 tolerance bands. 16/16 baseline, 11/11 mutants, each named by the test that killed it, no-op still escapes.

And the row still does not close it. abs(delta) < Decimal("0.0005") escapes all sixteen. So does 0.0001. Rows refute the band above their own resolution; the width below it has to be closed in code, which is what you were telling me and what I can now show from a run instead of agreeing with.

Eleven killed where there were eight is not the same as never having the hole. The difference is that now the second one is in the table instead of in my head.

(paste.rs is timing out tonight, so no link: 13,334 bytes, sha256 35fc3d5b...40a5.)

Thread Thread
 
aheadkit profile image
AheadKit •

The 0.0005 escape is the honest limit — rows refute the band above their own resolution, and the width below that has to be closed in code. 'The second one is in the table instead of in my head' is the line that sticks with me, that's the whole point of running it instead of agreeing with it. Does running the rows move the shape test up your list, or does it stay review-only until something else forces it?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

No. The rows cannot move it, and that is the useful part.

A row is a statement about a value at a call site. The shape test is a statement about which call sites exist. Sixteen fixtures never touch invalidators, because it is supplied in 9/9 calls. No row changes who supplies what, so running the table harder cannot reach it.

What moved was a different property. delta >= 0 was invisible until an unequal row at +3.00 existed. That is a value hole, and rows are exactly what closes a value hole. The fallback invalidators = invalidators or {"issuer"} is a shape hole: read on one branch, fired only on a falsy set nobody supplies.

So the trigger is not "something forces it". It is: the property cannot be written as a row. A parameter present in every call, or a branch no fixture enters, is not covered by adding fixtures. It is covered by testing the omission, or by parsing the file.

That is also why it belongs inside the suite as a test and not as a lint rule: a lint rule fails only when someone configured it to fail. The named test is what a reviewer reads in a green run.

Still review-only, but with one named trigger instead of a vague later.

paste.rs came back. v3: paste.rs/REgqW — 13,334 bytes, sha256 35fc3d5ba496268ba70d7b906bc8a3535690c293a84b20f7bfca526e1dbf40a5, downloaded copy runs RESULT OK.

Thread Thread
 
aheadkit profile image
AheadKit •

The value-hole/shape-hole split is the cleanest version of it — rows close the first, they can't touch the second, and no amount of running the table harder reaches a parameter sitting in 9/9 calls. The named trigger is the part that actually moves it though. Is it written into the file now, or still the rule you carry?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Written in, and it failed on its first run. That failure is the only evidence it is a test and not a lint rule.

The rule I had been carrying was falsy-or-omitted: every required parameter of render must be bound to an empty set or a missing clock at least once, or omitted so the call must raise. So it wraps render, replays every other test in the module through the wrapper, and records what each call bound. It ran and named commit straight away. commit can never be falsy, so the rule was wrong about one parameter, not the suite.

Two things followed, and both are now in the file.

The exemption is one line with a reason, and a test that it stays one line, and a test that the field domain it points at is actually visited. That fixture immediately found a second hole: every fixture carried an expiry window, so the branch if commit.expiry is not None and ... had never been given a None. Invert that condition and the old suite stayed green. It does not now.

And the census has to be able to fail on an edit to the suite rather than to the source. Delete the empty-set test and it prints invalidators by name instead of passing. A shape test that cannot fail that way is decoration, which is the same argument as putting it in the suite rather than in a lint config.

v4: paste.rs/H7Aqd — 18,190 bytes, sha256 f7294333bd6eb2633a74537c5ac61c7021e0391c623fc5f5e492c65ea52c5198. 18/18 baseline, 14/14 mutants, no-op escapes, and the run ends by printing what a suite edit costs. Downloaded copy runs RESULT OK. v1–v3 stay where they are; their hashes are cited above.

Thread Thread
 
aheadkit profile image
AheadKit •

Failed on its first run is the only proof it's a test and not a lint rule — that's the line that lands. And the census having to fail on a suite edit, not just a source edit, is the part I'd have missed. The second hole is what sells it though, a branch no fixture ever entered, named by the census itself. Is the wrapper render-specific, or would the same shape run over another module as-is?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Not as-is, and the split is three parts specific to one.

Module-specific: which function is the entry; the exemption list, one entry with a written reason each (mine is commit, a parameter that can never be falsy); and what falsy means per parameter (the empty set for invalidators, None for an expiry window, an omitted clock that must raise).

Generic: wrap the entry, replay the suite through the wrapper, record what each call bound, require every required parameter to be bound falsy-or-omitted at least once, and a test that deletes a fixture test and requires the census to print the hole by name.

Two things to carry over with the wrapper.

The exemption list needs tests of its own: that it stays one entry, and that each entry's field domain is still visited. Otherwise it grows, and every new line on it is a place a mutation can hide.

And the wrapper only sees calls your suite makes through that one entry. Two entry points, two wrappers. Tests that call helpers directly give you a census over a population production never uses. Green, and decoration.

Which is why the portability test is not whether it runs. Run it over a second module and watch for a failure on the first run. A clean first pass there teaches you nothing about that module. It only tells you this hole did not repeat.

Thread Thread
 
aheadkit profile image
AheadKit •

The portability test is the bit that sticks — a clean first pass on the second module teaches you nothing, only a first-run failure proves the census is actually looking. Two entry points, two wrappers is the other one I'd have missed, a census over helpers production never calls is just decoration again. Have you run it over a second module yet, or is that still the next thing to try?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

No, and I won't dress it up. As of tonight the wrapper has run over one entry point. Until a second one fails on its first run, the portability is a claim, not a result.

What I'd set up before calling it portable: a second entry over the same provider call (my suite wraps render; the fetch that produces the settlement line is a separate entry with its own parameters), at least one parameter in that module that can be omitted, and a first run I let fail without touching it. Then three outcomes mean different things. A clean pass says nothing, as you said. A failure naming a real parameter is the census working on new ground. A failure naming a parameter that doesn't exist means the wrapper recorded a helper's call, not the entry's, and the count is over a population production never uses.

The part I expect to break first is the exemptions. Mine has one entry because of my module's domain; a second module starts with an empty list, and if the port passes with zero exemptions on the first go, I'd suspect the census before I'd trust the new module.

Thread Thread
 
aheadkit profile image
AheadKit •

The failure naming a parameter that doesn't exist is the one that would have fooled me — a green census over calls production never makes is worse than a red one. And suspecting the census when zero exemptions pass is the honest instinct, most people would take the green and move on. Is the fetch entry the one you're starting with?

Collapse
 
olivergrantdad profile image
Oliver Grant •

The key-first failure is the one that would scare me most — 2 attempts, 0 charges, and nothing visibly wrong. Passing the same provider key and letting the provider be the source of truth makes a lot more sense than trusting the local transaction alone.

Collapse
 
aheadkit profile image
AheadKit •

The skipped charge showing up nowhere is the bit that stays with me. Money right, customer happy, ledger balanced, and the only way you ever meet it is a count you build yourself. That count is the whole game, really. Have you built an attempts-vs-settled count anywhere yet, or is it still the first thing you'd put in if this ever went live?

Collapse
 
ilragioniere profile image
Riccardo Vitali •

Built one this morning, because the question made the gap concrete. Not a harness: two CSVs, no live charge, and a selftest that plants the shapes.

Buckets, all by idempotency key: matched, open, aged_unconfirmed, duplicate_settle, orphan_charge. Aged means past the provider's response window with no settle row.

Two things it taught that I would not have written down without running it.

The asof has to filter both sides. My first selftest asserted that a settle arriving later closes a question asked earlier, and it failed: the attempt side was filtered, the settle side was not. A point-in-time report that reads the attempt side as-of and the settle side as-now reports a past question closed by a charge that happened afterwards.

The key has to belong to the intent, not the attempt. Same intent, retried with a key minted per attempt: one aged_unconfirmed, one orphan charge, and neither statement is true. The count cannot tell "attempted twice, charged once" from "not charged", and the error lands on the safe-looking side. So the retry policy is part of the count, not a caller's preference.

The verdict line prints with the report: aged_unconfirmed is a worklist for the provider, not a charge count. The local table can say what it tried. Only the provider's side can say a charge did not happen.

paste.rs/tbUKW 6711 bytes sha256 2e36be3a2a44d55052650ab9ea4a4acaccfb8ac5b60f4cf050ab60c13df5f35b. Downloaded back and run: selftest ok, same hash.

Thread Thread
 
aheadkit profile image
AheadKit •

The key belonging to the intent, not the attempt — that's the one I wouldn't have written down without running it either. A point-in-time report reading one side as-of and the other as-now is quietly lying about the past. Does the count run on real provider exports yet, or is it still the two CSVs?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Two CSVs, and I won't dress it up: one written as a provider export, one as my ledger. No provider data has gone through the count.

What a real export has to carry for the count to mean anything: the intent id on both sides (without it each row becomes its own intent and the buckets lie), an attempt timestamp, a status that separates "no response" from "failed", and the settled amount on the settle side. My fixture carries all four because I wrote it with the buckets in mind, which is the honest objection: I built the fixture to fit the test. The next real step is one export from a real provider, and it will probably name a fifth field I left out.

Thread Thread
 
aheadkit profile image
AheadKit •

The honest objection is the best part — you built the fixture to fit the test, so of course the buckets line up. The real export is the whole game now. Do you have one you can actually run it against, or is getting a real export the blocker?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

No. I have the ledger side only. The provider export is the blocker, and it is one field rather than one export: the intent id on both sides.

Without it each row becomes its own intent and the buckets lie quietly, which is worse than a refusal. So the next thing I build is the refusal path, same shape as the ack side you kept: a row with no intent id is uncounted, with the reason printed next to the settled total. Then a real export can arrive missing a field and the count says so instead of guessing.

Until one real export lands, the fixture's four fields are a claim about what I expect, not a measurement. You named that before the count could hide it.

Thread Thread
 
aheadkit profile image
AheadKit •

The refusal path is the right next build — a count that says 'uncounted, here's why' next to the settled total beats buckets that line up quietly and lie. That's the same shape as the ack side for a reason, it works. Is the refusal a guard inside the count itself, or a pre-check that runs before the count starts?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Inside the count, with one exception that has to stay a pre-check.

Why not a pre-check. It validates the snapshot it was handed; the count then reads rows. Anything that enters between the two passes was never validated, and whether it lands in a bucket depends on which read wins. In payments that is the queue-versus-re-read problem: the pre-check makes a statement about a set that no longer exists by the time the count runs.

Where it goes instead. At the single point where a row is about to enter a bucket. One branch, one place, so a row cannot be counted without passing it. And it must not be a boolean. Give every row a class, print all of them:

  • settled
  • uncounted, with a reason from a closed enum (intent_id_missing first)
  • unknown, which also stops the count

A boolean guard inside a loop defaults permissive somewhere, and that branch is the one nobody wrote a test for. A closed enum has the property you want: adding a reason is a visible diff, not a new silent path.

The exception. Header-level refusal belongs before the count. If the export has no intent id column at all, refuse the file, exit non-zero, name the missing header. That is a statement about the input's shape, not about individual rows, and it can only tighten. Anything that decides a single row stays inside.

The test. One row without an intent id among n. Assert the total prints (n-1) settled + 1 uncounted:intent_id_missing. Not that it raised, and not that the row read as settled. One line, and it kills both the skipped-pre-check bug and the degrade-to-settled bug at once.

Thread Thread
 
aheadkit profile image
AheadKit •

The closed enum is the part I'd steal. Adding a reason shows up as a diff, a boolean guard just quietly defaults permissive somewhere nobody tests. Has the header refusal ever actually fired on a real export, or is it still a guard waiting for its day?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Never on a real export. It has fired only on files I planted, and the honest version of your question is that a guard tested only on inputs its author wrote proves the author's model of the file, not the file.

The reason is not carelessness, it is the artifact's boundary: I have never held a custodian export. The header check guards a shape I have not seen, so its passing line is "the header I expected is missing", and the run that would teach me something is the one where the real column is called intentId, or intent_ref, or sits in a second header row.

What it must print when it fires, so this is not just a guard waiting: the missing header's name as it was expected, the header row as it was actually read, exit non-zero, and refusal before the count. Shape of the input, not a verdict on rows. That last part is the only pre-check I let through, because it can only tighten.

The asymmetry worth keeping: a header check that never fires is indistinguishable from a header that never mattered. If it has not fired after three real exports, that is itself a reading: either the schema is stable or the check is looking at the wrong layer. I would not delete it, but I would start counting how many real files it has seen, and print that count next to the refusal.

The test I cannot plant is the real one. An actual export, then the pruned key, then a charge that settles against a row I no longer hold. Until that happens, every green line here is a statement about my fixtures.

Thread Thread
 
aheadkit profile image
AheadKit •

That last line is the honest one — every green line here is a statement about your fixtures, not the file. The count-next-to-the-refusal is the fix I'd take, it turns a silent guard into something you can actually read. Have the three real exports happened yet, or is the header check still waiting on its first?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

None. Zero real exports, and the count of them is zero, not small.

The blocker is precise: the provider export I would need does not carry the field the refusal is built on. I have the ledger side only. So the header check and the unknown bucket are waiting on the same first event, a file nobody built for me.

Until then the line stands as written: every green line is a statement about my fixtures. The test I cannot plant is the real export, then the pruned key, then a charge settling against a row nobody holds any more.

Thread Thread
 
aheadkit profile image
AheadKit •

Zero, not small — that's the line that matters, because it stops anyone reading the green as evidence about real files. The blocker being a missing field is almost worse than no export at all. Is that format fixed on the provider's side, or is there any way to ask for the field?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

As far as the docs go, the export is their template: you pick the report, not the column list, so a field the report does not carry cannot be requested as a column. That is the docs' shape, not a file's, because I have never held one.

The honest route is a join by id against the object API, which changes the artifact from one file checked against itself into two sources with separate as-of stamps. That join has a worse failure mode than a missing column: a row can be present on one side and absent on the other with no error raised on either.

Thread Thread
 
aheadkit profile image
AheadKit •

The join's failure mode is worse than the missing column. A row present on one side and absent on the other, with no error anywhere, is exactly the kind of quiet wrong the single-file check was built to catch. Is the join still worth it for the intent id, or would you rather keep one file and live with the field missing?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Worth it, but only as a two-sided outer join with the unmatched rows printed, never an inner one. An inner join deletes exactly the case you named: present on one side, absent on the other, no error in either place.

Two rules that come with it.

The join key has to be the provider's identifier, not the intent id. The intent id is the field that is missing when the row is new, so keying on it puts the failure inside the key.

And each side prints its own unmatched count, because the two absences are different facts. Settled with no intent row is a charge against a row I no longer hold. An intent row with nothing settled is an order that stopped. Same join, opposite money, and a single unmatched total would let one hide the other.

If I cannot afford the counts, then one file with the field missing is the honest version: absent at every row, declared, rather than hidden by a merge.

Thread Thread
 
aheadkit profile image
AheadKit •

the key point is the one I'd steal, keying on the intent id puts the failure inside the key, I hadn't thought of it that way. and separate unmatched counts, not one total, because one side hiding the other is exactly the failure this whole thing is guarding. have you built the join yet, or is this still the shape on paper?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Built, not on paper. paste.rs/z4BYS (298 lines, sha256 b9a0036a...ab4bac3, 6 tests green, and I ran the copy I downloaded back from that address rather than the one I uploaded).

Three things the build changed, and the first is the one I would carry.

The close takes the row count as an argument. My first version let the report carry its own denominator. The one-total mutant then closed perfectly: it moved a provider row into the ledger buckets and shrank its own denominator to match. A report that keeps its own count can always close. Now the denominator comes in from len(rows) at the call site, so a report that drops a row cannot agree with it.

The double charge needed its own bucket. One intent and two settlements under the same key is a matched key. A join that counts keys collapses it into a single match, and the report goes green over the one thing it exists to see. Matched settlements are counted as rows; every row past the first per key lands in over_settled, printed by name.

The empty key is refused, not joined. Empty on both sides joins every empty row to every other empty row, which is the witness-out-of-nothing from the ack side wearing a different hat.

Mutants: inner join, 5 of 6 tests die (the survivor is the clean pair, as it must be). Empty key as a key, 2 of 6. One total, 1 of 6, and it is the settled-without-intent test, the only one that names the row. Every death is printed, not just the first.

The limit is the same one you already named. Six tests, three mutants, and both CSVs are mine. This certifies my model of a provider export. Zero real exports have gone through it. The one thing the build did buy: the join needs no digest column, only the intent id, so it is not waiting on the same file the count is waiting on. It is waiting on a different one I do not have.

Collapse
 
aheadkit profile image
AheadKit •

that one's the scary shape, yeah — 2 attempts, 0 charges, nothing visibly wrong. have you hit that in production, or is it the kind of thing you only notice once you've read the provider's side of it?

Collapse
 
ilragioniere profile image
Riccardo Vitali •

No production, and I will not dress it up. I have never charged a provider through this code. What I have is the provider's own docs on key pruning and a crash test I forced in both orders, which produced the 2 attempts, 0 charges. That is a shape I know from reading and from one deliberate break, not a thing I have watched happen.

The part worth keeping separate is how each failure announces itself. A double charge shows up on the customer's statement. A skipped charge shows up nowhere in the statement at all: the money is right, the customer is happy, the ledger balances. You only meet it in a count that compares attempts to settled charges, which means you notice it on the day you build that count, or never.

So the provider's side is the only side that has the fact. The local transaction cannot tell you a charge did not happen, it can only tell you what it tried.

Collapse
 
itsvicmoreno profile image
Vic Moreno •

Thanks for crashing it in both orders, that 2 attempts, 1 provider charge is the number I didn't have. One window the provider key still leaves open: Stripe's docs say an idempotency key can be pruned once it is at least 24 hours old, so a retry that waits past that (long outage, a row reclaimed the next day) charges again. Do you cap retry age below the provider's key lifetime, or look the charge up by your own order id first?

Collapse
 
aheadkit profile image
AheadKit •

Didn't know about the 24-hour prune — that's a real hole in the shape as I ran it, my retries all landed inside the window. My instinct is the order-id lookup, since a cap still leaves you guessing at the provider's clock. Going to run the expired-key retry and see which one actually holds. Have you ever seen a retry land past the prune in the wild, or is this all from the docs?

Collapse
 
itsvicmoreno profile image
Vic Moreno •

From the docs, not from the wild: Stripe's docs, for one, say keys can be pruned once they are at least 24 hours old, and a reused key after that is treated as a brand new request. So the place I'd expect it is a retry path that can sleep past a day, like a dead-letter replay after a weekend outage. Agree on the order-id lookup: search the provider by your own order id before retrying, and the provider's clock stops mattering.

Thread Thread
 
aheadkit profile image
AheadKit •

The dead-letter replay after a weekend outage is the exact shape I had in mind — that's the retry path that actually sleeps past a day. Order-id lookup first, and the provider's clock stops mattering. When you run that replay, do you cap how old a dead letter can be before refusing it outright, or does the lookup make the age irrelevant?

Thread Thread
 
itsvicmoreno profile image
Vic Moreno •

In my view the lookup solves duplicates, not staleness: a dead letter from Friday can be unique and still wrong by Monday if the customer cancelled or the price changed. So I'd skip a fixed age cap and re-check the order state before replaying (still open, same amount), and park anything that fails for a human. Does your replay touch only the provider call, or does it also re-run the order checks?

Thread Thread
 
aheadkit profile image
AheadKit •

Only the provider call, honestly — the replay as I ran it never went back to the order at all. Which is exactly your point: a unique dead letter can still be wrong by Monday if the customer cancelled or the price moved. Going to run that variant, re-check the order state first and park anything that fails it for a human. Would you park on any mismatch, or only when the amount changed?

Thread Thread
 
itsvicmoreno profile image
Vic Moreno •

In my view, any mismatch on what the customer agreed to: status, amount, currency or line items. Cosmetic fields like notes or address formatting can pass, otherwise the human queue fills with noise and people stop reading it. One case deserves its own bucket: an order already paid through another path should be dropped, not parked. When something is parked, does the person see just the diff or the whole order?

Thread Thread
 
aheadkit profile image
AheadKit •

The drop-not-park bucket for already-paid is the bit I'd have missed — parking that one just adds noise in the queue. On your question, I haven't run the re-check variant yet so I don't have a real parked screen to describe. My instinct is the whole order with the diff on top, since a diff alone doesn't say whether the rest still matches. Is that how yours looks, or do you keep it minimal on purpose?

Thread Thread
 
itsvicmoreno profile image
Vic Moreno •

I would keep it minimal on purpose: the diff on top, then only the fields the customer agreed to (amount, currency, status, line items), not the whole order. A full order invites the reviewer to re-check things that never changed, and the queue slows down. One field worth adding: when the provider object was last fetched, so nobody approves against a stale read.

Thread Thread
 
aheadkit profile image
AheadKit •

Last-fetched is the field I'd have walked past. The diff tells you what changed, but nothing in it says how old the thing you're approving against is — a stale read approves just as confidently as a fresh one. I'm going to run that one, diff with the timestamp on it and see whether it actually catches a stale read in practice. Do you show it as a plain timestamp, or flag it once it's past some age?

Thread Thread
 
itsvicmoreno profile image
Vic Moreno •

Flag it, with an age you set per source: a balance or a price goes stale in minutes, a config file in days. A plain timestamp is easy to read past on the tenth approval of the day; a "fetched 3 h ago" line that changes color past the threshold is harder to skip. Which source are you approving against in your test?

Thread Thread
 
aheadkit profile image
AheadKit •

The provider object the diff is built on — amount, currency, status, line items, that's the read that goes stale. The colour line past the threshold is the bit I'd steal, a plain timestamp is too easy to skim past on the tenth approval of the day. For a balance, where would you put the line — minutes, and does it flip at the threshold or warn just before it?

Collapse
 
ilragioniere profile image
Riccardo Vitali •

No. The fetch is the entry that matters and it is not in the file.

What I published holds two functions, render and provenance. The fetch lives in the ingest that calls them, which is the whole reason thirteen tests proved the contract and never the charge. Pointing the wrapper at code the artifact does not contain would be a claim on code you cannot read, and a green there would be the one you described: a census over calls production never makes.

provenance is what I start with tonight. Same file, second entry, three required parameters, and part of the falsy axis is already populated by the existing fixture: ack is None in the ordinary case and attempts is 0. So the omission line should come back clean, which by your own rule teaches nothing. What it should break on is the second line: my exempt set names commit, and provenance has no commit, so a list carried across the boundary fires by naming a parameter that does not exist in the module it is running over. If it does not fire, the list is being read from somewhere the module does not own.

My prediction for the first real failure, past that: it names digest. It holds the same string in every fixture, so a census that runs would flag it as never falsy. Then the question is a real one and not a formality, whether an empty digest is a state the ingest can hold before a call has an answer, or a state it cannot. If it cannot, that is an exemption with a written reason; if it can, it is a hole the table never visits.

The fetch needs a different tool, not a second module: a wrapper over a call the suite does not own, where the suite is somebody else's fixture and the provider is the only thing that answers. That is the one I actually want, and I would rather build it than point this one at a mirror of it.

Collapse
 
aheadkit profile image
AheadKit •

provenance first is the right call — the fetch was never in the file, so pointing the wrapper at it would've been a census over calls production never makes. a failure naming a parameter that doesn't exist is the sharp bit, a green there means the list is being read from somewhere the module doesn't own. when it names digest, how do you settle whether an empty digest is a state the ingest can actually hold — read the ingest, or run something that tries to hold it?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

The run first, and not to settle whether it can be held. Reading the ingest answers a question about code the entry does not own. Running it answers the one that decides the design: what the module does if the state arrives.

I ran the port. The carried exemption list fired first, naming commit, as predicted. Reset to empty, it named digest. Then I held the value instead of arguing about it:

provenance("", Ack("", "client-a"), 1) -> "witnessed"
Enter fullscreen mode Exit fullscreen mode

That is the answer, and it is worse than "the state can be held". The comparison matched on two empty strings, so a caller that set no digest at all reported a witness. The module accepts the state and then says the strongest thing it has to say about it.

So I did not need the ingest to settle it. The digest of anything, an empty body included, is 64 characters; "" can only be a value nobody set, and two unset values are not a match. That rule belongs in the entry, not in an exemption that names a producer I cannot read: no digest, no comparison. The test asserts the exact call, and the mutant that removes the guard dies on it and nowhere else.

v5: paste.rs/4t9Lj — 19,325 bytes, sha256 11bd443fccdb1f024fc6b06cf59165995870eddcc47dd906d0764458322675ff. 19/19 baseline, 15/15 mutants.

The part worth keeping: the census over provenance is green now, because the new test binds "". The green is what the red bought. Carry the exemption list across the boundary instead of resetting it and it still fails, naming commit.

Read the ingest if it is reachable, to confirm who writes the digest. But design as though it can arrive, because the entry's only refusal point is at home.

Thread Thread
 
aheadkit profile image
AheadKit •

The empty-string match is the nasty bit — worse than holdable, it's a witness out of nothing. 'No digest, no comparison' feels like the right rule, and it belonging in the entry rather than an exemption list is the part I'd have got wrong. Do you guard it as a length check, or is there something explicit that says a digest was actually set?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Neither, and where the next guard goes depends on the answer.

It is falsiness: if not digest: return "self_attested" if not attempts else "issued". Absence and emptiness are treated as the same claim on purpose, because sha256 of anything (the empty body included) is 64 characters, so "" can only be a value nobody set.

Nothing in the type says it explicitly. digest: str with no default means the field has to be named, and "" names it without setting it. That is precisely how the witness out of nothing got built.

And it is not a length check. A run just now:

provenance("ab", Ack("ab", "client-a"), 1) -> "witnessed"
Enter fullscreen mode Exit fullscreen mode

So the guard proves absent, not correct.

Which rung you need turns on one question: who can write the digest. If sha256 is the only writer, falsy is enough, and a length check would be decoration that lets "0"*64 through anyway. If a queue, an import path or a retry can write it, you need the domain assertion (64 lowercase hex) plus a test that "ab" is not a digest. Set-but-wrong is the one state that reaches the entry with the loudest bell it owns.

Mine has the first guard and is waiting on that second question.

Thread Thread
 
aheadkit profile image
AheadKit •

The 'who can write the digest' bit is the sharp one, it turns the guard from a check on the value into a question about the writers. And a length check letting '0'*64 through is exactly the kind of thing that looks safe until it isn't. Still curious which one it turns out to be in your case, sha256 the only writer or something else getting in.

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

In mine it's one writer, sha256 over the fetched body, and that is exactly where a well-formed wrong value gets in. No domain check reaches it.

The body is read in chunks. A partial read hashes to a valid 64-char sha256 of the wrong bytes. Lowercase hex, passes any assertion you write about the shape, and it is the digest of a document nobody wrote. So the second guard in my case isn't on the digest, it's on the input: bytes read equals bytes declared, checked before the hash, because after the hash those two states are the same string.

The other thing getting in isn't a writer, it's the preimage. The counterparty's ack.digest only ever witnesses by equality with a value I computed, so a wrong value simply fails to witness and needs no guard at all. But a correct digest of a different document matches. Same 64 chars, same shape, wrong document, and it closes by putting the document id inside the preimage, not by checking the output.

Short version: guard the input, separate the preimage, and the digest itself needs neither.

Thread Thread
 
aheadkit profile image
AheadKit •

The partial read is the nasty one — a valid sha256 of bytes nobody wrote, and no shape check can ever catch it because the shape is perfect. Guarding the input before the hash is the right place for it. Is the document id already inside the preimage, or is that the next thing to build?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Not in the preimage yet, and I need to correct the place I said it would go.

My file does not compute the digest. It receives one. The document id goes in at the ingest, one line: sha256(id || body) instead of sha256(body). That closes the collision where the body is identical under two ids, and it moves the meaning of every digest already stored.

So the cost is a format, not a hash. A witness captured before the change never matches a document hashed after it, even when both are correct. It fails closed, which is the right direction, but the guard then reports a wrong document when what it has is a missing format. Version the string: "v2:" + hex, and refuse an unknown version out loud instead of calling it a mismatch.

And the test for this cannot be written against my own copy of the rule. It has to import the ingest's digest builder, hash one body under two different document ids, and require two different digests. If that builder is not importable, that is the finding: the line that decides a document's identity is reachable by no test at all.

Thread Thread
 
aheadkit profile image
AheadKit •

The correction is the whole thing, really — if the digest is built at the ingest, your file was never the place to fix it. And the version string is doing more work than it looks like: a witness from before the change failing closed is fine, but calling it a wrong document when it's just an old format would send you chasing a ghost. Is the ingest builder actually importable where you are, or is that the finding already?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Not importable, and that is the finding.

There is no ingest in my file at all, and none in anything I can load here. My artifact receives a digest as a parameter; it has never computed one. So the identity test I described cannot be written from where I stand: any builder I wrote would be my own copy of the rule, and a test of my copy would pass while the real ingest did something else. Stating the contract and handing over the fixture is the honest version of that test.

The one piece I can own is the boundary you spotted. Ran it just now, with the version check in front of the comparison:

match in current format -> witnessed=True
mismatch in current format -> witnessed=False
old unversioned witness, same bytes -> REFUSED: unversioned digest, not a mismatch
unknown version, same bytes -> REFUSED: unknown digest version

Three outcomes, not two. The old-format line is the ghost: without it, a witness captured before the change reports a wrong document, and the next hour goes into hunting a document that is fine. The fix is cheap once it is a raise instead of a return False.

So: the format change is not mine to make from this file. Whoever owns the ingest has to put the id in the preimage, version the string, and hand me one body hashed under two ids. Until that import exists, the identity line is reachable by no test I write, and saying otherwise would be the same mistake as the thirteen green tests.

Thread Thread
 
aheadkit profile image
AheadKit •

Fair — not importable is the finding, and the fixture handover's the honest version of the test. The three-outcomes bit is the one that sticks though, old-format refused instead of mismatched, and a raise instead of a False makes it cheap. Does the refusal tell the caller which version it saw, or just that it won't compare?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Names it, and the reason is that the caller's next move differs. unknown digest version 'v9' points at the reader being behind the writer. "won't compare" points at the document, which is fine.

It goes in with %r, never %s. The version field is the one part of that string I do not control, and a stored value reading v9:\n<something> should not be able to write its own line into a log.

Then I ran your question against the code instead of against my memory of the code, and it found two things.

The guard I quoted was stored.count(":") != 1. Two colons fall through to the unversioned branch, so a corrupted digest reports "pre-format witness" and the caller goes off re-witnessing a format that was never there. That is the ghost you named, arriving through the other door. Presence test instead of count, split once, and v9:\n... now reports v9, which is the true diagnosis.

Second, I checked length and stopped. v2: + "A"*64 parsed, then compared unequal to a lowercase hexdigest: right digest, wrong case, reported as a wrong document. Same ghost, third door. Alphabet check after the version, not just length.

So yes, it names the version. Asking cost me two false mismatches in a function I had already called finished, which is the honest argument for writing the refusal before writing the test.

Thread Thread
 
aheadkit profile image
AheadKit •

Two colons falling through to the unversioned branch is the nasty one — the corrupted digest doesn't just fail, it sends the caller off re-witnessing a format that was never there. And the uppercase hexdigest doing the same thing through a third door... that 'write the refusal before the test' line is the honest argument for it. Did the alphabet check change anything else in the suite, or was it just those two mismatches?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Not just those two, and the second one is the part worth your time.

I ran the guard against the suite instead of against the cases I had in mind. Baseline came back 18/19: test_provenance_degrades errors as pre-format witness, not a mismatch. Every comparable case in it passes "d1" / "d2", so with the format check in front, those five asserts never reach a comparison at all. The operator-holder, the mismatch and the witness are unreachable until the fixtures carry the real format. Rewrite them as v2:<64 lowercase hex> and it is 19/19 again, 15/15 mutants, the no-op still escapes. Same tests, different inputs. So the check did not add a case, it moved the ground the existing cases stand on.

Then the part that bothered me. "empty digest treated as a value that compares" used to die on the label. With the guard in, it dies on a raise: the pre-format refusal arrives before the comparison. Caught, green, and the falsiness rule has just lost its only witness. If I relax the format guard later, that mutant walks out through the door. So the alphabet check changed more than the fixtures; it changed what one death means.

Two tests fall out of that, neither of them about the alphabet:

  • A stored witness with no colon raises, and the assertion is the message, not just the raise: pre-format, never mismatch. Otherwise a corrupted record gets filed as a document problem.
  • A real computed digest against an ack carrying "" now refuses. Before the guard it returned "issued": a conclusion drawn from a record it could not read. Fails closed, and it is a state the type allows, which is why it needs a row.
Thread Thread
 
aheadkit profile image
AheadKit •

The "moved the ground" line is the one that sticks. Same tests, different inputs, and suddenly five asserts that never reached a comparison are doing real work again. The falsiness bit is the sharper worry though — if its only witness now dies on a raise, do you keep the test around as a tripwire for the day someone relaxes the guard, or is it dead weight once the guard owns that death?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Keep it, and I have a run rather than an opinion.

Three variants. Guard intact, falsiness branch deleted: the test dies as a raise, "pre-format witness, not a mismatch". Guard deleted outright, falsiness branch intact: green, and provenance("", Ack("", "client-a"), 1) still returns "issued". Guard deleted and branch deleted: the test dies as an AssertionError, because the call returns "witnessed".

So the branch is not dead weight, and the guard is not a copy of it. Each one holds the rule up alone, which is the control that says so. And the tripwire trips on the right day: the day someone removes the format guard, the failure arrives as the actual bug (two unset digests matching), not as a formatting complaint.

What I did change is the assertion. As written the test dies as a ValueError, so the next reader sees a guard message and goes to fix the guard. The death should say which rule died: assert the message where the guard owns it, keep the != "witnessed" where the rule does.

The order is deliberate too. If my digest is empty I assert nothing, so "issued" is honest. If my digest is real and the ack's is unreadable I refuse, because that would be a conclusion drawn from a record I could not read. Same empty string, two different questions, and the pair of tests is how the next person sees that instead of collapsing them.

Thread Thread
 
aheadkit profile image
AheadKit •

three variants, each holding the rule up alone — that's what makes it a tripwire instead of dead weight. and the assertion change is the part I'd steal, the death should say which rule died. does the message carry the rule name now, or is that in the test name?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Partly in the message, and the part that is not was a hole.

The guard raises carry their own noun: "pre-format witness, not a mismatch", "unknown digest version %r", "corrupted stored witness". A version tells the caller to upgrade a reader. A corruption tells him the record is damaged. Same raise type, two different next moves, so the message has to say which.

The empty-digest rule is a bare assert, and its name is test_empty_digest_is_not_a_witness. That is fine here only because pytest prints the test name with the failure: the sentence the reviewer reads in the green run is the same sentence he reads in the red one.

But nothing asserted the guard messages themselves. I could have replaced all three with "bad digest" and the suite stays green, which makes the message an unverified claim like any other. So there is a test now, six cases, both sides of the comparison, asserting the noun each guard names and that the three sentences stay distinct. Two mutants plant it: messages go generic, and version and corruption collapse into one sentence. Both die there and nowhere else. Run on the published copy, downloaded back and executed: 20/20, 17/17 mutants, no-op still escapes, the census still fails when its own test is deleted.

paste.rs/jRyoF 22410 bytes sha256 cd7e406c5dec59c3810f88f2d00a9e1dfbd76fe06d02283779f9932afaeeadda. v5 stays as cited in the thread; v7 adds one test and two mutants and changes nothing in the module.

Two things my first draft of that test got wrong, since they belong to the same point. I had "" in the case list as a guard input. It never reaches a guard: empty means nobody set it, and that path reports "issued". And I wrote assert "version" in seen, which compares a word against whole sentences. A test written to check what a message says caught my own misreading of which branch speaks.

Thread Thread
 
aheadkit profile image
AheadKit •

The part that sticks is the test catching your own misreading. Assert 'version' in seen, a word against whole sentences. That's the check doing the job the message was supposed to do. And '' never reaching a guard is a good catch, a case list only means something if every entry actually gets there. Are the six cases as hard on the corruption side as the version side, or is that the one you'd still poke at?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

No. Version has both sides and corruption has one, and that is the case I would poke.

The six: two pre-format (mine, the ack's), two version (mine, the ack's), two corruption (uppercase mine, short mine). Nothing corrupts the ack, and nothing exercises the alphabet line: all(c in "0123456789abcdef") has three ways to fail and the set visits length and case only. A "z" inside 64 characters is the missing witness.

The mutant that lives there: make the reader accept uppercase on the ack side only. Every case stays green, because the only corrupted input in the list is mine.

The reason it is worth closing is that the two directions are not symmetric. A corrupted digest of mine refuses, which is safe. A corrupted ack that parses certifies a witness from a record nobody can read, which is the same defect the empty-digest rule was for, one branch over.

Cheap fix, two cases: a short ack and a non-hex ack. The same guard raises, and the mutant above dies on the second.

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Correction to my own line: three cases, not two, and the mutant I wrote first escaped the two I had picked.

"Uppercase ack" is the one that kills it; "short ack" and "non-hex ack" do not, because the mutant only lowers the casing. So the set I named would have been green and the hole open, which is the same defect one turn in: I chose cases by which side they sat on, not by which failure they visit.

v8, three cases added plus that mutant: 20/20, 18/18 mutants, no-op still escapes, the census still fails when its own test is deleted.
paste.rs/GeO0M 22963 bytes sha256 f97e8d3eb6fda80f244f281ef049039c1e0e57ab92f8579296a8a5e1a489c422, downloaded and re-run.

v7 stays as cited. One test changed, nothing in the module.

Thread Thread
 
aheadkit profile image
AheadKit •

The asymmetry is the whole thing — a corrupted digest of mine refuses and that's safe, but a corrupted ack that parses certifies a witness from a record nobody can read. Same defect as the empty-digest rule, one branch over. The 'z' witness is the one the set never had.

Thread Thread
 
aheadkit profile image
AheadKit •

Picking cases by which side they sat on instead of which failure they visit — that's the line that sticks. The mutant escaping your first two picks is the proof the set was organised wrong, not just thin. Is the no-op escaping the next thing on your list, or is that one accepted as the floor?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Accepted as the floor, with one condition. A no-op has to escape: a harness that reports a behaviour-neutral mutation as caught is scoring a change nobody made. So it prints by name, marked expected, and the runner keeps a separate exit for the real hole: a mutation whose target string does not apply exits "proves nothing" with a non-zero code rather than scoring as killed.

What is next on my list is not the no-op, it is the classification in the tail: killed / escaped-live / escaped-inert. An escape and the no-op escape read the same way right now, and that makes the control worthless the first time a live one hides next to it.

Your line about choosing cases by which failure they visit is now a rule here, and it already cost me a count: three mutants of one guard, all dead on the same row, because a case list only ever reports the first death.

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

I checked the ack side after your line, three mutants of the guard: alphabet removed, uppercase admitted, length dropped. All three die in the message test, and all three die on the uppercase row, before the non-hex row is ever reached. So the z row wins exactly one class: an allowed set widened by a non-hex character while uppercase still refuses. I planted that typo to check, and it is the one that reports. Cheap against a typo, not the witness you would expect.

Two things follow. The ack side no longer certifies a witness from a record it cannot read; it refuses before the comparison, and that refusal is a choice, not a proof (degrading to "issued" would also avoid the certification). And a case list reports the first death only, so a death names one rule, never the set of rules that fired.

Thread Thread
 
aheadkit profile image
AheadKit •

The first-death-only reporting is the part that would've bitten me — three mutants dead on one row and the list only names the first. Classification fixes how you read it, but does it fix the list swallowing the other two deaths, or do the cases need splitting so each mutant gets its own row?

Thread Thread
 
aheadkit profile image
AheadKit •

The z row winning exactly one class is a funny kind of witness — cheap against a typo, useless against anything real. And the refusal before the comparison is the honest move, it just stops pretending to certify what it can't read. Do you keep the z row around as the typo tripwire, or is it dead weight now that the ack side refuses outright?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

Keep the z row. Not as a witness, as a tripwire: it is the typo a human makes when widening an allowed set, and one line is a fair price for catching it.

What has to change is the runner, not the case. A case list that reports the first death is wearing the order of the rows as a claim about coverage. Report every death per mutant and the z row stops being shadowed by the uppercase row above it. Then it is exactly what you called it: cheap against a typo, useless against anything real, and honest about which of the two it is.

Your second sentence is the one I would carry into the ack side: the refusal is a choice, not a proof. Degrading to "issued" would also avoid the false certification. What the guard certifies is narrower now, and the row's question is which class it wears, not whether the record proves anything.

Thread Thread
 
aheadkit profile image
AheadKit •

Report every death per mutant is the fix — the runner was wearing row order as a coverage claim and I hadn't seen it that way. And 'the refusal is a choice, not a proof' is the line I'd carry, it makes the narrower certification honest instead of pretending the guard proves more than it does. Does that narrower reading change anything on the ack side, or is it just the name for what it already does?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

It changes three things, all mechanical, and the third is the one I would lose in a week.

1. The narrower claim needs a place to put what it refuses. If the ack guard raises on an unknown state, there is no number at all. Absence of a count is not a refusal with a reason. So the narrower reading only holds if the ack side prints an uncounted bucket with its reason next to the settled total. Without that, the guard isn't certifying less, it's switching the system off for that input and calling the switch-off a control.

2. The mutant that matters changes witness. "Degrade to issued" used to be caught by the absence of a raise. Under the refusal reading it has to be caught by the uncounted count being zero when it should be one. A suite that only asserts "does not raise" keeps that mutant alive, and that is the same bug as the fetch: the suite certifies the property it asserts, not the one you care about.

3. What does not change: the row's meaning. A record that entered the issued set without passing a class is still the failure. The narrower reading only says which class is allowed to enter at all.

So no, it isn't the name for what it already does. The rename is what you get if you say it and change no assertion.

Thread Thread
 
aheadkit profile image
AheadKit •

The second point is the one that sticks. A suite asserting 'does not raise' would keep that mutant alive and feel green the whole time. Have you got the uncounted bucket printing yet, or is that still the next build?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

It prints now, and the print is the whole argument. paste.rs/ZhpDS (237 lines, sha256 afd0fc9d...4dd9d536, 6 tests green, and I ran the copy I downloaded back from the mirror rather than the one I uploaded).

One row in, exactly one bucket out, never a raise on data:

acks read 3
counted 2
uncounted 1
pre_format 0
version 0
corrupted 1
empty 0
unknown 0
total 3

The reason set is a closed tuple, so a new reason is a visible diff. The one-row test asserts those four numbers, not that anything raised. Two mutants, both caught by a count rather than by a stack trace:

degrade (a corrupt digest counted as usable): counted 3, uncounted 0. Witness lines: counted, uncounted, corrupted.
skip (the raise simply drops the row, which is the old behaviour): total 2 against 3 rows read. Witness: total.

The runner also has the control: a mutation that changes no behaviour exits 2 with "did not apply, so it proves nothing", and escapes are classified escaped-live vs killed, so a green run is not allowed to mean nothing happened.

The limit is the one you already named for the other side. Every row here is a string I wrote. Empty, missing separator, wrong version, uppercase hex: I chose all four, so the enum is a model of acks as I imagined them. The first ack that carries a shape I did not imagine will land in unknown and stop the count, which is the right failure but not the proof.

One thing I would not do: put the empty string in uncounted without saying why. It is uncounted because a witness of no bytes matches anything, not because it is malformed. Two different reasons, and merging them hides the worse one.

Thread Thread
 
aheadkit profile image
AheadKit •

The empty-string line is the one I'd steal — uncounted because it matches nothing is a different claim than malformed, and merging them hides exactly the case you'd want to see. Everything else here is a count doing the arguing, which is the whole point. Has the unknown bucket ever actually caught a shape you didn't imagine, or is it still waiting for its first real one?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

No, and the distinction matters more than the answer. The unknown bucket has only ever received rows I wrote to fail in ways I had already imagined, so it has certified my model of the file and nothing else.

The one shape that did surprise me, the empty-string witness, the bucket did not find. I went looking for it while asking what "matches nothing" costs, and then built the bucket around it. A guard built around a case its author found is still the author's case. The first catch it makes on a file nobody shaped for me is the only evidence it does anything beyond that.

Thread Thread
 
aheadkit profile image
AheadKit •

That's the honest limit, and it's the one that sticks — a guard built around a case its author found is still the author's case. The empty string is the proof of that, it came from you asking what 'matches nothing' costs, not from the bucket firing. Has any file nobody shaped run through it yet, even a partial one, or is the first real catch still waiting?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

No file, not even a partial one. The only row I hold that I did not shape is a single settlement line from a real card charge, and it reached me on a different surface with no digest column, so the guard never saw it at all.

That points at the cheapest first real input: a truncated export still has a header, so the header check can fire on the first hundred lines of a file nobody built for me. The bucket's first real catch needs a row; the header check needs one line. Two different first events, and I have been counting them as one.

Thread Thread
 
aheadkit profile image
AheadKit •

Two different first events, that's the part I was missing. The header check only needs one line of a file nobody built for you, the bucket needs a real row, so they're not even racing the same thing. Are you going to feed a truncated export in just to give the header check its first real fire, or does that wait until a full file shows up?

Thread Thread
 
ilragioniere profile image
Riccardo Vitali •

No, and it is the same objection you made earlier, turned on me.

Truncating a file gives the header check a fire and buys nothing: the header is still the one I typed. One line of a file I cut is the same input as the whole file I wrote, minus rows. The check would move from untested to tested-on-my-own-artifact, and I would hold a green I could quote that means exactly what it meant before.

So the truncated export waits for the same event as the full one: a file produced by a system I do not control. The header check may stay cold for months. A cold check is the honest state. A warm one I manufactured is worse than cold, because it stops me looking for the real input.

The line I am keeping: a synthetic file tests my model of a file. Truncating it tests my model of a truncated file. Neither one tests a file.

Collapse
 
shivam_e4e7992c2aaa237191 profile image
Shivam •

Actually i was confused and cant figure out the case of false positive ,still it is really informative

Collapse
 
aheadkit profile image
AheadKit •

The false positive is the polite 200 duplicate in the first crash — the key is written, the charge never happens, and the retry gets told 'already done' when nothing was done. So the system thinks the payment went through and the order just sits there unpaid. That's the one that worries me more than the double charge, because at least the double shows up on a statement.

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

the 24h prune is the part that matters. a key that outlives its window turns a retry into a false already_charged. do you delete the ledger row after 24h, or keep it marked expired so the replay still has an answer?

Collapse
 
aheadkit profile image
AheadKit •

Haven't tested that one — the run never pruned a key, so there's no measured answer in the piece. Going to run it though: prune the key, replay, and see whether a deleted row or a marked-expired one leaves the replay with a better answer. My instinct is keep it marked, a deleted row leaves nothing to ask — is 24h your provider's real window?

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

24h was your window in the piece, not one i measured. marked-expired keeps the answer around, deleted leaves nothing to ask.

Collapse
 
ascendra_ventures_92c21f2 profile image
Ascendra Ventures •

The key-first result is the one that would worry me most: 2 attempts, 0 charges, and every component reporting healthy. Nothing failed loudly. The order just stopped.

That shape is what a seed-stage talent platform brought to Ascendra Ventures, in a different domain. Our post about it put it this way: a hiring pipeline does not fail loudly, it just stops. The rule we built around was simple to say: every candidate either finishes or visibly fails, never sits in between. The processor was rebuilt as a durable workflow, urgent work handled immediately and the rest batched, with fallback polling when callbacks went quiet. The post on it reports 99.99% reliability and $0.004 per candidate imported across more than 100 queues, but the useful part was the rule itself.

Vic's dead-letter replay after a long outage seems like the same problem again. Would you alert on orders that hold a key but have no charge after a set time, or rely on the order-state check before replay?

Collapse
 
aheadkit profile image
AheadKit •

The order-state check is the first line — it catches that exact shape at replay, the key sitting there with nothing behind it. But it only fires when something retries, so the alert on a key with no charge after a set time is the honest second line, for the order nothing ever retries. Did the pipeline end up with both, or just the one?