fleetd #609: nudge an idle lead to hand over when its own context reads HIGH #610
Reference in New Issue
Block a user
Delete Branch "worker/fleetd-609-context-high-nudge-01f62b-1"
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?
Closes fleetd #609.
What changed
LeadHeartbeatLoopcan now append a text-only notice to its heartbeat nudge whenthe idle lead's own
LeadContextGaugereading isHIGH, gated by the newleadHeartbeat.contextHighNudgeconfig key (default off — an upgraded daemonnever silently acquires the behavior).
LeadContextGauge.Reading.unknown()widened from package-private to public,so
LeadHeartbeatLoop.LeadContextSource.none()(a different package) canreturn the same inert "I could not look" reading without a parallel constant.
No other change to
LeadContextGauge.FleetConfig.LeadHeartbeatgains a 4th component,contextHighNudge. A 3-argconvenience constructor keeps every pre-existing call site compiling unchanged.
LeadHeartbeatLoop.decidetakes the lead's ownLeadContextGauge.Stateand acontextNotifiedlatch. The latch fires the notice once per HIGH stretch, iscleared only by a later
OKreading (never byUNKNOWN, which means "couldnot look," not "got better"), and never spends the
quietNudgeCapbudget.This never rolls a pane by itself — only the operator can approve a handover,
via the lead's own
fleet_handover.Fleetdwires a newleadContextLookup/leadContextSourcefactory pair(mirroring the existing
leadConfigDirLookupidiom) intomain()'sLeadHeartbeatLoopconstruction.fleetd.example.yamldocuments the new key (required byFleetConfigTest.everyNestedConfigKeyIsDocumentedInTheExample— outside thestrict 3-file scope, but needed for the existing test to pass).
Ticket comment (id 17381) addressed
nullwhenreading.tokens()is null (defensive; today aHIGHreading always carriesnon-null tokens, verified in
LeadContextGauge.java) — covered bycontextNoticeOmitsTheTokenClauseRatherThanPrintingNull.grep -rln "new LeadHeartbeatLoop(" src/test/javashows onlyLeadHeartbeatLoopTest.javaconstructs
LeadHeartbeatLoopdirectly. Its edits were driven entirely by thedecide()signature expansion this ticket's design explicitly asked for(adding the
context/contextNotifiedparameters), not by any inadequacy inthe new constructor's defaults — the two pre-existing public constructors are
byte-for-byte unchanged and no caller of them needed any edit.
Tests
mvn -o clean installfromfleetd/:New tests: 13 added to
LeadHeartbeatLoopTest.java(properties A-H fordecide()'s context/latch behavior, plus 5contextNoticetests), plus two newfiles,
FleetdLeadContextLookupTest.java(4 tests) andFleetdLeadContextSourceWiringTest.java(2 tests), covering the newFleetdfactories end to end with a real transcript file.
Mutation testing (per the ticket's requirement)
Mutation 1 — made
decide()'s latch always clear on any non-HIGH reading(including
UNKNOWN, not justOK) — real red:Mutation 2 — made the
contextHigh && !latchgate ignore the latch (alwaysINJECTon HIGH) — real red:Both mutations reverted;
mvn -o test -Dtest=LeadHeartbeatLoopTestgreen againbefore committing.