Make the pesto. Pulse the basil, garlic and pine nuts in a food processor to a coarse paste, adding enough olive oil to produce a loose-textured purée. Pour into a bowl and fold in the parmesan.
Blanch remaining garlic in boiling water for 3 mins, until slightly softened. Drain, return to the pan with 200ml/7fl oz of the chicken stock and half the butter. Simmer for about 15 mins until the garlic is soft and coated in the syrupy stock. Remove from the heat. You can do this up to 4 hrs in advance.
Heat oven to 200C/fan 180C/gas 6. Toss the pumpkin cubes with the olive oil in a roasting tin, and roast for 10-15 mins until the flesh is just tender.
Make the crispy shallots. Dust them in the flour and shake off excess. Heat 2cm oil in a large pan and fry until light golden brown. Drain and keep warm.
Sweat the onion in the remaining butter in a large shallow pan until soft, about 5 mins. Tip in the rice, raise the heat and toast until translucent. Lower the heat and add the remaining stock a ladleful at a time, stirring well until the stock is completely absorbed before you add the next ladleful.
Once the rice is al dente, fold in the 2 cheeses, garlic cloves and pumpkin and cook for 2 mins. Serve with a drizzle of pesto and the shallots on top.