Hmbown/CodeWhale · error

Failed to persist compaction: {persistence_error}

Error message

Failed to persist compaction: {persistence_error}

What it means

From trigger_compaction: the persistence closure (save_turn for the new compaction turn, then save_thread updating latest_turn_id/updated_at) returned Err. The in-memory engine state was already mutated (active_turn pushed, route_identity/route_model set), so memory and the durable store now disagree; the companion cleanup path attempts to remove the unaccepted records.

Source

Thrown at crates/tui/src/runtime_threads.rs:6454

                interrupt_requested: false,
                compaction_id: Some(compaction_id),
            });
            state.route_identity = route_identity;
            state.route_model = route_model;

            let persistence_result = (|| -> Result<()> {
                self.store.save_turn(&turn)?;
                current_thread.latest_turn_id = Some(turn_id.clone());
                current_thread.updated_at = now;
                self.store.save_thread(&current_thread)
            })();
            if let Err(persistence_error) = persistence_result {
                let cleanup_error = self.cleanup_unaccepted_turn_records(&turn_id, None).err();
                state.active_turn = None;
                state.route_identity = previous_active_route.0;
                state.route_model = previous_active_route.1;
                return match cleanup_error {
                    None => Err(anyhow!("Failed to persist compaction: {persistence_error}")),
                    Some(cleanup_error) => Err(anyhow!(
                        "Failed to persist compaction: {persistence_error}; cleanup also failed: {cleanup_error}"
                    )),
                };
            }

            self.register_runtime_usage_sink(&turn_id);
            let policy = RuntimePolicyProjection::from_persisted(
                &current_thread.mode,
                current_thread.permission_posture.as_deref(),
                current_thread.auto_approve,
            );
            engine.publish_turn_authority(
                policy.mode,
                current_thread.allow_shell,
                current_thread.trust_mode,
                policy.auto_approve(),
                policy.permission,

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Diagnose persistence_error (disk full, store lock, IO failure) and fix it before retrying compaction
  2. Retry compaction after recovery; the cleanup path should have removed the unaccepted turn record
  3. If cleanup also reported errors, check for an orphaned compaction turn in the store
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/tui/src/runtime_threads.rs:6454 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/143e976aee4057cf. Report an issue: GitHub.