Skip to content

fix(cli): YAML removers answer OK for an absent config, so uninstall no longer refuses - #2059

Merged
DeusData merged 2 commits into
DeusData:mainfrom
Balneario-de-Cofrentes:fix/yaml-remove-absent-config
Sep 6, 2026
Merged

fix(cli): YAML removers answer OK for an absent config, so uninstall no longer refuses#2059
DeusData merged 2 commits into
DeusData:mainfrom
Balneario-de-Cofrentes:fix/yaml-remove-absent-config

Conversation

@dgilperez

Copy link
Copy Markdown
Contributor

Problem

codebase-memory-mcp uninstall exits 1 on any macOS where Hermes is installed. Hermes is detected by its binary on PATH (cbm_agent_cli_exists("hermes", ...)), not by its home, so a HOME without .hermes/ reaches the Hermes uninstall ops with ~/.hermes/config.yaml absent. The JSON removers already treat a missing config as "nothing to remove" (cbm_json_like_read_document returns 1 → CLI_OK). The four YAML removers acquire the lock first, and the lock directory is created beside the target, so with the parent directory absent the lock fails and the adapter records:

error: agent_config agent=Hermes op=pre_llm_hook_uninstall path=.../.hermes/config.yaml (target: does not exist or cannot be inspected)
error: agent_config agent=Hermes op=mcp_uninstall path=.../.hermes/config.yaml (target: does not exist or cannot be inspected)
error: one or more agent cleanup operations failed; executable and index removal were not started

This is also why cli_uninstall_quiesces_active_cohort_before_removing_binary_and_index fails on such a machine: on a pristine main (2026-09-04) the suite gives 7837 passed, 1 failed, 7 skipped here, with Hermes at ~/.local/bin/hermes.

Fix

cbm_yaml_remove_mapping_entry, cbm_yaml_remove_owned_mapping_entry, cbm_yaml_remove_mapping_sequence_item and cbm_yaml_remove_string_list_item short-circuit with their OK value on a true ENOENT (lstat, or ERROR_FILE_NOT_FOUND/ERROR_PATH_NOT_FOUND on Windows) and create nothing. A dangling symlink still reaches the reader and keeps its byte-identical rejection (config_yaml_edit_nested_sequence_rejects_symlink_byte_identically unchanged).

Validation

  • New test config_yaml_edit_remove_on_absent_config_is_a_no_op covers the four removers against a path whose directory does not exist.
  • make -f Makefile.cbm test on macOS arm64 with Hermes installed: all passed, 7 skipped (the previously failing cli_uninstall_quiesces_active_cohort_before_removing_binary_and_index included).
  • DCO sign-off included.

@dgilperez
dgilperez requested a review from DeusData as a code owner September 4, 2026 22:09
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Thanks for opening this — it has been seen, and it is queued.

This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence.

Current review status: working through a backlog. 0.9.1-rc.1 is out, so the release freeze that held reviews is over — but it left a large queue of open pull requests behind it, and we are reading through them oldest-first. The background is in discussion #1144.

What that means for this PR, concretely:

  • It will not be closed for inactivity. No stale bot touches pull requests here.
  • It may still sit a while before a human reads it. That is on us, not on you.
  • Older PRs are read first, so a recent one is not being skipped — it is behind a queue.

Things that will genuinely speed it up whenever review does happen:

  • Keep it rebased on main — the tree is moving quickly right now, and a conflicting branch cannot be reviewed as the diff you intended.
  • Get CI green, or say which failures you believe are pre-existing.
  • Keep the change to one claim. Bundled features and refactors get split before they get merged, which costs you a round trip.
  • Every commit needs a sign-off (git commit -s) — CI enforces DCO.

If this fixes a bug, a reproduction we can run is worth more than a description of the symptom.

Thanks for contributing, and sorry in advance for the wait.

@DeusData DeusData added bug Something isn't working editor/integration Editor compatibility and CLI integration ux/behavior Display bugs, docs, adoption UX priority/high Needs near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker. labels Sep 5, 2026
@DeusData

DeusData commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Thanks — this is right, and I verified it the hard way: with a fake hermes on PATH and a fresh HOME without .hermes/, main's uninstall really does stop with the Hermes error and keeps the binary; your test is red against main's config_yaml_edit.c and green with your change; the merged tree passes config_yaml_edit, cli, activation_transaction, daemon_bootstrap and daemon_frontend (411 cases) plus the end-to-end run. The JSON and TOML removers already behave this way, so this aligns YAML with them. One thing keeps CI red: both Windows shards fail to COMPILE — tests/test_config_yaml_edit.c:1851 calls lstat, and the new TEST body sits outside the #ifndef _WIN32 block while its RUN_TEST is inside one. Wrap the test definition in the same #ifndef _WIN32 / #endif (or drop the lstat assertion), keep the sign-off, and I'll merge on green.

…no longer refuses

`uninstall` failed with rc 1 on any macOS where Hermes is installed:
Hermes is detected by its binary on PATH, not by its home, so a HOME
without `.hermes/` (every test HOME, and a fresh user's) reached the
Hermes uninstall ops with `~/.hermes/config.yaml` absent. The JSON
removers already treat a missing config as "nothing to remove"; the YAML
removers acquired the lock first, and the lock directory is created
beside the target — with the parent directory absent that failed, the
adapter recorded

  error: agent_config agent=Hermes op=pre_llm_hook_uninstall ... (target: does not exist or cannot be inspected)
  error: agent_config agent=Hermes op=mcp_uninstall ...

and uninstall refused to remove the executable and the indexes. This is
what made cli_uninstall_quiesces_active_cohort_before_removing_binary_and_index
fail on such a machine (7837 passed, 1 failed on a pristine main).

All four YAML removers short-circuit on a genuinely absent path and
create nothing: lstat + ENOENT on POSIX, and CreateFileW with
FILE_FLAG_OPEN_REPARSE_POINT on Windows, mirroring toml_read_file.
Opening the reparse point rather than following it keeps a dangling
symlink out of the short-circuit on both platforms, so it still reaches
the reader and its byte-identical rejection.

The regression test covers the four removers and runs on every platform:
it asserts "nothing was created" through cbm_path_info_utf8 rather than
lstat, so the Windows branch is exercised rather than compiled out.

Signed-off-by: David Gil <dgilperez@gmail.com>
@dgilperez
dgilperez force-pushed the fix/yaml-remove-absent-config branch from e0f37d7 to 3007dbf Compare September 5, 2026 21:45
@dgilperez

Copy link
Copy Markdown
Contributor Author

Thanks for verifying it that thoroughly - fixed both shards.

The test now checks "nothing was created" with cbm_path_info_utf8 instead of lstat, and its RUN_TEST moves out of the #ifndef _WIN32 block, so it runs on Windows too. Wrapping the test would have left the Windows branch untested, and that branch had a bug: GetFileAttributesW follows symlinks, so a dangling symlink counted as absent and skipped the reader, unlike the POSIX branch. It now uses CreateFileW with FILE_FLAG_OPEN_REPARSE_POINT, mirroring toml_read_file.

@DeusData
DeusData merged commit a6aea0b into DeusData:main Sep 6, 2026
34 checks passed
@DeusData

DeusData commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Merged as a6aea0b — thank you. Uninstall no longer trips over a YAML config that was never written, the test pins it, and the Windows probe correction (open the reparse point instead of following it) was the right call on top of the compile fix I asked for. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working editor/integration Editor compatibility and CLI integration priority/high Needs near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker. ux/behavior Display bugs, docs, adoption UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants