chore: stabilize current head before Phase 10a QC

This commit is contained in:
2026-05-10 23:00:25 +01:00
parent c95a5da077
commit b463c32f17
24 changed files with 238 additions and 89 deletions

View File

@@ -182,7 +182,9 @@ pub async fn update_transcript(
.bind(id)
.execute(pool)
.await
.map_err(|e| MagnotiaError::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 +193,9 @@ pub async fn update_transcript(
.bind(id)
.execute(pool)
.await
.map_err(|e| MagnotiaError::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 +204,9 @@ pub async fn update_transcript(
.bind(id)
.execute(pool)
.await
.map_err(|e| MagnotiaError::StorageError(format!("Update transcript failed: {e}")))?;
.map_err(|e| {
MagnotiaError::StorageError(format!("Update transcript failed: {e}"))
})?;
Ok(res.rows_affected())
}
(None, None) => Ok(0),
@@ -484,7 +490,9 @@ pub async fn complete_subtask_and_check_parent(pool: &SqlitePool, subtask_id: &s
.bind(&pid)
.execute(&mut *tx)
.await
.map_err(|e| MagnotiaError::StorageError(format!("Auto-complete parent failed: {e}")))?;
.map_err(|e| {
MagnotiaError::StorageError(format!("Auto-complete parent failed: {e}"))
})?;
}
}
@@ -708,7 +716,9 @@ pub async fn set_implementation_rule_enabled(
.bind(id)
.execute(pool)
.await
.map_err(|e| MagnotiaError::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(|| {
MagnotiaError::StorageError(format!(
@@ -731,7 +741,9 @@ pub async fn mark_implementation_rule_fired(
.bind(id)
.execute(pool)
.await
.map_err(|e| MagnotiaError::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(|| {
MagnotiaError::StorageError(format!(
@@ -745,7 +757,9 @@ pub async fn delete_implementation_rule(pool: &SqlitePool, id: &str) -> Result<(
.bind(id)
.execute(pool)
.await
.map_err(|e| MagnotiaError::StorageError(format!("Delete implementation rule failed: {e}")))?;
.map_err(|e| {
MagnotiaError::StorageError(format!("Delete implementation rule failed: {e}"))
})?;
Ok(())
}
@@ -2511,24 +2525,21 @@ mod tests {
let removed = prune_error_log(&pool, 90).await.unwrap();
assert_eq!(removed, 1, "only the 200-day row should be pruned");
let remaining: Vec<String> = sqlx::query_scalar(
"SELECT context FROM error_log ORDER BY id ASC",
)
.fetch_all(&pool)
.await
.unwrap();
let remaining: Vec<String> =
sqlx::query_scalar("SELECT context FROM error_log ORDER BY id ASC")
.fetch_all(&pool)
.await
.unwrap();
assert_eq!(remaining, vec!["recent".to_string(), "older".to_string()]);
// A 14-day window prunes the 30-day row too.
let removed = prune_error_log(&pool, 14).await.unwrap();
assert_eq!(removed, 1);
let remaining: Vec<String> = sqlx::query_scalar(
"SELECT context FROM error_log",
)
.fetch_all(&pool)
.await
.unwrap();
let remaining: Vec<String> = sqlx::query_scalar("SELECT context FROM error_log")
.fetch_all(&pool)
.await
.unwrap();
assert_eq!(remaining, vec!["recent".to_string()]);
}
}

View File

@@ -15,8 +15,7 @@ pub use database::{
list_profiles, list_recent_completions, list_recent_errors, list_subtasks, list_tasks,
list_transcripts, list_transcripts_paged, log_error, mark_implementation_rule_fired,
prune_error_log, record_feedback, search_transcripts, set_implementation_rule_enabled,
set_setting,
set_task_energy, uncomplete_task, update_profile, update_task, update_transcript,
set_setting, set_task_energy, uncomplete_task, update_profile, update_task, update_transcript,
update_transcript_meta, DailyCompletionCount, ErrorLogRow, FeedbackRow, FeedbackTargetType,
ImplementationRuleRow, InsertTranscriptParams, ProfileRow, ProfileTermRow,
RecordFeedbackParams, TaskRow, TranscriptRow,

View File

@@ -553,7 +553,9 @@ async fn run_migrations_slice(pool: &SqlitePool, migrations: &[(i64, &str, &str)
)
.execute(pool)
.await
.map_err(|e| MagnotiaError::StorageError(format!("Schema version table creation failed: {e}")))?;
.map_err(|e| {
MagnotiaError::StorageError(format!("Schema version table creation failed: {e}"))
})?;
let current: i64 = sqlx::query_scalar("SELECT COALESCE(MAX(version), 0) FROM schema_version")
.fetch_one(pool)
@@ -1178,7 +1180,8 @@ mod tests {
.map(|r| r.get::<String, _>("detail"))
.collect();
assert!(
plan.iter().any(|row| row.contains("idx_transcripts_profile_created")),
plan.iter()
.any(|row| row.contains("idx_transcripts_profile_created")),
"planner should use the composite index, got plan: {plan:?}",
);
}