Reverts PR #3498 / commit 0fffa44a2302a496dfa4ffa838843b3bbf0ee122.\n\nPR #3498 added BEADS_DOLT_CLI_DIR routing without a confirmed reproduction and introduced an external-server push/pull regression. Remove that override and its docs/tests so main no longer requires a local CLI database directory in external-server mode.\n\n_codex-gpt-5- on behalf of CI Bot_
* test(cmd/bd): use t.Chdir in drift tests to fix chdir race (GH#3729-followup)
The TestCheckHooksDrift/Server/Remote tests in config_drift_test.go were
using the manual os.Chdir + defer os.Chdir(origDir) pattern, which is
not race-safe when other tests in the same package call t.Parallel and
share the process cwd.
t.Chdir (Go 1.24+) restores cwd via t.Cleanup and refuses to run if the
test (or any ancestor) is parallel — both eliminating the race window
and surfacing future misuse loudly.
Fixes flaky TestCheckHooksDriftNotGitRepo identified as a pre-existing
chdir race during PR #3716 review (mybd-j2s).
Verified: go test -count=20 -run '^TestCheckHooksDriftNotGitRepo$' passes.
Amp-Thread-ID: https://ampcode.com/threads/T-019dfe19-17ae-713e-bc3a-d7c9da6a117d
Co-authored-by: Amp <amp@ampcode.com>
* test(cmd/bd): accept embedded Dolt lock output
---------
Co-authored-by: CI Bot <ci@beads.test>
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: upgrade-test <test@beads.test>
* fix(auto-import): restore top-level emptiness guard in maybeAutoImportJSONL (#2)
* fix(auto-import): restore top-level emptiness guard in maybeAutoImportJSONL
PR #3630 introduced jsonlImporter as a single-transaction fast-path for embedded mode and moved the TotalIssues>0 emptiness check inside that path. Stores that don't implement jsonlImporter (server-mode dolt store) fall through to the fallback multi-call path — which has no emptiness guard, so every bd command unconditionally runs importFromLocalJSONLFull on a non-empty Dolt.
importFromLocalJSONLFull's underlying ON DUPLICATE KEY UPDATE semantics in InsertIssueIntoTable then re-impose the (often stale) JSONL field values on top of live Dolt rows. Combined with the auto-export's debounce/commit-watermark gating in export_auto.go, partial-field bd updates (e.g. --append-notes alone, --priority=N alone) get clobbered: the next command's auto-import overwrites the just-written field with whatever the JSONL last had.
Restore the top-level GetStatistics+TotalIssues>0 guard that v1.0.3 had, before the path-fork. The embedded jsonlImporter retains its own atomic in-tx check (defense in depth against concurrent-writer races, which was the legitimate intent of #3630). The fallback path is now once again a true upgrade-recovery path: it only fires when the database is actually empty.
Reproducer (server mode):
1. bd update X --priority=2 --notes="X"
2. bd update X --append-notes "; appended"
3. bd update X --priority=3
Pre-fix: step 3 leaves notes='X' (the '; appended' is silently lost) and step 2 may revert priority to JSONL's stale value.
Post-fix: each single-field update preserves the unspecified fields from Dolt.
Test coverage gap: existing auto_import_upgrade_test.go is //go:build cgo and only exercises the embedded path. A non-CGO server-mode integration test would prevent reintroduction; left as a follow-up.
* test(auto-import): add server-mode fallback regression test for empty-DB guard
Adds two unit tests covering the server-mode fallback path of maybeAutoImportJSONL. Existing tests in auto_import_upgrade_test.go are //go:build cgo and exercise only the embedded jsonlImporter branch — leaving the fallback path (the actual location of the data-clobber regression) uncovered by CI.
Test design: a small testability seam exposes importFromLocalJSONLFull as a package-level 'fallbackImporter' var that tests can substitute. A minimal stub storage.DoltStorage embeds the interface (nil) and overrides only GetStatistics; any other method call panics, which is correct since the function under test should not invoke them after the emptiness guard short-circuits.
TestMaybeAutoImportJSONL_ServerModeFallback_SkipsWhenNonEmpty fails on the buggy code (substituted importer is invoked when it shouldn't be) and passes after the guard is restored. TestMaybeAutoImportJSONL_ServerModeFallback_RunsWhenEmpty is the negative control — guards against a future change that always short-circuits and would let the regression test pass vacuously.
* fix(test): TestEmbeddedAutoImportJSONLNoExplicitCommit — use write command to trigger auto-import (#3)
* fix(test): use a write command to trigger auto-import in TestEmbeddedAutoImportJSONLNoExplicitCommit
The test was added in PR #3630 with a comment claiming bd list 'triggers maybeAutoImportJSONL in pre-run'. This is incorrect: bd list is registered in cmd/bd/main.go's readOnlyCommands map, and the dispatcher at main.go:1023 explicitly skips maybeAutoImportJSONL for read-only commands (a guard added 2026-04-14 in fa87dd2bd to avoid opening a writable handle for read commands per GH#804).
The test consequently asserted on a 0-issue empty store, failed with 'expected 3 imported issues, got 0', and shipped broken. CI did not catch this because the test is gated behind BEADS_TEST_EMBEDDED_DOLT=1 and t.Skips otherwise; the embedded suite must not have been enabled in the PR's pipeline.
Fix: use bd create (a write command) to trigger auto-import in pre-run. bd create's own write coalesces with the auto-import via PersistentPostRun's maybeAutoCommit — exactly the deferred-commit flow the test was designed to verify. The post-import marker also brings the asserted total to 4.
The original commitCount > 2 assertion was a brittle proxy for 'auto-import didn't issue its own DOLT_COMMIT'. Replace it with a direct check: forbid the 'auto-import: ... (upgrade recovery, GH#2994)' commit message that the function only emits when it calls s.Commit explicitly (the fallback path). Its absence is the actual property under test.
Verified: passes locally with BEADS_TEST_EMBEDDED_DOLT=1; the four sibling auto-import tests in the same file continue to pass.
* docs(test): correct commit path attribution per PR #3 review
Copilot reviewer noted the previous comment incorrectly attributed the coalesced Dolt commit to PersistentPostRun's maybeAutoCommit. The actual commit path: bd create itself calls store.Commit at cmd/bd/create.go:676 (gated on isEmbeddedMode || postCreateWrites). The auto-import stages writes into the Dolt working set and bd create's own commit picks them up alongside its create write; PersistentPostRun's maybeAutoCommit is then a no-op.
* fix(auto-import): handle nil statistics guard
Incorporates the defensive nil-statistics behavior from #3690 by realies, while keeping #3691 as the broader tested fix.
Co-authored-by: realies <5107843+realies@users.noreply.github.com>
---------
Co-authored-by: maphew <486200+maphew@users.noreply.github.com>
Co-authored-by: realies <5107843+realies@users.noreply.github.com>
Fixes Gemini CLI hook integration by emitting the required SessionStart JSON envelope. Extends the same standard to Claude Code hooks (documented spec, not just tolerated raw text). Adds legacy detection in bd setup gemini --check.
- Add `--hook-json` flag to `bd prime` wrapping output in the cross-CLI `hookSpecificOutput.additionalContext` JSON envelope (Claude Code, Gemini CLI, and Codex all share this contract)
- Update `bd setup gemini` to register `bd prime --hook-json` on SessionStart; remove PreCompress registration (advisory-only, no additionalContext support per Gemini docs v0.40.1)
- Update `bd setup claude` to register `bd prime --hook-json` on SessionStart and PreCompact (JSON form is the documented spec; raw text was merely tolerated)
- Migration sweeps in both setup commands so re-running upgrades bare-command installs cleanly
- `bd setup gemini --check` distinguishes current (`--hook-json`) from legacy (bare `bd prime`) installs and emits upgrade advisory for legacy
- Fix `removeHookCommand` bug: previously dropped entire hook entry on first command match, silently deleting sibling commands; now filters only the matching command and drops the entry only when empty
- Refresh docs and recipes to reflect SessionStart-only Gemini hook behavior
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Route bd dolt status through the SQL probe when dolt_mode=server points at a local host but bd auto-start is disabled. In that configuration bd is not the server lifecycle owner, so the PID-file path can report a false negative even though the configured sql-server is reachable.
Keep the bd-managed local PID-file status path unchanged and covered with rendering tests. Document the observable JSON shape change for affected automation in the Unreleased changelog.
Fixes be-0eyj.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Test hardcoded forward-slash path literals against output from
filepath.Join, so it failed on Windows even though the production
code (geminiProjectSettingsPath, geminiGlobalSettingsPath) was
correct.
Matches the existing pattern from TestMuxProjectAgentsPath and
TestMuxGlobalAgentsPath in the same package, which compare
filepath.Join(...) on both sides.
Fixes#3554
Fix release pre-flight harness checks found while validating v1.0.4.
- prefer initialized dbPath over inherited BEADS_DIR for no-DB commands
- update npm integration assumptions for grouped help and embedded Dolt behavior
- read Version from cmd/bd/version.go in upgrade smoke test
- resolve relative CANDIDATE_BIN before running candidate commands from temp workspaces
- skip hook/agent setup in upgrade smoke init to avoid old-version timeout paths
- seed worktree hook-path test before git worktree add
Fixes#3764.
Verification:
- go test -tags gms_pure_go ./cmd/bd -count=1
- npm --prefix npm-package run test:all
- ./scripts/release.sh 1.0.4 --dry-run
- go test -tags gms_pure_go ./...
- make test-upgrade
Note: local make test-regression timed out separately in TestEpicWithChildrenStatus after most scenarios passed; CI passed on this PR.
`bd mol pour` creates molecule roots with `IssueType: types.TypeMolecule`
(cmd/bd/cook.go:452, :840), but `findParentMolecules` only treated
`TypeEpic` or template-labeled issues as molecule roots. As a result,
walking up from any poured-molecule step never found a parent, so:
- `bd close <step> --continue` silently no-oped (`AdvanceToNextStep`
returned `nil, nil` and the close-flow skipped its print path)
- `bd close <step> --continue --claim-next` claimed nothing — the
`--claim-next` branch in close.go is gated on `!continueFlag`
The existing tests (TestFindParentMolecule, TestFindParentMoleculesBatch,
TestAdvanceToNextStep, plus its concurrency variants) all construct the
root with `TypeEpic + BeadsTemplateLabel`, so both isMolecule clauses
matched and the gap stayed hidden.
Add `TypeMolecule` to the isMolecule check, plus two regression tests:
- TestFindParentMolecule_RootShapes — table-driven, covers every root
shape (TypeEpic+label, TypeMolecule no-label, TypeTask+label, plain
TypeTask) for both findParentMolecule and findParentMolecules.
- TestAdvanceToNextStep_PouredMolecule — reproduces #3719 end-to-end:
poured-style root, autoClaim=true, asserts the next step is
actually moved to in_progress.
Fixes#3719
Co-authored-by: AI+idvorkin <aitools-idvorkin@gmail.com>
Keep the PR #3609 behavior while aligning the rebased branch with current main: preserve local -> prefix -> contributor-auto routing precedence, use the centralized Dolt auto-commit path for routed stores, and remove stale embedded-flock framing from comments and changelog.
Refs GH#3609
Replaces the two single-purpose tests added in beads-0km with one
table-driven test covering three scenarios:
- maintainer-mode local-only resolution (no routing involved).
- contributor batch where every ID lives in the planning store; both
results must share one routed-store handle (the dedupe that prevents
the GH#3586 flock-deadlock pattern).
- contributor mixed batch with one local and one routed ID; validates
per-result store routing and the mutatedStores fan-out invariant.
Also extracts a small seedIssue helper so the case bodies stay focused
on the per-case wiring.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bd close called utils.ResolvePartialID directly against the local store,
while bd show and bd update went through resolveAndGetIssueWithRouting.
In contributor auto-routing mode (routing.mode=auto + routing.contributor
+ beads.role=contributor), bd create writes new issues to the routed
planning store; show/update found them via the routing fallback but close
errored with "no issue found matching <id>" — even for IDs that bd create
had just returned.
Replaces the bare resolver with resolveCloseTargets, which:
- Tries the local store first (fast path).
- Falls back to a single shared contributor-routed handle reused across
every routed ID. Per-id routing would deadlock on the embeddeddolt
flock (same class as GH#3586) for the common case of bulk-closing
several IDs that all live in the planning store.
- Falls back to explicit prefix routing via routes.jsonl as a last resort.
The per-id close loop now uses each result's Store for IsBlocked,
CloseIssue, autoCloseCompletedMolecule, and the re-fetch. countEpicOpenChildren
takes an explicit store parameter. CommitPending fans out across every
mutated store so embedded-mode flushes the routed store too.
--suggest-next, --continue, and --claim-next reuse the first resolved
result's store, matching the common-case assumption that all IDs route
together.
Adds two regression tests:
- TestResolveCloseTargets_RoutesToContributorPlanning: multi-id batch
resolves through one shared routed handle.
- TestResolveCloseTargets_LocalStoreUnchanged: maintainer-mode close
resolves against the local store with no routing involved.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mux post-edit hook now calls bd dolt push when only ~/bin/bd is available,
matching the primary branch.
bd setup claude --check scans Claude settings for removed bd sync hook
commands and prints a stderr warning with remediation.
Tests: TestClaudeSettingsUsesRemovedSyncCommand.
The truncation hint from printTruncationHint was plain text, easily
missed — especially in --tree mode where truncation can make the
tree structure misleading. Render it with ui.RenderWarn (yellow)
so the warning stands out.
Closes gastownhall#3580