Commit graph

39 commits

Author SHA1 Message Date
matt wilkie
ca1ae15d02
Fix init leaving beads.role unset in edge cases (GH#2950) (#2964)
Root cause: multiple code paths in bd init could skip setting beads.role:
- BEADS_DIR set → git init skipped → isGitRepo() false → role block skipped
- promptContributorMode() fails → role never set
- Non-interactive without explicit --role → only sets if not already present

Fix: Add safety net at end of init that checks isGitRepo() && !hasRole
and defaults to 'maintainer' (or --role value). This guarantees every
init leaves beads.role configured.

Also:
- Improve routing.go warning to show one-command fix
- Update doctor check fix to use 'git config' directly (simpler)
- Add TestInitNonInteractiveAlwaysSetsRole regression test

Amp-Thread-ID: https://ampcode.com/threads/T-019d4a99-63c8-779f-bb8e-ee8522b61cdf

Co-authored-by: Amp <amp@ampcode.com>
2026-04-01 17:00:41 -07:00
beads/crew/emma
d7629204f9 refactor: remove multi-rig routing from beads
Remove the entire multi-rig routing engine (routes.go, route resolution,
prefix-based dispatch) and cross-rig commands (move, refile). All bd
commands now operate on the local rig only.

Deleted: internal/routing/routes.go, cmd/bd/move.go, cmd/bd/refile.go,
and 5 associated test files.

Simplified: routed.go, close.go, create.go, dep.go, gate.go, list.go,
ready.go, promote.go, show.go, show_display.go.

Retained: contributor routing (routing.go, routing_read.go) is unchanged.

Resolves: bd-8hc5

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 19:53:13 -07:00
Bella-Giraffety
199c55c5fa
Fix routed town-root drift in nested worktrees (#2816)
* fix: anchor routed town root to active beads dir (bd-e3q)

* fix: fail closed for authoritative routed contexts (bd-e3q)

---------

Co-authored-by: obsidian <thalia.geraghty@fiserv.com>
2026-03-27 15:32:05 -07:00
garnet
3dae6bb3df refactor: remove gastown/Gas Town string references from beads code and docs (bd-1ue8)
Replace gastown-specific references with generic alternatives throughout
the codebase:

- Rename --gastown flag to --orchestrator in bd doctor
- Rename gastownMode/gastownThreshold params to orchestratorMode/orchestratorThreshold
- Rename isGasTownTownRoot() to isOrchestratorRoot()
- Replace "gastown" in CLI examples with generic rig names (my-project, other-project)
- Update comments replacing "Gas Town" with "orchestrator" or "multi-agent workspace"
- Update active docs (DOLT.md, CONFIG.md, ADVANCED.md, etc.)
- Update test data to use generic names instead of "gastown"
- Update role templates (deacon, witness, refinery) to use generic language

Preserved as historical (not changed):
- CHANGELOG.md entries (historical record)
- ARTICLES.md (links to real published articles)
- info.go version notes (historical release notes)
- gastown/ file path references in dolt-concurrency.md (point to actual repo)
2026-03-20 18:39:50 -07:00
amber
6468766523 fix: remove hardcoded ~/gt/ paths from beads codebase (bd-h615)
Replace ~/gt/ and ~/hop/ hardcoded paths with generic placeholders:
- routes.go comments: use <town-root> and <town> placeholders
- routing_test.go comments: use <town> placeholder
- deacon.md.tmpl: use {{ .TownRoot }} template variable
- witness.md.tmpl: use {{ .TownRoot }} template variable
- docs/DOLT.md: use <town-root> placeholder in example
- scripts/release.sh: reference docs by name, not path
- federation_test.go: reference HOP docs by name, not path

CHANGELOG.md entries left unchanged (historical records).
2026-03-20 18:31:13 -07:00
coffeegoddd☕️✨
58915b13e7 /{cmd,internal}: update global store to be interface 2026-03-17 13:26:17 -07:00
mrmaxsteel
fb51196f79 fix: preserve source rig's dolt_database across .beads/redirect
When bd follows a .beads/redirect file (e.g., from a rig to the Gas Town
root), it loads metadata.json from the TARGET directory. This overwrites
the source rig's dolt_database with the target's (e.g., "hq" instead of
"lola"), causing bd list/show to query the wrong database.

This affects both:
1. CWD path: running bd from a rig directory
2. Routing path: gt sling/bd show <routed-id> from the town root

Fix:
- Add ResolveRedirect() that reads source metadata.json (raw JSON, no
  Dolt connection) before following the redirect
- In main.go: set BEADS_DOLT_SERVER_DATABASE early so all store opens
  use the correct database
- In routing/routes.go: ResolveBeadsDirForID and ResolveBeadsDirForRig
  use ResolveRedirect and set the env var when a redirect changes the DB
- In routed.go: treat env var override as "routes differently" even when
  the target directory is the same (centralized Dolt serves multiple DBs
  from one .beads dir)

The env var BEADS_DOLT_SERVER_DATABASE retains highest priority — the
fix only sets it when not already set.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 15:03:29 -07:00
beads/crew/emma
f4c575e482 refactor: consolidate ExtractPrefix into types package
extractPrefix in dolt/dependencies.go and ExtractPrefix in
routing/routes.go were identical implementations. Move the
canonical definition to types.ExtractPrefix (importable by both
packages without cycles) and delegate from routing.ExtractPrefix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 23:17:14 -08:00
Osamu Okano
746564e361
fix: detect fork workflow as contributor when role unset 2026-03-02 20:25:52 +09:00
beads/crew/jane
3962285726 chore: clean up stale SQLite references in comments (bd-nlw2m)
Update ~20 stale comments across the Dolt storage layer that still
referenced SQLite after the migration to Dolt-only storage. Rename
LargeSQLite/XLargeSQLite fixture functions to LargeDolt/XLargeDolt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 11:50:52 -08:00
Steve Yegge
be39fe4e63
Merge pull request #1751 from julianknutsen/fix/routing-redirect-parent-base
test: lock relative redirect resolution for routed lookups
2026-02-15 12:17:23 -08:00
beads/crew/emma
a5da57e39b refactor: remove storage factory, memory backend, and provider abstraction (Phase 7)
Strip out the multi-backend storage layer: factory pattern, memory/in-memory
provider, connection string parsing, local provider, and associated tests.
Inline Dolt as the sole storage backend. Part of Dolt-Native Beads v2 epic.

WIP - SQLite removal in progress, more cleanup phases to follow.

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-15 11:27:39 -08:00
julianknutsen
d5dacdba0d test: lock relative redirect resolution for routed lookups 2026-02-14 21:17:18 +01:00
ALTECK Member
524e7249e0 fix: consolidate redirect resolution into single FollowRedirect function
Previously, resolveRedirect in internal/routing/routes.go duplicated the
redirect resolution logic from beads.FollowRedirect. This created risk of
inconsistent behavior between routing-based lookups and direct beads discovery.

Changes:
- Remove resolveRedirect from routes.go entirely
- Update callsites to use beads.FollowRedirect directly
- Add BD_DEBUG_ROUTING logging to FollowRedirect for debugging parity

This ensures all redirect resolution goes through a single code path with
consistent behavior: comment handling, path canonicalization (absolute paths,
symlinks, case-sensitivity), and redirect chain prevention.

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-14 11:02:29 -08:00
vault
afd352c3d8 fix: resolve redirect paths from parent of .beads dir, not .beads itself
resolveRedirect() in routing/routes.go resolved relative redirect paths
from the .beads directory itself (filepath.Join(beadsDir, redirectPath)),
while FollowRedirect() in beads.go correctly resolves from the parent
directory (filepath.Join(filepath.Dir(beadsDir), redirectPath)).

This inconsistency caused routing to resolve redirect targets to wrong
paths. For example, a redirect containing "mayor/rig/.beads" from
project/.beads/ would resolve to project/.beads/mayor/rig/.beads (wrong)
instead of project/mayor/rig/.beads (correct).

The fix aligns resolveRedirect() with FollowRedirect() by using
filepath.Dir(beadsDir) as the base for relative path resolution.

Fixes: hq-7wa47

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 18:46:45 +00:00
collins
237f47ba7e feat: delete SQLite storage backend (Phase 2 of Dolt transition)
Remove the entire internal/storage/sqlite/ package (~43K lines) and update
all 80+ files that imported it to use either the Dolt backend directly
(test files) or the storage factory (production files).

Key changes:
- Delete internal/storage/sqlite/ directory (150+ files)
- Update factory to make Dolt the sole backend, treating "sqlite" as alias for "dolt"
- Replace sqlite.New() calls with dolt.New() in tests, factory.New() in production
- Replace *sqlite.SQLiteStorage with storage.Storage interface throughout
- Replace :memory: SQLite URIs with t.TempDir() for Dolt compatibility
- Inline sqlite.GenerateIssueID() as SHA-256 content hashing where needed
- Fix import cycle in routing/routes.go (routing→factory→dolt→routing)
- Preserve backward-compatible beads.NewSQLiteStorage() wrapper in public API

228 files changed, 605 insertions, 43,821 deletions.
go vet ./... passes clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 12:23:15 -08:00
beads/crew/emma
761d2e7637 Merge pull request #1186 from peterkc/feature/contributor-prompt-recovery
feat(init): add contributor prompt and push-fail recovery

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-01-29 20:05:53 -08:00
emma
bf0bf7b156 fix(dolt): prevent daemon startup and fix routing same-dir check
- Daemon now refuses to start when dolt backend is configured
  (dolt uses sql-server mode, not the SQLite daemon)
- Add same-directory check in GetRoutedStorageWithOpener to avoid
  opening duplicate connections when routing resolves to current dir

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 17:39:44 -08:00
beads/crew/emma
e82f5136c1 fix(dolt): proper server mode support for routing and storage
- FindDatabasePath now handles Dolt server mode (no local dir required)
- main.go uses NewFromConfigWithOptions for Dolt to read server settings
- Routing uses factory via callback to respect backend configuration
- Handle Dolt "database exists" error (error 1007) gracefully

Previously, Dolt server mode failed because:
1. FindDatabasePath required a local directory to exist
2. main.go bypassed server mode config when creating Dolt storage
3. Routing always opened SQLite regardless of backend config

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 00:26:58 -08:00
Peter Chanthamynavong
9e16f34733
feat(role): implement explicit role configuration via git
- Prioritize beads.role git configuration in detection logic
- Add validation checks to bd doctor for role setup
- Update documentation with migration guides and setup steps
- Include unit tests for role validation logic

Allows users to explicitly define their development role for more predictable routing and diagnostics.
2026-01-20 20:53:01 -08:00
aleiby
f4ee7ee73b
fix(routing): default to Maintainer when no git remote exists (#1185)
When no git remote is configured, DetectUserRole() now defaults to
Maintainer instead of Contributor. This fixes issue routing for:

1. New personal projects (no remote configured yet)
2. Intentionally local-only repositories

Previously, issues would silently route to ~/.beads-planning instead
of the local .beads/ directory.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 10:11:00 -08:00
dennis
1f59119144 fix(sync): use town-level routes for prefix validation
Follow-up to 828fc11b addressing code review feedback:

1. Added LoadTownRoutes() - exported function that walks up to find
   town-level routes.jsonl (e.g., ~/gt/.beads/routes.jsonl)

2. Updated buildAllowedPrefixSet to use LoadTownRoutes instead of
   LoadRoutes, so it finds routes even when importing from a rig's
   local beads directory

3. Added unit tests for buildAllowedPrefixSet covering:
   - Primary prefix inclusion
   - allowed_prefixes config parsing
   - Routes from routes.jsonl
   - Missing routes.jsonl handling
   - Empty beadsDir handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 09:51:46 -08:00
Bo
6b5bebfa12
fix(routing): handle symlinked .beads directories correctly (#1112)
When .beads is a symlink (e.g., ~/gt/.beads -> ~/gt/olympus/.beads),
findTownRoutes() incorrectly used filepath.Dir() on the resolved
symlink path to determine the town root.

This caused route resolution to fail because the town root would be
~/gt/olympus instead of ~/gt, making routes point to non-existent
directories.

The fix adds findTownRootFromCWD() which walks up from the current
working directory instead of the beads directory path. This finds
the correct town root regardless of symlink resolution.

Changes:
- Add findTownRootFromCWD() function
- Update findTownRoutes() to use CWD-based town root detection
- Add fallback to filepath.Dir() for non-Gas Town repos
- Add debug logging (BD_DEBUG_ROUTING=1)
- Add comprehensive test case

Test: go test ./internal/routing/...
2026-01-15 19:20:42 -08:00
Peter Chanthamynavong
31239495f1
fix(routing): complete bd init --contributor routing (bd-6x6g) (#1088)
Implements the missing contributor routing logic so bd init --contributor actually works. Contributors' issues automatically route to ~/.beads-planning/ while maintainers' issues stay local.
2026-01-14 20:50:56 -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
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
Jordan Hubbard
12b797781d test: expand routing and compact coverage 2025-12-29 14:18:33 -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
1611f16751 refactor: remove unused bd pin/unpin/hook commands (bd-x0zl)
Analysis found these commands are dead code:
- gt never calls `bd pin` - uses `bd update --status=pinned` instead
- Beads.Pin() wrapper exists but is never called
- bd hook functionality duplicated by gt mol status
- Code comment says "pinned field is cosmetic for bd hook visibility"

Removed:
- cmd/bd/pin.go
- cmd/bd/unpin.go
- cmd/bd/hook.go

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 16:02:15 -08:00
Steve Yegge
c8b912cbe6 bd sync: 2025-12-27 15:56:42 2025-12-27 15:56:42 -08:00
Steve Yegge
2e7b993a88 feat: add --prefix flag for cross-rig issue creation
Adds --prefix as a forgiving alias to --rig flag. Accepts:
- Exact prefix: bd-, gt-
- Prefix without hyphen: bd, gt
- Rig name: beads, gastown

All resolve to the correct rig via routes.jsonl lookup.
This matches agents' mental model of prefix-based routing.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 14:26:00 -08:00
Steve Yegge
21f307de89 feat: add --rig flag for cross-rig issue creation (bd-4nzq)
Adds --rig flag to bd create that allows creating issues in a different
rig without having to cd to that directory.

Example: bd create --rig beads --title='Bug report'

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 00:44:39 -08:00
Steve Yegge
05304e3ab1 Merge origin/main, fix test git init for modern git 2025-12-27 00:17:36 -08:00
Steve Yegge
a958c83422 feat: auto-resolve cross-rig IDs in bd dep add (bd-lfiu)
When `bd dep add` fails to resolve the dependency ID locally, it now
checks routes.jsonl for a matching prefix and auto-converts to an
external reference format (external:<project>:<id>).

This allows simpler syntax like:
  bd dep add gt-xyz bd-abc

Instead of the verbose:
  bd dep add gt-xyz external:beads:bd-abc

New functions in routing package:
- ExtractProjectFromPath: Gets project name from route path
- ResolveToExternalRef: Converts foreign ID to external ref using routes

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 23:47:42 -08:00
Ryan Snodgrass
350a78f1ba
fix: resolve all golangci-lint errors
Fixes 15 pre-existing lint issues:

errcheck (6 issues):
- mol_distill.go: Add _ = for f.Close() and os.Remove()
- routed.go: Add _ = for routedStorage.Close() (4 locations)

gosec (8 issues):
- maintenance.go, routes.go: Add nolint for G304 (file paths from known dirs)
- mol_distill.go: Add nolint for G304 (file creation in known search paths)
- formula.go: Change WriteFile permissions from 0644 to 0600 (G306)
- gate.go: Add nolint for G204 (exec.Command with trusted AwaitID fields)

misspell (1 issue):
- gate.go: Fix "cancelled" -> "canceled" in comment

unparam (2 issues):
- cook.go, controlflow.go: Add nolint for functions returning always-nil error

Also:
- Update pre-commit-hooks to v6.0.0
- Add lint step to "Landing the Plane" session-end protocol
2025-12-26 19:20:03 -05:00
Steve Yegge
1583c57374 feat: Add prefix-based routing with routes.jsonl (bd-9gvf)
Enables cross-repo issue lookups via routes.jsonl configuration.
Running `bd show gt-xyz` from ~/gt now routes to the correct beads
directory based on the issue ID prefix.

- Add internal/routing/routes.go with routing logic
- Add cmd/bd/routed.go with routed storage helpers
- Update show command to use routed resolution in direct mode
- Support redirect files for canonical database locations
- Debug output available via BD_DEBUG_ROUTING=1

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 14:36:20 -08:00
Steve Yegge
8e05847d31 Fix TestRoutingIntegration and improve DetectUserRole robustness
Amp-Thread-ID: https://ampcode.com/threads/T-fc47ce9d-88a4-4bcd-b9cb-79327d98dee7
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 19:04:42 -05:00
Steve Yegge
58e915f22b Implement auto-routing for bd create (bd-ubu2)
- Add internal/routing package with DetectUserRole and DetermineTargetRepo
- Add routing config schema (mode, default, maintainer, contributor)
- Add --repo flag to bd create for explicit override
- Integrate routing logic into create command
- Test with contributor/maintainer roles and explicit override

Part of bd-8hf (Auto-routing and maintainer detection)
2025-11-04 23:12:42 -08:00