Skip to content

fix(gateway): start Matrix mautrix syncer#37807

Closed
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/matrix-mautrix-syncer
Closed

fix(gateway): start Matrix mautrix syncer#37807
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/matrix-mautrix-syncer

Conversation

@konsisumer

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the Matrix gateway receive path by starting mautrix's own syncer after handlers are registered. Direct client.sync() calls return sync payloads but do not drive add_event_handler(...) callbacks, which left the adapter connected and able to send while never responding to incoming Matrix messages.

Related Issue

Fixes #7914

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • gateway/platforms/matrix.py: start client.start(None) after auth, handler registration, initial sync, and initial key sharing; stop the mautrix syncer during disconnect; keep the Hermes background task for joined-room/DM/key-share maintenance instead of direct event-dispatch sync polling.
  • tests/gateway/test_matrix.py: update the fake mautrix client, replace stale direct-sync-loop expectations, and add lifecycle coverage for starting/stopping the mautrix syncer.

How to Test

  1. python -m pytest tests/gateway/test_matrix.py -q -x --timeout=60152 passed.
  2. python -m pytest tests/ -q -x --timeout=60 → stopped at tests/acp/test_approval_isolation.py::TestAcpExecAskGate::test_interactive_env_var_routes_to_callback; this ACP approval-path failure is outside the Matrix gateway files changed by this PR.
  3. python -m ruff check gateway/platforms/matrix.py tests/gateway/test_matrix.py → passed.
  4. python scripts/check-windows-footguns.py gateway/platforms/matrix.py tests/gateway/test_matrix.py → passed.
  5. git diff --check → passed.
  6. python -m ruff format --check gateway/platforms/matrix.py tests/gateway/test_matrix.py → reported pre-existing whole-file formatting churn in these Matrix files, so no broad formatter rewrite was applied.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS on darwin-arm64

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

N/A.

@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/gateway Gateway runner, session dispatch, delivery platform/matrix Matrix adapter (E2EE) labels Jun 3, 2026
@konsisumer

Copy link
Copy Markdown
Contributor Author

Closing this. CI here is red from a self-introduced regression — the _sync_loop rewrite broke tests/gateway/test_ws_auth_retry.py (not updated to the new loop contract) and drops the permanent-auth-error (M_UNKNOWN_TOKEN / 401 / 403) short-circuit those tests guard. Rather than push a rushed fix, deferring #7914 to @nepenth's #18505, which restores reliable inbound dispatch for the same root. The client.start(None) direction here was correct; reopen if #18505 stalls.

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

Labels

comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround platform/matrix Matrix adapter (E2EE) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Matrix gateway can send messages but doesn't receive/respond to incoming messages

2 participants