For jazz and rock, the principles appear to be phrasing and space, and to some degree, implied harmonic movement.
Since the underlying riff is not shifting around the harmony very much (it would produce an unpleasant vertigo effect), the melody can enter and exit when it chooses. But these choices define a larger rhythmic structure. Frenquently, the melody will take a short rest periodically to wait for the beat to turn around. The relative lengths of these rests with their associated melodic fragments evoke some degree of space.
Having no rests at all, especially when syncopated, so that the coda butts up flush to the next anacrusis, like a melodic ouroborous, produces a very closed space. If the melody is being sung, there is literally very little room to breathe. Conversely, long-rest lyrical codas, give a more open space, where the rhythm can be enjoyed more as a separate part (== rhythm must be interesting enough to stand on its own).
If the repeated riff has a sparse harmonic content, dyads or single-notes, then the melody can also make use of implied harmonic movement. For a bluesy minor pentatonic bassline, the melody can play as if a 12-bar blues or other form were being played, because the bassline is simple enough that it can be reinterpreted in the context of the implied chord/key.