On a few time scales you brain makes plans. It uses beliefs and a model of the world to make those plans. It stores those plans and the actions it has taken. And then checks if actions had their intended effects, and if plans reached their intended goals. Updating its model of the world, its beliefs, and what useful actions are.
This is a constant process reflecting upon the current situation, and upon the recent past of actions and plans. It is like an observer observing itself. This is the root of consciousness, I think.
Probably abstract thinking and language, enough intelligence, and a theory of mind, leads to self awareness.
If this is correct, we can formulate some necessary parts for a system to be conscious:
* recognition of the environment * a model of the environment * ability to reason about actions, their consequences, and how to achieve goals * memory of past plans and goals and outcomes * a process of executing actions, making new plans, and learning from the outcomes