Skip to content

fix(tests): repair stale test suite failures and a broken MCP import - #84

Merged
dizhaky merged 3 commits into
mainfrom
claude/hermes-errors-xh2x9x
Jul 17, 2026
Merged

fix(tests): repair stale test suite failures and a broken MCP import#84
dizhaky merged 3 commits into
mainfrom
claude/hermes-errors-xh2x9x

Conversation

@dizhaky

@dizhaky dizhaky commented Jul 9, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

Repairs a batch of pre-existing, unrelated test failures found during a general "fix Hermes errors / find more things to clean up" pass, plus one real production bug.

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding or improving test coverage)

Changes Made

  • tools/mcp_tool.py: _interpolate_env_vars() unconditionally imported agent.secret_scope, a module that doesn't exist anywhere in the repo — every call (i.e. every MCP config load) crashed with ImportError. Restored the documented os.environ fallback for when the module is unavailable, matching the function's own docstring contract.
  • acp_registry/agent.json: version was stale (0.14.0) vs pyproject.toml (0.15.0); scripts/release.py already keeps these in lockstep on a proper version bump, this one drifted from a manual edit.
  • tests/hermes_cli/test_gateway.py, test_gateway_service.py: updated mocks/assertions for legitimate recent features the tests hadn't caught up to — the non_interactive systemd_install() param, the temp-HERMES_HOME service-write guard, the D-Bus reachability preflight check, the HERMES_HOME-anchored WorkingDirectory (replacing the old rot-prone source-checkout path — see _stable_service_working_dir()'s docstring), the launchd self-preservation PID lookup, and an _HERMES_GATEWAY env var leaking across tests via a module-level import side effect in gateway/run.py.
  • tests/test_hermes_state.py: get_messages_as_conversation() now includes a timestamp key by design; and the declarative _reconcile_columns() schema-sync pattern (Beets/sqlite-utils style) intentionally supersedes the old version-gated "don't auto-add columns" migration test — updated the test to assert the new, documented behavior instead.
  • tests/hermes_cli/test_setup.py: setup_gateway() now drives platform selection through an interactive checkbox picker (prompt_checklist) instead of per-platform prompt_yes_no calls.

Also documents (.plans/missing-platform-plugin-shims.md, not fixed — explicit decision, not in scope for this PR) that telegram/slack/matrix/whatsapp/email/sms/wecom/feishu are missing from the hermes setup gateway picker: their plugin-registration shims (plugins/platforms/<name>/adapter.py) were never created after a refactor removed the old inline _PLATFORMS definitions, even though the underlying gateway/platforms/*.py adapters are all still present and functional (so live message routing is unaffected — only the setup wizard's picker/status display for these 8 platforms).

How to Test

  1. TZ=UTC LANG=C.UTF-8 PYTHONHASHSEED=0 python3 -m pytest tests/hermes_cli/test_gateway.py tests/hermes_cli/test_mcp_config.py tests/hermes_cli/test_gateway_service.py tests/test_hermes_state.py tests/acp/test_registry_manifest.py tests/hermes_cli/test_setup.py -q — all pass (previously 37 failing across these files)
  2. ruff check on all changed files — all checks passed

Checklist

Code

  • My commit messages follow Conventional Commits (fix(scope):)
  • My PR contains only changes related to this fix (no unrelated commits)
  • I've run the relevant test suites and all tests pass
  • I've added tests for my changes — N/A, this PR repairs existing test coverage rather than adding new behavior

Documentation & Housekeeping

  • I've documented the missing-platform-plugins finding in .plans/ per repo convention (see config-integrity-watchdog.md for precedent) rather than silently fixing or ignoring it
  • Cross-platform impact — N/A, test-only changes plus a defensive import fallback

Generated by Claude Code

Fixes a batch of pre-existing, unrelated test failures found while
doing a general repair/cleanup pass:

- tools/mcp_tool.py: `agent.secret_scope` doesn't exist anywhere in the
  repo, so every `_interpolate_env_vars()` call (i.e. every MCP config
  load) crashed with ImportError. Restore the documented os.environ
  fallback for when the module is unavailable.
- acp_registry/agent.json: version was stale (0.14.0) vs pyproject.toml
  (0.15.0).
- tests/hermes_cli/test_gateway.py, test_gateway_service.py: update
  mocks/assertions for legitimate features the tests hadn't caught up
  to yet -- the `non_interactive` systemd_install() param, the
  temp-HERMES_HOME service-write guard, the D-Bus reachability
  preflight check, the HERMES_HOME-anchored WorkingDirectory (replacing
  the old rot-prone source-checkout path), the launchd self-preservation
  PID lookup, and an `_HERMES_GATEWAY` env var leaking across tests via
  a module-level import side effect in gateway/run.py.
- tests/test_hermes_state.py: get_messages_as_conversation() now
  includes a `timestamp` key by design; and the declarative
  _reconcile_columns() schema-sync pattern intentionally supersedes the
  old version-gated "don't auto-add columns" migration test.
- tests/hermes_cli/test_setup.py: setup_gateway() now drives platform
  selection through an interactive checkbox picker (prompt_checklist)
  instead of per-platform prompt_yes_no calls.

Also documents (.plans/missing-platform-plugin-shims.md, not fixed per
explicit decision) that telegram/slack/matrix/whatsapp/email/sms/wecom/
feishu are missing from the `hermes setup gateway` picker -- their
plugin-registration shims were never created after a refactor removed
the old inline _PLATFORMS definitions, even though the underlying
gateway/platforms/*.py adapters are all still present and functional.
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

🔎 Lint report: claude/hermes-errors-xh2x9x vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8615 on HEAD, 8615 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4587 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

claude added 2 commits July 9, 2026 22:48
- test_gateway_linger.py::test_systemd_install_calls_linger_helper:
  same temp-HERMES_HOME write guard gap already fixed for its sibling
  tests in test_gateway_service.py -- this one just wasn't caught in
  the first pass.
- test_kanban_db.py::test_connect_falls_back_to_delete_on_locking_protocol:
  the kanban_home fixture's kb.init_db() already persists
  journal_mode=wal onto the DB file (a SQLite header property, not
  per-connection state), so apply_wal_with_fallback()'s read-only probe
  saw "wal" already set and returned early -- the mocked
  PRAGMA journal_mode=WAL failure this test exercises never actually
  ran. Delete the pre-existing db/-wal/-shm files so the mocked
  connect() creates a genuinely fresh one, and clear the
  (db_label -> already warned) dedup cache since it's keyed only on
  filename, not full path.
…e tests

- hermes_state.py: the same "chore: sync working changes" commit that
  added the timestamp field to conversation messages also dropped
  "disk i/o error" from _WAL_INCOMPAT_MARKERS -- a real regression, not
  test staleness. Restored it so flaky-network-FS disk I/O errors during
  WAL setup still trigger the DELETE-mode fallback instead of propagating.
- tests/acp/test_session.py: two more tests hit by the same
  get_messages_as_conversation() timestamp addition already handled in
  tests/test_hermes_state.py.
- tests/hermes_cli/test_auth_commands.py: _format_exhausted_status() now
  unconditionally reads entry.extra (per-model exhaustion tracking), but
  the test's hand-rolled _Entry mock didn't define it.
- tests/tools/test_mcp_tool.py: test_default_timeout asserted both the
  _DEFAULT_TOOL_TIMEOUT constant AND a stale hardcoded 120, left over
  from before the constant was bumped to 300.

Also updates .plans/missing-platform-plugin-shims.md with two more
casualties of the missing plugin shims found while triaging CI:
tests/hermes_cli/test_setup_openclaw_migration.py (Telegram/WhatsApp
missing from the config summary) and tests/gateway/test_setup_feishu.py
(the interactive_setup function itself was removed, not just picker
metadata -- all 14 tests fail on import).
@dizhaky
dizhaky marked this pull request as ready for review July 17, 2026 10:38
@dizhaky
dizhaky merged commit 4518726 into main Jul 17, 2026
37 of 46 checks passed
@dizhaky
dizhaky deleted the claude/hermes-errors-xh2x9x branch July 17, 2026 10:38
dizhaky added a commit that referenced this pull request Jul 17, 2026
…restoration

Main independently landed most of this branch's repairs while it was in
flight (platform picker restore #89, bespoke setup dispatch #94, stale
test repairs #84, agent.json bump). Resolution takes main's side
everywhere; the only remaining delta is restoring _setup_feishu (deleted
by the incomplete plugin-migration rewrite e39b468 — the
plugins/platforms/feishu/ dir it supposedly moved to never existed) and
its _builtin_setup_fn mapping. tests/gateway/test_setup_feishu.py is the
last red file on main's CI (run 29596109244).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants