Expand description
Shikumi (仕組み) — config discovery, hot-reload, and ArcSwap store
for Nix-managed desktop applications.
Extracted from karakuri’s configuration system, shikumi provides the shared infrastructure for desktop apps that need:
- XDG config discovery with env var overrides and format preference
- Figment provider chains (defaults → env vars → config file)
- Lock-free concurrent reads via
ArcSwap - Hot-reload with symlink-aware file watching (for nix-darwin managed configs)
§Quick Start
use serde::Deserialize;
use shikumi::{ConfigDiscovery, ConfigStore, Format};
#[derive(Deserialize, Clone, Debug, Default)]
struct MyConfig {
window_width: Option<u32>,
}
let path = ConfigDiscovery::new("myapp")
.env_override("MYAPP_CONFIG")
.formats(&[Format::Yaml, Format::Toml])
.discover()
.expect("config file not found");
let store = ConfigStore::<MyConfig>::load(&path, "MYAPP_")
.expect("failed to load config");
let config = store.get();
println!("width: {:?}", config.window_width);Re-exports§
pub use coverage::ConfigCoverage;pub use coverage::CoverageReport;pub use discovered::ContributorNamesIter;pub use discovered::ContributorsAtIter;pub use discovered::DiscoveryComposition;pub use discovered::DiscoveryLayer;pub use discovered::LayerAttribution;pub use discovered::LayerAttributionIntoIter;pub use discovered::LayerAttributionIter;pub use discovered::LayerAttributionLayerRankingIter;pub use discovered::LayerAttributionLayerRankingNamesIter;pub use discovered::LayerAttributionLeafCountsByLayerIter;pub use discovered::LayerAttributionSubtreeIter;pub use discovered::LayerAttributionSubtreeLayerRankingIter;pub use discovered::LayerAttributionSubtreeLayerRankingNamesIter;pub use discovered::LayerAttributionSubtreeLeafCountsByLayerIter;pub use discovered::LayerAttributionSubtreeSurvivingLayerNamesIter;pub use discovered::LayerAttributionSubtreeWritesByLayerIter;pub use discovered::LayerAttributionSubtreeWritesOfLayerIter;pub use discovered::LayerAttributionSurvivingLayerNamesIter;pub use discovered::LayerAttributionWritesByLayerIter;pub use discovered::LayerAttributionWritesOfLayerIter;pub use discovered::LayerNamesIter;pub use discovered::NonemptyLayerDictsIter;pub use discovered::PathContest;pub use discovered::PathContestContributorsIter;pub use discovered::PathContestSilencedIter;pub use discovered::SilencedAtIter;pub use discovered::SilentLayerNamesIter;pub use discovered::coarsest_at;pub use discovered::coarsest_silenced_at;pub use discovered::compose as compose_discovery;pub use discovered::compose_with_provenance;pub use discovered::contest_at;pub use discovered::contributor_count;pub use discovered::contributor_count_at;pub use discovered::contributor_names;pub use discovered::contributor_names_iter;pub use discovered::contributors_at;pub use discovered::contributors_at_iter;pub use discovered::decider_at;pub use discovered::deep_merge;pub use discovered::has_contributor;pub use discovered::has_multiple_contributors;pub use discovered::has_multiple_silent_layers;pub use discovered::has_silent_layer;pub use discovered::is_contested_at;pub use discovered::is_multiply_silenced_at;pub use discovered::is_touched_at;pub use discovered::layer_names;pub use discovered::layer_names_iter;pub use discovered::nonempty_layer_dicts;pub use discovered::nonempty_layer_dicts_iter;pub use discovered::runner_up_at;pub use discovered::silenced_at;pub use discovered::silenced_at_iter;pub use discovered::silenced_count_at;pub use discovered::silent_layer_count;pub use discovered::silent_layer_names;pub use discovered::silent_layer_names_iter;pub use nix_provider::NixProvider;pub use secret::SecretBackendKind;pub use secret::SecretRefShape;pub use secret_client::SecretClientKind;pub use secret_client::SecretErrorKind;pub use secret_client::SecretOperation;pub use tiered::ConfigDiff;pub use tiered::ConfigTier;pub use tiered::ConfigTierKind;pub use tiered::DiffLine;pub use tiered::DiffLineKind;pub use tiered::ProgressiveLayer;pub use tiered::ProgressiveResolution;pub use tiered::Provenance;pub use tiered::ProvenanceMap;pub use tiered::ProvenanceMapEntries;pub use tiered::ProvenanceMapIntoIter;pub use tiered::TieredConfig;
Modules§
- coverage
ConfigCoverage— fleet invariant: every declared config field has a consumer.- discovered
- The discovered-defaults tier — environment-discovered layered defaults, merged into a config chain above the developer’s prescribed defaults but below operator file/env config.
- macros
- Declarative macros over the closed-axis / product-cube / tiered-config
discipline —
perm_cube!andtiered_permutation_test!. - nix_
provider - Figment provider for Nix expression configs.
- secret
- Secret resolution for config fields that reference external vaults.
- secret_
client - Unified secret-client abstraction.
- tiered
- Tiered configuration — the shikumi configuration prime directive.
Macros§
- closed_
axis_ label_ string_ surface - Emit the canonical
(Display, FromStr, Serialize, Deserialize)string-surface quartet for acrate::ClosedAxisLabelimplementor. - closed_
axis_ label_ string_ surface_ typed_ err - Emit the canonical
(Display, FromStr, Serialize, Deserialize)string-surface quartet for a closed-axis-label primitive whoseFromStr::Erris a bespoke typed label-carrying error struct — the sibling lift ofclosed_axis_label_string_surface!for the typed-error cohort (thecrate::ModalityClass,crate::SupportCardinalityClass,crate::SupportBoundaryDistance,crate::SupportMagnitudeDirection, andcrate::PartitionFacetyped cube classifiers, plus any future closed-axis primitive whose parse-rejection diagnostic needs a typedResult<_, _>shape rather than thecrate::ShikumiError::Parsesurface theclosed_axis_label_string_surface!cohort routes through). - perm_
cube - Mechanically emit a
crate::ProductCubeover independentcrate::ClosedAxisenums — the product struct +const ALL(full Cartesian product) +impl ClosedAxis+impl ProductCube. - serde_
via_ display_ fromstr - Emit the canonical
(Serialize, Deserialize)serde pair for any type whose canonical scalar form is itsstd::fmt::Displayand whose canonical parse is itsstd::str::FromStr. - tiered_
permutation_ test - Emit ONE matrix
#[test]that stamps every cube cell onto every config tier, serde-round-trips each, runs a userapplyclosure, and aggregates EVERY failure before asserting.
Structs§
- Attribution
Coordinates - Coordinate triple of an
AttributionRuleover the three orthogonal projectionsAttributionAxis(whichfigment::Metadatafield drove dispatch),ConfigSourceKind(which layer class the rule attributes to), andAttributionConfidence(equality-based vs uniqueness-based attribution). - Attribution
Name Kind Coordinates - Joint cell of a name-axis
AttributionRule: the typed pair ofFigmentNameTagKind(whichfigment::Metadata::nameclass the rule’s identity already names) andConfigSourceKind(whichConfigSourcelayer class the rule attributes to). - Attribution
Source Kind Coordinates - Coordinate pair over the two orthogonal closed-enum projections
every source-axis
AttributionRulepins on its joint (figment-Source-axis kind × shikumi-layer-kind) cell:FigmentSourceKind(whichfigment::Sourceclass the rule’s identity already names) andConfigSourceKind(whichConfigSourcelayer class the rule attributes to). - Axis
Histogram - Dense, declaration-ordered per-cell observation tally over a
ClosedAxis— the typed histogram every fleet observer reaches for when bucketing observations by axis cell. - Axis
Histogram Into Iter - Consuming iterator over the
(axis-value, count)pairs of anAxisHistogram, yielded in declaration order overClosedAxis::ALL. - Axis
Histogram Iter - Borrowing iterator over the
(axis-value, count)pairs of anAxisHistogram, yielded in declaration order overClosedAxis::ALL. - Axis
Histogram Iter Mut - Mutable borrowing iterator over the
(axis-value, &mut count)pairs of anAxisHistogram, yielded in declaration order overClosedAxis::ALL. - Axis
Histogram Nonzero - Borrowing iterator over the
(axis-value, count)pairs of anAxisHistogramwhose count is strictly positive, yielded in declaration order overClosedAxis::ALL. - Axis
Histogram Observed - Borrowing iterator over the axis cells of an
AxisHistogramwhose count is strictly positive — the histogram’s observed support, yielded in declaration order overClosedAxis::ALL, with the per-cell observation counts dropped from the item shape. - Axis
Histogram Unobserved - Borrowing iterator over the axis cells of an
AxisHistogramwhose count is zero — the histogram’s coverage gap, yielded in declaration order overClosedAxis::ALL, with the (uniformly-zero) per-cell observation count dropped from the item shape. - Axis
Iter - Zero-allocation stream of every value of a
ClosedAxisin declaration order overClosedAxis::ALL, returned byaxis_iter. - Config
Discovery - Builder for config file discovery.
- Config
Store - A concurrent, hot-reloadable config store.
- Config
Watcher - A symlink-aware config file watcher.
- Configured
Extensions - Zero-allocation
&'static strstream over the file extensions aConfigDiscoveryhonors, in the preference order set byConfigDiscovery::formats. - Error
Localization Coordinates - Coordinate pair over the two orthogonal closed-enum projections
every
ShikumiError(and every capturedcrate::ReloadFailure) carries on its error-path-fidelity surface:ShikumiErrorKind(which variant) andFieldPathLocalization(whether figment localized the offending field, didn’t, or wasn’t applicable at all). - Failing
Source Attribution - Typed envelope returned by
ShikumiError::failing_attribution: the attributedConfigSourceand theAttributionRulethat produced the attribution. - Format
Coordinates - Coordinate pair of a
Formatover the two orthogonal projectionsFormat(which on-disk format) andFormatProvenance(which provider class loads it). - Format
Metadata Tag - Recognized form of a shikumi-built provider’s
figment::Metadata::name, as parsed byFormat::parse_metadata_tag. - Forward
Iter - Zero-allocation stream of every value of a
PartialInverseCubeunder the forward image→cube morphismPartialInverseCube::forwardoverClosedAxis::ALLonPartialInverseCube::Image, returned byforward_iter. - Parse
Modality Class Error - Typed parse failure of [
<ModalityClass as std::str::FromStr>::from_str] — the offending input was not a canonical name on theModalityClasssurface. - Parse
Partition Face Error - Typed parse failure of [
<PartitionFace as std::str::FromStr>::from_str] — the offending input was not a canonical name on thePartitionFacesurface. - Parse
Support Boundary Distance Error - Typed parse failure of
[
<SupportBoundaryDistance as std::str::FromStr>::from_str] — the offending input was not a canonical name on theSupportBoundaryDistancesurface. Carries the offending substring verbatim in thelabelfield. Idiom-peer ofParseSupportCardinalityClassErrorandParseModalityClassErroron the sibling typed classifiers. - Parse
Support Cardinality Class Error - Typed parse failure of
[
<SupportCardinalityClass as std::str::FromStr>::from_str] — the offending input was not a canonical name on theSupportCardinalityClasssurface. Carries the offending substring verbatim in thelabelfield. Idiom-peer ofParseModalityClassErroron the sibling typed classifier. - Parse
Support Magnitude Direction Error - Typed parse failure of
[
<SupportMagnitudeDirection as std::str::FromStr>::from_str] — the offending input was not a canonical name on theSupportMagnitudeDirectionsurface. Carries the offending substring verbatim in thelabelfield. Idiom-peer ofParseSupportBoundaryDistanceErroron the sibling typed-bucket classifier andParseSupportCardinalityClassError/ParseModalityClassErroron the typed-class classifiers. - Provider
Chain - Builder for a figment provider chain.
- Realizable
Images - Zero-allocation stream of every realized image of a
PartialInverseCube— theSomeoutputs ofPartialInverseCube::invertoverClosedAxis::ALLonC, in cube-declaration order — returned byrealizable_images. - Realizable
Iter - Zero-allocation stream of every realizable cell of a
ProductCube— theClosedAxis::ALLslice onCfiltered byProductCube::is_realizable, returned byrealizable_iter. - Reload
Failure - A clone-able summary of the most recent reload failure on a
crate::ConfigStore. - Unrealizable
Iter - Zero-allocation stream of every unrealizable cell of a
ProductCube— theClosedAxis::ALLslice onCfiltered by!ProductCube::is_realizable, returned byunrealizable_iter.
Enums§
- Attribution
Axis - Figment-metadata field consulted by an
AttributionRule. - Attribution
Confidence - Confidence class of an
AttributionRule. - Attribution
Rule - Reason a
figment::Errorwas attributed to a specific layer in the recordedConfigSourcechain by [resolve_failing_source]. - Config
Source - A single layer in a config provider chain.
- Config
Source Kind - Data-free discriminant of
ConfigSource: the kind of layer independent of its inner path or prefix. - EnvMetadata
Tag - Recognized form of
figment::providers::Env’sfigment::Metadata::name, as parsed byConfigSource::strip_env_metadata_name. - EnvMetadata
TagKind - Data-free,
'staticdiscriminant ofEnvMetadataTag: the kind of figment env-metadata shape independent of the inner borrowed prefix slice. - Field
Path Localization - Closed tri-state partition over the field-path-localization axis of
a
ShikumiError/crate::ReloadFailure. - Figment
Name Tag - Closed-enum classification of
figment::Metadata::name. - Figment
Name TagKind - Data-free,
'staticdiscriminant ofFigmentNameTag: the kind offigment::Metadata::nameshape independent of the inner borrowedcrate::FormatMetadataTagenvelope orEnvMetadataTagprefix. - Figment
Source Kind - Data-free,
'staticdiscriminant ofFigmentSourceTag: the kind offigment::Sourceindependent of the inner borrowed path / location / string. - Figment
Source Tag - Borrowed classification of a
figment::Source. - Format
- Supported config file formats, in preference order.
- Format
Provenance - Closed binary partition over the
Formatvariant space along the (figment-builtin × shikumi-built) axis: which provider class loads values of this format. - Modality
Class - The closed modal/antimodal classification of an
AxisHistogramon the(strict / tied) × (modal / antimodal)two-axis multiplicity surface, with the empty boundary lifted to its own variant. - Parse
Axis Histogram Error - Typed parse-failure mode of
<AxisHistogram<A> as FromStr>::from_stron the labeled-axis histogram surface — one variant per structurally distinct rejection reason the parser can surface, each carrying the offending substring verbatim so a caller can localize the failure without re-derived bookkeeping at the call site. - Parse
Format Coordinates Error - Typed parse failure of [
<FormatCoordinates as std::str::FromStr>::from_str] — the offending input was not a canonical<format>:<provenance>cell. - Parse
Format Metadata TagError - Typed rejection reason emitted by
FormatMetadataTag’sTryFrom<&str>impl when an input doesn’t parse as a shikumi-built provider’sfigment::Metadata::name. - Parse
Partition Ordinal Error - Typed parse failure of [
<PartitionOrdinal as std::str::FromStr>::from_str] — the offending input was not a canonical<face>:<face_ordinal>address on thePartitionOrdinalsurface. - Partition
Face - Typed witness of which half of a
ProductCubea cell occupies — the recognized-image realizable surface or the cross-axis consistency-violation unrealizable complement. The variant tag ofPartitionOrdinallifted into its own closed-axis typescape primitive. - Partition
Ordinal - Typed witness of which half of a
ProductCubea cell occupies, carrying the dense ordinal on that half. - Shikumi
Error - Errors produced by shikumi’s config discovery, loading, and watching.
- Shikumi
Error Kind - Closed partition over the
ShikumiErrorvariant space. - Support
Boundary Distance - Typed three-bucket projection of the support-cardinality scalar by
distance from the support-cardinality boundary — the closed
enum lift of the (
is_boundary,is_singular,is_strict_partial_cover) strict ternary partition onSupportCardinalityClass. Each of the five class variants lands in exactly one bucket; the compiler enforces exhaustiveness at everymatchsite on the ternary. - Support
Cardinality Class - The support-cardinality classification of an
AxisHistogramon the(observed, unobserved)cell-partition surface — the five-corner exhaustive partition of the support-cardinality interval[0, axis_cardinality::<A>()]. - Support
Magnitude Direction - Typed three-bucket projection of the support-cardinality scalar by
support-magnitude direction — the closed enum lift of the
(
is_low_support,is_strict_partial_cover,is_high_support) strict ternary partition onSupportCardinalityClass. The mirror peer ofSupportBoundaryDistanceacross theSupportCardinalityClass::StrictPartialCovermiddle leg: both ternaries share the strict-interior middle bucket but split the four non-interior corners on orthogonal axes. - Watch
Event Class - Reload-relevance class of a file-watch
notify::Event— the typed decision “does this event warrant re-reading the config?”.
Traits§
- Closed
Axis - Closed discipline trait every typescape closed-axis primitive and every typescape product cube satisfies.
- Closed
Axis Label - Closed labeling discipline trait — adds the canonical operator-facing
string label on top of
ClosedAxis. - Config
Source Chain - Chain-level provenance queries over a recorded
ConfigSourcechain. - Partial
Inverse Cube - Closed discipline trait for the
ProductCubesubset whose forward map from the recognized-image type into the cube is injective, so the cube carries a partial inverse back into the image:invert(cell) = Some(image)exactly on the realizable cells,Noneon the cross-axis consistency-violation complement. - Product
Cube - Closed discipline trait every typescape product cube satisfies — a
refinement of
ClosedAxisthat additionally pins the realizability predicate over the recognized-image cells.
Functions§
- at_
partition_ ordinal - Decode a
PartitionOrdinalinto the cell it addresses on aProductCube— fuses (realizable_at,unrealizable_at) into one helper routed by the variant tag. - axis_at
- Structural ordinal lookup for a
ClosedAxis— the value at positionordinalinA::ALL, orNoneif the index is out-of-range. - axis_
cardinality - Cardinality of a
ClosedAxis—A::ALL.len()collapsed to one named helper. - axis_
from_ label - Parse a
ClosedAxisLabelvalue from its canonical operator-facing label —ClosedAxisLabel::from_canonical_strreached as a free function generic over the axis type. - axis_
histogram - Lift an iterator of axis observations into a typed
AxisHistogram<A>— the dense per-cell tally overClosedAxis::ALL. - axis_
iter - Iterate every value of a
ClosedAxis—A::ALL.iter().copied()collapsed to one named helper. - axis_
label - Canonical operator-facing label of a
ClosedAxisLabelvalue —ClosedAxisLabel::as_strreached as a free function generic over the axis type. - axis_
ordinal - Structural ordinal of a
ClosedAxisvalue — the position ofvalueinA::ALL, in declaration order. - forward_
iter - Iterate the forward image of every image under
PartialInverseCube::forward—C::Image::ALL.iter().copied() .map(C::forward)collapsed to one named helper. - partition_
ordinal - Typed partition ordinal of a
ProductCubecell — fuses (realizable_ordinal,unrealizable_ordinal) into one total helper returning aPartitionOrdinalvariant tagged with which face of the cube the cell sits on. - realizable_
at - Dense ordinal lookup over the realizable surface of a
ProductCube— the realizable cell at positionordinalinrealizable_iter::<C>(), orNoneif the index is out-of-range. - realizable_
count - Count the realizable cells of a
ProductCube. - realizable_
images - Iterate the realized images of a
PartialInverseCube— theSomeoutputs ofPartialInverseCube::invertoverClosedAxis::ALL, in cube-declaration order. - realizable_
iter - Iterate the realizable cells of a
ProductCube—C::ALL.iter().copied().filter(|c| c.is_realizable())collapsed to one named helper. - realizable_
ordinal - Dense ordinal of a
ProductCubecell over the realizable surface — the position ofcellinrealizable_iter::<C>(), orNoneon the cross-axis consistency-violation complement. - symlink_
target - Resolves a symlink to its canonical target, or returns
Noneif the path is not a symlink. - unrealizable_
at - Dense ordinal lookup over the unrealizable complement of a
ProductCube— the unrealizable cell at positionordinalinunrealizable_iter::<C>(), orNoneif the index is out-of-range. - unrealizable_
count - Count the unrealizable cells of a
ProductCube—C::ALL.len() - realizable_count::<C>()collapsed to one named helper. - unrealizable_
iter - Iterate the unrealizable cells of a
ProductCube—C::ALL.iter().copied().filter(|c| !c.is_realizable())collapsed to one named helper. - unrealizable_
ordinal - Dense ordinal of a
ProductCubecell over the unrealizable complement — the position ofcellinunrealizable_iter::<C>(), orNoneon the recognized-image realizable surface.