Skip to content

Component: Smrt.Infrastructure

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


Smrt.Infrastructure

Overview & Responsibilities

  • Provides the canonical bootstrap hook (InfrastructureBootstrap) that host processes call during startup to coordinate one-time registrations.
  • Establishes the landing zone for future infrastructure adapters that must stay UI/runtime agnostic and integrate cleanly with Smrt.Core primitives.
  • Keeps diagnostics centralized by deferring logging and configuration work to Smrt.Logging and Smrt.Config.

Dependencies & Integrations

  • Targets .NET 8 and references Smrt.Core for shared primitives.
  • Designed to integrate with Smrt.Config, Smrt.Logging, and other platform libraries without introducing circular dependencies.

Configuration & Log Paths

  • Infrastructure helpers resolve configuration and logging paths via Smrt.Config and defer log emission to Smrt.Logging.
  • No configuration files ship with the assembly; consuming apps provide overlays in their own AppData slugs per policy.

Runtime Flows

  • InfrastructureBootstrap.EnsureLoaded(Action? onLoaded) should be invoked from each host application's startup path. The method returns true only the first time it runs, allowing callers to gate one-time registrations while remaining safe for repeated calls.
  • Future bootstrap entry points (e.g., dependency injection modules) must remain deterministic and side-effect free so they can be invoked in service hosts or desktop apps alike.
  • Additional infrastructure adapters must document threading and lifecycle assumptions in their XML comments.

Public surface

The primary public surface is the bootstrap entry point listed under Key APIs below.

Key APIs

  • InfrastructureBootstrap.EnsureLoaded(Action? onLoaded) – idempotent bootstrap guard that executes the provided callback exactly once per process lifetime.
using Smrt.Infrastructure;

if (InfrastructureBootstrap.EnsureLoaded(RegisterInfrastructureServices))
{
    // Execute logic needed only on the first process boot.
}

void RegisterInfrastructureServices()
{
    // Perform dependency injection wiring, messaging subscriptions, etc.
}

Storage Guard Components

  • StorageGuard/StorageGuardService.cs captures drive, sync, and retention health; it now embeds sanitized policy + legal-hold snapshots sourced from Smrt.Retention so compliance tooling consumes a single signed artifact.
  • StorageGuard/StorageGuardModels.cs contains DTOs for StorageGuardSnapshot, the new StorageGuardRetentionStatus, and supporting records used throughout the platform.
  • StorageGuard/StorageGuardPaths.cs resolves canonical locations for storage-guard.json and signatures, handling migrations between %LocalAppData% and %ProgramData% automatically.

System Info Snapshot

  • SystemInfo/SystemSpecsWriter.cs writes a machine-level system specs + capabilities snapshot once at startup.
  • SystemInfo/SystemInfoPaths.cs resolves the canonical path under %ProgramData%/SmrtHub/Logs/system-info/ (with SMRTHUB_COMMON_APPDATA_OVERRIDE support for tests).
  • Consumers should treat the snapshot as best-effort diagnostics and still validate hard requirements at point-of-use.
  • AI OCR note: Windows AI Text Recognition uses Microsoft.Windows.AI.Imaging.TextRecognizer. The snapshot reports windowsAiTextRecognizerReadyState via TextRecognizer.GetReadyState() and does not call EnsureReadyAsync() at startup.
  • UI note: capabilities.evaluations provides stable, user-facing capability IDs with statuses + reasons (for example ocr.windowsAi).

Testing & Validation

  • Add component-level tests in the dependent application or a future Smrt.Infrastructure.Tests project to validate integration scenarios.
  • Validate new adapters against both .NET desktop and service hosts to ensure no UI-specific dependencies leak in.

Support Bundle & Diagnostics

  • Infrastructure components leverage Smrt.Logging for telemetry and automatically participate in Support Bundle exports when the host opts in.

Roadmap

  • TODO: add dependency-injection extension methods that wrap InfrastructureBootstrap so hosts can register common services via fluent calls.

Subdirectories

  • StorageGuard/ – Storage Guard service, DTOs, and path helpers powering the system-info snapshot artifacts.
  • Generated build artifacts (bin/, obj/).
  • SmrtApps/src/Smrt.Core/README.md
  • SmrtApps/src/Smrt.Config/README.md