Skip to content

refactor: describe schema bootstrap extensions declaratively #325

Closed

Description

@Sinity

Context

The low-churn audit in #315 found that polylogue/storage/backends/schema_bootstrap.py imperatively appends many column, index, and FTS extension operations. The repository uses fresh-current schema semantics, but bootstrap extension planning still repeats facts that also live in schema DDL.

This is not urgent correctness debt, but it is a drift risk around a high-blast-radius boundary.

Scope

Replace repeated imperative extension planning with declarative schema extension descriptors where practical.

Candidate descriptor facts:

  • table name
  • required columns and column DDL
  • required indexes
  • FTS table/trigger requirements
  • optional backfill/update statements

Acceptance criteria

  • Common column/index/FTS extension checks are represented declaratively.
  • Existing bootstrap behavior remains compatible for current-version databases.
  • Schema tests cover descriptor expansion and missing-object detection.
  • The design keeps raw DDL reviewable; do not hide schema facts behind opaque generation.
  • devtools verify passes before PR merge.

Ref #315

Activity

  1. added
    type:refactor
    on Apr 21, 2026
  2. Sinity commented on Apr 23, 2026

    @Sinity
    OwnerAuthor

    Starting implementation on feature/refactor/schema-bootstrap-descriptors.

    Tactic:

    • Keep the descriptor catalog close to polylogue/storage/backends/schema_bootstrap.py for this slice, rather than introducing a repo-wide schema DSL.
    • Split descriptor kinds by behavior: columns, indexes, scripts, and backfills.
    • Let snapshot capture derive the tables/indexes it needs from the descriptor catalog, so detection state cannot drift from planning state.
    • Preserve current bootstrap behavior for current-version databases, including legacy raw table rejection and the raw source-mtime index replacement path.

    Verification target before PR: focused schema/storage tests plus devtools verify if the local changes stay broad enough to warrant the full gate.

  3. Sinity commented on Apr 23, 2026

    @Sinity
    OwnerAuthor

    Implementation checkpoint on feature/refactor/schema-bootstrap-descriptors.

    What changed locally:

    • Added typed schema extension descriptors for columns, indexes, scripts, and backfills in polylogue/storage/backends/schema_bootstrap.py.
    • Reworked build_current_schema_extension_plan() to expand the ordered descriptor catalog instead of maintaining repeated imperative conditionals.
    • Made capture_schema_snapshot() and capture_schema_snapshot_async() derive inspected tables/indexes from the descriptor catalog.
    • Added focused backend tests for descriptor expansion, catalog snapshot scope, and catalog-to-plan expansion.

    Verification so far:

    • ruff check polylogue/storage/backends/schema_bootstrap.py tests/unit/storage/test_backend.py
    • pytest -q tests/unit/storage/test_backend.py -k 'schema' → 9 passed
    • mypy polylogue/storage/backends/schema_bootstrap.py → no issues
    • pytest -q tests/unit/storage/test_backend.py tests/unit/storage/test_parse_tracking.py → 57 passed
    • devtools render-all --check → all generated surfaces in sync

    Next: run the full local devtools verify, then commit/open PR if it stays clean.

  4. Sinity commented on Apr 23, 2026

    @Sinity
    OwnerAuthor

    Closed via PR #372, merged as cbee9706e3c23dfddbf438b1c98546e042882ddc.

    Final implementation:

    • Schema extension planning now uses typed descriptors for columns, indexes, scripts, and backfills.
    • Sync and async schema snapshots now derive inspected table/index names from the descriptor catalog.
    • Existing raw source-mtime index replacement behavior is preserved through an index descriptor with drift repair enabled.
    • Backend tests cover descriptor idempotence, catalog-driven snapshot scope, and catalog-to-plan expansion.

    Final verification before merge:

    • mypy polylogue/storage/backends/schema_bootstrap.py → no issues
    • pytest -q tests/unit/storage/test_backend.py tests/unit/storage/test_parse_tracking.py → 57 passed
    • devtools render-all --check → generated surfaces in sync
    • devtools verify → all checks passed
    • pre-push devtools verify --quick → all checks passed

    GitHub CI was left pending per the quota caveat; local verification was clean.

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:schemaarea:storagetype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions