Skip to content

fix(daemon): @sam in non-broadcast member channels misclassified as side-pane#85

Merged
spashii merged 2 commits into
mainfrom
sam/fix-side-pane-misclassification
May 25, 2026
Merged

fix(daemon): @sam in non-broadcast member channels misclassified as side-pane#85
spashii merged 2 commits into
mainfrom
sam/fix-side-pane-misclassification

Conversation

@spashii
Copy link
Copy Markdown
Member

@spashii spashii commented May 25, 2026

What this changes

  • @-mentioning Sam in any member channel besides #sam now triggers a real session reply instead of the side-pane redirect — src/runtime/daemon.py
  • _is_side_pane_event short-circuits on channel in self.member_channels BEFORE checking Slack's stapled assistant_thread metadata
  • 5 new tests in test_channel_routing.py pin the classifier across genuine side-panes, member channels with stapled metadata (the bug), known assistant-thread channels, unknown channels, and empty events
  • _mock_daemon helper now initializes _assistant_thread_channels so the new tests don't trip on it
  • New self-maintenance section: "When something breaks — solve the class, not the instance" — a four-step protocol Sam now follows when responding to bugs: name the class (not the instance), find where else it shows up, pick a durable guard, ship the patch AND the guard

The bug (production logs, 2026-05-25)

Operator invited Sam to #team-engineering and @-mentioned. Sam replied with the side-pane redirect ("i live in #sam — talk to me there, not here") instead of responding to the mention.

19:20:07  ignoring event from non-whitelisted channel C0884QPQF6W   ← on_app_mention silently dropped
19:20:29  redirected side-pane message in C0884QPQF6W               ← on_message fired the redirect

Slack staples an assistant_thread field onto every event for assistant-type apps, including events that arrive on real workspace channels. The previous _is_side_pane_event short-circuit only excluded SAM_CHANNEL (and after #79's aed41ba, broadcast_channel_id) — leaving every other member channel vulnerable to misclassification.

PR #79's multi-channel routing landed on main as a09ee9d but the side-pane handler still treats every-channel-except-broadcast as side-pane. So the operator-visible behavior of #79 didn't actually work in production.

The class fix

The instance is _is_side_pane_event misfiring on one stapled-metadata signal. The class is "review checked diff-correctness against one channel kind, never traced behavior under all channel kinds." PR #79 changed the short-circuit from SAM_CHANNEL to broadcast_channel_id — correct edit, wrong frame: still one named target, not the full member-channels set.

So this PR ships two things in one:

  1. The targeted fix to _is_side_pane_event (member-channel short-circuit) + tests.
  2. The durable guard in src/capabilities/self-maintenance.md — a four-step protocol Sam runs when something breaks, with the side-pane bug as the worked example.

The guard is the part that prevents the next variant of this class from shipping in a week.

Confidence

High. Bug reproduced in production logs, fixed deterministically with a member-channel short-circuit, 5 tests pin the corrected behavior. The self-maintenance addition is docs-only and doesn't affect runtime. All 199 tests pass.

spashii added 2 commits May 25, 2026 19:29
…nnel

Bug confirmed in production logs 2026-05-25 on @-mention in #team-engineering:

  19:20:07 ignoring event from non-whitelisted channel C0884QPQF6W
  19:20:29 redirected side-pane message in C0884QPQF6W

Slack staples an `assistant_thread` field onto events for assistant-type
apps even when the event arrives on a real workspace channel. The previous
short-circuit only excluded SAM_CHANNEL (or `broadcast_channel_id` after
the aed41ba refactor) — leaving every OTHER member channel vulnerable:
on_app_mention correctly ignored (SAM_CHANNEL narrowed scope), but
on_message saw the `assistant_thread` staple, classified the event as
side-pane, and posted "i live in #sam — talk to me there, not here"
in response to a legitimate @sam in #team-engineering.

Fix: short-circuit on `channel in self.member_channels` BEFORE checking
the `assistant_thread` field. Real workspace channels are never side-
panes regardless of metadata.

PR #79's multi-channel routing depends on this — without the fix, every
channel besides #sam would still get the redirect. 5 new tests pin the
behavior across genuine side-panes, member channels with stapled
metadata, known assistant-thread channels, unknown channels, and empty
events.
New section under "Pre-push self-checks": when something breaks, the
work is identifying the class of problem and closing every door the
class can come back through — not just patching the visible case.

Four-step protocol: name the class (not the instance), find where else
the class shows up, pick a durable guard (test shape / review item /
process step), ship the patch AND the guard.

Anchored in the 2026-05-25 side-pane misclassification: the instance
was an @sam in #team-engineering getting redirected; the class was
"review checked diff-correctness against one channel kind, never
traced behavior under all channel kinds." Naming both is the discipline.

Counter-examples explicitly called out: single-bug test, "be careful"
prose, deferred ticket. Each looks like a class fix; none is.
@spashii spashii merged commit cb91a24 into main May 25, 2026
2 checks passed
@spashii spashii deleted the sam/fix-side-pane-misclassification branch May 25, 2026 17:38
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