Files
hakorune/docs/development/current/main/design/pattern6-7-contracts.md

40 lines
1.2 KiB
Markdown

# Pattern6/7 Contracts (SSOT)
This document defines the **contract boundary** for Pattern6/7 extractors.
It is the SSOT for `NotApplicable` vs `Freeze` decisions.
## Common Rule
- **NotApplicable**: shape mismatch (another pattern may apply)
- **Freeze**: shape matches but contract is violated (fail-fast)
Tags:
- Pattern6: `[joinir/phase29ab/pattern6/contract]`
- Pattern7: `[joinir/phase29ab/pattern7/contract]`
## Pattern6 (ScanWithInit / MatchScan)
Accepted shape:
- `loop(i < s.length())` or `loop(i <= s.length() - needle.length())`
- `if s.substring(i, i + 1) == needle { return i }`
- step update exists and matches direction
Freeze conditions:
- step update missing
- forward scan with step != `i = i + 1`
- reverse scan with step != `i = i - 1`
Note:
- plan line is forward-only; reverse scans are currently treated as NotApplicable
## Pattern7 (SplitScan)
Accepted shape:
- `loop(i <= s.length() - separator.length())`
- `if s.substring(i, i + separator.length()) == separator`
- then: `result.push(...)`, `start = i + separator.length()`, `i = start`
- else: `i = i + 1`
Freeze conditions:
- then/else update contracts broken (start/i updates)
- separator literal length != 1 (P0 scope)