Skip to content

Extract shared work-queue worker target resolution - #75807

Merged
pelikhan merged 7 commits into
mainfrom
copilot/refactor-extract-worker-target-resolution
Nov 8, 2026
Merged

pelikhan merged 7 commits into
mainfrom
copilot/refactor-extract-worker-target-resolution

Conversation

Copilot AI commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Three work-queue validators repeated workflow lookup, compiler-managed source checks, and worker declaration checks, while applying different policies and error messages.

  • Shared resolution: Added resolveWorkQueueWorkerTarget to centralize lookup and worker detection.
  • Preserved caller behavior: Callers retain their own error wording, non-worker skip/reject policies, and the profile self-reference shortcut. Lookup and source-inspection errors also keep their existing handling.
worker, err := resolveWorkQueueWorkerTarget(name, markdownPath)
if errors.Is(err, errNotCompilerManagedWorkQueueTarget) {
    // Apply the caller-specific source error.
}

Copilot AI changed the title [WIP] Refactor shared work-queue worker-target resolution in work_queue_policy.go Extract shared work-queue worker target resolution Nov 8, 2026
Copilot AI requested a review from gh-aw-bot November 8, 2026 03:43
@pelikhan
pelikhan marked this pull request as ready for review November 8, 2026 04:02
Copilot AI adaptive review requested due to automatic review settings November 8, 2026 04:02
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

❌ Design Decision Gate 🏗️ failed to deliver outputs during design decision gate check.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #75807

@github-actions

github-actions Bot commented Nov 8, 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 Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Specification Reviewer · gpt56 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.7K · ◷

Generated by PR Specification Reviewer for #75807

@github-actions

github-actions Bot commented Nov 8, 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 Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: gpt56 max · ~1 AIC · ⌖ ~2 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@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 changed work-queue target resolution and tests. I found no actionable correctness, security, performance, or maintainability issues on the changed lines. Static review only; tests were not run.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Warning

The push_to_pull_request_branch operation failed: Cannot verify branch protection rules for "copilot/refactor-extract-worker-target-resolution": Resource not accessible by integration - https://docs.github.com/rest/branches/branch-protection\#get-branch-protection. Reading classic branch protection requires a GitHub App installation token or fine-grained PAT with Administration: read repository permission; GITHUB_TOKEN cannot provide this permission. Push blocked to prevent accidental writes to protected branches.. The code changes were not applied.

🏗️ Design Decision Gate — ADR Required

This PR adds 117 lines under pkg/, which is over the 100-line threshold for core business logic, but it does not link an Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/75807-shared-work-queue-worker-target-resolution.md. Please review and complete it before merging.

The draft records the decision to move work-queue worker target lookup and worker detection into resolveWorkQueueWorkerTarget, while each validator keeps its own error wording and skip/reject policy. The helper reports its outcome through typed errors: the errNotCompilerManagedWorkQueueTarget sentinel and the workQueueTargetLookupError wrapper.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch. It was generated from the PR diff.

  2. Complete the missing sections: add context the AI couldn't infer, refine the decision rationale, and list the alternatives you actually considered.

  3. Commit the finalized ADR to docs/adr/ on your branch.

  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-75807: Shared Work-Queue Worker Target Resolution with Caller-Owned Error Policy (link unavailable: invalid HTTPS URL)

Once an ADR is linked in the PR body, this gate will re-run and check that the implementation matches the decision.

❓ Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context: What is the problem? What forces are at play?
  • Decision: What did you decide, and why?
  • Alternatives Considered: What else could have been done?
  • Consequences: What are the trade-offs, positive and negative?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: opus55 medium · ~26 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷
Comment /review to run again

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.

🟢 Approval recommended

No active review issues are recorded for the shared worker-target resolution refactor.

No open issues 🎉

What changed in this PR

This PR centralizes worker-target resolution in the gh-aw workflow compiler, reducing duplication across three work-queue validators while preserving caller-specific behavior.

Changes:

  • Adds a shared helper for workflow lookup, compiler-managed source validation, and worker detection.
  • Preserves error messages, non-worker skip/reject policies, and the profile self-reference shortcut.
  • Adds tests for target resolution and caller-specific validation behavior.
File Description
pkg/​workflow/​work_queue_policy.go Extracts shared resolution logic and updates all three callers.
pkg/​workflow/​work_queue_policy_test.go Tests resolution outcomes and preserved caller policies and error messages.

Review effort: Balanced (auto)

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

What this change does: It centralizes workflow lookup and worker declaration checks for approved dispatch targets, default profiles, and configured profiles. It keeps the caller-specific messages and policies through a new lookup-error marker.

Should fix:

  1. The shared resolver adds an error protocol instead of removing one (pkg/workflow/work_queue_policy.go:L572-L587)

    • What this is: The marker type and classifier exist only to tell the three callers whether resolution failed in findWorkflowFile or in mdHasWorkQueueWorker.
    • Problem: For an invalid target such as ../outside, the helper wraps the lookup error and each caller immediately detects that wrapper just to add its own prefix; the extraction adds more error plumbing than it removes.
    • Fix: Return a sourceFound/compiler-managed flag alongside the raw error, so callers can distinguish lookup failure from source inspection failure without the custom type, Unwrap, and errors.As.
    • If we skip it: Future target-validation changes must maintain three copies of this classification path.

Not checked: I did not run tests; I reviewed the pre-fetched diff and the connected resolver and callers.
Verdict: fix 1 first.
Lean: -16 lines possible.

Generated by ✂️ Ponytail Reviewer for #75807 · codex · routed: gpt56 max · ~4 AIC · ⌖ ~1 AIC · ⊞ 118
Comment /ponytail to run again

Comment thread pkg/workflow/work_queue_policy.go Outdated

var errNotCompilerManagedWorkQueueTarget = errors.New("workflow source is not compiler-managed")

type workQueueTargetLookupError 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.

What this is: This marker type and its classifier exist only to tell the three callers whether resolution failed in findWorkflowFile or in mdHasWorkQueueWorker. Problem: For an invalid target such as ../outside, the helper wraps the lookup error and each caller immediately detects that wrapper just to add its own prefix; the extraction adds more error plumbing than it removes. Fix: Return a sourceFound/compiler-managed flag alongside the raw error, so callers can distinguish lookup failure from source inspection failure without workQueueTargetLookupError, Unwrap, and errors.As. If we skip it: Future target-validation changes must maintain three copies of this classification path.

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.

Simplified the helper to resolve only a compiler-managed source path and return lookup errors raw; callers now add their own lookup prefixes. Removed the marker wrapper and classifier in 6623326.

@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 and /tdd to this refactor. Behavior looks preserved and the targeted work-queue tests pass. Two follow-ups: simplify the helper error channel, and cover the caller-specific lookup wrapping in tests.

📋 Key Themes & Highlights

Key Themes

  • Error channel complexity: resolveWorkQueueWorkerTarget returns three kinds of error (sentinel, wrapper, raw parser error). The wrapper type and two predicates exist only to keep caller prefixes.
  • Test gap: the lookup prefixes in the approved-worker and worker-profile callers are not asserted by any test. The profile-target wrapper is unreachable through filepath.Base.

Positive Highlights

  • ✅ The duplicated lookup and worker-detection code now lives in one place.
  • ✅ Caller-specific messages and the profile self-reference shortcut are preserved, and TestWorkQueueTargetCallersPreserveWorkerPolicies pins them.
  • ✅ The non-worker and not-compiler-managed paths have direct test coverage.

Validation

  • go test ./pkg/workflow with the -run filter for TestResolveWorkQueueWorkerTarget, TestWorkQueueTargetCallersPreserveWorkerPolicies, and WorkQueue passes.
  • A temporary probe confirmed the approved-worker lookup-error wrapping. The probe file was removed afterwards.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~5 AIC · ⌖ ~2 AIC · ⊞ 5.4K
Comment /matt to run again

Comment thread pkg/workflow/work_queue_policy.go Outdated
return errors.As(err, &lookupErr)
}

func resolveWorkQueueWorkerTarget(name, markdownPath string) (bool, 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] The helper removes the lookup duplication, but its error channel now carries three categories: the not-compiler-managed sentinel, the workQueueTargetLookupError wrapper, and raw parser errors. That needs a wrapper type plus two predicates, and each caller still repeats the same three-way branch.

💡 Simpler split

Return only the source path from the lookup and keep the worker check in callers:

func resolveWorkQueueWorkerSource(name, markdownPath string) (string, error) {
    target, err := findWorkflowFile(name, markdownPath)
    if err != nil {
        return "", err
    }
    if !target.mdExists {
        return "", errNotCompilerManagedWorkQueueTarget
    }
    return target.mdPath, nil
}

Callers check the sentinel first, wrap any other lookup error with their prefix, then call mdHasWorkQueueWorker and return its error unchanged. workQueueTargetLookupError, isWorkQueueTargetLookupError, and the wrapper's Error/Unwrap methods can then be removed.

@copilot please address this.

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.

Removed the wrapper type and classifier. The helper now returns the compiler-managed source path or a raw lookup/sentinel error; each caller wraps lookup failures and runs the worker declaration check separately. Fixed in 6623326.

require.False(t, worker)
}

func TestWorkQueueTargetCallersPreserveWorkerPolicies(t *testing.T) {

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] The PR says lookup errors keep their caller-specific wrapping, but no test asserts the %w prefixes for the default-profile or profile-target callers. Only the approved-worker path was checked, and only manually.

💡 Suggested assertion

Add a case with "../outside" in DispatchWorkflow.Workflows and assert on populateDefaultWorkQueueProfiles, which should produce the prefix work-queue: worker profile "../outside": invalid workflow name. Do the same for validateApprovedWorkQueueTargets with the approved worker prefix.

The profile-target wrapper is hard to reach: validateWorkQueueProfileTargets derives the name with filepath.Base, which strips path separators before lookup. Either pick a different trigger for it or leave that wrapper uncovered and say so in the PR.

@copilot please address this.

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.

Added exact lookup-error assertions for populateDefaultWorkQueueProfiles and validateApprovedWorkQueueTargets. I left the profile-target lookup prefix uncovered: that caller applies filepath.Base before lookup, so traversal input is normalized and cannot exercise the same invalid-name lookup path. Added in 6623326.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (pkg/workflow/work_queue_policy.go:572): What this is: This marker type and its classifier exist only to tell the three callers whether resolution failed in findWorkflowFile or in mdHasWorkQueueWorker. Problem: For an invalid target such as ../outside, the helper wraps the lookup error and each caller immediately detects that wrapper just to add its own prefix; the extraction adds more error plumbing than it removes. Fix: Return a sourceFound/compiler-managed flag alongside the raw error, so callers can distinguish lookup failure from source inspection failure without workQueueTargetLookupError, Unwrap, and errors.As. If we skip it: Future target-validation changes must maintain three copies of this classification path. - Extract shared work-queue worker target resolution #75807 (comment)
  3. Review (pkg/workflow/work_queue_policy.go:589): [/codebase-design] The helper removes the lookup duplication, but its error channel now carries three categories: the not-compiler-managed sentinel, the workQueueTargetLookupError wrapper, and raw parser errors. That needs a wrapper type plus two predicates, and each caller still repeats the same three-way branch. - Extract shared work-queue worker target resolution #75807 (comment)
  4. Review (pkg/workflow/work_queue_policy_test.go:44): [/tdd] The PR says lookup errors keep their caller-specific wrapping, but no test asserts the %w prefixes for the default-profile or profile-target callers. Only the approved-worker path was checked, and only manually. - Extract shared work-queue worker target resolution #75807 (comment)
  5. Fix failing check impacted-go-tests (FAILURE): https://github.com/github/gh-aw/actions/runs/42443858207/job/128618653266.
  6. Fix failing check safe_outputs (FAILURE): https://github.com/github/gh-aw/actions/runs/42445161774/job/128623620547.

Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI.

Sous-chef requested-head: d727ba1
Sous-chef requested-work: 42e5d572d9d75b7168fe7d0aeda0717cc07e65ed240f6d299e6fec661214f1ac 4d697b3cc0d6c5ecf16ca9d0dccd2b7badb5dd0730981910ad1dc4abc79ef45f 7fe7c913452ca4d4d261538258045af79d01b6768df8dac00532cadf255febc1 90b32c3acb4f1e2fd8736b78d31390e2b0070b25f695af963998f77a284bddd5 c7cf93e497befdd5e698d00101b0703e4101fe4133d86d433f7c170d07402b7e
Sous-chef requested-state: 6291bc6c07da905939d8ee1466e8bb9552dac43c552141c69d8b5f7696470719

Generated by 👨🍳 PR Sous Chef · pi · haiku45 · ~8 AIC · ⌖ ~16 AIC · ⊞ 1.2K · ◷
Comment /souschef to run again

Copilot AI commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot assignment requested for the following outstanding work:...

Sous-chef requested-head: d727ba1
Sous-chef requested-work: 42e5d572d9d75b7168fe7d0aeda0717cc07e65ed240f6d299e6fec661214f1ac 4d697b3cc0d6c5ecf16ca9d0dccd2b7badb5dd0730981910ad1dc4abc79ef45f 7fe7c913452ca4d4d261538258045af79d01b6768df8dac00532cadf255febc1 90b32c3acb4f1e2fd8736b78d31390e2b0070b25f695af963998f77a284bddd5 c7cf93e497befdd5e698d00101b0703e4101fe4133d86d433f7c170d07402b7e
Sous-chef requested-state: 6291bc6c07da905939d8ee1466e8bb9552dac43c552141c69d8b5f7696470719

Copilot AI and others added 2 commits November 8, 2026 04:37
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Triage

  • Category: refactor
  • Risk: medium
  • Priority score: 47/100 (impact 26 + urgency 10 + quality 11)
  • Action: batch_review
  • Reason: shared resolution helper reduces duplication but touches validation paths; review in the grouped pass.

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~7 AIC · ⌖ ~2 AIC · ⊞ 16K · ◷

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Fix failing check impacted-go-tests (FAILURE): https://github.com/github/gh-aw/actions/runs/42448733526/job/128633237010.

Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI.

Sous-chef requested-head: 6623326
Sous-chef requested-work: 42e5d572d9d75b7168fe7d0aeda0717cc07e65ed240f6d299e6fec661214f1ac
Sous-chef requested-state: 94bae6495d1ffa932950174890ee7b1cf920f0ae43400816bc44c8987a6544e2

Generated by 👨🍳 PR Sous Chef · pi · haiku45 · ~7 AIC · ⌖ ~11 AIC · ⊞ 1.2K · ◷
Comment /souschef to run again

Copilot AI commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot assignment requested for the following outstanding work:...

I’m starting the requested branch update and impacted Go test investigation.

Sous-chef requested-head: 6623326
Sous-chef requested-work: 42e5d572d9d75b7168fe7d0aeda0717cc07e65ed240f6d299e6fec661214f1ac
Sous-chef requested-state: 94bae6495d1ffa932950174890ee7b1cf920f0ae43400816bc44c8987a6544e2

@pelikhan

pelikhan commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts on this branch.

Copilot AI commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot assignment requested for the following outstanding work:...

I’m updating the branch with the latest main, resolving the conflict, and reproducing the impacted Go test failure.

Sous-chef requested-head: 6623326
Sous-chef requested-work: 42e5d572d9d75b7168fe7d0aeda0717cc07e65ed240f6d299e6fec661214f1ac
Sous-chef requested-state: 94bae6495d1ffa932950174890ee7b1cf920f0ae43400816bc44c8987a6544e2

@copilot resolve the merge conflicts on this branch.

Merged the latest main and resolved the conflict in pkg/workflow/mcp_scripts_shared_queries_test.go. The merge commit is 5b491602; impacted Go tests passed.

…act-worker-target-resolution

# Conflicts:
#	pkg/workflow/mcp_scripts_shared_queries_test.go

Co-authored-by: pelikhan <[email protected]>
Copilot AI requested a review from pelikhan November 8, 2026 16:46
@pelikhan
pelikhan merged commit cf3a319 into main Nov 8, 2026
44 of 46 checks passed
@pelikhan
pelikhan deleted the copilot/refactor-extract-worker-target-resolution branch November 8, 2026 16:51
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

PR triage: category=refactor | risk=medium | total=47 | breakdown=impact 26, urgency 10, quality 11 | action=batch_review | batch=pr-batch:quality-copilot

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~3 AIC · ⌖ ~2 AIC · ⊞ 15.1K · ◷

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.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.

[refactor] Extract shared work-queue worker-target resolution in work_queue_policy.go

4 participants