Issue IDs like bd-E.10 now sort after bd-E.9 instead of before bd-E.2.
Adds NaturalCompareIDs to internal/utils and replaces string comparison
in list, graph, swarm, todo, and tree display code.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* ci: install dolt binary on Linux and macOS test runners
Install dolt via the official install.sh on Linux and via Homebrew on
macOS so the main test job can exercise the ~24 test gates that
previously silently skipped on every PR when dolt was absent from PATH.
Matches the installation pattern already used by nightly.yml.
Docker-testcontainer gates (testDoltServerPort == 0 skips) remain
skipped — a known GitHub Actions hang documented in
scripts/repro-dolt-hang/INCIDENT-REPORT.md and nightly.yml:37-41
prevents enabling testcontainers here.
* test: require dolt binary under GITHUB_ACTIONS
Add testutil.RequireDoltBinary: skips when the dolt CLI is absent
locally but fails the test under GITHUB_ACTIONS. Replace bare
exec.LookPath("dolt") skip-gates with the helper so ~24 tests that
previously fell through silently in CI now run — and hard-fail if
the CI workflow ever drops the dolt install step.
tests/regression/regression_test.go uses an inline variant because
its gate lives in TestMain, and internal/remotecache/cache_test.go
duplicates the helper inline to avoid an import cycle
(testutil -> doltutil -> remotecache).
Remove all BEADS_NO_DAEMON env var handling from test files (dead code
since daemon removal in v0.50.0), delete stopRepoDaemon() and daemon
file guards from test setup, remove no-daemon config key from tests,
and update daemon→server wording in docs and comments.
37 files changed, -193 lines net.
Co-Authored-By: davetashner <davetashner@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Make issue ID resolution config-aware by using issue_prefix and
allowed_prefixes as ground truth for prefix detection, instead of
relying solely on heuristics.
Changes:
- Add ExtractIssuePrefixKnown() in issue_id.go: deterministic prefix
extraction that checks known prefixes (longest-first) before falling
back to the existing heuristic ExtractIssuePrefix()
- Add hasKnownPrefix() in id_parser.go: checks if input starts with
any known/allowed prefix
- Modify ResolvePartialID() to read allowed_prefixes from config and
use config-aware detection in both normalization (preventing
accidental prefix prepending) and hash extraction (correct prefix
boundary for multi-hyphen prefixes)
- Do NOT change looksLikePrefixedID() or ExtractIssuePrefix() —
existing heuristic behavior is preserved as fallback
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migrate 12 TestMain files to use EnsureDoltContainerForTestMain/TerminateDoltContainer
instead of the removed StartTestDoltServer/TestDoltServer API.
Replace testServer.IsCrashed()/CrashError() crash detection with standalone
testutil.DoltContainerCrashed()/DoltContainerCrashError() in 6 test files.
(bd-m7sy)
bd unconditionally ran CREATE DATABASE IF NOT EXISTS on every connection.
When connecting to the wrong server (auto-started from .beads/dolt/ or
Homebrew default), this created an empty shadow database hiding real data.
Changes:
- Add CreateIfMissing field to Config — only bd init sets it true
- SHOW DATABASES LIKE check before CREATE (with underscore escaping)
- Network error handling for SHOW DATABASES failure
- Suppress auto-start when metadata.json has explicit dolt_server_port
- Fix backup git push across .beads/redirect (findGitRoot)
- Fix macOS CanonicalizePath case resolution (walk dirs, not realpath)
- Add CreateIfMissing to all migration and create paths
- 10 regression tests covering guard, auto-start, ReadOnly, underscore
- CHANGELOG and TROUBLESHOOTING docs
Authored by: Aaron Lippold<lippold@gmail.com>
Add TestMain to internal/utils/ that starts an isolated test Dolt server
on a dynamic port, preventing test issues (offlinebrew-, aap-, cr-,
hq-abc12, bd-wisp-t3st) from leaking into the production database on
port 3307.
Changes:
- Add internal/utils/testmain_test.go with isolated test server setup
- Update newTestStore to use testServerPort and unique testdb_ databases
- Register utils-pkg-test-* in orphaned temp dir cleanup list
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/polecats/jasper
Rig: beads
Role: polecats
Two bugs fixed:
1. wispPrefix() generated bd-wisp-wisp-<hash> because IDPrefix='wisp' was
appended via configPrefix+"-"+IDPrefix, then "-wisp" was unconditionally
appended again. Now IDPrefix provides the suffix directly.
2. ResolvePartialID() only searched issues table via SearchIssues; the
DoltStore merges wisps but transaction-level SearchIssues does not.
Added explicit ephemeral fallback search to ensure wisps are always
resolvable by partial ID.
Closes: beads-yzh
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/polecats/obsidian
Rig: beads
Role: polecats
1. FORMATTING: gofmt 14 files.
2. LINT:
- Delete dead code cmd/bd/bootstrap.go (unused bootstrapEmbeddedDolt)
- Prefix unused 'actor' param in wisps.go updateWisp with _
- Prefix unused 'ctx' param in telemetry.go buildTraceProvider with _
3. TESTS: Add skipIfNoDolt to test helpers that call dolt.New() without
a running test server. In CI (no dolt installed), these tests now skip
instead of failing with "server unreachable at 127.0.0.1:3307".
Delete TestOpenFromConfig_Embedded and TestOpenFromConfig_DefaultsToEmbedded
which tested removed embedded Dolt functionality.
Fixed packages: beads_test, cmd/bd, cmd/bd/doctor, cmd/bd/doctor/fix,
internal/tracker, internal/utils
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix pre-existing test failures from Dolt-Native Pruning phases 1-8.
All internal/* packages and cmd/bd/doctor now pass. Remaining 19
failures in cmd/bd are routing (9), init path checks (7), and tips (3).
Key fixes:
- Remove type assertions on concrete *dolt.DoltStore (not an interface)
- Fix DATETIME timezone bug: normalize timestamps to UTC before storage
- Replace SQLite datetime() syntax with MySQL DATE_SUB() in stale tests
- Remove --backend flag from init test invocations (flag removed)
- Update doctor tests for Dolt-only backend behavior
- Skip/remove tests for removed features (CompactableStorage,
FederatedStorage, ExportToMultiRepo, merge driver, no-db mode)
- Add issue_prefix config in test stores that create issues
- Fix export_hashes → interactions table reference in schema test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
Phase 7 (a5da57e3) deleted internal/storage/factory/ and internal/storage/memory/
but left 30+ files still importing them. This commit fixes all broken references:
- Created internal/storage/dolt/open.go with NewFromConfig/NewFromConfigWithOptions
- Replaced all factory.New/NewFromConfig/NewWithOptions with dolt equivalents
- Broke import cycles in dolt/bootstrap.go (routing/utils/audit → local types)
- Removed dead storage.Config struct
- Converted all test files from memory.New() to dolt.New() test stores
- Removed tests that depended on deleted detectPrefix/LoadFromIssues/mockRemoteStore
46 files changed, 249 insertions(+), 851 deletions(-)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
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
* perf(doctor): fix O(n) full-table scans causing 130s doctor runs
Three performance fixes for bd doctor on large databases (23k+ issues):
1. CheckDuplicateIssues (66s → 10ms): Replace SearchIssues() that loaded
ALL issues into memory with SQL GROUP BY aggregation. The old code
transferred 23k full issue rows (50+ columns) over MySQL wire protocol
just to count duplicates.
2. CheckStaleClosedIssues (57s → 4ms): Replace SearchIssues() that loaded
ALL closed issues with SELECT COUNT(*) SQL query. Same root cause as #1.
3. ResolvePartialID (60s+ → <1s for missing IDs): The substring search
fallback loaded ALL issues when exact match failed. Now passes the hash
as a search query to leverage SQL-level id LIKE filtering instead of
transferring the entire database to Go for in-memory matching.
Total bd doctor runtime: 130s → 6s (22x speedup).
Total gt doctor runtime: infinite hang → 15s.
Root cause: These checks used store.SearchIssues() which does SELECT id
then GetIssuesByIDs() (full row fetch). On Dolt server mode with 23k+
issues, transferring all rows over MySQL wire protocol is catastrophically
slow. SQL aggregation and filtering avoid the data transfer entirely.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test(doctor): add 7 missing tests for performance PR
CheckStaleClosedIssues (6 tests):
- DisabledSmallCount: threshold=0, <10k closed → OK
- DisabledLargeCount: threshold=0, ≥10k closed → warning
- EnabledWithCleanable: threshold=30d, old issues → correct count
- EnabledNoneCleanable: threshold=30d, recent issues → OK
- PinnedExcluded: all pinned → 0 cleanable
- MixedPinnedAndStale: 5 stale + 3 pinned → reports 5
CheckDuplicateIssues (2 tests):
- MultipleDuplicateGroups: 2+ groups → correct groupCount/dupCount
- ZeroDuplicatesNullHandling: SUM() NULL → defaults to 0
ResolvePartialID (1 test):
- TitleFalsePositive: hash in title but different ID → rejected
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Add dec/adr aliases to utils.NormalizeIssueType() so CLI commands
like `bd list --type dec` resolve correctly. Add TypeDecision to
coreWorkTypes so `bd types` lists it. Update remaining help strings
in export, ready, and claude-plugin commands. Add alias test cases.
Co-authored-by: dariye <dariye@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
Merged internal/util (NormalizeIssueType, NormalizeLabels) into
internal/utils package. Updated 8 consumers to import from the
consolidated package. Eliminates the confusing coexistence of
two similarly-named utility packages.
Closes dolt-test-oli
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add test coverage for ExtractIssuePrefix with multi-hyphen prefixes
like 'hacker-news' and 'me-py-toolkit' that were previously parsed
incorrectly when falling back to first-hyphen splitting.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When issues from different rigs are hydrated into a single database,
each rig may have a different prefix (e.g., "aap-" for argocd, "hq-"
for town-level). Previously, `bd show aap-4ar` would fail when the
configured prefix was "hq-" because the code would incorrectly
normalize to "hq-aap-4ar".
The fix adds a `looksLikePrefixedID()` helper that detects if an input
already has a valid prefix format. If so, we skip prepending the
configured prefix and let the exact match or substring search handle it.
This enables Gas Town's `gt sling` command to resolve beads from any
rig regardless of the town-level prefix configuration.
In dolt-native mode (no issues.jsonl), FindJSONLInDir falls through
to "last resort" and returns the first .jsonl file found. This
caused routes.jsonl to be used as the export target, corrupting it
with issue data and breaking all cross-rig operations.
Fixes: bd-yxyh6
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add nil check at start of ResolvePartialID to return a proper error
instead of panicking when storage interface is nil.
Root cause: When bd refile (or other commands) is called with a nil
storage, calling store.SearchIssues() panics with SIGSEGV. This can
happen when routing fails to initialize storage properly.
Now returns: "cannot resolve issue ID <id>: storage is nil"
Fixes: bd-7ypor
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Centralizes repository context resolution via RepoContext API, fixing bugs where git commands run in the wrong repo when BEADS_DIR points elsewhere or in worktree scenarios.
Use SearchIssues with filter.IDs instead of GetIssue in ResolvePartialID.
This fixes inconsistencies where bd list could find issues that bd show
could not, due to subtle query differences between the two code paths.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
bd sync fails with exit status 128 when the daemon is started from a
terminal with different path casing than what git has stored. This
happens on macOS case-insensitive filesystem when directory names
are renamed (e.g., MyProject to myproject) but terminal sessions
retain the old casing.
The fix uses realpath(1) on macOS to get the true filesystem case
when canonicalizing paths:
- CanonicalizePath() now calls realpath on macOS
- git.GetRepoRoot() canonicalizes repoRoot via canonicalizeCase()
- syncbranch.GetRepoRoot() uses utils.CanonicalizePath()
This ensures git worktree paths match exactly, preventing the
exit status 128 errors from git operations.
🤖 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>
FindJSONLInDir() was returning interactions.jsonl when issues.jsonl
didn't exist. This caused bd sync to write issue data to the wrong
file after fresh init.
Add interactions.jsonl to the skip list alongside deletions.jsonl
and merge artifacts, so the function correctly defaults to issues.jsonl.
On macOS, /var is a symlink to /private/var, so EvalSymlinks returns
the canonical path. The test needs to resolve the expected target path
before comparison.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add support for template molecules (is_template field and TypeMolecule type):
- Add IsTemplate field to Issue type with JSON support
- Add TypeMolecule constant to IssueType constants
- Add IsTemplate filter to IssueFilter for querying
- Update all SQL queries to include is_template column
- Add migration 024 for is_template column
- Add FindMoleculesJSONLInDir helper for molecules.jsonl path detection
This enables treating certain issues as read-only templates that can be
instantiated to create work items. The template flag allows separating
template molecules from regular work items in queries and exports.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Refine ExtractIssuePrefix to better distinguish hash IDs from English
words in multi-part issue IDs. Hash suffixes now require digits or be
exactly 3 chars, preventing "test", "gate", "part" from being treated
as hashes. This fixes prefix extraction for IDs like "vc-baseline-test".
Also updates git hooks to use -q flag and adds AGENTS.md documentation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The ExtractIssuePrefix function was falling back to first-hyphen
extraction when the suffix didn't look like a hash (e.g., 4+ char
words without digits). This broke prefixes like 'hacker-news' where
an issue ID 'hacker-news-test' would incorrectly extract 'hacker'.
Fix: Always use last-hyphen extraction for alphanumeric suffixes.
Only fall back to first-hyphen for non-alphanumeric suffixes.
Examples:
- 'hacker-news-test' -> 'hacker-news' (was: 'hacker')
- 'me-py-toolkit-abc' -> 'me-py-toolkit' (was: 'me')
- 'vc-baseline-hello' -> 'vc-baseline' (was: 'vc')
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
isLikelyHash() required at least one digit to distinguish hashes from
English words, but base36 hashes can be all-letters by chance.
This caused ExtractIssuePrefix("xa-adt-bat") to return "xa" instead
of "xa-adt", breaking import for 20 issues in xa-adapt.
Fix: Accept all-letter suffixes for 3-char only, keep digit requirement
for 4+ chars where word collision probability is low enough (~0.2%).
Rationale:
- 3-char: 36³ = 46K hashes, ~1000 common words = ~2% collision
- 4-char: 36⁴ = 1.6M hashes, ~3000 words = ~0.2% collision
- 5+ char: collision rate negligible
- Lower minimum hash length from 4 to 3 characters
- Update hash validation to support base36 (0-9, a-z) instead of just hex
- Require at least one digit to distinguish hashes from English words
- Fixes prefix extraction for hyphenated prefixes with 3-char hashes
e.g., 'document-intelligence-0sa' now correctly extracts 'document-intelligence'
- Add test cases for 3-char hashes with multi-part prefixes
- Resolves bd sync failures with 'prefix mismatch detected' errors
Fixed bug where issue IDs with multiple hyphens in the prefix and hash
suffixes were incorrectly parsed. For example, `web-app-a3f8e9` was
being parsed with prefix `web-` instead of `web-app`.
Root cause: ExtractIssuePrefix() only checked for numeric suffixes.
When it encountered a hash suffix, it fell back to using the first
hyphen instead of the last hyphen.
Changes:
- Added isLikelyHash() helper to detect hexadecimal hash suffixes (4-8 chars)
- Updated ExtractIssuePrefix() to handle both numeric and hash suffixes
- Added comprehensive test cases for various prefix patterns
Test coverage includes:
- web-app-123 (numeric suffix)
- web-app-a3f8e9 (hash suffix)
- my-cool-app-a3f8e9 (three-part prefix with hash)
- super-long-project-name-1a2b (four-part prefix)
- Various hash lengths and case variations
Co-authored-by: dubstylee <dubstylee@users.noreply.github.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Extract shared JSONL file discovery logic to internal/utils/path.go.
Both autoimport and beads packages now use this shared implementation.
Changes:
- Add utils.FindJSONLInDir with common logic
- Update autoimport.go to use utils.FindJSONLInDir
- Update beads.go to delegate to utils.FindJSONLInDir
- Update server_export_import_auto.go to use utils.FindJSONLInDir
- Move FindJSONLInDir test to utils/path_test.go
- Fix pre-existing duplicate countIssuesInJSONLFile in init.go
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add fast path for exact ID matches in ResolvePartialID
- Properly unmarshal ResolveID RPC responses used by `bd show`
Summary:
--------
Fixes regression introduced after v0.23.1 where `bd show <issue_id>`,
`bd update <issue_id>`, and `bd close <issue_id>` commands failed with
"operation failed: issue not found" errors even when the issue existed
in the database.
Root Cause:
-----------
The daemon's ResolveID RPC handler (handleResolveID in
internal/rpc/server_issues_epics.go) returns a JSON-encoded string
containing the resolved issue ID. For example, when resolving "ao-izl",
the RPC response contains the JSON string: "ao-izl" (with quotes).
After v0.23.1, the show/update/close commands in cmd/bd/show.go were
changed to use string(resp.Data) to extract the resolved ID, which
treats the raw bytes as a string without decoding the JSON. This caused
the resolved ID to literally be "ao-izl" (including the quotes),
which then failed to match the actual issue ID ao-izl (without quotes)
when passed to subsequent Show/Update/Close RPC calls.
In v0.23.1 (commit 77dcf55), the code correctly unmarshaled the JSON:
var resolvedID string
if err := json.Unmarshal(resp.Data, &resolvedID); err != nil {
// handle error
}
This unmarshal step was removed in later commits, causing the regression.
Fix:
----
Restored the JSON unmarshaling step in three places in cmd/bd/show.go:
1. showCmd - line 37-42
2. updateCmd - line 400-405
3. closeCmd - line 723-728
Each now properly decodes the JSON string response before using the
resolved ID in subsequent RPC calls.
Testing:
--------
- Verified `bd show <issue-id-with-prefix>` works correctly in both daemon and direct modes
- Tested with newly created issues to ensure the fix works for all IDs
- All Go tests pass (go test ./... -short)
- Confirmed behavior matches v0.23.1 working binary
The fix ensures that issue ID resolution works correctly regardless of
whether the ID prefix matches the configured issue_prefix.
The ID disambiguation logic treated 'offlinebrew-3d0' as ambiguous when
child IDs like 'offlinebrew-3d0.1' existed. Now the system:
1. Checks for exact full ID matches first (issue.ID == input)
2. Checks for exact hash matches (handling cross-prefix scenarios)
3. Only falls back to substring matching if no exact match is found
Added test cases verifying:
- 'offlinebrew-3d0' matches exactly, not ambiguously with children
- '3d0' without prefix still resolves to exact match
Amp-Thread-ID: https://ampcode.com/threads/T-5358ea57-e9ea-49e9-aedf-7044ebf8b52a
Co-authored-by: Amp <amp@ampcode.com>
This change improves information density by using Base36 (0-9, a-z) instead
of hex (0-9, a-f) for hash-based issue IDs. Key benefits:
- Shorter IDs: Can now use 3-char IDs (was 4-char minimum)
- Better scaling: 3 chars good for ~160 issues, 4 chars for ~980 issues
- Case-insensitive: Maintains excellent CLI usability
- Backward compatible: Old hex IDs continue to work
Changes:
- Implemented Base36 encoding with proper truncation (keep LSB)
- Updated adaptive length thresholds (3-8 chars instead of 4-8)
- Fixed collision probability math to match encoding (was calculating
for base36 but encoding in hex - now both use base36)
- Fixed ID parser bug (use prefixWithHyphen for substring matching)
- Updated all tests and test data patterns
Fixes#213🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Extracts duplicated path canonicalization logic (filepath.Abs + EvalSymlinks)
into a reusable helper function utils.CanonicalizePath() in internal/utils/path.go.
Changes:
- Add internal/utils/path.go with CanonicalizePath() function
- Add comprehensive tests in internal/utils/path_test.go
- Replace inline canonicalization in beads.go:131-140
- Replace inline canonicalization in cmd/bd/main.go:446-454
- Replace inline canonicalization in cmd/bd/nodb.go:25-33
The new helper maintains identical behavior:
1. Converts path to absolute form via filepath.Abs
2. Resolves symlinks via filepath.EvalSymlinks
3. Falls back gracefully on errors (returns absPath if EvalSymlinks fails,
returns original path if Abs fails)
Fixes bd-efe8
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- update prefix/number parsing to use the last hyphen across utils and nodb paths
- add regression tests covering multi-hyphen prefixes in both packages