Merge pull request #371 from PR0M3TH3AN/refactor/governance-apply-proposal-17916899384602246938

Refactor applyProposal to avoid redundant proposal fetch
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-02-20 16:34:54 -05:00
commit 9223d55e8c
2 files changed
+9 -11

No files matched your search

+9 -3
View File
@@ -132,8 +132,14 @@ export async function createProposal({ agent, target, newContent, reason }) {
return { id, diff };
}
export async function validateProposal(id) {
const { meta, newContent } = await getProposal(id);
export async function validateProposal(proposalOrId) {
let proposal;
if (typeof proposalOrId === 'string') {
proposal = await getProposal(proposalOrId);
} else {
proposal = proposalOrId;
}
const { meta, newContent } = proposal;
// 1. Allowlist check (redundant but safe)
const { isAllowed } = resolveAndValidateTarget(meta.target);
@@ -165,7 +171,7 @@ export async function applyProposal(id) {
throw new Error(`Proposal is ${meta.status}, cannot apply.`);
}
const validation = await validateProposal(id);
const validation = await validateProposal(proposal);
if (!validation.valid) {
// Mark as rejected if validation fails?
// Or just throw? The governance agent should decide.
-8
View File
@@ -1,8 +0,0 @@
{
"dashboard": {
"auth": "admin:password123",
"relays": [
"wss://secure.relay.com"
]
}
}