Repository navigation
feat(channels): add Matrix and LINE join introductions - #131128
Conversation
Introduce on admitted bot joins using the existing sealed no-tools turn and durable room dedupe. Matrix uses room metadata and readable history; LINE uses group names and explicitly unavailable history. Mark Matrix bridge membership provenance without changing existing event delivery, invite handling, or auto-join. Exclude startup snapshots and already-joined profile updates, including startup connection recovery. Simplify snapshot budget accounting while preserving prompt bytes, metadata order, and oldest-first message dropping. Add channel config, docs, and regression coverage.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 3:09 PM ET / 19:09 UTC. ClawSweeper reviewWhat this changesAdds configurable, default-on group-join introductions for Matrix and LINE, including Matrix join-versus-startup provenance, docs, and regression tests. Merge readinessKeep open for maintainer review: the introduced Matrix and LINE flows are coherent and have focused coverage, but this default-on feature adds configuration surface and its external SDK event contract was not independently inspectable locally. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherMatrix and LINE plugins receive native membership events and pass eligible group-room joins to the shared introduction owner. That owner builds bounded untrusted context, runs an isolated no-tools turn, sends the introduction, and deduplicates it durably. flowchart LR
A[Native bot join event] --> B[Matrix or LINE plugin]
B --> C[Room admission and context]
C --> D[Shared introduction owner]
D --> E[Isolated no-tools agent turn]
E --> F[Channel delivery]
D --> G[Durable room deduplication]
Decision needed
Why: This is a maintainer-authored product and configuration decision; source review cannot establish the intended default or external-provider behavior conclusively. Before merge
Agent review detailsSecurityNone. PR surfaceSource +176, Tests +547, Docs +46, Generated 0. Total +769 across 25 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Confirm the default-on configuration direction, then obtain redacted real Matrix and LINE membership-to-delivery evidence when provider access is available. Do we have a high-confidence way to reproduce the issue? Not applicable to an existing-bug report. The introduced paths have focused harness coverage, but no real Matrix or LINE join was driven. Is this the best way to solve the issue? Unclear: the Matrix producer-side provenance is the right ownership boundary, but provider SDK behavior and the intended default require remaining maintainer evidence or direction. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 19be0f6dc094. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Following up on the review note that the Matrix SDK ordering and event-identity assumption could not be directly verified. I checked it against the installed What I verified. What remains unverified. Whether that instance is always identical to the one delivered to the raw timeline listener across every sync path. Why this is acceptable to land. The failure direction is safe by construction. The startup replay path ( Follow-up worth doing: a live Matrix run against a real homeserver would settle the identity question and is the only thing that can. There are no Matrix credentials on the machine this was built on, so it could not be done here. |
|
Merged via squash.
|
Introduce on admitted bot joins using the existing sealed no-tools turn and durable room dedupe. Matrix uses room metadata and readable history; LINE uses group names and explicitly unavailable history. Mark Matrix bridge membership provenance without changing existing event delivery, invite handling, or auto-join. Exclude startup snapshots and already-joined profile updates, including startup connection recovery. Simplify snapshot budget accounting while preserving prompt bytes, metadata order, and oldest-first message dropping. Add channel config, docs, and regression coverage.
What Problem This Solves
Group join introductions shipped in #130103 for Slack, Discord, and Telegram. Matrix and LINE were left out even though both already receive a bot-join signal and did nothing with it but write a log line, so operators on those channels still get a bot that appears in a room and says nothing.
Extending it surfaced a real defect in the Matrix bridge that would have made a naive integration actively harmful.
Why This Change Was Made
The Matrix bridge could not distinguish a join from a restart.
emitMembershipForRoomsynthesizes anm.room.memberevent withorigin_server_ts: Date.now()andunsigned: { age: 0 }, andemitOutstandingInviteEventscalls it for every room fromclient.getRooms()at startup. Because the producer fabricates a fresh timestamp, the freshness guard that protects Discord'sGUILD_CREATEhas no analogue here, and the durable dedupe cannot help either since pre-existing rooms hold no claims yet. Wiringroom.joinstraight through would have introduced the bot into every Matrix room it was already in, on the first restart after upgrade.Per the Repair Doctrine that belongs at the producer, not compensated downstream, so the bridge now carries explicit
membershipProvenanceoftransition,update, orsnapshot. It is derived from the SDK's ownRoomEvent.MyMembershipsignal (which suppliespreviousMembership), gated on initial sync completion, and handles theERROR → CATCHUPrecovery path where catchup can precede the first successful sync. The change is additive: event names, ordering, delivery, timestamps, invite handling, and auto-join behavior are untouched, and every existing Matrix assertion still passes unchanged, including "replays outstanding invite rooms at startup" and "does not auto-join invites by default".Only an absent-to-join transition introduces. A self-membership update that stays
join— a display-name or avatar change — does not, which was the other false positive in the raw-event path.User Impact
Matrix and LINE now post one grounded introduction when the bot joins a group room, on by default, with the same
joinIntroopt-out at channel and account scope as the existing three.What each can honestly ground on differs, and the code says so rather than pretending:
historyUnavailable: true, because the Messaging API exposes no prior-message history. Multi-person rooms have no name or topic at all. This matches the honest pattern Telegram already uses. LINE's allowlist authorizes human senders, so a bot join is admitted on conversation policy and room enabled state rather than inventing a sender.Everything else is unchanged from #130103: the sealed no-tools turn, untrusted-content wrapping, required fail-closed
roomAllowed, durable once-per-room dedupe, DM exclusion, and the closed outcome union.Also folds in a bounded cleanup of
formatChannelJoinRoomSnapshot, which previously accumulated a string and then discarded it to rebuild from scratch whenever any messages survived, and reversed the message list twice to end where it started. Behavior is identical — verified across 18,160 byte-for-byte comparisons — and it is net −6 lines.Evidence
The most important test is
never introduces into an already-joined room during startup, including recovery=%s— parameterized over the recovery paths, it is the exact upgrade case that would otherwise spam every room. Alongside it: introduction on a genuine transition with the account route and oldest-first history, no introduction for profile changes or other members' joins, correct handling of a new-room lifecycle snapshot followed by a real transition with duplicate raw delivery ignored, and direct-room exclusion.Autoreview reported no actionable findings.
Proof gap, stated plainly: this was verified through the Matrix SDK and LINE webhook harnesses, not a live channel send. There are no Matrix or LINE credentials on this machine, so a real join could not be driven locally. The Slack/Discord/Telegram paths from #130103 are unaffected by this change.
LOC: production +218/−42 (net +176), tests +547, docs +52/−6, generated net 0.
Docs: channels, matrix, line, config-channels.