{"record":{"id":"e99783824ac34653","repo":"gastownhall/beads","slug":"comparison-ref-q-resolves-through-a-worktree-loca","errorCode":null,"errorMessage":"comparison ref %q resolves through a worktree-local ref namespace and cannot independently prove containment","messagePattern":"comparison ref %q resolves through a worktree-local ref namespace and cannot independently prove containment","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/worktree_cmd.go","lineNumber":1875,"sourceCode":"\t}\n\treturn true\n}\n\nfunc pinWorktreeComparatorRef(\n\tctx context.Context,\n\tgit *worktreeRemovalGit,\n\texecutionRoot string,\n\ttarget pinnedWorktreeTarget,\n\tselector string,\n\tref string,\n\texplicit bool,\n) (pinnedWorktreeComparator, error) {\n\tterminalRef, err := resolveWorktreeTerminalRef(ctx, git, executionRoot, ref)\n\tif err != nil {\n\t\treturn pinnedWorktreeComparator{}, err\n\t}\n\tif isWorktreeLocalRef(ref) || isWorktreeLocalRef(terminalRef) {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\n\t\t\t\"comparison ref %q resolves through a worktree-local ref namespace and cannot independently prove containment\",\n\t\t\tref,\n\t\t)\n\t}\n\tif ref == target.branch || terminalRef == target.branch {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\n\t\t\t\"comparison ref %q resolves to the target worktree branch and cannot independently prove containment\",\n\t\t\tref,\n\t\t)\n\t}\n\toid, err := resolveWorktreeCommitOID(ctx, git, executionRoot, ref)\n\tif err != nil {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\"comparison ref %q does not resolve to a commit: %w\", ref, err)\n\t}\n\treturn pinnedWorktreeComparator{\n\t\tselector:    selector,\n\t\texplicit:    explicit,\n\t\tref:         ref,","sourceCodeStart":1857,"sourceCodeEnd":1893,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/worktree_cmd.go#L1857-L1893","documentation":"A `--merged-into` ref must independently prove containment of the worktree HEAD. If the provided ref, or the ref it resolves to (terminal ref), lives in a worktree-local ref namespace (e.g. `refs/worktree/...` or `refs/bd/worktrees/...` per `isWorktreeLocalRef`), it is not independent evidence, so bd rejects it.","triggerScenarios":"Passing a ref whose name, or whose resolved terminal ref name, is inside a worktree-local namespace to `--merged-into`.","commonSituations":"Using bd-internal per-worktree refs generated by worktree management; copying a refname like `refs/worktree/<id>/HEAD` from bd output; scripting against internal namespaces.","solutions":["Use a shared repository ref such as `refs/heads/<branch>` or a remote-tracking ref like `origin/main`","Inspect what the selector resolves to with `git rev-parse --symbolic-full-name <ref>` and pick a non-worktree-local equivalent","Pass the full commit OID of the merged-into commit instead of the worktree-local ref"],"exampleFix":"// before\nbd worktree remove --merged-into refs/worktree/wt-7/main\n// after\nbd worktree remove --merged-into refs/heads/main","handlingStrategy":"validation","validationCode":"// shell pre-check: reject worktree-local namespaces\nfull=$(git rev-parse --symbolic-full-name \"$REF\" 2>/dev/null || true)\ncase \"$full\" in refs/worktree/*|refs/bd/*) echo \"$full is worktree-local\" ;; esac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only pass refs/heads/* or refs/remotes/* refs to --merged-into","Avoid scripting against bd-internal worktree ref namespaces","Resolve the terminal ref with `git rev-parse --symbolic-full-name` before passing it"],"tags":["git","refs","namespacing","containment-proof"],"backgroundTag":"worktree-local-ref","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}