The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(release): --branding stable builds a channel commit as the regular app
ethernet13dbe260aa18
diff --git a/.github/workflows/desktop-bundled-release.yml b/.github/workflows/desktop-bundled-release.ymlindex 089e386ed76..f00737516e7 100644--- a/.github/workflows/desktop-bundled-release.yml+++ b/.github/workflows/desktop-bundled-release.yml@@ -149,6 +149,12 @@ on:required: falsetype: stringdefault: ''+ branding:+ description: 'Channel app name, icon and package ID: preview (own app) or stable (the regular Hermes app). Fixed when the channel is first created.'+ required: false+ type: choice+ options: [preview, stable]+ default: previewbuild_commit:description: 'Commit-only build: EXACT full 40-hex SHA already pushed to this repo (workflow_dispatch from the default branch only). Mutually exclusive with tag.'required: false@@ -256,6 +262,7 @@ jobs:TAG: ${{ inputs.tag }}BUILD_COMMIT: ${{ inputs.build_commit }}CHANNEL: ${{ inputs.channel }}+ BRANDING: ${{ inputs.branding }}DISPOSABLE_CHANNEL: ${{ inputs.disposable_channel }}DISPOSABLE_RECEIVERS: ${{ inputs.disposable_receivers }}RELEASE_PHASE: ${{ inputs.release-phase }}@@ -291,6 +298,7 @@ jobs:env:DISPOSABLE_CHANNEL: ${{ inputs.disposable_channel }}CHANNEL: ${{ inputs.channel }}+ BRANDING: ${{ inputs.branding }}DISPOSABLE_RECEIVERS: ${{ inputs.disposable_receivers }}BUILD_COMMIT: ${{ inputs.build_commit }}TAG: ${{ inputs.tag }}diff --git a/scripts/releases/channel_build.py b/scripts/releases/channel_build.pyindex 69445a59686..6319691f8e8 100644--- a/scripts/releases/channel_build.py+++ b/scripts/releases/channel_build.py@@ -20,13 +20,20 @@ from hermes_cli.release_channels import ()from scripts.releases import commit_build, r2from scripts.releases.bundle_env import parse_assignments, validate-from scripts.releases.channels import ChannelPublisher, R2ChannelStore+from scripts.releases.channels import BRANDINGS, ChannelPublisher, R2ChannelStoredef dispatch_command(- name: str, commit: str, repository: str, branch: str, bundle_env: dict | None = None+ name: str,+ commit: str,+ repository: str,+ branch: str,+ bundle_env: dict | None = None,+ branding: str = "preview",) -> list[str]:validate_name(name)+ if branding not in BRANDINGS:+ raise ChannelError(f"Unknown channel branding: {branding}")validate_repository(repository)commit_build.require_commit(commit)if not branch or branch.startswith("-"):@@ -53,6 +60,8 @@ def dispatch_command(]if bundle_env:command += ["-f", "bundle_env=" + json.dumps(bundle_env, sort_keys=True)]+ if branding != "preview":+ command += ["-f", "branding=" + branding]return command@@ -67,6 +76,7 @@ def prepare_build(dispatch,bundle_env: dict | None = None,publish: bool = False,+ branding: str = "preview",) -> dict:validate_name(name)validate_repository(repository)@@ -75,9 +85,10 @@ def prepare_build(version = commit_build.version_at(repo, commit)if not default_branch or default_branch.startswith("-"):raise ChannelError("Missing repository default branch")- command = dispatch_command(name, commit, repository, default_branch, bundle_env)+ command = dispatch_command(name, commit, repository, default_branch, bundle_env, branding)result = {"channel": name,+ "branding": branding,"repository": repository,"commit": commit,"sourceVersion": version,@@ -173,6 +184,7 @@ def cmd_channel(args) -> None:),bundle_env=bundle_env,publish=args.publish,+ branding=args.branding,)print(json.dumps(result, sort_keys=True, indent=2))if not args.publish:@@ -236,6 +248,14 @@ def add_arguments(parser) -> None:action="store_true",help="Set HERMES_HOME et al to a directory specific for this channel",)+ parser.add_argument(+ "--branding",+ choices=BRANDINGS,+ default="preview",+ help="App name, icon and package ID for --channel: 'stable' installs as the "+ "regular Hermes app (fixed when the channel is created), 'preview' as "+ "its own side-by-side app",+ )parser.add_argument("--channels", action="store_true", help="List authenticated R2 channel records")@@ -268,6 +288,8 @@ def validate_arguments(parser, args) -> bool:if getattr(args, key)]retirement = (args.to, args.minimum_version)+ if args.branding != "preview" and not args.channel:+ parser.error("--branding requires --channel")if any(retirement) and not args.retire_channel:parser.error("Retirement options require --retire-channel")if len(selected) > 1:diff --git a/scripts/releases/channel_disposable.py b/scripts/releases/channel_disposable.pyindex 92ebb4ccabb..ed14fe3a6ce 100644--- a/scripts/releases/channel_disposable.py+++ b/scripts/releases/channel_disposable.py@@ -90,6 +90,9 @@ def allocate(env: dict[str, str]) -> dict:if disposable_name and channel_name:raise ValueError("Choose disposable_channel or channel, not both")disposable = bool(disposable_name)+ branding = env.get("BRANDING") or "preview"+ if disposable and branding != "preview":+ raise ValueError("Disposable namespaces have no published stable identity to copy")name = validate_name(disposable_name or channel_name)if disposable:if name in {"ci-cas-probe", "stable", "canary", "main"}:@@ -119,7 +122,7 @@ def allocate(env: dict[str, str]) -> dict:base, authorize=authorize)if disposable:probe(publisher, admitted["sha"], admitted["payload-version"], controller)- publisher.create(name)+ publisher.create(name, branding)from scripts.releases.bundle_env import decoderequest = publisher.allocate(name, admitted["sha"], admitted["payload-version"],decode(env.get("BUNDLE_ENV_JSON", "")), controller)diff --git a/scripts/releases/channels.py b/scripts/releases/channels.pyindex 736dcd3ebd4..17c2a46e782 100644--- a/scripts/releases/channels.py+++ b/scripts/releases/channels.py@@ -15,6 +15,9 @@ from hermes_cli.release_channels import (from scripts.releases import r2+BRANDINGS = ("preview", "stable")++class ChannelConflict(ChannelError):pass@@ -138,27 +141,53 @@ class ChannelPublisher:raise ChannelError("Retired channel is permanently closed to publication")self.authorize(action, record)- def create(self, name: str) -> dict:+ def _stable_identity(self) -> dict:+ """The identity installed stable clients already carry, read from its channel record."""+ current = self._read("stable")+ if current is None or current[0]["head"] is None:+ raise ChannelError("Stable branding copies the published stable channel identity; none is published")+ return deepcopy(current[0]["identity"])++ def _require_branding(self, record: dict, branding: str) -> None:+ # Identity is fixed when the channel is created, so a mismatch means a+ # different channel name, never a silent rebrand of installed clients.+ identity = record["identity"]+ if branding == "stable":+ matches = identity == self._stable_identity()+ else:+ matches = identity == preview_identity(record["name"], identity["token"])+ if not matches:+ raise ChannelError(f"Channel {record['name']} was created with different branding; "+ "pick a new channel name or pass its original --branding")++ def create(self, name: str, branding: str = "preview") -> dict:validate_name(name)+ if branding not in BRANDINGS:+ raise ChannelError(f"Unknown channel branding: {branding}")existing = self._read(name)if existing:self._preview("create", existing[0])+ self._require_branding(existing[0], branding)return existing[0]record = {"schema": 1, "name": name, "repository": self.repository,"policy": "preview", "state": "active", "revision": 1,"nextSequence": 1, "head": None}self.authorize("create", record)- for _ in range(16):- token = secrets.token_hex(8)- try:- self.store.put(f"releases/channel-identities/{token}.json",- canonical_json({"schema": 1, "repository": self.repository, "channel": name}))- record["identity"] = preview_identity(name, token)- break- except ChannelConflict:- continue+ if branding == "stable":+ # Shares the stable app's name, icon and package ID, so no token is reserved.+ record["identity"] = self._stable_identity()else:- raise ChannelConflict("Could not reserve a channel identity")+ for _ in range(16):+ token = secrets.token_hex(8)+ try:+ self.store.put(f"releases/channel-identities/{token}.json",+ canonical_json({"schema": 1, "repository": self.repository, "channel": name}))+ record["identity"] = preview_identity(name, token)+ break+ except ChannelConflict:+ continue+ else:+ raise ChannelConflict("Could not reserve a channel identity")validate_record(record)try:self._write(channel_key(name), record)@@ -167,6 +196,7 @@ class ChannelPublisher:if winner is None:raiseself._preview("create", winner[0])+ self._require_branding(winner[0], branding)return winner[0]return recorddiff --git a/scripts/releases/dispatch_log.py b/scripts/releases/dispatch_log.pyindex 8f34ce23ffb..14f32180775 100644--- a/scripts/releases/dispatch_log.py+++ b/scripts/releases/dispatch_log.py@@ -85,6 +85,7 @@ def describe(env: Mapping[str, str]) -> dict[str, object]:"disposable_receivers": _flag(env.get("DISPOSABLE_RECEIVERS")),"disposable_run": _text(env.get("R2_DISPOSABLE_RUN")),"bundle_env": bundle_env(env.get("BUNDLE_ENV_JSON")),+ "branding": _text(env.get("BRANDING")) or "preview",}@@ -112,7 +113,8 @@ def release_command(env: Mapping[str, str]) -> list[str] | 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)+ return dispatch_command(str(facts["channel"]), commit, str(repository), branch, baked or None,+ str(facts["branding"]))from scripts.releases.commit_build import dispatch_commandreturn dispatch_command(commit, str(repository), branch, baked or None)@@ -165,6 +167,8 @@ def command_flags(facts: Mapping[str, object]) -> list[str]:flags = ["--build-commit", str(facts["build_commit"])]if facts["kind"] == "channel":flags += ["--channel", str(facts["channel"])]+ if facts["branding"] != "preview":+ flags += ["--branding", str(facts["branding"])]baked = facts["bundle_env"]if isinstance(baked, dict):for name in sorted(baked):diff --git a/tests/scripts/test_dispatch_log.py b/tests/scripts/test_dispatch_log.pyindex a0e570c9b14..232d0e725e7 100644--- a/tests/scripts/test_dispatch_log.py+++ b/tests/scripts/test_dispatch_log.py@@ -59,13 +59,15 @@ def test_pre_build_setup_prints_the_dispatch_before_any_other_work():@pytest.mark.parametrize("kind,extra", [("commit", {}),("channel", {"CHANNEL": "magic-test"}),+ ("channel", {"CHANNEL": "magic-test", "BRANDING": "stable"}),("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)+ expected = channel_dispatch(values["CHANNEL"], SHA, REPOSITORY, BRANCH, baked or None,+ values.get("BRANDING", "preview"))else:expected = commit_dispatch(SHA, REPOSITORY, BRANCH, baked or None)text = dispatch_log.report(values)@@ -73,6 +75,7 @@ def test_printed_command_is_the_dispatcher_command(kind, extra):assert "workflow: " + shlex.join(expected) in textflags = dispatch_log.command_flags(dispatch_log.describe(values))assert "release.py: " + shlex.join(["python", "scripts/release.py", "--publish", "--remote", "<remote>", *flags]) in text+ assert ("--branding stable" in text) == (values.get("BRANDING") == "stable")assert "receipt: v<version>+" + kind + ".<run-created-utc>.35629258153" in textfacts = json.loads(text.split("facts: ", 1)[1].splitlines()[0])assert facts["run_id"] == "35629258153"diff --git a/tests/scripts/test_release_channel_build.py b/tests/scripts/test_release_channel_build.pyindex c3ce99e8034..3d1f9bdfebf 100644--- a/tests/scripts/test_release_channel_build.py+++ b/tests/scripts/test_release_channel_build.py@@ -42,6 +42,9 @@ def test_dispatch_names_channel_and_binds_to_pushed_source(source):assert "build_commit=" + dry["commit"] in commandassert any(value.startswith("bundle_env=") for value in command)assert "--ref" in command and command[command.index("--ref") + 1] == "main"+ assert not any(value.startswith("branding=") for value in command)+ stable = prepare_build(**options, branding="stable")+ assert "branding=stable" in stable["command"] and stable["branding"] == "stable"admitted = prepare_build(**options, publish=True)assert calls == [command]assert admitted["commit"] == dry["commit"]@@ -104,4 +107,11 @@ def test_release_parser_preserves_plain_oneoff_dispatch(monkeypatch):monkeypatch.setattr(sys, "argv", ["release.py", "--channels", "--bundle-env", "X=y"])with pytest.raises(SystemExit) as incompatible:release.main()- assert incompatible.value.code == 2\ No newline at end of file+ assert incompatible.value.code == 2+ monkeypatch.setattr(sys, "argv", ["release.py", "--branding", "stable", "--build-commit", "main"])+ with pytest.raises(SystemExit) as orphan:+ release.main()+ assert orphan.value.code == 2+ monkeypatch.setattr(sys, "argv", ["release.py", "--channel", "unknown-name", "--branding", "stable", "--build-commit", "main"])+ release.main()+ assert calls[-1] == ("channel", "unknown-name")diff --git a/tests/scripts/test_release_channels.py b/tests/scripts/test_release_channels.pyindex 1d806562717..6e7a3b170ad 100644--- a/tests/scripts/test_release_channels.py+++ b/tests/scripts/test_release_channels.py@@ -120,6 +120,31 @@ def test_unknown_channel_created_over_http_retains_identity_and_immutable_requesassert "immutable" in headers[f"releases/channel-builds/{one['buildId']}/request.json"]["Cache-Control"]+def test_stable_branded_channel_reuses_the_published_stable_identity():+ """--branding stable is fixed at creation and needs an actual published stable to copy."""+ from hermes_cli.release_channels import ChannelError, canonical_json+ with object_server() as (url, objects, headers, requests, faults):+ pub = publisher(url)+ with pytest.raises(ChannelError, match="none is published"):+ pub.create("like-stable", "stable")+ stable = pub.create("stable")+ stable.update(policy="stable-release", nextSequence=2, head={+ "buildId": "e" * 32, "sequence": 1, "sha256": "0" * 64,+ "manifestKey": "releases/channel-builds/" + "e" * 32 + "/build.json"})+ objects["releases/channels/stable.json"] = canonical_json(stable)+ reserved = [key for key in objects if key.startswith("releases/channel-identities/")]+ branded = pub.create("like-stable", "stable")+ assert branded["identity"] == stable["identity"]+ assert pub.allocate("like-stable", "a" * 40, "1.2.3")["identity"] == stable["identity"]+ assert [key for key in objects if key.startswith("releases/channel-identities/")] == reserved+ assert pub.create("like-stable", "stable")["identity"] == stable["identity"]+ with pytest.raises(ChannelError, match="different branding"):+ pub.create("like-stable")+ pub.create("own-app")+ with pytest.raises(ChannelError, match="different branding"):+ pub.create("own-app", "stable")++def put_build(objects, request):from hermes_cli.release_channels import build_prefix, canonical_jsonprefix = build_prefix(request["buildId"])diff --git a/website/docs/developer-guide/stable-releases.md b/website/docs/developer-guide/stable-releases.mdindex 5dc64abc7ac..34866edb5dd 100644--- a/website/docs/developer-guide/stable-releases.md+++ b/website/docs/developer-guide/stable-releases.md@@ -352,6 +352,19 @@ python scripts/release.py --channel pm-preview --build-commit my-branch --remotepython scripts/release.py --channels --remote origin```+By default a preview channel installs as its own side-by-side app (`Hermes+NAME`, its own package ID). To test an exact commit as the regular app instead,+create the channel with `--branding stable`: it copies the published stable+channel's name, icon and package ID, so the build installs over the official+app and later updates follow the channel. Branding is fixed when the channel is+created; repeat the flag on every dispatch of that channel and use a new channel+name to change it. `--branding` needs `--channel`, since a plain one-off commit+build always carries its `Hermes Agent <sha>` identity.++```sh+python scripts/release.py --channel my-commit --branding stable --build-commit SHA --remote origin --publish+```+Disposable R2 scoping is opt-in, for test runs only. Dispatch the desktopworkflow with `disposable_channel` and `build_commit` to allocate a namespaceunder `ci-disposable/<repository-id>/<run-id>/`, then use the exact scoped build