mirror of
https://github.com/block/buzz.git
synced 2026-10-31 22:41:12 +00:00
chore(desktop): extract persona_drift_state to runtime/drift sibling
Merge-collision ratchet relief. Merging current main pushed managed_agents/runtime.rs to 1012 split-count (>1000 limit): the PR's fail-closed spawn gating (+16) and main's mesh acp_model translation (+12) landed in disjoint regions of one file. Move the self-contained persona_drift_state helper verbatim to a new runtime/drift.rs sibling (the file's existing plain-submodule pattern) and re-export it, dropping runtime.rs to 986. No logic change: the fn body is identical; only visibility (pub(crate)) and an import replacing the inline fully-qualified type path differ. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This commit is contained in:
@@ -68,34 +68,8 @@ mod lifecycle;
|
||||
use lifecycle::kill_stale_tracked_processes_with;
|
||||
pub use lifecycle::{kill_stale_tracked_processes, sync_managed_agent_processes};
|
||||
|
||||
/// Classify an agent's persona against the live catalog for the Agents-menu
|
||||
/// drift indicator. Returns `(out_of_date, orphaned)`.
|
||||
///
|
||||
/// Drift basis is the RECORD's `persona_source_version`, never the engram:
|
||||
/// - persona_id set + persona present: out_of_date when the snapshot hash
|
||||
/// differs from the persona's current content hash.
|
||||
/// - persona_id set + persona gone: orphaned (no current hash to respawn into,
|
||||
/// so never out_of_date — we must not tell the user to respawn into nothing).
|
||||
/// - no persona_id: neither — a hand-built agent has no persona to drift from.
|
||||
fn persona_drift_state(
|
||||
record: &ManagedAgentRecord,
|
||||
personas: &[crate::managed_agents::types::AgentDefinition],
|
||||
) -> (bool, bool) {
|
||||
let Some(persona_id) = record.persona_id.as_deref() else {
|
||||
return (false, false);
|
||||
};
|
||||
let Some(persona) = personas.iter().find(|p| p.id == persona_id) else {
|
||||
return (false, true);
|
||||
};
|
||||
let current = crate::managed_agents::persona_events::persona_content_hash(
|
||||
&crate::managed_agents::persona_events::persona_event_content(persona),
|
||||
);
|
||||
let out_of_date = record
|
||||
.persona_source_version
|
||||
.as_deref()
|
||||
.is_some_and(|pinned| pinned != current);
|
||||
(out_of_date, false)
|
||||
}
|
||||
mod drift;
|
||||
pub(crate) use drift::persona_drift_state;
|
||||
|
||||
/// Resolve the runtime-pair key this record maps to for the active
|
||||
/// workspace: always the active workspace relay (the legacy per-record relay
|
||||
|
||||
32
desktop/src-tauri/src/managed_agents/runtime/drift.rs
Normal file
32
desktop/src-tauri/src/managed_agents/runtime/drift.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
//! Persona drift classification for the Agents-menu drift indicator.
|
||||
|
||||
use crate::managed_agents::{types::AgentDefinition, ManagedAgentRecord};
|
||||
|
||||
/// Classify an agent's persona against the live catalog for the Agents-menu
|
||||
/// drift indicator. Returns `(out_of_date, orphaned)`.
|
||||
///
|
||||
/// Drift basis is the RECORD's `persona_source_version`, never the engram:
|
||||
/// - persona_id set + persona present: out_of_date when the snapshot hash
|
||||
/// differs from the persona's current content hash.
|
||||
/// - persona_id set + persona gone: orphaned (no current hash to respawn into,
|
||||
/// so never out_of_date — we must not tell the user to respawn into nothing).
|
||||
/// - no persona_id: neither — a hand-built agent has no persona to drift from.
|
||||
pub(crate) fn persona_drift_state(
|
||||
record: &ManagedAgentRecord,
|
||||
personas: &[AgentDefinition],
|
||||
) -> (bool, bool) {
|
||||
let Some(persona_id) = record.persona_id.as_deref() else {
|
||||
return (false, false);
|
||||
};
|
||||
let Some(persona) = personas.iter().find(|p| p.id == persona_id) else {
|
||||
return (false, true);
|
||||
};
|
||||
let current = crate::managed_agents::persona_events::persona_content_hash(
|
||||
&crate::managed_agents::persona_events::persona_event_content(persona),
|
||||
);
|
||||
let out_of_date = record
|
||||
.persona_source_version
|
||||
.as_deref()
|
||||
.is_some_and(|pinned| pinned != current);
|
||||
(out_of_date, false)
|
||||
}
|
||||
Reference in New Issue
Block a user