Skip to content

fix(storage): converge duplicate session metadata migration 30 #3788

Description

@liugddx

Problem

Current main at 689a4515f15870d3c0ae9ee66c2f2021b34c0e2b has two entries for session metadata migration version 30 in packages/storage/src/sqlite-session-metadata-schema.ts:

MIGRATIONS is constructed as a JavaScript Map, so the later [30, ...] silently replaces the earlier one. A fresh database advances session_metadata_schema to version 30 after creating only the coordination index. The message-admission store then fails with no such table: message_admissions.

Reproduction

On current main after building @maka/core and @maka/storage:

node@24 --test --test-concurrency=1 \
  --test-name-pattern="materializes an accepted steering draft" \
  packages/storage/dist/__tests__/sqlite-session-metadata-store.test.js

Result:

Error: no such table: message_admissions

The complete session metadata file reports five failures in the admission/handoff/reorder tests. I reproduced the same failure after stashing an unrelated Windows-baseline branch and rebuilding pure upstream/main, so it is not introduced by that branch.

Merge interaction

Both PR heads could be green independently because each owned version 30 on its own base. The conflict is semantic rather than textual and appeared only after both merges.

Required compatibility

Simply renumbering the latest source entry is insufficient because version-30 databases may already exist in three shapes:

  1. feat: durable message lifecycle from admission to execution #3721 head: message-admission tables exist, coordination index absent;
  2. feat(workhub): add coordination session lifecycle #3764 head: coordination index exists, message-admission tables absent;
  3. current main: same as (2), with schema version recorded as 30.

Recommend bumping the current schema to 31 and making migration 31 converge every version-30 shape with guarded creation of both authorities. Add tests for all three starting shapes and a contract that prevents duplicate migration-version declarations from being silently collapsed by Map construction.

This is a current-main storage migration blocker, independent of #2624.

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