Skip to content

refactor: rebuild storage and product runtime boundary contracts #259

Closed

Description

@Sinity

Outcome

Continue the semantic-precision renewal program by rebuilding the persisted runtime and product boundary layer around explicit typed state/product contracts instead of broad object/mapping plumbing.

Ref #250

Problem or opportunity

After the source, run/acquisition, and schema/audit tranches, the next highest remaining pressure is concentrated in the runtime/product persistence layer:

  • polylogue/storage/ still carries broad object-typed coercion in run-state, raw-state, artifact-view, repository-contract, and query-builder helpers
  • polylogue/products/registry.py still presents product rows and query parameters through generic object accessors and kwargs flow
  • adjacent lib models such as session profiles, work threads, and work events still serialize and hydrate through loose dict[str, object] conventions
  • the result is code that passes strict mypy but still hides meaning behind generic payload adapters and cast-heavy persistence edges

Expected scope

Likely modules include:

  • polylogue/products/registry.py
  • polylogue/storage/run_state.py
  • polylogue/storage/raw_state_models.py
  • polylogue/storage/artifact_views.py
  • polylogue/storage/repository_contracts.py
  • polylogue/storage/search_query_builders.py
  • polylogue/lib/session_profile_models.py
  • polylogue/lib/threads.py
  • polylogue/lib/work_event_extraction.py
  • adjacent helpers where the same persisted-contract shape applies

Constraints and invariants

  • keep the persisted archive/product semantics unchanged
  • establish the target contract shape in local anchor rewrites first
  • use workers only for narrow mechanical follow-through after the anchor is committed
  • prefer explicit intermediate records, typed state payloads, and narrowing helpers over generic object accessors
  • keep tests targeted to proof of the new persisted/runtime contracts rather than opportunistic suite churn

Acceptance criteria

  • runtime and product persistence paths no longer depend on broad object/dict[str, object] contracts where the shape is actually known
  • cast pressure is materially reduced across the touched storage/product/lib slice
  • product registry and persisted state models express row/query meaning directly instead of via generic adapters
  • the tranche lands as a coherent PR with devtools verify green

Verification plan

Run devtools verify before merge.

Activity

  1. added
    type:refactor
    on Apr 22, 2026
  2. added 4 commits that reference this issue on Apr 22, 2026
    1274614
    d6f5b42
    420a21b
    fbebfe1
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