Implements three-tier garbage collection for agent sessions: - SessionGCService.collect() for immediate per-session cleanup on destroySession() - SessionGCService.sweepOrphans() for daily cron sweep of orphaned Valkey keys - SessionGCService.fullCollect() for cold-start aggressive cleanup via OnModuleInit - /gc slash command wired into CommandExecutorService + registered in CommandRegistryService - SESSION_GC_CRON (daily 4am) added to CronService - GCModule provides Valkey (ioredis via @mosaic/queue) and is imported by AgentModule, LogModule, CommandsModule, AppModule - 8 Vitest unit tests covering all three GC tiers Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
27 lines
809 B
TypeScript
27 lines
809 B
TypeScript
import { Global, Module } from '@nestjs/common';
|
|
import { createLogService, type LogService } from '@mosaic/log';
|
|
import type { Db } from '@mosaic/db';
|
|
import { DB } from '../database/database.module.js';
|
|
import { LOG_SERVICE } from './log.tokens.js';
|
|
import { LogController } from './log.controller.js';
|
|
import { SummarizationService } from './summarization.service.js';
|
|
import { CronService } from './cron.service.js';
|
|
import { GCModule } from '../gc/gc.module.js';
|
|
|
|
@Global()
|
|
@Module({
|
|
imports: [GCModule],
|
|
providers: [
|
|
{
|
|
provide: LOG_SERVICE,
|
|
useFactory: (db: Db): LogService => createLogService(db),
|
|
inject: [DB],
|
|
},
|
|
SummarizationService,
|
|
CronService,
|
|
],
|
|
controllers: [LogController],
|
|
exports: [LOG_SERVICE, SummarizationService],
|
|
})
|
|
export class LogModule {}
|