SPECTRE (Service Pair Execution Comparator for Traffic Response Equivalence) is a system for validating service migrations against real traffic. It runs a reference implementation and a candidate implementation in parallel, then compares their externally observable behaviour.
The reference implementation remains authoritative for client responses and side effects. The candidate runs in a network sandbox: SPECTRE intercepts its outbound requests, compares them with the reference implementation's requests, and replays the reference results without allowing the candidate to make real writes.
Semantic differences are captured for analysis and can be fed back into an LLM-assisted migration workflow. A candidate is quarantined when its behaviour diverges from the reference implementation.
SPECTRE is primarily intended for language and framework migrations, but the same approach can help validate dependency upgrades, service consolidation, and other behaviour-sensitive changes.
See USAGE.md for how to run and configure SPECTRE, and the design document for the proposed architecture and safety model.
The repository runs a whole mirror of a sample service locally with
proctor, as the Procfile describes. Each part runs as its own
process, over unix sockets under dist/sockets/:
referenceandcandidate, two copies of the sample service. They serve users from MySQL over gRPC, and forecasts over HTTP.forecasts, an HTTP forecast provider that the samples depend on.mysql, a MySQL server in Docker, seeded with the sample users.proxy, SPECTRE's mirror. It sends each client request to both samples, compares their responses, and intercepts their calls to the forecast provider and MySQL.server, the SPECTRE server, which the mirror reports to. It serves a web page of what it hears at http://127.0.0.1:50070/.
Docker must be running. Start everything in one terminal:
bit sample
proctorThen run this in another terminal, step by step, with the web page open:
# 1. Send traffic. The client gets the reference's answer, and the candidate's
# is compared with it. The candidate's MySQL statements and forecast call are
# answered with the reference's results, so it never reaches either.
grpcurl -unix -plaintext -d '{}' "$(pwd)/dist/sockets/ingress.sock" spectre.sample.v1.UserService/ListUsers
grpcurl -unix -plaintext -d '{"id":"user-2"}' "$(pwd)/dist/sockets/ingress.sock" spectre.sample.v1.UserService/GetUser
curl --unix-socket dist/sockets/ingress.sock 'http://ingress/v2/forecast?location=london'
# 2. Within a second, the page charts each route's requests for both sides,
# in ingress and egress, and the mirror is healthy. The CLI shows the same.
spectre status --server-url=http://127.0.0.1:50070
# 3. Make the responses diverge. /_diverge answers each request with a random
# value, so the reference and candidate disagree, and SPECTRE quarantines
# the candidate: it stops sending it traffic until the mirror restarts.
curl --unix-socket dist/sockets/ingress.sock http://ingress/_diverge
spectre status --server-url=http://127.0.0.1:50070 # ingress is quarantined as divergent, on ~ $.nonce
# 4. Reset: stop proctor with Ctrl-C and start it again, then clear the
# recorded divergence.
spectre status clear --server-url=http://127.0.0.1:50070 --service=sample --environment=local
# 5. Make the MySQL statements diverge. Each sample looks up a random user ID,
# so the candidate's statement matches none of the reference's. After the
# match window, about 5s, SPECTRE quarantines the candidate's egress and
# fails its statement, so the candidate answers 502 and ingress diverges too.
curl --unix-socket dist/sockets/ingress.sock http://ingress/_diverge/mysql
spectre status --server-url=http://127.0.0.1:50070 # egress is quarantined on SELECT, ingress on $status 200 → 502