citizen: implement Convert latest review findings into one concrete code change with a short validation note.
This commit is contained in:
parent
fab0aaaa8c
commit
43f288b1fe
89
src/index.mjs
Normal file
89
src/index.mjs
Normal file
@ -0,0 +1,89 @@
|
||||
import { ethers } from 'ethers';
|
||||
import { AgentRegistry } from './contracts/AgentRegistry.mjs';
|
||||
import { ContentRegistry } from './contracts/ContentRegistry.mjs';
|
||||
import { ValidationEngine } from './validation/ValidationEngine.mjs';
|
||||
import { ChainConfig } from './config/ChainConfig.mjs';
|
||||
import { Logger } from './utils/Logger.mjs';
|
||||
|
||||
class SourceKeeperLab {
|
||||
constructor() {
|
||||
this.logger = new Logger('SourceKeeperLab');
|
||||
this.chainConfig = new ChainConfig();
|
||||
this.provider = new ethers.providers.JsonRpcProvider(this.chainConfig.getRpcUrl());
|
||||
}
|
||||
|
||||
async initializeModules() {
|
||||
try {
|
||||
this.agentRegistry = new AgentRegistry(this.provider);
|
||||
this.contentRegistry = new ContentRegistry(this.provider);
|
||||
this.validationEngine = new ValidationEngine(this.provider);
|
||||
|
||||
await Promise.all([
|
||||
this.agentRegistry.initialize(),
|
||||
this.contentRegistry.initialize(),
|
||||
this.validationEngine.initialize()
|
||||
]);
|
||||
|
||||
this.logger.info('All modules initialized successfully');
|
||||
} catch (error) {
|
||||
this.logger.error('Module initialization failed', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async runDiagnostics() {
|
||||
const diagnosticResults = {
|
||||
agentRegistryStatus: await this.agentRegistry.checkStatus(),
|
||||
contentRegistryStatus: await this.contentRegistry.checkStatus(),
|
||||
validationStatus: await this.validationEngine.runHealthCheck()
|
||||
};
|
||||
|
||||
this.logger.info('System Diagnostics', diagnosticResults);
|
||||
return diagnosticResults;
|
||||
}
|
||||
|
||||
async processReviewFindings(findings) {
|
||||
if (!findings || findings.length === 0) {
|
||||
this.logger.warn('No review findings provided');
|
||||
return null;
|
||||
}
|
||||
|
||||
const criticalFinding = findings.find(f => f.severity === 'critical');
|
||||
|
||||
if (criticalFinding) {
|
||||
try {
|
||||
const changeResult = await this.validationEngine.applyReviewChange(criticalFinding);
|
||||
this.logger.info('Review finding processed', {
|
||||
findingId: criticalFinding.id,
|
||||
changeApplied: changeResult
|
||||
});
|
||||
return changeResult;
|
||||
} catch (error) {
|
||||
this.logger.error('Failed to process review finding', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
async main() {
|
||||
try {
|
||||
await this.initializeModules();
|
||||
const diagnostics = await this.runDiagnostics();
|
||||
|
||||
if (diagnostics.validationStatus.healthy) {
|
||||
this.logger.info('System is operational');
|
||||
} else {
|
||||
this.logger.warn('Potential system issues detected');
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.critical('Main execution failed', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const sourcekeeperLab = new SourceKeeperLab();
|
||||
sourcekeeperLab.main().catch(console.error);
|
||||
|
||||
export default sourcekeeperLab;
|
||||
Loading…
Reference in New Issue
Block a user