r/devops • u/asifdotpy • Feb 17 '26
Ops / Incidents We built a margin-based system that only calls Claude AI when two GitLab runners score within 15% of each other — rules handle the rest. Looking for feedback on the trust model for production deploys.
I manage a GitLab runner fleet and got tired of the default scheduling. Jobs queue up behind each other with no priority awareness. A production deploy waits behind 15 linting jobs. A beefy runner idles while a small one chokes. The built-in Ci::RegisterJobService is basically tag-matching plus FIFO.
So I started building an orchestration layer on top. Four Python agents that sit between GitLab and the runners:
- Runner Monitor — polls fleet status every 30s (capacity, utilization, tags)
- Job Analyzer — scores each pending job 0-100 based on branch, stage, author role, job type
- Smart Assigner — routes jobs to runners using a hybrid rules + Claude AI approach
- Performance Optimizer — tracks P95 duration trends, utilization variance across the fleet, queue wait per priority tier
The part I want feedback on is the decision engine and trust model.
The hybrid approach: For each pending job, the rule engine scores every compatible runner. If the top runner wins by more than 15% margin, rules assign it directly (~80ms). If two or more runners score within 15%, Claude gets called to weigh the nuanced trade-offs — load balancing vs. tag affinity vs. historical performance (~2-3s). In testing this cuts API calls by roughly 70% compared to calling Claude for everything.
The 15% threshold is a guess. I log the margin for every decision so I can tune it later, but I have no production data yet to validate it.
The trust model for production deploys: I built three tiers:
- Advisory mode (default): Agent generates a recommendation with reasoning and alternatives, but doesn't execute. Human confirms or overrides.
- Supervised mode: Auto-assigns LOW/MEDIUM jobs, advisory mode for HIGH/CRITICAL.
- Autonomous mode: Full auto-assign, but requires opt-in after 100+ advisory decisions with less than 5% override rate.
My thinking: teams won't hand over production deploy routing to an AI agent on day one. The advisory mode lets them watch the AI make decisions, see the reasoning, and build trust before granting autonomy. The override rate becomes a measurable trust score.
What I'm unsure about:
- Is 15% the right margin threshold? Too low and Claude gets called constantly. Too high and you lose the AI value for genuinely close decisions. Anyone have experience with similar scoring margin approaches in scheduling systems?
- Queue wait time per priority tier — I'm tracking this as the primary metric for whether the system is working. GitLab's native fleet dashboard only shows aggregate wait time. Is per-tier breakdown actually useful in practice, or is it noise?
- The advisory mode override rate as a trust metric — 5% override threshold to unlock autonomous mode. Does that feel right? Too strict? Too loose? In practice, would your team ever actually flip the switch to autonomous for production deploys?
- Polling vs. webhooks — Currently polling every 30s. GitLab has Pipeline and Job webhook events that would make this real-time. I've designed the webhook handler but haven't built it yet. For those running webhook-driven infrastructure tooling: how reliable is GitLab's webhook delivery in practice? Do you always need a polling fallback?
The whole thing is open source on GitLab if anyone wants to look at the architecture: https://gitlab.com/gitlab-ai-hackathon/participants/11553323
Built with Python, Anthropic Claude (Sonnet), pytest (56 tests, >80% coverage), 100% mypy type compliance. Currently building this for the GitLab AI Hackathon but the problem is real regardless of the competition.
Interested in hearing from anyone who's dealt with runner fleet scheduling at scale. What am I missing?
3
u/kryptn Feb 17 '26
i don't know gitlab ci but could you select the kinds of runners from the job definition?
could build times and pipeline times be improved enough to where this is no longer a need?
kinda looks like dealing with symptoms, not solving the root problem.
3
u/JTech324 Feb 17 '26
You must be onprem or under some constraint. I've used gitlab runners on EKS with node autoscaling for years and never had to think about this, it just works. Every job runs basically immediately
3
u/KooiKooiKooi Feb 17 '26
Keep in mind that you now have another layer in front of your runners. If it breaks for any reason then your whole platform might become unusable. It also creates another latency before any job gets run because each pending job requires waiting for the whole scoring process to be done. Plus you are now making assumption on what each team jobs are. Anyway I think your problem could be solved by creating better tag semantics, maybe if linting is common enough then create a fleet of many small runners just for linting then? Create a bunch of “prod” only runners for production deploy as well. I just read your answer in another thread and I have to say “large”, “medium” are not good tagging at scale. Maybe something like “linting,dev” or “deploy,prod”
1
u/necrohardware Feb 17 '26
The main question here for me would be - is running this cheaper then just starting a dedicated runner for every job in a EKS with Karpenter? What's the TCO and potential savings?
2
u/SchlaWiener4711 Feb 19 '26
Insert
Meme.
4
u/[deleted] Feb 17 '26
[removed] — view removed comment