Skip to content

Add model policy frontmatter + import unioning + env policy overrides#41824

Open
Copilot wants to merge 8 commits into
mainfrom
copilot/add-frontmatter-models-fields
Open

Add model policy frontmatter + import unioning + env policy overrides#41824
Copilot wants to merge 8 commits into
mainfrom
copilot/add-frontmatter-models-fields

Conversation

Copilot AI commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

This change introduces model policy controls in workflow frontmatter (models.allowed, models.disallowed, models.blocked) and maps them to AWF’s allowedModels / disallowedModels config. It also makes policy behavior import-safe by unioning model sets across composed workflows, with centralized environment overrides taking precedence.

  • Frontmatter + schema support

    • Extended models frontmatter schema to support policy fields alongside optional pricing providers.
    • Added typed parsing for:
      • models.allowed
      • models.disallowed
      • models.blocked
  • Import compatibility (union semantics)

    • Extended import extraction/results to carry model policy sets from imported workflows.
    • Added workflow merge logic to union policy sets across imports + main workflow.
    • Normalized deny behavior by combining disallowed and blocked into a single blocked set for runtime policy emission.
  • Centralized policy overrides

    • Added compiler env overrides:
      • GHAW_POLICY_MODELS_ALLOWED
      • GHAW_POLICY_MODELS_BLOCKED
    • Override values are parsed as model lists and applied with precedence over frontmatter/import-derived policy.
  • AWF config mapping

    • Emitted merged/effective policy into AWF config:
      • apiProxy.allowedModels
      • apiProxy.disallowedModels
# workflow frontmatter
models:
  allowed: [gpt-5, claude-sonnet]
  disallowed: [gpt-5-pro]
  blocked: [claude-opus]
// generated AWF apiProxy fragment
{
  "allowedModels": ["gpt-5", "claude-sonnet"],
  "disallowedModels": ["gpt-5-pro", "claude-opus"]
}

pr-sous-chef run: https://github.com/github/gh-aw/actions/runs/28287576045

Generated by 👨‍🍳 PR Sous Chef · 92.6 AIC · ⌖ 0.951 AIC · ⊞ 17.2K ·


pr-sous-chef run: https://github.com/github/gh-aw/actions/runs/28288509195

Generated by 👨‍🍳 PR Sous Chef · 71.1 AIC · ⌖ 0.943 AIC · ⊞ 17.1K ·


https://github.com/github/gh-aw/actions/runs/28293057253

Generated by 👨‍🍳 PR Sous Chef · 69.1 AIC · ⌖ 0.98 AIC · ⊞ 17.1K ·


Generated by 👨‍🍳 PR Sous Chef · 48.2 AIC · ⌖ 0.974 AIC · ⊞ 17.1K ·

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review June 27, 2026 01:19
Copilot AI review requested due to automatic review settings June 27, 2026 01:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds end-to-end “model policy” support to gh-aw workflows, allowing authors (and centralized operators via env vars) to control which models are permitted/blocked, and ensuring policies compose safely across imported workflows before being emitted into the generated AWF config.

Changes:

  • Extended workflow frontmatter models to support allowed, disallowed, and blocked policy lists (alongside optional pricing providers).
  • Propagated model policy through import extraction and merged policies across imports + main workflow using union semantics.
  • Emitted effective model policy to AWF config (apiProxy.allowedModels / apiProxy.disallowedModels) with env override precedence.
Show a summary per file
File Description
pkg/workflow/workflow_builder.go Extracts main workflow model policy and unions it with imported policy sets into WorkflowData.
pkg/workflow/workflow_builder_model_policy_test.go Adds unit tests for policy extraction and union merge behavior.
pkg/workflow/model_aliases_test.go Verifies frontmatter parsing populates parsed model policy lists.
pkg/workflow/frontmatter_types.go Adds parsed frontmatter fields for model policy lists.
pkg/workflow/frontmatter_parsing.go Parses model policy lists from raw frontmatter into typed config.
pkg/workflow/compilerenv/manager.go Adds env-driven policy overrides for allowed/blocked model sets.
pkg/workflow/compilerenv/manager_test.go Tests env override parsing and “unset” behavior.
pkg/workflow/compiler_types.go Plumbs merged model policy into WorkflowData.
pkg/workflow/awf_config.go Maps effective model policy (with env precedence) into AWF apiProxy config.
pkg/workflow/awf_config_test.go Tests AWF config emission and env override precedence.
pkg/parser/schemas/main_workflow_schema.json Updates schema for models to include policy fields and make providers optional.
pkg/parser/import_processor.go Extends ImportsResult to carry extracted model policy sets.
pkg/parser/import_field_extractor.go Extracts model policy from imported workflows and avoids treating policy keys as aliases.
pkg/parser/import_field_extractor_test.go Adds tests ensuring model policy is extracted (and not misinterpreted as aliases) and can coexist with model costs.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (2)

pkg/parser/import_field_extractor.go:639

  • When an imported workflow has models.providers plus model policy keys (allowed/disallowed/blocked), this appends the entire rawModels object into acc.modelCosts. That will later flow into WorkflowData.ModelCosts and into GH_AW_INFO_MODEL_COSTS, leaking policy keys into a payload that is expected to match the models.json pricing structure (providers-only). This can break downstream cost merging/parsing.
	if _, hasProviders := rawModels["providers"]; hasProviders {
		acc.modelCosts = append(acc.modelCosts, rawModels)
		if providers, ok := rawModels["providers"].(map[string]any); ok {
			parserLog.Printf("Extracted model costs from import: providers=%d", len(providers))
		} else {

pkg/workflow/workflow_builder.go:166

  • Now that models frontmatter can contain policy keys (allowed/disallowed/blocked) without providers, toolsResult.parsedFrontmatter.ModelCosts may be non-empty even when there is no pricing data (because it unmarshals the whole models object). extractMainModelCostsOverlay currently returns that map as a cost overlay, which can cause policy-only models to be emitted as GH_AW_INFO_MODEL_COSTS and/or pollute the providers overlay with policy keys.
	}

	return workflowData
}

  • Files reviewed: 14/14 changed files
  • Comments generated: 0
  • Review effort level: Low

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Category feature
Risk 🔴 High
Priority High (score 50/100)
Action defer · Batch: active-drafts

Score breakdown: Impact 35 · Urgency 5 · Quality 10

New model policy frontmatter controls (models.allowed/disallowed/blocked) with import-safe union semantics (+483/-11, 14 files). Just created (<1 h), draft, no CI yet. Well-described and scoped. Deferred pending CI and agent completion. Part of pr-batch:active-drafts group (#41824, #41822, #41821).

Generated by 🔧 PR Triage Agent · 87.6 AIC · ⌖ 14.9 AIC · ⊞ 5.4K ·

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @Copilot 👋 — great work on the model policy frontmatter feature! The addition of models.allowed, models.disallowed, and models.blocked to workflow frontmatter — along with import-safe union semantics and centralized env overrides — is a well-scoped, coherent change.

The PR is well-structured:

  • ✅ Clear, detailed description with YAML/JSON examples showing the before/after config shape.
  • ✅ Tests across all touched layers: import_field_extractor_test.go, awf_config_test.go, compilerenv/manager_test.go, model_aliases_test.go, and the newly added workflow_builder_model_policy_test.go.
  • ✅ No unrelated changes — every file touched is in service of the model policy feature.
  • ✅ No new external dependencies introduced.

This looks ready for review. 🚀

Generated by ✅ Contribution Check · 307.9 AIC · ⌖ 20.6 AIC · ⊞ 6K ·

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot merge main and recompile

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan June 27, 2026 02:33
@pelikhan

Copy link
Copy Markdown
Collaborator

/review

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, rebase or merge main into this branch, and rerun the build/checks once the branch is current.

Generated by 👨‍🍳 PR Sous Chef · 92.6 AIC · ⌖ 0.951 AIC · ⊞ 17.2K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address the remaining review feedback about model-policy and cost-overlay handling, rebase or merge main into this branch, and rerun the build/checks once the branch is current.

Generated by 👨‍🍳 PR Sous Chef · 71.1 AIC · ⌖ 0.943 AIC · ⊞ 17.1K ·

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

PR Triage Update — §28289524040

Field Value
Category feature
Risk high
Score 70 / 100 — impact 38, urgency 20, quality 12
Action fast_track — model policy feature ready for expedited review
Batch feature-promo (review with #41777 + #41821)

Label conflict: pr-action:defer label is stale (from draft state) and should be removed manually. pr-batch:active-drafts is also stale — PR is no longer a draft. Correct labels: pr-action:fast_track, pr-batch:feature-promo.

Generated by 🔧 PR Triage Agent · 90.3 AIC · ⌖ 11.7 AIC · ⊞ 5.4K ·

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot remove "blocked" since dissallow is the same field

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, rebase this branch from main, address the remaining model-policy review feedback, and rerun checks once the branch is current.

Generated by 👨‍🍳 PR Sous Chef · 69.1 AIC · ⌖ 0.98 AIC · ⊞ 17.1K ·

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot

  • apply model disallowed opus to smoke-claude

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address unresolved review comments, refresh the branch from base, and rerun checks once it is up to date.

Generated by 👨‍🍳 PR Sous Chef · 48.2 AIC · ⌖ 0.974 AIC · ⊞ 17.1K ·

…er-models-fields

# Conflicts:
#	.github/workflows/smoke-claude.lock.yml

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage (updated)

Attribute Value
Category feature
Risk 🔴 High
Priority 🔴 High
Score 69/100
Action fast_track
Batch feature-promo (#41824 + #41777)

Score breakdown: Impact 40 + Urgency 15 + Quality 14 = 69

Assessment: Significant feature introducing model policy frontmatter controls (models.allowed/disallowed/blocked) with import-union semantics and env-based overrides (+536/-18, 14 files). Bot-approved (Test Quality Sentinel 82/100); prior CHANGES_REQUESTED dismissed. No CI checks present. Age: ~18h. ⚠️ Stale labels pr-action:defer and pr-batch:active-drafts remain (auto-removal not supported — manually remove).

Run §28298156610

Generated by 🔧 PR Triage Agent · 74.3 AIC · ⌖ 8.1 AIC · ⊞ 5.4K ·

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot Review the AWF specification to see if it supports wildcards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants