# @phoebe data-model & persistence (phase 181.1.2)

Provisioning for the three Phoebe data stores against the dev docker stack
(`docker/docker-compose.dev.yml`). All are **domain-isolated**.

## PostgreSQL (`phoebe` database) — 181.1.2.1
`./apply.sh` creates the `phoebe` DB and applies `migrations/`:
- `0001_core_entities.sql` — the canonical `@phoebe/core` entity set (subject,
  consent, study, protocol, hypothesis, experiment, session, recording, channel,
  stimulus, trial, assessment, ontology_term, claim, dataset) with lifecycle-state
  enums and fail-loud CHECK constraints mirroring the domain state machines, plus
  a **pgvector** embedding table with an HNSW cosine index.
- `0002_timeseries_hypertables.sql` — neural / EMA / passive-sensing time-series
  as **native declarative range partitions** by time. TimescaleDB is the intended
  production layer; the dev pgvector image lacks the extension, so native
  partitioning (which TimescaleDB automates as hypertables) is used and the
  migration promotes to `create_hypertable()` when timescaledb is present.

`phoebe` is registered in the compose `POSTGRES_MULTIPLE_DATABASES` list so fresh
setups provision it automatically.

## Neo4j knowledge-graph store — 181.1.2.2
`neo4j-schema.cypher` installs the Biolink schema layer (unique `:PhoebeEntity`
id constraint + `category` index). Seed the RDoC ontology + DSM/ICD/MeSH/SNOMED
crosswalk from `@phoebe/knowledge-graph`. A `MATCH (dsm {id:'DSM5:296.2x'})-[r]->(t)`
traversal resolves MDD to its ICD-11/MeSH/SNOMED/RDoC neighbours with SSSOM
predicate + confidence. (Community edition is single-DB, so Phoebe isolates by
label rather than a separate database.)

## MinIO object storage — 181.1.2.3
`./minio-provision.sh` creates the `phoebe-{nwb,zarr,ome-zarr,neuroglancer,
derivatives}` buckets and writes an **OME-Zarr v0.4** group/multiscales layout and
a **Neuroglancer-precomputed** `info` so petascale imaging/connectome and NWB
electrophysiology are stored in their canonical layouts.
