From 73cad50db2d495e404a497852f59f86b41bd9762 Mon Sep 17 00:00:00 2001 From: Daniel Hanold Date: Thu, 22 Oct 2026 17:53:01 -0400 Subject: [PATCH 1/2] Add design spec: Fix duplicate originHasBranch breaking combined-tag go vet --- ...nch-breaking-combined-tag-go-vet-design.md | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 docs/superpowers/specs/2026-10-22-fix-duplicate-originhasbranch-breaking-combined-tag-go-vet-design.md diff --git a/docs/superpowers/specs/2026-10-22-fix-duplicate-originhasbranch-breaking-combined-tag-go-vet-design.md b/docs/superpowers/specs/2026-10-22-fix-duplicate-originhasbranch-breaking-combined-tag-go-vet-design.md new file mode 100644 index 000000000..4bd9e9a8b --- /dev/null +++ b/docs/superpowers/specs/2026-10-22-fix-duplicate-originhasbranch-breaking-combined-tag-go-vet-design.md @@ -0,0 +1,42 @@ +# Fix duplicate originHasBranch breaking combined-tag go vet — design + +Change 0577 — Fix duplicate originHasBranch breaking combined-tag go vet + +## Why + +`go vet -tags integration,e2e ./...` fails to compile the `internal/app` test package with one error, `originHasBranch redeclared in this block`. Two test helpers in that package share the name, each behind a different build tag: + +- `internal/app/finalize_e2e_test.go` (`//go:build e2e`) declares `originHasBranch(t, origin, branch)`. It takes a short branch name (`feat/x`), probes `refs/heads/` with `tryGit`, and treats any git error as "absent". All five callers are in that file. +- `internal/app/leak_check_private_integration_test.go` (`//go:build integration`, added 2026-10-06 with the private-mode leak check) declares `originHasBranch(t, origin, ref)`. It takes a full ref (`refs/heads/feat/x`), probes it with `for-each-ref`, and fails the test on any probe error other than a missing ref. Its sibling `originRefTip` and the leak-check tests in that file call it, and so does `internal/app/finalize_cleanup_integration_test.go`. + +Each tag compiles fine on its own, and the suite only ever vets them separately: `tests/test_go_finalize_e2e.sh` runs `go vet -tags e2e ./internal/app/`, and `tests/test_go_integration_contract.sh` runs `go vet -tags integration` over the integration packages. No suite row, CI workflow, editor config, or doc runs both tags together. The clash was found by a reviewer who ran the combined vet by hand, and it was recorded as a known issue. The harm is small, but anyone who vets both tags together hits a compile error that has nothing to do with their work. + +The integration helper is also misnamed: it checks a ref, not a branch. + +## Design (decided at grooming) + +Rename the integration-tag helper from `originHasBranch` to `originHasRef`, at its declaration and at every caller, and update its doc comment to the new name. The e2e helper keeps its name and its behavior. No behavior changes, no new file, and no shared helper. + +Find the callers with a grep for the identifier across `internal/app`'s integration-tagged files, not from the list above. At grooming they were the declaration, `originRefTip`, and the leak-check tests in `leak_check_private_integration_test.go`, plus one call in `finalize_cleanup_integration_test.go`. + +Grooming checked the rename with `go vet -overlay` on renamed copies of the two integration files, leaving the tree untouched. With both tags, vet passed on `./internal/app/` and on `./...`. It also passed with each tag alone, and the combined run reported no other error. + +The check that fails before the fix is the combined vet itself. No new test file is needed. + +## Acceptance + +- `go vet -tags integration,e2e ./...` exits 0. +- `go vet -tags integration ./internal/app/` and `go vet -tags e2e ./internal/app/` still exit 0. +- `internal/app` declares `originHasBranch` exactly once, in `finalize_e2e_test.go`. +- The whole suite (`build.test_command`) passes. +- The results file's verification section records the combined-vet run as the one-time proof. + +## Non-goals + +- **No new suite check or CI step for the combined tags (decided at grooming).** Nothing runs both tags together, so a guard would turn a harmless future clash into a failed build. A future clash gets found the same way this one was. +- **No shared helper (decided at grooming).** The two helpers stay separate, and the e2e helper keeps treating probe errors as "absent". Unifying them means more churn for a risk the e2e test setup already catches. +- No other renames or cleanups in these test files. + +## Left to the builder + +- The exact wording of the renamed helper's doc comment. From 0d1190aabbf4603d34ed2b1e6a2ba3322ad2102c Mon Sep 17 00:00:00 2001 From: Daniel Hanold Date: Thu, 22 Oct 2026 17:54:39 -0400 Subject: [PATCH 2/2] fix: rename integration-tag originHasBranch to originHasRef so combined-tag vet compiles --- internal/app/finalize_cleanup_integration_test.go | 2 +- .../app/leak_check_private_integration_test.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/app/finalize_cleanup_integration_test.go b/internal/app/finalize_cleanup_integration_test.go index 089cda88d..27c8c84c0 100644 --- a/internal/app/finalize_cleanup_integration_test.go +++ b/internal/app/finalize_cleanup_integration_test.go @@ -982,7 +982,7 @@ func TestIntegrationFinalizeCleanupResultsArtifactRealGit(t *testing.T) { runGit(t, lw.wp, "push", "-q", "origin", "HEAD:"+lw.featureRef) deps := completeLeakWorkspace(t, lw, repo.meta, m.branch, recPath) assertResultsArtifactCleaned(t, lw, deps) - if !originHasBranch(t, lw.origin, lw.featureRef) { + if !originHasRef(t, lw.origin, lw.featureRef) { t.Fatalf("cleanup of a completed change must never delete a remote branch") } } diff --git a/internal/app/leak_check_private_integration_test.go b/internal/app/leak_check_private_integration_test.go index 9115a65f0..6ba8e9de7 100644 --- a/internal/app/leak_check_private_integration_test.go +++ b/internal/app/leak_check_private_integration_test.go @@ -185,10 +185,10 @@ func resetWorkspace(t *testing.T, wp, commit string) { runGit(t, wp, "reset", "-q", "--hard", commit) } -// originHasBranch reports whether the bare origin carries ref. A probe that +// originHasRef reports whether the bare origin carries ref. A probe that // fails for any reason other than an absent ref fails the test, so an // unreadable origin never reads as "absent". -func originHasBranch(t *testing.T, origin, ref string) bool { +func originHasRef(t *testing.T, origin, ref string) bool { t.Helper() out := runGit(t, origin, "for-each-ref", "--format=%(refname)", ref) return out == ref @@ -197,7 +197,7 @@ func originHasBranch(t *testing.T, origin, ref string) bool { // originRefTip returns ref's commit on the bare origin, failing when absent. func originRefTip(t *testing.T, origin, ref string) string { t.Helper() - if !originHasBranch(t, origin, ref) { + if !originHasRef(t, origin, ref) { t.Fatalf("origin lacks %s", ref) } return runGit(t, origin, "rev-parse", ref) @@ -275,7 +275,7 @@ func TestIntegrationPrivateModeLeakCheckBlocksSeededLeaks(t *testing.T) { resetWorkspace(t, lw.wp, lw.specCommit) head := commitInWorkspace(t, lw.wp, tc.msg, tc.files) requireLeakRefusal(t, lw.publish(t, head), tc.want(head)) - if originHasBranch(t, lw.origin, lw.featureRef) { + if originHasRef(t, lw.origin, lw.featureRef) { t.Errorf("a refused publish left %s on origin", lw.featureRef) } }) @@ -295,7 +295,7 @@ func TestIntegrationPrivateModeLeakCheckBlocksSeededLeaks(t *testing.T) { if !strings.Contains(pub.Message, shortCommit(added)) { t.Errorf("refusal message does not name the adding commit %s: %q", shortCommit(added), pub.Message) } - if originHasBranch(t, lw.origin, lw.featureRef) { + if originHasRef(t, lw.origin, lw.featureRef) { t.Errorf("a refused publish left %s on origin", lw.featureRef) } }) @@ -429,7 +429,7 @@ func TestIntegrationPrivateModeLeakCheckUnverifiedPushesNothing(t *testing.T) { t.Fatalf("publish of an unscannable head = %q/%q (msg %q), want %s/%s", pub.Result, pub.Reason, pub.Message, ResultExternalFailed, ReasonLeakCheckUnverified) } - if originHasBranch(t, lw.origin, lw.featureRef) { + if originHasRef(t, lw.origin, lw.featureRef) { t.Errorf("an unverified scan still pushed %s to origin", lw.featureRef) } } @@ -450,7 +450,7 @@ func TestIntegrationPrivateModeLeakCheckScansBranchName(t *testing.T) { head := commitInWorkspace(t, lw.wp, "Tidy the alias table", map[string]string{"aliases.txt": "tidy\n"}) requireLeakRefusal(t, lw.publish(t, head), LeakHit{Source: "branch-name", Text: "dckt", Rule: "alias"}) - if originHasBranch(t, lw.origin, lw.featureRef) { + if originHasRef(t, lw.origin, lw.featureRef) { t.Errorf("a refused publish left %s on origin", lw.featureRef) } }