refactor: apply 5-pass audit optimizations across mcp-memory codebase
This commit is contained in:
1 parent
924b6d09fa
commit
5bd8b1587a
43 files changed
+1866
-1658
No files matched your search
@@ -72,9 +72,45 @@ pub fn normalize_relation_type(input: &str) -> String {
|
||||
trimmed.to_lowercase().replace([' ', '-'], "_")
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Default)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum TaskStatus {
|
||||
#[default]
|
||||
Active,
|
||||
InProgress,
|
||||
Blocked,
|
||||
Completed,
|
||||
}
|
||||
|
||||
impl TaskStatus {
|
||||
pub fn is_active(&self) -> bool {
|
||||
matches!(self, TaskStatus::Active | TaskStatus::InProgress | TaskStatus::Blocked)
|
||||
}
|
||||
|
||||
pub fn is_completed(&self) -> bool {
|
||||
matches!(self, TaskStatus::Completed)
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
TaskStatus::Active => "active",
|
||||
TaskStatus::InProgress => "in_progress",
|
||||
TaskStatus::Blocked => "blocked",
|
||||
TaskStatus::Completed => "completed",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for TaskStatus {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct Entity {
|
||||
pub name: String,
|
||||
#[serde(alias = "entityType", alias = "type", alias = "category")]
|
||||
pub entity_type: String,
|
||||
#[serde(default)]
|
||||
pub observations: Vec<String>,
|
||||
@@ -85,8 +121,11 @@ pub struct Entity {
|
||||
}
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, JsonSchema)]
|
||||
pub struct Relation {
|
||||
#[serde(alias = "source", alias = "from_node", alias = "source_node")]
|
||||
pub from: String,
|
||||
#[serde(alias = "target", alias = "to_node", alias = "target_node")]
|
||||
pub to: String,
|
||||
#[serde(alias = "relationType", alias = "type", alias = "relation")]
|
||||
pub relation_type: String,
|
||||
#[serde(default = "default_namespace")]
|
||||
pub namespace: String,
|
||||
@@ -123,6 +162,16 @@ pub struct Task {
|
||||
#[serde(default)]
|
||||
pub acceptance_criteria: Vec<AcceptanceCriteria>,
|
||||
}
|
||||
|
||||
impl Task {
|
||||
pub fn is_active(&self) -> bool {
|
||||
let s = self.status.trim();
|
||||
!s.eq_ignore_ascii_case("completed")
|
||||
&& !s.eq_ignore_ascii_case("done")
|
||||
&& !s.eq_ignore_ascii_case("cancelled")
|
||||
&& !s.eq_ignore_ascii_case("canceled")
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct Snippet {
|
||||
pub name: String,
|
||||
|
||||
Reference in new issue
Block a user