Skip to content

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

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/425-storage-by-domain
Apr 27, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/425-storage-by-domain

Conversation

@Sinity

@Sinity Sinity commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Summary

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

@coderabbitai

coderabbitai Bot commented Apr 27, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 242 files, which is 92 over the limit of 150.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4b7eb53d-1c2d-4bda-9542-edd7ce543516

📥 Commits

Reviewing files that changed from the base of the PR and between a983de0 and 1f5dd72.

📒 Files selected for processing (242)
  • .gitignore
  • devtools/build_topology_projection.py
  • devtools/large_archive_generator.py
  • devtools/mutation_scenario_catalog.py
  • devtools/pipeline_probe.py
  • devtools/synthetic_benchmark_runtime.py
  • docs/plans/topology-target.yaml
  • docs/test-quality-workflows.md
  • docs/topology-status.md
  • polylogue/api/archive.py
  • polylogue/api/sync/products.py
  • polylogue/archive_product_rollups.py
  • polylogue/archive_product_summaries.py
  • polylogue/archive_products.py
  • polylogue/archive_resume.py
  • polylogue/artifacts/__init__.py
  • polylogue/cli/check_models.py
  • polylogue/cli/helper_summary.py
  • polylogue/cli/query_output.py
  • polylogue/cli/query_progress.py
  • polylogue/cli/query_semantic.py
  • polylogue/lib/embeddings/runtime.py
  • polylogue/lib/embeddings/stats.py
  • polylogue/lib/query_retrieval_candidates.py
  • polylogue/operations/archive.py
  • polylogue/operations/specs.py
  • polylogue/pipeline/materialization_runtime.py
  • polylogue/pipeline/payload_types.py
  • polylogue/pipeline/prepare.py
  • polylogue/pipeline/prepare_enrichment.py
  • polylogue/pipeline/prepare_models.py
  • polylogue/pipeline/prepare_transform.py
  • polylogue/pipeline/run_execution.py
  • polylogue/pipeline/run_finalization.py
  • polylogue/pipeline/run_stages.py
  • polylogue/pipeline/services/acquisition.py
  • polylogue/pipeline/services/acquisition_persistence.py
  • polylogue/pipeline/services/acquisition_records.py
  • polylogue/pipeline/services/acquisition_streams.py
  • polylogue/pipeline/services/indexing.py
  • polylogue/pipeline/services/ingest_batch.py
  • polylogue/pipeline/services/ingest_worker.py
  • polylogue/pipeline/services/planning_backlog.py
  • polylogue/pipeline/services/planning_runtime.py
  • polylogue/pipeline/services/validation.py
  • polylogue/pipeline/services/validation_flow.py
  • polylogue/pipeline/services/validation_runtime.py
  • polylogue/product_readiness.py
  • polylogue/protocols.py
  • polylogue/readiness/__init__.py
  • polylogue/rendering/block_models.py
  • polylogue/schemas/operator_models.py
  • polylogue/schemas/verification_artifacts.py
  • polylogue/site/publication_flow.py
  • polylogue/storage/__init__.py
  • polylogue/storage/action_events/__init__.py
  • polylogue/storage/action_events/artifacts.py
  • polylogue/storage/action_events/rebuild_loading.py
  • polylogue/storage/action_events/rebuild_materialization.py
  • polylogue/storage/action_events/rebuild_runtime.py
  • polylogue/storage/action_events/rebuild_sql.py
  • polylogue/storage/action_events/rebuild_storage.py
  • polylogue/storage/action_events/rows.py
  • polylogue/storage/action_events/status.py
  • polylogue/storage/archive_views.py
  • polylogue/storage/artifacts/__init__.py
  • polylogue/storage/artifacts/inspection.py
  • polylogue/storage/artifacts/persistence.py
  • polylogue/storage/artifacts/queries.py
  • polylogue/storage/artifacts/views.py
  • polylogue/storage/backends/async_sqlite.py
  • polylogue/storage/backends/async_sqlite_archive.py
  • polylogue/storage/backends/async_sqlite_raw.py
  • polylogue/storage/backends/queries/action_events.py
  • polylogue/storage/backends/queries/artifacts.py
  • polylogue/storage/backends/queries/attachment_content_blocks.py
  • polylogue/storage/backends/queries/attachment_mutations.py
  • polylogue/storage/backends/queries/attachment_records.py
  • polylogue/storage/backends/queries/conversations_reads.py
  • polylogue/storage/backends/queries/conversations_search.py
  • polylogue/storage/backends/queries/conversations_writes.py
  • polylogue/storage/backends/queries/mappers_archive.py
  • polylogue/storage/backends/queries/mappers_product_aggregates.py
  • polylogue/storage/backends/queries/mappers_product_profiles.py
  • polylogue/storage/backends/queries/mappers_product_timelines.py
  • polylogue/storage/backends/queries/message_query_reads.py
  • polylogue/storage/backends/queries/message_query_writes.py
  • polylogue/storage/backends/queries/publications.py
  • polylogue/storage/backends/queries/raw_reads.py
  • polylogue/storage/backends/queries/raw_state.py
  • polylogue/storage/backends/queries/raw_writes.py
  • polylogue/storage/backends/queries/runs.py
  • polylogue/storage/backends/queries/session_product_profile_reads.py
  • polylogue/storage/backends/queries/session_product_profile_writes.py
  • polylogue/storage/backends/queries/session_product_summary_queries.py
  • polylogue/storage/backends/queries/session_product_thread_queries.py
  • polylogue/storage/backends/queries/session_product_timeline_reads.py
  • polylogue/storage/backends/queries/session_product_timeline_writes.py
  • polylogue/storage/backends/queries/stats.py
  • polylogue/storage/backends/query_store.py
  • polylogue/storage/backends/query_store_archive.py
  • polylogue/storage/backends/query_store_maintenance.py
  • polylogue/storage/backends/query_store_product_profiles.py
  • polylogue/storage/backends/query_store_product_timelines.py
  • polylogue/storage/derived/__init__.py
  • polylogue/storage/derived/derived_status.py
  • polylogue/storage/derived/products.py
  • polylogue/storage/embeddings/__init__.py
  • polylogue/storage/embeddings/embedding_stats.py
  • polylogue/storage/embeddings/models.py
  • polylogue/storage/embeddings/sql.py
  • polylogue/storage/embeddings/support.py
  • polylogue/storage/fts/__init__.py
  • polylogue/storage/fts/fts_lifecycle.py
  • polylogue/storage/fts/sql.py
  • polylogue/storage/hydrators.py
  • polylogue/storage/index.py
  • polylogue/storage/products/__init__.py
  • polylogue/storage/products/aggregate/__init__.py
  • polylogue/storage/products/aggregate/records.py
  • polylogue/storage/products/product_read_support.py
  • polylogue/storage/products/session/__init__.py
  • polylogue/storage/products/session/aggregates.py
  • polylogue/storage/products/session/profiles.py
  • polylogue/storage/products/session/rebuild.py
  • polylogue/storage/products/session/records.py
  • polylogue/storage/products/session/refresh.py
  • polylogue/storage/products/session/runtime.py
  • polylogue/storage/products/session/status.py
  • polylogue/storage/products/session/storage.py
  • polylogue/storage/products/session/threads.py
  • polylogue/storage/products/session/timeline_rows.py
  • polylogue/storage/products/timeline/__init__.py
  • polylogue/storage/products/timeline/records.py
  • polylogue/storage/raw/__init__.py
  • polylogue/storage/raw/artifacts.py
  • polylogue/storage/raw/models.py
  • polylogue/storage/repair.py
  • polylogue/storage/repository/__init__.py
  • polylogue/storage/repository/action/__init__.py
  • polylogue/storage/repository/action/reads.py
  • polylogue/storage/repository/archive/__init__.py
  • polylogue/storage/repository/archive/conversations.py
  • polylogue/storage/repository/archive/queries.py
  • polylogue/storage/repository/archive/reads.py
  • polylogue/storage/repository/archive/repository_writes.py
  • polylogue/storage/repository/archive/search.py
  • polylogue/storage/repository/archive/tree.py
  • polylogue/storage/repository/archive/writes/__init__.py
  • polylogue/storage/repository/archive/writes/conversations.py
  • polylogue/storage/repository/archive/writes/metadata.py
  • polylogue/storage/repository/product/__init__.py
  • polylogue/storage/repository/product/profile_reads.py
  • polylogue/storage/repository/product/summary_reads.py
  • polylogue/storage/repository/product/thread_reads.py
  • polylogue/storage/repository/product/timeline_reads.py
  • polylogue/storage/repository/raw/__init__.py
  • polylogue/storage/repository/raw/repository_raw.py
  • polylogue/storage/repository/repository_contracts.py
  • polylogue/storage/repository/vectors/__init__.py
  • polylogue/storage/repository/vectors/repository_vectors.py
  • polylogue/storage/runtime/__init__.py
  • polylogue/storage/runtime/action/__init__.py
  • polylogue/storage/runtime/action/records.py
  • polylogue/storage/runtime/archive/__init__.py
  • polylogue/storage/runtime/archive/records.py
  • polylogue/storage/runtime/raw/__init__.py
  • polylogue/storage/runtime/raw/records.py
  • polylogue/storage/runtime/store_constants.py
  • polylogue/storage/search/__init__.py
  • polylogue/storage/search/cache.py
  • polylogue/storage/search/models.py
  • polylogue/storage/search/query_builders.py
  • polylogue/storage/search/query_support.py
  • polylogue/storage/search/runtime.py
  • polylogue/storage/search_providers/fts5.py
  • polylogue/storage/search_providers/hybrid.py
  • polylogue/storage/search_providers/hybrid_conversations.py
  • polylogue/storage/search_providers/sqlite_vec_embeddings.py
  • polylogue/storage/search_providers/sqlite_vec_queries.py
  • tests/benchmarks/conftest.py
  • tests/benchmarks/test_pipeline.py
  • tests/conftest.py
  • tests/infra/archive_scenarios.py
  • tests/infra/corpus_fixtures.py
  • tests/infra/semantic_facts.py
  • tests/infra/storage_records.py
  • tests/unit/architecture/test_topology_invariants.py
  • tests/unit/cli/test_check.py
  • tests/unit/cli/test_embed.py
  • tests/unit/cli/test_products.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/cli/test_resume.py
  • tests/unit/cli/test_site.py
  • tests/unit/core/test_facade_api.py
  • tests/unit/core/test_health_core.py
  • tests/unit/core/test_models.py
  • tests/unit/core/test_product_export_bundles.py
  • tests/unit/core/test_product_readiness.py
  • tests/unit/core/test_repo_identity.py
  • tests/unit/core/test_resume.py
  • tests/unit/core/test_verification.py
  • tests/unit/devtools/test_benchmark_campaigns.py
  • tests/unit/devtools/test_pipeline_probe.py
  • tests/unit/lib/test_query_miss_diagnostics.py
  • tests/unit/mcp/test_tool_contracts.py
  • tests/unit/pipeline/test_ingest_batch.py
  • tests/unit/pipeline/test_ingestion_chaos.py
  • tests/unit/pipeline/test_parsing_service.py
  • tests/unit/pipeline/test_prepare.py
  • tests/unit/pipeline/test_quarantine_fixtures.py
  • tests/unit/pipeline/test_resilience.py
  • tests/unit/pipeline/test_run_sources.py
  • tests/unit/pipeline/test_run_stages_runtime.py
  • tests/unit/proof/test_structural_error_evidence.py
  • tests/unit/site/test_builder.py
  • tests/unit/sources/test_compaction.py
  • tests/unit/storage/test_action_event_artifacts.py
  • tests/unit/storage/test_archive_search_contracts.py
  • tests/unit/storage/test_backend.py
  • tests/unit/storage/test_derived_status.py
  • tests/unit/storage/test_embedding_stats.py
  • tests/unit/storage/test_fts5.py
  • tests/unit/storage/test_parse_tracking.py
  • tests/unit/storage/test_product_materialization_laws.py
  • tests/unit/storage/test_publications.py
  • tests/unit/storage/test_query_mappers.py
  • tests/unit/storage/test_raw.py
  • tests/unit/storage/test_raw_ingest_artifacts.py
  • tests/unit/storage/test_repository_lifecycle_laws.py
  • tests/unit/storage/test_repository_product_runtime.py
  • tests/unit/storage/test_scale.py
  • tests/unit/storage/test_session_product_profiles.py
  • tests/unit/storage/test_session_product_refresh.py
  • tests/unit/storage/test_session_product_status_descriptors.py
  • tests/unit/storage/test_session_product_timeline_rows.py
  • tests/unit/storage/test_store_ops.py
  • tests/unit/storage/test_vec.py
  • tests/unit/test_protocol_conformance.py

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.

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]>
@Sinity
Sinity force-pushed the feature/refactor/425-storage-by-domain branch from 2ff0710 to 1f5dd72 Compare April 27, 2026 17:22
@Sinity
Sinity merged commit cb04f48 into master Apr 27, 2026
13 checks passed
@Sinity
Sinity deleted the feature/refactor/425-storage-by-domain branch April 27, 2026 17:53
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

ℹ️ 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 a review from Copilot May 1, 2026 01:55
@Sinity
Sinity removed the request for review from Copilot May 1, 2026 02:20
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]>
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.

refactor(storage): group storage by ownership domain

1 participant