Files
hermes-agent/tests/session_rules/test_session_ids.py
yoniebans 2f3405ba9c test(evals): evals, end-to-end suites, scripts and CI on the persistence interface
Evals, the end-to-end and conformance suites, scripts and CI reach the store through the interface.

scripts/ci/check_backend_imports.py, run by scripts/check, refuses an import of persistence.sqlite outside persistence/ and persistence_assembly.py (tests excepted). The two evals that instrumented the backend now reach it through the interface: the failure-ownership probe patches the message repository class of the store it opens, and the attachment bench meters whole-blob reads at the gateway attachment store.
2026-11-17 17:51:21 +01:00

22 lines
968 B
Python

"""Session-id minting contract: every surface that creates a session mints through
``session_rules.session_ids.new_session_id`` and the id it produces is what lost-and-found salvage classifies
as a session id (the shape is the recovery sentinel for schema-less rows).
"""
from __future__ import annotations
import re
from datetime import datetime
import pytest
from session_rules.session_ids import new_session_id
@pytest.mark.parametrize("hex_len,expected_re", [(6, r"^\d{8}_\d{6}_[0-9a-f]{6}$"), (8, r"^\d{8}_\d{6}_[0-9a-f]{8}$"),
(12, r"^\d{8}_\d{6}_[0-9a-f]{12}$")])
def test_minted_ids_are_what_salvage_classifies_as_session_ids(hex_len, expected_re):
from persistence.sqlite.admin._lost_and_found import _is_session_id
sid = new_session_id(datetime(2026, 1, 2, 3, 4, 5), hex_len=hex_len)
assert re.fullmatch(expected_re, sid) and sid.startswith("20260102_030405_")
assert _is_session_id(sid)