Skip to main content

Series bindings

Declarative series bindings describe how spreadsheet cells map to named dimensions (SDMX-style concepts) and how generated Python compute_* functions accept named tensors or scalars. Use as_records for a tidy list[dict] view.

They replace the retired label-detection heuristics (row_labels / column_labels on graph nodes). The machine source of truth is a sidecar manifest next to the workbook, not inferred geometry. Validation uses the JSON Schema shipped with the package at excel_grapher/series_bindings/series_binding.schema.json.

Package exports (generate_modules(...)) use inverted-tree: compute_* functions take explicit named-coordinate tensors or scalars and return tensors or scalars. Use as_records(compute, result) for a Records view. There is no bindings-free generate() path; callers who want a named compute_* API provide a sidecar. See Exporting standalone Python for the package layout.

Example workbook: series_bindings.xlsx with series_bindings.bindings.yaml

Hands-on walkthrough: Series bindings example (Quarto source)

JSON Schema

The schema below is read from the installed package (same file used by validate_bindings_document()):

JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://teal-insights.github.io/excel-grapher/series_binding.schema.json",
  "title": "Workbook series bindings",
  "description": "Declarative structure and spreadsheet bindings for workbook series. Shared series structure describes dimensions and data_range; optional input, output, internal, and constant blocks declare inverted-tree I/O, triangulation targets, or constants.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "series"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "enum": [
        "1.0.0",
        "1.1.0",
        "1.2.0",
        "1.3.0",
        "1.4.0",
        "1.5.0",
        "1.6.0",
        "1.7.0",
        "1.8.0",
        "1.9.0",
        "1.10.0",
        "1.11.0",
        "1.12.0",
        "1.13.0",
        "1.14.0",
        "1.15.0",
        "1.16.0",
        "1.17.0",
        "1.18.0",
        "1.19.0",
        "1.20.0",
        "1.21.0",
        "1.22.0"
      ],
      "description": "Schema version for tooling and migrations. 1.0.0\u20131.2.0: row_series and scalar (fully supported). 1.1.0: adds matrix layout (supported with explicit binds). 1.2.0: optional input/output direction blocks and output compute functions. 1.3.0: row_series renamed to series layout; load-time normalization accepts legacy row_series. 1.4.0: adds bool and datetime read modes and dtypes for dimensions and constants (ISO 8601 date strings in manifests). 1.5.0: grouped-row matrix geometry (skip/include/fill/missing on row_label and column_header binds, value_map bind kind, series-level exclude_rows) and optional view-level groups for export sequencing and documentation grouping. 1.6.0: input.mode override for user-editable formula cells (non-leaf input setters). 1.7.0: internal direction for non-I/O formula-cell key triangulation (intersect_graph_formulas validation). 1.8.0: optional dimension/attribute id separating dimension identity from concept, so multiple dimensions can share one concept; record fields and key entries use the effective id (id when declared, else concept) while concept keeps dtype inheritance from concept_scheme. Also adds optional per-dimension dtype overriding the concept-scheme dtype for same-concept dimensions with differing storage types. 1.9.0 (historical): optional input.reader name override for generated read_* duals of set_* setters; extra input.reader keys are now rejected. 1.10.0: optional output.compute.helper so compute_* evaluates collapsed / parameterized helpers from record dims instead of xl_cell(address) when a helper covers the published leaves. 1.11.0: constant direction for non-I/O graph-leaf bindings. Historical codegen emitted read_* without set_* or compute_*; inverted-tree imports constants from data. 1.12.0: series-level exclude_columns (ColumnSpec) symmetric with exclude_rows for carving non-data columns out of an expanded data_range. 1.13.0: optional input.domain so inverted-tree compute_* / Model arguments reject out-of-domain measure values (enum literals, integer between, real_between). 1.14.0: complementary shards with the same series id may declare different sheet/data_range (merged data_range is a list); bind.kind sheet_name reads the worksheet name of each data cell, with an optional values map from worksheet name to dimension code. 1.15.0: optional input.value_map on scalar input series maps public compute_* values to workbook cell needles (MATCH/IF labels); domain checks use the map keys. 1.16.0: input direction no longer requires a setter block; empty `input: {}` marks a series as an editable leaf. Extra setter/reader keys are rejected. Package export takes inputs as `compute_*` / `Model` arguments. 1.17.0: series-level axis_labels identifies a series whose values provide runtime labels for its sole key axis. 1.18.0: series-level relations compile greater_than / not_equal partner series ids to GreaterThanCell / NotEqualCell, aligned on the shared key. 1.19.0: series-level domain (enum / between / real_between / from_workbook); input.domain is accepted and normalized to the series-level key. constant implies from_workbook. Compiles to the CellTypeEnv dynamic-ref inference consumes. 1.20.0: bind.kind row_index and column_letter key each observation by the data cell's own 1-based row index or column letter (Sheet!D18 yields 18 and D) without a values map. 1.21.0: validation.catalog false marks an extract-only series: it still compiles into CellTypeEnv / DynamicRefConfig.from_bindings, but inverted-tree omits it from the catalog and data.py tensors. Fail closed if that series uniquely owns an on-graph formula cell. 1.22.0: domain may union enum with exactly one of between or real_between, so a text sentinel (or other literal) and a numeric interval are alternatives. A value matches when it is an enum member or lies in the interval. Measure dtype follows the interval arm. The two interval kinds cannot be combined."
    },
    "workbook": {
      "type": "string",
      "description": "Optional workbook filename or path used when validating bindings against a graph extract."
    },
    "concept_scheme": {
      "$ref": "#/$defs/ConceptScheme",
      "description": "Optional shared concept definitions referenced by series bindings in this file."
    },
    "series": {
      "type": "array",
      "minItems": 0,
      "items": {
        "$ref": "#/$defs/SeriesBinding"
      },
      "description": "One binding per series (input, output, internal, or constant). Empty lists are allowed for draft/placeholder shards."
    }
  },
  "$defs": {
    "A1Range": {
      "type": "string",
      "pattern": "!",
      "description": "Sheet-qualified range using project target conventions: Inputs!F5:J5, Inputs!F5:Inputs!J5, 'My Sheet'!A1:'My Sheet'!B2. Parsed via expand_targets_to_roots (not a single regex)."
    },
    "DefinedName": {
      "type": "string",
      "pattern": "^[A-Za-z_][A-Za-z0-9_.]*$",
      "description": "Workbook defined name resolving to a single cell or rectangular range (requires workbook or graph named-range maps at expand time)."
    },
    "DataRange": {
      "description": "Leaf cells for this binding: sheet-qualified range and/or defined name.",
      "oneOf": [
        {
          "$ref": "#/$defs/A1Range"
        },
        {
          "$ref": "#/$defs/DefinedName"
        }
      ]
    },
    "DataRangeList": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/DataRange"
      },
      "description": "One or more DataRange entries concatenated at resolve time (complementary shards)."
    },
    "SheetName": {
      "type": "string",
      "minLength": 1,
      "description": "Worksheet name (must match a data_range sheet)."
    },
    "SheetNameList": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/SheetName"
      },
      "description": "Worksheet names covered by a multi-range complementary series."
    },
    "A1Cell": {
      "type": "string",
      "pattern": "^[^!]+![A-Z]{1,3}[1-9][0-9]*$",
      "description": "Sheet-qualified A1 cell, e.g. Inputs!A2."
    },
    "ColumnLetter": {
      "type": "string",
      "pattern": "^[A-Z]{1,3}$",
      "description": "Excel column letters without row, e.g. A or AA."
    },
    "ConceptId": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
      "description": "Stable concept identifier (SDMX-style ids such as REF_AREA or local ids such as DESCRIPTION)."
    },
    "DimensionId": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
      "description": "Dimension (or attribute) identifier distinguishing the dimension from the concept it references (SDMX concept identity). Defaults to the concept id when omitted; effective ids must be unique within a series' structure. Record fields and key entries use the effective id; concept_scheme dtype inheritance keys on concept."
    },
    "ScalarValue": {
      "description": "Constant attribute or context value stored in records when include_in_record is true. Datetime constants use ISO 8601 strings (e.g. 2024-01-15 or 2024-01-15T00:00:00); tooling coerces them when read or dtype is datetime.",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ]
    },
    "RowSpec": {
      "description": "One 1-based row index, or an inclusive row range string like 3:8.",
      "oneOf": [
        {
          "type": "integer",
          "minimum": 1
        },
        {
          "type": "string",
          "pattern": "^[1-9][0-9]*(:[1-9][0-9]*)?$"
        }
      ]
    },
    "ColumnSpec": {
      "type": "string",
      "pattern": "^[A-Z]{1,3}(:[A-Z]{1,3})?$",
      "description": "One column letter, or an inclusive column range string like C:D."
    },
    "MissingPolicy": {
      "description": "What to do when no source label exists for a data cell: error (default) fails resolution; null keys the cell on None. YAML null is accepted as a spelling of \"null\".",
      "enum": [
        "error",
        "null",
        null
      ],
      "default": "error"
    },
    "ReadAs": {
      "type": "string",
      "enum": [
        "string",
        "int",
        "float",
        "number",
        "bool",
        "datetime",
        "auto"
      ],
      "default": "auto",
      "description": "How to coerce a cell or header value into a record field."
    },
    "Normalize": {
      "type": "string",
      "enum": [
        "none",
        "strip",
        "strip_trailing_unit"
      ],
      "default": "strip",
      "description": "Label normalization applied after reading strings from the sheet."
    },
    "ConceptScheme": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "concepts"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "concepts": {
          "type": "array",
          "minItems": 0,
          "items": {
            "$ref": "#/$defs/ConceptDefinition"
          }
        }
      }
    },
    "ConceptDefinition": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/ConceptId"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "dtype": {
          "type": "string",
          "enum": [
            "string",
            "int",
            "float",
            "number",
            "bool",
            "datetime"
          ]
        },
        "sdmx_concept": {
          "type": "string",
          "description": "Optional mapping to an external SDMX concept id for documentation."
        }
      }
    },
    "Bind": {
      "description": "How to obtain a concept value from the workbook for each leaf cell in data_range.",
      "oneOf": [
        {
          "$ref": "#/$defs/BindDataCell"
        },
        {
          "$ref": "#/$defs/BindCell"
        },
        {
          "$ref": "#/$defs/BindColumnHeader"
        },
        {
          "$ref": "#/$defs/BindRowLabel"
        },
        {
          "$ref": "#/$defs/BindValueMap"
        },
        {
          "$ref": "#/$defs/BindConstant"
        },
        {
          "$ref": "#/$defs/BindSheetName"
        },
        {
          "$ref": "#/$defs/BindRowIndex"
        },
        {
          "$ref": "#/$defs/BindColumnLetter"
        }
      ]
    },
    "BindDataCell": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind"
      ],
      "properties": {
        "kind": {
          "const": "data_cell"
        },
        "read": {
          "$ref": "#/$defs/ReadAs"
        }
      }
    },
    "BindCell": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "address"
      ],
      "properties": {
        "kind": {
          "const": "cell"
        },
        "address": {
          "$ref": "#/$defs/A1Cell"
        },
        "read": {
          "$ref": "#/$defs/ReadAs"
        },
        "normalize": {
          "$ref": "#/$defs/Normalize"
        }
      }
    },
    "BindColumnHeader": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "header_row"
      ],
      "not": {
        "required": [
          "skip",
          "include"
        ]
      },
      "properties": {
        "kind": {
          "const": "column_header"
        },
        "header_row": {
          "type": "integer",
          "minimum": 1,
          "description": "1-based row index containing column headers for the data columns."
        },
        "skip": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ColumnSpec"
          },
          "description": "Columns in header_row that are not label sources for this dimension. Mutually exclusive with include."
        },
        "include": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ColumnSpec"
          },
          "description": "The only columns in header_row that are label sources for this dimension. Mutually exclusive with skip."
        },
        "fill": {
          "type": "boolean",
          "default": false,
          "description": "When true, a data column whose header source is skipped or empty inherits the nearest non-skipped, non-empty header to its left."
        },
        "missing": {
          "$ref": "#/$defs/MissingPolicy"
        },
        "read": {
          "$ref": "#/$defs/ReadAs"
        },
        "normalize": {
          "$ref": "#/$defs/Normalize"
        }
      }
    },
    "BindRowLabel": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "label_column"
      ],
      "not": {
        "required": [
          "skip",
          "include"
        ]
      },
      "description": "Read the label on the same row as the data cell from label_column (typical for indicator text in column A).",
      "properties": {
        "kind": {
          "const": "row_label"
        },
        "label_column": {
          "$ref": "#/$defs/ColumnLetter"
        },
        "skip": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RowSpec"
          },
          "description": "Rows in label_column that are not label sources for this dimension (e.g. group header rows for a sub-label key). Mutually exclusive with include."
        },
        "include": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RowSpec"
          },
          "description": "The only rows in label_column that are label sources for this dimension (e.g. group header rows for a band key). Mutually exclusive with skip."
        },
        "fill": {
          "type": "boolean",
          "default": false,
          "description": "When true, a data row whose label source is skipped or empty inherits the nearest non-skipped, non-empty label above it."
        },
        "missing": {
          "$ref": "#/$defs/MissingPolicy"
        },
        "read": {
          "$ref": "#/$defs/ReadAs"
        },
        "normalize": {
          "$ref": "#/$defs/Normalize"
        }
      }
    },
    "BindValueMap": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "values"
      ],
      "description": "Key data rows or columns by manifest values when labels are absent from the sheet. Axis is inferred from spec syntax: row specs (3, 3:4) key data rows; column specs (C, C:D) key data columns. Map keys within one bind must share one scalar type.",
      "properties": {
        "kind": {
          "const": "value_map"
        },
        "values": {
          "type": "object",
          "minProperties": 1,
          "additionalProperties": {
            "oneOf": [
              {
                "$ref": "#/$defs/RowSpec"
              },
              {
                "$ref": "#/$defs/ColumnSpec"
              },
              {
                "type": "array",
                "minItems": 1,
                "items": {
                  "oneOf": [
                    {
                      "$ref": "#/$defs/RowSpec"
                    },
                    {
                      "$ref": "#/$defs/ColumnSpec"
                    }
                  ]
                }
              }
            ]
          },
          "description": "Mapping from dimension value to the row or column specs it covers."
        },
        "missing": {
          "$ref": "#/$defs/MissingPolicy"
        },
        "read": {
          "$ref": "#/$defs/ReadAs"
        }
      }
    },
    "BindConstant": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "value"
      ],
      "properties": {
        "kind": {
          "const": "constant"
        },
        "value": {
          "$ref": "#/$defs/ScalarValue"
        }
      }
    },
    "BindSheetName": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind"
      ],
      "properties": {
        "kind": {
          "const": "sheet_name"
        },
        "values": {
          "type": "object",
          "minProperties": 1,
          "additionalProperties": {
            "$ref": "#/$defs/ScalarValue"
          },
          "description": "Map from worksheet name to dimension code. When omitted, the worksheet name of each data cell is the dimension value."
        },
        "read": {
          "$ref": "#/$defs/ReadAs"
        },
        "normalize": {
          "$ref": "#/$defs/Normalize"
        }
      }
    },
    "BindRowIndex": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind"
      ],
      "description": "Key each observation by the data cell's own 1-based row index. For Sheet!D18 yields 18. No values map.",
      "properties": {
        "kind": {
          "const": "row_index"
        },
        "read": {
          "$ref": "#/$defs/ReadAs"
        }
      }
    },
    "BindColumnLetter": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind"
      ],
      "description": "Key each observation by the data cell's own column letter. For Sheet!D18 yields D. No values map.",
      "properties": {
        "kind": {
          "const": "column_letter"
        },
        "read": {
          "$ref": "#/$defs/ReadAs"
        },
        "normalize": {
          "$ref": "#/$defs/Normalize"
        }
      }
    },
    "GroupRef": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "path"
      ],
      "description": "View-level group membership for export sequencing and documentation. Affects only the generated API shape, never graph extraction or record semantics.",
      "properties": {
        "path": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          },
          "description": "Nested group labels, outermost to innermost (e.g. ['Climate scenarios', 'Paris'])."
        },
        "order": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Optional intra-group sequencing hint. Members without order fall back to binding declaration order."
        }
      }
    },
    "DimensionScope": {
      "type": "string",
      "enum": [
        "series",
        "cell"
      ],
      "description": "series: one value for the entire binding (e.g. country in A2). cell: varies per leaf (e.g. TIME_PERIOD from column header)."
    },
    "DimensionRole": {
      "type": "string",
      "enum": [
        "key",
        "attribute"
      ],
      "description": "key: participates in record matching. attribute: metadata only unless listed in key."
    },
    "Dimension": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "concept",
        "role",
        "scope",
        "bind"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/DimensionId"
        },
        "concept": {
          "$ref": "#/$defs/ConceptId"
        },
        "dtype": {
          "type": "string",
          "enum": [
            "string",
            "int",
            "float",
            "number",
            "bool",
            "datetime"
          ],
          "description": "Per-dimension storage type overriding the concept-scheme dtype for this dimension only. Use when same-concept dimensions store different types (e.g. an int projection axis and a datetime reference period sharing TIME_PERIOD); an explicit bind read still wins for coercion."
        },
        "role": {
          "const": "key"
        },
        "scope": {
          "$ref": "#/$defs/DimensionScope"
        },
        "bind": {
          "$ref": "#/$defs/Bind"
        },
        "include_in_record": {
          "type": "boolean",
          "default": true,
          "description": "When false and scope is series, value is used for validation only and omitted from emitted Records unless listed in series_context."
        }
      }
    },
    "Attribute": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "concept",
        "role"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/DimensionId"
        },
        "concept": {
          "$ref": "#/$defs/ConceptId"
        },
        "role": {
          "const": "attribute"
        },
        "bind": {
          "$ref": "#/$defs/Bind"
        },
        "value": {
          "$ref": "#/$defs/ScalarValue",
          "description": "Shorthand for bind.kind constant when the attribute is fixed for the series."
        },
        "include_in_record": {
          "type": "boolean",
          "default": false
        }
      },
      "oneOf": [
        {
          "required": [
            "bind"
          ]
        },
        {
          "required": [
            "value"
          ]
        }
      ]
    },
    "Measure": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "concept",
        "bind"
      ],
      "properties": {
        "concept": {
          "type": "string",
          "const": "OBS_VALUE",
          "description": "Observation value concept (required field name value in Records)."
        },
        "dtype": {
          "type": "string",
          "enum": [
            "int",
            "float",
            "number",
            "string",
            "bool",
            "datetime"
          ],
          "default": "float"
        },
        "bind": {
          "allOf": [
            {
              "$ref": "#/$defs/BindDataCell"
            }
          ]
        }
      }
    },
    "ComputeHelper": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$",
          "description": "Parameterized helper callable `(ctx, **dims) -> CellValue` covering the published output leaves (typically a post-refactor internals helper)."
        },
        "dims": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "description": "Binding concept / effective ids passed as kwargs from the static record. Defaults to the series key when omitted."
        }
      }
    },
    "Compute": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^compute_[a-z][a-z0-9_]*$",
          "description": "Generated Python function name, e.g. compute_borvelia_primary_balance."
        },
        "record_contract": {
          "type": "string",
          "const": "records",
          "default": "records",
          "description": "list[Record] with OBS_VALUE and all declared dimensions."
        },
        "include_address": {
          "type": "boolean",
          "default": false,
          "description": "When true, each output record includes address or cell_address."
        },
        "helper": {
          "$ref": "#/$defs/ComputeHelper",
          "description": "Optional parameterized helper covering this series' published leaves. When set, compute_* calls the helper from static record dims instead of xl_cell(address). Leaves without helper coverage (via address overlay) still use xl_cell."
        }
      }
    },
    "InputDomainBounds": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "min": {
          "type": "number",
          "description": "Inclusive lower bound."
        },
        "max": {
          "type": "number",
          "description": "Inclusive upper bound."
        }
      },
      "anyOf": [
        {
          "required": [
            "min"
          ]
        },
        {
          "required": [
            "max"
          ]
        }
      ],
      "description": "Closed numeric interval; at least one of min or max is required."
    },
    "InputDomainIntBounds": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "min": {
          "type": "integer",
          "description": "Inclusive lower bound."
        },
        "max": {
          "type": "integer",
          "description": "Inclusive upper bound."
        }
      },
      "anyOf": [
        {
          "required": [
            "min"
          ]
        },
        {
          "required": [
            "max"
          ]
        }
      ],
      "description": "Closed integer interval; at least one of min or max is required."
    },
    "InputDomain": {
      "description": "Allowed measure values. One kind: enum, between, real_between, or from_workbook; or a union of enum with exactly one of between or real_between (1.22.0). enum/between/real_between are enforced on compute_* / Model arguments. A union enum member is matched against the caller's original value, before int-to-float coercion; other values are checked after that coercion. A union value matches when it is an enum member or lies in the interval. from_workbook pins each bound cell to its cached workbook value (dynamic-ref env only) and cannot be combined with another kind. `between` requires measure dtype `int`; `real_between` requires `float` or `number`. Bind validation and export fail closed on a mismatch. A union cannot combine between with real_between.",
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "enum"
          ],
          "properties": {
            "enum": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "description": "Closed set of allowed measure values (exact match)."
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "between"
          ],
          "properties": {
            "between": {
              "$ref": "#/$defs/InputDomainIntBounds",
              "description": "Inclusive integer bounds (Between semantics)."
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "real_between"
          ],
          "properties": {
            "real_between": {
              "$ref": "#/$defs/InputDomainBounds",
              "description": "Inclusive real bounds (RealBetween semantics)."
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "from_workbook"
          ],
          "properties": {
            "from_workbook": {
              "type": "boolean",
              "const": true,
              "description": "Pin each bound cell to a singleton domain from its cached workbook value."
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "enum",
            "between"
          ],
          "properties": {
            "enum": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "description": "Literal arm of a union. A value matches when it equals a member or lies in between."
            },
            "between": {
              "$ref": "#/$defs/InputDomainIntBounds",
              "description": "Inclusive integer arm of a union (Between semantics)."
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "enum",
            "real_between"
          ],
          "properties": {
            "enum": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "description": "Literal arm of a union. A value matches when it equals a member or lies in real_between."
            },
            "real_between": {
              "$ref": "#/$defs/InputDomainBounds",
              "description": "Inclusive real arm of a union (RealBetween semantics)."
            }
          }
        }
      ]
    },
    "InputDirection": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "leaf",
            "override"
          ],
          "default": "leaf",
          "description": "Input binding semantics. leaf (default): data_range cells must be graph leaves. override: allow formula cells with dependents (typed-over-formula validation)."
        },
        "domain": {
          "$ref": "#/$defs/InputDomain",
          "description": "Optional measure-value domain. Accepted and normalized to series-level `domain` at load time (1.19.0). When `value_map` is set and `domain` is omitted, compute_* checks use the map keys and the cell env uses the workbook needles."
        },
        "value_map": {
          "$ref": "#/$defs/InputValueMap",
          "description": "Optional map from public scalar input values to workbook cell values (MATCH/IF needles). Applied after `input.domain` at the inverted-tree orchestrator before the value enters any expression. Distinct from bind.kind `value_map`."
        }
      }
    },
    "InputValueMap": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "$ref": "#/$defs/ScalarValue"
      },
      "description": "Public scalar value to workbook needle. Keys are the caller-facing domain; values are the literal cell text the formula compares against."
    },
    "OutputDirection": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "compute"
      ],
      "properties": {
        "compute": {
          "$ref": "#/$defs/Compute"
        }
      }
    },
    "InternalDirection": {
      "type": "object",
      "additionalProperties": false,
      "description": "Marks a non-I/O binding for formula-cell key triangulation."
    },
    "ConstantDirection": {
      "type": "object",
      "additionalProperties": false,
      "description": "Marks a non-I/O graph-leaf binding. No public compute_* API is emitted."
    },
    "Layout": {
      "type": "string",
      "enum": [
        "series",
        "scalar",
        "matrix"
      ],
      "description": "Optional declarative intent for analysts and layout-specific validation. Resolution and codegen use bind kinds, not layout name. series: one-dimensional data_range with at least one cell-scoped dimension when declared. scalar: single leaf. matrix: rectangular multi-row data_range with at least two dimensions and a cell-scoped dimension when declared."
    },
    "SeriesRelation": {
      "type": "object",
      "additionalProperties": false,
      "minProperties": 1,
      "maxProperties": 1,
      "description": "One cell-to-cell comparison against a partner series, aligned on the shared key (1.18.0). Partner is a series id, not an A1 address.",
      "properties": {
        "greater_than": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$",
          "description": "Partner series id. The declaring cell is strictly greater than the partner cell at the same key (GreaterThanCell)."
        },
        "not_equal": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$",
          "description": "Partner series id. The declaring cell is never equal to the partner cell at the same key (NotEqualCell)."
        }
      }
    },
    "SeriesBinding": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "sheet",
        "data_range",
        "structure",
        "key"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$",
          "description": "Stable binding id, e.g. borvelia_primary_balance."
        },
        "sheet": {
          "description": "Worksheet name (must match data_range sheet). A list when complementary shards cover multiple sheets.",
          "oneOf": [
            {
              "$ref": "#/$defs/SheetName"
            },
            {
              "$ref": "#/$defs/SheetNameList"
            }
          ]
        },
        "data_range": {
          "description": "Numeric cells for this series; codegen intersects with the extracted graph. A list concatenates complementary shard ranges at resolve time.",
          "oneOf": [
            {
              "$ref": "#/$defs/DataRange"
            },
            {
              "$ref": "#/$defs/DataRangeList"
            }
          ]
        },
        "layout": {
          "$ref": "#/$defs/Layout",
          "description": "Optional analyst-facing layout intent; triggers layout-specific schema and validation rules when set."
        },
        "axis_labels": {
          "$ref": "#/$defs/DimensionId",
          "description": "The sole key axis whose runtime labels are supplied by this series' values."
        },
        "relations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SeriesRelation"
          },
          "uniqueItems": true,
          "description": "Optional cell-to-cell comparisons against partner series, aligned on the shared key (1.18.0). greater_than compiles to GreaterThanCell; not_equal to NotEqualCell. Partner is a series id, not an A1 address."
        },
        "domain": {
          "$ref": "#/$defs/InputDomain",
          "description": "Optional series-level measure domain (1.19.0). One of enum, between, real_between, or from_workbook, or a union of enum with exactly one interval (1.22.0). input.domain is accepted and normalized to this key. constant implies from_workbook when omitted. Feeds compute_* checks (except from_workbook) and the CellTypeEnv compiler."
        },
        "exclude_rows": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RowSpec"
          },
          "description": "Rows within data_range that are never data (e.g. group header or separator rows referenced by lookup formulas). Applied before graph-leaf intersection."
        },
        "exclude_columns": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ColumnSpec"
          },
          "description": "Columns within data_range that are never data for this series (e.g. milestone years published on a separate summary series). Applied after data_range expansion alongside exclude_rows, before graph-leaf intersection. Distinct from column_header skip/include, which only filter label sources."
        },
        "editable": {
          "type": "boolean",
          "default": true
        },
        "input": {
          "$ref": "#/$defs/InputDirection"
        },
        "output": {
          "$ref": "#/$defs/OutputDirection"
        },
        "internal": {
          "$ref": "#/$defs/InternalDirection"
        },
        "constant": {
          "$ref": "#/$defs/ConstantDirection"
        },
        "groups": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/GroupRef"
          },
          "description": "Optional view-level groups for documentation sequencing. Omitted or empty reproduces the flat catalog order."
        },
        "structure": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "measure",
            "dimensions"
          ],
          "properties": {
            "measure": {
              "$ref": "#/$defs/Measure"
            },
            "dimensions": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/Dimension"
              }
            },
            "attributes": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/Attribute"
              },
              "default": []
            }
          }
        },
        "key": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DimensionId"
          },
          "uniqueItems": true,
          "description": "Effective dimension ids (dimension id when declared, else concept) required on each incoming record for matching (MVP series: typically [TIME_PERIOD] when country and indicator are series-scoped). Scalar layout may use an empty key when the binding resolves to a single cell."
        },
        "series_context": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/ScalarValue"
          },
          "description": "Fixed key-values attached to every record and setter docs; not used for matching unless also listed in key."
        },
        "validation": {
          "$ref": "#/$defs/Validation"
        },
        "sdmx_notes": {
          "type": "string",
          "description": "Human-readable SDMX fit commentary; not consumed by codegen."
        },
        "notes": {
          "type": "string",
          "description": "Free-form analyst notes."
        }
      },
      "allOf": [
        {
          "$ref": "#/$defs/SeriesBindingDirectionRules"
        },
        {
          "$ref": "#/$defs/SeriesBindingInternalExclusivity"
        },
        {
          "$ref": "#/$defs/SeriesBindingConstantExclusivity"
        },
        {
          "$ref": "#/$defs/SeriesBindingLayoutKeyRules"
        },
        {
          "$ref": "#/$defs/SeriesBindingInputValueMapRules"
        },
        {
          "$ref": "#/$defs/SeriesBindingMvpRules"
        },
        {
          "$ref": "#/$defs/SeriesBindingMatrixRules"
        }
      ]
    },
    "SeriesBindingInputValueMapRules": {
      "description": "input.value_map is allowed only on layout scalar input series (1.15.0).",
      "if": {
        "required": [
          "input"
        ],
        "properties": {
          "input": {
            "required": [
              "value_map"
            ]
          }
        }
      },
      "then": {
        "required": [
          "layout"
        ],
        "properties": {
          "layout": {
            "const": "scalar"
          }
        }
      }
    },
    "SeriesBindingLayoutKeyRules": {
      "description": "Non-scalar layouts require at least one key and dimension; scalar may use empty key and dimensions.",
      "if": {
        "properties": {
          "layout": {
            "const": "scalar"
          }
        },
        "required": [
          "layout"
        ]
      },
      "then": {
        "properties": {
          "key": {
            "minItems": 0
          },
          "structure": {
            "properties": {
              "dimensions": {
                "minItems": 0
              }
            }
          }
        }
      },
      "else": {
        "properties": {
          "key": {
            "minItems": 1
          },
          "structure": {
            "properties": {
              "dimensions": {
                "minItems": 1
              }
            }
          }
        }
      }
    },
    "SeriesBindingDirectionRules": {
      "description": "Each series must declare at least one of input, output, internal, or constant.",
      "anyOf": [
        {
          "required": [
            "input"
          ]
        },
        {
          "required": [
            "output"
          ]
        },
        {
          "required": [
            "internal"
          ]
        },
        {
          "required": [
            "constant"
          ]
        }
      ]
    },
    "SeriesBindingInternalExclusivity": {
      "description": "internal direction is mutually exclusive with input, output, and constant.",
      "if": {
        "required": [
          "internal"
        ]
      },
      "then": {
        "not": {
          "anyOf": [
            {
              "required": [
                "input"
              ]
            },
            {
              "required": [
                "output"
              ]
            },
            {
              "required": [
                "constant"
              ]
            }
          ]
        }
      }
    },
    "SeriesBindingConstantExclusivity": {
      "description": "constant direction is mutually exclusive with input, output, and internal.",
      "if": {
        "required": [
          "constant"
        ]
      },
      "then": {
        "not": {
          "anyOf": [
            {
              "required": [
                "input"
              ]
            },
            {
              "required": [
                "output"
              ]
            },
            {
              "required": [
                "internal"
              ]
            }
          ]
        }
      }
    },
    "SeriesBindingMatrixRules": {
      "description": "Constraints for layout matrix (1.1.0).",
      "if": {
        "properties": {
          "layout": {
            "const": "matrix"
          }
        },
        "required": [
          "layout"
        ]
      },
      "then": {
        "properties": {
          "structure": {
            "properties": {
              "dimensions": {
                "type": "array",
                "minItems": 2,
                "contains": {
                  "type": "object",
                  "properties": {
                    "scope": {
                      "const": "cell"
                    }
                  },
                  "required": [
                    "scope"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "SeriesBindingMvpRules": {
      "description": "MVP constraints for one-series-per-id layout rules.",
      "allOf": [
        {
          "if": {
            "properties": {
              "layout": {
                "const": "series"
              }
            },
            "required": [
              "layout"
            ]
          },
          "then": {
            "properties": {
              "structure": {
                "properties": {
                  "dimensions": {
                    "type": "array",
                    "contains": {
                      "type": "object",
                      "properties": {
                        "scope": {
                          "const": "cell"
                        }
                      },
                      "required": [
                        "scope"
                      ]
                    },
                    "minItems": 1
                  }
                }
              }
            }
          }
        }
      ]
    },
    "Validation": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "intersect_graph_leaves": {
          "type": "boolean",
          "default": true,
          "description": "When true, every cell in data_range must be a leaf in the extracted dependency graph (input leaf mode and constant bindings)."
        },
        "require_unique_key": {
          "type": "boolean",
          "default": true,
          "description": "When true, resolved key tuples must be unique across leaves in data_range. Keyed inverted-tree catalog series require unique keys; false is incompatible with a keyed catalog series. Extract-only series (`catalog: false`) default this to false."
        },
        "catalog": {
          "type": "boolean",
          "default": true,
          "description": "When true (the default), inverted-tree catalogs this series as a tensor (`data.py`, occupancy, unique keys). When false, the series is extract-only: it still compiles into CellTypeEnv / DynamicRefConfig.from_bindings and is omitted from the catalog. Fail closed if the series uniquely owns an on-graph formula cell."
        },
        "fail_on_empty_leaf": {
          "type": "boolean",
          "default": true
        },
        "warn_on_partial_overlap": {
          "type": "boolean",
          "default": true,
          "description": "When true, emit a warning when data_range cells are skipped because they are absent from the graph."
        },
        "intersect_graph_nodes": {
          "type": "boolean",
          "default": true,
          "description": "When true for output bindings, only cells present in the extracted graph are included."
        },
        "intersect_graph_formulas": {
          "type": "boolean",
          "default": true,
          "description": "When true for internal bindings, only formula cells present in the extracted graph are included."
        }
      }
    }
  },
  "examples": [
    {
      "schema_version": "1.3.0",
      "workbook": "lic_inputs.xlsx",
      "series": [
        {
          "id": "borvelia_primary_balance",
          "sheet": "Inputs",
          "data_range": "Inputs!F5:J5",
          "layout": "series",
          "editable": true,
          "structure": {
            "measure": {
              "concept": "OBS_VALUE",
              "dtype": "float",
              "bind": {
                "kind": "data_cell",
                "read": "float"
              }
            },
            "dimensions": [
              {
                "concept": "REF_AREA",
                "role": "key",
                "scope": "series",
                "bind": {
                  "kind": "cell",
                  "address": "Inputs!A2",
                  "read": "string",
                  "normalize": "strip"
                },
                "include_in_record": false
              },
              {
                "concept": "INDICATOR",
                "role": "key",
                "scope": "series",
                "bind": {
                  "kind": "row_label",
                  "label_column": "A",
                  "read": "string",
                  "normalize": "strip_trailing_unit"
                },
                "include_in_record": false
              },
              {
                "concept": "TIME_PERIOD",
                "role": "key",
                "scope": "cell",
                "bind": {
                  "kind": "column_header",
                  "header_row": 1,
                  "read": "int"
                }
              }
            ],
            "attributes": [
              {
                "concept": "UNIT_MEASURE",
                "role": "attribute",
                "value": "PC_GDP",
                "include_in_record": true
              }
            ]
          },
          "key": [
            "TIME_PERIOD"
          ],
          "series_context": {
            "REF_AREA": "Borvelia",
            "INDICATOR": "Primary balance (% of GDP)"
          },
          "validation": {
            "intersect_graph_leaves": true,
            "require_unique_key": true
          },
          "sdmx_notes": "Wide row: TIME_PERIOD from row 1 offsets 1-5; REF_AREA from A2; indicator from A5.",
          "input": {}
        }
      ]
    },
    {
      "schema_version": "1.1.0",
      "workbook": "lic_inputs.xlsx",
      "series": [
        {
          "id": "country_block_primary_balance",
          "sheet": "Inputs",
          "data_range": "Inputs!F3:J8",
          "layout": "matrix",
          "structure": {
            "measure": {
              "concept": "OBS_VALUE",
              "bind": {
                "kind": "data_cell",
                "read": "float"
              }
            },
            "dimensions": [
              {
                "concept": "REF_AREA",
                "role": "key",
                "scope": "cell",
                "bind": {
                  "kind": "row_label",
                  "label_column": "A"
                }
              },
              {
                "concept": "INDICATOR",
                "role": "key",
                "scope": "cell",
                "bind": {
                  "kind": "row_label",
                  "label_column": "A"
                }
              },
              {
                "concept": "TIME_PERIOD",
                "role": "key",
                "scope": "cell",
                "bind": {
                  "kind": "column_header",
                  "header_row": 1,
                  "read": "int"
                }
              }
            ]
          },
          "key": [
            "REF_AREA",
            "INDICATOR",
            "TIME_PERIOD"
          ],
          "notes": "Illustrative 1.1.0 matrix binding with explicit row_label and column_header binds.",
          "input": {}
        }
      ]
    }
  ]
}

Authoring conventions

Topic Convention
Format YAML by default (.bindings.yaml); JSON (.bindings.json) also accepted
Location One sidecar per workbook, colocated with the .xlsx
Granularity (MVP) One series[] entry per logical indicator → one compute_* argument (layout: series)
Naming Stable id (snake_case); becomes the compute_* / Model argument name
Mixed-series leaves To tune a retained graph leaf inside an internal/output range, also bind that cell as a separate input or constant series
Non-executable prose sdmx_notes, notes — documentation only

Default file layout

lic_inputs.xlsx
lic_inputs.bindings.yaml    # schema_version, workbook, series[]

All series for that workbook live in a single series[] array.

Optional per-sheet shards

For large workbooks, split by sheet and merge at load time:

lic_inputs.xlsx
lic_inputs.bindings/
  Inputs.bindings.yaml
  Assumptions.bindings.yaml
  internals.bindings.yaml   # optional non-I/O formula-cell triangulation

Rules:

  • Same schema_version and workbook in every shard (error otherwise).
  • Union series[] by id. Duplicate ids within one shard are an error.
  • Duplicate ids across shards merge:
    • Direction composition: sheet, data_range, and structure match — combine input / output / internal / constant blocks (conflicting blocks error).
    • Complementary ranges (1.14.0): sheet / data_range may differ when shards share direction, key, and dimension shape. Resolve concatenates cells. A scenario dimension may use a different constant (or bind.kind: sheet_name) per shard without counting as a structural conflict.
  • load_series_bindings(path) accepts a file or directory of *.bindings.{yaml,yml,json}.

Non-goals: bindings embedded inside the xlsx; one file per series; repo-wide manifest without a workbook field.

Complementary shards (1.14.0)

Excel workbooks often paste the same statement onto scenario sheets (Baseline, B1_GDP_ext, …): identical row labels and year headers, different numbers. Author one series id per economic line, one shard per sheet:

# baseline.bindings.yaml
schema_version: "1.14.0"
series:
  - id: external_debt_nominal
    sheet: Baseline
    data_range: Baseline!C12:X12
    layout: series
    internal: {}
    structure:
      measure:
        concept: OBS_VALUE
        dtype: float
        bind: {kind: data_cell, read: float}
      dimensions:
        - id: SCENARIO
          concept: SCENARIO
          role: key
          scope: cell
          bind: {kind: constant, value: Baseline}
        - id: TIME_PERIOD
          concept: TIME_PERIOD
          role: key
          scope: cell
          bind: {kind: column_header, header_row: 8, read: int}
    key: [SCENARIO, TIME_PERIOD]

A second shard with sheet: B1, data_range: B1!C12:X12, and SCENARIO constant B1 merges into one series whose resolved cells include both ranges, keyed by (SCENARIO, TIME_PERIOD).

To share an identical structure block across shards, bind the scenario to the worksheet name:

bind: {kind: sheet_name}                        # value is the sheet name
bind: {kind: sheet_name, values: {Baseline DSA: Baseline, B1_GDP_ext: B1}}

A single file may also declare data_range (and sheet) as lists covering every complementary rectangle. Putting two entries with the same id in one file is still an error.

Input and output direction blocks

Each series[] entry shares structure (data_range, layout, structure, key) and declares optional direction blocks:

  • input — editable series (input: {} is enough). Optional domain, value_map, and mode. Package compute_* / Model take these as named arguments.
  • output.compute — generated compute returns all declared dimensions plus computed OBS_VALUE per graph cell in data_range.
  • internal — resolve per-cell {address, key, record} for formula nodes without emitting compute_* APIs.
  • constant — bind graph leaves (fixed parameters / scenario knobs / lookup seeds) without a public compute_*.

At least one of input, output, internal, or constant is required per series (legacy layout: row_series is normalized to series).

Input mode: leaf vs override (schema 1.6.0+)

By default, input bindings use input.mode: leaf: every cell in data_range must be a graph leaf (a value cell with no formula in the dependency graph). If data_range includes a formula cell, validation fails with non_leaf_input_overlap instead of silently skipping it.

Use input.mode: override for the Excel typed-over-formula pattern: cells that keep a formula in the workbook but callers may still supply as public compute_* / Model arguments. Override bindings:

  • Resolve graph nodes in data_range (formula cells and, when mixed, leaf cells too).
  • Require at least one formula cell in the range (no_formula_override_targets otherwise).
  • Package export emits the series as an optional input (there is no set_* method). The default is unset, so omitting the argument evaluates the template formula. A compute_* / Model argument, or a literal in a case workbook, displaces that formula for the evaluation walk. from_workbook reads the cell itself: a remaining formula stays unset, so the extracted formula runs even when the cached result is stale, and a literal binds in its place. A literal outside the series domain fails closed. An untouched template matches from_defaults.
  • Leave graph formulas and dependency edges unchanged (evaluation-time displacement only).
schema_version: "1.6.0"
series:
  - id: productivity_turning_point
    sheet: Productivity
    data_range: Productivity!J21
    layout: scalar
    input:
      mode: override
    structure:
      measure:
        concept: OBS_VALUE
        dtype: float
        bind: { kind: data_cell }
      dimensions: []
    key: []

Example manifest: formula_override.bindings.yaml.

Migration (all schema versions): Leaf-mode bindings that accidentally included formula cells previously emitted a partial_graph_overlap warning and dropped those cells. They now error at validation. Either narrow data_range to leaves only or declare input.mode: override.

Evaluator note: Durable override inputs (this feature) differ from transient per-call overlays tracked in issue #122. FormulaEvaluator does not yet expose equivalent durable override semantics.

Internal direction (schema 1.7.0+)

Use internal: {} for formula cells that need the same dimensional key machinery as public I/O bindings but should not generate compute_* functions. Typical consumers are extraction pipelines that triangulate internal computation cells by concept keys (for example ref_0[TIME_PERIOD, INDICATOR]).

Internal bindings:

  • Resolve formula graph nodes in data_range. layout: series may also retain on-graph leaves as holes; those stay baked unless double-bound.
  • Default to validation.intersect_graph_formulas: true so constants outside the formula graph are skipped; set false to include every expanded cell.
  • Require at least one formula cell in the range when intersection is enabled (no_formula_internal_targets otherwise).
  • Preserve validation.require_unique_key so each address is uniquely identified by its declared key concepts.
  • Emit no codegen; use derive_internal_series() after validate_series_bindings().

Pipelines can add internals.bindings.yaml alongside inputs.bindings.yaml and outputs.bindings.yaml; load_series_bindings() merges all *.bindings.yaml shards in a directory.

schema_version: "1.7.0"
series:
  - id: engine_primary_balance
    sheet: Engine
    data_range: Engine!B2:D2
    layout: series
    internal: {}
    structure:
      measure:
        concept: OBS_VALUE
        dtype: float
        bind: { kind: data_cell, read: float }
      dimensions:
        - concept: TIME_PERIOD
          role: key
          scope: cell
          bind: { kind: column_header, header_row: 1, read: int }
    key: [TIME_PERIOD]

A layout: series internal range may also contain graph leaves. See double-binding retained graph leaves to expose one as an input or constant instead of a baked literal.

Constant direction (schema 1.11.0+)

Use constant: {} for graph leaves that participate in formulas as fixed parameters, scenario knobs, or lookup seeds, but should not appear as user-editable Records API inputs (compute_* arguments) or published outputs (compute_*). Without a constant binding, those leaves fall back to baked xl_cell literals in generated formula bodies even when the domain model already names them.

Constant bindings:

  • Resolve graph leaves in data_range (the inverse of internal, which requires formula nodes).
  • Default to validation.intersect_graph_leaves: true; non-leaf / formula cells in the range fail validation (non_leaf_constant_overlap), and a range with no leaf overlap fails with no_leaf_constant_targets.
  • Set validation.catalog: false for extract-time domain pins (OFFSET/INDEX/INDIRECT CellTypeEnv coverage) that must not become inverted-tree tensors. Those series still compile at extract and are omitted from the catalog / data.py. A catalog-skipped series that uniquely owns an on-graph formula cell fails closed (catalog_skipped_formula_owner).
  • A single series entry cannot combine constant with input, output, or internal. A separate constant (or input) series may name a graph leaf that already sits inside an internal/output rectangle; see Double-binding retained graph leaves.
  • Values still live in the export CONSTANTS / bound-leaf defaults (same as unclassified constant leaves); there is no public write surface unless you also declare an input binding instead.
schema_version: "1.11.0"
series:
  - id: shock_year_anchor
    sheet: Engine
    data_range: Engine!C5
    layout: scalar
    constant: {}
    structure:
      measure:
        concept: OBS_VALUE
        dtype: float
        bind: { kind: data_cell, read: float }
      dimensions: []
    key: []

After export, formula cells that referenced Engine!C5 rewrite to read_shock_year_anchor(ctx) instead of xl_cell(ctx, 'Engine!C5').

Do not confuse the constant direction with bind kind constant (a fixed dimension / attribute value in structure). The direction binds a spreadsheet leaf; the bind kind fills a coordinate without reading a cell.

Example fixture for internals: internal_engine_row.yaml.

Pipeline note: derive_*_series omits series with zero resolved leaves. Call validate_series_bindings() first so hard errors such as no_formula_internal_targets or no_leaf_constant_targets surface before derive.

Double-binding retained graph leaves (mixed series)

An internal or output layout: series rectangle may include literal cells next to formulas — a seed in a recursive block, a populated corner of a vintage triangle. Those leaves stay in the formula series as retained graph-leaf holes. Leave them unbound when the workbook value should stay baked. To make a retained leaf tunable, also bind that same cell as a separate input or constant series.

Occupancy is the feature: there is no extra schema flag and no mixed direction.

schema_version: "1.11.0"
series:
  - id: engine_row
    sheet: Engine
    data_range: Engine!B2:D2
    layout: series
    internal: {}
    structure:
      measure:
        concept: OBS_VALUE
        dtype: float
        bind: { kind: data_cell, read: float }
      dimensions:
        - concept: TIME_PERIOD
          role: key
          scope: cell
          bind: { kind: column_header, header_row: 1, read: int }
    key: [TIME_PERIOD]
  - id: seed
    sheet: Engine
    data_range: Engine!C2
    layout: scalar
    constant: {}
    structure:
      measure:
        concept: OBS_VALUE
        dtype: float
        bind: { kind: data_cell, read: float }
      dimensions: []
    key: []

What this pairing does:

  • Catalog ownership (range walks, covering series) stays with the formula series (engine_row). The claimant does not splice the rectangle.
  • The claimant (seed) supplies the value. Export emits it as a helper parameter (engine_row(..., seed=)) instead of a Python literal. A constant claimant also appears in __constants__ (so data.overrides(SEED=...) works); an input claimant is a normal compute_* argument.
  • validate_series_bindings() accepts the overlap and drops the leaf_in_formula_series notice when every retained leaf in the formula series is double-bound.

Choose constant when the leaf is a named knob with a workbook default. Choose input when callers should pass it on every compute.

Allowed pairing: exactly one internal/output owner where the cell is a graph leaf, plus exactly one input/constant claimant.

Still errors (cell … is bound to both / double_bound_cell):

  • The cell is a formula (use input.mode: override if you need to type over a formula).
  • A third series names the same cell.
  • Two formula series (internal/output) share the cell.

Two input series (or two output series) sharing a cell is a different occupancy pattern and stays legal when it already was — for example sliced week stats versus a full-season input.

Do not confuse this with input.mode: override. Override displaces a formula cell. Double-binding exposes a literal leaf that already sits inside a formula-series rectangle.

Out of scope: general multi-owner cells, range splicing, and a mixed direction block.

data_range addressing

Expansion uses the same path as graph targets (expand_targets_to_roots), including:

  • Local range: Inputs!F5:J5
  • Both-end sheet-qualified (project standard): Inputs!F5:Inputs!J5, 'My Sheet'!A1:'My Sheet'!B2
  • Defined names: PrimaryRow (requires workbook= or a graph built from that workbook so named-range maps are available)
  • List of ranges (1.14.0): data_range: [Baseline!C12:X12, B1!C12:X12] concatenates complementary rectangles; series_data_ranges() normalizes a string or list
from excel_grapher.series_bindings import expand_data_range, expand_data_range_for_graph

expand_data_range("Inputs!F5:Inputs!J5")
expand_data_range("PrimaryRow", workbook=path_to_xlsx)
expand_data_range_for_graph(graph, "PrimaryRow", workbook=path_to_xlsx)

LIC manifest table → sidecar workflow

Analysts often maintain a manifest table (Excel or markdown) listing inputs: country, indicator, units, sheet/range, and notes. Treat that table as human QA; the sidecar YAML is what tooling validates and codegen consumes.

Suggested workflow:

  1. Inventory inputs in the manifest (one row per logical series / indicator row).
  2. Draft series_bindings.bindings.yaml — one series[] item per manifest row that should become a compute_* argument.
  3. Map columns from the manifest into binding fields:
Manifest column (typical) Binding field
Sheet name sheet (required today; may become inferred from data_range)
Cell range (e.g. F5:J5) data_range
Country / REF_AREA series_context.REF_AREA or bind.kind: cell
Indicator label bind.kind: row_label + series_context.INDICATOR
Year / period axis bind.kind: column_header + key: [TIME_PERIOD]; use read: int for projection offsets (1–5) or read: datetime for calendar headers
Active / flag column bind.kind: row_label or column_header + read: bool; or bind.kind: constant with YAML true / false
Unit structure.attributes[] with value:
Series id id (becomes the compute_* / Model argument name)
  1. Validate against the dependency graph (see Python API).
  2. Export. CodeGenerator.generate_modules(series_bindings=..., bindings_workbook=...) emits inverted-tree compute_* (explicit tensor/scalar inputs and results). There is no bindings-free generate() path (see Code export).

Offset projection years (1..5) vs calendar years (1999..2000) are distinguished only by what you bind in column_header — declare the intended semantics in sdmx_notes. Use read: int for offset-style headers and read: datetime (or read: auto when Excel stores native date cells) for calendar TIME_PERIOD keys.

Example: calendar_flags.yaml — bool flag column (IS_ACTIVE) plus datetime column headers (TIME_PERIOD). The workbook is built in integration tests via write_calendar_flags_workbook().

Export authoring checklist

  1. Extract a dependency graph whose targets include the cells you need (targets seed extraction; output bindings may also cover intermediate formula cells present in the graph).
  2. Declare data_range, layout, structure.measure, structure.dimensions, and key (input matching uses key only).
  3. Add dimension binds (column_header, row_label, row_index, column_letter, cell, constant, …). Use bind.kind: constant for fixed dimensions such as FREQUENCY: A. Use row_index + column_letter for grab-bag pins with no header or label.
  4. Add output.compute.name (e.g. compute_borvelia_primary_balance). Package compute_* functions take a frozen {Output}Inputs bundle and return tensors or scalars; use as_records for a Records view.
  5. Mark editable series with input: {} (plus optional domain / value_map / mode). Generated packages validate input tensors against their declared schemas.
  6. Pass series_bindings and bindings_workbook to generate_modules(). Build {Output}Inputs.from_defaults(**overrides) (or pass every field) and use as_records afterward when records are needed.

Records contract

Package compute_* functions take a frozen {Output}Inputs bundle and return tensors or scalars. Use as_records(compute, result) for a tidy list[dict] view. Build or overlay input tensors with with_records on the data.py binding, then pass them through from_defaults. See examples/micro_workbooks/setter_dataframe_example.py (single-key updates) and examples/micro_workbooks/matrix_dataframe_example.py (matrix).

result = compute_borvelia_primary_balance_out(
    BorveliaPrimaryBalanceOutInputs.from_defaults(
        borvelia_primary_balance=data.BORVELIA_PRIMARY_BALANCE.with_records(
            (((1,), -2.0), ((2,), -1.0), ((3,), 0.0), ((4,), 7.5), ((5,), 8.0)),
        ),
    )
)
records = as_records(compute_borvelia_primary_balance_out, result)

Record dicts

Each tidy record includes:

  • Measure field — named by structure.measure.concept (OBS_VALUE by default).
  • Key fields — every concept listed in key (e.g. TIME_PERIOD: 3 for offset-style int keys).

Do not repeat series_context, attributes, or documentation dimensions in caller input unless they are listed in key. For example, REF_AREA and INDICATOR are binding metadata for Borvelia-style series — only TIME_PERIOD and OBS_VALUE are required in records or DataFrame columns used to build a tensor.

Wide grids → tidy records

Convert wide Excel-shaped grids to long/tidy tables before with_records:

# Single-key series: periods across columns, one indicator row
tidy = df_wide.T.reset_index().rename(columns={"index": "TIME_PERIOD", 0: "OBS_VALUE"})

# pandas melt (multi-column wide grid)
tidy = df_wide.reset_index().melt(
    id_vars=["INDICATOR"], var_name="TIME_PERIOD", value_name="OBS_VALUE"
)

# polars
tidy = df_wide.unpivot(on="TIME_PERIOD", index="INDICATOR", value_name="OBS_VALUE")

Only include columns that appear in key plus the measure concept.

Key types must match resolved Python types. Resolution coerces workbook and manifest values according to each bind’s read mode (and concept_scheme dtypes for constants and series_context entries). Tensor coordinates use the same types — callers must not pass strings when resolution produced datetime or bool objects:

Binding Resolved key type Correct record value Incorrect (will not match)
read: int on TIME_PERIOD int 3 "3"
read: datetime on TIME_PERIOD datetime.datetime datetime(2024, 1, 1) "2024-01-01"
read: auto on TIME_PERIOD (Excel date serial) int or float serial as stored (e.g. 45309.0) datetime(2024, 1, 1) — use read: datetime
read: bool on IS_ACTIVE bool True 1 or "true"

Inspect resolve_series_binding() output to confirm the types for a given manifest. Output compute_* functions return the same types in each record’s key fields.

series_context values are attached to emitted records for documentation; they are not used for matching unless also listed in key. When a series_context concept has a dtype in concept_scheme, resolution coerces ISO date strings and bool-like strings the same way as bind constants.

Bind kinds

bind.kind Scope Status Purpose
data_cell leaf supported Read numeric input from the leaf itself
cell series supported Fixed address (e.g. country in A2)
column_header cell supported Header row for the data column
row_label series/cell supported Label text on the data row
value_map cell supported Key rows or columns by manifest values (1.5.0)
row_index cell supported Data cell’s own 1-based row index; Sheet!D18 yields 18 (1.20.0)
column_letter cell supported Data cell’s own column letter; Sheet!D18 yields "D" (1.20.0)
constant series supported Fixed scalar (e.g. scalar layout key)
sheet_name cell supported Worksheet name of each data cell; optional values map to a code (1.14.0)

Normalization: strip, strip_trailing_unit (removes trailing (…) unit clauses from indicator text).

Layouts

layout is optional. Resolution and codegen use bind kinds, not the layout name. When set, layout expresses analyst intent and triggers layout-specific schema and validation rules:

  • scalar — relaxes empty-key rules for single-cell bindings
  • series — requires at least one cell-scoped dimension
  • matrix — requires at least two dimensions, including one cell-scoped dimension

layout: series names a one-dimensional data_range with at least one cell-scoped dimension in key. Whether data runs across rows or columns is determined by bind kinds (column_header, row_label, …), not by the layout name. Borvelia’s wide-row example is one orientation; a single-column range with row_label for the varying dimension is equally valid.

layout Status Description
series supported 1D data_range + bind geometry (row- or column-oriented)
scalar supported Single editable cell
matrix supported Rectangular blocks; vertical keys from row binds, horizontal keys from column binds

Supported matrix shape. The simplest matrix is a dense logical table: no blank rows or columns inside the data range, with each cell-scoped key read from a label directly to the left of the cell (row_label) or directly above it (column_header), plus any number of whole-matrix scalar keys (cell / constant). Banded blocks — where a group label appears once per band and sub-rows carry a second dimension — are supported via explicit grouped-row geometry (schema 1.5.0); see Grouped-row matrix geometry below.

Example (layout: matrix with explicit row and column binds):

schema_version: "1.4.0"
workbook: matrix_inputs.xlsx
series:
  - id: macro_matrix
    sheet: Inputs
    data_range: Inputs!B3:D5
    layout: matrix
    input: {}
    structure:
      measure:
        concept: OBS_VALUE
        dtype: float
        bind:
          kind: data_cell
          read: float
      dimensions:
        - concept: INDICATOR
          role: key
          scope: cell
          bind:
            kind: row_label
            label_column: A
            read: string
        - concept: TIME_PERIOD
          role: key
          scope: cell
          bind:
            kind: column_header
            header_row: 2
            read: int
    key:
      - INDICATOR
      - TIME_PERIOD

Package compute_* takes a named matrix tensor. Build it with with_records or overlay data.py defaults — see examples/micro_workbooks/matrix_dataframe_example.py.

Grouped-row matrix geometry (1.5.0)

The dense matrix above assumes every cell-scoped key is read from a label directly adjacent to the data cell: row_label immediately left, column_header immediately above. Schema 1.5.0 adds explicit geometry for banded blocks where that contract does not hold — a group label appears once per band and sub-rows carry a second row dimension:

        A                     C       D
1                             2024    2025
2       Paris
3       Revenue               1.1     1.2
4       Primary expenditure   2.1     2.2
5
6       Moderate
7       Revenue               3.1     3.2
8       Primary expenditure   4.1     4.2

All geometry is declared explicitly in the manifest — there is no indentation or formatting inference.

Label sources: skip, include, fill, missing

row_label and column_header binds accept four optional fields:

  • skip / include — restrict which rows (or header columns) are label sources for this dimension. skip lists rows that are not sources; include lists the only sources. They are mutually exclusive. Row specs are 1-based integers or inclusive "first:last" strings; column specs are letters ("C", "C:D"). Quote range strings — YAML parses a bare [3:4] as a mapping, not a string.
  • fill — when true, a data row (or column) whose own label source is skipped or empty inherits the nearest non-skipped, non-empty label above it (row_label) or to its left (column_header). Because merged cells store their value only in the anchor cell, fill: true also covers merged group headers with no further configuration.
  • missing — what to do when no source label exists for a data cell: error (default) fails resolution with bind_resolution_failed; null keys the cell on None. YAML null is accepted as a spelling of "null". None keys participate in the composite key and leaf index like any other value — callers pass None in that field to match.

Two key dimensions may bind the same label column: in the banded sheet above, SCENARIO reads only the band header rows and fills down, while SHOCK_TYPE reads everything else:

schema_version: "1.5.0"
workbook: grouped_inputs.xlsx
series:
  - id: discrete_risks
    sheet: Inputs
    data_range: Inputs!C2:D8
    layout: matrix
    exclude_rows: [2, "5:6"]
    input: {}
    structure:
      measure:
        concept: OBS_VALUE
        dtype: float
        bind: {kind: data_cell, read: float}
      dimensions:
        - concept: SCENARIO
          role: key
          scope: cell
          bind:
            kind: row_label
            label_column: A
            include: [2, 6]     # band header rows are the only label sources
            fill: true          # sub-rows inherit the band label above
            read: string
        - concept: SHOCK_TYPE
          role: key
          scope: cell
          bind:
            kind: row_label
            label_column: A
            skip: [2, 6]        # band header rows are not sub-labels
            read: string
        - concept: TIME_PERIOD
          role: key
          scope: cell
          bind: {kind: column_header, header_row: 1, read: int}
    key: [SCENARIO, SHOCK_TYPE, TIME_PERIOD]

This emits one set_discrete_risks accepting the full composite key — no per-band shards with group names smuggled through series_context:

set_discrete_risks(
    ctx,
    [
        {"SCENARIO": "Paris", "SHOCK_TYPE": "Revenue", "TIME_PERIOD": 2024, "OBS_VALUE": 9.9},
    ],
)

For the simpler sparse/merged variant — group labels in their own column, blank (or merge-covered) on sub-rows — fill: true alone suffices; no skip/include lists are needed because emptiness already identifies the non-source rows.

Data membership: exclude_rows / exclude_columns

Which cells count as data is a series-level concern, separate from label geometry. By default resolution keeps cells that are graph input leaves, so unreferenced decorative rows or columns drop out automatically. But a formula spanning the block (a SUM or a lookup table array) makes embedded blank rows or milestone columns graph leaves too. Series-level membership filters force-drop addresses that are never data for this series:

  • exclude_rows — rows that are never data. In the example, rows 2 and 6 (band headers) and row 5 (separator) are excluded even though the block-wide SUM references them. Excluded rows can still serve as label sources — SCENARIO reads its band labels from excluded rows 2 and 6. Label reads go through the workbook, not the graph. Without exclude_rows, an unlabeled row fails resolution loudly under missing: error (the SHOCK_TYPE bind cannot label it) instead of mis-keying a record — configure nothing and you get an error, not corruption.
  • exclude_columns (schema 1.12.0+) — columns that are never data for this series (single letters or inclusive "C:D" ranges). Typical use: an annual matrix that keeps milestone years on-sheet for formula refs / a separate summary series, while this binding publishes every year except those columns. Applied after data_range expansion alongside exclude_rows, before graph intersection and label binding.

column_header.skip / include (and the row-label equivalents) remain label-source filters only — they do not remove data cells from the series. Use exclude_columns / exclude_rows when the cells themselves must not become resolved leaves.

Hardcoded keys: value_map

When labels are absent from the sheet entirely (or unreliable), key rows or columns by manifest values. The axis is inferred from spec syntax — row specs (3, "3:4") key data rows, column specs ("C", "C:D") key data columns; mixing axes or assigning one row to two values is a validation error (invalid_bind_geometry):

- concept: SCENARIO
  role: key
  scope: cell
  bind:
    kind: value_map
    values:
      Paris: "3:4"
      Moderate: [7, 8]     # lists allow disjoint rows, e.g. repeated sub-labels

value_map shares the missing policy: a data row covered by no entry is an error by default, or None-keyed with missing: null. Map keys are coerced through read (and concept_scheme dtypes) like constant values; keys within one bind must share one scalar type. This bind kind keys geometry; it is not input.value_map (1.15.0), which rewrites scalar public inputs to workbook MATCH/IF needles.

Own-address keys: row_index / column_letter

A grab-bag data_range that must be a keyed tensor (inverted-tree Domain uniqueness) sometimes has no year header or row label. Hand-written identity value_maps (2: 2, B: B, …) encode geometry as YAML. Schema 1.20.0 reads the data cell’s own address instead:

dimensions:
  - id: ROW
    concept: ROW
    role: key
    scope: cell
    bind: {kind: row_index, read: int}
  - id: COL
    concept: COL
    role: key
    scope: cell
    bind: {kind: column_letter, read: string}
key: [ROW, COL]

For data cell Sheet!D18, row_index yields 18 and column_letter yields "D". There is no values: map. A non-rectangular pin is unique only as (row, column) — one axis alone still collides when two cells share a row or a column.

Choosing a mechanism

Sheet geometry Mechanism
Dense block, labels directly adjacent plain row_label / column_header
Group labels merged or sparse in their own column fill: true
Group headers interleaved with sub-labels in one column skip/include + fill: true
Labels absent from the sheet value_map
Grab-bag pins keyed by the cell’s own row/column row_index + column_letter
Referenced non-data rows (headers, separators, subtotals) exclude_rows
Referenced non-data columns (milestones, summary years) exclude_columns

Boolean and datetime types (1.4.0)

Schema 1.4.0 adds bool and datetime to bind.read, measure.dtype, and concept_scheme concept dtypes. Use them for flag dimensions, calendar TIME_PERIOD axes, and typed manifest constants.

read: bool

Bind Excel TRUE/FALSE cells and bool-typed keys:

  • data_cell — scalar or series measure cells stored as boolean (or coerced with explicit read: bool from numeric 0/1).
  • column_header / row_label — flag columns or row labels used as key dimensions (e.g. an IS_ACTIVE column distinguishing scenario rows).
  • constant — fixed bool keys on layout: scalar or series-scoped dimensions.

YAML manifest constants accept native booleans or strings such as true, false, yes, no, 1, and 0. When the concept dtype is bool (via concept_scheme or inferred from a native YAML boolean), resolution coerces string constants and matching series_context values to Python bool. Numeric coercion with read: bool accepts only 0 or 1 (int or float); other numbers raise a resolution error.

concept_scheme:
  concepts:
    - id: IS_ACTIVE
      dtype: bool
structure:
  dimensions:
    - concept: IS_ACTIVE
      role: key
      scope: series
      bind:
        kind: constant
        value: true          # or "FALSE" — coerced to bool
    - concept: IS_ACTIVE
      role: key
      scope: cell
      bind:
        kind: row_label
        label_column: A
        read: bool           # Excel TRUE/FALSE in column A

With read: auto on a bool Excel cell, resolution preserves the native bool. Use read: bool when the cell may be numeric (0/1) but the key should be boolean.

read: datetime

Bind calendar TIME_PERIOD column headers and date constants:

  • column_header + read: datetime — calendar month/quarter/year headers formatted as Excel dates; serial numbers are converted to naive datetime values.
  • constant — ISO 8601 strings in YAML ("2024-01-01", "2024-03-15T00:00:00"); requires dtype: datetime on the concept (via concept_scheme or dimension metadata). The same coercion applies to series_context entries for datetime-typed concepts.
  • read: auto — when Excel already exposes a native datetime cell, resolution keeps it without serial conversion.
concept_scheme:
  concepts:
    - id: TIME_PERIOD
      dtype: datetime
structure:
  dimensions:
    - concept: TIME_PERIOD
      role: key
      scope: cell
      bind:
        kind: column_header
        header_row: 1
        read: datetime       # calendar headers; not projection offsets
    - concept: TIME_PERIOD
      role: key
      scope: series
      bind:
        kind: constant
        value: "2024-01-01"  # ISO date string in the manifest

read: auto vs explicit read: datetime: auto passes through native datetimes from the workbook reader and is appropriate when headers are stored as Excel date cells. Explicit datetime coerces Excel serial numbers and ISO strings and is required when you need deterministic date parsing regardless of how the reader classified the cell. Timezone-aware datetimes are rejected; only naive datetimes are supported.

read: auto footgun: when the workbook reader returns a calendar date as a number (Excel serial), read: auto keeps it as int or float — it does not convert serials to datetime. That often surfaces as coordinate mismatches: resolution indexed 45309.0 but callers pass datetime(2024, 1, 1). Prefer read: datetime on column_header binds for calendar TIME_PERIOD axes unless you have confirmed the reader yields native datetime cells for those headers.

Contrast with Borvelia’s offset-style headers (read: int, values 1–5): calendar and offset period axes differ only in the declared read mode and analyst notes — not in layout name.

Generated code imports datetime and emits datetime.datetime(...) literals only when resolutions include datetime scalars.

Schema versions

Version Contents
1.0.0–1.2.0 row_series, scalar; supported bind kinds above. Use for production workbooks.
1.1.0 Adds matrix layout (supported with explicit binds).
1.2.0 Optional input / output direction blocks and output compute_* functions.
1.3.0 row_series renamed to series (no resolver/codegen change). Legacy row_series accepted at load time.
1.4.0 bool and datetime read modes and dtypes; ISO date strings in manifest constants.
1.5.0 Grouped-row matrix geometry: skip/include/fill/missing on row_label and column_header binds, the value_map bind kind, and series-level exclude_rows.
1.6.0 input.mode: override for user-editable formula cells (non-leaf input setters).
1.7.0 internal direction for non-I/O formula-cell key triangulation (intersect_graph_formulas validation).
1.8.0 Optional dimension/attribute id separating dimension identity from concept, so multiple dimensions can share one concept; optional per-dimension dtype for same-concept dimensions with differing storage types.
1.9.0 Historical: optional input.reader name override for generated read_* duals (removed; extra input / constant keys are rejected).
1.10.0 Optional output.compute.helper so compute_* can call parameterized helpers from record dims (with xl_cell fallback). Modular exports place _OUTPUT_LEAVES_* in _output_leaves.py.
1.11.0 constant direction for non-I/O graph-leaf bindings. Historical codegen emitted read_* without compute_*; inverted-tree imports data.CONSTANT_*.
1.12.0 Series-level exclude_columns (ColumnSpec) symmetric with exclude_rows for carving non-data columns out of an expanded data_range.
1.13.0 Optional input.domain so inverted-tree compute_* / Model arguments reject out-of-domain measure values (enum, between, real_between).
1.14.0 Complementary shards: same series id with different sheet / data_range merge when direction, key, and dimension shape match (data_range may be a list). bind.kind: sheet_name (optional values map from worksheet name to code).
1.15.0 Optional input.value_map on scalar input series: map public compute_* values to workbook cell needles (MATCH/IF labels). Distinct from bind kind value_map.
1.16.0 input no longer requires a setter block. Empty input: {} marks an editable series. Package export takes inputs as compute_* / Model arguments.
1.17.0 Series-level axis_labels names a one-key series whose evaluated values are the runtime keys of that axis.
1.18.0 Series-level relations name a partner series (greater_than / not_equal). The compiler emits GreaterThanCell / NotEqualCell on each declaring cell, aligned on the shared key.
1.19.0 Series-level domain (enum, between, real_between, from_workbook). input.domain is accepted and normalized to that key. constant implies from_workbook. Compiles to the CellTypeEnv dynamic-ref inference consumes.
1.20.0 bind.kind: row_index and column_letter key each observation by the data cell’s own 1-based row index or column letter, without a values map.
1.21.0 validation.catalog: false marks an extract-only series: it still compiles into CellTypeEnv / DynamicRefConfig.from_bindings, but inverted-tree omits it from the catalog and data.py tensors. Fail closed if that series uniquely owns an on-graph formula cell.
1.22.0 domain may union enum with exactly one of between or real_between. A value matches when it is an enum member or lies in the interval (a text sentinel beside a numeric range). Measure dtype follows the interval arm.

Runtime axis labels (1.17.0)

A header row that is a formula, not a snapshot literal, can still be a tensor axis. Bind the header cells as their own series and set axis_labels to the sole key field:

schema_version: "1.17.0"
series:
  - id: engine_year_labels
    data_range: Engine!C5:G5
    layout: series
    internal: {}
    axis_labels: TIME_PERIOD
    structure:
      measure:
        concept: OBS_VALUE
        dtype: int
        bind: {kind: data_cell, read: int}
      dimensions:
        - id: TIME_PERIOD
          concept: TIME_PERIOD
          role: key
          scope: cell
          bind: {kind: column_header, header_row: 5, read: int}
    key: [TIME_PERIOD]

The labeller’s values become the keys of every tensor on that axis — inputs after validation, internals, and compute_* results. internals.x.sel(TIME_PERIOD=2026) selects 2026. Positions remain the codegen’s layout truth and are emitted as positions (axis_step, _p == 2 on a projection suffix), never as snapshot literals. Family conditions, lags, and literal-table subscripts index the labeller (or interned master), not the series’ sliced axis.

Authoring rules. The named axis must be the series’ only key. Measure type must match the axis key type. Duplicate labeller identities, two runtime labellers for the same axis name, a labeller cell outside the extracted graph, cached values that disagree with snapshot keys, or an input on the labelled axis in the labeller’s leaf closure fail at export. Non-injective header formulas fail at compute_* with AxisError.

Defaults. Workbook-default input tensors are published over the snapshot axis. A suffix input (fewer keys than the labeller) still imports: SchemaTemplate.validate checks that tensor with AxisTemplate.validate_axis (name, key type, and size). AxisTemplate.bind accepts only the full source-ordered labeller and rejects any other length with AxisError. Shifting the labeller’s input without re-keying those tensors raises SchemaError listing the accepted labels. The same unknown-labels message applies to any tensor whose keys overlap the required set on neither side.

Out of scope. Translated input enums / value_map needles; f-string key templates over a runtime string axis; host-key remaps over a runtime string axis; cross-field key equality between a runtime axis and a static axis.

Series relations (1.18.0)

A pair of input series that must stay ordered (maturity strictly above grace) or unequal (a tenor and its amortization mirror) declare that as a partner series, not an A1 address. cell_type_env_from_bindings expands each declaring cell to GreaterThanCell / NotEqualCell naming the partner cell at the same key. constant series pin their cached workbook values (from_workbook).

schema_version: "1.18.0"
series:
  - id: input4_grace_period
    sheet: Inputs
    data_range: Inputs!G2:G3
    layout: series
    input:
      domain: { between: { min: 0, max: 50 } }
    structure:
      measure:
        concept: OBS_VALUE
        dtype: int
        bind: {kind: data_cell, read: int}
      dimensions:
        - id: INSTRUMENT
          concept: INSTRUMENT
          role: key
          scope: cell
          bind: {kind: row_label, label_column: A, read: string, normalize: strip}
    key: [INSTRUMENT]

  - id: input4_loan_maturity
    sheet: Inputs
    data_range: Inputs!H2:H3
    layout: series
    input:
      domain: { between: { min: 0, max: 80 } }
    relations:
      - greater_than: input4_grace_period
    structure:
      measure:
        concept: OBS_VALUE
        dtype: int
        bind: {kind: data_cell, read: int}
      dimensions:
        - id: INSTRUMENT
          concept: INSTRUMENT
          role: key
          scope: cell
          bind: {kind: row_label, label_column: A, read: string, normalize: strip}
    key: [INSTRUMENT]

Kinds: greater_than → GreaterThanCell, not_equal → NotEqualCell. Validation requires the partner series to exist, comparable measure dtypes, matching key field names (order does not matter), no self-partner, and no greater_than cycles. Expansion fails closed when a key does not resolve or the partner has no unique cell at that key.

Complementary shards of the same series id must repeat the same relations list on every shard; omitting it on one shard is a structural merge conflict.

Cell domains (1.19.0)

domain is series-level. input.domain is still accepted and is copied to the series-level key at load time. One declaration feeds compute_* argument checks and the CellTypeEnv dynamic-ref inference consumes.

schema_version: "1.19.0"
series:
  - id: shock_year
    data_range: Inputs!B21
    input: {}
    domain: { between: { min: 1, max: 5 } }

  - id: country_profile_names
    data_range: Inputs!A10:A12
    constant: {}                       # domain: { from_workbook: true } implied

  - id: engine_year_labels
    data_range: Engine!C5:G5
    internal: {}
    domain: { from_workbook: true }    # pin formula cells to template values

Kinds: enum, between, real_between, plus from_workbook: true (each cell in the range gets a singleton from the cached value). One kind per domain, or enum together with exactly one of between or real_between (1.22.0). The constrained range is the series (data_range minus exclude_rows / exclude_columns).

Direction defaults: constant implies from_workbook. input uses domain, else the values of value_map (workbook needles; map keys remain the public compute_* domain). internal, output, and input.mode: override contribute nothing unless domain is explicit.

Build a DynamicRefConfig with DynamicRefConfig.from_bindings(bindings, workbook). cell_type_env_from_bindings returns the same lazy SeriesDomainIndex: a lookup compiles one address, while iteration and len expand the whole domain. bindings validate and bindings viz derive that config from the sidecar. The local corpus manifest (corpus.toml) does the same: omit a Python constraint table when the sidecar covers every dynamic-ref leaf. bindings undomained prints graph leaves that still have no domain. bindings candidates prints the pre-extract worklist (list_dynamic_ref_constraint_candidates with DynamicRefConfig.from_bindings) without building the graph and without cached dynamic refs. Lookup cells that exact MATCH keeps only because they have no domain are a warning, not entries on that list; --undomained-match prints them separately. The list grows only as selector domains get wide enough to reach the next OFFSET / INDEX / INDIRECT. After extract, non-dynamic leaves are an undomained / attach_domains pass. See Command-line interface.

Extract-only series (1.21.0)

Some authored series exist only so extract-time OFFSET / INDEX / INDIRECT inference can read a CellType for a cell. They are not a public tensor. Set validation.catalog: false:

schema_version: "1.21.0"
series:
  - id: engine_stock_pin
    data_range: Engine!B2:C2
    layout: series
    constant: {}
    validation:
      intersect_graph_leaves: false
      catalog: false
    structure:
      measure:
        concept: OBS_VALUE
        dtype: float
        bind: {kind: data_cell, read: float}
      dimensions:
        - id: ROW
          concept: ROW
          role: key
          scope: cell
          bind: {kind: value_map, values: {2: 2}, read: int}
        - id: COL
          concept: COL
          role: key
          scope: cell
          bind: {kind: value_map, values: {B: B, C: C}, read: string}
    key: [ROW, COL]

The series still compiles into CellTypeEnv / DynamicRefConfig.from_bindings. Inverted-tree omits it from the catalog and data.py. Unique semantic keys are not required (extract-only defaults require_unique_key to false). A catalog-skipped series that uniquely owns an on-graph formula cell fails closed (catalog_skipped_formula_owner). Identity ROW / COL binds remain a separate authoring feature for series that are tensors keyed by sheet geometry.

Input domains (1.13.0)

Declare an allowed measure domain on an input binding so inverted-tree compute_* arguments fail at the call site instead of accepting bad values and surfacing Excel errors later:

input:
  domain:
    enum: [Alpha, Beta, "High "]   # exact match; trailing spaces preserved
input:
  domain:
    real_between: {min: 0, max: 300}   # inclusive; measure dtype float or number
input:
  domain:
    between: {min: 0, max: 100}   # inclusive integers; measure dtype int

between is a closed integer interval and requires measure dtype int. real_between is a closed real interval and requires measure dtype float or number. Bind validation and inverted-tree export fail closed when the domain kind does not match the measure dtype (for example a 0–1 share authored as dtype: float with between instead of real_between).

Union domains (1.22.0)

A cell can hold a text sentinel when a number is unavailable and a number when it is present, with the formula guarding the type (=IF(ISNUMBER(A1), A1, 0)). Declare both arms on one domain. A value matches when it is an enum member or lies in the interval:

input:
  domain:
    enum: ["n.a."]
    real_between: {min: -1.0e15, max: 1.0e15}

The generated argument type is Literal["n.a."] | Annotated[float, RealBetween(...)] when the binding domain is on the graph’s cell-type env. Measure dtype follows the interval arm (int for between, float or number for real_between). between and real_between cannot be combined, and from_workbook stays a pin by itself. input.value_map cannot be combined with a union.

An integer code in enum is compared to the value the caller passed, before int is rewritten to float. compute_*(code=-999) stays an int when -999 is a member. A number that matches only the interval is still coerced (0 becomes 0.0 when the measure dtype is float). Membership is type-strict: 1 is not True, and -999 is not -999.0 until coercion runs for a value that was not already a member. Author the code as an integer (-999) or as a float (-999.0) to match what callers pass.

Python enum membership is case-sensitive. Excel’s = comparison is not, so A1="n.a." also accepts N.A. while compute_* accepts only the declared spelling.

The same union is a constraint annotation: Literal["n.a."] | Annotated[float, RealBetween(...)]. Two Literal arms merge into one enum (Literal["a"] | Literal["b"]). An open type next to a constrained arm (Literal["n.a."] | float) is rejected; put Between or RealBetween on the numeric arm. A finite integer union is enumerated for OFFSET, INDEX, and INDIRECT as the combined set. A text sentinel unioned with real_between is not enumerated.

Cached workbook text such as n.a. is kept for measure dtype float or number. Dtype int cannot read that cached text; the cell’s cached value has to be an integer, and callers can still pass the sentinel.

Domain checks run on each required compute_* / Model argument (scalar or every sequence member) before the evaluation walk. For a union, enum membership is tested on the original value, then the same safe dtype coercion setters use runs for everything else (int becomes float when the measure dtype is float; float is never narrowed to int). A value of the wrong type for a single-arm domain raises ValueError naming the type, not a bounds failure. A union mismatch names the whole domain.

Scalar input maps (1.15.0)

Workbook MATCH / IF comparisons often use label cells with trailing spaces ("High "). Passing that needle as a public compute_* argument is easy to get slightly wrong: a clean "High" does not error; the IF falls through. Declare input.value_map on a scalar input series so callers pass the clean keys and the orchestrator rewrites to the workbook needle after the domain check:

input:
  value_map:
    High: "High "
    Medium: Medium
    Low: "Low "

When domain is omitted, the implied enum domain is the map keys, so compute_x(XInputs(selector="High")) works and "High " / "Nope" raise ValueError naming the accepted keys. Internals still compare the literal needle; Excel parity is unchanged because the mapped value is what the workbook cell would have held.

input.value_map is not the bind kind value_map (hardcoded row/column keys). It is rejected on non-scalar and non-input series.

Dimension ids vs concepts (1.8.0)

Following SDMX, a concept (e.g. TIME_PERIOD) is the meaning category a dimension falls into, while a dimension is the parameter that keys or qualifies observations. Usually one dimension per concept suffices, so concept doubles as the dimension’s identity. When a series needs two dimensions in the same concept category — a projection year and a comparison year, a reference area and a counterpart area — declare an explicit id on the extra dimension:

dimensions:
  - concept: TIME_PERIOD          # effective id: TIME_PERIOD
    role: key
    scope: cell
    bind: {kind: column_header, header_row: 1, read: int}
  - id: REFERENCE_TIME_PERIOD     # effective id: REFERENCE_TIME_PERIOD
    concept: TIME_PERIOD          # same concept, different dimension
    role: key
    scope: series
    bind: {kind: cell, address: Inputs!B1}
key: [TIME_PERIOD, REFERENCE_TIME_PERIOD]

The effective dimension id (id when declared, else concept) names the record field and must be used in key entries; effective ids must be unique within a series’ structure (duplicate_dimension_id validation). The concept keeps its semantic jobs: dtype inheritance from concept_scheme (here REFERENCE_TIME_PERIOD inherits TIME_PERIOD’s int dtype). Attributes accept id the same way. Manifests without id are unchanged — the effective id defaults to the concept.

Per-dimension dtype

Same-concept dimensions usually share the concept’s storage type. When they genuinely differ — say an int projection axis and a calendar-date comparison period — first ask whether the two really share one concept: a calendar date and an integer offset under one TIME_PERIOD is often a semantic stretch, and splitting into separate concepts is the cleaner model. When they do belong together, declare a per-dimension dtype to override the concept-scheme dtype for that dimension only:

dimensions:
  - concept: TIME_PERIOD            # int, inherited from concept_scheme
    role: key
    scope: cell
    bind: {kind: column_header, header_row: 1, read: int}
  - id: REFERENCE_TIME_PERIOD
    concept: TIME_PERIOD
    dtype: datetime                 # this dimension stores a calendar date
    role: key
    scope: series
    bind: {kind: cell, address: Inputs!C1}

The declared dtype drives value coercion when the bind has no explicit read (an explicit read still wins) and flows into tensor coordinate types instead of the concept’s dtype. Relying on a divergent bind.read alone (without dtype) triggers the dtype_read_mismatch warning, which nudges you to either declare the per-dimension dtype or split the concepts.

Validation and codegen closure

validate_series_bindings() and derive_*_series intersect bindings with the extracted graph (input: leaves; output: any graph node; internal: formula nodes). A retained graph leaf inside an internal/output layout: series range may also be named by one input or constant series; see double-binding retained graph leaves. Codegen intersects with the export closure from the current CodeGenerator targets (formula cells, inputs, and dependencies actually emitted). Cells outside that closure are skipped; validation.warn_on_partial_overlap (default true) emits a warning when that happens.

Python API

from pathlib import Path

from excel_grapher.grapher import create_dependency_graph
from excel_grapher.series_bindings import (
    bindings_canonical_sha256,
    derive_input_series,
    derive_internal_series,
    expand_data_range,
    load_series_bindings,
    series_data_ranges,
    validate_series_bindings,
)
from excel_grapher.exporter import CodeGenerator

workbook = Path("lic_inputs.xlsx")
bindings = load_series_bindings(workbook.with_suffix(".bindings.yaml"))

targets = [
    addr
    for s in bindings["series"]
    for data_range in series_data_ranges(s)
    for addr in expand_data_range(data_range, workbook=workbook)
]
graph = create_dependency_graph(workbook, targets, load_values=True)

report = validate_series_bindings(graph, bindings, workbook=workbook)
assert report["ok"]

bindings_canonical_sha256(bindings)
input_series = derive_input_series(graph, bindings, workbook=workbook)
internal_series = derive_internal_series(graph, bindings, workbook=workbook)

with CodeGenerator(graph) as gen:
    modules = gen.generate_modules(
        series_bindings=bindings,
        bindings_workbook=workbook,
    )

Graph identity stays CellKey. To reach dimension binds and key coordinates from a node, use SeriesCatalog (do not copy them onto Node.metadata):

from excel_grapher.exporter.inverted_tree.catalog import build_catalog

catalog = build_catalog(bindings, workbook=workbook, graph=graph)
node = graph.get_node("Inputs!B10")
key_point = catalog.key_point_for(node.key)  # KeyPoint | None
binds = catalog.binds_for(node.key)  # series-level bind mappings | None

# Thin adapters on Node / NodeView:
key_point = node.key_point(catalog)
binds = node.dimension_binds(catalog)

Unbound cells return None. Bind mappings are series-level; key points are per-cell.

After export:

from generated import BorveliaPrimaryBalanceInputs, as_records, compute_borvelia_primary_balance

result = compute_borvelia_primary_balance(
    BorveliaPrimaryBalanceInputs(borvelia_primary_balance=(-0.5, -0.5, -0.5, -0.5, -0.5)),
)
records = as_records(compute_borvelia_primary_balance, result)

Package discovery is api.__all__ (Inputs classes and compute names). list_groups() is not emitted.

generate_modules omits setters, readers, make_context, and list_groups.

Command-line validation

Full CLI reference: Command-line interface. Authoring loop (skill, audit, burndown, upsert): Authoring series bindings.

Quick examples:

excel-grapher bindings validate lic_inputs.xlsx
excel-grapher bindings validate lic_inputs.xlsx --json
excel-grapher bindings validate lic_inputs.xlsx --smoke-test
excel-grapher bindings validate lic_inputs.xlsx --smoke-test --emit-dir ./generated
excel-grapher bindings audit lic_inputs.xlsx
excel-grapher bindings burndown lic_inputs.xlsx

By default the command resolves lic_inputs.bindings.yaml or a lic_inputs.bindings/ shard directory colocated with the workbook. Use --bindings to override. Validation-only is the default; --smoke-test generates inverted-tree package code and exercises every declared compute_* function with data.py defaults; --emit-dir writes generated module files to disk.

Design note

Series bindings are framed around input series derived from binding manifests, not independently discovered input groups. One binding id corresponds to one compute_* / Model argument (when input is declared), one optional output compute_* function (when output.compute is declared), and matching input-series views over the participating graph cells in data_range.

Design history: GitHub issue #192.