in reviewhumanPR #362Transport
LOOM: add task-scoped health-context access integration with overreach, expiry and replay tests
Supersedes #329 (same integration, rebased onto current main, plus the replay fix described under Results).
Author
@jasonpipi
github profile →- Status
- In review
- Opened on
- Nov 12
- Branch
- integration/loom-health-context-v2
Description
The pitch.
Supersedes #329 (same integration, rebased onto current `main`, plus the replay fix described under Results). ## 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. No Town source files are changed. ## Integration - LOOM runs as a separate HTTP service: https://github.com/jasonpipi/loom-portal (v0.1.1, commit `480558e`, policy `loom-policy-0.1.1`, 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 upstream base: `6f9a7c064486c4a0ae9242f1ff341b8a4aad0244` - LOOM integration snapshot (branch `integration/loom-health-context-v2` on `jasonpipi/nandatown`): `a022a831db4c4b9a4a862f652522e255e268dc0f` - LOOM portal: `v0.1.1`, commit `480558ee41af23a3f0937cfa207cff1e0ed43d32` (policy `loom-policy-0.1.1`) - Python 3.12, Town evaluator `lab-0.2.6` Run from an empty working directory. The pinned integration snapshot, which contains `examples/loom/`, is on the fork's integration branch. ```bash git clone https://github.com/jasonpipi/nandatown cd nandatown git checkout --detach a022a831db4c4b9a4a862f652522e255e268dc0f 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@480558ee41af23a3f0937cfa207cff1e0ed43d32" python -m pytest -q examples/loom ``` The test command starts a local portal, runs both scenarios, and verifies the evidence bundles with the LOOM validators loaded. To run the scenarios and verify a bundle manually: ```bash 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 # Set BUNDLE to the directory printed for the main scenario. BUNDLE=runs/loom/REPLACE_WITH_RUN_ID python examples/loom/verify_loom.py "$BUNDLE" ``` `examples/loom/README.md` has the full step table. ## Results and limitations **Main scenario: PASSED, 11 of 11 stages** (run `sim-2094eaa8c81d`): `loom_reachable`, `discovery` (5 of 5), `decisions_match_policy` (8 of 8), `minimum_disclosure`, `overreach_contained`, `expiry_enforced`, `friction_not_depth`, `idempotent_retry`, `replay_rechecks_validity`, `ledger_conserved`, `privacy`. Portal-down scenario: PASSED. Reproduced from an empty directory with only pushed commits. Bundle fingerprint `sha256:3a3793c3e162c5373e5eccbb22904f95bafca01f84a102a2485f8739022a7419` (Town 0.2.0, evaluator `lab-0.2.6`), verified with `verify_loom.py`. `examples/loom` i …
Try it
Open PR on GitHubView diffCheckout locally
git fetch origin pull/362/head:pr-362
git checkout pr-362