From 586929fde5c9323a534442190dd97d2513311df0 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 1 Nov 2026 19:45:08 -0800 Subject: [PATCH 1/6] chore(quest): claim quest/m1/shared-version.md Quest-Claim: ff3168453fd3f1cd From a632093b474cbcd9730cbf01872dad2c707904b9 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 1 Nov 2026 19:54:31 -0800 Subject: [PATCH 2/6] chore(release): add shared-minor cut tooling Co-Authored-By: GPT-6.1 Sol --- .github/justfile | 2 + CONTRIBUTING.md | 35 ++++- justfile | 4 + quest/m1/README.md | 1 - quest/m1/shared-version.md | 91 ------------ quest/m2/release/cut.md | 6 +- sh/version.py | 264 ++++++++++++++++++++++++++++++++++ sh/version.test.py | 283 +++++++++++++++++++++++++++++++++++++ version.json | 7 + 9 files changed, 595 insertions(+), 98 deletions(-) delete mode 100644 quest/m1/shared-version.md create mode 100644 sh/version.py create mode 100644 sh/version.test.py create mode 100644 version.json diff --git a/.github/justfile b/.github/justfile index 6804c4b08f8..7b9b0aee19f 100644 --- a/.github/justfile +++ b/.github/justfile @@ -23,6 +23,7 @@ runner-vm: # Lint GitHub Actions workflows, their security, their alert coverage, that every step runs a recipe, and that every opt-in test has a caller. check: + python3 sh/version.py actionlint zizmor --offline --quiet .github sh/gh/alert.sh check-coverage @@ -33,6 +34,7 @@ check: # Tests of repository tooling; every `just check` and `just ci` runs them. test: + python3 sh/version.test.py python3 sh/local.test.py python3 test/smoke/runner.test.py python3 sh/coverage.test.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 174f45da228..0e97d434e36 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -92,7 +92,7 @@ For an advisory against Quinn, follow the advisory triage in [`rs/moq-quic/READM `main` is the trunk; `release` is what ships, and release-plz and every branch-triggered publish run only there. - Smoke clients call only the latest published APIs. A release cut updates `test/smoke/clients` to the APIs being published, then verifies the affected smoke lanes. -- A release is cut by hand: a PR merging `main` into `release`, with a merge commit. +- A release is cut by hand: a PR merging `main` into `release`, with a merge commit. After the pre-cut merge of `release` into `main`, run `just version 0.22.0` on `main` for the first shared cut, or the next shared minor for later cuts. Commit the resulting versions and lockfiles before opening the cut PR. Run `just version` to check them. - A breaking cut first writes, on `main`, each changed package's version-transition section in its `MIGRATE.md` (`## 0.3 -> 0.4`) from the migration audit: the `!` subjects since the `release` merge base, each of those PRs' Impact section, and the API diff. - Suggest a `release` backport for any serious bug fix (crash, security, data loss, broken interop), whether found on `main` or reported against a release. Land it on `main` first, then port it onto `release` as a separate PR that keeps the published API, so it ships as a patch. The Release gate's API diff (`just api-diff --deny`) fails a backport that changes one; on the cut PR, whose head is `main`, it only reports. - After any release publishes, patch or breaking, run `just test wire-compat --remeasure` on `main` and land the rewritten `test/interop/compat/planned-breaks.json` with refreshed reasons. Otherwise the nightly wire-compat check fails on the stale pins. @@ -100,12 +100,41 @@ For an advisory against Quinn, follow the advisory triage in [`rs/moq-quic/READM # Versions -Releases are cut separately; bump only when asked. Each package's version lives in one place: +Releases are cut separately; bump only when asked. Every published MoQ package +shares one minor across ecosystems, including unchanged packages at each cut. +The first shared cut is `0.22.0`; later cuts advance the minor together. Patch +versions stay independent per package, including Rust: release-plz has no +`version_group`. + +`kio`, `kio-macros`, `qmux`, and npm `@moq/qmux` keep their own version lines; +`@moq/signals` joins the shared minor. New experiments start at `0.0.x`. +A published library's normal or build dependency on an experimental package +in the same ecosystem promotes that package into the shared minor, including +optional and target-specific dependencies. Dev dependencies and binary-only +Rust dependents do not promote it. Unpublished/private packages are excluded. +Thus `moq-uring` joins through the relay library, while `moq-archive` stays +experimental through the binary-only CLI and a dev dependency. + +`just version 0.22.0` sets eligible versions and workspace lock entries without +resolving unrelated dependencies. Rust requirements are updated by +`release-plz set-version`; disposable changelogs keep published history intact. +The recipe records the shared minor and named exemptions in `version.json`. +`just version` checks it on every `just check` and `just ci`; enforcement is +disabled while its minor is `null`, until the cut runs the recipe. Once active, +the check rejects minor drift, unpromoted dependencies, stale exemptions, and +mismatched npm/Python lock entries. + +The nonpublishing fixture in `sh/version.test.py` verifies that release-plz's +`update` engine, also used by `release-pr`, preserves a manually set unpublished +minor despite breaking commits. Run it when changing release-plz. No publish, +tag, or release workflow runs as part of `just version`. + +Each package's version lives in one place: - **Rust**: release-plz owns crate versions and Rust dependency requirements. - **JavaScript**: `js/*/package.json` packages with a `scripts.release` entry (skip private ones), plus the matching workspace version in `bun.lock`. - **Python**: `py/moq-rs/pyproject.toml`, plus the matching `moq-rs` entry in the root `uv.lock`; `py/moq-ffi` follows the `moq-ffi-v*` tag and Rust crate. - **Swift**: `swift/VERSION`. **Kotlin**: `moq.version` in `kt/gradle.properties`. **Dart**: `version` in `dart/moq/pubspec.yaml`. Their FFI counterparts track the Rust crate. -- **Go**: `go/wrapper/VERSION` holds a human-owned `MAJOR.MINOR` line; CI derives the patch, so only edit it for a breaking API. Leave the placeholder FFI version in `go.mod` alone. +- **Go**: `go/wrapper/VERSION` holds a human-owned `MAJOR.MINOR` line; CI derives the independent patch; the shared cut sets the minor. Leave the placeholder FFI version in `go.mod` alone. - **C++**: `cpp/moq/VERSION`, human-owned; a `cpp-v` tag releases it. - **OBS**: `cpp/obs/VERSION`, human-owned; each C++ release also cuts `obs-moq-v`, and refuses one whose version already names an earlier release. diff --git a/justfile b/justfile index e9a52a9ac78..9867db01b1a 100644 --- a/justfile +++ b/justfile @@ -134,6 +134,10 @@ fix $BASE="": oss-scanner *args: sh/oss-scanner.sh "$@" +# Set every eligible package to one minor at a release cut; omit to check. +version TARGET="": + python3 sh/version.py {{ if TARGET == "" { "" } else { quote(TARGET) } }} + # Build the packages. build: just js build diff --git a/quest/m1/README.md b/quest/m1/README.md index 55660210155..c01cbc5c375 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -193,7 +193,6 @@ per-frame CPU growth since #5926. - [A truncated MKV ends its tracks at finish](/quest/m1/mkv-truncated-finish.md) - `finish()` refusing truncated input still ends the tracks, so subscribers stop waiting - [moq-quic deletes its remaining 0-RTT code](/quest/m1/quic-zero-rtt-leftovers.md) - only the code that drops a 0-RTT packet remains, with a test - [Gate the no-em-dash rule](/quest/m1/em-dash-gate.md) - `just check` fails on an em dash in any tracked text file -- [Every package shares one minor version](/quest/m1/shared-version.md) - a recipe sets every published package to one minor at the cut (next: 0.22.0), and `just check` enforces it and the `0.0.x` rule for experiments ## Related diff --git a/quest/m1/shared-version.md b/quest/m1/shared-version.md deleted file mode 100644 index be93ef0e8ca..00000000000 --- a/quest/m1/shared-version.md +++ /dev/null @@ -1,91 +0,0 @@ -# [M] Every package shares one minor version - -## Goal - -Every published MoQ package, in every ecosystem (Rust crates, npm `@moq/*`, -Python, Swift, Kotlin, Dart, Go, C++, and OBS), ships with the same minor -version, so a release is announced as one number. The next breaking cut -publishes everything at `0.22.0`, and each later cut bumps them together to -the next minor, including packages that did not change. - -This quest delivers the tooling, check, and docs; the -[cut](/quest/m2/release/cut.md) applies the version. Patch versions stay -independent per package between cuts. Experiments stay on `0.0.x`. - -## Plan - -Decided 2026-11-01 (maintainer, via `/quest-plan`), for marketing: one minor -across the whole project. - -- Scope: every published package listed in CONTRIBUTING.md's Versions - section, not just Rust crates. - - Rust crates only - - Every package ✅ ("we can build some automation if needed") -- Shared version: `0.22.0`, the lowest above every published package - (crates.io has hang 0.21.19 and moq-native 0.20.0, so 0.20 is taken; every - npm, PyPI, pub.dev, and OBS release is below 0.7). - - 0.22.0 ✅ - - 0.30.0 -- Patch versions are independent, for Rust too: release-plz keeps bumping - each crate's patch on its own, so moq-net 0.22.3 beside hang 0.22.1 is - fine. No `version_group`; it lines up the patch versions too, which is not - wanted. ([moq-dev/moq#629](https://github.com/moq-dev/moq/pull/629) added - groups and [moq-dev/moq#726](https://github.com/moq-dev/moq/pull/726) - removed them without a recorded reason.) - - version_group - - Independent patches ✅ ("patch versions are not lockstep") -- Exempt by name, keeping their own versions: `kio`, `kio-macros`, `qmux`, - and npm `@moq/qmux`, because they are not MoQ-specific. `@moq/signals` - joins. `@moq/qmux` keeps its name and its own version line (decided - 2026-11-01): npm refused the unscoped `qmux` as too similar to the - unrelated `qm-ux`, and the maintainer chose to keep `@moq/qmux` over a - scoped or suffixed name. - - Join the group - - Exempt by name ✅ (Rust); npm: exempt `@moq/qmux` only ✅ -- New packages start at `0.0.x`. A `0.0.x` package that a published `0.x.y` - package depends on (normal or build dependency, same ecosystem) must join - the shared version. Today that promotes `moq-archive` (moq-cli depends on it) - and `moq-uring` (moq-relay's optional dependency). Every other `0.1+` crate - already has a `0.x.y` dependent. Unpublished packages (`publish = false`, - npm `private`) are exempt from both rules. -- Enforcement: a CI check in `just check`. - - CI check ✅ - - Docs only -- Bump timing: at the cut, not in this quest's PR, so the maintainer's - pre-cut merge of `release` into `main` doesn't conflict on every version - line and lockfile. - - In this quest's PR - - At the cut ✅ -- Milestone: m1, since it must land before the cut. - -Implementation guidance: - -- One recipe, for example `just version 0.22.0`, sets every eligible - package: `release-plz set-version` for each crate (which also rewrites - dependents' requirements), each `js/*/package.json` with a `release` script - plus `bun.lock`, `py/moq-rs/pyproject.toml` plus `uv.lock`, `swift/VERSION`, - `moq.version` in `kt/gradle.properties`, `dart/moq/pubspec.yaml`, - `go/wrapper/VERSION` (`0.22`), `cpp/moq/VERSION`, and `cpp/obs/VERSION`. - Packages that track the moq-ffi crate (py/moq-ffi, the FFI artifacts) need - no edit. The recipe also records the shared minor in one place, such as a - root file, for the check to read. -- The check reads Cargo metadata and the JS workspace, along with the other - version files. It fails when an eligible package's minor differs from the - recorded one, when a `0.0.x` package has a published `0.x.y` dependent, or - when an exemption names a package that no longer exists. Until the cut - records the shared minor, the check passes without enforcing (the bump - waits for the cut). Add a regression test for each failure. -- Verify that `release-plz release-pr` publishes a hand-set, unpublished - `0.22.0` as is, without bumping it again from breaking commits. If it - doesn't, the recipe must run where release-plz respects it, for example - inside the release PR. -- Update CONTRIBUTING.md's Versions section with the shared-minor rule, the - exemptions, the `0.0.x` rule, and the recipe. Update its release bullets so - a cut runs the recipe. - -Public API: none. Wire: none. - -## Related - -- [Cut and publish](/quest/m2/release/cut.md) - runs the recipe right after the pre-cut merge of `release` into `main` -- [Retire the web-transport JS qmux](/quest/m2/release/qmux-js-retire.md) - owns the `@moq/qmux` npm name this exempts diff --git a/quest/m2/release/cut.md b/quest/m2/release/cut.md index 7bef3bef7a6..b1bb4f5bd0f 100644 --- a/quest/m2/release/cut.md +++ b/quest/m2/release/cut.md @@ -10,9 +10,9 @@ package versions, and the release-triggered publication jobs complete. Follow CONTRIBUTING.md's release procedure: merge release into main first, then main into release using merge commits. Confirm the maintainer's cut instruction before executing it. Right after merging release into main, set -every eligible package to the next shared minor with the recipe from -[one minor version](/quest/m1/shared-version.md) (`0.22.0` for this cut, then -one minor up per cut), including packages that did not change. Rust +every eligible package with `just version 0.22.0` for this cut, then one +minor up per cut, following [Versions](/CONTRIBUTING.md#versions), including +packages that did not change. Rust publication remains owned by release-plz. This supersedes keeping `moq-rs` at its unpublished 0.6.0 (decided 2026-11-01). Run candidate compatibility, draft, package, and all-language interop checks, and verify diff --git a/sh/version.py b/sh/version.py new file mode 100644 index 00000000000..d5a96bb8345 --- /dev/null +++ b/sh/version.py @@ -0,0 +1,264 @@ +#!/usr/bin/env python3 +"""Set the shared release minor, or check it without enforcing before the first cut.""" + +import argparse +import json +import re +import subprocess +import sys +import tempfile +from dataclasses import dataclass, field +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +SEMVER = r"(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)" + + +def version(value): + if not re.fullmatch(SEMVER, value): + raise ValueError(f"expected a stable MAJOR.MINOR.PATCH version, got {value!r}") + return tuple(map(int, value.split("."))) + + +def replace(text, pattern, value): + """Change exactly one captured version, preserving surrounding formatting.""" + matches = list(re.finditer(pattern, text, re.MULTILINE | re.DOTALL)) + if len(matches) != 1: + raise ValueError(f"expected one version matching {pattern!r}, found {len(matches)}") + match = matches[0] + return text[: match.start(1)] + value + text[match.end(1) :] + + +@dataclass +class Package: + ecosystem: str + name: str + current: str + path: Path + library: bool = True + dependencies: set[str] = field(default_factory=set) + + @property + def key(self): + return self.ecosystem, self.name + + +# These wrappers have one independently owned version. Generated FFI packages +# take their version from the Rust crate and must not be edited here. +WRAPPERS = { + "python": ("moq-rs", "py/moq-rs/pyproject.toml", r'(?s:\[project\]\n(?:(?!\n\[).)*?\nversion = ")([^"\n]+)'), + "swift": ("moq", "swift/VERSION", r"^([^\n]+)$"), + "kotlin": ("moq", "kt/gradle.properties", r"^moq\.version=([^\n]+)$"), + "dart": ("moq", "dart/moq/pubspec.yaml", r"^version: ([^\n]+)$"), + "go": ("moq", "go/wrapper/VERSION", r"^([^\n]+)$"), + "cpp": ("moq", "cpp/moq/VERSION", r"^([^\n]+)$"), + "obs": ("moq", "cpp/obs/VERSION", r"^([^\n]+)$"), +} + + +def run(root, *args): + return subprocess.run(args, cwd=root, check=True, text=True, capture_output=True).stdout + + +def cargo_metadata(root): + return json.loads(run(root, "cargo", "metadata", "--no-deps", "--format-version", "1", "--locked")) + + +def packages(root, metadata=None): + metadata = cargo_metadata(root) if metadata is None else metadata + members = set(metadata["workspace_members"]) + rust = [p for p in metadata["packages"] if p["id"] in members and p["publish"] != []] + names = {Path(p["manifest_path"]).parent.resolve(): p["name"] for p in rust} + result = [] + for p in rust: + result.append( + Package( + "rust", + p["name"], + p["version"], + Path(p["manifest_path"]), + any(set(t["kind"]) - {"bin", "example", "test", "bench", "custom-build"} for t in p["targets"]), + { + names[Path(d["path"]).resolve()] + for d in p["dependencies"] + if d["kind"] != "dev" and d.get("path") and Path(d["path"]).resolve() in names + }, + ) + ) + workspace = json.loads((root / "package.json").read_text())["workspaces"] + for path in sorted({p / "package.json" for pattern in workspace for p in root.glob(pattern)}): + p = json.loads(path.read_text()) + if p.get("private") or "release" not in p.get("scripts", {}): + continue + result.append( + Package( + "npm", + p["name"], + p["version"], + path, + dependencies=set(p.get("dependencies", {})) + | set(p.get("optionalDependencies", {})) + | set(p.get("peerDependencies", {})), + ) + ) + for ecosystem, (name, path, pattern) in WRAPPERS.items(): + path = root / path + matches = list(re.finditer(pattern, path.read_text(), re.MULTILINE)) + if len(matches) != 1: + raise ValueError(f"{path}: expected one version") + value = matches[0][1] + if ecosystem == "go": + value += ".0" + result.append(Package(ecosystem, name, value, path)) + for package in result: + version(package.current) + return result + + +def eligible(packages, exemptions): + known = {p.key for p in packages} + exempt = {(ecosystem, name) for ecosystem, names in exemptions.items() for name in names} + if stale := exempt - known: + raise ValueError(f"exemptions name missing published packages: {sorted(stale)}") + selected = {p.key for p in packages if p.key not in exempt and version(p.current)[:2] != (0, 0)} + # Promotion follows normal/build dependencies, including optional and target + # dependencies, transitively. Binary-only Rust dependents expose no library API. + while True: + promoted = { + (p.ecosystem, name) + for p in packages + if p.key in selected and p.library + for name in p.dependencies + if (p.ecosystem, name) in known and (p.ecosystem, name) not in exempt + } + following = selected | promoted + if following == selected: + return [p for p in packages if p.key in selected] + selected = following + + +def lock_pattern(package, root): + if package.ecosystem == "npm": + path = package.path.parent.relative_to(root).as_posix() + return "bun.lock", rf'^ "{re.escape(path)}": \{{\n(?:(?!^ \}},).)*?"version": "([^"\n]+)' + return "uv.lock", r'(?s:\[\[package\]\]\nname = "moq-rs"\nversion = ")([^"\n]+)' + + +def lock_version(root, package): + path, pattern = lock_pattern(package, root) + matches = list(re.finditer(pattern, (root / path).read_text(), re.MULTILINE | re.DOTALL)) + if len(matches) != 1: + raise ValueError(f"{path}: expected one workspace version for {package.name}") + return matches[0][1] + + +def check(root, config): + minor = config["minor"] + if minor is None: + print("shared version: disabled until the release cut runs just version") + return + if not re.fullmatch(r"0\.[1-9][0-9]*", minor): + raise ValueError(f"invalid shared minor: {minor!r}") + selected = eligible(packages(root), config["exemptions"]) + errors = [] + for p in selected: + if ".".join(map(str, version(p.current)[:2])) != minor: + errors.append(f"{p.ecosystem} {p.name}: {p.current} must join {minor}.x") + if p.ecosystem in ("npm", "python") and lock_version(root, p) != p.current: + errors.append(f"{p.name}: lockfile version differs from {p.current}") + if errors: + raise ValueError("\n".join(errors)) + print(f"shared version: {len(selected)} packages on {minor}.x (patches independent)") + + +def bump(root, config, target): + major, minor, patch = version(target) + if major != 0 or minor == 0 or patch != 0: + raise ValueError("a shared cut must be 0.MINOR.0 with a nonzero minor") + metadata = cargo_metadata(root) + selected = eligible(packages(root, metadata), config["exemptions"]) + if any(version(p.current) > (major, minor, patch) for p in selected): + raise ValueError("the cut must not downgrade any package; choose a newer minor") + # Prepare every text edit before release-plz mutates anything. Lockfile edits + # touch only workspace versions, preserving the dependency graph and audits. + edits = {} + for p in selected: + if p.ecosystem == "rust": + continue + text = p.path.read_text() + if p.ecosystem == "npm": + pattern = r'^\s*"version": "([^"\n]+)"' + else: + pattern = WRAPPERS[p.ecosystem][2] + edits[p.path] = replace(text, pattern, f"{major}.{minor}" if p.ecosystem == "go" else target) + if p.ecosystem in ("npm", "python"): + if lock_version(root, p) != p.current: + raise ValueError(f"{p.name}: lockfile version differs from {p.current}") + path, pattern = lock_pattern(p, root) + path = root / path + edits[path] = replace(edits.get(path, path.read_text()), pattern, target) + rust = [p for p in selected if p.ecosystem == "rust"] + # set-version renames the last release heading, including published history, + # and refuses crates without a changelog. Give it disposable changelogs; + # release-pr will generate the real entries from the committed cut later. + scratch = root / ".tmp" + scratch.mkdir(exist_ok=True) + paths = {root / "Cargo.toml", root / "Cargo.lock", root / "version.json", *edits} + paths.update(Path(p["manifest_path"]) for p in metadata["packages"] if p["id"] in metadata["workspace_members"]) + originals = {path: path.read_bytes() if path.exists() else None for path in paths} + try: + with tempfile.TemporaryDirectory(dir=scratch, prefix="version-") as temporary: + directory = Path(temporary) + config_path = directory / "release-plz.toml" + sections = [] + for p in rust: + changelog = directory / f"{p.name}.md" + changelog.write_text(f"# Changelog\n\n## [{p.current}]\n") + sections.append(f'[[package]]\nname = "{p.name}"\nchangelog_path = {json.dumps(str(changelog))}\n') + config_path.write_text("\n".join(sections)) + if rust: + run( + root, + "release-plz", + "set-version", + "--config", + str(config_path), + *[f"{p.name}@{target}" for p in rust], + ) + for path, text in edits.items(): + path.write_text(text) + config = {**config, "minor": f"{major}.{minor}"} + check(root, config) + # Activate enforcement only after every ecosystem passed validation. + (root / "version.json").write_text(json.dumps(config, indent="\t") + "\n") + except BaseException: + for path, original in originals.items(): + if original is None: + path.unlink(missing_ok=True) + else: + path.write_bytes(original) + raise + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("target", nargs="?", help="0.MINOR.0 for a cut; omit to check") + parser.add_argument("--root", type=Path, default=ROOT, help=argparse.SUPPRESS) + args = parser.parse_args() + try: + root = args.root.resolve() + config = json.loads((root / "version.json").read_text()) + if args.target: + bump(root, config, args.target) + else: + check(root, config) + except (ValueError, OSError, subprocess.CalledProcessError) as error: + print(f"shared version: {error}", file=sys.stderr) + if isinstance(error, subprocess.CalledProcessError): + print(error.stderr, file=sys.stderr) + return 1 + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/sh/version.test.py b/sh/version.test.py new file mode 100644 index 00000000000..b4099e79b5c --- /dev/null +++ b/sh/version.test.py @@ -0,0 +1,283 @@ +#!/usr/bin/env python3 +"""Shared-minor policy and real, nonpublishing release-plz integration.""" + +import copy +import importlib.util +import json +import os +import shutil +import subprocess +import sys +import tempfile +import unittest +from pathlib import Path + +import tomllib + +ROOT = Path(__file__).resolve().parents[1] +spec = importlib.util.spec_from_file_location("shared_version", ROOT / "sh/version.py") +module = importlib.util.module_from_spec(spec) +sys.modules[spec.name] = module +spec.loader.exec_module(module) + + +class Versions(unittest.TestCase): + def setUp(self): + (ROOT / ".tmp").mkdir(exist_ok=True) + self.temp = tempfile.TemporaryDirectory(dir=ROOT / ".tmp", prefix="version-test-") + self.addCleanup(self.temp.cleanup) + self.root = Path(self.temp.name) + self.env = dict(os.environ, CARGO_NET_OFFLINE="true", GIT_CONFIG_GLOBAL=os.devnull, GIT_CONFIG_NOSYSTEM="1") + self.config = {"minor": None, "exemptions": {"rust": ["independent"], "npm": ["@moq/qmux"]}} + self.write("version.json", json.dumps(self.config)) + self.write("Cargo.toml", '[workspace]\nmembers = ["rs/*"]\nresolver = "2"\n') + self.crate( + "shared", + "0.21.3", + '[dependencies]\npromoted = { path = "../promoted", version = "0.0.1", optional = true }\n' + '[dev-dependencies]\ndev = { path = "../dev" }\n' + "[target.'cfg(windows)'.dependencies]\n" + 'renamed = { package = "target-only", path = "../target-only", version = "0.0.1" }\n', + ) + self.crate( + "promoted", "0.0.1", '[build-dependencies]\ntransitive = { path = "../transitive", version = "0.0.1" }\n' + ) + for name in ("transitive", "archive", "dev", "experiment", "target-only"): + self.crate(name, "0.0.1") + self.crate( + "binary", "0.21.0", '[dependencies]\narchive = { path = "../archive", version = "0.0.1" }\n', binary=True + ) + self.crate("independent", "0.6.0") + self.crate( + "private", + "0.1.0", + 'publish = false\n[dependencies]\nexperiment = { path = "../experiment", version = "0.0.1" }\n', + ) + self.call("cargo", "generate-lockfile", "--offline") + self.write("package.json", json.dumps({"private": True, "workspaces": ["js/*"]})) + for name, value in ( + ("signals", "0.2.5"), + ("qmux", "0.7.0"), + ("experiment", "0.0.1"), + ("promoted", "0.0.1"), + ("private", "0.1.0"), + ): + p = {"name": f"@moq/{name}", "version": value, "scripts": {"release": "bun publish"}} + if name == "signals": + p["dependencies"] = {"@moq/promoted": "workspace:^"} + p["devDependencies"] = {"@moq/experiment": "workspace:^"} + if name == "private": + p["private"] = True + self.write(f"js/{name}/package.json", json.dumps(p, indent="\t") + "\n") + self.call("bun", "install", "--lockfile-only", "--ignore-scripts") + for ecosystem, (_, path, _) in module.WRAPPERS.items(): + value = { + "python": '[project]\nname = "moq-rs"\nversion = "0.21.3"\n', + "kotlin": "moq.version=0.21.3\n", + "dart": "name: moq\nversion: 0.21.3\n", + "go": "0.21\n", + }.get(ecosystem, "0.21.3\n") + self.write(path, value) + self.write( + "uv.lock", + 'version = 1\n\n[[package]]\nname = "moq-rs"\nversion = "0.21.3"\nsource = { editable = "py/moq-rs" }\n' + '\n[[package]]\nname = "unrelated"\nversion = "1.2.3"\n', + ) + self.call("git", "init", "-q") + self.call("git", "config", "user.name", "Fixture") + self.call("git", "config", "user.email", "fixture@example.com") + self.call("git", "config", "commit.gpgsign", "false") + self.commit("chore: fixture") + + def write(self, path, content): + path = self.root / path + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(content) + + def call(self, *args, cwd=None, ok=True): + result = subprocess.run(args, cwd=cwd or self.root, env=self.env, capture_output=True, text=True) + if ok: + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + return result + + def commit(self, message): + self.call("git", "add", ".") + self.call("git", "commit", "-qm", message) + + def crate(self, name, value, extra="", binary=False): + self.write( + f"rs/{name}/Cargo.toml", f'[package]\nname = "{name}"\nversion = "{value}"\nedition = "2024"\n{extra}' + ) + self.write( + f"rs/{name}/src/{'main' if binary else 'lib'}.rs", "fn main() {}\n" if binary else "pub fn original() {}\n" + ) + + def check(self, ok=True): + return self.call(sys.executable, str(ROOT / "sh/version.py"), "--root", str(self.root), ok=ok) + + def cut(self, ok=True): + return self.call(sys.executable, str(ROOT / "sh/version.py"), "--root", str(self.root), "0.22.0", ok=ok) + + def snapshot(self): + return { + str(p.relative_to(self.root)): p.read_bytes() + for p in self.root.rglob("*") + if p.is_file() and not set(p.relative_to(self.root).parts) & {".git", ".tmp", "node_modules"} + } + + def test_disabled_before_cut_and_invalid_marker_fails(self): + self.assertIn("disabled", self.check().stdout) + # Disabled enforcement does not require Cargo, the lockfiles, or packages. + (self.root / "Cargo.toml").unlink() + self.assertIn("disabled", self.check().stdout) + for value in ("", "0.22.0", "0.0", "0.022"): + self.write("version.json", json.dumps({**self.config, "minor": value})) + self.assertNotEqual(self.check(ok=False).returncode, 0) + + def test_cut_promotes_only_published_library_dependencies_and_preserves_exemptions(self): + before = self.snapshot() + self.cut() + self.check() + packages = {p.key: p.current for p in module.packages(self.root)} + for name in ("shared", "promoted", "transitive", "binary", "target-only"): + self.assertEqual(packages["rust", name], "0.22.0") + for name in ("archive", "dev", "experiment"): + self.assertEqual(packages["rust", name], "0.0.1") + self.assertEqual(packages["rust", "independent"], "0.6.0") + self.assertNotIn(("rust", "private"), packages) + for name in ("signals", "promoted"): + self.assertEqual(packages["npm", f"@moq/{name}"], "0.22.0") + for name in ("qmux", "experiment", "private"): + path = f"js/{name}/package.json" + self.assertEqual((self.root / path).read_bytes(), before[path]) + for ecosystem in module.WRAPPERS: + self.assertEqual(packages[ecosystem, module.WRAPPERS[ecosystem][0]], "0.22.0") + self.assertEqual((self.root / "go/wrapper/VERSION").read_text(), "0.22\n") + self.assertIn('version = "0.22.0", optional = true', (self.root / "rs/shared/Cargo.toml").read_text()) + lock = tomllib.loads((self.root / "Cargo.lock").read_text()) + self.assertEqual(next(p["version"] for p in lock["package"] if p["name"] == "promoted"), "0.22.0") + # No real changelogs exist in this fixture. set-version must not require + # them, or create release sections or rewrite published history. + self.assertFalse(list((self.root / "rs").glob("*/CHANGELOG.md"))) + bun_before = json.loads( + self.call( + "bun", "-e", "console.log(JSON.stringify(Bun.JSON5.parse(await Bun.file('bun.lock').text())))" + ).stdout + ) + self.call("bun", "install", "--lockfile-only", "--ignore-scripts", "--frozen-lockfile") + bun_after = json.loads( + self.call( + "bun", "-e", "console.log(JSON.stringify(Bun.JSON5.parse(await Bun.file('bun.lock').text())))" + ).stdout + ) + self.assertEqual(bun_before, bun_after) + self.assertIn('name = "unrelated"\nversion = "1.2.3"', (self.root / "uv.lock").read_text()) + self.assertEqual(json.loads((self.root / "version.json").read_text())["minor"], "0.22") + + def test_check_reports_each_ecosystem_mismatch_promotion_and_stale_exemption(self): + self.cut() + pristine = self.snapshot() + for ecosystem, (_, path, pattern) in module.WRAPPERS.items(): + with self.subTest(ecosystem=ecosystem): + self.write( + path, module.replace(pristine[path].decode(), pattern, "0.21" if ecosystem == "go" else "0.21.0") + ) + self.assertIn("must join 0.22.x", self.check(ok=False).stderr) + (self.root / path).write_bytes(pristine[path]) + for ecosystem, path in ( + ("rust", "rs/shared/Cargo.toml"), + ("npm", "js/signals/package.json"), + ("rust", "rs/promoted/Cargo.toml"), + ("npm", "js/promoted/package.json"), + ): + with self.subTest(ecosystem=ecosystem, path=path): + self.write(path, pristine[path].decode().replace("0.22.0", "0.0.1" if "promoted" in path else "0.21.1")) + result = self.check(ok=False) + self.assertNotEqual(result.returncode, 0) + self.assertIn("must join 0.22.x", result.stderr) + (self.root / path).write_bytes(pristine[path]) + for ecosystem in ("rust", "npm"): + config = copy.deepcopy(json.loads((self.root / "version.json").read_text())) + config["exemptions"][ecosystem].append("removed") + self.write("version.json", json.dumps(config)) + self.assertIn("exemptions name missing", self.check(ok=False).stderr) + (self.root / "version.json").write_bytes(pristine["version.json"]) + + def test_independent_patches_and_lock_consistency(self): + self.cut() + for path, old, new in ( + ("rs/shared/Cargo.toml", 'version = "0.22.0"', 'version = "0.22.3"'), + ("js/signals/package.json", "0.22.0", "0.22.7"), + ): + text = (self.root / path).read_text() + self.write(path, text.replace(old, new, 1)) + signals = next(p for p in module.packages(self.root) if p.key == ("npm", "@moq/signals")) + path, pattern = module.lock_pattern(signals, self.root) + self.write(path, module.replace((self.root / path).read_text(), pattern, "0.22.7")) + self.call("cargo", "generate-lockfile", "--offline") + self.check() + for path in ("bun.lock", "uv.lock"): + text = (self.root / path).read_text() + self.write(path, text.replace("0.22.", "0.21.", 1)) + self.assertIn("lockfile version differs", self.check(ok=False).stderr) + self.write(path, text) + + def test_cut_refuses_bad_targets_and_restores_partial_external_failure(self): + before = self.snapshot() + for target in ("0.22", "0.22.1", "1.0.0", "0.0.0", "0.20.0", "0.022.0", "0.22.0-wip"): + result = self.call(sys.executable, str(ROOT / "sh/version.py"), "--root", str(self.root), target, ok=False) + self.assertNotEqual(result.returncode, 0, target) + self.assertEqual(self.snapshot(), before) + # release-plz can fail after editing some manifests. Keep every caller + # edit and leave the activation marker disabled on that failure. + binary = self.root / ".tmp/bin/release-plz" + self.write( + ".tmp/bin/release-plz", "#!/bin/sh\nprintf broken > Cargo.toml\nprintf broken > Cargo.lock\nexit 1\n" + ) + binary.chmod(0o755) + self.env["PATH"] = f"{binary.parent}:{self.env['PATH']}" + result = self.cut(ok=False) + self.assertNotEqual(result.returncode, 0) + self.assertEqual(self.snapshot(), before) + + def test_release_plz_keeps_manual_cut_despite_breaking_commits(self): + # update is the version/changelog engine used by release-pr. Local + # registry manifests exercise it without credentials, publishing, or a forge. + self.write(".release-plz.toml", "[workspace]\nsemver_check = false\ndependencies_update = false\n") + for p in module.packages(self.root): + if p.ecosystem == "rust": + self.write( + p.path.parent / "CHANGELOG.md", f"# Changelog\n\n## [Unreleased]\n\n## [{p.current}] - 2026-01-01\n" + ) + self.call("git", "tag", f"{p.name}-v{p.current}") + self.commit("chore: release baseline") + registry = self.root / ".tmp/registry" + shutil.copytree(self.root / "rs", registry / "rs") + shutil.copy(self.root / "Cargo.toml", registry / "Cargo.toml") + self.write("rs/shared/src/lib.rs", "pub fn replacement() {}\n") + self.commit("feat!: replace the public API") + changelogs = {p: p.read_bytes() for p in (self.root / "rs").glob("*/CHANGELOG.md")} + self.cut() + for path, original in changelogs.items(): + self.assertEqual(path.read_bytes(), original) + self.commit("chore: shared minor cut") + result = self.call( + "release-plz", + "update", + "--registry-manifest-path", + str(registry / "Cargo.toml"), + "--repo-url", + "https://github.com/moq-dev/moq", + ) + self.assertIn("shared`: 0.21.3 -> 0.22.0", result.stdout) + self.check() + self.assertIn("## [0.22.0]", (self.root / "rs/shared/CHANGELOG.md").read_text()) + # Unchanged published members also retain the cut; exempt packages keep + # independent versioning instead of being coupled by version_group. + self.assertEqual( + tomllib.loads((self.root / "rs/binary/Cargo.toml").read_text())["package"]["version"], "0.22.0" + ) + + +if __name__ == "__main__": + unittest.main() diff --git a/version.json b/version.json new file mode 100644 index 00000000000..89cb82f17ef --- /dev/null +++ b/version.json @@ -0,0 +1,7 @@ +{ + "minor": null, + "exemptions": { + "rust": ["kio", "kio-macros", "qmux"], + "npm": ["@moq/qmux"] + } +} From ba877b6d476967be5d2311a565ee334f0228fa8b Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 1 Nov 2026 20:05:46 -0800 Subject: [PATCH 3/6] fix(release): advance wrapper binding requirements at the shared cut Co-Authored-By: GPT-6.1 Sol --- CONTRIBUTING.md | 6 ++++-- kt/moq/build.gradle.kts | 14 ++++++-------- py/moq-rs/pyproject.toml | 15 ++++++--------- sh/dispatch-query.test.py | 1 + sh/dispatch.sh | 2 +- sh/version.py | 34 +++++++++++++++++++++++++++++++++- sh/version.test.py | 29 +++++++++++++++++++++++++++-- 7 files changed, 78 insertions(+), 23 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0e97d434e36..15112a676df 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -116,13 +116,15 @@ Thus `moq-uring` joins through the relay library, while `moq-archive` stays experimental through the binary-only CLI and a dev dependency. `just version 0.22.0` sets eligible versions and workspace lock entries without -resolving unrelated dependencies. Rust requirements are updated by +resolving unrelated dependencies. It also advances Python, Dart, and Kotlin +bindings requirements to the cut's minor while allowing independent patches. +Rust requirements are updated by `release-plz set-version`; disposable changelogs keep published history intact. The recipe records the shared minor and named exemptions in `version.json`. `just version` checks it on every `just check` and `just ci`; enforcement is disabled while its minor is `null`, until the cut runs the recipe. Once active, the check rejects minor drift, unpromoted dependencies, stale exemptions, and -mismatched npm/Python lock entries. +mismatched npm/Python lock entries, and stale bindings requirements. The nonpublishing fixture in `sh/version.test.py` verifies that release-plz's `update` engine, also used by `release-pr`, preserves a manually set unpublished diff --git a/kt/moq/build.gradle.kts b/kt/moq/build.gradle.kts index e8d7156bc57..f3f5acb5d8a 100644 --- a/kt/moq/build.gradle.kts +++ b/kt/moq/build.gradle.kts @@ -6,11 +6,10 @@ // `dev.moq.*` typealiases and adds idiomatic helpers (a `connect()` facade, // Flow extensions, AutoCloseable ergonomics). // -// Versioning is INDEPENDENT of the crate: `-Pmoq.version` (default in -// gradle.properties), bumped by hand. release-kt-lib.yml publishes a new -// version only when that property changes. The dependency on `moq-ffi` is a -// floating range so consumers transitively pick up new bindings patches -// without this wrapper being re-cut. See MOQ_FFI_RANGE below. +// `-Pmoq.version` (default in gradle.properties) owns the wrapper version. +// Shared cuts set its minor; patches are independent of the bindings. +// release-kt-lib.yml publishes when that property changes. MOQ_FFI_RANGE +// lets consumers pick up bindings patches without a wrapper re-release. // // Local builds and CI resolve `moq-ffi` from the sibling project via the // dependency substitution below, so tests run against freshly-built bindings. @@ -58,9 +57,8 @@ val generateVersion = } } -// Compatible-patch range for the bindings: 0.4.3 (the WebSocket fallback -// setters) or newer, never 0.5.0. Published into the wrapper's POM so consumers -// float to the newest bindings patch. +// The published POM admits newer bindings patches within the cut's minor. +// Shared cuts move this range; raise its floor when newer FFI API is required. val MOQ_FFI_RANGE = "[0.4.3,0.5)" val androidEnabled = providers.gradleProperty("android.enabled").orNull == "true" diff --git a/py/moq-rs/pyproject.toml b/py/moq-rs/pyproject.toml index 827532e0b3b..6d2e6212653 100644 --- a/py/moq-rs/pyproject.toml +++ b/py/moq-rs/pyproject.toml @@ -9,11 +9,9 @@ packages = ["moq"] [project] name = "moq-rs" # Distribution is `moq-rs` (the `moq` name is taken on PyPI); the import name -# stays `moq`. Versioned independently of the moq-ffi crate: bump this by hand -# in a PR. On merge to release, release-py.yml publishes to PyPI if this version -# isn't already there (no tag needed; the registry is the gate). -# Starts at 0.3.0 to open a new line above the old lockstep 0.2.x releases that -# bundled the bindings. +# stays `moq`. Shared cuts set the minor; patches are independent of moq-ffi. +# On merge to release, release-py.yml publishes this version if it is not on +# PyPI yet (no tag needed; the registry is the gate). version = "0.6.0" description = "Media over QUIC: real-time pub/sub with built-in caching, fan-out, and prioritization, with a Pythonic API. Import as `moq`." readme = "README.md" @@ -28,10 +26,9 @@ classifiers = [ "Topic :: Multimedia :: Sound/Audio", "Topic :: Multimedia :: Video", ] -# Compatible-release pin: floats to the latest 0.5.x moq-ffi patch without a -# wrapper re-release. A moq-ffi minor bump (0.6) is the only thing that forces -# bumping this constraint. Floor is 0.5.0: no 0.4.x has the epoch, range, and -# demand API this wrapper calls. +# Compatible-release pin: consumers float to newer bindings patches without +# a wrapper re-release. Shared cuts move the floor to the new minor; raise +# its patch when the wrapper requires newer FFI API. dependencies = ["moq-ffi ~= 0.5.0"] [project.urls] diff --git a/sh/dispatch-query.test.py b/sh/dispatch-query.test.py index da809764f2c..1f4826508bf 100644 --- a/sh/dispatch-query.test.py +++ b/sh/dispatch-query.test.py @@ -214,6 +214,7 @@ def stub_ci(self, just=""): "bun", "python3", "cargo", + "release-plz", "jq", "shellcheck", "shfmt", diff --git a/sh/dispatch.sh b/sh/dispatch.sh index 51b6c7231e7..760cbfddf5a 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -178,7 +178,7 @@ declare -A tools=( [toml]='taplo' [nix]='nixfmt' [justfile]='' - [gh]='actionlint zizmor bun python3 cargo clippy-driver dpkg-deb nfpm rpm' + [gh]='actionlint zizmor bun python3 cargo release-plz clippy-driver dpkg-deb nfpm rpm' ) # CI and the local check share one selection and one lint/test dispatch. diff --git a/sh/version.py b/sh/version.py index d5a96bb8345..0c30c7743ad 100644 --- a/sh/version.py +++ b/sh/version.py @@ -56,6 +56,22 @@ def key(self): } +# Published wrappers must resolve bindings from the cut's minor. Their local +# workspace/path substitutions would otherwise hide a stale registry constraint. +FFI_REQUIREMENTS = ( + ("py/moq-rs/pyproject.toml", r'"moq-ffi ([^"\n]+)"', "~= {version}"), + ("dart/moq/pubspec.yaml", r"^ moq_ffi: ([^\n]+)$", "^{version}"), + ("kt/moq/build.gradle.kts", r'^val MOQ_FFI_RANGE = "([^"\n]+)"$', "[{version},0.{next_minor})"), +) + + +def captured(text, pattern): + matches = list(re.finditer(pattern, text, re.MULTILINE | re.DOTALL)) + if len(matches) != 1: + raise ValueError(f"expected one value matching {pattern!r}, found {len(matches)}") + return matches[0][1] + + def run(root, *args): return subprocess.run(args, cwd=root, check=True, text=True, capture_output=True).stdout @@ -159,13 +175,25 @@ def check(root, config): return if not re.fullmatch(r"0\.[1-9][0-9]*", minor): raise ValueError(f"invalid shared minor: {minor!r}") - selected = eligible(packages(root), config["exemptions"]) + inventory = packages(root) + selected = eligible(inventory, config["exemptions"]) errors = [] for p in selected: if ".".join(map(str, version(p.current)[:2])) != minor: errors.append(f"{p.ecosystem} {p.name}: {p.current} must join {minor}.x") if p.ecosystem in ("npm", "python") and lock_version(root, p) != p.current: errors.append(f"{p.name}: lockfile version differs from {p.current}") + ffi = next(p for p in inventory if p.key == ("rust", "moq-ffi")) + for path, pattern, template in FFI_REQUIREMENTS: + requirement = captured((root / path).read_text(), pattern) + expected = template.format(version="VERSION", next_minor=int(minor.split(".")[1]) + 1) + match = re.fullmatch(re.escape(expected).replace("VERSION", f"({SEMVER})"), requirement) + if ( + match is None + or ".".join(map(str, version(match[1])[:2])) != minor + or version(match[1]) > version(ffi.current) + ): + errors.append(f"{path}: FFI requirement {requirement!r} must use {minor}.x, at most {ffi.current}") if errors: raise ValueError("\n".join(errors)) print(f"shared version: {len(selected)} packages on {minor}.x (patches independent)") @@ -197,6 +225,10 @@ def bump(root, config, target): path, pattern = lock_pattern(p, root) path = root / path edits[path] = replace(edits.get(path, path.read_text()), pattern, target) + for path, pattern, template in FFI_REQUIREMENTS: + path = root / path + requirement = template.format(version=target, next_minor=minor + 1) + edits[path] = replace(edits.get(path, path.read_text()), pattern, requirement) rust = [p for p in selected if p.ecosystem == "rust"] # set-version renames the last release heading, including published history, # and refuses crates without a changelog. Give it disposable changelogs; diff --git a/sh/version.test.py b/sh/version.test.py index b4099e79b5c..e884a17f1f6 100644 --- a/sh/version.test.py +++ b/sh/version.test.py @@ -48,6 +48,7 @@ def setUp(self): "binary", "0.21.0", '[dependencies]\narchive = { path = "../archive", version = "0.0.1" }\n', binary=True ) self.crate("independent", "0.6.0") + self.crate("moq-ffi", "0.21.3") self.crate( "private", "0.1.0", @@ -72,12 +73,13 @@ def setUp(self): self.call("bun", "install", "--lockfile-only", "--ignore-scripts") for ecosystem, (_, path, _) in module.WRAPPERS.items(): value = { - "python": '[project]\nname = "moq-rs"\nversion = "0.21.3"\n', + "python": '[project]\nname = "moq-rs"\nversion = "0.21.3"\ndependencies = ["moq-ffi ~= 0.21.0"]\n', "kotlin": "moq.version=0.21.3\n", - "dart": "name: moq\nversion: 0.21.3\n", + "dart": "name: moq\nversion: 0.21.3\ndependencies:\n moq_ffi: ^0.21.0\n", "go": "0.21\n", }.get(ecosystem, "0.21.3\n") self.write(path, value) + self.write("kt/moq/build.gradle.kts", 'val MOQ_FFI_RANGE = "[0.21.0,0.22)"\n') self.write( "uv.lock", 'version = 1\n\n[[package]]\nname = "moq-rs"\nversion = "0.21.3"\nsource = { editable = "py/moq-rs" }\n' @@ -222,6 +224,29 @@ def test_independent_patches_and_lock_consistency(self): self.assertIn("lockfile version differs", self.check(ok=False).stderr) self.write(path, text) + def test_ffi_constraints_advance_and_reject_stale_ranges(self): + self.cut() + for path, pattern, template in module.FFI_REQUIREMENTS: + with self.subTest(path=path): + text = (self.root / path).read_text() + self.assertEqual(module.captured(text, pattern), template.format(version="0.22.0", next_minor=23)) + for floor, upper in (("0.21.0", 22), ("0.22.1", 23)): + self.write(path, module.replace(text, pattern, template.format(version=floor, next_minor=upper))) + self.assertIn("FFI requirement", self.check(ok=False).stderr) + self.write(path, text) + self.write( + "rs/moq-ffi/Cargo.toml", (self.root / "rs/moq-ffi/Cargo.toml").read_text().replace("0.22.0", "0.22.3") + ) + for path, pattern, template in module.FFI_REQUIREMENTS: + self.write( + path, + module.replace( + (self.root / path).read_text(), pattern, template.format(version="0.22.2", next_minor=23) + ), + ) + self.call("cargo", "generate-lockfile", "--offline") + self.check() + def test_cut_refuses_bad_targets_and_restores_partial_external_failure(self): before = self.snapshot() for target in ("0.22", "0.22.1", "1.0.0", "0.0.0", "0.20.0", "0.022.0", "0.22.0-wip"): From e2f597055bca5c151041154d9c838d57dc9bb9fe Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 1 Nov 2026 20:08:45 -0800 Subject: [PATCH 4/6] fix(release): include the independent C package in shared cuts Keep binding floors on the shared minor while allowing their patches to advance independently. Co-Authored-By: GPT-6.1 Sol --- CONTRIBUTING.md | 1 + sh/version.py | 10 +++------- sh/version.test.py | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 15112a676df..b2ee3d43873 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -138,5 +138,6 @@ Each package's version lives in one place: - **Python**: `py/moq-rs/pyproject.toml`, plus the matching `moq-rs` entry in the root `uv.lock`; `py/moq-ffi` follows the `moq-ffi-v*` tag and Rust crate. - **Swift**: `swift/VERSION`. **Kotlin**: `moq.version` in `kt/gradle.properties`. **Dart**: `version` in `dart/moq/pubspec.yaml`. Their FFI counterparts track the Rust crate. - **Go**: `go/wrapper/VERSION` holds a human-owned `MAJOR.MINOR` line; CI derives the independent patch; the shared cut sets the minor. Leave the placeholder FFI version in `go.mod` alone. +- **C**: `c/moq/VERSION`, human-owned; a `c-v` tag releases it. - **C++**: `cpp/moq/VERSION`, human-owned; a `cpp-v` tag releases it. - **OBS**: `cpp/obs/VERSION`, human-owned; each C++ release also cuts `obs-moq-v`, and refuses one whose version already names an earlier release. diff --git a/sh/version.py b/sh/version.py index 0c30c7743ad..0cf2adae937 100644 --- a/sh/version.py +++ b/sh/version.py @@ -51,6 +51,7 @@ def key(self): "kotlin": ("moq", "kt/gradle.properties", r"^moq\.version=([^\n]+)$"), "dart": ("moq", "dart/moq/pubspec.yaml", r"^version: ([^\n]+)$"), "go": ("moq", "go/wrapper/VERSION", r"^([^\n]+)$"), + "c": ("moq", "c/moq/VERSION", r"^([^\n]+)$"), "cpp": ("moq", "cpp/moq/VERSION", r"^([^\n]+)$"), "obs": ("moq", "cpp/obs/VERSION", r"^([^\n]+)$"), } @@ -183,17 +184,12 @@ def check(root, config): errors.append(f"{p.ecosystem} {p.name}: {p.current} must join {minor}.x") if p.ecosystem in ("npm", "python") and lock_version(root, p) != p.current: errors.append(f"{p.name}: lockfile version differs from {p.current}") - ffi = next(p for p in inventory if p.key == ("rust", "moq-ffi")) for path, pattern, template in FFI_REQUIREMENTS: requirement = captured((root / path).read_text(), pattern) expected = template.format(version="VERSION", next_minor=int(minor.split(".")[1]) + 1) match = re.fullmatch(re.escape(expected).replace("VERSION", f"({SEMVER})"), requirement) - if ( - match is None - or ".".join(map(str, version(match[1])[:2])) != minor - or version(match[1]) > version(ffi.current) - ): - errors.append(f"{path}: FFI requirement {requirement!r} must use {minor}.x, at most {ffi.current}") + if match is None or ".".join(map(str, version(match[1])[:2])) != minor: + errors.append(f"{path}: FFI requirement {requirement!r} must use {minor}.x") if errors: raise ValueError("\n".join(errors)) print(f"shared version: {len(selected)} packages on {minor}.x (patches independent)") diff --git a/sh/version.test.py b/sh/version.test.py index e884a17f1f6..dbdc3bfb113 100644 --- a/sh/version.test.py +++ b/sh/version.test.py @@ -230,7 +230,7 @@ def test_ffi_constraints_advance_and_reject_stale_ranges(self): with self.subTest(path=path): text = (self.root / path).read_text() self.assertEqual(module.captured(text, pattern), template.format(version="0.22.0", next_minor=23)) - for floor, upper in (("0.21.0", 22), ("0.22.1", 23)): + for floor, upper in (("0.21.0", 22), ("0.23.0", 24)): self.write(path, module.replace(text, pattern, template.format(version=floor, next_minor=upper))) self.assertIn("FFI requirement", self.check(ok=False).stderr) self.write(path, text) From 9de0b6f6ba15506032a820d600aaa08f81b1413d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 1 Nov 2026 20:11:24 -0800 Subject: [PATCH 5/6] test(release): distinguish a preserved cut from automatic version bumps Co-Authored-By: GPT-6.1 Sol --- sh/version.test.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sh/version.test.py b/sh/version.test.py index dbdc3bfb113..efb56579f1e 100644 --- a/sh/version.test.py +++ b/sh/version.test.py @@ -268,7 +268,11 @@ def test_cut_refuses_bad_targets_and_restores_partial_external_failure(self): def test_release_plz_keeps_manual_cut_despite_breaking_commits(self): # update is the version/changelog engine used by release-pr. Local # registry manifests exercise it without credentials, publishing, or a forge. - self.write(".release-plz.toml", "[workspace]\nsemver_check = false\ndependencies_update = false\n") + self.write(".release-plz.toml", (ROOT / ".release-plz.toml").read_text()) + # A breaking bump from this baseline would be 0.20.0, so a recomputed + # version cannot accidentally satisfy the hand-set 0.22.0 assertion. + self.write("rs/shared/Cargo.toml", (self.root / "rs/shared/Cargo.toml").read_text().replace("0.21.3", "0.19.3")) + self.call("cargo", "generate-lockfile", "--offline") for p in module.packages(self.root): if p.ecosystem == "rust": self.write( @@ -286,6 +290,8 @@ def test_release_plz_keeps_manual_cut_despite_breaking_commits(self): for path, original in changelogs.items(): self.assertEqual(path.read_bytes(), original) self.commit("chore: shared minor cut") + self.write("rs/shared/src/lib.rs", "pub fn replacement_after_cut() {}\n") + self.commit("feat!: break the public API after the cut") result = self.call( "release-plz", "update", @@ -294,7 +300,7 @@ def test_release_plz_keeps_manual_cut_despite_breaking_commits(self): "--repo-url", "https://github.com/moq-dev/moq", ) - self.assertIn("shared`: 0.21.3 -> 0.22.0", result.stdout) + self.assertIn("shared`: 0.19.3 -> 0.22.0", result.stdout) self.check() self.assertIn("## [0.22.0]", (self.root / "rs/shared/CHANGELOG.md").read_text()) # Unchanged published members also retain the cut; exempt packages keep From 0f66c2198608d1aacc7620462f12bb9a2505e334 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 2 Nov 2026 09:38:49 -0800 Subject: [PATCH 6/6] docs(release): say the release-plz fixture runs on every check Co-Authored-By: Claude Opus 5.5 --- CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cf32243a561..591d791d81f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -129,8 +129,9 @@ mismatched npm/Python lock entries, and stale bindings requirements. The nonpublishing fixture in `sh/version.test.py` verifies that release-plz's `update` engine, also used by `release-pr`, preserves a manually set unpublished -minor despite breaking commits. Run it when changing release-plz. No publish, -tag, or release workflow runs as part of `just version`. +minor despite breaking commits. `just gh test` runs it on every check, so a +release-plz upgrade that breaks the cut fails before it lands. No publish, tag, +or release workflow runs as part of `just version`. Each package's version lives in one place: