chore: recovery checkpoint - v3.0 API successfully recovered
CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB Recovery Status: - Successfully recovered brainy.ts from compiled JavaScript - All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.) - Neural subsystem intact (562KB embedded patterns, NLP working) - Augmentation pipeline operational (20+ augmentations) - HNSW clustering system complete - Triple Intelligence compiled (needs constructor fix) - Test suite validates functionality Changes preserved: - 898 files with changes from last 3 days - 144,475 insertions - All augmentation improvements - All test coverage enhancements - Complete v3.0 feature set This is a LOCAL checkpoint only - contains recovered work after corruption incident. Created backup in .backups/brainy-full-20250910-151314.tar.gz Branch: recovery-checkpoint-20250910-151433 Date: Wed Sep 10 03:18:04 PM PDT 2025
This commit is contained in:
parent
f65455fb22
commit
8ff382ca3b
895 changed files with 143654 additions and 28268 deletions
140
tests/helpers/minio-server.ts
Normal file
140
tests/helpers/minio-server.ts
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
import * as Minio from 'minio';
|
||||
import { GenericContainer, StartedTestContainer, Wait } from 'testcontainers';
|
||||
|
||||
export interface MinioTestConfig {
|
||||
bucketName: string;
|
||||
accessKey?: string;
|
||||
secretKey?: string;
|
||||
region?: string;
|
||||
}
|
||||
|
||||
export class MinioTestServer {
|
||||
private container?: StartedTestContainer;
|
||||
private client?: Minio.Client;
|
||||
private config: Required<MinioTestConfig>;
|
||||
|
||||
constructor(config: MinioTestConfig) {
|
||||
this.config = {
|
||||
bucketName: config.bucketName,
|
||||
accessKey: config.accessKey || 'minioadmin',
|
||||
secretKey: config.secretKey || 'minioadmin',
|
||||
region: config.region || 'us-east-1'
|
||||
};
|
||||
}
|
||||
|
||||
async start(): Promise<void> {
|
||||
console.log('Starting MinIO test container...');
|
||||
|
||||
this.container = await new GenericContainer('minio/minio:latest')
|
||||
.withExposedPorts(9000)
|
||||
.withEnvironment({
|
||||
MINIO_ROOT_USER: this.config.accessKey,
|
||||
MINIO_ROOT_PASSWORD: this.config.secretKey
|
||||
})
|
||||
.withCommand(['server', '/data'])
|
||||
.withWaitStrategy(Wait.forHttp('/minio/health/live', 9000))
|
||||
.start();
|
||||
|
||||
const port = this.container.getMappedPort(9000);
|
||||
const host = this.container.getHost();
|
||||
|
||||
this.client = new Minio.Client({
|
||||
endPoint: host,
|
||||
port: port,
|
||||
useSSL: false,
|
||||
accessKey: this.config.accessKey,
|
||||
secretKey: this.config.secretKey
|
||||
});
|
||||
|
||||
// Create test bucket
|
||||
const bucketExists = await this.client.bucketExists(this.config.bucketName);
|
||||
if (!bucketExists) {
|
||||
await this.client.makeBucket(this.config.bucketName, this.config.region);
|
||||
console.log(`Created test bucket: ${this.config.bucketName}`);
|
||||
}
|
||||
|
||||
console.log(`MinIO server started on ${host}:${port}`);
|
||||
}
|
||||
|
||||
async stop(): Promise<void> {
|
||||
if (this.client && this.config.bucketName) {
|
||||
try {
|
||||
// Clean up bucket
|
||||
const objects = await this.listAllObjects();
|
||||
if (objects.length > 0) {
|
||||
await this.client.removeObjects(this.config.bucketName, objects.map(obj => obj.name!));
|
||||
}
|
||||
await this.client.removeBucket(this.config.bucketName);
|
||||
console.log(`Cleaned up test bucket: ${this.config.bucketName}`);
|
||||
} catch (error) {
|
||||
console.warn('Failed to clean up MinIO bucket:', error);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.container) {
|
||||
await this.container.stop();
|
||||
console.log('MinIO test container stopped');
|
||||
}
|
||||
}
|
||||
|
||||
private async listAllObjects(): Promise<Array<{name: string}>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const objects: Array<{name: string}> = [];
|
||||
const stream = this.client!.listObjects(this.config.bucketName, '', true);
|
||||
|
||||
stream.on('data', (obj: Minio.BucketItem) => {
|
||||
if (obj.name) {
|
||||
objects.push({name: obj.name});
|
||||
}
|
||||
});
|
||||
stream.on('error', reject);
|
||||
stream.on('end', () => resolve(objects));
|
||||
});
|
||||
}
|
||||
|
||||
getConnectionConfig() {
|
||||
if (!this.container) {
|
||||
throw new Error('MinIO container not started');
|
||||
}
|
||||
|
||||
return {
|
||||
endpoint: `http://${this.container.getHost()}:${this.container.getMappedPort(9000)}`,
|
||||
accessKeyId: this.config.accessKey,
|
||||
secretAccessKey: this.config.secretKey,
|
||||
bucket: this.config.bucketName,
|
||||
region: this.config.region,
|
||||
forcePathStyle: true
|
||||
};
|
||||
}
|
||||
|
||||
getClient(): Minio.Client {
|
||||
if (!this.client) {
|
||||
throw new Error('MinIO client not initialized');
|
||||
}
|
||||
return this.client;
|
||||
}
|
||||
|
||||
async uploadTestData(key: string, data: Buffer | string): Promise<void> {
|
||||
if (!this.client) {
|
||||
throw new Error('MinIO client not initialized');
|
||||
}
|
||||
|
||||
const buffer = typeof data === 'string' ? Buffer.from(data) : data;
|
||||
await this.client.putObject(this.config.bucketName, key, buffer);
|
||||
}
|
||||
|
||||
async getTestData(key: string): Promise<Buffer> {
|
||||
if (!this.client) {
|
||||
throw new Error('MinIO client not initialized');
|
||||
}
|
||||
|
||||
const stream = await this.client.getObject(this.config.bucketName, key);
|
||||
const chunks: Buffer[] = [];
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
stream.on('data', chunk => chunks.push(chunk));
|
||||
stream.on('error', reject);
|
||||
stream.on('end', () => resolve(Buffer.concat(chunks)));
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue