The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(release): pin receiver kind into retired channel records (round 3 slice 1)
ethernet59b7b9bce61d
diff --git a/apps/desktop/electron/updater/channel-protocol.ts b/apps/desktop/electron/updater/channel-protocol.tsindex 236429a8f8c..c2d5eb5c550 100644--- a/apps/desktop/electron/updater/channel-protocol.ts+++ b/apps/desktop/electron/updater/channel-protocol.ts@@ -46,12 +46,14 @@ interface ChannelRecordBase {head: ChannelHead | null}export interface ActiveChannel extends ChannelRecordBase { state: 'active' }+export type ReceiverKind = 'in-place' | 'discontinued'export interface RetiredChannel extends ChannelRecordBase {state: 'retired'destination: stringminimumVersion: stringdestinationHead: ChannelHeadreceiverProtocol: 1+ receiver: { kind: ReceiverKind }lastHead: ChannelHead | null}export type ChannelRecord = ActiveChannel | RetiredChannel@@ -206,10 +208,14 @@ export function decodeChannelRecord(body: string): ChannelRecord {const lastHead = head(fields.get('lastHead'))if (JSON.stringify(lastHead) !== JSON.stringify(common.head)) { throw new Error('Retirement lastHead mismatch') }if (fields.get('receiverProtocol') !== 1) { throw new Error('Unsupported retirement receiver protocol') }+ const receiverFields = fields.object('receiver')+ const kind = receiverFields.text('kind')+ if (kind !== 'in-place' && kind !== 'discontinued') { throw new Error('Invalid retirement receiver kind') }return {...common, state, lastHead, destination: validateChannelName(fields.text('destination')),minimumVersion: fields.text('minimumVersion', VERSION),- destinationHead: requiredHead(fields.get('destinationHead')), receiverProtocol: 1+ destinationHead: requiredHead(fields.get('destinationHead')), receiverProtocol: 1,+ receiver: { kind }}}diff --git a/apps/desktop/electron/updater/channel.test.ts b/apps/desktop/electron/updater/channel.test.tsindex 7a1b1ac673c..1df56bbf13f 100644--- a/apps/desktop/electron/updater/channel.test.ts+++ b/apps/desktop/electron/updater/channel.test.ts@@ -7,6 +7,7 @@ import feedContract from '../../update-feed.cjs'import { ChannelResolver } from './channel'import type { ChannelBuild, ChannelManifest, ChannelRecord, RetiredChannel } from './channel-protocol'+import { decodeChannelRecord, sameChannelIdentity } from './channel-protocol'import { ChannelStrategy } from './channel-strategy'import type { RetirementConsent } from './retirement-state'@@ -100,13 +101,34 @@ async function retiredFixture(): Promise<Awaited<ReturnType<typeof fixture>> & {if (!f.record.head) { throw new Error('Expected published stable') }const retired: RetiredChannel = {...sourceRecord, state: 'retired', destination: 'stable', minimumVersion: '1.0.0',- destinationHead: structuredClone(f.record.head), receiverProtocol: 1, lastHead: sourceRecord.head+ destinationHead: structuredClone(f.record.head), receiverProtocol: 1,+ receiver: { kind: 'discontinued' }, lastHead: sourceRecord.head}f.objects.set(`/releases/channels/${retired.name}.json`, JSON.stringify(retired))return { ...f, retired }}+test('receiver kind mirrors the identity comparison between retired channel and destination', async (): Promise<void> => {+ const f = await retiredFixture()+ const read = (): RetiredChannel => decodeChannelRecord(+ f.objects.get(`/releases/channels/${f.retired.name}.json`)!) as RetiredChannel+ const stable = decodeChannelRecord(f.objects.get('/releases/channels/stable.json')!)+ // The fixture destination identity is suffixed away from the preview's, so the+ // publisher-pinned tier is the one a mismatch implies.+ expect(sameChannelIdentity(read().identity, stable.identity)).toBe(false)+ expect(read().receiver).toEqual({ kind: 'discontinued' })+ // A mainline-like prerelease shares the destination identity: in-place.+ f.objects.set(`/releases/channels/${f.retired.name}.json`,+ JSON.stringify({ ...f.retired, receiver: { kind: 'in-place' } }))+ expect(read().receiver).toEqual({ kind: 'in-place' })+ for (const kind of ['unknown', 'In-Place', '', 'discontinue'] as const) {+ f.objects.set(`/releases/channels/${f.retired.name}.json`,+ JSON.stringify({ ...f.retired, receiver: { kind } }))+ expect(read).toThrow(/kind/)+ }+})+test('protected canary accepts bounded Windows revisions without relaxing stable', async (): Promise<void> => {const f = await fixture()f.record.policy = 'canary-release'diff --git a/hermes_cli/release_channels.py b/hermes_cli/release_channels.pyindex b38f11d66c5..19bcada43ea 100644--- a/hermes_cli/release_channels.py+++ b/hermes_cli/release_channels.py@@ -219,6 +219,9 @@ def validate_record(value: object, *, name: str | None = None, repository: str |raise ChannelError("Retirement requires a pinned destination head")if type(record.get("receiverProtocol")) is not int or record["receiverProtocol"] != 1:raise ChannelError("Unsupported retirement receiver protocol")+ receiver = record.get("receiver")+ if not isinstance(receiver, dict) or receiver.get("kind") not in ("in-place", "discontinued"):+ raise ChannelError("Invalid retirement receiver kind")if _head(record.get("lastHead")) != head:raise ChannelError("Retirement last head mismatch")return recorddiff --git a/scripts/releases/channels.py b/scripts/releases/channels.pyindex 6d397ca1584..5064c123400 100644--- a/scripts/releases/channels.py+++ b/scripts/releases/channels.py@@ -397,9 +397,15 @@ class ChannelPublisher:raise ChannelError("Retirement requires a directly active stable-release destination")target_raw = self.reader.read_bytes(target["head"]["manifestKey"], target["head"]["sha256"])manifest = validate_manifest(decode_json(target_raw), target, self.public_base)+ # Two-tier retirement: the kind is derived, never asserted by the caller.+ # A suffixed (canary/commit) identity can never match stable's, so+ # "in-place" cannot be mis-assigned; the kind is a client routing hint.+ identity = record.get("identity")+ kind = "in-place" if identity is not None and identity == target.get("identity") else "discontinued"retired = {**record, "state": "retired", "revision": record["revision"] + 1,"destination": destination, "minimumVersion": minimum_version,"destinationHead": target["head"], "receiverProtocol": 1,+ "receiver": {"kind": kind},"lastHead": record["head"]}validate_record(retired)if tuple(map(int, manifest["request"]["sourceVersion"].split("."))) < tuple(map(int, minimum_version.split("."))):diff --git a/tests/ci/test_channel_build_publication.py b/tests/ci/test_channel_build_publication.pyindex 068cefe58bf..ded2d82db0d 100644--- a/tests/ci/test_channel_build_publication.py+++ b/tests/ci/test_channel_build_publication.py@@ -306,7 +306,8 @@ def test_real_publication_cas_and_manifest_summary(tmp_path, r2_server, staged_cassert evidence["request"] == request# A retired publisher can stage immutable diagnostics, but never revive its pointer.retired = {**stored, "state": "retired", "destination": "stable", "minimumVersion": "1.2.3",- "lastHead": stored["head"], "destinationHead": stored["head"], "receiverProtocol": 1}+ "lastHead": stored["head"], "destinationHead": stored["head"], "receiverProtocol": 1,+ "receiver": {"kind": "discontinued"}}r2_server.store[channel_key] = (canonical_json(retired), '"retired"')result = run_shell(tmp_path, r2_server, script, env, cwd=tmp_path / "clone")assert result.returncode != 0 and "Retired" in result.stderrdiff --git a/tests/hermes_cli/test_release_channels.py b/tests/hermes_cli/test_release_channels.pyindex 082148f157d..2cde0922e06 100644--- a/tests/hermes_cli/test_release_channels.py+++ b/tests/hermes_cli/test_release_channels.py@@ -46,7 +46,8 @@ def test_resolve_verifies_exact_manifest_and_preserves_retirement_constraints():assert reader.resolve("next-preview").manifest == manifestold = pub._read("old-preview")[0]old.update(state="retired", destination="next-preview", minimumVersion="1.0.0",- destinationHead=record["head"], receiverProtocol=1, lastHead=None)+ destinationHead=record["head"], receiverProtocol=1,+ receiver={"kind": "discontinued"}, lastHead=None)objects["releases/channels/old-preview.json"] = canonical_json(old)resolved = reader.resolve("old-preview")assert resolved.requested == old and resolved.terminal == record@@ -93,7 +94,8 @@ def test_reader_rejects_cycles_identity_substitution_and_cross_authority():reader.resolve("alpha")record["repository"] = "example/hermes-agent"record.update(state="retired", destination="alpha", minimumVersion="1.0.0", lastHead=record["head"],- destinationHead=record["head"], receiverProtocol=1)+ destinationHead=record["head"], receiverProtocol=1,+ receiver={"kind": "discontinued"})objects["releases/channels/alpha.json"] = canonical_json(record)with pytest.raises(ChannelError, match="cycle"):reader.resolve("alpha")@@ -170,7 +172,8 @@ def test_malformed_record_and_unqualified_retirement_never_resolve():target["policy"] = "stable-release"objects["releases/channels/destination.json"] = canonical_json(target)record.update(state="retired", destination="destination", minimumVersion="2.0.0", lastHead=None,- destinationHead=target["head"], receiverProtocol=1)+ destinationHead=target["head"], receiverProtocol=1,+ receiver={"kind": "discontinued"})objects["releases/channels/preview.json"] = canonical_json(record)with pytest.raises(ChannelError, match="minimum version"):pub.reader.resolve("preview")diff --git a/tests/hermes_cli/test_source_channel_integration.py b/tests/hermes_cli/test_source_channel_integration.pyindex dee44722882..22e062b367c 100644--- a/tests/hermes_cli/test_source_channel_integration.py+++ b/tests/hermes_cli/test_source_channel_integration.py@@ -267,7 +267,8 @@ def retired_channel_archive(source, channel_archive):preview = publish_channel_build(channel_archive, name, "a" * 32, source.commits[0])qualified = publish_channel_build(channel_archive, "stable", "b" * 32, source.commits[1], stable=True)retired = dict(preview, state="retired", destination="stable", minimumVersion="1.0.0",- destinationHead=qualified["head"], receiverProtocol=1, lastHead=preview["head"])+ destinationHead=qualified["head"], receiverProtocol=1,+ receiver={"kind": "discontinued"}, lastHead=preview["head"])(archive / f"releases/channels/{name}.json").write_bytes(canonical_json(retired))publish_channel_build(channel_archive, "stable", "c" * 32, source.commits[2], sequence=2, stable=True)set_install_channel(name, source.root)diff --git a/tests/scripts/test_release_channels.py b/tests/scripts/test_release_channels.pyindex a2811111e4a..3dc85fe45a9 100644--- a/tests/scripts/test_release_channels.py+++ b/tests/scripts/test_release_channels.py@@ -246,6 +246,37 @@ def test_retirement_race_requires_a_new_explicit_attempt():assert pub.retire("preview", "stable", "2.0.0")["lastHead"]["buildId"] == second["buildId"]+def test_retire_derives_receiver_kind_from_channel_identity_match():+ """The pinned kind is derived from identity comparison, never caller-asserted."""+ from hermes_cli.release_channels import canonical_json+ with object_server() as (url, objects, headers, requests, faults):+ pub = publisher(url, verify_build=lambda request, manifest: True)+ for name in ("mainline-preview", "suffixed-preview", "stable"):+ pub.create(name)+ # A mainline-like prerelease shares the destination stable identity.+ preview = pub._read("mainline-preview")[0]+ first = pub.allocate("mainline-preview", "a" * 40, "1.0.0")+ put_build(objects, first)+ pub.promote(first["buildId"])+ target = pub._read("stable")[0]+ target["policy"] = "stable-release"+ target["identity"] = preview["identity"]+ stable = dict(first, channel="stable", identity=target["identity"], releaseTag="v2.0.0", version="2.0.0", windowsVersion="2.0.0.0", sourceVersion="2.0.0", buildId="e" * 32)+ manifest = put_build(objects, stable)+ target.update(nextSequence=stable["sequence"] + 1, head={"buildId": stable["buildId"], "sequence": stable["sequence"], "manifestKey": "releases/channel-builds/" + stable["buildId"] + "/build.json", "sha256": hashlib.sha256(canonical_json(manifest)).hexdigest()})+ objects["releases/channels/stable.json"] = canonical_json(target)+ in_place = pub.retire("mainline-preview", "stable", "2.0.0")+ assert in_place["receiver"] == {"kind": "in-place"}+ assert pub.reader.resolve("mainline-preview").requested["receiver"] == {"kind": "in-place"}+ # A suffixed channel identity can never match stable's.+ second = pub.allocate("suffixed-preview", "b" * 40, "1.0.0")+ put_build(objects, second)+ pub.promote(second["buildId"])+ discontinued = pub.retire("suffixed-preview", "stable", "2.0.0")+ assert discontinued["receiver"] == {"kind": "discontinued"}+ assert pub.reader.resolve("suffixed-preview").requested["receiver"] == {"kind": "discontinued"}++def test_mutable_read_loss_recovery_never_clones_another_allocation():from scripts.releases.channels import ChannelConflictfrom hermes_cli.release_channels import canonical_json