From d0efbee65b3b4b935253696383f604e50a644805 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 16 Nov 2026 13:36:49 +0100 Subject: [PATCH] take-in.taken names the catalog graph revision the take-in made (A-448) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds: design 47 G (G-22 lead answers 2) A-448; §476, §493 --- .../go/seats/meshcatalog/contract.go | 2 ++ .../seats/mesh-catalog/seat.json | 4 ++++ .../ts/seats/meshcatalog/index.d.ts | 2 ++ .../internal/index/catalog_revisions.go | 13 +++++++++++++ .../mesh-delivery-indexer/internal/index/pending.go | 3 ++- .../internal/index/pending_test.go | 3 +++ modules/mesh-delivery-indexer/takein/takein.go | 8 +++++--- 7 files changed, 31 insertions(+), 4 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go index 61f1966b..59ca3d53 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go @@ -1154,6 +1154,8 @@ type TakeInTaken struct { OwnBuildUnknown string `json:"own-build-unknown,omitempty"` // why the manifest of the indexer the revision names was refused Refused string `json:"refused,omitempty"` + // the catalog graph revision of the branch the take-in made, which the pipelines of its entries start at (design 47 G section 476, A-448) + Revision int64 `json:"revision,omitempty"` // when the wait began Since time.Time `json:"since"` // the source revision taken in (design 47 G section 476) diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json index 323a0447..118c8e13 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json @@ -2959,6 +2959,10 @@ }, "description": "the merges it holds, oldest first" }, + "revision": { + "type": "integer", + "description": "the catalog graph revision of the branch the take-in made, which the pipelines of its entries start at (design 47 G section 476, A-448)" + }, "group": { "type": "string", "description": "the delivery group, for a group being gathered" 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 d26823b6..6f31c3a3 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts @@ -608,6 +608,8 @@ export interface TakeInTaken { "own-build-unknown"?: string; /** why the manifest of the indexer the revision names was refused */ "refused"?: string; + /** the catalog graph revision of the branch the take-in made, which the pipelines of its entries start at (design 47 G section 476, A-448) */ + "revision"?: number; /** when the wait began */ "since": string; /** the source revision taken in (design 47 G section 476) */ diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go index d78477b7..ca51d308 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go @@ -657,3 +657,16 @@ func (ix *Indexer) manifestBytes(ctx context.Context, digest string) string { } return raw } + +// NewestRevision is the number of the newest catalog graph revision kept for the watched branch, 0 when none is kept: the +// revision a take-in has just made, said with its take-in.taken (design 47 G §476, A-448). +func (ix *Indexer) NewestRevision(ctx context.Context, branch string) int64 { + if ix.Revisions == nil { + return 0 + } + newest, any, err := newestOf(ctx, ix.Revisions, branch) + if err != nil || !any { + return 0 + } + return newest.Revision +} diff --git a/modules/mesh-delivery-indexer/internal/index/pending.go b/modules/mesh-delivery-indexer/internal/index/pending.go index 97abbf0e..a6c3c08d 100644 --- a/modules/mesh-delivery-indexer/internal/index/pending.go +++ b/modules/mesh-delivery-indexer/internal/index/pending.go @@ -1170,9 +1170,10 @@ func (ix *Indexer) takeInWholeBy(ctx context.Context, entries []PendingEntry, ow ix.forget(claimed...) branch, src, took := ix.takenWhat(ctx, claimed, applied) ix.logf("take-in: %d merges taken in as one revision by %s%s, oldest %s: source revision %d of %s, %d entries", len(claimed), own, byWords(by), claimed[0].Key, src, branch, len(took)) + revision := ix.NewestRevision(ctx, branch) // the revision this take-in just kept (A-448) for _, t := range takenWaits(claimed) { t.By, t.Why = who, why - t.Branch, t.Source, t.Entries = branch, src, took + t.Branch, t.Source, t.Entries, t.Revision = branch, src, took, revision ix.sayTakeIn(ctx, t) } return applied, nil diff --git a/modules/mesh-delivery-indexer/internal/index/pending_test.go b/modules/mesh-delivery-indexer/internal/index/pending_test.go index 230369d4..b051c2d4 100644 --- a/modules/mesh-delivery-indexer/internal/index/pending_test.go +++ b/modules/mesh-delivery-indexer/internal/index/pending_test.go @@ -1000,6 +1000,7 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633) !strings.Contains(r.Answer, TakeInPendingTool) || len(b.keys()) != 1 { t.Fatalf("a drop nothing covers: %+v, pending %v", r, b.keys()) } + b.ix.Revisions = newMemObjects(0) // A-448: the taken event names the catalog graph revision the take-in made b.said = nil if r := b.ix.TakeInPendingByHand(ctx, takein.PendingKey(3), "lead@shanks", "the named indexer can never run"); !r.Stored { t.Fatalf("hand take-in: %+v", r) @@ -1013,6 +1014,8 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633) if got.Branch != TrunkBranch || got.Source <= 0 || len(got.Entries) != 1 || got.Entries[0].Module != "avahi" || got.Entries[0].Commit != sha('d') || got.Entries[0].Fingerprint == "" { t.Errorf("hand take-in said branch %q source %d entries %+v: want main, a source revision and avahi at its commit", got.Branch, got.Source, got.Entries) + } else if newest, any, _ := newestTrunk(ctx, b.ix.Revisions); !any || got.Revision != newest.Revision { + t.Errorf("hand take-in said revision %d, want the revision it made, %d (A-448)", got.Revision, newest.Revision) } else if _, err := takein.EncodeTakeIn(got); err != nil { t.Errorf("the taken event is refused by its own contract: %v", err) } diff --git a/modules/mesh-delivery-indexer/takein/takein.go b/modules/mesh-delivery-indexer/takein/takein.go index 7b559d64..66923591 100644 --- a/modules/mesh-delivery-indexer/takein/takein.go +++ b/modules/mesh-delivery-indexer/takein/takein.go @@ -151,9 +151,11 @@ type TakeIn struct { // Branch, Source and Entries are what a take-in took in (design 47 G §476, §493, §648): the watched branch, the source // revision it makes of that branch, and one entry per module it wrote. Every taken event of one take-in carries the same; // a taken event that ends a wait without a take-in (a group's end, a drop) carries none and starts no pipeline. - Branch string `json:"branch,omitempty"` - Source int64 `json:"source,omitempty"` - Entries []meshcatalog.TakeInEntry `json:"entries,omitempty"` + Branch string `json:"branch,omitempty"` + Source int64 `json:"source,omitempty"` + // Revision is the catalog graph revision of the branch the take-in made (A-448): the pipelines of its entries start at it. + Revision int64 `json:"revision,omitempty"` + Entries []meshcatalog.TakeInEntry `json:"entries,omitempty"` } func (t TakeIn) check() error {