docs: Day-8 close-out — AGENTS §12-§14 + README Day-8 row
Browse files- AGENTS §12 documents the multi-modal explainer surface
(explain(payload, modality)), §13 the Experiments routes
(/experiments/runs, /experiments/diff) and disable-mlflow contract,
§14 the HF Spaces deploy surface (Dockerfile.hf, supervisord.conf,
build-time artifact baking).
- README adds Day 8 to the status table (184 tests green) and points
to the Day-8 plan + new endpoints + new deploy artifacts.
- DoD-1 through DoD-5 all green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
AGENTS.md
CHANGED
|
@@ -231,3 +231,48 @@ behavior:
|
|
| 231 |
The `POST /explain/bbb` endpoint mirrors this contract. Pydantic
|
| 232 |
enforces a non-empty `top_features` list (422 on empty); every other
|
| 233 |
failure mode degrades to template + WARNING log + `source="template"`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
The `POST /explain/bbb` endpoint mirrors this contract. Pydantic
|
| 232 |
enforces a non-empty `top_features` list (422 on empty); every other
|
| 233 |
failure mode degrades to template + WARNING log + `source="template"`.
|
| 234 |
+
|
| 235 |
+
## 12. Multi-Modal Explainer (Day 8)
|
| 236 |
+
|
| 237 |
+
`src/llm/explainer.py` exposes `explain(payload, modality)` where
|
| 238 |
+
`modality ∈ {"bbb", "eeg", "mri"}`. Each modality has its own
|
| 239 |
+
deterministic template (`_template_explain_bbb / _eeg / _mri`) and
|
| 240 |
+
its own LLM prompt header. Unknown modality strings degrade to the
|
| 241 |
+
BBB template with a warning log; the function never raises. The
|
| 242 |
+
hybrid OpenRouter fallback contract from §11 applies uniformly.
|
| 243 |
+
|
| 244 |
+
The API exposes three matching endpoints — `POST /explain/{bbb,eeg,mri}` —
|
| 245 |
+
each on the `explain_router` (`/explain` prefix). Streamlit surfaces
|
| 246 |
+
the BBB version in the AI Assistant tab and the EEG/MRI versions as
|
| 247 |
+
inline expanders inside their respective pipeline tabs.
|
| 248 |
+
|
| 249 |
+
## 13. Experiments Surface (Day 8)
|
| 250 |
+
|
| 251 |
+
`GET /experiments/runs` returns up to 50 most recent MLflow runs
|
| 252 |
+
across the bbb/eeg/mri experiments, flattened into a list of
|
| 253 |
+
`MLflowRunSummary` (run_id, experiment_name, start_time, status,
|
| 254 |
+
metrics, params). `POST /experiments/diff {run_id_a, run_id_b}`
|
| 255 |
+
returns a side-by-side metric+param diff (`RunDiffRow`).
|
| 256 |
+
|
| 257 |
+
When `NEUROBRIDGE_DISABLE_MLFLOW=1`, both endpoints return empty
|
| 258 |
+
responses without raising — required for the HF Spaces deployment
|
| 259 |
+
where there is no writable mlruns/ tree. Unknown run ids → 404.
|
| 260 |
+
|
| 261 |
+
The Streamlit "Experiments" tab is the user-facing surface. Cached
|
| 262 |
+
in session state with an explicit Refresh button.
|
| 263 |
+
|
| 264 |
+
## 14. Deploy Surface (Day 8)
|
| 265 |
+
|
| 266 |
+
`Dockerfile.hf` is the Hugging Face Spaces image. Single container,
|
| 267 |
+
two processes (FastAPI :8000 + Streamlit :7860) launched via
|
| 268 |
+
`supervisord.conf`. Build-time `RUN python -m src.models.bbb_model`
|
| 269 |
+
bakes the model artifact into the image so the first `/predict/bbb`
|
| 270 |
+
call is instant on cold start.
|
| 271 |
+
|
| 272 |
+
Default environment: `DEPLOY_ENV=hf_spaces`,
|
| 273 |
+
`NEUROBRIDGE_DISABLE_MLFLOW=1`, `NEUROBRIDGE_DISABLE_LLM=1`.
|
| 274 |
+
Operators can opt back into LLM by setting `OPENROUTER_API_KEY` in
|
| 275 |
+
the HF Space's Secrets panel and unsetting the disable flag.
|
| 276 |
+
|
| 277 |
+
The README's YAML front-matter declares the Space metadata
|
| 278 |
+
(SDK=docker, port=7860, app_file=src/frontend/app.py).
|
README.md
CHANGED
|
@@ -38,6 +38,7 @@ short_description: Living decision system for BBB, EEG, and MRI clinical ML
|
|
| 38 |
| 5 | Decision Layer (Model + XAI + Interactive UI) | [`bbb_model.py`](src/models/bbb_model.py) — RandomForest + SHAP + `POST /predict/bbb` | Shipped — 158 tests green |
|
| 39 |
| 6 | Final Polish & Demo Features (Edge cases + Calibration + ComBat viz) | Calibration metadata + edge-case probes + `POST /pipeline/mri/diagnostics` | Shipped — 165 tests green |
|
| 40 |
| 7 | Final 5% (Drift, Traceability & Agents) | Per-worker drift z-score + MLflow provenance badge + `POST /explain/bbb` (LLM + template fallback) + AI Assistant tab | Shipped — 175 tests green |
|
|
|
|
| 41 |
|
| 42 |
## Quick Start
|
| 43 |
|
|
@@ -220,6 +221,9 @@ finishes in under 4 seconds on a 2024 laptop.
|
|
| 220 |
- **Day-7 plan (full TDD task breakdown):** [`docs/superpowers/plans/2026-05-05-day7-drift-traceability-agents.md`](docs/superpowers/plans/2026-05-05-day7-drift-traceability-agents.md)
|
| 221 |
- **New surface:** `POST /explain/bbb` — natural-language rationale (LLM + deterministic fallback)
|
| 222 |
- **New surface:** `drift_z` / `rolling_n` / `provenance` fields in `POST /predict/bbb` response
|
|
|
|
|
|
|
|
|
|
| 223 |
|
| 224 |
## Day 7 — Demo Recipe
|
| 225 |
|
|
|
|
| 38 |
| 5 | Decision Layer (Model + XAI + Interactive UI) | [`bbb_model.py`](src/models/bbb_model.py) — RandomForest + SHAP + `POST /predict/bbb` | Shipped — 158 tests green |
|
| 39 |
| 6 | Final Polish & Demo Features (Edge cases + Calibration + ComBat viz) | Calibration metadata + edge-case probes + `POST /pipeline/mri/diagnostics` | Shipped — 165 tests green |
|
| 40 |
| 7 | Final 5% (Drift, Traceability & Agents) | Per-worker drift z-score + MLflow provenance badge + `POST /explain/bbb` (LLM + template fallback) + AI Assistant tab | Shipped — 175 tests green |
|
| 41 |
+
| Day 8 — The Grand Finale (Multi-Modal Agents, Track 5 & Public Deploy) | Shipped — 184 tests green |
|
| 42 |
|
| 43 |
## Quick Start
|
| 44 |
|
|
|
|
| 221 |
- **Day-7 plan (full TDD task breakdown):** [`docs/superpowers/plans/2026-05-05-day7-drift-traceability-agents.md`](docs/superpowers/plans/2026-05-05-day7-drift-traceability-agents.md)
|
| 222 |
- **New surface:** `POST /explain/bbb` — natural-language rationale (LLM + deterministic fallback)
|
| 223 |
- **New surface:** `drift_z` / `rolling_n` / `provenance` fields in `POST /predict/bbb` response
|
| 224 |
+
- **Day-8 plan (full TDD task breakdown):** [`docs/superpowers/plans/2026-05-06-day8-grand-finale.md`](docs/superpowers/plans/2026-05-06-day8-grand-finale.md)
|
| 225 |
+
- **New surfaces:** `POST /explain/eeg`, `POST /explain/mri`, `GET /experiments/runs`, `POST /experiments/diff`
|
| 226 |
+
- **New deploy artifacts:** `Dockerfile.hf`, `supervisord.conf`
|
| 227 |
|
| 228 |
## Day 7 — Demo Recipe
|
| 229 |
|