classDiagram
    direction TB
    ICompilerPayload <|-- CompilerPayload
    CompilerPayload : +command
    CompilerPayload : +selections
    CompilerPayload : +code
    CompilerPayload : +context
    CompilerPayload : +toJSON()
    CompilerPayload *-- IDispatchContext
    InferenceResults : +id
    InferenceResults : +prompt_id
    InferenceResults : +payload_send
    InferenceResults : +response_received
    InferenceResults : +telemetry
    InferenceResults : +timestamp
    ResultsCollection : +_collections
    ResultsCollection : +_get()
    ResultsCollection *-- InferenceResults
    BaseState <|-- ResearchResult
    ResearchResult : +id
    ResearchResult : +status
    ResearchResult : +roi_gain
    ResearchResult : +execution_time_ms
    ResearchResult : +error_message
    BaseState <|-- ResearchLibrary
    ResearchLibrary : +_collection
    ResearchLibrary : +runTrial()
    ResearchLibrary : +_refresh()
    Notification <|-- ApiError
    ApiError : +name
    ApiError : +fromResponse()
    ApiError <|-- ValidationError
    ValidationError : +name
    ValidationError : +details
    ValidationError : +summmary
    ApiError <|-- NetworkError
    NetworkError : +name
    BaseCRUD <|-- LLMServer
    LLMServer : +_directives
    LLMServer : +name
    LLMServer : +address
    LLMServer : +port
    LLMServer : +proto
    LLMServer : +service_online
    LLMServer : +models
    LLMServer : +pull_status
    LLMServer : +hydrate()
    BaseLibrary <|-- LLMServerLibrary
    LLMServerLibrary : +ItemClass
    Error <|-- Notification
    Notification : +isNotification
    Notification : +id
    Notification : +type
    Notification : +timeout
    Notification : +sticky
    Notification *-- MessageType
    Notification <|-- Sticky
    Notifications : +#queue
    Notifications : +message()
    Notifications : +push()
    Notifications : +dismiss()
    BaseCRUD <|-- ResearchTier
    ResearchTier : +_directives
    ResearchTier : +name
    BaseLibrary <|-- ResearchTierLibrary
    ResearchTierLibrary : +ItemClass
    ResearchTierLibrary : +getTier()
    BaseState <|-- Server
    Server : +name
    Server : +proto
    Server : +address
    Server : +port
    Server : +models
    Server : +_systemStatus
    Server : +_pullProgress
    Server : +_apiClient
    Server : +_refresh()
    Server : +getPullProgress()
    Server *-- LLMServerStatusLibrary
    Server *-- ServerStatus
    Server *-- ReturnType<typeof createApiClient> | null
    Server ..> LLMServerStatusLibrary : creates
    Server ..> Compiler : creates
    BaseState <|-- ServerList
    ServerList : +_servers
    ServerList : +getServer()
    ServerList : +getServerList()
    ServerList *-- Server[]
    Dataset : +status
    Dataset : +#polling
    Dataset : +#getUri
    Dataset : +apiUri
    Dataset : +startBuild()
    Dataset : +stopBuild()
    Dataset : +pollDataset()
    TerminalController : +isProcessing
    TerminalController : +isSyncing
    TerminalController : +terminalInput
    TerminalController : +masterSeed
    TerminalController : +scripts
    TerminalController : +selectedScriptName
    TerminalController : +pullProgress
    TerminalController : +servers
    TerminalController : +systemStatus
    TerminalController : +selectedServer
    TerminalController : +selectedModel
    TerminalController : +baselineData
    TerminalController : +trainedData
    TerminalController : +selectedCategory
    TerminalController : +selectedTemplate
    TerminalController : +selectedTrialId
    TerminalController : +selectionType
    TerminalController : +activeSelectionId
    TerminalController : +categories
    TerminalController : +systemLogs
    TerminalController : +apiUri
    TerminalController : +ui
    TerminalController : +researchMode
    TerminalController : +handleMainAction()
    TerminalController : +startDatasetBuild()
    TerminalController : +syncSystemLogs()
    TerminalController : +stopDatasetBuild()
    TerminalController : +pollDataset()
    TerminalController : +fetchInitialData()
    TerminalController : +executeCommand()
    TerminalController : +pollForResult()
    TerminalController : +migrateToNewServer()
    TerminalController : +getModelLabel()
    TerminalController : +#calculateStats()
    TerminalController : +loadScript()
    TerminalController : +refreshStatus()
    TerminalController : +handleReset()
    TerminalController : +handleMutation()
    TerminalController : +addLog()
    TerminalController : +getBaselineMarkdown()
    TerminalController : +getTrainedMarkdown()
    TerminalController : +loadState()
    TerminalController : +sendPatch
    TerminalController : +updatePaneHeight()
    TerminalController ..> Dataset : creates
    TerminalController ..> CompilerConfig : creates
    BaseState <|-- BaseCRUD
    BaseCRUD : +id
    BaseCRUD : +isSaving
    BaseCRUD : +#memento
    BaseCRUD : +_schema
    BaseCRUD : +_createSchema
    BaseCRUD : +_directives
    BaseCRUD : +_parentLibrary
    BaseCRUD : +ensureDirectives()
    BaseCRUD : +commitMemento()
    BaseCRUD : +isNew()
    BaseCRUD : +hydrate()
    BaseCRUD : +getValidPayload()
    BaseCRUD : +save()
    BaseCRUD : +delete()
    BaseCRUD : +inferTag()
    BaseCRUD : +inferOptions()
    BaseCRUD : +inferAttributes()
    BaseState <|-- BaseLibrary
    BaseLibrary : +#_collection
    BaseLibrary : +activeItem
    BaseLibrary : +searchFilter
    BaseLibrary : +isModalOpen
    BaseLibrary : +_endpoint
    BaseLibrary : +ItemClass
    BaseLibrary : +list()
    BaseLibrary : +get()
    BaseLibrary : +select()
    BaseLibrary : +sync()
    BaseLibrary : +_refresh()
    BaseLibrary : +hydrate()
    BaseLibrary : +createNew()
    BaseLibrary : +handlePurge()
    BaseLibrary *-- new (
    data: S,
  ) => T
    BaseState : +_dependencies
    BaseState : +server
    BaseState : +notifications
    BaseState : +isFetching
    BaseState : +created_at
    BaseState : +updated_at
    BaseState : +last_sync
    BaseState : +inherit()
    BaseState : +get_deps()
    BaseState : +_sync_threshold_ms
    BaseState : +updateServer()
    BaseState : +ensureServer()
    BaseState : +dep()
    BaseState : +apiUri()
    BaseState : +apiFetch()
    BaseState : +setThreshold()
    BaseState : +setThresholdSeconds()
    BaseState : +setThresholdMinutes()
    BaseState : +isStale()
    BaseState : +updateSyncTimestamp()
    BaseState : +refresh()
    BaseState : +debugNetwork()
    BaseState : +error()
    BaseState : +notify()
    BaseState : +sticky()
    BaseState : +info()
    BaseState *-- IServerContext
    BaseState *-- Notifications
    BaseState <|-- CompilerConfig
    CompilerConfig : +capabilities
    CompilerConfig : +selections
    CompilerConfig : +masterSeed
    CompilerConfig : +hydrateDefaults()
    CompilerConfig : +fetchCapabilities()
    BaseCRUD <|-- LLMModelData
    LLMModelData : +name
    LLMModelData : +nickname
    LLMModelData : +description
    LLMModelData : +servers
    LLMModelData : +research_tiers
    LLMModelData : +init_directives()
    LLMModelData : +hydrate()
    BaseLLMModel : +getName()
    BaseLibrary <|-- LLMModelDataLibrary
    LLMModelDataLibrary : +ItemClass
    LLMServerStatus : +id
    LLMServerStatus : +name
    LLMServerStatus : +service_online
    LLMServerStatus : +models
    LLMServerStatus : +pull_status
    LLMServerStatus : +hydrate()
    LLMServerStatus : +isReady()
    BaseState <|-- LLMServerStatusLibrary
    LLMServerStatusLibrary : +entries
    LLMServerStatusLibrary : +_refresh()
    LLMServerStatusLibrary : +list()
    BaseCRUD <|-- Prompt
    Prompt : +_directives
    Prompt : +name
    Prompt : +system_prompt
    Prompt : +models
    Prompt : +research_tiers
    Prompt : +isEditing
    Prompt : +isPending
    BaseLibrary <|-- PromptLibrary
    PromptLibrary : +ItemClass
    PromptLibrary : +getByResearchTier()
    BaseCRUD <|-- PromptConfig
    PromptConfig : +_directives
    PromptConfig : +name
    PromptConfig : +research_tier
    PromptConfig : +prompt
    PromptConfig : +model
    PromptConfig : +prompt_id
    PromptConfig : +model_id
    PromptConfig : +research_tier_id
    PromptConfig : +init_directives()
    PromptConfig : +hydrate()
    BaseLibrary <|-- PromptConfigLibrary
    PromptConfigLibrary : +ItemClass
    BaseCRUD <|-- PromptPair
    PromptPair : +name
    PromptPair : +prompt_a_id
    PromptPair : +prompt_b_id
    PromptPair : +prompt_a
    PromptPair : +prompt_b
    PromptPair : +init_directives()
    PromptPair : +hydrate()
    PromptPair *-- PromptConfig
    PromptPair *-- PromptConfig
    BaseLibrary <|-- PromptPairLibrary
    PromptPairLibrary : +ItemClass
    PromptPairLibrary : +init_directives()
    BaseCRUD <|-- WBSTask
    WBSTask : +component
    WBSTask : +name
    WBSTask : +phase
    WBSTask : +status
    WBSTask : +is_breaking
    WBSTask : +dependency_id
    BaseLibrary <|-- WBSTaskLibrary
    WBSTaskLibrary : +ItemClass
    WBSTaskLibrary : +getByComponent()
    BaseCRUD <|-- WBSPhase
    WBSPhase : +_directives
    WBSPhase : +name
    WBSPhase : +sequence
    BaseLibrary <|-- WBSPhaseLibrary
    WBSPhaseLibrary : +ItemClass
    BaseCRUD <|-- WBSTask
    WBSTask : +_directives
    WBSTask : +component
    WBSTask : +name
    WBSTask : +description
    WBSTask : +phase_id
    WBSTask : +status
    WBSTask : +is_breaking
    WBSTask : +dependency_id
    WBSTask : +start_date
    WBSTask : +end_date
    WBSTask : +estimated_hours
    WBSTask : +init_directives()
    BaseLibrary <|-- WBSTaskLibrary
    WBSTaskLibrary : +ItemClass
    WBSTaskLibrary : +getByComponent()
