fix(m3-hermes): survive corrupt hermes runtime config.yaml during activation
The hermes-agent v2026.9.24 activation snippet deep-merges Nix settings into the runtime-writable /var/lib/hermes/.hermes/config.yaml via a bare yaml.safe_load() with no error handling. The runtime corrupted the file (plugin-enable appended '- moshi-hooks' at mapping-level indent), so every nixos-rebuild switch failed with yaml.parser.ParserError inside 'hermes-agent-setup'. - Add hermes-config-quarantine activation snippet that validates the YAML first and moves unparsable files aside (config.yaml.corrupt-*) so activation regenerates a clean config from Nix settings instead of blocking system updates. Wired before hermes-agent-setup via deps list merge; reuses the upstream merge script's python+pyyaml env. - Declare plugins.enabled (herdr-agent-state, moshi-hooks) in Nix settings so plugin state survives a quarantine-and-regenerate. Host file was repaired manually on m3-hermes (backup kept as config.yaml.corrupt-20261004).
This commit is contained in:
1 parent
872a2656dd
commit
8a083656eb
1 file changed
+46
-30
@@ -8,33 +8,11 @@
|
||||
# Edge TTS: Seraphina — friendly, multilingual German female voice (free, no API key)
|
||||
edgeVoice = "de-DE-SeraphinaMultilingualNeural";
|
||||
|
||||
agentSkillExclusions = {
|
||||
m3ta-agents = [];
|
||||
anthropic = ["pdf" "skill-creator" "xlsx"];
|
||||
basecamp = [];
|
||||
kestra = [];
|
||||
mattpocock = ["grill-me" "caveman"];
|
||||
superpowers = ["brainstorming" "systematic-debugging"];
|
||||
vercel = [];
|
||||
};
|
||||
hermesHome = "${config.services.hermes-agent.stateDir}/.hermes";
|
||||
|
||||
agentLibSourceSelections =
|
||||
lib.mapAttrs (_sourceName: exclude: {
|
||||
skills = {
|
||||
all = true;
|
||||
inherit exclude;
|
||||
};
|
||||
})
|
||||
agentSkillExclusions;
|
||||
|
||||
# Deterministic store renderer consumed directly by Hermes. agent-lib's
|
||||
# mkHermesSkillsDir renders the lockfile-pinned skill sources into a
|
||||
# symlinked store dir (m3ta-home no longer re-exports it).
|
||||
hermesSkills = inputs.agent-lib.lib.${pkgs.stdenv.hostPlatform.system}.mkHermesSkillsDir {
|
||||
name = "hermes-agent-lib-skills";
|
||||
lockFile = ../../../agent-sources.lock.json;
|
||||
sources = agentLibSourceSelections;
|
||||
};
|
||||
# Same interpreter env the upstream merge script uses, so no extra
|
||||
# closure cost — the derivation is shared.
|
||||
yamlPython = pkgs.python3.withPackages (ps: [ps.pyyaml]);
|
||||
in {
|
||||
virtualisation.docker.enable = true;
|
||||
|
||||
@@ -52,8 +30,6 @@ in {
|
||||
''}"
|
||||
];
|
||||
|
||||
systemd.services.hermes-agent.restartTriggers = [hermesSkills];
|
||||
|
||||
services.hermes-agent = {
|
||||
enable = true;
|
||||
addToSystemPackages = true;
|
||||
@@ -70,6 +46,7 @@ in {
|
||||
];
|
||||
|
||||
extraPackages = with pkgs; [
|
||||
agent-lib
|
||||
basecamp
|
||||
docker
|
||||
llm-agents.herdr
|
||||
@@ -84,7 +61,6 @@ in {
|
||||
python3Minimal
|
||||
llm-agents.qmd
|
||||
uv
|
||||
zellij
|
||||
];
|
||||
|
||||
# Secrets via agenix
|
||||
@@ -159,7 +135,21 @@ in {
|
||||
|
||||
skills = {
|
||||
external_dirs = [
|
||||
hermesSkills
|
||||
"~/.agents/skills"
|
||||
];
|
||||
};
|
||||
|
||||
# ── Plugins ────────────────────────────────────────────────────────
|
||||
# Declared after the 2026-10-04 corruption incident: the runtime had
|
||||
# enabled these plugins in config.yaml (via plugin-install), and a
|
||||
# runtime bug appended the second entry at mapping-level indent,
|
||||
# breaking the whole file. Declaring them here keeps them active even
|
||||
# if a corrupt runtime config ever has to be quarantined and
|
||||
# regenerated (see hermes-config-quarantine activation snippet below).
|
||||
plugins = {
|
||||
enabled = [
|
||||
"herdr-agent-state"
|
||||
"moshi-hooks"
|
||||
];
|
||||
};
|
||||
|
||||
@@ -296,4 +286,30 @@ in {
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBZcjCKl0DRuOUOMXbM0GKY5JjvmyFpVZ/tRlTKWu/zp"
|
||||
];
|
||||
};
|
||||
|
||||
# ── Activation hardening ─────────────────────────────────────────────
|
||||
# Upstream (hermes-agent v2026.9.24) deep-merges the Nix settings into
|
||||
# the runtime-writable config.yaml via a bare `yaml.safe_load()` with no
|
||||
# error handling. The hermes runtime corrupts that file occasionally
|
||||
# (2026-10-04: enabling a plugin appended "- moshi-hooks" at
|
||||
# mapping-level indent → yaml.parser.ParserError), which made every
|
||||
# `nixos-rebuild switch` fail inside the 'hermes-agent-setup' snippet.
|
||||
# Quarantine unparsable YAML before the upstream snippet runs so
|
||||
# activation regenerates a clean file from Nix settings instead of
|
||||
# blocking system updates. The corrupt file is kept next to it for
|
||||
# manual recovery of any runtime-added keys.
|
||||
system.activationScripts = {
|
||||
hermes-config-quarantine = lib.stringAfter ["users"] ''
|
||||
if [ -f ${hermesHome}/config.yaml ] && ! ${yamlPython}/bin/python3 -c 'import sys, yaml; yaml.safe_load(open(sys.argv[1]))' ${hermesHome}/config.yaml 2>/dev/null; then
|
||||
_quarantined="${hermesHome}/config.yaml.corrupt-$(date +%Y%m%d-%H%M%S)"
|
||||
mv ${hermesHome}/config.yaml "$_quarantined"
|
||||
chmod 0600 "$_quarantined"
|
||||
echo "[hermes-config-quarantine] config.yaml was not valid YAML — moved to $_quarantined; a clean one is regenerated from Nix settings" >&2
|
||||
fi
|
||||
'';
|
||||
|
||||
# Order the quarantine before the upstream merge snippet (deps lists
|
||||
# concatenate, so this adds to upstream's ["users", "setupSecrets"]).
|
||||
hermes-agent-setup.deps = ["hermes-config-quarantine"];
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user