import type { NodeStatusDTO } from './common.js'; /** Ephemeral daemon lifecycle phase reported by health and status. */ export type StartupPhaseDTO = 'initializing' | 'blocked' | 'prepared' | 'recovering' | 'ready'; /** `GET /healthz` — substrate readiness probe. Versions are informational, never * a gate. Used by the provisioning ladder. */ export interface HealthDTO { ok: boolean; daemon_up: boolean; store_accessible: boolean; brokers_reconciled: boolean; /** Present while corpus migration or normal daemon startup is incomplete. */ startup_blocked?: string; /** Always present; only `ready` admits normal daemon work. */ startup_phase: StartupPhaseDTO; } /** `GET /v1/status` — daemon status snapshot. Backs `crtr sys daemon status` * state and the `crtr canvas dashboard` header. `runtime_version` is also * checked by Core's minimum-runtime capability gate. */ export interface StatusDTO { daemon_pid: number; tick_interval_ms: number; /** Node counts keyed by status. */ node_counts: Partial>; /** Nodes genuinely mid-turn: their busy marker exists and their recorded pid is alive. Unlike `node_counts.active`, this excludes live-but-waiting, parked, or blocked engines. */ busy_node_count: number; /** Bound listener addresses. `tcp` is null when the TCP listener is off. */ listeners: { socket_path: string; tcp: string | null; }; runtime_version: string; api_version: string; /** Always present; only `ready` admits normal daemon work. */ startup_phase: StartupPhaseDTO; } /** `POST /v1/daemon/restart` — the ack for a daemon-owned handover. * * The daemon answers BEFORE it tears anything down: the caller is normally a * node's own bash tool, whose broker this handover will kill, so the ack must * be a settled tool result in that node's transcript before the SIGTERM lands. * `accepted` is therefore a promise about the future, not a completed action — * the successor daemon is spawned after `grace_ms`, and every node the * teardown interrupts is resumed by it. */ export interface MigrateStateRequest { dry_run?: boolean; dirs?: string[]; } export interface MigrateStateDTO { profiles: number; stores: number; changed: number; applied: { store: string; lane: string; migration: string; files: string[]; }[]; skipped: { store: string; relPath: string; error: string; }[]; blockers: { kind: string; message: string; store?: string; target?: string; path?: string; name?: string; paths?: readonly string[]; }[]; discovery_roots: { reason: string; root: string; boundary: string; detail?: string; }[]; discovered_stores: { store: string; scope: string; namespace: string; mount_status: string; writable: boolean; reasons: string[]; targets: readonly string[]; docs: number; }[]; discovered_targets: { id: string; kind: string; origin: string; cwd: string; profile_id: string | null; node_id: string | null; stores: readonly string[]; }[]; repository_namespaces: { repository_root: string; repository_key: string; declaration_path: string; namespace: string; source: string; action: string; }[]; store_prefixes: { store_root: string; owner_dir: string; repository_root: string; owner_relative_path: string; old_prefix: string; old_rule: string; effective_prefix: string; nested_declaration_action: string; front_door_action: string; }[]; renames: { store_root: string; path: string; from: string; to: string; }[]; references: { store_root: string; path: string; kind: string; from: string; to: string; }[]; dryRun: boolean; blocked: boolean; corpus_phase: 'not-started' | 'planned' | 'written'; wrote: { profile_manifests: string[]; documents: string[]; corpus_consumers: string[]; corpus_identities: string[]; }; resumed: boolean; resume_error?: string; } /** `POST /v1/daemon/admit` — opens normal daemon work after preparation. */ export interface DaemonAdmitDTO { /** True only for the request that began admission. */ admitted: boolean; /** True when another request had already begun or completed admission. */ already_admitted: boolean; startup_phase: StartupPhaseDTO; } export interface DaemonRestartDTO { accepted: boolean; /** The daemon that took the request and is about to hand over. */ predecessor_pid: number; /** Its epoch id — the successor mints a new one. */ predecessor_epoch: string; /** How long the daemon waits after answering before teardown begins. */ grace_ms: number; }