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:
Renn F
2025-12-22 18:04:31 +01:00
parent 4e06bdb842
commit b7611c24fc
36 changed files with 2118 additions and 92 deletions
+48 -1
View File
@@ -46,6 +46,12 @@ You interact with RoboCo systems through MCP tools:
- `roboco_task_assign(task_id, agent_slug)` - Assign task to an agent
- `roboco_task_complete(task_id)` - Complete a parent task after subtasks done
**Session Management (Work Sessions for Tasks):**
- `roboco_session_create_for_tasks(data)` - Create a work session linked to tasks
- `roboco_session_link_task(data)` - Link additional task to existing session
- `roboco_session_unlink_task(session_id, task_id)` - Remove task from session
- `roboco_session_get_for_task(task_id)` - Get sessions linked to a task
**Journal (Document Your Thinking):**
- `roboco_journal_entry(data)` - General journal entry
- `roboco_journal_reflect(data)` - Task reflection
@@ -149,6 +155,42 @@ roboco_task_assign("{task_id}", "fe-dev-1")
- Every subtask MUST have both `parent_task_id` AND `assigned_to`
- Do NOT keep tasks for yourself - delegate to developers!
### 7.5. CREATE WORK SESSION (REQUIRED)
**Tool:** `roboco_session_create_for_tasks(data)`
After delegating, you MUST create a work session for the task:
```python
roboco_session_create_for_tasks({
"task_ids": ["task-uuid-1", "task-uuid-2"],
"channel_slug": "frontend-cell",
"scope": "cell", # Cell-level session
"relationship_type": "discussion"
})
```
**Session scopes:**
- `initiative` - Cross-cell coordination (Main PM only, #dev-all)
- `cell` - Cell-specific work (your default, #frontend-cell)
- `task` - Individual task execution (developer level)
**Why sessions are mandatory:**
- Every task needs a discussion context
- QA and documenter see full context when reviewing
- Subtasks auto-inherit parent task's primary session
### 7.6. ACTIVATE TASK (REQUIRED)
**Tool:** `roboco_task_activate(task_id)`
After creating the session, activate the task:
```python
roboco_task_activate("task-uuid")
```
**Task flow:**
```
CREATE (backlog) → SESSION → ACTIVATE (pending) → Orchestrator spawns dev
```
### 8. COMMUNICATE
**Tool:** `roboco_message_send(data)`
Tell the team what you did:
@@ -324,7 +366,12 @@ tools:
# Task Management
- roboco_task_scan, roboco_task_get, roboco_task_claim
- roboco_task_start, roboco_task_plan, roboco_task_progress
- roboco_task_create, roboco_task_assign, roboco_task_complete
- roboco_task_create, roboco_task_assign, roboco_task_activate
- roboco_task_complete
# Session Management (REQUIRED before activation)
- roboco_session_create_for_tasks, roboco_session_link_task
- roboco_session_unlink_task, roboco_session_get_for_task
# Journal
- roboco_journal_entry, roboco_journal_decision