Parse Uncertainty At Edge

BOUNDARY-PARSE-UNCERTAINTY-AT-EDGE

Summary

Parse and validate raw strings, JSON, CLI args, provider responses, and user input at the boundary before passing values inward. Core logic receives typed invariants, while domain-specific checks that require later context remain explicit policy decisions.

Rule

Push uncertainty to the boundary, then pass trusted values inward.

Why

Raw strings, JSON, CLI args, provider responses, and user input contain uncertainty. Parse and validate them at the edge so inner code receives typed values with known invariants instead of repeating defensive checks everywhere.

Helps

  • Concentrates validation policy and reduces invalid states in core logic.

Limits

Some validation depends on domain context that is only available later. Parse structural uncertainty early and make later policy checks explicit.

Agent Instruction

Push uncertainty to the boundary, then pass trusted values inward from parsed strings, JSON, CLI
args, provider responses, and user input.

Mechanisms

Supported by FromStr, TryFrom, parser types, validation errors, newtypes with invariants, and tests for accepted and rejected inputs.

References