Commit Graph

1454 Commits

Author SHA1 Message Date
Steve Yegge
6da54f49fa bd sync: 2025-11-05 00:55:40 2025-11-05 00:55:40 -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
23f09ee0c1 Update .beads metadata after sync
Amp-Thread-ID: https://ampcode.com/threads/T-d089540c-c172-440f-88c9-ff06bde6504d
Co-authored-by: Amp <amp@ampcode.com>
2025-11-05 00:41:42 -08:00
Steve Yegge
78fe709deb bd sync: 2025-11-05 00:41:02 2025-11-05 00:41:42 -08:00
Steve Yegge
7292c856dd Fix import to respect import.missing_parents config
When --orphan-handling flag not specified, import was passing empty string
instead of reading config or defaulting to 'allow'. This broke all imports
with hierarchical IDs after git pull.

Fix: Read import.missing_parents config, default to 'allow' if unset.
Priority: flag > config > default
Amp-Thread-ID: https://ampcode.com/threads/T-d089540c-c172-440f-88c9-ff06bde6504d
Co-authored-by: Amp <amp@ampcode.com>
2025-11-05 00:41:14 -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
626d51dd61 fix: Add npm-package to bump-version script and publish v0.21.8
- Added npm-package/package.json to version bump automation
- Published @beads/bd@0.21.8 to npm
- Future releases will auto-update npm package version
2025-11-05 00:18:19 -08:00
Steve Yegge
e774d80939 bd sync: 2025-11-05 00:17:06 2025-11-05 00:17:06 -08:00
Steve Yegge
37ed10c7be fix: Point GoReleaser homebrew tap to homebrew-beads repo
Was pushing to steveyegge/beads instead of steveyegge/homebrew-beads.
This caused Homebrew formula to be committed to wrong repo.
2025-11-05 00:13:48 -08:00
goreleaserbot
8d2cc60600 Brew formula update for beads version v0.21.8 2025-11-05 08:10:46 +00:00
Steve Yegge
9855388094 docs: Make CHANGELOG update mandatory first step in release process 2025-11-05 00:09:48 -08:00
Steve Yegge
d46894e0ad docs: Add CHANGELOG entry for v0.21.8 2025-11-05 00:09:08 -08:00
Steve Yegge
38df6c8838 fix: Add --tag and --push flags to bump-version.sh
This addresses confusion where version bump doesn't trigger release.
The script now supports:
- --commit: Create git commit
- --tag: Create annotated git tag (requires --commit)
- --push: Push commit and tag (requires --tag)

Updated RELEASING.md to use: ./scripts/bump-version.sh X.Y.Z --commit --tag --push

Fixes the gap between version bump and actual release trigger.
2025-11-05 00:08:08 -08:00
Steve Yegge
1aa9a2e140 chore: Bump version to 0.21.8
Updated all component versions:
- bd CLI: 0.21.7 → 0.21.8
- Plugin: 0.21.7 → 0.21.8
- MCP server: 0.21.7 → 0.21.8
- Documentation: 0.21.7 → 0.21.8

Generated by scripts/bump-version.sh
2025-11-05 00:03:47 -08:00
Steve Yegge
265b142dc5 test: add comprehensive orphan handling mode tests
- TestOrphanHandling_Strict: Verifies import fails on missing parent
- TestOrphanHandling_Resurrect: Verifies parent tombstone creation
- TestOrphanHandling_Skip: Verifies orphans are skipped with warning
- TestOrphanHandling_Allow: Verifies orphans import without validation
- TestOrphanHandling_Config: Tests config reading with all modes + defaults
- TestOrphanHandling_NonHierarchical: Verifies flat IDs work in all modes

Also fixes batch_ops_test.go to pass OrphanHandling parameter to generateBatchIDs.

All tests pass. Closes bd-968f

Amp-Thread-ID: https://ampcode.com/threads/T-fd18d4a5-06b3-4400-9073-194d570846d8
Co-authored-by: Amp <amp@ampcode.com>
2025-11-05 00:02:57 -08:00
Steve Yegge
ff8f6ecadf feat(import): add import.orphan_handling config with 4 modes
- Add GetOrphanHandling() helper to SQLiteStorage (reads from config table)
- Add --orphan-handling flag to 'bd import' command
- Wire OrphanHandling through ImportOptions -> importer.Options
- Auto-read config if flag not provided (default: 'allow')
- Document in CONFIG.md with detailed mode explanations

Modes:
- strict: Fail on missing parent (safest)
- resurrect: Auto-create parent tombstones from JSONL
- skip: Skip orphans with warning
- allow: Import without validation (default, most permissive)

Closes bd-8072, bd-b92a

Amp-Thread-ID: https://ampcode.com/threads/T-fd18d4a5-06b3-4400-9073-194d570846d8
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 23:59:50 -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
09f2edafba Add OrphanHandling type with 'allow' as default (bd-8072)
- Add OrphanHandling enum: strict/resurrect/skip/allow
- Add OrphanHandling field to importer.Options
- Default to 'allow' mode to work around existing system bugs
- Strict mode can be enabled via config for safer imports

Related: bd-8072, bd-b92a
2025-11-04 23:40:22 -08:00
Steve Yegge
ee01574e5c bd sync: 2025-11-04 23:31:46 2025-11-04 23:31:46 -08:00
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