in reviewhumanPR #364Identity
Mine Context Layer: add MCP shared-context integration with permission and degraded-source tests
Mine Context Layer is an MCP server that holds the shared context of one underground-mine shift: plan, fleet, operating rules, events with provenance (source, validity, confidence, link to the original record), proposals, and a human…
Description
The pitch.
## Summary
Mine Context Layer is an MCP server that holds the shared context of one underground-mine shift: plan, fleet, operating rules, events with provenance (source, validity, confidence, link to the original record), proposals, and a human decision log. Agents read and write it through eight MCP tools, with permissions by role: source agents only publish events from their own system, function agents read everything and propose, and only a human approves.
This PR adds `examples/integrations/mine-context-layer/`: three Lab scenarios that run one shift incident (scoop LH-07 fails at stope TP-1310-04) against the live server, validators that judge only what the adapter recorded, saved evidence for each case, and `tests/test_example_mine_context_layer.py`. No project code is added to Town.
## Integration
- The server stays in its own repository (https://github.com/jsanti00/mine-context-layer), pinned at commit `4b3c9e0`, and runs as separate processes with its own environment.
- `mcl_layer` is the adapter and the only role that talks MCP. It opens one MCP stdio session per Town participant, each with that participant's layer identity and role (source or function), and turns Town messages into real tool calls. Town agents without a layer identity are refused.
- Radio, CMMS, maintenance and planning are Town scripts in the `workflow` and `cmms_down` cases. In the `agents` case they are the project's four real agents (headless Claude Code, each connected only to the layer over MCP), and Town carries their turn-taking.
- The supervisor approves through the project's own non-MCP command (`python -m mcl.session decide`), because no MCP tool can approve.
- `mcp_bridge.py` is adapted from the Open Trading Desk example (#322), so both integrations share one bridge design.
## Reproduce
Python 3.12 and uv. From the root of this repository:
git clone https://github.com/jsanti00/mine-context-layer.git ../mine-context-layer
git -C ../mine-context-layer checkout 4b3c9e017f1e85db55e251a21efd65f090847af5
(cd ../mine-context-layer && uv sync)
python3.12 -m venv .venv
.venv/bin/python -m pip install -e '.[dev]' -r examples/integrations/mine-context-layer/requirements.lock
.venv/bin/python examples/integrations/mine-context-layer/run.py --project ../mine-context-layer --case workflow --out /tmp/mcl-town
.venv/bin/python examples/integrations/mine-context-layer/run.py --project ../mine-context-layer --case cmms-down --out /tmp/mcl-town
.venv/bin/python examples/integrations/mine-context-layer/run.py --verify examples/integrations/mine-context-layer/evidence
.venv/bin/python -m pytest -q tests/test_example_mine_context_layer.py
The `agents` case (`--case agents`) needs Claude Code installed and logged in. Nanda Town commit: `6f9a7c0`. Project version: `4b3c9e0`. Evaluator `lab-0.2.6`, seed 42.
## Results and limitations
| Stage | Expected | workflow | cmms_down | agents |
| --- | --- | --- | --- | --- |
| connection | Eight project tools over live MCP sessions, unmodified commit `4b3c9e0` | Passed | Passed | Passed |
| id_resolution | Spoken "scoop 7" / "1310-04" resolved to LH-07 at TP-1310-04 | Passed | Passed | Passed |
| provenance | CMMS record links to its work orders and is cited by the assessment | Passed | n/a | n/a |
| permission_boundary | Function agent's publish denied and logged; Town agent without a layer identity refused | Passed | n/a | n/a |
| degraded_source | CMMS down: no CMMS record; estimate names what is missing, confidence below 0.7 | n/a | Passed | n/a |
| action_matches_key | Move LH-11 from TP-1250-02 to TP-1310-04, citing failure and assessment | Passed | Passed | Passed |
| real_agents | Four real agents finish, use only layer tools, no denials | n/a | n/a | Passed (64 s) |
| human_decision | Supervisor's approval in the layer's decision log, written outside MCP | Passed | Passed | Passed |
Failure and boundary cases: a function agent trying to publish (denied by the laye
…Try it
Open PR on GitHubView diffCheckout locally
git fetch origin pull/364/head:pr-364
git checkout pr-364