A4: a want of no pipeline carries the newest source held for it

A placement's build or a put written after a delivery carried the kept
graph's trunk source as its run, which can be older than the delivered
want's, so the compare-and-set refused a person's act (the whole test of a
placement back at a module's first build). The newest source the assigner
holds for such a want is now the kept trunk source or the run of the want
written, whichever is newer.

Builds: design 47 H2 §813 (1); H-A-416
This commit is contained in:
2026-11-22 01:22:52 +01:00
parent b9bc44024d
commit 40ad2650bd
2 changed files with 19 additions and 6 deletions
@@ -118,6 +118,11 @@ func TestTheWantsAreSaidWantedFromTheKeptAssignmentGraphRevision(t *testing.T) {
if w, _ := mwc.DecodeWant(kv.values[skey]); w.Run != "9" {
t.Errorf("a put's want is %+v, want the newest source held, 9", w)
}
// a placement's build after the delivery of run 12: the newest source held for it is the want's own, never refused
p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.0"})
if w := stored(); w.Run != "12" || w.Version != "0.1.0" {
t.Errorf("a placement's want after run 12 is %+v, want it written at run 12", w)
}
})
// A-201, A-235: a run's candidate catalog revision, read whole through the seat's verb revision, keeps the run's assignment
@@ -314,19 +314,27 @@ func (p *passer) putWant(ctx context.Context, node, module string, want mwc.Want
// runOf is the run a want carries (design 47 H2 §813 (1); H-A-355 (1), H-A-416): the source revision of the pipeline that
// released it, `<branch>.<source>`, in decimal; for a want of no pipeline (a put, a placement's build, a removal) the newest
// source the assigner holds, the trunk's source of its kept assignment graph revision; "" when it holds none.
func (p *passer) runOf(want mwc.Want) string {
// source the assigner holds for it: the trunk's source of its kept assignment graph revision, or the run of the want written
// (held) when that is newer, so a person's put or placement after a delivery is never refused as older; "" when it holds none.
func (p *passer) runOf(want mwc.Want, held *mwc.Want) string {
if i := strings.LastIndexByte(want.Pipeline, '.'); i >= 0 {
if n, err := strconv.ParseInt(want.Pipeline[i+1:], 10, 64); err == nil && n > 0 {
return strconv.FormatInt(n, 10)
}
}
var newest int64
if p.graph != nil {
if _, source, ok := p.graph.keptNow(); ok && source > 0 {
return strconv.FormatInt(source, 10)
if _, source, ok := p.graph.keptNow(); ok {
newest = source
}
}
return ""
if held != nil {
newest = max(newest, runNumber(held.Run))
}
if newest <= 0 {
return ""
}
return strconv.FormatInt(newest, 10)
}
// runNumber is a want's run as a number, 0 for none.
@@ -345,7 +353,7 @@ func (p *passer) wantWritten(ctx context.Context, node, module, key string, want
held = &h
}
}
want.Run = p.runOf(want)
want.Run = p.runOf(want, held)
if held != nil {
same := *held
same.Run = want.Run