Compare commits

...
Author SHA1 Message Date
jschoubben 0d97c09c49 Fold the retake test into the prefix test (issue 1748 review 1)
mesh/check pass 0d97c09c49b4 on 5a38a1221659 | unit 6409 run, 187 kept, 14 skipped | integration 6544 run, 220 kept, 23 skipped | over bound: unit, in…
mesh/delivery-group group fix/1748-retake-and-resolver ready: every member ready, and composed together they pass
mesh/delivery closed: the pull request closed unmerged
Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
2026-11-04 22:41:49 +01:00
jschoubben 9c4b2c5e56 A build's log entry says how many times its key was retaken (issue 1748)
Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
2026-11-04 22:27:52 +01:00
jschoubben 0261881feb Add the retake class beside FailedUntilChanged and the retake count on a build key (issue 1748)
A network failure passes by itself; the build contract names it so every build module is held to it and the builder acts on it.

Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
2026-11-04 22:27:00 +01:00
3 changed files with 45 additions and 0 deletions
+15
View File
@@ -150,6 +150,11 @@ const (
// WaitsFor: a fetch found the module's lock naming a package version the registry does not hold yet; the builder
// writes the key queued with Waits (novox/hq ADR 0500 clause 6), and it is built once the package is published.
WaitsFor = "waits for: "
// Retake: a failure that passes by itself (a name lookup that timed out, a refused connection): the builder takes
// the key again after a backoff, at most MaxRetakes times (issue 1748). A build module opens every such failure with it.
Retake = "retakeable: "
// MaxRetakes is how many times the builder takes a key again by itself for a retakeable failure.
MaxRetakes = 3
)
// FailedUntilChanged says whether a failed key's error is one that is not built again until the module's fingerprint
@@ -159,6 +164,12 @@ func FailedUntilChanged(err string) bool {
return strings.HasPrefix(err, NotPinned) || strings.HasPrefix(err, VersionTaken) || strings.HasPrefix(err, RefusedKind)
}
// Retakeable says whether a failed key's error opens with Retake: the builder takes it again by itself after a backoff,
// until BuilderBuild.Retakes reaches MaxRetakes. An error that is FailedUntilChanged, or opens with no prefix, is not.
func Retakeable(err string) bool {
return strings.HasPrefix(err, Retake) && !FailedUntilChanged(err)
}
// ToolchainUsed is what a build used for one language (ADR 0405 clauses 2 and 7): the installed toolchain's version and
// the build module's recipe version.
type ToolchainUsed struct {
@@ -180,6 +191,10 @@ type BuilderBuild struct {
Artifacts []BuiltArtifact `json:"artifacts,omitempty"`
Toolchains map[string]ToolchainUsed `json:"toolchains,omitempty"`
Error string `json:"error,omitempty"`
// Retakes is how many times the builder took this key again by itself after a retakeable failure (Retake); it is kept
// on the key, so a builder that starts again reads it and the count survives a restart (issue 1748). A reader that
// does not know the field reads 0.
Retakes int `json:"retakes,omitempty"`
// Waits is, on a queued key only, the package version `<name>@<version>` the module's lock names and the registry
// does not yet hold: the key is not claimed until that package's trunk key is done and published (novox/hq ADR 0500
// clause 6). A reader that does not know the field reads the key as queued.
+27
View File
@@ -86,11 +86,38 @@ func TestOnlyAPushFailureIsBuiltAgainBeforeTheFingerprintChanges(t *testing.T) {
{VersionTaken + "@novox/mesh-sdk@0.1.15 holds another file", false},
{RefusedKind + "a package in go", false},
{"go test: 2 failed", true},
{Retake + "lookup git.novox.be: i/o timeout", true},
} {
if got := FailedUntilChanged(c.err); got == c.again {
t.Errorf("FailedUntilChanged(%q) = %v", c.err, got)
}
}
// A retakeable error opens with Retake and is not one that waits for the fingerprint; the count is on the key's value (issue 1748).
for _, c := range []struct {
err string
want bool
}{
{Retake + "lookup git.novox.be: i/o timeout", true},
{NotPinned + "x", false},
{Retake[:4] + " not the prefix", false},
{"go test: 2 failed", false},
{"", false},
{VersionTaken + Retake, false},
} {
if got := Retakeable(c.err); got != c.want {
t.Errorf("Retakeable(%q) = %v", c.err, got)
}
}
data, err := EncodeBuilderBuild(BuilderBuild{State: BuildFailed, Error: Retake + "x", Retakes: 2})
if err != nil {
t.Fatal(err)
}
if back, err := DecodeBuilderBuild(data); err != nil || back.Retakes != 2 {
t.Fatalf("decoded %+v, %v", back, err)
}
if Retake != "retakeable: " || MaxRetakes != 3 {
t.Fatal("the retake prefix or its bound changed")
}
if NotStored != "not stored: " || NotPinned != "not pinned: " || VersionTaken != "version taken: " || RefusedKind != "refused kind: " {
t.Fatal("a prefix changed its words")
}
+3
View File
@@ -175,6 +175,9 @@ type BuildLogEntry struct {
// sorted and each once, as the build module answered them (BuildAnswer.Imports; novox/hq ADR 0593 §2): the indexer
// keeps them on the module (KeptInputs2.Imports) when the build's fingerprint is the module's.
Imports []string `json:"imports,omitempty"`
// Retakes is, at a build's end, how many times the builder took the key again by itself after a retakeable failure
// (BuilderBuild.Retakes; issue 1748): builder_builds_since reads it.
Retakes int `json:"retakes,omitempty"`
}
// BuildsSince is the answer of BuildsSinceTool: every ended build since a time, oldest first, and whether the log held