feat(tuning): scoring weights → DB-backed admin tuning lab
The recommendation scoring knobs move out of YAML (radio profile) and out of the systemMixWeights hard-code (daily_mix profile) into DB-backed settings with live effect (#1250) — the defaults-discovery lab per decision #1247: the operator turns knobs to find good values, which then get baked back into shipped defaults; end users and other operators should never need the card. - Migration 0040: recommendation_weight_profiles (radio / daily_mix, 8 weight columns), taste_tuning singleton (engagement half-life + completion-curve points), recommendation_tuning_audit (one row per change with a {field, old, new} diff — the trend view's markers, #1251). - internal/recsettings: boot reconcile seeds shipped defaults without clobbering tuned rows (coverart SettingsService pattern), validates patches (bounds, curve ordering), writes audit rows, and pushes daily_mix weights + taste config into package playlists. No-op patches write no audit row. - playlists gains SetSystemMixWeights / SetTasteConfig swap points under a RWMutex — no signature threading through the producers; the scheduler's taste rebuild reads the pushed config. - Radio reads its weight profile from the service per request; the 8 weight fields leave config.RecommendationConfig (YAML keeps only RecentlyPlayedHours / RadioSize / RadioSizeMax). - Admin API: GET/PATCH/reset under /api/admin/recommendation-tuning, echoing current + shipped values. - Web: new admin Tuning tab — two weight profiles side by side, taste card, per-scope save (changed fields only) + reset, deviation dots against shipped defaults. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TsF3cNoKrqCYsU78cXC8U6
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
-- Recommendation tuning lab queries (#1250). Seeding happens via the
|
||||
-- recsettings boot reconcile; shipped defaults live in Go only.
|
||||
|
||||
-- name: UpsertWeightProfileDefaults :exec
|
||||
-- Boot reconcile: insert the shipped defaults for a profile if the row
|
||||
-- doesn't exist yet. Never overwrites operator-tuned values.
|
||||
INSERT INTO recommendation_weight_profiles (
|
||||
profile, base_weight, like_boost, recency_weight, skip_penalty,
|
||||
jitter_magnitude, context_weight, similarity_weight, taste_weight
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||
ON CONFLICT (profile) DO NOTHING;
|
||||
|
||||
-- name: ListWeightProfiles :many
|
||||
SELECT * FROM recommendation_weight_profiles ORDER BY profile;
|
||||
|
||||
-- name: UpdateWeightProfile :one
|
||||
UPDATE recommendation_weight_profiles
|
||||
SET base_weight = $2,
|
||||
like_boost = $3,
|
||||
recency_weight = $4,
|
||||
skip_penalty = $5,
|
||||
jitter_magnitude = $6,
|
||||
context_weight = $7,
|
||||
similarity_weight = $8,
|
||||
taste_weight = $9,
|
||||
updated_at = now()
|
||||
WHERE profile = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpsertTasteTuningDefaults :exec
|
||||
INSERT INTO taste_tuning (
|
||||
singleton, half_life_days, engagement_hard_skip,
|
||||
engagement_neutral, engagement_full
|
||||
) VALUES (true, $1, $2, $3, $4)
|
||||
ON CONFLICT (singleton) DO NOTHING;
|
||||
|
||||
-- name: GetTasteTuning :one
|
||||
SELECT * FROM taste_tuning WHERE singleton = true;
|
||||
|
||||
-- name: UpdateTasteTuning :one
|
||||
UPDATE taste_tuning
|
||||
SET half_life_days = $1,
|
||||
engagement_hard_skip = $2,
|
||||
engagement_neutral = $3,
|
||||
engagement_full = $4,
|
||||
updated_at = now()
|
||||
WHERE singleton = true
|
||||
RETURNING *;
|
||||
|
||||
-- name: InsertTuningAudit :exec
|
||||
-- changes is a jsonb array of {field, old, new} objects.
|
||||
INSERT INTO recommendation_tuning_audit (scope, action, changes)
|
||||
VALUES ($1, $2, $3);
|
||||
|
||||
-- name: ListTuningAudit :many
|
||||
-- Newest first; consumed by the metrics trend view (#1251) to annotate
|
||||
-- knob turns on the timeline.
|
||||
SELECT id, changed_at, scope, action, changes
|
||||
FROM recommendation_tuning_audit
|
||||
ORDER BY changed_at DESC, id DESC
|
||||
LIMIT $1;
|
||||
Reference in New Issue
Block a user