Skip to content

feat(config): add central server config library#3258

Merged
maphew merged 4 commits into
gastownhall:mainfrom
trillium:feature/central-server-config
Apr 27, 2026
Merged

feat(config): add central server config library#3258
maphew merged 4 commits into
gastownhall:mainfrom
trillium:feature/central-server-config

Conversation

@trillium

@trillium trillium commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Overview

Eliminates the need to duplicate server connection settings (host, port, user, mode, TLS) across 30+ per-project metadata.json files by introducing a central config library that can load machine-wide defaults from ~/.config/beads/server.json.

Changes

  • Add LoadCentralConfig(), DefaultCentralConfigPath(), and ApplyCentralDefaults() to the configfile package
  • Wire applyCentralConfigDefaults() into NewFromConfigWithOptions and NewFromConfigWithCLIOptions in internal/storage/dolt/open.go

Design decisions

  • Only server connection fields are inherited from central config — per-project fields (database, data-dir, project-id) are never inherited
  • Per-project values always override central defaults
  • Missing central config is a silent no-op
  • Central config path overridable via BEADS_CENTRAL_CONFIG env var

Test plan

Run go test ./internal/configfile/ -run TestLoadCentral -v and go test ./internal/configfile/ -run TestApplyCentral -v to validate the library, and go test ./internal/storage/dolt/ -run TestApplyCentralConfigDefaults -v to validate the integration wiring:

  • Loading a valid central config file returns the expected fields
  • Missing file returns (nil, nil) — no error, graceful skip
  • Invalid JSON returns a parse error
  • Empty project fields are filled from central defaults
  • Non-zero project fields are preserved over central values
  • Env vars (BEADS_DOLT_SERVER_HOST, etc.) override both project and central via getter methods
  • Per-project-only fields (database, data-dir, project-id) are never inherited
  • nil central config is a no-op
  • DefaultCentralConfigPath() returns a path ending in beads/server.json
  • applyCentralConfigDefaults loads and applies central config to per-project config
  • Missing central config file is a no-op in the wiring path
  • Project fields override central defaults through the wiring path

Commits

  1. test(config): add specs for central server config library — Stub implementations + full test suite. Three tests fail (LoadCentralConfig_FileExists, LoadCentralConfig_InvalidJSON, ApplyCentralDefaults_FillsEmptyFields), defining expected behavior before implementation.
  2. feat(config): implement central server config library — Fill in LoadCentralConfig (read + parse JSON, graceful skip on missing file) and ApplyCentralDefaults (merge server-only fields at zero values). All 9 tests pass.
  3. test(config): add integration specs for central config wiring — Stub applyCentralConfigDefaults in open.go + integration tests. One test fails (WiresIntoOpenPath), proving the glue function doesn't yet load/apply the central config.
  4. feat(config): wire central config into store open paths — Implement applyCentralConfigDefaults and call it in both NewFromConfigWithOptions and NewFromConfigWithCLIOptions. All integration tests pass.

@codecov-commenter

codecov-commenter commented Apr 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.63636% with 16 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
internal/storage/dolt/open.go 30.76% 6 Missing and 3 partials ⚠️
internal/configfile/central_config.go 77.41% 4 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

Add test cases for LoadCentralConfig, ApplyCentralDefaults, and
DefaultCentralConfigPath with stub implementations. Tests define
the expected behavior; implementations follow in the next commit.
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.
@trillium trillium force-pushed the feature/central-server-config branch from a4d4e59 to 18634c8 Compare April 13, 2026 22:11
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.
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.
@maphew

maphew commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

hi @trillium is there a reason this is still in draft mode? what more do you have incoming?

@trillium

Copy link
Copy Markdown
Contributor Author

No, just being conservative about automated PRs and didn't catch the it was draft as I was going back and forth with the agent

@trillium trillium marked this pull request as ready for review April 27, 2026 14:55
@maphew maphew merged commit 3367288 into gastownhall:main Apr 27, 2026
37 checks passed
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.

3 participants