Commit graph

47 commits

Author SHA1 Message Date
matt wilkie
0c47b3c5ac
fix(init): use git origin as default Dolt remote (#3909)
* fix(init): wire git origin as Dolt remote

Default bd init now treats a git origin as the Dolt remote, persists sync.remote, and still skips synthesis in --stealth. JSONL auto-export/import paths now warn or skip based on sync.remote so exports do not masquerade as cross-machine sync.

Docs and generated agent/CLI references now state that Dolt is canonical, refs/dolt/data is the sync channel, and .beads/issues.jsonl is export/interchange/backup only.

_codex-gpt-5-xhigh on behalf of maphew_

* test: keep embedded command stderr out of parsed stdout

Embedded command tests parse IDs and JSON from command output. The new auto-export warnings correctly go to stderr, but several tests used CombinedOutput and treated warnings as stdout, which broke CI shards that parse issue IDs or JSON lists. Capture stdout separately on success while preserving combined output for error diagnostics.\n\n_codex-gpt-5-medium on behalf of CI Bot_

---------

Co-authored-by: CI Bot <ci@beads.test>
2026-05-13 07:02:39 -07:00
coffeegoddd☕️✨
c2b998e41d /{cmd,internal}: some refactors 2026-05-08 13:07:37 -07:00
coffeegoddd☕️✨
4bf03b31e6 /{cmd,internal}: initial proxy server backend pass 2026-05-07 16:26:16 -07:00
Bella-Giraffety
5a2fc61f7a
fix: repair shared-server bootstrap and doctor metadata drift (#3242)
Reconcile local metadata.json against the authoritative server state in
shared-server/server mode. Repairs two drift cases:
1. Stale dolt_database when another server DB matches the local project_id
2. Stale/missing local project_id when the configured DB has one

Also hardens the server metadata probe:
- Escapes backticks in database names to prevent SQL injection
- Distinguishes expected probe errors (table/DB not found) from unexpected
  ones (permission denied, connection failures) so reconciliation does not
  act on an incomplete server inventory

Co-authored-by: Bella-Giraffety <thalia.geraghty@fiserv.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-03 14:42:21 -07:00
matt wilkie
3e56f0b214
Document Linear external_ref pre-linking (#3517)
* Document Linear external ref prelinking (bd-ly3)
* Fix Linear sync dependency graph handling
* Fix init remote clone routing
* Fix stale gate help text
* Fix init remote cherry-pick integration
* Fix init remote flag handling
* Fix Linear prelink hydration blockers
* Fix Linear relation dependency gating
* Fix ready list parent filtering
* Deduplicate dry-run dependency previews by stored identity
2026-04-27 06:05:30 -07:00
Andreas Lingenhag
1e76efcfb6
fix: don't normalize user-provided sync.remote URLs (GH#3339) (#3432)
normalizeRemoteURL() converts http:// to git+http://, which breaks Dolt
remotesapi endpoints. Stop normalizing URLs from sync.remote (user
explicitly chose the format) while keeping normalization for auto-detected
git origin URLs. Also add git+http to allowedSchemes in remotecache so
ValidateRemoteURL accepts it.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-24 09:33:02 -07:00
Steven Syrek
c6d0cc2fd9
fix(init): refuse --force when remote has Dolt history (#3455)
* fix(init): refuse --force when remote has Dolt history

bd init --force in a repo whose origin has refs/dolt/data silently
skipped the bootstrap-from-remote path and then wired origin as a Dolt
remote anyway. The next write auto-pushed an orphan history, failing
with "no common ancestor". Recovery options were all destructive.

This change:

- Adds --reinit-local (named-intent replacement for --force) and
  --discard-remote (explicit cross-boundary authorization).
- Routes --force to --reinit-local with a DeprecationWarning. --force
  continues to work for ≥2 releases.
- Refuses bd init --force / --reinit-local when origin has
  refs/dolt/data, unless --discard-remote is also passed. Exit code 10
  (ExitRemoteDivergenceRefused).
- Adds stable numeric exit codes for init refusals (10/11/12).
- Adds bd init-safety documenting the full flag surface and the
  destroy-token format.
- Adds an internal race-safety re-check: if remote state changes
  during the TTY confirmation window, abort rather than overwrite.
- Retrofits the existing destroy-token echo at init.go:231 to not
  print a copy-pasteable destructive invocation, matching the new
  error-text-no-echo ADR invariant.

Adds:
- cmd/bd/init_safety.go — CheckRemoteSafety chokepoint (pure fn).
- cmd/bd/init_safety_test.go — guard matrix (13 cases) + subprocess
  regression test with a synthetic refs/dolt/data fixture.
- docs/adr/0002-init-safety-invariants.md — ADR encoding the five
  invariants (single-source identity, scope-bound --force, central
  chokepoint, error-text-no-echo, race-safety).
- docs/RECOVERY.md — named recovery playbooks per refusal exit code.
- .github/CODEOWNERS — review ownership for init*.go pointing at the
  ADR so future flags must extend the guard matrix.

Historical pattern (git log for cmd/bd/init.go): 8+ prior commits
patched individual surfaces of this class without encoding the
invariant. The guard matrix test is the structural hedge — adding a
new flag or data source is a signal to extend the table, not to add
another `&& !someFlag` at the call site.

(bd-q83)

* fix(init): satisfy lint for origin safety helpers (bd-main-nwo)

---------

Co-authored-by: matt wilkie <maphew@gmail.com>
2026-04-24 09:01:35 -07:00
Okano, Osamu
e585a61875
fix: avoid false shared-server bootstrap no-op for synthesized worktrees
Co-authored-by: Okano, Osamu <19066+osamu2001@users.noreply.github.com>
2026-04-24 08:16:38 -07:00
Okano, Osamu
55625dbef2
Fix worktree-aware config.yaml resolution (#3265)
* 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>
2026-04-24 07:33:31 -07:00
Harry Miller
80255b69ce
fix(bootstrap): clone via SQL server in external server mode (#3346)
When dolt_mode=server is configured in metadata.json (e.g. for an
externally managed dolt sql-server), bd bootstrap was cloning to the
local .beads/dolt/ directory instead of letting the server handle the
clone. The server never discovered the database, causing bd ready to
return empty results.

Root cause: cloneFromRemote() used isEmbeddedMode() which checks
runtime globals not yet initialized during bootstrap, defaulting to
embedded mode. finalizeSyncedBootstrap() had the same issue, resetting
dolt_mode back to embedded.

Fix:
- cloneFromRemote() now uses doltserver.ResolveServerMode() which reads
  metadata.json directly to determine the server lifecycle mode
- In ServerModeExternal, connects to the running server via MySQL and
  executes CALL DOLT_CLONE so the server places the database in its
  own data directory
- finalizeSyncedBootstrap() uses cfg.IsDoltServerMode() to preserve
  the server mode from the loaded config
- Added tests for both server-mode clone routing and mode preservation

Fixes #3343

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-20 17:56:20 -07:00
coffeegoddd☕️✨
31d512325c fix: ensure wisp tables exist after bootstrap clone
After `bd bootstrap` clones from a remote, dolt_ignore'd wisp tables
(wisps, wisp_dependencies, wisp_labels, wisp_events, wisp_comments)
are absent because they are never committed. This caused "table not
found: wisp_dependencies" errors on commands like `bd delete`.

Two fixes:
1. Add EnsureIgnoredTables call to embeddeddolt.New() — matches what
   server mode already does in newServerMode(). This is the primary
   fix: every embedded store open now creates missing wisp tables.
2. Add post-clone store warmup in executeSyncAction() — opens and
   closes a store after finalization to trigger wisp table creation
   immediately, regardless of storage mode.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 11:03:17 -07:00
matt wilkie
ebcb901d7a
fix(bootstrap): commit issue_prefix to config table (GH#3216) (#3247)
bd init/restore/import wrote issue_prefix via SetConfig but called
Commit(), which excludes the config table per GH#2455. The prefix row
sat orphaned in the working set forever, causing bd dolt pull to fail
with "cannot merge with uncommitted changes" on every fresh init.

Fix: use CommitWithConfig in the three bootstrap paths, matching the
pattern PR #3052 introduced for remember/forget/config set. Promote
CommitWithConfig to the VersionControl interface and add an alias on
EmbeddedDoltStore (whose Commit already includes config via DOLT_ADD -A).

Reported by @GraemeF.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:54:50 -07:00
matt wilkie
dfd1add67d
chore(bootstrap): remove unreachable nil-cfg guard in finalizeSyncedBootstrap (#3222)
The caller chain (bootstrapCmd.Run → executeBootstrapPlan → executeSyncAction)
guarantees cfg is non-nil via DefaultConfig() fallback at bootstrap.go:178-180.

Follow-up to #3203.

Amp-Thread-ID: https://ampcode.com/threads/T-019d7fee-1326-74af-a566-9c45ad5b349e

Co-authored-by: Amp <amp@ampcode.com>
2026-04-12 14:46:51 -07:00
Julian Knutsen
4aa573db56
fix(bootstrap): write metadata.json and config.yaml after sync clone (#3203)
fix(bootstrap): write metadata.json and config.yaml after sync clone

executeSyncAction created .beads/ and cloned remote Dolt data but never
wrote metadata.json or config.yaml, leaving the workspace in a broken
state where bd status, bd where, and bd dolt push all failed.

Adds finalizeSyncedBootstrap helper that runs after cloneFromRemote and
mirrors what init does: save cfg as metadata.json, create the config.yaml
template, and persist sync.remote. The helper is idempotent so bootstrap
retries remain safe.

Fixes gastownhall/gascity#561

Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
2026-04-12 14:44:57 -07:00
Okano, Osamu
ef6c6e3e48
Follow up remaining runtime .beads fallbacks after GH#3124 (#3183)
* fix(workspace): align resolved workspace messaging and config lookup

intent(workspace): pure worktrees and external BEADS_DIR setups should work without implying a local .beads directory is required
decision(config): derive config repo roots from FindBeadsDir-backed workspace resolution instead of a local-only .beads walk
constraint(workspace-detection): keep FindBeadsDir ordering and storage behavior unchanged while making bd where the primary diagnostic hint
learned(testing): shared-server env and global .beads ignore rules can distort CGO suites, so regression coverage now normalizes those test paths

* fix(bootstrap): align no-workspace JSON wording

intent(bootstrap): machine-readable no-workspace output should match the resolved-workspace guidance used elsewhere on this branch
decision(bootstrap-json): reuse the shared workspace error helpers through a dedicated payload builder so tests can lock the JSON contract
constraint(review-loop): keep the bootstrap CLI flow unchanged outside the no-workspace JSON branch while adding a focused regression test

* fix(where): allow no-workspace diagnostics without db (beads-9f74-5l1)

intent(where): no-workspace guidance should point to a command that actually runs when workspace resolution fails
decision(startup): treat top-level where as a no-db command so it reaches its own handler before database preflight
constraint(where-tests): subprocess mode can change the exact hint text, so the regression test locks the JSON contract and stable guidance fragments instead

* fix(bootstrap): restore bd where guidance for no-workspace output (beads-9f74-3c3)

intent(bootstrap): no-workspace bootstrap guidance should match the resolved-workspace diagnostics introduced on this branch
decision(no-workspace-hints): reuse the shared hint that mentions bd where instead of the bootstrap-specific fallback text
constraint(bootstrap-tests): cover both the payload helper and subprocess CLI path so wording regressions are caught before release

* fix(workspace): remove no-workspace .beads fallbacks (beads-9f74-gr1)

intent(workspace-resolution): finish the GH#3124 follow-up for runtime paths that still fabricated local .beads state
rejected(no-workspace-fallback): inventing ./ .beads paths outside an active workspace hid shared-worktree resolution and created stray files
decision(setup-recipes): keep built-in bd setup recipes usable without a workspace but require an active workspace for custom recipe state
constraint(worktree-support): completion and backup helpers still need to resolve shared main-repo workspaces from a git worktree

* fix(config): skip no-workspace store init for store-free commands

intent(config): review-fix-loop found no-workspace config commands should reach their own graceful paths instead of failing in PersistentPreRun
decision(config-preflight): detect store-free config subcommands before DB synthesis so config.yaml, git-backed, and diagnostic flows can run without an opened store
constraint(json-contract): keep bd config validate --json machine-readable on stdout once pre-run stops short-circuiting into low-level DB errors
learned(config-preflight): the parent config command not being in noDbCommands leaked store init into show, validate, drift, apply, and yaml-only config helpers

* fix(ci): restore init prefix normalization and formatting

intent(ci): clear the current PR failures instead of leaving the branch blocked behind known red checks

decision(init-prefix): normalize dotted prefixes before persisting issue_prefix so config, metadata.json, and Dolt database naming stay aligned for Julia-style repos
constraint(fmt-check): CI runs gofmt over the whole repo, so the existing spacing drift in internal/jira/tracker_test.go had to be cleaned up on this branch to get a green run
learned(ci): the latest main CI was already red on the same formatting file and the same embedded shard, so rebasing surfaced pre-existing blockers rather than introducing a new shard-only regression
2026-04-10 21:23:14 -07:00
coffeegoddd☕️✨
1684130a26 /{cmd,docs,internal}: get bootstrap and init working correctly and remote agnostic 2026-04-10 14:37:49 -07:00
coffeegoddd☕️✨
c96008f975 /cmd/bd: unify behavior of bd init and bootstrap 2026-04-10 14:36:19 -07:00
Osamu Okano
33109be4ac
fix: use worktree fallback in bootstrap path synthesis
When FindBeadsDir() returns empty and remote has dolt data,
bootstrap would create a stray .beads in the worktree. Now
checks GetWorktreeFallbackBeadsDir() first.
2026-04-07 22:19:15 +09:00
matt wilkie
eee8514054
fix: bootstrap uses parent workspace db name when local .beads missing (#3029) (#3083)
When running `bd bootstrap` from a rig subdirectory (its own git repo)
that doesn't have a local .beads/metadata.json, the config fell back to
DefaultConfig() which always returned "beads" as the database name.

Add findParentConfig() that walks up parent directories to find the
workspace-level metadata.json, so server-mode rigs get their configured
dolt_database name instead of the default.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 20:04:33 -07:00
coffeegoddd☕️✨
fef1d1898c /{cmd,internal,scripts}: use dsn helpers 2026-04-06 15:56:37 -07:00
Harry Miller
f3c15513d7
fix: bootstrap respects shared-server mode for database path (#3016)
When dolt.shared-server is enabled (via config.yaml or env var) but
cfg.DoltMode is not explicitly set to "server" in metadata.json,
detectBootstrapAction() incorrectly used the embedded database path
(embeddeddolt/) instead of the shared-server path (~/.beads/shared-server/dolt/).

This caused bd bootstrap to clone the database to the wrong location,
making it invisible to the shared Dolt server.

Fix: use cfg.IsDoltServerMode() (which checks env vars and metadata.json)
combined with doltserver.IsSharedServerMode() (which also checks config.yaml)
to determine the correct database path.

Fixes #30

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-05 17:22:37 -07:00
Bella-Giraffety
4e4d958baf
fix: prefer bootstrap for missing database recovery (#2940)
* fix: prefer bootstrap for missing database recovery

Executed-By: beads/crew/emma

* fix: align doctor recovery guidance with bootstrap

Executed-By: beads/crew/emma

* fix: let bootstrap recover missing server databases

Executed-By: beads/crew/emma

* fix: bootstrap missing server databases safely

Executed-By: beads/crew/emma

* fix: fail closed on bootstrap server probe errors

Executed-By: beads/crew/emma

* fix: honor runtime server config in bootstrap

Executed-By: beads/crew/emma

* docs: soften bootstrap-first recovery wording

Executed-By: beads/crew/emma

* fix: report resolved bootstrap server port

Executed-By: beads/crew/emma

* fix: repair test failures from build tag mismatch and mode detection

Three issues causing CI failures on macOS and Ubuntu:

1. detectBootstrapAction used isEmbeddedMode() (global state) to choose
   the database path, but tests set cfg.DoltMode without updating the
   global serverMode flag. Switch to cfg.GetDoltMode() so the detection
   logic respects the config object passed by the caller.

2. TestDetectBootstrapAction_NoneWhenDatabaseExists created a "dolt"
   directory but default (embedded) config looks for "embeddeddolt".
   Fix the test to create the correct directory.

3. embeddeddolt/slots.go and new_methods_test.go used //go:build
   embeddeddolt tag while all other files in the package use cgo,
   causing interface satisfaction failures. Also fix undefined
   isEmbeddedDolt reference (should be isEmbeddedMode()).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Executed-By: beads/crew/emma

---------

Co-authored-by: mayor <thalia.geraghty@fiserv.com>
Co-authored-by: beads/crew/emma <steve.yegge@gmail.com>
2026-04-02 19:52:58 -07:00
beads/crew/emma
a2fc789faf fix: make --yes/-y the primary flag in bd bootstrap, --non-interactive as alias
The PR merged with -y as shorthand for --non-interactive and --yes as a
separate flag with no shorthand. This was confusing UX. Now --yes/-y is
the primary flag and --non-interactive is the alias.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Executed-By: beads/crew/emma
2026-04-02 19:33:48 -07:00
Harry Miller
7806fbf47f
feat: add --non-interactive flag to bd bootstrap for CI (#2942)
Add --non-interactive / --yes / -y flag to bd bootstrap, matching the
pattern already used by bd init. Also supports BD_NON_INTERACTIVE=1
environment variable. This allows CI environments to skip confirmation
prompts without piping input.

Fixes harry-miller-trimble/beads#19

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-02 19:32:55 -07:00
coffeegoddd☕️✨
f1bf098d07 /{cmd,docs,internal}: remove file removal that can cause data corruption 2026-03-31 12:04:55 -07:00
Steve Yegge
b28d5179be
Merge pull request #2795 from harry-miller-trimble/fix/bootstrap-fresh-clone
fix: bd bootstrap detects remote data in fresh clones
2026-03-30 20:40:32 -07:00
Harry
dbdc9555b8 fix: clean stale noms LOCK files after bootstrap clone (bd-cmo)
bd bootstrap leaves .dolt/noms/LOCK files at multiple paths after
cloning, which prevents dolt sql-server from starting. Two changes:

1. CleanStaleNomsLocks now uses filepath.WalkDir to recursively find
   all noms/LOCK files, including nested stats databases:
   - <db>/.dolt/stats/.dolt/noms/LOCK
   - .dolt/noms/LOCK (root-level)

2. executeSyncAction in bootstrap.go now calls CleanStaleNomsLocks
   after clone completes, for both server and embedded mode paths.

The existing pre-flight cleanup in PersistentPreRun (main.go) also
benefits from the recursive scan as defense-in-depth.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 13:01:17 -07:00
Harry
685cb841b9 fix: bd bootstrap detects remote data in fresh clones (GH#2792)
bd bootstrap failed in a fresh second clone even when the origin already
had refs/dolt/data. The command required .beads to pre-exist, exiting
with 'No .beads directory found' before ever probing the remote.

Root cause: bootstrap.go called beads.FindBeadsDir() and exited at
line 48-62 when it returned empty, before detectBootstrapAction() could
run its remote detection logic (lines 132-142).

Fix: When .beads doesn't exist, probe the git remote for refs/dolt/data
before giving up. If remote has Beads data, synthesize the theoretical
.beads path and proceed with the sync plan. Actual .beads directory
creation is deferred to executeSyncAction to preserve --dry-run semantics.

Design decisions per council review:
- No filesystem writes during plan generation (--dry-run safe)
- No config.yaml generation needed (Dolt clone carries config)
- .beads created with 0750 permissions in executeSyncAction only
- Existing bootstrap behavior for all other scenarios unchanged

Tests added:
- Fresh clone with remote data: detects refs/dolt/data, produces sync plan
- Fresh clone without remote data: exits cleanly, no .beads created
- Existing .beads directory: normal flow unaffected

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 09:03:06 -07:00
coffeegoddd☕️✨
9b30a7f911 /{cmd,internal}: fix restore 2026-03-28 13:47:20 -07:00
coffeegoddd☕️✨
fb0bdbc60a /{cmd,internal}: update backup command 2026-03-28 13:47:20 -07:00
coffeegoddd☕️✨
a35edfd28e /{internal,cmd,.goreleaser,.github}: embedded mode by default 2026-03-28 13:47:20 -07:00
coffeegoddd☕️✨
f4b04e2ecd /cmd/bd: remove docker tip in embeddeddolt mode 2026-03-26 11:13:02 -07:00
coffeegoddd☕️✨
979d4f7052 /{cmd,internal}: bootstrap, compact, migrate 2026-03-26 10:59:57 -07:00
coffeegoddd☕️✨
bca3589913 /cmd/bd: skip bootstrap 2026-03-25 12:40:02 -07:00
Patrick Farrell
e67a57495f fix: bootstrap imports from git-tracked .beads/issues.jsonl
On a fresh clone, `bd bootstrap` never looks at the git-tracked
.beads/issues.jsonl file — the portable export that travels with the
repo. It only checks .beads/backup/issues.jsonl (a separate backup
format). This means the fresh-clone scenario (git clone, bd bootstrap,
expect your issues) is broken.

Add a "jsonl-import" action to the bootstrap detection chain, after
backup restore but before fresh init. When .beads/issues.jsonl exists
but no database, backup, or sync remote is present, bootstrap creates
a fresh database and imports all issues from the JSONL file using the
existing importFromLocalJSONL() function (which already handles prefix
auto-detection, tombstone filtering, and SetDefaults).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 17:01:59 -05:00
cwalv
4d14fb8ce1 feat: auto-detect beads database on git origin during bootstrap
When running `bd bootstrap` in a fresh clone, probe origin for
refs/dolt/data and automatically clone the existing beads database
instead of creating unrelated state. `bd init` warns if the ref
exists and suggests using `bd bootstrap` instead.

Fixes #2580
2026-03-14 00:18:13 -07:00
Patrick Farrell
6a1391e2f0 fix: skip empty backup/issues.jsonl so git-tracked JSONL wins
A stale empty backup/issues.jsonl (e.g. from a previous bd init --force)
would take priority over the git-tracked .beads/issues.jsonl, causing
bootstrap to attempt a backup restore with no data instead of importing
the real issues. Check that the backup file is non-empty before choosing
the backup restore path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 17:32:39 -07:00
darcy
efd7568de5 feat: bd bootstrap executes recovery actions instead of printing advice
Make bootstrap actually run init, restore, and sync operations rather than
just printing manual commands. Adds confirmation prompt, proper error handling,
and tests for action detection logic.

Cherry-picked from PR #2516.

Co-authored-by: Melsov Yernur <MelsovCOZY@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 18:23:40 -07:00
beads/crew/elinor
0bb3bf20a0 feat: add workspace identity preflight and bd bootstrap command (GH#2438, GH#2372)
Add validateWorkspaceIdentity() preflight in PersistentPreRun that compares
project_id from metadata.json with _project_id in the database. Blocks writes
on mismatch to prevent cross-project data corruption. Escape hatch:
BEADS_SKIP_IDENTITY_CHECK=1.

Add 'bd bootstrap' command as non-destructive alternative to 'bd init --force'.
Auto-detects recovery action: sync from remote, restore from backup, or create
fresh. Supports --dry-run and --json.

Co-Authored-By: matt wilkie <maphew@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:33:34 -07: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
gastown/crew/george
6911eeafb6 refactor(bootstrap): remove JSONL bootstrap, Dolt clone only (gt-vemg9q.1)
Remove the entire JSONL-to-Dolt bootstrap path (Bootstrap(), parseJSONLWithErrors,
importIssuesBootstrap, importRoutesBootstrap, importInteractionsBootstrap) and
742 lines of bootstrap tests. Cold-start now requires either a configured
sync.git-remote for dolt clone, or 'bd init --backend=dolt'.

Also delete orphaned sync_divergence_test.go missed in Phase 1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Executed-By: gastown/crew/george
Rig: gastown
Role: crew
2026-02-21 17:49:37 -08:00
beads/crew/lizzy
9abb7dd5d9 refactor(dolt): remove vestigial embedded-mode artifacts
- Remove Config.ServerMode and Config.OpenTimeout fields (dead since embedded removal)
- Rewrite doctor/dolt.go to use MySQL protocol instead of embedded dolthub/driver
- Rename openDoltDBWithLock to openDoltConn, remove closeDoltDB helpers
- Delete dolt_nocgo.go stubs (doctor + store_nocgo_test.go)
- Remove cgo build tags from doctor package
- Update lock error messages for server-only world
- Clean up unused lockTimeout parameter threading in list.go

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 17:33:59 -08:00
beads/crew/emma
bd68c87b00 fix: remove stale embedded Dolt references after server-only migration
Delete broken store_nocgo_test.go (references undefined errNoCGO),
remove dead bootstrapEmbeddedDolt/hasDoltSubdir functions, and clean up
stale comments and docs that still referenced embedded mode, CGO
requirements, or in-process Dolt across 20 files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-21 16:59:44 -08:00
elinor
c4010c1977 feat: remove CGO build-tag bifurcation for dolt commands
Delete 6 CGO/nocgo stub files and remove //go:build cgo tags from
dolt.go and bootstrap.go. Beads now always operates in server mode
(dolt sql-server subprocess). Embedded mode references removed from
CLI help text and config commands.

Part of epic: Remove embedded Dolt mode (server-only operation).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 15:37:31 -08:00
beads/crew/emma
ff7244b619 feat: remove JSONL sync-branch pipeline, replace with Dolt-in-Git
Remove 10,955 lines of dead code from the JSONL sync-branch pipeline,
now replaced by native Dolt push/pull via git remotes.

Deleted:
- internal/syncbranch/ (5,720 lines: worktree management, integrity checks)
- cmd/bd/deletion_tracking.go (3-way JSONL merge)
- cmd/bd/snapshot_manager.go (JSONL snapshot tracking)
- cmd/bd/doctor/sync_branch_jsonl.go (JSONL validation)
- cmd/bd/doctor/fix/sync_branch.go (sync branch repair)
- All associated test files

Preserved:
- bd export / bd import (manual tools)
- isGitRepo(), gitHasUpstream() (still have callers)
- Doctor check stubs (return StatusOK N/A)

Added:
- BootstrapFromGitRemote() for Dolt-in-Git bootstrap
- Dolt push in bd sync via store.Push()
- sync.git-remote config key
- HasRemote() on DoltStore

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-18 20:13:55 -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
beads/crew/emma
a5da57e39b refactor: remove storage factory, memory backend, and provider abstraction (Phase 7)
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
2026-02-15 11:27:39 -08:00
Renamed from internal/storage/factory/factory_dolt.go (Browse further)