Skip to content

refactor: unify query semantics under field descriptors #321

Closed

Description

@Sinity

Context

The low-churn audit in #315 found that query semantics are still expressed through several parallel models: polylogue/lib/query_spec.py, polylogue/lib/query_plan.py, polylogue/lib/filter_builder.py, polylogue/storage/search_query_builders.py, polylogue/storage/backends/queries/filter_builder.py, CLI contracts, and MCP-facing parameter plumbing.

This is no longer type debt; it is semantic duplication. The same field inventory is manually restated for normalization, presence checks, human descriptions, storage pushdown, and surface metadata.

Scope

Introduce a query field descriptor/catalog layer that can own shared query field facts and drive the existing query surfaces without changing user-facing behavior.

Candidate responsibilities:

  • field normalization and defaults
  • filter-presence detection
  • human-readable query descriptions
  • storage pushdown eligibility and SQL parameter mapping
  • CLI/MCP/facade surface metadata where practical

Acceptance criteria

  • The descriptor catalog replaces at least one duplicated field inventory across spec, plan, filter, and storage layers.
  • Existing CLI, MCP, and facade behavior remains compatible unless a correctness bug is explicitly found.
  • Query tests cover descriptor-driven behavior instead of only snapshotting final output.
  • Focused query/storage tests pass.
  • devtools verify passes before PR merge.

Ref #315

Activity

  1. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Starting #321 on feature/refactor/query-field-descriptors.

    Working scope:

    • introduce the query field descriptor/catalog layer in the query substrate;
    • wire it into an existing duplicated field inventory across query spec/plan/filter/storage paths;
    • preserve CLI, MCP, and facade behavior unless a concrete correctness bug appears;
    • add descriptor-focused query/storage tests, then run focused gates and final devtools verify before PR.

    Scratch log: .agent/scratch/321-query-field-descriptors.md.

  2. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Implementation for #321 is up in PR #363: #363

    What changed:

    • Added polylogue/lib/query_fields.py as the shared descriptor catalog for query field facts.
    • Replaced duplicated field inventories in query spec descriptions/presence, query plan descriptions/presence, plan-to-record-query mapping, SQL pushdown params, runtime capability predicates, search-hit blockers, and storage stats-join detection.
    • Added tests/unit/core/test_query_fields.py for descriptor-driven spec/plan descriptions, active field names, pushdown params, record-query tuple/list shape, and stats-join metadata.

    Local verification:

    • focused ruff/mypy on touched files and descriptor tests;
    • focused query/MCP/storage pytest slices (175 passed, 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).

    Scratch log: .agent/scratch/321-query-field-descriptors.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliarea:mcparea:storagetype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions