mesh-config: a rename window written after start rearms the deadline timer (issue 1982; ADR 0681 §1; A-490l)
The timer was rearmed on a write of proposals or retiring only, so a rename window opened after start, with nothing else waiting on a time, left it blocked and its seven-day held finding never came; a window opened under a later armed deadline came late. The condition is now armsDeadline (proposals, retiring, renames), and a test shows a written window rearms it. The comment on Proposal.Pull cites ADR 0681 §5. Builds: ADR 0681 §1; lead answer A-490l (hq main, 03-DESIGN/01-to-be/47-milestones/G-22-lead-answers-2.md: the held finding comes in a quiet mesh too). Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user