feat(storage): storage hub with named backend registry and data-form mounts
ctx.storage is a pure registration hub: multiple named backends stay mounted side by side, data forms (domain first) mount via the merge-extensible StorageForms map. src/backend.ts is the normative KV-facet contract; tests/contract.ts is the shared conformance suite every backend runs. Backends expose data-shape facets (kv now, an append-log facet reserved for the future session-backend migration).
This commit is contained in:
18
packages/storage/storage/README.md
Normal file
18
packages/storage/storage/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# @deepseek-ai/dsh-storage
|
||||
|
||||
Storage hub (`ctx.storage`) for non-session data: a named backend registry plus mounted data-form facilities. The hub performs no IO itself — backends own media, data forms own semantics. Design and trade-offs: [domain KV storage Agent Note](../../../.agents/notes/proposed/architecture/2026-07-24-domain-kv-storage-and-workspace.zh.md).
|
||||
|
||||
## Shape
|
||||
|
||||
- `ctx.storage.backend` — name → backend table. Multiple backends stay mounted side by side (`json`, `sqlite`); which backend serves a consumer is that consumer's configuration (the domain layer's route table), never a hub-global choice. `register()` returns the disposer; duplicate names and unknown lookups fail loud.
|
||||
- `ctx.storage.mount(form, facility)` / `ctx.storage.form(form)` — data-form mounting. `StorageForms` is merge-extensible; the domain layer merges `domain` and is reached as `ctx.storage.domain`.
|
||||
- A backend owns one medium (file-tree root, database file) and exposes optional data-shape **facets** — `kv` today; an append-log facet is reserved for the future session-backend migration. `src/backend.ts` is the normative contract text; `tests/contract.ts` exports the shared conformance suite every backend runs.
|
||||
|
||||
## Packages in this group
|
||||
|
||||
| Package | Role |
|
||||
| --- | --- |
|
||||
| `dsh-storage` | The hub service + backend vocabulary + shared conformance suite |
|
||||
| `dsh-storage-json` | JSON backend: one unit per human-readable file, atomic whole-file rewrite |
|
||||
| `dsh-storage-sqlite` | SQLite backend: one database hosting all routed units, document-per-row |
|
||||
| `dsh-domain` | Domain data form (`ctx.storage.domain`): typed schemas, write chain, change events |
|
||||
Reference in New Issue
Block a user