Skip to main content

Module vault_writer

Module vault_writer 

Source
Expand description

Lifecycle → Vault canonical note 回写。

负责把 MemoryRecorddocs/OBSIDIAN_SCHEMA.md 的 frontmatter 契约渲染成单个 Markdown note,落入 50-Memory-Ledger/Extracted/<record_id>.md

幂等 + body 保护:frontmatter 里保存上次写入时的 body hash (spool_body_hash), 再次回写时若磁盘上 body 的实际 hash 与 stored 不一致,视为用户手改,保留用户 body 只重写 frontmatter;一致则按 record 重新渲染 body。archive 不删文件,仅打 archived 标记。

Structs§

VaultWriteResult

Enums§

WriteStatus

Constants§

BODY_HASH_KEY
MEMORY_LEDGER_COMPILED_DIR
MEMORY_LEDGER_DIR
NOTE_VERSION
VERSION_KEY

Functions§

apply_writeback_for_entry
根据 LedgerEntry 的最新 state 做 vault 回写,错误降级为 stderr warn。
archive_memory_note
memory_note_path
memory_note_path_for
根据 memory_type 分发目标子目录: knowledge (Karpathy wiki compiled 页) 走 Compiled/,其他碎片记忆走 Extracted/。保持 Extracted 为默认以兼容现有 测试与 MCP 路径引用。
write_memory_note
writeback_from_config
从 config_path 加载 AppConfig 并 resolve vault root,再做 writeback。 任何 config/vault 解析错误都 swallow 为 None (不阻断业务)。
writeback_from_config_no_compile
Same as writeback_from_config but skips auto-compile. Used by MCP handlers that will run LLM-assisted compile separately.