From eff960c54620bfba47d40bc3792ba805dea3dab3 Mon Sep 17 00:00:00 2001 From: Sam Scholten Date: Sun, 30 Aug 2026 20:34:38 +1000 Subject: rss: provenance + score calibration in items Item titles gain a rune-capped source-feed suffix so list views (which only ever show the channel title) display provenance inline. Item bodies open with feed, model score, and the batch-wide score median; the median is computed over every scored entry at poll time and stored on the run row as a nil-safe pointer, so old rows render without it. /api/status exposes the median too. --- cmds/serve_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cmds/serve_test.go') diff --git a/cmds/serve_test.go b/cmds/serve_test.go index d7df2dd..e8aec19 100644 --- a/cmds/serve_test.go +++ b/cmds/serve_test.go @@ -133,6 +133,9 @@ func TestPollMultiPage(t *testing.T) { if !row.ModelCreatedAt.Equal(model.CreatedAt) { t.Errorf("model_created_at = %v, want %v", row.ModelCreatedAt, model.CreatedAt) } + if row.ScoreMedian == nil { + t.Error("score_median missing on run row (median over all scored entries)") + } } func TestPollCrashLeavesNoState(t *testing.T) { @@ -274,6 +277,20 @@ func TestAssembleBatchFewCandidates(t *testing.T) { } } +func TestMedianScore(t *testing.T) { + if m := medianScore(nil); m != nil { + t.Errorf("empty poll: median = %v, want nil (field omitted)", *m) + } + odd := []scoredEntry{{score: 0.1}, {score: 0.9}, {score: 0.5}} + if m := medianScore(odd); m == nil || *m != 0.5 { + t.Errorf("odd median = %v, want 0.5", m) + } + even := []scoredEntry{{score: 0.1}, {score: 0.5}, {score: 0.9}, {score: 0.2}} + if m := medianScore(even); m == nil || *m != 0.35 { + t.Errorf("even median = %v, want 0.35", m) + } +} + func TestParseRefreshAt(t *testing.T) { mins, err := parseRefreshAt("18:00,06:00, 12:30") if err != nil { -- cgit v1.2.3