Conversation
…e customizations
Adds a complete local-patch-recovery toolkit for users who maintain
source-tree customizations to /usr/local/lib/hermes-agent/ (e.g. local
bug fixes, performance patches, or workarounds for unmerged PRs).
The kit:
1. scripts/local-patch-recovery-hook.sh — a git post-merge hook
template. When installed into .git/hooks/post-merge, it runs after
every successful git pull / git merge (including the git-based path
of `hermes update`). It detects when a tracked local patch has been
reverted by checking a canary function in the source, then
re-applies the fix using:
a) git cherry-pick --3way of the commit SHA listed in
~/.hermes/patches/manifest.txt (preferred — survives context
line drift from rebases)
b) git apply --3way on a .patch file in ~/.hermes/patches/ as a
legacy fallback
2. scripts/hermes-preupdate.sh — a read-only preflight check you run
before any `hermes update`. Snapshots the current git state and
local patches to ~/.hermes/state-snapshots/<timestamp>-pre-update/,
verifies the hook is installed, verifies the canary is currently
applied, and reminds you to run a backup if the last one is older
than 14 days.
3. scripts/install-local-patch-hooks.sh — one-shot installer. Copies
the hook + scripts to ~/.hermes/bin/, installs the git hook, creates
the manifest placeholder, and supports --check / --uninstall.
4. scripts/local-patches-README.md — the README that gets installed to
~/.hermes/patches/README.md explaining the format and recovery
procedure.
Use case: today, any local source patch is silently reverted by the
first `hermes update`. This makes that visible and recoverable
without operator action. Triggered by PR NousResearch#36779 which is the first
known local patch on this server; future local patches can be added
by appending a line to ~/.hermes/patches/manifest.txt.
The hook is opt-in: nothing is installed until the user runs the
install script. The default Hermes install is unaffected.
mxnstrexgl
approved these changes
Jun 1, 2026
mxnstrexgl
left a comment
There was a problem hiding this comment.
🤖 Automated PR Review
Security Scan
- ✓ No hardcoded secrets, injection sinks, unsafe deserialization, or dependency red flags found by this automated scan.
Code Quality
- ✓ No blocking code-quality issues found by this automated scan.
- ℹ️ No test file changes detected; verify existing coverage exercises this behavior.
Summary
Status: APPROVE — security findings: 0, quality suggestions: 0.
Automated review; raw diff content intentionally omitted.
Collaborator
|
Thanks for the recovery tooling work. This is an automated hermes-sweeper review; current
Because local source-tree patches are no longer silently overwritten by |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
If a user applies a local source-tree patch to
/usr/local/lib/hermes-agent/(e.g. to fix a bug, optimize a workflow, or work around an unmerged PR), the firsthermes updatewill silently revert that patch with no warning.hermes updaterunsgit pull --ff-onlyon the managed checkout, and uncommitted modifications to tracked files are overwritten.This is invisible until something breaks. There is no built-in way to:
Solution
A small, opt-in toolkit that ships as ordinary files under
scripts/:**scripts/local-patch-recovery-hook.sh**— a git post-merge hook template. When installed into.git/hooks/post-merge, it runs after every successfulgit pull/git merge(including the git-based path ofhermes update). It detects when a tracked local patch has been reverted by checking a canary function in the source, then re-applies the fix using:git cherry-pick --3wayof the commit SHA listed in~/.hermes/patches/manifest.txt(preferred — survives context line drift from rebases)git apply --3wayon a.patchfile in~/.hermes/patches/as a legacy fallback**scripts/hermes-preupdate.sh**— a read-only preflight check you run before anyhermes update. Snapshots the current git state and local patches to~/.hermes/state-snapshots/<timestamp>-pre-update/, verifies the hook is installed, verifies the canary is currently applied, and reminds you to run a backup if the last one is older than 14 days.**scripts/install-local-patch-hooks.sh**— one-shot installer. Copies the hook + scripts to~/.hermes/bin/, installs the git hook, creates the manifest placeholder, and supports--check/--uninstall.**scripts/local-patches-README.md**— the README that gets installed to~/.hermes/patches/README.mdexplaining the format and recovery procedure.Use case: PR #36779
PR #36779 is a fix for the minimax-oauth auxiliary routing bug — the kind of patch a user might apply locally while waiting for the PR to merge. Once it does merge, the local patch becomes redundant; until then, the user needs it to survive updates. This toolkit is the mechanism that makes that work without operator action.
Design choices
~/.hermes/and the local.git/hooks/directory. The source checkout is never modified by the install script itself.install-local-patch-hooks.shcan be run multiple times safely.--checkis intended for cron / monitoring.git applyis a fallback for legacy patches without a recorded SHA.pyproject.toml.Verification
The author has installed this on a production server and tested the full failure recovery:
git checkout main -- agent/auxiliary_client.py(simulating an upstream revert) → canary count drops to 0.git/hooks/post-mergefires automaticallygit apply --3wayre-applies the patch from~/.hermes/patches/→ canary count back to 2hermes-preupdate.sh --checkconfirms: hook installed, patch applied, canary presentFiles
scripts/local-patch-recovery-hook.sh(new, 7.3 KB)scripts/hermes-preupdate.sh(new, 6.0 KB)scripts/install-local-patch-hooks.sh(new, 4.9 KB)scripts/local-patches-README.md(new, 3.0 KB)Total: +21 KB across 4 new files. No existing files modified.