背景
DESIGN §3.2 规定 graph.db 位于 ~/.engram/graph.db,作为跨 scope 的全局索引;同时 assets.id 是主键,path 也要求全局唯一。当前实现已经在 cli/engram/commands/memory.py 注释里临时改成 <project>/.engram/graph.db,并说明存在 cross-project uniqueness 的 schema gap。
问题
同一个用户的多个项目很容易都存在 local/user_profile、local/feedback_confirm_before_push 这类 asset ID。若按全局 ~/.engram/graph.db + id TEXT PRIMARY KEY 实现,会出现主键冲突。path TEXT UNIQUE 也有类似问题,因为 local/user_profile.md 在不同项目中是合法重复路径。
这不是实现细节,而是 on-disk contract 和索引 contract 的身份模型没有完全定义。
影响
references_、usage_events、consistency_proposals 无法稳定指向跨项目资产。
engram graph rebuild 无法从多个项目重建一个无歧义的全局索引。
- 第三方实现会在“项目本地 graph.db”与“用户全局 graph.db”之间产生分歧。
建议
先在 SPEC/DESIGN 中冻结全局 asset URI。候选模型:
(store_root_id, scope_kind, scope_name, asset_id)
其中 store_root_id 对项目 scope 使用 repo id 或规范化 project path hash;对 user/team/org/pool scope 使用对应全局 scope 标识。assets 表用复合唯一键或新增 canonical_uri 主键,references_ 和 usage_events 指向该 canonical URI。
同时明确:
- 裸
local/foo 只在当前 project context 内可解析。
- 跨项目或 journal 中必须使用 canonical URI。
path 只能在 (store_root_id, scope_kind, scope_name) 内唯一,不能全局唯一。
参考
DESIGN.md §3.2:~/.engram/graph.db、assets.id TEXT PRIMARY KEY、path TEXT UNIQUE
cli/engram/commands/memory.py 顶部注释:当前实现已临时改为 <project>/.engram/graph.db
背景
DESIGN §3.2 规定
graph.db位于~/.engram/graph.db,作为跨 scope 的全局索引;同时assets.id是主键,path也要求全局唯一。当前实现已经在cli/engram/commands/memory.py注释里临时改成<project>/.engram/graph.db,并说明存在 cross-project uniqueness 的 schema gap。问题
同一个用户的多个项目很容易都存在
local/user_profile、local/feedback_confirm_before_push这类 asset ID。若按全局~/.engram/graph.db+id TEXT PRIMARY KEY实现,会出现主键冲突。path TEXT UNIQUE也有类似问题,因为local/user_profile.md在不同项目中是合法重复路径。这不是实现细节,而是 on-disk contract 和索引 contract 的身份模型没有完全定义。
影响
references_、usage_events、consistency_proposals无法稳定指向跨项目资产。engram graph rebuild无法从多个项目重建一个无歧义的全局索引。建议
先在 SPEC/DESIGN 中冻结全局 asset URI。候选模型:
其中
store_root_id对项目 scope 使用 repo id 或规范化 project path hash;对 user/team/org/pool scope 使用对应全局 scope 标识。assets表用复合唯一键或新增canonical_uri主键,references_和usage_events指向该 canonical URI。同时明确:
local/foo只在当前 project context 内可解析。path只能在(store_root_id, scope_kind, scope_name)内唯一,不能全局唯一。参考
DESIGN.md§3.2:~/.engram/graph.db、assets.id TEXT PRIMARY KEY、path TEXT UNIQUEcli/engram/commands/memory.py顶部注释:当前实现已临时改为<project>/.engram/graph.db