Skip to content

Make pr-docs-check target-branch resolution deterministic and prefer latest aspire.dev release branch - #16950

Merged
David Pine (IEvangelist) merged 3 commits into
mainfrom
dapine/improve-gh-aw-reliability
May 12, 2026
Merged

Make pr-docs-check target-branch resolution deterministic and prefer latest aspire.dev release branch#16950
David Pine (IEvangelist) merged 3 commits into
mainfrom
dapine/improve-gh-aw-reliability

Conversation

@IEvangelist

Copy link
Copy Markdown
Member

Description

Makes the pr-docs-check workflow's target-branch resolution deterministic and correct for the actual layout of microsoft/aspire.dev. Previously the LLM agent re-derived the target branch from the source PR's milestone, linked issues, and base ref on every run — sometimes drafting docs PRs against branches that don't exist on microsoft/aspire.dev (notably release/13.3, which only exists on microsoft/aspire).

Two commits:

1. Make the resolution deterministic (pre-agent-steps:)

A new pre-agent-steps: block runs a shell resolver before the agent starts and writes the result to .pr-docs-check/target.json. The agent reads that file verbatim instead of recomputing.

Inputs considered (in priority order):

  1. Source PR milestone title (e.g. 13.3release/13.3, 13.2.1release/13.2.1)
  2. Linked-issue milestone titles from the source PR's body / closing keywords
  3. PR base ref if it matches ^release/X.Y(.Z)?$
  4. Otherwise: candidate is main

The resolver mints an aspire-bot GitHub App installation token (via actions/create-github-app-token@v3.1.1) scoped to both microsoft/aspire and microsoft/aspire.dev, so cross-repo reads work even if Microsoft's org policy blocks the default GITHUB_TOKEN against external repos. The same token is used by the agent's checkout and tool calls downstream — the workflow no longer relies on GITHUB_TOKEN for cross-repo access.

target.json records the full reasoning chain (candidate_target_branch, candidate_source, candidate_source_detail, available_release_branches, enumeration_source, target_resolution, linked_issues) so the draft docs PR can explain the choice and humans can audit it without re-running.

2. Prefer latest release/* on aspire.dev over main

The first commit's policy was "candidate exists on aspire.dev → use it; otherwise fall back to main". That turned out to be wrong for the actual repo layout:

  • microsoft/aspire keeps a release branch for every shipped release (release/8.0, release/9.0, …, release/13.3).
  • microsoft/aspire.dev only keeps a release/* branch for the upcoming release. Older release-branch content gets merged into main as those releases ship.

So when a microsoft/aspire PR is milestoned 13.3 but release/13.3 no longer exists on aspire.dev (only release/13.4 does), falling back to main is wrong — those docs should still land on the staged release/13.4 branch. Same goes for microsoft/aspire PRs against main with no milestone: their docs should target the latest staged release branch on aspire.dev, not aspire.dev's main.

New policy, in priority order:

  1. exact_match — candidate release/* exists on aspire.dev → use it.
  2. latest_release_fallbackaspire.dev has at least one release/* → use the highest-versioned one (sort with sort -V after stripping the release/ prefix so 13.4 beats 9.5).
  3. main_fallbackaspire.dev has zero release/* branches → use main.

fell_back_to_main (boolean) was replaced by target_resolution (the enum above) so the agent can describe the resolution accurately in its draft PR. The agent prompt's Step 9 PR-description guidance was updated with three matching example sentences.

Verification

Dispatched against two PRs on microsoft/aspire from this branch:

Source PR Milestone Candidate Effective branch on aspire.dev Resolution
#16933 13.4 release/13.4 release/13.4 exact_match
#16553 13.3 (missing on aspire.dev) release/13.3 release/13.4 latest_release_fallback

Both runs end-to-end green: pre-agent resolver → agent → detection → safe outputs → notify-source-PR comment.

Misc

  • Bumped 11 references to github/gh-aw v0.69.0 URLs in .github/agents/agentic-workflows.agent.md to v0.72.0 so the doc lines up with the pinned compiler.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No — workflow-level change; verified by dispatching against two real merged PRs from this branch.
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No

The workflow now mints an ASPIRE_BOT_APP_ID/ASPIRE_BOT_PRIVATE_KEY installation token in pre-agent-steps and passes that to checkout, tools, and safe-outputs. The app is already installed on both microsoft/aspire and microsoft/aspire.dev and is consumed identically by other workflows in this repo. The token has contents: read on both repos and pull-requests: write on aspire.dev so the draft PR and source-PR notification still work; nothing was broadened beyond what the previous default GITHUB_TOKEN would have needed.

Add a pre-agent-steps bash step that resolves the target microsoft/aspire.dev
branch up front (PR milestone -> linked-issue milestone -> PR base ref ->
main), validates it against the live release/* branch list on aspire.dev,
and writes the result to .pr-docs-check/target.json. The agent now reads
that JSON as the single source of truth instead of re-deriving the branch
from scratch.

The resolver authenticates with a short-lived installation token minted
from the existing ASPIRE_BOT_APP_ID app (already trusted by checkout:,
tools.github, and safe-outputs), so cross-repo reads of aspire.dev still
work under Microsoft org token policy that can restrict GITHUB_TOKEN.

Also bump v0.69.0 -> v0.72.0 doc URLs in
.github/agents/agentic-workflows.agent.md to match the pinned gh-aw
compiler version.
When the milestone-derived target branch does not exist on microsoft/aspire.dev (or the candidate falls back to main because the source PR has no milestone), use the latest release/* branch on aspire.dev instead of main. The docs site only keeps a release/* branch for the upcoming release; older release-branch content is merged into main as those releases ship, so docs for upcoming-release work should always land on the staged release branch when one exists. Only fall back to main when aspire.dev has no release/* branches at all.

Replace fell_back_to_main boolean with a target_resolution enum (exact_match | latest_release_fallback | main_fallback) in .pr-docs-check/target.json so the agent can describe the resolution accurately in the draft PR description.
@github-actions

github-actions Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16950

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16950"

@IEvangelist
David Pine (IEvangelist) marked this pull request as ready for review May 11, 2026 17:38
Copilot AI review requested due to automatic review settings May 11, 2026 17:38

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

This PR updates the pr-docs-check agentic workflow to deterministically resolve the target microsoft/aspire.dev branch via a pre-agent shell resolver, and changes the fallback policy to prefer the latest release/* branch on aspire.dev when an exact release branch match doesn’t exist.

Changes:

  • Add pre-agent-steps that computes and writes .pr-docs-check/target.json, and require the agent to use effective_target_branch from that file.
  • Update target-branch policy to prefer the latest release/* branch on aspire.dev over main when an exact release branch isn’t available.
  • Refresh gh-aw documentation links and regenerate the compiled workflow lockfile.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
.github/workflows/pr-docs-check.md Adds deterministic pre-agent target-branch resolution and updates the agent instructions accordingly.
.github/workflows/pr-docs-check.lock.yml Regenerates compiled workflow to include the new pre-agent steps and updated prompt hash.
.github/agents/agentic-workflows.agent.md Updates gh-aw documentation URLs to the newer pinned version.

Comment thread .github/workflows/pr-docs-check.md Outdated
Comment thread .github/workflows/pr-docs-check.md Outdated
Comment on lines +454 to +457
LINKED_FILE="$(mktemp)"
: > "${LINKED_FILE}"
python3 - "${PR_BODY}" > "${LINKED_FILE}" <<'PY' || true
import re, sys
Comment on lines +677 to +681
# --- 7. Emit target.json ---------------------------------------------
jq -n \
--argjson pr_number "${PR_NUMBER}" \
--arg pr_base_ref "${PR_BASE_REF}" \
--arg candidate "${CANDIDATE}" \
…d parser failure, accurate checkout comment

1. Validate PR_NUMBER is a positive integer before passing it to jq via --argjson or to gh api. workflow_dispatch inputs are free-form strings; non-numeric or whitespace values now fail early with a clear error instead of an opaque jq parse error.

2. Accept the optional colon GitHub allows in linked-issue closing keywords (Fixes: #123, Closes: #123, Resolves: #789). The previous regex required whitespace immediately after the keyword and silently ignored these common forms.

3. Drop the '|| true' guard on the python3 linked-issue parser. If python fails (missing on runner, oversized body, etc.) the resolver should fail loudly rather than silently produce an empty linked-issue set and pick the wrong target branch.

4. Rewrite the inaccurate comment on the checkout block: when local 'fetch: release/*' produces nothing the resolver falls back to a gh api /branches call, so target-branch selection stays correct - it does not always fall back to main.
@github-actions

Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 78 recordings uploaded (commit 75fc3bc)

View all recordings
Status Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireInitSingleFileAppHostRunsViaDotnetRunAppHost ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View Recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
DeployK8sBasicApiService ▶️ View Recording
DeployK8sWithExternalHelmChart ▶️ View Recording
DeployK8sWithGarnet ▶️ View Recording
DeployK8sWithMongoDB ▶️ View Recording
DeployK8sWithMySql ▶️ View Recording
DeployK8sWithPostgres ▶️ View Recording
DeployK8sWithRabbitMQ ▶️ View Recording
DeployK8sWithRedis ▶️ View Recording
DeployK8sWithSqlServer ▶️ View Recording
DeployK8sWithValkey ▶️ View Recording
DeployTypeScriptAppToKubernetes ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View Recording
DoListStepsShowsPipelineSteps ▶️ View Recording
DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InteractiveCSharpInitCreatesExpectedFiles ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LatestCliCanStartStableChannelAppHost ▶️ View Recording
LatestCliCanStartStableChannelTypeScriptAppHost ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
OtelLogsReturnsStructuredLogsFromStarterAppCore ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View Recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #25688929129

@IEvangelist
David Pine (IEvangelist) merged commit 0015b9f into main May 12, 2026
297 checks passed
@github-actions github-actions Bot added this to the 13.4 milestone May 12, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

CI/workflow infrastructure change only — improves internal pr-docs-check target-branch resolution logic with no user-facing API, feature, or configuration changes to Aspire itself. No documentation updates are needed.

Nell Shamrell-Harrington (nellshamrell) pushed a commit to nellshamrell/aspire that referenced this pull request May 18, 2026
…latest aspire.dev release branch (microsoft#16950)

* Make pr-docs-check target-branch resolution deterministic

Add a pre-agent-steps bash step that resolves the target microsoft/aspire.dev
branch up front (PR milestone -> linked-issue milestone -> PR base ref ->
main), validates it against the live release/* branch list on aspire.dev,
and writes the result to .pr-docs-check/target.json. The agent now reads
that JSON as the single source of truth instead of re-deriving the branch
from scratch.

The resolver authenticates with a short-lived installation token minted
from the existing ASPIRE_BOT_APP_ID app (already trusted by checkout:,
tools.github, and safe-outputs), so cross-repo reads of aspire.dev still
work under Microsoft org token policy that can restrict GITHUB_TOKEN.

Also bump v0.69.0 -> v0.72.0 doc URLs in
.github/agents/agentic-workflows.agent.md to match the pinned gh-aw
compiler version.

* Prefer latest aspire.dev release branch over main when candidate missing

When the milestone-derived target branch does not exist on microsoft/aspire.dev (or the candidate falls back to main because the source PR has no milestone), use the latest release/* branch on aspire.dev instead of main. The docs site only keeps a release/* branch for the upcoming release; older release-branch content is merged into main as those releases ship, so docs for upcoming-release work should always land on the staged release branch when one exists. Only fall back to main when aspire.dev has no release/* branches at all.

Replace fell_back_to_main boolean with a target_resolution enum (exact_match | latest_release_fallback | main_fallback) in .pr-docs-check/target.json so the agent can describe the resolution accurately in the draft PR description.

* Address Copilot review: PR_NUMBER validation, linked-issue colon, loud parser failure, accurate checkout comment

1. Validate PR_NUMBER is a positive integer before passing it to jq via --argjson or to gh api. workflow_dispatch inputs are free-form strings; non-numeric or whitespace values now fail early with a clear error instead of an opaque jq parse error.

2. Accept the optional colon GitHub allows in linked-issue closing keywords (Fixes: microsoft#123, Closes: microsoft#123, Resolves: microsoft#789). The previous regex required whitespace immediately after the keyword and silently ignored these common forms.

3. Drop the '|| true' guard on the python3 linked-issue parser. If python fails (missing on runner, oversized body, etc.) the resolver should fail loudly rather than silently produce an empty linked-issue set and pick the wrong target branch.

4. Rewrite the inaccurate comment on the checkout block: when local 'fetch: release/*' produces nothing the resolver falls back to a gh api /branches call, so target-branch selection stays correct - it does not always fall back to main.
@IEvangelist
David Pine (IEvangelist) deleted the dapine/improve-gh-aw-reliability branch May 28, 2026 01:12
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants