Preheat the oven to 400 degrees. Slice 10 of the red chilis in half and place them face down on a baking sheet. Place garlic cloves and onion on the baking sheet, insuring that none of the vegetables are overlapping. Bake, without stirring, until chilis begin to blacken in spots, about 40 minutes (note: watch them closely and remove if they start to blacken earlier than the recommended timeframe; some reviewers have noted that their aromatics began to blacken after 10 to 15 minutes). Remove from the oven and allow to cool to room temperature.
Cut the 3 remaining chilis in half lengthwise. Gently remove the seeds and membranes from both the roasted and raw chilies (see note below). Gently squeeze the garlic cloves to extract the roasted garlic, and discard the peels.
Put garlic, chilis, onions and mushrooms in the bowl of a food processor. Pulse until the mixture is finely and evenly chopped. (It will be nearly smooth and ground to a paste in some spots.)
Place the chopped vegetables, sugar, water, tamarind paste and vinegar in a small pot over medium heat. If the mixture appears quite dry, add a splash more water so that it can easily come to a simmer.
Simmer, stirring frequently (reduce the heat if it begins to boil), until the mixture becomes smooth and thick, about 10 minutes. Remove from heat and allow to cool.
Store in the refrigerator for up to 2 weeks.