Skip to content

feat: add versioned product export bundles for downstream consumers #375

Closed

Description

@Sinity

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.json with archive id/fingerprint, generated_at, polylogue version, git revision if available, query/filter arguments, timezone, product list, and row counts;
  • schemas/*.schema.json or equivalent schema/version descriptors for each exported product;
  • products/session_profiles.jsonl;
  • products/session_work_events.jsonl;
  • products/daily_rollups.jsonl or similar date-bucketed summaries when available;
  • coverage.json describing product coverage by provider/date and any known stale/missing materialization;
  • optional README.md generated 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 generated README.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

  1. Sinity commented on Apr 23, 2026

    @Sinity
    OwnerAuthor

    Implementation log before PR:

    • Strengthened this issue from a simple export command into a versioned product-bundle contract: manifest, coverage, schemas, JSONL product payloads, README, provenance, readiness metadata, and atomic publication.
    • Implemented the bundle writer below CLI surfaces in polylogue/product_export_bundles.py so facade/API/CLI can share one contract.
    • Wired Polylogue.export_product_bundle() and polylogue products export as thin adapters.
    • Export uses the product registry for supported product ids and records per-product warnings when common bounds are not supported.
    • Degraded readiness is intentional output: stale or unavailable products write an empty JSONL plus manifest errors and coverage metadata, rather than failing the whole bundle after partial writes.
    • Current focused verification: ruff check ... passed, mypy ... passed, pytest -q tests/unit/core/test_product_export_bundles.py tests/unit/cli/test_products.py passed with 36 passed, and devtools lab-scenario verify-baselines passed after updating expected help baselines.
  2. added a commit that references this issue on Apr 23, 2026
    f95bf9f
  3. added a commit that references this issue on May 7, 2026
    8f53991
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions