diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c6984a10d..23335f59c 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -13,8 +13,6 @@ - [ ] New features follow vertical-slice layout (Handler + Request + Response + Endpoint + Validator) - [ ] Cross-module behavior uses `ISender` or direct service/navigation calls as fits the feature slice - [ ] Domain operations return `Result` / `Result`, not exceptions -- [ ] `.harness/domains.yml` LOC counts are up-to-date for affected modules -- [ ] `AGENTS.md` is updated if conventions or structure changed ### Security diff --git a/.opencode/plans/2026-08-07-cross-module-contract-relocation.md b/.opencode/plans/2026-08-07-cross-module-contract-relocation.md deleted file mode 100644 index 5c7790e92..000000000 --- a/.opencode/plans/2026-08-07-cross-module-contract-relocation.md +++ /dev/null @@ -1,1017 +0,0 @@ -# Cross-Module Contract Relocation — Implementation Plan - -> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. - -**Goal:** Move 15 cross-module MediatR contracts from `Shared/Application/Contracts/` into module feature folders, remove `Contracts/` folder layer, delete 2 dead Catalog queries. - -**Architecture:** Each cross-module service becomes a feature folder following the `CreateOptionType` pattern (static partial class with Command/Query + Handler + Request/Response). Handlers already exist in module folders — we move the Command/Query/Response records alongside them and delete the Shared originals. - -**Tech Stack:** .NET 10, C#, MediatR, FluentValidation, Carter, EF Core + PostgreSQL - -## Global Constraints - -- All 9 modules share one `Module.csproj` assembly — no project references change -- `TreatWarningsAsErrors=true` — any warning fails build -- Domain error factories in `Module.{X}/Domain/{Entity}/{Entity}.Result.cs` — use existing errors, add new ones only if needed -- `Result` / `Result` patterns for all return types — no inline error strings -- Tests use xUnit + FluentAssertions + Moq + EF Core InMemory - ---- - -## File Structure - -### Files to CREATE (new) - -| Module | Path | Content | -|---|---|---| -| Inventory | `Features/Storefront/ReserveCartStock/ReserveCartStock.Command.cs` | `ReserveCartStockCommand` + `ReserveLineItem` records | -| Inventory | `Features/Storefront/ReserveCartStock/ReserveCartStock.Response.cs` | `ReserveCartStockResponse` record | -| Inventory | `Features/Storefront/ConsumeCartStockReservations/ConsumeCartStockReservations.Command.cs` | `ConsumeCartStockReservationsCommand` record | -| Inventory | `Features/Storefront/ReleaseCartStockReservations/ReleaseCartStockReservations.Command.cs` | `ReleaseCartStockReservationsCommand` record | -| Inventory | `Features/Storefront/CheckVariantAvailability/CheckVariantAvailability.Query.cs` | `CheckVariantAvailabilityQuery` record | -| Inventory | `Features/Storefront/CheckVariantAvailability/CheckVariantAvailability.Response.cs` | `CheckVariantAvailabilityResponse` record | -| Ordering | `Features/Storefront/GetCartForCheckout/GetCartForCheckout.Query.cs` | `GetCartForCheckoutQuery` record | -| Ordering | `Features/Storefront/GetCartForCheckout/GetCartForCheckout.Response.cs` | `GetCartForCheckoutResponse` + `CartLineItem` records | -| Ordering | `Features/Storefront/AdvanceCheckoutState/AdvanceCheckoutState.Command.cs` | `AdvanceCheckoutStateCommand` record | -| Ordering | `Features/Storefront/GetCartForShipping/GetCartForShipping.Query.cs` | `GetCartForShippingQuery` record | -| Ordering | `Features/Storefront/GetCartForShipping/GetCartForShipping.Response.cs` | `CartForShippingResponse` record | -| Payment | `Features/Storefront/GetPaymentForCheckout/GetPaymentForCheckout.Query.cs` | `GetPaymentForCheckoutQuery` record | -| Payment | `Features/Storefront/GetPaymentForCheckout/GetPaymentForCheckout.Response.cs` | `PaymentForCheckoutResponse` record | -| Payment | `Features/Storefront/MarkPaymentPaid/MarkPaymentPaid.Command.cs` | `MarkPaymentPaidCommand` record | -| Profile | `Features/Storefront/Profiles/Create/CreateProfile.Command.cs` | `CreateUserProfileCommand` + `CreateUserProfileResult` records | - -### Files to MOVE (handler + delete old location) - -| FROM | TO | -|---|---| -| `Inventory/.../Contracts/ReserveCartStock/ReserveCartStock.cs` | `Inventory/.../ReserveCartStock/ReserveCartStock.cs` | -| `Inventory/.../Contracts/ConsumeCartStockReservations/ConsumeCartStockReservations.cs` | `Inventory/.../ConsumeCartStockReservations/ConsumeCartStockReservations.cs` | -| `Inventory/.../Contracts/ReleaseCartStockReservations/ReleaseCartStockReservations.cs` | `Inventory/.../ReleaseCartStockReservations/ReleaseCartStockReservations.cs` | -| `Inventory/.../Contracts/CheckVariantAvailability/CheckVariantAvailability.cs` | `Inventory/.../CheckVariantAvailability/CheckVariantAvailability.cs` | -| `Ordering/.../Contracts/GetCartForCheckout/GetCartForCheckout.cs` | `Ordering/.../GetCartForCheckout/GetCartForCheckout.cs` | -| `Ordering/.../Contracts/AdvanceCheckoutState/AdvanceCheckoutState.cs` | `Ordering/.../AdvanceCheckoutState/AdvanceCheckoutState.cs` | -| `Ordering/.../Contracts/GetCartForShipping/GetCartForShipping.cs` | `Ordering/.../GetCartForShipping/GetCartForShipping.cs` | -| `Payment/.../Contracts/GetPaymentForCheckout/GetPaymentForCheckout.cs` | `Payment/.../GetPaymentForCheckout/GetPaymentForCheckout.cs` | -| `Payment/.../Contracts/MarkPaymentPaid/MarkPaymentPaid.cs` | `Payment/.../MarkPaymentPaid/MarkPaymentPaid.cs` | -| `Shared/.../Contracts/Inventory/IStockQuantityService.cs` | `Inventory/Services/Abstractions/IStockQuantityService.cs` | - -### Files to UPDATE (consumer using statements) - -| Module | File | -|---|---| -| Ordering | `Cart/Checkout/CreateOrderFromCart.cs` | -| Ordering | `Cart/AddItem/AddToCart.cs` | -| Ordering | `Cart/UpdateItemQuantity/UpdateCartItemQuantity.cs` | -| Ordering | `GetCartForShipping/GetCartForShipping.cs` | -| Payment | `Payment/CreateIntent/CreatePaymentIntent.cs` | -| Profile | `Addresses/Validators/Address.Validator.cs` | -| Identity | `Emails/Confirm/ConfirmEmail.cs` | -| Identity | `Auth/Login/External/Authenticate/ExternalAuthenticate.cs` | -| Inventory | 4 handler files (self-cleanup) | -| Ordering | 3 handler files (self-cleanup) | -| Payment | 2 handler files (self-cleanup) | -| Profile | 1 handler file (self-cleanup) | -| Location | 2 handler files (self-cleanup) | - -### Files to DELETE - -| File | Reason | -|---|---| -| `Shared/.../Contracts/Inventory/ConsumeCartStockReservationsCommand.cs` | Moved to Inventory module | -| `Shared/.../Contracts/Inventory/ReserveCartStockCommand.cs` | Moved to Inventory module | -| `Shared/.../Contracts/Inventory/ReleaseCartStockReservationsCommand.cs` | Moved to Inventory module | -| `Shared/.../Contracts/Inventory/CheckVariantAvailabilityQuery.cs` | Moved to Inventory module | -| `Shared/.../Contracts/Inventory/IStockQuantityService.cs` | Moved to Inventory module | -| `Shared/.../Contracts/Ordering/GetCartForCheckoutQuery.cs` | Moved to Ordering module | -| `Shared/.../Contracts/Ordering/AdvanceCheckoutStateCommand.cs` | Moved to Ordering module | -| `Shared/.../Contracts/Ordering/GetCartForShippingQuery.cs` | Moved to Ordering module | -| `Shared/.../Contracts/Payment/GetPaymentForCheckoutQuery.cs` | Moved to Payment module | -| `Shared/.../Contracts/Payment/MarkPaymentPaidCommand.cs` | Moved to Payment module | -| `Shared/.../Contracts/Profile/CreateUserProfileCommand.cs` | Moved to Profile module | -| `Shared/.../Contracts/Location/CountryExistsByIsoQuery.cs` | Moved into handler file | -| `Shared/.../Contracts/Location/StateExistsByIsoQuery.cs` | Moved into handler file | -| `Shared/.../Contracts/Catalog/GetVariantDiscontinuedStatusesQuery.cs` | Dead code — no handler | -| `Shared/.../Contracts/Catalog/GetVariantWeightsQuery.cs` | Dead code — no handler | -| `Shared/.../Contracts/Inventory/` (directory) | Empty after moves | -| `Shared/.../Contracts/Ordering/` (directory) | Empty after moves | -| `Shared/.../Contracts/Payment/` (directory) | Empty after moves | -| `Shared/.../Contracts/Profile/` (directory) | Empty after moves | -| `Shared/.../Contracts/Location/` (directory) | Empty after moves | -| `Shared/.../Contracts/Catalog/` (directory) | Empty after moves | - ---- - -## Task 1: Inventory — ReserveCartStock - -**Files:** -- Create: `Module/Inventory/Features/Storefront/ReserveCartStock/ReserveCartStock.Command.cs` -- Create: `Module/Inventory/Features/Storefront/ReserveCartStock/ReserveCartStock.Response.cs` -- Move: `Module/Inventory/Features/Storefront/Contracts/ReserveCartStock/ReserveCartStock.cs` → `Module/Inventory/Features/Storefront/ReserveCartStock/ReserveCartStock.cs` -- Delete: `Shared/Application/Contracts/Inventory/ReserveCartStockCommand.cs` - -- [ ] **Step 1: Create command file** - -Create `Module/Inventory/Features/Storefront/ReserveCartStock/ReserveCartStock.Command.cs`: - -```csharp -namespace Module.Inventory.Features.Storefront.Contracts.ReserveCartStock; - -public sealed record ReserveCartStockCommand : ICommand -{ - public Guid CartId { get; init; } - public IReadOnlyList LineItems { get; init; } = []; - public int TtlMinutes { get; init; } = 30; -} - -public sealed record ReserveLineItem -{ - public Guid VariantId { get; init; } - public int Quantity { get; init; } -} -``` - -Wait — namespace should NOT include `Contracts`. Fix: - -```csharp -namespace Module.Inventory.Features.Storefront.ReserveCartStock; - -public sealed record ReserveCartStockCommand : ICommand -{ - public Guid CartId { get; init; } - public IReadOnlyList LineItems { get; init; } = []; - public int TtlMinutes { get; init; } = 30; -} - -public sealed record ReserveLineItem -{ - public Guid VariantId { get; init; } - public int Quantity { get; init; } -} -``` - -- [ ] **Step 2: Create response file** - -Create `Module/Inventory/Features/Storefront/ReserveCartStock/ReserveCartStock.Response.cs`: - -```csharp -namespace Module.Inventory.Features.Storefront.ReserveCartStock; - -public sealed record ReserveCartStockResponse -{ - public IReadOnlyList ReservationIds { get; init; } = []; -} -``` - -- [ ] **Step 3: Move handler file** - -Move `Module/Inventory/Features/Storefront/Contracts/ReserveCartStock/ReserveCartStock.cs` to `Module/Inventory/Features/Storefront/ReserveCartStock/ReserveCartStock.cs`. - -Update namespace from `Module.Inventory.Features.Storefront.Contracts.ReserveCartStock` to `Module.Inventory.Features.Storefront.ReserveCartStock`. - -Remove `using Shared.Application.Contracts.Inventory;` — the types are now in the same namespace. - -- [ ] **Step 4: Delete old Shared contract** - -Delete `Shared/Application/Contracts/Inventory/ReserveCartStockCommand.cs`. - -- [ ] **Step 5: Build verification** - -Run: `dotnet build service/Api/src/Api` -Expected: PASS (consumers still reference old namespace — will fail, fix in Task 10) - -- [ ] **Step 6: Commit** - -```bash -git add -A -git commit -m "refactor(inventory): move ReserveCartStock from Shared to feature folder" -``` - ---- - -## Task 2: Inventory — ConsumeCartStockReservations - -**Files:** -- Create: `Module/Inventory/Features/Storefront/ConsumeCartStockReservations/ConsumeCartStockReservations.Command.cs` -- Move: `Module/Inventory/Features/Storefront/Contracts/ConsumeCartStockReservations/ConsumeCartStockReservations.cs` → `Module/Inventory/Features/Storefront/ConsumeCartStockReservations/ConsumeCartStockReservations.cs` -- Delete: `Shared/Application/Contracts/Inventory/ConsumeCartStockReservationsCommand.cs` - -- [x] **Step 1: Create command file** - -Create `Module/Inventory/Features/Storefront/ConsumeCartStockReservations/ConsumeCartStockReservations.Command.cs`: - -```csharp -namespace Module.Inventory.Features.Storefront.ConsumeCartStockReservations; - -public sealed record ConsumeCartStockReservationsCommand : ICommand -{ - public Guid CartId { get; init; } -} -``` - -- [x] **Step 2: Move handler file** - -Move `Module/Inventory/Features/Storefront/Contracts/ConsumeCartStockReservations/ConsumeCartStockReservations.cs` to `Module/Inventory/Features/Storefront/ConsumeCartStockReservations/ConsumeCartStockReservations.cs`. - -Update namespace to `Module.Inventory.Features.Storefront.ConsumeCartStockReservations`. - -Remove `using Shared.Application.Contracts.Inventory;`. - -- [x] **Step 3: Delete old Shared contract** - -Delete `Shared/Application/Contracts/Inventory/ConsumeCartStockReservationsCommand.cs`. - -- [x] **Step 4: Commit** - -```bash -git add -A -git commit -m "refactor(inventory): move ConsumeCartStockReservations from Shared to feature folder" -``` - ---- - -## Task 3: Inventory — ReleaseCartStockReservations - -**Files:** -- Create: `Module/Inventory/Features/Storefront/ReleaseCartStockReservations/ReleaseCartStockReservations.Command.cs` -- Move: `Module/Inventory/Features/Storefront/Contracts/ReleaseCartStockReservations/ReleaseCartStockReservations.cs` → `Module/Inventory/Features/Storefront/ReleaseCartStockReservations/ReleaseCartStockReservations.cs` -- Delete: `Shared/Application/Contracts/Inventory/ReleaseCartStockReservationsCommand.cs` - -- [ ] **Step 1: Create command file** - -Create `Module/Inventory/Features/Storefront/ReleaseCartStockReservations/ReleaseCartStockReservations.Command.cs`: - -```csharp -namespace Module.Inventory.Features.Storefront.ReleaseCartStockReservations; - -public sealed record ReleaseCartStockReservationsCommand : ICommand -{ - public Guid CartId { get; init; } -} -``` - -- [ ] **Step 2: Move handler file** - -Move `Module/Inventory/Features/Storefront/Contracts/ReleaseCartStockReservations/ReleaseCartStockReservations.cs` to `Module/Inventory/Features/Storefront/ReleaseCartStockReservations/ReleaseCartStockReservations.cs`. - -Update namespace to `Module.Inventory.Features.Storefront.ReleaseCartStockReservations`. - -Remove `using Shared.Application.Contracts.Inventory;`. - -- [ ] **Step 3: Delete old Shared contract** - -Delete `Shared/Application/Contracts/Inventory/ReleaseCartStockReservationsCommand.cs`. - -- [ ] **Step 4: Commit** - -```bash -git add -A -git commit -m "refactor(inventory): move ReleaseCartStockReservations from Shared to feature folder" -``` - ---- - -## Task 4: Inventory — CheckVariantAvailability - -**Files:** -- Create: `Module/Inventory/Features/Storefront/CheckVariantAvailability/CheckVariantAvailability.Query.cs` -- Create: `Module/Inventory/Features/Storefront/CheckVariantAvailability/CheckVariantAvailability.Response.cs` -- Move: `Module/Inventory/Features/Storefront/Contracts/CheckVariantAvailability/CheckVariantAvailability.cs` → `Module/Inventory/Features/Storefront/CheckVariantAvailability/CheckVariantAvailability.cs` -- Delete: `Shared/Application/Contracts/Inventory/CheckVariantAvailabilityQuery.cs` - -- [ ] **Step 1: Create query file** - -Create `Module/Inventory/Features/Storefront/CheckVariantAvailability/CheckVariantAvailability.Query.cs`: - -```csharp -namespace Module.Inventory.Features.Storefront.CheckVariantAvailability; - -public sealed record CheckVariantAvailabilityQuery(Guid VariantId, int Quantity) - : IQuery; -``` - -- [ ] **Step 2: Create response file** - -Create `Module/Inventory/Features/Storefront/CheckVariantAvailability/CheckVariantAvailability.Response.cs`: - -```csharp -namespace Module.Inventory.Features.Storefront.CheckVariantAvailability; - -public sealed record CheckVariantAvailabilityResponse -{ - public Guid VariantId { get; init; } - public bool IsAvailable { get; init; } -} -``` - -- [ ] **Step 3: Move handler file** - -Move `Module/Inventory/Features/Storefront/Contracts/CheckVariantAvailability/CheckVariantAvailability.cs` to `Module/Inventory/Features/Storefront/CheckVariantAvailability/CheckVariantAvailability.cs`. - -Update namespace to `Module.Inventory.Features.Storefront.CheckVariantAvailability`. - -Remove `using Shared.Application.Contracts.Inventory;`. - -- [ ] **Step 4: Delete old Shared contract** - -Delete `Shared/Application/Contracts/Inventory/CheckVariantAvailabilityQuery.cs`. - -- [ ] **Step 5: Commit** - -```bash -git add -A -git commit -m "refactor(inventory): move CheckVariantAvailability from Shared to feature folder" -``` - ---- - -## Task 5: Inventory — IStockQuantityService + Delete Contracts - -**Files:** -- Move: `Shared/Application/Contracts/Inventory/IStockQuantityService.cs` → `Module/Inventory/Services/Abstractions/IStockQuantityService.cs` -- Delete: `Module/Inventory/Features/Storefront/Contracts/` (entire directory) - -- [ ] **Step 1: Move interface** - -Move `Shared/Application/Contracts/Inventory/IStockQuantityService.cs` to `Module/Inventory/Services/Abstractions/IStockQuantityService.cs`. - -Update namespace from `Shared.Application.Contracts.Inventory` to `Module.Inventory.Services.Abstractions`. - -- [ ] **Step 2: Delete Contracts/ directory** - -```bash -rm -rf service/Api/src/Module/Inventory/Features/Storefront/Contracts/ -``` - -- [ ] **Step 3: Build verification** - -Run: `dotnet build service/Api/src/Module` -Expected: PASS (consumers still reference old namespace — will fail at Api level, fix in Task 10) - -- [ ] **Step 4: Commit** - -```bash -git add -A -git commit -m "refactor(inventory): move IStockQuantityService to Services/Abstractions, delete Contracts/" -``` - ---- - -## Task 6: Ordering — GetCartForCheckout - -**Files:** -- Create: `Module/Ordering/Features/Storefront/GetCartForCheckout/GetCartForCheckout.Query.cs` -- Create: `Module/Ordering/Features/Storefront/GetCartForCheckout/GetCartForCheckout.Response.cs` -- Move: `Module/Ordering/Features/Storefront/Contracts/GetCartForCheckout/GetCartForCheckout.cs` → `Module/Ordering/Features/Storefront/GetCartForCheckout/GetCartForCheckout.cs` -- Delete: `Shared/Application/Contracts/Ordering/GetCartForCheckoutQuery.cs` - -- [ ] **Step 1: Create query file** - -Create `Module/Ordering/Features/Storefront/GetCartForCheckout/GetCartForCheckout.Query.cs`: - -```csharp -namespace Module.Ordering.Features.Storefront.GetCartForCheckout; - -public sealed record GetCartForCheckoutQuery : IQuery -{ - public Guid CartId { get; init; } -} -``` - -- [ ] **Step 2: Create response file** - -Create `Module/Ordering/Features/Storefront/GetCartForCheckout/GetCartForCheckout.Response.cs`: - -```csharp -namespace Module.Ordering.Features.Storefront.GetCartForCheckout; - -public sealed record GetCartForCheckoutResponse -{ - public string State { get; init; } = default!; - public IReadOnlyList LineItems { get; init; } = []; - public decimal Total { get; init; } - public string? Email { get; init; } -} - -public sealed record CartLineItem -{ - public Guid VariantId { get; init; } - public int Quantity { get; init; } -} -``` - -- [ ] **Step 3: Move handler file** - -Move `Module/Ordering/Features/Storefront/Contracts/GetCartForCheckout/GetCartForCheckout.cs` to `Module/Ordering/Features/Storefront/GetCartForCheckout/GetCartForCheckout.cs`. - -Update namespace to `Module.Ordering.Features.Storefront.GetCartForCheckout`. - -Remove `using Shared.Application.Contracts.Ordering;`. - -- [ ] **Step 4: Delete old Shared contract** - -Delete `Shared/Application/Contracts/Ordering/GetCartForCheckoutQuery.cs`. - -- [ ] **Step 5: Commit** - -```bash -git add -A -git commit -m "refactor(ordering): move GetCartForCheckout from Shared to feature folder" -``` - ---- - -## Task 7: Ordering — AdvanceCheckoutState - -**Files:** -- Create: `Module/Ordering/Features/Storefront/AdvanceCheckoutState/AdvanceCheckoutState.Command.cs` -- Move: `Module/Ordering/Features/Storefront/Contracts/AdvanceCheckoutState/AdvanceCheckoutState.cs` → `Module/Ordering/Features/Storefront/AdvanceCheckoutState/AdvanceCheckoutState.cs` -- Delete: `Shared/Application/Contracts/Ordering/AdvanceCheckoutStateCommand.cs` - -- [ ] **Step 1: Create command file** - -Create `Module/Ordering/Features/Storefront/AdvanceCheckoutState/AdvanceCheckoutState.Command.cs`: - -```csharp -namespace Module.Ordering.Features.Storefront.AdvanceCheckoutState; - -public sealed record AdvanceCheckoutStateCommand : ICommand -{ - public Guid CartId { get; init; } - public string TargetState { get; init; } = default!; -} -``` - -- [ ] **Step 2: Move handler file** - -Move `Module/Ordering/Features/Storefront/Contracts/AdvanceCheckoutState/AdvanceCheckoutState.cs` to `Module/Ordering/Features/Storefront/AdvanceCheckoutState/AdvanceCheckoutState.cs`. - -Update namespace to `Module.Ordering.Features.Storefront.AdvanceCheckoutState`. - -Remove `using Shared.Application.Contracts.Ordering;`. - -- [ ] **Step 3: Delete old Shared contract** - -Delete `Shared/Application/Contracts/Ordering/AdvanceCheckoutStateCommand.cs`. - -- [ ] **Step 4: Commit** - -```bash -git add -A -git commit -m "refactor(ordering): move AdvanceCheckoutState from Shared to feature folder" -``` - ---- - -## Task 8: Ordering — GetCartForShipping + Delete Contracts - -**Files:** -- Create: `Module/Ordering/Features/Storefront/GetCartForShipping/GetCartForShipping.Query.cs` -- Create: `Module/Ordering/Features/Storefront/GetCartForShipping/GetCartForShipping.Response.cs` -- Move: `Module/Ordering/Features/Storefront/Contracts/GetCartForShipping/GetCartForShipping.cs` → `Module/Ordering/Features/Storefront/GetCartForShipping/GetCartForShipping.cs` -- Delete: `Shared/Application/Contracts/Ordering/GetCartForShippingQuery.cs` -- Delete: `Module/Ordering/Features/Storefront/Contracts/` (entire directory) - -- [ ] **Step 1: Create query file** - -Create `Module/Ordering/Features/Storefront/GetCartForShipping/GetCartForShipping.Query.cs`: - -```csharp -namespace Module.Ordering.Features.Storefront.GetCartForShipping; - -public sealed record GetCartForShippingQuery(Guid CartId) : IQuery; -``` - -- [ ] **Step 2: Create response file** - -Create `Module/Ordering/Features/Storefront/GetCartForShipping/GetCartForShipping.Response.cs`: - -```csharp -namespace Module.Ordering.Features.Storefront.GetCartForShipping; - -public sealed record CartForShippingResponse -{ - public decimal TotalWeight { get; init; } - public decimal TotalValue { get; init; } - public Guid? ShipAddressId { get; init; } - public string Currency { get; init; } = default!; -} -``` - -- [ ] **Step 3: Move handler file and rewrite weight calculation** - -Move `Module/Ordering/Features/Storefront/Contracts/GetCartForShipping/GetCartForShipping.cs` to `Module/Ordering/Features/Storefront/GetCartForShipping/GetCartForShipping.cs`. - -Update namespace to `Module.Ordering.Features.Storefront.GetCartForShipping`. - -Remove `using Shared.Application.Contracts.Ordering;` and `using Shared.Application.Contracts.Catalog;`. - -Replace the MediatR weights query (lines 25-28) with direct DB query: - -```csharp -var variantWeights = await dbContext.Set() - .Where(v => variantIds.Contains(v.Id)) - .Select(v => new { v.Id, v.Weight }) - .ToListAsync(cancellationToken); -var weightMap = variantWeights.ToDictionary(v => v.Id, v => v.Weight ?? 0m); -``` - -- [ ] **Step 4: Delete old Shared contract and Contracts/ directory** - -Delete `Shared/Application/Contracts/Ordering/GetCartForShippingQuery.cs`. - -```bash -rm -rf service/Api/src/Module/Ordering/Features/Storefront/Contracts/ -``` - -- [ ] **Step 5: Commit** - -```bash -git add -A -git commit -m "refactor(ordering): move GetCartForShipping, rewrite weight calc, delete Contracts/" -``` - ---- - -## Task 9: Payment — GetPaymentForCheckout - -**Files:** -- Create: `Module/Payment/Features/Storefront/GetPaymentForCheckout/GetPaymentForCheckout.Query.cs` -- Create: `Module/Payment/Features/Storefront/GetPaymentForCheckout/GetPaymentForCheckout.Response.cs` -- Move: `Module/Payment/Features/Storefront/Contracts/GetPaymentForCheckout/GetPaymentForCheckout.cs` → `Module/Payment/Features/Storefront/GetPaymentForCheckout/GetPaymentForCheckout.cs` -- Delete: `Shared/Application/Contracts/Payment/GetPaymentForCheckoutQuery.cs` - -- [ ] **Step 1: Create query file** - -Create `Module/Payment/Features/Storefront/GetPaymentForCheckout/GetPaymentForCheckout.Query.cs`: - -```csharp -namespace Module.Payment.Features.Storefront.GetPaymentForCheckout; - -public sealed record GetPaymentForCheckoutQuery : IQuery -{ - public string PaymentIntentId { get; init; } = default!; - public Guid OrderId { get; init; } -} -``` - -- [ ] **Step 2: Create response file** - -Create `Module/Payment/Features/Storefront/GetPaymentForCheckout/GetPaymentForCheckout.Response.cs`: - -```csharp -namespace Module.Payment.Features.Storefront.GetPaymentForCheckout; - -public sealed record PaymentForCheckoutResponse -{ - public decimal Amount { get; init; } - public bool IsCompleted { get; init; } -} -``` - -- [ ] **Step 3: Move handler file** - -Move `Module/Payment/Features/Storefront/Contracts/GetPaymentForCheckout/GetPaymentForCheckout.cs` to `Module/Payment/Features/Storefront/GetPaymentForCheckout/GetPaymentForCheckout.cs`. - -Update namespace to `Module.Payment.Features.Storefront.GetPaymentForCheckout`. - -Remove `using Shared.Application.Contracts.Payment;`. - -- [ ] **Step 4: Delete old Shared contract** - -Delete `Shared/Application/Contracts/Payment/GetPaymentForCheckoutQuery.cs`. - -- [ ] **Step 5: Commit** - -```bash -git add -A -git commit -m "refactor(payment): move GetPaymentForCheckout from Shared to feature folder" -``` - ---- - -## Task 10: Payment — MarkPaymentPaid + Delete Contracts - -**Files:** -- Create: `Module/Payment/Features/Storefront/MarkPaymentPaid/MarkPaymentPaid.Command.cs` -- Move: `Module/Payment/Features/Storefront/Contracts/MarkPaymentPaid/MarkPaymentPaid.cs` → `Module/Payment/Features/Storefront/MarkPaymentPaid/MarkPaymentPaid.cs` -- Delete: `Shared/Application/Contracts/Payment/MarkPaymentPaidCommand.cs` -- Delete: `Module/Payment/Features/Storefront/Contracts/` (entire directory) - -- [ ] **Step 1: Create command file** - -Create `Module/Payment/Features/Storefront/MarkPaymentPaid/MarkPaymentPaid.Command.cs`: - -```csharp -namespace Module.Payment.Features.Storefront.MarkPaymentPaid; - -public sealed record MarkPaymentPaidCommand : ICommand -{ - public Guid OrderId { get; init; } - public string PaymentIntentId { get; init; } = default!; -} -``` - -- [ ] **Step 2: Move handler file** - -Move `Module/Payment/Features/Storefront/Contracts/MarkPaymentPaid/MarkPaymentPaid.cs` to `Module/Payment/Features/Storefront/MarkPaymentPaid/MarkPaymentPaid.cs`. - -Update namespace to `Module.Payment.Features.Storefront.MarkPaymentPaid`. - -Remove `using Shared.Application.Contracts.Payment;`. - -- [ ] **Step 3: Delete old Shared contract and Contracts/ directory** - -Delete `Shared/Application/Contracts/Payment/MarkPaymentPaidCommand.cs`. - -```bash -rm -rf service/Api/src/Module/Payment/Features/Storefront/Contracts/ -``` - -- [ ] **Step 4: Commit** - -```bash -git add -A -git commit -m "refactor(payment): move MarkPaymentPaid, delete Contracts/" -``` - ---- - -## Task 11: Catalog — Delete Dead Queries - -**Files:** -- Delete: `Shared/Application/Contracts/Catalog/GetVariantDiscontinuedStatusesQuery.cs` -- Delete: `Shared/Application/Contracts/Catalog/GetVariantWeightsQuery.cs` -- Delete: `Shared/Application/Contracts/Catalog/` (directory) -- Update: `Module/Ordering/.../Cart/Checkout/CreateOrderFromCart.cs` - -- [ ] **Step 1: Delete query contracts** - -```bash -rm service/Api/src/Shared/Application/Contracts/Catalog/GetVariantDiscontinuedStatusesQuery.cs -rm service/Api/src/Shared/Application/Contracts/Catalog/GetVariantWeightsQuery.cs -rmdir service/Api/src/Shared/Application/Contracts/Catalog/ -``` - -- [ ] **Step 2: Remove discontinued check from CreateOrderFromCart** - -In `Module/Ordering/Features/Storefront/Cart/Checkout/CreateOrderFromCart.cs`: - -Remove `using Shared.Application.Contracts.Catalog;` - -Remove the entire block (lines ~66-78): -```csharp -// Validate: Reject orders containing discontinued variants via ISender. -var variantIds = cart.LineItems.Select(li => li.VariantId).ToList(); -var discResult = await sender.Send(new GetVariantDiscontinuedStatusesQuery { VariantIds = variantIds }, cancellationToken); -if (discResult.IsFailure) - return discResult.Errors; - -var discontinuedVariantIds = discResult.Value! - .Where(kvp => kvp.Value) - .Select(kvp => kvp.Key) - .ToHashSet(); - -if (!cart.EnsureLineItemVariantsAreNotDiscontinued(discontinuedVariantIds)) - return OrderResult.Errors.VariantDiscontinued; -``` - -- [ ] **Step 3: Commit** - -```bash -git add -A -git commit -m "refactor(catalog): delete dead GetVariantDiscontinuedStatusesQuery and GetVariantWeightsQuery" -``` - ---- - -## Task 12: Profile — Move Command into CreateProfile - -**Files:** -- Create: `Module/Profile/Features/Storefront/Profiles/Create/CreateProfile.Command.cs` -- Update: `Module/Profile/Features/Storefront/Profiles/Create/CreateProfile.cs` -- Delete: `Shared/Application/Contracts/Profile/CreateUserProfileCommand.cs` - -- [ ] **Step 1: Create command file** - -Create `Module/Profile/Features/Storefront/Profiles/Create/CreateProfile.Command.cs`: - -```csharp -namespace Module.Profile.Features.Storefront.Profiles.Create; - -public sealed record CreateUserProfileCommand : ICommand -{ - public Guid UserId { get; init; } - public string FirstName { get; init; } = default!; - public string? LastName { get; init; } - public string Email { get; init; } = default!; -} - -public sealed record CreateUserProfileResult -{ - public Guid ProfileId { get; init; } -} -``` - -- [ ] **Step 2: Update CreateProfile.cs** - -In `Module/Profile/Features/Storefront/Profiles/Create/CreateProfile.cs`: - -Remove `using Shared.Application.Contracts.Profile;` - -- [ ] **Step 3: Delete old Shared contract** - -Delete `Shared/Application/Contracts/Profile/CreateUserProfileCommand.cs`. - -- [ ] **Step 4: Commit** - -```bash -git add -A -git commit -m "refactor(profile): move CreateUserProfileCommand into CreateProfile feature" -``` - ---- - -## Task 13: Location — Move Queries into Handler Files - -**Files:** -- Update: `Module/Location/Features/Shared/Queries/CountryExistsByIsoHandler.cs` -- Update: `Module/Location/Features/Shared/Queries/StateExistsByIsoHandler.cs` -- Delete: `Shared/Application/Contracts/Location/CountryExistsByIsoQuery.cs` -- Delete: `Shared/Application/Contracts/Location/StateExistsByIsoQuery.cs` -- Delete: `Shared/Application/Contracts/Location/` (directory) - -- [ ] **Step 1: Add query record to CountryExistsByIsoHandler** - -In `Module/Location/Features/Shared/Queries/CountryExistsByIsoHandler.cs`: - -Add before the handler class: - -```csharp -public sealed record CountryExistsByIsoQuery(string IsoCode) : IQuery; -``` - -Remove `using Shared.Application.Contracts.Location;`. - -- [ ] **Step 2: Add query record to StateExistsByIsoHandler** - -In `Module/Location/Features/Shared/Queries/StateExistsByIsoHandler.cs`: - -Add before the handler class: - -```csharp -public sealed record StateExistsByIsoQuery(string CountryCode, string StateCode) : IQuery; -``` - -Remove `using Shared.Application.Contracts.Location;`. - -- [ ] **Step 3: Delete old Shared contracts and directory** - -```bash -rm service/Api/src/Shared/Application/Contracts/Location/CountryExistsByIsoQuery.cs -rm service/Api/src/Shared/Application/Contracts/Location/StateExistsByIsoQuery.cs -rmdir service/Api/src/Shared/Application/Contracts/Location/ -``` - -- [ ] **Step 4: Commit** - -```bash -git add -A -git commit -m "refactor(location): move query records into handler files, delete Contracts/" -``` - ---- - -## Task 14: Update All Consumer Using Statements - -This task updates every file that references the old `Shared.Application.Contracts.*` namespaces. Execute in order by module. - -- [ ] **Step 1: Update Inventory consumers (self-cleanup)** - -Update these 4 handler files — remove `using Shared.Application.Contracts.Inventory;`: -- `Module/Inventory/Features/Storefront/ConsumeCartStockReservations/ConsumeCartStockReservations.cs` -- `Module/Inventory/Features/Storefront/ReserveCartStock/ReserveCartStock.cs` -- `Module/Inventory/Features/Storefront/ReleaseCartStockReservations/ReleaseCartStockReservations.cs` -- `Module/Inventory/Features/Storefront/CheckVariantAvailability/CheckVariantAvailability.cs` - -- [ ] **Step 2: Update Ordering consumers** - -`Module/Ordering/.../Cart/Checkout/CreateOrderFromCart.cs`: -```csharp -// Remove: -using Shared.Application.Contracts.Catalog; -using Shared.Application.Contracts.Inventory; -using Shared.Application.Contracts.Payment; - -// Add: -using Module.Inventory.Features.Storefront.ConsumeCartStockReservations; -using Module.Payment.Features.Storefront.GetPaymentForCheckout; -using Module.Payment.Features.Storefront.MarkPaymentPaid; -``` - -`Module/Ordering/.../Cart/AddItem/AddToCart.cs`: -```csharp -// Remove: -using Shared.Application.Contracts.Inventory; - -// Add: -using Module.Inventory.Features.Storefront.ReserveCartStock; -``` - -`Module/Ordering/.../Cart/UpdateItemQuantity/UpdateCartItemQuantity.cs`: -```csharp -// Remove: -using Shared.Application.Contracts.Inventory; - -// Add: -using Module.Inventory.Features.Storefront.CheckVariantAvailability; -``` - -`Module/Ordering/.../GetCartForShipping/GetCartForShipping.cs`: -```csharp -// Remove: -using Shared.Application.Contracts.Catalog; -using Shared.Application.Contracts.Ordering; - -// (no new usings needed — Query/Response are in same namespace) -``` - -- [ ] **Step 3: Update Payment consumer** - -`Module/Payment/.../Payment/CreateIntent/CreatePaymentIntent.cs`: -```csharp -// Remove: -using Shared.Application.Contracts.Ordering; -using Shared.Application.Contracts.Inventory; - -// Add: -using Module.Inventory.Features.Storefront.ReserveCartStock; -using Module.Inventory.Features.Storefront.ReleaseCartStockReservations; -using Module.Ordering.Features.Storefront.GetCartForCheckout; -using Module.Ordering.Features.Storefront.AdvanceCheckoutState; -``` - -- [ ] **Step 4: Update Profile consumer** - -`Module/Profile/.../Addresses/Validators/Address.Validator.cs`: -```csharp -// Remove: -// (uses Shared.Application.Contracts.Location indirectly via sender.Send) - -// Add: -using Module.Location.Features.Shared.Queries; -``` - -- [ ] **Step 5: Update Identity consumers** - -`Module/Identity/.../Emails/Confirm/ConfirmEmail.cs`: -```csharp -// Remove: -using Shared.Application.Contracts.Profile; - -// Add: -using Module.Profile.Features.Storefront.Profiles.Create; -``` - -`Module/Identity/.../Auth/Login/External/Authenticate/ExternalAuthenticate.cs`: -```csharp -// Remove: -using Shared.Application.Contracts.Profile; - -// Add: -using Module.Profile.Features.Storefront.Profiles.Create; -``` - -- [ ] **Step 6: Build verification** - -Run: `dotnet build service/Api/src/Api` -Expected: PASS with 0 warnings - -- [ ] **Step 7: Commit** - -```bash -git add -A -git commit -m "refactor: update all consumer using statements for relocated contracts" -``` - ---- - -## Task 15: Update Test Files - -- [ ] **Step 1: Update CreateOrderFromCartTransactionTests.cs** - -Remove `using Shared.Application.Contracts.Catalog;` and `using Shared.Application.Contracts.Inventory;` and `using Shared.Application.Contracts.Payment;`. - -Add: -```csharp -using Module.Inventory.Features.Storefront.ConsumeCartStockReservations; -using Module.Payment.Features.Storefront.GetPaymentForCheckout; -using Module.Payment.Features.Storefront.MarkPaymentPaid; -``` - -Remove the `GetVariantDiscontinuedStatusesQuery` mock setup (line ~57). - -- [ ] **Step 2: Update CreateOrderFromCartTests.cs** - -Same using changes as Step 1. - -Remove `GetVariantDiscontinuedStatusesQuery` mock setups (lines ~62, ~243). - -- [ ] **Step 3: Update CreateOrderFromCartStockTests.cs** - -Same using changes as Step 1. - -Remove `GetVariantDiscontinuedStatusesQuery` mock setup (line ~54). - -- [ ] **Step 4: Update AddToCart test files** - -`AddToCartTests.cs`, `AddToCartDefaultsTests.cs`, `AddToCart.Reservation.Tests.cs`: - -Replace `using Shared.Application.Contracts.Inventory;` with `using Module.Inventory.Features.Storefront.ReserveCartStock;`. - -- [ ] **Step 5: Update UpdateCartItemQuantity.Tests.cs** - -Replace `using Shared.Application.Contracts.Inventory;` with `using Module.Inventory.Features.Storefront.CheckVariantAvailability;`. - -- [ ] **Step 6: Update CreatePaymentIntentTests.cs** - -Replace: -```csharp -using Shared.Application.Contracts.Ordering; -using Shared.Application.Contracts.Inventory; -``` -With: -```csharp -using Module.Ordering.Features.Storefront.GetCartForCheckout; -using Module.Ordering.Features.Storefront.AdvanceCheckoutState; -using Module.Inventory.Features.Storefront.ReserveCartStock; -using Module.Inventory.Features.Storefront.ReleaseCartStockReservations; -``` - -- [ ] **Step 7: Update remaining test files** - -`UpdateOrderStatusTests.cs`: Replace `using Shared.Application.Contracts.Inventory;` with `using Module.Inventory.Services.Abstractions;` - -`EventHandlerInvocationTests.cs`: Same as above. - -`CheckVariantAvailability.Tests.cs`: Replace with `using Module.Inventory.Features.Storefront.CheckVariantAvailability;` - -`CalculateShippingHandlerTests.cs`: Replace `using Shared.Application.Contracts.{Catalog,Ordering};` with `using Module.Ordering.Features.Storefront.GetCartForShipping;` - -`ExistsByIsoQueryTests.cs`: Replace with `using Module.Location.Features.Shared.Queries;` - -`ConfirmEmail.Tests.cs`, `ExternalAuthenticate.Tests.cs`, `ExternalAuthenticateProfileCreationTests.cs`: Replace `using Shared.Application.Contracts.Profile;` with `using Module.Profile.Features.Storefront.Profiles.Create;` - -- [ ] **Step 8: Build and test** - -Run: `dotnet build service/Api/src/Api` -Run: `dotnet test service/Api/tests/Module.UnitTests` -Expected: All PASS - -- [ ] **Step 9: Commit** - -```bash -git add -A -git commit -m "refactor: update test using statements for relocated contracts" -``` - ---- - -## Task 16: Final Cleanup and Verification - -- [ ] **Step 1: Delete remaining Shared Contracts directories** - -```bash -rmdir service/Api/src/Shared/Application/Contracts/Inventory/ 2>/dev/null || true -rmdir service/Api/src/Shared/Application/Contracts/Ordering/ 2>/dev/null || true -rmdir service/Api/src/Shared/Application/Contracts/Payment/ 2>/dev/null || true -rmdir service/Api/src/Shared/Application/Contracts/Profile/ 2>/dev/null || true -rmdir service/Api/src/Shared/Application/Contracts/Location/ 2>/dev/null || true -rmdir service/Api/src/Shared/Application/Contracts/Catalog/ 2>/dev/null || true -``` - -- [ ] **Step 2: Update cross-module baseline** - -In `scripts/check-cross-module-refs.sh`, update `EXPECTED_BASELINE` to reflect the new count (run the script first to see the actual count). - -- [ ] **Step 3: Full build verification** - -Run: `dotnet build service/Api/src/Api` -Expected: 0 warnings, 0 errors - -- [ ] **Step 4: Full test verification** - -Run: `dotnet test service/Api/tests/Module.UnitTests` -Run: `dotnet test service/Api/tests/Shared.UnitTests` -Expected: All PASS - -- [ ] **Step 5: Cross-module check** - -Run: `bash scripts/check-cross-module-refs.sh` -Expected: Baseline updated, no new violations - -- [ ] **Step 6: Commit** - -```bash -git add -A -git commit -m "chore: cleanup empty Shared/Contracts directories, update cross-module baseline" -``` diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index ff2245f43..000000000 --- a/AGENTS.md +++ /dev/null @@ -1,82 +0,0 @@ -# ReSys.Shop — Agent Guide - -ReSys.Shop e-commerce platform — .NET 10 modular monolith with Vue 3 frontends -and Python ML sidecar. Agents work C#, TypeScript, Python; all service -components start via Aspire orchestration. See `.harness/` for machine-readable -domain boundaries, principles, quality baselines. - -## Non-Negotiable Rules - -1. **Result objects, not exceptions** — all domain operations return `Result` or `Result`. Exceptions only for unrecoverable infrastructure failures. -2. **Modules share one assembly and may reference each other; behavior may use MediatR `ISender` or direct calls** — all 9 business modules (Catalog, Identity, Inventory, Location, Ordering, Payment, Profile, Shipping, Dashboard) live in one `Module` assembly. Cross-module `using` statements, EF Core FK relationships, navigations, and direct service calls are all permitted (no whitelist, no drift check — removed 2026-08-16). For behavior, prefer MediatR `ISender` when dispatching work to another module so it flows through the pipeline (validation, logging, transaction); call services or navigate relationships directly when that fits the feature slice. - - **TODO (replace the ISender convention):** the `ISender`-for-behavior convention is retained for now but is itself under review. Proposal options to replace it (see `brainstorming` skill): (a) keep `ISender` as-is, (b) direct cross-module service calls where the type is already referenced, (c) a module gateway/facade layer, (d) splitting modules into separate assemblies with explicit ProjectReferences. Run `/brainstorming` before choosing. - - **Replacement candidates (audited 2026-08-16):** navigations fit where `Order` is the hub — `GetPaymentForCheckout`/`GetCartForCheckout`/`GetCartForShipping` → load `Order` + `LineItems`/`PaymentCaptures` via `.Include`/direct nav; `MarkPaymentPaid` → `payment.Complete()` on the nav-loaded capture; `RecordOrderPaymentState` → `order.MarkPayment{Completed|Failed|Processing}`; `AdvanceCheckoutState`/`RegressCheckoutState` → `order.AdvanceCheckoutState()`/`Regress*`. Direct service calls fit where a foreign aggregate is created: `CreateShipment` (→ Shipping service), `CreateUserProfile` (→ Customer profile service). Keep `ISender` (pipeline/retry/transaction value): `VoidOrderPayments`, `CompleteCheckoutForPayment`. -3. **Vertical slice feature files** — every C# feature action is `static partial class` split across files in `Features/{Admin|Storefront}/{Feature}/{Action}/`, each with Handler, Request, Response, Endpoint, Validator. Subdirectory always `Storefront` (not `Store`). Read-only queries may omit Request/Validator files. -4. **Warnings-as-errors** — `TreatWarningsAsErrors=true` globally. Any warning fails build. -5. **Forward-only dependency** — `Shared` depends on nothing within `service/`. `Module` depends only on `Shared`. `Api` composes both. -6. **NO git stash / worktree / revert / restore / checkout -- without human permission** — never run `git stash`, `git checkout -- `, `git restore`, `git revert`, `git reset --hard`, or any command that moves/rewrites/loses working-tree changes, unless the human explicitly asked for it and you got an explicit "yes" to run that specific command. If your tooling or hooks auto-stash or reset the working tree, STOP and report it immediately — do not silently continue. Recover lost changes only after the human confirms. Uncommitted work is precious and irreplaceable. - -## Repository Map - -- `.harness/domains.yml` — 8 business domains + infrastructure + UI domains with layer maps -- `.harness/principles.yml` — golden principles with rationale and enforcement -- `.harness/enforcement.yml` — naming, file limits, logging, import rules -- `.harness/quality.yml` — per-domain quality scores (6 dimensions) -- `docs/codebase/ARCHITECTURE.md` — detailed architecture, layer responsibilities, data flow -- `docs/codebase/STACK.md` — full framework versions and toolchain -- `docs/codebase/CONCERNS.md` — tech debt, risks, security concerns -- `docs/codebase/CONVENTIONS.md` — coding conventions -- `docs/codebase/TESTING.md` — testing strategy -- `docs/codebase/PROCESS.md` — doc-gardening, GC, feedback encoding, escalation boundaries -- `docs/failures/` — failure memory: known incidents -- `plan/` — implementation plans (currently consolidating README docs across modules) -- `guide/code-commenting/CommentingRules.xml` — comment convention rules -- `Directory.Packages.props` — central NuGet package versions -- `scripts/check-feature-conventions.sh` — feature file AC-001/002/003/005 drift checks - -## Tech Stack - -- .NET 10 (C# preview), Vue 3 + TypeScript 6, Python 3.12 -- EF Core + Npgsql + pgvector, Carter minimal APIs, MediatR CQRS, FluentValidation, Mapster -- HybridCache + Redis, Hangfire, JWT + ASP.NET Identity, SendGrid/SMTP/Sinch -- Aspire orchestration (PostgreSQL pgvector:pg17-trixie, Redis 7-alpine), OpenTelemetry -- pnpm workspaces for Vue SPAs, uv for Python, Central Package Management for NuGet - -## Verification - -```bash -dotnet build # C# build (warnings-as-errors) -dotnet test service/Api/tests/Module.UnitTests # Unit tests (fast, no Docker) -dotnet test service/Api/tests/Shared.UnitTests # Shared unit tests -dotnet test # All tests (inc. integration — requires Docker) -dotnet test /p:CollectCoverage=true # Opt-in coverage -dotnet test --filter "FullyQualifiedName~Location" # Filter by module -cd app/Admin && pnpm run lint && pnpm run test:unit # Admin SPA verification -cd app/Store && pnpm run lint && pnpm run test:unit # Store SPA verification -cd service/Embedding && uv run ruff check . && uv run pytest # Python verification -cd benchmarks && uv run ruff check src/ && uv run pytest --ignore=src/tests/integration/ # Benchmark verification -bash scripts/check-feature-conventions.sh # Feature file completeness check -``` - -## Code Organization - -- **`service/Api/src/Api/`** — thin host: `Program.cs`, appsettings, startup -- **`service/Api/src/Module/`** — 9 business modules (Catalog, Identity, Inventory, Location, Ordering, Payment, Profile, Shipping, Dashboard), each with `Domain/`, `Features/`, `Persistence/` -- **`service/Api/src/Shared/`** — cross-cutting infrastructure: Application abstractions, Security, Operational, Performance, Observability, Governance -- **`service/Api/src/Migrations/`** — EF Core migrations (separate assembly) -- **`app/Admin/`** — Vue 3 Admin SPA (PrimeVue, Sakai theme, pnpm, Vite 8) -- **`app/Store/`** — Vue 3 Storefront SPA (Nuxt UI, pnpm, Vite 8) -- **`service/Embedding/`** — Python FastAPI ML sidecar (uv, Fashion-CLIP, torch) -- **`benchmarks/`** — Python fashion image retrieval benchmark (11 models, 3 modes, thesis protocol) — see `benchmarks/AGENTS.md` -- **`infra/Aspire/`** — orchestration (AppHost + ServiceDefaults) -- **`ApiTests/`** — 49 `.http` files for manual endpoint testing - -## Known Issues - -- Dev JWT secret for non-Development environments rejected by `JwtSettingsValidator` (commit `770b6a06`); dev secrets in `dotnet user-secrets` (id `resys.shop.api`), bootstrapped via `service/Api/scripts/setup-dev-secrets.sh` -- `app/ReSys.Admin/` legacy admin SPA (npm, older deps) — use `app/Admin/` (pnpm) instead -- `ValidateVerticalSliceIsolation` build target emits `` for module ProjectReferences; cross-module references are permitted, so this only guards against future module-split ProjectReference cycles -- CI/CD partial — `.github/workflows/ci.yml` runs build, unit tests, lint on PR/push for .NET, both Vue SPAs, Embedding service, Benchmarks. Integration tests (Testcontainers) and deployment not yet automated -- `service/Embedding/Dockerfile` exists for Python sidecar; no Dockerfiles for .NET API or Vue SPAs (Aspire manages containers for local dev) -- `Embedding/build/lib/` contains stale build artifacts — should be gitignored -- `.harness/domains.yml` LOC counts may drift from actual codebase — re-measure after significant changes \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 8e380fbea..000000000 --- a/CLAUDE.md +++ /dev/null @@ -1,120 +0,0 @@ -# CLAUDE.md - -This file give guidance to Claude Code (claude.ai/code) when work with code in this repo. - -## Essential Commands - -```bash -# .NET — build and test -dotnet build # Warnings-as-errors enforced; any warning fails -dotnet test service/Api/tests/Module.UnitTests # Fast unit tests (InMemory DB, no Docker) -dotnet test service/Api/tests/Shared.UnitTests # Shared infrastructure unit tests -dotnet test service/Api/tests/Api.Tests # Integration tests (requires Docker: PostgreSQL + Redis) -dotnet test # All tests -dotnet test --filter "FullyQualifiedName~ModuleName" # Filter by module -dotnet test /p:CollectCoverage=true # Opt-in code coverage - -# Admin SPA (Vue 3 + PrimeVue) -cd app/Admin && pnpm install && pnpm run dev # Dev server (port 5173, proxies /api → localhost:5035) -cd app/Admin && pnpm run lint # Oxlint + ESLint -cd app/Admin && pnpm run test:unit # Vitest unit tests - -# Store SPA (Vue 3 + PrimeVue 5) -cd app/Store && pnpm install && pnpm run dev # Dev server (port 5174) -cd app/Store && pnpm run lint && pnpm run test:unit - -# Python Embedding service -cd service/Embedding && uv sync && uv run uvicorn embedding.main:app --reload # Port 8000 -cd service/Embedding && uv run ruff check . && uv run pytest - -# Python Benchmarks -cd benchmarks && uv run ruff check src/ && uv run pytest --ignore=src/tests/integration/ - -# Aspire orchestration (starts everything: PG, Redis, API, Embedding, both SPAs) -dotnet run --project infra/Aspire/src/ReSys.AppHost - -# Drift checks -bash scripts/check-feature-conventions.sh # Feature file completeness (AC-001 through AC-005) -``` - -## Architecture - -**Modular monolith with CQRS vertical slices.** 8 business modules (Catalog, Identity, Inventory, Location, Ordering, Payment, Profile, Shipping) + 1 unregistered proto-module (Dashboard) live in single `Module` assembly. Each module organized as `Domain/`, `Features/`, `Persistence/`, `Backgrounds/`, `Services/`. - -**Request pipeline:** -``` -HTTP Request → Carter endpoint → FluentValidation → MediatR pipeline (Logging → Validation → ExceptionMapping) - → Command/Query Handler → Domain logic + EF Core / external services → Mapster-mapped DTO response -``` - -**Assembly dependency chain** (forward-only): `Api` → `Module` + `Shared` + `Migrations`; `Module` → `Shared`; `Shared` → `ServiceDefaults`. Modules share one `Module` assembly and may reference each other's types; for behavior, cross-module work flows through MediatR `ISender.Send(new OtherModule.Command(...))` so it passes the pipeline. - -**Every feature** is `static partial class` split across files in one directory under `Features/{Admin|Storefront}/{Domain}/{Action}/`: -- `{Action}.cs` — handler (`ICommandHandler` or `IQueryHandler`) -- `{Action}.Endpoint.cs` — Carter `ICarterModule` route mapping -- `{Action}.Request.cs` — command/query DTO (some queries use `.Parameters.cs`) -- `{Action}.Response.cs` — response DTO -- `{Action}.Validator.cs` — FluentValidation rules -- `{Action}.Result.cs` — typed error factories (not all features) - -**Result monad, not exceptions.** All domain ops and handlers return `Result` or `Result`. Typed error codes via static factory classes (e.g., `OrderResult.Errors.NotFound(id)` → `"Order.NotFound"`). Endpoints convert `Result` to HTTP responses via `result.ToResult()`. Exceptions only for unrecoverable infrastructure failures. - -**Subdirectory convention:** Feature subdirectories use `Storefront` (not `Store`). Some modules (Identity, Location, Profile) still use `Store` — being standardized. - -## Key Conventions - -### C# -- **Files:** PascalCase, one type per file (except partial class features). Test files: `{Feature}Tests.cs`. -- **Namespaces:** Mirror folder structure. File-scoped namespaces preferred. Using directives outside namespace, System first. -- **Fields:** `_camelCase` (private instance), `s_camelCase` (private static). No `var` for primitives/built-in types. -- **Module registration:** Each module has `{Module}.Extension.cs` with `builder.Add{Module}Module()` pattern, composed in `Program.cs`. -- **Global usings:** `Shared/GlobalUsings.cs` provides common imports. -- **InternalsVisibleTo:** Projects expose internals to `{Name}.Tests`, `{Name}.UnitTests`, `{Name}.IntegrationTests`, and `DynamicProxyGenAssembly2` (Moq). -- **Central Package Management:** All NuGet versions in `Directory.Packages.props`. - -### TypeScript (Vue SPAs) -- **Admin:** PrimeVue + Sakai theme + Tailwind CSS 4. Path alias `@/` → `./src/`. Form validation with Vee-Validate + Zod. Auto-imports via `unplugin-auto-import`. -- **Store:** PrimeVue 5 + Aura theme + Tailwind CSS 4. Same path alias pattern. -- **Linting:** Dual linter — Oxlint + ESLint. Formatting via Oxfmt (no Prettier). `noUncheckedIndexedAccess: true` in both SPAs. -- **Tests:** Vitest + jsdom, tests co-located in `src/**/__tests__/`. - -### Python -- **Lint/Format:** Ruff (`line-length=100`, `target-version=py312`). Embedding: `["E", "F", "W", "I"]`. Benchmarks: `["E", "F", "I", "UP", "B", "SIM"]`. -- **Tests:** pytest with `asyncio_mode=auto`. Integration tests marked with `@pytest.mark.integration`. -- **Benchmarks:** 60% coverage minimum enforced in CI. - -### Temporal Markers -Follow `guide/code-commenting/CommentingRules.xml`. Use `TODO`, `FIXME`, `HACK`, `UNDONE` with structured metadata. Markers may include `// EXCEPTION` comment to opt out of feature-convention checks. - -## Testing Strategy - -- **Unit tests (.NET):** EF Core InMemory database per test class (`Guid.NewGuid().ToString()` as DB name), isolated via constructor-create/dispose. Moq for external interfaces (`ICurrentUser`, `INotificationService`, etc.). Cross-module calls via real `ISender` against InMemory DB — not mocked. AAA pattern with `[Trait("Category", "Unit")]`, `[Trait("Module", "...")]`, `[Trait("Feature", "...")]`. -- **Integration tests (.NET):** `Api.Tests` project uses Testcontainers for PostgreSQL + Redis, Respawn for DB reset between tests. -- **Vue tests:** Vitest + jsdom + `@vue/test-utils`. Mocking via `vi.mock()` / `vi.fn()`. -- **No automated E2E tests:** `ApiTests/` contains 49 `.http` files for manual endpoint testing only. - -## Pitfalls & Known Issues - -- **`TreatWarningsAsErrors=true`** — any compiler warning fails the build. Includes unused variables and nullable reference warnings. Always run `dotnet build` before committing C# changes. -- **InMemory DB ≠ real PostgreSQL** — InMemory doesn't support pgvector, transaction isolation levels, or sequences. Tests passing with InMemory may fail against real PostgreSQL. Add integration tests for DB-specific features. -- **Feature subdirectory naming:** Use `Storefront`, not `Store`, for new features. Identity, Location, and Profile still use `Store` — don't replicate in new code. -- **Cross-module references:** Cross-module type references, direct service calls, and navigation/relationship access are all permitted (modules share one assembly). Use MediatR `ISender` when a command/query should flow through the pipeline (validation, logging, transaction); otherwise call the service or navigate the relationship directly. -- **Dashboard module:** Exists but NOT registered in `Program.cs`. Don't add new Dashboard features without registering it first. -- **Dev secrets:** Live in `dotnet user-secrets` (id: `resys.shop.api`), bootstrapped via `service/Api/scripts/setup-dev-secrets.sh`. Dev JWT secret rejected for non-Development environments. -- **Legacy code:** `app/legacy/` directories exist but deprecated and gitignored. Use `app/Admin/` (pnpm) for all admin UI work. -- **Stale Embedding artifacts:** `service/Embedding/build/lib/` not gitignored — don't commit files there. -- **High-churn areas:** `CreateOrderFromCart.cs` (checkout orchestration) and `StripeWebhook.cs` (payment webhook) see most change activity. Be especially careful when modifying — add integration tests. -- **eslint-plugin-boundaries:** Installed as dependency in Admin but NOT activated in `eslint.config.ts`. TypeScript feature layer boundaries unenforced. - -## Key Documentation Files - -- `docs/codebase/ARCHITECTURE.md` — detailed architecture, layer responsibilities, data flow -- `docs/codebase/STACK.md` — full framework versions and toolchain -- `docs/codebase/CONVENTIONS.md` — naming, formatting, error handling, import rules -- `docs/codebase/TESTING.md` — test frameworks, layout, mocking strategy -- `docs/codebase/CONCERNS.md` — tech debt, security concerns, high-churn areas, resolved decisions -- `docs/codebase/INTEGRATIONS.md` — external services, data stores, secrets, reliability -- `docs/codebase/STRUCTURE.md` — directory layout, entry points, module boundaries -- `AGENTS.md` — agent-specific guide with non-negotiable rules -- `.harness/` — machine-readable domain boundaries, principles, enforcement rules -- `Directory.Packages.props` — all NuGet versions (Central Package Management) \ No newline at end of file diff --git a/Directory.Build.targets b/Directory.Build.targets index 91cba5d3a..59332213b 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -41,7 +41,7 @@ + relationships are permitted; no namespace drift check exists. --> diff --git a/_thesis/chapters/part2/chapter1/07-backend-stack.typ b/_thesis/chapters/part2/chapter1/07-backend-stack.typ index 8b83f8405..7bf9e0803 100644 --- a/_thesis/chapters/part2/chapter1/07-backend-stack.typ +++ b/_thesis/chapters/part2/chapter1/07-backend-stack.typ @@ -22,7 +22,7 @@ Traditional ASP.NET uses "Controllers", which are classes that define API endpoi This project uses *Carter*, a library that organizes minimal APIs into modules: -```csharp +```cs // A simplified example of how endpoints are defined public class SearchModule : ICarterModule { @@ -130,7 +130,7 @@ Key features used: - *PostgreSQL provider:* Connects EF Core to PostgreSQL Example of a database query: -```csharp +```cs var products = await dbContext.Products .Where(p => p.IsActive) .OrderByDescending(p => p.CreatedAt) diff --git a/_thesis/chapters/part2/chapter2/06-api-design.typ b/_thesis/chapters/part2/chapter2/06-api-design.typ index 0509c3994..ab9424a9f 100644 --- a/_thesis/chapters/part2/chapter2/06-api-design.typ +++ b/_thesis/chapters/part2/chapter2/06-api-design.typ @@ -33,7 +33,7 @@ The `ApiResponse` wrapper enables consistent handling of metadata, such as pa Each feature exposes its own module. Below is the implementation of the *Product Management* API, demonstrating the rigorous security checks and command dispatching pattern. -```csharp +```cs public class ProductsModule : ICarterModule { public void AddRoutes(IEndpointRouteBuilder app) diff --git a/_thesis/chapters/part2/chapter2/implementation/02-backend.typ b/_thesis/chapters/part2/chapter2/implementation/02-backend.typ index 2484510a4..ca932f27f 100644 --- a/_thesis/chapters/part2/chapter2/implementation/02-backend.typ +++ b/_thesis/chapters/part2/chapter2/implementation/02-backend.typ @@ -15,7 +15,7 @@ The fundamental structure of the data layer is designed around the *Vertical Sli #figure( placement: none, - ```csharp + ```cs // ReSys.Core/Data/ShopDbContext.cs public class ShopDbContext : DbContext, IApplicationDbContext { diff --git a/_thesis/chapters/part2/chapter2/implementation/02-backend/01-orchestration-observability.typ b/_thesis/chapters/part2/chapter2/implementation/02-backend/01-orchestration-observability.typ index 84f3f89f9..85d0ec7af 100644 --- a/_thesis/chapters/part2/chapter2/implementation/02-backend/01-orchestration-observability.typ +++ b/_thesis/chapters/part2/chapter2/implementation/02-backend/01-orchestration-observability.typ @@ -4,7 +4,7 @@ The backend operates as a distributed system where services are loosely coupled - *Service Discovery:* Environment-based configuration manages connection strings for databases (PostgreSQL) and message brokers (Redis), ensuring seamless transitions between development and production environments. - *Telemetry:* Comprehensive OpenTelemetry integration provides distributed tracing across the .NET API and Python ML Service, allowing full visibility into request latency and inter-service communication. -```csharp +```cs // Program.cs // Service defaults configure OpenTelemetry, logging, and health checks builder.AddServiceDefaults(); diff --git a/_thesis/chapters/part2/chapter2/implementation/02-backend/02-middleware-pipelines.typ b/_thesis/chapters/part2/chapter2/implementation/02-backend/02-middleware-pipelines.typ index bcfd53cd4..9681ee0b9 100644 --- a/_thesis/chapters/part2/chapter2/implementation/02-backend/02-middleware-pipelines.typ +++ b/_thesis/chapters/part2/chapter2/implementation/02-backend/02-middleware-pipelines.typ @@ -5,7 +5,7 @@ The application utilizes *MediatR Behaviors* to implement cross-cutting concerns *Validation Pipeline:* Before a handler executes, the `ValidationBehavior` intercepts the request, runs all defined `FluentValidation` rules, and returns a structured error response if validation fails. -```csharp +```cs public class ValidationBehavior(IValidator? validator) : IPipelineBehavior { diff --git a/_thesis/chapters/part2/chapter2/implementation/02-backend/04-product-images-vectorization.typ b/_thesis/chapters/part2/chapter2/implementation/02-backend/04-product-images-vectorization.typ index b24a6751c..a0509b256 100644 --- a/_thesis/chapters/part2/chapter2/implementation/02-backend/04-product-images-vectorization.typ +++ b/_thesis/chapters/part2/chapter2/implementation/02-backend/04-product-images-vectorization.typ @@ -1,7 +1,7 @@ ===== Product Images & Vectorization To support the multi-model AI strategy, the database uses a flexible *One-to-Many* relationship for storing embeddings. -```csharp +```cs public class ProductImage : Aggregate { public Guid ProductId { get; set; } public string Url { get; set; } diff --git a/_thesis/chapters/part2/chapter2/implementation/02-backend/05-recommendations-api.typ b/_thesis/chapters/part2/chapter2/implementation/02-backend/05-recommendations-api.typ index 04ab6a0cd..7b05f8cca 100644 --- a/_thesis/chapters/part2/chapter2/implementation/02-backend/05-recommendations-api.typ +++ b/_thesis/chapters/part2/chapter2/implementation/02-backend/05-recommendations-api.typ @@ -1,7 +1,7 @@ ===== Recommendations API (Clean Architecture) The `RecommendationsModule` exposes endpoints via *Carter* modules, delegating logic to the Domain via MediatR. This separates the *Transport Mechanism* (HTTP) from the *Application Logic*. -```csharp +```cs // POST /api/storefront/recommendations/by-product/{id} app.MapGet("/by-product/{productId:guid}", async (ISender sender, ...) => { diff --git a/app/Admin/AGENTS.md b/app/Admin/AGENTS.md deleted file mode 100644 index 66d0a4aff..000000000 --- a/app/Admin/AGENTS.md +++ /dev/null @@ -1,72 +0,0 @@ -# Admin SPA — Agent Guide - -Vue 3 Admin SPA (PrimeVue, Sakai theme, pnpm, Vite 8). Lives in the ReSys.Shop -monorepo. This file provisions the Code Commenting Standard v3.0 for view files -under `app/Admin/src/features/*/views/` (`.vue` and `.ts`). - -## Code Commenting Standard (effective rules) - -The repository's Code Commenting Standard v3.0 governs all comments in this app: - -- `guide/code-commenting/README.md` — human-readable overview -- `guide/code-commenting/SKILL.md` — applied workflow (decision tree, label table) -- `guide/code-commenting/CommentingRules.xml` — authoritative machine-readable spec - -Every comment in a view must follow the rules below; where they conflict, the -XML standard wins. - -## Inline label format (script logic) - -Format every `