From 6820167b5d6ce34449f9184f05d63fc806832666 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Wed, 4 Nov 2026 16:04:19 +0100 Subject: [PATCH 01/18] fix(#8672): resolve mint URL from config in dispatch workflows Dispatch jobs still passed the FULLSEND_MINT_URL snapshot as --mint-url, so a hand-edited config mint_url never took effect on live runs after #8400. Resolve overlay then base then the workflow input before mint-token and fullsend run, and vendor the helper script to enrolled repos. Signed-off-by: fmuntean Co-authored-by: Cursor --- .../resolve-effective-mint-url-test.sh | 72 +++++++++++++++++ .github/scripts/resolve-effective-mint-url.sh | 47 +++++++++++ .github/workflows/reusable-dispatch.yml | 80 +++++++++++++++---- .github/workflows/reusable-prioritize.yml | 16 +++- docs/contributing/config-source-inventory.md | 6 +- internal/scaffold/vendorcontent.go | 13 +-- internal/scaffold/vendorcontent_test.go | 1 + internal/scaffold/vendormanifest.go | 1 + .../scaffold/workflow_call_alignment_test.go | 9 ++- 9 files changed, 219 insertions(+), 26 deletions(-) create mode 100755 .github/scripts/resolve-effective-mint-url-test.sh create mode 100755 .github/scripts/resolve-effective-mint-url.sh diff --git a/.github/scripts/resolve-effective-mint-url-test.sh b/.github/scripts/resolve-effective-mint-url-test.sh new file mode 100755 index 0000000000..0ab1e01d18 --- /dev/null +++ b/.github/scripts/resolve-effective-mint-url-test.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +# resolve-effective-mint-url-test.sh — Tests for resolve-effective-mint-url.sh +# +# Run from the repo root: +# bash .github/scripts/resolve-effective-mint-url-test.sh + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SCRIPT="${SCRIPT_DIR}/resolve-effective-mint-url.sh" +FAILURES=0 + +TMPDIR="$(mktemp -d)" +trap 'rm -rf "${TMPDIR}"' EXIT + +run_resolve() { + local fallback="${1:-}" + local output_file="${TMPDIR}/github-output.txt" + : >"${output_file}" + ( + cd "${TMPDIR}/repo" + export GITHUB_OUTPUT="${output_file}" + export FALLBACK_MINT_URL="${fallback}" + bash "${SCRIPT}" + ) + grep '^mint_url=' "${output_file}" | cut -d= -f2- +} + +setup_repo() { + rm -rf "${TMPDIR}/repo" + mkdir -p "${TMPDIR}/repo/.fullsend" + cd "${TMPDIR}/repo" +} + +assert_eq() { + local name="$1" want="$2" got="$3" + if [[ "${want}" != "${got}" ]]; then + echo "FAIL: ${name}: want ${want@Q}, got ${got@Q}" + FAILURES=$((FAILURES + 1)) + fi +} + +setup_repo +assert_eq "fallback only" "https://fallback.example" "$(run_resolve "https://fallback.example")" + +setup_repo +printf 'version: "1"\nmint_url: https://overlay.example\n' >.fullsend/config.yaml +assert_eq "overlay wins" "https://overlay.example" "$(run_resolve "https://fallback.example")" + +setup_repo +printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml +assert_eq "base only" "https://base.example" "$(run_resolve "https://fallback.example")" + +setup_repo +printf 'version: "1"\n' >.fullsend/config.yaml +printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml +assert_eq "silent overlay uses base" "https://base.example" "$(run_resolve "https://fallback.example")" + +setup_repo +printf 'version: "1"\nmint_url: https://overlay.example\n' >.fullsend/config.yaml +printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml +assert_eq "overlay beats base" "https://overlay.example" "$(run_resolve "https://fallback.example")" + +setup_repo +assert_eq "empty fallback" "" "$(run_resolve "")" + +if [[ "${FAILURES}" -eq 0 ]]; then + echo "All tests passed." +else + echo "${FAILURES} test(s) failed." + exit 1 +fi diff --git a/.github/scripts/resolve-effective-mint-url.sh b/.github/scripts/resolve-effective-mint-url.sh new file mode 100755 index 0000000000..9deed96c7c --- /dev/null +++ b/.github/scripts/resolve-effective-mint-url.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# resolve-effective-mint-url.sh — Layered mint_url for GitHub dispatch workflows. +# +# Mirrors ConfigMintURLFromFile (overlay, then base) with FALLBACK_MINT_URL as +# the FULLSEND_MINT_URL snapshot when both files are silent. Stops short of the +# compiled default (https://mint.fullsend.sh), matching resolveMintURL in the CLI. +# +# Requires: yq, GITHUB_OUTPUT, FALLBACK_MINT_URL (may be empty). + +set -euo pipefail + +if [[ -z "${GITHUB_OUTPUT:-}" ]]; then + echo "GITHUB_OUTPUT is required" >&2 + exit 1 +fi + +_effective="${FALLBACK_MINT_URL:-}" + +_read_mint_url() { + local file="$1" + local value + value=$(yq -r '.mint_url // ""' "${file}" 2>/dev/null || echo "") + if [[ -n "${value}" && "${value}" != "null" ]]; then + printf '%s' "${value}" + fi +} + +if [[ -f .fullsend/config.yaml ]]; then + overlay=$(_read_mint_url .fullsend/config.yaml) + if [[ -n "${overlay}" ]]; then + _effective="${overlay}" + elif [[ -f .fullsend/config.base.yaml ]]; then + base=$(_read_mint_url .fullsend/config.base.yaml) + if [[ -n "${base}" ]]; then + _effective="${base}" + fi + fi +elif [[ -f .fullsend/config.base.yaml ]]; then + base=$(_read_mint_url .fullsend/config.base.yaml) + if [[ -n "${base}" ]]; then + _effective="${base}" + fi +fi + +{ + printf 'mint_url=%s\n' "${_effective}" +} >>"${GITHUB_OUTPUT}" diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index d34d76ff86..30aabbf6bb 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -126,6 +126,7 @@ jobs: stage: ${{ steps.agent-check.outputs.skipped != 'true' && steps.route.outputs.stage || '' }} trigger_source: ${{ steps.route.outputs.trigger_source }} event_payload: ${{ steps.payload.outputs.event_payload }} + mint_url: ${{ steps.resolve-mint.outputs.mint_url }} steps: - name: Validate event_action if: ${{ inputs.event_action == '' }} @@ -147,10 +148,27 @@ jobs: sparse-checkout: | .fullsend/config.yaml .fullsend/config.base.yaml + .github/scripts/resolve-effective-mint-url.sh + .defaults/.github/scripts/resolve-effective-mint-url.sh /OWNERS /OWNERS_ALIASES sparse-checkout-cone-mode: false + - name: Resolve effective mint URL + id: resolve-mint + env: + FALLBACK_MINT_URL: ${{ inputs.mint_url }} + run: | + set -euo pipefail + for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do + if [[ -f "${candidate}" ]]; then + bash "${candidate}" + exit 0 + fi + done + echo "::error::resolve-effective-mint-url.sh is missing; re-run fullsend github converge" + exit 1 + - name: Determine stage id: bash-route env: @@ -707,7 +725,7 @@ jobs: GITHUB_EVENT_NAME: ${{ github.event_name }} EVENT_ACTION: ${{ inputs.event_action }} ROUTE_AGENT: ${{ steps.cel-opt-in.outputs.agent }} - FULLSEND_MINT_URL: ${{ inputs.mint_url }} + FULLSEND_MINT_URL: ${{ steps.resolve-mint.outputs.mint_url }} run: | set -euo pipefail # gha_text makes a value safe inside a ::notice::/::warning::/::error:: @@ -1056,7 +1074,7 @@ jobs: with: role: triage repos: ${{ steps.workspace.outputs.repo_name }} - mint_url: ${{ inputs.mint_url }} + mint_url: ${{ needs.route.outputs.mint_url }} - name: Checkout target repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -1114,7 +1132,7 @@ jobs: status-repo: ${{ github.repository }} status-number: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} - mint-url: ${{ inputs.mint_url }} + mint-url: ${{ needs.route.outputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} code: @@ -1167,7 +1185,7 @@ jobs: with: role: coder repos: ${{ steps.workspace.outputs.repo_name }} - mint_url: ${{ inputs.mint_url }} + mint_url: ${{ needs.route.outputs.mint_url }} - name: Checkout target repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -1246,7 +1264,7 @@ jobs: status-repo: ${{ github.repository }} status-number: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} - mint-url: ${{ inputs.mint_url }} + mint-url: ${{ needs.route.outputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} review: @@ -1298,7 +1316,7 @@ jobs: with: role: review repos: ${{ steps.workspace.outputs.repo_name }} - mint_url: ${{ inputs.mint_url }} + mint_url: ${{ needs.route.outputs.mint_url }} - name: Checkout target repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -1376,7 +1394,7 @@ jobs: status-repo: ${{ github.repository }} status-number: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.number || fromJSON(needs.route.outputs.event_payload).issue.number }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} - mint-url: ${{ inputs.mint_url }} + mint-url: ${{ needs.route.outputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} fix: @@ -1429,7 +1447,7 @@ jobs: with: role: coder repos: ${{ steps.workspace.outputs.repo_name }} - mint_url: ${{ inputs.mint_url }} + mint_url: ${{ needs.route.outputs.mint_url }} - name: Resolve bot identity env: @@ -1640,7 +1658,7 @@ jobs: status-repo: ${{ github.repository }} status-number: ${{ steps.context.outputs.pr_number }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} - mint-url: ${{ inputs.mint_url }} + mint-url: ${{ needs.route.outputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} retro: @@ -1691,7 +1709,7 @@ jobs: with: role: retro repos: ${{ steps.workspace.outputs.repo_name }} - mint_url: ${{ inputs.mint_url }} + mint_url: ${{ needs.route.outputs.mint_url }} - name: Checkout target repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -1750,7 +1768,7 @@ jobs: status-repo: ${{ github.repository }} status-number: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.number || fromJSON(needs.route.outputs.event_payload).issue.number }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} - mint-url: ${{ inputs.mint_url }} + mint-url: ${{ needs.route.outputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} prioritize: @@ -1845,7 +1863,7 @@ jobs: run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ github.repository }} status-number: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} - mint-url: ${{ inputs.mint_url }} + mint-url: ${{ needs.route.outputs.mint_url }} harness-dispatch: name: Harness dispatch @@ -1878,8 +1896,25 @@ jobs: .defaults/action.yml .defaults/.github/actions/install-fullsend-cli/ .fullsend/.defaults/action.yml + .github/scripts/resolve-effective-mint-url.sh + .defaults/.github/scripts/resolve-effective-mint-url.sh sparse-checkout-cone-mode: false + - name: Resolve effective mint URL + id: resolve-mint + env: + FALLBACK_MINT_URL: ${{ inputs.mint_url }} + run: | + set -euo pipefail + for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do + if [[ -f "${candidate}" ]]; then + bash "${candidate}" + exit 0 + fi + done + echo "::error::resolve-effective-mint-url.sh is missing; re-run fullsend github converge" + exit 1 + - name: Detect registered harness triggers id: triggers shell: bash @@ -1990,7 +2025,7 @@ jobs: GH_TOKEN: ${{ github.token }} GITHUB_EVENT_NAME: ${{ github.event_name }} EVENT_ACTION: ${{ inputs.event_action }} - FULLSEND_MINT_URL: ${{ inputs.mint_url }} + FULLSEND_MINT_URL: ${{ steps.resolve-mint.outputs.mint_url }} run: | set -euo pipefail if [[ "${{ steps.triggers.outputs.has_triggers }}" != "true" ]]; then @@ -2064,6 +2099,21 @@ jobs: mkdir -p .github/scripts cp "${SRC}/.github/scripts/setup-agent-env.sh" .github/scripts/setup-agent-env.sh + - name: Resolve effective mint URL + id: resolve-mint + env: + FALLBACK_MINT_URL: ${{ inputs.mint_url }} + run: | + set -euo pipefail + for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do + if [[ -f "${candidate}" ]]; then + bash "${candidate}" + exit 0 + fi + done + echo "::error::resolve-effective-mint-url.sh is missing; re-run fullsend github converge" + exit 1 + - name: Extract repo metadata id: repo-parts shell: bash @@ -2089,7 +2139,7 @@ jobs: with: role: ${{ matrix.role }} repos: ${{ steps.repo-parts.outputs.name }} - mint_url: ${{ inputs.mint_url }} + mint_url: ${{ steps.resolve-mint.outputs.mint_url }} - name: Checkout target repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -2210,5 +2260,5 @@ jobs: status-repo: ${{ matrix.status_repo }} status-number: ${{ matrix.status_number }} status-comment-id: ${{ fromJSON(matrix.event_payload).comment.id }} - mint-url: ${{ inputs.mint_url }} + mint-url: ${{ steps.resolve-mint.outputs.mint_url }} pr-head-sha: ${{ fromJSON(matrix.event_payload).pull_request.head.sha || '' }} diff --git a/.github/workflows/reusable-prioritize.yml b/.github/workflows/reusable-prioritize.yml index 4ad66325c5..c718766498 100644 --- a/.github/workflows/reusable-prioritize.yml +++ b/.github/workflows/reusable-prioritize.yml @@ -128,6 +128,20 @@ jobs: mkdir -p .github/scripts cp "${SRC}/.github/scripts/setup-agent-env.sh" .github/scripts/setup-agent-env.sh + - name: Resolve effective mint URL + id: resolve-mint + env: + FALLBACK_MINT_URL: ${{ inputs.mint_url }} + run: | + set -euo pipefail + for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do + if [[ -f "${candidate}" ]]; then + bash "${candidate}" + exit 0 + fi + done + echo "::error::resolve-effective-mint-url.sh is missing; re-run fullsend github converge" + exit 1 - name: Validate enrollment and extract repository metadata id: repo-parts @@ -187,6 +201,6 @@ jobs: runner_secrets: ${{ secrets.FULLSEND_GITHUB_RUNNER_SECRETS }} version: ${{ inputs.fullsend_version || job.workflow_sha }} fullsend-dir: .fullsend - mint-url: ${{ inputs.mint_url }} + mint-url: ${{ steps.resolve-mint.outputs.mint_url }} gcp_wif_provider: ${{ secrets.FULLSEND_GCP_WIF_PROVIDER }} gcp_project_id: ${{ secrets.FULLSEND_GCP_PROJECT_ID }} diff --git a/docs/contributing/config-source-inventory.md b/docs/contributing/config-source-inventory.md index 26686a15c4..99e4d139a3 100644 --- a/docs/contributing/config-source-inventory.md +++ b/docs/contributing/config-source-inventory.md @@ -49,7 +49,9 @@ its own separate allowlist of `FULLSEND_*` repository variables into the job environment. The OpenAI Workload Identity variables come from a separate opt-in step, `fullsend inference openai import --variables`. Dispatch steps in `reusable-dispatch.yml` also `yq` `.fullsend/config.yaml` -directly and do not read `config.base.yaml`. +directly for some checks and do not read `config.base.yaml`, except +`mint_url` and `kill_switch`, which use the layered files (see their rows +below). A value set only in the base file is invisible to a reader that looks at the repository variable or at `config.yaml` alone. @@ -81,6 +83,7 @@ These fields live on `perRepoConfig` in `internal/config/config.go`. Unset means | `models.aliases` | Remap of `opus`, `sonnet`, `haiku`, `fable` | Overlay, base, compiled alias table | Per-key merge, then the compiled table | Model resolution | Already layered | Yes. Fleet model pins belong here. | | `inference.provider` | Inference backend id | Overlay, base, compiled `vertex` | Overlay, then base, then `vertex`. No workflow variable found | Accessor at install and run setup | Already layered | Yes. | | `kill_switch` | Stop all agent dispatch | Overlay, base, compiled `false` | Overlay, then base, then `false`. Both direct reads — GitHub's "Check kill switch" bash step and GitLab's `run-agent-job.sh` — now consult `config.base.yaml` when `config.yaml` is silent on the key, matching the Go accessor | `internal/harnessdispatch`, `reusable-dispatch.yml`, and GitLab's `run-agent-job.sh` | Already layered | Yes. A central stop belongs in the base file. | +| `mint_url` | Token mint address | `--mint-url`, overlay, base, `FULLSEND_MINT_URL`, compiled `https://mint.fullsend.sh` | `--mint-url` when explicitly passed, then overlay, then base, then `FULLSEND_MINT_URL` / the workflow `mint_url` input snapshot (`resolveMintURL` and `resolve-effective-mint-url.sh`, #8400, #8672). Workflows resolve overlay → base → `inputs.mint_url` before `mint-token` and before passing `mint-url` to `fullsend run`. Stops short of the compiled default when every layer is silent (same as the CLI file layer). `mint token` has no `--fullsend-dir`, so it stays flag then env | `fullsend run`, `reconcile-status`, `mint token`, `fullsend dispatch`, `reusable-dispatch.yml`, `reusable-prioritize.yml`. GitLab never mints | Already layered. `FULLSEND_MINT_URL` stays the fallback when both YAML layers are silent. OIDC downgrade for `reconcile-status` and status comments, and mint-endpoint checks for file-only prioritize, remain tracked separately | Yes. | `authorization` (extra permission sources, today `owners_file` and `jira`) is overlay-only by design, not an accessor gap: a base-file value under this @@ -108,7 +111,6 @@ The Go accessor layers these. The bash steps in `.github/workflows/reusable-disp | `runtime`, and per-agent `agents[].runtime` | Which runtime runs (`claude`, `pi`, `codex`, `dummy`) | `--runtime`, `FULLSEND_RUNTIME` (repository variable copied by `setup-agent-env.sh`), agent entry, repo `runtime:`, compiled `claude` | Flag, then `FULLSEND_RUNTIME`, then the agent entry, then repo `runtime:`, then `claude` (`docs/cli/run.md`) | `fullsend run` | File should win. Flag stays first. `FULLSEND_RUNTIME` stays as the fallback | Yes, for the fleet default. | | `agents[].model` | Model for one agent | `--model`, `FULLSEND_MODEL`, then `FULLSEND_PI_MODEL` or `FULLSEND_CODEX_MODEL` when that runtime is selected, agent entry, harness, frontmatter | Flag, then `FULLSEND_MODEL`, then the runtime-scoped alias, then the agent entry | `fullsend run` | File should win. Same fallback rule | The shared default can live on the base-file agent entry. | | `agents[].effort` | Effort for one agent | `--effort`, `FULLSEND_EFFORT`, agent entry, harness | Flag, then `FULLSEND_EFFORT`, then the agent entry | `fullsend run` | File should win. Same fallback rule | Same as model. | -| `mint_url` | Token mint address | `--mint-url`, `FULLSEND_MINT_URL`, layered `mint_url`, compiled `https://mint.fullsend.sh` | `fullsend run` and `reconcile-status --fullsend-dir`: flag, then layered `mint_url`, then `FULLSEND_MINT_URL` (`resolveMintURL`, #8400). Only `runAgent`'s agent-token mint downgrades a file-sourced value to warn-and-skip (ambient `GH_TOKEN`) when GitHub Actions OIDC is unavailable; `reconcile-status` and the status-comment mint still attempt it and fail — fail-closed for `reconcile-status`, a per-call warning for status comments. `mint token` has no `--fullsend-dir`, so it stays flag then env | `fullsend run`, `reconcile-status`, `mint token`, `fullsend dispatch` (GitHub bot-role lookup, flag-less: layered `mint_url`, then `FULLSEND_MINT_URL`). GitLab never mints | File should win: done for `run` and `reconcile-status`. This has a live effect today, not only a future one: `action.yml` (`MINT_FLAGS`) omits `--mint-url` entirely when the composite action's `mint_url` input is empty, rather than passing an empty value, and the `prioritize` paths (`reusable-prioritize.yml` and the inlined `prioritize` job in `reusable-dispatch.yml`) have no upfront mint-token step gating on `FULLSEND_MINT_URL` the way triage/code/review/fix/retro/harness-run do. So when that repository variable is unset, those two paths (and any other composite-action caller that leaves `mint-url` empty) already mint — and notify — from a file-only `mint_url` inside real GitHub Actions runs with working OIDC. Every other dispatched stage still passes `mint-url` built from the possibly-stale variable, so the flag wins there until the `route` job computes the value from the file itself. `mint token` stays flag-then-env; it has no directory to layer from. The OIDC downgrade should extend to `reconcile-status` and status comments for consistency — tracked, not yet done. Confirming the mint endpoint serves the `prioritize` role wherever `mint_url` is file-only is tracked, not yet done (#8400 review) | Yes. | | `inference.region` | GCP region for inference | Layered `inference.region`, compiled `global`. Workflows pass `vars.FULLSEND_GCP_REGION` as `gcp_region`, which becomes `CLOUD_ML_REGION`. GitLab `run-agent-job.sh` exports `CLOUD_ML_REGION` from `FULLSEND_GCP_REGION` | The job environment, not the file. Setup writes the file's effective region into `FULLSEND_GCP_REGION` at install time. A later edit to the file does not change the variable | Vertex client via `CLOUD_ML_REGION`. The accessor is used at install and converge | File should win for the binary. Keep `FULLSEND_GCP_REGION` as the fallback and as the value old workflows still pass | Yes. | | `inference.project` | GCP project for inference | Layered `inference.project` (no compiled default), secret `FULLSEND_GCP_PROJECT_ID` | The secret. Workflows export it as `ANTHROPIC_VERTEX_PROJECT_ID`. `setup-gcp` uses the same secret to authenticate before the binary runs | Google auth action and the Vertex client | Leave the secret for the auth action. The file should be what the binary reads, with the secret as fallback. Do not put the secret value only in git if the auth action still needs it | Yes for the project id the binary uses. The secret remains for the auth action. | | `inference.wif_provider` | Workload Identity provider resource name | Layered `inference.wif_provider` (no compiled default), secret `FULLSEND_GCP_WIF_PROVIDER` | The secret. `setup-gcp` reads it | Google auth action | Leave the secret for the auth action. The file should describe the provider the binary needs. Same split as the project id | Yes for the non-secret resource name. The credential material stays a secret. | diff --git a/internal/scaffold/vendorcontent.go b/internal/scaffold/vendorcontent.go index 0a88c12e21..941484c08d 100644 --- a/internal/scaffold/vendorcontent.go +++ b/internal/scaffold/vendorcontent.go @@ -173,12 +173,13 @@ func isVendoredReusableWorkflow(path string) bool { // and scripts/renovate/update-openshell-sha.sh) must stay at their // current path regardless of whether they are listed. var vendoredDefaultsScripts = map[string]bool{ - ".github/scripts/check-fix-eligibility.sh": true, - ".github/scripts/count-fix-commits.jq": true, - ".github/scripts/install-openshell.sh": true, - ".github/scripts/install-podman.sh": true, - ".github/scripts/openshell-version.sh": true, - ".github/scripts/pre-fetch-review-body.sh": true, + ".github/scripts/check-fix-eligibility.sh": true, + ".github/scripts/count-fix-commits.jq": true, + ".github/scripts/install-openshell.sh": true, + ".github/scripts/install-podman.sh": true, + ".github/scripts/openshell-version.sh": true, + ".github/scripts/pre-fetch-review-body.sh": true, + ".github/scripts/resolve-effective-mint-url.sh": true, } // vendoredDefaultsActions is the explicit allowlist of .github/actions/ diff --git a/internal/scaffold/vendorcontent_test.go b/internal/scaffold/vendorcontent_test.go index cdae5276dc..6da0bc0812 100644 --- a/internal/scaffold/vendorcontent_test.go +++ b/internal/scaffold/vendorcontent_test.go @@ -81,6 +81,7 @@ func TestIsVendoredDefaultsInfra(t *testing.T) { assert.True(t, isVendoredDefaultsInfra(".github/scripts/count-fix-commits.jq")) assert.True(t, isVendoredDefaultsInfra(".github/scripts/install-podman.sh")) assert.True(t, isVendoredDefaultsInfra(".github/scripts/pre-fetch-review-body.sh")) + assert.True(t, isVendoredDefaultsInfra(".github/scripts/resolve-effective-mint-url.sh")) assert.False(t, isVendoredDefaultsInfra(".github/scripts/run.sh")) assert.False(t, isVendoredDefaultsInfra(".github/scripts/check-fix-eligibility-test.sh")) assert.False(t, isVendoredDefaultsInfra(".github/scripts/count-fix-commits-test.sh")) diff --git a/internal/scaffold/vendormanifest.go b/internal/scaffold/vendormanifest.go index 18d309c469..82cf7eb77a 100644 --- a/internal/scaffold/vendormanifest.go +++ b/internal/scaffold/vendormanifest.go @@ -162,6 +162,7 @@ var vendoredDefaultsInfraPaths = []string{ ".github/scripts/install-podman.sh", ".github/scripts/openshell-version.sh", ".github/scripts/pre-fetch-review-body.sh", + ".github/scripts/resolve-effective-mint-url.sh", } // enumerateVendoredPaths returns embed-derived paths for a current --vendor install layout. diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index 7dcf7f02d7..5ea094762c 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -869,6 +869,11 @@ func TestReusableDispatchJobsReceiveMintOIDC(t *testing.T) { require.NoError(t, err) require.NoError(t, yaml.Unmarshal(content, &workflow)) + routeJob, ok := workflow.Jobs["route"] + require.True(t, ok, "route job must exist") + assert.Equal(t, "${{ steps.resolve-mint.outputs.mint_url }}", routeJob.Outputs["mint_url"], + "route job must export the resolved mint URL for stage jobs") + for _, tc := range []struct { jobName string stepName string @@ -892,8 +897,8 @@ func TestReusableDispatchJobsReceiveMintOIDC(t *testing.T) { require.NotEmpty(t, dispatch.Name, "job %q must include step %q", tc.jobName, tc.stepName) assert.Contains(t, dispatch.Run, "--input-driver gha-event", "step %q must use the GitHub event driver", tc.stepName) - assert.Equal(t, "${{ inputs.mint_url }}", dispatch.Env["FULLSEND_MINT_URL"], - "step %q must receive the configured mint URL", tc.stepName) + assert.Equal(t, "${{ steps.resolve-mint.outputs.mint_url }}", dispatch.Env["FULLSEND_MINT_URL"], + "step %q must receive the resolved mint URL", tc.stepName) for name, value := range job.Outputs { assert.NotContains(t, name, "ACTIONS_ID_TOKEN_REQUEST_TOKEN", "job %q output names must not expose the OIDC request token", tc.jobName) From e0cce734671ee24f55eba6c72b99a4aff26f84bd Mon Sep 17 00:00:00 2001 From: fmuntean Date: Thu, 5 Nov 2026 12:27:47 +0100 Subject: [PATCH 02/18] fix(#8672): address PR 9104 review on mint URL resolver Fetch the resolver from job.workflow_repository when upstream callers lack a vendored copy, validate HTTPS mint URLs in bash, run shell tests in CI, and document layered config precedence for operators. Signed-off-by: fmuntean Co-authored-by: Cursor --- .../resolve-effective-mint-url-test.sh | 33 +++- .github/scripts/resolve-effective-mint-url.sh | 36 ++++- .github/workflows/reusable-dispatch.yml | 144 +++++++++++++++--- .github/workflows/reusable-prioritize.yml | 48 +++++- Makefile | 1 + .../infrastructure/mint-administration.md | 2 +- internal/scaffold/vendorcontent_test.go | 1 + .../scaffold/workflow_call_alignment_test.go | 44 ++++++ 8 files changed, 269 insertions(+), 40 deletions(-) diff --git a/.github/scripts/resolve-effective-mint-url-test.sh b/.github/scripts/resolve-effective-mint-url-test.sh index 0ab1e01d18..12b2d79d72 100755 --- a/.github/scripts/resolve-effective-mint-url-test.sh +++ b/.github/scripts/resolve-effective-mint-url-test.sh @@ -16,16 +16,29 @@ trap 'rm -rf "${TMPDIR}"' EXIT run_resolve() { local fallback="${1:-}" local output_file="${TMPDIR}/github-output.txt" + local oldpwd="${PWD}" : >"${output_file}" - ( - cd "${TMPDIR}/repo" - export GITHUB_OUTPUT="${output_file}" - export FALLBACK_MINT_URL="${fallback}" - bash "${SCRIPT}" - ) + cd "${TMPDIR}/repo" + GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" bash "${SCRIPT}" + cd "${oldpwd}" grep '^mint_url=' "${output_file}" | cut -d= -f2- } +run_resolve_expect_fail() { + local fallback="${1:-}" + local output_file="${TMPDIR}/github-output.txt" + local oldpwd="${PWD}" + : >"${output_file}" + cd "${TMPDIR}/repo" + if GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" bash "${SCRIPT}"; then + cd "${oldpwd}" + echo "FAIL: ${2}: expected non-zero exit" + FAILURES=$((FAILURES + 1)) + return 0 + fi + cd "${oldpwd}" +} + setup_repo() { rm -rf "${TMPDIR}/repo" mkdir -p "${TMPDIR}/repo/.fullsend" @@ -64,6 +77,14 @@ assert_eq "overlay beats base" "https://overlay.example" "$(run_resolve "https:/ setup_repo assert_eq "empty fallback" "" "$(run_resolve "")" +setup_repo +printf 'version: "1"\nmint_url: http://evil.example\n' >.fullsend/config.yaml +run_resolve_expect_fail "https://fallback.example" "reject http mint_url" + +setup_repo +printf 'version: "1"\nmint_url: https://user:pass@mint.example\n' >.fullsend/config.yaml +run_resolve_expect_fail "https://fallback.example" "reject userinfo mint_url" + if [[ "${FAILURES}" -eq 0 ]]; then echo "All tests passed." else diff --git a/.github/scripts/resolve-effective-mint-url.sh b/.github/scripts/resolve-effective-mint-url.sh index 9deed96c7c..e80fe3d46a 100755 --- a/.github/scripts/resolve-effective-mint-url.sh +++ b/.github/scripts/resolve-effective-mint-url.sh @@ -14,12 +14,42 @@ if [[ -z "${GITHUB_OUTPUT:-}" ]]; then exit 1 fi +if ! command -v yq >/dev/null 2>&1; then + echo "::error::yq is required to resolve mint_url from config" >&2 + exit 1 +fi + _effective="${FALLBACK_MINT_URL:-}" +# Matches validateDeclaredMintURL in internal/repos/managed_config.go. +_validate_resolved_mint_url() { + local url="$1" + if [[ -z "${url}" ]]; then + return 0 + fi + if [[ "${url}" == *$'\n'* || "${url}" == *$'\r'* ]]; then + echo "::error::mint_url must not contain CR or LF" >&2 + return 1 + fi + if [[ ! "${url}" =~ ^https://[^/?#]+ ]]; then + echo "::error::mint_url must be a valid HTTPS URL, got ${url@Q}" >&2 + return 1 + fi + local after_scheme="${url#https://}" + if [[ "${after_scheme}" == *@* ]]; then + echo "::error::mint_url must not contain userinfo, got ${url@Q}" >&2 + return 1 + fi + return 0 +} + _read_mint_url() { local file="$1" local value - value=$(yq -r '.mint_url // ""' "${file}" 2>/dev/null || echo "") + if ! value=$(yq -r '.mint_url // ""' "${file}"); then + echo "::error::failed to read mint_url from ${file}" >&2 + exit 1 + fi if [[ -n "${value}" && "${value}" != "null" ]]; then printf '%s' "${value}" fi @@ -42,6 +72,10 @@ elif [[ -f .fullsend/config.base.yaml ]]; then fi fi +if ! _validate_resolved_mint_url "${_effective}"; then + exit 1 +fi + { printf 'mint_url=%s\n' "${_effective}" } >>"${GITHUB_OUTPUT}" diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index 30aabbf6bb..ec3836fd48 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -154,20 +154,52 @@ jobs: /OWNERS_ALIASES sparse-checkout-cone-mode: false - - name: Resolve effective mint URL - id: resolve-mint - env: - FALLBACK_MINT_URL: ${{ inputs.mint_url }} + - name: Prepare mint URL resolver script + id: mint-resolver-script run: | set -euo pipefail + RESOLVER="" for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do if [[ -f "${candidate}" ]]; then - bash "${candidate}" - exit 0 + RESOLVER="${candidate}" + break fi done - echo "::error::resolve-effective-mint-url.sh is missing; re-run fullsend github converge" - exit 1 + if [[ -n "${RESOLVER}" ]]; then + echo "path=${RESOLVER}" >> "${GITHUB_OUTPUT}" + echo "fetched=false" >> "${GITHUB_OUTPUT}" + else + echo "fetched=true" >> "${GITHUB_OUTPUT}" + fi + + - name: Checkout workflow mint URL resolver + if: steps.mint-resolver-script.outputs.fetched == 'true' + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: ${{ job.workflow_repository }} + ref: ${{ job.workflow_sha }} + path: ${{ runner.temp }}/workflow-mint-resolver + fetch-depth: 1 + persist-credentials: false + sparse-checkout: | + .github/scripts/resolve-effective-mint-url.sh + sparse-checkout-cone-mode: false + + - name: Resolve effective mint URL + id: resolve-mint + env: + FALLBACK_MINT_URL: ${{ inputs.mint_url }} + run: | + set -euo pipefail + RESOLVER="${{ steps.mint-resolver-script.outputs.path }}" + if [[ -z "${RESOLVER}" ]]; then + RESOLVER="${RUNNER_TEMP}/workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" + fi + if [[ ! -f "${RESOLVER}" ]]; then + echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" + exit 1 + fi + bash "${RESOLVER}" - name: Determine stage id: bash-route @@ -1900,20 +1932,52 @@ jobs: .defaults/.github/scripts/resolve-effective-mint-url.sh sparse-checkout-cone-mode: false - - name: Resolve effective mint URL - id: resolve-mint - env: - FALLBACK_MINT_URL: ${{ inputs.mint_url }} + - name: Prepare mint URL resolver script + id: mint-resolver-script run: | set -euo pipefail + RESOLVER="" for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do if [[ -f "${candidate}" ]]; then - bash "${candidate}" - exit 0 + RESOLVER="${candidate}" + break fi done - echo "::error::resolve-effective-mint-url.sh is missing; re-run fullsend github converge" - exit 1 + if [[ -n "${RESOLVER}" ]]; then + echo "path=${RESOLVER}" >> "${GITHUB_OUTPUT}" + echo "fetched=false" >> "${GITHUB_OUTPUT}" + else + echo "fetched=true" >> "${GITHUB_OUTPUT}" + fi + + - name: Checkout workflow mint URL resolver + if: steps.mint-resolver-script.outputs.fetched == 'true' + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: ${{ job.workflow_repository }} + ref: ${{ job.workflow_sha }} + path: ${{ runner.temp }}/workflow-mint-resolver + fetch-depth: 1 + persist-credentials: false + sparse-checkout: | + .github/scripts/resolve-effective-mint-url.sh + sparse-checkout-cone-mode: false + + - name: Resolve effective mint URL + id: resolve-mint + env: + FALLBACK_MINT_URL: ${{ inputs.mint_url }} + run: | + set -euo pipefail + RESOLVER="${{ steps.mint-resolver-script.outputs.path }}" + if [[ -z "${RESOLVER}" ]]; then + RESOLVER="${RUNNER_TEMP}/workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" + fi + if [[ ! -f "${RESOLVER}" ]]; then + echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" + exit 1 + fi + bash "${RESOLVER}" - name: Detect registered harness triggers id: triggers @@ -2099,20 +2163,52 @@ jobs: mkdir -p .github/scripts cp "${SRC}/.github/scripts/setup-agent-env.sh" .github/scripts/setup-agent-env.sh - - name: Resolve effective mint URL - id: resolve-mint - env: - FALLBACK_MINT_URL: ${{ inputs.mint_url }} + - name: Prepare mint URL resolver script + id: mint-resolver-script run: | set -euo pipefail + RESOLVER="" for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do if [[ -f "${candidate}" ]]; then - bash "${candidate}" - exit 0 + RESOLVER="${candidate}" + break fi done - echo "::error::resolve-effective-mint-url.sh is missing; re-run fullsend github converge" - exit 1 + if [[ -n "${RESOLVER}" ]]; then + echo "path=${RESOLVER}" >> "${GITHUB_OUTPUT}" + echo "fetched=false" >> "${GITHUB_OUTPUT}" + else + echo "fetched=true" >> "${GITHUB_OUTPUT}" + fi + + - name: Checkout workflow mint URL resolver + if: steps.mint-resolver-script.outputs.fetched == 'true' + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: ${{ job.workflow_repository }} + ref: ${{ job.workflow_sha }} + path: ${{ runner.temp }}/workflow-mint-resolver + fetch-depth: 1 + persist-credentials: false + sparse-checkout: | + .github/scripts/resolve-effective-mint-url.sh + sparse-checkout-cone-mode: false + + - name: Resolve effective mint URL + id: resolve-mint + env: + FALLBACK_MINT_URL: ${{ inputs.mint_url }} + run: | + set -euo pipefail + RESOLVER="${{ steps.mint-resolver-script.outputs.path }}" + if [[ -z "${RESOLVER}" ]]; then + RESOLVER="${RUNNER_TEMP}/workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" + fi + if [[ ! -f "${RESOLVER}" ]]; then + echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" + exit 1 + fi + bash "${RESOLVER}" - name: Extract repo metadata id: repo-parts diff --git a/.github/workflows/reusable-prioritize.yml b/.github/workflows/reusable-prioritize.yml index c718766498..0cf5d6bd32 100644 --- a/.github/workflows/reusable-prioritize.yml +++ b/.github/workflows/reusable-prioritize.yml @@ -128,20 +128,52 @@ jobs: mkdir -p .github/scripts cp "${SRC}/.github/scripts/setup-agent-env.sh" .github/scripts/setup-agent-env.sh - - name: Resolve effective mint URL - id: resolve-mint - env: - FALLBACK_MINT_URL: ${{ inputs.mint_url }} + - name: Prepare mint URL resolver script + id: mint-resolver-script run: | set -euo pipefail + RESOLVER="" for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do if [[ -f "${candidate}" ]]; then - bash "${candidate}" - exit 0 + RESOLVER="${candidate}" + break fi done - echo "::error::resolve-effective-mint-url.sh is missing; re-run fullsend github converge" - exit 1 + if [[ -n "${RESOLVER}" ]]; then + echo "path=${RESOLVER}" >> "${GITHUB_OUTPUT}" + echo "fetched=false" >> "${GITHUB_OUTPUT}" + else + echo "fetched=true" >> "${GITHUB_OUTPUT}" + fi + + - name: Checkout workflow mint URL resolver + if: steps.mint-resolver-script.outputs.fetched == 'true' + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: ${{ job.workflow_repository }} + ref: ${{ job.workflow_sha }} + path: ${{ runner.temp }}/workflow-mint-resolver + fetch-depth: 1 + persist-credentials: false + sparse-checkout: | + .github/scripts/resolve-effective-mint-url.sh + sparse-checkout-cone-mode: false + + - name: Resolve effective mint URL + id: resolve-mint + env: + FALLBACK_MINT_URL: ${{ inputs.mint_url }} + run: | + set -euo pipefail + RESOLVER="${{ steps.mint-resolver-script.outputs.path }}" + if [[ -z "${RESOLVER}" ]]; then + RESOLVER="${RUNNER_TEMP}/workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" + fi + if [[ ! -f "${RESOLVER}" ]]; then + echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" + exit 1 + fi + bash "${RESOLVER}" - name: Validate enrollment and extract repository metadata id: repo-parts diff --git a/Makefile b/Makefile index 4ba82d1550..265b7d1a2d 100644 --- a/Makefile +++ b/Makefile @@ -190,6 +190,7 @@ script-test: $(call run-timed,bash scripts/check-e2e-authorization-test.sh) $(call run-timed,bash scripts/redact-behaviour-artifacts-test.sh) $(call run-timed,bash .github/scripts/check-fix-eligibility-test.sh) + $(call run-timed,bash .github/scripts/resolve-effective-mint-url-test.sh) $(call run-timed,bash .github/scripts/count-fix-commits-test.sh) $(call run-timed,bash .github/scripts/pre-fetch-review-body-test.sh) $(call run-timed,bash scripts/check-agents-gate-pin-test.sh) diff --git a/docs/guides/infrastructure/mint-administration.md b/docs/guides/infrastructure/mint-administration.md index ce23442812..8aefb628a1 100644 --- a/docs/guides/infrastructure/mint-administration.md +++ b/docs/guides/infrastructure/mint-administration.md @@ -32,7 +32,7 @@ The fullsend team operates a public hosted community mint service. Install the s https://mint.fullsend.sh ``` -The CLI defaults to this URL. You can also set the `FULLSEND_MINT_URL` repository/org variable in GitHub explicitly. If you are using the hosted community mint, the rest of this guide (deploying, enrolling, troubleshooting) is for platform operators managing self-hosted mints — you do not need to manage mint infrastructure yourself. +The CLI defaults to this URL. You can also set the `FULLSEND_MINT_URL` repository/org variable in GitHub explicitly. When `mint_url` is declared in `.fullsend/config.yaml` or `config.base.yaml`, dispatch resolves that layered value before the variable (see [Layered configuration reference](layered-config-reference.md)); the variable remains the fallback when both files are silent on `mint_url`. If you are using the hosted community mint, the rest of this guide (deploying, enrolling, troubleshooting) is for platform operators managing self-hosted mints — you do not need to manage mint infrastructure yourself. ## Prerequisites diff --git a/internal/scaffold/vendorcontent_test.go b/internal/scaffold/vendorcontent_test.go index 6da0bc0812..f743d9d516 100644 --- a/internal/scaffold/vendorcontent_test.go +++ b/internal/scaffold/vendorcontent_test.go @@ -82,6 +82,7 @@ func TestIsVendoredDefaultsInfra(t *testing.T) { assert.True(t, isVendoredDefaultsInfra(".github/scripts/install-podman.sh")) assert.True(t, isVendoredDefaultsInfra(".github/scripts/pre-fetch-review-body.sh")) assert.True(t, isVendoredDefaultsInfra(".github/scripts/resolve-effective-mint-url.sh")) + assert.False(t, isVendoredDefaultsInfra(".github/scripts/resolve-effective-mint-url-test.sh")) assert.False(t, isVendoredDefaultsInfra(".github/scripts/run.sh")) assert.False(t, isVendoredDefaultsInfra(".github/scripts/check-fix-eligibility-test.sh")) assert.False(t, isVendoredDefaultsInfra(".github/scripts/count-fix-commits-test.sh")) diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index 5ea094762c..f149142b39 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -911,6 +911,50 @@ func TestReusableDispatchJobsReceiveMintOIDC(t *testing.T) { "the workflow must not copy the OIDC request token into logs or matrix data") } +// TestReusableDispatchMintResolverFetchesFromWorkflow ensures upstream-mode +// callers without a vendored resolver can sparse-checkout the script from +// job.workflow_repository (#9104). +func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { + type workflowStep struct { + Name string `yaml:"name"` + If string `yaml:"if"` + } + type workflowJob struct { + Steps []workflowStep `yaml:"steps"` + } + var workflow struct { + Jobs map[string]workflowJob `yaml:"jobs"` + } + + content, err := os.ReadFile(filepath.Join("..", "..", ".github", "workflows", "reusable-dispatch.yml")) + require.NoError(t, err) + require.NoError(t, yaml.Unmarshal(content, &workflow)) + + for _, jobName := range []string{"route", "harness-dispatch", "harness-run"} { + t.Run(jobName, func(t *testing.T) { + job, ok := workflow.Jobs[jobName] + require.True(t, ok, "job %q must exist", jobName) + names := make([]string, 0, len(job.Steps)) + var checkoutStep workflowStep + for _, step := range job.Steps { + names = append(names, step.Name) + if step.Name == "Checkout workflow mint URL resolver" { + checkoutStep = step + } + } + assert.Contains(t, names, "Prepare mint URL resolver script") + assert.Contains(t, names, "Checkout workflow mint URL resolver") + assert.Contains(t, checkoutStep.If, "mint-resolver-script.outputs.fetched") + }) + } + assert.Contains(t, string(content), "workflow-mint-resolver", + "upstream resolver checkout must use a dedicated path under RUNNER_TEMP") + + prioritize := string(loadRepoFile(".github/workflows/reusable-prioritize.yml")(t)) + assert.Contains(t, prioritize, "Checkout workflow mint URL resolver") + assert.Contains(t, prioritize, "Prepare mint URL resolver script") +} + // TestCustomAppSetReviewBotWiring ensures every GitHub review/fix dispatch // path receives the configured app-set prefix and recognizes its exact review // bot identity. From 407e3558d8a38c00c9f558eb06b6702b945c6b16 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Thu, 5 Nov 2026 16:13:30 +0100 Subject: [PATCH 03/18] fix(#8672): gate mint URL resolver and align URL checks Check the workflow resolver out under GITHUB_WORKSPACE, run it only after route/kill-switch and harness trigger gating, match Go HTTPS/userinfo rules without echoing rejected URLs, and cover those cases in tests. Signed-off-by: fmuntean Co-authored-by: Cursor --- .../resolve-effective-mint-url-test.sh | 32 +++- .github/scripts/resolve-effective-mint-url.sh | 45 +++++- .github/workflows/reusable-dispatch.yml | 148 +++++++++--------- .github/workflows/reusable-prioritize.yml | 4 +- .../scaffold/workflow_call_alignment_test.go | 51 +++++- 5 files changed, 189 insertions(+), 91 deletions(-) diff --git a/.github/scripts/resolve-effective-mint-url-test.sh b/.github/scripts/resolve-effective-mint-url-test.sh index 12b2d79d72..6908a46ae1 100755 --- a/.github/scripts/resolve-effective-mint-url-test.sh +++ b/.github/scripts/resolve-effective-mint-url-test.sh @@ -26,17 +26,25 @@ run_resolve() { run_resolve_expect_fail() { local fallback="${1:-}" + local name="${2}" + local leak="${3:-}" local output_file="${TMPDIR}/github-output.txt" + local stderr_file="${TMPDIR}/stderr.txt" local oldpwd="${PWD}" : >"${output_file}" + : >"${stderr_file}" cd "${TMPDIR}/repo" - if GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" bash "${SCRIPT}"; then + if GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" bash "${SCRIPT}" 2>"${stderr_file}"; then cd "${oldpwd}" - echo "FAIL: ${2}: expected non-zero exit" + echo "FAIL: ${name}: expected non-zero exit" FAILURES=$((FAILURES + 1)) return 0 fi cd "${oldpwd}" + if [[ -n "${leak}" ]] && grep -F -- "${leak}" "${stderr_file}" >/dev/null; then + echo "FAIL: ${name}: stderr leaked ${leak@Q}" + FAILURES=$((FAILURES + 1)) + fi } setup_repo() { @@ -83,7 +91,25 @@ run_resolve_expect_fail "https://fallback.example" "reject http mint_url" setup_repo printf 'version: "1"\nmint_url: https://user:pass@mint.example\n' >.fullsend/config.yaml -run_resolve_expect_fail "https://fallback.example" "reject userinfo mint_url" +run_resolve_expect_fail "https://fallback.example" "reject userinfo mint_url" "user:pass" + +setup_repo +printf 'version: "1"\nmint_url: https://mint.example/a@b\n' >.fullsend/config.yaml +assert_eq "at-sign in path is not userinfo" "https://mint.example/a@b" "$(run_resolve "")" + +setup_repo +printf 'version: "1"\nmint_url: HTTPS://mint.example\n' >.fullsend/config.yaml +assert_eq "uppercase scheme" "HTTPS://mint.example" "$(run_resolve "")" + +setup_repo +assert_eq "localhost http fallback" "http://localhost:8080" "$(run_resolve "http://localhost:8080")" + +setup_repo +assert_eq "loopback http fallback" "http://127.0.0.1:8080" "$(run_resolve "http://127.0.0.1:8080")" + +setup_repo +printf 'version: "1"\nmint_url: http://localhost:8080\n' >.fullsend/config.yaml +run_resolve_expect_fail "" "reject localhost http from config file" if [[ "${FAILURES}" -eq 0 ]]; then echo "All tests passed." diff --git a/.github/scripts/resolve-effective-mint-url.sh b/.github/scripts/resolve-effective-mint-url.sh index e80fe3d46a..cb8f30ccc2 100755 --- a/.github/scripts/resolve-effective-mint-url.sh +++ b/.github/scripts/resolve-effective-mint-url.sh @@ -5,6 +5,10 @@ # the FULLSEND_MINT_URL snapshot when both files are silent. Stops short of the # compiled default (https://mint.fullsend.sh), matching resolveMintURL in the CLI. # +# Declared file values use the same HTTPS/userinfo gate as +# validateDeclaredMintURL. The FULLSEND_MINT_URL fallback also allows loopback +# HTTP (localhost / 127.0.0.1), matching mintclient.MintToken. +# # Requires: yq, GITHUB_OUTPUT, FALLBACK_MINT_URL (may be empty). set -euo pipefail @@ -20,10 +24,13 @@ if ! command -v yq >/dev/null 2>&1; then fi _effective="${FALLBACK_MINT_URL:-}" +_from_file=false -# Matches validateDeclaredMintURL in internal/repos/managed_config.go. +# Aligns with validateDeclaredMintURL for file-sourced values. Never echoes +# the URL: rejected values may contain userinfo. _validate_resolved_mint_url() { local url="$1" + local from_file="${2:-false}" if [[ -z "${url}" ]]; then return 0 fi @@ -31,16 +38,35 @@ _validate_resolved_mint_url() { echo "::error::mint_url must not contain CR or LF" >&2 return 1 fi - if [[ ! "${url}" =~ ^https://[^/?#]+ ]]; then - echo "::error::mint_url must be a valid HTTPS URL, got ${url@Q}" >&2 + + local scheme rest authority host + if [[ "${url}" =~ ^([A-Za-z][A-Za-z0-9+.-]*)://(.*)$ ]]; then + scheme="$(printf '%s' "${BASH_REMATCH[1]}" | tr '[:upper:]' '[:lower:]')" + rest="${BASH_REMATCH[2]}" + else + echo "::error::mint_url must be a valid HTTPS URL" >&2 + return 1 + fi + authority="${rest%%[/?#]*}" + if [[ -z "${authority}" ]]; then + echo "::error::mint_url must be a valid HTTPS URL" >&2 return 1 fi - local after_scheme="${url#https://}" - if [[ "${after_scheme}" == *@* ]]; then - echo "::error::mint_url must not contain userinfo, got ${url@Q}" >&2 + if [[ "${authority}" == *@* ]]; then + echo "::error::mint_url must not contain userinfo" >&2 return 1 fi - return 0 + if [[ "${scheme}" == "https" ]]; then + return 0 + fi + if [[ "${from_file}" != "true" && "${scheme}" == "http" ]]; then + host="${authority%%:*}" + if [[ "${host}" == "localhost" || "${host}" == "127.0.0.1" ]]; then + return 0 + fi + fi + echo "::error::mint_url must be a valid HTTPS URL" >&2 + return 1 } _read_mint_url() { @@ -59,20 +85,23 @@ if [[ -f .fullsend/config.yaml ]]; then overlay=$(_read_mint_url .fullsend/config.yaml) if [[ -n "${overlay}" ]]; then _effective="${overlay}" + _from_file=true elif [[ -f .fullsend/config.base.yaml ]]; then base=$(_read_mint_url .fullsend/config.base.yaml) if [[ -n "${base}" ]]; then _effective="${base}" + _from_file=true fi fi elif [[ -f .fullsend/config.base.yaml ]]; then base=$(_read_mint_url .fullsend/config.base.yaml) if [[ -n "${base}" ]]; then _effective="${base}" + _from_file=true fi fi -if ! _validate_resolved_mint_url "${_effective}"; then +if ! _validate_resolved_mint_url "${_effective}" "${_from_file}"; then exit 1 fi diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index ec3836fd48..3990aa8b3f 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -154,53 +154,6 @@ jobs: /OWNERS_ALIASES sparse-checkout-cone-mode: false - - name: Prepare mint URL resolver script - id: mint-resolver-script - run: | - set -euo pipefail - RESOLVER="" - for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do - if [[ -f "${candidate}" ]]; then - RESOLVER="${candidate}" - break - fi - done - if [[ -n "${RESOLVER}" ]]; then - echo "path=${RESOLVER}" >> "${GITHUB_OUTPUT}" - echo "fetched=false" >> "${GITHUB_OUTPUT}" - else - echo "fetched=true" >> "${GITHUB_OUTPUT}" - fi - - - name: Checkout workflow mint URL resolver - if: steps.mint-resolver-script.outputs.fetched == 'true' - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - repository: ${{ job.workflow_repository }} - ref: ${{ job.workflow_sha }} - path: ${{ runner.temp }}/workflow-mint-resolver - fetch-depth: 1 - persist-credentials: false - sparse-checkout: | - .github/scripts/resolve-effective-mint-url.sh - sparse-checkout-cone-mode: false - - - name: Resolve effective mint URL - id: resolve-mint - env: - FALLBACK_MINT_URL: ${{ inputs.mint_url }} - run: | - set -euo pipefail - RESOLVER="${{ steps.mint-resolver-script.outputs.path }}" - if [[ -z "${RESOLVER}" ]]; then - RESOLVER="${RUNNER_TEMP}/workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" - fi - if [[ ! -f "${RESOLVER}" ]]; then - echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" - exit 1 - fi - bash "${RESOLVER}" - - name: Determine stage id: bash-route env: @@ -757,7 +710,7 @@ jobs: GITHUB_EVENT_NAME: ${{ github.event_name }} EVENT_ACTION: ${{ inputs.event_action }} ROUTE_AGENT: ${{ steps.cel-opt-in.outputs.agent }} - FULLSEND_MINT_URL: ${{ steps.resolve-mint.outputs.mint_url }} + FULLSEND_MINT_URL: ${{ inputs.mint_url }} run: | set -euo pipefail # gha_text makes a value safe inside a ::notice::/::warning::/::error:: @@ -915,6 +868,55 @@ jobs: exit 1 fi + - name: Prepare mint URL resolver script + if: steps.route.outputs.stage != '' + id: mint-resolver-script + run: | + set -euo pipefail + RESOLVER="" + for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do + if [[ -f "${candidate}" ]]; then + RESOLVER="${candidate}" + break + fi + done + if [[ -n "${RESOLVER}" ]]; then + echo "path=${RESOLVER}" >> "${GITHUB_OUTPUT}" + echo "fetched=false" >> "${GITHUB_OUTPUT}" + else + echo "fetched=true" >> "${GITHUB_OUTPUT}" + fi + + - name: Checkout workflow mint URL resolver + if: steps.route.outputs.stage != '' && steps.mint-resolver-script.outputs.fetched == 'true' + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: ${{ job.workflow_repository }} + ref: ${{ job.workflow_sha }} + path: .workflow-mint-resolver + fetch-depth: 1 + persist-credentials: false + sparse-checkout: | + .github/scripts/resolve-effective-mint-url.sh + sparse-checkout-cone-mode: false + + - name: Resolve effective mint URL + if: steps.route.outputs.stage != '' + id: resolve-mint + env: + FALLBACK_MINT_URL: ${{ inputs.mint_url }} + run: | + set -euo pipefail + RESOLVER="${{ steps.mint-resolver-script.outputs.path }}" + if [[ -z "${RESOLVER}" ]]; then + RESOLVER=".workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" + fi + if [[ ! -f "${RESOLVER}" ]]; then + echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" + exit 1 + fi + bash "${RESOLVER}" + - name: Validate agents config if: steps.route.outputs.stage != '' run: | @@ -1932,7 +1934,27 @@ jobs: .defaults/.github/scripts/resolve-effective-mint-url.sh sparse-checkout-cone-mode: false + - name: Detect registered harness triggers + id: triggers + shell: bash + run: | + set -euo pipefail + has_triggers=false + if [[ -f .fullsend/config.yaml ]]; then + if grep -qE 'source:[[:space:]]*https?://' .fullsend/config.yaml; then + has_triggers=true + elif grep -qE '^[[:space:]]*agents:' .fullsend/config.yaml \ + && grep -qE '^[[:space:]]*-[[:space:]]*name:|^[[:space:]]*name:' .fullsend/config.yaml; then + # Agents are registered; let dispatch enumerate triggers. Skipping only + # when the config has no agents avoids false negatives from harness path + # layout while still skipping the CLI install on empty configs. + has_triggers=true + fi + fi + echo "has_triggers=${has_triggers}" >> "${GITHUB_OUTPUT}" + - name: Prepare mint URL resolver script + if: steps.triggers.outputs.has_triggers == 'true' id: mint-resolver-script run: | set -euo pipefail @@ -1951,12 +1973,12 @@ jobs: fi - name: Checkout workflow mint URL resolver - if: steps.mint-resolver-script.outputs.fetched == 'true' + if: steps.triggers.outputs.has_triggers == 'true' && steps.mint-resolver-script.outputs.fetched == 'true' uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: ${{ job.workflow_repository }} ref: ${{ job.workflow_sha }} - path: ${{ runner.temp }}/workflow-mint-resolver + path: .workflow-mint-resolver fetch-depth: 1 persist-credentials: false sparse-checkout: | @@ -1964,6 +1986,7 @@ jobs: sparse-checkout-cone-mode: false - name: Resolve effective mint URL + if: steps.triggers.outputs.has_triggers == 'true' id: resolve-mint env: FALLBACK_MINT_URL: ${{ inputs.mint_url }} @@ -1971,7 +1994,7 @@ jobs: set -euo pipefail RESOLVER="${{ steps.mint-resolver-script.outputs.path }}" if [[ -z "${RESOLVER}" ]]; then - RESOLVER="${RUNNER_TEMP}/workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" + RESOLVER=".workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" fi if [[ ! -f "${RESOLVER}" ]]; then echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" @@ -1979,25 +2002,6 @@ jobs: fi bash "${RESOLVER}" - - name: Detect registered harness triggers - id: triggers - shell: bash - run: | - set -euo pipefail - has_triggers=false - if [[ -f .fullsend/config.yaml ]]; then - if grep -qE 'source:[[:space:]]*https?://' .fullsend/config.yaml; then - has_triggers=true - elif grep -qE '^[[:space:]]*agents:' .fullsend/config.yaml \ - && grep -qE '^[[:space:]]*-[[:space:]]*name:|^[[:space:]]*name:' .fullsend/config.yaml; then - # Agents are registered; let dispatch enumerate triggers. Skipping only - # when the config has no agents avoids false negatives from harness path - # layout while still skipping the CLI install on empty configs. - has_triggers=true - fi - fi - echo "has_triggers=${has_triggers}" >> "${GITHUB_OUTPUT}" - - name: Detect dispatch CLI install mode id: mode if: steps.triggers.outputs.has_triggers == 'true' @@ -2187,7 +2191,7 @@ jobs: with: repository: ${{ job.workflow_repository }} ref: ${{ job.workflow_sha }} - path: ${{ runner.temp }}/workflow-mint-resolver + path: .workflow-mint-resolver fetch-depth: 1 persist-credentials: false sparse-checkout: | @@ -2202,7 +2206,7 @@ jobs: set -euo pipefail RESOLVER="${{ steps.mint-resolver-script.outputs.path }}" if [[ -z "${RESOLVER}" ]]; then - RESOLVER="${RUNNER_TEMP}/workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" + RESOLVER=".workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" fi if [[ ! -f "${RESOLVER}" ]]; then echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" diff --git a/.github/workflows/reusable-prioritize.yml b/.github/workflows/reusable-prioritize.yml index 0cf5d6bd32..856577aa99 100644 --- a/.github/workflows/reusable-prioritize.yml +++ b/.github/workflows/reusable-prioritize.yml @@ -152,7 +152,7 @@ jobs: with: repository: ${{ job.workflow_repository }} ref: ${{ job.workflow_sha }} - path: ${{ runner.temp }}/workflow-mint-resolver + path: .workflow-mint-resolver fetch-depth: 1 persist-credentials: false sparse-checkout: | @@ -167,7 +167,7 @@ jobs: set -euo pipefail RESOLVER="${{ steps.mint-resolver-script.outputs.path }}" if [[ -z "${RESOLVER}" ]]; then - RESOLVER="${RUNNER_TEMP}/workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" + RESOLVER=".workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" fi if [[ ! -f "${RESOLVER}" ]]; then echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index f149142b39..389441fe9d 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -877,9 +877,19 @@ func TestReusableDispatchJobsReceiveMintOIDC(t *testing.T) { for _, tc := range []struct { jobName string stepName string + mintURL string }{ - {jobName: "route", stepName: "Evaluate CEL route"}, - {jobName: "harness-dispatch", stepName: "Run fullsend dispatch"}, + { + jobName: "route", + stepName: "Evaluate CEL route", + // CLI resolveMintURL layers config files over FULLSEND_MINT_URL. + mintURL: "${{ inputs.mint_url }}", + }, + { + jobName: "harness-dispatch", + stepName: "Run fullsend dispatch", + mintURL: "${{ steps.resolve-mint.outputs.mint_url }}", + }, } { t.Run(tc.jobName, func(t *testing.T) { job, ok := workflow.Jobs[tc.jobName] @@ -897,8 +907,8 @@ func TestReusableDispatchJobsReceiveMintOIDC(t *testing.T) { require.NotEmpty(t, dispatch.Name, "job %q must include step %q", tc.jobName, tc.stepName) assert.Contains(t, dispatch.Run, "--input-driver gha-event", "step %q must use the GitHub event driver", tc.stepName) - assert.Equal(t, "${{ steps.resolve-mint.outputs.mint_url }}", dispatch.Env["FULLSEND_MINT_URL"], - "step %q must receive the resolved mint URL", tc.stepName) + assert.Equal(t, tc.mintURL, dispatch.Env["FULLSEND_MINT_URL"], + "step %q must receive the expected mint URL", tc.stepName) for name, value := range job.Outputs { assert.NotContains(t, name, "ACTIONS_ID_TOKEN_REQUEST_TOKEN", "job %q output names must not expose the OIDC request token", tc.jobName) @@ -930,6 +940,17 @@ func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { require.NoError(t, err) require.NoError(t, yaml.Unmarshal(content, &workflow)) + stepIndex := func(names []string, name string) int { + t.Helper() + for i, n := range names { + if n == name { + return i + } + } + t.Fatalf("missing step %q", name) + return -1 + } + for _, jobName := range []string{"route", "harness-dispatch", "harness-run"} { t.Run(jobName, func(t *testing.T) { job, ok := workflow.Jobs[jobName] @@ -945,14 +966,32 @@ func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { assert.Contains(t, names, "Prepare mint URL resolver script") assert.Contains(t, names, "Checkout workflow mint URL resolver") assert.Contains(t, checkoutStep.If, "mint-resolver-script.outputs.fetched") + switch jobName { + case "route": + assert.Less(t, stepIndex(names, "Check kill switch"), + stepIndex(names, "Prepare mint URL resolver script"), + "route must resolve mint URL after the kill switch") + assert.Contains(t, checkoutStep.If, "steps.route.outputs.stage") + case "harness-dispatch": + assert.Less(t, stepIndex(names, "Detect registered harness triggers"), + stepIndex(names, "Prepare mint URL resolver script"), + "harness-dispatch must resolve mint URL after trigger detection") + assert.Contains(t, checkoutStep.If, "has_triggers") + } }) } - assert.Contains(t, string(content), "workflow-mint-resolver", - "upstream resolver checkout must use a dedicated path under RUNNER_TEMP") + assert.Contains(t, string(content), "path: .workflow-mint-resolver", + "upstream resolver checkout must use a workspace-relative path") + assert.NotContains(t, string(content), "runner.temp }}/workflow-mint-resolver", + "actions/checkout path must stay under GITHUB_WORKSPACE") + assert.NotContains(t, string(content), "RUNNER_TEMP}/workflow-mint-resolver", + "resolver script path must stay under GITHUB_WORKSPACE") prioritize := string(loadRepoFile(".github/workflows/reusable-prioritize.yml")(t)) assert.Contains(t, prioritize, "Checkout workflow mint URL resolver") assert.Contains(t, prioritize, "Prepare mint URL resolver script") + assert.Contains(t, prioritize, "path: .workflow-mint-resolver") + assert.NotContains(t, prioritize, "runner.temp }}/workflow-mint-resolver") } // TestCustomAppSetReviewBotWiring ensures every GitHub review/fix dispatch From 61ddf398db9048e443b3c16fea144b63bd11b912 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Thu, 5 Nov 2026 17:42:25 +0100 Subject: [PATCH 04/18] fix(#8672)!: prefer config mint_url over FULLSEND_MINT_URL Skip yq when no config files are present, rewrap the mint-administration precedence paragraph, and mark the dispatch mint URL change as breaking. BREAKING CHANGE: A mint_url in .fullsend/config.yaml or config.base.yaml now overrides FULLSEND_MINT_URL on dispatch. Dispatch fails when the resolved endpoint is not HTTPS (loopback HTTP is still allowed for the variable fallback), the URL contains userinfo, yq is missing while a config file exists, or a config file does not parse. Signed-off-by: fmuntean Co-authored-by: Cursor --- .../resolve-effective-mint-url-test.sh | 34 +++++++++++++++++++ .github/scripts/resolve-effective-mint-url.sh | 29 +++++++++------- .../infrastructure/mint-administration.md | 11 +++++- 3 files changed, 61 insertions(+), 13 deletions(-) diff --git a/.github/scripts/resolve-effective-mint-url-test.sh b/.github/scripts/resolve-effective-mint-url-test.sh index 6908a46ae1..157e0e0935 100755 --- a/.github/scripts/resolve-effective-mint-url-test.sh +++ b/.github/scripts/resolve-effective-mint-url-test.sh @@ -111,6 +111,40 @@ setup_repo printf 'version: "1"\nmint_url: http://localhost:8080\n' >.fullsend/config.yaml run_resolve_expect_fail "" "reject localhost http from config file" +noyq_path="" +IFS=':' read -ra _path_parts <<<"${PATH}" +for _dir in "${_path_parts[@]}"; do + if [[ -n "${_dir}" && -x "${_dir}/yq" ]]; then + continue + fi + if [[ -z "${noyq_path}" ]]; then + noyq_path="${_dir}" + else + noyq_path="${noyq_path}:${_dir}" + fi +done +if [[ -z "${noyq_path}" ]]; then + noyq_path="/usr/bin:/bin" +fi + +run_resolve_without_yq() { + local fallback="${1:-}" + local output_file="${TMPDIR}/github-output.txt" + local oldpwd="${PWD}" + : >"${output_file}" + cd "${TMPDIR}/repo" + PATH="${noyq_path}" GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" bash "${SCRIPT}" + cd "${oldpwd}" + grep '^mint_url=' "${output_file}" | cut -d= -f2- +} + +setup_repo +assert_eq "no yq without config files" "https://fallback.example" "$(run_resolve_without_yq "https://fallback.example")" + +setup_repo +printf 'version: "1"\nmint_url: https://overlay.example\n' >.fullsend/config.yaml +PATH="${noyq_path}" run_resolve_expect_fail "https://fallback.example" "yq required when config files exist" + if [[ "${FAILURES}" -eq 0 ]]; then echo "All tests passed." else diff --git a/.github/scripts/resolve-effective-mint-url.sh b/.github/scripts/resolve-effective-mint-url.sh index cb8f30ccc2..442dc94a4e 100755 --- a/.github/scripts/resolve-effective-mint-url.sh +++ b/.github/scripts/resolve-effective-mint-url.sh @@ -9,7 +9,8 @@ # validateDeclaredMintURL. The FULLSEND_MINT_URL fallback also allows loopback # HTTP (localhost / 127.0.0.1), matching mintclient.MintToken. # -# Requires: yq, GITHUB_OUTPUT, FALLBACK_MINT_URL (may be empty). +# Requires: GITHUB_OUTPUT, FALLBACK_MINT_URL (may be empty). yq is required +# only when .fullsend/config.yaml or config.base.yaml is present. set -euo pipefail @@ -18,13 +19,17 @@ if [[ -z "${GITHUB_OUTPUT:-}" ]]; then exit 1 fi -if ! command -v yq >/dev/null 2>&1; then - echo "::error::yq is required to resolve mint_url from config" >&2 - exit 1 -fi - _effective="${FALLBACK_MINT_URL:-}" _from_file=false +_overlay=".fullsend/config.yaml" +_base=".fullsend/config.base.yaml" + +if [[ -f "${_overlay}" || -f "${_base}" ]]; then + if ! command -v yq >/dev/null 2>&1; then + echo "::error::yq is required to resolve mint_url from config" >&2 + exit 1 + fi +fi # Aligns with validateDeclaredMintURL for file-sourced values. Never echoes # the URL: rejected values may contain userinfo. @@ -81,20 +86,20 @@ _read_mint_url() { fi } -if [[ -f .fullsend/config.yaml ]]; then - overlay=$(_read_mint_url .fullsend/config.yaml) +if [[ -f "${_overlay}" ]]; then + overlay=$(_read_mint_url "${_overlay}") if [[ -n "${overlay}" ]]; then _effective="${overlay}" _from_file=true - elif [[ -f .fullsend/config.base.yaml ]]; then - base=$(_read_mint_url .fullsend/config.base.yaml) + elif [[ -f "${_base}" ]]; then + base=$(_read_mint_url "${_base}") if [[ -n "${base}" ]]; then _effective="${base}" _from_file=true fi fi -elif [[ -f .fullsend/config.base.yaml ]]; then - base=$(_read_mint_url .fullsend/config.base.yaml) +elif [[ -f "${_base}" ]]; then + base=$(_read_mint_url "${_base}") if [[ -n "${base}" ]]; then _effective="${base}" _from_file=true diff --git a/docs/guides/infrastructure/mint-administration.md b/docs/guides/infrastructure/mint-administration.md index 8aefb628a1..7b39c239bb 100644 --- a/docs/guides/infrastructure/mint-administration.md +++ b/docs/guides/infrastructure/mint-administration.md @@ -32,7 +32,16 @@ The fullsend team operates a public hosted community mint service. Install the s https://mint.fullsend.sh ``` -The CLI defaults to this URL. You can also set the `FULLSEND_MINT_URL` repository/org variable in GitHub explicitly. When `mint_url` is declared in `.fullsend/config.yaml` or `config.base.yaml`, dispatch resolves that layered value before the variable (see [Layered configuration reference](layered-config-reference.md)); the variable remains the fallback when both files are silent on `mint_url`. If you are using the hosted community mint, the rest of this guide (deploying, enrolling, troubleshooting) is for platform operators managing self-hosted mints — you do not need to manage mint infrastructure yourself. +The CLI defaults to this URL. You can also set the `FULLSEND_MINT_URL` +repository/org variable in GitHub explicitly. When `mint_url` is declared +in `.fullsend/config.yaml` or `config.base.yaml`, dispatch resolves that +layered value before the variable (see +[Layered configuration reference](layered-config-reference.md)); the +variable remains the fallback when both files are silent on `mint_url`. +If you are using the hosted community mint, the rest of this guide +(deploying, enrolling, troubleshooting) is for platform operators +managing self-hosted mints — you do not need to manage mint +infrastructure yourself. ## Prerequisites From 274b2dee2e230347f514627fe28c887774780ed1 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Fri, 6 Nov 2026 12:26:40 +0100 Subject: [PATCH 05/18] ci(ci-local): pin yq so script-test matches GitHub runners Signed-off-by: fmuntean Co-authored-by: Cursor --- .github/workflows/lint.yml | 9 +++++++++ hack/ci-local/Containerfile | 24 +++++++++++++++++++----- hack/ci-local/README.md | 12 +++++++----- hack/ci-local/ci-local | 3 +++ hack/ci-local/ci-local_test.sh | 6 ++++-- 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3785f26f91..4f4186d389 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -42,6 +42,15 @@ jobs: echo "8fcbf1b3e95551c82fd995535e3c1defa70e23299ce36eb3afd6c98778de6ca0 /tmp/pinact.tar.gz" | sha256sum -c tar xzf /tmp/pinact.tar.gz -C /usr/local/bin pinact + - name: Install yq + run: | + curl -sSfL "https://github.com/mikefarah/yq/releases/download/v4.54.1/yq_linux_amd64.tar.gz" -o /tmp/yq.tar.gz + echo "e68a456f90c577af3fe4960184b3a3cf5c461e0348407c10f107da3a5fec8972 /tmp/yq.tar.gz" | sha256sum -c + tar xzf /tmp/yq.tar.gz -C /tmp + mv /tmp/yq_linux_amd64 /usr/local/bin/yq + chmod 0755 /usr/local/bin/yq + # yq_linux_arm64.tar.gz sha256sum 8c27f6e7476fb5acefb9352e3d30f6bc2dc93f1956eb92e8da727173fb7ec6d3 + # The gateway doc config check pulls an agentgateway image, so it runs # in its own job, only when its files change. - run: make lint-all diff --git a/hack/ci-local/Containerfile b/hack/ci-local/Containerfile index cefeabaca5..3bf56f8b48 100644 --- a/hack/ci-local/Containerfile +++ b/hack/ci-local/Containerfile @@ -1,6 +1,6 @@ # Local replica of the fullsend CI toolchain (.github/workflows/lint.yml, # mint-cf-worker-test.yml, site-build.yml): ubuntu-24.04 runner, Go, Python + -# the pre-commit stack, Node, lychee, pinact. Build it with +# the pre-commit stack, Node, lychee, pinact, yq. Build it with # `hack/ci-local/ci-local build-image`: the versions are read from go.mod and # lint.yml and passed in as build args, so this file pins none of them. # Digest-pinned like images/*; Renovate keeps the digest current. @@ -31,8 +31,12 @@ ARG LYCHEE_VERSION ARG LYCHEE_SHA256_AMD64 ARG PINACT_VERSION ARG PINACT_SHA256_AMD64 +ARG YQ_VERSION +ARG YQ_SHA256_AMD64 +ARG YQ_SHA256_ARM64 RUN for v in GO_VERSION PYTHON_VERSION NODE_VERSION PIP_PACKAGES LYCHEE_VERSION \ - LYCHEE_SHA256_AMD64 PINACT_VERSION PINACT_SHA256_AMD64; do \ + LYCHEE_SHA256_AMD64 PINACT_VERSION PINACT_SHA256_AMD64 \ + YQ_VERSION YQ_SHA256_AMD64 YQ_SHA256_ARM64; do \ eval "x=\${$v}"; [ -n "$x" ] || { echo "build arg $v is not set; build with hack/ci-local/ci-local build-image" >&2; exit 1; }; \ done @@ -84,9 +88,10 @@ RUN uv venv --python "${PYTHON_VERSION}" /opt/venv \ && VIRTUAL_ENV=/opt/venv uv pip install ${PIP_PACKAGES} \ && chmod -R a+rX /opt/uv-python /opt/venv -# lychee + pinact (lint.yml "Install lychee" / "Install pinact"). On amd64 the -# checksum is the one lint.yml pins; lint.yml pins no arm64 checksum, so other -# architectures use the release's own checksum file. +# lychee + pinact + yq (lint.yml "Install lychee" / "Install pinact" / +# "Install yq"). On amd64 the checksum is the one lint.yml pins. lychee and +# pinact have no arm64 pin in lint.yml, so other architectures use the +# release's own checksum file; yq pins both architectures in lint.yml. RUN set -e; \ case "$TARGETARCH" in amd64) a=x86_64 ;; arm64) a=aarch64 ;; *) a=$TARGETARCH ;; esac; \ name="lychee-${a}-unknown-linux-gnu.tar.gz"; \ @@ -100,6 +105,15 @@ RUN set -e; \ if [ "$TARGETARCH" = amd64 ]; then s=$PINACT_SHA256_AMD64; else s=$(sumof "$rel/pinact_${PINACT_VERSION}_checksums.txt" "$name"); fi; \ fetch "$rel/$name" "$s"; \ tar -xzf /tmp/dl -C /usr/local/bin pinact; rm /tmp/dl +RUN set -e; \ + name="yq_linux_${TARGETARCH}.tar.gz"; \ + url="https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/$name"; \ + if [ "$TARGETARCH" = amd64 ]; then s=$YQ_SHA256_AMD64; else s=$YQ_SHA256_ARM64; fi; \ + fetch "$url" "$s"; \ + tar -xzf /tmp/dl -C /tmp; rm /tmp/dl; \ + mv /tmp/yq_linux_${TARGETARCH} /usr/local/bin/yq; \ + chmod 0755 /usr/local/bin/yq; \ + rm -f /tmp/yq.1 /tmp/install-man-page.sh # CI=true: matches Actions and makes `make ensure-hooks` a no-op, so running # lint never installs git hooks into the host checkout. diff --git a/hack/ci-local/README.md b/hack/ci-local/README.md index b2b02b4889..8a18c06776 100644 --- a/hack/ci-local/README.md +++ b/hack/ci-local/README.md @@ -163,7 +163,7 @@ checkout and passes them in as build args: | Go | `go.mod` (`go` line), as `actions/setup-go` does | | Python, Node | `python-version` / `node-version` in `.github/workflows/lint.yml` | | pip packages | the `uv pip install --system` step in `lint.yml` | -| lychee, pinact | the download URLs and SHA256s in `lint.yml` | +| lychee, pinact, yq | the download URLs and SHA256s in `lint.yml` | | uv | latest release (`lint.yml` doesn't pin it) | The image is tagged with a hash of those versions and the `Containerfile`, so @@ -188,10 +188,12 @@ Python also comes from a different build: uv's python-build-standalone here, actions/python-versions in CI. `hack/ci-local/ci-local build-image` rebuilds without cache to pick up new patch releases. -On amd64, lychee and pinact are verified against the SHA256s that `lint.yml` -pins. `lint.yml` pins no arm64 checksums, so on arm64 (Apple silicon) they, -like Node and uv everywhere, are verified against the publisher's checksum -file from the same release. +On amd64, lychee, pinact, and yq are verified against the SHA256s that +`lint.yml` pins. `lint.yml` pins no arm64 checksums for lychee and pinact, so +on arm64 (Apple silicon) those two, like Node and uv everywhere, are verified +against the publisher's checksum file from the same release. yq pins both +architectures in `lint.yml` because its GitHub checksums file is not a +standard SHA256 list. Each version set leaves its own image behind. `hack/ci-local/ci-local clean` removes every `ci-local` image except the current one for this checkout (add diff --git a/hack/ci-local/ci-local b/hack/ci-local/ci-local index 2e2cc431ca..e94ddd9897 100755 --- a/hack/ci-local/ci-local +++ b/hack/ci-local/ci-local @@ -156,6 +156,9 @@ resolve_versions() { add LYCHEE_SHA256_AMD64 "$(grep -m1 -E 'lychee\.tar\.gz.*sha256sum' "$wf" | grep -oE '[0-9a-f]{64}')" lint.yml add PINACT_VERSION "$(grep -m1 -oE 'pinact/releases/download/v[0-9.]+/' "$wf" | sed -E 's#.*/v##; s#/$##')" lint.yml add PINACT_SHA256_AMD64 "$(grep -m1 -E 'pinact\.tar\.gz.*sha256sum' "$wf" | grep -oE '[0-9a-f]{64}')" lint.yml + add YQ_VERSION "$(grep -m1 -oE 'mikefarah/yq/releases/download/v[0-9.]+/' "$wf" | sed -E 's#.*/v##; s#/$##')" lint.yml + add YQ_SHA256_AMD64 "$(grep -m1 -E 'yq\.tar\.gz.*sha256sum' "$wf" | grep -oE '[0-9a-f]{64}')" lint.yml + add YQ_SHA256_ARM64 "$(grep -m1 -E 'yq_linux_arm64\.tar\.gz.*sha256sum' "$wf" | grep -oE '[0-9a-f]{64}')" lint.yml # Docker and rootful Podman run as the host uid:gid (user_args); build # runner with those ids so whoami/id -un resolve. keep-id adds its own # passwd entry. diff --git a/hack/ci-local/ci-local_test.sh b/hack/ci-local/ci-local_test.sh index f6ba251cca..ce546cac6e 100755 --- a/hack/ci-local/ci-local_test.sh +++ b/hack/ci-local/ci-local_test.sh @@ -207,13 +207,15 @@ BUILD=$(last_build_args) arg() { grep -A1 -x -- '--build-arg' <<< "${BUILD}" | sed -n "s/^$1=//p"; } want_go=$(awk '$1 == "go" {print $2; exit}' "${REPO}/go.mod") missing="" -for v in GO_VERSION PYTHON_VERSION NODE_VERSION PIP_PACKAGES LYCHEE_VERSION LYCHEE_SHA256_AMD64 PINACT_VERSION PINACT_SHA256_AMD64; do +for v in GO_VERSION PYTHON_VERSION NODE_VERSION PIP_PACKAGES LYCHEE_VERSION LYCHEE_SHA256_AMD64 PINACT_VERSION PINACT_SHA256_AMD64 YQ_VERSION YQ_SHA256_AMD64 YQ_SHA256_ARM64; do [ -n "$(arg "$v")" ] || missing="${missing} $v" done if [ -z "${missing}" ] && [ "$(arg GO_VERSION)" = "${want_go}" ] && grep -q "python-version: \"$(arg PYTHON_VERSION)\"" "${REPO}/.github/workflows/lint.yml" && grep -q "$(arg LYCHEE_SHA256_AMD64) /tmp/lychee.tar.gz" "${REPO}/.github/workflows/lint.yml" && - [[ "$(arg PINACT_SHA256_AMD64)" =~ ^[0-9a-f]{64}$ ]]; then + [[ "$(arg PINACT_SHA256_AMD64)" =~ ^[0-9a-f]{64}$ ]] && + grep -q "$(arg YQ_SHA256_AMD64) /tmp/yq.tar.gz" "${REPO}/.github/workflows/lint.yml" && + grep -q "yq_linux_arm64.tar.gz sha256sum $(arg YQ_SHA256_ARM64)" "${REPO}/.github/workflows/lint.yml"; then pass "all build args are read from the real go.mod and lint.yml" else fail "build args from CI config: missing=[${missing}] args=$(tr '\n' ' ' <<< "${BUILD}")" From 0471562df6eb678a66773ef9db8695192bf3996c Mon Sep 17 00:00:00 2001 From: fmuntean Date: Fri, 6 Nov 2026 12:35:27 +0100 Subject: [PATCH 06/18] test(#8672): cover fail-closed mint URL resolver branches Signed-off-by: fmuntean Co-authored-by: Cursor --- .../resolve-effective-mint-url-test.sh | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/scripts/resolve-effective-mint-url-test.sh b/.github/scripts/resolve-effective-mint-url-test.sh index 157e0e0935..4579de4996 100755 --- a/.github/scripts/resolve-effective-mint-url-test.sh +++ b/.github/scripts/resolve-effective-mint-url-test.sh @@ -27,10 +27,12 @@ run_resolve() { run_resolve_expect_fail() { local fallback="${1:-}" local name="${2}" - local leak="${3:-}" + local expected="${3}" + local leak="${4:-}" local output_file="${TMPDIR}/github-output.txt" local stderr_file="${TMPDIR}/stderr.txt" local oldpwd="${PWD}" + local got : >"${output_file}" : >"${stderr_file}" cd "${TMPDIR}/repo" @@ -41,6 +43,11 @@ run_resolve_expect_fail() { return 0 fi cd "${oldpwd}" + got="$(cat "${stderr_file}")" + if ! grep -F -- "${expected}" "${stderr_file}" >/dev/null; then + echo "FAIL: ${name}: expected ${expected@Q} in stderr, got ${got@Q}" + FAILURES=$((FAILURES + 1)) + fi if [[ -n "${leak}" ]] && grep -F -- "${leak}" "${stderr_file}" >/dev/null; then echo "FAIL: ${name}: stderr leaked ${leak@Q}" FAILURES=$((FAILURES + 1)) @@ -87,11 +94,11 @@ assert_eq "empty fallback" "" "$(run_resolve "")" setup_repo printf 'version: "1"\nmint_url: http://evil.example\n' >.fullsend/config.yaml -run_resolve_expect_fail "https://fallback.example" "reject http mint_url" +run_resolve_expect_fail "https://fallback.example" "reject http mint_url" "::error::mint_url must be a valid HTTPS URL" setup_repo printf 'version: "1"\nmint_url: https://user:pass@mint.example\n' >.fullsend/config.yaml -run_resolve_expect_fail "https://fallback.example" "reject userinfo mint_url" "user:pass" +run_resolve_expect_fail "https://fallback.example" "reject userinfo mint_url" "::error::mint_url must not contain userinfo" "user:pass" setup_repo printf 'version: "1"\nmint_url: https://mint.example/a@b\n' >.fullsend/config.yaml @@ -109,7 +116,25 @@ assert_eq "loopback http fallback" "http://127.0.0.1:8080" "$(run_resolve "http: setup_repo printf 'version: "1"\nmint_url: http://localhost:8080\n' >.fullsend/config.yaml -run_resolve_expect_fail "" "reject localhost http from config file" +run_resolve_expect_fail "" "reject localhost http from config file" "::error::mint_url must be a valid HTTPS URL" + +setup_repo +run_resolve_expect_fail "http://evil.example" "reject non-loopback http fallback" "::error::mint_url must be a valid HTTPS URL" + +setup_repo +run_resolve_expect_fail "https://u:p@host" "reject userinfo fallback" "::error::mint_url must not contain userinfo" "u:p" + +setup_repo +run_resolve_expect_fail $'https://mint.example\nsmuggled' "reject LF in fallback" "::error::mint_url must not contain CR or LF" + +setup_repo +printf 'mint_url: [unclosed\n' >.fullsend/config.yaml +run_resolve_expect_fail "https://fallback.example" "reject unparsable overlay" "::error::failed to read mint_url from .fullsend/config.yaml" + +setup_repo +printf 'version: "1"\n' >.fullsend/config.yaml +printf 'mint_url: [unclosed\n' >.fullsend/config.base.yaml +run_resolve_expect_fail "https://fallback.example" "reject unparsable base under silent overlay" "::error::failed to read mint_url from .fullsend/config.base.yaml" noyq_path="" IFS=':' read -ra _path_parts <<<"${PATH}" @@ -143,7 +168,7 @@ assert_eq "no yq without config files" "https://fallback.example" "$(run_resolve setup_repo printf 'version: "1"\nmint_url: https://overlay.example\n' >.fullsend/config.yaml -PATH="${noyq_path}" run_resolve_expect_fail "https://fallback.example" "yq required when config files exist" +PATH="${noyq_path}" run_resolve_expect_fail "https://fallback.example" "yq required when config files exist" "::error::yq is required to resolve mint_url from config" if [[ "${FAILURES}" -eq 0 ]]; then echo "All tests passed." From 6db5779c19f836d4cda1a832c62634dc9b101898 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Fri, 6 Nov 2026 15:50:37 +0100 Subject: [PATCH 07/18] test(#8672): isolate PATH in missing-yq resolver tests Signed-off-by: fmuntean Co-authored-by: Cursor --- .../resolve-effective-mint-url-test.sh | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/scripts/resolve-effective-mint-url-test.sh b/.github/scripts/resolve-effective-mint-url-test.sh index 4579de4996..f10864969c 100755 --- a/.github/scripts/resolve-effective-mint-url-test.sh +++ b/.github/scripts/resolve-effective-mint-url-test.sh @@ -8,6 +8,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT="${SCRIPT_DIR}/resolve-effective-mint-url.sh" +BASH_ABS="$(command -v bash)" FAILURES=0 TMPDIR="$(mktemp -d)" @@ -19,7 +20,7 @@ run_resolve() { local oldpwd="${PWD}" : >"${output_file}" cd "${TMPDIR}/repo" - GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" bash "${SCRIPT}" + GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" "${BASH_ABS}" "${SCRIPT}" cd "${oldpwd}" grep '^mint_url=' "${output_file}" | cut -d= -f2- } @@ -33,10 +34,11 @@ run_resolve_expect_fail() { local stderr_file="${TMPDIR}/stderr.txt" local oldpwd="${PWD}" local got + local script_path="${RESOLVE_PATH:-${PATH}}" : >"${output_file}" : >"${stderr_file}" cd "${TMPDIR}/repo" - if GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" bash "${SCRIPT}" 2>"${stderr_file}"; then + if PATH="${script_path}" GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" "${BASH_ABS}" "${SCRIPT}" 2>"${stderr_file}"; then cd "${oldpwd}" echo "FAIL: ${name}: expected non-zero exit" FAILURES=$((FAILURES + 1)) @@ -136,20 +138,21 @@ printf 'version: "1"\n' >.fullsend/config.yaml printf 'mint_url: [unclosed\n' >.fullsend/config.base.yaml run_resolve_expect_fail "https://fallback.example" "reject unparsable base under silent overlay" "::error::failed to read mint_url from .fullsend/config.base.yaml" -noyq_path="" -IFS=':' read -ra _path_parts <<<"${PATH}" -for _dir in "${_path_parts[@]}"; do - if [[ -n "${_dir}" && -x "${_dir}/yq" ]]; then - continue - fi - if [[ -z "${noyq_path}" ]]; then - noyq_path="${_dir}" - else - noyq_path="${noyq_path}:${_dir}" +# Isolate PATH so yq is missing without dropping bash/tr from system +# directories that also contain yq (for example /usr/bin on merged-/usr). +noyq_bin="${TMPDIR}/noyq-bin" +mkdir -p "${noyq_bin}" +for _cmd in bash tr grep cut cat; do + _src="$(command -v "${_cmd}")" + if [[ -z "${_src}" || ! -x "${_src}" ]]; then + echo "FAIL: required tool ${_cmd} not found on PATH" + exit 1 fi + ln -s "${_src}" "${noyq_bin}/${_cmd}" done -if [[ -z "${noyq_path}" ]]; then - noyq_path="/usr/bin:/bin" +if PATH="${noyq_bin}" command -v yq >/dev/null 2>&1; then + echo "FAIL: isolated PATH still finds yq" + exit 1 fi run_resolve_without_yq() { @@ -158,7 +161,7 @@ run_resolve_without_yq() { local oldpwd="${PWD}" : >"${output_file}" cd "${TMPDIR}/repo" - PATH="${noyq_path}" GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" bash "${SCRIPT}" + PATH="${noyq_bin}" GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" "${BASH_ABS}" "${SCRIPT}" cd "${oldpwd}" grep '^mint_url=' "${output_file}" | cut -d= -f2- } @@ -168,7 +171,7 @@ assert_eq "no yq without config files" "https://fallback.example" "$(run_resolve setup_repo printf 'version: "1"\nmint_url: https://overlay.example\n' >.fullsend/config.yaml -PATH="${noyq_path}" run_resolve_expect_fail "https://fallback.example" "yq required when config files exist" "::error::yq is required to resolve mint_url from config" +RESOLVE_PATH="${noyq_bin}" run_resolve_expect_fail "https://fallback.example" "yq required when config files exist" "::error::yq is required to resolve mint_url from config" if [[ "${FAILURES}" -eq 0 ]]; then echo "All tests passed." From 23c2d4f70d020a46427f1a34b93ad7926679c92d Mon Sep 17 00:00:00 2001 From: fmuntean Date: Mon, 9 Nov 2026 16:00:08 +0100 Subject: [PATCH 08/18] fix(#8672): notice when config mint_url overrides FULLSEND_MINT_URL Workflow runs should leave an audit trail when .fullsend config picks a different mint endpoint than the repository variable snapshot. Signed-off-by: fmuntean Co-authored-by: Cursor --- .../resolve-effective-mint-url-test.sh | 42 ++++++++++++++++++- .github/scripts/resolve-effective-mint-url.sh | 29 +++++++++++++ internal/scaffold/vendorcontent.go | 2 +- internal/scaffold/vendormanifest.go | 2 +- 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/.github/scripts/resolve-effective-mint-url-test.sh b/.github/scripts/resolve-effective-mint-url-test.sh index f10864969c..e363f250fc 100755 --- a/.github/scripts/resolve-effective-mint-url-test.sh +++ b/.github/scripts/resolve-effective-mint-url-test.sh @@ -17,14 +17,45 @@ trap 'rm -rf "${TMPDIR}"' EXIT run_resolve() { local fallback="${1:-}" local output_file="${TMPDIR}/github-output.txt" + local stderr_file="${TMPDIR}/resolve-stderr.txt" local oldpwd="${PWD}" : >"${output_file}" + : >"${stderr_file}" cd "${TMPDIR}/repo" - GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" "${BASH_ABS}" "${SCRIPT}" + GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" "${BASH_ABS}" "${SCRIPT}" 2>"${stderr_file}" cd "${oldpwd}" grep '^mint_url=' "${output_file}" | cut -d= -f2- } +run_resolve_stderr() { + local fallback="${1:-}" + local output_file="${TMPDIR}/github-output.txt" + local stderr_file="${TMPDIR}/resolve-stderr.txt" + local oldpwd="${PWD}" + : >"${output_file}" + : >"${stderr_file}" + cd "${TMPDIR}/repo" + GITHUB_OUTPUT="${output_file}" FALLBACK_MINT_URL="${fallback}" "${BASH_ABS}" "${SCRIPT}" 2>"${stderr_file}" + cd "${oldpwd}" + cat "${stderr_file}" +} + +assert_notice_contains() { + local name="$1" want="$2" stderr="$3" + if ! grep -F -- "${want}" <<<"${stderr}" >/dev/null; then + echo "FAIL: ${name}: expected notice containing ${want@Q}, stderr=${stderr@Q}" + FAILURES=$((FAILURES + 1)) + fi +} + +assert_no_notice_override() { + local name="$1" stderr="$2" + if grep -F -- "overrides FULLSEND_MINT_URL" <<<"${stderr}" >/dev/null; then + echo "FAIL: ${name}: unexpected override notice in stderr=${stderr@Q}" + FAILURES=$((FAILURES + 1)) + fi +} + run_resolve_expect_fail() { local fallback="${1:-}" local name="${2}" @@ -76,6 +107,15 @@ assert_eq "fallback only" "https://fallback.example" "$(run_resolve "https://fal setup_repo printf 'version: "1"\nmint_url: https://overlay.example\n' >.fullsend/config.yaml assert_eq "overlay wins" "https://overlay.example" "$(run_resolve "https://fallback.example")" +assert_notice_contains "overlay override notice" "mint host: overlay.example" "$(run_resolve_stderr "https://fallback.example")" + +setup_repo +printf 'version: "1"\nmint_url: https://same.example\n' >.fullsend/config.yaml +assert_eq "file matches fallback" "https://same.example" "$(run_resolve "https://same.example")" +assert_no_notice_override "no notice when values match" "$(run_resolve_stderr "https://same.example")" + +setup_repo +assert_no_notice_override "no notice for fallback only" "$(run_resolve_stderr "https://fallback.example")" setup_repo printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml diff --git a/.github/scripts/resolve-effective-mint-url.sh b/.github/scripts/resolve-effective-mint-url.sh index 442dc94a4e..b850ac7d14 100755 --- a/.github/scripts/resolve-effective-mint-url.sh +++ b/.github/scripts/resolve-effective-mint-url.sh @@ -110,6 +110,35 @@ if ! _validate_resolved_mint_url "${_effective}" "${_from_file}"; then exit 1 fi +# File-sourced mint_url overrides the FULLSEND_MINT_URL snapshot; log only the +# host when the two differ so runs retain an audit trail without echoing URLs. +_mint_host_from_url() { + local url="$1" + local rest authority host + if [[ -z "${url}" ]]; then + return 0 + fi + if [[ "${url}" =~ ^[A-Za-z][A-Za-z0-9+.-]*://(.*)$ ]]; then + rest="${BASH_REMATCH[1]}" + else + return 1 + fi + authority="${rest%%[/?#]*}" + host="${authority%%:*}" + if [[ -n "${host}" ]]; then + printf '%s' "${host}" + fi +} + +if [[ "${_from_file}" == "true" && "${_effective}" != "${FALLBACK_MINT_URL:-}" ]]; then + host=$(_mint_host_from_url "${_effective}") || host="" + if [[ -n "${host}" ]]; then + echo "::notice::mint_url from .fullsend config overrides FULLSEND_MINT_URL (mint host: ${host})" >&2 + else + echo "::notice::mint_url from .fullsend config overrides FULLSEND_MINT_URL" >&2 + fi +fi + { printf 'mint_url=%s\n' "${_effective}" } >>"${GITHUB_OUTPUT}" diff --git a/internal/scaffold/vendorcontent.go b/internal/scaffold/vendorcontent.go index 502ab1ec43..c35e210b73 100644 --- a/internal/scaffold/vendorcontent.go +++ b/internal/scaffold/vendorcontent.go @@ -180,7 +180,7 @@ var vendoredDefaultsScripts = map[string]bool{ ".github/scripts/install-podman.sh": true, ".github/scripts/openshell-version.sh": true, ".github/scripts/pre-fetch-review-body.sh": true, - ".github/scripts/retry-with-backoff.sh": true, + ".github/scripts/retry-with-backoff.sh": true, ".github/scripts/resolve-effective-mint-url.sh": true, } diff --git a/internal/scaffold/vendormanifest.go b/internal/scaffold/vendormanifest.go index 486f406d9e..b95127fe27 100644 --- a/internal/scaffold/vendormanifest.go +++ b/internal/scaffold/vendormanifest.go @@ -163,7 +163,7 @@ var vendoredDefaultsInfraPaths = []string{ ".github/scripts/install-podman.sh", ".github/scripts/openshell-version.sh", ".github/scripts/pre-fetch-review-body.sh", - ".github/scripts/retry-with-backoff.sh", + ".github/scripts/retry-with-backoff.sh", ".github/scripts/resolve-effective-mint-url.sh", } From 481761b951d81346dbc72707d1062b552d0a9c81 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Mon, 9 Nov 2026 16:04:45 +0100 Subject: [PATCH 09/18] fix(#8672): keep vendored script lists in alphabetical order Signed-off-by: fmuntean Co-authored-by: Cursor --- internal/scaffold/vendorcontent.go | 2 +- internal/scaffold/vendormanifest.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/scaffold/vendorcontent.go b/internal/scaffold/vendorcontent.go index c35e210b73..b1eddead87 100644 --- a/internal/scaffold/vendorcontent.go +++ b/internal/scaffold/vendorcontent.go @@ -180,8 +180,8 @@ var vendoredDefaultsScripts = map[string]bool{ ".github/scripts/install-podman.sh": true, ".github/scripts/openshell-version.sh": true, ".github/scripts/pre-fetch-review-body.sh": true, - ".github/scripts/retry-with-backoff.sh": true, ".github/scripts/resolve-effective-mint-url.sh": true, + ".github/scripts/retry-with-backoff.sh": true, } // vendoredDefaultsActions is the explicit allowlist of .github/actions/ diff --git a/internal/scaffold/vendormanifest.go b/internal/scaffold/vendormanifest.go index b95127fe27..5ff5b4d866 100644 --- a/internal/scaffold/vendormanifest.go +++ b/internal/scaffold/vendormanifest.go @@ -163,8 +163,8 @@ var vendoredDefaultsInfraPaths = []string{ ".github/scripts/install-podman.sh", ".github/scripts/openshell-version.sh", ".github/scripts/pre-fetch-review-body.sh", - ".github/scripts/retry-with-backoff.sh", ".github/scripts/resolve-effective-mint-url.sh", + ".github/scripts/retry-with-backoff.sh", } // enumerateVendoredPaths returns embed-derived paths for a current --vendor install layout. From 063c582ce38ec7ac26112ec30130a8a1c07e3a6e Mon Sep 17 00:00:00 2001 From: fmuntean Date: Tue, 10 Nov 2026 10:04:59 +0100 Subject: [PATCH 10/18] fix(#8672): resolve mint URL from vendored defaults or workflow pin Stop preferring a caller-root resolver script so upstream repos cannot skew against the pinned reusable workflow ref; lock wiring with tests. Signed-off-by: fmuntean Co-authored-by: Cursor --- .github/workflows/reusable-dispatch.yml | 40 ++++----- .github/workflows/reusable-prioritize.yml | 16 ++-- .../scaffold/workflow_call_alignment_test.go | 90 +++++++++++++++++++ 3 files changed, 112 insertions(+), 34 deletions(-) diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index d0a628d3b5..82501e7050 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -154,8 +154,9 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: # checkout@v7 blocks fork PR checkouts on pull_request_target by - # default. Safe here: only .fullsend/ config is read, no fork code - # is executed, and credentials are not persisted. Pin to base branch + # default. Safe here: trusted config under .fullsend/ is read; the + # vendored or workflow-pinned mint URL resolver may run later with + # id-token scope. Credentials are not persisted. Pin to base branch # SHA for PR-scoped events so kill-switch / role gating always reads # trusted config — PR authors cannot self-authorize. ref: ${{ (github.event_name == 'pull_request_target' || github.event_name == 'pull_request_review') && github.event.pull_request.base.sha || github.sha }} @@ -164,7 +165,6 @@ jobs: sparse-checkout: | .fullsend/config.yaml .fullsend/config.base.yaml - .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh /OWNERS /OWNERS_ALIASES @@ -916,12 +916,9 @@ jobs: run: | set -euo pipefail RESOLVER="" - for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do - if [[ -f "${candidate}" ]]; then - RESOLVER="${candidate}" - break - fi - done + if [[ -f .defaults/.github/scripts/resolve-effective-mint-url.sh ]]; then + RESOLVER=".defaults/.github/scripts/resolve-effective-mint-url.sh" + fi if [[ -n "${RESOLVER}" ]]; then echo "path=${RESOLVER}" >> "${GITHUB_OUTPUT}" echo "fetched=false" >> "${GITHUB_OUTPUT}" @@ -954,7 +951,7 @@ jobs: RESOLVER=".workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" fi if [[ ! -f "${RESOLVER}" ]]; then - echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" + echo "::error::resolve-effective-mint-url.sh is missing from vendored defaults and workflow repository" exit 1 fi bash "${RESOLVER}" @@ -1996,7 +1993,6 @@ jobs: .defaults/action.yml .defaults/.github/actions/install-fullsend-cli/ .fullsend/.defaults/action.yml - .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh sparse-checkout-cone-mode: false @@ -2025,12 +2021,9 @@ jobs: run: | set -euo pipefail RESOLVER="" - for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do - if [[ -f "${candidate}" ]]; then - RESOLVER="${candidate}" - break - fi - done + if [[ -f .defaults/.github/scripts/resolve-effective-mint-url.sh ]]; then + RESOLVER=".defaults/.github/scripts/resolve-effective-mint-url.sh" + fi if [[ -n "${RESOLVER}" ]]; then echo "path=${RESOLVER}" >> "${GITHUB_OUTPUT}" echo "fetched=false" >> "${GITHUB_OUTPUT}" @@ -2063,7 +2056,7 @@ jobs: RESOLVER=".workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" fi if [[ ! -f "${RESOLVER}" ]]; then - echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" + echo "::error::resolve-effective-mint-url.sh is missing from vendored defaults and workflow repository" exit 1 fi bash "${RESOLVER}" @@ -2238,12 +2231,9 @@ jobs: run: | set -euo pipefail RESOLVER="" - for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do - if [[ -f "${candidate}" ]]; then - RESOLVER="${candidate}" - break - fi - done + if [[ -f .defaults/.github/scripts/resolve-effective-mint-url.sh ]]; then + RESOLVER=".defaults/.github/scripts/resolve-effective-mint-url.sh" + fi if [[ -n "${RESOLVER}" ]]; then echo "path=${RESOLVER}" >> "${GITHUB_OUTPUT}" echo "fetched=false" >> "${GITHUB_OUTPUT}" @@ -2275,7 +2265,7 @@ jobs: RESOLVER=".workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" fi if [[ ! -f "${RESOLVER}" ]]; then - echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" + echo "::error::resolve-effective-mint-url.sh is missing from vendored defaults and workflow repository" exit 1 fi bash "${RESOLVER}" diff --git a/.github/workflows/reusable-prioritize.yml b/.github/workflows/reusable-prioritize.yml index 3f84fee0a6..d7c2a3ffd0 100644 --- a/.github/workflows/reusable-prioritize.yml +++ b/.github/workflows/reusable-prioritize.yml @@ -105,8 +105,9 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: # checkout@v7 blocks fork PR checkouts on pull_request_target by default. - # Safe here: only .fullsend/ config is read, no fork code is executed, - # and credentials are not persisted. + # Safe here: trusted config under .fullsend/ is read; the vendored or + # workflow-pinned mint URL resolver may run later with id-token scope. + # Credentials are not persisted. ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.base.sha || github.sha }} persist-credentials: false allow-unsafe-pr-checkout: ${{ github.event_name == 'pull_request_target' }} @@ -145,12 +146,9 @@ jobs: run: | set -euo pipefail RESOLVER="" - for candidate in .github/scripts/resolve-effective-mint-url.sh .defaults/.github/scripts/resolve-effective-mint-url.sh; do - if [[ -f "${candidate}" ]]; then - RESOLVER="${candidate}" - break - fi - done + if [[ -f .defaults/.github/scripts/resolve-effective-mint-url.sh ]]; then + RESOLVER=".defaults/.github/scripts/resolve-effective-mint-url.sh" + fi if [[ -n "${RESOLVER}" ]]; then echo "path=${RESOLVER}" >> "${GITHUB_OUTPUT}" echo "fetched=false" >> "${GITHUB_OUTPUT}" @@ -182,7 +180,7 @@ jobs: RESOLVER=".workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" fi if [[ ! -f "${RESOLVER}" ]]; then - echo "::error::resolve-effective-mint-url.sh is missing from caller and workflow repository" + echo "::error::resolve-effective-mint-url.sh is missing from vendored defaults and workflow repository" exit 1 fi bash "${RESOLVER}" diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index e010af9153..cbfe1a969b 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -1137,6 +1137,88 @@ func TestReusableDispatchJobsReceiveMintOIDC(t *testing.T) { "the workflow must not copy the OIDC request token into logs or matrix data") } +// TestReusableDispatchStageJobsResolvedMintURL ensures inline stage jobs use the +// route-resolved mint URL, not the workflow-call input snapshot (#8672). +func TestReusableDispatchStageJobsResolvedMintURL(t *testing.T) { + type workflowStep struct { + Uses string `yaml:"uses"` + With map[string]string `yaml:"with"` + } + type workflowJob struct { + Steps []workflowStep `yaml:"steps"` + } + var workflow struct { + Jobs map[string]workflowJob `yaml:"jobs"` + } + + content, err := os.ReadFile(filepath.Join("..", "..", ".github", "workflows", "reusable-dispatch.yml")) + require.NoError(t, err) + require.NoError(t, yaml.Unmarshal(content, &workflow)) + + wantRoute := "${{ needs.route.outputs.mint_url }}" + for _, jobName := range []string{"triage", "code", "review", "fix", "retro", "prioritize"} { + t.Run(jobName, func(t *testing.T) { + job, ok := workflow.Jobs[jobName] + require.True(t, ok, "job %q must exist", jobName) + var sawMintToken, sawAgent bool + for _, step := range job.Steps { + if step.Uses == "./.defaults/.github/actions/mint-token" { + sawMintToken = true + assert.Equal(t, wantRoute, step.With["mint_url"], + "job %q mint-token must use route output", jobName) + assert.NotEqual(t, "${{ inputs.mint_url }}", step.With["mint_url"], + "job %q mint-token must not use workflow input", jobName) + } + if step.Uses == "./.defaults/" { + sawAgent = true + assert.Equal(t, wantRoute, step.With["mint-url"], + "job %q agent action must use route output", jobName) + } + } + if jobName != "prioritize" { + assert.True(t, sawMintToken, "job %q must mint an app token", jobName) + } + assert.True(t, sawAgent, "job %q must run the agent composite", jobName) + }) + } + + wantHarness := "${{ steps.resolve-mint.outputs.mint_url }}" + harnessRun, ok := workflow.Jobs["harness-run"] + require.True(t, ok, "harness-run job must exist") + for _, step := range harnessRun.Steps { + if step.Uses == "./.defaults/.github/actions/mint-token" { + assert.Equal(t, wantHarness, step.With["mint_url"], + "harness-run mint-token must use job-local resolve output") + } + if step.Uses == "./.defaults/" { + assert.Equal(t, wantHarness, step.With["mint-url"], + "harness-run agent action must use job-local resolve output") + } + } + + prioritizePath := filepath.Join("..", "..", ".github", "workflows", "reusable-prioritize.yml") + prioritizeContent, err := os.ReadFile(prioritizePath) + require.NoError(t, err) + var prioritizeWF struct { + Jobs map[string]struct { + Steps []workflowStep `yaml:"steps"` + } `yaml:"jobs"` + } + require.NoError(t, yaml.Unmarshal(prioritizeContent, &prioritizeWF)) + wantPrioritize := "${{ steps.resolve-mint.outputs.mint_url }}" + for jobName, job := range prioritizeWF.Jobs { + for _, step := range job.Steps { + if step.Uses != "./.defaults/" { + continue + } + assert.Equal(t, wantPrioritize, step.With["mint-url"], + "reusable-prioritize job %q must use resolve-mint output", jobName) + assert.NotEqual(t, "${{ inputs.mint_url }}", step.With["mint-url"], + "reusable-prioritize job %q must not use workflow input", jobName) + } + } +} + // TestReusableDispatchMintResolverFetchesFromWorkflow ensures upstream-mode // callers without a vendored resolver can sparse-checkout the script from // job.workflow_repository (#9104). @@ -1208,6 +1290,14 @@ func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { assert.Contains(t, prioritize, "Prepare mint URL resolver script") assert.Contains(t, prioritize, "path: .workflow-mint-resolver") assert.NotContains(t, prioritize, "runner.temp }}/workflow-mint-resolver") + + w := string(content) + assert.NotContains(t, w, "for candidate in .github/scripts/resolve-effective-mint-url.sh", + "resolver must not prefer a caller-root script copy") + assert.Contains(t, w, "if [[ -f .defaults/.github/scripts/resolve-effective-mint-url.sh ]]", + "resolver must read vendored defaults before workflow fetch") + assert.NotContains(t, w, ".fullsend/config.base.yaml\n .github/scripts/resolve-effective-mint-url.sh\n", + "route sparse checkout must not pull caller-root resolver") } // TestCustomAppSetReviewBotWiring ensures every GitHub review/fix dispatch From c07729f9f38f0b105d7e07ae4bb67ba4d3afb4b2 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Tue, 10 Nov 2026 21:49:07 +0100 Subject: [PATCH 11/18] docs(#8672): document dispatch mint_url precedence and migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Config reference and operator guides now describe overlay → base → FULLSEND_MINT_URL resolution, fail-closed validation, and retargeting. Signed-off-by: fmuntean Co-authored-by: Cursor --- .../layered-config-reference.md | 7 ++++++ .../infrastructure/mint-administration.md | 22 ++++++++++++++++++- docs/guides/infrastructure/standalone-mint.md | 6 +++++ docs/guides/user/custom-agent-identity.md | 7 +++--- docs/reference/config-reference.md | 15 +++++++++++++ 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/docs/guides/infrastructure/layered-config-reference.md b/docs/guides/infrastructure/layered-config-reference.md index e1f613f22a..06bcb02945 100644 --- a/docs/guides/infrastructure/layered-config-reference.md +++ b/docs/guides/infrastructure/layered-config-reference.md @@ -235,6 +235,13 @@ unset, the accessor falls through to the base layer, then to code defaults. unset (`""`) falls through to parent, then to code default `DefaultPerRepoMintURL` (the hosted public mint). +**GitHub agent dispatch** uses the same overlay-then-base order, then the +`FULLSEND_MINT_URL` snapshot from the caller (`inputs.mint_url` on the +reusable workflow), not `DefaultPerRepoMintURL`. A declared config value +overrides the variable; the resolver stops there when both files are silent +on `mint_url`. Validation and failure modes for dispatch runs are listed in +[Config reference — `mint_url`](../../reference/config-reference.md#mint_url). + **`inference`** groups inference backend settings under a single YAML key (`inference:`) using the `PerRepoInferenceConfig` struct. Each subfield (`provider`, `project`, `region`, `wif_provider`, `wif_audience`, diff --git a/docs/guides/infrastructure/mint-administration.md b/docs/guides/infrastructure/mint-administration.md index 7b39c239bb..ab3c6454a6 100644 --- a/docs/guides/infrastructure/mint-administration.md +++ b/docs/guides/infrastructure/mint-administration.md @@ -43,6 +43,20 @@ If you are using the hosted community mint, the rest of this guide managing self-hosted mints — you do not need to manage mint infrastructure yourself. +### Dispatch mint URL migration + +If `.fullsend/config.yaml` or `config.base.yaml` declares `mint_url`, +dispatch uses that endpoint instead of `FULLSEND_MINT_URL`. To retarget a +repo, change or remove the config field (removing it restores the variable +fallback). When both are set, dispatch follows config and emits a workflow +notice if the values differ. + +Config-sourced values must be HTTPS with no userinfo. Dispatch now fails +when config is present but `yq` is missing, YAML does not parse, the +resolved URL is invalid, or a declared config URL is not HTTPS (loopback +HTTP remains allowed only on the variable fallback when config is silent on +`mint_url`). + ## Prerequisites - **GCP project** with the following APIs enabled: @@ -181,7 +195,13 @@ fullsend mint deploy --project="$GCP_PROJECT" --pem-dir=/path/to/pems \ The mint URL is stable across redeploys within the same project and region — updating the Cloud Function does not change its URL. Enrolling a new repository in an existing mint only updates `PER_REPO_WIF_REPOS` (and WIF configuration) without redeploying the function. Shared `ROLE_APP_IDS` are managed at deploy/bootstrap time (`mint deploy --pem-dir`) or per-role via `mint add-role` / `remove-role` — not during enrollment. Existing enrolled repos continue working with no changes when new repos are enrolled. -Deploying to a **different region** (e.g., changing `--region` from `us-central1` to `us-east5`) creates a new Cloud Run service with a different URL. All enrolled repos store the mint URL in a repo or org variable (`FULLSEND_MINT_URL`), so changing the region requires updating every enrolled repo's variable. Avoid changing `--region` after initial deployment unless you plan to update all consumers. +Deploying to a **different region** (e.g., changing `--region` from +`us-central1` to `us-east5`) creates a new Cloud Run service with a +different URL. Update every consumer: set `mint_url` in +`.fullsend/config.yaml` or `config.base.yaml` when dispatch reads config, +and update `FULLSEND_MINT_URL` when config is silent on `mint_url` (see +[dispatch mint URL migration](#dispatch-mint-url-migration)). Avoid changing +`--region` after initial deployment unless you plan to update all consumers. ### HTTP Strict Transport Security diff --git a/docs/guides/infrastructure/standalone-mint.md b/docs/guides/infrastructure/standalone-mint.md index 706580c9f1..9b764b069e 100644 --- a/docs/guides/infrastructure/standalone-mint.md +++ b/docs/guides/infrastructure/standalone-mint.md @@ -199,6 +199,12 @@ gh api -X POST /repos/myorg/my-repo/actions/variables \ > **Note:** Repository-level variables override organization-level variables in GitHub Actions. If a repo already has `FULLSEND_MINT_URL` set at the repo level, update it there — the org-level variable will be ignored for that repo. +> **Dispatch precedence:** When `.fullsend/config.yaml` or +> `config.base.yaml` declares `mint_url`, agent dispatch uses that value +> instead of `FULLSEND_MINT_URL`. Retarget by updating the config field; +> changing only the variable is not enough when config sets a URL. See +> [Mint administration — dispatch mint URL migration](mint-administration.md#dispatch-mint-url-migration). + ## Privilege levels Levels are keys on each role. The mint looks up the requested level and returns the stored permission map — or returns an error if the level is not defined. Every role must define at least `read` and `write`; custom roles may define additional named levels. diff --git a/docs/guides/user/custom-agent-identity.md b/docs/guides/user/custom-agent-identity.md index 9cfe2a1d62..3075abf4c8 100644 --- a/docs/guides/user/custom-agent-identity.md +++ b/docs/guides/user/custom-agent-identity.md @@ -117,9 +117,10 @@ Set it up, then point your repo at it: slug: my-org-my-role # install-time App discovery; still not read by the mint ``` -3. **Point your repo at your mint** — set `FULLSEND_MINT_URL` to your mint's - URL. Without this, tokens are requested from the hosted mint, which does not - serve `my-role`. +3. **Point your repo at your mint** — set `FULLSEND_MINT_URL` and/or declare + `mint_url` in `.fullsend/config.yaml` or `config.base.yaml`. Dispatch + prefers the config value when both are set. Without either, tokens are + requested from the hosted mint, which does not serve `my-role`. > **Tip: adopt gradually.** With `FALLBACK_MINT_URL`, your standalone mint > serves your custom roles locally and proxies the built-in ones to the hosted diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index aef412e59f..d5f13bd173 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -652,6 +652,21 @@ variable. Install, dry run and `repos status` report a conflict when it differs from the manifest's own `mint_url`. See [Effective infrastructure values](../cli/repos.md#effective-infrastructure-values). +**GitHub agent dispatch** (`reusable-dispatch.yml`, `reusable-prioritize.yml`) +resolves the mint endpoint before minting credentials: this field in +`config.yaml`, then `config.base.yaml`, then the `FULLSEND_MINT_URL` +repository/org variable snapshot passed into the reusable workflow. A +declared config value overrides the variable; changing only the variable has +no effect while config sets `mint_url`. When every layer is silent, dispatch +uses the variable and does not apply the compiled CLI default +(`https://mint.fullsend.sh`). Dispatch fails when a config file exists but +`yq` is missing, a config file does not parse, the resolved URL is not HTTPS +(file values must be HTTPS; loopback HTTP is allowed only on the variable +fallback), or the URL contains userinfo. When config and the variable differ, +the route job emits a workflow notice naming the effective mint host. See +[Layered configuration reference](../guides/infrastructure/layered-config-reference.md) +and [Mint administration — dispatch mint URL migration](../guides/infrastructure/mint-administration.md#dispatch-mint-url-migration). + ### `inference` Groups inference backend settings under a single key. Each subfield resolves From 1bad343001e18f44c9e918e01acd26856bcca927 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Wed, 11 Nov 2026 11:02:30 +0100 Subject: [PATCH 12/18] fix(#8672): strengthen mint resolver wiring tests and docs Align vendor allowlist comments, workflow step gates and ordering assertions, script-test order, and dispatch mint_url notice wording. Signed-off-by: fmuntean Co-authored-by: Cursor --- Makefile | 2 +- .../infrastructure/mint-administration.md | 19 +++++---- docs/reference/config-reference.md | 10 +++-- internal/scaffold/vendorcontent.go | 16 ++++---- .../scaffold/workflow_call_alignment_test.go | 39 ++++++++++++++++++- 5 files changed, 64 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 221b4a3ecd..85ee05bafc 100644 --- a/Makefile +++ b/Makefile @@ -192,9 +192,9 @@ script-test: $(call run-timed,bash scripts/notify-adr-merge-test.sh) $(call run-timed,bash scripts/redact-behaviour-artifacts-test.sh) $(call run-timed,bash .github/scripts/check-fix-eligibility-test.sh) - $(call run-timed,bash .github/scripts/resolve-effective-mint-url-test.sh) $(call run-timed,bash .github/scripts/count-fix-commits-test.sh) $(call run-timed,bash .github/scripts/pre-fetch-review-body-test.sh) + $(call run-timed,bash .github/scripts/resolve-effective-mint-url-test.sh) $(call run-timed,bash .github/scripts/retry-with-backoff-test.sh) $(call run-timed,bash scripts/check-agents-gate-pin-test.sh) $(call run-timed,bash scripts/semgrep-scan-test.sh) diff --git a/docs/guides/infrastructure/mint-administration.md b/docs/guides/infrastructure/mint-administration.md index ab3c6454a6..48e0b85a13 100644 --- a/docs/guides/infrastructure/mint-administration.md +++ b/docs/guides/infrastructure/mint-administration.md @@ -48,14 +48,17 @@ infrastructure yourself. If `.fullsend/config.yaml` or `config.base.yaml` declares `mint_url`, dispatch uses that endpoint instead of `FULLSEND_MINT_URL`. To retarget a repo, change or remove the config field (removing it restores the variable -fallback). When both are set, dispatch follows config and emits a workflow -notice if the values differ. - -Config-sourced values must be HTTPS with no userinfo. Dispatch now fails -when config is present but `yq` is missing, YAML does not parse, the -resolved URL is invalid, or a declared config URL is not HTTPS (loopback -HTTP remains allowed only on the variable fallback when config is silent on -`mint_url`). +fallback). When config declares a value that differs from the workflow +`FULLSEND_MINT_URL` snapshot (including when that variable is unset), +dispatch follows config and emits a workflow notice naming the effective +mint host when it can be parsed safely. + +Config-sourced values must be HTTPS with no userinfo. The resolved URL is +validated on every run: declared config values must be HTTPS (no userinfo). +The variable fallback when config is silent on `mint_url` must also be a +valid URL and may use loopback HTTP (`localhost` / `127.0.0.1`) only on +that fallback path. Dispatch fails when config is present but `yq` is +missing, YAML does not parse, or the resolved URL fails validation. ## Prerequisites diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index e918f6e541..51d1ba61ed 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -667,10 +667,12 @@ declared config value overrides the variable; changing only the variable has no effect while config sets `mint_url`. When every layer is silent, dispatch uses the variable and does not apply the compiled CLI default (`https://mint.fullsend.sh`). Dispatch fails when a config file exists but -`yq` is missing, a config file does not parse, the resolved URL is not HTTPS -(file values must be HTTPS; loopback HTTP is allowed only on the variable -fallback), or the URL contains userinfo. When config and the variable differ, -the route job emits a workflow notice naming the effective mint host. See +`yq` is missing, a config file does not parse, or the resolved URL fails +validation (file values must be HTTPS with no userinfo; the variable +fallback may use loopback HTTP only when config is silent on `mint_url`). +When a declared config value differs from the workflow variable snapshot +(including an unset variable), dispatch follows config and the route job +may emit a workflow notice naming the effective mint host. See [Layered configuration reference](../guides/infrastructure/layered-config-reference.md) and [Mint administration — dispatch mint URL migration](../guides/infrastructure/mint-administration.md#dispatch-mint-url-migration). diff --git a/internal/scaffold/vendorcontent.go b/internal/scaffold/vendorcontent.go index b1eddead87..d0e02e4ca5 100644 --- a/internal/scaffold/vendorcontent.go +++ b/internal/scaffold/vendorcontent.go @@ -157,13 +157,15 @@ func isVendoredReusableWorkflow(path string) bool { // vendoredDefaultsScripts is the explicit allowlist of .github/scripts/ // files that ship to consumer repos. Everything here is executed in user -// repos: check-fix-eligibility.sh directly by the vendored reusable -// workflows, pre-fetch-review-body.sh and count-fix-commits.jq by the fix -// job's "Pre-fetch review body" (#8353) and "Extract PR number and -// context" (#8425) steps, the other four by the root composite action -// (action.yml, invoked as ./.defaults/ with GITHUB_ACTION_PATH resolving -// into the vendored tree). retry-with-backoff.sh is sourced by -// install-podman.sh and install-openshell.sh, so it must ship with them. +// repos: check-fix-eligibility.sh and resolve-effective-mint-url.sh +// directly by the vendored reusable workflows (dispatch route/harness jobs +// and reusable-prioritize); pre-fetch-review-body.sh and count-fix-commits.jq +// by the fix job's "Pre-fetch review body" (#8353) and "Extract PR number and +// context" (#8425) steps; install-openshell.sh, install-podman.sh, and +// openshell-version.sh by the root composite action (action.yml, invoked as +// ./.defaults/ with GITHUB_ACTION_PATH resolving into the vendored tree). +// retry-with-backoff.sh is sourced by install-podman.sh and +// install-openshell.sh, so it must ship with them. // // .github/scripts/ also hosts repo-local CI tooling and *-test.sh files // that must NOT ship to consumers. The directory prefix alone is diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index cbfe1a969b..7788d89c93 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -1185,16 +1185,21 @@ func TestReusableDispatchStageJobsResolvedMintURL(t *testing.T) { wantHarness := "${{ steps.resolve-mint.outputs.mint_url }}" harnessRun, ok := workflow.Jobs["harness-run"] require.True(t, ok, "harness-run job must exist") + var harnessMintToken, harnessAgent bool for _, step := range harnessRun.Steps { if step.Uses == "./.defaults/.github/actions/mint-token" { + harnessMintToken = true assert.Equal(t, wantHarness, step.With["mint_url"], "harness-run mint-token must use job-local resolve output") } if step.Uses == "./.defaults/" { + harnessAgent = true assert.Equal(t, wantHarness, step.With["mint-url"], "harness-run agent action must use job-local resolve output") } } + assert.True(t, harnessMintToken, "harness-run must mint an app token") + assert.True(t, harnessAgent, "harness-run must run the agent composite") prioritizePath := filepath.Join("..", "..", ".github", "workflows", "reusable-prioritize.yml") prioritizeContent, err := os.ReadFile(prioritizePath) @@ -1254,15 +1259,19 @@ func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { job, ok := workflow.Jobs[jobName] require.True(t, ok, "job %q must exist", jobName) names := make([]string, 0, len(job.Steps)) - var checkoutStep workflowStep + var checkoutStep, resolveStep workflowStep for _, step := range job.Steps { names = append(names, step.Name) if step.Name == "Checkout workflow mint URL resolver" { checkoutStep = step } + if step.Name == "Resolve effective mint URL" { + resolveStep = step + } } assert.Contains(t, names, "Prepare mint URL resolver script") assert.Contains(t, names, "Checkout workflow mint URL resolver") + assert.Contains(t, names, "Resolve effective mint URL") assert.Contains(t, checkoutStep.If, "mint-resolver-script.outputs.fetched") switch jobName { case "route": @@ -1270,11 +1279,19 @@ func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { stepIndex(names, "Prepare mint URL resolver script"), "route must resolve mint URL after the kill switch") assert.Contains(t, checkoutStep.If, "steps.route.outputs.stage") + assert.Contains(t, resolveStep.If, "steps.route.outputs.stage", + "route must not resolve mint URL when no stage is selected") case "harness-dispatch": assert.Less(t, stepIndex(names, "Detect registered harness triggers"), stepIndex(names, "Prepare mint URL resolver script"), "harness-dispatch must resolve mint URL after trigger detection") assert.Contains(t, checkoutStep.If, "has_triggers") + assert.Contains(t, resolveStep.If, "has_triggers", + "harness-dispatch must not resolve mint URL without registered triggers") + case "harness-run": + assert.Less(t, stepIndex(names, "Checkout upstream defaults"), + stepIndex(names, "Resolve effective mint URL"), + "harness-run must resolve mint URL only after upstream defaults are available") } }) } @@ -1285,11 +1302,29 @@ func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { assert.NotContains(t, string(content), "RUNNER_TEMP}/workflow-mint-resolver", "resolver script path must stay under GITHUB_WORKSPACE") - prioritize := string(loadRepoFile(".github/workflows/reusable-prioritize.yml")(t)) + prioritizeContent, err := os.ReadFile(filepath.Join("..", "..", ".github", "workflows", "reusable-prioritize.yml")) + require.NoError(t, err) + prioritize := string(prioritizeContent) assert.Contains(t, prioritize, "Checkout workflow mint URL resolver") assert.Contains(t, prioritize, "Prepare mint URL resolver script") assert.Contains(t, prioritize, "path: .workflow-mint-resolver") assert.NotContains(t, prioritize, "runner.temp }}/workflow-mint-resolver") + var prioritizeWF struct { + Jobs map[string]workflowJob `yaml:"jobs"` + } + require.NoError(t, yaml.Unmarshal(prioritizeContent, &prioritizeWF)) + for jobName, job := range prioritizeWF.Jobs { + names := make([]string, 0, len(job.Steps)) + for _, step := range job.Steps { + names = append(names, step.Name) + } + assert.Less(t, stepIndex(names, "Checkout upstream defaults"), + stepIndex(names, "Resolve effective mint URL"), + "reusable-prioritize job %q must resolve mint URL after upstream defaults", jobName) + assert.Less(t, stepIndex(names, "Resolve effective mint URL"), + stepIndex(names, "Validate enrollment and extract repository metadata"), + "reusable-prioritize job %q must resolve mint URL before composite actions", jobName) + } w := string(content) assert.NotContains(t, w, "for candidate in .github/scripts/resolve-effective-mint-url.sh", From 1b17a4e5d0086c6eccbe4cd933c2480bca651581 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Thu, 12 Nov 2026 15:19:58 +0100 Subject: [PATCH 13/18] fix(#8672): omit mint host from config override notice Align with mint-token URL masking: audit trail without exposing the endpoint in workflow annotations. Signed-off-by: fmuntean Co-authored-by: Cursor --- .../resolve-effective-mint-url-test.sh | 2 +- .github/scripts/resolve-effective-mint-url.sh | 29 ++----------------- .../infrastructure/mint-administration.md | 4 +-- docs/reference/config-reference.md | 3 +- 4 files changed, 8 insertions(+), 30 deletions(-) diff --git a/.github/scripts/resolve-effective-mint-url-test.sh b/.github/scripts/resolve-effective-mint-url-test.sh index e363f250fc..591d83c971 100755 --- a/.github/scripts/resolve-effective-mint-url-test.sh +++ b/.github/scripts/resolve-effective-mint-url-test.sh @@ -107,7 +107,7 @@ assert_eq "fallback only" "https://fallback.example" "$(run_resolve "https://fal setup_repo printf 'version: "1"\nmint_url: https://overlay.example\n' >.fullsend/config.yaml assert_eq "overlay wins" "https://overlay.example" "$(run_resolve "https://fallback.example")" -assert_notice_contains "overlay override notice" "mint host: overlay.example" "$(run_resolve_stderr "https://fallback.example")" +assert_notice_contains "overlay override notice" "mint_url from .fullsend config overrides FULLSEND_MINT_URL" "$(run_resolve_stderr "https://fallback.example")" setup_repo printf 'version: "1"\nmint_url: https://same.example\n' >.fullsend/config.yaml diff --git a/.github/scripts/resolve-effective-mint-url.sh b/.github/scripts/resolve-effective-mint-url.sh index b850ac7d14..6bb6f130ec 100755 --- a/.github/scripts/resolve-effective-mint-url.sh +++ b/.github/scripts/resolve-effective-mint-url.sh @@ -110,33 +110,10 @@ if ! _validate_resolved_mint_url "${_effective}" "${_from_file}"; then exit 1 fi -# File-sourced mint_url overrides the FULLSEND_MINT_URL snapshot; log only the -# host when the two differ so runs retain an audit trail without echoing URLs. -_mint_host_from_url() { - local url="$1" - local rest authority host - if [[ -z "${url}" ]]; then - return 0 - fi - if [[ "${url}" =~ ^[A-Za-z][A-Za-z0-9+.-]*://(.*)$ ]]; then - rest="${BASH_REMATCH[1]}" - else - return 1 - fi - authority="${rest%%[/?#]*}" - host="${authority%%:*}" - if [[ -n "${host}" ]]; then - printf '%s' "${host}" - fi -} - +# File-sourced mint_url overrides the FULLSEND_MINT_URL snapshot; say so without +# echoing the URL or host (mint-token masks the endpoint in later steps). if [[ "${_from_file}" == "true" && "${_effective}" != "${FALLBACK_MINT_URL:-}" ]]; then - host=$(_mint_host_from_url "${_effective}") || host="" - if [[ -n "${host}" ]]; then - echo "::notice::mint_url from .fullsend config overrides FULLSEND_MINT_URL (mint host: ${host})" >&2 - else - echo "::notice::mint_url from .fullsend config overrides FULLSEND_MINT_URL" >&2 - fi + echo "::notice::mint_url from .fullsend config overrides FULLSEND_MINT_URL" >&2 fi { diff --git a/docs/guides/infrastructure/mint-administration.md b/docs/guides/infrastructure/mint-administration.md index 218febc6a5..aab77ffa8b 100644 --- a/docs/guides/infrastructure/mint-administration.md +++ b/docs/guides/infrastructure/mint-administration.md @@ -50,8 +50,8 @@ dispatch uses that endpoint instead of `FULLSEND_MINT_URL`. To retarget a repo, change or remove the config field (removing it restores the variable fallback). When config declares a value that differs from the workflow `FULLSEND_MINT_URL` snapshot (including when that variable is unset), -dispatch follows config and emits a workflow notice naming the effective -mint host when it can be parsed safely. +dispatch follows config and emits a workflow notice that config overrides +the variable (no URL or host in the notice). Config-sourced values must be HTTPS with no userinfo. The resolved URL is validated on every run: declared config values must be HTTPS (no userinfo). diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index 29c861bdaa..26ed47e96e 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -710,7 +710,8 @@ validation (file values must be HTTPS with no userinfo; the variable fallback may use loopback HTTP only when config is silent on `mint_url`). When a declared config value differs from the workflow variable snapshot (including an unset variable), dispatch follows config and the route job -may emit a workflow notice naming the effective mint host. See +may emit a workflow notice that config overrides the variable (no URL or +host in the notice). See [Layered configuration reference](../guides/infrastructure/layered-config-reference.md) and [Mint administration — dispatch mint URL migration](../guides/infrastructure/mint-administration.md#dispatch-mint-url-migration). From c9791dcdc34505b47fe3271d04feb6a7432284c0 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Mon, 16 Nov 2026 11:01:41 +0100 Subject: [PATCH 14/18] fix(#8672): gofmt vendored script map after main merge Restore tab alignment so pre-commit go-fmt passes in CI. Signed-off-by: fmuntean Co-authored-by: Cursor --- internal/scaffold/vendorcontent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/scaffold/vendorcontent.go b/internal/scaffold/vendorcontent.go index 633b15cd04..bab0a878e3 100644 --- a/internal/scaffold/vendorcontent.go +++ b/internal/scaffold/vendorcontent.go @@ -183,7 +183,7 @@ var vendoredDefaultsScripts = map[string]bool{ ".github/scripts/openshell-version.sh": true, ".github/scripts/pre-fetch-review-body.sh": true, ".github/scripts/resolve-effective-mint-url.sh": true, - ".github/scripts/review-diff-hash.sh": true, + ".github/scripts/review-diff-hash.sh": true, ".github/scripts/retry-with-backoff.sh": true, } From cd3456737b29a84501b9bb7e27b9a046b42f0d98 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Mon, 16 Nov 2026 13:55:39 +0100 Subject: [PATCH 15/18] fix(#8672): address matrix event_payload as an object in harness-run fromJSON expects a JSON string; the harness matrix already passes a structured payload. Align status-comment-id and pr-head-sha with the Jira inputs on the same step. Signed-off-by: fmuntean Co-authored-by: Cursor --- .github/workflows/reusable-dispatch.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index 0b0e5512e5..73665974b0 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -2871,7 +2871,7 @@ jobs: run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ matrix.status_repo }} status-number: ${{ matrix.status_number }} - status-comment-id: ${{ fromJSON(matrix.event_payload).comment.id }} + status-comment-id: ${{ matrix.event_payload.comment.id }} mint-url: ${{ steps.resolve-mint.outputs.mint_url }} - pr-head-sha: ${{ fromJSON(matrix.event_payload).pull_request.head.sha || '' }} + pr-head-sha: ${{ matrix.event_payload.pull_request.head.sha || '' }} artifact-name: ${{ steps.dispatch-env.outputs.artifact_name }} From 89f1939f139004451f269bc11cf13958dc4c7920 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Wed, 25 Nov 2026 12:26:37 +0100 Subject: [PATCH 16/18] fix(#8672): accept loopback mint URLs from config Signed-off-by: fmuntean --- .../resolve-effective-mint-url-test.sh | 12 +++++++---- .github/scripts/resolve-effective-mint-url.sh | 20 +++++++++---------- .../infrastructure/mint-administration.md | 10 ++++------ docs/reference/config-reference.md | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/scripts/resolve-effective-mint-url-test.sh b/.github/scripts/resolve-effective-mint-url-test.sh index 591d83c971..9bd6719cb1 100755 --- a/.github/scripts/resolve-effective-mint-url-test.sh +++ b/.github/scripts/resolve-effective-mint-url-test.sh @@ -136,7 +136,7 @@ assert_eq "empty fallback" "" "$(run_resolve "")" setup_repo printf 'version: "1"\nmint_url: http://evil.example\n' >.fullsend/config.yaml -run_resolve_expect_fail "https://fallback.example" "reject http mint_url" "::error::mint_url must be a valid HTTPS URL" +run_resolve_expect_fail "https://fallback.example" "reject non-loopback http from config" "::error::mint_url must be a valid HTTPS URL, or HTTP on localhost/127.0.0.1" setup_repo printf 'version: "1"\nmint_url: https://user:pass@mint.example\n' >.fullsend/config.yaml @@ -157,11 +157,15 @@ setup_repo assert_eq "loopback http fallback" "http://127.0.0.1:8080" "$(run_resolve "http://127.0.0.1:8080")" setup_repo -printf 'version: "1"\nmint_url: http://localhost:8080\n' >.fullsend/config.yaml -run_resolve_expect_fail "" "reject localhost http from config file" "::error::mint_url must be a valid HTTPS URL" +printf 'version: "1"\nmint_url: http://127.0.0.1:18502\n' >.fullsend/config.yaml +assert_eq "emulator loopback http in overlay and fallback" "http://127.0.0.1:18502" "$(run_resolve "http://127.0.0.1:18502")" setup_repo -run_resolve_expect_fail "http://evil.example" "reject non-loopback http fallback" "::error::mint_url must be a valid HTTPS URL" +printf 'version: "1"\nmint_url: http://localhost:8080\n' >.fullsend/config.base.yaml +assert_eq "localhost http from base config" "http://localhost:8080" "$(run_resolve "https://fallback.example")" + +setup_repo +run_resolve_expect_fail "http://evil.example" "reject non-loopback http fallback" "::error::mint_url must be a valid HTTPS URL, or HTTP on localhost/127.0.0.1" setup_repo run_resolve_expect_fail "https://u:p@host" "reject userinfo fallback" "::error::mint_url must not contain userinfo" "u:p" diff --git a/.github/scripts/resolve-effective-mint-url.sh b/.github/scripts/resolve-effective-mint-url.sh index 6bb6f130ec..ee34943894 100755 --- a/.github/scripts/resolve-effective-mint-url.sh +++ b/.github/scripts/resolve-effective-mint-url.sh @@ -5,9 +5,8 @@ # the FULLSEND_MINT_URL snapshot when both files are silent. Stops short of the # compiled default (https://mint.fullsend.sh), matching resolveMintURL in the CLI. # -# Declared file values use the same HTTPS/userinfo gate as -# validateDeclaredMintURL. The FULLSEND_MINT_URL fallback also allows loopback -# HTTP (localhost / 127.0.0.1), matching mintclient.MintToken. +# Both config and fallback values allow HTTPS or loopback HTTP (localhost / +# 127.0.0.1), without userinfo, matching validateDeclaredMintURL. # # Requires: GITHUB_OUTPUT, FALLBACK_MINT_URL (may be empty). yq is required # only when .fullsend/config.yaml or config.base.yaml is present. @@ -31,11 +30,9 @@ if [[ -f "${_overlay}" || -f "${_base}" ]]; then fi fi -# Aligns with validateDeclaredMintURL for file-sourced values. Never echoes -# the URL: rejected values may contain userinfo. +# Never echoes the URL: rejected values may contain userinfo. _validate_resolved_mint_url() { local url="$1" - local from_file="${2:-false}" if [[ -z "${url}" ]]; then return 0 fi @@ -45,16 +42,17 @@ _validate_resolved_mint_url() { fi local scheme rest authority host + local invalid_url="::error::mint_url must be a valid HTTPS URL, or HTTP on localhost/127.0.0.1" if [[ "${url}" =~ ^([A-Za-z][A-Za-z0-9+.-]*)://(.*)$ ]]; then scheme="$(printf '%s' "${BASH_REMATCH[1]}" | tr '[:upper:]' '[:lower:]')" rest="${BASH_REMATCH[2]}" else - echo "::error::mint_url must be a valid HTTPS URL" >&2 + echo "${invalid_url}" >&2 return 1 fi authority="${rest%%[/?#]*}" if [[ -z "${authority}" ]]; then - echo "::error::mint_url must be a valid HTTPS URL" >&2 + echo "${invalid_url}" >&2 return 1 fi if [[ "${authority}" == *@* ]]; then @@ -64,13 +62,13 @@ _validate_resolved_mint_url() { if [[ "${scheme}" == "https" ]]; then return 0 fi - if [[ "${from_file}" != "true" && "${scheme}" == "http" ]]; then + if [[ "${scheme}" == "http" ]]; then host="${authority%%:*}" if [[ "${host}" == "localhost" || "${host}" == "127.0.0.1" ]]; then return 0 fi fi - echo "::error::mint_url must be a valid HTTPS URL" >&2 + echo "${invalid_url}" >&2 return 1 } @@ -106,7 +104,7 @@ elif [[ -f "${_base}" ]]; then fi fi -if ! _validate_resolved_mint_url "${_effective}" "${_from_file}"; then +if ! _validate_resolved_mint_url "${_effective}"; then exit 1 fi diff --git a/docs/guides/infrastructure/mint-administration.md b/docs/guides/infrastructure/mint-administration.md index 94782ba943..bb82cdca21 100644 --- a/docs/guides/infrastructure/mint-administration.md +++ b/docs/guides/infrastructure/mint-administration.md @@ -53,12 +53,10 @@ fallback). When config declares a value that differs from the workflow dispatch follows config and emits a workflow notice that config overrides the variable (no URL or host in the notice). -Config-sourced values must be HTTPS with no userinfo. The resolved URL is -validated on every run: declared config values must be HTTPS (no userinfo). -The variable fallback when config is silent on `mint_url` must also be a -valid URL and may use loopback HTTP (`localhost` / `127.0.0.1`) only on -that fallback path. Dispatch fails when config is present but `yq` is -missing, YAML does not parse, or the resolved URL fails validation. +Dispatch validates the resolved URL on every run. Both config and the +variable fallback accept HTTPS or HTTP on `localhost` or `127.0.0.1`, +without userinfo. Dispatch fails when config is present but `yq` is missing, +YAML does not parse, or the resolved URL fails validation. ## Prerequisites diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index fc40a6bc55..de62ccc96b 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -905,8 +905,8 @@ no effect while config sets `mint_url`. When every layer is silent, dispatch uses the variable and does not apply the compiled CLI default (`https://mint.fullsend.sh`). Dispatch fails when a config file exists but `yq` is missing, a config file does not parse, or the resolved URL fails -validation (file values must be HTTPS with no userinfo; the variable -fallback may use loopback HTTP only when config is silent on `mint_url`). +validation. Both config and the variable fallback accept HTTPS or HTTP on +`localhost` or `127.0.0.1`, without userinfo. When a declared config value differs from the workflow variable snapshot (including an unset variable), dispatch follows config and the route job may emit a workflow notice that config overrides the variable (no URL or From 6367e326ffb3249786950d0134716792a1367d27 Mon Sep 17 00:00:00 2001 From: fmuntean Date: Thu, 26 Nov 2026 11:32:59 +0100 Subject: [PATCH 17/18] fix(#8672): resolve review skip tokens from layered mint URL Signed-off-by: fmuntean --- .../resolve-effective-mint-url-test.sh | 34 +++ .github/workflows/reusable-dispatch.yml | 216 +++++++++--------- .../scaffold/workflow_call_alignment_test.go | 70 +++++- 3 files changed, 202 insertions(+), 118 deletions(-) diff --git a/.github/scripts/resolve-effective-mint-url-test.sh b/.github/scripts/resolve-effective-mint-url-test.sh index 9bd6719cb1..5e0a06e26e 100755 --- a/.github/scripts/resolve-effective-mint-url-test.sh +++ b/.github/scripts/resolve-effective-mint-url-test.sh @@ -11,6 +11,11 @@ SCRIPT="${SCRIPT_DIR}/resolve-effective-mint-url.sh" BASH_ABS="$(command -v bash)" FAILURES=0 +if ! command -v yq >/dev/null 2>&1; then + echo "FAIL: yq is required to run resolve-effective-mint-url-test.sh" >&2 + exit 1 +fi + TMPDIR="$(mktemp -d)" trap 'rm -rf "${TMPDIR}"' EXIT @@ -97,10 +102,22 @@ assert_eq() { local name="$1" want="$2" got="$3" if [[ "${want}" != "${got}" ]]; then echo "FAIL: ${name}: want ${want@Q}, got ${got@Q}" + if [[ -s "${TMPDIR}/resolve-stderr.txt" ]]; then + echo "Resolver stderr:" + cat "${TMPDIR}/resolve-stderr.txt" + fi FAILURES=$((FAILURES + 1)) fi } +setup_repo +if (unset GITHUB_OUTPUT; FALLBACK_MINT_URL="https://fallback.example" "${BASH_ABS}" "${SCRIPT}" 2>"${TMPDIR}/resolve-stderr.txt"); then + echo "FAIL: missing GITHUB_OUTPUT: expected non-zero exit" + FAILURES=$((FAILURES + 1)) +else + assert_notice_contains "missing GITHUB_OUTPUT" "GITHUB_OUTPUT is required" "$(cat "${TMPDIR}/resolve-stderr.txt")" +fi + setup_repo assert_eq "fallback only" "https://fallback.example" "$(run_resolve "https://fallback.example")" @@ -120,6 +137,7 @@ assert_no_notice_override "no notice for fallback only" "$(run_resolve_stderr "h setup_repo printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml assert_eq "base only" "https://base.example" "$(run_resolve "https://fallback.example")" +assert_notice_contains "base override notice" "mint_url from .fullsend config overrides FULLSEND_MINT_URL" "$(run_resolve_stderr "https://fallback.example")" setup_repo printf 'version: "1"\n' >.fullsend/config.yaml @@ -131,6 +149,19 @@ printf 'version: "1"\nmint_url: https://overlay.example\n' >.fullsend/config.yam printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml assert_eq "overlay beats base" "https://overlay.example" "$(run_resolve "https://fallback.example")" +setup_repo +printf 'version: "1"\nmint_url: null\n' >.fullsend/config.yaml +printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml +assert_eq "null overlay uses base" "https://base.example" "$(run_resolve "https://fallback.example")" + +setup_repo +printf 'version: "1"\nmint_url: null\n' >.fullsend/config.yaml +assert_eq "null overlay uses fallback" "https://fallback.example" "$(run_resolve "https://fallback.example")" + +setup_repo +printf 'version: "1"\nmint_url: "null"\n' >.fullsend/config.yaml +assert_eq "literal null overlay uses fallback" "https://fallback.example" "$(run_resolve "https://fallback.example")" + setup_repo assert_eq "empty fallback" "" "$(run_resolve "")" @@ -173,6 +204,9 @@ run_resolve_expect_fail "https://u:p@host" "reject userinfo fallback" "::error:: setup_repo run_resolve_expect_fail $'https://mint.example\nsmuggled' "reject LF in fallback" "::error::mint_url must not contain CR or LF" +setup_repo +run_resolve_expect_fail $'https://mint.example\rsmuggled' "reject CR in fallback" "::error::mint_url must not contain CR or LF" + setup_repo printf 'mint_url: [unclosed\n' >.fullsend/config.yaml run_resolve_expect_fail "https://fallback.example" "reject unparsable overlay" "::error::failed to read mint_url from .fullsend/config.yaml" diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index 4cdc96c63b..d9e3316bcb 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -1360,113 +1360,8 @@ jobs: echo "stage=${STAGE}" >> "${GITHUB_OUTPUT}" echo "trigger_source=${TRIGGER_SOURCE}" >> "${GITHUB_OUTPUT}" - # Only obtain a write-capable review token after final routing has - # authorized the review stage. The diff check above remains read-only. - - name: Checkout upstream defaults for review skip note - if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' && hashFiles('.defaults/action.yml', '.fullsend/.defaults/action.yml') == '' - continue-on-error: true - timeout-minutes: 2 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - repository: ${{ job.workflow_repository }} - ref: ${{ (github.event_name == 'pull_request' && job.workflow_sha == github.sha && github.event.pull_request.base.sha || job.workflow_sha) }} - path: .defaults - fetch-depth: 1 - sparse-checkout: | - .github/actions/ - internal/scaffold/fullsend-repo/ - sparse-checkout-cone-mode: false - - - name: Prepare workspace for review skip note - if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' && hashFiles('.fullsend/.defaults/action.yml') == '' - id: review-token-workspace - continue-on-error: true - timeout-minutes: 2 - uses: ./.defaults/.github/actions/prepare-workspace - with: - source_repo: ${{ github.repository }} - - # Older vendored prepare-workspace actions use the historical - # .defaults path internally. Provide that compatibility path while - # the action's defaults_root input is adopted by existing callers. - - name: Stage nested defaults compatibility path - if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' && hashFiles('.fullsend/.defaults/action.yml') != '' - shell: bash - run: ln -s .fullsend/.defaults .defaults - - - name: Prepare workspace for review skip note (nested vendor) - if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' && hashFiles('.fullsend/.defaults/action.yml') != '' - id: review-token-workspace-nested - continue-on-error: true - timeout-minutes: 2 - uses: ./.fullsend/.defaults/.github/actions/prepare-workspace - with: - defaults_root: .fullsend/.defaults - source_repo: ${{ github.repository }} - - - name: Mint review token for review skip note - if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' && hashFiles('.fullsend/.defaults/action.yml') == '' && steps.review-token-workspace.outcome == 'success' - id: review-token - continue-on-error: true - timeout-minutes: 2 - uses: ./.defaults/.github/actions/mint-token - with: - role: review - repos: ${{ steps.review-token-workspace.outputs.repo_name }} - level: write - mint_url: ${{ inputs.mint_url }} - - - name: Mint review token for review skip note (nested vendor) - if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' && hashFiles('.fullsend/.defaults/action.yml') != '' && steps.review-token-workspace-nested.outcome == 'success' - id: review-token-nested - continue-on-error: true - timeout-minutes: 2 - uses: ./.fullsend/.defaults/.github/actions/mint-token - with: - role: review - repos: ${{ steps.review-token-workspace-nested.outputs.repo_name }} - level: write - mint_url: ${{ inputs.mint_url }} - - - name: Publish review skip note - id: review-skip-publish - if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' - continue-on-error: true - env: - GH_TOKEN: ${{ steps.review-token.outputs.token || steps.review-token-nested.outputs.token || github.token }} - REVIEW_TOKEN: ${{ steps.review-token.outputs.token || steps.review-token-nested.outputs.token }} - SOURCE_REPO: ${{ github.repository }} - PR_NUMBER: ${{ github.event.pull_request.number || steps.fork-pr.outputs.number }} - FULLSEND_APP_SET: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} - REVIEW_APP_CLIENT_ID: ${{ vars.FULLSEND_REVIEW_CLIENT_ID }} - shell: bash - run: | - set -euo pipefail - echo "skipped=false" >> "${GITHUB_OUTPUT}" - if [[ -z "${REVIEW_TOKEN}" ]]; then - echo "::notice::Review-App token was unavailable; running the full review" - exit 0 - fi - dedup_cli="${RUNNER_TEMP}/fullsend-review-dedup/fullsend" - if [[ ! -x "${dedup_cli}" ]]; then - echo "::warning::Review deduplication CLI unavailable; running review" - exit 0 - fi - if ! decision="$("${dedup_cli}" review-dedup \ - --repo "${SOURCE_REPO}" \ - --pr "${PR_NUMBER}" \ - --app-set "${FULLSEND_APP_SET}" \ - --app-client-id "${REVIEW_APP_CLIENT_ID}" \ - --publish)"; then - echo "::warning::Review deduplication CLI failed to publish the skip note; running review" - exit 0 - fi - printf '%s\n' "${decision}" - if grep -qx 'skipped=true' <<<"${decision}"; then - echo "::notice::Skipping review after final routing: synchronize event has the same effective diff as the previous review" - echo "skipped=true" >> "${GITHUB_OUTPUT}" - fi - + # Validate the final route and resolve the mint URL before any + # write-capable review skip-note token is minted. - name: Validate routed stage if: steps.route.outputs.stage != '' env: @@ -1577,6 +1472,113 @@ jobs: fi bash "${RESOLVER}" + # Only obtain a write-capable review token after final routing has + # authorized the review stage. The diff check above remains read-only. + - name: Checkout upstream defaults for review skip note + if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' && hashFiles('.defaults/action.yml', '.fullsend/.defaults/action.yml') == '' + continue-on-error: true + timeout-minutes: 2 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: ${{ job.workflow_repository }} + ref: ${{ (github.event_name == 'pull_request' && job.workflow_sha == github.sha && github.event.pull_request.base.sha || job.workflow_sha) }} + path: .defaults + fetch-depth: 1 + sparse-checkout: | + .github/actions/ + internal/scaffold/fullsend-repo/ + sparse-checkout-cone-mode: false + + - name: Prepare workspace for review skip note + if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' && hashFiles('.fullsend/.defaults/action.yml') == '' + id: review-token-workspace + continue-on-error: true + timeout-minutes: 2 + uses: ./.defaults/.github/actions/prepare-workspace + with: + source_repo: ${{ github.repository }} + + # Older vendored prepare-workspace actions use the historical + # .defaults path internally. Provide that compatibility path while + # the action's defaults_root input is adopted by existing callers. + - name: Stage nested defaults compatibility path + if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' && hashFiles('.fullsend/.defaults/action.yml') != '' + shell: bash + run: ln -s .fullsend/.defaults .defaults + + - name: Prepare workspace for review skip note (nested vendor) + if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' && hashFiles('.fullsend/.defaults/action.yml') != '' + id: review-token-workspace-nested + continue-on-error: true + timeout-minutes: 2 + uses: ./.fullsend/.defaults/.github/actions/prepare-workspace + with: + defaults_root: .fullsend/.defaults + source_repo: ${{ github.repository }} + + - name: Mint review token for review skip note + if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' && steps.resolve-mint.outcome == 'success' && hashFiles('.fullsend/.defaults/action.yml') == '' && steps.review-token-workspace.outcome == 'success' + id: review-token + continue-on-error: true + timeout-minutes: 2 + uses: ./.defaults/.github/actions/mint-token + with: + role: review + repos: ${{ steps.review-token-workspace.outputs.repo_name }} + level: write + mint_url: ${{ steps.resolve-mint.outputs.mint_url }} + + - name: Mint review token for review skip note (nested vendor) + if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' && steps.resolve-mint.outcome == 'success' && hashFiles('.fullsend/.defaults/action.yml') != '' && steps.review-token-workspace-nested.outcome == 'success' + id: review-token-nested + continue-on-error: true + timeout-minutes: 2 + uses: ./.fullsend/.defaults/.github/actions/mint-token + with: + role: review + repos: ${{ steps.review-token-workspace-nested.outputs.repo_name }} + level: write + mint_url: ${{ steps.resolve-mint.outputs.mint_url }} + + - name: Publish review skip note + id: review-skip-publish + if: ((github.event_name == 'pull_request_target' || github.event_name == 'pull_request') && inputs.event_action == 'synchronize' || (github.event_name == 'workflow_run' && steps.bash-route.outputs.event_action == 'synchronize')) && steps.route.outputs.stage == 'review' && steps.review-diff.outputs.skip == 'true' + continue-on-error: true + env: + GH_TOKEN: ${{ steps.review-token.outputs.token || steps.review-token-nested.outputs.token || github.token }} + REVIEW_TOKEN: ${{ steps.review-token.outputs.token || steps.review-token-nested.outputs.token }} + SOURCE_REPO: ${{ github.repository }} + PR_NUMBER: ${{ github.event.pull_request.number || steps.fork-pr.outputs.number }} + FULLSEND_APP_SET: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} + REVIEW_APP_CLIENT_ID: ${{ vars.FULLSEND_REVIEW_CLIENT_ID }} + shell: bash + run: | + set -euo pipefail + echo "skipped=false" >> "${GITHUB_OUTPUT}" + if [[ -z "${REVIEW_TOKEN}" ]]; then + echo "::notice::Review-App token was unavailable; running the full review" + exit 0 + fi + dedup_cli="${RUNNER_TEMP}/fullsend-review-dedup/fullsend" + if [[ ! -x "${dedup_cli}" ]]; then + echo "::warning::Review deduplication CLI unavailable; running review" + exit 0 + fi + if ! decision="$("${dedup_cli}" review-dedup \ + --repo "${SOURCE_REPO}" \ + --pr "${PR_NUMBER}" \ + --app-set "${FULLSEND_APP_SET}" \ + --app-client-id "${REVIEW_APP_CLIENT_ID}" \ + --publish)"; then + echo "::warning::Review deduplication CLI failed to publish the skip note; running review" + exit 0 + fi + printf '%s\n' "${decision}" + if grep -qx 'skipped=true' <<<"${decision}"; then + echo "::notice::Skipping review after final routing: synchronize event has the same effective diff as the previous review" + echo "skipped=true" >> "${GITHUB_OUTPUT}" + fi + - name: Validate agents config if: steps.route.outputs.stage != '' run: | diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index 9437ea60de..a01fe48a5f 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -1271,8 +1271,11 @@ func TestReusableDispatchJobsReceiveMintOIDC(t *testing.T) { // route-resolved mint URL, not the workflow-call input snapshot (#8672). func TestReusableDispatchStageJobsResolvedMintURL(t *testing.T) { type workflowStep struct { + Name string `yaml:"name"` + If string `yaml:"if"` Uses string `yaml:"uses"` With map[string]string `yaml:"with"` + Env map[string]string `yaml:"env"` } type workflowJob struct { Steps []workflowStep `yaml:"steps"` @@ -1285,12 +1288,33 @@ func TestReusableDispatchStageJobsResolvedMintURL(t *testing.T) { require.NoError(t, err) require.NoError(t, yaml.Unmarshal(content, &workflow)) + wantLocal := "${{ steps.resolve-mint.outputs.mint_url }}" + route, ok := workflow.Jobs["route"] + require.True(t, ok, "route job must exist") + resolverIndex := -1 + var routeMintTokens int + for i, step := range route.Steps { + if step.Name == "Resolve effective mint URL" { + resolverIndex = i + } + if step.Uses == "./.defaults/.github/actions/mint-token" || + step.Uses == "./.fullsend/.defaults/.github/actions/mint-token" { + routeMintTokens++ + require.GreaterOrEqual(t, resolverIndex, 0, "route must resolve before minting %q", step.Name) + assert.Less(t, resolverIndex, i, "route must resolve before minting %q", step.Name) + assert.Equal(t, wantLocal, step.With["mint_url"], "route mint-token %q must use resolved URL", step.Name) + assert.Contains(t, step.If, "steps.resolve-mint.outcome == 'success'", + "route mint-token %q must not run when resolution fails", step.Name) + } + } + assert.Equal(t, 2, routeMintTokens, "route must check both review skip-note mint paths") + wantRoute := "${{ needs.route.outputs.mint_url }}" for _, jobName := range []string{"triage", "code", "review", "fix", "retro", "prioritize"} { t.Run(jobName, func(t *testing.T) { job, ok := workflow.Jobs[jobName] require.True(t, ok, "job %q must exist", jobName) - var sawMintToken, sawAgent bool + var sawMintToken, sawAgent, sawFailureReporter bool for _, step := range job.Steps { if step.Uses == "./.defaults/.github/actions/mint-token" { sawMintToken = true @@ -1304,33 +1328,52 @@ func TestReusableDispatchStageJobsResolvedMintURL(t *testing.T) { assert.Equal(t, wantRoute, step.With["mint-url"], "job %q agent action must use route output", jobName) } + if step.Name == "Report "+jobName+" launch failure" { + sawFailureReporter = true + assert.True(t, sawAgent, "job %q must report failures after its resolved-URL agent consumer", jobName) + if jobName != "prioritize" { + assert.True(t, sawMintToken, "job %q must report failures after its resolved-URL token consumer", jobName) + } + } } if jobName != "prioritize" { assert.True(t, sawMintToken, "job %q must mint an app token", jobName) } assert.True(t, sawAgent, "job %q must run the agent composite", jobName) + assert.True(t, sawFailureReporter, "job %q must include its launch-failure reporter", jobName) }) } - wantHarness := "${{ steps.resolve-mint.outputs.mint_url }}" harnessRun, ok := workflow.Jobs["harness-run"] require.True(t, ok, "harness-run job must exist") var harnessMintToken, harnessAgent bool for _, step := range harnessRun.Steps { if step.Uses == "./.defaults/.github/actions/mint-token" { harnessMintToken = true - assert.Equal(t, wantHarness, step.With["mint_url"], + assert.Equal(t, wantLocal, step.With["mint_url"], "harness-run mint-token must use job-local resolve output") } if step.Uses == "./.defaults/" { harnessAgent = true - assert.Equal(t, wantHarness, step.With["mint-url"], + assert.Equal(t, wantLocal, step.With["mint-url"], "harness-run agent action must use job-local resolve output") } } assert.True(t, harnessMintToken, "harness-run must mint an app token") assert.True(t, harnessAgent, "harness-run must run the agent composite") + harnessDispatch, ok := workflow.Jobs["harness-dispatch"] + require.True(t, ok, "harness-dispatch job must exist") + var sawDispatch bool + for _, step := range harnessDispatch.Steps { + if step.Name == "Run fullsend dispatch" { + sawDispatch = true + assert.Equal(t, wantLocal, step.Env["FULLSEND_MINT_URL"], + "harness-dispatch CLI must receive job-local resolve output") + } + } + assert.True(t, sawDispatch, "harness-dispatch must run the CLI") + prioritizePath := filepath.Join("..", "..", ".github", "workflows", "reusable-prioritize.yml") prioritizeContent, err := os.ReadFile(prioritizePath) require.NoError(t, err) @@ -1340,18 +1383,23 @@ func TestReusableDispatchStageJobsResolvedMintURL(t *testing.T) { } `yaml:"jobs"` } require.NoError(t, yaml.Unmarshal(prioritizeContent, &prioritizeWF)) - wantPrioritize := "${{ steps.resolve-mint.outputs.mint_url }}" + var prioritizeAgents, prioritizeMintTokens int for jobName, job := range prioritizeWF.Jobs { for _, step := range job.Steps { - if step.Uses != "./.defaults/" { - continue + if step.Uses == "./.defaults/" { + prioritizeAgents++ + assert.Equal(t, wantLocal, step.With["mint-url"], + "reusable-prioritize job %q must use resolve-mint output", jobName) + } + if step.Uses == "./.defaults/.github/actions/mint-token" { + prioritizeMintTokens++ + assert.Equal(t, wantLocal, step.With["mint_url"], + "reusable-prioritize job %q mint-token must use resolve-mint output", jobName) } - assert.Equal(t, wantPrioritize, step.With["mint-url"], - "reusable-prioritize job %q must use resolve-mint output", jobName) - assert.NotEqual(t, "${{ inputs.mint_url }}", step.With["mint-url"], - "reusable-prioritize job %q must not use workflow input", jobName) } } + assert.Positive(t, prioritizeAgents, "reusable-prioritize must run at least one agent composite") + assert.Positive(t, prioritizeMintTokens, "reusable-prioritize must mint at least one app token") } // TestReusableDispatchMintResolverFetchesFromWorkflow ensures upstream-mode From 59b967ab4b92337600471f8fd8cf7f6bea7e4d2c Mon Sep 17 00:00:00 2001 From: fmuntean Date: Wed, 2 Dec 2026 09:59:56 +0100 Subject: [PATCH 18/18] fix(#8672)!: keep review fallback independent of masked mint URL Resolve the endpoint in the review job so a failed skip note can still fall back to a full review. Align shell URL validation with Go and test resolver wiring, fallback paths, and empty config values. BREAKING CHANGE: Dispatch rejects malformed mint URLs, including nonnumeric ports and uppercase schemes. Use lowercase HTTPS URLs with numeric ports when specifying one. Signed-off-by: fmuntean --- .../resolve-effective-mint-url-test.sh | 38 +++++++- .github/scripts/resolve-effective-mint-url.sh | 14 ++- .github/workflows/reusable-dispatch.yml | 52 ++++++++++- .../infrastructure/mint-administration.md | 6 +- .../scaffold/workflow_call_alignment_test.go | 87 ++++++++++++++++--- 5 files changed, 178 insertions(+), 19 deletions(-) diff --git a/.github/scripts/resolve-effective-mint-url-test.sh b/.github/scripts/resolve-effective-mint-url-test.sh index 5e0a06e26e..f695d62e08 100755 --- a/.github/scripts/resolve-effective-mint-url-test.sh +++ b/.github/scripts/resolve-effective-mint-url-test.sh @@ -154,6 +154,15 @@ printf 'version: "1"\nmint_url: null\n' >.fullsend/config.yaml printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml assert_eq "null overlay uses base" "https://base.example" "$(run_resolve "https://fallback.example")" +setup_repo +printf 'version: "1"\nmint_url: ""\n' >.fullsend/config.yaml +printf 'version: "1"\nmint_url: https://base.example\n' >.fullsend/config.base.yaml +assert_eq "empty overlay uses base" "https://base.example" "$(run_resolve "https://fallback.example")" + +setup_repo +printf 'version: "1"\nmint_url: ""\n' >.fullsend/config.base.yaml +assert_eq "empty base uses fallback" "https://fallback.example" "$(run_resolve "https://fallback.example")" + setup_repo printf 'version: "1"\nmint_url: null\n' >.fullsend/config.yaml assert_eq "null overlay uses fallback" "https://fallback.example" "$(run_resolve "https://fallback.example")" @@ -179,7 +188,7 @@ assert_eq "at-sign in path is not userinfo" "https://mint.example/a@b" "$(run_re setup_repo printf 'version: "1"\nmint_url: HTTPS://mint.example\n' >.fullsend/config.yaml -assert_eq "uppercase scheme" "HTTPS://mint.example" "$(run_resolve "")" +run_resolve_expect_fail "" "reject uppercase scheme (Go parity)" "::error::mint_url must be a valid HTTPS URL" setup_repo assert_eq "localhost http fallback" "http://localhost:8080" "$(run_resolve "http://localhost:8080")" @@ -201,6 +210,33 @@ run_resolve_expect_fail "http://evil.example" "reject non-loopback http fallback setup_repo run_resolve_expect_fail "https://u:p@host" "reject userinfo fallback" "::error::mint_url must not contain userinfo" "u:p" +setup_repo +run_resolve_expect_fail "http://user@127.0.0.1" "Go rejects loopback userinfo" "::error::mint_url must not contain userinfo" "user@" + +# Mirror the URL cases in internal/urlutil.TestIsMintURL. The resolver +# deliberately permits an empty value: mint-token reports that separately. +for valid_url in \ + "https://mint.example.com" \ + "https://mint.example.com/v1/token" \ + "http://127.0.0.1:18502" \ + "http://localhost"; do + setup_repo + assert_eq "Go accepts ${valid_url}" "${valid_url}" "$(run_resolve "${valid_url}")" +done + +for invalid_url in \ + "http://10.0.0.1" \ + "http://example.com" \ + "https://" \ + "http:///path" \ + "ftp://127.0.0.1" \ + "https://mint.example " \ + "https://host:abc" \ + $'https://mint.example\t/path'; do + setup_repo + run_resolve_expect_fail "${invalid_url}" "Go rejects ${invalid_url}" "::error::mint_url must be a valid HTTPS URL" +done + setup_repo run_resolve_expect_fail $'https://mint.example\nsmuggled' "reject LF in fallback" "::error::mint_url must not contain CR or LF" diff --git a/.github/scripts/resolve-effective-mint-url.sh b/.github/scripts/resolve-effective-mint-url.sh index ee34943894..68088cd9f0 100755 --- a/.github/scripts/resolve-effective-mint-url.sh +++ b/.github/scripts/resolve-effective-mint-url.sh @@ -43,8 +43,14 @@ _validate_resolved_mint_url() { local scheme rest authority host local invalid_url="::error::mint_url must be a valid HTTPS URL, or HTTP on localhost/127.0.0.1" + # Reject characters and ports that net/url.Parse rejects before checking + # the scheme. Keep this gate aligned with internal/urlutil.TestIsMintURL. + if [[ "${url}" == *[[:cntrl:]]* ]]; then + echo "${invalid_url}" >&2 + return 1 + fi if [[ "${url}" =~ ^([A-Za-z][A-Za-z0-9+.-]*)://(.*)$ ]]; then - scheme="$(printf '%s' "${BASH_REMATCH[1]}" | tr '[:upper:]' '[:lower:]')" + scheme="${BASH_REMATCH[1]}" rest="${BASH_REMATCH[2]}" else echo "${invalid_url}" >&2 @@ -59,6 +65,12 @@ _validate_resolved_mint_url() { echo "::error::mint_url must not contain userinfo" >&2 return 1 fi + if [[ "${authority}" == *[[:space:]]* || + ( "${authority}" != \[* && ! "${authority}" =~ ^[^:]+(:[0-9]*)?$ ) || + ( "${authority}" == \[* && ! "${authority}" =~ ^\[[^][]+\](:[0-9]*)?$ ) ]]; then + echo "${invalid_url}" >&2 + return 1 + fi if [[ "${scheme}" == "https" ]]; then return 0 fi diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index d9e3316bcb..7d3caa490d 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -146,6 +146,8 @@ jobs: stage: ${{ steps.review-skip-publish.outputs.skipped != 'true' && steps.agent-check.outputs.skipped != 'true' && steps.route.outputs.stage || '' }} trigger_source: ${{ steps.route.outputs.trigger_source }} event_payload: ${{ steps.payload.outputs.event_payload }} + # Only jobs that never mint in route may consume this output. The + # skip-note mint masks the URL, so review resolves it in its own job. mint_url: ${{ steps.resolve-mint.outputs.mint_url }} # The fork PR number for workflow_run events, whose payload has none; # the stage concurrency groups fall back to it. @@ -2124,6 +2126,52 @@ jobs: internal/scaffold/fullsend-repo/ action.yml + # The route skip-note token masks its URL; GitHub omits masked job + # outputs. Resolve locally so a failed skip note can still run review. + - name: Prepare mint URL resolver script + id: mint-resolver-script + run: | + set -euo pipefail + RESOLVER="" + if [[ -f .defaults/.github/scripts/resolve-effective-mint-url.sh ]]; then + RESOLVER=".defaults/.github/scripts/resolve-effective-mint-url.sh" + fi + if [[ -n "${RESOLVER}" ]]; then + echo "path=${RESOLVER}" >> "${GITHUB_OUTPUT}" + echo "fetched=false" >> "${GITHUB_OUTPUT}" + else + echo "fetched=true" >> "${GITHUB_OUTPUT}" + fi + + - name: Checkout workflow mint URL resolver + if: steps.mint-resolver-script.outputs.fetched == 'true' + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: ${{ job.workflow_repository }} + ref: ${{ (github.event_name == 'pull_request' && job.workflow_sha == github.sha && github.event.pull_request.base.sha || job.workflow_sha) }} + path: .workflow-mint-resolver + fetch-depth: 1 + persist-credentials: false + sparse-checkout: | + .github/scripts/resolve-effective-mint-url.sh + sparse-checkout-cone-mode: false + + - name: Resolve effective mint URL + id: resolve-mint + env: + FALLBACK_MINT_URL: ${{ inputs.mint_url }} + run: | + set -euo pipefail + RESOLVER="${{ steps.mint-resolver-script.outputs.path }}" + if [[ -z "${RESOLVER}" ]]; then + RESOLVER=".workflow-mint-resolver/.github/scripts/resolve-effective-mint-url.sh" + fi + if [[ ! -f "${RESOLVER}" ]]; then + echo "::error::resolve-effective-mint-url.sh is missing from vendored defaults and workflow repository" + exit 1 + fi + bash "${RESOLVER}" + # The review job is separate from route, so it must install its own # copy before using the CLI to supersede an earlier skip note. - name: Detect review dedup CLI @@ -2245,7 +2293,7 @@ jobs: with: role: review repos: ${{ steps.workspace.outputs.repo_name }} - mint_url: ${{ needs.route.outputs.mint_url }} + mint_url: ${{ steps.resolve-mint.outputs.mint_url }} - name: Checkout target repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -2363,7 +2411,7 @@ jobs: source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} failure-trusted-bots: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} - mint-url: ${{ needs.route.outputs.mint_url }} + mint-url: ${{ steps.resolve-mint.outputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report review launch failure diff --git a/docs/guides/infrastructure/mint-administration.md b/docs/guides/infrastructure/mint-administration.md index bb82cdca21..4545c2d46e 100644 --- a/docs/guides/infrastructure/mint-administration.md +++ b/docs/guides/infrastructure/mint-administration.md @@ -49,9 +49,9 @@ If `.fullsend/config.yaml` or `config.base.yaml` declares `mint_url`, dispatch uses that endpoint instead of `FULLSEND_MINT_URL`. To retarget a repo, change or remove the config field (removing it restores the variable fallback). When config declares a value that differs from the workflow -`FULLSEND_MINT_URL` snapshot (including when that variable is unset), -dispatch follows config and emits a workflow notice that config overrides -the variable (no URL or host in the notice). +`FULLSEND_MINT_URL` snapshot, dispatch follows config. The same applies +when the variable is unset. Dispatch emits a workflow notice that config +overrides the variable. The notice omits the URL and host. Dispatch validates the resolved URL on every run. Both config and the variable fallback accept HTTPS or HTTP on `localhost` or `127.0.0.1`, diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index a01fe48a5f..e3cf3e812a 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -1267,18 +1267,22 @@ func TestReusableDispatchJobsReceiveMintOIDC(t *testing.T) { "the workflow must not copy the OIDC request token into logs or matrix data") } -// TestReusableDispatchStageJobsResolvedMintURL ensures inline stage jobs use the -// route-resolved mint URL, not the workflow-call input snapshot (#8672). +// TestReusableDispatchStageJobsResolvedMintURL ensures inline stage jobs use +// resolved mint URLs. Review must resolve locally: its route skip-note token +// masks the URL, which GitHub then omits from route's job outputs (#8672). func TestReusableDispatchStageJobsResolvedMintURL(t *testing.T) { type workflowStep struct { - Name string `yaml:"name"` - If string `yaml:"if"` - Uses string `yaml:"uses"` - With map[string]string `yaml:"with"` - Env map[string]string `yaml:"env"` + Name string `yaml:"name"` + ID string `yaml:"id"` + If string `yaml:"if"` + Uses string `yaml:"uses"` + With map[string]string `yaml:"with"` + Env map[string]string `yaml:"env"` + ContinueOnError bool `yaml:"continue-on-error"` } type workflowJob struct { - Steps []workflowStep `yaml:"steps"` + Outputs map[string]string `yaml:"outputs"` + Steps []workflowStep `yaml:"steps"` } var workflow struct { Jobs map[string]workflowJob `yaml:"jobs"` @@ -1293,6 +1297,7 @@ func TestReusableDispatchStageJobsResolvedMintURL(t *testing.T) { require.True(t, ok, "route job must exist") resolverIndex := -1 var routeMintTokens int + var sawSkipPublish bool for i, step := range route.Steps { if step.Name == "Resolve effective mint URL" { resolverIndex = i @@ -1300,17 +1305,25 @@ func TestReusableDispatchStageJobsResolvedMintURL(t *testing.T) { if step.Uses == "./.defaults/.github/actions/mint-token" || step.Uses == "./.fullsend/.defaults/.github/actions/mint-token" { routeMintTokens++ + assert.True(t, step.ContinueOnError, "skip-note token failure must fall back to review") require.GreaterOrEqual(t, resolverIndex, 0, "route must resolve before minting %q", step.Name) assert.Less(t, resolverIndex, i, "route must resolve before minting %q", step.Name) assert.Equal(t, wantLocal, step.With["mint_url"], "route mint-token %q must use resolved URL", step.Name) assert.Contains(t, step.If, "steps.resolve-mint.outcome == 'success'", "route mint-token %q must not run when resolution fails", step.Name) } + if step.ID == "review-skip-publish" { + sawSkipPublish = true + assert.True(t, step.ContinueOnError, "skip-note publication failure must fall back to review") + } } assert.Equal(t, 2, routeMintTokens, "route must check both review skip-note mint paths") + assert.True(t, sawSkipPublish, "route must attempt skip-note publication") + assert.Contains(t, route.Outputs["stage"], "steps.review-skip-publish.outputs.skipped != 'true'", + "review must run when skip-note minting or publication fails") wantRoute := "${{ needs.route.outputs.mint_url }}" - for _, jobName := range []string{"triage", "code", "review", "fix", "retro", "prioritize"} { + for _, jobName := range []string{"triage", "code", "fix", "retro", "prioritize"} { t.Run(jobName, func(t *testing.T) { job, ok := workflow.Jobs[jobName] require.True(t, ok, "job %q must exist", jobName) @@ -1344,6 +1357,32 @@ func TestReusableDispatchStageJobsResolvedMintURL(t *testing.T) { }) } + review, ok := workflow.Jobs["review"] + require.True(t, ok, "review job must exist") + resolvedAt := -1 + var reviewMint, reviewAgent bool + for i, step := range review.Steps { + if step.ID == "resolve-mint" { + resolvedAt = i + assert.Equal(t, "${{ inputs.mint_url }}", step.Env["FALLBACK_MINT_URL"]) + } + if step.Uses == "./.defaults/.github/actions/mint-token" { + reviewMint = true + assert.GreaterOrEqual(t, resolvedAt, 0, "review must resolve before mint-token") + assert.Less(t, resolvedAt, i) + assert.Equal(t, wantLocal, step.With["mint_url"], + "review must not use a route output masked by skip-note minting") + } + if step.Uses == "./.defaults/" { + reviewAgent = true + assert.GreaterOrEqual(t, resolvedAt, 0, "review must resolve before agent") + assert.Less(t, resolvedAt, i) + assert.Equal(t, wantLocal, step.With["mint-url"]) + } + } + assert.True(t, reviewMint, "review must mint an app token") + assert.True(t, reviewAgent, "review must run the agent composite") + harnessRun, ok := workflow.Jobs["harness-run"] require.True(t, ok, "harness-run job must exist") var harnessMintToken, harnessAgent bool @@ -1407,8 +1446,10 @@ func TestReusableDispatchStageJobsResolvedMintURL(t *testing.T) { // job.workflow_repository (#9104). func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { type workflowStep struct { - Name string `yaml:"name"` - If string `yaml:"if"` + Name string `yaml:"name"` + If string `yaml:"if"` + Env map[string]string `yaml:"env"` + Uses string `yaml:"uses"` } type workflowJob struct { Steps []workflowStep `yaml:"steps"` @@ -1432,7 +1473,7 @@ func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { return -1 } - for _, jobName := range []string{"route", "harness-dispatch", "harness-run"} { + for _, jobName := range []string{"route", "review", "harness-dispatch", "harness-run"} { t.Run(jobName, func(t *testing.T) { job, ok := workflow.Jobs[jobName] require.True(t, ok, "job %q must exist", jobName) @@ -1451,6 +1492,8 @@ func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { assert.Contains(t, names, "Checkout workflow mint URL resolver") assert.Contains(t, names, "Resolve effective mint URL") assert.Contains(t, checkoutStep.If, "mint-resolver-script.outputs.fetched") + assert.Equal(t, "${{ inputs.mint_url }}", resolveStep.Env["FALLBACK_MINT_URL"], + "job %q must pass the variable snapshot to the resolver", jobName) switch jobName { case "route": assert.Less(t, stepIndex(names, "Check kill switch"), @@ -1471,6 +1514,16 @@ func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { stepIndex(names, "Resolve effective mint URL"), "harness-run must resolve mint URL only after upstream defaults are available") } + if jobName == "review" || jobName == "harness-run" || jobName == "harness-dispatch" { + resolveIndex := stepIndex(names, "Resolve effective mint URL") + for i, step := range job.Steps { + if step.Uses == "./.defaults/.github/actions/mint-token" || + step.Uses == "./.defaults/" || + step.Name == "Run fullsend dispatch" { + assert.Less(t, resolveIndex, i, "job %q must resolve before %q", jobName, step.Name) + } + } + } }) } assert.Contains(t, string(content), "path: .workflow-mint-resolver", @@ -1495,6 +1548,10 @@ func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { names := make([]string, 0, len(job.Steps)) for _, step := range job.Steps { names = append(names, step.Name) + if step.Name == "Resolve effective mint URL" { + assert.Equal(t, "${{ inputs.mint_url }}", step.Env["FALLBACK_MINT_URL"], + "reusable-prioritize job %q must pass the variable snapshot", jobName) + } } assert.Less(t, stepIndex(names, "Checkout upstream defaults"), stepIndex(names, "Resolve effective mint URL"), @@ -1502,6 +1559,12 @@ func TestReusableDispatchMintResolverFetchesFromWorkflow(t *testing.T) { assert.Less(t, stepIndex(names, "Resolve effective mint URL"), stepIndex(names, "Validate enrollment and extract repository metadata"), "reusable-prioritize job %q must resolve mint URL before composite actions", jobName) + resolveIndex := stepIndex(names, "Resolve effective mint URL") + for i, step := range job.Steps { + if step.Uses == "./.defaults/.github/actions/mint-token" || step.Uses == "./.defaults/" { + assert.Less(t, resolveIndex, i, "reusable-prioritize job %q must resolve before %q", jobName, step.Name) + } + } } w := string(content)