import type { NetworkZone } from '../db/schema'; /** * Machine classification * - host: Single-interface machine, used for normal modules * - router: Multi-interface machine spanning multiple zones, used for firewall modules */ export type MachineRole = 'host' | 'router'; /** * Detected network interface on a machine */ export interface NetworkInterface { name: string; ipAddress: string; zone: NetworkZone | 'unknown'; } /** * Container service provider types */ export type ProviderName = 'proxmox' | 'digitalocean' | 'aws' | 'gcp' | 'azure'; /** * Proxmox provider configuration */ export interface ProxmoxConfig { api_url: string; api_token_id: string; api_token_secret: string; default_target_node: string; lxc_template: string; storage: string; /** * Cloud-init VM template to clone for `requires.system.type: vm` modules — the * VM analogue of `lxc_template`. Optional: only services hosting VM modules set * it (the operator builds the template once, per VM_INFRA_TYPE.md). */ vm_template?: string; } /** * Digital Ocean provider configuration */ export interface DigitalOceanConfig { api_token: string; region: string; default_image: string; size_mappings: Record; // e.g., "1-1024" -> "s-1vcpu-1gb" } /** * Container service (from database) */ export interface ContainerService { id: string; serviceId: string; // User-facing kebab-case identifier name: string; providerName: ProviderName; zones: NetworkZone[]; apiCredentialsEncrypted: string; providerConfig: Record; verified: boolean; verifiedAt: Date | null; verificationError: string | null; createdAt: Date; updatedAt: Date; } /** * Machine hardware specifications */ export interface MachineHardware { cpu_cores: number; memory_mb: number; disk_gb: number; arch?: string; } /** * Machine (from database) */ export interface Machine { id: string; hostname: string; zone: NetworkZone; ipAddress: string; sshUser: string; sshKeyEncrypted: string; hardware: MachineHardware; role: MachineRole; interfaces: NetworkInterface[]; // No `assignedModuleIds` (celilo#773). Occupancy is DERIVED — call // `getModulesOnMachine(machineId)` in machine-pool.ts. It used to be a stored // array with an append-only writer and no removal path, which diverged in // both directions on the live fleet: a removed module's id stranded forever // so placement rejected an empty box citing a module that no longer existed, // and a machine genuinely hosting `iptables` reported "None (available)" so a // second module could be placed on top of it. // // It is gone from the TYPE rather than merely unused, so nothing can read it // back: leaving the field is what would let a new call site compile clean // against a value nobody maintains (Rule 3.9). /** Module ID this machine is earmarked for, or null/undefined */ earmarkedModule?: string | null; /** * Appliance / API-only machines (e.g., greenwave) where celilo has * no shell access. Base-module aspects skip these — see * openspec/specs/base-module-aspects/spec.md D8. Optional on the type because most call * sites don't care; the DB column defaults to false so the * effective value is well-defined regardless. */ apiOnly?: boolean; createdAt: Date; updatedAt: Date; } /** * Infrastructure type discriminator */ export type InfrastructureType = 'machine' | 'container_service'; /** * Module infrastructure tracking */ export interface ModuleInfrastructure { id: string; moduleId: string; infrastructureType: InfrastructureType; machineId: string | null; serviceId: string | null; containerMetadata: Record | null; createdAt: Date; } /** * Infrastructure selection result */ export interface InfrastructureSelection { type: InfrastructureType; machineId?: string; serviceId?: string; } /** * Resource requirements (from module manifest) */ export interface ResourceRequirements { cpu: number; memory: number; disk: number; storage?: string; // Optional, only for container services zone: NetworkZone; } /** * Resource allocation tracking for machines */ export interface ResourceAllocation { cpu: number; memory: number; disk: number; } /** * Connection test result */ export interface TestResult { success: boolean; message?: string; details?: Record; } /** * Machine detection result */ export interface DetectedMachineInfo { hostname: string; osInfo: string; hardware: MachineHardware; }