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>
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
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>
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.
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>
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>
- 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>
- Add internal/utils/id_parser.go with ParseIssueID and ResolvePartialID
- Update all CLI commands to accept IDs without prefix (e.g., '170' or 'bd-170')
- Add comprehensive tests for ID parsing functionality
- Works in direct mode; RPC handlers to be updated in bd-177
Commands updated:
- show, update, edit, close (show.go)
- reopen (reopen.go)
- dep add/remove/tree (dep.go)
- label add/remove/list (label.go)
- comments (comments.go)
Amp-Thread-ID: https://ampcode.com/threads/T-1f6a301b-b53f-440f-bd79-e453234ac1c9
Co-authored-by: Amp <amp@ampcode.com>