C1: the engine-reads keeper calls every node again at its part's consumer bind (issue 1966, ADR 0668)

A manifest-reads-changed said before the part's consumer existed was never heard (note 155), and the
statement taken while an engine restarted stood. AtBind is registered on the hub's OnBound.

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
2026-11-10 02:54:44 +01:00
parent 66e0c611bf
commit 5c29bea0b3
2 changed files with 39 additions and 1 deletions
@@ -1,8 +1,11 @@
package enginereads
import (
"context"
"encoding/json"
"strings"
"testing"
"time"
)
// The answer and the event are judged as the contract lays them out and its reader checks: the layout's version, a node
@@ -34,6 +37,24 @@ func TestTheAnswerAndTheEventAreJudged(t *testing.T) {
t.Errorf("event %s: %v, want %q", name, err, c.bad)
}
}
// Issue 1966 note 155, ADR 0668 §4: a part whose first call of a node timed out, and whose consumer was bound after
// the node's event was said, calls every node once at the bind, and the node is then held as it answered.
calls := map[string]int{}
k := &Keeper{Sync: true, Call: func(node, _ string, _ any) (json.RawMessage, error) {
calls[node]++
if node == "ace" && calls[node] == 1 {
return nil, context.DeadlineExceeded
}
return json.RawMessage(`{"v":1,"node":"` + node + `","manifest-reads":["a.b"],"stated-at":"` + at + `"}`), nil
}}
k.AskNode("ace", "the first view")
if k.Statements()["ace"].Answered {
t.Errorf("a call that timed out reads as answered")
}
k.AtBind(func() []string { return []string{"ace", "g14"} })(time.Unix(0, 0))
if p := k.Present([]string{"ace", "g14"}); len(p["ace"]) != 1 || len(p["g14"]) != 1 || calls["ace"] != 2 || calls["g14"] != 1 {
t.Errorf("after the bind: present %v, calls %v", p, calls)
}
if Verb != "manifest-reads" || Event != "manifest-reads-changed" || Consumes != "node-engine.manifest-reads-changed" || Invoke != "seat:node-engine.manifest-reads" {
t.Errorf("the names are %s %s %s %s", Verb, Event, Consumes, Invoke)
}