Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(auto-improve): release a scheduler claim when the review fails
Abhishek Sharmad9406ebbf12e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9c59817a..4267d747 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -25,6 +25,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0model ids, and which model goes through the Responses endpoint (#763).### Fixed+- A failed scheduled `auto_improve` review no longer removes its session from+ the queue permanently. The scheduler claims a session before reviewing it,+ and the candidate query excludes any session that holds a claim — but nothing+ ever released one, so a review that failed (a hung provider call, or a+ proposal the reviewer could not stage) left a claim with no run row and that+ session was skipped by every later tick. The state was silent: the tick+ reported `errors=1` once and clean runs from then on, and the only exit was a+ hand-written `DELETE`. A claim now records the failure and releases, so the+ next tick retries it, and parks after 3 attempts with the last error kept so a+ deterministic failure stops costing a review every tick instead of vanishing.+ The tick summary counts `parked` separately from `errors`. (#833)- The Windows Docker wrapper (`bin/ai-memory.ps1`) now forwards the sameprovider credentials and host-config env vars as the POSIX wrapper into thehelper container. A host-exported `GEMINI_API_KEY` / `GOOGLE_API_KEY`,diff --git a/crates/ai-memory-consolidate/src/auto_improve_schedule.rs b/crates/ai-memory-consolidate/src/auto_improve_schedule.rsindex 2ca284c7..d5399d96 100644--- a/crates/ai-memory-consolidate/src/auto_improve_schedule.rs+++ b/crates/ai-memory-consolidate/src/auto_improve_schedule.rs@@ -107,6 +107,10 @@ pub struct ScheduledAutoImproveTickOutcome {pub skipped: usize,/// Per-scope/per-session failures, logged and counted, not fatal.pub errors: usize,+ /// Sessions whose claim spent its last attempt this tick and is now parked.+ /// Counted separately from `errors` because it is the terminal state an+ /// operator has to act on, not just another retryable failure (#833).+ pub parked: usize,/// Cross-session ("experience") passes that ran this tick.pub experience_runs: usize,}@@ -325,11 +329,48 @@ pub async fn run_auto_improve_scheduler_tick(}Err(e) => {outcome.errors += 1;+ // #833: the claim is this session's only in-flight marker and the+ // candidate query excludes on it, so leaving it behind dropped the+ // session from every future tick — silently, because the tick+ // reports `errors=1` once and clean runs forever after. Release it+ // so the next tick retries, and let the attempt counter park it+ // once a deterministic failure has proved it will not recover.+ let attempts = match ctx+ .writer+ .record_auto_improve_claim_failure(+ ctx.workspace_id,+ ctx.project_id,+ candidate.session_id,+ &e.to_string(),+ )+ .await+ {+ Ok(attempts) => Some(attempts),+ Err(release_err) => {+ // The review already failed; a failed release is a second,+ // separate fault and must not mask the first.+ tracing::warn!(+ workspace = %scope.workspace_name,+ project = %scope.project_name,+ session_id = %candidate.session_id,+ error = %release_err,+ "scheduled auto-improve claim release failed"+ );+ None+ }+ };+ let parked = attempts+ .is_some_and(|n| n >= ai_memory_store::AUTO_IMPROVE_CLAIM_MAX_ATTEMPTS);+ if parked {+ outcome.parked += 1;+ }tracing::warn!(workspace = %scope.workspace_name,project = %scope.project_name,session_id = %candidate.session_id,error = %e,+ attempts = attempts.unwrap_or(0),+ parked,"scheduled auto-improve failed");}diff --git a/crates/ai-memory-store/migrations/V65__auto_improve_claim_attempts.sql b/crates/ai-memory-store/migrations/V65__auto_improve_claim_attempts.sqlnew file mode 100644index 00000000..bdf54c47--- /dev/null+++ b/crates/ai-memory-store/migrations/V65__auto_improve_claim_attempts.sql@@ -0,0 +1,30 @@+-- Make a scheduler claim releasable (#833).+--+-- `auto_improve_scheduler_claims` was written once, by `INSERT OR IGNORE`, and+-- never deleted or expired. The candidate query in `auto_improve_candidate_sessions`+-- excludes a session that has a claim OR a run, so a review that failed — a hung+-- provider call, or a proposal the reviewer could not stage — left a claim with no+-- run and removed that session from every future tick. The state was silent: the+-- tick reported `errors=1` once and clean runs forever after.+--+-- A claim now carries its own outcome:+--+-- attempts = 0 in flight (just claimed)+-- 0 < attempts < max failed and retryable; the next tick picks it up+-- attempts >= max parked, with `last_error` for the operator+--+-- `attempts` defaults to 0 so existing rows keep meaning "in flight". That is the+-- conservative reading for a row written by an older version: those claims are the+-- leaked ones this fixes, and a release path that resurrected them silently would+-- re-review sessions an operator may have already handled by hand. `ai-memory+-- auto-improve --session-id` remains the way to drive one of them.++ALTER TABLE auto_improve_scheduler_claims ADD COLUMN attempts INTEGER NOT NULL DEFAULT 0;+ALTER TABLE auto_improve_scheduler_claims ADD COLUMN last_error TEXT;+ALTER TABLE auto_improve_scheduler_claims ADD COLUMN last_failed_at INTEGER;++-- The candidate query filters claims by `attempts`, and the parked-claim listing+-- reads the scope. Both ride the existing scope+session index for lookup; this+-- index keeps the "which claims are parked" scan off a table scan.+CREATE INDEX idx_auto_improve_scheduler_claims_attempts+ ON auto_improve_scheduler_claims(workspace_id, project_id, attempts);diff --git a/crates/ai-memory-store/src/api_credentials.rs b/crates/ai-memory-store/src/api_credentials.rsindex cef85c04..7af28525 100644--- a/crates/ai-memory-store/src/api_credentials.rs+++ b/crates/ai-memory-store/src/api_credentials.rs@@ -411,7 +411,7 @@ mod tests {|row| row.get(0),).unwrap();- assert_eq!(version, 64, "update the pin when adding a migration");+ assert_eq!(version, 65, "update the pin when adding a migration");let cols: i64 = conn.query_row("SELECT COUNT(*) FROM pragma_table_info('users') WHERE name = 'token_hash'",diff --git a/crates/ai-memory-store/src/auto_improve.rs b/crates/ai-memory-store/src/auto_improve.rsindex 923d1b8c..1d294eb4 100644--- a/crates/ai-memory-store/src/auto_improve.rs+++ b/crates/ai-memory-store/src/auto_improve.rs@@ -559,11 +559,25 @@ pub fn mark_experience_pass_run(Ok(())}+/// Maximum scheduled review attempts for one session before its claim parks.+///+/// A parked claim stops being a candidate and keeps `last_error` so an operator+/// can see why, rather than the session silently vanishing from the queue (#833).+/// Three is enough to ride out a flaky provider and few enough that a+/// deterministic failure — a proposal the reviewer cannot stage, say — stops+/// costing a review every tick.+pub const AUTO_IMPROVE_CLAIM_MAX_ATTEMPTS: u32 = 3;+/// Atomically claim one ended session for background review. Returns `true`/// only for the first claimer: the insert requires the session to be past/// the scope's watermark and not already covered by a run, so concurrent/// schedulers and restarts cannot double-review a session.///+/// A claim left by a *failed* review is re-armed rather than skipped, so the+/// session is retried while it still has attempts left (#833). A claim that is+/// in flight (`last_failed_at IS NULL`) or parked (`attempts` exhausted) does+/// not conflict-update, so this still returns `false` for both.+////// # Errors/// Returns an error when the underlying SQLite statements fail.pub fn claim_scheduler_session(@@ -576,7 +590,7 @@ pub fn claim_scheduler_session(let now = Timestamp::now().as_microsecond();let tx = conn.transaction()?;let inserted = tx.execute(- "INSERT OR IGNORE INTO auto_improve_scheduler_claims \+ "INSERT INTO auto_improve_scheduler_claims \(workspace_id, project_id, session_id, claimed_at) \SELECT ?1, ?2, ?3, ?4 \WHERE EXISTS ( \@@ -595,13 +609,19 @@ pub fn claim_scheduler_session(WHERE r.workspace_id = ?1 \AND r.project_id = ?2 \AND r.session_id = ?3 \- )",+ ) \+ ON CONFLICT(session_id) DO UPDATE SET \+ claimed_at = excluded.claimed_at, \+ last_failed_at = NULL \+ WHERE auto_improve_scheduler_claims.last_failed_at IS NOT NULL \+ AND auto_improve_scheduler_claims.attempts < ?6",params![workspace_id.as_bytes(),project_id.as_bytes(),session_id.as_bytes(),now,ended_at,+ AUTO_IMPROVE_CLAIM_MAX_ATTEMPTS,],)?;if inserted == 1 {@@ -616,6 +636,58 @@ pub fn claim_scheduler_session(Ok(inserted == 1)}+/// Record that a scheduled review of `session_id` failed, releasing its claim+/// for another attempt and returning the new attempt count.+///+/// The claim is the scheduler's only in-flight marker and nothing used to clear+/// it, so a failed review excluded its session from every later tick with no+/// run row and no operator-visible state (#833). Recording the failure here+/// keeps the row — it is the memory of how many attempts have been spent, and+/// carries `last_error` once the session parks — while making the session a+/// candidate again until `AUTO_IMPROVE_CLAIM_MAX_ATTEMPTS` is reached.+///+/// Returns `0` when no claim exists, which is the manual path: `ai-memory+/// auto-improve --session-id` does not claim, so a failure there has no claim+/// to release.+///+/// # Errors+/// Returns an error when the underlying SQLite statement fails.+pub fn record_claim_failure(+ conn: &Connection,+ workspace_id: WorkspaceId,+ project_id: ProjectId,+ session_id: SessionId,+ error: &str,+) -> StoreResult<u32> {+ let now = Timestamp::now().as_microsecond();+ let updated = conn.execute(+ "UPDATE auto_improve_scheduler_claims \+ SET attempts = attempts + 1, last_error = ?4, last_failed_at = ?5 \+ WHERE workspace_id = ?1 AND project_id = ?2 AND session_id = ?3",+ params![+ workspace_id.as_bytes(),+ project_id.as_bytes(),+ session_id.as_bytes(),+ error,+ now,+ ],+ )?;+ if updated == 0 {+ return Ok(0);+ }+ let attempts: u32 = conn.query_row(+ "SELECT attempts FROM auto_improve_scheduler_claims \+ WHERE workspace_id = ?1 AND project_id = ?2 AND session_id = ?3",+ params![+ workspace_id.as_bytes(),+ project_id.as_bytes(),+ session_id.as_bytes(),+ ],+ |row| row.get(0),+ )?;+ Ok(attempts)+}+/// Persist one review run and stage its proposals as `pending`, all in one/// transaction. Validates per-proposal preconditions (create targets must/// not exist, update/patch targets must exist and — for patches — stilldiff --git a/crates/ai-memory-store/src/lib.rs b/crates/ai-memory-store/src/lib.rsindex 9ba87d21..f04f070a 100644--- a/crates/ai-memory-store/src/lib.rs+++ b/crates/ai-memory-store/src/lib.rs@@ -36,12 +36,13 @@ pub use fts_query::prepare_fts5_query;pub use api_credentials::{AuthenticatedApiUser, generate_api_key, preview_for as api_key_preview};pub use auto_improve::{- ApproveAutoImproveProposal, ApproveAutoImproveProposalResult, AutoImproveProposalDetail,- AutoImproveProposalEvent, AutoImproveProposalOperation, AutoImproveProposalStatus,- AutoImproveProposalSummary, AutoImproveRejectionSummary, AutoImproveTelemetryAggregate,- AutoImproveTelemetryCount, FailAutoImproveProposal, NewAutoImproveProposal,- OwnedAutoImproveProposalDetail, RejectAutoImproveProposal, SkippedProposal,- StageAutoImproveRun, StagedAutoImproveRun, StagedAutoImproveRunReport, artifact_path_for,+ AUTO_IMPROVE_CLAIM_MAX_ATTEMPTS, ApproveAutoImproveProposal, ApproveAutoImproveProposalResult,+ AutoImproveProposalDetail, AutoImproveProposalEvent, AutoImproveProposalOperation,+ AutoImproveProposalStatus, AutoImproveProposalSummary, AutoImproveRejectionSummary,+ AutoImproveTelemetryAggregate, AutoImproveTelemetryCount, FailAutoImproveProposal,+ NewAutoImproveProposal, OwnedAutoImproveProposalDetail, RejectAutoImproveProposal,+ SkippedProposal, StageAutoImproveRun, StagedAutoImproveRun, StagedAutoImproveRunReport,+ artifact_path_for,};pub use decay::{DecayParams, SALIENCE_MAX, SALIENCE_MIN, SALIENCE_STEP, retention_score,@@ -60,15 +61,15 @@ pub use ops::{};pub use reader::{ActivityWindow, AgentSessionCount, AuditEvent, AuditLogFilter, AutoImproveCandidateSession,- BriefPageBody, BriefingPage, BriefingSnapshot, ClientActivity, ContaminationFinding,- ContaminationReport, ContaminationSummary, ContradictionEdge, DecayCandidate, DecayTombstone,- DerivedIndexStatus, EmbeddingTripleCount, FeedbackFinding, GraphVia, HealthDetail, HealthPage,- ObservationHit, ObservationOrder, ObservationPage, ObservationPageResult, ObservationRecord,- OpenSession, PageAuthor, PageHit, PageHitWithMeta, PageLinks, PageMeta, PageSummary,- ProjectSummary, ReaderPool, ReindexTargetStatus, RelatedPage, RrfContributions, ScopeRow,- SearchExplain, SessionDependentRows, SessionEndDisposition, SessionSummary, SettledPage,- StatusCounts, StorageStatus, StoredEmbedding, StoredPageBody, WorkspaceScopeRow,- WorkspaceSummary, f32_vec_to_bytes,+ AutoImproveParkedClaim, BriefPageBody, BriefingPage, BriefingSnapshot, ClientActivity,+ ContaminationFinding, ContaminationReport, ContaminationSummary, ContradictionEdge,+ DecayCandidate, DecayTombstone, DerivedIndexStatus, EmbeddingTripleCount, FeedbackFinding,+ GraphVia, HealthDetail, HealthPage, ObservationHit, ObservationOrder, ObservationPage,+ ObservationPageResult, ObservationRecord, OpenSession, PageAuthor, PageHit, PageHitWithMeta,+ PageLinks, PageMeta, PageSummary, ProjectSummary, ReaderPool, ReindexTargetStatus, RelatedPage,+ RrfContributions, ScopeRow, SearchExplain, SessionDependentRows, SessionEndDisposition,+ SessionSummary, SettledPage, StatusCounts, StorageStatus, StoredEmbedding, StoredPageBody,+ WorkspaceScopeRow, WorkspaceSummary, f32_vec_to_bytes,};pub use retrieval_tuning::{RetrievalTuning, is_session_recall_query};pub use scope::{@@ -4073,6 +4074,149 @@ mod tests {assert_eq!(remaining[0].ended_at, same_ended_at);}+ // #833: a claim is the scheduler's in-flight marker, but the only writer was+ // `INSERT OR IGNORE` — nothing ever removed or expired a row. A review that+ // failed left the claim behind with no `auto_improve_runs` row, and the+ // candidate query excludes on the claim alone, so the session was dropped+ // from every future tick with no operator-visible state.+ #[tokio::test]+ async fn auto_improve_failed_claim_is_retried_then_parked() {+ let tmp = TempDir::new().unwrap();+ let store = Store::open(tmp.path()).unwrap();+ let ws = store+ .writer+ .get_or_create_workspace("default")+ .await+ .unwrap();+ let proj = store+ .writer+ .get_or_create_project(ws, "ai-memory", None)+ .await+ .unwrap();+ store+ .writer+ .ensure_auto_improve_scheduler_state(ws, proj)+ .await+ .unwrap();++ tokio::time::sleep(std::time::Duration::from_millis(1)).await;+ let session = SessionId::new();+ store+ .writer+ .begin_session(NewSession {+ id: session,+ workspace_id: ws,+ project_id: proj,+ agent_kind: AgentKind::OpenCode,+ cwd: None,+ actor_user: None,+ })+ .await+ .unwrap();+ store.writer.end_session(session, None).await.unwrap();++ let candidates = store+ .reader+ .auto_improve_candidate_sessions(ws, proj, 0, 10)+ .await+ .unwrap();+ assert_eq!(candidates.len(), 1);++ // Every attempt but the last releases the session back to the queue.+ for attempt in 1..AUTO_IMPROVE_CLAIM_MAX_ATTEMPTS {+ let candidates = store+ .reader+ .auto_improve_candidate_sessions(ws, proj, 0, 10)+ .await+ .unwrap();+ assert_eq!(+ candidates.len(),+ 1,+ "session should still be a candidate before attempt {attempt}"+ );+ assert!(+ store+ .writer+ .claim_auto_improve_scheduler_session(+ ws,+ proj,+ candidates[0].session_id,+ candidates[0].ended_at,+ )+ .await+ .unwrap()+ );+ // In flight: not a candidate while the review is running.+ assert!(+ store+ .reader+ .auto_improve_candidate_sessions(ws, proj, 0, 10)+ .await+ .unwrap()+ .is_empty(),+ "an in-flight claim must not be handed out twice"+ );+ let attempts = store+ .writer+ .record_auto_improve_claim_failure(+ ws,+ proj,+ session,+ "error decoding response body",+ )+ .await+ .unwrap();+ assert_eq!(attempts, attempt);+ }++ // The final failure parks the session instead of looping forever.+ let candidates = store+ .reader+ .auto_improve_candidate_sessions(ws, proj, 0, 10)+ .await+ .unwrap();+ assert_eq!(candidates.len(), 1);+ store+ .writer+ .claim_auto_improve_scheduler_session(ws, proj, session, candidates[0].ended_at)+ .await+ .unwrap();+ let attempts = store+ .writer+ .record_auto_improve_claim_failure(+ ws,+ proj,+ session,+ "create proposal target already exists",+ )+ .await+ .unwrap();+ assert_eq!(attempts, AUTO_IMPROVE_CLAIM_MAX_ATTEMPTS);+ assert!(+ store+ .reader+ .auto_improve_candidate_sessions(ws, proj, 0, 10)+ .await+ .unwrap()+ .is_empty(),+ "an exhausted claim stays parked rather than spinning every tick"+ );++ // ...and it is visible, which a bare claim never was.+ let parked = store+ .reader+ .auto_improve_parked_claims(ws, proj)+ .await+ .unwrap();+ assert_eq!(parked.len(), 1);+ assert_eq!(parked[0].session_id, session);+ assert_eq!(parked[0].attempts, AUTO_IMPROVE_CLAIM_MAX_ATTEMPTS);+ assert_eq!(+ parked[0].last_error.as_deref(),+ Some("create proposal target already exists")+ );+ }+#[tokio::test]async fn auto_improve_scheduler_claim_is_unique_across_store_instances() {let tmp = TempDir::new().unwrap();diff --git a/crates/ai-memory-store/src/reader.rs b/crates/ai-memory-store/src/reader.rsindex bbb00efa..d160e835 100644--- a/crates/ai-memory-store/src/reader.rs+++ b/crates/ai-memory-store/src/reader.rs@@ -650,6 +650,23 @@ pub struct AutoImproveCandidateSession {pub ended_at: i64,}+/// A scheduler claim that has spent every review attempt (#833).+///+/// The session is no longer a candidate, so this is the only place its state is+/// visible: without it a failed review removed a session from the queue with+/// nothing but a single `errors=1` in one tick's log to show for it.+#[derive(Debug, Clone, PartialEq, Eq)]+pub struct AutoImproveParkedClaim {+ /// Session whose scheduled review kept failing.+ pub session_id: SessionId,+ /// How many attempts were spent.+ pub attempts: u32,+ /// The last failure, verbatim, as the scheduler saw it.+ pub last_error: Option<String>,+ /// When the last attempt failed, in Unix microseconds.+ pub last_failed_at: Option<i64>,+}+/// Open session selected for manual finalization.#[derive(Debug, Clone, PartialEq, Eq)]pub struct OpenSession {@@ -3290,6 +3307,10 @@ impl ReaderPool {WHERE c.workspace_id = s.workspace_id \AND c.project_id = s.project_id \AND c.session_id = s.id \+ AND NOT ( \+ c.last_failed_at IS NOT NULL \+ AND c.attempts < ?6 \+ ) \) \AND NOT EXISTS ( \SELECT 1 FROM auto_improve_runs r \@@ -3307,6 +3328,7 @@ impl ReaderPool {watermark,cutoff,limit.min(i64::MAX as usize) as i64,+ crate::auto_improve::AUTO_IMPROVE_CLAIM_MAX_ATTEMPTS,],|row| {let id_bytes: Vec<u8> = row.get(0)?;@@ -3326,6 +3348,58 @@ impl ReaderPool {.await}+ /// Scheduler claims that have spent every attempt and no longer produce a+ /// candidate, newest failure first.+ ///+ /// A parked claim is a session the scheduler has given up on. It is excluded+ /// from `auto_improve_candidate_sessions` exactly like an in-flight claim,+ /// so without this listing the two are indistinguishable from outside the+ /// database — which is what made the original leak silent (#833).+ ///+ /// # Errors+ /// Returns an error when the underlying SQLite statement fails.+ pub async fn auto_improve_parked_claims(+ &self,+ workspace_id: WorkspaceId,+ project_id: ProjectId,+ ) -> StoreResult<Vec<AutoImproveParkedClaim>> {+ self.with_conn(move |conn| {+ let mut stmt = conn.prepare_cached(+ "SELECT session_id, attempts, last_error, last_failed_at \+ FROM auto_improve_scheduler_claims \+ WHERE workspace_id = ?1 AND project_id = ?2 AND attempts >= ?3 \+ ORDER BY last_failed_at DESC",+ )?;+ let rows = stmt.query_map(+ params![+ workspace_id.as_bytes(),+ project_id.as_bytes(),+ crate::auto_improve::AUTO_IMPROVE_CLAIM_MAX_ATTEMPTS,+ ],+ |row| {+ Ok((+ row.get::<_, Vec<u8>>(0)?,+ row.get::<_, u32>(1)?,+ row.get::<_, Option<String>>(2)?,+ row.get::<_, Option<i64>>(3)?,+ ))+ },+ )?;+ let mut out = Vec::new();+ for row in rows {+ let (id_bytes, attempts, last_error, last_failed_at) = row?;+ out.push(AutoImproveParkedClaim {+ session_id: SessionId::from_slice(&id_bytes)?,+ attempts,+ last_error,+ last_failed_at,+ });+ }+ Ok(out)+ })+ .await+ }+/// Look up the `(workspace_id, project_id)` a session belongs to./// Returns `None` when no such session row exists.///diff --git a/crates/ai-memory-store/src/writer.rs b/crates/ai-memory-store/src/writer.rsindex 6150676e..3993eb56 100644--- a/crates/ai-memory-store/src/writer.rs+++ b/crates/ai-memory-store/src/writer.rs@@ -602,6 +602,13 @@ pub(crate) enum WriteCmd {ended_at: i64,reply: oneshot::Sender<StoreResult<bool>>,},+ RecordAutoImproveClaimFailure {+ workspace_id: WorkspaceId,+ project_id: ProjectId,+ session_id: SessionId,+ error: String,+ reply: oneshot::Sender<StoreResult<u32>>,+ },RecordMaintenanceJobSuccess {job: crate::maintenance::MaintenanceJob,reply: oneshot::Sender<StoreResult<()>>,@@ -2503,6 +2510,31 @@ impl WriterHandle {rx.await.map_err(|_| StoreError::WriterClosed)?}+ /// Record a failed scheduled review, releasing the session's claim for+ /// another attempt and returning the new attempt count. Returns `0` when the+ /// session holds no claim, which is the manual path.+ ///+ /// # Errors+ /// Returns an error when the writer is closed or the statement fails.+ pub async fn record_auto_improve_claim_failure(+ &self,+ workspace_id: WorkspaceId,+ project_id: ProjectId,+ session_id: SessionId,+ error: &str,+ ) -> StoreResult<u32> {+ let (tx, rx) = oneshot::channel();+ self.send(WriteCmd::RecordAutoImproveClaimFailure {+ workspace_id,+ project_id,+ session_id,+ error: error.to_owned(),+ reply: tx,+ })+ .await?;+ rx.await.map_err(|_| StoreError::WriterClosed)?+ }+/// Persist a global maintenance job's successful completion time.pub async fn record_maintenance_job_success(&self,@@ -3539,6 +3571,22 @@ fn worker_loop(mut conn: Connection, mut rx: mpsc::Receiver<WriteCmd>) {);send_or_warn(reply, result, "claim_auto_improve_scheduler_session");}+ WriteCmd::RecordAutoImproveClaimFailure {+ workspace_id,+ project_id,+ session_id,+ error,+ reply,+ } => {+ let result = crate::auto_improve::record_claim_failure(+ &conn,+ workspace_id,+ project_id,+ session_id,+ &error,+ );+ send_or_warn(reply, result, "record_auto_improve_claim_failure");+ }WriteCmd::RecordMaintenanceJobSuccess { job, reply } => {let result = crate::maintenance::record_success(&conn, job);send_or_warn(reply, result, "record_maintenance_job_success");