pub fn assert_editable_file(path: &Path) -> Result<(), String>Expand description
Refuse to modify a file that declares itself machine-generated.
This guard is called ONLY by write-path tools ([crate::fs::write],
[crate::fs::edit], crate::fs::ast_edit) because those tools replace
file content. Read-only tools (read, grep) never call it — surfacing a
generated file is harmless.
The check is deliberately cheap: only the first [AUTO_GENERATED_SCAN_LINES]
lines are scanned, and only for a small set of conventional markers. A file
without one of those markers, a new file (nothing is being overwritten), and
an unreadable file all pass — the caller surfaces its own read error.
§Errors
Returns Err when path exists and its header carries an auto-generated
marker, with an actionable message (regenerate instead, or remove the
marker to force the write).