in reviewhumanPR #325Identity

TrueMenu: add verified-quote seller adapter and stale-data compatibility check

[TrueMenu](https://github.com/IntelCodes/truemenu) is a service that ordering agents call before they quote a customer. It returns menu items, prices and open-now status that come from the restaurant, labels each restaurant's data as…

Author

Status
In review
Opened on
Nov 9
Branch
integration/truemenu-verified-quotes

Description

The pitch.

## Summary

[TrueMenu](https://github.com/IntelCodes/truemenu) is a service that ordering agents call before they quote a customer. It returns menu items, prices and open-now status that come from the restaurant, labels each restaurant's data as fresh, aging or stale, and signs a quote that anyone can check with `POST /v1/verify_quote`. If the data is stale, the restaurant is closed or the price is unverified, it refuses to sign.

This PR lets TrueMenu take part in a Track run without moving it into Town. No Town code is changed. It adds:

- `examples/truemenu/truemenu_seller.py`, the seller. It turns a `menu_request` (area, budget, dislikes, diet, meal time) into a TrueMenu `find_items` call and replies with up to five offers, each with TrueMenu's own signed `quote_id`, or with a decline and TrueMenu's reasons. It never sets a price itself.
- `examples/truemenu/lunch_buyer.py`, the buyer. It finds the seller through the town, asks for lunch, picks a main dish, and checks that quote directly with TrueMenu.
- `examples/truemenu/check.sh`, the compatibility check: 8 cases, each with an expected verdict.
- `examples/truemenu/README.md`, with setup steps and the case list.
- `tests/test_truemenu_example.py`, 11 unit tests for the adapters using canned TrueMenu answers.

## Integration

The buyer sends a `quote_request` through the Town coordinator. The seller claims it, calls TrueMenu's `find_items` with its own read-only key, and replies with a `quote_response`. The buyer then verifies the chosen quote with TrueMenu's public verify endpoint, which does not go through the seller or Town.

TrueMenu runs separately from its own repository (FastAPI and SQLite, with a simulated restaurant feed that syncs every 15 seconds, covering three Kendall Square restaurants). Town reaches it at `TRUEMENU_URL`. The key in `TRUEMENU_AGENT_KEY` is only sent to TrueMenu and is never written into a run bundle.

The interface tested is the Track mailbox exchange (claim, lease, acknowledgement, redelivery), with both roles supplied through `--agent role=cmd:...`. The `menu_request`, `offers` and `status` fields are this integration's own; `request_id` correlates the reply as Town expects, and `correct` is the buyer's own judgment, recorded on its acknowledgement.

One design point: TrueMenu signs a new quote on every call, so the seller saves its first reply and resends the same one if Town delivers the request again, as Town's reference seller does.

## Reproduce

Versions: TrueMenu `IntelCodes/truemenu@d35ad2d`. This branch is at `b747c92`, on top of `projnanda/nandatown@6f9a7c0` (`main`). Tested on Ubuntu with Python 3.12.3.

```bash
# TrueMenu, in its own repository
git clone https://github.com/IntelCodes/truemenu ~/truemenu
cd ~/truemenu && ./setup.sh && ./tests/smoke.sh
KEY=tm_$(python3 -c "import secrets; print(secrets.token_urlsafe(24))")
sed -i "s/^TRUEMENU_AGENT_KEYS=.*/&,nanda-town-seller:$KEY:read/" .env
echo "TRUEMENU_TOWN_KEY=$KEY" >> .env
scripts/start.sh

# Town, from this branch
python3 -m venv .venv && source .venv/bin/activate
python -m pip install -e '.[dev]'
python -m pytest -q tests/test_truemenu_example.py

export TRUEMENU_URL=http://127.0.0.1:8088
export TRUEMENU_AGENT_KEY=$(grep '^TRUEMENU_TOWN_KEY=' ~/truemenu/.env | cut -d= -f2)
TRUEMENU_HOME=~/truemenu examples/truemenu/check.sh runs/truemenu
```

A single case can be run with:

```bash
nandatown run quote-clean \
  --agent seller=cmd:"python examples/truemenu/truemenu_seller.py" \
  --agent buyer=cmd:"python examples/truemenu/lunch_buyer.py"
```

The check takes about three minutes, saves one evidence bundle per case and a `summary.tsv`, and exits 0 only if every case matches. `TRUEMENU_HOME` is only used to pause and resume the feeds for the stale case, so run one check at a time.

## Results and limitations

Run on a DigitalOcean server against a live TrueMenu. Unit tests: 11 passed. Compatibility check: all 8 cases matched.

| Case | Profile | Expected | Observed |
|---|

…

Try it

Open PR on GitHubView diff

Checkout locally

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