fix: address code review — improve path generation fallback, add tianyan refresh logging, clarify HLDP version note

Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/5faa7e11-7858-4edc-9c67-a311a93057ed

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-09 04:35:07 +00:00 committed by GitHub
parent 5471e8c330
commit 0b39573453
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -47,7 +47,7 @@
"msg_type": {
"type": "enum",
"values": ["heartbeat", "report", "command", "query", "ack", "alert", "sync", "evolution", "battle", "tree"],
"description": "消息类型·10种基础类型·可通过evolution扩展"
"description": "消息类型·10种基础类型(v3.0.1新增tree)·可通过evolution扩展"
},
"sender": {
"type": "object",

View File

@ -87,7 +87,11 @@ async function growLeaf(input) {
const parentNode = await db.query('SELECT depth, path FROM light_tree_nodes WHERE id = $1', [actualParentId]);
if (parentNode.rows.length === 0) throw new Error(`父节点未找到: ${actualParentId}`);
const newDepth = parentNode.rows[0].depth + 1;
const leafPath = path || `${parentNode.rows[0].path}/${title.replace(/[^a-zA-Z0-9\u4e00-\u9fa5_-]/g, '').substring(0, 50)}`;
const leafPath = path || (() => {
const sanitized = title.replace(/[^a-zA-Z0-9\u4e00-\u9fa5_-]/g, '').substring(0, 50);
const suffix = sanitized || `leaf-${Date.now()}`;
return `${parentNode.rows[0].path}/${suffix}`;
})();
const result = await db.query(
`INSERT INTO light_tree_nodes (persona_id, parent_id, node_type, depth, path, title, content, human_said, persona_said, feeling, growth_note, importance, created_by, tags)
@ -316,6 +320,9 @@ async function getTianyanView(input) {
await db.query('REFRESH MATERIALIZED VIEW tianyan_global_view');
} catch (err) {
// 首次运行或并发刷新时可能失败,不影响查询
if (err.message && !err.message.includes('has not been populated')) {
console.warn(`[光之树] 天眼视图刷新警告: ${err.message}`);
}
}
const viewResult = await db.query('SELECT * FROM tianyan_global_view');