Expand description
Dependency-light storage descriptor types: the wire/config contract for CortexKit module storage.
There is one central storage config. subc resolves it into a
StorageDescriptor per module and delivers that descriptor to the module
(today via the registration handshake). The module hands the descriptor to the
cortexkit-store crate, which opens the actual database.
This crate is kept dependency-light (serde only, no database driver) so the
wire crate that carries the descriptor can depend on it without pulling sqlite
or a postgres driver into the thin daemon. The heavy cortexkit-store crate
re-exports these types and provides the open/migrate mechanics.
§Design invariants
- The backend set is extensible (sqlite now, postgres soon, cloud later). A
new variant is additive; module code does not branch on the backend, it just
hands the descriptor to
cortexkit-store. - Database isolation is explicit, never derived from a naming convention, so a future per-(module, project) isolation is an additive variant rather than a breaking change to how names are built.
- The descriptor a module receives is fully resolved and least-privilege: it never carries central config or an admin credential. For postgres the DSN reaches only the module’s own database.
Structs§
- Storage
Descriptor - The resolved storage handle subc delivers to a module. The module passes this
to
cortexkit-storeto open its database; it never sees central config.
Enums§
- Isolation
- How many physical databases a module’s storage spans.
- Storage
Backend - The backend a module’s storage runs on.
Functions§
- module_
data_ dir - The conventional module data directory (
<data_home>/cortexkit/<module_id>), with the data home resolved byresolve_data_home. Modules that keep non-sqlite state (journals, caches, rings) root it here. - module_
store_ path - THE entry point for a module resolving its own sqlite store path:
<resolved data home>/cortexkit/<module_id>/store.db. Wrapsresolve_data_home+sqlite_store_pathso no module hand-assembles either half. Prefer this over callingsqlite_store_pathdirectly; the two-argument form exists for callers that genuinely hold a foreign data home (the daemon resolving descriptors, tests, rig tooling). - postgres_
database_ name - Build the per-module postgres database name:
cortexkit_<slug>_<16hex>. - resolve_
config_ home - The XDG-style CONFIG HOME (
~/.config,%APPDATA%), with nocortexkit/tail: a module joinscortexkit/<its file>under it. Mirrors the supervisor’sdefault_config_homeexactly and is pinned to the same golden rows (tests/golden/config_home_resolution.json, vendored from subconscious). Modules previously carried a dated hand copy of this ladder because the only callable was the daemon’s, which bakes in its owncortexkit/subc.jsonctail; a copy is current the day it is taken and every local check passes forever after, so the ladder lives here once. - resolve_
data_ home - The platform data home, resolved by THE SUPERVISOR’S RULES – this function
is a byte-for-byte mirror of
default_data_homein subconsciouscrates/subc-core/src/daemon_config.rs, which is the authority: the daemon resolves each module’s storage descriptor with that function, so a module resolving its own path with different rules silently splits from the directory its supervisor serves. Any change lands THERE first and is mirrored here against the shared golden fixture (tests/golden/data_home_resolution.json, vendored from subconscious). - sqlite_
store_ path - The conventional sqlite store path for a module under a data-home root
(
<data_home>/cortexkit/<module_id>/store.db). subc uses this to resolve a sqlite descriptor; the resolved absolute path then travels in the descriptor.