Skip to content

Shared query and archive-product infrastructure is buried inside domain modules #123

Closed

Description

@Sinity

Context

Several core archive surfaces are currently organized around broad domain roots rather than around the shared responsibilities they actually carry. polylogue/archive_products.py mixes contract versions, provenance models, payload DTOs, entity models, and query DTOs in one file. polylogue/cli/products_rendering.py, polylogue/cli/products_workflow.py, and polylogue/mcp/server_product_tools.py each bundle session, aggregate, and governance product families into single transport modules. polylogue/storage/backends/queries/conversations.py, polylogue/storage/backends/queries/raw.py, and polylogue/storage/backends/queries/mappers.py each mix identity, reads, writes, search, and row mapping.

The same pattern shows up in the read-model and support roots. polylogue/storage/session_product_rows.py, polylogue/storage/session_product_status.py, and polylogue/storage/session_product_storage.py span profiles, timelines, aggregates, and support helpers at once. polylogue/health_archive.py owns database/index checks, derived-model readiness, source checks, and schema checks together. polylogue/site/templates.py, polylogue/sources/parsers/base.py, polylogue/sources/drive_source.py, polylogue/cli/query_output.py, polylogue/ui/facade.py, and polylogue/schemas/validator.py each contain both orchestration and low-level support logic.

devtools/run_validation_lanes.py has the same coupling problem in the QA layer: lane declarations, command construction, dry-run formatting, and execution all live in one root.

Motivation

This layout makes focused work noisy. A small change to one product family tends to reopen the same large CLI, MCP, storage, and health modules because the shared scaffolding is not isolated. Query changes carry the same cost: read-only search work, write-path changes, mapper fixes, and raw-state updates all sit next to one another in the same roots, which increases merge pressure and makes review harder than it needs to be.

It also makes testing narrower concerns awkward. When runtime helpers, payload models, and orchestrators are all defined together, there is no natural seam for a unit test to target. The code can still be exercised through end-to-end suites, but the module boundaries do not help us prove or evolve one concern at a time. The result is a codebase that is technically modular at the package level but still behaves monolithically inside the most active roots.

Scope

The scope here is to extract shared query, storage, archive-product, health, site, source, UI, and validation-lane infrastructure into dedicated sibling modules while preserving the existing top-level entry points where they still make sense.

In scope:

  • archive-product contract roots and product transport helpers
  • storage query backends, session-product read-model helpers, and derived-status/debt helpers
  • archive health orchestration vs runtime/source/schema check families
  • page/template composition, parser/provider support, Drive source runtime helpers, query output/UI helpers, and validator support
  • validation lane declarations vs runtime execution

Out of scope:

  • changing product schemas or query semantics
  • introducing new external dependencies
  • redesigning the CLI or MCP product surfaces

Acceptance criteria

  • polylogue/archive_products.py, polylogue/cli/products_*, polylogue/mcp/server_product_tools.py, and polylogue/health_archive.py remain usable entry points, but their concrete runtime/model/rendering logic lives in narrower sibling modules.
  • Conversation and raw query code is split so identity, reads, writes, search, and mapper logic no longer share the same root files.
  • Session-product profile/timeline/aggregate/thread helpers are split into narrower row, status, and storage modules without changing the persisted product model or repository/query-store behavior.
  • Validation lane dry runs and execution still resolve the same lane names, but declarations are separated from runtime helpers.
  • Site templates, provider/parser support, Drive runtime helpers, query output, UI facade support, and validator helpers each have dedicated modules instead of remaining inside omnibus roots.

Activity

  1. added
    type:refactor
    faux-pull-request
    on Apr 7, 2026
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:parserarea:qaarea:schemaarea:storagefaux-pull-requesttype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions