Skip to content

refactor(storage): single-source archive FTS schema DDL #626

Closed as not planned

Description

@Sinity

Problem

Archive/action FTS DDL is duplicated between schema creation and lifecycle repair code.

Evidence:

  • polylogue/storage/backends/schema_ddl_archive.py:258-285 declares the messages_fts table and its insert/delete/update triggers for fresh schema creation.
  • polylogue/storage/backends/schema_ddl_actions.py:48-82 declares the action_events_fts table and triggers.
  • polylogue/storage/fts/sql.py:9-18 separately declares the same FTS virtual tables for lifecycle helpers.
  • polylogue/storage/fts/fts_lifecycle.py:119-156 separately declares the same message/action FTS trigger DDL, with a comment saying it “must match” the schema files.

This creates a manual sync contract for some of the most sensitive storage machinery. It is directly adjacent to #619: sync ingest drops and restores these triggers, so a future trigger/schema edit must be propagated to both fresh schema and restore paths or bulk ingest will restore an old trigger definition.

Acceptance criteria

  • Define message/action FTS table and trigger DDL in one module, then import/reuse it from fresh schema creation and FTS lifecycle repair.
  • Remove the “must match” duplicate trigger literals from fts_lifecycle.py.
  • Add a test that fresh schema creation and lifecycle restoration use the same trigger names/SQL source, or otherwise fail if they drift.
  • Keep product-specific FTS DDL out of scope unless the same duplication is found there.

Ref #578
Ref #619

Activity

  1. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Superseded by #618. 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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions