Repository navigation
refactor: tighten schema and lib payload boundary contracts - #253
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (36)
📝 WalkthroughWalkthroughThis PR refactors type annotations across the codebase, replacing broad Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 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: d831e43324
ℹ️ 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".
## Summary Tighten the shared JSON/payload contract that flows through raw payload decode, schema harmonization, provider semantic extractors, and adjacent schema/runtime helpers. Ref #251 Ref #250 ## Problem Recent semantic-precision work established a stronger shared JSON/document contract, but the schema and lib boundary layer still had mixed assumptions: - raw payload helpers, harmonization code, and runtime consumers were still split between loose `dict[str, object]` plumbing and newer JSON-shaped contracts - schema fallback and provider-meta extraction paths still depended on cast-heavy or partially duplicated coercion logic - adjacent schema utilities, action-event helpers, acquisition helpers, and tests still assumed the older, looser signatures - the result was a type-clean local slice only after focused checks, while the full repo baseline still surfaced cross-module fallout ## Solution This branch renews that boundary as one coherent slice: - centralize shared JSON aliases and coercion helpers in `polylogue.lib.json`, including stricter fallback decoding behavior and filtered document-list coercion - propagate JSON/document contracts through raw payload decode, provider semantics, viewport/runtime helpers, and schema harmonization entrypoints - tighten schema fallback, unified extraction, observation, validator, and generation workflow helpers around explicit JSON-shaped payloads - align acquisition and action-event helper seams with the same normalized payload contracts - update the affected tests to narrow decoded JSON locally instead of widening production signatures back Key modules touched include: - `polylogue/lib/json.py` - `polylogue/lib/raw_payload_decode.py` - `polylogue/lib/provider_semantics.py` - `polylogue/pipeline/materialization_runtime.py` - `polylogue/pipeline/semantic_capture.py` - `polylogue/schemas/unified*.py` - `polylogue/schemas/extraction.py` - `polylogue/schemas/observation_runtime.py` - `polylogue/schemas/validator.py` - `polylogue/sources/source_acquisition.py` ## Verification - `ruff check polylogue/lib/provider_semantics.py polylogue/schemas/unified.py polylogue/schemas/unified_adapters.py polylogue/schemas/unified_fallbacks.py polylogue/schemas/unified_models.py polylogue/schemas/unified_provider_meta_coercion.py polylogue/schemas/unified_provider_meta_harmonize.py polylogue/schemas/unified_provider_meta_runtime.py` - `mypy polylogue/lib/provider_semantics.py polylogue/schemas/unified.py polylogue/schemas/unified_adapters.py polylogue/schemas/unified_fallbacks.py polylogue/schemas/unified_models.py polylogue/schemas/unified_provider_meta_coercion.py polylogue/schemas/unified_provider_meta_harmonize.py polylogue/schemas/unified_provider_meta_runtime.py` - `pytest -q tests/unit/sources/test_unified_semantic_laws.py tests/unit/core/test_filters_schemas.py tests/integration/test_extraction_db.py` - `pytest -q tests/unit/core/test_json.py tests/unit/core/test_models.py tests/unit/core/test_schema_corpus_alignment.py tests/unit/core/test_filters_schemas.py tests/unit/core/test_schema_generation.py tests/unit/sources/test_unified_semantic_laws.py tests/unit/sources/test_models.py tests/unit/sources/test_source_laws.py tests/integration/test_extraction_db.py` - `devtools verify`
Recent semantic-precision work established a stronger shared JSON / document contract, but the schema and lib boundary layer had mixed assumptions: raw payload helpers, harmonization code, and runtime consumers split between loose `dict[str, object]` plumbing and newer JSON-shaped contracts; schema fallback and provider-meta extraction still cast-heavy or partially duplicated; adjacent schema utilities, action-event helpers, acquisition helpers, and tests assuming older looser signatures. Type-clean locally after focused checks, but the full-repo baseline surfaced cross-module fallout. Centralizes shared JSON aliases and coercion helpers in `lib/json.py` with stricter fallback decoding and filtered document-list coercion. Propagates JSON/document contracts through raw payload decode, provider semantics, viewport/runtime helpers, and schema harmonization entrypoints. Tightens schema fallback, unified extraction, observation, validator, and generation workflow helpers around explicit JSON-shaped payloads. Aligns acquisition and action-event helper seams with the same normalized payload contracts. Updates affected tests to narrow decoded JSON locally instead of widening production signatures back. Key modules: `lib/json.py`, `lib/raw_payload_decode.py`, `lib/provider_semantics.py`, `pipeline/materialization_runtime.py`, `pipeline/semantic_capture.py`, `schemas/unified*.py`, `schemas/extraction.py`, `schemas/observation_runtime.py`, `schemas/validator.py`, `sources/source_acquisition.py`. Verification: ruff + mypy + pytest over unified schema, source, core, and extraction tests; devtools verify green. Ref #251 Ref #250
The run and acquisition flow still relied on loosely shaped dictionaries and ad hoc payload coercion at key boundaries. Stage observations, run-state payload emission, sidecar enrichment, and a chunk of the downstream tests were all depending on inferred `dict[str, object]` shapes rather than stable typed contracts, leaving the code path-dependent and brittle at runtime and verification time. Adds `pipeline/payload_types.py` and threads typed payload contracts through run execution, finalization, acquisition, parsing, ingest batching, source acquisition, and the run CLI. Tightens `run_state`, `metrics`, and stage outcome models so emitted run payloads and observation summaries are explicit JSON-shaped values instead of generic dict/cast plumbing. Replaces loose source sidecar maps with typed Claude Code and Codex sidecar contracts, then aligns the pipeline/source tests with the new observation and run-json helpers. Stacked on the schema/lib payload-boundary renewal (#253). Verification: ruff + mypy over pipeline/run/acquisition/source modules; pytest over parsing, run-sources, assembly, source-laws, and probe suites; devtools verify green. Ref #252
Recent semantic-precision work established a stronger shared JSON / document contract, but the schema and lib boundary layer had mixed assumptions: raw payload helpers, harmonization code, and runtime consumers split between loose `dict[str, object]` plumbing and newer JSON-shaped contracts; schema fallback and provider-meta extraction still cast-heavy or partially duplicated; adjacent schema utilities, action-event helpers, acquisition helpers, and tests assuming older looser signatures. Type-clean locally after focused checks, but the full-repo baseline surfaced cross-module fallout. Centralizes shared JSON aliases and coercion helpers in `lib/json.py` with stricter fallback decoding and filtered document-list coercion. Propagates JSON/document contracts through raw payload decode, provider semantics, viewport/runtime helpers, and schema harmonization entrypoints. Tightens schema fallback, unified extraction, observation, validator, and generation workflow helpers around explicit JSON-shaped payloads. Aligns acquisition and action-event helper seams with the same normalized payload contracts. Updates affected tests to narrow decoded JSON locally instead of widening production signatures back. Key modules: `lib/json.py`, `lib/raw_payload_decode.py`, `lib/provider_semantics.py`, `pipeline/materialization_runtime.py`, `pipeline/semantic_capture.py`, `schemas/unified*.py`, `schemas/extraction.py`, `schemas/observation_runtime.py`, `schemas/validator.py`, `sources/source_acquisition.py`. Verification: ruff + mypy + pytest over unified schema, source, core, and extraction tests; devtools verify green. Ref #251 Ref #250
The run and acquisition flow still relied on loosely shaped dictionaries and ad hoc payload coercion at key boundaries. Stage observations, run-state payload emission, sidecar enrichment, and a chunk of the downstream tests were all depending on inferred `dict[str, object]` shapes rather than stable typed contracts, leaving the code path-dependent and brittle at runtime and verification time. Adds `pipeline/payload_types.py` and threads typed payload contracts through run execution, finalization, acquisition, parsing, ingest batching, source acquisition, and the run CLI. Tightens `run_state`, `metrics`, and stage outcome models so emitted run payloads and observation summaries are explicit JSON-shaped values instead of generic dict/cast plumbing. Replaces loose source sidecar maps with typed Claude Code and Codex sidecar contracts, then aligns the pipeline/source tests with the new observation and run-json helpers. Stacked on the schema/lib payload-boundary renewal (#253). Verification: ruff + mypy over pipeline/run/acquisition/source modules; pytest over parsing, run-sources, assembly, source-laws, and probe suites; devtools verify green. Ref #252
Recent semantic-precision work established a stronger shared JSON / document contract, but the schema and lib boundary layer had mixed assumptions: raw payload helpers, harmonization code, and runtime consumers split between loose `dict[str, object]` plumbing and newer JSON-shaped contracts; schema fallback and provider-meta extraction still cast-heavy or partially duplicated; adjacent schema utilities, action-event helpers, acquisition helpers, and tests assuming older looser signatures. Type-clean locally after focused checks, but the full-repo baseline surfaced cross-module fallout. Centralizes shared JSON aliases and coercion helpers in `lib/json.py` with stricter fallback decoding and filtered document-list coercion. Propagates JSON/document contracts through raw payload decode, provider semantics, viewport/runtime helpers, and schema harmonization entrypoints. Tightens schema fallback, unified extraction, observation, validator, and generation workflow helpers around explicit JSON-shaped payloads. Aligns acquisition and action-event helper seams with the same normalized payload contracts. Updates affected tests to narrow decoded JSON locally instead of widening production signatures back. Key modules: `lib/json.py`, `lib/raw_payload_decode.py`, `lib/provider_semantics.py`, `pipeline/materialization_runtime.py`, `pipeline/semantic_capture.py`, `schemas/unified*.py`, `schemas/extraction.py`, `schemas/observation_runtime.py`, `schemas/validator.py`, `sources/source_acquisition.py`. Verification: ruff + mypy + pytest over unified schema, source, core, and extraction tests; devtools verify green. Ref #251 Ref #250
The run and acquisition flow still relied on loosely shaped dictionaries and ad hoc payload coercion at key boundaries. Stage observations, run-state payload emission, sidecar enrichment, and a chunk of the downstream tests were all depending on inferred `dict[str, object]` shapes rather than stable typed contracts, leaving the code path-dependent and brittle at runtime and verification time. Adds `pipeline/payload_types.py` and threads typed payload contracts through run execution, finalization, acquisition, parsing, ingest batching, source acquisition, and the run CLI. Tightens `run_state`, `metrics`, and stage outcome models so emitted run payloads and observation summaries are explicit JSON-shaped values instead of generic dict/cast plumbing. Replaces loose source sidecar maps with typed Claude Code and Codex sidecar contracts, then aligns the pipeline/source tests with the new observation and run-json helpers. Stacked on the schema/lib payload-boundary renewal (#253). Verification: ruff + mypy over pipeline/run/acquisition/source modules; pytest over parsing, run-sources, assembly, source-laws, and probe suites; devtools verify green. Ref #252
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Tighten the shared JSON/payload contract that flows through raw payload decode, schema harmonization, provider semantic extractors, and adjacent schema/runtime helpers.
Ref #251
Ref #250
Problem
Recent semantic-precision work established a stronger shared JSON/document contract, but the schema and lib boundary layer still had mixed assumptions:
dict[str, object]plumbing and newer JSON-shaped contractsSolution
This branch renews that boundary as one coherent slice:
polylogue.lib.json, including stricter fallback decoding behavior and filtered document-list coercionKey modules touched include:
polylogue/lib/json.pypolylogue/lib/raw_payload_decode.pypolylogue/lib/provider_semantics.pypolylogue/pipeline/materialization_runtime.pypolylogue/pipeline/semantic_capture.pypolylogue/schemas/unified*.pypolylogue/schemas/extraction.pypolylogue/schemas/observation_runtime.pypolylogue/schemas/validator.pypolylogue/sources/source_acquisition.pyVerification
ruff check polylogue/lib/provider_semantics.py polylogue/schemas/unified.py polylogue/schemas/unified_adapters.py polylogue/schemas/unified_fallbacks.py polylogue/schemas/unified_models.py polylogue/schemas/unified_provider_meta_coercion.py polylogue/schemas/unified_provider_meta_harmonize.py polylogue/schemas/unified_provider_meta_runtime.pymypy polylogue/lib/provider_semantics.py polylogue/schemas/unified.py polylogue/schemas/unified_adapters.py polylogue/schemas/unified_fallbacks.py polylogue/schemas/unified_models.py polylogue/schemas/unified_provider_meta_coercion.py polylogue/schemas/unified_provider_meta_harmonize.py polylogue/schemas/unified_provider_meta_runtime.pypytest -q tests/unit/sources/test_unified_semantic_laws.py tests/unit/core/test_filters_schemas.py tests/integration/test_extraction_db.pypytest -q tests/unit/core/test_json.py tests/unit/core/test_models.py tests/unit/core/test_schema_corpus_alignment.py tests/unit/core/test_filters_schemas.py tests/unit/core/test_schema_generation.py tests/unit/sources/test_unified_semantic_laws.py tests/unit/sources/test_models.py tests/unit/sources/test_source_laws.py tests/integration/test_extraction_db.pydevtools verify