Three issues.

 First, dock services should not agree to remove a device if it results in a ship having fewer than zero free device slots.

 Second, dock services will not allow you to replace one weapon with another weapon if you have no device slots open, even if this would result in the same number of slots being used.

 Third, it is possible to install a two-slot reactor even if all of your device slots are full, resulting in -1 free slots.

Screenshot.png
Screenshot.png
relanat 15 Jun 2016:

Another example from Cabbage Corp taken from a post here; http://forums.kronosaur.com/viewtopic.php?f=24&t=6955&start=30
=========================

In a Wolfen I swapped a 25MW reactor (single slot) for a dual Siva-40M reactor (2 slots) but didn't have a spare slot.
It could be installed even without a spare slot and the Ship Configuration screen showed device slots changing from '8 (0 free)' to '8 (-1 free).. non-weapons stayed at '4 (0 free)'.
I uninstalled the dual laser cannon and got the device slot numbers back to normal (8 and 4 with 0 free).

But after that I tried to replace the previously installed solar array with a biohybrid solar dynamo and the Starton dock services wouldn't do it. I think this should have been allowed because it would swap devices in a non-weapons slot.

I then uninstalled the solar array so I could install (as opposed to replace) the solar dynamo but the device slot that should have been free was a weapons slot not the non-weapons slot that I had just emptied. The Ship Configuration screen showed 'device slots:8 (1 free)' and 'non-weapons:4 (0 free)'. The end result was I uninstalled a non-weapons device and then couldn't install another non-weapons device.

If you're confused, don't worry, so am I.
I think what's happening is the Siva reactor, which was installed when there wasn't enough slots for it, is changing slots until the ship gets back to a normal setup with 8 slots and 4 (and only 4) of them with non-weapons. Making it so that 2 slot devices can't be installed when there is only 1 slot available will fix all the rest of this. (maybe!)
======================

Although I'm not sure if this is clear enough to be of any help! :)

assumedpseudonym 17 Jun 2016:

 Can confirm Relanat’s observation.
 So yeah. Basically, removal or installation of any device needs to check to make sure a ship doesn’t wind up with fewer than zero slots available.

relanat 10 Oct 2017:

I think there also there needs to be a check that the available slot is either weapons or non-weapons as required. It looks like this is what caused some of the problems in the Cabbage Corp example above. The game was just grabbing any slot of whatever type until it could get the numbers back to where they should be regardless of device type.

the_shrike 5 Oct 2018:

I'm working on another slot-granting device so I also need this.

assumedpseudonym 5 Oct 2018:

 Updated the original post and changed the ticket name accordingly.