From b0c24a1722d12a42544e875fcb182518af33939b Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Sat, 31 Oct 2026 12:39:25 +0200 Subject: [PATCH] Standardizes the architecture decision records Uses ADR-0001 as the template for the sections of every ADR, moves the remaining in-document amendments to amendment sections at the end in chronological order, renames the consequence subsections to the template names, and fixes the heading formatting. --- .../architecture-decision-record-0003.md | 27 +++++++++---------- .../architecture-decision-record-0008.md | 8 +++--- .../architecture-decision-record-0010.md | 20 ++++++++------ .../architecture-decision-record-0011.md | 4 +-- .../architecture-decision-record-0012.md | 4 +-- .../architecture-decision-record-0013.md | 4 +-- .../architecture-decision-record-0014.md | 4 +-- .../architecture-decision-record-0015.md | 4 +-- .../architecture-decision-record-0016.md | 4 +-- .../architecture-decision-record-0017.md | 4 +-- .../architecture-decision-record-0018.md | 4 +-- .../architecture-decision-record-0019.md | 1 - 12 files changed, 37 insertions(+), 51 deletions(-) diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0003.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0003.md index 1bfd69b4..b9adc308 100644 --- a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0003.md +++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0003.md @@ -1,9 +1,9 @@ # Architecture Decision Record (ADR): 0003 - Pragmatic `System.IO` Usage for File System Discovery in Library Scan Job -## Status +## Status **Accepted** (2025-03-01) -## Context +## Context The media library scanning subsystem requires: 1. **Performance at scale**: enumeration of files needs to run fast, because file discovery is the first job in the chain of media library scan jobs. If this is slow, the entire scan will be slow, no matter how optimized subsequent jobs are. 2. **Domain model limitations**: @@ -13,7 +13,7 @@ The media library scanning subsystem requires: - Users potentially having tens of millions of files and hundreds of terrabytes of data, in some cases. - Limited value from domain semantics during raw discovery. -## Decision +## Decision Use `System.IO` directly in `FileSystemDiscoveryJob` with: ```csharp @@ -25,33 +25,28 @@ private static List GetFiles(...) } ``` - -## Amendments - -- **2026-10-09**: The single generic `FileSystemDiscoveryJob` was split into per-type discovery jobs (`BooksFileSystemDiscoveryJob`, `MusicFileSystemDiscoveryJob`). The `System.IO` guidance of this ADR applies to the books discovery job, which still traverses the file system directly. The music discovery job uses the domain file system provider services (`IFileProviderService`, `IDirectoryProviderService`) instead. - ## Consequences -### Performance vs Purity Tradeoff +### Positive Outcomes | Metric | Before (Domain) | After (System.IO) | Delta | |----------------------|-----------------|-------------------|----------| | 100k File Enumeration| 65s | 4s | -94% | -### Risks and Mitigations +### Risks and Tradeoffs | Risk | Mitigation Strategy | |-------------------------------|------------------------------------------------------------| | Hidden Platform Dependencies | Regular integration tests on Linux/Windows | | Loss of Domain Abstraction | Strictly limit usage to library scan discovery phase only | -## Alternatives Considered +## Alternatives Considered -### 1. Optimized Domain Aggregate +### 1. Optimized Domain Aggregate Domain entities like `File` or `Directory` could be modified to bypass invariants checks in their initialization, leading to a noticeable latency drop. **Rejected**: Invariants checks are one of the most important domain aspects, and the performance gain was still insufficient for the target scale. -### 2. Hybrid Approach +### 2. Hybrid Approach ```csharp if (fileCount > 10_000) @@ -84,7 +79,7 @@ static extern IntPtr OpenDir(string name); | Memory Leaks | Manual handle management required finalizers and safe handles | | Testing Complexity | Physical VM requirements for platform validation | -### 5. Native C Library with Managed Interop +### 4. Native C Library with Managed Interop ```c // file_discovery.c @@ -114,3 +109,7 @@ void lin_enumerate(const char* path, void (callback)(const char)) | Cross-Compilation Complexity | Required CI pipeline support for Windows/macOS/Linux binaries | | ABI Breakage | High risk of crashes during .NET runtime updates | | Debugging Difficulty | Specialized tools (WinDbg/gdb) needed for crash analysis | + +## Amendment: Per-Type File System Discovery Jobs (2026-10-09) + +The single generic `FileSystemDiscoveryJob` was split into per-type discovery jobs (`BooksFileSystemDiscoveryJob`, `MusicFileSystemDiscoveryJob`). The `System.IO` guidance of this ADR applies to the books discovery job, which still traverses the file system directly. The music discovery job uses the domain file system provider services (`IFileProviderService`, `IDirectoryProviderService`) instead. diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0008.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0008.md index 37c87324..6e0244e1 100644 --- a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0008.md +++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0008.md @@ -17,10 +17,6 @@ Define the `IScanJobRegistry` interface, which maps a hook name to the plugin jo The payload passing between jobs keeps the generic `ExecuteAsync` contract. The core scan jobs are database-centric and ignore the payload, because they exchange the scan state through the staging and snapshot tables ([ADR-0004](architecture-decision-record-0004.md), [ADR-0005](architecture-decision-record-0005.md)). Payload passing remains available for plugin jobs that need to exchange data in memory, and the runtime type switching that was used in the previous `HashComparerJob` is eliminated. -## Amendments - -- **2026-10-09**: Superseded by [ADR-0015](architecture-decision-record-0015.md). The `ScanJobHooks` hook points and the `IScanJobRegistry` / `ScanJobRegistry` were removed, and plugins now contribute capability providers (`IMetadataProvider`, `IArtworkProvider`, `IBookReader`) instead of scan jobs. This ADR is marked superseded rather than amended because its decision is replaced in full by [ADR-0015](architecture-decision-record-0015.md); [ADR-0001](architecture-decision-record-0001.md), [ADR-0003](architecture-decision-record-0003.md) and [ADR-0010](architecture-decision-record-0010.md) stay accepted because only part of their decisions changed. - ## Consequences > The rows struck through reflect the superseded hook point and scan job registry model. They no longer hold, see [ADR-0015](architecture-decision-record-0015.md). @@ -51,3 +47,7 @@ Allow plugins to attach anywhere in the graph without restriction. Rework the jobs into a generic pipeline engine where edges carry strongly typed channels. **Rejected**: The database-centric jobs exchange state through the database, so a full in-memory typed dataflow engine would add complexity without benefit. The generic payload contract is retained for the plugin jobs that need it. + +## Amendment: Superseded by Plugin Capability Providers (2026-10-09) + +Superseded by [ADR-0015](architecture-decision-record-0015.md). The `ScanJobHooks` hook points and the `IScanJobRegistry` / `ScanJobRegistry` were removed, and plugins now contribute capability providers (`IMetadataProvider`, `IArtworkProvider`, `IBookReader`) instead of scan jobs. This ADR is marked superseded rather than amended because its decision is replaced in full by [ADR-0015](architecture-decision-record-0015.md); [ADR-0001](architecture-decision-record-0001.md), [ADR-0003](architecture-decision-record-0003.md) and [ADR-0010](architecture-decision-record-0010.md) stay accepted because only part of their decisions changed. diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0010.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0010.md index 09680ffa..4c274bf6 100644 --- a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0010.md +++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0010.md @@ -18,14 +18,6 @@ The metadata enrichment job (`MediaLibraryScanMetadataEnrichmentJob`) is a best- The `MediaLibraryScanResultsSaveJob` no longer publishes `LibraryScanFinishedDomainEvent`. The event is published by the last job of the directed acyclic job graph: the save job when the library does not permit downloading data from the web (no enrichment phase), or the metadata enrichment job otherwise. -## Amendments - -- **2026-10-09**: The enrichment phase is now three sequential jobs, and the last job of the graph is the artwork enrichment job. - - `MediaLibraryScanProviderConfigurationInvalidationJob` invalidates the enrichment state of the items whose metadata or artwork providers changed since the last scan, and the metadata derived from the paths when the path template changed. - - `MediaLibraryScanMetadataEnrichmentJob` enriches the metadata and links the media contributors. - - `MediaLibraryScanArtworkEnrichmentJob` resolves the artwork and is always the last job, publishing `LibraryScanFinishedDomainEvent` (see `MediaLibraryScanArtworkEnrichmentJob`). -- **2026-10-09**: The `MediaLibraryScanResultsSaveJob` no longer publishes `LibraryScanFinishedDomainEvent`; it triggers the provider configuration invalidation job. The metadata enrichment semantics described below apply to both the metadata and the artwork enrichment jobs, and across every media library type with enrichers, including music (`MusicMediaLibraryScanMetadataEnricher`, `MusicMediaLibraryScanArtworkEnricher`), not only books. - ## Consequences ### Positive Outcomes @@ -53,3 +45,15 @@ Keep [ADR-0009](architecture-decision-record-0009.md) semantics for the enrichme Enrich the books asynchronously after the scan, decoupled from the scan progress and cancellation. **Rejected**: This contradicts the decision that the metadata enrichment phase is part of the scan lifetime, covered by the scan progress reporting and cancellation machinery, so that the scan progress reaches completion only when the metadata is downloaded. + +## Amendment: Sequential Enrichment Jobs and Artwork Enrichment Last (2026-10-09) + +The enrichment phase is now three sequential jobs, and the last job of the graph is the artwork enrichment job. + +- `MediaLibraryScanProviderConfigurationInvalidationJob` invalidates the enrichment state of the items whose metadata or artwork providers changed since the last scan, and the metadata derived from the paths when the path template changed. +- `MediaLibraryScanMetadataEnrichmentJob` enriches the metadata and links the media contributors. +- `MediaLibraryScanArtworkEnrichmentJob` resolves the artwork and is always the last job, publishing `LibraryScanFinishedDomainEvent` (see `MediaLibraryScanArtworkEnrichmentJob`). + +## Amendment: Enrichment Semantics Across Media Library Types (2026-10-09) + +The `MediaLibraryScanResultsSaveJob` no longer publishes `LibraryScanFinishedDomainEvent`; it triggers the provider configuration invalidation job. The metadata enrichment semantics described above apply to both the metadata and the artwork enrichment jobs, and across every media library type with enrichers, including music (`MusicMediaLibraryScanMetadataEnricher`, `MusicMediaLibraryScanArtworkEnricher`), not only books. diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0011.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0011.md index 4e57fd2f..375bb703 100644 --- a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0011.md +++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0011.md @@ -1,7 +1,6 @@ # Architecture Decision Record (ADR): 0011 - Replace MediatR with Custom CQRS Abstractions ## Status - **Accepted** (2026-08-13) ## Context @@ -121,8 +120,7 @@ internal sealed class GetConfiguredNismsEndpoint : IGetConfiguredNismsEndpoint | DI Alignment | Leverages the existing .NET DI container idioms already present in the solution | | Performance | No runtime reflection, other than the startup registration of application use case handlers | -### Risks and Mitigations - +### Risks and Tradeoffs | Risk | Mitigation Strategy | |---|---| | Loss of pipeline behavior support | Application validation will be performed manually, as an orchestration step | diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0012.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0012.md index 27bf386e..933c28cd 100644 --- a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0012.md +++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0012.md @@ -1,7 +1,6 @@ # Architecture Decision Record (ADR): 0012 - Replace FluentValidation with Custom Validation Abstractions ## Status - **Accepted** (2026-08-13) ## Context @@ -171,8 +170,7 @@ internal sealed class CreateSensorCommandValidator : AbstractValidator`, `IQueryHandler<>` | Consistency | Domain event handlers join the same explicit registration scan as the CQRS handlers | | Single event contract | `IDomainEvent` remains the sole contract until a real cross-bounded-context consumer exists | -### Risks and Mitigations - +### Risks and Tradeoffs | Risk | Mitigation Strategy | |---|---| | Handler resolution failures surface at runtime | Existing integration test suite exercises the DI container on startup | diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0014.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0014.md index 32fd843b..56b3e3d0 100644 --- a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0014.md +++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0014.md @@ -1,7 +1,6 @@ # Architecture Decision Record (ADR): 0014 - Closed Generic Persistence Toolkit for Aggregate Graph Persistence ## Status - **Accepted** (2026-09-26) ## Context @@ -54,8 +53,7 @@ Treat `Lumina.DataAccess\Common\Persistence` as a closed set of generic, entity- | Testability | The primitives are covered directly by unit tests, independently of any repository | | Ownership | No new external dependency and no declarative engine; the toolkit depends only on the internal `ISharedReferenceEntity` marker, and the logic stays explicit and inspectable | -### Risks and Mitigations - +### Risks and Tradeoffs | Risk | Mitigation Strategy | |---|---| | The generic resolver depends on an entity keyed by `Name` and translated by EF Core | `SharedReferenceResolver` is generic over `ISharedReferenceEntity` and is exercised by both unit and integration tests, which prove the EF translation | diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0015.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0015.md index 6756845e..c4a946f0 100644 --- a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0015.md +++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0015.md @@ -1,7 +1,6 @@ # Architecture Decision Record (ADR): 0015 - Plugin Capability Providers for Media Library Enrichment ## Status - **Accepted** (2026-10-09) Supersedes [ADR-0008](architecture-decision-record-0008.md). @@ -56,8 +55,7 @@ The host defines the capability contracts, and a plugin implements the ones it s | Per-library control | Providers are enabled and ranked per media library, independent of plugin installation | | Simplicity | No hook registry, no graph splicing across the plugin boundary, and no runtime payload type switching | -### Risks and Mitigations - +### Risks and Tradeoffs | Risk | Mitigation Strategy | |---|---| | A plugin registers a capability a library type does not support | Providers declare `SupportedLibraryTypes`, and the host only offers and invokes providers that support the library being processed | diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0016.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0016.md index f438f466..93ee1830 100644 --- a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0016.md +++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0016.md @@ -1,7 +1,6 @@ # Architecture Decision Record (ADR): 0016 - Playback Delivery Decision and Player Capability Negotiation ## Status - **Accepted** (2026-10-14) ## Context @@ -70,8 +69,7 @@ The segments are exposed through a dedicated segment route, `.../stream/deliveri | Seekability | Time addressed segments make a normalized delivery seekable without a byte to time index | | Testability | The decision is a pure function of the stored container and codec and the advertised capabilities | -### Risks and Mitigations - +### Risks and Tradeoffs | Risk | Mitigation Strategy | |---|---| | The probe reports a codec as a free form description that does not name the codec the player advertises | The stored description is canonicalized to the advertised codec names before comparison, and the MPEG layer is matched by its layer number, so a description that names no decodable codec is left unmatched and forces a transcode | diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0017.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0017.md index 1a1e6f43..0a0f8476 100644 --- a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0017.md +++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0017.md @@ -1,7 +1,6 @@ # Architecture Decision Record (ADR): 0017 - One Generic Favorites Aggregate Keyed by Media Kind and Item Id ## Status - **Accepted** (2026-10-21) ## Context @@ -61,8 +60,7 @@ The decision includes these rules: | No existence oracle | An inaccessible item and a missing item are indistinguishable when adding, and inaccessible display data is never listed | | No schema change for new kinds | The kind is stored by name, so a planned kind only needs its restriction lifted and its two resolutions written | -### Risks and Mitigations - +### Risks and Tradeoffs | Risk | Mitigation Strategy | |---|---| | Without a foreign key, rows can point at items that no longer exist | This is intended: the listing returns such rows as unavailable and removal never needs the item. Nothing relies on the item being present | diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0018.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0018.md index b30cfb39..980a40e2 100644 --- a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0018.md +++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0018.md @@ -1,7 +1,6 @@ # Architecture Decision Record (ADR): 0018 - Media Neutral Consumption History, Resume Points, and Derived Statistics ## Status - **Accepted** (2026-10-26) ## Context @@ -88,8 +87,7 @@ The statistics count a session when the rule of its media kind says so. Duration | Per-library policy | Progress tracking and completion thresholds are chosen per library instead of being hardcoded for a media kind | | Privacy by default | A regular user cannot read or delete another user's data, and a wrong user id is reported as not authorized rather than revealing existence | -### Risks and Mitigations - +### Risks and Tradeoffs | Risk | Mitigation Strategy | |---|---| | Without a foreign key, a record can point at an item that no longer exists | This is intended: the history keeps its counts and duration, and the list returns the item as unavailable with blank display data so the user can delete it | diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0019.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0019.md index 3385708e..e8d7e710 100644 --- a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0019.md +++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0019.md @@ -1,7 +1,6 @@ # Architecture Decision Record (ADR): 0019 - SSD Aware Read Parallelism During Media Library Scans ## Status - **Accepted** (2026-10-30) ## Context