Skip to content

fix(state): refuse WAL on SQLite builds with the WAL-reset bug - #69981

Closed
HexLab98 wants to merge 2 commits into
NousResearch:mainfrom
HexLab98:fix/69784-sqlite-wal-reset-gate
Closed

fix(state): refuse WAL on SQLite builds with the WAL-reset bug#69981
HexLab98 wants to merge 2 commits into
NousResearch:mainfrom
HexLab98:fix/69784-sqlite-wal-reset-gate

Conversation

@HexLab98

@HexLab98 HexLab98 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • On SQLite builds still affected by the upstream WAL-reset bug (e.g. uv-managed 3.50.4), refuse to enable WAL for fresh / non-WAL shared databases and use journal_mode=DELETE instead.
  • Leave existing on-disk WAL databases alone — no live TRUNCATE/mode flip under concurrent gateway/cron/worker openers (same safety rule as the NFS WAL path).
  • Route other production WAL openers through apply_wal_with_fallback so they cannot re-enable WAL on a vulnerable build.
  • hermes doctor reports Python + SQLite version/source id as a warn-only note (not a blocking issues entry); packaging a fixed SQLite runtime remains a separate install decision.
  • Fixes [Bug]: Bundled SQLite 3.50.4 hits upstream WAL-reset corruption; clean on 3.51.3 #69784 (application-side gate; does not replace shipping SQLite ≥ 3.51.3 / 3.50.7).

Test plan

  • Reproduced on upstream/main: vulnerable SQLite still got WAL via apply_wal_with_fallback.
  • After fix: fresh DB → delete; already-WAL → stays wal (no checkpoint/DELETE pragmas); fixed SQLite → wal.
  • scripts/run_tests.sh tests/test_sqlite_wal_reset_gate.py tests/test_hermes_state_wal_fallback.py
  • scripts/run_tests.sh tests/test_hermes_state.py -k 'TestApplyWalProbe or test_wal_mode'
  • Manual: hermes doctor on 3.50.4 shows SQLite warn + source id without listing it under blocking issues.

Infographic

Hermes SQLite WAL-reset gate

HexLab98 added 2 commits July 23, 2026 15:48
On vulnerable SQLite (e.g. 3.50.4), do not enable WAL for fresh/non-WAL
shared databases — prefer DELETE instead. Leave existing on-disk WAL
alone (no live downgrade under concurrent gateway/cron openers). Surface
Python/SQLite version details as a doctor warning (NousResearch#69784).
Assert the version matrix, fresh-DB DELETE fallback, already-WAL left
alone (no checkpoint/DELETE), fixed-SQLite WAL path, and warn-only
doctor output for vulnerable builds (NousResearch#69784).
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins platform/discord Discord bot adapter area/install-update Installer, updater, packaging, wheels, doctor sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 23, 2026
@HexLab98
HexLab98 force-pushed the fix/69784-sqlite-wal-reset-gate branch from e177d89 to 1adb18b Compare July 23, 2026 08:48
@HexLab98 HexLab98 changed the title fix(state): gate WAL on SQLite builds with the WAL-reset bug fix(state): refuse WAL on SQLite builds with the WAL-reset bug Jul 23, 2026
kshitijk4poor pushed a commit to kshitijk4poor/hermes-agent that referenced this pull request Jul 23, 2026
Hoist the duplicated check_info(source_id) call out of both
if/else branches into a single call after the branch. Remove
trailing whitespace on the blank line after the except block.

Follow-up cleanup for PR NousResearch#69981.
kshitijk4poor pushed a commit that referenced this pull request Jul 23, 2026
Consolidate the two near-identical warning strings in
_log_wal_reset_bug_once into a single logger.warning call with an
action variable. Remove overengineered defensive tuple-length handling
in is_sqlite_wal_reset_vulnerable (sqlite3.sqlite_version_info always
returns a 3-tuple). Remove extra blank line.

Follow-up cleanup for PR #69981.
kshitijk4poor pushed a commit that referenced this pull request Jul 23, 2026
Hoist the duplicated check_info(source_id) call out of both
if/else branches into a single call after the branch. Remove
trailing whitespace on the blank line after the except block.

Follow-up cleanup for PR #69981.
@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Merged via #70055 — your commits were cherry-picked onto fresh main with authorship preserved (rebase-merge). The fix and test commits are yours; two small follow-up cleanups were added on top (consolidated duplicate warning strings, simplified tuple handling, deduped check_info call). Thanks for the thorough bug report and clean fix!

Rmup67350 pushed a commit to Rmup67350/hermes-agent that referenced this pull request Jul 24, 2026
Consolidate the two near-identical warning strings in
_log_wal_reset_bug_once into a single logger.warning call with an
action variable. Remove overengineered defensive tuple-length handling
in is_sqlite_wal_reset_vulnerable (sqlite3.sqlite_version_info always
returns a 3-tuple). Remove extra blank line.

Follow-up cleanup for PR NousResearch#69981.
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
Consolidate the two near-identical warning strings in
_log_wal_reset_bug_once into a single logger.warning call with an
action variable. Remove overengineered defensive tuple-length handling
in is_sqlite_wal_reset_vulnerable (sqlite3.sqlite_version_info always
returns a 3-tuple). Remove extra blank line.

Follow-up cleanup for PR NousResearch#69981.
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
Hoist the duplicated check_info(source_id) call out of both
if/else branches into a single call after the branch. Remove
trailing whitespace on the blank line after the except block.

Follow-up cleanup for PR NousResearch#69981.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/install-update Installer, updater, packaging, wheels, doctor comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins P1 High — major feature broken, no workaround platform/discord Discord bot adapter sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Bundled SQLite 3.50.4 hits upstream WAL-reset corruption; clean on 3.51.3

3 participants