OpenResearch Science Lab
by danialhasan
README.md
# OpenResearch Science Lab (MCP App Plugin)
An open-source, EffectTS-powered Antigravity MCP App plugin that gives independent AI/ML/systems researchers a live side-pane and sidebar cockpit for:
- **Live GPU Compute & Zero-Leak Telemetry:** Colab Compute Unit (CU) balance, burn rate (`CU/hr`), active GPU assignments across default and isolated `/tmp/colab-*.json` configs, inferred experiment purpose, and a 2-step emergency `Stop VM` button.
- **Process & Quota Balance Monitor:** Live view of local GPU experiment runners, CLI model lanes, and test/build processes so silicon utilization and model token quota stay balanced.
- **AI Science Protocol GPS:** Generic 5-stage scientific method tracker (`Hypothesis & Falsification Gate`, `Cold Instrument Audit`, `Live Silicon Run`, `Blind Adversarial Audit`, `3-Layer Closeout`) paired with a dedicated `This Run:` live receipt strip underneath.
- **3-Layer Closing Loop Ledger:** Live disk-backed status for Layer 1 (Audited Paper), Layer 2 (Unsaturated Benchmarks), and Layer 3 (Reward-Safe RL Environment).
- **Experiments & Receipts Board:** Dynamic scan of `~/OpenResearch` with status filters (`All`, `Running`, `Verified`, `Falsified`, `Ready`), inline `Inspect Receipt` preview drawer (sandboxed strictly to `OPENRESEARCH_ROOT`), `Open File` host editor action, and capability-gated `Attach to Chat`.
## Architecture
- **EffectTS Services (`src/services/`):**
- `ColabService.ts` parses `colab usage` and `colab sessions` with bounded concurrency (`concurrency: 4`) and validates session/config names before teardown.
- `ProcessMonitor.ts` inspects active local runners and computes Compute-vs-Quota balance notes.
- `ResearchScanner.ts` scans `OPENRESEARCH_ROOT` for verified JSON/Markdown receipts and enforces canonical `realpath` boundary checks on previews.
- **MCP App Server (`src/mcp.ts`, `src/server.ts`):**
- Serves `ui://openresearch-lab/app.html` (`text/html;profile=mcp-app`) built into a single self-contained HTML bundle via `esbuild`.
- Registers `openresearch_lab_cockpit` with both `aux_pane` and `global` Antigravity entrypoints titled `Science Lab`.
- Keeps UI-driven polling and actions (`refresh_lab_state`, `stop_colab_session`, `read_receipt_preview`) strictly `visibility: ["app"]` so background refreshes spend zero model tokens.
## Build & Verify
```bash
pnpm install
npm run typecheck
npm run build
npm test
```
## Local Antigravity Installation
Symlink this repository into your local Antigravity plugins folder:
```bash
git clone https://github.com/danialhasan/ai-science-plugin.git
cd ai-science-plugin
pnpm install && npm run build
ln -s "$(pwd)" ~/.gemini/config/plugins/openresearch-lab
```
Once linked, open **Science Lab** from the side pane `+` menu, the left sidebar, or by calling `openresearch_lab_cockpit` in chat.
## Environment Variables
- `OPENRESEARCH_ROOT`: Override the default `~/OpenResearch` research directory.
- `OPENRESEARCH_COLAB_BIN`: Override the path to the `colab` CLI binary.
- `OPENRESEARCH_APP_HTML`: Override the path to the bundled `app.html` UI file (useful during UI iteration).
## License
MIT