Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(release): preserve silent tags and stable installer launchers (#2002)

Call White3577ca7f6ee4
diff --git a/.github/workflows/release_ai.yml b/.github/workflows/release_ai.yml
index 03b0b9aad..21cb090e6 100644
--- a/.github/workflows/release_ai.yml
+++ b/.github/workflows/release_ai.yml
@@ -624,6 +624,18 @@ jobs:
TAG: ${{ steps.tag.outputs.tag }}
GH_TOKEN: ${{ github.token }}
run: |
+ set -euo pipefail
+ SOURCE_SHA="$(git rev-parse "refs/tags/${TAG}^{commit}")"
+ # checkout can replace the runner-local annotated ref with its peeled
+ # commit. Read the exact origin object through FETCH_HEAD instead,
+ # without overwriting any local tag or remote-tracking refs.
+ git fetch --no-tags --refmap= origin "refs/tags/${TAG}"
+ TAG_OBJECT="$(git rev-parse FETCH_HEAD)"
+ if [ "$(git rev-parse "${TAG_OBJECT}^{commit}")" != "$SOURCE_SHA" ]; then
+ echo "Remote tag no longer matches the release notes source." >&2
+ exit 1
+ fi
+
# Permissive form for DETECTING intent to be silent (tag annotation or
# existing body may carry the marker bare or as a comment).
MARKER_RE='(avibe|vibe-remote):update-notification[[:space:]]*=[[:space:]]*none'
@@ -634,8 +646,12 @@ jobs:
MARKER_COMMENT_RE='<!--[[:space:]]*(avibe|vibe-remote):update-notification[[:space:]]*=[[:space:]]*none[[:space:]]*-->'
has_marker="false"
- # Source 1: the tag annotation (annotated-tag release flow).
- TAG_MSG=$(git tag -l --format='%(contents)' "$TAG")
+ # Source 1: only an actual annotation, never a lightweight tag's
+ # commit message (which may merely discuss this marker).
+ TAG_MSG=""
+ if [ "$(git cat-file -t "$TAG_OBJECT")" = "tag" ]; then
+ TAG_MSG="$(git cat-file tag "$TAG_OBJECT" | sed '1,/^$/d')"
+ fi
if echo "$TAG_MSG" | grep -qE "$MARKER_RE"; then
echo "Silent update marker found in tag annotation."
has_marker="true"
@@ -666,7 +682,6 @@ jobs:
mv release.md.tmp release.md
fi
- SOURCE_SHA="$(git rev-parse "${TAG}^{commit}")"
READY_MARKER="<!-- avibe:release-notes=ready source=${SOURCE_SHA} run=${GITHUB_RUN_ID} -->"
if ! grep -qF "$READY_MARKER" release.md; then
printf '\n\n%s\n' "$READY_MARKER" >> release.md
diff --git a/docs/plans/release-silent-stable-launcher.md b/docs/plans/release-silent-stable-launcher.md
new file mode 100644
index 000000000..966b503ae
--- /dev/null
+++ b/docs/plans/release-silent-stable-launcher.md
@@ -0,0 +1,71 @@
+# Preserve release intent and the established installer entrypoint
+
+## Scope and contracts
+
+Two failures observed during the packaged preview trial have separate owners:
+
+1. Release notes read notification intent from the remote annotated tag, not a
+ runner-local tag that checkout can replace with its peeled commit. Fetch the
+ exact remote tag object without changing local tag refs, and require its
+ peeled source to match the source used for the notes. A lightweight tag's
+ commit message is not a tag annotation. Existing strict HTML-comment body
+ fallback, both current/legacy notification markers, and the exact source/run
+ readiness marker remain intact. Remote lookup or source mismatch fails before
+ notes mutation; it must not silently turn a silent release into a notification.
+2. The POSIX installer first reuses a recognized Avibe `vibe` entrypoint in an
+ eligible writable directory on the original PATH, in PATH order. Keep the
+ entrypoint directory, not its resolved package-generation directory.
+ Relative, transient, and sbin entries remain ineligible for this preference.
+ Explicit generation/tool-environment bins are transient too, consistent with
+ the shared activation owner's existing stable-launcher boundary.
+ Recognize the shipped `vibe.cli:main` console script statically, including
+ legacy pip/uv installations. Never execute an unknown same-name command to
+ discover ownership. With no eligible existing entrypoint, retain selection
+ order among safe destinations. Occupied unrecognized paths, including broken
+ links, are not available for fresh installation or fallback activation.
+ Off-PATH, broken, and non-executable entries do not override PATH.
+ Staging, source-generation snapshot, and shared atomic activation stay owned
+ by the existing installer protocol.
+
+Windows already selects an explicit stable directory (configured tool bin or
+user-local bin), rather than the first writable PATH entry. No Windows change
+is needed for this failure.
+
+## Verification
+
+- Execute the actual notes workflow shell against disposable real Git repos:
+ annotated tags with current/legacy intent, checkout-rewritten local refs,
+ lightweight tags, prose-only mentions, existing-body fallback, idempotence,
+ unavailable remote refs, and mismatched remote sources.
+- Run the complete POSIX installer in isolated homes with its existing fake
+ package producer, real console-script shape, and activation protocol. Check
+ unowned executable/file/link/directory occupants in both PATH orders without
+ executing or overwriting them. Check the final launcher, original
+ generation preservation, absence of a second entry, source snapshot, PATH
+ precedence, and excluded directories. Failure must preserve the old launcher.
+- Run adjacent release/installer tests, changed Python lint, shell syntax, and
+ whitespace checks. PR review and exact-head CI remain required.
+
+Local result: 517 tests passed with zero skips across the installer, actual
+notes/public-verification shell, release state machine, update notification
+consumer, upgrade/activation flow, and package integrity suites. Changed-file
+Ruff 0.4.9, Bash syntax, whitespace, and UI build passed. Before the fix, the
+new regressions reproduced lost annotation intent, commit-prose false positives,
+missing/mismatched remote acceptance, and lost stable-launcher source identity.
+The task environment needed its own editable package/UI build for isolated
+upgrade subprocess probes; no production package was installed.
+Ownership regressions failed before the installer guard and passed afterward;
+the current managed/legacy launcher fixtures use executable Python entrypoints,
+not arbitrary same-name shell programs. Unknown custom wrappers are preserved,
+not probed or automatically adopted.
+
+## Boundaries and known-by-design
+
+No version/tag/asset changes, workflow dispatch/rerun, publication, production
+installation, service restart, configuration change, or real Show Page edit.
+Official v3.1.0 remains paused. This work does not change release package
+ownership, platform matrices, verification gates, or activation semantics.
+PR creation/review is authorized; merge awaits a separate owner instruction.
+
+Separately authorized Show Page repairs are outside this repository change and
+do not expand its release, deployment, or merge authority.
diff --git a/install.sh b/install.sh
index a702a7800..44a7d4424 100755
--- a/install.sh
+++ b/install.sh
@@ -123,11 +123,15 @@ is_transient_bin_dir() {
local dir="$1"
case "$dir" in
- */.venv/bin|*/venv/bin|*/env/bin|*/.pyenv/shims|*/.pyenv/versions/*/bin|*/.local/share/mise/installs/*/bin|*/.mise/installs/*/bin)
+ */.venv/bin|*/venv/bin|*/env/bin|*/.pyenv/shims|*/.pyenv/versions/*/bin|*/.local/share/mise/installs/*/bin|*/.mise/installs/*/bin|*/uv/tools/*/bin)
return 0
;;
esac
+ case "$dir" in
+ "$AVIBE_RUNTIME_HOME"/runtime/install-generations/*) return 0 ;;
+ esac
+
if [ -n "${VIRTUAL_ENV:-}" ] && [ "$dir" = "${VIRTUAL_ENV%/}/bin" ]; then
return 0
fi
@@ -152,14 +156,43 @@ is_transient_bin_dir() {
return 1
}
+is_avibe_launcher() {
+ # pip and uv generate this console script from vibe.cli:main, including
+ # legacy vibe-remote installs. Inspect it; never execute an unknown command
+ # merely because it happens to be named vibe. Symlinks retain their logical
+ # public directory while these reads follow the installed script.
+ [ -f "$1" ] && [ -x "$1" ] &&
+ LC_ALL=C grep -qE '^from vibe[.]cli import main[[:space:]]*$' "$1" &&
+ LC_ALL=C grep -qE '^[[:space:]]*sys[.]exit\(main\(\)\)[[:space:]]*$' "$1"
+}
+
+launcher_destination_is_available() {
+ { [ ! -e "$1/vibe" ] && [ ! -L "$1/vibe" ]; } || is_avibe_launcher "$1/vibe"
+}
+
choose_tool_bin_dir() {
local dir
local fallback_sbin_dir=""
local old_ifs="$IFS"
IFS=":"
+ # Reinstall through the established public entrypoint before choosing a new
+ # writable directory. Do not resolve its symlink into a package generation:
+ # the shared activation owner must keep switching this stable launcher.
+ for dir in $ORIGINAL_PATH; do
+ dir="${dir%/}"
+ if [ -n "$dir" ] && is_absolute_dir "$dir" &&
+ ! is_transient_bin_dir "$dir" && ! is_sbin_dir "$dir" &&
+ [ -w "$dir" ] && is_avibe_launcher "$dir/vibe"; then
+ IFS="$old_ifs"
+ echo "$dir"
+ return 0
+ fi
+ done
+
for dir in $ORIGINAL_PATH; do
- if [ -n "$dir" ] && is_absolute_dir "$dir" && ! is_transient_bin_dir "$dir" && ensure_writable_dir "$dir"; then
+ if [ -n "$dir" ] && is_absolute_dir "$dir" && ! is_transient_bin_dir "$dir" &&
+ launcher_destination_is_available "$dir" && ensure_writable_dir "$dir"; then
if is_sbin_dir "$dir"; then
if [ -z "$fallback_sbin_dir" ]; then
fallback_sbin_dir="$dir"
@@ -181,7 +214,7 @@ choose_tool_bin_dir() {
)
for dir in "${preferred_dirs[@]}"; do
- if is_absolute_dir "$dir" && ensure_writable_dir "$dir"; then
+ if is_absolute_dir "$dir" && launcher_destination_is_available "$dir" && ensure_writable_dir "$dir"; then
echo "$dir"
return 0
fi
@@ -420,6 +453,10 @@ uv_tool_install() {
local stable_bin_dir="${VIBE_TOOL_BIN_DIR:-$HOME/.local/bin}"
local previous_target=""
local source_snapshot=""
+ if ! launcher_destination_is_available "$stable_bin_dir"; then
+ warn "Refusing to replace an unrecognized vibe entrypoint in $stable_bin_dir"
+ return 1
+ fi
mkdir -p "$generation_tools" "$generation_bin" "$stable_bin_dir"
if [ -e "$stable_bin_dir/vibe" ] || [ -L "$stable_bin_dir/vibe" ]; then
previous_target="$(resolve_binary_path "$stable_bin_dir/vibe" || true)"
diff --git a/tests/test_install_script.py b/tests/test_install_script.py
index 692fc855b..d71bbde1a 100644
--- a/tests/test_install_script.py
+++ b/tests/test_install_script.py
@@ -3,9 +3,12 @@ from __future__ import annotations
import os
import stat
import subprocess
+import sys
import textwrap
from pathlib import Path
+import pytest
+
REPO_ROOT = Path(__file__).resolve().parents[1]
INSTALL_SCRIPT = REPO_ROOT / "install.sh"
@@ -20,6 +23,29 @@ def _write_executable(path: Path, content: str) -> None:
path.chmod(path.stat().st_mode | stat.S_IEXEC)
+def _write_console_launcher(path: Path, driver: str) -> None:
+ """Use the real packaged entrypoint shape around an isolated CLI double."""
+ module = path.parent / "test-module" / "vibe"
+ module.mkdir(parents=True, exist_ok=True)
+ (module / "__init__.py").write_text("", encoding="utf-8")
+ (module / "cli.py").write_text(
+ "import subprocess, sys\n"
+ f"def main():\n return subprocess.call(['bash', '-c', {textwrap.dedent(driver)!r}, *sys.argv])\n",
+ encoding="utf-8",
+ )
+ _write_executable(
+ path,
+ f"""\
+ #!{sys.executable}
+ import sys
+ from pathlib import Path
+ sys.path.insert(0, str(Path(__file__).resolve().parent / "test-module"))
+ from vibe.cli import main
+ sys.exit(main())
+ """,
+ )
+
+
def _run(command: str, *, cwd: Path, env: dict[str, str], timeout: int = 30) -> subprocess.CompletedProcess[str]:
return subprocess.run(
["bash", "-c", command],
@@ -52,7 +78,7 @@ def _write_fake_uv(path: Path, uv_log: Path) -> None:
bin_dir="${{UV_TOOL_BIN_DIR:-$HOME/.local/bin}}"
mkdir -p "$bin_dir"
- cat > "$bin_dir/vibe" <<'EOF'
+ cat > "$bin_dir/vibe-test-driver" <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
if [ "${{VIBE_TEST_REQUIRE_CANONICAL_HOME:-}}" = "1" ] && \
@@ -152,6 +178,23 @@ def _write_fake_uv(path: Path, uv_log: Path) -> None:
echo "started"
fi
EOF
+ mkdir -p "$bin_dir/test-module/vibe"
+ touch "$bin_dir/test-module/vibe/__init__.py"
+ cat > "$bin_dir/test-module/vibe/cli.py" <<'EOF'
+ import subprocess, sys
+ from pathlib import Path
+ def main():
+ driver = Path(__file__).resolve().parents[2] / "vibe-test-driver"
+ return subprocess.call(["bash", "-c", driver.read_text(), *sys.argv])
+ EOF
+ cat > "$bin_dir/vibe" <<'EOF'
+ #!{sys.executable}
+ import sys
+ from pathlib import Path
+ sys.path.insert(0, str(Path(__file__).resolve().parent / "test-module"))
+ from vibe.cli import main
+ sys.exit(main())
+ EOF
chmod +x "$bin_dir/vibe"
if [ "${{VIBE_TEST_LEGACY_ACTIVATION:-}}" = "1" ]; then
touch "$bin_dir/.legacy-activation"
@@ -435,7 +478,7 @@ def test_install_script_recovers_an_existing_3_0_13_generation(tmp_path):
old_generation = home_dir / ".avibe" / "runtime" / "install-generations" / "3.0.13"
old_vibe = old_generation / "tools" / "avibe-os" / "bin" / "vibe"
old_vibe.parent.mkdir(parents=True)
- _write_executable(
+ _write_console_launcher(
old_vibe,
"""\
#!/usr/bin/env bash
@@ -916,6 +959,190 @@ def test_install_script_prefers_original_path_order(tmp_path):
_assert_staged_uv_bin(uv_log, home_dir)
[email protected]("candidate_fails", [False, True])
+def test_install_script_reuses_existing_stable_launcher_after_path_changes(tmp_path, candidate_fails):
+ home_dir = tmp_path / "home"
+ home_dir.mkdir()
+ stable_bin = home_dir / ".local" / "bin"
+ stable_bin.mkdir(parents=True)
+ first_bin = tmp_path / "Framework Python bin"
+ first_bin.mkdir()
+ uv_log = tmp_path / "uv-tool-bin-dir.txt"
+ _write_fake_uv(first_bin / "uv", uv_log)
+ env = {
+ **os.environ,
+ "HOME": str(home_dir),
+ "AVIBE_HOME": str(home_dir / ".avibe"),
+ "PATH": os.pathsep.join([str(stable_bin), str(first_bin), "/usr/bin", "/bin"]),
+ }
+ first = _install(env, cwd=tmp_path)
+ assert first.returncode == 0, first.stdout + first.stderr
+ launcher = stable_bin / "vibe"
+ old_target = launcher.resolve()
+ old_bytes = old_target.read_bytes()
+ env["PATH"] = os.pathsep.join([str(first_bin), str(stable_bin), "/usr/bin", "/bin"])
+ env["VIBE_TEST_REQUIRE_SOURCE_GENERATION"] = "1"
+ if candidate_fails:
+ env["VIBE_TEST_CANDIDATE_PROBE_FAIL"] = "1"
+ # One exact candidate; do not exercise unrelated index fallbacks.
+ env["AVIBE_INSTALL_PACKAGE_SPEC"] = "avibe-os==9.9.9"
+ second = _install(env, cwd=tmp_path)
+
+ assert (second.returncode == 0) is (not candidate_fails), second.stdout + second.stderr
+ assert launcher.is_symlink()
+ assert (launcher.resolve() == old_target) is candidate_fails
+ assert old_target.read_bytes() == old_bytes
+ assert not (first_bin / "vibe").exists()
+ assert not (first_bin / ".legacy-activation").exists()
+ version = _vibe_version(env, cwd=tmp_path)
+ assert version.returncode == 0, version.stdout + version.stderr
+ assert "avibe-os 9.9.9" in version.stdout
+
+
+ "excluded",
+ ["relative", "venv", "pyenv", "mise", "sbin", "not-executable", "broken-link", "read-only",
+ "atomic-generation", "uv-environment"],
+)
+def test_install_script_existing_entrypoint_preference_keeps_directory_guards(tmp_path, excluded):
+ home_dir = tmp_path / "home"
+ home_dir.mkdir()
+ first_bin = tmp_path / "first-bin"
+ first_bin.mkdir()
+ excluded_bin = {
+ "relative": tmp_path / "relative-bin",
+ "venv": tmp_path / ".venv" / "bin",
+ "pyenv": tmp_path / ".pyenv" / "versions" / "3.12.0" / "bin",
+ "mise": tmp_path / ".local/share/mise/installs/python/3.12.0/bin",
+ "sbin": tmp_path / "usr" / "sbin",
+ "atomic-generation": home_dir / ".avibe/runtime/install-generations/old/bin",
+ "uv-environment": home_dir / ".local/share/uv/tools/avibe-os/bin",
+ }.get(excluded, tmp_path / "ineligible-bin")
+ excluded_bin.mkdir(parents=True)
+ uv_log = tmp_path / "uv-tool-bin-dir.txt"
+ _write_fake_uv(first_bin / "uv", uv_log)
+ excluded_launcher = excluded_bin / "vibe"
+ if excluded == "broken-link":
+ excluded_launcher.symlink_to(tmp_path / "absent")
+ else:
+ _write_console_launcher(excluded_launcher, "#!/bin/sh\necho old-excluded\n")
+ original_bytes = None if excluded == "broken-link" else excluded_launcher.read_bytes()
+ if excluded == "not-executable":
+ excluded_launcher.chmod(0o644)
+ if excluded == "read-only":
+ excluded_bin.chmod(0o555)
+ if os.access(excluded_bin, os.W_OK):
+ excluded_bin.chmod(0o755)
+ pytest.skip("Privileged test process can write mode-0555 directories")
+ path_entry = "relative-bin" if excluded == "relative" else str(excluded_bin)
+ env = {
+ **os.environ,
+ "HOME": str(home_dir),
+ "AVIBE_HOME": str(home_dir / ".avibe"),
+ "PATH": os.pathsep.join([str(first_bin), path_entry, "/usr/bin", "/bin"]),
+ }
+ try:
+ result = _install(env, cwd=tmp_path)
+ finally:
+ excluded_bin.chmod(0o755)
+ assert result.returncode == 0, result.stdout + result.stderr
+ assert (first_bin / "vibe").is_symlink()
+ if excluded == "broken-link":
+ assert excluded_launcher.readlink() == tmp_path / "absent"
+ else:
+ assert excluded_launcher.read_bytes() == original_bytes
+
+
+def test_install_script_reuses_first_eligible_existing_entrypoint(tmp_path):
+ home_dir = tmp_path / "home"
+ home_dir.mkdir()
+ bins = [tmp_path / name for name in ("empty-bin", "first-existing", "second-existing")]
+ for directory in bins:
+ directory.mkdir()
+ _write_fake_uv(bins[0] / "uv", tmp_path / "uv-log")
+ old_script = "#!/bin/sh\necho old-conventional-install\n"
+ for directory in bins[1:]:
+ _write_console_launcher(directory / "vibe", old_script)
+ untouched_bytes = (bins[2] / "vibe").read_bytes()
+ env = {
+ **os.environ, "HOME": str(home_dir), "AVIBE_HOME": str(home_dir / ".avibe"),
+ "PATH": os.pathsep.join([*(str(directory) for directory in bins), "/usr/bin", "/bin"]),
+ "VIBE_TEST_REQUIRE_SOURCE_GENERATION": "1",
+ }
+ result = _install(env, cwd=tmp_path)
+ assert result.returncode == 0, result.stdout + result.stderr
+ assert not (bins[0] / "vibe").exists()
+ assert (bins[1] / "vibe").is_symlink()
+ assert (bins[2] / "vibe").read_bytes() == untouched_bytes
+ assert "avibe-os 9.9.9" in _vibe_version(env, cwd=tmp_path).stdout
+
+
[email protected]("occupied_first", [False, True])
[email protected]("entry", ["script", "symlink", "broken-link", "non-executable", "directory"])
+def test_install_script_preserves_unowned_vibe_without_executing_it(tmp_path, occupied_first, entry):
+ home_dir = tmp_path / "home"
+ home_dir.mkdir()
+ free_bin = tmp_path / "free-bin"
+ occupied_bin = tmp_path / "occupied-bin"
+ free_bin.mkdir()
+ occupied_bin.mkdir()
+ _write_fake_uv(free_bin / "uv", tmp_path / "uv-log")
+ probe_log = tmp_path / "unowned-executed"
+ unrelated = tmp_path / "unrelated-program"
+ _write_executable(unrelated, f"#!/bin/sh\nprintf called >> '{probe_log}'\necho another-product\n")
+ original = unrelated.read_bytes()
+ occupant = occupied_bin / "vibe"
+ if entry in {"symlink", "broken-link"}:
+ occupant.symlink_to(unrelated if entry == "symlink" else tmp_path / "missing")
+ elif entry == "directory":
+ occupant.mkdir()
+ else:
+ _write_executable(occupant, unrelated.read_text())
+ if entry == "non-executable":
+ occupant.chmod(0o644)
+ order = [occupied_bin, free_bin] if occupied_first else [free_bin, occupied_bin]
+ result = _install({
+ **os.environ, "HOME": str(home_dir), "AVIBE_HOME": str(home_dir / ".avibe"),
+ "PATH": os.pathsep.join([*(str(item) for item in order), "/usr/bin", "/bin"]),
+ }, cwd=tmp_path)
+ assert result.returncode == 0, result.stdout + result.stderr
+ assert not probe_log.exists()
+ assert unrelated.read_bytes() == original
+ if entry in {"symlink", "broken-link"}:
+ assert occupant.readlink() == (unrelated if entry == "symlink" else tmp_path / "missing")
+ elif entry == "directory":
+ assert occupant.is_dir()
+ assert not tuple(occupant.iterdir())
+ else:
+ assert not occupant.is_symlink()
+ assert occupant.read_bytes() == original
+ assert (free_bin / "vibe").is_symlink()
+
+
+def test_install_script_activation_fallback_refuses_an_unowned_destination(tmp_path):
+ home_dir = tmp_path / "home"
+ stable_bin = home_dir / ".local" / "bin"
+ stable_bin.mkdir(parents=True)
+ probe_log = tmp_path / "unowned-executed"
+ original = f"#!/bin/sh\nprintf called >> '{probe_log}'\n"
+ _write_executable(stable_bin / "vibe", original)
+ uv_log = tmp_path / "uv-log"
+ _write_fake_uv(stable_bin / "uv", uv_log)
+ # Exercise the actual last-resort activation destination without main's
+ # selection pass; an empty selection must not bypass the ownership guard.
+ source = INSTALL_SCRIPT.read_text().rsplit('\nmain "$@"', 1)[0]
+ result = _run(source + "\nuv_tool_install avibe-os\n", cwd=tmp_path, env={
+ **os.environ, "HOME": str(home_dir), "AVIBE_HOME": str(home_dir / ".avibe"),
+ "PATH": os.pathsep.join([str(stable_bin), "/usr/bin", "/bin"]),
+ })
+ assert result.returncode != 0
+ assert "Refusing to replace an unrecognized vibe entrypoint" in result.stdout
+ assert (stable_bin / "vibe").read_text() == original
+ assert not probe_log.exists()
+ assert not uv_log.exists()
+ assert not (home_dir / ".avibe" / "runtime" / "install-generations").exists()
+
+
def test_install_script_skips_relative_path_entries_for_tool_bin(tmp_path):
home_dir = tmp_path / "home"
home_dir.mkdir()
diff --git a/tests/test_release_verification.py b/tests/test_release_verification.py
index 9093cd8a4..5df803084 100644
--- a/tests/test_release_verification.py
+++ b/tests/test_release_verification.py
@@ -23,6 +23,116 @@ WORKFLOWS = (
)
+ ("annotation", "existing_body", "silent"),
+ [
+ ("说明\n<!-- avibe:update-notification=none -->", "", True),
+ ("vibe-remote:update-notification=none", "", True),
+ ("Ordinary annotated release", "", False),
+ (None, "", False),
+ (None, "<!-- vibe-remote:update-notification=none -->", True),
+ (None, "Document `avibe:update-notification=none` in prose.", False),
+ ],
+)
[email protected]("rewritten", [False, True])
+def test_notes_shell_reads_remote_annotation_not_checkout_ref(
+ tmp_path, annotation, existing_body, silent, rewritten,
+):
+ remote, workspace, env, tag, source, command = _notes_git_fixture(
+ tmp_path, annotation=annotation, existing_body=existing_body,
+ )
+ if rewritten:
+ _fixture_git(workspace, "update-ref", f"refs/tags/{tag}", source)
+ local_object = _fixture_git(workspace, "rev-parse", f"refs/tags/{tag}")
+ remote_object = _fixture_git(remote, "rev-parse", f"refs/tags/{tag}")
+ notes = workspace / "release.md"
+ notes.write_text("# Release 发布说明\n\nChanges and changes in Chinese.\n", encoding="utf-8")
+ for _ in range(2):
+ result = subprocess.run(
+ ["bash", "--noprofile", "--norc", "-e", "-o", "pipefail", "-c", command],
+ cwd=workspace, env=env, capture_output=True, text=True, timeout=15,
+ )
+ assert result.returncode == 0, result.stdout + result.stderr
+ text = notes.read_text(encoding="utf-8")
+ for brand in ("avibe", "vibe-remote"):
+ assert text.count(f"<!-- {brand}:update-notification=none -->") == int(silent)
+ assert text.count(f"<!-- avibe:release-notes=ready source={source} run=42 -->") == 1
+ assert "# Release 发布说明" in text
+ assert _fixture_git(workspace, "rev-parse", f"refs/tags/{tag}") == local_object
+ assert _fixture_git(remote, "rev-parse", f"refs/tags/{tag}") == remote_object
+
+
[email protected]("failure", ["missing-tag", "source-mismatch"])
+def test_notes_shell_does_not_mutate_notes_when_remote_tag_cannot_be_bound(tmp_path, failure):
+ remote, workspace, env, tag, source, command = _notes_git_fixture(
+ tmp_path, annotation="<!-- avibe:update-notification=none -->",
+ existing_body="<!-- vibe-remote:update-notification=none -->",
+ )
+ _fixture_git(remote, "update-ref", "-d", f"refs/tags/{tag}")
+ if failure == "source-mismatch":
+ _fixture_git(remote, "commit", "--allow-empty", "-m", "Different release source")
+ _fixture_git(remote, "tag", "-a", tag, "-m", "Replacement annotation")
+ notes = workspace / "release.md"
+ before = b"# Untouched release notes\n"
+ notes.write_bytes(before)
+ result = subprocess.run(
+ ["bash", "--noprofile", "--norc", "-e", "-o", "pipefail", "-c", command],
+ cwd=workspace, env=env, capture_output=True, text=True, timeout=15,
+ )
+ assert result.returncode != 0, result.stdout + result.stderr
+ assert notes.read_bytes() == before
+ assert _fixture_git(workspace, "rev-parse", f"refs/tags/{tag}^{{commit}}") == source
+
+
+def _fixture_git(directory, *arguments):
+ return subprocess.run(
+ ["git", "-C", str(directory), "-c", "user.name=Release test",
+ "-c", "[email protected]", "-c", "commit.gpgsign=false",
+ "-c", "tag.gpgsign=false", *arguments],
+ check=True, capture_output=True, text=True, timeout=15,
+ ).stdout.strip()
+
+
+def _notes_git_fixture(tmp_path, *, annotation, existing_body):
+ remote = tmp_path / "remote 中文"
+ remote.mkdir()
+ _fixture_git(remote, "init")
+ # Lightweight commit-message prose is not an annotation. Annotated cases
+ # use an ordinary commit, reproducing checkout losing actual silent intent.
+ message = (
+ "Document avibe:update-notification=none without selecting that policy"
+ if annotation is None else "Release source"
+ )
+ _fixture_git(remote, "commit", "--allow-empty", "-m", message)
+ source = _fixture_git(remote, "rev-parse", "HEAD")
+ tag = "gh-v3.1.0rc1"
+ if annotation is None:
+ _fixture_git(remote, "tag", tag)
+ else:
+ _fixture_git(remote, "tag", "-a", tag, "-m", annotation)
+ workspace = tmp_path / "checkout 中文"
+ _fixture_git(tmp_path, "clone", "--no-hardlinks", str(remote), str(workspace))
+ binaries = tmp_path / "bin"
+ binaries.mkdir()
+ gh = binaries / "gh"
+ gh.write_text(
+ f"#!{sys.executable}\nimport sys\n"
+ f"assert sys.argv[1:] == {['release', 'view', tag, '--repo', 'avibe-bot/avibe', '--json', 'body', '--jq', '.body']!r}\n"
+ f"print({existing_body!r})\n",
+ encoding="utf-8",
+ )
+ gh.chmod(0o755)
+ env = {
+ **os.environ, "PATH": f"{binaries}{os.pathsep}{os.environ['PATH']}",
+ "TAG": tag, "GITHUB_RUN_ID": "42", "GITHUB_REPOSITORY": "avibe-bot/avibe",
+ }
+ command = _step(
+ _job("release_ai.yml", "release"),
+ "Preserve silent-update marker (tag annotation or existing release body)",
+ )["run"]
+ return remote, workspace, env, tag, source, command
+
+
@pytest.mark.parametrize("failure", [None, "missing-wheel", "missing-sdist", "mismatch", "unpublished"])
@pytest.mark.parametrize(
("tag", "version"),