* feat(unclaim): add --if-assignee conditional release (CAS inverse of claim)
bd has an atomic compare-and-swap on the claim side (ClaimIssueInTx:
UPDATE ... WHERE assignee = '' with RowsAffected as the verdict) but no
inverse on the release side. The concurrency audit flagged this as the
conditional-release gap: a supervisor returning a dead worker's issue
(e.g. gas city's orphan release) can only do read-then-unclaim, a TOCTOU
window in which the claim may be reclaimed and re-taken by another worker
-- the stale releaser then silently clobbers the live claim. The only
atomic workaround was raw `bd sql`, which is neither portable nor part of
the CLI contract.
This adds `bd unclaim --if-assignee <who>`, backed by a new
Storage.UnclaimIssueIfAssignee that reuses the claim-side CAS idiom:
UPDATE ... WHERE id = ? AND assignee = ? in the same mutation tx,
returning typed storage.ErrAssigneeMismatch (naming the current holder)
and leaving the row untouched when the holder differs. On success it
applies the same transition as an ordinary unclaim (assignee cleared,
status reopened, started_at cleared, lease dropped, row_lock rewritten,
"unclaimed" event recorded). Wired through the shared issueops helper and
both storage backends (Dolt server and embedded Dolt), and instrumented
in telemetry. Covered by storage conformance cases (match + stale) and an
end-to-end CLI test.
Adopted onto current main via the /adopt-pr workflow: the original PR
predated the storage refactor that removed the sqlkit/SQLite/MySQL/Postgres
backends, so the change was re-expressed against the current Dolt-only
Storage interface (which had also gained unclaim's force flag), dropping
the now-obsolete per-backend "unsupported" wiring.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(unclaim): reject empty --if-assignee and conflicting --force
Review (attempt 1) found the CLI selected the conditional compare-and-swap
release on `ifAssignee != ""`, so an explicitly empty `--if-assignee ""` (an
unset variable expanded into the flag) silently fell back to an
unconditional, --force-capable release, and `--force`/`--if-assignee` could
be combined with one flag silently winning.
Dispatch on cmd.Flags().Changed("if-assignee") instead, reject an explicitly
empty expected assignee before processing any IDs, and mark --force and
--if-assignee mutually exclusive. Update the command help to state the
contract and add CLI regression tests for the empty-value and combined-flag
cases (both run as the holder, so the pre-fix behavior would have released
the claim).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: extend embedded conformance timeout
---------
Co-authored-by: Test User <test@test.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>