~ knotless Search/
↑↓ move↵ open⇧↵ all results

socialweb.computer/socialweb-computer-kcp

socialweb.computer: a compute market on atproto (kcp)

1 collaborator
0
0
157 lines · 6.5 KB Raw History

Request from prod bidders

You need the binary (README) and an atproto account that a bidder operator vouches for.

Vouches

Prod bidders run the policy bidder-tangled-vouch and every requester runs requester-tangled-vouch: both read sh.tangled.graph.vouch records whose rkey is the vouched DID (any kind but denounce).

who writesin whose reporkey
the bidder operatorthe operator'syour DID
youyoursthe operator's DID (or the bidder's)

Read both directions, here between a prod operator and its acceptance requester (put your handles in):

did() { curl -fsSL "https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=$1" | jq -r .did; }
pds() { curl -fsSL "https://plc.directory/$1" | jq -r '.service[] | select(.id == "#atproto_pds") | .serviceEndpoint'; }
vouch() { curl -fsSL "$(pds "$1")/xrpc/com.atproto.repo.getRecord?repo=$1&collection=sh.tangled.graph.vouch&rkey=$2" | jq -c .value; }
OP=$(did bobvmbuilder.bsky.social) ME=$(did aliceoa.bsky.social)
vouch "$OP" "$ME"
vouch "$ME" "$OP"

Each prints a record such as {"kind":"vouch","$type":"sh.tangled.graph.vouch",...}; a missing one fails with 400. Without them you get no bids received. Verdicts are cached 5 minutes, denials too: write the records first.

Run a command

socialweb-computer run request --name vm1 --atproto-oauth-qr --exec -- id

Sign in with the QR code (or the URL under it). You see uid=0(root) gid=0(root) groups=0(root); the VM is released when the command ends.

Hold a VM, ssh in, release it

socialweb-computer run request --name vm2 --hold --expires-in 2h --atproto-oauth-qr --exec -- uname -a
socialweb-computer run request ssh vm2
socialweb-computer run request list
socialweb-computer run request release vm2

--hold keeps the VM after the command; run request ssh opens a root shell (--exec -- <command> [args...] runs one command; both read stdin, so each is the last line of its block). Without --expires-in the bidder ends a VM 24 h after its accept.

optiondefault
--cpus N2
--mem 8G4G
--nested-virtoff: the VM gets /dev/kvm (only bidders that offer it bid)
--image <https base>@<image.json sha256>the bidder's guest image
--tunnel ssh:22:webrtc --transport webrtcssh over iroh
--state-dir <dir>~/.local/state/socialweb-computer

Who you run as

modethe requester isuse it when
your account (--atproto-oauth-qr or pdsAccount)your atproto account itself: its records go to your repoyou request by hand
associated (--identity <name> with --associate-with <your DID>)a DID of its own, on a PDS it runs, an agent of your accounta machine requests for you and holds no session of your account

Bidders serve an associated requester as they serve you: their vouch check walks it to your account. A fresh DID of its own with no account behind it (--skip-qr) gets no bids on prod.

Your account

--atproto-oauth-qr prints a QR code and its URL (qr.fedfork.com, valid 5 minutes): scan it with a phone or open it in any browser and sign in. With an app password instead, from a file (mode 0600):

ATPROTO_PASSWORD="$(cat ~/.config/socialweb-computer/app-password)" socialweb-computer run request --name vm3 \
  --atproto-identity-mode pdsAccount --atproto-handle <your handle> --atproto-pds-url <your PDS> --exec -- id

or typed (never in the shell history), then the same command without the ATPROTO_PASSWORD=... prefix:

read -rs ATPROTO_PASSWORD && export ATPROTO_PASSWORD

The requester puts the password into its own OpenBao.

Associated

  1. Make the identity: it prints its DID and waits (leave it running).
socialweb-computer run requester --name me --identity me --associate-with <your DID>
  1. In a second terminal, your account writes the grant and the endorsement, rkey the new DID. With goat (go install github.com/bluesky-social/goat@v0.2.3), signed in as your account (goat account login -u <your handle>, password from GOAT_PASSWORD):
D=$(jq -r .did ~/.local/state/socialweb-computer/requesters/me/ready.json)
echo "{\"\$type\": \"com.publicdomainrelay.temp.market.association\", \"agent\": \"$D\", \"createdAt\": \"$(date -u +%FT%TZ)\"}" \
  | goat record create --no-validate --rkey "$D" -
echo "{\"\$type\": \"link.ident.endorsement\", \"agent\": \"$D\"}" | goat record create --no-validate --rkey "$D" -
socialweb-computer internal association "$D" | jq -c '{roots, errors}'

You see {"roots":["<your DID>"],"errors":null} (before the records: the new DID itself).

  1. Ctrl-C the requester of step 1, then request with the identity; no sign-in:
socialweb-computer run request --identity me --name vm4 --exec -- id

To end the association, delete both records (goat record delete -c <collection> -r "$D").

A requester that stays up: run requester

A long-lived kcp you kubectl apply Infra, EphemeralInfra or ComputeContract objects to. From a clone of this repo (examples/infra/), in two terminals:

socialweb-computer run requester --name me --atproto-oauth-qr
eval "$(socialweb-computer run requester env me)"
sed "s|ssh-ed25519 AAAAREPLACE-WITH-YOUR-PUBLIC-KEY you@laptop|$(cat "$(jq -r .sshPublicKey ~/.local/state/socialweb-computer/requesters/me/ready.json)")|" \
  examples/infra/vm.yaml | kubectl apply -f -
kubectl wait infras.socialweb.computer/quickstart-vm --for=jsonpath='{.status.phase}'=Deployed --timeout=5m
socialweb-computer run requester ssh me --contract infra-quickstart-vm-vm1 --exec -- cat /root/quickstart

You see quickstart-vm-ok. Release it:

kubectl delete infras.socialweb.computer quickstart-vm

Ctrl-C in the first terminal stops the requester and keeps its DID and contracts; the same command starts it again. The objects: ../examples/infra/.

More

whatwhere
in a browsershell.socialweb.computer, acceptance/0009
ssh over webrtcacceptance/0003
an atirc agent on the VM (--agent)acceptance/0004
Kubernetes clustersgateway.md; your own: run requester --with-gateway, acceptance/0013
the requester as a systemd servicesocialweb-computer install requester -h