Skip to content

feat(storage): complete SQLite session metadata migration - #1373

Merged
likun666661 merged 1 commit into
apache:mainfrom
likun666661:agent/sqlite-session-metadata-compatibility
Jul 23, 2026
Merged

feat(storage): complete SQLite session metadata migration#1373
likun666661 merged 1 commit into
apache:mainfrom
likun666661:agent/sqlite-session-metadata-compatibility

Conversation

@likun666661

Copy link
Copy Markdown
Member

Part 3 of #1370.

Depends on #1372 (and transitively #1371). This is the final stacked draft; review and merge the stack in order.

What changes

  • Replaces the copied SessionHeader in new session.jsonl files with a versioned session_transcript marker containing only the session id.
  • Keeps old line-1 SessionHeader files readable and importable, while refusing orphan transcript markers that have no SQLite row or deletion tombstone.
  • Makes usage statistics resolve provider/model metadata from canonical sessions.sqlite, with legacy fallback only when the database does not exist.
  • Adds exportLegacySessionTree() for an atomic, non-destructive downgrade/export tree with canonical headers and untouched transcript bodies.
  • Adds a versioned session-metadata.json export manifest.
  • Adds online SQLite backup support through backupSessionMetadataDatabase() and the store backup API, with overwrite/source-path guards.
  • Exports the transcript marker and maintenance contracts from @maka/storage.

Compatibility and safety

  • Existing JSONL-header sessions continue to work and are imported once.
  • New marker-based sessions reopen without re-importing metadata.
  • Deleted sessions remain protected by SQLite tombstones.
  • Export is staged and atomically renamed; it refuses to overlap the live session tree or overwrite an existing destination.
  • Backup refuses to overwrite an existing file or target the live database.

Validation

  • npm test --workspace @maka/storage: 439 passed, 1 skipped
  • npm run build:test: passed across all workspaces and desktop bundles
  • npx biome check on all 11 changed files: passed
  • git diff --check: passed
  • npm run test:dist: scripts/core/storage/mcp passed; @maka/runtime retains the same 2 unrelated macOS sandbox/toolchain failures (hard-coded /usr/local executable-root expectation and Homebrew rg blocked from loading PCRE2). Runtime result: 2377 passed, 7 skipped, 2 failed.

Completes #1370 after the three-PR stack lands.

@likun666661

Copy link
Copy Markdown
Member Author

DeepSeek live E2E evidence (2026-07-23)

Ran one real deepseek-chat turn with the environment-provided DEEPSEEK_API_KEY; the key was neither printed nor persisted in the repository.

  • Model response: OK; stop reason: end_turn
  • Usage: 178 input tokens, 1 output token; estimated cost $0.00004916
  • New transcript first record: session_transcript marker with no copied metadata
  • Renamed session metadata, closed/reopened the store, and verified the canonical SQLite title persisted
  • Usage stats read 1 request from the marker-based session using SQLite metadata
  • Exported 1 legacy-compatible session and read it back through createLegacyFileSessionStore
  • Created an online SQLite backup (17 pages) and verified the restored metadata row

All live artifacts were written under a temporary /tmp workspace.

@likun666661
likun666661 force-pushed the agent/sqlite-session-metadata-compatibility branch from 76f4eec to d013bd2 Compare July 23, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant