Heat the olive oil in a wide, heavy-bottomed pot over medium-low heat. Add the carrots and celery and cook for 5 minutes, stirring occasionally, until fragrant. Add the garlic and cook 30 seconds more.
Add the sliced onions and a generous pinch of salt. Stir to coat, reduce heat to low, cover, and cook for 70–75 minutes, stirring every 10 minutes, until the onions are fully melted and deeply golden.
Raise heat to medium, pour in the white wine, and scrape the bottom of the pot. Simmer 2 minutes until the alcohol smell fades. Stir in the tomato paste and cook 1 minute more.
Add the stock, bay leaf, and red pepper flakes if using. Simmer uncovered over low heat for 25–30 minutes, until thickened. Season with salt and pepper.
Meanwhile, cook the rigatoni in well-salted boiling water until just shy of al dente. Drain, reserving 1 cup of pasta water.
Remove the bay leaf from the sauce. Gently fold in the drained tuna, breaking it into large flakes. Add the pasta and toss, loosening with reserved pasta water as needed.
Stir in the parsley and basil, and finish with a drizzle of olive oil. Serve immediately with grated Parmesan or Pecorino.