Skip to content

Split the pure Company flatten from ticker enrichment - #2

Open
omarzeineddine-ai wants to merge 3 commits into
mainfrom
refactor/company-flatten
Open

Split the pure Company flatten from ticker enrichment#2
omarzeineddine-ai wants to merge 3 commits into
mainfrom
refactor/company-flatten

Conversation

@omarzeineddine-ai

Copy link
Copy Markdown
Contributor

First of three stacked architecture PRs (this one → ticker resolver → store seam). Merge this one first; the follow-ups auto-retarget.

Why

flatten_and_standardize looked 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 to companies.py as a pure Snapshot → Company transform; enrich_with_tickers(companies, resolve) is a separate pass with the resolver injected; utils.fetch_and_decode_data composes the two. A stray debug print in 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, nullable stockTicker, 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.

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.
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.

1 participant