{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "ConfigToml",
  "type": "object",
  "properties": {
    "activities": {
      "$ref": "#/$defs/ActivitiesGlobalConfigToml"
    },
    "activity_external": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ActivityStubExtComponentConfigToml"
      }
    },
    "activity_stub": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ActivityStubExtComponentConfigToml"
      }
    },
    "activity_wasm": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ActivityWasmComponentConfigToml"
      }
    },
    "api": {
      "$ref": "#/$defs/ApiConfig"
    },
    "cancel_watcher": {
      "$ref": "#/$defs/CancelWatcherTomlConfig"
    },
    "database": {
      "$ref": "#/$defs/DatabaseConfigToml"
    },
    "http_server": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/HttpServer"
      }
    },
    "log": {
      "$ref": "#/$defs/LoggingConfig"
    },
    "otlp": {
      "anyOf": [
        {
          "$ref": "#/$defs/OtlpConfig"
        },
        {
          "type": "null"
        }
      ]
    },
    "timers_watcher": {
      "$ref": "#/$defs/TimersWatcherTomlConfig"
    },
    "wasm": {
      "$ref": "#/$defs/WasmGlobalConfigToml"
    },
    "webhook_endpoint": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/WebhookComponentConfigToml"
      }
    },
    "webui": {
      "$ref": "#/$defs/WebUIConfig"
    },
    "workflow": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/WorkflowComponentConfigToml"
      }
    },
    "workflows": {
      "$ref": "#/$defs/WorkflowsGlobalConfigToml"
    }
  },
  "additionalProperties": false,
  "required": [
    "api"
  ],
  "$defs": {
    "ActivitiesDirectoriesCleanupConfigToml": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": true
        },
        "older_than": {
          "$ref": "#/$defs/DurationConfig"
        },
        "run_every": {
          "$ref": "#/$defs/DurationConfig"
        }
      },
      "additionalProperties": false
    },
    "ActivitiesDirectoriesGlobalConfigToml": {
      "type": "object",
      "properties": {
        "cleanup": {
          "$ref": "#/$defs/ActivitiesDirectoriesCleanupConfigToml"
        },
        "enabled": {
          "type": "boolean",
          "default": false
        },
        "parent_directory": {
          "type": "string",
          "default": "${TEMP_DIR}/obelisk"
        }
      },
      "additionalProperties": false
    },
    "ActivitiesGlobalConfigToml": {
      "type": "object",
      "properties": {
        "directories": {
          "$ref": "#/$defs/ActivitiesDirectoriesGlobalConfigToml"
        }
      },
      "additionalProperties": false,
      "required": [
        "directories"
      ]
    },
    "ActivityDirectoriesConfigToml": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": false
        },
        "process_provider": {
          "$ref": "#/$defs/ActivityDirectoriesProcessProvider"
        },
        "reuse_on_retry": {
          "type": "boolean",
          "default": false
        }
      },
      "additionalProperties": false
    },
    "ActivityDirectoriesProcessProvider": {
      "type": "string",
      "enum": [
        "none",
        "native"
      ]
    },
    "ActivityStubExtComponentConfigToml": {
      "type": "object",
      "properties": {
        "location": {
          "$ref": "#/$defs/ComponentLocation"
        },
        "name": {
          "$ref": "#/$defs/ConfigName"
        }
      },
      "additionalProperties": false,
      "required": [
        "name",
        "location"
      ]
    },
    "ActivityWasmComponentConfigToml": {
      "type": "object",
      "properties": {
        "directories": {
          "$ref": "#/$defs/ActivityDirectoriesConfigToml"
        },
        "env_vars": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/EnvVarConfig"
          }
        },
        "exec": {
          "$ref": "#/$defs/ExecConfigToml"
        },
        "forward_stderr": {
          "$ref": "#/$defs/StdOutput"
        },
        "forward_stdout": {
          "$ref": "#/$defs/StdOutput"
        },
        "location": {
          "$ref": "#/$defs/ComponentLocation"
        },
        "max_retries": {
          "type": "integer",
          "format": "uint32",
          "default": 5,
          "minimum": 0
        },
        "name": {
          "$ref": "#/$defs/ConfigName"
        },
        "retry_exp_backoff": {
          "$ref": "#/$defs/DurationConfig"
        },
        "retry_on_err": {
          "type": "boolean",
          "default": true
        }
      },
      "additionalProperties": false,
      "required": [
        "name",
        "location"
      ]
    },
    "ApiConfig": {
      "type": "object",
      "properties": {
        "listening_addr": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "listening_addr"
      ]
    },
    "AppenderOut": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "level": {
          "$ref": "#/$defs/EnvFilter"
        },
        "span": {
          "$ref": "#/$defs/SpanConfig"
        },
        "style": {
          "$ref": "#/$defs/LoggingStyle"
        },
        "target": {
          "type": "boolean",
          "default": false
        }
      },
      "additionalProperties": false,
      "required": [
        "enabled"
      ]
    },
    "AppenderRollingFile": {
      "type": "object",
      "properties": {
        "directory": {
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        },
        "level": {
          "$ref": "#/$defs/EnvFilter"
        },
        "prefix": {
          "type": "string"
        },
        "rotation": {
          "$ref": "#/$defs/Rotation"
        },
        "span": {
          "$ref": "#/$defs/SpanConfig"
        },
        "style": {
          "$ref": "#/$defs/LoggingStyle"
        },
        "target": {
          "type": "boolean",
          "default": false
        }
      },
      "additionalProperties": false,
      "required": [
        "enabled",
        "directory",
        "prefix"
      ]
    },
    "BlockingStrategyConfigCustomized": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "await"
            },
            "non_blocking_event_batching": {
              "type": "integer",
              "format": "uint32",
              "default": 100,
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "kind"
          ]
        }
      ]
    },
    "BlockingStrategyConfigSimple": {
      "type": "string",
      "enum": [
        "interrupt",
        "await"
      ]
    },
    "BlockingStrategyConfigToml": {
      "anyOf": [
        {
          "$ref": "#/$defs/BlockingStrategyConfigCustomized"
        },
        {
          "$ref": "#/$defs/BlockingStrategyConfigSimple"
        }
      ]
    },
    "CancelWatcherTomlConfig": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": true
        },
        "tick_sleep": {
          "$ref": "#/$defs/DurationConfig"
        }
      },
      "additionalProperties": false
    },
    "CodegenCache": {
      "type": "object",
      "properties": {
        "directory": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "enabled": {
          "type": "boolean",
          "default": true
        }
      },
      "additionalProperties": false
    },
    "ComponentLocation": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "path": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "path"
          ]
        },
        {
          "type": "object",
          "properties": {
            "oci": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "oci"
          ]
        }
      ]
    },
    "ConfigName": {
      "description": "Activity, Webhook, Workflow or a Http server",
      "type": "string"
    },
    "DatabaseConfigToml": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "sqlite": {
              "$ref": "#/$defs/SqliteConfigToml"
            }
          },
          "additionalProperties": false,
          "required": [
            "sqlite"
          ]
        },
        {
          "type": "object",
          "properties": {
            "postgres": {
              "$ref": "#/$defs/PostgresConfigToml"
            }
          },
          "additionalProperties": false,
          "required": [
            "postgres"
          ]
        }
      ]
    },
    "DurationConfig": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "milliseconds": {
              "type": "integer",
              "format": "uint64",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "milliseconds"
          ]
        },
        {
          "type": "object",
          "properties": {
            "seconds": {
              "type": "integer",
              "format": "uint64",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "seconds"
          ]
        },
        {
          "type": "object",
          "properties": {
            "minutes": {
              "type": "integer",
              "format": "uint64",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "minutes"
          ]
        },
        {
          "type": "object",
          "properties": {
            "hours": {
              "type": "integer",
              "format": "uint64",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "hours"
          ]
        }
      ]
    },
    "DurationConfigOptional": {
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "none"
          ]
        },
        {
          "type": "object",
          "properties": {
            "milliseconds": {
              "type": "integer",
              "format": "uint64",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "milliseconds"
          ]
        },
        {
          "type": "object",
          "properties": {
            "seconds": {
              "type": "integer",
              "format": "uint64",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "seconds"
          ]
        },
        {
          "type": "object",
          "properties": {
            "minutes": {
              "type": "integer",
              "format": "uint64",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "minutes"
          ]
        },
        {
          "type": "object",
          "properties": {
            "hours": {
              "type": "integer",
              "format": "uint64",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "hours"
          ]
        }
      ]
    },
    "EnvFilter": {
      "type": "string"
    },
    "EnvVarConfig": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string"
        },
        "val": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "key"
      ]
    },
    "ExecConfigToml": {
      "type": "object",
      "properties": {
        "batch_size": {
          "type": "integer",
          "format": "uint32",
          "default": 5,
          "minimum": 0
        },
        "lock_expiry": {
          "$ref": "#/$defs/DurationConfig"
        },
        "locking_strategy": {
          "$ref": "#/$defs/LockingStrategy",
          "default": "by_ffqns"
        },
        "tick_sleep": {
          "$ref": "#/$defs/DurationConfig"
        }
      },
      "additionalProperties": false
    },
    "HttpServer": {
      "type": "object",
      "properties": {
        "listening_addr": {
          "type": "string"
        },
        "name": {
          "$ref": "#/$defs/ConfigName"
        }
      },
      "additionalProperties": false,
      "required": [
        "name",
        "listening_addr"
      ]
    },
    "InflightSemaphore": {
      "anyOf": [
        {
          "$ref": "#/$defs/Unlimited"
        },
        {
          "type": "integer",
          "format": "uint32",
          "minimum": 0
        }
      ]
    },
    "LockingStrategy": {
      "type": "string",
      "enum": [
        "by_ffqns",
        "by_component_id"
      ]
    },
    "LoggingConfig": {
      "type": "object",
      "properties": {
        "file": {
          "anyOf": [
            {
              "$ref": "#/$defs/AppenderRollingFile"
            },
            {
              "type": "null"
            }
          ]
        },
        "stdout": {
          "anyOf": [
            {
              "$ref": "#/$defs/AppenderOut"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "LoggingStyle": {
      "type": "string",
      "enum": [
        "plain",
        "plain_compact",
        "json"
      ]
    },
    "OtlpConfig": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "level": {
          "$ref": "#/$defs/EnvFilter"
        },
        "otlp_endpoint": {
          "type": "string",
          "default": "http://localhost:4317"
        },
        "service_name": {
          "type": "string",
          "default": "obelisk-server"
        }
      },
      "additionalProperties": false,
      "required": [
        "enabled"
      ]
    },
    "PostgresConfigToml": {
      "type": "object",
      "properties": {
        "db_name": {
          "type": "string"
        },
        "host": {
          "type": "string"
        },
        "password": {
          "type": "string"
        },
        "provision_policy": {
          "$ref": "#/$defs/PostgresProvisionPolicy"
        },
        "subscription_interruption": {
          "description": "Interrupts listening for notifications periodically, needed for Postgres with a local-only subscription mechanism.",
          "$ref": "#/$defs/DurationConfigOptional"
        },
        "user": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "host",
        "user",
        "password",
        "db_name"
      ]
    },
    "PostgresProvisionPolicy": {
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "never"
          ]
        },
        {
          "description": "Create database if it does not exist.",
          "type": "string",
          "const": "auto"
        }
      ]
    },
    "Rotation": {
      "type": "string",
      "enum": [
        "minutely",
        "hourly",
        "daily",
        "never"
      ]
    },
    "SpanConfig": {
      "oneOf": [
        {
          "description": "spans are ignored (this is the default)",
          "type": "string",
          "const": "none"
        },
        {
          "description": "one event when span is created",
          "type": "string",
          "const": "new"
        },
        {
          "description": "one event per enter of a span",
          "type": "string",
          "const": "enter"
        },
        {
          "description": "one event per exit of a span",
          "type": "string",
          "const": "exit"
        },
        {
          "description": "one event when the span is dropped",
          "type": "string",
          "const": "close"
        },
        {
          "description": "one event per enter/exit of a span",
          "type": "string",
          "const": "active"
        },
        {
          "description": "events at all points (new, enter, exit, drop)",
          "type": "string",
          "const": "full"
        }
      ]
    },
    "SqliteConfigToml": {
      "type": "object",
      "properties": {
        "directory": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "metrics_threshold": {
          "anyOf": [
            {
              "$ref": "#/$defs/DurationConfig"
            },
            {
              "type": "null"
            }
          ]
        },
        "pragma": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "default": {}
        },
        "queue_capacity": {
          "type": "integer",
          "format": "uint",
          "default": 100,
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "StdOutput": {
      "type": "string",
      "enum": [
        "none",
        "stdout",
        "stderr"
      ]
    },
    "TimersWatcherTomlConfig": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": true
        },
        "leeway": {
          "$ref": "#/$defs/DurationConfig"
        },
        "tick_sleep": {
          "$ref": "#/$defs/DurationConfig"
        }
      },
      "additionalProperties": false
    },
    "Unlimited": {
      "type": "string",
      "enum": [
        "unlimited"
      ]
    },
    "ValueOrUnlimited": {
      "anyOf": [
        {
          "$ref": "#/$defs/Unlimited"
        },
        {
          "type": "integer",
          "format": "uint64",
          "minimum": 0
        }
      ]
    },
    "WasmGlobalBacktrace": {
      "type": "object",
      "properties": {
        "persist": {
          "type": "boolean",
          "default": true
        }
      },
      "additionalProperties": false
    },
    "WasmGlobalConfigToml": {
      "type": "object",
      "properties": {
        "allocator_config": {
          "$ref": "#/$defs/WasmtimeAllocatorConfig"
        },
        "backtrace": {
          "$ref": "#/$defs/WasmGlobalBacktrace"
        },
        "build_semaphore": {
          "$ref": "#/$defs/ValueOrUnlimited"
        },
        "cache_directory": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "codegen_cache": {
          "$ref": "#/$defs/CodegenCache"
        },
        "debug": {
          "type": "boolean",
          "default": false
        },
        "fuel": {
          "$ref": "#/$defs/ValueOrUnlimited"
        },
        "global_executor_instance_limiter": {
          "$ref": "#/$defs/InflightSemaphore"
        },
        "global_webhook_instance_limiter": {
          "$ref": "#/$defs/InflightSemaphore"
        },
        "parallel_compilation": {
          "type": "boolean",
          "default": true
        },
        "wasmtime_pooling_config": {
          "$ref": "#/$defs/WasmtimePoolingAllocatorConfig"
        }
      },
      "additionalProperties": false
    },
    "WasmtimeAllocatorConfig": {
      "type": "string",
      "enum": [
        "auto",
        "on_demand",
        "pooling"
      ]
    },
    "WasmtimePoolingAllocatorConfig": {
      "type": "object",
      "properties": {
        "memory_protection_keys": {
          "description": "Enable memory protection keys for the pooling allocator; this can\noptimize the size of memory slots.",
          "type": [
            "boolean",
            "null"
          ],
          "default": null
        },
        "pooling_max_memory_size": {
          "description": "The maximum runtime size of each linear memory in the pooling\nallocator, in bytes.",
          "type": [
            "integer",
            "null"
          ],
          "format": "uint",
          "default": null,
          "minimum": 0
        },
        "pooling_memory_keep_resident": {
          "description": "How many bytes to keep resident between instantiations for the\npooling allocator in linear memories.",
          "type": [
            "integer",
            "null"
          ],
          "format": "uint",
          "default": null,
          "minimum": 0
        },
        "pooling_table_keep_resident": {
          "description": "How many bytes to keep resident between instantiations for the\npooling allocator in tables.",
          "type": [
            "integer",
            "null"
          ],
          "format": "uint",
          "default": null,
          "minimum": 0
        },
        "pooling_total_component_instances": {
          "description": "The maximum number of WebAssembly components which can be created\nwith the pooling allocator.",
          "type": [
            "integer",
            "null"
          ],
          "format": "uint32",
          "default": null,
          "minimum": 0
        },
        "pooling_total_core_instances": {
          "description": "The maximum number of WebAssembly instances which can be created\nwith the pooling allocator.",
          "type": [
            "integer",
            "null"
          ],
          "format": "uint32",
          "default": null,
          "minimum": 0
        },
        "pooling_total_memories": {
          "description": "The maximum number of WebAssembly memories which can be created with\nthe pooling allocator.",
          "type": [
            "integer",
            "null"
          ],
          "format": "uint32",
          "default": null,
          "minimum": 0
        },
        "pooling_total_stacks": {
          "description": "The maximum number of WebAssembly stacks which can be created with\nthe pooling allocator.",
          "type": [
            "integer",
            "null"
          ],
          "format": "uint32",
          "default": null,
          "minimum": 0
        },
        "pooling_total_tables": {
          "description": "The maximum number of WebAssembly tables which can be created with\nthe pooling allocator.",
          "type": [
            "integer",
            "null"
          ],
          "format": "uint32",
          "default": null,
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "WebUIConfig": {
      "type": "object",
      "properties": {
        "listening_addr": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "additionalProperties": false
    },
    "WebhookComponentConfigToml": {
      "type": "object",
      "properties": {
        "backtrace": {
          "$ref": "#/$defs/WorkflowComponentBacktraceConfig"
        },
        "env_vars": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/EnvVarConfig"
          }
        },
        "forward_stderr": {
          "$ref": "#/$defs/StdOutput"
        },
        "forward_stdout": {
          "$ref": "#/$defs/StdOutput"
        },
        "http_server": {
          "$ref": "#/$defs/ConfigName"
        },
        "location": {
          "$ref": "#/$defs/ComponentLocation"
        },
        "name": {
          "$ref": "#/$defs/ConfigName"
        },
        "routes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/WebhookRoute"
          }
        }
      },
      "additionalProperties": false,
      "required": [
        "name",
        "location",
        "http_server",
        "routes"
      ]
    },
    "WebhookRoute": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "$ref": "#/$defs/WebhookRouteDetail"
        }
      ]
    },
    "WebhookRouteDetail": {
      "type": "object",
      "properties": {
        "methods": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        },
        "route": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "route"
      ]
    },
    "WorkflowComponentBacktraceConfig": {
      "type": "object",
      "properties": {
        "sources": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false,
      "required": [
        "sources"
      ]
    },
    "WorkflowComponentConfigToml": {
      "type": "object",
      "properties": {
        "backtrace": {
          "$ref": "#/$defs/WorkflowComponentBacktraceConfig"
        },
        "blocking_strategy": {
          "$ref": "#/$defs/BlockingStrategyConfigToml"
        },
        "convert_core_module": {
          "type": "boolean",
          "default": true
        },
        "exec": {
          "$ref": "#/$defs/ExecConfigToml"
        },
        "location": {
          "$ref": "#/$defs/ComponentLocation"
        },
        "lock_extension": {
          "$ref": "#/$defs/DurationConfig"
        },
        "name": {
          "$ref": "#/$defs/ConfigName"
        },
        "retry_exp_backoff": {
          "$ref": "#/$defs/DurationConfig"
        },
        "stub_wasi": {
          "type": "boolean",
          "default": false
        }
      },
      "additionalProperties": false,
      "required": [
        "name",
        "location"
      ]
    },
    "WorkflowsGlobalConfigToml": {
      "type": "object",
      "properties": {
        "lock_extension_leeway": {
          "$ref": "#/$defs/DurationConfig"
        }
      },
      "additionalProperties": false
    }
  }
}
