Skip to content

refactor(parser): unify ChatGPT typed models and parser extraction #597

Closed as not planned

Description

@Sinity

Problem

ChatGPT ingestion currently has two semantic extraction implementations that can drift.

Evidence from current master:

  • polylogue/sources/providers/chatgpt_conversation_models.py defines ChatGPTConversation.messages, which finds a root node and follows only children[0].
  • polylogue/sources/parsers/chatgpt.py defines extract_messages_from_mapping(), which iterates raw mapping values, emits every text+role message, computes branch_index from the parent children array, extracts attachments/content blocks/provider metadata, and sorts by timestamp when available.
  • Production parsing uses the raw-dict parser path. The typed ChatGPT conversation/message models are exercised by tests and unified semantic adapters, but they are not the production ingestion authority.

For branched ChatGPT exports, those two paths answer different questions: the typed model exposes one primary branch, while the parser preserves all parseable mapping entries with branch metadata. Tests can validate the typed path while ingestion uses different semantics.

Acceptance criteria

  • Pick one canonical ChatGPT extraction path for ingestion semantics.
  • Either make the typed ChatGPT model the parser's semantic helper, or remove/demote typed traversal helpers that are not production-canonical.
  • Add a branched ChatGPT fixture where at least one node has multiple children.
  • Assert the intended typed projection and production parsed projection agree on message inclusion, ordering, parent references, branch indexes, content blocks, and attachments.
  • Keep unified schema adapters aligned with the same canonical behavior.
  • Run the focused ChatGPT parser/model tests plus devtools verify --quick.

Notes

Found during the wide duplication/source-organization audit recorded in .agent/scratch/574-duplication-organization-audit.md.

Activity

  1. added
    type:refactor
    on May 1, 2026
  2. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Superseded by #623. I consolidated this finding into the composite issue so the work can be handled as one coherent slice instead of as a tiny standalone ticket. The original evidence remains available in this issue history.

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

    area:parsertool:codextype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions