:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(web-analytics): keep repeatedly check-missed shapes warm via sticky selection (#93054)
Lucas Ricoyee6be3d5e959
diff --git a/products/web_analytics/backend/hogql_queries/test/test_web_lazy_precompute_common.py b/products/web_analytics/backend/hogql_queries/test/test_web_lazy_precompute_common.pyindex a74626324836..9b60f1e71cb4 100644--- a/products/web_analytics/backend/hogql_queries/test/test_web_lazy_precompute_common.py+++ b/products/web_analytics/backend/hogql_queries/test/test_web_lazy_precompute_common.py@@ -1,3 +1,5 @@+import json+import timefrom datetime import UTC, datetimeimport time_machine@@ -45,6 +47,7 @@ from products.web_analytics.backend.hogql_queries.web_lazy_precompute_common impREVALIDATION_TRIGGER,SESSION_SETTLING_SECONDS,STALE_WHILE_REVALIDATE_SECONDS,+ STICKY_WARM_SHAPES_KEY,TEAM_SHAPE_SET_TTL_SECONDS,VOLUME_FLOOR_READY_KEY,VOLUME_FLOOR_TEAMS_KEY,@@ -54,10 +57,12 @@ from products.web_analytics.backend.hogql_queries.web_lazy_precompute_common impPropertyAccessControlled,UnsupportedFilterType,_oom_pin_key,+ _sticky_team_count_key,_team_shape_set_key,check_common_eligibility,compute_filters_eligibility_hash,compute_shape_cap_key,+ get_sticky_warm_shapes,handle_stale_served,host_filter_expr,is_precompute_enabled_for_team,@@ -67,6 +72,7 @@ from products.web_analytics.backend.hogql_queries.web_lazy_precompute_common implog_eligibility_outcome,pin_team_oom,publish_volume_floor_teams,+ record_sticky_warm_shape,try_reserve_precompute_shape,web_ensure_precomputed,)@@ -840,6 +846,111 @@ class TestWebEnsurePrecomputed(BaseTest):assert schedule.get_ttl(fresh_window_start) == 3600+class TestStickyWarmShapes(BaseTest):+ def setUp(self):+ super().setUp()+ redis.get_client().delete(STICKY_WARM_SHAPES_KEY, _sticky_team_count_key(self.team.id))++ def tearDown(self):+ redis.get_client().delete(STICKY_WARM_SHAPES_KEY, _sticky_team_count_key(self.team.id))+ super().tearDown()++ def _runner(self, query=None):+ runner = mock.Mock()+ runner.team = self.team+ runner.query = query or _overview()+ runner._test_account_filters = []+ return runner++ def test_single_miss_leaves_only_a_marker(self):+ # A one-off exploration (a filter combo tried once) must never be+ # warmed — the whole point of the two-touch bar. First miss = marker,+ # invisible to the warmer.+ record_sticky_warm_shape(team=self.team, runner=self._runner())+ assert get_sticky_warm_shapes() == []+ assert redis.get_client().hlen(STICKY_WARM_SHAPES_KEY) == 1 # the marker++ def test_second_miss_upgrades_and_date_variants_share_one_entry(self):+ # Date-range variants share one bucket namespace, so their misses must+ # count as touches of ONE entry — otherwise the warmer replays the same+ # namespace once per variant. Two variant misses = two touches = sticky.+ record_sticky_warm_shape(team=self.team, runner=self._runner(_overview(date_from="-7d")))+ record_sticky_warm_shape(team=self.team, runner=self._runner(_overview(date_from="-30d")))+ # A different shape (filters) touched once stays a marker.+ filtered = _overview(properties=[EventPropertyFilter(key="$host", value="a.com", operator="exact")])+ record_sticky_warm_shape(team=self.team, runner=self._runner(filtered))++ entries = get_sticky_warm_shapes()+ assert len(entries) == 1+ assert entries[0]["team_id"] == self.team.id+ assert entries[0]["query"]["kind"] == "WebOverviewQuery"+ # A third miss of the sticky shape is a no-op, not a rewrite.+ record_sticky_warm_shape(team=self.team, runner=self._runner(_overview(date_from="-7d")))+ assert len(get_sticky_warm_shapes()) == 1++ def test_oversized_query_stays_a_marker(self):+ # A multi-megabyte filter value must not be retained in shared Redis for the+ # entry's lifetime. The second miss would upgrade the marker to a full entry,+ # but the oversized payload keeps it a marker instead.+ huge = _overview(properties=[EventPropertyFilter(key="$host", value="x" * 60_000, operator="exact")])+ record_sticky_warm_shape(team=self.team, runner=self._runner(huge))+ record_sticky_warm_shape(team=self.team, runner=self._runner(huge))+ assert get_sticky_warm_shapes() == []+ assert redis.get_client().hlen(STICKY_WARM_SHAPES_KEY) == 1 # marker only, never upgraded++ @mock.patch(f"{_COMMON}.STICKY_SHAPE_MAX_PER_TEAM", 1)+ def test_per_team_cap_refuses_new_shapes_but_still_upgrades_own_marker(self):+ # One tenant must not fill the shared hash and starve others: past its+ # per-team cap, new distinct shapes are refused even though the global+ # hash is nowhere near full. Upgrading the team's own existing marker+ # adds no field, so it must still proceed.+ record_sticky_warm_shape(team=self.team, runner=self._runner()) # shape A: marker, team count -> 1+ filtered = _overview(properties=[EventPropertyFilter(key="$host", value="a.com", operator="exact")])+ record_sticky_warm_shape(team=self.team, runner=self._runner(filtered)) # shape B: refused, team cap+ assert redis.get_client().hlen(STICKY_WARM_SHAPES_KEY) == 1+ record_sticky_warm_shape(team=self.team, runner=self._runner()) # shape A again: upgrades, not blocked+ assert len(get_sticky_warm_shapes()) == 1++ @mock.patch(f"{_COMMON}.STICKY_SHAPE_MAX_ENTRIES", 1)+ def test_full_set_refuses_new_shapes_but_upgrades_existing_markers(self):+ record_sticky_warm_shape(team=self.team, runner=self._runner()) # marker fills the cap+ filtered = _overview(properties=[EventPropertyFilter(key="$host", value="a.com", operator="exact")])+ record_sticky_warm_shape(team=self.team, runner=self._runner(filtered)) # refused: cap+ assert redis.get_client().hlen(STICKY_WARM_SHAPES_KEY) == 1+ # Upgrading the capped shape's own marker adds no field, so it proceeds.+ record_sticky_warm_shape(team=self.team, runner=self._runner())+ assert len(get_sticky_warm_shapes()) == 1++ def test_read_prunes_aged_and_undecodable_entries(self):+ record_sticky_warm_shape(team=self.team, runner=self._runner())+ record_sticky_warm_shape(team=self.team, runner=self._runner()) # upgrade to full+ client = redis.get_client()+ aged = time.time() - 48 * 3600+ client.hset(+ STICKY_WARM_SHAPES_KEY, "9999:aged", json.dumps({"team_id": 9999, "recorded_at": aged, "query": {}})+ )+ client.hset(STICKY_WARM_SHAPES_KEY, "9999:oldmark", json.dumps({"team_id": 9999, "recorded_at": aged}))+ client.hset(STICKY_WARM_SHAPES_KEY, "9999:garbage", "not json")+ # Fresh but malformed full entries: decodable JSON whose team_id is+ # missing or non-numeric must be pruned, never handed to the warmer —+ # one corrupt field would otherwise fail the whole hourly warm op.+ client.hset(+ STICKY_WARM_SHAPES_KEY, "9999:noteam", json.dumps({"recorded_at": time.time(), "query": {"kind": "x"}})+ )+ client.hset(+ STICKY_WARM_SHAPES_KEY,+ "9999:badteam",+ json.dumps({"team_id": "not-a-number", "recorded_at": time.time(), "query": {"kind": "x"}}),+ )++ entries = get_sticky_warm_shapes()+ assert len(entries) == 1+ assert entries[0]["team_id"] == self.team.id+ # Aged entries, aged markers, garbage, and malformed entries are pruned+ # from Redis too, not just filtered from the return value.+ assert client.hlen(STICKY_WARM_SHAPES_KEY) == 1++class TestVolumeFloor(BaseTest):def setUp(self):super().setUp()@@ -1074,9 +1185,10 @@ class TestServeLiveWarmBehind(BaseTest):runner._test_account_filters = []return runner+ @mock.patch(f"{_COMMON}.record_sticky_warm_shape")@mock.patch(f"{_COMMON}.enqueue_stale_revalidation")@mock.patch(f"{_COMMON}.ensure_precomputed")- def test_user_facing_is_check_only_and_warms_on_miss(self, mock_ensure, mock_enqueue):+ def test_user_facing_is_check_only_and_warms_on_miss(self, mock_ensure, mock_enqueue, mock_sticky):mock_ensure.return_value = LazyComputationResult(ready=False, job_ids=[], memory_exceeded=False)runner = self._runner()web_ensure_precomputed(@@ -1086,6 +1198,9 @@ class TestServeLiveWarmBehind(BaseTest):assert "runner" not in mock_ensure.call_args.kwargsassert "family" not in mock_ensure.call_args.kwargsmock_enqueue.assert_called_once_with(team=self.team, query=runner.query, family="web_overview")+ # The check-missed shape also becomes sticky, so the hourly warmer keeps+ # it warm instead of letting the one-off reactive build expire.+ mock_sticky.assert_called_once_with(team=self.team, runner=runner)@mock.patch(f"{_COMMON}.enqueue_stale_revalidation")@mock.patch(f"{_COMMON}.ensure_precomputed")diff --git a/products/web_analytics/backend/hogql_queries/web_lazy_precompute_common.py b/products/web_analytics/backend/hogql_queries/web_lazy_precompute_common.pyindex 1852fc51bc43..e46b54ed45b2 100644--- a/products/web_analytics/backend/hogql_queries/web_lazy_precompute_common.py+++ b/products/web_analytics/backend/hogql_queries/web_lazy_precompute_common.py@@ -368,6 +368,147 @@ REVALIDATION_TEAM_BUDGET_PER_WINDOW = 25# (team, family, shape) per debounce window — a trickle, not a backlog.REVALIDATION_START_DELAY_SECONDS = 20+# Sticky warm set: lazy-eligible user reads that check-missed TWICE record their+# shape here, and the hourly warmer unions the set into its selection. This+# closes the gap between new demand and the hours-stale cached demand selection,+# and keeps reactively built namespaces warm instead of letting them expire and+# re-miss. Two touches are required so a one-off exploration (a filter combo+# tried once) costs one tiny marker and is never warmed — mirroring the demand+# selection's own min-2 bar. One Redis hash; the key TTL is refreshed on write,+# and each entry carries `recorded_at` so the warmer prunes entries older than+# the max age. Entries are keyed per bucket namespace (`compute_shape_cap_key`),+# so date-range variants of one shape collapse to a single entry — warming any+# variant serves them all.+STICKY_WARM_SHAPES_KEY = "{web_precompute_sticky_shapes}:v1"+STICKY_SHAPE_KEY_TTL_SECONDS = 48 * 3600+STICKY_SHAPE_MAX_AGE_SECONDS = 24 * 3600+# Bounds the hash. Full entries are query JSONs (~1-2 KB); first-touch markers+# are a few bytes and age out on the warmer's hourly prune. When full, new+# shapes simply are not recorded — they keep self-healing via check-miss builds.+STICKY_SHAPE_MAX_ENTRIES = 20_000+# Per-entry byte ceiling on the stored query. A legitimate filter set serializes to+# ~1-2 KB; this only rejects an abusively large filter value that would otherwise sit+# in shared Redis for the entry's lifetime. The shape still self-heals via check-miss.+STICKY_SHAPE_MAX_QUERY_BYTES = 50_000+# Per-team admission cap on the shared hash, so one tenant can't fill all+# STICKY_SHAPE_MAX_ENTRIES and starve every other team's shapes for the TTL.+# Matches the warmer's per-team union cap: recording more than the warmer will+# ever replay for one team is wasted. The counter is approximate — the warmer's+# prune (HDEL) does not decrement it, so it over-counts and only ever refuses a+# team earlier than strictly needed, resetting on its own TTL.+STICKY_SHAPE_MAX_PER_TEAM = 100++WEB_ANALYTICS_STICKY_WARM_RECORDED = Counter(+ "web_analytics_sticky_warm_shapes_recorded_total",+ "Check-missed shapes recorded into (or refused by) the sticky warm set.",+ labelnames=["outcome"], # marked | recorded | full | team_full | oversized | error+)+++def _sticky_team_count_key(team_id: int) -> str:+ # Same hash tag as STICKY_WARM_SHAPES_KEY so the counter and the hash share a+ # Redis Cluster slot.+ return f"{{web_precompute_sticky_shapes}}:count:{team_id}"+++def record_sticky_warm_shape(*, team: Team, runner: Any) -> None:+ """Record a check-missed shape for the warmer's next pass — on its SECOND+ miss. The first miss writes a marker; only a repeat miss within the marker's+ lifetime upgrades it to a full entry the warmer replays. Best-effort: runs+ on the user-facing read path, so any failure degrades to "not sticky" — the+ shape still self-heals through the check-miss build, it just is not kept+ warm until the demand selection picks it up."""+ try:+ field = compute_shape_cap_key(runner.query, team.timezone, getattr(runner, "_test_account_filters", None))[:24]+ field = f"{team.id}:{field}"+ client = redis.get_client()+ existing = client.hget(STICKY_WARM_SHAPES_KEY, field)+ if existing is not None:+ try:+ if "query" in json.loads(existing):+ return # already a full sticky entry+ except Exception:+ pass # undecodable marker: treat as a first touch and upgrade+ if existing is None:+ # First touch: a marker only. Upgrading an existing marker adds no+ # field, so only this branch adds an entry and is subject to the caps.+ if client.hlen(STICKY_WARM_SHAPES_KEY) >= STICKY_SHAPE_MAX_ENTRIES:+ WEB_ANALYTICS_STICKY_WARM_RECORDED.labels(outcome="full").inc()+ return+ count_key = _sticky_team_count_key(team.id)+ team_count = client.get(count_key)+ if team_count is not None and int(team_count) >= STICKY_SHAPE_MAX_PER_TEAM:+ # One tenant must not fill the shared hash and starve other teams.+ WEB_ANALYTICS_STICKY_WARM_RECORDED.labels(outcome="team_full").inc()+ return+ payload = json.dumps({"team_id": team.id, "recorded_at": time.time()})+ outcome = "marked"+ else:+ payload = json.dumps(+ {+ "team_id": team.id,+ "recorded_at": time.time(),+ "query": runner.query.model_dump(mode="json", exclude_none=True),+ }+ )+ if len(payload) > STICKY_SHAPE_MAX_QUERY_BYTES:+ # Leave the marker rather than retain an oversized query: the warmer+ # skips a shape it has no query for, and the shape still self-heals.+ WEB_ANALYTICS_STICKY_WARM_RECORDED.labels(outcome="oversized").inc()+ return+ outcome = "recorded"+ pipe = client.pipeline()+ pipe.hset(STICKY_WARM_SHAPES_KEY, field, payload)+ pipe.expire(STICKY_WARM_SHAPES_KEY, STICKY_SHAPE_KEY_TTL_SECONDS)+ if existing is None:+ # A new field was added, so bump the team's admission counter.+ pipe.incr(_sticky_team_count_key(team.id))+ pipe.expire(_sticky_team_count_key(team.id), STICKY_SHAPE_KEY_TTL_SECONDS)+ pipe.execute()+ WEB_ANALYTICS_STICKY_WARM_RECORDED.labels(outcome=outcome).inc()+ except Exception:+ WEB_ANALYTICS_STICKY_WARM_RECORDED.labels(outcome="error").inc()+ logger.exception("web_precompute.sticky_warm_record_failed", team_id=team.id)+++def get_sticky_warm_shapes() -> list[dict]:+ """Full sticky entries for the warmer: `[{team_id, recorded_at, query}]`.+ First-touch markers (no `query`) are skipped while fresh and pruned once+ aged, like full entries; entries that do not decode to that shape are+ pruned too, so one corrupt field can never fail the warm pass that+ consumes this list. Pruning happens on read. The lazy HDEL can race a+ concurrent writer: a second miss may upgrade an aged marker between the+ HGETALL and the HDEL, deleting the fresh entry — bounded loss, the shape+ re-earns stickiness on its next two misses. Fails open to an empty list —+ the warmer then runs on the demand selection alone."""+ try:+ raw = redis.get_client().hgetall(STICKY_WARM_SHAPES_KEY)+ except Exception:+ logger.exception("web_precompute.sticky_warm_read_failed")+ return []+ now = time.time()+ entries: list[dict] = []+ dead_fields: list = []+ for hash_field, blob in raw.items():+ try:+ entry = json.loads(blob)+ if now - float(entry["recorded_at"]) > STICKY_SHAPE_MAX_AGE_SECONDS:+ dead_fields.append(hash_field)+ continue+ if "query" in entry:+ # A missing or non-numeric team_id raises here, routing the+ # entry into the prune below instead of into the warmer.+ entry["team_id"] = int(entry["team_id"])+ entries.append(entry)+ except Exception:+ dead_fields.append(hash_field)+ if dead_fields:+ try:+ redis.get_client().hdel(STICKY_WARM_SHAPES_KEY, *dead_fields)+ except Exception:+ logger.warning("web_precompute.sticky_warm_prune_failed", exc_info=True)+ return entries+def enqueue_stale_revalidation(*, team: Team, query: Any, family: str) -> None:"""Enqueue a background re-run of `query` so a stale-served read gets fresh data next time.@@ -538,6 +679,10 @@ def web_ensure_precomputed(*, team: Team, **kwargs: Any) -> LazyComputationResul# so the next visit is served from precompute while this one goes live.WEB_ANALYTICS_LAZY_PRECOMPUTE_CHECK_MISS.labels(family=family).inc()enqueue_stale_revalidation(team=team, query=runner.query, family=family)+ # Sticky: the shape reached this point through the lazy gate, so it is+ # proven lazy-eligible — record it so the hourly warmer keeps its buckets+ # warm instead of letting the one-off reactive build expire and re-miss.+ record_sticky_warm_shape(team=team, runner=runner)if result.memory_exceeded:pin_team_oom(team.id) # set or refresh the cap so a still-OOMing team stays pinnedif not pinned:diff --git a/products/web_analytics/dags/cache_warming.py b/products/web_analytics/dags/cache_warming.pyindex e9b8b3fe16f5..06cb6a870281 100644--- a/products/web_analytics/dags/cache_warming.py+++ b/products/web_analytics/dags/cache_warming.py@@ -7,6 +7,7 @@ import zlibimport randomimport threadingimport statistics+from collections import defaultdictfrom concurrent.futures import FIRST_COMPLETED, ThreadPoolExecutor, waitfrom datetime import datetime, timedeltafrom typing import TYPE_CHECKING, Optional@@ -45,6 +46,7 @@ from products.web_analytics.backend.hogql_queries.web_lazy_precompute_common impBACKGROUND_WARMING_TRIGGERS,MAX_PRECOMPUTE_DAYS,SHAPE_CAP_KEY_IGNORED_QUERY_FIELDS,+ get_sticky_warm_shapes,is_team_above_volume_floor,publish_volume_floor_teams,)@@ -690,17 +692,60 @@ def get_warmable_queries_op(context: dagster.OpExecutionContext, floor_published)_write_cached_warmable_queries(days, minimum_query_count, max_shapes, queries)- selected_count = len(queries)- # `cap_reached` keys off the pre-floor selection: the cap bounds the- # selection query, and floor-dropped shapes still consumed cap slots.- cap_reached = selected_count >= max_shapes+ # `selection_cap_reached` reflects the selection query alone: sticky entries+ # are appended below and floor-dropped shapes still consumed cap slots, so+ # neither must read as the selection hitting its LIMIT.+ selection_cap_reached = len(queries) >= max_shapes++ # Union in shapes that check-missed twice since the selection was cached:+ # they are proven lazy-eligible (recorded from inside the lazy gate) and+ # their teams have repeat demand right now, so waiting for the selection+ # blob's TTL leaves them re-missing for hours. No dedupe against the+ # selection here — the warm pass already dedupes replays by (team_id, cache+ # key), so an overlap costs one `skipped_duplicate`, not a double build.+ # `representative_query_count=1` keeps any shape whose eligibility has since+ # changed under the raw-replay demand bar, so stickiness can never mint raw+ # background scans.+ sticky = get_sticky_warm_shapes()+ # Cap sticky contributions per team with the same bound the demand+ # selection's `LIMIT ... BY team_id` uses. The two caps stack — a team can+ # contribute up to MAX_SHAPES_PER_TEAM sticky shapes on top of its+ # selection shapes — but each side is bounded, so one tenant filling the+ # shared sticky set can't crowd the fleet-wide warm pass.+ sticky_per_team: defaultdict[int, int] = defaultdict(int)+ sticky_added = 0+ for entry in sticky:+ team_id = entry["team_id"]+ if sticky_per_team[team_id] >= MAX_SHAPES_PER_TEAM:+ continue+ sticky_per_team[team_id] += 1+ query_json = entry.get("query") or {}+ date_from = (query_json.get("dateRange") or {}).get("date_from")+ queries.append(+ {+ "team_id": team_id,+ "query_json": query_json,+ "query_count": 1,+ "representative_query_count": 1,+ # Stable per-shape int for the staleness jitter, derived the same+ # way selection derives it — from the payload content.+ "normalized_query_hash": zlib.crc32(json.dumps(query_json, sort_keys=True).encode()),+ "observed_date_froms": [date_from] if date_from else [],+ }+ )+ sticky_added += 1+ if sticky_added:+ context.log.info(f"Unioned {sticky_added} sticky check-miss shapes into the warm pass")+# The floor is enforced here, per replay, not in the selection SQL: keeping the# cached selection floor-agnostic means a team that grows above the floor is# warmed on the next pass, rather than waiting for the selection blob's TTL to- # lapse. Below-floor shapes that consumed cap slots are dropped here; a fresh- # `is_team_above_volume_floor` verdict (60s-cached) applies each pass.+ # lapse. It applies to sticky-unioned shapes too, so a below-floor team can't+ # be warmed through the sticky path. A fresh `is_team_above_volume_floor`+ # verdict (60s-cached) applies each pass.+ pre_floor_count = len(queries)queries = [q for q in queries if is_team_above_volume_floor(int(q["team_id"]))]- floor_dropped = selected_count - len(queries)+ floor_dropped = pre_floor_count - len(queries)team_count = len({q["team_id"] for q in queries})WARMING_SHAPES_SELECTED_GAUGE.set(len(queries))@@ -718,8 +763,10 @@ def get_warmable_queries_op(context: dagster.OpExecutionContext, floor_published{"query_count": len(queries),"team_count": team_count,+ "sticky_count": len(sticky),+ "sticky_added": sticky_added,"floor_dropped": floor_dropped,- "cap_reached": cap_reached,+ "cap_reached": selection_cap_reached,"from_cache": from_cache,})diff --git a/products/web_analytics/dags/tests/test_cache_warming.py b/products/web_analytics/dags/tests/test_cache_warming.pyindex 254cdb59da54..b6335309468c 100644--- a/products/web_analytics/dags/tests/test_cache_warming.py+++ b/products/web_analytics/dags/tests/test_cache_warming.py@@ -514,6 +514,33 @@ class TestFleetQuerySelection(BaseTest):result = get_warmable_queries_op(dagster.build_op_context())self.assertEqual(result, [])+ @patch(+ "products.web_analytics.dags.cache_warming.get_sticky_warm_shapes",+ return_value=[+ {+ "team_id": 42,+ "recorded_at": 0,+ "query": {"kind": "WebOverviewQuery", "dateRange": {"date_from": "-7d"}, "properties": []},+ }+ ],+ )+ @patch("products.web_analytics.dags.cache_warming._read_cached_warmable_queries", return_value=[])+ def test_op_unions_sticky_shapes_into_selection(self, _mock_read: MagicMock, _mock_sticky: MagicMock) -> None:+ # A check-missed shape recorded between selection rotations must reach the+ # warm pass without waiting out the selection cache's TTL, and it must+ # carry the full query_info contract (the warm pass indexes these keys).+ result = get_warmable_queries_op(dagster.build_op_context())++ self.assertEqual(len(result), 1)+ entry = result[0]+ self.assertEqual(entry["team_id"], 42)+ self.assertEqual(entry["query_json"]["kind"], "WebOverviewQuery")+ self.assertEqual(entry["observed_date_froms"], ["-7d"])+ # Below the raw-replay demand bar, so a shape whose eligibility changed+ # can never be amplified into raw background scans.+ self.assertLess(entry["representative_query_count"], cache_warming.RAW_REPLAY_MIN_QUERY_COUNT)+ self.assertIsInstance(entry["normalized_query_hash"], int)+class _FakeObjectStorage:def __init__(self) -> None: