Expand description
Schema, validation, comment-preserving editing and public hashing for a
Stratum node’s stratum.toml.
Pre-release. This is 0.1.0-alpha: the API and the file format may
change before 0.1.0.
§The model
- One schema table.
schemareturns the only definition of the configuration: every field’s dotted path,ValueType, default, description andApplyClass. Validation, the seed document, the typedConfig, the public view and the serialised form served by an HTTP schema endpoint are all derived from it, so they cannot drift. - Documents.
ConfigDocument::parseturnsstratum.tomltext into a validated document or a list of everyValidationError: syntax, unknown keys, wrong types, out-of-range values, field rules and cross-field conflicts. A document carriesschema_version =SCHEMA_VERSION; any other version is rejected. Omitted fields take their defaults. - Preview.
previewapplies a list ofChanges to base text and reports, without side effects, the edited text (comments and order kept), a unified diff, the changed fields in schema order with secret references redacted, each change’s apply class, the strictest class overall, and every validation error of the result. - Apply classes.
ApplyClass::Live<ApplyClass::Restart<ApplyClass::Redeploy; the strictest class of a set of changes is their maximum and tells the caller what it must do for them to take effect. - Public hash.
ConfigDocument::public_configis the effective configuration minus secret-reference fields, andConfigDocument::public_hashis SHA-256 over its documented canonical encoding (PublicConfig::canonical_text) prefixed withPUBLIC_HASH_VERSION. Changing a secret reference leaves the hash unchanged; changing anything else changes it.
The crate is pure: it performs no filesystem, network, clock or
environment access and never resolves a secret reference. Text longer
than MAX_DOCUMENT_BYTES (256 KiB) is refused before it is parsed. A
syntax error reports only its line and column, never the parser’s
description, which can quote the input.
backup.age_recipients accepts only post-quantum hybrid age recipients
(age1pq1…), checked structurally (lowercase Bech32, checksum, padding,
key length) without depending on age. The list holds at most
MAX_BACKUP_RECIPIENTS (32) entries, the most a Stratum node encrypts a
backup to.
§Examples
use stratum_node_config::{preview, schema, ApplyClass, Change, ConfigDocument};
// Start from the generated seed, which validates and holds the defaults.
let seed = schema().seed_text();
let before = ConfigDocument::parse(&seed)?;
// Preview an edit and inspect it before committing anything.
let p = preview(&seed, &[Change::new("node.name", "alpha")])?;
assert!(p.errors().is_empty());
assert_eq!(p.strictest_apply_class(), Some(ApplyClass::Live));
let after = p.into_document().ok_or("edit should be valid")?;
assert_eq!(after.config().node_name(), "alpha");
assert_ne!(after.public_hash(), before.public_hash());Structs§
- Change
- A requested edit: set the field at
pathtovalue. - Config
- The effective configuration of a valid document, with one strongly typed getter per schema field.
- Config
Document - A validated
stratum.tomldocument: its exact text plus the effective configuration with defaults filled in. - Field
Change - One entry of a preview’s change list: a field whose effective value the edit changes.
- Field
Descriptor - One field of the schema: its path, type, default, description and apply class.
- Fields
- Iterator over the schema’s
FieldDescriptors, returned bySchema::fields. - Preview
- The result of
preview: what an edit would do, computed without side effects. - Public
Config - The effective configuration with every secret-reference field removed.
- Public
Hash - A SHA-256 public-configuration hash, from
PublicConfig::hash. - Public
Iter - Iterator over a
PublicConfig’s(path, value)pairs, returned byPublicConfig::iter. - Schema
- The complete
stratum.tomlschema. - Secret
Ref - An opaque reference to a secret held by a custody service.
- Validation
Error - One problem found while validating a configuration document.
- Validation
Errors - A non-empty list of every
ValidationErrorfound in one document.
Enums§
- Apply
Class - When a changed field takes effect.
- Preview
Error - Why
previewcould not produce an edited document. - Validation
Error Kind - The category of a
ValidationError. - Value
- A configuration value, independent of any TOML or JSON library.
- Value
Type - The type of a schema field, including any range or variant set.
Constants§
- MAX_
BACKUP_ RECIPIENTS - The largest number of entries
backup.age_recipientsmay hold. - MAX_
DOCUMENT_ BYTES - The largest
stratum.tomlthis crate accepts, in bytes: 256 KiB. - PUBLIC_
HASH_ VERSION - The version of the public-configuration hash format.
- REDACTED
- The text that stands in for a secret-reference value in change lists and
Debugoutput. - SCHEMA_
VERSION - The version of the
stratum.tomlschema this library implements.