# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.2] - 2026-01-03

### Fixed

- **CLI Provider Error Extraction**: Improved error message extraction from CLI tool outputs
  - `ClaudeProvider`: Extract errors from JSON output with `is_error: true` field
  - `CodexProvider`: Extract errors from JSONL events (`type: error`, `type: turn.failed`)
  - `CursorAgentProvider`: Check stdout for plain text errors (not just stderr)
  - `GeminiProvider`: Parse text + JSON error format, skip unhelpful `[object Object]` messages
  - `OpenCodeProvider`: Extract errors from wrapper JSONL output

- **OpenCode NODE_PATH Configuration**: Added `_ensure_node_path()` to include global npm modules
  - Allows `@opencode-ai/sdk` to be installed globally rather than bundled
  - Detects global npm root via `npm root -g` and adds to NODE_PATH

## [0.8.1] - 2026-01-03

### Added

- **Batch Operations for Parallel Task Execution**: New actions for autonomous multi-task workflows
  - `prepare-batch`: Find independent tasks for parallel execution with file-path conflict detection
  - `start-batch`: Atomically start multiple tasks as in_progress (all-or-nothing validation)
  - `complete-batch`: Complete multiple tasks with partial failure support
  - `reset-batch`: Reset batch on failure, returning tasks to pending status
  - Token budget support for context-aware batch sizing
  - Stale task detection for tasks stuck in_progress beyond threshold
  - Dependency graph visualization in prepare-batch responses

- **Autonomous Session Context Tracking**: CLI context management for continuous task processing
  - `AutonomousSession` class for tracking batch state across operations
  - `ContextTracker` for managing session lifecycle and context limits
  - Integration with task router for session-aware operations

- **Configurable Tool Disabling**: Added `disabled_tools` configuration option to selectively disable MCP tools
  - Configure via environment variable: `FOUNDRY_MCP_DISABLED_TOOLS=error,health,metrics,test`
  - Configure via TOML: `[server] disabled_tools = ["error", "health", "metrics", "test"]`
  - Tools remain in codebase but are not registered with the MCP server when disabled
  - Useful for reducing context window usage by hiding unused tools

### Changed

- Enhanced development guide with batch operations documentation and usage examples

## [0.7.11] - 2025-12-30

### Fixed

- **Consensus Workflow Provider Spec Parsing**: Extended provider spec parsing fix to consensus workflow
  - Full specs like `[cli]codex:gpt-5.2` in `consensus_providers` config now work correctly
  - Parses specs in `execute()`, `_query_provider_sync()`, and `_query_single_provider()`
  - Filters providers by base ID availability while preserving model selection

## [0.7.10] - 2025-12-30

### Fixed

- **Research Workflow Provider Spec Parsing**: Fixed `_resolve_provider` to handle full provider specs
  - Full specs like `[cli]codex:gpt-5.2-codex` in `default_provider` config now work correctly
  - Extracts base provider ID for availability check (e.g., `codex` from full spec)
  - Passes model from spec to `resolve_provider()` for proper model selection
  - Caches providers by full spec string to differentiate model variants

## [0.7.9] - 2025-12-30

### Fixed

- **Provider Detector Cache Isolation**: Fixed test pollution where availability cache persisted across tests
  - `reset_detectors()` now clears `_AVAILABILITY_CACHE` to ensure fresh detection
  - Prevents false negatives when test order affects cached availability results

- **Research E2E Test Fixtures**: Added missing `max_messages_per_thread` to mock_config fixture
  - Fixed `TypeError: '>=' not supported between instances of 'MagicMock' and 'int'`
  - Research chat workflow now works correctly in test mode

- **OpenCode Model Validation Test**: Removed obsolete test for empty model validation
  - Model validation was delegated to CLI in v0.7.5 but test was not removed
  - OpenCode provider correctly passes any model to CLI for validation

## [0.7.8] - 2025-12-30

### Fixed

- **Consensus Event Loop Conflict**: Fixed `asyncio.run() cannot be called from a running event loop` error
  - Replaced `asyncio.run()` with `ThreadPoolExecutor` for parallel provider execution
  - Works correctly within MCP server's event loop context
  - New `_execute_parallel_sync()` and `_query_provider_sync()` methods for thread-based parallelism

- **Research Timeout Configuration**: Fixed thinkdeep and other workflows timing out after 30 seconds
  - Added `default_timeout` config option to `[research]` section (default: 60 seconds)
  - Workflows now use configurable timeout from config instead of hardcoded 30s
  - Longer-running investigation workflows like thinkdeep no longer timeout prematurely

## [0.7.7] - 2025-12-30

### Added

- **Research ProviderSpec Alignment**: Research config now supports full ProviderSpec notation like consultation
  - `default_provider` accepts both simple IDs (`"gemini"`) and ProviderSpec (`"[cli]gemini:gemini-2.5-flash"`)
  - `consensus_providers` accepts mixed notation for flexible model selection per provider
  - New `ResearchConfig.get_default_provider_spec()` helper parses default provider
  - New `ResearchConfig.get_consensus_provider_specs()` helper parses consensus providers
  - New `ProviderSpec.parse_flexible()` method for backward-compatible parsing
  - Workflows (`chat`, `consensus`, `thinkdeep`, `ideate`) now extract models from specs
  - Added `[research]` section to sample config with notation examples

## [0.7.6] - 2025-12-30

### Fixed

- **Research Tools Feature Flag**: Fixed bug where `research_tools = true` in `[features]` config section was ignored
  - Root cause 1: `research_tools` flag was never registered in the feature flag registry
  - Root cause 2: `[features]` section in TOML config was not being read
  - Added flag registration in `research.py` following `provider.py` pattern
  - Added global override support to `FeatureFlagRegistry` for config-based flag settings
  - Added `[features]` section handling in `ServerConfig._load_toml()`
  - Added `FOUNDRY_MCP_FEATURES` environment variable support (format: `flag1=true,flag2=false`)

### Added

- **Feature Flag Global Overrides**: New methods on `FeatureFlagRegistry`:
  - `set_global_override(flag_name, enabled)` - Set config-based override for all clients
  - `clear_global_override(flag_name)` - Clear a global override
  - `clear_all_global_overrides()` - Clear all global overrides
  - `apply_config_overrides(features)` - Apply multiple overrides from config dict

### Dependencies

- Added `filelock>=3.20.1` as a required dependency

## [Unreleased]

## [0.8.1] - 2026-01-03

### Added

- **Batch Operations for Parallel Task Execution**: New actions for autonomous multi-task workflows
  - `prepare-batch`: Find independent tasks for parallel execution with file-path conflict detection
  - `start-batch`: Atomically start multiple tasks as in_progress (all-or-nothing validation)
  - `complete-batch`: Complete multiple tasks with partial failure support
  - `reset-batch`: Reset batch on failure, returning tasks to pending status
  - Token budget support for context-aware batch sizing
  - Stale task detection for tasks stuck in_progress beyond threshold
  - Dependency graph visualization in prepare-batch responses

- **Autonomous Session Context Tracking**: CLI context management for continuous task processing
  - `AutonomousSession` class for tracking batch state across operations
  - `ContextTracker` for managing session lifecycle and context limits
  - Integration with task router for session-aware operations

### Changed

- Enhanced development guide with batch operations documentation and usage examples

## [0.8.0] - 2026-01-01

### Added

- **Deep Research Workflow**: Multi-phase iterative research with parallel source gathering
  - Background async execution with immediate `research_id` return for non-blocking operation
  - Five-phase pipeline: decomposition → search → analyze → synthesize → report
  - Query decomposition with strategic sub-query generation based on research intent
  - Gap detection and iterative refinement loops for comprehensive coverage
  - Final synthesis with confidence scoring (low/medium/high/confirmed) and source citations
  - Crash handler infrastructure for session recovery
  - Research tool actions:
    - `deep-research`: Start, continue, or resume research sessions
    - `deep-research-status`: Poll running research status with phase progress
    - `deep-research-report`: Get final markdown report with citations and audit trail
    - `deep-research-list`: List sessions with cursor-based pagination
    - `deep-research-delete`: Clean up research sessions

- **Search Provider System**: Extensible multi-provider search architecture
  - **Google Custom Search**: Web search via Google's Custom Search JSON API
  - **Perplexity AI**: Sonar model integration for AI-powered search
  - **Tavily AI**: Search and extract modes with content analysis
  - **Semantic Scholar**: Academic paper search with citation metadata
  - Domain quality tiers (authoritative → unreliable) for source credibility scoring
  - Rate limiting and error handling per provider
  - Pluggable provider interface for custom backends

- **Research Configuration**: New `[research.deep]` config section
  - Per-provider API key configuration (Google, Perplexity, Tavily, Semantic Scholar)
  - Timeout, iteration, and concurrency controls
  - Source quality and domain tier preferences
  - Storage path and session TTL settings

- **Deep Research Documentation**: Comprehensive workflow documentation
  - `docs/concepts/deep_research_workflow.md`: Architecture and usage guide
  - `docs/examples/deep-research/`: Example research sessions and reports

- **Provider Availability Caching**: Cache provider detection results to speed up MCP tool calls
  - New `[providers] availability_cache_ttl` config option (default: 3600 seconds)
  - Reduces repeated calls from ~5s to ~0s

### Changed

- **Provider Model Validation Removed**: Model allowlists removed from all CLI providers
  - Providers no longer pre-register or validate model IDs against hardcoded lists
  - Any model string is now passed through to the underlying CLI for validation
  - Eliminates sync issues when providers release new models
  - Affected providers: `claude`, `gemini`, `codex`, `cursor-agent`
  - Default models remain as fallbacks: opus, pro, gpt-5.2, composer-1

- **BREAKING: Simplified Spec Templates**: Removed pre-baked spec templates (simple, medium, complex, security)
  - Only `empty` template is now supported - creates a blank spec with no phases
  - Use phase templates (`planning`, `implementation`, `testing`, `security`, `documentation`) to add structure
  - Default template changed from `medium` to `empty`
  - Mission statement no longer required (was required for medium/complex)
  - `_requires_rich_task_fields()` now checks explicit `complexity` metadata instead of template
  - Passing deprecated templates (simple, medium, complex, security) returns validation error

### Fixed

- **AI Consultation Config Loading**: Fixed issue where AI consultation features returned `model_used: "none"` because config was loaded from CWD instead of workspace path
  - `review.py`: Now loads `foundry-mcp.toml` from workspace path for fidelity reviews
  - `plan.py`: Added `_find_config_file()` helper to walk up directories and find config

### Migration

**Spec Templates:**
```python
# Old approach (no longer works)
authoring(action="spec-create", name="my-feature", template="medium", mission="...")

# New approach
authoring(action="spec-create", name="my-feature")
authoring(action="phase-template", template_action="apply", template_name="planning", spec_id="...")
authoring(action="phase-template", template_action="apply", template_name="implementation", spec_id="...")
```

**Deep Research:**
```python
# Start a deep research session (returns immediately with research_id)
research(action="deep-research", query="What are the best practices for LLM evaluation?")

# Poll for status
research(action="deep-research-status", research_id="...")

# Get final report when complete
research(action="deep-research-report", research_id="...")
```

## [0.7.0] - 2025-12-30

### Added

- **Research Router**: New unified research tool providing multi-model orchestration capabilities
  - **chat**: Single-model conversation with thread persistence
    - Thread creation with title and system prompt
    - Conversation continuation via thread_id
    - Token budgeting for context management
    - Thread CRUD operations (list, get, delete)
  - **consensus**: Multi-model parallel consultation with synthesis
    - Parallel execution via asyncio.gather with semaphore limiting
    - Four synthesis strategies: all_responses, synthesize, majority, first_valid
    - Partial failure handling with min_responses and require_all options
    - Configurable timeout per provider
  - **thinkdeep**: Hypothesis-driven systematic investigation
    - Investigation step execution with state persistence
    - Hypothesis creation and tracking with evidence accumulation
    - Confidence level progression (speculation -> confirmed)
    - Convergence detection based on depth and confidence
  - **ideate**: Creative brainstorming with idea clustering
    - Four-phase workflow: divergent, convergent, selection, elaboration
    - Multi-perspective idea generation
    - Automatic clustering and scoring
    - Detailed plan elaboration for selected clusters
- **ResearchConfig**: New configuration section for research workflows
  - Configurable storage path, TTL, max messages per thread
  - Default provider and consensus provider list
  - ThinkDeep max depth and Ideate perspectives
- **Research Data Models**: Pydantic models for all workflow states
  - Enums: WorkflowType, ConfidenceLevel, ConsensusStrategy, ThreadStatus, IdeationPhase
  - Conversation, ThinkDeep, Ideate, and Consensus state models
- **File-Based Memory Storage**: Persistent state management for research sessions
  - FileStorageBackend with CRUD operations
  - File locking via filelock for thread safety
  - TTL-based cleanup for expired sessions
- **Research Test Suite**: 149 tests covering models, memory, and router
- **Feature Flag**: `research_tools` flag (experimental) gates research tool access

## [0.6.0] - 2025-12-29

### Added

- **Bikelane Intake System**: Fast-capture queue for rapid idea/task capture with automatic triage workflow
  - **intake-add**: Add items to the intake queue with title, description, priority (p0-p4), tags, source, and requester fields
    - Idempotency key support for deduplication (checks last 100 items)
    - Tag normalization to lowercase
    - Full dry-run support for validation without persistence
  - **intake-list**: List pending intake items in FIFO order with cursor-based pagination
    - Configurable page size (1-200, default 50)
    - Efficient line-hint seeking with fallback to full scan
    - Returns total_count for queue size visibility
  - **intake-dismiss**: Mark items as dismissed with optional reason
    - Atomic file rewrite pattern for data integrity
    - Supports dry-run mode
  - JSONL-based storage at `specs/.bikelane/intake.jsonl` with fcntl file locking
  - Automatic file rotation at 1000 items or 1MB
  - Thread-safe and cross-process safe with 5-second lock timeout
  - Security hardening: path traversal prevention, prompt injection sanitization, control character stripping
  - Feature flag gated: `intake_tools` (experimental, opt-in)
- **Intake Schema**: JSON Schema for intake-v1 format with comprehensive validation constraints
- **Intake Documentation**: User guide at `docs/guides/intake.md`
- **RESOURCE_BUSY Error Code**: New error code for lock contention scenarios

## [0.5.1] - 2025-12-27

### Added

- **Phase Metadata Updates**: New `authoring action=phase-update-metadata` for updating phase-level metadata
  - Supports updating `estimated_hours`, `description`, and `purpose` fields
  - Full dry-run support for previewing changes
  - Tracks previous values for audit purposes
  - Core function `update_phase_metadata()` in `spec.py` with comprehensive validation

### Fixed

- **Lifecycle Tool Router Compatibility**: Fixed `_handle_move()` and other lifecycle handlers receiving unexpected keyword arguments (`force`, `to_folder`) from the unified router dispatch
  - All lifecycle handlers now accept full parameter set for router compatibility
  - Resolves errors like `_handle_move() got an unexpected keyword argument 'force'`

## [0.5.0] - 2025-12-27

### Added

- **Spec Modification Capabilities**: Complete implementation of dynamic spec modification (7 phases, 54 tasks)
  - **Task Hierarchy Mutations**: `task action=move` for repositioning tasks within/across phases with circular reference prevention
  - **Dependency Management**: `task action=add-dependency`, `task action=remove-dependency` for blocks/blocked_by/depends relationships
  - **Task Requirements**: `task action=add-requirement` for adding structured requirements to tasks
  - **Bulk Operations**: `authoring action=phase-add-bulk` for batch phase creation, `authoring action=phase-template` for applying predefined structures
  - **Metadata Batch Updates**: `task action=metadata-batch` with AND-based filtering by node_type, phase_id, or pattern regex
  - **Find-Replace**: `authoring action=spec-find-replace` with regex support and scope filtering for bulk spec modifications
  - **Spec Rollback**: `authoring action=spec-rollback` for restoring specs from automatic backups
  - **Spec History & Diff**: `spec action=history` for backup timeline, `spec action=diff` for comparing specs
  - **Validation Enhancements**: `spec action=completeness-check` with weighted scoring (0-100), `spec action=duplicate-detection` with configurable similarity threshold
- **Standardized Error Codes**: New `ErrorCode` enum with semantic error codes per 07-error-semantics.md
- **Contract Tests**: Comprehensive test suite for response-v2 envelope compliance across all phases

### Changed

- Updated capabilities manifest with 15 new actions documented
- Spec modification spec moved from pending to active (100% complete)

## [0.4.2] - 2025-12-24

### Added

- **Preflight Validation**: `authoring action=spec-create dry_run=true` now generates and validates the full spec, returning `is_valid`, `error_count`, `warning_count`, and detailed diagnostics before actual creation
- **Schema Introspection**: New `spec action=schema` returns all valid enum values (templates, node_types, statuses, task_categories, verification_types, journal_entry_types, blocker_types, status_folders) for LLM/client discovery

### Changed

- **Spec Field Requirements**: Medium/complex specs now require `metadata.mission` and task metadata for `task_category`, `description`, and `acceptance_criteria`; implementation/refactoring tasks must include `file_path`
- **Task Metadata Updates**: `task update-metadata` now accepts `acceptance_criteria` and aligns task category validation with the canonical spec categories

## [0.4.1] - 2025-12-24

### Added

- **Batch Metadata Utilities**: New task actions for bulk operations
  - `task action=metadata-batch`: Apply metadata updates to multiple nodes with AND-based filtering by `node_type`, `phase_id`, or `pattern` regex
  - `task action=fix-verification-types`: Auto-fix invalid/missing verification types on verify nodes with legacy mapping support
  - Both actions support `dry_run` mode for previewing changes
- **Phase-First Authoring**: New `authoring action=phase-add-bulk` for creating multiple phases at once with metadata defaults
- **Spec Mission Field**: Added `mission` field to spec metadata schema for concise goal statements
- **Workflow Timeout Override**: AI consultation now supports workflow-specific timeout configuration

### Changed

- **JSON Output Optimization**: CLI and MCP server now emit minified JSON (no indentation) for smaller payloads
- **Fidelity Review Improvements**: Better path resolution with workspace_root support, graceful handling of non-JSON provider responses
- **Provider Configuration**: Updated OpenCode model IDs and default model; reordered provider priority
- **Claude Provider Tests**: Updated to use Haiku model for faster test execution

### Fixed

- Fixed parameter filtering in error_list handler to prevent unexpected argument errors
- Fixed duplicate file paths in fidelity review implementation artifacts
- Synced `__init__.py` version with `pyproject.toml`

## [0.4.0] - 2025-12-23

### Changed

- **Verification Types**: Aligned task API and spec validator to use canonical values (`run-tests`, `fidelity`, `manual`)
  - Task API now accepts `run-tests`, `fidelity`, `manual` (previously `auto`, `manual`, `none`)
  - Spec validator updated to match canonical schema values
  - Legacy values automatically mapped: `test` → `run-tests`, `auto` → `run-tests`

### Added

- **Auto-fix for `INVALID_VERIFICATION_TYPE`**: Specs with legacy verification types are now auto-fixable via `validate-fix`
- **Auto-fix for `INVALID_ROOT_PARENT`**: Specs where spec-root has non-null parent are now auto-fixable

### Removed

- Removed `foundry-mcp-ctl` package and mode-toggling feature - server now always runs with all tools registered

## [0.3.4] - 2025-12-21

_Note: Mode toggling features added in this version were subsequently removed._

## [0.3.3] - 2025-12-17

### Changed
- **Dashboard**: Refactored pages module to views with cleaner organization
- **Dashboard**: Improved data stores with better caching and filtering
- **Observability**: Added action label to tool metrics for router-level granularity
- **Providers**: Codex CLI now ignores unsupported parameters (warning instead of error)

### Added
- Dashboard PID file tracking for cross-CLI process management
- Tool usage dashboard view with action-level breakdown
- OpenCode Node.js wrapper for subprocess execution
- Integration tests for provider smoke testing, fidelity review flow, and plan review flow

### Fixed
- Codex provider environment handling (unsets OPENAI_API_KEY/OPENAI_BASE_URL that interfere with CLI)
- Minor fixes to Claude and Gemini providers

## [0.3.2] - 2025-12-16

### Added
- Launcher script (`bin/foundry-mcp`) for configurable Python interpreter selection
- `FOUNDRY_MCP_PYTHON` environment variable to override the default Python interpreter

### Fixed
- Removed duplicate `spec_id` and `node_id` fields from task progress response

## [0.3.1] - 2025-12-16

### Removed
- Removed `code` unified tool (find-class, find-function, callers, callees, trace, impact actions) from MCP surface. Unified manifest reduced from 17 to 16 tools.

## [0.3.0] - 2025-12-15

### Changed
- Consolidated the MCP tool surface into 17 unified routers (tool + `action`) and aligned CLI/MCP naming.
- Updated documentation and manifests to reflect the unified router contract.

### Added
- New completed specs documenting MCP tool consolidation and removal of docquery/rendering/docgen.
- Unified-manifest budget telemetry (Prometheus metrics, recording rules, alerting rules, and dashboard panels).

### Removed
- Legacy per-tool MCP modules and legacy CLI command surfaces in favor of unified routers.
- Docquery/rendering/docgen modules and generated docs previously under `docs/generated/`.

## [0.2.1] - 2025-12-08

### Changed
- **Dashboard**: Replaced aiohttp+vanilla JS dashboard with Streamlit for better visualizations and interactivity
- Dashboard dependencies changed from `aiohttp` to `streamlit`, `plotly`, `pandas`
- Default dashboard port changed from 8080 to 8501 (Streamlit default)

### Added
- New Streamlit dashboard with 5 pages: Overview, Errors, Metrics, Providers, SDD Workflow
- Interactive Plotly charts with zoom, pan, and hover tooltips
- Data export functionality (CSV/JSON download buttons)
- Cached data access via `@st.cache_data` for performance
- CLI commands: `dashboard start`, `dashboard stop`, `dashboard status`
- New SDD Workflow page for spec progress tracking, phase burndown, task status
- Plan review tool (`plan-review`) for AI-assisted specification review

### Removed
- Old aiohttp-based dashboard server and static JS/CSS files
