in reviewhumanPR #324Transport

Taste Twin: add shared-taste MCP integration and duplicate-choice test

Taste Twin is a shared taste memory for AI agents. Any agent acting for a person can call it over MCP to rank cafe options the way that person would.

Author

Status
In review
Opened on
Nov 9
Branch
integration/tastetwin-ranking

Description

The pitch.

## Summary
Taste Twin is a shared taste memory for AI agents. Any agent acting for a person can call it over MCP to rank cafe options the way that person would. When the person picks one, the agent records the choice, and every other agent working for them benefits next time.

This PR adds a Lab scenario (`examples/tastetwin/`) in which several Nanda Town agents use the live Taste Twin server through Town's shared infrastructure:
- two independent planner agents acting for one person
- six cafe agents acting for themselves
- an agent acting for someone else that tries to get the person's taste
- a Taste Twin adapter that all of them can find through the registry

It checks that one agent's recorded choice reaches a second agent that was never told, that a duplicated choice message is applied once, and that an agent the person never granted gets nothing.

## Integration
- **Taste Twin service:** hosted separately at `https://cafe-taste-twin.lovable.app/mcp` (MCP over Streamable HTTP, Supabase sign-in). No Taste Twin app code is in this PR.
- **`tastetwin_plugin.py`** defines five roles and the `tastetwin_shared_taste` validator:
  - `tt_adapter`: publishes a signed `taste.rank` card and turns Town messages into MCP calls (`get_profile_context`, `get_taste_profile`, `rank_options`, `record_feedback`, `record_choice`).
  - `tt_planner`: acts for one person. Finds cafes and Taste Twin through the registry, asks for a ranking, and (planner-a only) asks the person and reports the pick and one stated preference.
  - `tt_cafe`: publishes its own `cafe.listing` card.
  - `tt_user`: stands in for the person.
  - `tt_snoop`: acts for someone else, claims to act for the person, and asks anyway.
- **Access:**
  - Taste Twin checks its own callers: an OAuth token for one user, then per-agent read and write switches.
  - The adapter holds that user's sign-in, so Taste Twin can't tell which Town agent is behind a call. The adapter therefore enforces the person's grants itself (`serves: pang`, `grants: [planner-a, planner-b]`).
  - Town's signatures (`hmac.v1`) make the sender's name trustworthy; the grant decides access.
- **`tastetwin_shared_taste.yaml`** loads the plugin through `plugin_files:` and duplicates the first `choice_report` message.
- **Town layers exercised:**
  - registry `index.owned.v1`: discovery
  - auth `hmac.v1`: signed cards and messages
  - memory `kv.v1`: each planner's private working state; planner-b starts empty
  - transport: the duplicate fault
  - privacy `redact.v1`: what the person said and the profile weights stay out of exported records
- **Modes:**
  - `TASTETWIN_MODE=live` calls the real server.
  - `replay` (the default) serves reduced responses recorded from it (`fixtures/`), so reviewers need no credentials. Replay reports `live_service` and `server_auth` as `not_tested`; it is not live compatibility evidence.
  - `TASTETWIN_DEDUPE=0` turns off the adapter's duplicate protection.

## Reproduce
- **Nanda Town:** `6f9a7c064486c4a0ae9242f1ff341b8a4aad0244` (v0.2.0, evaluator `lab-0.2.6`)
- **Taste Twin:** MCP server `cafe-taste-twin` 0.1.0, app commit `cc7fa17`. Live runs recorded 2026-11-09 17:30–17:32 UTC.

```bash
python3 -m venv .venv && source .venv/bin/activate
python -m pip install -e '.[dev]'

# Replay (no credentials)
TASTETWIN_MODE=replay nandatown run examples/tastetwin/tastetwin_shared_taste.yaml --out runs/tt
python examples/tastetwin/verify.py runs/tt/<run-id>
TASTETWIN_MODE=replay TASTETWIN_DEDUPE=0 nandatown run examples/tastetwin/tastetwin_shared_taste.yaml --out runs/tt-nodedupe
python -m pytest -q tests/test_tastetwin_example.py

# Committed live evidence
python examples/tastetwin/verify.py examples/tastetwin/evidence/live-dedupe-on
python examples/tastetwin/verify.py examples/tastetwin/evidence/live-dedupe-off

# Live (needs a Taste Twin account; writes one choice and one preference)
python examples/tastetwin/tt_auth.py start          # open the link, sign in, approve
python examples/tas

…

Try it

Open PR on GitHubView diff

Checkout locally

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