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:
@@ -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
|
// 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
|
// 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) {
|
func composeAnsweredWhileAPassRuns(t *testing.T) {
|
||||||
b := newFakeBus()
|
b := newFakeBus()
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
@@ -30,7 +30,10 @@ func composeAnsweredWhileAPassRuns(t *testing.T) {
|
|||||||
reached := make(chan struct{}, 8)
|
reached := make(chan struct{}, 8)
|
||||||
env.Running = func() []compositions.Composed {
|
env.Running = func() []compositions.Composed {
|
||||||
passes.Add(1)
|
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 {
|
if passes.Load() == 1 {
|
||||||
<-hold // the first pass waits on the bus
|
<-hold // the first pass waits on the bus
|
||||||
}
|
}
|
||||||
@@ -72,12 +75,28 @@ func composeAnsweredWhileAPassRuns(t *testing.T) {
|
|||||||
case <-time.After(2 * time.Second):
|
case <-time.After(2 * time.Second):
|
||||||
t.Fatal("the verb compose gave no answer while a pass ran")
|
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)
|
close(hold)
|
||||||
select {
|
select {
|
||||||
case <-reached: // the queued pass
|
case <-reached: // the queued pass
|
||||||
case <-time.After(5 * time.Second):
|
case <-time.After(5 * time.Second):
|
||||||
t.Fatal("the queued pass was not made when the running one ended")
|
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,
|
// H-A-480: the composer's watch ends with the agent's stop: once its ctx ended, Wait returns only after its loop ended,
|
||||||
|
|||||||
@@ -309,6 +309,10 @@ type Composer struct {
|
|||||||
asked chan chan Pass
|
asked chan chan Pass
|
||||||
// passing is set while a pass is made.
|
// passing is set while a pass is made.
|
||||||
passing atomic.Bool
|
passing atomic.Bool
|
||||||
|
// passMu is held for the whole of a pass (compose, composeEarly): a second pass over this composer's state waits for
|
||||||
|
// the one running to end, never runs beside it (issue 721 note 11: a pass beside the loop's handed again what the
|
||||||
|
// other had taken back).
|
||||||
|
passMu sync.Mutex
|
||||||
// early is true while the early pass of a start runs (design 47 G §683, A-117).
|
// early is true while the early pass of a start runs (design 47 G §683, A-117).
|
||||||
early atomic.Bool
|
early atomic.Bool
|
||||||
// assignmentsRead is set once the watch of the seat's assignments has caught up: from then the placements this composer holds
|
// assignmentsRead is set once the watch of the seat's assignments has caught up: from then the placements this composer holds
|
||||||
@@ -1089,8 +1093,16 @@ func (c *Composer) takeValue(u agent.Update) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// compose composes the node once and answers the updates to hand: each composition whose digest differs from the one
|
// compose composes the node once and answers the updates to hand: each composition whose digest differs from the one
|
||||||
// handed, and a deletion for each handed one no want names any more.
|
// handed, and a deletion for each handed one no want names any more. It holds passMu for the whole pass, so a pass asked
|
||||||
|
// while another runs is made after it.
|
||||||
func (c *Composer) compose(ctx context.Context) []agent.Update {
|
func (c *Composer) compose(ctx context.Context) []agent.Update {
|
||||||
|
c.passMu.Lock()
|
||||||
|
defer c.passMu.Unlock()
|
||||||
|
return c.composePass(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// composePass is compose's pass, made with passMu held.
|
||||||
|
func (c *Composer) composePass(ctx context.Context) []agent.Update {
|
||||||
early := c.early.Load()
|
early := c.early.Load()
|
||||||
pass := Pass{}
|
pass := Pass{}
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -2645,8 +2657,11 @@ func (c *Composer) standing() bool {
|
|||||||
|
|
||||||
// composeEarly is the pass of a start before the assignments, haves and resolved values are read: it composes only the modules whose
|
// composeEarly is the pass of a start before the assignments, haves and resolved values are read: it composes only the modules whose
|
||||||
// kept want and kept entry it holds, a kept want standing for their placement, and leaves every other module as it runs; the full
|
// kept want and kept entry it holds, a kept want standing for their placement, and leaves every other module as it runs; the full
|
||||||
// pass follows once the inputs are read (design 47 G §683, A-95, A-117).
|
// pass follows once the inputs are read (design 47 G §683, A-95, A-117). The placement it stands in for the assignments, and
|
||||||
|
// its taking back, are within the pass: passMu is held for all of it.
|
||||||
func (c *Composer) composeEarly(ctx context.Context) []agent.Update {
|
func (c *Composer) composeEarly(ctx context.Context) []agent.Update {
|
||||||
|
c.passMu.Lock()
|
||||||
|
defer c.passMu.Unlock()
|
||||||
node := c.env.Node
|
node := c.env.Node
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
_, hadRecord := c.records[node]
|
_, hadRecord := c.records[node]
|
||||||
@@ -2684,5 +2699,5 @@ func (c *Composer) composeEarly(ctx context.Context) []agent.Update {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
c.env.Say("the node composes the modules it kept a want and an entry of, before its other inputs are read")
|
c.env.Say("the node composes the modules it kept a want and an entry of, before its other inputs are read")
|
||||||
return c.compose(ctx)
|
return c.composePass(ctx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
// 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
|
// 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.
|
// 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
|
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}} {
|
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)
|
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()
|
sc.mu.Lock()
|
||||||
placed := c.assignments["n1"]
|
placed := sc.assignments["n1"]
|
||||||
placed.Modules = append(slices.Clone(placed.Modules), meshmoduleassigner.PlacedModule{Module: "tool"})
|
placed.Modules = append(slices.Clone(placed.Modules), meshmoduleassigner.PlacedModule{Module: "tool"})
|
||||||
c.assignments["n1"] = placed
|
sc.assignments["n1"] = placed
|
||||||
c.mu.Unlock()
|
sc.mu.Unlock()
|
||||||
said := func(sub string) (n int) {
|
said := func(sub string) (n int) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
@@ -414,27 +418,18 @@ func testTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
c.compose(ctx)
|
sc.compose(ctx)
|
||||||
saidOfNofp := said("the node composes nothing of nofp")
|
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) ||
|
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"] != "" {
|
!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)
|
t.Errorf("the pass says it composed nothing of %q", why)
|
||||||
}
|
}
|
||||||
readGhost()
|
readGhost()
|
||||||
c.compose(ctx)
|
sc.compose(ctx)
|
||||||
if n := said("the node composes nothing of nofp"); n != saidOfNofp || n == 0 {
|
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)
|
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.
|
// The agent waits for what the node believes it handed: handed again; for what it never handed, nothing is.
|
||||||
c.Waiting("ghost", fp)
|
c.Waiting("ghost", fp)
|
||||||
select {
|
select {
|
||||||
|
|||||||
Reference in New Issue
Block a user