selfcompose: one pass at a time; the hand passes of the 1966 step run on a copy

TestSelfcompose/TheNodeComposesItsWantsFromTheBus failed pipelines main.266,
main.459 and main.479: its issue 1966 step composed by hand beside the
composer's running loop, and a loop pass woken by an entry's answer composed
tool too and handed it on out, so a later quiet or wait saw n1.tool.

The kind is two passes over one composer's state at once. compose and
composeEarly now hold one lock (passMu) for the whole pass, so a pass asked
while another runs is made after it. The lock alone does not take the
order away (the loop's woken pass may still come before the test's), so the
step's passes run on a copy of what the composer holds (scratch), which runs
no loop; the take-back pass at its end is no longer needed and goes.

The test of an ask while a pass runs also makes a pass by hand there: it
does not begin until the running one ended (fails without the lock). Its
read of what runs no longer blocks once eight reads are unheard (a pass
reads it more than once, and the extra pass filled the channel).

Issue 721 note 11 (a blocking fault for its live proof).
This commit is contained in:
2026-11-23 15:30:46 +01:00
parent 90f80565f4
commit fd7f049e2e
3 changed files with 52 additions and 23 deletions
+13 -18
View File
@@ -393,17 +393,21 @@ func testTheNodeComposesItsWantsFromTheBus(t *testing.T) {
// Issue 1966 (novox, 2026-11-09): every pass names each wanted module it composed nothing of, or composed from the indexer's
// manifest for want of a done build, with why, and a want it did not take; said once; the agent's word that it waits
// hands a composition the node believes handed again.
// The passes of this step are made by hand on a copy of what c holds, which runs no loop (issue 721 note 11): beside c's
// loop, a pass it makes when an entry is answered composed tool too, and handed it on out (pipelines main.266, main.459, main.479).
sc := c.scratch()
sc.env.Running = nil // composed counts c's passes alone
tfp := toolFp
c.holdEntry(t, "tool", tfp, toolBody)
sc.holdEntry(t, "tool", tfp, toolBody)
for module, w := range map[string]meshwants.WantsByWantNodeModuleValue{"tool": {Fp: tfp, Self: true}, "ghost": {Fp: ghostFp, Self: true}, "nofp": {Self: true}} {
raw, _ := bucketstest.Want(w)
c.takeWant(agent.Update{Key: "want.n1." + module, Value: raw})
sc.takeWant(agent.Update{Key: "want.n1." + module, Value: raw})
}
c.mu.Lock()
placed := c.assignments["n1"]
sc.mu.Lock()
placed := sc.assignments["n1"]
placed.Modules = append(slices.Clone(placed.Modules), meshmoduleassigner.PlacedModule{Module: "tool"})
c.assignments["n1"] = placed
c.mu.Unlock()
sc.assignments["n1"] = placed
sc.mu.Unlock()
said := func(sub string) (n int) {
b.mu.Lock()
defer b.mu.Unlock()
@@ -414,27 +418,18 @@ func testTheNodeComposesItsWantsFromTheBus(t *testing.T) {
}
return n
}
c.compose(ctx)
sc.compose(ctx)
saidOfNofp := said("the node composes nothing of nofp")
why := map[string]string{"tool": c.LastHeld()["tool"], "ghost": c.LastHeld()["ghost"], "nofp": c.WhyUnmade("nofp"), "lemurs": c.WhyUnmade("lemurs")}
why := map[string]string{"tool": sc.LastHeld()["tool"], "ghost": sc.LastHeld()["ghost"], "nofp": sc.WhyUnmade("nofp"), "lemurs": sc.WhyUnmade("lemurs")}
if !strings.Contains(why["tool"], "tool at "+tfp) || !strings.Contains(why["ghost"], "entry-asked: the entry of the build "+ghostFp) ||
!strings.Contains(why["nofp"], "want not taken: its want names no fingerprint") || why["lemurs"] != "" {
t.Errorf("the pass says it composed nothing of %q", why)
}
readGhost()
c.compose(ctx)
sc.compose(ctx)
if n := said("the node composes nothing of nofp"); n != saidOfNofp || n == 0 {
t.Errorf("the journal says why nofp is not composed %d times after the second pass, %d after the first: want the same, not none", n, saidOfNofp)
}
// The state of this step is taken away again, and the pass that takes back what it handed is made here.
for _, module := range []string{"tool", "ghost", "nofp"} {
c.takeWant(agent.Update{Key: "want.n1." + module, Deleted: true})
}
c.mu.Lock()
placed.Modules = placed.Modules[:len(placed.Modules)-1]
c.assignments["n1"] = placed
c.mu.Unlock()
c.compose(ctx)
// The agent waits for what the node believes it handed: handed again; for what it never handed, nothing is.
c.Waiting("ghost", fp)
select {