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(harness): simplify restart interruption notices

cyh410975b3d39c
diff --git a/core/scheduled_tasks.py b/core/scheduled_tasks.py
index aa701f48f..ad1cfca78 100644
--- a/core/scheduled_tasks.py
+++ b/core/scheduled_tasks.py
@@ -6692,9 +6692,11 @@ class ScheduledTaskService:
else None
)
is_watch = watch is not None or str(run.get("run_type") or "").strip().startswith("watch")
+ explicit_name = (task.name if task else None) or (
+ str((watch or {}).get("name") or "").strip() or None
+ )
name = (
- (task.name if task else None)
- or (str((watch or {}).get("name") or "").strip() or None)
+ explicit_name
or definition_id
or str(run["id"])
)
@@ -6709,6 +6711,14 @@ class ScheduledTaskService:
)
reason = str(notice.get("interrupt_reason") or "").strip()
error = str(run.get("error") or "").strip() or self._t("harness.notice.unknownError")
+ if reason == SETTLED_BY_RESTARTED:
+ # A service restart is a lifecycle event, not a diagnosis. Keep its
+ # notification to one calm action and leave internal Run/definition
+ # details on the inspection surfaces. A deleted definition has no
+ # trustworthy display name, so never substitute its opaque id.
+ if explicit_name:
+ return self._t("harness.notice.restartStopped", name=explicit_name)
+ return self._t("harness.notice.restartStoppedUnnamed")
if failure_notices.is_interruption(notice):
# The reason is rendered INSIDE a translated sentence, so it is copy: the
# wire value went through a closed label map, never interpolated raw. An
diff --git a/docs/plans/harness-watch-run-failure-boundary.md b/docs/plans/harness-watch-run-failure-boundary.md
index 54d284182..0c0ff3808 100644
--- a/docs/plans/harness-watch-run-failure-boundary.md
+++ b/docs/plans/harness-watch-run-failure-boundary.md
@@ -198,6 +198,10 @@ does not claim that an event was detected.
timestamp. If one legacy notice was already sent, that delivery evidence owns
the Turn and all pending siblings stand down; otherwise one stable participant
becomes the only fallback.
+- `HFR-475`: a service-restart notice is one calm recovery action rather than a
+ diagnostic dump. It names a readable definition when one still exists, never
+ substitutes an opaque deleted-definition id, and leaves error, origin,
+ lifecycle, Run, and Watch details on their inspection surfaces.
Residual manual check: trigger two one-shot Watches into one failing Turn and
confirm that the conversation contains one backend error, both Runs are failed,
diff --git a/tests/scenarios/harness_failure_recovery/catalog.yaml b/tests/scenarios/harness_failure_recovery/catalog.yaml
index 1cd8f1214..2c0763459 100644
--- a/tests/scenarios/harness_failure_recovery/catalog.yaml
+++ b/tests/scenarios/harness_failure_recovery/catalog.yaml
@@ -4265,6 +4265,16 @@ scenarios:
# per-Run restart notices into one Turn fallback. A notice already sent remains
# authoritative and suppresses every pending sibling.
test: tests/test_session_delivery_fsm.py::test_hfr_474_startup_collapses_legacy_restart_notices_by_durable_turn
+ - id: HFR-475
+ name: restart notices stay concise and hide opaque internal identities
+ status: covered
+ kind: failure_recovery
+ layer: contract
+ backend: shared
+ # A service restart renders one calm recovery action. Readable definition names
+ # remain visible, while deleted definitions never leak their opaque id or append
+ # internal error, origin, lifecycle, and inspection lines.
+ test: tests/test_harness_failure_visibility.py::test_hfr_475_restart_notice_is_one_calm_action_without_internal_details
manual_evidence:
- local Incus backend process death after prompt acceptance
- local Incus controller restart with persisted queued successor
diff --git a/tests/test_harness_failure_visibility.py b/tests/test_harness_failure_visibility.py
index ddf3f40aa..d78c95a9d 100644
--- a/tests/test_harness_failure_visibility.py
+++ b/tests/test_harness_failure_visibility.py
@@ -11510,7 +11510,10 @@ def test_an_interruption_notice_never_prints_the_raw_wire_reason(tmp_path: Path)
``tests/test_i18n_backend_keys.py`` so a new reason cannot ship unlabelled.
"""
- from core.run_settlement import RUN_INTERRUPTION_REASONS as REASONS
+ from core.run_settlement import (
+ RUN_INTERRUPTION_REASONS as REASONS,
+ SETTLED_BY_RESTARTED,
+ )
sqlite, requests = _store(tmp_path)
_task(sqlite, "task-zh-reason", name="daily report")
@@ -11524,7 +11527,8 @@ def test_an_interruption_notice_never_prints_the_raw_wire_reason(tmp_path: Path)
assert reason not in body, (
f"the raw wire reason {reason!r} leaked into user-visible copy: {body}"
)
- assert "被中断" in body, f"the interrupted headline must still render: {body}"
+ expected_copy = "重启停止" if reason == SETTLED_BY_RESTARTED else "被中断"
+ assert expected_copy in body, f"the interruption must still render: {body}"
def test_an_unmapped_interruption_reason_renders_a_localized_fallback(
@@ -11567,6 +11571,58 @@ def test_an_unmapped_interruption_reason_renders_a_localized_fallback(
)
[email protected]("language", ["en", "zh"])
+def test_hfr_475_restart_notice_is_one_calm_action_without_internal_details(
+ tmp_path: Path,
+ language: str,
+) -> None:
+ """A restart notice names readable work but never exposes an orphaned id."""
+
+ from types import SimpleNamespace
+
+ from core.run_settlement import SETTLED_BY_RESTARTED
+ from core.scheduled_tasks import ScheduledTaskService
+ from vibe.i18n import t as i18n_t
+
+ sqlite, requests = _store(tmp_path)
+ _watch(sqlite, "watch-release", name="Watch release", mode="once")
+ service = _drain_service(tmp_path, SimpleNamespace(), sqlite, requests)
+ service.controller.config = SimpleNamespace(language=language, platform="avibe")
+ service._t = ScheduledTaskService._t.__get__(service, ScheduledTaskService)
+
+ def _body(definition_id: str, run_id: str) -> str:
+ _settled_run(
+ sqlite,
+ definition_id,
+ run_id,
+ status="failed",
+ at="2026-08-11T04:47:17+00:00",
+ metadata={"interrupt_reason": SETTLED_BY_RESTARTED},
+ )
+ return service._failure_notice_body(
+ sqlite.get_run(run_id),
+ {
+ "failure_id": run_id,
+ "interrupt_reason": SETTLED_BY_RESTARTED,
+ },
+ )
+
+ named = _body("watch-release", "run-restart-named")
+ assert named == i18n_t(
+ "harness.notice.restartStopped",
+ language,
+ name="Watch release",
+ )
+ assert "\n" not in named
+
+ opaque_definition_id = "b366664bf5db"
+ unnamed = _body(opaque_definition_id, "run-restart-unnamed")
+ assert unnamed == i18n_t("harness.notice.restartStoppedUnnamed", language)
+ assert opaque_definition_id not in unnamed
+ assert "run-restart-unnamed" not in unnamed
+ assert "\n" not in unnamed
+
+
def _settled_run(
sqlite,
definition_id: str,
diff --git a/vibe/i18n/en.json b/vibe/i18n/en.json
index b165dd42f..7356e2776 100644
--- a/vibe/i18n/en.json
+++ b/vibe/i18n/en.json
@@ -102,6 +102,8 @@
"watchCircuitRepairFailed": "[Avibe Harness] Watch \"{name}\" remains paused because its circuit-repair Agent Run failed.",
"watchFollowUpFailed": "[Avibe Harness] Watch \"{name}\" follow-up Agent processing failed.",
"interrupted": "[Avibe Harness] Scheduled work \"{name}\" was interrupted ({reason}). Nothing is wrong with the definition itself.",
+ "restartStopped": "[Avibe Harness] Background task \"{name}\" stopped when Avibe restarted. To continue, send \"continue\" to the Agent.",
+ "restartStoppedUnnamed": "[Avibe Harness] A background task stopped when Avibe restarted. To continue, send \"continue\" to the Agent.",
"commandLine": "Command: {command}",
"error": "Error: {error}",
"commandExit": "Exit code: {exitCode}",
diff --git a/vibe/i18n/zh.json b/vibe/i18n/zh.json
index aaa65875b..92b6f2529 100644
--- a/vibe/i18n/zh.json
+++ b/vibe/i18n/zh.json
@@ -102,6 +102,8 @@
"watchCircuitRepairFailed": "[Avibe Harness] Watch「{name}」的熔断修复 Agent Run 失败,Watch 将保持暂停。",
"watchFollowUpFailed": "[Avibe Harness] Watch「{name}」的后续 Agent 处理失败。",
"interrupted": "[Avibe Harness] 后台任务「{name}」被中断({reason}),任务本身没有问题。",
+ "restartStopped": "[Avibe Harness] 后台任务「{name}」已随 Avibe 重启停止。如需继续,请发送“继续”给 Agent。",
+ "restartStoppedUnnamed": "[Avibe Harness] 一项后台任务已随 Avibe 重启停止。如需继续,请发送“继续”给 Agent。",
"commandLine": "命令:{command}",
"error": "错误:{error}",
"commandExit": "退出码:{exitCode}",