Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,18 @@ This document contains comprehensive TODOs and recommendations based on a detail
- More concise syntax
- Aligns with original design intent

### TODO-003: Fix Hanging Test in PlanChunking Tool
### TODO-003: Fix Hanging Test in PlanChunking Tool ✅ COMPLETED
**Priority**: High | **Complexity**: Medium
**Context**: The test `PlanChunking_WithValidMember_ReturnsChunkPlan` in `ToolImplementationTests.cs` hangs indefinitely and never completes, causing CI/testing issues.

**Root Cause Analysis**:
- Test calls `PlanChunkingTool.PlanChunking()` which internally calls `DecompilerService.DecompileMember()` and `GetSourceSlice()`
- Issue likely in decompilation process rather than chunking logic itself
- DecompilerService decompiles entire containing type for methods/fields/properties (lines 153, 158, 163, 168 in DecompilerService.cs)
- Potential infinite loop or very slow decompilation when processing test assembly members
- Test times out after 10+ seconds, indicating genuine hang rather than slow operation

**Investigation Needed**:
- Add timeout protection to decompilation calls in PlanChunking tool
- Identify which specific member ID causes the hang (test finds first non-constructor method)
- Consider caching issues or circular reference in decompiler
- May need fallback mechanism or early termination for problematic members

**Immediate Fix**: Add timeout wrapper around decompilation calls in PlanChunking tool to prevent infinite hangs.
**Context**: The test `PlanChunking_WithValidMember_ReturnsChunkPlan` in `ToolImplementationTests.cs` was hanging indefinitely due to an infinite loop in the chunking logic.

**Root Cause**: The infinite loop prevention logic in PlanChunking tool was flawed. When `currentStart = currentEnd + 1 - overlap`, if the overlap was large enough, `currentStart` would not advance, causing an infinite loop.

**Fix Applied**:
- Simplified and fixed the infinite loop prevention logic to ensure `currentStart` always advances
- Changed the logic to `if (nextStart <= currentStart) { nextStart = currentStart + 1; }`
- Test now passes reliably in ~1 second instead of hanging indefinitely

**Status**: ✅ COMPLETED - Fix verified, all tests passing

### TODO-004: Standardize Pagination Across All Tools
**Priority**: High | **Complexity**: Low
Expand Down
10 changes: 6 additions & 4 deletions Tools/PlanChunking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ public static string PlanChunking(string memberId, int targetChunkSize = 6000, i
(currentEnd - currentStart + 1) * avgCharsPerLine));

// Move to next chunk with overlap consideration
currentStart = currentEnd + 1 - overlap;
var nextStart = currentEnd + 1 - overlap;

// Prevent infinite loop if overlap is too large
if (currentStart <= currentEnd - targetLinesPerChunk + overlap)
// Prevent infinite loop by ensuring we always advance
if (nextStart <= currentStart)
{
currentStart = currentEnd + 1;
nextStart = currentStart + 1;
}

currentStart = nextStart;
}

result = new ChunkPlanResult(
Expand Down