fix(install): Hermes hook edit no longer refuses unrelated YAML sections (#2209) - #2355
Merged
Merged
Conversation
…ons (#2209) `install` on a Hermes Agent config wrote the mcp_servers entry and the skill, then failed op=pre_llm_hook_install on the same config.yaml. The stock Hermes config (cli-config.yaml.example) reproduces it on its own. Root cause: the nested-sequence editor behind the hooks.pre_llm_call item validated EVERY line of the document and refused any flow collection or block scalar anywhere. The stock config carries flow sequences in sections the hook edit never reads or rewrites (`platform_toolsets:` -> `cli: [hermes-cli]`, reporters' `plugins:` -> `enabled: [...]`). The mapping-entry editor that writes mcp_servers into the same file already treats other top-level sections as opaque user content, which is why that op succeeded. Fix: yaml_sequence_validate_document now validates only the top-level section the edit descends into (the first sequence_path key). The root mapping is still validated at parse time, so section boundaries stay sound. An absent section is appended as a new top-level key and touches no existing line. Inside the edited `hooks` subtree the fail-closed rules are unchanged. This also unblocks uninstall (op=pre_llm_hook_uninstall), which shares the analyzer. Tests: new config_yaml_edit case with foreign flow sequences plus `|`/`>` block scalars (install, byte-idempotent reinstall, remove). The two #1924 "still refuses" pins now place the unsupported construct inside `hooks:`, where the refusal still applies byte-identically. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
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.
The
hooks.pre_llm_calledit (nested-sequence YAML editor) checked every line of config.yaml and refused any flow collection or block scalar anywhere in the file. The stock Hermes config hasplatform_toolsets: cli: [hermes-cli], so install failed atpre_llm_hook_install(and uninstall atpre_llm_hook_uninstall), while themcp_serversedit on the same file succeeded.The validator now checks only the top-level section it descends into (
hooks); other sections are opaque user content, matching the mapping-entry editor. The strict rules insidehooks:are unchanged, and the canonical-item self-check is still fully validated.Review note: this deliberately narrows the #1924 / #1631 fail-closed scope from the whole file to the subtree being edited (the same precedent the mapping-entry editor already follows). The two #1924 pins now assert the refusal of
|,>and[a, b]insidehooks:, where it still applies byte-identically.cli-config.yaml.example(122 KB): before,op=pre_llm_hook_installerror and activation stopped; after, hook installed, reinstall byte-identical, uninstall clean, and the result parses with a real YAML parser.config_yaml_edit_nested_sequence_ignores_foreign_flow_and_block_scalars_issue2209(RED 3/3 before, RED on revert); config_yaml_edit 66/66, cli 322;make lint-cigreen.Fixes #2209