Skip to content

feat: add OpenBestAvailable to public API#3149

Merged
maphew merged 1 commit into
mainfrom
feat/open-best-available
Apr 9, 2026
Merged

feat: add OpenBestAvailable to public API#3149
maphew merged 1 commit into
mainfrom
feat/open-best-available

Conversation

@maphew

@maphew maphew commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3143

Adds OpenBestAvailable(ctx, beadsDir) which routes to the correct storage backend based on metadata.json, mirroring the CLI's newDoltStoreFromConfig logic:

  • CGO builds: embedded mode (default) with exclusive flock, or server mode when dolt_mode=server
  • Non-CGO builds: server mode only, returns clear error for embedded mode

Returns (Storage, Unlocker, error) so callers manage the flock lifetime. This fixes the problem where library users of OpenFromConfig silently got an empty shadow database instead of the actual embedded store.

Files

  • beads_cgo.go — CGO build: loads config, acquires flock, opens embedded Dolt (or delegates to server mode)
  • beads_nocgo.go — Non-CGO build: server mode only, clear error for embedded

Adds OpenBestAvailable(ctx, beadsDir) which routes to the correct
storage backend based on metadata.json, mirroring the CLI's
newDoltStoreFromConfig logic:

- CGO builds: embedded mode (default) with exclusive flock, or server
  mode when dolt_mode=server
- Non-CGO builds: server mode only, returns clear error for embedded

Returns (Storage, Unlocker, error) so callers manage the flock lifetime.
This fixes the problem where library users of OpenFromConfig silently
got an empty shadow database instead of the actual embedded store.

Amp-Thread-ID: https://ampcode.com/threads/T-019d736a-46a6-7178-91f3-854f36dd474b
Co-authored-by: Amp <amp@ampcode.com>
@maphew maphew merged commit 4bce933 into main Apr 9, 2026
31 checks passed
maphew added a commit that referenced this pull request Apr 9, 2026
Restores test coverage that was dropped when PR #3149 reimplemented
the feature without carrying over the tests from bgjackma's original
PR #3143. Tests are adapted for the current (Storage, Unlocker, error)
return signature.

Co-authored-by: Brock Jackman <brockj@lyft.com>
maphew added a commit that referenced this pull request Apr 9, 2026
* feat: add OpenBestAvailable to public API (#3143)

Adds OpenBestAvailable(ctx, beadsDir) which routes to the correct
storage backend based on metadata.json, mirroring the CLI's
newDoltStoreFromConfig logic:

- CGO builds: embedded mode (default) with exclusive flock, or server
  mode when dolt_mode=server
- Non-CGO builds: server mode only, returns clear error for embedded

Returns (Storage, Unlocker, error) so callers manage the flock lifetime.
This fixes the problem where library users of OpenFromConfig silently
got an empty shadow database instead of the actual embedded store.

Amp-Thread-ID: https://ampcode.com/threads/T-019d736a-46a6-7178-91f3-854f36dd474b
Co-authored-by: Amp <amp@ampcode.com>

* test: add OpenBestAvailable tests from PR #3143

Restores test coverage that was dropped when PR #3149 reimplemented
the feature without carrying over the tests from bgjackma's original
PR #3143. Tests are adapted for the current (Storage, Unlocker, error)
return signature.

Co-authored-by: Brock Jackman <brockj@lyft.com>

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brock Jackman <brockj@lyft.com>
seanmartinsmith pushed a commit to seanmartinsmith/beads that referenced this pull request Apr 10, 2026
…hall#3149)

Adds OpenBestAvailable(ctx, beadsDir) which routes to the correct
storage backend based on metadata.json, mirroring the CLI's
newDoltStoreFromConfig logic:

- CGO builds: embedded mode (default) with exclusive flock, or server
  mode when dolt_mode=server
- Non-CGO builds: server mode only, returns clear error for embedded

Returns (Storage, Unlocker, error) so callers manage the flock lifetime.
This fixes the problem where library users of OpenFromConfig silently
got an empty shadow database instead of the actual embedded store.

Amp-Thread-ID: https://ampcode.com/threads/T-019d736a-46a6-7178-91f3-854f36dd474b

Co-authored-by: Amp <amp@ampcode.com>
seanmartinsmith pushed a commit to seanmartinsmith/beads that referenced this pull request Apr 10, 2026
…3143 (gastownhall#3150)

* feat: add OpenBestAvailable to public API (gastownhall#3143)

Adds OpenBestAvailable(ctx, beadsDir) which routes to the correct
storage backend based on metadata.json, mirroring the CLI's
newDoltStoreFromConfig logic:

- CGO builds: embedded mode (default) with exclusive flock, or server
  mode when dolt_mode=server
- Non-CGO builds: server mode only, returns clear error for embedded

Returns (Storage, Unlocker, error) so callers manage the flock lifetime.
This fixes the problem where library users of OpenFromConfig silently
got an empty shadow database instead of the actual embedded store.

Amp-Thread-ID: https://ampcode.com/threads/T-019d736a-46a6-7178-91f3-854f36dd474b
Co-authored-by: Amp <amp@ampcode.com>

* test: add OpenBestAvailable tests from PR gastownhall#3143

Restores test coverage that was dropped when PR gastownhall#3149 reimplemented
the feature without carrying over the tests from bgjackma's original
PR gastownhall#3143. Tests are adapted for the current (Storage, Unlocker, error)
return signature.

Co-authored-by: Brock Jackman <brockj@lyft.com>

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brock Jackman <brockj@lyft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant