From 481d1f255be245a0569b94708d6167b4cbb9d016 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:47:59 +0100 Subject: [PATCH] B1a: the builder's version floor and its wait go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The numbering from before G goes with its floor wait (design 47 H §756): the builder asks no floor (seat git.tags, the registry seats' versions, the entries' requirements), keeps no state floor-waits, serves neither builder_floor_again nor builder_floor_waits, raises no floor-silent finding and hears no take-in.taken or condition-cleared to wake one. The claim numbering that asked the floor (Numberer.Number, build.Numbers) goes with it; the reservation is the one place a version is numbered. Builds: design 47 H §756, G §372, spec 29, 41, 47, 48 --- .../cmd/mesh-delivery-builder-tools/main.go | 22 +- .../reservedname_test.go | 2 +- .../cmd/mesh-delivery-builder/catalog.go | 5 - .../cmd/mesh-delivery-builder/findings.go | 18 - .../mesh-delivery-builder/integration_test.go | 39 +- .../cmd/mesh-delivery-builder/main.go | 32 +- .../cmd/mesh-delivery-builder/names.go | 7 +- .../cmd/mesh-delivery-builder/names_test.go | 11 +- .../cmd/mesh-delivery-builder/reasks.go | 14 +- .../cmd/mesh-delivery-builder/refused_test.go | 49 +-- .../cmd/mesh-delivery-builder/reserve_test.go | 4 +- .../cmd/mesh-delivery-builder/seats.go | 36 +- .../cmd/mesh-delivery-builder/versions.go | 132 +------ .../internal/build/entry_test.go | 5 - .../internal/build/numbers.go | 83 ---- .../internal/build/run.go | 20 - .../internal/build/run_test.go | 77 +--- .../internal/build/stuck.go | 19 +- .../internal/versions/again.go | 17 - .../internal/versions/claim.go | 205 +--------- .../internal/versions/entrynames.go | 17 - .../internal/versions/entrynames_test.go | 19 - .../internal/versions/floor.go | 332 ---------------- .../internal/versions/heard.go | 19 +- .../internal/versions/oldform.go | 2 + .../internal/versions/store.go | 68 ---- .../internal/versions/tools.go | 1 - .../internal/versions/versions.go | 119 ------ .../internal/versions/versions_test.go | 364 ++---------------- .../mesh-delivery-builder/manifest_test.go | 13 +- modules/mesh-delivery-builder/module.json | 6 - 31 files changed, 97 insertions(+), 1660 deletions(-) delete mode 100644 modules/mesh-delivery-builder/internal/versions/floor.go diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/main.go index 9e164d827..84cb5a258 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/main.go @@ -44,7 +44,7 @@ type queueAsker func(key string, value []byte) (json.RawMessage, error) // builder_versions, asked by a name, answers also what the verb reserved answers for it (reserve; design 47 G §572): the // bundle calls the seat mesh-builds through its invokes, as any caller does. Nil answers none. func Tools(r build.StuckReader, askAgain func(key string, value []byte) error, queue, buildAgain queueAsker, since build.LogSince, now func() time.Time, vs versions.Reader, - fw, of versions.Reader, reserve func(name, version string) (meshbuilds.ReservedAnswer, error)) []stdio.Tool { + of versions.Reader, reserve func(name, version string) (meshbuilds.ReservedAnswer, error)) []stdio.Tool { str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) } // handAct writes a reasks value of a versions hand act and answers the builder's answer, or its refusal as an error. handAct := func(key string, value []byte, err error) (any, error) { @@ -65,13 +65,6 @@ func Tools(r build.StuckReader, askAgain func(key string, value []byte) error, q return map[string]any{"key": key, "name": a.Name, "answer": a.Answer}, nil } return []stdio.Tool{ - {Name: versions.FloorAgainTool, Description: versions.FloorAgainDescription, - Input: map[string]any{"type": "object", "required": []string{"name", "why"}, "properties": map[string]any{ - "name": map[string]any{"type": "string", "description": "the numbered name, /"}, - "why": map[string]any{"type": "string", "description": "why, in plain words"}}}, - Run: func(args map[string]any) (any, error) { - return handAct(build.NewFloorAgain(str(args, "name"), str(args, "why"), stdio.CallerOf(args), now())) - }}, {Name: versions.OldFormTool, Description: versions.OldFormDescription, Input: map[string]any{"type": "object", "properties": map[string]any{ "drop": map[string]any{"type": "string", "description": "a retired node to drop from the count by hand"}, @@ -82,9 +75,6 @@ func Tools(r build.StuckReader, askAgain func(key string, value []byte) error, q } return versions.AnswerOldForm(of) }}, - {Name: versions.FloorWaitsTool, Description: versions.FloorWaitsDescription, - Input: map[string]any{"type": "object", "properties": map[string]any{}}, - Run: func(map[string]any) (any, error) { return versions.AnswerFloorWaits(fw) }}, {Name: versions.VersionsTool, Description: versions.VersionsDescription, Input: map[string]any{"type": "object", "required": []string{"name"}, "properties": map[string]any{ "name": map[string]any{"type": "string", "description": "the package, image, bundle or archive name"}, @@ -366,14 +356,6 @@ func main() { } return e.Value, true, nil }} - fs := stdio.State(versions.FloorWaitsState) - fr := versions.Reader{Keys: fs.Keys, Get: func(key string) (json.RawMessage, bool, error) { - e, err := fs.Get(key) - if err != nil || e == nil { - return nil, false, err - } - return e.Value, true, nil - }} ofs := stdio.State(versions.OldFormState) ofr := versions.Reader{Keys: ofs.Keys, Get: func(key string) (json.RawMessage, bool, error) { e, err := ofs.Get(key) @@ -429,7 +411,7 @@ func main() { var a meshbuilds.ReservedAnswer return a, json.Unmarshal(raw, &a) } - tools := Tools(r, put, askQueue(stdio.State(build.QueuesState), 25*time.Second), buildAgain, stdio.Log(builds.BuilderLog).Since, time.Now, vr, fr, ofr, reserve) + tools := Tools(r, put, askQueue(stdio.State(build.QueuesState), 25*time.Second), buildAgain, stdio.Log(builds.BuilderLog).Since, time.Now, vr, ofr, reserve) tools = append(tools, buildTool(&build.BuildReader{Builds: read(stdio.State("builds")), Entry: entryOf(stdio.State("builds").Get), Asked: read(stdio.State("asked")), Newest: newestVia(stdio.Ask), Steps: r})) tools = append(tools, reservedTools(rr, buildAgain, time.Now, meshhandactsclient.Recorder{Ask: stdio.Ask})...) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reservedname_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reservedname_test.go index a91daa9e8..79a91bde9 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reservedname_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reservedname_test.go @@ -28,7 +28,7 @@ func TestBuilderVersionsByNameCallsReserved(t *testing.T) { called = append(called, name+"@"+version) return want, nil } - tools := Tools(build.StuckReader{}, nil, nil, nil, nil, time.Now, none, none, none, reserve) + tools := Tools(build.StuckReader{}, nil, nil, nil, nil, time.Now, none, none, reserve) for _, tl := range tools { if tl.Name == versions.VersionsTool { out, err := tl.Run(map[string]any{"name": "@novox/mesh-sdk", "version": "0.1.2"}) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go index 5ff5f0bd4..ff2b00580 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go @@ -75,8 +75,6 @@ type catalogHalf struct { halves map[string]*views.Follower once sync.Once ctx context.Context - // floor is told each entry change: a floor whose tags or requirements were silent is asked again (design 47 G A-119). - floor func(context.Context) // holders is told each entry change: a claim of a build seat may have moved (design 47 G A-82). holders func() } @@ -112,9 +110,6 @@ func (c *catalogHalf) Changed(ctx context.Context) func(branch, module string, e c.logf("%v", err) } c.b.Entry(ctx, origin, e) - if c.floor != nil { - defer c.floor(ctx) - } c.mu.Lock() was := c.named[module] now := namesOf(e) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/findings.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/findings.go index b50b6af37..8e0db2c85 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/findings.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/findings.go @@ -13,8 +13,6 @@ import ( mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-sdk/go/views" - - "mesh-delivery-builder/internal/versions" ) // heldWriter is the builder's finding writer: its findings are raised as they happen, so the writer holds them (design 47 G @@ -151,19 +149,3 @@ func (f *findings) notHeard(ctx context.Context) heard.Writer { return f.w.Clear(ctx, scope, rest[:i], rest[i+1:], "the builder hears it") }} } - -// floorSaid is the floor finding (design 51 *Health and conditions*: a floor source silent): raised for a name waiting on -// its floor, about that name, cleared once all three sources answered. -func (f *findings) floorSaid(ctx context.Context) func(versions.FloorWait, bool) { - return func(w versions.FloorWait, raised bool) { - if !raised { - f.clear(ctx, versions.FloorSilent, mcc.ScopeModule, w.Name) - return - } - f.raise(ctx, finding{kind: versions.FloorSilent, scope: mcc.ScopeModule, id: w.Name, summary: w.Finding(), - headline: "A version's floor is not known", - explanation: "The builder numbers a name only once its registry seat, the forge bridge's tags and the indexer's requirements all answered; one of them did not.", - resolved: "All three answered.", - needs: "builder_floor_waits names the silent source; builder_floor_again asks again by hand."}) - } -} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go index ca19716f6..36e202b03 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go @@ -9,7 +9,6 @@ import ( "encoding/json" "errors" "fmt" - "maps" "os" "path/filepath" "slices" @@ -323,7 +322,7 @@ func startBedWith(t *testing.T, closed bool) *bed { // each have their durable consumer. b.catalog = newCatalogHolder(t, ctx, js, ctl) b.catalog.buildSeats(t, ctl, map[string]string{"node-build-go": testGo, "node-build-node": testNode, "node-build-image": testImage, - "git": "mesh-delivery-forge-bridge", "mesh-catalog": "mesh-delivery-indexer", // the floor's sources are the holders of git and mesh-catalog + "git": "mesh-delivery-forge-bridge", "mesh-catalog": "mesh-delivery-indexer", "mesh-builds": builds.BuilderModule}) // the builder's own seat, whose verb reserved it answers once its definition is read (A-115, A-278) readers := []string{"n1_" + builds.BuilderModule, "n2_" + builds.BuilderModule} // Design 47 G §717, A-298: the catalog half names testAssigner the claimant of mesh-module-assigner, and its seat-holders view @@ -571,7 +570,7 @@ func isState(state string) func(builds.BuilderBuild) bool { // the digests of both bundles, both build modules' toolchains, after a fetch and a build on one node (ADR 0478 clause 4). func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7 b := startBed(t) - // The builder's versions, findings and the floor's three sources are on the bus, the seat answering 0.1.4; two merges close + // The builder's versions and findings are on the bus, the seat answering 0.1.4; two merges close // together, the first replaced before its claim. The builder numbers neither in its state versions (design 47 H H-A-159, // G §348, §369): the reservation is the one place a version is numbered. reg := b.registry(t, "n1", "0.1.4") @@ -622,7 +621,7 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7 for _, e := range b.logged(t, "netcheck") { if e.Event != builds.BuildSaidEvent { ended = append(ended, e) - } else if e.Why == versions.SaidNumbered || e.Why == versions.SaidKept { + } else if e.Why == "numbered" || e.Why == "kept" { // the narrations of the numbering from before G (design 47 H §756) t.Errorf("said = %+v, want no version of the builder's own numbered (H-A-159)", e) } } @@ -669,29 +668,6 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7 if _, err := reg.versions.Put(b.ctx, versions.Key("netcheck/tools-go", "0.1.6"), refusable); err != nil { t.Fatal(err) } - // Running-testing note (review round 1): two claims never get one number on the bus's own compare-and-set, as - // the builder's state versions keeps them: eight claims of one name at once, eight versions. - store := versions.Versions{Store: awaitedVersions{b: process.AwaitBucket(b.ctx, b.js, nil, builds.StateBucket(builds.BuilderModule, versions.State), "", t.Logf)}} - numbers := make(chan string, 8) - var claims sync.WaitGroup - for i := range 8 { - claims.Go(func() { - d, _, err := store.Number(b.ctx, versions.Claim{Name: "netcheck/race", Kind: versions.KindBundle, Fingerprint: fmt.Sprintf("f%d", i)}) - if err != nil { - t.Error(err) - } - numbers <- d.Version - }) - } - claims.Wait() - close(numbers) - got := map[string]bool{} - for v := range numbers { - got[v] = true - } - if len(got) != 8 { - t.Errorf("eight claims of one name at once were numbered %v, want eight versions", slices.Sorted(maps.Keys(got))) - } if got := reg.numberedOf("netcheck/tools-go"); len(got) != 0 { t.Errorf("version.numbered of netcheck/tools-go said %v, want none", got) } @@ -1154,10 +1130,9 @@ func TestARestartedBuilderPutsNoSecondAsk(t *testing.T) { } } -// registry is the part of the bed design 51's builder cases need: the builder's states versions, findings, floor-waits and -// reasks, EVENTS with the seat oci-artifact-registry's outcomes and the builder's durable consumer of it, the builder's -// own events kept, and the floor's three sources served on the bus as their holders answer through the tool runner -// ({result}): the seat's versions, the seat git's tags and the indexer's indexer_requirements. +// registry is the part of the bed design 51's builder cases need: the builder's states versions, findings and reasks, EVENTS +// with the seat oci-artifact-registry's outcomes and the builder's durable consumer of it, the builder's own events kept, and +// the seat's versions served on the bus as its holder answers through the tool runner ({result}). type registry struct { b *bed versions, findings, reasks jetstream.KeyValue @@ -1176,7 +1151,6 @@ func (b *bed) registry(t *testing.T, node string, seatVersions ...string) *regis return kv } r.versions, r.findings, r.reasks = mk(builds.StateBucket(builds.BuilderModule, versions.State)), mk(builds.StateBucket(builds.BuilderModule, mcseat.StateFindings)), mk(builds.StateBucket(builds.BuilderModule, build.ReAsksState)) - mk(builds.StateBucket(builds.BuilderModule, versions.FloorWaitsState)) // EVENTS with two seats' outcomes, and the forge bridge's stream (a branch's end): each with the builder's durable consumer. for stream, subjects := range map[string][]string{ eventsStream: {"mesh.mod.*.event.>", "mesh.seat.*.event.>"}, @@ -1206,7 +1180,6 @@ func (b *bed) registry(t *testing.T, node string, seatVersions ...string) *regis } for subject, answer := range map[string]any{ "mesh.seat." + ociartifactregistry.Seat + ".call.versions.>": map[string]any{"versions": listed}, - "mesh.seat.git.call.tags.>": map[string]any{"tags": []string{}}, } { reply, _ := json.Marshal(map[string]any{"result": answer, "node": "ctl"}) s, err := nc.Subscribe(subject, func(m *nats.Msg) { _ = m.Respond(reply) }) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index 8ec595725..e7df9c9d1 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -163,22 +163,13 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // it, bound once the bus holds it; the builder numbers nothing in it (design 47 H H-A-159). versionsKV := process.AwaitBucket(ctx, js, conn, own.versions, "builder_versions answers nothing of the versions numbered before G", logger.Printf) found := &findings{module: cred.Module, w: fw, logf: logger.Printf, now: time.Now} - floorWaits := &versions.FloorWaits{Holder: versions.HolderOf(branches), Logf: logger.Printf, Said: found.floorSaid(context.WithoutCancel(ctx))} - // The names waiting on their floor are kept in the state floor-waits (DLV-B4): a restarted builder takes them in, so - // their silent sources' events still wake them; until the state is bound they are kept here only. - process.AwaitBucket(ctx, js, conn, builds.StateBucket(cred.Module, versions.FloorWaitsState), "the names waiting on their floor are kept in memory only, and builder_floor_waits shows none", logger.Printf). - Ready(func(kv jetstream.KeyValue) { - floorWaits.Keep(kvKeeper{ctx: ctx, kv: kv}, heldFloorWaits(ctx, kv, logger.Printf)) - }) - // A package is numbered under its name in its ecosystem, read from the catalog half's entries (design 32, design 47 G §348). - numberer := &versions.Numberer{Versions: versions.Versions{Store: awaitedVersions{b: versionsKV}}, Floor: floorVia(calls.Call, versions.RequirementsFrom(versions.EntriesOf(branches))), Waits: floorWaits, - Names: versions.NamesFrom(versions.EntriesOf(branches))} + // The state versions kept from before G: the registry seats' words still mark its entries (design 47 H §756 removes it). + numberer := &versions.Numberer{Versions: versions.Versions{Store: awaitedVersions{b: versionsKV}}} // A publish that ends badly is a finding (design 51 *Health and conditions*): a holder's refused, a version no holder // answered within its bound (a key of the state bounds with its own time to live), a seat's outcome that does not read. pubBoundsKV := process.AwaitBucket(ctx, js, conn, own.bounds, "a publish no holder answers, and a node holding the old form seven days, are not raised", logger.Printf) stepReads.bounds, stepReads.findings = func() jetstream.KeyValue { return pubBoundsKV.KV() }, found pubs := &publishes{bounds: pubBoundsKV.KV, versions: numberer.Versions, findings: found, bound: versions.PublishBound, logf: logger.Printf} - numberer.Publishing = pubs.arm stepExpiry := &buildrun.Expiry{} var b *build.Builder seatsChanged := func(ctx context.Context) { @@ -211,9 +202,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro unput := &unputs{bounds: pubBoundsKV.KV, store: b.Claimer.Store, looking: b.Looking, findings: found, bound: meshconditionsclient.CallUnansweredAfter, now: time.Now, logf: logger.Printf} b.Left, b.Ended = unput.left, unput.ended - // The builder numbers nothing of its own (design 47 H H-A-159, G §348, §349, §369): b.Numbers stays nil, so no trunk build - // is numbered in the state versions, waits on a floor or arms a publish-unanswered bound of it; the reservation is the one - // place a version is numbered. The state, kept from before G, is still read (builder_versions) until G §372 removes it. + // The builder numbers nothing of its own and asks no floor (design 47 H §756, H H-A-159, G §348, §349, §369): the + // reservation is the one place a version is numbered. // The builder's toolchain waits (design 47 G §672): its state waits, and wait-held and wait-ended on its stream waits; its // bound is its setting toolchain-wait-minutes. waitBound, err := toolchainWaitOf(getenv("MESH_BUILDER_TOOLCHAIN_WAIT_FILE")) @@ -269,8 +259,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro reserved.readFilled(ctx, lastKeptOf(js, cred, logger.Printf), sleeps) // A state bound later numbers the builds looked at without it. versionsKV.Ready(func(jetstream.KeyValue) { b.Reconsider(ctx) }) - // The versions' hand acts (builder_publish_again, builder_floor_again) come through reasks, as builder_build_again. - acts := versions.Acts{Numberer: numberer, DropReserved: reserved.dropped, Reconsider: b.Reconsider} + // The versions' hand acts (builder_publish_again, builder_reserved_drop) come through reasks, as builder_build_again. + acts := versions.Acts{Numberer: numberer, DropReserved: reserved.dropped} // A reserved version left unpublished is published again, by the builder on an event or by a person's tool (design 47 G // §588): its items on the work queue publishes, the module's own stream of its old streams section (design 47 H2 §793, H-A-454). actedKV := process.AwaitBucket(ctx, js, conn, own.acted, "no version is published again on an event or by builder_publish_again", logger.Printf) @@ -479,9 +469,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // The seat mesh-artifact-sweep says artifacts-gone when it found a key's blob gone (issue 1937, ADR 0571 §2): the // builder's durable consumer on EVENTS, made by the grants part from the manifest's consumes. Where it is not there yet the builder says // so; it still asks held at its start and at every module value. - // The same consumer carries what wakes a floor (design 51 *The floor*): the indexer's take-in.taken (design 47 H H-A-116) and the - // condition keeper's condition-cleared. - floor := floorWake{b: b, waits: floorWaits, logf: logger.Printf} // And the four registry seats' published, refused and removed (DLV-B4), which move a numbered version. seatHeard := seatHearer{n: numberer, b: b, logf: logger.Printf, pub: pubs, res: reserved} // Each part takes the events it hears in turn; a handling over the setting slow-event is said with the part that took it @@ -496,7 +483,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro {"what a node's engine reads", func(m jetstream.Msg) bool { return reads.heard(m, logger.Printf) }}, // manifest-reads-changed (ADR 0618 §4) {"the toolchains reported", func(m jetstream.Msg) bool { return heardTools.Reported(ctx, m) }}, {"the toolchains running", func(m jetstream.Msg) bool { return heardTools.Running(ctx, m) }}, - {"the floor", func(m jetstream.Msg) bool { return floor.heard(ctx, m) }}, {"the reservations", func(m jetstream.Msg) bool { return reserved.heard(ctx, m) }}, {"the registry seats' outcomes", func(m jetstream.Msg) bool { return seatHeard.heard(ctx, m) }}, } @@ -573,15 +559,11 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro b.SayUnbuildable(ctx) // at the start, once the first views are in: the plans no seat builds in one line (§795) } branches.Changed = half.Changed(ctx) - // A catalog revision the builder hears wakes a floor whose tags or requirements were silent (design 47 G A-119). - half.floor = func(ctx context.Context) { - (&floorWake{b: b, waits: floorWaits, logf: logger.Printf}).wake(ctx, versions.WakeRevision, "", "") - } // All of the catalog half's wiring is set before the reader starts: its views are heard on the reader's goroutines from then. reader.Start(ctx, js, cred, process.AwaitBucket(ctx, js, conn, builds.StateBucket(cred.Module, views.StatusState), "builder_first_views reads nothing and builder_first_view_again is not heard", logger.Printf)) // Every part has registered: the hub pulls the module's durable. Where the consumer is not there yet the builder says so // and binds it at a later change (heard.Writer; ADR 0615 §5). - _ = notHeard.Bind(eventsStream, sweep.EventArtifactsGone+", what wakes a floor, the registry seats' words, the views and manifest-reads-changed are not heard until the builder starts again", func() error { + _ = notHeard.Bind(eventsStream, sweep.EventArtifactsGone+", the registry seats' words, the views and manifest-reads-changed are not heard until the builder starts again", func() error { if err := hub.Start(ctx, js, cred); err != nil { return err } diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names.go index e54fac5e0..7126852f1 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names.go @@ -8,8 +8,8 @@ import ( const namedTreePrefix = "named:" // seatEventPatterns are the seats' events the builder's own handler takes off its durable consumer (its manifest's `consumes` of -// them): the registry seats' words, artifacts-gone, the build seats' toolchain-reported, condition-cleared, the node-engine -// seat's events, of the seat mesh-catalog, version-released and versions-filled, and the indexer's take-in.taken. The seat mesh-catalog's +// them): the registry seats' words, artifacts-gone, the build seats' toolchain-reported, the node-engine +// seat's events, of the seat mesh-catalog, version-released and versions-filled. The seat mesh-catalog's // catalog-revision and registration-changed and the seat mesh-delivery's source-moved are the views reader's (the branch // follower's), so no pattern here covers them: a message has one taker. var seatEventPatterns = func() []string { @@ -21,6 +21,5 @@ var seatEventPatterns = func() []string { for _, event := range []string{meshcatalog.EventVersionReleased, meshcatalog.EventVersionsFilled} { out = append(out, "mesh.seat."+meshcatalog.Seat+".event."+event, "mesh.seat."+meshcatalog.Seat+".event."+event+".>") } - // And the indexer's take-in.taken, which wakes the floor (design 47 H H-A-116). - return append(out, takenInSubject) + return out }() diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names_test.go index c22673e35..e0530af02 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names_test.go @@ -32,14 +32,11 @@ func TestTheNamesAreTheManifests(t *testing.T) { t.Errorf("the builder reads %s, its manifest's reads are %v", read, m.Reads) } } - // The catalog half (design 47 G §348, §614) is followed through the seat, and no state of the indexer is; the indexer's - // event take-in.taken wakes the floor (design 47 H H-A-116). - if !slices.Contains(m.Consumes, "mesh-delivery-indexer.take-in.taken") { - t.Errorf("the builder's floor wakes on no take-in.taken: its manifest consumes %v", m.Consumes) - } + // The catalog half (design 47 G §348, §614) is followed through the seat, and nothing of the indexer is: with the floor gone + // (design 47 H §756) not its take-in.taken either (H-A-116). for _, c := range m.Consumes { - if strings.HasPrefix(c, "mesh-delivery-indexer.") && c != "mesh-delivery-indexer.take-in.taken" { - t.Errorf("the builder follows %s, an indexer state, its manifest consumes it", c) + if strings.HasPrefix(c, "mesh-delivery-indexer.") { + t.Errorf("the builder follows %s of the indexer, its manifest consumes it", c) } } for _, view := range []string{"mesh-catalog.catalog-revision", "mesh-catalog.registration-changed", "mesh-delivery.source-moved", "seat:mesh-module-assigner.views.assignments"} { diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go index d57314066..e3951c9a6 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go @@ -65,7 +65,7 @@ func reAsked(ctx context.Context, b askAgainer, acts versions.Acts, items *publi released(ctx, b, kv, e, r, logf) return } - if r.Mode == build.ModeRepublish || r.Mode == build.ModePublishDrop || r.Mode == build.ModeFloorAgain || r.Mode == build.ModeOldFormDrop || r.Mode == build.ModeReservedDrop || r.Mode == build.ModeReserveDone { + if r.Mode == build.ModeRepublish || r.Mode == build.ModePublishDrop || r.Mode == build.ModeOldFormDrop || r.Mode == build.ModeReservedDrop || r.Mode == build.ModeReserveDone { // A version's hand act (design 51 *Tools of the builder*) may build again, so it is answered beside the watch. go versionActed(ctx, acts, kv, e, r, logf) return @@ -196,7 +196,7 @@ func emitBuildEnded(ctx context.Context, js jetstream.JetStream, cred process.Ac return nil } -// versionActed answers a reasks value of builder_publish_again, builder_floor_again or builder_old_form's drop, a hand act said in the log. +// versionActed answers a reasks value of builder_publish_again, builder_publish_drop, builder_reserve_done, builder_reserved_drop or builder_old_form's drop, a hand act said in the log. func versionActed(ctx context.Context, acts versions.Acts, kv jetstream.KeyValue, e jetstream.KeyValueEntry, r build.ReAsk, logf func(string, ...any)) { var err error if r.Mode == build.ModeRepublish { @@ -227,14 +227,10 @@ func versionActed(ctx context.Context, acts versions.Acts, kv jetstream.KeyValue } else { r.Answer, err = acts.DropReserved(ctx, r.Name, r.FP, r.By, r.Why, r.At) } - } else if r.Mode == build.ModeOldFormDrop { - if acts.DropOldForm == nil { - err = errors.New("this builder keeps no old-form window") - } else { - r.Answer, err = acts.DropOldForm(ctx, r.Name, r.By, r.Why, r.At) - } + } else if acts.DropOldForm == nil { + err = errors.New("this builder keeps no old-form window") } else { - r.Answer, err = acts.FloorAgain(ctx, r.Name) + r.Answer, err = acts.DropOldForm(ctx, r.Name, r.By, r.Why, r.At) } if err != nil { r.Answer, r.Refused = err.Error(), true diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go index 87f09a7a1..df600590a 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go @@ -42,7 +42,7 @@ import ( // its grant. The gate over the seat's assignments, and its refusal, are mesh-sdk's (buildrun.PlacedNodes, // issue 774). func TestARefusedBucketIsSaidAndThePartGoesOn(t *testing.T) { - t.Run("a floor's wake is heard on the events consumer (design 51 The floor)", aFloorsWakeIsHeard) + t.Run("a registry seat's outcome is heard on the events consumer (DLV-B4)", aSeatsOutcomeIsHeard) t.Run("a failed trunk build is a finding until a later done one (DLV-B7)", aFailedTrunkBuildIsAFinding) refused := refusingBus{err: errors.New("nats: permissions violation for publish to $JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules")} if _, err := process.EssentialBucket(context.Background(), refusingBus{refuseOpen: true, err: refused.err}, "builder", "mesh-delivery-indexer_modules", "work"); err == nil || @@ -250,33 +250,16 @@ func (m *wakeMsg) Headers() nats.Header { return nil } -func aFloorsWakeIsHeard(t *testing.T) { +func aSeatsOutcomeIsHeard(t *testing.T) { var logs bytes.Buffer - holders := map[string]string{"git": "mesh-delivery-forge-bridge", "mesh-catalog": "mesh-delivery-indexer"} - waits := &versions.FloorWaits{Holder: func(seat string) (string, bool) { h, ok := holders[seat]; return h, ok }} - waits.Wait("m/lib", versions.SeatGoPackages, "", versions.Floor{Silent: []string{versions.SourceRequirements}}, nil, time.Unix(0, 0)) - waits.Wait("m/img", versions.SeatImages, "", versions.Floor{Silent: []string{versions.SourceTags}}, nil, time.Unix(0, 0)) - f := &floorWake{b: &build.Builder{}, waits: waits, logf: log.New(&logs, "", 0).Printf} - accepted := &wakeMsg{subject: takenInSubject} - if !f.heard(context.Background(), accepted) || !accepted.acked || !strings.Contains(logs.String(), "the floor of m/lib is asked again: take-in.taken") { - t.Fatalf("take-in.taken: acked %v, log %q", accepted.acked, logs.String()) - } - logs.Reset() - cleared := &wakeMsg{subject: conditionClearedSubject, data: []byte(`{"subject":{"scope":"probe","id":"ace/mesh-delivery-forge-bridge"}}`)} - if !f.heard(context.Background(), cleared) || !strings.Contains(logs.String(), "the floor of m/img is asked again: condition-cleared") { - t.Fatalf("condition-cleared: log %q", logs.String()) - } - if f.heard(context.Background(), &wakeMsg{subject: sweep.SubjectArtifactsGone}) { - t.Fatal("artifacts-gone was taken as a floor's wake") - } - // DLV-B4: a registry seat's outcome on the same consumer moves a version; a published wakes a name whose seat was - // silent; one the state cannot take is left for the bus to give again. - logs.Reset() - waits.Wait("m/pkg", versions.SeatGoPackages, "", versions.Floor{Silent: []string{versions.SourceSeat}}, nil, time.Unix(0, 0)) - h := &seatHearer{n: &versions.Numberer{Versions: versions.Versions{Store: noVersions{}}, Waits: waits}, b: &build.Builder{}, logf: log.New(&logs, "", 0).Printf} + // DLV-B4: a registry seat's outcome on the events consumer moves a version; a by-digest publish marks none and is taken. + h := &seatHearer{n: &versions.Numberer{Versions: versions.Versions{Store: noVersions{}}}, b: &build.Builder{}, logf: log.New(&logs, "", 0).Printf} byDigest := &wakeMsg{subject: "mesh.seat.go-package-registry.event.published", data: []byte(`{"name":"m/other","digest":"sha256:aa","kind":"package","holder":"gitea"}`)} - if !h.heard(context.Background(), byDigest) || !byDigest.acked || !strings.Contains(logs.String(), "the floor of m/pkg is asked again: go-package-registry said published") { - t.Fatalf("published: acked %v, log %q", byDigest.acked, logs.String()) + if !h.heard(context.Background(), byDigest) || !byDigest.acked || byDigest.naked { + t.Fatalf("published: acked %v, naked %v, log %q", byDigest.acked, byDigest.naked, logs.String()) + } + if h.heard(context.Background(), &wakeMsg{subject: sweep.SubjectArtifactsGone}) { + t.Fatal("artifacts-gone was taken as a seat's outcome") } // Design 47 G §369, A-415: a published of a version the reservation numbered, which the state versions does not hold, is // taken: its artifact is marked and package-published said, never left for the bus to give again. @@ -299,9 +282,6 @@ func aFloorsWakeIsHeard(t *testing.T) { if !h.heard(context.Background(), published) || !published.acked || published.naked || len(saidPub) != 1 || saidPub[0].Artifact != "m:program" { t.Fatalf("a published of a reserved version: acked %v, naked %v, said %+v, log %q", published.acked, published.naked, saidPub, logs.String()) } - if h.heard(context.Background(), &wakeMsg{subject: takenInSubject}) { - t.Fatal("take-in.taken was taken as a seat's outcome") - } // Design 47 G A-420: a message left for the bus is said given up on the last delivery its consumer allows, never before. for _, n := range []uint64{4, EventDeliveries} { logs.Reset() @@ -354,17 +334,6 @@ func aFailedTrunkBuildIsAFinding(t *testing.T) { if _, ok := st.vals[key]; ok { t.Error("a later done trunk build leaves build-failed") } - // The floor finding: raised while a name waits on its floor, cleared once it is known. - fw := &versions.FloorWaits{Said: f.floorSaid(context.Background())} - fw.Wait("m/lib", versions.SeatGoPackages, "", versions.Floor{Silent: []string{versions.SourceTags}}, nil, time.Unix(0, 0)) - floorKey := meshconditionsclient.Key(meshconditionsclient.ScopeModule, "m/lib", versions.FloorSilent) - if got, err := decodeFinding(st.vals[floorKey]); err != nil || !strings.Contains(got.Summary, "git.tags did not answer") { - t.Fatalf("the floor finding = %+v, %v", got, err) - } - fw.Answered("m/lib") - if _, ok := st.vals[floorKey]; ok { - t.Error("a known floor leaves floor-silent") - } // Design 51 *Health and conditions* (review round 1): a holder's refused is publish-refused with its reason, a version // no holder answered within its bound publish-unanswered, a seat's outcome that does not read seat-outcome-unread; // a later published of the name clears the first two, the seat's next outcome that reads the third. diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go index 6a20ddd58..279dd947f 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go @@ -689,8 +689,8 @@ func TestEventsAreHandledByAWorkerPerName(t *testing.T) { if got := eventKey(&wakeMsg{subject: meshcatalog.SubjectVersionReleased, data: []byte(`{"module":"m","version":"0.1.0"}`)}); got != "module m" { t.Errorf("a version-released's key is %q, want its module", got) } - if got := eventKey(&wakeMsg{subject: takenInSubject, data: []byte(`{}`)}); got != "" { - t.Errorf("a take-in's key is %q, want the shared worker's", got) + if got := eventKey(&wakeMsg{subject: "mesh.seat.mesh-artifact-sweep.event.artifacts-gone", data: []byte(`{}`)}); got != "" { + t.Errorf("an event naming no name has the key %q, want the shared worker's", got) } release := make(chan struct{}) handled := make(chan string, 4) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seats.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seats.go index d45ffe18d..7edfc3a13 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seats.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seats.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "strconv" - "strings" "github.com/nats-io/nats.go/jetstream" @@ -44,8 +43,7 @@ var seatEvents = map[string]seatEvent{ npmpackageregistry.SubjectKept: {npmpackageregistry.Seat, npmpackageregistry.EventKept}, } -// seatHearer takes the registry seats' outcomes in: each moves a numbered version (versions.Numberer.Heard), and a -// `published` that wakes a name waiting on its floor looks at every module again. +// seatHearer takes the registry seats' outcomes in: each moves a numbered version (versions.Numberer.Heard). type seatHearer struct { n *versions.Numberer b *build.Builder @@ -83,7 +81,7 @@ func (h *seatHearer) heard(ctx context.Context, m jetstream.Msg) bool { if m.Headers() != nil { id = m.Headers().Get("x-event-id") } - wake, err := h.n.Heard(ctx, se.seat, se.event, id, o) + err := h.n.Heard(ctx, se.seat, se.event, id, o) if errors.Is(err, versions.ErrNotNumbered) { // The version is no entry of the state versions, design 51's numbering by name, which G keeps only until it is removed // (§372); the reservation numbers a version (§369, §52) and takes the outcome in (A-415). Heard again it would stay @@ -115,10 +113,6 @@ func (h *seatHearer) heard(ctx context.Context, m jetstream.Msg) bool { h.b.PackagePublished(o.Name, o.Version) } h.ack(m) - if len(wake) > 0 { - h.logf("the floor of %s is asked again: %s said %s", strings.Join(wake, ", "), se.seat, se.event) - h.b.Reconsider(ctx) - } return true } @@ -150,7 +144,7 @@ func (h *seatHearer) ack(m jetstream.Msg) { } } -// kvKeeper is the state floor-waits as versions.FloorKeeper. +// kvKeeper is a state of the builder as a keeper of keys: Put a key's value, Delete its key. type kvKeeper struct { ctx context.Context kv jetstream.KeyValue @@ -168,27 +162,3 @@ func (k kvKeeper) Delete(key string) error { } return err } - -// heldFloorWaits are the waits floor-waits holds at the builder's start; a value that is no wait is said and left. -func heldFloorWaits(ctx context.Context, kv jetstream.KeyValue, logf func(string, ...any)) []versions.FloorWait { - l, err := kv.ListKeys(ctx) - if err != nil { - logf("%s cannot be listed, so a restart's waits are asked at their next claim: %v", versions.FloorWaitsState, err) - return nil - } - defer func() { _ = l.Stop() }() - var out []versions.FloorWait - for k := range l.Keys() { - e, err := kv.Get(ctx, k) - if err != nil { - continue - } - w, err := versions.DecodeFloorWait(e.Value()) - if err != nil { - logf("%s.%s holds what is no floor wait, left: %v", versions.FloorWaitsState, k, err) - continue - } - out = append(out, w) - } - return out -} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go index 6fc60acf6..ed1107257 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go @@ -5,23 +5,19 @@ import ( "encoding/json" "errors" "fmt" - "strings" "time" "github.com/nats-io/nats.go" "github.com/nats-io/nats.go/jetstream" - "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" - gitseat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/gopackageregistry" "git.novox.be/novox/mesh-sdk/go/process" - "mesh-delivery-builder/internal/build" "mesh-delivery-builder/internal/versions" ) // awaitedVersions is the state versions as versions.Store: bound once the bus holds it (the grants part makes it, issue -// 1790); until then every use is an error, so a trunk build is built unnumbered and said (build.Builder.number). +// 1790); until then every use is an error. type awaitedVersions struct { b *process.AwaitedBucket // bucket names the state in the error of one not on the bus yet; empty is the versions'. @@ -119,70 +115,6 @@ func publishedVersionsVia(call toolCaller) func(context.Context, string) ([]stri } } -// floorVia is the floor's three sources as calls of the builder's own account (design 51 *The floor*): the seat's verb -// versions, the seat git's tags and the requirements the catalog half's entries name (A-119). A call that fails is that source -// silent. -func floorVia(call toolCaller, requirements func(context.Context, string) ([]string, error)) versions.FloorSources { - return versions.FloorSources{ - Seat: func(_ context.Context, seat, name string) ([]string, error) { - raw, err := call("seat:"+seat+".versions", map[string]any{"name": name}) - if err != nil { - return nil, err - } - var a struct { - Versions []struct { - Version string `json:"version"` - } `json:"versions"` - } - if err := json.Unmarshal(raw, &a); err != nil { - return nil, fmt.Errorf("%s's versions answered what is no list of versions: %w", seat, err) - } - var out []string - for _, v := range a.Versions { - if v.Version != "" { - out = append(out, v.Version) - } - } - return out, nil - }, - Tags: func(ctx context.Context, repository, prefix string) ([]string, error) { - tags, _, err := tagsVia(call)(ctx, repository, prefix) - out := make([]string, 0, len(tags)) - for _, t := range tags { - out = append(out, t.Tag) - } - return out, err - }, - Requirements: requirements, - } -} - -// tagsVia reads a repository's tags starting with prefix, each with the commit it names, through the seat git's verb tags, -// whichever module holds the seat (design 47 G §7, A-82), page by page; its answer is read tolerantly, form 2 naming each tag's -// commit (design 47 H2 §796, §780). away says the read met a transport fault or the error kind away (§776). -func tagsVia(call toolCaller) func(ctx context.Context, repository, prefix string) ([]gitseat.Tag, bool, error) { - return func(_ context.Context, repository, prefix string) ([]gitseat.Tag, bool, error) { - var out []gitseat.Tag - for page := int64(1); ; page++ { - raw, err := call("seat:"+gitseat.Seat+"."+gitseat.VerbTags, gitseat.TagsInput{Repository: repository, Prefix: prefix, Page: page}) - if err != nil { - return nil, true, err - } - a, _, err := gitseat.DecodeTagsAnswer(raw) - if err != nil { - return nil, false, fmt.Errorf("the seat git's tags answered what is no list of tags: %w", err) - } - if a.Error != "" { - return nil, a.ErrorKind == gitseat.ErrorKindAway, fmt.Errorf("the seat git's tags: %s (%s)", a.Error, a.ErrorKind) - } - out = append(out, a.Tags...) - if !a.More { - return out, false, nil - } - } - } -} - // emitEvent says one of the builder's events, mesh.mod..event., with the SDK's envelope headers and id as // the bus's dedup id. func emitEvent(ctx context.Context, js jetstream.JetStream, cred process.Account, event, id string, body any) error { @@ -221,65 +153,3 @@ func emitSeatEvent(ctx context.Context, js jetstream.JetStream, cred process.Acc _, err = js.PublishMsg(pub, msg, jetstream.WithMsgID(id)) return err } - -// The events on the builder's consumer of EVENTS that wake a floor (design 51 *The floor*, DLV-B3b). -var ( - // The indexer's take-in.taken, which the builder consumes in place of the retired manifest-accepted (design 47 H H-A-116). - takenInSubject = "mesh.mod.mesh-delivery-indexer.event.take-in.taken" - conditionClearedSubject = meshconditions.SubjectConditionCleared -) - -// floorWake asks the floor of the names an event wakes again, by looking at every module again: a trunk build is -// numbered before its claim (build.Builder.number). -type floorWake struct { - b *build.Builder - waits *versions.FloorWaits - logf func(string, ...any) -} - -// heard takes a message of the consumer in when it is one that wakes a floor, acknowledged, and answers whether it was. -func (f *floorWake) heard(ctx context.Context, m jetstream.Msg) bool { - switch m.Subject() { - case takenInSubject: - f.ack(m) - f.wake(ctx, versions.WakeTakenIn, "", "") - case conditionClearedSubject: - f.ack(m) - var e meshconditions.ConditionEvent - if err := json.Unmarshal(m.Data(), &e); err != nil { - f.logf("%s holds what is no condition, left: %v", m.Subject(), err) - return true - } - if e.Subject == nil { - return true - } - for _, module := range conditionModules(e.Subject.ID) { - f.wake(ctx, versions.WakeCleared, "", module) - } - default: - return false - } - return true -} - -func (f *floorWake) ack(m jetstream.Msg) { - if err := m.Ack(); err != nil { - f.logf("acknowledging %s: %v", m.Subject(), err) - } -} - -// wake looks at every module again when the event wakes a name, and says which. -func (f *floorWake) wake(ctx context.Context, kind, seat, module string) { - names := f.waits.Wake(kind, seat, module, "") - if len(names) == 0 { - return - } - f.logf("the floor of %s is asked again: %s", strings.Join(names, ", "), kind) - f.b.Reconsider(ctx) -} - -// conditionModules are the tokens of a condition's subject id (`/`, `.`): a module named -// among them is the one whose condition cleared. -func conditionModules(id string) []string { - return strings.FieldsFunc(id, func(r rune) bool { return r == '/' || r == '.' || r == ':' }) -} diff --git a/modules/mesh-delivery-builder/internal/build/entry_test.go b/modules/mesh-delivery-builder/internal/build/entry_test.go index f2e4f2f12..5511dbeb4 100644 --- a/modules/mesh-delivery-builder/internal/build/entry_test.go +++ b/modules/mesh-delivery-builder/internal/build/entry_test.go @@ -23,11 +23,6 @@ func TestAnEntryOfTheCatalogHalfIsTheFormTheBuilderBuildsBy(t *testing.T) { !reflect.DeepEqual(got.Inputs2.Paths, map[string]string{"a/b": "lib", "c": "lib"}) { t.Errorf("ModuleOf = %+v", got) } - // A module value carries no source stamp (design 47 H H-A-48): its claim is numbered per fingerprint, naming no source - // revision and no merge. - if c := ClaimOf("netcheck", got, Plan{}); c.Revision != "" || c.Merge != 0 || c.Fingerprint != "src2:f" { - t.Errorf("ClaimOf = %+v", c) - } if bare := ModuleOf(meshcatalog.CatalogEntry{Module: "m"}); bare.Inputs2 != nil || bare.Fp2 != "" { t.Errorf("ModuleOf of an entry with none = %+v, want nothing set", bare) } diff --git a/modules/mesh-delivery-builder/internal/build/numbers.go b/modules/mesh-delivery-builder/internal/build/numbers.go index 8e0cd70e6..484c18eed 100644 --- a/modules/mesh-delivery-builder/internal/build/numbers.go +++ b/modules/mesh-delivery-builder/internal/build/numbers.go @@ -11,93 +11,10 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" "mesh-delivery-builder/internal/versions" ) -// Numbers numbers a trunk build at its claim (novox/hq design 51 *The versions*, ADR 0606, ADR 0617 §1) and records the -// digests it was built with. Nil numbers nothing. -type Numbers interface { - // done is the digests of the build's key when it is done already (versions.BuildClaim.Done), nil otherwise. - Number(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue, plan Plan, done map[string]string) (versions.Numbering, error) - Built(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue, plan Plan, got versions.Numbering, made []builds.BuiltArtifact) error -} - -// VersionNumbers is Numbers over the builder's state versions. -type VersionNumbers struct { - N *versions.Numberer -} - -// ClaimOf is the claim a module value's trunk build is numbered by, per fingerprint: a module value carries no source stamp -// (design 47 H H-A-48), so the claim names no source revision and no merge. -func ClaimOf(module string, m meshcatalog.ModulesByModuleValue, plan Plan) versions.BuildClaim { - c := versions.BuildClaim{Module: module, Path: m.Path, Repository: trunk.RepositoryName(m.Repository), Fingerprint: m.Fp2, - Commit: m.Commit} - for _, t := range plan.Tasks { - c.Artifacts = append(c.Artifacts, versions.ClaimArtifact{Artifact: t.Artifact, Kind: t.Kind, Language: t.Language}) - } - return c -} - -func (v VersionNumbers) Number(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue, plan Plan, done map[string]string) (versions.Numbering, error) { - c := ClaimOf(module, m, plan) - c.Done = done - return v.N.Number(ctx, c) -} - -func (v VersionNumbers) Built(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue, plan Plan, got versions.Numbering, made []builds.BuiltArtifact) error { - digests := map[string]string{} - for _, a := range made { - digests[a.Name] = a.Digest - } - return v.N.Built(ctx, ClaimOf(module, m, plan), got, digests) -} - -// number numbers a trunk build's artifacts before its claim: false -// when it waits for its floor (a package, design 51 *The floor*), and then nothing is claimed; the floor's wake looks at -// the module again. -func (b *Builder) number(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue, plan Plan) (versions.Numbering, bool) { - if b.Numbers == nil { - return versions.Numbering{}, true - } - done := b.doneDigests(ctx, module, m.Fp2) - got, err := b.Numbers.Number(ctx, module, m, plan, done) - for _, s := range got.Said { - b.logf("%s at %s: %s", module, m.Fp2, s.Line) - // And in the build log (design 51 *The versions*: it says a version was kept, and why), between the build's start and end. - // A look at a key already done builds nothing and has no start or end: a version kept there says nothing new, and is - // not logged (each later look, a first view answered or a name heard, would add one). - if b.Log != nil && !(done != nil && s.Why == versions.SaidKept) { - b.Log(builds.BuildLogEntry{Event: builds.BuildSaidEvent, Module: module, FP: m.Fp2, Commit: m.Commit, Node: b.Node, - At: time.Now().UTC(), Line: s.Line, Why: s.Why}) - } - } - if err != nil { - // Said, and built as before: an unnumbered build is published by its digest (ADR 0617 §1), numbered at its next look. - b.logf("%s at %s: %v", module, m.Fp2, fmt.Errorf("not numbered, the versions cannot be used: %w", err)) - return versions.Numbering{}, true - } - if done != nil && len(got.Versions) > 0 && b.Reserved != nil { - // A late look numbered a done build: G §349 retires numbering at a look, so one with no reservation and no release is - // said aloud with the recovery that reserves it (A-455), never taken in silently. - _, reserved, rerr := b.Reserved.ReservedFor(ctx, module, m.Fp2) - released, derr := b.Reserved.ReleasedFor(ctx, module, m.Fp2) - if rerr == nil && derr == nil && !reserved && !released { - b.logf("%s at %s: a late look numbered this done build (%v) and no version is reserved for it: builder_reserve_done reserves one and queues its publish", module, m.Fp2, got.Versions) - } - } - if got.Refused != "" { - b.logf("%s at %s: %s", module, m.Fp2, got.Refused) - return got, true - } - if got.Wait != "" { - b.logf("%s at %s is not built yet: %s", module, m.Fp2, got.Wait) - return got, false - } - return got, true -} - // doneDigests are the digests of a trunk build's key by artifact when the key is done, nil otherwise or when it cannot be // read: a look at a done build numbers what it left unnumbered with them (versions.BuildClaim.Done). func (b *Builder) doneDigests(ctx context.Context, module, fp string) map[string]string { diff --git a/modules/mesh-delivery-builder/internal/build/run.go b/modules/mesh-delivery-builder/internal/build/run.go index 5242f95ce..be7432f24 100644 --- a/modules/mesh-delivery-builder/internal/build/run.go +++ b/modules/mesh-delivery-builder/internal/build/run.go @@ -104,9 +104,6 @@ type Builder struct { // time.Now. Node is the node the builder runs on, which asked the build. Now func() time.Time Node string - // Numbers numbers each trunk build at its claim and records what it was built with (design 51 *The versions*); nil - // numbers nothing, as the builder's program leaves it (design 47 H H-A-159: the reservation numbers, G §369). - Numbers Numbers // Reserved reserves the version of a trunk build at its start (design 47 G §369); nil reserves nothing. Reserved Reservations // Picture answers the source revision the builder's picture of a watched branch holds, false while it holds none (design 47 @@ -719,14 +716,6 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB byEvent := b.events[key] delete(b.events, key) b.mu.Unlock() - var numbering versions.Numbering - if trunk && planErr == nil && !nothing { - var goOn bool - if numbering, goOn = b.number(ctx, module, m, plan); !goOn { - end("is not built yet: it waits for its package's floor, nothing is claimed") - return - } - } // Only a build of the registration's first watched branch reserves and releases a version (design 47 G §371). reserving := trunk && b.originOf(key).First && planErr == nil && !nothing && b.reserves(ctx, module, m, plan) if trunk && b.originOf(key).First && planErr == nil && !nothing && !reserving { @@ -805,10 +794,6 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB // A trunk build that reserves is never built without its version: it would end done and publish nothing, and its key would // stay done, never built again (A-490). The key fails with why and is taken again at the next look or by builder_build_again. result = failed("no version is reserved for this build: the builder's journal says why, and it is built again once one can be") - } else if numbering.Refused != "" && cl.Build.State != builds.BuildDone { - // Refused, naming the state it could not read, and built against no guess (ADR 0666 §15; design 47, test 70): the key - // fails with why, and is taken again at the next look. - result = failed("%s", numbering.Refused) } else if nothing { // A manifest with no artifact is built by building nothing: its key is done with no artifact, claimed and written as // any other, so the controller has a done key to register it from (issue 1613, ADR 0478 clause 1, ADR 0501 clause 1). @@ -858,11 +843,6 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB ended := LogEnded(module, m, "", b.Node, b.now(), result) ended.OutOfStep = b.takeOutOfStep(key) // the generated files the build module's compare found out of step (design 26) b.logBuild(ended) - if result.State == builds.BuildDone && b.Numbers != nil && len(numbering.Versions) > 0 { - if err := b.Numbers.Built(ctx, module, m, plan, numbering, result.Artifacts); err != nil { - b.logf("%s: %v", cl.Key, err) - } - } if result.State == builds.BuildDone && hasReserved { digests := map[string]string{} for _, a := range result.Artifacts { diff --git a/modules/mesh-delivery-builder/internal/build/run_test.go b/modules/mesh-delivery-builder/internal/build/run_test.go index 383bca35b..87ee34b31 100644 --- a/modules/mesh-delivery-builder/internal/build/run_test.go +++ b/modules/mesh-delivery-builder/internal/build/run_test.go @@ -23,8 +23,6 @@ import ( stdio "git.novox.be/novox/mesh-sdk/go" "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/keys" - - "mesh-delivery-builder/internal/versions" ) // buildModules simulates the two build modules on the nodes: a long tool answers a step and key at once and writes the @@ -552,88 +550,21 @@ func TestABundleAndAnImageOfOneModuleBuildOnOneNodeEach(t *testing.T) { // 1705a } } -func TestATrunkImageCallCarriesPublish(t *testing.T) { // 1705b; design 51 *The versions*: numbered at the claim +func TestATrunkImageCallCarriesPublish(t *testing.T) { // 1705b; design 47 H §756: a trunk build is claimed and built, asking no floor r := newRig(t, imageArt) r.puller = "ace" - nums := &fakeNumbers{wait: "m/img: the package waits for its floor"} - r.b.Numbers = nums - r.b.Module(context.Background(), "m", moduleValue(t, "modules/m")) - r.b.Wait() - if _, ok := r.st.vals[r.key]; ok || nums.numbered != 1 { - t.Fatalf("a build waiting for its floor was claimed (numbered %d times)", nums.numbered) - } - nums.wait, nums.versions = "", map[string]string{"img": "0.1.4"} r.consider(t, "modules/m") calls := r.bm.callsOf("build_image_build") if len(calls) != 1 || calls[0].body.(map[string]any)["publish"] != true { t.Errorf("calls = %+v, want publish true", calls) } - if nums.built["img"] != digest { - t.Errorf("the built digest recorded = %v, want %s for img", nums.built, digest) - } - if nums.done != nil { - t.Errorf("a build still to make was numbered with done digests %v", nums.done) - } // The indexer's packages state names a package of the module (PackageNamed): the done build is looked at again and - // numbered with its key's digests, so version.numbered carries them for the late publish; nothing is built again. - looks := nums.numbered + // nothing is built again. r.b.PackageNamed(context.Background(), "m") r.b.Wait() - if nums.numbered != looks+1 || nums.done["img"] != digest || len(r.bm.callsOf("build_image_build")) != 1 { - t.Errorf("a named package's done build: numbered %d more times with %v, %d image builds; want once with img %s and no build", - nums.numbered-looks, nums.done, len(r.bm.callsOf("build_image_build")), digest) + if n := len(r.bm.callsOf("build_image_build")); n != 1 { + t.Errorf("a named package's done build was built again: %d image builds, want 1", n) } - // A late look that numbers a done build with no reservation is said aloud, naming builder_reserve_done (G §349, A-455). - late := &logged{} - r.b.Logf, r.b.Reserved = late.logf, &fakeReservations{filled: true} - r.b.PackageNamed(context.Background(), "m") - r.b.Wait() - if !late.has("late look numbered", "builder_reserve_done") { - t.Errorf("a late look numbered a done build with no reservation and said %v", late.lines) - } - r.b.Reserved = nil - looks = nums.numbered - r.b.PackageNamed(context.Background(), "other") - r.b.Wait() - if nums.numbered != looks { - t.Errorf("a module the builder does not know was looked at") - } - // D-B5 (ADR 0666 §15; design 47, test 70): a build whose published packages cannot be read is refused, naming the - // state: its key fails with why, and nothing is built. - unread := newRig(t, imageArt) - unread.puller = "ace" - unread.b.Numbers = &fakeNumbers{refused: "m/img: refused: the builder's state versions (bucket mesh-delivery-builder_versions) cannot be read"} - unread.b.Module(context.Background(), "m", moduleValue(t, "modules/m")) - unread.b.Wait() - if v := valueOf(t, unread.st, unread.key); v.State != builds.BuildFailed || !strings.Contains(v.Error, "state versions") || len(unread.bm.callsOf("build_image_build")) != 0 { - t.Errorf("a build with its versions unread: key %+v, %d builds; want failed naming the state, none built", v, len(unread.bm.callsOf("build_image_build"))) - } -} - -// fakeNumbers is Numbers that answers what it is set to and keeps the digests a done build recorded. -type fakeNumbers struct { - wait string - versions map[string]string - numbered int - built map[string]string - done map[string]string // the done key's digests the last look numbered with - refused string // answered as Numbering.Refused -} - -func (f *fakeNumbers) Number(_ context.Context, _ string, _ meshcatalog.ModulesByModuleValue, _ Plan, done map[string]string) (versions.Numbering, error) { - f.done = done - f.numbered++ - return versions.Numbering{Wait: f.wait, Versions: f.versions, Refused: f.refused}, nil -} - -func (f *fakeNumbers) Built(_ context.Context, _ string, _ meshcatalog.ModulesByModuleValue, _ Plan, got versions.Numbering, made []builds.BuiltArtifact) error { - f.built = map[string]string{} - for _, a := range made { - if got.Versions[a.Name] != "" { - f.built[a.Name] = a.Digest - } - } - return nil } func TestAnUnpinnedUpstreamFailsNotPinnedAndIsNeverBuiltAgain(t *testing.T) { // B3, ADR 0498 clause 4 diff --git a/modules/mesh-delivery-builder/internal/build/stuck.go b/modules/mesh-delivery-builder/internal/build/stuck.go index 84f08cc4c..a2c8173db 100644 --- a/modules/mesh-delivery-builder/internal/build/stuck.go +++ b/modules/mesh-delivery-builder/internal/build/stuck.go @@ -56,7 +56,7 @@ type ReAsk struct { Failed string `json:"failed,omitempty"` Revision uint64 `json:"revision,omitempty"` Asks map[string]string `json:"asks,omitempty"` - // Name is the numbered name (`/`) of a ModeFloorAgain value; Version is a ModeRepublish value's + // Name is the module or node a hand act names; Version is a ModeRepublish value's // request and Queued the builder's answer to it: the versions it queued, ` `. Name string `json:"name,omitempty"` Version string `json:"version,omitempty"` @@ -92,9 +92,6 @@ func NewPublishAct(mode, module, version, why, by string, at time.Time) (string, return mode + "." + strconv.FormatInt(at.UnixNano(), 10), data, err } -// ModeFloorAgain is the Mode of a reasks value of builder_floor_again (design 51 *The floor*). -const ModeFloorAgain = "floor-again" - // NewRepublish is the value builder_publish_again writes (design 47 G §588): its key, `republish.` // (a call is one value, never a build key), and the value. Module and version are each optional. func NewRepublish(module, version, why, by string, at time.Time) (string, []byte, error) { @@ -109,20 +106,6 @@ func NewRepublish(module, version, why, by string, at time.Time) (string, []byte return "republish." + strconv.FormatInt(at.UnixNano(), 10), data, err } -// NewFloorAgain is the value builder_floor_again writes for a name: the key `floor.`, never a build key, -// and the value. -func NewFloorAgain(name, why, by string, at time.Time) (string, []byte, error) { - name = strings.TrimSpace(name) - if module, artifact, ok := strings.Cut(name, "/"); !ok || module == "" || artifact == "" { - return "", nil, fmt.Errorf("name %q is not a numbered name, /, as builder_versions lists it", name) - } - if strings.TrimSpace(why) == "" { - return "", nil, errors.New("say why the floor is asked again (why)") - } - data, err := json.Marshal(ReAsk{V: 1, Why: strings.TrimSpace(why), By: by, At: at.UTC(), Mode: ModeFloorAgain, Name: name}) - return "floor." + versions.EscapeToken(name), data, err -} - // ModeOldFormDrop is the Mode of a reasks value of builder_old_form's drop (design 51 *Every build keeps the old // reference form*): a retired node dropped from the count by hand; Name is the node. const ModeOldFormDrop = "old-form-drop" diff --git a/modules/mesh-delivery-builder/internal/versions/again.go b/modules/mesh-delivery-builder/internal/versions/again.go index 3c3798756..2621ffbb5 100644 --- a/modules/mesh-delivery-builder/internal/versions/again.go +++ b/modules/mesh-delivery-builder/internal/versions/again.go @@ -2,22 +2,12 @@ package versions import ( "context" - "fmt" "time" ) -// The tools' descriptions. -const ( - FloorAgainDescription = "Refused for every name: the builder numbers nothing of its own and asks no floor (design 47 H H-A-159); " + - "a version is numbered by the reservation (design 47 G §369, builder_reserved). Kept until design 47 G §372 removes it with " + - "the state versions." -) - // Acts are the builder's hand acts on its versions, answered by its program (the tools bundle writes them to reasks). type Acts struct { Numberer *Numberer - // Reconsider looks at every module again, so a claim asks a name's floor. - Reconsider func(ctx context.Context) // Republish queues the reserved versions builder_publish_again names (design 47 G §588): the versions it queued. Republish func(ctx context.Context, module, version string) ([]string, error) // DropOldForm drops a retired node from the old form's count by hand (builder_old_form): its answer, or why not. @@ -30,10 +20,3 @@ type Acts struct { // PublishDrop terminates one publish item (builder_publish_drop, design 47 H2 §793): the answer, or why not. PublishDrop func(ctx context.Context, module, version, by, why string) (string, error) } - -// FloorAgain is builder_floor_again of name: refused, since the builder numbers nothing of its own and no claim asks a floor -// (design 47 H H-A-159; the reservation numbers, G §369). The tool stays until G §372 removes it with the state versions. -func (a Acts) FloorAgain(_ context.Context, name string) (string, error) { - return "", fmt.Errorf("the floor of %s is not asked: the builder numbers nothing of its own and asks no floor (design 47 H H-A-159); "+ - "a version is numbered by the reservation (G §369, builder_reserved)", name) -} diff --git a/modules/mesh-delivery-builder/internal/versions/claim.go b/modules/mesh-delivery-builder/internal/versions/claim.go index b54113236..86c67c3e5 100644 --- a/modules/mesh-delivery-builder/internal/versions/claim.go +++ b/modules/mesh-delivery-builder/internal/versions/claim.go @@ -2,10 +2,7 @@ package versions import ( "context" - "fmt" - "sort" "strings" - "time" ) // The registry seats a version is published to (design 51 *The seats*), by what is published. @@ -55,206 +52,8 @@ func TagPrefix(path string) string { return path + "/v" } -// ClaimArtifact is one artifact of a trunk build to number. -type ClaimArtifact struct { - Artifact, Kind, Language string -} - -// BuildClaim is a trunk build at its claim: what Numberer.Number numbers. -type BuildClaim struct { - Module, Path, Repository, Fingerprint, Commit, Series string - // Revision is the source revision of the merge (a package is numbered per revision); Merge its sequence, for order. - Revision string - Merge uint64 - Artifacts []ClaimArtifact - // Done are the digests of the build's done key, by artifact, when the claim is a look at a build already done: what it - // left unnumbered (a package whose name was not known yet, a floor that was silent) is numbered with them, so - // version.numbered carries the digest its build module publishes late. Nil for a build still to make. - Done map[string]string -} - -// Numbering is what the claim got. -type Numbering struct { - // Versions are each artifact's version, by artifact; an artifact built unnumbered (its floor not known) has none. - Versions map[string]string - // Unnumbered are the artifacts built and published by digest, numbered once their floor answers (ADR 0617 §1). - Unnumbered []string - // Wait is why the build waits: a package whose floor is not known (design 51 *The floor*). Nothing is claimed. - Wait string - // Said are the builder's narrations of each decision, for its process log and its build log (build.said). - Said []Narration - // Names are the names each numbered artifact was numbered under, by artifact (NameOf, or a package's name in its - // ecosystem). - Names map[string]string - // Refused is why the build is refused: a package's published versions could not be read (ADR 0666 §15). Nothing else - // is numbered. - Refused string -} - -// NameOf is the name artifact of module was numbered under in this numbering. -func (g Numbering) NameOf(module, artifact string) string { - if name := g.Names[artifact]; name != "" { - return name - } - return NameOf(module, artifact) -} - -// Narration is one line the builder says in its build log (design 51: the build log says a version was kept, and -// why), and what it narrates. -type Narration struct{ Line, Why string } - -// What a narration of the build log narrates (the build.said entry's why). -const ( - SaidNumbered = "numbered" - SaidKept = "kept" - SaidWaiting = "waiting" - SaidUnnumbered = "unnumbered" - SaidOldFormClosed = "old-form-closed" -) - -// narrationOf is a decision's narration. -func narrationOf(name string, d Decision) Narration { - why := SaidNumbered - switch { - case d.Keep: - why = SaidKept - case d.Wait: - why = SaidWaiting - case d.Unnumbered: - why = SaidUnnumbered - } - return Narration{Line: name + ": " + d.Why, Why: why} -} - -// Numberer numbers trunk builds at their claim (design 51 *The versions*, DLV-B2, B3): it asks a name's floor only -// when versions holds nothing for it, and records a silent floor as a wait (FloorWaits, woken by its source's event). +// Numberer holds the state versions kept from before G (design 51 *The versions*): the builder numbers nothing in it at a +// claim and asks no floor (design 47 H §756, H H-A-159); the registry seats' words still mark its entries (Heard). type Numberer struct { Versions Versions - Floor FloorSources - Waits *FloorWaits - // Holder is the module holding a seat, whose health condition's clear wakes a silent seat source; nil names none. - Holder func(seat string) string - // Names answers a package's name in its ecosystem; nil numbers a package as NameOf names it. - Names PackageNames - // Publishing is told each version Built recorded that is still numbered, its holder's word not heard yet: the - // builder arms its publish bound (publish.go); nil arms none. - Publishing func(ctx context.Context, e Entry) - Now func() time.Time -} - -// Number numbers every numbered artifact of c. An error is a store that cannot be read or written: the claim is then -// built as before, unnumbered, and said. -func (n *Numberer) Number(ctx context.Context, c BuildClaim) (Numbering, error) { - out := Numbering{Versions: map[string]string{}, Names: map[string]string{}} - arts := append([]ClaimArtifact(nil), c.Artifacts...) - sort.Slice(arts, func(i, j int) bool { return arts[i].Artifact < arts[j].Artifact }) - for _, a := range arts { - seat, kind, ok := SeatOf(a.Kind, a.Language) - if !ok { - continue - } - name := NameOf(c.Module, a.Artifact) - if kind == KindPackage && n.Names != nil { - // A package is numbered, asked for its floor and published under its name in its ecosystem (design 32), the - // name the holder's builder_versions question and the seat's versions name it by. - named, known, err := n.Names(ctx, c.Module, a.Artifact) - if err != nil || !known { - why := "the indexer's packages state names no name of it in its ecosystem yet (it writes one at the module's next trunk merge)" - if err != nil { - why = "the indexer's packages state cannot be read: " + err.Error() - } - out.Unnumbered = append(out.Unnumbered, a.Artifact) - out.Said = append(out.Said, Narration{Line: name + ": built unnumbered: " + why, Why: SaidUnnumbered}) - continue - } - name = named - } - out.Names[a.Artifact] = name - entries, err := n.Versions.Of(ctx, name) - if err != nil && kind == KindPackage { - // A build that cannot read the published packages refuses, naming the unread state, never building against a - // guess (ADR 0666 §15; design 51 *The versions*, line 287). - out.Refused = fmt.Sprintf("%s: refused: the builder's state %s cannot be read, so its published versions are not known: %v", name, State, err) - return out, nil - } - if err != nil { - return out, err - } - var floor Floor - var why map[string]string - if len(entries) == 0 { - floor, why = n.askFloor(ctx, seat, name, c) - } - d, _, err := n.Versions.Number(ctx, Claim{Name: name, Kind: kind, Series: c.Series, Module: c.Module, Fingerprint: c.Fingerprint, - Commit: c.Commit, Revision: c.Revision, Digest: c.Done[a.Artifact], Seat: seat, Merge: c.Merge, Floor: floor}) - if err != nil { - return out, err - } - out.Said = append(out.Said, narrationOf(name, d)) - switch { - case d.Wait: - n.wait(name, seat, floor, why) - out.Wait = name + ": " + d.Why - return out, nil - case d.Unnumbered: - n.wait(name, seat, floor, why) - out.Unnumbered = append(out.Unnumbered, a.Artifact) - continue - } - if n.Waits != nil { - n.Waits.Answered(name) - } - out.Versions[a.Artifact] = d.Version - } - return out, nil -} - -func (n *Numberer) askFloor(ctx context.Context, seat, name string, c BuildClaim) (Floor, map[string]string) { - return n.Floor.Ask(ctx, FloorOf{Seat: seat, Name: name, Repository: c.Repository, Prefix: TagPrefix(c.Path)}) -} - -func (n *Numberer) wait(name, seat string, f Floor, why map[string]string) { - if n.Waits == nil { - return - } - holder := "" - if n.Holder != nil { - holder = n.Holder(seat) - } - now := time.Now() - if n.Now != nil { - now = n.Now() - } - n.Waits.Wait(name, seat, holder, f, why, now) -} - -// Built records the digest each numbered artifact was built with, on an entry that holds none yet or was never published: what the holder's -// builder_versions question compares (ADR 0605 §4). -func (n *Numberer) Built(ctx context.Context, c BuildClaim, got Numbering, digests map[string]string) error { - var errs []string - for artifact, version := range got.Versions { - d := digests[artifact] - if d == "" { - continue - } - e, err := n.Versions.Mark(ctx, got.NameOf(c.Module, artifact), version, func(e *Entry) { - // The new digest replaces the recorded one only while no published was said for the number (design 51 - // *Tools of the builder*): a rebuild of a gone file under the same number. - if e.Digest == "" || e.State == Numbered || e.State == Refused { - e.Digest = d - } - }) - if err != nil { - errs = append(errs, err.Error()) - continue - } - if e.State == Numbered && n.Publishing != nil { - n.Publishing(ctx, e) - } - } - if len(errs) > 0 { - sort.Strings(errs) - return fmt.Errorf("the built digests could not be recorded: %s", strings.Join(errs, "; ")) - } - return nil } diff --git a/modules/mesh-delivery-builder/internal/versions/entrynames.go b/modules/mesh-delivery-builder/internal/versions/entrynames.go index e317b4a52..4d5ab9f08 100644 --- a/modules/mesh-delivery-builder/internal/versions/entrynames.go +++ b/modules/mesh-delivery-builder/internal/versions/entrynames.go @@ -122,20 +122,3 @@ func EntriesOf(branches *meshcatalogclient.Branches) Entries { func HolderOf(branches *meshcatalogclient.Branches) func(seat string) (string, bool) { return branches.Claimant } - -// RequirementsFrom answers the versions of a package the entries of every followed half require, each once, in order: what a -// consumer's entry names for it in its packages (design 47 G A-119), the floor's third source. -func RequirementsFrom(all Entries) func(ctx context.Context, name string) ([]string, error) { - return func(_ context.Context, name string) ([]string, error) { - seen := map[string]bool{} - var out []string - for _, e := range all() { - if v := e.Packages[name]; v != "" && !seen[v] { - seen[v] = true - out = append(out, v) - } - } - sort.Strings(out) - return out, nil - } -} diff --git a/modules/mesh-delivery-builder/internal/versions/entrynames_test.go b/modules/mesh-delivery-builder/internal/versions/entrynames_test.go index 7cb1276b3..4d94d3ce6 100644 --- a/modules/mesh-delivery-builder/internal/versions/entrynames_test.go +++ b/modules/mesh-delivery-builder/internal/versions/entrynames_test.go @@ -66,22 +66,3 @@ func TestPackageNamesAreReadFromTheCatalogHalfsEntries(t *testing.T) { t.Errorf("CarriersFrom(twin) = %v, want %v", got, want) } } - -// Design 47 G A-119: the floor's requirements are what the catalog half's entries name for the package, each version once. -func TestRequirementsFromAreTheVersionsEntriesNameForAPackage(t *testing.T) { - entries := func() []meshcatalog.CatalogEntry { - return []meshcatalog.CatalogEntry{ - {Module: "a", Packages: map[string]string{"x/sdk": "v0.0.0-2026-aaa", "y": "v1.0.0"}}, - {Module: "b", Packages: map[string]string{"x/sdk": "v0.0.0-2026-bbb"}}, - {Module: "c", Packages: map[string]string{"x/sdk": "v0.0.0-2026-aaa"}}, - {Module: "d"}, - } - } - got, err := RequirementsFrom(entries)(context.Background(), "x/sdk") - if err != nil || !reflect.DeepEqual(got, []string{"v0.0.0-2026-aaa", "v0.0.0-2026-bbb"}) { - t.Errorf("requirements = %v, %v", got, err) - } - if got, _ := RequirementsFrom(entries)(context.Background(), "none"); len(got) != 0 { - t.Errorf("a package no entry names has requirements %v", got) - } -} diff --git a/modules/mesh-delivery-builder/internal/versions/floor.go b/modules/mesh-delivery-builder/internal/versions/floor.go deleted file mode 100644 index a186bcb3f..000000000 --- a/modules/mesh-delivery-builder/internal/versions/floor.go +++ /dev/null @@ -1,332 +0,0 @@ -package versions - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "slices" - "sort" - "strings" - "sync" - "time" -) - -// FloorSources are the three sources of a name's floor (design 51 *The floor*): each a tool call that answers the -// versions it knows of a name, or an error when it does not answer. -type FloorSources struct { - // Seat is `seat:.versions` of the registry seat the name is published to. - Seat func(ctx context.Context, seat, name string) ([]string, error) - // Tags is the seat git's tags: the git tags of the repository the name is built from, under prefix. - Tags func(ctx context.Context, repository, prefix string) ([]string, error) - // Requirements are the versions of a package the catalog half's entries require (design 47 G A-119). - Requirements func(ctx context.Context, name string) ([]string, error) -} - -// FloorOf names what a floor is asked for: the name on its seat, and the repository and tag prefix of its git tags. -type FloorOf struct{ Seat, Name, Repository, Prefix string } - -// Ask asks the three sources of a name; a source that errs, or is not wired, is named in Silent with its error in why. -func (s FloorSources) Ask(ctx context.Context, of FloorOf) (Floor, map[string]string) { - seat, name := of.Seat, of.Name - var f Floor - why := map[string]string{} - ask := func(source string, call func() ([]string, error), into *[]string) { - if call == nil { - f.Silent, why[source] = append(f.Silent, source), "not asked: the builder has no path to it" - return - } - got, err := call() - if err != nil { - f.Silent, why[source] = append(f.Silent, source), err.Error() - return - } - *into = got - } - var seatCall, tagsCall, reqCall func() ([]string, error) - if s.Seat != nil { - seatCall = func() ([]string, error) { return s.Seat(ctx, seat, name) } - } - if s.Tags != nil { - tagsCall = func() ([]string, error) { return s.Tags(ctx, of.Repository, of.Prefix) } - } - if s.Requirements != nil { - reqCall = func() ([]string, error) { return s.Requirements(ctx, name) } - } - ask(SourceSeat, seatCall, &f.Seat) - ask(SourceTags, tagsCall, &f.Tags) - ask(SourceRequirements, reqCall, &f.Requirements) - return f, why -} - -// What wakes a name waiting on its floor, never a timer (design 51, DLV-B3b): the source that was silent saying -// something, or its module's health condition clearing. -const ( - // WakePublished is the holder's `published` on the builder's durable consumer of `.events`. - WakePublished = "published" - // WakeRevision is a catalog revision the builder hears (the catalog half's entry changed): tags and requirements are asked again. - WakeRevision = "catalog-revision" - // WakeTakenIn is the indexer's next `take-in.taken`, in place of the retired manifest-accepted: the floor looks at every - // module again (design 47 H H-A-116). - WakeTakenIn = "take-in.taken" - // WakeCleared is the condition keeper's clear of a silent module's health condition on `mesh-conditions`. - WakeCleared = "condition-cleared" - // WakeByHand is builder_floor_again, a hand act. - WakeByHand = "by hand" -) - -// sourceOfWake is the floor source each event says something of; a clear names the source by its module. -var sourceOfWake = map[string]string{WakePublished: SourceSeat, WakeTakenIn: SourceRequirements} - -// SourceSeats are the seats whose holders are the floor's tag and requirement sources (design 47 G A-82): the seat git (tags) -// and the seat mesh-catalog (requirements), the holders read from the seat list and the catalog half. -var SourceSeats = map[string]string{SourceTags: "git", SourceRequirements: "mesh-catalog"} - -// FloorWait is one name waiting on its floor: the sources still silent and why, since when; the finding the builder -// writes names them, cleared once all three answer. -type FloorWait struct { - Name string `json:"name"` - Seat string `json:"seat"` - Silent []string `json:"silent"` - Why map[string]string `json:"why,omitempty"` - Since time.Time `json:"since"` - // Holder is the module holding the name's seat: its condition's clear wakes the seat source. - Holder string `json:"holder,omitempty"` -} - -// Finding is the floor finding's words. -func (w FloorWait) Finding() string { - var parts []string - for _, s := range w.Silent { - p := s - if why := w.Why[s]; why != "" { - p += " (" + why + ")" - } - parts = append(parts, p) - } - return fmt.Sprintf("the floor of %s is not known since %s: %s did not answer; nothing of it is numbered until all three answer", - w.Name, w.Since.UTC().Format(time.RFC3339), strings.Join(parts, ", ")) -} - -// The builder's state floor-waits (DLV-B4): each name waiting on its floor, keyed by its escaped name, so a restarted -// builder still knows which names its silent sources' events wake; builder_floor_waits reads it. -const ( - FloorWaitsState = "floor-waits" - FloorWaitsTool = "builder_floor_waits" -) - -// FloorWaitKey is a wait's key in floor-waits. -func FloorWaitKey(name string) string { return EscapeToken(name) } - -// FloorKeeper keeps the waits on the bus: Put a wait's value, Delete its key. -type FloorKeeper interface { - Put(key string, value []byte) error - Delete(key string) error -} - -// FloorWaits are the names waiting on their floor. Wake answers which names to ask again for an event, Answered drops -// a name once all three answered; the builder's finding for each is the wait's Finding. Once Kept, every change is -// written to the state floor-waits as well. -type FloorWaits struct { - mu sync.Mutex - waits map[string]FloorWait - keeper FloorKeeper - // Logf says a wait that could not be kept; nil says nothing. - Logf func(string, ...any) - // Holder finds the module holding a seat (the catalog half's claim); a source's module is the holder of its SourceSeats seat. - Holder func(seat string) (string, bool) - // Said is told each wait recorded (raised) and each answered (not raised): the builder's finding floor-silent. - Said func(w FloorWait, raised bool) -} - -// FloorSilent is the kind of the floor finding. -const FloorSilent = "floor-silent" - -// Keep binds the state: the waits it holds that are not known here are taken in (a restarted builder's), every wait -// known here is written to it, and every change from now on is. -func (fw *FloorWaits) Keep(k FloorKeeper, held []FloorWait) { - fw.mu.Lock() - if fw.waits == nil { - fw.waits = map[string]FloorWait{} - } - for _, w := range held { - if _, had := fw.waits[w.Name]; !had && w.Name != "" { - fw.waits[w.Name] = w - } - } - fw.keeper = k - all := make([]FloorWait, 0, len(fw.waits)) - for _, w := range fw.waits { - all = append(all, w) - } - fw.mu.Unlock() - for _, w := range all { - fw.put(k, w) - } -} - -func (fw *FloorWaits) put(k FloorKeeper, w FloorWait) { - if k == nil { - return - } - data, err := json.Marshal(w) - if err == nil { - err = k.Put(FloorWaitKey(w.Name), data) - } - if err != nil && fw.Logf != nil { - fw.Logf("the floor wait of %s is not kept in %s (a restart forgets it until its next claim): %v", w.Name, FloorWaitsState, err) - } -} - -// DecodeFloorWait reads one value of floor-waits. -func DecodeFloorWait(raw []byte) (FloorWait, error) { - var w FloorWait - if err := json.Unmarshal(raw, &w); err != nil { - return FloorWait{}, err - } - if w.Name == "" { - return FloorWait{}, errors.New("a floor wait names no name") - } - return w, nil -} - -// Wait records that name's floor is not known. -func (fw *FloorWaits) Wait(name, seat, holder string, f Floor, why map[string]string, now time.Time) FloorWait { - fw.mu.Lock() - if fw.waits == nil { - fw.waits = map[string]FloorWait{} - } - w, had := fw.waits[name] - if !had { - w.Since = now - } - w.Name, w.Seat, w.Holder, w.Silent, w.Why = name, seat, holder, slices.Clone(f.Silent), why - fw.waits[name] = w - k := fw.keeper - fw.mu.Unlock() - fw.put(k, w) - if fw.Said != nil { - fw.Said(w, true) - } - return w -} - -// Answered drops name: its floor is known. It says whether the name waited, so its finding is cleared. -func (fw *FloorWaits) Answered(name string) bool { - fw.mu.Lock() - w, had := fw.waits[name] - delete(fw.waits, name) - k := fw.keeper - fw.mu.Unlock() - if had && fw.Said != nil { - fw.Said(w, false) - } - if had && k != nil { - if err := k.Delete(FloorWaitKey(name)); err != nil && fw.Logf != nil { - fw.Logf("the floor wait of %s is not cleared from %s: %v", name, FloorWaitsState, err) - } - } - return had -} - -// FloorWaitsAnswer is what builder_floor_waits answers: every name waiting on its floor, oldest first, with its finding. -type FloorWaitsAnswer struct { - Waits []FloorWaitRead `json:"waits"` -} - -// FloorWaitRead is one wait as builder_floor_waits shows it. -type FloorWaitRead struct { - FloorWait - Finding string `json:"finding"` -} - -// AnswerFloorWaits is builder_floor_waits, read from the state floor-waits. -func AnswerFloorWaits(r Reader) (FloorWaitsAnswer, error) { - keys, err := r.Keys() - if err != nil { - return FloorWaitsAnswer{}, err - } - out := FloorWaitsAnswer{Waits: []FloorWaitRead{}} - for _, k := range keys { - raw, ok, err := r.Get(k) - if err != nil { - return FloorWaitsAnswer{}, err - } - if !ok { - continue - } - w, err := DecodeFloorWait(raw) - if err != nil { - return FloorWaitsAnswer{}, fmt.Errorf("%s.%s: %w", FloorWaitsState, k, err) - } - out.Waits = append(out.Waits, FloorWaitRead{FloorWait: w, Finding: w.Finding()}) - } - sort.Slice(out.Waits, func(i, j int) bool { - if !out.Waits[i].Since.Equal(out.Waits[j].Since) { - return out.Waits[i].Since.Before(out.Waits[j].Since) - } - return out.Waits[i].Name < out.Waits[j].Name - }) - return out, nil -} - -// FloorWaitsDescription is builder_floor_waits' description. -const FloorWaitsDescription = "The names waiting on their floor (the builder's state floor-waits, design 51 *The floor*), oldest first: " + - "each name, its registry seat, the sources still silent and why, since when, and the finding the builder says for it. " + - "Nothing of a waiting name is numbered until all three sources answer; builder_floor_again asks one again by hand. Read-only." - -// Wake answers the names to ask their floor again on an event: kind one of the Wake constants; seat the seat a -// `published` came on; module the module whose condition cleared. A name is woken only when the event says something -// of a source it waits on; WakeByHand with a name wakes that name alone. -func (fw *FloorWaits) Wake(kind, seat, module, name string) []string { - fw.mu.Lock() - defer fw.mu.Unlock() - var out []string - for n, w := range fw.waits { - switch kind { - case WakeByHand: - if n == name { - out = append(out, n) - } - case WakeCleared: - for _, s := range w.Silent { - if fw.holds(SourceSeats[s], module) || (s == SourceSeat && w.Holder != "" && w.Holder == module) { - out = append(out, n) - break - } - } - default: - src := sourceOfWake[kind] - if kind == WakeRevision { - if slices.Contains(w.Silent, SourceTags) || slices.Contains(w.Silent, SourceRequirements) { - out = append(out, n) - } - } else if slices.Contains(w.Silent, src) && (kind != WakePublished || seat == "" || seat == w.Seat) { - out = append(out, n) - } - } - } - sort.Strings(out) - return out -} - -// Waiting is every wait, by name. -func (fw *FloorWaits) Waiting() []FloorWait { - fw.mu.Lock() - defer fw.mu.Unlock() - out := make([]FloorWait, 0, len(fw.waits)) - for _, w := range fw.waits { - out = append(out, w) - } - sort.Slice(out, func(i, j int) bool { return out[i].Name < out[j].Name }) - return out -} - -// holds is whether module holds seat on the catalog half. -func (fw *FloorWaits) holds(seat, module string) bool { - if seat == "" || module == "" || fw.Holder == nil { - return false - } - holder, ok := fw.Holder(seat) - return ok && holder == module -} diff --git a/modules/mesh-delivery-builder/internal/versions/heard.go b/modules/mesh-delivery-builder/internal/versions/heard.go index 12dc34c6b..9c8d6380b 100644 --- a/modules/mesh-delivery-builder/internal/versions/heard.go +++ b/modules/mesh-delivery-builder/internal/versions/heard.go @@ -30,15 +30,10 @@ type Outcome struct { // Heard takes one seat event in: a numbered version's entry turns published (with its digest when it held none), // refused with the holder's reason, removed with its reason and the event's id, or kept (another tag names its digest) // with the other tags; a by-digest publish (no version) -// marks nothing. It answers the names waiting on their floor that the event wakes: a `published` says the seat -// answers (design 51 *The floor*). -func (n *Numberer) Heard(ctx context.Context, seat, event, id string, o Outcome) ([]string, error) { - var wake []string - if event == HeardPublished && n.Waits != nil { - wake = n.Waits.Wake(WakePublished, seat, "", "") - } +// marks nothing. +func (n *Numberer) Heard(ctx context.Context, seat, event, id string, o Outcome) error { if o.Version == "" { - return wake, nil + return nil } var change func(*Entry) switch event { @@ -46,7 +41,7 @@ func (n *Numberer) Heard(ctx context.Context, seat, event, id string, o Outcome) // A published of other bytes than an entry records under its number is no publish of that entry: the reservation // numbered it and takes it in (design 47 H H-A-159, G §369, A-415; ADR 0605 §4), and the entry stays as it is. if e, ok, _, err := n.Versions.Recorded(ctx, o.Name, o.Version, o.Digest); err == nil && !ok && e.Digest != "" && o.Digest != "" && e.Digest != o.Digest { - return wake, fmt.Errorf("%s@%s is recorded with digest %s, so %s's published of %s is %w", o.Name, o.Version, e.Digest, seat, o.Digest, ErrNotNumbered) + return fmt.Errorf("%s@%s is recorded with digest %s, so %s's published of %s is %w", o.Name, o.Version, e.Digest, seat, o.Digest, ErrNotNumbered) } change = func(e *Entry) { e.State, e.Reason = Published, "" @@ -72,10 +67,10 @@ func (n *Numberer) Heard(ctx context.Context, seat, event, id string, o Outcome) } } default: - return wake, fmt.Errorf("%s says %q, which the builder does not hear", seat, event) + return fmt.Errorf("%s says %q, which the builder does not hear", seat, event) } if _, err := n.Versions.Mark(ctx, o.Name, o.Version, change); err != nil { - return wake, fmt.Errorf("%s's %s of %s@%s: %w", seat, event, o.Name, o.Version, err) + return fmt.Errorf("%s's %s of %s@%s: %w", seat, event, o.Name, o.Version, err) } - return wake, nil + return nil } diff --git a/modules/mesh-delivery-builder/internal/versions/oldform.go b/modules/mesh-delivery-builder/internal/versions/oldform.go index f7730ac48..c51f62c8f 100644 --- a/modules/mesh-delivery-builder/internal/versions/oldform.go +++ b/modules/mesh-delivery-builder/internal/versions/oldform.go @@ -25,6 +25,8 @@ import ( const ( OldFormState = "old-form" OldFormKey = "window" + // SaidOldFormClosed is the why of the build log's line saying the window closed (build.said). + SaidOldFormClosed = "old-form-closed" ) // OldFormHeld is the finding of a node holding the window open for FindingAfter, about that node, cleared when the diff --git a/modules/mesh-delivery-builder/internal/versions/store.go b/modules/mesh-delivery-builder/internal/versions/store.go index 5cdb30ca5..a24ac8fa9 100644 --- a/modules/mesh-delivery-builder/internal/versions/store.go +++ b/modules/mesh-delivery-builder/internal/versions/store.go @@ -68,58 +68,6 @@ func (v Versions) Of(ctx context.Context, name string) ([]Entry, error) { return InOrder(out), nil } -// Claim is one numbering asked of the builder. -type Claim struct { - Name, Kind, Series, Module, Fingerprint, Commit, Revision, Digest, Seat string - Merge uint64 - Floor Floor - // Fresh numbers anew a fingerprint or revision already numbered: builder_publish_again after a published (design 51 - // *Tools of the builder*). - Fresh bool -} - -// Number numbers a claim under compare-and-set: two claims of one name never get one number, the second reading the -// first's key and taking the next (ADR 0606 §2). It answers the decision and, when it numbered or kept a version, its -// entry. Attempts are bounded by the claims the name can meet at once; a store that keeps conflicting is an error. -func (v Versions) Number(ctx context.Context, c Claim) (Decision, Entry, error) { - if c.Series == "" { - c.Series = DefaultSeries - } - for attempt := 0; attempt < 16; attempt++ { - entries, err := v.Of(ctx, c.Name) - if err != nil { - return Decision{}, Entry{}, err - } - d := Decide(fresh(entries, c), c.Kind, c.Series, c.Fingerprint, c.Revision, c.Floor) - if d.Version == "" { - return d, Entry{}, nil - } - if d.Keep { - for _, e := range entries { - if e.Version == d.Version { - return d, e, nil - } - } - } - e := Entry{Name: c.Name, Kind: c.Kind, Series: c.Series, Version: d.Version, Module: c.Module, - Fingerprint: c.Fingerprint, Commit: c.Commit, Revision: c.Revision, Digest: c.Digest, Seat: c.Seat, - State: Numbered, At: v.now(), Merge: c.Merge} - raw, err := Encode(e) - if err != nil { - return Decision{}, Entry{}, err - } - _, err = v.Store.Create(ctx, Key(c.Name, d.Version), raw) - if errors.Is(err, ErrConflict) { - continue // another claim took this number: read again and take the next - } - if err != nil { - return Decision{}, Entry{}, fmt.Errorf("%s@%s: %w", c.Name, d.Version, err) - } - return d, e, nil - } - return Decision{}, Entry{}, fmt.Errorf("%s: the versions kept changing under 16 claims", c.Name) -} - // ErrNotNumbered is a version the state versions does not hold (design 51's numbering by name): a version the reservation // numbered (§369) is never held there. var ErrNotNumbered = errors.New("not numbered by the builder") @@ -186,22 +134,6 @@ func (v Versions) now() time.Time { return time.Now().UTC() } -// fresh is entries as Decide reads them for c: with Fresh, the entries of c's fingerprint and revision still count for the -// next number but keep none. -func fresh(entries []Entry, c Claim) []Entry { - if !c.Fresh { - return entries - } - out := make([]Entry, len(entries)) - for i, e := range entries { - if e.Tag == "" && (e.Fingerprint == c.Fingerprint || (c.Revision != "" && e.Revision == c.Revision)) { - e.Fingerprint, e.Revision = "", "" - } - out[i] = e - } - return out -} - // All is every entry of every name, by name in order: what the versions' readers read. func (v Versions) All(ctx context.Context) ([]Entry, error) { keys, err := v.Store.KeysOf(ctx, AllFilter) diff --git a/modules/mesh-delivery-builder/internal/versions/tools.go b/modules/mesh-delivery-builder/internal/versions/tools.go index 8a562cbf5..499c99ce9 100644 --- a/modules/mesh-delivery-builder/internal/versions/tools.go +++ b/modules/mesh-delivery-builder/internal/versions/tools.go @@ -14,7 +14,6 @@ import ( const ( VersionsTool = "builder_versions" PublishAgainTool = "builder_publish_again" - FloorAgainTool = "builder_floor_again" OldFormTool = "builder_old_form" // OldFormClosedEvent is the builder's own family `version`, kept seven days, // apart from its builds' ends, so a waiter on a build's end does not wake on them. diff --git a/modules/mesh-delivery-builder/internal/versions/versions.go b/modules/mesh-delivery-builder/internal/versions/versions.go index b04dd7ca9..4488bf049 100644 --- a/modules/mesh-delivery-builder/internal/versions/versions.go +++ b/modules/mesh-delivery-builder/internal/versions/versions.go @@ -182,125 +182,6 @@ func Patch(series, version string) (int, bool) { return n, true } -// Floor is what the three sources answered for a name (design 51 *The floor*, ADR 0606 §3): the seat's versions, the -// package's git tags (the seat git's tags) and the pseudo-versions consumers require (the catalog half's -// indexer_requirements). A source not answered is listed in Silent. -type Floor struct { - Seat []string `json:"seat,omitempty"` - Tags []string `json:"tags,omitempty"` - Requirements []string `json:"requirements,omitempty"` - // Silent names the sources that did not answer: "seat", "git.tags", "catalog.requirements". - Silent []string `json:"silent,omitempty"` -} - -// The floor's sources, as Floor.Silent names them. -const ( - SourceSeat = "seat" - SourceTags = "git.tags" - SourceRequirements = "catalog.requirements" -) - -// Known is whether every source answered. -func (f Floor) Known() bool { return len(f.Silent) == 0 } - -// Highest is the highest count of series the floor's three sources name, -1 when none names one. A pseudo-version -// (`v0.1.14-0.2026…-abc`) counts as the version below it was cut from, so its base (`0.1.13`) counts: Go orders it -// before `0.1.14`. -func (f Floor) Highest(series string) int { - high := -1 - for _, list := range [][]string{f.Seat, f.Tags, f.Requirements} { - for _, v := range list { - n, ok := Patch(series, v) - if !ok { - n, ok = pseudoBase(series, v) - } - if ok && n > high { - high = n - } - } - } - return high -} - -// pseudoBase is the count a Go pseudo-version stands on: `v0.1.14-0.