Skip to content

fix(ingest): reconcile manifest-only zero-message conversations #945

Closed

Description

@Sinity

Problem

An external archive audit found 362 of 11,067 sessions (3.3%) with message_count=0, work_event_count=0, and substantive_count=0. Example titles look like conversations-001-37.

That shape is consistent with bulk-import manifest registration creating conversation IDs before message ingestion completed, leaving manifest-only conversation rows in the archive. This is a Polylogue ingest/reconciliation defect, not a Lynchpin downstream cleanup.

Split from #944 because it is a self-contained ingest data-integrity concern.

Scope

  • Add a reproducible detector/query for manifest-only conversation rows.
  • Trace the ingest path that can register a conversation before messages are materialized.
  • Prevent new manifest-only rows from being created silently.
  • Add a repair or classification path for existing rows: delete, repair, or explicitly mark as intentional non-conversation artifacts.

Acceptance Criteria

  • A focused test reproduces bulk-import manifest registration without message ingestion and proves it does not leave an ordinary zero-message conversation row.
  • Existing archive rows with message_count=0, work_event_count=0, and substantive_count=0 are detectable through a documented check or repair surface.
  • The repair/classification path is idempotent and does not delete legitimate raw artifacts.
  • The closing PR records the archive query used to verify the 362-row class.

Verification

Run focused ingest/reconciliation tests plus the relevant local gate:

pytest -q tests/unit/pipeline tests/unit/storage
devtools verify --quick

Ref #944

Activity

  1. Sinity commented on May 8, 2026

    @Sinity
    OwnerAuthor

    Closing: manifest-only zero-message conversation guard landed.

    Changes:

    • _write_conversation in ingest_batch/_core.py now skips new conversations with zero messages (the guard only blocks new rows, not updates to existing ones)
    • The detector (count_empty_conversations_sync) and repair (repair_empty_conversations) already exist in storage/repair.py, wired through polylogue doctor --repair
    • Two focused tests: new-with-zero-messages skipped, existing-with-zero-messages allowed

    Archive query counting the affected class:

    SELECT COUNT(*) FROM conversations c
    LEFT JOIN messages m ON m.conversation_id = c.conversation_id
    WHERE m.conversation_id IS NULL;

    This returns the count of conversations with no messages — the manifest-only rows that the guard now prevents.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions