fix(desktop): re-sign stale retention events at flush - #5358
Draft
olympusbuildz wants to merge 1 commit into
Draft
fix(desktop): re-sign stale retention events at flush#5358olympusbuildz wants to merge 1 commit into
olympusbuildz wants to merge 1 commit into
Conversation
Replay of retained pre-signed kind:30177/30175/30176 events past the relay ±900s ingest window was rejected forever every 30s. Re-sign parameterized replaceables and kind:5 tombstones at publish time the same way archive requests already do. Co-authored-by: Olympusbuildz <Olympus.roots@outlook.com> Signed-off-by: Olympusbuildz <Olympus.roots@outlook.com>
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
Managed-agent retention can leave parameterized replaceables (kinds 30175–30178) and kind:5 tombstones stuck with
pending_sync = 1forever. Desktop re-publishes the retained pre-signedraw_eventevery ~30s; oncecreated_atfalls outside the relay ingest skew window the relay rejects every attempt and nothing ever clears.Root cause
flush_pending_events_atindesktop/src-tauri/src/managed_agents/persona_events.rsreplayed retained pre-signed events for most kinds.Relay ingest enforces
MAX_TIMESTAMP_DRIFT_SECS = 900. After that window:invalid: event timestamp too far from server timepending_sync = 1NIP-IA identity-archive requests already re-signed with a fresh timestamp at publish; parameterized replaceables and tombstones did not.
Fix
At flush/publish time, re-sign events that need a fresh timestamp via the same path as archive requests (
resign_with_fresh_timestamp):is_parameterized_replaceable)Preserves kind, tags, and content.
mark_syncedstill keys off the retained originalcreated_at+ content so local retention rows clear correctly after a successful publish.Helper:
needs_fresh_timestamp_at_publish.Why it matters
Without this, managed-agent persona/retention traffic can permanently hammer the relay with undeliverable events and never converge — a reliability bug for every desktop that retains those kinds across the ±15m window (sleep, offline, long-lived agents).
Test plan
persona_events/tests.rs(flush_barrier): fresh-timestamp re-sign for parameterized replaceables + kind:5;mark_syncedkeying unchangedjust cinot run on 16GB Mini for this change (desktop Tauri lib filter only) — happy to run or expand if maintainers wantraw_eventpast 15m, confirm next 30s flush is accepted andpending_syncclearsRisk / blast radius
created_atat sendcreated_at+content so we do not orphan retention rows after re-signClosest existing work
none found for this root cause (issue #4967 was open without a linked fix PR at open time)
Follow-ups
none deferred in-tree; optional maintainer ask: broader soak on long-lived BYOH desks
Fixes #4967