The house, which is open to the public three days a month including this Thursday, is a wonder in itself. It comes with a time capsule, a ghostly legend and a ton of history.

It is now celebrated as an architectural treasure, but the Octagon House was once such a dilapidated wreck it was nearly torn down, only to be rescued by a group of women who are descendants of some of America's oldest families.

The Octagon House is a bit of a time capsule of the city itself, built when Cow Hollow was way out in the country. The house was on the cutting edge of innovation when it was new in 1861, but it was built without indoor plumbing or a kitchen.

The shape is what makes it unique: The house has eight sides - which means more windows and twice as much sunshine and fresh air as a conventional house with four sides.

The first octagon house in the United States was built about 1790 in South Carolina, but the design really took off after the publication of "A Home for All" in 1848 by Orson Fowler, a self-taught architect and a phrenologist. Phrenology is a branch of science that holds that the shape of one's head is the key to personality. Fowler, as you might imagine, was a bit of a crank.

But his octagon idea became a fad; octagon houses were built all over the United States, including eight in San Francisco. The Octagon House in Cow Hollow is one of only two that remain in the city. The other, a residence at 1067 Green St. on Russian Hill, is not open to the public.

Nancy McAteer, president of the National Society of Colonial Dames of America in California, gave The Chronicle a guided tour of the Octagon House the other morning. It is a quiet, sunny, immaculate house, flanked by gardens and a city park. The Colonial Dames bought the house in 1953 and saved it.

The Octagon House was built by William and Harriet McElroy in 1861. She was a Forty-Niner and a person of some wealth in Gold Rush San Francisco; he ran a flour mill. They married in 1859 and built the house two years later.

It was a difficult time in this country. The Civil War was just beginning and there were worries even in the West: Southern sympathizers might try to take California out of the union.

The McElroys hid a time capsule in the house - family pictures, some newspaper clippings and a letter for future generations about Abraham Lincoln and the gathering war clouds.

McAteer, the guide to the house, talked about its long history and the families who lived there: how William died in 1869, how Harriet lived on until nearly the turn of the 20th century, how the old house changed hands and was rented to various tenants, including three reclusive spinster sisters, and how it fell, finally, under the ownership of the Pacific Gas and Electric Co.

PG&E wasn't interested in the house, only the property. It stood empty for years, a picturesque ruin. In 1953, the well-connected Colonial Dames persuaded PG&E to sell it for $1 on condition they move it across Gough Street to its present location.

It is said to be haunted by a ghostly figure who climbs the stairs to the second floor on the night before Thanksgiving every year. On a summer's day, however, the place seems too bright and sunny for ghosts.

The house itself is a survivor. It lived through fires, earthquakes, decay and neglect. The key to its survival? "Luck, just luck," said McAteer. It is something from another era, "but for that era," said McAteer, "this house is the star."

The Octagon house is open the second Sunday of every month and the second and fourth Thursdays from noon to 3 p.m. Admission is free, but the Colonial Dames ask for a $3 donation.