Skip to content

Give GitHubReposScope a concrete type - #55793

Merged
pelikhan merged 6 commits into
mainfrom
copilot/deep-report-give-githubreposscope-type
Aug 25, 2026
Merged

Give GitHubReposScope a concrete type#55793
pelikhan merged 6 commits into
mainfrom
copilot/deep-report-give-githubreposscope-type

Conversation

Copilot AI commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

GitHubReposScope used any, forcing consumers to handle scalar strings and YAML-parsed arrays independently. This change normalizes both supported YAML forms into a typed string slice.

  • Type

    • Define GitHubReposScope as []string.
    • Add YAML unmarshalling for scalar and list forms.
    • Reject non-string list entries.
  • Consumers

    • Normalize repository scopes during tool parsing.
    • Remove redundant type switches from validation, policy hashing, and dry-run reporting.
    • Preserve omitted versus explicitly empty scopes.
allowed-repos: all
allowed-repos:
  - github/gh-aw
  - github/docs

Both forms now produce:

GitHubReposScope{"all"}
GitHubReposScope{"github/gh-aw", "github/docs"}

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

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 31.4 AIC · ⌖ 8.24 AIC · ⊞ 8.7K ·
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Give GitHubReposScope a real type instead of bare any Give GitHubReposScope a concrete type Aug 25, 2026
Copilot AI requested a review from pelikhan August 25, 2026 14:16
@pelikhan
pelikhan marked this pull request as ready for review August 25, 2026 16:21
Copilot AI balanced review requested due to automatic review settings August 25, 2026 16:21
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

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

Introduces a concrete repository-scope type for GitHub guard policies and simplifies downstream handling.

Changes:

  • Normalizes scalar and list scopes into GitHubReposScope.
  • Simplifies validation, hashing, and reporting.
  • Updates affected tests.
Show a summary per file
File Description
pkg/workflow/tools_types.go Defines typed scope and YAML decoding.
pkg/workflow/tools_parser.go Normalizes parsed scope values.
pkg/workflow/tools_validation_github.go Validates typed scopes.
pkg/workflow/tools_validation_test.go Updates validation coverage.
pkg/workflow/tools_validation_github_test.go Updates alias-validation tests.
pkg/workflow/tools_types_test.go Tests normalization and YAML decoding.
pkg/workflow/cache_integrity.go Simplifies scope canonicalization.
pkg/workflow/cache_integrity_test.go Updates policy-hash fixtures.
pkg/cli/compile_guard_policy_report.go Simplifies scope reporting.
pkg/cli/compile_guard_policy_report_test.go Updates report fixtures.

Review details

  • Files reviewed: 10/10 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread pkg/workflow/tools_parser.go Outdated
Comment on lines +89 to +92
value, ok := repo.(string)
if !ok {
return GitHubReposScope{}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed by ad17985 and covered again in c60b4f2: parseGitHubReposScope now returns contextual errors through both guard-policy validation and ParseToolsConfig for mixed non-string arrays.

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-08-25T00:00:00Z
review_event: REQUEST_CHANGES
top_themes:
  - guard-policy validation regression
  - malformed allowed-repos widens to default all
files_reviewed:
  - pkg/cli/compile_guard_policy_report.go
  - pkg/cli/compile_guard_policy_report_test.go
  - pkg/workflow/cache_integrity.go
  - pkg/workflow/cache_integrity_test.go
  - pkg/workflow/tools_parser.go
  - pkg/workflow/tools_types.go
  - pkg/workflow/tools_types_test.go
  - pkg/workflow/tools_validation_github.go
  - pkg/workflow/tools_validation_github_test.go
  - pkg/workflow/tools_validation_test.go
comment_count: 1

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 · pi · gpt54 · 10.1 AIC · ⌖ 6.98 AIC · ⊞ 7K ·
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.

Request changes

The new concrete GitHubReposScope type is a good cleanup direction, but this patch currently turns malformed allowed-repos input into the implicit default scope instead of rejecting it.

Blocking theme
  • Invalid allowed-repos shapes are normalized to an empty slice during parsing, and later treated as “field omitted”.
  • That means bad guard-policy configuration can now bypass validation and widen to allowed-repos: all, which is the opposite of fail-closed behavior for an access-control setting.
  • Please preserve explicit validation failures for unsupported scalar types and non-string array entries, then add regression coverage for parser + validator integration.

🔎 Code quality review by PR Code Quality Reviewer · pi · gpt54 · 10.1 AIC · ⌖ 6.98 AIC · ⊞ 7K
Comment /review to run again

Comment thread pkg/workflow/tools_parser.go Outdated
for _, repo := range repos {
value, ok := repo.(string)
if !ok {
return GitHubReposScope{}

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.

This change silently reclassifies malformed allowed-repos values as “not configured”, which means invalid frontmatter can now bypass the min-integrity requirement and get defaulted to all instead of failing fast.

💡 Why this blocks merge

Before this patch, an unsupported type like allowed-repos: 42 or a mixed array failed validation because validateReposScope still saw the original value and returned an explicit type error. Now parseGitHubReposScope converts every unsupported shape into an empty slice, and validateGitHubGuardPolicy treats that as if the field were omitted (hasRepos := github.AllowedRepos != nil is false for an empty slice). That changes invalid policy input into permissive defaulting:

tools:
  github:
    allowed-repos: 42
    min-integrity: approved

With the new parser, that reaches:

config.AllowedRepos = GitHubReposScope{}
hasRepos := github.AllowedRepos != nil // false
github.AllowedRepos = GitHubReposScope{"all"}

So a bad config no longer produces a schema/validation error; it broadens access to all. Please preserve parse/validation failure for unsupported scalar types and mixed/non-string arrays, and add a regression test around invalid allowed-repos input going through NewTools(...) + validateGitHubGuardPolicy(...).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed by ad17985 and covered again in c60b4f2: unsupported scalar and mixed-array scopes fail before defaulting, with min-integrity: approved regression coverage through NewTools validation and ParseToolsConfig.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

gh-aw-pr-sous-chef
@copilot PR Sous Chef triage: this PR still needs a forward-progress pass before maintainer investigation is likely to be productive.

Please do one focused follow-up pass:

  • address the blocking review about malformed allowed-repos input widening to the default all scope
  • refresh the branch if needed
  • use the pr-finisher skill before handing back for review

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

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 31.4 AIC · ⌖ 8.24 AIC · ⊞ 8.7K ·
Comment /souschef to run again

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

Copilot AI commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

gh-aw-pr-sous-chef
@copilot PR Sous Chef triage: this PR still needs a forward-progress pass before maintainer investigation is likely to be productive.
...

Addressed in ad17985. Malformed scalar and mixed-array repository scopes now return contextual parse errors through ParseToolsConfig and guard-policy validation, preventing fallback to all.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

gh-aw-pr-sous-chef
@copilot PR Sous Chef triage: this PR still needs a forward-progress pass before maintainer investigation is likely to be productive.

Please do one focused follow-up pass:

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

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 9.12 AIC · ⌖ 8.12 AIC · ⊞ 8.7K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@pelikhan
pelikhan merged commit a5432dc into main Aug 25, 2026
Copilot stopped work on behalf of gh-aw-bot due to an error August 25, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[deep-report] Give GitHubReposScope a real type instead of bare any

4 participants