Add gateway-first pattern: when AGILITON_API_KEY is set, route all
external API calls through the gateway with X-API-Key auth. Falls back
to direct API access when gateway is unavailable.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tables migrated to Jira tracking. PostgreSQL tables will be dropped separately.
Archived in s3://macbookdev/db-archive/agiliton-db-2026-02-08.sql.gz
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The project parameter was passed to createSessionIssue() but ignored -
all sessions were created in the CF Jira project regardless of the
actual session project (ST, LLB, GB, etc.).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
session_sequences table fell behind when sessions were inserted with
explicit session_number (e.g., retro imports), causing duplicate key
violations on next auto-assigned number. Function now syncs forward
by checking MAX(session_number) before assigning.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sessions now auto-create CF Jira issues on start and post full session
output as comments on end, transitioning the issue to Done.
- Add src/services/jira.ts with createSessionIssue, addComment, transitionToDone
- Update session_start to create CF Jira issue and store key in sessions table
- Update session_end to post session output and close Jira issue
- Add migration 031 to archive local task tables (moved to Jira Cloud)
- Update .env.example with Jira Cloud env vars
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When session_id is not provided, falls back to getSessionId() which
reads from CLAUDE_SESSION_ID env or ~/.cache/session-memory/current_session.
Fixes NOT NULL constraint violation on session_notes.session_id.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds DB column, TypeScript types, MCP tool schemas, and CRUD handlers
for planning_mode_required (NULL=auto-detect, true=always, false=never).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove invalid 'pending' status from task_list and task_update enums
- Default to excluding completed tasks when no status filter provided
- Previously, task_list(status=open) missed in_progress/blocked/testing tasks
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Phase 3 cleanup: Transition complete to transcript-based recovery.
- Remove fallback to recoverNotesFromTempFile()
- All recovery now uses JSONL transcripts only
- Log warning if transcript not found for recovery
- Simplify recovery logic (no more dual-method path)
This completes the daemon elimination:
- LaunchAgent plist: Deleted
- session-notes-sync script: Deleted
- Legacy fallback code: Removed
- Result: Simpler architecture, no daemon overhead
Migration complete. System now uses only transcript-based recovery.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Migration 025: Add 'abandoned' status to sessions CHECK constraint (fixes blocking issue)
- Migration 026: Add recovery metadata columns (recovered_from, recovered_at) to track note recovery source
- Update sessionRecoverOrphaned to recover notes from temp files when marking sessions abandoned
- Update notes-parser to track recovery source and timestamp for analytics
These changes complete Priority 3, 5 and part of Priority 1 for CF-572 Session Notes Loss fix.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add PROJECT_KEY_REGEX for valid format (2-5 uppercase letters)
- Add validateProjectKey() and isValidProjectKey() functions
- Update getProjectKey() to validate input and generated keys
- Reject invalid formats with clear error messages
Invalid formats now rejected:
- Single letters (A, C, U)
- Numbers (1, 20, 123)
- Full names (ClaudeFramework, Circles)
- Mixed case (Circles)
- Too long (>5 chars)
Also fixes Sentry SDK v8 API changes (httpIntegration, postgresIntegration).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create sentry.ts with MCP-aware initialization and PII scrubbing
- Replace basic inline Sentry initialization with initSentry()
- Update .env.vault-mapping for sentry.backend-node.dsn secret
- Includes PostgreSQL integration and transaction tracing
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Fixes task project rename command by adding ON UPDATE CASCADE to all foreign key constraints that reference projects(key).
Updated 10 FK constraints: task_sequences, epic_sequences, versions, epics, tasks, project_locks, project_archives, sessions, session_sequences, project_documentation.
Migration drops old constraints and adds new ones with both ON DELETE CASCADE and ON UPDATE CASCADE (except sessions which uses ON DELETE SET NULL).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added 'done' status to task lifecycle for verification period before completion.
**Changes:**
- Added 'done' to task_status enum (pending, open, in_progress, testing, blocked, done, completed)
- Added auto_close_at timestamp column for scheduling auto-close
- Created index for efficient cron job queries
**Workflow:**
1. Task marked 'done' → auto_close_at = NOW() + 7 days
2. Cron job runs daily to check tasks past auto_close_at
3. If no related issues → auto-close to 'completed'
4. If related issues → keep as 'done' (prevents premature closure)
**Lifecycle:**
open → in_progress → done (7-day verification) → completed (auto-closed)
task:CF-454
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Enhanced task_add to search both open AND completed tasks when checking for
duplicates. Previously only checked non-completed tasks.
**Changes:**
- Removed `status != 'completed'` filter from similarity search
- Increased search limit from 3 to 5 tasks
- Separated display: open tasks vs previously completed
- Show 150-char context snippet from completed task descriptions
- Suggest using "task show <id>" to see full solution
**Benefits:**
- Prevents recreating already-solved tasks
- Surfaces solutions from previous attempts
- Reduces circular work on recurring issues
- Maintains context from closed tasks
**Example output:**
```
⚠️ Similar tasks found:
**Open/In Progress:**
- CF-442: Next.js cache issue (92% match, open)
**Previously Completed:**
- CF-378: Pre-test validation (85% match)
Context: "Created comprehensive pre-test quality validation workflow..."
💡 Use "task show <id>" to see full solution before recreating work
```
Fixes: CF-450
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Extends project_documentation with 'workflow' type for:
- Development workflows
- Quality validation processes
- Testing procedures
Used for CF-378 pre-test validation workflow.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Extends project_documentation with 'configuration' type to store:
- Public/internal domains
- Component locations (VMs, services)
- Dependencies and infrastructure setup
**Changes:**
- Added 'configuration' to doc_type enum in tools/index.ts
**Use case:**
Displayed at session start via session-start script (CF-382)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
New link types added:
- depends_on: Task depends on another task to complete first
- needs: Task needs another task (weaker dependency)
- implements: Task implements a feature/requirement
- fixes: Task fixes an issue identified in another task
- causes: Task causes/introduces issue in another task
- subtask_of: Task is a subtask of another (parent-child)
Preserves existing types: blocks, relates_to, duplicates
Changes:
- Migration 021 updates database constraint
- Updated TypeScript types and MCP tool schema
- Applied to production database
Implements CF-385
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- DB_HOST: 10.0.1.1 → infra.agiliton.internal
Improves maintainability and enables dynamic DNS resolution.
Relates to CF-382
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed hardcoded port 5432 to read from POSTGRES_PORT environment
variable to support pgbouncer connection pooling (port 6432).
Connection pooling reduces overhead for frequent queries and better
handles concurrent connections.
.env now configured with POSTGRES_PORT=6432 (pgbouncer).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Check if session exists before inserting commit link
- Auto-create minimal session record if missing (status=active, no project)
- Prevents FK constraint violation when cache/DB drift occurs
- Return message indicates if session was auto-created for monitoring
- Handles edge cases: concurrent calls, missing committed_at, NULL project
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Resolves MCP error when trying to set status="pending" on tasks.
Changes:
- Migration 019: Add 'pending' to tasks.status CHECK constraint
- Update task_update tool schema to accept 'pending' status
- Update task_list tool schema to filter by 'pending' status
Status meanings:
- pending: Created, awaiting approval or dependencies
- open: Approved and ready to start
- in_progress: Currently being worked on
- testing: Implementation complete, being tested
- blocked: Stuck waiting for something
- completed: Done
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Removed hardcoded internal IP address from debug log to comply with
CF-303 IP exposure validation. Changed to generic message.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added validation to check if session_id exists in sessions table before
inserting memories. Falls back to NULL if session not found, preventing
foreign key constraint violations while preserving memory content.
Logs warning when invalid session_id provided for debugging.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added task_move_project tool to move tasks between projects while
preserving all relationships and history:
Changes:
- db.ts: Added getClient() for transaction support
- crud.ts: Implemented taskMoveProject() with full transaction
- index.ts: Wired up tool handler and import
- tools/index.ts: Registered tool definition
Preserves:
- Task metadata (title, description, type, status, priority)
- Checklist items
- Linked commits
- Delegations
- Activity history
- Task links (relates_to, blocks, duplicates)
- Epic and version assignments
- Embeddings
Process:
1. Validates source task and target project exist
2. Generates new ID in target project
3. Transfers all related data in transaction
4. Marks old task as completed with reference
5. Creates duplicate link between tasks
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
**CF-282: Session Reference in Tasks**
- Add session_id column to tasks table (migration 019)
- Store session_id when creating tasks in taskAdd()
- Display session_id in taskShow() output
- Create index for performance
- Backfill existing tasks from task_activity
**CF-278: Enhanced Session Context**
- Updated session-start to load memories (via DB query)
- Performance: 2-3.6s (target <5s) ✓
Changes:
- migrations/019_add_session_id_to_tasks.sql: New migration
- src/tools/crud.ts: taskAdd and taskShow modifications
Requires: Claude Code restart to load new code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Creates deployments and deployment_logs tables for tracking all
deployment types (Docker, MCP, iOS/macOS, services). Includes
deployment status, timing, git integration, and structured logging.
Also adds run-migration.mjs helper for running migrations against
PostgreSQL database.
Part of CF-290, completes CF-291.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
When LiteLLM embedding service is unavailable, archive_search now gracefully falls back to PostgreSQL text search (ILIKE) instead of returning an error. Also adds dotenv support for proper credential loading.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Phase 7 complete: Advanced session analysis capabilities
New MCP Tools (3):
1. session_semantic_search - Vector similarity search across all sessions
2. session_productivity_analytics - Metrics (avg duration, tasks, commits, tokens)
3. session_pattern_detection - Detect patterns (tool usage, task types)
Features:
- Semantic search with embedding-based similarity
- Fallback to ILIKE text search if embeddings unavailable
- Analytics over configurable time periods (week/month/quarter)
- Pattern detection with frequency analysis
Use Cases:
- Find similar past work: "sessions about WhatsApp integration"
- Track productivity: avg commits/tasks per session
- Identify tool usage patterns: which tools used most often
- Analyze task type distribution
All 7 phases complete! System ready for testing.
Related: CF-257
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Switch from external Gemini API (3072 dims, $0.15/1M tokens) to local
Ollama mxbai-embed-large (1024 dims, free) for cost savings and HNSW
index support.
Changes:
- Updated embeddings.ts: model 'mxbai-embed-large', API URL fixed
- Updated migration 015: vector(1024) with HNSW index
- Regenerated 268 tool_docs embeddings with new model
Benefits:
- Free embeddings (no API costs)
- HNSW index enabled (1024 < 2000 dim limit)
- Fast similarity search (O(log n) vs O(n))
- No external API dependency
Trade-offs:
- 5% quality loss (MTEB 64.68 vs ~70 Gemini)
- Uses local compute (1.2GB RAM, <1s per embedding)
Task: CF-251
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Added session existence check before INSERT
- Graceful degradation: sets session_id to null if invalid
- Prevents FK constraint violation
- Memory still stored without session link