feat: make seed loading explicit, not lazy (#232) - #233
Merged
Conversation
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
marked this pull request as ready for review
July 3, 2026 19:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the lazy seed auto-load from
cache.queryso that seed data only enters the cache when explicitly requested. Closes #232.Problem
cache.querywas 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 (manualDELETE, SQLite introspection, CI cache-health checks) just to prevent seed from silently reactivating.Changes
cache.query— returnsNoneon 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 toPricingCache.PricingCache.source_info()— new method returns per-source row counts:{"infracost": 42, "seed": 90}.PricingCatalog.source_info()— public facade for the above.seed_prices()andseed-pricingCLI — unchanged; seed loading remains an explicit, deliberate action.PricingCatalog()calls — updated toPricingCatalog(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
Breaking changes
None.
seed_prices(),seed-pricingCLI, andaws_fallback_prices(seed_only=True)all work as before. The only behavioral change is thatcache.queryno longer silently injects seed data — a caller that wants seed must ask for it explicitly viaPricingCatalog(seed=True)or a priorseed_prices()call.— feral-bison-42