Skip to main content

Module schema

Module schema 

Source
Expand description

Schema export: a deterministic, machine-readable description of every model the admin knows about.

The emitted rustio.schema.json file is the interface between a RustIO project and external tooling — including the Phase 2 AI layer. Its shape is versioned and expected to stay stable across patch releases. Additions in minor releases are allowed; renames and removals are breaking changes and must bump SCHEMA_VERSION.

The schema is produced by introspecting a built Admin registry, not by parsing source code. This guarantees that whatever the admin actually serves is what the schema describes.

§Determinism contract

For a given registered model set, Schema::from_admin produces byte-for-byte identical JSON on every invocation:

  • Models are emitted sorted by name.
  • Fields within a model are emitted sorted by name.
  • No timestamps, hashes, or environment-derived values are written to the file.

This is what makes the schema usable as a diff target in CI and as a stable anchor for AI-layer tooling.

Structs§

IncomingRelation
0.8.0 — one inferred incoming relation. Produced by Schema::incoming_relations; not stored on disk.
Relation
First-class foreign-key annotation on a field.
Schema
Top-level schema document. Serialised as rustio.schema.json.
SchemaField
SchemaModel
SchemaRelation
Placeholder relation shape left from 0.4.0. Still serialised in SchemaModel.relations for backward compatibility (reserved slot for future per-model metadata). The 0.8.0 flow uses SchemaField::relation instead — the per-field location is the source of truth.

Enums§

RelationKind
Typed relation direction. Kept #[non_exhaustive] so a later pass can add variants (OneToOne, ManyToMany) without breaking downstream matchers. Callers must include a wildcard arm.
SchemaError
Reasons a schema can be rejected. Named variants (never raw strings) so tooling can branch on the failure kind.

Constants§

SCHEMA_VERSION
Version of the rustio.schema.json format itself. Independent of the rustio-core crate version — a single schema version can outlive many rustio-core releases as long as the wire format doesn’t change.
VALID_TYPE_NAMES
The complete set of type names that may appear in SchemaField.ty. Anything outside this set is a schema error and the AI boundary rejects it. Kept as a const so tests and validators share a single source of truth.