feat(CF-166): Add investigation workflow with auto-linking

Implements comprehensive investigation task management:

**Schema Changes (Migration 020):**
- Add 'investigation' task type to tasks table
- Add investigation_parent_id and auto_link_enabled columns to session_context
- Add auto_linked and linked_at columns to task_links for tracking
- Create indexes for efficient auto-linking queries

**Auto-Linking Logic:**
1. Investigation Parent Linking: Tasks auto-link to active investigation
2. Current Task Linking: Tasks link to current working task
3. Time-Based Linking: Tasks within 1 hour auto-link (fallback)

**New Tool:**
- task_investigate: Start investigation workflow, sets session context

**Documentation:**
- Add comprehensive investigation workflow guide to README
- Include examples and session context explanation

All checklist items completed:
✓ Investigation task type in schema
✓ Session context table enhancements
✓ Auto-linking implementation
✓ task_investigate command
✓ Documentation updates

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-01-19 19:15:25 +02:00
parent caf9356aad
commit 7be5878d35
6 changed files with 246 additions and 17 deletions

View File

@@ -0,0 +1,43 @@
-- Migration 020: Add 'investigation' task type and auto-linking infrastructure
-- Implements CF-166: Enhanced investigation workflows
-- 1. Add 'investigation' to task type CHECK constraint
-- First, check if constraint exists and drop it
DO $$
BEGIN
IF EXISTS (
SELECT 1 FROM pg_constraint
WHERE conname = 'tasks_type_check'
AND conrelid = 'tasks'::regclass
) THEN
ALTER TABLE tasks DROP CONSTRAINT tasks_type_check;
END IF;
END $$;
-- Add new constraint with investigation type
ALTER TABLE tasks ADD CONSTRAINT tasks_type_check
CHECK (type IN ('task', 'bug', 'feature', 'debt', 'investigation'));
-- 2. Add new columns to session_context table for investigation tracking
-- Table already exists from previous migration, just add new columns
ALTER TABLE session_context ADD COLUMN IF NOT EXISTS investigation_parent_id TEXT REFERENCES tasks(id) ON DELETE SET NULL;
ALTER TABLE session_context ADD COLUMN IF NOT EXISTS auto_link_enabled BOOLEAN DEFAULT true;
-- Create indexes for new columns
CREATE INDEX IF NOT EXISTS idx_session_context_investigation ON session_context(investigation_parent_id);
-- Add comments (only if table was just created)
-- COMMENT ON TABLE session_context IS 'Tracks current working task per session for auto-linking (CF-166)';
-- COMMENT ON COLUMN session_context.current_task_id IS 'Task currently being worked on in this session';
-- COMMENT ON COLUMN session_context.investigation_parent_id IS 'Parent investigation task for auto-linking subtasks';
-- COMMENT ON COLUMN session_context.auto_link_enabled IS 'Whether to automatically link new tasks to current context';
-- 3. Add metadata to task_links for auto-linking tracking
ALTER TABLE task_links ADD COLUMN IF NOT EXISTS auto_linked BOOLEAN DEFAULT false;
ALTER TABLE task_links ADD COLUMN IF NOT EXISTS linked_at TIMESTAMP WITH TIME ZONE DEFAULT NOW();
COMMENT ON COLUMN task_links.auto_linked IS 'Whether this link was created automatically (CF-166)';
COMMENT ON COLUMN task_links.linked_at IS 'Timestamp when the link was created';
-- Create index for finding tasks created within time windows (for auto-linking)
CREATE INDEX IF NOT EXISTS idx_tasks_created_at_desc ON tasks(created_at DESC);