Browse documentation
See a library edit reach a running consumer
Use the watch loop to activate a compatible tested edit while refused edits leave the last accepted version serving.
Use the pricing project from the library tutorial to watch a local library and serve its consumer. You need the runtime on PATH, two terminals and curl.
The generated consumer binds to an available port on 127.0.0.1. This is a local development listener with control routes; keep it on loopback.
1. Start from a passing project
effectful verify ./pricing
effectful test ./pricing
Keep the generated revision test. If you completed the tutorial’s edit, both the library and test should now expect 2; an untouched scaffold expects 1.
2. Start the consumer watch
In the first terminal, create a separate scratch state directory and start serving:
watch_work=$(mktemp -d)
effectful serve --app ./pricing --consumer example \
--state "$watch_work/state" --watch
Find the printed line beginning listener graph. It gives the actual address, including the selected port. Leave this process running.
3. Read the current result
In the second terminal, replace the placeholder with that exact address:
address='PASTE_LOOPBACK_HOST_AND_PORT'
curl -sS -H 'Content-Type: application/json' \
--data '[]' "http://$address/revision"
The JSON response includes a result, such as ["s64","1"] for the untouched scaffold, and its execution origin. Retain that origin to compare with the next accepted version.
4. Observe a refused edit
Change the integer returned by revision() in pricing/packages/pricing/src/lib.rs, but leave its consumer test unchanged for the moment.
The watch loop checks the candidate and runs its tests. The revision expectation should fail. Inspect the watch event’s status and diagnostics in the first terminal. Request /revision again: the last accepted version continues serving.
This is an intentional failure demonstration, not a reason to remove the test.
5. Accept a reviewed change
Confirm the intended new result, then update pricing/consumers/example/tests/revision.json to that expectation. Watch for an activated event. Repeat the request and inspect the new result and origin.
The source and tests now agree on the reviewed change, and the compatible candidate becomes the active consumer selection. The installed runtime handled checking, lowering, testing and activation without a separate native build for this library edit.
Changes to a route’s schema are a different case: the loop can refuse an incompatible candidate while retaining the accepted selection. A passing suite does not authorize arbitrary state migration or route replacement.
6. Stop the local listener
From the second terminal:
curl -sS -X POST "http://$address/_loop/stop"
Keep the scratch directory if you want its retained selection and history. The library project and runtime state have separate lifecycles; do not edit the state directory to switch source versions.
Build software you can reason about.