lib: centralize query parsing, store results.