feat: backend-driven task system with Notion agent#24
Conversation
Implements cc_tasks table, 6 API endpoints with state machine (queued->running->needs_review->verified->done), verification gate requiring hard artifacts for actionable tasks, Notion cron sync, 4 MCP tools, and frontend API types. Tasks flow from Notion AI agent capture through backend validation to verified completion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughIntroduces a comprehensive task management system including database schema, backend CRUD and state-machine routes, Notion data synchronization, MCP tools, and frontend API layer with validation schemas and type definitions. Changes
Sequence DiagramssequenceDiagram
participant Client as Client/UI
participant Webhook as POST /webhook
participant TaskAPI as Task Routes
participant DB as Database
Client->>Webhook: Send Notion payload
Webhook->>TaskAPI: Parse & validate payload
TaskAPI->>DB: Upsert cc_tasks by external_id
DB->>DB: Check if terminal state exists
DB->>TaskAPI: Return created/updated task
TaskAPI->>Client: 201 Created with task
sequenceDiagram
participant Client as Client/MCP
participant TaskAPI as Task Routes
participant StateMachine as State Machine
participant DB as Database
participant ActionLog as cc_actions_log
Client->>TaskAPI: PATCH /:id/status
TaskAPI->>StateMachine: Validate transition
alt Invalid Transition
StateMachine->>TaskAPI: Return 422 error
TaskAPI->>Client: Error response
else Valid Transition
StateMachine->>TaskAPI: Transition allowed
TaskAPI->>DB: Update cc_tasks status
TaskAPI->>ActionLog: Log state transition
DB->>TaskAPI: Confirm update
ActionLog->>TaskAPI: Confirm log
TaskAPI->>Client: Updated task response
end
sequenceDiagram
participant Cron as Cron Job
participant Notion as Notion API
participant Parser as Property Parser
participant DB as Database
Cron->>Notion: Query pages (last 25 hours)
Notion->>Cron: Return page batch
Cron->>Parser: Extract page properties
Parser->>Parser: Map Notion fields to task fields
Parser->>Cron: Return parsed task data
Cron->>DB: Upsert cc_tasks with conflict handling
DB->>DB: Preserve terminal state fields
DB->>Cron: Confirmation
Cron->>Cron: Log sync completion
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
cc_taskstable (migration 0011) with state machine lifecycle and verification gates/api/tasks— webhook ingestion, list/get, status transitions, verification, recommendation spawningquery_tasks,get_task,update_task_status,verify_task) for Claude Code integrationTask/TaskActiontypes and 5 API methods inui/src/lib/api.tsState Machine
verifiedrequiresverification_artifactnon-nullledger_record_iddoneis terminal;failedretries back toqueuedPost-Merge Setup
0011_tasks.sqlagainst Neonnotion:task_agent_token,notion:task_database_idTest plan
npm run devstarts without type errorsGET /api/tasksreturns empty listPOST /api/tasks/webhookwith test payload creates taskPATCH /api/tasks/:id/statusenforces state machine (rejectqueued -> done)POST /api/tasks/:id/verifyrejects without artifact, accepts with artifactledger_record_idPOST /api/tasks/:id/spawn-recommendationcreates recommendation and links it🤖 Generated with Claude Code
Summary by CodeRabbit