"""E3 S3 (B-core-10): the config/state mutators flush but do NOT self-commit, so the caller owns the transaction and a change lands together with its audit row. These lock that contract — a rollback before the caller commits discards the change (proving no hidden internal commit), while a same-session read still sees it (flush visibility). DB lane (`db` fixture) — skipped without Postgres. """ from app import state, sysconfig def test_set_value_flushes_but_leaves_the_commit_to_the_caller(db): default = sysconfig.get_int(db, "quota_daily_budget") new = default + 4321 sysconfig.set_value(db, "quota_daily_budget", new) assert sysconfig.get_int(db, "quota_daily_budget") == new # visible in-session (flushed) db.rollback() # the caller never committed assert ( sysconfig.get_int(db, "quota_daily_budget") == default ) # discarded — no hidden self-commit def test_reset_flushes_but_leaves_the_commit_to_the_caller(db): default = sysconfig.get_int(db, "quota_daily_budget") sysconfig.set_value(db, "quota_daily_budget", default + 10) db.commit() # a persisted override to reset sysconfig.reset(db, "quota_daily_budget") assert sysconfig.get_int(db, "quota_daily_budget") == default # reset visible in-session db.rollback() assert ( sysconfig.get_int(db, "quota_daily_budget") == default + 10 ) # reset discarded until committed def test_set_sync_paused_flushes_but_leaves_the_commit_to_the_caller(db): assert state.is_sync_paused(db) is False state.set_sync_paused(db, True) assert state.is_sync_paused(db) is True # visible in-session db.rollback() assert state.is_sync_paused(db) is False # discarded — the caller owns the commit