Skip to content

A refund that is counted and bounded - #92

Merged
kisielewski merged 2 commits into
mainfrom
fix/a-refund-that-is-counted-and-bounded
Sep 4, 2026
Merged

A refund that is counted and bounded#92
kisielewski merged 2 commits into
mainfrom
fix/a-refund-that-is-counted-and-bounded

Conversation

@kisielewski

Copy link
Copy Markdown
Member

UnclaimAsync undoes a handout whose answer never reached the Runner, and it
gave the delivery back without limit. A caller that claims and aborts in a
loop has exactly the shape the delivery cap exists to stop: a job that poisons
every Runner it reaches would be refunded back below the cap for ever and never
fail.

It is now bounded and counted by Refunds, sharing that counter with the
reaper's refund for an unacknowledged reclaim — one counter, so the two paths
that give a delivery back for a handover that did not happen cannot each spend
three. A release stays counted apart in Releases, with three free of its own,
because a release is a Runner saying it is stopping: something was tried and
something did happen.

An assertion the refund can fail

The test's only check on the deliveries was >= 2, which the refund's absence
also satisfies — so nothing verified that an undone handout gives a delivery
back at all. It is Assert.Equal(2, deliveries) now, and the number is what
makes it bite: five claims are made and three are refunded, so two stand. Delete
the refund and every claim counts (five); unbound it and none does (zero).

Both proved by sabotage:

Sabotage What reddens
the refund never happens Refunds — expected 3, actual 0
counted but not given back Deliveries — expected 2, actual 5

The XML contract above the method said the delivery is given back without
counting
, which is now the opposite of what it does, and the test's own comment
claimed a release shares this counter. Both corrected.

Verification

dotnet build -warnaserror: 0 warnings, 0 errors. Full suite: 809 passed, 0
failed, 2 skipped
.

The unclaim path gave a delivery back without limit, so a caller claiming
and aborting in a loop could never reach the delivery cap.
The only check on the deliveries was a lower bound, which the refund's
absence also satisfies. The contract above it still described the old
behaviour, and a release does not share this counter.
@kisielewski
kisielewski merged commit 265a768 into main Sep 4, 2026
3 checks passed
@kisielewski
kisielewski deleted the fix/a-refund-that-is-counted-and-bounded branch September 4, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant