Skip to content

refactor(cli): absorb correlate command into read --view correlation (#1842) - #1894

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/cli-correlate-to-read-view
Jun 15, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/cli-correlate-to-read-view

Conversation

@Sinity

@Sinity Sinity commented Jun 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Folds the standalone correlate command into read --view correlation, continuing the #1842 CLI floor. MCP correlate_session(s) tools and the correlation logic are untouched — no capability lost.

Problem

correlate <session> is a session-seeded explainable report: git commits within the session's time window (by explicit ref / file-overlap / time), issue & PR references, optional GitHub-API enrichment, and optional OTLP span evidence. That is structurally a read --view (like neighbors / context), not a top-level command — the #1842 floor is find QUERY then read|mark|analyze|delete.

Solution

  • polylogue/cli/commands/correlate.py: convert correlate_command into run_correlation_view(env, *, session_id, repo_path, since_hours, output_format, confidence_threshold, github_api, otlp); all logic helpers (GitHub enrichment, OTLP evidence, pretty-print) retained. Removed a dead _parse_git_log helper (the live parser is _parse_git_log_blocks in insights/session_commit.py) and the now-unused click import.
  • polylogue/cli/query_verbs.py: add correlation to _READ_VIEWS, the five correlation options (--repo-path, --since-hours, --confidence-threshold, --github-api/--no-github-api, --otlp), and a dispatch branch resolving the seed from --id/id:/--latest.
  • Delete the correlate command registrations (short-help + ROOT_COMMANDS, commands discovery map, output_assurance entry).
  • Kept: MCP correlate_session(s) tools and insights.session_commit logic.
  • Added tests/unit/cli/test_correlate_view.py (JSON payload, missing-session exit, plain render) — the command had no dedicated CLI test before. Removed the command from the click-app / json-output enumeration suites.

Verification

devtools verify --quick   # exit 0: ruff/mypy/render-all --check/topology/...
devtools test test_correlate_view test_click_app test_json_output   # 127 passed

Baselines (help-main/help-read; help-correlate deleted), syrupy snapshots, topology projection, and cli-reference regenerated.

Ref #1842

Summary by CodeRabbit

  • New Features

    • Integrated correlation analysis into the read command via the new --view correlation option for unified access to correlation functionality.
    • Added correlation-specific configuration options: --repo-path, --since-hours, --confidence-threshold, --github-api/--no-github-api, and --otlp for customized analysis and enrichment.
  • Changes

    • The standalone correlate command has been retired.

…1842)

Problem: the standalone `correlate` command (session→git/GitHub correlation:
commits in the session window, issue/PR refs, optional GitHub-API enrichment
and OTLP span evidence) is a session-seeded explainable report that the #1842
floor folds into `read --view <view>`, like neighbors.

What changed:
- Convert correlate_command's body into run_correlation_view(env, *, session_id,
  repo_path, since_hours, output_format, confidence_threshold, github_api, otlp);
  all logic helpers (GitHub enrichment, OTLP, pretty-print) kept in correlate.py.
  Dropped a dead `_parse_git_log` helper (the live parser is _parse_git_log_blocks
  in insights/session_commit.py) and the now-unused click import.
- Add `correlation` to read's _READ_VIEWS plus --repo-path/--since-hours/
  --confidence-threshold/--github-api/--otlp options and a dispatch branch that
  resolves the seed from --id/id:/--latest.
- Delete the correlate command registrations (command_registration short-help +
  ROOT_COMMANDS, commands discovery map, output_assurance entry).
- MCP correlate_session(s) tools and the insights.session_commit logic unchanged.
- Add tests/unit/cli/test_correlate_view.py (json payload, missing-session exit,
  plain render) — the command previously had no dedicated CLI test. Removed the
  command from the click-app / json-output enumeration suites.

Verification: devtools verify --quick → exit 0; devtools test over
test_correlate_view + test_click_app + test_json_output → 127 passed.
Baselines/snapshots/topology/cli-reference regenerated.

Ref #1842

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

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The correlate top-level CLI command is removed and its behavior is absorbed into polylogue read --view correlation. correlate_command and _parse_git_log are deleted from correlate.py and replaced with run_correlation_view. read_verb gains five new correlation options and a dispatch branch. Help baselines, snapshots, and docs are updated throughout.

Changes

correlate → read --view correlation migration

Layer / File(s) Summary
correlate.py: replace Click command with run_correlation_view
polylogue/cli/commands/correlate.py
Removes correlate_command and _parse_git_log; introduces run_correlation_view as a programmatic function with keyword-only correlation parameters.
Remove correlate from CLI registration and output assurance
polylogue/cli/click_command_registration.py, polylogue/cli/commands/commands.py, polylogue/cli/output_assurance.py
Deletes correlate from _SHORT_HELP, ROOT_COMMANDS, _COMMAND_CATEGORIES, and ASSURANCE_REGISTRY.
read_verb: add --view correlation options and dispatch
polylogue/cli/query_verbs.py
Extends _READ_VIEWS with "correlation", adds five new Click options, updates read_verb signature, and adds the if view == "correlation" branch dispatching to run_correlation_view.
New unit tests for run_correlation_view
tests/unit/cli/test_correlate_view.py, tests/unit/cli/test_json_output.py, tests/unit/cli/test_click_app.py
Adds three tests covering JSON output, missing-session exit, and plain-text rendering; removes correlate from the JSON exclusion list; updates subcommand registration assertions.
Update help baselines and CLI snapshots
tests/baselines/showcase/help-*.txt, tests/unit/cli/__snapshots__/test_help_snapshots.ambr, tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
Removes help-correlate.txt; updates help-main.txt and help-read.txt; removes correlate entries from three terminal snapshot variants.
Docs and metadata updates
docs/cli-reference.md, docs/plans/topology-target.yaml, docs/test-quality-workflows.md
Removes correlate from the CLI reference command list, documents --view correlation under read, updates the output assurance matrix, and corrects topology loc and test quality counts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Sinity/polylogue#1711: Originally added correlate_command as a standalone CLI command with Click option wiring; this PR removes that same command and replaces it with run_correlation_view.
  • Sinity/polylogue#1863: Established the read_verb unified view router that this PR extends with the --view correlation branch and new dispatch logic.

Suggested labels

type:refactor, area:cli

Poem

🐇 Hop hop, the command list shrinks today,
correlate packed its bags and moved away.
Now nested in read, view correlation shines,
one verb to rule them, cleaner design!
The rabbit approves — fewer roots, better flow. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% 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 accurately describes the main change: refactoring the correlate command into a read view option, which aligns with the primary objective of the changeset.
Description check ✅ Passed The description follows the template with Summary, Problem, Solution, Verification, and Changelog sections completed; all required information is present and adequately detailed.
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/cli-correlate-to-read-view

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 15, 2026
@Sinity
Sinity merged commit 2ca0e3e into master Jun 15, 2026
13 of 14 checks passed
@Sinity
Sinity deleted the feature/refactor/cli-correlate-to-read-view branch June 15, 2026 09:12

@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: e383f55d6a

ℹ️ 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/cli/query_verbs.py Resolved
Comment thread polylogue/cli/query_verbs.py Resolved
@Sinity

Sinity commented Oct 1, 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.

  • 61.F102 / P2: fixed-already at the checked revision: The shared query-action resolver now obtains an exact session ID from the compiled id: clause. The correlation adapter supplies that invocation.session_id to read.correlation at polylogue/cli/read_views/correlation.py:50 instead of rejecting the canonical query-first seed.
  • 61.F103 / P2: fixed-already at the checked revision: Correlation builds its JSON or text document and routes it through deliver_content at polylogue/cli/read_views/correlation.py:76 with invocation.destination and invocation.out_path. The report is no longer emitted directly through the terminal console.

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.

1 participant