Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ All notable changes to SkillEvaluator are documented in this file.
records and is reported as an unsupported agent log format; agent log files read
from a trial directory are unaffected because they are read with newline
normalization.
- Claude Code and Cline log reconstruction skips non-object JSON events and
Cline tool payloads instead of discarding valid surrounding evidence with an exception.
- Declarative command-success checks retain recorded exit status for a single
script command whose quoted path contains spaces. Pipeline tails (`|` and `|&`)
and negated commands (`!` and `time [-p] [--] !`) remain unattributed instead
Expand Down
9 changes: 9 additions & 0 deletions src/skillevaluator/tier3/eval_core/log_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def synthetic_trajectory_from_claude_stream_jsonl(text: str) -> dict[str, Any] |
except json.JSONDecodeError:
continue

if not isinstance(evt, dict):
continue

et = evt.get("type")
if et == "assistant":
msg = evt.get("message")
Expand Down Expand Up @@ -293,6 +296,9 @@ def synthetic_trajectory_from_cline_cli(text: str) -> dict[str, Any] | None:
except json.JSONDecodeError:
continue

if not isinstance(evt, dict):
continue

say = evt.get("say", "")
ask = evt.get("ask", "")
evt_text = evt.get("text", "")
Expand All @@ -303,6 +309,9 @@ def synthetic_trajectory_from_cline_cli(text: str) -> dict[str, Any] | None:
except (json.JSONDecodeError, TypeError):
tool_data = {}

if not isinstance(tool_data, dict):
continue

tool_name = tool_data.get("tool", "")
if tool_name == "useSkill":
path = tool_data.get("path", "")
Expand Down
7 changes: 4 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ def test_top_level_help_groups_commands_by_workflow() -> None:


def test_help_emits_color_when_enabled() -> None:
ctx = click.Context(cli, info_name="skillevaluator", color=True)
colored = render_help(cli, ctx, width=80)
plain = render_help(cli, click.Context(cli, info_name="skillevaluator", color=False), width=80)
with cli.make_context("skillevaluator", [], resilient_parsing=True, color=True) as ctx:
colored = render_help(cli, ctx, width=80)
with cli.make_context("skillevaluator", [], resilient_parsing=True, color=False) as ctx:
plain = render_help(cli, ctx, width=80)

assert "\x1b[" in colored
assert "\x1b[" not in plain
Expand Down
10 changes: 4 additions & 6 deletions tests/test_cli_banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import shutil
import sys

import click
import pytest
from click.testing import CliRunner

Expand Down Expand Up @@ -122,11 +121,10 @@ def test_banner_respects_terminal_color_capabilities(terminal, monkeypatch):


def test_nested_help_does_not_show_banner(terminal):
parent = click.Context(cli, info_name="skillevaluator")
tier = cli.get_command(parent, "tier1")
ctx = click.Context(tier, info_name="tier1", parent=parent, color=False)

assert render_help(tier, ctx).startswith("Usage: skillevaluator tier1")
with cli.make_context("skillevaluator", [], resilient_parsing=True) as parent:
tier = cli.get_command(parent, "tier1")
with tier.make_context("tier1", [], parent=parent, resilient_parsing=True, color=False) as ctx:
assert render_help(tier, ctx).startswith("Usage: skillevaluator tier1")


@pytest.mark.parametrize(
Expand Down
75 changes: 75 additions & 0 deletions tests/tier3/test_log_event_shapes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""Non-event JSON values must not discard valid surrounding agent evidence."""

import json
from pathlib import Path

import pytest

from skillevaluator.tier3.eval_core.log_converters import (
load_trajectory_with_fallback,
synthetic_trajectory_from_claude_stream_jsonl,
synthetic_trajectory_from_cline_cli,
)

CLAUDE_EVENTS = [
{
"type": "assistant",
"message": {"content": [{"type": "tool_use", "id": "t1", "name": "Bash", "input": {"command": "echo kept"}}]},
},
{"type": "user", "message": {"content": [{"type": "tool_result", "tool_use_id": "t1", "content": "kept"}]}},
{"type": "assistant", "message": {"content": "finished"}},
]
CLINE_EVENTS = [
{"say": "command", "text": "echo kept"},
{"ask": "command_output", "text": "kept"},
{"say": "completion_result", "text": "finished"},
]
NON_EVENTS = [None, [], False, 7, "noise"]


def _jsonl(events: list[object]) -> str:
return "\n".join(json.dumps(event) for event in events)


@pytest.mark.parametrize("noise", NON_EVENTS)
@pytest.mark.parametrize(
("parser", "events"),
[
(synthetic_trajectory_from_claude_stream_jsonl, CLAUDE_EVENTS),
(synthetic_trajectory_from_cline_cli, CLINE_EVENTS),
],
)
def test_non_object_events_preserve_surrounding_tool_evidence(parser, events, noise) -> None:
clean = parser(_jsonl(events))
assert clean is not None

assert parser(_jsonl([noise, events[0], noise, *events[1:], noise])) == clean
assert parser(_jsonl([noise])) is None


@pytest.mark.parametrize("payload", NON_EVENTS)
def test_cline_non_object_tool_payload_preserves_surrounding_events(payload) -> None:
malformed_tool = {"say": "tool", "text": json.dumps(payload)}

assert synthetic_trajectory_from_cline_cli(
_jsonl([CLINE_EVENTS[0], malformed_tool, *CLINE_EVENTS[1:]])
) == synthetic_trajectory_from_cline_cli(_jsonl(CLINE_EVENTS))


@pytest.mark.parametrize(
("filename", "parser", "events"),
[
("claude-code.txt", synthetic_trajectory_from_claude_stream_jsonl, CLAUDE_EVENTS),
("cline.txt", synthetic_trajectory_from_cline_cli, CLINE_EVENTS),
],
)
def test_fallback_recovers_valid_evidence_around_non_events(tmp_path: Path, filename, parser, events) -> None:
(tmp_path / filename).write_text(_jsonl([*NON_EVENTS, *events, *NON_EVENTS]), encoding="utf-8")

trajectory, metadata = load_trajectory_with_fallback(tmp_path / "trajectory.json", tmp_path)

assert trajectory == parser(_jsonl(events))
assert metadata["source"] == filename
Loading