docs(8.0): RELEASES — portable export/import (BackupData v1) + distinctCount any-type section

This commit is contained in:
David Snelling 2026-06-17 12:05:00 -07:00
parent 574a8b147c
commit 4741e23d45

View file

@ -80,6 +80,47 @@ historical records) are documented in:
- [docs/ADR-001-generational-mvcc.md](docs/ADR-001-generational-mvcc.md) — the - [docs/ADR-001-generational-mvcc.md](docs/ADR-001-generational-mvcc.md) — the
design record: persisted layout, commit protocol, crash recovery, proof table design record: persisted layout, commit protocol, crash recovery, proof table
### Portable export & import (BackupData v1)
A portable, versioned graph format that serializes part or all of a brain to a
single JSON document and restores it — the cross-environment, cross-version
(7.x↔8.0), partial-or-whole companion to the native `persist()` snapshot.
```ts
// Export is a method on the immutable Db, so it composes with now()/asOf()/with()
const backup = await brain.export({ collection: id }, { includeVectors: true })
await otherBrain.import(backup, { onConflict: 'merge' }) // dedup-by-id
;(await brain.asOf(gen)).export(sel) // time-travel export
brain.now().with(ops).export(sel) // what-if export
```
- **`brain.export(selector?, options?)` / `db.export(...)`** → a versioned
`BackupData` document. Selectors reuse `find()`'s grammar: `{ ids }`,
`{ collection }` (alias `memberOf`, transitive `Contains`),
`{ connected: { from, depth } }`, `{ vfsPath }`, predicate
(`{ type, subtype, where, service }`), or the whole brain (omit) — and they
compose. Options: `includeVectors`, `includeContent` (VFS file bytes),
`includeSystem`, `edges: 'induced' | 'incident' | 'none'`.
- **`brain.import(backup, options?)`** is polymorphic: a `BackupData` document is
restored as **one atomic transaction** (`onConflict: 'merge' | 'replace' | 'skip'`,
`reembed: 'auto' | 'never'`, `remapIds` for cloning); a file/buffer routes to the
existing CSV/PDF/Excel/JSON ingestion. No migration for ingestion callers.
- **`validateBackup(data)`** — dry-run structural/version/endpoint check before import.
- **Format** (`format:'brainy-backup'`, `formatVersion: 1`) is identical on 7.x
(7.32.0) and 8.0; standard fields (`subtype`/`visibility`/`data`/…) are top-level,
`metadata` is custom-only. Current-state (no generation history — that lives in
`persist()`). Types exported from the package root.
- Guide: [docs/guides/export-and-import.md](docs/guides/export-and-import.md).
### Aggregation: distinctCount over any value type
`distinctCount` now counts distinct values of **any** type (strings, booleans,
numbers) — previously it silently returned `0` for non-numeric fields, missing its
primary use (distinct categories / users / tags). `percentile` (with `p`; median =
`p: 0.5`), `stddev`, and `variance` are exact and delete-safe alongside the
write-time `sum`/`count`/`avg`/`min`/`max`.
### Removed surfaces and their replacements ### Removed surfaces and their replacements
| Removed in 8.0 | Replacement | | Removed in 8.0 | Replacement |