Skip to content

Component: Smrt.SmrtSpace

Canonical source: SmrtApps/src/Smrt.SmrtSpace/README.md (mirrored below)


Smrt.SmrtSpace

Overview & Responsibilities

  • Provides a small, policy-aligned persistence layer for SmrtSpace:
  • A per-user SmrtSpace catalog (multiple workspaces).
  • A per-user active selection pointer (active_smrtspace.json) declaring the current SmrtSpace name + root.
  • Implements enterprise-grade write semantics for config/state:
  • Atomic file writes.
  • Cross-process coordination via named mutex.

Public surface / Entry points

  • Library API only (no CLI, UI, or hosted service).
  • Primary entry point: SmrtSpaceCatalogStore.

Dependencies & Integrations

  • Depends on Smrt.Config for canonical path resolution and atomic JSON persistence.
  • Depends on Smrt.Logging for policy-aligned logging.
  • Intended to be consumed by UI/hosts (for example, HubWindow quick settings or Settings Host workflows).

Configuration & Log Paths

  • Configuration/state directory (Roaming): %APPDATA%/SmrtHub/Config/smrt-space/
  • Files:
  • smrt-space-catalog.json — per-user catalog of known SmrtSpaces.
  • active_smrtspace.json — active SmrtSpace selection (name + root).
  • Logging follows the standard %LOCALAPPDATA%/SmrtHub/Logs/<component>/ conventions through Smrt.Logging.

Runtime flows

  • Read operations are tolerant of missing files and will return empty/default models.
  • Mutations are wrapped with Smrt.Config.ConfigJson.WithNamedMutex(...) so multiple processes cannot corrupt state.
  • Creating a SmrtSpace:
  • Normalizes the root and appends the SmrtSpace name when the root is a parent path.
  • Ensures the target root directory exists.
  • Upserts the entry into the catalog.
  • Updates the active selection.

Key APIs

  • SmrtSpaceCatalogStore.ListSpaces() — returns known catalog entries.
  • SmrtSpaceCatalogStore.LoadActiveSelectionOrNull() — reads active_smrtspace.json best-effort.
  • SmrtSpaceCatalogStore.CreateSmrtSpace(name, root) — creates/upserts + sets active selection.
  • SmrtSpaceCatalogStore.SetActiveSmrtSpaceById(id) — sets active selection by catalog entry id and updates the entry’s last-selected timestamp.

Testing & Validation

  • Unit tests live in the sibling project Smrt.SmrtSpace.Tests.
  • Run: dotnet test SmrtApps/src/Smrt.SmrtSpace.Tests/Smrt.SmrtSpace.Tests.csproj -c Debug -r win-x64

Support Bundle & Diagnostics

  • SmrtSpace state is already stored under canonical Operational Data Policy directories and is therefore support-bundle friendly.
  • Avoid logging user-provided values (filesystem paths, profile ids, etc.); log presence and stable event names only.

Subdirectories

  • bin/, obj/ — Build outputs.