The Codex is your personal collection of combat bonuses. It is not tied to any item: it belongs to the character and follows you with whatever set you are wearing.
There are 17 bonuses, each with its own level from 1 to 100. To raise a level you pay gold and hand over materials, and the attempt has a chance to fail. The higher the level, the more expensive and the riskier it gets.
Failing never resets anything. The level you already have never drops. You lose the attempt, and you have a chance to keep what you spent — see Fail-safe below.