LEM/cmd/lemcmd/score.go
Snider a3e9a1e035 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>
2026-02-22 19:03:41 +00:00

34 lines
1.3 KiB
Go

package lemcmd
import (
"fmt"
"forge.lthn.ai/core/go/pkg/cli"
"forge.lthn.ai/lthn/lem/pkg/lem"
)
func addScoreCommands(root *cli.Command) {
scoreGroup := cli.NewGroup("score", "Scoring commands", "Score responses, probe models, compare results.")
scoreGroup.AddCommand(passthrough("run", "Score existing response files", lem.RunScore))
scoreGroup.AddCommand(passthrough("probe", "Generate responses and score them", lem.RunProbe))
// compare has a different signature — it takes two named args, not []string.
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)")
scoreGroup.AddCommand(compareCmd)
scoreGroup.AddCommand(passthrough("tier", "Score expansion responses (heuristic/judge tiers)", lem.RunTierScore))
scoreGroup.AddCommand(passthrough("agent", "ROCm scoring daemon (polls M3, scores checkpoints)", lem.RunAgent))
root.AddCommand(scoreGroup)
}