Repository navigation
refactor: split query stats route helpers - #305
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
89c5957 to
656b998
Compare
8dd8628 to
94927b4
Compare
## Summary - Extracts query stats route helper functions from the main query execution branch chain. - Centralizes stats dimension fallback and summary-vs-query-backed summary loading for semantic/profile grouped stats. - Keeps existing route behavior and output calls intact. ## Problem `polylogue/cli/query.py` repeated summary loading and query-plan fallback logic across semantic and profile stats routes. The main execution function was doing orchestration plus low-level route bookkeeping inline, which made it harder to reason about branch equivalence. ## Solution - Add a typed `QueryExecutionStore` protocol for the combined repository surface used by query execution. - Add `_stats_dimension`, `_semantic_stats_summaries`, and `_profile_stats_summaries` helpers. - Replace duplicated route branches with helper calls while preserving fallback to hydrated conversation stats when action-event-backed stats are unavailable. Ref #270 ## Verification - `ruff format polylogue/cli/query.py` - `ruff check polylogue/cli/query.py` - `mypy polylogue/cli/query.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_query_exec.py` - `pytest -q tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_query_exec.py -k 'stats_by or route or query_route or semantic or profile'` - push hook: `devtools verify --quick`
## Summary - Replace the schema-local JSON alias module with the canonical runtime JSON contract in polylogue.lib.json. - Update schema, MCP, surface, CLI, and test imports to use the canonical JSON types and coercion helpers. - Tighten readiness, repair, maintenance, and check-command machine payloads to return canonical JSONDocument values. - Remove polylogue/schemas/json_types.py so new schema code cannot drift back to the unsafe cast-only helper. ## Problem - The codebase carried two JSON helper modules: polylogue.lib.json, which validates JSON values at runtime, and polylogue.schemas.json_types, which duplicated the type aliases but used cast-only coercion. - That split made schema code depend on a weaker, path-dependent contract and left check/maintenance JSON renderers with object-shaped payloads instead of explicit JSON contracts. ## Solution - Standardize internal imports on polylogue.lib.json across the schema/tooling/tests surface. - Convert readiness, repair, maintenance, and check rendering payload outputs to canonical JSONDocument coercion. - Delete the duplicate schema-local helper module instead of keeping a compatibility wrapper. ## Verification - ruff check polylogue tests/infra tests/unit - mypy polylogue tests/infra tests/unit - pytest -q tests/unit/core/test_schema_laws.py tests/unit/core/test_schema_registry.py tests/unit/core/test_schema_cluster_assignment.py tests/unit/core/test_schema_annotation_contracts.py tests/unit/pipeline/test_prepare_semantic.py tests/unit/pipeline/test_run_sources.py tests/unit/sources/test_source_laws.py tests/unit/sources/test_drive_ops.py - mypy polylogue/maintenance_models.py polylogue/readiness.py polylogue/storage/repair.py polylogue/cli/check_models.py polylogue/cli/check_rendering_json.py - pytest -q tests/unit/cli/test_check.py tests/unit/storage/test_repair.py tests/unit/core/test_health_core.py tests/unit/core/test_maintenance_targets.py - git push hook: devtools verify --quick Stacked on #305. Ref #300.
`cli/query.py` repeated summary loading and query-plan fallback logic across semantic and profile stats routes. The main execution function was doing orchestration plus low-level route bookkeeping inline, which made branch equivalence harder to reason about. Extracts stats route helper functions from the main query execution branch chain. Centralizes stats dimension fallback and summary-vs-query-backed summary loading for semantic/profile grouped stats. Adds a typed `QueryExecutionStore` protocol for the combined repository surface used by query execution; adds `_stats_dimension`, `_semantic_stats_summaries`, and `_profile_stats_summaries` helpers. Replaces duplicated route branches with helper calls while preserving fallback to hydrated conversation stats when action-event-backed stats are unavailable. Verification: ruff + mypy + pytest over query-exec / query-exec-laws stats/route/semantic/profile coverage; devtools verify --quick green. Ref #270
The codebase carried two JSON helper modules: `polylogue.lib.json` validates JSON values at runtime, while `polylogue.schemas.json_types` duplicated the type aliases but used cast-only coercion. Schema code depended on a weaker, path-dependent contract, and check/maintenance JSON renderers carried object-shaped payloads instead of explicit JSON contracts. Standardizes internal imports on `polylogue.lib.json` across the schema / tooling / tests surface. Updates schema, MCP, surface, CLI, and test imports to use the canonical JSON types and coercion helpers. Tightens readiness, repair, maintenance, and check-command machine payloads to return canonical `JSONDocument` values. Deletes `polylogue/schemas/json_types.py` so new schema code cannot drift back to the unsafe cast-only helper (no compatibility wrapper). Verification: ruff + mypy + pytest over schema / pipeline / source / check / repair / health-core / maintenance-targets suites; devtools verify --quick green. Stacked on #305. Ref #300
`cli/query.py` repeated summary loading and query-plan fallback logic across semantic and profile stats routes. The main execution function was doing orchestration plus low-level route bookkeeping inline, which made branch equivalence harder to reason about. Extracts stats route helper functions from the main query execution branch chain. Centralizes stats dimension fallback and summary-vs-query-backed summary loading for semantic/profile grouped stats. Adds a typed `QueryExecutionStore` protocol for the combined repository surface used by query execution; adds `_stats_dimension`, `_semantic_stats_summaries`, and `_profile_stats_summaries` helpers. Replaces duplicated route branches with helper calls while preserving fallback to hydrated conversation stats when action-event-backed stats are unavailable. Verification: ruff + mypy + pytest over query-exec / query-exec-laws stats/route/semantic/profile coverage; devtools verify --quick green. Ref #270
The codebase carried two JSON helper modules: `polylogue.lib.json` validates JSON values at runtime, while `polylogue.schemas.json_types` duplicated the type aliases but used cast-only coercion. Schema code depended on a weaker, path-dependent contract, and check/maintenance JSON renderers carried object-shaped payloads instead of explicit JSON contracts. Standardizes internal imports on `polylogue.lib.json` across the schema / tooling / tests surface. Updates schema, MCP, surface, CLI, and test imports to use the canonical JSON types and coercion helpers. Tightens readiness, repair, maintenance, and check-command machine payloads to return canonical `JSONDocument` values. Deletes `polylogue/schemas/json_types.py` so new schema code cannot drift back to the unsafe cast-only helper (no compatibility wrapper). Verification: ruff + mypy + pytest over schema / pipeline / source / check / repair / health-core / maintenance-targets suites; devtools verify --quick green. Stacked on #305. Ref #300
`cli/query.py` repeated summary loading and query-plan fallback logic across semantic and profile stats routes. The main execution function was doing orchestration plus low-level route bookkeeping inline, which made branch equivalence harder to reason about. Extracts stats route helper functions from the main query execution branch chain. Centralizes stats dimension fallback and summary-vs-query-backed summary loading for semantic/profile grouped stats. Adds a typed `QueryExecutionStore` protocol for the combined repository surface used by query execution; adds `_stats_dimension`, `_semantic_stats_summaries`, and `_profile_stats_summaries` helpers. Replaces duplicated route branches with helper calls while preserving fallback to hydrated conversation stats when action-event-backed stats are unavailable. Verification: ruff + mypy + pytest over query-exec / query-exec-laws stats/route/semantic/profile coverage; devtools verify --quick green. Ref #270
The codebase carried two JSON helper modules: `polylogue.lib.json` validates JSON values at runtime, while `polylogue.schemas.json_types` duplicated the type aliases but used cast-only coercion. Schema code depended on a weaker, path-dependent contract, and check/maintenance JSON renderers carried object-shaped payloads instead of explicit JSON contracts. Standardizes internal imports on `polylogue.lib.json` across the schema / tooling / tests surface. Updates schema, MCP, surface, CLI, and test imports to use the canonical JSON types and coercion helpers. Tightens readiness, repair, maintenance, and check-command machine payloads to return canonical `JSONDocument` values. Deletes `polylogue/schemas/json_types.py` so new schema code cannot drift back to the unsafe cast-only helper (no compatibility wrapper). Verification: ruff + mypy + pytest over schema / pipeline / source / check / repair / health-core / maintenance-targets suites; devtools verify --quick green. Stacked on #305. Ref #300
|
@codex review |
Summary
Problem
polylogue/cli/query.pyrepeated summary loading and query-plan fallback logic across semantic and profile stats routes. The main execution function was doing orchestration plus low-level route bookkeeping inline, which made it harder to reason about branch equivalence.Solution
QueryExecutionStoreprotocol for the combined repository surface used by query execution._stats_dimension,_semantic_stats_summaries, and_profile_stats_summarieshelpers.Ref #270
Verification
ruff format polylogue/cli/query.pyruff check polylogue/cli/query.pymypy polylogue/cli/query.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_query_exec.pypytest -q tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_query_exec.py -k 'stats_by or route or query_route or semantic or profile'devtools verify --quick