Skip to content

Preserve workflow source refs so updates follow releases - #74948

Merged
pelikhan merged 5 commits into
mainfrom
copilot/gh-aw-add-records-source-commit-sha
Nov 5, 2026
Merged

pelikhan merged 5 commits into
mainfrom
copilot/gh-aw-add-records-source-commit-sha

Conversation

Copilot AI commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

gh aw add ...@v1.2.0 replaced the requested tag with a commit SHA in source:, causing subsequent updates to track the default branch instead of compatible releases.

  • Source refs: Preserve explicit tags, branches, and SHAs for workflow and manifest installs; use the resolved SHA only when no ref is supplied.
  • Dependency resolution: Isolate default-ref mutations so dependency fetching cannot alter source intent.
  • Regression coverage: Cover installed frontmatter and release-based updates within the current major version.
# After adding owner/repo/workflows/x.md@v1.2.0
source: owner/repo/workflows/x.md@v1.2.0

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix gh aw add to support tagging with version instead of commit SHA Preserve workflow source refs so updates follow releases Nov 4, 2026
Copilot AI requested a review from pelikhan November 4, 2026 19:33
@pelikhan
pelikhan marked this pull request as ready for review November 4, 2026 20:01
Copilot AI adaptive review requested due to automatic review settings November 4, 2026 20:01
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail 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 Ponytail Reviewer · routed: gpt56 max · ~4 AIC · ⌖ ~1 AIC · ⊞ 118 · ◷

Generated by Ponytail Reviewer for #74948

@github-actions

github-actions Bot commented Nov 4, 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: haiku55 xhigh · ~1 AIC · ⌖ ~1 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 4, 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

This comment has been minimized.

@github-actions

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

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR adds a lot of new code to core business logic (108 new lines under pkg/), but it has no linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/74948-preserve-requested-ref-in-workflow-source-field.md. Please review and finish it before merging.

Decision found in the diff: source: will keep the ref the user asked for (tag, major ref, branch, or SHA) instead of the resolved commit SHA. The commit SHA is used only when no ref is given, for both per-file and manifest installs. Dependency fetching also works on a copy of the WorkflowSpec, so it can no longer change the recorded ref.

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

📋 What to do next
  1. Review the draft ADR on your branch. It was written from the PR diff and issue gh aw add records source: as a commit SHA, so gh aw update follows the default branch instead of releases #73077.

  2. Fill in the [TODO: verify] items: who made the decision, and whether you still want the resolved SHA kept as audit metadata (Alternative 3).

  3. Check the trade-offs: branch installs (for example @main) now record the branch name, and update will follow that branch. Existing SHA-based source: values are not migrated.

  4. Link the ADR in this PR body, for example:

    ADR: ADR-74948: Preserve the Requested Ref in the Workflow source: Field (link unavailable: invalid HTTPS URL)

Once the PR body links an ADR, this gate will run again and check that the code matches the decision.

❓ Why ADRs Matter

ADRs give the codebase a searchable, permanent record of why it looks the way it does. This change redefines what source: means: it now records what to track, not the exact commit installed. That is worth writing down for future maintainers.

📋 Michael Nygard ADR Format Reference

An ADR needs four sections: Context, Decision, Alternatives Considered, and Consequences. ADRs live in docs/adr/ and are numbered by PR number.

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

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-04T20:10:00Z
review_event: REQUEST_CHANGES
top_themes: dependency revision consistency; mutable refs during install
files_reviewed: pkg/cli/add_workflow_content.go, pkg/cli/spec.go, pkg/cli/includes.go, pkg/cli/trial_repository.go, pkg/cli/update_workflows.go
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
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 · gpt50 · ~5 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
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.

Review verdict

Request changes: dependency installation can become internally inconsistent when the requested branch or tag moves during the add operation.

Highlights
  • Pin dependency fetching to the resolved commit, matching the existing trial-install path.
  • Preserve the requested ref only for the installed source: field.

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

return fetchAllRemoteDependencies(ctx, string(sourceContent), workflowSpec, githubWorkflowsDir, opts.Verbose, opts.Force, tracker)
// Dependency fetching may fill in a default ref; preserve the requested source ref.
dependencySpec := *workflowSpec
return fetchAllRemoteDependencies(ctx, string(sourceContent), &dependencySpec, githubWorkflowsDir, opts.Verbose, opts.Force, tracker)

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.

Dependency fetching still uses the mutable requested ref instead of the exact commit that was fetched for the workflow, so includes/imports/dispatch workflows can come from a different revision than the installed workflow.

💡 Pin dependency resolution to the fetched commit

The trial path already copies the spec and sets Version to fetched.CommitSHA. This add path should do the same when sourceInfo.CommitSHA is available, while leaving the original spec unchanged for writing the requested source: ref. Otherwise a moving branch or retagged release can change between the main fetch and dependency fetch, producing an inconsistent install. Add a regression test that asserts the dependency fetch receives the resolved SHA.

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.

Fixed in 2d50115. Dependency fetching now pins the copied specification to the fetched workflow’s commit SHA while retaining the requested source ref. Regression coverage verifies direct and transitive imports use that SHA.

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

Mutable refs break merge-base tracking and can bypass release cooldowns, causing silently stale updates or premature installation of potentially compromised executable content.

2 open issues
What changed in this PR

This PR addresses #73077 by preserving requested workflow source refs, allowing release-based installs to track compatible releases rather than the default branch.

Changes:

  • Preserve explicit tags, branches, and SHAs; use the resolved SHA only when no ref was supplied.
  • Isolate dependency-fetching mutations from the original workflow specification.
  • Add regression coverage for source frontmatter and same-major release resolution.
File Description
pkg/​cli/​update_workflows_test.go Tests compatible release selection from an installed release source.
pkg/​cli/​spec.go Preserves requested refs in workflow and manifest sources.
pkg/​cli/​spec_manifest_source_test.go Covers manifest source formatting across ref types.
pkg/​cli/​add_workflow_content.go Copies the specification before dependency fetching.
pkg/​cli/​add_command_test.go Verifies installed source fields preserve explicit refs.

Review effort: Balanced (auto)

Comment thread pkg/cli/spec.go
Comment on lines +488 to +490
ref := workflow.Version
if ref == "" {
ref = commitSHA

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.

Fixed in 2d50115. Release resolution propagates CoolDownBlocked, so manifest synchronization stops before downloads or resource writes when every eligible upgrade is cooling down, including with --force. Added blocked-major-tag and eligible-fallback regressions.

Comment thread pkg/cli/spec.go
Comment on lines +488 to +490
ref := workflow.Version
if ref == "" {
ref = commitSHA

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.

Fixed in 2d50115. source retains the tracking ref; source-sha records the installed commit for immutable three-way merge bases. Direct and manifest install → branch advance → default update regressions cover local edits, advancing metadata, and repeat updates. Missing recorded manifest bases now fail without overwriting local edits.

@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 /diagnosing-bugs and /tdd. The changed source-ref logic preserves explicit release, branch, and SHA refs, isolates dependency default-ref mutation, and the targeted regression tests pass. I found no actionable correctness issues in the changed lines.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: gpt56 max · ~22 AIC · ⌖ ~1 AIC · ⊞ 5.4K
Comment /matt to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

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/cli/add_workflow_content.go:181): Dependency fetching still uses the mutable requested ref instead of the exact commit that was fetched for the workflow, so includes/imports/dispatch workflows can come from a different revision than the installed workflow. - Preserve workflow source refs so updates follow releases #74948 (comment)
  3. Review (pkg/cli/spec.go:490): Preserving a movable major tag can bypass the release cooldown for manifest installs: if v1 moves from v1.0.0 to a new v1.1.0 still in cooldown, the resolver falls back to v1 without marking the update blocked. The manifest updater then synchronizes resources from that moved tag, allowing compromised upstream executable content to be installed before the cooldown expires. Propagate the blocked-release result and skip manifest synchronization when no eligible upgrade exists, rather than fetching the mutable fallback ref. - Preserve workflow source refs so updates follow releases #74948 (comment)
  4. Review (pkg/cli/spec.go:490): Preserving a moving ref such as main without retaining the installed revision breaks default updates after the branch advances: the updater downloads both the merge base and incoming content from the new revision, so it keeps the old local body while reporting success. Keep the requested tracking ref, but persist the installed SHA separately and use it as the merge base. Add an install → branch advance → update regression test without --no-merge. - Preserve workflow source refs so updates follow releases #74948 (comment)

Once you start work, post this work summary as a PR comment, 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: 627d3c7
Sous-chef requested-work: 4f8a56196fd27f1544593e957d0a05f738a62a4058db7badf868902d304cfd97 81267e2df4332e3a1e5e4b4b774f60b4f5bf8d98f08fb6383e8381279efd2db2 f1e0a23daddf66c3e61bdf49ebcee29a22f9c970dcdc43250b996953b440c8f9
Sous-chef requested-state: 0378a6deb23ae6d9d83d83c19f560138646603717dc310431f57aa0e978fb391

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

@pelikhan

pelikhan commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Copilot AI and others added 2 commits November 4, 2026 23:08
…ords-source-commit-sha

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Ran pr-finisher and pushed 2d50115, including a clean merge of main and fixes for all three review threads. Standard lint, focused/impacted tests, workflow drift checks, and secret scanning passed. Existing custom-linter findings remain; CodeQL timed out. Thread replies are posted, but resolving threads requires a maintainer because authenticated thread-mutation tooling is unavailable. CI on the new head remains unverified; no CI was triggered and the PR was not merged.

@pelikhan
pelikhan merged commit fc4b951 into main Nov 5, 2026
66 checks passed
@pelikhan
pelikhan deleted the copilot/gh-aw-add-records-source-commit-sha branch November 5, 2026 04:05
github-actions Bot added a commit that referenced this pull request Nov 5, 2026
…forks flag

Document safe-output output_id/depends-on dependency gating (#74376),
the managed source-sha frontmatter field (#74948), the
dangerously-allow-pull-request-target-forks-all feature flag (#74884),
and detection report-as-issue permission requirements (#74949).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.1

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.

gh aw add records source: as a commit SHA, so gh aw update follows the default branch instead of releases

4 participants