diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go index 9029f776..1ad5e63d 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go @@ -717,7 +717,7 @@ type CatalogRevision struct { Branch string `json:"branch,omitempty"` // what made the revision (design 47 H-A-212, H-A-213): a take-in's the gate's call its source revision names, a re-pin's release of , a take-in again's take-in again of ; absent for a candidate's Call string `json:"call,omitempty"` - // the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215): a take-in's, a re-pin's on a module's release, a take-in again's; absent for a candidate's + // the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215, H-A-217): a take-in's, a re-pin's on a module's release, a take-in again's, a recompute's that moved a fingerprint (its call naming the reason); absent for a candidate's CallKind string `json:"call-kind,omitempty"` // the seat definitions it was judged with, each by its digest, read whole through seat-definitions Definitions []CatalogRevisionDefinitionsItem `json:"definitions,omitempty"` @@ -752,6 +752,7 @@ const ( CatalogRevisionCallKindTakeIn = "take-in" CatalogRevisionCallKindRelease = "release" CatalogRevisionCallKindTakeInAgain = "take-in-again" + CatalogRevisionCallKindRecompute = "recompute" ) // Edge is one edge of the catalog graph between artifact references, B before A (ADR 0666 section 14): kind 1 B published before A builds (a package A imports), 2 B published before A delivers (fetched by reference at its start), 3 B delivered before A builds (its build module and toolchain), 4 B delivered before A delivers (a provision, bus state, a format's reader), 5 B has acted for A's new version (an acting rule), 6 B runs a version that serves A (a verb or a manifest word A uses). @@ -1320,7 +1321,7 @@ type CatalogRevisionEvent struct { Branch string `json:"branch,omitempty"` // what made the revision, as the revision's call names it (design 47 H-A-212, H-A-213); absent for a candidate's Call string `json:"call,omitempty"` - // the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215); absent for a candidate's + // the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215, H-A-217); absent for a candidate's CallKind string `json:"call-kind,omitempty"` // the modules whose entries differ from the revision before it of the same kind Changed []string `json:"changed,omitempty"` @@ -1346,6 +1347,7 @@ const ( CatalogRevisionEventCallKindTakeIn = "take-in" CatalogRevisionEventCallKindRelease = "release" CatalogRevisionEventCallKindTakeInAgain = "take-in-again" + CatalogRevisionEventCallKindRecompute = "recompute" ) // FillingEvent is the body of the event filling. diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json index e0195d64..164a7576 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json @@ -666,9 +666,10 @@ "enum": [ "take-in", "release", - "take-in-again" + "take-in-again", + "recompute" ], - "description": "the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215); absent for a candidate's" + "description": "the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215, H-A-217); absent for a candidate's" }, "module": { "type": "string", @@ -1905,9 +1906,10 @@ "enum": [ "take-in", "release", - "take-in-again" + "take-in-again", + "recompute" ], - "description": "the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215): a take-in's, a re-pin's on a module's release, a take-in again's; absent for a candidate's" + "description": "the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215, H-A-217): a take-in's, a re-pin's on a module's release, a take-in again's, a recompute's that moved a fingerprint (its call naming the reason); absent for a candidate's" }, "module": { "type": "string", diff --git a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts index 1fcf459d..1bef6feb 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts @@ -279,8 +279,8 @@ export interface CatalogRevision { "branch"?: string; /** what made the revision (design 47 H-A-212, H-A-213): a take-in's the gate's call its source revision names, a re-pin's release of , a take-in again's take-in again of ; absent for a candidate's */ "call"?: string; - /** the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215): a take-in's, a re-pin's on a module's release, a take-in again's; absent for a candidate's */ - "call-kind"?: "take-in" | "release" | "take-in-again"; + /** the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215, H-A-217): a take-in's, a re-pin's on a module's release, a take-in again's, a recompute's that moved a fingerprint (its call naming the reason); absent for a candidate's */ + "call-kind"?: "take-in" | "release" | "take-in-again" | "recompute"; /** the seat definitions it was judged with, each by its digest, read whole through seat-definitions */ "definitions"?: CatalogRevisionDefinitionsItem[]; /** one per module, by name */ @@ -808,8 +808,8 @@ export interface CatalogRevisionEvent { "branch"?: string; /** what made the revision, as the revision's call names it (design 47 H-A-212, H-A-213); absent for a candidate's */ "call"?: string; - /** the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215); absent for a candidate's */ - "call-kind"?: "take-in" | "release" | "take-in-again"; + /** the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215, H-A-217); absent for a candidate's */ + "call-kind"?: "take-in" | "release" | "take-in-again" | "recompute"; /** the modules whose entries differ from the revision before it of the same kind */ "changed"?: string[]; /** how many entries it lists */ diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go index bcf46813..76a24231 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -433,7 +433,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro done() done = step("following the assignments") followAssignments(ctx, reader, seatHolders.holders(), process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, views.StatusState), "indexer_first_views reads nothing and indexer_first_view_again is not heard", logger.Printf), cred, js, gate, func(ctx context.Context) { - if err := ix.Recompute(ctx); err != nil { + if err := ix.RecomputeKept(ctx, "the assignments of a build module"); err != nil { logger.Printf("writing the modules again after the assignments of a build module changed: %v", err) } }, logger.Printf) @@ -449,7 +449,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // the toolchain. return ix.ToolchainReported(ctx) }, - recompute: ix.Recompute}, func() []string { return buildModuleNames(ix.BuildModules()) }, logger) + recompute: func(ctx context.Context) error { return ix.RecomputeKept(ctx, "the toolchains read") }}, func() []string { return buildModuleNames(ix.BuildModules()) }, logger) if err := tools.start(); err != nil { return err } diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go index 2110f08f..548e8c93 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go @@ -478,6 +478,15 @@ func takeInAgainCall(repository string) revisionCall { return revisionCall{Call: TakeInAgainCall(repository), Kind: meshcatalog.CatalogRevisionCallKindTakeInAgain, Repository: repository} } +// recomputeCall is a recompute's that moved a fingerprint, its call naming the reason (H-A-217). +func recomputeCall(reason string) revisionCall { + return revisionCall{Call: RecomputeCall(reason), Kind: meshcatalog.CatalogRevisionCallKindRecompute} +} + +// RecomputeCall is the call of the catalog revision a recompute keeps: its reason, such as the assignments of a build module, +// a toolchain or a hand act (design 47 H-A-217). +func RecomputeCall(reason string) string { return "recompute on " + reason } + // HeldObjectsFull is the reason a pending merge is held while the catalog graph revisions are full (Pending.Held). const HeldObjectsFull = "objects full" diff --git a/modules/mesh-delivery-indexer/internal/index/revision_tools.go b/modules/mesh-delivery-indexer/internal/index/revision_tools.go index 279e41e8..cd98aba6 100644 --- a/modules/mesh-delivery-indexer/internal/index/revision_tools.go +++ b/modules/mesh-delivery-indexer/internal/index/revision_tools.go @@ -272,7 +272,7 @@ func (ix *Indexer) RecomputeByHand(ctx context.Context, by, why string) TakenIn r.Answer = "the newest catalog graph revision cannot be read: " + err.Error() return r } - if err := ix.Recompute(ctx); err != nil { + if err := ix.RecomputeKept(ctx, fmt.Sprintf("a hand act by %s (%s)", by, why)); err != nil { r.Answer = "the recompute failed: " + err.Error() return r } diff --git a/modules/mesh-delivery-indexer/internal/index/take_in_again_test.go b/modules/mesh-delivery-indexer/internal/index/take_in_again_test.go index 1e114d53..1fe65e2d 100644 --- a/modules/mesh-delivery-indexer/internal/index/take_in_again_test.go +++ b/modules/mesh-delivery-indexer/internal/index/take_in_again_test.go @@ -92,4 +92,22 @@ func TestATakeInAgainReachesARepositoryWithNoMergeSince(t *testing.T) { len(rev.Movers) != 1 || rev.Movers[0].Module != "g" || rev.Movers[0].Fingerprint != m.Fp2 { t.Errorf("the newest trunk revision = %+v (%v), want revision 2 of source 4 with the take-in again's call and g its mover", rev, err) } + // H-A-217: a recompute that moves no fingerprint keeps nothing; one that moves one (a toolchain reported) keeps the trunk's + // next revision of the same source, its call-kind recompute, its call naming the reason, the moved modules its movers. + if err := ix.RecomputeKept(ctx, "the assignments of a build module"); err != nil { + t.Fatal(err) + } + if rev, _, _, _ := readNewestOf(ctx, ix.Revisions, TrunkBranch); rev.Revision != 2 { + t.Errorf("a recompute that moved nothing kept revision %d (%s), want none", rev.Revision, rev.Call) + } + reportToolchainRecipe(t, ix, "mesh-build-go", "novox", "go", "go1.27.1", "2") // a recipe change moves a Go module at once + moved, _ := moduleOf(t, mods, "g") + rev, _, found, err = readNewestOf(ctx, ix.Revisions, TrunkBranch) + if err != nil || !found || rev.Revision != 3 || rev.Source != 4 || rev.CallKind != meshcatalog.CatalogRevisionCallKindRecompute || + rev.Call != RecomputeCall("a toolchain reported") || !slices.ContainsFunc(rev.Movers, func(e meshcatalog.TakeInEntry) bool { + return e.Module == "g" && e.Fingerprint == moved.Fp2 && moved.Fp2 != m.Fp2 + }) { + t.Errorf("after a toolchain reported: the newest trunk revision = %+v (%v), want revision 3 of source 4, kind recompute, g its mover at %s (was %s)", + rev, err, moved.Fp2, m.Fp2) + } } diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index b0043487..dfba512a 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -79,9 +79,22 @@ func (ix *Indexer) ApplyToolchain(ctx context.Context, module, key string, value return ix.ToolchainReported(ctx) } -// ToolchainReported is what a changed toolchain moves: the modules written again (Recompute). +// ToolchainReported is what a changed toolchain moves: the modules written again, kept as a revision (RecomputeKept). func (ix *Indexer) ToolchainReported(ctx context.Context) error { - return ix.Recompute(ctx) + return ix.RecomputeKept(ctx, "a toolchain reported") +} + +// RecomputeKept is Recompute kept as a re-pin is (design 47 H-A-217): when it moved at least one fingerprint against the +// trunk's newest revision, it keeps the trunk's next revision of the same source, its movers the modules that moved, its +// call-kind recompute and its call naming reason, pinned for its pipeline, and says catalog-revision; one that moves none +// keeps nothing. Recompute writes the trunk's modules state, so only the trunk's revision is kept. +func (ix *Indexer) RecomputeKept(ctx context.Context, reason string) error { + ix.pendingMu.Lock() // one take-in step at a time, so the trunk's newest stays the one compared against (pending.go) + defer ix.pendingMu.Unlock() + if err := ix.Recompute(ctx); err != nil { + return err + } + return ix.keepRepinned(ctx, ix, TrunkBranch, recomputeCall(reason), nil) } // agreed is the toolchain of each language every reporting node agrees on, or why there is none. @@ -544,7 +557,7 @@ func (ix *Indexer) RecomputeAtStart(ctx context.Context) error { ix.logf("no toolchain is read yet: the new-form fingerprints are computed when one is") return nil } - return ix.Recompute(ctx) + return ix.RecomputeKept(ctx, "the indexer's start") } // fillPaths gives every module whose key names no directory (a key written before the indexer learned paths) the one its @@ -702,7 +715,7 @@ func (ix *Indexer) keepRepinned(ctx context.Context, x *Indexer, branch string, } var movers []meshcatalog.TakeInEntry moved := slices.Sorted(maps.Keys(only)) - if only == nil { // a take-in again: every module whose fingerprint moved (H-A-212) + if only == nil { // a take-in again or a recompute: every module whose fingerprint moved (H-A-212, H-A-217) moved = slices.Sorted(maps.Keys(entries)) } for _, key := range moved {