Build a multi-user code review flow
Pair two workspaces with one command and exchange code-review records in both directions, with consent controlling what is shared.
By the end of this tutorial, two workspaces, alice and bob, will be paired and exchanging code-review records over a single link. Alice opens a review request, bob publishes a verdict, and both can be shown in a shared three-pane view.
This is the smallest complete multi-user flow.
It uses the spl federation invite command. There is no extra setup: the records and threads are created
as you go.
Allow 15 to 20 minutes.
What you'll build
┌──────────────────────────┐ ┌──────────────────────────┐
│ alice (submitter) │ │ bob (reviewer) │
│ │ │ │
│ th_review_inbox ──────────────────────────► th_review_inbox │
│ (request published) │ │ (request appears) │
│ │ │ │
│ th_review_done ◄─────────────────────────── th_review_done │
│ (verdict appears) │ │ (verdict published) │
└──────────────────────────┘ └──────────────────────────┘Three threads (th_review_inbox, th_review_active,
th_review_done) flow over a single federation pair, limited by
consent on a code namespace.
Prerequisites
- Two workspaces. The simplest setup: one running on the default port
(
9100) and a second on9201in a separate terminal. Both can live on the same machine; that's what this tutorial uses. - An identity on each:
spl identity showshould show a DID. If not, runspl identity generate. splinstalled, withspl federation inviteavailable (spl version).
This tutorial gives each workspace its own data
directory and uses --insecure-localhost so they can pair without
TLS certificates. For real setups across machines, use TLS on both.
Alice uses port 9100, the default. If you already run a workspace on this
machine, stop it first or pick other free ports for the whole tutorial.
1. Start two workspaces
In terminal A (alice):
SYNCROPEL_HOME="$HOME/.syncro-alice" \
spl serve --port 9100 --insecure-localhostIn terminal B (bob):
SYNCROPEL_HOME="$HOME/.syncro-bob" \
spl serve --port 9201 --insecure-localhostVerify each is healthy:
curl -s http://127.0.0.1:9100/health
curl -s http://127.0.0.1:9201/healthEach should return a JSON {"status": "ok", ...}.
2. Confirm both are ready
There is nothing to set up. The threads are created as records arrive in them. A workspace screen is optional, if you want to view the records side by side. See Authoring a workspace to build one afterwards.
In a third terminal, confirm each one is reachable:
SPL_SERVE_URL=http://127.0.0.1:9100 spl status
SPL_SERVE_URL=http://127.0.0.1:9201 spl statusBoth should report healthy. You now have two workspaces ready to pair.
3. Pair the workspaces
Alice starts the pair:
SPL_SERVE_URL=http://127.0.0.1:9100 \
spl federation invite http://127.0.0.1:9201 \
--grant-namespace code \
--grant-thread th_review_inbox \
--grant-thread th_review_active \
--grant-thread th_review_doneThe first time, the handshake pauses until someone approves it on bob's side. Switch to bob's terminal and approve:
SPL_SERVE_URL=http://127.0.0.1:9201 \
spl decisions list
# copy the pending request ID
SPL_SERVE_URL=http://127.0.0.1:9201 \
spl decisions approve <id>Back in alice's terminal, the invite command finishes:
Invited did:sync:instance:bob-...
Pair ID: fed_<sha256>
Peer DID: did:sync:instance:bob-...
Consent grants: 1
- code cg_<id>
Thread allows: 3
- th_review_inbox
- th_review_active
- th_review_done
Send the recipient this URL so they can find the pair again:
http://127.0.0.1:9201/.well-known/syncropelThe pair is live. From now on spl sync uses it automatically.
4. Open a review request (alice)
Alice publishes a code_review.request.v1 record on the inbox
thread. For records with custom body shapes (anything beyond the
built-in intend/know/do/learn shortcuts), use POST /v1/records:
ALICE_DID=$(curl -s http://127.0.0.1:9100/.well-known/syncropel | jq -r .did)
curl -s -X POST http://127.0.0.1:9100/v1/records \
-H 'Content-Type: application/json' \
-d "{
\"thread\": \"th_review_inbox\",
\"actor\": \"$ALICE_DID\",
\"act\": \"INTEND\",
\"data_type\": \"SCALAR\",
\"parents\": [],
\"clock\": 0,
\"body\": {
\"kind\": \"code_review.request.v1\",
\"_v\": 1,
\"title\": \"Refactor auth middleware\",
\"branch\": \"feature/auth-rewrite\",
\"summary\": \"Migrate session tokens to encrypted-at-rest storage.\",
\"diff_url\": \"https://example.com/pulls/42\"
}
}"The workspace assigns the record ID (a SHA-256 of its content) and returns it. Setting clock
by hand is fine for a tutorial; the SDKs handle
it for you (see TypeScript
SDK or Python
SDK).
To get the record to bob's side, run a sync pull:
SPL_SERVE_URL=http://127.0.0.1:9201 \
spl sync th_review_inbox from did:sync:instance:alice-...(Substitute alice's DID. spl identity show on alice's workspace
prints it, or you can find it on bob's side with spl federation list.)
After the pull completes, bob's inbox thread carries alice's request:
SPL_SERVE_URL=http://127.0.0.1:9201 \
spl thread records th_review_inbox5. Publish a verdict (bob)
Bob reviews the request (in real life he would read the diff and decide)
and publishes a code_review.verdict.v1 record:
BOB_DID=$(curl -s http://127.0.0.1:9201/.well-known/syncropel | jq -r .did)
curl -s -X POST http://127.0.0.1:9201/v1/records \
-H 'Content-Type: application/json' \
-d "{
\"thread\": \"th_review_done\",
\"actor\": \"$BOB_DID\",
\"act\": \"KNOW\",
\"data_type\": \"SCALAR\",
\"parents\": [],
\"clock\": 0,
\"body\": {
\"kind\": \"code_review.verdict.v1\",
\"_v\": 1,
\"request_title\": \"Refactor auth middleware\",
\"verdict\": \"approved\",
\"comments\": \"Migration plan looks safe. Two minor nits inline.\"
}
}"To get the verdict back to alice:
SPL_SERVE_URL=http://127.0.0.1:9100 \
spl sync th_review_done from did:sync:instance:bob-...Alice's th_review_done now carries the verdict:
SPL_SERVE_URL=http://127.0.0.1:9100 \
spl thread records th_review_done6. View it in the Studio (optional)
A three-pane view is available
(Inbox / In review / Verdicts). To see it rendered, point a
browser at each workspace's Studio (the path depends on your
setup, typically /local).
The Inbox pane shows code_review.request.v1 records. The In
review pane shows code_review.assignment.v1 (a record bob would
write when claiming a request). The Verdicts pane shows
code_review.verdict.v1.
What you just did
- A code-review flow with two roles on two workspaces.
- A pair created with one command, including consent and thread allowlists.
- Records flowing in both directions under consent. Alice's request reaches bob and bob's verdict reaches alice. Nothing else crosses unless you grant it.
- A flow anyone can repeat with their own collaborators.
Where to go next
- Pair two workspaces in one command:
the pairing step that
invitebuilds on. - Invite another workspace:
full reference for the
invitearguments. - Consent management: what the sharing levels mean and how Syncropel chooses between competing grants.
- Async federation: how syncs run in the background once a pair is set up.
Your first pattern
Do the same kind of work three times, see Syncropel recognize the pattern, watch your trust score grow, and see how the next similar piece of work is handled.
Your First Multi-Namespace Setup
Set up two isolated environments under one organization, write records into each and check that a child namespace can only narrow its parent. About 15 minutes.