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(watch): budget startup timeout from reconcile cadence

cyh832d0409c387
diff --git a/core/watches.py b/core/watches.py
index 1025ccdc2..b901b6c02 100644
--- a/core/watches.py
+++ b/core/watches.py
@@ -18,6 +18,7 @@ from core.scheduled_tasks import TaskExecutionStore
logger = logging.getLogger(__name__)
DEFAULT_RETRY_EXIT_CODE = 75
+WATCH_RECONCILE_INTERVAL_SECONDS = 2.0
def _utc_now_iso() -> str:
@@ -333,7 +334,7 @@ class ManagedWatchService:
raise
except Exception as exc:
logger.error("Managed watch reconcile failed: %s", exc, exc_info=True)
- await asyncio.sleep(2)
+ await asyncio.sleep(WATCH_RECONCILE_INTERVAL_SECONDS)
def reconcile_watches(self) -> None:
desired_ids = {watch.id for watch in self.store.list_watches() if watch.enabled}
diff --git a/tests/test_cli_watch_command.py b/tests/test_cli_watch_command.py
index 428b003dc..bca7b0b84 100644
--- a/tests/test_cli_watch_command.py
+++ b/tests/test_cli_watch_command.py
@@ -329,6 +329,14 @@ def test_wait_for_watch_startup_accepts_stably_running_watch(tmp_path: Path) ->
assert runtime_entry["running"] is True
+def test_default_watch_startup_timeout_exceeds_reconcile_and_stable_windows() -> None:
+ timeout_seconds = cli._default_watch_startup_timeout_seconds(
+ stable_running_seconds=cli.WATCH_STARTUP_STABLE_RUNNING_SECONDS
+ )
+
+ assert timeout_seconds > cli.WATCH_RECONCILE_INTERVAL_SECONDS + cli.WATCH_STARTUP_STABLE_RUNNING_SECONDS
+
+
def test_wait_for_watch_startup_rejects_watch_that_fails_before_stable_window(tmp_path: Path) -> None:
store = ManagedWatchStore(tmp_path / "watches.json")
runtime_store = WatchRuntimeStateStore(tmp_path / "watch_runtime.json")
diff --git a/vibe/cli.py b/vibe/cli.py
index 83ad105ce..658b79724 100644
--- a/vibe/cli.py
+++ b/vibe/cli.py
@@ -29,12 +29,20 @@ from config.v2_config import (
V2Config,
)
from core.scheduled_tasks import ScheduledTaskStore, TaskExecutionStore, parse_session_key
-from core.watches import DEFAULT_RETRY_EXIT_CODE, ManagedWatchStore, WatchRuntimeStateStore
+from core.watches import (
+ DEFAULT_RETRY_EXIT_CODE,
+ WATCH_RECONCILE_INTERVAL_SECONDS,
+ ManagedWatchStore,
+ WatchRuntimeStateStore,
+)
from vibe import __version__, api, runtime
from vibe.upgrade import build_upgrade_plan, cache_running_vibe_path, get_latest_version_info, get_safe_cwd
logger = logging.getLogger(__name__)
+WATCH_STARTUP_STABLE_RUNNING_SECONDS = 1.5
+WATCH_STARTUP_JITTER_BUFFER_SECONDS = 1.0
+
class VibeArgumentParser(argparse.ArgumentParser):
def __init__(self, *args, **kwargs):
@@ -826,16 +834,22 @@ def _seconds_since_iso(timestamp: object) -> float | None:
return max(0.0, (datetime.now(timezone.utc) - started_at).total_seconds())
+def _default_watch_startup_timeout_seconds(*, stable_running_seconds: float = WATCH_STARTUP_STABLE_RUNNING_SECONDS) -> float:
+ return WATCH_RECONCILE_INTERVAL_SECONDS + stable_running_seconds + WATCH_STARTUP_JITTER_BUFFER_SECONDS
+
+
def _wait_for_watch_startup(
store: ManagedWatchStore,
runtime_store: WatchRuntimeStateStore,
watch_id: str,
*,
- timeout_seconds: float = 4.0,
+ timeout_seconds: float | None = None,
poll_interval_seconds: float = 0.1,
- stable_running_seconds: float = 1.5,
+ stable_running_seconds: float = WATCH_STARTUP_STABLE_RUNNING_SECONDS,
):
inspect_command = f"vibe watch show {watch_id}"
+ if timeout_seconds is None:
+ timeout_seconds = _default_watch_startup_timeout_seconds(stable_running_seconds=stable_running_seconds)
deadline = time.monotonic() + timeout_seconds
while time.monotonic() < deadline:
store.maybe_reload()