Skip to content

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs

Comment 1, line 1

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:1

//! GitHub Copilot CLI helpers under the independent adapter-directory convention.

Comment 2, line 2

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:2

//! - Usage mapping moved from root usage_map.rs; V30 keeps product rules with the adapter.

Comment 3, line 3

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:3

//! - Read-only database helpers copied from adapters/goose/common.rs, following hermes/kilo.

Comment 4, line 4

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:4

//!

Comment 5, line 5

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:5

//! Field references: M0 m0-agent-fixtures.md and real local checks on 2026-09-29:

Comment 6, line 6

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:6

//! ~/.copilot/session-store.db schema_version=8; all 36 rows matched these rules.

Comment 7, line 7

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:7

//! - assistant_usage_events input_tokens = uncached + cache_read + cache_write.

Comment 8, line 8

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:8

//! Derive input_uncached by subtraction; output_tokens is reported. reasoning_tokens is

Comment 9, line 9

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:9

//! separate, with unverified output inclusion: retain it without adding it to output/totals.

Comment 10, line 10

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:10

//! - request_multiplier, observed as 27.0, is a premium multiplier rather than tokens.

Comment 11, line 11

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:11

//! - total_nano_aiu measures nano AIU, rather than tokens; exclude it from token statistics.

Comment 12, line 12

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:12

//! - created_at is ISO8601; duration_ms/time_to_first_token_ms are REAL milliseconds.

Comment 13, line 13

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:13

//! - M0 events.jsonl has no per-call tokens and is excluded; do not read conversation columns.

Comment 14, line 18

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:18

/// Five assistant_usage_events token fields; NULL remains unknown.

Comment 15, line 28

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:28

/// Verified input = uncached + cache read + cache write; derive uncached by subtraction.

Comment 16, line 37

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:37

// Both cache buckets may reach MAX_TOKEN_VALUE; overflow stops derivation and is diagnosed.

Comment 17, line 38

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:38

// Do not pass distorted saturating sums into later calculations.

Comment 18, line 75

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:75

// Reasoning/output inclusion is unverified; report separately without adding reasoning to totals.

Comment 19, line 110

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:110

// Independent read-only database helpers copied from adapters/hermes/common.rs.

Comment 20, line 118

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:118

/// Read-only source access; busy-like probe failures switch to a staging snapshot.

Comment 21, line 142

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:142

/// SQLite busy/locked/CANTOPEN errors prevent a successful consistency probe.

Comment 22, line 152

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:152

/// Staging page/time/size limits and cleanup follow architecture.md.

Comment 23, line 170

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:170

/// Open read-only; short busy_timeout bounds probe waits before a staging fallback.

Comment 24, line 183

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:183

/// Online Backup creates a consistent system-temp snapshot without writing the source.

Comment 25, line 214

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:214

// More means pages were copied; count those pages toward the size limit.

Comment 26, line 225

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:225

// Busy/Locked or other non-exhaustive results retry without progress, within the timeout.

Comment 27, line 226

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:226

// 2026-09-30 fix: retries previously added pages and raced the timeout, causing

Comment 28, line 227

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:227

// platform-specific false size-limit failures (Linux CI hit the page cap before timeout).

Comment 29, line 246

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:246

/// Read the source database directly; busy-like probe failures try staging, other errors propagate.

Comment 30, line 247

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:247

/// Never write the source database.

Comment 31, line 274

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:274

/// Short sqlite_master count probe, following kilo; it creates no explicit transaction.

Comment 32, line 279

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:279

/// Required usage-event columns; thread metadata is not this table's schema.

Comment 33, line 280

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:280

/// assistant_usage_events columns verified against local schema 8 and M0 1.0.73.

Comment 34, line 296

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:296

/// Read schema_version.version into a registry format string; local sample reports 8.

Comment 35, line 297

desktop/src-tauri/crates/core/src/adapters/copilot/common.rs:297

/// Shared by detection/scanning: missing table or failed query returns None for LatestFallback.