MILTON API Service Context
You are working in the MILTON service — the main ASP.NET Core API.
Responsibilities
- Document management, user interactions, and core business logic.
- Owns
milton-dbviaAppDbContext(EF Core + PostgreSQL). - The only service that reads/writes
milton-dbdirectly. - Publishes/consumes cross-service messages via Wolverine.
Owned Paths
MILTON/Features/— vertical slices for Documents, Projects, Templates, Git, Clustering, ProjectConfig, HealthMILTON/Domain/— EF Core entities and domain logicMILTON/Infrastructure/— persistence, auth, encryption, tenant interceptorsMILTON/Shared/— DTOs, DTO validators, and contract modelsMILTON/Migrations/— EF Core migrations formilton-db
Key Technologies & Patterns
- FastEndpoints: Inherit from
Endpoint<TRequest, TResponse>. Always useSend.OkAsync()(not deprecatedSendOkAsync()). UseMiltonPermissionspolicies for endpoint auth. - Wolverine CQRS: Prefer static handlers (
Handle(MyCommand cmd, AppDbContext db)). Dependencies injected as method parameters. Durable inbox/outbox handles retries automatically (do not add manual retry loops). - EF Core & Multi-tenancy: PostgreSQL persistence.
TenantInterceptorautomatically sets session variable for Row-Level Security based onITenantService. - ContentBlock Polymorphism: Blocks are polymorphic (
Requirement,TestCase,TestResult,Text,Mermaid,Scanner,TraceMatrix).PropertiesJsonis accessed viablock.As<T>()and modified viablock.UpdateConfig(model). - Encrypted LLM Presets: Built-in presets (
Writer,Coder,Analyst) with per-project overrides stored encrypted inProjectConfig.LlmPresetsJson. UseLlmPreset.Resolve()/LlmPreset.ResolveWithOverrides(). Encrypt secrets usingIEncryptionServicewith purpose string"MILTON.Encryption.Tokens". - Cross-Service Contracts:
[MessageIdentity]records declared per-producer. Payload claim-checks travel through S3 (IClaimCheckStore).
Contracts This Service Owns
DocumentCreatedEventPrepareRequirementGenerationRequested/RequirementGenerationCompleted(API-side mirrors)PrepareScannerGenerationRequested/ScannerGenerationCompleted(API-side mirrors)PrepareTestCaseGenerationRequested/TestCaseGenerationCompleted(API-side mirrors)- Outbound notification messages bound to
MILTON.NotificationService
Working Rules
- Load and follow
milton-vertical-slicebefore creating any newMILTON/Features/<Feature>. - Load and follow
milton-tddbefore writing or changing behavior. Strict RED-GREEN-REFACTOR. - Keep endpoints in
MILTON/Features/<Feature>/. - Use
MiltonPermissionspolicies on endpoints. - Do not let other services touch
milton-db; expose data via messages or APIs. - Maintain
[MessageIdentity]parity withMILTON.DocumentGeneratorandMILTON.NotificationService.
Migrations & Verification
# Add EF Core migration for milton-db (from solution root)
dotnet ef migrations add MigrationName --project MILTON --startup-project MILTON
# Apply migration manually (normally applied by MILTON.ApiMigrationService on startup)
dotnet ef database update --project MILTON --startup-project MILTON
# Run tests
dotnet test MILTON.Tests --no-build --verbosity normal- New behavior has a failing-then-passing test in
MILTON.Tests/. -
dotnet buildsucceeds with no warnings. -
dotnet test MILTON.Tests/passes. - Cross-service contracts have matching
[MessageIdentity]strings in consumer services.