From 8a71e32149b50ead2ac9afdaf2b7c5f1ea5ca477 Mon Sep 17 00:00:00 2001 From: matst80 Date: Sun, 28 Jun 2026 21:42:46 +0200 Subject: [PATCH] catalog: log ProjectionStore delta applies + greppable snapshot line Restore the per-batch visibility lost in the cart migration: applyDelta now logs 'delta applied epoch=N (+U/-D, overlay=X)', and the snapshot swap line includes 'snapshot' so it's findable. Deltas were applying silently, which read as 'nothing happened' on a bulk catalog update (only the debounced snapshot swap was logged). Co-Authored-By: Claude Opus 4.8 (1M context) --- catalog/consumer.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/catalog/consumer.go b/catalog/consumer.go index 1e46a03..54348e0 100644 --- a/catalog/consumer.go +++ b/catalog/consumer.go @@ -196,7 +196,7 @@ func (s *ProjectionStore[T]) endSnapshot(epoch int64, meta map[string]string) er } s.epoch = epoch s.overlay = make(map[string]overlayEntry[T]) // base now includes everything ≤ epoch - log.Printf("catalog: ProjectionStore base swapped epoch=%d (%d entries)", epoch, s.buildingSeen) + log.Printf("catalog: ProjectionStore snapshot applied — base swapped epoch=%d (%d entries)", epoch, s.buildingSeen) return nil } @@ -222,16 +222,23 @@ func (s *ProjectionStore[T]) applyDelta(epoch int64, payload []byte) error { // this epoch; the consumer's fallback covers reads until then. return nil } + var upserts, deletes int for _, u := range ups { if u.SKU == "" { continue } if u.Deleted { s.overlay[u.SKU] = overlayEntry[T]{deleted: true} + deletes++ continue } // Transform applied here too — overlay holds the consumer's shape. s.overlay[u.SKU] = overlayEntry[T]{val: s.transform(u.Projection)} + upserts++ + } + if upserts+deletes > 0 { + log.Printf("catalog: ProjectionStore delta applied epoch=%d (+%d/-%d, overlay=%d)", + epoch, upserts, deletes, len(s.overlay)) } return nil }