selfcompose: a refused catalog-revision subscription is said once and tried again, never refuses Watch

The subscription is a wake-up; the backoff bounds the asks without it. The refusal is said with its subject and error
(principle 3), the composer goes on, and the subscription is tried again on laterAgain's steps until it holds.

Builds: design 47 G-22 A-487a, principle 3
This commit is contained in:
2026-11-19 00:59:17 +01:00
parent 6ac8952541
commit 2057c9d304
2 changed files with 101 additions and 22 deletions
+40 -22
View File
@@ -547,29 +547,12 @@ func (c *Composer) Watch(ctx context.Context, _ string) (<-chan agent.Update, er
}(i, ch)
}
if c.env.Hear != nil {
revisions, stopRevisions, err := c.env.Hear(CatalogRevisionEvents)
if err != nil {
return nil, fmt.Errorf("the node asks the trunk builds again when the catalog says a revision, and cannot hear it: %w", err)
}
go func() {
defer stopRevisions()
for {
select {
case <-ctx.Done():
return
case _, ok := <-revisions:
if !ok {
return
}
c.trunkRetryCleared()
select {
case merged <- tagged{in: -1, ok: true}:
case <-ctx.Done():
return
}
}
go c.hearCatalogRevisions(ctx, func() {
select {
case merged <- tagged{in: -1, ok: true}:
case <-ctx.Done():
}
}()
})
heard, stop, err := c.env.Hear(VaultSecretChanged)
if err != nil {
return nil, fmt.Errorf("the node composes again when a secret changes, and cannot hear the vault say so: %w", err)
@@ -727,6 +710,41 @@ func (c *Composer) Watch(ctx context.Context, _ string) (<-chan agent.Update, er
return out, nil
}
// hearCatalogRevisions hears the seat mesh-catalog's event catalog-revision: each one clears the backoffs of the trunk builds the
// catalog gave none of and wakes a pass (A-487a). A wake-up only, the backoff bounds the asks without it: a subscription refused
// is said once with its subject and error (principle 3), the composer goes on composing, and the subscription is tried again on
// laterAgain's steps until it holds.
func (c *Composer) hearCatalogRevisions(ctx context.Context, wake func()) {
said := false
for try := 0; ; try++ {
revisions, stop, err := c.env.Hear(CatalogRevisionEvents)
if err == nil {
defer stop()
for {
select {
case <-ctx.Done():
return
case _, ok := <-revisions:
if !ok {
return
}
c.trunkRetryCleared()
wake()
}
}
}
if !said {
said = true
c.env.Say(fmt.Sprintf("the node cannot hear %s: %v; it asks the trunk builds again on a backoff alone and tries to hear it again", CatalogRevisionEvents, err))
}
select {
case <-ctx.Done():
return
case <-time.After(LaterWait(try)):
}
}
}
func all(b []bool) bool {
for _, v := range b {
if !v {