mesh-issues: a counter not started never starts without the knowledge base's answer, floor or no floor (review of #214)
mesh/merge-gate pass: builds mesh-issues, mesh-knowledge, records → novox; no bus step; every machine composes with the change as it did without (4 of 4 co…
mesh/repo-check pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-check-typescript.sh (typescript)
mesh/delivery delivered

This commit is contained in:
2026-10-11 12:44:45 +02:00
parent 2369098303
commit 1b7f79f761
3 changed files with 22 additions and 27 deletions
+5 -11
View File
@@ -180,8 +180,8 @@ func busHighest() (map[string]uint64, error) {
}
// nextOf takes a sequence's next number. A counter not yet started is started once, above the highest the
// knowledge base holds, the operator's floor and every reservation kept. With the knowledge base silent it starts
// from the floor alone, saying so, and with neither it is not started and nothing is spent. A started counter
// knowledge base holds, the operator's floor and every reservation kept; with the knowledge base silent it is not
// started, floor or no floor, and nothing is spent. A started counter
// behind the knowledge base (a number taken by hand, or imported) is raised to it first; a knowledge base that
// does not answer then leaves the counter as it is, and the warning answered says so.
func (t *Tracker) nextOf(seq sequence, highest uint64, heldErr error) (uint64, string, error) {
@@ -192,15 +192,9 @@ func (t *Tracker) nextOf(seq sequence, highest uint64, heldErr error) (uint64, s
}
if e == nil {
if heldErr != nil {
s, serr := t.Settings()
if serr != nil || seq.floor(s) == 0 {
return 0, "", fmt.Errorf("the %s counter has not started, and neither the knowledge base answers the highest %s "+
"number it holds (%v) nor the operator set a %s floor: it starts above them, so no number was taken. Ask "+
"again when the knowledge base answers", seq.kind, seq.kind, heldErr, seq.kind)
}
warning = fmt.Sprintf("the knowledge base did not answer the highest %s number it holds (%v): the %s counter "+
"started above the operator's floor %d alone, unchecked against the records held. Check that the knowledge "+
"base holds no %s at or above it", seq.kind, heldErr, seq.kind, seq.floor(s), seq.kind)
return 0, "", fmt.Errorf("the %s counter has not started, and the knowledge base does not answer the highest %s "+
"number it holds (%v): the counter starts above it, and a floor alone cannot say a number is free, so no "+
"number was taken. Ask again when the knowledge base answers", seq.kind, seq.kind, heldErr)
}
if err := t.startSequence(seq, highest); err != nil {
return 0, "", err
@@ -232,9 +232,8 @@ func TestARefusedReservationSpendsNothing(t *testing.T) {
func TestAKnowledgeBaseThatDoesNotAnswerRefusesTheFirstNumberAndNotTheNext(t *testing.T) {
h, k := reserveHarness(t)
k.err = errors.New("nothing answers mesh-knowledge.knowledge_highest")
if _, err := h.Reserve(ReserveAsk{Kind: KindDecision}); err == nil || !strings.Contains(err.Error(), "knowledge_highest") ||
!strings.Contains(err.Error(), "floor") {
t.Fatalf("a first reservation with the knowledge base silent and no floor: %v", err)
if _, err := h.Reserve(ReserveAsk{Kind: KindDecision}); err == nil || !strings.Contains(err.Error(), "knowledge_highest") {
t.Fatalf("a first reservation with the knowledge base silent: %v", err)
}
if h.mem.counterOf(t, KindDecision) != 0 || len(h.said()) != 0 {
t.Fatal("a refused first reservation started the counter or said something")
@@ -259,18 +258,21 @@ func TestAKnowledgeBaseThatDoesNotAnswerRefusesTheFirstNumberAndNotTheNext(t *te
}
}
// With the knowledge base silent, the operator's floor alone starts a counter, above it and every reservation
// kept, and the answer says it was not checked against what is held.
func TestTheFloorAloneStartsACounterWhenTheKnowledgeBaseDoesNotAnswer(t *testing.T) {
// A counter not started never starts without the knowledge base's answer, floor or no floor: a floor alone
// cannot say a number above it is free. Nothing is spent. With the answer, the floor still raises the start.
func TestAFloorDoesNotStartACounterTheKnowledgeBaseDoesNotAnswerFor(t *testing.T) {
h, k := reserveHarness(t)
k.err = errors.New("the knowledge base holds no record yet")
h.settings.ResearchFloor = 47
out, err := h.Reserve(ReserveAsk{Kind: KindResearch})
if err != nil || out.Number != 48 || !strings.Contains(out.Warning, "floor") || !strings.Contains(out.Warning, "unchecked") {
t.Fatalf("%+v %v", out, err)
if out, err := h.Reserve(ReserveAsk{Kind: KindResearch}); err == nil || !strings.Contains(err.Error(), "the knowledge base holds no record yet") {
t.Fatalf("a research number from the floor alone: %+v %v", out, err)
}
if _, err := h.Reserve(ReserveAsk{Kind: KindDecision}); err == nil {
t.Fatal("a decision number with no floor and no answer was handed out")
if keys, _ := h.mem.Keys(ReservationsState); len(keys) != 0 || h.mem.counterOf(t, KindResearch) != 0 {
t.Fatal("a refused first reservation spent a number or started the counter")
}
k.err = nil
if got := h.reserve(t, KindResearch); got != 48 {
t.Fatalf("got %d, want 48: one above the floor 47, above the 045 held", got)
}
}