# Orchestrator Storage Configuration Fragment

[[elements]]
border_top = true
border_bottom = false
name = "storage_section_header"
title = "💾 Storage Configuration"
type = "section_header"

# Storage Backend Selection
[[elements]]
default = "filesystem"
help = "Storage backend for workflow state and artifacts"
name = "storage_backend"
nickel_path = ["orchestrator", "storage", "backend"]
options = ["filesystem", "surrealdb_embedded", "surrealdb_server"]
prompt = "Storage Backend"
type = "select"

# Filesystem Storage (conditional)
[[elements]]
condition = "storage_backend == 'filesystem'"
default = "/var/lib/provisioning/orchestrator/data"
help = "Path for local filesystem storage (absolute path required)"
name = "storage_path"
nickel_path = ["orchestrator", "storage", "path"]
prompt = "Storage Path"
required = true
type = "text"

# SurrealDB Embedded (conditional)
[[elements]]
condition = "storage_backend == 'surrealdb_embedded'"
default = "/var/lib/provisioning/orchestrator/surrealdb"
help = "Path for embedded SurrealDB data directory"
name = "surrealdb_embedded_path"
nickel_path = ["orchestrator", "storage", "path"]
prompt = "SurrealDB Data Path"
required = true
type = "text"

# SurrealDB Server (conditional)
[[elements]]
condition = "storage_backend == 'surrealdb_server'"
default = "http://localhost:8000"
help = "URL for SurrealDB server (e.g., http://surrealdb:8000)"
name = "surrealdb_url"
nickel_path = ["orchestrator", "storage", "surrealdb_url"]
prompt = "SurrealDB URL"
required = true
type = "text"

[[elements]]
condition = "storage_backend == 'surrealdb_server'"
default = "provisioning"
help = "SurrealDB namespace"
name = "surrealdb_namespace"
nickel_path = ["orchestrator", "storage", "surrealdb_namespace"]
prompt = "Namespace"
required = true
type = "text"

[[elements]]
condition = "storage_backend == 'surrealdb_server'"
default = "orchestrator"
help = "SurrealDB database name"
name = "surrealdb_database"
nickel_path = ["orchestrator", "storage", "surrealdb_database"]
prompt = "Database"
required = true
type = "text"

# Storage Cache Configuration
[[elements]]
default = false
help = "Enable storage caching for improved performance"
name = "storage_cache_enabled"
nickel_path = ["orchestrator", "storage", "cache", "enabled"]
prompt = "Enable Storage Cache"
type = "confirm"

[[elements]]
condition = "storage_cache_enabled == true"
default = "lru"
help = "Cache eviction policy"
name = "storage_cache_eviction_policy"
nickel_path = ["orchestrator", "storage", "cache", "eviction_policy"]
options = ["lru", "lfu", "fifo"]
prompt = "Cache Eviction Policy"
type = "select"

[[elements]]
condition = "storage_cache_enabled == true"
default = 3600
help = "Cache TTL in seconds (range: 60-86400)"
max = 86400
min = 60
name = "storage_cache_ttl"
nickel_path = ["orchestrator", "storage", "cache", "ttl"]
prompt = "Cache TTL (seconds)"
type = "number"

[[elements]]
condition = "storage_cache_enabled == true"
default = 1000
help = "Maximum cache entries (range: 10-1000000)"
max = 1000000
min = 10
name = "storage_cache_max_entries"
nickel_path = ["orchestrator", "storage", "cache", "max_entries"]
prompt = "Max Cache Entries"
type = "number"

# Storage Compression Configuration
[[elements]]
default = false
help = "Enable compression for stored data"
name = "storage_compression_enabled"
nickel_path = ["orchestrator", "storage", "compression", "enabled"]
prompt = "Enable Compression"
type = "confirm"

[[elements]]
condition = "storage_compression_enabled == true"
default = "snappy"
help = "Compression algorithm"
name = "storage_compression_algorithm"
nickel_path = ["orchestrator", "storage", "compression", "algorithm"]
options = ["snappy", "zstd", "gzip"]
prompt = "Compression Algorithm"
type = "select"

[[elements]]
condition = "storage_compression_enabled == true && storage_compression_algorithm == 'zstd'"
default = 3
help = "Compression level (1-19, higher = better compression but slower)"
min = 1
max = 19
name = "storage_compression_level"
nickel_path = ["orchestrator", "storage", "compression", "level"]
prompt = "Compression Level"
type = "number"

# Storage Garbage Collection
[[elements]]
default = true
help = "Enable automatic garbage collection of orphaned artifacts"
name = "storage_gc_enabled"
nickel_path = ["orchestrator", "storage", "gc", "enabled"]
prompt = "Enable Garbage Collection"
type = "confirm"

[[elements]]
condition = "storage_gc_enabled == true"
default = 604800
help = "Retention period for artifacts in seconds (default: 7 days, range: 3600-31536000)"
max = 31536000
min = 3600
name = "storage_gc_retention"
nickel_path = ["orchestrator", "storage", "gc", "retention_seconds"]
prompt = "GC Retention (seconds)"
type = "number"

[[elements]]
condition = "storage_gc_enabled == true"
default = 3600
help = "Garbage collection interval in seconds (default: 1 hour, range: 300-86400)"
max = 86400
min = 300
name = "storage_gc_interval"
nickel_path = ["orchestrator", "storage", "gc", "interval_seconds"]
prompt = "GC Interval (seconds)"
type = "number"
