{"record":{"id":"51aa4d05f15f4d91","repo":"gastownhall/beads","slug":"cannot-verify-unpushed-commits-no-comparison-targ","errorCode":null,"errorMessage":"cannot verify unpushed commits: no comparison target is available","messagePattern":"cannot verify unpushed commits: no comparison target is available","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/worktreeremove/policy.go","lineNumber":208,"sourceCode":"\t}\n\tif facts.Status != Clean && facts.Status != Dirty {\n\t\treturn Plan{}, fmt.Errorf(\"worktree cleanliness observation is absent or invalid\")\n\t}\n\tif facts.ManagedIgnore != IgnoreAbsent && facts.ManagedIgnore != IgnoreManaged {\n\t\treturn Plan{}, fmt.Errorf(\"managed ignore observation is absent or invalid\")\n\t}\n\tif (facts.ManagedIgnore == IgnoreManaged) != (facts.ManagedIgnoreEntry != \"\") {\n\t\treturn Plan{}, fmt.Errorf(\"managed ignore cleanup identity is absent or invalid\")\n\t}\n\tif request.Mode != Force {\n\t\tif facts.Status != Clean {\n\t\t\treturn Plan{}, fmt.Errorf(\"worktree contains modified, untracked, or ignored files\")\n\t\t}\n\t\tif facts.Comparator != ComparatorAvailable && facts.Comparator != ComparatorMissing && facts.Comparator != ComparatorNotRequired {\n\t\t\treturn Plan{}, fmt.Errorf(\"worktree comparison target observation is absent or invalid\")\n\t\t}\n\t\tif facts.Comparator != ComparatorAvailable {\n\t\t\treturn Plan{}, fmt.Errorf(\"cannot verify unpushed commits: no comparison target is available\")\n\t\t}\n\t\tif facts.Containment != Contained && facts.Containment != NotContained && facts.Containment != ContainmentNotRequired {\n\t\t\treturn Plan{}, fmt.Errorf(\"worktree containment observation is absent or invalid\")\n\t\t}\n\t\tif facts.Containment != Contained {\n\t\t\treturn Plan{}, fmt.Errorf(\"worktree HEAD is not contained in the comparison target\")\n\t\t}\n\t} else if facts.Comparator != ComparatorNotRequired || facts.Containment != ContainmentNotRequired {\n\t\treturn Plan{}, fmt.Errorf(\"worktree force-mode comparison observations are inconsistent\")\n\t}\n\tplan := Plan{approved: true, mode: request.Mode, targetPath: facts.RegisteredPath}\n\tif facts.ManagedIgnore == IgnoreManaged {\n\t\tplan.managedIgnoreEntry = facts.ManagedIgnoreEntry\n\t}\n\treturn plan, nil\n}\n\n// InvariantState is the adapter's raw observation of one independently","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/worktreeremove/policy.go#L190-L226","documentation":"Prepare rejects the request because mode is Normal and facts.Comparator is ComparatorMissing or ComparatorNotRequired — no comparison target (e.g. upstream branch) exists to prove the worktree HEAD was pushed. Removing could orphan commits, so the library fails closed.","triggerScenarios":"Calling Prepare with Mode: Normal while the worktree branch has no upstream / comparison ref (Comparator != ComparatorAvailable).","commonSituations":"A local-only branch that was never pushed; the remote branch was deleted; upstream not configured after cloning a single branch.","solutions":["Push the worktree branch to a remote (git push -u origin <branch>) so a comparison target exists","Push the worktree HEAD to a ref the comparator resolves, then retry","Use Force mode only if losing the commits is acceptable"],"exampleFix":"// before\nplan, err := worktreeremove.Prepare(req, facts) // Normal mode, Comparator == ComparatorMissing\n// after\n// git push -u origin <branch> in the worktree, re-observe facts, then:\nplan, err := worktreeremove.Prepare(req, facts)","handlingStrategy":"validation","validationCode":"if facts.Comparator != worktreeremove.ComparatorAvailable {\n\treturn fmt.Errorf(\"no upstream ref for %s; push or use Force\", facts.RegisteredPath)\n}","typeGuard":"func hasComparisonTarget(c worktreeremove.ComparatorKind) bool {\n\treturn c == worktreeremove.ComparatorAvailable\n}","tryCatchPattern":"plan, err := worktreeremove.Prepare(req, facts)\nif err != nil && strings.Contains(err.Error(), \"no comparison target is available\") {\n\treturn fmt.Errorf(\"push the branch (git push -u origin <branch>) or use Force: %w\", err)\n}","preventionTips":["Push worktree branches before removal workflows","Configure upstream tracking on new branches","Automate push-before-clean in CI scripts"],"tags":["worktree","git","unpushed-commits"],"backgroundTag":"unpushed-commits","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}