Descriptor validation
contract validate checks declarations, without opening datasets, connecting to servers, executing quality rules, or evaluating SLA compliance.
packata contract validate contract.yaml # schema + semantic
packata contract validate contract.yaml --schema # schema only
packata contract validate contract.yaml --semantic # semantic only
packata contract validate contract.yaml --semantic --schema # both, in schema-first order
Flags are additive. With any layer flag, only the requested layers run. With no flags, the explicit default is schema plus semantic; future categories do not automatically enter that default. A schema failure skips semantic validation with a reason. Semantic-only validation never enables schema validation implicitly.
JSON reports contain layers (the selected layers, each with state, executed and optional reason) and diagnostics (layer, code, severity, sourcePath, message). States are Passed, Failed, and Skipped. Success requires every selected layer to complete and pass. Parse/version prerequisites produce skipped layers and errors; an incomplete native declaration check also produces an error. New source paths use $ followed by a JSON Pointer; reused native diagnostics retain their existing paths. Schema messages name the selected profile and explain the expected shape or failed assertion without echoing source values. Rejected anyOf/oneOf alternatives and false if conditions are not independent errors. When shape or discriminator evidence identifies one relevant alternative, its actionable findings replace ancestor summaries; otherwise a union-shape error is reported. Multiple matching oneOf alternatives produce an ambiguity error. Independent failed assertions remain visible. Exit codes remain 0 success, 1 invalid or unsupported descriptor, 2 invocation error, 3 I/O failure, 130 cancellation.
Schemas and versions
Validation uses the original JSON or a typed YAML 1.2 core projection before native defaults, coercion, or ignored properties. Quoted scalars remain strings, explicit null remains null, duplicate keys fail, and cyclic aliases, multiple documents, depth over 64, and expansions over 100,000 nodes fail parsing. Non-finite YAML numbers and unsupported explicit tags are rejected. JSON input uses JSON syntax.
| Standard | Selection and pinned artifact |
|---|---|
| ODCS | Requires an explicit apiVersion: v3.2.0. Contract version is independent. Validation derives its schema from the pinned 2026-11-17 companion schema snapshot from upstream dev, Draft 2019-09, with format assertions and Packata’s key/value tag preview enabled. |
| Data Package | Defaults to the pinned v2 profile when $schema is absent, using Draft 7 and format assertions. Packata embeds the official profile verbatim and applies a validation correction for the string-valued fieldsMatch property. Table Schema specification |
| Packata Category Tables 1.0.0 | Explicit $schema: https://raw.githubusercontent.com/Seddryck/Packata/profile-category-tables-v1.0.0/docs/profiles/category-tables/1.0.0/datapackage.json selects the self-contained Draft 7 compatibility profile. It adds reference objects and category field maps while retaining inline categories and other v2 assertions. See the complete recipe example. |
The embedded artifacts are offline resources. Descriptor $schema, references, and endpoint declarations cannot trigger schema downloads. Automatic detection uses ODCS kind/apiVersion or Data Package content; mixed ODCS markers and resources are ambiguous. --input-format odcs|datapackage overrides detection, but does not supply required source fields or a missing ODCS specification version.
An unknown or malformed $schema fails selection. Reports include profile (uri, label, format) for the selected artifact, also shown in CLI text and the VS Code validation output. The recipe profile checks descriptor structure; semantic checks additionally verify local resource/field bindings, type agreement, required and unique codes, unique string labels and label encoding prerequisites. Neither layer reads lookup rows or resolves external packages.
Bundled ODCS schema revisions
| Revision | Upstream change |
|---|---|
v3.2.0-20260828 | Final pre-release snapshot |
v3.2.0-20260908 | Initial v3.2.0 release |
v3.2.0-20261029 | Allows multiple comparison operators in a SQL or library quality rule |
v3.2.0-20261117 | Allows custom relationship types and retains the foreignKey default |
Run packata contract list to see the bundled revisions and the default. ODCS validation defaults to v3.2.0-20261117 for contracts declaring apiVersion: v3.2.0.
packata contract list
packata contract validate contract.odcs.yaml --schema-revision v3.2.0-20260908
--schema-revision accepts an exact bundled revision for ODCS schema-only or combined validation. Include --schema to run only schema checks. Validation reports show the selected revision, and historical revisions pin only the schema assertions. Semantic checks still use the current Packata version.
An explicit revision requires schema validation and an ODCS descriptor with the matching apiVersion. Unknown revisions fail without fallback or downloads. Application callers can enumerate DescriptorProfiles.OdcsSchemaSnapshots and pass schemaRevision to DescriptorValidation.Validate. VS Code can set packata.validation.schemaRevision for explicitly selected schema checks. Reports include the selected revision, pinned source, checksum and active extensions.
Explicit revision selection uses the official artifact and any explicitly enabled RFC profiles. Automatic selection also applies Packata’s existing key/value tag preview. To reproduce semantic checks and experimental profile behavior, pin the Packata version and profile settings used for the run.
ODCS key/value tag preview
Packata accepts mixed string and key/value tags in YAML and JSON based on ODCS issue #357. Each mapping has exactly one non-empty key and a string, number, or boolean value. The native reader applies Packata’s scalar range and precision limits to numbers. Plain string tags and mappings can appear in the same list.
tags:
- finance
- pii: true
- retention_days: 365
- classification: confidential
The preview applies to the contract, schema objects and properties, enum entries, quality rules, the team, and team members. Context constraint and verified statement tags still require strings. The ODCS .NET model exposes the ordered entries through TagEntries, and its existing Tags properties expose plain labels. Canonical mapping preserves the mixed entries in ODCS extension metadata. The bundled official schema remains pinned verbatim.
Experimental ODCS profiles
RFC-0048 spatial types and RFC-0069 property units are independently opt-in and can be enabled together. The same mapping options apply to schema validation, semantic validation and canonical mapping.
var mapping = ContractMappingOptions.Default.WithSpatialTypes().WithUcumUnits();
The declarative equivalents are Odcs.EnableSpatialRfc0048 and Odcs.EnableUcumUnits. CLI and editor hosts that use Packata’s user configuration read mapping.odcs.enableSpatialRfc0048 and mapping.odcs.enableUcumUnits as booleans. For example, run packata config set mapping.odcs.enableUcumUnits true.
With RFC-0069 enabled, schema properties (including nested properties) can declare an optional string unit, such as kW.h, EUR, or persons per household. UCUM and ISO 4217 codes are recommendations. Packata preserves exact spelling and case, so MW and mW are distinct. A unit does not affect the logical, physical or CLR type, and Packata does not convert values. Compatibility checks treat adding, removing or changing the unit of an existing field as breaking.
Reports include the base profile and the ordered extension identities. The existing profile identity is preserved for a single extension. officialSchemaValid reports the unmodified ODCS JSON Schema result, while the schema layer reports the configured profile’s result.
SLA duration units with RFC-0069
The experimental units profile also checks durations for freshness, latency, frequency and retention. Use the case-sensitive codes s, min, h, d, wk, mo and a. Months and years use calendar arithmetic in the evaluation time zone. The schema still permits omitted units, while mapping and semantic validation require a unit to normalize a duration.
During migration, use WithUcumUnits(sla => sla.AllowLegacyUnits()), set Odcs.AllowLegacySlaUnits = true, or configure mapping.odcs.allowLegacySlaUnits. With the profile enabled, these settings accept unambiguous legacy aliases such as hours, week and yr. The ambiguous m still requires an explicit min or mo. The report includes the effective legacy setting as allowLegacySlaUnits. Native declarations retain their original tokens. When projecting canonical durations with ToOdcsDurationProperty, synthesized or explicitly normalized declarations use standard codes.
Other SLA metrics keep their existing rules. For example, availability takes a percentage, and custom metrics can retain UCUM, ISO 4217 or free-text units as metadata even when Packata has no evaluator for the metric.
Experimental RFC-0032 definition resolution
Use packata contract resolve source.odcs.yaml --output resolved.odcs.yaml to materialize schema-property semanticDefinition links. The command reads local relative YAML and JSON files. A fragment such as definitions.odcs.yaml@1.2.0#/schema/sales/properties/total selects a property by stable ID first, then by name. Fragments can traverse nested properties and array items. A file without a fragment holds one standalone definition. A version pin asserts the file’s declared version, ignoring one leading v. An unpinned reference or @latest uses that same local file.
Materialization preserves local attributes and structure. It fills absent descriptions, business names, logical types and options, classification, critical-data flags, examples, enums, tags, custom properties, and units when RFC-0069 is enabled. Collections are copied whole when absent. Resolution follows transitive references against the path of each referencing file and reports cycles, ambiguous targets and invalid links.
Use --strict to block output when any targeted declaration is unresolved. Without it, valid partial output retains unresolved links and reports warnings to stderr. --without-provenance removes only successfully resolved semanticDefinition links. By default retained relative links are rebased when --output moves the contract. On stdout, links remain relative to the source directory. A .json output path emits JSON. Materialization preserves native data and metadata. YAML comments and formatting can change when a document is rewritten.
The command validates the materialized contract against the selected --schema-revision and active profiles before writing. It enables the experimental imports profile for that operation. Other hosts can set Odcs.EnableImportsRfc0032 or call WithImports() and invoke DefinitionResolutionService.ResolveAsync explicitly. The configuration key mapping.odcs.enableImportsRfc0032 enables the declaration checks and profile reporting. Reading, mapping and validation alone never fetch definitions.
The supported subset covers relative files only, with bounded local reads and chain depth. Network and registry locators, OSDS document envelopes, and user-created symbolic links and junctions are outside this MVP. macOS system aliases for /etc, /tmp, and /var are supported when they point to the expected local directories. RFC-0032 Option C
Semantic checks
This is the implementation matrix for ODCS 3.2.0. “ODCS” refers to declaration rules and consistency derived from the versioned specification. “Packata” identifies interoperability or execution-model requirements. Organizational recommendations (preferred status, classification, role, naming or ownership vocabularies) are not enforced as normative requirements.
| Area | Semantic check beyond the official schema | Origin / limits |
|---|---|---|
| Structure and names | Explicit schema; non-empty identity/version/kind and existing status requirement; non-empty, scoped unique schema/property names, server names, role names and team usernames | ODCS declaration consistency; schema itself does not require schema or status. Empty schema arrays remain permitted. |
| Stable IDs | Reserved characters and duplicate IDs in containing declaration arrays, including properties, relationships, quality, enums, governance, references and custom properties | ODCS; IDs may repeat in different scopes. Root contract ID is not a stable element ID. Vendor payload contents are opaque. |
| Relationships | Schema-level from/to shapes, implicit property-level sources, equal nonzero composite lengths, no repeated references, existence and matching declared logical types/type options | ODCS; shorthand uses names (users.id), qualified paths use IDs (schema/users-id/properties/key-id), including nested properties. External file.yaml#…/URL references fail with an explicit unresolved-reference error; no resolver or network fetch is implied. Missing logical types are not inferred. |
| Keys and partitions | Supplied positions must be unique positive integers on flagged sibling properties; -1 means unspecified | ODCS; positions are optional, and gaps/partially specified positions are allowed. |
| Options and bounds | Numeric/temporal bounds must match the declared type and describe a nonempty interval; length/item/property limits must be non-negative integers with minimum ≤ maximum; multipleOf positive; decimal precision positive, scale non-negative and ≤ declared precision | ODCS consistency plus Packata decimal support. Options without a logical type cannot be meaningfully checked and fail. Native decimal/range limits still apply. |
| Enums and vectors | Nonempty enum with unique values, independent of metadata; non-null scalar values match the logical type without numeric/string coercion; vectors require positive integer dimensions | ODCS plus Packata’s non-null enum model. Scalar range support follows the native model. |
| Servers | Unique declarations, supported encoding placement, local directory servers require object physical names | ODCS plus Packata binding rules. Multiple servers do not acquire inferred asset bindings. No endpoint availability or authentication checks. |
| Governance | Scoped IDs/names, team joining date ≤ leaving date, replacement identifies a different declared member | Declaration consistency. No IAM, email ownership, or organizational policy evaluation. |
| Quality | Type-specific definition, known library metric, custom implementation presence, metric/deprecated-rule conflicts, one or more expectations on measured rules, numeric ordering operands and ascending two-value ranges | ODCS declaration consistency. Custom adapter/normalization limitations remain warnings. No SQL/expression execution, scheduler validation or metric measurement. |
| SLA | Existing duration/unit, availability percentage/window, element-path and lifecycle milestone normalization; invalid recognized declarations are errors | Packata normalization rules; unsupported SLA property names remain warnings and metadata. No compliance evaluation. |
| Category tables | Retains category declarations, field-map, referenced object/property and binding checks (ODCS006/ODCS007) | Packata extension, declared through vendor: packata; no lookup dataset reads. |
The schema layer evaluates closure, conditional branches, types, formats, enums and collection constraints against the pinned base plus the tag preview. The complete assertion-path inventory records the keywords and values in the pinned base. Regression tests cover both source representations, selection, layer sequencing, declarations and prerequisites (DescriptorValidationTests, ValidateCommandTests).
Deliberate specification/schema differences
The official artifact is never patched to make the semantic layer agree with it:
| Disagreement | Schema-only | Semantic-only / combined |
|---|---|---|
| Required schema section | May omit schema | Semantic requires it; combined catches it after schema passes. |
Optional property logicalType | Optional; upstream conditionals can still constrain options when absent | May omit type without options; supplied options require a type. |
| Object-valued array items | Uses SchemaItemProperty, allowing nested object properties | Recursively checks the declared item object and its properties. |
| Vector without options | Can pass because dimensions is not conditionally required | Fails SEM_VECTOR. |
| Enum entries with equal values and different labels | uniqueItems compares complete entries, so may pass | Fails SEM_ENUM. |
| Enum value type / null | Companion schema scalar union may accept mismatched values and null | Enforces logical type without coercion and rejects null; required is not a null enum entry. Explicit null elsewhere follows the schema’s declared types. |
Decimal alias / nullable extension | decimal and property nullable are outside the official ODCS shape | Existing native decimal alias/nullability support does not override schema failure in combined mode. |
For example, logicalType: vector without options passes schema-only but fails semantic-only and default validation. Adding logicalTypeOptions: {dimensions: 3} fixes that declaration. Adding an unknown root field fails schema validation and skips semantics. A valid descriptor still says nothing about actual vector lengths, enum membership, foreign-key rows, quality results, or SLA observations in a dataset.
Library entry point
The CLI and .NET hosts share Packata.Application.Validation.DescriptorValidation:
var report = DescriptorValidation.Validate(originalText, format: "odcs");
var semantics = DescriptorValidation.Validate(originalText, format: "odcs",
layers: ValidationLayers.Semantic);
// report.Valid requires every selected layer to complete and pass.
For background syntax checks, use Packata.Application.Validation.DescriptorSyntaxValidation.Validate(originalText, cancellationToken). It checks a single bounded YAML mapping and strict JSON syntax for JSON-shaped input without deserializing native models, evaluating schemas/semantics or accessing resource data. Its result contains reusable Syntax and safe Diagnostics; optional parser locations use one-based line/column coordinates. Editor hosts project those coordinates into their range representation and apply their own document-size limits. ContractSyntax.Parse alone supplies a bounded YAML representation and does not enforce strict JSON grammar.
Layered validation reuses this syntax result and exposes its parser findings as report.SyntaxDiagnostics, so hosts can project errors without reparsing source.
Each layer reports its State, whether it Executed, and its Prerequisites (Satisfied or Failed). A semantic layer can partially execute and fail a structural prerequisite; it then reports State=Failed, Executed=true, and Prerequisites=Failed. A skipped layer has Executed=false and failed prerequisites. Editor hosts use this structured status to show blocked checks; they do not derive execution eligibility from diagnostic codes. Ordinary failed checks can have satisfied prerequisites.
report.Format and ContractSyntax.Format use the same DescriptorFormat classifier as native parsing and inspection. In auto mode, either kind or apiVersion identifies ODCS, including partially authored documents. Explicit format overrides remain authoritative. Broken-buffer recovery hints are also provided by Application through DescriptorFormat.Detect/Recover.
Pass original source text, not a serialized native model. The older ContractDocument.Validate(object) remains a native-model helper; it cannot prove source-schema validity. Data Package semantic validation retains the existing resource, field, key/category, contributor/license and dialect validators.