From 3b1f5a07d2cc606f8a5edb5d4c79044a9b1ad607 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 02:58:22 +0100 Subject: [PATCH] H-A-458 (2): answer the composition's drift through the seat's contract MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The verb composition's drift, the directory entries the mesh made whose owner or mode on disk differ, was the engine's own DriftView, a field the node-engine seat's definition did not have. The definition now carries drift (id, path, drift) at form 4, and the engine answers it as the generated CompositionAnswerDriftItem; DriftView goes. Row: the answer read back through the contract's decoder names the drift. Review round 1, finding: drift in the composition answer. Builds: design 47 H2 §813; H-A-374, H-A-392 (b), H-A-458 (2) --- cmd/mesh-host/nodeagent.go | 6 +++--- internal/agent/agent.go | 2 +- internal/agent/agent_test.go | 10 ++++++++-- internal/agent/composition.go | 12 ++---------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/cmd/mesh-host/nodeagent.go b/cmd/mesh-host/nodeagent.go index d28a669e..fde0506a 100644 --- a/cmd/mesh-host/nodeagent.go +++ b/cmd/mesh-host/nodeagent.go @@ -558,7 +558,7 @@ func nodeAgent(ctx context.Context, opts options, signer ed25519.PublicKey, trus say(line) } }, - DirectoryDrift: func(runs compositions.Composed) []agent.DriftView { + DirectoryDrift: func(runs compositions.Composed) []nodeengine.CompositionAnswerDriftItem { d, err := declarationOf(runs) if err != nil { return nil @@ -567,9 +567,9 @@ func nodeAgent(ctx context.Context, opts options, signer ed25519.PublicKey, trus if err != nil { return nil } - var out []agent.DriftView + var out []nodeengine.CompositionAnswerDriftItem for _, x := range apply.DirectoryDrifts(d, known) { - out = append(out, agent.DriftView{ID: x.ID, Path: x.Path, Drift: x.Drift}) + out = append(out, nodeengine.CompositionAnswerDriftItem{ID: x.ID, Path: x.Path, Drift: x.Drift}) } return out }, diff --git a/internal/agent/agent.go b/internal/agent/agent.go index d78e0358..7753f658 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -195,7 +195,7 @@ type Env struct { TakenAtStart func(module string, runs compositions.Composed) // DirectoryDrift reads, for the verb composition's diff, each directory entry of runs the mesh made whose owner or // mode on disk differ (apply.DirectoryDrifts, H-A-392). Nil reads none. - DirectoryDrift func(runs compositions.Composed) []DriftView + DirectoryDrift func(runs compositions.Composed) []nodeengine.CompositionAnswerDriftItem // RunsChanged is told, outside the agent's lock, that what runs (Everything) changed other than by an apply or a // removal: once at the start, when the haves and the compositions they name are read, and each time a module is // taken as running from its have or the kept declaration. Like Settled, the filling then tells the provisioner's diff --git a/internal/agent/agent_test.go b/internal/agent/agent_test.go index d5a968b1..d1c96b92 100644 --- a/internal/agent/agent_test.go +++ b/internal/agent/agent_test.go @@ -2027,13 +2027,19 @@ func testTheNodesOwnCompositionIsAppliedWhenItDiffersAndARecordMoveWaitsForAYes( keep(dk, draw) keep(dk, drawMoved) // H-A-392: and with diff, each directory the mesh made of what runs whose mode or owner on disk drifted. - b.ag.env.DirectoryDrift = func(runs compositions.Composed) []DriftView { - return []DriftView{{ID: runs.Module + ".data", Path: "/srv/db", Drift: "mode 0700, 0711 declared"}} + b.ag.env.DirectoryDrift = func(runs compositions.Composed) []nodeengine.CompositionAnswerDriftItem { + return []nodeengine.CompositionAnswerDriftItem{{ID: runs.Module + ".data", Path: "/srv/db", Drift: "mode 0700, 0711 declared"}} } view, err := b.ag.Composition(context.Background(), "db", "", true) if len(view.Drift) != 1 || view.Drift[0].ID != "db.data" { t.Errorf("the diff of db names the drift %+v", view.Drift) } + // H-A-458 (2): the answer is read as the seat's contract has it, drift among its fields. + if raw, merr := json.Marshal(view); merr != nil { + t.Error(merr) + } else if read, _, derr := nodeengine.DecodeCompositionAnswer(raw); derr != nil || len(read.Drift) != 1 || read.Drift[0] != view.Drift[0] { + t.Errorf("the composition answer read through the contract: drift %+v, %v", read.Drift, derr) + } if err != nil || view.Have == nil || view.Have.Phase != string(nodeengineclient.PhaseWaitingYes) || view.Composition.Digest != ddigMoved || view.Runs == nil || view.Runs.Composed != ddig || view.Judged.Judgement != string(nodeengineclient.JudgedRecreates) || !view.Judged.WaitsForYes || len(view.Diff) != 1 || view.Diff[0].ID != "db.server" || view.Diff[0].Change != "changed" || diff --git a/internal/agent/composition.go b/internal/agent/composition.go index c39bb8bd..4eae9994 100644 --- a/internal/agent/composition.go +++ b/internal/agent/composition.go @@ -51,8 +51,8 @@ type CompositionView struct { Diff []judge.ResourceChange `json:"diff,omitempty"` // Drift is, when the diff is asked, each directory entry of what runs that the mesh made, as its record holds, whose // owner or mode on disk differ from it (H-A-374, H-A-392): read-only; the engine sets it right at its next start or - // apply of the module. - Drift []DriftView `json:"drift,omitempty"` + // apply of the module. Its form is the node-engine seat's contract's (H-A-458 (2)). + Drift []nodeengine.CompositionAnswerDriftItem `json:"drift,omitempty"` // Own is, of the node's own composition (module node), its own fields beside what runs names (issue 774: ace's // own composition dropped the provisioner client's account, and nothing read could show it). Own *OwnView `json:"own,omitempty"` @@ -348,14 +348,6 @@ func (a *Agent) revisionsOf(ctx context.Context, key string) ([]compNow, error) return out, nil } -// DriftView is one directory entry the mesh made whose owner or mode on disk differ from it, as the verb composition's -// diff names it (H-A-392): its id, its path and how, in words. -type DriftView struct { - ID string `json:"id"` - Path string `json:"path"` - Drift string `json:"drift"` -} - // CompositionDiff answers the node-engine seat's read verb composition-diff (design 47 H2 §813 (3), H-A-349 DQ-12b): one // module's composition that runs beside another revision of its composition key, given by its revision or its digest, // as the entries that differ per resource; environment entries by name, a secret's value masked. It changes nothing.