The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Merge branch 'ethie/release-attempt-refs' into ethie/pm-clean
ethernet0384a24edc99
diff --cc .github/workflows/desktop-bundled-release.ymlindex 6adfc2e29d5,83302d57590..cdac24df738--- a/.github/workflows/desktop-bundled-release.yml+++ b/.github/workflows/desktop-bundled-release.yml@@@ -212,21 -242,6 +242,21 @@@ jobsfetch-depth: 0fetch-tags: true+ - name: Print the release.py command for this run+ env:+ TAG: ${{ inputs.tag }}+ BUILD_COMMIT: ${{ inputs.build_commit }}+ CHANNEL: ${{ inputs.channel }}+ DISPOSABLE_CHANNEL: ${{ inputs.disposable_channel }}+ DISPOSABLE_RECEIVERS: ${{ inputs.disposable_receivers }}+ RELEASE_PHASE: ${{ inputs.release-phase }}+ UPLOAD_RELEASE: ${{ inputs.upload_release }}- TERMUX_ONLY: ${{ inputs.termux_only }}++ JOBS: ${{ inputs.jobs }}+ TERMUX_UPGRADE_FROM_TAG: ${{ inputs.termux_upgrade_from_tag }}+ BUNDLE_ENV_JSON: ${{ inputs.bundle_env }}+ DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}+ run: python3 -m scripts.releases.dispatch_log+- name: Archive every pinned input# Runner Python is intentional: the toolchain's upstream may be gone.# Same checkout contract the standalone archive job had: the tag ref@@@ -1522,8 -1799,11 +1814,10 @@@timeout-minutes: 90env:HERMES_PAYLOAD_TAG: ${{ inputs.tag }}+ # Archive ref for the termux handoff: attempt ref for stable phases.+ HERMES_ARCHIVE_TAG: ${{ needs.validate.outputs.archive-tag }}HERMES_BUILD_COMMIT: ${{ inputs.build_commit != '' && needs.validate.outputs.channel-build == '' && needs.validate.outputs.sha || '' }}HERMES_RELEASE_COMMIT: ${{ inputs.release-phase != '' && needs.validate.outputs.sha || '' }}- HERMES_RELEASE_EPOCH: ${{ needs.validate.outputs.release-epoch }}# termux_build.sh gates on `gh release view <tag>` (refuse to build# before the release exists); gh needs GH_TOKEN or it errors out and# the gate misreads that as "release not found".diff --cc scripts/releases/dispatch_log.pyindex d9a245160aa,00000000000..8f34ce23ffbmode 100644,000000..100644--- a/scripts/releases/dispatch_log.py+++ b/scripts/releases/dispatch_log.py@@@ -1,171 -1,0 +1,186 @@@+"""Print the release.py command and receipt identity for this bundle run.++The print is a log. It must not fail the build, and it must not invent a+command the dispatcher does not send. A commit or channel run also gets a+post-build receipt tag. This step runs before that tag exists, so it prints+the tag shape and names the step that writes the real tag.+"""+from __future__ import annotations++import json+import shlex+from collections.abc import Mapping+++def _text(value: object) -> str:+ return value if isinstance(value, str) else ""+++def _flag(value: object) -> bool:+ return str(value).lower() == "true"+++def bundle_env(raw: object) -> dict[str, str | None]:+ """The dispatcher's own bundle-env object, or empty when it is absent."""+ text = _text(raw).strip()+ if not text or text == "{}":+ return {}+ from scripts.releases.bundle_env import decode++ return decode(text)++++def _all_jobs(raw: object) -> bool:++ """True when the dispatch builds every job group; a subset has no release.py replay.++++ An unreadable value is reported, not raised: this log must not fail the++ build, and the admission step that follows refuses the input.++ """++ from scripts.releases.job_groups import selects_all++++ try:++ return selects_all(raw if isinstance(raw, str) else None)++ except ValueError:++ return False+++++def describe(env: Mapping[str, str]) -> dict[str, object]:+ """Classify one workflow dispatch without reading git or the network."""+ tag = _text(env.get("TAG"))+ commit = _text(env.get("BUILD_COMMIT"))+ channel = _text(env.get("CHANNEL"))+ disposable = _text(env.get("DISPOSABLE_CHANNEL"))+ phase = _text(env.get("RELEASE_PHASE"))+ if channel or disposable:+ kind = "channel"+ elif commit:+ kind = "commit"+ elif phase == "candidate":+ kind = "stable-candidate"+ elif phase in {"publish", "promote"}:+ kind = "stable-" + phase+ elif "-canary." in tag:+ kind = "canary"+ elif tag:+ kind = "stable"+ else:+ kind = "unknown"+ return {+ "kind": kind,+ "repository": _text(env.get("GITHUB_REPOSITORY")),+ "ref": _text(env.get("GITHUB_REF")),+ "sha": _text(env.get("GITHUB_SHA")),+ "run_id": _text(env.get("GITHUB_RUN_ID")),+ "run_attempt": _text(env.get("GITHUB_RUN_ATTEMPT")),+ "actor": _text(env.get("GITHUB_ACTOR")),+ "tag": tag,+ "build_commit": commit,+ "channel": channel,+ "disposable_channel": disposable,+ "release_phase": phase,+ "upload_release": _flag(env.get("UPLOAD_RELEASE")),- "termux_only": _flag(env.get("TERMUX_ONLY")),++ "jobs": _text(env.get("JOBS")),++ "all_jobs": _all_jobs(env.get("JOBS")),+ "termux_upgrade_from_tag": _text(env.get("TERMUX_UPGRADE_FROM_TAG")),+ "disposable_receivers": _flag(env.get("DISPOSABLE_RECEIVERS")),+ "disposable_run": _text(env.get("R2_DISPOSABLE_RUN")),+ "bundle_env": bundle_env(env.get("BUNDLE_ENV_JSON")),+ }+++def release_command(env: Mapping[str, str]) -> list[str] | None:+ """The gh workflow command for a dispatch release.py can recreate.++ Stable and canary dispatches mint a tag before they start a workflow, so+ no release.py command recreates those runs. Return None for them.+ """+ facts = describe(env)+ repository = facts["repository"]+ branch = _text(env.get("DEFAULT_BRANCH"))+ if not repository or not branch or facts["kind"] not in {"commit", "channel"}:+ return None+ if facts["disposable_channel"] or facts["disposable_run"] or facts["disposable_receivers"]:+ return None- if facts["termux_only"] or facts["termux_upgrade_from_tag"] or facts["upload_release"]:++ if not facts["all_jobs"] or facts["termux_upgrade_from_tag"] or facts["upload_release"]:+ return None+ commit = facts["build_commit"]+ if not isinstance(commit, str) or not commit:+ return None+ baked = facts["bundle_env"]+ if not isinstance(baked, dict):+ return None+ if facts["kind"] == "channel":+ from scripts.releases.channel_build import dispatch_command++ return dispatch_command(str(facts["channel"]), commit, str(repository), branch, baked or None)+ from scripts.releases.commit_build import dispatch_command++ return dispatch_command(commit, str(repository), branch, baked or None)+++def receipt_shape(facts: Mapping[str, object]) -> str | None:+ """The post-build receipt tag shape for a commit or channel run.++ The real tag needs the run's creation time, which this step does not have.+ Show the shape from receipt_tag so the log and the publisher agree.+ """+ kind = facts["kind"]+ run_id = facts["run_id"]+ if kind not in {"commit", "channel"} or not isinstance(run_id, str) or not run_id:+ return None+ if facts["disposable_run"]:+ return None+ from scripts.releases.commit_build import receipt_tag++ return receipt_tag(str(kind), "0.0.0", "2000-01-01T00:00:00Z", run_id).replace(+ "v0.0.0", "v<version>", 1).replace("20000101T000000Z", "<run-created-utc>", 1)+++def report(env: Mapping[str, str]) -> str:+ """One log block: the mode, the replay command, the receipt, and the facts."""+ facts = describe(env)+ lines = [+ "::group::Bundle dispatch",+ "kind: " + str(facts["kind"]),+ ]+ command = release_command(env)+ if command is None:+ lines.append("release.py: this dispatch is not a release.py --build-commit run")+ else:+ lines.append("release.py: " + shlex.join(["python", "scripts/release.py", "--publish", "--remote", "<remote>", *command_flags(facts)]))+ lines.append("workflow: " + shlex.join(command))+ shape = receipt_shape(facts)+ if shape is None:+ lines.append("receipt: this dispatch writes no post-build receipt tag")+ else:+ lines.append("receipt: " + shape)+ lines.append("receipt writer: publish step, after the native jobs succeed")+ lines.append("facts: " + json.dumps(facts, sort_keys=True))+ lines.append("::endgroup::")+ return "\n".join(lines)+++def command_flags(facts: Mapping[str, object]) -> list[str]:+ """The release.py flags that name this dispatch, in dispatcher order."""+ flags = ["--build-commit", str(facts["build_commit"])]+ if facts["kind"] == "channel":+ flags += ["--channel", str(facts["channel"])]+ baked = facts["bundle_env"]+ if isinstance(baked, dict):+ for name in sorted(baked):+ value = baked[name]+ if value is None:+ flags += ["--bundle-unset", name]+ else:+ flags += ["--bundle-env", name + "=" + value]+ return flags+++def main() -> None:+ import os++ print(report(os.environ))+++if __name__ == "__main__":+ main()diff --cc scripts/render-builds-table.pyindex 868c83cccfb,0b6e2c7b44d..ab558e38fd5mode 100755,100644..100755--- a/scripts/render-builds-table.py+++ b/scripts/render-builds-table.pydiff --cc tests/ci/test_stable_release_graph.pyindex 2e4b146382a,c91f178a1b5..cfeeb30b27e--- a/tests/ci/test_stable_release_graph.py+++ b/tests/ci/test_stable_release_graph.py@@@ -68,21 -105,57 +105,57 @@@ def test_claim_custody_and_final_payloaassert call["claim-object"] == "${{ needs.admit.outputs.claim-object }}"desktop = workflow("desktop-bundled-release.yml")assert "release-epoch" in desktop["jobs"]["validate"]["outputs"]- assert desktop["jobs"]["termux-deb"]["env"]["HERMES_RELEASE_EPOCH"] == \- "${{ needs.validate.outputs.release-epoch }}"+ assert "HERMES_RELEASE_EPOCH" not in desktop["jobs"]["termux-deb"]["env"]+ # B3: each build group stages its own receipt before its smoke, and the+ # receipt URL and digest cross the call boundary as workflow outputs.+ assert "manifest-url" not in desktop["on"]["workflow_call"]["outputs"]+ assert "manifest-sha256" not in desktop["on"]["workflow_call"]["outputs"]+ receipts = {"darwin-arm64": "stage-receipt-darwin-arm64", "darwin-x64": "stage-receipt-darwin-x64",+ "win32-bundle": "assemble-win32-bundle"}+ for group, job in receipts.items():+ producer = desktop["jobs"][job]+ assert producer["outputs"]["receipt-url"] == "${{ steps.receipt.outputs.receipt-url }}"+ assert producer["outputs"]["receipt-sha256"] == "${{ steps.receipt.outputs.receipt-sha256 }}"+ for suffix, output in (("url", "receipt-url"), ("sha256", "receipt-sha256")):+ expected = "${{ jobs." + job + ".outputs." + output + " }}"+ assert desktop["on"]["workflow_call"]["outputs"][f"{group}-receipt-{suffix}"]["value"] == expected+ for name in ("smoke-darwin-arm64", "smoke-darwin-x64"):+ assert f"stage-receipt-{name.removeprefix('smoke-')}" in desktop["jobs"][name]["needs"]+ for call, key, output in (("candidates-darwin-arm64", "RECEIPT_URL", "darwin-arm64-receipt-url"),+ ("candidates-darwin-arm64", "RECEIPT_SHA256", "darwin-arm64-receipt-sha256"),+ ("candidates-darwin-x64", "RECEIPT_URL", "darwin-x64-receipt-url"),+ ("candidates-darwin-x64", "RECEIPT_SHA256", "darwin-x64-receipt-sha256"),+ ("candidates-win32-bundle", "RECEIPT_URL", "win32-bundle-receipt-url"),+ ("candidates-win32-bundle", "RECEIPT_SHA256", "win32-bundle-receipt-sha256")):+ receipt_job = {"candidates-darwin-arm64": "transitions-darwin-arm64",+ "candidates-darwin-x64": "transitions-darwin-x64",+ "candidates-win32-bundle": "transitions-win32"}[call]+ expected = "${{ needs." + call + ".outputs." + output + " }}"+ assert jobs[receipt_job]["steps"][-1]["env"][key] == expected- for name in ("docker", "nix", "pm-bundle"):+ for name in ("docker", "nix"):assert jobs[name]["with"]["version"] == "${{ needs.admit.outputs.version }}"- for name in ("docker", "nix", "pm-bundle"):- assert jobs[name]["with"]["release-epoch"] == "${{ needs.admit.outputs.release-epoch }}"- assert jobs["publish-docker"]["with"]["release-epoch"] == \- "${{ needs.admit.outputs.release-epoch }}"+ assert "version" not in jobs["pm-bundle"]["with"]+ assert "release-epoch" not in jobs["docker"]["with"]+ assert "release-epoch" not in jobs["nix"]["with"]+ assert "release-epoch" not in jobs["pm-bundle"]["with"]+ assert "release-epoch" not in jobs["publish-docker"]["with"]complete = jobs["complete"]["steps"]- final = next(i for i, step in enumerate(complete) if step.get("name", "").startswith("Create the final tag"))- assert complete[final]["env"]["DOCKER_MANIFEST_DIGEST"] == \- "${{ needs.publish-docker.outputs.manifest-digest }}"+ # A6: the green workflow validates the accepted candidate archive; the+ # final tag and the retarget move to the publication pass.+ validation = next(i for i, step in enumerate(complete)+ if step.get("name", "").startswith("Validate the accepted candidate archive"))+ assert "DOCKER_MANIFEST_DIGEST" not in complete[validation]["env"]+ assert "RELEASE_ID" not in complete[validation]["env"]+ # B4: complete and the render read the manifest that stable-release.yml's+ # candidate-manifest job wrote.+ assert complete[validation]["env"]["CANDIDATE_MANIFEST_SHA256"] == \+ "${{ needs.candidate-manifest.outputs.manifest-sha256 }}"+ assert jobs["publish-bundles"]["with"]["manifest-sha256"] == \+ "${{ needs.candidate-manifest.outputs.manifest-sha256 }}"render = next(i for i, step in enumerate(complete) if step.get("name", "").startswith("Render the admitted"))reconcile = next(i for i, step in enumerate(complete) if step.get("name", "").startswith("Reconcile ordered"))- assert final < render < reconcile+ assert validation < render < reconcile+ assert not any("Create the final tag" in step.get("name", "") for step in complete)def test_docker_dev_stamp_checkout_has_release_history():diff --cc tests/scripts/test_dispatch_log.pyindex 42ac8a52c34,00000000000..a0e570c9b14mode 100644,000000..100644--- a/tests/scripts/test_dispatch_log.py+++ b/tests/scripts/test_dispatch_log.py@@@ -1,119 -1,0 +1,129 @@@+"""The pre-build log must name the release.py command that started the run."""+import json+import shlex++import pytest++from scripts.releases import dispatch_log+from scripts.releases.bundle_env import parse_assignments+from scripts.releases.channel_build import dispatch_command as channel_dispatch+from scripts.releases.commit_build import dispatch_command as commit_dispatch++from scripts.releases.job_groups import ALL_JOBS+from tests.ci.test_desktop_release_tag_admission import _workflow++SHA = "a" * 40+REPOSITORY = "fixture-owner/fixture-repo"+BRANCH = "main"+++def env(**values):+ base = {+ "GITHUB_REPOSITORY": REPOSITORY,+ "GITHUB_REF": "refs/heads/" + BRANCH,+ "GITHUB_SHA": SHA,+ "GITHUB_RUN_ID": "35629258153",+ "GITHUB_RUN_ATTEMPT": "1",+ "GITHUB_ACTOR": "ethernet8023",+ "DEFAULT_BRANCH": BRANCH,+ "TAG": "",+ "BUILD_COMMIT": "",+ "CHANNEL": "",+ "DISPOSABLE_CHANNEL": "",+ "DISPOSABLE_RECEIVERS": "false",+ "RELEASE_PHASE": "",+ "UPLOAD_RELEASE": "false",- "TERMUX_ONLY": "false",++ "JOBS": ALL_JOBS,+ "TERMUX_UPGRADE_FROM_TAG": "",+ "BUNDLE_ENV_JSON": "{}",+ "R2_DISPOSABLE_RUN": "",+ }+ base.update(values)+ return base+++def test_pre_build_setup_prints_the_dispatch_before_any_other_work():+ steps = _workflow()["jobs"]["validate"]["steps"]+ printed = steps[1]+ assert printed["name"] == "Print the release.py command for this run"+ assert printed["run"] == "python3 -m scripts.releases.dispatch_log"+ assert "if" not in printed+ forwarded = {key: value for key, value in printed["env"].items()}+ assert forwarded["BUILD_COMMIT"] == "${{ inputs.build_commit }}"+ assert forwarded["CHANNEL"] == "${{ inputs.channel }}"+ assert forwarded["BUNDLE_ENV_JSON"] == "${{ inputs.bundle_env }}"++ assert forwarded["JOBS"] == "${{ inputs.jobs }}"+ assert forwarded["DEFAULT_BRANCH"] == "${{ github.event.repository.default_branch }}"+ assert "GITHUB_TOKEN" not in forwarded and "GH_TOKEN" not in forwarded++[email protected]("kind,extra", [+ ("commit", {}),+ ("channel", {"CHANNEL": "magic-test"}),+ ("commit", {"BUNDLE_ENV_JSON": json.dumps({"HERMES_SKIP_INTRO": "1", "HERMES_HOME": None})}),+])+def test_printed_command_is_the_dispatcher_command(kind, extra):+ values = env(BUILD_COMMIT=SHA, **extra)+ baked = json.loads(values["BUNDLE_ENV_JSON"])+ if kind == "channel":+ expected = channel_dispatch(values["CHANNEL"], SHA, REPOSITORY, BRANCH, baked or None)+ else:+ expected = commit_dispatch(SHA, REPOSITORY, BRANCH, baked or None)+ text = dispatch_log.report(values)+ assert "kind: " + kind in text+ assert "workflow: " + shlex.join(expected) in text+ flags = dispatch_log.command_flags(dispatch_log.describe(values))+ assert "release.py: " + shlex.join(["python", "scripts/release.py", "--publish", "--remote", "<remote>", *flags]) in text+ assert "receipt: v<version>+" + kind + ".<run-created-utc>.35629258153" in text+ facts = json.loads(text.split("facts: ", 1)[1].splitlines()[0])+ assert facts["run_id"] == "35629258153"+ assert facts["bundle_env"] == baked++[email protected]("override", [+ {"TAG": "v0.1.0-canary.20260921120000", "UPLOAD_RELEASE": "true"},+ {"TAG": "v0.1.0", "RELEASE_PHASE": "candidate"},+ {"TAG": "v0.1.0", "RELEASE_PHASE": "publish"},+ {"DISPOSABLE_CHANNEL": "probe", "BUILD_COMMIT": SHA, "R2_DISPOSABLE_RUN": "99"},+])+def test_unrecreatable_dispatches_name_the_kind_and_no_command(override):+ text = dispatch_log.report(env(**override))+ assert "release.py: this dispatch is not a release.py --build-commit run" in text+ assert "workflow: " not in text+ assert "receipt: this dispatch writes no post-build receipt tag" in text+ assert "kind: unknown" not in text++- def test_termux_only_commit_has_a_receipt_but_no_release_command():- text = dispatch_log.report(env(BUILD_COMMIT=SHA, TERMUX_ONLY="true"))[email protected]("jobs", ["termux", "darwin-arm64,win32-x64"])++def test_a_partial_jobs_commit_has_a_receipt_but_no_release_command(jobs):++ text = dispatch_log.report(env(BUILD_COMMIT=SHA, JOBS=jobs))+ assert "release.py: this dispatch is not a release.py --build-commit run" in text+ assert "receipt: v<version>+commit.<run-created-utc>.35629258153" in text++++def test_an_unreadable_jobs_value_is_reported_not_raised():++ # The log must not fail the build; admission refuses the input next.++ text = dispatch_log.report(env(BUILD_COMMIT=SHA, JOBS="mac,mac"))++ assert "release.py: this dispatch is not a release.py --build-commit run" in text++ assert '"jobs": "mac,mac"' in text+++++def test_report_omits_values_the_workflow_did_not_forward(monkeypatch):+ monkeypatch.setenv("CLOUDFLARE_R2_SECRET_ACCESS_KEY", "secret-value")+ text = dispatch_log.report(env(BUILD_COMMIT=SHA))+ assert "secret-value" not in text+++def test_module_prints_the_report_from_the_process_environment(monkeypatch, capsys):+ for key, value in env(BUILD_COMMIT=SHA, CHANNEL="magic-test").items():+ monkeypatch.setenv(key, value)+ dispatch_log.main()+ text = capsys.readouterr().out+ assert "kind: channel" in text+ assert "gh workflow run desktop-bundled-release.yml" in text+++def test_bundle_env_round_trips_the_cli_flags():+ baked = parse_assignments(["HERMES_SKIP_INTRO=1"], ["HERMES_HOME"])+ facts = dispatch_log.describe(env(BUILD_COMMIT=SHA, BUNDLE_ENV_JSON=json.dumps(baked)))+ flags = dispatch_log.command_flags(facts)+ assert flags == ["--build-commit", SHA, "--bundle-unset", "HERMES_HOME", "--bundle-env", "HERMES_SKIP_INTRO=1"]