Add Go-side dedup in searchTableInTx to ensure SearchIssues never
returns the same issue ID twice, regardless of how many dependency
subqueries match. This prevents bd list from showing issues multiple
times when they have more than one blocks dependency.
`Ephemeral=&false` in SearchIssuesInTx previously only queried the issues
table, skipping the wisps table entirely. But NoHistory beads (ephemeral=0,
no_history=1) live in the wisps table and must survive export.
Extend the wisps merge pass to also run when Ephemeral=&false. The WHERE
clause (`ephemeral=0 OR ephemeral IS NULL`) already exists in the wisps
query via BuildIssueFilterClauses — so NoHistory beads are included while
true ephemeral wisps (ephemeral=1) are correctly excluded.
Fixes the regression flagged in GH#3659 review: `TestExportNoHistoryBeadRoundTrip`
documents that NoHistory beads must survive export/import. (GH#3649)
Keep GetLabelsForIssuesInTx compatible with existing callers that pass a scoped active-wisp set while retaining the new batched partitioner for default callers.
This fixes stale Dolt tests on PR #3666 after the GH#3414 batching refactor.
Co-authored-by: Harry Miller <harry_miller@trimble.com>
Every mutating bd command against a remote Dolt backend hung ~10–15s
with `auto-export failed: ... hydrate labels: ... context canceled`.
Root cause: five bulk fetchers in internal/storage/issueops partitioned
IDs into wisp vs permanent buckets by calling IsActiveWispInTx once per
ID, and each call is a round-trip to the SQL server. With ~600 issues
over WAN latency that's ~12s of sequential SELECTs *before* the real
label query runs — blowing past the context deadline.
Fix:
- Add PartitionWispIDsInTx that batches the check into one
`SELECT id FROM wisps WHERE id IN (...)` per queryBatchSize chunk,
reducing cost from O(N) to O(1 + N/200) round-trips. Falls back to
"no wisps" when the wisps table is absent (pre-migration dbs).
- Rewrite GetLabelsForIssuesInTx, GetCommentsForIssuesInTx,
GetDependencyRecordsForIssuesInTx, GetBlockingInfoForIssuesInTx, and
DeleteIssuesInTx to use it.
- Add fast-path helpers GetLabelsForIssuesFromTableInTx and
GetDependencyRecordsForIssuesFromTableInTx for callers (searchTableInTx)
that already know every ID is in a single table, skipping the partition
round-trip entirely on the hot auto-export path.
Tests:
- New wisp_partition_test.go covering the partitioner directly: empty,
all-perm, all-wisp, mixed-with-unknown, input-order preservation, and
a 450-ID large-batch case crossing the queryBatchSize boundary.
- End-to-end mixed-routing regression tests for GetCommentsForIssues,
GetDependencyRecordsForIssues, and a 250-ID GetLabelsForIssues case
that crosses the chunk boundary.
Made-with: Cursor
P1 privacy fix. Federation push now filters issues by
federation.exclude_types config (default: ["wisp"]) before sending
to peers, consistent with the existing type filter in the sync
engine. Opt-out via federation.exclude_types = [].
bd list --deferred only matched issues with defer_until set, missing
issues with status=deferred but no defer_until timestamp. The filter
now uses (defer_until IS NOT NULL OR status = 'deferred') in both
issueops and dolt transaction paths.
* test(config): add specs for central server config library
Add test cases for LoadCentralConfig, ApplyCentralDefaults, and
DefaultCentralConfigPath with stub implementations. Tests define
the expected behavior; implementations follow in the next commit.
* feat(config): implement central server config library
Implement LoadCentralConfig and ApplyCentralDefaults to satisfy
the specs from the previous commit. LoadCentralConfig reads and
parses ~/.config/beads/server.json; ApplyCentralDefaults merges
server-only fields into per-project config at zero values.
* test(config): add integration specs for central config wiring
Add tests that verify applyCentralConfigDefaults loads the central
server config and merges it into the per-project config. Stub
implementation is a no-op; tests define expected behavior before
the wiring is implemented.
* feat(config): wire central config into store open paths
Implement applyCentralConfigDefaults and call it in both
NewFromConfigWithOptions and NewFromConfigWithCLIOptions so that
server fields from ~/.config/beads/server.json are applied as
defaults before per-project config resolution.
* cmd/bd: extract sanitizeDBName to its own file for CGO_ENABLED=0 lint
sanitizeDBName lived in store_factory.go which is //go:build cgo,
but init.go (no tag) calls it. The pre-commit golangci-lint runs
with CGO_ENABLED=0 and flagged it as undefined. Move the pure-Go
function to its own untagged file and drop the now-unused strings
import from store_factory.go. No behavior change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* schema: tolerate "does not have column" errors in migration runner
Broadens isConcurrentInitError to also treat "does not have column"
as a benign migration error, symmetric with the existing "duplicate
column" tolerance for ADD races. Makes DROP COLUMN migrations
idempotent across databases bootstrapped with different base schemas.
Observed failure: migration 0032 (DROP COLUMN applied_at) loops
forever on any database that lands at v31 without the column. Dolt
has no DROP COLUMN IF EXISTS, so the SQL itself can't be guarded;
handling it in the runner keeps the migration file trivial.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Add migration 0032 idempotence tests (bd-7mh.3)
* Document bd execution metadata workflow (bd-b1a)
* Revert "Document bd execution metadata workflow (bd-b1a)"
This reverts commit 0d6a96babd.
* Reapply "Document bd execution metadata workflow (bd-b1a)"
This reverts commit df90cf5404.
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
* perf: add --no-cycle-check flag to bd dep add for bulk wiring
On large dependency graphs (230+ edges), bd dep add performs a full
DetectCycles traversal after every insertion — O(V+E) per call. This
causes individual dep add calls to hang for 3+ minutes as the graph
grows beyond ~150 edges.
Add --no-cycle-check to both `dep add` and the `dep --blocks`
shorthand. When set, the post-insert warnIfCyclesExist call is skipped.
Callers doing bulk wiring can run `bd dep cycles` once at the end to
verify the complete graph.
The flag is intentionally not the default: single-edge interactive use
keeps cycle detection on. Bulk callers opt in explicitly.
* Add bulk JSONL dependency wiring (bd-wjl)
* Fix bulk dep file lint warning
---------
Co-authored-by: Robin Carswell <robin@robincarswell.com>
* fix(ready): honor filter.ExcludeTypes in GetReadyWorkInTx (GH#3397)
The --exclude-type CLI flag was silently ignored by bd ready. The CLI
correctly populated filter.ExcludeTypes, and the type's godoc promised
that values are "Appended to the default exclusion list", but the
no-Type branch of GetReadyWorkInTx built the NOT IN clause from the
hardcoded defaults only.
Merge user-supplied ExcludeTypes into the default exclusion list (with
dedup against defaults and empties) before building the placeholders.
This matches the pattern already used by issueops/filters.go and
dolt/queries.go for bd list.
Fixes GH#3397.
* fix(ready): --parent returns transitive descendants, not direct children only (GH#3396)
The SQL clause in GetReadyWorkInTx's ParentID branch was a one-hop join
against the parent-child dependency table, so only direct children
surfaced. The --parent help text in cmd/bd/ready.go:672 and the
WorkFilter.ParentID godoc (internal/types/types.go:1295) both promise
"descendants (recursive)".
Add a BFS helper GetDescendantIDsInTx alongside GetChildrenOfIssuesInTx
in blocked.go — BFS rather than a recursive CTE because the existing
children helper already iterates across both dependencies and
wisp_dependencies tables, and composing that inside a single CTE gets
ugly. The visited set breaks cycles and a depth cap (default 100,
matching the cycle-detection CTE elsewhere in issueops) guards against
malformed data.
Rewrite the ParentID branch in GetReadyWorkInTx to resolve descendants
via the new helper and OR that with the prior dotted-ID prefix match
(for implicit-parent IDs with no explicit parent-child dep), preserving
the original semantics for dotted IDs.
MoleculeID is deliberately left as one-hop — its inline comment
explicitly scopes it to "direct children" unlike ParentID.
Fixes GH#3396.
* Improve ready and list UX regressions (bd-main-typ)
* fix(list): make --ready flag use blocker-aware GetReadyWork semantics (GH#3478)
bd list --ready previously only filtered by status=open, showing issues
that bd ready correctly excluded as blocked. Now both commands use the
same GetReadyWork path, ensuring consistent results.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add list ready blocker regression coverage (bd-qo1)
* Fix ready list review regressions
---------
Co-authored-by: Daniel Jasiński <daniel.jasinski@gmail.com>
Co-authored-by: kev <kglynn@pryoninc.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TestConcurrencyMultiProcess shells out to `go test -c` to build a child
test binary that subprocesses then exec. The build invocation didn't
pass `-tags gms_pure_go`, so on Windows the subprocess build pulled in
the cgo-backed ICU regex package and failed at compile time on a missing
`unicode/uregex.h` header.
Linux/macOS toolchains ship ICU dev headers by default so the cgo path
compiled silently without the tag — Windows was structurally broken.
Per CLAUDE.md, `gms_pure_go` is mandatory project-wide. Pass it through
to the subprocess build and add a comment explaining the constraint
since it's not obvious from Go conventions alone.
Fixes#3508
ApplyCLIAutoStart now resolves the actual Dolt server mode before deciding whether CLI paths may auto-start a server, matching NewFromConfigWithOptions and preventing fallback shadow servers for external-mode repos.
Also updates doctor autostart coverage for the new external-mode behavior while preserving owned standalone auto-start coverage.
Co-authored-by: Shaun Cutts <shauncutts@factfiber.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
The embedded Dolt backend open path ran only the embedded SQL
migrations via schema.MigrateUp. The defensive backward-compat
migration runner was invoked only from the server-mode path in
dolt.initSchemaOnDB. Pre-existing embedded databases opened by a
newer bd binary therefore skipped every compat migration 001-017,
leaving missing columns and tables unrepaired.
The runner itself has no coupling to package dolt -- it drives
idempotent migration functions that already live in the migrations/
subpackage. Relocating CompatMigration, compatMigrationsList,
RunCompatMigrations, and ListCompatMigrations into package migrations
puts them alongside the functions they drive, and lets both the
server and embedded backends share them without a cross-backend
import.
Changes:
- New internal/storage/dolt/migrations/runner.go with the runner,
registry list, and the exported List function.
- internal/storage/dolt/migrations.go trimmed to CreateIgnoredTables.
- internal/storage/dolt/store.go and cmd/bd/migrate.go updated to
call through package migrations.
- internal/storage/embeddeddolt/store.go opens a fresh sql.DB after
the schema-migration tx commits and calls RunCompatMigrations.
- Regression test: synthetic old-schema DB (drop issues.started_at),
reopen, assert the compat runner re-adds the column.
Refs GH#3412.
Hook-bypass-reason: local pre-commit hook fails on Windows with
CGO_ENABLED=0 because cmd/bd/init.go references sanitizeDBName,
defined in cmd/bd/store_factory.go which is gated //go:build cgo.
Reproduced against pristine origin/main; not introduced by this
change. Upstream fix in flight at GH#3402 / GH#3403.
* perf(storage): amortize per-ID wisp routing via WispIDSetInTx
Implements D2 build per ADR be-nu4 §4.D2 (bead be-nu4.2.1).
Add WispIDSetInTx helper that returns the set of currently-active
wisp IDs, consistent for the tx's lifetime under Dolt MVCC. The hot
batch-routing paths (GetLabelsForIssuesInTx, GetIssuesByIDsInTx)
gain a trailing wispSet parameter; callers that pass nil trigger a
single internal SELECT id FROM wisps rather than the N-per-ID
IsActiveWispInTx loop the helpers previously ran.
IsActiveWispInTx is retained unchanged for single-ID callers
(AddLabelInTx etc.) per the ADR audit note.
Mixed-ID routing is the sacred invariant (ADR §11.5); covered by a
new hard-gate test TestWispIDSetInTx_HardGate that exercises both
refactored helpers with a permanent issue and an active wisp in the
same input slice. Pure-fn unit coverage (partitionByWispSet) runs
without a testcontainer.
Adds BenchmarkGetLabelsForIssues_Mixed and
BenchmarkGetIssuesByIDs_Mixed at 1K / 10K / 50K with 25% wisp share.
Note for reviewer: two additional per-ID hot loops share the same
pattern (GetDependencyRecordsForIssuesInTx,
GetBlockingInfoForIssuesInTx in dependency_queries.go) and would
benefit from the same treatment. Left alone here to respect ADR
scope; flagged for a follow-up bead.
Dolt testcontainer runs flaky on this worktree (Docker 29.4 + ryuk
0.13.0). TESTCONTAINERS_RYUK_DISABLED=true works when infra
cooperates; unit-level coverage (TestPartitionByWispSet) runs
container-free and is green.
Refs: be-nu4.2.1, be-nu4
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: release gate PASS for be-eqw
* fix(storage): scope WispIDSetInTx to input IDs
Reviewer maphew on #3453 flagged that the new default helper builds
the active wisp set with an unscoped SELECT id FROM wisps for
nil-set callers. That turns a small hydration batch (N IDs) into a
full scan of the wisps table (W rows), which is worse than the
pre-PR per-ID IsActiveWispInTx path for small N against large W.
Scope the helper query to the input IDs so cost becomes O(N·log W)
+ 1 round-trip — strictly better than both the old per-ID path and
the current unscoped path.
Signature change: WispIDSetInTx now takes ids []string. Both
internal call sites (GetIssuesByIDsInTx, GetLabelsForIssuesInTx)
pass their input IDs through; all 13 existing nil-set callers
continue to pass nil and get a scoped internal build. Doc updated
on the wispSet parameter to reflect "set scoped to cover these
IDs."
Note: committed with --no-verify (authorized) because release/be-eqw
inherits a pre-existing pre-commit hook blocker — sanitizeDBName is
only defined in the cgo-tagged store_factory.go and the hook runs the
linter under CGO_ENABLED=0. be-4lf (on main) deletes the duplicate
extraction file; once release/be-eqw rebases onto main post-merge the
hook passes naturally. Green-field build/vet/gofmt and all wisp
routing tests were run locally before committing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test(storage): be-rgm WispIDSetInTx scoped path + small-N bench
be-3l2 fills the codecov gap on PR #3453 flagged by maphew:
WispIDSetInTx scope-to-input-IDs (14 missing lines on
wisp_routing.go, 0% on dependencies.go/labels.go hydration paths).
New tests in internal/storage/dolt/wisp_set_scoped_test.go:
- TestWispIDSetInTx_Scoped_ReturnsOnlyInputIDs — "lock the fix"
regression: seeds 5 wisps, passes 1 ID, asserts the other 4
are NOT in the set. Reverting to `SELECT id FROM wisps` fails this.
- TestWispIDSetInTx_Scoped_AcrossBatchBoundary — 250 wisps (past
queryBatchSize=200) all pass through the batched IN-clause loop.
- TestWispIDSetInTx_Scoped_UnknownIDsReturnEmpty — unknown IDs
return empty set; a bait wisp outside the input must not leak.
- TestGetLabelsForIssuesInTx_SmallInputLargeWispTable — end-to-end
hydration with nil wispSet against 20 noise wisps; exercises the
dependencies.go/labels.go callers that pass input IDs through.
- TestGetIssuesByIDsInTx_SmallInputLargeWispTable — same shape for
issue hydration.
New benches in internal/storage/dolt/dolt_benchmark_test.go:
- BenchmarkGetLabelsForIssues_SmallNLargeW_10_5K / _10_10K / _100_5K
- BenchmarkGetIssuesByIDs_SmallNLargeW_10_5K / _10_10K / _100_5K
These measure the maphew regression shape: small input batch
against a large wisps table. Local 10_5K: ~2.6 ms/op, confirming
the scoped N·log(W) path wins cleanly over the pre-be-rgm
full-scan path (existing Mixed10K is ~1.35 s/op for the full
hydration, but that loads 10K not 10).
Note: committed with --no-verify (authorized). release/be-eqw
inherits a pre-existing pre-commit hook blocker — golangci-lint
on the hook is built with go1.25 while go.mod targets 1.26.2,
so the lint step errors before seeing the diff. Green-field
go vet, go build, and all five new tests pass locally against
an isolated Dolt test container.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: fall back to DOLT_FETCH+DOLT_MERGE when DOLT_PULL fails on missing branch tracking
When a remote is added via bd dolt remote add (rather than bd bootstrap
or dolt clone), repo_state.json has an empty "branches" map. DOLT_PULL
then fails with "did not specify a branch" even when the branch is
passed explicitly, because Dolt checks upstream tracking config first.
This fix detects that specific error in pullWithAutoResolve and falls
back to the DOLT_FETCH + DOLT_MERGE approach already used by
versioncontrolops.Pull (GH#3144). The fallback preserves the existing
metadata conflict auto-resolution logic.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test(dolt): add regression tests for GH#3144 branch-tracking fallback
pullWithAutoResolve_BranchTrackingFallback (no build tag) injects the
exact Dolt tracking-error text via a stored procedure SIGNAL, then
verifies pullWithAutoResolve enters the DOLT_FETCH + DOLT_MERGE fallback
path (confirmed by the 'fetch from' error when no remote is configured).
Covers lines A–D of the fallback block.
pullWithAutoResolve_BranchTrackingSuccess (//go:build integration)
reproduces the real failure scenario end-to-end: a remote is added via
DOLT_REMOTE('add', ...) rather than clone, leaving repo_state.json with
an empty 'branches' map, causing DOLT_PULL to fail with the tracking
error. The test then verifies pullWithAutoResolve succeeds via the
DOLT_FETCH + DOLT_MERGE fallback. Covers lines E–I of the fallback block.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* fix(config): reject 'bd config set issue-prefix' with actionable error
'bd config set' landed the value in DB key "issue-prefix" (dash), while
'bd create' reads YAML "issue-prefix" then DB "issue_prefix" (underscore) —
a third key no reader consults. The result was a silent-success write
that left users unable to create issues after what looked like a successful
config change (bd-f4m).
Reject both dash and underscore forms at the top of the config-set handler
and point the user at the three commands that own the prefix lifecycle
(bd init --prefix / bd bootstrap / bd rename-prefix). A unit test locks
in the rejected keys, the required error substrings, and a control set
of adjacent keys that must continue to work.
* fix(errors): mention 'bd bootstrap' in 'issue_prefix is missing' hint
The fresh-clone flow lands here when a user clones a repo but has no
local database yet. The existing hint only mentioned 'bd init --prefix',
which is the wrong answer for that scenario — 'bd bootstrap' is what
reconstitutes a database from the remote. Add it to the hint alongside
'bd init --prefix' so both the new-project and fresh-clone paths are
directed at the right command (bd-f4m, AC bullet 4).
* fix(config): drop private tracker IDs from issue-prefix rejection comments
Strips internal bead tracker IDs from code comments and a test
message. Private tracker IDs have no meaning to external reviewers,
so they should not ship in the repository.
No behavior change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Fix worktree-aware config.yaml resolution
* fix: honor shared worktree config resolution
* fix(doctor-fix): resolve shared-worktree beads paths
intent(doctor-fix): review-fix-loop found that doctor --fix should keep working when a worktree uses a shared .beads directory with no local path
constraint(doctor-fix): permission fixes must still skip chmod on local symlinked .beads directories when they exist
decision(doctor-fix): centralize resolved workspace lookup in a helper and route fix handlers through it instead of rebuilding path/.beads ad hoc
* test(doctor-fix): cover shared-worktree path resolution
intent(doctor-fix): review-fix-loop needed regressions that prove fix handlers operate on the shared workspace when a worktree has no local .beads
decision(doctor-fix): cover one config-regeneration path and two file-mutation paths so future regressions fail close to the real worktree behavior
learned(doctor-fix): metadata regeneration, stale lock cleanup, and permission repair all exercised separate path assumptions inside the fix package
* test(doctor-fix): strengthen workspace validation coverage
Why:
- shared-worktree fix coverage still left validateBeadsWorkspace edge cases loosely asserted
- fix package had no direct test for resolvedWorkspaceBeadsDir local vs shared precedence
What:
- add focused tests for resolvedWorkspaceBeadsDir local/shared selection
- make validateBeadsWorkspace reject file-backed and file-symlinked .beads explicitly
Refs:
- beads-xc4
* refactor(doctor-fix): share workspace beads dir resolution
Why:
- fix package resolved local and shared .beads paths in multiple steps even though they come from the same workspace root
- permissions handling was correct but harder to follow because local/resolved values were stitched together at the call site
What:
- extract a package-local helper that returns both local and resolved .beads paths from one workspace lookup
- make Permissions reuse that helper and add direct tests for local path behavior
Refs:
- beads-rim
* fix(config): remove shared-worktree import cycle
Why:
- shared-worktree config fallback in internal/config imported internal/beads
- that pulled internal/utils back into internal/utils test setup through storage/dolt and caused PR #37 CI import cycle failures
What:
- keep worktree fallback resolution inside internal/config
- reuse the repo-scoped git-dir fallback for config.yaml discovery without importing internal/beads
Refs:
- beads-3ix
* fix(doctor): resolve database-integrity against shared worktrees
intent(doctor): keep integrity recovery from reading a nonexistent worktree-local .beads during shared-worktree repairs
decision(database-integrity): resolve config and dolt paths from resolvedWorkspaceBeadsDir while keeping bd init --force anchored to the worktree repo root
learned(shared-worktree): the server-mode guard must inspect shared config or it can silently bypass the configured database safety check
* fix(doctor): honor shared worktrees in remote-consistency
intent(doctor): keep remote reconciliation pointed at the active shared workspace state during worktree repairs
decision(remote-consistency): resolve shared-worktree config and dolt paths once before comparing SQL and CLI remotes
constraint(remote-consistency): the fixer still runs from the worktree repo path but cannot derive paths from repoPath/.beads when that directory is absent
* fix(doctor): align shared worktree resolution (beads-u8z)
* test(config): cover shared worktree config precedence (beads-7kw)
intent(config): lock down shared worktree config resolution so future fallback fixes do not silently write or read the wrong file
decision(config-tests): cover both write precedence and Initialize() local override behavior in worktree-specific tests
constraint(shared-worktree): runtime resolution can legitimately target either worktree-local or shared .beads, so the regression coverage must assert both paths explicitly
* Add worktree path coverage for beads dir resolution
* Avoid creating .beads on normal Dolt store opens
* Prefer loaded worktree config when finding project config
* test(worktree): add shared config regression coverage (beads-z65b)
intent(worktree-config): keep shared-worktree sync.remote persistence covered at both the YAML helper and CLI command layers
decision(regression-tests): pair a loaded-state config test with a bd subprocess test because the original regression crossed initialization and command execution
constraint(cmd-bd): use the repo CGO test wrapper for command coverage because raw go test ./cmd/bd requires local ICU setup outside the supported path
* fix(doctor): sweep shared-worktree resolver into remaining checks (beads-3y9p)
intent: keep this PR's worktree bugfix coherent by removing the last redirect-only doctor resolution paths
decision: route standalone doctor checks through ResolveBeadsDirForRepo and add shared-worktree regressions for locks, mq cleanup, hook migrations, and remote consistency
constraint: leave local-only semantics alone and validate with targeted doctor tests instead of broad environment-sensitive full-suite expectations
* test(worktree): strengthen resolver regression coverage (beads-i9x1)
intent(worktree-coverage): raise patch coverage for the shared-worktree resolver PR on branches introduced by this change set
decision(config-tests): cover worktree config helpers directly in internal/config so fallback and loaded-state branches stay deterministic
decision(storage-tests): exercise lazy federation credential-key initialization with one server-backed peer lifecycle instead of broader end-to-end sync flows
constraint(doctor-tests): verify tracked runtime cleanup from the resolved main repo because shared .beads lives outside the worktree root
* fix(bootstrap): persist sync remote in resolved config
intent(bootstrap): fresh worktree bootstrap should finalize the shared workspace config instead of failing on a local .beads stub
decision(config-resolution): add a targeted yaml writer for an explicit beads directory so bootstrap can reuse the resolved workspace path
constraint(worktree-config): bare-parent and shared worktree setups can expose a local .beads directory that must not shadow the canonical config.yaml during finalize
* test(config): cover worktree resolution edge paths (beads-adan)
intent(codecov): PR #3265 needed patch coverage above the Codecov complaint on config/worktree resolution changes
decision(tests): add unit coverage in existing config, doctor/fix, and credentials suites instead of broader e2e coverage
constraint(tests): keep sanitizeDBName available to nocgo typecheck because init.go calls it outside cgo-only files
* test(embedded): allow concurrent dolt status
---------
Co-authored-by: matt wilkie <maphew@gmail.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).
Add a pre-push fsck check to prevent propagating dangling chunk
references from the local noms store to the remote. Concurrent
pushes to GitHub git+ssh remotes can race on the manifest, leaving
the remote with chunk references that were never uploaded — and any
agent that fetches then re-pushes faithfully carries the corruption.
`dolt fsck --quiet` runs before every CLI push (doltCLIPush and
doltCLIPushToPeer). If any chunk is missing, ErrDanglingReference is
returned and the push is aborted before touching the network.
The check is skipped when CLIDir is empty or .dolt/noms does not
exist (uninitialized or SQL-only paths).
Co-authored-by: gastown/crew/woodhouse <5449665+ckumar1@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Add ServerSocket config field and BEADS_DOLT_SERVER_SOCKET env var to
connect to Dolt via unix sockets instead of TCP. This eliminates port
conflicts between concurrent projects and simplifies sandbox integration.
- Wire --server-socket CLI flag through bd init and bd dolt set (dolt.socket)
- Add GetDoltServerSocket() to configfile with env var precedence
- Socket mode disables auto-start with socket-specific error hints
- TLS settings honored regardless of transport
- Integration test: starts dolt sql-server --socket, verifies end-to-end SQL
- Document in README.md server mode table
Closes#2939
* fix(lint): silence G122 on dolt cache cleanup remove
golangci-lint v2.11.4 (released recently) enabled a new gosec check:
G122: Filesystem operation in filepath.Walk/WalkDir callback uses
race-prone path; consider root-scoped APIs (e.g. os.Root) to prevent
symlink TOCTOU traversal (gosec)
This flags the `os.Remove(path)` inside cleanGitRemoteCacheGarbage.
Main went red on the Lint job with no code change to blame — it broke
on every PR that rebased past the golangci-lint bump.
The warning is not applicable here: the walk root is
`<beadsDir>/<database>/.dolt/git-remote-cache/`, owned by the user
running bd. An attacker who can symlink-swap a tmp_pack_*/tmp_idx_*
file mid-walk already has write access to the Dolt data directory,
which is a much bigger compromise than cache_cleanup.go doing anything
unsafe.
Add a targeted `#nosec G122` with justification rather than refactor
to `os.Root`-scoped APIs, which would be a larger change against a
file that exists to clean up a 102 GB leak (GH#3354) and shouldn't
take on additional complexity for a hypothetical threat. Matches the
project's existing pattern of per-site gosec exceptions with rationale.
Verification:
golangci-lint run --timeout=5m --build-tags=gms_pure_go ./...
# 0 issues.
* fix(dolt): update shared-server credential tests for new per-remote signatures
Two tests added by #3223 (f9ec9859, 2026-04-13) were not updated when
#3211 (73d72ec0, 2026-04-20) widened the credential-routing guards to
take per-remote parameters. The resulting signature drift landed on
main and broke the build on ubuntu-latest and macos-latest:
internal/storage/dolt/credentials_test.go:445:39: not enough
arguments in call to store.shouldUseCLIForCredentials
internal/storage/dolt/credentials_test.go:486:6: not enough
arguments in call to store.shouldUseCLIForCloudAuth
Fix:
- TestCredentialCLIRoutingSharedServerUsesSharedDoltRoot:
pass store.remote and store.mainRemoteCredentials() to match the
new shouldUseCLIForCredentials(ctx, remote, creds) signature,
matching the pattern already used by the sibling
TestCredentialCLIRoutingExternalServer/NoRemote tests.
- TestCloudAuthCLIRoutingSharedServerUsesSharedDoltRoot:
pass store.remote to the new shouldUseCLIForCloudAuth(remote)
signature, and change the dolt remote URL from https:// to az://.
The old global "any cloud env var triggers CLI routing" heuristic
was replaced by per-scheme matching (AZURE_STORAGE_* only triggers
for az:// remotes, etc. — see the positive/negative cases in
TestCloudAuthCLIRouting). The test sets AZURE_STORAGE_ACCOUNT, so
the remote must be az:// for the assertion to hold.
Verification: both tests pass locally (`go test -tags gms_pure_go
-run 'SharedServerUsesSharedDoltRoot' ./internal/storage/dolt/`).
When a formula step has `gate = { type = "human" }`, the cook pipeline
creates a companion bead with IssueType "gate". But "gate" was
intentionally removed from the built-in type whitelist (see types.go
comment at the IssueType const block) and moved to a custom type that
requires explicit `types.custom` configuration. Without that config,
`bd mol pour` fails with:
validation failed for issue : invalid issue type: gate
This forces operators to run `bd config set types.custom '["gate"]'`
before pouring any formula with gate steps — a papercut that blocks
first-time formula users.
Fix: add `ensureSubgraphCustomTypes` in `cloneSubgraph` (template.go)
that scans the template issues for non-built-in types and auto-registers
any missing ones via `SetConfig("types.custom", ...)` before the clone
transaction creates the issues. This is the same store path that
`bd config set` uses, which triggers `SyncCustomTypesTable` to populate
the normalized `custom_types` table consumed by `PrepareIssueForInsert →
ValidateWithCustom`.
Also add `EnsureCustomTypeInTx` helper in issueops/config_helpers.go
for callers that already hold a transaction (not used by this fix but
provides a lower-level primitive for future use).
The fix applies to both `bd mol pour` (persistent) and `bd mol wisp`
(ephemeral) since both call `cloneSubgraph`.
Fixes#3213
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add PushRemote/PullRemote methods to RemoteStore interface, allowing
push/pull to target a specific named remote instead of the default.
Implementation:
- Refactor Push/ForcePush/Pull to delegate to internal pushToRemote/
pullFromRemote methods with parameterized remote name
- Parameterize credential routing (isGitProtocolRemote,
shouldUseCLIForCredentials, shouldUseCLIForCloudAuth) to accept
remote name instead of using s.remote
- Make shouldUseCLIForCloudAuth per-scheme-aware: Azure env vars only
trigger CLI routing for az:// remotes, not dolthub:// remotes
- Add credentialsForRemote() helper that only returns creds when the
target remote matches the default remote (prevents sending wrong
creds to wrong host)
- Add --remote flag to doltPushCmd and doltPullCmd in CLI
- Implement PushRemote/PullRemote on EmbeddedDoltStore
Backwards compatibility:
- Push(ctx)/Pull(ctx)/ForcePush(ctx) signatures unchanged
- No --remote flag = exact same behavior as today
- PushTo/PullFrom for federation peers unchanged
Closes: bd-4v3
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(doctor): resolve Dolt password/TLS for externally-hosted servers
bd doctor failed against externally-hosted Dolt servers (dolt_mode=server
with a remote dolt_server_host) while bd create/list/close all succeeded.
The CRUD path in cmd/bd/main.go set ServerPassword (via
GetDoltServerPasswordForPort) and ServerTLS explicitly, but several doctor
code paths either hardcoded os.Getenv("BEADS_DOLT_PASSWORD") only or
omitted the password/TLS entirely. This produced "Access denied for user
root" on the lock check, "Unable to open database" on the database check,
"Unable to verify Dolt server-backed database permissions", and
false-positive "Fresh clone detected" warnings for users whose
credentials live in ~/.config/beads/credentials.
Root cause: applyResolvedConfig in internal/storage/dolt/open.go populated
Host/Port/User from metadata.json but never Password or TLS, so any
caller that went through NewFromConfigWithOptions (notably doctor's
SharedStore) got an unauthenticated DSN.
Changes:
- internal/storage/dolt/open.go: applyResolvedConfig now resolves
ServerPassword via GetDoltServerPasswordForPort(cfg.ServerPort) and
ServerTLS from fileCfg, matching the CRUD path in main.go. This alone
fixes Database, Permissions, Repo Fingerprint, and Project Identity
checks for the SharedStore-based doctor checks.
- cmd/bd/doctor/dolt.go, doctor/server.go, doctor/perf_dolt.go: use
cfg.GetDoltServerPasswordForPort(port) instead of reading only
BEADS_DOLT_PASSWORD. The helper already checks the env var first so
behavior is a strict superset. Drop now-unused "os" import where
applicable.
- cmd/bd/doctor_health.go: include Password in the DSN (it was omitted).
- cmd/bd/doctor/legacy.go (CheckFreshClone): look up the password using
the resolved runtime port instead of cfg.GetDoltServerPassword(), which
internally uses cfg.GetDoltServerPort() and defaults to 3307 when
metadata.json omits dolt_server_port. Credentials are keyed by
[host:port], so the mismatched-port lookup returned empty and caused a
spurious "Fresh clone detected" warning.
Using GetDoltServerPasswordForPort (not GetDoltServerPassword) is
important because the resolved runtime port from the port file may
differ from cfg.GetDoltServerPort(), matching the approach already used
in cmd/bd/main.go.
Verified end-to-end against an external Dolt server using TLS with
credentials in ~/.config/beads/credentials: bd doctor goes from
65 passed / 7 warn / 2 error to 69 passed / 5 warn / 0 error, with all
remaining warnings reflecting genuine project state (missing
fingerprint, uncommitted working tree, etc.), not bugs.
Tests: go test ./cmd/bd/ ./cmd/bd/doctor/ ./internal/storage/dolt/ pass.
Made-with: Cursor
* test(doctor): cover external-server credential resolution paths
Adds targeted unit tests for the four doctor code paths flagged by
codecov on PR #3361 (bd-h5k7 / bd-tzo9):
- TestCheckFreshClone_ServerModeUnreachable: exercises the
GetDoltServerPasswordForPort(port) branch in legacy.go and the
FR-030 fall-through when the configured external Dolt server is
unreachable.
- TestCheckDoltVersion_Unreachable: exercises the credential
resolution and DSN build in doctor/server.go with a guaranteed-
unreachable port via BEADS_DOLT_SERVER_PORT=1.
- TestRunDoltServerDiagnostics_Unreachable: loads metadata.json so
runDoltServerDiagnostics pulls user/tls/password through
configfile.Load before the ping fails.
- TestRunCheckHealth_UnreachableServer: smoke-tests runCheckHealth
to cover the Password field in doctor_health.go's DSN.
All four tests run without a real Dolt server by pointing at an
unreachable loopback port so CI does not need docker.
Made-with: Cursor
* ci: retrigger unrelated audit concurrency flake
Made-with: Cursor
Move type validation from CLI-level (update.go) to storage layer
(UpdateIssueInTx), matching the create path. The CLI-level validation
failed when GetCustomTypes() was unavailable (subprocess context,
circuit breaker) and config.yaml lacked types.custom (because bd config
set only writes to Dolt). The storage layer reads custom types within
the same transaction, so it always works.
Co-authored-by: mayor <rastislav.marko@panzarobotics.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The embedded Dolt backend accumulates orphaned tmp_pack_* files in
.dolt/git-remote-cache/*/repo.git/objects/pack/ when git fetch operations
fail or are interrupted. Dolt's built-in cleanup (GitBlobstore.maybeRunGC,
gated to once per 24h) either never fires in embedded mode or cannot keep
pace with the accumulation rate.
On a real machine with normal beads usage across ~10 workspaces, this leak
consumed 102 GB (412 files) in 7 days, filling the disk to capacity and
causing cascading system failures (swap exhaustion, shell temp file errors,
app crashes).
Add cleanGitRemoteCacheGarbage() to EmbeddedDoltStore that walks the
git-remote-cache pack directories and removes tmp_pack_*/tmp_idx_* files
older than 5 minutes (preserving in-progress fetches). The method is:
- Called from Close() to clean up on store teardown
- Called from withDBConn() deferred cleanup (covers fetch/push paths)
- Rate-limited to once per 10 minutes via a package-level throttle to
avoid filesystem thrashing on hot paths
Fixes#3354
Co-authored-by: kev <kglynn@pryoninc.com>
DetectOrphanedChildren ran a full table scan with a LEFT JOIN on every
store open (every bd command), logging up to 107 orphan warnings per
invocation. At ~90 connections/sec in polled environments, this drove
sustained backend CPU load and trained users to ignore stderr.
Replace with a no-op. Orphan detection already lives in bd doctor
(--deep and --check=conventions) where it belongs as an on-demand
diagnostic, not a recurring side effect.
Co-authored-by: kev <kglynn@pryoninc.com>
RunCompatMigrations unconditionally called DOLT_COMMIT('-m', 'schema:
auto-migrate') on every store open, even when all migrations were
already applied (the common case). The Dolt server logs each no-op as
a WARNING, flooding the server log — one user reported 103K "nothing
to commit" warnings out of 110K total log lines (94%).
Fix: check dolt_status for dirty tables before staging and committing.
When all compat migrations are no-ops and no schema tables are dirty,
skip the DOLT_ADD/DOLT_COMMIT entirely. Falls back to the original
behavior if dolt_status is unavailable (older servers).
Co-authored-by: kev <kglynn@pryoninc.com>