Skip to content

Commit 66a2ed7

Browse files
dgunningclaude
andcommitted
Fix MTD balance sheet resolution by validating standard-name matches (GH #659)
_match_by_standard_name() now filters candidates through essential-concept validation, preventing mislabeled roles (e.g., a supplemental schedule with the standard root concept but only 2 elements) from short-circuiting the resolver cascade. When all standard-name candidates fail validation, the method falls through to concept-pattern matching which finds the real balance sheet. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8ff039e commit 66a2ed7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎edgar/xbrl/statement_resolver.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,17 @@ def _match_by_standard_name(self, statement_type: str) -> Tuple[List[Dict[str, A
10001000
if statements:
10011001
# Issue #506: Sort by statement quality to prefer correct statement type
10021002
statements = sorted(statements, key=lambda s: self._score_statement_quality(s, statement_type), reverse=True)
1003+
# Issue #659: Filter out candidates that fail essential-concept validation.
1004+
# This prevents mislabeled roles (e.g., a supplemental schedule with
1005+
# us-gaap_StatementOfFinancialPositionAbstract as root) from blocking
1006+
# the cascade to concept-pattern or content-based matchers.
1007+
if statement_type in ESSENTIAL_CONCEPTS:
1008+
valid = [s for s in statements
1009+
if self._validate_statement(s, statement_type)[0]]
1010+
if valid:
1011+
return valid, valid[0]['role'], 0.95
1012+
# All candidates failed validation — fall through to cascade
1013+
return [], None, 0.0
10031014
return statements, statements[0]['role'], 0.95
10041015

10051016
return [], None, 0.0

0 commit comments

Comments
 (0)