Repository navigation
fix(setup): keep Hermes config numbers as written - #2368
Conversation
Setup and uninstall re-printed every number in an existing Hermes config.yaml from a JavaScript number. Hermes reads the file as YAML 1.1 with exact integers, so a Discord channel ID lost its low digits, an octal mode such as 0600 became 600, and 0.0000001 became 1e-7, which YAML 1.1 does not define as a float. Two IDs that round to the same double were also rejected as duplicate keys, so setup could not register at all. Hermes YAML parsing and editing move to HermesConfigurationYaml. A parsed number is written with its source spelling while that spelling still reads as the node's value, the rule yaml's own boolean tag follows, and two keys are duplicates only when both their value and their spelling match. Parsed values stay JavaScript numbers.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Review Finding & Edge CaseIn const reader = context.doc.schema.tags.find(
(candidate): candidate is ScalarTag =>
candidate.default === true && candidate.test?.test(source) === true,
);
const read = reader?.resolve(
source,
() => undefined,
context.doc.options,
);
return Object.is(isScalar(read) ? read.value : read, item.value)
? source
: stringify(item, context, ...rest);Finding: BigInt vs Number Comparison in Hermes YAML
Suggested FixExplicitly configure |
|
@greptileai review |
|
This PR is set for a Plus review. TREX isn't supported with Plus or Apex reviews yet, so Greptile reviews this PR at Base while TREX is on. |
|
|
@matbrgz Neither side of that |
Summary
rea setupandrea uninstallrewrote every number in an existing Hermesconfig.yaml, not only REA's own entry, and some rewrites change what Hermes reads. Discord channel IDs lost their low digits, so adiscord.channel_promptsentry no longer matched its channel, and0600(octal 384 in YAML 1.1) became600. Two channel IDs that round to the same double also made setup refuse a file Hermes reads without error. Setup and uninstall now leave unrelated numbers exactly as written.No issue is linked. I found this while running setup and uninstall against synthetic Hermes configurations in a temporary
HOME.Problem and expected behavior
Smallest trigger: a Hermes
config.yamlwith an unquoted integer above 2^53, for example a Discord channel ID used as achannel_promptskey:Hermes reads
config.yamlthroughhermes_yaml.safe_load, which uses ruamel.yaml with YAML 1.1; before September 2026 it used PyYAML's safe loader. Integers stay exact,0600is octal, andgateway/config_loader.pystringifieschannel_promptskeys (_str_keyed), so the key must stay1187654321098765433.serializeHermesConfigurationedited the file through theyamlpackage's Document API, which keeps comments, butDocument.toString()prints every number from its JavaScript value. Integers above 2^53 round,0600is printed as the YAML 1.2 decimal600, and small floats switch to exponent notation such as1e-7, which YAML 1.1 does not define as a float.parseDocumentread the same file with default options, so two IDs that round to one double failed as duplicate keys before setup could register. Uninstall goes through the same serializer, so the changes stayed after REA was removed.Expected: only REA's
mcp_servers.reaentry changes, and every other scalar keeps its original text.Change and scope
Hermes YAML parsing and editing move to a new module,
src/application/HermesConfigurationYaml.ts, which owns theyamloptions both use.ClientConfigurationDocumentcalls itsparseHermesConfigurationYamlandeditHermesConfigurationYaml.customTagsfunction wraps the built-in int and float tags. A parsed number is written with its source text while that text still reads as the node's current value; otherwise it is printed from the value. This is the ruleyaml's own boolean tag follows, so a later in-place edit cannot write a stale spelling. Numbers REA creates for its own entry have no source text and print as before.uniqueKeystreats two keys as duplicates only when both their values and their source spellings match. IDs that round to one double, and0600beside600, are distinct keys to Hermes and are now accepted. A repeated key, such asaand"a", is still refused. Number keys spelled differently that Hermes reads as one value, such as1.0and1.00, were refused onmain; they are now left for Hermes to reject, and setup leaves their text unchanged.Parsed values are still JavaScript numbers. REA reads only
mcp_serversfrom the parsed object and edits the file text through the document, so rounding in unrelated parsed values does not reach the file. Other YAML and JSON client formats are unchanged. Comment placement and spacing are unchanged.#2096 (comment-only Hermes files) edits the same two
yamlcalls and already conflicts withmain. If this lands first, its root handling would move intoeditHermesConfigurationYaml.Contribution scope: not applicable (ordinary fix within existing boundaries).
Contract and boundary impact
HermesConfigurationYamlmodule, whichparseDocumentandserializeHermesConfigurationinsrc/application/ClientConfigurationDocument.tsnow call.mcp_servers.rea, and uninstall still removes only that entry; unrelated values are no longer altered as a side effect.docs/public/product-catalog.json), package, or installation impact: none.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
The checked configuration change is setup and uninstall editing Hermes
config.yaml, as before; this PR narrows what that edit touches.Evidence and regression coverage
Tests added or updated:
tests/boundary/filesystem/hermesClientConfiguration.test.tsadds "keeps unrelated numbers as written, including Discord IDs". It configures a file with a Discord ID list, twochannel_promptskeys one apart (they round to the same double),mode: 0600,min_score: 0.0000001and another MCP server, then checks that the original text is an exact prefix of the result, that the REA entry reads back, and that uninstall restores the original bytes.src/application/HermesConfigurationYaml.test.tscovers what the public workflow cannot reach: an in-place number edit is written from its new value, and0600/600keys are accepted while a repeated key is refused.Base reproduction or other evidence: with
ClientConfigurationDocument.tsrestored frommain(fd95880), the boundary test fails withexpected 'failed' to be 'configured'.User-visible CLI/MCP output (if applicable):
rea setup --yes --client hermes --skill=falseandrea uninstall, withHOMEset to a temporary directory holding:The
Hermeslines below read the files with Hermes's ownhermes_yaml.safe_load.Before (
main), setup returnsneeds_humanand reports the file as malformed (Map keys must be unique at line 7, column 5), and uninstall reportsfailed. With the second prompt removed, setup succeeds but rewrites the numbers, and uninstall leaves them rewritten:PyYAML reads that rewritten
min_scoreas the string'1e-7'.After, setup configures both files, the text above stays byte-for-byte ahead of the new
mcp_servers.reaentry, and Hermes reads the same values:Uninstall then removes the entry. Because this file had no
mcp_serverskey, an emptymcp_servers: {}remains, as it does onmain.Remaining proof gaps: I read the results with Hermes's
hermes_yaml.py(ruamel.yaml 0.18.16, on Python 3.9 rather than Hermes's 3.11+) and with PyYAML 6.0.3, but did not start Hermes itself.For evidence-bearing changes:
Validation performed
mainfd95880, with dependencies installed bynpm ci:npm run check:fastpasses.npm run test:focusedover 90 test files: everysrc/application/*.test.ts, the client configuration, setup, uninstall and Hermes suites intests/boundary/filesystem/, andtests/acceptance/setup/. All 1103 tests pass.npm run build:cachedon each checkout.Compatibility, safety, and release
rea setup --client hermesandrea uninstallwith an isolatedHOME; Hermes's YAML module and PyYAML as oracles.Before merge
type(scope): outcome.