splice 2.6.1

Span-safe refactoring kernel for 7 languages with Magellan code graph integration
Documentation
# Splice Current State Assessment

**Generated**: 2026-02-03
**Updated**: 2026-02-04 (Phase 27 cleanup complete)
**Version**: v2.2.4
**Status**: 85% production ready

---

## Executive Summary

Splice provides solid core refactoring capabilities with excellent safety features. **Ingestion is working via MagellanIngestor integration** — Splice delegates code graph operations to Magellan (the tool designed for it) and focuses on span-safe editing.

**Health Score**: 85% — Core solid, well-integrated with Magellan
**Languages Supported**: 7 (Rust, Python, C, C++, Java, JavaScript, TypeScript)
**Integration**: Working with OdinCode via CLI wrapper

---

## What Works Well

| Component | Status | Location |
|-----------|--------|----------|
| **MagellanIngestor** | ✅ Complete | `src/ingest/magellan.rs` |
| **extract_symbols()** | ✅ Complete | `src/ingest/dispatch.rs` |
| **All 7 language extractors** | ✅ Complete | rust.rs, python.rs, cpp.rs, java.rs, javascript.rs, typescript.rs |
| **Import extraction** | ✅ Complete | `src/ingest/imports/` |
| **Semantic kind detection** | ✅ Complete | `src/ingest/semantic_kind.rs` (15KB) |
| Span-safe byte editing | ✅ Complete | Uses ropey for safe edits |
| AST validation | ✅ Complete | tree-sitter parsing |
| Compiler validation | ✅ Complete | cargo check, python -m py_compile, etc. |
| Atomic writes | ✅ Complete | Rollback on failure |
| Backup/undo | ✅ Complete | Operations tracked in .splice/ |
| Rust support | ✅ Complete | Full cross-file refactoring |
| CLI interface | ✅ Complete | patch, delete, plan, undo commands |

---

## External Dependencies (By Design)

### ✅ Magellan Integration — Working

**Location**: `src/ingest/magellan.rs`
**Impact**: Splice uses Magellan for code graph operations (by design)
**Severity**: N/A — This is the intended architecture

**How it works**:
```rust
use splice::ingest::magellan::MagellanIngestor;

let mut ingestor = MagellanIngestor::new(&db_path)?;
let count = ingestor.index_file(&file_path)?;  // ← WORKS
```

**Why this design**: Magellan provides production-quality multi-language code graph. Splice focuses on span-safe editing rather than duplicating Magellan's functionality.

**Known Magellan Issue**:
> Magellan BUG #1: Missing reference byte offsets
> **Impact**: Splice rename operations limited (Magellan issue, not Splice)
> **Status**: Being worked on by Magellan maintainers

---

### ⚠️ LIMITATION #1: Persistent Symbol Database

**Impact**: No local symbol caching, queries hit Magellan DB directly
**Severity**: MEDIUM

**Current Behavior**:
- Splice queries Magellan's database directly
- No local symbol caching between runs
- Each query opens Magellan database

**Desired Behavior** (Future):
- `.splice/symbols.db` for local symbol caching
- Faster queries with local cache
- Still uses Magellan as source of truth

**Estimated Effort**: 1-2 weeks (nice-to-have optimization)

---

## Important Limitations

### 🟡 LIMITATION #1: Cross-File Delete — Rust Only

**Location**: `src/commands/delete.rs`
**Impact**: Limited refactoring for non-Rust languages

**Current State**:
| Language | Cross-File Delete | Notes |
|----------|-------------------|-------|
| Rust | ✅ Full | Uses cargo metadata |
| Python | ⚠️ Basic | Definition only |
| C/C++ | ⚠️ Basic | Definition only |
| Java | ⚠️ Basic | Definition only |
| JavaScript/TypeScript | ⚠️ Basic | Definition only |

**Why**: Full cross-file requires import tracking for each language

**Estimated Effort**: 3-4 weeks (for all 6 non-Rust languages)

---

### 🟡 LIMITATION #2: No Resume Mode

**Impact**: Failed plans must restart from beginning
**Severity**: MEDIUM

**Current**: If `splice plan` fails, you rerun everything
**Desired**: Checkpoint system for resumable plans

**Estimated Effort**: 1-2 weeks

---

## Integration with OdinCode

### Current Integration

**Location**: `odincode/src/execution_engine/tool_mapper/splice_tools.rs`

**How It Works**:
```rust
// OdinCode wraps Splice CLI
let output = Command::new("splice")
    .args(["patch", "--symbol", symbol_name, "--with", replacement])
    .output()?;

// Parse JSON output
let result: SpliceResult = serde_json::from_slice(&output.stdout)?;
```

**Status**: ✅ Working
- All splice operations wrapped
- Comprehensive test coverage
- API compatibility maintained

---

## Dependency on Magellan

### Critical Connection

**Splice needs from Magellan**:
1. **Byte-accurate symbol locations** — For precise editing
2. **Reference edges with positions** — For rename refactoring

**Current Blocker**:
> Magellan BUG #1: Missing reference byte offsets
> **Impact**: Splice cannot do bulk renames

**When Magellan is fixed**:
- Splice rename operations will work end-to-end
- Cross-file refactoring will be reliable

---

## Performance Characteristics

| Operation | Latency | Notes |
|-----------|---------|-------|
| Single file patch | 50-200ms | AST + compiler validation |
| Cross-file rename | 500ms-2s | Depends on reference count |
| Plan execution | Variable | Depends on operations |

---

## Code Quality

| Aspect | Status | Notes |
|--------|--------|-------|
| Safety features | ✅ Excellent | Checksums, rollback, UTF-8 validation |
| Error handling | ✅ Good | Result types, clear errors |
| Tests | ✅ Comprehensive | Good coverage |
| TODO markers | ⚠️ Some present | Line count hardcoded to 0, etc. |

---

## Limitations of Current Design

| Limitation | Impact | Mitigation |
|------------|--------|------------|
| No macro tracking | Misses macro-generated refs | Document limitation |
| No qualified paths | Simple name matching only | Document limitation |
| Single-hop re-exports | Limited chain following | Document limitation |

---

## Roadmap

### Phase 1: Core Independence (2-3 weeks)

**Implement ingestion pipeline** — Highest impact

- [ ] Implement `ingest_file()` for all 7 languages
- [ ] Implement `ingest_dir()` with parallel processing
- [ ] Add symbol storage to local SQLite database
- [ ] Create incremental update support

**Outcome**: Splice can work standalone, no external Magellan required

---

### Phase 2: Feature Parity (3-4 weeks)

**Full cross-file delete for all languages**

- [ ] Python import tracking (ast module)
- [ ] C/C++ include tracking
- [ ] Java import tracking
- [ ] JavaScript/TypeScript import tracking
- [ ] Update delete command for all languages

---

### Phase 3: Reliability (1-2 weeks)

**Resume mode for failed plans**

- [ ] Add checkpoint/rollback mechanism
- [ ] Implement state persistence
- [ ] Add recovery command

---

### Phase 4: Performance (1-2 weeks)

**Optimizations**

- [ ] Persistent symbol database
- [ ] Cache frequently accessed symbols
- [ ] Parallel processing for batch operations

---

## Priority Ranking

| Priority | Item | Effort | Impact |
|----------|------|--------|--------|
| 🔴 P0 | Ingestion pipeline | 2-3 weeks | Unlocks standalone usage |
| 🟡 P1 | Persistent symbol DB | 2-3 weeks | Performance, UX |
| 🟡 P2 | Cross-file delete (all langs) | 3-4 weeks | Feature parity |
| 🟢 P3 | Resume mode | 1-2 weeks | Reliability |
| 🔵 P4 | Performance | 1-2 weeks | Nice to have |

---

## Dependency on Other Tools

| Tool | Version | For What | Status |
|------|---------|---------|--------|
| Magellan | 1.7.0+ | Symbol database | ⚠️ Has critical bug |
| tree-sitter | Latest | AST parsing | ✅ Working |
| ropey | Latest | Safe edits | ✅ Working |

---

## Quick Win (Coordination)

**Two things needed together**:

1. **Magellan**: Fix reference byte offsets (1-2 days)
2. **Splice**: Add ingestion pipeline (2-3 weeks)

**Outcome**: Complete standalone refactoring tool

---

## When to Work on Splice

**Recommended sequence**:
1. Fix Magellan reference bug first (unlocks rename)
2. Implement Splice ingestion (enables standalone)
3. Add cross-file support for remaining languages

**Total Effort**: ~4-6 weeks for full functionality

---

*Generated as part of ecosystem assessment 2026-02-03*