fix(plugin-discord): implement message-triage adapter so channel sweeps work [core-brain] - #12935
Conversation
…ps work
the core DiscordMessageAdapter stub threw NotYetImplementedError from
listMessagesImpl whenever the discord service was registered, so
MESSAGE op=triage/list_inbox/respond and the app inbox could not list
or batch-triage discord channel messages ('go thru the chats and
respond' died with 'NotYetImplemented: discord adapter listMessagesImpl').
- add DiscordTriageAdapter in plugin-discord bridging the triage
contract onto the connector's existing plumbing:
fetchConnectorMessages (REST channel fetch -> Memory) for list,
listConnectorRooms for channel discovery, handleSendMessage for
draft replies; registered at plugin init, replacing the core stub
- isolate per-source failures in TriageService.triage()/search() so
one broken adapter degrades with a warning instead of aborting the
cross-connector sweep; rethrow only when failures leave zero results
- unit tests for the adapter mapping/sweep/draft flow and the
isolation semantics
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Focused local validation in an isolated Passed:
Broader checks with existing unrelated/baseline failures:
Implementation read-through: the Discord adapter maps existing Discord connector |
lalalune
left a comment
There was a problem hiding this comment.
Blocking on the PR's own evidence gate before merge.
Code-level review so far looks coherent: the adapter bridges through fetchConnectorMessages / listConnectorRooms / handleSendMessage, channel-id fetches are supported by resolveConnectorTextChannel, and plugin init registers the adapter. Local validation passed:
git diff --check origin/develop...pr-12935bunx vitest run packages/core/src/features/messaging/triage/__tests__/triage-service-isolation.test.ts plugins/plugin-discord/__tests__/triage-adapter.test.ts --pool forks --testTimeout 10000(2 files, 21 tests)
But the PR body marks the real-LLM/live Discord trajectory as PENDING and says not to merge on unit tests alone. Please attach the live Discord sweep trajectory and post-fix backend logs described in the evidence matrix, then I can re-review/approve.
|
Local validation from Codex review:
I am not merging this yet because the PR evidence table still marks the real Discord sweep trajectory/backend-log evidence as PENDING - required before merge. The code path looks coherent, but repo evidence rules require that live connector proof for this behavior change. |
|
Reviewed (incl. the core |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
fix(plugin-discord): implement message-triage adapter so channel sweeps work
Root cause
plugins/plugin-discord/triage-adapter.tsregistered aDiscordMessageAdapterinto the shared TriageService with every capability flag off andlistMessagesImplinherited fromBaseMessageAdapter— a single throw-on-use stub. The moment the discord service was registered, any cross-connector sweep that touched thediscordsource (MESSAGE op=triage/op=list_inbox/op=respond, plugin-inbox) died with:Worse,
TriageService.triage()awaited adapters sequentially with no isolation, so the discord stub throwing aborted the whole sweep — email/signal results were lost too. "go thru the chats and respond" / "catch up on cozy devs" could not work at all.Fix
plugins/plugin-discord/triage-adapter.ts— implementDiscordTriageAdapterby bridging the triage contract onto the connector's existing, already-tested plumbing:listMessagesImpl→DiscordService.fetchConnectorMessages(discord.js REST channel fetch → coreMemory), then map memories toMessageRefs (channel/guild/thread ids preserved inraw, mention detection, in-memory filter reuse)listRooms→listConnectorRoomsfor channel discovery across guildsdraftReply/send→handleSendMessage, so triage replies go out through the same send path (and send-policy gates) as normal connector trafficpackages/core/.../triage/triage-service.ts— per-source failure isolation intriage()andsearch(): one broken adapter degrades to a warning + zero results for that source instead of aborting the cross-connector sweep; rethrows only when failures leave zero results overall (so a fully-broken pipeline still fails loud, per the error-policy doctrine — no healthy-empty fabrication).Tests
plugins/plugin-discord/__tests__/triage-adapter.test.ts— 15 tests: memory→ref mapping (ids, threads, mentions, attachments), channel sweep, room listing, draft/send flow, unavailable-service degrade, error pathspackages/core/.../triage/__tests__/triage-service-isolation.test.ts— 7 tests: healthy+broken adapter mix keeps healthy results, warning surfaced, all-broken rethrows, search parityorigin/develop(f317d1c): core triage lane 22/22, plugin-discord vitest 213 pass (the 4 remaining fails are pre-existingoutbound-attachment/messageConnector.outbound-mediafetch-stub issues in files this PR does not touch), plugin-signal triage adapter 3/3, plugin-inbox 23/23,tsgotypecheck green in both packagesEvidence
MESSAGE op=triage→ DiscordTriageAdapter REST fetch → per-channel refs → reply drafts) will be attached as behavioral evidence; do not merge on unit tests alone.NotYetImplemented: discord adapter listMessagesImplkilling the sweep; post-fix[MessagingTriage:discord]log lines will accompany the trajectory aboveNotes
developat rebase time; no overlap with the mute-hardening work in fix: make channel/server mute enforceable end to end (mute hardening) #12892 (that gates ingestion indiscord-events.ts; this implements the triage read/send path)biome checkcurrently reformats the whole ofpackages/core/plugins/plugin-discordto spaces (pre-existing repo-wide drift being normalized lane-by-lane, see fix: green verify baseline — browser redact export, logger arg order, prober contract, biome drift #12919), so no reformat here🤖 Generated with Claude Code