Skip to content

feat(metadata): extract the catalog crate, and give the schema a version - #27

Merged
define-null merged 5 commits into
masterfrom
defnull/extract-metadata-crate
Sep 11, 2026
Merged

define-null merged 5 commits into
masterfrom
defnull/extract-metadata-crate

Conversation

@define-null

Copy link
Copy Markdown
Contributor

What is this PR about?

Two changes that belong together: the catalog types and loader become a crate of their own, and the catalog schema they read gains a version.

src/metadata becomes crates/metadata, package sqd-metadata, so other projects can read a catalog without pulling in the engine. The engine re-exports it under the module's old path, so every crate::metadata:: consumer in the engine, tests, benches and examples is untouched. The catalogs stay at the repository root; the crate's tests reach them from there. The spec checker walked src/ and tests/ for coverage tags, which would have lost the loader's fourteen: it now walks crates/ too, and its self-tests stage that tree. The Makefile gates pass --workspace, since a root package makes plain cargo test skip the member.

A catalog now opens with version, a string, and the loader refuses any value but the one it reads, v2, exported as SCHEMA_VERSION. Required rather than defaulted: a version that could be omitted tells a reader nothing, and a catalog written for a later schema should fail at load rather than be read as this one. The bundled catalogs and every inline test catalog carry it.

A new version must stay backwards compatible with v2. A catalog is published once by its provider (the network scheduler, for one) and read by several consumers on their own release cycles, so a version a v2 reader cannot accept obliges the provider to publish one catalog per version in use. The rule is recorded beside the constant, in the crate's README and in the catalogs' README.

Two changes that belong together: the catalog types and loader become a
crate of their own, and the catalog schema they read gains a version.

src/metadata becomes crates/metadata, package sqd-metadata, so other
projects can read a catalog without pulling in the engine. The engine
re-exports it under the module's old path, so every crate::metadata::
consumer in the engine, tests, benches and examples is untouched. The
catalogs stay at the repository root; the crate's tests reach them from
there. The spec checker walked src/ and tests/ for coverage tags, which
would have lost the loader's fourteen: it now walks crates/ too, and its
self-tests stage that tree. The Makefile gates pass --workspace, since a
root package makes plain `cargo test` skip the member.

A catalog now opens with `version`, a string, and the loader refuses any
value but the one it reads, `v2`, exported as SCHEMA_VERSION. Required
rather than defaulted: a version that could be omitted tells a reader
nothing, and a catalog written for a later schema should fail at load
rather than be read as this one. The bundled catalogs and every inline
test catalog carry it.

A new version must stay backwards compatible with v2. A catalog is
published once by its provider (the network scheduler, for one) and read
by several consumers on their own release cycles, so a version a v2
reader cannot accept obliges the provider to publish one catalog per
version in use. The rule is recorded beside the constant, in the crate's
README and in the catalogs' README.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@define-null
define-null marked this pull request as ready for review September 8, 2026 15:16
define-null and others added 4 commits September 11, 2026 13:58
A catalog is published once and read by consumers on their own release
cycles, so a key added under v2 reaches readers that predate it. Every
catalog type denied unknown fields, and the loader walked
special_filters and virtual_fields for stray keys, so one new optional
key made every older reader refuse the whole catalog.

The types now skip a key they do not know, and the stray-key walk goes,
with the per-kind key lists it read. A misspelled optional key is
skipped the same way. A test loads a catalog carrying an unknown key in
every shape a catalog has. The stale-key test and the misspelled alias
key case asserted the opposite and are removed, as is the conformance
note's citation of the former.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The loader skips a key it does not know, so a catalog that gained an
optional key still loads in a release that predates it. A misspelled
optional key is skipped the same way, and changes what the engine does:
parent_hash_colum turns fork detection off, implicit_filter widens an
alias to its whole table, knd: children makes a relation a plain join.
A reader cannot tell the two apart; only the release a catalog is
written for can.

parse_dataset_description_strict and load_dataset_description_strict
load as the others do, then refuse every key the parse skipped and name
each by its path. They find one by comparing the document with the
description written back out, which reaches into special_filters and
virtual_fields too. A plain scalar key is compared as its text, and a
key set to null is passed over, since it sets nothing.

The bundled catalogs and the format doc's alias example load strictly,
and both READMEs say a provider checks a catalog this way before
publishing it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@define-null
define-null merged commit 419b99d into master Sep 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant