H-A-458 (2): answer the composition's drift through the seat's contract

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)
This commit is contained in:
2026-11-22 02:58:22 +01:00
parent 213542192c
commit 3b1f5a07d2
4 changed files with 14 additions and 16 deletions
+3 -3
View File
@@ -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
},
+1 -1
View File
@@ -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
+8 -2
View File
@@ -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" ||
+2 -10
View File
@@ -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.