|
1 | 1 | # SynapDrive-AI |
2 | 2 |
|
3 | | -**SynapDrive-AI** is a **simulation-first** prototype of an **intent → safety → actuation** control pipeline inspired by BCI/autonomy workflows. |
| 3 | +**SynapDrive-AI** is a **simulation-first** reference implementation of an **intent → context → safety gate → actuation** pipeline inspired by autonomy + BCI workflows. |
4 | 4 |
|
5 | | -This repo **does not** claim medical/clinical functionality. It is intentionally built to be runnable on any machine without hardware: |
6 | | -- **Text pathway** = “decoded intent” (what a BCI decoder *could* output) |
7 | | -- **Signal pathway** = simulated EEG-like waveforms + label-driven reasoning |
| 5 | +This repo makes **no medical/clinical claims**. It’s designed to be runnable without hardware, while still supporting **optional** real-world input pathways (BrainFlow / LSL). |
8 | 6 |
|
9 | 7 | --- |
10 | 8 |
|
11 | | -## What you can do with it (today) |
| 9 | +## What it does |
12 | 10 |
|
13 | | -- Run a full end-to-end loop: **intent → context → safety gate → actuation → evaluation** |
14 | | -- Verify safety gating blocks low-confidence actions |
15 | | -- View stable telemetry logs (intended for dashboards/tests) |
16 | | -- Extend it with real adapters later (robotics, vehicles, BCI devices) |
| 11 | +- End-to-end loop: **intent → optimizer (memory + vision context) → safety gate → actuation → evaluation** |
| 12 | +- **Safe-by-default:** unknown / low-confidence intents are blocked |
| 13 | +- **Telemetry contract:** stable log schema for dashboards/tests |
| 14 | +- **Reproducibility:** record/replay (JSONL) |
| 15 | +- **Quality gates:** tests + CI + lint + type-check + coverage |
| 16 | +- **Dashboard:** local Flask UI for quick inspection |
17 | 17 |
|
18 | 18 | --- |
19 | 19 |
|
20 | 20 | ## Architecture (canonical pipeline) |
21 | 21 |
|
22 | 22 | ```mermaid |
23 | 23 | flowchart LR |
24 | | - A[Input: decoded text OR simulated signal] --> B[Intent decode / reasoning] |
25 | | - B --> C[Optimizer: memory + vision context] |
26 | | - C --> D[SafetyGuard] |
27 | | - D -->|safe| E[DecisionRouter] |
28 | | - D -->|blocked| X[Blocked result] |
29 | | - E --> F[ActuationEngine (simulated)] |
30 | | - F --> G[EpisodicMemory] |
31 | | - F --> H[MetaEvaluator] |
32 | | - G --> C |
33 | | -
|
| 24 | + A[Input: decoded text / simulated signal / BrainFlow / LSL] --> B[Intent packet] |
| 25 | + B --> C[Context optimizer: memory + vision] |
| 26 | + C --> D{SafetyGate} |
| 27 | + D -- safe --> E[DecisionRouter] |
| 28 | + D -- blocked --> X[Blocked response] |
| 29 | + E --> F[ActuationEngine (simulated)] |
| 30 | + F --> G[EpisodicMemory] |
| 31 | + F --> H[MetaEvaluator] |
| 32 | + G --> C |
34 | 33 |
|
35 | 34 | Single source of truth wiring: synapdrive_ai/pipeline.py |
36 | 35 |
|
37 | 36 | Quickstart |
38 | | -1) Install |
| 37 | +Install |
39 | 38 | python -m venv .venv |
40 | 39 | source .venv/bin/activate |
41 | 40 | pip install -r requirements.txt |
| 41 | +Run (decoded intent text) |
| 42 | +python -m synapdrive_ai --text "move left" --image road --no-delay |
| 43 | +python -m synapdrive_ai --text "stop" --image hazard --no-delay |
| 44 | +Run (simulated signal label) |
| 45 | +python -m synapdrive_ai --signal walk --count 3 --interval 1 --no-delay |
| 46 | +python -m synapdrive_ai --signal stop --no-delay |
| 47 | +Tests |
| 48 | +pip install -r requirements-dev.txt |
| 49 | +pytest -q |
| 50 | +Record & replay (reproducible runs) |
42 | 51 |
|
43 | | -2) Run one cycle (decoded intent text) |
44 | | -python -m synapdrive_ai --text "move left" --image road |
45 | | -python -m synapdrive_ai --text "stop" --image hazard |
| 52 | +Record a run to JSONL: |
46 | 53 |
|
47 | | -3) Run one cycle (simulated signal label) |
48 | | -python -m synapdrive_ai --signal walk --count 3 --interval 1 |
49 | | -python -m synapdrive_ai --signal stop |
| 54 | +python -m synapdrive_ai --text "move left" --image road --record runs.jsonl --no-delay |
| 55 | +python -m synapdrive_ai --signal walk --count 3 --record runs.jsonl --no-delay |
50 | 56 |
|
51 | | -4) Run tests |
52 | | -pytest -q |
| 57 | +Replay later (deterministic, no-delay): |
| 58 | +
|
| 59 | +python -m synapdrive_ai --replay runs.jsonl |
| 60 | +Dashboard (Flask) |
| 61 | +
|
| 62 | +Run: |
| 63 | +
|
| 64 | +python -m synapdrive_ai.interface.web_dashboard |
| 65 | +
|
| 66 | +Open: |
| 67 | +
|
| 68 | +http://127.0.0.1:5055 |
| 69 | +
|
| 70 | +Optional integrations (not installed by default) |
| 71 | +BrainFlow (optional) |
| 72 | +
|
| 73 | +Install: |
| 74 | +
|
| 75 | +pip install -r requirements-brainflow.txt |
| 76 | +
|
| 77 | +Run (defaults to BrainFlow Synthetic board, id=0): |
| 78 | +
|
| 79 | +python -m synapdrive_ai --brainflow --bf-board-id 0 --bf-seconds 2 --no-delay |
| 80 | +LSL / pylsl (optional) |
| 81 | +
|
| 82 | +Install: |
| 83 | +
|
| 84 | +pip install -r requirements-lsl.txt |
| 85 | +
|
| 86 | +Run (recommend specifying stream type or name): |
| 87 | +
|
| 88 | +python -m synapdrive_ai --lsl --lsl-type EEG --lsl-seconds 2 --no-delay |
| 89 | +# or |
| 90 | +python -m synapdrive_ai --lsl --lsl-name "MyEEGStream" --lsl-seconds 2 --no-delay |
| 91 | +Repo map |
| 92 | +
|
| 93 | +synapdrive_ai/pipeline.py — canonical wiring (supports deterministic --no-delay) |
| 94 | +
|
| 95 | +synapdrive_ai/bci/intent_generator.py — conservative text → intent packet |
| 96 | +
|
| 97 | +synapdrive_ai/bci/signal_simulator.py — synthetic EEG-like signals |
53 | 98 |
|
54 | | -Repo map (what matters) |
| 99 | +synapdrive_ai/agi/core_reasoning.py — RMS-based confidence from signal energy |
55 | 100 |
|
56 | | -synapdrive_ai/pipeline.py |
57 | | -Canonical end-to-end pipeline. |
| 101 | +synapdrive_ai/agi/cognitive_optimizer.py — memory + vision context injection |
58 | 102 |
|
59 | | -synapdrive_ai/bci/signal_simulator.py |
60 | | -Generates EEG-like synthetic waveforms. |
| 103 | +synapdrive_ai/safety/safety_guard.py — safety gating |
61 | 104 |
|
62 | | -synapdrive_ai/agi/core_reasoning.py |
63 | | -Label + waveform → structured intent packet (uses RMS energy for confidence). |
| 105 | +synapdrive_ai/action/decision_router.py — normalized result packets |
64 | 106 |
|
65 | | -synapdrive_ai/agi/cognitive_optimizer.py |
66 | | -Injects memory + vision context into intent. |
| 107 | +synapdrive_ai/control/actuation_engine.py — simulated actuation + telemetry schema |
67 | 108 |
|
68 | | -synapdrive_ai/safety/safety_guard.py |
69 | | -Blocks low-confidence or suspicious actions. |
| 109 | +synapdrive_ai/replay/recording.py — JSONL record/replay utilities |
70 | 110 |
|
71 | | -synapdrive_ai/action/decision_router.py |
72 | | -Normalizes results and routes to actuation. |
| 111 | +synapdrive_ai/interface/web_dashboard.py — Flask dashboard |
73 | 112 |
|
74 | | -synapdrive_ai/control/actuation_engine.py |
75 | | -Simulated actuator + telemetry log schema. |
| 113 | +synapdrive_ai/tests/ — contract tests (pipeline shape, telemetry keys, dashboard API) |
76 | 114 |
|
77 | | -synapdrive_ai/tests/ |
78 | | -Contract tests enforcing stable output + telemetry. |
| 115 | +examples/ — reviewer quickcheck + golden runs generator |
79 | 116 |
|
80 | | -Safety stance |
| 117 | +docs/ — architecture + safety model writeups |
81 | 118 |
|
82 | | -This project enforces a conservative safety default: |
| 119 | +Reviewer validation pack |
83 | 120 |
|
84 | | -Unknown / low-confidence intents are blocked |
| 121 | +examples/REVIEWER_QUICKCHECK.md (2–5 minute checklist) |
85 | 122 |
|
86 | | -Telemetry schema is treated as a contract (dashboard/tests depend on it) |
| 123 | +examples/generate_golden_runs.py → examples/golden_runs.jsonl |
87 | 124 |
|
88 | | -Roadmap (credible next steps) |
| 125 | +Generate & replay: |
89 | 126 |
|
90 | | -Add optional integration adapters (not enabled by default): |
| 127 | +python examples/generate_golden_runs.py --out examples/golden_runs.jsonl |
| 128 | +python -m synapdrive_ai --replay examples/golden_runs.jsonl |
| 129 | +Safety stance (explicit) |
91 | 130 |
|
92 | | -BrainFlow input stream (device or replay) |
| 131 | +Unknown or low-confidence intents are blocked |
93 | 132 |
|
94 | | -MNE-based feature extraction for offline datasets |
| 133 | +Stable response shapes (no crashing on drift) |
95 | 134 |
|
96 | | -LSL (Lab Streaming Layer) bridge for research setups |
| 135 | +Telemetry schema is a contract (UI/tests depend on it) |
97 | 136 |
|
98 | | -Add real actuator adapters: |
| 137 | +Non-goals: |
99 | 138 |
|
100 | | -ROS2 topic publisher |
| 139 | +clinical diagnosis |
101 | 140 |
|
102 | | -MAVLink command emitter |
| 141 | +medical-device claims |
103 | 142 |
|
104 | | -Game/Sim environment interface |
| 143 | +real-world safety certification for actuation |
105 | 144 |
|
106 | 145 | License |
107 | 146 |
|
|
0 commit comments