Skip to content

Commit 7219a24

Browse files
DeusDataclaude
andcommitted
fix(yaml): scope > | [ ] indicators to the value start (DeusData#1924)
Hermes `install` failed with `op=pre_llm_hook_install` whenever config.yaml held a PLAIN scalar with a `>` or `|` anywhere after the value start — `probe: kaomoji face >w< here` — while the identical string double-quoted, or a mid-value `*`, installed fine. An agent-config failure aborts activation, so the whole install exited 1 and user-PATH registration was skipped although eleven other agents had configured cleanly. Bisected by @ukind, key by key and persona by persona, down to two persona strings (DeusData#1924, continuing DeusData#1631/DeusData#1656). Root cause: yaml_sequence_line_has_unsupported — the document validator on the mapping-sequence path that the hook upsert/remove uses — ran a second scan after the shared yaml_range_has_unsupported_ex and returned "unsupported" for `[`, `]`, `|` and `>` at ANY position of a plain scalar. The mapping-body path (mcp_servers) never had that check, which is exactly why the mcp op succeeded and only the hook op failed on the same file. Fix: the positional rule the `*`/`&` fix (v0.10.4) and the quote fix (DeusData#1631, v0.10.6) already use — an indicator counts only where a NODE begins (range start, after a mapping colon, after a block-sequence dash). Interior ones are text. `probe: >`, `probe: |`, `probe: >-` and `probe: [a, b]` still begin a value and stay unsupported, byte-identically. `[`/`]` get the same treatment on purpose: in block context they are ordinary characters inside a plain scalar (`a: b[0]` parses as the string `b[0]`), a value-start `[` still opens a flow sequence and stays refused (the DeusData#1631 line: exact `[]` accepted, non-empty flow sequences unsupported), and the mapping-body path already accepted them mid-value — leaving the sequence scan stricter would keep the mcp-op-passes / hook-op-fails asymmetry this issue is about. Known conservative residue, shared with the `*` rule: a plain-scalar CONTINUATION line that itself starts with one of these characters is still refused (nothing precedes it on its line). Tests (tests/test_config_yaml_edit.c): three accept cases run both real Hermes ops (mcp_servers + pre_llm_call) against a persona corpus with a mid-value `>`, `|` and `[]` and require the original document to survive as an untouched prefix; two pins keep value-start block scalars and a non-empty flow sequence refused with the file byte-identical. RED on the unfixed editor: 61 passed, 3 failed (`yaml_hermes_hook_upsert(&fixture) == -1`); GREEN: 64 passed; RED again with the production change reverted. config_yaml_edit 64 · yaml 73 · cli 306 — 443 passed, 0 failed (macOS, ASan/UBSan test build). Not in this change: the refusal still reaches the user as `op=pre_llm_hook_install path=... (target: regular file, N bytes)` with no reason. The editor collapses every one of its ~236 YAML_ERROR sites into CBM_YAML_IDENTITY_EDIT_ERROR, so naming the refusing rule needs a detailed variant with a typed failure out-parameter, the shape the Codex TOML hook path already has (cbm_toml_codex_hook_failure_t + record_agent_config_error_with_reason). Follow-up. Fixes DeusData#1924. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent aa44c28 commit 7219a24

2 files changed

Lines changed: 119 additions & 1 deletion

File tree

‎src/cli/config_yaml_edit.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2624,8 +2624,18 @@ static int yaml_sequence_line_has_unsupported(const yaml_doc_t *doc, const yaml_
26242624
if (value == '#' && (i == start || doc->data[i - YAML_UNIT] == ' ')) {
26252625
break;
26262626
}
2627+
/* Block-scalar (`|`, `>`) and flow-sequence (`[`, `]`) indicators
2628+
* count only where a NODE begins, the same positional rule
2629+
* yaml_range_has_unsupported_ex applies to `&`/`*`. Interior ones are
2630+
* text: `probe: kaomoji face >w< here` is a plain scalar, and a real
2631+
* Hermes config carried two such personas (#1924). `probe: >`,
2632+
* `probe: |` and `probe: [a, b]` still begin a value and stay
2633+
* unsupported here. */
26272634
if (value == '[' || value == ']' || value == '|' || value == '>') {
2628-
return YAML_MATCH;
2635+
bool begins_node = previous == '\0' || previous == ':' || previous == '-';
2636+
if (begins_node) {
2637+
return YAML_MATCH;
2638+
}
26292639
}
26302640
if (value != ' ' && value != '\t') {
26312641
previous = value;

‎tests/test_config_yaml_edit.c‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,109 @@ TEST(config_yaml_edit_bom_before_our_own_section_stays_single_issue1656) {
10961096
PASS();
10971097
}
10981098

1099+
/* ── #1924: block/flow indicators are indicators only where a value begins ──
1100+
*
1101+
* The sequence-document scan (the pre_llm_hook_install path) refused `>`,
1102+
* `|`, `[` and `]` at ANY position of a plain scalar, so a Hermes persona
1103+
* such as `probe: kaomoji face >w< here` made the hook op fail while the
1104+
* mcp_servers op on the same file succeeded (bisected to two persona strings
1105+
* by @ukind). YAML reads them as indicators only where a value begins — the
1106+
* rule the `*`/`&` fix and the quote fix (#1631) already apply. Both real
1107+
* Hermes ops run here; our blocks append, so the original document must
1108+
* survive as an untouched prefix. */
1109+
1110+
TEST(config_yaml_edit_hermes_accepts_interior_gt_in_plain_scalar_issue1924) {
1111+
const char *initial = "agent:\n"
1112+
" personalities:\n"
1113+
" probe: kaomoji face >w< here\n";
1114+
yaml_fixture_t fixture;
1115+
ASSERT_EQ(yaml_fixture_init(&fixture, initial), 0);
1116+
ASSERT_EQ(yaml_hermes_upsert(&fixture), CBM_YAML_IDENTITY_EDIT_OK);
1117+
ASSERT_EQ(yaml_hermes_hook_upsert(&fixture), CBM_YAML_IDENTITY_EDIT_OK);
1118+
char *after = yaml_read_alloc(fixture.path);
1119+
ASSERT_NOT_NULL(after);
1120+
ASSERT_EQ(strncmp(after, initial, strlen(initial)), 0);
1121+
ASSERT_NOT_NULL(strstr(after, "cbm-context"));
1122+
free(after);
1123+
th_cleanup(fixture.dir);
1124+
PASS();
1125+
}
1126+
1127+
TEST(config_yaml_edit_hermes_accepts_interior_pipe_in_plain_scalar_issue1924) {
1128+
const char *initial = "agent:\n"
1129+
" personalities:\n"
1130+
" probe: pipe char | mid value\n";
1131+
yaml_fixture_t fixture;
1132+
ASSERT_EQ(yaml_fixture_init(&fixture, initial), 0);
1133+
ASSERT_EQ(yaml_hermes_upsert(&fixture), CBM_YAML_IDENTITY_EDIT_OK);
1134+
ASSERT_EQ(yaml_hermes_hook_upsert(&fixture), CBM_YAML_IDENTITY_EDIT_OK);
1135+
char *after = yaml_read_alloc(fixture.path);
1136+
ASSERT_NOT_NULL(after);
1137+
ASSERT_EQ(strncmp(after, initial, strlen(initial)), 0);
1138+
ASSERT_NOT_NULL(strstr(after, "cbm-context"));
1139+
free(after);
1140+
th_cleanup(fixture.dir);
1141+
PASS();
1142+
}
1143+
1144+
TEST(config_yaml_edit_hermes_accepts_interior_brackets_in_plain_scalar_issue1924) {
1145+
/* In block context `[`/`]` inside a plain scalar are ordinary text; only
1146+
* a value-start `[` opens a flow sequence. */
1147+
const char *initial = "agent:\n"
1148+
" personalities:\n"
1149+
" probe: see docs[1] and args[] here\n";
1150+
yaml_fixture_t fixture;
1151+
ASSERT_EQ(yaml_fixture_init(&fixture, initial), 0);
1152+
ASSERT_EQ(yaml_hermes_upsert(&fixture), CBM_YAML_IDENTITY_EDIT_OK);
1153+
ASSERT_EQ(yaml_hermes_hook_upsert(&fixture), CBM_YAML_IDENTITY_EDIT_OK);
1154+
char *after = yaml_read_alloc(fixture.path);
1155+
ASSERT_NOT_NULL(after);
1156+
ASSERT_EQ(strncmp(after, initial, strlen(initial)), 0);
1157+
ASSERT_NOT_NULL(strstr(after, "cbm-context"));
1158+
free(after);
1159+
th_cleanup(fixture.dir);
1160+
PASS();
1161+
}
1162+
1163+
TEST(config_yaml_edit_hermes_hook_still_refuses_block_scalar_value_issue1924) {
1164+
/* A `>` or `|` that BEGINS a value is a real block scalar whose
1165+
* indentation contract this editor does not model: the fail-closed
1166+
* refusal stays, and the file stays byte-identical. */
1167+
static const char *const initials[] = {
1168+
"agent:\n personalities:\n probe: >\n folded face\n",
1169+
"agent:\n personalities:\n probe: |\n literal face\n",
1170+
"agent:\n personalities:\n probe: >-\n chomped face\n",
1171+
};
1172+
for (size_t i = 0U; i < sizeof(initials) / sizeof(initials[0]); i++) {
1173+
yaml_fixture_t fixture;
1174+
ASSERT_EQ(yaml_fixture_init(&fixture, initials[i]), 0);
1175+
ASSERT_EQ(yaml_hermes_hook_upsert(&fixture), CBM_YAML_IDENTITY_EDIT_ERROR);
1176+
char *after = yaml_read_alloc(fixture.path);
1177+
ASSERT_NOT_NULL(after);
1178+
ASSERT_STR_EQ(after, initials[i]);
1179+
free(after);
1180+
th_cleanup(fixture.dir);
1181+
}
1182+
PASS();
1183+
}
1184+
1185+
TEST(config_yaml_edit_hermes_hook_still_refuses_nonempty_flow_sequence_value_issue1924) {
1186+
/* Pins the #1631 line: exact `[]` is accepted, a non-empty flow sequence
1187+
* value is still unsupported in the sequence-document scan. */
1188+
const char *initial = "agent:\n"
1189+
" personalities:\n"
1190+
" probe: [a, b]\n";
1191+
yaml_fixture_t fixture;
1192+
ASSERT_EQ(yaml_fixture_init(&fixture, initial), 0);
1193+
ASSERT_EQ(yaml_hermes_hook_upsert(&fixture), CBM_YAML_IDENTITY_EDIT_ERROR);
1194+
char *after = yaml_read_alloc(fixture.path);
1195+
ASSERT_NOT_NULL(after);
1196+
ASSERT_STR_EQ(after, initial);
1197+
free(after);
1198+
th_cleanup(fixture.dir);
1199+
PASS();
1200+
}
1201+
10991202
/* ── Owned-entry repair (#1631 galaxy + goose upgrades) ──────────────────────
11001203
*
11011204
* Byte-identity alone freezes users on any OLD canonical our past writers
@@ -1989,6 +2092,11 @@ SUITE(config_yaml_edit) {
19892092
RUN_TEST(config_yaml_edit_hermes_accepts_interior_apostrophe_and_plain_wrap_issue1631);
19902093
RUN_TEST(config_yaml_edit_accepts_utf8_bom_issue1656);
19912094
RUN_TEST(config_yaml_edit_bom_before_our_own_section_stays_single_issue1656);
2095+
RUN_TEST(config_yaml_edit_hermes_accepts_interior_gt_in_plain_scalar_issue1924);
2096+
RUN_TEST(config_yaml_edit_hermes_accepts_interior_pipe_in_plain_scalar_issue1924);
2097+
RUN_TEST(config_yaml_edit_hermes_accepts_interior_brackets_in_plain_scalar_issue1924);
2098+
RUN_TEST(config_yaml_edit_hermes_hook_still_refuses_block_scalar_value_issue1924);
2099+
RUN_TEST(config_yaml_edit_hermes_hook_still_refuses_nonempty_flow_sequence_value_issue1924);
19922100
RUN_TEST(config_yaml_edit_repairs_prior_unquoted_command_entry_issue1631);
19932101
RUN_TEST(config_yaml_edit_repairs_prior_goose_block_without_name);
19942102
RUN_TEST(config_yaml_edit_still_refuses_truly_foreign_entry_under_our_key);

0 commit comments

Comments
 (0)