~ 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](../README.md#install)) 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 writes | in whose repo | rkey |
| --- | --- | --- |
| the bidder operator | the operator's | your DID |
| you | yours | the operator's DID (or the bidder's) |

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

```sh run=gate
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

```sh
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

```sh
socialweb-computer run request --name vm2 --hold --expires-in 2h --atproto-oauth-qr --exec -- uname -a
```

```sh
socialweb-computer run request ssh vm2
```

```sh
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.

| option | default |
| --- | --- |
| `--cpus N` | 2 |
| `--mem 8G` | 4G |
| `--nested-virt` | off: 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 webrtc` | ssh over iroh |
| `--state-dir <dir>` | `~/.local/state/socialweb-computer` |

## Who you run as

| mode | the requester is | use it when |
| --- | --- | --- |
| your account (`--atproto-oauth-qr` or `pdsAccount`) | your atproto account itself: its records go to your repo | you 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 account | a 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):

```sh
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:

```sh
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).

```sh
socialweb-computer run requester --name me --identity me --associate-with <your DID>
```

2. In a second terminal, your account writes the grant and the endorsement, rkey the new DID. With
[goat](https://github.com/bluesky-social/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`):

```sh
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).

3. Ctrl-C the requester of step 1, then request with the identity; no sign-in:

```sh
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:

```sh
socialweb-computer run requester --name me --atproto-oauth-qr
```

```sh
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:

```sh
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/](../examples/infra/).

## More

| what | where |
| --- | --- |
| in a browser | [shell.socialweb.computer](https://shell.socialweb.computer), [acceptance/0009](acceptance/0009-browser-page.md) |
| ssh over webrtc | [acceptance/0003](acceptance/0003-cli-webrtc-ssh.md) |
| an atirc agent on the VM (`--agent`) | [acceptance/0004](acceptance/0004-vm-atirc-agent.md) |
| Kubernetes clusters | [gateway.md](gateway.md); your own: `run requester --with-gateway`, [acceptance/0013](acceptance/0013-mixed-prod.md) |
| the requester as a systemd service | `socialweb-computer install requester -h` |