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(regression): expose deployed source identity (#940)

Call White993530a2404a
diff --git a/core/update_checker.py b/core/update_checker.py
index f82aecded..a10f7aa69 100644
--- a/core/update_checker.py
+++ b/core/update_checker.py
@@ -25,6 +25,7 @@ from config import paths
from config.v2_config import UpdateConfig
from config.v2_settings import _infer_channel_platform, _infer_user_platform, _split_scoped_key
from modules.im import InlineButton, InlineKeyboard, MessageContext
+from vibe.build_identity import get_build_identity
from vibe.i18n import t as i18n_t
from vibe.upgrade import (
PACKAGE_NAME,
@@ -67,6 +68,8 @@ def _fetch_pypi_version_sync() -> Dict[str, Any]:
current = __version__
result = {"current": current, "latest": None, "has_update": False, "error": None}
+ if get_build_identity().kind == "source":
+ return result
try:
url = get_update_metadata_url()
diff --git a/docs/plans/regression-source-identity.md b/docs/plans/regression-source-identity.md
new file mode 100644
index 000000000..cc7b18119
--- /dev/null
+++ b/docs/plans/regression-source-identity.md
@@ -0,0 +1,43 @@
+# Regression Source Identity
+
+## Background
+
+The Incus regression runner syncs the active source tree on every update, but
+only refreshes the editable Python installation when dependency inputs change.
+`vibe.__version__` can therefore describe an older editable-install build while
+the service is executing newer backend source and UI assets. Using that package
+version as the deployed build identity also produces false PyPI update prompts.
+
+## Goal
+
+- Identify the exact source revision served by local Incus regression targets.
+- Keep the package version and its semantic update behavior unchanged for
+ packaged installs.
+- Avoid reinstalling unchanged Python dependencies just to refresh display
+ metadata.
+
+## Design
+
+The regression runner already rewrites `/var/lib/avibe-regression/metadata.json`
+after every source sync with the deployed commit and dirty state. The systemd
+service will declare that file through `VIBE_BUILD_METADATA_PATH`. A small
+shared build-identity reader will expose it as a source build without treating
+the Git revision as a package version.
+
+`/api/version` remains backward compatible: `current`, `latest`, `has_update`,
+and `error` keep their existing meanings for packaged installs. It gains a
+`build` object. Source builds report their revision there and skip product
+package update checks; the UI shows the source revision as the primary badge
+identity and labels the stale install-time value as package metadata.
+
+No scenario catalog entry currently covers regression deployment identity.
+Focused runner, API, and update-checker tests cover this boundary.
+
+## Acceptance
+
+- Two metadata refreshes with an unchanged dependency fingerprint produce two
+ different source identities without rebuilding package metadata.
+- Source deployments do not advertise a PyPI update from stale package data.
+- Packaged deployments retain the existing semantic version comparison.
+- The local worktree Incus environment reports the branch head through
+ `/api/version` after repeated source syncs.
diff --git a/docs/regression/README.md b/docs/regression/README.md
index 47f993333..7e653ca3c 100644
--- a/docs/regression/README.md
+++ b/docs/regression/README.md
@@ -186,6 +186,9 @@ The Incus runner separates slow-changing dependencies from fast-changing source:
- **Service**: Avibe runs under `avibe-regression.service` as user `avibe`.
- **Home**: `/home/avibe/.avibe` is the active product state home;
`/home/avibe/.vibe_remote` is a compatibility symlink.
+- **Build identity**: the version badge and `/api/version` report the commit
+ recorded by the latest source sync separately from install-time package
+ metadata. Source targets do not use that package metadata for update prompts.
- **Show Runtime**: every successful update runs `vibe runtime prepare --strict`
and then verifies `vibe runtime status --json`.
diff --git a/scripts/incus_regression.py b/scripts/incus_regression.py
index 481f1c7fe..b543bf4b2 100644
--- a/scripts/incus_regression.py
+++ b/scripts/incus_regression.py
@@ -506,6 +506,7 @@ def regression_service_unit() -> str:
Environment=HOME={SERVICE_HOME}
Environment=AVIBE_HOME=
Environment=VIBE_DEPLOYMENT_ENV=regression
+ Environment=VIBE_BUILD_METADATA_PATH={METADATA_PATH}
Environment=AVIBE_ALLOW_DEV_STATE_MIGRATION=1
Environment=VIBE_INTERNAL_DISPATCH_SOCKET=/tmp/vibe_remote/dispatch.sock
Environment=PYTHONUNBUFFERED=1
diff --git a/tests/test_incus_regression.py b/tests/test_incus_regression.py
index c2bd87da3..b9601a736 100644
--- a/tests/test_incus_regression.py
+++ b/tests/test_incus_regression.py
@@ -244,6 +244,7 @@ def test_cloud_init_configures_systemd_service_without_source_code() -> None:
assert "name: avibe" in data
assert "Description=Avibe regression service" in data
assert "Environment=VIBE_DEPLOYMENT_ENV=regression" in data
+ assert "Environment=VIBE_BUILD_METADATA_PATH=/var/lib/avibe-regression/metadata.json" in data
assert "Environment=AVIBE_ALLOW_DEV_STATE_MIGRATION=1" in data
assert "EnvironmentFile=-/etc/avibe-regression.env" in data
assert "ExecStart=/opt/avibe/venv/bin/python scripts/incus_regression_supervisor.py" in data
diff --git a/tests/test_version_identity.py b/tests/test_version_identity.py
new file mode 100644
index 000000000..519672f73
--- /dev/null
+++ b/tests/test_version_identity.py
@@ -0,0 +1,78 @@
+import json
+
+from core import update_checker
+from vibe import api
+
+
+def _write_metadata(path, *, commit: str, fingerprint: str = "same") -> None:
+ path.write_text(
+ json.dumps(
+ {
+ "schema_version": 1,
+ "commit": commit,
+ "dirty": False,
+ "fingerprints": {"python": fingerprint},
+ }
+ ),
+ encoding="utf-8",
+ )
+
+
+def test_source_sync_identity_refreshes_without_package_reinstall(monkeypatch, tmp_path) -> None:
+ metadata_path = tmp_path / "metadata.json"
+ first_revision = "1" * 40
+ second_revision = "2" * 40
+ monkeypatch.setenv("VIBE_BUILD_METADATA_PATH", str(metadata_path))
+ monkeypatch.setattr("vibe.__version__", "3.0.6rc5", raising=False)
+ monkeypatch.setattr(api, "get_latest_version_info", lambda _current: (_ for _ in ()).throw(AssertionError("source builds must not query PyPI")))
+
+ _write_metadata(metadata_path, commit=first_revision)
+ first = api.get_version_info()
+ _write_metadata(metadata_path, commit=second_revision)
+ second = api.get_version_info()
+
+ assert first == {
+ "current": "3.0.6rc5",
+ "latest": None,
+ "has_update": False,
+ "error": None,
+ "build": {"kind": "source", "revision": first_revision, "dirty": False},
+ }
+ assert second["current"] == first["current"]
+ assert second["build"] == {"kind": "source", "revision": second_revision, "dirty": False}
+
+
+def test_source_build_skips_background_package_update_check(monkeypatch, tmp_path) -> None:
+ metadata_path = tmp_path / "metadata.json"
+ _write_metadata(metadata_path, commit="a" * 40)
+ monkeypatch.setenv("VIBE_BUILD_METADATA_PATH", str(metadata_path))
+ monkeypatch.setattr("vibe.__version__", "3.0.6rc5", raising=False)
+ monkeypatch.setattr(
+ update_checker.urllib.request,
+ "urlopen",
+ lambda *_args, **_kwargs: (_ for _ in ()).throw(AssertionError("source builds must not query PyPI")),
+ )
+
+ assert update_checker._fetch_pypi_version_sync() == {
+ "current": "3.0.6rc5",
+ "latest": None,
+ "has_update": False,
+ "error": None,
+ }
+
+
+def test_packaged_install_keeps_semantic_update_behavior(monkeypatch) -> None:
+ expected = {"current": "3.0.6", "latest": "3.0.7", "has_update": True, "error": None}
+ monkeypatch.delenv("VIBE_BUILD_METADATA_PATH", raising=False)
+ monkeypatch.setattr("vibe.__version__", "3.0.6", raising=False)
+ monkeypatch.setattr(api, "get_latest_version_info", lambda current: expected if current == "3.0.6" else None)
+
+ assert api.get_version_info() == {**expected, "build": {"kind": "package"}}
+
+
+def test_configured_missing_metadata_stays_a_source_build(monkeypatch, tmp_path) -> None:
+ monkeypatch.setenv("VIBE_BUILD_METADATA_PATH", str(tmp_path / "not-written-yet.json"))
+ monkeypatch.setattr("vibe.__version__", "3.0.6rc5", raising=False)
+ monkeypatch.setattr(api, "get_latest_version_info", lambda _current: (_ for _ in ()).throw(AssertionError("source builds must not query PyPI")))
+
+ assert api.get_version_info()["build"] == {"kind": "source"}
diff --git a/ui/src/components/VersionBadge.tsx b/ui/src/components/VersionBadge.tsx
index 472f4e971..b7b600df8 100644
--- a/ui/src/components/VersionBadge.tsx
+++ b/ui/src/components/VersionBadge.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useApi, type VersionInfo, type UpgradeResult } from '../context/ApiContext';
-import { Download, X, RefreshCw, Check, AlertCircle } from 'lucide-react';
+import { Download, X, RefreshCw, Check, AlertCircle, GitCommitHorizontal } from 'lucide-react';
import clsx from 'clsx';
import { ToggleSwitch } from './settings/SettingsPrimitives';
import { Button } from './ui/button';
@@ -108,7 +108,16 @@ export const VersionBadge: React.FC<{ openUpward?: boolean }> = ({ openUpward =
const hasUpdate = versionInfo?.has_update === true;
const currentVersion = versionInfo?.current || '...';
- const displayVersion = shortenVersion(currentVersion);
+ const isSourceBuild = versionInfo?.build?.kind === 'source';
+ const sourceRevision = versionInfo?.build?.revision;
+ const shortSourceRevision = sourceRevision?.slice(0, 12) || t('dashboard.unknownRevision');
+ const displayVersion = isSourceBuild ? shortSourceRevision : shortenVersion(currentVersion);
+ const refreshLabel = checking
+ ? t('dashboard.checking')
+ : t(isSourceBuild ? 'dashboard.refreshBuildInfo' : 'dashboard.checkUpdate');
+ const badgeTitle = isSourceBuild
+ ? `${t('dashboard.sourceRevision')}: ${sourceRevision || t('dashboard.unknownRevision')}${versionInfo?.build?.dirty ? ` (${t('dashboard.dirtySource')})` : ''}`
+ : `v${currentVersion}`;
return (
<div className="relative" ref={popupRef}>
@@ -120,9 +129,10 @@ export const VersionBadge: React.FC<{ openUpward?: boolean }> = ({ openUpward =
badgeVariants({ variant: hasUpdate ? 'warning' : 'secondary' }),
'relative cursor-pointer rounded-md font-medium tracking-normal hover:brightness-110 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
)}
- title={`v${currentVersion}`}
+ title={badgeTitle}
>
- v{displayVersion}
+ {isSourceBuild ? <GitCommitHorizontal size={12} /> : 'v'}
+ {displayVersion}
{hasUpdate && (
<span className="absolute -top-1 -right-1 size-2.5 rounded-full border-2 border-background bg-gold animate-pulse" />
)}
@@ -144,7 +154,9 @@ export const VersionBadge: React.FC<{ openUpward?: boolean }> = ({ openUpward =
>
{/* Header */}
<div className="flex items-center justify-between border-b border-border px-4 py-3">
- <span className="text-sm font-medium text-foreground">{t('dashboard.versionAndUpdate')}</span>
+ <span className="text-sm font-medium text-foreground">
+ {t(isSourceBuild ? 'dashboard.buildAndVersion' : 'dashboard.versionAndUpdate')}
+ </span>
<div className="flex items-center gap-1">
<Button
variant="ghost"
@@ -152,8 +164,8 @@ export const VersionBadge: React.FC<{ openUpward?: boolean }> = ({ openUpward =
className="h-7 w-7 text-muted hover:text-foreground"
onClick={checkVersion}
disabled={checking || restarting}
- aria-label={checking ? t('dashboard.checking') : t('dashboard.checkUpdate')}
- title={checking ? t('dashboard.checking') : t('dashboard.checkUpdate')}
+ aria-label={refreshLabel}
+ title={refreshLabel}
>
<RefreshCw size={14} className={checking ? 'animate-spin' : ''} />
</Button>
@@ -171,14 +183,26 @@ export const VersionBadge: React.FC<{ openUpward?: boolean }> = ({ openUpward =
{/* Content */}
<div className="space-y-3 p-4">
- {/* Current Version */}
+ {isSourceBuild && (
+ <div className="flex items-start justify-between gap-3 text-sm">
+ <span className="shrink-0 text-muted">{t('dashboard.sourceRevision')}</span>
+ <span className="max-w-[10rem] break-all text-right font-mono font-medium text-foreground">
+ {sourceRevision || t('dashboard.unknownRevision')}
+ {versionInfo?.build?.dirty ? ` (${t('dashboard.dirtySource')})` : ''}
+ </span>
+ </div>
+ )}
+
+ {/* Current package version */}
<div className="flex items-center justify-between text-sm">
- <span className="text-muted">{t('dashboard.currentVersion')}</span>
- <span className="font-mono font-medium text-foreground">{currentVersion}</span>
+ <span className="text-muted">
+ {t(isSourceBuild ? 'dashboard.packageVersion' : 'dashboard.currentVersion')}
+ </span>
+ <span className="max-w-[10rem] break-all text-right font-mono font-medium text-foreground">{currentVersion}</span>
</div>
{/* Latest Version */}
- {versionInfo?.latest && (
+ {!isSourceBuild && versionInfo?.latest && (
<div className="flex items-center justify-between text-sm">
<span className="text-muted">{t('dashboard.latestVersion')}</span>
<span className="font-mono font-medium text-foreground">{versionInfo.latest}</span>
@@ -186,7 +210,7 @@ export const VersionBadge: React.FC<{ openUpward?: boolean }> = ({ openUpward =
)}
{/* Update Status */}
- {hasUpdate ? (
+ {!isSourceBuild && (hasUpdate ? (
<div className="flex items-center gap-2 rounded-md border border-gold/30 bg-gold/10 px-3 py-2 text-sm text-gold">
<AlertCircle size={16} className="shrink-0" />
<span>
@@ -206,7 +230,7 @@ export const VersionBadge: React.FC<{ openUpward?: boolean }> = ({ openUpward =
<AlertCircle size={16} className="shrink-0" />
<span>{t('dashboard.checkFailed')}</span>
</div>
- ) : null}
+ ) : null)}
{/* Upgrade Result */}
{upgradeResult && (
@@ -234,7 +258,7 @@ export const VersionBadge: React.FC<{ openUpward?: boolean }> = ({ openUpward =
)}
{/* Auto Update Toggle */}
- {autoUpdate !== null && (
+ {!isSourceBuild && autoUpdate !== null && (
<div className="flex items-center justify-between gap-3 border-t border-border pt-3">
<div className="min-w-0">
<div className="text-sm text-foreground">{t('dashboard.autoUpdate')}</div>
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index e96bf096e..ea0c0a768 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -1372,6 +1372,11 @@ export type VersionInfo = {
latest: string | null;
has_update: boolean;
error: string | null;
+ build?: {
+ kind: 'package' | 'source';
+ revision?: string;
+ dirty?: boolean;
+ };
};
export type UpgradeResult = {
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index f5a63911d..46d5be4ca 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -1743,7 +1743,13 @@
"uiRestartMessage": "Saved. Restarting UI server...",
"mainServiceRestarted": "Saved. Main service restarted.",
"versionAndUpdate": "Version & Update",
+ "buildAndVersion": "Build & Version",
"currentVersion": "Current Version",
+ "packageVersion": "Package Version",
+ "sourceRevision": "Source Revision",
+ "refreshBuildInfo": "Refresh Build Information",
+ "unknownRevision": "unknown",
+ "dirtySource": "dirty",
"latestVersion": "Latest Version",
"checkUpdate": "Check for Updates",
"checking": "Checking...",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 9b9f397b7..97f47f934 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -1743,7 +1743,13 @@
"uiRestartMessage": "已保存,正在重启 UI 服务器...",
"mainServiceRestarted": "已保存,主服务已重启",
"versionAndUpdate": "版本与更新",
+ "buildAndVersion": "构建与版本",
"currentVersion": "当前版本",
+ "packageVersion": "包版本",
+ "sourceRevision": "源码修订",
+ "refreshBuildInfo": "刷新构建信息",
+ "unknownRevision": "未知",
+ "dirtySource": "有未提交改动",
"latestVersion": "最新版本",
"checkUpdate": "检查更新",
"checking": "检查中...",
diff --git a/vibe/api.py b/vibe/api.py
index b4ff01246..492c9af85 100644
--- a/vibe/api.py
+++ b/vibe/api.py
@@ -46,6 +46,7 @@ from vibe.opencode_config import (
load_first_opencode_user_config,
set_jsonc_top_level_string_property,
)
+from vibe.build_identity import get_build_identity
from vibe.upgrade import (
build_upgrade_plan,
get_latest_version_info,
@@ -5002,19 +5003,26 @@ def _runtime_process_was_running() -> bool:
def get_version_info() -> dict:
- """Get current version and check for updates.
+ """Get package version, deployed build identity, and available updates.
Returns:
{
"current": str,
"latest": str | None,
"has_update": bool,
- "error": str | None
+ "error": str | None,
+ "build": {"kind": "package" | "source", ...}
}
"""
from vibe import __version__
- return get_latest_version_info(__version__)
+ build = get_build_identity()
+ if build.kind == "source":
+ result = {"current": __version__, "latest": None, "has_update": False, "error": None}
+ else:
+ result = get_latest_version_info(__version__)
+ result["build"] = build.as_dict()
+ return result
def do_upgrade(auto_restart: bool = True) -> dict:
diff --git a/vibe/build_identity.py b/vibe/build_identity.py
new file mode 100644
index 000000000..55a0d0b37
--- /dev/null
+++ b/vibe/build_identity.py
@@ -0,0 +1,56 @@
+"""Describe the code identity served by this Avibe process."""
+
+from __future__ import annotations
+
+import json
+import os
+import re
+from dataclasses import dataclass
+from pathlib import Path
+
+
+BUILD_METADATA_PATH_ENV = "VIBE_BUILD_METADATA_PATH"
+_GIT_REVISION_RE = re.compile(r"^[0-9a-fA-F]{7,64}$")
+
+
+@dataclass(frozen=True)
+class BuildIdentity:
+ kind: str
+ revision: str | None = None
+ dirty: bool | None = None
+
+ def as_dict(self) -> dict[str, object]:
+ payload: dict[str, object] = {"kind": self.kind}
+ if self.revision is not None:
+ payload["revision"] = self.revision
+ if self.dirty is not None:
+ payload["dirty"] = self.dirty
+ return payload
+
+
+def get_build_identity() -> BuildIdentity:
+ """Return package identity or source identity from deployment metadata.
+
+ A configured metadata path is itself the source-deployment marker. Invalid
+ or temporarily unavailable metadata must not make a source checkout fall
+ back to package update behavior.
+ """
+
+ metadata_path = os.environ.get(BUILD_METADATA_PATH_ENV, "").strip()
+ if not metadata_path:
+ return BuildIdentity(kind="package")
+
+ try:
+ payload = json.loads(Path(metadata_path).read_text(encoding="utf-8"))
+ except (OSError, json.JSONDecodeError):
+ return BuildIdentity(kind="source")
+ if not isinstance(payload, dict):
+ return BuildIdentity(kind="source")
+
+ raw_revision = payload.get("commit")
+ revision = str(raw_revision).strip() if raw_revision is not None else ""
+ if not _GIT_REVISION_RE.fullmatch(revision):
+ revision = ""
+ raw_dirty = payload.get("dirty")
+ dirty = raw_dirty if isinstance(raw_dirty, bool) else None
+ return BuildIdentity(kind="source", revision=revision or None, dirty=dirty)