Validate structure, limits and domain rules at entry
#Parse with a format-aware parser, validate types and allowed fields, and bound size/depth/record counts. Then enforce domain rules. Client-side validation helps users but does not protect the server boundary.
Protocol / decision sketch
Sequence or decision sketch; not executable code.