closedhumanPR #329Transport
LOOM: add task-scoped health-context access integration with overreach, expiry and portal-down tests
What this tests: the agent-to-service interaction where a Town agent working for a person asks LOOM for that person's health context.
Author
@jasonpipi
github profile →- Status
- Closed without merging
- Opened on
- Nov 10
- Branch
- integration/loom-health-context
Description
The pitch.
## Summary **What this tests:** the agent-to-service interaction where a Town agent working for a person asks LOOM for that person's health context. A `loom_requester` discovers the `loom_gateway` through the Town registry and sends a signed `health.context` request and fetch; the gateway forwards it to the LOOM portal's HTTP API, which returns a task-scoped, expiring grant or a denial. LOOM decides how much of a person's health information an agent that works for them may receive, for how long, and with how much friction. Depth follows the task, every grant expires, overreach is blocked, and a publisher's credit changes friction but never depth. This PR adds `examples/loom/`: a Lab gateway/requester adapter, two scenarios, an integration test and a verify helper. Together they run LOOM end to end inside Town's shared registry, auth, transport, trust, privacy and evidence layers. No Town source files are changed. ## Integration - LOOM runs as a separate HTTP service: https://github.com/jasonpipi/loom-portal (tag `v0.1.0`, policy `loom-policy-0.1.0`, standard library only). This PR does not include it. - The `loom_gateway` role registers `health.context` in the Town registry and forwards each signed request to the portal at `LOOM_URL`. It uses the envelope sender as the requester and Lab time as the request time. If the portal is unreachable, it fails closed. - Five `loom_requester` agents (grocery, injected grocery, meal plan, clinic, marketing) discover the gateway through the registry and send requests and fetches on logical days. - Overreach produces `api.rate(..., "bad")`, which leaves a signed data-facts receipt and a trust-layer update. Health data in replies is redacted from the bundle (`redact_fields: [data]`). Town's transport fault injection duplicates the first request. ## Reproduce Nanda Town `main` @ `6f9a7c064486c4a0ae9242f1ff341b8a4aad0244`, evaluator `lab-0.2.6`, Python 3.12, loom-portal `v0.1.0`. ```bash python3.12 -m venv .venv && source .venv/bin/activate python -m pip install -e '.[dev]' python -m pip install "git+https://github.com/jasonpipi/loom-portal@v0.1.0" python -m pytest -q examples/loom # starts a portal, runs both scenarios, verifies bundles # by hand loom-portal --port 8787 --seed-credit cambridge-clinic=85 & LOOM_URL=http://127.0.0.1:8787 nandatown run examples/loom/loom_health_access.yaml --out runs/loom nandatown run examples/loom/loom_health_access_portal_down.yaml --out runs/loom-down python examples/loom/verify_loom.py runs/loom/<run-id> ``` `examples/loom/README.md` has the full step table. ## Results and limitations **Main scenario: PASSED, 10 of 10 stages.** The stages are `loom_reachable`, `discovery` (5 of 5 via the registry), `decisions_match_policy` (8 of 8 steps), `minimum_disclosure`, `overreach_contained`, `expiry_enforced`, `friction_not_depth`, `idempotent_retry`, `ledger_conserved` and `privacy`. | Case | Expected | Observed | |---|---|---| | Injected grocery agent asks for 5-minute readings | blocked, publisher penalized, Town reputation down | blocked `overreach`, credit 61 → 41, `reputation_updated` bad with receipt | | Same publisher's honest agent, next day | same tier, more friction | still L3, confirmation `first_request` → `every_time` | | Meal-plan fetch on day 5 / day 9 (7-day grant) | granted / expired | granted / denied `expired` | | Duplicated request | one decision, credit moves once | replay, credit unchanged | | Portal down (second scenario) | fail closed, no data | all 8 steps denied `loom_unreachable`; `fail_closed` passed | **A failure found by Town.** On the first run, `idempotent_retry` failed. The duplicated copy reached the gateway 0.1 days later, the gateway stamped that later time into the request, and LOOM answered `conflict` (409) instead of a replay. LOOM's unit tests had missed this because they always resent identical bodies. LOOM now leaves the receive time out of its idempotency di …
Try it
Open PR on GitHubView diffCheckout locally
git fetch origin pull/329/head:pr-329
git checkout pr-329