* fix(init): verify refs/dolt/data before remote-history refusal
bd init --reinit-local refused solely because sync.remote was set,
claiming the remote had Dolt history without checking refs/dolt/data.
Git remotes with only ordinary branches tripped a false positive and
stranded workspaces with no way to set issue-prefix (GH#4861).
Probe gitRemoteHasDoltDataRef for configured sync.remote in both early
and late safety checks; re-probe on confirmation callbacks.
Fixes#4861
* fix(init): tri-state the refs/dolt/data probe so a failed check refuses
gitRemoteHasDoltDataRef collapsed "no refs/dolt/data" and "could not ask"
(timeout, DNS, credential refusal) into the same false, so a probe
failure silently fell through ADR-0002's refusal gate instead of
tripping it. Add gitRemoteHasDoltDataRefStatus / gitOriginHasDoltDataRefStatus
returning (bool, error), and route all four init.go call sites (both the
new sync.remote probe from GH#4861 and the two pre-existing git-origin
probes) through resolveRemoteHasDoltDataProbe, which treats a probe error
as UNKNOWN and fails closed (refuse) rather than open. The confirmation
re-probe in handleRemoteSafetyDecision now treats a probe error as
"unchanged" too, so only a genuine true->false transition aborts —
a transient network blip no longer spuriously kills a confirmed
--discard-remote flow.
Replace TestCheckRemoteSafety_ConfiguredRemoteWithoutDoltData, which
called the pure CheckRemoteSafety directly and passed whether or not
init.go actually probed anything, with a caller-level regression test:
bd init --reinit-local against a real bare-repo sync.remote, with and
without a pushed refs/dolt/data ref.
Also restore the "Remote has no Dolt data yet; initialized a fresh local
database" message on the configured-remote/no-history path, which the
GH#4861 fix silently dropped by skipping cloneFromRemoteWithMode.
Addresses maphew's review on #5136.
* test(init): make the sync.remote regression test hermetic
BD_SYNC_REMOTE works (viper AutomaticEnv maps BD_-prefixed vars to config
keys, config.go:165-169 — confirmed empirically via `bd config get
sync.remote`), but the test relied on the inherited environment: any
ambient ~/.beads/config.yaml, ~/.config/bd/config.yaml, or stray BD_*/
BEADS_* var on the machine running the test could leak in unnoticed.
Add hermeticInitEnv: strips inherited BD_*/BEADS_* vars and points HOME
at an isolated tempdir (distinct from workDir — metrics.go caches to
$HOME/.beads/eventsData, which collides with the project .beads/ this
test asserts on if HOME == workDir).
Verified under `env -i` with an isolated HOME/XDG_CONFIG_HOME and no
inherited env: without BD_SYNC_REMOTE, init succeeds; with it pointed at
a Dolt-data-free bare repo, only the pre-#4861-fix binary refuses (the
actual bug); with it pointed at a repo with pushed refs/dolt/data, both
pre- and post-fix binaries correctly refuse.