Four years ago, after more than a decade of litigation and negotiation, New York State officials agreed that the system of often dismal and dangerous adult homes was no place for the mentally ill.

They agreed to move as many as 4,000 mentally ill residents out of their apartments and into supportive housing, a hard-fought recognition that people with disabilities should have the opportunity to live independently and participate in all aspects of community life.

But as a July deadline nears, a federal judge has found that the state seems far from meeting its commitment: Fewer than 500 people have actually been moved into supportive housing from adult homes.

But what the judge, Nicholas G. Garaufis of the Eastern District of New York, found most troubling was that the state appeared to be working with the adult home industry to undermine the settlement.