Grammar-constrained decoding and domain validation
medium 6 minA parser can restrict the next tokens to those that keep a partial output compatible with a grammar.
Where it shows up
The same pattern appears across everyday software.
Generate a valid status that can still be wrong
The output has reached the enum field. The engine knows which continuations the supported grammar accepts. Exclude tokens that cannot lead to paid or void. Continue until the full object parses. Syntax succeeds but the business invariant fails. Store the discrepancy for review.