in reviewhumanPR #337Registry

Trajano: B2B procurement deal over MCP with lost-accept idempotency and over-mandate checks

[Trajano](https://github.com/augustoal/trajano) is an agent-native B2B procurement marketplace. Buyer and seller agents trade only through its MCP tools, using typed messages (rfq, offer, counter, accept, withdraw, order updates).

Author

Status
In review
Opened on
Nov 10
Branch
integration/trajano-procurement

Description

The pitch.

## Summary
[Trajano](https://github.com/augustoal/trajano) is an agent-native B2B procurement marketplace. Buyer and seller agents trade only through its MCP tools, using typed messages (`rfq`, `offer`, `counter`, `accept`, `withdraw`, order updates). The server enforces the rules: two negotiation rounds, price floors, offer hashes, stock, idempotency keys, and the buyer's signed spending mandate, which is checked at `accept`.

This PR adds a Lab integration in `examples/integrations/trajano/`:
- an adapter role that drives a live Trajano server over MCP;
- a Town-scripted buyer;
- three scenarios with their validators: a full purchase, a lost accept reply, and an over-mandate accept;
- recorded evidence bundles;
- a test that runs in CI without Trajano.

## Integration
- **Subject:** [augustoal/trajano](https://github.com/augustoal/trajano) at `26d78f6`, hosted separately. It runs as its own process with its own uv environment. The adapter starts it with `python -m scripts.town_world`. That script builds a fresh database with the clock frozen at the task's morning, seeds the catalog, provisions one buyer with a signed mandate, and starts the server and Trajano's five rule-based seller agents.
- **Interface tested:** MCP over streamable HTTP, through the official `mcp` SDK. The buyer tools are `search_listings`, `request_quote`, `counter_offer`, `accept_offer`, `withdraw`, `get_thread`, `get_inbox` and `get_order`. The sellers are Trajano's own MCP clients on its seller server.
- **Adapter (`trajano_market`):** the only role that talks to Trajano. Each Town message becomes one real tool call. It registers `procurement.fasteners` in Town's registry. The API key and signed mandate stay inside it: the buyer refers to the mandate by handle, and `redact_fields` covers both.
- **Buyer (`trajano_buyer`):** a Town script. It reaches Trajano only through Town messages, so Town faults apply to it. Its steps:
  1. Discovers the market in the registry.
  2. Asks two sellers for quotes and counters once.
  3. Accepts, then withdraws the other thread.
  4. Waits for delivery and pays the order total through Town's ledger.
- **Ground truth:** when the buyer finishes, the adapter stops the world, and Trajano writes an audit of the buyer's orders and threads from its database, scored against its solver's answer key. The validators compare what the buyer believes with that audit.
- **Why a Lab scenario:** `test-agent` profiles judge a single quote, and `nandatown mcp test` stops at the handshake, so neither can judge a negotiated purchase.

## Reproduce
Run from the root of this PR's checkout. Town base commit is `6f9a7c0` (current `main` when the evidence was recorded), evaluator `lab-0.2.6`, seed 42. Trajano is at `26d78f6c1f02c888e38ae48fe898e448f4aefcaa`. Use Python 3.12 and uv. No model key is needed.

```bash
git clone https://github.com/augustoal/trajano.git ../trajano
git -C ../trajano checkout 26d78f6c1f02c888e38ae48fe898e448f4aefcaa
(cd ../trajano && uv sync)
python3.12 -m venv .venv
.venv/bin/python -m pip install -e '.[dev]' -r examples/integrations/trajano/requirements.lock
.venv/bin/python examples/integrations/trajano/run.py --project ../trajano --case deal --out /tmp/trajano-town
.venv/bin/python examples/integrations/trajano/run.py --project ../trajano --case lost-accept --out /tmp/trajano-town
.venv/bin/python examples/integrations/trajano/run.py --project ../trajano --case over-mandate --out /tmp/trajano-town
.venv/bin/python examples/integrations/trajano/run.py --verify examples/integrations/trajano/evidence
.venv/bin/python -m pytest -q tests/test_example_trajano.py
```

`run.py` exits nonzero unless every stage passed, and with 2 if the project is missing. `--verify` is needed because `nandatown verify` does not load scenario plugins. Each case takes about 4 seconds.

## Results and limitations

| Run | Expected | Observed | Bundle fingerprint |
| --- | --- | --- | --- |
| Deal | Market found in the registry, two seller of

…

Try it

Open PR on GitHubView diff

Checkout locally

git fetch origin pull/337/head:pr-337
git checkout pr-337