Q:

Interfaces for microservice boundaries - how to import code?

I'm building some small services in Haskell. I'd like to make the boundary between services formal, such that the build process will tell the developer if the contract has been violated
For a simple example, say we have an API with a route POST /users. It's supposed to add the user to the users queue. Then we have one worker, which reads from the queue and processes the new user. 
The contract between the two looks like:

The exchange is named "exchange"
The queue is named "users"
Messages should be user objects serialized to JSON (or msgpack, or protobuf)
users are: { name : String, age : Int }

How can I enforce this so that I get build errors if either service:

Connects to the wrong queue or exchange
Uses an incorrect schema for User

This would be easy if all the code were in one repository, but one of the main goals of microservices as I understand them is to make them independent. How could it be done with separate repos? 
I had the idea to create a 3rd repo for the contract, and have both services depend on it. If it contained some Haskell types, the API and the worker could both include it and typecheck their implementations against it. If I do this, how should I handle versioning? Should they include it as a git submodule, or through the package manager (which would allow depending on old versions, which might be bad)?
If I wanted to update the schema of User, how would I architect things so that I then get errors in the two services until they are updated?
For folks who use protobuf, where do you store those files in relation to the two services? Can protobuf surface errors in the implementations? 

A:

I'd say it's idiomatic for micro-services to not expect compile-time, or build-time support for boundary checking or enforcement. 
Instead you would enforce these rules in two ways at run-time:

validation and error handling:  services must always expect incorrect input or abuse and be prepared to handle it gracefully, by returning proper error codes and throttling
take advantage of digital signatures to authenticate requests and enforce access policies

