Sanitize a document identifier for safe use as a filesystem filename.
Replaces characters unsafe for filenames with hyphens, collapses runs of
hyphens, trims, and lowercases. When the result exceeds 80 characters,
a deterministic hash suffix is appended to avoid collisions between IDs
that share the same first 80 characters. Falls back to a deterministic
hash of the input when the sanitized result is empty.
Parameters
id: string
Raw document identifier (e.g. "TA-10-2026-0094", procedure reference)
Sanitize a document identifier for safe use as a filesystem filename.
Replaces characters unsafe for filenames with hyphens, collapses runs of hyphens, trims, and lowercases. When the result exceeds 80 characters, a deterministic hash suffix is appended to avoid collisions between IDs that share the same first 80 characters. Falls back to a deterministic hash of the input when the sanitized result is empty.