Skip to content

refactor(cli): move absorbed read views out of commands - #2072

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/read-view-implementation-modules-1849
Jun 18, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/read-view-implementation-modules-1849

Conversation

@Sinity

@Sinity Sinity commented Jun 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Move the already-absorbed context, context-pack, and correlation read-view implementations out of polylogue.cli.commands and into their owning context/insight modules. The read dispatcher and read-view profiles now point at those owner modules directly, and the focused tests import/patch those modules instead of command wrappers.

Problem

read --view context, read --view context-pack, and read --view correlation had been absorbed into the read surface, but their implementations still lived under polylogue.cli.commands. That kept the old command-module layout as the behavioral owner and made later root-command pruning riskier than it needed to be.

Solution

  • Move context preamble composition to polylogue.context.preamble.
  • Move context-pack rendering to polylogue.context.pack.
  • Move session/git/GitHub/OTLP correlation rendering to polylogue.insights.correlation_view.
  • Rewire polylogue.cli.query_verbs and polylogue.archive.viewport.profiles to the new owners.
  • Update focused tests to import and patch the new owner modules directly.
  • Regenerate topology docs for the moved modules.

This deliberately does not add any old-command absence blacklist test.

Ref #1849

Verification

  • python -m py_compile polylogue/context/__init__.py polylogue/context/preamble.py polylogue/context/pack.py polylogue/insights/correlation_view.py polylogue/cli/query_verbs.py polylogue/archive/viewport/profiles.py exited 0.
  • nix develop --command devtools test tests/unit/cli/test_context_view.py tests/unit/cli/test_context_pack_view.py tests/unit/cli/test_correlate_view.py tests/unit/cli/test_query_verbs_runtime.py -k 'context or correlation' selected 9 tests: 9 passed, 23 deselected.
  • nix develop --command devtools verify --quick exited 0.
  • Pre-push devtools verify --quick on 5aad7da exited 0.

I also started the default nix develop --command devtools verify; static/generated checks passed, but the pytest-testmon phase selected a very large affected set and was interrupted after 711s at 69%. I am not counting that as a passing gate.

Summary by CodeRabbit

Release Notes

  • Refactor
    • Reorganized internal module structure for improved code organization and maintainability.
  • Documentation
    • Updated docstrings and comments to reflect refactored code organization.
  • Tests
    • Updated tests to align with internal structural changes.

No functional changes to user-facing features or behavior.

Move the context, context-pack, and correlation read-view implementations into their owning context/insight modules instead of keeping behavior under polylogue.cli.commands. The query read dispatcher and viewport profiles now point at those owner modules directly, and tests import/patch the owner modules rather than command adapters.\n\nRef #1849
@coderabbitai

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9b3bb793-b3d4-4adb-af16-6f7f6a49402e

📥 Commits

Reviewing files that changed from the base of the PR and between 207faa1 and 5aad7da.

📒 Files selected for processing (12)
  • docs/plans/topology-target.yaml
  • docs/topology-status.md
  • polylogue/archive/viewport/profiles.py
  • polylogue/cli/query_verbs.py
  • polylogue/context/__init__.py
  • polylogue/context/pack.py
  • polylogue/context/preamble.py
  • polylogue/insights/correlation_view.py
  • tests/unit/cli/test_context_pack_view.py
  • tests/unit/cli/test_context_view.py
  • tests/unit/cli/test_correlate_view.py
  • tests/unit/cli/test_query_verbs_runtime.py

📝 Walkthrough

Walkthrough

Three read-view functions (compose_context_preamble, run_context_pack_view, run_correlation_view) are relocated from polylogue/cli/commands/ into polylogue/context/ and polylogue/insights/. A new polylogue/context/__init__.py provides lazy exports. The CLI router, profile ownership metadata, tests, and topology docs are all updated to reflect the new locations.

Changes

View logic migration to domain modules

Layer / File(s) Summary
polylogue/context package: preamble rename, pack cleanup, lazy __init__
polylogue/context/__init__.py, polylogue/context/preamble.py, polylogue/context/pack.py
New __init__.py exposes compose_context_preamble and run_context_pack_view via lazy __getattr__. In preamble.py, run_context_compose is renamed to compose_context_preamble and AppEnv is moved under TYPE_CHECKING. In pack.py, AppEnv similarly moves under TYPE_CHECKING and docstrings are shortened.
polylogue/insights/correlation_view.py cleanup
polylogue/insights/correlation_view.py
AppEnv moved under TYPE_CHECKING. Arrow symbols → replaced with -> in OTLP and pretty-printer output. Redundant local import json removed. Commit method glyph mapping updated. Section comments removed without changing output content.
CLI router and profile ownership wiring
polylogue/cli/query_verbs.py, polylogue/archive/viewport/profiles.py
query_verbs.py redirects read --view context-pack and read --view correlation imports to the new domain modules, and replaces read --view context with compose_context_preamble (enforcing session_id, clamping related_limit). SessionViewProfile owner strings updated for all three views.
Test updates for new import paths
tests/unit/cli/test_context_view.py, tests/unit/cli/test_context_pack_view.py, tests/unit/cli/test_correlate_view.py, tests/unit/cli/test_query_verbs_runtime.py
All four test files redirect imports and patches from polylogue.cli.commands.* to polylogue.context.* / polylogue.insights.*. Test functions in test_context_view.py renamed to test_compose_context_preamble_*.
Topology target and status docs
docs/plans/topology-target.yaml, docs/topology-status.md
topology-target.yaml removes three CLI command entries and adds stable entries for the four new domain module paths. topology-status.md increments Stable and Total declared counts by 1.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Sinity/polylogue#968: Introduced polylogue/cli/commands/context_pack.py, the module that this PR migrates run_context_pack_view away from.
  • Sinity/polylogue#1894: Absorbed the standalone correlate command into read --view correlation, which this PR completes by moving run_correlation_view to polylogue.insights.correlation_view.
  • Sinity/polylogue#1970: Also modifies the generated docs/topology-status.md drift dashboard counts to reflect newly realized modules, directly overlapping with this PR's topology doc changes.

Poem

🐇 Hop, hop, the commands have moved,
From CLI caves to domain grooves!
compose_context_preamble takes the stage,
Lazy imports turn a cleaner page.
The topology ticks one count ahead—
The rabbit refactors, full speed ahead! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: moving read-view implementations from the commands module to their respective owner modules.
Description check ✅ Passed The PR description covers all required template sections: Summary, Problem, Solution, Verification, Changelog (appropriately skipped as refactor), and Risks and Follow-ups (deleted as none identified).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/read-view-implementation-modules-1849

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.

github-actions Bot pushed a commit that referenced this pull request Jun 17, 2026
@Sinity
Sinity merged commit ac84f73 into master Jun 18, 2026
14 checks passed
@Sinity
Sinity deleted the feature/refactor/read-view-implementation-modules-1849 branch June 18, 2026 00:49
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