mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
feat(sessions): Session-Task linking with scoped context management
Major feature: Sessions are now linked to tasks with smart routing and context loading, ensuring agents have proper discussion context.
## Session-Task Relationship (Many-to-Many)
- Added SessionTaskTable junction table linking sessions to tasks
- Sessions can link to multiple tasks, tasks can have multiple sessions
- is_primary flag marks the main discussion session for a task
- relationship_type: discussion, planning, review, retrospective
- Subtasks auto-inherit parent task's session
## BACKLOG Status + Activation Flow
- Tasks now created with BACKLOG status (not PENDING)
- PMs must create session BEFORE activating task
- roboco_task_activate() transitions BACKLOG → PENDING
- Prevents race condition where dev starts before session exists
- Flow: CREATE (backlog) → SESSION → ACTIVATE (pending) → spawn
## Session Scopes
- SessionScope enum: initiative, cell, task
- initiative: Cross-cell coordination (Main PM, #dev-all)
- cell: Cell-specific work (Cell PM default)
- task: Individual task execution (dev level)
- Enables future smart context loading by scope
## Message Routing to Task Sessions
- When task_id provided in roboco_message_send(), routes to task's primary session instead of channel's active session
- New API endpoint: GET /sessions/for-task/{task_id}
- TaskResponse now includes linked sessions array
## Dev Session Access
- New tool: roboco_session_history_for_task(task_id)
- Devs can now see their task's discussion history
- Messages tagged with task_id for filtering
## Communication Guidelines
- Added "When to Post / When NOT to Post" to all 9 agent blueprints
- Devs/QA/Doc should use task tools for status, journal for reasoning
- Sessions reserved for coordination that needs response
- Reduces noise: no "Starting work" or "Made progress" chat messages
Files changed:
- DB: SessionTaskTable, SessionScope column
- Services: messaging.py (linking), task.py (activation)
- MCP: 5 new session tools, message routing update
- API: session-task endpoints, TaskResponse sessions
- Blueprints: All 13 updated with session/activation workflow
This commit is contained in:
@@ -10,6 +10,7 @@ Creates all tables for the RoboCo AI Agents Company system:
|
||||
- channels: Communication channels
|
||||
- groups: Role-based groups within channels
|
||||
- sessions: Bounded message sessions
|
||||
- session_tasks: Many-to-many session-task links (PM work sessions)
|
||||
- messages: Extracted messages
|
||||
- notifications: Formal notifications
|
||||
- journals: Agent personal logs
|
||||
@@ -292,6 +293,13 @@ def upgrade() -> None:
|
||||
server_default="active",
|
||||
index=True,
|
||||
),
|
||||
sa.Column(
|
||||
"scope",
|
||||
sa.Enum("initiative", "cell", "task", name="sessionscope"),
|
||||
nullable=False,
|
||||
server_default="task",
|
||||
index=True,
|
||||
),
|
||||
sa.Column(
|
||||
"started_at", sa.DateTime(), nullable=False, server_default=sa.func.now()
|
||||
),
|
||||
@@ -309,6 +317,54 @@ def upgrade() -> None:
|
||||
),
|
||||
)
|
||||
|
||||
# ==========================================================================
|
||||
# SESSION_TASKS TABLE (Many-to-Many Junction)
|
||||
# ==========================================================================
|
||||
op.create_table(
|
||||
"session_tasks",
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True),
|
||||
sa.Column(
|
||||
"session_id",
|
||||
postgresql.UUID(as_uuid=True),
|
||||
sa.ForeignKey("sessions.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
),
|
||||
sa.Column(
|
||||
"task_id",
|
||||
postgresql.UUID(as_uuid=True),
|
||||
sa.ForeignKey("tasks.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
),
|
||||
sa.Column("is_primary", sa.Boolean(), nullable=False, server_default="false"),
|
||||
sa.Column(
|
||||
"relationship_type",
|
||||
sa.String(50),
|
||||
nullable=False,
|
||||
server_default="discussion",
|
||||
),
|
||||
sa.Column(
|
||||
"added_at", sa.DateTime(), nullable=False, server_default=sa.func.now()
|
||||
),
|
||||
sa.Column(
|
||||
"added_by",
|
||||
postgresql.UUID(as_uuid=True),
|
||||
sa.ForeignKey("agents.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
),
|
||||
sa.UniqueConstraint("session_id", "task_id", name="uq_session_task"),
|
||||
)
|
||||
|
||||
# Partial unique index: only one primary session per task
|
||||
op.execute(
|
||||
"""
|
||||
CREATE UNIQUE INDEX ix_session_tasks_primary_per_task
|
||||
ON session_tasks (task_id)
|
||||
WHERE is_primary = true
|
||||
"""
|
||||
)
|
||||
|
||||
# ==========================================================================
|
||||
# MESSAGES TABLE
|
||||
# ==========================================================================
|
||||
@@ -651,6 +707,8 @@ def downgrade() -> None:
|
||||
op.drop_table("journals")
|
||||
op.drop_table("notifications")
|
||||
op.drop_table("messages")
|
||||
op.drop_index("ix_session_tasks_primary_per_task", table_name="session_tasks")
|
||||
op.drop_table("session_tasks")
|
||||
op.drop_table("sessions")
|
||||
op.drop_table("groups")
|
||||
op.drop_table("channels")
|
||||
@@ -668,6 +726,7 @@ def downgrade() -> None:
|
||||
op.execute("DROP TYPE IF EXISTS notificationtype")
|
||||
op.execute("DROP TYPE IF EXISTS messagetype")
|
||||
op.execute("DROP TYPE IF EXISTS sessionstatus")
|
||||
op.execute("DROP TYPE IF EXISTS sessionscope")
|
||||
op.execute("DROP TYPE IF EXISTS channeltype")
|
||||
op.execute("DROP TYPE IF EXISTS complexity")
|
||||
op.execute("DROP TYPE IF EXISTS taskstatus")
|
||||
|
||||
Reference in New Issue
Block a user