Skip to content

feat(cli): add bulk-export verb for filter-driven JSONL dumps - #483

Merged
Sinity merged 2 commits into
masterfrom
feature/feat/export-bulk
Apr 26, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/feat/export-bulk

Conversation

@Sinity

@Sinity Sinity commented Apr 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • New query verb polylogue bulk-export consumes the parent filter chain (--provider, --since, --path, --message-role, etc.) and emits every matched conversation in one process.
  • Default --format jsonl writes one single-line conversation JSON per line — drops straight into jq/Python pipelines.
  • Other formats (json array, markdown, yaml, html, plaintext, obsidian, org) concatenate with appropriate separators.

Closes #408.

Problem

Single-conversation polylogue export <id> requires one process per conversation. The user's existing pattern (list --format json | jq -r '.[].id' | xargs polylogue export) pays ~1.5s of Python interpreter + DB connection startup overhead per call — about 50s of pure overhead for 35 conversations. There is no way to dump every conversation matching a filter set into one analyzable corpus in a single process.

Solution

polylogue/cli/bulk_export.py (new): run_bulk_export(env, request, *, output_format, fields) builds a ConversationQuerySpec and a full QueryExecutionPlan from the parent RootModeRequest, calls ArchiveOperations.query_conversations(spec) to load every match in one go, then projects through project_query_results() so root-level --message-role / --dialogue-only / transform settings flow through. Output is streamed format-by-format:

  • jsonl (default): each conversation rendered as JSON, collapsed to one line.
  • json: emits a JSON array ([, comma-delimited entries, ]).
  • markdown/obsidian/org/plaintext/html/yaml: concatenated with \n---\n separators between conversations (no separator before the first).

polylogue/cli/query_verbs.py: register bulk_export_verb (Click command name bulk-export) and add "bulk-export" to VERB_NAMES so _split_query_mode_args recognizes it after positional filters.

Tests:

  • tests/unit/cli/test_bulk_export.py (new): 6 focused tests covering the JSONL stream, zero-result behavior, markdown separator placement, the verb's CLI dispatch path, VERB_NAMES membership, and field-pass-through.
  • tests/unit/cli/test_query_verbs_runtime.py: extend the verb-runtime suite with a parent-request capture test for bulk-export.
  • tests/unit/cli/test_click_app.py: extend the registered-commands assertion.
  • Snapshots refreshed via --snapshot-update; docs/plans/topology-target.yaml and the cli/quality/verification reference docs regenerated by devtools render-all.

Out of scope (deferred): a tar-of-markdown-files mode, streaming results from disk (current path materializes the full match set in memory; sufficient for the issue's ~35-session use case, room to revisit if memory becomes a constraint on larger corpora).

Verification

nix develop -c pytest tests/unit/cli/ -q                # 851 passed
nix develop -c devtools verify --quick                  # all checks passed

End-to-end:

$ time polylogue --plain --provider claude-code --since 2026-04-25 --limit 2 bulk-export --format jsonl | head -1 | cut -c1-160
{"id":"claude-code:8d821a23-...","provider":"claude-code","title":"investigate open issues and propose a set you'd tackle next, ...
real  0m3.10s

🤖 Generated with Claude Code

@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 24 minutes and 42 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 24 minutes and 42 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: 0529ed20-7b3f-4323-8ea5-d65b4a855f80

📥 Commits

Reviewing files that changed from the base of the PR and between 68e88f2 and 17c4936.

📒 Files selected for processing (13)
  • docs/cli-reference.md
  • docs/plans/topology-target.yaml
  • docs/test-quality-workflows.md
  • docs/topology-status.md
  • docs/verification-catalog.md
  • polylogue/cli/bulk_export.py
  • polylogue/cli/query_verbs.py
  • tests/baselines/showcase/help-bulk-export.txt
  • tests/baselines/showcase/help-main.txt
  • tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
  • tests/unit/cli/test_bulk_export.py
  • tests/unit/cli/test_click_app.py
  • tests/unit/cli/test_query_verbs_runtime.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/export-bulk

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.

@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: 23a600ceb6

ℹ️ 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/bulk_export.py Resolved
Comment thread polylogue/cli/bulk_export.py Resolved
@Sinity
Sinity enabled auto-merge (squash) April 26, 2026 21:00
Sinity and others added 2 commits April 26, 2026 23:15
Closes #408.

Single-conversation `polylogue export <id>` requires one process per
conversation; piping `list --format json | jq | xargs export` adds ~1.5s
of interpreter/DB-startup overhead per conversation (50s for 35
sessions). `bulk-export` consumes the parent filter chain
(`--provider`, `--since`, `--path`, `--message-role`, etc.), loads every
match in one process via `ArchiveOperations.query_conversations`, and
streams them to stdout — defaulting to JSONL (one conversation per
line) so the output drops straight into `jq`/Python pipelines.

`polylogue/cli/bulk_export.py` carries the per-format streaming logic;
`query_verbs.py` registers the verb and wires it into the parent
`RootModeRequest`. `--message-role` and `--dialogue-only` from the root
group are honored via the existing `project_query_results()`
projection. Other formats (markdown, json-array, yaml, html, etc.)
concatenate with the appropriate separator.

Verification:

- pytest tests/unit/cli/ -q (851 passed)
- devtools verify --quick (all checks passed)
- live: polylogue --plain --provider claude-code --since 2026-04-25
        --limit 2 bulk-export --format jsonl
  emits two single-line conversation JSONs in ~3s.

Co-Authored-By: Claude <[email protected]>
The new ``bulk-export`` verb introduced in this PR exposes a new
``help-bulk-export`` showcase exercise via the auto-discovered help-N
catalog. Commit the captured baseline and refresh ``help-main`` to
include the verb in the top-level command listing.

Co-Authored-By: Claude <[email protected]>
@Sinity
Sinity force-pushed the feature/feat/export-bulk branch from 0a31116 to 17c4936 Compare April 26, 2026 21:20
@Sinity
Sinity merged commit 005c0a2 into master Apr 26, 2026
10 of 11 checks passed
@Sinity
Sinity deleted the feature/feat/export-bulk branch April 26, 2026 21:20
Sinity added a commit that referenced this pull request Apr 27, 2026
Three baselines drifted after the show/export/bulk-export fixes landed:

  - help-show: show verb body rewritten (#482)
  - help-export: gained provider:id-prefix note (#483)
  - help-main: show description text adjusted (#482)

Master CI (showcase-verify) has been red since 6b5c392. Refreshing
the baselines unblocks PRs that depend on a green master.

Verification: `devtools lab-scenario verify-baselines` exits 0.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@Sinity
Sinity requested a review from Copilot May 1, 2026 00:45

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sinity added a commit that referenced this pull request May 7, 2026
## Summary

- New query verb `polylogue bulk-export` consumes the parent filter
chain (`--provider`, `--since`, `--path`, `--message-role`, etc.) and
emits every matched conversation in one process.
- Default `--format jsonl` writes one single-line conversation JSON per
line — drops straight into `jq`/Python pipelines.
- Other formats (json array, markdown, yaml, html, plaintext, obsidian,
org) concatenate with appropriate separators.

Closes #408.

## Problem

Single-conversation `polylogue export <id>` requires one process per
conversation. The user's existing pattern (`list --format json | jq -r
'.[].id' | xargs polylogue export`) pays ~1.5s of Python interpreter +
DB connection startup overhead per call — about 50s of pure overhead for
35 conversations. There is no way to dump every conversation matching a
filter set into one analyzable corpus in a single process.

## Solution

`polylogue/cli/bulk_export.py` (new): `run_bulk_export(env, request, *,
output_format, fields)` builds a `ConversationQuerySpec` and a full
`QueryExecutionPlan` from the parent `RootModeRequest`, calls
`ArchiveOperations.query_conversations(spec)` to load every match in one
go, then projects through `project_query_results()` so root-level
`--message-role` / `--dialogue-only` / transform settings flow through.
Output is streamed format-by-format:

- `jsonl` (default): each conversation rendered as JSON, collapsed to
one line.
- `json`: emits a JSON array (`[`, comma-delimited entries, `]`).
- `markdown`/`obsidian`/`org`/`plaintext`/`html`/`yaml`: concatenated
with `\n---\n` separators between conversations (no separator before the
first).

`polylogue/cli/query_verbs.py`: register `bulk_export_verb` (Click
command name `bulk-export`) and add `"bulk-export"` to `VERB_NAMES` so
`_split_query_mode_args` recognizes it after positional filters.

Tests:

- `tests/unit/cli/test_bulk_export.py` (new): 6 focused tests covering
the JSONL stream, zero-result behavior, markdown separator placement,
the verb's CLI dispatch path, `VERB_NAMES` membership, and
field-pass-through.
- `tests/unit/cli/test_query_verbs_runtime.py`: extend the verb-runtime
suite with a parent-request capture test for `bulk-export`.
- `tests/unit/cli/test_click_app.py`: extend the registered-commands
assertion.
- Snapshots refreshed via `--snapshot-update`;
`docs/plans/topology-target.yaml` and the cli/quality/verification
reference docs regenerated by `devtools render-all`.

Out of scope (deferred): a tar-of-markdown-files mode, streaming results
from disk (current path materializes the full match set in memory;
sufficient for the issue's ~35-session use case, room to revisit if
memory becomes a constraint on larger corpora).

## Verification

```
nix develop -c pytest tests/unit/cli/ -q                # 851 passed
nix develop -c devtools verify --quick                  # all checks passed
```

End-to-end:

```
$ time polylogue --plain --provider claude-code --since 2026-04-25 --limit 2 bulk-export --format jsonl | head -1 | cut -c1-160
{"id":"claude-code:8d821a23-...","provider":"claude-code","title":"investigate open issues and propose a set you'd tackle next, ...
real  0m3.10s
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <[email protected]>
@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.

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.

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(export): add bulk export for filtered conversations

2 participants