The distributed-clustering subsystem never ran in production: it was inert, orphaned dead code (faked consensus, stub replication, no live wiring, and it did not interoperate with the 8.0 Db API). Brainy 8.0 is a single-process library. Scale is single-process + the optional native provider (@soulcraft/cortex, on-disk DiskANN to 10B+ vectors) + per-tenant pools + horizontal read scaling (many reader processes, one writer). Removed: - src/distributed/ entirely (coordinator, shardManager, cacheSync, readWriteSeparation, queryPlanner, healthMonitor, configManager, hashPartitioner, shardMigration, domainDetector, storageDiscovery, http/network transports). ReaderMode/HybridMode relocated to src/storage/operationalModes.ts (slimmed to the live surface). - src/types/distributedTypes.ts; config.distributed field + JSDoc; coreTypes distributedConfig; memoryStorage distributedConfig persistence. - DistributedRole enum + src/config/distributedPresets.ts and the orphaned src/config/extensibleConfig.ts (config/augmentation registry built on removed cloud adapters + distributed presets), plus their src/index.ts re-exports. - 13 BRAINY_* cluster env vars; the storage setDistributedComponents hook; enableDistributedSearch (dead config flag); the metadata partition field; the distributed_ reserved key prefix. - Orphaned src/storage/readOnlyOptimizations.ts (zero importers). - Tests targeting the subsystem: distributed-demo, distributed-cluster helper, distributed-transactions, sharding-transactions. - Docs: EXTENDING_STORAGE.md (deleted); scrubbed distributed/cluster/Raft/ shard-manager/multi-node prose from v3-features, enterprise-for-everyone, augmentations-actual, complete-feature-list, vfs/README, vfs/ROADMAP, vfs/VFS_CORE, capacity-planning, transactions, MIGRATION-V3-TO-V4, storage-architecture; reframed scale prose to the 8.0 model. Kept: src/storage/sharding.ts (local-disk 256-bucket directory sharding via getShardIdFromUuid — used live by baseStorage, unrelated to clustering); the multi-process mode: 'reader' | 'writer' roles; semantic/HNSW clustering. RELEASES.md: added a removed-surfaces row documenting the cut and the 8.0 scale model.
73 lines
2.6 KiB
TypeScript
73 lines
2.6 KiB
TypeScript
/**
|
|
* @module storage/operationalModes
|
|
* @description Operational modes that gate which operations a Brainy instance may
|
|
* perform. Brainy's multi-process model runs one writer process plus any number of
|
|
* reader processes against a single shared on-disk store; the mode object is the
|
|
* in-process guard that enforces that contract.
|
|
*
|
|
* - {@link HybridMode} (the default, used by writer instances) permits reads,
|
|
* writes, and deletes — a writer must be able to read its own data.
|
|
* - {@link ReaderMode} (used by `mode: 'reader'` / `Brainy.openReadOnly()` and by
|
|
* `asOf()` historical snapshots) permits reads only; every mutation throws.
|
|
*
|
|
* `validateOperation()` is called at the top of each mutation path, and the
|
|
* `canWrite` flag drives the public read-only checks on the instance.
|
|
*/
|
|
|
|
/**
|
|
* @description Base class for operational modes. Concrete modes declare which of
|
|
* read/write/delete they permit; {@link BaseOperationalMode.validateOperation}
|
|
* turns a disallowed operation into an explicit error.
|
|
*/
|
|
export abstract class BaseOperationalMode {
|
|
abstract canRead: boolean
|
|
abstract canWrite: boolean
|
|
abstract canDelete: boolean
|
|
|
|
/**
|
|
* @description Throw if the requested operation is not allowed in this mode.
|
|
* Called at the top of every mutation method so read-only instances fail loudly
|
|
* rather than silently dropping writes.
|
|
* @param operation - The operation being attempted.
|
|
* @throws {Error} When the mode does not permit the operation.
|
|
*/
|
|
validateOperation(operation: 'read' | 'write' | 'delete'): void {
|
|
switch (operation) {
|
|
case 'read':
|
|
if (!this.canRead) {
|
|
throw new Error('Read operations are not allowed in write-only mode')
|
|
}
|
|
break
|
|
case 'write':
|
|
if (!this.canWrite) {
|
|
throw new Error('Write operations are not allowed in read-only mode')
|
|
}
|
|
break
|
|
case 'delete':
|
|
if (!this.canDelete) {
|
|
throw new Error('Delete operations are not allowed in this mode')
|
|
}
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @description Read-only mode. Reads are permitted; writes and deletes throw.
|
|
* Used by reader processes, `Brainy.openReadOnly()`, and historical snapshots.
|
|
*/
|
|
export class ReaderMode extends BaseOperationalMode {
|
|
canRead = true
|
|
canWrite = false
|
|
canDelete = false
|
|
}
|
|
|
|
/**
|
|
* @description Read-write mode and the default for writer instances. Permits
|
|
* reads, writes, and deletes — a writer needs to read its own data.
|
|
*/
|
|
export class HybridMode extends BaseOperationalMode {
|
|
canRead = true
|
|
canWrite = true
|
|
canDelete = true
|
|
}
|