diff --git a/cmd/mesh-host/nodeagent.go b/cmd/mesh-host/nodeagent.go index 7476a3f8..ebb39e01 100644 --- a/cmd/mesh-host/nodeagent.go +++ b/cmd/mesh-host/nodeagent.go @@ -699,7 +699,7 @@ func nodeAgent(ctx context.Context, opts options, signer ed25519.PublicKey, trus apply.UseEngineModule(composer.EngineModule) // the guard of the engine's own trees fixes no name (§527) env.Composed, env.SelfComposed, env.Policy, env.ComposedToday = composer, true, composer.Policy, composer.ComposedToday env.Recovery = recoveryEnv(session, composer) - env.WhyUnmade, env.Waiting = composer.WhyUnmade, composer.Waiting + env.WhyUnmade, env.Waiting, env.RunningManifest = composer.WhyUnmade, composer.Waiting, composer.RunningManifest keptFetchFn := keptArtifactFetch(composer.KeptBuildOf, session.AskSeatOn, session.KeptObject) keptFetch.Store(&keptFetchFn) env.HoldsData = composer.HoldsData // what runs from the kept declaration says Data as its manifest does diff --git a/internal/agent/agent.go b/internal/agent/agent.go index a3a7437c..2ae0a6d9 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -132,6 +132,10 @@ type Env struct { // a fingerprint it holds none of, so a composer that believes it handed it hands it again. Nil tells nobody. WhyUnmade func(module string) string Waiting func(module, fp string) + // RunningManifest is the one place that answers the manifest of the build a module runs here (design 47 G A-484): the source + // that answered with its build, or, where none did, the words naming the three it tried. The tool composition says it. Nil + // says nothing. + RunningManifest func(module string) (source, fp, words string) // Apply applies one module's composition (scope NodeModule for the node's own), given the compositions the node's // other modules run so a path, unit or group they hold is not removed or taken. It is called with one module at a // time. diff --git a/internal/agent/agent_test.go b/internal/agent/agent_test.go index d70664b3..f4f8e4c2 100644 --- a/internal/agent/agent_test.go +++ b/internal/agent/agent_test.go @@ -1718,6 +1718,15 @@ func TestTheNodesOwnCompositionIsAppliedWhenItDiffersAndARecordMoveWaitsForAYes( if _, err := b.ag.Composition(context.Background(), "ghost", "", false); err == nil || !strings.Contains(err.Error(), "waits for the composer: no manifest in the composer's picture") { t.Errorf("the composition read of ghost says %v, want why the composer made none", err) } + // Where the one place says what runs of it (A-484), the tool answers it though the want's build has no composition. + b.ag.env.RunningManifest = func(string) (string, string, string) { + return "the module's trunk manifest in the catalog", "src2:t", "the manifest of the build ghost runs here is read from the module's trunk manifest in the catalog" + } + if view, err := b.ag.Composition(context.Background(), "ghost", "", false); err != nil || view.RunsManifest == nil || + view.RunsManifest.Source != "the module's trunk manifest in the catalog" || !strings.Contains(view.Composition.Refused, "waits for the composer") { + t.Errorf("the composition read of ghost says %+v, %v, want what runs of it and why the composer made none", view.RunsManifest, err) + } + b.ag.env.RunningManifest = nil toldMu.Lock() if n := slices.Index(told, "ghost@"+fpOf("9")); saidCount() != 1 || n < 0 || slices.Contains(told[n+1:], "ghost@"+fpOf("9")) { t.Errorf("said %d times, told %q; want once and ghost told once", saidCount(), told) diff --git a/internal/agent/composition.go b/internal/agent/composition.go index 9539952c..b570f5f7 100644 --- a/internal/agent/composition.go +++ b/internal/agent/composition.go @@ -37,6 +37,9 @@ type CompositionView struct { Revisions []RevisionView `json:"revisions,omitempty"` // Runs is what runs of the module, and where that is known from; nil when nothing of it runs. Runs *RunsView `json:"runs,omitempty"` + // RunsManifest is the manifest of the build that runs of the module, as the one place reads it (design 47 G A-484): which + // source answered, or the words naming the three it tried. Said also where the want's build has no composition. + RunsManifest *RunsManifestView `json:"runs-manifest,omitempty"` // Judged is the move from what runs to the composition read, as the agent judges it before an apply. Judged JudgedView `json:"judged"` // Diff is every resource that differs from what runs, when asked. @@ -136,6 +139,14 @@ type RunsView struct { Resources int `json:"resources"` } +// RunsManifestView is what the one place answers of the build a module runs here. +type RunsManifestView struct { + // Source is the source that answered; empty when none did. + Source string `json:"source,omitempty"` + FP string `json:"fp,omitempty"` + Words string `json:"words"` +} + // JudgedView is a move's judgement. type JudgedView struct { Judgement string `json:"judgement"` @@ -178,6 +189,10 @@ func (a *Agent) Composition(ctx context.Context, module, digest string, diff boo Held: att.Held, AnsweredRevision: att.AnsweredRev, Transient: att.Transient} } view.Started = a.checked[module] + if a.env.RunningManifest != nil && module != NodeModule { + src, rfp, words := a.env.RunningManifest(module) + view.RunsManifest = &RunsManifestView{Source: src, FP: rfp, Words: words} + } latest, haveLatest := a.compositionFor(module, fp) r, ran := a.running[module] from, known := a.runningComposition(module) @@ -220,12 +235,19 @@ func (a *Agent) Composition(ctx context.Context, module, digest string, diff boo case digest != "" && read == nil: return view, fmt.Errorf("no revision of %s the bucket keeps has the digest %s; revisions lists those it keeps", key, digest) case read == nil && !haveLatest: + // What runs of the module is still said, through the one place (A-484): the composition read is the want's build, and a + // module held at another build has none of it. + words := fmt.Sprintf("the bucket holds no composition of %s at %s", module, fp) if a.env.SelfComposed && a.env.WhyUnmade != nil && module != NodeModule { if why := a.env.WhyUnmade(module); why != "" { - return view, fmt.Errorf("the bucket holds no composition of %s at %s; the agent waits for the composer: %s", module, fp, why) + words = fmt.Sprintf("the bucket holds no composition of %s at %s; the agent waits for the composer: %s", module, fp, why) } } - return view, fmt.Errorf("the bucket holds no composition of %s at %s", module, fp) + if view.RunsManifest == nil { + return view, errors.New(words) + } + view.Composition = RevisionView{Key: key, Refused: words} + return view, nil case read == nil: read = &latest } diff --git a/internal/compose/frombus/answer.go b/internal/compose/frombus/answer.go index 27b8f5aa..3ee74415 100644 --- a/internal/compose/frombus/answer.go +++ b/internal/compose/frombus/answer.go @@ -75,7 +75,7 @@ func Answer(ctx context.Context, r Reader, mesh Mesh, s Scope, fps map[string]st return refuse(fmt.Errorf("frombus: the credentials of %s: %w", s.Node, err)) } } - composed, skipped, stood, err := composeEach(in, s.Node, fps, false, s.Running, failed, ranOf(ctx, r, mesh, s.Running, fps), true) + composed, skipped, stood, err := composeEach(in, s.Node, fps, false, s.Running, failed, s.RunningManifest, true) if err != nil { // Not one module's: the node's own (a value served elsewhere, the mesh's network), said once as the node's. if len(failed) == 0 { @@ -358,21 +358,13 @@ func composeEach(in compose.Input, node string, fps map[string]string, applied b if !ok { return } - running, known := catalogue.Manifest{}, false if ran != nil { if was, ok := ran(m); ok { - man.Contributes, man.ContributesMany, man.Listens = was.Contributes, was.ContributesMany, was.Listens - running, known = was, true + // A held module keeps running what it runs, so it keeps offering what that build offers, whatever its version and + // whether the catalog lists the build: the module that requires it is no "nothing provides" (A-480, A-484). + man.Contributes, man.ContributesMany, man.Listens, man.Provides = was.Contributes, was.ContributesMany, was.Listens, was.Provides } } - if !known { - running, known = heardManifest(in, node, m) - } - if known { - // A held module keeps running what it runs, so it keeps providing what that build provides, whatever its version and - // whether the catalog lists the build: the module that requires it is no "nothing provides" (A-480). - man.Provides = running.Provides - } src[m] = man } if leave != "" { @@ -522,19 +514,6 @@ func manifestOn(in compose.Input, node, module string) (catalogue.Manifest, bool return man, ok } -// heardManifest is the manifest of the build node said it runs of module (its `running` event's manifest, read by the event's digest, -// Node.Heard): false where nothing runs of it, it is stopped or the digest could not be read. -func heardManifest(in compose.Input, node, module string) (catalogue.Manifest, bool) { - for _, n := range in.Nodes { - if n.Name == node { - if h, ok := n.Heard[module]; ok && h.Read && !h.Stopped { - return h.Manifest, true - } - } - } - return catalogue.Manifest{}, false -} - // culprit is the module placed on node whose composition the error is of, and what of its offer to leave out: the // first, in assignment order, whose stub (compose.Stub) makes the composition in mode succeed or fail otherwise (leave // ""); else the first whose stub without what it contributes to one provision does (leave that provision: de-spiegel's diff --git a/internal/compose/frombus/answer_rows_test.go b/internal/compose/frombus/answer_rows_test.go index 5ea57583..d15ef72a 100644 --- a/internal/compose/frombus/answer_rows_test.go +++ b/internal/compose/frombus/answer_rows_test.go @@ -638,7 +638,10 @@ func answerNamesEveryRefusalAndLeavesAnOldBuildToTheNode(t *testing.T) { siteRuns.FP = fp("7") b.manifests[meshcatalogclient.ManifestDigest(site)] = site b.builds["site "+fp("7")] = &builds.BuilderBuild{State: builds.BuildDone, Manifest: meshcatalogclient.ManifestDigest(site)} - got, _, held, err = Compose(ctx, b, Mesh{}, Scope{Node: "n1", Running: []engcomp.Composed{siteRuns}}, fps) + // The manifest of the build that runs is read in the one place (A-484), here the manifest of the build 7. + ranSite, _ := catalogue.Decode(site) + got, _, held, err = Compose(ctx, b, Mesh{}, Scope{Node: "n1", Running: []engcomp.Composed{siteRuns}, + RunningManifest: func(module string) (catalogue.Manifest, bool) { return ranSite, module == "site" }}, fps) if err != nil || held["site"] == "" || held["nft"] != "" { t.Errorf("site moved to 9090 in its new manifest: %v, held %v; want site held alone", err, held) } diff --git a/internal/compose/frombus/frombus.go b/internal/compose/frombus/frombus.go index 991efd3b..2f9866ef 100644 --- a/internal/compose/frombus/frombus.go +++ b/internal/compose/frombus/frombus.go @@ -197,6 +197,11 @@ type Scope struct { // the seat list, novox/hq ADR 0636 §1): each is held as it runs, as a module refused alone is, so no take-in or // artifact reference of it can refuse the node (issue 1966). Nil holds none. Held map[string]string + // RunningManifest answers the manifest of the build a module runs on the composing node, from the one place that reads it + // (design 47 G A-484: its entry, else the composition the node runs of it, else the trunk's manifest): what a held module + // keeps offering the others (what it provides, contributes and listens on), since it keeps running what it runs. False + // where nothing is read; the manifest it is composed from is its offer then. Nil: none is read. + RunningManifest func(module string) (catalogue.Manifest, bool) } // InOwn is, of the modules p places on its node, those whose resources the node's own composition it runs @@ -703,7 +708,7 @@ func Compose(ctx context.Context, r Reader, mesh Mesh, s Scope, fps map[string]s return nil, nil, held, fmt.Errorf("frombus: the credentials of %s: %w", s.Node, err) } } - out, skipped, _, err = composeEach(in, s.Node, fps, true, s.Running, held, ranOf(ctx, r, mesh, s.Running, fps), true) + out, skipped, _, err = composeEach(in, s.Node, fps, true, s.Running, held, s.RunningManifest, true) return out, skipped, held, err } @@ -991,33 +996,6 @@ func parser(Mesh) func([]byte) (catalogue.Manifest, error) { return catalogue.Decode } -// ranOf is what a module last offered the others, read when it is held (composeEach, issue 1960): its manifest at the -// build its own composition runs at (running), where that is another build than the one it is composed at (fps) and -// the builder holds it done. False where nothing is known of it (it runs no composition of its own, it runs the build -// it is composed at, or its build is unread): the manifest it is composed from is its offer then. Only what it says to -// others is taken of it, which needs no take-in of its artifacts. -func ranOf(ctx context.Context, r Reader, mesh Mesh, running []engcomp.Composed, fps map[string]string) func(string) (catalogue.Manifest, bool) { - parse := parser(mesh) - return func(module string) (catalogue.Manifest, bool) { - for _, c := range running { - if c.Module != module || c.FP == "" || c.FP == fps[module] { - continue - } - b, err := r.Build(ctx, module, c.FP) - if err != nil || b == nil || b.State != builds.BuildDone || b.Manifest == "" { - return catalogue.Manifest{}, false - } - raw, err := r.Manifest(ctx, b.Manifest) - if err != nil { - return catalogue.Manifest{}, false - } - man, err := parse(raw) - return man, err == nil - } - return catalogue.Manifest{}, false - } -} - // fromBuilds puts in the built manifest of each module placed on the composing node, at the trunk's FP2, and of each // module it keeps at another build (Scope.KeptAt, into its node's Kept), read from the builder's done key and resolved // by the one take-in rule (takein.Manifest), a templates archive read in the artifact store as the node reaches it diff --git a/internal/compose/frombus/held_rows_test.go b/internal/compose/frombus/held_rows_test.go index 4d8d8367..628d617e 100644 --- a/internal/compose/frombus/held_rows_test.go +++ b/internal/compose/frombus/held_rows_test.go @@ -10,6 +10,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + "git.novox.be/novox/mesh-sdk/go/catalogue" "github.com/novox/mesh-host/internal/compose" "github.com/novox/mesh-host/internal/compose/resolution" engcomp "github.com/novox/mesh-host/internal/compositions" @@ -342,8 +343,8 @@ func TestASecondClaimantOfASeatIsHeldAndTheNodeComposesTheRest(t *testing.T) { // A-480 (design 47 G): a module the node holds keeps running what it runs, and so keeps providing what its running build provides, // whatever its catalogue entry: the module that requires it is not held for "nothing provides" (live, 2026-11-17 22:52: feh on g14 // held for "x11-display" while xorg runs there, held only for want of an entry of its wanted build). The offer is the running - // composition's build's manifest (the builder's done key), else the manifest the module's `running` event names; a module - // neither running nor composable still gives "nothing provides". + // manifest of the build it runs, from the one place that reads it (A-484); a module neither running nor composable still gives + // "nothing provides". const xorgRunning = `{"module":"xorg","version":"1","provides":[{"name":"x11-display"}]}` feh := `{"module":"feh","version":"1","requires":["x11-display"]}` nameOnly := `{"module":"xorg","version":"0"}` @@ -352,18 +353,13 @@ func TestASecondClaimantOfASeatIsHeldAndTheNodeComposesTheRest(t *testing.T) { scope func(fps map[string]string, b *bus) Scope provided bool }{ - {"it runs a build its running event names", func(fps map[string]string, b *bus) Scope { - digest := meshcatalogclient.ManifestDigest([]byte(xorgRunning)) - b.manifests[digest] = []byte(xorgRunning) - return Scope{Heard: map[string]map[string]Heard{"n1": {"xorg": {Fingerprint: "src2:" + strings.Repeat("r", 64), Manifest: digest}}}} - }, true}, - {"its composition runs a build the builder holds done", func(fps map[string]string, b *bus) Scope { - fp := "src2:" + strings.Repeat("r", 64) - digest := meshcatalogclient.ManifestDigest([]byte(xorgRunning)) - b.manifests[digest] = []byte(xorgRunning) - b.builds["xorg "+fp] = &builds.BuilderBuild{State: builds.BuildDone, Manifest: digest} - return Scope{Running: []engcomp.Composed{{Node: "n1", Module: "xorg", FP: fp}}} + {"the one place answers the manifest of the build it runs (A-484)", func(fps map[string]string, b *bus) Scope { + man, _ := catalogue.Decode([]byte(xorgRunning)) + return Scope{RunningManifest: func(module string) (catalogue.Manifest, bool) { return man, module == "xorg" }} }, true}, + {"the one place reads none", func(map[string]string, *bus) Scope { + return Scope{RunningManifest: func(string) (catalogue.Manifest, bool) { return catalogue.Manifest{}, false }} + }, false}, {"nothing of it runs", func(map[string]string, *bus) Scope { return Scope{} }, false}, } { b, fps := aNode(t, nameOnly, feh) diff --git a/internal/selfcompose/candidate.go b/internal/selfcompose/candidate.go index 42edf498..e6ec25cf 100644 --- a/internal/selfcompose/candidate.go +++ b/internal/selfcompose/candidate.go @@ -490,7 +490,7 @@ func (c *Composer) composeShadow(ctx context.Context, running []engcomp.Composed c.mu.Lock() c.wants = wants c.mu.Unlock() - scope := frombus.Scope{Node: node, KeptAt: kept, InOwn: inOwn, Running: running, SameValue: c.sameValue, Heard: c.heardNow()} + scope := frombus.Scope{Node: node, KeptAt: kept, InOwn: inOwn, Running: running, SameValue: c.sameValue, Heard: c.heardNow(), RunningManifest: c.runningFor(node)} if input != nil { input(scope, fps) } diff --git a/internal/selfcompose/entries.go b/internal/selfcompose/entries.go index 74d01903..99f878a1 100644 --- a/internal/selfcompose/entries.go +++ b/internal/selfcompose/entries.go @@ -296,14 +296,6 @@ func (c *Composer) wantedBuilds() map[string]bool { } } } - // The trunk build of a module this node runs without an entry of its wanted or running build is asked too (A-480a). - for module, tb := range c.trunkBuilds { - if tb.fp != "" && c.runsWithoutEntry(module) { - if _, named := out[tb.fp]; !named { - out[tb.fp] = false - } - } - } // The build each module runs here, as the node's own record of it says: its entry, kept in the composition state, stays held // for the judgement of a move's data forms though the catalog half dropped it and no event of the stream names it. for _, r := range running { @@ -391,6 +383,11 @@ func (c *Composer) layModules() { c.sayOnceEach(line) } }() + // Read before the lock: what the node runs is the agent's, and a read of it may wait. + var running []engcomp.Composed + if c.env.Running != nil { + running = c.env.Running() + } c.mu.Lock() defer c.mu.Unlock() modules := map[string]meshcatalog.ModulesByModuleValue{} @@ -413,6 +410,19 @@ func (c *Composer) layModules() { c.manifests[digest] = raw return true } + // layAnswer lays a module from the manifest the one place read of the build it runs (A-484): the entry's own fields, or the + // trunk's answer, which holds none of an entry's checks. + layAnswer := func(module string, a runningAnswer) bool { + switch { + case !a.Known: + return false + case a.Source == SourceTrunk: + modules[module] = meshcatalog.ModulesByModuleValue{Fp2: a.FP, Manifest: a.Digest, Repository: a.Repository, Commit: a.Commit, Path: a.Path} + c.manifests[a.Digest] = a.Raw + return true + } + return lay(module, a.FP) + } nodes := make([]string, 0, len(c.heard)) for node := range c.heard { nodes = append(nodes, node) @@ -424,9 +434,7 @@ func (c *Composer) layModules() { // Where the running build has no entry, the module is laid from the entry of the build the assignment places // for that node, the mesh's truth of what it runs there (A-461); with neither it stays name-only below. if !lay(module, run.fingerprint) && node != c.env.Node { - if built := c.placedBuild(node, module); built != "" && built != run.fingerprint { - lay(module, built) - } + layAnswer(module, c.runningLocked(running, node, module, "")) } } } @@ -446,9 +454,7 @@ func (c *Composer) layModules() { if _, laid := modules[pm.Module]; laid || !c.needsAddressOf(node, pm.Module) || !c.lacksEntry(node, pm.Module) { continue } - if built := c.placedBuild(node, pm.Module); built != "" { - lay(pm.Module, built) - } + layAnswer(pm.Module, c.runningLocked(running, node, pm.Module, "")) } } for module, w := range c.wants { @@ -471,14 +477,19 @@ func (c *Composer) layModules() { } continue } - // Running here with no entry of its wanted or running build and none of the newest: it stands, for resolution alone, as its - // trunk build, so the module that requires what it provides is no "nothing provides" (A-480a); its want stays held. - if _, laid := modules[module]; !laid && c.runsWithoutEntry(module) { - if tb := c.trunkBuilds[module]; tb.fp != "" && lay(module, tb.fp) { + // Running here with no entry of its wanted build and none of the newest: it stands, for resolution alone, as the manifest of + // the build it runs, from the one place (A-484), so the module that requires what it provides is no "nothing provides"; + // its want stays held. A running build whose entry is held is laid where it is heard (above) and is read by a held module's offer + // through the one place alone, so it is not laid again here. + if _, laid := modules[module]; !laid && c.countsAsRunning(module) { + if a := c.runningLocked(running, c.env.Node, module, ""); a.Source != SourceEntry && layAnswer(module, a) { m := modules[module] m.Fp2 = w.Fp modules[module] = m - said = append(said, fmt.Sprintf("%s runs a build whose manifest the node does not hold, so it counts what the trunk build %s of %s provides; its want stays held", module, tb.fp, module)) + said = append(said, fmt.Sprintf("%s runs a build whose entry the node does not hold, so it counts the manifest read from %s; its want stays held", module, a.Source)) + if a.Said != "" { + said = append(said, a.Said) + } continue } } @@ -503,15 +514,12 @@ func (c *Composer) layModules() { c.modules = modules } -// placedBuild is the build the assignment places for module on node (c.mu held), the mesh's truth of what it runs there; where the -// placement names none, the module's trunk build as syncEntries asked it (A-461b). Empty where neither is known. +// placedBuild is the build the assignment places for module on node (c.mu held), the mesh's truth of what it runs there; empty +// where the placement names none (the one place then asks the trunk's manifest, A-484). func (c *Composer) placedBuild(node, module string) string { for _, pm := range c.assignments[node].Modules { if pm.Module == module { - if pm.Build != "" { - return pm.Build - } - return c.trunkBuilds[module].fp + return pm.Build } } return "" @@ -549,68 +557,40 @@ func (c *Composer) needsAddressOf(node, module string) bool { return false } -// runsWithoutEntry says this node holds module on, as it runs it, and holds no entry of its wanted build nor of its running build -// (c.mu held), and whose running event's manifest is not held (A-480a): the case where its -// provisions are read from its trunk build (A-480a). A module built by hand before G says no running event (the engine says one only -// of a build whose manifest it knows), so it counts as running when its have names a build in the phase running or held (A-482); one -// wanted here that is heard running nowhere, runs nothing here and has no such have does not count. -func (c *Composer) runsWithoutEntry(module string) bool { - run := c.heard[c.env.Node][module] - w, wanted := c.wants[module] - if run.stopped || !wanted || w.Fp == "" || !(c.runsHere(module) || c.haveRuns[module]) { - return false - } - // What is read decides (A-480a: "can be read from neither"): the manifest its running event names, where that digest is held; - // a running composition's build is read as frombus ranOf reads it, only through the entry of the wanted fingerprint (the - // loop below), so a composition at another build reads nothing. - if _, read := c.manifests[run.manifest]; run.manifest != "" && read { - return false - } - for _, fp := range []string{w.Fp, run.fingerprint} { - if k, held := c.keptEnt[fp]; held && k.entry.Module != "" { - return false - } - } - return true -} - // askTrunkBuilds asks, for each module another node runs at a build with no entry and whose placement names no build, the trunk // build by the seat's verb `module`, once per running build (A-461b). Called before the lock is taken: the verb is a call. func (c *Composer) askTrunkBuilds() (wait func()) { type ask struct{ node, module, running string } var asks []ask + var running []engcomp.Composed + if c.env.Running != nil { + running = c.env.Running() + } c.mu.Lock() + // The module whose running build's manifest the one place reads from the trunk, where neither its entry nor its composition + // answers (A-484): the modules this node runs, and another node's module this node needs the address of (A-461, A-461d). for node, p := range c.assignments { for _, pm := range p.Modules { module := pm.Module - // Only a module this node needs the address of (A-461): the store's holder, the provider of a requirement. - if pm.Build != "" || !c.needsAddressOf(node, module) || !c.lacksEntry(node, module) || c.trunkAsking[module] { + if c.trunkAsking[module] { continue } - running := c.heard[node][module].fingerprint - if had, asked := c.trunkBuilds[module]; !asked || had.running != running { - asks = append(asks, ask{node, module, running}) - if c.trunkAsking == nil { - c.trunkAsking = map[string]bool{} + if node == c.env.Node { + if !c.countsAsRunning(module) { + continue } - c.trunkAsking[module] = true + } else if !c.needsAddressOf(node, module) || !c.lacksEntry(node, module) { + continue } - } - } - // A module this node runs whose wanted build and running build have no entry stands as its trunk build, for resolution alone - // (A-480a): asked once per running build, as another node's is. - for _, pm := range c.assignments[c.env.Node].Modules { - module := pm.Module - if !c.runsWithoutEntry(module) || c.trunkAsking[module] { - continue - } - running := c.heard[c.env.Node][module].fingerprint - if had, asked := c.trunkBuilds[module]; !asked || had.running != running { - asks = append(asks, ask{c.env.Node, module, running}) - if c.trunkAsking == nil { - c.trunkAsking = map[string]bool{} + if a := c.runningLocked(running, node, module, ""); a.NeedTrunk { + if had, asked := c.trunkBuilds[module]; !asked || had.running != a.RunFP { + asks = append(asks, ask{node, module, a.RunFP}) + if c.trunkAsking == nil { + c.trunkAsking = map[string]bool{} + } + c.trunkAsking[module] = true + } } - c.trunkAsking[module] = true } } c.mu.Unlock() @@ -623,14 +603,22 @@ func (c *Composer) askTrunkBuilds() (wait func()) { go func() { defer all.Done() for a := range work { - fp, why := c.trunkFp(a.module) + t, why := c.trunkOf(a.module) + fp := t.fp c.mu.Lock() delete(c.trunkAsking, a.module) if fp != "" { if c.trunkBuilds == nil { c.trunkBuilds = map[string]trunkBuild{} } - c.trunkBuilds[a.module] = trunkBuild{running: a.running, fp: fp} + t.running = a.running + c.trunkBuilds[a.module] = t + delete(c.trunkWhy, a.module) + } else { + if c.trunkWhy == nil { + c.trunkWhy = map[string]string{} + } + c.trunkWhy[a.module] = why } c.mu.Unlock() if fp == "" { @@ -823,23 +811,34 @@ func (c *Composer) FormChanges(_ context.Context, module, runningFp, appliedFp s } return catalogue.Decode(raw) } - running, err := read(runningFp) - if err != nil { - // A running build with no entry (one from before G): what it keeps on the bus is read from the composition it runs on this - // node, as what it provides is (A-480). Where neither that composition nor the wanted build's manifest keeps data, no form - // can change; where either does, the module still waits for the entry (A-113, A-483). + // The manifest of the build the module runs is read in the one place (A-484): its entry, else the composition this node runs of + // it, else the trunk's manifest. Where it reads no manifest, the composition says whether the running build keeps data: with + // none on either side no form can change and the move goes on; where either keeps data, the move waits (A-113, A-483), with + // the words naming the three sources tried. + // The entry of the running build is asked of the catalog half (once), and kept when answered, as every entry the composer reads. + if e, state := c.entryOf(runningFp); state == meshcatalogclient.EntryAnswered && e.Module != "" { + c.mu.Lock() + if _, kept := c.keptEnt[runningFp]; !kept { + c.keptEnt[runningFp] = keptEntry{entry: e, since: c.now()} + } + c.mu.Unlock() + } + ra := c.runningManifest(c.env.Node, module, runningFp) + var running catalogue.Manifest + if ra.Known { + var err error + if running, err = catalogue.Decode(ra.Raw); err != nil { + return nil, fmt.Errorf("%s's running manifest: %w", module, err) + } + } else { wanted, werr := read(appliedFp) if werr != nil { return nil, fmt.Errorf("%s's wanted manifest: %w", module, werr) } - if c.env.Running != nil && len(wanted.DataItems()) == 0 { - for _, r := range c.env.Running() { - if r.Module == module && r.FP != "" && !r.Data { - return nil, nil - } - } + if ra.Source == SourceComposition && !ra.Data && len(wanted.DataItems()) == 0 { + return nil, nil } - return nil, fmt.Errorf("%s's running manifest: %w", module, err) + return nil, fmt.Errorf("%s's running manifest: %s", module, ra.Why) } applied, err := read(appliedFp) if err != nil { @@ -873,27 +872,34 @@ func (c *Composer) syncShadowEntries(ctx context.Context) (pending bool) { // moduleVerb is the seat mesh-catalog's verb `module`: one module's trunk fingerprint and manifest by name. const moduleVerb = "seat:" + meshcatalog.Seat + "." + meshcatalog.VerbModule -// trunkFp is the fingerprint of a module's trunk build, by the seat's verb `module`; empty with why where the catalog half gives none. -func (c *Composer) trunkFp(module string) (fp, why string) { +// trunkOf is a module's trunk build, by the seat's verb `module`: its fingerprint, manifest and where it is built from; empty with +// why where the catalog half gives none. +func (c *Composer) trunkOf(module string) (t trunkBuild, why string) { if c.env.Entry == nil { - return "", "this node reads no module of the catalog half" + return t, "this node reads no module of the catalog half" } raw, err := c.env.Entry(moduleVerb, meshcatalog.ModuleInput{Module: module}) if err != nil { - return "", fmt.Sprintf("the catalog half's answer for %s: %v", module, err) + return t, fmt.Sprintf("the catalog half's answer for %s: %v", module, err) } answer, said, ok := buscalls.Unwrap(raw) if !ok { - return "", fmt.Sprintf("the catalog half holds no module %s: %s", module, said) + return t, fmt.Sprintf("the catalog half holds no module %s: %s", module, said) } var a meshcatalog.ModuleAnswer if err := json.Unmarshal(answer, &a); err != nil { - return "", fmt.Sprintf("the catalog half's answer for %s cannot be read: %v", module, err) + return t, fmt.Sprintf("the catalog half's answer for %s cannot be read: %v", module, err) } if a.Module.Fp == "" { - return "", fmt.Sprintf("the catalog half gives %s no fingerprint: %s", module, a.Module.None) + return t, fmt.Sprintf("the catalog half gives %s no fingerprint: %s", module, a.Module.None) } - return a.Module.Fp, "" + return trunkBuild{fp: a.Module.Fp, manifest: a.Module.Manifest, repository: a.Module.Repository, commit: a.Module.Commit, path: a.Module.Path}, "" +} + +// trunkFp is the fingerprint of a module's trunk build (trunkOf); empty with why where the catalog half gives none. +func (c *Composer) trunkFp(module string) (fp, why string) { + t, why := c.trunkOf(module) + return t.fp, why } // addedModule is the trunk's build of a module an assignment candidate adds to this node when no want here names it yet: the diff --git a/internal/selfcompose/entries_test.go b/internal/selfcompose/entries_test.go index beafd92b..64fae4ba 100644 --- a/internal/selfcompose/entries_test.go +++ b/internal/selfcompose/entries_test.go @@ -291,7 +291,7 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) { {"heard no running event, its have says running (A-480a, A-482)", false, "", false, true, old, false, true, "running", ""}, {"heard no running event, its have says held (A-482)", false, "", false, true, old, false, true, "held", ""}, {"wanted here, heard no running event, no have (A-482)", false, "", false, false, old, false, true, "", ""}, - {"its running event names a manifest this node holds (A-480a)", true, "", false, false, old, false, true, "", "held"}, + {"its running event names a manifest this node holds: no source of the one place (A-484)", true, "", false, true, old, false, true, "", "held"}, {"its running event names a manifest this node cannot read (A-480a)", true, "", false, true, old, false, true, "", "unread"}, {"runs a composition at another build, no manifest read (A-480a)", true, "", false, true, old, false, true, "other", ""}, {"heard stopped, trunk entry held (A-480a)", false, "", false, false, old, true, true, "running", ""}, @@ -302,7 +302,9 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) { trunkFp := meshcatalogclient.SourcePrefix2 + strings.Repeat("4", 64) env.Entry = EntryCall(func(_ context.Context, _, verb string, _ any) (json.RawMessage, error) { if verb == meshcatalog.VerbModule && tc.trunk { - return json.Marshal(meshcatalog.ModuleAnswer{Module: meshcatalog.ModuleAnswerModule{Fp: trunkFp}}) + var man map[string]any + _ = json.Unmarshal([]byte(body), &man) + return json.Marshal(meshcatalog.ModuleAnswer{Module: meshcatalog.ModuleAnswerModule{Fp: trunkFp, Manifest: man}}) } return nil, errors.New("not held") }) @@ -426,6 +428,27 @@ func TestRunningBuildEntryKeptAndHandedAgain(t *testing.T) { }) } + // A-484: where neither the entry nor a composition answers, the trunk's manifest is the running build's: a form change is judged + // against it, and its words name the three sources where the trunk answered none either. + for _, trunk := range []bool{true, false} { + env := newFakeBus().env() + env.Node = "n1" + c := New(env) + c.holdEntry(t, "feh", next, `{"module":"feh","version":"2","data":{"own":[{"id":"state","kind":"state"}]}}`) + if trunk { + c.mu.Lock() + c.trunkBuilds = map[string]trunkBuild{"feh": {running: old, fp: next, manifest: map[string]any{"module": "feh", "version": "1"}}} + c.mu.Unlock() + } + changes, err := c.FormChanges(context.Background(), "feh", old, next) + switch { + case trunk && err != nil: + t.Errorf("the trunk's manifest answers, FormChanges = %v, %v", changes, err) + case !trunk && (err == nil || !strings.Contains(err.Error(), SourceEntry) || !strings.Contains(err.Error(), SourceComposition) || !strings.Contains(err.Error(), SourceTrunk)): + t.Errorf("no source answers, FormChanges says %v, want the three named", err) + } + } + // A-461, A-461a, A-461b: another node's module whose running build has no entry is laid from the entry of the build the assignment // places for it on that node, or, where the placement names none, of its trunk build; with neither entry it stays as its name // alone, and this node's own module is never laid from a placement. @@ -453,7 +476,11 @@ func TestRunningBuildEntryKeptAndHandedAgain(t *testing.T) { env.Node = "n1" env.Entry = EntryCall(func(_ context.Context, _, verb string, _ any) (json.RawMessage, error) { if verb == meshcatalog.VerbModule { - return json.Marshal(meshcatalog.ModuleAnswer{Module: meshcatalog.ModuleAnswerModule{Fp: tc.trunk}}) + var man map[string]any + if tc.trunk != "" { + man = map[string]any{"module": "distribution", "version": "2"} + } + return json.Marshal(meshcatalog.ModuleAnswer{Module: meshcatalog.ModuleAnswerModule{Fp: tc.trunk, Manifest: man}}) } return nil, errors.New("not held") }) @@ -481,7 +508,7 @@ func TestRunningBuildEntryKeptAndHandedAgain(t *testing.T) { if tc.node == "n2" && tc.build == "" && tc.trunk == "" && kept { t.Error("a trunk build that could not be had was kept, so it is asked once per process (A-461e)") } - if _, asked := c.wantedBuilds()[placedFp]; asked != (tc.node == "n2" && (tc.build != "" || tc.trunk != "")) { + if _, asked := c.wantedBuilds()[placedFp]; asked != (tc.node == "n2" && tc.build != "") { t.Errorf("the placed build asked = %v", asked) } c.layModules() diff --git a/internal/selfcompose/running.go b/internal/selfcompose/running.go new file mode 100644 index 00000000..294f3371 --- /dev/null +++ b/internal/selfcompose/running.go @@ -0,0 +1,227 @@ +package selfcompose + +import ( + "crypto/sha256" + "encoding/hex" + "encoding/json" + "fmt" + "slices" + + "git.novox.be/novox/mesh-sdk/go/catalogue" + engcomp "github.com/novox/mesh-host/internal/compositions" +) + +// The one place that answers "the manifest of the build a module runs here" (design 47 G A-484, joining A-480, A-480a, A-483 and +// A-461d). Every step that needs it reads it here and nowhere else: what the module provides (a held module keeps providing +// what it runs, frombus.Scope.RunningManifest), what it keeps on the bus and whether that changes form (FormChanges), the +// artifact store's holder (layModules, A-461d), and the picture of the catalog the composer resolves from. It answers in this +// order: the entry of the running build; else the composition this node runs of that build; else the module's trunk manifest +// through the seat mesh-catalog's verb `module`. + +// The three sources of the one place, in the words it says them in. +const ( + SourceEntry = "the entry of the running build" + SourceComposition = "the composition this node runs of it" + SourceTrunk = "the module's trunk manifest in the catalog" +) + +// runningAnswer is what the one place answers of one module. +type runningAnswer struct { + // Source is the source that answered; empty when none did, and Why then names the three. + Source string + // FP is the build the answer is of: the running build for an entry, the composition's build, or the trunk's. + FP string + // Known says the manifest itself was read (an entry or the trunk); a composition names its build and whether it keeps + // data, which is all it holds of the manifest. + Known bool + Manifest catalogue.Manifest + Raw []byte + Digest string + // Data is, from the composition, whether the running build keeps data on the bus. + Data bool + // Repository, Commit and Path are where the manifest's entry or the trunk's answer says it is built from. + Repository, Commit, Path string + // Why names what each of the three said, when none answered. + Why string + // RunFP is the running build the trunk manifest is asked for and kept against (A-461b). + RunFP string + // NeedTrunk says the trunk manifest is the one source left and is not held yet: the composer asks it beside the pass. + NeedTrunk bool + // Said is the line to say, once per module and source (principle 3); empty when it was said before. + Said string +} + +// runningFpsLocked are the fingerprints of the build module runs on node, as the node's own record says (c.mu held), most direct +// first: the build its running event names; on this node else the hint the caller knows and the build of the composition it runs; +// on another node also the build its placement names, the mesh's truth of what runs there (A-461). +func (c *Composer) runningFpsLocked(running []engcomp.Composed, node, module, hint string) (fps []string) { + add := func(fp string) { + if fp != "" && !slices.Contains(fps, fp) { + fps = append(fps, fp) + } + } + if r, ok := c.heard[node][module]; ok && !r.stopped { + add(r.fingerprint) + } + if node != c.env.Node { + add(c.placedBuild(node, module)) + return fps + } + add(hint) + for _, r := range running { + if r.Module == module { + add(r.FP) + } + } + return fps +} + +// runningLocked answers the manifest of the build module runs on node (c.mu held; running is what this node runs, read before +// the lock), from the three sources in order, and says which answered once per module and source. +func (c *Composer) runningLocked(running []engcomp.Composed, node, module, hint string) runningAnswer { + fps := c.runningFpsLocked(running, node, module, hint) + fp := "" + if len(fps) > 0 { + fp = fps[0] + } + var a runningAnswer + entryWhy, compWhy, trunkWhy := "", "", "" + // 1. The entry of the running build. + for _, f := range fps { + k, ok := c.keptEnt[f] + if !ok || k.entry.Module == "" { + continue + } + if digest, raw, err := entryManifest(k.entry); err == nil { + if man, err := catalogue.Decode(raw); err == nil { + a = runningAnswer{Source: SourceEntry, FP: f, Known: true, Manifest: man, Raw: raw, Digest: digest, + Repository: k.entry.Repository, Commit: k.entry.Commit, Path: k.entry.Path} + break + } + } + } + if a.Source == "" { + entryWhy = fmt.Sprintf("no entry of the build %s is held", orNone(fp)) + // 2. The composition this node runs of that build, whatever the want's build. + if node == c.env.Node { + for _, r := range running { + if r.Module != module || r.FP == "" { + continue + } + // The composition holds no manifest, only its build and whether that keeps data; its build's entry, if held, was + // read as the running build's above. + a = runningAnswer{Source: SourceComposition, FP: r.FP, Data: r.Data} + break + } + if a.Source == "" { + compWhy = "this node runs no composition of it" + } + } else { + compWhy = "only the node itself runs compositions of its modules" + } + } + // 3. The module's trunk manifest through the seat's verb `module`. + if !a.Known { + if t, ok := c.trunkBuilds[module]; ok && t.running == fp && len(t.manifest) > 0 { + if raw, err := json.Marshal(t.manifest); err == nil { + if man, err := catalogue.Decode(raw); err == nil { + keep := a // the composition's words stay: it says whether the build keeps data + a = runningAnswer{Source: SourceTrunk, FP: t.fp, Known: true, Manifest: man, Raw: raw, Digest: digestOf(raw), + Repository: t.repository, Commit: t.commit, Path: t.path, Data: keep.Data} + } + } + } + if !a.Known { + trunkWhy = c.trunkWhy[module] + if trunkWhy == "" { + trunkWhy = "the seat mesh-catalog's verb module has not answered" + } + a.NeedTrunk, a.RunFP = true, fp + } + } + if a.Source == "" || (!a.Known && a.Source == SourceComposition) { + a.Why = fmt.Sprintf("the manifest of the build %s runs here is read from none of: %s (%s); %s (%s); %s (%s)", module, + SourceEntry, orWords(entryWhy, "its entry is held without a manifest"), SourceComposition, + orWords(compWhy, "it names the build "+a.FP+" and no entry of that build is held"), SourceTrunk, trunkWhy) + } + if a.Source != "" { + line := fmt.Sprintf("%s runs a build whose manifest is read from %s", module, a.Source) + key := "running-manifest:" + node + "/" + module + "/" + a.Source + if c.told == nil { + c.told = map[string]bool{} + } + if !c.told[key] { + c.told[key] = true + a.Said = line + } + } + return a +} + +// runningManifest is runningLocked with the lock taken here: what runs is read first, since the agent's record may wait. +func (c *Composer) runningManifest(node, module, hint string) runningAnswer { + var running []engcomp.Composed + if c.env.Running != nil { + running = c.env.Running() + } + c.mu.Lock() + a := c.runningLocked(running, node, module, hint) + c.mu.Unlock() + if a.Said != "" { + c.env.Say(a.Said) + } + return a +} + +// countsAsRunning says this node holds module on as it runs it (A-482, c.mu held): it is heard running here, in what the agent +// runs, or its have names a build in the phase running or held. A module wanted here with none of these runs nothing here. +func (c *Composer) countsAsRunning(module string) bool { + if run := c.heard[c.env.Node][module]; run.stopped { + return false + } + return c.runsHere(module) || c.haveRuns[module] +} + +// RunningManifest is what the one place says of module's running build here, in words, for the tool composition: the source that +// answered with its build, or the words naming the three it tried. +func (c *Composer) RunningManifest(module string) (source, fp, words string) { + a := c.runningManifest(c.env.Node, module, "") + if a.Source == "" || (!a.Known && a.Why != "") { + return a.Source, a.FP, a.Why + } + return a.Source, a.FP, fmt.Sprintf("the manifest of the build %s runs here is read from %s", module, a.Source) +} + +// runningFor is the manifest of the build a module runs on node, for frombus.Scope.RunningManifest: only a module counted as +// running here (A-482) answers, and only a manifest read, never a composition alone. +func (c *Composer) runningFor(node string) func(module string) (catalogue.Manifest, bool) { + return func(module string) (catalogue.Manifest, bool) { + c.mu.Lock() + counts := node != c.env.Node || c.countsAsRunning(module) + c.mu.Unlock() + if !counts { + return catalogue.Manifest{}, false + } + a := c.runningManifest(node, module, "") + return a.Manifest, a.Known + } +} + +func digestOf(raw []byte) string { + sum := sha256.Sum256(raw) + return "sha256:" + hex.EncodeToString(sum[:]) +} + +func orNone(s string) string { + if s == "" { + return "(none named)" + } + return s +} + +func orWords(s, otherwise string) string { + if s == "" { + return otherwise + } + return s +} diff --git a/internal/selfcompose/running_test.go b/internal/selfcompose/running_test.go new file mode 100644 index 00000000..254f06a5 --- /dev/null +++ b/internal/selfcompose/running_test.go @@ -0,0 +1,76 @@ +package selfcompose + +import ( + "encoding/json" + "strings" + "testing" + + "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" + "github.com/novox/mesh-host/internal/compositions" +) + +// A-484: the manifest of the build a module runs here is answered in one place, from the entry of the running build, else the +// composition this node runs of it, else the module's trunk manifest; it says its source once per module and source, and where +// none answers its words name the three. +func TestTheManifestOfTheRunningBuildIsReadInOnePlace(t *testing.T) { + running := meshcatalogclient.SourcePrefix2 + strings.Repeat("1", 64) + other := meshcatalogclient.SourcePrefix2 + strings.Repeat("2", 64) + body := `{"module":"xorg","version":"1","provides":[{"name":"x11-display"}]}` + for _, tc := range []struct { + name string + entry string // the entry held, by fingerprint ("running", "other") or none + composition string // the composition this node runs: its build ("running", "other") or none + data bool + trunk bool + wantSource string + wantKnown bool + }{ + {"its entry answers first", "running", "running", false, true, SourceEntry, true}, + {"the entry of the composition's build is the running build's", "other", "other", true, true, SourceEntry, true}, + {"a composition with no manifest keeps the trunk's manifest and its data", "", "running", true, true, SourceTrunk, true}, + {"a composition and no trunk answer: its build and its data alone", "", "running", true, false, SourceComposition, false}, + {"the trunk alone", "", "", false, true, SourceTrunk, true}, + {"none answers", "", "", false, false, "", false}, + } { + t.Run(tc.name, func(t *testing.T) { + env := newFakeBus().env() + env.Node = "n1" + var said []string + env.Say = func(s string) { said = append(said, s) } + if tc.composition != "" { + fp := map[string]string{"running": running, "other": other}[tc.composition] + env.Running = func() []compositions.Composed { + return []compositions.Composed{{Node: "n1", Module: "xorg", FP: fp, Data: tc.data}} + } + } + c := New(env) + c.mu.Lock() + c.assignments["n1"] = meshmoduleassigner.Assignments{Node: "n1", Modules: []meshmoduleassigner.PlacedModule{{Module: "xorg"}}} + c.heard = map[string]map[string]heardRun{"n1": {"xorg": {fingerprint: running}}} + if tc.trunk { + var man map[string]any + _ = json.Unmarshal([]byte(body), &man) + c.trunkBuilds = map[string]trunkBuild{"xorg": {running: running, fp: other, manifest: man}} + } + c.mu.Unlock() + if tc.entry != "" { + c.holdEntry(t, "xorg", map[string]string{"running": running, "other": other}[tc.entry], body) + } + a := c.runningManifest("n1", "xorg", "") + again := c.runningManifest("n1", "xorg", "") + if a.Source != tc.wantSource || a.Known != tc.wantKnown || (a.Known && len(a.Manifest.Provides) != 1) { + t.Fatalf("answered %q (known %v, provides %d), want %q (known %v)", a.Source, a.Known, len(a.Manifest.Provides), tc.wantSource, tc.wantKnown) + } + if tc.wantSource != "" && (len(said) != 1 || again.Said != "" || !strings.Contains(said[0], tc.wantSource)) { + t.Errorf("said %q (and %q again), want its source once", said, again.Said) + } + if tc.composition != "" && a.Data != tc.data && a.Source != SourceEntry { + t.Errorf("the composition's data = %v, want %v", a.Data, tc.data) + } + if !tc.wantKnown && !strings.Contains(a.Why, SourceEntry) || !tc.wantKnown && !strings.Contains(a.Why, SourceComposition) || !tc.wantKnown && !strings.Contains(a.Why, SourceTrunk) { + t.Errorf("the words of an answer that reads no manifest are %q, want the three sources named", a.Why) + } + }) + } +} diff --git a/internal/selfcompose/selfcompose.go b/internal/selfcompose/selfcompose.go index f2f463a4..4c9a23f7 100644 --- a/internal/selfcompose/selfcompose.go +++ b/internal/selfcompose/selfcompose.go @@ -217,7 +217,9 @@ type Composer struct { trunkBuilds map[string]trunkBuild // trunkAsking is, by module, a trunk build being asked beside the pass (askTrunkBuilds), under mu. trunkAsking map[string]bool - heardRead bool + // trunkWhy is, by module, why the last ask of its trunk build gave none, for the words of the one place (A-484). + trunkWhy map[string]string + heardRead bool // ends is, by module, the last build end naming no branch the builder said of it (NoteBuildEnded), its newest build that // ended, under mu; endsRead is whether the first read of the builder's stream ended (BuildEndsRead) (design 47 G A-293). ends map[string]builds.BuildEnded @@ -1036,7 +1038,7 @@ func (c *Composer) compose(ctx context.Context) []agent.Update { var keptMu sync.Mutex var holds map[string]compose.Hold fromManifest := map[string]string{} // by module, why it is composed from the indexer's manifest and not a build - scope := frombus.Scope{Node: c.env.Node, KeptAt: kept, InOwn: inOwn, Running: running, Heard: c.heardNow(), Engine: c.noteEngine, OwnFingerprint: os.Getenv(engcomp.FingerprintVar), Kept: func(module, words string) { + scope := frombus.Scope{Node: c.env.Node, KeptAt: kept, InOwn: inOwn, Running: running, Heard: c.heardNow(), RunningManifest: c.runningFor(c.env.Node), Engine: c.noteEngine, OwnFingerprint: os.Getenv(engcomp.FingerprintVar), Kept: func(module, words string) { keptMu.Lock() defer keptMu.Unlock() if !slices.Contains(keptRuns[module], words) { @@ -1899,7 +1901,7 @@ func (c *Composer) ComposedToday(ctx context.Context, module, fp string) (string if c.env.Running != nil { running = c.env.Running() } - scope := frombus.Scope{Node: c.env.Node, KeptAt: kept, InOwn: inOwn, Running: running, Heard: c.heardNow()} + scope := frombus.Scope{Node: c.env.Node, KeptAt: kept, InOwn: inOwn, Running: running, Heard: c.heardNow(), RunningManifest: c.runningFor(c.env.Node)} comps, _, held, err := frombus.Compose(ctx, reader{c: c}, c.env.Mesh, scope, fps) if err != nil || held[module] != "" { return "", false @@ -2325,7 +2327,13 @@ func (c *Composer) WhyUnmade(module string) string { return c.last.Unmade[module] } -type trunkBuild struct{ running, fp string } +// trunkBuild is a module's trunk build as the seat mesh-catalog's verb module answered it for the running build it was asked for +// (A-461b, A-484): its fingerprint, its manifest and where it is built from. +type trunkBuild struct { + running, fp string + manifest map[string]any + repository, commit, path string +} // heardRun is one running event as the composer keeps it, with when it was said. type heardRun struct { diff --git a/internal/selfcompose/shadow.go b/internal/selfcompose/shadow.go index 8fb993c5..5a571bab 100644 --- a/internal/selfcompose/shadow.go +++ b/internal/selfcompose/shadow.go @@ -682,7 +682,7 @@ func (s *Shadow) answerProposal(ctx context.Context, proposal string) (nodeengin given[node] = &without } a := frombus.Answer(ctx, reader{c: c}, c.env.Mesh, frombus.Scope{Node: node, KeptAt: kept, Assignments: given, InOwn: inOwn, - SameValue: c.sameValue, HeldToday: s.heldToday(heldAdded)}, fps, running, proposal, rev) + SameValue: c.sameValue, HeldToday: s.heldToday(heldAdded), RunningManifest: c.runningFor(node)}, fps, running, proposal, rev) for _, module := range slices.Sorted(maps.Keys(heldAdded)) { a.Held = append(a.Held, nodeengine.CandidateRefusal{Module: module, Why: heldAdded[module]}) }