[ARCH] Financial statement mapping has two parallel implementations (Rust + TypeScript) #26
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
The financial statement mapping logic exists in two places:
rust/taxonomy/fiscal/v1/*.jsonfileslib/server/financials/standard-template.tsEvidence
The Rust sidecar CLI (
rust/fiscal-xbrl-core/src/lib.rs) parses XBRL and builds surfaces using:load_surface_pack()- loads JSON surface definitionsload_crosswalk()- loads XBRL concept mappingssurface_mapper.rs- performs the actual mappingThe TypeScript
standard-template.tsdefines similar mappings but appears to NOT be used by the actual XBRL parsing pipeline.Impact
Missing Surface Definitions
The `cost_of_revenue` surface is:
This mismatch causes the cost_of_revenue row to not appear in the UI!
Proposed Fix
Files Affected
CONFIRMED: TypeScript Code is Dead/Legacy Code
Data Flow Verified:
Evidence That TypeScript Mapping Code is NOT Used:
buildStandardizedRowsinstandardize.ts:standard-template.tsgrepforbuildStandardizedRowsshows it's only called fromsurface.tsline 205buildCompactHydrationModelinsurface.ts:grepforbuildCompactHydrationModelshows ZERO production callersstandard-template.ts(1471 lines):STANDARD_FINANCIAL_TEMPLATESstandardize.tssurface.tscodeProduction Path:
task-processors.ts:760callsupsertFilingTaxonomySnapshot(normalizedSnapshot)hydrateFilingTaxonomySnapshot()The Real Source of Truth:
rust/taxonomy/fiscal/v1/core.surface.jsonrust/taxonomy/fiscal/v1/core.income-bridge.jsonrust/taxonomy/crosswalk/us-gaap.jsonrust/fiscal-xbrl-core/src/surface_mapper.rslib/server/financials/standard-template.tslib/server/financials/standardize.tslib/server/financials/surface.tsRoot Cause of Bugs:
The bugs reported in issues #20-25 are ALL in the Rust JSON files, NOT TypeScript:
cost_of_revenuemissing fromcore.surface.jsonallowed_source_conceptsarrayscore.surface.jsonRecommended Actions:
Immediate: Fix bugs by editing
rust/taxonomy/fiscal/v1/core.surface.jsonShort-term:
Long-term:
standard-template.ts,standardize.ts,surface.ts)surface.tsif it provides value for UI-specific transformationsTest Coverage Note:
The tests in
lib/server/financial-taxonomy.test.tsuse__financialTaxonomyInternals.buildStandardizedRowswhich tests the DEAD code path. These tests should be updated to test the Rust JSON configurations instead.