WM13 (builder half): a key queued behind a package says wait-held and wait-ended in the one wait form

The builder says wait-held for a key queued behind a package, the package as its part and on (package:<ref>), on its
stream waits, and wait-ended published once the key is claimed; a toolchain wait never ends by that, and a package wait
never by a toolchain's end. Files: internal/build/waits.go (Package, On, WaitPublished), internal/build/run.go (Hold at
the queued result, End at the claim), cmd/mesh-delivery-builder/waits.go (Part in the body, the End rule).

Builds: design 47 G A-192, §499

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 05:52:10 +01:00
parent 62de8d0bb8
commit 524fbb02ef
6 changed files with 72 additions and 8 deletions
@@ -18,8 +18,10 @@ import (
// waitBody is the body of wait-held and wait-ended on the builder's stream waits (design 47 G §672): the fields of §629's
// wait with `step` building, `on` toolchain:<language>@<version>, `module` and `fingerprint`, and, on wait-ended, `how`.
type waitBody struct {
Step string `json:"step"`
On string `json:"on"`
Step string `json:"step"`
On string `json:"on"`
// Part is the package a key queued behind it waits for (design 47 G A-192); none for a toolchain wait.
Part string `json:"part,omitempty"`
Module string `json:"module"`
Fingerprint string `json:"fingerprint"`
Since time.Time `json:"since"`
@@ -46,7 +48,7 @@ func newWaitsKept(kv *process.AwaitedBucket, say func(context.Context, string, s
}
func (w *waitsKept) body(t build.ToolchainWait, how string) waitBody {
return waitBody{Step: waitStepBuilding, On: t.On(), Module: t.Module, Fingerprint: t.Fingerprint, Since: t.Since, Bound: w.bound.String(), How: how}
return waitBody{Step: waitStepBuilding, On: t.On(), Part: t.Package, Module: t.Module, Fingerprint: t.Fingerprint, Since: t.Since, Bound: w.bound.String(), How: how}
}
// start reads the state whole and says wait-held again for each key.
@@ -110,7 +112,13 @@ func (w *waitsKept) End(ctx context.Context, module, fp, how string) bool {
}
w.mu.Lock()
t, had := w.held[key]
delete(w.held, key)
// A key queued behind a package ends only when it is published, and a toolchain wait never by that (design 47 G A-192).
if had && (t.Package != "") != (how == build.WaitPublished) {
had = false
}
if had {
delete(w.held, key)
}
w.mu.Unlock()
if !had {
return false
@@ -0,0 +1,21 @@
package main
import (
"testing"
"time"
"mesh-delivery-builder/internal/build"
)
// Design 47 G A-192: a key queued behind a package says its wait in the one wait form, the package as its `part` and `on`; a toolchain
// wait names none.
func TestAWaitBodyNamesItsPart(t *testing.T) {
w := &waitsKept{bound: time.Hour, held: map[string]build.ToolchainWait{}}
pkg := w.body(build.ToolchainWait{Module: "m", Fingerprint: "src2:f", Package: "@novox/sdk@0.1.15"}, "")
if pkg.Part != "@novox/sdk@0.1.15" || pkg.On != "package:@novox/sdk@0.1.15" || pkg.Step != waitStepBuilding {
t.Errorf("a package wait says %+v", pkg)
}
if tc := w.body(build.ToolchainWait{Module: "m", Fingerprint: "src2:f", Language: "go", Version: "go1.26.0"}, ""); tc.Part != "" || tc.On != "toolchain:go@go1.26.0" {
t.Errorf("a toolchain wait says %+v", tc)
}
}