Skip to content

fix(config,startup): accept and wire session_state_path (#653) - #661

Open
Yatsuiii wants to merge 1 commit into
agentrust-io:mainfrom
Yatsuiii:fix/653-session-state-store-wiring
Open

Yatsuiii wants to merge 1 commit into
agentrust-io:mainfrom
Yatsuiii:fix/653-session-state-store-wiring

Conversation

@Yatsuiii

Copy link
Copy Markdown
Contributor

Closes #653. Credit to @saintmalik for the report - the root-cause tracing to both defects, including the exact config.py/startup.py line citations, is theirs; this PR is the fix.

session_state_path was documented (docs/configuration.md) and its feature described as shipped (CHANGELOG, merged #629), but was non-functional in two independent ways:

  1. _KNOWN_TOP_KEYS (config.py) omitted the key, so load_config rejected any config that set it, before the existing parsing code (config.py:489-491, :561) ever ran.
  2. Even past that, run_startup never constructed a SqliteSessionStateStore - only an import and a RuntimeContext dataclass field existed. RuntimeContext.session_state_store stayed None regardless of configuration, so the shared, persistent session-sensitivity ratchet never activated: a restart still lost the accumulated value, and multiple instances serving one session still ratcheted independently.

Confirmed both by direct inspection before writing anything: SqliteSessionStateStore( had zero call sites in src/ outside its own class definition.

What changed

  • config.py: added session_state_path to _KNOWN_TOP_KEYS.
  • startup.py: added _open_session_state_store(), called from run_startup as step 5f. Opens the store when session_state_path is configured and wires it into RuntimeContext; leaves it None, unchanged, when unconfigured. An unopenable path fails startup closed (SESSION_STATE_STORE_UNAVAILABLE), mirroring the existing audit_store open-failure pattern exactly.
  • Extracted into its own helper rather than inlined, to avoid adding to run_startup's already-high pre-existing complexity (measured at 26 on clean main before this change; unchanged after, since the helper is a single call site).

Scope

The store's own logic (locking, hydrate/reset semantics, cross-process behavior) is untouched - tests/unit/test_session_state_store.py's existing suite already exercises SessionState.hydrate() against a real SqliteSessionStateStore, including a real multiprocessing-based cross-process lock test. This PR only closes the wiring gap between that already-tested mechanism and run_startup.

Testing

  • New: config acceptance test, and three run_startup tests (unconfigured stays None; configured opens a real store and the file exists on disk, closed in finally; a store-open failure aborts startup - forced via monkeypatch rather than an OS-level directory trick, since this repo's CI runs both Linux and Windows).
  • Full suite: pytest tests/unit -q -> 1838 passed, 6 skipped, one pre-existing unrelated failure (test_startup_fails_on_unknown_tee_provider_name, fails identically on clean main, a local TPM auto-detection quirk unrelated to this change).
  • Ruff and mypy clean on all touched source files.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session_state_path is documented and released but rejected at config load and never constructed at startup

2 participants