Refactor build API and controller (1/2)

Refactor the build API and validation. Refactor the build controller
to use the upstream cache package where possible. Use watches wherever
possible.
Add tests for refactored build system (2/2)

Add test coverage for refactored builds.