1
0
Fork 0
forked from lthn/LEM

fix: handle error in score resume merge path

ReadScorerOutput error was silently discarded during resume merge,
risking partial data loss on TOCTOU file changes. Also clean up
compare command construction to pass RunE directly to NewCommand.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Snider 2026-02-22 19:03:41 +00:00
parent 80048b5b00
commit a3e9a1e035
2 changed files with 12 additions and 8 deletions

View file

@ -14,16 +14,17 @@ func addScoreCommands(root *cli.Command) {
scoreGroup.AddCommand(passthrough("probe", "Generate responses and score them", lem.RunProbe))
// compare has a different signature — it takes two named args, not []string.
compareCmd := cli.NewCommand("compare", "Compare two score files", "", nil)
var compareOld, compareNew string
compareCmd := cli.NewCommand("compare", "Compare two score files", "",
func(cmd *cli.Command, args []string) error {
if compareOld == "" || compareNew == "" {
return fmt.Errorf("--old and --new are required")
}
return lem.RunCompare(compareOld, compareNew)
},
)
cli.StringFlag(compareCmd, &compareOld, "old", "", "", "Old score file (required)")
cli.StringFlag(compareCmd, &compareNew, "new", "", "", "New score file (required)")
compareCmd.RunE = func(cmd *cli.Command, args []string) error {
if compareOld == "" || compareNew == "" {
return fmt.Errorf("--old and --new are required")
}
return lem.RunCompare(compareOld, compareNew)
}
scoreGroup.AddCommand(compareCmd)
scoreGroup.AddCommand(passthrough("tier", "Score expansion responses (heuristic/judge tiers)", lem.RunTierScore))

View file

@ -78,7 +78,10 @@ func RunScore(args []string) {
if *resume {
if _, statErr := os.Stat(*output); statErr == nil {
existing, _ := ReadScorerOutput(*output)
existing, readErr := ReadScorerOutput(*output)
if readErr != nil {
log.Fatalf("re-read scores for merge: %v", readErr)
}
for model, scores := range existing.PerPrompt {
perPrompt[model] = append(scores, perPrompt[model]...)
}