Commit Graph

1432 Commits

Author SHA1 Message Date
Steve Yegge
d4b801fb34 Fix post-merge issues: indentation and EnsureIDs method signature 2025-11-04 23:26:28 -08:00
Steve Yegge
de23bd21a6 Merge gh-207-multi-repo: Multi-repo support with routing and hydration 2025-11-04 23:24:59 -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
fc0223854c Add remaining multi-repo files from bd-307 2025-11-04 23:12:41 -08:00
Steve Yegge
67710e4a0c Add multi-repo CLI commands and integrate with daemon sync 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
05529fe4c0 Implement multi-repo hydration layer with mtime caching (bd-307)
- Add repo_mtimes table to track JSONL file modification times
- Implement HydrateFromMultiRepo() with mtime-based skip optimization
- Support tilde expansion for repo paths in config
- Add source_repo column via migration (not in base schema)
- Fix schema to allow migration on existing databases
- Comprehensive test coverage for hydration logic
- Resurrect missing parent issues bd-cb64c226 and bd-cbed9619

Implementation:
- internal/storage/sqlite/multirepo.go - Core hydration logic
- internal/storage/sqlite/multirepo_test.go - Test coverage
- docs/MULTI_REPO_HYDRATION.md - Documentation

Schema changes:
- source_repo column added via migration only (not base schema)
- repo_mtimes table for mtime caching
- All SELECT queries updated to include source_repo

Database recovery:
- Restored from 17 to 285 issues
- Created placeholder parents for orphaned hierarchical children

Amp-Thread-ID: https://ampcode.com/threads/T-faa1339a-14b2-426c-8e18-aa8be6f5cde6
Co-authored-by: Amp <amp@ampcode.com>
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
d38a312583 Fix bd-3xq: Import gracefully handles missing parents
Implemented hybrid approach (topological sort + resurrection):

Phase 1: Import ordering (fixes latent bug)
- Sort issues by hierarchy depth before batch creation
- Create in depth-ordered batches (0→1→2→3)
- Ensures parents always created before children

Phase 2: Parent resurrection
- Attempt to resurrect missing parents from import batch
- Only fail if parent truly doesn't exist anywhere
- Enables deleted parent scenarios to work correctly

Benefits:
- Fixes import failure when parents deleted via bd-delete
- Handles parent-child pairs in same import batch
- Maintains referential integrity
- Enables multi-repo workflows with divergent deletion states

Amp-Thread-ID: https://ampcode.com/threads/T-14d3a206-aeac-4499-8ae9-47f3715e18fa
Co-authored-by: Amp <amp@ampcode.com>
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
83283878c6 chore: update metadata.json 2025-11-04 22:59:44 -08:00
Steve Yegge
b9edb8f8a2 revmoed some old cruft 2025-11-04 22:52:04 -08:00
Steve Yegge
019c34029f removed bogus old issues file 2025-11-04 22:50:36 -08:00
Steve Yegge
ff137611b4 Delete 110 old closed issues to trim database 2025-11-04 22:46:23 -08:00
Steve Yegge
3c21dfaaac Merge fix/import-missing-parents: Parent resurrection with P0 bug fixes 2025-11-04 22:44:58 -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
4c77631e48 Add comprehensive code review guide for resurrection feature
Detailed review guide covering:
- Backwards compatibility (highest priority)
- Transaction safety
- Resurrection logic correctness
- Integration points
- Testing coverage
- Edge cases
- Documentation

Includes specific code snippets, test workflows, and expected issues.
2025-11-04 22:25:33 -08:00
Steve Yegge
3cb2e790a9 Fix transaction conflict in TryResurrectParent (bd-58c0)
Refactored resurrection functions to accept optional *sql.Conn parameter:
- Added tryResurrectParentWithConn() internal function
- Added tryResurrectParentChainWithConn() internal function
- Updated CreateIssue to use conn-based resurrection
- Updated EnsureIDs to use conn-based resurrection

This eliminates 'database is locked' errors when resurrection
happens inside an existing transaction.

Fixes bd-58c0
2025-11-04 22:25:33 -08:00
Steve Yegge
c5865bc77e Add comprehensive tests for parent resurrection (bd-d19a Phase 3)
- Created resurrection_test.go with 9 unit tests covering:
  * Parent already exists (no-op)
  * Parent found in JSONL (successful resurrection)
  * Parent not in JSONL (graceful failure)
  * Missing JSONL file (graceful handling)
  * Malformed JSONL lines (skip with warning)
  * Dependency resurrection (best-effort)
  * Multi-level chain resurrection
  * Partial chain missing (stops at gap)
  * Idempotent resurrection

- Added integration test for deleted parent scenario
- Fixed resurrection.go dependency insertion (type column name)

All unit tests pass. Integration test reveals transaction conflict
that needs fixing (separate issue).

Relates to: bd-d19a
2025-11-04 22:25:33 -08:00
Steve Yegge
9e719afe8c docs: add next session guide for Phase 3 of bd-d19a 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
d6e2ff6151 Phase 1: Add topological sorting to fix import ordering
- Add sort.go with depth-based utilities (GetHierarchyDepth, SortByDepth, GroupByDepth)
- Sort issues by hierarchy depth before batch creation
- Create in depth-order batches (0→1→2→3)
- Fixes latent bug: parent-child pairs in same batch could fail if wrong order
- Comprehensive tests for all sorting functions
- Closes bd-37dd, bd-3433, bd-8b65

Part of bd-d19a (Fix import failure on missing parent issues)

Amp-Thread-ID: https://ampcode.com/threads/T-44a36985-b59c-426f-834c-60a0faa0f9fb
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 22:25:26 -08:00
Ben Lovell
b92e79f98e Fix pointer dereferencing in Update RPC handler (#223)
- Dereference Design, AcceptanceCriteria, Notes, and Assignee pointers in updatesFromArgs
- Fixes EOF errors when using --notes, --design, --assignee, or --acceptance-criteria flags
- Enhance TestUpdateIssue to verify all pointer-dereferenced fields are correctly stored
2025-11-04 22:10:56 -08:00
Steve Yegge
a40f9e1835 Add comprehensive tests for parent resurrection (bd-d19a Phase 3)
- Created resurrection_test.go with 9 unit tests covering:
  * Parent already exists (no-op)
  * Parent found in JSONL (successful resurrection)
  * Parent not in JSONL (graceful failure)
  * Missing JSONL file (graceful handling)
  * Malformed JSONL lines (skip with warning)
  * Dependency resurrection (best-effort)
  * Multi-level chain resurrection
  * Partial chain missing (stops at gap)
  * Idempotent resurrection

- Added integration test for deleted parent scenario
- Fixed resurrection.go dependency insertion (type column name)

All unit tests pass. Integration test reveals transaction conflict
that needs fixing (separate issue).

Relates to: bd-d19a
2025-11-04 13:26:57 -08:00
Steve Yegge
318709414e Update metadata 2025-11-04 13:18:55 -08:00
Steve Yegge
8530902a32 docs: add next session guide for Phase 3 of bd-d19a 2025-11-04 13:18:32 -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
f2cb91d1fb Phase 1: Add topological sorting to fix import ordering
- Add sort.go with depth-based utilities (GetHierarchyDepth, SortByDepth, GroupByDepth)
- Sort issues by hierarchy depth before batch creation
- Create in depth-order batches (0→1→2→3)
- Fixes latent bug: parent-child pairs in same batch could fail if wrong order
- Comprehensive tests for all sorting functions
- Closes bd-37dd, bd-3433, bd-8b65

Part of bd-d19a (Fix import failure on missing parent issues)

Amp-Thread-ID: https://ampcode.com/threads/T-44a36985-b59c-426f-834c-60a0faa0f9fb
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 13:03:20 -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
aa7ec9fdbc Resolve merge conflict: accept remote 2025-11-04 12:46:19 -08:00
Steve Yegge
14bdc6fe68 Add bd migrate --to-separate-branch command
Implements bd-caa9: migration tool for existing users to enable
separate branch workflow.

Features:
- bd migrate --to-separate-branch <branch> sets sync.branch config
- Validates branch names (no whitespace/empty)
- Dry-run support with --dry-run flag
- Idempotent (safe to run multiple times)
- JSON output support
- Clear next steps for users

Closes bd-caa9, bd-a101

Amp-Thread-ID: https://ampcode.com/threads/T-93c3427d-12a1-4d9a-8690-1d0cfe22188f
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 12:39:38 -08:00
Steve Yegge
f3f5c142ce bd sync: 2025-11-04 12:36:59 2025-11-04 12:36:59 -08:00
Steve Yegge
cc9f4127ca bd sync: 2025-11-04 12:32:53 2025-11-04 12:32:53 -08:00
Steve Yegge
f76f150997 Add import bug analysis for bd-3xq
Amp-Thread-ID: https://ampcode.com/threads/T-14d3a206-aeac-4499-8ae9-47f3715e18fa
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 12:25:53 -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
ba325a2931 Remove spurious test issues from issues.jsonl
These test issues (Frontend task, Backend task, Test Epic, etc.) were
accidentally committed during template feature development and kept
getting re-imported by auto-sync.

Restores issues.jsonl to the state before commit eb434dd.

Amp-Thread-ID: https://ampcode.com/threads/T-29a525fd-6b2d-4601-99ea-fce8c5cf6b13
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 11:26:21 -08:00