KEDA Autoscaling & Git Branching Operators
Tharior Remedai leverages Kubernetes Custom Resource Definitions (CRDs) and specialized operators for dynamic pod scaling and Git branch lifecycle management.
1. KEDA Multi-Component Autoscaling Architecture
Tharior Remedai decouples into three specialized operational roles with custom KEDA autoscaling profiles:
-
BFF / Gateway (
remedai-bff): Runs 1 minimal replica when idle to maintain instant responsiveness for webhooks, UI desk, and healthchecks. Scales dynamically up to 10 replicas via KEDA ScaledObject when CPU exceeds 70% or Memory exceeds 75%. -
Scheduler (
remedai-scheduler): Runs 1 minimal replica when idle for background timers. Scales up to 5 replicas via KEDA Cron / task queues during weekly OpenRouter catalog syncs and batch repository maintenance sweeps. -
Agentic Worker (
remedai-agent-worker): Operates in Scale-to-Zero mode (0 replicas when idle)! When remediation tasks, PR reviews, or AST synthesis requests arrive, KEDA provisions isolated ephemeral worker pods scaling from 0 to 50 jobs dynamically.
2. Multi-Tenant Session Isolation & Memory Fences
Strict sandboxing ensures zero cross-session context overlap, memory leaks, or file disclosure:
Each tenant session is allocated an isolated directory in /tmp/sandboxes/{tenant}_{user}_{session}
with POSIX 0700 permission masks, strictly prohibiting unauthorized read/write access.
Ephemeral Kubernetes emptyDir scratchpads with automated lifecycle sweeps ensure all temporary files,
AST traces, and git artifacts are completely wiped upon task completion.
Pod resource managers enforce a strict 75% memory and CPU threshold, preserving 25% operational headroom for Python generational garbage collection and adaptive chunk size reduction.
Workload NetworkPolicies restrict worker pod egress strictly to external LLM providers and VCS endpoints, blocking lateral pod-to-pod network traffic.
3. Git Branching Lifecycle Operator (`branch_operator.py`)
The Branch Operator enforces clean Git practices across all remediation pipelines:
Converts issue metadata into sanitized branch names conforming to standards:
tharior/fix-{TICKET_ID}-{slug}.
Rebases remediation branches on the latest trunk HEAD prior to pull request generation to detect merge conflicts early.
Automatically prunes ephemeral branches from git repositories once pull requests are merged or closed.
4. Kubernetes Deployment Blueprints & Helm Chart
Manifests located in deploy/k8s/ and deploy/k8s/resilient-app/:
app-config.yaml: Top-level unified config blueprint for BFF, Scheduler, and Agent Workers.deploy/k8s/resilient-app/: Complete production Helm chart supporting GKE Spot VMs and KEDA.deploy/k8s/keda-scaledobject.yaml: ScaledObjects for BFF (min 1) and Scheduler (min 1).deploy/k8s/keda-scaledjob.yaml: ScaledJob for Agent Workers with Scale-to-Zero (min 0).deploy/k8s/crd-remediation-branch.yaml: CRD forRemediationBranchresource.deploy/k8s/keda-operator-deployment.yaml: Complete KEDA v2.14 operator and metrics server deployment.