Skip to content

Conversation

@mjunaidca
Copy link
Owner

Summary

  • Implement recurring task system with automatic next-occurrence spawning on task completion
  • Add chain tracking via recurring_root_id linking all spawned tasks to original root
  • Full agent parity - MCP tools support all recurring task fields identically to web UI

What Was Built

Component Description
7 Database Fields is_recurring, recurrence_pattern, max_occurrences, recurring_root_id, recurrence_trigger, clone_subtasks_on_recur, has_spawned_next
Spawn Logic create_next_occurrence() - Creates next task when current is completed
Chain Tracking All spawned tasks link to original root via recurring_root_id
Count-Based Limits max_occurrences checked via COUNT(*) query, not stored counter
Subtask Cloning Optional recursive cloning of subtasks to new occurrence
Duplicate Prevention has_spawned_next flag prevents re-spawn on re-completion
9 Patterns 1m, 5m, 10m, 15m, 30m, 1h, daily, weekly, monthly

Files Changed

Backend API

  • packages/api/src/taskflow_api/models/task.py - 7 new recurring fields
  • packages/api/src/taskflow_api/routers/tasks.py - Spawn logic + helper functions
  • packages/api/src/taskflow_api/schemas/task.py - Schema updates with validation

MCP Server (Agent Parity)

  • packages/mcp-server/src/taskflow_mcp/api_client.py - Recurring params support
  • packages/mcp-server/src/taskflow_mcp/models.py - Model updates
  • packages/mcp-server/src/taskflow_mcp/tools/tasks.py - Tool interface updates

Web Dashboard

  • web-dashboard/src/app/projects/[id]/tasks/new/page.tsx - Recurring form fields
  • web-dashboard/src/app/tasks/[id]/page.tsx - Display recurring status
  • web-dashboard/src/app/tasks/page.tsx - List view indicators
  • web-dashboard/src/types/index.ts - TypeScript types

ChatKit Integration

  • packages/api/src/taskflow_api/services/chat_agent.py - Agent tool updates
  • packages/api/src/taskflow_api/services/chatkit_server.py - Server updates
  • packages/api/src/taskflow_api/services/widgets/task_form.py - Form widget

Architectural & Design Concerns

🔴 Critical (Should Fix Before Production)

  1. No Tests for Recurring Logic - Zero dedicated tests for spawn-on-completion, max_occurrences enforcement, chain tracking
  2. recurrence_trigger Has Unimplemented Values - on_due_date and both are stored but no background job exists
  3. Missing Database Index - recurring_root_id needs index=True for query performance

🟡 Medium (Should Address)

  1. No Cascade Delete Strategy - Orphaned chain tasks if root is deleted
  2. Monthly = 30 Days - Not calendar-accurate, causes date drift over time
  3. Potential Race Condition - Concurrent completions could spawn duplicates

🟢 Low (Future Consideration)

  1. Subtask due dates not adjusted relative to parent
  2. new_task variable unused in approve_task
  3. No rate limiting on rapid spawn
  4. Model accepts any string for recurrence_pattern

Positive Aspects

✅ Clean chain tracking design using recurring_root_id + COUNT query
✅ Proper audit logging for all spawn events
✅ Full agent parity - MCP tools support recurring task creation
✅ UI integration - Both web form and ChatKit form support recurring fields
✅ Duplicate prevention via has_spawned_next flag
✅ Subtask cloning is configurable per-task

Test Plan

  • Backend pytest suite passes (74 tests)
  • Frontend build succeeds
  • Manual testing of recurring task completion flow
  • Verify chain tracking in database
  • Test max_occurrences limit enforcement
  • Test subtask cloning behavior

Questions for Review

  1. Monthly behavior: Should "monthly" be calendar-accurate (same day next month) or 30-day fixed?
  2. Spawn notification: Should users be notified when a new occurrence is spawned?
  3. Chain visibility: Should UI show "View all occurrences" for a recurring chain?
  4. Orphan handling: If user deletes a recurring root, what happens to chain tasks?

🤖 Generated with Claude Code

mjunaidca and others added 2 commits December 11, 2025 00:49
…cking

Implement comprehensive recurring task functionality enabling automatic task
regeneration on completion. This is a core Agent 2A feature for the TaskFlow
platform.

## What's New

### Database Model (7 new fields)
- is_recurring: Enable recurrence for a task
- recurrence_pattern: 1m, 5m, 10m, 15m, 30m, 1h, daily, weekly, monthly
- max_occurrences: Optional limit on total spawns (null = unlimited)
- recurring_root_id: Links all spawned tasks to original root for chain tracking
- recurrence_trigger: When to spawn (currently: on_complete only)
- clone_subtasks_on_recur: Copy subtasks to new occurrence
- has_spawned_next: Duplicate prevention flag

### Backend Logic
- create_next_occurrence(): Spawns next task when current is completed
- Chain tracking via recurring_root_id + COUNT query
- Automatic due date calculation based on pattern
- Optional recursive subtask cloning
- Full audit logging for all spawn events

### MCP Integration (Agent Parity)
- taskflow_add_task supports all recurring fields
- Agents can create and manage recurring tasks identically to humans

### Web Dashboard
- New task form with recurring options
- Task detail page shows recurring status and chain info
- Tasks list displays recurrence indicators

### ChatKit Integration
- Task form widget supports recurring field configuration
- Natural chat-based recurring task creation

## Known Limitations (Documented in Review)
- recurrence_trigger only supports 'on_complete' (on_due_date not implemented)
- Monthly = 30 days (not calendar-accurate)
- No dedicated test suite for recurring logic yet

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Shorten description strings in Task model fields (E501)
- Shorten comment for self-referential relationship (E501)
- Remove unused new_task variable assignment (F841)
- Add index=True to recurring_root_id for query performance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mjunaidca mjunaidca merged commit 98f882a into main Dec 10, 2025
3 checks passed
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.

2 participants