The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): prevent recursive source completion
Gillede48024d75ee
diff --git a/hermes_cli/venv_sync.py b/hermes_cli/venv_sync.pyindex c17e6d46b91..199d861223d 100644--- a/hermes_cli/venv_sync.py+++ b/hermes_cli/venv_sync.py@@ -223,10 +223,18 @@ def prepare_launch(project_root: Path, argv: list[str]) -> Path | None:"""import osimport sys++ root = Path(project_root).resolve()+ # Post-build maintenance imports hermes_cli.main while this worker still owns the+ # completion marker. Re-entering the launch repair here starts another tail before+ # this one can clear it, recursively rebuilding the products on every pass.+ if (Path(sys.argv[0]).name == "source_completion.py"+ and Path(sys.argv[0]).resolve() == root / "hermes_cli" / "source_completion.py"):+ return None+from hermes_cli._parser import command_argvfrom hermes_cli.steward import read_install_stamp- root = Path(project_root).resolve()if (command_argv(argv)[:1] == ["pm"]or _METADATA_FLAGS & set(argv)or os.environ.get("HERMES_DISABLE_LAZY_INSTALLS", "").lower() in ("1", "true", "yes")diff --git a/tests/hermes_cli/test_update_launch_completion.py b/tests/hermes_cli/test_update_launch_completion.pyindex 6f89f497e18..e61b40e51da 100644--- a/tests/hermes_cli/test_update_launch_completion.py+++ b/tests/hermes_cli/test_update_launch_completion.py@@ -102,6 +102,25 @@ def test_failed_completion_tail_is_retried_without_rebuilding_dependencies(tmp_passert len(completion_tail) == 3, "a finished tail was run again"+def test_prepared_completion_import_does_not_start_another_tail(tmp_path, monkeypatch, completion_tail):+ """Maintenance imports the CLI while its own completion marker is still present."""+ import pm+ from hermes_cli import _launchers++ root = _self_checkout(tmp_path, monkeypatch)+ worker = root / "hermes_cli" / "source_completion.py"+ worker.parent.mkdir()+ worker.touch()+ venv_sync.arm_completion(root)+ monkeypatch.setattr(pm, "venv_is_current", lambda **kw: True)+ monkeypatch.setattr(_launchers, "resolve_store_python", lambda _: Path(sys.executable))+ monkeypatch.setattr(sys, "argv", [str(worker), "--source", str(root), "--finish-update", "--prepared"])++ assert venv_sync.prepare_launch(root, sys.argv[1:]) is None+ assert not completion_tail+ assert venv_sync.completion_pending_path(root).is_file()++def test_completion_tail_output_stays_off_stdout(tmp_path, monkeypatch, completion_tail):"""The automatic tail runs in front of the user's command, which may be piping JSON."""import pm