Actually I was thinking of changing *all* first-level keys to use the object's object_id, though that's not what I said :) Changing to this scheme would fix the null context_id problem automatically, that's what I'm thinking.
So your A,B,C nodes would all have their object_id as their first-level sortkey ...
Now doing the update may still be difficult because update's in PG aren't (logically) atomic so you can have unique constraint errors generated mid-update so any update script has to be very careful, I don't think you can just do one big UPDATE statement.
But this is the most attractive solution I've been able to think of ...