Skip to content

The agent that grows with you

refactor(ci): one-dispatch disposable builds; run-id lease without attempt (round 4)

ethernet3112b440d9a8
diff --git a/.github/workflows/desktop-bundled-release.yml b/.github/workflows/desktop-bundled-release.yml
index 7c156322a00..54f66772117 100644
--- a/.github/workflows/desktop-bundled-release.yml
+++ b/.github/workflows/desktop-bundled-release.yml
@@ -155,11 +155,15 @@ permissions:
id-token: write
concurrency:
- group: desktop-bundled-release-${{ inputs.channel_build || inputs.tag || inputs.build_commit || 'canary' }}-${{ inputs.release-phase || 'canary' }}
+ # One dispatch: a disposable run's identity is its channel name, so a
+ # re-dispatch of the same channel serializes instead of racing the namespace.
+ group: desktop-bundled-release-${{ inputs.channel_build || inputs.disposable_channel || inputs.tag || inputs.build_commit || 'canary' }}-${{ inputs.release-phase || 'canary' }}
cancel-in-progress: false
env:
- R2_DISPOSABLE_RUN: ${{ inputs.disposable_run }}
+ # One dispatch: a disposable-mode run leases its namespace by run id alone
+ # (no attempt suffix) so "re-run failed jobs" re-enters the same namespace.
+ R2_DISPOSABLE_RUN: ${{ inputs.disposable_run || (inputs.disposable_channel != '' && github.run_id) || '' }}
jobs:
allocate-disposable:
@@ -205,11 +209,24 @@ jobs:
cache-python: false
archive-inputs: false
- name: Probe scoped storage and allocate without dispatching
+ id: allocate
run: python -m scripts.releases.channel_disposable
+ outputs:
+ channel_build: ${{ steps.allocate.outputs.channel_build }}
+ channel_request_sha256: ${{ steps.allocate.outputs.channel_request_sha256 }}
+ disposable_run: ${{ steps.allocate.outputs.disposable_run }}
+ public_base: ${{ steps.allocate.outputs.public_base }}
+ storage_prefix: ${{ steps.allocate.outputs.storage_prefix }}
validate:
name: Validate the build source
- if: inputs.disposable_channel == ''
+ # One dispatch: in disposable mode the channel pin comes from this run's
+ # allocation (needs below), not a second dispatch's inputs. A failed
+ # allocation skips admission; non-disposable runs have nothing allocated.
+ if: >-
+ !cancelled() && (inputs.disposable_channel == ''
+ || needs.allocate-disposable.result == 'success')
+ needs: [allocate-disposable]
runs-on: ubuntu-24.04
# Public root is an environment variable, not a repository variable. No
# secret is injected into admission; downstream jobs consume its outputs.
@@ -230,6 +247,9 @@ jobs:
receiver-candidate: ${{ steps.admission.outputs.receiver-candidate }}
public-root: ${{ steps.admission.outputs.public-root }}
public-base: ${{ steps.admission.outputs.public-base }}
+ channel-build: ${{ (inputs.disposable_channel != '' && needs.allocate-disposable.outputs.channel_build) || inputs.channel_build || '' }}
+ channel-request-sha256: ${{ (inputs.disposable_channel != '' && needs.allocate-disposable.outputs.channel_request_sha256) || inputs.channel_request_sha256 || '' }}
+ disposable-run: ${{ (inputs.disposable_channel != '' && github.run_id) || inputs.disposable_run || '' }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
@@ -244,8 +264,8 @@ jobs:
env:
TAG: ${{ inputs.tag }}
BUILD_COMMIT: ${{ inputs.build_commit }}
- CHANNEL_BUILD: ${{ inputs.channel_build }}
- CHANNEL_REQUEST_SHA256: ${{ inputs.channel_request_sha256 }}
+ CHANNEL_BUILD: ${{ inputs.channel_build || needs.allocate-disposable.outputs.channel_build || '' }}
+ CHANNEL_REQUEST_SHA256: ${{ inputs.channel_request_sha256 || needs.allocate-disposable.outputs.channel_request_sha256 || '' }}
CLOUDFLARE_R2_PUBLIC_URL: ${{ vars.CLOUDFLARE_R2_PUBLIC_URL }}
TERMUX_ONLY: ${{ inputs.termux_only }}
BUNDLE_ENV_JSON: ${{ inputs.bundle_env }}
@@ -345,7 +365,7 @@ jobs:
# Windows assembly and publication depend on these native Windows legs.
archive-inputs:
name: Archive every pinned input
- if: inputs.disposable_run == '' && (inputs.release-phase == '' || inputs.release-phase == 'candidate')
+ if: inputs.disposable_run == '' && inputs.disposable_channel == '' && (inputs.release-phase == '' || inputs.release-phase == 'candidate')
needs: [validate]
uses: ./.github/workflows/archive-inputs.yml
with:
@@ -371,7 +391,7 @@ jobs:
- label: win32-arm64
runner: windows-11-arm
env: &win32-env
- CHANNEL_BUILD: ${{ inputs.channel_build }}
+ CHANNEL_BUILD: ${{ needs.validate.outputs.channel-build }}
HERMES_DESKTOP_VARIANT: bundled
HERMES_PAYLOAD_TAG: ${{ inputs.tag }}
HERMES_BUILD_COMMIT: ${{ needs.validate.outputs.sha && inputs.build_commit != '' && needs.validate.outputs.sha || '' }}
@@ -412,7 +432,7 @@ jobs:
fetch-tags: true
- name: Check out trusted channel controller
- if: inputs.channel_build != ''
+ if: needs.validate.outputs.channel-build != ''
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.sha }}
@@ -420,12 +440,12 @@ jobs:
persist-credentials: false
- name: Retrieve pinned channel request
- if: inputs.channel_build != ''
+ if: needs.validate.outputs.channel-build != ''
shell: bash
working-directory: .build/channel-controller
env:
- CHANNEL_BUILD: ${{ inputs.channel_build }}
- CHANNEL_REQUEST_SHA256: ${{ inputs.channel_request_sha256 }}
+ CHANNEL_BUILD: ${{ needs.validate.outputs.channel-build }}
+ CHANNEL_REQUEST_SHA256: ${{ needs.validate.outputs.channel-request-sha256 }}
run: python -m scripts.releases.channel_publish request --out "$RUNNER_TEMP/channel-request.json"
- name: Restore desktop dependency inputs
@@ -537,7 +557,7 @@ jobs:
--arch="${MATRIX_LABEL##*-}" --root=apps/desktop/release
- name: Record and stage channel windows packages
- if: inputs.channel_build != ''
+ if: needs.validate.outputs.channel-build != ''
shell: bash
working-directory: .build/channel-controller
env:
@@ -588,7 +608,7 @@ jobs:
name: bundled ${{ matrix.target.label }} (commit)
if: >-
!cancelled() && needs.validate.result == 'success'
- && (needs.archive-inputs.result == 'success' || (inputs.disposable_run != '' && needs.archive-inputs.result == 'skipped'))
+ && (needs.archive-inputs.result == 'success' || ((inputs.disposable_run != '' || inputs.disposable_channel != '') && needs.archive-inputs.result == 'skipped'))
&& inputs.termux_only != true && (inputs.release-phase == '' || inputs.release-phase == 'candidate')
&& (inputs.build_commit != '' || inputs.channel_build != '')
needs: [validate, archive-inputs]
@@ -607,7 +627,7 @@ jobs:
if: >-
always() && inputs.termux_only != true && (inputs.release-phase == '' || inputs.release-phase == 'candidate')
&& needs.validate.result == 'success'
- && (needs.archive-inputs.result == 'success' || (inputs.disposable_run != '' && needs.archive-inputs.result == 'skipped'))
+ && (needs.archive-inputs.result == 'success' || ((inputs.disposable_run != '' || inputs.disposable_channel != '') && needs.archive-inputs.result == 'skipped'))
needs: [validate, archive-inputs, build-win32-release, build-win32-commit]
runs-on: ubuntu-24.04
permissions: {}
@@ -653,7 +673,7 @@ jobs:
- label: darwin-x64
runner: macos-15-intel
env: &darwin-env
- CHANNEL_BUILD: ${{ inputs.channel_build }}
+ CHANNEL_BUILD: ${{ needs.validate.outputs.channel-build }}
HERMES_DESKTOP_VARIANT: bundled
HERMES_PAYLOAD_TAG: ${{ inputs.tag }}
HERMES_BUILD_COMMIT: ${{ needs.validate.outputs.sha && inputs.build_commit != '' && needs.validate.outputs.sha || '' }}
@@ -678,7 +698,7 @@ jobs:
fetch-depth: 0
- name: Check out trusted channel controller
- if: inputs.channel_build != ''
+ if: needs.validate.outputs.channel-build != ''
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.sha }}
@@ -686,12 +706,12 @@ jobs:
persist-credentials: false
- name: Retrieve pinned channel request
- if: inputs.channel_build != ''
+ if: needs.validate.outputs.channel-build != ''
shell: bash
working-directory: .build/channel-controller
env:
- CHANNEL_BUILD: ${{ inputs.channel_build }}
- CHANNEL_REQUEST_SHA256: ${{ inputs.channel_request_sha256 }}
+ CHANNEL_BUILD: ${{ needs.validate.outputs.channel-build }}
+ CHANNEL_REQUEST_SHA256: ${{ needs.validate.outputs.channel-request-sha256 }}
run: python -m scripts.releases.channel_publish request --out "$RUNNER_TEMP/channel-request.json"
- name: Restore desktop dependency inputs
@@ -833,7 +853,7 @@ jobs:
mv "$f" "apps/desktop/release/${arch}-${channel}-mac.yml"
- name: Record and stage channel macos packages
- if: inputs.channel_build != ''
+ if: needs.validate.outputs.channel-build != ''
shell: bash
working-directory: .build/channel-controller
env:
@@ -884,7 +904,7 @@ jobs:
name: bundled ${{ matrix.target.label }} (commit)
if: >-
!cancelled() && needs.validate.result == 'success'
- && (needs.archive-inputs.result == 'success' || (inputs.disposable_run != '' && needs.archive-inputs.result == 'skipped'))
+ && (needs.archive-inputs.result == 'success' || ((inputs.disposable_run != '' || inputs.disposable_channel != '') && needs.archive-inputs.result == 'skipped'))
&& inputs.termux_only != true && (inputs.release-phase == '' || inputs.release-phase == 'candidate')
&& (inputs.build_commit != '' || inputs.channel_build != '')
needs: [validate, archive-inputs]
@@ -903,7 +923,7 @@ jobs:
if: >-
always() && inputs.termux_only != true && (inputs.release-phase == '' || inputs.release-phase == 'candidate')
&& needs.validate.result == 'success'
- && (needs.archive-inputs.result == 'success' || (inputs.disposable_run != '' && needs.archive-inputs.result == 'skipped'))
+ && (needs.archive-inputs.result == 'success' || ((inputs.disposable_run != '' || inputs.disposable_channel != '') && needs.archive-inputs.result == 'skipped'))
needs: [validate, archive-inputs, build-darwin-release, build-darwin-commit]
runs-on: ubuntu-24.04
permissions: {}
@@ -953,13 +973,13 @@ jobs:
format: ${{ matrix.format }}
sha: ${{ needs.validate.outputs.sha }}
tag: ${{ inputs.tag }}
- commit-build: ${{ inputs.build_commit != '' }}
- channel-build: ${{ inputs.channel_build }}
- channel-request-sha256: ${{ inputs.channel_request_sha256 }}
+ commit-build: ${{ inputs.build_commit != '' && needs.validate.outputs.channel-build == '' }}
+ channel-build: ${{ needs.validate.outputs.channel-build }}
+ channel-request-sha256: ${{ needs.validate.outputs.channel-request-sha256 }}
controller-sha: ${{ github.sha }}
public-base: ${{ needs.validate.outputs.public-base }}
public-root: ${{ needs.validate.outputs.public-root }}
- disposable-run: ${{ inputs.disposable_run }}
+ disposable-run: ${{ needs.validate.outputs.disposable-run }}
smoke-win32:
name: Smoke Windows ${{ matrix.arch }} MSIX
@@ -982,13 +1002,13 @@ jobs:
format: msix
sha: ${{ needs.validate.outputs.sha }}
tag: ${{ inputs.tag }}
- commit-build: ${{ inputs.build_commit != '' }}
- channel-build: ${{ inputs.channel_build }}
- channel-request-sha256: ${{ inputs.channel_request_sha256 }}
+ commit-build: ${{ inputs.build_commit != '' && needs.validate.outputs.channel-build == '' }}
+ channel-build: ${{ needs.validate.outputs.channel-build }}
+ channel-request-sha256: ${{ needs.validate.outputs.channel-request-sha256 }}
controller-sha: ${{ github.sha }}
public-base: ${{ needs.validate.outputs.public-base }}
public-root: ${{ needs.validate.outputs.public-root }}
- disposable-run: ${{ inputs.disposable_run }}
+ disposable-run: ${{ needs.validate.outputs.disposable-run }}
smoke-win32-universal:
name: Smoke Windows ${{ matrix.arch }} MSIXBUNDLE
@@ -1011,13 +1031,13 @@ jobs:
format: msixbundle
sha: ${{ needs.validate.outputs.sha }}
tag: ${{ inputs.tag }}
- commit-build: ${{ inputs.build_commit != '' }}
- channel-build: ${{ inputs.channel_build }}
- channel-request-sha256: ${{ inputs.channel_request_sha256 }}
+ commit-build: ${{ inputs.build_commit != '' && needs.validate.outputs.channel-build == '' }}
+ channel-build: ${{ needs.validate.outputs.channel-build }}
+ channel-request-sha256: ${{ needs.validate.outputs.channel-request-sha256 }}
controller-sha: ${{ github.sha }}
public-base: ${{ needs.validate.outputs.public-base }}
public-root: ${{ needs.validate.outputs.public-root }}
- disposable-run: ${{ inputs.disposable_run }}
+ disposable-run: ${{ needs.validate.outputs.disposable-run }}
# Assembly never writes a feed, including for canaries.
assemble-win32-bundle:
@@ -1033,8 +1053,8 @@ jobs:
cache-mode: read
timeout-minutes: 45
env:
- CHANNEL_BUILD: ${{ inputs.channel_build }}
- CHANNEL_REQUEST_SHA256: ${{ inputs.channel_request_sha256 }}
+ CHANNEL_BUILD: ${{ needs.validate.outputs.channel-build }}
+ CHANNEL_REQUEST_SHA256: ${{ needs.validate.outputs.channel-request-sha256 }}
HERMES_PAYLOAD_TAG: ${{ inputs.tag }}
HERMES_BUILD_COMMIT: ${{ needs.validate.outputs.sha && inputs.build_commit != '' && needs.validate.outputs.sha || '' }}
HERMES_PAYLOAD_VERSION: ${{ needs.validate.outputs.payload-version }}
@@ -1054,21 +1074,24 @@ jobs:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# Channel assembly/publishing code stays at the trusted controller.
- ref: ${{ inputs.channel_build != '' && github.sha || needs.validate.outputs.sha }}
+ ref: ${{ needs.validate.outputs.channel-build != '' && github.sha || needs.validate.outputs.sha }}
# stage-msixbundle derives the canary MSIX build number as
# minutes-since-the-last-stable from git tags — must see them.
fetch-tags: true
- name: Retrieve pinned channel request
- if: inputs.channel_build != ''
+ if: needs.validate.outputs.channel-build != ''
shell: bash
+ env:
+ CHANNEL_BUILD: ${{ needs.validate.outputs.channel-build }}
+ CHANNEL_REQUEST_SHA256: ${{ needs.validate.outputs.channel-request-sha256 }}
run: python -m scripts.releases.channel_publish request --out "$RUNNER_TEMP/channel-request.json"
- name: Set up the locked build toolchain
uses: ./.github/actions/setup-pm
with:
toolchain: all
- archive-inputs: ${{ inputs.disposable_run == '' }}
+ archive-inputs: ${{ inputs.disposable_run == '' && inputs.disposable_channel == '' }}
cache-python: false
save-tools-cache: false
save-node-cache: false
@@ -1198,7 +1221,7 @@ jobs:
name: Publish the complete native-smoked channel build
needs: [validate, build-darwin, build-win32, assemble-win32-bundle, smoke-darwin, smoke-win32, smoke-win32-universal]
if: >-
- !cancelled() && inputs.channel_build != '' && needs.validate.result == 'success'
+ !cancelled() && needs.validate.outputs.channel-build != '' && needs.validate.result == 'success'
&& needs.build-darwin.result == 'success' && needs.build-win32.result == 'success'
&& needs.assemble-win32-bundle.result == 'success' && needs.smoke-darwin.result == 'success'
&& needs.smoke-win32.result == 'success' && needs.smoke-win32-universal.result == 'success'
@@ -1209,8 +1232,8 @@ jobs:
permissions:
contents: read
env:
- CHANNEL_BUILD: ${{ inputs.channel_build }}
- CHANNEL_REQUEST_SHA256: ${{ inputs.channel_request_sha256 }}
+ CHANNEL_BUILD: ${{ needs.validate.outputs.channel-build }}
+ CHANNEL_REQUEST_SHA256: ${{ needs.validate.outputs.channel-request-sha256 }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GH_TOKEN: ${{ github.token }}
RELEASE_NEEDS: ${{ toJSON(needs) }}
@@ -1385,7 +1408,7 @@ jobs:
termux-deb:
name: Build + publish the termux .deb (aarch64)
needs: [validate, archive-inputs]
- if: inputs.channel_build == '' && (inputs.upload_release == true || inputs.release-phase == 'candidate' || inputs.build_commit != '')
+ if: inputs.channel_build == '' && inputs.disposable_channel == '' && (inputs.upload_release == true || inputs.release-phase == 'candidate' || inputs.build_commit != '')
runs-on: ubuntu-24.04-arm
environment: release-signing
timeout-minutes: 90
@@ -1799,7 +1822,7 @@ jobs:
name: Commit build summary (every binary, built or not)
needs: [validate, build-win32, build-darwin, build-linux, assemble-win32-bundle, smoke-darwin, smoke-win32, smoke-win32-universal, termux-deb]
if: |
- always() && inputs.build_commit != ''
+ always() && inputs.build_commit != '' && inputs.disposable_channel == ''
&& needs.validate.result == 'success' && needs.validate.outputs.sha != ''
runs-on: ubuntu-24.04
environment: release-signing
diff --git a/scripts/release.py b/scripts/release.py
index 9715a64822c..9eaef1a6447 100755
--- a/scripts/release.py
+++ b/scripts/release.py
@@ -2940,10 +2940,9 @@ def main():
"HEAD has no new commits since the last canary")
parser.add_argument("--build-commit", type=str, metavar="REV",
help="Preview an exact-commit build into releases/commit/<sha>/ on R2. "
- "Add --publish to dispatch without a tag or release. On a fork "
- "(any repository other than NousResearch/hermes-agent) this "
- "transparently dispatches a disposable channel allocation and "
- "prints the follow-up build command from its run.")
+ "Add --publish to dispatch without a tag or release. One dispatch: "
+ "on a fork (any repository other than NousResearch/hermes-agent) "
+ "the same run allocates a disposable channel and builds it.")
parser.add_argument("--bundle-env", action="append", default=[], metavar="NAME=VALUE",
help="Bake a non-secret environment default into a commit desktop bundle. "
"Repeat for multiple variables. Runtime environment values win.")
diff --git a/scripts/releases/channel_disposable.py b/scripts/releases/channel_disposable.py
index 6bcd1d77b5f..66418a93199 100644
--- a/scripts/releases/channel_disposable.py
+++ b/scripts/releases/channel_disposable.py
@@ -1,4 +1,4 @@
-"""Privileged allocation only: print a separate maintainer build dispatch."""
+"""Privileged allocation: probe CAS/CDN and allocate the channel this run builds."""
from __future__ import annotations
import hashlib
@@ -81,13 +81,14 @@ def allocate(env: dict[str, str]) -> dict:
name = validate_name(env.get("DISPOSABLE_CHANNEL", ""))
if name in {"ci-cas-probe", "stable", "canary", "main"}:
raise ValueError("Use a non-protected disposable preview name")
- if env.get("CHANNEL_BUILD") or env.get("CHANNEL_REQUEST_SHA256") or env.get("R2_DISPOSABLE_RUN"):
+ if env.get("CHANNEL_BUILD") or env.get("CHANNEL_REQUEST_SHA256"):
raise ValueError("Allocation cannot reuse a build request or select a storage scope")
if env.get("TERMUX_ONLY") == "true":
raise ValueError("Disposable allocation cannot select Termux")
- # A fresh attempt gets a fresh prefix, including controller reruns. Never
- # accept a caller-supplied path, public URL, or allocation namespace.
- run = require_run(env.get("GITHUB_RUN_ID", "") + "-" + env.get("GITHUB_RUN_ATTEMPT", ""))
+ # One dispatch now allocates AND builds, so the namespace must survive a
+ # "re-run failed jobs": lease by the run id alone (no attempt suffix), and
+ # never accept a caller-supplied path, public URL, or allocation namespace.
+ run = require_run(env.get("GITHUB_RUN_ID", ""))
admitted = commit_build.admit(env)
controller = commit_build.require_commit(env.get("GITHUB_SHA", ""))
os.environ["R2_DISPOSABLE_RUN"] = run
@@ -106,7 +107,7 @@ def allocate(env: dict[str, str]) -> dict:
publisher.create(name)
from scripts.releases.bundle_env import decode
request = publisher.allocate(name, admitted["sha"], admitted["payload-version"],
- decode(env.get("BUNDLE_ENV_JSON", "")), controller)
+ decode(env.get("BUNDLE_ENV_JSON", "")), controller)
requests = {"A": request}
if env.get("DISPOSABLE_RECEIVERS") == "true":
requests["B"] = publisher.allocate(name, admitted["sha"], admitted["payload-version"],
@@ -122,12 +123,24 @@ def allocate(env: dict[str, str]) -> dict:
def main() -> None:
result = allocate(dict(os.environ))
+ # Job outputs feed the build legs of THIS run (one dispatch). The summary
+ # stays informational; the printed commands are no longer required.
+ if os.environ.get("GITHUB_OUTPUT"):
+ with Path(os.environ["GITHUB_OUTPUT"]).open("a", encoding="utf-8") as stream:
+ stream.write("".join(f"{key}={value}\n" for key, value in {
+ "channel_build": result["request"]["buildId"],
+ "channel_request_sha256": result["requestSha256"],
+ "disposable_run": result["disposableRun"],
+ "public_base": channel_public_base(),
+ "storage_prefix": result["storagePrefix"],
+ }.items()))
summary = ("## Disposable channel allocation\n\n"
"CAS, stale-writer rejection, listing and public readback passed. "
"No native build or production record was published.\n\n"
f"Storage prefix: `{result['storagePrefix']}`\n\n"
- "Run this separately using your maintainer login; the controller token "
- "does not dispatch a publication run:\n\n" + "\n\n".join(
+ "This run's build legs consume the allocation through job outputs; "
+ "no separate follow-up dispatch is needed. The command below is "
+ "informational only:\n\n" + "\n\n".join(
f"### {slot}\n```sh\n{shlex.join(cmd)}\n```" for slot, cmd in result["commands"].items()) + "\n")
with Path(os.environ["GITHUB_STEP_SUMMARY"]).open("a", encoding="utf-8") as stream:
stream.write(summary)
diff --git a/scripts/releases/commit_build.py b/scripts/releases/commit_build.py
index 487cde0e022..931eb14bfcb 100644
--- a/scripts/releases/commit_build.py
+++ b/scripts/releases/commit_build.py
@@ -14,21 +14,10 @@ WORKFLOW = "desktop-bundled-release.yml"
# Direct commit-build dispatch is the upstream-only path: the workflow's
# admission step rejects any repository != NousResearch/hermes-agent that has
-# no disposable allocation (the fork CI guard). Forks must instead allocate a
-# disposable channel first; commit_build.cmd_build_commit routes them there.
+# no disposable allocation (the fork CI guard). Forks dispatch the same
+# workflow in disposable mode instead; cmd_build_commit selects the flags.
UPSTREAM_REPOSITORY = "NousResearch/hermes-agent"
-# The allocation workflow run is created by a server-side race we do not
-# observe; this bounds the wait for it to appear in `gh run list`.
-_ALLOCATION_APPEAR_TIMEOUT_S = 120
-# A disposable allocation is a single 10-minute-timeout GHA job (probes plus
-# R2 writes, no native build); the same budget covers queueing.
-_ALLOCATION_COMPLETE_TIMEOUT_S = 900
-_ALLOCATION_POLL_INTERVAL_S = 15
-# How recent a listed run's createdAt must be to count as ours without being
-# queued/running — generous enough for gh/GitHub clock skew.
-_RUN_RECENCY_WINDOW_S = 300
-
def require_commit(value: str) -> str:
if not isinstance(value, str) or not re.fullmatch(r"[a-f0-9]{40}", value):
@@ -111,12 +100,11 @@ def dispatch_command(commit: str, repository: str, branch: str,
def disposable_dispatch_command(commit: str, repository: str, branch: str,
bundle_env: dict[str, str | None] | None = None) -> list[str]:
- """Fork allocation dispatch: same workflow, disposable_channel inputs.
+ """Fork dispatch: same workflow, disposable_channel inputs.
- Bundle env travels here (not on the follow-up build dispatch): the
- allocation bakes it into the immutable request, so every value must be
- present at allocation time. The follow-up command pinned to that request
- must never re-pass bundle_env.
+ Bundle env travels here: the allocation bakes it into the immutable
+ request inside the same run that builds it, so every value must be
+ present at dispatch time.
"""
from scripts.releases.bundle_env import validate
@@ -141,144 +129,6 @@ def _allocation_channel_name(commit: str) -> str:
return f"commit-{commit[:12]}-{int(time.time())}"
-def _fork_allocation(repository: str, command: list[str], repo_root: Path) -> None:
- """Dispatch the allocation run on a fork, then dispatch its follow-up build.
-
- The lease lives in the fork's Actions run (release-signing secrets exist
- only there), so the allocation itself cannot run locally. But the
- follow-up dispatch CAN: it runs with the local maintainer's gh login —
- the same identity that dispatched the allocation — unlike the CI
- controller token, which deliberately never dispatches publication runs.
- One command therefore covers both steps; if the follow-up cannot be
- recovered from the run logs, fall back to pointing at the run summary.
- """
- run = subprocess.run(command, cwd=repo_root, capture_output=True, text=True, # windows-footgun: ok — encoding and replacement policy are on the next line.
- encoding="utf-8", errors="replace", check=True, timeout=60)
- print((run.stdout or "").strip() or f"Dispatched disposable allocation for {repository}.")
- run_id = _await_allocation_run(repository)
- _await_completion(repository, run_id)
- follow_up = _extract_follow_up(repository, run_id)
- if not _is_pinned_follow_up(follow_up, repository):
- print(f"Disposable allocation succeeded (run {run_id}), but the follow-up build "
- "command could not be recovered from the run logs. Copy it from the "
- f"allocation run summary — https://github.com/{repository}/actions/runs/{run_id} "
- "— and run it with your maintainer login.")
- return
- assert follow_up is not None
- print("Allocation complete; dispatching the pinned channel build.")
- print(f" {shlex.join(follow_up)}")
- result = subprocess.run(follow_up, cwd=repo_root, capture_output=True, text=True, # windows-footgun: ok — encoding and replacement policy are on the next line.
- encoding="utf-8", errors="replace", check=True, timeout=60)
- print((result.stdout or "").strip() or f"Dispatched channel build from allocation run {run_id}. No release was created.")
-
-
-def _is_pinned_follow_up(command: object, repository: str) -> bool:
- """Only ever execute a follow-up shaped exactly like our own dispatch.
-
- The command is parsed from CI logs, so refuse anything that is not a
- `gh workflow run` of this workflow against the same repository.
- """
- if not (isinstance(command, list) and len(command) > 6
- and command[:4] == ["gh", "workflow", "run", WORKFLOW] and "--repo" in command):
- return False
- index = command.index("--repo")
- return command[index + 1:index + 2] == [repository]
-
-
-def _await_allocation_run(repository: str) -> str:
- """Wait for the just-dispatched allocation run to appear and return its id.
-
- GitHub creates workflow_dispatch runs asynchronously, so the newest list
- entry right after dispatch may still be a prior run. Accept the newest
- entry once it is queued/running, or once it was created inside a recent
- window (allowing gh/GitHub clock skew); otherwise keep polling and fall
- back to the newest entry when the window closes.
- """
- list_command = ["gh", "run", "list", "--repo", repository,
- "--workflow", WORKFLOW, "--limit", "1",
- "--json", "databaseId,status,conclusion,createdAt"]
- recent_cutoff = _iso_utc_now_minus(_RUN_RECENCY_WINDOW_S)
- deadline = time.monotonic() + _ALLOCATION_APPEAR_TIMEOUT_S
- latest: dict = {}
- while time.monotonic() < deadline:
- result = subprocess.run(list_command, capture_output=True, text=True, # windows-footgun: ok — encoding and replacement policy are on the next line.
- encoding="utf-8", errors="replace", timeout=60)
- if result.returncode == 0:
- latest = (json.loads(result.stdout or "[]") or [{}])[0]
- if (latest.get("status") in {"queued", "in_progress"}
- or str(latest.get("createdAt", "")) >= recent_cutoff):
- return str(latest["databaseId"])
- time.sleep(_ALLOCATION_POLL_INTERVAL_S)
- if latest.get("databaseId"):
- # gh's server-side lag outran the window; the newest run we saw is
- # still the best candidate for the dispatch we just made.
- return str(latest["databaseId"])
- raise ValueError(f"No workflow run appeared for {repository} within "
- f"{_ALLOCATION_APPEAR_TIMEOUT_S} seconds")
-
-
-def _iso_utc_now_minus(seconds: int) -> str:
- """A UTC ISO-8601 timestamp `seconds` in the past, for string comparison
- against gh's `createdAt` values (both share the same format and zone)."""
- from datetime import datetime, timedelta, timezone
-
- return (datetime.now(timezone.utc) - timedelta(seconds=seconds)).isoformat()
-
-
-def _await_completion(repository: str, run_id: str) -> None:
- """Poll the allocation run until GitHub reports a terminal conclusion."""
- view_command = ["gh", "run", "view", run_id, "--repo", repository,
- "--json", "status,conclusion"]
- deadline = time.monotonic() + _ALLOCATION_COMPLETE_TIMEOUT_S
- while True:
- result = subprocess.run(view_command, capture_output=True, text=True, # windows-footgun: ok — encoding and replacement policy are on the next line.
- encoding="utf-8", errors="replace", timeout=60)
- if result.returncode != 0:
- raise ValueError(f"Could not read workflow run {run_id}: {(result.stderr or '').strip()}")
- status = (json.loads(result.stdout or "{}") or {})
- if status.get("status") == "completed":
- if status.get("conclusion") != "success":
- raise ValueError(f"Disposable allocation run {run_id} finished with "
- f"conclusion {status.get('conclusion')!r}; see "
- f"https://github.com/{repository}/actions/runs/{run_id}")
- return
- if time.monotonic() >= deadline:
- raise ValueError(f"Disposable allocation run {run_id} did not complete within "
- f"{_ALLOCATION_COMPLETE_TIMEOUT_S} seconds; see "
- f"https://github.com/{repository}/actions/runs/{run_id}")
- time.sleep(_ALLOCATION_POLL_INTERVAL_S)
-
-
-def _extract_follow_up(repository: str, run_id: str) -> list[str] | None:
- """Find the printed follow-up dispatch in the allocation run's logs.
-
- channel_disposable prints one single-line JSON object (sorted keys) whose
- "command" value is the exact argv list of the follow-up dispatch. gh --log
- prefixes each line with "job\\tstep\\ttimestamp ", so scan every line for
- a decodable JSON object carrying a "command" argv. Return the argv list,
- or None when the log line is unavailable.
- """
- result = subprocess.run(["gh", "run", "view", run_id, "--repo", repository, "--log"],
- capture_output=True, text=True, # windows-footgun: ok — encoding and replacement policy are on the next line.
- encoding="utf-8", errors="replace", timeout=120)
- if result.returncode != 0:
- return None
- decoder = json.JSONDecoder()
- for line in (result.stdout or "").splitlines():
- index = line.find("{")
- while index != -1:
- try:
- value, _ = decoder.raw_decode(line, index)
- except json.JSONDecodeError:
- index = line.find("{", index + 1)
- continue
- command = value.get("command") if isinstance(value, dict) else None
- if isinstance(command, list) and command and all(isinstance(part, str) for part in command):
- return command
- index = line.find("{", index + 1)
- return None
-
-
def cmd_build_commit(args) -> None:
from scripts import release
from scripts.releases import r2
@@ -301,19 +151,10 @@ def cmd_build_commit(args) -> None:
print(f"Building one-off bundle for commit {commit}")
print(f"Builds will be available at: {page}.")
if fork:
- # The disposable flow allocates the channel in the fork's Actions
- # run and prints the pinned follow-up dispatch there; bundle env
- # already travels inside the allocation request.
- print(f"Repository {repository} is not {UPSTREAM_REPOSITORY}; routing the "
- "commit build through a disposable channel allocation.")
- print(f"Allocation command, running from {repository}@{branch}")
- print(f" {shlex.join(command)}")
- if not args.publish:
- print("Dry run. Add --publish to dispatch.")
- return
- print("Starting disposable allocation workflow!")
- _fork_allocation(repository, command, release.REPO_ROOT)
- return
+ # One dispatch: the fork run allocates its disposable channel and
+ # builds it in the same run; bundle env travels in the allocation.
+ print(f"Repository {repository} is not {UPSTREAM_REPOSITORY}; dispatching "
+ "a disposable channel build.")
print(f"Workflow command, running from {repository}@{branch}")
print(f" {shlex.join(command)}")
if not args.publish:
diff --git a/scripts/releases/r2_scope.py b/scripts/releases/r2_scope.py
index 739c5d1c8dc..70f1bbab8ea 100644
--- a/scripts/releases/r2_scope.py
+++ b/scripts/releases/r2_scope.py
@@ -5,10 +5,16 @@ from dataclasses import dataclass
import os
import re
+# A lease is the workflow run id alone: "re-run failed jobs" must re-enter the
+# SAME namespace (succeeded jobs are skipped and their outputs persist). The
+# legacy <run-id>-<attempt> shape stays readable for allocations minted before
+# the one-dispatch collapse.
+_RUN_LEASE = r"[1-9][0-9]{0,19}(?:-[1-9][0-9]{0,5})?"
+
def require_run(value: str) -> str:
- if not isinstance(value, str) or not re.fullmatch(r"[1-9][0-9]{0,19}-[1-9][0-9]{0,5}", value):
- raise ValueError("Disposable R2 run must be <run-id>-<attempt>")
+ if not isinstance(value, str) or not re.fullmatch(_RUN_LEASE, value):
+ raise ValueError("Disposable R2 run must be <run-id> or legacy <run-id>-<attempt>")
return value
@@ -18,7 +24,7 @@ class R2Scope:
def __post_init__(self):
if self.prefix and not re.fullmatch(
- r"ci-disposable/[1-9][0-9]{0,19}/[1-9][0-9]{0,19}-[1-9][0-9]{0,5}/", self.prefix):
+ r"ci-disposable/[1-9][0-9]{0,19}/" + _RUN_LEASE + r"/", self.prefix):
raise ValueError("Invalid disposable R2 namespace")
@classmethod
diff --git a/tests/ci/test_channel_build_publication.py b/tests/ci/test_channel_build_publication.py
index ded2d82db0d..59d7773061a 100644
--- a/tests/ci/test_channel_build_publication.py
+++ b/tests/ci/test_channel_build_publication.py
@@ -387,14 +387,16 @@ def test_disposable_controller_allocates_then_separate_admission(tmp_path):
assert result.returncode == 0, result.stdout + result.stderr
allocation = json.loads(result.stdout)
request = allocation["request"]
- assert request["publicBase"] == url + "/bucket/ci-disposable/12345/98765-1"
- assert allocation["storagePrefix"] == "ci-disposable/12345/98765-1/"
- assert "disposable_run=98765-1" in allocation["command"]
+ assert request["publicBase"] == url + "/bucket/ci-disposable/12345/98765"
+ assert allocation["storagePrefix"] == "ci-disposable/12345/98765/"
+ assert "disposable_run=98765" in allocation["command"]
assert "channel_build=" + request["buildId"] in allocation["command"]
assert objects["releases/channels/stable.json"] == b"production sentinel"
assert all(key.startswith(allocation["storagePrefix"]) for method, key in requests if method == "PUT")
before = dict(objects)
- for change in ({"R2_DISPOSABLE_RUN": "98765-1"}, {"DISPOSABLE_CHANNEL": "stable"},
+ # One dispatch: a preset R2_DISPOSABLE_RUN no longer fails admission — the
+ # allocator derives and overwrites the lease from GITHUB_RUN_ID.
+ for change in ({"DISPOSABLE_CHANNEL": "stable"},
{"GITHUB_REF": "refs/heads/other"}, {"GITHUB_ACTOR": "", "GITHUB_TRIGGERING_ACTOR": ""}):
failed = run_shell(tmp_path, server, script, {**env, **change}, cwd=clone)
assert failed.returncode != 0
diff --git a/tests/ci/test_desktop_bundle_smoke.py b/tests/ci/test_desktop_bundle_smoke.py
index 597b3276b01..e597a5c6ade 100644
--- a/tests/ci/test_desktop_bundle_smoke.py
+++ b/tests/ci/test_desktop_bundle_smoke.py
@@ -155,11 +155,20 @@ def test_smoke_matrix_native_routes_and_driver_only_dependencies():
assert set(executions) == {(platform, arch, fmt) for arch in ('arm64', 'x64')
for platform, formats in [('darwin', ('dmg', 'zip')), ('win32', ('msix', 'msixbundle'))]
for fmt in formats}
- for job in workflow['jobs'].values():
+ for name, job in workflow['jobs'].items():
+ # validate is the admission job (rejects unsupported targets before any
+ # runner spawns, no checkout, no runner resources); every other job is a
+ # read-only smoke runner.
+ if name == 'validate':
+ continue
assert job['cache-mode'] == 'read' and 'environment' not in job
checkout = next(step for step in job['steps'] if 'actions/checkout@' in step.get('uses', ''))
assert checkout['with']['persist-credentials'] is False
- assert checkout['with']['ref'] == '${{ inputs.sha }}'
+ # A channel build smokes the trusted controller's checkout, not the
+ # admitted source — the runner fetches the pinned channel request itself.
+ assert checkout['with']['ref'] in (
+ '${{ inputs.sha }}',
+ "${{ inputs.channel-build != '' && inputs.controller-sha || inputs.sha }}")
recording = next(step for step in job['steps'] if step.get('id') == 'recording')
assert 'save-cache' not in recording['with']
upload = next(step for step in job['steps'] if 'actions/upload-artifact@' in step.get('uses', ''))
@@ -179,8 +188,10 @@ def test_smoke_matrix_native_routes_and_driver_only_dependencies():
workflows = [workflow] + [hermes_yaml.safe_load((ROOT / '.github/workflows' / name).read_text(encoding='utf-8-sig'))
for name in ('install-e2e-run.yml', 'install-e2e-macos-run.yml', 'install-e2e-windows-run.yml')]
for document in workflows:
- for job in document['jobs'].values():
- if 'steps' not in job:
+ for name, job in document['jobs'].items():
+ if 'steps' not in job or name == 'validate':
+ # the smoke workflow's validate job rejects unsupported targets
+ # with a bare case statement; it needs no toolchain setup.
continue
steps = job['steps']
setup = next(step for step in steps if step.get('uses') == './.github/actions/setup-pm')
diff --git a/tests/ci/test_desktop_release_tag_admission.py b/tests/ci/test_desktop_release_tag_admission.py
index a048fb3c3ad..bac97cb21f1 100644
--- a/tests/ci/test_desktop_release_tag_admission.py
+++ b/tests/ci/test_desktop_release_tag_admission.py
@@ -66,21 +66,25 @@ def test_signing_jobs_pin_source_and_controller_revisions_not_mutable_tags():
continue
ref = step.get("with", {}).get("ref")
expected = "${{ needs.validate.outputs.sha }}"
- if name in {"publish-channel", "allocate-disposable"} or step.get("if") == "inputs.channel_build != ''":
+ if name in {"publish-channel", "allocate-disposable"} or step.get("if") == "needs.validate.outputs.channel-build != ''":
expected = "${{ github.sha }}"
elif name == "validate":
expected = "${{ (inputs.build_commit != '' || inputs.channel_build != '') && github.sha || inputs.tag }}"
elif name == "assemble-win32-bundle":
- expected = "${{ inputs.channel_build != '' && github.sha || needs.validate.outputs.sha }}"
+ expected = "${{ needs.validate.outputs.channel-build != '' && github.sha || needs.validate.outputs.sha }}"
assert ref == expected, (
f"signing job {name!r} checks out {ref!r} — it must check out "
"the admitted source or explicitly selected trusted controller, never a mutable tag"
)
- # The admission and allocation controllers do not consume a prior admission.
+ # The allocation controller does not consume a prior admission; validate's
+ # only allowed need is this run's own allocation (the one-dispatch design).
for name, job in privileged.items():
- if name in {"validate", "allocate-disposable"}:
+ if name == "allocate-disposable":
assert not job.get("needs")
continue
+ if name == "validate":
+ assert job.get("needs") in ([], None, ["allocate-disposable"])
+ continue
needs = job.get("needs") or []
needs = [needs] if isinstance(needs, str) else needs
assert "validate" in needs, f"signing job {name!r} reads needs.validate.outputs.sha but does not need validate"
diff --git a/tests/scripts/test_release_build_commit.py b/tests/scripts/test_release_build_commit.py
index 62b7bd0836a..20c93479020 100644
--- a/tests/scripts/test_release_build_commit.py
+++ b/tests/scripts/test_release_build_commit.py
@@ -57,17 +57,6 @@ def run(argv, *args, **kwargs):
value = 'main\\n'
elif argv[1:3] == ['workflow', 'run']:
value = 'fixture dispatch accepted\\n'
- elif argv[1:3] == ['run', 'list']:
- value = json.dumps([{'databaseId': 777, 'status': 'queued', 'conclusion': '',
- 'createdAt': __import__('datetime').datetime.now(__import__('datetime').timezone.utc).isoformat()}]) + '\\n'
- elif argv[1:3] == ['run', 'view'] and '--log' in argv:
- if os.environ.get('PROBE_ALLOCATION_FAIL'):
- return subprocess.CompletedProcess(argv, 1, stdout='', stderr='fixture log unavailable')
- record = json.loads(os.environ.get('PROBE_ALLOCATION_LOG', '{}'))
- line = json.dumps(record, sort_keys=True) if record else ''
- value = 'allocate-disposable\\tProbe scoped storage\\t2026-09-14T00:00:00Z ' + line + '\\n'
- elif argv[1:3] == ['run', 'view']:
- value = json.dumps({'status': 'completed', 'conclusion': 'success'}) + '\\n'
elif argv[1] == 'api':
value = os.environ.get('PROBE_PERMISSION', 'write') + '\\n'
else:
@@ -170,42 +159,10 @@ def test_fork_commit_build_routes_through_disposable_allocation(fixture_repo):
assert not any(call[1:3] == ['workflow', 'run'] for call in calls)
assert 'disposable' in result.stdout.lower()
-def test_fork_allocation_polls_extracts_and_dispatches_followup(fixture_repo):
- repo, _, invoke = fixture_repo
- tip = git(repo, 'rev-parse', 'HEAD')
- follow_up = ['gh', 'workflow', 'run', 'desktop-bundled-release.yml', '--repo',
- 'fixture-owner/fixture-repo', '--ref', 'main', '-f', 'channel_build=' + 'a' * 32,
- '-f', 'channel_request_sha256=' + 'b' * 64, '-f', 'disposable_run=12345-1',
- '-f', 'tag=', '-f', 'upload_release=false', '-f', 'termux_only=false',
- '-f', 'termux_upgrade_from_tag=']
- result, calls = invoke('--build-commit', tip, '--publish',
- extra={'PROBE_ALLOCATION_LOG': json.dumps({'command': follow_up})})
- assert result.returncode == 0, result.stderr
- dispatches = [call for call in calls if call[1:3] == ['workflow', 'run']]
- assert len(dispatches) == 2
- assert 'disposable_channel=' in ' '.join(dispatches[0])
- # The extracted follow-up is dispatched verbatim: pinned build, digest and
- # disposable_run from the allocation, and no bundle_env re-passed.
- assert dispatches[1] == follow_up
- assert 'bundle_env=' not in ' '.join(dispatches[1])
- run_lists = [call for call in calls if call[1:3] == ['run', 'list']]
- assert run_lists and all('--repo' in call for call in run_lists)
- run_views = [call for call in calls if call[1:3] == ['run', 'view']]
- assert run_views and all(call[3] == '777' for call in run_views)
- assert 'channel_build=' in result.stdout
+# (One-dispatch redesign) The allocation poll/extract/auto-dispatch machinery these
+# two tests exercised was deleted: a fork commit build is now a SINGLE dispatch whose
+# run both allocates and builds. See test_fork_commit_build_routes_through_disposable_allocation.
-def test_fork_allocation_extraction_failure_prints_summary_pointer(fixture_repo):
- repo, _, invoke = fixture_repo
- tip = git(repo, 'rev-parse', 'HEAD')
- result, calls = invoke('--build-commit', tip, '--publish',
- extra={'PROBE_ALLOCATION_FAIL': '1'})
- # The allocation itself succeeded, so the command completes; the follow-up
- # must be surfaced via a clear pointer to the run summary.
- assert result.returncode == 0, result.stderr
- dispatches = [call for call in calls if call[1:3] == ['workflow', 'run']]
- assert len(dispatches) == 1 and 'disposable_channel=' in ' '.join(dispatches[0])
- assert 'actions/runs/777' in result.stdout
- assert 'Traceback' not in result.stderr
def test_commit_bundle_environment_is_literal_and_validated(fixture_repo):
repo, _, invoke = fixture_repo