Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/autoskillit/execution/session_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
from typing import TYPE_CHECKING, Any, Literal

if TYPE_CHECKING:
from autoskillit.core import ProviderOutcome, RecipeIdentity, SessionTelemetry
from autoskillit.core import ProviderOutcome, RecipeIdentity, SessionLocator, SessionTelemetry


from autoskillit.core import (
ModelIdentity,
atomic_write,
claude_code_log_path,
default_log_dir,
get_logger,
iter_merged_assistant_turns,
Expand Down Expand Up @@ -155,6 +154,7 @@ def flush_session_log(
codex_log_path: Path | None = None,
backend: Literal["claude-code", "codex"] = "claude-code",
telemetry: SessionTelemetry,
session_locator: SessionLocator | None = None,
) -> None:
"""Flush session diagnostics to disk.

Expand Down Expand Up @@ -187,7 +187,13 @@ def flush_session_log(
cc_log = None
cc_log_str = None
else:
cc_log = claude_code_log_path(cwd, session_id)
if session_locator is not None:
_locator = session_locator
else:
from autoskillit.execution.backends.claude import ClaudeSessionLocator

_locator = ClaudeSessionLocator()
cc_log = _locator.session_log_path(cwd, session_id)
cc_log_str = str(cc_log) if cc_log else None

if cc_log and not cc_log.exists():
Expand Down
11 changes: 9 additions & 2 deletions tests/execution/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import pytest

from autoskillit.core import BackendCapabilities, CmdSpec
from autoskillit.core import BackendCapabilities, CmdSpec, SessionLocator
from autoskillit.core.types import SubprocessResult, TerminationReason
from autoskillit.execution.session import ClaudeSessionResult
from autoskillit.execution.session._exit_classification import _CODEX_API_ERROR_PATTERNS
Expand Down Expand Up @@ -310,7 +310,13 @@ def _subagent_assistant_ndjson(
)


def _flush(tmp_path: Path, *, backend: str = "claude-code", **overrides) -> None:
def _flush(
tmp_path: Path,
*,
backend: str = "claude-code",
session_locator: SessionLocator | None = None,
**overrides,
) -> None:
from autoskillit.core.types._type_results import ModelIdentity, ProviderOutcome
from autoskillit.core.types._type_results_execution import (
RecipeIdentity,
Expand Down Expand Up @@ -393,6 +399,7 @@ def _flush(tmp_path: Path, *, backend: str = "claude-code", **overrides) -> None
provider_outcome=provider_outcome,
recipe_identity=recipe_identity,
backend=backend,
session_locator=session_locator,
)


Expand Down
8 changes: 8 additions & 0 deletions tests/execution/test_flush_completeness_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ def test_recipe_identity_is_required_parameter(self):
param = sig.parameters["recipe_identity"]
assert param.default is inspect.Parameter.empty

def test_session_locator_is_optional_parameter(self):
from autoskillit.execution.session_log import flush_session_log

sig = inspect.signature(flush_session_log)
assert "session_locator" in sig.parameters
param = sig.parameters["session_locator"]
assert param.default is None


class TestFlushOutputCompleteness:
"""Every ProviderOutcome field must appear in flush output."""
Expand Down
Loading
Loading