Repository navigation
refactor: tighten source provider and ingestion emission seams - #266
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 35 minutes and 32 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (8)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18e5b2807f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if resolved_schema is None and plan.artifact.schema_eligible: | ||
| resolved_schema = _resolve_schema_resolution( | ||
| plan.provider, |
There was a problem hiding this comment.
Guard schema lookup behind payload mode
_parse_plan_conversations resolves schema before checking plan.mode, so stream plans now call _resolve_schema_resolution(...) even though parse_stream_payload never uses a schema resolution. That adds avoidable schema-registry work to JSONL ingestion and makes validation_mode='off' still incur schema-resolution overhead; move this lookup into the payload-only branch (or after the stream early return) to restore the previous stream fast path.
Useful? React with 👍 / 👎.
## Summary - tighten provider-facing message adapters for Claude Code, Codex, and Gemini payloads - unify ingest parsing around explicit parse-plan helpers instead of duplicated stream/envelope control flow - normalize JSONL emission and provider-specific parser follow-through over the renewed ingestion contracts ## Problem The remaining source/provider seam was still carrying path-dependent payload branching across three adjacent layers: - provider message adapters mixed open dict plumbing with ad hoc normalization - `ingest_worker` duplicated grouped-stream versus envelope parsing control flow - the JSONL emitter and Codex/Drive parsers repeated provider detection and metadata shaping in slightly different forms That code was strict-mypy-cleanable, but it still hid runtime meaning behind loosely shaped containers and repeated branches. ## Solution - rebuild the provider message adapters in `polylogue/sources/providers/claude_code_models.py`, `polylogue/sources/providers/claude_code_record.py`, `polylogue/sources/providers/codex.py`, and `polylogue/sources/providers/gemini_message.py` around explicit helper aliases and normalization helpers - refactor `polylogue/pipeline/services/ingest_worker.py` to use typed parse-plan/context records so grouped stream parsing and envelope parsing share one orchestration path - restructure `polylogue/sources/emitter.py` so grouped JSONL, individual payload, and raw-capture handling all flow through one resolved payload path - carry the contract shape through `polylogue/sources/parsers/codex.py` and `polylogue/sources/parsers/drive.py` Ref #262 ## Verification - `ruff check polylogue/sources/providers/claude_code_models.py polylogue/sources/providers/claude_code_record.py polylogue/sources/providers/codex.py polylogue/sources/providers/gemini_message.py` - `mypy polylogue/sources/providers/claude_code_models.py polylogue/sources/providers/claude_code_record.py polylogue/sources/providers/codex.py polylogue/sources/providers/gemini_message.py` - `pytest -q tests/unit/sources/test_models.py -k 'Gemini or ClaudeCode or Codex'` - `ruff check polylogue/sources/parsers/codex.py polylogue/sources/parsers/drive.py polylogue/sources/emitter.py polylogue/pipeline/services/ingest_worker.py` - `mypy polylogue/sources/parsers/codex.py polylogue/sources/parsers/drive.py polylogue/sources/emitter.py polylogue/pipeline/services/ingest_worker.py` - `pytest -q tests/unit/pipeline/test_quarantine_fixtures.py tests/unit/pipeline/test_resilience.py tests/unit/pipeline/test_ingest_batch.py -k 'ingest_record or malformed_jsonl or zero_length_blob or schema_resolution or streams_codex_jsonl or iter_ingest_results_sync'` - `pytest -q tests/unit/sources/test_models.py tests/unit/sources/test_source_laws.py tests/unit/pipeline/test_quarantine_fixtures.py tests/unit/pipeline/test_resilience.py tests/unit/pipeline/test_ingest_batch.py -k 'Gemini or ClaudeCode or Codex or conversation_emitter or ingest_record or malformed_jsonl or zero_length_blob or schema_resolution or streams_codex_jsonl or iter_ingest_results_sync'` - `devtools verify`
The source/provider seam carried path-dependent payload branching across three adjacent layers: provider message adapters mixed open dict plumbing with ad hoc normalization; `ingest_worker` duplicated grouped-stream vs envelope parsing control flow; and the JSONL emitter and Codex/Drive parsers repeated provider detection and metadata shaping in slightly different forms. Strict-mypy-cleanable but hiding runtime meaning behind loosely shaped containers and repeated branches. Rebuilds the provider message adapters in `sources/providers/claude_code_models.py`, `claude_code_record.py`, `codex.py`, and `gemini_message.py` around explicit helper aliases and normalization helpers. Refactors `pipeline/services/ingest_worker.py` to use typed parse-plan / context records so grouped stream parsing and envelope parsing share one orchestration path. Restructures `sources/emitter.py` so grouped JSONL, individual payload, and raw-capture handling all flow through one resolved payload path. Carries the contract shape through `sources/parsers/codex.py` and `sources/parsers/drive.py`. Verification: ruff + mypy + pytest over provider models, source laws, quarantine fixtures, resilience, and ingest-batch suites; devtools verify green. Ref #262
The source/provider seam carried path-dependent payload branching across three adjacent layers: provider message adapters mixed open dict plumbing with ad hoc normalization; `ingest_worker` duplicated grouped-stream vs envelope parsing control flow; and the JSONL emitter and Codex/Drive parsers repeated provider detection and metadata shaping in slightly different forms. Strict-mypy-cleanable but hiding runtime meaning behind loosely shaped containers and repeated branches. Rebuilds the provider message adapters in `sources/providers/claude_code_models.py`, `claude_code_record.py`, `codex.py`, and `gemini_message.py` around explicit helper aliases and normalization helpers. Refactors `pipeline/services/ingest_worker.py` to use typed parse-plan / context records so grouped stream parsing and envelope parsing share one orchestration path. Restructures `sources/emitter.py` so grouped JSONL, individual payload, and raw-capture handling all flow through one resolved payload path. Carries the contract shape through `sources/parsers/codex.py` and `sources/parsers/drive.py`. Verification: ruff + mypy + pytest over provider models, source laws, quarantine fixtures, resilience, and ingest-batch suites; devtools verify green. Ref #262
The source/provider seam carried path-dependent payload branching across three adjacent layers: provider message adapters mixed open dict plumbing with ad hoc normalization; `ingest_worker` duplicated grouped-stream vs envelope parsing control flow; and the JSONL emitter and Codex/Drive parsers repeated provider detection and metadata shaping in slightly different forms. Strict-mypy-cleanable but hiding runtime meaning behind loosely shaped containers and repeated branches. Rebuilds the provider message adapters in `sources/providers/claude_code_models.py`, `claude_code_record.py`, `codex.py`, and `gemini_message.py` around explicit helper aliases and normalization helpers. Refactors `pipeline/services/ingest_worker.py` to use typed parse-plan / context records so grouped stream parsing and envelope parsing share one orchestration path. Restructures `sources/emitter.py` so grouped JSONL, individual payload, and raw-capture handling all flow through one resolved payload path. Carries the contract shape through `sources/parsers/codex.py` and `sources/parsers/drive.py`. Verification: ruff + mypy + pytest over provider models, source laws, quarantine fixtures, resilience, and ingest-batch suites; devtools verify green. Ref #262
Summary
Problem
The remaining source/provider seam was still carrying path-dependent payload branching across three adjacent layers:
ingest_workerduplicated grouped-stream versus envelope parsing control flowThat code was strict-mypy-cleanable, but it still hid runtime meaning behind loosely shaped containers and repeated branches.
Solution
polylogue/sources/providers/claude_code_models.py,polylogue/sources/providers/claude_code_record.py,polylogue/sources/providers/codex.py, andpolylogue/sources/providers/gemini_message.pyaround explicit helper aliases and normalization helperspolylogue/pipeline/services/ingest_worker.pyto use typed parse-plan/context records so grouped stream parsing and envelope parsing share one orchestration pathpolylogue/sources/emitter.pyso grouped JSONL, individual payload, and raw-capture handling all flow through one resolved payload pathpolylogue/sources/parsers/codex.pyandpolylogue/sources/parsers/drive.pyRef #262
Verification
ruff check polylogue/sources/providers/claude_code_models.py polylogue/sources/providers/claude_code_record.py polylogue/sources/providers/codex.py polylogue/sources/providers/gemini_message.pymypy polylogue/sources/providers/claude_code_models.py polylogue/sources/providers/claude_code_record.py polylogue/sources/providers/codex.py polylogue/sources/providers/gemini_message.pypytest -q tests/unit/sources/test_models.py -k 'Gemini or ClaudeCode or Codex'ruff check polylogue/sources/parsers/codex.py polylogue/sources/parsers/drive.py polylogue/sources/emitter.py polylogue/pipeline/services/ingest_worker.pymypy polylogue/sources/parsers/codex.py polylogue/sources/parsers/drive.py polylogue/sources/emitter.py polylogue/pipeline/services/ingest_worker.pypytest -q tests/unit/pipeline/test_quarantine_fixtures.py tests/unit/pipeline/test_resilience.py tests/unit/pipeline/test_ingest_batch.py -k 'ingest_record or malformed_jsonl or zero_length_blob or schema_resolution or streams_codex_jsonl or iter_ingest_results_sync'pytest -q tests/unit/sources/test_models.py tests/unit/sources/test_source_laws.py tests/unit/pipeline/test_quarantine_fixtures.py tests/unit/pipeline/test_resilience.py tests/unit/pipeline/test_ingest_batch.py -k 'Gemini or ClaudeCode or Codex or conversation_emitter or ingest_record or malformed_jsonl or zero_length_blob or schema_resolution or streams_codex_jsonl or iter_ingest_results_sync'devtools verify