Skip to content

Add model inventory validation to compile - #57958

Merged
pelikhan merged 3 commits into
mainfrom
copilot/add-models-flag-to-compile-command
Sep 2, 2026
Merged

Add model inventory validation to compile#57958
pelikhan merged 3 commits into
mainfrom
copilot/add-models-flag-to-compile-command

Conversation

Copilot AI commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

gh aw compile cannot currently identify model references absent from the active inventory. Add opt-in --models validation that warns without blocking compilation.

  • Shared inventory

    • Reuse the gh aw models catalog, alias, and observed-model collection path.
    • Skip validation when no observed model data is available.
  • Compile validation

    • Check models.allowed, models.blocked, and engine.models.
    • Accept built-in and workflow-defined aliases, patterns, parameters, and runtime expressions.
    • Emit deduplicated warnings for unknown models.
gh aw compile --models
  • Documentation
    • Add --models to the CLI reference and describe its behavior.

Run: https://github.com/github/gh-aw/actions/runs/33641605189

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 33.4 AIC · ⌖ 8.81 AIC · ⊞ 9.2K ·
Comment /souschef to run again

Copilot AI and others added 3 commits September 2, 2026 13:42
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Add compile model inventory validation Add model inventory validation to compile Sep 2, 2026
Copilot AI requested a review from pelikhan September 2, 2026 13:57
@pelikhan
pelikhan marked this pull request as ready for review September 2, 2026 14:06
Copilot AI balanced review requested due to automatic review settings September 2, 2026 14:06

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.

🟡 Changes recommended

Imported engine models, inventory refresh failures, and structured JSON warnings are not handled correctly.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds opt-in model inventory validation to gh aw compile.

Changes:

  • Builds model inventory from catalog, aliases, and observations.
  • Warns for unknown model references.
  • Adds CLI wiring, tests, and documentation.
File summaries
File Description
pkg/workflow/configured_model_validation.go Emits compiler model warnings.
pkg/workflow/configured_model_validation_test.go Tests warning emission.
pkg/workflow/compiler_types.go Stores the validator callback.
pkg/workflow/compiler_orchestrator_workflow.go Runs model validation during parsing.
pkg/workflow/compiler_mutators.go Exposes validator configuration.
pkg/cli/models_command.go Extracts shared inventory reporting logic.
pkg/cli/compile_model_validation.go Implements inventory matching and findings.
pkg/cli/compile_model_validation_test.go Tests inventory validation behavior.
pkg/cli/compile_config.go Adds model-validation configuration.
pkg/cli/compile_compiler_setup.go Connects inventory validation to the compiler.
docs/src/content/docs/setup/cli.md Documents --models.
cmd/gh-aw/main.go Registers and prepares the flag.
cmd/gh-aw/compile_flags_test.go Tests flag propagation.
Review details
  • Files reviewed: 13/13 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment on lines +95 to +101
if engine, ok := data.RawFrontmatter["engine"].(map[string]any); ok {
if models, ok := engine["models"].(map[string]any); ok {
if value, ok := models["default"].(string); ok {
add("engine.models.default", []string{value})
}
add("engine.models.supported", stringSlice(models["supported"]))
}
Comment on lines +127 to +132
report := buildModelsReport(ctx, modelsReportOptions{
logsDir: defaultLogsOutputDir,
refreshObserved: true,
refreshCount: defaultModelsRefreshCount,
})
config.activeModels = buildActiveModelInventory(report)
Comment on lines +135 to +141
func unknownConfiguredModelMessages(data *workflow.WorkflowData, inventory *activeModelInventory) []string {
issues := findUnknownConfiguredModels(data, inventory)
messages := make([]string, 0, len(issues))
for _, issue := range issues {
messages = append(messages, issue.Message)
}
return messages
@pelikhan
pelikhan merged commit b0ef30c into main Sep 2, 2026
55 checks passed
@pelikhan
pelikhan deleted the copilot/add-models-flag-to-compile-command branch September 2, 2026 14:26
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security scanning failed for Ponytail Reviewer. Review the logs for details.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • ab.chatgpt.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"

See Network Configuration for more information.

Generated by Ponytail Reviewer for #57958

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

🧪 Test quality analysis by Test Quality Sentinel

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please review the current PR state, address the latest review feedback, refresh the branch if needed, and run the pr-finisher skill before handing back to maintainers.

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 33.4 AIC · ⌖ 8.81 AIC · ⊞ 9.2K ·
Comment /souschef to run again

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

ADR required

This PR meets the ADR gate because it adds implementation work in business-logic code (pkg/ additions exceed the default threshold: 353 new lines) and introduces a new architectural decision.

I drafted an ADR at docs/adr/57958-add-model-inventory-validation-to-compile.md, but I could not push it to the PR branch from this checkout because only pull/57958/merge is available locally and the head branch ref copilot/add-models-flag-to-compile-command is not present for branch pinning.

Evidence used

  • PR description defines a new opt-in gh aw compile --models validation path.
  • Diff adds new compile configuration, model inventory reuse, compiler validator hooks, warning behavior, and docs/tests across cmd/gh-aw/, pkg/cli/, and pkg/workflow/.
  • No existing ADR was found beyond older unrelated records in docs/adr/.

Draft ADR content

See the drafted file content below for review and manual application:

# ADR-57958: Add Model Inventory Validation to Compile

**Date**: 2026-09-02
**Status**: Draft
**Deciders**: pelikhan, adr-writer agent

---

### Context

This pull request adds a new `gh aw compile --models` option and threads that option through the CLI, compile configuration, compiler setup, workflow validation, tests, and CLI documentation. The PR description says compilation cannot currently identify model references that are absent from the active inventory, while `gh aw models` already has the catalog, alias, and observed-model collection path needed for that check. The diff shows an explicit requirement to warn without blocking compilation, to skip the check when no observed model data is available, and to validate `models.allowed`, `models.blocked`, and `engine.models`. Because this introduces a new compile-time validation behavior that depends on shared model inventory state and affects how workflow authors receive feedback, the decision should be recorded explicitly.

### Decision

We will add an opt-in `--models` compile flag that reuses the existing `gh aw models` inventory-building path to warn when configured models are absent from the active observed model inventory. The validation will run during workflow compilation, accept built-in aliases, workflow-defined aliases, wildcard patterns, parameterized model references, and runtime expressions, and it will emit deduplicated warnings instead of failing the compile. We will skip this validation entirely when no observed model data is available so compilation behavior remains non-blocking in environments without inventory data.

### Alternatives Considered

#### Alternative 1: Keep Model Inventory Checks Only in `gh aw models`

Continue limiting inventory inspection to the standalone `gh aw models` command and do not add any compile-time validation.

This was considered because it avoids adding another compile flag and keeps compilation focused on syntax and workflow validation only. It was not chosen because the PR evidence shows users need feedback at compile time when workflow configuration references models that are not present in the active inventory, and the existing command already provides reusable data sources for that validation.

#### Alternative 2: Make Unknown Models a Compile Error

Validate the same fields during compilation, but fail the command when an unknown configured model is found.

This was considered because it would enforce stricter correctness and could prevent invalid configurations from shipping. It was not chosen because the PR description and implementation explicitly require warnings without blocking compilation, reflecting that observed-model data may be incomplete or unavailable and that the inventory is advisory rather than an absolute source of truth.

### Consequences

#### Positive
- Workflow authors can detect unknown configured models earlier, at compile time, instead of needing a separate inventory inspection step.
- The implementation reuses the shared model report pipeline, reducing duplicated logic for catalog, alias, and observed-model handling.
- Validation remains practical in real repositories because aliases, wildcard patterns, parameterized model strings, and runtime expressions are treated as valid inputs.

#### Negative
- Compile now has an additional opt-in path that refreshes observed model artifacts, which adds implementation and maintenance complexity across CLI and compiler layers.
- Warning quality depends on the freshness and availability of observed model data, so results may be incomplete when logs are stale or missing.
- The validation logic must track multiple accepted reference forms and inventory aliases, increasing the risk of edge cases if model naming rules evolve.

#### Neutral
- The compiler now supports an external configured-model validator hook and increments warning counts for advisory inventory findings.
- The `models` report-building logic is factored into a reusable helper so both `gh aw models` and `gh aw compile --models` share the same data path.
- CLI documentation and tests now treat model inventory validation as an optional maintenance-style compile check rather than a required correctness gate.

---

*ADR created by [adr-writer agent]. Review and finalize before changing status from Draft to Accepted.*

Next action

Add this ADR file to the PR branch and update it during review if the decision scope changes.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · gpt54 · 20.6 AIC · ⌖ 9.46 AIC · ⊞ 10.1K ·
Comment /review to run again

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-09-02T14:28:43Z
review_event: COMMENT
top_themes:
  - no-new-findings
  - prior-model-validation-risks-already-commented
files_reviewed:
  - cmd/gh-aw/compile_flags_test.go
  - cmd/gh-aw/main.go
  - docs/src/content/docs/setup/cli.md
  - pkg/cli/compile_compiler_setup.go
  - pkg/cli/compile_config.go
  - pkg/cli/compile_model_validation.go
  - pkg/cli/compile_model_validation_test.go
  - pkg/cli/models_command.go
  - pkg/workflow/compiler_mutators.go
  - pkg/workflow/compiler_orchestrator_workflow.go
  - pkg/workflow/compiler_types.go
  - pkg/workflow/configured_model_validation.go
  - pkg/workflow/configured_model_validation_test.go
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 57.7 AIC · ⌖ 7.35 AIC · ⊞ 23.5K ·
Comment /review to run again

@github-actions github-actions Bot 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.

Verdict

No additional merge-blocking issues beyond the three model-validation problems already called out on this PR.

Why I’m not stacking more comments

I re-checked the changed lines around the new --models plumbing, the inventory builder, and the warning emission path. The high-signal risks remain the ones already raised: imported/built-in engine definitions are missed, refresh failures can silently validate against stale observations, and --json loses these warnings from per-workflow results. The extra sub-agent output was discarded because it targeted unrelated executable-bit changes that are not part of this diff.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 57.7 AIC · ⌖ 7.35 AIC · ⊞ 23.5K
Comment /review to run again

@github-actions github-actions Bot 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.

The new inventory wrapper is more structure than this feature needs; a plain normalized map plus direct checks in findUnknownConfiguredModels would keep the same behavior with less indirection. net: -20 lines possible.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • ab.chatgpt.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"

See Network Configuration for more information.

Generated by ✂️ Ponytail Reviewer for #57958 · codex · mai10 · 6.47 AIC · ⌖ 0.383 AIC · ⊞ 13.5K
Comment /ponytail to run again

"github.com/github/gh-aw/pkg/workflow"
)

type activeModelInventory struct {

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.

pkg/cli/compile_model_validation.go:13: yagni: activeModelInventory wrapper with one consumer and a bespoke contains method. Replace it with a plain normalized map and inline the matching logic in findUnknownConfiguredModels.

@github-actions github-actions Bot 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.

Skills-Based Review 🧠

Applied /tdd and /codebase-design. The feature is well-tested for its core matching logic (aliases, patterns, runtime expressions), opt-in, and non-blocking — good design fit. Existing bot comments already flag three solid issues in compile_model_validation.go (imported-engine-definitions gap at line 101, swallowed refresh warnings at line 132, and lost structured messages under --json at line 141); I added two more in the same area rather than duplicate those.

📋 Key Themes & Highlights

Key Themes

  • Silent no-op risk: When report.Observed is empty (bad --logs-dir, no artifacts, refresh failure), --models produces zero warnings with zero indication that validation didn't actually run — indistinguishable from "everything is fine."
  • Divergence from gh aw models: PrepareCompileModelValidation hardcodes the default logs dir and drops --repo override, unlike the sibling models command; untested and undocumented.
  • These compound with the already-flagged issue that buildModelsReport's warnings are discarded in PrepareCompileModelValidation — a single fix (surfacing those warnings) would resolve both the "why did I get no warnings" and "refresh failed silently" concerns together.

Positive Highlights

  • ✅ Clean reuse of the existing models catalog/alias/observed-model pipeline via buildModelsReport
  • ✅ Sensible handling of runtime expressions (${{ ... }}) and glob patterns in activeModelInventory.contains
  • ✅ Solid test coverage for the matching/dedup logic itself (TestFindUnknownConfiguredModels)

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 67.5 AIC · ⌖ 14.9 AIC · ⊞ 10.3K
Comment /matt to run again


// PrepareCompileModelValidation builds the active model inventory used by compile --models.
func PrepareCompileModelValidation(ctx context.Context, config *CompileConfig) {
if !config.Models {

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.

[/codebase-design] --models silently no-ops whenever report.Observed is empty (e.g. wrong --logs-dir, no local artifacts, or refresh failure) — activeModels stays nil, so SetConfiguredModelValidator is never wired up and the compiler prints nothing. A user cannot distinguish "no unknown models" from "validation never ran."

💡 Suggested improvement

Surface this state explicitly, e.g. emit a one-line stderr notice ("--models: no observed model data available, skipping validation") from PrepareCompileModelValidation when config.activeModels == nil, and add a test asserting that notice appears. This also ties into the existing review comment on this same function about refresh failures being silently swallowed — both stem from the same root cause: buildModelsReport warnings are discarded here instead of being surfaced to the compile user.

@copilot please address this.

return
}
report := buildModelsReport(ctx, modelsReportOptions{
logsDir: defaultLogsOutputDir,

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.

[/tdd] PrepareCompileModelValidation hardcodes logsDir: defaultLogsOutputDir and omits repoOverride, unlike runModelsCommand which reads both from CLI flags. There's no test exercising a non-default --logs-dir or --repo through compile --models, so this divergence from gh aw models wasn't caught.

💡 Suggested test
func TestPrepareCompileModelValidationRespectsLogsDirOverride(t *testing.T) {
    // arrange: config with a custom logs dir containing fixture observed-model data
    // act: PrepareCompileModelValidation(ctx, &config)
    // assert: config.activeModels reflects the fixture data, not the default dir
}

If the omission is intentional (e.g. compile --models is meant to always use the default logs dir), consider documenting why in a comment, since it's a subtle behavioral difference from gh aw models --logs-dir.

@copilot please address this.

@github-actions github-actions Bot 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.

Reviewed the model inventory validation changes. This is a Go/CLI feature (not UI), so I applied a standard correctness review rather than Impeccable UI modes.

Found one high-signal gap: findUnknownConfiguredModels doesn't check the top-level model: frontmatter field or the singular engine.model override, which are the dominant ways workflows configure models in this repo (219+ files use model:), while the only engine-level field it does check (engine.models.default/supported) has no real usages. Left an inline comment with details.

Other aspects (inventory building, alias handling, flag wiring, docs) look solid and well-tested.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · copilot · sonnet50 · 145.3 AIC · ⌖ 14.3 AIC · ⊞ 8.3K

}
add("engine.models.supported", stringSlice(models["supported"]))
}
}

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.

findUnknownConfiguredModels never checks data.Model (the top-level model: frontmatter field) or engine.model (the singular string override consumed by resolveEngineModel in pkg/workflow/engine.go). In this repo, model: is used directly in 219+ workflow files (e.g. .github/workflows/ace-editor.md: model: openai/gpt-5.4), while engine.models.default/supported (the only engine-level field validated here) has zero real usages under .github/workflows/. As written, --models silently skips validating the model configuration for the overwhelming majority of existing workflows, which contradicts the PR's stated goal of warning when models.allowed, models.blocked, or configured engine models are absent from the active inventory. Please also validate data.Model and engine.model (falling back to top-level model:), and add a test case covering the common single-string model: frontmatter form.

@copilot please address this.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.88.2

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