Skip to content

feat: add shared content projection surface - #391

Merged
Sinity merged 2 commits into
masterfrom
feature/feat/content-kind-projection
Apr 23, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/feat/content-kind-projection

Conversation

@Sinity

@Sinity Sinity commented Apr 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Add a shared content-kind projection contract for conversation output and wire it through the CLI, facade, MCP, and formatter/payload surfaces. This lands prose-only and selective content suppression without reintroducing one-off string surgery in each consumer.

Problem

#310 called for content-kind decomposition as a real shared projection contract, not ad hoc trimming. Before this slice, Polylogue only had narrow transforms like strip-tools and strip-thinking, while full conversation output still flowed through CLI, facade, MCP, and formatter paths without a shared way to remove code blocks, tool calls, tool outputs, or file-read payloads. That made the projection semantics incomplete and surface-specific.

Solution

  • add polylogue.lib.content_projection with canonical content kinds and a reusable ContentProjectionSpec
  • project structured blocks first, then fall back to text segmentation for fenced code and reasoning tags
  • preserve file-read vs general tool-output distinctions by pairing tool results with tool-use semantic types
  • wire projection through conversation runtime helpers, archive operations, facade methods, CLI query output, and MCP read/export tools
  • add root CLI flags --no-code-blocks, --no-tool-calls, --no-tool-outputs, --no-file-reads, and --prose-only
  • refresh the generated CLI reference, showcase help baseline, and PTY help snapshots for the new surface
  • cover the contract across core, CLI, facade, and MCP tests, including the attachment-only edge case

Verification

  • pytest -q tests/unit/core/test_content_projection.py tests/unit/cli/test_query_fmt.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_query_exec.py tests/unit/cli/test_click_app.py tests/unit/cli/test_terminal_snapshots.py tests/unit/core/test_facade_api.py tests/unit/mcp/test_server_surfaces.py -q
  • devtools verify

Closes #310

Summary by CodeRabbit

Release Notes

  • New Features
    • Five new CLI flags control conversation output filtering: --no-code-blocks, --no-tool-calls, --no-tool-outputs, --no-file-reads, and --prose-only. Users can exclude specific content types such as code blocks, tool records, tool outputs, or file-read results, or view only authored prose.
    • Content filtering capabilities now available across conversation retrieval and export operations.

Sinity added 2 commits April 23, 2026 22:00
Problem
The archive exposed full conversation text, but content-kind filtering still
lived in narrow one-off transforms. CLI, facade, MCP, and formatter paths
had no shared projection contract for prose-only views or for selectively
removing code blocks, tool calls, tool outputs, and file-read payloads.

Solution
Add a substrate-owned content projection model and wire it through the
conversation runtime, archive operations, facade, CLI query output, MCP
read/export tools, and shared formatting/payload helpers. This also adds
owning tests across core, CLI, facade, and MCP surfaces, including the
attachment edge case where prose-only output must drop attachment-only
messages.

Verification
Ref #310
- pytest -q tests/unit/core/test_content_projection.py tests/unit/cli/test_query_fmt.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_query_exec.py tests/unit/cli/test_click_app.py tests/unit/cli/test_terminal_snapshots.py tests/unit/core/test_facade_api.py tests/unit/mcp/test_server_surfaces.py -q
- devtools verify
Problem
The new content projection flags change the observable help surface, so the
CLI reference, showcase help baseline, and PTY terminal snapshots must move
with the implementation.

Solution
Refresh the generated CLI reference and the committed help/snapshot baselines
for the top-level query surface.

Verification
Ref #310
- pytest -q tests/unit/cli/test_terminal_snapshots.py -q
- devtools render-all --check
@coderabbitai

coderabbitai Bot commented Apr 23, 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: fc03df40-4ad5-443d-8bc4-35169eda7226

📥 Commits

Reviewing files that changed from the base of the PR and between 769febe and 566c745.

📒 Files selected for processing (24)
  • docs/cli-reference.md
  • polylogue/cli/click_app.py
  • polylogue/cli/click_option_groups.py
  • polylogue/cli/query.py
  • polylogue/cli/query_contracts.py
  • polylogue/cli/query_output.py
  • polylogue/facade_archive.py
  • polylogue/lib/__init__.py
  • polylogue/lib/content_projection.py
  • polylogue/lib/conversation_runtime.py
  • polylogue/mcp/query_contracts.py
  • polylogue/mcp/server_maintenance_tools.py
  • polylogue/mcp/server_tools.py
  • polylogue/operations/archive.py
  • polylogue/rendering/formatting.py
  • polylogue/surface_payloads.py
  • tests/baselines/showcase/help-main.txt
  • tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
  • tests/unit/cli/test_query_exec.py
  • tests/unit/cli/test_query_exec_laws.py
  • tests/unit/cli/test_query_fmt.py
  • tests/unit/core/test_content_projection.py
  • tests/unit/core/test_facade_api.py
  • tests/unit/mcp/test_server_surfaces.py

📝 Walkthrough

Walkthrough

This change introduces content-kind decomposition to allow filtering conversation output by content category: code blocks, tool calls, tool outputs, and file reads. A new ContentProjectionSpec system is integrated across CLI, MCP, facade, and query surfaces to enable consistent filtering without modifying archived data.

Changes

Cohort / File(s) Summary
CLI Option Declaration
docs/cli-reference.md, polylogue/cli/click_app.py, polylogue/cli/click_option_groups.py
Five new output-filtering flags added to CLI: --no-code-blocks, --no-tool-calls, --no-tool-outputs, --no-file-reads, and --prose-only. Integrated into Click command parameters and option groups.
Core Projection Logic
polylogue/lib/content_projection.py, polylogue/lib/__init__.py, polylogue/lib/conversation_runtime.py
New ContentKind enum and ContentProjectionSpec dataclass define filtering model. project_conversation_content() applies projection by segmenting messages, classifying content kinds, and filtering based on configuration. New with_content_projection() method added to conversation runtime for in-memory filtering.
Query Execution & Output
polylogue/cli/query.py, polylogue/cli/query_contracts.py, polylogue/cli/query_output.py
QueryOutputSpec extended with content_projection field and filters_content() predicate. Query routing (prefers_summary_list) tightened to avoid summary-list path when active filtering occurs. stream_conversation() bifurcated to load full conversation for projection filtering or iterate messages for streaming without filtering.
Archive & Repository Layer
polylogue/operations/archive.py, polylogue/facade_archive.py
Archive mixin methods (get_conversation, get_conversations, list_conversations, query_conversations) accept optional content_projection parameter and apply projection via with_content_projection() when filtering is active.
MCP Surface
polylogue/mcp/query_contracts.py, polylogue/mcp/server_tools.py, polylogue/mcp/server_maintenance_tools.py
New MCPContentProjectionRequest dataclass encapsulates projection flags. export_conversation and export_query_results tools accept projection flags, build request, and pass projection to archive retrieval and formatting operations.
Rendering & Serialization
polylogue/rendering/formatting.py, polylogue/surface_payloads.py
format_conversation() and ConversationDetailPayload.from_conversation() accept optional content_projection parameter and apply filtering before format-specific rendering.
Test Snapshots & Baselines
tests/baselines/showcase/help-main.txt, tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
CLI help text and terminal output snapshots updated to reflect five new filtering options with appropriate line-wrapping for different terminal widths.
Unit Tests
tests/unit/cli/test_query_exec.py, tests/unit/cli/test_query_exec_laws.py, tests/unit/cli/test_query_fmt.py, tests/unit/core/test_content_projection.py, tests/unit/core/test_facade_api.py, tests/unit/mcp/test_server_surfaces.py
New and updated tests validate content projection behavior across query execution, formatting, facade APIs, and MCP surfaces. Test suites cover filtering code blocks, tool calls, tool outputs, file reads, and prose-only modes.

Sequence Diagram

sequenceDiagram
    participant CLI as CLI Parser
    participant QuerySpec as QueryOutputSpec
    participant Archive as ArchiveSearchMixin
    participant Conversation as Conversation
    participant Projection as ContentProjection
    participant Formatter as Formatter

    CLI->>QuerySpec: Create with content_projection<br/>flags (no_code_blocks, etc.)
    QuerySpec->>Archive: query_conversations(spec,<br/>content_projection=spec)
    Archive->>Archive: Fetch conversations<br/>from repository
    Archive->>Conversation: with_content_projection(spec)
    Conversation->>Projection: project_conversation_content()
    Projection->>Projection: Classify & filter<br/>by ContentKind
    Projection-->>Conversation: Return filtered<br/>conversation
    Conversation-->>Archive: Return projected
    Archive-->>QuerySpec: Return list[Conversation]
    QuerySpec->>Formatter: format_conversation(conv,<br/>content_projection=spec)
    Formatter->>Conversation: with_content_projection(spec)
    Conversation->>Projection: Apply filtering
    Projection-->>Conversation: Projected content
    Formatter->>Formatter: Render to format<br/>(markdown/JSON/etc.)
    Formatter-->>CLI: Formatted output
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Suggested labels

type:feat, area:cli, area:storage, area:parser, area:docs

Poem

🐰 A bunny's ode to content projection:

Code blocks vanish, tool calls cease,
Prose alone brings gentle peace,
Filtering magic, kind by kind,
Leaves only thoughts within the mind!
–✨ The Filtering Rabbit

✨ 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/feat/content-kind-projection

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 811c948 into master Apr 23, 2026
10 of 12 checks passed
@Sinity
Sinity deleted the feature/feat/content-kind-projection branch April 23, 2026 20:03

@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: 566c745dd2

ℹ️ 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.py Resolved
Comment thread polylogue/lib/content_projection.py Resolved
@Sinity
Sinity requested review from Copilot and removed request for Copilot May 1, 2026 00:44
@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
## Summary
Add a shared content-kind projection contract for conversation output
and wire it through the CLI, facade, MCP, and formatter/payload
surfaces. This lands prose-only and selective content suppression
without reintroducing one-off string surgery in each consumer.

## Problem
`#310` called for content-kind decomposition as a real shared projection
contract, not ad hoc trimming. Before this slice, Polylogue only had
narrow transforms like `strip-tools` and `strip-thinking`, while full
conversation output still flowed through CLI, facade, MCP, and formatter
paths without a shared way to remove code blocks, tool calls, tool
outputs, or file-read payloads. That made the projection semantics
incomplete and surface-specific.

## Solution
- add `polylogue.lib.content_projection` with canonical content kinds
and a reusable `ContentProjectionSpec`
- project structured blocks first, then fall back to text segmentation
for fenced code and reasoning tags
- preserve file-read vs general tool-output distinctions by pairing tool
results with tool-use semantic types
- wire projection through conversation runtime helpers, archive
operations, facade methods, CLI query output, and MCP read/export tools
- add root CLI flags `--no-code-blocks`, `--no-tool-calls`,
`--no-tool-outputs`, `--no-file-reads`, and `--prose-only`
- refresh the generated CLI reference, showcase help baseline, and PTY
help snapshots for the new surface
- cover the contract across core, CLI, facade, and MCP tests, including
the attachment-only edge case

## Verification
- `pytest -q tests/unit/core/test_content_projection.py
tests/unit/cli/test_query_fmt.py tests/unit/cli/test_query_exec_laws.py
tests/unit/cli/test_query_exec.py tests/unit/cli/test_click_app.py
tests/unit/cli/test_terminal_snapshots.py
tests/unit/core/test_facade_api.py
tests/unit/mcp/test_server_surfaces.py -q`
- `devtools verify`

Closes #310
@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.

@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.F078 / P2: stale at the checked revision: The role-filter-then-content-projection CLI chain is retired, including the old --no-file-reads message option. Current message-read options are explicitly declared at polylogue/cli/read_view_registry.py:241, and the operation refuses filtered transcript windows at polylogue/operations/daemon_reads.py:1526 instead of running the lossy projection ordering.

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.

[feat] Content-kind decomposition — strip code blocks / tool outputs / file reads

1 participant