fleetd #440: derive coordinator.heldDurable from queue durability + ack mode #443
Reference in New Issue
Block a user
Delete Branch "worker/440-helddurable-derived-d462d7-13"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #440.
What was wrong
FleetMcp.coordinatorViewwroteheldDurableas the literaltrue(FleetMcp.java:1418, confirmed in this tree). The value it describes -- held peer mail survives a crash because the queue is declared durable AND the consumer uses manual ack -- was true, but nothing in the code checked it. Breaking either fact (a non-durable queue, orautoAck=true) would leave the field, and the whole test suite, green.Lines named in the ticket (
FleetMcp.java:1418,FleetMcpTest.java:733,LeadMailbox.java:195/:196) all matched what I found in my own tree before I started.What changed
LeadChannelgets a newheldDurable()method. Javadoc states it as the conjunction of "queue declared durable" and "consumer is manual-ack", and that an implementation must derive it from what it actually did, never assert it.LeadMailbox.own()now captures the exact booleans it passes toqueueDeclare/basicConsumeinto locals (durableQueue,autoAck), storesdurableQueue && !autoAckin a new field, andheldDurable()returns that field. The queue declaration and the ack mode themselves are unchanged -- only how the fact is captured.FleetMcp.coordinatorViewnow readschannel.heldDurable()instead of the literal. Javadoc atFleetMcp.java:1396-1404rewritten to say where the fact comes from instead of arguing it's true in prose.FakeLeadChannelgets aheldDurablefield (defaults totrue, matching production) and awithHeldDurable(boolean)setter, so hermetic tests can force the false case.FleetMcpTest: new testlistReportsHeldDurableFalseWhenTheChannelSaysMailIsNotDurable-- proves the field follows the channel, not a constant (acceptance criterion 3).LeadMailboxTest(the@Tag("contract")real-broker test, unchanged in scope): new testheldDurableReportsTrueBecauseTheQueueIsDurableAndTheConsumeIsManualAck. This is the one that actually exercisesown()'s realqueueDeclare/basicConsumecalls --FleetMcpTestonly exercises the fake, so it can't catch a mutation toLeadMailboxitself.LeadChannelinFleetMcpTest(the timeout/interrupt test) got a trivialheldDurable() { return true; }to keep compiling -- it's an unrelated fake with no bearing on this fact.Mechanism note (departure from the ticket's suggestion)
The ticket suggested exposing this "through
LeadChannel... since it already ownsselfCoordId()/peek()" -- I did exactly that,heldDurable()lives onLeadChannel. No departure there.Acceptance criterion 2 -- no behaviour change
heldDurableis stilltrueon the current configuration (proved by the existinglistReportsAnHonestHeldCountAndDurabilityNotJustPendingZerotest, unchanged, still green) and no otherfleet_listfield moved.Acceptance criterion 4 -- the mutation must fail (evidence)
Ran everything against a real broker via
-Pcontract(Docker was available in this worktree).1. Baseline green, before any mutation:
Mutation applied -- flipped
own()'sautoAcklocal totrue(this isLeadMailbox.java:201in the refactored code; confirmed applied before running):2. RED run, same test class, same command (
mvn -Pcontract test -Dtest=LeadMailboxTest):My new test caught it directly; two pre-existing redelivery tests also went red as a side effect of the same mutation (autoAck=true means the broker never redelivers on a fresh connection).
3. Restored, then GREEN again -- reverted the local to
false, confirmed the revert applied, reran:Full-suite run (hermetic, no Docker profile)
Run twice (once before the mutation experiment, once after restoring it) -- same count both times, 1563/0/0, BUILD SUCCESS.
LeadMailboxTeststays@Tag("contract")-excluded from this run, as before; it's exercised separately above.Extra: other constant-looking fields in coordinatorView (report only, not fixed)
row.put("configured", true)atFleetMcp.javaincoordinatorView-- this one is currently safe: the method returnsnulltwo lines above wheneverchannel == null, so by the time this line runs,configuredreally is a fact, not a guess. It's still a literal describing a condition already established elsewhere in the method rather than reading it directly, so worth a second look if that guard ever gets refactored.coordinatorView,mailboxView,heldView, orpeerView-- everything else there reads offLeadMessage/MailboxState/held.size()/coordination.peers().Caveats for review
heldDurableReportsTrueBecauseTheQueueIsDurableAndTheConsumeIsManualAck) lives in the@Tag("contract")class, so it needs Docker (orAMQP_URI) to run -- it does not run under plainmvn clean install/mvn test. I don't see a way around this: there is no existing hermetic seam (no Mockito, no hand-rolled fakeChannel/Connection) for exercisingLeadMailbox.own()without a real broker, and adding one felt out of scope for this ticket.FleetMcpTest's new test covers the wiring (criterion 3) hermetically viaFakeLeadChannel; the contract test covers the actual derivation (criterion 4).