Split the pure Company flatten from ticker enrichment - #2
Open
omarzeineddine-ai wants to merge 3 commits into
Open
Split the pure Company flatten from ticker enrichment#2omarzeineddine-ai wants to merge 3 commits into
omarzeineddine-ai wants to merge 3 commits into
Conversation
flatten_and_standardize made a network round-trip per company via get_stock_ticker, so reshape bugs and enrichment bugs shared one blast radius and flatten tests had to mock inside the module. Move the flatten to companies.py as a pure transform and add enrich_with_tickers(companies, resolve) as a separate pass with the resolver injected; utils composes the two. Also drops a stray debug print in the campaign merge. Flatten tests now run on plain data with zero mocks; enrichment is tested with a fake resolver.
Names the concepts the codebase is organized around — Snapshot, Company, Campaign, Complicity categories, Flatten, Ticker resolution — so modules, tests, and future architecture work share one vocabulary.
The README said the endpoint returns 'the decoded JSON data', which told consumers nothing. Document the Company object with its always- present fields, the nullable stockTicker, and the conditional category and campaign fields that otherwise have to be reverse-engineered from a 458KB response.
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.
First of three stacked architecture PRs (this one → ticker resolver → store seam). Merge this one first; the follow-ups auto-retarget.
Why
flatten_and_standardizelooked like a pure transform but made a network round-trip per company (get_stock_ticker→ Perplexity + OpenRouter). Reshape bugs and enrichment bugs shared one blast radius, and testing the flatten required mocking inside the module.What
split pure company flatten from ticker enrichment— the flatten moves tocompanies.pyas a pure Snapshot → Company transform;enrich_with_tickers(companies, resolve)is a separate pass with the resolver injected;utils.fetch_and_decode_datacomposes the two. A stray debugprintin the campaign merge dies with the rewrite.add domain glossary (CONTEXT.md)— names the concepts (Snapshot, Company, Campaign, Complicity categories, Flatten, Ticker resolution) so modules and future work share one vocabulary.document the /api response shape in README— the Company object's always-present fields, nullablestockTicker, and the conditional category/campaign keys, which consumers previously had to reverse-engineer from a 458KB response.Tests
Flatten tests now run on plain data with zero mocks (
tests/test_companies.py); enrichment is tested with a fake resolver. Added coverage for multi-company campaigns and absent category keys. Suite: 72 passed (was 67), coverage 91%. API behavior is unchanged — same response payload.