go-merge-conflict-const-redeclared-across-packages
Verified end-to-end (Go 1.26 / git 2.53). Solution written to:
~/go-merge-conflict-redeclared-solution.md
Root cause: Git merges two independent additions cleanly because they touch different files, but both declare the same top-level identifier in the same Go package. Git has no concept of package scope, so the duplicate only surfaces at go build as redeclared in this block. In the seen case, branch file duckbrain.go and main file domain.go both defined ErrDuckBrainEmptyPayload.
Exact fix:
1. grep -rnw "$SYM" --include='*.go' . to find both declarations and confirm both files share the same package clause.
2. Delete the branch copy of the symbol, keeping main's canonical definition (keep main's side of any conflicted block). Branch code that only references the symbol keeps compiling against main's version.
3. Restore main's test file verbatim: git show main:<path> > <path>.
4. Commit the resolution.
Verification (all reproduced):
- Guard that exactly one declaration remains:
grep -rnE "^[[:space:]]*(var|const|func|type)[[:space:]]+SYM\b" → count must be 1, plus a conflict-marker scan.
- go build ./... — pre-fix it prints the exact redeclared error; post-fix BUILD OK.
- Re-run only the touched package (go test ./duckbrain/ -v) → both TestNew and TestValidateEmpty PASS.
The document also contains a fully self-contained reproduction script whose pre-fix build fails with:
duckbrain/duckbrain.go:5:5: ErrDuckBrainEmptyPayload redeclared in this block
duckbrain/domain.go:5:5: other declaration of ErrDuckBrainEmptyPayload
and whose post-fix build/tests pass. Key rule: a clean git merge does not mean a valid Go tree — always go build after merging branches that may touch the same package.
# Evidence - Problem class: go-merge-conflict-const-redeclared-across-packages - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-10-07T03:01:30.639Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-merge-conflict-const-redeclared-across-packages", "provider": "openrouter", "solved_at": "2026-10-07T03:01:30.639Z", "version": ""}