fix: prevent circuit breaker activation and data loss during bulk imports

Storage-aware batching system prevents rate limiting issues on cloud storage (GCS, S3, R2, Azure). Replaces entity-by-entity creation with addMany()/relateMany() batch operations in ImportCoordinator. Separate read/write circuit breakers prevent read lockouts during write throttling. Each storage adapter auto-configures optimal batch sizes and delays. Fixes silent data loss and 30+ second lockouts on 1000+ row imports.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
David Snelling 2025-10-30 08:54:04 -07:00
parent 3c5f622d64
commit 14231554e1
12 changed files with 551 additions and 112 deletions

View file

@ -16,6 +16,7 @@ import {
} from '../../coreTypes.js'
import {
BaseStorage,
StorageBatchConfig,
NOUNS_DIR,
VERBS_DIR,
METADATA_DIR,
@ -80,6 +81,31 @@ export class OPFSStorage extends BaseStorage {
'getDirectory' in navigator.storage
}
/**
* Get OPFS-optimized batch configuration
*
* OPFS (Origin Private File System) is browser-based storage with moderate performance:
* - Moderate batch sizes (100 items)
* - Small delays (10ms) for browser event loop
* - Limited concurrency (50 operations) - browser constraints
* - Sequential processing preferred for stability
*
* @returns OPFS-optimized batch configuration
* @since v4.11.0
*/
public getBatchConfig(): StorageBatchConfig {
return {
maxBatchSize: 100,
batchDelayMs: 10,
maxConcurrent: 50,
supportsParallelWrites: false, // Sequential safer in browser
rateLimit: {
operationsPerSecond: 1000,
burstCapacity: 500
}
}
}
/**
* Initialize the storage adapter
*/