Fix P0 bug: JSONL lookup now returns LAST match (bd-58c0)
Addresses code review feedback: ✅ P0 (Must Fix): - Fix JSONL lookup to return LAST match, not FIRST (resurrection.go:160-162) - Changed from early return to scan all matches and keep last - Respects JSONL append-only semantics ✅ P1 (Should Fix): - Add test for multiple JSONL versions - TestTryResurrectParent_MultipleVersionsInJSONL verifies correct behavior - Document error message change in CHANGELOG.md - Old: "parent issue X does not exist" - New: "parent issue X does not exist and could not be resurrected from JSONL history" - Marked as breaking change for script parsers ✅ P2/P3 (Nice to Have): - Add documentation to AGENTS.md explaining auto-resurrection behavior - Document best-effort dependency resurrection ⏸️ Deferred (P1 - Optimize batch resurrection): - Caching optimization deferred (no batch use cases currently) All tests pass: - Unit tests: internal/storage/sqlite/ - Integration test: TestImportWithDeletedParent
This commit is contained in:
@@ -133,6 +133,7 @@ func (s *SQLiteStorage) findIssueInJSONL(issueID string) (*types.Issue, error) {
|
||||
scanner.Buffer(buf, maxCapacity)
|
||||
|
||||
lineNum := 0
|
||||
var lastMatch *types.Issue
|
||||
for scanner.Scan() {
|
||||
lineNum++
|
||||
line := scanner.Text()
|
||||
@@ -156,9 +157,10 @@ func (s *SQLiteStorage) findIssueInJSONL(issueID string) (*types.Issue, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if this is the issue we're looking for
|
||||
// Keep the last occurrence (JSONL append-only semantics)
|
||||
if issue.ID == issueID {
|
||||
return &issue, nil
|
||||
issueCopy := issue
|
||||
lastMatch = &issueCopy
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +168,7 @@ func (s *SQLiteStorage) findIssueInJSONL(issueID string) (*types.Issue, error) {
|
||||
return nil, fmt.Errorf("error reading JSONL file: %w", err)
|
||||
}
|
||||
|
||||
return nil, nil // Not found
|
||||
return lastMatch, nil // Returns last match or nil if not found
|
||||
}
|
||||
|
||||
// TryResurrectParentChain recursively resurrects all missing parents in a hierarchical ID chain.
|
||||
|
||||
Reference in New Issue
Block a user