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(model-hub): keep the engine's log in a bounded, owner-private file (#2482)

Call Whitefbf0699d0c7c
diff --git a/tests/test_model_hub_runtime.py b/tests/test_model_hub_runtime.py
index b35203b2b..ee4be9c27 100644
--- a/tests/test_model_hub_runtime.py
+++ b/tests/test_model_hub_runtime.py
@@ -1703,6 +1703,10 @@ def test_config_generation_is_private_and_never_logs_secrets(
]
assert stat.S_IMODE(config_path.stat().st_mode) == 0o600
assert stat.S_IMODE(store.auth_dir.stat().st_mode) == 0o700
+ # The engine's own log stays beside its config, owner-private and bounded, and carries no bodies.
+ assert payload["logging-to-file"] is True and payload["logs-max-total-size-mb"] > 0
+ assert payload["commercial-mode"] is True and payload["request-log"] is False
+ assert stat.S_IMODE((instance_dir / "logs").stat().st_mode) == 0o700
credential_path = next((store.root / "credentials").iterdir())
assert stat.S_IMODE(credential_path.stat().st_mode) == 0o600
for secret in (
diff --git a/tests/test_model_hub_state_private.py b/tests/test_model_hub_state_private.py
index c6f7f49e6..6e7049938 100644
--- a/tests/test_model_hub_state_private.py
+++ b/tests/test_model_hub_state_private.py
@@ -46,7 +46,7 @@ def test_windows_engine_start_and_api_key_source_keep_secrets_private(root):
# any access rule; they must pass the audit every engine start runs.
(store.auth_dir / "codex-synthetic.json").write_text("{}", encoding="utf-8")
store.audit_auth_permissions()
- for path in (store.root, instance_dir, instance_dir / "runtime-secrets.json", store.auth_dir):
+ for path in (store.root, instance_dir, instance_dir / "runtime-secrets.json", instance_dir / "logs", store.auth_dir):
assert _private(path), path
diff --git a/vibe/model_hub_runtime/config.py b/vibe/model_hub_runtime/config.py
index d0ac51fb5..1ad52cff6 100644
--- a/vibe/model_hub_runtime/config.py
+++ b/vibe/model_hub_runtime/config.py
@@ -16,6 +16,9 @@ from vibe.model_hub_runtime.api_key_vendors import (
)
from vibe.model_hub_runtime.state import EngineStateError, EngineStateStore, RuntimeSecrets, SourceRecord
+# The engine rotates main.log at 10 MB and deletes the oldest rotated files beyond this total.
+ENGINE_LOGS_MAX_TOTAL_MB = 20
+
def write_engine_config(
path: Path,
@@ -76,8 +79,12 @@ def render_engine_config(
"debug": False,
"pprof": {"enable": False, "addr": "127.0.0.1:0"},
"plugins": {"enabled": False, "dir": str(path.parent / "plugins"), "configs": {}},
+ # Commercial mode also skips the engine's request logging, so nothing it writes carries a body.
"commercial-mode": True,
- "logging-to-file": False,
+ # The engine's own log goes to a rotating logs/main.log in its instance directory instead of
+ # nowhere, bounded in total, so an engine-side stream failure can be diagnosed afterwards.
+ "logging-to-file": True,
+ "logs-max-total-size-mb": ENGINE_LOGS_MAX_TOTAL_MB,
"request-log": False,
"usage-statistics-enabled": False,
"redis-usage-queue-retention-seconds": 60,
diff --git a/vibe/model_hub_runtime/state.py b/vibe/model_hub_runtime/state.py
index af7c29cce..54d5e3066 100644
--- a/vibe/model_hub_runtime/state.py
+++ b/vibe/model_hub_runtime/state.py
@@ -32,6 +32,10 @@ _CREDENTIAL_REF_RE = re.compile(r"^cred_[A-Za-z0-9_-]{6,128}$")
_BEARER_CREDENTIAL_REF_RE = re.compile(r"^cred_auth_bearer_[0-9a-f]{32}$")
_SOURCE_ID_RE = re.compile(r"^src_[a-z0-9]{8,}$")
_PROTOCOLS = {"anthropic", "openai_responses", "openai_chat", "google"}
+# The engine writes its file log to ``logs`` under its working directory, the instance directory, only
+# when that directory already exists; otherwise it falls back to ``<auth-dir>/logs``, among the
+# credentials (CLIProxyAPI internal/logging/global_logger.go ResolveLogDirectory).
+ENGINE_LOG_DIR = "logs"
class EngineStateError(RuntimeError):
@@ -206,6 +210,7 @@ class EngineStateStore:
self.audit_auth_permissions()
instance_dir = self.root / "instances" / _safe_identifier(install_id)
self._ensure_private_dir(instance_dir)
+ self._ensure_private_dir(instance_dir / ENGINE_LOG_DIR)
self._remove_obsolete_instances(instance_dir)
secrets_path = instance_dir / "runtime-secrets.json"
if not rotate: