Skip to content

refactor(archive): move conversation models out of lib - #655

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/archive-conversation-clean
May 1, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/archive-conversation-clean

Conversation

@Sinity

@Sinity Sinity commented May 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Move the conversation domain package from polylogue.lib into polylogue.archive, keeping conversation models, branch types, attribution, work-event extraction, neighbor discovery, and thread building with archive-domain code.

Problem

polylogue/lib/conversation owned archive conversation meaning while living under the generic lib namespace. After query, filter, message, semantic, projection, and related packages moved into archive, conversation remained the largest archive-domain package in the old bucket.

Solution

  • Rename polylogue/lib/conversation to polylogue/archive/conversation.
  • Update public facades, API/MCP/CLI surfaces, storage hydration/repositories, pipeline materialization, products, parsers, and tests to import the archive package.
  • Refresh topology ownership from lib-conversation to archive-conversation.
  • Update the library API docs import example for session thread building.

Verification

  • ruff check --fix polylogue/ tests/ devtools/ followed by ruff check polylogue/ tests/ devtools/
  • pytest -q tests/unit/core/test_conversation_semantics.py tests/unit/core/test_threads_runtime.py tests/unit/core/test_session_summaries.py tests/unit/core/test_neighbor_candidates.py tests/unit/core/test_repo_identity.py — 59 passed
  • pytest -q tests/unit/archive/test_query_runtime_filters.py tests/unit/archive/test_query_runtime_matching.py tests/unit/archive/test_query_search_runtime.py tests/unit/storage/test_store_ops.py tests/unit/storage/test_archive_search_contracts.py tests/unit/storage/test_search_misc.py — 107 passed
  • pytest -q tests/unit/cli/test_neighbors_command.py tests/unit/cli/test_command_aux_runtime.py tests/unit/mcp/test_tool_contracts.py tests/unit/pipeline/test_branching.py tests/unit/sources/test_parsers_codex.py — 116 passed
  • devtools build-topology-projection && devtools verify-topology
  • devtools render-all --check
  • pre-push devtools verify --quick — all checks passed

Ref #635

Summary by CodeRabbit

  • Chores

    • Reorganized internal conversation-related modules as part of codebase restructuring.
    • Updated topology configuration and module organization.
  • Documentation

    • Updated API documentation to reflect restructured module paths.

Copilot AI review requested due to automatic review settings May 1, 2026 18:23
@coderabbitai

coderabbitai Bot commented May 1, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8b5c5910-4051-4f81-9fe3-0af760b01fa9

📥 Commits

Reviewing files that changed from the base of the PR and between 0cbe022 and dbce10d.

📒 Files selected for processing (75)
  • devtools/build_topology_projection.py
  • docs/library-api.md
  • docs/plans/topology-target.yaml
  • docs/topology-status.md
  • polylogue/__init__.py
  • polylogue/api/archive.py
  • polylogue/api/sync/conversations.py
  • polylogue/archive/conversation/__init__.py
  • polylogue/archive/conversation/attribution.py
  • polylogue/archive/conversation/branch_type.py
  • polylogue/archive/conversation/extraction.py
  • polylogue/archive/conversation/models.py
  • polylogue/archive/conversation/neighbor_candidates.py
  • polylogue/archive/conversation/runtime.py
  • polylogue/archive/conversation/summary_runtime.py
  • polylogue/archive/conversation/threads.py
  • polylogue/archive/filter/filters.py
  • polylogue/archive/projection/projections.py
  • polylogue/archive/projection/terminal_mixin.py
  • polylogue/archive/semantic/content_projection.py
  • polylogue/cli/commands/neighbors.py
  • polylogue/lib/__init__.py
  • polylogue/lib/models.py
  • polylogue/lib/session/models.py
  • polylogue/lib/session/runtime.py
  • polylogue/mcp/payloads.py
  • polylogue/mcp/server_prompts.py
  • polylogue/operations/archive.py
  • polylogue/pipeline/materialization_runtime.py
  • polylogue/pipeline/services/ingest_worker.py
  • polylogue/products/resume.py
  • polylogue/protocols.py
  • polylogue/site/models.py
  • polylogue/sources/parsers/base_models.py
  • polylogue/sources/parsers/claude/code_parser.py
  • polylogue/sources/parsers/codex.py
  • polylogue/storage/backends/queries/mappers_archive.py
  • polylogue/storage/hydrators.py
  • polylogue/storage/products/session/profiles.py
  • polylogue/storage/products/session/rebuild.py
  • polylogue/storage/products/session/threads.py
  • polylogue/storage/products/session/timeline_rows.py
  • polylogue/storage/repository/archive/conversations.py
  • polylogue/storage/repository/archive/queries.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/conversations.py
  • polylogue/storage/repository/product/thread_reads.py
  • polylogue/storage/repository/product/timeline_reads.py
  • polylogue/storage/repository/vectors/repository_vectors.py
  • polylogue/storage/runtime/archive/records.py
  • polylogue/surfaces/payloads.py
  • polylogue/ui/tui/screens/base.py
  • tests/infra/pipeline_roundtrip.py
  • tests/infra/storage_records.py
  • tests/unit/archive/test_query_runtime_filters.py
  • tests/unit/archive/test_query_runtime_matching.py
  • tests/unit/archive/test_query_search_runtime.py
  • tests/unit/cli/test_command_aux_runtime.py
  • tests/unit/cli/test_neighbors_command.py
  • tests/unit/core/test_filters_props.py
  • tests/unit/core/test_neighbor_candidates.py
  • tests/unit/core/test_repo_identity.py
  • tests/unit/core/test_session_summaries.py
  • tests/unit/core/test_threads_runtime.py
  • tests/unit/lib/test_coverage_diagnostics.py
  • tests/unit/lib/test_search_hits.py
  • tests/unit/mcp/test_tool_contracts.py
  • tests/unit/pipeline/test_branching.py
  • tests/unit/sources/test_parsers_codex.py
  • tests/unit/storage/test_archive_search_contracts.py
  • tests/unit/storage/test_hybrid.py
  • tests/unit/storage/test_search_misc.py
  • tests/unit/storage/test_store_ops.py

📝 Walkthrough

Walkthrough

This PR systematically migrates conversation-related modules from polylogue/lib/conversation/ to polylogue/archive/conversation/ by updating topology ownership mappings and redirecting imports across the entire codebase to reference the new package location.

Changes

Cohort / File(s) Summary
Build Topology & Documentation
devtools/build_topology_projection.py, docs/library-api.md, docs/plans/topology-target.yaml, docs/topology-status.md
Updates topology projection rules to redirect conversation module prefixes (conversation_, branch_type, threads, etc.) from lib-conversation to archive-conversation ownership; updates documentation examples and topology plan accordingly.
Root & Core Package Exports
polylogue/__init__.py, polylogue/lib/__init__.py, polylogue/lib/models.py
Redirects lazy imports and TYPE_CHECKING paths for Conversation, BranchType, and ConversationSummary from polylogue.lib.conversation.* to polylogue.archive.conversation.*.
API & Protocol Modules
polylogue/api/archive.py, polylogue/api/sync/conversations.py, polylogue/protocols.py
Updates TYPE_CHECKING imports for conversation model types to reference the archive package instead of lib.
Archive Conversation Core
polylogue/archive/conversation/models.py, polylogue/archive/conversation/neighbor_candidates.py, polylogue/archive/conversation/runtime.py, polylogue/archive/conversation/summary_runtime.py
Repoints internal imports (BranchType, Conversation, runtime mixins) to use the archive conversation package namespace.
Archive Filter & Projection
polylogue/archive/filter/filters.py, polylogue/archive/projection/projections.py, polylogue/archive/projection/terminal_mixin.py, polylogue/archive/semantic/content_projection.py
Updates TYPE_CHECKING imports for Conversation and related types to reference polylogue.archive.conversation.models.
CLI, Operations & MCP
polylogue/cli/commands/neighbors.py, polylogue/operations/archive.py, polylogue/mcp/payloads.py, polylogue/mcp/server_prompts.py
Switches dependencies for neighbor candidates and conversation types from lib to archive conversation modules; includes runtime import redirect in operations module.
Pipeline & Services
polylogue/pipeline/materialization_runtime.py, polylogue/pipeline/services/ingest_worker.py
Updates BranchType imports to reference polylogue.archive.conversation.branch_type.
Session & Products
polylogue/lib/session/models.py, polylogue/lib/session/runtime.py, polylogue/products/resume.py, polylogue/site/models.py
Redirects imports for session-related types (ConversationAttribution, WorkEvent) and conversation models to archive package locations.
Parsers & Sources
polylogue/sources/parsers/base_models.py, polylogue/sources/parsers/claude/code_parser.py, polylogue/sources/parsers/codex.py
Updates BranchType import source for parsed conversation models to use archive package.
Storage Repository & Hydration
polylogue/storage/backends/queries/mappers_archive.py, polylogue/storage/hydrators.py, polylogue/storage/repository/archive/*, polylogue/storage/repository/product/thread_reads.py, polylogue/storage/repository/product/timeline_reads.py, polylogue/storage/repository/vectors/repository_vectors.py
Repoints all conversation model and work-event type imports from lib to archive conversation modules; updates mappers and hydrator logic source references.
Storage Products & Runtime
polylogue/storage/products/session/profiles.py, polylogue/storage/products/session/rebuild.py, polylogue/storage/products/session/threads.py, polylogue/storage/products/session/timeline_rows.py, polylogue/storage/runtime/archive/records.py
Updates imports for BranchType, WorkEvent, WorkThread and related session types to use archive conversation package paths.
Surfaces & UI
polylogue/surfaces/payloads.py, polylogue/ui/tui/screens/base.py
Updates TYPE_CHECKING imports for neighbor candidate and conversation types to reference archive package.
Test Infrastructure & Unit Tests
tests/infra/pipeline_roundtrip.py, tests/infra/storage_records.py, tests/unit/archive/*, tests/unit/cli/*, tests/unit/core/*, tests/unit/lib/*, tests/unit/mcp/*, tests/unit/pipeline/*, tests/unit/sources/*, tests/unit/storage/*
Systematically updates all test imports for conversation models, branch types, work events, and neighbor candidates to reference the archive package locations.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

Suggested labels

type:refactor, area:storage, area:pipeline, area:api, type:test

Poem

🐰 A hoppy hop through lib's grand hall,
Now archive holds the conversation's call,
With imports bright and patterns true,
We reorganize what's old into the new!
Topology maps and tests align—
The refactor flows like twitching whisker-line! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/archive-conversation-clean

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@Sinity
Sinity merged commit 2822a63 into master May 1, 2026
10 of 14 checks passed
@Sinity
Sinity deleted the feature/refactor/archive-conversation-clean branch May 1, 2026 18:23
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Polylogue Proof Pack

Refs: origin/master..HEAD
Changed paths: 0

Affected Domains

  • none

Required Gates

  • devtools verify --quick — full PR gate remains explicit
  • devtools verify — full PR gate remains explicit
  • devtools build-package — deployment readiness gate; run when packaging or release confidence matters
  • nix flake check — deployment readiness gate; run when packaging or release confidence matters

Known Gaps

  • none for affected domains

Oracle / Cost

  • oracle mix: {}
  • cost tier: {}
  • stale evidence: 0
  • manual review cells: 0

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbce10d1a1

ℹ️ 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".

Comment thread polylogue/lib/__init__.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Moves the conversation domain package from polylogue.lib into polylogue.archive, updating internal and surface-layer imports while keeping the public polylogue.lib facades aligned with the new archive-domain ownership.

Changes:

  • Relocates conversation domain modules to polylogue/archive/conversation/ (branch types, attribution, work-event extraction, neighbor discovery, thread building).
  • Updates imports across storage/repository, pipeline/materialization, API/MCP/CLI, UI, and tests to reference polylogue.archive.conversation.*.
  • Refreshes topology ownership/mappings and updates library API docs to point at the new module paths.

Reviewed changes

Copilot reviewed 70 out of 75 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit/storage/test_store_ops.py Update Conversation import to archive conversation models.
tests/unit/storage/test_search_misc.py Update BranchType import to archive conversation package.
tests/unit/storage/test_hybrid.py Update BranchType import to archive conversation package.
tests/unit/storage/test_archive_search_contracts.py Update Conversation import to archive conversation models.
tests/unit/sources/test_parsers_codex.py Update BranchType import to archive conversation package.
tests/unit/pipeline/test_branching.py Update BranchType import to archive conversation package.
tests/unit/mcp/test_tool_contracts.py Update neighbor-candidate imports to archive conversation package.
tests/unit/lib/test_search_hits.py Update Conversation/ConversationSummary imports to archive conversation models.
tests/unit/lib/test_coverage_diagnostics.py Update ConversationSummary import to archive conversation models.
tests/unit/core/test_threads_runtime.py Update threads import to archive conversation package.
tests/unit/core/test_session_summaries.py Update work-event extraction imports to archive conversation package.
tests/unit/core/test_repo_identity.py Update attribution imports to archive conversation package.
tests/unit/core/test_neighbor_candidates.py Update neighbor discovery imports to archive conversation package.
tests/unit/core/test_filters_props.py Update Conversation import to archive conversation models.
tests/unit/cli/test_neighbors_command.py Update neighbor-candidate imports to archive conversation package.
tests/unit/cli/test_command_aux_runtime.py Update neighbor-candidate imports to archive conversation package.
tests/unit/archive/test_query_search_runtime.py Update ConversationSummary import to archive conversation models.
tests/unit/archive/test_query_runtime_matching.py Update Conversation import to archive conversation models.
tests/unit/archive/test_query_runtime_filters.py Update BranchType/ConversationSummary imports to archive conversation package.
tests/infra/storage_records.py Update BranchType + TYPE_CHECKING Conversation imports to archive conversation package.
tests/infra/pipeline_roundtrip.py Update Conversation import to archive conversation models.
polylogue/ui/tui/screens/base.py Update TYPE_CHECKING Conversation import to archive conversation models.
polylogue/surfaces/payloads.py Update TYPE_CHECKING neighbor-candidate imports to archive conversation package.
polylogue/storage/runtime/archive/records.py Update BranchType import to archive conversation package.
polylogue/storage/repository/vectors/repository_vectors.py Update TYPE_CHECKING Conversation import to archive conversation models.
polylogue/storage/repository/product/timeline_reads.py Update WorkEvent import to archive conversation extraction.
polylogue/storage/repository/product/thread_reads.py Update WorkThread import to archive conversation threads.
polylogue/storage/repository/archive/writes/conversations.py Update Conversation import to archive conversation models.
polylogue/storage/repository/archive/tree.py Update Conversation import to archive conversation models.
polylogue/storage/repository/archive/search.py Update TYPE_CHECKING conversation model imports to archive conversation models.
polylogue/storage/repository/archive/repository_writes.py Update Conversation import to archive conversation models.
polylogue/storage/repository/archive/queries.py Update conversation model imports to archive conversation models.
polylogue/storage/repository/archive/conversations.py Update conversation model imports to archive conversation models.
polylogue/storage/products/session/timeline_rows.py Update WorkEvent import to archive conversation extraction.
polylogue/storage/products/session/threads.py Update thread building imports to archive conversation threads.
polylogue/storage/products/session/rebuild.py Update BranchType/Conversation imports to archive conversation package.
polylogue/storage/products/session/profiles.py Update WorkEvent/WorkEventPayload imports to archive conversation extraction.
polylogue/storage/hydrators.py Update conversation model imports to archive conversation models.
polylogue/storage/backends/queries/mappers_archive.py Update BranchType import to archive conversation package.
polylogue/sources/parsers/codex.py Update BranchType import to archive conversation package.
polylogue/sources/parsers/claude/code_parser.py Update BranchType import to archive conversation package.
polylogue/sources/parsers/base_models.py Update BranchType import to archive conversation package.
polylogue/site/models.py Update TYPE_CHECKING ConversationSummary import to archive conversation models.
polylogue/protocols.py Update TYPE_CHECKING conversation model imports to archive conversation models.
polylogue/products/resume.py Update Conversation import to archive conversation models.
polylogue/pipeline/services/ingest_worker.py Update BranchType import to archive conversation package.
polylogue/pipeline/materialization_runtime.py Update BranchType import to archive conversation package.
polylogue/operations/archive.py Update conversation/neighbor-candidate imports to archive conversation package.
polylogue/mcp/server_prompts.py Update TYPE_CHECKING Conversation import to archive conversation models.
polylogue/mcp/payloads.py Update TYPE_CHECKING neighbor-candidate import to archive conversation package.
polylogue/lib/session/runtime.py Update attribution/work-event extraction imports to archive conversation package.
polylogue/lib/session/models.py Update attribution/work-event type imports to archive conversation package.
polylogue/lib/models.py Re-export conversation models from polylogue.archive.conversation.models.
polylogue/lib/init.py Update lazy exports for BranchType/Conversation to archive conversation package.
polylogue/cli/commands/neighbors.py Update neighbor-candidate imports to archive conversation package.
polylogue/archive/semantic/content_projection.py Update TYPE_CHECKING Conversation import to archive conversation models.
polylogue/archive/projection/terminal_mixin.py Update TYPE_CHECKING Conversation import to archive conversation models.
polylogue/archive/projection/projections.py Update TYPE_CHECKING Conversation import to archive conversation models.
polylogue/archive/filter/filters.py Update TYPE_CHECKING conversation model imports to archive conversation models.
polylogue/archive/conversation/threads.py New archive-owned thread builder + thread payload models.
polylogue/archive/conversation/summary_runtime.py Update BranchType import to archive conversation package.
polylogue/archive/conversation/runtime.py Update BranchType and internal Conversation import to archive conversation package.
polylogue/archive/conversation/neighbor_candidates.py Update TYPE_CHECKING conversation model imports to archive conversation models.
polylogue/archive/conversation/models.py Update imports to reference archive conversation runtime/branch types.
polylogue/archive/conversation/extraction.py New archive-owned work-event extraction implementation.
polylogue/archive/conversation/branch_type.py New archive-owned BranchType enum module.
polylogue/archive/conversation/attribution.py New archive-owned attribution extraction implementation.
polylogue/archive/conversation/init.py Establish archive conversation package root.
polylogue/api/sync/conversations.py Update TYPE_CHECKING conversation model imports to archive conversation models.
polylogue/api/archive.py Update TYPE_CHECKING conversation model imports to archive conversation models.
polylogue/init.py Update root lazy export for Conversation to archive conversation models.
docs/topology-status.md Add archive-conversation cell and update counts.
docs/plans/topology-target.yaml Assign new archive conversation files to archive-conversation; remove old lib conversation entries.
docs/library-api.md Update import example to polylogue.archive.conversation.threads.
devtools/build_topology_projection.py Update topology projection mappings/owners for conversation to archive/conversation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/library-api.md
Comment on lines 39 to 41
from polylogue.lib.session.session_profile import build_session_profile, infer_auto_tags
from polylogue.lib.conversation.threads import build_session_threads
from polylogue.archive.conversation.threads import build_session_threads
```
Sinity added a commit that referenced this pull request May 7, 2026
## Summary

Move the conversation domain package from `polylogue.lib` into
`polylogue.archive`, keeping conversation models, branch types,
attribution, work-event extraction, neighbor discovery, and thread
building with archive-domain code.

## Problem

`polylogue/lib/conversation` owned archive conversation meaning while
living under the generic `lib` namespace. After query, filter, message,
semantic, projection, and related packages moved into `archive`,
conversation remained the largest archive-domain package in the old
bucket.

## Solution

- Rename `polylogue/lib/conversation` to
`polylogue/archive/conversation`.
- Update public facades, API/MCP/CLI surfaces, storage
hydration/repositories, pipeline materialization, products, parsers, and
tests to import the archive package.
- Refresh topology ownership from `lib-conversation` to
`archive-conversation`.
- Update the library API docs import example for session thread
building.

## Verification

- `ruff check --fix polylogue/ tests/ devtools/` followed by `ruff check
polylogue/ tests/ devtools/`
- `pytest -q tests/unit/core/test_conversation_semantics.py
tests/unit/core/test_threads_runtime.py
tests/unit/core/test_session_summaries.py
tests/unit/core/test_neighbor_candidates.py
tests/unit/core/test_repo_identity.py` — 59 passed
- `pytest -q tests/unit/archive/test_query_runtime_filters.py
tests/unit/archive/test_query_runtime_matching.py
tests/unit/archive/test_query_search_runtime.py
tests/unit/storage/test_store_ops.py
tests/unit/storage/test_archive_search_contracts.py
tests/unit/storage/test_search_misc.py` — 107 passed
- `pytest -q tests/unit/cli/test_neighbors_command.py
tests/unit/cli/test_command_aux_runtime.py
tests/unit/mcp/test_tool_contracts.py
tests/unit/pipeline/test_branching.py
tests/unit/sources/test_parsers_codex.py` — 116 passed
- `devtools build-topology-projection && devtools verify-topology`
- `devtools render-all --check`
- pre-push `devtools verify --quick` — all checks passed

Ref #635
@Sinity

Sinity commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

Only the rows listed above are dispositioned. Held findings remain open.

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.

2 participants