mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 09:11:10 +00:00
Renames project content from Lumina to Nemera
This commit is contained in:
1 parent
0f659a4877
commit
c583c9327c
6127 files changed
+41884
-41884
No files matched your search
+2
-2
@@ -95,9 +95,9 @@ public class JobHandler
|
||||
|
||||
### 3. Registration of `DbContextFactory` instead of `DbContext`
|
||||
```csharp
|
||||
services.AddDbContextFactory<LuminaDbContext>(options =>
|
||||
services.AddDbContextFactory<NemeraDbContext>(options =>
|
||||
{
|
||||
options.UseSqlite($"Data Source={Path.Combine(basePath, "Lumina.db")}");
|
||||
options.UseSqlite($"Data Source={Path.Combine(basePath, "Nemera.db")}");
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ The media library scan pipeline stages the file system items discovered during a
|
||||
2. is read by the diff, hash and metadata enrichment jobs,
|
||||
3. is written by the discovery job and read by later jobs, which run in separate dependency injection scopes (see [ADR-0001](architecture-decision-record-0001.md)), hence on separate database connections.
|
||||
|
||||
A real SQLite `TEMP` table was considered, but SQLite `TEMP` tables are scoped to a single database connection. Because each media library scan job creates its own `AsyncServiceScope`, and therefore its own `LuminaDbContext` and connection ([ADR-0001](architecture-decision-record-0001.md)), a `TEMP` table created by the discovery job would be invisible to the diff job, which runs on a different connection. Making a `TEMP` table work would require pinning a single dedicated connection for the whole staging phase of a scan, a larger architectural carve-out.
|
||||
A real SQLite `TEMP` table was considered, but SQLite `TEMP` tables are scoped to a single database connection. Because each media library scan job creates its own `AsyncServiceScope`, and therefore its own `NemeraDbContext` and connection ([ADR-0001](architecture-decision-record-0001.md)), a `TEMP` table created by the discovery job would be invisible to the diff job, which runs on a different connection. Making a `TEMP` table work would require pinning a single dedicated connection for the whole staging phase of a scan, a larger architectural carve-out.
|
||||
|
||||
## Decision
|
||||
Use a permanent table, `LibraryScanStagingResults`, keyed by `(LibraryScanId, Path)`. Its rows are deleted at the end of the scan (as part of the snapshot swap transaction of the save job) and on scan failure or cancellation. Leftover rows of a crashed scan are inert, because every scan has a unique id, and can be purged by the audit cleanup job.
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ The media library scan jobs perform bulk data operations that the Entity Framewo
|
||||
Bulk inserts through the EF Core change tracker are slow for hundreds of thousands of rows, because every entity is individually tracked and saved. At the target scale (millions of files), the scan pipeline needs a data access path that is not only fast, but also bounded in memory.
|
||||
|
||||
## Decision
|
||||
Add the Dapper library to the DataAccess layer, and perform the bulk data operations of the scan jobs with parameterized raw SQL on a dedicated `Microsoft.Data.Sqlite` connection, derived from the connection string of the injected `LuminaDbContext`.
|
||||
Add the Dapper library to the DataAccess layer, and perform the bulk data operations of the scan jobs with parameterized raw SQL on a dedicated `Microsoft.Data.Sqlite` connection, derived from the connection string of the injected `NemeraDbContext`.
|
||||
|
||||
These operations never touch the Entity Framework change tracker. Reads that are not bulk (for example loading the media library entity) keep using EF Core, and bulk reads use unbuffered, key-set paginated queries to keep the peak memory bounded.
|
||||
|
||||
|
||||
+3
-3
@@ -19,12 +19,12 @@ Key constraints that shaped this decision:
|
||||
|
||||
## Decision
|
||||
|
||||
Replace MediatR with minimal, hand-written CQRS abstractions placed in `Lumina.Application.Common.CQRS`. Handlers are resolved directly via the .NET dependency injection container - no mediator object, no runtime reflection dispatch.
|
||||
Replace MediatR with minimal, hand-written CQRS abstractions placed in `Nemera.Application.Common.CQRS`. Handlers are resolved directly via the .NET dependency injection container - no mediator object, no runtime reflection dispatch.
|
||||
|
||||
### Core Abstractions
|
||||
|
||||
```csharp
|
||||
// src/Lumina.Application/Common/CQRS/ICommand.cs
|
||||
// src/Nemera.Application/Common/CQRS/ICommand.cs
|
||||
|
||||
/// <summary>
|
||||
/// Marker interface for command types handled by <see cref="ICommandHandler{TCommand, TResult}"/>.
|
||||
@@ -46,7 +46,7 @@ public interface ICommandHandler<in TCommand, TResult> where TCommand : ICommand
|
||||
```
|
||||
|
||||
```csharp
|
||||
// src/Lumina.Application/Common/CQRS/IQuery.cs
|
||||
// src/Nemera.Application/Common/CQRS/IQuery.cs
|
||||
|
||||
/// <summary>
|
||||
/// Marker interface for query types handled by <see cref="IQueryHandler{TQuery, TResult}"/>.
|
||||
|
||||
+3
-3
@@ -13,11 +13,11 @@ The solution uses FluentValidation to validate commands and queries at the appli
|
||||
|
||||
3. **External Dependency Surface**: FluentValidation is a well-maintained library, but the danger of it going commercial, like other open source popular libraries in recent times, and the lack of usage of its advanced features mandates an in-house replacement.
|
||||
|
||||
4. **Placement in SharedKernel**: Validation logic is cross-cutting and lives in `Lumina.Application.Common.Infrastructure.Validation`. Owning the abstraction entirely means the validation model stays aligned with the domain's `Error` type without any adapter.
|
||||
4. **Placement in SharedKernel**: Validation logic is cross-cutting and lives in `Nemera.Application.Common.Infrastructure.Validation`. Owning the abstraction entirely means the validation model stays aligned with the domain's `Error` type without any adapter.
|
||||
|
||||
## Decision
|
||||
|
||||
Replace FluentValidation with a minimal, first-party validation framework placed in `Lumina.Application.Common.Infrastructure.Validation`. The API mirrors FluentValidation's familiar fluent surface (`RuleFor`, `Must`, `When`, `WithError`) to minimize migration friction.
|
||||
Replace FluentValidation with a minimal, first-party validation framework placed in `Nemera.Application.Common.Infrastructure.Validation`. The API mirrors FluentValidation's familiar fluent surface (`RuleFor`, `Must`, `When`, `WithError`) to minimize migration friction.
|
||||
|
||||
### Core Abstractions
|
||||
|
||||
@@ -123,7 +123,7 @@ internal sealed class ValidationRule<TRequest, TProperty>
|
||||
|
||||
### Built-in Extension Methods
|
||||
|
||||
Common predicates are provided as extension methods on `IRuleBuilder<TRequest, TProperty>` via `ValidatorUtilities`, placed in `Lumina.Application.Common.Utilities`:
|
||||
Common predicates are provided as extension methods on `IRuleBuilder<TRequest, TProperty>` via `ValidatorUtilities`, placed in `Nemera.Application.Common.Utilities`:
|
||||
|
||||
| Extension | Overloads | Behaviour |
|
||||
|---|---|---|
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ The remaining publish half carries the same third-party dependency and source-ge
|
||||
|
||||
Replace Mediator's notification publishing with a first-party domain event publisher.
|
||||
|
||||
### New Abstractions (in `Lumina.Domain.Common.Events`)
|
||||
### New Abstractions (in `Nemera.Domain.Common.Events`)
|
||||
|
||||
- `IDomainEvent` no longer inherits `INotification`.
|
||||
- `IDomainEventPublisher` exposes `ValueTask PublishAsync(IDomainEvent domainEvent, CancellationToken cancellationToken = default)`.
|
||||
|
||||
+3
-3
@@ -13,11 +13,11 @@ Repositories in the DataAccess layer persist aggregate graphs: they load a track
|
||||
|
||||
3. **Scalar copy on edit**: `EditableValuesCopier` applies editable scalar values while leaving the audit columns to the auditing interceptor. Seven auditable repositories (`Role`, `LibraryScan`, `ScheduledJob`, `ScheduledJobExecution`, `Theme`, `User`, `UserSettings`) still copied scalars with `CurrentValues.SetValues`, which writes every scalar property, including the primary key and the audit columns. Writing the primary key is destructive whenever the tracked row was located by a key other than its primary key: `UserRepository` locates the row by username, so an incoming entity whose Id differs from, or is unset relative to, the stored one would retarget the tracked row's identity, leaving the guarantee "the stored identity is never overwritten by an edit" to caller convention instead of to the code.
|
||||
|
||||
`Lumina.DataAccess\Common\Persistence` already held `CollectionReconciler` and `EditableValuesCopier`, but there was no shared reference primitive and no explicit boundary defining what may live there, so the shared reference concern was expressed per type and per repository.
|
||||
`Nemera.DataAccess\Common\Persistence` already held `CollectionReconciler` and `EditableValuesCopier`, but there was no shared reference primitive and no explicit boundary defining what may live there, so the shared reference concern was expressed per type and per repository.
|
||||
|
||||
## Decision
|
||||
|
||||
Treat `Lumina.DataAccess\Common\Persistence` as a closed set of generic, entity-agnostic primitives that express the whole of aggregate graph persistence. Per-entity logic stays in the repository, and cross-cutting logic is generalized rather than specialized.
|
||||
Treat `Nemera.DataAccess\Common\Persistence` as a closed set of generic, entity-agnostic primitives that express the whole of aggregate graph persistence. Per-entity logic stays in the repository, and cross-cutting logic is generalized rather than specialized.
|
||||
|
||||
### The closed set
|
||||
|
||||
@@ -99,6 +99,6 @@ Details edits still go through `EditableValuesCopier`, but the copier now compar
|
||||
|
||||
The one-time application initialization is the only save whose audit identity is provided explicitly instead of being stamped by the auditing interceptor. The setup handler creates the original administrator account before any user exists, and the seed service creates the default permissions, roles, role-permission grants, user-role link and scheduled jobs in the same anonymous flow. Those rows therefore cannot derive an actor from `ICurrentUserService`.
|
||||
|
||||
The bootstrap code sets `CreatedBy` to the fixed SYSTEM audit identifier `11111111-1111-1111-1111-111111111111` and sets `CreatedOnUtc` from `IDateTimeProvider`, then saves through `SaveChangesAsInitializationAsync`. That method marks the save on the `LuminaDbContext` for its duration, and the interceptor skips its stamping only for that save. No other save path is affected.
|
||||
The bootstrap code sets `CreatedBy` to the fixed SYSTEM audit identifier `11111111-1111-1111-1111-111111111111` and sets `CreatedOnUtc` from `IDateTimeProvider`, then saves through `SaveChangesAsInitializationAsync`. That method marks the save on the `NemeraDbContext` for its duration, and the interceptor skips its stamping only for that save. No other save path is affected.
|
||||
|
||||
The SYSTEM identity is never inferred from a missing authenticated user. Ordinary anonymous creation and modification remain unattributed with `Guid.Empty`, and the interceptor is still the sole writer for every ordinary save. The initialization exception exists because the app has no user account to attribute the bootstrap rows to, and it is confined to the setup and seed code paths.
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
## Context
|
||||
|
||||
Lumina's music player is implemented from scratch, on WebCodecs for decoding and the Web Audio API for output, with no `HTMLMediaElement` and no Media Source Extensions. That player can only demux a curated set of containers and decode a curated set of codecs, so the server has to tell it, before it fetches any audio, whether a track can be played as stored or whether the server has to change the container or the codec first.
|
||||
Nemera's music player is implemented from scratch, on WebCodecs for decoding and the Web Audio API for output, with no `HTMLMediaElement` and no Media Source Extensions. That player can only demux a curated set of containers and decode a curated set of codecs, so the server has to tell it, before it fetches any audio, whether a track can be played as stored or whether the server has to change the container or the codec first.
|
||||
|
||||
The server already has each track's stored probe result (the container and the codec, plus the sample rate, the channels, the bit depth, the duration and the ReplayGain values) and a stream endpoint with HTTP range support that serves the original file. What is missing is the decision itself and a way for the player to state what it can play.
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ The decision includes these rules:
|
||||
| `MediaConsumptionRecord` | The write aggregate of a session. It holds a `MediaConsumptionRecordId`, the owner, the library, the media kind, the media item identifier, the status, the start, last activity and end times, the consumed duration, the latest position and progress fraction, and the consecutive page count. No album, artist, series or catalogue hierarchy is stored on the record. |
|
||||
| `MediaResumePoint` | The write aggregate of the latest position. It holds a `MediaResumePointId`, the owner, the library, the media kind, the media item identifier, the latest position, the latest progress fraction and the last consumption time. It is created only for a resumable kind whose library tracks progress. |
|
||||
| `ConsumptionStatistics` | A read model, not an aggregate and not a table. It is built from `MediaConsumptionRecordEntity` collections in the application handlers and mapped to the summary, recent, most consumed, tag and genre responses. |
|
||||
| `MediaKind` | The shared enumeration in `Lumina.Domain.SharedKernel`. `MusicTrack` and `Book` are supported by the current catalogues. `PodcastEpisode`, `Audiobook`, `Movie`, `TvEpisode`, `Photo` and `Video` have rules and are listed for clients, but are rejected by the lifecycle endpoints until their catalogues exist. `None` is invalid. |
|
||||
| `MediaKind` | The shared enumeration in `Nemera.Domain.SharedKernel`. `MusicTrack` and `Book` are supported by the current catalogues. `PodcastEpisode`, `Audiobook`, `Movie`, `TvEpisode`, `Photo` and `Video` have rules and are listed for clients, but are rejected by the lifecycle endpoints until their catalogues exist. `None` is invalid. |
|
||||
| `MediaConsumptionRule` | The shared value object hierarchy that owns resumability (`PositionKind`, `CanResume`), one-shot behavior and counting (`Counts`). It is reused by both aggregates and the statistics read model, so callers never switch on `MediaKind` for these rules. |
|
||||
| Completion settings | `LibraryConsumptionSettings` on the `Library` aggregate. It stores `ShouldTrackConsumptionProgress` and an optional `CompletionThresholdPercentage`. The validator rejects a threshold when tracking is off, and a threshold outside 0 to 100 when it is supplied. |
|
||||
| Storage | `MediaConsumptionRecords` and `MediaResumePoints`. The owner is a cascading foreign key to `Users`; the media item is a plain identifier with no foreign key to a media catalogue. Both tables carry an optimistic concurrency version and the audit columns. |
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
A media library scan performs two kinds of file system reads. Discovery reads directory entries and file metadata, and hashing samples file contents. Their throughput depends on the storage medium. A solid state drive serves concurrent reads with little penalty, while a mechanical hard drive pays a seek for every position change, so concurrent reads can reduce its throughput.
|
||||
|
||||
Lumina cannot determine the storage medium reliably. Drive type queries are platform specific, and they are unreliable for network, virtual, and removable volumes. The scan therefore needs an explicit input instead of an automatic guess.
|
||||
Nemera cannot determine the storage medium reliably. Drive type queries are platform specific, and they are unreliable for network, virtual, and removable volumes. The scan therefore needs an explicit input instead of an automatic guess.
|
||||
|
||||
Not every scan stage performs bulk local reads. Audio metadata extraction parses tag blocks, and metadata and artwork enrichment call remote providers. Those stages have their own constraints, which are part of this decision.
|
||||
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@ Persisted entity and domain event identifiers are created with `Guid.CreateVersi
|
||||
The decision applies to Domain, Application, DataAccess, and Infrastructure:
|
||||
|
||||
- Every identifier factory and every code path that mints an entity or domain event identifier in application code calls `Guid.CreateVersion7()` directly.
|
||||
- Every Entity Framework Core property of type `Guid` with `ValueGenerated.OnAdd` is assigned the `GuidV7ValueGenerator` in `LuminaDbContext.OnModelCreating`. The loop covers real keys and owned collection shadow keys, so the data seed service can keep leaving seeded permission and role identifiers unset.
|
||||
- Every Entity Framework Core property of type `Guid` with `ValueGenerated.OnAdd` is assigned the `GuidV7ValueGenerator` in `NemeraDbContext.OnModelCreating`. The loop covers real keys and owned collection shadow keys, so the data seed service can keep leaving seeded permission and role identifiers unset.
|
||||
- Existing rows keep their version 4 identifiers. This is a forward-only change, and no primary key or foreign key is rewritten.
|
||||
|
||||
The following identifiers intentionally remain outside the version 7 strategy:
|
||||
@@ -57,7 +57,7 @@ The following identifiers intentionally remain outside the version 7 strategy:
|
||||
| Existing rows keep version 4 identifiers | Do not use identifier order as a chronology across the migration boundary; use `CreatedOnUtc` |
|
||||
| The two SQL bulk insert paths keep version 4 identifiers | The exception is documented in this ADR and in both repositories, so it is not changed accidentally |
|
||||
| Version 7 ordering depends on the system clock | Clock skew can break ordering, but not uniqueness; do not depend on strict ordering across machines |
|
||||
| Entity Framework Core could seed a new key with version 4 again | `LuminaDbContext` applies the generator to every `Guid` property configured with `ValueGenerated.OnAdd`, including owned shadow keys |
|
||||
| Entity Framework Core could seed a new key with version 4 again | `NemeraDbContext` applies the generator to every `Guid` property configured with `ValueGenerated.OnAdd`, including owned shadow keys |
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
@@ -87,4 +87,4 @@ Migrate every stored primary key and foreign key to a version 7 value.
|
||||
|
||||
## Amendment: Relocation of the SYSTEM Audit Identity (2026-11-25)
|
||||
|
||||
The fixed SYSTEM audit identifier is no longer declared inline in `UpdateAuditableEntitiesInterceptor`. It is declared as the static readonly field `AuditIdentities.s_systemUserId` in `Lumina.Application/Common/DataAccess/Entities/Common/AuditIdentities.cs`. The identifier value and its behavior are unchanged.
|
||||
The fixed SYSTEM audit identifier is no longer declared inline in `UpdateAuditableEntitiesInterceptor`. It is declared as the static readonly field `AuditIdentities.s_systemUserId` in `Nemera.Application/Common/DataAccess/Entities/Common/AuditIdentities.cs`. The identifier value and its behavior are unchanged.
|
||||
Reference in new issue
Block a user