Text this: Goal-oriented inference : theoretical foundations and application to carbon capture and storage