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
@@ -19,7 +19,7 @@ import (
// Issue 1965 (shanks 2026-11-05 22:27: the verb compose gave no answer in 30 s while a pass waited on the bus): an ask
// that comes while a pass runs is answered at once, says one more pass is queued and what the running one waits on, and
// the queued pass is made when the running one ends.
// the queued pass is made when the running one ends. A pass made by hand meanwhile is made after the running one too.
func composeAnsweredWhileAPassRuns(t *testing.T) {
b := newFakeBus()
ctx, cancel := context.WithCancel(context.Background())
@@ -30,7 +30,10 @@ func composeAnsweredWhileAPassRuns(t *testing.T) {
reached := make(chan struct{}, 8)
env.Running = func() []compositions.Composed {
passes.Add(1)
reached <- struct{}{}
select {
case reached <- struct{}{}:
default: // a pass reads what runs more than once: past eight reads unheard, a read is told to nobody and never waits
}
if passes.Load() == 1 {
<-hold // the first pass waits on the bus
}
@@ -72,12 +75,28 @@ func composeAnsweredWhileAPassRuns(t *testing.T) {
case <-time.After(2 * time.Second):
t.Fatal("the verb compose gave no answer while a pass ran")
}
// Issue 721 note 11: a pass made by hand while the loop's runs waits for it to end, and never begins beside it.
byHand := make(chan struct{})
go func() {
defer close(byHand)
c.compose(ctx)
}()
select {
case <-reached:
t.Error("a pass made by hand began while the loop's pass ran")
case <-time.After(50 * time.Millisecond):
}
close(hold)
select {
case <-reached: // the queued pass
case <-time.After(5 * time.Second):
t.Fatal("the queued pass was not made when the running one ended")
}
select {
case <-byHand:
case <-time.After(5 * time.Second):
t.Fatal("the pass made by hand was not made when the running one ended")
}
}
// H-A-480: the composer's watch ends with the agent's stop: once its ctx ended, Wait returns only after its loop ended,