mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 13:29:19 +08:00
fix(release): synchronize editable uv lock version (#4054)
## Description Full version synchronization changes pyproject.toml but previously left the editable root package version in uv.lock unchanged. Locked uv installs then reject regenerated release branches. #4002 demonstrated this again when release-please regenerated from main and discarded its manual lock repair and automation commit. Move the durable automation repair into main through this dedicated PR. Release-please can inherit it after merge rather than repeatedly dropping a change made only on its generated branch. Current commit:f61cd097d(comment punctuation follow-up; functional code unchanged). ## Type of Change - [x] Bug fix (release lock synchronization) ## Changes Made - Update exactly the editable source="." root package's version during full version synchronization. - Preserve all third-party lock entries without resolving dependencies. - Keep plugin-only synchronization from touching Python/lock metadata. - Add a byte-preservation regression with a third-party package sharing the old version. ## Testing - [x] 81 focused version-sync/release-version/release-workflow tests passed on current main17abee272. - [x] Scoped Ruff lint, format and whitespace checks passed. - [x] Actual full-sync CLI and uv locked-check replay passed. ```text 81 passed in 5.42s All checks passed! 2 files already formatted ``` The regression's original red/green evidence is retained from #4002: full sync left the editable root at 0.5.25 before repair and correctly updated it to 0.7.0 after repair while same-version third-party bytes remained unchanged. Plugin-only control passes. ## Real Behavior Proof - Environment: Windows, current-main checkout with the actual uv.lock, uv and the real scripts/version-sync.py command. No dependency resolver substitution. - Exact command / steps: Run python G:/git/headroom/.remember/tmp/resume36-lock-sync-runtime.py. Independently replace only the editable headroom-ai root version with 0.0.0 while project metadata stays 0.40.0; run uv lock --check; run python scripts/version-sync.py; rerun uv lock --check and compare the full lock bytes to the original. - Observed result: The stale root was rejected; full CLI synchronization repaired it; the locked check passed and every lock byte matched the original. Existing generated Windows manifest newline noise was restored before publication; only script/tests change. - Not tested: Full locked environment installation, release/tag creation, npm/PyPI publication or external rollout. Exact-head hosted checks are terminal: 52 successes, 16 intended skips, and 46 duplicate-run cancellations; successful matching workflow runs are verified below. The repair takes effect for release-please regeneration only after this PR reaches main. ```text PASS red: actual uv lock --check rejects stale editable root Version synchronized to 0.40.0 PASS green: full CLI sync repairs root; uv lock --check passes; complete lock bytes match original ``` ## Runtime Rollout Safety - Rollout-managed feature(s): Release metadata only; no runtime feature. - Minimum rollout channel: No new channel requirement. - Stable/default behavior changed: Full version-sync now aligns the editable uv.lock root; dependencies and plugin-only synchronization retain their existing behavior. - Kill switch / disable path: Do not invoke version synchronization; no runtime toggle applies. - Unsafe override required: No. - Qualification impact: Local metadata checks cover the two-file repair. Release packaging/publication remains separately gated. - Rollback path: Revert this script/test change, restoring the known stale-lock limitation. ## Review Readiness - [x] I have performed a self-review - [x] This PR is ready for human review Independent review is required. No merge, release, publication or self-approval performed. Exact-head qualification forf61cd097d7: all checks are terminal, with 52 successes and 16 intended skips. The remaining 46 cancelled checks belong to duplicate runs of the same SHA; corresponding complete successful workflow runs exist. Verified successful runs: CI 37838252441, Security 37838252409, rust 37838252460, Release 37838252963, Merge Conflicts 37838252937, Changelog Guard 37838252468 and PR Governance 37838907358. No failed or live checks remain. The sole review thread is resolved. The local full-sync/uv locked-check and byte-preservation proof remains applicable; the last commit only repairs comment punctuation. This provides the durable main-branch repair that #4002's generated release branch still lacks. Release-please cannot inherit it until this PR merges; future regeneration may discard #4002's manual repair before then. Independent review is still required. No merge, self-approval, release or publication performed.
This commit is contained in:
@@ -421,3 +421,46 @@ def test_opencode_headroom_dependency_is_preserved_for_registry_installability(
|
||||
opencode_pkg = json.loads(temp_project["opencode_pkg"].read_text())
|
||||
assert opencode_pkg["version"] == "0.28.0"
|
||||
assert opencode_pkg["dependencies"]["headroom-ai"] == "^0.22.3"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("plugin_only", [False, True])
|
||||
def test_version_sync_preserves_locked_dependencies_and_syncs_editable_root(
|
||||
temp_project: dict[str, Path], plugin_only: bool
|
||||
) -> None:
|
||||
root = temp_project["root"]
|
||||
lock = root / "uv.lock"
|
||||
before = """version = 1
|
||||
|
||||
[[package]]
|
||||
name = "dependency"
|
||||
version = "0.5.25"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
|
||||
[[package]]
|
||||
name = "headroom-ai"
|
||||
version = "0.5.25"
|
||||
source = { editable = "." }
|
||||
dependencies = [{ name = "dependency" }]
|
||||
"""
|
||||
lock.write_text(before, encoding="utf-8", newline="\n")
|
||||
args = [
|
||||
sys.executable,
|
||||
str(Path(__file__).parent.parent / "version-sync.py"),
|
||||
"--root",
|
||||
str(root),
|
||||
"--version",
|
||||
"0.7.0",
|
||||
]
|
||||
if plugin_only:
|
||||
args.append("--plugin-manifests-only")
|
||||
result = subprocess.run(args, capture_output=True, text=True)
|
||||
assert result.returncode == 0, result.stderr
|
||||
expected = (
|
||||
before
|
||||
if plugin_only
|
||||
else before.replace(
|
||||
'name = "headroom-ai"\nversion = "0.5.25"',
|
||||
'name = "headroom-ai"\nversion = "0.7.0"',
|
||||
)
|
||||
)
|
||||
assert lock.read_bytes() == expected.encode()
|
||||
|
||||
@@ -173,6 +173,29 @@ def write_release_metadata(root: Path, version: str) -> None:
|
||||
f.write("\n")
|
||||
|
||||
|
||||
def update_uv_lock_version(root: Path, version: str) -> None:
|
||||
"""Sync only the editable project's version without resolving dependencies."""
|
||||
lock_path = root / "uv.lock"
|
||||
if not lock_path.exists():
|
||||
return
|
||||
content = lock_path.read_text(encoding="utf-8")
|
||||
packages = tomllib.loads(content).get("package", [])
|
||||
editable = [p for p in packages if p.get("source", {}).get("editable") == "."]
|
||||
if len(editable) != 1:
|
||||
raise ValueError("uv.lock must contain exactly one editable root package")
|
||||
package = editable[0]
|
||||
if package["version"] == version:
|
||||
return
|
||||
pattern = (
|
||||
rf'(?m)(^name = {re.escape(json.dumps(package["name"]))}\nversion = )"[^"\n]+"'
|
||||
r'(?=\nsource = \{ editable = "\." \})'
|
||||
)
|
||||
updated, count = re.subn(pattern, lambda match: match[1] + json.dumps(version), content)
|
||||
if count != 1:
|
||||
raise ValueError("Cannot locate canonical editable root version in uv.lock")
|
||||
lock_path.write_text(updated, encoding="utf-8", newline="\n")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="Synchronize version across headroom packages")
|
||||
parser.add_argument(
|
||||
@@ -210,6 +233,7 @@ def main() -> None:
|
||||
|
||||
# Update all versioned files
|
||||
update_pyproject_version(args.root, version)
|
||||
update_uv_lock_version(args.root, version)
|
||||
update_openclaw_package_json(args.root / "plugins" / "openclaw" / "package.json", version)
|
||||
update_opencode_package_json(args.root / "plugins" / "opencode" / "package.json", version)
|
||||
update_package_json(args.root / "sdk" / "typescript" / "package.json", version)
|
||||
|
||||
Reference in New Issue
Block a user