Repository navigation
fix(matrix): keep bot discovery off the Gateway thread - #152122
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 8:59 AM ET / 12:59 UTC (Revision 8). ClawSweeper reviewWhat this changesMoves Matrix startup’s bot-account discovery onto the existing SQLite worker while preserving credential matching, environment selection, and cancellation. Merge readiness✅ Ready for maintainer review The fix remains necessary: current main and the latest release still perform synchronous credential reads during bot discovery. No actionable introduced defect was found; the patch is suitable for the normal review and CI gates. Priority: P2 Review scores
Verification
How this fits togetherMatrix startup identifies other configured bot accounts from configuration and stored credentials. Those identities feed inbound message filtering and bot-loop protection before the client begins processing messages. flowchart TD
A[Account configuration and environment] --> B[Prepare account facts]
B --> C[Read credentials through SQLite worker]
C --> D[Match bot identities]
D --> E{Startup cancelled?}
E -->|Yes| F[Return after active read settles]
E -->|No| G[Start client and install message filters]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +37, Tests +301, Docs +4. Total +342 across 8 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep bot discovery on the existing credential worker while retaining one credential observation per identity and settling admitted reads before cancelled startup returns. Do we have a high-confidence way to reproduce the issue? Yes, from source: current-main bot discovery calls synchronous credential lookups during monitor startup. The added monitor test targets that boundary, but no tests were executed in this read-only review. Is this the best way to solve the issue? Yes. Reusing the existing async credential loader and shared readiness rules is a narrow repair that preserves public APIs and stored-data formats. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cf8c5724cbca. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
Prepare account authentication against native environment lookups before asynchronous reads. Capture the resolved credential state directory and supervisor setting once through existing host APIs, preserving Windows lookup behavior and the supported host floor without expanding the SDK.
Preserve the qualified worker-backed bot discovery and native environment lookup while retaining current history-limit normalization, credential presence coverage, and worker-test registrations. The eight feature deltas are unchanged from the reviewed public head. Validation: 88 focused cases, six Doctor cases, full changed-file checks, and independent P2 review passed on the reconciled source. Exact-head hosted CI and native preparation remain pending.
Merge main 9a472a9 so the Matrix candidate itself contains the retained-agent Doctor fix e99e75e. The reopened CI run used an older merge with the pre-fix Doctor owner, despite the corrected eight-file PR projection. All eight Matrix feature postimages are unchanged. Fresh 88-case runtime proof, full changed-file checks, six Doctor contract cases and independent P2 review pass. The unchanged Doctor owner/test hashes match the retained main proof. Exact-head hosted CI remains required before native preparation.
Merge current main to include the canonical tsx CLI shim declaration repair required by the hosted test merge. Preserve all eight Matrix feature deltas and newer main changes; no duplicate declaration or Doctor repair.
|
Merged via squash.
|
Related: #151994
What Problem This Solves
Matrix monitor startup reads other bot accounts' stored credentials through SQLite on the Gateway thread. Moving those reads to the worker also needs to preserve Windows environment lookup and keep later reads on the state directory selected when discovery began.
User Impact
Bot discovery awaits the existing SQLite worker, preserves bot filtering decisions, and settles an active read before cancelled startup returns. It does not start another sibling read, acquire a client, or install handlers after cancellation. No configuration, schema, or minimum host-version change is required.
Why This Change Was Made
The monitor prepares account authentication facts against the original environment before storage yields. Matrix's credential owner captures the resolved state directory and supervisor setting once, then the existing loader reads selected account keys serially. This preserves Windows case-insensitive lookup without introducing a new host SDK export; the runtime APIs used here already exist in the supported 2026.9.4 host.
Each identity uses one credential observation. Default-account selection, environment precedence, token and homeserver matching, self-exclusion, and revocation handling remain intact. Public account-readiness and package auth-presence probes retain their synchronous contracts.
Evidence
Current head
374d8137ceeccac46a8afa9d6d7b2cc88d709c4fcarries the reviewed Matrix change onto main96482375236d829b6e39dddc61467e7f8d5f1bce. All seven code and worker-catalog postimages remain byte-identical to the qualified9a139984bdf4be91d00e23f0e0f1b666d7dc3551source. The storage documentation cleanly combines current main additions, and all eight ordered feature deltas remain exact.Fresh current-source validation passed 88 focused account, credential and monitor cases across five files, including main's additional persisted-auth case. Real monitor ingress recorded zero calls to all six measured host SQLite methods for matching credentials, changed tokens, changed homeservers and revoked credentials. Cancellation joins the active read before startup returns and starts no later sibling read, client or handler. Six Doctor declaration/closure cases also passed. The full changed-file gate passed, including production/test typechecks, formatting, typed lint, plugin boundaries, storage guards, zero dead exports and zero runtime import cycles. Fresh independent review of the complete staged change is clean through P2; the reviewers did not execute tests.
The original real-SQLite regression still provides the causal failure: the old collector lost both expected bot identities under case-insensitive environment lookup. The qualified repair passes that case, both POSIX controls, and environment changes between reads without redirecting the credential source. Windows environment behavior is modeled on macOS; no native Windows execution, external Matrix account or operator Gateway is claimed. The supported 2026.9.4 runtime APIs remain unchanged; no new SDK export or host-version floor is introduced.
The prior exact-head CI run 35688151973 failed shared catalog cleanup and Slack lint checks; its logs are retained. This source integration carries current main's canonical repairs. Fresh exact-head hosted CI and native preparation remain required before landing. No new distributable-build claim is attached to this carry.
The earlier Doctor failure was repaired on main by
e99e75e2e60a48875d63f6d84a3db4882ca00252, already retained in this ancestry. The subsequent exact-head run 35715269599 failed UI typechecking in test merge6715f31529685e4d4382c168391b44eb3409f755: newer main imported the tooling shim without its declaration file. This carry includes main's canonical declaration fix80b9608a25e191a17e1466d750c2f76a38a38507; current-source UI typechecking passes. No duplicate Doctor or declaration implementation was added. Fresh exact-head CI and native preparation remain pending.