Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
later increase in `compare`.
- Count primary cases consistently in Markdown and CLI summaries for benchmark
runs, without counting baseline rows as extra cases or discarding their details.
- Reject duplicate selected IDs in Anthropic `evals.json` before import writes
any files or auto mode runs the cases. Duplicate IDs mapped to the same case.
- Reject malformed `--include-case-name` and `--exclude-case-name` glob patterns
before loading cases, including in auto mode, instead of silently ignoring them.

Expand Down
5 changes: 5 additions & 0 deletions internal/cli/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,17 @@ func convertAnthropicEvals(evalsData anthropicEvals, skillDir string, selected f
defer root.Close() //nolint:errcheck

cases := make([]*config.CaseConfig, 0, len(evalsData.Evals))
seen := make(map[int]bool, len(evalsData.Evals))
for _, eval := range evalsData.Evals {
caseCfg := convertEvalToCase(eval, evalsData.SkillName)
cases = append(cases, caseCfg)
if selected != nil && !selected(caseCfg.ID) {
continue
}
if seen[eval.ID] {
return nil, fmt.Errorf("duplicate eval ID %d: both entries map to %s", eval.ID, caseCfg.ID)
}
seen[eval.ID] = true
files, err := readEvalFiles(eval, root)
if err != nil {
return nil, err
Expand Down
27 changes: 27 additions & 0 deletions internal/cli/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,33 @@ func makeEvalsJSON(t *testing.T, skillName string, ids []int) string {
return string(data)
}

func TestImportCmdRejectsDuplicateIDsBeforeWriting(t *testing.T) {
t.Parallel()
root := t.TempDir()
writeSkillFile(t, root, "SKILL.md", "# Example")
writeSkillFile(t, root, "evals/evals.json", makeEvalsJSON(t, "example", []int{1, 2, 1}))
writeSkillFile(t, root, "evals/cases/case-1.yaml", "existing content")
cmd := newImportCmd()
cmd.SetArgs([]string{filepath.Join(root, "evals", "evals.json")})
if err := cmd.Execute(); err == nil || !strings.Contains(err.Error(), "duplicate eval ID 1") {
t.Fatalf("import error = %v, want duplicate eval ID 1", err)
}
got, err := os.ReadFile(filepath.Join(root, "evals", "cases", "case-1.yaml"))
if err != nil || string(got) != "existing content" {
t.Fatalf("existing case after failed import = %q, %v", got, err)
}
}

func TestConvertAnthropicEvalsIgnoresDuplicatesOutsideSelection(t *testing.T) {
t.Parallel()
input := anthropicEvals{Evals: []anthropicEval{{ID: 1}, {ID: 2}, {ID: 2}}}
selectedID := importedCaseID(1)
selected := func(id string) bool { return id == selectedID }
if _, err := convertAnthropicEvals(input, t.TempDir(), selected); err != nil {
t.Fatalf("unselected duplicates should not block the selected case: %v", err)
}
}

func TestImportCmd_Success(t *testing.T) {
t.Parallel()
dir := t.TempDir()
Expand Down
Loading