Repository navigation
fix(setup): configure a comment-only Hermes config.yaml - #2096
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
dandgabr
left a comment
There was a problem hiding this comment.
Review suggestion
- P2 — Preserve explicit YAML null roots.
parseYaml(text) ?? {}treats every YAML null scalar (for examplenullor~) like a comment-only or bare----document. Setup then replaces that explicit value with the REA server map, silently discarding existing configuration. Restrict the empty-document exception to syntactically empty/comment-only input and a bare document marker; continue rejecting explicit null scalar roots.
|
@greptileai review |
|
comments, or only a `---` marker, also parses to a null YAML document.
Setup still rejected it as malformed ("expected record, received null")
and reported Hermes as invalid.
Treat a null Hermes document as holding no settings, as morluto#1983 does for
an empty file. The serializer already edits a comment-only document in
place. A bare `---` document holds a null scalar that takes no keys, so
replace it with a map and keep the comments written after the marker.
Only a document with no root, or a bare --- marker whose null scalar has no source text, holds no settings. An explicit null or ~ is a value, so setup and uninstall reject it as before, the same as any other non-map root.
4e86418 to
41c6de4
Compare
|
@dandgabr Thanks, you're right. 41c6de4 narrows it. A document is treated as empty only when it has no root (comments only) or its root is the null scalar of a bare Four cases cover it in the shape-diagnostics |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41c6de4b78
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ction length limit The Hermes YAML registration block reached 159 lines, past oxlint's max-lines-per-function limit of 150. Move the empty-document cases and the multiple-document rejection into their own block.
|
Thanks for taking this further. I ran the checks you skipped against ede7dfe. The Hermes configuration tests passed (28), but typecheck and lint each failed once. Both are fixed on the branch now:
|
parseDocument with options returns a Document.Parsed, whose contents accept only parsed nodes, so assigning the new map for a bare --- root failed typecheck (TS2322). Annotate the edited document as Document, as the code did before it moved into HermesConfigurationYaml.ts.
|
Thanks for merging, and for tightening the empty-document rule. |
Summary
rea setup --client hermesstill fails when~/.hermes/config.yamlholds only comments. #1983 fixed the empty file, and its PR body left the comment-only file out because the serializer would need separate handling. This finishes that case. No issue is linked, because the gap is the one #1983 already describes.Problem and expected behavior
A file such as
# Hermes configuration\nis not whitespace, so it skips the empty-file rule #1983 added. YAML then parses it tonull, the same value an empty file gives, and the Hermes branch ofparseDocumentrejects it:A file holding only a
---marker fails the same way, and fixing the parse is not enough for it. yaml 2.9.0 gives a bare---document a null scalar as its root, where a comment-only file has empty contents.serializeHermesConfigurationcannot set a key path on a scalar ("Expected a YAML collection as document contents").Expected: both files are configured like an empty one, and their comments stay. DeepSeek Harness already does this for a comment-only
cordis.patch.yml(appends a registration to a comment-only patch fileindshClientConfiguration.test.ts).Change and scope
parseDocumentreads a Hermes document with no settings as{}: comments only, or a bare---. An explicitnullor~root is written out, so it is still rejected like any other root that is not a map (changed after review).serializeHermesConfigurationreplaces a null-scalar root with an empty map before it adds the entry. The comments the scalar carried move to the new map, so---\n# Hermes configuration\nkeeps its comment.setInalready builds the map, keeping the comment above it.Not changed, and yours to decide:
cordis.patch.ymlbut rejects a bare---one with "Cordis patches must be a YAML operation list". It is the same null-scalar root, in a separate reader (DshCordisYaml). I left it alone to keep this to Hermes.// cursor\nin~/.cursor/mcp.json, with "Invalid JSON/JSONC at offset 10: ValueExpected". That comes from the JSON parser, so this fix does not reach it, and whether each client should accept such a file is a separate question.mcp_servers: {}behind, after the kept comments. An empty file does the same today after fix(setup): configure an empty Hermes config.yaml #1983.Contract and boundary impact
parseDocumentand its serializer,serializeHermesConfiguration(src/application/ClientConfigurationDocument.ts).docs/public/product-catalog.json), package, or installation impact: none.Evidence and regression coverage
it.eachintests/boundary/filesystem/hermesClientConfiguration.test.tsgets 3 more inputs:"# Hermes configuration\n","---\n"and"---\n# Hermes configuration\n". Each case now also checks that the written file starts with the original text. The shape-diagnosticsit.eachgetsnull,~, a comment thennull, and--- ~, which must still be rejected before any change. All 4 fail on the first commit and pass on the second.expected 'failed' to be 'configured'. The 2 existing cases still pass.parseDocument, all 3 fail. Without the root replacement, the 2---cases fail. Without carrying the comments over,"---\n# Hermes configuration\n"fails on the kept text.rea setup --client hermes --yesagainst a scratchHOME, before and after.config.yamlbeforeready, configuredready, configured# Hermes configurationneeds_human, "expected record, received null"ready, comment kept---needs_human, "expected record, received null"ready, marker kept---then# Hermes configurationneeds_human, "expected record, received null"ready, marker and comment keptWith the fix, a second
rea setupplans no actions and leaves the file byte-identical, anddoctorreads the registration asaligned.rea uninstallthen reportsremovedand keeps the comments and the marker.For evidence-bearing changes:
Validation performed
npm run test:focusedover the 8 files that cover client configuration setup, including the Hermes and DeepSeek Harness acceptance and boundary tests: 227 tests passed.npm run check:fast: passed.npm run verify:test-discovery: "Discovered all 915 test files exactly once."Compatibility, safety, and release
---, is newly accepted, as a document with no settings. An explicit null root is rejected as before.Review checklist
type(scope): outcome.