Skip to content

fix(xbrl): require section evidence for three current/noncurrent entries (#1438) - #2071

Merged
dgunning merged 1 commit into
mainfrom
fix/1438-classification-evidence
Nov 28, 2026
Merged

dgunning merged 1 commit into
mainfrom
fix/1438-classification-evidence

Conversation

@dgunning

@dgunning dgunning commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Fixes #1438

Implements the scope I posted on #1438, built from synfonia-llc's design and BXP case.

What changes

  1. A require-evidence rule for three entries. OtherBorrowings, AdvancesFromFederalHomeLoanBanks and RestrictedCashAndCashEquivalents resolve only from the row's own current/noncurrent section, or from a classified ancestor whose section matches the candidate's kind. Otherwise get_standard_concept() returns None and the row keeps its filed label and values. get_display_name() agrees, so no "Short-Term Debt" label comes back through the label path. lookup() still returns both candidates. This adds no status API, and gaap_mappings.json is unchanged: the rule is a three-key frozenset in reverse_index.py.
  2. _derive_section_from_parent(). An ambiguous parent's context-free first candidate no longer counts as evidence. A parent that states no side passes on its nearest classified ancestor's side, found through the statement's own calculation parents; ancestors that disagree, or a cycle, give no side. A ...CurrentAndNoncurrent parent states no side. Noncurrent spellings are matched before the current spellings they contain (OtherNoncurrentAssets used to read as current). Assets/Liabilities totals never count as a side. A single-candidate parent outside the balance sheet role, such as LongTermDebtNoncurrent in a debt note, still gives its side.
  3. Stitching. A restricted-cash aggregate (RestrictedCash, RestrictedCashAndCashEquivalents) and a current or noncurrent portion (...AtCarryingValue, ...Current, ...Noncurrent) never merge on name containment, even when a common-period value agrees. The [DATA] Stitched balance sheet merges any two cash-bucket lines from different filings, so cash plus short-term investments can show as cash and cash equivalents #1685 guard is unchanged and covered by a control test.

Verification

Ground truth, read from the filings and checked offline against verbatim gzipped XBRL now committed under tests/fixtures/xbrl_gz/ (SHA-256 values in its README):

  • BXP FY2025 10-K, 0001037540-26-000006: the balance sheet's us-gaap:OtherBorrowings row "Unsecured term loans, net" is $797,053,000 at 2025-12-31 and $798,813,000 at 2024-12-31. Its standard concept was ShortTermDebt on main and is none here. The label and values are unchanged, and the standard=True render shows no "Short-Term" on that line.
  • FHLB, real filing: Pathfinder Bancorp FY2024 10-K, 0000950170-25-047820. In the long-term borrowings note, "Total advances with FHLB" ($27,068,000 at 2024-12-31) rolls up to LongTermDebtNoncurrent and resolves LongTermDebt. This is the control showing that a supported classification survives. It also caught a regression in my first cut: the debt note isn't a balance sheet role, so the parent's section lookup came back empty.
  • PNC FY2025 10-K, 0000713676-26-000020 (checked live, not committed): FHLB advances ($13,000,000,000) and OtherBorrowings "Other" ($2,443,000,000) under LongTermDebt "Total borrowed funds" stay LongTermDebt, the same as on main.
  • I didn't find a real filing with FHLB → OtherBorrowings → noncurrent liabilities. I searched 42 filers reporting both tags at CY2024Q4, plus the LongTermDebtNoncurrent/LiabilitiesNoncurrent frame intersections for 2012–2025. Banks file unclassified balance sheets. The two-level chain is covered by the synthetic test, both sides, plus a generic-total parent, conflicting parents and a cycle.
  • XOM FY2022 10-K, 0000034088-23-000020 (existing fixture): the deferred tax on PP&E ($25,607,000,000 at 2022-12-31) moves from DeferredTaxCurrentLiabilities to DeferredTaxNonCurrentLiabilities, matching its own total, which was already noncurrent on main.

The new regression file is tests/issues/regression/test_issue_1438_classification_evidence.py (31 tests). On origin/main, 17 of them fail: every targeted behavior, XOM included. The 14 that pass are controls: Pathfinder, the current-liabilities chain, #1685, name-variant merges and the classified-section cases. On this branch hatch run test-fast gives 52,704 passed, 9 skipped, 1 xfailed. The offline standardization/stitching/mapping selection gives 19,382 passed. Lint is unchanged (same count as main). check-regression-provenance passes.

Two existing tests changed on purpose. test_issue_1438_followup.py and test_issue_1441_industry_mappings.py asserted the first-candidate fallback for these entries, such as (None, "LongTermDebt") for FHLB with no section. For the three require-evidence tags they now expect None without a side. Every other tag keeps its assertion.

Every changed fixture row

standard_concept for every non-abstract row of every statement role in all 65 committed XBRL fixture sets (git ls-files tests directories holding a schema), standardized through xbrl.standardization.standardize_statement_data(), on origin/main vs this branch. 27 of 87,716 rows change, and every changed row is listed:

  • Rows 1–15: the targeted entries, none on a classified balance sheet section, lose their first-candidate concept.
  • Rows 16–27: a child now takes its classified parent's side instead of the ambiguous parent's first candidate. These are XOM deferred-tax components, and debt discounts/issuance costs under LongTermDebt or LongTermDebtNoncurrent.
  • One weak row, How to get all 13F-HR holdings per ticker? #19 (SIF pension ...CurrentAndNoncurrent "Liabilities"): it moves current → noncurrent because its parent maps to RetirementRelatedNonCurrentAssets. A liability candidate was picked from an asset section by _disambiguate_by_context()'s existing name fallback. I left that fallback alone as out of scope; neither side is right for a current-and-noncurrent total.
# Fixture Statement Concept Label Calculation parent main this PR
1 attachments/aapl/20250329 Disclosures RestrictedCashAndCashEquivalents Cash and cash equivalents held in escrow and restricted f… — RestrictedCashCurrent —
2 statement-fidelity/0001298946-24-000052/xbrl BalanceSheet RestrictedCashAndCashEquivalents Restricted cash Assets RestrictedCashCurrent —
3 statement-fidelity/0001581068-21-000012/xbrl CashFlowStatement RestrictedCashAndCashEquivalents Restricted cash CashCashEquivalentsRestrictedCashAndRestrictedCashEquivalents RestrictedCashCurrent —
4 xbrl/cato/10k_2023 Disclosures RestrictedCashAndCashEquivalents Restricted cash and cash equivalents in escrow — RestrictedCashCurrent —
5 xbrl/jpm/10k_2013 Disclosures OtherBorrowings Other borrowed funds, primarily commercial paper — ShortTermDebt —
6 xbrl/jpm/10k_2013 Disclosures RestrictedCashAndCashEquivalents Restricted Cash and Cash Equivalents — RestrictedCashCurrent —
7 xbrl/jpm/10k_2024 Disclosures RestrictedCashAndCashEquivalents Total restricted cash — RestrictedCashCurrent —
8 xbrl/ko/10k_2024 CashFlowStatement RestrictedCashAndCashEquivalents Restricted Cash and Restricted Cash Equivalents — RestrictedCashCurrent —
9 xbrl/ko/10k_2024 Disclosures RestrictedCashAndCashEquivalents Restricted Cash and Restricted Cash Equivalents CashCashEquivalentsRestrictedCashAndRestrictedCashEquivalents RestrictedCashCurrent —
10 xbrl/special_cases/custom_taxonomy/ba CashFlowStatement RestrictedCashAndCashEquivalents Less restricted cash & cash equivalents, included in Inve… — RestrictedCashCurrent —
11 xbrl/special_cases/dimensional/ko CashFlowStatement RestrictedCashAndCashEquivalents Restricted Cash and Restricted Cash Equivalents — RestrictedCashCurrent —
12 xbrl/special_cases/dimensional/ko Disclosures RestrictedCashAndCashEquivalents Restricted Cash and Restricted Cash Equivalents CashCashEquivalentsRestrictedCashAndRestrictedCashEquivalents RestrictedCashCurrent —
13 xbrl_gz/ba/10k_2025 CashFlowStatement RestrictedCashAndCashEquivalents Less restricted cash & cash equivalents, included in Inve… — RestrictedCashCurrent —
14 xbrl_gz/intu/10k_2026 CashFlowStatement RestrictedCashAndCashEquivalents Restricted cash and restricted cash equivalents included … CashCashEquivalentsRestrictedCashAndRestrictedCashEquivalents RestrictedCashCurrent —
15 xbrl_gz/intu/10k_2026 Disclosures RestrictedCashAndCashEquivalents Restricted cash and restricted cash equivalents intu_FundsReceivableAndAmountsHeldForCustomers RestrictedCashCurrent —
16 xbrl/aapl Disclosures DebtInstrumentUnamortizedDiscountPremiumAndDebtIssuanceCostsNet Unamortized premium/(discount) and issuance costs, net LongTermDebt ShortTermDebt LongTermDebt
17 xbrl/aapl/10k_2023 Disclosures DebtInstrumentUnamortizedDiscountPremiumAndDebtIssuanceCostsNet Unamortized premium/(discount) and issuance costs, net LongTermDebt ShortTermDebt LongTermDebt
18 xbrl/msft/10k_2024 Disclosures DebtInstrumentUnamortizedDiscountPremiumAndDebtIssuanceCostsNet Unamortized discount and issuance costs LongTermDebt ShortTermDebt LongTermDebt
19 xbrl/sif/10k_2025 Disclosures PensionAndOtherPostretirementDefinedBenefitPlansLiabilitiesCurrentAndNoncurrent Liabilities DefinedBenefitPlanAmountsRecognizedInBalanceSheet RetirementRelatedCurrentLiabilities RetirementRelatedNonCurrentLiabilities
20 xbrl/xom/10k_2023 Disclosures DeferredTaxLiabilitiesPropertyPlantAndEquipment Property, plant and equipment DeferredIncomeTaxLiabilities DeferredTaxCurrentLiabilities DeferredTaxNonCurrentLiabilities
21 xbrl/xom/10k_2023 Disclosures DeferredTaxLiabilitiesOther Other liabilities DeferredIncomeTaxLiabilities DeferredTaxCurrentLiabilities DeferredTaxNonCurrentLiabilities
22 xbrl/xom/10k_2023 Disclosures DeferredTaxAssetsOperatingLossCarryforwards Tax loss carryforwards DeferredTaxAssetsGross DeferredTaxCurrentAssets DeferredTaxNoncurrentAssets
23 xbrl/xom/10k_2023 Disclosures DeferredTaxAssetsOther Other assets DeferredTaxAssetsGross DeferredTaxCurrentAssets DeferredTaxNoncurrentAssets
24 xbrl/zbh/10k_2018 Disclosures DebtInstrumentUnamortizedDiscountPremiumAndDebtIssuanceCostsNet Debt discount and issuance costs LongTermDebtNoncurrent ShortTermDebt LongTermDebt
25 xbrl_gz/intu/10k_2026 Disclosures DebtInstrumentUnamortizedDiscountPremiumAndDebtIssuanceCostsNet Unamortized discount and debt issuance costs LongTermDebt ShortTermDebt LongTermDebt
26 xbrl_gz/noc/10k_2025 Disclosures DeferredFinanceCostsNet Debt issuance costs LongTermDebt OtherNonOperatingCurrentAssets OtherNonOperatingNonCurrentAssets
27 xbrl_gz/wday/10k_2026 Disclosures DebtInstrumentUnamortizedDiscountPremiumAndDebtIssuanceCostsNet Less: unamortized debt discount and issuance costs LongTermDebtNoncurrent ShortTermDebt LongTermDebt

Not in this PR

AI tool: Claude Code, Claude Opus 5.5.

🤖 Generated with Claude Code

OtherBorrowings, AdvancesFromFederalHomeLoanBanks and
RestrictedCashAndCashEquivalents each map to one current and one noncurrent
concept. With no section, get_standard_concept() took the first candidate, so
BXP's unsecured term loans (FY2025 10-K 0001037540-26-000006, $797,053,000 /
$798,813,000, an unclassified REIT balance sheet) became ShortTermDebt. These
three now resolve only from the row's own classified section or a classified
ancestor and otherwise return None; the row keeps its filed label and values,
get_display_name() agrees, and lookup() still lists both candidates. No
mapping data changes.

_derive_section_from_parent() no longer uses an ambiguous parent's
context-free first candidate. A parent that states no side passes on its
nearest classified ancestor's (conflicts and cycles give none), a
...CurrentAndNoncurrent parent states no side, noncurrent spellings are
matched before the current ones they contain, and a single-candidate parent
outside the balance sheet role (LongTermDebtNoncurrent in a debt note) still
states its side.

Stitching no longer merges a restricted-cash aggregate with its current or
noncurrent portion on name containment, even when a common period agrees.
The GH #1685 guard is unchanged.

Across the 65 committed XBRL fixture sets, 27 of 87,716 standardized rows
change: 15 target rows lose a first-candidate concept, 12 children now match
their classified parent (XOM deferred taxes, debt discounts under long-term
debt).

Design and BXP case by synfonia-llc on GH #1438.

Refs #1438

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dgunning
dgunning merged commit 068b335 into main Nov 28, 2026
13 checks passed
@dgunning
dgunning deleted the fix/1438-classification-evidence branch November 28, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DATA] 135 balance-sheet elements bypass their dedicated concept, land in the wrong class, or standardize as a total

1 participant