@startuml images/02-01_activity.png
title Image 2.1: Audit Job Merge SystemMetadata

note top:  “The SystemMetadata Merge Rule declares that  the highest serial version establishes the ascendant revision of the SystemMetadata.\nOnly if the SerialVersions are equal will the most recent dateSystemMetadataModified date be used”
(*)-right-> if "Are all serialVersions equal?" then
         ->[yes]"Set Record with Most Recent dateSysMetadataModified as ascendant revision"
         -down-> ===ARCHIVED===
       else
         -down->[no]"Set Record with Highest SerialVersion as ascendant revision"
         -right-> ===ARCHIVED===
       endif
===ARCHIVED=== -down-> if "Is any record archived?" as archived then
         -right->[yes] "Set archive flag on ascendant revision"
         -down-> ===UPDATED===
        else
         -down->[no] ===UPDATED===
         endif

===UPDATED=== -down-> if "Is any record updated?"  then
              -left->[yes] "set obsoleted/obsoletedBy element on ascendant revision"
              -down-> ===REPLICATION===
            else
              -down->[no] ===REPLICATION===
            endif
===REPLICATION=== -down-> if "Is replication Policy Info Set?" as replication then
          note left:  “We only check replication and replica # for this fix.\nAny daemon code will have to accept\nthe ascendant revision's replica Allowed and replica #"
          -right->[yes] "On accendant revision, Set replication\nallowed if set true on any revision\ninstance. Set Number of Replicas to\nhighest Number from any revision instance\n"
          -right->"Merge Preferred Member Node List and\nBlocked Member Node List. So long\nas there are no conflicts betwen Preferred\nand Blocked List. If Conflicts, then use\nAscendant revisions lists. Preferred list\nmust maintain original order"
          -down->  ===MERGE_REPLICA_LIST===
        else
          -down->[no] ===MERGE_REPLICA_LIST=== 
        endif
 ===MERGE_REPLICA_LIST=== -down-> "Merge Replica List"
note right:  “Merge all replicas. Remove Duplicates of MN/CN replica targets\nChoose the most recent Date Verified for definitive replica.\nIf replicas found with differing replica status,\nchoose highest order of Invalidate>Complete>Failed."
-down->"accept Access Policy from ascendant revision"
-down->"accept Rights Holder from ascendant revision"
-->(*)
note left:  “How do we determine deletes?"
@enduml