@@ -301,8 +301,7 @@ async def test_disable_reverses_enable(self, tool_ctx):
301301
302302 with patch .object (tools_kitchen_mod , "_prime_quota_cache" , new = AsyncMock ()):
303303 with patch .object (tools_kitchen_mod , "_write_hook_config" ):
304- with patch .object (tools_kitchen_mod , "_register_gate_cleanup" ):
305- await _open_kitchen_handler ()
304+ await _open_kitchen_handler ()
306305 _close_kitchen_handler ()
307306 result = json .loads (await run_cmd (cmd = "echo hi" , cwd = "/tmp" ))
308307 assert result ["success" ] is False
@@ -612,110 +611,6 @@ def test_get_config_raises_before_initialize(self, monkeypatch):
612611 _state ._get_config ()
613612
614613
615- class TestGateFileRecovery :
616- """T-RECOVER: _initialize removes stale/malformed gate files at startup."""
617-
618- @pytest .mark .anyio
619- async def test_initialize_removes_stale_gate_file (self , monkeypatch , tmp_path ):
620- """_initialize must remove gate files whose owning PID is dead."""
621- monkeypatch .chdir (tmp_path )
622- gate_dir = tmp_path / ".autoskillit" / "temp"
623- gate_dir .mkdir (parents = True )
624- gate_file = gate_dir / ".kitchen_gate"
625- gate_file .write_text (json .dumps ({"pid" : 999999999 , "opened_at" : "2026-01-01T00:00:00Z" }))
626-
627- from autoskillit .server ._factory import make_context
628- from tests .conftest import MockSubprocessRunner
629-
630- ctx = make_context (
631- AutomationConfig (), runner = MockSubprocessRunner (), plugin_dir = str (tmp_path )
632- )
633- from autoskillit .server ._state import _initialize
634-
635- _initialize (ctx )
636- assert not gate_file .exists ()
637-
638- @pytest .mark .anyio
639- async def test_initialize_preserves_live_gate_file (self , monkeypatch , tmp_path ):
640- """_initialize must NOT remove gate files whose owning PID is alive."""
641- import os
642-
643- monkeypatch .chdir (tmp_path )
644- gate_dir = tmp_path / ".autoskillit" / "temp"
645- gate_dir .mkdir (parents = True )
646- gate_file = gate_dir / ".kitchen_gate"
647- from datetime import UTC , datetime
648-
649- from autoskillit .execution import read_boot_id , read_starttime_ticks
650-
651- gate_file .write_text (
652- json .dumps (
653- {
654- "pid" : os .getpid (),
655- "starttime_ticks" : read_starttime_ticks (os .getpid ()),
656- "boot_id" : read_boot_id (),
657- "opened_at" : datetime .now (UTC ).isoformat (),
658- }
659- )
660- )
661-
662- from autoskillit .server ._factory import make_context
663- from tests .conftest import MockSubprocessRunner
664-
665- ctx = make_context (
666- AutomationConfig (), runner = MockSubprocessRunner (), plugin_dir = str (tmp_path )
667- )
668- from autoskillit .server ._state import _initialize
669-
670- _initialize (ctx )
671- assert gate_file .exists () # still there — owning process is alive
672-
673- @pytest .mark .anyio
674- async def test_initialize_removes_malformed_gate_file (self , monkeypatch , tmp_path ):
675- """Malformed gate files must be removed at startup."""
676- monkeypatch .chdir (tmp_path )
677- gate_dir = tmp_path / ".autoskillit" / "temp"
678- gate_dir .mkdir (parents = True )
679- gate_file = gate_dir / ".kitchen_gate"
680- gate_file .write_text ("not valid json" )
681-
682- from autoskillit .server ._factory import make_context
683- from tests .conftest import MockSubprocessRunner
684-
685- ctx = make_context (
686- AutomationConfig (), runner = MockSubprocessRunner (), plugin_dir = str (tmp_path )
687- )
688- from autoskillit .server ._state import _initialize
689-
690- _initialize (ctx )
691- assert not gate_file .exists ()
692-
693- @pytest .mark .anyio
694- async def test_initialize_removes_companion_hook_config_with_stale_gate (
695- self , monkeypatch , tmp_path
696- ):
697- """_initialize must remove both gate file and companion hook config when stale."""
698- monkeypatch .chdir (tmp_path )
699- gate_dir = tmp_path / ".autoskillit" / "temp"
700- gate_dir .mkdir (parents = True )
701- gate_file = gate_dir / ".kitchen_gate"
702- gate_file .write_text (json .dumps ({"pid" : 999999999 , "opened_at" : "2026-01-01T00:00:00Z" }))
703- companion = gate_dir / ".autoskillit_hook_config.json"
704- companion .write_text ("{}" )
705-
706- from autoskillit .server ._factory import make_context
707- from tests .conftest import MockSubprocessRunner
708-
709- ctx = make_context (
710- AutomationConfig (), runner = MockSubprocessRunner (), plugin_dir = str (tmp_path )
711- )
712- from autoskillit .server ._state import _initialize
713-
714- _initialize (ctx )
715- assert not gate_file .exists ()
716- assert not companion .exists ()
717-
718-
719614class TestConfigDrivenBehavior :
720615 """S1-S10: Verify tools use config instead of hardcoded values."""
721616
0 commit comments