Skip to content

contract.yaml spec

A normative reference. For tutorial coverage, see contract.yaml.

Top-level

apiVersion: v3.0.0
kind: DataContract
id: <slug>
name: <display-name>
version: <semver>
description: <string | mapping>
schema:
- name: <string>
physicalType: jsonl
properties: [...]
FieldTypeRequiredNotes
apiVersionstringMust be v3.0.0. Tracks ODCS v3.0.0.
kindstringMust be DataContract.
idstringStable slug; scopes the cache and runtime directories.
namestringHuman-readable display name.
versionstringSemver (MAJOR.MINOR.PATCH).
descriptionstring | mappingFree-form, or a {locale: text} mapping.
schemaarrayMust contain exactly one entry.

schema[]

schema:
- name: items
physicalType: jsonl
properties:
- name: id
...
FieldTypeRequiredNotes
namestringLogical name of the table. Convention: items.
physicalTypestringMust be jsonl.
propertiesarrayOne entry per column.

properties[]

- name: country_code
logicalType: string
description: ISO 3166-1 alpha-2.
required: false
primaryKey: false
x-derived: true
x-inputs: [country]
x-editable-by: ["agent:human"]
FieldTypeRequiredNotes
namestringColumn name. ASCII letters, digits, _, -.
logicalTypeenumOne of: string, integer, number, boolean, date, timestamp, array, object.
descriptionstring | mappingMultilingual via {locale: text} mapping.
requiredbooleanDefault false.
primaryKeybooleanDefault false. Exactly one property must be true.
x-derivedbooleanDefault false. When true, requires x-inputs.
x-inputsarray of stringsconditionalRequired when x-derived: true. Must reference declared properties.
x-editable-byarray of stringsDefault [] ⇒ field not human-editable. fnmatch patterns.

logicalType mapping

FolioJSON shapeFrictionless export
stringstringstring
integerintegerinteger
numbernumbernumber
booleanbooleanboolean
datestring YYYY-MM-DDdate
timestampstring ISO-8601 with offsetdatetime
arrayarrayarray
objectobjectobject

Folio does not validate inner shape for array and object — that’s an application concern.

What’s rejected

folio validate (and Sheet(...) construction) reject contracts with:

  • More than one or zero primaryKey: true properties.
  • A logicalType value not in the enum above.
  • x-derived: true without x-inputs.
  • x-inputs referencing a non-existent property.
  • properties[].name containing characters outside [A-Za-z0-9_-].
  • Top-level fields other than the eight in the table above (typo of Names instead of name is loud).
  • Properties with unknown attribute names (typo of primaryKeys is loud).
  • A second schema[] entry (1 sheet = 1 model — §6.2).

What’s tolerated

  • Extra fields on records that aren’t in the contract — preserved verbatim across writes.
  • Properties on the contract that don’t appear on records — surface as null.
  • Whitespace and YAML comments — Folio re-emits canonical YAML if you use Sheet.update_contract (not yet shipped).

ODCS alignment

Folio’s contract is a subset of ODCS v3.0.0. Specifically:

ODCS featureFolio
apiVersion, kind, id, name, version
schema[].properties[].logicalType✓ (subset)
schema[].properties[].primaryKey, required
Quality checks (quality:)not yet
Servers / connectionsn/a (sheet is the resource)
Stakeholders, terms, supportnot yet
description localization

A future Folio release may extend the supported subset; the goal is to stay readable by datacontract-cli.

ADRs

The contract design is anchored by: