Repository navigation
Description
Context
Polylogue now has durable derived products such as session profiles and session_work_events, and downstream tools increasingly need those products as data, not as rendered conversation transcripts. Lynchpin is one current consumer, but the need is generic: any local analytics, notebook, MCP client, or archival tool should be able to request a stable export bundle for a query/time window and know what product schemas and coverage it received.
Issue #194 includes an export_query_results MCP/CLI gap, but that scope is conversation-result export and general surface widening. This issue is narrower and more data-product oriented: export a versioned bundle of normalized archive products with schema/provenance metadata, suitable for downstream computation without rehydrating full conversations.
Problem
Today downstream consumers have to read Polylogue internals or a local SQLite table directly when they need structured products. That creates several bad properties:
- consumers couple to current table names and column shapes;
- exports do not carry product schema/version metadata;
- date/provider/query bounds are not recorded as a reproducible contract;
- coverage gaps are invisible unless the consumer separately audits tables;
- non-conversation products such as work events, day summaries, project/file/tool rollups, and materialization status do not have a stable bundle shape.
Scope
Add a generic downstream export bundle capability for archive products.
Candidate command/API shape:
polylogue products export \
--since 2026-03-01 \
--until 2026-03-31 \
--provider codex --provider claude-code \
--product sessions --product work-events --product daily-rollups \
--format jsonl \
--out polylogue-products-2026-03.bundle/Bundle contents should be product-oriented, not Lynchpin-specific. A plausible initial bundle:
manifest.jsonwith archive id/fingerprint, generated_at, polylogue version, git revision if available, query/filter arguments, timezone, product list, and row counts;schemas/*.schema.jsonor equivalent schema/version descriptors for each exported product;products/session_profiles.jsonl;products/session_work_events.jsonl;products/daily_rollups.jsonlor similar date-bucketed summaries when available;coverage.jsondescribing product coverage by provider/date and any known stale/missing materialization;- optional
README.mdgenerated from manifest facts for human inspection.
Acceptance criteria
- A downstream consumer can export session and work-event products for a bounded query without reading Polylogue's SQLite schema directly.
- The bundle includes machine-readable schema/product versions and query provenance.
- The bundle includes coverage/readiness metadata, including stale or missing derived products.
- CLI, Python/facade, and MCP surfaces expose the same underlying export contract where practical.
- Tests cover at least one bounded export, schema metadata, and a missing/stale product case.
- The design stays generic: no Lynchpin-specific names, fields, or directory layout.
Non-goals
- Exporting full private transcripts by default.
- Replacing the existing rendered conversation export formats.
- Committing to a remote service or cloud sync model.
Execution-strengthened scope
Use the new product-readiness contract from #376 as the export bundle's coverage source. This should not be a CLI-only dump: define a reusable bundle request/result contract below CLI surfaces, then expose it through facade/operations and polylogue products export.
The first export format should be deliberately small but stable:
- an atomic directory bundle with
manifest.json,coverage.json,schemas/*.schema.json,products/*.jsonl, and a generatedREADME.md; - deterministic filenames derived from registered product ids, not consumer-specific names;
- query provenance in the manifest: selected products, provider/since/until bounds, generated timestamp, contract version, Polylogue version/git revision when available, and per-product row counts;
- embedded readiness metadata from
ProductReadinessReport, so consumers can reject stale/missing/legacy bundles without running a second command; - product schema descriptors generated from the Pydantic product models exposed through the product registry/query contract;
- initial support for registry-backed products whose query models can accept common bounds, with unsupported common bounds recorded in manifest warnings rather than silently misapplied;
- JSONL product payloads written with the same typed model serialization used by the CLI/API surfaces.
Treat MCP exposure as a follow-up adapter only if it would duplicate CLI plumbing in this slice. The durable requirement for this issue is that MCP/export surfaces can call the same operations/facade contract later without reimplementing bundle creation.
Additional acceptance criteria for this execution:
- Bundle writes are atomic: a failed export does not leave a half-valid target directory advertised as complete.
- Existing targets fail unless an explicit overwrite flag is provided.
- Tests cover successful bounded export, readiness metadata inclusion, schema descriptor output, stale/missing readiness propagation, and existing-target protection.
- Generated CLI/help/proof/showcase surfaces are refreshed for
products export.
Activity
Sinity commentedon Apr 23, 2026
Implementation log before PR:
polylogue/product_export_bundles.pyso facade/API/CLI can share one contract.Polylogue.export_product_bundle()andpolylogue products exportas thin adapters.ruff check ...passed,mypy ...passed,pytest -q tests/unit/core/test_product_export_bundles.py tests/unit/cli/test_products.pypassed with36 passed, anddevtools lab-scenario verify-baselinespassed after updating expected help baselines.feat: add product export bundles (#381)
feat: add product export bundles (#381)