Port core functionality from coherence-mcp to blue-core: - store.rs: SQLite persistence with schema v1, WAL mode, FTS5 search - documents, document_links, tasks, worktrees, metadata tables - Blue's voice in all error messages - documents.rs: Enhanced with markdown generation - Rfc, Spike, Adr, Decision types with to_markdown() methods - Blue's signature at the end of generated docs - state.rs: ProjectState aggregation - active_items(), ready_items(), stalled_items(), draft_items() - generate_hint() for contextual recommendations - status_summary() for complete overview - repo.rs: Git detection and worktree operations - detect_blue() finds .blue/ directory structure - WorktreeInfo with rfc_title() extraction - create_worktree(), remove_worktree(), is_branch_merged() - workflow.rs: Status transitions - RfcStatus, SpikeOutcome, SpikeStatus, PrdStatus enums - Transition validation with helpful error messages MCP server updated with 9 tools: - blue_status, blue_next, blue_rfc_create, blue_rfc_get - blue_rfc_update_status, blue_rfc_plan, blue_rfc_validate - blue_rfc_task_complete, blue_search 14 unit tests passing. RFC 0002 tracks remaining phases. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
6.3 KiB
RFC 0002: Port Coherence Functionality
| Status | In Progress |
| Date | 2026-01-24 |
| Source Spike | blue-feature-gap-analysis |
Summary
Port the essential functionality from coherence-mcp to blue, maintaining Blue's voice and philosophy while gaining the workflow capabilities that make coherence useful.
Problem
Blue currently has ~2% of coherence-mcp's functionality:
- 3 MCP tools (vs 35)
- 0 handler modules (vs 28)
- ~50 LOC core (vs 8,796)
- 0 database tables (vs 14)
Without these capabilities, blue can't manage RFCs, track work, or provide meaningful project status.
Proposal
Port coherence-mcp in 4 phases, adapting to Blue's voice throughout.
Phase 1: Foundation
Goal: Basic document management and persistence.
| Component | Source | Target | Notes |
|---|---|---|---|
| store.rs | alignment-core | blue-core | Rename tables, Blue voice in errors |
| documents.rs | alignment-core | blue-core | Keep existing Blue structs, add methods |
| state.rs | alignment-core | blue-core | ProjectState → BlueState |
| repo.rs | alignment-core | blue-core | detect_alignment → detect_blue |
| workflow.rs | alignment-core | blue-core | Status transitions |
Database schema:
- documents, document_links, tasks, worktrees, metadata
- FTS5 for search
- Schema version 1 (fresh start, not migrating from coherence)
MCP tools (Phase 1):
- blue_status
- blue_next
- blue_rfc_create
- blue_rfc_get
- blue_rfc_update_status
- blue_rfc_plan
- blue_rfc_validate
- blue_rfc_complete
- blue_rfc_task_complete
Phase 2: Workflow
Goal: Full RFC/Spike/ADR lifecycle + PR workflow.
| Component | Source | Target |
|---|---|---|
| rfc.rs | handlers | blue-mcp/handlers |
| spike.rs | handlers | blue-mcp/handlers |
| adr.rs | handlers | blue-mcp/handlers |
| decision.rs | handlers | blue-mcp/handlers |
| worktree.rs | handlers | blue-mcp/handlers |
| pr.rs | handlers | blue-mcp/handlers |
| release.rs | handlers | blue-mcp/handlers |
| search.rs | handlers | blue-mcp/handlers |
MCP tools (Phase 2):
- blue_spike_create, blue_spike_complete
- blue_adr_create, blue_decision_create
- blue_worktree_create, blue_worktree_list, blue_worktree_remove
- blue_pr_create, blue_pr_verify, blue_pr_check_item, blue_pr_merge
- blue_release_create
- blue_search
Phase 3: Advanced
Goal: Multi-agent coordination and reminders.
| Component | Source | Target |
|---|---|---|
| staging.rs | handlers | blue-mcp/handlers |
| reminder.rs | handlers | blue-mcp/handlers |
| session.rs | handlers | blue-mcp/handlers |
| env.rs | handlers | blue-mcp/handlers |
Database additions:
- staging_locks, staging_lock_queue, staging_deployments
- active_sessions
- reminders
Phase 4: Specialized
Goal: Code intelligence and quality tools.
| Component | Source | Target |
|---|---|---|
| code_store.rs | alignment-core | blue-core |
| symbol_extractor.rs | alignment-core | blue-core |
| lint.rs | handlers | blue-mcp/handlers |
| audit.rs | handlers | blue-mcp/handlers |
| guide.rs | handlers | blue-mcp/handlers |
What NOT to Port
- Parked/Gated items - Half-implemented in coherence, skip for now
- Post-mortems/Runbooks - Low usage, add later if needed
- Dialogue tools - Specialized, port only if needed
- Infrastructure indexing - Complex, defer to Phase 5
Blue's Voice Adaptation
All ported code must speak as Blue:
// Coherence style
return Err(ServerError::AlignmentNotDetected);
// Blue style
return Err(ServerError::NotHome("Can't find Blue here. Run 'blue init' first?"));
// Coherence message
"RFC created successfully"
// Blue message
"Created RFC '{}'. Want me to help fill in the details?"
Directory Structure After Port
blue/
├── crates/
│ └── blue-core/
│ ├── src/
│ │ ├── lib.rs
│ │ ├── documents.rs # Document types
│ │ ├── store.rs # SQLite persistence
│ │ ├── state.rs # Project state
│ │ ├── repo.rs # Git operations
│ │ ├── workflow.rs # Status transitions
│ │ ├── voice.rs # Blue's tone (existing)
│ │ └── search.rs # FTS5 search
│ └── Cargo.toml
│ └── blue-mcp/
│ ├── src/
│ │ ├── lib.rs
│ │ ├── server.rs # MCP server
│ │ ├── error.rs # Error types
│ │ ├── tools.rs # Tool definitions
│ │ └── handlers/
│ │ ├── mod.rs
│ │ ├── rfc.rs
│ │ ├── spike.rs
│ │ ├── adr.rs
│ │ ├── worktree.rs
│ │ ├── pr.rs
│ │ ├── search.rs
│ │ └── ...
│ └── Cargo.toml
└── apps/
└── blue-cli/
Goals
- Feature parity with coherence-mcp core workflow
- Blue's voice and philosophy throughout
- Fresh schema (no migration baggage)
- Cleaner code structure from lessons learned
Non-Goals
- 100% feature parity (skip rarely-used features)
- Backward compatibility with coherence databases
- Supporting both alignment_ and blue_ tool names
Implementation Progress
Phase 1: Foundation - COMPLETE
- store.rs - SQLite persistence with schema v1, WAL mode, FTS5 search
- documents.rs - Rfc, Spike, Adr, Decision with markdown generation
- state.rs - ProjectState with active/ready/stalled/draft items
- repo.rs - detect_blue(), worktree operations
- workflow.rs - RfcStatus, SpikeOutcome, transitions
- 9 MCP tools: blue_status, blue_next, blue_rfc_create, blue_rfc_get, blue_rfc_update_status, blue_rfc_plan, blue_rfc_validate, blue_rfc_task_complete, blue_search
- 14 unit tests passing
- Blue's voice in all error messages
Phase 2-4: Pending
Test Plan
- blue init creates .blue/ directory structure
- blue rfc create persists to SQLite
- blue status shows active/ready/stalled items
- blue search finds documents by keyword
- Blue's voice in all error messages
- Worktree operations work with git
"Right then. Quite a bit to port. But we'll take it step by step."
— Blue