{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/dagger/dagger/engine/config/config",
  "$ref": "#/$defs/Config",
  "$defs": {
    "CacheVolumesConfig": {
      "properties": {
        "dir": {
          "type": "string",
          "description": "Dir, when set, keeps every cache volume as a plain directory under this absolute path, apart from the engine's snapshots, instead of as a snapshot. Another engine given the same directory later reuses its volumes. One engine uses the directory at a time: an engine that finds it in use keeps cache volumes as snapshots. It must not be inside the engine's worker state directory."
        },
        "capacityBytes": {
          "type": "integer",
          "description": "CapacityBytes is the provisioned size, in bytes, of the storage that holds Dir, such as a cache volume created at a given size. Set it when the filesystem's own size isn't the limit to keep to. Garbage collection keeps the directory's volumes within 80% of it, removing the least recently used first. When unset, the directory's own filesystem sets the limits, as the engine's defaults do for its state."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "Config": {
      "properties": {
        "logLevel": {
          "type": "string",
          "enum": [
            "error",
            "warn",
            "info",
            "debug",
            "debugextra",
            "trace"
          ],
          "description": "LogLevel defines the engine's logging level."
        },
        "telemetry": {
          "$ref": "#/$defs/TelemetryConfig",
          "description": "Telemetry configures the engine's own telemetry, separate from client telemetry."
        },
        "remoteCache": {
          "$ref": "#/$defs/RemoteCacheConfig",
          "description": "RemoteCache connects the engine's cache to a remote cache service."
        },
        "gc": {
          "$ref": "#/$defs/GCConfig",
          "description": "GC configures the engine's garbage collector."
        },
        "security": {
          "$ref": "#/$defs/Security",
          "description": "Security allows configuring various security settings for the engine."
        },
        "registries": {
          "additionalProperties": {
            "$ref": "#/$defs/RegistryConfig"
          },
          "type": "object",
          "description": "Registries configures custom registry mirrors, root CAs, and insecure/HTTP access."
        },
        "shutdown": {
          "$ref": "#/$defs/ShutdownConfig",
          "description": "Shutdown configures how the engine stops."
        },
        "cacheVolumes": {
          "$ref": "#/$defs/CacheVolumesConfig",
          "description": "CacheVolumes configures where the engine keeps cache volumes."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "DagqlCacheGCConfig": {
      "properties": {
        "maxEstimatedBytes": {
          "type": "integer",
          "description": "MaxEstimatedBytes triggers structural DAGQL cache pruning when the coarse metadata estimate exceeds this absolute number of bytes. Zero uses the built-in default."
        },
        "targetEstimatedBytes": {
          "type": "integer",
          "description": "TargetEstimatedBytes is the lower structural estimate a pruning pass attempts to reach. Zero uses the built-in default."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "DiskSpace": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[0-9][0-9.]*([kKmMgGtTpP][iI]?)?[bB]?$"
        },
        {
          "type": "string",
          "pattern": "^[0-9]+%$"
        },
        {
          "type": "number"
        }
      ],
      "description": "DiskSpace is either an integer number of bytes (e.g. 512000000), a string with a byte unit suffix (e.g. \"512MB\"), or a string percentage of the total disk space (e.g. \"10%\")."
    },
    "Duration": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$"
        },
        {
          "type": "string",
          "pattern": "^[0-9]+$"
        },
        {
          "type": "number"
        }
      ],
      "description": "Duration is either an integer number of seconds (e.g. 3600), or a string representation of the time (e.g. \"1h30m\")."
    },
    "GCConfig": {
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "Enabled controls whether the garbage collector is enabled - it is switched on by default (and generally shouldn't be turned off, except for very short-lived dagger instances)."
        },
        "dagqlCache": {
          "$ref": "#/$defs/DagqlCacheGCConfig",
          "description": "DagqlCache configures structural memory pruning for the in-memory DAGQL cache independently of physical cache disk usage."
        },
        "reservedSpace": {
          "$ref": "#/$defs/DiskSpace",
          "description": "ReservedSpace is the minimum amount of disk space this policy is guaranteed to retain. Any usage below this threshold will not be reclaimed during garbage collection."
        },
        "maxUsedSpace": {
          "$ref": "#/$defs/DiskSpace",
          "description": "MaxUsedSpace is the maximum amount of disk space this policy is allowed to use. Any usage exceeding this limit will be cleaned up during a garbage collection sweep."
        },
        "minFreeSpace": {
          "$ref": "#/$defs/DiskSpace",
          "description": "MinFreeSpace is the target amount of free disk space the garbage collector will attempt to leave. However, it will never let the available space fall below ReservedSpace."
        },
        "sweepSize": {
          "$ref": "#/$defs/DiskSpace",
          "description": "SweepSize is the minimum amount of space to sweep during a single gc pass. Either an absolute number of bytes, or a percentage of the \"allowed space\" between reserved and max."
        },
        "policies": {
          "items": {
            "$ref": "#/$defs/GCPolicy"
          },
          "type": "array",
          "description": "Policies are a list of manually configured policies - if not specified, an automatic default will be generated from the top-level disk space parameters."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "GCPolicy": {
      "properties": {
        "all": {
          "type": "boolean",
          "description": "All matches every cache record."
        },
        "filters": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "description": "Filters are a list of containerd filters to match specific cache records. The available filters are: \"id\", \"parents\", \"description\", \"inuse\", \"mutable\", \"immutable\", \"type\", \"shared\", and \"private\"."
        },
        "keepDuration": {
          "$ref": "#/$defs/Duration",
          "description": "KeepDuration specifies the minimum amount of time to keep records in this policy."
        },
        "reservedSpace": {
          "$ref": "#/$defs/DiskSpace",
          "description": "ReservedSpace is the minimum amount of disk space this policy is guaranteed to retain. Any usage below this threshold will not be reclaimed during garbage collection."
        },
        "maxUsedSpace": {
          "$ref": "#/$defs/DiskSpace",
          "description": "MaxUsedSpace is the maximum amount of disk space this policy is allowed to use. Any usage exceeding this limit will be cleaned up during a garbage collection sweep."
        },
        "minFreeSpace": {
          "$ref": "#/$defs/DiskSpace",
          "description": "MinFreeSpace is the target amount of free disk space the garbage collector will attempt to leave. However, it will never let the available space fall below ReservedSpace."
        },
        "sweepSize": {
          "$ref": "#/$defs/DiskSpace",
          "description": "SweepSize is the minimum amount of space to sweep during a single gc pass. Either an absolute number of bytes, or a percentage of the \"allowed space\" between reserved and max."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "RegistryConfig": {
      "properties": {
        "mirrors": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "http": {
          "type": "boolean"
        },
        "insecure": {
          "type": "boolean"
        },
        "ca": {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "mirrors",
        "http",
        "insecure",
        "ca"
      ]
    },
    "RemoteCacheConfig": {
      "properties": {
        "url": {
          "type": "string",
          "description": "URL is the remote cache service's URL. The engine connects to it when DAGGER_CLOUD_TOKEN holds an engine token, and then exports its cache events too. The _EXPERIMENTAL_DAGGER_REMOTE_CACHE_URL environment variable sets it too, and wins."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "Security": {
      "properties": {
        "insecureRootCapabilities": {
          "type": "boolean",
          "description": "InsecureRootCapabilities controls whether the argument of the same name is permitted in Container.withExec - it is allowed by default. Disabling this option ensures that dagger build containers do not run as privileged, and is a basic form of security hardening."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "ShutdownConfig": {
      "properties": {
        "gracefulStopTimeout": {
          "$ref": "#/$defs/Duration",
          "description": "GracefulStopTimeout bounds the engine's whole stop, from the first SIGTERM or SIGINT to process exit. The final telemetry flushes get what remains of it, at most 30s each. Set it below the grace period of whatever supervises the engine, so that the engine exits on its own rather than being killed. Defaults to 5m; when set, it must be positive."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "TelemetryConfig": {
      "properties": {
        "resourceMetrics": {
          "type": "boolean",
          "description": "ResourceMetrics enables cgroup v2 resource metrics for the engine process. It is disabled by default. Export requires OTEL_EXPORTER_OTLP_METRICS_ENDPOINT in the engine environment. Other OTLP settings use the standard environment variables. This does not change client or execution metric collection and export.",
          "default": false
        },
        "engineEvents": {
          "type": "boolean",
          "description": "EngineEvents enables the export of the engine's cache events to Dagger Cloud: its cache's start, prunes, snapshot sharing and stop. It is disabled by default. Export requires DAGGER_CLOUD_TOKEN in the engine environment, the credential it is sent under. The _EXPERIMENTAL_DAGGER_ENGINE_EVENTS environment variable enables it too.",
          "default": false
        }
      },
      "additionalProperties": false,
      "type": "object"
    }
  }
}
