fix(desktop): republish agent identity records when a persona rename propagates#2607
Open
SeanGearin wants to merge 1 commit into
Open
fix(desktop): republish agent identity records when a persona rename propagates#2607SeanGearin wants to merge 1 commit into
SeanGearin wants to merge 1 commit into
Conversation
…propagates Signed-off-by: Sean Gearin <sgearin@gmail.com>
SeanGearin
force-pushed
the
fix-2423-agent-identity-republish
branch
from
July 23, 2026 20:20
81be1c0 to
63a53dc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Part of #2423 (renaming personal agents desynchronises identity).
Renaming an agent definition (persona) propagates the new display name to its
linked agent instances (
propagate_persona_name_renameindesktop/src-tauri/src/commands/personas/mod.rs) and savesmanaged-agents.json— but, unlike the instance-rename path(
update_managed_agent), it never re-retains the renamed instances' kind:30177managed-agent identity records.
record.nameis part of the published identityprojection (
agent_event_content), so after a persona rename:managed-agents.jsonsays the NEW name,the OLD name, with the OLD
created_at.The stale identity record stays live on the relay until the next app launch,
when the boot-time reconcile (
reconcile_agents_in_dir) finally notices thecontent diff and republishes. Until that restart, any surface that resolves
agents from kind:30177 records (second desktop of the same owner, CLI, other
NIP-AP clients) sees the OLD name bound to the agent pubkey while the kind:0
profile already shows the NEW one — the name→identity binding desync described
in #2423, and consistent with the report's observation that repairing state
required "a separate restart".
Fix
managed_agents::reconcile::retain_agent_record(conn, keys, record) -> Result<bool, String>— one shared content-diff + monotonic-
created_at-bump engine (returnswhether a row was rewritten).
reconcile_agents_in_dirnow calls it perrecord (behavior unchanged; existing reconcile tests still pass).
commands::agents::retain_managed_agent_pendingdelegates to the sharedengine instead of carrying a duplicate implementation (same semantics:
projection-equality no-op guard, monotonic bump,
pending_sync = 1).update_persona(Phase 1, still under the store lock, aftersave_managed_agents): callretain_managed_agent_pendingfor every recordthe rename propagated to — mirroring
update_managed_agent. Avatar-onlyedits are deliberately excluded (the avatar is not part of the kind:30177
projection; retaining would be a guaranteed no-op).
No new events, kinds, or APIs — this uses the existing signed-event retention
and flush pipeline, per CONTRIBUTING's guidance to prefer a signed Nostr event
and the existing ingest path over endpoint-specific JSON APIs.
Out of scope (deliberately)
territory (and largely superseded by the merged rollback in fix(desktop): refresh cached channel member names #2258).
repair for stale identities: TS-side, noted in [Bug] Renaming or re-adding personal agents can desynchronise identity and break @mentions #2423, not touched here.
Test evidence
Two new unit tests in
desktop/src-tauri/src/managed_agents/reconcile/tests.rs(same harness as the existing reconcile tests — tempdir + retention.db + fresh
keys, no AppHandle):
rename_re_retains_identity_record_with_new_name— retain "Fizz", confirmflush, rename to "Spark", re-retain: row keeps the pubkey coordinate,
carries the new name only, is
pending_sync, and itscreated_atisstrictly past the retained head (replaceable-event acceptance).
retain_agent_record_is_noop_when_unchanged— an unchanged projection doesnot rewrite the row and produces zero
pending_syncchurn.Ran scoped per CONTRIBUTING build discipline (from
desktop/src-tauri):Full
buzz-desktoplib suite: 1562 passed, 0 failed, 13 ignored —including all 12
managed_agents::reconciletests (10 pre-existing, allunmodified in behavior, plus the 2 new regression tests above).
Links
(kind:0 sync-failure surfacing), merged fix(desktop): refresh cached channel member names #2258 (instance-rename rollback).