desktop/src-tauri/crates/core/src/adapters/opencode/common.rs
Comment 1, line 1
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:1
//! OpenCode-specific helpers; independent layout: architecture.md#adapter-layout.Comment 2, line 2
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:2
//! - Schema fingerprint requires five session tokens_* totals, absent from the referenced MiMo schema.Comment 3, line 3
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:3
//! - Read-only state database access with Online Backup staging snapshots:Comment 4, line 4
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:4
//! helpers copied from `adapters/kilo/common.rs`; each Agent keeps its own module.Comment 5, line 5
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:5
//! The Kilo helper originated in the checked M3 implementation; prefixes/comments differ.Comment 6, line 6
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:6
//!Comment 7, line 7
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:7
//! Fixed source: A17, commit 0027387dc5c59793c12dfc531abc78f825ed6868.Comment 8, line 8
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:8
//! - packages/core/src/global.ts: data uses the xdg-basedir opencode directory;Comment 9, line 9
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:9
//! absent $XDG_DATA_HOME defaults to ~/.local/share/opencode.Comment 10, line 10
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:10
//! - packages/core/src/database/database.ts defines the database path:Comment 11, line 11
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:11
//! data/opencode.db, or channel variant opencode-<channel>.db;Comment 12, line 12
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:12
//! normalize channel with [^a-zA-Z0-9._-]; database uses WAL.Comment 13, line 13
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:13
//! - packages/core/src/session/sql.ts: session includes parent_id/version and fiveComment 14, line 14
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:14
//! cumulative tokens_input/output/reasoning/cache_read/cache_write columns;Comment 15, line 15
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:15
//! message has id/session_id/data JSON; part has id/message_id/session_id/Comment 16, line 16
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:16
//! time_created/time_updated/data JSON. Use literal columns from these three tables.Comment 17, line 24
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:24
// Read-only database helpers copied from adapters/kilo/common.rs; modules remain independent.Comment 18, line 26
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:26
/// Read-only source access; busy-like probe failures switch to a staging snapshot.Comment 19, line 27
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:27
/// The staging guard owns its path and cleans up on drop, including query failures.Comment 20, line 51
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:51
/// SQLite busy/locked/CANTOPEN errors prevent a successful consistency probe.Comment 21, line 61
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:61
/// Staging page/time/size limits and cleanup follow architecture.md.Comment 22, line 79
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:79
/// Open read-only; short busy_timeout bounds probe waits before a staging fallback.Comment 23, line 92
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:92
/// Online Backup creates a consistent system-temporary snapshot without writing the source.Comment 24, line 123
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:123
// More means pages were copied; count those pages toward the size limit.Comment 25, line 134
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:134
// Busy/Locked or other non-exhaustive results retry without progress, within the timeout.Comment 26, line 135
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:135
// 2026-09-30 fix: retries previously added pages and raced the timeout, causingComment 27, line 136
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:136
// platform-specific false size-limit failures (Linux CI hit the page cap before timeout).Comment 28, line 155
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:155
/// Probe read-only opencode.db; busy-like probe failures use staging, later failures propagate.Comment 29, line 156
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:156
/// Never write the source or invoke upstream open paths that could initialize/migrate it.Comment 30, line 183
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:183
/// Short schema query probes access, following kilo's rule.Comment 31, line 188
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:188
// Schema fingerprint uses fixed sql.ts table/column names only, safe to persist.Comment 32, line 190
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:190
/// Required per-call part columns use literal sql.ts PartTable names.Comment 33, line 199
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:199
/// Session identity/parent/version and five cumulative columns support reconciliation.Comment 34, line 200
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:200
/// The referenced MiMo schema lacks these five columns and cannot match this fingerprint.Comment 35, line 211
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:211
/// Required message columns join model ownership from message.data.$.modelID/providerID.Comment 36, line 214
desktop/src-tauri/crates/core/src/adapters/opencode/common.rs:214
/// Return schema fingerprint, or None for absent tables/required columns.