Skip to content

fix(ipc): solve multi-channel collision and agent staleness #533

Closed
gabi-simons wants to merge 5 commits intoqwibitai:mainfrom
gabi-simons:feat/multi-channel-db-v2
Closed

fix(ipc): solve multi-channel collision and agent staleness #533
gabi-simons wants to merge 5 commits intoqwibitai:mainfrom
gabi-simons:feat/multi-channel-db-v2

Conversation

@gabi-simons
Copy link
Copy Markdown
Collaborator

@gabi-simons gabi-simons commented Feb 26, 2026

Type of Change

  • Skill - adds a new skill in .claude/skills/
  • Fix - bug fix or security fix to source code
  • Simplification - reduces or simplifies source code

Description

This PR builds on the modular channel architecture by implementing the necessary database migrations and fixing critical IPC routing issues discovered during multi-channel testing .

Key Changes

  1. Database & Schema Evolution
    Folder Constraint Removal: Removed the UNIQUE constraint on the folder column in registered_groups. This allows multiple JIDs (e.g., WhatsApp, Telegram, Discord) to share the same agent session/folder.

Channel Column: Added a channel column to the database to track the platform origin of each registered JID.

Automatic Migration: Implemented migrateRegisteredGroupsSchema to handle existing databases, ensuring a smooth upgrade path for current users.

  1. IPC Collision Fix (Issue Replace IPC busy-loop polling with async fs.watch #6)
    Fixed the "cross-routing" bug where messages from one channel received replies on another when sharing a folder.

JID-Tagged IPC: Every IPC message now carries a chatJid field. Containers filter incoming files and only consume messages addressed to them.

Isolated Sentinels: Replaced the global _close sentinel with JID-specific files (_close.{safeJid}) to prevent one channel's idle timeout from killing sibling containers in the same folder.

Auto-Sync Logic: Updated container-runner.ts to sync the agent-runner source on every container start, ensuring protocol fixes reach existing group sessions immediately.

Known Limitations & Technical Debt
Resource Overhead: Currently, each channel on a shared folder still runs its own Docker container. This ensures complete isolation but consumes more memory/CPU than a single multiplexed container.

Future Optimization: We have identified Approach C (Folder-aware Queue) as the long-term architectural goal to reduce resource usage, but it remains deferred to avoid breaking changes in the MCP response routing layer.

- Introduced ChannelRegistry for dynamic channel loading
- Decoupled WhatsApp from core index.ts and config.ts
- Updated setup wizard to support ENABLED_CHANNELS selection
- Refactored IPC and group registration to be channel-aware
- Verified with 359 passing tests and clean typecheck
- Tagged IPC messages and close sentinels with chatJid
- Implemented JID-based filtering in agent-runner
- Added per-JID close sentinels to prevent cross-channel kills
- Forced agent-runner src sync on every container start
- Updated tests to match new sentinel pattern
- Verified 369/369 tests pass
@gabi-simons gabi-simons changed the title Feat/multi channel db v2 fix(ipc): solve multi-channel collision and agent staleness Feb 26, 2026
@gabi-simons gabi-simons closed this Mar 4, 2026
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