mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-10-27 07:51:52 +00:00
feat: add governance system for prompt evolution
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]>
This commit is contained in:
1 parent
470093d9ad
commit
64b6f43df1
8 files changed
+606
No files matched your search
@@ -0,0 +1,45 @@
|
||||
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);
|
||||
});
|
||||
Reference in new issue
Block a user