# lexicons-market: one row per lexicon - the fields of every lexicon come from the lexicon files: each section below includes its generated field table (the `lexicon:` link; on https://socialweb.computer/docs/protocol/lexicons-market.html the table is rendered in place) and adds what the code does with it: the rkey it writes, who writes and reads it, and the step - every lexicon, generated: https://socialweb.computer/docs/lexicons/ (XRPC methods: https://socialweb.computer/docs/xrpc/) - covers every lexicon under `lexicons/com/publicdomainrelay/temp/` except `cluster.*` ([infra.md](infra.md#compublicdomainrelaytempcluster)) and `badgeBlueKeys` ([identity.md](identity.md#badgebluekeys)), with `compute.secrets.getSecrets` and `compute.config.wif.simple` at the end - the flows: [market.md](market.md) (rfp to release), [guest-events.md](guest-events.md) (events under a receipt); steps S3 to S9: [README.md](README.md#end-to-end-sequence) - headings drop the prefix `com.publicdomainrelay.temp.`; file paths are under `lexicons/com/publicdomainrelay/temp/` - the Go types are generated from these files into `internal/atproto/market/zz_generated.lexicons.go` (`go generate` in `internal/atproto/market/nsid.go`) - "defined, not written": the lexicon and its NSID constant exist, but no Go code in this repo writes the record ## Rows | row | meaning | |---|---| | rkey | what the code writes, not only the lexicon `key` | | written by / read by | role and the Go function | | code notes | what the code does with a field, where it differs from what the lexicon allows | | step | the README step it belongs to | ## Summary | NSID tail | rkey written | written by | step | |---|---|---|---| | `market.rfp` | TID | requester | S3 | | `market.bid` | `market.BidRKey` | bidder | S4 | | `market.bids.free` | `-payload` | bidder | S4 | | `market.bids.x402` | none | defined, not written | S4 | | `market.accept` | `SessionRKey("accept", ...)` | requester | S5 | | `market.accepts.free`, `market.accepts.x402` | none | defined, not written | S5 | | `market.receipt` | `market.ReceiptRKey` | bidder | S6 | | `market.receipts.free`, `market.receipts.x402` | none | defined, not written | S6 | | `market.event` | per kind | both | S7-S9 | | `market.offering` | `self` | bidder | S3 (discovery) | | `market.heartbeat` | `self` (literal) | bidder | S3 (discovery) | | `market.relays` | `self` | no Go writer here | S3 (discovery) | | `market.association` | the agent DID | principal | S5, S8 | | `market.associationRequest` | the principal DID | guest requester | S8 | | `computer.socialweb.peer` | the subhandle | guest requester (its own and each co-located account's); requester (each spec.agent contract's atirc agent) | S8 | | `market.submitRfp` | - | served by bidder | S3 | | `market.submitBid` | - | served by requester | S4 | | `market.submitAccept` | - | served by bidder | S5 | | `market.submitEvent` | - | served by both | S7-S9 | | `compute.vm` | TID | requester | S3 | | `compute.events.vm.*` | per kind | bidder (vm.delete: requester) | S7, S9 | | `compute.events.guest.*` | per kind | requester or bidder for the guest | S8 | | `compute.guest.subscribeEvents` | - | served by bidder GuestControlPlane | S8 | | `ingress.webRTC` | `webrtc` (listen), TID (offer, answer) | requester, bidder | S3-S6 | | `compute.secrets.getSecrets` | - | served by requester | S8 | | `compute.config.wif.simple` | `-config` | bidder | S4 | ## market.rfp [lexicon: com.publicdomainrelay.temp.market.rfp](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.rfp.html) | item | value | |---|---| | 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) | ## market.bid [lexicon: com.publicdomainrelay.temp.market.bid](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.bid.html) | item | value | |---|---| | rkey | `market.BidRKey(bidderDID, rfpURI, rfpCID)` = `bid-<20 hex>`; also the Bid object name | | written by | bidder: `writeBidRecord` in `internal/market/bidder/bids.go` (`market.BuildBid`, `market.SignRecord`) | | read by | requester: `submitBid` (`Requester.SubmitBid` in `internal/market/requester/callbacks.go`), stream, catch-up `getRecord` at `BidRKey` (`internal/market/requester/bidcatchup.go`); bidder at accept time | | step | [S4](README.md#step-s4) | ## market.bids.free [lexicon: com.publicdomainrelay.temp.market.bids.free](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.bids.free.html) | item | value | |---|---| | rkey | `-payload` | | written by | bidder: `writeBidRecord` | | read by | requester: free detection for `firstFree` (`internal/market/requester/accept.go`, `internal/market/requester/inbox.go`) | | step | [S4](README.md#step-s4) | ## market.bids.x402 [lexicon: com.publicdomainrelay.temp.market.bids.x402](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.bids.x402.html) | item | value | |---|---| | rkey | none: defined, not written | | written by | no Go writer | | read by | requester reads `cost` when a bid names one (`internal/market/requester/accept.go`, `internal/market/requester/inbox.go`) | | step | [S4](README.md#step-s4) | ## market.accept [lexicon: com.publicdomainrelay.temp.market.accept](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.accept.html) | item | value | |---|---| | code notes | `payload` is never set by the code | | rkey | `acceptRKeyFor` -> `market.SessionRKey("accept", repoDID, contract, rfpURI, rfpCID, bidURI, bidCID)` (`internal/market/requester/secrets.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) | ## market.accepts.free [lexicon: com.publicdomainrelay.temp.market.accepts.free](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.accepts.free.html) | item | value | |---|---| | rkey | none: defined, not written | | written by | no Go writer (`AcceptsFreeNSID` constant only) | | read by | none | | step | [S5](README.md#step-s5) | ## market.accepts.x402 [lexicon: com.publicdomainrelay.temp.market.accepts.x402](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.accepts.x402.html) | item | value | |---|---| | rkey | none: defined, not written | | written by | no Go writer (`AcceptsX402NSID` constant only) | | read by | none | | step | [S5](README.md#step-s5) | ## market.receipt [lexicon: com.publicdomainrelay.temp.market.receipt](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.receipt.html) | item | value | |---|---| | code notes | `submitEvent` is copied from the accept when the bidder serves inbound XRPC; `payload` is the RFP's `compute.vm` (`null` when none) | | rkey | `market.ReceiptRKey(acceptURI, acceptCID)` = `receipt-<32 hex>` | | written by | bidder: `createReceipt` in `internal/market/bidder/submit.go` -> `market.CreateReceiptRecordAt` (`internal/atproto/market/attest.go`) | | read by | requester: `FindReceipt` (one `getRecord`, `internal/market/requester/market.go`), `market.VerifyReceipt` in `acceptReceipt`; policy trust (`internal/policyengine/trust/association.go`) | | step | [S6](README.md#step-s6) | ## market.receipts.free [lexicon: com.publicdomainrelay.temp.market.receipts.free](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.receipts.free.html) | item | value | |---|---| | rkey | none: defined, not written | | written by | no Go writer (`ReceiptsFreeNSID` constant; named in OAuth scopes, `internal/atproto/oauth/scope.go`) | | read by | none | | step | [S6](README.md#step-s6) | ## market.receipts.x402 [lexicon: com.publicdomainrelay.temp.market.receipts.x402](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.receipts.x402.html) | item | value | |---|---| | rkey | none: defined, not written | | written by | no Go writer (`ReceiptsX402NSID` constant; named in OAuth scopes) | | read by | none | | step | [S6](README.md#step-s6) | ## market.event [lexicon: com.publicdomainrelay.temp.market.event](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.event.html) | item | value | |---|---| | rkey | bidder: `market.EventRKeys(key)` second value `-event-<32 hex>`; requester: `SessionRKey("event", receiptURI)` for vm.delete, `SessionRKey("contract-event-envelope", uid)` for ContractEvents | | written by | bidder event adapter (`writeMarketEvent` in `internal/market/bidder/adapters.go`); requester `destroyEnvelope` (`runner.go`), `publishContractEvent` (`internal/market/requester/contractevents.go`); both via `market.PutEvent` | | read by | the other party: `submitEvent` or stream; requester `FindTermination` | | step | [S7](README.md#step-s7), [S8](README.md#step-s8), [S9](README.md#step-s9) | ## market.offering [lexicon: com.publicdomainrelay.temp.market.offering](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.offering.html) | item | value | |---|---| | rkey | `self` (`market.OfferingRKey`) | | written by | bidder: `putOffering`, `withdraw` in `internal/market/bidder/offering.go` | | read by | requester: `market.ReadOffering` (`self`, else the rkey the heartbeat names), `market.OfferingApplies`; relays list its repos by `listReposByCollection` | | step | [S3](README.md#step-s3) (discovery) | ## market.heartbeat [lexicon: com.publicdomainrelay.temp.market.heartbeat](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.heartbeat.html) | item | value | |---|---| | rkey | `self` | | written by | bidder: `beat` in `internal/market/bidder/offering.go`, every `HeartbeatInterval` (60 s) | | read by | requester: `market.HeartbeatCache.FreshDIDs` (fresh = at most `HeartbeatTTL` 300 s old); `internal/marketpresence` | | step | [S3](README.md#step-s3) (discovery) | ## market.relays [lexicon: com.publicdomainrelay.temp.market.relays](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.relays.html) | item | value | |---|---| | rkey | `self` (`market.RelaysRKey`) | | written by | no Go writer in this repo | | read by | requester discovery: `market.RelayURLsOf` from `relaySources` in `internal/market/requester/discovery.go` | | step | [S3](README.md#step-s3) (discovery) | ## market.association [lexicon: com.publicdomainrelay.temp.market.association](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.association.html) | item | value | |---|---| | rkey | the agent DID | | meaning | the grant beside the `link.ident.endorsement` at the same rkey: [identity.md](identity.md#associations-identlink) | | written by | the operator (standing, no `contract`: `compose.ApplyOperatorPair`, `scripts/associate-bidder.ts`); the requester 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 ` prints the walk | | step | [S5](README.md#step-s5), [S8](README.md#step-s8); release deletes only its own | ## market.associationRequest [lexicon: com.publicdomainrelay.temp.market.associationRequest](https://socialweb.computer/docs/lexicons/com.publicdomainrelay.temp.market.associationRequest.html) | item | value | |---|---| | 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) | ## computer.socialweb.peer [lexicon: computer.socialweb.peer](https://socialweb.computer/docs/lexicons/computer.socialweb.peer.html) | item | value | |---|---| | code notes | only `createdAt` and `iroh` are written; no writer sets `webrtc` or `channels` | | rkey | the subhandle: the guest requester's atirc subhandle (`r2-.`, its handle without one); `.` for a co-located account; `