When bd sync fails mid-operation, the local JSONL can become stale while
the SQLite database has the correct state. Previously, bd doctor only
checked count and timestamp differences, missing cases where counts match
but issue statuses differ.
This adds content-level comparison to CheckDatabaseJSONLSync that:
- Compares issue statuses between DB and JSONL
- Samples up to 500 issues for performance on large databases
- Reports detailed mismatches (shows up to 3 examples)
- Suggests 'bd export' to fix the stale JSONL
Example detection:
Status mismatch: 1 issue(s) have different status in DB vs JSONL
Status mismatches detected:
test-1: DB=closed, JSONL=open
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add flag-based alternatives to the positional argument for `bd dep add`:
- `--blocked-by <id>`: Specify the blocking issue via flag
- `--depends-on <id>`: Alias for --blocked-by
This reduces token waste when Claude guesses flag-based syntax, which
is a common pattern. Previously, Claude would attempt commands like:
bd dep add issue-123 --blocked-by issue-456
This would fail with "unknown flag" and require retry. Now both:
bd dep add issue-123 issue-456
bd dep add issue-123 --blocked-by issue-456
work identically.
Closes GH#888
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The close_reason and closed_by_session fields were being silently dropped
during 3-way merge operations because the simplified Issue struct in
internal/merge/merge.go was missing these fields.
Changes:
- Add CloseReason and ClosedBySession fields to merge.Issue struct
- Implement merge logic that preserves these fields when status is closed
- Use timestamp-based conflict resolution (later closed_at wins)
- Clear close metadata when status becomes non-closed
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
On Windows, the downloaded ZIP file may remain locked by antivirus
software or Node.js file handle release delays. This causes
Expand-Archive to fail with "being used by another process" errors.
Added exponential backoff retry logic (5 attempts, 500ms-8s delays)
that detects file lock errors and retries the extraction. Non-lock
errors still fail immediately.
Fixes GH#889 (bd-5dlz)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Git 2.38+ enables core.sparseCheckout on the main repo as a side effect
of worktree creation, causing confusing git status message:
"You are in a sparse checkout with 100% of tracked files present."
The fix explicitly disables sparse checkout on the main repo after
creating the beads worktree. This doesn't affect the worktree's sparse
checkout functionality since the patterns are already applied during
checkout.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When gitRefsPath is empty (not in a git repo), strings.HasPrefix(path, "")
always returns true, causing every file write in .beads/ directory
(including daemon.log) to trigger debouncer and create an event storm.
This fix adds a check to ensure gitRefsPath is not empty before the
HasPrefix comparison.
Fixes the issue where daemon.log grows rapidly (17MB+) due to the
self-triggering loop: write log -> detect change -> write log -> ...
Co-authored-by: Test User <test@example.com>
When not in a git repository:
- Daemon startup now shows clear message immediately instead of waiting
5 seconds: "Note: No git repository initialized — running without
background sync"
- Added new doctor check "Git Sync Setup" that explains the situation
Doctor check now shows three states:
1. No git repo → Warning with fix: "Run 'git init' to enable background sync"
2. Git repo, no sync-branch → OK with hint about team collaboration benefits
3. Git repo + sync-branch → OK, fully configured
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
feat: add multi-prefix support via allowed_prefixes config
Adds support for allowing multiple prefixes in a beads database via the
allowed_prefixes config key. This is needed for Gas Town which uses different
prefixes for different purposes (hq-, gt-, rig-specific prefixes).
Usage: bd config set allowed_prefixes "gt,hq,hmc"
PR #881 by @web3dev1337
- Pull from sync-branch before rename if configured
- Import all issues from JSONL before rename to prevent data loss
- Export directly to JSONL after rename (don't rely on flushManager)
- Apply same pattern to --repair mode
- Add newSilentLogger() for production use (not test-only)
- Add comprehensive tests for JSONL update scenarios
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Allow team-wide auto-sync configuration via config.yaml instead of SQLite.
This enables teams to share auto-commit/auto-push settings through version control.
Changes:
- Add daemon.auto_commit, daemon.auto_push, daemon.auto_pull to YamlOnlyKeys
- Add daemon.* prefix to YAML-only prefixes
- Update daemon startup to read from config.yaml first, then fall back to SQLite
- Update bd init --team to write daemon settings to config.yaml
Usage:
# In .beads/config.yaml (version controlled, shared by team)
daemon.auto_commit: true
daemon.auto_push: true
# Or via bd config set
bd config set daemon.auto_commit true
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Users can now place a .beads/PRIME.md file to fully customize the
workflow instructions output by `bd prime`. The --export flag outputs
the default content for use as a starting template.
Local .beads/PRIME.md is checked first, then redirected location,
allowing clone-specific customization even with shared beads.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Review findings addressed:
1. Fixed HasSyncBranchGitignoreFlags() - now correctly returns (hasAnyFlag,
hasSkipWorktree) since skip-worktree takes precedence in git ls-files -v
2. Added interactions.jsonl to list of files to hide (was only issues.jsonl)
3. Added idempotency check - skips setting flags if already set (checks for S)
4. Made output conditional - only prints when flags actually changed
5. Fixed addToGitExclude() pattern matching - now uses exact line match
instead of substring to prevent false positives
6. Refactored to use setGitIndexFlags() helper to reduce duplication
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/crew/dave
Rig: beads
Role: crew
- Guard deploy-docs job to only run in canonical repository
- Guard goreleaser job to only run in canonical repository
- Guard update-homebrew job to only run in canonical repository
- Guard test-pypi job to only run in canonical repository
Prevents fork workflows from attempting to deploy, release, or publish to external services.
When sync.branch is configured, issues.jsonl appears modified in git status
even though changes go to the sync branch. This is confusing for users and
risks accidental commits to the wrong branch.
Implementation:
- Added SyncBranchGitignore() to set git index flags (assume-unchanged,
skip-worktree) on issues.jsonl when sync.branch is configured
- For untracked files, adds to .git/info/exclude instead
- Called automatically from bd sync after successful sync-branch sync
- Added bd doctor check and fix for this issue
- Added HasSyncBranchGitignoreFlags() to check current flag state
- Added ClearSyncBranchGitignore() to remove flags when sync.branch disabled
Fixes: GH#870 (duplicate of GH#797, GH#801)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/crew/dave
Rig: beads
Role: crew
The --protect-left-snapshot mechanism was protecting ALL local issues
by ID alone, ignoring timestamps. This caused newer remote changes to
be incorrectly skipped during cross-worktree sync.
Changes:
- Add BuildIDToTimestampMap() to SnapshotManager for timestamp-aware
snapshot reading
- Change ProtectLocalExportIDs from map[string]bool to map[string]time.Time
- Add shouldProtectFromUpdate() helper that compares timestamps
- Only protect if local snapshot is newer than incoming; allow update
if incoming is newer
This fixes data loss scenarios where:
1. Main worktree closes issue at 11:31
2. Test worktree syncs and incorrectly skips the update
3. Test worktree then pushes stale open state, overwriting mains changes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Complements the validation fix from c6fe9d71 - the parseAgentIDFields
function now also scans right-to-left for known role tokens instead
of using fixed position parsing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The sync.remote config was being set via `bd config set sync.remote <name>`
but `bd sync` was still using 'origin' for git pull/push operations.
Changes:
- Updated gitPull() and gitPush() in sync_git.go to accept a configuredRemote
parameter that takes precedence over git's branch tracking config
- Updated sync.go to read sync.remote config and pass it to gitPull/gitPush
- Updated daemon_sync.go to read sync.remote config for all daemon sync ops
- Added user-facing messages to show which remote is being used
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/crew/dave
Rig: beads
Role: crew
On macOS and Windows, filesystems are typically case-insensitive, so
/Users/foo/Desktop and /Users/foo/desktop refer to the same directory.
The daemon registry and discovery code was doing direct string comparison,
causing path mismatches when the casing differed.
Fix:
- Add NormalizePathForComparison() and PathsEqual() to internal/utils/path.go
- These resolve symlinks and lowercase paths on darwin/windows
- Update all workspace path comparisons in registry.go, discovery.go, and
daemons.go to use PathsEqual()
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Ensures AwaitType, AwaitID, and Timeout fields are carried over when
cloning template subgraphs, enabling async coordination in instantiated
molecules.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rewrites ValidateAgentID to scan right-to-left for known role tokens
instead of relying on fixed position parsing. This allows rig names
containing hyphens (e.g., ob-my-project-witness).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The bd agent state, heartbeat, and show commands now respect
routes.jsonl for cross-repo lookups, matching the behavior of
bd show.
Previously, these commands used utils.ResolvePartialID directly,
which bypassed routing. Now they use resolveAndGetIssueWithRouting
and needsRouting checks, consistent with show.go.
GetYamlConfig was not normalizing key aliases (e.g., sync.branch ->
sync-branch), causing 'bd config get sync.branch' to return 'not set'
even when the value was correctly stored.
SetYamlConfig already normalized keys, but GetYamlConfig did not,
leading to a confusing mismatch where set appeared to work but get
could not find the value.
Added TestGetYamlConfig_KeyNormalization to verify the fix.
Fixes#873
Adds a new slot bead type and merge-slot commands for serializing
conflict resolution in the merge queue. This prevents "monkey knife
fights" where multiple polecats race to resolve conflicts.
- Add TypeSlot to bead types
- Add Holder field to Issue struct
- Add bd merge-slot create/check/acquire/release commands
- Add Holder field to UpdateArgs in RPC protocol
(gt-4u49x)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Beads only had the skill version (Claude-only). This adds the command
version so users can type /handoff directly like in gastown.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add BenchmarkRebuildBlockedCache_Large and _XLarge to measure cache
rebuild performance in isolation.
Results show cache rebuild takes ~773ms at 10K issues and ~1.3s at 20K,
significantly slower than the ~50ms originally estimated in the issue.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Optimize CheckExternalDeps to group refs by project and open each
external DB only once, checking all capabilities in a single query.
Before: If 10 issues depend on external:gastown:cap1, we opened
gastown's DB 10 times.
After: We open each external project's DB once, query for all
capabilities needed from that project, then close.
Also added deduplication in filterByExternalDeps to collect all
unique refs before checking, avoiding redundant checks for the
same ref across multiple issues.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
createInRig was missing event fields (event_kind, actor, target, payload),
molecule/agent fields (mol_type, role_type, rig), and time scheduling
fields (due_at, defer_until). Now extracts these from cmd.Flags() directly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rewrite the beads release formula with gate syntax for async waits:
- Phase 1 (Prep & Push): preflight through push-tag
- Gate: await-ci step with gh:run gate on release.yml
- Phase 2 (Verify): parallel verify-github, verify-npm, verify-pypi
- Phase 3 (Install): fan-in at local-install, then daemons restart
Key improvements:
- Polecat does not sit idle during CI (5-10 min wait)
- Clean phase handoff via gt done --phase-complete
- Refinery auto-discovers and closes gate when CI completes
- Parallel verification runs concurrently after gate
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add `bd gate add-waiter <gate-id> <waiter>` command to register
agents as waiters on a gate bead using the native Waiters field
- Add `bd gate show <gate-id>` command to display gate details
including waiters (used by gt gate wake)
- Add Waiters field to UpdateArgs in RPC protocol
- Update server to handle waiters field in updates
This is part of the polecat phase handoff feature (bd-quw1).
The corresponding gastown changes (gt done --phase-complete) are
tracked separately.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements automatic discovery of GitHub workflow run IDs for gates
awaiting CI/CD completion. This enables the Refinery patrol to
auto-populate await_id for gh:run gates that were created without one.
Changes:
- Add `bd gate discover` command that:
- Finds open gh:run gates without await_id
- Queries recent GitHub workflow runs via gh CLI
- Matches runs to gates using heuristics (branch, commit, time)
- Updates gates with discovered run IDs
- Add `--await-id` flag to `bd update` for manual setting
- Add AwaitID to UpdateArgs in RPC protocol
- Add await_id to allowedUpdateFields in storage layer
Matching heuristics (scored, highest match wins):
- Commit SHA match: +100 points
- Branch match: +50 points
- Time proximity (<5min: +30, <10min: +20, <30min: +10)
- In-progress/queued status: +5 points
Usage:
bd gate discover # Auto-discover for all matching gates
bd gate discover --dry-run # Preview without updating
bd gate discover --branch main --limit 10
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When daemon fails to start due to legacy database or fingerprint validation,
the error was only logged to daemon.log. Users saw "Daemon took too long"
with no hint about the actual problem.
Changes:
- Write validation errors to .beads/daemon-error file before daemon exits
- Check for daemon-error file in autostart and display contents on timeout
- Elevate legacy database check in bd doctor from warning to error
Now when daemon fails due to legacy database, users see:
"LEGACY DATABASE DETECTED!
...
Run 'bd migrate --update-repo-id' to add fingerprint"
Instead of just "Daemon took too long to start".
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Claude Code v2.0+ moved from .claude/commands/ to .claude/skills/.
This adds the handoff skill in the new format so workers can use
/handoff to cycle to fresh sessions.
The skill wraps `gt handoff` with optional message support.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When pouring a formula with `title` and `desc` variables defined,
the root molecule's title and description now use {{title}} and
{{desc}} placeholders that get substituted during pour.
Previously, the root was always assigned the formula name and static
description, ignoring these common variables. Child beads correctly
substituted variables, but the root did not.
Fixes#852
When sync-branch is configured, JSONL files are intentionally untracked
in working branches and only committed to the dedicated sync branch.
The CheckIssuesTracking and CheckUntrackedBeadsFiles checks now detect
sync-branch mode via GetFromYAML() and return OK status instead of
false warnings.
The caller already checks IsCompound() before calling, so the internal
guard was unnecessary. Added doc comment clarifying the precondition.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for parsing the Gate field in formula steps:
- TestParse_GateField: JSON parsing with all gate fields
- TestParse_GateFieldTOML: TOML parsing
- TestParse_GateFieldMinimal: minimal gate with only type
- TestParse_GateFieldWithAllTypes: all gate types (gh:run, gh:pr, timer, human, bead, mail)
- TestParse_GateInChildStep: gate in nested child steps
The Gate struct and Step.Gate field already existed. These tests
verify TOML and JSON parsing works correctly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add visualization for compound molecules (those created by bonding protos):
- Detect compound molecules via IsCompound() check on root issue
- Display "Bonded from:" section showing constituent protos with bond types
- Show bond point when specified (attachment site within molecule)
- Format bond types as human-readable: sequential, parallel, on-failure, root
- Include is_compound and bonded_from in JSON output
Example output for compound molecules:
🧪 Compound: proto-feature-with-tests
ID: bd-abc123
Steps: 5
🔗 Bonded from:
├── proto-feature (sequential)
└── proto-testing (sequential, at step-2)
Added unit tests for compound detection and bond type formatting.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add bead gate type for cross-rig bead dependencies:
- await_type=bead with await_id=<rig>:<bead-id> format
- Add `bd gate check` command to evaluate open gates
- Support --type=bead to check only bead gates
- Support --dry-run to preview without closing
- Gate resolves when target bead is closed
Closes bd-w3rh
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement timer gate evaluation for Witness patrol integration:
- Add `bd gate check` command to evaluate gate conditions
- Support `--type=timer` filter to check only timer gates
- Check if `now > created_at + timeout` for timer gates
- Add `--escalate` flag to trigger `gt escalate` for expired gates
- JSON output support with `--json` flag
The command integrates with Witness patrol via:
bd gate check --type=timer --escalate
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement Phase 3 of gate evaluation: GitHub gates (gh:run and gh:pr).
## Changes
- Add `bd gate check` command to evaluate open gates
- Support --type=gh to check all GitHub gates
- Support --type=gh:run for GitHub Actions workflow run gates
- Support --type=gh:pr for pull request merge status gates
- Add --dry-run flag to preview gate resolution without closing
- Auto-close gates when conditions are met:
- gh:run: workflow completed with success
- gh:pr: PR merged
- Escalate when conditions fail:
- gh:run: workflow failed or cancelled
- gh:pr: PR closed without merging
- Add unit tests for shouldCheckGate filtering
Note: mol-refinery-patrol.formula.toml updated in gastown rig to include
check-github-gates step (version 4).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Align beads skill with Claude Code best practices:
- Restructure SKILL.md from 3,306 to ~510 words (85% reduction)
- Use bd prime as CLI reference source of truth (DRY)
- Rename references/ to resources/ per Claude Code conventions
- Add v0.43.0 feature documentation (agents, gates, worktrees)
- Add ADR-0001 documenting the bd prime decision
- Add CLAUDE.md maintenance guide
New resources:
- agents.md - Agent bead tracking
- async-gates.md - Human-in-the-loop gates
- chemistry-patterns.md - Mol vs Wisp decision tree
- worktrees.md - Parallel development patterns
BREAKING: references/ path changed to resources/
Fixes#855
Ensure deterministic output when merging issues. Go map iteration order
is non-deterministic, causing inconsistent merge results across runs.
Sort result slice by ID before returning, matching bd export behavior.
Fixes#853
Previously, `bd agent state <agent> <state>` would fail if the agent bead
didn't exist in the database. This caused issues when `gt sling` tried to
update agent state for newly spawned polecats.
Now when the agent doesn't exist:
1. Parse role_type and rig from the agent ID (e.g., gt-gastown-polecat-nux)
2. Auto-create the agent bead with type=agent
3. Add role_type and rig labels for filtering (bd list --label=role_type:polecat)
4. Continue with the state update
This enables:
- Work history accumulation per polecat name
- Skill/success tracking over time
- `bd list --type=agent` to see all agents
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The 0.43.0 release bump missed several files that should have been
updated by scripts/bump-version.sh:
- npm-package/package.json
- integrations/beads-mcp/pyproject.toml
- integrations/beads-mcp/src/beads_mcp/__init__.py
- .claude-plugin/plugin.json
- .claude-plugin/marketplace.json
- cmd/bd/templates/hooks/*
This caused the NPM publish to fail (could not publish 0.42.0 over itself).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/crew/dave
Rig: beads
Role: crew
- Fix help text to accurately describe cross-rig dependency handling
- Remove dead same-rig code path (moves are always cross-rig)
- Simplify remapDependencies to always use external refs
- Document that comments/history are not transferred
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/crew/dave
Rig: beads
Role: crew