feat: v0.3.0 — policy engine, suggestion comments, 14-region ledger#9
Merged
Conversation
## Policy Engine (policy.ts) - Zero-dependency YAML parser for .greenops.yml - Budget constraints: max_pr_co2e_increase_kg, max_pr_cost_increase_usd, max_total_co2e_kg - Fail-open: missing policy file always passes; parse errors are warnings not fatal - fail_on_violation flag controls exit code (1 = block PR, 0 = warn only) - 9 new tests covering all constraint paths, multi-violation collection, and error handling ## GitHub Suggestion Comments (suggestions.ts) - Posts inline Terraform suggestion comments using GitHub's suggestion syntax - Developer clicks 'Commit suggestion' to rewrite instance_type in-place - Zero runtime dependencies — uses Node 20 native fetch exclusively - Idempotent: existing GreenOps suggestion comments are updated, not duplicated - Fail-open: suggestion errors never block the CLI (exit 0 with warning) - Region-shift suggestions gracefully degrade with a warning (no single line to target) ## Expanded Methodology Ledger (factors.json v1.2.0) - Instances: 12 → 40 (adds t3a, m5a, m5.2xlarge, c5a, r5, t4g.micro/small/xlarge, m6g.medium/2xlarge, m7g family, c6g.medium/2xlarge, c7g family, r6g family) - Regions: 5 → 14 (adds us-east-2, us-west-1, eu-west-2, eu-north-1, ap-southeast-1, ap-northeast-1, ap-south-1, ca-central-1, sa-east-1) - eu-north-1 (Stockholm, 8.8 gCO2e/kWh) is now the cleanest supported region - All grid intensity values sourced from Electricity Maps 2024 annual averages - All pricing from AWS public pricing API Q1 2026 ## CLI updates (cli.ts) - New flags: --github-token, --repo, --pr-number, --commit-sha, --post-suggestions - Policy evaluation runs automatically when .greenops.yml is present - --help output updated with all new flags ## Action updates (action.yml) - New input: post-suggestions (default: false) — enables one-click Terraform patches - Updated description to reflect full capabilities ## Test updates - recommendation.test.ts: updated to reflect new 14-region ledger behaviour (eu-north-1 now wins scoring over ARM for high-carbon regions — correct behaviour) - integration.test.ts: updated math traces and assertions for v1.2.0 ledger - Total: 60 tests, 60 passing ## npm fix - package.json: license field now present (was missing, causing npm to show 'None')
🌱 GreenOps Infrastructure Impact
Resource Breakdown
Recommendations
|
omrdev1
added a commit
that referenced
this pull request
May 19, 2026
## Policy Engine (policy.ts) - Zero-dependency YAML parser for .greenops.yml - Budget constraints: max_pr_co2e_increase_kg, max_pr_cost_increase_usd, max_total_co2e_kg - Fail-open: missing policy file always passes; parse errors are warnings not fatal - fail_on_violation flag controls exit code (1 = block PR, 0 = warn only) - 9 new tests covering all constraint paths, multi-violation collection, and error handling ## GitHub Suggestion Comments (suggestions.ts) - Posts inline Terraform suggestion comments using GitHub's suggestion syntax - Developer clicks 'Commit suggestion' to rewrite instance_type in-place - Zero runtime dependencies — uses Node 20 native fetch exclusively - Idempotent: existing GreenOps suggestion comments are updated, not duplicated - Fail-open: suggestion errors never block the CLI (exit 0 with warning) - Region-shift suggestions gracefully degrade with a warning (no single line to target) ## Expanded Methodology Ledger (factors.json v1.2.0) - Instances: 12 → 40 (adds t3a, m5a, m5.2xlarge, c5a, r5, t4g.micro/small/xlarge, m6g.medium/2xlarge, m7g family, c6g.medium/2xlarge, c7g family, r6g family) - Regions: 5 → 14 (adds us-east-2, us-west-1, eu-west-2, eu-north-1, ap-southeast-1, ap-northeast-1, ap-south-1, ca-central-1, sa-east-1) - eu-north-1 (Stockholm, 8.8 gCO2e/kWh) is now the cleanest supported region - All grid intensity values sourced from Electricity Maps 2024 annual averages - All pricing from AWS public pricing API Q1 2026 ## CLI updates (cli.ts) - New flags: --github-token, --repo, --pr-number, --commit-sha, --post-suggestions - Policy evaluation runs automatically when .greenops.yml is present - --help output updated with all new flags ## Action updates (action.yml) - New input: post-suggestions (default: false) — enables one-click Terraform patches - Updated description to reflect full capabilities ## Test updates - recommendation.test.ts: updated to reflect new 14-region ledger behaviour (eu-north-1 now wins scoring over ARM for high-carbon regions — correct behaviour) - integration.test.ts: updated math traces and assertions for v1.2.0 ledger - Total: 60 tests, 60 passing ## npm fix - package.json: license field now present (was missing, causing npm to show 'None') Co-authored-by: GreenOps E2E <greenops-e2e@test.local>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three additive features built on top of the existing offline-first, zero-dependency architecture. Nothing deleted, everything strengthened.
1.
.greenops.ymlPolicy EngineTeams can now define carbon budgets that are enforced on every PR:
.greenops.yml= always passes; parse errors are warnings not fatalfail_on_violation: trueexits with code 1, blocking the PR2. GitHub Inline Suggestion Comments
When
--post-suggestionsis enabled, GreenOps posts suggestion comments directly on the Terraform lines that need changing. The developer clicks Commit suggestion and theinstance_typeis rewritten in-place:fetchexclusively3. Expanded Methodology Ledger (v1.2.0)
New families:
t3a,m5a,m7g,c7g,r6g,c5a,r5,m5.2xlarge,c5.2xlargeNew regions:
us-east-2,us-west-1,eu-west-2,eu-north-1(Stockholm, 8.8 gCO2e/kWh),ap-southeast-1,ap-northeast-1,ap-south-1,ca-central-1,sa-east-1Tests
60 tests, 60 passing. Includes 9 new policy engine tests.
npm license fix
package.jsonwas missing thelicensefield, causing npm to displayNone. Fixed.