Skip to content

Split workflow resolution into focused modules - #64854

Closed
pelikhan with Copilot wants to merge 7 commits into
mainfrom
copilot/file-diet-refactor-cli-add-workflow-resolution
Closed

pelikhan with Copilot wants to merge 7 commits into
mainfrom
copilot/file-diet-refactor-cli-add-workflow-resolution

Conversation

Copilot AI commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

pkg/cli/add_workflow_resolution.go had grown to 1,214 lines and mixed remote resolution, local package handling, asset discovery, and wildcard expansion.

  • Module boundaries: Split the implementation into five files for resolution, local packages, package assets, package specs, and wildcard handling. Each is under 400 lines; public APIs and behavior are unchanged.
  • Coverage: Added focused tests for invalid resolution input, dispatch parsing, local skill and agent discovery, and package spec generation.

Copilot AI and others added 2 commits October 1, 2026 22:42
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 [WIP] Refactor pkg/cli/add_workflow_resolution.go for better organization Split workflow resolution into focused modules Oct 1, 2026
Copilot AI requested a review from pelikhan October 1, 2026 22:57
@pelikhan
pelikhan marked this pull request as ready for review October 1, 2026 23:12
Copilot AI balanced review requested due to automatic review settings October 1, 2026 23:12

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.

Copilot review overview

🟢 Approval recommended

The refactor preserves behavior and adds focused coverage, with only a minor non-blocking control-flow simplification noted.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Refactors workflow resolution into focused modules while preserving existing behavior and APIs.

Changes:

  • Splits resolution, local packages, assets, package specs, and wildcard handling.
  • Adds targeted tests for resolution validation, package assets/specs, and dispatch parsing.
File Description
pkg/​cli/​add_workflow_resolution.go Retains core resolution orchestration.
pkg/​cli/​add_workflow_wildcard.go Extracts wildcard, dispatch, and redirect handling.
pkg/​cli/​add_workflow_local_package.go Extracts local package resolution.
pkg/​cli/​add_workflow_package_assets.go Extracts skill and agent discovery.
pkg/​cli/​add_workflow_package_specs.go Extracts package-to-workflow spec generation.
pkg/​cli/​add_workflow_resolution_test.go Tests invalid resolution inputs.
pkg/​cli/​add_workflow_local_package_test.go Tests local manifest discovery.
pkg/​cli/​add_workflow_package_assets_test.go Tests skill and agent discovery.
pkg/​cli/​add_workflow_package_specs_test.go Tests package spec generation and fallbacks.
pkg/​cli/​add_wildcard_test.go Adds dispatch parsing coverage.

Comment thread pkg/cli/add_workflow_resolution.go Outdated
Comment on lines +358 to +362
for _, bootstrapProfile := range bootstrapProfiles {
resolutionLog.Printf("Bootstrap profile found: packageID=%s", bootstrapProfile.PackageID)
return bootstrapProfile, resolutionWarnings
}
return nil, resolutionWarnings

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.

Updated in d7873a9: removed the loop and unreachable fallback, using the single profile from the case directly.

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.

Updated in d7873a9: removed the loop and unreachable fallback, using the single profile from the case directly.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot
there are still follow-up items before maintainers can investigate quickly:

  • review the failing checks below, push the needed fix, refresh the branch if needed, and then run the pr-finisher skill.

Failed checks:

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 19.1 AIC · ⌖ 8.56 AIC · ⊞ 9.5K · ◷
Comment /souschef to run again

…actor-cli-add-workflow-resolution

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

github-actions Bot commented Oct 1, 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 Oct 1, 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

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

github-actions Bot commented Oct 1, 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 Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

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.

Generated by Ponytail Reviewer for #64854

Copilot AI commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot
there are still follow-up items before maintainers can investigate quickly:
...

The three failed jobs all trace to the existing typeassertionnil registry/documentation/CI sync mismatch; I reproduced it locally. Merged the latest main and addressed the review in d7873a9. Local make test still fails only on that unrelated linter mismatch; CI needs a maintainer re-trigger.

@copilot
there are still follow-up items before maintainers can investigate quickly:
...

The three failed jobs all trace to the existing typeassertionnil registry/documentation/CI sync mismatch; I reproduced it locally. Merged the latest main and addressed the review in d7873a9. Local make test still fails only on that unrelated linter mismatch; CI needs a maintainer re-trigger.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

ADR required

This PR triggers the design-decision gate because it adds more than 100 lines in a business-logic directory (pkg/; prefetch summary reports 1108 additions).

I did not find an existing ADR in the PR body, and the latest ADR on the branch (docs/adr/64813-expose-operation-specific-ledger-tools.md) does not cover this refactor.

Based on the PR description and diff, I added a draft ADR here:

  • docs/adr/64854-split-workflow-resolution-into-focused-modules.md

Evidence used:

  • PR title: Split workflow resolution into focused modules
  • PR body: pkg/cli/add_workflow_resolution.go had grown to 1,214 lines and mixed multiple concerns; behavior and public APIs are intended to remain unchanged
  • Diff: extraction into dedicated files for local package resolution, package assets, package specs, and related tests

Next action: review and refine the draft ADR, then keep it with the PR as the design record for this refactor.

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

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-10-01T23:51:46Z
review_event: COMMENT
top_themes:
  - no blocking regression found in the resolution-file split
  - focused tests cover the moved parsing and package-discovery helpers
files_reviewed:
  - pkg/cli/add_wildcard_test.go
  - pkg/cli/add_workflow_local_package.go
  - pkg/cli/add_workflow_local_package_test.go
  - pkg/cli/add_workflow_package_assets.go
  - pkg/cli/add_workflow_package_assets_test.go
  - pkg/cli/add_workflow_package_specs.go
  - pkg/cli/add_workflow_package_specs_test.go
  - pkg/cli/add_workflow_resolution.go
  - pkg/cli/add_workflow_resolution_test.go
  - pkg/cli/add_workflow_wildcard.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 · 61.5 AIC · ⌖ 7.02 AIC · ⊞ 19.2K · ◷
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 blocking regressions stood out in the current head of this refactor.

What I checked
  • The current head already removed the earlier unreachable-control-flow nit in selectBootstrapProfile, so I did not repeat that comment.
  • The rest of the diff reads as mechanical extraction of local-package, asset, package-spec, and wildcard helpers rather than a semantic rewrite.
  • The added tests cover the main moved seams: invalid resolution input, workflow_dispatch parsing, local skill/agent discovery, and package spec generation.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 61.5 AIC · ⌖ 7.02 AIC · ⊞ 19.2K
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 — approving with minor non-blocking suggestions.

📋 Key Themes & Highlights

Key Themes

  • Two small cross-cutting-concern nits: add_workflow_wildcard.go mixes redirect-following with wildcard expansion (name doesn't match full content), and RepoSpec{...} literals are duplicated 5x across add_workflow_package_specs.go.
  • The split follows good module boundaries overall: local-package resolution, asset discovery, spec generation, and wildcard expansion are each cleanly separated with clear public/private surfaces.
  • The previously flagged unreachable-fallback issue in selectBootstrapProfile (case 1 loop) was already fixed in commit d7873a9.

Positive Highlights

  • ✅ Each extracted file stays well under 400 lines with a single clear responsibility.
  • ✅ Good new test coverage added for invalid resolution input, package-spec generation, local skill/agent discovery, and dispatch parsing — mitigates refactor risk.
  • ✅ Public API surface (ResolveWorkflows, WorkflowSpec, etc.) is unchanged; package-private sentinel (errNotHandled) correctly threads fallback logic across the new files.
  • ✅ Build passes (go build ./pkg/cli/...) with no behavior regressions observed in the moved code.

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

return expandedSpecs, true, nil
}

func resolveAddWorkflowSpecAndContent(ctx context.Context, initialSpec *WorkflowSpec, verbose bool) (*WorkflowSpec, *FetchedWorkflow, error) {

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] resolveAddWorkflowSpecAndContent (redirect-following) and expandLocalWildcard/expandLocalWildcardWorkflows are two distinct concerns sharing one file named add_workflow_wildcard.go. The name only signals the wildcard-expansion half.

💡 Suggestion

Consider moving resolveAddWorkflowSpecAndContent and checkWorkflowHasDispatchFromContent (redirect-following / fetch logic) into a separate add_workflow_redirect.go, keeping this file focused purely on wildcard glob expansion as the name promises. This keeps the new module boundaries as navigable as the split overall intends.

@copilot please address this.

return parsedSpecs
}

func appendRepositoryPackageWorkflowSpecs(parsedSpecs []*WorkflowSpec, repoSpec *RepoSpec, pkg *resolvedRepositoryPackage) []*WorkflowSpec {

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] appendRepositoryPackageWorkflowSpecs and appendRepositoryPackageExtensionSpecs repeat the same RepoSpec{RepoSlug, Version, PackagePath} literal 5 times across this file (and similarly in appendLocalRepositoryPackageWorkflowSpecs). This duplication is a readability/maintenance risk if a new field is added to RepoSpec later.

💡 Suggestion

Factor out a small helper, e.g. func (r *RepoSpec) withVersion(version string) RepoSpec, or build the base RepoSpec once per call and reuse it when constructing each WorkflowSpec. Not blocking, but worth a follow-up cleanup now that the logic has its own file.

@copilot please address this.

@pelikhan pelikhan closed this Oct 2, 2026
Copilot stopped work on behalf of pelikhan due to an error October 2, 2026 00:14
@github-actions
github-actions Bot deleted the copilot/file-diet-refactor-cli-add-workflow-resolution branch October 9, 2026 02:13
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.

[file-diet] Refactor pkg/cli/add_workflow_resolution.go (1214 lines)

4 participants