Purpose
-------
Provide shared Python-source parsing helpers:
- :func:`safe_parse` parses source text into an AST while capturing any
``SyntaxWarning`` diagnostics (so callers can surface them without
letting them leak to stderr).
- :func:`header_boundary` (OI-509 / FS-505) returns the line index where
file content begins, scanning at most the first 5 lines in the strict
order shebang → encoding → file-identity comment → blank line. This
replaces two drift-prone inline copies that previously existed in the
linter and the formatter.
Responsibilities
----------------
- Parse Python source text into an AST tree.
- Capture ``SyntaxWarning`` (e.g. invalid escape sequences) as structured data.
- Locate the header/content boundary of an Option-C-formatted Python file
using only the file's basename and (optionally) its expected identity
comment, so both the linter (with full ``LinterContext``) and the
formatter (with a lighter ``FormatterContext``) can share one code path.
Diagnostics
-----------
Domain: OCT-CORE
Levels:
L2 — lifecycle
L3 — semantic details
L4 — deep tracing
Contracts
---------
- :func:`safe_parse` must not emit warnings to stderr; all warnings are
returned as strings.
- :func:`safe_parse` must return ``None`` for the tree on ``SyntaxError``.
- :func:`header_boundary` must never raise; it returns an integer in
``[0, min(len(lines), 5)]``.
- :func:`header_boundary` must consume the trailing blank only if at
least one header element was matched first.