Replace monthly community goals with JARVIS server projects, staff review, scoped funding and automatic closure

This commit is contained in:
unimatrixgit 2026-11-18 23:56:35 +01:00
commit 3fab6cd650

View file

@ -15,6 +15,7 @@ const boundStore=tx=>({query:tx.query.bind(tx),first:tx.first.bind(tx),transacti
export function createProjectBanking(bank,{authorize,clock=Date.now}){
if(typeof authorize!=='function')throw TypeError('Project decision authority required');
return Object.freeze({
async exhausted(){return bank.query("SELECT p.project_id FROM jarvis_project_banking p JOIN pb_accounts a ON a.id=p.account_id WHERE p.state='funded' AND a.state='active' AND a.balance_minor=0 AND a.reserved_minor=0 AND NOT EXISTS(SELECT 1 FROM pb_orders o WHERE (o.source_id=a.id OR o.target_id=a.id) AND o.state IN ('queued','pending')) ORDER BY p.funded_at,p.project_id LIMIT 20");},
async fund(actor,input){
const {projectId,applicantId,requestId,title,amountMinor}=input||{};
if(!input||Object.keys(input).some(k=>!['projectId','applicantId','requestId','title','amountMinor'].includes(k))||!uuid(actor?.id)||!uuid(projectId)||!uuid(applicantId)||!uuid(requestId)||typeof title!=='string'||!title.trim()||title.length>100||!Number.isSafeInteger(amountMinor)||amountMinor<1||amountMinor>1000000000000)throw TypeError('Invalid approved project funding');