From 24b3537ecc048d25270261c3be636af7a1819785 Mon Sep 17 00:00:00 2001 From: showxu <10173746+showxu@users.noreply.github.com> Date: Fri, 4 Dec 2026 00:02:03 +0800 Subject: [PATCH 1/3] test: pin the release Host for plugin checks --- .github/computer-mcp-host.sha | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/computer-mcp-host.sha b/.github/computer-mcp-host.sha index 7bb883c..e888ed9 100644 --- a/.github/computer-mcp-host.sha +++ b/.github/computer-mcp-host.sha @@ -1 +1 @@ -941999d411e2a0f1626cc124a3679748804ce2f2 +88402a605dc5383cbed7babd547419cb93893a73 From b0b6653092e735c72056a29dfe5b6f5fb4306e82 Mon Sep 17 00:00:00 2001 From: showxu <10173746+showxu@users.noreply.github.com> Date: Fri, 4 Dec 2026 02:37:35 +0800 Subject: [PATCH 2/3] feat: verify editable native release assets against CI --- .github/workflows/release.yml | 8 +- Documentation/Reference/Release.md | 54 +++---- Tests/test_plugin_release.py | 237 ++++++++++++----------------- VERSIONING.md | 11 ++ scripts/check-workflow.py | 6 +- scripts/plugin_release.py | 129 ++++++---------- 6 files changed, 191 insertions(+), 254 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 366e89e..8a3e226 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: inputs: source_run: - description: Accepted successful CI run ID (frozen receipt takes precedence on recovery) + description: Accepted successful CI run ID type: string required: true release_tag: @@ -15,6 +15,9 @@ on: type: boolean default: false permissions: {} +concurrency: + group: plugin-release-${{ inputs.release_tag || github.run_id }} + queue: max jobs: verify: if: github.repository == 'computer-mcp/plugin-codex' && github.ref == 'refs/heads/master' @@ -28,6 +31,7 @@ jobs: asset_digests: ${{ steps.bundle.outputs.asset_digests }} helper_digest: ${{ steps.bundle.outputs.helper_digest }} tag: ${{ steps.bundle.outputs.tag }} + public_release: ${{ steps.bundle.outputs.public_release }} steps: - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 with: @@ -71,7 +75,7 @@ jobs: if-no-files-found: error retention-days: 14 publish: - if: inputs.publish + if: inputs.publish && needs.verify.outputs.public_release == 'false' needs: verify runs-on: ubuntu-24.04 timeout-minutes: 10 diff --git a/Documentation/Reference/Release.md b/Documentation/Reference/Release.md index 71f3951..39aec22 100644 --- a/Documentation/Reference/Release.md +++ b/Documentation/Reference/Release.md @@ -8,7 +8,7 @@ Candidate runtime acceptance and Release notes require an operator. Version rules are in this repository's [VERSIONING.md](https://github.com/computer-mcp/plugin-codex/blob/master/VERSIONING.md), which adopts the organization's rules and records the native artifact promotion -exception. This reference records release facts, procedures and checks. +and editable-asset exceptions. This reference records release facts, procedures and checks. ## Components and Version Sources @@ -212,7 +212,7 @@ python3 -m unittest discover -s Tests -p 'test_host_acceptance.py' -v The dry run checks the source manifest, positive integer `plugin_api`, declared archive set, CI attempt and artifact digests, native inventories, - byte-identical manifests and repository release immutability. It omits tag + and byte-identical manifests. It omits tag and signature checks and reads no catalog secret. Inspect the `assets/` directory in the `plugin-release--` Actions artifact. 3. Accept those exact archive bytes through the runtime checks above and record @@ -227,8 +227,7 @@ python3 -m unittest discover -s Tests -p 'test_host_acceptance.py' -v ``` Verification checks GitHub's tag signature result, the tag's commit and the - manifest version, and refuses if repository release immutability is disabled - or cannot be verified. The verification job has only `contents: read` and + manifest version. The verification job has only `contents: read` and `actions: read`, receives no secrets, executes the release workflow's revision, and treats the accepted source and CI files as data. Only the publishing job has `contents: write`; it downloads the verified bundle by its @@ -242,10 +241,12 @@ the organization's [release content contract](https://github.com/computer-mcp/.github/blob/master/VERSIONING.md#plugin-release-contents) and [Codex promotion contract](https://github.com/computer-mcp/.github/blob/master/VERSIONING.md#codex-promotion-exception). -Publication uploads the unified receipt first to freeze provenance, then the -archives and native receipts, then checksums. Every asset's API size and SHA-256 -must match before the draft becomes public. The publication response must report -`immutable: true`. Release notes remain operator-owned. +Publication uploads the unified receipt first, then the archives and native +receipts, then checksums. It verifies every asset's API state, size and SHA-256 +before and after publication. Release notes remain operator-owned. Workflows +for the same tag are queued, and maintainers edit attachments only after the +workflow finishes. A manual replacement must include corresponding provenance +and checksum files. Consumer digest changes require separate approval. ### Catalog notification @@ -275,20 +276,20 @@ dependent job only after confirmed publication. Only that job receives Use **Re-run failed jobs** after a failed publication. A publish-only retry uses the original bundle artifact ID and digest outputs, including after a workflow -run attempt changes. If verification reruns, a complete uploaded draft receipt -wins over `source_run`: recovery validates its recorded successful historical CI -attempt, fetches each artifact by its recorded ID and digest, and reproduces the -same receipt and checksums. It never selects a newer CI attempt or changes the -recorded workflow identity. - -Expected `starter` assets can be deleted and uploaded again only while the -Release is a draft. Matching completed assets are retained. Unexpected names, -conflicting digests or sizes, or an invalid historical attempt fail without -replacement. If a recorded artifact expired or disappeared, delete the -unpublished draft, obtain fresh successful CI artifacts, and dispatch publication -again to start a new assembly. For an existing public Release, a rerun checks -the exact asset set against the frozen receipt, requires `immutable: true`, -and reports it already published without writes or reliance on CI retention. +run attempt changes. If publication succeeded but its response or readback +failed, a publish-only retry checks the public release against that bundle and +allows catalog notification without modifying the release. When verification +reruns, it reconstructs the complete +bundle from the supplied successful `source_run`, its latest attempt's exact +artifacts, native receipts and the current trusted workflow revision. The +existing assets must match those bytes. Expired, missing or conflicting CI and +asset evidence fails visibly. Resolve stale or incomplete draft assets manually +before retrying. Matching completed assets are retained. + +Verification of an existing public Release is read-only and skips publication +and catalog notification. This includes a Release removed after verification. +Public attachments and their receipts can be edited, so they are checked against +the independently reconstructed bundle. For a missed or failed catalog notification, rerun only the notifier or dispatch: @@ -319,10 +320,9 @@ Changes to compiled source, dependencies or packaging inputs require a new archive, including changes to the shipped manual. Local rechecks after checker-only changes can use unchanged archive bytes with the new checker revision recorded separately. -Publication still uses source CI artifacts for the exact accepted commit and -the provenance frozen in the draft receipt. A new CI identity can be selected -before provenance freezes or after deleting an unpublished draft, as described -in [Retry](#retry). +Publication uses source CI artifacts for the exact accepted commit. A retry +requires the existing assets to match the supplied CI run and workflow, as +described in [Retry](#retry). Source tests do not replace installed-package or authenticated runtime evidence. Preserve failed results and distinguish fixture, product and external failures. @@ -338,7 +338,7 @@ operator decision. | Release workflow validation | `python3 scripts/check-workflow.py --check-release-workflow` and `python3 -m unittest discover -s Tests -p 'test_*.py'` | Local files; no host, vendor or credentials | | Candidate build | `python3 scripts/package.py --output dist --configuration release` | Local build tools and resolved dependencies; new output directory | | Archive and runtime acceptance | [Runtime acceptance](#runtime-acceptance) | Verified archive, installed host and vendor; authorized file-store login for full mode | -| Dry run and publication | [Publish](#publish) | Actions dispatch; verified immutable-release setting; publication job has contents write access | +| Dry run and publication | [Publish](#publish) | Actions dispatch; publication job has contents write access | | Interrupted-run recovery and catalog status | [Retry](#retry) | Actions access; catalog authority isolated to the notifier | | Install, upgrade and rollback | [Installation](Installation.md) | Host owner authority | | Cleanup | Manual inventory and removal after confirming inactivity and cleanup receipts | Ownership of each disposable output | diff --git a/Tests/test_plugin_release.py b/Tests/test_plugin_release.py index 519384f..abe182e 100644 --- a/Tests/test_plugin_release.py +++ b/Tests/test_plugin_release.py @@ -89,7 +89,6 @@ def __init__(self, archives): self.tag_commit = COMMIT self.verified = True self.reason = "valid" - self.immutability = {"enabled": True, "enforced_by_owner": False} self.install_artifact(20, archives) def run(self, **changes): @@ -125,8 +124,6 @@ def get(self, path): route = self._record("GET", path) if route == "": result = {"default_branch": "main"} - elif route == "/immutable-releases": - result = self.immutability elif route.startswith("/contents/computer-mcp-plugin.toml?"): assert parse_qs(urlsplit(route).query) == {"ref": [self.tag_commit]} result = {"type": "file", "encoding": "base64", "content": base64.b64encode(self.manifest).decode()} @@ -198,7 +195,7 @@ def add_draft(self): def publish_release(self, release_id=50): item = self.releases[release_id] if item["draft"]: - item.update(draft=False, immutable=self.immutability.get("enabled") is True) + item.update(draft=False, immutable=False) return item def add_asset(self, name, data=b"", state="uploaded", release_id=50): @@ -217,14 +214,11 @@ def send(self, method, path, data=None, content_type="application/json"): step = parse_qs(urlsplit(route).query)["name"][0] elif method == "PATCH": step = "publish" - elif method == "DELETE": - step = "delete" else: raise AssertionError((method, route)) self._failure(step, "before") if step != "draft": - release_id = (self.assets[int(route.split("/")[3])]["release_id"] if step == "delete" - else int(route.split("/")[2])) + release_id = int(route.split("/")[2]) if self.releases[release_id].get("immutable") is True: raise release.APIError(422, path) self.writes.append((step, copy.deepcopy(data))) @@ -236,11 +230,6 @@ def send(self, method, path, data=None, content_type="application/json"): if data.get("draft") is False: self.publish_release(result["id"]) result.update(data) - elif step == "delete": - asset_id = int(route.split("/")[3]) - del self.assets[asset_id] - del self.asset_bytes[asset_id] - result = None else: release_id = int(route.split("/")[2]) assert not any(item["name"] == step for item in self.assets.values()) @@ -290,7 +279,9 @@ def test_first_publication_order_fields_checksums_and_notes(self): outputs = self.verify() self.assertEqual(self.api.writes, []) self.assertEqual(self.publish(), {"published": "true", "release_id": "50", "tag": TAG}) - self.assertIs(self.api.releases[50]["immutable"], True) + self.assertFalse(any(method == "DOWNLOAD" and "/releases/assets/" in path + for method, path in self.api.calls)) + self.assertIs(self.api.releases[50]["immutable"], False) self.assertEqual([step for step, _ in self.api.writes], ["draft", release.RECEIPT, ARCHIVE, NATIVE, release.SUMS, "publish"]) self.assertEqual(self.api.releases[50]["body"], "Operator acceptance notes") @@ -322,73 +313,29 @@ def test_failures_before_and_after_every_publication_step_are_recoverable(self): self.api.fail = (step, when) with self.assertRaises(release.APIError): self.publish() + before_retry = copy.deepcopy(self.api.writes) self.assertEqual(self.publish()["published"], "true") + if (step, when) == ("publish", "after"): + self.assertEqual(self.api.writes, before_retry) self.assertEqual({item["name"]: self.api.asset_bytes[item["id"]] for item in self.api.assets.values()}, expected) - def test_partial_upload_then_ci_rerun_recovers_identical_frozen_bundle(self): - self.verify() + def test_draft_recovery_requires_same_ci_and_workflow(self): + self.frozen_draft() original = self.files() - self.api.fail = (ARCHIVE, "before") - with self.assertRaises(release.APIError): - self.publish() - self.api.rerun_ci(native_files(payload=b"new CI bytes")) - self.api.runs[10]["conclusion"] = "failure" - self.api.calls.clear() - self.verify_again(source_run=999, workflow_ref=WORKFLOW_REF + "-updated", workflow_sha="d" * 40) + self.verify_again() self.assertEqual(self.files(self.root / "recovered"), original) - self.assertIn(("GET", API_ROOT + "/actions/runs/10/attempts/1"), self.api.calls) - self.assertIn(("DOWNLOAD", API_ROOT + "/actions/artifacts/20/zip"), self.api.calls) - self.assertFalse(any(path.endswith("/actions/runs/10") or "/attempts/2" in path - or "/actions/runs/999" in path for _, path in self.api.calls)) - self.output = self.root / "recovered" - self.publish() - self.assertEqual([name for name, _ in self.api.writes].count(release.RECEIPT), 1) - - def test_recovery_refuses_invalid_or_missing_historical_attempt(self): - self.frozen_draft() - for field, value in (("event", "workflow_dispatch"), ("head_branch", "other"), - ("head_sha", "d" * 40), ("path", ".github/workflows/other.yml"), - ("head_repository", {"full_name": "fork/plugin"}), - ("conclusion", "failure"), ("status", "in_progress"), - ("id", 99), ("run_attempt", 99)): - with self.subTest(field=field), patch.dict(self.api.attempts[10, 1], {field: value}): - self.assert_no_writes(self.verify_again, "CI must|Recorded CI attempt") - del self.api.attempts[10, 1] - self.assert_no_writes(self.verify_again, "Cannot validate recorded CI attempt.*404") - - def test_recovery_refuses_artifact_outside_recorded_attempt(self): - self.frozen_draft() - self.api.artifacts[20]["created_at"] = "2026-01-02T00:05:00Z" - self.assert_no_writes(self.verify_again, "not created within the recorded CI attempt") + self.api.rerun_ci(native_files(payload=b"new CI bytes")) + self.assert_no_writes(lambda: self.verify(output=self.root / "changed-ci"), "conflicts") + self.api.runs[10] = self.api.attempts[10, 1] + self.assert_no_writes(lambda: self.verify(output=self.root / "changed-workflow", workflow_sha="d" * 40), + "conflicts") - def test_starters_at_every_upload_position_are_replaced_only_in_drafts(self): - self.verify() - files = self.files() - for name in (release.RECEIPT, ARCHIVE, NATIVE, release.SUMS): - with self.subTest(name=name): - self.api = FakeGitHub(self.native) - self.api.add_draft() - if name != release.RECEIPT: - self.api.add_asset(release.RECEIPT, files[release.RECEIPT]) - self.api.add_asset(name, b"partial", state="starter") - self.publish() - self.assertIn("delete", [step for step, _ in self.api.writes]) - self.assertEqual({item["name"]: self.api.asset_bytes[item["id"]] - for item in self.api.assets.values()}, files) - - def test_starter_deletion_failure_before_and_after_is_recoverable(self): + def test_starter_asset_requires_operator_resolution(self): self.frozen_draft() - for when in ("before", "after"): - with self.subTest(when=when): - self.api.add_asset(ARCHIVE, state="starter") - self.api.fail = ("delete", when) - with self.assertRaises(release.APIError): - self.publish() - self.publish() - self.api = FakeGitHub(self.native) - self.api.add_draft() - self.api.add_asset(release.RECEIPT, self.files()[release.RECEIPT]) + self.api.add_asset(ARCHIVE, b"partial", state="starter") + self.assert_no_writes(self.verify_again, "operator must resolve") + self.assert_no_writes(self.publish, "operator must resolve") def test_completed_conflicting_digest_size_or_state_is_never_replaced(self): self.verify() @@ -400,29 +347,82 @@ def test_completed_conflicting_digest_size_or_state_is_never_replaced(self): self.api.add_asset(name, self.files()[name])[field] = value self.assert_no_writes(self.publish, "conflicts") - def test_expired_or_missing_recorded_artifact_reports_explicit_recovery(self): - self.frozen_draft() - for missing in (False, True): - with self.subTest(missing=missing): - self.api.artifacts[20]["expired"] = True - if missing: - del self.api.artifacts[20] - self.assert_no_writes(self.verify_again, "delete the unpublished draft.*fresh successful CI") - - def test_published_rerun_needs_no_ci_retention_and_performs_no_writes(self): + def test_public_repeat_reconstructs_from_ci_and_is_read_only(self): self.verify() - expected = self.files() self.publish() - self.api.artifacts.clear() - self.api.attempts.clear() self.api.calls.clear() self.api.writes.clear() - self.verify_again(source_run=999, workflow_sha="d" * 40) - self.assertEqual(self.files(self.root / "recovered"), expected) - self.output = self.root / "recovered" + result = self.verify_again() + self.assertEqual(result["public_release"], "true") + self.assertEqual(self.files(self.root / "recovered"), self.files()) + self.assertIn(("DOWNLOAD", API_ROOT + "/actions/artifacts/20/zip"), self.api.calls) + for asset in self.api.assets.values(): + self.assertEqual(self.api.calls.count(("DOWNLOAD", API_ROOT + f"/releases/assets/{asset['id']}")), 1) + self.assertFalse(any("immutable-releases" in path for _, path in self.api.calls)) self.assertEqual(self.publish()["published"], "true") + outputs = self.root / "workflow-output" + arguments = [str(SCRIPT), "verify", "--repository", REPOSITORY, "--source-run", "10", + "--tag", TAG, "--publish", "true", "--workflow-ref", WORKFLOW_REF, + "--workflow-sha", WORKFLOW_SHA, "--output", str(self.root / "workflow-assets")] + with patch.object(sys, "argv", arguments), patch.dict(os.environ, {"GH_TOKEN": "fake", + "GITHUB_OUTPUT": str(outputs)}), patch.object(release, "GitHub", return_value=self.api), \ + redirect_stdout(io.StringIO()): + self.assertEqual(release.main(), 0) + self.api.releases.clear() + self.assertIn("public_release=true\n", outputs.read_text()) + self.assertIn("needs.verify.outputs.public_release == 'false'", workflow_job("publish")) self.assertEqual(self.api.writes, []) - self.assertFalse(any("/actions/" in path for _, path in self.api.calls)) + + def test_public_repeat_refuses_expired_ci_or_changed_workflow(self): + self.verify() + self.publish() + self.api.writes.clear() + self.api.artifacts[20]["expired"] = True + self.assert_no_writes(self.verify_again, "expired") + self.api.artifacts[20]["expired"] = False + self.assert_no_writes(lambda: self.verify(output=self.root / "other", workflow_sha="d" * 40), "conflicts") + self.api.runs[11] = self.api.run(id=11) + self.api.attempts[11, 1] = self.api.run(id=11) + self.api.install_artifact(21, self.native, workflow_run={"id": 11, "head_sha": COMMIT}) + self.assert_no_writes(lambda: self.verify(output=self.root / "other-run", source_run=11), "conflicts") + + def test_selected_attempt_must_be_available_and_valid(self): + for field, value in (("head_sha", "d" * 40), ("status", "in_progress"), + ("conclusion", "failure"), ("run_attempt", 2)): + with self.subTest(field=field), patch.dict(self.api.attempts[10, 1], {field: value}): + self.assert_no_writes(self.verify, "CI must|Recorded CI attempt") + del self.api.attempts[10, 1] + self.assert_no_writes(self.verify, "Cannot validate recorded CI attempt.*404") + + def test_public_repeat_rejects_self_consistent_replaced_assets(self): + self.verify() + self.publish() + receipt = json.loads(self.files()[release.RECEIPT]) + replacement = native_files(payload=b"manually replaced") + receipt["archives"] = [dict(release.file_record(ARCHIVE, replacement[ARCHIVE]), + native_receipt=release.file_record(NATIVE, replacement[NATIVE]))] + forged = release.assemble(receipt, replacement) + for asset in self.api.assets.values(): + data = forged[asset["name"]] + self.api.asset_bytes[asset["id"]] = data + asset.update(digest="sha256:" + release.sha256(data), size=len(data)) + self.api.writes.clear() + self.assert_no_writes(self.verify_again, "conflicts") + + def test_publication_readback_detects_asset_changes_after_publish(self): + self.verify() + original = self.api.send + + def send(method, path, data=None, content_type="application/json"): + result = original(method, path, data, content_type) + if method == "PATCH": + asset = next(item for item in self.api.assets.values() if item["name"] == ARCHIVE) + asset["digest"] = "sha256:" + "0" * 64 + return result + + with patch.object(self.api, "send", side_effect=send), \ + self.assertRaisesRegex(release.ReleaseError, "conflicts"): + self.publish() def test_published_assets_cannot_be_incomplete_conflicting_or_unexpected(self): self.verify() @@ -443,53 +443,6 @@ def test_published_assets_cannot_be_incomplete_conflicting_or_unexpected(self): asset["digest"] = "sha256:" + "0" * 64 self.assert_no_writes(self.publish, "incomplete|conflicts|unexpected") - def test_repository_immutability_must_be_verifiable_and_enabled(self): - self.verify() - for enabled in (False, None): - with self.subTest(enabled=enabled): - self.api.immutability["enabled"] = enabled - self.assert_no_writes(self.publish, "Enable release immutability") - original = self.api.get - def get(path): - if path.endswith("/immutable-releases"): - raise release.APIError(403, path) - return original(path) - with patch.object(self.api, "get", side_effect=get): - self.assert_no_writes(self.publish, "Cannot verify repository release immutability") - - def test_public_but_mutable_release_is_refused_even_after_setting_enabled(self): - self.verify() - self.api.immutability["enabled"] = False - self.api.add_draft() - self.api.publish_release() - self.api.immutability["enabled"] = True - self.assert_no_writes(self.publish, "public but mutable") - self.assert_no_writes(self.verify_again, "public but mutable") - - def test_publish_requires_immutable_true_in_publication_response(self): - self.verify() - original = self.api.send - def send(method, path, data=None, content_type="application/json"): - result = original(method, path, data, content_type) - if method == "PATCH": - result["immutable"] = False - return result - with patch.object(self.api, "send", side_effect=send): - with self.assertRaisesRegex(release.ReleaseError, "public but mutable"): - self.publish() - - def test_publication_race_is_blocked_by_immutable_release_server(self): - self.verify() - self.api.add_draft() - original = self.api.send - def send(method, path, data=None, content_type="application/json"): - if method == "POST" and "/assets?" in path: - self.api.publish_release() - return original(method, path, data, content_type) - with patch.object(self.api, "send", side_effect=send), self.assertRaises(release.APIError): - self.publish() - self.assertEqual(self.api.assets, {}) - def test_tag_signature_annotation_and_exact_target_are_required(self): for field, value, pattern in (("tag_type", "commit", "annotated"), ("verified", False, "signature"), ("reason", "unknown_key", "signature"), @@ -639,7 +592,7 @@ def test_dry_run_cli_reports_publication_conditions(self): patch.object(release, "GitHub", return_value=self.api), redirect_stdout(output): self.assertEqual(release.main(), 0) self.assertIn("signed annotated v0.2.0", output.getvalue()) - self.assertIn("immutable published Release", output.getvalue()) + self.assertIn("manual acceptance in Release notes", output.getvalue()) self.assertEqual(self.api.writes, []) def test_receipt_validation_rejects_noncanonical_or_invalid_provenance(self): @@ -665,7 +618,9 @@ def test_job_graph_permissions_and_frozen_output_checks(self): source = WORKFLOW.read_text() mutations = [ (" contents: read", " contents: write"), - (" if: inputs.publish\n", " if: always()\n"), + ("needs.verify.outputs.public_release == 'false'", "true"), + (" public_release: ${{ steps.bundle.outputs.public_release }}", ""), + (" queue: max\n", " cancel-in-progress: true\n"), ("needs.verify.outputs.artifact_id", "github.run_attempt"), ("needs.verify.outputs.asset_digests", "inputs.asset_digests"), ("needs.publish.outputs.published == 'true'", "always()"), @@ -718,12 +673,14 @@ def run_helper(arguments, check): with patch.dict(os.environ, environment), patch.object(subprocess, "run", side_effect=run_helper), \ redirect_stdout(io.StringIO()), redirect_stderr(io.StringIO()): if attempt == 1: - case.api.fail = (release.SUMS, "before") + case.api.fail = ("publish", "after") with self.assertRaises(subprocess.CalledProcessError): exec(compile(script, str(WORKFLOW), "exec"), {}) else: + writes_before_retry = copy.deepcopy(case.api.writes) exec(compile(script, str(WORKFLOW), "exec"), {}) self.assertIn("published=true", (runner / "output").read_text()) + self.assertEqual(case.api.writes, writes_before_retry) self.assertEqual({item["name"]: case.api.asset_bytes[item["id"]] for item in case.api.assets.values()}, expected) diff --git a/VERSIONING.md b/VERSIONING.md index 6c8ad8d..a7f4f80 100644 --- a/VERSIONING.md +++ b/VERSIONING.md @@ -11,6 +11,17 @@ uses its own release workflow to promote accepted CI archives and native build receipts under the organization's Codex promotion contract, with `reproduction: ci-artifact-promotion`, instead of the reusable rebuild workflow. +## Editable release assets + +Codex release assets can be edited by a maintainer after publication, and +publication does not require the GitHub release immutability setting. The +publisher verifies existing assets against the accepted CI artifacts and the +current release workflow. A public repeat is read-only and requires retained CI +evidence. Draft recovery creates missing assets and requires an operator to +resolve incomplete or conflicting assets. Manual edits must update corresponding +receipts and checksums. Consumers that pin digests require a separate approval +and update. + ## Release notes Breaking changes include migration guidance in the Release notes. diff --git a/scripts/check-workflow.py b/scripts/check-workflow.py index 910d1cb..5871b31 100644 --- a/scripts/check-workflow.py +++ b/scripts/check-workflow.py @@ -33,6 +33,8 @@ def require(condition, message): require(set(jobs) == {"verify", "publish", "notify-catalog"}, "Unexpected release job graph") require("\npermissions: {}\n" in source, "Release permissions must default to none") + require(" group: plugin-release-${{ inputs.release_tag || github.run_id }}\n queue: max\n" in source, + "Release workflows must queue writers by tag") verify, publish, notify = (jobs[name] for name in ("verify", "publish", "notify-catalog")) require(" permissions:\n contents: read\n actions: read\n" in verify, "Verification requires read-only contents and actions") @@ -42,7 +44,9 @@ def require(condition, message): "Verification must execute the workflow revision without persisted credentials") require("scripts/plugin_release.py verify" in verify and "--publish" in verify, "Verification must assemble both publication and dry-run bundles") - require(" if: inputs.publish\n needs: verify\n" in publish + require(" public_release: ${{ steps.bundle.outputs.public_release }}\n" in verify, + "Verification must report an observed public release") + require(" if: inputs.publish && needs.verify.outputs.public_release == 'false'\n needs: verify\n" in publish and " permissions:\n contents: write\n" in publish, "Only publication may write after verification") require("actions: read" not in publish and "secrets" not in publish diff --git a/scripts/plugin_release.py b/scripts/plugin_release.py index 8ad83a5..389fbf5 100644 --- a/scripts/plugin_release.py +++ b/scripts/plugin_release.py @@ -238,32 +238,25 @@ def select_ci(api, repository, commit, run_id, declared): "artifacts": sorted(selected, key=lambda item: item["id"])} -def get_ci_files(api, repository, commit, ci, declared, recovering=False): +def get_ci_files(api, repository, commit, ci, declared): root = repository_path(repository) - recovery = ("Recorded CI artifact is expired or missing; delete the unpublished draft release, " - "obtain fresh successful CI artifacts, then rerun release.yml to select fresh CI provenance") require(len(ci["artifacts"]) == len(declared), "Expected one CI artifact per declared archive") attempt = check_attempt(api, root, repository, commit, ci["run_id"], ci["run_attempt"]) files = {} for source in ci["artifacts"]: - try: - artifact = api.get(f"{root}/actions/artifacts/{source['id']}") - if artifact.get("expired"): - raise APIError(410, "recorded CI artifact") - require(artifact.get("id") == source["id"] and artifact.get("digest") == source["digest"], - "CI artifact digest or ID conflicts with provenance") - require(artifact.get("workflow_run", {}).get("id") == ci["run_id"] - and artifact.get("workflow_run", {}).get("head_sha") == commit, - "CI artifact belongs to another run or commit") - require(within_attempt(artifact, attempt), "CI artifact was not created within the recorded CI attempt") - names = [name for name in declared if artifact.get("name") == name[:-4] + "-" + commit] - require(len(names) == 1, "CI artifact name differs from the manifest") - name = names[0] - data = api.download(f"{root}/actions/artifacts/{source['id']}/zip", accept="application/vnd.github+json") - except APIError as error: - if recovering and error.status in (404, 410): - raise ReleaseError(recovery) from None - raise + artifact = api.get(f"{root}/actions/artifacts/{source['id']}") + if artifact.get("expired"): + raise APIError(410, "recorded CI artifact") + require(artifact.get("id") == source["id"] and artifact.get("digest") == source["digest"], + "CI artifact digest or ID conflicts with provenance") + require(artifact.get("workflow_run", {}).get("id") == ci["run_id"] + and artifact.get("workflow_run", {}).get("head_sha") == commit, + "CI artifact belongs to another run or commit") + require(within_attempt(artifact, attempt), "CI artifact was not created within the recorded CI attempt") + names = [name for name in declared if artifact.get("name") == name[:-4] + "-" + commit] + require(len(names) == 1, "CI artifact name differs from the manifest") + name = names[0] + data = api.download(f"{root}/actions/artifacts/{source['id']}/zip", accept="application/vnd.github+json") require(sha256(data) == digest_value(source["digest"]), "Downloaded CI artifact digest mismatch") contents = zip_entries(data) require(set(contents) == {name, "receipt.json"}, "CI artifact must contain its native archive and receipt.json") @@ -283,11 +276,6 @@ def find_release(api, root, tag): return matches[0] if matches else None -def check_immutable_release(release): - require(release.get("immutable") is True, - "Release is public but mutable; the repository owner must handle it (immutable: true required)") - - def release_assets(api, root, release): assets = api.list(f"{root}/releases/{release['id']}/assets") names = [asset["name"] for asset in assets] @@ -377,24 +365,14 @@ def assemble(receipt, native_files): return files -def check_assets(assets, files, draft, complete=False): +def check_assets(assets, files, complete=False): require(set(assets) <= set(files), "Release contains unexpected assets") if complete: require(set(assets) == set(files), "Release asset set is incomplete") for name, asset in assets.items(): - if asset.get("state") == "starter" and draft and not complete: - continue require(asset.get("state") == "uploaded" and asset.get("digest") == "sha256:" + sha256(files[name]) - and asset.get("size") == len(files[name]), f"Completed release asset conflicts: {name}") - - -def check_repository_immutability(api, root): - try: - immutable = api.get(f"{root}/immutable-releases") - except APIError as error: - raise ReleaseError(f"Cannot verify repository release immutability: {error}") from None - require(immutable.get("enabled") is True, - "Enable release immutability in the plugin repository before publishing") + and asset.get("size") == len(files[name]), + f"Release asset conflicts or is incomplete: {name}; operator must resolve it") def verify_native_files(files, manifest, parent): @@ -432,47 +410,35 @@ def verify(api, repository, source_run, tag, publish, workflow_ref, workflow_sha "Release source manifest must be a file with base64 contents") manifest_bytes = base64.b64decode(source["content"]) info, declared = manifest_info(tomllib.loads(manifest_bytes.decode()), tag) - check_repository_immutability(api, root) release = find_release(api, root, tag) - if release: - if release["draft"]: - require(release["target_commitish"] == commit, "Draft release target differs from the verified commit") - else: - check_immutable_release(release) - assets = release_assets(api, root, release) if release else {} - receipt = None - if RECEIPT in assets and assets[RECEIPT].get("state") == "uploaded": - receipt = validate_receipt(read_asset(api, root, assets[RECEIPT])) - require(all(receipt[key] == value for key, value in info.items()) - and receipt["tag"] == tag and receipt["commit"] == commit, - "Frozen receipt differs from release source") - if release and not release["draft"]: - require(receipt is not None, "Published release lacks a complete receipt; it cannot be modified") - expected = payload_names(receipt) | {RECEIPT, SUMS} - require(set(assets) == expected, "Published release asset set differs") - native_files = {name: read_asset(api, root, assets[name]) for name in payload_names(receipt)} - else: - ci = receipt["ci"] if receipt else select_ci(api, repository, commit, source_run, declared) - native_files = get_ci_files(api, repository, commit, ci, declared, recovering=receipt is not None) + if release and release["draft"]: + require(release["target_commitish"] == commit, "Draft release target differs from the verified commit") + ci = select_ci(api, repository, commit, source_run, declared) + native_files = get_ci_files(api, repository, commit, ci, declared) require(not output.exists(), "Release output directory must not exist") output.parent.mkdir(parents=True, exist_ok=True) verify_native_files(native_files, manifest_bytes, output.parent) - if receipt is None: - receipt = dict(info, schema=1, tag=tag, commit=commit, - archives=[dict(file_record(name, native_files[name]), - native_receipt=file_record(name[:-4] + ".receipt.json", - native_files[name[:-4] + ".receipt.json"])) - for name in declared], ci=ci, - workflow={"ref": workflow_ref, "sha": workflow_sha}, reproduction="ci-artifact-promotion") + receipt = dict(info, schema=1, tag=tag, commit=commit, + archives=[dict(file_record(name, native_files[name]), + native_receipt=file_record(name[:-4] + ".receipt.json", + native_files[name[:-4] + ".receipt.json"])) + for name in declared], ci=ci, + workflow={"ref": workflow_ref, "sha": workflow_sha}, reproduction="ci-artifact-promotion") require(receipt["workflow"]["ref"].startswith(repository + "/" + WORKFLOW), "Receipt workflow belongs to another repository") files = assemble(receipt, native_files) if release: - check_assets(assets, files, release["draft"], complete=not release["draft"]) + assets = release_assets(api, root, release) + check_assets(assets, files, complete=not release["draft"]) + if not release["draft"]: + for name, asset in assets.items(): + require(read_asset(api, root, asset) == files[name], f"Release asset bytes conflict: {name}") output.mkdir() for name, data in files.items(): (output / name).write_bytes(data) - return {"commit": commit, "tag": tag or "", "asset_digests": json.dumps( + return {"commit": commit, "tag": tag or "", + "public_release": "true" if release and not release["draft"] else "false", + "asset_digests": json.dumps( {name: sha256(data) for name, data in files.items()}, sort_keys=True, separators=(",", ":"))} @@ -500,7 +466,6 @@ def publish_bundle(api, repository, directory, expected_digests): require(receipt["tag"] is not None, "Cannot publish an untagged dry-run bundle") commit, tag = resolve(api, repository, receipt["tag"]) require(commit == receipt["commit"], "Release tag moved after verification") - check_repository_immutability(api, root) release = find_release(api, root, tag) if release is None: release = api.send("POST", f"{root}/releases", { @@ -511,47 +476,43 @@ def publish_bundle(api, repository, directory, expected_digests): def current(): observed = api.get(f"{root}/releases/{release_id}") require(observed["tag_name"] == tag, "Release tag changed") - if not observed["draft"]: - check_immutable_release(observed) return observed def draft(): observed = current() - require(observed["draft"], "Release became public; rerun to verify its immutable assets") + require(observed["draft"], "Release became public; rerun read-only verification") require(observed["target_commitish"] == commit, "Draft release target differs from the verified commit") release = current() assets = release_assets(api, root, release) - check_assets(assets, files, release["draft"], complete=not release["draft"]) + check_assets(assets, files, complete=not release["draft"]) if not release["draft"]: return {"published": "true", "release_id": str(release_id), "tag": tag} draft() - # Receipt-first upload freezes provenance before any archive is exposed. + # Upload provenance before the associated archives. archives = [item["name"] for item in receipt["archives"]] natives = [item["native_receipt"]["name"] for item in receipt["archives"]] for name in [RECEIPT, *archives, *natives, SUMS]: assets = release_assets(api, root, release) - check_assets(assets, files, True) + check_assets(assets, files) asset = assets.get(name) if asset and asset["state"] == "uploaded": continue - if asset: - draft() - api.send("DELETE", f"{root}/releases/assets/{asset['id']}") draft() content_type = "application/zip" if name.endswith(".zip") else "application/json" if name.endswith(".json") else "text/plain" uploaded = api.send("POST", f"{root}/releases/{release_id}/assets?{urlencode({'name': name})}", files[name], content_type) - check_assets({name: uploaded}, {name: files[name]}, True, complete=True) + check_assets({name: uploaded}, {name: files[name]}, complete=True) draft() - check_assets(release_assets(api, root, release), files, True, complete=True) + check_assets(release_assets(api, root, release), files, complete=True) require(resolve(api, repository, tag) == (commit, tag), "Release tag moved during publication") draft() # Publishing changes only visibility; release notes remain operator-owned. published = api.send("PATCH", f"{root}/releases/{release_id}", {"draft": False}) require(published.get("draft") is False and published.get("tag_name") == tag, "Release did not become public") - check_immutable_release(published) - check_assets(release_assets(api, root, published), files, False, complete=True) + published = current() + require(not published["draft"], "Release did not remain public") + check_assets(release_assets(api, root, published), files, complete=True) return {"published": "true", "release_id": str(release_id), "tag": tag} @@ -581,7 +542,7 @@ def main(): version = json.loads((args.output / RECEIPT).read_bytes())["version"] print("Dry run: no Release writes or catalog notification. Publication additionally requires " "a signed annotated v" + version + " tag at the verified commit passing GitHub signature " - "verification, manual acceptance in Release notes, and an immutable published Release.") + "verification and manual acceptance in Release notes.") else: result = publish_bundle(api, args.repository, args.directory, args.asset_digests) if "GITHUB_OUTPUT" in os.environ: From e81efc7191c8b77643715721eba0e04e6ba96646 Mon Sep 17 00:00:00 2001 From: showxu <10173746+showxu@users.noreply.github.com> Date: Fri, 4 Dec 2026 07:33:18 +0800 Subject: [PATCH 3/3] test: pin the Host release candidate for plugin checks --- .github/computer-mcp-host.sha | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/computer-mcp-host.sha b/.github/computer-mcp-host.sha index e888ed9..1a0e196 100644 --- a/.github/computer-mcp-host.sha +++ b/.github/computer-mcp-host.sha @@ -1 +1 @@ -88402a605dc5383cbed7babd547419cb93893a73 +dec7150f3dc94411c290309e6f26e59d95da248d