Editable analysis prompts on the admin page
CI / test (push) Successful in 44s
CI / build (push) Successful in 4m13s
CI / deploy (push) Skipped

The system prompts of the free summary and the paid detailed analysis can be
edited per language under /admin/promptok. Every save is a new row in
prompt_revisions (NULL = built-in text); new analyses record the revision in
prompt_version (v2-r<id>) and the worker uses exactly that text. Existing
analyses stay; the cross-user cache only copies results of the same revision.

The prompt code moves to the shared analysis-prompt crate so the backend can
show the built-in text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-17 14:25:08 +00:00
co-authored by Claude Opus 5.5
parent 0ba80abb47
commit 86d5dc5503
25 changed files with 1051 additions and 347 deletions
+29
View File
@@ -369,6 +369,35 @@ mod analyses {
}
}
#[sqlx::test(migrator = "db::MIGRATOR")]
async fn uses_the_admin_edited_system_prompt(db: PgPool) {
let s = setup(&db).await;
let (revision,): (i64,) = sqlx::query_as(
"INSERT INTO prompt_revisions (kind, language, system) VALUES ('natal', 'hu', 'Saját szabályok.') RETURNING id",
)
.fetch_one(&db)
.await
.unwrap();
// a newer revision is not used: the analysis records the one it was requested with
sqlx::query("INSERT INTO prompt_revisions (kind, language, system) VALUES ('natal', 'hu', 'Újabb.')")
.execute(&db)
.await
.unwrap();
let id = request_analysis(&db, &s).await;
sqlx::query("UPDATE analyses SET prompt_version = $1 WHERE id = $2")
.bind(format!("v1-r{revision}"))
.bind(id)
.execute(&db)
.await
.unwrap();
let (fake, url) = fake_openrouter(vec![reply(&content(Kind::Natal))]).await;
assert!(run_once(&analyzer(&db, &url)).await);
assert_eq!(row(&db, id).await.0, "done");
let requests = fake.requests.lock().unwrap();
assert_eq!(requests[0]["messages"][0]["content"], "Saját szabályok.");
assert!(requests[0]["messages"][1]["content"].as_str().unwrap().contains("- personality: "));
}
#[sqlx::test(migrator = "db::MIGRATOR")]
async fn retries_bad_answers_then_fails_and_refunds(db: PgPool) {
let s = setup(&db).await;