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

socialweb.computer/socialweb-computer-kcp

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

2 collaborators
0
0
1043 lines · 59.5 KB Raw History

<a id="operate-the-operator-notebook"></a>

Operator Notebook

This notebook moved here from CONTRIBUTING.md (plan 0062), text unchanged. It covers builds, hosts, bidders, the gateway, PDS ingress, troubleshooting, and a dev market network. To contribute a change, see CONTRIBUTING.md.

Related docs to read first:

Use a plain git worktree or branch, make small logical commits, and push as you go. Live work runs as the VM account (test-0001) from a dev build and a tree mirror that account can read. Commands marked "variables carry over" depend on values set in an earlier block.

Contents

Dev Build

Build the working tree, including uncommitted changes:

cd "$(git rev-parse --show-toplevel)"
scripts/build-socialweb-computer.sh --dev --publish /var/tmp/swc
export PATH=/var/tmp/swc/bin:$PATH
socialweb-computer version

A dev binary prints dev build, not reproducible along with its commit and dirty state.

Build artifacts land at these paths:

PathHolds
/var/tmp/swc/bin/socialweb-computerHost binary from --publish.
/var/tmp/swc/srcMirror of the working tree, readable by every account.
$HOME/.tmp/socialweb-computer-build/dev/<worktree>/socialweb-computerHost binary without --publish.
$HOME/.tmp/socialweb-computer-build/dev/<worktree>/<goos>_<goarch>/socialweb-computerPer-platform binary.

Options for scripts/build-socialweb-computer.sh:

OptionEffect
--devBuild the working tree for the host platform.
--publish DIRCopy the host binary to DIR/bin/socialweb-computer, mirror the tree to DIR/src, and run from DIR/src.
--sync-onlyWith --publish, re-mirror the tree without rebuilding.
--platform PTarget linux/amd64 or linux/arm64. Repeat for multiple platforms.
--commit REVCommit to build (default HEAD). Uncommitted changes are excluded.
--build-root DIRDirectory for checkouts, caches, and outputs (default $HOME/.tmp/socialweb-computer-build).
--update-pinsRebuild assets built from pinned upstream source (kcp, atirc) and write new pins to internal/versions/versions.json. make passes this flag. Assets built from the current commit are not pinned, and their hashes are recorded by the build (<asset>.built.json).

Restarting a Running Market Network

Every component runs inside the core process, so any component change requires rebuilding the core binary (--sync-only only re-mirrors the tree and does not rebuild). Rebuild and replace the core binary on a running instance:

cd "$(git rev-parse --show-toplevel)"
scripts/build-socialweb-computer.sh --dev --publish /var/tmp/swc
sudo -n -u test-0001 env HOME=/home/test-0001 XDG_RUNTIME_DIR=/run/user/$(id -u test-0001) \
  /var/tmp/swc/bin/socialweb-computer dev restart mn1 core --binary /var/tmp/swc/bin/socialweb-computer

dev restart supports two targets:

  • dev restart [<instance>] [<app>/]core replaces the core of an instance, or of a market network child application with <app>/ (replace mn1 with your instance).
  • dev restart <instance> [<app>/][<workspace>:][<kind>/]<component> restarts a single component via its kcp object without replacing the binary.

Release Build

make builds both release platforms and updates owned asset pins:

cd "$(git rev-parse --show-toplevel)"
make
C=$(git rev-parse HEAD)
ls "$HOME/.tmp/socialweb-computer-build/release/$C"

Release artifacts are written under $HOME/.tmp/socialweb-computer-build/release/<commit>/:

PathHolds
socialweb-computer-linux-amd64Host binary, Linux amd64.
socialweb-computer-linux-arm64Host binary, Linux arm64.
SHA256SUMSsha256 of both binaries.
release.jsonCommit, build mode, and one entry per platform.
version-linux-<arch>.json, .txtPinned version and sha256 of every embedded asset.

Build a single commit and platform:

cd "$(git rev-parse --show-toplevel)"
C=$(git rev-parse HEAD)
scripts/build-socialweb-computer.sh --platform linux/amd64 --commit "$C"
B=$HOME/.tmp/socialweb-computer-build/release/$C/socialweb-computer-linux-amd64
SHA=$(sha256sum "$B" | cut -d' ' -f1)
echo "$B $SHA"

If make modified internal/versions/versions.json, commit that update with the source change.

B and SHA are passed to install and upgrade --binary --sha256. CI publishes the same artifact names to the public bucket under releases/<tag>/ for a v* tag, and under main/<commit>/ and main/latest/ on main. The guest image is published once per pin at guest-images/<target>/<sha256 of the pinned image.json>/, and CI fetches it from there instead of rebuilding when its pins haven't changed.

Copy a release to another host and verify its checksum:

# variables carry over: C, B
R=$(dirname "$B")
DEST=user@host
scp "$B" "$R/SHA256SUMS" "$DEST:/var/tmp/"
ssh "$DEST" 'cd /var/tmp && grep " socialweb-computer-linux-amd64$" SHA256SUMS | sha256sum -c -'

Install or upgrade on the target host:

# variables carry over: DEST
SHA=$(ssh "$DEST" "awk '\$2 == \"socialweb-computer-linux-amd64\" {print \$1}' /var/tmp/SHA256SUMS")
ssh "$DEST" 'sudo install -m 0755 /var/tmp/socialweb-computer-linux-amd64 /usr/local/bin/socialweb-computer'
ssh "$DEST" "sudo /usr/local/bin/socialweb-computer install bidder --handle <handle>"

Fresh Host

Install the required packages before running install:

NeedUbuntu / DebianFedora / RHEL
newuidmap, newgidmap for per-VM user namespacesuidmapshadow-utils
ssh, ssh-keygenopenssh-clientopenssh-clients
curlcurlcurl
zoneinfo for embedded postgrestzdatatzdata
jq for examplesjqjq
# Ubuntu / Debian
sudo apt-get update && sudo apt-get install -y uidmap openssh-client curl tzdata jq
# Fedora / RHEL
# sudo dnf install -y shadow-utils openssh-clients curl tzdata jq

Host requirements:

  • 64-bit Linux, /dev/kvm, /dev/net/tun, systemd 253+, and cgroup v2.
  • /dev/kvm read-write for the kvm group.
  • One /etc/subuid and /etc/subgid range of N * 65536 ids for the bidder account (install bidder --vm-slots N, default 256).
  • For a gateway host: Caddy configured to import /etc/caddy/sites/*.caddy from /etc/caddy/Caddyfile.

install bidder and install gateway create their own accounts (swc-bidder, socialweb), subuid ranges, units, and linger automatically. Do not create them manually for a production install. For a dev host, create test-0001 once:

sudo useradd -m -s /bin/bash -G kvm -K SUB_UID_COUNT=0 -K SUB_GID_COUNT=0 test-0001
sudo usermod --add-subuids 100000-1148575 --add-subgids 100000-1148575 test-0001
sudo install -d -m 0700 -o test-0001 -g test-0001 ~test-0001/.ssh
sudo install -m 0600 -o test-0001 -g test-0001 ~/.ssh/authorized_keys ~test-0001/.ssh/
sudo loginctl enable-linger test-0001

Log in with ssh test-0001@<host> or sudo machinectl shell test-0001@, since sudo -u and runuser do not create a /run/user/<uid> session.

After installing, verify the host contract as the service account:

sudo runuser -u swc-bidder -- env XDG_RUNTIME_DIR=/run/user/$(id -u swc-bidder) \
  /var/lib/socialweb-computer/swc-bidder/bin/current/socialweb-computer \
  check-host -role bidder -state-dir /var/lib/socialweb-computer/swc-bidder
sudo runuser -u socialweb -- env XDG_RUNTIME_DIR=/run/user/$(id -u socialweb) \
  /var/lib/socialweb-computer/socialweb/bin/current/socialweb-computer \
  check-host -role gateway -state-dir /var/lib/socialweb-computer/socialweb

<a id="install-a-release-bidder"></a>

Installing a Release Bidder

See docs/bidder.md for release binaries, foreground bidders, and installed bidders. A locally built release binary installs the same way:

# variables carry over: C, B
sudo "$B" install bidder --handle <handle>

Bidder Association

A fresh install generates a new DID. Association uses the ident.link pair plus grant (docs/design/ident-link-associations.md):

  • The bidder adds https://ident.link/agent-of/<operator DID> to its DID document.
  • The operator's repo holds com.publicdomainrelay.temp.market.association/<bidder DID> and link.ident.endorsement/<bidder DID>.

The identity controller walks the bidder DID and writes the operator DID into MarketIdentity.status.associations without manual patching. The helper script reads the handle and password from a mode-0600 credentials file without printing either, then writes the grant and the endorsement:

HANDLE=bobvmbuilder.bsky.social
ACCOUNT=BOB
CREDS=$HOME/.bobvmbuilder_bsky_social_source
STATE=/var/lib/socialweb-computer/swc-bidder
K=$(sudo sh -c "ls $STATE/handles/*/kcp/admin.kubeconfig" | head -1)
BIDDER_DID=$(sudo kubectl --kubeconfig "$K" get marketidentity bidder -o jsonpath='{.status.did}')
deno run -A --no-lock scripts/associate-bidder.ts --creds "$CREDS" --account "$ACCOUNT" --agent-did "$BIDDER_DID"
sudo kubectl --kubeconfig "$K" get marketidentity bidder \
  -o jsonpath='{.status.phase}{" "}{range .status.conditions[*]}{.type}={.status} {.reason}{"\n"}{end}'

Wait for Associated=True. Pass --remove to delete the endorsement and then the grant.

A requester uses the same helper with its own DID. The operator writes the pair once in the operator's repo, the gateway adds the agent-of entry to the requester's DID doc, and the identity controller approves the requester once its walk reaches the operator. No manual approvedAssociations patch is needed. The gateway kcp lives under its state dir (default /var/lib/socialweb-computer/socialweb), and the requester MarketIdentity lives in the root:app workspace:

ACCOUNT=ALICE
CREDS=$HOME/.aliceoa_bsky_social_source
KGW=/var/lib/socialweb-computer/socialweb/kcp/admin.kubeconfig
GW=https://127.0.0.1:6443/clusters/root:app
REQUESTER_DID=$(sudo kubectl --kubeconfig "$KGW" --server "$GW" get marketidentity requester -o jsonpath='{.status.did}')
deno run -A --no-lock scripts/associate-bidder.ts --creds "$CREDS" --account "$ACCOUNT" --agent-did "$REQUESTER_DID"
sudo kubectl --kubeconfig "$KGW" --server "$GW" get marketidentity requester \
  -o jsonpath='{.status.phase}{" "}{range .status.conditions[*]}{.type}={.status} {.reason}{"\n"}{end}'

For non-association mode, patch the identity association to Skip and let the controller reconcile it. No agent-of entry, grant, or endorsement is written:

STATE=/var/lib/socialweb-computer/swc-bidder
K=$(sudo sh -c "ls $STATE/handles/*/kcp/admin.kubeconfig" | head -1)
sudo kubectl --kubeconfig "$K" patch marketbidder app --type=merge \
  -p '{"spec":{"identity":{"association":"Skip"}}}'
sudo kubectl --kubeconfig "$K" get marketidentity bidder \
  -o jsonpath='{.status.phase}{" "}{range .status.conditions[*]}{.type}={.status} {.reason}{"\n"}{end}'

Bidder on a Real Account (oauthQr)

You can run the bidder as an existing atproto account instead of a local PDS. Market records live in the account's repo, and the bidder keeps no local Pds.

Put the mode in the bidder's spec file (bidder-spec-file in config.json, preserved by install bidder and upgrade), never in a drop-in with its own ExecStart, because flags accepted by a newer binary may be rejected by an older binary after a rollback:

STATE=/var/lib/socialweb-computer/swc-bidder
HANDLE=bobvmbuilder.bsky.social
printf 'identity:\n  mode: oauthQr\n' | sudo install -m 0644 -o swc-bidder -g swc-bidder /dev/stdin $STATE/bidder-spec.yaml
sudo "$STATE/bin/current/socialweb-computer" install bidder --handle $HANDLE --bidder-spec-file $STATE/bidder-spec.yaml
sudo runuser -u swc-bidder -- env XDG_RUNTIME_DIR=/run/user/$(id -u swc-bidder) \
  systemctl --user daemon-reload
sudo runuser -u swc-bidder -- env XDG_RUNTIME_DIR=/run/user/$(id -u swc-bidder) \
  systemctl --user restart socialweb-computer-bidder@$HANDLE.service
K=$(sudo sh -c "ls $STATE/handles/*/kcp/admin.kubeconfig" | head -1)
until sudo kubectl --kubeconfig "$K" get marketidentity bidder -o jsonpath='{.status.pendingAction.url}' 2>/dev/null | grep -q .; do sleep 3; done
U=$(sudo kubectl --kubeconfig "$K" get marketidentity bidder -o jsonpath='{.status.pendingAction.url}')
deno run -A --no-lock scripts/oauth-signin.ts --creds ~/.bobvmbuilder_bsky_social_source --account BOB --url "$U"
sudo kubectl --kubeconfig "$K" get marketidentity bidder \
  -o jsonpath='{.spec.mode}{" "}{.status.phase}{" "}{.status.did}{" "}{.status.pdsUrl}{"\n"}'

Expect oauthQr Ready <the account DID> <the account PDS> and no resources from kubectl get pds. The QR url expires after 5 minutes.

<a id="upgrade-reinstall-uninstall"></a>

Upgrade, Reinstall, and Uninstall

Upgrade an installed bidder as its service account, then run install bidder again:

C=$(git rev-parse HEAD)
BIN=$HOME/.tmp/socialweb-computer-build/release/$C/socialweb-computer-linux-amd64
SHA=$(sha256sum "$BIN" | cut -d' ' -f1)
STATE=/var/lib/socialweb-computer/swc-bidder
sudo install -d -m 0755 /var/tmp/swc-release
sudo install -m 0755 "$BIN" /var/tmp/swc-release/socialweb-computer-${C:0:8}
STAGED=/var/tmp/swc-release/socialweb-computer-${C:0:8}
sudo runuser -u swc-bidder -- env XDG_RUNTIME_DIR=/run/user/$(id -u swc-bidder) \
  CONFIG_PATH_SOCIALWEB_COMPUTER=$STATE/config.json \
  "$STATE/bin/current/socialweb-computer" upgrade --binary "$STAGED" --sha256 "$SHA"
sudo "$STAGED" install bidder --handle <handle>

Upgrades preserve the state dir, OpenBao, DID, and association. rollback swaps bin/current and bin/previous and restarts the core:

sudo runuser -u swc-bidder -- env XDG_RUNTIME_DIR=/run/user/$(id -u swc-bidder) \
  CONFIG_PATH_SOCIALWEB_COMPUTER=/var/lib/socialweb-computer/swc-bidder/config.json \
  /var/lib/socialweb-computer/swc-bidder/bin/current/socialweb-computer rollback

To reinstall, run the same install bidder command with the new binary. Completed steps are skipped, and a changed config or unit restarts the core. If install refuses because bin/current does not match the binary you invoked, run upgrade --binary --sha256 first and then reinstall.

Uninstall while keeping state:

sudo /var/lib/socialweb-computer/swc-bidder/bin/current/socialweb-computer uninstall bidder

Uninstall and purge (removes the state dir, VMs, PDS repo, OpenBao, and any account created by install):

sudo /var/lib/socialweb-computer/swc-bidder/bin/current/socialweb-computer uninstall bidder --purge

Uninstall flags:

  • --force: proceed even while VM units are active (each stopped VM becomes Lost).
  • --json: print the result as JSON.
  • --account NAME: target a different account.

Notes before purging:

  • A fresh install over an old-shape workspace must purge first because the app WorkspaceType name is immutable.
  • Back up the state dir and Caddy sites before purging.
  • Purging generates a new DID on the next install, so the bidder must be associated again.
  • Purging preserves an adopted account (one not created by install) but removes the install record, so the next install bidder on that host requires --adopt-account.
  • A kcp storage shape change (a new kcp build) also requires a purge, since the new kcp cannot read the old store.

Dev Build on a Bidder Host

Running a dev binary requires --allow-dev-binary. Add --adopt-account only when adopting an account that has no install record (such as after a purge that kept the account), and --force only if uninstall refuses due to active VM units:

cd "$(git rev-parse --show-toplevel)"
HANDLE=bobvmbuilder.bsky.social
STATE=/var/lib/socialweb-computer/swc-bidder
scripts/build-socialweb-computer.sh --dev --publish /var/tmp/swc
C=$(git rev-parse HEAD)
sudo mkdir -p /var/tmp/swc-release
sudo install -m 0755 /var/tmp/swc/bin/socialweb-computer /var/tmp/swc-release/socialweb-computer-${C:0:8}
DEV=/var/tmp/swc-release/socialweb-computer-${C:0:8}
SHA=$(sha256sum "$DEV" | cut -d' ' -f1)
sudo "$DEV" uninstall bidder --purge --json
sudo "$DEV" install bidder --handle "$HANDLE" --allow-dev-binary --adopt-account \
  --state-dir "$STATE" --guest-image-source file:///var/lib/socialweb-computer/guest-image --dry-run
sudo "$DEV" install bidder --handle "$HANDLE" --allow-dev-binary --adopt-account \
  --state-dir "$STATE" --guest-image-source file:///var/lib/socialweb-computer/guest-image

If the install record and existing shape are compatible, upgrade in place instead:

# variables carry over: HANDLE, STATE, DEV, SHA
sudo runuser -u swc-bidder -- env XDG_RUNTIME_DIR=/run/user/$(id -u swc-bidder) \
  CONFIG_PATH_SOCIALWEB_COMPUTER=$STATE/config.json \
  "$STATE/bin/current/socialweb-computer" upgrade --binary "$DEV" --sha256 "$SHA" --allow-dev-binary
sudo "$DEV" install bidder --handle "$HANDLE" --allow-dev-binary

<a id="deploy-the-gateway"></a>

Deploying the Gateway

scripts/deploy.sh installs on a fresh host or upgrades an existing gateway. It ships gateway.env and the Gateway spec, writes the Caddy sites, hands over Caddy certificates, validates Caddy, and reloads it.

Run a fresh or routine deploy:

cd "$(git rev-parse --show-toplevel)"
BINARY=$HOME/.tmp/socialweb-computer-build/release/$(git rev-parse HEAD)/socialweb-computer-linux-amd64
SHA=$(sha256sum "$BINARY" | cut -d' ' -f1)
SSH_KEY=~/.ssh/id_ed25519_no_password \
SSH_TARGET=root@socialweb.computer SSH_PORT=1997 \
ACCOUNT=socialweb STATE_DIR=/var/lib/socialweb-computer/socialweb \
GATEWAY_ENV_FILE=$HOME/.tmp/deploy/gateway.env \
GATEWAY_SPEC_FILE=$HOME/.tmp/deploy/gateway-spec.yaml \
BINARY=$BINARY SHA256=$SHA scripts/deploy.sh

gateway.env and the Gateway spec are required on a fresh host, while an existing host can omit them to keep the files already in state. The script aborts on a digest mismatch. If BINARY is unset, it builds the release of HEAD.

Supported environment variables:

VariableMeaningDefault
BINARYRelease binary to ship.Build HEAD.
SHA256Published sha256 of BINARY.From SHA256SUMS when the script builds.
SSH_KEYSSH key.
SSH_TARGETDeploy host.root@socialweb.computer
SSH_PORTSSH port.1997
ACCOUNTGateway account.socialweb
STATE_DIRGateway state dir./var/lib/socialweb-computer/socialweb
DOMAINBase domain.socialweb.computer
ORIGINWeb app host.k8s.<DOMAIN>
KCP_ORIGINkcp host.kcp.<DOMAIN>
GATEWAY_ENV_FILEShipped as $STATE_DIR/gateway.env.
GATEWAY_SPEC_FILEShipped as /var/lib/socialweb-computer/gateway-spec-$ACCOUNT.yaml.
ALLOW_DEV_BINARYPass --allow-dev-binary to install gateway and upgrade.off

Once the gateway answers, scripts/deploy.sh handles the Caddy certificate handoff:

  • Extracts the kcp CA from the gateway's admin kubeconfig to /etc/caddy/socialweb-computer/kcp.crt.
  • Copies $STATE_DIR/tls/tls.crt to gateway.crt.
  • Copies $STATE_DIR/tls/edge-client.crt to edge-client.crt and its key (root:caddy, 0640) to edge-client.key.
  • Writes /etc/caddy/sites/k8s.<domain>.caddy and /etc/caddy/sites/kcp.<domain>.caddy, imports the sites directory, adds skip_install_trust, runs caddy validate, and reloads or restarts Caddy.

Verify the deploy:

curl -fsS https://k8s.socialweb.computer/api/config | jq
sudo caddy validate --config /etc/caddy/Caddyfile
sudo systemctl status caddy --no-pager
sudo ls -l /etc/caddy/socialweb-computer

k8s.<domain> proxies to the gateway API front on 127.0.0.1:8788. kcp.<domain> proxies to kcp 6443 without a client certificate, and to the certificate front 8444 with one.

After a fresh deploy, the requester has no gateway session, so cluster claims log no oauth session stored. Sign in with scripts/oauth-signin.ts --creds <file> --account ALICE --url https://k8s.socialweb.computer/ --start-api.

To upgrade, rerun scripts/deploy.sh with the new BINARY and SHA256. It executes upgrade --binary --sha256 as the gateway account, then runs install gateway again with bin/current. A routine upgrade preserves state, kcp objects, OpenBao, the requester DID, association, web sessions, and running components. A fresh install preserves nothing.

Uninstall and purge the gateway:

sudo /var/lib/socialweb-computer/socialweb/bin/current/socialweb-computer uninstall gateway --purge

Deploy inputs live on the orphan branch swc-deploy in the worktree ~/.tmp/deploy. Credential files ~/.aliceoa_bsky_social_source and ~/.bobvmbuilder_bsky_social_source are mode 0600. Never print, log, or commit their contents.

PDS Ingress Provider

A production PDS is a public HTTPS service. Its account DID document contains an atproto_pds service entry whose serviceEndpoint includes only scheme, host, and optional port. /.well-known/did.json, createAccount, and requestCrawl all use the same public host. The PDS may bind loopback while an IngressProxy provides the public URL.

Every app root selects its provider via spec.ingress. Production profiles (prod-qr, market-network, the requester default, and gateway prod) default to xrpc-subscription with ingressProxyHost: xrpc.fedproxy.com and IngressProxy/ingress. xrpc.fedproxy.com provides a stable https://<did-subdomain>.<host> for as long as the ingress identity keypair persists.

XRPC subscription config:

spec:
  ingress:
    provider: xrpc-subscription
    ingressRef:
      kind: IngressProxy
      name: ingress
    publicHost: example.fedproxy.com
    xrpc:
      ingressProxyHost: xrpc.fedproxy.com
      relayURL: https://relay.example

OpenTunnel config (optional, requires a stable route name):

spec:
  ingress:
    provider: opentunnel
    ingressRef:
      kind: IngressProxy
      name: ingress
    publicHost: example.example
    opentunnel:
      command: [/usr/local/bin/opentunnel, route, add]
      routeName: alice-pds
      localHost: 127.0.0.1:2583
      proxyProtocol: v2

Provider selection and persistence rules:

  • xrpc-subscription when ingress.xrpc.ingressProxyHost is set.
  • opentunnel when ingress.opentunnel is set.
  • Otherwise fail closed (no implicit local fallback and no GuestTlsUrl override).
  • iroh is recognized by the API and rejected until a later plan.
  • A missing provider, command, route name, or local host produces a named failure.
  • A provider that returns a different public URL on restart fails with StableHostMismatch.
  • Set Pds.spec.requireIngress on every production PDS. No account is created and no sign-in completes until the ingress is Ready.
  • The first public URL is persisted in Pds.spec.publicURL and Pds.spec.stableHost.

On run bidder and run request, --ingress-provider, --ingress-public-host, --ingress-xrpc-host, --ingress-relay-url, --ingress-opentunnel-command, --ingress-opentunnel-route-name, --ingress-opentunnel-local-host, and --ingress-opentunnel-proxy-protocol override the profile defaults. A gateway spec setting spec.ingress.opentunnel selects OpenTunnel. A MarketNetwork publishes one IngressProxy/dispatcher in status.network.ingress that children inherit.

Known gap (plan 0022): OpenTunnel is wired but not yet proven on a prod host. Check Pds.spec.publicURL, the ingress Exposure, and the DID document before trusting a standalone PDS whose host does not resolve.

Market Transport Modes

spec.comms.mode accepts XRPC, Firehose, or Both. Requesters default to Both, and bidders default to XRPC. PDS writes happen in every mode.

An external relay or firehose is configured as an EventSource backed by a RelayEventSource or JetstreamEventSource (with its endpoint in spec.url), referenced by the root's spec.comms.eventSourceRefs.

In Firehose and Both, a requester composes public sources automatically. spec.comms.relayUrls defaults to our relay https://relay.mini-cloud-0002.chadig.com (replaced by a market network's relay when present), and spec.comms.jetstreamUrls defaults to the two Jetstream v2 instances, wss://jetstream.us-east.bsky.network and wss://jetstream.us-west.bsky.network at /xrpc/network.bsky.jetstream.subscribeEvents. An empty list disables that source. A bidder composes no per-bidder stream. While it has live ComputeVMs, it composes requester streams from those requesters' DIDs, resuming from a stored cursor only if that cursor was saved within the last 10 minutes.

Create a RelayEventSource and EventSource, then point a bidder or requester at it:

K=$(sudo sh -c "ls /var/lib/socialweb-computer/swc-bidder/handles/*/kcp/admin.kubeconfig" | head -1)
sudo kubectl --kubeconfig "$K" apply -f - <<'YAML'
apiVersion: events.socialweb.computer/v1alpha1
kind: RelayEventSource
metadata: {name: relay-example}
spec: {url: https://relay.example}
---
apiVersion: events.socialweb.computer/v1alpha1
kind: EventSource
metadata: {name: relay-example}
spec: {backendRef: {group: events.socialweb.computer, kind: RelayEventSource, name: relay-example}}
YAML
# Firehose only: no submit XRPC; events come from the named EventSource
socialweb-computer run bidder --host-backend proc --profile prod-qr --handle <handle> \
  --comms-mode Firehose --comms-event-source relay-example
# Both: XRPC first, then the public sources and the named EventSource
socialweb-computer run request --name demo \
  --comms-mode Both --comms-event-source relay-example

Operational rules for market transport:

  • A bidder in Firehose or Both requires a source (a named EventSource or the network relay). Otherwise the root fails closed instead of falling back to XRPC.
  • Every market EventStream for a role delivers to one sink, which drops any uri|cid seen within the last 15 s and logs market_event_duplicate_dropped.
  • StateSync inboxes are not the dedup source of truth: the requester keeps only records for its own ComputeContracts, and the bidder keeps only RFPs, accepts whose bid is in its repo, and events whose receipt is in its repo.
  • The requester prunes the inbox of a Released or Failed contract 10 minutes after it is Acked. The bidder prunes every Acked inbox after 10 minutes.
  • Switching back to XRPC deletes the root's market EventStreams.

Account Modes

spec.identity.mode controls how the account and PDS are backed:

spec.identity.modeWhat runsAssociation
localRepo (default)Local Pds component and a new DIDRequireApproval or Skip
pdsAccountExisting account on a RemotePDS, with password in OpenBaoNone
oauthBrowserExisting account signed in from a browser callbackNone
oauthQrExisting account signed in by scanning a QRNone
oauthDelegatedExisting account signed in by a delegated flowNone
oauthSessionProxyThe gateway's per-account session: spec.did and a spec.sessionRef to that session in the vaultNone

run bidder and run request do not set oauthSessionProxy. A cluster claim uses it to act as the signed-in account.

Examples of configuring account modes:

# Managed, unassociated: patch the root after it exists (or use run request --skip-qr)
K=$(sudo sh -c "ls /var/lib/socialweb-computer/swc-bidder/handles/*/kcp/admin.kubeconfig" | head -1)
sudo kubectl --kubeconfig "$K" patch marketbidder app --type=merge \
  -p '{"spec":{"identity":{"association":"Skip"}}}'
# Existing account on another PDS (password comes from ATPROTO_PASSWORD)
export ATPROTO_PASSWORD=...   # never echo it
socialweb-computer run bidder --host-backend proc --profile prod-qr --handle <handle> \
  --atproto-identity-mode pdsAccount --atproto-pds-url https://pds.example
# OAuth browser
socialweb-computer run request --name demo \
  --atproto-identity-mode oauthBrowser --atproto-pds-url https://pds.example

pdsAccount fails closed if no PDS is specified, and OAuth modes fail closed without a pdsUrl or a resolvable handle. Tokens stay in OpenBao, and MarketIdentity.status holds refs only.

For a prod CLI requester (run request without --network), behavior depends on whether --atproto-oauth-qr is set. With --atproto-oauth-qr, MarketIdentity requester reads and writes its oauth session in the invocation's own OpenBaoServer requester (mount requester, identity/requester/pds-session) and requests requester role scopes (including guest.*) through qr.fedfork.com. On stderr, the CLI prints identity requester is AwaitingScan (no DID yet): scan the qr url to sign in, followed by identity requester pendingAction scanQr url <url> expiresAt <RFC 3339> for each new URL. Sign in with scripts/oauth-signin.ts --url "<url>" (see AGENTS.md, Prod deployments). Once waiting on a person, it waits without a deadline, and Ctrl-C stops it before any contract is posted.

With the default localRepo, run request generates a new DID per invocation and waits in AwaitingApproval for the operator's endorsement + grant (scripts/associate-bidder.ts --requester-did <did>, printed by the CLI with the DID). --skip-qr skips approval, but leaves the requester without an operator so requester-tangled-vouch vouches no prod bidder.

<a id="verify-public-pds-did-and-requestcrawl"></a>

Verifying Public PDS, DID, and requestCrawl

Check the resolved DID, PDS document, records, and requestCrawl response:

HANDLE=bobvmbuilder.bsky.social
DID=$(curl -fsS "https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=$HANDLE" | jq -r .did)
PDS=$(curl -fsS "https://plc.directory/$DID" | jq -r '.service[] | select(.id == "#atproto_pds") | .serviceEndpoint')
HOST=${PDS#https://}; HOST=${HOST%%/*}
echo "$DID $PDS $HOST"
curl -fsS "$PDS/.well-known/did.json" | jq '{id, service}'
curl -fsS "$PDS/xrpc/com.atproto.repo.listRecords?repo=$DID&collection=com.publicdomainrelay.temp.badgeBlueKeys" | jq '.records | length'
curl -fsS -X POST "$PDS/xrpc/com.atproto.sync.requestCrawl" -H 'Content-Type: application/json' \
  -d "{\"hostname\":\"$HOST\"}" -o /dev/null -w '%{http_code}\n'

serviceEndpoint must be HTTPS with no path, and the final command returns 200. Confirm the crawl in the PDS journal:

sudo journalctl _SYSTEMD_USER_UNIT='socialweb-computer-bidder@<handle>.service' --since -5min | grep -i requestCrawl

hat-9 and hat-7

SSH aliases on the lead's workstation are ssh hat-9, ssh hat-7, and ssh socialweb.computer. No credentials belong in this document, so use your own SSH key.

HostState rootBidder DIDAssociation
this host/var/lib/socialweb-computer/swc-bidderdid:plc:vxd7pmlhw6bnpyu6wngewthnAssociated, RequireApproval
hat-9/var/lib/socialweb-computer/swc-bidderdid:plc:cjuftobfmmmdkmblcl4h54ebAssociated, RequireApproval
hat-7/var/lib/socialweb-computer/swc-bidderdid:plc:exjutifioeu2p7oorbdrex2oAssociationSkipped, Skip

The bidder state dir is readable only by root:

ssh hat-9
sudo ls /var/lib/socialweb-computer/swc-bidder/handles
sudo runuser -u swc-bidder -- env XDG_RUNTIME_DIR=/run/user/$(id -u swc-bidder) \
  systemctl --user status 'socialweb-computer-bidder@<handle>.service'

Troubleshooting

Check units, logs, and kcp status. Service accounts are swc-bidder for a bidder and socialweb for a gateway:

# units as the account (the unit itself reads the backend and state from config.json)
sudo runuser -u swc-bidder -- env XDG_RUNTIME_DIR=/run/user/$(id -u swc-bidder) \
  /var/lib/socialweb-computer/swc-bidder/bin/current/socialweb-computer units list \
  --host-backend systemd-user --state-dir /var/lib/socialweb-computer/swc-bidder
# bidder unit and journal (system journal: swc-bidder is a system account)
sudo runuser -u swc-bidder -- env XDG_RUNTIME_DIR=/run/user/$(id -u swc-bidder) \
  systemctl --user status 'socialweb-computer-bidder@<handle>.service'
sudo journalctl _SYSTEMD_USER_UNIT='socialweb-computer-bidder@<handle>.service' --since -10min
# gateway unit and journal
sudo systemctl --user -M socialweb@ status socialweb-computer-gateway.service
sudo journalctl --user -M socialweb@ -u socialweb-computer-gateway.service --since -10min
# kcp status (there is no kubectl kcp plugin in this tree; use the admin kubeconfig)
K=$(sudo sh -c 'ls /var/lib/socialweb-computer/swc-bidder/handles/*/kcp/admin.kubeconfig' | head -1)
sudo kubectl --kubeconfig "$K" get --raw /readyz
sudo kubectl --kubeconfig "$K" get workspaces,marketbidder,marketidentity,pds,exposure
sudo kubectl --kubeconfig "$K" get marketbidder app -o jsonpath='{.status.phase}{"\n"}'
sudo kubectl --kubeconfig "$K" get marketidentity bidder -o jsonpath='{.spec}{"\n"}{.status}{"\n"}'
# a dev instance
sudo -n -u test-0001 env HOME=/home/test-0001 XDG_RUNTIME_DIR=/run/user/$(id -u test-0001) \
  /var/tmp/swc/bin/socialweb-computer dev status --instance mn1
sudo -n -u test-0001 env HOME=/home/test-0001 XDG_RUNTIME_DIR=/run/user/$(id -u test-0001) \
  /var/tmp/swc/bin/socialweb-computer dev logs core --instance mn1 --tail 50
# gateway's embedded k3s on a host without kubectl
K3S=$(sudo find /var/lib/socialweb-computer/socialweb/runtime -name k3s -type f | head -1)
sudo "$K3S" kubectl get ns

Key paths on a host:

ItemPath
Bidder state/var/lib/socialweb-computer/swc-bidder
Gateway state/var/lib/socialweb-computer/socialweb
kcp admin kubeconfig<state>/handles/<hash>/kcp/admin.kubeconfig
Tenant k3s kubeconfig<state>/.../server/cred/admin.kubeconfig
Core binary<state>/bin/current/socialweb-computer
Previous binary<state>/bin/previous/socialweb-computer

Dev Market Network

Run as the VM account on a prepared host. The first dev up downloads and verifies the guest image unless --guest-image-source specifies one:

cd "$(git rev-parse --show-toplevel)"
swc() {
  sudo -n -u test-0001 env HOME=/home/test-0001 \
    XDG_RUNTIME_DIR=/run/user/$(id -u test-0001) \
    DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u test-0001)/bus \
    /var/tmp/swc/bin/socialweb-computer "$@"
}
swc dev up --instance mn1 --profile market-network --bidders 1 --with-gateway --vm-host-backend systemd-user
swc dev status --instance mn1 | jq '.network.status.apps'
swc status --instance mn1
eval "$(swc dev env --instance mn1)"
swc dev logs core --instance mn1 --tail 50
swc dev down --instance mn1

Rent a VM through the RFP flow:

# variables carry over: swc
sudo -n -u test-0001 tee /var/tmp/swc-secrets.json >/dev/null <<'JSON'
[{"path":"/root/x","value":"hello"}]
JSON
swc run request --network mn1 --secrets /var/tmp/swc-secrets.json --exec -- cat /root/x
swc run request list --json | jq -r '.[].name'
swc run request release "$(swc run request list --json | jq -r '.[0].name')"

Flags and behavior for run request:

  • run request flags: --network, --name, --identity, --secrets, --tunnel, --exec, --hold, --skip-ssh, --contract-timeout, --transport, --tag.
  • run request ssh, resume, and proxy also take --contract and --log-level.
  • --tunnel syntax: <tag>:<port>[:<transport>][:shell[=<envFile>]], with transport opentunnel (default) or webrtc.
  • --identity <name> reuses a single localRepo did:plc, repo, and embedded PDS state across invocations at <state-root>/identities/<name>/ (the first run requires --skip-qr). Each invocation still creates a fresh kcp and OpenBao. Only one PDS process per identity store is allowed, and ssh/release attach to a running kcp. release preserves the identity store. Delete it manually only after the invocation is released.

Run a bidder as a child application of the market network:

# variables carry over: swc
swc run bidder --host-backend proc --profile market-network --network mn1 --handle b2.mn1.bob.test

Passing --fg keeps it running until Ctrl-C, which removes it from the network. With --network, the profile defaults to market-network.

Foreground Bidder (No Systemd)

See docs/bidder.md for the production command and prerequisites.

Running run bidder --host-backend proc without --network starts a standalone instance named b-<handle-with-dashes>. It runs bringUp of a quick-profile instance under devsup (which terminates with the process when --fg is set), creates the MarketBidder root object, and waits for identity and Ready. It first runs the bidder host checks from check-host -role bidder, excluding the systemd checks.

Join a dev market network over the market protocol only, in its own kcp (standalone path, no public PLC DID):

# variables carry over: swc
swc dev status --instance mn1 | jq .network.status > /var/tmp/swc/mn1.json
swc run bidder --market-network-file /var/tmp/swc/mn1.json --handle b3.mn1.bob.test --host-backend proc --fg
K=/home/test-0001/.local/state/socialweb-computer/dev/b-b3-mn1-bob-test/kcp/admin.kubeconfig
sudo -n -u test-0001 kubectl --kubeconfig "$K" patch marketbidder app --type=merge \
  -p '{"spec":{"identity":{"association":"Skip"}}}'
swc run request --network mn1 --exec -- uname -r
swc status --instance b-b3-mn1-bob-test

Ctrl-C (or SIGTERM) on run bidder prints the dev down --keep-state report (vmsStopped, remaining: []). Run swc dev down --instance b-b3-mn1-bob-test to delete its state.

<a id="run-the-requester-where-the-release-assets-are-not-staged"></a>

Running the Requester Without Staged Release Assets

run request starts its own kcp (kine over sqlite, the port-0 front, one kcp slot, and core) as units of the proc placement backend (devsup, hostsvc backend proc), then posts the RFP from the requester inside the core process. Because the backend has a darwin implementation, the requester runs natively on macOS. The bidder role does not, because it requires the launchd backend and Virtualization.framework runtime (plan 0012).

On a release platform, scripts/build-socialweb-computer.sh --dev stages every pinned asset so the binary resolves them automatically. Use this recipe when staging cannot run, such as on macOS (not a release platform in internal/versions/versions.json) or on a Linux host where staging fails on an unrelated pinned asset (for example, a non-rustup-managed rustc). Pass the four executables by path instead.

<a id="the-four-executables"></a>

Required Executables

Pass these four executables to run request:

ExecutableWhyPin
kcpAPI server for the invocation's kcpBuilt from the pinned commit. kcp --version must match the version pinned in internal/versions/versions.json.
kinesqlite etcd shim under kcpRelease binary, sha256 pinned
baoRequester's own OpenBao (vault phase of its set)Release archive, verified against checksums.txt
socialweb-pipe (--dumbpipe-path)iroh ssh into the guest (--transport iroh, the default) on our relay (plan 0058)Built from this commit's rust/ (cargo build --release -p socialweb-pipe in rust/, embedded in releases)

internal/versions/versions.json stores each asset's URL and sha256 under assets.<name>.fetch.<os>/<arch>, so you can fetch and verify directly from the checkout:

v=internal/versions/versions.json
url=$(jq -r '.assets.kine.fetch["linux/amd64"].url' "$v")
sha=$(jq -r '.assets.kine.fetch["linux/amd64"].sha256' "$v")
curl -fsSL -o kine "$url" && echo "$sha  kine" | sha256sum -c -

Build kcp from source with CGO_ENABLED=0 and the pinned version flags:

git clone https://github.com/johnandersen777/kcp
git -C kcp checkout de7d521f6278615689df17b779cd89afa9d334a0
cd kcp && CGO_ENABLED=0 go build -trimpath -buildvcs=false -mod=readonly \
  -ldflags="-s -w -buildid= \
    -X k8s.io/client-go/pkg/version.gitVersion=v1.36.0+kcp-v0.33.0-164-gde7d521f627861 \
    -X k8s.io/client-go/pkg/version.gitCommit=de7d521f6278615689df17b779cd89afa9d334a0 \
    -X k8s.io/client-go/pkg/version.gitTreeState=clean \
    -X k8s.io/component-base/version.gitVersion=v1.36.0+kcp-v0.33.0-164-gde7d521f627861 \
    -X k8s.io/component-base/version.gitCommit=de7d521f6278615689df17b779cd89afa9d334a0 \
    -X k8s.io/component-base/version.gitTreeState=clean" \
  -o ../bin/kcp ./cmd/kcp

Build and runtime notes:

  • Generated deepcopy imports encoding/json/jsontext, so Go 1.26 needs GOEXPERIMENT=jsonv2 (enabled by default in Go 1.27).
  • CGO_ENABLED=0 avoids requiring libc headers.
  • GOTOOLCHAIN=go1.26.6 (matching go.mod) builds cleanly if the host's Go version differs.
  • Outside a -tags embed_deno release build, the policy engine does not embed Deno, so deno must be on PATH when PolicyEngine starts (internal/policyengine/deno, pinned v2.9.3). Without it, the root stays in Provisioning with PolicyEngine/policy-engine ready=false phase=Pending.

Build this tree and run one invocation with explicit paths:

go build -o bin/socialweb-computer ./cmd/socialweb-computer
bin/socialweb-computer run request --name host1 \
  --kcp-path "$PWD/bin/kcp" --kine-path "$PWD/bin/kine" --bao-path "$PWD/bin/bao" --dumbpipe-path "$PWD/bin/dumbpipe" \
  --skip-qr --exec -- uname -a

macOS

scripts/build-socialweb-computer.sh --dev refuses darwin because it builds only the release platforms listed in versions.json, where darwin/arm64 is a seam with only vfkit pinned. Build with plain go build (Go 1.27 or newer) and pass the four paths as above. Stage these once into ~/.tmp/swc-mac/bin:

  • darwin kcp
  • kine (cgo sqlite build of v0.17.1: CGO_ENABLED=1 CGO_CFLAGS="-DSQLITE_USE_ALLOCA=1" go build -tags nats)
  • bao (openbao_2.6.2_darwin_arm64.tar.gz)
  • socialweb-pipe (cargo build --release -p socialweb-pipe in rust/)

Linux

On a release platform, scripts/build-socialweb-computer.sh --dev --publish /var/tmp/<work> stages every pinned asset once so run request needs no path flags. If staging fails on an asset the requester does not use (for example, a non-rustup-managed rustc blocking meshd downloads), follow the explicit-path recipe above with GOTOOLCHAIN and GOEXPERIMENT=jsonv2 as on Windows.

Windows

Use WSL2. A native Windows requester needs a windows placement backend, which does not exist yet (plan 0011). Windows 11 WSL2 supports AF_UNIX, so devsup, kine, and front sockets work unchanged. Copy the checkout into the distro, install the toolchain, and run as a non-root user (dev refuses uid 0).

In a WSL shell (wsl.exe -d Ubuntu), as root:

apt-get update && apt-get install -y golang-go jq zstd make
useradd -m -s /bin/bash swc

Then, as that user (su - swc):

CGO_ENABLED=0 GOEXPERIMENT=jsonv2 GOTOOLCHAIN=go1.26.6 \
  go build -o ~/bin/socialweb-computer ./cmd/socialweb-computer
~/bin/socialweb-computer run request --name wsl1 \
  --kcp-path ~/bin/kcp --kine-path ~/bin/kine --bao-path ~/bin/bao --dumbpipe-path ~/bin/dumbpipe \
  --skip-qr --exec -- uname -a

The distro's golang-go is 1.26, which is why GOEXPERIMENT=jsonv2 and the toolchain pin are needed. The Ubuntu image's gcc lacks libc headers, which CGO_ENABLED=0 avoids. Use the linux/amd64 binaries from above, and make sure deno is on PATH.

<a id="what-differs-on-macos"></a>

macOS Differences

Runtime behavior on macOS differs from Linux in these areas:

AreaOn macOS
XDG_RUNTIME_DIRUsually unset. The instance runtime dir, devsup socket, and front control socket fall back to <state-dir>/run.
front fd storeNot offered by the proc backend (hostsvc Capabilities.FDStore is false), so the front binds its own address and the kcp slot restarts when the front moves to a new port.
unix socket pathssun_path is 104 bytes, so the limit is 103 instead of 107.
bound portsRead via lsof (about 25 ms per read) instead of /proc.
process identityUses kinfo start time and kern.boottime instead of start ticks and /proc.
child reapingNo subreaper. Orphaned grandchildren reparent to launchd and are killed by the env-attribution sweep.

Reading the Result

Inspect the root with kubectl --kubeconfig <state-dir>/requests/<name>/dev/<name>/kcp/admin.kubeconfig get marketrequester app (Ready once the pod-less stack is up), and view the posted RFP with get computecontract. Because the requester's PDS, ingress proxy, and policy engine all run inside the core process, nothing else is required on the host.

The RFP reaches public bidders through the ingress relay. The contract leaves Requesting with a verified receipt, moves to Held when the guest publishes its address, and --exec runs over iroh ssh before the contract is released. --skip-ssh rents, reports, and releases without opening a session.

Deno Sandbox Bidder

A bidder can offer a non-VM compute kind. Setting computeKind: deno on the contract (kind in the payload) runs spec.userData as a Deno program on the bidder host and reports its output instead of booting a firecracker guest. Because it needs no KVM, guest image, or VM runtime, macOS and WSL2 hosts can run this bidder.

API pieces for the deno sandbox kind:

  • kind on com.publicdomainrelay.temp.compute.vm (defaults to vm when absent).
  • computeKind on the contract and Bidder spec.
  • DenoSandbox backend kind on ComputeVM.
  • Guest event com.publicdomainrelay.temp.compute.events.vm.sandbox (exitCode, timedOut, stdout, stderr).

The sandbox runs deno run --no-remote --no-lock --deny-net --deny-run --deny-ffi with read/write access limited to its own working directory and a 2-minute timeout.

A bidder serves only its configured kinds and drops RFPs of other kinds before bidding:

run bidder --host-backend proc --compute-kinds deno --handle <handle> --fg \
  --state-dir <state> --kcp-path <kcp> --kine-path <kine> --bao-path <bao> \
  --openbao-plugin-dir <dir with both openbao plugins>

Behavior of --compute-kinds:

  • --compute-kinds accepts vm, deno, or both (vm,deno), defaulting to vm. A bidder serving both selects a firecracker guest or sandbox per accepted RFP, and both count against maxConcurrentGuests.
  • Without vm, the bidder opens no VM runtime, skips KVM preflight, and applies the bidder API sets itself (internal/computevm ApplyBidderSets), since the ComputeVM controller is not started.
  • Without deno on PATH (pinned v2.9.3), a bidder declines deno RFPs rather than bidding on work it cannot run.
  • On macOS, the two OpenBao plugins require the darwin pins carried in internal/versions/versions.json.

Request a deno sandbox with --compute-kind, passing the program in the usual user-data file:

run request --name deno1 <the four paths> --skip-qr --compute-kind deno --user-data prog.ts

--compute-kind deno skips ssh because there is no guest. The contract transitions to Held once the sandbox reports its result, and summary.json records contract.sandbox {exitCode, timedOut, stdout, stderr}. Example program:

console.log(`hello from ${Deno.build.os}/${Deno.build.arch}`);

Market caveat: bidders running older code ignore kind, so they may still bid on a deno RFP and boot a VM if they win. On a shared market, pin the requester to your deno bidder with --allow-bidder-dids <did> (from MarketIdentity bidder status, with --deny-bidder-dids as the inverse).

Observed output on each host: macOS sandbox://... with hello from darwin/arm64, hat-7 and WSL2 hello from linux/x86_64, exit 0, release 200.

<a id="the-proof-recipe-three-hosts"></a> <a id="run-a-bidder-that-sells-a-deno-sandbox"></a>

Three-Host Proof Recipe

Copy this shared request runner to every host (it prints the fields checked by the proof):

#!/usr/bin/env bash
# run-one.sh <kind> <name> <bidder-did> <userdata>; env SWC_BIN SWC_STATE KCP KINE BAO
set -e
kind="$1"; name="$2"; did="$3"; ud="$4"
extra=()
[ "$kind" = deno ] && extra=(--compute-kind deno)
"$SWC_BIN" run request --name "$name" --state-dir "$SWC_STATE" \
  --kcp-path "$KCP" --kine-path "$KINE" --bao-path "$BAO" \
  --ready-timeout 90s --network-timeout 180s --contract-timeout 5m --skip-ssh \
  --skip-qr --allow-bidder-dids "$did" "${extra[@]}" --user-data "$ud" \
  > "$SWC_STATE/$name.log" 2>&1
grep -E "\"phase\": \"(Held|Released|Failed)\"|exitCode|\"stdout\"|vmAddress|releaseStatus|winnerDid" "$SWC_STATE/$name.log" | tail -6 | cut -c1-190

Start a bidder on each host (foreground under devsup, which exits with the process):

# macOS, deno only
nohup ~/.tmp/swc-mac/bin/socialweb-computer run bidder --host-backend proc --compute-kinds deno \
  --handle probe.deno.test --fg --state-dir ~/.tmp/swc-mac/state \
  --kcp-path ~/.tmp/swc-mac/bin/kcp --kine-path ~/.tmp/swc-mac/bin/kine --bao-path ~/.tmp/swc-mac/bin/bao \
  --openbao-plugin-dir ~/.tmp/swc-mac/bin/plugins > ~/.tmp/swc-mac/bidder-mac-deno.log 2>&1 &

# hat-7, both kinds (VM assets at explicit paths; see the VM half below)
B=$HOME/.tmp/swc-req/bin
nohup "$B/socialweb-computer" run bidder --host-backend proc --compute-kinds vm,deno --handle probe.mixed.test --fg \
  --state-dir "$HOME/.tmp/swc-req/state-mixed" \
  --kcp-path "$B/kcp" --kine-path "$B/kine" --bao-path "$B/bao" --openbao-plugin-dir "$B/plugins" \
  --userns-stage-path "$B/vm/swc-userns-stage" --pasta-path "$B/vm/pasta" \
  --vmexec-path "$B/vm/socialweb-vmexec" --firecracker-path "$B/vm/firecracker" \
  > "$HOME/.tmp/swc-req/mixed.log" 2>&1 &

# desktop: WSL2, deno only, as a non-root user (dev refuses uid 0)
wsl.exe -d Ubuntu -u root -e bash -c 'su - swc -c "export PATH=/usr/local/bin:\$PATH; cd ~; nohup /var/tmp/swc-req/bin/socialweb-computer run bidder --host-backend proc --compute-kinds deno --handle probe.deno.test --fg --state-dir /home/swc/.tmp/swc-req/state --kcp-path /var/tmp/swc-req/bin/kcp --kine-path /var/tmp/swc-req/bin/kine --bao-path /var/tmp/swc-req/bin/bao --openbao-plugin-dir /var/tmp/swc-req/bin/plugins > /home/swc/bidder-deno.log 2>&1 < /dev/null & echo started"'

Wait for the root and read the bidder DID for the allowlist:

KUBECONFIG=<state>/dev/<instance>/kcp/admin.kubeconfig kubectl get marketbidder app -o jsonpath='{.status.phase}'
KUBECONFIG=<state>/dev/<instance>/kcp/admin.kubeconfig kubectl get marketidentity bidder -o jsonpath='{.status.did}'

Run the matrix directly on macOS and hat-7:

export SWC_BIN=$HOME/.tmp/swc-mac/bin/socialweb-computer SWC_STATE=$HOME/.tmp/swc-mac/state \
       KCP=$HOME/.tmp/swc-mac/bin/kcp KINE=$HOME/.tmp/swc-mac/bin/kine BAO=$HOME/.tmp/swc-mac/bin/bao
bash run-one.sh vm   m3-mac-vm   <bidder-did> $HOME/.tmp/swc-mac/vm.yaml
bash run-one.sh deno m3-mac-deno <bidder-did> $HOME/.tmp/swc-mac/prog.ts

On desktop, embed the arguments inside the wrapper script instead of passing them on the command line, because nested invocations across ssh, MSYS bash, wsl.exe, and su -c drop positional parameters:

# ~/swc-desk/wsl-deno.sh
wsl.exe -d Ubuntu -u root -e bash -c 'su - swc -c "export PATH=/usr/local/bin:\$PATH SWC_BIN=/var/tmp/swc-req/bin/socialweb-computer SWC_STATE=/home/swc/.tmp/swc-req/state KCP=/var/tmp/swc-req/bin/kcp KINE=/var/tmp/swc-req/bin/kine BAO=/var/tmp/swc-req/bin/bao; bash /home/swc/run-one.sh deno d-wsl-deno <bidder-did> /home/swc/prog.ts"'
ssh desktop 'bash ~/swc-desk/wsl-deno.sh' | tr -d '\r' | tail -5

User-data files for deno and VM requests:

// prog.ts, the program of a deno request
console.log(`hello from ${Deno.build.os}/${Deno.build.arch}`);
# vm.yaml, the cloud-init of a vm request
#cloud-config
runcmd:
  - [ sh, -c, "echo vm-ok > /tmp/vm-ok" ]

For host prep, build cmd/socialweb-computer with the pinned toolchain (CGO_ENABLED=0 GOEXPERIMENT=jsonv2 GOTOOLCHAIN=go1.26.6), ship the tree via rsync to a Linux host or a tar stream into WSL2, and stage the two OpenBao plugins into a directory matching the pins.

The VM half on hat-7 also requires four pinned assets, a subuid range for the account, and /dev/kvm:

scripts/stage-assets.sh --platform linux/amd64 --asset firecracker --asset pasta --blobs $HOME/.tmp/swc-req/vmblobs
scripts/stage-assets.sh --platform linux/amd64 --asset socialweb-vmexec --print-pins --blobs $HOME/.tmp/swc-req/vmblobs
scripts/stage-assets.sh --platform linux/amd64 --asset swc-userns-stage --blobs $HOME/.tmp/swc-req/vmblobs
for a in firecracker pasta socialweb-vmexec swc-userns-stage; do
  zstd -q -d -c $HOME/.tmp/swc-req/vmblobs/linux_amd64/$a.tar.zst | tar -x -C $HOME/.tmp/swc-req/bin/vm
done
sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 "$USER"

--print-pins is required on a dirty tree because socialweb-vmexec embeds internal/versions/versions.json, so a modified pin makes the built binary differ from its own pin and stage-assets.sh rejects it. The live run uses the staged binaries passed to the bidder by path.

Each run keeps its log at <state>/<name>.log, which can be re-checked with grep -E "exitCode|vmAddress|releaseStatus" <state>/<name>.log.

<a id="the-web-worker-runner-in-the-browser-build"></a>

Web Worker Runner in the Browser Build

../wasm (the kcp-plus-socialweb js/wasm checkout) builds the runner into two artifacts:

  • socialweb-wasm/cmd/sandbox-wasm: a small module exposing sandboxAvailable(), sandboxKind(), and sandboxRun(source, timeoutMs), which returns a Promise. Built with GOOS=js GOARCH=wasm go build -modfile=.go.wasm.mod ./cmd/sandbox-wasm with -replace pointing at the tree under test.
  • Combined page module (cmd/kcp-wasm): exposes socialwebSandboxAvailable and the page export socialwebSandboxRun (via socialwebCall, answered by __kcpResolve).

Both exports are asynchronous by contract. sandbox.Runner.Run blocks its goroutine until the worker responds, and JavaScript events cannot be delivered while a syscall/js callback is on the stack. Never call Run synchronously from a JS callback. The export hands off to a goroutine and resolves via a Promise (or __kcpResolve). In Go code, always call Run from a Go goroutine, never inside a js.FuncOf callback.

Verified on 2026-10-27 with sandbox-wasm (same Go source) in headless Chrome (CDP Runtime.evaluate loading wasm_exec.js + sandbox.wasm) and in Deno (same two files via WebAssembly.instantiate):

  • Available true, kind webworker.
  • console.log("hi from worker", 1 + 1) -> {"exitCode":0,"stdout":"hi from worker 2"}.
  • Throw -> {"exitCode":1,...} with stdout: "before" and the stack on stderr.
  • Awaited program -> {"exitCode":0,"stdout":"v+1 42"}.
  • Program outliving its timeout -> {"exitCode":-1,"timedOut":true}.

The combined page module carries the export but was not exercised through the shell page in this pass, because booting cmd/kcp-wasm requires the shell's fs shim and worker protocol not provided by the bare test page.

Sandbox Runtimes

The sandbox implements sandbox.Runner (internal/contract/sandbox): Run(Program{Source, Dir, Timeout}) returns {ExitCode, TimedOut, Stdout, Stderr}, Available() reports whether the runtime can run a program, and Kind() names it.

PackageBuildRuns the program as
internal/sandbox/deno!jsdeno run --no-remote --no-lock --quiet --allow-read=<dir> --allow-write=<dir> --deny-net --deny-run --deny-ffi --ext ts -, program on stdin
internal/sandbox/workerjs && wasmWeb Worker: the shim in worker.go captures console.*, runs the program, and posts {exitCode, stdout, stderr} back

Build tags select the implementation in the composition layer: internal/stack/componentcore/sandbox_deno.go and sandbox_worker.go both define newSandbox(), so neither the bidder nor the policy engine names a runtime. This lets a browser-hosted bidder (the kcp-plus-socialweb wasm module in the wasm checkout, which already overlays JS versions of hostos, portscan, and the atproto stores) serve kind: deno via a Web Worker without a deno binary.

A bidder whose runner is absent or unavailable (Available()) declines deno RFPs rather than bidding and failing. The native runner resolves deno via internal/policyengine/deno.Resolve, so a -tags embed_deno release build uses its embedded deno for both the sandbox and the policy engine.

The policy engine runs its gha-lite jobs through the same runner (workflow.Options.Sandbox). Each if:/${{ }} expression and uses: action calls Run with Net: true, a closed environment (NO_COLOR, DENO_NO_UPDATE_CHECK, and step env only), and no filesystem scope. This matches the prior permission set, with two rules:

  • Any runner reporting Fenced() == false is rejected for policy code. Expressions fall back to the pure-Go property-path resolver (no code runs) and action steps fail, which returns Deny. This keeps policy code from running in the browser build, because a Web Worker is not a security boundary against the page's own origin and policy workflows are arbitrary counterparty TS. The deno runner reports Fenced() == true.
  • A non-zero exit, timeout, or unavailable runner is an error. That fails the step with ExitStatus: failure and Deny (statusToVerdict allows only ExitStatus: success).

The deno runner sets its flags from Program.Net: --allow-net when network is requested, otherwise --deny-net --no-remote --no-lock (disabling network also disables remote resolution), plus --deny-run --deny-ffi and read/write on Program.Dir only when set.

The worker runner runs JavaScript only (browser Workers do not strip TypeScript) and has whatever the page's worker exposes, so isolation relies on the Worker itself rather than deno's permission flags. The deno runner keeps the explicit flags above.

<a id="which-runtime-runs-the-sandbox"></a>

Gate and Acceptance

Run the fast gate from the repo root:

cd "$(git rev-parse --show-toplevel)"
deploy/check.sh --fast

deploy/check.sh --fast runs gofmt, go build, go vet, the generated-code drift check (go generate ./...), the architecture rules (scripts/check-architecture.sh), cross-OS builds, and release builds. The full pre-release gate adds the release closure and the live proofs this host can run. See AGENTS.md ("How to verify").

There are no Go tests until plan 0027. Scenarios from the old integration suite and the acceptance rows of plan 0026 live in docs/spec/integration-catalog.yaml. Release candidates are proven live using docs/acceptance/0001-auth-modes.md.

See Also