Parses the leading --- frontmatter block. A file without a block parses
to an empty Frontmatter; a malformed block is an error so a typo never
silently registers a ticket under the wrong identity.
Writes id, project, worktree, and flow into the frontmatter
without disturbing any other byte of the file. Returns None when the
file already carries all four values, so callers can skip the write
entirely.