# Requirements Archive: v2.0 Chunk Foundation

**Archived:** 2026-02-24
**Milestone:** v2.0 Chunk Foundation
**Status:** ✅ PARTIAL SHIP — CHUNK-01 and CHUNK-02 completed; remaining v2 requirements deferred to v2.1+

---

## Requirements Completed in v2.0

### Cluster A — Chunk-Level Display (HIGHEST PRIORITY)

- [x] **CHUNK-01**: `ChunkRecord` schema updated to `v4`: `start_line: int`, `end_line: int`, `chunk_name: str`, and `chunk_text: str` persisted in LanceDB; `ensure_schema_v4()` idempotent migration adds columns to existing tables without data loss; existing rows default to `start_line=0`, `end_line=0`, `chunk_name=""`, `chunk_text=""`
  - **Outcome**: Implemented in Phase 17. All three chunkers emit v4 fields. Round-trip contract verified. 330 tests green.

- [x] **CHUNK-02**: `corpus search` CLI output changed from 3-line snippet format to grep/compiler-error format: `path/to/file.md:42-67 [skill] score:0.021` on the primary line; chunk text (truncated to 200 chars) on the next line; format is IDE-clickable (VSCode, IntelliJ parse `file:line` natively)
  - **Outcome**: Implemented in Phase 18 via `format_result()`. `search_command` render loop replaced. 340 tests green.

---

## Requirements Deferred to v2.1+

### Cluster A (continued)

- [ ] **CHUNK-03**: MCP `corpus_search` tool response includes `start_line`, `end_line`, and `text` (full chunk text, untruncated) in each result object
  - **Deferred to**: v2.1 (Phase 19)

### Cluster C — Method-Level Sub-Chunking

- [ ] **SUB-01**: Python AST chunker produces a "header chunk" for each class
  - **Deferred to**: v2.1 (Phase 20)
- [ ] **SUB-02**: Python AST chunker produces a separate chunk for each method on a class; `ClassName.method_name` naming
  - **Deferred to**: v2.1 (Phase 20)
- [ ] **SUB-03**: TypeScript/JavaScript AST chunker produces per-method chunks for class bodies
  - **Deferred to**: v2.1 (Phase 21)
- [ ] **SUB-04**: 85%+ branch coverage on chunking modules
  - **Deferred to**: v2.1

### Cluster B — `chunk_name` Persistence and Filtering

- [ ] **NAME-01**: All three chunkers consistently populate `chunk_name`
  - **Note**: Partially done (chunk_name emitted by all chunkers via CHUNK-01); filter layer pending
  - **Deferred to**: v2.1 (Phase 22)
- [ ] **NAME-02**: `corpus search --name <fragment>` CLI flag
  - **Deferred to**: v2.1 (Phase 22)
- [ ] **NAME-03**: MCP `corpus_search` accepts `name: Optional[str]` parameter
  - **Deferred to**: v2.1 (Phase 22)

### Cluster D — MCP Sort + Score Normalisation

- [ ] **SORT-01**: MCP `corpus_search` accepts `sort_by` parameter
  - **Deferred to**: v2.1 (Phase 23/24)
- [ ] **NORM-01**: RRF scores normalised to 0–1 per query within the search engine
  - **Deferred to**: v2.1 (Phase 23)

### Cluster E — New Features

- [ ] **JSON-01**: `corpus search --output json` emits JSON array to stdout
  - **Deferred to**: v2.1/v2.2 (Phase 24)
- [ ] **GRAPH-01**: MCP `corpus_graph` tool accepting `slug`, returning upstream/downstream lists
  - **Deferred to**: v2.2 (Phase 25)

### Quality Requirements

- [ ] **QUAL-01**: 85%+ branch coverage on chunking modules
  - **Deferred to**: v2.1
- [ ] **QUAL-02**: Zero-hallucination parametrised integration test
  - **Partially done**: Round-trip test established in Phase 17; full cross-check deferred to v2.1
- [x] **QUAL-03**: `uv run ruff check .` exits 0; `uv run mypy src/` exits 0
  - **Outcome**: Maintained through v2.0. Zero violations, zero errors.
- [x] **QUAL-04**: All 320 existing tests continue to pass alongside new v2 tests
  - **Outcome**: 340 tests passing after v2.0.

---

## Traceability

| Requirement | Status | Milestone | Notes |
|-------------|--------|-----------|-------|
| CHUNK-01 | ✅ Complete | v2.0 | Phase 17 |
| CHUNK-02 | ✅ Complete | v2.0 | Phase 18 |
| CHUNK-03 | ⏳ Deferred | v2.1 | Phase 19 |
| SUB-01 | ⏳ Deferred | v2.1 | Phase 20 |
| SUB-02 | ⏳ Deferred | v2.1 | Phase 20 |
| SUB-03 | ⏳ Deferred | v2.1 | Phase 21 |
| SUB-04 | ⏳ Deferred | v2.1 | — |
| NAME-01 | ⏳ Deferred | v2.1 | Phase 22; chunk_name stored (CHUNK-01 done) |
| NAME-02 | ⏳ Deferred | v2.1 | Phase 22 |
| NAME-03 | ⏳ Deferred | v2.1 | Phase 22 |
| SORT-01 | ⏳ Deferred | v2.1 | Phase 23/24 |
| NORM-01 | ⏳ Deferred | v2.1 | Phase 23 |
| JSON-01 | ⏳ Deferred | v2.1/v2.2 | Phase 24 |
| GRAPH-01 | ⏳ Deferred | v2.2 | Phase 25 |
| QUAL-01 | ⏳ Deferred | v2.1 | — |
| QUAL-02 | ⚡ Partial | v2.1 | Round-trip exists; full contract in v2.1 |
| QUAL-03 | ✅ Complete | v2.0 | Maintained |
| QUAL-04 | ✅ Complete | v2.0 | 340 tests |
