AstrBot-Desktop/docs/spikes/P00-06-sqlite-profile-isolation.md
YokiiroBW 353a439b41
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
docs(p00): record spike results and unresolved boundaries
2026-07-18 21:00:49 +08:00

2.9 KiB

P00-06: SQLite Profile Isolation

  • Status: Passed on a disposable SQLite database
  • Date recorded: 2026-07-18
  • MVP gate: Required before persistent dual-instance data

Objective

Verify schema and repository isolation for multiple saved profiles and two active slots, including collisions in server, conversation, message, cursor, proposal, and transaction identifiers.

Environment

  • SQLite implementation: rusqlite 0.40.1 with bundled SQLite
  • Rust toolchain: rustc/cargo 1.97.1
  • Migration execution: transactional disposable fixture
  • Persistent user database: not created

Minimal validation implementation

The Spike is expected to use a disposable database and transactional migrations. Server-derived tables must include profile_id and server_instance_id. Conversation and message keys must remain unique within their profile and server context.

Credential values must never be stored; only opaque credential references are permitted.

Required execution

  1. Create at least five profiles with only two active slots.
  2. Store identical conversation_id and message_id values for two different profiles.
  3. Store independent SSE cursors, unread counts, errors, proposals, and transaction summaries.
  4. Query each profile and verify no cross-profile result.
  5. Verify a duplicate within the same composite key is rejected or deterministically updated.
  6. Verify credential values are absent from all tables.
  7. Interrupt a transaction and confirm rollback or recovery.
  8. Reopen the database and repeat isolation checks.

Actual execution result

Passed. Tests created multiple saved profiles with only companion and operations active slots, inserted intentionally colliding server/conversation/message identifiers under different composite profile keys, and verified independent reads.

Tests also covered separate SSE cursors, unread/error state, proposals and file-transaction summaries, duplicate composite-key behavior, transaction rollback, reopen/requery behavior, and schema inspection confirming that credential values are absent.

All database files were disposable test fixtures; no migration touched user data.

Log summary

Command: cargo test --workspace. Result: passed, including SQLite migration and isolation tests. Logs contained test status only and no stored content values.

Known limitations

  • Migration backup and recovery behavior remain unverified.
  • WAL behavior on abrupt process termination remains unverified.
  • Encryption at rest is not provided by ordinary SQLite and does not replace Credential Manager.

Security impact

Incorrect composite keys can mix conversations or local-tool state between companion and operations profiles. Storing credential values would violate the security model.

Recommendation

Use transactional migrations, foreign keys, explicit composite uniqueness, and a disposable database for isolation tests. Any migration with potential data loss requires a separate stop-and-review decision.