Commit Graph

859 Commits

Author SHA1 Message Date
beads/crew/emma
b161e22144 fix: support delete in --no-db mode (GH#822)
Add CreateTombstone() to MemoryStorage and deleteBatchFallback() to
handle deletion when SQLite is not available. This fixes the error
"tombstone operation not supported by this storage backend" when
using bd delete with --no-db flag.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 11:45:52 -08:00
beads/crew/emma
6893eb6080 feat: add negation support for step conditions (!{{var}})
Adds "!{{var}}" syntax for negated truthy checks in Step.Condition.
Useful for "skip this step if feature is enabled" patterns.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 00:37:59 -08:00
beads/crew/emma
ee34a74e90 feat: implement Step.Condition evaluation in bd cook (bd-7zka.1)
Add compile-time step filtering based on formula variables:
- New EvaluateStepCondition function for {{var}} truthy and equality checks
- FilterStepsByCondition to exclude steps based on conditions
- Integration into pour, wisp, and mol bond commands
- Supports: {{var}}, {{var}} == value, {{var}} != value

Steps with conditions that evaluate to false are excluded from the
cooked formula, along with their children.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 00:33:11 -08:00
beads/crew/fang
1ec6df9eb5 fix: emit issue title with dep/label/comment mutation events (bd-sco6)
Added lookupIssueMeta helper to fetch title and assignee before emitting
mutation events. This makes bd activity and gt feed show informative entries
like "gt-xxx updated · Title..." instead of just "gt-xxx updated".

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 21:22:06 -08:00
Steve Yegge
202a617bb5 test: add coverage for GH#807 sync.branch main/master rejection
- Add TestSet cases for main/master rejection in syncbranch_test.go
- Add TestInitWithSyncBranch to verify --branch flag works
- Add TestInitWithoutBranchFlag to verify no auto-detection (root cause)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 18:19:53 -08:00
Steve Yegge
430c6bba9b Merge remote-tracking branch 'origin/fix/actor-on-status-events'
# Conflicts:
#	.beads/issues.jsonl
2025-12-30 18:14:27 -08:00
Steve Yegge
b919c47fd8 Exclude agent type from bd ready by default
Agent beads are identity/state tracking beads for agents, not actionable work items.
2025-12-30 18:13:12 -08:00
Steve Yegge
9cc385debc feat: Add --claim flag to bd update for work queue semantics (gt-il2p7)
Adds atomic claim operation for work queue messages:

- New --claim flag on bd update command
- Sets assignee to claimer and status to in_progress
- Fails with clear error if already claimed by someone else
- Works in both daemon and direct modes
- Includes comprehensive tests for claim functionality

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 18:09:34 -08:00
Steve Yegge
def4cf4efa Add sync branch integrity guards for force-push detection (bd-hlsw.4)
This implements sync branch integrity guards that detect when the remote
sync branch has been force-pushed since the last sync, preventing silent
data corruption.

Changes:
- Add internal/syncbranch/integrity.go with:
  - CheckForcePush() - detects force-push via stored remote SHA comparison
  - UpdateStoredRemoteSHA() - stores current remote SHA after successful sync
  - ClearStoredRemoteSHA() - clears stored SHA when resetting
  - GetStoredRemoteSHA() - retrieves stored SHA for inspection

- Update cmd/bd/sync.go to:
  - Add --accept-rebase flag for non-interactive reset to remote
  - Add force-push detection before sync branch pull operations
  - Prompt user for confirmation when force-push detected
  - Update stored remote SHA after successful sync

The implementation:
1. Tracks the remote sync branch commit SHA in config after each sync
2. On subsequent syncs, checks if stored SHA is ancestor of current remote
3. If not (force-push detected), warns user with details and prompts
4. User can accept reset or abort to investigate manually
5. --accept-rebase flag allows scripted/non-interactive recovery

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 17:07:25 -08:00
Steve Yegge
6b78b3fceb fix: bd sync fails to copy local changes TO beads-sync worktree (#810)
The bug: In a bare repo + worktrees setup, jsonlRelPath was calculated
relative to the project root (containing all worktrees), resulting in
paths like "main/.beads/issues.jsonl". But the sync branch worktree uses
sparse checkout for .beads/*, so files are at ".beads/issues.jsonl".

This caused SyncJSONLToWorktreeWithOptions to write to the wrong location
(e.g., worktree/main/.beads/ instead of worktree/.beads/), so changes
made locally never reached the sync branch worktree.

#785 fixed the reverse direction (worktree → local) by adding
normalizeBeadsRelPath(), but the local → worktree direction was missed.

Fix:
- Export NormalizeBeadsRelPath() (uppercase) for cross-package use
- Apply normalization in SyncJSONLToWorktreeWithOptions for dstPath
- Apply normalization in daemon_sync_branch.go for worktreeJSONLPath
  in both commit and pull paths
- Add unit tests for the normalization function

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 16:49:50 -08:00
Steve Yegge
7d4e8e2db9 fix: read operations no longer modify database file (GH#804)
Add SQLite read-only mode for commands that only query data (list, ready,
show, stats, blocked, count, search, graph, duplicates, comments, export).

Changes:
- Add NewReadOnly() and NewReadOnlyWithTimeout() to sqlite package
  - Opens with mode=ro to prevent any file writes
  - Skips WAL pragma, schema init, and migrations
  - Skips WAL checkpoint on Close()
- Update main.go to detect read-only commands and use appropriate opener
- Skip auto-migrate, FlushManager, and auto-import for read-only commands
- Add tests verifying file mtime is unchanged after read operations

This fixes the issue where file watchers (like beads-ui) would go into
infinite loops because bd list/show/ready modified the database file.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 16:47:38 -08:00
Steve Yegge
994512654c fix: prevent sync.branch from being set to main/master (#807)
Two issues fixed:
1. `bd init` was auto-detecting current branch (e.g., main) as sync.branch
   when no --branch flag was specified. This caused worktree conflicts.
2. Added validation to reject main/master as sync.branch values.

When sync.branch is set to main, the worktree mechanism creates a checkout
of main at .git/beads-worktrees/main/, which prevents git checkout main
from working in the user's working directory.

The sync branch feature should use a dedicated branch like 'beads-sync'.

🤖 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
2025-12-30 16:45:51 -08:00
Steve Yegge
6d84701a5f fix: migration 022 fails with SQL syntax error on v0.30.3 upgrade
db.Exec was being passed %s format specifiers directly in the SQL
string, but db.Exec does not do printf-style formatting - it uses the
variadic args as SQL parameter bindings. This caused the literal %s
to be sent to SQLite, which failed with near percent: syntax error.

Fixed by using fmt.Sprintf to interpolate the column expressions into
the SQL string before passing to db.Exec.

Added regression test that creates an old-schema database with edge
columns (replies_to, relates_to, duplicate_of, superseded_by) and
verifies migration 022 completes successfully.

Fixes #809

Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 16:45:01 -08:00
Steve Yegge
21a0ff6d0d Add type: event for state transitions (bd-ecmd)
Adds TypeEvent issue type for recording operational state changes as
immutable beads. Events capture:
- event_category: namespaced category (e.g., patrol.muted, agent.started)
- event_actor: entity URI who caused the event
- event_target: entity URI or bead ID affected
- event_payload: event-specific JSON data

Changes:
- Add TypeEvent constant and IsValid() support in types.go
- Add event fields to Issue struct with ComputeContentHash support
- Add --event-category/actor/target/payload flags to bd create
- Add event fields to RPC CreateArgs and UpdateArgs
- Add migration 033_event_fields to add columns to issues table
- Update insertIssue and queries to include event fields
- Fix migrations_test.go for new column requirements

This enables:
- bd activity --follow showing events
- bd list --type=event --target=agent:deacon
- Full audit trail for operational state
- HOP-compatible transaction records

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 16:27:59 -08:00
Steve Yegge
b45e68c5ce Add BD_AGENT_MODE for ultra-compact output
Adds agent-optimized output mode for `bd list` triggered by:
- BD_AGENT_MODE=1 environment variable (explicit)
- CLAUDE_CODE environment variable (auto-detect)

Agent mode provides:
- Ultra-compact format: just "ID: Title" per line
- Lower default limit (20 vs 50) for context efficiency
- No colors, no emojis, no pager
- Defaults to open/in_progress only (existing behavior)

(bd-x2ht)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 16:04:39 -08:00
Steve Yegge
643a162f0e Centralize validation patterns with composable validators (bd-jbqx)
Add composable issue validators to internal/validation package:
- IssueValidator type with Chain() composition function
- Exists(), NotTemplate(), NotPinned(), NotClosed(), NotHooked() validators
- HasStatus(), HasType() for checking allowed values
- ForUpdate(), ForClose(), ForDelete(), ForReopen() convenience chains

Update cmd/bd/show_unit_helpers.go to use centralized validators instead
of duplicated inline validation logic. This enables consistent validation
across all commands with a single source of truth.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 16:00:22 -08:00
Steve Yegge
0f21a80fe0 Add debug logging for tombstone resurrection events
When debug mode is enabled, the merge system now logs a message when
an expired tombstone loses to a live issue (resurrection occurs).
This helps understand why previously closed issues reappear.

Example output: "Issue bd-abc resurrected (tombstone expired)"

Changes:
- Add debug parameter to Merge3WayWithTTL and merge3Way functions
- Add debug logging in all 4 resurrection code paths
- Update tests to pass new debug parameter (bd-nl2)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 15:59:51 -08:00
Steve Yegge
31ee2a61b5 Use types.Status constants in merge package for type safety
Added StatusClosed constant derived from types.StatusClosed alongside
the existing StatusTombstone constant. Replaced hardcoded "closed"
strings with the constant for compile-time type checking consistency.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 15:58:49 -08:00
Steve Yegge
087a9dd984 Show actor on status/pinned change events in activity feed
Added actor field to RPC client and set it before daemon requests.
This ensures status changes (like pinned events) show who performed
the action in bd activity output.

Changes:
- Added actor field to Client struct
- Added SetActor method to set actor for audit trail
- Modified ExecuteWithCwd to include actor in RPC requests
- Updated main.go to call SetActor after daemon connection

Fixes gt-1ydd9

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 15:56:52 -08:00
Steve Yegge
6d292f6a0f feat: add type: event for operational state changes (bd-ecmd)
Adds support for event beads that capture operational state transitions
as immutable records. Events are a new issue type with fields:
- event_kind: namespaced category (patrol.muted, agent.started)
- actor: entity URI who caused the event
- target: entity URI or bead ID affected
- payload: event-specific JSON data

This enables:
- bd activity --follow showing events
- bd list --type=event --target=agent:deacon
- Full audit trail for operational state
- HOP-compatible transaction records

🤖 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
2025-12-30 15:54:51 -08:00
Steve Yegge
407e75b363 feat: add refs field for cross-references with relationship types (bd-irah)
- Add new DependencyType constants: until, caused-by, validates
- Add --refs flag to bd show for reverse reference lookups
- Group refs by type with appropriate emojis
- Update tests for new dependency types

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 15:52:33 -08:00
Steve Yegge
5f3cb0fdf3 refactor: remove Gas Town references from codebase
Replace Gas Town-specific terminology with generic orchestrator concepts:
- "Gas Town" → "orchestrator" or "multi-clone"
- Hardcoded ~/gt/ paths → GT_ROOT environment variable
- signalGasTownActivity → signalOrchestratorActivity
- GUPP → hook-based work assignment

Updated 21 files across CHANGELOG, cmd/bd/, internal/, docs/, scripts.

🤖 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
2025-12-30 14:13:32 -08:00
Steve Yegge
f6f9ef260d feat: auto-detect non-TTY and adjust output (bd-xrwy)
Add TTY detection to automatically disable ANSI colors when stdout is
piped or redirected. Respects standard conventions:
- NO_COLOR environment variable (no-color.org)
- CLICOLOR=0 disables color
- CLICOLOR_FORCE enables color even in non-TTY

Also adds ShouldUseEmoji() helper controlled by BD_NO_EMOJI.
Pager already disabled non-TTY in previous work (bd-jdz3).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 10:19:44 -08:00
Steve Yegge
06c8855873 feat: add daemon RPC endpoints for config and mol stale (bd-ag35)
Add two new RPC endpoints to allow CLI commands to work in daemon mode:

1. GetConfig (OpGetConfig) - Retrieves config values from the daemon database.
   Used by bd create to validate issue prefix in daemon mode.

2. MolStale (OpMolStale) - Finds stale molecules (complete-but-unclosed
   epics). Used by bd mol stale command in daemon mode.

Changes:
- internal/rpc/protocol.go: Add operation constants and request/response types
- internal/rpc/client.go: Add client methods GetConfig() and MolStale()
- internal/rpc/server_issues_epics.go: Add handler implementations
- internal/rpc/server_routing_validation_diagnostics.go: Register handlers
- cmd/bd/create.go: Use GetConfig RPC instead of skipping validation
- cmd/bd/mol_stale.go: Use MolStale RPC instead of requiring --no-daemon
- internal/rpc/coverage_test.go: Add tests for new endpoints

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 06:59:51 -08:00
Steve Yegge
96f2996997 Show actor on status/pinned change events in activity feed
Added actor field to RPC client and set it before daemon requests.
This ensures status changes (like pinned events) show who performed
the action in bd activity output.

Changes:
- Added actor field to Client struct
- Added SetActor method to set actor for audit trail
- Modified ExecuteWithCwd to include actor in RPC requests
- Updated main.go to call SetActor after daemon connection

Fixes gt-1ydd9

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 06:57:51 -08:00
Steve Yegge
7216109284 feat: add pager support to bd list (bd-jdz3)
Add pager support following gh cli conventions:

Flags:
- --no-pager: disable pager for this command

Environment variables:
- BD_PAGER / PAGER: pager program (default: less)
- BD_NO_PAGER: disable pager globally

Behavior:
- Auto-enable pager when output exceeds terminal height
- Respect LESS env var for pager options
- Disable pager when stdout is not a TTY (pipes/scripts)

Implementation:
- New internal/ui/pager.go with ToPager() function
- Added formatIssueLong/formatIssueCompact helper functions
- Buffer output before displaying to support pager

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:41:11 -08:00
Steve Yegge
ebd5c1b72a fix: rename BondRef.ProtoID to SourceID for clarity (bd-ia3g)
The ProtoID field in BondRef was misleading as it could hold both proto
IDs (from proto+proto bonds) and molecule IDs (from mol+mol bonds).
Rename to SourceID with updated JSON tag to better reflect its purpose.

Changes:
- Rename BondRef.ProtoID to SourceID in types.go
- Update JSON tag from proto_id to source_id
- Update all usages in mol_bond.go and tests

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:40:16 -08:00
Steve Yegge
b273465966 chore: remove stale TODOs for implemented Expand/ExpandVars (bd-qe7j)
- Step.Expand and Step.ExpandVars are implemented in ApplyInlineExpansions
  (expand.go), but had stale TODO comments claiming they were not
- Updated doc comments to reference the implementation
- Updated bd-7zka to reflect which features are still not implemented
  (Step.Condition and Step.Gate remain as future work)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:39:16 -08:00
Steve Yegge
0f8d7093b2 fix: add missing mockStorage methods for Storage interface compliance
Added GetDependenciesWithMetadata and GetDependentsWithMetadata to mockStorage
to match the Storage interface definition.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:26:56 -08:00
Steve Yegge
b63df91230 feat: add 'convoy' issue type with reactive completion (bd-hj0s)
- Add TypeConvoy to issue types for cross-project tracking
- Implement reactive completion: when all tracked issues close,
  convoy auto-closes with reason "All tracked issues completed"
- Uses 'tracks' dependency type (non-blocking, cross-prefix capable)
- Update help text for --type flag in list/create commands
- Add test for convoy reactive completion behavior

🤖 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
2025-12-30 00:04:43 -08:00
Steve Yegge
cb69f1c154 feat: Show actor on pinned/status change events (gt-1ydd9)
- Add Actor field to MutationEvent struct
- Use new assignee from update args instead of old issue state
- Include actor (who performed the action) in mutation events
- Display actor in bd activity output, falling back to assignee

When pinning/updating status, the activity feed now shows who performed
the action (e.g., "@gastown/crew/jack") instead of showing nothing.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 23:42:20 -08:00
Steve Yegge
3c6354c051 fix: prevent label accumulation when updating agent role_type/rig
When updating role_type or rig on an agent bead, remove existing
role_type:* or rig:* labels before adding the new one. This prevents
label accumulation that would break filtering.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 21:41:14 -08:00
Steve Yegge
a8748936e4 feat: add structured labels for agent beads (bd-g7eq)
Add role_type and rig labels to agent beads for filtering queries.

Changes:
- Add RoleType/Rig to CreateArgs and UpdateArgs in RPC protocol
- Auto-add role_type:<value> and rig:<value> labels when creating/updating agents
- Add --role-type and --agent-rig flags to bd create (requires --type=agent)
- Add bd agent backfill-labels command to update existing agent beads

This enables queries like:
  bd list --type=agent --label=role_type:witness
  bd list --type=agent --label=rig:gastown

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 21:15:46 -08:00
Steve Yegge
b8a5ee162b feat: Add tracks relation type for convoy tracking (bd-3roq)
Adds non-blocking tracks dependency type for convoy to issue relationships:
- Non-blocking: does not affect ready work calculation
- Cross-prefix capable: convoys in hq-* can track issues in gt-*, bd-*
- Reverse lookup: bd dep list <id> --direction=up -t tracks

Also adds bd dep list command with direction and type filtering for
querying dependencies/dependents.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 21:04:45 -08:00
Steve Yegge
34e2548c86 feat: bd list defaults to non-closed issues with 50 limit (GH#788)
Changes:
- Default to excluding closed issues (use --all to include)
- Default limit of 50 issues (use --limit 0 for unlimited)
- --all flag now overrides the closed filter

This addresses agent context blowout from seeing hundreds of closed issues.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 17:54:56 -08:00
Steve Yegge
a08dd63079 test: fix config test environment pollution
Tests were failing when BD_ACTOR or other BD_/BEADS_ environment
variables were set. Added envSnapshot helper to save, clear, and
restore environment variables for proper test isolation.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 16:08:43 -08:00
Jordan Hubbard
c9fa7af04c test: expand compact and ui coverage 2025-12-29 16:01:11 -08:00
Steve Yegge
d3b6855aa9 fix: resolve lint errors blocking CI
- Add explicit error checking for fmt.Fprintf/Fprintln in claude.go
- Add gosec nolint for safe exec.CommandContext calls in sync_git.go
- Remove unused error return from findTownRoutes in routes.go

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 15:58:24 -08:00
Steve Yegge
53a63f2779 fix: edge case in normalizeBeadsRelPath for similar prefixes
Code review caught that ".beads" would incorrectly match prefixes like
".beads-backup". Changed to match ".beads/" (with trailing slash) to
ensure we only match the actual .beads directory.

Added test cases for this edge case.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 15:51:17 -08:00
Steve Yegge
0fa97a4c30 fix: bd sync fails in bare repo worktrees (#785)
The bug: In a bare repo + worktrees setup, jsonlRelPath was calculated
relative to the project root (which contains all worktrees), resulting in
paths like "main/.beads/issues.jsonl". But the sync branch worktree uses
sparse checkout for .beads/*, so files are at ".beads/issues.jsonl".

This caused copyJSONLToMainRepo to look in the wrong location, silently
returning when the file was not found.

Fix: Add normalizeBeadsRelPath() to strip leading path components before
".beads", ensuring correct path resolution in both directions:
- copyJSONLToMainRepo (worktree -> local)
- SyncJSONLToWorktreeWithOptions (local -> worktree)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 15:39:23 -08:00
Steve Yegge
1256352d49 fix: bd delete --cascade now recursively deletes dependents (#787)
The --cascade flag was documented but not working for single-issue
deletes. The bug had two causes:

1. CLI direct mode: Single-issue deletes bypassed the batch path where
   cascade expansion actually happens. Fixed by routing cascade deletes
   through deleteBatch() regardless of issue count.

2. Daemon/RPC mode: handleDelete() iterated through IDs individually
   without expanding dependents. Fixed by using DeleteIssues() with
   cascade flag when SQLite storage is available.

Now `bd delete <id> --cascade --force` correctly deletes the target
issue plus all issues that depend on it (recursively).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 15:10:59 -08:00
Steve Yegge
c2c2ef5d07 feat: Update agent ID validation for canonical naming (gt-zvte2)
Updates ValidateAgentID to accept canonical format: prefix-rig-role-name
- Rig-level: gt-<rig>-witness (was gt-witness-<rig>)
- Named: gt-<rig>-crew-<name> (was gt-crew-<rig>-<name>)

Town-level agents unchanged: gt-mayor, gt-deacon

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 14:55:06 -08:00
Jordan Hubbard
12b797781d test: expand routing and compact coverage 2025-12-29 14:18:33 -08:00
Steve Yegge
96c7cceefc refactor: Extract IssueDetails to shared type (bd-6dnt)
Consolidated 5 duplicate IssueDetails struct definitions into a single
types.IssueDetails in internal/types/types.go:

- Removed 4 inline definitions from cmd/bd/show.go
- Removed 1 inline definition from internal/rpc/server_issues_epics.go

The shared type embeds types.Issue by value and includes:
Labels, Dependencies, Dependents, Comments, and Parent fields.

This improves maintainability and reduces risk of inconsistency.
2025-12-29 14:04:35 -08:00
Steve Yegge
64d5f20b90 fix: Add pre-migration orphan cleanup to avoid chicken-and-egg failure (bd-eko4)
When the database has orphaned foreign key references (dependencies or labels
pointing to non-existent issues), the migration invariant check would fail,
preventing the database from opening. This created a chicken-and-egg problem:

1. bd doctor --fix tries to open the database
2. Opening triggers migrations with invariant checks
3. Invariant check fails due to orphaned refs
4. Fix never runs because database won't open

The fix adds CleanOrphanedRefs() that runs BEFORE captureSnapshot() in
RunMigrations. This automatically cleans up orphaned dependencies and labels
(preserving external:* refs), allowing the database to open normally.

Added test coverage for the cleanup function.
2025-12-29 13:47:04 -08:00
Steve Yegge
819208b8c1 fix: hq- prefix routing by finding town root for routes.jsonl
The routing code now walks up from the current beads directory to find
the Gas Town root (identified by mayor/town.json), then loads routes
from <townRoot>/.beads/routes.jsonl. The '.' path is correctly resolved
to the town beads directory.

Previously, routes.jsonl was only searched in the current beads dir,
which failed when working from rig subdirectories like crew/emma.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 13:46:10 -08:00
Steve Yegge
5560a4243e refactor: Export FollowRedirect and consolidate duplicate implementations
- Rename followRedirect to FollowRedirect in internal/beads (export it)
- Update doctor/maintenance.go to use beads.FollowRedirect
- Update doctor/fix/common.go to use beads.FollowRedirect
- Remove 66 lines of duplicated code across 3 implementations

This ensures consistent redirect handling with path canonicalization,
chain prevention, and proper error warnings.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 13:23:05 -08:00
Steve Yegge
7d1ee6d3e9 feat: Add 'hooked' status for GUPP work assignment (bd-s00m)
Separates semantics of 'pinned' (identity records) from work-on-hook:
- 'pinned' = domain table / identity record (agents, roles) - non-blocking
- 'hooked' = work on agent's hook (GUPP-driven) - blocks dependents

Changes:
- Add StatusHooked constant to types.go
- Update all blocking queries to include 'hooked' status
- Add cyan styling for 'hooked' in UI output
- Create migration 032 to convert pinned work items to hooked

Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 22:37:04 -08:00
Steve Yegge
7ff5481966 fix: resolve golangci-lint errors (errcheck, gosec, unparam)
- orphans.go: check fmt.Scanln return value
- edit.go: #nosec G204 for trusted $EDITOR execution
- sync_git.go: #nosec G204 for git commands with internal branch names
- worktree_cmd.go: #nosec G304/G306 for .gitignore file operations
- migrations: handle rows.Close() error
- doctor_pollution.go: mark unused path parameter

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 20:50:54 -08:00
Steve Yegge
f3dcafca66 feat: Add mol_type schema field for molecule type classification (bd-oxgi)
Add mol_type field to beads for swarm coordination:
- Values: 'swarm' (multi-polecat), 'patrol' (recurring ops), 'work' (default)
- Nullable, defaults to empty string (treated as 'work')

Changes:
- Add mol_type column to SQLite schema and migration 031
- Add MolType type with IsValid() validation in types.go
- Update insertIssue/GetIssue to handle mol_type
- Add --mol-type flag to create command
- Add mol_type filtering to list and ready commands
- Update RPC protocol for daemon mode support
- Update test schema in migrations_test.go

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 19:52:51 -08:00