chore: Complete lost issues recovery investigation (bd-229)

Successfully recovered 3 valuable issues from 22 total lost during auto-import bug:
- bd-222 → bd-232: Batching API feature request
- bd-223 → bd-233: Early context check optimization
- bd-221 context preserved in bd-89 notes

19 test fixtures identified but not recovered (no production value).

Auto-import collision detection fix (bd-228) prevents future data loss.

See LOST_ISSUES_RECOVERY.md for full investigation details.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-10-15 02:32:10 -07:00
parent 6b88d60d6e
commit 46258c6834
2 changed files with 101 additions and 2 deletions

View File

@@ -118,8 +118,12 @@
{"id":"bd-226","title":"Epic: Fix status/closed_at inconsistency (bd-224 solution)","description":"Implement hybrid solution to enforce status/closed_at invariant:\n- Database CHECK constraint\n- Smart UpdateIssue logic\n- Import enforcement\n- Reopen command\n\nThis is a data integrity issue that affects statistics and will cause problems for agent swarms. The hybrid approach provides defense-in-depth.\n\nSee ULTRATHINK_BD224.md for full analysis and rationale.\n\nParent of all implementation tasks for this fix.","status":"open","priority":1,"issue_type":"epic","created_at":"2025-10-15T01:58:41.041574-07:00","updated_at":"2025-10-15T01:58:41.041574-07:00"}
{"id":"bd-227","title":"Audit and document all inconsistent issues in database","description":"Before we add the constraint, we need to know what data is inconsistent.\n\nSteps:\n1. Query database for status/closed_at mismatches\n2. Document each case (how many, which issues, patterns)\n3. Decide on cleanup strategy (trust status vs trust closed_at)\n4. Create SQL script for cleanup\n\nOutput: Document with counts and cleanup SQL ready to review.\n\nThis unblocks the migration work.","status":"open","priority":1,"issue_type":"task","created_at":"2025-10-15T01:58:50.908363-07:00","updated_at":"2025-10-15T01:58:50.908363-07:00","dependencies":[{"issue_id":"bd-227","depends_on_id":"bd-226","type":"parent-child","created_at":"2025-10-15T01:58:50.909081-07:00","created_by":"stevey"}]}
{"id":"bd-228","title":"Critical: Auto-import silently overwrites local changes without collision detection","description":"## Problem\n\nAuto-import is silently overwriting local changes when pulling from Git, without using collision detection or warning the user.\n\n## Evidence\n\nIssue bd-89 timeline:\n1. 08:07:31 - Manual update: set status=in_progress\n2. 08:13:08 - Manual close: set status=closed, closed_at set\n3. 08:33:25 - **Auto-import silently overwrote to status=open** (discarded local change)\n4. 08:57:59 - Auto-import overwrote again\n5. 08:58:30 - Auto-import overwrote again\n\nQuery shows 10+ issues with multiple auto-import overwrites, including bd-198, bd-199, bd-200-206.\n\n## Root Cause Hypothesis\n\nWhen two clones both modify issue N:\n- Clone A: modifies bd-89, exports to JSONL, commits\n- Clone B: also modifies bd-89 differently, pulls from A\n- Auto-import uses UpdateIssue which **unconditionally overwrites**\n- Clone B's local changes are silently lost\n- No collision detection warning\n- References and work context corrupted\n\n## Impact\n\n- **Data loss**: Local changes silently discarded\n- **Corruption**: Issue state doesn't reflect actual work done\n- **Lost references**: Comments/deps referencing lost state are now wrong\n- **Trust**: Can't trust the database reflects reality\n- **Agent swarms**: Catastrophic for parallel workers\n\n## Expected Behavior\n\nAuto-import should:\n1. Detect collisions (same ID, different content)\n2. Warn user or fail import\n3. Offer resolution options (--resolve-collisions)\n4. Never silently overwrite without user confirmation\n\n## Current Behavior\n\nAuto-import silently overwrites using UpdateIssue, no collision detection.\n\n## Reproduction\n\n1. Clone A: bd update bd-1 --status in_progress\n2. Clone A: git add .beads/issues.jsonl \u0026\u0026 git commit \u0026\u0026 git push\n3. Clone B: bd update bd-1 --status closed \n4. Clone B: git pull (triggers auto-import)\n5. Result: bd-1 status silently reverted to in_progress, closed state lost\n\n## Files Involved\n\n- cmd/bd/main.go: auto-import trigger logic\n- cmd/bd/import.go: import without collision detection\n- internal/storage/sqlite/sqlite.go: UpdateIssue unconditionally overwrites","status":"closed","priority":0,"issue_type":"bug","created_at":"2025-10-15T02:06:30.671918-07:00","updated_at":"2025-10-15T02:11:30.794518-07:00","closed_at":"2025-10-15T02:11:30.794518-07:00"}
{"id":"bd-229","title":"Investigate data recovery for issues overwritten by auto-import bug","description":"Auto-import bug (bd-228) has been silently overwriting local changes since the feature was introduced. We need to investigate if any important data was lost and if it can be recovered.\n\n## Data Sources for Recovery\n\n1. **Git history of .beads/issues.jsonl** - May contain older versions with lost changes\n2. **Events table** - Has full audit trail with old_value/new_value\n3. **Commit messages** - May reference work that was done but later overwritten\n\n## Investigation Steps\n\n1. Check events table for patterns:\n - Look for auto-import events that changed status from closed → open\n - Look for manual updates followed by auto-import reverts\n - Identify issues with suspicious event sequences\n\n2. Git archaeology:\n - Check git log for .beads/issues.jsonl\n - Look for commits where status=closed was changed to status=open\n - Compare git history vs current database state\n\n3. Document lost work:\n - Create list of issues that were closed but reverted to open\n - Identify any critical work that was marked done but lost\n - Check if any issue references are now broken\n\n## Recovery Actions\n\nIf significant data loss is found:\n- Create script to reconstruct lost state from events table\n- Manually review and restore critical closed issues\n- Document lessons learned for preventing future data loss\n\n## Example Query\n\n```sql\n-- Find issues where status was manually changed then reverted by auto-import\nSELECT \n issue_id,\n GROUP_CONCAT(event_type || ':' || actor, ' -\u003e ') as event_chain\nFROM events \nWHERE issue_id IN (\n SELECT DISTINCT issue_id \n FROM events \n WHERE actor = 'auto-import' AND event_type = 'status_changed'\n)\nGROUP BY issue_id\nHAVING event_chain LIKE '%stevey%auto-import%';\n```","status":"open","priority":1,"issue_type":"task","created_at":"2025-10-15T02:10:40.724826-07:00","updated_at":"2025-10-15T02:10:40.724826-07:00","dependencies":[{"issue_id":"bd-229","depends_on_id":"bd-228","type":"discovered-from","created_at":"2025-10-15T02:10:40.740673-07:00","created_by":"stevey"}]}
{"id":"bd-229","title":"Investigate data recovery for issues overwritten by auto-import bug","description":"Auto-import bug (bd-228) has been silently overwriting local changes since the feature was introduced. We need to investigate if any important data was lost and if it can be recovered.\n\n## Data Sources for Recovery\n\n1. **Git history of .beads/issues.jsonl** - May contain older versions with lost changes\n2. **Events table** - Has full audit trail with old_value/new_value\n3. **Commit messages** - May reference work that was done but later overwritten\n\n## Investigation Steps\n\n1. Check events table for patterns:\n - Look for auto-import events that changed status from closed → open\n - Look for manual updates followed by auto-import reverts\n - Identify issues with suspicious event sequences\n\n2. Git archaeology:\n - Check git log for .beads/issues.jsonl\n - Look for commits where status=closed was changed to status=open\n - Compare git history vs current database state\n\n3. Document lost work:\n - Create list of issues that were closed but reverted to open\n - Identify any critical work that was marked done but lost\n - Check if any issue references are now broken\n\n## Recovery Actions\n\nIf significant data loss is found:\n- Create script to reconstruct lost state from events table\n- Manually review and restore critical closed issues\n- Document lessons learned for preventing future data loss\n\n## Example Query\n\n```sql\n-- Find issues where status was manually changed then reverted by auto-import\nSELECT \n issue_id,\n GROUP_CONCAT(event_type || ':' || actor, ' -\u003e ') as event_chain\nFROM events \nWHERE issue_id IN (\n SELECT DISTINCT issue_id \n FROM events \n WHERE actor = 'auto-import' AND event_type = 'status_changed'\n)\nGROUP BY issue_id\nHAVING event_chain LIKE '%stevey%auto-import%';\n```","notes":"Auto-import bug (bd-228) has been silently overwriting local changes since the feature was introduced. We investigated if any important data was lost and successfully recovered what could be salvaged.\n\n## Investigation Complete ✅\n\n**Date:** 2025-10-15\n**Status:** Data recovery completed, minimal impact\n\n## Findings\n\n### Lost Issues Recovered: 22 total\n- **bd-200 through bd-223** (excluding bd-211, bd-212, bd-224+)\n- Lost due to auto-import bug silently overwriting local changes during git pull\n\n### Breakdown\n1. **Test fixtures (19 issues):** bd-200 to bd-220\n - Temporary race_test_* and verification_* issues\n - **Action:** NOT recovered (no production value)\n\n2. **Real issues (3 issues):**\n - **bd-221 (P0, closed):** Transaction state corruption in first fix attempt\n - Already resolved, historical context preserved in bd-89 notes\n - **bd-222 (P2, open):** Batching API for bulk creation\n - **Recovered as bd-232** ✅\n - **bd-223 (P3, open):** Early context check optimization\n - **Recovered as bd-233** ✅\n\n## Recovery Actions Completed\n\n✅ **Git archaeology:** Extracted all 22 lost issues from git history \n✅ **Triage:** Identified 3 real issues vs 19 test fixtures \n✅ **References:** Verified no broken links (no code/docs referenced lost IDs) \n✅ **Re-filed:** Created bd-232 and bd-233 for the valuable open issues \n✅ **Documentation:** Added historical context to bd-89 for bd-221 \n✅ **Report:** Created LOST_ISSUES_RECOVERY.md with full details \n\n## Impact Assessment\n\n**Severity:** LOW to MEDIUM\n- 19 test fixtures lost (no impact)\n- 2 open feature/task requests lost (P2/P3 - minor)\n- 1 closed bug documentation lost (historical context only)\n\n**Data Loss:** Minimal. The most valuable issue (bd-221) was already resolved and closed. The two open issues are low-priority enhancements that have been successfully re-filed.\n\n## Prevention Measures\n\n✅ Auto-import now has collision detection (bd-228 fix) \n✅ Manual import has --dry-run and --resolve-collisions \n✅ Auto-export debounce ensures JSONL stays in sync \n\n**Future consideration:** Add warning if database has issues not in JSONL\n\n## References\n\n- Full recovery report: LOST_ISSUES_RECOVERY.md\n- Root cause: bd-228 (auto-import bug, now fixed)\n- Recovery commit example: dd613f4 (recovered bd-180, bd-181, bd-182)\n- Re-filed issues: bd-232 (batching API), bd-233 (context check)\n- Historical context preserved: bd-89 (notes field)\n\n## Conclusion\n\nInvestigation complete. Successfully recovered all valuable lost work with minimal effort. The auto-import bug has been fixed (bd-228) and proper collision detection is now in place. No further action required.","status":"closed","priority":1,"issue_type":"task","created_at":"2025-10-15T02:10:40.724826-07:00","updated_at":"2025-10-15T02:22:39.729396-07:00","closed_at":"2025-10-15T02:22:30.426785-07:00","dependencies":[{"issue_id":"bd-229","depends_on_id":"bd-228","type":"discovered-from","created_at":"2025-10-15T02:10:40.740673-07:00","created_by":"stevey"}]}
{"id":"bd-23","title":"Optimize export dependency queries (N+1 problem)","description":"Export triggers separate GetDependencyRecords() per issue. For large DBs (1000+ issues), this is N+1 queries. Add GetAllDependencyRecords() to fetch all dependencies in one query. Location: cmd/bd/export.go:52-59, import.go:138-142","status":"closed","priority":3,"issue_type":"task","created_at":"2025-10-14T14:43:06.910124-07:00","updated_at":"2025-10-15T01:58:30.041954-07:00"}
{"id":"bd-230","title":"Code review: Auto-import collision detection fix (bd-228)","description":"Request thorough code review of the auto-import collision detection implementation.\n\n## Files Changed\n- cmd/bd/main.go: autoImportIfNewer() and new autoImportWithoutCollisionDetection()\n\n## Review Focus Areas\n\n### 1. Correctness\n- Does collision detection properly identify conflicts?\n- Are colliding issues correctly filtered from import?\n- Is the fallback function correct for non-SQLite backends?\n\n### 2. Edge Cases\n- What happens if DetectCollisions() fails?\n- What if all issues are collisions?\n- What if JSONL is malformed?\n- Race conditions with concurrent auto-imports?\n\n### 3. User Experience\n- Is the warning message clear and actionable?\n- Should we log to a file instead of/in addition to stderr?\n- Should there be a --auto-resolve flag?\n\n### 4. Performance\n- Does collision detection add significant latency?\n- Will this work with 1000+ issues?\n- Any unnecessary N+1 queries?\n\n### 5. Testing Gaps\n- Do we need integration tests for collision scenarios?\n- Should we test the warning output?\n- Test autoImportWithoutCollisionDetection() fallback?\n\n## Questions for Reviewer\n1. Should auto-import be more aggressive (auto-resolve) or more conservative (fail)?\n2. Should we add a counter for how many times collisions occurred?\n3. Should there be a config option to disable collision detection?\n4. Is the warning too verbose for typical workflows?\n\n## Current Behavior\n- Skips colliding issues (preserves local)\n- Prints warning to stderr\n- Suggests manual resolution command\n- Continues with non-colliding issues","status":"open","priority":1,"issue_type":"task","created_at":"2025-10-15T02:12:48.210337-07:00","updated_at":"2025-10-15T02:12:48.210337-07:00","dependencies":[{"issue_id":"bd-230","depends_on_id":"bd-228","type":"discovered-from","created_at":"2025-10-15T02:12:48.212265-07:00","created_by":"stevey"}]}
{"id":"bd-231","title":"Add integration tests for auto-import collision detection","description":"The auto-import collision detection fix (bd-228) needs comprehensive integration tests.\n\n## Test Scenarios Needed\n\n### 1. Basic Collision Detection\n```go\nTestAutoImportWithCollisions\n- Setup: Create issue in DB with status=closed\n- Simulate: Git pull with JSONL containing same issue with status=open\n- Verify: Local changes preserved, warning printed, issue still closed\n```\n\n### 2. Multiple Collisions\n```go\nTestAutoImportWithMultipleCollisions\n- Setup: 5 issues with local modifications\n- Simulate: JSONL with 3 colliding, 2 matching\n- Verify: 3 skipped, 2 updated, appropriate warnings\n```\n\n### 3. No Collisions (Happy Path)\n```go\nTestAutoImportWithoutCollisions\n- Setup: Clean database\n- Simulate: JSONL with new issues + exact matches\n- Verify: All imported successfully, no warnings\n```\n\n### 4. All Collisions\n```go\nTestAutoImportAllCollisions\n- Setup: Every issue has local modifications\n- Simulate: JSONL with conflicting versions\n- Verify: All skipped, warning lists all issues\n```\n\n### 5. Collision Detection Failure\n```go\nTestAutoImportCollisionDetectionError\n- Setup: Mock DetectCollisions() to return error\n- Verify: Import skipped entirely (safe failure mode)\n```\n\n### 6. Hash-Based Skip\n```go\nTestAutoImportHashUnchanged\n- Setup: JSONL hash matches last_import_hash\n- Verify: No collision detection runs, fast path\n```\n\n### 7. Fallback for Non-SQLite\n```go\nTestAutoImportWithoutCollisionDetection\n- Setup: Mock non-SQLite storage backend\n- Verify: Falls back to old behavior, no collision detection\n```\n\n## Test Infrastructure Needed\n\n1. **Helper functions:**\n - createTestDBWithIssues()\n - writeJSONLFile()\n - captureStderrWarnings()\n - simulateGitPull()\n\n2. **Fixtures:**\n - sample-collisions.jsonl\n - sample-exact-matches.jsonl\n - sample-mixed.jsonl\n\n3. **Assertions:**\n - assertIssueState(id, expectedStatus)\n - assertWarningContains(text)\n - assertCollisionCount(n)\n\n## Acceptance Criteria\n- All 7 test scenarios implemented\n- Tests pass consistently\n- Code coverage \u003e80% for autoImportIfNewer()\n- Tests run in \u003c5 seconds total\n- Clear test names and documentation","status":"open","priority":1,"issue_type":"task","created_at":"2025-10-15T02:12:49.315295-07:00","updated_at":"2025-10-15T02:12:49.315295-07:00","dependencies":[{"issue_id":"bd-231","depends_on_id":"bd-230","type":"blocks","created_at":"2025-10-15T02:12:49.31615-07:00","created_by":"stevey"}]}
{"id":"bd-232","title":"Consider batching API for bulk issue creation (recovered from bd-222)","description":"Current CreateIssue acquires a dedicated connection for each call. For bulk imports or agent workflows creating many issues, a batched API could improve performance:\n\nCreateIssues(ctx, issues []*Issue, actor string) error\n\nThis would:\n- Acquire one connection\n- Use one IMMEDIATE transaction\n- Insert all issues atomically\n- Reduce connection overhead\n\nNot urgent - current approach is correct and fast enough for typical use.\n\n**Recovered from:** bd-222 (lost in auto-import bug, see LOST_ISSUES_RECOVERY.md)","status":"open","priority":2,"issue_type":"feature","created_at":"2025-10-15T02:21:43.085279-07:00","updated_at":"2025-10-15T02:21:43.085279-07:00"}
{"id":"bd-233","title":"Consider early context check in CreateIssue (recovered from bd-223)","description":"CreateIssue starts an IMMEDIATE transaction before checking if context is cancelled. If a client cancels early, we've already acquired the write lock.\n\nConsider adding:\n if err := ctx.Err(); err != nil {\n return err\n }\n\nBetween validation (line 318) and acquiring connection (line 331).\n\nLow priority - the busy_timeout and deferred cleanup handle this gracefully, but an early check would be slightly more efficient.\n\n**Recovered from:** bd-223 (lost in auto-import bug, see LOST_ISSUES_RECOVERY.md)","status":"open","priority":3,"issue_type":"task","created_at":"2025-10-15T02:21:44.4758-07:00","updated_at":"2025-10-15T02:21:44.4758-07:00"}
{"id":"bd-24","title":"Support ID space partitioning for parallel worker agents","description":"Enable external orchestrators (like AI worker swarms) to control issue ID assignment. Add --id flag to 'bd create' for explicit ID specification. Optionally support 'bd config set next_id N' to set the starting point for auto-increment. Storage layer already supports pre-assigned IDs (sqlite.go:52-71), just need CLI wiring. This keeps beads simple while letting orchestrators implement their own ID partitioning strategies to minimize merge conflicts. Complementary to bd-9's collision resolution.","status":"closed","priority":1,"issue_type":"feature","created_at":"2025-10-14T14:43:06.910467-07:00","updated_at":"2025-10-15T01:58:30.042402-07:00"}
{"id":"bd-25","title":"Add transaction support to storage layer for atomic multi-operation workflows","description":"Currently each storage method (CreateIssue, UpdateIssue, etc.) starts its own transaction. This makes it impossible to perform atomic multi-step operations like collision resolution. Add support for passing *sql.Tx through the storage interface, or create transaction-aware versions of methods. This would make remapCollisions and other batch operations truly atomic.","status":"closed","priority":4,"issue_type":"feature","created_at":"2025-10-14T14:43:06.910892-07:00","updated_at":"2025-10-15T01:58:30.043082-07:00"}
{"id":"bd-26","title":"Optimize reference updates to avoid loading all issues into memory","description":"In updateReferences(), we call SearchIssues with no filter to get ALL issues for updating references. For large databases (10k+ issues), this loads everything into memory. Options: 1) Use batched processing with LIMIT/OFFSET, 2) Use SQL UPDATE with REPLACE() directly, 3) Stream results instead of loading all at once. Located in collision.go:266","status":"open","priority":2,"issue_type":"task","created_at":"2025-10-14T14:43:06.911497-07:00","updated_at":"2025-10-15T01:58:30.043529-07:00"}
@@ -191,7 +195,7 @@
{"id":"bd-86","title":"GH-2: Evaluate optional Turso backend for collaboration","description":"RFC proposal for optional Turso/libSQL backend to enable: database branching, near-real-time sync between agents/humans, native vector search, browser-ready persistence (WASM/OPFS), and concurrent writes. Would be opt-in, keeping current JSONL+SQLite as default. Requires storage driver interface.","status":"open","priority":3,"issue_type":"feature","created_at":"2025-10-14T14:43:06.942254-07:00","updated_at":"2025-10-15T01:58:30.11535-07:00","external_ref":"gh-2"}
{"id":"bd-87","title":"GH-3: Debug zsh killed error on bd init","description":"User reports 'zsh: killed bd init' when running bd init or just bd command. Likely a crash or signal. Need to reproduce and investigate cause.","status":"open","priority":1,"issue_type":"bug","created_at":"2025-10-14T14:43:06.942576-07:00","updated_at":"2025-10-15T01:58:30.115833-07:00","external_ref":"gh-3"}
{"id":"bd-88","title":"GH-4: Consider system-wide/multi-repo beads usage","description":"User wants to use beads across multiple repositories and for sysadmin tasks. Currently beads is project-scoped (.beads/ directory). Explore options for system-wide issue tracking that spans multiple repos. Related question: how does beads compare to membank MCP?","status":"open","priority":3,"issue_type":"feature","created_at":"2025-10-14T14:43:06.942895-07:00","updated_at":"2025-10-15T01:58:30.116196-07:00","external_ref":"gh-4"}
{"id":"bd-89","title":"GH-6: Fix race condition in parallel issue creation","description":"Creating multiple issues rapidly in parallel causes 'UNIQUE constraint failed: issues.id' error. The ID generation has a race condition. Reproducible with: for i in {26..35}; do ./bd create parallel_ 2\u003e\u00261 \u0026 done","status":"open","priority":0,"issue_type":"bug","created_at":"2025-10-14T14:43:06.943239-07:00","updated_at":"2025-10-15T01:58:30.116562-07:00","closed_at":"2025-10-15T01:13:08.412107-07:00","external_ref":"gh-6"}
{"id":"bd-89","title":"GH-6: Fix race condition in parallel issue creation","description":"Creating multiple issues rapidly in parallel causes 'UNIQUE constraint failed: issues.id' error. The ID generation has a race condition. Reproducible with: for i in {26..35}; do ./bd create parallel_ 2\u003e\u00261 \u0026 done","notes":"**Historical context (recovered from lost issue bd-221):**\n\nFirst attempt at fixing this race condition had a critical flaw: used 'ROLLBACK; BEGIN IMMEDIATE' which executed as two separate statements. After ROLLBACK, the Go tx object was invalid but continued to be used, causing undefined behavior.\n\nRoot cause of failed fix: database/sql connection pooling. Without acquiring a dedicated connection, subsequent queries could use different connections from the pool, breaking the transaction.\n\nCorrect fix (the one that was merged): Use conn := s.db.Conn(ctx) to acquire a dedicated connection, then execute BEGIN IMMEDIATE, all operations, and COMMIT on that single connection.\n\nThis bug was caught during code review and fixed before merging.\n\nSee LOST_ISSUES_RECOVERY.md for details on bd-221.","status":"open","priority":0,"issue_type":"bug","created_at":"2025-10-14T14:43:06.943239-07:00","updated_at":"2025-10-15T02:21:55.770834-07:00","closed_at":"2025-10-15T01:13:08.412107-07:00","external_ref":"gh-6"}
{"id":"bd-9","title":"Build collision resolution tooling for distributed branch workflows","description":"When branches diverge and both create issues, auto-incrementing IDs collide on merge. Build excellent tooling to detect collisions during import, auto-renumber issues with fewer dependencies, update all references in descriptions and dependency links, and provide clear user feedback. Goal: keep beautiful brevity of numeric IDs (bd-302) while handling distributed creation gracefully.","status":"closed","priority":1,"issue_type":"feature","created_at":"2025-10-14T14:43:06.943629-07:00","updated_at":"2025-10-15T01:58:30.117069-07:00"}
{"id":"bd-90","title":"GH-7: Package available in AUR (beads-git)","description":"Community member created AUR package for Arch Linux: https://aur.archlinux.org/packages/beads-git. This is informational - no action needed, but good to track for release process and documentation.","status":"open","priority":4,"issue_type":"chore","created_at":"2025-10-14T14:43:06.943974-07:00","updated_at":"2025-10-15T01:58:30.117502-07:00","external_ref":"gh-7"}
{"id":"bd-91","title":"GH-9: Support markdown files in bd create","description":"Request to support markdown files as input to bd create, which would parse the markdown and split it into multiple issues. Use case: developers keep feature drafts in markdown files in version control, then want to convert them into issues. Example: bd create -f feature-draft.md","status":"closed","priority":2,"issue_type":"feature","created_at":"2025-10-14T14:43:06.944561-07:00","updated_at":"2025-10-15T01:58:30.117933-07:00","external_ref":"gh-9"}

95
LOST_ISSUES_RECOVERY.md Normal file
View File

@@ -0,0 +1,95 @@
# Lost Issues Recovery Report
**Investigation Date:** 2025-10-15
**Related Issue:** bd-229
**Root Cause:** Auto-import bug (bd-228) silently overwrote local changes
## Summary
Recovered **3 valuable issues** from 22 total lost issues (bd-200 through bd-223, excluding bd-211, bd-212) that were silently overwritten by the auto-import bug.
**Note:** 19 test fixtures (race_test_*, verification_*) were found but not documented here - they had no production value.
## Recovered Issues (3 total)
#### bd-221: Transaction state corruption (P0, CLOSED)
- **Title:** P0: Transaction state corruption in first fix attempt
- **Type:** bug (closed)
- **Priority:** 0
- **Description:** First attempt at fixing bd-89 had a critical flaw: used 'ROLLBACK; BEGIN IMMEDIATE' which executed as two separate statements. After ROLLBACK, the Go tx object was invalid but continued to be used, causing undefined behavior. Root cause: database/sql connection pooling. Correct fix: Use conn := s.db.Conn(ctx).
- **Status:** Fixed during code review before merging
- **Related:** bd-89 (GH-6: Fix race condition in parallel issue creation)
#### bd-222: Batching API for bulk creation (P2, OPEN)
- **Title:** P2: Consider batching API for bulk issue creation
- **Type:** feature
- **Priority:** 2
- **Description:** Current CreateIssue acquires a dedicated connection for each call. For bulk imports or agent workflows creating many issues, a batched API could improve performance: `CreateIssues(ctx, issues []*Issue, actor string) error`. This would acquire one connection, use one IMMEDIATE transaction, insert all issues atomically, and reduce connection overhead.
- **Status:** Open enhancement, not urgent
#### bd-223: Early context check optimization (P3, OPEN)
- **Title:** P3: Consider early context check in CreateIssue
- **Type:** task
- **Priority:** 3
- **Description:** CreateIssue starts an IMMEDIATE transaction before checking if context is cancelled. Consider adding early context check between validation (line 318) and acquiring connection (line 331). Low priority - the busy_timeout and deferred cleanup handle this gracefully.
- **Status:** Open optimization, low priority
## Recovery Actions
### Completed
1. ✅ Extracted all 22 lost issues from git history
2. ✅ Identified which are test fixtures vs real issues
3. ✅ Verified no broken references (no code/docs reference these IDs)
4. ✅ Confirmed bd-89 (referenced by bd-221 and bd-228) still exists
### Actions Taken
1.**Re-filed bd-222 as bd-232** - Batching API feature request
2.**Re-filed bd-223 as bd-233** - Early context check optimization
3.**Documented bd-221 in bd-89 notes** - Transaction fix historical context preserved
## Data Integrity Notes
### How Issues Were Lost
The auto-import bug (bd-228, now fixed) silently overwrote local changes when pulling from git. Issues bd-200 to bd-223 were likely:
1. Created locally by an agent or test run
2. Not exported to JSONL before git pull
3. Git pull triggered auto-import that didn't include these issues
4. Issues silently disappeared from database
### Prevention
- ✅ Auto-import now has collision detection (bd-228 fix)
- ✅ Manual import has --dry-run and --resolve-collisions
- ✅ Auto-export debounce ensures JSONL stays in sync
- Consider: Add warning if database has issues not in JSONL
## Git Archaeology Details
### Search Method
```bash
# Found highest numbered issue
git log --all -p -- .beads/issues.jsonl | grep -o '"id":"bd-[0-9]*"' | sort -rn
# Extracted removed issues
git log --all -p -- .beads/issues.jsonl | grep '^-{"id":"bd-2[0-2][0-9]"'
# Verified current state
bd list --json | jq -r '.[] | select(.id | startswith("bd-")) | .id'
```
### Current State
- **Total issues in DB:** 231 (bd-1 through bd-231, no gaps)
- **Lost issue range:** bd-200 through bd-223 (22 issues)
- **Last recovered commit:** dd613f4 (recovered bd-180, bd-181, bd-182)
## Full Lost Issue Data
Complete JSON of recovered issues available at `/tmp/real_lost_issues.jsonl`.
## Conclusion
**Impact Assessment:** LOW
- 2 open feature/task requests recovered (P2/P3) → bd-232, bd-233
- 1 closed bug context preserved in bd-89 notes
- 19 test fixtures discarded (no production value)
**Data Loss:** Minimal. All valuable issues successfully recovered. The auto-import bug has been fixed (bd-228) and proper collision detection is now in place.