feat(adapters): read a filing from its Project Tavi compiled model - #50
Merged
Merged
Conversation
A `tavi.json` is xbrlkit's second JSON projection of a filing beside the holon: the taxonomy and report objects of XBRL International's Tavi draft (PWD 2026-09-01) in one resolved document. `parseTavi` walks it straight into the normalized report — concepts typed from their datatype and balance (share counts from the unit their facts carry), headings, axes and members as abstract elements, units with composites, facts with explicit and typed dimensions, and one section per presentation network titled and ordered by its group's role definition, a fact belonging to every network that presents its concept. Preferred labels resolve to their text; calculation weights ride along. Periods land as the holon's human dates whether the emitter wrote exclusive-end dateTimes or inclusive dates. `parseReportDocument` sniffs a holon from a Tavi so a consumer can take either file through one door. No RDF step: a full 10-K parses in tens of milliseconds where the holon's expansion takes hundreds. Claude-Session: https://claude.ai/code/session_01TBKj1VsfBpKsFY7PPcrCFu
Member
Author
|
@claude please review this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Read a filing from its
tavi.json: the Project Tavi compiled model (XBRL International, PWD 2026-09-01) that xbrlkit writes beside every holon, and that the SEC pipeline now publishes per filing on the public CDN. With this the library renders both of xbrlkit's JSON projections, and a consumer can take either file through one sniffing entry. There is no RDF step, so a full 10-K parses in tens of milliseconds where the holon's JSON-LD expansion takes hundreds.Changes
src/adapters/tavi.ts:parseTavi(doc)(synchronous),taviFileAdapter,isTaviDocument. Concepts are typed from their Tavi datatype andxbrla:balance; share counts, which have no built-in Tavi type, are recognized from thexbrla:sharesunit their facts carry. Headings, axes, domain classes and members become abstract elements with role tags stripped. Units include composites (iso4217:USD/xbrla:shares). Facts carry explicit and typed dimensions with labels. Each presentation network is a section whose fact set is the network; a fact belongs to every network that presents its concept (the SEC adapter's rule per structure), and the pivot's dimensional scope does the rest. Sections take their title, kind and order from the group's role definition label (9952153 - Statement - …). Presentation arcs resolve their preferred label to its text and keep the label type as the role; calculation arcs carryxbrl:weight. Periods normalize to the holon's inclusive dates from either the current exclusive-end dateTime form or the older date form.src/adapters/detect.ts:detectReportFormat(doc)→'holon' | 'tavi' | nullandparseReportDocument(doc), which dispatches toparseJsonldorparseTavi.adapters/index.tsadds the five names above and theTaviDocument/ReportFormattypes. README lists the adapter.Consumer Impact
ADDITIVE. New exports only; nothing existing changes. No rendered number changes for any existing source.
For a Tavi-loaded report specifically: the same statements render as from the holon of the same filing (checked on 3M FY2024 and Workday FY2025: five primary statements each, same columns), and
reportSections/buildPivotsbehave identically. Two things a consumer of the Tavi path should know: there is no RDF store, so anything that queried the holon's graph (the viewer's SPARQL chat) has nothing to query; and text blocks arrive inline (the CDN's holon carries them as URLs, its Tavi does not).Testing
npm run test:allpasses: 129 tests in 15 files (16 new), format, lint, typecheck and build. Fixtures: a hand-built model in the current emitter's form covering every mapping above (test/tavi.test.ts), andtest/fixtures/mmm-fy2024-statements.tavi.json, the balance sheet and income statement of 3M's FY2024 10-K trimmed from a real xbrlkit output (231 KB), which the tests parse, section and pivot to known cell values. Also run once against two full filings on disk (3M FY2024 with date periods, Workday FY2025 with dateTime periods): every primary statement renders, no fact unassigned, parse 23 ms and 10 ms.🤖 Generated with Claude Code
https://claude.ai/code/session_01TBKj1VsfBpKsFY7PPcrCFu