diff --git a/modules/mesh-config/cmd/mesh-config/main.go b/modules/mesh-config/cmd/mesh-config/main.go index 15d4d8df5..aadd6c207 100644 --- a/modules/mesh-config/cmd/mesh-config/main.go +++ b/modules/mesh-config/cmd/mesh-config/main.go @@ -134,10 +134,15 @@ func (runtimeAsks) Warranted(ask string) error { return err } +// armsDeadline says a write to this state can move the deadline timer: a proposal, a retirement or a rename window (A-490l). +func armsDeadline(state string) bool { + return state == ProposalsState || state == RetiringState || state == RenamesState +} + func main() { own, rearm := newOwnCopy(), make(chan struct{}, 1) own.changed = func(state string) { - if state == ProposalsState || state == RetiringState { + if armsDeadline(state) { select { case rearm <- struct{}{}: default: diff --git a/modules/mesh-config/cmd/mesh-config/proposals.go b/modules/mesh-config/cmd/mesh-config/proposals.go index f821555bb..59d31ac8f 100644 --- a/modules/mesh-config/cmd/mesh-config/proposals.go +++ b/modules/mesh-config/cmd/mesh-config/proposals.go @@ -98,8 +98,8 @@ type Proposal struct { HadValue bool `json:"had-value"` WasDigest string `json:"was-digest"` Trusted bool `json:"trusted,omitempty"` - // Pull is read only: a proposal an earlier mesh-config kept for a pull request (ADR 0502, ended by the operator's word, - // record pending). It is never set on an Approve now, and judged not to be one this module makes (problem). + // Pull is read only: a proposal an earlier mesh-config kept for a pull request (ADR 0502, superseded by ADR 0681 ยง5). + // It is never set on an Approve now, and judged not to be one this module makes (problem). Pull string `json:"pull,omitempty"` // Reaches is each module on each node whose value it moves, as it was judged when proposed. Reaches []string `json:"reaches"` diff --git a/modules/mesh-config/cmd/mesh-config/quiet_test.go b/modules/mesh-config/cmd/mesh-config/quiet_test.go index 1995523e3..0abf7b72e 100644 --- a/modules/mesh-config/cmd/mesh-config/quiet_test.go +++ b/modules/mesh-config/cmd/mesh-config/quiet_test.go @@ -320,3 +320,34 @@ func TestAHeldWindowIsAFindingAtItsDeadlineWithNoPass(t *testing.T) { t.Error("a deadline is still set once the finding is written") } } + +// A write of a proposal, a retirement or a rename window sets the deadline timer again, and no other state does: a window opened +// after start, with nothing else waiting on a time, must not leave the timer blocked (A-490l). +func TestAWriteOfARenameWindowRearmsTheDeadlineTimer(t *testing.T) { + for state, want := range map[string]bool{ProposalsState: true, RetiringState: true, RenamesState: true, + ValuesState: false, ResolvedState: false, DeclaredState: false} { + if got := armsDeadline(state); got != want { + t.Errorf("a write of %s arms the timer: %v, want %v", state, got, want) + } + } + // Wired as main wires it: the copy's write of a window tells the channel the timer waits on. + b := &busOf{held: map[string]map[string][]byte{}, handles: map[string]func(stdio.StateChange) error{}} + own := b.ownCopy() + rearm := make(chan struct{}, 1) + own.changed = func(state string) { + if armsDeadline(state) { + select { + case rearm <- struct{}{}: + default: + } + } + } + if err := own.write(RenamesState, "player.level", Rename{Module: "player"}); err != nil { + t.Fatal(err) + } + select { + case <-rearm: + default: + t.Error("a rename window written after start did not rearm the timer") + } +}