From 53d5c8b20fca66a0a12ae91a3e82b5146f082030 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 21 Nov 2026 23:18:48 +0100 Subject: [PATCH] E1: read another part's values tolerantly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The generated decoders keep unknown fields and return the form read, so a want the assigner writes with run, or any field added later, is applied rather than refused: the node-engine that reads run runs before the assigner writes it. Builds: design 47 H2 §780; §813 (1) (the edge) --- internal/agent/agent.go | 4 ++-- internal/agent/agent_test.go | 8 ++++++++ internal/selfcompose/candidate.go | 2 +- internal/selfcompose/selfcompose.go | 2 +- internal/selfcompose/shadow.go | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/internal/agent/agent.go b/internal/agent/agent.go index c78eedf2..50e8283e 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -828,7 +828,7 @@ func (a *Agent) takeWant(u Update) string { if _, ok := meshwants.ParseWantsByWantNodeNodeKey(u.Key); ok { w := wantNow{Node: true, Rev: u.Revision} if !u.Deleted { - nw, err := meshwants.DecodeWantsByWantNodeNodeValue(u.Value) + nw, _, err := meshwants.DecodeWantsByWantNodeNodeValue(u.Value) if err != nil { a.sayOnce("want:node", fmt.Sprintf("the node's own want is not one: %v", err)) return "" @@ -844,7 +844,7 @@ func (a *Agent) takeWant(u Update) string { } w := wantNow{Rev: u.Revision} if !u.Deleted { - want, err := meshwants.DecodeWantsByWantNodeModuleValue(u.Value) + want, _, err := meshwants.DecodeWantsByWantNodeModuleValue(u.Value) if err != nil { a.sayOnce("want:"+module, fmt.Sprintf("the want of %s is not one: %v", module, err)) return "" diff --git a/internal/agent/agent_test.go b/internal/agent/agent_test.go index 77990ac5..92080f0b 100644 --- a/internal/agent/agent_test.go +++ b/internal/agent/agent_test.go @@ -331,6 +331,14 @@ func TestAWantAndItsCompositionApplyTheModuleAndTheHaveNamesBoth(t *testing.T) { ckn, crawn, dign := composition(t, "web", fpn, false, archive("a", d1), archive("b", d2)) b.comps.put(ckn, crawn) wkn, wrawn := wantFor(t, "web", fpn, dign, "") + // Design 47 H2 §780, §813 (1): the want is read tolerantly, a field this engine does not know and a later form kept + // rather than refused, so the engine that reads run runs before the assigner writes it. + var later map[string]any + if err := json.Unmarshal(wrawn, &later); err != nil { + t.Fatal(err) + } + later["form"], later["a-later-field"] = 3, "x" + wrawn, _ = json.Marshal(later) b.wants.put(wkn, wrawn) b.idle() if got := len(b.appliedList()) - before; got != 1 { diff --git a/internal/selfcompose/candidate.go b/internal/selfcompose/candidate.go index c03ba799..15cbdac5 100644 --- a/internal/selfcompose/candidate.go +++ b/internal/selfcompose/candidate.go @@ -187,7 +187,7 @@ func (s *Shadow) composeCandidate(ctx context.Context, c *Composer, ask nodeengi if raw == nil { return refuse("the indexer holds no candidate " + ask.Candidate) } - cand, err = meshcatalog.DecodeCandidatesByGroupValue(raw) + cand, _, err = meshcatalog.DecodeCandidatesByGroupValue(raw) if err != nil { return refuse(fmt.Sprintf("the indexer's candidate %s cannot be read: %v", ask.Candidate, err)) } diff --git a/internal/selfcompose/selfcompose.go b/internal/selfcompose/selfcompose.go index f177fd83..7b12cccb 100644 --- a/internal/selfcompose/selfcompose.go +++ b/internal/selfcompose/selfcompose.go @@ -898,7 +898,7 @@ func (c *Composer) takeWantLocked(u agent.Update) string { delete(c.notTaken, module) delete(c.keptWants, module) c.dropForgottenLocked(module) // its next want asks again what a failed fetch made it forget (H-A-146) - w, err := meshwants.DecodeWantsByWantNodeModuleValue(u.Value) + w, _, err := meshwants.DecodeWantsByWantNodeModuleValue(u.Value) if u.Deleted || err != nil || w.Removed || w.Fp == "" { delete(c.wants, module) switch { diff --git a/internal/selfcompose/shadow.go b/internal/selfcompose/shadow.go index c4ebd49d..506efd1b 100644 --- a/internal/selfcompose/shadow.go +++ b/internal/selfcompose/shadow.go @@ -332,7 +332,7 @@ func (s *Shadow) takeCandidate(u agent.Update) bool { } return true } - c, err := meshmoduleassigner.DecodeCandidatesByProposalNodeValue(u.Value) + c, _, err := meshmoduleassigner.DecodeCandidatesByProposalNodeValue(u.Value) if err != nil || c.Proposal != proposal || (c.Assignments != nil && c.Assignments.Node != node) { // Not one: read as gone. if _, ok := s.candidates[proposal][node]; ok {