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(vault): pin avault 0.1.7 for the eMudhra TLS trust refresh (#2918)

Call Whiteb7ccd69a5525
diff --git a/tests/test_avault_agent.py b/tests/test_avault_agent.py
index 59aa1e8f1..cd4f70216 100644
--- a/tests/test_avault_agent.py
+++ b/tests/test_avault_agent.py
@@ -302,3 +302,50 @@ class MockProcess:
def kill(self):
self.killed = True
+
+
+def _spawn_recording_manager(binary: Path, monkeypatch) -> AvaultAgentManager:
+ socket_path = Path(tempfile.mkdtemp(prefix="avault-ident-", dir="/tmp")) / "s"
+ manager = AvaultAgentManager(socket_path=socket_path, binary_resolver=lambda: str(binary))
+ monkeypatch.setattr(manager, "_socket_responds", lambda: False)
+
+ def _spawn() -> None:
+ manager.binary_identity_path.unlink(missing_ok=True)
+ manager._spawned_binary = manager._binary_resolver()
+ manager._process = MockProcess()
+
+ monkeypatch.setattr(manager, "_spawn_locked", _spawn)
+ monkeypatch.setattr(manager, "_wait_for_socket_locked", lambda: None)
+ return manager
+
+
+def test_agent_manager_records_the_binary_it_started(tmp_path, monkeypatch):
+ binary = tmp_path / "avault"
+ binary.write_text("v1")
+ manager = _spawn_recording_manager(binary, monkeypatch)
+
+ assert manager.serves_current_binary() is False
+ manager.ensure_running()
+
+ assert stat.S_IMODE(manager.binary_identity_path.stat().st_mode) == 0o600
+ assert manager.serves_current_binary() is True
+
+
+def test_agent_manager_distrusts_an_agent_after_the_binary_is_replaced(tmp_path, monkeypatch):
+ binary = tmp_path / "avault"
+ binary.write_text("v1")
+ manager = _spawn_recording_manager(binary, monkeypatch)
+ manager.ensure_running()
+
+ binary.write_text("v2-replaced")
+
+ assert manager.serves_current_binary() is False
+
+
+def test_agent_manager_distrusts_an_agent_it_did_not_record(tmp_path):
+ binary = tmp_path / "avault"
+ binary.write_text("v1")
+ socket_path = Path(tempfile.mkdtemp(prefix="avault-unrec-", dir="/tmp")) / "s"
+ manager = AvaultAgentManager(socket_path=socket_path, binary_resolver=lambda: str(binary))
+
+ assert manager.serves_current_binary() is False
diff --git a/tests/test_local_deps.py b/tests/test_local_deps.py
index 20868f909..d39542d31 100644
--- a/tests/test_local_deps.py
+++ b/tests/test_local_deps.py
@@ -2082,7 +2082,7 @@ def test_dependencies_status_shape(monkeypatch):
assert by["askill"]["status"] == "ready" and by["askill"]["version"] == "0.1.13" and by["askill"]["required"]
assert by["askill"]["latest_version"] is None and by["askill"]["has_update"] is False
assert by["avault"]["status"] == "ready" and by["avault"]["version"] == "0.0.1" and by["avault"]["required"]
- assert by["avault"]["latest_version"] is None and by["avault"]["has_update"] is False
+ assert by["avault"]["latest_version"] == api.AVAULT_VERSION and by["avault"]["has_update"] is True
assert by["show-runtime"]["installed"] and by["show-runtime"]["version"] == "1.4.0"
assert by["show-runtime"]["latest_version"] == "1.4.0"
assert by["show-runtime"]["has_update"] is False
@@ -2328,6 +2328,11 @@ def test_reconcile_startup_dependencies_uses_automatic_runtime_admission(monkeyp
return {"ok": True, "installed": True, "changed": False, "path": "/x/avault"}
monkeypatch.setattr(api, "ensure_avault_installed", fake_ensure_avault)
+ monkeypatch.setattr(
+ api,
+ "avault_status",
+ lambda: {"id": "avault", "installed": True, "version": api.AVAULT_VERSION, "status": "ready", "path": "/x/avault"},
+ )
monkeypatch.setattr(
api,
@@ -2403,3 +2408,60 @@ def test_reconcile_startup_dependencies_uses_automatic_runtime_admission(monkeyp
assert out["show_runtime"]["policy"]["state"] == "allowed"
assert out["show_runtime"]["install"]["state"] == "installed"
assert out["show_runtime"]["runtime"]["state"] == "unchecked"
+
+
+ ("installed_version", "expected_force"),
+ [("0.1.6", True), (None, True)],
+)
+def test_reconcile_startup_dependencies_moves_avault_below_the_pin_to_the_pin(
+ monkeypatch, installed_version, expected_force
+):
+ """Desktop never runs `vibe runtime prepare`; startup must still apply a new avault pin."""
+ monkeypatch.setenv("VIBE_RIPGREP_OFFLINE", "1")
+ _stub_tmux_install(monkeypatch)
+ monkeypatch.setattr(api, "ensure_askill_installed", lambda force=False: {"ok": True, "installed": True})
+ monkeypatch.setattr(
+ api, "ensure_model_hub_engine_installed", lambda force=False: {"ok": True, "installed": True}
+ )
+ status = (
+ {"id": "avault", "installed": True, "version": installed_version, "status": "ready", "path": "/x/avault"}
+ if installed_version
+ else {"id": "avault", "installed": False, "version": None, "status": "missing", "path": None}
+ )
+ monkeypatch.setattr(api, "avault_status", lambda: status)
+ avault_calls = []
+
+ def fake_ensure_avault(force=False):
+ avault_calls.append(force)
+ return {"ok": True, "installed": True, "changed": True, "path": "/x/avault", "version": api.AVAULT_VERSION}
+
+ monkeypatch.setattr(api, "ensure_avault_installed", fake_ensure_avault)
+
+ out = api.reconcile_startup_dependencies()
+
+ assert avault_calls == [expected_force]
+ assert out["avault"]["version"] == api.AVAULT_VERSION
+
+
+def test_reconcile_startup_dependencies_honors_the_avault_install_opt_out(monkeypatch):
+ monkeypatch.setenv("VIBE_RIPGREP_OFFLINE", "1")
+ monkeypatch.setenv("VIBE_INSTALL_SKIP_AVAULT", "1")
+ _stub_tmux_install(monkeypatch)
+ monkeypatch.setattr(api, "ensure_askill_installed", lambda force=False: {"ok": True, "installed": True})
+ monkeypatch.setattr(
+ api, "ensure_model_hub_engine_installed", lambda force=False: {"ok": True, "installed": True}
+ )
+ monkeypatch.setattr(
+ api,
+ "avault_status",
+ lambda: {"id": "avault", "installed": True, "version": "0.1.6", "status": "ready", "path": "/opt/avault"},
+ )
+ monkeypatch.setattr(api, "refresh_avault_if_stale", lambda: pytest.fail("opt-out must skip the pin refresh"))
+ monkeypatch.setattr(api, "ensure_avault_installed", lambda force=False: pytest.fail("opt-out must skip installs"))
+
+ out = api.reconcile_startup_dependencies()
+
+ assert out["avault"]["skipped"] is True
+ assert out["avault"]["reason"] == "VIBE_INSTALL_SKIP_AVAULT"
+ assert out["avault"]["version"] == "0.1.6"
diff --git a/tests/test_vault_api.py b/tests/test_vault_api.py
index 70a04648e..856cd1465 100644
--- a/tests/test_vault_api.py
+++ b/tests/test_vault_api.py
@@ -3348,11 +3348,14 @@ def test_agent_deliver_fetch_uses_finite_timeout(monkeypatch):
return {"status": 200, "headers": {}, "body": "ok"}
class FakeManager:
+ def serves_current_binary(self):
+ return True
+
def client(self, *, timeout=None):
seen_timeout.append(timeout)
return FakeClient()
- monkeypatch.setattr(api, "_require_avault_grant_delivery_surface", lambda _feature: None)
+ monkeypatch.setattr(api, "_require_avault_fetch_surface", lambda _feature, floor=None: None)
monkeypatch.setattr(api, "_avault_agent_manager", lambda: FakeManager())
result = api.avault_agent_deliver_fetch(
@@ -4823,3 +4826,92 @@ def test_create_grant_relays_every_protected_record_and_rejects_missing_dek(monk
"PROTECTED_LOGIN.username",
"PROTECTED_LOGIN.totp",
]
+
+
+_FETCH_REQUEST = {
+ "method": "GET",
+ "url": "https://example.com",
+ "allowed_hosts": ["example.com"],
+ "inject": {"type": "bearer"},
+}
+
+
[email protected]("installed_version", ["0.1.6", None])
+def test_one_shot_deliver_fetch_refuses_avault_without_refreshed_tls_trust(monkeypatch, installed_version):
+ status = {"installed": installed_version is not None, "version": installed_version}
+ monkeypatch.setattr(api, "avault_status", lambda: status)
+ monkeypatch.setattr(api, "_run_avault", lambda *a, **k: pytest.fail("credential handed to a pre-0.1.7 avault"))
+
+ with pytest.raises(api.AvaultPreHandoffError):
+ api.avault_deliver_fetch("GRANT_KEY", _sealed(), dict(_FETCH_REQUEST))
+
+
+def test_one_shot_deliver_fetch_runs_on_avault_with_refreshed_tls_trust(monkeypatch):
+ import subprocess
+
+ monkeypatch.setattr(api, "avault_status", lambda: {"installed": True, "version": api.AVAULT_FETCH_TLS_MIN_VERSION})
+ calls = []
+
+ def fake_run(args, **kwargs):
+ calls.append(args)
+ return subprocess.CompletedProcess(args, 0, stdout='{"status": 200, "headers": {}, "body": "ok"}', stderr="")
+
+ monkeypatch.setattr(api, "_run_avault", fake_run)
+
+ assert api.avault_deliver_fetch("GRANT_KEY", _sealed(), dict(_FETCH_REQUEST))["status"] == 200
+ assert calls == [["deliver", "fetch"]]
+
+
+def test_agent_deliver_fetch_refuses_avault_without_refreshed_tls_trust(monkeypatch):
+ # 0.1.6 clears the protected-record floor but not the fetch TLS floor.
+ monkeypatch.setattr(api, "avault_status", lambda: {"installed": True, "version": api.AVAULT_PROTECTED_RECORD_MIN_VERSION})
+ monkeypatch.setattr(api, "_avault_agent_manager", lambda: pytest.fail("credential handed to a pre-0.1.7 agent"))
+
+ with pytest.raises(api.AvaultPreHandoffError, match=api.AVAULT_FETCH_TLS_MIN_VERSION):
+ api.avault_agent_deliver_fetch(grant_id="vgr_grant", name="GRANT_KEY", sealed=_sealed(), request=dict(_FETCH_REQUEST))
+
+
+def test_agent_deliver_fetch_refuses_a_resident_agent_started_from_another_binary(monkeypatch):
+ # The on-disk binary already reports 0.1.7, but the live agent was not started from it.
+ monkeypatch.setattr(api, "avault_status", lambda: {"installed": True, "version": api.AVAULT_FETCH_TLS_MIN_VERSION})
+ fail_closed = []
+
+ class FakeManager:
+ def serves_current_binary(self):
+ return False
+
+ def client(self, *, timeout=None):
+ pytest.fail("credential handed to an unverified resident agent")
+
+ monkeypatch.setattr(api, "_avault_agent_manager", lambda: FakeManager())
+ monkeypatch.setattr(api, "_fail_closed_resident_agent_after_release_failure", lambda: fail_closed.append(True))
+
+ with pytest.raises(api.AvaultPreHandoffError, match="grant is missing or expired"):
+ api.avault_agent_deliver_fetch(grant_id="vgr_grant", name="GRANT_KEY", sealed=_sealed(), request=dict(_FETCH_REQUEST))
+
+ assert fail_closed == [True]
+
+
[email protected](("installed_version", "has_update"), [("0.1.6", True), (None, False)])
+def test_dependencies_status_reports_avault_below_the_pin(monkeypatch, installed_version, has_update):
+ status = (
+ {"id": "avault", "installed": True, "version": installed_version, "status": "ready", "path": "/x/avault"}
+ if installed_version
+ else {"id": "avault", "installed": False, "version": None, "status": "missing", "path": None}
+ )
+ monkeypatch.setattr(api, "avault_status", lambda: status)
+
+ dep = next(d for d in api.dependencies_status(dependency_ids=["avault"])["deps"] if d["id"] == "avault")
+
+ assert dep["latest_version"] == api.AVAULT_VERSION
+ assert dep["has_update"] is has_update
+
+
+def test_fetch_tls_floor_does_not_gate_non_fetch_delivery(monkeypatch):
+ # An offline or opted-out host left on 0.1.6 keeps protected grant/run/inject.
+ monkeypatch.setattr(api, "avault_status", lambda: {"installed": True, "version": api.AVAULT_PROTECTED_RECORD_MIN_VERSION})
+
+ assert api._avault_ready_min_version() == api.AVAULT_PROTECTED_RECORD_MIN_VERSION
+ api._require_avault_grant_delivery_surface("resident agent deliver run")
+ with pytest.raises(api.AvaultPreHandoffError, match=api.AVAULT_FETCH_TLS_MIN_VERSION):
+ api._require_avault_fetch_surface("resident agent deliver fetch", floor=api._avault_ready_min_version())
diff --git a/ui/src/components/settings/SettingsDependenciesPage.logic.ts b/ui/src/components/settings/SettingsDependenciesPage.logic.ts
index 1e822ba7b..5dd475750 100644
--- a/ui/src/components/settings/SettingsDependenciesPage.logic.ts
+++ b/ui/src/components/settings/SettingsDependenciesPage.logic.ts
@@ -23,20 +23,31 @@ export const dependencyHasInstallAction = (
export const dependencyIsStartupManaged = (dependency: Pick<DependencyItem, 'id'>): boolean =>
STARTUP_MANAGED_DEPENDENCIES.has(dependency.id);
+/**
+ * Upgrade required, or an installed avault below its managed pin. avault's
+ * readiness floor stays lower than the pin so run/inject keep working, but
+ * fetch needs the pinned release's TLS trust, and startup upgrades to it.
+ */
+export const dependencyNeedsUpgrade = (
+ dependency: Pick<DependencyItem, 'id' | 'status'> & Partial<Pick<DependencyItem, 'installed' | 'has_update'>>,
+): boolean =>
+ dependency.status === 'upgrade_required' ||
+ (dependency.id === 'avault' && dependency.status === 'ready' && dependency.installed === true && dependency.has_update === true);
+
/** Manual repair must wait for the startup pass, even before this step starts. */
export const dependencyNeedsStartupRepair = (
- dependency: Pick<DependencyItem, 'id' | 'status'>,
+ dependency: Pick<DependencyItem, 'id' | 'status'> & Partial<Pick<DependencyItem, 'installed' | 'has_update'>>,
): boolean =>
dependencyIsStartupManaged(dependency) &&
- (dependency.status === 'missing' || dependency.status === 'upgrade_required' || dependency.status === 'error');
+ (dependency.status === 'missing' || dependency.status === 'error' || dependencyNeedsUpgrade(dependency));
export const dependencyIsStartupRepairing = (
- dependency: Pick<DependencyItem, 'id' | 'installed' | 'status'>,
+ dependency: Pick<DependencyItem, 'id' | 'installed' | 'status'> & Partial<Pick<DependencyItem, 'has_update'>>,
activeIds?: ReadonlySet<string>,
): boolean =>
dependencyIsStartupManaged(dependency) &&
(activeIds === undefined || activeIds.has(dependency.id)) &&
- (!dependency.installed || dependency.status === 'upgrade_required' || dependency.status === 'error');
+ (!dependency.installed || dependency.status === 'error' || dependencyNeedsUpgrade(dependency));
export const dependenciesNeedAutomaticRefresh = (
result: DependenciesResult,
diff --git a/ui/src/components/settings/SettingsDependenciesPage.test.ts b/ui/src/components/settings/SettingsDependenciesPage.test.ts
index 59dd50c37..9bb106ade 100644
--- a/ui/src/components/settings/SettingsDependenciesPage.test.ts
+++ b/ui/src/components/settings/SettingsDependenciesPage.test.ts
@@ -4,6 +4,7 @@ import {
dependencyIsStartupManaged,
dependencyIsStartupRepairing,
dependencyNeedsStartupRepair,
+ dependencyNeedsUpgrade,
dependenciesNeedAutomaticRefresh,
} from './SettingsDependenciesPage.logic';
@@ -110,3 +111,19 @@ describe('startup dependency refresh', () => {
).toBe(false);
});
});
+
+describe('dependencyNeedsUpgrade', () => {
+ it('flags an installed avault below its managed pin without changing its readiness', () => {
+ const avault = { id: 'avault', status: 'ready' as const, installed: true, has_update: true };
+ expect(dependencyNeedsUpgrade(avault)).toBe(true);
+ expect(dependencyNeedsStartupRepair(avault)).toBe(true);
+ expect(dependencyIsStartupRepairing(avault, new Set(['avault']))).toBe(true);
+ expect(dependencyNeedsUpgrade({ ...avault, has_update: false })).toBe(false);
+ expect(dependencyNeedsUpgrade({ ...avault, installed: false, status: 'missing' as const })).toBe(false);
+ });
+
+ it('keeps pin staleness of other dependencies informational', () => {
+ expect(dependencyNeedsUpgrade({ id: 'askill', status: 'ready', installed: true, has_update: true })).toBe(false);
+ expect(dependencyNeedsUpgrade({ id: 'askill', status: 'upgrade_required', installed: true })).toBe(true);
+ });
+});
diff --git a/ui/src/components/settings/SettingsDependenciesPage.tsx b/ui/src/components/settings/SettingsDependenciesPage.tsx
index 634075e3d..d8f48bd73 100644
--- a/ui/src/components/settings/SettingsDependenciesPage.tsx
+++ b/ui/src/components/settings/SettingsDependenciesPage.tsx
@@ -28,6 +28,7 @@ import {
dependencyIsStartupRepairing,
dependencyHasInstallAction,
dependencyNeedsStartupRepair,
+ dependencyNeedsUpgrade,
} from './SettingsDependenciesPage.logic';
import { errorMessage } from '@/lib/errorMessage';
import { useDependencyChecks } from './useDependencyChecks';
@@ -103,7 +104,7 @@ export const SettingsDependenciesPage: React.FC = () => {
if (d.status === 'unknown') return t('settings.dependencies.statusUnknown');
if (d.status === 'not_required') return t('settings.dependencies.statusNotRequired');
if (!d.installed) return t('settings.dependencies.statusMissing');
- if (d.status === 'upgrade_required') {
+ if (dependencyNeedsUpgrade(d)) {
const word = t('settings.dependencies.statusUpgradeRequired');
return d.version ? `${word} · v${String(d.version).replace(/^v/i, '')}` : word;
}
@@ -116,13 +117,13 @@ export const SettingsDependenciesPage: React.FC = () => {
if (d.status === 'not_required') return 'secondary';
if (d.status === 'error') return 'destructive';
if (d.status === 'unknown') return 'warning';
- if (d.status === 'unsupported' || d.status === 'upgrade_required') return 'warning';
+ if (d.status === 'unsupported' || dependencyNeedsUpgrade(d)) return 'warning';
return d.installed ? 'success' : 'destructive';
};
const actionText = (d: DependencyItem, installing: boolean): string => {
if (installing) return t('settings.dependencies.installing');
- if (d.status === 'upgrade_required') return t('settings.dependencies.update');
+ if (dependencyNeedsUpgrade(d)) return t('settings.dependencies.update');
if (d.id === 'model-hub-engine' && d.status === 'error') {
return t('settings.dependencies.repair');
}
diff --git a/vibe/api.py b/vibe/api.py
index 65f509d74..25f7d9044 100644
--- a/vibe/api.py
+++ b/vibe/api.py
@@ -8681,18 +8681,24 @@ AVAULT_GRANT_DELIVERY_MIN_VERSION = "0.1.4"
# Older binaries cannot open browser-sealed protected values and fail with
# "open failed for <name>", so protected Vaults must not treat them as ready.
AVAULT_PROTECTED_RECORD_MIN_VERSION = "0.1.6"
-# Installer pin must reference a published release. v0.1.6 adds the
-# protected-record v2 AAD fix so agent delivery can open browser-sealed protected values.
-AVAULT_VERSION = "0.1.6"
+# ``deliver fetch`` hands a credential to avault's own HTTPS client. avault 0.1.7
+# refreshed that client's trust store (webpki-roots 1.0.10 / rustls-webpki
+# 0.103.16) to reject the compromised eMudhra/emSign intermediates, so older
+# binaries must not receive credentials for HTTPS egress.
+AVAULT_FETCH_TLS_MIN_VERSION = "0.1.7"
+# Installer pin must reference a published release. v0.1.7 refreshes the
+# outbound TLS trust (webpki-roots 1.0.10 / rustls-webpki 0.103.16) so delivery
+# fetches reject the compromised eMudhra/emSign intermediates.
+AVAULT_VERSION = "0.1.7"
# (sha256, size) of each AVAULT_VERSION archive by target, copied from that
# release's manifest.json so the download is verified whichever source served it.
_AVAULT_ARCHIVES = {
- "linux-arm64": ("3405d740ac91c5490a0c16839bb878a2c574ee21053a7a4362d7bbeb7ce3f110", 3251581),
- "linux-x64": ("42d5bd3bed5ccdd4748a99cfd64f2e32ab1649e4cd2dd13fcc060806c39109f2", 3574160),
- "macos-arm64": ("2bf9ace2e055c9988ca3b24aa483676e1123b7a588b5082f57cc18d7d856f7c9", 1458126),
- "macos-x64": ("558b4559b0bcdaeb713758183530d6944c2eacd68fcbfb35cd43ebd017fde163", 1597445),
- "windows-arm64": ("0b1a2a91ad0a24c392172164e4040fb3c50bec81fd3a14d58e6e13d04053d864", 1316664),
- "windows-x64": ("c0b9404d30980531f2a6df5e2b4f8bf6e5a34b31a916f7971b522a3a6cad71ad", 1394102),
+ "linux-arm64": ("22bbed967ba7403e323549eb8b161c2d918c1f5ed692f38d4e3b1049ad7d23dd", 3256706),
+ "linux-x64": ("ccc329b92a70c2d5b583b66725b0780a0f182975f2cbe6e7501232d9963ceb4c", 3580615),
+ "macos-arm64": ("d6e5fe7911c571d05734213af5c1b17332b3d7a71635f60c68887bd2dc977998", 1462107),
+ "macos-x64": ("56874a51ef37aab01be137898b3220c4a78bdbff0fc5362a862a42dd18a0abcc", 1583787),
+ "windows-arm64": ("6f7f7cbc69decb280a78e4936cfef7c15e95820168df981a3020393937f4c7aa", 1325310),
+ "windows-x64": ("c49cf29062fa5f22eab76e7785c040006a6fcf9fabf84667c120f8e99f5ccf0a", 1406456),
}
@@ -8758,6 +8764,8 @@ def _avault_ready_min_version() -> str:
# Managed avault readiness must satisfy both the resident grant-id delivery
# protocol and the protected-record v2 AAD open fix; take the higher floor so
# stale binaries (e.g. 0.1.5) are upgraded/blocked before protected delivery.
+ # The fetch TLS floor is deliberately not part of it: only the fetch guards
+ # enforce it, so run/inject/grant keep working on an older binary.
if _version_at_least(AVAULT_PROTECTED_RECORD_MIN_VERSION, AVAULT_GRANT_DELIVERY_MIN_VERSION):
return AVAULT_PROTECTED_RECORD_MIN_VERSION
return AVAULT_GRANT_DELIVERY_MIN_VERSION
@@ -9363,6 +9371,19 @@ def _require_avault_grant_protocol_surface(feature: str) -> None:
)
+def _require_avault_fetch_surface(feature: str, *, floor: str | None = None) -> None:
+ # Fetch egress needs the refreshed TLS trust on top of whatever floor the
+ # path already requires (the resident path also opens a protected record).
+ minimum = AVAULT_FETCH_TLS_MIN_VERSION
+ if floor and not _version_at_least(minimum, floor):
+ minimum = floor
+ _require_avault_min_version(
+ feature,
+ minimum,
+ managed_available=_version_at_least(AVAULT_VERSION, minimum),
+ )
+
+
# ---------------------------------------------------------------------------
# avault client — Avibe's only path to value cryptography.
#
@@ -9784,9 +9805,20 @@ def avault_agent_deliver_fetch(
"""Broker an HTTP request under a protected grant."""
from vibe.avault_agent import AvaultAgentError
- _require_avault_grant_delivery_surface("resident agent deliver fetch")
+ _require_avault_fetch_surface("resident agent deliver fetch", floor=_avault_ready_min_version())
+ manager = _avault_agent_manager()
+ if not manager.serves_current_binary():
+ # The version check above probed the executable on disk; a resident agent
+ # started from an older binary must not receive the credential. Drop it and
+ # its DEK cache (expiring the grants it held) so the request is approved
+ # again against an agent running the current binary.
+ _fail_closed_resident_agent_after_release_failure()
+ raise AvaultPreHandoffError(
+ "resident avault agent predates the installed avault binary; "
+ "the grant is missing or expired and must be approved again"
+ )
try:
- return _avault_agent_manager().client(timeout=_AVAULT_FETCH_TIMEOUT_SECONDS).deliver_fetch(
+ return manager.client(timeout=_AVAULT_FETCH_TIMEOUT_SECONDS).deliver_fetch(
grant_id=grant_id,
name=name,
envelope=_envelope_payload(sealed),
@@ -9831,6 +9863,7 @@ def avault_deliver_fetch(name: str, sealed, request: dict) -> dict:
``request`` must include ``allowed_hosts`` (avault rejects the target otherwise).
Returns ``{"status", "headers", "body"}`` — the response only, never the secret.
"""
+ _require_avault_fetch_surface("deliver fetch")
body = json.dumps(
{"name": name, "envelope": _envelope_payload(sealed), "request": request}
).encode("utf-8")
@@ -10290,8 +10323,8 @@ def dependencies_status(*, offline: bool = False, dependency_ids: list[str] | No
"required": True,
"installed": av["installed"],
"version": av.get("version"),
- "latest_version": None,
- "has_update": False,
+ "latest_version": AVAULT_VERSION,
+ "has_update": bool(av["installed"] and not _version_at_least(av.get("version"), AVAULT_VERSION)),
"status": av["status"],
}
if requested.intersection({"show-runtime", "node"}):
@@ -10491,7 +10524,13 @@ def reconcile_startup_dependencies() -> dict:
_set_startup_dependency_reconciling("avault", True)
try:
- avault = ensure_avault_installed(force=False)
+ # Pin-aware: Desktop never runs `vibe runtime prepare`, so startup is
+ # where an existing install below AVAULT_VERSION moves to the pin. The
+ # operator opt-out that `vibe runtime prepare` honors applies here too.
+ if os.environ.get("VIBE_INSTALL_SKIP_AVAULT", "").strip().lower() in _TRUTHY_ENV_VALUES:
+ avault = {**avault_status(), "ok": True, "skipped": True, "reason": "VIBE_INSTALL_SKIP_AVAULT"}
+ else:
+ avault = refresh_avault_if_stale()
except Exception as exc: # noqa: BLE001
logger.warning("Startup dependency reconcile failed to ensure avault: %s", exc, exc_info=True)
avault = {"ok": False, "message": str(exc)}
diff --git a/vibe/avault_agent.py b/vibe/avault_agent.py
index 7bf5f33f0..0a5c1a45e 100644
--- a/vibe/avault_agent.py
+++ b/vibe/avault_agent.py
@@ -9,6 +9,7 @@ from __future__ import annotations
import json
import logging
+import os
import signal
import socket
import subprocess
@@ -204,6 +205,7 @@ class AvaultAgentManager:
self.start_timeout = start_timeout
self._lock = threading.RLock()
self._process: subprocess.Popen | None = None
+ self._spawned_binary: str | None = None
def client(self, *, timeout: float | None = DEFAULT_AGENT_SOCKET_TIMEOUT) -> AvaultAgentClient:
return AvaultAgentClient(self.socket_path, timeout=timeout, ensure_agent=self.ensure_running)
@@ -222,15 +224,49 @@ class AvaultAgentManager:
self._process = None
self._spawn_locked()
self._wait_for_socket_locked()
+ self._record_binary_identity_locked()
def reset(self) -> None:
with self._lock:
self._terminate_process_locked()
+ @property
+ def binary_identity_path(self) -> Path:
+ return self.socket_path.with_name(f"{self.socket_path.name}.binary.json")
+
+ def serves_current_binary(self) -> bool:
+ """Whether the resident agent was started here from the binary resolved now.
+
+ A resident agent outlives the service and keeps running the executable it
+ was started from, so a binary replaced on disk (or an agent this code did
+ not start) says nothing about the code behind the socket.
+ """
+ try:
+ recorded = json.loads(self.binary_identity_path.read_text(encoding="utf-8"))
+ current = _binary_identity(self._binary_resolver())
+ except (OSError, ValueError, AvaultAgentError):
+ return False
+ return isinstance(recorded, dict) and current is not None and recorded == current
+
+ def _record_binary_identity_locked(self) -> None:
+ identity = _binary_identity(self._spawned_binary) if self._spawned_binary else None
+ if identity is None:
+ return
+ tmp = self.binary_identity_path.with_name(f"{self.binary_identity_path.name}.tmp")
+ try:
+ fd = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
+ with os.fdopen(fd, "w", encoding="utf-8") as handle:
+ json.dump(identity, handle)
+ os.replace(tmp, self.binary_identity_path)
+ except OSError:
+ logger.warning("failed to record the resident avault agent binary", exc_info=True)
+
def _spawn_locked(self) -> None:
binary = self._binary_resolver()
_ensure_agent_socket_parent(self.socket_path.parent)
_remove_stale_agent_socket(self.socket_path)
+ self.binary_identity_path.unlink(missing_ok=True)
+ self._spawned_binary = binary
try:
self._process = subprocess.Popen(
[
@@ -316,6 +352,15 @@ def _remove_stale_agent_socket(path: Path) -> None:
return
+def _binary_identity(binary: str) -> dict[str, Any] | None:
+ try:
+ resolved = Path(binary).resolve()
+ st = resolved.stat()
+ except OSError:
+ return None
+ return {"binary": str(resolved), "size": st.st_size, "mtime_ns": st.st_mtime_ns}
+
+
def _missing_binary_resolver() -> str:
raise AvaultAgentError(backend_t("dependencies.avault.missing"))