let node_state_type = [| 'pending, 'running, 'completed, 'failed, 'blocked, 'unknown |] in let operation_type = [| 'create, 'update, 'delete |] in let source_type = [| 'cli, 'orchestrator, 'sync |] in let provider_state_type = [| 'running, 'off, 'unknown |] in let actor_type = { identity | String | doc "Username from CLI session, or 'system' for orchestrator-initiated writes", source | source_type | doc "Write origin: cli = user invocation, orchestrator = daemon, sync = reconcile command", } in let log_entry_type = { ts | String | doc "ISO-8601 timestamp of the transition", event | String | doc "Transition description: started | completed | failed | skipped | sync-confirmed", source | source_type, } in let taskserv_state_type = { state | node_state_type | default = 'pending, operation | operation_type | default = 'create, profile | String | default = "", started_at | String | default = "", ended_at | String | default = "", blocker | String | doc "Taskserv name that is blocking this node (non-empty only when state = 'blocked)" | default = "", actor = { identity | String | default = "", source | source_type | default = 'orchestrator, }, log | Array log_entry_type | default = [], } in let server_state_type = { provider_id | String | default = "", provider_state | provider_state_type | default = 'unknown, last_sync | String | default = "", taskservs | { _ | taskserv_state_type } | default = {}, } in let workspace_state_type = { workspace | String | doc "Workspace name (directory basename)", cluster | String | doc "Primary cluster this state file describes", schema_version | String | default = "2.0", servers | { _ | server_state_type } | default = {}, } in { NodeState = node_state_type, Operation = operation_type, Source = source_type, ProviderState = provider_state_type, Actor = actor_type, LogEntry = log_entry_type, TaskservState = taskserv_state_type, ServerState = server_state_type, WorkspaceState = workspace_state_type, }