Commit graph

86 commits

Author SHA1 Message Date
matt wilkie
578524c0e9
[codex] Diagnose Dolt journal corruption and init lock hangs (#3457)
* fix: diagnose Dolt journal corruption on startup

* fix: prevent embedded init CI hang

* test(init): bound concurrent embedded init subprocesses

* test: align embedded dolt status concurrency expectation
2026-04-24 07:14:24 -07:00
Shaun Taheri
a78e58388f
feat: support Unix domain sockets for Dolt server connections (#3300)
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
2026-04-21 22:12:15 -07:00
matt wilkie
d57dc7128a
fix(dolt): auto-recover from corrupt manifest on startup (GH#3290) (#3327)
Closes #3290 — auto-recovery from corrupt dolt manifest on startup (GH#3290 signature: 'root hash doesn't exist').
2026-04-17 21:02:04 -07:00
workingdoge
abf03e1d4c
Keep regular epics open after the last child closes (#3276)
* Fix macOS lsof cwd filtering in doltserver

* Keep regular epics open after last child closes
2026-04-17 15:10:38 -07:00
coffeegoddd☕️✨
fa87dd2bdd feat: add global beads_global database for shared-server mode
Adds a project-agnostic beads_global database to shared-server mode so
clients can track issues globally across all projects on the server.

- Add EnsureGlobalDatabase() to create the DB during shared server init
- Add --global persistent flag to switch CLI commands to the global DB
- Add global_dolt_database field to metadata.json for connection info
- Seed global DB with issue_prefix="global" and sentinel project ID
- Export/import default to global-issues.jsonl with --global flag
- --global errors when not in shared-server mode (additive, no breakage)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 09:18:43 -07:00
Jim Wordelman
9fa62ee397
fix(doltserver): rotate dolt-server.log at startup to cap size (#3161)
Co-authored-by: quad341 <quad341@users.noreply.github.com>
2026-04-10 21:52:37 -07:00
Jim Wordelman
935a200a78
fix: silence dolt sql-server NewConnection log spam (#3160)
Co-authored-by: quad341 <quad341@users.noreply.github.com>
2026-04-10 21:51:51 -07:00
matt wilkie
f09970fe32 Allow BEADS_DOLT_READY_TIMEOUT to override waitForReady timeout (#3188)
On slow hardware, Dolt's first-run SQL engine bootstrap takes ~60s before
the MySQL listener accepts connections, exceeding the hardcoded 10-second
waitForReady budget and causing bd init --shared-server to kill dolt
mid-bootstrap with "server started but not accepting connections."
Default behavior is unchanged; the fix is opt-in.

- Add readyTimeout() helper reading BEADS_DOLT_READY_TIMEOUT (positive
  integer seconds, default 10) with stderr warning on invalid input
- Use readyTimeout() at the Start() call site
- Add TestReadyTimeout covering parsing, fallback, and edge cases
- Add TestWaitForReady: direct test of waitForReady's timeout behavior
  using a delayed-bind fake listener; closes a pre-existing coverage gap
- Update CHANGELOG.md

Maintainer polish: fix warning casing to match project convention,
correct comment (TCP connections, not queries), fix env var cleanup
in unset test case, add subtest ordering comment.

Fixes #3142

Co-authored-by: David Hite <14855188+ghbaud@users.noreply.github.com>
2026-04-10 21:38:19 -07:00
coffeegoddd☕️✨
c71930d1e5 /{cmd,internal}: pr feedback 2026-04-08 15:03:32 -07:00
coffeegoddd☕️✨
a0849721ba /{cmd,internal}: some cleanup 2026-04-08 14:45:18 -07:00
coffeegoddd☕️✨
0c2dfc14af /{cmd,internal}: shared server concurrency tests 2026-04-08 13:22:54 -07:00
coffeegoddd☕️✨
fef1d1898c /{cmd,internal,scripts}: use dsn helpers 2026-04-06 15:56:37 -07:00
Alex Siri
97fea942f6
fix: respect dolt.auto-start=false, prevent rogue server spawns (#3058)
* fix: respect dolt.auto-start=false config, prevent rogue server spawns

resolveAutoStart checked the caller's `current=true` before the config
file's explicit opt-out, so dolt.auto-start=false was never honored.

Reorder priority so config.yaml opt-out wins over caller defaults.
Add defense-in-depth guard in EnsureRunningDetailed and clearer error
messages when auto-start is disabled.

Fixes #3057

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

* fix: make config opt-out comparison case-insensitive

Use strings.EqualFold for "false" and "off" checks in resolveAutoStart,
consistent with isFalsyBool in doltserver. Handles quoted YAML strings
like "FALSE" or "Off" that bypass YAML boolean normalization.

Addresses review yellow flag on case sensitivity.

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

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-04-06 10:08:04 -07:00
Harry Miller
9f3b813572
fix: use strconv.ParseBool for env var parsing in IsAutoStartDisabled (#2956)
* fix: use strconv.ParseBool for env var parsing in IsAutoStartDisabled

Replace manual strings.ToLower + equality checks with strconv.ParseBool
for standardized truthy/falsy handling. Retains "off" as a recognized
disable value for backward compatibility.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* style: fix gofmt formatting in doltserver_test.go

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-02 19:23:04 -07:00
Harry Miller
1f4863b85b
fix: add whitespace trimming to env var parsing in IsAutoStartDisabled (#2955)
Add strings.TrimSpace() before comparison in IsAutoStartDisabled to
handle env var values with surrounding whitespace like ' 0 ' or
' false '. Consistent with TrimSpace usage elsewhere in the file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-02 19:18:50 -07:00
matt wilkie
baa9d02457
fix: treat --shared-server as server mode for DoltMode (#2947)
* fix: prevent silent fallback to embedded mode when shared-server is active (GH#2949)

Root cause: ResolveServerMode() and IsDoltServerMode() checked
metadata.json dolt_mode=embedded BEFORE runtime env vars, so stale
persisted metadata silently overrode active shared-server config.

Fixes:
- ResolveServerMode: env vars (BEADS_DOLT_SERVER_MODE, BEADS_DOLT_SHARED_SERVER)
  now checked before metadata.json, preventing stale embedded override
- IsDoltServerMode: now checks BEADS_DOLT_SHARED_SERVER env var (shared-server
  implies server-backed storage)
- warnSharedServerEmbeddedMismatch -> repairSharedServerEmbeddedMismatch:
  auto-repairs stale dolt_mode=embedded in metadata.json instead of just warning
- Added 6 regression tests covering the upgrade path

Closes #2949

Amp-Thread-ID: https://ampcode.com/threads/T-019d4b84-cddd-725a-a3c6-ee7e3631f2aa
Co-authored-by: Amp <amp@ampcode.com>

* fix: treat --shared-server as server mode for metadata.json DoltMode (#2946)

--shared-server sets BEADS_DOLT_SHARED_SERVER for directory resolution but
never set initServerMode, so metadata.json recorded DoltMode as "embedded"
and all subsequent commands used embedded Dolt despite config.yaml having
dolt.shared-server: true.

Also override metadata.json at runtime when dolt.shared-server is set,
so existing installs with stale metadata.json are handled without re-init.

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

* fix: ensure shared server runs during init and fix isEmbeddedMode check

Two additional fixes for GH#2946:

1. Init auto-starts the shared Dolt server if not already running,
   since ResolveServerMode classifies shared-server as External
   which suppresses the normal auto-start path.

2. isEmbeddedMode() now checks doltserver.IsSharedServerMode() as a
   fallback. Dolt subcommands (status, start, stop) skip DB init in
   PersistentPreRun, so serverMode is never set from metadata.json.
   Without this, "bd dolt status" would still report embedded mode
   even with dolt.shared-server: true in config.yaml.

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

* fix: apply shared-server override to loadServerModeFromConfig()

Closes the gap flagged in PR review: no-db commands (bd dolt start,
bd dolt status, bd doctor, etc.) go through loadServerModeFromConfig()
which didn't have the shared-server override for stale metadata.json.

This ensures isEmbeddedMode() returns false for all command paths when
dolt.shared-server is true in config.yaml, not just commands that pass
the no-db guard in PersistentPreRun.

GH#2946

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d4f6f-01f8-72d4-b474-f75d7909b8b9

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 11:52:20 -07:00
matt wilkie
78cc11677e
Merge pull request #2884 from renezander030/fix/2812-dolt-env-vars
fix: pass parent env vars to dolt-sql-server child process
2026-04-01 06:47:00 -07:00
Harry
047e506859 Enforce .beads/ directory permissions at runtime
- Add config.BeadsDirPerm (0700) and config.BeadsFilePerm (0600) constants
- Add config.CheckBeadsDirPermissions() for startup warning if permissions
  are too permissive (non-fatal, checks group/world bits)
- Add config.EnsureBeadsDir() helper for consistent directory creation
- Tighten all MkdirAll calls for .beads/ paths from 0750/0755 to 0700:
  init.go, doltserver.go, credentials.go, audit.go, recipes.go,
  embeddeddolt store.go and flock.go
- Add startup check in loadEnvironment() (cmd/bd/main.go)
- Windows build tag with no-op implementation (ACL-based permissions)
- 6 tests: constants, dir creation perms, warning on permissive, no
  warning on secure, no error on nonexistent

Fixes: bd-kl6

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 09:15:49 -07:00
Rene Zander
0a1be381ca fix: pass parent env vars to dolt-sql-server child process
When bd dolt start spawns dolt-sql-server as a detached process,
environment variables are not inherited. This breaks cloud storage
remotes (Azure, AWS) that rely on env vars for credentials.

Explicitly set cmd.Env = os.Environ() to ensure the child process
inherits the parent environment regardless of process group detachment.

Fixes #2812
2026-03-29 06:31:15 +00:00
emma
6d4a5adc9a feat: use writeRetryTx for Dolt serialization errors (fix-merge PR #2855)
Introduces withRetryTx — a transaction-level retry wrapper for Dolt
serialization errors (1213 deadlock / 1205 lock wait timeout). Migrates
all withWriteTx call sites to use it. Removes advisory lock from schema
init (DDL is now idempotent via IF NOT EXISTS). Stripped debug log level
flag that was left in doltserver.go.

Co-Authored-By: Dustin Brown <dustin@dolthub.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 12:33:08 -07:00
coffeegoddd☕️✨
910ad13108 /internal/{storage,doltserver}: remove incorrect locking attempt for journal corruption that does not repro 2026-03-26 15:00:48 -07:00
Harry
37355db018 test: add multi-process concurrency and server lifecycle integration tests
Implement 5 test groups for GH#2763, targeting production failure modes
that single-process goroutine tests cannot catch:

T1: Server lifecycle (lifecycle_integration_test.go)
  - Start/stop cycle with state file verification
  - Crash recovery (SIGKILL -> restart -> data survives)
  - Restart data persistence across stop/start cycles
  - Multi-repo isolation (KillStaleServers cross-repo safety)
  - Concurrent IsRunning+Start atomicity
  - PID reuse detection (isDoltProcess check)

T2: Multi-process schema init (initschema_multiprocess_test.go)
  - 8 subprocesses racing initSchemaOnDB on fresh DB
  - Journal corruption detection via dolt verify
  - Schema integrity validation (all tables/indexes present)

T3: Multi-DoltStore operations (multistore_multiprocess_test.go)
  - Layer 1: 5 independent sql.DB pools, in-process concurrent ops
  - Layer 2: 5 subprocesses each with own DoltStore
  - Close isolation (one pool close doesnt cascade)

T4: Dirty state recovery (dirty_state_test.go)
  - Stale PID (alive non-dolt, dead, reused)
  - Stale port file, corrupt PID, truncated metadata.json
  - Port 0 regression (GH#2598)
  - Combined stale PID+port, orphan noms LOCK

T5: Port allocation race (port_race_test.go)
  - Concurrent Start() exactly-one-wins via flock
  - Ephemeral port retry with occupied port
  - Loopback-only binding verification
  - Multi-repo port collision prevention

Shared harness (internal/testutil/integration/):
  - ProcessRegistry: SIGTERM->SIGKILL escalation with t.Cleanup
  - SubprocessRunner: sync.Once binary build, env allowlist, Setpgid
  - StateCorruptor: dirty state fixture helpers
  - Diagnostics: failure artifact capture

All tests use //go:build integration && !windows and run in nightly CI
with -race flag. Existing test suite unaffected.

Fixes #2763

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-22 15:01:45 -07:00
emma
9b2c012e7e feat: custom status categories (active/wip/done/frozen)
Add category-aware custom statuses that control behavior in bd ready
and bd list. New config format: bd config set status.custom
"in_review:active,qa_testing:wip,archived:done,on_hold:frozen".
Backward compatible with old flat format. New bd statuses command
lists all statuses with --json support.

Also fix TestKillStaleServersPreservesOtherRepoServers to clear
BEADS_DOLT_AUTO_START env var, since the new IsAutoStartDisabled guard
in killStaleServersForDir short-circuits when set.

PR: #2665

Co-Authored-By: Harry Miller <harry-miller-trimble@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:35:03 -07:00
emma
468c8630be fix: Windows Dolt server lifecycle — stale state files and false auto-stop warning (GH#2670)
Introduce ErrServerNotRunning sentinel so callers can distinguish "already
stopped" from real failures. Stop now cleans up leftover PID/port files even
when the server is not running, preventing bd dolt status from reporting stale
state. Consolidate IsAutoStartDisabled into a single exported function covering
both env var and config sources.

PR: #2740

Co-Authored-By: Harry Miller <harry-miller-trimble@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:31:20 -07:00
garnet
3dae6bb3df refactor: remove gastown/Gas Town string references from beads code and docs (bd-1ue8)
Replace gastown-specific references with generic alternatives throughout
the codebase:

- Rename --gastown flag to --orchestrator in bd doctor
- Rename gastownMode/gastownThreshold params to orchestratorMode/orchestratorThreshold
- Rename isGasTownTownRoot() to isOrchestratorRoot()
- Replace "gastown" in CLI examples with generic rig names (my-project, other-project)
- Update comments replacing "Gas Town" with "orchestrator" or "multi-agent workspace"
- Update active docs (DOLT.md, CONFIG.md, ADVANCED.md, etc.)
- Update test data to use generic names instead of "gastown"
- Update role templates (deacon, witness, refinery) to use generic language

Preserved as historical (not changed):
- CHANGELOG.md entries (historical record)
- ARTICLES.md (links to real published articles)
- info.go version notes (historical release notes)
- gastown/ file path references in dolt-concurrency.md (point to actual repo)
2026-03-20 18:39:50 -07:00
matt wilkie
e66ee1d98d style: fix gofmt formatting in doltserver.go
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 17:46:16 -07:00
matt wilkie
9e17dbfaa0 refactor(doltserver): introduce ServerMode enum to consolidate server ownership inference
Replace ad-hoc mode checks (hasExplicitPort(), explicitPort bool parameter,
BEADS_DOLT_SERVER_MODE env var checks) with a single ServerMode enum and
ResolveServerMode() function. This gives one canonical place to determine
whether beads owns/manages the server (Owned), the user manages it (External),
or the legacy embedded path is used (Embedded).

- Add ServerMode type with Owned/External/Embedded constants
- Add ResolveServerMode() as single source of truth for mode inference
- Thread Mode through doltserver.Config (populated by DefaultConfig)
- Replace hasExplicitPort() in EnsureRunningDetailed with ServerMode check
- Update resolveAutoStart() to take ServerMode instead of explicitPort bool
- Re-export ServerMode constants in storage/dolt for downstream callers
- Update all tests to use ServerMode instead of bool parameters

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 17:46:16 -07:00
matt wilkie
c41ddbc455
Merge pull request #2700 from maphew/fix/kill-stale-servers-ownership
fix: make KillStaleServers respect server ownership
2026-03-18 11:59:35 -07:00
matt wilkie
fe1c9d5624 fix: make KillStaleServers respect server ownership
KillStaleServers previously killed ANY dolt sql-server process whose CWD
matched the repo's dolt data directory. This could kill systemd-managed
shared servers or other repos' servers using the same shared data dir.

Now killStaleServersForDir checks ownership before killing:
- Skip entirely when hasExplicitPort() is true (externally managed)
- Skip entirely when BEADS_DOLT_AUTO_START=0 (externally managed)
- Skip entirely when no PID file exists (no beads-started server to
  compare against, so nothing is "stale" from our perspective)
- Only kill orphan processes when a valid PID file proves beads owns
  a server in this directory

Fixes bd-a36.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 11:44:17 -07:00
matt wilkie
2aff244538 fix: don't kill externally-managed dolt servers (GH#2641)
When dolt.auto-start is false (via BEADS_DOLT_AUTO_START=0 env var or
config.yaml), bd now skips all server kill logic in KillStaleServers and
refuses to auto-start servers in EnsureRunning. This prevents bd from
killing systemd-managed or other externally-managed dolt processes.

Also fixes initCredentialKey to create the .beads/ directory if it
doesn't exist, allowing connections to external servers without
requiring bd init first.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 19:46:23 -07:00
Gary
0952ffbe09 Preserve repo-local Dolt servers during stale cleanup (GH#2595) 2026-03-14 11:54:52 -05:00
beads/crew/emma
e9bce2304c fix: EnsureRunning skips Start() when explicit port indicates external server
When metadata.json has an explicit dolt_server_port, the server is
externally managed (e.g. systemd). Do not auto-start a per-project
server — it would conflict with the shared server.

Also adds EnsureRunningDetailed() returning startedByUs for cleanup.

PR: https://github.com/steveyegge/beads/pull/2561
PR: https://github.com/steveyegge/beads/pull/2562
Co-authored-by: matt wilkie <maphew@users.noreply.github.com>
2026-03-13 17:32:59 -07:00
Steve Yegge
9e9b19fac2
Merge pull request #2504 from steveyegge/fix/dolt-journal-corruption-2430
fix: prevent dolt journal corruption from concurrent server starts
2026-03-11 17:44:44 -07:00
lydia
a7755e5b13 fix: prevent bd init from creating DB on another project's Dolt server (GH#2336)
During bd init, port resolution via DefaultConfig falls through to
config.yaml / global config when no port file exists yet for the new
project. This can resolve to another project's server, causing the new
database to be created on the wrong server (cross-project data leakage).

Fix: bd init now uses only project-local port sources (env var, port
file) instead of DefaultConfig. For fresh inits with no port file,
port 0 forces auto-start to allocate an ephemeral port for THIS project.
Shared server mode is handled explicitly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:45:45 -07:00
beads/crew/emma
f0078a055a fix: warn on Dolt endpoint drift during auto-start (GH#2399)
When auto-start allocates a new ephemeral port because the configured port
is unreachable, bd now warns with the old and new port numbers and suggests
pinning via dolt.port in config.yaml. Also logs when port file is updated
to a different value.

This makes endpoint drift visible instead of silent, addressing the split-brain
scenario where other tools/agents still expect the old port.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:42:04 -07:00
beads/crew/lizzy
141119adef fix: move KillStaleServers inside flock to prevent journal corruption (GH#2430)
KillStaleServers was called outside the exclusive file lock in
EnsureRunning(), creating a race where one process could kill a server
that another process was in the middle of starting (PID file not yet
written). This caused concurrent dolt sql-server instances to corrupt
the journal file.

Moving the cleanup inside Start() after the flock is acquired ensures
the kill-and-start sequence is atomic — no other process can interfere
between orphan cleanup and PID file creation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:39:26 -07:00
beads/crew/emma
8386380437 fix: YAML config prefix takes precedence over DB in shared-server mode (GH#2469)
In shared-server mode, the DB issue_prefix belongs to whichever project
initialized first. This caused all projects sharing a server to use the
wrong prefix for issue creation, ID generation, and imports.

Fix: YAML config.yaml issue-prefix now takes precedence over the DB value
in create.go, github.go, gitlab.go, linear.go, orphans.go, and merge_slot.go
(which already had the correct pattern).

Also: EnsureRunning() now calls KillStaleServers() before starting a new
server, cleaning up orphaned dolt sql-server processes that accumulate when
parent processes crash without graceful shutdown (GH#2372).

Also: add cross-project data isolation tests (5 tests covering read isolation,
port collision, same-prefix isolation, concurrent writes, and concurrent
read-write mix). Based on tests by @PabloLION (PR #2472).

Co-Authored-By: PabloLION <dev@pablolion.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:18:19 -07:00
beads/crew/emma
396c944a5e fix: add shared Dolt server mode for multi-repo/agent setups (GH#2416)
Introduces BEADS_DOLT_SHARED_SERVER mode where multiple beads projects
share a single Dolt server on a fixed port (3308), avoiding per-project
server sprawl. Includes `bd init --shared-server`, `bd dolt shared-*`
commands, doctor checks, and comprehensive tests.

Co-Authored-By: Shybko <shybko@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:38:00 -07:00
beads/crew/emma
31bae5a2e4 fix: replace hash-derived dolt ports with OS-assigned ephemeral ports (GH#2415)
Replace DerivePort() (FNV-32a hash into 1000-port range) with OS-assigned
ephemeral ports via net.Listen(":0"). This eliminates birthday-problem
port collisions that caused cross-project data leakage (GH#2098, GH#2372).

DefaultConfig() returns port 0 when no explicit config exists. Start()
allocates an ephemeral port with retry loop for TOCTOU races. Explicit
port config (env var, config.yaml, metadata.json) is preserved unchanged.

Closes #2098. Partially addresses #2372 (Layer 1 — port isolation).

Co-Authored-By: timvisher-dd <timvisher-dd@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:04:53 -07:00
jane
b7cc484441 feat: replace hash-derived dolt ports with OS-assigned ephemeral ports (GH#2415)
Replace DerivePort() (FNV-32a hash into 1000-port range) with OS-assigned
ephemeral ports via net.Listen(":0"). This eliminates birthday-problem port
collisions (#2098) and complements Layer 2 identity verification (c6e41803)
for defense-in-depth against cross-project data leakage (#2372).

Start() now allocates ephemeral ports with a retry loop (10 attempts) for
TOCTOU races. Explicit port config (env var, config.yaml, metadata.json)
is preserved with conflict detection via reclaimPort.

Closes #2098. Partially addresses #2372.

Co-Authored-By: Tim Visher <194828183+timvisher-dd@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:39:43 -07:00
beads/crew/emma
4df17ca344 fix: remove idle monitor and activity signal daemon infrastructure (GH#2452)
Remove the idle monitor sidecar process and activity file mechanism.
In Gas Town and external Dolt server setups, the server is managed
externally, making this daemon infrastructure unnecessary. The idle
monitor also contributed to background connection accumulation and
CLOSE_WAIT issues under concurrent polecat load.

Co-Authored-By: athosmartins <noreply@github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:13:13 -07:00
beads/crew/emma
e56fc506bd fix: idle-monitor preserves port across restart cycles (bd-xvg)
The idle monitor removes the port file when stopping an idle server
(via stopServerProcess). When restarting, Start()/DefaultConfig()
cannot find the port file and falls through to DerivePort(), which
produces a hash-derived port that may differ from the original 3307.
This overwrites dolt-server.port with the wrong value, breaking other
bd/gt commands.

Fix: track the server port while running and restore the port file
before calling Start() on restart, so DefaultConfig() picks up the
correct port.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:41:29 -07:00
garitar
14df21b629
Fix repo-local Dolt ports across doctor paths (#2403)
* Fix legacy Dolt port resolution and port-file backfill

* Fix doctor checks to honor repo-local Dolt ports

* Fix doctor health checks for repo-local Dolt ports
2026-03-08 18:10:15 -07:00
matt wilkie
5a454aeb1d fix: suppress pre-existing gosec false positives with nolint directives
Amp-Thread-ID: https://ampcode.com/threads/T-019cc570-cef3-71cb-bc0f-e2ef4e5e6bde
Co-authored-by: Amp <amp@ampcode.com>
2026-03-06 16:21:41 -07:00
beads/crew/emma
2174032bdd fix(test): remove more daemon-dependent tests (maxDoltServers, idle monitor)
TestMaxDoltServers/gastown expected maxDoltServers()=1 under GT_ROOT,
but daemon removal made it always return 3.

TestRunIdleMonitorExitsOnStaleActivityNoServer relied on IsDaemonManaged
early exit to complete within 60s; without it the 60s sleep causes timeout.

TestRunIdleMonitorGasTownExitsImmediately tested the removed Gas Town
early-exit path in RunIdleMonitor; replaced with zero-timeout test.

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-03-05 14:48:03 -08:00
beads/crew/emma
246b0e83dc style: fix gofmt trailing blank lines
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-03-05 14:35:32 -08:00
beads/crew/emma
4e6528579a fix(test): remove tests for daemon infrastructure removed in b3decc26
The daemon removal (w-bd-001) deleted IsDaemonManaged, GasTownPort,
HasGasTownPathSegment, isGasTownRoot, and walkUpForGasTownRoot but
left tests referencing them, causing CI build failures on all branches.

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-03-05 14:34:16 -08:00
Steve Yegge
a040a4bd5c
Merge pull request #2356 from fryz/wasteland/w-bd-001-remove-daemon
feat(bd): remove daemon infrastructure
2026-03-05 13:21:52 -08:00
beads/crew/emma
c6e41803a5 fix(dolt): idle-monitor single-instance lock, port config isolation, project UUID verification (GH#2367, GH#2372)
Three P1 fixes for the Dolt server stabilization epic (bd-109c):

1. Idle-monitor single-instance enforcement (GH#2367): RunIdleMonitor now
   acquires an exclusive file lock at startup. If another monitor is already
   running, the new one exits immediately. This prevents the accumulation
   bug where Start() called from within the monitor watchdog would fork
   additional monitors (one per minute, ~32MB each).

2. Port config isolation (GH#2372): The port file (dolt-server.port, now
   gitignored) is elevated to primary source for port resolution, ahead of
   metadata.json and config.yaml which are git-tracked and can propagate
   to collaborators. metadata.json DoltServerPort emits a deprecation
   warning when used.

3. Client-side project identity verification (GH#2372): bd init now generates
   a UUID stored in both metadata.json (project_id) and the database metadata
   table (_project_id). On every store open, these are compared. A mismatch
   means the client is connected to the wrong projects Dolt server and the
   connection is refused with a clear diagnostic message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 11:44:09 -08:00
EC2 Default User
b3decc2659 feat(bd): remove daemon infrastructure (w-bd-001)
Remove daemon/RPC subsystem and Gas Town detection heuristics from beads.
The daemon functionality has been superseded by Gas Town's deacon/daemon system.

Removed:
- IsDaemonManaged/IsDaemonManagedFor and Gas Town detection functions
- GasTownPort constant and GT_ROOT-based server directory resolution
- Daemon PID file checks in IsRunning, reclaimPort, KillStaleServers
- Daemon guard in Stop/StopWithForce
- Gas Town bypass in forkIdleMonitor and RunIdleMonitor
- Python bd_daemon_client.py RPC client and test_daemon_health_check.py
- Python test_multi_repo.py daemon integration test
- Daemon socket preference in create_bd_client
- Daemon client cleanup tracking in MCP server
- Daemon-related gitignore patterns and doctor fix ordering

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 20:22:28 +00:00