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

socialweb.computer/socialweb-computer-kcp

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

1 collaborator
0
0

docs: the protocol flow and how it works; plan 0040 state

Merged johnandersen777.bsky.social asked to merge into main from socialweb.computer/socialweb-computer-kcp:phase-2
docs/plans/0040-findings.md+26−0
@@ -2204,3 +2204,29 @@ Each: what was seen (with the log), the cause, the fix, its proof.
2026-11-18, the prod gateway, both CLI blocks as written with a `goat account login` session of `aliceoa.bsky.social`:
the cluster `Ready`, `kubectl get ns` listed `default`, `kube-system` and the rest; `revokeKubeconfig` `"revoked": true`;
`deleteCluster`, then `listClusters` `Draining`. The browser path and the operating section were not run (prod).
- FIRST CYCLE IN SERIES (main a7dab399, 2026-11-19; release 08:02Z, test 08:25Z, promote 10:26Z; v0.0.1-rc1).
`test`: ONE staging network, all 43 entries: `gate: staging: 43 of 43 PASS`, wall 6215 s (104 min; the estimate was
160 to 220 against deadlineMin 250), no rerun, on four home bidders. `promote` ran after it (`==> staging gate`,
`==> test at a7dab399...: success`): `gate: prod: 27 of 30 PASS`, wall 3862 s; RED, rolled back to v0.0.0-rc186;
artifacts kept (157 of gate-runs). FAIL: 0007:run (bob): "the contract flow failed: read the attached policy
at://did:plc:ocnu.../computer.socialweb.temp.policy.ghalite/3n2nwcyu7dqhi: pdsclient: xrpc InternalServerError
(status 500)": a READ tried once; 0014:abandon (bob): "com.fedfork.exec.ops.getLog: iroh: the relay ended (exit
1): error: connection lost": a read tried once; 0013:run (alice): "vm1 over webrtc: ... the peer connection
failed before the datachannel opened: ICE failed ... a symmetric NAT on either side defeats STUN-only WebRTC
(stun:stun.cloudflare.com:3478, no TURN)": the guest on hat-7 and the release VM on a home host too, since the
droplets are gone (decision 43): not a flake by its message; to confirm from the artifacts. Logs saved
~/.tmp/ci-main/{test,promote}-a7dab399.log. The lead saw the result about 6 h late (no watch was armed while a
question waited on the owner).
- CODE FINDINGS FROM THE PROTOCOL DOCS' TRACE (2026-11-19, read only, none fixed; branch docs-protocol): the
association grant's rkey is the agent DID (AGENTS.md and internal/clicfg/options.json:717 say
`requester_associate-...`; a second contract with the same subject is refused); bidder association.go:133 lets
compute.vm `expiresAt` replace the 24 h bound even when later; cloudinit/modules.go:233-242 falls back to an
unchecked GitHub download of dumbpipe; the bidder and the ComputeVM controller both create the termination
StateSync (first one sets the reason), bids.go:574,660,680 hardcode `deleted_on_request`; a contract's
`policyArgs` reach no policy run; discovery lists the vouches of walk roots only while policy counts every
ancestor, `capped` keeps the first 64 DIDs by sort; runner.go:2055-2064 counts the release deadline from creation
with an 8-day TTL (`DefaultReleaseBound` unused); `setup-secrets` ignores the bundle's `mode`;
`spec.approvedAssociations` count as associated with no walk; renterkey.go tombstones on the renter's PLC URL
though R2 may have been made on `GuestPLCDirectoryURL`; lexicons omit `CapacityExceeded` and `RFPClosed`, the
manifest lexicon says `key: tid` while the rkey is `socialweb-computer:<version>`; the policy `index.ts` files
import a source not in the repo; prose comments at market.go:61-62,78-79, runner.go:387-388,757, vmsize.go:19.
docs/plans/0040-release-pipeline.md+37−17
@@ -3,24 +3,28 @@
Status: the only plan in flight (owner, 2026-11-17); docs/plans/0001-0039 and NEXT.yaml are history. How to run, hold
and debug CI by hand: `docs/ci-debug.md`. The state before this work: main e39097c2 (2026-11-12).
State (2026-11-19 09:00Z; updated by the lead):
- Main, with this landing: CI in series (decision 43): `release`, then one `test` (one staging network, all 43
entries), then `promote` (`after: [release, test]`; its first step checks `test` green before rc moves; the prod
gate, all 30 entries, three drivers), on four home bidders. With it: the staging bidder install's image budget
(20 min), the failed-run evidence fetch, the renter retiring an unverified guest requester's DID (decision 42),
the accept and RBAC write retries, the kcp docs with `scripts/install.sh` (decisions 44, 45).
- STAGING IN CI: 43 of 43 PASS at d6a2b391, a5269317 and 688c2105 (`scripts/ci-staging-total.sh`, exit 0).
- PROD IN CI: 30 of 30 PASS at 688c2105 (promote rc186, 04:22Z 11-19). At db33c9ff: 29 of 30 (0005:r2fail).
- ROLLS: promote 10 (rc186) GREEN: stable v0.0.0 = main 688c2105. Promote 11 (v0.0.1-rc0, db33c9ff) RED; rolled
back to rc186. Two consecutive greens are still owed: this landing's cycle is the first in series (about 4 h 15
min: release 22 min, test 2 h 40 min, promote 70 min); one code change per cycle.
- Reviewed or in review, for later cycles: `rc-cap` (bidder reservations with no guest behind them: 0014:concurrent,
twice), `rc-pins` (a self-update drops the downloads live guests still fetch; proven by hand; entry 0007:upgrade
makes staging 44, two landings), `rc-writes` (webrtc ingress offer), `site` (socialweb.computer from the repo).
State (2026-11-19 17:30Z; updated by the lead):
- Main: CI in series on four home bidders (decision 43), the fixes of promote 11's cycle, the kcp docs, the site
from the repo (`site/`), the protocol docs.
- STAGING IN CI: 43 of 43 PASS at a7dab399, the first cycle in series (one network, 6215 s); before it at
d6a2b391, a5269317, 688c2105 (four shares).
- PROD IN CI: 30 of 30 PASS at 688c2105 (promote rc186, 04:22Z 11-19). Since: 29 of 30 at db33c9ff (0005:r2fail,
fixed on main), 27 of 30 at a7dab399 (0007:run and 0014:abandon: reads tried once; 0013:run: WebRTC between two
home-NATed hosts, STUN only).
- ROLLS: promote 10 (rc186) GREEN: stable v0.0.0 = main 688c2105. Promotes 11 (db33c9ff) and 12 (a7dab399) RED,
rolled back to rc186. Two consecutive greens are still owed. One code change per cycle; a cycle is about 3 h 15
min as measured (release 22 min, test 104 min + stand-up, promote 65 min).
- In work: the three prod failures of a7dab399 from their artifacts and a sweep of reads tried once (agent);
`rc-cap` (bidder reservations per accept; fourth review); `rc-pins` (self-update keeps guest downloads; proven by
hand; entry 0007:upgrade makes staging 44); `rc-writes` (webrtc ingress offer; third review).
- Owner asks of 11-19 (decisions 46-49), each on its own agent: the site and /fancy/ in the console's terminal
style; a DigitalOcean bidder in today's architecture; association-mode examples in the docs; `run request` flags
before `--exec --`.
- Open, no fix yet: the guest's own release step exits 1 every time (0005); a stable build's version string holds
`-rc`, so a bidder installed from it follows rc unless pinned; 0001:run's second node that never joined (11-18).
- Compute: the three `swc-dev` droplets are destroyed. Prod: hat-7, hat-8, hat-9, hat-10.
`-rc`; 0001:run's second node that never joined (11-18); the trace's code findings (findings).
- Compute: prod is hat-7, hat-8, hat-9, hat-10. The DigitalOcean OAuth client secret that sat in the old site's web
root must be rotated by the owner.
## Flow
@@ -497,6 +501,22 @@ All answered 2026-11-17.
examples to run the bidder requester in different ways". Branch `docs-0041`.
45. (2026-11-19) "our readme still shows the old rc, how do we make it just always show how to download the latest
version?": the README follows the stable channel record (step 19's note).
46. (2026-11-19, AskUserQuestion) The old /fancy/ pages: "Restore and update but in the style/theme of
console.socialweb.computer - also make the root page that same terminal like styling". The site keeps the
owner's own text, his demo video near the top, his diagrams, one repo link named "source", no "Verified"
sections on user pages ("this is end user facing").
47. (2026-11-19, AskUserQuestion) The hosted DigitalOcean bidder: "Write code in socialweb-computer-kcp to fill out
whatever kcp native abstractions we need to make the DigitalOcean based bidder a reality again within our new
architecture, then put the link back and redeploy - dispatch fable subagent to do this - once the deployed
version is working then land the commit on main and push".
48. (2026-11-19, AskUserQuestion) The protocol diagram's stale label: "Change that label".
49. (2026-11-19, AskUserQuestion) Docs: "we just care about having the requester/bidder association modes as copy
pastable examples with how to do the association and also ... the mode where the account itself is used"; is
QR sign-in still supported; and `run request --name vm1 --exec id -- --atproto-oauth-qr`: "why is the
--atproto-oauth-qr flag behind exec and the double hyphen? ... usually it would be `socialweb-computer run
request --name vm1 --atproto-oauth-qr --exec -- some-command --with-that-commands-args`".
50. (2026-11-19) "make sure we have docs on the full protocol flow and how everything works in docs/": `docs/
how-it-works.md`, `docs/protocol/{flow,release,glossary}.md`, the older protocol pages corrected in place.
docs/protocol/flow.mdnew+319−0
@@ -0,0 +1,319 @@
# flow: one compute contract, end to end
- the flow is: Request For Proposal -> Bid -> Accept -> Receipt, then the guest's events, then the release
- the compute contract flow can run purely over the firehose and relays (comms mode `Firehose`: no inbound endpoint); the `market.submit*` calls are the fast path
- every record lives in its author's own repo; the other side reads it with one `getRecord` (from a firehose or Jetstream commit, or from the `market.submit*` call that names it)
- every `market.*` record and every event payload carries badge.blue signatures (`network.attested.signature`: [identity.md](identity.md#networkattested)); they are left out of the records below
- the records below are one real contract, read 2026-11-19 from prod: the requester `aliceoa.bsky.social` rented a 4 vCPU VM from one of `bobvmbuilder.bsky.social`'s bidders on 2026-11-15 (trimmed; `did:plc:lpfuqerea3deuoyrn7ojser4` is alice, `did:plc:2l2wdry77c7jtucbslstagkj` the bidder)
- field by field: [market.md](market.md), [guest-events.md](guest-events.md); who is who: [identity.md](identity.md#actors); every NSID: [glossary.md](glossary.md)
## The Story
```mermaid
sequenceDiagram
autonumber
actor Alice as Alice (requester)
actor Bob as Bob's bidder (an agent of Bob)
rect rgb(240, 248, 255)
Note over Alice,Bob: Request For Proposal (RFP)
Alice->>Alice: createRecord: policy record (the workflow she runs)
Alice->>Alice: createRecord: compute.vm<br/>(CPUs, Memory, Disk, cloud-init user_data, ...)
Alice->>Alice: createRecord: rfp<br/>(strongRef to compute.vm + policy, signed)
Alice->>Bob: discover (offering + heartbeat), submitRfp
end
rect rgb(245, 245, 245)
Note over Alice,Bob: Bid
Note over Bob: policy: Bob's workflow + Alice's attached one
Bob->>Bob: createRecord: compute.config.wif.simple, bids.free (or x402)
Bob->>Bob: createRecord: bid<br/>(strongRef to RFP + payment terms + config)
Bob->>Alice: submitBid
end
rect rgb(240, 248, 255)
Note over Alice,Bob: Accept
Note over Alice: policy on the winner<br/>Payment Settlement Flow (NOP if bids.free)
Alice->>Alice: createRecord: accept<br/>(strongRef to RFP + Bid)
Alice->>Bob: submitAccept (re-sent until the receipt)
end
rect rgb(245, 245, 255)
Note over Alice,Bob: Receipt
Note over Bob: capacity check + reservation, Provision Compute
Bob->>Bob: createRecord: receipt<br/>(strongRef to RFP + Bid + Accept + compute.vm, cid binds the accept)
Bob->>Bob: createRecord: compute.events.vm.hostKeys, vm.onNetwork<br/>(address: the guest's iroh ticket)
Bob->>Bob: createRecord: market.event<br/>(strongRef to the payload + receipt)
Bob->>Alice: submitEvent
end
Note over Alice: Held: connect to the guest over iroh (ssh), webrtc or an https tunnel
rect rgb(245, 245, 245)
Note over Alice,Bob: Release
Alice->>Alice: createRecord: compute.events.vm.delete + market.event
Alice->>Bob: submitEvent
Bob->>Bob: createRecord: compute.events.vm.terminated + market.event
Alice->>Alice: delete her contract records
end
```
- Alice, Bob and Eve are on the network. Bob runs bidders: hosts with VMs to sell, each its own DID, an agent of Bob's account
- Alice has vouched for Bob and Bob for Alice (`sh.tangled.graph.vouch`); Alice has denounced Eve (a vouch record with `kind: denounce`, which no policy counts)
- Alice writes her Compute Contract Request For Proposal (CCRFP: the `compute.vm` record, the VM-specific payload: cpus, mem, disk, cloud-init `user_data`, ...) and wraps it in a top-level RFP record (`domain: compute`, `payload` a strongRef to the CCRFP). The RFP is the domain-tagged envelope bidders and indexers route on; the CCRFP is the inner VM-specific record
- Bob's and Eve's bidders each issue a Compute Contract Bid (CCB: `market.bid`). Alice's policy engine (`requester-tangled-vouch`) sees she vouched for Bob (his bidder's walk reaches him) and denounced Eve: it allows Bob's bid and denies Eve's
- Alice issues a Compute Contract Bid Accept (CCBA: `market.accept`) against Bob's CCB. With `bids.x402` she would first pay per the CCB's terms; no x402 flow is exercised today (`accepts.*` and `receipts.*` are defined, not written)
- Bob's bidder checks its capacity and issues a Compute Contract Receipt (CCR: `market.receipt`) over the CCRFP, the CCB and the CCBA; it builds to the CCRFP's spec (boots the VM from its `user_data`) and reports the guest's address
- Alice reaches the guest, works, and releases it; both sides record the end
## The Steps
| step | who writes | where | what the other side verifies |
|---|---|---|---|
| [S0](#s0-sign-in) sign in | each party | its OpenBao | - |
| [S1](#s1-trust) trust | operators, users | their repos | vouches and associations, at every policy run |
| [S2](#s2-declare-optional) declare (optional) | the owner's kcp | owner repo | - |
| [S3](#s3-policy-vm-rfp) policy, vm, rfp; discovery; submitRfp | requester | requester repo | RFP signature, RFP author = token issuer, bid window, policies |
| [S4](#s4-bid) bid | bidder | bidder repo | bid author = token issuer, scope policy on each bid |
| [S5](#s5-accept) accept; submitAccept | requester | requester repo | accept signature, accept author = RFP author, policies again, capacity |
| [S6](#s6-receipt) receipt | bidder | bidder repo | receipt signature, `cid` binds the accept |
| [S7](#s7-boot-and-vm-events) boot, vm events | bidder (for the guest) | bidder repo | event author = receipt author, both signatures |
| [S8](#s8-guest-events-secrets-held) guest events, secrets, Held | both | each its own | event author, kind allowed for that side |
| [S9](#s9-release-and-cleanup) release, cleanup | both | each its own | delete author = accept author |
## S0: sign in
- a party is a MarketIdentity: a repo DID and how the app reaches it (`localRepo`, `pdsAccount`, `oauthQr`, `oauthBrowser`, `oauthDelegated`, `oauthSessionProxy`): [identity.md](identity.md#sign-in)
- `socialweb-computer run request --name vm1 --exec id -- --atproto-oauth-qr` signs in with a QR code; the session stays in the requester's own OpenBao
## S1: trust
- vouches: a person vouches another at `sh.tangled.graph.vouch/<subject DID>` in their own repo; both directions are needed for a deal ([policy.md](policy.md#tangled-vouch))
- associations: a bidder is an agent of its operator by the ident.link pair (its DID document's `agent-of`, the operator's `link.ident.endorsement` and `market.association` at rkey = the agent DID); trust walks agent -> principal up to 100 levels ([identity.md](identity.md#associations-identlink))
- the policy modes in code: `tangled-vouch` (the default on both sides), `only-me`, `mutuals`, `open` (only when named, never prod), and the work policies `bid-payload`, `under-4-cpus` ([policy.md](policy.md#bundled-workflows))
## S2: declare (optional)
- an Infra or EphemeralInfra kcp object of the owner mirrors to `computer.socialweb.infra` / `ephemeralInfra` in the owner's repo; each of its contracts is a ComputeContract that runs S3 to S9 ([infra.md](infra.md)). `run request` makes the ComputeContract directly
## S3: policy, vm, rfp
The requester (`internal/market/requester/runner.go` `requestOnce`) checks the size, the token paths and the contract deadline (the `vm-expires-at` label: a deadline in the past sends no RFP), then writes, each with putRecord at a TID:
```yaml
# the policy record: the workflow the requester runs, so the bidder can run it too
uri: at://aliceoa.bsky.social/computer.socialweb.temp.policy.ghalite/3n2de4u2n2c2i
$type: computer.socialweb.temp.policy.ghalite
name: requester-tangled-vouch
perspective: requester
requester: did:plc:lpfuqerea3deuoyrn7ojser4
workflow: "<the bundled workflow, 2448 chars>"
---
# the VM asked for (unsigned; reused by every RFP round of the contract)
uri: at://aliceoa.bsky.social/com.publicdomainrelay.temp.compute.vm/3n2de4twuxb2t
$type: com.publicdomainrelay.temp.compute.vm
kind: vm
role: stg-gateway
cpus: 4
mem: 8G
disk: 50G
expiresAt: "2026-11-15T11:00:45.000Z"
user_data: "<cloud-init, 5399 bytes: cloudinit.BuildUserData, with the iroh module>"
---
# the RFP (signed)
uri: at://aliceoa.bsky.social/com.publicdomainrelay.temp.market.rfp/3n2de4uaqaj2a
$type: com.publicdomainrelay.temp.market.rfp
domain: compute
payload: {uri: at://did:plc:lpfuqerea3deuoyrn7ojser4/com.publicdomainrelay.temp.compute.vm/3n2de4twuxb2t, cid: bafyreiejybdf2t77...}
policies:
- {uri: at://did:plc:lpfuqerea3deuoyrn7ojser4/computer.socialweb.temp.policy.ghalite/3n2de4u2n2c2i, cid: bafyreick65zxk47w...}
submitBid: https://did-key-zq3shrcc7qedh4rhor1nwahzrt2anfc9iaxeqfcsrztsl8ype.xrpc.fedproxy.com
createdAt: "2026-11-15T06:10:46.139Z"
```
`submitBid` here is the requester's did:key ingress (it has no public host: [identity.md](identity.md#didkey-ingress)).
Then discovery ([market.md](market.md#discovery)): every repo with a `market.offering` that the relays list, plus the DIDs its operators vouch for and the agents they endorse; candidates without a fresh heartbeat (300 s) or lacking a capability (`maxCpus`, `nestedVirt`, `images`) are dropped. Never a pinned list.
The requester sends `market.submitRfp {rfpUri, rfpCid}` to each candidate's first endpoint (iroh, webrtc, https), service auth aud `<bidder DID>#pdr_temp_market`, lxm the NSID.
The bidder (`internal/market/bidder/submit.go` `SubmitRFP`) checks the token issuer is the RFP's author and the bid window (10 min from the RFP's TID), answers 200 `{name, phase: Deciding}` or `declined {kind: capacity|unservable, reason}`, or 409 `RFPClosed`. The RFP also reaches it on the relay and Jetstream streams; one sink drops duplicates.
## S4: bid
The bidder (`bids.go` `decideBid`): the window, the RFP's signature, the requester's DID resolves, the payload, guest tools and net, the scope policy, then the full policy (its own workflow and every attached one: all must allow). Then three records at the bid's deterministic rkey (`BidRKey`: one bid per RFP):
```yaml
uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.market.bids.free/bid-596cc856db4e8aaf1080-payload
$type: com.publicdomainrelay.temp.market.bids.free
reason: free
cost: 0
# Can also be x402 (not exercised today):
# $type: com.publicdomainrelay.temp.market.bids.x402
# cost: 0.10
# currency: USDC
# frequency: hourly
# prepay: true
# url: https://compute-contract.bob.example/receipt
---
uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.market.bid/bid-596cc856db4e8aaf1080
$type: com.publicdomainrelay.temp.market.bid
rfp: {uri: at://did:plc:lpfuqerea3deuoyrn7ojser4/com.publicdomainrelay.temp.market.rfp/3n2de4uaqaj2a, cid: bafyreiewnv734zjy...}
payload: {uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.market.bids.free/bid-596cc856db4e8aaf1080-payload, cid: bafyreidtjdg5zrwd...}
config: {uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.compute.config.wif.simple/bid-596cc856db4e8aaf1080-config, cid: bafyreig7dqqmi2ky...}
createdAt: "2026-11-15T06:10:53Z"
```
The `config` is the VM's workload identity issuer and subject format ([guest-events.md](guest-events.md#secrets-getsecrets-or-sealed-fallback)). The bidder sends `market.submitBid` to the RFP's `submitBid`.
The requester takes bids from submitBid, the streams, and one getRecord per bidder at `BidRKey` a few seconds after submitRfp. Its window (`bidWindowSeconds`, 30 s) ends at the first free bid its scope policy allows; else it takes the lowest-cost allowed bid after the window. It runs the full policy on the winner (a deny fails the contract: `policy_rejected`).
## S5: accept
```yaml
uri: at://aliceoa.bsky.social/com.publicdomainrelay.temp.market.accept/ro7pddf4ecfze
$type: com.publicdomainrelay.temp.market.accept
rfp: {uri: at://did:plc:lpfuqerea3deuoyrn7ojser4/com.publicdomainrelay.temp.market.rfp/3n2de4uaqaj2a, cid: bafyreiewnv734zjy...}
bid: {uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.market.bid/bid-596cc856db4e8aaf1080, cid: bafyreidpljip3s4e...}
submitEvent: https://did-key-zq3shrcc7qedh4rhor1nwahzrt2anfc9iaxeqfcsrztsl8ype.xrpc.fedproxy.com
createdAt: "2026-11-15T06:11:00.665Z"
```
- rkey `SessionRKey("accept", repo, contract, rfp, bid)`: a restarted requester finds and reuses it
- no payload record today: with x402 the accept would wrap the proof of payment
- `market.submitAccept {acceptUri, acceptCid}` (`accept.go` `submitAcceptAndWait`): re-sent every 0.5 s doubling to 2 s until the receipt is found or `receiptTimeoutSeconds` (5 min) pass
- the bidder (`SubmitAccept`, `vmsize.go`) checks capacity at once: a guest counts its vCPUs and its memory plus the VM overhead; an accept reserves its size for 10 min (per RFP; cut to 1 min once placed and dropped when its ComputeVM exists); a full host answers 409 `CapacityExceeded` before any receipt, else 202 `{id}`
- then, asynchronously (`adapters.go` `acceptContract`): the accept's signature, the scope policy, the bid is its own for that RFP, the accept's author is the RFP's, not expired, the RFP's signature, the full policies again, capacity again
## S6: receipt
```yaml
uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.market.receipt/receipt-fa04c66e2d8effc84a2f6a869217fa11
$type: com.publicdomainrelay.temp.market.receipt
rfp: {uri: at://did:plc:lpfuqerea3deuoyrn7ojser4/com.publicdomainrelay.temp.market.rfp/3n2de4uaqaj2a, cid: bafyreiewnv734zjy...}
bid: {uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.market.bid/bid-596cc856db4e8aaf1080, cid: bafyreidpljip3s4e...}
accept: {uri: at://did:plc:lpfuqerea3deuoyrn7ojser4/com.publicdomainrelay.temp.market.accept/ro7pddf4ecfze, cid: bafyreickrv6epucq...}
payload: {uri: at://did:plc:lpfuqerea3deuoyrn7ojser4/com.publicdomainrelay.temp.compute.vm/3n2de4twuxb2t, cid: bafyreiejybdf2t77...}
cid: bafyreihoa6m57iajl63umctjn4mke2l4ezbzmbxhclfj5ghrx2uaxklrla
submitEvent: https://did-key-zq3shrcc7qedh4rhor1nwahzrt2anfc9iaxeqfcsrztsl8ype.xrpc.fedproxy.com
createdAt: "2026-11-15T06:11:07.641Z"
```
- rkey `receipt-` + 32 hex of sha256(accept uri LF accept cid) (`market.ReceiptRKey`): the requester finds it with one getRecord in the bidder's repo
- `cid` is the attestation CID of the accept record in the requester's repo; the requester checks the receipt's signature and that binding (`market.VerifyReceipt`); a bad one fails the contract `receipt_invalid`
- no atirc token and no association exist before a verified receipt
## S7: boot and vm events
- placement (`provision.go` `placeAccepted`): a ComputeVM owned by the Bid, then a FirecrackerVM; the VM boots the requester's `user_data` with the bidder's additions (the accept bundle, the network, workload login, `guest-onnetwork.service`, the guest agent and `setup-guest-binaries.service`: `internal/guestseed`)
- the fence is loaded before the tap exists: the guest reaches the internet; TCP to the bidder's host only to the guest control plane at `http://192.0.2.1:<port>` (its `spec.hostPorts`), never TCP to the LAN; DNS; UDP to the LAN for WebRTC by default ([../SYSTEM.md](../SYSTEM.md#fence))
- downloads: the guest image is the bidder's, pinned by sha256 in `internal/versions/versions.json` (`guest-images/<target>/<image.json sha256>` in the bucket); a requester image (`compute.vm.image {url, sha256}`) is fetched and verified by the bidder; guest binaries (opentunnel, wootty, atirc, the guest agent) come from `GET /v1/downloads/<sha256>/<name>` of the guest control plane and are checked against that sha256. One exception in code: when the image's baked dumbpipe is not the pinned version, the iroh module fetches dumbpipe from GitHub with no sha256 check (`internal/atproto/cloudinit/modules.go`, `setup-iroh.sh`)
- the guest logs in with its ssh host key (`sshsig`), which binds the host key to the ComputeVM; `iroh-listener.sh` runs `dumbpipe listen-tcp 127.0.0.1:22` and `send-onnetwork.sh` POSTs `vm.onNetwork` with the iroh ticket to `POST /v1/events`
- the bidder writes each as a payload + `market.event` in its repo at `EventRKeys(<kind>:<receipt>)` and sends `market.submitEvent` to the receipt's `submitEvent`:
```yaml
uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.compute.events.vm.hostKeys/hostkeys-payload-2aac09c4d09c6fa506757931c42eb7f1
$type: com.publicdomainrelay.temp.compute.events.vm.hostKeys
keys: [{type: ssh-ed25519, publicKey: AAAAC3NzaC1lZDI1NTE5AAAAIAnyKwEO5wzWGBi44fIk0IINLHqK21fd1/Q0CVUssM1u, fingerprint: "SHA256:HLs4eIe9xpZuDqOzbJ4V0PMGYUAT0MykBqMj5YdG4UQ"}]
observedAt: "2026-11-15T06:11:17Z"
---
uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.compute.events.vm.onNetwork/onnetwork-payload-ffcde96d9e9d32d1fc7a38f6a2c46ad5
$type: com.publicdomainrelay.temp.compute.events.vm.onNetwork
address: iroh://endpointaakwnx5yuadc7qofuw3rdurziaeaghixq...
createdAt: "2026-11-15T06:11:19Z"
---
uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.market.event/onnetwork-event-63e463b75b052b3a570a6956e00d9a4d
$type: com.publicdomainrelay.temp.market.event
payload: {uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.compute.events.vm.onNetwork/onnetwork-payload-ffcde96d9e9d32d1fc7a38f6a2c46ad5, cid: bafyreicronh3k2gu...}
receipt: {uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.market.receipt/receipt-fa04c66e2d8effc84a2f6a869217fa11, cid: bafyreihpm5lvqqro...}
createdAt: "2026-11-15T06:11:19Z"
```
## S8: guest events, secrets, Held
- guest -> requester: the guest POSTs `{acceptUri, acceptCid, record}` to its bidder (`POST /v1/events`, bearer the workload token); the bidder signs and publishes it (`publicKey`, `signalWebRTC`, `secretsRequested`, `secretsApplied`, `requesterDid`, `r2Released`, `memoryPressure`, `oomKill`, `image`)
- requester -> guest: the requester writes the event in its repo and sends submitEvent to the bidder, which checks the author is the accept's and queues it for the guest's `compute.guest.subscribeEvents` WebSocket (`publicKey`, `signalWebRTC`, `secrets`, `agentStart`, `secretsUpdated`, `r2Start`, `r2Release`)
- secrets: the guest fetches the requester's bundle with `getSecrets` and its workload identity token; a sealed fallback only when the requester enables it and the guest asks ([guest-events.md](guest-events.md#secrets-getsecrets-or-sealed-fallback))
- Held (`runGuestAndHold`): the iroh address and the host keys, plus the image marker for an image contract and the secrets fetch when the contract has secrets and no sealed fallback
- transports, three and no other: iroh (every guest; ssh over `dumbpipe`, `run request ssh`), opentunnel https (per tag), webrtc (per tag; sealed signaling through the bidder) ([../SYSTEM.md](../SYSTEM.md#transports-three-never-add-one)). The ssh gateway (`ssh <handle>@socialweb.computer`) runs the same flow as the user and hops over iroh ([../SYSTEM.md](../SYSTEM.md#ssh-gateway))
- atirc: for `spec.agent` the requester mints a token leased to the receipt and the bidder's `vm.terminated` after the receipt is verified ([outside.md](outside.md#chatatirc))
- a guest requester (R2) in the VM is associated here: [identity.md](identity.md#guest-requester-r2)
## S9: release and cleanup
1. a release request (`spec.releaseRequestedAt`): the guest requester's contracts first (`guest.r2Release`, wait for `guest.r2Released`), then leased atirc tokens are revoked while the lease is alive
2. the requester writes `compute.events.vm.delete {reason: released}` + `market.event` and sends submitEvent, retried until the bidder's `vm.terminated` appears or the release deadline
3. the bidder checks the delete's author is the accept's and the receipt is its own, deletes the ComputeVM, and writes `vm.terminated`:
```yaml
uri: at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.compute.events.vm.terminated/termination-payload-2da9e2aef573b37793d5c43f443186a1
$type: com.publicdomainrelay.temp.compute.events.vm.terminated
reason: deleted_on_request
observedAt: "2026-11-15T06:18:58Z"
```
4. the requester reads it at `EventRKeys(TerminationKey(receipt))` (up to 2 min) and is Released
5. cleanup: the requester deletes the records it wrote for the contract (the rbac grant, the association and endorsement, its delete records, the accept, the RFP, the `compute.vm`, the policy record, its ContractEvents); a guest requester's DIDs are tombstoned (by the guest, else by the renter's rotation key). The bidder keeps its bid, receipt and events
6. reasons a VM ends without a release: `guest_poweroff`, `vmm_exited`, `oom`, `host_reboot`, `identity_mismatch`, `image_refused`, `expired` (past its association's `expiresAt`), `association_ended` ([market.md](market.md#release-and-termination))
The records of this contract are still in alice's repo on 2026-11-19, and its `vm.terminated` has no `request`: its requester did not run step 5. Why is not visible in the records.
## When It Does Not Go That Way
```mermaid
flowchart TD
RFP["RFP written, submitRfp to the discovered bidders"] --> D{"bids?"}
D -->|"every bidder declined unservable, or every candidate lacks a capability"| F1["Failed: no bidder can serve this request"]
D -->|"none (full, silent, capacity declines)"| W["wait for capacity: delete the RFP, back off 30 s, 1 min, then 2 min"]
W -->|"before the deadline (vm-expires-at, else 30 min)"| RFP
W -->|"deadline passed"| F2["Failed: no bids, gave up after N rounds"]
D -->|"all denied by policy"| F3["Failed: bids_denied"]
D -->|"a winner"| P{"full policy on the winner"}
P -->|"deny"| F4["Failed: policy_rejected"]
P -->|"allow"| A["accept, submitAccept"]
A -->|"declined (409 CapacityExceeded, any 4xx but 408/425/429)"| X{"replacements left? (3, shared)"}
X -->|"yes, bids of this RFP left"| RFP2["same RFP: submitRfp again without the refusers"]
RFP2 --> D
X -->|"yes, no bids left"| NEW["delete the RFP, a new RFP without the refusers"]
NEW --> D
X -->|"no"| F5["Failed"]
A -->|"no receipt in 5 min"| F6["Failed: no receipt"]
A -->|"receipt"| V{"VerifyReceipt"}
V -->|"bad"| F7["Failed: receipt_invalid"]
V -->|"ok"| G{"guest on network + host keys in 120 s"}
G -->|"no"| F8["Failed: network_timeout"]
G -->|"wrong image marker or image_refused"| R["release it, accept another bid (shares the 3)"]
G -->|"yes"| H["Held"]
```
- the requester keeps a declined accept (a bidder that already acted on it may still need it; the bidder gives up on its own: `bidder_accept_abandoned`)
- a failure before a receipt deletes the RFP, the `compute.vm` and the policy record, and keeps the accept
- sources: `runner.go` `Run`, `replaceDeclined`, `reRFPAfterRefusals`, `waitForCapacity`, `unservableBy`; `accept.go` `acceptDeclined`; `image.go`
## A Real Run
The requester's `contract` lines of one rent on a local market (`run request --network`, 2026-11-19 UTC; `~/.tmp/docs-0041/local-t1.log` on hat-8):
```
06:02:32 Requesting requested step preparing
06:02:32 Requesting rfp_submitted step creatingRfp
06:02:32 Requesting rfp_submitted the RFP is submitted; collecting bids
06:02:32 Requesting rfp_submitted ... requester_no_bidders: no bidder with a market endpoint among 1 candidates
06:03:02 Requesting rfp_submitted waiting for a default-size slot: round 1, a new RFP in 30s
06:03:32 Requesting rfp_submitted step creatingRfp
06:03:35 Requesting winner_selected the winner is selected; accepting
06:03:35 Requesting accepted the accept is submitted; waiting for the receipt
06:03:39 Requesting receipt the receipt is verified; waiting for the guest
06:03:51 Requesting receipt the guest reported hostKeys
06:03:54 Requesting network the guest reported onNetwork
06:03:54 Held network held: the guest is on the network
06:03:55 Releasing network the destroy is delivered; waiting for the bidder's vm.terminated
06:04:00 Released released the bidder ended the contract: deleted_on_request
```
The first round found the network's bidder before its offering named an endpoint; the requester waited for capacity and the second round got the VM.
## See Also
- [README.md](README.md) (the index and the sequence), [market.md](market.md), [guest-events.md](guest-events.md), [identity.md](identity.md), [policy.md](policy.md), [release.md](release.md), [glossary.md](glossary.md)
- the acceptance runbooks: `docs/acceptance/`
docs/protocol/glossary.mdnew+120−0
@@ -0,0 +1,120 @@
# glossary: every NSID on the wire
- one line each, grouped by namespace; the lexicon file is `lexicons/<nsid with / for .>.json` unless the line says "no file"
- namespaces: market and relay `com.publicdomainrelay.temp.*`; runtime and host contracts `com.fedfork.exec.*`; deployments, ingress and peers `computer.socialweb.*`; releases `software.release.*`; associations `link.ident.*`; signatures `network.attested.*`
- names in other docs drop `com.publicdomainrelay.temp.` (`market.rfp`)
## com.publicdomainrelay.temp.market
| NSID | type | one line | doc |
|---|---|---|---|
| `market.rfp` | record | signed request for proposals: `payload` -> `compute.vm`, `policies[]`, `submitBid`, `ingress[]` | [flow.md](flow.md#s3-policy-vm-rfp) |
| `market.bid` | record | signed bid on an RFP: `rfp`, `payload` -> `bids.*`, `config` -> `compute.config.wif.simple`; rkey `BidRKey` | [flow.md](flow.md#s4-bid) |
| `market.bids.free` | record | bid terms at no cost `{reason, cost: 0}` | [market.md](market.md) |
| `market.bids.x402` | record | bid terms paid over x402 `{cost, currency, frequency, prepay, url}`; defined, not written | [lexicons-market.md](lexicons-market.md#marketbidsx402) |
| `market.accept` | record | signed accept of one bid: `rfp`, `bid`, `submitEvent`, `ingress[]` | [flow.md](flow.md#s5-accept) |
| `market.accepts.free`, `market.accepts.x402` | record | accept terms; defined, not written | [lexicons-market.md](lexicons-market.md) |
| `market.receipt` | record | the bidder's signed receipt; `cid` binds it to the accept; `payload` -> the `compute.vm` | [flow.md](flow.md#s6-receipt) |
| `market.receipts.free`, `market.receipts.x402` | record | receipt terms; defined, not written | [lexicons-market.md](lexicons-market.md) |
| `market.event` | record | signed event envelope under a receipt: `receipt`, `payload` -> a `compute.events.*` record | [guest-events.md](guest-events.md) |
| `market.offering` | record (`self`) | what a bidder bids on and where it takes calls: `appliesTo`, `endpoints[]`, `maxCpus`, `maxMem`, `nestedVirt`, `images` | [market.md](market.md#discovery) |
| `market.heartbeat` | record (`self`) | a bidder's liveness beat, fresh for 300 s; `version` of the running binary | [market.md](market.md#discovery) |
| `market.relays` | record (`self`) | relays a participant crawls; read in discovery, no Go writer | [market.md](market.md#discovery) |
| `market.association` | record | the grant: the repo trusts `agent` (rkey = the agent DID); `contract` and `expiresAt` scope it | [identity.md](identity.md#associations-identlink) |
| `market.associationRequest` | record | a guest requester asks the principal to grant it for one contract (rkey = the principal DID, `nonce`) | [identity.md](identity.md#guest-requester-r2) |
| `market.submitRfp` | procedure | requester -> bidder: an RFP; 200 `{name, phase, declined?}`, 409 `RFPClosed` | [market.md](market.md#xrpc-procedures) |
| `market.submitBid` | procedure | bidder -> requester: a bid it wrote | [market.md](market.md#xrpc-procedures) |
| `market.submitAccept` | procedure | requester -> bidder: an accept; 202, 409 `CapacityExceeded` | [market.md](market.md#xrpc-procedures) |
| `market.submitEvent` | procedure | either party -> the other: a `market.event` it wrote | [market.md](market.md#xrpc-procedures) |
| `market.policies.denoWorker` | record (no file) | a policy record type the engine denies | [policy.md](policy.md) |
## com.publicdomainrelay.temp.compute
| NSID | type | one line | doc |
|---|---|---|---|
| `compute.vm` | record | the VM asked for: `role`, `kind`, `cpus`, `mem`, `disk`, `nestedVirt`, `image`, `user_data`, `net`, `expiresAt` | [flow.md](flow.md#s3-policy-vm-rfp) |
| `compute.config.wif.simple` | record (no file) | a bid's workload identity config: OIDC issuer and `sub` format of the VM | [guest-events.md](guest-events.md#secrets-getsecrets-or-sealed-fallback) |
| `compute.secrets.getSecrets` | query (no file; route `/xrpc/<nsid>/<contract>`) | the guest fetches its secrets bundle from the requester with a workload identity token | [guest-events.md](guest-events.md#secrets-getsecrets-or-sealed-fallback) |
| `compute.guest.subscribeEvents` | subscription | the guest's WebSocket at its bidder for requester-authored `compute.events.guest.*` | [guest-events.md](guest-events.md#computeguestsubscribeevents) |
| `compute.events.vm.onNetwork` | record | an address of the VM: iroh ticket, https tunnel URL, webrtc DTLS fingerprint | [guest-events.md](guest-events.md#each-kind) |
| `compute.events.vm.hostKeys` | record | the VM's ssh host keys | [guest-events.md](guest-events.md#each-kind) |
| `compute.events.vm.delete` | record | the requester asks the bidder to delete the VM (`reason: released`) | [market.md](market.md#release-and-termination) |
| `compute.events.vm.terminated` | record | the bidder reports the VM stopped, with a reason | [market.md](market.md#release-and-termination) |
| `compute.events.vm.sandbox` | record | a deno sandbox ended, with its output | [guest-events.md](guest-events.md#each-kind) |
| `compute.events.vm.memoryPressure`, `vm.oomKilled` | record | the VM's host cgroup crossed a memory threshold / OOM-killed | [guest-events.md](guest-events.md#each-kind) |
| `compute.events.vm.started`, `vm.registerIdentity` | record | defined, no writer | [lexicons-market.md](lexicons-market.md) |
| `compute.events.guest.publicKey` | record | an age-x25519 key per tag, either side | [guest-events.md](guest-events.md#sealed-signaling-webrtc-tunnels) |
| `compute.events.guest.signalWebRTC` | record | a sealed WebRTC offer or answer for one tag | [guest-events.md](guest-events.md#sealed-signaling-webrtc-tunnels) |
| `compute.events.guest.secrets` | record | the requester's bundle sealed to the guest's key (only when asked) | [guest-events.md](guest-events.md#secrets-getsecrets-or-sealed-fallback) |
| `compute.events.guest.secretsRequested` | record | the guest asks for the sealed bundle | same |
| `compute.events.guest.secretsApplied` | record | the guest wrote its bundle (`via`) | same |
| `compute.events.guest.secretsUpdated` | record | the bundle changed; fetch again | same |
| `compute.events.guest.agentStart` | record | start the guest's atirc agent unit | [guest-events.md](guest-events.md#agent-start-and-atirc-mint) |
| `compute.events.guest.requesterDid` | record | the guest reports its guest requester's DID | [identity.md](identity.md#guest-requester-r2) |
| `compute.events.guest.r2Start` | record | start the guest requester unit | same |
| `compute.events.guest.r2Release` | record | release the guest requester's contracts | same |
| `compute.events.guest.r2Released` | record | the guest requester released them | same |
| `compute.events.guest.memoryPressure`, `guest.oomKill` | record | the guest's PSI or swap threshold / an OOM kill | [guest-events.md](guest-events.md#each-kind) |
| `compute.events.guest.image` | record | the marker of the image the guest booted | [guest-events.md](guest-events.md#each-kind) |
## com.publicdomainrelay.temp (other)
| NSID | type | one line | doc |
|---|---|---|---|
| `ingress.webRTC` | record | the requester's WebRTC ingress listen record (rkey `webrtc`) named in `ingress[]` | [lexicons-market.md](lexicons-market.md#ingresswebrtc) |
| `badgeBlueKeys` | record | binds a signing key (or an ssh key) to the repo DID | [identity.md](identity.md#badgebluekeys) |
| `cluster.createCluster`, `deleteCluster`, `controlPlaneUp`, `controlPlaneDown`, `getKubeconfig`, `listClusters`, `listKubeconfigs`, `revokeKubeconfig`, `revokeIdentity`, `subscribeClusters` | XRPC | the gateway's tenant cluster API | [infra.md](infra.md#compublicdomainrelaytempcluster) |
| `auth.allowlist.rbacDid` | scope only (no file) | an OAuth scope; nothing writes it | [outside.md](outside.md#scope-only-collections) |
## com.fedfork.exec
| NSID | type | one line | doc |
|---|---|---|---|
| `ops.listVms`, `ops.getVm`, `ops.getVmMemory`, `ops.getBidder`, `ops.getHealth`, `ops.getLog` | query | a bidder's read-only operations routes (bearer: the ops read secret) | [../SYSTEM.md](../SYSTEM.md#xrpc) |
| `ops.getRequesterLog` | query | the ssh gateway's requester log lines of one DID | same |
| `binding`, `pins` | record (no file here; knotless) | CI executor bindings and the tested atlibs pin set, in the release account's repo | [../ci-debug.md](../ci-debug.md) |
## computer.socialweb
| NSID | type | one line | doc |
|---|---|---|---|
| `computer.socialweb.infra` | record | a long-lived deployment: contracts with their wanted state; index at `self` | [infra.md](infra.md) |
| `computer.socialweb.ephemeralInfra` | record | a short-lived deployment that ends at `createdAt + ttlSeconds` | [infra.md](infra.md) |
| `computer.socialweb.ingress.listen` | record | a WebRTC answerer's keys (rkey: the listen name, `market` for a bidder) | [market.md](market.md#xrpc-procedures) |
| `computer.socialweb.ingress.offer` | record | a sealed WebRTC offer, rkey `<answerer DID>.<tid>` | same |
| `computer.socialweb.ingress.answer` | record | the sealed answer, rkey `<offerer DID>.<tid>` | same |
| `computer.socialweb.peer` | record | how to reach one subhandle directly (iroh ticket) | [lexicons-market.md](lexicons-market.md#computersocialwebpeer) |
| `computer.socialweb.mesh.roster` | record | one socialweb-meshd overlay's roster | `lexicons/computer/socialweb/mesh/roster.json` |
| `computer.socialweb.k8s.kubectlApplyServerSide`, `k8s.getJob` | XRPC | the gateway's k8s API | [infra.md](infra.md#computersocialwebk8s) |
| `computer.socialweb.temp.policy.ghalite` | record (no file) | the requester's published policy workflow, strongRef'd by the RFP | [policy.md](policy.md) |
| `computer.socialweb.temp.policy.typescript` | record (no file) | a policy type the engine denies | [policy.md](policy.md) |
## software.release
| NSID | type | one line | doc |
|---|---|---|---|
| `software.release.project` | record | a released piece of software | [release.md](release.md) |
| `software.release.manifest` | record | the artifacts of one build, each with its CID | [release.md](release.md) |
| `software.release.version` | record | a named version: its manifest and `previous` | [release.md](release.md) |
| `software.release.channel` | record | `rc` or `stable`: the version followers track | [release.md](release.md) |
| `software.release.defs` | defs | `httpArtifact`, `target` | [release.md](release.md) |
## link.ident, network.attested, com.atproto
| NSID | type | one line | doc |
|---|---|---|---|
| `link.ident.endorsement` | record | the principal confirms an agent (rkey = the agent DID); vendored from ident.link | [identity.md](identity.md#associations-identlink) |
| `network.attested.signature` | object | the inline signature on market records | [identity.md](identity.md#networkattested) |
| `network.attested.proof`, `network.attested.verify` | record, query | defined, not written or served | [identity.md](identity.md#networkattested) |
| `com.atproto.repo.strongRef` | object | `{uri, cid}` (a vendored copy) | [outside.md](outside.md#comatprotorepostrongref) |
## Used, Not Ours
| NSID | owner | one line | doc |
|---|---|---|---|
| `sh.tangled.graph.vouch` | tangled | a trust edge, rkey = the subject DID; read by every trust policy | [outside.md](outside.md#shtangledgraphvouch) |
| `chat.atirc.mint`, `chat.atirc.revoke` | atirc | subhandle tokens for agents, leased to a contract | [outside.md](outside.md#chatatirc) |
| `com.fedproxy.rbac` | fedproxy | the requester's workload identity roles for its VMs (rkey `node.<accept rkey>`) | [outside.md](outside.md#comfedproxy) |
| `com.fedproxy.sshPublicKey` | fedproxy | OAuth scope only | [outside.md](outside.md#comfedproxy) |
| `com.atproto.*` (repo, sync, server, identity) | atproto | records, streams, sessions, `getServiceAuth`, `listReposByCollection` | [outside.md](outside.md) |
| `network.bsky.jetstream.subscribeEvents` | Bluesky | the Jetstream v2 stream | [outside.md](outside.md#streams) |
docs/protocol/guest-events.md+27−3
@@ -18,7 +18,8 @@
| payload | originator | written in | consumer | file of the consumer |
|---|---|---|---|---|
| `vm.onNetwork` | guest (iroh ticket and https tunnel URL from the `guest-onnetwork` script, webrtc fingerprint from the guest agent) or bidder (sandbox) | bidder repo | requester: `status.contract.vmAddress`, `status.contract.networks` | `internal/market/requester/runner.go` `waitGuest` |
| `vm.onNetwork` | guest (iroh ticket and https tunnel URL from `/usr/local/bin/send-onnetwork.sh` of `guest-onnetwork.service`, webrtc fingerprint from the guest agent) or bidder (sandbox) | bidder repo | requester: `status.contract.vmAddress`, `status.contract.networks` | `internal/market/requester/runner.go` `waitGuest` |
| `vm.memoryPressure`, `vm.oomKilled` | bidder (the VM unit's cgroup `memory.events`, polled 15 s, edge-triggered, at most 10 per contract) | bidder repo | requester: one `requester_market_event` line each | `internal/market/bidder/memory.go` |
| `vm.hostKeys` | bidder (the host key the guest bound at its workload identity login) | bidder repo | requester: `status.contract.hostKeys` | same |
| `vm.sandbox` | bidder (deno sandbox ended) | bidder repo | requester: `status.contract.sandbox` | `internal/market/requester/events.go` |
| `vm.terminated` | bidder | bidder repo | requester: Released | `internal/market/requester/market.go` `FindTermination` |
@@ -66,7 +67,8 @@ sequenceDiagram
- the POST body: `{acceptUri, acceptCid, record}`; the record has `$type` = the payload NSID and no signature (`internal/guestagent/events.go`)
- the bearer is the `Authorization` header only (`Guest.Events` in `internal/guestidentity/service.go`)
- answers: 200 `{ok, name}`; 401 `AuthenticationRequired` / `InvalidToken`; 400 `InvalidRequest`; 404 `UnknownGuest` / `UnknownAccept`; 503 `Unavailable`
- answers: 200 `{ok, name, guestLogin}`; 401 `AuthenticationRequired` / `InvalidToken`; 400 `InvalidRequest`; 404 `UnknownGuest` / `UnknownAccept`; 503 `Unavailable`
- `vm.onNetwork` is checked against the contract's accept only once the ComputeVM holds it (`guestrecord.go`); every other kind needs the exact accept and a receipt
- the bidder keys: `reportSyncKey` and `guestEventSyncKey` in `internal/market/bidder/syncs.go`; the rkeys: [market.md](market.md#rkeys)
- the bidder never opens a sealed body; it routes by NSID prefix
@@ -117,7 +119,9 @@ sequenceDiagram
| `vm.hostKeys` | `keys[] {type, publicKey, fingerprint}`, `observedAt` | at most 8 keys, an ed25519 key required (`internal/guestidentity/guestrecord.go`) |
| `vm.sandbox` | `exitCode`, `timedOut`, `stdout`, `stderr` | `compute.vm.kind: deno` only (`internal/market/bidder/sandbox.go`) |
| `vm.delete` | `reason` | requester writes `released` |
| `vm.terminated` | `reason`, `exitCode`, `observedAt`, `request` | `request` -> the `vm.delete` when `reason` is `deleted_on_request` |
| `vm.terminated` | `reason`, `exitCode`, `observedAt`, `request?` | reasons: [market.md](market.md#release-and-termination); `request` is optional: a `deleted_on_request` without one is a delete on the bidder |
| `vm.memoryPressure` | `kind`, `threshold`, `observed`, `observedAt` | the VM unit's cgroup `memory.events` high or max rose |
| `vm.oomKilled` | `kills`, `total`, `limit`, `observedAt` | its `oom_kill` rose |
| `guest.publicKey` | `kind: age-x25519`, `tag`, `key` (age1...) | one per tag per side; anything sealed for a tag goes to the other side's latest key |
| `guest.signalWebRTC` | `kind` offer / answer, `tag`, `ciphertext` | plaintext `{sdp, replyTo}`; non-trickle ICE, one offer, one answer |
| `guest.secrets` | `ciphertext` | age armored, at most 65536 bytes (`MaxGuestSecretsCiphertext`); plaintext = the getSecrets JSON array |
@@ -194,6 +198,26 @@ sequenceDiagram
## Secrets: getSecrets Or Sealed Fallback
To send secrets to the VM without putting them in cloud-init (public atproto data), pass a JSON file to `run request --secrets`: `[{path, value, mode?}]`. It is written only into the requester's own OpenBao; the guest fetches it at boot. This works by Workload Identity Federation, so nothing sensitive is in the public `compute.vm` record:
- each bid's `config` is a `com.publicdomainrelay.temp.compute.config.wif.simple` record: it tells the requester, before it accepts, what the OIDC issuer of the VM will be and how its `sub` claim is formed. If the VM goes away the requester can accept another bidder's bid; the WIF configuration is loosely coupled to the bidder (in-depth: [droplet-oidc-poc](https://github.com/digitalocean-labs/droplet-oidc-poc))
- the requester writes a `com.fedproxy.rbac` record in its repo at `node.<accept rkey>`: one role per VM `{role_name, definition: {iss, aud: api://ATProto?actx=<requester DID>, sub, policies}}` (`prepareWorkloadGrant` in `internal/market/requester/secrets.go`); the bidder reads it (`internal/guestidentity/rbac_reader.go`), turns the roles whose `iss` and `sub` are its own into `GuestIdentityGrant`s, and its OpenBao identity engine then lets that guest mint a token for that audience
- the user_data (`cloudinit` module setup-secrets) logs the guest in at the bidder (`guest-login token <aud>`) and sends that token to the requester's getSecrets route; the requester checks the audience against the bidder issuer's keys and the `wid_sub` claim against the subject `actx:<bidder>:plc:<requester>:role:<vm>` (`secretsState.fetch`), then answers the bundle
- who can read the bundle: the requester (its OpenBao) and the guest that holds the token. The bidder relays no secret on the getSecrets path and on the sealed path carries ciphertext it cannot open; it does run the token issuer, so a requester trusts the bidder it accepts
- release deletes the rbac record (`deleteRBAC`)
A real bid config (bidder `did:plc:2l2wdry77c7jtucbslstagkj`, read 2026-11-19):
```json
{"uri": "at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.compute.config.wif.simple/bid-596cc856db4e8aaf1080-config",
"value": {"$type": "com.publicdomainrelay.temp.compute.config.wif.simple",
"issuer_uri": "https://did-key-zq3shm88jyzpmldhqzbifwpqacv3hcp24jfsgb8g9eopcbmjm.xrpc.fedproxy.com/v1/identity/oidc",
"subject": "actx:{actx}:plc:{did-plc-key}:role:{role}", "actx": "2l2wdry77c7jtucbslstagkj",
"to_issue": "openbao-identity-oidc", "url_route": "/v1/identity/oidc/token", "createdAt": "2026-11-15T06:10:53Z"}}
```
The rest of this section is the guest's side.
- `spec.secretsRef` names a bundle `[{path, value, mode?}]` in the requester's OpenBao; mode octal, at most 0600 (`ParseSecretsBundle` in `internal/market/requester/secrets.go`)
- primary: getSecrets. `setup-secrets.service` exchanges its workload identity token and GETs `/xrpc/com.publicdomainrelay.temp.compute.secrets.getSecrets/<contract>` from the requester ingress ([lexicons-market.md](lexicons-market.md#computesecretsgetsecrets))
- the requester checks the token audience `api://ATProto?actx=<requester DID>` and the subject claim (`secretsState.fetch`)
docs/protocol/identity.md+70−10
@@ -5,6 +5,47 @@
- rule (plan 0036): the authority is always the repo in the record's at-uri, never a record field or an issuer claim
- index: [README.md](README.md). sequence steps: [S0](README.md#step-s0), [S1](README.md#step-s1), [S5](README.md#step-s5), [S9](README.md#step-s9)
## Actors
Every actor is an atproto DID with a repo on a PDS; it writes only its own repo. Prod examples (read 2026-11-19).
| actor | DID | repo lives on | writes |
|---|---|---|---|
| requester (a person) | own account, e.g. `aliceoa.bsky.social` (`did:plc:lpfuqerea3deuoyrn7ojser4`) | its PDS (bsky); or, `localRepo`, the app's own Pds | `compute.vm`, policy record, `market.rfp`, `market.accept`, `market.event` + payloads, `com.fedproxy.rbac`, vouches, the Infra records |
| bidder operator (a person) | own account, e.g. `bobvmbuilder.bsky.social` (`did:plc:ocnuqjlzgohypj3zoznermms`) | its PDS (bsky) | vouches; per bidder agent the `link.ident.endorsement` + standing `market.association` at rkey = the agent DID |
| bidder (agent) | its own did:plc (`localRepo`, `internal/stack/bidder`), DID document `alsoKnownAs: https://ident.link/agent-of/<operator DID>` | the bidder's own Pds, public through the did:key ingress (`https://did-key-<did:key>.xrpc.fedproxy.com`) | `market.offering`, `market.heartbeat`, bids, receipts, `market.event` + payloads (also the guest's) |
| bidder as the operator itself | `--atproto-oauth-qr` / `identity: {mode: oauthQr}`: the operator's own DID (`CheckSignIn` refuses any other handle) | the operator's PDS | the same, in the operator's repo |
| gateway requester | a `localRepo` agent of the gateway operator (`internal/app/gateway`) | the gateway's Pds | the RFP records of tenant cluster nodes; nodes mirror to the owner's `computer.socialweb.infra/nodes-<hex>` |
| ssh gateway session requester | the signed-in user's own DID (MarketIdentity `owner-<stamp(did)>`, `oauthSessionProxy`, `internal/app/compose/sessionowner.go`) | the user's PDS | the user's RFP records, as the user |
| guest requester R2 | a did:plc made inside a rented VM, an agent of the renter for one contract ([below](#guest-requester-r2)) | R2's own Pds in the guest | `market.associationRequest`, its own RFP records, `computer.socialweb.peer` |
| guest | none: it holds no repo key; a workload identity token from the bidder's OpenBao | - | nothing; the bidder signs and writes its events |
| release account | `socialweb.computer` (`did:plc:gmlkrhimoueejcertevr4hl3`) | its PDS (bsky) | `software.release.*` ([release.md](release.md)), `com.fedfork.exec.binding` (CI executors) |
The four prod bidders today are `bobvmbuilder.bsky.social`'s agents (`deploy/release/rc-operators.json`). One of them, as the records show it:
```json
{"did": "did:plc:2l2wdry77c7jtucbslstagkj",
"alsoKnownAs": ["https://ident.link/agent-of/did:plc:ocnuqjlzgohypj3zoznermms"],
"service": [{"id": "#atproto_pds", "serviceEndpoint": "https://did-key-zq3shc9tdkt67yslq9wahqywwix2gfvvtzstwsyvsg7ewbafg.xrpc.fedproxy.com"}]}
{"uri": "at://bobvmbuilder.bsky.social/link.ident.endorsement/did:plc:2l2wdry77c7jtucbslstagkj",
"value": {"$type": "link.ident.endorsement", "agent": "did:plc:2l2wdry77c7jtucbslstagkj"}}
{"uri": "at://bobvmbuilder.bsky.social/com.publicdomainrelay.temp.market.association/did:plc:2l2wdry77c7jtucbslstagkj",
"value": {"$type": "com.publicdomainrelay.temp.market.association", "agent": "did:plc:2l2wdry77c7jtucbslstagkj", "createdAt": "2026-11-11T09:37:44.146Z"}}
```
The operator writes the pair once: by signing in at the bidder's MarketIdentity `operator` URL (`compose.ApplyOperatorPair`: grant, then endorsement), or with `scripts/associate-bidder.ts --agent-did <did>`. The bidder adds its own `agent-of` to its DID document (`compose.UpdateAgentOf`, signed with its Pds PLC rotation key).
### Keys: who signs what
| key | held in | signs |
|---|---|---|
| attestation key (secp256k1 JWK, 0600): bidder `<state>/attestation.jwk`, requester `attestation-key.json` | the app's state dir | the `signatures` of every market record and event payload ([below](#networkattested)) |
| repo signing key | the PDS (bsky for an account there; the app's Pds `repo-keys/<sha256(did)>.key` for `localRepo`, copied into the requester's `repo-key.json` and `attestation-key.json`, `compose.SyncRequesterRepoKey`) | repo commits; a `localRepo` requester's self-signed service auth |
| a PDS session (OAuth or password) | the app's OpenBao (`auth/atproto session/<did>`) | `com.atproto.server.getServiceAuth` for `market.submit*`, `chat.atirc.*`, `computer.socialweb.k8s.*` |
| PLC rotation key | the app's Pds `plc-rotation.key`; the renter's `<requester dir>/plc-rotation.key` (k256, first rotation key of every R2 DID it rents) | DID document updates (`agent-of`), tombstones |
| did:key ingress key (bidder `market-relay.jwk`) | the state dir | the ingress relay registration (self-signed, no DID document) |
| guest ssh host key (`ssh_host_ed25519_key`) | the guest | its workload identity bind at the bidder's OpenBao (`sshsig`), which binds its host key to the ComputeVM |
## Lexicons And NSIDs In This File
| NSID | type | rkey | used |
@@ -41,7 +82,7 @@ flowchart LR
- records with a `signatures` field: `market.rfp`, `market.bid`, `bids.free`, `bids.x402`, `market.accept`, `accepts.free`, `accepts.x402`, `market.receipt`, `receipts.free`, `receipts.x402`, `market.event`, every `compute.events.vm.*` and `compute.events.guest.*`
- signing keys: secp256k1 JWK files, mode 0600 (`internal/atproto/market/keys.go` `LoadOrCreateSignerFile`)
- bidder: `<stateDir>/attestation.jwk` (`internal/services/bidder/wiring.go`)
- requester: `attestation-key.json`, else `repo-key.json` (`internal/market/requester/requester.go`); compose seeds both with the same key (`internal/app/compose/pds.go`)
- requester: `attestation-key.json`, else `repo-key.json` (`internal/market/requester/requester.go`); for `localRepo`, gateway and R2 identities compose seeds both from the app Pds repo signing key of the DID (`internal/app/compose/pds.go` `SyncRequesterRepoKey`)
- the public `did:key` (`Signer.PublicDID`) is the `keyId` of the signer key binding below
### Verifying
@@ -61,15 +102,15 @@ flowchart LR
|---|---|
| NSID | `com.publicdomainrelay.temp.badgeBlueKeys` |
| type | record, key `any` |
| key fields | `keyId` (the bound key), `challenge` (the repo DID it binds to), `service`, `nonce`, `name`, `createdAt` |
| key fields | `keyId` (the bound key), `challenge` (the repo DID it binds to), `service`, `createdAt`; optional `nonce`, `name` (the signer binding writes neither) |
| Go | `internal/atproto/market/badgeblue.go` |
One collection, two uses. Each has its own rkey and `service`.
| use | in repo of | rkey | `keyId` | `challenge` | `service` | written by | read by | step |
|---|---|---|---|---|---|---|---|---|
| signer key binding | the signer (bidder or requester) | `BadgeBlueKeysRkey(did, keyId)`: base58 of sha256(`did:keyId`)[:24], max 32 chars | signer `did:key` | the signer's repo DID | `bidder_attestation` (bidder), `market_requester` (requester) | bidder `internal/market/bidder/offering.go`; requester `internal/market/requester/identity.go` | `KeyBoundByBadgeBlueKey` from `participant/comms.go`, `requester/events.go` | S0, before the first signed record |
| ssh key claim | the user | stable `keyRkey` | the ssh key | the user DID | ssh | ssh.socialweb.computer `/keys` | ssh authorizer, one getRecord per offered key (`internal/sshtransport`) | ssh sign-in |
| signer key binding | the signer (bidder or requester) | `BadgeBlueKeysRkey(did, keyId)`: base58 of sha256(`did:keyId`)[:24], max 32 chars | signer `did:key` | the signer's repo DID | `bidder_attestation` (bidder), `market_requester` (requester) | bidder `internal/market/bidder/offering.go` (at start, retried on each heartbeat); requester `internal/market/requester/identity.go` (owner-session, OAuth and callback identities only: a localRepo requester signs with its repo key, which its DID document names) | `KeyBoundByBadgeBlueKey` from `participant/comms.go`, `requester/events.go` | S0 |
| ssh key claim | the user | `keyRkey`: 13 TID-alphabet chars of sha256(`sshtransport/badge-blue-key/v1`, did, key) (`internal/sshtransport/keys.go`) | `<algo> <key>` | the user DID | `requester_associate` | ssh.socialweb.computer `/keys` | ssh authorizer, one getRecord per offered key (`internal/sshtransport/authorizer.go`) | ssh sign-in |
## Associations (identlink)
@@ -104,15 +145,34 @@ One collection, two uses. Each has its own rkey and `service`.
| bidder networked deno | roots(requester) meets roots(bidder) |
| bidder guest lifetime cap | walk `expiresAt` of the requester |
| requester discovery | roots(self) are operators; an operator's endorsed agents whose walk reaches it |
| MarketIdentity associated | its DID's walk has a root other than itself; `associationRef` pins the grant (rkey = the DID) and its walk must reach the grant's repo |
| MarketIdentity associated | localRepo only: its DID's walk has a root other than itself; `associationRef` pins the grant (rkey = the DID) and its walk must reach the grant's repo; `spec.approvedAssociations` are listed as roots without a walk (`internal/marketidentity/atproto/association.go`); OAuth modes report none |
### Contract-scoped association
- the guest requester R2 is an agent of the renter for one contract: grant `contract` = the renter's `market.accept`, `expiresAt` = the contract deadline
- `market.associationRequest {principal, contract, nonce}` in the guest repo, rkey = principal DID: the principal endorses only the DID that answered this contract's nonce
- writers: requester `association.go` (renter: grant + endorsement at rkey = R2 DID after the nonce check), compose `records.go` (operator pair, agent-of), compose `peer.go` (R2: its co-located accounts' grant + endorsement, their peer records without `lease`)
- the renter writes no VM agent peer record and no self-association; the bundle entry `/etc/socialweb-computer/association-request.json` is {principal, contract, nonce, rotationKey}
- guest events of this flow (`requesterDid`, `r2Start`, `r2Release`, `r2Released`): [guest-events.md](guest-events.md)
- the guest requester R2 is an agent of the renter for one contract: grant `contract` = the renter's `market.accept` `{uri, cid}`, `expiresAt` = the accept time + 24 h (`market.ContractAssociationLifetime`)
- `market.associationRequest {principal, contract, nonce, accounts?, createdAt}` in the guest repo, rkey = principal DID: the principal endorses only the DID that answered this contract's nonce
- writers: requester `association.go` (renter: grant + endorsement at rkey = R2 DID after the nonce check), compose `records.go` (operator pair, agent-of, the association request), compose `peer.go` (R2: its co-located accounts' grant + endorsement, with R2's contract and expiresAt, and their peer records `{iroh?, createdAt}`)
- the renter writes no VM agent peer record and no self-association; the bundle entry `/etc/socialweb-computer/association-request.json` is {principal, contract, nonce (48 hex), rotationKey (the renter's did:key), handle?}
- guest events of this flow (`requesterDid`, `r2Start`, `r2Release`, `r2Released`): [guest-events.md](guest-events.md); the lifecycle: [Guest requester (R2)](#guest-requester-r2)
## Guest Requester (R2)
What it is for: a machine that rents machines from inside a rental. A CI VM rented as R2's host (the knotless executor binding `com.fedfork.exec.binding/kcp-test` of `socialweb.computer` has `inputs.association: true`) runs `socialweb-computer run request --guest-requester`, and that requester rents the staging network's VMs as an agent of the renter, for that one contract only. The `release` binding asks for none (`scripts/promote.sh prepare` exits 1 on a VM that has one).
| step | who | what (source) |
|---|---|---|
| ask | renter | `spec.association {fromGuest: true}` (`run request --associate guest`; `spec.agent` with no association defaults to it: `requester.DefaultAssociation`); the bundle gets `/etc/socialweb-computer/association-request.json` {principal, contract, nonce, rotationKey, handle?} (`ensureAssociationRequest`) |
| create | R2 in the guest | a `localRepo` account on its own Pds (`internal/app/marketrequester`): did:plc with `alsoKnownAs: https://ident.link/agent-of/<renter DID>` and rotation keys [renter key, R2 Pds key] (`internal/pds/plcsubmit`); handle `<label>-<rfp rkey>.<renter handle>` when the renter's handle verifies; PLC: the renter network's, else none given (the requester default `https://plc.directory`) |
| request | R2 | `market.associationRequest/<renter DID>` {principal, contract, nonce, accounts?} in its repo; then writes its DID to `requester-did` |
| report | guest agent | `guest.requesterDid {did}` (did:plc only, never the renter's own DID: `market.ValidGuestRequesterDID`) |
| verify | renter | records the DID Pending (a second DID is refused), one getRecord of `<R2>/market.associationRequest/<renter DID>`, principal and contract equal, nonce equal (constant time) (`proveGuestRequester`) |
| grant | renter | `market.association/<R2 DID>` {agent, contract: the accept, expiresAt: accept + 24 h} and `link.ident.endorsement/<R2 DID>` in its own repo; the ref `<uri>#<cid>` into the bundle at `association-ref`; `guest.secretsUpdated` (`associate`, `notifySecretsUpdated`) |
| use | everyone | R2's walk reaches the renter while the grant lives and the contract is held (the accept has a receipt, no `vm.delete`, no `vm.terminated`: `trust/association.go` `contractHeld`); co-located accounts `<label>.<R2 handle>` get grants from R2 with the same contract and expiresAt |
| bound | bidder | a VM of R2 ends 10 min after `spec.associationExpiresAt`, and within a minute once the outer contract's `vm.terminated` or `vm.delete` exists (`association_ended`) |
| retire | renter, R2 | release sends `guest.r2Release`, waits for `guest.r2Released` (`GuestRequesterReleaseTimeout`); R2's `run request release` sets `spec.peer.retire`: its peer, grant and endorsement records go, its accounts are deactivated and tombstoned with R2's Pds rotation key (`compose/peer.go`) |
| tombstone fallback | renter | on release the renter waits up to 2 min (`RenterTombstoneWait`) for the guest's tombstones, then tombstones R2 and its verified co-located accounts with its own `plc-rotation.key`, only when the DID document names `agent-of/<renter>` (or `<R2>`) and that key is a rotation key (`renterkey.go`, `requester_tombstoned`); then deletes its grant and endorsement |
Trust never depends on that cleanup: the grant's `expiresAt`, `vm.delete` and `vm.terminated` end every link.
## Sign-In
docs/protocol/lexicons-market.md+11−11
@@ -109,8 +109,8 @@
| file | `market/rfp.json` |
| type | record, key any |
| key fields | `payload`* (strongRef -> `compute.vm`), `signatures`*, `domain` (`compute`), `submitBid`, `ingress[]`, `policies[]`, `createdAt` |
| rkey | TID (`market.CreateRFP` passes no rkey) |
| written by | requester: `contractRunner` in `internal/market/requester/runner.go` via `market.CreateRFP` (`internal/atproto/market/records.go`) |
| rkey | TID (`putRFP` puts the signed record at a TID it makes) |
| written by | requester: `contractRunner` in `internal/market/requester/runner.go` `putRFP` (`market.BuildRFP`, `market.SignRecord`, putRecord) |
| read by | bidder: stream or `submitRfp`, then `getRecord` (`internal/market/bidder/submit.go` `SubmitRFP`, `acceptContract` in `internal/market/bidder/adapters.go`); bid window from `createdAt` (`internal/atproto/market/rfpwindow.go`) |
| step | [S3](README.md#step-s3) |
@@ -158,7 +158,7 @@
| type | record, key any |
| key fields | `rfp`*, `bid`*, `signatures`*, `payload` (unset by the code), `submitEvent`, `ingress[]`, `createdAt` |
| rkey | `acceptRKeyFor` -> `market.SessionRKey("accept", repoDID, contract, rfpURI, rfpCID, bidURI, bidCID)` (`internal/market/requester/secrets.go`) |
| written by | requester: `market.CreateAcceptAt` from `runner.go` |
| written by | requester: `putAccept` in `runner.go` (`market.SignRecord`, putRecord) |
| read by | bidder: `submitAccept` or stream -> provisioning StateSync (`SubmitAccept` in `internal/market/bidder/submit.go`, `acceptContract`); the receipt `cid` binds it |
| step | [S5](README.md#step-s5) |
@@ -279,7 +279,7 @@
| key fields | `agent`* (== rkey), `createdAt`*, `expiresAt`, `contract` (-> `market.accept`, needs `expiresAt`) |
| rkey | the agent DID |
| meaning | the grant beside the `link.ident.endorsement` at the same rkey: [identity.md](identity.md#associations-identlink) |
| written by | requester (`association.go`), guest requester (`internal/app/compose/peer.go`); both still write the old shape until the writer cut-over |
| written by | the operator (standing, no `contract`: `compose.ApplyOperatorPair`, `scripts/associate-bidder.ts`); the renter for its guest requester (`contract` = the accept `{uri, cid}`, `expiresAt` = accept + 24 h: `internal/market/requester/association.go`); the guest requester for its co-located accounts (R2's contract and expiresAt: `internal/app/compose/peer.go`) |
| read by | `internal/identlink` walk: policy trust, bidder lifetime cap (`internal/market/bidder/association.go`, ComputeVM `spec.associationExpiresAt` = the walk `expiresAt`; `spec.associationContracts` = the contracts (accept + receipt) of its contract-scoped grants at accept, and the VM ends `association_ended` once each of them has its `vm.terminated` or `vm.delete`), requester discovery, MarketIdentity |
| chain | from the agent's DID document (`alsoKnownAs` agent-of), up to `maxDepth` (AssociationPolicy `maxDepth`, 1 to 100, default 100), 256 getRecords per walk. `socialweb-computer internal association <did>` prints the walk |
| step | [S5](README.md#step-s5), [S8](README.md#step-s8); release deletes only its own |
@@ -290,8 +290,8 @@
|---|---|
| file | `market/associationRequest.json` |
| type | record, key any |
| key fields | `principal`*, `contract`* (the principal's accept uri), `nonce`*, `createdAt`* |
| rkey | the principal DID (writers still use `market.ContractScopedRKey` until the writer cut-over) |
| key fields | `principal`*, `contract`* (the principal's accept uri), `nonce`*, `createdAt`*, `accounts` (the co-located DIDs) |
| rkey | the principal DID (`compose.ApplyAssociationRequestRecord`) |
| written by | the guest requester: an AtprotoRecord object from `internal/app/compose/records.go` |
| read by | the authority requester: one `getRecord` in the DID the guest reported (`internal/market/requester/association.go`); `cmd/socialweb-computer/requestassociation.go` |
| step | [S8](README.md#step-s8); flow: [identity.md](identity.md#associations-identlink) |
@@ -302,12 +302,12 @@
|---|---|
| file | `computer/socialweb/peer.json` |
| type | record, key any |
| key fields | `createdAt`*, `iroh` (short ticket), `webrtc` (the DID answering ingress offers), `channels` |
| key fields | `createdAt`*, `iroh` (short ticket); the lexicon also has `webrtc` (the DID answering ingress offers) and `channels`, which no writer sets |
| rkey | the subhandle: the guest requester's atirc subhandle (`r2-<accept rkey>.<owner handle>`, its handle without one); `<name>.<that>` for a co-located account; `<label>-<rfp rkey>.<handle>` for a contract's atirc agent (label: the handle's first label, at most 14 characters) |
| iroh | the short ticket of the node that is that identity: for an account a PDS hosts, the PDS's XRPC endpoint (ingress-iroh); for an atirc agent identity, its `atirc mesh run` daemon (ALPN `atirc/mesh/1`). One identity, one node; the dialer picks the protocol by ALPN |
| written by | the guest requester (`run request --guest-requester [--colocated a,b]`): AtprotoRecord objects of `internal/app/compose/peer.go` in its own repo and each co-located account's, present only while its association ref verifies; the requester of a spec.agent contract (`internal/market/requester/agentpeer.go`) after the verified receipt, in its own repo: `iroh` the ticket (no addresses) of the 32-byte ed25519 seed it generated into the bundle (`/etc/atirc/iroh_key.hex`, 0600), `lease` a contract-scoped market.association in its own repo whose `subject` is its own DID (`service` requester_associate, `contract` the accept, `expiresAt` 24 h after the write, rewritten when under 1 h is left at a receipt or restart) |
| written by | the guest requester (`run request --guest-requester [--colocated a,b]`): AtprotoRecord objects of `internal/app/compose/peer.go` in its own repo and each co-located account's, present only while its association ref verifies. The requester of a spec.agent contract writes no peer record: after the verified receipt it puts the agent's iroh key (a 32-byte ed25519 seed, `/etc/atirc/iroh_key.hex`, 0600) and, for a guest requester, `R2_COLOCATED=<nick>=<ticket>` (`/etc/socialweb-computer/r2-agent.env`) into the bundle (`internal/market/requester/agentpeer.go` `publishAgentPeer`), and R2 writes the agent's peer record |
| read by | mesh peers: one `getRecord(DID, computer.socialweb.peer, subhandle)`, never listRecords; trusted only while the walk of the repo DID reaches the owner |
| release | the guest requester's `run request release` sets `spec.peer.retire`: the peer, association and keys-mirror records are deleted, each local account deactivated and its did:plc tombstoned (best effort; expiry covers a skipped cleanup); a spec.agent contract's release deletes its agent peer record and its lease association, best effort (the lease's `expiresAt` ends the binding without it) |
| release | the guest requester's `run request release` sets `spec.peer.retire`: the peer, association and endorsement records are deleted, each local account deactivated and its did:plc tombstoned (best effort; expiry covers a skipped cleanup) |
## market.submitRfp
@@ -340,7 +340,7 @@
| file | `market/submitAccept.json` |
| type | procedure, issuer = requester |
| input | `{acceptUri, acceptCid, ingress?}` |
| output | 202 `{ok, id, acceptUri, acceptCid}`; lexicon also has `uri`, `cid`, `submitEvent`, `ingress`; errors add `InternalError` |
| output | 202 `{ok, id, acceptUri, acceptCid}`; lexicon also has `uri`, `cid`, `submitEvent`, `ingress` (never returned); errors add `InternalError`; the code also answers 409 `CapacityExceeded` (not in the lexicon) |
| served by | bidder: `handleSubmitAccept` -> `Bidder.SubmitAccept` (provisioning StateSync) |
| called by | requester: `submitAcceptAndWait` (`internal/market/requester/accept.go`) |
| step | [S5](README.md#step-s5) |
@@ -364,7 +364,7 @@
| file | `compute/vm.json` |
| type | record, key any |
| key fields | `role`* (VM name in the contract), `kind` (`vm` default, `deno`), `cpus` (2), `mem` (`4G`), `disk` (`50G`), `nestedVirt`, `image` (`{url, sha256}`: an https base holding `image.json`, sha256 of that file), `network`, `location`, `user_data`, `createdAt` |
| rkey | TID (`CreateRecord`) |
| rkey | TID (`putSetupRecord`: putRecord at a TID; unsigned) |
| written by | requester: `runner.go` with `DefaultComputeCPUs`, `DefaultComputeMem`, `DefaultComputeDisk` (`internal/market/requester/requester.go`); `user_data` from `cloudinit.BuildUserData` (`internal/atproto/cloudinit`) |
| read by | bidder through `rfp.payload`: kind check (`rfpKind` in `submit.go`), boot (`acceptContract`, `internal/guestseed` adds the binaries unit) |
| step | [S3](README.md#step-s3) |
docs/protocol/market.md+64−25
@@ -22,9 +22,9 @@
| step | record | repo | rkey | strongRefs it holds |
|---|---|---|---|---|
| [S3](README.md#step-s3) | `compute.vm` | requester | TID (`CreateRecord`) | none. `user_data` = cloud-init from `cloudinit.BuildUserData` |
| [S3](README.md#step-s3) | policy record `computer.socialweb.temp.policy.ghalite` | requester | TID | none ([policy.md](policy.md)) |
| [S3](README.md#step-s3) | `market.rfp` | requester | TID (`market.CreateRFP`) | `payload` -> `compute.vm`, `policies[]` -> policy record, `ingress[]` -> `ingress.webRTC` listen |
| [S3](README.md#step-s3) | `compute.vm` | requester | TID (`putSetupRecord`: putRecord at a TID; unsigned; one per contract, reused by every RFP round) | none. `user_data` = cloud-init from `cloudinit.BuildUserData` |
| [S3](README.md#step-s3) | policy record `computer.socialweb.temp.policy.ghalite` | requester | TID (putRecord; unsigned) | none ([policy.md](policy.md)) |
| [S3](README.md#step-s3) | `market.rfp` | requester | TID (`putRFP`: `BuildRFP`, `SignRecord`, putRecord) | `payload` -> `compute.vm`, `policies[]` -> policy record, `ingress[]` -> `ingress.webRTC` listen |
| [S4](README.md#step-s4) | `compute.config.wif.simple` | bidder | `<bid rkey>-config` | none |
| [S4](README.md#step-s4) | `market.bids.free` | bidder | `<bid rkey>-payload` | none |
| [S4](README.md#step-s4) | `market.bid` | bidder | `market.BidRKey` | `rfp` -> rfp, `config` -> wif config, `payload` -> bids.free |
@@ -52,7 +52,9 @@ Stable rkeys make every write idempotent and every read one `getRecord`. A resta
| requester ContractEvent payload + event | `SessionRKey("contract-event", uid)`, `SessionRKey("contract-event-envelope", uid)` | `publishContractEvent` | `internal/market/requester/contractevents.go` |
| `market.offering`, `market.heartbeat`, `market.relays` | `self` | `OfferingRKey`, `HeartbeatRKey`, `RelaysRKey` | `internal/atproto/market/nsid.go` |
| requester `ingress.webRTC` listen | `webrtc` | `ingressDescriptor` | `internal/market/requester/requester.go` |
| contract-scoped `market.association`, `market.associationRequest` | `<service>-<first 32 hex of sha256(did)>-<accept rkey>` | `market.ContractScopedRKey` | `internal/atproto/market/guest.go` |
| contract-scoped `market.association` (and its `link.ident.endorsement`) | the agent DID (the guest requester's); one grant per agent, refused when it is bound to another contract | `associate` (`rkey := subject`) | `internal/market/requester/association.go` |
| `market.associationRequest` | the principal DID (the renter's) | `ApplyAssociationRequestRecord` | `internal/app/compose/records.go` |
| `com.fedproxy.rbac` | `node.<accept rkey>` | `market.RBACRKey` | `internal/atproto/market/records.go` |
- the bidder's event idempotency keys (`internal/market/bidder/syncs.go`): `onNetwork:<receipt>`, `onNetwork:<tag>:<receipt>`, `hostKeys:<receipt>`, `terminated:<receipt>`, `guest:<nsid>:<tag>:<kind>:<n>:<receipt>` (n = 0, 1, ... per VM, nsid, tag and kind: a guest's n-th event of that stream), else `<nsid>:<receipt>`
- so a requester reads a guest's events send/recv style, one `getRecord` each: n = 0, 1, ... until one is not found (never `listRecords`)
@@ -102,13 +104,40 @@ flowchart LR
| record | writer | reader | rule |
|---|---|---|---|
| `market.offering` at `self` | bidder (`internal/market/bidder/offering.go`) | requester (`market.ReadOffering`) | `appliesTo` must hold `compute.vm` (`market.OfferingApplies`); `endpoints[]` = where the market XRPC goes (`{kind, address}`: iroh a short ticket, node id and relay, no IPs; https an origin; the requester takes iroh first when it has dumbpipe, else https); `withdrawnAt` + empty `appliesTo` = withdrawn |
| `market.heartbeat` at `self` | bidder, every `HeartbeatInterval` (60 s) | requester (`market.HeartbeatCache`), `internal/marketpresence` | fresh while `createdAt` is at most `HeartbeatTTL` (300 s) old; `offering` names the offering (a legacy non-`self` rkey is read through it) |
| `market.offering` at `self` | bidder (`internal/market/bidder/offering.go`) | requester (`market.ReadOffering`) | `appliesTo` must hold `compute.vm` (`market.OfferingApplies`); `endpoints[]` = where the market XRPC goes (`{kind, address}`: `iroh` a short ticket, node id and relay, no IPs; `webrtc` base64url JSON `{did, listen}`; `https` an origin); `maxCpus` (the host's cores), `maxMem` (its RAM), `nestedVirt`, `images`; `withdrawnAt` + empty `appliesTo` = withdrawn (a guest image that does not verify withdraws it) |
| `market.heartbeat` at `self` | bidder, every `spec.heartbeatIntervalSeconds` (default 60 s) | requester (`market.HeartbeatCache`), `internal/marketpresence` | fresh while `createdAt` is at most `HeartbeatTTL` (300 s) old and not more than 60 s ahead; `offering` names the offering (a legacy non-`self` rkey is read through it); `version {version, commit, sha256}` of the running binary |
| `market.relays` at `self` | no Go writer here | requester (`market.RelayURLsOf`) | extra relays to ask `listReposByCollection` |
- candidate bidders (`HTTPMarket.discover` in `internal/market/requester/market.go`): DIDs from `com.atproto.sync.listReposByCollection?collection=market.offering` on each relay (configured + `market.relays` of the trust roots, `internal/market/requester/discovery.go`), or the contract's `spec.bidderDids` only
- unnamed candidates without a fresh heartbeat are dropped (`dropNoHeartbeat`); `spec.denyBidderDids` are dropped
- discovery results are cached 20 s
- candidate bidders (`candidateSources` in `internal/market/requester/discovery.go`, `HTTPMarket.discover` in `market.go`), in order:
- the requester's own `spec.bidderDIDs` (named: no heartbeat needed)
- every DID `com.atproto.sync.listReposByCollection?collection=market.offering` lists on each relay: the network relay, else `spec.comms.relayUrls`, else `relay1.us-east.bsky.network` and our relay; plus `market.relays/self` of self and `spec.operatorDID`
- the DIDs its operators vouch for (operators = self, `spec.operatorDID`, the roots of its identlink walk; at most 64)
- the agents those operators endorse (`link.ident.endorsement`) whose walk reaches the operator (one level down)
- discovery is not a trust filter: the relay lists every bidder; the policy decides who is served ([policy.md](policy.md))
- a contract's `spec.bidderDids` narrows that set (it adds no DID); `spec.denyBidderDids` and the bidders that declined this contract are removed (`Discovery.Without`)
- unnamed candidates without a fresh heartbeat are dropped (`dropNoHeartbeat`); then `Bidder.Lacks`: `maxCpus` below the VM's cpus, no `nestedVirt`, no `images` for an image contract (`maxMem` is not read)
- every candidate dropped for good (a capability or a size): the contract fails at once; none at all with `bidderDids` set: no bids
- discovery results are cached 20 s (only when a bidder was found)
- a bidder's endpoint: the first of iroh (only with `dumbpipe` on PATH), webrtc, https in its offering (`DefaultEndpointKinds`; `SOCIALWEB_REQUESTER_BIDDER_ENDPOINTS` replaces the order); service auth aud `<bidder DID>#pdr_temp_market`
A real offering and heartbeat (one of `bobvmbuilder.bsky.social`'s prod bidders, read 2026-11-19, addresses trimmed):
```json
{"uri": "at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.market.offering/self",
"value": {"$type": "com.publicdomainrelay.temp.market.offering",
"appliesTo": ["com.publicdomainrelay.temp.compute.vm"],
"endpoints": [{"kind": "iroh", "address": "endpointadsmudoo..."},
{"kind": "webrtc", "address": "eyJkaWQiOiJkaWQ6cGxjOjJsMndkcnk3N2M3anR1Y2JzbHN0YWdraiIsImxpc3RlbiI6Im1hcmtldCJ9"}],
"maxCpus": 16, "maxMem": "47253M", "nestedVirt": true, "images": true,
"createdAt": "2026-10-31T06:08:35Z", "refreshedAt": "2026-11-18T16:04:01Z"}}
{"uri": "at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.market.heartbeat/self",
"value": {"$type": "com.publicdomainrelay.temp.market.heartbeat",
"offering": "at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.market.offering/3myowdvhzjy22",
"version": {"version": "v0.0.0-rc99.0.20261119030632-688c2105f879", "commit": "688c2105f879...", "sha256": "d4933943..."},
"createdAt": "2026-11-19T08:12:43Z"}}
```
The webrtc address decodes to `{"did":"did:plc:2l2wdry77c7jtucbslstagkj","listen":"market"}`. This heartbeat's `offering` still names a legacy TID rkey; the reader falls back to it only when `self` is missing.
## Delivery: XRPC Callbacks And Streams
@@ -133,9 +162,9 @@ Every record also reaches the other side two ways. The XRPC call is the fast pat
| NSID | served by | caller | body | answer | file |
|---|---|---|---|---|---|
| `market.submitRfp` | bidder ingress | requester | `{rfpUri, rfpCid, ingress?}` | 200 `{ok, name, phase: Deciding, ingress?, declined?: {kind: capacity|unservable, reason}}`; 409 `RFPClosed` after the bid window | `internal/services/bidder/routes.go` `handleSubmitRFP` |
| `market.submitRfp` | bidder ingress | requester | `{rfpUri, rfpCid, ingress?}` | 200 `{ok, name, phase: Deciding, ingress?, declined?: {kind: capacity\|unservable, reason}}`; 409 `RFPClosed` after the bid window (by the RFP's TID rkey); 400, 401/403, 500, 503 `Suspended`/`Unavailable` | `internal/services/bidder/routes.go` `handleSubmitRFP` |
| `market.submitBid` | requester ingress | bidder | `{uri, cid, record}` of the `market.bid` | 200 `{ok}`; 403 when the record is not the issuer's | `internal/services/requester/routes.go`, `Requester.SubmitBid` in `internal/market/requester/callbacks.go` |
| `market.submitAccept` | bidder ingress | requester | `{acceptUri, acceptCid, ingress?}` | 202 `{ok, id, acceptUri, acceptCid}` (`id` = the provisioning intent); the receipt follows as a record. the lexicon also allows `uri`, `cid`, `submitEvent`, `ingress` | `handleSubmitAccept` |
| `market.submitAccept` | bidder ingress | requester | `{acceptUri, acceptCid, ingress?}` (`ingress` is parsed, not used) | 202 `{ok, id, acceptUri, acceptCid}` (`id` = the provision StateSync `accept-<16 hex>`); 409 `CapacityExceeded` before any receipt; the receipt follows as a record. the lexicon's output also allows `uri`, `cid`, `submitEvent`, `ingress`; the code returns none of them, and the lexicons list neither `CapacityExceeded` nor `RFPClosed` | `handleSubmitAccept` |
| `market.submitEvent` | both ingresses | the contract party that wrote the event | `{uri, cid, record}` of the `market.event` | 200 `{ok}`; 403 `Forbidden` when the sender is not the accept author (to a bidder) or the receipt author (to a requester) | `handleSubmitEvent`, `Requester.SubmitEvent` |
- auth: a service-auth JWT with `lxm` = the NSID; the token issuer is the caller (`AuthorizeCallback` in `internal/market/requester/callbacks.go`, `participant.Authorizer`)
@@ -163,9 +192,10 @@ Every record also reaches the other side two ways. The XRPC call is the fast pat
- bidder side window: `market.RFPBidWindow` = 10 min from the RFP `createdAt`, else from its TID rkey (`internal/atproto/market/rfpwindow.go`). the lexicon has no expiry
- a closed RFP: submitRfp answers 409 `RFPClosed`, the stream sink drops it (`market_rfp_closed_dropped`), a Deciding Bid fails `BidWindowOver` (`bidder_rfp_closed`)
- one bid per RFP: the Bid object is named `market.BidRKey`; after its TTL (24 h, `BidTTLSeconds`) the bidder's own `market.bid` at that rkey is the fact (`bidder_rfp_already_bid`, `enqueueBid` in `internal/market/bidder/submit.go`)
- requester side window: `RequesterSpec.bidWindowSeconds` (default 30 s); the first policy-allowed free bid ends it (`collectBids` in `internal/market/requester/runner.go`)
- `status.chosen.reason`: `firstFree`, `bestWithinWindow`, `policy`, `resumed`; `status.bids` keeps at most 20 (`MaxRecordBids`)
- no bids: outcome `NoBids`; all denied: `BidsDenied`; winner denied by policy: `PolicyRejected`
- requester side window: `RequesterSpec.bidWindowSeconds` (default 30 s); the first free bid the scope policy allows ends it, else the lowest-cost allowed bid after the window (`collectBids`, `bestBid` in `internal/market/requester/runner.go`)
- the requester also reads each discovered bidder's bid at `BidRKey` once, min(5 s, window/2) after submitRfp (`catchUpBids`, at most 32 DIDs)
- `status.chosen.reason`: `firstFree` or `policy` (the enum also has `bestWithinWindow` and `resumed`; no code path leaves them written); `status.bids` keeps at most 20 (`MaxRecordBids`)
- no bids: outcome `no_bids` (then the capacity wait below); all denied: `bids_denied`; winner denied by the full policy: `policy_rejected` (no fallback to the next bid)
## Policies Attached
@@ -215,8 +245,8 @@ sequenceDiagram
R->>R: VMAddress + HostKeys set, secrets fetched, ComputeContract Held
```
- waits (`internal/market/requester/requester.go`): receipt `DefaultReceiptTimeout` 5 min, iroh address `DefaultVMReadyTimeout` 120 s, host keys `DefaultHostKeysTimeout` 120 s, getSecrets fetch `DefaultVMReadyTimeout`
- Held needs the iroh address and the host keys (`waitGuest`, `runGuestAndHold` in `runner.go`); a sandbox (`compute.vm.kind: deno`) needs its `vm.sandbox` result instead
- waits (`internal/market/requester/requester.go`): receipt `DefaultReceiptTimeout` 5 min (submitAccept re-sent every 0.5 s doubling to 2 s until then, `accept.go`), iroh address `DefaultVMReadyTimeout` 120 s (an image contract: + `RequestedFetchTimeout` 30 min), host keys `DefaultHostKeysTimeout` 120 s, `guest.image` 120 s after on network (image contracts), getSecrets fetch 120 s
- Held needs the iroh address and the host keys, plus the image marker for an image contract and the getSecrets fetch when `spec.secretsRef` is set and the fallback is not `Sealed` (`waitGuest`, `runGuestAndHold` in `runner.go`); a sandbox (`compute.vm.kind: deno`) needs its `vm.sandbox` result instead
- the guest side of S7 and S8: [guest-events.md](guest-events.md)
## Release And Termination
@@ -225,11 +255,11 @@ sequenceDiagram
2. guest requester first: `releaseGuestRequester` publishes `guest.r2Release` and waits for `guest.r2Released` (only with `spec.association.fromGuest`)
3. atirc tokens: `revokeBeforeDestroy` (`internal/market/requester/atirc.go`) revokes a leased token while its lease is alive
4. `destroyEnvelope`: `compute.events.vm.delete` at `ReleasePayloadRKey(receipt)` + `market.event` at `SessionRKey("event", receipt)`, both signed
5. `submitEvent` to the bidder; retried with `releaseRetryDelay` until the release deadline. no endpoint: the stream carries it
6. bidder: `applyRelease` -> `verifyInboundDelete` (event author = accept author, receipt is its own), `markReleaseRequested` records the release request on the Bid and ComputeVM, and the ComputeVM is deleted (`internal/market/bidder/adapters.go`, `internal/market/bidder/bids.go` `finishRelease`)
7. bidder: termination StateSync (`internal/computevm/termination.go`, adapter `atproto.market.event`) writes `compute.events.vm.terminated` `{reason: deleted_on_request, request -> the vm.delete}` + `market.event` at `EventRKeys(TerminationKey(receipt))`
8. requester: `Released` once submitEvent answered 2xx, or once the bidder's `vm.terminated` appears (`settleTerminated`)
9. requester deletes only its own contract-scoped records (`deleteContractRecords`: the `com.fedproxy.rbac` grant, the contract association)
5. `submitEvent` to the bidder; retried 5 s doubling to 5 min (`DefaultReleaseRetryFirst`, `DefaultReleaseRetryMax`) until the release deadline (the contract's creation plus `ttlSecondsAfterFinished`, default 8 days; `DefaultReleaseBound` 24 h when that is 0), checking for the bidder's `vm.terminated` after each wait. no endpoint: the stream carries it
6. bidder: `applyRelease` -> `verifyInboundDelete` (event author = accept author, receipt is its own, both signatures), `markReleaseRequested` records the release request on the Bid and ComputeVM, and the ComputeVM is deleted (`internal/market/bidder/adapters.go`, `internal/market/bidder/bids.go` `finishRelease`)
7. bidder: termination StateSync (`internal/computevm/termination.go`, adapter `atproto.market.event`) writes `compute.events.vm.terminated` `{reason: deleted_on_request, request?}` + `market.event` at `EventRKeys(TerminationKey(receipt))`
8. requester: after a 2xx it reads the bidder's `vm.terminated` (`awaitTermination`, `FindTermination`) for up to `DefaultReleaseTerminationWait` (2 min), then `Released` either way
9. requester deletes the records it wrote for this contract (`deleteContractRecords` in `internal/market/requester/association.go`): the `com.fedproxy.rbac` grant, the contract association and its endorsement (then, for a guest requester, the tombstone fallback: [identity.md](identity.md#guest-requester-r2)), its `vm.delete` and release `market.event`, the accept (only once a receipt exists), the RFP, the `compute.vm`, the policy record, and every outbound ContractEvent's payload and envelope (`requester_contract_records_deleted`)
```mermaid
sequenceDiagram
@@ -251,13 +281,22 @@ sequenceDiagram
B->>G: stop, delete ComputeVM
B->>BP: vm.terminated deleted_on_request + market.event at TerminationKey rkeys
B->>R: submitEvent vm.terminated
R->>BP: getRecord vm.terminated (FindTermination) if submitEvent failed
R->>RP: delete own com.fedproxy.rbac + contract association
R->>BP: getRecord vm.terminated (FindTermination), up to 2 min
R->>RP: delete own contract records: rbac, association, vm.delete + event, accept, rfp, compute.vm, policy, ContractEvents
R->>R: ComputeContract Released
```
- a guest that stops for any other reason gets `vm.terminated` with `request` unset and a reason from `market.VMTerminatedReasons` (`guest_poweroff`, `vmm_exited`, `oom`, `host_reboot`, `identity_mismatch`), or the bidder's own end of it:
- a guest that stops for any other reason gets `vm.terminated` with `request` unset and a reason from `market.VMTerminatedReasons` (`internal/atproto/market/nsid.go`): a lost VM's `guest_poweroff`, `vmm_exited`, `oom`, `host_reboot`, `identity_mismatch`, `image_refused` (`computevm.GoneReason`), or the bidder's own end of it:
`expired` (the association's expiresAt passed), `association_ended` (the contract that scoped the requester's association is over: its `vm.terminated` or `vm.delete` is present)
- `deleted_on_request` is also written for a direct ComputeVM delete on the bidder (no `request`)
A real `vm.terminated` (bidder `did:plc:2l2wdry77c7jtucbslstagkj`, the release of the contract in [flow.md](flow.md), read 2026-11-19):
```json
{"uri": "at://did:plc:2l2wdry77c7jtucbslstagkj/com.publicdomainrelay.temp.compute.events.vm.terminated/termination-payload-2da9e2aef573b37793d5c43f443186a1",
"value": {"$type": "com.publicdomainrelay.temp.compute.events.vm.terminated", "reason": "deleted_on_request",
"observedAt": "2026-11-15T06:18:58Z", "createdAt": "2026-11-15T06:18:58Z", "signatures": ["..."]}}
```
- a VM the bidder ends at its `spec.associationExpiresAt` (+ grace) gets `vm.terminated` `{reason: expired}`, `request` unset (`computevm.ReleaseReason`: a release without a `vm.delete`, requested at or after that time)
- a release whose destroy record or submitEvent keeps failing settles `Released` once the bidder's `vm.terminated` for that receipt appears
- a bidder also releases a VM whose contract-scoped association expired 10 min ago (ComputeVM `spec.associationExpiresAt`, [identity.md](identity.md#contract-scoped-association))
@@ -272,7 +311,7 @@ sequenceDiagram
## Records Policy
- user records are never deleted. no sweep, retention or GC of repo records
- the requester deletes only the contract-scoped records it wrote for that contract (rbac grant, association), never a record of another contract
- the requester deletes only the records it wrote for that contract (release step 9), never a record of another contract; the bidder keeps its bids, receipts and events (it deletes only an outbox event it retracts and its webrtc answers)
- one `getRecord` at a deterministic rkey; `listRecords` only as a legacy fallback
## See Also
docs/protocol/outside.md+1−1
@@ -146,7 +146,7 @@ sequenceDiagram
| `internal/market/requester/discovery.go` | trust lists (vouches) |
| `internal/ssh/ownersession/ownersession.go`, `internal/gateway/custody/signin.go`, `internal/atproto/market/http.go` | legacy and custody paths |
- deleteRecord: only on records the app wrote itself for a contract: the requester's `market.association` and `com.fedproxy.rbac` grants (`internal/market/requester/association.go`, `secrets.go`), a bidder outbox event it retracts (`internal/market/bidder/adapters.go`), an AtprotoRecord object whose policy is not Retain (`internal/controllers/atprotorecord/apply.go`). never on Infra records, never on someone else's records
- deleteRecord: only on records the app wrote itself for a contract: the requester's records of a released contract ([market.md](market.md#release-and-termination) step 9: `deleteContractRecords` in `internal/market/requester/association.go`), an RFP between capacity rounds (`runner.go`), a bidder outbox event it retracts (`internal/market/bidder/adapters.go`), an AtprotoRecord object whose policy is not Retain (`internal/controllers/atprotorecord/apply.go`). never on Infra records, never on someone else's records
| server | serves |
|---|---|
docs/protocol/policy.md+51−28
@@ -1,16 +1,16 @@
# policy: policy records, attached policies, tangled-vouch
- a market policy ALWAYS runs, both sides, both lanes (scope + full), every decision. no skip paths
- a market policy ALWAYS runs, both sides, both lanes (scope + full), every decision. no skip paths (the ssh gateway sign-in runs the scope lane only, by design: `internal/services/sshserver/signin.go`)
- the requester publishes the workflow it runs as a record; the RFP strongRefs it; the bidder runs it next to its own
- caching lives inside the engine run, never across parties, never a skip
- caching lives inside the engine run, never across parties; the scope lane's memo serves a stored outcome for the same key (every party is in the key: allow 5 min, deny 30 s, `internal/policyengine/manager.go`)
- index: [README.md](README.md). sequence steps: [S1](README.md#step-s1) (vouches), [S3](README.md#step-s3) (record + RFP), [S4](README.md#step-s4) (bidder runs), [S5](README.md#step-s5) (requester runs)
## Records And Fields
| NSID / field | type | rkey | written by | read by | Go | step |
|---|---|---|---|---|---|---|
| `computer.socialweb.temp.policy.ghalite` | record (no lexicon file) | TID (createRecord without rkey); one per contract, kept in `state.Policy` | requester | bidder (via the RFP strongRef), requester (re-check) | `internal/market/requester/policy.go` `BuildPolicyRecord`, `internal/market/requester/runner.go`, `internal/market/participant/policyrecord.go` | S3 |
| `market.rfp` `policies[]` | array of `com.atproto.repo.strongRef` | - | requester | bidder | `internal/atproto/market/records.go` `BuildRFP`, `CreateRFP` | S3 |
| `computer.socialweb.temp.policy.ghalite` | record (no lexicon file) | TID (putRecord at a TID the requester makes); one per contract, kept in `state.Policy` | requester | bidder (via the RFP strongRef), requester (re-check) | `internal/market/requester/policy.go` `BuildPolicyRecord`, `internal/market/requester/runner.go`, `internal/market/participant/policyrecord.go` | S3 |
| `market.rfp` `policies[]` | array of `com.atproto.repo.strongRef` | - | requester | bidder | `internal/atproto/market/records.go` `BuildRFP`; `internal/market/requester/runner.go` `putRFP` | S3 |
| `computer.socialweb.infra#contract` `policy`, `policyArgs` | strings | - | owner | requester (via the ComputeContract) | `internal/market/requester/runner.go` | S2 |
| `sh.tangled.graph.vouch` | record (outside) | subject DID | operators, users | both policies (trust snapshot) | `internal/policyengine/trust/trust.go` | S1 |
| `computer.socialweb.temp.policy.typescript` | record (no lexicon file) | - | nobody | denied | `internal/policyengine/registry/registry.go` | - |
@@ -39,9 +39,10 @@
## Infra Contract Fields
- `policy`: the workflow name. resolution: `cmp.Or(contract.Spec.Policy, cfg.PolicyWorkflow, DefaultPolicyWorkflow)`
- `PolicyWorkflowName` normalizes: `""` -> `requester-tangled-vouch`; `only-me` -> `requester-only-me`; `mutuals` -> `requester-mutuals`; `tangled-vouch` -> `requester-tangled-vouch`
- the name must be a bundled workflow, else the contract fails before the RFP
- `policyArgs`: a JSON object, parsed to `map[string]string` (`internal/market/participant/policy.go` `ParsePolicyArgs`)
- `PolicyWorkflowName` (`internal/market/requester/policy.go`) trims and lowercases, then: `""` -> `requester-tangled-vouch`; `only-me`, `only_me` -> `requester-only-me`; `mutuals` -> `requester-mutuals`; `tangled-vouch`, `tangled_vouch` -> `requester-tangled-vouch`; any other name passes through
- the bidder does not normalize: `spec.policy` or `bidder-tangled-vouch` (`internal/market/bidder/policy.go`)
- the name must be a bundled workflow, else the contract fails before the RFP (the `compute.vm` record is already written then: `runner.go`)
- `policyArgs`: a JSON object, parsed to `map[string]string` (`internal/market/participant/policy.go` `ParsePolicyArgs`) and stored in the record's `args`. No run receives them today: see "Not wired" below
## RFP Policy StrongRefs
@@ -65,8 +66,8 @@ sequenceDiagram
B->>B: S4 bid or no bid
```
- requester write path: `runner.go` step `creatingRfp`: `BuildPolicyRecord` -> `CreateRecord` -> `attachedPolicy` -> `rfpOptions.Policies` -> `market.CreateRFP`
- requester re-check `attachedPolicy` (`internal/market/requester/policy.go`): the record is in the requester's own repo, the cid matches, the name matches the contract, the body equals the bundled workflow byte for byte. `rfpPolicyRef` requires exactly one policy
- requester write path: `runner.go` step `creatingRfp`: `BuildPolicyRecord` -> putRecord at a TID -> `attachedPolicy` -> `rfpOptions.Policies` -> `putRFP`
- requester re-check `attachedPolicy` (`internal/market/requester/policy.go`): the record is in the requester's own repo, the cid matches, the name matches the contract, the body equals the bundled workflow byte for byte
- bidder: `EvaluatePolicies` (`internal/market/bidder/policy.go`) runs its own workflow (default `bidder-tangled-vouch`), then each RFP ref via `RepoStore.Resolve` (local getRecord or a foreign resolver), `PolicyRecordWorkflow`, `runs.Request{Workflow, Source: uri}`. first deny wins
- the bidder runs the attached workflow with `perspective=bidder` (`internal/market/bidder/bids.go`)
- a restarted runner reuses `state.Policy`; it does not write a second record
@@ -75,11 +76,18 @@ sequenceDiagram
| lane | input | where |
|---|---|---|
| scope | DIDs only, RFP nil, `mode: scope` | bidder `bids.go`, `internal/policyengine/executor/ghalite.go` `Scope` |
| full | self, subject, counterparty, root requester DIDs, rfp, bid, accept, args, `mode: full` | bidder `bids.go` `fullInput`, `adapters.go`; `ghalite.go` `Execute` |
- executor: `GhaLite` (`internal/policyengine/executor/ghalite.go`), default timeout 30 s
- run path: `runs.Client.Run` creates a PolicyWorkflowRun and waits (`internal/policyengine/runs/client.go`)
| scope | DIDs, `mode: scope`; the bidder passes no RFP, the requester passes the RFP ref | bidder `bids.go` (bid), `adapters.go` (accept); requester `accept.go` `bidAllowedWithPolicy` (each bid); ssh gateway `signin.go` |
| full | self, subject, counterparty, root requester DIDs, the RFP ref (bidder; the requester also the bid ref), `mode: full` | bidder `bids.go` `fullInput`, `adapters.go`; requester `runner.go` (the winner, a resume), `session.go` |
| side | decision | self | counterparty |
|---|---|---|---|
| bidder | bid on an RFP: scope, then own workflow + every attached policy (full) | the bidder DID | the requester DID |
| bidder | take an accept: scope and full again | the bidder DID | the requester DID |
| requester | each bid: scope | `spec.operatorDID`, else the market DID | the bidder DID |
| requester | the winner, before the accept: full, with the attached record's body | the market DID | the bidder DID |
| ssh gateway | sign-in admission: `bidder-tangled-vouch`, scope | `spec.ssh.operatorDid` (none: nobody is admitted) | the signing-in DID |
- run path: `runs.Client.Run` creates a PolicyWorkflowRun and waits (`internal/policyengine/runs/client.go`, timeout `DefaultTimeout` 2 min unless set); `RunReconciler` (`internal/policyengine/controller/run.go`) seeds the trust snapshot and executes
- missing engine, evaluator or a non-boolean `allow` = deny
### Caching (inside the run)
@@ -88,9 +96,9 @@ sequenceDiagram
|---|---|---|
| trust snapshot seed | `trust/<counterpartyDid>` | per run |
| record | `rec/<uri>/<cid>` (`internal/policyengine/cache/cache.go`) | - |
| verdict | `policy/<name>/<rfp>\|<bid>\|<accept>[:argsHash]` | 30 s default |
| scope verdict memo | `internal/policyengine/controller/scopememo.go` | 30 s, plus a negative TTL |
| vouch, operator lookups | `trust.Resolver` ttlcache | 5 min, errors 5 s |
| verdict | `policy/<workflow>/<mode>\|<perspective>\|<self>\|<subject>\|<counterparty>\|<root>\|<source>\|<rfp>\|<bid>\|<accept>:<args sha8>` (`runs/client.go`) | 30 s default (`cacheTtlSec`) |
| scope verdict memo | `internal/policyengine/controller/scopememo.go` | allow 5 min, deny 30 s (`manager.go`) |
| identlink walk | `trust.Resolver` | 5 min (capped at the earliest `expiresAt`), 5 s with errors; a failed vouch lookup is not cached |
## Bundled Workflows
@@ -99,16 +107,22 @@ sequenceDiagram
| workflow | kind | decides |
|---|---|---|
| `bidder-tangled-vouch` | trust (bidder default) | the requester or its operator is vouched by the bidder or its operator |
| `requester-tangled-vouch` | trust (requester default) | the same, for the bidder, from the requester side |
| `bidder-mutuals`, `requester-mutuals` | trust | operators follow each other on Bluesky |
| `bidder-only-me`, `requester-only-me` | trust | the counterparty resolves to the own operator |
| `bidder-tangled-vouch` | trust (bidder default) | allow when the counterparty is self, shares a root with self, has self as its root, or when any DID of self + its walk ancestors vouches any DID of the counterparty + its walk ancestors |
| `requester-tangled-vouch` | trust (requester default) | the same function, from the requester side |
| `bidder-mutuals`, `requester-mutuals` | trust | self, the same operator, or vouches both ways: the self side vouches the counterparty (or its operator) and the counterparty side vouches self (or its operator). tangled vouches only; the action's description string still says "follows on Bluesky", which it does not read |
| `bidder-only-me`, `requester-only-me` | trust | the counterparty is self or resolves to self or the operator of self |
| `open` | trust | no restriction. only when named, never prod |
| `bid-payload` | work (requester) | the bid payload NSID is in `allowedPayloadNsids` (default `market.bids.free`) |
| `under-4-cpus` | work | the VM asks at most `maxCpus` vCPUs |
| `under-4-cpus` | work (bidder) | the VM asks at most `maxCpus` vCPUs (default 4) |
- the action infers its perspective from the `bidder-` prefix unless the `perspective` input says otherwise
- defaults: `api/v1alpha1/types_computevm.go` `BidderDefaultPolicy`, `RequesterDefaultPolicy`
- the policy logic is the bundled `tangy/policy-<name>/dist/index.js`; its `index.ts` imports a source that is not in this repo
### Not wired
- a contract's `policyArgs` reach no run: the requester's runs client has no args, and the bidder runs every attached workflow with its own `policyArgs` (`internal/services/bidder/wiring.go`)
- the work policies read numbers and arrays (`maxCpus`, `allowedPayloadNsids`, `cacheTtlSec`), and args are `map[string]string`: their defaults always apply
## Tangled-Vouch
@@ -118,19 +132,28 @@ sequenceDiagram
```mermaid
flowchart LR
SELF["self"] --> T["trusted = self + operator(self)"]
CP["counterparty"] --> OPC["operator(counterparty) via identity.md"]
T --> Q{"one getRecord per pair: trusted vouches counterparty or operator(counterparty)?"}
SELF["self"] --> T["self side = self + its walk ancestors"]
CP["counterparty"] --> OPC["counterparty side = counterparty + its walk ancestors (identity.md)"]
T --> Q{"one getRecord per pair, both directions: a self-side DID vouches a counterparty-side DID?"}
OPC --> Q
Q -->|yes| ALLOW["allow"]
Q -->|operator(counterparty) is trusted| ALLOW
OPC -->|"operator(counterparty) is self or operator(self)"| ALLOW
Q -->|no| DENY["deny"]
```
- snapshot: `trust.BuildSnapshotWith` (`internal/policyengine/trust/trust.go`): vouches between self + its walk ancestors and the counterparty + its walk ancestors (≤256 pairs, nearest first)
- snapshot: `trust.BuildSnapshot` (`internal/policyengine/trust/trust.go`): vouches between self + its walk ancestors and the counterparty + its walk ancestors (at most 256 pairs, nearest first); the vouches of every self-side DID count as self's
- operator resolution (identlink walk): [identity.md](identity.md#walk)
- who writes vouches: market networks declare operator vouches both ways (`internal/app/marketnetwork/vouches.go`, compose `ApplyOperatorVouch`); people write them from any client. the requester OAuth scope offers vouch write as an optional scope
- requester discovery lists the vouches of its trusted DIDs (`internal/market/requester/discovery.go` `vouchedBy`, a listRecords that skips `denounce` and takes rkeys starting `did:`)
- requester discovery lists the vouches of its operators (self, `spec.operatorDID`, its walk roots; not intermediate ancestors) to add candidates (`internal/market/requester/discovery.go` `vouchedBy`, a listRecords that skips `denounce` and takes rkeys starting `did:`); the policy, not discovery, decides who is served
Real records (read 2026-11-19): the prod requester `aliceoa.bsky.social` and the bidder operator `bobvmbuilder.bsky.social` vouch each other, so `requester-tangled-vouch` and `bidder-tangled-vouch` both allow (bob's bidders are his agents: their walk reaches him).
```json
{"uri": "at://aliceoa.bsky.social/sh.tangled.graph.vouch/did:plc:ocnuqjlzgohypj3zoznermms",
"value": {"$type": "sh.tangled.graph.vouch", "kind": "vouch", "createdAt": "2026-08-05T01:26:28+03:00"}}
{"uri": "at://bobvmbuilder.bsky.social/sh.tangled.graph.vouch/did:plc:lpfuqerea3deuoyrn7ojser4",
"value": {"$type": "sh.tangled.graph.vouch", "kind": "vouch", "createdAt": "2026-08-05T01:26:51+03:00"}}
```
## See Also
docs/protocol/README.md+28−17
docs/protocol/release.mdnew+72−0
docs/deploy.md+3−3
docs/how-it-works.mdnew+62−0
docs/README.md+3−1
docs/SYSTEM.md+26−20
site/build.ts+1−0
.plans.yaml+3−3
README.md+1−0