Skip to content

[DRY/KISS] Consolidate settings transaction plumbing across use-case facades #122

Closed

Description

@KeyffMS

Audit finding

ConfigurationUseCases and VisualProfileUseCases are intentionally thin, but they repeat the same infrastructure around SettingsCoordinator:

  • storing and validating the coordinator;
  • exposing a defensive snapshot;
  • forwarding the Changed event;
  • wrapping domain mutations in Commit;
  • returning closely related commit-result shapes.

SettingsCoordinator.Commit and PersistCurrent also repeat expected-exception classification and persistence failure handling.

The duplication is small, but it is transaction plumbing rather than product behavior and is likely to spread as additional configuration use cases are added.

Target state

Introduce one lightweight reusable transaction context/helper for application use cases and one private persistence execution path inside SettingsCoordinator.

Prefer composition and private helpers. Do not create a deep use-case inheritance hierarchy or generic command framework.

Acceptance criteria

  • Expected settings persistence errors are classified and formatted through one implementation path.
  • Unexpected transaction failures continue to be reported and rethrown.
  • Commit still publishes exactly once only after persistence succeeds.
  • PersistCurrent preserves its current no-change-event behavior unless an explicit product decision changes it.
  • Configuration and visual-profile use cases share snapshot/event/commit plumbing without sharing their domain commands.
  • Public behavior and error messages remain unchanged.
  • Tests cover success, validation failure, I/O failure and unexpected exception paths after refactoring.

Completion evidence — 2026-09-24

Implemented in PR #157 and merged as 10e3e64747e8982a116aa4e686ac943ba99eb35c.

Verified pull-request checks:

  • DCO run 36000698085 — success;
  • full Windows build/test/release-compliance run 36000698065 — success.

The implementation exposes read snapshots through IReadOnlySightAdaptSettings, preserves defensive copies, centralizes shared use-case transaction plumbing in SettingsUseCaseContext, and routes both Commit and PersistCurrent through one private persistence execution path while preserving their distinct change-event behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions