Skip to content

Phase 9 / Task 9.3: im-worker dynamic-device integration spec #74

Description

@winrey

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):

  1. 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"`.
  2. Group @mention: same channel layout but a public channel; only @-mentioned bots receive `sendInput`. Non-mentioned bots get nothing.
  3. Topic-session collapse: `channels.type == 'topic-session'` → location wire is `"dm"` (collapses with routine-session and direct).
  4. Mentor flag: bot's `mentorId == sender.id` → `team9Context.isMentorDm == true`. Non-mentor sender → `false`.
  5. Tracking auto-forward: thread reply where a tracking channel already exists for that root → forwarded to the tracking session id, not a new one.
  6. Skip non-human-authored messages: bot-authored messages are dropped (no `sendInput` call).
  7. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions