FA-3751 / Parsing / Open access
A closing parenthesis appears before its matching opener · case 01
A closing parenthesis appears before its matching opener.
ROOT CAUSE
The implementation applies an operation whose text or grammar semantics violate this contract: Validate strings of parentheses with balanced counts and no negative prefix depth.
VERIFIED REPAIR
Implement the complete stated contract, including the boundary fixtures: Validate strings of parentheses with balanced counts and no negative prefix depth.
Unsuccessful approach: The attempted repair handles the primary example but still violates a separate boundary of the same contract.
Case contract
Validate strings of parentheses with balanced counts and no negative prefix depth.
Why this case matters
A local executable model for consumers of structured text; oracle values are authored literals, not outputs copied from the repaired implementation.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap
N = 1
observations = []
def solve(x):
try:
return x.count('(')==x.count(')')
except Exception as exc:
return {"error": type(exc).__name__}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve(')('), False)
check('boundary 2', solve('())(()'), False)
check('boundary 3', solve('(())'), True)
check('boundary 4', solve(''), True)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| boundary 1 | True | False | Failed |
| boundary 2 | True | False | Failed |
| boundary 3 | True | True | Passed |
| boundary 4 | True | True | Passed |
SHA-256 / ba606a73055b7fb063beea2c90e00fe3b2010cdbfaa844c70a36859c25649ec4
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap
N = 1
observations = []
def solve(x):
try:
return x.count('(')==x.count(')') and (not x or x[0]=='(')
except Exception as exc:
return {"error": type(exc).__name__}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve(')('), False)
check('boundary 2', solve('())(()'), False)
check('boundary 3', solve('(())'), True)
check('boundary 4', solve(''), True)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| boundary 1 | False | False | Passed |
| boundary 2 | True | False | Failed |
| boundary 3 | True | True | Passed |
| boundary 4 | True | True | Passed |
SHA-256 / 1e2adf23955d76a34219d51eb840b87adef735c6e4fc9ebe192462a2bf011690
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap
N = 1
observations = []
def solve(x):
try:
depth=0
for c in x:
depth+=1 if c=='(' else -1
if depth<0: return False
return depth==0
except Exception as exc:
return {"error": type(exc).__name__}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve(')('), False)
check('boundary 2', solve('())(()'), False)
check('boundary 3', solve('(())'), True)
check('boundary 4', solve(''), True)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| boundary 1 | False | False | Passed |
| boundary 2 | False | False | Passed |
| boundary 3 | True | True | Passed |
| boundary 4 | True | True | Passed |
SHA-256 / 87e7895c156b1f325bb6bfcf46089c5f865d5bf8fbc0d1a7ad3c586dde557176
Verification & scope
This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:37:30.330607+00:00.
Case digest / e8153711c5305a8a6c2ae5d52c747fbd9a768a8f2eac57ec46bb40f88d1a133d