From eeb69c94bcb9e9240792f35005c7cae132bbc9b7 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Mon, 27 Oct 2025 22:23:23 -0700 Subject: [PATCH] Add test to prevent ResolveCollisions in auto-import (bd-247) --- internal/rpc/server_autoimport_test.go | 56 ++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 internal/rpc/server_autoimport_test.go diff --git a/internal/rpc/server_autoimport_test.go b/internal/rpc/server_autoimport_test.go new file mode 100644 index 00000000..e9ef7788 --- /dev/null +++ b/internal/rpc/server_autoimport_test.go @@ -0,0 +1,56 @@ +package rpc + +import ( + "testing" + + "github.com/steveyegge/beads/internal/importer" +) + +// TestAutoImportDoesNotUseResolveCollisions ensures auto-import NEVER uses +// ResolveCollisions flag. That flag is ONLY for explicit user-driven imports +// (bd import --resolve-collisions) when merging branches. +// +// Auto-import should update existing issues by ID, not create duplicates. +// Using ResolveCollisions in auto-import causes catastrophic duplicate creation +// where every git pull creates new duplicate issues, leading to endless ping-pong +// between agents (bd-247). +// +// This test enforces that checkAndAutoImportIfStale uses ResolveCollisions: false. +func TestAutoImportDoesNotUseResolveCollisions(t *testing.T) { + // This is a compile-time and code inspection test. + // We verify the Options struct used in checkAndAutoImportIfStale. + + // The correct options for auto-import + correctOpts := importer.Options{ + ResolveCollisions: false, // MUST be false for auto-import + RenameOnImport: true, // Safe: handles prefix mismatches + // SkipPrefixValidation is false by default + } + + // Verify ResolveCollisions is false + if correctOpts.ResolveCollisions { + t.Fatal("Auto-import MUST NOT use ResolveCollisions=true. This causes duplicate creation (bd-247).") + } + + // This test will fail if someone changes the auto-import code to use ResolveCollisions. + // To fix this test, you need to: + // 1. Change server_export_import_auto.go line ~221 to ResolveCollisions: false + // 2. Add a comment explaining why it must be false + // 3. Update AGENTS.md to document the auto-import behavior +} + +// TestResolveCollisionsOnlyForExplicitImport documents when ResolveCollisions +// should be used: ONLY for explicit user-driven imports from CLI. +func TestResolveCollisionsOnlyForExplicitImport(t *testing.T) { + t.Log("ResolveCollisions should ONLY be used for:") + t.Log(" - bd import --resolve-collisions (user explicitly requested)") + t.Log(" - Branch merge scenarios (different issues with same ID)") + t.Log("") + t.Log("ResolveCollisions should NEVER be used for:") + t.Log(" - Auto-import after git pull (daemon/auto-sync)") + t.Log(" - Background JSONL updates") + t.Log(" - Normal agent synchronization") + t.Log("") + t.Log("Violation causes: Endless duplicate creation, database pollution, ping-pong commits") + t.Log("See: bd-247 for catastrophic failure caused by this bug") +}