ProjectConfig Feature

The ProjectConfig Feature manages the technical configuration associated with a specific Project entity. While the core Project holds metadata (name, description, members), the ProjectConfig dictates how the project interacts with the external world: resolving Git repositories, configuring per-project LLM overrides (temperature, custom API keys, prompts), and mapping file exclusions.

Business Logic Intent

Different projects inside the same MILTON tenant often require vastly different operational configurations:

  • Repository Mappings: A project might span multiple Git repositories (e.g., frontend, backend, infra). This feature manages that list.
  • LLM Presets: The tenant may have a default OpenAI model, but a specific project might require Claude 3.5 Sonnet or a localized Llama-3 instance for stringent IP reasons. This module allows overriding the Writer, Coder, or Analyst presets on a per-project basis using jsonb.
  • Secret Management: Accessing Git requires tokens, and LLMs require API keys. This module interacts with IEncryptionService to guarantee that incoming plain-text secrets are immediately encrypted before being stored in Entity Framework. It handles the logic of clearing, updating, or leaving secrets unchanged during PUT operations.
  • Triggering Git Clones: When repositories or tokens are updated, this feature is responsible for initiating the CloneRepositoriesCommand outbox message to instruct the worker to pull the latest code.

Architecture & Integration

  • FastEndpoints: Exposes GET and PUT endpoints to the React client.
  • Wolverine CQRS: Uses standard static and instanced handlers (GetProjectConfigHandler, UpdateProjectConfigHandler).
  • Entity Framework Core: Mutates ProjectConfig and its child GitRepository collections.
  • Encryption: Uses DPAPI integration.

Mermaid Sequence Diagram

sequenceDiagram
    autonumber
    actor User
    participant API as UpdateProjectConfig Endpoint
    participant DB as AppDbContext
    participant Enc as IEncryptionService
    participant MQ as Wolverine Message Bus

    User->>API: PUT /projects/1/config (Repos, Presets, Tokens)
    API->>DB: Load ProjectConfig + Repos
    
    API->>API: Add/Update/Remove Git Repositories
    
    alt Git Token Provided
        API->>Enc: Encrypt(Token)
        Enc-->>API: Encrypted Ciphertext
        API->>API: Update ProjectConfig.EncryptedGitToken
    end
    
    API->>API: Merge LLM Presets (Encrypting API Keys if provided)
    API->>DB: SaveChangesAsync()
    
    alt Has Repositories
        API->>Enc: Decrypt Git Tokens
        API->>MQ: SendAsync(CloneRepositoriesCommand)
    end
    
    API-->>User: 200 OK (Success)

Modules and Components

Endpoints

Located in the Core/ subfolder:

  • GetProjectConfig: Retrieves the configuration, mapping Entity fields to DTOs. Noticeably, it strips actual tokens out, returning boolean flags (HasToken, HasApiKey) to the client for security.
  • UpdateProjectConfig: Handles idempotency, secret encryption, repository sync (delta tracking additions and deletions), LLM JSON merges, and triggers the clone worker.

Handlers & Messages

  • GetProjectConfigQuery / GetProjectConfigHandler
  • UpdateProjectConfigCommand / UpdateProjectConfigHandler