desktop/src-tauri/crates/core/src/adapters/hermes/common.rs
Comment 1, line 1
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:1
//! Hermes Agent helpers; independent layout: architecture.md#adapter-layout.Comment 2, line 2
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:2
//! - map_hermes/HermesUsage uses fixed source column definitions below.Comment 3, line 3
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:3
//! - Normalize billing_base_url in memory to a credential-free provider ID or local digest.Comment 4, line 4
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:4
//! - Read-only state.db access uses direct connections and Online Backup staging:Comment 5, line 5
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:5
//! helpers copied from adapters/kilo/common.rs, keeping independent Agent modules.Comment 6, line 6
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:6
//! Kilo was accepted in M3; shared access semantics retain product-specific prefixes/comments.Comment 7, line 7
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:7
//!Comment 8, line 8
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:8
//! Fixed A24 source: ef70b3661cbfcf57e583008ad91dd04d8ba46070.Comment 9, line 9
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:9
//! - hermes_state_common.py SCHEMA_SQL defines 18 session_model_usage columns, withComment 10, line 10
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:10
//! PRIMARY KEY (session_id, model, billing_provider, billing_base_url,Comment 11, line 11
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:11
//! billing_mode, task). sessions includes id/source/parent_session_id/started_at/Comment 12, line 12
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:12
//! ended_at/end_reason and five cumulative buckets; read only required fallback-time columns.Comment 13, line 13
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:13
//! - hermes_state_usage.py adds counters by compound key on the incremental path.Comment 14, line 14
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:14
//! absolute updates sessions totals without model rows. record_auxiliary_usage writesComment 15, line 15
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:15
//! task rows rather than main totals; first_seen is insert-only and last_seen advancesComment 16, line 16
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:16
//! on conflict updates.Comment 17, line 17
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:17
//! - hermes_constants.py get_hermes_home uses context override, HERMES_HOME, thenComment 18, line 18
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:18
//! platform default: Windows %LOCALAPPDATA%/hermes, otherwise ~/.hermes.Comment 19, line 19
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:19
//! Named profiles have independent state.db at <root>/profiles/<name>.Comment 20, line 20
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:20
//!Comment 21, line 21
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:21
//! first_seen/last_seen/started_at/ended_at are REAL Unix seconds from PythonComment 22, line 22
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:22
//! time.time(); convert to milliseconds. A24 and fixed 0.21.5 normalize_usage establishComment 23, line 23
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:23
//! uncached input_tokens and reasoning as an output subset.Comment 24, line 24
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:24
//! Real request/resume checks passed; initialization/missing fields become zero and remain unknown.Comment 25, line 34
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:34
/// Five native session_model_usage counters: i64, NOT NULL DEFAULT 0.Comment 26, line 44
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:44
/// Positive normalized native buckets are reported; default zeros cannot establish field presence.Comment 27, line 45
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:45
/// Derive input/complete totals only with all required buckets known, without default-zero completion.Comment 28, line 83
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:83
/// REAL epoch seconds to UTC milliseconds; reject nonfinite/pre-2000 values to avoid unit mistakes.Comment 29, line 96
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:96
/// Normalize billing_base_url only in memory, under the Hermes adapter rules:Comment 30, line 97
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:97
/// retain a credential-free provider identifier/local digest, never full URLs or query parameters.Comment 31, line 98
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:98
/// URL-like values become scheme/host[:port], stripping userinfo/path/query/fragment.Comment 32, line 99
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:99
/// Other values become a local FNV-1a digest via identity::content_hash, without retaining raw text.Comment 33, line 107
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:107
// Strip user:pass@host userinfo by taking the host segment after the final @.Comment 34, line 123
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:123
// Independent read-only database helpers copied from adapters/kilo/common.rs.Comment 35, line 125
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:125
/// Read-only source access; busy-like probe failures switch to a staging snapshot.Comment 36, line 126
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:126
/// _staging owns the snapshot guard; drop cleans up even after query failure.Comment 37, line 150
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:150
/// SQLite busy/locked/CANTOPEN errors prevent a successful consistency probe.Comment 38, line 160
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:160
/// Staging page/time/size limits and cleanup follow architecture.md.Comment 39, line 178
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:178
/// Open read-only; short busy_timeout bounds probe waits before a staging fallback.Comment 40, line 191
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:191
/// Online Backup creates a consistent system-temp snapshot without writing the source.Comment 41, line 222
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:222
// More means pages were copied; count those pages toward the size limit.Comment 42, line 233
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:233
// Busy/Locked or other non-exhaustive results retry without progress, within the timeout.Comment 43, line 234
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:234
// 2026-09-30 fix: retries previously added pages and raced the timeout, causingComment 44, line 235
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:235
// platform-specific false size-limit failures (Linux CI hit the page cap before timeout).Comment 45, line 254
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:254
/// Read state.db directly; busy-like probe failures try staging, other errors propagate.Comment 46, line 255
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:255
/// Never write the source or invoke upstream initialization that may migrate/repair it.Comment 47, line 282
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:282
/// Short sqlite_master count probe, following kilo; it creates no explicit transaction.Comment 48, line 287
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:287
// Schema fingerprints contain fixed DDL table/column names, rather than source records.Comment 49, line 289
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:289
/// Required sessions identity/time-fallback columns; fixed source defines the full table.Comment 50, line 291
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:291
/// All 18 session_model_usage columns, using exact SCHEMA_SQL names.Comment 51, line 312
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:312
/// Expected compound-key columns; v22 migration adds task to the primary key.Comment 52, line 323
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:323
/// None indicates missing tables/required columns or an unmatched primary-key shape.Comment 53, line 325
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:325
/// True when required columns exist but one or more expected key columns are absent from the PK.Comment 54, line 329
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:329
/// Compute schema fingerprint and primary-key classification from actual columns/keys,Comment 55, line 330
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:330
/// rather than relying on a version integer.Comment 56, line 375
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:375
// All six SMU_KEY_COLUMNS must participate in the v22 primary key.Comment 57, line 397
desktop/src-tauri/crates/core/src/adapters/hermes/common.rs:397
/// Read maximum schema_version (fixed source SCHEMA_VERSION=30); SQL/type errors propagate.