GreenGate
File an issue and walk away. Duo agents ship it to production, every decision is weighed in carbon, and every issue closes with an SCI carbon receipt.
Path A: Start Fresh - Hands-off. Also entered for Most Environmentally Impactful (SCI-quantified) and Most Stages Covered. Deployed on Google Cloud (Cloud Run, OpenTofu in the repo).
Inspiration
AI agents are about to write and ship a lot of software. Each change costs energy: CI runs, agent sessions, LLM calls, and, for as long as it's in production, the code itself. Nobody sees that cost per change. Carbon tools report emissions per month, per cloud account, after the fact. We wanted the agents doing the work to see what each change costs in carbon while they work, and to have a number that anyone can check.
What it does
GreenGate is a hands-off, carbon-aware delivery loop on the GitLab Duo Agent Platform. A human files an issue and assigns it. From there:
greengate-delivery(Duo flow) plans the change, writes the code and tests, tests only the Go packages the change affects, and opens an MR.- CI runs tests, golangci-lint, SAST, Secret Detection, Dependency Scanning, and the carbon gate: a paired benchmark of the base and the change, converted to energy and gCO2e per 1k requests. It fails a slowdown of more than 5% that is statistically significant (Mann-Whitney U, p < 0.05). Path rules built from
go listskip jobs a change can't affect, and a check in CI makes sure those rules never miss a file. - If anything fails,
greengate-fixer(a second Duo flow, started by CI) reads the job logs, reproduces the failure, pushes a fix, and explains it with a before/after table. If two fix attempts in a row fail, it hands the MR to a human. greengate:automergemerges the MR once it is green.- Deploy: the image goes to Artifact Registry. Staging runs on Cloud Run in the lowest-carbon candidate region. Prod rolls out as a canary, gets a smoke test, takes 10% of traffic, then 100%. Prod runs in europe-north1 (29.8 gCO2e/kWh, versus 432 in us-central1).
- Receipt: after the deploy,
greengate receiptposts an SCI carbon receipt (Green Software Foundation, ISO/IEC 21031) on the MR and the issue. It covers every CI job, every Duo session's runner, and an estimate of the agents' LLM inference energy, itemized, with method and sources. It also writes an Impact Framework manifest that the GSF's ownif-runreproduces to the last digit.
DevSecOps stages covered
| Stage | What GreenGate automates |
|---|---|
| Plan | The delivery agent reads the issue and posts a plan |
| Create | The agent writes the code and tests, and opens the MR |
| Verify | Tests, golangci-lint, and the carbon regression gate. greengate affected runs only the jobs a change can affect, and checks that the path rules never miss a file |
| Secure | SAST, Secret Detection, Dependency Scanning, and a guard job that blocks agent MRs touching CI, infra, or scripts |
| Package | A distroless container image pushed to Artifact Registry |
| Release | Automerge once green, then a canary revision with a smoke test, 10% of traffic, and 100% |
| Deploy / Configure | Cloud Run staging in the lowest-carbon region, prod in europe-north1, all infrastructure as OpenTofu, keyless auth through GitLab OIDC |
| Monitor | A post-deploy smoke test, /metrics, and the SCI receipt for every change |
| Govern | Least-privilege, environment-scoped agent tokens with a documented threat model, plus receipts and Impact Framework manifests kept forever as an audit trail |
Results
- Fully hands-off: issue #5 (thumbnail cache) went from assignment to production in 20 minutes, with no human action after assigning the issue. The receipt was posted on the issue.
- Self-repair: in !2 an agent shipped a resize that was +775% slower. The carbon gate blocked it, and in about 4 minutes the fixer flow restored the fast path, finishing −4.3% versus the base. The MR then merged and deployed hands-off.
- Agents are the main cost, so we measured them. On a delivery receipt, the LLM estimate was 71–81% of the total. Capping the agents' prose (plans, MR descriptions, final answers) cut output tokens, the expensive ones at about 18× the energy of input tokens. The next delivery used 46% less LLM energy (one run, partly a smaller issue; about 3.3 Wh of it came from the shorter prose).
- Less CI: a docs-only change now runs 1 job instead of 6. A cache fix cut the lint job from 77 s to 32 s.
- Ten issues, filed one at a time and left alone: 8 merged hands-off (2 after the fixer: one carbon regression, one lint failure). One was handed to a human after two fixer passes. In one, the agent spotted that the issue contradicted an earlier change and asked for input instead of shipping. Issue to merge took 6–19 minutes.
- Measured gain over a naive agent loop (paired benchmarks, n = 8): a clean change costs about 0.3 g of extra CI and pays it back after about 115k requests, because prod runs at about a fifth of us-central1's carbon per request. The carbon gate caught a +19% regression in H1, and the fixer shipped a version 13.5% faster than the naive loop's. That fix cost 5.6 g, mostly LLM, so it takes 2.2M requests to repay. We report that honestly: the gate pays off on the tail it catches (the seeded +775%), not on every change. The full results, uncertainty, and the experiment's own 107 g footprint are in
docs/SCI.md.
How we built it
greengate, a Go CLI (standard library plus GitLab's officialclient-go) used by both CI and the agents:regions,sci,bench-gate,receipt,affected,automerge,fixer,gain.- SCI model:
SCI = ((E × I) + M) per R, using Cloud Carbon Footprint coefficients and Google Cloud's published 2025 grid intensity per region. Every coefficient is cited indocs/SCI.md. - LLM energy: read from each Duo session's trace (calls and tokens), with energy fitted to Jegham et al.'s per-model measurements. It is always labelled as an estimate, and its bounds are stated on the receipt.
- Agents: two custom Duo flows in
.gitlab/duo/flows/, chained through CI (flow triggers only fire on human actions, so CI starts the fixer through the Duo Workflows API). - Google Cloud: Cloud Run (staging and prod, canary traffic split), Artifact Registry, and Workload Identity Federation from GitLab OIDC (no service account keys). All of it is OpenTofu in
infra/, with state in GCS. - Demo service:
thumbd, a CPU-bound Go thumbnail API, so code changes have a measurable energy cost.
Challenges we ran into
- Merging without Maintainer access. The flow's identity can open MRs but can't merge them or start other flows, and participants can't protect branches. We use a fine-grained, project-only, short-lived token in a masked, hidden, environment-scoped variable that only two jobs can reach. A guard job fails any agent MR that touches CI, infra, or scripts. The residual risk is documented in the README.
- Agent → pipeline → agent chaining. Flow triggers ignore bot actions, so the fixer is started by a CI job through the API. That needed a user-level "Duo Workflow Create" permission we found in GitLab's source.
- Estimating LLM energy honestly. No provider publishes it per call. We fitted a published per-model study, stated every assumption, and kept the estimate on separate, labelled receipt lines.
- Noisy benchmarks on shared runners. We alternate base and head runs on the same runner and use a rank test, so the gate fails only on real regressions.
Accomplishments that we're proud of
- A real issue → production loop with no human in it, including repair when an agent gets it wrong.
- Every carbon number is traceable to a source, and an independent tool (GSF Impact Framework) reproduces the receipts exactly.
- Carbon is a signal inside the agents' loop, not a report after the fact.
What we learned
- In an agent delivery loop, the agents' own inference is most of the footprint, more than CI or the deploy. Output tokens dominate, so concise agents are greener agents.
- Go's test cache already skips unchanged packages. The real CI saving is skipping whole jobs, and that is only safe when a tool checks the path rules.
- A carbon gate needs statistics. Without paired runs and a significance test, a shared runner's noise looks like a regression.
What's next for GreenGate
- Carbon-aware scheduling of deferrable jobs (
window) once live grid intensity data is available. - A rightsizer flow that tunes Cloud Run CPU, memory, and concurrency from metrics.
- A carbon-reviewer agent for energy anti-patterns, and the fixer for security findings (today the scanners report, and the fixer handles tests, lint, and the carbon gate).
- A scheduled runtime SCI monitor, carbon budgets as MR policy, and a Pages dashboard of SCI per MR over time.
- Measuring the prompt's carbon guidance on its own (a no-guidance flow arm).
Built with
Go - GitLab Duo Agent Platform - GitLab CI/CD - GitLab SAST / Secret Detection / Dependency Scanning - Google Cloud Run - Artifact Registry - Workload Identity Federation - OpenTofu - Green Software Foundation SCI - Impact Framework - golangci-lint - Docker (distroless)
Try it out
- Repository (MIT): https://gitlab.com/gitlab-ai-hackathon/transcend-october-2026/5958906/showcase
- Live service on Google Cloud Run, deployed by the loop: https://thumbd-prod-3epb2typ3q-lz.a.run.app (
/health,POST /thumbnail) - Demo video: https://youtu.be/mmc2mukucYQ
Testing instructions
See the loop's history (no setup):
- MR !3 / issue #5: fully hands-off delivery. The plan comment, the MR, the pipeline, and the carbon receipt on both.
- MR !2 / issue #4: the carbon gate blocks a +775% regression, and the fixer's commit and MR note explain the fix.
- MR !4 / issue #6: a receipt with CI jobs, the Duo session runner, and the LLM estimate.
- Experiment issues #9–#18 (label
experiment): ten issues taken through the loop one at a time. MRs !7–!15, results indocs/SCI.md§ Measured gain and the data inexperiment/results/(go run ./cmd/greengate gain -spec experiment/results/experiment.jsonreproduces the table). - CI/CD → Pipelines: every run above.
greengate:receiptartifacts keepreceipt.md,receipt.json, andreceipt.manifest.yml.
Try the live service (Google Cloud Run, europe-north1):
curl https://thumbd-prod-3epb2typ3q-lz.a.run.app/health
curl -X POST --data-binary @image.png 'https://thumbd-prod-3epb2typ3q-lz.a.run.app/thumbnail?w=128' > thumb.jpg
Run the carbon engine locally (Go 1.27):
git clone https://gitlab.com/gitlab-ai-hackathon/transcend-october-2026/5958906/showcase.git greengate && cd greengate
go test ./...
go run ./cmd/greengate regions -candidates us-east1,us-central1,europe-north1
go run ./cmd/greengate bench-gate -base cmd/greengate/testdata/bench-base.txt -head cmd/greengate/testdata/bench-slow.txt -region europe-north1
go run ./cmd/greengate receipt -jobs cmd/greengate/testdata/jobs.json -title '!7' -manifest receipt.manifest.yml
npx --package @grnsft/[email protected] if-run -m receipt.manifest.yml # GSF Impact Framework reproduces the receipt
Run the loop yourself: the flows are enabled in this project, so a member with Developer access can file an issue, assign it to GreenGate Delivery, and watch the plan, MR, pipeline, deploy, and receipt arrive (6–20 minutes). Without access, the issues, MRs, and pipelines listed above show complete runs, and the video shows one end to end. To set the loop up in your own project, see the README sections "Run the loop in this project" and "Set up the loop in your own project".
Built With
- docker
- gitlab-duo-agent-platform
- go
- google-cloud
- google-cloud-run
- opentofu
Log in or sign up for Devpost to join the conversation.