Skip to content

Commit 76494bd

Browse files
committed
feat: thread session_locator into flush_session_log via Protocol dispatch
Replace the direct claude_code_log_path(cwd, session_id) call in flush_session_log with Protocol-dispatched resolution through SessionLocator.session_log_path(). Add a session_locator kwarg with lazy ClaudeSessionLocator() fallback to avoid import-time coupling between session_log and the backends module. Migration: - 15 monkeypatch.setattr sites in test_session_log_fields.py replaced with explicit injection via _FakeLocator test helper - conftest._flush() updated to accept and forward session_locator - 2 new structural guard tests: - test_session_locator_is_optional_parameter (signature guard) - test_flush_helper_forwards_session_locator (forwarding guard) This unblocks dispatching the cc_log resolution through any backend that supplies a SessionLocator (Codex, future backends) without hard-coupling to the claude module.
1 parent 773aa4e commit 76494bd

5 files changed

Lines changed: 100 additions & 68 deletions

File tree

src/autoskillit/execution/session_log.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
from typing import TYPE_CHECKING, Any, Literal
1717

1818
if TYPE_CHECKING:
19-
from autoskillit.core import ProviderOutcome, RecipeIdentity, SessionTelemetry
19+
from autoskillit.core import ProviderOutcome, RecipeIdentity, SessionLocator, SessionTelemetry
2020

2121

2222
from autoskillit.core import (
2323
ModelIdentity,
2424
atomic_write,
25-
claude_code_log_path,
2625
default_log_dir,
2726
get_logger,
2827
iter_merged_assistant_turns,
@@ -154,6 +153,7 @@ def flush_session_log(
154153
is_resume: bool = False,
155154
codex_log_path: Path | None = None,
156155
backend: Literal["claude-code", "codex"] = "claude-code",
156+
session_locator: SessionLocator | None = None,
157157
telemetry: SessionTelemetry,
158158
) -> None:
159159
"""Flush session diagnostics to disk.
@@ -187,7 +187,13 @@ def flush_session_log(
187187
cc_log = None
188188
cc_log_str = None
189189
else:
190-
cc_log = claude_code_log_path(cwd, session_id)
190+
if session_locator is not None:
191+
_locator = session_locator
192+
else:
193+
from autoskillit.execution.backends.claude import ClaudeSessionLocator
194+
195+
_locator = ClaudeSessionLocator()
196+
cc_log = _locator.session_log_path(cwd, session_id)
191197
cc_log_str = str(cc_log) if cc_log else None
192198

193199
if cc_log and not cc_log.exists():

tests/execution/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ def _subagent_assistant_ndjson(
310310
)
311311

312312

313-
def _flush(tmp_path: Path, *, backend: str = "claude-code", **overrides) -> None:
313+
def _flush(
314+
tmp_path: Path, *, backend: str = "claude-code", session_locator=None, **overrides
315+
) -> None:
314316
from autoskillit.core.types._type_results import ModelIdentity, ProviderOutcome
315317
from autoskillit.core.types._type_results_execution import (
316318
RecipeIdentity,
@@ -393,6 +395,7 @@ def _flush(tmp_path: Path, *, backend: str = "claude-code", **overrides) -> None
393395
provider_outcome=provider_outcome,
394396
recipe_identity=recipe_identity,
395397
backend=backend,
398+
session_locator=session_locator,
396399
)
397400

398401

tests/execution/test_flush_completeness_guard.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ def test_recipe_identity_is_required_parameter(self):
5656
param = sig.parameters["recipe_identity"]
5757
assert param.default is inspect.Parameter.empty
5858

59+
def test_session_locator_is_optional_parameter(self):
60+
from autoskillit.execution.session_log import flush_session_log
61+
62+
sig = inspect.signature(flush_session_log)
63+
assert "session_locator" in sig.parameters
64+
param = sig.parameters["session_locator"]
65+
assert param.default is None
66+
5967

6068
class TestFlushOutputCompleteness:
6169
"""Every ProviderOutcome field must appear in flush output."""

0 commit comments

Comments
 (0)