Skip to content

feat: capture messages in Discord command channels - #97

Merged
Ivory2024 merged 3 commits into
mainfrom
fm/discord-command-channel-20261007
Oct 7, 2026
Merged

Ivory2024 merged 3 commits into
mainfrom
fm/discord-command-channel-20261007

Conversation

@Ivory2024

@Ivory2024 Ivory2024 commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Intent

Captain wants a thin Discord "Captain Console" layer for Firstmate so they no longer have to type "@FIRST Crew" to reach it. Every message the captain posts in the 퍼스트크루-채팅방 (channel 1551134713727426570) should be read by Firstmate without an @mention, because the mention forces a Korean/English IME round-trip on every call.

Decisions and constraints the captain set:

  • Keep it a thin UX layer: the Discord layer only authenticates, normalizes, writes a durable inbox record, and enqueues a durable wake. It must NOT add a Discord-specific orchestration API (no /fm research|merge|spawn). Downstream handling stays the same.
  • Command channel first: implement mention-free capture via an explicit channel opt-in. Slash commands (/fm) and message buttons are deferred because Discord interactions need a public HTTP receiver / always-on service, which is more infrastructure than the polling design; that is reported as a tradeoff rather than built now.
  • The mention-free path must be opt-in and safe: only an explicitly listed command channel, and only from an authorized user id; bot messages and unauthorized authors are still ignored. A channel listed as a command channel and also excluded must fail safe (exclusion wins) with an explicit diagnostic.
  • Preserve the existing Discord reliability invariants: 2026-89: fix(discord): capture replies to the bot without an explicit mention #89 (reply to the bot's own message is captured without a mention), 2026-93: fix(discord): queue out-of-band mention wakes durably #93 (capture enqueues a durable wake), fix(discord): suppress routine progress notifications and enforce test hermeticity #94 (no routine notifications), fix(discord): make the proactive decision message scannable #95 (decision readability). DMs and the existing @mention fallback must keep working, and all inputs must normalize to the same discord-selfhosted x-inbox + durable wake path.

This change adds FM_DISCORD_COMMAND_CHANNELS (resolved in bin/fm-discord-lib.sh, exported by bin/fm-discord-poll.sh, gated in bin/fm-discord-poll.js), documents it in docs/configuration.md, and adds regression tests.

What Changed

  • Add opt-in FM_DISCORD_COMMAND_CHANNELS capture for authorized users’ plain messages, routing them through the existing self-hosted Discord inbox and durable wake path.
  • Report when a command channel is excluded; exclusion wins. Document the setting and add regression coverage for capture, authorization, exclusions, and duplicate polling.

Risk Assessment

No unresolved risk. The single high-severity review finding below was resolved by an explicit captain decision, with no code change required.

Resolution: in the "exclusion wins" rule, excluded means the explicit FM_DISCORD_EXCLUDE_CHANNELS list only. The built-in collision exclusion (which includes 1551134713727426570) is a default safety value, and an explicit captain allowlist / command-channel configuration intentionally overrides it: built-in default exclusion < explicit captain configuration. This is the only reading consistent with using 1551134713727426570 itself as a command channel. Current code already implements it, so behavior is unchanged; an explicit exclusion still wins and emits the diagnostic.

Testing

Ran the targeted self-hosted Discord integration script. It drove the real poller and durable inbox/wake path against a simulated Discord API; authorized capture, unauthorized and ordinary-channel rejection, existing reply and DM paths, idempotency, and explicit-exclusion diagnostics passed. No visual surface applies.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Authorized captain posts plain text in an opted-in channel; Firstmate stores the inbox record and enqueues a durable wake ✅ pass live bash tests/fm-discord-selfhosted.test.sh — command-channel capture and durable wake checks
Unauthorized author posts in an opted-in channel, or authorized captain posts in an ordinary channel; neither message is captured ✅ pass live bash tests/fm-discord-selfhosted.test.sh — unauthorized-author and ordinary-channel checks
Captain uses existing reply-to-bot or DM path, then polling repeats a captured message; fallback works and duplicate inbox records are not created ✅ pass live bash tests/fm-discord-selfhosted.test.sh — reply-to-bot, DM, and idempotency checks
Captain posts in a command channel also explicitly excluded; poller ignores it and emits the exclusion diagnostic ✅ pass live bash tests/fm-discord-selfhosted.test.sh — excluded command-channel check

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - 1 finding, resolved by captain decision
  • ✅ bin/fm-discord-lib.sh:71 - Resolved. The finding asked whether the built-in collision exclusion counts for the "exclusion wins" rule. Captain decision: it does not. "Exclusion wins" applies to the explicit FM_DISCORD_EXCLUDE_CHANNELS list; the built-in collision exclusion is a default safety that explicit captain configuration (allowlist / command channel) overrides. Current behavior is correct and was left unchanged: the command channel is honored, and a channel in the explicit exclusion list still wins with a diagnostic.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Authorized captain posts plain text in an opted-in channel; Firstmate stores the inbox record and enqueues a durable wake ✅ pass live bash tests/fm-discord-selfhosted.test.sh — command-channel capture and durable wake checks
Unauthorized author posts in an opted-in channel, or authorized captain posts in an ordinary channel; neither message is captured ✅ pass live bash tests/fm-discord-selfhosted.test.sh — unauthorized-author and ordinary-channel checks
Captain uses existing reply-to-bot or DM path, then polling repeats a captured message; fallback works and duplicate inbox records are not created ✅ pass live bash tests/fm-discord-selfhosted.test.sh — reply-to-bot, DM, and idempotency checks
Captain posts in a command channel also explicitly excluded; poller ignores it and emits the exclusion diagnostic ✅ pass live bash tests/fm-discord-selfhosted.test.sh — excluded command-channel check
  • bash tests/fm-discord-selfhosted.test.sh
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

Adds an explicit opt-in channel list where an authorized captain's plain message
is an inbound Firstmate request, without typing @FIRST Crew (which forces a
Korean/English IME round-trip on every call).

- bin/fm-discord-lib.sh: resolve FM_DISCORD_COMMAND_CHANNELS (one place); a
  command channel that is also excluded is dropped with an explicit diagnostic
  (exclusion wins).
- bin/fm-discord-poll.js: allow the mention-free path only when the polled
  channel is a command channel AND the author is authorized; bot messages and
  unauthorized authors are still ignored.
- bin/fm-discord-poll.sh: export the resolved command channels to the poll.
- docs/configuration.md: document the setting and how it differs from the
  polling allowlist.
- tests: authorized+command-channel plain -> captured; unauthorized -> ignored;
  ordinary channel plain -> ignored; duplicate poll -> one inbox record;
  command/exclusion conflict -> fail-safe diagnostic.

Preserves #89 (reply to bot), #93 (durable wake on capture), DM polling, and the
existing @mention fallback; all inputs still normalize to the same
discord-selfhosted x-inbox + durable-wake path.
@Ivory2024
Ivory2024 merged commit 1320c0d into main Oct 7, 2026
37 of 38 checks passed
Ivory2024 added a commit that referenced this pull request Oct 7, 2026
* feat(discord): captain command channel for mention-free requests

Adds an explicit opt-in channel list where an authorized captain's plain message
is an inbound Firstmate request, without typing @FIRST Crew (which forces a
Korean/English IME round-trip on every call).

- bin/fm-discord-lib.sh: resolve FM_DISCORD_COMMAND_CHANNELS (one place); a
  command channel that is also excluded is dropped with an explicit diagnostic
  (exclusion wins).
- bin/fm-discord-poll.js: allow the mention-free path only when the polled
  channel is a command channel AND the author is authorized; bot messages and
  unauthorized authors are still ignored.
- bin/fm-discord-poll.sh: export the resolved command channels to the poll.
- docs/configuration.md: document the setting and how it differs from the
  polling allowlist.
- tests: authorized+command-channel plain -> captured; unauthorized -> ignored;
  ordinary channel plain -> ignored; duplicate poll -> one inbox record;
  command/exclusion conflict -> fail-safe diagnostic.

Preserves #89 (reply to bot), #93 (durable wake on capture), DM polling, and the
existing @mention fallback; all inputs still normalize to the same
discord-selfhosted x-inbox + durable-wake path.

* no-mistakes(document): Document Discord command channel configuration

* no-mistakes(lint): Replace ls/grep inbox count with glob loop
Ivory2024 added a commit that referenced this pull request Oct 7, 2026
* feat(discord): captain command channel for mention-free requests

Adds an explicit opt-in channel list where an authorized captain's plain message
is an inbound Firstmate request, without typing @FIRST Crew (which forces a
Korean/English IME round-trip on every call).

- bin/fm-discord-lib.sh: resolve FM_DISCORD_COMMAND_CHANNELS (one place); a
  command channel that is also excluded is dropped with an explicit diagnostic
  (exclusion wins).
- bin/fm-discord-poll.js: allow the mention-free path only when the polled
  channel is a command channel AND the author is authorized; bot messages and
  unauthorized authors are still ignored.
- bin/fm-discord-poll.sh: export the resolved command channels to the poll.
- docs/configuration.md: document the setting and how it differs from the
  polling allowlist.
- tests: authorized+command-channel plain -> captured; unauthorized -> ignored;
  ordinary channel plain -> ignored; duplicate poll -> one inbox record;
  command/exclusion conflict -> fail-safe diagnostic.

Preserves #89 (reply to bot), #93 (durable wake on capture), DM polling, and the
existing @mention fallback; all inputs still normalize to the same
discord-selfhosted x-inbox + durable-wake path.

* no-mistakes(document): Document Discord command channel configuration

* no-mistakes(lint): Replace ls/grep inbox count with glob loop
@Ivory2024
Ivory2024 deleted the fm/discord-command-channel-20261007 branch October 10, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant