B5 read-before-the-ask: the registries' record at V is written on the reservation before a build module is asked again; a first not stored starts the build again once

Builds: design 47 H2 H-A-588 (3) (4), H-A-662, H-A-664, H-A-666, H-A-703
This commit is contained in:
2026-11-25 17:14:05 +01:00
parent 13c9fb430e
commit b7dc1dc3e1
9 changed files with 138 additions and 6 deletions
@@ -264,6 +264,10 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
return republish.HeldRecords(ctx, module, fp, refs, registryVersionsVia(calls.Call))
}
reserved.r.MovedFrom = reserved.movedFrom
republish.Unstored = reserved.unstoredAgain
reserved.judge = func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error) {
return republish.Held(ctx, v, registryVersionsVia(calls.Call))
}
// A done build whose number a registry holds elsewhere is built again at the next free number (H-A-279), on the builder's context.
reserved.rebuild = func(_ context.Context, module, fp, why string) error {
res := b.BuildAgain(ctx, module, fp, why, "the builder", buildAgainBound)
@@ -58,6 +58,8 @@ type reservations struct {
recordAgain func(ctx context.Context, module, fp, when string) (string, error)
// rebuild builds a done key of module at fp again (the build-again path, A-490; H-A-279); nil builds none.
rebuild func(ctx context.Context, module, fp, why string) error
// judge reads the registries' record of a reservation's artifacts at its version (the republisher's Held); nil reads none.
judge func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error)
// say says package-published on the seat mesh-builds; nil says none.
say func(context.Context, meshbuilds.PackagePublished) error
// names is each package's name as its series key names it (for Go, its module path), and sayReserved says version-reserved on
@@ -568,6 +570,36 @@ func (rv *reservations) ReleasedFor(ctx context.Context, module, fingerprint str
return rv.r.ReleasedFor(ctx, module, fingerprint)
}
// MarkRegistryHeld reads the registries' record of v's artifacts and writes the held digest of each artifact a registry holds at v's version
// for the build's fingerprint on the reservation, marked published, and says package-published of each once (design 47 H2 H-A-588
// (4)); what the registries do not hold loses its recorded digest (H-A-664). A read that does not answer is said and nothing is
// written, so the build goes on.
func (rv *reservations) MarkRegistryHeld(ctx context.Context, v versions.ReservedVersion) {
if rv.judge == nil {
return
}
j, err := rv.judge(ctx, v)
if err != nil {
rv.logf("%s %s: the registries' record of its artifacts is not read before the build module is asked again, so none is marked held: %v", v.Module, v.Version, err)
return
}
marked, _, err := rv.r.MarkHeld(ctx, v.Module, v.Version, j.Held)
if err != nil {
rv.logf("%s %s: what the registries hold is not written on the reservation: %v", v.Module, v.Version, err)
return
}
for _, m := range marked {
var held versions.HeldArtifact
for _, h := range j.Held {
if h.Ref == m.Artifact {
held = h
}
}
rv.logf("%s %s: %s holds %s %s at %s for this build: marked published from its record before the build is asked again", v.Module, v.Version, held.Seat, held.Name, held.Version, held.Digest)
rv.sayPublished(ctx, m, held.Digest)
}
}
// markHeld marks the artifacts the registries' record holds at their version with the built digest published, as their published
// heard would, and says package-published of each (design 47 H H-A-274): a published heard and lost never leaves the publish
// asked for ever. The version's release follows from the catalog as for any published.
@@ -627,6 +659,19 @@ func elsewhereWords(v versions.ReservedVersion, elsewhere []versions.HeldArtifac
return fmt.Sprintf("%s is withdrawn and the build of %s is built again at the next free number: %s", v.Version, v.Fingerprint, strings.Join(at, "; "))
}
// unstoredAgain builds a key again whose reservation's first artifact a holder refused as not stored (design 47 H2 H-A-662): the
// build under its standing version completes what the registries lack, as the person's builder_build_again would. A key the
// build again refuses (not a first branch's trunk build, or released) is said and left to the person's tool.
func (rv *reservations) unstoredAgain(ctx context.Context, v versions.ReservedVersion, ref, words string) {
if rv.rebuild == nil {
return
}
why := fmt.Sprintf("%s refused by its holder as not stored (%s): the build of %s is built again under %s", ref, words, v.Fingerprint, v.Version)
if err := rv.rebuild(ctx, v.Module, v.Fingerprint, why); err != nil {
rv.logf("%s %s: the build again is not started: %v; builder_build_again builds it", v.Module, v.Version, err)
}
}
// movedFrom is told by the reserver a standing number it withdrew at a build again (design 47 H2 H-A-590 (1)): the finding is raised;
// the reserve itself takes the next number no registry holds.
func (rv *reservations) movedFrom(ctx context.Context, v versions.ReservedVersion, elsewhere []versions.HeldArtifact) {