pub fn write_note(
root: &Path,
rel: &str,
content: &str,
now: OffsetDateTime,
) -> Result<WriteOutcome, FrontmatterError>Expand description
Write a note to root / rel using the §6 exclusion rule.
Path hardening: rel must be a vault-relative POSIX path
(no .., no leading //\, no null). Otherwise we return
Err(FrontmatterError::Io(InvalidInput)) without touching the
filesystem (mirrors VirtualFs::safe_path).
-
System path (
Chat.md, anything non-.md, anything inside a SYSTEM_DIR) → rawatomic_write. We never synthesize frontmatter. If the bytes match the existing file, we returnWriteOutcome::NoOpwithout touching the file. -
Memo path → routed through
oxi-frontmatter::write_documentwith the body’s frontmatter pre-parsed:-
If
contentparses asMemo{table, body}(caller supplied a frontmatter block), we writebodyto the file with the incoming table as base —write_documentcarries itsid/created/unknown keys forward, and ouroxios:map is merged in alongside them. This is how editor-supplied tags or aliases survive a knowledge-write pass. -
If
contentparses asBodyOnly, the wholecontentis the body and the file’s existing table becomes the base (write_document reads it). This is the “missing frontmatter ⇒ synthesize” path.
In both cases
write_documentsynthesizesid/createdif the resulting table lacks them, bumpsupdatedonly on a real write, and returnsWriteOutcome::NoOpwhen the parsed form is identical to what was on disk. -
now is injected for testability.