Skip to content

refactor: add query field descriptor catalog (#363) - #363

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/query-field-descriptors
Apr 22, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/query-field-descriptors

Conversation

@Sinity

@Sinity Sinity commented Apr 22, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a shared query field descriptor catalog and uses it to drive existing query-spec, query-plan, runtime capability, search-hit routing, and storage pushdown metadata paths.

Problem

#321 tracks semantic duplication found in #315: query fields were restated across spec descriptions, plan descriptions, filter presence checks, runtime capability checks, storage record-query mapping, SQL pushdown parameters, and stats-join detection. That made adding or changing one query field require hand-updating several parallel inventories.

Solution

Introduced polylogue/lib/query_fields.py as the shared descriptor catalog for query field facts: spec/plan attributes, active predicates, descriptions, record-query and SQL parameter mappings, stats-join requirements, runtime post-filter/content-loading flags, SQL-count blockers, action-event stats blockers, and search-hit evidence blockers.

Wired existing consumers through the catalog without changing CLI/MCP/facade signatures:

  • query_spec.py now delegates descriptions and filter-presence checks to descriptors.
  • query_plan_description.py delegates plan descriptions and presence checks.
  • query_plan.py delegates record-query and SQL pushdown mapping.
  • query_runtime_plan.py delegates runtime capability predicates.
  • query_search_hits.py delegates simple-message-hit blockers.
  • storage/backends/queries/filter_builder.py delegates stats-join detection.

Added descriptor tests covering spec/plan descriptions, active field names, SQL pushdown params, record-query tuple/list shape, and stats-join metadata.

Verification

  • ruff check polylogue/lib/query_fields.py polylogue/lib/query_spec.py polylogue/lib/query_plan.py polylogue/lib/query_plan_description.py polylogue/lib/query_runtime_plan.py polylogue/lib/query_search_hits.py polylogue/storage/backends/queries/filter_builder.py tests/unit/core/test_query_fields.py
  • mypy polylogue/lib/query_fields.py polylogue/lib/query_spec.py polylogue/lib/query_plan.py polylogue/lib/query_plan_description.py polylogue/lib/query_runtime_plan.py polylogue/lib/query_search_hits.py polylogue/storage/backends/queries/filter_builder.py tests/unit/core/test_query_fields.py
  • pytest -q tests/unit/core/test_query_fields.py tests/unit/lib/test_filter_executor.py tests/unit/core/test_filters_props.py -q
  • pytest -q tests/unit/cli/test_query_exec.py tests/unit/cli/test_click_app.py tests/unit/mcp/test_tool_contracts.py tests/unit/core/test_query_retrieval_candidates.py (175 passed)
  • pytest -q tests/unit/storage/test_store_ops.py tests/unit/storage/test_scale.py tests/unit/storage/test_search_misc.py tests/unit/storage/test_query_mappers.py (119 passed)
  • mypy polylogue/ tests/unit/core/test_query_fields.py
  • devtools render-all --check
  • devtools verify (all checks passed)
  • push hook: devtools verify --quick (all checks passed)

Closes #321

Problem: query field semantics were duplicated across spec descriptions, plan descriptions, runtime capability checks, storage pushdown, and stats-join detection. Keeping those lists aligned made query changes risky and obscured which layer owned each field fact.

What changed: introduced a shared query field descriptor catalog and wired existing spec, plan, search-hit, runtime capability, and storage stats-join paths through it without changing the CLI/MCP/facade query contract. Added descriptor tests covering descriptions, filter presence, SQL pushdown params, record-query shape, and stats metadata.

Verification: ruff check on touched files; mypy on touched files and full polylogue tree; focused query, MCP, and storage pytest slices; devtools render-all --check; devtools verify.

Closes #321
@coderabbitai

coderabbitai Bot commented Apr 22, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 34 minutes and 44 seconds before requesting another review.

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 34 minutes and 44 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9a8ce78d-ac4c-4cf8-b77e-9369e1297cc2

📥 Commits

Reviewing files that changed from the base of the PR and between 3c679aa and 35401c3.

📒 Files selected for processing (8)
  • polylogue/lib/query_fields.py
  • polylogue/lib/query_plan.py
  • polylogue/lib/query_plan_description.py
  • polylogue/lib/query_runtime_plan.py
  • polylogue/lib/query_search_hits.py
  • polylogue/lib/query_spec.py
  • polylogue/storage/backends/queries/filter_builder.py
  • tests/unit/core/test_query_fields.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/query-field-descriptors

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity Sinity changed the title refactor: add query field descriptor catalog refactor: add query field descriptor catalog (#363) Apr 22, 2026
@Sinity
Sinity merged commit 97ec439 into master Apr 22, 2026
10 of 13 checks passed
@Sinity
Sinity deleted the feature/refactor/query-field-descriptors branch April 22, 2026 18:14
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ 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".

@Sinity
Sinity removed the request for review from Copilot May 1, 2026 02:15
Sinity added a commit that referenced this pull request May 7, 2026
Summary:
Adds a shared query field descriptor catalog and uses it to drive existing query-spec, query-plan, runtime capability, search-hit routing, and storage pushdown metadata paths.

Problem:
#321 tracked semantic duplication found in #315: query fields were restated across spec descriptions, plan descriptions, filter presence checks, runtime capability checks, storage record-query mapping, SQL pushdown parameters, and stats-join detection. That made adding or changing one query field require hand-updating several parallel inventories.

Solution:
Introduced `polylogue/lib/query_fields.py` as the shared descriptor catalog for query field facts: spec/plan attributes, active predicates, descriptions, record-query and SQL parameter mappings, stats-join requirements, runtime post-filter/content-loading flags, SQL-count blockers, action-event stats blockers, and search-hit evidence blockers.

Wired existing consumers through the catalog without changing CLI/MCP/facade signatures:
- `query_spec.py` now delegates descriptions and filter-presence checks to descriptors.
- `query_plan_description.py` delegates plan descriptions and presence checks.
- `query_plan.py` delegates record-query and SQL pushdown mapping.
- `query_runtime_plan.py` delegates runtime capability predicates.
- `query_search_hits.py` delegates simple-message-hit blockers.
- `storage/backends/queries/filter_builder.py` delegates stats-join detection.

Added descriptor tests covering spec/plan descriptions, active field names, SQL pushdown params, record-query tuple/list shape, and stats-join metadata.

Verification:
- `ruff check polylogue/lib/query_fields.py polylogue/lib/query_spec.py polylogue/lib/query_plan.py polylogue/lib/query_plan_description.py polylogue/lib/query_runtime_plan.py polylogue/lib/query_search_hits.py polylogue/storage/backends/queries/filter_builder.py tests/unit/core/test_query_fields.py`
- `mypy polylogue/lib/query_fields.py polylogue/lib/query_spec.py polylogue/lib/query_plan.py polylogue/lib/query_plan_description.py polylogue/lib/query_runtime_plan.py polylogue/lib/query_search_hits.py polylogue/storage/backends/queries/filter_builder.py tests/unit/core/test_query_fields.py`
- `pytest -q tests/unit/core/test_query_fields.py tests/unit/lib/test_filter_executor.py tests/unit/core/test_filters_props.py -q`
- `pytest -q tests/unit/cli/test_query_exec.py tests/unit/cli/test_click_app.py tests/unit/mcp/test_tool_contracts.py tests/unit/core/test_query_retrieval_candidates.py` (`175 passed`)
- `pytest -q tests/unit/storage/test_store_ops.py tests/unit/storage/test_scale.py tests/unit/storage/test_search_misc.py tests/unit/storage/test_query_mappers.py` (`119 passed`)
- `mypy polylogue/ tests/unit/core/test_query_fields.py`
- `devtools render-all --check`
- `devtools verify` (`all checks passed`)
- push hook: `devtools verify --quick` (`all checks passed`)

Closes #321
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.

refactor: unify query semantics under field descriptors

1 participant