Enforce idempotency and prevent concurrent Ontology Actions from overwriting each other

Is there a recommended way to enforce idempotency and prevent concurrent Ontology Actions from overwriting each other when both read the same initial object state?

I need a non-primary-key property on Object B to be unique, but the Ontology doesn’t enforce that (from what I see). rn I am considering adding objectBId to related Object A, then using a TypeScript V2 function to create Object B and set ObjectA.objectBId in the same Action (to enforce a 1:1).

What I am wondering is, if two Actions concurrently see ObjectA.objectBId as empty, one tries to create B1 and the other B2. Will OSv2 guarantee that only one Action succeeds and fully roll back the loser, or could both B1 and B2 be created while Object A ends up pointing to whichever update was written last?

In other word, what I am worried about with this solution of solving a race case:

Action A: set ObjectA.objectBId = B1
Action B: set ObjectA.objectBId = B2

But what I want to happen is

Action A: set ObjectA.objectBId = B1
Action B: tries to set ObjectA.objectBId = B2 -> but here it fails, or see theres a version conflict that I can catch, which then kicks off some remediation work