Skip to content

Commit 281143c

Browse files
realmarcinclaude
andcommitted
Resolve merge conflicts and integrate iterative module functionality
- Resolved conflicts in src/fitness_mcp/main.py MCP tool registrations - Added minimal PairsDataLoader class using MetadataRegistry backend - Restored build_iterative_module and discover_functional_modules functions - Moved script files from src/scripts/ to src/fitness_mcp/ as intended - Combined fitness network tools with iterative module building tools - Maintained compatibility with new MetadataRegistry architecture Merge includes: - New MetadataRegistry centralized architecture - Enhanced testing infrastructure - Updated documentation and configuration - Combined tool registrations for comprehensive fitness analysis 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2 parents 65f95f7 + 9c48233 commit 281143c

24 files changed

Lines changed: 3817 additions & 1988 deletions

.claude/settings.local.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

.gitignore

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,19 @@ $RECYCLE.BIN/
221221
.nfs*
222222

223223
# Project-specific
224-
# Claude logs and demos
225-
claude-*.log
226-
*.claude.log
224+
# Logs directory
225+
logs/
227226

228227
# MCP specific
229228
.mcp/
230229
mcp.log
230+
231+
# Claude Code configuration and cache files
232+
.claude/
233+
**/.claude/
234+
.claude.json
235+
**/.claude.json
236+
237+
# LibreOffice/Office lock files
238+
.~lock.*#
239+
**/.~lock.*#

CLAUDE.md

Lines changed: 127 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,39 @@ This document establishes development patterns and guidelines for the fitness-mc
66

77
The Fitness MCP is a FastMCP server for analyzing gene fitness data from barcoded Agrobacterium mutant libraries. It efficiently handles a 90MB TSV dataset and provides scientific analysis tools for competitive fitness experiments.
88

9-
## Build & Test Commands
9+
## Key Development Commands
1010

11-
### Development Setup
12-
- Install dependencies: `uv sync --dev`
11+
### Essential Commands
1312
- Run MCP server: `uv run fitness-mcp`
14-
- Run in global mode: `uvx fitness-mcp`
13+
- Test fitness protocol: `make test-fitness-protocol`
14+
- Test gene analysis: `make test-gene-analysis`
15+
- Claude demo: `make demo-atu3150-function`
16+
- Full development cycle: `make all`
1517

16-
### Code Quality
17-
- Lint code: `uv run ruff check src/`
18-
- Fix lint issues: `uv run ruff check --fix src/`
19-
- Format code: `uv run ruff format src/`
20-
- Type check: `uv run mypy src/`
18+
### GitHub Issue Workflow
19+
For each GitHub issue, create a linked branch that will auto-close the issue when merged:
2120

22-
### Testing
23-
- Run all tests: `uv run pytest`
24-
- Run specific test: `uv run pytest tests/test_main.py::test_gene_lookup`
25-
- Run with coverage: `uv run pytest --cov=fitness_mcp`
21+
```bash
22+
# Create and switch to issue branch (auto-links to GitHub issue)
23+
git checkout -b issue-21-metadata-registry
24+
25+
# Work on the issue, making commits
26+
git add .
27+
git commit -m "Implement MetadataRegistry class
28+
29+
Addresses issue #21 by creating centralized metadata access.
30+
🤖 Generated with [Claude Code](https://claude.ai/code)"
31+
32+
# When ready, push and create PR
33+
git push -u origin issue-21-metadata-registry
34+
gh pr create --title "Implement Centralized Metadata Registry" --body "Closes #21"
35+
```
36+
37+
**Branch Naming Convention**: `issue-{number}-{short-description}`
38+
- `issue-21-metadata-registry`
39+
- `issue-22-eliminate-redundancy`
40+
- `issue-23-consistent-naming`
41+
- `issue-24-posix-tools`
2642

2743
## Architecture Principles
2844

@@ -166,29 +182,83 @@ return gene_info # Raw internal data structure
166182
```
167183
fitness-mcp/
168184
├── src/fitness_mcp/
169-
│ └── main.py # All MCP logic (currently monolithic)
185+
│ └── main.py # All MCP logic with 3 data loaders
170186
├── data/
171187
│ ├── fit_t.tab # Main fitness data (90MB TSV)
172-
│ └── exp_organism_Agro.txt # Experimental condition descriptions
188+
│ ├── exp_organism_Agro.txt # Experimental condition descriptions
189+
│ ├── RbTnSeq_modules_t1e-7.csv # Gene modules data
190+
│ ├── module_meta.tsv # Module metadata
191+
│ └── fit_t_pairs_threshold_2_long.tab # Significant gene-condition pairs
173192
├── tests/
174-
│ └── test_main.py # Unit tests
193+
│ ├── test_main.py # Core MCP tool tests
194+
│ └── test_integration.py # Integration tests
195+
├── prompts/
196+
│ └── fitness-demo-prompt.txt # Claude demo prompt
197+
├── logs/ # All log files (gitignored)
198+
├── Makefile # Build, test, and demo targets
175199
├── pyproject.toml # Project configuration
176200
├── README.md # User documentation
177201
└── CLAUDE.md # Development guide (this file)
178202
```
179203

180204
### Code Organization Within main.py
181-
The current monolithic structure is organized in logical sections:
205+
The monolithic structure contains three main data loaders:
182206

183-
1. **Imports and Setup** (lines 1-20)
184-
2. **Data Loading Class** (lines 21-340)
185-
3. **MCP Tool Functions** (lines 341-580)
186-
4. **FastMCP Registration** (lines 581-600)
207+
1. **FitnessDataLoader** (lines 214-477) - Main fitness data with thread safety
208+
2. **ModuleDataLoader** (lines 23-212) - Gene functional modules
209+
3. **PairsDataLoader** (lines 563-663) - Significant fitness pairs
210+
4. **MCP Tool Functions** (lines 672-1175) - 16 analysis tools
211+
5. **FastMCP Registration** (lines 1177-1206) - Server setup
187212

188-
Future refactoring should maintain this logical separation.
213+
All loaders follow TSV best practices with caching, file change detection, and thread safety.
189214

190215
## Testing Standards
191216

217+
### No Mocks or Patches Policy
218+
**NEVER use mocks, patches, or similar test doubles.** Tests should use real implementations and real data.
219+
220+
```python
221+
# ✅ Good: Test with real data loaders and real logic
222+
def test_get_gene_info():
223+
result = get_gene_info("Atu0001")
224+
assert result["locusId"] == "Atu0001"
225+
226+
# ❌ Bad: Using mocks or patches
227+
@patch.object(fitness_loader, 'get_gene_info')
228+
def test_get_gene_info_mocked(mock_get): # DON'T DO THIS
229+
mock_get.return_value = {'locusId': 'Atu0001'}
230+
```
231+
232+
### Conservative Error Handling in Tests
233+
Be very conservative with try/except in tests. If something fails, we want to know about it immediately.
234+
235+
```python
236+
# ✅ Good: Let exceptions bubble up
237+
def test_gene_lookup():
238+
result = get_gene_info("Atu0001") # Will fail clearly if broken
239+
assert "locusId" in result
240+
241+
# ❌ Bad: Hiding failures with try/except
242+
def test_gene_lookup():
243+
try:
244+
result = get_gene_info("Atu0001")
245+
except Exception:
246+
assert False # Doesn't show what actually failed
247+
```
248+
249+
### No Async/Batch Processing
250+
**NEVER use async/await or batch processing.** MCP tools are called by LLM agents (Claude, Goose) that expect synchronous responses.
251+
252+
```python
253+
# ✅ Good: Synchronous tool functions
254+
def get_gene_info(gene_id: str) -> Dict[str, Any]:
255+
return fitness_loader.get_gene_info(gene_id)
256+
257+
# ❌ Bad: Async functions break MCP protocol
258+
async def get_gene_info_async(gene_id: str) -> Dict[str, Any]: # DON'T DO THIS
259+
return await fitness_loader.get_gene_info_async(gene_id)
260+
```
261+
192262
### Test Categories
193263
Use pytest markers for different test types:
194264

@@ -324,6 +394,41 @@ gene_id = row[0] # Get gene ID from first column
324394

325395
---
326396

397+
## GitHub Issue Workflow
398+
399+
When working on GitHub issues, follow this systematic approach:
400+
401+
1. **Create and checkout linked branch**: `git checkout -b issue-{number}-{short-description}`
402+
2. **Bring feature branch up to date with main**: Feature branches MUST always be brought up to date with main before completing work
403+
3. **Work on implementation** following all guidelines in this document
404+
4. **Test thoroughly** with comprehensive test suite
405+
5. **Run `make all` until all problems are fixed** - This is mandatory before completion
406+
6. **Commit and push** when complete
407+
7. **Create pull request** that auto-closes the issue when merged
408+
409+
### Branch Naming Convention
410+
- Format: `issue-{number}-{short-description}`
411+
- Examples: `issue-21-metadata-registry`, `issue-22-data-redundancy`
412+
- Use kebab-case for descriptions
413+
- Keep descriptions concise but descriptive
414+
415+
### Task Completion Requirements
416+
**ALWAYS run `make all` before considering any task complete.** This command runs the full validation pipeline:
417+
- Code formatting and linting
418+
- Type checking
419+
- Comprehensive test suite
420+
- Coverage verification
421+
- Integration testing
422+
- MCP protocol validation
423+
424+
**Repeat `make all` until zero errors remain.** Only then is a task ready for commit and push. This ensures:
425+
- No regressions introduced
426+
- All code quality standards met
427+
- Full functionality preserved
428+
- Ready for production deployment
429+
430+
---
431+
327432
## Future Development Guidelines
328433

329434
### Extensibility Patterns

0 commit comments

Comments
 (0)