feat(ai): add personal summary models and retire Q&A

Add an admin-managed provider model catalog with per-user summary selection, migration backfill, and generation snapshots. Retire report creation and messaging while preserving owner-scoped history.

Refs #15 #16

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 20:45:21 +01:00
parent ac17d27f51
commit 989996fbd6
53 changed files with 2228 additions and 979 deletions

View File

@ -0,0 +1,33 @@
package migrations
import (
"os"
"testing"
)
func TestCatalogMigrationPreservesEffectiveConstructorDefaultWithoutRuntimeFallbackPostgres(t *testing.T) {
db, cleanup := ticket13Database(t)
defer cleanup()
for _, q := range []string{
`CREATE TABLE users(id UUID PRIMARY KEY)`,
`CREATE TABLE settings(key TEXT PRIMARY KEY,value TEXT)`,
`CREATE TABLE ai_providers(id UUID PRIMARY KEY,name TEXT,api_key_encrypted TEXT,model TEXT,endpoint TEXT,is_active BOOLEAN)`,
`INSERT INTO ai_providers VALUES('00000000-0000-0000-0000-000000001411','ollama','unchanged-secret','','private-endpoint',true)`,
`INSERT INTO users VALUES('00000000-0000-0000-0000-000000001401')`,
} {
if _, err := db.Exec(q); err != nil {
t.Fatal(err)
}
}
migration, err := os.ReadFile("000016_summary_model_catalog.up.sql")
if err != nil {
t.Fatal(err)
}
if _, err = db.Exec(string(migration)); err != nil {
t.Fatal(err)
}
var model, secret string
if err = db.QueryRow(`SELECT m.model,p.api_key_encrypted FROM users u JOIN ai_provider_models m ON m.id=u.summary_model_id JOIN ai_providers p ON p.id=m.provider_id`).Scan(&model, &secret); err != nil || model != "llama3" || secret != "unchanged-secret" {
t.Fatalf("effective default model=%s preserved=%v err=%v", model, secret == "unchanged-secret", err)
}
}