How Nomad knows internally about the allocation status of job (Running, Failed, Queued, Starting, Complete, Lost)?

Hi team, we can see about the allocation status of a job in nomad UI / command line. but how nomad finds whether a job is running or it failed or it completed ? Basically want to know how nomad figure out about allocation status.