From d12cec183303992e833acaecd5a8c9fcad4fc36c Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Mon, 14 Sep 2026 19:06:16 -0700 Subject: [PATCH] fix(tests): keep the leak registry in hermes_state_guard and skip shared handles Rebase follow-up. hermes_state.py is a facade now; the test-isolation guard code the registry sits beside moved to hermes_state_guard.py, so the WeakSet and _register_test_instance live there (gated on the same _TEST_ISOLATION_MARKER_ENV the guard already owns) and the facade only calls the helper from __init__. The sweep now skips instances flagged _shared_registry_owned: since #90837 close() on a hermes_state_registry.acquire() handle releases a refcount instead of closing, so sweeping them would retire a shared generation that a wider-scoped fixture still holds. The registry owns that lifecycle (close_all()). Per Enough1122's nit, the registry comment states explicitly that production never populates it and that the gate must not be removed. --- hermes_state.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hermes_state.py b/hermes_state.py index 96400097ab..a977424915 100644 --- a/hermes_state.py +++ b/hermes_state.py @@ -37,7 +37,7 @@ from hermes_state_errors import ( ) from hermes_state_guard import ( _STATE_DB_GUARD_BYPASS_ENV, _in_test_context, _is_production_state_db, _real_platform_state_root, - _register_test_instance, _set_last_init_error, _test_instance_registry, get_last_init_error, + _register_test_instance, _set_last_init_error, get_last_init_error, ) from hermes_state_readpool import _READ_POOL_MAX, _proc_fd_targets, _read_budget_for from hermes_state_sessions import SessionSessionsMixin