Skip to content

refactor(archive): move query semantics out of lib - #636

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/archive-query-naming
May 1, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/archive-query-naming

Conversation

@Sinity

@Sinity Sinity commented May 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Moves the archive query planning/runtime package from polylogue.lib.query to polylogue.archive.query and updates all imports, tests, topology metadata, and generated documentation references.

Problem

The query planner, runtime filters, retrieval helpers, miss diagnostics, and query spec are archive-domain semantics. Keeping them under polylogue.lib preserves the old library-bucket vocabulary and makes the archive/core split in #634/#635 harder to execute cleanly.

Solution

  • Moved polylogue/lib/query/ to polylogue/archive/query/.
  • Moved query-specific unit tests from tests/unit/lib/ to tests/unit/archive/.
  • Updated CLI, MCP, operations, storage filter builder, artifacts/proof metadata, and tests to import from the archive package.
  • Updated topology generation/status and mutation campaign metadata so the control plane records archive-query as an explicit placement domain.

Verification

  • pytest -q tests/unit/archive/test_query_*.py tests/unit/core/test_query_fields.py tests/unit/core/test_query_retrieval_candidates.py tests/unit/core/test_cwd_prefix_filter.py tests/unit/cli/test_query_exec.py tests/unit/cli/test_query_exec_laws.py tests/unit/devtools/test_render_topology_status.py tests/unit/architecture/test_topology_invariants.py → 208 passed
  • devtools verify-topology → realized=697 declared=697 blocking=False
  • devtools render-all --check → sync OK
  • push hook devtools verify --quick → all checks passed

Ref #634
Ref #635

Summary by CodeRabbit

Release Notes

  • Refactor

    • Reorganized internal query module architecture for improved domain separation and maintainability.
  • Documentation

    • Updated topology status dashboard and mutation scenario documentation to reflect architectural changes.

Copilot AI review requested due to automatic review settings May 1, 2026 14:09
@coderabbitai

coderabbitai Bot commented May 1, 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 43 minutes and 12 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ 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: 20d2f7d8-16ed-4654-b540-8d2ba4919a3b

📥 Commits

Reviewing files that changed from the base of the PR and between eac44a9 and be62ebb.

📒 Files selected for processing (66)
  • devtools/build_topology_projection.py
  • devtools/command_catalog.py
  • devtools/mutation_scenario_catalog.py
  • devtools/render_topology_status.py
  • devtools/verify_cluster_cohesion.py
  • docs/plans/topology-target.yaml
  • docs/test-quality-workflows.md
  • docs/topology-status.md
  • polylogue/archive/__init__.py
  • polylogue/archive/query/__init__.py
  • polylogue/archive/query/fields.py
  • polylogue/archive/query/miss_diagnostics.py
  • polylogue/archive/query/plan.py
  • polylogue/archive/query/plan_description.py
  • polylogue/archive/query/plan_execution.py
  • polylogue/archive/query/retrieval.py
  • polylogue/archive/query/retrieval_candidates.py
  • polylogue/archive/query/retrieval_search.py
  • polylogue/archive/query/runtime.py
  • polylogue/archive/query/runtime_filters.py
  • polylogue/archive/query/runtime_matching.py
  • polylogue/archive/query/runtime_plan.py
  • polylogue/archive/query/search_hits.py
  • polylogue/archive/query/sorting.py
  • polylogue/archive/query/spec.py
  • polylogue/archive/query/support.py
  • polylogue/artifacts/__init__.py
  • polylogue/cli/click_option_groups.py
  • polylogue/cli/commands/diagnostics.py
  • polylogue/cli/query.py
  • polylogue/cli/query_actions.py
  • polylogue/cli/query_contracts.py
  • polylogue/cli/query_feedback.py
  • polylogue/cli/query_output.py
  • polylogue/cli/query_progress.py
  • polylogue/cli/query_semantic.py
  • polylogue/cli/query_stats.py
  • polylogue/cli/root_request.py
  • polylogue/cli/shared/product_command_contracts.py
  • polylogue/lib/filter/builder.py
  • polylogue/lib/filter/filters.py
  • polylogue/lib/search_hits.py
  • polylogue/mcp/payloads.py
  • polylogue/mcp/query_contracts.py
  • polylogue/operations/archive.py
  • polylogue/operations/specs.py
  • polylogue/storage/backends/queries/filter_builder.py
  • tests/unit/architecture/test_topology_invariants.py
  • tests/unit/archive/test_query_miss_diagnostics.py
  • tests/unit/archive/test_query_runtime_filters.py
  • tests/unit/archive/test_query_runtime_matching.py
  • tests/unit/archive/test_query_search_runtime.py
  • tests/unit/cli/test_bulk_export.py
  • tests/unit/cli/test_diagnostics.py
  • tests/unit/cli/test_query_exec.py
  • tests/unit/cli/test_query_exec_laws.py
  • tests/unit/cli/test_query_progress_runtime.py
  • tests/unit/cli/test_query_support_runtime.py
  • tests/unit/core/test_cwd_prefix_filter.py
  • tests/unit/core/test_query_fields.py
  • tests/unit/core/test_query_retrieval_candidates.py
  • tests/unit/core/test_repo_filter.py
  • tests/unit/devtools/test_render_topology_status.py
  • tests/unit/devtools/test_topology_projection_witness.py
  • tests/unit/mcp/test_tool_contracts.py
  • tests/unit/pipeline/test_tail_overlay_runtime.py
📝 Walkthrough

Walkthrough

This pull request relocates query-related functionality from polylogue/lib/query/ to polylogue/archive/query/ and systematically updates imports, topology classification rules, documentation, and tests accordingly. The refactoring treats polylogue/archive/query/ as an explicit "archive-query" placement domain.

Changes

Cohort / File(s) Summary
Archive Query Implementation
polylogue/archive/__init__.py, polylogue/archive/query/*
Query modules relocated with imports internally repointed from polylogue.lib.query.* to polylogue.archive.query.* across fields, plan, execution, retrieval, runtime, filtering, and search components.
CLI Modules
polylogue/cli/click_option_groups.py, polylogue/cli/commands/diagnostics.py, polylogue/cli/query*.py, polylogue/cli/root_request.py, polylogue/cli/shared/product_command_contracts.py
Import paths updated for ConversationQuerySpec, QuerySpecError, QueryMissDiagnostics, and related query utilities from new polylogue.archive.query.* locations.
Core/Storage/Lib Modules
polylogue/lib/filter/builder.py, polylogue/lib/filter/filters.py, polylogue/lib/search_hits.py, polylogue/storage/backends/queries/filter_builder.py
Imports for query plan types, filter helpers, and summary utilities redirected to polylogue.archive.query.*.
Operations/Artifacts
polylogue/artifacts/__init__.py, polylogue/operations/archive.py, polylogue/operations/specs.py, polylogue/mcp/payloads.py, polylogue/mcp/query_contracts.py
Code references and type imports updated to reference polylogue.archive.query.* for miss diagnostics, plan execution, and query specs.
Devtools and Topology
devtools/build_topology_projection.py, devtools/command_catalog.py, devtools/mutation_scenario_catalog.py, devtools/render_topology_status.py, devtools/verify_cluster_cohesion.py
Topology classification logic updated to explicitly handle polylogue/archive/query/ as "archive-query" domain; command examples and mutation targets repointed to archive location; owner title mapping changed from lib-query to archive-query.
Documentation
docs/plans/topology-target.yaml, docs/test-quality-workflows.md, docs/topology-status.md
Topology projection entries, mutation campaign examples, and generated status dashboard updated to reflect archive query location and ownership changes.
Unit Tests
tests/unit/archive/test_query_*.py, tests/unit/cli/test_*.py, tests/unit/core/test_*.py, tests/unit/devtools/test_render_topology_status.py, tests/unit/mcp/test_*.py, tests/unit/pipeline/test_*.py, tests/unit/architecture/test_topology_invariants.py
Test imports and monkeypatch targets updated to use polylogue.archive.query.* modules; topology invariant assertions updated to validate archive query location.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Suggested labels

type:refactor, area:storage, area:cli, area:docs

Poem

🐰 The query hops to archive's keep,
From lib to fresh domain so deep,
Imports traced and paths reset,
A tidy move—now classed the best!
✨ Semantics archived right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.35% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main refactoring: moving query semantics from lib to archive namespace.
Description check ✅ Passed The description comprehensively covers all required sections: Summary, Problem, Solution, Verification, and Risks. It explains the rationale, what was moved, the scope of changes, and includes test results.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/archive-query-naming

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
Review rate limit: 0/1 reviews remaining, refill in 43 minutes and 12 seconds.

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

@github-actions

github-actions Bot commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Polylogue Proof Pack

Refs: origin/master..HEAD
Changed paths: 66

Affected Domains

  • architecture_discipline — 2 claim(s), maturity growing
  • docs_media — 0 claim(s), maturity seed
  • operational_resilience — 14 claim(s), maturity seed
  • spec_completeness — 1 claim(s), maturity seed
  • unclassified — 5 claim(s), maturity seed

Required Gates

  • devtools verify-manifests — structural manifest changed
  • devtools affected-obligations --path devtools/build_topology_projection.py — refresh structural obligation routing
  • devtools verify-topology — topology projection changed
  • devtools render-all --check — generated surface or renderer changed
  • devtools affected-obligations --path docs/plans/topology-target.yaml — refresh structural obligation routing
  • devtools affected-obligations --path docs/topology-status.md — refresh structural obligation routing
  • pytest tests/unit/cli — CLI command surface changed
  • pytest tests/unit/proof/test_evidence_runners.py — CLI proof runners exercise command output
  • devtools render-cli-reference --check — CLI reference is generated from command help
  • pytest tests/unit/operations/test_specs.py — operation spec routing metadata changed
  • devtools artifact-graph --json — operation specs feed artifact graph views
  • devtools verify --quick — full PR gate remains explicit
  • devtools verify — full PR gate remains explicit
  • devtools build-package — deployment readiness gate; run when packaging or release confidence matters
  • nix flake check — deployment readiness gate; run when packaging or release confidence matters

Known Gaps

  • docs_media: docs_media: No scenario for documentation freshness verification [owner: scenario-coverage; next: Add scenario family or generated projection for this subject], docs_media: README examples and media are not yet generated from executable scenario projections. [owner: docs-media; next: Add executable scenario projection or media integrity gate], docs_media: Screenshots and VHS media have no committed nonblank/readability verification. [owner: docs-media; next: Add executable scenario projection or media integrity gate]

Oracle / Cost

  • oracle mix: {"construction_sanity": 254, "drift_check": 2, "manual_review": 1, "proof": 36, "smoke": 12}
  • cost tier: {"static": 300, "unit": 5}
  • stale evidence: 305
  • manual review cells: 1

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Moves archive query semantics out of the generic polylogue.lib bucket into an explicit archive-domain package (polylogue.archive.query) and updates all repository references (imports, tests, devtools topology metadata, and docs) accordingly.

Changes:

  • Relocated the query planner/runtime implementation from polylogue.lib.query to polylogue.archive.query.
  • Updated runtime consumers (CLI, MCP, operations, storage filter builder) and unit tests to use the new import paths.
  • Updated topology/status rendering and mutation/topology metadata to treat archive-query as an explicit placement/ownership domain.

Reviewed changes

Copilot reviewed 61 out of 65 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit/pipeline/test_tail_overlay_runtime.py Updates query spec import to the new archive query package.
tests/unit/mcp/test_tool_contracts.py Updates MCP tool contract tests to import query spec + miss diagnostics from archive query.
tests/unit/devtools/test_render_topology_status.py Adjusts topology dashboard expectations for the new archive-query owner and archive paths.
tests/unit/core/test_repo_filter.py Updates query spec import for filter-builder unit coverage.
tests/unit/core/test_query_retrieval_candidates.py Updates retrieval candidate imports to polylogue.archive.query.*.
tests/unit/core/test_query_fields.py Updates query field/plan/spec imports to the new archive query modules.
tests/unit/core/test_cwd_prefix_filter.py Updates query spec import for cwd-prefix filter tests.
tests/unit/cli/test_query_support_runtime.py Updates CLI query tests to use archive query spec.
tests/unit/cli/test_query_progress_runtime.py Updates query progress tests to use archive query spec.
tests/unit/cli/test_query_exec_laws.py Updates property/law tests to import spec + miss diagnostics from archive query.
tests/unit/cli/test_query_exec.py Updates inline imports in CLI execution tests to the new archive query spec/errors.
tests/unit/cli/test_diagnostics.py Updates diagnostics CLI tests to use archive query spec.
tests/unit/cli/test_bulk_export.py Updates bulk export tests to use archive query spec.
tests/unit/archive/test_query_search_runtime.py Migrates archive query search runtime tests to the new archive query modules + patch targets.
tests/unit/archive/test_query_runtime_matching.py Updates runtime matching tests and patch targets to polylogue.archive.query.*.
tests/unit/archive/test_query_runtime_filters.py Updates runtime filters tests and patch targets to polylogue.archive.query.*.
tests/unit/archive/test_query_miss_diagnostics.py Updates miss diagnostics tests and patch target to polylogue.archive.query.*.
tests/unit/architecture/test_topology_invariants.py Updates topology invariants to assert query lives under polylogue/archive/query.
polylogue/storage/backends/queries/filter_builder.py Switches storage-side helper import to archive.query.fields.
polylogue/operations/specs.py Updates operation code references to point at polylogue.archive.query.plan_execution.
polylogue/operations/archive.py Updates archive operations to use polylogue.archive.query (spec/search hits/miss diagnostics).
polylogue/mcp/query_contracts.py Updates MCP query contracts to import query spec from archive query.
polylogue/mcp/payloads.py Updates TYPE_CHECKING imports for query miss diagnostics types to archive query.
polylogue/lib/search_hits.py Retargets the summary conversion helper import to polylogue.archive.query.support.
polylogue/lib/filter/filters.py Repoints filter adapter plumbing to the new archive query plan/fields/execution APIs.
polylogue/lib/filter/builder.py Updates TYPE_CHECKING plan import to polylogue.archive.query.plan.
polylogue/cli/shared/product_command_contracts.py Updates query parsing helpers import (QuerySpecError/date parsing) to archive query spec.
polylogue/cli/root_request.py Updates root request query spec import to archive query.
polylogue/cli/query_stats.py Updates TYPE_CHECKING query spec import to archive query.
polylogue/cli/query_semantic.py Updates TYPE_CHECKING query spec import to archive query.
polylogue/cli/query_progress.py Updates query progress dependencies (uses_action_read_model/spec) to archive query.
polylogue/cli/query_output.py Updates TYPE_CHECKING query imports (spec/miss diagnostics) to archive query.
polylogue/cli/query_feedback.py Updates TYPE_CHECKING query imports (spec/miss diagnostics) to archive query.
polylogue/cli/query_contracts.py Updates CLI query contracts to import query spec from archive query.
polylogue/cli/query_actions.py Updates TYPE_CHECKING query spec import to archive query.
polylogue/cli/query.py Updates CLI query runtime to import QuerySpecError / miss diagnostics / search hits from archive query.
polylogue/cli/commands/diagnostics.py Updates diagnostics command to import query spec from archive query.
polylogue/cli/click_option_groups.py Updates CLI option groups to import query constants from archive query spec.
polylogue/artifacts/init.py Updates artifact metadata code refs to the new archive query plan execution module.
polylogue/archive/query/support.py Adds shared query support helpers in the new archive query package.
polylogue/archive/query/spec.py Updates spec module to depend on archive query plan/fields (post-move wiring).
polylogue/archive/query/sorting.py Adds sorting/finalization helpers in the new archive query package.
polylogue/archive/query/search_hits.py Updates search-hits planning helpers to import from archive query submodules.
polylogue/archive/query/runtime_plan.py Updates runtime plan utilities to import field predicates from archive query.
polylogue/archive/query/runtime_matching.py Updates runtime matching module TYPE_CHECKING plan import to archive query.
polylogue/archive/query/runtime_filters.py Updates runtime filter implementation to use archive query matching/support + TYPE_CHECKING plan import.
polylogue/archive/query/runtime.py Updates runtime entrypoint imports to archive query runtime/filter/matching/plan modules.
polylogue/archive/query/retrieval_search.py Updates retrieval search implementation imports to archive query and adjusts TYPE_CHECKING plan import.
polylogue/archive/query/retrieval_candidates.py Updates candidate retrieval module imports to archive query support/search.
polylogue/archive/query/retrieval.py Updates retrieval orchestrator imports to archive query retrieval modules.
polylogue/archive/query/plan_execution.py Updates plan execution to use archive query plan/retrieval/support.
polylogue/archive/query/plan_description.py Updates plan description to use archive query fields.
polylogue/archive/query/plan.py Updates core plan module to import from archive query modules and rewire execution helpers.
polylogue/archive/query/miss_diagnostics.py Updates miss diagnostics dependencies to archive query retrieval/spec.
polylogue/archive/query/fields.py Adds canonical query-field descriptor registry + helpers in archive query package.
polylogue/archive/query/init.py Establishes the new archive query package boundary.
polylogue/archive/init.py Adds archive-domain package marker module/docstring.
docs/topology-status.md Updates generated topology status for the new archive-query owner and file counts.
docs/test-quality-workflows.md Updates mutation workflow docs to reference polylogue/archive/query/plan.py.
docs/plans/topology-target.yaml Updates topology projection to assign archive query modules to archive-query and remove lib/query entries.
devtools/verify_cluster_cohesion.py Updates cluster naming example/help to match archive/query cluster.
devtools/render_topology_status.py Renames topology owner title from lib-query to archive-query.
devtools/mutation_scenario_catalog.py Updates mutation scenario paths to target polylogue/archive/query/plan.py.
devtools/command_catalog.py Updates verify-cluster-cohesion example usage to --cluster archive/query.
devtools/build_topology_projection.py Updates topology classification rules to assign polylogue/archive/query/ to archive-query and map query_* to archive/query/.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

# polylogue/lib/ subpackage rules — prefix → subpackage
# Archive-domain subpackage rules — prefix → subpackage
Problem: the query planner/runtime package is archive-domain semantics, but it lived under polylogue.lib, which hides ownership and keeps the old library-bucket vocabulary alive.\n\nWhat changed: move polylogue.lib.query to polylogue.archive.query, update imports, move the query unit tests under tests/unit/archive, and regenerate topology/test-quality docs so the control plane records archive-query as an owned placement domain.\n\nVerification:\n- pytest -q tests/unit/archive/test_query_*.py tests/unit/core/test_query_fields.py tests/unit/core/test_query_retrieval_candidates.py tests/unit/core/test_cwd_prefix_filter.py tests/unit/cli/test_query_exec.py tests/unit/cli/test_query_exec_laws.py tests/unit/devtools/test_render_topology_status.py tests/unit/architecture/test_topology_invariants.py\n- devtools verify-topology\n- devtools render-all --check\n\nRef #634\nRef #635
@Sinity
Sinity force-pushed the feature/refactor/archive-query-naming branch from eac44a9 to be62ebb Compare May 1, 2026 14:26
@Sinity
Sinity merged commit 7390be0 into master May 1, 2026
14 checks passed
@Sinity
Sinity deleted the feature/refactor/archive-query-naming branch May 1, 2026 14:40
Sinity added a commit that referenced this pull request May 7, 2026
## Summary

Moves the archive query planning/runtime package from
`polylogue.lib.query` to `polylogue.archive.query` and updates all
imports, tests, topology metadata, and generated documentation
references.

## Problem

The query planner, runtime filters, retrieval helpers, miss diagnostics,
and query spec are archive-domain semantics. Keeping them under
`polylogue.lib` preserves the old library-bucket vocabulary and makes
the archive/core split in #634/#635 harder to execute cleanly.

## Solution

- Moved `polylogue/lib/query/` to `polylogue/archive/query/`.
- Moved query-specific unit tests from `tests/unit/lib/` to
`tests/unit/archive/`.
- Updated CLI, MCP, operations, storage filter builder, artifacts/proof
metadata, and tests to import from the archive package.
- Updated topology generation/status and mutation campaign metadata so
the control plane records `archive-query` as an explicit placement
domain.

## Verification

- `pytest -q tests/unit/archive/test_query_*.py
tests/unit/core/test_query_fields.py
tests/unit/core/test_query_retrieval_candidates.py
tests/unit/core/test_cwd_prefix_filter.py
tests/unit/cli/test_query_exec.py tests/unit/cli/test_query_exec_laws.py
tests/unit/devtools/test_render_topology_status.py
tests/unit/architecture/test_topology_invariants.py` → 208 passed
- `devtools verify-topology` → realized=697 declared=697 blocking=False
- `devtools render-all --check` → sync OK
- push hook `devtools verify --quick` → all checks passed

Ref #634
Ref #635


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **Refactor**
* Reorganized internal query module architecture for improved domain
separation and maintainability.

* **Documentation**
* Updated topology status dashboard and mutation scenario documentation
to reflect architectural changes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

2 participants