@soulcraft/brainy 5.10.4 → 5.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +101 -0
- package/dist/brainy.d.ts +160 -2
- package/dist/brainy.js +276 -11
- package/dist/storage/adapters/azureBlobStorage.d.ts +2 -5
- package/dist/storage/adapters/azureBlobStorage.js +4 -40
- package/dist/storage/adapters/fileSystemStorage.d.ts +2 -5
- package/dist/storage/adapters/fileSystemStorage.js +4 -42
- package/dist/storage/adapters/gcsStorage.d.ts +2 -5
- package/dist/storage/adapters/gcsStorage.js +10 -47
- package/dist/storage/adapters/historicalStorageAdapter.d.ts +2 -5
- package/dist/storage/adapters/historicalStorageAdapter.js +2 -9
- package/dist/storage/adapters/memoryStorage.d.ts +2 -5
- package/dist/storage/adapters/memoryStorage.js +2 -10
- package/dist/storage/adapters/opfsStorage.d.ts +2 -5
- package/dist/storage/adapters/opfsStorage.js +12 -54
- package/dist/storage/adapters/r2Storage.d.ts +0 -13
- package/dist/storage/adapters/r2Storage.js +18 -53
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +2 -5
- package/dist/storage/adapters/s3CompatibleStorage.js +18 -70
- package/dist/storage/baseStorage.d.ts +46 -16
- package/dist/storage/baseStorage.js +54 -42
- package/dist/storage/cow/CommitLog.d.ts +24 -0
- package/dist/storage/cow/CommitLog.js +37 -0
- package/dist/types/brainy.types.d.ts +59 -0
- package/dist/utils/paramValidation.d.ts +43 -0
- package/dist/utils/paramValidation.js +135 -22
- package/package.json +1 -1
|
@@ -859,18 +859,11 @@ export class AzureBlobStorage extends BaseStorage {
|
|
|
859
859
|
await blockBlobClient.delete();
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
|
-
//
|
|
863
|
-
//
|
|
864
|
-
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
862
|
+
// v5.11.0: Reset COW managers (but don't disable COW - it's always enabled)
|
|
863
|
+
// COW will re-initialize automatically on next use
|
|
865
864
|
this.refManager = undefined;
|
|
866
865
|
this.blobStorage = undefined;
|
|
867
866
|
this.commitLog = undefined;
|
|
868
|
-
this.cowEnabled = false;
|
|
869
|
-
// v5.10.4: Create persistent marker blob (CRITICAL FIX)
|
|
870
|
-
// Bug: cowEnabled = false only affects current instance, not future instances
|
|
871
|
-
// Fix: Create marker blob that persists across instance restarts
|
|
872
|
-
// When new instance calls initializeCOW(), it checks for this marker
|
|
873
|
-
await this.createClearMarker();
|
|
874
867
|
// Clear caches
|
|
875
868
|
this.nounCacheManager.clear();
|
|
876
869
|
this.verbCacheManager.clear();
|
|
@@ -919,39 +912,10 @@ export class AzureBlobStorage extends BaseStorage {
|
|
|
919
912
|
* @returns true if marker blob exists, false otherwise
|
|
920
913
|
* @protected
|
|
921
914
|
*/
|
|
922
|
-
async checkClearMarker() {
|
|
923
|
-
await this.ensureInitialized();
|
|
924
|
-
try {
|
|
925
|
-
const markerPath = `${this.systemPrefix}cow-disabled`;
|
|
926
|
-
const blockBlobClient = this.containerClient.getBlockBlobClient(markerPath);
|
|
927
|
-
const exists = await blockBlobClient.exists();
|
|
928
|
-
return exists;
|
|
929
|
-
}
|
|
930
|
-
catch (error) {
|
|
931
|
-
this.logger.warn('AzureBlobStorage.checkClearMarker: Error checking marker', error);
|
|
932
|
-
return false;
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
915
|
/**
|
|
936
|
-
*
|
|
937
|
-
*
|
|
938
|
-
* @protected
|
|
916
|
+
* v5.11.0: Removed checkClearMarker() and createClearMarker() methods
|
|
917
|
+
* COW is now always enabled - marker files are no longer used
|
|
939
918
|
*/
|
|
940
|
-
async createClearMarker() {
|
|
941
|
-
await this.ensureInitialized();
|
|
942
|
-
try {
|
|
943
|
-
const markerPath = `${this.systemPrefix}cow-disabled`;
|
|
944
|
-
const blockBlobClient = this.containerClient.getBlockBlobClient(markerPath);
|
|
945
|
-
// Create empty marker blob
|
|
946
|
-
await blockBlobClient.upload(Buffer.from(''), 0, {
|
|
947
|
-
blobHTTPHeaders: { blobContentType: 'text/plain' }
|
|
948
|
-
});
|
|
949
|
-
}
|
|
950
|
-
catch (error) {
|
|
951
|
-
this.logger.error('AzureBlobStorage.createClearMarker: Failed to create marker blob', error);
|
|
952
|
-
// Don't throw - marker creation failure shouldn't break clear()
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
919
|
/**
|
|
956
920
|
* Save statistics data to storage
|
|
957
921
|
*/
|
|
@@ -177,13 +177,10 @@ export declare class FileSystemStorage extends BaseStorage {
|
|
|
177
177
|
* @returns true if marker file exists, false otherwise
|
|
178
178
|
* @protected
|
|
179
179
|
*/
|
|
180
|
-
protected checkClearMarker(): Promise<boolean>;
|
|
181
180
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* @protected
|
|
181
|
+
* v5.11.0: Removed checkClearMarker() and createClearMarker() methods
|
|
182
|
+
* COW is now always enabled - marker files are no longer used
|
|
185
183
|
*/
|
|
186
|
-
protected createClearMarker(): Promise<void>;
|
|
187
184
|
/**
|
|
188
185
|
* Get information about storage usage and capacity
|
|
189
186
|
*/
|
|
@@ -878,18 +878,11 @@ export class FileSystemStorage extends BaseStorage {
|
|
|
878
878
|
if (await this.directoryExists(cowDir)) {
|
|
879
879
|
// Delete the entire _cow/ directory (not just contents)
|
|
880
880
|
await fs.promises.rm(cowDir, { recursive: true, force: true });
|
|
881
|
-
//
|
|
882
|
-
//
|
|
883
|
-
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
881
|
+
// v5.11.0: Reset COW managers (but don't disable COW - it's always enabled)
|
|
882
|
+
// COW will re-initialize automatically on next use
|
|
884
883
|
this.refManager = undefined;
|
|
885
884
|
this.blobStorage = undefined;
|
|
886
885
|
this.commitLog = undefined;
|
|
887
|
-
this.cowEnabled = false;
|
|
888
|
-
// v5.10.4: Create persistent marker file (CRITICAL FIX)
|
|
889
|
-
// Bug: cowEnabled = false only affects current instance, not future instances
|
|
890
|
-
// Fix: Create marker file that persists across instance restarts
|
|
891
|
-
// When new instance calls initializeCOW(), it checks for this marker
|
|
892
|
-
await this.createClearMarker();
|
|
893
886
|
}
|
|
894
887
|
// Clear the statistics cache
|
|
895
888
|
this.statisticsCache = null;
|
|
@@ -923,41 +916,10 @@ export class FileSystemStorage extends BaseStorage {
|
|
|
923
916
|
* @returns true if marker file exists, false otherwise
|
|
924
917
|
* @protected
|
|
925
918
|
*/
|
|
926
|
-
async checkClearMarker() {
|
|
927
|
-
// Check if fs module is available
|
|
928
|
-
if (!fs || !fs.promises) {
|
|
929
|
-
return false;
|
|
930
|
-
}
|
|
931
|
-
try {
|
|
932
|
-
const markerPath = path.join(this.systemDir, 'cow-disabled');
|
|
933
|
-
await fs.promises.access(markerPath, fs.constants.F_OK);
|
|
934
|
-
return true; // Marker exists
|
|
935
|
-
}
|
|
936
|
-
catch (error) {
|
|
937
|
-
return false; // Marker doesn't exist (ENOENT) or can't be accessed
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
919
|
/**
|
|
941
|
-
*
|
|
942
|
-
*
|
|
943
|
-
* @protected
|
|
920
|
+
* v5.11.0: Removed checkClearMarker() and createClearMarker() methods
|
|
921
|
+
* COW is now always enabled - marker files are no longer used
|
|
944
922
|
*/
|
|
945
|
-
async createClearMarker() {
|
|
946
|
-
// Check if fs module is available
|
|
947
|
-
if (!fs || !fs.promises) {
|
|
948
|
-
console.warn('FileSystemStorage.createClearMarker: fs module not available, skipping marker creation');
|
|
949
|
-
return;
|
|
950
|
-
}
|
|
951
|
-
try {
|
|
952
|
-
const markerPath = path.join(this.systemDir, 'cow-disabled');
|
|
953
|
-
// Create empty marker file
|
|
954
|
-
await fs.promises.writeFile(markerPath, '', 'utf8');
|
|
955
|
-
}
|
|
956
|
-
catch (error) {
|
|
957
|
-
console.error('FileSystemStorage.createClearMarker: Failed to create marker file', error);
|
|
958
|
-
// Don't throw - marker creation failure shouldn't break clear()
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
923
|
/**
|
|
962
924
|
* Get information about storage usage and capacity
|
|
963
925
|
*/
|
|
@@ -234,13 +234,10 @@ export declare class GcsStorage extends BaseStorage {
|
|
|
234
234
|
* @returns true if marker object exists, false otherwise
|
|
235
235
|
* @protected
|
|
236
236
|
*/
|
|
237
|
-
protected checkClearMarker(): Promise<boolean>;
|
|
238
237
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
* @protected
|
|
238
|
+
* v5.11.0: Removed checkClearMarker() and createClearMarker() methods
|
|
239
|
+
* COW is now always enabled - marker files are no longer used
|
|
242
240
|
*/
|
|
243
|
-
protected createClearMarker(): Promise<void>;
|
|
244
241
|
/**
|
|
245
242
|
* Save statistics data to storage
|
|
246
243
|
*/
|
|
@@ -772,28 +772,18 @@ export class GcsStorage extends BaseStorage {
|
|
|
772
772
|
await file.delete();
|
|
773
773
|
}
|
|
774
774
|
};
|
|
775
|
-
// Clear
|
|
776
|
-
|
|
777
|
-
await deleteObjectsWithPrefix(
|
|
778
|
-
|
|
779
|
-
await deleteObjectsWithPrefix(this.verbMetadataPrefix);
|
|
780
|
-
await deleteObjectsWithPrefix(this.systemPrefix);
|
|
781
|
-
// v5.6.1: Clear COW (copy-on-write) version control data
|
|
782
|
-
// This includes all git-like versioning data (commits, trees, blobs, refs)
|
|
783
|
-
// Must be deleted to fully clear all data including version history
|
|
775
|
+
// v5.11.0: Clear ALL data using correct paths
|
|
776
|
+
// Delete entire branches/ directory (includes ALL entities, ALL types, ALL VFS data, ALL forks)
|
|
777
|
+
await deleteObjectsWithPrefix('branches/');
|
|
778
|
+
// Delete COW version control data
|
|
784
779
|
await deleteObjectsWithPrefix('_cow/');
|
|
785
|
-
//
|
|
786
|
-
|
|
787
|
-
//
|
|
780
|
+
// Delete system metadata
|
|
781
|
+
await deleteObjectsWithPrefix('_system/');
|
|
782
|
+
// v5.11.0: Reset COW managers (but don't disable COW - it's always enabled)
|
|
783
|
+
// COW will re-initialize automatically on next use
|
|
788
784
|
this.refManager = undefined;
|
|
789
785
|
this.blobStorage = undefined;
|
|
790
786
|
this.commitLog = undefined;
|
|
791
|
-
this.cowEnabled = false;
|
|
792
|
-
// v5.10.4: Create persistent marker object (CRITICAL FIX)
|
|
793
|
-
// Bug: cowEnabled = false only affects current instance, not future instances
|
|
794
|
-
// Fix: Create marker object that persists across instance restarts
|
|
795
|
-
// When new instance calls initializeCOW(), it checks for this marker
|
|
796
|
-
await this.createClearMarker();
|
|
797
787
|
// Clear caches
|
|
798
788
|
this.nounCacheManager.clear();
|
|
799
789
|
this.verbCacheManager.clear();
|
|
@@ -845,37 +835,10 @@ export class GcsStorage extends BaseStorage {
|
|
|
845
835
|
* @returns true if marker object exists, false otherwise
|
|
846
836
|
* @protected
|
|
847
837
|
*/
|
|
848
|
-
async checkClearMarker() {
|
|
849
|
-
await this.ensureInitialized();
|
|
850
|
-
try {
|
|
851
|
-
const markerPath = `${this.systemPrefix}cow-disabled`;
|
|
852
|
-
const file = this.bucket.file(markerPath);
|
|
853
|
-
const [exists] = await file.exists();
|
|
854
|
-
return exists;
|
|
855
|
-
}
|
|
856
|
-
catch (error) {
|
|
857
|
-
this.logger.warn('GCSStorage.checkClearMarker: Error checking marker', error);
|
|
858
|
-
return false;
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
838
|
/**
|
|
862
|
-
*
|
|
863
|
-
*
|
|
864
|
-
* @protected
|
|
839
|
+
* v5.11.0: Removed checkClearMarker() and createClearMarker() methods
|
|
840
|
+
* COW is now always enabled - marker files are no longer used
|
|
865
841
|
*/
|
|
866
|
-
async createClearMarker() {
|
|
867
|
-
await this.ensureInitialized();
|
|
868
|
-
try {
|
|
869
|
-
const markerPath = `${this.systemPrefix}cow-disabled`;
|
|
870
|
-
const file = this.bucket.file(markerPath);
|
|
871
|
-
// Create empty marker object
|
|
872
|
-
await file.save('', { contentType: 'text/plain' });
|
|
873
|
-
}
|
|
874
|
-
catch (error) {
|
|
875
|
-
this.logger.error('GCSStorage.createClearMarker: Failed to create marker object', error);
|
|
876
|
-
// Don't throw - marker creation failure shouldn't break clear()
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
842
|
/**
|
|
880
843
|
* Save statistics data to storage
|
|
881
844
|
*/
|
|
@@ -107,13 +107,10 @@ export declare class HistoricalStorageAdapter extends BaseStorage {
|
|
|
107
107
|
* @returns Always false (read-only adapter doesn't manage COW state)
|
|
108
108
|
* @protected
|
|
109
109
|
*/
|
|
110
|
-
protected checkClearMarker(): Promise<boolean>;
|
|
111
110
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* @protected
|
|
111
|
+
* v5.11.0: Removed checkClearMarker() and createClearMarker() methods
|
|
112
|
+
* COW is now always enabled - marker files are no longer used
|
|
115
113
|
*/
|
|
116
|
-
protected createClearMarker(): Promise<void>;
|
|
117
114
|
/**
|
|
118
115
|
* WRITE BLOCKED: Historical storage is read-only
|
|
119
116
|
*/
|
|
@@ -232,17 +232,10 @@ export class HistoricalStorageAdapter extends BaseStorage {
|
|
|
232
232
|
* @returns Always false (read-only adapter doesn't manage COW state)
|
|
233
233
|
* @protected
|
|
234
234
|
*/
|
|
235
|
-
async checkClearMarker() {
|
|
236
|
-
return false; // Read-only adapter - COW state managed by underlying storage
|
|
237
|
-
}
|
|
238
235
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
* @protected
|
|
236
|
+
* v5.11.0: Removed checkClearMarker() and createClearMarker() methods
|
|
237
|
+
* COW is now always enabled - marker files are no longer used
|
|
242
238
|
*/
|
|
243
|
-
async createClearMarker() {
|
|
244
|
-
// No-op: HistoricalStorageAdapter is read-only, doesn't create markers
|
|
245
|
-
}
|
|
246
239
|
// ============= Override Write Methods (Read-Only) =============
|
|
247
240
|
/**
|
|
248
241
|
* WRITE BLOCKED: Historical storage is read-only
|
|
@@ -85,13 +85,10 @@ export declare class MemoryStorage extends BaseStorage {
|
|
|
85
85
|
* @returns Always false (marker doesn't persist in memory)
|
|
86
86
|
* @protected
|
|
87
87
|
*/
|
|
88
|
-
protected checkClearMarker(): Promise<boolean>;
|
|
89
88
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* @protected
|
|
89
|
+
* v5.11.0: Removed checkClearMarker() and createClearMarker() methods
|
|
90
|
+
* COW is now always enabled - marker files are no longer used
|
|
93
91
|
*/
|
|
94
|
-
protected createClearMarker(): Promise<void>;
|
|
95
92
|
/**
|
|
96
93
|
* Save statistics data to storage
|
|
97
94
|
* @param statistics The statistics data to save
|
|
@@ -164,18 +164,10 @@ export class MemoryStorage extends BaseStorage {
|
|
|
164
164
|
* @returns Always false (marker doesn't persist in memory)
|
|
165
165
|
* @protected
|
|
166
166
|
*/
|
|
167
|
-
async checkClearMarker() {
|
|
168
|
-
return false; // MemoryStorage doesn't persist - marker doesn't survive restart
|
|
169
|
-
}
|
|
170
167
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* @protected
|
|
168
|
+
* v5.11.0: Removed checkClearMarker() and createClearMarker() methods
|
|
169
|
+
* COW is now always enabled - marker files are no longer used
|
|
174
170
|
*/
|
|
175
|
-
async createClearMarker() {
|
|
176
|
-
// No-op: MemoryStorage doesn't persist, so marker is not needed
|
|
177
|
-
// clear() in memory already resets all state, no marker survives restart
|
|
178
|
-
}
|
|
179
171
|
/**
|
|
180
172
|
* Save statistics data to storage
|
|
181
173
|
* @param statistics The statistics data to save
|
|
@@ -100,13 +100,10 @@ export declare class OPFSStorage extends BaseStorage {
|
|
|
100
100
|
* @returns true if marker file exists, false otherwise
|
|
101
101
|
* @protected
|
|
102
102
|
*/
|
|
103
|
-
protected checkClearMarker(): Promise<boolean>;
|
|
104
103
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* @protected
|
|
104
|
+
* v5.11.0: Removed checkClearMarker() and createClearMarker() methods
|
|
105
|
+
* COW is now always enabled - marker files are no longer used
|
|
108
106
|
*/
|
|
109
|
-
protected createClearMarker(): Promise<void>;
|
|
110
107
|
private quotaWarningThreshold;
|
|
111
108
|
private quotaCriticalThreshold;
|
|
112
109
|
private lastQuotaCheck;
|
|
@@ -42,6 +42,16 @@ export class OPFSStorage extends BaseStorage {
|
|
|
42
42
|
this.statistics = null;
|
|
43
43
|
this.activeLocks = new Set();
|
|
44
44
|
this.lockPrefix = 'opfs-lock-';
|
|
45
|
+
/**
|
|
46
|
+
* Check if COW has been explicitly disabled via clear()
|
|
47
|
+
* v5.10.4: Fixes bug where clear() doesn't persist across instance restarts
|
|
48
|
+
* @returns true if marker file exists, false otherwise
|
|
49
|
+
* @protected
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* v5.11.0: Removed checkClearMarker() and createClearMarker() methods
|
|
53
|
+
* COW is now always enabled - marker files are no longer used
|
|
54
|
+
*/
|
|
45
55
|
// Quota monitoring configuration (v4.0.0)
|
|
46
56
|
this.quotaWarningThreshold = 0.8; // Warn at 80% usage
|
|
47
57
|
this.quotaCriticalThreshold = 0.95; // Critical at 95% usage
|
|
@@ -393,18 +403,11 @@ export class OPFSStorage extends BaseStorage {
|
|
|
393
403
|
try {
|
|
394
404
|
// Delete the entire _cow/ directory (not just contents)
|
|
395
405
|
await this.rootDir.removeEntry('_cow', { recursive: true });
|
|
396
|
-
//
|
|
397
|
-
//
|
|
398
|
-
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
406
|
+
// v5.11.0: Reset COW managers (but don't disable COW - it's always enabled)
|
|
407
|
+
// COW will re-initialize automatically on next use
|
|
399
408
|
this.refManager = undefined;
|
|
400
409
|
this.blobStorage = undefined;
|
|
401
410
|
this.commitLog = undefined;
|
|
402
|
-
this.cowEnabled = false;
|
|
403
|
-
// v5.10.4: Create persistent marker file (CRITICAL FIX)
|
|
404
|
-
// Bug: cowEnabled = false only affects current instance, not future instances
|
|
405
|
-
// Fix: Create marker file that persists across instance restarts
|
|
406
|
-
// When new instance calls initializeCOW(), it checks for this marker
|
|
407
|
-
await this.createClearMarker();
|
|
408
411
|
}
|
|
409
412
|
catch (error) {
|
|
410
413
|
// Ignore if _cow directory doesn't exist (not all instances use COW)
|
|
@@ -423,51 +426,6 @@ export class OPFSStorage extends BaseStorage {
|
|
|
423
426
|
throw error;
|
|
424
427
|
}
|
|
425
428
|
}
|
|
426
|
-
/**
|
|
427
|
-
* Check if COW has been explicitly disabled via clear()
|
|
428
|
-
* v5.10.4: Fixes bug where clear() doesn't persist across instance restarts
|
|
429
|
-
* @returns true if marker file exists, false otherwise
|
|
430
|
-
* @protected
|
|
431
|
-
*/
|
|
432
|
-
async checkClearMarker() {
|
|
433
|
-
await this.ensureInitialized();
|
|
434
|
-
try {
|
|
435
|
-
// Get system directory (may not exist yet)
|
|
436
|
-
const systemDir = await this.rootDir.getDirectoryHandle('system', { create: false });
|
|
437
|
-
// Try to get the marker file
|
|
438
|
-
await systemDir.getFileHandle('cow-disabled', { create: false });
|
|
439
|
-
return true; // Marker exists
|
|
440
|
-
}
|
|
441
|
-
catch (error) {
|
|
442
|
-
if (error.name === 'NotFoundError') {
|
|
443
|
-
return false; // Marker doesn't exist (or system dir doesn't exist)
|
|
444
|
-
}
|
|
445
|
-
// Other errors (permissions, etc.) - treat as marker not existing
|
|
446
|
-
console.warn('OPFSStorage.checkClearMarker: Error checking marker', error);
|
|
447
|
-
return false;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Create marker indicating COW has been explicitly disabled
|
|
452
|
-
* v5.10.4: Called by clear() to prevent COW reinitialization on new instances
|
|
453
|
-
* @protected
|
|
454
|
-
*/
|
|
455
|
-
async createClearMarker() {
|
|
456
|
-
await this.ensureInitialized();
|
|
457
|
-
try {
|
|
458
|
-
// Get or create system directory
|
|
459
|
-
const systemDir = await this.rootDir.getDirectoryHandle('system', { create: true });
|
|
460
|
-
// Create empty marker file
|
|
461
|
-
const fileHandle = await systemDir.getFileHandle('cow-disabled', { create: true });
|
|
462
|
-
const writable = await fileHandle.createWritable();
|
|
463
|
-
await writable.write(new Uint8Array(0)); // Empty file
|
|
464
|
-
await writable.close();
|
|
465
|
-
}
|
|
466
|
-
catch (error) {
|
|
467
|
-
console.error('OPFSStorage.createClearMarker: Failed to create marker file', error);
|
|
468
|
-
// Don't throw - marker creation failure shouldn't break clear()
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
429
|
/**
|
|
472
430
|
* Get information about storage usage and capacity
|
|
473
431
|
*/
|
|
@@ -200,18 +200,5 @@ export declare class R2Storage extends BaseStorage {
|
|
|
200
200
|
quota: number | null;
|
|
201
201
|
details?: Record<string, any>;
|
|
202
202
|
}>;
|
|
203
|
-
/**
|
|
204
|
-
* Check if COW has been explicitly disabled via clear()
|
|
205
|
-
* v5.10.4: Fixes bug where clear() doesn't persist across instance restarts
|
|
206
|
-
* @returns true if marker object exists, false otherwise
|
|
207
|
-
* @protected
|
|
208
|
-
*/
|
|
209
|
-
protected checkClearMarker(): Promise<boolean>;
|
|
210
|
-
/**
|
|
211
|
-
* Create marker indicating COW has been explicitly disabled
|
|
212
|
-
* v5.10.4: Called by clear() to prevent COW reinitialization on new instances
|
|
213
|
-
* @protected
|
|
214
|
-
*/
|
|
215
|
-
protected createClearMarker(): Promise<void>;
|
|
216
203
|
}
|
|
217
204
|
export {};
|
|
@@ -771,27 +771,27 @@ export class R2Storage extends BaseStorage {
|
|
|
771
771
|
async clear() {
|
|
772
772
|
await this.ensureInitialized();
|
|
773
773
|
prodLog.info('🧹 R2: Clearing all data from bucket...');
|
|
774
|
-
//
|
|
775
|
-
//
|
|
776
|
-
|
|
777
|
-
for (const
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
//
|
|
774
|
+
// v5.11.0: Clear ALL data using correct paths
|
|
775
|
+
// Delete entire branches/ directory (includes ALL entities, ALL types, ALL VFS data, ALL forks)
|
|
776
|
+
const branchObjects = await this.listObjectsUnderPath('branches/');
|
|
777
|
+
for (const key of branchObjects) {
|
|
778
|
+
await this.deleteObjectFromPath(key);
|
|
779
|
+
}
|
|
780
|
+
// Delete COW version control data
|
|
781
|
+
const cowObjects = await this.listObjectsUnderPath('_cow/');
|
|
782
|
+
for (const key of cowObjects) {
|
|
783
|
+
await this.deleteObjectFromPath(key);
|
|
784
|
+
}
|
|
785
|
+
// Delete system metadata
|
|
786
|
+
const systemObjects = await this.listObjectsUnderPath('_system/');
|
|
787
|
+
for (const key of systemObjects) {
|
|
788
|
+
await this.deleteObjectFromPath(key);
|
|
789
|
+
}
|
|
790
|
+
// v5.11.0: Reset COW managers (but don't disable COW - it's always enabled)
|
|
791
|
+
// COW will re-initialize automatically on next use
|
|
786
792
|
this.refManager = undefined;
|
|
787
793
|
this.blobStorage = undefined;
|
|
788
794
|
this.commitLog = undefined;
|
|
789
|
-
this.cowEnabled = false;
|
|
790
|
-
// v5.10.4: Create persistent marker object (CRITICAL FIX)
|
|
791
|
-
// Bug: cowEnabled = false only affects current instance, not future instances
|
|
792
|
-
// Fix: Create marker object that persists across instance restarts
|
|
793
|
-
// When new instance calls initializeCOW(), it checks for this marker
|
|
794
|
-
await this.createClearMarker();
|
|
795
795
|
this.nounCacheManager.clear();
|
|
796
796
|
this.verbCacheManager.clear();
|
|
797
797
|
this.totalNounCount = 0;
|
|
@@ -818,40 +818,5 @@ export class R2Storage extends BaseStorage {
|
|
|
818
818
|
}
|
|
819
819
|
};
|
|
820
820
|
}
|
|
821
|
-
/**
|
|
822
|
-
* Check if COW has been explicitly disabled via clear()
|
|
823
|
-
* v5.10.4: Fixes bug where clear() doesn't persist across instance restarts
|
|
824
|
-
* @returns true if marker object exists, false otherwise
|
|
825
|
-
* @protected
|
|
826
|
-
*/
|
|
827
|
-
async checkClearMarker() {
|
|
828
|
-
await this.ensureInitialized();
|
|
829
|
-
try {
|
|
830
|
-
const markerPath = `${this.systemPrefix}cow-disabled`;
|
|
831
|
-
const data = await this.readObjectFromPath(markerPath);
|
|
832
|
-
return data !== null; // Marker exists if we got any data
|
|
833
|
-
}
|
|
834
|
-
catch (error) {
|
|
835
|
-
prodLog.warn('R2Storage.checkClearMarker: Error checking marker', error);
|
|
836
|
-
return false;
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
/**
|
|
840
|
-
* Create marker indicating COW has been explicitly disabled
|
|
841
|
-
* v5.10.4: Called by clear() to prevent COW reinitialization on new instances
|
|
842
|
-
* @protected
|
|
843
|
-
*/
|
|
844
|
-
async createClearMarker() {
|
|
845
|
-
await this.ensureInitialized();
|
|
846
|
-
try {
|
|
847
|
-
const markerPath = `${this.systemPrefix}cow-disabled`;
|
|
848
|
-
// Create empty marker object
|
|
849
|
-
await this.writeObjectToPath(markerPath, '');
|
|
850
|
-
}
|
|
851
|
-
catch (error) {
|
|
852
|
-
prodLog.error('R2Storage.createClearMarker: Failed to create marker object', error);
|
|
853
|
-
// Don't throw - marker creation failure shouldn't break clear()
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
821
|
}
|
|
857
822
|
//# sourceMappingURL=r2Storage.js.map
|
|
@@ -379,13 +379,10 @@ export declare class S3CompatibleStorage extends BaseStorage {
|
|
|
379
379
|
* @returns true if marker object exists, false otherwise
|
|
380
380
|
* @protected
|
|
381
381
|
*/
|
|
382
|
-
protected checkClearMarker(): Promise<boolean>;
|
|
383
382
|
/**
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
* @protected
|
|
383
|
+
* v5.11.0: Removed checkClearMarker() and createClearMarker() methods
|
|
384
|
+
* COW is now always enabled - marker files are no longer used
|
|
387
385
|
*/
|
|
388
|
-
protected createClearMarker(): Promise<void>;
|
|
389
386
|
protected statisticsBatchUpdateTimerId: NodeJS.Timeout | null;
|
|
390
387
|
protected statisticsModified: boolean;
|
|
391
388
|
protected lastStatisticsFlushTime: number;
|