Skip to content

fix(pipeline): invert embed dependency, pipeline imports substrate not cli - #461

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/embed-cli-pipeline-cycle
Apr 26, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/embed-cli-pipeline-cycle

Conversation

@Sinity

@Sinity Sinity commented Apr 26, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #430. Moves embedding execution and stats payload helpers out of
polylogue/cli/ and into a new substrate module under
polylogue/lib/embeddings/. The CLI modules become thin click-formatting
wrappers; pipeline calls substrate directly without the _PlainUI /
_EmbedEnv shims that proxied a fake CLI surface back into pipeline.

Problem

polylogue/pipeline/run_stages.py imported embed_batch /
embed_single / show_embedding_stats from polylogue/cli/,
inverting the documented placement rule and creating a true substrate↔
surface cycle that devtools verify-cluster-cohesion flags. The
imports were lazy (inside function bodies) so they didn't crash at module
load, but they bound pipeline to a CLI shape and required pipeline to
fabricate a fake UI object to satisfy the CLI's protocol.

Solution

  • polylogue/lib/embeddings/runtime.py — click-free
    embed_conversation_sync + iter_pending_conversations +
    EmbedConversationOutcome.
  • polylogue/lib/embeddings/stats.py — embedding_status_payload
    and payload type definitions (was already click-free; just moved).
  • polylogue/cli/embed_runtime.py / embed_stats.py — thin click
    wrappers composing substrate outcomes into the existing CLI surface;
    no behavior change to polylogue run embed output.
  • polylogue/pipeline/run_stages.py — imports substrate; emits its
    own click.echo for the pipeline-stage user output. _PlainUI
    and _EmbedEnv shims removed.

Verification

  • tests/unit/pipeline/test_no_cli_imports.py (new) — regression
    guard asserting no polylogue/pipeline/**/*.py imports from
    polylogue/cli/**.
  • tests/unit/pipeline/test_run_stages_runtime.py — updated to patch
    substrate locations rather than CLI re-exports.
  • devtools verify (full, including pytest): all checks pass.

Acceptance criteria checklist

…t cli

Closes #430.

Move embedding execution and stats-payload helpers out of polylogue/cli/
and into a substrate module under polylogue/lib/embeddings/. The CLI
modules become thin click-formatting wrappers; pipeline calls substrate
directly without the _PlainUI/_EmbedEnv shim that proxied a fake CLI
into pipeline.

- polylogue/lib/embeddings/runtime.py: click-free
  embed_conversation_sync + iter_pending_conversations + EmbedConversationOutcome.
- polylogue/lib/embeddings/stats.py: embedding_status_payload + payload
  type definitions (was already click-free, just moved).
- polylogue/cli/embed_runtime.py / embed_stats.py: thin click wrappers
  that compose substrate output into the existing CLI surface.
- polylogue/pipeline/run_stages.py: imports substrate; emits its own
  click.echo for the existing pipeline-stage user output. _PlainUI and
  _EmbedEnv shims removed.

Verification: tests/unit/pipeline/test_no_cli_imports.py asserts no
polylogue/pipeline/**/*.py imports from polylogue/cli/**.
test_run_stages_runtime.py updated to patch substrate locations.
devtools verify (full): all checks pass.
@coderabbitai

coderabbitai Bot commented Apr 26, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 48 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 15 minutes and 48 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: fcd3ee63-4ef2-4e6a-b541-1239d940b5a7

📥 Commits

Reviewing files that changed from the base of the PR and between 0ec45e4 and c4b0c76.

📒 Files selected for processing (10)
  • docs/plans/topology-target.yaml
  • docs/topology-status.md
  • polylogue/cli/embed_runtime.py
  • polylogue/cli/embed_stats.py
  • polylogue/lib/embeddings/__init__.py
  • polylogue/lib/embeddings/runtime.py
  • polylogue/lib/embeddings/stats.py
  • polylogue/pipeline/run_stages.py
  • tests/unit/pipeline/test_no_cli_imports.py
  • tests/unit/pipeline/test_run_stages_runtime.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/embed-cli-pipeline-cycle

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 merged commit 3b56542 into master Apr 26, 2026
13 checks passed
@Sinity
Sinity deleted the feature/fix/embed-cli-pipeline-cycle branch April 26, 2026 18:00
Sinity added a commit that referenced this pull request Apr 26, 2026
…462)

## Summary

Closes #406. Stacked on #461.

## Problem

The single-conversation ``export`` command silently ignored root-level
``--message-role`` and ``--dialogue-only`` flags. Users had to dump full
JSON and post-filter in Python to extract user-only prose:

    polylogue --message-role user export <id> --format json
    # returns full message list, ignoring --message-role

## Solution

Wires the flags through the same helper the verbs use:
``conversation.with_roles(roles)``. Honors ``--message-role`` (one or
more roles); when ``--dialogue-only`` is set without an explicit role
filter, defaults to user+assistant.

## Verification

``tests/unit/cli/test_export.py`` covers both paths against a synthetic
conversation with mixed roles (user / assistant / system).
``devtools verify`` (full): all checks pass.
@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:54
@Sinity
Sinity removed the request for review from Copilot May 1, 2026 02:15
Sinity added a commit that referenced this pull request May 7, 2026
…t cli (#461)

## Summary

Closes #430. Moves embedding execution and stats payload helpers out of
``polylogue/cli/`` and into a new substrate module under
``polylogue/lib/embeddings/``. The CLI modules become thin
click-formatting
wrappers; pipeline calls substrate directly without the ``_PlainUI`` /
``_EmbedEnv`` shims that proxied a fake CLI surface back into pipeline.

## Problem

``polylogue/pipeline/run_stages.py`` imported ``embed_batch`` /
``embed_single`` / ``show_embedding_stats`` from ``polylogue/cli/``,
inverting the documented placement rule and creating a true substrate↔
surface cycle that ``devtools verify-cluster-cohesion`` flags. The
imports were lazy (inside function bodies) so they didn't crash at
module
load, but they bound pipeline to a CLI shape and required pipeline to
fabricate a fake UI object to satisfy the CLI's protocol.

## Solution

- ``polylogue/lib/embeddings/runtime.py`` — click-free
  ``embed_conversation_sync`` + ``iter_pending_conversations`` +
  ``EmbedConversationOutcome``.
- ``polylogue/lib/embeddings/stats.py`` — ``embedding_status_payload``
  and payload type definitions (was already click-free; just moved).
- ``polylogue/cli/embed_runtime.py`` / ``embed_stats.py`` — thin click
  wrappers composing substrate outcomes into the existing CLI surface;
  no behavior change to ``polylogue run embed`` output.
- ``polylogue/pipeline/run_stages.py`` — imports substrate; emits its
  own ``click.echo`` for the pipeline-stage user output. ``_PlainUI``
  and ``_EmbedEnv`` shims removed.

## Verification

- ``tests/unit/pipeline/test_no_cli_imports.py`` (new) — regression
  guard asserting no ``polylogue/pipeline/**/*.py`` imports from
  ``polylogue/cli/**``.
- ``tests/unit/pipeline/test_run_stages_runtime.py`` — updated to patch
  substrate locations rather than CLI re-exports.
- ``devtools verify`` (full, including pytest): all checks pass.

## Acceptance criteria checklist

- [x] No ``polylogue/pipeline/**/*.py`` imports from
``polylogue/cli/**``.
- [x] Embedding behavior is callable from pipeline without going through
``cli``.
- [x] Existing CLI behavior unchanged.
- [ ] ``devtools verify-cluster-cohesion`` reports no ``cli ↔ pipeline``
cycle —
will be exercised by the lint introduced in #429 / Phase 1 of #432.
Sinity added a commit that referenced this pull request May 7, 2026
…462)

## Summary

Closes #406. Stacked on #461.

## Problem

The single-conversation ``export`` command silently ignored root-level
``--message-role`` and ``--dialogue-only`` flags. Users had to dump full
JSON and post-filter in Python to extract user-only prose:

    polylogue --message-role user export <id> --format json
    # returns full message list, ignoring --message-role

## Solution

Wires the flags through the same helper the verbs use:
``conversation.with_roles(roles)``. Honors ``--message-role`` (one or
more roles); when ``--dialogue-only`` is set without an explicit role
filter, defaults to user+assistant.

## Verification

``tests/unit/cli/test_export.py`` covers both paths against a synthetic
conversation with mixed roles (user / assistant / system).
``devtools verify`` (full): all checks pass.
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.

fix(pipeline): pipeline imports cli/ — invert dependency

1 participant