Merge origin/main into the join: a placed module's failed build said as refused

Brings mesh-host #224 (issue 1966): newestFPs returns a placed module whose
newest build failed, composedValues writes its refused key at that fingerprint,
takeBuildDone starts the pass on a failed build. Conflict in newestFPs settled
by keeping G's by-entries branch first (design 47 G §421, §628: the node reads
neither the indexer's modules nor the builder's builds; it returns no failed),
and main's failed-build path in the other.

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 17:00:32 +01:00
3 changed files with 89 additions and 17 deletions
+32 -10
View File
@@ -28,7 +28,9 @@ import (
// build of it, so the plan exists before the want moves (build done, the node composes and writes, the provisioner
// reads, the providers provide, the assigner moves the want); a module it runs that no want names, at what runs;
// - each module's plan (catalogue.Plan) exactly when the provisioner's plans name it, from the same pass's builds;
// - a module refused alone at a fingerprint as that key with its refusal (Refused), and no resources.
// - a module refused alone at a fingerprint as that key with its refusal (Refused), and no resources; so is a module
// placed here whose newest build the builder holds failed (a build queued or running stays unpublished), at the
// indexer's fingerprint with the build's own error, so the provisioner holds it with those words and does not wait.
//
// A key is written only when its value differs from what the state holds (read once per run), and a module's key is
// deleted once its fingerprint is not among the five it wrote last (engcomp.Keep) and no want names it. A pass
@@ -84,23 +86,30 @@ func (c *Composer) publishComposed(ctx context.Context) {
// newestFPs is, of the modules placed here, the fingerprint each is composed at for the state beyond the wanted ones:
// the indexer's, where the builder holds a done build of it; else the want's; else what runs of it. A module with none
// is left out.
func (c *Composer) newestFPs(ctx context.Context, at *published) map[string]string {
// is left out. A module whose newest build the builder holds failed is also returned in failed, by module, with the
// indexer's fingerprint and the build's error: it is published as a refusal, not composed.
func (c *Composer) newestFPs(ctx context.Context, at *published) (out map[string]string, failed map[string][2]string) {
if c.byEntries() {
// The newest build is the indexer's (and the builder's done key says it is built): neither is read, and the node
// follows no branch (design 47 G §421, §628), so the state holds the wanted builds alone.
return maps.Clone(at.fps)
return maps.Clone(at.fps), nil
}
out := map[string]string{}
out = map[string]string{}
failed = map[string][2]string{}
r := reader{c: c}
for _, module := range at.placed {
c.mu.Lock()
fp2 := c.modules[module].Fp2
c.mu.Unlock()
if fp2 != "" {
if b, err := r.Build(ctx, module, fp2); err == nil && b != nil && b.State == builds.BuildDone {
out[module] = fp2
continue
if b, err := r.Build(ctx, module, fp2); err == nil && b != nil {
switch b.State {
case builds.BuildDone:
out[module] = fp2
continue
case builds.BuildFailed:
failed[module] = [2]string{fp2, b.Error}
}
}
}
if fp, ok := at.fps[module]; ok {
@@ -109,7 +118,7 @@ func (c *Composer) newestFPs(ctx context.Context, at *published) map[string]stri
out[module] = fp
}
}
return out
return out, failed
}
// writeComposed works out the state's keys from at and writes those that differ, then deletes what is past keeping.
@@ -183,7 +192,7 @@ func (c *Composer) composedValues(ctx context.Context, at *published) (map[strin
held map[string]string
}{{at.scope, at.fps, at.comps, at.held}}
// The newest builds, composed only where they differ from the wanted ones.
newest := c.newestFPs(ctx, at)
newest, failed := c.newestFPs(ctx, at)
if !maps.Equal(newest, at.fps) {
scope := at.scope
scope.KeptAt = map[string]string{}
@@ -246,6 +255,19 @@ func (c *Composer) composedValues(ctx context.Context, at *published) (map[strin
}
}
}
// A placed module whose newest build failed is refused alone at that build, with the build's words, unless a
// composition of it at that fingerprint is already written above.
for module, f := range failed {
comp := engcomp.Composed{Node: c.env.Node, Module: module, FP: f[0], Refused: f[1]}
if key, err := composedKeyOf(comp); err != nil {
return nil, err
} else if _, written := out[key]; written {
continue
}
if err := put(comp, nil); err != nil {
return nil, err
}
}
return out, nil
}