The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(update): tighten the partial-clone heal after review
kshitijk4poor596678d66516
diff --git a/hermes_cli/gitlock.py b/hermes_cli/gitlock.pyindex a69a53b9ea7..ddcaba5f36d 100644--- a/hermes_cli/gitlock.py+++ b/hermes_cli/gitlock.py@@ -500,7 +500,8 @@ def fetch_with_partial_clone_recovery(runner: Callable[..., subprocess.Completed"""Run a fetch; on the pack-objects BUG, mark the unmarked packs and retry it once.``runner(git_cmd, args) -> CompletedProcess`` and ``git_cmd + fetch_args`` is the plain- fetch argv. The retry's result is returned whatever its exit code, so the caller keeps its+ fetch argv. On the crash, ``repo_root``'s unmarked packs get a ``.promisor`` file and the+ identical fetch runs once more. The retry's result is returned whatever its exit code, so the caller keeps itsnormal failure handling. (A ``-c remote.origin.promisor=`` override does not help: gitregisters promisor remotes additively, so the repo's own ``true`` still wins.)"""diff --git a/hermes_cli/worktree_ops.py b/hermes_cli/worktree_ops.pyindex 7c9fb9f53e2..b77160940bd 100644--- a/hermes_cli/worktree_ops.py+++ b/hermes_cli/worktree_ops.py@@ -555,10 +555,9 @@ def _deepen_shallow_repo(repo_root: str, timeout: int = 600) -> bool:finally:# The filtered attempt makes the clone partial (git writes the config before fetching,# so even when it fails); its old packs need the marker or git 2.53+ crashes every- # later fetch (#124272).- if _git_out(["config", "--bool", "--get", f"remote.{remote}.promisor"], repo_root) == "true":- from hermes_cli.gitlock import mark_unmarked_packs_promisor- mark_unmarked_packs_promisor(Path(repo_root))+ # later fetch (#124272). Markers are inert in a clone without a promisor remote.+ from hermes_cli.gitlock import mark_unmarked_packs_promisor+ mark_unmarked_packs_promisor(Path(repo_root))except Exception as e:logger.debug("Deepening shallow repo failed (non-fatal): %s", e)return Falsediff --git a/scripts/install.ps1 b/scripts/install.ps1index 9e59a4cbb2d..dce40f5f2a1 100644--- a/scripts/install.ps1+++ b/scripts/install.ps1@@ -774,7 +774,10 @@ function Stage-Repository {if ("$promisor".Trim() -eq 'true' -and (Test-Path -LiteralPath $packDir)) {Get-ChildItem -LiteralPath $packDir -Filter 'pack-*.pack' | ForEach-Object {$marker = [IO.Path]::ChangeExtension($_.FullName, '.promisor')- if (-not (Test-Path -LiteralPath $marker)) { New-Item -ItemType File -Path $marker | Out-Null }+ if (-not (Test-Path -LiteralPath $marker)) {+ try { New-Item -ItemType File -Path $marker | Out-Null }+ catch { Write-Warn "could not mark $marker as a partial-clone pack" }+ }}}Invoke-Logged "Fetching origin/$Branch" { git -C $InstallDir fetch origin "+refs/heads/${Branch}:refs/remotes/origin/${Branch}" }diff --git a/scripts/install.sh b/scripts/install.shindex ef22de6b548..502c882fda8 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -469,7 +469,9 @@ stage_repository() {if [ "$(git -C "$INSTALL_DIR" config --bool --get remote.origin.promisor)" = true ]; thenlocal packfor pack in "$INSTALL_DIR"/.git/objects/pack/pack-*.pack; do- if [ -f "$pack" ] && [ ! -e "${pack%.pack}.promisor" ]; then : > "${pack%.pack}.promisor"; fi+ if [ -f "$pack" ] && [ ! -e "${pack%.pack}.promisor" ]; then+ : > "${pack%.pack}.promisor" || log_warn "could not mark $pack as a partial-clone pack"+ fidonefirun_logged "Fetching origin/$BRANCH" git -C "$INSTALL_DIR" fetch origin "+refs/heads/$BRANCH:refs/remotes/origin/$BRANCH" \diff --git a/tests/hermes_cli/test_gitlock.py b/tests/hermes_cli/test_gitlock.pyindex f9cfa8174ea..328f26fa6e2 100644--- a/tests/hermes_cli/test_gitlock.py+++ b/tests/hermes_cli/test_gitlock.py@@ -147,11 +147,8 @@ _CRASH_STDERR_WINDOWS = ("fatal: index-pack failed\n")-# git 2.55 evidence (#125138): the builds that dropped "index-pack failed" report the-# aborted helper as "fetch-pack: invalid index-pack output" instead — that string exists in-# Homebrew git 2.55.0 while "index-pack failed" does not. Field report: macOS 27 + git 2.55.0-# failed the update fetch on the bare assertion line and exited 1 without retrying, and a-# plain re-run of `hermes update` right after succeeded.+# git 2.55 builds report the aborted helper as "fetch-pack: invalid index-pack output" and no+# longer print "index-pack failed" (#125138)._CRASH_STDERR_GIT_255 = ("BUG: builtin/pack-objects.c:5004: should_include_obj should only be called on existing objects\n""fatal: fetch-pack: invalid index-pack output\n"@@ -165,7 +162,7 @@ def test_crash_recognizer_rejects_unrelated_failures():"error: pack-objects died of signal 6") # one marker alone is not the crashassert not is_partial_clone_pack_objects_crash("BUG: builtin/pack-objects.c:4842: should_include_obj should only be called on existing objects\n"- "fatal: index-pack failed\n") # fingerprint without either terminator: not this crash+ "fatal: index-pack failed\n") # fingerprint without a terminator line: not this crashassert not is_partial_clone_pack_objects_crash("fatal: fetch-pack: invalid index-pack output\n") # 2.55 wrapper alone is not the crashassert not is_partial_clone_pack_objects_crash("")diff --git a/website/docs/getting-started/updating.md b/website/docs/getting-started/updating.mdindex 914407739b4..cbd089c531b 100644--- a/website/docs/getting-started/updating.md+++ b/website/docs/getting-started/updating.md@@ -172,15 +172,18 @@ one, or when markers were lost. `hermes update` marks those packs and retries than installer rerun marks them before it fetches. An install whose own updater predates that fixcan't fetch it: rerun the installer, or mark the packs by hand (with Hermes closed) and update again.+The checkout is `hermes-agent` under your Hermes home (`~/.hermes`, or `HERMES_HOME` when set;+on Windows `%LOCALAPPDATA%\hermes` unless `HERMES_HOME` is set).+```bash# macOS / Linux-cd ~/.hermes/hermes-agent-for p in .git/objects/pack/pack-*.pack; do [ -e "${p%.pack}.promisor" ] || : > "${p%.pack}.promisor"; done+repo="${HERMES_HOME:-$HOME/.hermes}/hermes-agent"+for p in "$repo"/.git/objects/pack/pack-*.pack; do [ -e "${p%.pack}.promisor" ] || : > "${p%.pack}.promisor"; done``````powershell# Windows-$repo = "$env:LOCALAPPDATA\hermes\hermes-agent"+$repo = Join-Path ($(if ($env:HERMES_HOME) { $env:HERMES_HOME } else { "$env:LOCALAPPDATA\hermes" })) 'hermes-agent'Get-ChildItem "$repo\.git\objects\pack\pack-*.pack" | ForEach-Object {$m = [IO.Path]::ChangeExtension($_.FullName, '.promisor')if (-not (Test-Path -LiteralPath $m)) { New-Item -ItemType File -Path $m | Out-Null }@@ -190,12 +193,15 @@ Get-ChildItem "$repo\.git\objects\pack\pack-*.pack" | ForEach-Object {The checkout stays a partial clone. Don't remove `remote.origin.promisor` / `partialclonefilter` toget past the crash: objects that only release tags or update backups reach were never downloaded,so a non-partial checkout then fails `git gc` with `bad tree object`. If you already did, fetch the-missing objects and check that none are left before turning automatic cleanup back on-(PowerShell; on macOS / Linux the same `git` commands work with `grep '^?' | cut -c2-`):+missing objects and check that none are left before turning automatic cleanup back on:++```bash+git -C "$repo" rev-list --objects --missing=print --all | grep '^?' | cut -c2- | git -C "$repo" fetch -q --no-tags --stdin origin+git -C "$repo" rev-list --objects --missing=error --all >/dev/null && echo complete+``````powershell-$miss = git -C $repo rev-list --objects --missing=print --all | Where-Object { $_.StartsWith('?') } | ForEach-Object { $_.Substring(1) }-if ($miss) { git -C $repo fetch --no-tags origin @miss }+git -C $repo rev-list --objects --missing=print --all | Where-Object { $_.StartsWith('?') } | ForEach-Object { $_.Substring(1) } | git -C $repo fetch -q --no-tags --stdin origingit -C $repo rev-list --objects --missing=error --all | Out-Null; $LASTEXITCODE # 0 = complete```