From 91dc064f92095916d2054a97b60eb19666002fa0 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 18 Nov 2026 00:49:53 +0100 Subject: [PATCH] selfcompose: the running statement's manifest is the second source of the one place; a composition answers only whether the build keeps data (A-484a) Builds: design 47 G A-484a, A-484 --- internal/selfcompose/entries.go | 2 +- internal/selfcompose/entries_test.go | 4 ++-- internal/selfcompose/running.go | 29 ++++++++++++++++++++++------ internal/selfcompose/running_test.go | 23 ++++++++++++++-------- 4 files changed, 41 insertions(+), 17 deletions(-) diff --git a/internal/selfcompose/entries.go b/internal/selfcompose/entries.go index 99f878a1..6bb471a9 100644 --- a/internal/selfcompose/entries.go +++ b/internal/selfcompose/entries.go @@ -416,7 +416,7 @@ func (c *Composer) layModules() { switch { case !a.Known: return false - case a.Source == SourceTrunk: + case a.Source == SourceTrunk || a.Source == SourceStatement: 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 diff --git a/internal/selfcompose/entries_test.go b/internal/selfcompose/entries_test.go index 64fae4ba..3fa58a39 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: no source of the one place (A-484)", true, "", false, true, old, false, true, "", "held"}, + {"its running event names a manifest this node holds (A-484a)", 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", ""}, @@ -444,7 +444,7 @@ func TestRunningBuildEntryKeptAndHandedAgain(t *testing.T) { 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)): + case !trunk && (err == nil || !strings.Contains(err.Error(), SourceEntry) || !strings.Contains(err.Error(), SourceStatement) || !strings.Contains(err.Error(), SourceTrunk)): t.Errorf("no source answers, FormChanges says %v, want the three named", err) } } diff --git a/internal/selfcompose/running.go b/internal/selfcompose/running.go index 294f3371..f703c233 100644 --- a/internal/selfcompose/running.go +++ b/internal/selfcompose/running.go @@ -15,12 +15,14 @@ import ( // 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`. +// order: the entry of the running build; else the manifest its running statement names, when held (A-484a); else the module's trunk manifest +// through the seat mesh-catalog's verb `module`. The composition answers no manifest, only whether the build keeps data (A-483). // The three sources of the one place, in the words it says them in. const ( - SourceEntry = "the entry of the running build" + SourceEntry = "the entry of the running build" + SourceStatement = "the manifest its running statement names" + // SourceComposition answers no manifest: only the build and whether it keeps data on the bus (A-484a). SourceComposition = "the composition this node runs of it" SourceTrunk = "the module's trunk manifest in the catalog" ) @@ -100,9 +102,20 @@ func (c *Composer) runningLocked(running []engcomp.Composed, node, module, hint } } } + // 2. The manifest its running statement (the running event) names, when this node holds it (A-484a). + statementWhy := "its running event names no manifest" + if r, ok := c.heard[node][module]; ok && !r.stopped && a.Source == "" && r.manifest != "" { + if raw, held := c.manifests[r.manifest]; held { + if man, err := catalogue.Decode(raw); err == nil { + a = runningAnswer{Source: SourceStatement, FP: r.fingerprint, Known: true, Manifest: man, Raw: raw, Digest: r.manifest} + } + } else { + statementWhy = "this node holds no manifest " + r.manifest + } + } 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. + // The composition this node runs of that build, whatever the want's build: it answers whether the build keeps data (A-483, A-484a). if node == c.env.Node { for _, r := range running { if r.Module != module || r.FP == "" { @@ -141,8 +154,12 @@ func (c *Composer) runningLocked(running []engcomp.Composed, node, module, hint } 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) + SourceEntry, orWords(entryWhy, "its entry is held without a manifest"), SourceStatement, statementWhy, SourceTrunk, trunkWhy) + if a.Source == SourceComposition { + a.Why += fmt.Sprintf("; its composition names the build %s and says whether it keeps data: %v", a.FP, a.Data) + } else if compWhy != "" { + a.Why += "; " + compWhy + } } if a.Source != "" { line := fmt.Sprintf("%s runs a build whose manifest is read from %s", module, a.Source) diff --git a/internal/selfcompose/running_test.go b/internal/selfcompose/running_test.go index 254f06a5..2eabb1f9 100644 --- a/internal/selfcompose/running_test.go +++ b/internal/selfcompose/running_test.go @@ -23,15 +23,17 @@ func TestTheManifestOfTheRunningBuildIsReadInOnePlace(t *testing.T) { composition string // the composition this node runs: its build ("running", "other") or none data bool trunk bool + statement bool // the running event names a manifest this node holds (A-484a) 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}, + {"its entry answers first", "running", "running", false, true, false, SourceEntry, true}, + {"the entry of the composition's build is the running build's", "other", "other", true, true, false, SourceEntry, true}, + {"a composition with no manifest keeps the trunk's manifest and its data", "", "running", true, true, false, SourceTrunk, true}, + {"a composition and no trunk answer: its build and its data alone", "", "running", true, false, false, SourceComposition, false}, + {"the trunk alone", "", "", false, true, false, SourceTrunk, true}, + {"its running statement's manifest comes before the trunk's", "", "running", true, true, true, SourceStatement, true}, + {"none answers", "", "", false, false, false, "", false}, } { t.Run(tc.name, func(t *testing.T) { env := newFakeBus().env() @@ -48,6 +50,11 @@ func TestTheManifestOfTheRunningBuildIsReadInOnePlace(t *testing.T) { 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.statement { + digest := "sha256:" + strings.Repeat("9", 64) + c.heard["n1"]["xorg"] = heardRun{fingerprint: running, manifest: digest} + c.manifests[digest] = []byte(body) + } if tc.trunk { var man map[string]any _ = json.Unmarshal([]byte(body), &man) @@ -65,10 +72,10 @@ func TestTheManifestOfTheRunningBuildIsReadInOnePlace(t *testing.T) { 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 { + if tc.composition != "" && a.Data != tc.data && a.Source != SourceEntry && a.Source != SourceStatement { 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) { + if !tc.wantKnown && !strings.Contains(a.Why, SourceEntry) || !tc.wantKnown && !strings.Contains(a.Why, SourceStatement) || !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) } })