Commit graph

25 commits

Author SHA1 Message Date
Steven Syrek
f0057c7828
ci: install dolt binary on Linux and macOS test runners (#3440)
* 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).
2026-04-24 06:58:40 -07:00
Joseph Turian
b597fa168f fix: config-aware prefix detection in ResolvePartialID
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>
2026-03-05 17:19:33 -05:00
Aaron Lippold
63418ae549 fix: guard CREATE DATABASE to prevent shadow databases on wrong server
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>
2026-02-28 13:29:51 -05:00
jasper
e447ab2085 fix: isolate id_parser_test.go from shared Dolt server (bd-19i)
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
2026-02-27 16:31:27 -08:00
obsidian
ef57293e75 fix(dolt): stop wisp ID double-prefixing and add wisp fallback to ResolvePartialID
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
2026-02-24 15:50:46 -08:00
beads/crew/collins
6219b8692d fix: CI formatting, lint, and test failures blocking release
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>
2026-02-22 18:53:35 -08:00
beads/crew/emma
dd01a655b9 fix: repair test suite for Dolt-only backend (bd-h0zvj.4)
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
2026-02-15 18:17:16 -08:00
beads/crew/emma
12f9037d87 refactor: replace factory/memory imports with direct dolt calls (Phase 7 cleanup)
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
2026-02-15 13:22:06 -08:00
Krystian Gebis
1c92e9ce1c
perf(doctor): fix O(n) full-table scans causing 130s doctor runs (#1706)
* 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>
2026-02-14 14:50:37 -08:00
beads/crew/lizzy
2bb827facb style: run gofmt across entire codebase (bd-nmk12)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 19:35:20 -08:00
beads/crew/lizzy
de567cda79 chore: unexport 14 dead symbols across 8 packages
Unexport package-internal symbols that have no external callers:
- validation: ValidatePrefix, ValidatePrefixWithAllowed, ForUpdate, ForClose, ForDelete, ForReopen
- debug: PrintNormal, PrintlnNormal
- linear: IssuesQuery
- timeparsing: IsCompactDuration, ParseNaturalLanguage
- utils: FindMoleculesJSONLInDir, ParseIssueID
- testutil/fixtures: XLargeFromJSONL
- storage/sqlite: Snapshot type

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 09:24:22 -08:00
beads/crew/collins
80e75097fa test(utils): add multi-hyphen prefix tests for GH#405 (bd-s0qf)
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>
2026-02-05 21:35:18 -08:00
mayor
3d01c7fecc
fix: Support cross-prefix ID resolution in multi-repo scenarios (GH#1513)
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.
2026-02-05 14:05:24 -05:00
Nicolas Suzor
c8187137f5
fix(utils): prevent nil pointer panic in ResolvePartialID (#1132)
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>
2026-01-17 00:00:56 -08:00
Steve Yegge
aed166fe85 fix: improve issue ID prefix extraction for word-like suffixes
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>
2025-12-16 13:19:22 -08:00
Steve Yegge
77aeb50d27 fix(utils): parse multi-hyphen prefixes correctly (GH#405)
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>
2025-12-16 01:13:15 -08:00
Shaun Cutts
d541ff48e3 fix: accept 3-char all-letter base36 hashes in ExtractIssuePrefix (#446)
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
2025-12-02 23:00:24 -08:00
Steve Yegge
2320a1c2ef fix: ExtractIssuePrefix now handles 3-char base36 hashes (#425)
- 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
2025-11-30 20:50:56 -08:00
Steve Yegge
8becf0d9b9 fix: handle multi-hyphen prefixes with hash IDs (#419)
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>
2025-11-29 15:05:25 -08:00
Kris Hansen
9931ac9bd9
fix: support multi-part prefixes in issue ID extraction (#398) 2025-11-26 17:42:14 -08:00
Steve Yegge
934ae04fa0 Fix gh-316: Prefer exact ID matches over prefix matches
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>
2025-11-15 14:07:38 -08:00
Steve Yegge
83472aca3d bd sync: 2025-11-09 14:53:59 2025-11-09 14:53:59 -08:00
Midworld Kim
21ab565819
Fix hyphenated issue prefix detection (#199)
- update prefix/number parsing to use the last hyphen across utils and nodb paths
- add regression tests covering multi-hyphen prefixes in both packages
2025-11-01 19:57:37 -07:00
Steve Yegge
cd8cf997c9 Add comprehensive tests for internal/utils ID parsing functions
- Added tests for ExtractIssuePrefix (100% coverage)
- Added tests for ExtractIssueNumber (100% coverage)
- Enhanced ResolvePartialID tests with edge cases
- Added ResolvePartialIDs error handling tests
- Improved internal/utils coverage from 42% to 88%
- Overall project coverage increased from 45.6% to 45.8%

Amp-Thread-ID: https://ampcode.com/threads/T-1a44c987-7e49-431d-8e0b-467157d079eb
Co-authored-by: Amp <amp@ampcode.com>
2025-10-31 17:52:36 -07:00
Steve Yegge
2eb4c883ab Implement prefix-optional ID parsing (bd-170)
- 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>
2025-10-30 15:41:46 -07:00