Skip to content

feat: make seed loading explicit, not lazy (#232) - #233

Merged
elecnix merged 2 commits into
mainfrom
feat/explain-seed
Jul 3, 2026
Merged

feat: make seed loading explicit, not lazy (#232)#233
elecnix merged 2 commits into
mainfrom
feat/explain-seed

Conversation

@elecnix

@elecnix elecnix commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Removes the lazy seed auto-load from cache.query so that seed data only enters the cache when explicitly requested. Closes #232.

Problem

cache.query was auto-loading ~90 seed rows on any query miss — even when live Infracost pricing was already present for other metrics. This forced every live-pricing integration to build defensive layers (manual DELETE, SQLite introspection, CI cache-health checks) just to prevent seed from silently reactivating.

Changes

  • cache.query — returns None on miss instead of auto-loading seed. Caller decides whether to seed.
  • PricingCache(seed=True) — new parameter to explicitly request seed data on construction.
  • PricingCatalog(seed=True) — passes through to PricingCache.
  • PricingCache.source_info() — new method returns per-source row counts: {"infracost": 42, "seed": 90}.
  • PricingCatalog.source_info() — public facade for the above.
  • seed_prices() and seed-pricing CLI — unchanged; seed loading remains an explicit, deliberate action.
  • 34 test PricingCatalog() calls — updated to PricingCatalog(seed=True) so tests remain explicit about their data source. In CI there is no persistent default DB, so relying on auto-load was a hidden dependency.

Quality

Gate Status
Tests 904 passed, 13 pre-existing failures (same as main)
Ruff 12 pre-existing notices (no new)
Mypy 44 pre-existing errors in 6 files (no new in pricing/)

Breaking changes

None. seed_prices(), seed-pricing CLI, and aws_fallback_prices(seed_only=True) all work as before. The only behavioral change is that cache.query no longer silently injects seed data — a caller that wants seed must ask for it explicitly via PricingCatalog(seed=True) or a prior seed_prices() call.

— feral-bison-42

elecnix and others added 2 commits July 3, 2026 15:26
Remove the auto-load of seed prices from cache.query. Before this
change, any query miss silently loaded ~90 seed rows into the cache,
including rows for metrics that already had live Infracost pricing.
This was the root cause forcing downstream integrations to build
multi-layer defenses (manual DELETE before sync, SQLite introspection,
CI cache-health checks) to prevent seed prices from leaking into
production pricing.

After this change:
- cache.query returns None on miss — caller decides whether to seed
- new PricingCatalog.source_info() provides per-source row counts
  so downstream can check for live pricing without private attributes
- seed_prices() and seed-pricing CLI remain as explicit actions
- one test that relied on lazy auto-load now seeds explicitly

Co-authored-by: feral-bison-42 <feral-bison-42@pi-agent.local>
Tests that create PricingCatalog() without arguments now use
PricingCatalog(seed=True) to explicitly request seed data.  In CI there
is no persistent default DB, so without seed=True the lazy auto-load
removal left these tests with /bin/bash costs.

The seed parameter is a convenience for test code and local offline
use — production paths should use live sync-pricing instead.

Co-authored-by: feral-bison-42 <feral-bison-42@pi-agent.local>
@elecnix
elecnix marked this pull request as ready for review July 3, 2026 19:32
@elecnix
elecnix merged commit 0dfb4e6 into main Jul 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pricing: seed auto-load should be explicit, not lazy (root cause of downstream defense workarounds)

1 participant