Gate: region-pair-honored
Every #region [CODE] closes, and closes with its own code.
| Property | Value |
|---|---|
| Checker | region-pair-honored |
| Confronts | code test |
| Blocking by default — new project | yes |
| Blocking by default — existing project | no — informs |
How it measures
Section titled “How it measures”Confronts source code regions against their pairing markers: every opened code region must close, and must close specifying its own exact identity code.
A region marker pair gives identity a concrete line interval within the source file. Without region boundaries, one only knows that a given file realizes a requirement, but not WHERE within the file that implementation resides (TRACEABILITY §3). The region pair is the single fragile component of this mechanism, and its fragility is particularly perilous because it raises no compiler or syntax errors: closing in the wrong location produces an interval that is syntactically VALID and completely WRONG.
This gate detects the three critical structural pairing defects that cannot be reliably spotted by human review when reading large source files top-to-bottom:
- Unclosed region (
sem-fecho): A region opened and never closed, causing the requirement interval to bleed silently to the end of the file. - Orphan close (
fecho-orfao): An end region marker appearing without a preceding opening marker, typically left behind from careless cut-and-paste refactorings. - Mismatched close (
fecho-trocado): An end marker carrying a DIFFERENT identity code than the currently open region, indicating inverted or twisted nesting.
The third defect is the exact reason why region close markers must explicitly carry the identity code rather than using an anonymous end marker. With anonymous end markers, the count of open and close markers would balance perfectly, the gate would remain green, and the freshness stamp would measure the NEIGHBOR interval: requirement A would appear to change when neighbor B was edited. A silent, crossed error is the worst kind of defect: it vanishes during initial measurement and resurfaces weeks later as an erroneous conclusion.
Unlike gates that report non-blocking warnings for domain ambiguities (such as an uncatalogued requirement letter), this gate issues a definitive blocking Fail. A malformed region pair has no two legitimate interpretations: it is an objective syntax defect in code structure with a single unambiguous, local fix.
Finally, the ABSENCE of region markers is NOT a defect. Granular region delimitation is entirely optional; when a file does not define regions, the whole file revision applies cleanly.
Declaring it
Section titled “Declaring it”gates: - name: region-pair-honored on: [code, test] check: region-pair-honored