Commit Graph

2355 Commits

Author SHA1 Message Date
Steve Yegge
8d6696af40 docs: Complete error handling audit
- Add comprehensive audit document tracking all error patterns
- Update ERROR_HANDLING.md with metadata distinction guidelines
- Document init.go error handling patterns with metadata notes

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 00:35:04 -08:00
Steve Yegge
44b578534f bd sync: apply DB changes after import 2025-11-24 00:34:55 -08:00
Steve Yegge
05a317306a bd sync: apply DB changes after rebase 2025-11-24 00:34:36 -08:00
Steve Yegge
b7f4d3f34b bd sync: apply DB changes after push 2025-11-24 00:34:26 -08:00
Steve Yegge
528f27c053 Add orphan detection migration (bd-3852)
Creates migration to detect orphaned child issues and logs them for user
action. Orphaned children are issues with hierarchical IDs (e.g., "parent.child")
where the parent issue no longer exists in the database.

The migration:
- Queries for issues with IDs like '%.%' where parent doesn't exist
- Logs detected orphans with suggested actions (delete, convert, or restore)
- Does NOT automatically delete or convert orphans
- Is idempotent and safe to run multiple times

Test coverage:
- Detects orphaned child issues correctly
- Handles clean databases with no orphans
- Verifies idempotency

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 00:34:26 -08:00
Steve Yegge
3037e6ddd5 docs: Add metadata distinction guidelines to ERROR_HANDLING.md
Expanded the Metadata Operations section to clearly distinguish:
- Configuration Metadata (Pattern A): issue_prefix, sync.branch
  → Fatal errors - these are prerequisites for basic operation
- Tracking Metadata (Pattern B): bd_version, repo_id, last_import_hash
  → Warnings - system degrades gracefully without these

Includes concrete examples, rationales, and cross-references to init.go
implementation.

Resolves: bd-pp3
2025-11-24 00:34:15 -08:00
Steve Yegge
836c731cbe docs: Clarify metadata error handling patterns in init.go
Add detailed comments distinguishing between:
- Configuration metadata (issue_prefix, sync.branch): Pattern A (fatal)
- Tracking metadata (bd_version, repo_id, clone_id): Pattern B (warnings)

The code already followed the correct patterns from ERROR_HANDLING.md,
but lacked explicit documentation explaining WHY different metadata types
use different error handling strategies.

Resolves: bd-b2c
2025-11-24 00:33:25 -08:00
Steve Yegge
aeffb8d0ac bd sync: 2025-11-24 00:29:04 2025-11-24 00:29:04 -08:00
Steve Yegge
5fec8b47c6 bd sync: apply DB changes after import 2025-11-24 00:25:27 -08:00
Steve Yegge
1fe88c2d9c bd sync: apply DB changes after import 2025-11-24 00:25:09 -08:00
Steve Yegge
76e3f27eb0 fix: CI test failures and lint errors
- Fixed test file naming: issues.jsonl -> beads.jsonl
  - beads_test.go: Update expected path in TestFindJSONLPath
  - internal/beads/beads_test.go: Update TestFindJSONLPathDefault
  - cmd/bd/main_test.go: Update TestAutoFlushJSONLContent

- Fixed lint errors (gosec):
  - G304: Added nosec comments for file operations with user-provided paths
  - G204: Added nosec comment for subprocess with controlled binary path

- Fixed lint errors (errcheck):
  - cmd/bd/test_wait_helper.go: Acknowledge error return values with _
  - cmd/bd/onboard.go: Handle fmt.Fprintf error return

All tests passing locally. All lint checks passing.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 00:21:01 -08:00
Steve Yegge
ed3ddc0053 bd sync: 2025-11-24 00:12:24 2025-11-24 00:12:24 -08:00
Steve Yegge
3eec586a18 docs: Complete comprehensive v0.24.3 changelog
Thorough manual review of all 243 commits between v0.24.2 and v0.24.3:

- 10 major Added features with detailed sub-bullets
- 15 critical Fixed issues with technical context
- 4 Changed improvements to workflows
- 2 Testing enhancements
- 1 Performance optimization

Each entry includes:
- Commit hashes for traceability
- bd issue IDs where applicable
- User-focused descriptions
- Technical details and impact
- Follows Keep a Changelog format

This matches the quality and detail of previous changelog entries.
2025-11-24 00:12:17 -08:00
Steve Yegge
38a6ac95aa bd sync: apply DB changes after import 2025-11-24 00:07:34 -08:00
Steve Yegge
ed5a86b9e0 Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-24 00:07:34 -08:00
Steve Yegge
ba153d0a9f bd sync: 2025-11-24 00:07:33 2025-11-24 00:07:33 -08:00
Steve Yegge
e05784f4a9 docs: Add v0.24.3 changelog entry
Properly documents all changes from v0.24.2 to v0.24.3:
- Version management and auto-migration features
- Data consistency and sync improvements
- Security enhancements
- Cross-platform bug fixes
- Web UI improvements
- Daemon and git hook enhancements
2025-11-24 00:06:25 -08:00
Steve Yegge
634b6a20f9 feat: Update bump-version.sh to handle CHANGELOG.md
- Automatically moves [Unreleased] section to [version] - date
- Creates new empty [Unreleased] section at top
- Includes CHANGELOG.md in version bump commit
- Follows Keep a Changelog format properly
2025-11-24 00:05:45 -08:00
Steve Yegge
f7f4822601 bd sync: apply DB changes after import 2025-11-24 00:03:21 -08:00
Steve Yegge
319f1adaeb Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-24 00:03:21 -08:00
Steve Yegge
dbb3000d69 bd sync: 2025-11-24 00:03:20 2025-11-24 00:03:20 -08:00
Steve Yegge
2560b11f80 feat: Add --start flag to bd daemon, show help with no args
Currently 'bd daemon' with no args immediately starts the daemon. This is
inconsistent with other daemon management commands like --stop, --status,
etc. and makes the command less discoverable for new users.

Changes:
- Add --start flag to explicitly start daemon
- Show help text when no operation flags provided
- Update auto-start logic to use --start flag
- Update startDaemon() to pass --start when forking
- Update all documentation to use 'bd daemon --start'
- Update MCP Python client error messages

The MCP docs already incorrectly showed 'bd daemon start' which doesn't
work, so this change fixes that documentation bug while improving UX.

Auto-start still works correctly - it now passes --start internally.

Fixes bd-gfu

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 00:03:07 -08:00
Steve Yegge
a5429195b7 bd sync: 2025-11-24 00:01:30 2025-11-24 00:01:30 -08:00
Steve Yegge
95b1577521 bd sync: 2025-11-23 23:52:35 2025-11-23 23:52:35 -08:00
Steve Yegge
e5ace6cf6e chore: Bump version to 0.24.3
Updated all component versions:
- bd CLI: 0.24.2 → 0.24.3
- Plugin: 0.24.2 → 0.24.3
- MCP server: 0.24.2 → 0.24.3
- npm package: 0.24.2 → 0.24.3
- Documentation: 0.24.2 → 0.24.3

Generated by scripts/bump-version.sh
2025-11-23 23:42:48 -08:00
Steve Yegge
bc5d3690ce bd sync: 2025-11-23 23:41:14 2025-11-23 23:41:14 -08:00
Steve Yegge
d45cff5085 feat: Handle FOREIGN KEY constraint violations gracefully during import (bd-koab)
When importing JSONL after merges that include deletions, FK constraint
violations can occur if an issue references a deleted issue. Previously,
import would fail completely. Now it continues and reports skipped dependencies.

Changes:
- Add SkippedDependencies field to Result/ImportResult structs
- Update importDependencies() to detect FK violations using IsForeignKeyConstraintError()
- Log warnings for each skipped dependency with issue IDs and type
- Continue importing remaining dependencies instead of failing
- Display summary of all skipped dependencies at end of import

Example output:
  Warning: Skipping dependency due to missing reference: bd-b → bd-a (blocks)

  ⚠️  Warning: Skipped 2 dependencies due to missing references:
    - bd-b → bd-a (blocks)
    - bd-c → bd-a (parent-child)

  This can happen after merges that delete issues referenced by other issues.
  The import continued successfully - you may want to review the skipped dependencies.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 23:32:34 -08:00
Steve Yegge
e2e04c011a bd sync: 2025-11-23 23:11:21 2025-11-23 23:11:21 -08:00
Steve Yegge
d1641c7d2e Fix bd-afd: Auto-fix metadata.json jsonl_export mismatch
## Summary

When metadata.json gets deleted (git clean, merge conflict, rebase), the
version tracking code auto-recreates it using DefaultConfig() which hardcoded
jsonl_export to 'issues.jsonl'. But many repos (including beads itself) use
'beads.jsonl', causing a mismatch between config and actual JSONL file.

## Changes

1. **bd doctor --fix auto-detection** (cmd/bd/doctor/fix/database_config.go)
   - New DatabaseConfig() fix function that auto-detects actual JSONL file
   - Prefers beads.jsonl over issues.jsonl (canonical name)
   - Skips backup files and merge artifacts
   - Wired into doctor.go applyFixes()

2. **Version tracking auto-detection** (cmd/bd/version_tracking.go)
   - trackBdVersion() now scans for existing JSONL files before defaulting
   - Prevents mismatches when metadata.json gets recreated
   - Added findActualJSONLFile() helper function

3. **Canonical default name** (internal/configfile/configfile.go)
   - DefaultConfig() changed from issues.jsonl to beads.jsonl
   - Aligns with canonical naming convention

4. **FindJSONLPath preference** (internal/beads/beads.go)
   - Now prefers beads.jsonl over issues.jsonl when scanning
   - Default changed from issues.jsonl to beads.jsonl

5. **Test coverage**
   - Added comprehensive tests for DatabaseConfig fix
   - Updated configfile tests for new default
   - Verified backup file skipping logic

## Testing

- All existing tests pass
- New tests verify auto-fix behavior
- Integration tested with simulated mismatches

Closes: bd-afd
2025-11-23 23:11:08 -08:00
Steve Yegge
bee0e44187 bd sync: apply DB changes after import 2025-11-23 23:05:29 -08:00
Steve Yegge
2f7f77055f Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-23 23:05:29 -08:00
Steve Yegge
3006e67eef bd sync: 2025-11-23 23:05:28 2025-11-23 23:05:28 -08:00
Steve Yegge
153f724e95 Fix Windows CI test failures
Two Windows-specific test failures:

1. TestNewSQLiteStorage - File locking on temp cleanup
   - Windows couldn't delete temp database file because connection was still open
   - Added defer store.Close() to properly cleanup the database connection
   - Without this, Windows file locking prevents TempDir cleanup

2. TestFindAllDatabases - Unexpected nil slice return
   - FindAllDatabases could return nil instead of empty slice when os.Getwd() fails
   - Changed from var databases to explicit empty slice initialization
   - Ensures function always returns non-nil slice, matching test expectations

Both issues are more pronounced on Windows due to stricter file locking
and different filesystem behavior.

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 23:01:55 -08:00
Steve Yegge
e5bb6ed6dc bd sync: 2025-11-23 22:55:37 2025-11-23 22:55:37 -08:00
Steve Yegge
21d246f502 bd sync: apply DB changes after import 2025-11-23 22:54:16 -08:00
Steve Yegge
0e956d733b Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-23 22:54:16 -08:00
Steve Yegge
7e41f2b4a5 bd sync: 2025-11-23 22:54:08 2025-11-23 22:54:08 -08:00
Steve Yegge
dfcbb7d3af Optimize sync_test.go: eliminate redundant git init calls
- Add setupGitRepo(), setupGitRepoWithBranch(), and setupMinimalGitRepo() helpers
- Refactor 19 test functions to use shared git repo setup
- Reduces duplicate git initialization boilerplate by ~300 lines
- All tests pass with improved maintainability

Related to bd-ktng
2025-11-23 22:54:05 -08:00
Steve Yegge
c9a2e7a8b2 Fix bd-v0y: Remove mtime fast-path in hasJSONLChanged
Git doesn't preserve mtime on checkout, causing false negatives where
hasJSONLChanged() incorrectly returns false after git pull updates JSONL.
This caused bd sync to overwrite pulled JSONL instead of importing it,
resurrecting deleted issues.

Solution: Always compute content hash for comparison (Option 1).
Performance impact is minimal (~10-50ms for sync operations).

Changes:
- cmd/bd/integrity.go: Remove mtime fast-path, always compute hash
- cmd/bd/sync.go: Remove mtime storage after import
- cmd/bd/import.go: Remove mtime storage after import
- cmd/bd/daemon_sync.go: Remove mtime storage and update comments
- cmd/bd/daemon_sync_test.go: Remove mtime assertions from tests

All tests pass. Existing test 'mtime changed but content same - git
operation scenario' verifies the fix works correctly.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 22:53:54 -08:00
Steve Yegge
7491c142d4 bd sync: 2025-11-23 22:47:28 2025-11-23 22:47:28 -08:00
Steve Yegge
e4cd9a896d bd sync: 2025-11-23 22:47:12 2025-11-23 22:47:12 -08:00
Steve Yegge
f5e96f9a7b Update bd JSONL after rebase 2025-11-23 22:39:58 -08:00
Steve Yegge
949ab4294c Fix ZFC: only force import when DB >> JSONL (stale DB)
Reverted 'always import' - that would overwrite local DB changes.
Now: only import first if DB has >50% more issues than JSONL (stale DB).
Preserves local uncommitted changes while catching sora scenario.
2025-11-23 22:39:51 -08:00
Steve Yegge
e7dfe284b5 bd sync: 2025-11-23 22:38:58 2025-11-23 22:38:58 -08:00
Steve Yegge
2e4171a5f8 Properly enforce ZFC: always import JSONL before export in sync
- Removed arbitrary 50% divergence check
- bd sync now unconditionally imports JSONL first (source of truth)
- Simpler, more correct: JSONL -> DB -> JSONL flow
2025-11-23 22:38:13 -08:00
Steve Yegge
1ba068fabd Fix bd-l0r: Enforce ZFC (JSONL First Consistency) - refuse export when DB >> JSONL 2025-11-23 22:34:19 -08:00
Steve Yegge
f5cc3ff85a bd sync: apply DB changes after import 2025-11-23 22:33:05 -08:00
Steve Yegge
fee336e4ff Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-23 22:33:05 -08:00
Steve Yegge
839292657a bd sync: 2025-11-23 22:33:04 2025-11-23 22:33:04 -08:00
Steve Yegge
133c30d0d5 bd sync: apply DB changes after import 2025-11-23 22:32:42 -08:00