PR 3: Source-adapter interface + deterministic CELLxGENE adapter - #5
Merged
Conversation
Introduce the SourceAdapter / Normalizer contracts and refactor CELLxGENE into a fully deterministic adapter + normalizer, then rip out the LLM/Azure narrative path entirely. New contracts - models/raw_record.py: RawRecord, the source-shaped boundary object between adapters and normalizers (source, study_id, title, free-form payload). - sources/base.py: SourceAdapter Protocol (discover -> [ref], fetch -> RawRecord). - normalize/base.py: Normalizer Protocol (normalize -> KnowledgeGraphOutput). CELLxGENE migrated (no LLM in its path) - tools/cellxgene_fetcher.py -> sources/cellxgene.py (CellxgeneAdapter). Cell-type extraction dropped: the cell_type* Census columns and cell_types summary key are gone (data-inferred -> leakage). - tools/ncbi_fetcher.py -> sources/publication.py (EuropePMC title helper). - graph/builder.py -> normalize/cellxgene.py (CellxgeneNormalizer); reads record.source/title/payload instead of a hardcoded source. The organism-> NCBITaxon map moves here (normalization, future PR 4 resolver). - Vestigial @tool wrappers and the whole tools/ package (incl. GEO stub) removed. Narrative/LLM path removed - Deleted agent/curator.py, agent/prompts.py, models/narrative.py, the NarrativeOutput schema, and main.py's step-2 block. main.py is now a deterministic, synchronous discover -> fetch -> normalize -> write pipeline. Tooling/tests - Removed the parce.tools.* mypy exemption (modules migrated, now type-checked); parce.agent.* exemption stays for PR 5. - Tests: test_builder -> test_normalize, new test_sources (adapter + RawRecord + protocol conformance), rewritten test_orchestration, narrative tests removed. Gates green locally (incl. hermetic run with .env moved aside): ruff check, ruff format --check, mypy (16 files), 47 unit tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Scope (roadmap PR 3)
Introduce the
SourceAdapter/Normalizercontracts, refactor CELLxGENE into afully deterministic adapter + normalizer, and remove the LLM/Azure narrative
path entirely. One roadmap item; no work pulled forward.
New contracts
models/raw_record.py—RawRecord, the source-shaped boundary object betweenadapters and normalizers (
source,study_id,title, free-formpayload).sources/base.py—SourceAdapterProtocol (discover(query) -> [ref],fetch(ref) -> RawRecord).normalize/base.py—NormalizerProtocol (normalize(record) -> KnowledgeGraphOutput).CELLxGENE migrated (no LLM in its path)
tools/cellxgene_fetcher.py→sources/cellxgene.py(CellxgeneAdapter).Cell-type extraction dropped — the
cell_type*Census columns and thecell_typessummary key are gone (data-inferred → leakage).tools/ncbi_fetcher.py→sources/publication.py(EuropePMC title helper).graph/builder.py→normalize/cellxgene.py(CellxgeneNormalizer); readsrecord.source/title/payloadinstead of a hardcoded source. Theorganism→NCBITaxon map moves here (normalization; PR 4 resolver replaces it).
@toolwrappers and the wholetools/package (incl. the GEO stub)removed.
Narrative/LLM path removed
agent/curator.py,agent/prompts.py,models/narrative.py, theNarrativeOutputschema, andmain.py's step-2 block.main.pyis now adeterministic, synchronous
discover → fetch → normalize → writepipeline.Decisions
graph/is reserved for the PR 6cross-source merger (matches ARCHITECTURE §3).
graph/+agent/kept asdocumented placeholder packages.
discoveris the identity on a DOI for CELLxGENE (a collection = a DOI);keyword search is backlog.
call). Follow-up: source-fetch resilience (Census/EuropePMC) should be
re-added — noted in the Session Log.
mypy
parce.tools.*exemption (modules migrated, now fully type-checked).parce.agent.*exemption stays for PR 5.Verification
All four CI gates pass locally, including a hermetic run with
.envmoved aside:ruff check .ruff format --check .mypy src/parcepytest -m "not integration"No dependency changes (
agent-framework/azure-*retained for PR 5).▶ Next up after this: PR 4 — Ontology resolver.
🤖 Generated with Claude Code