mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-10-27 07:51:52 +00:00
Implement a comprehensive governance system to manage agent prompt changes safely. Key features: - **Proposal Workflow:** Prompt changes are now "proposals" stored in `src/proposals/` with metadata and diffs. - **Governance Agent:** A new `governance-agent` reviews and applies proposals using `scripts/governance/process-proposals.mjs`. - **Validation:** Strict validation ensures changes are limited to allowed directories (`src/prompts/daily|weekly`) and preserve required headers. - **Lock Enhancements:** Lock events now include `promptHash`, `promptPath`, and `gitCommit` for full auditability. - **Rollback:** New `torch-lock rollback` command restores prompts from local history (`.torch/prompt-history/`) or git. - **CLI:** Added `proposal` (create, list, show, apply, reject) and `rollback` commands. This establishes a "Stage -> Evaluate -> Apply" gate for prompt evolution, preventing silent drift and ensuring constitutional stability. Co-authored-by: PR0M3TH3AN <[email protected]>
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
import { listProposals, applyProposal, rejectProposal, validateProposal } from '../../src/services/governance/index.js';
|
|
|
|
async function main() {
|
|
console.log('Governance: Scanning for pending proposals...');
|
|
const proposals = await listProposals();
|
|
const pending = proposals.filter(p => p.status === 'pending');
|
|
|
|
if (pending.length === 0) {
|
|
console.log('No pending proposals found.');
|
|
return;
|
|
}
|
|
|
|
console.log(`Found ${pending.length} pending proposals.`);
|
|
|
|
for (const p of pending) {
|
|
console.log(`\nProcessing proposal: ${p.id} (Target: ${p.target})`);
|
|
|
|
// 1. Validate
|
|
const validation = await validateProposal(p.id);
|
|
if (!validation.valid) {
|
|
console.error(` Validation FAILED: ${validation.reason}`);
|
|
await rejectProposal(p.id, validation.reason);
|
|
console.log(` Rejected proposal ${p.id}.`);
|
|
continue;
|
|
}
|
|
console.log(' Validation PASSED.');
|
|
|
|
// 2. Apply
|
|
try {
|
|
await applyProposal(p.id);
|
|
console.log(` Applied proposal ${p.id} successfully.`);
|
|
} catch (e) {
|
|
console.error(` Application FAILED: ${e.message}`);
|
|
// Maybe reject with application error?
|
|
await rejectProposal(p.id, `Application failed: ${e.message}`);
|
|
}
|
|
}
|
|
|
|
console.log('\nGovernance cycle complete.');
|
|
}
|
|
|
|
main().catch(err => {
|
|
console.error('Fatal error in governance script:', err);
|
|
process.exit(1);
|
|
});
|