The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): fetch the commit graph of shallow checkouts before publishing identity
ethernetf5caa6c26ff6
diff --git a/hermes_cli/gitlock.py b/hermes_cli/gitlock.pyindex 97acbde555a..4aa5ae91adb 100644--- a/hermes_cli/gitlock.py+++ b/hermes_cli/gitlock.py@@ -388,3 +388,22 @@ def prune_stale_shallow_grafts(repo_root: Path) -> int:except Exception:logger.debug("shallow graft prune failed for %s", repo_root, exc_info=True)return 0+++def fetch_full_commit_graph(repo_root: Path, **run_kwargs) -> bool:+ """Turn a shallow checkout into a treeless partial clone of ``origin``.++ Version identity is the nearest reachable release tag plus the commit count since+ it, and a shallow boundary hides both. Only commits (and the tags that follow+ them) are fetched; trees and blobs stay on demand, so this costs a fraction of a+ full unshallow. Returns False when the checkout was not shallow; raises+ ``subprocess.CalledProcessError`` / ``TimeoutExpired`` when the fetch fails.+ """+ if _shallow_file_path(repo_root) is None:+ return False+ subprocess.run(+ ["git", "fetch", "--quiet", "--unshallow", "--filter=tree:0", "origin"],+ cwd=str(repo_root), check=True, capture_output=True, text=True,+ encoding="utf-8", errors="replace", timeout=900, **run_kwargs,+ )+ return Truediff --git a/hermes_cli/update_cmd_maint.py b/hermes_cli/update_cmd_maint.pyindex f930b77e0a0..bd03f5655c7 100644--- a/hermes_cli/update_cmd_maint.py+++ b/hermes_cli/update_cmd_maint.py@@ -960,6 +960,18 @@ def _run_post_update_maintenance(with _best_effort('Post-update state.db integrity check failed: %s'):_verify_and_restore_state_dbs_post_update()+ # Pre-PM installers cloned --depth 1, which hides the release tag identity is+ # derived from. Fetch the commit graph before the completion line and the+ # install stamp read that identity.+ try:+ from hermes_cli.gitlock import fetch_full_commit_graph+ from hermes_cli.update_cmd import _no_prompt_git_kwargs+ if fetch_full_commit_graph(Path(_m().PROJECT_ROOT), **_no_prompt_git_kwargs()):+ print(" ✓ Fetched release history (commits only) for version identity")+ except (OSError, subprocess.SubprocessError) as exc:+ detail = (getattr(exc, "stderr", None) or str(exc)).strip().splitlines()[-1:] or [type(exc).__name__]+ print(f" ⚠ Could not fetch release history ({detail[0]}); the version shows as git.<sha> until the next update")+# Seed the model-catalog cache from the checkout instead of a bot-gated, flaky fetch.with _best_effort('Model catalog seed during update failed: %s'):from hermes_cli.model_catalog import seed_cache_from_checkoutdiff --git a/tests/hermes_cli/test_source_completion_stamp.py b/tests/hermes_cli/test_source_completion_stamp.pyindex 28aa05afe36..d17099c778b 100644--- a/tests/hermes_cli/test_source_completion_stamp.py+++ b/tests/hermes_cli/test_source_completion_stamp.py@@ -66,8 +66,8 @@ def test_publishing_checkout_identity_moves_an_installer_receipt_to_head(tmp_pat# write_source_stamp is the one seam: the completion handoff, the PM updater's finish and# boot-time adoption all publish identity through it, and the receipt must follow every one.root = _repo(tmp_path)- release = subprocess.run(["git", "rev-parse", "HEAD"], cwd=root, capture_output=True, text=True, check=True).stdout.strip()- branch = subprocess.run(["git", "branch", "--show-current"], cwd=root, capture_output=True, text=True, check=True).stdout.strip()+ release = subprocess.run(["git", "rev-parse", "HEAD"], cwd=root, capture_output=True, text=True, encoding="utf-8", check=True).stdout.strip()+ branch = subprocess.run(["git", "branch", "--show-current"], cwd=root, capture_output=True, text=True, encoding="utf-8", check=True).stdout.strip()# What install.sh / install.ps1's complete stage leaves behind at the installed release.(root / ".hermes-bootstrap-complete").write_text(json.dumps({"schemaVersion": 1, "pinnedCommit": release, "pinnedBranch": branch, "completedAt": "2026-06-19T00:00:00.000Z",@@ -86,3 +86,25 @@ def test_publishing_checkout_identity_never_invents_an_installer_receipt(tmp_patassert write_source_stamp(root) is not Noneassert not (root / ".hermes-bootstrap-complete").exists()+++def test_shallow_checkout_publishes_its_release_after_fetching_the_commit_graph(tmp_path):+ # Pre-PM installers cloned --depth 1; the completion fetches commits (not trees) so+ # the stamp can still name the release the checkout is built on.+ from hermes_cli.gitlock import fetch_full_commit_graph++ server = _repo(tmp_path)+ subprocess.run(["git", "config", "uploadpack.allowFilter", "true"], cwd=server, check=True)+ for message in ("one", "two", "three"):+ subprocess.run(["git", "commit", "-q", "--allow-empty", "-m", message], cwd=server, check=True,+ capture_output=True, env={**os.environ, "GIT_AUTHOR_NAME": "t", "GIT_AUTHOR_EMAIL": "[email protected]",+ "GIT_COMMITTER_NAME": "t", "GIT_COMMITTER_EMAIL": "[email protected]"})+ checkout = tmp_path / "checkout"+ subprocess.run(["git", "clone", "-q", "--depth", "1", server.as_uri(), str(checkout)], check=True, capture_output=True)++ assert fetch_full_commit_graph(checkout)+ stamp = write_source_stamp(checkout)++ assert stamp is not None+ assert (stamp["baseVersion"], stamp["distance"]) == ("0.21.4", 3)+ assert not fetch_full_commit_graph(checkout)diff --git a/tests/hermes_cli/test_update_version_report.py b/tests/hermes_cli/test_update_version_report.pyindex e26542ce6c4..d624cfaed21 100644--- a/tests/hermes_cli/test_update_version_report.py+++ b/tests/hermes_cli/test_update_version_report.py@@ -35,7 +35,7 @@ def fake_root(tmp_path, monkeypatch):def _git(root: Path, *args: str) -> str:env = {**os.environ, "GIT_AUTHOR_NAME": "t", "GIT_AUTHOR_EMAIL": "[email protected]","GIT_COMMITTER_NAME": "t", "GIT_COMMITTER_EMAIL": "[email protected]"}- return subprocess.run(["git", *args], cwd=root, env=env, check=True, capture_output=True, text=True).stdout.strip()+ return subprocess.run(["git", *args], cwd=root, env=env, check=True, capture_output=True, text=True, encoding="utf-8").stdout.strip()class TestReadProjectVersion: