Help us shape the future of Go! Take the 2026 Go Developer Survey

model

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package model is the normalized, source-agnostic output contract for a filing: the Document and the value types every other package produces, renders, caches, diffs, or scores. It is deliberately flat and JSON-first — pure data plus the custom marshaling the schema requires — and depends only on the standard library, so every other package can import it without a cycle. The parser (internal/ixbrl) produces these types; it does not define them.

Index

Constants

View Source
const (
	SchemaVersion = "1.0.0"
	ParserVersion = "0.1.0"
)

SchemaVersion is the consumer-facing JSON output contract (semver: a breaking change to the JSON shape bumps the major). ParserVersion is the extraction code's identity; the cache keys parsed output on it so a parser fix invalidates cached results without re-fetching bytes. They are distinct on purpose — see DESIGN.md §2.4.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Label       string
	ContextRef  string
	PeriodStart time.Time
	PeriodEnd   time.Time
	Instant     bool
}

Column is one reporting period: the contextRef whose facts fill the column and the period it covers.

func (Column) MarshalJSON

func (c Column) MarshalJSON() ([]byte, error)

MarshalJSON renders period dates as plain YYYY-MM-DD, matching the output schema rather than Go's default RFC3339 time encoding.

func (*Column) UnmarshalJSON

func (c *Column) UnmarshalJSON(data []byte) error

UnmarshalJSON is the inverse of MarshalJSON: it parses the YYYY-MM-DD period dates the schema uses (not RFC3339), so a Document round-trips through JSON. The parsed cache (Phase 10) depends on this — it stores canonical JSON and reloads it into a *Document.

type Confidence

type Confidence struct {
	Level             string  `json:"level"`
	RowMatchRate      float64 `json:"row_match_rate"`
	CellResolvedRate  float64 `json:"cell_resolved_rate"`
	UntaggedCellCount int     `json:"untagged_cell_count"`
}

Confidence is the calibrated trust signal for an extracted artifact. Level is the bucket every artifact carries; the rate fields describe how completely a projected table resolved and are left zero for non-table partitions.

type Document

type Document struct {
	Metadata   Metadata  `json:"metadata"`
	Sections   []Section `json:"sections"`
	Statements []Table   `json:"statements"`
}

Document is the normalized, source-agnostic representation of one filing: the single value every package after Phase 8 produces, renders, caches, diffs, or scores. It is flat and JSON-first.

type Kind

type Kind string

Kind distinguishes the narrative item sections (Business, Risk Factors, MD&A, …) from the financial-statements section, where the fact-stream projection applies rather than free-text rendering.

const (
	KindNarrative Kind = "narrative"
	KindFinancial Kind = "financial"
)

Section kinds.

type Metadata

type Metadata struct {
	Company       string     `json:"company,omitempty"`
	CIK           int64      `json:"cik,omitempty"`
	Ticker        string     `json:"ticker,omitempty"`
	Form          string     `json:"form,omitempty"`
	Accession     string     `json:"accession,omitempty"`
	FilingDate    string     `json:"filing_date,omitempty"`
	PeriodStart   string     `json:"period_start,omitempty"`
	PeriodEnd     string     `json:"period_end,omitempty"`
	SchemaVersion string     `json:"schema_version"`
	ParserVersion string     `json:"parser_version"`
	Source        Source     `json:"source"`
	Confidence    Confidence `json:"confidence"`
}

Metadata identifies the filing and stamps the output: the company and filing coordinates, the period reported, the schema/parser versions, the extractor source, and the document-level confidence (combining statement and section confidences). Dates are plain YYYY-MM-DD strings.

type Row

type Row struct {
	Label   string     `json:"label"`
	Concept string     `json:"concept,omitempty"`
	Type    RowType    `json:"type"`
	Depth   int        `json:"depth,omitempty"`
	Values  []*float64 `json:"values"`
}

Row is one statement line: a concept, its filing label, and its value in each column. A nil entry in Values is a cell with no matching fact — null, never zero.

type RowType

type RowType string

RowType classifies a statement row. A total caps a section, a subtotal is a parent line that also carries a value, and data is a leaf line item.

const (
	RowData     RowType = "data"
	RowSubtotal RowType = "subtotal"
	RowTotal    RowType = "total"
)

Row types.

type Section

type Section struct {
	Item   string  `json:"item"`
	Title  string  `json:"title"`
	Kind   Kind    `json:"kind"`
	Text   string  `json:"text,omitempty"`
	Tables []Table `json:"tables,omitempty"`
}

Section is one named part of a filing: its item identifier and canonical title, whether it is narrative or the financial-statements section, the rendered free text, and the tables that fall inside it.

type Source

type Source struct {
	Extractor     string `json:"extractor"`
	ParserVersion string `json:"parser_version"`
}

Source records which extractor produced an artifact and the parser version.

type Table

type Table struct {
	SchemaVersion string            `json:"schema_version"`
	Title         string            `json:"title,omitempty"`
	RoleURI       string            `json:"role_uri,omitempty"`
	Columns       []Column          `json:"columns"`
	Rows          []Row             `json:"rows"`
	Footnotes     map[string]string `json:"footnotes,omitempty"`
	Confidence    Confidence        `json:"confidence"`
	Source        Source            `json:"source"`
}

Table is a statement or narrative table projected onto rows × columns, either from the iXBRL fact stream or by spatial layout. The JSON tags are the output schema.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL