Skip to content

Commit 599749e

Browse files
trilltinoclaude
andcommitted
Finish the README audit: buyer, runtime, packages, marketplace
Second pass over the per-package READMEs the top-level sync missed: - buyer-agent: flow diagram gains the policy gates + VERIFY/VERIFIED leg; files table adds wantFeed.ts/reputation.ts; env section documents VERIFIER_AGENT, WANT_FEED_URL, REPUTATION_URL, and the POLICY_* knobs - agent-runtime: module table now lists all six modules (ledger/, policy/) and the VERIFY/VERIFIED protocol exports - packages index: adds harness-runtime - marketplace: run-ledger paragraph + sibling-market pointers, fixes the stale `bash build-agents.sh seller buyer` invocation (script takes one arg) and replaces dead `just feed`/`just dashboard` commands (no justfile exists) with the real ones Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent b31e5be commit 599749e

4 files changed

Lines changed: 47 additions & 11 deletions

File tree

coral-agents/buyer-agent/README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
# buyer-agent
22

3-
The marketplace buyer broadcasts a `WANT`, collects competing seller bids, awards the best value, and
4-
settles the winner through the arbiter-gated escrow by default.
3+
The marketplace buyer broadcasts a `WANT` (or, in event mode, polls a feed for one), collects competing
4+
seller bids, awards the best value — weighing each seller's ledger-derived track record when
5+
`REPUTATION_URL` is set — and settles the winner through the arbiter-gated escrow by default.
6+
**Every deposit and release passes the policy choke point** (`enforce()` from `@pay/agent-runtime`):
7+
spend caps, service allowlist, payout binding, award-price binding (a seller can't inflate the escrow
8+
after winning), rate limit, verifier gate.
59

610
```text
711
WANT -> BID* -> AWARD
812
-> ESCROW_REQUIRED settlement=arbiter reference=<bound order>
13+
-> [policy: caps, payout + award-price binding]
914
-> ARBITER_OPENED / DEPOSITED vault=<vault PDA>
10-
-> DELIVERED
11-
-> ARBITER_RELEASED
15+
-> DELIVERED (hash-bound payload)
16+
-> VERIFY -> VERIFIED pass|fail (when VERIFIER_AGENT is set)
17+
-> [policy: verifier gate]
18+
-> ARBITER_RELEASED (fail/timeout -> funds stay refundable)
1219
```
1320

1421
> **CoralOS docs:** these messages ride Coral threads with `@mentions`
@@ -23,17 +30,30 @@ WANT -> BID* -> AWARD
2330

2431
| File | Role |
2532
|---|---|
26-
| `src/index.ts` | Market loop: WANT, bid collection, award, arbiter open, delivery wait, release |
33+
| `src/index.ts` | Market loop: WANT, bid collection, award, policy-gated deposit, delivery wait, verify, policy-gated release |
2734
| `src/arbiter.ts` | Arbiter wrapper client: config, vault PDA, open, release |
2835
| `src/escrow.ts` | Legacy direct base escrow client |
29-
| `src/guard.ts` | Seller payout binding and legacy payment guards |
36+
| `src/wantFeed.ts` | Event mode: `fetchNextWant()` — poll the research watcher for the next job |
37+
| `src/reputation.ts` | `fetchReputationLines()` — the feed's `/api/reputation` folded into the award prompt |
38+
| `src/guard.ts` | Legacy payout guard (subsumed by the policy choke point's `payout-binding` rule) |
3039

3140
## Env
3241

3342
`BUYER_KEYPAIR_B58` funds the order. `ARBITER_KEYPAIR_B58` signs arbiter release/refund.
3443
`SELLER_WALLET` binds the payout wallet. `BUYER_SERVICE` defaults to `txline`, `BUYER_ARG` defaults to
3544
an `edge <fixtureId>` style request, and `MARKET_SELLERS` controls the competing sellers.
3645

46+
New layers (all optional — unset means the classic loop):
47+
48+
- `VERIFIER_AGENT` + `VERIFY_WINDOW_MS` — hand each delivery to this agent and release **only** on a
49+
`VERIFIED pass` ([verifier-agent](../verifier-agent/README.md)); no verdict → funds stay refundable.
50+
- `WANT_FEED_URL` — event mode: poll this URL for the next job instead of rotating `BUYER_ARGS`
51+
(the research market's watcher); empty queue → no WANT, no spend.
52+
- `REPUTATION_URL` — the feed's `/api/reputation`; sellers' run-ledger track records enter the
53+
best-value prompt.
54+
- `POLICY_MAX_SOL_PER_ROUND`, `POLICY_MAX_SOL_PER_SESSION`, `POLICY_SERVICES`,
55+
`POLICY_MIN_INTERVAL_MS` — the choke point's knobs (round cap defaults to the budget).
56+
3757
For best-value bid selection set an LLM key — the kit's LLM is **Venice AI** (`LLM_PROVIDER=venice` +
3858
`VENICE_API_KEY`; new accounts get $50 free via code `IMPERIAL50` at
3959
[venice.ai/settings/api](https://venice.ai/settings/api)). `ANTHROPIC_API_KEY`, or `LLM_PROVIDER=openai`

examples/marketplace/README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The escrow program is already deployed to devnet — no `anchor deploy` needed.
2828

2929
```sh
3030
(cd examples/txodds && npm run mint) # one-time: free devnet TxLINE token → .env
31-
bash build-agents.sh seller buyer # build the two agent images (sellers reuse the seller image)
31+
bash build-agents.sh # build the agent images (sellers reuse the seller image)
3232
docker compose up -d coral # CoralOS (MCP coordinator)
3333
cd examples/marketplace && npm install && npm start
3434
```
@@ -68,12 +68,20 @@ Watch the auction in a browser instead of the logs — a read-only visualizer (n
6868
each round's bids, the winner + reasoning, and the escrow settlement with Explorer links:
6969

7070
```sh
71-
just feed # the feed server on :4000 (in another shell)
72-
just dashboard # the UI on :5173 → open ?session=<the market session id>
71+
cd feed && SESSION=<the market session id> npm start # the feed server on :4000 (another shell)
72+
npm run marketplace:web # from the repo root — the UI on :5173
7373
```
7474

7575
It's e2e-tested with fixtures (no devnet needed) — see [`web/`](web/README.md).
7676

77+
The feed also writes every round to the **run ledger** (`runs/<session>/round-<n>/` — want, bids,
78+
award reasoning, escrow + deposit tx, sha256-bound delivery, verifier verdict, Explorer-linked txs,
79+
raw transcript), serves `/api/runs` + `/api/reputation`, and **replays a session from disk when
80+
coral-server is down**. Details: [`feed/`](feed/README.md).
81+
82+
Sibling markets on the same rails: [`../freelancer`](../freelancer/README.md) (harness sellers +
83+
verifier-gated release) and [`../research`](../research/README.md) (odds events trigger the WANTs).
84+
7785
## Demo flourishes
7886

7987
- **Drop in a competitor live:** add a fourth seller to `start.ts`'s graph — it bids next round with

packages/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# packages
22

3-
- **[agent-runtime/](agent-runtime/README.md)** — the runtime the agent imports: the LLM provider shim, Solana Pay + devnet guard, a CoralOS MCP client, and the market protocol.
3+
- **[agent-runtime/](agent-runtime/README.md)** — the runtime the agent imports: the LLM provider
4+
shim, Solana Pay + devnet guard, a CoralOS MCP client, the market protocol (incl. VERIFY/VERIFIED),
5+
the run ledger + reputation, and the policy choke point.
6+
- **[harness-runtime/](harness-runtime/README.md)** — the harness adapter SDK: one
7+
`HarnessAdapter` interface (`quote`/`run`) so a seller can be a prompt (`node-llm`), headless
8+
**Claude Code** (`claude-code`), or any CLI (`HARNESS=cli HARNESS_CMD='hermes {prompt}'`).
9+
Harness processes never hold keys. Build after agent-runtime.

packages/agent-runtime/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ Each is a folder under `src/` with its own barrel; the root `src/index.ts` re-ex
2020
| **LLM** | `complete()` — SDK-free provider shim (**Venice AI** is the kit's LLM; `LLM_PROVIDER` also accepts `openai`/`anthropic`) + `parseJsonReply` | `llm/` (`complete.ts`) |
2121
| **Solana** | `solanaConnection`/`assertDevnet` (devnet guard), `generatePaymentUrl`/`verifyPayment`/`signTransfer`/`loadKeypairB58` (reference-bound) | `solana/` (`connection.ts`, `pay.ts`) |
2222
| **CoralOS** | `startCoralAgent(config, run)`, `CoralMcpAgent`, and the `ctx` verbs (`waitForMention`, `waitForAgent`, `reply`, `send`, `createThread`) | `coral/` (`mcp.ts`, `server.ts`) |
23-
| **Market** | `formatWant`/`parseBid`/`parseAward`/… + `selectBids`/`pickCheapest` — the WANT/BID/AWARD wire protocol (pure) | `market/` (`protocol.ts`) |
23+
| **Market** | `formatWant`/`parseBid`/`parseAward`/`parseVerify`/`parseVerified`/… + `selectBids`/`pickCheapest` — the WANT/BID/AWARD (+ VERIFY/VERIFIED) wire protocol (pure) | `market/` (`protocol.ts`) |
24+
| **Ledger** | `writeRun`/`readRun`/`listRuns` — one folder per paid round (hash-bound delivery, verdict, Explorer-linked txs, transcript) + `reputation()` derived from it | `ledger/` (`run.ts`, `store.ts`, `reputation.ts`) |
25+
| **Policy** | `enforce(action, policy)` + `policyFromEnv` — the choke point every deposit/release passes: spend caps, service allowlist, payout + award-price binding, rate limit, verifier gate | `policy/` (`policy.ts`) |
2426

2527
The runtime is coordination + helpers — it never holds a keypair. Settlement is the escrow contract,
2628
called agent-side.

0 commit comments

Comments
 (0)