Commit Graph

392 Commits

Author SHA1 Message Date
Steve Yegge
cabe5e8d9b bd sync: 2025-10-26 21:38:55 2025-10-26 21:38:55 -07:00
Steve Yegge
36fc8a19e6 Restore clean issue state after database corruption recovery
- Removed 173 duplicate beads- prefix issues
- Database now contains 165 clean bd- issues
- Fixed database prefix config from beads- to bd-
- All data recovered successfully from .beads/beads.db

Amp-Thread-ID: https://ampcode.com/threads/T-229f87e4-f015-4284-8568-9069cfae4fda
Co-authored-by: Amp <amp@ampcode.com>
2025-10-26 21:35:12 -07:00
Steve Yegge
79b7a48a73 Add database fingerprinting and validation (bd-166)
- Add fingerprint.go with robust URL canonicalization
  - Handles git@, ssh://, https://, http://, file://, and local paths
  - Normalizes URLs to produce consistent repo_id across formats
  - Clone ID uses git repo root for stability

- Update init.go to store repo_id and clone_id metadata
  - repo_id: SHA256 hash of canonical git remote URL
  - clone_id: SHA256 hash of hostname + repo root path

- Add daemon validation to prevent database mismatches
  - Validates repo_id on daemon start
  - Fails on legacy databases (requires explicit migration)
  - Clear error messages with actionable solutions

- Add migrate --update-repo-id command
  - Updates repo_id after remote URL changes
  - Confirmation prompt (can bypass with --yes)
  - Supports --dry-run

Prevents accidental database mixing across repos and provides
migration path for remote URL changes or bd upgrades.

Closes bd-166

Amp-Thread-ID: https://ampcode.com/threads/T-a9d9dab1-5808-4f62-93ea-75a16cca978b
Co-authored-by: Amp <amp@ampcode.com>
2025-10-26 21:15:57 -07:00
Steve Yegge
f24573a5f8 Enforce canonical database naming (beads.db) - bd-165
- Added CanonicalDatabaseName constant (beads.db) and LegacyDatabaseNames list
- Updated bd init to use canonical name via constant
- Added daemon validation to reject non-canonical database names
- Updated bd migrate to use canonical name constant
- Enhanced FindDatabasePath to warn when using legacy database names
- All database discovery now prefers beads.db with backward compatibility

Closes bd-165
2025-10-26 20:42:18 -07:00
Steve Yegge
a02729ea57 Complete bd-164: Fix timestamp-only export deduplication
- Add export_hashes table to track last exported content state
- Implement GetExportHash/SetExportHash in storage interface
- Update shouldSkipExport to use export_hashes instead of dirty_issues
- Call SetExportHash after successful export
- Clean up dirty_issues table (remove content_hash column)
- Simplify MarkIssueDirty functions (no longer compute hashes)
- Update markIssuesDirtyTx signature (remove store parameter)

Testing:
- Timestamp-only updates are skipped during export ✓
- Real content changes trigger export ✓
- export_hashes table populated correctly ✓

Fixes bd-159, bd-164
2025-10-26 20:35:37 -07:00
Steve Yegge
a898df6915 WIP: bd-164 timestamp-only export deduplication (~80% complete)
Implemented content hash-based deduplication to skip exports when only
timestamps changed. Core logic complete, needs export_hashes table wiring.

Completed:
- Added computeIssueContentHash() excluding timestamps
- Created shouldSkipExport() logic
- Updated export loop to skip timestamp-only changes
- Added hash.go with content hashing
- Extended Storage interface

Remaining:
- Complete export_hashes table migration
- Add SetExportHash/GetExportHash to interface
- Revert content_hash from dirty_issues approach
- Wire up hash persistence in export
- Testing

See bd-164 notes for details.

Amp-Thread-ID: https://ampcode.com/threads/T-d70657d1-4433-4f7e-b10a-3fccf8bf17fb
Co-authored-by: Amp <amp@ampcode.com>
2025-10-26 20:29:10 -07:00
Steve Yegge
d05e94d80d bd sync: 2025-10-26 20:27:23 2025-10-26 20:27:23 -07:00
Steve Yegge
3cbd913f31 bd-162: Add database integrity checks with oracle review fixes 2025-10-26 20:17:42 -07:00
Steve Yegge
b893be7d0e Fix bd-161: Implement daemon JSONL import (fix NO-OP stub)
Replace the NO-OP importToJSONLWithStore() stub with full implementation:
- Reads and parses JSONL file line by line using bufio.Scanner
- Uses importIssuesCore() with auto-collision resolution enabled
- Integrates with existing import infrastructure
- Fixes PRIMARY root cause of bd-160 multi-clone sync failure

The daemon now properly imports remote changes pulled from git instead
of ignoring them, allowing databases to converge across clones.

Amp-Thread-ID: https://ampcode.com/threads/T-9b92c2dc-e0e2-4d77-b562-136da8c3f64e
Co-authored-by: Amp <amp@ampcode.com>
2025-10-26 20:05:31 -07:00
Steve Yegge
4a340902a8 bd sync: 2025-10-26 19:42:46 2025-10-26 19:42:46 -07:00
Steve Yegge
c6494c3916 bd sync: 2025-10-26 19:39:31 2025-10-26 19:39:33 -07:00
Steve Yegge
f3005d3dc8 Export with bd-150/152/153 closed 2025-10-26 19:39:24 -07:00
Steve Yegge
1c95b69977 bd sync: 2025-10-26 19:39:04 2025-10-26 19:39:04 -07:00
Steve Yegge
445af4e3a5 bd sync: 2025-10-26 19:35:57 2025-10-26 19:35:57 -07:00
Steve Yegge
1c998917e5 bd sync: 2025-10-26 19:35:36 2025-10-26 19:35:36 -07:00
Steve Yegge
3d83a39362 bd sync: 2025-10-26 19:26:33 2025-10-26 19:26:33 -07:00
Steve Yegge
9e33784623 bd sync: 2025-10-26 19:23:21 2025-10-26 19:23:21 -07:00
Steve Yegge
5cede5e84d bd sync: 2025-10-26 19:04:08 2025-10-26 19:20:59 -07:00
Steve Yegge
2a274b7a10 bd sync: 2025-10-26 19:03:21 2025-10-26 19:03:21 -07:00
Steve Yegge
eb2563310b Update issue metadata
Amp-Thread-ID: https://ampcode.com/threads/T-f1cff202-188b-4850-a909-c2750d24ad22
Co-authored-by: Amp <amp@ampcode.com>
2025-10-26 19:03:07 -07:00
Steve Yegge
51abbb512e bd sync: 2025-10-26 18:44:19 2025-10-26 18:44:19 -07:00
Steve Yegge
50623f8be1 bd sync: 2025-10-26 18:35:28 2025-10-26 18:35:28 -07:00
Steve Yegge
93e170627d bd-154: Implement bd daemons stop and restart subcommands 2025-10-26 18:35:28 -07:00
Steve Yegge
cd86d7d2ba Implement bd-160: Add database schema versioning
- Added version validation on daemon startup
- Daemon checks bd_version metadata matches current version
- Clear error messages for version mismatches with 3 resolution options
- Auto-sets missing version metadata for old databases
- Added BEADS_IGNORE_VERSION_MISMATCH=1 override for emergencies
- Tested version mismatch detection, override flag, and missing metadata handling
2025-10-26 18:28:15 -07:00
Steve Yegge
b39420f748 bd sync: 2025-10-26 18:21:59 2025-10-26 18:21:59 -07:00
Steve Yegge
0a283d5148 bd-151: Implement bd daemons health subcommand 2025-10-26 18:21:55 -07:00
Steve Yegge
1c7de68bfc bd sync: 2025-10-26 18:17:38 2025-10-26 18:17:38 -07:00
Steve Yegge
991da5af0c bd sync: 2025-10-26 18:16:59 2025-10-26 18:16:59 -07:00
Steve Yegge
dd82840886 Close bd-165 as duplicate 2025-10-26 18:10:51 -07:00
Steve Yegge
95f50d7943 bd sync: 2025-10-26 18:10:45 2025-10-26 18:10:45 -07:00
Steve Yegge
764915f6a6 bd sync: 2025-10-26 18:10:25 2025-10-26 18:10:25 -07:00
Steve Yegge
c61ca494fe feat(daemons): implement discovery and list command (bd-146, bd-147)
- Add daemon discovery mechanism with socket scanning
- Implement depth-limited filesystem walk to avoid hangs
- Add DaemonInfo struct with metadata collection
- Create 'bd daemons list' command with table and JSON output
- Add FindDaemonByWorkspace and CleanupStaleSockets utilities
- Fix workspace path to be parent of .beads directory
- Add comprehensive tests for discovery functionality

Closes bd-146
Closes bd-147
2025-10-26 18:10:24 -07:00
Steve Yegge
6bf5c9d2b9 bd sync: 2025-10-26 17:55:32 2025-10-26 17:55:32 -07:00
Steve Yegge
fcff20a735 Reduce auto-sync delays for better UX
- Reduce flush debounce from 5s to 1s (BEADS_FLUSH_DEBOUNCE)
- Reduce daemon poll interval from 10s to 2s
- Makes issue changes sync much faster to JSONL and git
2025-10-26 17:14:25 -07:00
Steve Yegge
0f27c5abf1 Add bd daemons list and health subcommand tasks (bd-158, bd-157) 2025-10-26 17:11:08 -07:00
Steve Yegge
e657931186 Fix two daemon bugs: race condition on deletion (bd-155) and wrong project context (bd-156)
- bd-155: Add pre-import flush in daemon sync cycle to prevent deleted issues from being re-imported
- bd-155: Reduce default daemon polling interval from 5 minutes to 10 seconds
- bd-156: Fix hardcoded 'vc.db' - now properly detects existing .db files in local .beads/ directory
2025-10-26 17:09:20 -07:00
Steve Yegge
9f9ea48ec1 Update beads.jsonl 2025-10-26 13:24:18 -07:00
Steve Yegge
dde640a502 Add bd-144 for bd edit follow-ups 2025-10-26 13:24:18 -07:00
Steve Yegge
9cebb65410 Auto-update beads.jsonl 2025-10-26 13:21:49 -07:00
Steve Yegge
5228108d41 Update beads.jsonl: close bd-142, create bd-143 2025-10-26 13:21:49 -07:00
Steve Yegge
ec7d824897 Fix bd init --quiet and clarify agent usage in docs
- Fix: bd init --quiet now skips interactive prompts and auto-installs hooks
- Docs: Add Git Workflow & Auto-Sync section to README
- Docs: Update AGENTS.md with --quiet flag guidance for agents
- Docs: Update WORKFLOW.md to explain auto-import after git pull
- Docs: Add FAQ entries about auto-sync behavior and who runs init
- Closes bd-127, bd-140, bd-141

Amp-Thread-ID: https://ampcode.com/threads/T-72f55d41-f16c-4541-b72a-8acc9013e87b
Co-authored-by: Amp <amp@ampcode.com>
2025-10-26 12:53:50 -07:00
Steve Yegge
c91e83e993 Add bd sync --import-only flag and git pull integration test (bd-124, bd-125)
- Add --import-only flag to bd sync command for manual JSONL import after git pull
- Show import summary output instead of suppressing it
- Add comprehensive integration test for git pull sync scenario
- Test covers non-daemon auto-import and bd sync command
- Verify performance of import operations

Closes bd-123, bd-114, bd-124, bd-125, bd-136, bd-137

Amp-Thread-ID: https://ampcode.com/threads/T-7d8dc20f-baf2-4d1d-add1-57fa67028c15
Co-authored-by: Amp <amp@ampcode.com>
2025-10-26 12:37:46 -07:00
Steve Yegge
8fe0586080 Update bd-132 with current status and next steps 2025-10-26 12:11:24 -07:00
Steve Yegge
897bc6ace8 Merge duplicate bd-135 into bd-132 2025-10-26 11:59:55 -07:00
Steve Yegge
ada7bd0b73 Refactor autoImportIfNewer to internal/autoimport package (bd-128)
- Extracted auto-import logic from cmd/bd/main.go to internal/autoimport
- Removed global dependencies (store, dbPath) by using parameters
- Uses callback pattern (ImportFunc) for flexible import implementation
- Both CLI and daemon can now call auto-import after detecting staleness
- Added detailed ID remapping output for collision resolution
- Improved error reporting for parse failures
- All tests passing

Amp-Thread-ID: https://ampcode.com/threads/T-b7faaa33-fc52-409f-82b3-28db143b335d
Co-authored-by: Amp <amp@ampcode.com>
2025-10-26 11:55:24 -07:00
Steve Yegge
744d7b67dc Merge duplicate issue bd-135 into bd-132 2025-10-26 11:49:55 -07:00
Steve Yegge
8eca47c4fb Fix database: restore clean 135 issues and add exclusive lock docs 2025-10-25 23:39:26 -07:00
Steve Yegge
e42868c8e5 Update beads.jsonl after auto-import 2025-10-25 23:23:14 -07:00
Steve Yegge
ab69b6b744 Close bd-114: Add configurable SortPolicy to GetReadyWork
Amp-Thread-ID: https://ampcode.com/threads/T-da75f81b-41b9-4c99-b159-ffd67bfb670b
Co-authored-by: Amp <amp@ampcode.com>
2025-10-25 23:22:40 -07:00
Steve Yegge
8bd0ceb0d9 Clean up database: delete 41 duplicates/cruft and renumber to bd-1 through bd-135
Amp-Thread-ID: https://ampcode.com/threads/T-d238b838-793e-464b-a1b0-1d2efa0aeaf6
Co-authored-by: Amp <amp@ampcode.com>
2025-10-25 23:16:04 -07:00