* fix(bd): canonicalize actor==assignee comparisons in unclaim.go and AuthorizeAssigneeTransferWithPools
Follow-up to ga-wzl83, which canonicalized the two pure-Go validators in
internal/validation/issue.go but explicitly left out two higher-risk sites.
UnclaimIssueInTx / UnclaimIssueIfAssigneeInTx compared actor/expectedAssignee
to the stored assignee verbatim, both in a Go-side precheck AND in the SQL
UPDATE's WHERE clause -- so canonicalizing only the Go side would not have
fixed `bd unclaim` end-to-end. Replaced the `assignee = ?` SQL predicate with
a `row_lock = ?` CAS against the RowVersion read moments earlier: every
ownership/status/started_at mutation always rewrites row_lock (the documented
freshRowLock invariant in lease.go), so this detects the exact same race the
old predicate did -- and more (status/started_at races too) -- without
embedding a spelling-sensitive string comparison in SQL.
AuthorizeAssigneeTransferWithPools (the single fence both the DBTX and
unit-of-work backends evaluate, per its own doc comment) compared
before.Assignee to request.Actor and to request.Patch.Assignee.Value
verbatim, so a caller naming the current holder under a different layer's
identity spelling was wrongly fenced as a stranger.
Both fixes reuse the canonicalActor/actorMatches shape from ga-wzl83, kept as
a small package-local duplicate in issueops (internal/storage/issueops
importing internal/validation would invert the layering).
Verified: new cross-spelling cases in aggregate_authorize_transfer_test.go
and new end-to-end cases in unclaim_embedded_test.go /
unclaim_conditional_embedded_test.go (against a real embedded Dolt backend)
all fail with the exact bug-report symptom against the pre-fix code and pass
after the fix, with no regressions in the existing suites.
ga-5ksp5
* fix(bd): close the sibling-CAS disagreement gate review flagged on #5439
Review verdict on #5439 was "MERGE AFTER ONE FIX": after this branch's
unclaim.go/aggregate.go fix, bd unclaim --if-assignee succeeds under a
respelled identity while bd update --expected-assignee on the same bead
still fails ErrAssigneeMismatch — the same verbatim actor==assignee defect
(ga-wzl83), left in two more places.
- internal/storage/issueops/update_cas.go:46 (CheckExpectedFieldsInTx) now
compares under actorMatches (package-local, unexported — same package as
identity.go, no new import needed).
- internal/storage/domain/issue.go:643 (ApplyUpdate, the unit-of-work twin)
now compares under validation.ActorMatches. domain cannot import
internal/storage/issueops (issueops already imports domain in several
files — the reverse would cycle), but domain -> internal/validation is
safe (validation depends only on internal/types), so this reuses the
already-shipped validation copy instead of adding a third duplicate.
Two non-blocking asks from the same review, addressed:
- Exported internal/validation's canonicalActor/actorMatches to
CanonicalActor/ActorMatches so domain/issue.go could reuse them (the
reviewer's own point: "an issueops -> validation import creates no
cycle... layering inversion is a style call, not a compile fact" applies
equally to domain -> validation). Also fixed a garbled mid-sentence doc
comment on ActorMatches while touching the file (separate nit from the
same review, on #5438).
- Added a cross-package parity test
(internal/storage/issueops/identity_parity_test.go) that runs the
existing CanonicalActor/ActorMatches case tables through both this
package's local duplicate and validation's exported version, so the two
copies can't silently drift. Mutation-tested: dropped the hyphen
separator from issueops's copy, confirmed the two hyphen-related cases
correctly fail, reverted.
New conformance test (backend/conformance, wired into all three backend
legs) proves the fix end-to-end: an ExpectedAssignee guard now accepts a
different spelling of the current holder and still refuses a genuinely
different identity. Added as a SEPARATE function rather than extending the
existing RunIssueOperationsUpdateConditionalGuardsGateOrdinaryEdits — that
test's later "order-dependent composition" arm depends on the row's
assignee staying exactly "holder" through to the end, which a mid-test
respelling would have broken.
Verification: internal/validation, internal/storage/issueops,
internal/storage/domain(+db,fs,git) all green. New conformance test passes
on embeddeddolt and uow (dolt backend skips locally, no Docker — matches
the existing documented limitation, CI covers it). Broader regression
subset (Update/Claim/Unclaim, 28 embeddeddolt + 22 uow cases) green, no
regressions. go build/vet/gofmt clean.
Filed ga-4ymii for the reviewer's second (also non-blocking) ask: the
remaining verbatim sites at issueops/claim.go (SQL CAS + idempotent
re-claim), its domain/db and domain/issue.go uow twins, and
issueops/lease.go's heartbeat holder check — out of scope for this PR per
the reviewer's own framing ("please file the follow-up").
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(bd): dispatch the respelled-assignee contract case onto the role seam
TestRoleContractCasesCoverEveryContractCase (main, post-dating this branch's
fork point) caught a real gap: the ga-5ksp5 contract case added to this
branch's earlier commit (RunIssueOperationsUpdateConditionalGuardAccepts-
RespelledAssignee) had no roleContractCases dispatch row, so an external
backend running RunRoleContracts would never see it.
The reason isn't a missed row so much as the whole RunIssueOperationsUpdate*
family this case was written beside having been renamed and moved to
RunLifecycleUpdate* in backend/conformance/lifecycle_update_contract.go by
main's "de-stage the hard Lifecycle contracts onto the role seam" refactor,
which landed on main after this branch forked. Ported the case to match:
same logic, adapted to the new fixture's idioms (fixture.Lifecycle.Update
instead of fixture.Operations.Update, lifecycleUpdateRow(...).Priority
instead of a raw SQL assertion, storage.ErrAssigneeMismatch instead of
publicops.ErrAssigneeMismatch, seedLifecycleUpdateIssue instead of
seedClosePolicyIssue) — not a mechanical copy. Also wired it into the three
per-backend TestLifecycleUpdateContract dispatch lists (dolt, embeddeddolt,
uow) beside its ConditionalGuardsGateOrdinaryEdits sibling, so it actually
runs against real backends rather than only satisfying the completeness
guard.
Verified: TestRoleContractCasesCoverEveryContractCase passes; the ported
case passes against embeddeddolt (0.35s) and uow (0.17s) for real, not just
compiles (dolt backend test skips in this sandbox — no Docker); full
backend/conformance suite and repo build clean.
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>