How does the JaVaFo engine work and how random are the pairings? In most official FIDE tournaments, the JaVaFo engine is used to pair the players according to some FIDE-defined rules. What are those rules and how random are the pairings (i.e. can I reproduce them locally)?
What are those rules?

The rules are defined in the FIDE document C.04.1 Basic rules for Swiss Systems.

C.04.1 Basic rules for Swiss Systems
The following rules are valid for each Swiss system unless explicitly stated otherwise.
a The number of rounds to be played is declared beforehand.
b Two players shall not play against each other more than once.
c Should the number of players to be paired be odd, one player is unpaired. This player receives a pairing-allocated bye: no opponent, no colour and as many points as are rewarded for a win, unless the rules of the tournament state otherwise.
d A player who has already received a pairing-allocated bye, or has already scored a (forfeit) win due to an opponent not appearing in time, shall not receive the pairing-allocated bye.
e In general, players are paired to others with the same score.
f For each player the difference between the number of black and the number of white games shall not be greater than 2 or less than –2.
Each system may have exceptions to this rule in the last round of a tournament.
g No player shall receive the same colour three times in a row.
Each system may have exceptions to this rule in the last round of a tournament.
h 1 In general, a player is given the colour with which he played less games.
h 2 If colours are already balanced, then, in general, the player is given the colour that alternates from the last one with which he played.
i The pairing rules must be such transparent that the person who is in charge for the pairing can explain them.

Rgearding:

how random are the pairings?

They must be completely non-random. According to C.04.2 General handling rules for Swiss Tournaments

The Swiss Pairing Systems defined by FIDE and not deprecated (see C.04.4) pair the players in an objective, impartial and reproducible way.
In any tournament where such systems are used, different arbiters, or different endorsed software programs, must be able to arrive at identical pairings.