refactor(state): one read-only URI builder; probe a held store via snapshot only
read_only_db_uri() replaces four inline mode=ro URI sites (two of which still used the raw f-string that truncates on ?/# in the home path: state_db_has_structural_damage and collect_state_db_stats). The doctor write probe now applies the live-holder gate in both modes: a quiet store is probed in place as on main, a held store is probed through a read-only snapshot, and a held store over 1 GB is skipped with an info line unless --fix is given (the unconditional copy cost one full DB write per plain doctor run). Connect/backup failures propagate to the existing classification instead of being reported as FTS write-health failures. Observational sessions commands print a migration hint instead of a raw traceback when a read-only opener meets an older schema. Co-authored-by: Ahmett101 <Ahmett101@users.noreply.github.com>
This commit is contained in:
@@ -23,6 +23,7 @@ from typing import Any, Dict, List, Optional, Tuple
|
||||
from hermes_constants import get_hermes_home
|
||||
from hermes_startup_watchdog import report_startup_progress
|
||||
from hermes_state_common import (
|
||||
read_only_db_uri,
|
||||
_acquire_db_flock, _clear_lock_holder_record, _describe_lock_holder, _read_lock_holder_record,
|
||||
is_advisory_lock_contention,
|
||||
)
|
||||
@@ -727,7 +728,7 @@ def state_db_has_structural_damage(db_path: Path) -> bool:
|
||||
while ``messages``/``sessions`` read cleanly, and the FTS rebuild ladder cannot help.
|
||||
Cannot-open / locked stays False so the caller keeps the FTS path."""
|
||||
try:
|
||||
conn = sqlite3.connect(f"file:{db_path}?mode=ro", uri=True, timeout=1.0)
|
||||
conn = sqlite3.connect(read_only_db_uri(db_path), uri=True, timeout=1.0)
|
||||
except sqlite3.Error:
|
||||
return False
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user