From d1768241dc5a53dbbca328fbd3474a78880f87c2 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 18 Nov 2026 00:23:46 +0100 Subject: [PATCH] selfcompose: a running build with no entry keeps what its running composition keeps; with no data on either side the move goes on (A-483) Builds: design 47 G A-483 --- internal/selfcompose/entries.go | 14 ++++++++++ internal/selfcompose/entries_test.go | 39 ++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/internal/selfcompose/entries.go b/internal/selfcompose/entries.go index ca6abd86..74d01903 100644 --- a/internal/selfcompose/entries.go +++ b/internal/selfcompose/entries.go @@ -825,6 +825,20 @@ func (c *Composer) FormChanges(_ context.Context, module, runningFp, appliedFp s } 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). + 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 + } + } + } return nil, fmt.Errorf("%s's running manifest: %w", module, err) } applied, err := read(appliedFp) diff --git a/internal/selfcompose/entries_test.go b/internal/selfcompose/entries_test.go index 5650de53..beafd92b 100644 --- a/internal/selfcompose/entries_test.go +++ b/internal/selfcompose/entries_test.go @@ -387,6 +387,45 @@ func TestRunningBuildEntryKeptAndHandedAgain(t *testing.T) { t.Error("an entry of the running build was answered, and the composition was not handed again") } + // A-483: a running build with no entry is read from the composition it runs here: where neither it nor the wanted build's manifest + // keeps data on the bus no form can change and the move goes on; where either does, or no composition is run, it still waits. + for _, tc := range []struct { + name string + runs, data bool // a composition of the module runs here, keeping data + wantedData bool + wantedHeld bool + moves bool + }{ + {"no entry of the running build, its composition and the wanted build keep no data", true, false, false, true, true}, + {"no entry, its composition keeps data", true, true, false, true, false}, + {"no entry, the wanted build keeps data", true, false, true, true, false}, + {"no entry, no composition of it runs here", false, false, false, true, false}, + {"no entry, the wanted build's entry is not held either", true, false, false, false, false}, + } { + t.Run(tc.name, func(t *testing.T) { + env := newFakeBus().env() + env.Node = "n1" + env.Running = func() []compositions.Composed { + if !tc.runs { + return nil + } + return []compositions.Composed{{Node: "n1", Module: "feh", FP: old, Data: tc.data}} + } + c := New(env) + if tc.wantedHeld { + body := `{"module":"feh","version":"2"}` + if tc.wantedData { + body = `{"module":"feh","version":"2","data":{"own":[{"id":"state","kind":"state"}]}}` + } + c.holdEntry(t, "feh", next, body) + } + changes, err := c.FormChanges(context.Background(), "feh", old, next) + if (err == nil) != tc.moves || len(changes) != 0 { + t.Errorf("FormChanges = %v, %v; the move goes on: %v", changes, err, tc.moves) + } + }) + } + // 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.