Skip to content

refactor: derive session product status from descriptors #322

Closed

Description

@Sinity

Context

The low-churn audit in #315 found that polylogue/storage/session_product_status.py still repeats table checks, sync and async count queries, duplicate checks, FTS readiness checks, and status assembly logic.

The file is typed, but structurally boilerplate-heavy. A descriptor model for product tables and projections should reduce drift risk while keeping status semantics explicit.

Scope

Extract product status descriptors for tables/projections that can drive common status checks.

Candidate descriptors:

  • table name and row-count query
  • duplicate-key query where applicable
  • sync/async access path
  • FTS projection readiness checks
  • product status assembly metadata

Acceptance criteria

  • Repeated status-count and readiness patterns are replaced by descriptor-driven helpers.
  • Sync and async behavior stay equivalent.
  • Product status tests cover representative descriptor types and failure cases.
  • No user-facing CLI/MCP status contract changes unless explicitly documented.
  • devtools verify passes before PR merge.

Ref #315

Activity

  1. added
    type:refactor
    on Apr 21, 2026
  2. Sinity commented on Apr 23, 2026

    @Sinity
    OwnerAuthor

    Starting implementation on feature/refactor/session-product-status-descriptors.

    Tactic:

    • Keep the descriptor model local to polylogue/storage/session_product_status.py for this slice.
    • Add descriptors for table presence/counts, FTS projections, repair/count metrics, and readiness predicates.
    • Preserve SessionProductStatusSnapshot field names and CLI/MCP payload shape.
    • Add tests for representative descriptor behavior and sync/async parity on absent product tables, since that is the easiest fallback path for duplicated logic to drift.

    Verification target before PR: focused storage/product tests first, then devtools verify before merge.

  3. Sinity commented on Apr 23, 2026

    @Sinity
    OwnerAuthor

    Implementation checkpoint on feature/refactor/session-product-status-descriptors.

    What changed locally:

    • Added status descriptors in polylogue/storage/session_product_status.py for product tables, FTS projections, repair/count metrics, and readiness predicates.
    • Replaced repeated sync/async table/count/FTS/repair assembly logic with descriptor-driven helpers.
    • Preserved the public SessionProductStatusSnapshot field names and status payload shape.
    • Added tests/unit/storage/test_session_product_status_descriptors.py for representative descriptor behavior and sync/async parity when product tables are absent.

    Verification so far:

    • ruff check polylogue/storage/session_product_status.py tests/unit/storage/test_session_product_status_descriptors.py → passed
    • mypy polylogue/storage/session_product_status.py → no issues
    • pytest -q tests/unit/storage/test_session_product_status_descriptors.py tests/unit/cli/test_products.py -k 'session_product_status or descriptor or stale or duplicate' → 14 passed
    • pytest -q tests/unit/storage/test_session_product_status_descriptors.py tests/unit/cli/test_products.py tests/unit/storage/test_derived_status.py tests/unit/storage/test_embedding_stats.py → 44 passed
    • devtools render-all --check → generated surfaces in sync

    Next: run the full local devtools verify, then commit/open PR if clean.

  4. Sinity commented on Apr 23, 2026

    @Sinity
    OwnerAuthor

    Completed in PR #373 and squash-merged as 91a678cc8b378566aead2c847afd47108ce7041b.

    What landed:

    • Local descriptors now drive session product table checks, FTS projection checks, repair/count metrics, and readiness predicates in polylogue/storage/session_product_status.py.
    • Sync and async paths share the same descriptor catalogs while preserving the existing SessionProductStatusSnapshot and CLI/MCP payload contract.
    • Added descriptor-focused tests and an absent-product-table sync/async parity test in tests/unit/storage/test_session_product_status_descriptors.py.

    Verification used before merge:

    • ruff check polylogue/storage/session_product_status.py tests/unit/storage/test_session_product_status_descriptors.py -> passed
    • mypy polylogue/storage/session_product_status.py -> no issues
    • pytest -q tests/unit/storage/test_session_product_status_descriptors.py tests/unit/cli/test_products.py -k 'session_product_status or descriptor or stale or duplicate' -> 14 passed
    • pytest -q tests/unit/storage/test_session_product_status_descriptors.py tests/unit/cli/test_products.py tests/unit/storage/test_derived_status.py tests/unit/storage/test_embedding_stats.py -> 44 passed
    • devtools render-all --check -> generated surfaces in sync
    • devtools verify -> all checks passed
    • push pre-flight devtools verify --quick -> passed

    GitHub automation was quota-limited/unstable around review, but there were no inline review threads and local verification was clean.

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:storagetype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions