feat(desktop): persona engram instantiation + fleet update + legacy sync gate#945
Draft
wpfleger96 wants to merge 2 commits into
Draft
feat(desktop): persona engram instantiation + fleet update + legacy sync gate#945wpfleger96 wants to merge 2 commits into
wpfleger96 wants to merge 2 commits into
Conversation
…ync gate Write a mem/persona engram (kind:30174) when creating an agent from a persona. The engram is NIP-44 encrypted under the agent-owner conversation key with an HMAC-blinded d-tag, conforming to the existing engram envelope contract. Content includes the persona snapshot plus provenance (owner pubkey, kind:30175, slug, content SHA-256 digest). Fleet update reconciles agent engrams against current persona content on app launch and on persona save. Comparison is digest-based (not timestamp) to handle clock skew and export/import round-trips. No agent restart -- the live resolve path still reads the persona catalog at spawn; the engram is provenance and future-proofing for when it becomes the runtime source. Gate the directory-backed team sync machinery (import_team_from_directory, sync_team_from_dir, sync_team_personas) behind a legacy_team_sync feature flag (default-enabled). Fleet update replaces sync_team_personas in the launch sequence. The old code remains compilable for one release cycle as a rollback path. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
b7475b7 to
45b0782
Compare
publish_agent_event now parses the response body as SubmitEventResponse and verifies accepted == true. The relay can return HTTP 200 with accepted: false on duplicate events or policy rejections — previously this was treated as success. Matches the pattern in submit_event (relay.rs:394). Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.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.
Summary
Write a
mem/personaengram (kind:30174) when creating an agent from a persona, and keep it current via fleet update. Gate the old directory-based team sync behind a feature flag.Stack: #939 → this PR
Prerequisite: #939 must merge first (this PR targets the
wpfleger/persona-eventsbranch). #939 lays the event kind foundation and retention store that this PR builds on.What Changed
Part A: Persona Engram at Instantiation
In
create_managed_agent, after the agent keypair is generated, amem/personaengram is published to the relay:mem/persona, d-tag derived viaengram::d_tag(&conversation_key, "mem/persona")(HMAC-blinded, 64 hex chars)PersonaEventContentfields plusprovenance(owner pubkey, kind:30175, persona slug, content SHA-256 digest)Part B: Fleet Update
On app launch and on persona save, fleet update reconciles agent engrams against current persona content:
Part C: Legacy Sync Gate
The directory-backed team sync machinery (
import_team_from_directory,sync_team_from_dir,sync_team_personas) is gated behind alegacy_team_syncfeature flag (default-enabled). Fleet update replacessync_team_personasin the launch sequence. Old code remains compilable for one release cycle as a rollback path.Key Design Decisions
sprout_core::engram::build_event— reuses the existing engram infrastructure rather than hand-rolling tagsresolve_effective_prompt_model_providerpath is unchanged. Fleet update keeps the engram current for when it becomes the runtime source.#[cfg(feature = "legacy_team_sync")]provides a real rollback path (recompile with the flag) rather than just#[deprecated]annotationsFiles Changed
desktop/src-tauri/Cargo.toml— addlegacy_team_syncfeature (default-enabled)desktop/src-tauri/src/commands/agents.rs— write persona engram at creationdesktop/src-tauri/src/commands/personas.rs— trigger fleet update on persona savedesktop/src-tauri/src/commands/teams.rs— cfg-gate legacy team commandsdesktop/src-tauri/src/lib.rs— replacesync_team_personaswith fleet update spawndesktop/src-tauri/src/managed_agents/fleet_update.rs(new) — fleet update moduledesktop/src-tauri/src/managed_agents/persona_events.rs— engram builder, content hash, provenance typesdesktop/src-tauri/src/managed_agents/teams.rs— cfg-gate legacy functionsdesktop/src-tauri/src/managed_agents/env_vars.rs— cfg-gate unused helpersdesktop/src-tauri/src/managed_agents/mod.rs— register fleet_update moduleTests
persona_engram_round_trip— build → decrypt → verify content matches original personapersona_content_hash_is_deterministic— same content always produces same digestpersona_content_hash_changes_on_edit— content change produces different digestmissing_engram_writes— fleet update writes when no engram existsmatching_hash_is_noop— fleet update skips when content matchesdiffering_hash_writes— fleet update writes when content differs