fix(memory): add coalesce defaults for activation_value and related node properties
- Add coalesce fallbacks for importance_score, activation_value, and access_count in statement, entity, weak entity, strong entity, and memory summary MERGE queries to prevent null values on new nodes - Set activation_value default to coalesce(importance_score, 0.5) for consistency with the forgetting/activation scoring logic - Suppress Neo4j UNRECOGNIZED property key notifications in driver init since missing keys like last_access_time and activation_value are expected for newly created nodes
This commit is contained in:
@@ -42,6 +42,9 @@ SET s += {
|
||||
last_access_time: statement.last_access_time,
|
||||
access_count: statement.access_count
|
||||
}
|
||||
SET s.importance_score = coalesce(s.importance_score, 0.5),
|
||||
s.activation_value = coalesce(s.activation_value, s.importance_score, 0.5),
|
||||
s.access_count = coalesce(s.access_count, 0)
|
||||
RETURN s.id AS uuid
|
||||
"""
|
||||
|
||||
@@ -120,7 +123,7 @@ SET e.name = CASE WHEN entity.name IS NOT NULL AND entity.name <> '' THEN entity
|
||||
END
|
||||
END,
|
||||
e.importance_score = CASE WHEN entity.importance_score IS NOT NULL THEN entity.importance_score ELSE coalesce(e.importance_score, 0.5) END,
|
||||
e.activation_value = CASE WHEN entity.activation_value IS NOT NULL THEN entity.activation_value ELSE e.activation_value END,
|
||||
e.activation_value = CASE WHEN entity.activation_value IS NOT NULL THEN entity.activation_value ELSE coalesce(e.activation_value, e.importance_score, 0.5) END,
|
||||
e.access_history = CASE WHEN entity.access_history IS NOT NULL THEN entity.access_history ELSE coalesce(e.access_history, []) END,
|
||||
e.last_access_time = CASE WHEN entity.last_access_time IS NOT NULL THEN entity.last_access_time ELSE e.last_access_time END,
|
||||
e.access_count = CASE WHEN entity.access_count IS NOT NULL THEN entity.access_count ELSE coalesce(e.access_count, 0) END,
|
||||
@@ -165,6 +168,7 @@ SET e += {
|
||||
}
|
||||
// Independent weak flag,仅标记弱关系,不再维护 relations 聚合字段
|
||||
SET e.is_weak = true
|
||||
SET e.activation_value = coalesce(e.activation_value, 0.5)
|
||||
RETURN e.id AS id
|
||||
"""
|
||||
|
||||
@@ -175,10 +179,12 @@ MERGE (s:ExtractedEntity {id: item.source_id, run_id: item.run_id})
|
||||
SET s += {name: item.subject, end_user_id: item.end_user_id, run_id: item.run_id}
|
||||
// Independent strong flag
|
||||
SET s.is_strong = true
|
||||
SET s.activation_value = coalesce(s.activation_value, 0.5)
|
||||
MERGE (o:ExtractedEntity {id: item.target_id, run_id: item.run_id})
|
||||
SET o += {name: item.object, end_user_id: item.end_user_id, run_id: item.run_id}
|
||||
// Independent strong flag
|
||||
SET o.is_strong = true
|
||||
SET o.activation_value = coalesce(o.activation_value, 0.5)
|
||||
"""
|
||||
|
||||
|
||||
@@ -739,7 +745,7 @@ SET m += {
|
||||
summary_embedding: summary.summary_embedding,
|
||||
config_id: summary.config_id,
|
||||
importance_score: CASE WHEN summary.importance_score IS NOT NULL THEN summary.importance_score ELSE coalesce(m.importance_score, 0.5) END,
|
||||
activation_value: CASE WHEN summary.activation_value IS NOT NULL THEN summary.activation_value ELSE m.activation_value END,
|
||||
activation_value: CASE WHEN summary.activation_value IS NOT NULL THEN summary.activation_value ELSE coalesce(m.activation_value, m.importance_score, 0.5) END,
|
||||
access_history: CASE WHEN summary.access_history IS NOT NULL THEN summary.access_history ELSE coalesce(m.access_history, []) END,
|
||||
last_access_time: CASE WHEN summary.last_access_time IS NOT NULL THEN summary.last_access_time ELSE m.last_access_time END,
|
||||
access_count: CASE WHEN summary.access_count IS NOT NULL THEN summary.access_count ELSE coalesce(m.access_count, 0) END
|
||||
|
||||
Reference in New Issue
Block a user