A group of shipping companies and a powerful dockworkers union clinched a tentative labor deal on Friday after nine months of negotiations, settling a dispute that disrupted the flow of cargo through 29 U.S. West Coast ports and snarled trans-Pacific maritime trade with Asia. The settlement, confirmed in a joint statement by the two sides, was reached three days after U.S. Labor Secretary Thomas Perez arrived in San Francisco on Tuesday to broker a deal with the help of a federal mediator who had joined in the talks six weeks earlier.