chore: rebrand from Kon/Corbie to Magnotia

Replace all instances of the legacy product names "Kon" and "Corbie" with
"Magnotia" across user-facing copy, code identifiers, package names, bundle
ids, file paths, and documentation. Preserves the unrelated "konsole" (KDE
terminal) reference and the parent CORBEL company name.

- Renames 10 Rust crates (kon-* → magnotia-*) and the tauri binary
- Updates package.json, tauri.conf.json (productName + identifier)
- Renames CSS classes (kon-rh-* → magnotia-rh-*) and animations
- Renames brand and roadmap docs
- Regenerates Cargo.lock and package-lock.json

Verified: svelte-check passes; pure-rust crates compile under new names.
This commit is contained in:
Claude
2026-04-30 13:06:55 +00:00
parent 749403697a
commit 89c63891fa
186 changed files with 1297 additions and 1297 deletions

View File

@@ -3,7 +3,7 @@ use std::path::Path;
use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
use sqlx::{Row, SqlitePool};
use kon_core::error::{KonError, Result};
use magnotia_core::error::{MagnotiaError, Result};
/// Initialise the SQLite database with connection pool and run migrations.
pub async fn init(db_path: &Path) -> Result<SqlitePool> {
@@ -19,12 +19,12 @@ pub async fn init(db_path: &Path) -> Result<SqlitePool> {
.max_connections(5)
.connect_with(options)
.await
.map_err(|e| KonError::StorageError(format!("Database connect failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Database connect failed: {e}")))?;
sqlx::query("PRAGMA foreign_keys = ON")
.execute(&pool)
.await
.map_err(|e| KonError::StorageError(format!("foreign_keys pragma failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("foreign_keys pragma failed: {e}")))?;
run_migrations(&pool).await?;
@@ -33,7 +33,7 @@ pub async fn init(db_path: &Path) -> Result<SqlitePool> {
/// Open the SQLite database in read-only mode without running migrations.
///
/// Used by `kon-mcp` so the MCP server cannot write to the user's database
/// Used by `magnotia-mcp` so the MCP server cannot write to the user's database
/// regardless of which tools the dispatcher exposes — `read_only(true)` makes
/// the constraint structural rather than relying on the request handler being
/// well-behaved. Fails cleanly if the DB doesn't exist (no `create_if_missing`).
@@ -47,7 +47,7 @@ pub async fn init_readonly(db_path: &Path) -> Result<SqlitePool> {
.max_connections(2)
.connect_with(options)
.await
.map_err(|e| KonError::StorageError(format!("Read-only connect failed: {e}")))
.map_err(|e| MagnotiaError::StorageError(format!("Read-only connect failed: {e}")))
}
/// Run schema migrations via the versioned migration system.
@@ -82,7 +82,7 @@ pub async fn insert_transcript(
params: &InsertTranscriptParams<'_>,
) -> Result<()> {
if !profile_exists(pool, params.profile_id).await? {
return Err(KonError::StorageError(format!(
return Err(MagnotiaError::StorageError(format!(
"Insert transcript failed: unknown profile id '{}'",
params.profile_id
)));
@@ -110,7 +110,7 @@ pub async fn insert_transcript(
.bind(params.anti_hallucination)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Insert transcript failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Insert transcript failed: {e}")))?;
Ok(())
}
@@ -121,7 +121,7 @@ pub async fn get_transcript(pool: &SqlitePool, id: &str) -> Result<Option<Transc
.bind(id)
.fetch_optional(pool)
.await
.map_err(|e| KonError::StorageError(format!("Get transcript failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Get transcript failed: {e}")))?;
Ok(row.map(|r| transcript_row_from(&r)))
}
@@ -144,7 +144,7 @@ pub async fn list_transcripts_paged(
.bind(offset)
.fetch_all(pool)
.await
.map_err(|e| KonError::StorageError(format!("List transcripts failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("List transcripts failed: {e}")))?;
Ok(rows.iter().map(transcript_row_from).collect())
}
@@ -154,7 +154,7 @@ pub async fn count_transcripts(pool: &SqlitePool) -> Result<i64> {
let n: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM transcripts")
.fetch_one(pool)
.await
.map_err(|e| KonError::StorageError(format!("Count transcripts failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Count transcripts failed: {e}")))?;
Ok(n)
}
@@ -182,7 +182,7 @@ pub async fn update_transcript(
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Update transcript failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Update transcript failed: {e}")))?;
Ok(res.rows_affected())
}
(Some(t), None) => {
@@ -191,7 +191,7 @@ pub async fn update_transcript(
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Update transcript failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Update transcript failed: {e}")))?;
Ok(res.rows_affected())
}
(None, Some(ttl)) => {
@@ -200,7 +200,7 @@ pub async fn update_transcript(
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Update transcript failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Update transcript failed: {e}")))?;
Ok(res.rows_affected())
}
(None, None) => Ok(0),
@@ -247,10 +247,10 @@ pub async fn update_transcript_meta(
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("update_transcript_meta: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("update_transcript_meta: {e}")))?;
get_transcript(pool, id).await?.ok_or_else(|| {
KonError::StorageError(format!("update_transcript_meta: transcript {id} not found"))
MagnotiaError::StorageError(format!("update_transcript_meta: transcript {id} not found"))
})
}
@@ -259,7 +259,7 @@ pub async fn delete_transcript(pool: &SqlitePool, id: &str) -> Result<()> {
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Delete transcript failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Delete transcript failed: {e}")))?;
Ok(())
}
@@ -283,7 +283,7 @@ pub async fn search_transcripts(
.bind(limit)
.fetch_all(pool)
.await
.map_err(|e| KonError::StorageError(format!("FTS search failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("FTS search failed: {e}")))?;
Ok(rows.iter().map(transcript_row_from).collect())
}
@@ -321,7 +321,7 @@ pub async fn insert_task(
.bind(energy)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Insert task failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Insert task failed: {e}")))?;
Ok(())
}
@@ -333,7 +333,7 @@ pub async fn list_tasks(pool: &SqlitePool) -> Result<Vec<TaskRow>> {
)
.fetch_all(pool)
.await
.map_err(|e| KonError::StorageError(format!("List tasks failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("List tasks failed: {e}")))?;
Ok(rows.into_iter().map(task_row_from).collect())
}
@@ -346,7 +346,7 @@ pub async fn get_task_by_id(pool: &SqlitePool, id: &str) -> Result<Option<TaskRo
.bind(id)
.fetch_optional(pool)
.await
.map_err(|e| KonError::StorageError(format!("Get task failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Get task failed: {e}")))?;
Ok(row.map(task_row_from))
}
@@ -384,10 +384,10 @@ pub async fn update_task(
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Update task failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Update task failed: {e}")))?;
get_task_by_id(pool, id).await?.ok_or_else(|| {
KonError::StorageError(format!("update_task: task {id} not found after update"))
MagnotiaError::StorageError(format!("update_task: task {id} not found after update"))
})
}
@@ -405,10 +405,10 @@ pub async fn set_task_energy(pool: &SqlitePool, id: &str, energy: Option<&str>)
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("set_task_energy failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("set_task_energy failed: {e}")))?;
get_task_by_id(pool, id).await?.ok_or_else(|| {
KonError::StorageError(format!("set_task_energy: task {id} not found after update"))
MagnotiaError::StorageError(format!("set_task_energy: task {id} not found after update"))
})
}
@@ -424,7 +424,7 @@ pub async fn insert_subtask(
.bind(parent_task_id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Insert subtask failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Insert subtask failed: {e}")))?;
Ok(())
}
@@ -437,7 +437,7 @@ pub async fn list_subtasks(pool: &SqlitePool, parent_id: &str) -> Result<Vec<Tas
.bind(parent_id)
.fetch_all(pool)
.await
.map_err(|e| KonError::StorageError(format!("List subtasks failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("List subtasks failed: {e}")))?;
Ok(rows.into_iter().map(task_row_from).collect())
}
@@ -448,20 +448,20 @@ pub async fn complete_subtask_and_check_parent(pool: &SqlitePool, subtask_id: &s
let mut tx = pool
.begin()
.await
.map_err(|e| KonError::StorageError(format!("Begin transaction failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Begin transaction failed: {e}")))?;
sqlx::query("UPDATE tasks SET done = 1, done_at = datetime('now') WHERE id = ?")
.bind(subtask_id)
.execute(&mut *tx)
.await
.map_err(|e| KonError::StorageError(format!("Complete subtask failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Complete subtask failed: {e}")))?;
let parent_id: Option<String> =
sqlx::query_scalar("SELECT parent_task_id FROM tasks WHERE id = ?")
.bind(subtask_id)
.fetch_one(&mut *tx)
.await
.map_err(|e| KonError::StorageError(format!("Get parent_task_id failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Get parent_task_id failed: {e}")))?;
if let Some(pid) = parent_id {
let pending: i64 =
@@ -470,7 +470,7 @@ pub async fn complete_subtask_and_check_parent(pool: &SqlitePool, subtask_id: &s
.fetch_one(&mut *tx)
.await
.map_err(|e| {
KonError::StorageError(format!("Count pending subtasks failed: {e}"))
MagnotiaError::StorageError(format!("Count pending subtasks failed: {e}"))
})?;
if pending == 0 {
@@ -484,13 +484,13 @@ pub async fn complete_subtask_and_check_parent(pool: &SqlitePool, subtask_id: &s
.bind(&pid)
.execute(&mut *tx)
.await
.map_err(|e| KonError::StorageError(format!("Auto-complete parent failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Auto-complete parent failed: {e}")))?;
}
}
tx.commit()
.await
.map_err(|e| KonError::StorageError(format!("Commit transaction failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Commit transaction failed: {e}")))?;
Ok(())
}
@@ -500,7 +500,7 @@ pub async fn complete_task(pool: &SqlitePool, id: &str) -> Result<()> {
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Complete task failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Complete task failed: {e}")))?;
Ok(())
}
@@ -508,13 +508,13 @@ pub async fn uncomplete_task(pool: &SqlitePool, id: &str) -> Result<()> {
let mut tx = pool
.begin()
.await
.map_err(|e| KonError::StorageError(format!("Begin transaction failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Begin transaction failed: {e}")))?;
sqlx::query("UPDATE tasks SET done = 0, done_at = NULL, auto_completed = 0 WHERE id = ?")
.bind(id)
.execute(&mut *tx)
.await
.map_err(|e| KonError::StorageError(format!("Uncomplete task failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Uncomplete task failed: {e}")))?;
// Mirror the auto-complete invariant from
// `complete_subtask_and_check_parent`: a parent task is done iff
@@ -526,7 +526,7 @@ pub async fn uncomplete_task(pool: &SqlitePool, id: &str) -> Result<()> {
.bind(id)
.fetch_optional(&mut *tx)
.await
.map_err(|e| KonError::StorageError(format!("Get parent_task_id failed: {e}")))?
.map_err(|e| MagnotiaError::StorageError(format!("Get parent_task_id failed: {e}")))?
.flatten();
if let Some(pid) = parent_id {
@@ -537,12 +537,12 @@ pub async fn uncomplete_task(pool: &SqlitePool, id: &str) -> Result<()> {
.bind(&pid)
.execute(&mut *tx)
.await
.map_err(|e| KonError::StorageError(format!("Reopen parent failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Reopen parent failed: {e}")))?;
}
tx.commit()
.await
.map_err(|e| KonError::StorageError(format!("Commit transaction failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Commit transaction failed: {e}")))?;
Ok(())
}
@@ -552,7 +552,7 @@ pub async fn delete_task(pool: &SqlitePool, id: &str) -> Result<()> {
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Delete task failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Delete task failed: {e}")))?;
Ok(())
}
@@ -599,7 +599,7 @@ pub async fn list_recent_completions(
.bind(format!("-{} days", days - 1))
.fetch_all(pool)
.await
.map_err(|e| KonError::StorageError(format!("List recent completions failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("List recent completions failed: {e}")))?;
let lookup: std::collections::HashMap<String, u32> = rows
.into_iter()
@@ -610,7 +610,7 @@ pub async fn list_recent_completions(
let today_row: (String,) = sqlx::query_as("SELECT DATE('now', 'localtime')")
.fetch_one(pool)
.await
.map_err(|e| KonError::StorageError(format!("Get local today failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Get local today failed: {e}")))?;
let today = today_row.0;
let mut series = Vec::with_capacity(days as usize);
@@ -622,7 +622,7 @@ pub async fn list_recent_completions(
.bind(format!("-{offset} days"))
.fetch_one(pool)
.await
.map_err(|e| KonError::StorageError(format!("Compute spine day failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Compute spine day failed: {e}")))?;
let count = lookup.get(&day).copied().unwrap_or(0);
series.push(DailyCompletionCount { day, count });
}
@@ -655,10 +655,10 @@ pub async fn insert_implementation_rule(
.bind(last_fired_key)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Insert implementation rule failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Insert implementation rule failed: {e}")))?;
get_implementation_rule(pool, id).await?.ok_or_else(|| {
KonError::StorageError(format!(
MagnotiaError::StorageError(format!(
"insert_implementation_rule: rule {id} not found after insert"
))
})
@@ -672,7 +672,7 @@ pub async fn list_implementation_rules(pool: &SqlitePool) -> Result<Vec<Implemen
)
.fetch_all(pool)
.await
.map_err(|e| KonError::StorageError(format!("List implementation rules failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("List implementation rules failed: {e}")))?;
Ok(rows.into_iter().map(implementation_rule_row_from).collect())
}
@@ -689,7 +689,7 @@ pub async fn get_implementation_rule(
.bind(id)
.fetch_optional(pool)
.await
.map_err(|e| KonError::StorageError(format!("Get implementation rule failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Get implementation rule failed: {e}")))?;
Ok(row.map(implementation_rule_row_from))
}
@@ -708,10 +708,10 @@ pub async fn set_implementation_rule_enabled(
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Set implementation rule enabled failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Set implementation rule enabled failed: {e}")))?;
get_implementation_rule(pool, id).await?.ok_or_else(|| {
KonError::StorageError(format!(
MagnotiaError::StorageError(format!(
"set_implementation_rule_enabled: rule {id} not found after update"
))
})
@@ -731,10 +731,10 @@ pub async fn mark_implementation_rule_fired(
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Mark implementation rule fired failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Mark implementation rule fired failed: {e}")))?;
get_implementation_rule(pool, id).await?.ok_or_else(|| {
KonError::StorageError(format!(
MagnotiaError::StorageError(format!(
"mark_implementation_rule_fired: rule {id} not found after update"
))
})
@@ -745,7 +745,7 @@ pub async fn delete_implementation_rule(pool: &SqlitePool, id: &str) -> Result<(
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Delete implementation rule failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Delete implementation rule failed: {e}")))?;
Ok(())
}
@@ -757,7 +757,7 @@ pub async fn set_setting(pool: &SqlitePool, key: &str, value: &str) -> Result<()
.bind(value)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Set setting failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Set setting failed: {e}")))?;
Ok(())
}
@@ -766,7 +766,7 @@ pub async fn get_setting(pool: &SqlitePool, key: &str) -> Result<Option<String>>
.bind(key)
.fetch_optional(pool)
.await
.map_err(|e| KonError::StorageError(format!("Get setting failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Get setting failed: {e}")))?;
Ok(row.map(|r| r.get("value")))
}
@@ -809,7 +809,7 @@ pub struct TranscriptRow {
pub anti_hallucination: bool,
pub created_at: String,
// Task 2.5 — transcripts_meta (migration v5). Persists the UI metadata
// that previously lived in the removed localStorage `kon_history` cache.
// that previously lived in the removed localStorage `magnotia_history` cache.
pub starred: bool,
pub manual_tags: String,
pub template: String,
@@ -944,7 +944,7 @@ fn implementation_rule_row_from(r: sqlx::sqlite::SqliteRow) -> ImplementationRul
// 1. The DB triggers `trg_protect_default_profile_delete` /
// `trg_protect_default_profile_rename` from migration v6.
// 2. Rust-layer fail-fast checks below that short-circuit BEFORE the
// query hits sqlite, so UI callers get a friendly KonError::StorageError
// query hits sqlite, so UI callers get a friendly MagnotiaError::StorageError
// instead of an opaque `SQLITE_CONSTRAINT_TRIGGER` wrapped in text.
pub async fn list_profiles(pool: &SqlitePool) -> Result<Vec<ProfileRow>> {
@@ -952,7 +952,7 @@ pub async fn list_profiles(pool: &SqlitePool) -> Result<Vec<ProfileRow>> {
sqlx::query("SELECT id, name, initial_prompt, created_at FROM profiles ORDER BY name ASC")
.fetch_all(pool)
.await
.map_err(|e| KonError::StorageError(format!("List profiles failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("List profiles failed: {e}")))?;
Ok(rows.iter().map(profile_row_from).collect())
}
@@ -961,7 +961,7 @@ pub async fn get_profile(pool: &SqlitePool, id: &str) -> Result<Option<ProfileRo
.bind(id)
.fetch_optional(pool)
.await
.map_err(|e| KonError::StorageError(format!("Get profile failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Get profile failed: {e}")))?;
Ok(row.as_ref().map(profile_row_from))
}
@@ -981,7 +981,7 @@ pub async fn create_profile(
.bind(initial_prompt)
.fetch_one(pool)
.await
.map_err(|e| KonError::StorageError(format!("Create profile failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Create profile failed: {e}")))?;
Ok(profile_row_from(&row))
}
@@ -999,12 +999,12 @@ pub async fn update_profile(
initial_prompt: &str,
) -> Result<()> {
if id == crate::DEFAULT_PROFILE_ID && name != "Default" {
return Err(KonError::StorageError(
return Err(MagnotiaError::StorageError(
"Default profile cannot be renamed".into(),
));
}
if id != crate::DEFAULT_PROFILE_ID && name == "Default" {
return Err(KonError::StorageError(
return Err(MagnotiaError::StorageError(
"Cannot rename another profile to 'Default'".into(),
));
}
@@ -1014,7 +1014,7 @@ pub async fn update_profile(
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Update profile failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Update profile failed: {e}")))?;
Ok(())
}
@@ -1023,13 +1023,13 @@ pub async fn update_profile(
/// ON DELETE CASCADE on `profile_terms.profile_id` cleans up children.
pub async fn delete_profile(pool: &SqlitePool, id: &str) -> Result<()> {
if id == crate::DEFAULT_PROFILE_ID {
return Err(KonError::StorageError(
return Err(MagnotiaError::StorageError(
"Default profile cannot be deleted".into(),
));
}
let transcript_count = transcript_count_for_profile(pool, id).await?;
if transcript_count > 0 {
return Err(KonError::StorageError(format!(
return Err(MagnotiaError::StorageError(format!(
"Cannot delete profile while {transcript_count} transcript(s) still reference it; reassign transcripts first"
)));
}
@@ -1037,7 +1037,7 @@ pub async fn delete_profile(pool: &SqlitePool, id: &str) -> Result<()> {
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Delete profile failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Delete profile failed: {e}")))?;
Ok(())
}
@@ -1052,7 +1052,7 @@ pub async fn list_profile_terms(
.bind(profile_id)
.fetch_all(pool)
.await
.map_err(|e| KonError::StorageError(format!("List profile terms failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("List profile terms failed: {e}")))?;
Ok(rows.iter().map(profile_term_row_from).collect())
}
@@ -1078,7 +1078,7 @@ pub async fn add_profile_term(
.bind(note)
.fetch_one(pool)
.await
.map_err(|e| KonError::StorageError(format!("Add profile term failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Add profile term failed: {e}")))?;
Ok(profile_term_row_from(&row))
}
@@ -1087,7 +1087,7 @@ pub async fn delete_profile_term(pool: &SqlitePool, id: &str) -> Result<()> {
.bind(id)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Delete profile term failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Delete profile term failed: {e}")))?;
Ok(())
}
@@ -1096,7 +1096,7 @@ async fn profile_exists(pool: &SqlitePool, id: &str) -> Result<bool> {
.bind(id)
.fetch_optional(pool)
.await
.map_err(|e| KonError::StorageError(format!("Profile existence check failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Profile existence check failed: {e}")))?;
Ok(exists.is_some())
}
@@ -1105,7 +1105,7 @@ async fn transcript_count_for_profile(pool: &SqlitePool, id: &str) -> Result<i64
.bind(id)
.fetch_one(pool)
.await
.map_err(|e| KonError::StorageError(format!("Profile transcript count failed: {e}")))
.map_err(|e| MagnotiaError::StorageError(format!("Profile transcript count failed: {e}")))
}
// --- Error Logging ---
@@ -1139,7 +1139,7 @@ pub async fn log_error(
.bind(metadata)
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Error log failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Error log failed: {e}")))?;
Ok(())
}
@@ -1171,7 +1171,7 @@ pub async fn prune_error_log(pool: &SqlitePool, keep_days: i64) -> Result<u64> {
.bind(format!("-{keep_days} days"))
.execute(pool)
.await
.map_err(|e| KonError::StorageError(format!("Prune error_log failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Prune error_log failed: {e}")))?;
Ok(result.rows_affected())
}
@@ -1183,7 +1183,7 @@ pub async fn list_recent_errors(pool: &SqlitePool, limit: i64) -> Result<Vec<Err
.bind(limit)
.fetch_all(pool)
.await
.map_err(|e| KonError::StorageError(format!("Read error_log failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("Read error_log failed: {e}")))?;
Ok(rows
.into_iter()
@@ -1203,7 +1203,7 @@ pub async fn list_recent_errors(pool: &SqlitePool, limit: i64) -> Result<Vec<Err
// Phase 2 of the feature-complete roadmap: capture thumbs + corrections on
// AI-generated output so the prompt builder can inject recent examples as
// few-shot exemplars. Storage-only here; the prompt-conditioning logic lives
// in kon-llm. Retrieval returns the most recent rows, narrowed to the
// in magnotia-llm. Retrieval returns the most recent rows, narrowed to the
// active profile when provided so feedback does not cross profiles.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -1264,7 +1264,7 @@ pub struct FeedbackRow {
pub async fn record_feedback(pool: &SqlitePool, params: RecordFeedbackParams) -> Result<i64> {
if !matches!(params.rating, -1..=1) {
return Err(KonError::StorageError(format!(
return Err(MagnotiaError::StorageError(format!(
"invalid feedback rating {} (must be -1, 0, or 1)",
params.rating
)));
@@ -1288,7 +1288,7 @@ pub async fn record_feedback(pool: &SqlitePool, params: RecordFeedbackParams) ->
.bind(profile_id)
.fetch_one(pool)
.await
.map_err(|e| KonError::StorageError(format!("record_feedback failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("record_feedback failed: {e}")))?;
Ok(row.get::<i64, _>("id"))
}
@@ -1325,7 +1325,7 @@ pub async fn list_feedback_examples(
.bind(limit)
.fetch_all(pool)
.await
.map_err(|e| KonError::StorageError(format!("list_feedback_examples failed: {e}")))?;
.map_err(|e| MagnotiaError::StorageError(format!("list_feedback_examples failed: {e}")))?;
Ok(rows
.into_iter()
@@ -2430,7 +2430,7 @@ mod tests {
#[tokio::test]
async fn init_readonly_rejects_writes_and_serves_reads() {
let dir = std::env::temp_dir().join(format!("kon-storage-ro-{}", std::process::id()));
let dir = std::env::temp_dir().join(format!("magnotia-storage-ro-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let path = dir.join("ro.db");
let _ = std::fs::remove_file(&path);
@@ -2482,7 +2482,7 @@ mod tests {
#[tokio::test]
async fn init_readonly_fails_when_db_missing() {
let path = std::env::temp_dir().join(format!(
"kon-storage-ro-missing-{}.db",
"magnotia-storage-ro-missing-{}.db",
std::process::id()
));
let _ = std::fs::remove_file(&path);