H-A-374: set a drifted directory the mesh made right at the engine's start
ace's Node toolchain cache directory stood at 0700 against its entry's 0711 while the engine said its composition was unchanged: an unchanged composition is never applied, and the judgement reads the compositions, not the disk. Each module taken as running at the engine's start now has every directory entry its record says the mesh made given its declared owner and mode where they drifted on disk, one journal line each; one the mesh never made stays used as found and is said (issue 339). The verb composition's diff names a drifted directory the mesh made. The agent test that marks modules not composed now waits for every want it marks. Builds: design 47 H2 §813; H-A-374, H-A-392
This commit is contained in:
@@ -185,6 +185,13 @@ type Env struct {
|
||||
// them. The node-engine's filling tells the provisioner's client then to fill again what it refused (mesh-host
|
||||
// internal/filling Knock; ace, 2026-10-25 21:17). Nil tells nothing.
|
||||
Settled func(module string)
|
||||
// TakenAtStart is told, outside the agent's lock, each module taken as running at this start from its have or the
|
||||
// kept declaration, with no apply, and the composition it runs: the node-engine converges the owner and mode of each
|
||||
// record-held directory entry of it (H-A-374, H-A-392). Nil tells nothing.
|
||||
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
|
||||
// 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
|
||||
@@ -1700,6 +1707,7 @@ func (a *Agent) baseline(ctx context.Context, module string, w wantNow, comp com
|
||||
a.running[module] = nodeengine.HaveByNodeModuleValue{Fp: h.FP, Composed: h.Composed, Phase: nodeengineclient.PhaseRunning}
|
||||
a.mu.Unlock()
|
||||
a.runsChanged(module + " was taken from its have")
|
||||
a.takenAtStart(module, comp.C)
|
||||
// Said again, so the session holds the module and its key carries the health this engine judges,
|
||||
// not the one an older engine left there (xorg's unknown on g14 and shanks, 2026-10-25).
|
||||
a.writeHave(ctx, Have{Module: module, FP: h.FP, Composed: h.Composed,
|
||||
@@ -1729,6 +1737,7 @@ func (a *Agent) baseline(ctx context.Context, module string, w wantNow, comp com
|
||||
a.running[module] = nodeengine.HaveByNodeModuleValue{Fp: w.Want.Fp, Composed: w.Composed, Phase: nodeengineclient.PhaseRunning}
|
||||
a.mu.Unlock()
|
||||
a.runsChanged(module + " was taken from the kept declaration")
|
||||
a.takenAtStart(module, comp.C)
|
||||
a.writeHave(ctx, Have{Module: module, FP: w.Want.Fp, Composed: w.Composed, Phase: string(nodeengineclient.PhaseRunning)})
|
||||
return true
|
||||
}
|
||||
@@ -1876,6 +1885,13 @@ func (a *Agent) apply(ctx context.Context, module string, w wantNow, comp compNo
|
||||
a.catchUp(ctx, module, catchUps)
|
||||
}
|
||||
|
||||
// takenAtStart tells TakenAtStart of a module taken as running at this start (H-A-392).
|
||||
func (a *Agent) takenAtStart(module string, runs compositions.Composed) {
|
||||
if a.env.TakenAtStart != nil {
|
||||
a.env.TakenAtStart(module, runs)
|
||||
}
|
||||
}
|
||||
|
||||
// runIsNewer says whether a want's run orders after the run a module was applied from (design 47 H2 §813 (1)): each is
|
||||
// the composition run's pipeline sequence in decimal. A want or an apply without one is not ordered by run, nor is a run
|
||||
// that is no decimal number.
|
||||
|
||||
@@ -133,6 +133,8 @@ type bed struct {
|
||||
said []string
|
||||
// settled is each module Settled was told, and settledRan whether what runs held it then.
|
||||
settled []string
|
||||
// takenAtStart is each module TakenAtStart was told, with its composition's resource count.
|
||||
takenAtStart []string
|
||||
settledRan []bool
|
||||
ag *Agent // the agent run() runs
|
||||
env Env
|
||||
@@ -179,6 +181,11 @@ func newBed(t *testing.T) *bed {
|
||||
}
|
||||
return Backup{Done: true}
|
||||
},
|
||||
TakenAtStart: func(m string, runs compositions.Composed) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
b.takenAtStart = append(b.takenAtStart, fmt.Sprintf("%s:%d", m, len(runs.Resources)))
|
||||
},
|
||||
Settled: func(m string) {
|
||||
ran := false
|
||||
if b.ag != nil {
|
||||
@@ -420,6 +427,11 @@ func TestStartingOnWhatTheKeptDeclarationHoldsAppliesNothing(t *testing.T) {
|
||||
if got := b.appliedList(); len(got) != 0 {
|
||||
t.Fatalf("a module that already runs what the want names was applied: %v", got)
|
||||
}
|
||||
// H-A-392: a module taken as running at the start is told with the composition it runs, for its directories' drift.
|
||||
if b.mu.Lock(); !slices.Equal(b.takenAtStart, []string{"web:2"}) {
|
||||
t.Errorf("taken at the start were %v; want web with its two resources", b.takenAtStart)
|
||||
}
|
||||
b.mu.Unlock()
|
||||
t.Run("starting on its own have applies nothing", testStartingOnItsOwnHaveAppliesNothing)
|
||||
}
|
||||
|
||||
@@ -1907,10 +1919,11 @@ func TestTheNodesOwnCompositionIsAppliedWhenItDiffersAndARecordMoveWaitsForAYes(
|
||||
b.haves.Write(context.Background(), Have{Module: "broken", FP: brokenFP, Composed: brokenDig, Phase: string(nodeengineclient.PhaseFailed),
|
||||
Detail: "apply: unit failed to start"})
|
||||
want("broken", brokenFP, "")
|
||||
eventually(t, "unread's want was not taken", func() bool {
|
||||
// Every want taken before the mark, not unread's alone: fresh's taken after it was not marked (seen under -race).
|
||||
eventually(t, "the wants were not taken", func() bool {
|
||||
b.ag.mu.Lock()
|
||||
defer b.ag.mu.Unlock()
|
||||
return b.ag.wants["unread"].Present
|
||||
return b.ag.wants["unread"].Present && b.ag.wants["fresh"].Present && b.ag.wants["broken"].Present
|
||||
})
|
||||
b.ag.NotComposed(context.Background(), "a stand-in for web's password, again")
|
||||
if h := b.haves.last("unread"); h.Module != "" {
|
||||
@@ -1992,7 +2005,14 @@ func TestTheNodesOwnCompositionIsAppliedWhenItDiffersAndARecordMoveWaitsForAYes(
|
||||
// container it recreates; the revision that runs, asked by its digest, is no move (issue 774).
|
||||
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"}}
|
||||
}
|
||||
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)
|
||||
}
|
||||
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" ||
|
||||
|
||||
@@ -49,6 +49,10 @@ type CompositionView struct {
|
||||
Judged JudgedView `json:"judged"`
|
||||
// Diff is every resource that differs from what runs, when asked.
|
||||
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"`
|
||||
// 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"`
|
||||
@@ -302,6 +306,9 @@ func (a *Agent) Composition(ctx context.Context, module, digest string, diff boo
|
||||
}
|
||||
if diff {
|
||||
view.Diff = judge.ChangedResources(running, read.C)
|
||||
if running != nil && a.env.DirectoryDrift != nil {
|
||||
view.Drift = a.env.DirectoryDrift(*running)
|
||||
}
|
||||
}
|
||||
return view, nil
|
||||
}
|
||||
@@ -341,6 +348,14 @@ 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.
|
||||
|
||||
Reference in New Issue
Block a user