diff --git a/docs/SCHEMA_HISTORY.md b/docs/SCHEMA_HISTORY.md index c7c65b2..7f5f658 100644 --- a/docs/SCHEMA_HISTORY.md +++ b/docs/SCHEMA_HISTORY.md @@ -1,10 +1,113 @@ # Schema Evolution History +PowderLine recipes are validated against a **core schema** (the shared top level +and structural models, owned by PowderLine) plus one **engine schema** per +gateway (`gsasii`, `topas`, `easydiffraction`), each in its engine's native +conventions. Every schema has its own version. A recipe states both +(`core_schema_version`, `engine_schema_version`), and each PowderLine release +**declares** which versions it accepts. Compatibility is never inferred from the +version numbers (`powderline.support_matrix()` lists the declarations). + +> **Refactor in progress (v0.2.0).** The schemas below are being introduced on +> the `refactor/multi-engine` branch. Until the 0.26.0 schema is removed (re/07), +> `powderline.run()` / `validate()` still validate recipes against the +> **unified 0.26.0 schema** documented in the archive at the bottom of this page. + +--- + +## Core schema + +### 1.0.0 — introduced in PowderLine 0.2.0 (in development) + +Defined in `src/powderline/schema_core.py`. Not used by any gateway yet: the +engine schemas adopt it in re/04–06. + +- **Recipe frame** (`CoreRecipe`): `schema_name` (`"."`), + `core_schema_version`, `engine_schema_version`, `metadata`, `payload` (typed + by the engine schema). Unknown keys are errors at every level. +- **`metadata`**: free-form and never interpreted; must be JSON-serializable and + at most **1 MiB** as UTF-8 JSON. The cap is the constant + `schema_core.METADATA_MAX_BYTES`; change it there and record the change here. +- **Parameters**: `[value, refine_flag]` (no bounds) or + `[value, refine_flag, min, max]` (bounds the engine honors). A bounded list + where bounds aren't supported is an error. `refine_flag` is a JSON boolean. + `value` may be `null` (= start from the phase structure's value) only for + quantities that mirror a structure value. +- **Data and ranges**: `xrd_data` (2θ in degrees, weights 1/σ², validated as in + 0.26.0); `fit_range` `[min, max]`, with `max > min`, inside the data's 2θ range. +- **Background**: Chebyshev (`num_coefficients`, `coefficients`, `refine_flag`). + Coefficient semantics are documented per engine. +- **Units** are fixed per field in the schema, never written in a recipe. +- **Numbers** are JSON numbers: a quoted number (`"0.25"`) or a boolean is an + error, never converted. Integer fields (`Multiplicity`, `num_coefficients`) + take a whole number (`4` or `4.0`), not `4.5`. +- **Accepted core versions** (this release): `==1.0.0`. + +- **Phase structure** (`PhaseStructure`): `phase_name`, `space_group`, + `unit_cell`, `atoms` (keyed by label). Structural interpretation is checked + once, in core, so every engine gets the same structure. All structural + problems are reported together, each at its own field (`unit_cell`, + `atoms.