Ensure the document has a session ID. If no frontmatter exists, creates one
with a new UUID v4. If frontmatter exists but session is None/null, generates
a UUID and sets it. If session already exists, returns as-is.
Returns (updated_content, session_id).
Parse YAML frontmatter from a document. Returns (frontmatter, body).
If no frontmatter block is present, returns defaults and the full content as body.