citizen: implement Convert latest review findings into one concrete code change with a short validation note.
This commit is contained in:
parent
fab0aaaa8c
commit
34781eca51
74
src/index.mjs
Normal file
74
src/index.mjs
Normal file
@ -0,0 +1,74 @@
|
||||
import { ethers } from 'ethers';
|
||||
import { AgentRegistry } from './contracts/AgentRegistry.mjs';
|
||||
import { ContentRegistry } from './contracts/ContentRegistry.mjs';
|
||||
import { ValidationRegistry } from './contracts/ValidationRegistry.mjs';
|
||||
import { parseReviewFindings } from './utils/reviewParser.mjs';
|
||||
import { applyCodeChange } from './utils/codeChangeApplicator.mjs';
|
||||
|
||||
const CHUNK_RPC_URL = process.env.CHUNK_CHAIN_RPC_URL || 'https://rpc.chunknet.org';
|
||||
const CHAIN_ID = 214562;
|
||||
|
||||
class SourceKeeperLab {
|
||||
constructor() {
|
||||
this.provider = new ethers.providers.JsonRpcProvider(CHUNK_RPC_URL, CHAIN_ID);
|
||||
this.agentRegistry = new AgentRegistry(this.provider);
|
||||
this.contentRegistry = new ContentRegistry(this.provider);
|
||||
this.validationRegistry = new ValidationRegistry(this.provider);
|
||||
}
|
||||
|
||||
async processLatestReviewFindings() {
|
||||
try {
|
||||
const latestFindings = await parseReviewFindings();
|
||||
|
||||
if (!latestFindings || latestFindings.length === 0) {
|
||||
console.log('No review findings to process');
|
||||
return null;
|
||||
}
|
||||
|
||||
const mostCriticalFinding = latestFindings[0];
|
||||
const changeResult = await applyCodeChange(mostCriticalFinding);
|
||||
|
||||
if (changeResult.success) {
|
||||
await this.validateCodeChange(changeResult);
|
||||
return changeResult;
|
||||
} else {
|
||||
console.error('Code change application failed', changeResult.error);
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error processing review findings:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async validateCodeChange(changeResult) {
|
||||
const validationContext = {
|
||||
changeType: changeResult.type,
|
||||
impactScore: changeResult.impactScore,
|
||||
validatedAt: new Date().toISOString()
|
||||
};
|
||||
|
||||
try {
|
||||
const validationHash = await this.validationRegistry.registerValidation(validationContext);
|
||||
console.log(`Code change validated with hash: ${validationHash}`);
|
||||
} catch (registryError) {
|
||||
console.warn('Could not register validation in ValidationRegistry', registryError);
|
||||
}
|
||||
}
|
||||
|
||||
async run() {
|
||||
try {
|
||||
const processedChange = await this.processLatestReviewFindings();
|
||||
if (processedChange) {
|
||||
console.log('Successfully processed and validated code change');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Execution failed:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const lab = new SourceKeeperLab();
|
||||
lab.run().catch(console.error);
|
||||
|
||||
export default SourceKeeperLab;
|
||||
Loading…
Reference in New Issue
Block a user