fix(daemon): prevent zombie state after database file replacement
Adds checkFreshness() to health check paths (GetMetadata, GetConfig, GetAllConfig) and refactors reconnect() to validate new connection before closing old.
PR-URL: https://github.com/steveyegge/beads/pull/1213
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix(routing): auto-enable hydration and flush JSONL after routed create
Fixes split-brain bug where issues routed to different repos (via routing.mode=auto)
weren't visible in bd list because JSONL wasn't updated and hydration wasn't configured.
**Problem**: When routing.mode=auto routes issues to a separate repo (e.g., ~/.beads-planning),
those issues don't appear in 'bd list' because:
1. Target repo's JSONL isn't flushed after create
2. Multi-repo hydration (repos.additional) not configured automatically
3. No doctor warnings about the misconfiguration
**Changes**:
1. **Auto-flush JSONL after routed create** (cmd/bd/create.go)
- After routing issue to target repo, immediately flush to JSONL
- Tries target daemon's export RPC first (if daemon running)
- Falls back to direct JSONL export if no daemon
- Ensures hydration can read the new issue immediately
2. **Enable hydration in bd init --contributor** (cmd/bd/init_contributor.go)
- Wizard now automatically adds planning repo to repos.additional
- Users no longer need to manually run 'bd repo add'
- Routed issues appear in bd list immediately after setup
3. **Add doctor check for hydrated repo daemons** (cmd/bd/doctor/daemon.go)
- New CheckHydratedRepoDaemons() warns if daemons not running
- Without daemons, JSONL becomes stale and hydration breaks
- Suggests: cd <repo> && bd daemon start --local
4. **Add doctor check for routing+hydration mismatch** (cmd/bd/doctor/config_values.go)
- Validates routing targets are in repos.additional
- Catches split-brain configuration before users encounter it
- Suggests: bd repo add <routing-target>
**Testing**: Builds successfully. Unit/integration tests pending.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* test(routing): add comprehensive tests for routing fixes
Add unit tests for all 4 routing/hydration fixes:
1. **create_routing_flush_test.go** - Test JSONL flush after routing
- TestFlushRoutedRepo_DirectExport: Verify direct JSONL export
- TestPerformAtomicExport: Test atomic file operations
- TestFlushRoutedRepo_PathExpansion: Test path handling
- TestRoutingWithHydrationIntegration: E2E routing+hydration test
2. **daemon_test.go** - Test hydrated repo daemon check
- TestCheckHydratedRepoDaemons: Test with/without daemons running
- Covers no repos, daemons running, daemons missing scenarios
3. **config_values_test.go** - Test routing+hydration validation
- Test routing without hydration (should warn)
- Test routing with correct hydration (should pass)
- Test routing target not in hydration list (should warn)
- Test maintainer="." edge case (should pass)
All tests follow existing patterns and use t.TempDir() for isolation.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix(tests): fix test failures and refine routing validation logic
Fixes test failures and improves validation accuracy:
1. **Fix routing+hydration validation** (config_values.go)
- Exclude "." from hasRoutingTargets check (current repo doesn't need hydration)
- Prevents false warnings when maintainer="." or contributor="."
2. **Fix test ID generation** (create_routing_flush_test.go)
- Use auto-generated IDs instead of hard-coded "beads-test1"
- Respects test store prefix configuration (test-)
- Fixed json.NewDecoder usage (file handle, not os.Open result)
3. **Fix config validation tests** (config_values_test.go)
- Create actual directories for routing paths to pass path validation
- Tests now verify both routing+hydration AND path existence checks
4. **Fix daemon test expectations** (daemon_test.go)
- When database unavailable, check returns "No additional repos" not error
- This is correct behavior (graceful degradation)
All tests now pass:
- TestFlushRoutedRepo* (3 tests)
- TestPerformAtomicExport
- TestCheckHydratedRepoDaemons (3 subtests)
- TestCheckConfigValues routing tests (5 subtests)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* docs: clarify when git config beads.role maintainer is needed
Clarify that maintainer role config is only needed in edge case:
- Using GitHub HTTPS URL without credentials
- But you have write access (are a maintainer)
In most cases, beads auto-detects correctly via:
- SSH URLs (git@github.com:owner/repo.git)
- HTTPS with credentials
This prevents confusion - users with SSH or credential-based HTTPS
don't need to manually configure their role.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix(lint): address linter warnings in routing flush code
- Add missing sqlite import in daemon.go
- Fix unchecked client.Close() error return
- Fix unchecked tempFile.Close() error returns
- Mark unused parameters with _ prefix
- Add nolint:gosec for safe tempPath construction
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Roland Tritsch <roland@ailtir.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Release highlights:
- VersionedStorage interface for pluggable backends
- bd types command and enhancement type alias
- bd close -m flag (git commit convention)
- RepoContext API for centralized git operations
- Dolt backend improvements (WIP)
- Many bug fixes for doctor, sync, hooks, worktrees
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add detection for external git hook managers (lefthook, husky, pre-commit,
overcommit, yorkie, simple-git-hooks) and check if they have bd hooks
integration configured.
- Detect manager config files in various locations/formats
- Parse lefthook YAML/TOML/JSON to check for `bd hooks run` commands
- Check husky hook scripts for bd integration
- Report which hooks have bd integration vs missing
- Use --chain flag in `bd doctor --fix` when external managers detected
- Detect active manager from git hooks when multiple present
Executed-By: mayor
Role: mayor
- Update Version in cmd/bd/version.go: 0.42.0 → 0.43.0
- Update CHANGELOG.md with 0.43.0 section
- Fix test isolation in TestTrackBdVersion_NoBeadsDir
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New commands and features:
- bd worktree for parallel development
- bd slot commands for agent bead slot management
- bd agent state for ZFC-compliant state reporting
- bd doctor --deep for full graph integrity validation
- Agent bead support (type=agent, type=role, migration 030)
- Computed .parent field in JSON output
- Auto-bypass daemon for wisp operations
- Pour warning for vapor-phase formulas
Performance:
- O(2^n) → O(V+E) cycle detection (GH#775)
Fixes:
- Import hash mismatch warnings
- Test updates for version tracking thresholds
- Migration test updated for new agent schema fields
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Strip (bd-xxx), (gt-xxx) suffixes from code comments and changelog
entries. The descriptions remain meaningful without the ephemeral
issue IDs.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update docs to reflect CLI command restructuring:
- migrate-tombstones → migrate tombstones
- bd quickstart is now hidden, point to docs/QUICKSTART.md
- Add CLI consolidation section to CHANGELOG.md
- Remove quickstart from command tables
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Analysis found these commands are dead code:
- gt never calls `bd pin` - uses `bd update --status=pinned` instead
- Beads.Pin() wrapper exists but is never called
- bd hook functionality duplicated by gt mol status
- Code comment says "pinned field is cosmetic for bd hook visibility"
Removed:
- cmd/bd/pin.go
- cmd/bd/unpin.go
- cmd/bd/hook.go
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When closing an issue, the new --suggest-next flag returns a list of
issues that became unblocked (ready to work on) as a result of the close.
This helps agents and users quickly identify what work is now available
after completing a blocker.
Example:
$ bd close bd-5 --suggest-next
✓ Closed bd-5: Completed
Newly unblocked:
• bd-7 "Implement feature X" (P1)
• bd-8 "Write tests for X" (P2)
Implementation:
- Added GetNewlyUnblockedByClose to storage interface
- Implemented efficient single-query for SQLite using blocked_issues_cache
- Added SuggestNext field to CloseArgs in RPC protocol
- Added CloseResult type for structured response
- CLI handles both daemon and direct modes
Thanks to @kraitsura for the detailed feature request and design.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Skip daemon mode on Windows (sys.platform == win32)
- Falls back to CLI mode which works on all platforms
- Avoids asyncio.open_unix_connection which does not exist on Windows
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move write stream creation after redirect handling to avoid orphan
streams that keep file handles open
- Add 100ms delay after file.close() on Windows to ensure handle release
- Fixes "The process cannot access the file" error during extraction
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comprehensive changelog entries for all changes since v0.36.0:
- 8 new features (control flow, aspects, stale detection, etc.)
- 3 breaking changes (YAML→JSON, wisp architecture, mol run removal)
- 13 bug fixes
- 2 documentation updates
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Wisps are now just issues with Wisp=true flag in the main database,
not exported to JSONL. Removes all references to .beads-wisp/ directory.
- Update docs: CLAUDE.md, CLI_REFERENCE.md, MOLECULES.md, DELETIONS.md
- Update code comments: wisp.go
- Update changelog and info.go version notes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Change file extension from .formula.yaml to .formula.json
- Replace gopkg.in/yaml.v3 with encoding/json in parser
- Remove yaml struct tags, keep json tags only
- Update all test cases to use JSON format
- Update documentation references
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Highlights that this prevents a common LLM temporal reasoning trap
where 'Phase 1 before Phase 2' gets modeled as Phase 1 blocking Phase 2
instead of Phase 2 depending on Phase 1.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove the spawn command from bd mol. Proto instantiation now uses:
- bd pour <proto> - Instantiate as persistent mol (liquid phase)
- bd wisp create <proto> - Instantiate as ephemeral wisp (vapor phase)
Rationale:
- 'spawn' doesn't fit the chemistry metaphor
- Two phase transitions (pour/wisp) are clearer than one command with flags
- Avoids confusion about defaults
Changes:
- Delete mol_spawn.go
- Update mol.go, mol_catalog.go, mol_distill.go to reference pour/wisp
- Update pour.go and wisp.go to remove 'Equivalent to spawn' comments
- Update info.go changelog entries
- Update CHANGELOG.md, ARCHITECTURE.md, DELETIONS.md
Closes bd-8y9t
Adds release notes for v0.35.0 including:
- Dynamic molecule bonding with --ref flag
- bd activity command for real-time state feed
- waits-for dependency type for fanout gates
- Parallel step detection for molecules
- bd list --parent flag
- Molecule navigation commands
- Performance indexes and bug fixes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes:
- P0 priority preserved - omitempty removed from Priority field (GH#671)
- nil pointer check in markdown parsing (GH#674)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Wisp = ephemeral vapor produced by the Steam Engine (Gas Town).
This aligns with the metaphor:
- Claude = Fire
- Claude Code = Steam
- Gas Town = Steam Engine
- Wisps = ephemeral vapor it produces
Changes:
- types.Issue.Ephemeral → types.Issue.Wisp
- types.IssueFilter.Ephemeral → types.IssueFilter.Wisp
- JSON field: "ephemeral" → "wisp"
- CLI flag: --ephemeral → --wisp (bd cleanup)
- All tests updated
Note: SQLite column remains "ephemeral" (no migration needed).
This is a breaking change for JSON consumers using 0.33.0.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Ephemeral molecules release:
- bd mol spawn creates ephemeral issues by default
- Ephemeral issues never export to JSONL
- bd mol squash with --summary for agent summaries
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
CRITICAL: Fixed dependency resurrection bug that caused removed/orphaned
dependencies to keep coming back after sync.
Root cause: mergeDependencies() was doing a union (additive only) and
completely ignored the base parameter. This meant any dependency present
in either left or right would be included, even if it was intentionally
removed.
Fix: Proper 3-way merge where REMOVALS ARE AUTHORITATIVE:
- If dep was in base and removed by left OR right → stays removed
- If dep wasn't in base and added by left OR right → included
- If dep was in base and both still have it → included
This fixes months of issues with orphaned parent-child relationships
being resurrected during git sync operations.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>