BOSTON -- In the Middle Ages, Europeans would confine their lunatics between the city gates. They would stay there, locked behind iron grills, forming a symbolic human way station, marking the fragile edge of civilization.

Later on, mad people were loaded onto boats, ''ships of fools,'' that were set on the waterways. These boats carried their human refuse from one city to another.

We don't do such things anymore. In the late 20th century, we let many of our mentally ill wander the city streets. We step over them, walk around them. Unless we hear them talking with characters in their own psychotic world, we may not even distinguish them from others who make their ''home'' on the sidewalks.

But now we have a new celebrity among the homeless. Her name is Joyce Brown. And with her fame comes a set of questions about our cities' obligations to the mentally ill.

Joyce Brown -- alias Billie Boggs or Ann Smith -- had a chic address in Manhattan's high-rent district. She lived on a grate beside a restaurant at 65th Street and Second Avenue.

On Oct. 28, Brown became the first person picked up under a New York City program. The mayor had created a plan to round up some of the homeless mentally ill and take them to hospital shelters.

But in a real way, this story began much earlier, before Brown's own life began to fall apart. Back in the '50s and '60s it was easy, too easy, to commit people to institutions. Then, in the '70s, as Dr. Darold Treffert, the Wisconsin psychiatrist who has written widely on this subject, says simply, ''The pendulum swung too far.''

In 1972, a Wisconsin federal court ruled that the state could detain people only if they were dangerous, and dangerous meant suicidal or homicidal. It became harder to hold people against their will. And it remained harder to help people.

There were a large number of people who were not suicidal, not homicidal, but gravely disabled -- people who just didn't know enough to come in out of a snowstorm. Treffert collects some of their stories under the title ''People Who Died With Their Rights On.''

Now, in urban America, many wonder whether the respect for rights isn't also an excuse for neglect. The feisty mayor of New York, Ed Koch, is one of the few who decided to push the pendulum back a bit.

It is too bad for the mayor and for the program that Brown was its first target. He would have had a better case with the man who willingly shares his plastic bag ''house'' with rats in Central Park or the woman acting out her own sexual hallucinations in the Port Authority.

Brown resisted the city's ''help'' all the way to court. There, one group of psychiatrists portrayed her as a psychotic who defecated in the streets and ran in front of traffic. Another portrayed her as a rational survivor who could take care of herself.

The 40-year-old former secretary, shored up by all the attention (or in a respite from mental disorder) was her own best witness. The ''professional'' street dweller, as she called herself, was hard to distinguish from other homeless we are conditioned to ignore. So, the judge ruled last week that Brown must be allowed to return to her homeless home.

Make no mistake. There are no victors in this case. The civil-liberties lawyers who protected Brown's right to be ''free'' know that the streets provide a mean sort of freedom. The judge who ordered Brown's release also wrote pointedly, ''There must be some civilized alternatives other than involuntary hospitalization or the street.''

Joyce Brown herself, ''choosing'' street life, was asked in court where she would like to go. She wanted to go to an apartment. Could she afford it? No, she answered.

In reality, there are very few civilized alternatives. Today there are fewer institutions and more mentally ill people on the streets. If released (she is being held on appeal), Brown might go on coping. Or like so many others, she might have to deteriorate to the point of real danger to get help.

The homeless celebrity provided a poor test case for the city. But even the judge called the program a first step in the right direction. It won't cure high rents and homelessness. It won't end psychosis. It won't produce a community mental health program. But New York is offering a small antidote to urban callousness. At the very least we can provide emergency help to some of the mentally ill before they, too, die with their rights on.