Each attempt rolls the success chance for your current level. On success the item goes up one. On failure, from +4 or higher it drops one level; at +3 or below nothing changes. The item is never destroyed, and the material is spent whether you succeed or fail. Every level gained also raises the item's maximum Endurance, and a level lost takes that bonus back with it.
All chances below are the game's real numbers — unique weapons use the high (70→40) table; common weapons use the low (35→5) table; armour and shields use 70→50. Dark Knight / Dark magic weapons are a case apart: they never fail (100% every step), they are paid for in Majestic Points, and they cap at +5 instead of +7.
One thing this calculator does not model: the Tutelary Angels climb a ladder of their own — three levels, not a star track, and it never fails. Level 2 costs 100 Majestics and level 3 costs 300. There is no risk to calculate there, only a bill. See Tutelary Angels.
Common weapons that already carry +1 or +2 in their name (a Falchion +2, say) start on that row of the table, not on the first: their next upgrade rolls the chance of the level they show. The +7 ceiling is the total shown on the weapon, so a +2 weapon has only five upgrades left in it. The fail penalty, though, counts only the levels you added with stones: nothing drops until you have added four. Set Comes with (in its name) below and the calculator does all of this for you.