desktop: retire conflicted aggregate attempts

Delete an exact pending edit attempt after a proven relay conflict so the next edit can advance from newly hydrated authority instead of being blocked by a dead retained generation.

Co-authored-by: Carl <c7ebe626f000404285d3686e1dc74cc07cc60a9754a150041ba132e14bd3e2ec@buzz.block.builderlab.xyz>

Signed-off-by: Wes <wesbillman@users.noreply.github.com>
This commit is contained in:
Wes
2026-08-05 13:40:56 -06:00
parent d88f3f1544
commit 25fca37e01
2 changed files with 19 additions and 1 deletions

View File

@@ -940,7 +940,7 @@ pub async fn update_managed_agent(
let conn = crate::managed_agents::retention::open_retention_db(
&scope.db_path,
)?;
if !crate::managed_agents::retention::mark_managed_agent_aggregate_synced(
if !crate::managed_agents::retention::retire_managed_agent_aggregate(
&conn,
&pending.owner_pubkey,
&pending.agent_pubkey,

View File

@@ -131,6 +131,24 @@ pub struct RetainedManagedAgentAggregate {
pub local_authority_applied: bool,
}
pub fn retire_managed_agent_aggregate(
conn: &Connection,
owner_pubkey: &str,
agent_pubkey: &str,
generation: u64,
private_event_id: &str,
) -> Result<bool, String> {
let changed = conn
.execute(
"DELETE FROM managed_agent_aggregates
WHERE owner_pubkey = ?1 AND agent_pubkey = ?2
AND generation = ?3 AND private_event_id = ?4 AND pending_sync = 1",
params![owner_pubkey, agent_pubkey, generation as i64, private_event_id],
)
.map_err(|error| format!("failed to retire managed-agent aggregate: {error}"))?;
Ok(changed == 1)
}
pub fn seed_confirmed_managed_agent_aggregate(
conn: &Connection,
aggregate: &RetainedManagedAgentAggregate,