From df51dce5395bbc95eb2ca5eee0a60ad7efdacad1 Mon Sep 17 00:00:00 2001 From: Duncan Date: Wed, 19 Aug 2026 11:08:30 -0400 Subject: [PATCH] refactor(desktop): make identity-transition coordinator runtime-generic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Widen run_identity_transition, import_identity_blocking, and their two drain/compensate helpers to , plus the shared drain_scope_runtimes on the apply_workspace path. Monomorphization makes the existing Wry call sites (import_identity, import_recovered_identity, apply_workspace) compile to identical code — behavior-neutral. This lets the P26-C1 coordinator schedules be driven under mock_builder()'s App in the forthcoming §7 fixtures. Co-authored-by: Will Pfleger Signed-off-by: Will Pfleger --- .../src/commands/identity_transition.rs | 16 ++++++++-------- .../src/managed_agents/runtime_commands.rs | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/desktop/src-tauri/src/commands/identity_transition.rs b/desktop/src-tauri/src/commands/identity_transition.rs index 9afe9b158a..63fba8ddc4 100644 --- a/desktop/src-tauri/src/commands/identity_transition.rs +++ b/desktop/src-tauri/src/commands/identity_transition.rs @@ -10,8 +10,8 @@ use tauri::Manager; /// Drain live managed-agent runtimes for identity import (Layer 2 protocol). /// Caller must hold `managed_agent_runtime_transition`. Returns stopped entries /// or `Err((stopped, msg))` on failure. -fn drain_managed_agent_runtimes_for_import( - app: &tauri::AppHandle, +fn drain_managed_agent_runtimes_for_import( + app: &tauri::AppHandle, state: &AppState, ) -> Result< Vec, @@ -33,8 +33,8 @@ fn drain_managed_agent_runtimes_for_import( /// without any interleave window. `scope`/`rt_guard` are `None` on the no-scope /// path (nothing drained); either being `None` skips compensation. Returns a /// combined diagnostic string when compensation itself fails. -fn compensate_import_drain( - app_handle: &tauri::AppHandle, +fn compensate_import_drain( + app_handle: &tauri::AppHandle, stopped: &[crate::managed_agents::DrainJournalEntry], scope: Option<&crate::managed_agents::scope::WorkspaceAgentScope>, rt_guard: Option>, @@ -102,8 +102,8 @@ fn compensate_import_drain( /// runtimes compensate, but revoked owner-identity durable capabilities stay /// revoked. This is design-conformant fail-closed churn, not a split state — /// see `CROSS_WORKSPACE_AGENT_LIBRARY.md` §3.3a (barrier sequence is fixed). -pub(crate) async fn run_identity_transition( - app_handle: tauri::AppHandle, +pub(crate) async fn run_identity_transition( + app_handle: tauri::AppHandle, nsec: String, password: Option, commit_fence: Option>>, @@ -200,8 +200,8 @@ pub(crate) fn commit_under_fence( /// either compensates (cancelled during drain, before the fence is taken) or /// loses to the committed recovery (cancelled after the fenced commit begins). /// Normal import supplies `None` + an always-`Ok(())` check. -fn import_identity_blocking( - app_handle: tauri::AppHandle, +fn import_identity_blocking( + app_handle: tauri::AppHandle, nsec: String, password: Option, commit_fence: Option>>, diff --git a/desktop/src-tauri/src/managed_agents/runtime_commands.rs b/desktop/src-tauri/src/managed_agents/runtime_commands.rs index d8b4aea287..4c5c6347fc 100644 --- a/desktop/src-tauri/src/managed_agents/runtime_commands.rs +++ b/desktop/src-tauri/src/managed_agents/runtime_commands.rs @@ -717,8 +717,8 @@ pub(crate) fn execute_drain_journal_with_stop_fn( /// entries that were successfully killed (compensation restores these). /// `remaining` contains entries that were NOT attempted (due to early-exit on /// first failure). On success `remaining` is empty. -pub(crate) fn drain_scope_runtimes( - app: &AppHandle, +pub(crate) fn drain_scope_runtimes( + app: &AppHandle, state: &AppState, ) -> ( Vec,