Skip to content

The agent that grows with you

fix(update): the dead-lock proof decodes as UTF-8 and its lsof lookup is allowlisted

Tekniuma1403f42bc7f
diff --git a/hermes_cli/_early_recovery.py b/hermes_cli/_early_recovery.py
index 177dbbb5a0f..402a94b67ca 100644
--- a/hermes_cli/_early_recovery.py
+++ b/hermes_cli/_early_recovery.py
@@ -444,7 +444,7 @@ def _held_open(path: Path, root: Path | None = None) -> bool | None:
if inside is None:
continue
try:
- comm = (pid_dir / "comm").read_text(encoding="utf-8", errors="replace").strip()
+ comm = (pid_dir / "comm").read_bytes().decode("ascii", "replace").strip() # /proc: Linux only
cwd = os.readlink(pid_dir / "cwd")
except OSError:
continue
@@ -460,7 +460,8 @@ def _held_open(path: Path, root: Path | None = None) -> bool | None:
if lsof is None:
return None
try:
- found = subprocess.run([lsof, "-t", "--", str(path)], capture_output=True, text=True, timeout=20,
+ found = subprocess.run([lsof, "-t", "--", str(path)], capture_output=True, text=True, encoding="utf-8",
+ errors="replace", timeout=20,
stdin=subprocess.DEVNULL)
except (OSError, subprocess.SubprocessError):
return None
diff --git a/tests/fixtures/resolution_allowlist.json b/tests/fixtures/resolution_allowlist.json
index eb19295eed1..e9738000134 100644
--- a/tests/fixtures/resolution_allowlist.json
+++ b/tests/fixtures/resolution_allowlist.json
@@ -125,6 +125,12 @@
"kind": "bare_which",
"reason": "stdlib-only launch-time repair (runs from hermes_bootstrap before hermes_platform or app deps import); falls back to PM's staged git"
},
+ {
+ "path": "hermes_cli/_early_recovery.py",
+ "symbol": "_held_open",
+ "kind": "bare_which",
+ "reason": "stdlib-only launch-time repair asks the OS's own lsof (macOS/BSD) whether a dead git's index.lock is still open; absent lsof means unknown and the lock is kept"
+ },
{
"path": "hermes_cli/_subprocess_compat.py",
"symbol": "resolve_node_command",