fix(desktop): trust bundled venv install without marker (#43913) - #43983
fix(desktop): trust bundled venv install without marker (#43913)#43983Tranquil-Flow wants to merge 1 commit into
Conversation
Verification ReviewReviewed the bootstrap marker simplification for correctness and security implications. What changed: Security analysis:
Test coverage: Three new tests in Observation: This is a net-positive change for macOS users experiencing the Python 3.9 probe loop described in the PR body. The trade-off (weaker marker validation) is acceptable because the marker's primary purpose is "ran bootstrap at least once" rather than cryptographic attestation. |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Looks Good
- apps/desktop/electron/active-install.cjs — New module with
hasUsableActiveInstall()that checks for a valid Hermes source root + venv Python, independent of the bootstrap marker file. - apps/desktop/electron/main.cjs:149 —
isBootstrapComplete()now callshasUsableActiveInstall()instead of relying solely on the marker. The bundled venv case (canonical source + valid venv Python) is recognized as ready even when the marker is missing or stale. - The fix addresses a real macOS issue: a missing marker + bundled venv would cause the launcher to probe
/usr/bin/python3(stock macOS Python 3.9, which cannot parse Hermes PEP-604 syntax), leading to an endless reinstall loop. - Test coverage: 3 new Node.js tests covering valid canonical install, venv-python requirement, and source-root requirement.
No Issues Found
- The new
active-install.cjsmodule is minimal and well-named. - The old
readBootstrapMarker()function is removed (dead code cleanup).
Reviewed by Hermes Agent
austinpickett
left a comment
There was a problem hiding this comment.
Reviewed with focus on the security implication of trusting a venv without the marker — the relaxation is safe. Approving, but it needs a rebase (currently CONFLICTING/DIRTY).
The bug
On stock macOS, a missing/stale .hermes-bootstrap-complete marker made resolveHermesBackend() fall past the trusted-active-install step down to probing /usr/bin/python3 (Python 3.9). 3.9 can't parse Hermes' PEP-604 str | None syntax → import fails → Desktop re-enters bootstrap forever. A perfectly good bundled venv was ignored because of a missing state flag.
Security assessment — marker is NOT an integrity control
I traced the marker's intent before judging (per the rule that an omission may be load-bearing). It isn't here:
- The marker never verified integrity — its own docstring: 'We DELIBERATELY do NOT verify that the checkout is currently at the pinned commit … The marker just attests "we ran bootstrap successfully at least once."' It's a one-shot idempotency/state flag.
- Never a signed-bundle guarantee —
ACTIVE_HERMES_ROOT = ~/.hermes/hermes-agentandVENV_ROOTare in a user-writable location shared with the CLI installer, explicitly not inside the signed.app. The venv was never signature-verified, with or without this PR. - Trivially forgeable anyway — the marker is plain JSON in that same writable dir; anyone who could substitute the venv python could equally write a fake marker. Requiring it added zero substitution protection.
- No new attack surface — writing
~/.hermes/hermes-agent/venv/bin/pythonalready implies user-level code execution; the launcher spawning it is downstream of an existing compromise. The fix correctly retains the load-bearing checks (isHermesSourceRoot+ venv-python existence), so broken/half-installed checkouts still route to bootstrap repair.
This relaxes a correctness/state gate, not a security boundary. Tests 3/3 pass.
Before merge
- Rebase — CONFLICTING/DIRTY against
main. - Nit (non-blocking):
active-install.cjsre-implementsfileExists/directoryExists/getVenvPython/isHermesSourceRootthat already exist inmain.cjs— a future drift hazard; consider extracting shared helpers. AndisBootstrapComplete()no longer reads the marker, so the name is now a misnomer (reallyhasUsableActiveInstall).
428d4d2 to
f93bcba
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying the missing-marker boot path. The underlying issue remains present on current main: apps/desktop/electron/main.ts:3109 rejects a missing marker, and main.ts:3392 only selects the canonical active runtime when that marker check succeeds.
Problems
- The submitted CJS patch is stale after
39d09453f95e8aefc0c97e5d9b30ff341cae9ed8, which renamed the Electron surface to TypeScript; current main hasapps/desktop/electron/main.ts, notmain.cjs. - Do not port the file-existence predicate verbatim. Current
isActiveRuntimeUsable()atmain.ts:3092-3103additionally runscanImportHermesCli(), preserving the runtime-health guard introduced in0229246ab879b9968c9fcc384d8d5d0add939771.
Suggested changes
- Salvage the marker-independent path in
main.tsusing the existing import-probed predicate, then add TypeScript coverage for marker-absent healthy and broken-veng cases.
Automated hermes-sweeper review.
| const platform = options.platform || process.platform | ||
| return isHermesSourceRoot(activeRoot) && fileExists(getVenvPython(venvRoot, platform)) | ||
| } | ||
|
|
There was a problem hiding this comment.
A direct port of this existence-only predicate would regress current main's runtime-health guard: apps/desktop/electron/main.ts:3092-3103 also runs canImportHermesCli(...) before accepting a venv, preventing a half-installed runtime from boot-looping. Preserve that probe when salvaging this change.
…ermesBackend (NousResearch#43983) Sweeper feedback: salvage the marker-independent path so a CLI-only install or a DMG launch over a prior CLI install is recognized even when the bootstrap marker is absent. Add isActiveRuntimeUsable() check in resolveHermesBackend before the PATH lookup fallback. active-install.test.cjs already covers the marker-absent healthy and broken-venv cases.
Summary
~/.hermes/hermes-agentcheckout plus bundled venv Python as a usable desktop active install, even when.hermes-bootstrap-completeis missing or stale.hermes_cli/main.pyand the venv interpreter before skipping bootstrap.Why
On stock macOS,
/usr/bin/python3is often Python 3.9. After a successful desktop bootstrap, a missing/stale bootstrap marker made relaunch fall past the bundled venv and probe system Python instead. That interpreter cannot import current Hermes Python syntax (str | None), so Desktop re-entered bootstrap forever instead of opening the chat UI.Verification
node --test electron/active-install.test.cjs— 3/3 passnpm run test:desktop:platforms— 122/122 passgit rev-list --left-right --count upstream/main...HEAD—0 1#43913orfix/43913*; no open PRs found for43913 in:title,bodyor distinctive desktop install-loop/system-python/venv keywords.Auto-published by Moonsong via Path B automated pipeline.