From e7177db3cce8b790fe54b2035818afde343f9d0c Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 19:03:01 +0100 Subject: [PATCH] H-A-178: key restore-point-missing by module and node; test the placements read MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Findings are keyed by scope, id and kind across the mesh, so the module alone as the id let two machines clear each other's restore-point-missing: its id is now ., as a held module's is. Before the watch of the assignments has caught up the point is asked as before and a missing answer holds the move (H-A-178, built in d217056c); the composer's Watch test now shows RecoveryPlaced answers read only once the assignments are caught up. Builds: design 47 H §456, H-A-177, H-A-178 --- internal/seatwait/restorepoint.go | 14 ++++++++++---- internal/seatwait/seatwait_test.go | 6 +++--- internal/selfcompose/selfcompose_test.go | 7 +++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/internal/seatwait/restorepoint.go b/internal/seatwait/restorepoint.go index 2dc86df2..36932842 100644 --- a/internal/seatwait/restorepoint.go +++ b/internal/seatwait/restorepoint.go @@ -10,18 +10,24 @@ import ( // RestorePointMissingKind is the finding the node-engine writes when it moves a module across a form change without its restore // point, because the assigner's placements name no holder of the seat mesh-recovery anywhere on the mesh (design 47 H, H-A-177, -// H §456): a warning, scope the machine, its id the module. It clears at the module's next take-in with a point. +// H §456): a warning, scope the machine, its id `.` (H-A-178), as a held module's is. It clears at the module's +// next take-in with a point. const RestorePointMissingKind = "restore-point-missing" +// RestorePointMissingID is the finding's id for a module on a node: findings are keyed by scope, id and kind across the mesh, so +// two machines never clear each other's (H-A-178). +func RestorePointMissingID(module, node string) string { return module + "." + node } + // SayRestorePointMissing writes the finding for module when missing, with the words naming what moved without a point, and clears // it when no longer: a take-in of the module took its point. A write or a clear that fails is returned for the caller to say. func SayRestorePointMissing(ctx context.Context, w Writer, node, observer, module, words string, missing bool, now func() time.Time) error { + id := RestorePointMissingID(module, node) if !missing { - return w.Clear(ctx, scopeMachine, module, RestorePointMissingKind, "a take-in of the module took its restore point") + return w.Clear(ctx, scopeMachine, id, RestorePointMissingKind, "a take-in of the module took its restore point") } - return w.Write(ctx, condseat.Finding{Observer: observer, Kind: RestorePointMissingKind, Scope: scopeMachine, ID: module, + return w.Write(ctx, condseat.Finding{Observer: observer, Kind: RestorePointMissingKind, Scope: scopeMachine, ID: id, Severity: condseat.FindingSeverityWarning, Source: RestorePointMissingKind, - Subject: condseat.Subject{Scope: scopeMachine, ID: module, Machine: node}, + Subject: condseat.Subject{Scope: scopeMachine, ID: id, Machine: node}, Summary: fmt.Sprintf("%s moved on %s without its restore point: %s", module, node, words), Headline: fmt.Sprintf("%s moved without a restore point on %s", module, node), Explanation: "No holder of the seat mesh-recovery is placed on the mesh, so the node-engine moved the module across a change of its kept data's form without taking a restore point first: that move cannot be reverted to the data as it was. The finding clears at the module's next take-in that takes its point.", diff --git a/internal/seatwait/seatwait_test.go b/internal/seatwait/seatwait_test.go index a742726b..b3d31b84 100644 --- a/internal/seatwait/seatwait_test.go +++ b/internal/seatwait/seatwait_test.go @@ -242,17 +242,17 @@ func caseAnEntryNotFoundIsAFindingOfTheFingerprint(t *testing.T) { t.Fatalf("cleared %+v, %v", u.cleared, err) } // And design 47 H, H-A-177: a module moved without its restore point is the finding restore-point-missing, a warning of scope - // machine with the module as its id, on the node's machine, cleared by the same. + // machine with `.` as its id (H-A-178), on the node's machine, cleared by the same. r := &fakeFindings{} if err := SayRestorePointMissing(context.Background(), r, "n1", "mesh-host", "db", "cache (form 1)", true, now); err != nil { t.Fatal(err) } if len(r.put) != 1 || RestorePointMissingKind != "restore-point-missing" || r.put[0].Kind != RestorePointMissingKind || r.put[0].Scope != "machine" || - r.put[0].ID != "db" || r.put[0].Severity != condseat.FindingSeverityWarning || r.put[0].Subject.Machine != "n1" || !strings.Contains(r.put[0].Summary, "cache (form 1)") { + r.put[0].ID != "db.n1" || r.put[0].Severity != condseat.FindingSeverityWarning || r.put[0].Subject.Machine != "n1" || !strings.Contains(r.put[0].Summary, "cache (form 1)") { t.Fatalf("written %+v", r.put) } if err := SayRestorePointMissing(context.Background(), r, "n1", "mesh-host", "db", "", false, now); err != nil || len(r.cleared) != 1 || - r.cleared[0].Kind != RestorePointMissingKind || r.cleared[0].ID != "db" { + r.cleared[0].Kind != RestorePointMissingKind || r.cleared[0].ID != "db.n1" { t.Fatalf("cleared %+v, %v", r.cleared, err) } } diff --git a/internal/selfcompose/selfcompose_test.go b/internal/selfcompose/selfcompose_test.go index d06377de..9264aa2c 100644 --- a/internal/selfcompose/selfcompose_test.go +++ b/internal/selfcompose/selfcompose_test.go @@ -286,6 +286,10 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) { c.holdEntry(t, "oldie", oldieFp, oldie) b.put(t, buckets.Wants, "want.n1.lemurs", want) b.put(t, buckets.Wants, "want.n1.node", nodeWant) + // Design 47 H, H-A-177, H-A-178: before the watch of the assignments has caught up, the placements are not read. + if _, read := c.RecoveryPlaced(); read { + t.Error("the placements are read before the watch of the assignments caught up") + } for _, bucket := range []string{buckets.Wants, buckets.Assignments, buckets.Have, ResolvedBucket} { b.send(bucket, agent.Update{Caught: true}) } @@ -294,6 +298,9 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) { for { u := next(t, out) if u.Caught { + if placed, read := c.RecoveryPlaced(); !read || placed { + t.Errorf("once the assignments are caught up RecoveryPlaced answers placed %v read %v, want read with no holder", placed, read) + } break } c, err := compositions.Decode(u.Value)