On a recent morning, Josh Shapiro, chairman of the Montgomery County commissioners, broke into a big grin as colleague Bruce Castor strode into the commissioners' conference room.

"There he is," Shapiro said, his eyes following Castor's swashbuckling entrance. "Looking all gubernatorial."

It was the Tuesday after the Pennsylvania Society gala in New York City, where Castor had floated his own name as a possible primary challenger to Gov. Corbett. Now the good-natured ribbing from Shapiro - who has also been mentioned as a gubernatorial aspirant - was met with laughter among commissioners' staffers.

It's a new sound for those four walls. Congress may be small-minded, glacial, and ideologically splintered, but, until recently, it had nothing on Montgomery County, which for much of the last four years had been Exhibit A in government dysfunction. Corruption and mismanagement reigned. Feuding commissioners called one another "sick bastard," "liar," and "corrupt."

The backstory is well-known: After their election in 2007, Republican Chairman Jim Matthews and Democrat Joe Hoeffel formed an alliance to squeeze out Republican Castor. Great drama followed, culminating in a grand jury report that not only accused Matthews of lying, but highlighted the county government's wasteful spending, secrecy, and questionable awarding of contracts. Matthews later agreed to a deal in which he did not admit guilt but did pay a fine and court costs.

Enter Shapiro, a numbers-crunching policy nerd whose wonky appearance masks a tough-as-nails reformer and true disrupter. He'd tried to clean up the state House before setting his sights on another seemingly lost cause last year when he sought, and won, a seat on the Board of Commissioners and became chairman. Now, a year after Shapiro's election, Montgomery County is one of the country's few bipartisan success stories.

Under Shapiro, transparency has been restored, an ethics policy has been adopted, and crony appointees have been replaced with merit hires. Among other moves, he plucked Uri Monson, the respected executive director of the Pennsylvania Intergovernmental Cooperation Authority - Philadelphia's fiscal overseer - to be the county's chief financial officer.

Shapiro saved his boldest innovation for the recently passed budget. In the '90s, Shapiro heard President Bill Clinton talk about "zero-based budgeting," an idea he brought to county government. Instead of submitting a request for a percentage raise in their budgets, each department had to write a paragraph detailing its core mission. Shapiro and the department heads worked backward from there, figuring out how much money it would take to meet the mission - and not a penny more. There were skeptics. Shapiro ended one meeting abruptly when a staffer objected: "This isn't how we do it."

"People either became converts or they no longer work here," Shapiro says.

What had been a $10 million shortfall was transformed into a balanced budget that required no new taxes and that increased pension funding, grew the county's reserves for the first time in four years, and eliminated all earmarks.

"I never heard of 'zero-based budgeting' and I thought it was a gimmick," says Castor, who ridiculed the concept in last year's campaign. "But now I'm a convert."

The conversion of Castor just may be Shapiro's greatest political sleight-of-hand. After last year's election, the three commissioners had lunch at the Aviation Club at Wings Field in Blue Bell. Castor filled in Shapiro and Leslie Richards, the other Democratic commissioner elected that year, on the previous regime.

Shapiro had leverage: He knew Castor needed to prove that he had not been the problem in the previous administration. And, as Castor vented about how he'd been treated - he said his fellow commissioners had him sit off the dais during televised meetings and edited his comments out of the broadcasts, for example - Shapiro sensed that all Castor really wanted was some respect.

"You should vote your conscience, but I'd like to seek consensus on every matter before us," Shapiro told his colleague, pledging that Castor's voice would be heard on every issue no matter how he voted. "I have only one rule: No surprises. Just don't blindside me." During public meetings, he moved Castor's chair back to the dais: "It's so foreign to me that you would treat a colleague like that," Shapiro says.

The result has been a year of unanimous votes and structural reform. Castor says we shouldn't be surprised. "You fellows in the media always had it wrong," he says, sitting beside Shapiro in the chairman's corner office - an office Castor never was invited to enter during Matthews' reign.

"The dysfunction here was never over philosophy." It was a result, he says, of his two former colleagues "who didn't have the best interests of the people at heart."

The pugnacious Castor goes on to castigate his former rivals for a good five minutes, peppering his soliloquy with some in-your-face name calling, while Shapiro squirms in his seat. "He's about to say something nice about me - wait for it," Shapiro finally blurts out, laughing.

Castor catches himself. "Because Josh strives for consensus, you never have anybody who feels he or she wasn't heard," he says. "There hasn't been one instance where I've felt something was rammed down my throat."

It's a tricky proposition in Montgomery County, where three ambitious politicians try to reform a government that had embarrassingly lost its way. Adding to the complexity is that two of them - Shapiro and Castor - might someday be rivals statewide. But, for now at least, they're proving that maybe bipartisanship isn't dead after all - and that a politician doing his job well might also be the smartest of political moves.

Larry Platt's column appears regularly in Currents. He can be reached at larry.platt@gmail.com.