Commit Graph

5 Commits

Author SHA1 Message Date
yoniebans
0edf4be2b3 refactor(state): the backend and the backup share one zeroed-file detector in sqlite_support
The removal gave the backend's dbfile module its own copy of hermes_cli.backup.is_zeroed_sqlite_file, because the backend does not import hermes_cli.backup, and the test that kept the copy equal to backup's went with the old store's parity tests. So the detector existed twice, plus the header probe is_zeroed_state_db falls back on, and a fix to the live-connection guard or the header test had to land in both copies. The function now lives once in sqlite_support, the neutral SQLite helper module both sides already import, moved from hermes_cli/backup.py unchanged; backup.py and the backend import it from there, and the backend's copy goes. is_zeroed_state_db keeps main's fallback probe for the case where the detector raises.

The new case checks that the backend, the backup and sqlite_support name the same function; it fails before this commit. Greptile raised the duplicate in review.
2026-11-17 19:10:58 +01:00
yoniebans
be3d6affc8 refactor(state)!: remove the old session store
hermes_state.py becomes the stand-in plugins import, the rest of the legacy store and its test folder go, and the per-process modules the backend imported from main move under persistence/sqlite/_state/. The backend checks PID namespaces and lease holders through process_identity and its WAL setup through sqlite_support, and its error module takes the shared predicates and classification from storage_errors, so neither helper set has a second copy. The backend, sqlite_support.py and the tests that pin those modules reach their final imports, and the backend-import guard allows no file outside persistence/. The modules no caller imports any more go with it: the agent's onboarding rules (now in session_rules) and gateway/session_admission.py.

The stand-in's SessionDB releases its store on close() and, used again afterwards, opens it again with a warning, as the old class reopened its connection, unless the file at its path was replaced or the store is latched corrupt; a read-only one raises. A close during a call releases the store when the call returns. A named source wins over a source list in its session listing and count.

An agent given a writable stand-in SessionDB as session_db= and no persistence= takes the store handle that SessionDB forwards to as its persistence, so its turn flush, token counts, compression and session row writes go through the storage interface, as an agent given the old SessionDB wrote through it.

The backend-import guard also holds the backend's remaining reads of the process or task home, each with its reason, and refuses any other and any import of the stand-in inside persistence/sqlite/.

Plugin context engines get the agent's store as persistence= beside the deprecated session_db=, in each hook whose signature accepts that keyword, including the rebind after /new, /resume and /branch, and the context engine guide and the plugin guide's replacement table name it. A test fails once the running release reaches the stand-in's removal release, listing what goes with the stand-in.

release_unheld_media and collect_unheld_api_images take a store only: their SessionDB branches, which no caller reaches, go with the gateway's own copies of the admission and transcript queries.
2026-11-17 19:10:57 +01:00
yoniebans
3d442b65a8 fix(sqlite_support): apply_database_pragmas is importable from sqlite_support, as the published plugin API lists it
The published plugin API and the plugin guide name sqlite_support.apply_database_pragmas, but at this level the function still lives in hermes_state_wal, so a plugin following the guide failed to import it and main's published-API conformance case failed. sqlite_support now has the name, forwarding to hermes_state_wal's function until the old store's removal moves the function itself into sqlite_support.
2026-11-17 17:51:23 +01:00
yoniebans
ac7459e9b3 fix(sqlite_support): carry the network-filesystem journal-mode policy
A new store on an nfs/cifs/smb/sshfs mount starts in DELETE unless database.journal_mode is set explicitly, with one WARNING naming the override; an existing WAL store there keeps WAL (never live-downgraded) and gets one WARNING with the offline remedy, on both already-WAL paths. Stores opening through sqlite_support.open_db, including the hosted-room shared-state.db, follow the same policy as hermes_state_wal.

Tests: tests/persistence_sqlite/core/test_sqlite_support_network_fs.py and test_sqlite_support_network_fs_store_coverage.py.
2026-11-17 17:49:49 +01:00
yoniebans
b728cd3c19 feat(storage): SQLite helpers and storage error classification as neutral modules
sqlite_support.py holds the SQLite helpers the backend shares with the other SQLite stores: the connection open with its journal-mode policy, column migration, file permissions, the writability preflight, durability barriers and the diagnostics printed about SQLite builds, filesystems and lock holders. storage_errors.py classifies storage failures, and storage_user_copy.py holds the plain-language notices shown when session storage is unavailable or could not be written.
2026-11-17 17:49:46 +01:00