Skip to content

feat(reader): identity-preserving marks and annotations across reimport #1114

Closed

Description

@Sinity

Problem

#867 AC includes "User metadata survives reimport where identity evidence is available." The current substrate has two parallel systems:

  • conversation_user_metadata (keyed by identity_key in polylogue/storage/sqlite/schema_ddl_identity.py) — tags/summaries survive soft-delete + reimport.
  • user_marks / user_annotations (keyed by conversation_id in polylogue/storage/sqlite/schema_ddl_archive.py, with ON DELETE CASCADE) — die when the conversation row is replaced.

This means marks/annotations are lost on reset-then-reimport, which violates the AC.

Scope

Choose one of:

  1. Migrate marks/annotations to identity-key-keyed storage (analogous to conversation_user_metadata) so identity-ledger lookup resolves them back to the current conversation_id at query time.
  2. Hook the reset/reimport path so it walks identity_ledger and rewrites mark/annotation conversation_id / message_id after the new conv lands.

Option 1 is structurally cleaner; option 2 is less invasive. Pick during design.

Files likely touched

  • polylogue/storage/sqlite/schema_ddl_archive.py (DDL change → SCHEMA_VERSION bump)
  • polylogue/storage/sqlite/schema_ddl_identity.py (or merge)
  • polylogue/storage/repository/archive/repository_writes.py (write contracts)
  • polylogue/operations/mutations.py (read/write paths)
  • polylogue/storage/sqlite/queries/conversations_identity.py (preservation logic)
  • migration tooling (fresh-first per docs/internals.md schema-versioning model)

Verification

  • Integration test: ingest → mark → reset --keep-user-state → reingest → assert mark visible.
  • Same for annotations.
  • Same for message-target marks (must resolve to new message_id via identity evidence).
  • Content-hash exclusion regression test.

Dependencies

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