crv.core.versioning
Experimental API
Version helpers may change while APIs converge toward 1.0. Since: 2025-09-25.
crv.core.versioning
Schema version metadata and helpers for CRV JSON schemas and table descriptors.
Exposes the canonical schema version (SCHEMA_V) used across artifacts and provides compatibility and successor checks. This module is zero-IO.
Notes
- Downstream components embed SCHEMA_V to tag produced artifacts.
- Tests assert constants match SCHEMA_V and validate bump sequences.
- Loaders/writers may use is_compatible to enforce contract alignment.
References
- specs: src/crv/core/.specs/spec-0.1.md, spec-0.2.md
- ADR: src/crv/core/.specs/adr-2025-09-20-core-schema-0.1-and-graphedit-normalization.md
crv.core.versioning.SCHEMA_V
module-attribute
crv.core.versioning.SCHEMA_COMPAT_MAJOR
module-attribute
crv.core.versioning.SCHEMA_COMPAT_MINOR
module-attribute
crv.core.versioning.SchemaVersion
dataclass
Immutable semantic version with ISO release date for CRV artifacts.
Attributes:
| Name | Type | Description |
|---|---|---|
major |
int
|
Non-negative major component signalling breaking changes. |
minor |
int
|
Non-negative minor component for additive, non-breaking changes. |
date |
str
|
ISO YYYY-MM-DD release timestamp retained for JSON/metadata payloads. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any component is negative or the date is not ISO compliant. |
Source code in src/crv/core/versioning.py
crv.core.versioning.is_compatible
Check whether a version matches the supported schema contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ver
|
crv.core.versioning.SchemaVersion
|
Version descriptor to validate against the canonical schema metadata. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if ver shares both the major and minor numbers with SCHEMA_V; False otherwise. |
Examples:
>>> from crv.core.versioning import SchemaVersion, SCHEMA_V, is_compatible
>>> is_compatible(SCHEMA_V)
True
Source code in src/crv/core/versioning.py
crv.core.versioning.is_successor_of
is_successor_of(
candidate: crv.core.versioning.SchemaVersion,
current: crv.core.versioning.SchemaVersion,
) -> bool
Determine whether a version is the immediate successor of another.
CRV schema updates follow semantic versioning semantics
- Minor bumps increase the minor component while keeping the major fixed.
- Major bumps increase the major component by exactly one and reset minor to zero.
- Larger jumps (skipping minor numbers or jumping more than one major version) are non-sequential.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidate
|
crv.core.versioning.SchemaVersion
|
Proposed schema revision. |
required |
current
|
crv.core.versioning.SchemaVersion
|
Baseline schema version currently supported. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if candidate immediately follows current; False otherwise. |
Examples:
>>> from crv.core.versioning import SchemaVersion, SCHEMA_V, is_successor_of
>>> is_successor_of(SchemaVersion(SCHEMA_V.major, SCHEMA_V.minor + 1, SCHEMA_V.date), SCHEMA_V)
True
>>> is_successor_of(SchemaVersion(SCHEMA_V.major + 1, 0, SCHEMA_V.date), SCHEMA_V)
True
>>> is_successor_of(SchemaVersion(SCHEMA_V.major, SCHEMA_V.minor + 2, SCHEMA_V.date), SCHEMA_V)
False