fix: adversarial testing — 4 false positive/negative fixes + comment stripping
COBOL migration expert adversarial testing found 4 real defects:
FIX 1: Comment-stripping in detect_keyword() (FP-2)
- Remove *> inline comments and * comment lines before keyword matching
- Prevents 「マッチング」 from triggering on WS-KEY in comments
FIX 2: KEY comparison context validation (FP-1, FP-6)
- Add _matches_key_comparison() — requires WS-KEY variable to appear
NEAR an actual comparison operator (= < >), not just as PIC/VALUE decl
- Same check in _path_rule_engine features via has_key_var injection
- Fix regex bug: [=<>\s] vs [=<>] — \s matched whitespace after PIC decl
FIX 3: Old-school naming support (FN-1)
- Add L1 keyword r'[A-Z]\d{0,2}-\w*KEY' with 0.55 confidence
- Matches K01-KEY, KS-KEY etc. (non-WS- prefix naming convention)
FIX 4: mn_output_mode over-matching (FP-6)
- Require IF branches + KEY evidence before returning M:N for file>=3
- matching_vs_keybreak rule 3 now requires has_key_var
New tests: test_adversarial.py — 8 parametrized adversarial tests
Regression: 755 passed (0 new failures)
This commit is contained in:
@@ -245,8 +245,13 @@ def test_mn_output_mode_unknown():
|
||||
|
||||
|
||||
def test_mn_output_mode_many_files():
|
||||
"""文件数 >=3 无提示 → M:N"""
|
||||
features = {"has_mn_output_hint": False, "select_files": {"a": {}, "b": {}, "c": {}}}
|
||||
"""文件数 >=3 + IF 分支 + KEY 证据 → M:N"""
|
||||
features = {
|
||||
"has_mn_output_hint": False,
|
||||
"select_files": {"a": {}, "b": {}, "c": {}},
|
||||
"if_types": {"total": 2, "comparison": 1, "equality": 1, "compound": 0, "nested_depth": 0},
|
||||
"variable_patterns": {"has_prev_key": True, "has_accumulator": False},
|
||||
}
|
||||
result = resolve_mn_output_mode(features)
|
||||
assert result["resolved_type"] == "M:N"
|
||||
assert result["confidence"] >= 0.55
|
||||
|
||||
Reference in New Issue
Block a user