The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(release): Store certifies before the gate; publication switches it live
ethernet4148f6d1f370
diff --git a/.github/workflows/desktop-bundled-release.yml b/.github/workflows/desktop-bundled-release.ymlindex 2866a075507..43ab18b3df0 100644--- a/.github/workflows/desktop-bundled-release.yml+++ b/.github/workflows/desktop-bundled-release.yml@@ -2418,9 +2418,10 @@ jobs:stable-store:name: Submit the verified Store package# Runs beside stable-publish: it materializes and digest-checks its own Store candidate- # from the admitted manifest and never reads stable-publish's output. It leaves an- # uncommitted draft; only the publication pass commits it (auto-publish on), so a run- # whose stable-publish fails leaves a draft no customer sees, never a live build.+ # from the admitted manifest and never reads stable-publish's output. It commits the+ # submission held (Manual), so certification runs before the gate; only the+ # publication pass switches it to Immediate, so a run whose stable-publish fails+ # leaves a held submission no customer sees, never a live build.needs: [validate]if: inputs.release-phase == 'publish' && inputs.skip-store != true# The Store is not a release gate: a failed submission leaves the release publishable@@ -2459,8 +2460,8 @@ jobs:files=(verified/Store-*.msixbundle)test "${#files[@]}" -eq 1test -f "${files[0]}"- # An uncommitted draft: the publication pass sets targetPublishMode- # Immediate and commits it (scripts/releases/store.py).+ # Committed held (Manual); the publication pass switches it to+ # Immediate (scripts/releases/store.py).python -m scripts.releases.store submit "${files[0]}"- name: Name the Store package for a manual uploadif: failure()diff --git a/scripts/releases/sequencer.py b/scripts/releases/sequencer.pyindex 6b1a78499c3..6f3c1302370 100644--- a/scripts/releases/sequencer.py+++ b/scripts/releases/sequencer.py@@ -371,10 +371,32 @@ def channel_head(desktop_head: str | None, records: list[dict],return max(versions, key=_key, default=None)+def _reconcile_store(env: dict, records: list[dict], read_archive) -> None:+ from scripts.releases import store++ # Channels are already durable; Store recovery must not depend on advancing them again.+ for record in sorted(records, key=lambda row: _key(row["version"]), reverse=True):+ if record["state"] != "published" or "windows-store" not in record["lanes"]:+ continue+ log(f"Reconciling the Microsoft Store submission for {record['tag']}")+ try:+ raw = read_archive(f"releases/tag/{record['claim_tag']}/release-candidates.json")+ if hashlib.sha256(raw).hexdigest() != record["candidate_manifest_sha256"]:+ raise store.StoreError("the archived candidate manifest differs from the receipt")+ result = store.release_from_env(env, json.loads(raw))+ except (store.StoreError, ValueError, OSError) as error:+ print(f"::warning title=Microsoft Store::{error}. The release is published; "+ "check its Store submission in Partner Center.")+ return+ # A newer public release may have failed its advisory upload, leaving an older one held.+ if result != "superseded":+ return++def reconcile(env: dict, *, run=output, read_head=None, advance_head=None,read_archive=None) -> list[dict]:"""Converge GitHub publication and protected heads oldest-first."""- from scripts.releases import channel_releases, docker, stable, store+ from scripts.releases import channel_releases, docker, stablerepository = env["GITHUB_REPOSITORY"]run = logged_run(run)@@ -437,7 +459,8 @@ def reconcile(env: dict, *, run=output, read_head=None, advance_head=None,for kind, version in step.items()) or "(none)"))by_version = {record["version"]: record for record in records}- if advance_head is None:+ production = advance_head is None+ if production:def production_advance(record: dict) -> None:if lane_set.advances_desktop(record["lanes"]):log(f"Advancing the protected desktop channel to {record['version']} from "@@ -457,19 +480,6 @@ def reconcile(env: dict, *, run=output, read_head=None, advance_head=None,# build that pushed the image under the attempt ref.docker.promote_stable(record["claim_tag"], record["docker_manifest_digest"], record["tag"])log("Docker aliases moved")- if "windows-store" in record["lanes"]:- log("Releasing the Microsoft Store draft")- # The Store joins the pass here (after the feeds and aliases move): this- # release's draft is committed with auto-publish on. The Store never- # blocks a release: a failed or unreadable submission becomes a warning.- try:- raw = read_archive(f"releases/tag/{record['claim_tag']}/release-candidates.json")- if hashlib.sha256(raw).hexdigest() != record["candidate_manifest_sha256"]:- raise store.StoreError("the archived candidate manifest differs from the receipt")- store.release_from_env(env, json.loads(raw))- except (store.StoreError, ValueError) as error:- print(f"::warning title=Microsoft Store::{error}. The release is published; "- "upload the Store package from the release run's summary in Partner Center.")advance_head = production_advancefor number, step in enumerate(steps, start=1):@@ -503,6 +513,8 @@ def reconcile(env: dict, *, run=output, read_head=None, advance_head=None,log(f"Channel head after the pass: {reached} (planned {expected})")if reached != expected:raise ValueError("Stable protected head did not reach the planned version")+ if production:+ _reconcile_store(env, list(final.values()), read_archive)log("Stable sequencer finished: " + (", ".join(f"{kind} {version}" for step in steps for kind, version in step.items()) or "nothing to do"))return stepsdiff --git a/scripts/releases/store.py b/scripts/releases/store.pyindex 1fd97e551c2..3293fe1cbf4 100644--- a/scripts/releases/store.py+++ b/scripts/releases/store.py@@ -1,26 +1,33 @@"""Store submission control for the release pipeline.-The green run uploads the verified ``.msixbundle`` as a draft submission and-stops: nothing a customer can see changes, and certification has not started.-The publication pass, which runs only when the release really goes out, sets-``targetPublishMode: "Immediate"`` on that draft and commits it, so the Store-build goes live as soon as it passes certification. The submission API has no-call that releases a submission once it is committed and held, which is why-the commit waits for publication instead of happening at green with Manual.-Both entry points are safe to rerun.+The green run submits the verified ``.msixbundle`` with auto-publish off+(``targetPublishMode: "Manual"``) and commits it, so certification runs before+the release gate and nothing a customer sees changes. The publication pass,+which runs only when the release really goes out, tries to switch that held+submission to ``Immediate`` and commit it again so it goes live by itself.+Microsoft documents no call that releases a held submission and does not say+whether update accepts a committed one; when it refuses (409), publication+prints a Publish now instruction instead, which is the manual step this+replaces. Both entry points are safe to rerun.Green run — ``python -m scripts.releases.store submit <package>`` (Windowsrunner, ``msstore`` CLI configured beforehand by``microsoft/microsoft-store-apppublisher`` + ``msstore reconfigure``):1. ``msstore submission get <productId>`` — the current submission as JSON.-2. ``msstore submission delete <productId> --no-confirm`` — only for a draft- (``PendingCommit``) or a failed submission. A committed submission that is- still in certification or publishing belongs to an earlier release going- live; ``msstore publish`` would delete it, so ``submit`` refuses instead.+2. ``msstore submission delete <productId> --no-confirm`` — for a draft,+ a failed submission, or a committed Manual submission whose recorded claim+ has a matching remote abandon marker. Other committed submissions stay+ protected; old submissions without an owner record need manual cleanup.3. ``msstore publish <package> --appId <productId> --noCommit`` — uploads thepackage and leaves the submission as a draft (``--noCommit`` / ``-nc``,"Disables committing the submission, keeping it in draft state").+4. ``msstore submission get <productId>`` — the complete draft JSON.+5. ``msstore submission update <productId> <json>`` — the same JSON with+ ``targetPublishMode: "Manual"`` and the claim tag in ``notesForCertification``.+ Existing certification instructions are preserved. For MSIX apps the CLI+ sends the complete submission JSON, setting packages and publish mode at once.+6. ``msstore submission publish <productId>`` — commits; certification starts.Publication pass — ``scripts.releases.store.release(...)`` (Ubuntu runner,Partner Center submission REST API, stdlib ``urllib`` only):@@ -30,18 +37,18 @@ Partner Center submission REST API, stdlib ``urllib`` only):``https://manage.devcenter.microsoft.com/.default`` (the same MS_STORE_*credentials the CLI uses).2. ``GET https://manage.devcenter.microsoft.com/v1.0/my/applications/{id}`` —- ``pendingApplicationSubmission.id`` names the draft.-3. ``GET .../submissions/{id}`` — the draft must carry this release's Store- bundle (``applicationPackages[].fileName``); a draft from a newer green run+ ``pendingApplicationSubmission.id`` names the held submission.+3. ``GET .../submissions/{id}`` — it must carry this release's Store bundle+ (``applicationPackages[].fileName``); a submission from a newer green runis left alone.4. ``PUT .../submissions/{id}`` with ``targetPublishMode: "Immediate"``, then- ``POST .../submissions/{id}/commit``; certification starts and the build- goes live when it passes. A submission that is already committed or live is- a no-op.+ ``POST .../submissions/{id}/commit``. A 409 from either means the API will+ not change a committed submission: publication warns with the Publish now+ step and stays green. A live submission is a no-op.Sources for the commands and fields above:-- msstore CLI commands and options (``submission get/delete --no-confirm``,- ``publish --noCommit``):+- msstore CLI commands and options (``submission get/update/publish/delete+ --no-confirm``, ``publish --noCommit``):https://learn.microsoft.com/en-us/windows/apps/publish/msstore-dev-cli/commands- CLI CI/CD setup (``msstore reconfigure --tenantId --sellerId --clientId--clientSecret`` on the runner):@@ -56,12 +63,14 @@ Sources for the commands and fields above:https://learn.microsoft.com/en-us/windows/uwp/monetize/update-an-app-submissionhttps://learn.microsoft.com/en-us/windows/uwp/monetize/commit-an-app-submissionhttps://learn.microsoft.com/en-us/windows/uwp/monetize/get-status-for-an-app-submission- Update and commit refuse a submission that is no longer a draft (409).+ Update documents 409 as "could not be updated because of the current state+ of the app" without naming the states.- Azure AD client-credentials token:https://learn.microsoft.com/en-us/windows/uwp/monetize/create-and-manage-submissions-using-windows-store-services#obtain-an-azure-ad-access-token"""from __future__ import annotations+from collections.abc import Callableimport jsonimport osimport subprocess@@ -95,8 +104,8 @@ def _cli_run(argv: list[str]) -> str:return result.stdout-def _status(submission_output: str) -> str:- """The status of the submission ``msstore submission get`` prints.+def _submission(submission_output: str) -> dict:+ """Read the submission ``msstore submission get`` prints.``submission status`` is no use here: for a packaged (MSIX) app it prints a Spectremarkup line (``Submission Status = ...``) and status tables, never JSON, and prints@@ -111,7 +120,7 @@ def _status(submission_output: str) -> str:key = _key(submission, "status") if isinstance(submission, dict) else Noneif key is None:raise StoreError(f"unreadable submission: {submission_output[:200]!r}")- return submission[key]+ return submissiondef _key(submission: dict, name: str) -> str | None:@@ -120,18 +129,64 @@ def _key(submission: dict, name: str) -> str | None:return next((k for k in submission if k.lower() == name.lower()), None)-def submit(package: str, *, product_id: str, run=_cli_run) -> dict:- """Upload ``package`` as an uncommitted draft; the publication pass commits it."""- status = _status(run(["msstore", "submission", "get", product_id]))- if status == _DRAFT or status in _FAILED:+def _notes(submission: dict) -> dict:+ raw = submission.get(_key(submission, "notesForCertification") or "notesForCertification") or ""+ try:+ notes = json.loads(raw)+ except (TypeError, ValueError):+ notes = None+ # Preserve existing certification instructions when adding our owner record.+ return notes if isinstance(notes, dict) else ({"notes": raw} if raw else {})+++def _is_abandoned(claim_tag: str) -> bool:+ from scripts.releases.versioning import marker_ref, parse_attempt_ref++ parsed = parse_attempt_ref(claim_tag)+ if parsed is None:+ return False+ claim = f"refs/tags/{claim_tag}^{{}}"+ marker = f"refs/tags/{marker_ref(*parsed)}^{{}}"+ refs = {ref: sha for sha, ref in (line.split() for line in _cli_run(+ ["git", "ls-remote", "--tags", "origin", claim, marker]).splitlines())}+ # A similarly named or foreign marker must never authorize deleting a submission.+ return bool(refs.get(claim) and refs.get(marker) == refs[claim])+++def submit(package: str, *, product_id: str, claim_tag: str | None = None,+ is_abandoned: Callable[[str], bool] | None = None, run=_cli_run) -> dict:+ """Submit held; replace a committed predecessor only after its claim was abandoned."""+ from scripts.releases.versioning import parse_attempt_ref++ if claim_tag is not None and parse_attempt_ref(claim_tag) is None:+ raise StoreError(f"invalid Store release claim: {claim_tag!r}")+ submission = _submission(run(["msstore", "submission", "get", product_id]))+ status = submission[_key(submission, "status")]+ owner = _notes(submission).get("claimTag")+ abandoned = (status in _COMMITTED+ and submission.get(_key(submission, "targetPublishMode")) == "Manual"+ and isinstance(owner, str) and parse_attempt_ref(owner) is not None+ and (is_abandoned or _is_abandoned)(owner))+ if status == _DRAFT or status in _FAILED or abandoned:run(["msstore", "submission", "delete", product_id, "--no-confirm"])elif status not in _SETTLED:- # Committed and on its way live: an earlier release's Store update, which- # msstore publish would delete.- raise StoreError(f"a committed Store submission is {status}; rerun stable-store "- "after it is published")+ raise StoreError(f"a committed Store submission is {status}; rerun stable-store after "+ "it is published, or after its owning claim is abandoned; a submission "+ "without an owner record needs manual cleanup in Partner Center")run(["msstore", "publish", package, "--appId", product_id, "--noCommit"])- return {"productId": product_id, "status": _DRAFT}+ submission = _submission(run(["msstore", "submission", "get", product_id]))+ submission[_key(submission, "targetPublishMode") or "TargetPublishMode"] = "Manual"+ notes = _notes(submission)+ if claim_tag is not None:+ notes["claimTag"] = claim_tag+ else:+ # The CLI may inherit the last submission's notes; that owner does not own this upload.+ notes.pop("claimTag", None)+ submission[_key(submission, "notesForCertification") or "notesForCertification"] = json.dumps(notes)+ run(["msstore", "submission", "update", product_id,+ json.dumps(submission, separators=(",", ":"))])+ run(["msstore", "submission", "publish", product_id])+ return {"productId": product_id, "targetPublishMode": "Manual"}def _http_run(request: dict) -> dict:@@ -174,12 +229,16 @@ def _token(tenant_id: str, client_id: str, client_secret: str, run) -> str:return response["body"]["access_token"]+class _Refused(StoreError):+ """The submission API answered 409: it will not change this submission now."""++def release(*, product_id: str, store_file: str, tenant_id: str, client_id: str,client_secret: str, run=_http_run) -> str:- """Commit this release's Store draft with ``targetPublishMode: "Immediate"``.+ """Switch this release's held Store submission to ``Immediate`` and commit it.``store_file`` is the Store bundle the release's candidate manifest names; a- draft that does not carry it belongs to another green run and is left alone.+ submission that does not carry it belongs to another green run and is left alone."""token = _token(tenant_id, client_id, client_secret, run)auth = {"Authorization": f"Bearer {token}"}@@ -189,6 +248,8 @@ def release(*, product_id: str, store_file: str, tenant_id: str, client_id: str,if body is not None:request["body"] = bodyresponse = run(request)+ if response["status"] == 409 and method != "GET":+ raise _Refused(f"{method} {path}: {response['body']}")if response["status"] != 200:raise StoreError(f"{method} {path} failed: {response['status']} {response['body']}")return response["body"]@@ -196,8 +257,8 @@ def release(*, product_id: str, store_file: str, tenant_id: str, client_id: str,app = call("GET", f"/applications/{product_id}")pending = (app.get("pendingApplicationSubmission") or {}).get("id")if not pending:- _notice(f"No Store draft is pending for {product_id}; check the release's stable-store job.")- return "no-draft"+ _notice(f"No Store submission is pending for {product_id}; check the release's stable-store job.")+ return "no-submission"path = f"/applications/{product_id}/submissions/{pending}"submission = call("GET", path)state = submission.get(_key(submission, "status") or "status")@@ -206,23 +267,29 @@ def release(*, product_id: str, store_file: str, tenant_id: str, client_id: str,for package in packages)if state in _ALREADY_LIVE:return "already-live"- if state in _COMMITTED:- return "already-committed" if bound else "other-committed"if state in _FAILED:raise StoreError(f"Store submission {pending} is {state}; resubmit from a green run")- if state != _DRAFT:+ if state != _DRAFT and state not in _COMMITTED:raise StoreError(f"Store submission {pending} has an unexpected status: {state!r}")if not bound:- _notice(f"The pending Store draft {pending} does not carry {store_file}; a newer "- "green run replaced it, and that release's publication commits it.")+ _notice(f"The pending Store submission {pending} does not carry {store_file}; a newer "+ "green run replaced it, and that release's publication releases it.")return "superseded"- submission[_key(submission, "targetPublishMode") or "targetPublishMode"] = "Immediate"- call("PUT", path, submission)- call("POST", f"{path}/commit")+ mode_key = _key(submission, "targetPublishMode") or "targetPublishMode"+ if submission.get(mode_key) == "Immediate" and state in _COMMITTED:+ return "already-immediate"+ submission[mode_key] = "Immediate"+ try:+ call("PUT", path, submission)+ call("POST", f"{path}/commit")+ except _Refused as refused:+ _notice(f"Store submission {pending} stays held: the submission API refused to switch it "+ f"to Immediate ({refused}). Once it is certified, select Publish now in Partner Center.")+ return "held"after = call("GET", f"{path}/status").get("status")if after in _FAILED:raise StoreError(f"Store submission {pending} is {after} after commit")- return "committed"+ return "immediate"def _notice(text: str) -> None:@@ -240,7 +307,7 @@ def store_bundle(manifest: dict) -> str:def release_from_env(env: dict, manifest: dict, run=_http_run) -> str:- """Release the Store draft for ``manifest`` when the environment configures the Store."""+ """Release the held Store submission for ``manifest`` when the environment configures the Store."""product_id = env.get("MS_STORE_PRODUCT_ID")if not product_id:print("Store release skipped: MS_STORE_PRODUCT_ID is not configured.",@@ -260,7 +327,7 @@ def main(argv: list[str]) -> int:if len(argv) >= 2 and argv[0] == "submit":product_id = os.environ["MS_STORE_PRODUCT_ID"]package = argv[1]- result = submit(package, product_id=product_id)+ result = submit(package, product_id=product_id, claim_tag=os.environ.get("HERMES_ARCHIVE_TAG"))print(json.dumps(result, sort_keys=True))return 0print("usage: python -m scripts.releases.store submit <package>", file=sys.stderr)diff --git a/tests/scripts/test_release_sequencer.py b/tests/scripts/test_release_sequencer.pyindex 81dcfa1bd94..97d6121b745 100644--- a/tests/scripts/test_release_sequencer.py+++ b/tests/scripts/test_release_sequencer.py@@ -622,6 +622,97 @@ def test_the_store_release_joins_the_pass_after_the_aliases_move(monkeypatch):assert seen[0][1] == json.loads(manifest)[email protected]("recovery_head", ["0.21.5", "0.21.6"])+def test_store_release_recovers_after_alias_movement_without_rewinding_channels(monkeypatch, recovery_head):+ from scripts.releases import channel_releases, docker, sequencer, store+ from tests.scripts.test_release_store import STORE_FILE, _Api++ manifest = json.dumps({"files": [{"path": STORE_FILE}]}).encode()+ _tags, _releases, run = _sequencer_fixture(+ "0.21.5", manifest_digest=hashlib.sha256(manifest).hexdigest(), drafts_on_claim_tag=True)+ head = ["0.21.4"]+ events = []+ api = _Api()+ release_from_env = store.release_from_env+ env = {"GITHUB_REPOSITORY": "example/project", "MS_STORE_PRODUCT_ID": "9NTEST",+ "MS_STORE_TENANT_ID": "T", "MS_STORE_CLIENT_ID": "C", "MS_STORE_CLIENT_SECRET": "S"}++ def advance(_env, record, _root):+ head[0] = record["version"]+ events.append("feed")++ def interrupt_after_aliases(*_args):+ events.append("aliases")+ raise KeyboardInterrupt("cancelled after aliases moved")++ def release_store(environment, candidate):+ events.append("store")+ return release_from_env(environment, candidate, run=api)++ monkeypatch.setattr(channel_releases, "advance_stable", advance)+ monkeypatch.setattr(docker, "promote_stable", interrupt_after_aliases)+ monkeypatch.setattr(store, "release_from_env", release_store)+ with pytest.raises(KeyboardInterrupt, match="after aliases moved"):+ sequencer.reconcile(env, run=run, read_head=lambda: head[0], read_archive=lambda _key: manifest)+ assert head[0] == "0.21.5" and events == ["feed", "aliases"]+ assert api.mode == "Manual" and api.commits == 0++ # Channel movement is already durable; retry only the receipt-bound Store work,+ # even if another publication has since advanced the channels further.+ head[0] = recovery_head+ monkeypatch.setattr(channel_releases, "advance_stable",+ lambda *_args: pytest.fail("Store recovery moved the desktop head"))+ monkeypatch.setattr(docker, "promote_stable",+ lambda *_args: pytest.fail("Store recovery moved the Docker aliases"))+ assert sequencer.reconcile(+ env, run=run, read_head=lambda: head[0], read_archive=lambda _key: manifest) == []+ assert head[0] == recovery_head and events == ["feed", "aliases", "store"]+ assert api.mode == "Immediate" and api.commits == 1+ sequencer.reconcile(env, run=run, read_head=lambda: head[0], read_archive=lambda _key: manifest)+ assert api.commits == 1++[email protected]("pending_is_latest", [True, False])+def test_store_reconciliation_finds_the_newest_matching_published_submission(monkeypatch, pending_is_latest):+ from scripts.releases import channel_releases, docker, sequencer, store+ from tests.scripts.test_release_store import STORE_FILE, _Api++ newest_file = "Store-HermesBundled-2026.7000.1.0-win.msixbundle"+ manifests = {+ f"releases/tag/rc.1-v{version}/release-candidates.json":+ json.dumps({"files": [{"path": filename}]}).encode()+ for version, filename in [("0.21.5", STORE_FILE), ("0.21.6", newest_file)]+ }+ tags, releases, run = _sequencer_fixture("0.21.5", "0.21.6", manifest_digest=None)+ for version, raw in zip(("0.21.5", "0.21.6"), manifests.values()):+ tags[f"v{version}"][2]["candidateManifestSha256"] = hashlib.sha256(raw).hexdigest()+ for row in releases:+ row.update(draft=False, published_at="2026-09-22T01:00:00Z")+ api = _Api(files=[newest_file if pending_is_latest else STORE_FILE])+ seen = []+ release_from_env = store.release_from_env++ def release_store(env, manifest):+ result = release_from_env(env, manifest, run=api)+ seen.append((store.store_bundle(manifest), result))+ return result++ monkeypatch.setattr(store, "release_from_env", release_store)+ monkeypatch.setattr(channel_releases, "advance_stable",+ lambda *_args: pytest.fail("Store reconciliation moved the desktop head"))+ monkeypatch.setattr(docker, "promote_stable",+ lambda *_args: pytest.fail("Store reconciliation moved the Docker aliases"))+ env = {"GITHUB_REPOSITORY": "example/project", "MS_STORE_PRODUCT_ID": "9NTEST",+ "MS_STORE_TENANT_ID": "T", "MS_STORE_CLIENT_ID": "C", "MS_STORE_CLIENT_SECRET": "S"}+ assert sequencer.reconcile(+ env, run=run, read_head=lambda: "0.21.6", read_archive=manifests.__getitem__) == []+ # A newer public release may have failed its non-blocking Store upload;+ # only a package mismatch permits trying an older public release.+ assert seen == ([(newest_file, "immediate")] if pending_is_latest else+ [(newest_file, "superseded"), (STORE_FILE, "immediate")])+ assert api.mode == "Immediate" and api.commits == 1++def test_a_publish_that_died_before_the_retarget_is_repaired():from scripts.releases.sequencer import reconcilediff --git a/tests/scripts/test_release_store.py b/tests/scripts/test_release_store.pyindex f0775bf46d5..0ced83bc34e 100644--- a/tests/scripts/test_release_store.py+++ b/tests/scripts/test_release_store.py@@ -1,4 +1,4 @@-"""The Store build stays an uncommitted draft until publication, which commits it."""+"""The green run commits the Store build held; publication tries to switch it to Immediate."""import jsonimport pytest@@ -7,9 +7,11 @@ import pytestclass _Cli:"""Stands in for the msstore CLI. Records every argv it is handed."""- def __init__(self, status="Published"):+ def __init__(self, status="Published", *, mode="Immediate", claim_tag=None):self.events = []self.status = status+ self.mode = mode+ self.claim_tag = claim_tagdef __call__(self, argv):name = " ".join(argv)@@ -24,7 +26,9 @@ class _Cli:status = "PendingCommit" if uploaded else self.status# The CLI serializes .NET property names (rc.13-v0.21.7: '{"Id": ..., "ApplicationCategory": ...').return json.dumps({- "Status": status, "TargetPublishMode": "Immediate",+ "Status": status, "TargetPublishMode": "Immediate" if uploaded else self.mode,+ "NotesForCertification": json.dumps({"claimTag": self.claim_tag})+ if self.claim_tag and not uploaded else "","FriendlyName": "Submission 2", "Listings": {}})if argv[:3] == ["msstore", "submission", "delete"]:self.events.append(("delete-pending", name))@@ -49,15 +53,17 @@ def _names(cli):return cli.names()-def test_submit_uploads_an_uncommitted_draft_and_stops():+def test_submit_commits_the_upload_held_so_certification_starts_before_the_gate():from scripts.releases.store import submitcli = _Cli()submit("verified/Store-1.2.3.msixbundle", product_id="9NTEST", run=cli)names = cli.names()- assert names[-1] == "msstore publish verified/Store-1.2.3.msixbundle --appId 9NTEST --noCommit"- assert not any(name.startswith(("msstore submission update", "msstore submission publish"))- for name in names)+ upload = names.index("msstore publish verified/Store-1.2.3.msixbundle --appId 9NTEST --noCommit")+ update = next(i for i, n in enumerate(names) if n.startswith("msstore submission update 9NTEST "))+ assert upload < update < names.index("msstore submission publish 9NTEST") == len(names) - 1+ # The CLI's own spelling is kept, so update does not get two publish-mode keys.+ assert cli.updated["TargetPublishMode"] == "Manual" and "targetPublishMode" not in cli.updated@pytest.mark.parametrize("status", ["PendingCommit", "CommitFailed", "CertificationFailed",@@ -91,19 +97,69 @@ def test_submit_refuses_to_clobber_an_earlier_release_on_its_way_live(status):assert cli.names() == ["msstore submission get 9NTEST"][email protected]("status", ["Certification", "Release"])+def test_submit_replaces_an_abandoned_claims_held_submission(status):+ from scripts.releases.store import submit++ prior_claim = "rc.1-v0.21.5"+ next_claim = "rc.2-v0.21.5"+ cli = _Cli(status, mode="Manual", claim_tag=prior_claim)+ checked = []++ def is_abandoned(claim_tag):+ checked.append(claim_tag)+ return claim_tag == prior_claim++ submit("verified/Store-next.msixbundle", product_id="9NTEST", claim_tag=next_claim,+ is_abandoned=is_abandoned, run=cli)++ names = cli.names()+ assert checked == [prior_claim]+ assert names.index("msstore submission delete 9NTEST --no-confirm") < names.index(+ "msstore publish verified/Store-next.msixbundle --appId 9NTEST --noCommit")+ assert names[-1] == "msstore submission publish 9NTEST"+ assert cli.updated["TargetPublishMode"] == "Manual"+ # Bind the new upload before committing so its own abandonment can be recovered.+ assert json.loads(cli.updated["NotesForCertification"])["claimTag"] == next_claim+ assert "notesForCertification" not in cli.updated++[email protected]("status,mode,owner,marked_claim", [+ ("Release", "Manual", "rc.1-v0.21.5", None),+ ("Release", "Manual", "rc.1-v0.21.5", "rc.9-v0.21.5"),+ ("Release", "Manual", None, "rc.1-v0.21.5"),+ ("Release", "Manual", "v0.21.5", "v0.21.5"),+ ("Certification", "Immediate", "rc.1-v0.21.5", "rc.1-v0.21.5"),+ ("Release", "SpecificDate", "rc.1-v0.21.5", "rc.1-v0.21.5"),+ ("PendingPublication", "Manual", "rc.1-v0.21.5", "rc.1-v0.21.5"),+ ("Publishing", "Manual", "rc.1-v0.21.5", "rc.1-v0.21.5"),+])+def test_abandoned_cleanup_does_not_clobber_an_unproven_or_live_owner(status, mode, owner, marked_claim):+ from scripts.releases.store import StoreError, submit++ cli = _Cli(status, mode=mode, claim_tag=owner)+ with pytest.raises(StoreError):+ submit("verified/Store-next.msixbundle", product_id="9NTEST", claim_tag="rc.2-v0.21.5",+ is_abandoned=lambda claim_tag: claim_tag == marked_claim, run=cli)+ assert cli.names() == ["msstore submission get 9NTEST"]++STORE_FILE = "Store-HermesBundled-2026.6864.2132.0-win.msixbundle"class _Api:"""Stands in for the Partner Center submission REST API, with state."""- def __init__(self, status="PendingCommit", files=(STORE_FILE,), pending="1152921504621243540",- commit_status=200):+ def __init__(self, status="Release", files=(STORE_FILE,), pending="1152921504621243540",+ commit_status=200, refuse_committed=False):self.requests = []self.status = statusself.files = list(files)self.pending = pendingself.commit_status = commit_status+ # Microsoft does not document whether update accepts a committed submission;+ # both answers are modelled.+ self.refuse_committed = refuse_committedself.mode = "Manual"self.commits = 0@@ -127,13 +183,13 @@ class _Api:if method == "GET" and url.endswith(f"{submission}/status"):return {"status": 200, "body": {"status": self.status}}if method == "PUT" and url.endswith(submission):- if self.status != "PendingCommit":+ if self.status != "PendingCommit" and self.refuse_committed:return {"status": 409, "body": {"code": "InvalidState"}}self.mode = request["body"]["targetPublishMode"]return {"status": 200, "body": request["body"]}if method == "POST" and url.endswith(f"{submission}/commit"):- if self.commit_status != 200 or self.status != "PendingCommit":- return {"status": self.commit_status if self.commit_status != 200 else 409, "body": {}}+ if self.commit_status != 200:+ return {"status": self.commit_status, "body": {}}self.commits += 1self.status = "CommitStarted"return {"status": 200, "body": {"status": "CommitStarted"}}@@ -150,22 +206,30 @@ def _release(api, store_file=STORE_FILE):client_secret="S", run=api)-def test_release_commits_this_releases_draft_with_auto_publish_on():- api = _Api()- assert _release(api) == "committed"[email protected]("status", ["Certification", "Release"])+def test_release_switches_this_releases_held_submission_to_immediate(status):+ api = _Api(status)+ assert _release(api) == "immediate"assert api.mode == "Immediate" and api.commits == 1put, commit = api.writes()assert put["method"] == "PUT" and commit["url"].endswith("/commit")[email protected]("refusal", ["update", "commit"])+def test_a_refused_switch_leaves_it_held_and_says_publish_now(capsys, refusal):+ api = _Api(refuse_committed=refusal == "update", commit_status=409 if refusal == "commit" else 200)+ assert _release(api) == "held"+ assert "Publish now" in capsys.readouterr().out++def test_release_is_safe_to_rerun():api = _Api()_release(api)- assert _release(api) == "already-committed"+ assert _release(api) == "already-immediate"assert api.commits == 1-def test_release_leaves_a_draft_from_another_green_run_alone(capsys):+def test_release_leaves_a_submission_from_another_green_run_alone(capsys):api = _Api(files=["Store-HermesBundled-2026.7000.1.0-win.msixbundle"])assert _release(api) == "superseded"assert api.writes() == [] and "::warning" in capsys.readouterr().out@@ -185,16 +249,16 @@ def test_a_failed_submission_raises_and_says_to_resubmit(status):_release(_Api(status))-def test_a_refused_commit_raises():+def test_any_other_api_failure_raises():from scripts.releases.store import StoreError- with pytest.raises(StoreError, match="commit failed: 409"):- _release(_Api(commit_status=409))+ with pytest.raises(StoreError, match="commit failed: 500"):+ _release(_Api(commit_status=500))-def test_no_pending_draft_is_reported_not_invented(capsys):+def test_no_pending_submission_is_reported_not_invented(capsys):api = _Api(pending=None)- assert _release(api) == "no-draft"+ assert _release(api) == "no-submission"assert api.writes() == [] and "::warning" in capsys.readouterr().out@@ -251,7 +315,7 @@ def test_release_from_env_releases_the_manifests_store_bundle_with_the_configure"MS_STORE_CLIENT_SECRET": "SECRET",}manifest = {"files": [{"path": "HermesBundled-0.22.0-win.msixbundle"}, {"path": STORE_FILE}]}- assert release_from_env(env, manifest, run=api) == "committed"+ assert release_from_env(env, manifest, run=api) == "immediate"token = next(r for r in api.requests if r["url"].endswith("/token"))assert token["form"]["client_id"] == "CLIENT"assert token["form"]["client_secret"] == "SECRET"diff --git a/website/docs/developer-guide/stable-releases.md b/website/docs/developer-guide/stable-releases.mdindex 42298ca33a4..9777c69ea42 100644--- a/website/docs/developer-guide/stable-releases.md+++ b/website/docs/developer-guide/stable-releases.md@@ -280,12 +280,17 @@ attempt installed from it is not upgrade-safe: every attempt of a version hasthe same package version, so the published build never replaces it. The Dockerimage is pushed early under the attempt ref; the `stable` and `latest` aliasesmove with the feed in the publication pass. The Store build follows the same-rule: the green run uploads it as an uncommitted draft, and the publication-pass commits that draft with auto-publish on, so it goes live as soon as-certification passes. The submission API cannot release a submission once it-is committed and held, which is why the commit waits for publication. A draft-that does not carry the release's Store bundle (a newer green run replaced it)-is left for that release's publication. A failed submission becomes a warning;+rule: the green run commits it held (auto-publish off), so certification runs+before the gate, and the publication pass switches that submission to+auto-publish. If the submission API refuses the switch, the pass warns: select+Publish now in Partner Center once the build is certified. A submission that+does not carry the release's Store bundle is left alone while the pass checks+older published releases for its owner. Store reconciliation runs even when+the feeds and aliases are already current, so interrupted publication can be+retried without rewinding them. A held submission records its claim in the+certification notes: a successor can replace it only after that claim has a+matching remote abandon marker. Legacy submissions without an owner record+need manual cleanup in Partner Center. A failed submission becomes a warning;the release still publishes. Stable channelrecords carry an optional `archiveRef` naming the attempt ref; `releaseTag`stays `vX.Y.Z` and the protected prefix falls back to it when `archiveRef` is