Skip to content

refactor: consolidate hasCopilotRequestsWritePermission frontmatter adapter into workflow package#44886

Merged
pelikhan merged 3 commits into
mainfrom
copilot/refactor-semantic-function-clustering-analysis
Jul 11, 2026
Merged

refactor: consolidate hasCopilotRequestsWritePermission frontmatter adapter into workflow package#44886
pelikhan merged 3 commits into
mainfrom
copilot/refactor-semantic-function-clustering-analysis

Conversation

Copilot AI commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Two same-named hasCopilotRequestsWritePermission functions lived in separate packages with different input types, both delegating to (*Permissions).HasCopilotRequestsWrite(). The frontmatter-based adapter in pkg/cli duplicated the frontmatter-to-*Permissions conversion logic that belongs in pkg/workflow.

Changes

  • pkg/workflow/permissions_operations.go — Adds exported HasCopilotRequestsWriteFromFrontmatter(frontmatter map[string]any) bool, co-located with the existing hasCopilotRequestsWritePermission(*WorkflowData) adapter so both entry points are visible side-by-side.
  • pkg/cli/workflow_secrets.go — Removes the local hasCopilotRequestsWritePermission adapter and replaces its call site with workflow.HasCopilotRequestsWriteFromFrontmatter.
// before (pkg/cli/workflow_secrets.go — now deleted)
func hasCopilotRequestsWritePermission(frontmatter map[string]any) bool {
    perms := workflow.NewPermissionsParserFromValue(frontmatter["permissions"]).ToPermissions()
    return perms.HasCopilotRequestsWrite()
}

// after (pkg/cli call site)
if workflow.HasCopilotRequestsWriteFromFrontmatter(frontmatter) { ... }

Behaviour-preserving; the conversion logic is identical.

Copilot AI and others added 2 commits July 11, 2026 07:13
Add HasCopilotRequestsWriteFromFrontmatter to pkg/workflow as the
single exported predicate for frontmatter-based permission checks.
Remove the duplicate local adapter from pkg/cli/workflow_secrets.go
and replace its call site with workflow.HasCopilotRequestsWriteFromFrontmatter.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Reference the unexported counterpart function explicitly to make it clear
both functions live in the same file.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor semantic function clustering analysis with minor deduplication refactor: consolidate hasCopilotRequestsWritePermission frontmatter adapter into workflow package Jul 11, 2026
Copilot AI requested a review from pelikhan July 11, 2026 07:15
@pelikhan pelikhan marked this pull request as ready for review July 11, 2026 07:20
Copilot AI review requested due to automatic review settings July 11, 2026 07:20
@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR does not have the 'implementation' label and has ≤100 new lines of code in business logic directories (17 lines added across 2 files).

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

Consolidates Copilot permission parsing in pkg/workflow without changing behavior.

Changes:

  • Adds an exported frontmatter permission helper.
  • Replaces and removes the duplicate CLI adapter.
Show a summary per file
File Description
pkg/workflow/permissions_operations.go Adds the centralized frontmatter adapter.
pkg/cli/workflow_secrets.go Uses the workflow helper and removes duplicate logic.

Review details

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Medium

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

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

@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.

Clean consolidation — the new exported function is a faithful lift of the deleted private one, and co-locating both entry points in pkg/workflow is the right call. No blocking issues.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 9.8 AIC · ⌖ 5.13 AIC · ⊞ 4.8K

@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.

Clean behaviour-preserving refactor. The extracted function is logically identical to the removed private adapter; nil guard and conversion logic are preserved. No issues found.

🔎 Code quality review by PR Code Quality Reviewer · 26.5 AIC · ⌖ 4.27 AIC · ⊞ 5.4K
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.

Skills-Based Review 🧠

Applied /codebase-design — this is a clean, behaviour-preserving consolidation.

📋 Highlights

Positive

  • ✅ Eliminates duplication of the frontmatter-to-Permissions conversion logic
  • ✅ Nil and missing-key guards are correctly preserved in the moved implementation
  • ✅ Co-location with the unexported hasCopilotRequestsWritePermission(*WorkflowData) adapter makes both entry points visible side-by-side — good discoverability
  • ✅ Chaining NewPermissionsParserFromValue(...).ToPermissions().HasCopilotRequestsWrite() is idiomatic and equivalent to the previous two-step form

Minor observation

The doc comment on HasCopilotRequestsWriteFromFrontmatter is verbose relative to the function's simplicity. A shorter form (e.g. // HasCopilotRequestsWriteFromFrontmatter reports whether frontmatter declares copilot-requests: write.) would be more in line with Go convention, but this is not blocking.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 14.8 AIC · ⌖ 4.37 AIC · ⊞ 6.6K
Comment /matt to run again

@pelikhan pelikhan merged commit d05f11c into main Jul 11, 2026
85 of 96 checks passed
@pelikhan pelikhan deleted the copilot/refactor-semantic-function-clustering-analysis branch July 11, 2026 07:49
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.8

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.

[refactor] Semantic function clustering analysis — codebase already well-consolidated (1 minor dedup)

3 participants