That Antonio Bastardo backed himself into a corner for his second straight outing – and this time wasn’t able to get out of it, for another bullpen loss – was less than encouraging.

But even the Phillies 4-3 extra-inning walk-off loss to the San Francisco Giants at AT&T Park today was rife with silver linings.

Deploying only a B-squad lineup to support rookie Jonathan Pettibone, the Phillies stayed within arm’s reach of the World Champions until the ninth, when they hung two runs on one of the best relievers in baseball.

After a Jimmy Rollins leadoff double and Michael Young walk, Chase Utley zip-lined a single and Delmon Young soared a sac fly to left on Sergio Romo, who’d only blown one save since taking over the closer role in late 2011 – on July 30 last year.

This, for the Phillies first multi-run ninth-inning comeback of the year.

Carlos Ruiz picked a good time to nab his first base stealer of seven so far. If he doesn’t throw out Gregor Blanco at second in the ninth, Marco Scutaro’s double in the next at-bat scores him.

Ben Revere gave them a chance in the 10th by crashing a comebacker off the glove of Javier Lopez for an infield single. But after a blown caught stealing call – Revere clearly beat the tag – and Dom Brown strikeout, a runner on second with one out became the end of the inning.

Credit the Giants: they executed textbook late-game strategy, small-balling Buster Posey all the way around the bases for the winner. Posey smeared a leadoff single. Joaquin Arias bunted him to second.

Posey swiped third on a Bastardo breaking ball in the dirt – it was scored a wild pitch, but Posey’s instincts and anticipation deserve credit – and Andres Torres finished it off with a smoker up the middle.

The Phillies came that close to their first sweep at AT&T Park and first on the road over the Giants in (I stopped looking after 20 years…), and even despite today, have solid momentum heading into this four-game set in Arizona.

Kevin Frandsen roped a fourth-inning solo shot to answer Hunter Pence’s one-run blast in the second. John Mayberry went 0 for 2 but bellied out in left for this shoo-in Web Gem in the third.

Not bad production from the guys spelling the team’s hottest hitters, Ryan Howard and Brown.

Pettibone for the first time looked like a rookie. Not so much on the three runs in 5 2/3, which bumped his ERA to 3.63. More with the four walks – he’d issued free passes only twice in 16 2/3 innings prior.

He did well to keep the ball low, forcing 11 grounders, and he made his mistake with no men on – each of his four homers allowed have been one-runners.

But opposing hitters continue to get good contact on him.

Jimmy Rollins and Revere each went 2 for 4. Rollins entered 4 for his last 32 and hadn’t stuck a multi-hit game in his last nine. Revere got his first set of back-to-back multi-hit games all year.

Next: Cole Hamels (1-4, 4.34 ERA) kicks it off in Arizona against lefty Patrick Corbin (4-0, 1.80 ERA) at Chase Field tomorrow at 9:40.