## Phase 181: Phoebe — Brain-Computer Interface, Neuroscience, Clinical Psychology & Autonomous Discovery Platform

**Phoebe (Greek Titaness Φοίβη, "radiant / bright"; grandmother of Apollo and
the Titaness associated with the prophetic intellect and the Delphic oracle —
"she who sees and foretells") is the comprehensive brain-and-mind science
platform of the Oshun ecosystem. Phoebe pursues fundamental breakthroughs across
five frontier fields and the connective tissue between them: brain-computer
interfaces, computational and systems neuroscience, clinical psychology and
psychiatry, the AI-driven design and execution of experiments on brains and
behaviour, and the unified knowledge graph that links molecules → cells →
circuits → cognition → behaviour → disorders. Every layer is AI-integrated and
every layer is built to a single standard: read biological reality honestly,
report uncertainty loudly, keep a qualified human in the loop wherever a human
brain or a patient is on the other end, and turn passive observation into
causal, model-driven discovery.**

**Domain Assignment:** Phoebe **Library Prefix:** `@phoebe/*` **Goddess:**
Phoebe (Φοίβη) — Titaness of radiant intellect, prophetic insight, and the
oracle.

**Status:** In progress — 183/189 tasks complete. Built & tested: 30 `@phoebe/*`
packages (incl. the `phoebe-neuromodulation` Rust crate) + real Python backends
— Brian2 spiking simulation, a SONATA network on two backends (Brian2 + NEST,
matching rasters), Arbor↔TVB multi-scale co-simulation, BMTK/SONATA builds, a
GPU/HPC job scheduler with headroom guards, the TVB virtual-brain twin,
SpikeInterface spike-sorting benchmark, a calcium-imaging pipeline
(motion/segment/dF-F/OME-Zarr), latent-identifiability + RSA/CKA/CCA analysis,
PyNWB HDF5 round-trip, DANDI no-download streaming, LSL sub-ms time-sync + XDF
replay, a pyRiemann-validated motor-imagery benchmark on real EEGBCI data, and
the full `@phoebe/connectomics` CPU stack — a Biolink synapse-graph store &
connectivity query API validated on a FlyWire-derived olfactory fixture, a
CAVE-style versioned proofreading ChunkedGraph, an ML merge/split boundary-error
detector (from-scratch logistic regression, held-out AUC ≫ chance under a
label-permutation null), Neuroglancer-precomputed/sharded (compressed-Morton +
murmurhash3_x86_128) no-download chunk addressing, and MICrONS-style
function↔structure like-to-like fusion, plus the CPU `@phoebe/brain-models`
TopoLoss topographic prior (analytic-gradient smoothness objective + topography
diagnostic) and MEI / in-silico-optogenetics synthesis (projected-gradient MEI
that recovers a linear unit's receptive field to its closed-form optimum, and
causal unit-clamp readout), plus the board-agnostic `@phoebe/neural-io`
acquisition abstraction (BrainFlow-pattern prepare→stream→read lifecycle, a real
SPSC ring buffer that buffers a 384-channel 30 kHz second with zero sample loss,
a deterministic multi-sine synthetic board whose spectral peak recovers the
injected tone, and Iris/Aphrodite bridge adapters that consume their frames via
contracts), and the sEMG/fNIRS/fUS ingestion DSP (surface-EMG rectified
windowed-RMS envelope, the fNIRS modified Beer-Lambert ΔHbO/ΔHbR inversion that
round-trips exactly, and fUS mean-clutter-filtered power-Doppler), a
Neuropixels→NWB adapter (SPSC ring buffer drops 0/30000 samples and a PyNWB
`ElectricalSeries` passes `pynwb.validate` + round-trips with a checksum
matching the buffered stream), and a pure-TS Zarr v2 / OME-NGFF writer for
ScanImage/GEVI imaging that round-trips pixel-exact and is read back by
zarr-python. The `phoebe` PostgreSQL DB, the Neo4j Biolink KG store, and MinIO
object storage are provisioned against the dev docker stack; all five
`@phoebe/apps` Next.js apps are build-verified. The remaining 6 tasks are under
capability-by-capability audit and are left unchecked rather than represented by
tokenizer-only or fail-loud seams: GPU foundation-model training (spike/EEG/fMRI
foundation models & fMRI-to-image, §181.5.2, §181.9.1.1, §181.9.2.1), the
learned C++/CUDA flood-filling-network on petavoxel EM (§181.7.1.1; its
tiling/resume orchestration is built and tested on CPU). Spike sorting
(§181.10.1.1) now runs MountainSort5 through SpikeInterface with SNR/rate/
presence QC, validates motion estimation and interpolation on a known drifting
recording, exposes a capability-checked Kilosort4 wrapper that refuses to
substitute another sorter when CUDA is absent, and includes a bounded-memory
streaming template sorter for edge use. The latent-model suite (§181.10.2.1) now
runs real CPU-reference GPFA, LFADS/AutoLFADS, pi-VAE, and CEBRA fits, evaluated
on held-out data from a known-generative fixture against label-permutation/null
baselines with explicit identifiability and rotational-degeneracy reports;
production-scale sweeps remain a GPU deployment concern rather than an
implementation gap. Phoebe is a **standalone domain that depends on** existing
assets via contracts and **does not move or absorb their code**: it consumes
Iris's BCI device/HID layer (`@iris/bci-*`, `@iris/multimodal-bci`), Aphrodite's
biometric/EEG engine (`@aphrodite/biometric-engine`), Psyche's
affective-computing and conversational stack, the Phase 178 Autonomous-Research
& Agentic-Scientist substrate, and Kalika's autonomous-research-agent and
computational-notebook infrastructure.

The remaining capability gates and their re-entry conditions are recorded in
[`phase-181-capability-audit.md`](./phase-181-capability-audit.md). That audit
is evidence for keeping the six tasks unchecked, not a substitute for completing
them.

**Core Pillars:**

1. **Neural Interfaces & Signal Intelligence (BCI)** — multimodal neural
   acquisition with sub-millisecond time-sync (LSL/XDF over EEG/MEG/ECoG/spikes/
   sEMG/fNIRS/fUS), real-time streaming signal processing (ICA, CSP, xDAWN,
   Riemannian/SPD-covariance methods), neural decoders and neural foundation
   models (POYO/NDT2/LaBraM-class), cross-session/cross-subject adaptation that
   removes daily recalibration, and closed-loop neuromodulation orchestration
   (adaptive DBS, RNS, tFUS, temporal-interference) with bidirectional
   read–write and sensory feedback.
2. **Computational & Systems Neuroscience** — spike sorting and image processing
   at acquisition scale (SpikeInterface/Kilosort 4, calcium/voltage pipelines),
   connectomics segmentation & versioned proofreading & petascale graph serving
   (flood-filling networks, CAVE, Neuroglancer/TensorStore), multi-scale
   simulation (NEST, NEURON/CoreNEURON, Arbor, Brian2 over the SONATA
   interchange), brain/neural foundation models, latent-dynamics and manifold
   analysis (LFADS, CEBRA, RSA≈CKA≈CCA), and **circuit/region digital twins with
   fail-loud uncertainty** (whole-brain emulation is treated as infeasible, not
   a goal).
3. **Clinical Psychology & Psychiatry** — a validated assessment engine (PHQ-9,
   GAD-7, PCL-5, C-SSRS) with computable DSM-5-TR / ICD-11 coding,
   measurement-based and collaborative care, digital phenotyping / passive
   sensing / JITAI, computational-psychiatry models (RDoC, HiTOP, RL/drift-
   diffusion/active-inference, circuit biotypes), regulated therapeutic content
   with anti-sycophancy guardrails, a clinician copilot/ambient scribe, and
   treatment-matching decision support — **all human-in-the-loop gated** and
   compliant with the 2025–2026 wave of AI-therapy law.
4. **Experiment Design & Autonomous Discovery** — a hypothesis engine
   (generate/debate/rank/evolve over the knowledge graph with graph-derived
   novelty and GNN-derived feasibility), a Bayesian optimal-experimental-design
   / adaptive-design optimizer (BOED, amortized DAD/iDAD, ADO/QUEST+, Bayesian
   adaptive trials, contextual-bandit/MRT/SMART JITAIs), a frame-precise
   experiment authoring & runtime layer with closed-loop control, subject/panel
   management, an IRB/consent & fail-closed AI-ethics gate & DSMB, BIDS-App and
   causal-inference analysis pipelines, and a preregistration & reproducibility
   ledger that makes multiverse analysis the default.
5. **Brain-Mind Knowledge & Evidence** — a Biolink-typed knowledge-graph store
   and ontology service (ingesting SPOKE/PrimeKG/Hetionet/Monarch/NeuroKG and
   hosting Cognitive Atlas, NIFSTD, Uberon, NeuroNames, NBO, MFOEM, MeSH, SNOMED
   CT, DSM-5-TR/ICD-11), **the canonical machine-readable RDoC ontology and the
   maintained DSM↔ICD-11↔MeSH↔SNOMED↔Cognitive-Atlas↔RDoC crosswalk that do not
   yet exist anywhere** (Phoebe's clearest greenfield to own), literature
   ingestion & claim/evidence extraction, living evidence synthesis, GraphRAG
   with KG-verified anti-hallucination, and a FAIR dataset catalog.

Two cross-cutting pillars bind these together:

- **Neuroethics, Governance & Regulatory Compliance** — neural-data governance
  to the Chile/Colorado/California/Montana/Connecticut neurorights laws & UNESCO
  2025 standard, HIPAA/GDPR, federated learning and differential privacy,
  neuroimaging defacing, W3C-PROV provenance, FDA SaMD lifecycle (510(k)/De
  Novo/PMA) with Predetermined Change Control Plans, bias/equity testing, and a
  crisis-safety backbone (988/Samaritans routing, suicidality escalation,
  jurisdiction-aware feature gating).
- **AI Breakthrough Engine** — the autonomous closed-loop neuroscientist that
  ties hypothesis → adaptive design → ethics gate → execution → analysis →
  theory update, specialized for brains and behaviour, with reliability
  guardrails (hallucination/fabrication detection) on every autonomous step.

**Technology Stack:**

- **TypeScript** for orchestration, APIs, contracts, dashboards, clinician/
  researcher consoles, and the knowledge/evidence services.
- **Rust** for the hard-real-time path that the rest of the platform cannot be:
  streaming signal processing and artifact rejection, the decode→stimulate
  closed loop (bounded-latency, fail-safe), neuromodulation safety state
  machines, and high-throughput connectome graph queries. GPU via `wgpu`.
- **C/C++** for simulation kernels and device DSP (CoreNEURON, Arbor backends,
  flood-filling-network inference, acquisition drivers).
- **Python** for ML and neuro/clinical pipelines: PyNWB/MatNWB, MNE-Python,
  SpikeInterface & Kilosort 4, NEST/NEURON/Arbor/Brian2, fMRIPrep/Nipype,
  DoWhy/causal-learn, Pyro (variational BOED), ADOpy, PsychoPy, and the neural-
  foundation-model training stack (POYO/NDT2/CEBRA/LaBraM lineages).
- **WASM** for the frame-precise browser experiment runtime (PsychoJS/PixiJS/
  WebGPU) and for bridging Rust DSP into TS clients.
- **PostgreSQL & TimescaleDB** for neural/behavioural time-series and EMA;
  **pgvector** for embeddings; **Neo4j / RDF triplestore** for the Biolink
  knowledge graph; **Redis** for real-time session state; **Kafka** for the
  experiment/clinical/neural event bus.
- **Lab Streaming Layer (LSL) & XDF** for multimodal time-sync; **NWB (HDF5 +
  Zarr) and BIDS** as the canonical data-at-rest formats; **Zarr / OME-Zarr +
  Neuroglancer-precomputed** for petascale imaging and connectomes.

**Distinction from Adjacent Domains:**

- **vs Iris** — Iris owns the multimodal human–computer _interface_, including
  the BCI device/HID layer (`libs/iris/bci/*`, `libs/iris/multimodal/bci/*` —
  apple-hid, intent-prediction, privacy-framework, neural-signal, bci-device).
  Phoebe **consumes** those device primitives and adds neuroscience-grade
  decoding, neural foundation models, closed-loop neuromodulation, and the
  clinical/research applications above. Iris is the input device; Phoebe is the
  science and medicine behind and atop it.
- **vs Aphrodite** — Aphrodite owns the consumer biometric engine, including
  `libs/aphrodite/biometric-engine/src/eeg/` for wellness/affect. Phoebe
  consumes Aphrodite's biosignal acquisition but owns clinical interpretation,
  neuroscience analysis, and regulated/research use. Aphrodite = consumer
  biometrics; Phoebe = clinical and research neuroscience.
- **vs Psyche** — Psyche owns affective computing and digital humans (emotion
  recognition, avatars, real-time conversational AI). Phoebe consumes Psyche's
  affect/sentiment signals for digital phenotyping and uses its conversational
  stack to _deliver_ therapeutic content, but owns the clinical evidence base,
  validated assessment, and regulated therapeutics. Psyche is the face and
  voice; Phoebe is the clinical mind that governs what is safe to say.
- **vs Phase 178 (Autonomous Research & Agentic Scientist)** — Phase 178 is the
  horizontal autonomous-scientist substrate (Sakana AI Scientist v2, Google
  Co-Scientist, deep-research agents, physical-lab autonomy, observability/
  ledger). Phoebe is the **brain/behavioural vertical on top of it**: BOED/ADO
  adaptive design, IRB/consent & fail-closed AI-ethics gating, neuro/behavioural
  wet-lab and online-experiment execution, BIDS-App analysis, and theory update
  into a neuroscience knowledge graph. Phoebe does not re-implement the generic
  engine; it specializes and constrains it for living brains and human subjects.
- **vs Kalika** — Kalika owns mathematics/physics/materials research agents, the
  CAS engine, and computational notebooks. Phoebe reuses Kalika's
  autonomous-research-agent and notebook infrastructure but owns the neuro/psych
  domain, its data standards, and its human-subjects constraints.
- **vs Lilith / Tara** — Lilith and Tara own contemplative wellness and
  meditation (consumer, non-regulated; see `libs/meditation/*`). Phoebe owns
  clinical psychology and psychiatry (measurement-based, clinician-in-the-loop,
  FDA/UKCA-gated). The boundary is the clinical line: a wellness practice is
  Lilith/Tara; a validated diagnostic or therapeutic with a clinician in the
  loop and a regulatory pathway is Phoebe.
- **vs Mnemosyne / Nous** — Mnemosyne provides memory infrastructure and Nous
  provides the ML platform; Phoebe consumes both. Phoebe studies _biological_
  memory and cognition; it does not own the platform's artificial memory or
  model-serving substrate.

---

### 181.1 Domain Foundation & Infrastructure

#### 181.1.1 Library Structure Setup

- [x] **181.1.1.1** Create `libs/phoebe/` root with domain README, ownership
      boundaries, and the planned-package map; add `@phoebe/*` path mappings to
      `tsconfig.base.json` and register projects with Nx.
- [x] **181.1.1.2** Create `libs/phoebe/core/` — domain primitives, entities,
      enums, state machines, and the shared dimensional (RDoC/HiTOP) model.
- [x] **181.1.1.3** Create `libs/phoebe/neural-io/` — multimodal neural
      acquisition and LSL/XDF time-sync.
- [x] **181.1.1.4** Create `libs/phoebe/signal/` — real-time streaming signal
      processing (Rust hot path & TS/Python bindings).
- [x] **181.1.1.5** Create `libs/phoebe/decoding/` — decoder runtime, model
      registry, and neural foundation models.
- [x] **181.1.1.6** Create `libs/phoebe/neuromodulation/` — closed-loop
      stimulation orchestration and bidirectional read–write.
- [x] **181.1.1.7** Create `libs/phoebe/connectomics/` — EM segmentation,
      versioned proofreading, and petascale graph serving.
- [x] **181.1.1.8** Create `libs/phoebe/simulation/` — multi-scale neural
      simulation engines over SONATA.
- [x] **181.1.1.9** Create `libs/phoebe/brain-models/` — brain/neural foundation
      models and circuit/region digital twins.
- [x] **181.1.1.10** Create `libs/phoebe/neuro-analysis/` — spike sorting,
      imaging pipelines, latent-dynamics and manifold analysis.
- [x] **181.1.1.11** Create `libs/phoebe/assessment/` — validated psychometric
      instruments and DSM-5-TR/ICD-11 coding.
- [x] **181.1.1.12** Create `libs/phoebe/mbc/` — measurement-based and
      collaborative care.
- [x] **181.1.1.13** Create `libs/phoebe/phenotyping/` — digital phenotyping,
      passive sensing, and JITAI.
- [x] **181.1.1.14** Create `libs/phoebe/comp-psychiatry/` — RDoC/HiTOP models,
      computational models, and biotype/treatment-matching.
- [x] **181.1.1.15** Create `libs/phoebe/therapeutics/` — therapeutic content,
      anti-sycophancy guardrails, and clinician copilot.
- [x] **181.1.1.16** Create `libs/phoebe/hypothesis/` — KG-grounded hypothesis
      generation and scoring.
- [x] **181.1.1.17** Create `libs/phoebe/design/` — optimal experimental design
      and adaptive-trial/JITAI optimizers.
- [x] **181.1.1.18** Create `libs/phoebe/experiment-runtime/` — experiment
      authoring, frame-precise runtime, and closed-loop control.
- [x] **181.1.1.19** Create `libs/phoebe/subjects/` — subject/panel management
      and data-quality firewall.
- [x] **181.1.1.20** Create `libs/phoebe/analysis/` — BIDS-App pipelines and
      causal inference.
- [x] **181.1.1.21** Create `libs/phoebe/reproducibility/` — preregistration,
      multiverse, and the provenance ledger.
- [x] **181.1.1.22** Create `libs/phoebe/knowledge-graph/` — Biolink KG store
      and ontology service.
- [x] **181.1.1.23** Create `libs/phoebe/literature/` — literature ingestion and
      claim/evidence extraction.
- [x] **181.1.1.24** Create `libs/phoebe/evidence-synthesis/` — living
      systematic reviews and GraphRAG.
- [x] **181.1.1.25** Create `libs/phoebe/datasets/` — FAIR dataset catalog and
      NWB/BIDS I/O connectors.
- [x] **181.1.1.26** Create `libs/phoebe/governance/` — neural-data governance,
      neurorights, privacy, and provenance.
- [x] **181.1.1.27** Create `libs/phoebe/regulatory/` — FDA SaMD lifecycle and
      validation harness.
- [x] **181.1.1.28** Create `libs/phoebe/safety/` — crisis-safety and compliance
      backbone.
- [x] **181.1.1.29** Create `libs/phoebe/ai/` — the autonomous closed-loop
      neuroscientist (AI breakthrough engine).
- [x] **181.1.1.30** Create `libs/phoebe/apps/` — researcher/clinician/control-
      room/participant application suite.
- [x] **181.1.1.31** Create `libs/phoebe/integration/` — cross-domain hub.
- [x] **181.1.1.32** Create `libs/contracts/phoebe/` (`@phoebe/contracts`) — Zod
      schemas and cross-domain DTOs for every contract Phoebe exposes/consumes.

#### 181.1.2 Core Data Model & Persistence

- [x] **181.1.2.1** Provision the `phoebe` PostgreSQL database (per
      domain-isolation convention) with TimescaleDB hypertables for neural and
      behavioural time-series and `pgvector` for embeddings.
- [x] **181.1.2.2** Stand up the knowledge-graph store (Neo4j or RDF
      triplestore) with the **Biolink model** as the schema layer.
- [x] **181.1.2.3** Provision object storage (MinIO/S3) with **Zarr/OME-Zarr +
      Neuroglancer-precomputed** layouts for petascale imaging/connectomes and
      **NWB (HDF5 & Zarr)** for electrophysiology.
- [x] **181.1.2.4** Define the canonical entity set in `@phoebe/core`: Subject/
      Participant, Study, Protocol, Session, Recording, Signal/Channel,
      Stimulus, Trial, ConsentRecord, Assessment, Measurement, Hypothesis,
      Experiment, Claim, Dataset, OntologyTermRef — with explicit state
      machines.
- [x] **181.1.2.5** Implement the dimensional clinical model: RDoC matrix (6
      domains × 7 units of analysis) and HiTOP spectra & p-factor, as
      first-class, queryable structures (not free text).
- [x] **181.1.2.6** Define the LSL/XDF stream descriptor and NWB/BIDS object
      mappings so every recording is born standards-conformant.

#### 181.1.3 API Gateway & Service Topology

- [x] **181.1.3.1** Implement the Phoebe API gateway (TypeScript) with
      role-scoped access (researcher, clinician, participant, admin, autonomous
      agent) and per-role capability tokens.
- [x] **181.1.3.2** Define the service topology: real-time (Rust) neural/decode/
      stim services, batch (Python) pipeline services, knowledge/evidence
      services, and clinical services — with the Kafka event bus between them.
- [x] **181.1.3.3** Wire OpenAPI & `@phoebe/contracts` so every endpoint is
      contract-validated; publish the Phoebe contracts other domains import.
- [x] **181.1.3.4** Implement a global **fail-loud uncertainty** convention:
      every inference/decode/prediction response carries calibrated confidence
      and an explicit `not_configured` / `insufficient_evidence` seam rather
      than fabricating a result.

---

### 181.2 @phoebe/core — Domain Primitives

#### 181.2.1 Neural & Signal Types

- [x] **181.2.1.1** Define typed neural-signal primitives spanning modality,
      sampling rate, channel geometry, and reference scheme for EEG, MEG, ECoG,
      intracortical spikes, sEMG, fNIRS, and fUS.
- [x] **181.2.1.2** Define the device-capability descriptor (channel count,
      bandwidth, latency budget, invasiveness class) and a modality-to-bandwidth
      ceiling model (e.g., ~50–63 bits/s non-invasive vs intracortical 8–10
      bits/s cursor control) used to validate use-case feasibility.
- [x] **181.2.1.3** Define provenance and lineage types that attach to every
      sample, derivation, and claim (W3C PROV-aligned).

#### 181.2.2 Clinical & Experimental Types

- [x] **181.2.2.1** Define the assessment/measurement types with instrument
      versioning, scoring bands, and a hard-trigger flag for crisis items.
- [x] **181.2.2.2** Define Study/Protocol/Hypothesis/Experiment types with a
      preregistration lock and an IRB-approval state machine.
- [x] **181.2.2.3** Define ConsentRecord with broad/dynamic consent variants,
      withdrawal, and neural-data-class tagging.
- [x] **181.2.2.4** Write domain-correctness tests for every state machine
      (legal/illegal transitions for consent, IRB approval, preregistration
      lock, and crisis escalation).

---

### 181.3 @phoebe/neural-io — Multimodal Acquisition & Time-Sync

#### 181.3.1 Acquisition & Device Abstraction

- [x] **181.3.1.1** Implement a board-agnostic acquisition abstraction
      (BrainFlow pattern) and adapters that **consume Iris's `@iris/bci-*`
      device layer and Aphrodite's biometric engine** rather than
      re-implementing drivers.
- [x] **181.3.1.2** Implement Neuropixels 1.0/2.0/Ultra and high-channel (Argo/
      Connexus-class) ingestion adapters writing directly to NWB, with 30 kHz
      streaming buffers.
  - File: `libs/phoebe/neural-io/src/neuropixels.ts` (+ `SampleRingBuffer` in
    `acquisition.ts`, PyNWB backend `python/neuropixels_nwb.py`)
  - Acceptance: a 384-channel 30 kHz stream is buffered without sample loss and
    persisted as a valid NWB `ElectricalSeries`. **Verified:** ring buffer drops
    0/30000 samples; PyNWB writes a Neuropixels `ElectricalSeries` (int16,
    2-column staggered geometry) that passes `pynwb.validate`, round-trips, and
    whose checksum matches the buffered stream bit-for-bit.
- [x] **181.3.1.3** Implement ScanImage/light-beads-microscopy and GEVI voltage
      adapters emitting OME-Zarr.
  - File: `libs/phoebe/neural-io/src/imaging.ts`
  - **Verified:** a pure-TS Zarr v2 + OME-NGFF 0.4 writer round-trips ScanImage
    (TZYX uint16) and GEVI (TYX float32) stacks pixel-exact and its output is
    read back pixel-exact by zarr-python 3.2.1 (external spec-compliance
    cross-check).
- [x] **181.3.1.4** Implement sEMG (Meta-Neural-Band-class, 16-ch @ 2 kHz) and
      fNIRS/fUS ingestion adapters.

#### 181.3.2 Lab Streaming Layer & Synchronization

- [x] **181.3.2.1** Integrate **Lab Streaming Layer** (pylsl & a Rust client) as
      the multimodal transport, with NTP-style offset/RTT clock filtering.
  - Acceptance: cross-stream synchronization jitter is sub-millisecond (≈≤200 µs
    SD) across EEG & eye-tracking & IMU & marker streams.
- [x] **181.3.2.2** Implement **XDF** recording and replay for deterministic
      offline re-runs and decoder regression testing.
- [x] **181.3.2.3** Implement signal-quality and impedance telemetry with a
      per-channel health model feeding the monitoring dashboards.

---

### 181.4 @phoebe/signal — Real-Time Streaming Signal Processing

#### 181.4.1 Filtering & Artifact Rejection

- [x] **181.4.1.1** Implement the streaming DSP DAG in **Rust** (Timeflux/
      NeuroPype pattern): re-referencing, band-pass/notch, resampling, epoching
      — with a bounded per-window latency budget exposed as an SLA.
- [x] **181.4.1.2** Implement **ICA** artifact removal (Picard/Infomax) with
      ICLabel-style component classification for EOG/EMG/ECG rejection.
- [x] **181.4.1.3** Implement online drift/impedance-change detection that flags
      when recalibration or the cross-subject adapter is required.

#### 181.4.2 Feature Extraction

- [x] **181.4.2.1** Implement **Common Spatial Patterns** (generalized
      eigendecomposition of class covariances) and **xDAWN** ERP spatial
      filters.
- [x] **181.4.2.2** Implement **Riemannian / SPD-covariance** featurization
      (pyRiemann-equivalent in Rust): tangent-space projection, MDM classifier,
      and Riemannian Procrustes alignment.
  - Acceptance: on a public motor-imagery set, the Riemannian MDM pipeline
    reproduces published accuracy within tolerance and beats a CSP+LDA baseline
    on cross-session transfer.
- [x] **181.4.2.3** Implement streaming spike binning and band-power features
      for intracortical decoders.

---

### 181.5 @phoebe/decoding — Decoders & Neural Foundation Models

#### 181.5.1 Decoder Runtime & Model Registry

- [x] **181.5.1.1** Implement a hot-swappable decoder runtime supporting Kalman,
      LSTM/RNN, and transformer decoders behind a uniform interface with a
      bounded inference-latency contract.
- [x] **181.5.1.2** Implement the model registry with versioning, per-subject
      calibration artifacts, and edge/on-device serving.
- [x] **181.5.1.3** Implement an **LLM-coupled language-model decoding** stage
      for Brain-to-Text (phoneme/word logits → LLM rescoring), reproducing the
      Brain-to-Text-benchmark ensemble-merge pattern.

#### 181.5.2 Neural Foundation Models

- [ ] **181.5.2.1** Spike-level foundation models (POYO/POYO+ tokenization,
      Perceiver backbone) with cross-session stitching. Split 2026-09-18: the
      code/serving half is actionable; the training half is budget-gated.
  - [ ] **181.5.2.1.a** Implement the tokenizer, the Perceiver-style backbone
        architecture and the inference/serving path in the Phoebe libraries,
        exercised on synthetic spike trains. Verify: a spec tokenizes a fixture
        multi-unit spike recording, runs a forward pass and asserts output
        shape, determinism, and that cross-session stitching aligns two fixture
        sessions.
  - [ ] **181.5.2.1.b** Train the spike foundation model on real neural
        recordings. Needs an owner decision on a compute and data budget (stated
        2026-09-18). `blocked:governance`
- [ ] **181.5.2.2** Masked-autoencoding population models (NDT2/NEDS) and
      EEG/SEEG foundation models (LaBraM neural-spectrum tokenizer). Split
      2026-09-18: the code/serving half is actionable; the training half is
      budget-gated.
  - [ ] **181.5.2.2.a** Implement the LaBraM neural-spectrum tokenizer, the
        masked-autoencoder model architecture and its inference path, tested on
        synthetic EEG/SEEG. Verify: a spec tokenizes a fixture EEG segment, runs
        masked reconstruction and asserts the tokenizer round-trips and the
        model output shape.
  - [ ] **181.5.2.2.b** Train the population/EEG foundation models on real
        recordings. Needs an owner decision on a compute and data budget (stated
        2026-09-18). `blocked:governance`
- [ ] **181.5.2.3** fMRI/EEG-to-image path (MindEye2-style shared-subject latent
      → CLIP → diffusion) as a research capability: assemble the pipeline from
      PUBLISHED pretrained components (a pretrained CLIP encoder and an open
      diffusion model, run on CPU; install-first, record versions, park only
      with a named failed install attempt) plus a small trainable brain→CLIP
      ridge/MLP adapter. Verify: a spec runs the pipeline end-to-end on a
      fixture (open NSD-style sample) and asserts a reconstructed image is
      produced and that the adapter improves CLIP-space cosine similarity over a
      random baseline. Training the adapter at scale on the full dataset is a
      budget decision, but the pipeline and a small-fit adapter are actionable
      here.
- [x] **181.5.2.4** Establish a benchmarking harness (WER, bits/s, co-bps, ITR;
      NLB/FALCON/Brain-to-Text style) with held-out cross-session/subject
      splits.
  - Acceptance: leaderboards are reproducible and a decoder that returns random
    or fixed outputs scores at chance — i.e., the metrics actually test
    decoding, not data flow.

#### 181.5.3 Cross-Session / Cross-Subject Adaptation

- [x] **181.5.3.1** Implement Euclidean/Riemannian alignment and manifold
      alignment for training-free cross-subject transfer.
- [x] **181.5.3.2** Implement online recalibration and meta-learning to attack
      session-to-session drift (the central usability blocker).

---

### 181.6 @phoebe/neuromodulation — Closed-Loop Stimulation & Read–Write

#### 181.6.1 Adaptive Stimulation Orchestration

- [x] **181.6.1.1** Implement a hard-real-time decode→stimulate loop in **Rust**
      with explicit deadlines, watchdogs, and fail-safe stop.
- [x] **181.6.1.2** Implement adaptive-DBS policy primitives (beta-band LFP
      sensing → amplitude adjustment, BrainSense-style) and responsive-
      neurostimulation detect-and-stimulate state machines (RNS-style).
  - Acceptance: a beta-driven aDBS policy modulates a simulated stimulator
    within the latency deadline and logs every state transition to an
    append-only ledger.
- [x] **181.6.1.3** Implement non-invasive neuromodulation control interfaces
      for tFUS/LIFU and temporal-interference (envelope-frequency) stimulation,
      including target/beam parameterization.

#### 181.6.2 Bidirectional Read–Write & Sensory Feedback

- [x] **181.6.2.1** Implement biomimetic ICMS sensory-feedback encoding
      (edge/orientation/motion patterns) for the read–write loop.
- [x] **181.6.2.2** Implement a thermal/power/charge-density safety governor
      (≤0.5 °C cortical-heat constraint, charge-per-phase limits) that hard-caps
      stimulation regardless of policy output.
- [x] **181.6.2.3** Implement the append-only stimulation incident/audit log
      with manual-override and safety-stop verification tests.

---

### 181.7 @phoebe/connectomics — Segmentation, Proofreading & Graph Serving

#### 181.7.1 Segmentation & Proofreading

- [ ] **181.7.1.1** Flood-filling-network (FFN) inference for EM neurite
      segmentation with tiled, resumable processing: this is INFERENCE, not
      training — use a published FFN model. Install the runtime (record the
      version; park only with a named failed install attempt) and run tiled,
      resumable segmentation on the CPU (GPU on the Mac/lavapipe where
      available). Verify: a spec segments a fixture EM sub-volume, asserts the
      tiling covers the volume with the configured overlap, that a resumed run
      reproduces the un-interrupted result, and reports the segmentation against
      a small labelled fixture.
- [x] **181.7.1.2** Implement ML-driven merge/split error detection to automate
      the proofreading cost center.
- [x] **181.7.1.3** Implement **CAVE-style** versioned, distributed annotation
      (continuous versioning, edit history, multi-user proofreading).

#### 181.7.2 Petascale Serving & Query

- [x] **181.7.2.1** Implement Neuroglancer-precomputed / TensorStore serving for
      petabyte-class volumes with streaming, no-download access.
- [x] **181.7.2.2** Implement a synapse-graph store and query API scaling toward
      10⁹–10¹² edges, with a cross-dataset schema spanning FlyWire/MICrONS/H01.
  - Acceptance: a connectivity query (e.g., all post-synaptic partners of a cell
    class within a region) returns correct results against a FlyWire-derived
    fixture.
- [x] **181.7.2.3** Implement function↔structure fusion linking activity
      recordings to the connectome (the MICrONS pattern).

---

### 181.8 @phoebe/simulation — Multi-Scale Neural Simulation

#### 181.8.1 Engine Backends & Interchange

- [x] **181.8.1.1** Implement managed backends for **NEST** (point/spiking),
      **NEURON/CoreNEURON** (biophysical), **Arbor** (GPU morphological), and
      **Brian2/GeNN**, behind one job interface.
- [x] **181.8.1.2** Adopt **SONATA** as the model-interchange format so a model
      can be ported across backends; implement a BMTK-style build/simulate/
      analyze flow.
  - Acceptance: a SONATA network runs on at least two backends and produces
    matching spike rasters within numerical tolerance.
- [x] **181.8.1.3** Implement **Arbor↔TVB** multi-scale co-simulation (detailed
      circuit embedded in a whole-brain neural-mass model).

#### 181.8.2 Scheduling & Scale

- [x] **181.8.2.1** Implement GPU/HPC job scheduling with memory checkpointing
      and headroom guards for large simulations.
- [x] **181.8.2.2** Integrate Open Brain Institute / Allen (BMTK, SONATA) open
      reconstructions as starting assets rather than building circuits cold.

---

### 181.9 @phoebe/brain-models — Foundation Models & Digital Twins

#### 181.9.1 Brain Foundation Models

- [ ] **181.9.1.1** fMRI foundation models (BrainLM-style MAE) and multi-modal
      neural foundation models, with a hosted model zoo. Split 2026-09-18: the
      code/serving half is actionable; the training half is budget-gated.
  - [ ] **181.9.1.1.a** Build the model-zoo serving scaffold in the Phoebe
        libraries: a registry of model cards (architecture, inputs, checksum), a
        loader, and an inference endpoint that serves a registered model on CPU.
        Verify: a spec registers a fixture (small) model, loads it and serves an
        inference, and rejects a card whose checksum does not match.
  - [ ] **181.9.1.1.b** Train the BrainLM-style fMRI MAE and the multi-modal
        models. Needs an owner decision on a compute and data budget (stated
        2026-09-18). `blocked:governance`
- [x] **181.9.1.2** Implement topographic priors (TopoLoss) as an optional
      training objective for biologically-plausible representations.

#### 181.9.2 Circuit/Region Digital Twins

- [ ] **181.9.2.1** Function→structure digital twins (mouse-visual-cortex-FM /
      MICrONS pattern) predicting cell type and connectivity from function.
      Needs an owner decision on a compute budget to train the twin, and the
      paired functional+structural data (the MICrONS dataset is openly available
      but must be fetched and stored) (stated 2026-09-18). `blocked:governance`
      `blocked:corpus`
- [x] **181.9.2.2** Implement in-silico optogenetics / most-exciting-input (MEI,
      EGG-diffusion) stimulus synthesis for closed-loop in-silico→in-vivo
      design.
- [x] **181.9.2.3** Implement patient-specific virtual-brain-twin pipelines
      (TVB-style) that **report calibrated uncertainty and refuse to
      overstate**; whole-brain emulation is explicitly out of scope and
      documented as infeasible.
  - Acceptance: twin outputs always carry uncertainty bounds; a request beyond
    validated scope returns an explicit `out_of_validated_scope` rather than a
    fabricated prediction.

---

### 181.10 @phoebe/neuro-analysis — Sorting, Imaging & Latent Dynamics

#### 181.10.1 Spike Sorting & Image Processing

- [x] **181.10.1.1** Integrate **SpikeInterface** as the orchestration core
      wrapping **Kilosort 4** / MountainSort5 with drift correction and QC
      metrics; add a streaming/edge sorter for closed-loop use.
- [x] **181.10.1.2** Implement calcium/voltage image pipelines (motion
      correction, segmentation, dF/F) at acquisition speed with OME-Zarr output.
- [x] **181.10.1.3** Build a realistic-simulator & ground-truth benchmark
      harness for sorter accuracy.

#### 181.10.2 Latent Dynamics & Representation

- [x] **181.10.2.1** Implement latent-variable models: **LFADS/AutoLFADS**,
      GPFA, pi-VAE, and **CEBRA** (consistent cross-subject/session embeddings).
- [x] **181.10.2.2** Implement manifold-native APIs (project/align/decode across
      sessions) and a unified **RSA≈CKA≈CCA** representation-comparison module
      (bias-corrected).
- [x] **181.10.2.3** Report **identifiability/degeneracy** as a first-class
      quantity (per the 3,400-RNN solution-degeneracy result) on any
      mechanism-recovery analysis.
  - Acceptance: latent-model fits include a degeneracy/identifiability report;
    decoding accuracy is validated against a known-generative-model fixture, not
    asserted by truthiness.

---

### 181.11 @phoebe/assessment — Validated Psychometric Instruments

#### 181.11.1 Instruments & Scoring

- [x] **181.11.1.1** Implement **PHQ-9** (0–27, bands 0-4/5-9/10-14/15-19/20-27,
      ≥10 cutoff) with exact scoring and versioning.
- [x] **181.11.1.2** Implement **GAD-7** (0–21, ≥10 cutoff) and **PCL-5**
      (20×0–4, 0–80, DSM-5 diagnostic algorithm ≥1 B / ≥1 C / ≥2 D / ≥2 E rated
      ≥2, cutoff 31–33).
- [x] **181.11.1.3** Implement **C-SSRS** (ideation severity 1–5, intensity,
      behaviour, lethality) and **PHQ-9 item-9** handling.
  - Acceptance: a C-SSRS or PHQ-9 item-9 positive **hard-triggers** the
    `@phoebe/safety` crisis module and a clinician alert — never an autonomous
    reassurance response. Scoring is unit-tested against published worked
    examples.

#### 181.11.2 Computable Nosology

- [x] **181.11.2.1** Implement **DSM-5-TR** and **ICD-11 Chapter 06** computable
      coding via the ICD-11 Foundation API & post-coordination.
- [x] **181.11.2.2** Map every instrument result to the dimensional RDoC/HiTOP
      model and to nosology codes through the `@phoebe/knowledge-graph`
      crosswalk.

---

### 181.12 @phoebe/mbc — Measurement-Based & Collaborative Care

#### 181.12.1 Measurement-Based Care

- [x] **181.12.1.1** Implement scheduled repeat administration, symptom-
      trajectory dashboards, and treat-to-target alerting (Joint Commission
      CTS.03.01.09 aligned).
- [x] **181.12.1.2** Implement the **Collaborative Care Model** caseload
      registry and stepped-care review (IMPACT-trial pattern).
  - Acceptance: a registry review surfaces patients not improving on schedule
    and computes correct response/remission status from instrument trajectories.

---

### 181.13 @phoebe/phenotyping — Digital Phenotyping & JITAI

#### 181.13.1 Passive Sensing & EMA

- [x] **181.13.1.1** Implement an EMA engine (configurable cadence, compliance
      tracking) and a passive-sensing pipeline (sleep, mobility/GPS entropy,
      typing, voice acoustics) on the Beiwe/mindLAMP pattern.
- [x] **181.13.1.2** Integrate **Psyche** affect/sentiment signals and implement
      speech/voice biomarkers (acoustic & semantic-coherence) as
      decision-support features.
- [x] **181.13.1.3** Implement relapse/anomaly detection (CrossCheck/SHARP
      pattern) that emits clinician alerts with **explicit, calibrated
      uncertainty** (effect sizes are small; surface that honestly).

#### 181.13.2 Just-In-Time Adaptive Interventions

- [x] **181.13.2.1** Implement a JITAI engine using **contextual bandits /
      Thompson sampling** (HeartSteps II pattern) with nightly re-fit.
- [x] **181.13.2.2** Implement micro-randomized-trial (MRT) instrumentation so
      JITAI components are causally evaluable.
  - Acceptance: phenotyping outputs are typed as decision-support signal, never
    autonomous diagnosis; the privacy path anonymizes on-device by default.

---

### 181.14 @phoebe/comp-psychiatry — Computational Psychiatry & Treatment Matching

#### 181.14.1 Computational Models

- [x] **181.14.1.1** Implement reinforcement-learning (reward-sensitivity /
      RPE), drift-diffusion, and model-based/model-free control fits as
      transdiagnostic markers.
- [x] **181.14.1.2** Implement active-inference / predictive-coding analyses as
      a **lens** (documented as contested, not a validated mechanism).

#### 181.14.2 Biomarkers & Treatment Matching

- [x] **181.14.2.1** Implement ingestion of circuit biotypes (Stanford six-
      biotype pattern) and EEG antidepressant-response markers (rACC theta).
- [x] **181.14.2.2** Implement treatment-matching decision support routing to
      pharmacotherapy / esketamine / TMS-SAINT / neuromodulation /
      psychedelic-AT trials.
  - Acceptance: outputs are **research-use-only and advisory to a clinician**;
    the module refuses autonomous prescribing and records that ML suicide
    prediction (e.g., VA REACH VET PPV ≈0.05%) is too inaccurate to drive
    automated decisions.

---

### 181.15 @phoebe/therapeutics — Therapeutic Content & Clinician Copilot

#### 181.15.1 Therapeutic Content & Guardrails

- [x] **181.15.1.1** Implement modality-specific (CBT/DBT/ACT/MI) retrieval-
      grounded therapeutic content delivered through the **Psyche**
      conversational stack.
- [x] **181.15.1.2** Implement **anti-sycophancy guardrails** that challenge
      rather than confirm delusional/false beliefs, with an adversarial test
      suite for the documented failure mode.
- [x] **181.15.1.3** Implement crisis-detection on every turn, escalating to
      `@phoebe/safety` (988/Samaritans) and a human.
  - Acceptance: autonomous therapeutic conversation is **gated behind clinician
    supervision and jurisdiction-aware feature flags** (Illinois WOPR / Nevada
    AB 406 / Utah HB 452); the system never makes therapeutic decisions
    unsupervised and surfaces mandatory AI-disclosure.

#### 181.15.2 Clinician Copilot & Ambient Scribe

- [x] **181.15.2.1** Implement a behavioural-health-tuned ambient scribe
      (SOAP/GIRP/BIRP/DAP) with DSM-5-TR/ICD-11 auto-coding and risk
      summarization.
- [x] **181.15.2.2** Require clinician review/sign-off on every note, plan, and
      risk flag (unsupervised AI treatment plans are prohibited).

---

### 181.16 @phoebe/hypothesis — KG-Grounded Hypothesis Generation

#### 181.16.1 Multi-Agent Generation

- [x] **181.16.1.1** Implement a generate/debate/rank/evolve loop (Google
      Co-Scientist pattern) over the `@phoebe/knowledge-graph`, **built on the
      Phase 178 substrate and Kalika research agents** rather than
      re-implementing them.
- [x] **181.16.1.2** Implement an Elo tournament for pairwise hypothesis ranking
      with test-time-compute scaling.

#### 181.16.2 Novelty & Feasibility Scoring

- [x] **181.16.2.1** Implement **graph-derived novelty** = KG distance +
      SemMedDB predication absence (not subjective LLM rating).
- [x] **181.16.2.2** Implement **GNN-derived feasibility** (TxGNN/PROTON-style
      link-prediction confidence) emitting explainable multi-hop paths.
  - Acceptance: a known repurposing result (e.g., a documented compound→disease
    link) scores high feasibility with a correct, inspectable evidence path; a
    nonsensical link scores low.

---

### 181.17 @phoebe/design — Optimal Experimental Design & Adaptive Trials

#### 181.17.1 Bayesian Optimal Experimental Design

- [x] **181.17.1.1** Implement a BOED core maximizing **Expected Information
      Gain** (variational/ACE estimators, Pyro-backed).
- [x] **181.17.1.2** Implement amortized **DAD/iDAD/Step-DAD** policies (train
      offline, design in milliseconds) for real-time adaptive psychophysics.
  - Acceptance: an amortized policy produces a next-design decision in
    sub-second wall-clock and beats a fixed/random design on cumulative EIG.

#### 181.17.2 Adaptive Design in Psychology & Psychophysics

- [x] **181.17.2.1** Implement **ADO** (ADOpy pattern: psychometric function,
      delay discounting, choice-under-risk) and **QUEST+/Psi** adaptive
      staircases.
- [x] **181.17.2.2** Reproduce the ADO efficiency result (delay-discounting
      ≥0.95 reliability in 10–20 trials) on a simulated participant as a
      regression test.

#### 181.17.3 Adaptive Clinical Trials & Bandit Interventions

- [x] **181.17.3.1** Implement Bayesian adaptive-trial primitives: response-
      adaptive randomization, group-sequential boundaries (O'Brien-Fleming/
      Pocock/Haybittle-Peto), BOIN/CRM dose-finding, and predictive-probability
      futility.
- [x] **181.17.3.2** Implement master-protocol support
      (platform/basket/umbrella, I-SPY 2 / GBM AGILE graduation thresholds) with
      operating-characteristic simulation (FACTS/East pattern, Type-I control
      enforced).
- [x] **181.17.3.3** Implement SMART designs and offline-RL DTR pre-training
      (EpiCare benchmark) for dynamic treatment regimes.

---

### 181.18 @phoebe/experiment-runtime — Authoring, Runtime & Closed-Loop Control

#### 181.18.1 Authoring & Frame-Precise Runtime

- [x] **181.18.1.1** Implement a Builder GUI (PsychoPy/lab.js pattern) compiling
      to a frame-precise browser runtime (PsychoJS/PixiJS/**WebGPU**, WASM) and
      a native lab runtime, with a plugin architecture (jsPsych pattern).
- [x] **181.18.1.2** Implement timing instrumentation and calibration targeting
      sub-millisecond lab precision and characterizing the macOS ~1-frame visual
      onset delay.
  - Acceptance: a timing test reports measured stimulus-onset/response variance
    and flags configurations that exceed the precision budget.

#### 181.18.2 Closed-Loop & Robotic Execution

- [x] **181.18.2.1** Implement a closed-loop layer over **LSL** for brain-state-
      dependent stimulation (e.g., mu-rhythm-phase-triggered TMS, real-time fMRI
      neurofeedback).
- [x] **181.18.2.2** Implement robotic/wet-lab execution backends: **Opentrons**
      Python Protocol API, **Emerald Cloud Lab / Strateos** APIs, automated
      patch-clamp, and **DeepLabCut/SLEAP/Keypoint-MoSeq** behavioural rigs.

---

### 181.19 @phoebe/subjects — Subject & Panel Management

#### 181.19.1 Recruitment & Data Quality

- [x] **181.19.1.1** Implement connectors to **Prolific / CloudResearch / MTurk
      / Gorilla / SONA** with per-panel quality metadata.
- [x] **181.19.1.2** Implement the data-quality firewall: attention/IMC checks,
      IP/geo uniqueness, bot honeypots, and **LLM-agent contamination
      detection** with human-verified attestation.
  - Acceptance: a simulated bot/LLM respondent that passes naive attention
    checks is still flagged by the adversarial layer.

#### 181.19.2 Allocation & Eligibility

- [x] **181.19.2.1** Implement randomization/allocation services and
      longitudinal subject tracking with consent-state gating.
- [x] **181.19.2.2** Implement eligibility/patient↔trial matching (TrialGPT
      pattern) as clinician-reviewed decision support.

---

### 181.20 @phoebe/analysis — Pipelines & Causal Inference

#### 181.20.1 Neuro/Behavioural Pipelines

- [x] **181.20.1.1** Implement containerized **BIDS-App** runtimes (fMRIPrep/
      Nipype; FSL/SPM/AFNI) and **MNE-Python**/EEGLAB pipelines, orchestrated
      via Nextflow/Snakemake/CWL.
- [x] **181.20.1.2** Enforce post-Eklund multiple-comparison correction
      (permutation/TFCE/voxel-FWE/FDR) as a non-optional gate on any
      cluster-inference result.
- [x] **181.20.1.3** Implement mixed-effects modelling (lme4/brms) with
      maximal-vs-parsimonious random-effects guidance.

#### 181.20.2 Causal Inference

- [x] **181.20.2.1** Implement causal discovery (PC/FCI/GES/LiNGAM/NOTEARS) and
      a **DoWhy/causal-learn** model→identify→estimate→**refute** flow.
- [x] **181.20.2.2** Implement IV/Mendelian-randomization, mediation
      (counterfactual NDE/NIE), and target-trial emulation.
  - Acceptance: the refutation step runs before any effect is reported; a known
    confounded fixture is correctly flagged by a placebo/refutation test.

---

### 181.21 @phoebe/reproducibility — Preregistration, Multiverse & Provenance

#### 181.21.1 Preregistration & Multiverse

- [x] **181.21.1.1** Implement machine-readable **auto-preregistration**
      (locked, timestamped hypotheses & power analysis (G\*Power/simr) +
      analysis DAG).
- [x] **181.21.1.2** Make **multiverse / specification-curve** analysis a
      default execution mode (enumerate defensible pipelines by construction).
- [x] **181.21.1.3** Implement preregistration-vs-execution **auto-diff** that
      flags undisclosed researcher degrees of freedom.
  - Acceptance: an analysis that deviates from its locked preregistration is
    automatically flagged with the specific divergence.

#### 181.21.2 Provenance Ledger

- [x] **181.21.2.1** Implement an end-to-end provenance graph (DataLad/`rerun`
      pattern, W3C PROV / RO-Crate) from stimulus → raw data → analysis → figure
      with one-command recompute.
- [x] **181.21.2.2** Implement FAIR/BIDS-conformant export and dataset DOIs.

---

### 181.22 @phoebe/knowledge-graph — Biolink KG & Ontology Service

#### 181.22.1 Graph Store & Ingestion

- [x] **181.22.1.1** Implement a **Biolink-model**-typed graph store ingesting
      **SPOKE, PrimeKG, Hetionet, Monarch, DRKG, and NeuroKG**.
- [x] **181.22.1.2** Implement KG-embedding (TransE/RotatE/ComplEx) and
      heterogeneous-graph-transformer (TxGNN/PROTON pattern) services for
      link-prediction-based hypothesis support.

#### 181.22.2 Ontology Service & The Crosswalk Phoebe Owns

- [x] **181.22.2.1** Host **Cognitive Atlas, NIFSTD, Uberon, NeuroNames, NBO,
      MF/MFOEM, MeSH, SNOMED CT, DSM-5-TR, ICD-11** with versioned IRIs.
- [x] **181.22.2.2** Publish the **canonical machine-readable RDoC ontology
      (OWL/SKOS)** — which does not exist anywhere today — with constructs
      mapped to Cognitive Atlas concepts and NBO behaviours.
- [x] **181.22.2.3** Publish and maintain the **DSM-5-TR ↔ ICD-11 Ch.06 ↔ MeSH
      F03 ↔ SNOMED CT ↔ Cognitive Atlas ↔ RDoC crosswalk** as an **SSSOM**
      mapping graph (current best-in-class is a static third-party table).
  - Acceptance: a query resolves a DSM-5-TR disorder to its ICD-11 code, MeSH
    term, SNOMED concept, and related RDoC constructs through the crosswalk,
    with mapping provenance attached.

---

### 181.23 @phoebe/literature — Ingestion & Claim Extraction

#### 181.23.1 Corpus Connectors

- [x] **181.23.1.1** Implement connectors to **PubMed/E-utilities, OpenAlex,
      Semantic Scholar/S2ORC (+ SPECTER2 embeddings), Europe PMC Annotations,**
      and openRxiv/PsyArXiv preprint feeds.

#### 181.23.2 Claim & Evidence Extraction

- [x] **181.23.2.1** Implement claim/evidence extraction (SciFact/MultiVerS
      SUPPORTS/REFUTES/NOINFO & rationales) with entity linking to the ontology
      service.
- [x] **181.23.2.2** Implement smart-citation typing (supporting/contrasting/
      mentioning, scite pattern).
  - Acceptance: extraction is evaluated on SciFact with reported F1; a
    fabricated claim with no supporting evidence is labelled NOINFO, not
    SUPPORTS.

---

### 181.24 @phoebe/evidence-synthesis — Living Reviews & GraphRAG

#### 181.24.1 Living Systematic Reviews

- [x] **181.24.1.1** Implement active-learning screening (ASReview pattern) +
      LLM majority-vote screening & multi-pass extraction with RCT detection
      (RobotSearch) and PICO & risk-of-bias extraction.
- [x] **181.24.1.2** Implement contradiction detection across the claim graph
      and versioned, provenance-stamped living-review outputs.

#### 181.24.2 GraphRAG with KG Verification

- [x] **181.24.2.1** Implement hybrid vector & graph retrieval (GraphRAG Leiden-
      community summaries; Local/Global/DRIFT search).
- [x] **181.24.2.2** Implement **KGARevion-style** verification of every
      LLM-generated triple against the grounded KG to suppress hallucination.
  - Acceptance: a generated triple absent from / contradicted by the KG is
    filtered out before it reaches an answer.

---

### 181.25 @phoebe/datasets — FAIR Catalog & NWB/BIDS I/O

#### 181.25.1 Catalog & Access Tiers

- [x] **181.25.1.1** Implement a FAIR (RO-Crate/schema.org) catalog of **UK
      Biobank, HCP, ABCD, ENIGMA, OpenNeuro, IBL, Allen ABC Atlas, ABIDE, ADNI,
      PPMI, AnswerALS, NDA, DANDI, BIL, EBRAINS**, recording modality, scale,
      and **access tier** (open / DUA-LONI / enclave-Workbench /
      federated-only).

#### 181.25.2 Standards I/O

- [x] **181.25.2.1** Implement first-class **NWB** (PyNWB/MatNWB; HDF5 & Zarr)
      and **BIDS** (incl. iEEG/microscopy/MRS) read/write, with **DICOM→BIDS via
      HeuDiConv** recording W3C-PROV provenance.
- [x] **181.25.2.2** Implement IBL **ONE/Alyx**, DANDI, and OpenNeuro streaming
      connectors (no-download access).
  - Acceptance: a round-trip BIDS validation passes and a streamed DANDI NWB
    file reads without local download.

---

### 181.26 @phoebe/governance — Neuroethics, Neurorights & Privacy

#### 181.26.1 Neural-Data Governance

- [x] **181.26.1.1** Implement neural-data classification/tagging and a
      consent-management service (broad & dynamic consent, withdrawal,
      portability, deletion) engineered to **Chile / Colorado HB24-1058 /
      California SB 1223 / Montana SB 163 / Connecticut SB 1295 & the UNESCO
      2025 neurotechnology standard**, plus HIPAA and GDPR Art. 9.
- [x] **181.26.1.2** Implement HIPAA de-identification (Safe Harbor
      18-identifier & Expert Determination) and **mandatory neuroimaging
      defacing** (fsl_deface/mri_reface) — given the 83% top-1 face-reID risk.

#### 181.26.2 Privacy-Preserving Compute & Provenance

- [x] **181.26.2.1** Implement federated learning (NVIDIA FLARE / COINSTAC for
      neuroimaging) and differential privacy (OpenDP) for multi-institution
      analysis; SMPC+HE for genomics (SF-GWAS pattern).
- [x] **181.26.2.2** Implement dbGaP-style controlled access (DAR → DAC → DUC)
      and end-to-end audit trails.
  - Acceptance: a neural-data export for an unconsented purpose is hard-blocked;
    every access is logged immutably.

---

### 181.27 @phoebe/regulatory — FDA SaMD Lifecycle & Validation Harness

#### 181.27.1 SaMD Lifecycle

- [x] **181.27.1.1** Implement SaMD lifecycle support (510(k)/De Novo/PMA by
      risk; IMDRF framework) with a **Predetermined Change Control Plan
      (PCCP)**-aware model-update pipeline (ship updates without full
      re-submission).
- [x] **181.27.1.2** Implement model-card / data-lineage documentation, **bias/
      equity testing** (race-stratified, per the npj 2025 finding), and model-
      drift detection with rollback criteria and post-market monitoring (TPLC).

#### 181.27.2 Evidence & Registration

- [x] **181.27.2.1** Implement a clinical-evidence/RCT pipeline
      (Therabot/Limbic- grade) and ClinicalTrials.gov / WHO ICTRP registration
      emission.
  - Acceptance: a model update that fails bias/drift thresholds is blocked from
    promotion and triggers rollback; the validation record is auditable.

---

### 181.28 @phoebe/safety — Crisis & Compliance Backbone

#### 181.28.1 Crisis Handling

- [x] **181.28.1.1** Implement crisis routing (988 Suicide & Crisis Lifeline /
      Samaritans / findahelpline) and suicidality-escalation workflows triggered
      by C-SSRS / PHQ-9 item-9 / conversational detection.
- [x] **181.28.1.2** Implement age-gating (post-Character.AI) and mandatory
      AI-disclosure (Utah HB 452).

#### 181.28.2 Jurisdiction-Aware Compliance

- [x] **181.28.2.1** Implement jurisdiction-aware feature flags that disable
      autonomous-therapy features for Illinois/Nevada users and enforce
      human-in-the-loop where law requires it.
- [x] **181.28.2.2** Implement a human-in-the-loop checkpoint framework that any
      patient-facing or human-subjects autonomous action must pass.
  - Acceptance: a high-risk query is never answered autonomously; the backbone
    forces escalation and records the human handoff.

---

### 181.29 @phoebe/ai — Autonomous Closed-Loop Neuroscientist

#### 181.29.1 Closed-Loop Orchestration

- [x] **181.29.1.1** Implement the supervisor that chains **hypothesis →
      adaptive design → IRB/AI-ethics gate → execution → analysis → theory
      update → re-rank**, specializing the Phase 178 substrate for
      brains/behaviour.
- [x] **181.29.1.2** Implement the **theory/model-update** step: formalize
      findings back into the knowledge graph / causal world-model with
      provenance and contradiction detection (the hardest unsolved piece).

#### 181.29.2 Reliability Guardrails

- [x] **181.29.2.1** Implement hallucination/fabrication detection on every
      autonomous analysis step and human-in-the-loop checkpoints for all
      human-subjects actions.
- [x] **181.29.2.2** Implement the **fail-closed AI-IRB** ethics gate: real-time
      machine-readable protocol checking against Common Rule / Belmont / ICH
      E6(R3) before any agent enrolls a human, with continuous AE monitoring and
      automatic stopping-rule enforcement.
  - Acceptance: the engine cannot enroll a human subject without passing the
    AI-IRB gate and a human sign-off; a protocol violation halts the loop and
    raises an alert rather than proceeding.

---

### 181.30 @phoebe/apps — Application Suite

#### 181.30.1 Researcher & Clinician Surfaces

- [x] **181.30.1.1** Implement the **Researcher Workbench** (hypothesis → design
      → run → analyze → prereg/reproduce) as a Next.js app under
      `libs/phoebe/apps/`.
- [x] **181.30.1.2** Implement the **Clinician Console** (assessment, MBC
      dashboards, treatment-matching, copilot/scribe) with human-sign-off gates.

#### 181.30.2 Real-Time & Participant Surfaces

- [x] **181.30.2.1** Implement the **Neural-Interface Control Room** (live BCI
      decode/stim, signal-quality and device-health telemetry, latency SLAs).
- [x] **181.30.2.2** Implement the **Knowledge Explorer**
      (KG/literature/evidence browsing with verified-citation answers).
- [x] **181.30.2.3** Implement the **Participant/Patient app** (consent, EMA,
      phenotyping opt-ins, therapeutic content with crisis safety).

---

### 181.31 @phoebe/integration — Cross-Domain Hub

#### 181.31.1 Adapters

- [x] **181.31.1.1** Implement the **Iris** adapter consuming `@iris/bci-*` /
      `@iris/multimodal-bci` device, intent-prediction, and privacy primitives.
- [x] **181.31.1.2** Implement the **Aphrodite** adapter consuming
      `@aphrodite/biometric-engine` (incl. EEG) biosignal acquisition.
- [x] **181.31.1.3** Implement the **Psyche** adapter consuming affective/
      sentiment signals and the conversational stack for therapeutic delivery.
- [x] **181.31.1.4** Implement the **Phase 178 / Nous** adapter consuming the
      autonomous-research substrate and ML platform, and the **Kalika** adapter
      consuming research-agent & computational-notebook infrastructure.
- [x] **181.31.1.5** Implement adapters to **Mnemosyne** (memory), **Maat**
      (ethics/governance), **Veritas** (verification), **Themis** (IP), and
      **Shared** (platform infra), plus integration tests covering every adapter
      (minimum 200 test cases).
  - Acceptance: no Phoebe package re-implements Iris/Aphrodite/Psyche device or
    affect code; all such access flows through these contract-bound adapters.

---

### Phase 181 Summary — Phoebe Domain

| Library                    | Subsections         | Tasks   | Description                                                                            |
| -------------------------- | ------------------- | ------- | -------------------------------------------------------------------------------------- |
| Infrastructure             | 181.1.1 – 181.1.3   | 42      | Library structure, data model/persistence, API gateway & topology                      |
| @phoebe/core               | 181.2.1 – 181.2.2   | 7       | Neural/signal & clinical/experimental primitives, state machines                       |
| @phoebe/neural-io          | 181.3.1 – 181.3.2   | 7       | Multimodal acquisition & LSL/XDF sub-ms time-sync                                      |
| @phoebe/signal             | 181.4.1 – 181.4.2   | 6       | Real-time DSP, ICA/CSP/xDAWN/Riemannian feature extraction                             |
| @phoebe/decoding           | 181.5.1 – 181.5.3   | 9       | Decoder runtime, neural foundation models, cross-subject adaptation                    |
| @phoebe/neuromodulation    | 181.6.1 – 181.6.2   | 6       | Closed-loop aDBS/RNS/tFUS/TI, bidirectional read–write, safety governor                |
| @phoebe/connectomics       | 181.7.1 – 181.7.2   | 6       | FFN segmentation, CAVE proofreading, petascale graph serving                           |
| @phoebe/simulation         | 181.8.1 – 181.8.2   | 5       | NEST/NEURON/Arbor/Brian2 over SONATA, multi-scale co-sim                               |
| @phoebe/brain-models       | 181.9.1 – 181.9.2   | 5       | Brain foundation models & circuit/region digital twins (fail-loud)                     |
| @phoebe/neuro-analysis     | 181.10.1 – 181.10.2 | 6       | SpikeInterface/Kilosort, LFADS/CEBRA, manifolds, identifiability                       |
| @phoebe/assessment         | 181.11.1 – 181.11.2 | 5       | PHQ-9/GAD-7/PCL-5/C-SSRS & DSM-5-TR/ICD-11 computable coding                           |
| @phoebe/mbc                | 181.12.1            | 2       | Measurement-based & collaborative care registry                                        |
| @phoebe/phenotyping        | 181.13.1 – 181.13.2 | 5       | Passive sensing, EMA, voice biomarkers, contextual-bandit JITAI                        |
| @phoebe/comp-psychiatry    | 181.14.1 – 181.14.2 | 4       | RL/DDM/active-inference, biotypes, treatment-matching (advisory)                       |
| @phoebe/therapeutics       | 181.15.1 – 181.15.2 | 5       | CBT/DBT/ACT/MI content, anti-sycophancy, clinician copilot/scribe                      |
| @phoebe/hypothesis         | 181.16.1 – 181.16.2 | 4       | Co-Scientist generate/debate/rank, graph-novelty & GNN-feasibility                     |
| @phoebe/design             | 181.17.1 – 181.17.3 | 7       | BOED/DAD/ADO, Bayesian adaptive trials, SMART/JITAI optimizers                         |
| @phoebe/experiment-runtime | 181.18.1 – 181.18.2 | 4       | Frame-precise authoring/runtime & closed-loop & robotic execution                      |
| @phoebe/subjects           | 181.19.1 – 181.19.2 | 4       | Panel connectors, data-quality firewall, eligibility matching                          |
| @phoebe/analysis           | 181.20.1 – 181.20.2 | 5       | BIDS-App/MNE pipelines, multiple-comparison gate, causal inference                     |
| @phoebe/reproducibility    | 181.21.1 – 181.21.2 | 5       | Auto-preregistration, multiverse default, provenance ledger                            |
| @phoebe/knowledge-graph    | 181.22.1 – 181.22.2 | 5       | Biolink KG, ontology service, RDoC OWL & DSM↔ICD crosswalk (greenfield)                |
| @phoebe/literature         | 181.23.1 – 181.23.2 | 3       | PubMed/OpenAlex/S2 ingestion, SciFact claim/evidence extraction                        |
| @phoebe/evidence-synthesis | 181.24.1 – 181.24.2 | 4       | Living systematic reviews, GraphRAG & KGARevion verification                           |
| @phoebe/datasets           | 181.25.1 – 181.25.2 | 4       | FAIR catalog (UKB/HCP/ABCD/IBL/Allen…), NWB/BIDS/DICOM I/O                             |
| @phoebe/governance         | 181.26.1 – 181.26.2 | 4       | Neurorights/HIPAA/GDPR, defacing, federated & DP compute, controlled access            |
| @phoebe/regulatory         | 181.27.1 – 181.27.2 | 3       | FDA SaMD & PCCP, bias/drift testing, RCT evidence & registration                       |
| @phoebe/safety             | 181.28.1 – 181.28.2 | 4       | 988/Samaritans crisis routing, age-gating, jurisdiction-aware HITL                     |
| @phoebe/ai                 | 181.29.1 – 181.29.2 | 4       | Closed-loop neuroscientist, theory update, fail-closed AI-IRB gate                     |
| @phoebe/apps               | 181.30.1 – 181.30.2 | 5       | Researcher Workbench, Clinician Console, Control Room, Explorer, Patient               |
| @phoebe/integration        | 181.31.1            | 5       | Iris/Aphrodite/Psyche/Phase-178/Kalika & Mnemosyne/Maat/Veritas/Themis                 |
| **TOTAL**                  | **181.1 – 181.31**  | **189** | **Brain-computer interface, neuroscience, clinical psychology & autonomous discovery** |

---
