fix(matrix): supervise sync consumer lifecycle - #96022
Draft
jerryhjones wants to merge 1 commit into
Draft
Conversation
Author
Agent exact-head audit: no blockers foundReviewed draft PR #96022 at exact head This is a durable agent audit record, not a formal GitHub or maintainer approval. Lens
Checks rerun
Follow-up completed during auditThe body phrase that GitHub parsed as an auto-closing keyword was rewritten. Live Residual risk
Verdict: ready for Jerry's observation in draft state; not ready to merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Matrix currently owns
_sync_taskas fire-and-forget state. Initial sync failure can still be followed by a connected claim, and a later sync-consumer exit can leave the adapter and gateway reporting healthy while inbound Matrix processing is dead.This PR gives the consumer an explicit startup handoff, clears connected state on every teardown/failure path, retains fatal-notification carrier tasks, and makes readiness reflect current unhealthy platform state. It deliberately does not reimplement Matrix authentication classification; #80532 remains the classifier dependency.
Related Issue
Related to #80336.
This PR addresses only the sync-task lifecycle/readiness portion of #80336; #80532 owns structured auth-error classification, so the issue should remain open until both parts are resolved.
Type of Change
Changes Made
plugins/platforms/matrix/adapter.py: fail initial sync cleanly; serialize same-instance connect/disconnect; use a generation-owned two-phase startup handoff; supervise unexpected consumer exit; retain and generation-gate fatal notifications; and transfer task/client/crypto teardown to a cancellation-safe cleanup owner.gateway/readiness.py: degrade only for current unhealthy configured platform records while preserving intentional disabled and legacy record behavior.tests/gateway/test_matrix.py,tests/gateway/test_matrix_sync_lifecycle.py,tests/gateway/test_readiness.py: cover startup failure, reconnect failure, unexpected task exit, cancellation, notification ownership, stale callbacks, cleanup, and readiness identity/state semantics.How to Test
HERMES_PYTHON=/Users/jj/.hermes/venvs/hermes-matrix-dev/bin/python \ scripts/run_tests.sh tests/gateway/test_matrix*.py tests/gateway/test_readiness.py -qupstream/main@791e2ae3: 226 passed, 1 failed, 1 skipped. The lone failure is the pre-existingtest_collect_runtime_readiness_reports_healthy_local_runtimedisk-capacity assertion; unchanged current main reproduces it because this host reportsdisk.used_percent=90.0. Excluding that baseline case, the three changed suites pass 154/154. On the preceding base, the same diff recorded 227 passed, 0 failed, 1 skipped; the 19-test lifecycle file also passed 10 consecutive runs (190/190).upstream/main@79b8703d+ fix(matrix): classify sync auth failures by status and errcode, not substring (salvage #66878) #80532 classifier stack, same command: 252 passed, 0 failed, 1 skipped.upstream/main@79b8703dwhile retaining the new tests: initial-sync false-connected, unexpected consumer exit, connect cancellation, connect/disconnect serialization, in-flight stale notification, cancellation-safe cleanup (crypto and session cases), immediate and cancelled constructor cleanup, cancellation during crypto database start, and stale readiness provenance all failed as intended (11 failed).ruff check .passed; Windows-footgun scan passed across 1,019 files;py_compileandgit diff --checkpassed. Advisorytydiff reported no new production-code diagnostic (new entries are test-mock/module-resolution diagnostics plus a tool panic). A full canonical run on the preceding baseupstream/main@790e1eb6recorded 124 failures across 39 unrelated files and no Matrix/readiness failure, so the full-suite checklist remains honestly unchecked and draft CI is the next broad gate.Checklist
Code
pytest tests/ -qand all tests passscripts/run_tests.shDocumentation & Housekeeping
cli-config.yaml.example— N/ACONTRIBUTING.md/AGENTS.md— N/ARisks and exclusions
Screenshots / Logs
N/A — lifecycle behavior is covered by automated regression tests.