Configuration Subsystem¶
The Configuration Subsystem is a platform-level, cross-cutting subsystem that standardizes how SmrtHub components locate, read, validate, and persist configuration/state artifacts.
Canonical policy reference:
README.Files/System/Policies/SmrtHub-Operational-Data-Policy-v1.0.README.md
Overview & responsibilities¶
- Define and enforce canonical locations and naming for configuration/state artifacts (per Operational Data Policy).
- Provide safe, deterministic persistence primitives (atomic writes, minimal backups, deterministic JSON formatting).
- Ensure cross-runtime parity between C# and Python so components behave consistently.
Contracts and invariants¶
All SmrtHub components must follow these contracts:
- Canonical paths only
- Config/state artifacts live under
%AppData%/SmrtHub/Config/<component-slug>/(roaming) or%LocalAppData%/SmrtHub/Config/<component-slug>/(local), per Operational Data Policy. -
Slugs are kebab-case (examples:
trigger-manager,clipboard-monitor,python-core). -
Canonical file names
- Prefer the Operational Data Policy defaults (for example
<slug>-config.json,<slug>-state.json). -
Do not invent new per-component naming patterns.
-
Atomic persistence
- Writes must be atomic: no partial files should appear on disk.
- C# uses
Smrt.Config.ConfigJson.AtomicWrite(or a component wrapper that calls into it). -
Python uses the canonical atomic JSON write helper used by
python_core. -
Minimal backup policy
- Overwriting an existing file leaves a single adjacent
.bakfor quick recovery. -
No multi-file rotation for config/state artifacts.
-
Deterministic JSON
- Persist UTF-8 JSON with stable key ordering to minimize diffs and support troubleshooting.
-
When migrations matter, include a root
schemaVersionand keep forward-migration behavior explicit. -
No secrets in config/state
- Tokens and secrets must not be stored in config/state JSON.
- Store secrets in the approved secret store (Windows Credential Manager via
Smrt.Security) and persist only references/IDs.
Integration points¶
- C#
Smrt.ConfigprovidesConfigPathResolverandConfigJsonfor path computation and JSON persistence.- Python
python_coreuses its configuration path resolver and atomic persistence helpers to match the same Operational Data Policy conventions.
Configuration, paths, and operational data¶
- The authoritative path rules, slugs, and filenames are defined in
README.Files/System/Policies/SmrtHub-Operational-Data-Policy-v1.0.README.md. - Component READMEs should reference those rules rather than duplicating path tables.
Observability & diagnostics¶
- Components must log configuration load/validation failures via the unified logging subsystem (
Smrt.Loggingin C#,python_core.utils.loggerin Python). - Failures should be actionable: include which artifact failed (kind + component slug), which scope (roaming/local), and the failure mode (missing file, parse failure, schema mismatch, permissions).
- Support Bundle tooling may collect configuration snapshots from canonical directories; do not write config outside canonical locations.
Security/privacy notes¶
- Treat config/state as potentially sensitive operational metadata.
- Enforce “no secrets in JSON” as a hard rule.
- Ensure logs do not emit full config payloads unless redacted and explicitly required for diagnostics.
Testing & validation expectations¶
- Validate path resolution produces the expected canonical directories and filenames.
- Validate atomic write behavior under interruption and concurrent access (no partial files;
.bakbehavior correct). - Validate schema/version migration behavior where applicable.
- Validate parity across C# and Python for the same component slug and artifact kinds.