/** * Resolve a deployed module's "system identity" — the hostname and IP of the * machine / container-service instance it runs on. Used to populate * system.created / system.destroyed event payloads (D5) and to enumerate hosts * for a dns_internal provider's deploy-time DNS backfill. */ import type { DbClient } from '../db/client'; import { getModuleSystems } from './deployed-systems'; export interface SystemIdentity { hostname: string; /** IPv4 address, CIDR stripped. */ ip: string; } /** * Get a module's hostname and IP from its recorded deployed systems * (openspec/specs/module-systems-addressing/spec.md). Returns null for a module with no host * (config-only providers like namecheap). Single-system modules have one; this * returns the first (Phase C iterates all systems for per-system events). */ export async function getModuleHostAndIp( moduleId: string, db: DbClient, ): Promise { const systems = getModuleSystems(moduleId, db); if (!systems[0]) return null; return { hostname: systems[0].hostname, ip: systems[0].ipv4_address }; }