Sorry, probably my english is not good enough to understand everything. But let me try:

you compress the spring at the top and use 1 unit if energy

and the box sinks.

then if you decompress the spring under water so that it will expand and float up ,

Thats not my initial model.

In my model I use the energy at the bottom to stretch the spring. And at the top I get some of this energy back by letting it recontract.

Same as you using energy for electrolysis at the bottom and regaining some of this energy at the top.

But, ok. Lets assume we are compressing the spring at the top, using 1 Unit of energy. The Box will now fall downwards. At the Bottom we have the let the spring stretch again.

The problem is: at the top we have less surrounding pressure then at the bottom. So the energy used at the top to compress the spring is NOT ENOUGH to let the spring stretch on the Bottom.

Lets quantify this: We build an offshore-box-driven-power-plant in some part where the oceans depth is 10km.

Tower height: 10.000 m.

Density of Water: 1000 kg / m³

Weight of Box: 6000 kg.

Volume of Box at the top: 3 m³

Density of Box at the top: 2000 kg/m³ (will sink)

downward force while sinking: [6t - 3m³ * 1t/m³ ] * 9.81m/s² = 29.43 t*m/s² ~ 30 kN

Volume of Box at the bottom: 12 m³

Density of Box at the bottom: 500 kg/m³ (will float up)

upward force while floating up: [12m³ * 1t/m³ - 6t] * 9.81m/s² = 58.86 t*m/s² ~ 60 kN.

Energy gained by floating up and falling down:

10.000m * 60kN + 10.000m * 30kN

= 900.000.000 N*m = 900 MJ.

(or 882.9 MJ using the exact numbers)

How much energy do we need to convert the box from the sinking to the floating state?

At the bottom we have to extend the volume of our box from 3m³ to 12m³. So we have to push 9m³ of water away.

The surrounding pressure at the bottom would be: 10.000 m * 1000 kg/m³ * 9.81 m/s² = 9.81 * 10^7 N/m² = 9.81*10^7 Pa = 981 bar.

The energy needed to gain 9m³ of volume at this pressure would be: 9m³ * 9.81*10^7 N/m² = 88.29*10^7 N*m = 882.9 MJ.

All generated Energy is lost if you try to complete a full cycle.

If we try your latest approach and

compress the spring at the top we have the same problem.

Either we use a light spring, easy to compress.

But then the stored energy in the spring won't be able to overcome the surrounding pressure. The box won't float up again. Or we use a heavy spring, but then we have to apply the needed energy at the beginning for compressing it.

then you are making the water level at the top increase , and you are lifting the water using the 1 unit of energy you put in compressing the spring.

[...]

and if you let the box rise more you could get more energy out from buoyancy.

Now, this is a different model!

Now you are complicating things by changing the water level during the floating phase.

I guess now the problem is:

a) inserting the box at the bottom of the water-tower at the start of the second run. (pushing against the now elevated water level means pushing against more pressure loosing all energy gained by increasing the falling and rising distance.

b) You could try to sink the water level again, before inserting the box at the bottom. But now you have the problem of re-elevating the water level. You are loosing again exactly the same amount of energy.

c) You could use water from a separate source (like rain), but then you have just an open system, gaining nothing more then the potential energy stored in raindrops.