Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Java HotROD

A small ride-dispatch system in Java: four Spring Boot services that call each other over HTTP, each with a committed OpenAPI contract. It exists to show, on real pull requests, two kinds of evidence side by side:

  • SpecShield: does this change break a service's API contract, and does the running service still match its contract?
  • Code Telemetry: did the coding agent that made the change actually run those checks on the commit it pushed?

It's modelled on the roles in Jaeger's HotROD demo (a frontend that dispatches a driver using customer, driver and route services), written from scratch in Java.

The services

                    GET /dispatch/{customerId}
                              │
                        ┌─────▼─────┐
                        │ frontend  │ :8080
                        └─┬───┬───┬─┘
      GET /customers/{id} │   │   │ GET /routes/{pickup}/{dropoff}
              ┌───────────┘   │   └───────────┐
        ┌─────▼────┐   ┌──────▼─────┐   ┌─────▼────┐
        │ customer │   │   driver   │   │  route   │
        └──────────┘   └────────────┘   └──────────┘
           :8081   GET /drivers/nearest/{location}   :8083
                           :8082
Service Contract What it does
frontend frontend/openapi.yaml Looks up the customer, finds nearby drivers, asks the route service how long each would take and dispatches the fastest
customer customer/openapi.yaml A customer's name and pickup point
driver driver/openapi.yaml Five drivers near a point
route route/openapi.yaml Drive time between two points

Points are "x,y" coordinates on a made-up city map. Customers are 123, 392, 731 and 567.

Run it

Needs Java 21 and Docker.

mvn package
docker compose up --build
curl localhost:8080/dispatch/123
# {"customerId":"123","driverId":"HR-7141","driverLocation":"572,343","etaSeconds":112}

If port 8080 is taken: FRONTEND_PORT=8090 docker compose up --build.

The checks

.github/workflows/ci.yml runs three jobs on every pull request:

Check Command Catches
Build and unit tests mvn verify Code that doesn't compile or fails its own tests
Contract gate (one per service) specshield gate <service>/openapi.yaml A spec change that breaks callers, compared with the commit the branch started from
Provider conformance specshield bdct verify-provider against each running service Code that no longer does what an unchanged spec promises

Run the same checks locally, with the stack up:

npx specshield gate customer/openapi.yaml --base main
npx specshield bdct verify-provider --spec customer/openapi.yaml --base-url http://localhost:8081

The demo changes

Two changes, each made by a coding agent and pushed twice with the same diff: once without running the checks, once after running them on the final commit.

1. A contract change that breaks a caller. The customer service renames location to pickupPoint in its spec and code. The unit tests are updated to match, so the build passes. The contract gate blocks it:

✖ 1 breaking change blocks this change
● Field "responses.200.location" was removed from GET /customers/{customerId}

2. Silent drift. The customer service's code stops returning location, but the spec is left alone and the unit test is updated to the new shape. The build and the contract gate both pass, because the contract didn't change. The frontend now answers 502 for every dispatch. Provider conformance catches it:

FAIL   GET    /customers/{customerId}  (200)
       (root): must have required property 'location'

For each pair, SpecShield says what the checks found, and Code Telemetry says whether the agent ran them after its last edit.

Licence

Apache License 2.0.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages