Commit Graph

504 Commits

Author SHA1 Message Date
Steve Yegge
c10a5bc839 bd sync: 2025-11-05 00:55:53 2025-11-05 00:55:53 -08:00
Steve Yegge
6c541edeed Database export: WASM issues now properly closed 2025-11-05 00:46:36 -08:00
Steve Yegge
e0c1872dd8 bd sync: 2025-11-05 00:44:55 2025-11-05 00:44:55 -08:00
Steve Yegge
fbe790aa40 feat: Add ancestor_id field and implement epic/child filtering
Amp-Thread-ID: https://ampcode.com/threads/T-22f7d7c5-6f7b-4783-beda-8494360d887a
Co-authored-by: Amp <amp@ampcode.com>
2025-11-05 00:44:41 -08:00
Steve Yegge
78fe709deb bd sync: 2025-11-05 00:41:02 2025-11-05 00:41:42 -08:00
Steve Yegge
8b9a486056 Fix critical import bug: preserve closed_at timestamps during sync
**Problem:**
Closed issues were silently reopening during git sync/import operations.
When importing an issue update, the importer built an updates map with
status='closed' but NO closed_at timestamp. The UpdateIssue() function's
manageClosedAt() would only set closed_at when status was CHANGING to
closed, not when it was already closed. Result: closed_at got cleared,
effectively reopening issues.

**Root Cause:**
1. Importer built updates map without closed_at field (lines 443-451, 519-528)
2. closed_at was not in allowedUpdateFields whitelist
3. manageClosedAt() only managed closed_at for status TRANSITIONS
4. Import of already-closed issue → closed_at lost → issue reopens

**Impact:**
- WASM issues (bd-44d0, bd-8507, etc.) were closed on Nov 4 (commit 0df9144)
- They reopened as 'open' status during sync on Nov 5 (commit 8c9814a)
- Users had to repeatedly close the same issues
- Data integrity violation: status=closed with closed_at=NULL

**Fix:**
1. Add closed_at to allowedUpdateFields whitelist
2. Add closed_at to importer updates maps (both external_ref and ID paths)
3. Update manageClosedAt() to skip auto-management if closed_at explicitly provided
   - Preserves import timestamps while maintaining auto-management for CLI operations

**Testing:**
- All internal/importer tests pass
- All internal/storage/sqlite tests pass
- Explicitly tests timestamp preservation in TestImportWithExternalRef

**Files Changed:**
- internal/importer/importer.go: Add closed_at to updates maps
- internal/storage/sqlite/sqlite.go: Allow closed_at updates, respect explicit values

Amp-Thread-ID: https://ampcode.com/threads/T-53ed6e45-9d04-4a35-97e9-d1ec36321ab0
Co-authored-by: Amp <amp@ampcode.com>
2025-11-05 00:41:10 -08:00
Steve Yegge
6f5687f934 bd sync: 2025-11-05 00:32:20 2025-11-05 00:32:20 -08:00
Steve Yegge
8c9814a827 bd sync: 2025-11-05 00:27:51 2025-11-05 00:27:51 -08:00
Steve Yegge
e774d80939 bd sync: 2025-11-05 00:17:06 2025-11-05 00:17:06 -08:00
Steve Yegge
0bf5c91cb3 Wire OrphanHandling through import pipeline (bd-8072)
- Added OrphanHandling type to sqlite package with 4 modes: strict/resurrect/skip/allow
- Updated EnsureIDs() to accept orphanHandling parameter and implement mode logic
- Added CreateIssuesWithOptions() that passes orphan handling through batch creation
- Made importer.OrphanHandling an alias to sqlite.OrphanHandling
- Importer now respects opts.OrphanHandling during batch issue creation

Next: Add import.orphan_handling config and wire through CLI commands
Amp-Thread-ID: https://ampcode.com/threads/T-bb7ffdd9-f444-4975-b5f7-bfff97cb92ff
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 23:53:44 -08:00
Steve Yegge
ee01574e5c bd sync: 2025-11-04 23:31:46 2025-11-04 23:31:46 -08:00
Steve Yegge
ede9c999fa Update beads.jsonl during merge 2025-11-04 23:24:58 -08:00
Steve Yegge
cac9ae6647 Add routing integration tests and documentation
- Created routing_integration_test.go with comprehensive routing tests
- Tests cover maintainer/contributor detection, explicit overrides, end-to-end multi-repo
- Added docs/ROUTING.md documenting auto-routing feature
- Closed bd-6u6g, bd-zmi5, bd-nzt4, bd-btsm (routing tests)
- Updated bd-4ms and bd-8hf with progress notes

All routing tests pass. Multi-repo auto-routing is complete.

Amp-Thread-ID: https://ampcode.com/threads/T-2ea8b2ed-ceb7-432e-91f1-1f527b0e7b4d
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 23:12:42 -08:00
Steve Yegge
6ab6f82c6e bd sync: 2025-11-04 17:01:01 2025-11-04 23:12:42 -08:00
Steve Yegge
d0f15d6f56 bd sync: 2025-11-04 17:00:50 2025-11-04 23:12:42 -08:00
Steve Yegge
58e915f22b Implement auto-routing for bd create (bd-ubu2)
- Add internal/routing package with DetectUserRole and DetermineTargetRepo
- Add routing config schema (mode, default, maintainer, contributor)
- Add --repo flag to bd create for explicit override
- Integrate routing logic into create command
- Test with contributor/maintainer roles and explicit override

Part of bd-8hf (Auto-routing and maintainer detection)
2025-11-04 23:12:42 -08:00
Steve Yegge
8bcb8a40f1 bd sync: 2025-11-04 16:51:29 2025-11-04 23:12:41 -08:00
Steve Yegge
13c552a239 bd sync: 2025-11-04 16:32:36 2025-11-04 23:12:41 -08:00
Steve Yegge
7a1447444c Add multi-repo config schema and source_repo metadata
For bd-307: Multi-repo hydration layer

Changes:
- Add MultiRepoConfig to internal/config
- Add GetMultiRepoConfig() to retrieve repos.primary and repos.additional
- Add source_repo field to Issue type to track ownership
- Prepare for hydration logic that reads from N repos
2025-11-04 23:12:39 -08:00
Steve Yegge
b7f2c34dcd bd sync: 2025-11-04 12:25:08 2025-11-04 23:11:54 -08:00
Steve Yegge
d7bc30d88c Update bd-4ms and bd-307 to in_progress status
Amp-Thread-ID: https://ampcode.com/threads/T-97e07ae5-417f-4c3d-9574-630484c5beb9
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 23:11:54 -08:00
Steve Yegge
ff137611b4 Delete 110 old closed issues to trim database 2025-11-04 22:46:23 -08:00
Steve Yegge
001b74b9c3 bd sync: 2025-11-04 22:27:00 2025-11-04 22:27:00 -08:00
Steve Yegge
f1e17c2fcf Merge branch 'fix/import-missing-parents' of github.com:steveyegge/beads into fix/import-missing-parents
Amp-Thread-ID: https://ampcode.com/threads/T-cc299337-55ef-4b3e-b090-d12521080b54
Co-authored-by: Amp <amp@ampcode.com>

# Conflicts:
#	.beads/beads.jsonl
#	internal/storage/sqlite/ids.go
#	internal/storage/sqlite/resurrection.go
#	internal/storage/sqlite/resurrection_test.go
#	internal/storage/sqlite/sqlite.go
2025-11-04 22:26:11 -08:00
Steve Yegge
3af353ade3 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
2025-11-04 22:25:33 -08:00
Steve Yegge
93195e336b feat(import): implement parent resurrection (bd-cc4f, bd-d76d, bd-02a4)
Phase 2 of fixing import failure on missing parent issues (bd-d19a).

Implemented:
- TryResurrectParent: searches JSONL history for deleted parents
- TryResurrectParentChain: recursively resurrects entire parent chains
- Creates tombstones (status=closed) to preserve hierarchical structure
- Modified EnsureIDs and CreateIssue to call resurrection before validation

When importing a child issue with missing parent:
1. Searches .beads/issues.jsonl for parent in git history
2. If found, creates tombstone with status=closed
3. Preserves original title and metadata
4. Appends original description to tombstone
5. Copies dependencies if targets exist

This allows imports to proceed even when parents were deleted,
enabling multi-repo workflows and normal database hygiene operations.

Part of bd-d19a (fix import failure on missing parents).

Amp-Thread-ID: https://ampcode.com/threads/T-a1c9e824-885e-40ce-a179-148cf39c7e64
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 22:25:33 -08:00
Steve Yegge
9cad8581d2 bd sync: 2025-11-04 13:18:13 2025-11-04 13:18:13 -08:00
Steve Yegge
b41d65d833 feat(import): implement parent resurrection (bd-cc4f, bd-d76d, bd-02a4)
Phase 2 of fixing import failure on missing parent issues (bd-d19a).

Implemented:
- TryResurrectParent: searches JSONL history for deleted parents
- TryResurrectParentChain: recursively resurrects entire parent chains
- Creates tombstones (status=closed) to preserve hierarchical structure
- Modified EnsureIDs and CreateIssue to call resurrection before validation

When importing a child issue with missing parent:
1. Searches .beads/issues.jsonl for parent in git history
2. If found, creates tombstone with status=closed
3. Preserves original title and metadata
4. Appends original description to tombstone
5. Copies dependencies if targets exist

This allows imports to proceed even when parents were deleted,
enabling multi-repo workflows and normal database hygiene operations.

Part of bd-d19a (fix import failure on missing parents).

Amp-Thread-ID: https://ampcode.com/threads/T-a1c9e824-885e-40ce-a179-148cf39c7e64
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 13:16:17 -08:00
Steve Yegge
b55359d7db bd sync: 2025-11-04 13:08:01 2025-11-04 13:08:01 -08:00
Steve Yegge
0df9144a2f Delete WASM zombie issues - switched to npm package 2025-11-04 13:07:34 -08:00
Steve Yegge
f58605f26f bd sync: 2025-11-04 13:06:31 2025-11-04 13:06:31 -08:00
Steve Yegge
7b3f762e81 bd sync: 2025-11-04 12:55:23 2025-11-04 12:55:23 -08:00
Steve Yegge
2618bee57f bd sync: 2025-11-04 12:46:20 2025-11-04 12:46:20 -08:00
Steve Yegge
f3f5c142ce bd sync: 2025-11-04 12:36:59 2025-11-04 12:36:59 -08:00
Steve Yegge
eae4fcbec7 bd sync: 2025-11-04 11:29:29 2025-11-04 11:29:29 -08:00
Steve Yegge
e0e15400a1 bd sync: 2025-11-04 11:26:20 2025-11-04 11:26:31 -08:00
Steve Yegge
040e06dfad bd sync: 2025-11-04 11:25:42 2025-11-04 11:25:42 -08:00
Steve Yegge
568c565e8c bd sync: 2025-11-04 10:38:13 2025-11-04 10:38:13 -08:00
Steve Yegge
47214ddfe2 bd sync: 2025-11-04 10:26:37 2025-11-04 10:26:37 -08:00
Steve Yegge
919da0da2c bd sync: 2025-11-04 10:25:11 2025-11-04 10:25:11 -08:00
Steve Yegge
ff914b2a2f bd sync: 2025-11-04 09:52:32 2025-11-04 09:52:32 -08:00
Steve Yegge
85e1cc13de test: add waitFor helper for event-driven testing
- Add test_wait_helper.go with waitFor() function for polling-based test assertions
- Used by daemon watcher platform tests for non-blocking event verification
- Sync beads.jsonl

Amp-Thread-ID: https://ampcode.com/threads/T-80e427aa-40e0-48a6-82e0-e29a93edd444
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 01:10:18 -08:00
Steve Yegge
b1aec38b46 Fix :memory: database connection pool issue (bd-b121)
- Add db.SetMaxOpenConns(1) for :memory: databases
- SQLite shared cache mode requires single connection
- Fixes 'no such table' errors in VC and other consumers
- See bd-b121 for full details

Amp-Thread-ID: https://ampcode.com/threads/T-bbbb8f17-5ac0-4125-9035-e5488d3ebab1
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 00:59:22 -08:00
Steve Yegge
6e4a1589f4 Auto-sync issues 2025-11-04 00:38:23 -08:00
Steve Yegge
1009f0b263 Sync issues to JSONL
Amp-Thread-ID: https://ampcode.com/threads/T-c3fa2879-21ad-4918-b539-8f299e13f706
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 00:38:15 -08:00
Steve Yegge
efed596124 bd sync: 2025-11-04 00:37:56 2025-11-04 00:37:56 -08:00
Steve Yegge
abbdbf487a fix: Update dep_add test to match current show output format 2025-11-04 00:23:25 -08:00
Steve Yegge
7caab7aa9a bd sync: 2025-11-03 22:40:18 2025-11-03 22:40:18 -08:00
Steve Yegge
4e1e1f361c bd sync: 2025-11-03 22:23:29 2025-11-03 22:23:29 -08:00
Steve Yegge
21797db780 bd sync: 2025-11-03 21:31:40 2025-11-03 21:31:40 -08:00