Skip to main content
Glama
README.md
# GhostBus

**Old machines. New intelligence. Controlled access.**

GhostBus is an agent-independent MCP-to-Modbus command firewall for one simulated centrifugal pump. It brings legacy Modbus TCP telemetry into MCP, checks proposed actions against deterministic policy, waits for operator approval when required, and independently verifies outcomes. TimeMachine reconstructs the incident and shows the simulated consequences of a different decision.

![GhostBus blocks a 96 °C reset and previews an approved cooling path](docs/screenshots/interlock.png)

[Machine overview](docs/screenshots/console.png) · [TimeMachine comparison](docs/screenshots/timemachine.png) · [Mobile console](docs/screenshots/mobile.png)

## Start GhostBus

```sh
docker compose up --build -d --wait
```

Open [GhostBus on localhost](http://127.0.0.1:8000/). [OpenAPI](http://127.0.0.1:8000/docs) documents the HTTP routes. Configuration defaults to the deterministic demonstration operator.

For local development with Python 3.12 and Node 22.12 or later in the 22.x line.

```sh
python3.12 -m venv .venv
.venv/bin/python -m pip install -r requirements-dev.txt
npm --prefix frontend ci
npm --prefix frontend run build
.venv/bin/python -m uvicorn backend.app:app --host 127.0.0.1 --port 8000
```

## Demonstrate the interlock

1. Inject overheating and advance three virtual ticks. The pump reaches 96 °C with a critical alarm.
2. Trigger the unsafe reset. GhostBus records `TEMP_RESET_001` and preserves the pump state.
3. Start diagnosis in demonstration mode. Inspect the proposed cooldown and its simulated temperature trajectory.
4. Approve cooling, execute it, and advance three more ticks. A separate Modbus read confirms recovery at 75 °C.
5. Compare outcomes in TimeMachine. Inspect the actual recovery and the simulated pump fault from allowing the reset.

## Architecture

```mermaid
flowchart LR
  Model["Operator or AI diagnosis"] --> MCP["MCP gateway"]
  MCP --> Workflow["Guarded workflow"]
  Console["Operator console"] --> Workflow
  Workflow --> Policy["Deterministic policy and approval"]
  Policy --> Executor["Controlled executor"]
  Executor --> Bridge["Private Modbus TCP bridge"]
  Bridge --> Pump["Pump simulator"]
  Pump --> Verify["Independent verification"]
  Verify --> Audit["TimeMachine and SQLite"]
  Policy --> Audit
  Audit --> Fork["Isolated counterfactual"]
```

[Architecture](docs/architecture.md) · [Safety policies](docs/safety-model.md) · [Threat model](docs/threat-model.md) · [Register map](docs/modbus-register-map.md) · [MCP tools and connection](docs/mcp-tools.md)

## Configuration

| Variable | Default or purpose |
| --- | --- |
| `GHOSTBUS_DB` | `ghostbus.sqlite` locally, mounted `/data/ghostbus.sqlite` in the image |
| `GHOSTBUS_SECURE_COOKIE` | Set to `1` behind HTTPS |
| `GHOSTBUS_ORIGIN` | Public origin allowed for browser-originated MCP requests |
| `GHOSTBUS_ENABLE_LIVE` | `0`. Set to `1` for a controlled live provider session |
| `GHOSTBUS_LLM_BASE` | Chat-completions base URL, defaults to OpenAI's versioned endpoint |
| `GHOSTBUS_LLM_MODEL`, `GHOSTBUS_LLM_KEY` | Optional provider configuration |
| `GHOSTBUS_MCP_TOKEN` | Client-side environment variable containing the generated incident bearer token |

Use the example environment file with Compose or export the variables for local Uvicorn. Live mode uses an explicitly configured provider compatible with JSON-mode chat completions. Its recommendation still passes through GhostBus policy and authorization.

## Verify

```sh
cd frontend
npx playwright install chromium
cd ..
./scripts/verify.sh
```

The verification suite covers policy boundaries, generated state and retry sequences, unauthorized writes, concurrent execution, Modbus TCP interoperability, the SDK MCP lifecycle, persistence, replay, and the complete browser walkthrough. See the [verification report](docs/verification-report.md) for observed results and limits.

## Release and Kiro

[Deployment](docs/deployment.md) · [Demo script](docs/demo-script.md) · [Devpost draft](docs/devpost-draft.md) · [Kiro handoff and submission requirements](docs/kiro-handoff.md) · [Engineering progress](docs/progress.md)

The project uses an illustrative simulator, session-based operator identity, a limited protocol profile, and a single application replica. Audit hashes detect edits under the stated trust model. Release notes describe the remaining public demo and Kiro work. Released under the [MIT License](LICENSE).

[ORBIT comparison](docs/differentiation.md) · [Capability profile](docs/capability-manifest.md)