fix(daemon): add sync-branch guard to daemon code paths (#1271)

* fix(daemon): skip export when sync-branch matches current

Prevent redundant export operations by checking if the daemon's sync
branch matches the current active branch.

Previously, the daemon would attempt to perform an export even when
already on the target branch. This logic now skips the export step in
such cases to avoid unnecessary overhead and potential conflicts.
Includes a new integration test to verify the guard logic.

* fix(daemon): prevent sync on guarded branches

Add checks to verify if a branch is guarded before performing automated
sync cycles, auto-imports, or branch-specific commit and pull operations.
This prevents the daemon from modifying protected branches or running
synchronization tasks where they are restricted.

Includes comprehensive integration tests to verify the guard logic
during sync-branch operations.

* fix(daemon): warn on sync branch misconfiguration at startup

The daemon now checks for sync branch name conflicts during its startup
loop. This provides early feedback if the sync branch is configured
in a way that might conflict with existing branches or other settings.

The warnIfSyncBranchMisconfigured function performs the validation
and logs a warning to the console. Integration tests verify that
the daemon correctly identifies and reports these misconfigurations
at initialization.
This commit is contained in:
Peter Chanthamynavong
2026-01-24 17:10:08 -08:00
committed by GitHub
parent b7d650bd8e
commit dbd505656d
4 changed files with 1162 additions and 2 deletions

View File

@@ -529,6 +529,13 @@ func runDaemonLoop(interval time.Duration, autoCommit, autoPush, autoPull, local
log.Warn("repository mismatch ignored (BEADS_IGNORE_REPO_MISMATCH=1)")
}
// GH#1258: Warn at startup if sync-branch == current-branch (misconfiguration)
// This is a one-time warning - per-operation skipping is handled by shouldSkipDueToSameBranch()
// Skip check in local mode (no sync-branch is used)
if !localMode {
warnIfSyncBranchMisconfigured(ctx, store, log)
}
// Validate schema version matches daemon version
versionCtx := context.Background()
dbVersion, err := store.GetMetadata(versionCtx, "bd_version")