refactor(desktop): make identity-transition coordinator runtime-generic

Widen run_identity_transition, import_identity_blocking, and their two
drain/compensate helpers to <R: tauri::Runtime>, 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<MockRuntime> in the forthcoming §7 fixtures.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This commit is contained in:
Duncan
2026-08-19 11:08:30 -04:00
parent b91754044b
commit df51dce539
2 changed files with 10 additions and 10 deletions

View File

@@ -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<R: tauri::Runtime>(
app: &tauri::AppHandle<R>,
state: &AppState,
) -> Result<
Vec<crate::managed_agents::DrainJournalEntry>,
@@ -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<R: tauri::Runtime>(
app_handle: &tauri::AppHandle<R>,
stopped: &[crate::managed_agents::DrainJournalEntry],
scope: Option<&crate::managed_agents::scope::WorkspaceAgentScope>,
rt_guard: Option<std::sync::MutexGuard<'_, ()>>,
@@ -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<R: tauri::Runtime>(
app_handle: tauri::AppHandle<R>,
nsec: String,
password: Option<String>,
commit_fence: Option<std::sync::Arc<std::sync::Mutex<()>>>,
@@ -200,8 +200,8 @@ pub(crate) fn commit_under_fence<T>(
/// 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<R: tauri::Runtime>(
app_handle: tauri::AppHandle<R>,
nsec: String,
password: Option<String>,
commit_fence: Option<std::sync::Arc<std::sync::Mutex<()>>>,

View File

@@ -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<R: tauri::Runtime>(
app: &AppHandle<R>,
state: &AppState,
) -> (
Vec<DrainJournalEntry>,