Make core/proto depend only on lib/*, and not used by core/mainloop

None of this code ought to depend on core/, much less on app/.

Nothing in core/mainloop should use any of the core/proto code.