Skip to content

refactor(storage): group storage by ownership domain (#425) - #536

Closed
Sinity wants to merge 1 commit into
feature/refactor/426-root-facade-package-boundaryfrom
feature/refactor/425-storage-by-domain
Closed

Sinity wants to merge 1 commit into
feature/refactor/426-root-facade-package-boundaryfrom
feature/refactor/425-storage-by-domain

Conversation

@Sinity

@Sinity Sinity commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Summary

63 moves grouping polylogue/storage/ by ownership domain
(action_events, artifacts, derived, embeddings, fts, products,
raw, repository, runtime, search) per docs/plans/topology-target.yaml.

Stacked on #535. Merge that first, then this rebases onto master.

Problem

Per #425: storage was a flat catch-all of 90+ modules with ownership
conveyed only by filename prefix. The verify-topology lint declared
the targets but the realized tree had not moved yet.

Solution

action_event_*.py        -> storage/action_events/
artifact_*.py            -> storage/artifacts/
derived_status*.py       -> storage/derived/
embedding_stats*.py      -> storage/embeddings/
fts_lifecycle*.py        -> storage/fts/
raw_ingest_*.py, raw_state_*.py -> storage/raw/
search.py, search_*.py   -> storage/search/
store.py, store_runtime_*, store_constants -> storage/runtime/
store_product_*, session_product_* -> storage/products/{aggregate,session,timeline}/
repository.py, repository_* -> storage/repository/{archive,product,action,raw,vectors}/

Notes:

  • Fixed build_topology_projection bug where exact-filename keys
    with full-path values (e.g. repository.py: storage/repository/__init__.py)
    produced concatenated nonsense like __init__.pyrepository.py.
    Refactored a shared _apply_rule helper for both lib and storage.
  • Relative imports in moved files were re-anchored to the OLD parent
    package (polylogue.storage), then mapped through the move table —
    files like search/runtime.py now use absolute imports.
  • polylogue/storage/index.py stayed at storage/ root but its from .X
    imports referenced moved siblings; rewritten to absolute.
  • Two #425 xfail-strict invariants flip to normal asserts.

Verification

devtools build-topology-projection      # 663 rows; #425 cells absorbed into 'stable'
devtools verify-topology                # realized=663 declared=663 blocking=False
devtools verify-cross-cuts              # cross-cut tags: clean
devtools verify-cluster-cohesion        # 42 cycles (= master baseline 43; no new cycles)
devtools render-all --check             # sync OK
mypy polylogue                          # Success: no issues found in 663 source files
pytest -q --ignore=tests/integration    # 5615 passed, 7 xfailed
                                        # 1 flake on test_tui::test_search_empty_db (passes on rerun)
devtools verify --quick                 # all checks passed

Closes #425

Problem: polylogue/storage/ was a flat catch-all of 90+ modules with
ownership conveyed only by filename prefix (action_event_*, repository_*,
store_*, search_*, etc). #425 declares a domain-grouped target shape;
verify-topology lint had been carrying the manifest in soft mode.

Solution: 63 moves per docs/plans/topology-target.yaml.

  action_event_*.py        -> storage/action_events/
  artifact_*.py            -> storage/artifacts/
  derived_status*.py       -> storage/derived/
  embedding_stats*.py      -> storage/embeddings/
  fts_lifecycle*.py        -> storage/fts/
  raw_ingest_*.py, raw_state_*.py -> storage/raw/
  search.py, search_*.py   -> storage/search/
  store.py, store_runtime_*, store_constants -> storage/runtime/
  store_product_*, session_product_* -> storage/products/{aggregate,session,timeline}/
  product_read_support.py  -> storage/products/
  repository.py, repository_* -> storage/repository/{archive,product,action,raw,vectors}/

Notes:
  - Fixed build_topology_projection bug where exact-filename keys with
    full-path values (e.g. `repository.py: storage/repository/__init__.py`)
    produced concatenated nonsense like `__init__.pyrepository.py`.
    Refactored shared `_apply_rule` helper for both lib and storage.
  - Relative imports in moved files were re-anchored to the OLD parent
    package (polylogue.storage), then mapped through the move table —
    files like search/runtime.py now use absolute imports for cross-
    cluster references.
  - polylogue/storage/index.py stayed at storage/ root but its `from .X`
    imports referenced moved siblings; rewritten to absolute.
  - Two #425 xfail-strict invariants flip to normal asserts:
    test_storage_has_products_session_subpackage,
    test_no_session_product_at_storage_root.

Verification:

  devtools build-topology-projection      # 663 rows; #425 cells absorbed into 'stable'
  devtools verify-topology                # realized=663 declared=663 blocking=False
  devtools verify-cross-cuts              # cross-cut tags: clean
  devtools verify-cluster-cohesion        # 42 cycles (= master baseline 43; no new cycles)
  devtools render-all --check             # sync OK
  mypy polylogue                          # Success: no issues found in 663 source files
  pytest -q --ignore=tests/integration    # 5615 passed, 7 xfailed
                                          # 1 flake on test_tui::test_search_empty_db
                                          # (passes on rerun; unrelated)

Closes #425

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d3912614-e728-4ade-856d-fdc0ba33b650

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/425-storage-by-domain

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

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

@Sinity
Sinity deleted the branch feature/refactor/426-root-facade-package-boundary April 27, 2026 16:49
@Sinity Sinity closed this Apr 27, 2026
Sinity added a commit that referenced this pull request Apr 27, 2026
## Summary
- Regroup `polylogue/storage/` modules by ownership domain
(archive/products/sessions/repository) per topology projection (#425).

## Problem
`polylogue/storage/` had grown to ~80 flat-laid modules —
repository/products/backends/sessions intermingled. Topology projection
(`docs/plans/topology-target.yaml`) declares ownership-domain clusters;
the realized tree didn't match.

## Solution
63 file moves grouping by domain. Imports rewritten via topology-driven
AST renamer. Verified via `verify-topology`, `verify-cluster-cohesion`,
`verify-test-ownership`.

## Verification
- `devtools verify --quick` — green (format, lint, mypy, render-all, all
5 topology lints).
- Local `pytest -q --ignore=tests/integration` — all green prior to
push.

Stacked on #535 (merged). Replaces closed #536 after `--delete-branch`
cascade closed it.

Closes #425

Co-authored-by: Claude <[email protected]>
Sinity added a commit that referenced this pull request Apr 27, 2026
## Summary

64 moves grouping `polylogue/lib/` into domain subpackages
(query, session, viewport, conversation, message, raw_payload,
artifact_taxonomy, action_event, semantic, filter, projection,
phase, provider, attachment) per `docs/plans/topology-target.yaml`,
plus two package-init merges.

**Stacked on #536 (which is stacked on #535).** Merge that train
bottom-up; rebase between if needed.

## Problem

Per #424: `polylogue/lib/` was a flat catch-all of 80+ modules with
domain logic, infrastructure primitives, model carriers, and runtime
adapters all coexisting at one level. The substrate ring rule didn't
survive the package; manifest declared targets but moves had not landed.

## Solution

```
query_*.py            -> lib/query/
session_profile_*.py  -> lib/session/
viewport_*.py         -> lib/viewport/
conversation_*.py     -> lib/conversation/
message_*.py          -> lib/message/
raw_payload_*.py      -> lib/raw_payload/{decode,streams,sampling_*}.py
artifact_taxonomy_*.py -> lib/artifact_taxonomy/{models,runtime,support}.py
action_event_*.py     -> lib/action_event/
semantic_fact_*.py    -> lib/semantic/{models,support}.py
semantic_facts.py     -> lib/semantic/facts.py
filter_*.py, filters  -> lib/filter/
projection_*.py       -> lib/projection/
phase_extraction.py   -> lib/phase/extraction.py
provider_*.py         -> lib/provider/
attachment_models.py  -> lib/attachment/models.py
```

Notes:

- `lib/raw_payload.py` and `lib/artifact_taxonomy.py` were merged into
  their packages' `__init__.py` so the public API surface stays at
  `polylogue.lib.<pkg>.X` rather than the awkward
  `polylogue.lib.<pkg>.<pkg>.X`.
- Fixed two `build_topology_projection` bugs:
  1. The exact-filename rule now triggers on `prefix == name` OR
     `prefix == name.removesuffix(".py")`, so rules like
     `"semantic_facts": "lib/semantic/facts.py"` work.
  2. Added explicit `semantic_facts -> lib/semantic/facts.py` rule;
     the broad `semantic_fact` prefix had been incorrectly catching
     `semantic_facts.py` and chopping it to `s.py`.
- Two `#424` xfail-strict invariants flip to normal asserts.

## Verification

```
devtools build-topology-projection      # 675 rows; #424 cells absorbed into 'stable'
devtools verify-topology                # realized=675 declared=675 blocking=False
devtools verify-cross-cuts              # cross-cut tags: clean
devtools verify-cluster-cohesion        # 42 cycles (= master baseline 43; no new cycles)
devtools render-all --check             # sync OK
mypy polylogue                          # Success: no issues found in 675 source files
pytest -q --ignore=tests/integration    # 5618 passed, 5 xfailed
devtools verify --quick                 # all checks passed
```

Closes #424

Co-authored-by: Claude <[email protected]>
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Provided git ref refs/pull/536/head does not exist
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Sinity
Sinity requested review from Copilot and removed request for Copilot May 1, 2026 01:55
Sinity added a commit that referenced this pull request May 7, 2026
## Summary
- Regroup `polylogue/storage/` modules by ownership domain
(archive/products/sessions/repository) per topology projection (#425).

## Problem
`polylogue/storage/` had grown to ~80 flat-laid modules —
repository/products/backends/sessions intermingled. Topology projection
(`docs/plans/topology-target.yaml`) declares ownership-domain clusters;
the realized tree didn't match.

## Solution
63 file moves grouping by domain. Imports rewritten via topology-driven
AST renamer. Verified via `verify-topology`, `verify-cluster-cohesion`,
`verify-test-ownership`.

## Verification
- `devtools verify --quick` — green (format, lint, mypy, render-all, all
5 topology lints).
- Local `pytest -q --ignore=tests/integration` — all green prior to
push.

Stacked on #535 (merged). Replaces closed #536 after `--delete-branch`
cascade closed it.

Closes #425

Co-authored-by: Claude <[email protected]>
Sinity added a commit that referenced this pull request May 7, 2026
## Summary

64 moves grouping `polylogue/lib/` into domain subpackages
(query, session, viewport, conversation, message, raw_payload,
artifact_taxonomy, action_event, semantic, filter, projection,
phase, provider, attachment) per `docs/plans/topology-target.yaml`,
plus two package-init merges.

**Stacked on #536 (which is stacked on #535).** Merge that train
bottom-up; rebase between if needed.

## Problem

Per #424: `polylogue/lib/` was a flat catch-all of 80+ modules with
domain logic, infrastructure primitives, model carriers, and runtime
adapters all coexisting at one level. The substrate ring rule didn't
survive the package; manifest declared targets but moves had not landed.

## Solution

```
query_*.py            -> lib/query/
session_profile_*.py  -> lib/session/
viewport_*.py         -> lib/viewport/
conversation_*.py     -> lib/conversation/
message_*.py          -> lib/message/
raw_payload_*.py      -> lib/raw_payload/{decode,streams,sampling_*}.py
artifact_taxonomy_*.py -> lib/artifact_taxonomy/{models,runtime,support}.py
action_event_*.py     -> lib/action_event/
semantic_fact_*.py    -> lib/semantic/{models,support}.py
semantic_facts.py     -> lib/semantic/facts.py
filter_*.py, filters  -> lib/filter/
projection_*.py       -> lib/projection/
phase_extraction.py   -> lib/phase/extraction.py
provider_*.py         -> lib/provider/
attachment_models.py  -> lib/attachment/models.py
```

Notes:

- `lib/raw_payload.py` and `lib/artifact_taxonomy.py` were merged into
  their packages' `__init__.py` so the public API surface stays at
  `polylogue.lib.<pkg>.X` rather than the awkward
  `polylogue.lib.<pkg>.<pkg>.X`.
- Fixed two `build_topology_projection` bugs:
  1. The exact-filename rule now triggers on `prefix == name` OR
     `prefix == name.removesuffix(".py")`, so rules like
     `"semantic_facts": "lib/semantic/facts.py"` work.
  2. Added explicit `semantic_facts -> lib/semantic/facts.py` rule;
     the broad `semantic_fact` prefix had been incorrectly catching
     `semantic_facts.py` and chopping it to `s.py`.
- Two `#424` xfail-strict invariants flip to normal asserts.

## Verification

```
devtools build-topology-projection      # 675 rows; #424 cells absorbed into 'stable'
devtools verify-topology                # realized=675 declared=675 blocking=False
devtools verify-cross-cuts              # cross-cut tags: clean
devtools verify-cluster-cohesion        # 42 cycles (= master baseline 43; no new cycles)
devtools render-all --check             # sync OK
mypy polylogue                          # Success: no issues found in 675 source files
pytest -q --ignore=tests/integration    # 5618 passed, 5 xfailed
devtools verify --quick                 # all checks passed
```

Closes #424

Co-authored-by: Claude <[email protected]>
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.

1 participant