where do certain rake commands reside

All the Rails built in rake tasks are in
vendor/rails/railties/lib/tasks - various .rake files depending on
function.

You can use "rake --tasks".
The files Tom mentioned can also be found in your apps lib/tasks/
directory.
- Brian