# PR#92: MatrixSource at a Mutation-CRAP of at Most 15 Version: patch > **WARNING:** This document describes only the change applied in this PR. > It may already be outdated once the next PR is merged. > Historic PR documentation is not maintained along with new PRs; treat it as a snapshot. ## Related Links - [werkregie PR#91](https://git.javagil.de/mi/werkregie/pulls/91), `matrix react`, which stops the relay for each reaction. ## Problem `matrix react` needs `sync.lock`, which the running relay holds; an agent stops the relay for about 50 s per reaction. The relay is to send the reaction itself, which changes `sources/MatrixSource.kt`. A branch fails on each method above a Mutation-CRAP of 15 in a class it changes; 9 of its methods are above, `MatrixSource.message` at 812 on `main`, the highest of the nightly ratchet: a complexity of 28 without a killed mutant, since only a homeserver could drive it. ## Non-Goals - No change of behaviour. - No reaction through the relay yet; that is the follow-up PR. ## Specification None; the behaviour stays the same. ## Solution The decisions move out of `MatrixSource` into functions that tests reach without a client; what stays in `MatrixSource` is the glue to Trixnity, at a complexity of at most 3, so that it stays at most 12 without a killed mutant (3² + 3). - `MatrixEvents`, new: what `MatrixSource` takes from Trixnity, tested with Trixnity's own data classes: `incoming` decides which event is a message of someone else, `message` builds the `MatrixMessage` from event, room and members, `receiptTime` takes the newest read receipt, `baseUrl` and `isUrl` the homeserver, `crossSigned` the trust level of the device. - `MatrixMessages`, free of the client library: `unread`, `roomOf`, `readIn`, `encrypted` and `decrypted`. - `MatrixSource`: `decryptAgain` hands each row to `decrypted`; `login` and `verify` take the lock by `locked`, which the follow-up PR also uses; `verifyWith` takes its checks from `checkVerified`, `verifyBy`, `byRecoveryKey` and `byPassphrase`; `syncError` names the cause of an ended sync. - New tests in [MatrixEventsTest](../../dashboard/src/test/kotlin/de/hoennig/werkregie/dashboard/sources/MatrixEventsTest.kt), [MatrixMessagesTest](../../dashboard/src/test/kotlin/de/hoennig/werkregie/dashboard/sources/MatrixMessagesTest.kt) and [MatrixSourceTest](../../dashboard/src/test/kotlin/de/hoennig/werkregie/dashboard/sources/MatrixSourceTest.kt). - `pitestPartial mutationCrapCheck` against main: the highest Mutation-CRAP of `MatrixSource` is 12, of `MatrixEvents` 11 (`incoming`, all mutants killed). The ratchet of the nightly run falls from 812 to 272, now `CodexSource.fetch`; the change of `dashboard/build.gradle.kts` makes the check stricter, not weaker. ## Open Questions None. ## Follow-up PRs - [werkregie PR#93](https://git.javagil.de/mi/werkregie/pulls/93): `matrix react` no longer needs a stop of the relay. The relay, which holds `sync.lock`, sends the reaction with its own Matrix client, on request through a local socket. That PR changes `MatrixSource`, so it needs the limit of 15 that this PR reaches.