Commit Graph

5246 Commits

Author SHA1 Message Date
emma
9ea8fa5d68 bd daemon sync: 2026-01-08 14:30:53 2026-01-08 14:30:53 -08:00
emma
29858230d5 bd daemon sync: 2026-01-08 14:30:52 2026-01-08 14:30:52 -08:00
emma
df554ae1b1 bd daemon sync: 2026-01-08 14:30:50 2026-01-08 14:30:50 -08:00
emma
d1014c2f35 bd daemon sync: 2026-01-08 14:30:48 2026-01-08 14:30:48 -08:00
emma
2d21603a55 bd daemon sync: 2026-01-08 14:30:25 2026-01-08 14:30:25 -08:00
emma
5de5fb4877 bd daemon sync: 2026-01-08 14:30:24 2026-01-08 14:30:24 -08:00
emma
8396febaee bd daemon sync: 2026-01-08 14:30:23 2026-01-08 14:30:23 -08:00
emma
fbe38d324d bd daemon sync: 2026-01-08 14:30:22 2026-01-08 14:30:22 -08:00
emma
40463988b2 bd daemon sync: 2026-01-08 14:29:36 2026-01-08 14:29:36 -08:00
emma
efc234e267 bd daemon sync: 2026-01-08 14:29:26 2026-01-08 14:29:26 -08:00
emma
2c73246194 bd daemon sync: 2026-01-08 14:23:46 2026-01-08 14:23:46 -08:00
emma
90b3a14d4c bd daemon sync: 2026-01-08 14:23:28 2026-01-08 14:23:28 -08:00
emma
fd3b380439 bd daemon sync: 2026-01-08 14:23:27 2026-01-08 14:23:27 -08:00
emma
d0441ceac7 bd daemon sync: 2026-01-08 14:23:18 2026-01-08 14:23:18 -08:00
emma
a693831607 bd daemon sync: 2026-01-08 14:22:41 2026-01-08 14:22:41 -08:00
emma
5450f55386 bd daemon sync: 2026-01-08 14:22:40 2026-01-08 14:22:40 -08:00
emma
5d1d13ba32 bd daemon sync: 2026-01-08 14:22:38 2026-01-08 14:22:38 -08:00
emma
48a082d633 bd daemon sync: 2026-01-08 14:22:36 2026-01-08 14:22:36 -08:00
emma
3697145f57 bd daemon sync: 2026-01-08 14:22:23 2026-01-08 14:22:23 -08:00
emma
64d0740f64 bd daemon sync: 2026-01-08 14:22:21 2026-01-08 14:22:21 -08:00
emma
97de7136dc bd daemon sync: 2026-01-08 14:22:10 2026-01-08 14:22:10 -08:00
emma
d5382f4c10 bd daemon sync: 2026-01-08 14:21:48 2026-01-08 14:21:48 -08:00
emma
8d00801717 bd daemon sync: 2026-01-08 14:20:30 2026-01-08 14:20:30 -08:00
emma
c608e9e601 bd daemon sync: 2026-01-08 14:20:28 2026-01-08 14:20:28 -08:00
emma
c84e793ba3 bd daemon sync: 2026-01-08 14:20:27 2026-01-08 14:20:27 -08:00
emma
13ed4acb43 bd daemon sync: 2026-01-08 14:20:26 2026-01-08 14:20:26 -08:00
emma
1ebc515f81 bd daemon sync: 2026-01-08 14:20:08 2026-01-08 14:20:08 -08:00
emma
d0df2f30be bd daemon sync: 2026-01-08 14:20:07 2026-01-08 14:20:07 -08:00
emma
94857dce48 bd daemon sync: 2026-01-08 14:20:05 2026-01-08 14:20:05 -08:00
emma
17862bdac2 bd daemon sync: 2026-01-08 14:20:04 2026-01-08 14:20:04 -08:00
emma
8f4f5c6557 bd daemon sync: 2026-01-08 14:17:35 2026-01-08 14:17:35 -08:00
emma
19fc2c10df bd daemon sync: 2026-01-08 14:16:55 2026-01-08 14:16:56 -08:00
deacon
e3c59bb086 bd daemon sync: 2026-01-08 14:10:47 2026-01-08 14:10:47 -08:00
deacon
91cb31e1b6 bd daemon sync: 2026-01-08 14:09:53 2026-01-08 14:09:53 -08:00
deacon
54787db177 bd daemon sync: 2026-01-08 14:09:21 2026-01-08 14:09:21 -08:00
deacon
9f36e1e3d3 bd daemon sync: 2026-01-08 14:07:54 2026-01-08 14:07:54 -08:00
deacon
2d9d0af498 bd daemon sync: 2026-01-08 12:27:07 2026-01-08 12:27:07 -08:00
deacon
255b67286b bd daemon sync: 2026-01-08 12:25:34 2026-01-08 12:25:34 -08:00
mayor
66ab0ccdd4 test: add tests for bd create --dry-run flag (bd-nib2)
Adds runBDInProcessAllowError helper and dry-run test coverage.
Interrupted work - committing to preserve progress.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 12:15:07 -08:00
fang
9cffdceb4e feat: add bd resolve-conflicts command for JSONL merge conflicts (bd-7e7ddffa.1)
Implements a new command to resolve git merge conflict markers in JSONL files.

Features:
- Mechanical mode (default): deterministic merge using updated_at timestamps
- Closed status wins over open
- Higher priority (lower number) wins
- Notes are concatenated when different
- Dependencies are unioned
- Dry-run mode to preview changes
- JSON output for agent integration
- Automatic backup creation before changes

The command defaults to resolving .beads/beads.jsonl but accepts any file path.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 21:41:29 -08:00
dave
bfd848c5c4 bd sync: 2026-01-07 21:38:04 2026-01-07 21:38:04 -08:00
dave
97d4aed534 bd sync: 2026-01-07 21:37:33 2026-01-07 21:37:33 -08:00
dave
e96dd023ce refactor(formula): break run-bump-script into individual version-update steps (bd-a854)
Replace the monolithic run-bump-script step with 7 individual steps:
- bump-version-go: Update cmd/bd/version.go
- bump-plugin-json: Update .claude-plugin/*.json
- bump-mcp-python: Update pyproject.toml and __init__.py
- bump-npm-package: Update npm-package/package.json
- bump-hook-templates: Update cmd/bd/templates/hooks/*
- bump-readme: Update README.md badge
- stamp-changelog: Add date to [Unreleased] section

Benefits:
- Durability: If interrupted mid-release, can resume from specific step
- Visibility: Activity feed shows progress through each sub-operation
- Atomicity: Each step has clear verify commands

Also removed outdated JSON formula file (TOML is authoritative).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: beads/crew/dave
Rig: beads
Role: crew
2026-01-07 21:37:19 -08:00
emma
bf09f0c6ea fix(doctor): recognize bd shims when external manager config exists (GH#946)
When an external hook manager config file (like .pre-commit-config.yaml) exists
but the actual hooks are bd shims, doctor now correctly reports OK instead of
warning that the manager doesn't call bd.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 21:35:07 -08:00
emma
370b946360 fix(create): parse DeferUntil in daemon handleCreate (GH#950)
The daemon's handleCreate was parsing DueAt but ignoring the DeferUntil
field from CreateArgs. This caused --defer flag to be silently dropped
when using daemon mode.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 21:31:40 -08:00
mayor
073f74322d bd daemon sync: 2026-01-07 21:30:34 2026-01-07 21:30:34 -08:00
mayor
1a0e5a8d52 bd daemon sync: 2026-01-07 21:30:29 2026-01-07 21:30:29 -08:00
Peter Chanthamynavong
1561374c04 feat(sync): pull-first sync with 3-way merge (#918)
* feat(sync): implement pull-first synchronization strategy

- Add --pull-first flag and logic to sync command
- Introduce 3-way merge stub for issue synchronization
- Add concurrent edit tests for the pull-first flow

Ensures local changes are reconciled with remote updates before pushing to prevent data loss.

* feat(sync): implement 3-way merge and state tracking

- Implement 3-way merge algorithm for issue synchronization
- Add base state storage to track changes between syncs
- Add comprehensive tests for merge logic and persistence

Ensures data consistency and prevents data loss during concurrent
issue updates.

* feat(sync): implement field-level conflict merging

- Implement field-level merge logic for issue conflicts
- Add unit tests for field-level merge strategies

Reduces manual intervention by automatically resolving overlapping updates at the field level.

* refactor(sync): simplify sync flow by removing ZFC checks

The previous sync implementation relied on Zero-False-Convergence (ZFC)
staleness checks which are redundant following the transition to
structural 3-way merging. This legacy logic added complexity and
maintenance overhead without providing additional safety.

This commit introduces a streamlined sync pipeline:
- Remove ZFC staleness validation from primary sync flow
- Update safety documentation to reflect current merge strategy
- Eliminate deprecated unit tests associated with ZFC logic

These changes reduce codebase complexity while maintaining data
integrity through the robust structural 3-way merge implementation.

* feat(sync): default to pull-first sync workflow

- Set pull-first as the primary synchronization workflow
- Refactor core sync logic for better maintainability
- Update concurrent edit tests to validate 3-way merge logic

Reduces merge conflicts by ensuring local state is current before pushing changes.

* refactor(sync): clean up lint issues in merge code

- Remove unused error return from MergeIssues (never returned error)
- Use _ prefix for unused _base parameter in mergeFieldLevel
- Update callers to not expect error from MergeIssues
- Keep nolint:gosec for trusted internal file path

* test(sync): add mode compatibility and upgrade safety tests

Add tests addressing Steve's PR #918 review concerns:

- TestSyncBranchModeWithPullFirst: Verifies sync-branch config
  storage and git branch creation work with pull-first
- TestExternalBeadsDirWithPullFirst: Verifies external BEADS_DIR
  detection and pullFromExternalBeadsRepo
- TestUpgradeFromOldSync: Validates upgrade safety when
  sync_base.jsonl doesn't exist (first sync after upgrade)
- TestMergeIssuesWithBaseState: Comprehensive 3-way merge cases
- TestLabelUnionMerge: Verifies labels use union (no data loss)

Key upgrade behavior validated:
- base=nil (no sync_base.jsonl) safely handles all cases
- Local-only issues kept (StrategyLocal)
- Remote-only issues kept (StrategyRemote)
- Overlapping issues merged (LWW scalars, union labels)

* fix(sync): report line numbers for malformed JSON

Problem:
- JSON decoding errors when loading sync base state lacked line numbers
- Difficult to identify location of syntax errors in large state files

Solution:
- Include line number reporting in JSON decoder errors during state loading
- Add regression tests for malformed sync base file scenarios

Impact:
- Users receive actionable feedback for corrupted state files
- Faster troubleshooting of manual configuration errors

* fix(sync): warn on large clock skew during sync

Problem:
- Unsynchronized clocks between systems could lead to silent merge errors
- No mechanism existed to alert users of significant timestamp drift

Solution:
- Implement clock skew detection during sync merge
- Log a warning when large timestamp differences are found
- Add comprehensive unit tests for skew reporting

Impact:
- Users are alerted to potential synchronization risks
- Easier debugging of time-related merge issues

* fix(sync): defer state update until remote push succeeds

Problem:
- Base state updated before confirming remote push completion
- Failed pushes resulted in inconsistent local state tracking

Solution:
- Defer base state update until after the remote push succeeds

Impact:
- Ensures local state accurately reflects remote repository status
- Prevents state desynchronization during network or push failures

* fix(sync): prevent concurrent sync operations

Problem:
- Multiple sync processes could run simultaneously
- Overlapping operations risk data corruption and race conditions

Solution:
- Implement file-based locking using gofrs/flock
- Add integration tests to verify locking behavior

Impact:
- Guarantees execution of a single sync process at a time
- Eliminates potential for data inconsistency during sync

* docs: document sync architecture and merge model

- Detail the 3-way merge model logic
- Describe the core synchronization architecture principles

* fix(lint): explicitly ignore lock.Unlock return value

errcheck linter flagged bare defer lock.Unlock() calls. Wrap in
anonymous function with explicit _ assignment to acknowledge
intentional ignore of unlock errors during cleanup.

* fix(lint): add sync_merge.go to G304 exclusions

The loadBaseState and saveBaseState functions use file paths derived
from trusted internal sources (beadsDir parameter from config). Add
to existing G304 exclusion list for safe JSONL file operations.

* feat(sync): integrate sync-branch into pull-first flow

When sync.branch is configured, doPullFirstSync now:
- Calls PullFromSyncBranch before merge
- Calls CommitToSyncBranch after export

This ensures sync-branch mode uses the correct branch for
pull/push operations.

* test(sync): add E2E tests for sync-branch and external BEADS_DIR

Adds comprehensive end-to-end tests:
- TestSyncBranchE2E: verifies pull→merge→commit flow with remote changes
- TestExternalBeadsDirE2E: verifies sync with separate beads repository
- TestExternalBeadsDirDetection: edge cases for repo detection
- TestCommitToExternalBeadsRepo: commit handling

* refactor(sync): remove unused rollbackJSONLFromGit

Function was defined but never called. Pull-first flow saves base
state after successful push, making this safety net unnecessary.

* test(sync): add export-only mode E2E test

Add TestExportOnlySync to cover --no-pull flag which was the only
untested sync mode. This completes full mode coverage:

- Normal (pull-first): sync_test.go, sync_merge_test.go
- Sync-branch: sync_modes_test.go:TestSyncBranchE2E (PR#918)
- External BEADS_DIR: sync_external_test.go (PR#918)
- From-main: sync_branch_priority_test.go
- Local-only: sync_local_only_test.go
- Export-only: sync_modes_test.go:TestExportOnlySync (this commit)

Refs: #911

* docs(sync): add sync modes reference section

Document all 6 sync modes with triggers, flows, and use cases.
Include mode selection decision tree and test coverage matrix.

Co-authored-by: Claude <noreply@anthropic.com>

* test(sync): upgrade sync-branch E2E tests to bare repo

- Replace mocked repository with real bare repo setup
- Implement multi-machine simulation in sync tests
- Refactor test logic to handle distributed states

Coverage: sync-branch end-to-end scenarios

* test(sync): add daemon sync-branch E2E tests

- Implement E2E tests for daemon sync-branch flow
- Add test cases for force-overwrite scenarios

Coverage: daemon sync-branch workflow in cmd/bd

* docs(sync): document sync-branch paths and E2E architecture

- Describe sync-branch CLI and Daemon execution flow
- Document the end-to-end test architecture

* build(nix): update vendorHash for gofrs/flock dependency

New dependency added for file-based sync locking changes the
Go module checksum.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-07 21:27:20 -08:00
mayor
50a0142a1d bd daemon sync: 2026-01-07 20:59:09 2026-01-07 20:59:09 -08:00
mayor
55fd5ba2db bd daemon sync: 2026-01-07 20:56:53 2026-01-07 20:56:53 -08:00