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.

feat(release): add version-less latest desktop installer links to dl.avibe.bot (#3046)

Call White69ce15ee2160
diff --git a/docs/plans/release-download-mirror.md b/docs/plans/release-download-mirror.md
index bbcf09022..60aa5b7c9 100644
--- a/docs/plans/release-download-mirror.md
+++ b/docs/plans/release-download-mirror.md
@@ -58,6 +58,14 @@ only the releases that `vibe/ripgrep_runtime_manifest.json` and
asset name never change bytes.
- `https://dl.avibe.bot/<root>index/releases.json` is the repository's release
index: `Cache-Control: public, max-age=60`.
+- `https://dl.avibe.bot/latest/Avibe_<target>.<ext>` is a stable download
+ link for people, not clients: a copy of `Avibe_<version>_<target>.<ext>`
+ (`.dmg` and `.exe` installers) from the highest-SemVer stable `vX.Y.Z`
+ release that ships installers, the release the desktop updater's stable
+ channel offers. Its bytes change when that release changes, so it carries
+ `Cache-Control: public, max-age=60` and
+ `Content-Disposition: attachment; filename="Avibe_<version>_<target>.<ext>"`.
+ Only Avibe's root has `latest/`; clients keep using versioned URLs.
- Other top-level prefixes are reserved and never touched by the release
mirror (for example a future `thirdparty/` for install-script dependencies).
A new mirrored repository takes a new root.
@@ -125,10 +133,14 @@ reconciles each mirrored repository against its own root:
3. Upload each selected asset that is missing, has the wrong size, or is not
recorded with the same digest in the previous index, after verifying the
downloaded size and sha256 against GitHub's digest.
-4. Write the index if its bytes changed, then delete `<root>releases/` objects
- that left the selection. Objects appear before the index names them and
- disappear only after it stops naming them.
-5. If GitHub's digest for an indexed asset changed, re-upload it and fail the
+4. For Avibe, copy each `latest/` installer whose recorded sha256 differs
+ from its source inside the bucket, after the source is verified or
+ uploaded.
+5. Write the index if its bytes changed, then delete `<root>releases/` objects
+ that left the selection and `latest/` installers the latest release no
+ longer ships. Objects appear before the index names them and disappear only
+ after it stops naming them.
+6. If GitHub's digest for an indexed asset changed, re-upload it and fail the
run: published bytes changed, and edge caches may hold the old copy until
that URL is purged.
diff --git a/docs/release.md b/docs/release.md
index 099f65778..f970fd81b 100644
--- a/docs/release.md
+++ b/docs/release.md
@@ -50,5 +50,7 @@ that guard: the mirror holds the pinned release, verified against the manifest.
`https://dl.avibe.bot/releases/<tag>/<asset>` and writes the release index at
`https://dl.avibe.bot/index/releases.json`. It follows the publishing
workflows, so a renamed publishing workflow must also be renamed in its
-trigger. The contract and retention rules are in
+trigger. It also keeps version-less links to the newest stable desktop
+installers, such as
+`https://dl.avibe.bot/latest/Avibe_aarch64-apple-darwin.dmg`. The contract and retention rules are in
`docs/plans/release-download-mirror.md`.
diff --git a/scripts/release_mirror.py b/scripts/release_mirror.py
index a8e97ff02..829a400d3 100644
--- a/scripts/release_mirror.py
+++ b/scripts/release_mirror.py
@@ -3,7 +3,8 @@
GitHub stays the source of truth. For each mirrored repository the bucket holds
byte-identical copies under ``<root>releases/<tag>/<asset>`` and a release
-index at ``<root>index/releases.json``; see
+index at ``<root>index/releases.json``. Avibe's root also holds version-less
+``latest/`` copies of the newest stable desktop installers; see
``docs/plans/release-download-mirror.md`` for the contract.
"""
@@ -52,13 +53,21 @@ FULL_RELEASES_ONLY = frozenset({"tmux/tmux-builds"})
RELEASE_PREFIX = "releases/"
INDEX_KEY = "index/releases.json"
IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immutable"
-INDEX_CACHE_CONTROL = "public, max-age=60"
+# The index and the ``latest/`` installers change bytes under one URL.
+MUTABLE_CACHE_CONTROL = "public, max-age=60"
+# ``latest/Avibe_<target>.<ext>`` copies ``Avibe_<version>_<target>.<ext>`` from
+# the highest stable release that ships installers. Only Avibe's root has them.
+LATEST_REPOSITORY = "avibe-bot/avibe"
+LATEST_PREFIX = "latest/"
+INSTALLER_SUFFIXES = (".dmg", ".exe")
DEFAULT_KEEP_PRERELEASES = 20
INDEX_SCHEMA_VERSION = 1
_NAME_RE = re.compile(r"[A-Za-z0-9._+-]+")
_SHA256_RE = re.compile(r"[0-9a-f]{64}")
_COMMIT_RE = re.compile(r"[0-9a-f]{40}")
+# The desktop updater's stable channel: canonical ``vX.Y.Z`` full releases.
+_STABLE_TAG_RE = re.compile(r"v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)")
class MirrorError(RuntimeError):
@@ -98,6 +107,8 @@ class Release:
@dataclass(frozen=True)
class Plan:
uploads: tuple[tuple[str, Asset], ...]
+ # ``(latest key, source key, asset)``, copied in the bucket after uploads.
+ aliases: tuple[tuple[str, str, Asset], ...]
deletions: tuple[str, ...]
# Keys whose published bytes changed upstream. Edge caches may still hold
# the old copy for up to a year, so these fail the run after repair.
@@ -177,6 +188,28 @@ def select(releases: Sequence[Release], keep_prereleases: int) -> list[Release]:
return [release for release in ordered if not release.prerelease or release in prereleases]
+def latest_installers(releases: Sequence[Release]) -> dict[str, tuple[str, Asset]]:
+ """Map each ``latest/`` key to its source in the highest stable release that ships installers.
+
+ SemVer orders the releases, as in the desktop updater; publication order never counts.
+ """
+ stable = [
+ (tuple(int(part) for part in match.groups()), release)
+ for release in releases
+ if not release.prerelease and (match := _STABLE_TAG_RE.fullmatch(release.tag))
+ ]
+ for _, release in sorted(stable, key=lambda item: item[0], reverse=True):
+ prefix = f"Avibe_{release.tag.removeprefix('v')}_"
+ installers = {
+ f"{LATEST_PREFIX}Avibe_{asset.name.removeprefix(prefix)}": (release.key(asset), asset)
+ for asset in release.assets
+ if asset.name.startswith(prefix) and asset.name.endswith(INSTALLER_SUFFIXES)
+ }
+ if installers:
+ return installers
+ return {}
+
+
def render_index(repository: str, releases: Sequence[Release]) -> bytes:
document = {
"schema_version": INDEX_SCHEMA_VERSION,
@@ -252,11 +285,13 @@ def plan(
releases: Sequence[Release],
objects: Mapping[str, int],
previous_index: bytes | None,
+ latest: Mapping[str, str | None] | None = None,
) -> Plan:
"""Compare the selected releases with the repository's ``releases/`` objects.
A manifest-pinned repository's root only grows: its objects are the backup of
- every release a published manifest pinned.
+ every release a published manifest pinned. ``latest`` maps each existing
+ ``latest/`` object to the sha256 it was copied with.
"""
if not releases:
raise MirrorError(f"GitHub returned no published releases for {repository}; refusing to reconcile")
@@ -279,8 +314,19 @@ def plan(
if repository in PINNED_BY_MANIFEST
else sorted(key for key in objects if key.startswith(prefix) and key not in expected)
)
+ aliases = []
+ if repository == LATEST_REPOSITORY:
+ current = latest or {}
+ installers = latest_installers(releases)
+ aliases = [
+ (key, source, asset)
+ for key, (source, asset) in sorted(installers.items())
+ if current.get(key) != asset.sha256
+ ]
+ deletions += sorted(key for key in current if key not in installers)
return Plan(
uploads=tuple(uploads),
+ aliases=tuple(aliases),
deletions=tuple(deletions),
changed=tuple(changed),
index=render_index(repository, releases),
@@ -365,6 +411,22 @@ class Bucket:
"--metadata", f"sha256={sha256}",
)
+ def copy(
+ self, source: str, key: str, *, content_type: str, cache_control: str, content_disposition: str, sha256: str
+ ) -> None:
+ # A server-side copy; REPLACE gives the copy its own headers.
+ self._s3api(
+ "copy-object", "--copy-source", f"{self.name}/{source}", "--key", key,
+ "--metadata-directive", "REPLACE", "--content-type", content_type,
+ "--cache-control", cache_control, "--content-disposition", content_disposition,
+ "--metadata", f"sha256={sha256}",
+ )
+
+ def sha256(self, key: str) -> str | None:
+ """Return the sha256 this job recorded on ``key``."""
+ head = json.loads(self._s3api("head-object", "--key", key, "--output", "json"))
+ return (head.get("Metadata") or {}).get("sha256")
+
def delete(self, key: str) -> None:
# DeleteObjects requires a request checksum that R2 may not implement.
self._s3api("delete-object", "--key", key)
@@ -380,11 +442,16 @@ def reconcile(repository: str, bucket: Bucket, *, keep_prereleases: int, dry_run
previous_index = bucket.read(key) if key in objects else None
if repository in PINNED_BY_MANIFEST:
releases = with_earlier_pins(repository, releases, previous_index)
- result = plan(repository, releases, objects, previous_index)
+ latest = (
+ {name: bucket.sha256(name) for name in objects if name.startswith(LATEST_PREFIX)}
+ if repository == LATEST_REPOSITORY
+ else None
+ )
+ result = plan(repository, releases, objects, previous_index, latest)
size = sum(asset.size for _, asset in result.uploads)
print(
f"{repository}: {len(releases)} releases mirrored; "
- f"{len(result.uploads)} uploads ({size / 1e9:.2f} GB), "
+ f"{len(result.uploads)} uploads ({size / 1e9:.2f} GB), {len(result.aliases)} latest copies, "
f"{len(result.deletions)} deletions, index {'unchanged' if result.index == previous_index else 'changed'}"
)
for changed in result.changed:
@@ -392,6 +459,8 @@ def reconcile(repository: str, bucket: Bucket, *, keep_prereleases: int, dry_run
if dry_run:
for upload, _ in result.uploads:
print(f"would upload {upload}")
+ for alias, source, _ in result.aliases:
+ print(f"would copy {source} to {alias}")
for deletion in result.deletions:
print(f"would delete {deletion}")
else:
@@ -404,11 +473,18 @@ def reconcile(repository: str, bucket: Bucket, *, keep_prereleases: int, dry_run
cache_control=IMMUTABLE_CACHE_CONTROL, sha256=asset.sha256,
)
print(f"uploaded {upload}")
+ # Sources exist now: each was verified earlier or uploaded above.
+ for alias, source, asset in result.aliases:
+ bucket.copy(
+ source, alias, content_type=asset.content_type, cache_control=MUTABLE_CACHE_CONTROL,
+ content_disposition=f'attachment; filename="{asset.name}"', sha256=asset.sha256,
+ )
+ print(f"copied {source} to {alias}")
if result.index != previous_index:
path.write_bytes(result.index)
bucket.put(
key, path, content_type="application/json",
- cache_control=INDEX_CACHE_CONTROL, sha256=hashlib.sha256(result.index).hexdigest(),
+ cache_control=MUTABLE_CACHE_CONTROL, sha256=hashlib.sha256(result.index).hexdigest(),
)
print(f"wrote {key}")
# Delete only after the index stops listing these objects.
diff --git a/tests/test_release_mirror.py b/tests/test_release_mirror.py
index 339abf153..7731a7d4f 100644
--- a/tests/test_release_mirror.py
+++ b/tests/test_release_mirror.py
@@ -240,21 +240,79 @@ def test_ripgrep_diverging_from_its_manifest_fails_without_touching_the_mirror(m
def test_a_completed_reconcile_is_a_no_op_on_the_next_run():
selected = releases(
- github_release("v1.0.0", published_at="2026-01-01T00:00:00Z", assets=("a.tgz", "b+local.whl")),
+ github_release(
+ "v1.0.0", published_at="2026-01-01T00:00:00Z",
+ assets=("a.tgz", "b+local.whl", "Avibe_1.0.0_aarch64-apple-darwin.dmg"),
+ ),
github_release("gh-v1.0.1rc1", published_at="2026-01-02T00:00:00Z", prerelease=True),
)
first = mirror.plan(REPOSITORY, selected, {}, None)
objects = {key: asset.size for key, asset in first.uploads}
+ latest = {key: asset.sha256 for key, _, asset in first.aliases}
- again = mirror.plan(REPOSITORY, selected, objects, first.index)
+ again = mirror.plan(REPOSITORY, selected, {**objects, **dict.fromkeys(latest, 1)}, first.index, latest)
- assert (again.uploads, again.deletions, again.changed) == ((), (), ())
+ assert first.aliases
+ assert (again.uploads, again.aliases, again.deletions, again.changed) == ((), (), (), ())
assert again.index == first.index
+def test_latest_installers_follow_the_highest_stable_release_that_ships_them():
+ installers = (
+ "aarch64-apple-darwin.dmg", "aarch64-apple-darwin.app.tar.gz", "x86_64-pc-windows-msvc.exe",
+ )
+ selected = releases(
+ github_release(
+ "v1.10.0", published_at="2026-01-01T00:00:00Z",
+ assets=(*(f"Avibe_1.10.0_{name}" for name in installers), "desktop-update-aarch64-apple-darwin.json"),
+ ),
+ # Publication order never counts: a later patch to an older line is not the latest.
+ github_release("v1.9.1", published_at="2026-01-05T00:00:00Z",
+ assets=tuple(f"Avibe_1.9.1_{name}" for name in installers)),
+ github_release("v1.11.0", published_at="2026-01-06T00:00:00Z", assets=("avibe_os-1.11.0.tar.gz",)),
+ github_release("gh-v1.12.0rc1", published_at="2026-01-07T00:00:00Z", prerelease=True,
+ assets=tuple(f"Avibe_1.12.0-rc.1_{name}" for name in installers)),
+ )
+ latest = {
+ "latest/Avibe_aarch64-apple-darwin.dmg": "0" * 64,
+ "latest/Avibe_x86_64-apple-darwin.dmg": "0" * 64,
+ }
+
+ result = mirror.plan(REPOSITORY, selected, dict.fromkeys(latest, 1), None, latest)
+
+ assert [(key, source) for key, source, _ in result.aliases] == [
+ ("latest/Avibe_aarch64-apple-darwin.dmg", "releases/v1.10.0/Avibe_1.10.0_aarch64-apple-darwin.dmg"),
+ ("latest/Avibe_x86_64-pc-windows-msvc.exe", "releases/v1.10.0/Avibe_1.10.0_x86_64-pc-windows-msvc.exe"),
+ ]
+ assert result.deletions == ("latest/Avibe_x86_64-apple-darwin.dmg",)
+ # Only Avibe's root carries latest installers.
+ assert mirror.plan("avibe-bot/askill", selected, {}, None, latest).aliases == ()
+
+
+def test_latest_installers_are_copied_from_their_verified_source_and_stale_ones_removed(monkeypatch):
+ item = github_release("v1.0.0", published_at="2026-01-01T00:00:00Z",
+ assets=("Avibe_1.0.0_aarch64-apple-darwin.dmg",))
+ bucket = RecordingBucket({"latest/Avibe_x86_64-pc-windows-msvc.exe": 1}, None)
+ monkeypatch.setattr(mirror, "github_releases", lambda repository: [item])
+ monkeypatch.setattr(mirror, "tag_commits", lambda repository: {"v1.0.0": "0" * 40})
+ monkeypatch.setattr(mirror, "download", lambda asset, destination: destination.write_bytes(b""))
+
+ assert mirror.reconcile(REPOSITORY, bucket, keep_prereleases=20, dry_run=False) == 0
+ source = "releases/v1.0.0/Avibe_1.0.0_aarch64-apple-darwin.dmg"
+ assert bucket.writes == [
+ source, "latest/Avibe_aarch64-apple-darwin.dmg", "index/releases.json",
+ "latest/Avibe_x86_64-pc-windows-msvc.exe",
+ ]
+ ((copied, metadata),) = bucket.copies
+ assert copied == source
+ assert metadata["cache_control"] == "public, max-age=60"
+ assert metadata["content_disposition"] == 'attachment; filename="Avibe_1.0.0_aarch64-apple-darwin.dmg"'
+ assert metadata["sha256"] == hashlib.sha256(b"Avibe_1.0.0_aarch64-apple-darwin.dmg").hexdigest()
+
+
class RecordingBucket:
def __init__(self, objects, index):
- self._objects, self._index, self.writes = objects, index, []
+ self._objects, self._index, self.writes, self.copies = objects, index, [], []
def objects(self):
return dict(self._objects)
@@ -265,6 +323,13 @@ class RecordingBucket:
def put(self, key, path, **metadata):
self.writes.append(key)
+ def copy(self, source, key, **metadata):
+ self.writes.append(key)
+ self.copies.append((source, metadata))
+
+ def sha256(self, key):
+ return None
+
def delete(self, key):
self.writes.append(key)