An alleged mob capo who is considering singing for the feds yesterday found himself caged with the man he likely fears the most – reputed Bonanno boss Joseph Massino – as the result of a jaw-dropping blunder by the feds.

For the past two months, Frank Lino has been housed in solitary confinement – kept away from his four co-defendants and excused from attending joint court dates – while he weighs whether to become a turncoat, according to sources close to the case.

So Lino must have been stunned when he was locked in a holding pen with Massino and three other old pals – and then directed to a seat right next to his reputed boss in a Brooklyn federal courtroom.

For several heart-stopping moments, lawyers in the case addressed federal Judge Nicholas Garaufis as if they hadn’t noticed Lino was there. The reputed capo looked slightly baffled but seemed ready to go along with it – even though his attorney, Barry Rhodes, was not present.

Suddenly, a U.S. marshal waived Lino out of the jury box – where he and the other prisoners were seated – and swiftly escorted him out of the courtroom.