Context
The im-worker is the path that turns a team9 message into a hive sendInput call, and along the way it builds the `team9Context` payload that ahand-integration relies on for `peerUserId` resolution. The full chain is currently only verified by today's E2E smoke (live deploy + bot DM).
Scope
Add `apps/server/apps/im-worker/src/post-broadcast/integration/ahand-dynamic-device.integration.spec.ts` driving the `pushToHiveBots` path with a mocked claw-hive-api endpoint and a real (or testcontainer'd) Postgres for bot lookup.
Scenarios from Phase 9 / Task 9.3 (§ 9.4.5 / § 9.4.8 im-worker matrix):
- DM happy path: human sends a message in a direct channel containing one hive bot → `sendInput` fires once with the right `sessionId` and a `team9Context` whose `peerUserId == sender.id`, `scopeType == "dm"`.
- Group @mention: same channel layout but a public channel; only @-mentioned bots receive `sendInput`. Non-mentioned bots get nothing.
- Topic-session collapse: `channels.type == 'topic-session'` → location wire is `"dm"` (collapses with routine-session and direct).
- Mentor flag: bot's `mentorId == sender.id` → `team9Context.isMentorDm == true`. Non-mentor sender → `false`.
- Tracking auto-forward: thread reply where a tracking channel already exists for that root → forwarded to the tracking session id, not a new one.
- Skip non-human-authored messages: bot-authored messages are dropped (no `sendInput` call).
- Skip deep-research messages: messages flagged in metadata as deep-research are dropped.
Acceptance criteria
References
- Phase 9 / Task 9.3 in `docs/superpowers/plans/2026-04-22-ahand-integration-plan.md`
- `apps/server/apps/im-worker/src/post-broadcast/post-broadcast.service.ts:594-870` (the path under test)
Context
The im-worker is the path that turns a team9 message into a hive sendInput call, and along the way it builds the `team9Context` payload that ahand-integration relies on for `peerUserId` resolution. The full chain is currently only verified by today's E2E smoke (live deploy + bot DM).
Scope
Add `apps/server/apps/im-worker/src/post-broadcast/integration/ahand-dynamic-device.integration.spec.ts` driving the `pushToHiveBots` path with a mocked claw-hive-api endpoint and a real (or testcontainer'd) Postgres for bot lookup.
Scenarios from Phase 9 / Task 9.3 (§ 9.4.5 / § 9.4.8 im-worker matrix):
Acceptance criteria
References