beads/cmd/bd/dolt_autocommit_config.go
obsidian 836835d8f6 feat: add batch auto-commit mode for Dolt to reduce commit bloat
Add a "batch" auto-commit mode that defers DOLT_COMMIT until logical
boundaries (bd sync, bd dolt commit) instead of creating a commit after
every bd CLI invocation. This addresses the 49K commit bloat problem
reported by the Dolt team.

Changes:
- Add doltAutoCommitBatch mode alongside existing on/off modes
- Change embedded mode default from "on" to "batch"
- Add CommitPending method to DoltStore that generates descriptive
  summary messages by querying dolt_diff (e.g. "3 created, 2 updated")
- Wire batch commit into bd sync and bd dolt commit
- Update existing tests and add new tests for batch mode

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

Executed-By: beads/polecats/obsidian
Rig: beads
Role: polecats
2026-02-21 12:14:31 -08:00

33 lines
863 B
Go

package main
import (
"fmt"
"strings"
)
type doltAutoCommitMode string
const (
doltAutoCommitOff doltAutoCommitMode = "off"
doltAutoCommitOn doltAutoCommitMode = "on"
doltAutoCommitBatch doltAutoCommitMode = "batch"
)
func getDoltAutoCommitMode() (doltAutoCommitMode, error) {
mode := strings.TrimSpace(strings.ToLower(doltAutoCommit))
if mode == "" {
// Default resolved at store-creation time in main.go based on server mode.
// If still empty here, fall back to off (safe default).
mode = string(doltAutoCommitOff)
}
switch doltAutoCommitMode(mode) {
case doltAutoCommitOff:
return doltAutoCommitOff, nil
case doltAutoCommitOn:
return doltAutoCommitOn, nil
case doltAutoCommitBatch:
return doltAutoCommitBatch, nil
default:
return "", fmt.Errorf("invalid --dolt-auto-commit=%q (valid: off, on, batch)", doltAutoCommit)
}
}