diff --git a/website/control-panel/public/cp-v2/cp-v2-decision-audit.mjs b/website/control-panel/public/cp-v2/cp-v2-decision-audit.mjs index ea2d3975..20352e8f 100644 --- a/website/control-panel/public/cp-v2/cp-v2-decision-audit.mjs +++ b/website/control-panel/public/cp-v2/cp-v2-decision-audit.mjs @@ -13,7 +13,7 @@ const related={ const authority={IMP:'Current Emperor deed',ATR:'Current Aerdrecht House office deed',HAR:'Current Harkveen House office deed',COR:'Current Korenholt House office deed',ORD:'Current Oordwijk House office deed',FRE:'Current recognised sietch deed; independent Council',BG:'Current Veiled Concord office deed',NF:'Current Church of Muad’Dib office deed',SG:'Current Spacing Guild office deed',CLD:'Current clan delegate deed'}; function paidDecisionGap(id){ const kind=politicalDecision(id)?.kind,base='Current office, Reputation, authorised office funding and successor-safe cooldown checked atomically. '; - return base+(kind==='ballot'?'Paid consultation records a frozen institutional electorate. Current independent clan owners or original Royal Great House mandates cast one signed vote per seat; no personal election allocation is consumed. Shared quorum and strict-majority tally closes once; ties and low participation fail. This is a nonbinding resolution, with no automatic law or war change.':kind==='agreement'?'A confidential proposal is delivered only to its original receiving office holder or legal company owner. Acceptance or refusal requires that same current mandate or company ownership, a signed response and the 72-hour window. Accepted terms expire with either mandate; no votes, ownership or war rights move.':kind==='clan-grant'?'The current native clan deed selects its own active bank account or its legal Basic owner. The balanced transfer, recorded purpose and proportional Reputation commit together; retries cannot pay twice.':kind==='report'?'Verified aggregate snapshot, fee and reward share one receipt; no private identities or balances are disclosed.':kind==='event'?'The existing political calendar and event history commit with the fee and reward; a diplomatic meeting does not manufacture participant consent.':['tariff','guild-discount'].includes(kind)?'The latest signed current-mandate policy controls new Guild quote and boarding fares. Confirmed tickets retain their amount; no travel or embargo rights change.':'Existing publication/profile consumers display the result.'); + return base+(kind==='ballot'?'Paid consultation records a frozen institutional electorate. Current independent clan owners or original Royal Great House mandates cast one signed vote per seat; no personal election allocation is consumed. Shared quorum and strict-majority tally closes once; ties and low participation fail. This is a nonbinding resolution, with no automatic law or war change.':kind==='agreement'&&politicalDecision(id).agreementMode==='petition'?'A confidential petition requires a signed response from its original receiving Royal holder within72h. Acknowledgement is historical receipt only; hearings, votes and concession changes require separate authorised actions. No bank, vote, ownership or war rights change.':kind==='agreement'?'A confidential proposal is delivered only to its original receiving office holder or legal company owner. Acceptance or refusal requires that same current mandate or company ownership, a signed response and the 72-hour window. Accepted terms expire with either mandate; no votes, ownership or war rights move.':kind==='clan-grant'?'The current native clan deed selects its own active bank account or its legal Basic owner. The balanced transfer, recorded purpose and proportional Reputation commit together; retries cannot pay twice.':kind==='report'?'Verified aggregate snapshot, fee and reward share one receipt; no private identities or balances are disclosed.':kind==='event'?'The existing political calendar and event history commit with the fee and reward; a diplomatic meeting does not manufacture participant consent.':['tariff','guild-discount'].includes(kind)?'The latest signed current-mandate policy controls new Guild quote and boarding fares. Confirmed tickets retain their amount; no travel or embargo rights change.':'Existing publication/profile consumers display the result.'); } export const DECISION_AUDIT=Object.freeze(DECISION_CATALOGUE.map(d=>Object.freeze({id:d.id,office:d.office,status:naibDecision(d.id)||houseFaithDecision(d.id)||clanFaithDecision(d.id)||tradeDecision(d.id)||politicalDecision(d.id)||d.id==='IMP-10'||faithBlessing(d.id)?'active':'design',currency:'DM',amountConversion:1,authority:authority[d.office],conditions:'Current unexpired and unrevoked deed, eligible target and all stated effect conditions must be checked by the domain consumer. Level and XP do not grant office authority.',costCooldown:d.cost,effect:d.effect,level:d.level,proposedXP:d.xp,adapter:naibDecision(d.id)?'createNaibCouncil / createNaibCouncilFunding':houseFaithDecision(d.id)?'createHouseFaithLaws / missionaryFaithOutlawed':clanFaithDecision(d.id)?'createClanFaith.offer / reply':tradeDecision(d.id)?'createWorldTradeGovernance / createGameExchangeService / createGuildService':politicalDecision(d.id)?'createPoliticalDecisions':faithBlessing(d.id)?'createFaithBlessings / faithAward':d.id==='IMP-10'?'createImperialPassage / createGuildService':related[d.id]?.adapter||null,gap:naibDecision(d.id)?'Current independent sietch deed, Reputation'+naibDecision(d.id).level+','+naibDecision(d.id).feeMinor/100+'DM from its active account or the legal Basic owner,'+naibDecision(d.id).xp+' Reputation and'+naibDecision(d.id).cooldownMs/3600000+'h seat cooldown. Fee, signed key, proposal electorate and reward commit together. No free production fallback; one Council vote per current sietch. Personal election votes are unchanged.':houseFaithDecision(d.id)?'Royal House authority and Reputation checked before a sealed 48-hour personal referendum. Seven-day office cooldown survives succession; quorum and strict majority required. Only future invitations and clan-owner acceptance are gated by the latest live law; existing allegiance and earned rewards remain unchanged.':clanFaithDecision(d.id)?'Current faith officer can invite; only the receiving clan’s legal owner can consent. Daily invitation and seven-day clan-change cooldowns are enforced; no membership or rights move.':tradeDecision(d.id)?'Current Royal office and Reputation, immutable creation-world metadata, seven-day cooldown, retained stock and atomic seller-funded bank levy; no default activation.':politicalDecision(d.id)?paidDecisionGap(d.id):faithBlessing(d.id)?'Current faith leader/officer deed, owner-approved clan allegiance, appointment expiry and cooldown are checked centrally. Old Faith and New Faith use the same capped bonus consumer; historical queued rewards retain their claim-time consent proof.':d.id==='IMP-10'?'Native House selection replaces the prior grant; seven-day office cooldown and current Emperor deed are checked centrally.':related[d.id]?.gap||'No complete registered domain consumer implements this exact target, price, cooldown, duration and effect. Execution remains unavailable.',repeatability:'Only after the stated cooldown; no implied stacking or automatic renewal.',executionEnabled:!!naibDecision(d.id)||!!houseFaithDecision(d.id)||!!clanFaithDecision(d.id)||!!tradeDecision(d.id)||!!politicalDecision(d.id)||d.id==='IMP-10'||!!faithBlessing(d.id)}))); export const decisionAudit=id=>DECISION_AUDIT.find(row=>row.id===id)||null; diff --git a/website/control-panel/public/cp-v2/cp-v2-political-agreements.mjs b/website/control-panel/public/cp-v2/cp-v2-political-agreements.mjs index 97084ca3..8f307c1e 100644 --- a/website/control-panel/public/cp-v2/cp-v2-political-agreements.mjs +++ b/website/control-panel/public/cp-v2/cp-v2-political-agreements.mjs @@ -1,12 +1,12 @@ import {element as el} from './cp-v2-page-template.mjs'; import {createUserAPI} from './cp-v2-user-api.mjs'; export function mountPoliticalAgreements(host,{fetcher=fetch}={}){ - const root=el('section',undefined,'cp-political-agreement-inbox'),heading=el('h3','Diplomatic proposals'),status=el('p','Reading your diplomatic proposals…'),list=el('div'),refresh=el('button','Refresh proposals'),api=createUserAPI(fetcher); + const root=el('section',undefined,'cp-political-agreement-inbox'),heading=el('h3','Proposals and petitions'),status=el('p','Reading your proposals and petitions…'),list=el('div'),refresh=el('button','Refresh proposals'),api=createUserAPI(fetcher); status.setAttribute('role','status');refresh.type='button';root.append(heading,status,list,refresh);host.append(root);let busy=false; - async function load(){if(busy)return;busy=true;refresh.disabled=true;try{const data=await api.request('/api/politics/agreements');if(!root.isConnected)return;list.replaceChildren();status.textContent=data.agreements.length?'Only proposals addressed to you or issued by you are shown.':'No diplomatic proposals for your current account.'; - for(const a of data.agreements){const card=el('article'),title=el('h4',a.title),terms=el('p',a.terms),state=el('p',a.sourceOffice.replaceAll('_',' ')+' → '+(a.targetName||a.targetOffice.replaceAll('_',' '))+' · '+a.state),deadline=el('p',(a.endsAt?'Ends: ':'Reply before: ')+new Date(a.endsAt||a.responseUntil).toLocaleString());card.append(title,terms,state,deadline,el('small','J.A.R.V.I.S. reference: '+a.reference)); - if(a.canReply){const review=el('p'),confirm=el('button','Confirm response'),cancel=el('button','Cancel'),accept=el('button','Review acceptance'),decline=el('button','Review refusal');for(const b of [confirm,cancel,accept,decline])b.type='button';confirm.hidden=cancel.hidden=true;let pending=null; - const prepare=choice=>{pending={proposalId:a.id,requestId:crypto.randomUUID(),choice,confirmed:true};review.textContent=(choice==='accept'?'Accept':'Decline')+' “'+a.title+'”? This does not change votes, offices, ownership, travel or war participation.';confirm.hidden=cancel.hidden=false;accept.disabled=decline.disabled=true;};accept.onclick=()=>prepare('accept');decline.onclick=()=>prepare('decline');cancel.onclick=()=>{pending=null;review.textContent='';confirm.hidden=cancel.hidden=true;accept.disabled=decline.disabled=false;}; + async function load(){if(busy)return;busy=true;refresh.disabled=true;try{const data=await api.request('/api/politics/agreements');if(!root.isConnected)return;list.replaceChildren();status.textContent=data.agreements.length?'Only proposals addressed to you or issued by you are shown.':'No proposals or petitions for your current account.'; + for(const a of data.agreements){const card=el('article'),title=el('h4',a.title),terms=el('p',a.terms),state=el('p',a.sourceOffice.replaceAll('_',' ')+' → '+(a.targetName||a.targetOffice.replaceAll('_',' '))+' · '+a.state),deadline=el('p',(a.mode==='petition'&&a.respondedAt?'Responded: ':a.endsAt?'Ends: ':'Reply before: ')+new Date(a.mode==='petition'&&a.respondedAt||a.endsAt||a.responseUntil).toLocaleString());card.append(title,terms,state,deadline,el('small','J.A.R.V.I.S. reference: '+a.reference)); + if(a.canReply){const review=el('p'),confirm=el('button','Confirm response'),cancel=el('button','Cancel'),accept=el('button',a.mode==='petition'?'Review acknowledgement':'Review acceptance'),decline=el('button','Review refusal');for(const b of [confirm,cancel,accept,decline])b.type='button';confirm.hidden=cancel.hidden=true;let pending=null; + const prepare=choice=>{pending={proposalId:a.id,requestId:crypto.randomUUID(),choice,confirmed:true};review.textContent=(choice==='accept'?(a.mode==='petition'?'Acknowledge receipt of':'Accept'):'Decline')+' “'+a.title+'”? This does not change votes, offices, ownership, travel or war participation.';confirm.hidden=cancel.hidden=false;accept.disabled=decline.disabled=true;};accept.onclick=()=>prepare('accept');decline.onclick=()=>prepare('decline');cancel.onclick=()=>{pending=null;review.textContent='';confirm.hidden=cancel.hidden=true;accept.disabled=decline.disabled=false;}; confirm.onclick=async()=>{if(!pending||busy)return;busy=true;confirm.disabled=cancel.disabled=refresh.disabled=true;try{await api.request('/api/politics/agreements',pending);pending=null;busy=false;await load();}catch(error){status.textContent=error.message+(error.uncertain?' Retry this same response to check its recorded result.':'');if(!error.uncertain)cancel.onclick();}finally{busy=false;confirm.disabled=cancel.disabled=refresh.disabled=false;}}; card.append(accept,decline,review,confirm,cancel); }list.append(card); diff --git a/website/control-panel/public/cp-v2/cp-v2-political-decisions.mjs b/website/control-panel/public/cp-v2/cp-v2-political-decisions.mjs index acbe8a34..67e1607e 100644 --- a/website/control-panel/public/cp-v2/cp-v2-political-decisions.mjs +++ b/website/control-panel/public/cp-v2/cp-v2-political-decisions.mjs @@ -9,7 +9,7 @@ export function mountPoliticalDecision(host,id,{fetcher=fetch}={}){ function field(title,tag){const label=el('label',title),input=el(tag);label.append(input);form.append(label);fields.push(input);return input;} const account=field('Office funding account','select');let title,body,recipient,citation,search,find,startsAt,endsAt,percent,houseSelect,clanSelect,grantAmount,grantReason,officeSelect; if(d.kind==='ballot'){title=field('Resolution title','input');title.maxLength=100;body=field('Resolution and consultation terms','textarea');body.minLength=20;body.maxLength=4000;body.rows=6;form.append(el('p',d.electorate==='houses'?'One institutional vote per current Royal Great House. A resolution does not automatically change laws or personal voting rights.':'One institutional vote per native Caladan clan, exercised by its current legal owner. The result is nonbinding and does not consume personal election votes.'));} - else if(d.kind==='agreement'){officeSelect=field(d.targetKind==='company'?'Receiving company':'Receiving political office','select');title=field('Proposal title','input');title.maxLength=100;body=field('Confidential diplomatic terms','textarea');body.minLength=20;body.maxLength=4000;body.rows=6;form.append(el('p','The receiving current legal company owner or Royal office holder must consent within 72 hours. Accepted terms last at most '+d.durationMs/86400000+' days and end with '+(d.targetKind==='company'?'the issuing mandate or a change of company ownership':'either mandate')+'. No votes, ownership, war, bank or travel rights are transferred.'));} + else if(d.kind==='agreement'){officeSelect=field(d.targetKind==='company'?'Receiving company':'Receiving political office','select');title=field('Proposal title','input');title.maxLength=100;body=field(d.agreementMode==='petition'?'Petition and requested action':'Confidential diplomatic terms','textarea');body.minLength=20;body.maxLength=4000;body.rows=6;form.append(el('p',d.agreementMode==='petition'?'Request a signed response from the original receiving Royal office holder within 72 hours. Acknowledgement records receipt only. Hearings, votes, grants and concession changes require their own authorised actions.':'The receiving current legal company owner or Royal office holder must consent within 72 hours. Accepted terms last at most '+d.durationMs/86400000+' days and end with '+(d.targetKind==='company'?'the issuing mandate or a change of company ownership':'either mandate')+'. No votes, ownership, war, bank or travel rights are transferred.'));} else if(d.kind==='proclamation'){title=field('Title','input');title.maxLength=120;title.minLength=3;body=field('Official message','textarea');body.maxLength=6000;body.minLength=10;body.rows=6;} else if(d.kind==='event'){title=field('Session title','input');title.maxLength=100;body=field('Purpose and invitation','textarea');body.maxLength=2000;body.rows=4;startsAt=field('Start time (UTC)','input');endsAt=field('End time (UTC)','input');startsAt.type=endsAt.type='datetime-local';form.append(el('p','Schedule at least one minute ahead and no more than 30 days ahead. The session must finish before your mandate ends and last at most '+(d.maxEventMs||86400000)/3600000+' hours. It appears in the existing political calendar.'));if(d.id==='SG-06')form.append(el('p','This convenes voluntary mediation. Participants must separately approve any treaty, coalition or peace through its existing consent flow.'));} else if(d.kind==='tariff'){percent=field('Guild surcharge','select');for(let n=0;n<=5;n++){const o=el('option',n===0?'0% · repeal':n+'%');o.value=String(n);percent.append(o);}form.append(el('p','Applies to new Guild bookings for seven days, while this mandate remains current. Confirmed fares remain unchanged. It does not open blocked routes or change smuggler fares.'));} diff --git a/website/control-panel/public/jarvis-master-keys.mjs b/website/control-panel/public/jarvis-master-keys.mjs index 41054cfe..e4b18904 100644 --- a/website/control-panel/public/jarvis-master-keys.mjs +++ b/website/control-panel/public/jarvis-master-keys.mjs @@ -19,6 +19,7 @@ export const MASTER_KEY_TEMPLATES=[ action('politics.naib-accord-withdraw','Withdraw a sietch accord consent','organisation-action',[field('dossierId','Closed Council dossier UUID'),field('requestId','Withdrawal UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createNaibCouncil.withdraw / withdrawCouncilAccord',executionStatus:'current-original-consenting-sietch-owner-only',effect:'Use the existing Council audit transaction to withdraw the current sietch from a funded, accepted and unexpired accord. Recheck current independent ownership and the original yes vote; mother control and successor ownership do not inherit consent. Record a single idempotent withdrawal event without deleting the historical vote, charging money or awarding Reputation. No arbitrary JARVIS key is issued by this ordinary Council event flow.'}), action('politics.naib-council-assembly','Fund an independent sietch Council proposal','entity-state',[field('kind','Registered Council decision','select',{options:['decision','defense-coalition','water-sharing','desert-alliance']}),field('requestId','Council request UUID'),field('sourceAccount','Authorised sietch funding account'),field('title','Council proposal title'),field('message','Consultation terms','textarea')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createNaibCouncil.propose / createNaibCouncilFunding',executionStatus:'current-independent-sietch-owner-funded-council',effect:'FRE01 uses the existing24h Council, current independent Naib ownership and one institutional vote per recognised sietch. Reputation10,1000DM to Tax and200 Reputation points;24h seat cooldown survives ownership transfer. Keyed sietches fund their own active payment account; Basic sietches use the current legal owner’s active personal account. Source authority, balances, Reputation, ordinary scoped ESK key and complete dossier commit atomically. FRE02:15000DM,400 Reputation,level25,7d cooldown and7d defensive accord. FRE03:2500DM,300 Reputation,level20,72h cooldown and7d water-sharing accord. FRE06:5000DM,500 Reputation,level30,7d cooldown and14d alliance. All use24h Council consent, frozen institutional electorate and the existing quorum rule. Only current sietches whose original Naib voted yes join; they may withdraw through the normal Council audit flow. No automatic war consent or delivery is fabricated. No free production fallback or extra charge/reward for voting. Personal election rights and Imperial appointment authority remain unchanged.'}), action('politics.company-consortium','Ordos confidential company consortium','entity-state',[field('decisionId','Company agreement','select',{options:['ORD-02']}),field('sourceAccount','Authorised Ordos funding account'),field('targetCompanyId','Receiving active company UUID'),field('title','Proposal title'),field('terms','Confidential commercial terms','textarea'),field('requestId','Request UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createPoliticalDecisions.execute / createPoliticalAgreements / readCompanyDeed',executionStatus:'current-ordos-office-and-original-company-owner-consent',effect:'Current Royal Ordos holder,Reputation35,5000DM,600 Reputation and7d cooldown. Reuse the confidential bilateral proposal flow, with72h response by a different current legal owner of an active company. CEO or mother-company control never substitutes for ownership. Accepted terms last at most14d, clipped to the source mandate, and end on ownership change. Separate typed company reply proofs preserve existing office replies without altering their table. No ownership, corporate control, bank, vote or war rights change.'}), + action('politics.clan-petition','Clan Delegate petition','entity-state',[field('decisionId','Petition','select',{options:['CLD-01','CLD-03','CLD-05']}),field('sourceAccount','Authorised Clan Delegate office account'),field('targetOffice','Receiving Royal office'),field('title','Petition title'),field('terms','Petition and requested action','textarea'),field('requestId','Request UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createPoliticalDecisions.execute / createPoliticalAgreements',executionStatus:'current-delegate-funded-signed-petition-response',effect:'Three fixed Clan Delegate policies use their published office fee, Reputation requirement and successor-safe cooldown. Another current Royal holder has72h to acknowledge or decline. Both original mandates must cover the response window. A signed acknowledgement remains history; it does not create a hearing, vote, concession, grant, appointment or war.'}), action('politics.diplomatic-proposal','Confidential diplomatic proposal','entity-state',[field('decisionId','Diplomatic decision','select',{options:['ATR-05','COR-06','ORD-05','BG-05','NF-05']}),field('sourceAccount','Authorised office funding account'),field('targetOffice','Receiving Royal office'),field('title','Proposal title'),field('terms','Confidential diplomatic terms','textarea'),field('requestId','Request UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createPoliticalDecisions.execute / createPoliticalAgreements',executionStatus:'current-officeholder-bilateral-consent-consumer',effect:'Five fixed diplomatic policies charge the published office fee and award Reputation atomically with a confidential proposal. A different current Royal office holder must answer within72h; both mandates must cover that full window. Accepted terms last at most7d, or14d for Corrino, and end with either original mandate. Original participants alone see the terms. No votes, ownership, bank authority, travel or war consent move.'}), action('politics.diplomatic-response','Accept or refuse a diplomatic proposal','entity-state',[field('proposalId','Proposal UUID'),field('choice','Response','select',{options:['accept','decline']}),field('requestId','Response UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createPoliticalAgreements.reply',executionStatus:'original-receiving-officeholder-consent-consumer',effect:'Only the original receiving current Royal mandate can accept or refuse a live72h proposal. Recheck both original mandates and the unrevoked signed proposal under the same transaction; record one signed response. Exact retries return the original receipt; conflicting responses, changed holders, expired or revoked proposals cannot manufacture acceptance. No further payment or Reputation is issued for replying.'}), action('politics.clan-development-grant','Office clan development allocation','entity-state',[field('decisionId','Registered development grant','select',{options:['ATR-01','ATR-04','HAR-02','COR-02','COR-04','NF-03']}),field('sourceAccount','Authorised House funding account'),field('clanId','Receiving clan UUID'),field('amountMinor','Development allocation in DM minor units','number',{min:10000}),field('reason','Development purpose','textarea'),field('requestId','Request UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createPoliticalDecisions.execute / createPoliticalClanGrants / organisationRewardRoute',executionStatus:'current-house-office-and-current-clan-deed-consumer',effect:'House development policies re-read the native clan homeworld, current legal deed, active receiving bank account and authorised House source. Atreides Patronage is exactly10,000 DM; other published grants range from100 DM to their15,000/25,000 DM cap. Basic clans route to their current legal owner, keyed clans to their own account; mother control never substitutes for that owner. Actual funded amount scales Reputation up to the catalogue cap. Existing balanced bank transfer, immutable purpose, ordinary key and Reputation commit together; safe retries retain the original payment recipient. Church sponsorship additionally requires current signed New Faith consent, caps funding at10,000 DM and pays a separate2,500 DM Tax admin fee; grant, fee and proportional Reputation commit or roll back together, with a7d cooldown. No P&O issuance, account activation, construction completion, inventory progress or ownership change is fabricated.'}), diff --git a/website/control-panel/public/political-decision-policy.mjs b/website/control-panel/public/political-decision-policy.mjs index b26c2485..2377e68a 100644 --- a/website/control-panel/public/political-decision-policy.mjs +++ b/website/control-panel/public/political-decision-policy.mjs @@ -1,5 +1,10 @@ // Fixed catalogue prices are DM minor units. Browser fields cannot override policy. export const POLITICAL_DECISIONS=Object.freeze([ + ...[ + ['CLD-01','Clan Petition',10,200,100000,48], + ['CLD-03','Challenge Concession',35,600,250000,72], + ['CLD-05','Demand Representation',30,500,250000,72] + ].map(([id,title,level,xp,feeMinor,hours])=>({id,office:'clan_delegate',title,level,xp,feeMinor,cooldownMs:hours*3600000,kind:'agreement',agreementMode:'petition',responseMs:72*3600000,durationMs:0})), ...[ ['ATR-05','atreides','Diplomatic Envoy',30,500,250000,48,7], ['COR-06','corrino','Dynastic Alliance',35,600,500000,168,14], @@ -41,4 +46,4 @@ export const POLITICAL_DECISIONS=Object.freeze([ ].map(d=>Object.freeze({...d,durationMs:d.durationMs??(d.kind==='honour'?30*86400000:null)}))); export const politicalDecision=id=>POLITICAL_DECISIONS.find(d=>d.id===id)||null; export function proclamationDecisionId(kind,faction){return kind==='imperial'?'IMP-04':kind==='guild'?'SG-PROCLAIM':kind==='house'?({atreides:'ATR-PROCLAIM',harkonnen:'HAR-PROCLAIM',corrino:'COR-PROCLAIM',ordos:'ORD-PROCLAIM',veiled_concord:'BG-04',muad_dib:'NF-04'})[faction]||null:null;} -export const POLITICAL_DECISION_CATALOGUE=Object.freeze(POLITICAL_DECISIONS.map(d=>Object.freeze({...d,office:({emperor:'IMP',atreides:'ATR',harkonnen:'HAR',corrino:'COR',ordos:'ORD',veiled_concord:'BG',muad_dib:'NF',spacing_guild:'SG'})[d.office],cost:(d.kind==='clan-grant'?(d.grantMinMinor===d.grantMaxMinor?(d.grantMaxMinor/100).toLocaleString('en-GB'):'Grant amount')+(d.feeMinor?' + '+(d.feeMinor/100).toLocaleString('en-GB')+' admin':''):(d.feeMinor/100).toLocaleString('en-GB'))+' / '+d.cooldownMs/3600000+'h',effect:d.kind==='ballot'?'Open a '+d.ballotMs/3600000+'-hour nonbinding resolution vote. '+(d.electorate==='houses'?'One seat for each currently occupied Royal Great House office. Its original mandate must still be current to vote.':'One seat for each current native Caladan clan, exercised by its legal owner; mother control does not confer a seat.')+' Frozen electorate; more-than-half participation and strict majority required. Ties fail. Personal election votes are untouched.':d.kind==='agreement'?(d.targetKind==='company'?'Send a confidential proposal to an active company. Its current legal owner must consent within 72 hours.':'Send a confidential diplomatic proposal to another current Royal office holder, who must consent within 72 hours.')+' Accepted terms last '+d.durationMs/86400000+' days at most and end with '+(d.targetKind==='company'?'the issuing mandate or a change of company ownership':'either mandate')+'. This records diplomatic terms without moving votes, ownership, military allegiance or bank rights.':d.kind==='clan-grant'?'Allocate '+(d.grantMaxMinor/100).toLocaleString('en-GB')+' DM'+(d.grantMinMinor===d.grantMaxMinor?'':' maximum')+(d.grantFaith?' from the Church to a clan with current signed New Faith consent. A separate 2,500 DM administrative fee goes to Tax.':' from this House to a current clan on its native world.')+' Basic clans receive through the current legal owner; other clans use their own account. Reputation scales with the amount; allocation and its purpose are recorded together.':d.kind==='guild-discount'?'Give one native House '+d.discountPercent+'% off new Guild bookings for '+d.durationMs/3600000+' hours. Preferred fares never stack, open routes, change boarding windows or override embargoes and Imperial Arrakis access.':d.kind==='tariff'?'Set a 0–5% surcharge on new Guild bookings for seven days; choose 0 to repeal. Existing confirmed fares remain unchanged.':d.kind==='event'?(d.effect||'Schedule an official audience in the existing House calendar. Fixed office funding, Reputation and cooldown; no election, membership or travel change.'):d.kind==='report'?'Read a sealed aggregate of available Exchange stock. Guild reports also include seven-day confirmed arrival totals. No passenger identities, private orders or account balances. Fixed office funding and cooldown.':d.kind==='proclamation'?'Publish an official message in this office’s existing proclamation archive. Fixed office funding and cooldown; no membership or voting rights change.':'Ceremonial profile recognition for '+d.durationMs/86400000+' days. No office, rank, vote or permission is granted.'}))); +export const POLITICAL_DECISION_CATALOGUE=Object.freeze(POLITICAL_DECISIONS.map(d=>Object.freeze({...d,office:({emperor:'IMP',atreides:'ATR',harkonnen:'HAR',corrino:'COR',ordos:'ORD',veiled_concord:'BG',muad_dib:'NF',spacing_guild:'SG',clan_delegate:'CLD'})[d.office],cost:(d.kind==='clan-grant'?(d.grantMinMinor===d.grantMaxMinor?(d.grantMaxMinor/100).toLocaleString('en-GB'):'Grant amount')+(d.feeMinor?' + '+(d.feeMinor/100).toLocaleString('en-GB')+' admin':''):(d.feeMinor/100).toLocaleString('en-GB'))+' / '+d.cooldownMs/3600000+'h',effect:d.kind==='ballot'?'Open a '+d.ballotMs/3600000+'-hour nonbinding resolution vote. '+(d.electorate==='houses'?'One seat for each currently occupied Royal Great House office. Its original mandate must still be current to vote.':'One seat for each current native Caladan clan, exercised by its legal owner; mother control does not confer a seat.')+' Frozen electorate; more-than-half participation and strict majority required. Ties fail. Personal election votes are untouched.':d.kind==='agreement'?d.agreementMode==='petition'?'Send a confidential petition to another current Royal office holder for a signed response within 72 hours. Acknowledgement records receipt only; any hearing, vote, grant, concession change or war still needs its own authorised action. An answered petition remains a historical record.':(d.targetKind==='company'?'Send a confidential proposal to an active company. Its current legal owner must consent within 72 hours.':'Send a confidential diplomatic proposal to another current Royal office holder, who must consent within 72 hours.')+' Accepted terms last '+d.durationMs/86400000+' days at most and end with '+(d.targetKind==='company'?'the issuing mandate or a change of company ownership':'either mandate')+'. This records diplomatic terms without moving votes, ownership, military allegiance or bank rights.':d.kind==='clan-grant'?'Allocate '+(d.grantMaxMinor/100).toLocaleString('en-GB')+' DM'+(d.grantMinMinor===d.grantMaxMinor?'':' maximum')+(d.grantFaith?' from the Church to a clan with current signed New Faith consent. A separate 2,500 DM administrative fee goes to Tax.':' from this House to a current clan on its native world.')+' Basic clans receive through the current legal owner; other clans use their own account. Reputation scales with the amount; allocation and its purpose are recorded together.':d.kind==='guild-discount'?'Give one native House '+d.discountPercent+'% off new Guild bookings for '+d.durationMs/3600000+' hours. Preferred fares never stack, open routes, change boarding windows or override embargoes and Imperial Arrakis access.':d.kind==='tariff'?'Set a 0–5% surcharge on new Guild bookings for seven days; choose 0 to repeal. Existing confirmed fares remain unchanged.':d.kind==='event'?(d.effect||'Schedule an official audience in the existing House calendar. Fixed office funding, Reputation and cooldown; no election, membership or travel change.'):d.kind==='report'?'Read a sealed aggregate of available Exchange stock. Guild reports also include seven-day confirmed arrival totals. No passenger identities, private orders or account balances. Fixed office funding and cooldown.':d.kind==='proclamation'?'Publish an official message in this office’s existing proclamation archive. Fixed office funding and cooldown; no membership or voting rights change.':'Ceremonial profile recognition for '+d.durationMs/86400000+' days. No office, rank, vote or permission is granted.'}))); diff --git a/website/integrations/osticket/dev-jarvis-catalogue.json b/website/integrations/osticket/dev-jarvis-catalogue.json index 36ad8408..ff4353ba 100644 --- a/website/integrations/osticket/dev-jarvis-catalogue.json +++ b/website/integrations/osticket/dev-jarvis-catalogue.json @@ -1,6 +1,6 @@ { "schemaVersion": 1, - "sourceHash": "a4dedf5da7944eec6a6d0416f55bedc33d7da0fe967be09b14349d243960bce7", + "sourceHash": "f471bc8245cd6298251b16fe702498ae1d15bdb102df64bc16f2173771105661", "actions": [ { "id": "war.coalition-consent", @@ -675,6 +675,66 @@ "webIssue": false, "recordOnly": true }, + { + "id": "politics.clan-petition", + "label": "POL & orders · Clan Delegate petition", + "version": 1, + "keyType": "entity-state", + "fields": [ + { + "name": "ticketId", + "label": "Ban / support ticket ID", + "type": "text", + "required": true, + "maxLength": 80 + }, + { + "name": "decisionId", + "label": "Petition", + "type": "select", + "required": true, + "options": [ + "CLD-01", + "CLD-03", + "CLD-05" + ] + }, + { + "name": "sourceAccount", + "label": "Authorised Clan Delegate office account", + "type": "text", + "required": true + }, + { + "name": "targetOffice", + "label": "Receiving Royal office", + "type": "text", + "required": true + }, + { + "name": "title", + "label": "Petition title", + "type": "text", + "required": true + }, + { + "name": "terms", + "label": "Petition and requested action", + "type": "textarea", + "required": true + }, + { + "name": "requestId", + "label": "Request UUID", + "type": "text", + "required": true + } + ], + "effect": "Three fixed Clan Delegate policies use their published office fee, Reputation requirement and successor-safe cooldown. Another current Royal holder has72h to acknowledge or decline. Both original mandates must cover the response window. A signed acknowledgement remains history; it does not create a hearing, vote, concession, grant, appointment or war.", + "fixedTargets": [], + "webIssue": false, + "recordOnly": true + }, { "id": "politics.diplomatic-proposal", "label": "POL & orders · Confidential diplomatic proposal", diff --git a/website/node/political-agreements.mjs b/website/node/political-agreements.mjs index b53b77bf..05d97c6d 100644 --- a/website/node/political-agreements.mjs +++ b/website/node/political-agreements.mjs @@ -42,9 +42,10 @@ export function createPoliticalAgreements(raw,keys,{clock=Date.now}={}){ if(![row.actor_id,row.recipient_id].includes(actor.id))return null;const v=await verified(tx,row,now);if(!v)return null; const reply=await tx.first('SELECT r.*,k.id verified_key FROM '+replyTable(v.d)+' r LEFT JOIN organisation_keys k ON k.id=r.key_id AND k.account_id=? AND k.key_type=\'entity-state\' AND k.scope_id=CONCAT(\'state:political-agreement-reply:\',r.request_id) AND k.revoked_at IS NULL WHERE r.decision_request=?',[STAFF_OFFICE_ACCOUNT_ID,row.request_id]); const replyValid=reply?.verified_key&&reply.actor_id===v.a.targetActorId&&(v.d.targetKind==='company'?reply.company_id===v.a.targetCompanyId:reply.term_id===v.a.targetTermId)&&['accept','decline'].includes(reply.choice)&&Number(reply.created_at)>=Number(row.created_at)&&Number(reply.created_at)o.key===v.a.targetOffice)?.scope||v.a.targetOffice,responseUntil:v.a.responseUntil,endsAt,state,canReply:state==='pending'&&actor.id===v.a.targetActorId,reference:row.key_id}; + const petition=v.d.agreementMode==='petition'; + const endsAt=!petition&&replyValid&&reply.choice==='accept'?Math.min(Number(reply.created_at)+v.a.durationMs,v.a.mandateUntil):null; + const state=petition&&replyValid?(reply.choice==='accept'?'acknowledged':'declined'):!v.mandates?'mandate-ended':reply&&!replyValid?'response-unavailable':replyValid?(reply.choice==='decline'?'declined':nowo.key===v.a.targetOffice)?.scope||v.a.targetOffice,responseUntil:v.a.responseUntil,endsAt,state,canReply:state==='pending'&&actor.id===v.a.targetActorId,reference:row.key_id}; } async function read(actor){const rows=await db.query('SELECT * FROM jarvis_political_decisions WHERE actor_id=? OR recipient_id=? ORDER BY created_at DESC,request_id DESC LIMIT 100',[actor.id,actor.id]),items=[];for(const row of rows){const item=await projection(db,row,actor,clock());if(item)items.push(item);}return{agreements:items};} async function reply(actor,input){ diff --git a/website/tests/political-decisions.test.mjs b/website/tests/political-decisions.test.mjs index 5e81af07..452b1d0f 100644 --- a/website/tests/political-decisions.test.mjs +++ b/website/tests/political-decisions.test.mjs @@ -225,6 +225,29 @@ async function diplomacyFixture(office='atreides'){ const agreements=createPoliticalAgreements(f.db,f.keys,{clock:f.clock}),service=createPoliticalDecisions(f.db,f.db,f.keys,{verifyStorage:async()=>null,authority:f.authority,clock:f.clock,agreements}); return{...f,agreements,service,targetOffice,targetTerm,proposal:(decisionId='ATR-05')=>({decisionId,requestId:randomUUID(),sourceAccount:String(f.source.id),targetOffice,title:'A diplomatic understanding',terms:'Both offices agree to maintain an open channel for peaceful diplomacy.',confirmed:true}),reply:(proposalId,choice='accept')=>({proposalId,choice,requestId:randomUUID(),confirmed:true})}; } + +test('three Clan Delegate petitions charge their fixed fee once and retain signed acknowledgement as history',async()=>{ + for(const id of ['CLD-01','CLD-03','CLD-05']){const f=await diplomacyFixture('clan_delegate');try{ + const d=POLITICAL_DECISIONS.find(d=>d.id===id),input=f.proposal(id),before=await f.db.first('SELECT balance_minor FROM pb_accounts WHERE id=?',[f.source.id]); + const receipt=await f.service.execute(f.people.Owner,input);assert.equal(receipt.agreement.durationMs,0);assert.equal(receipt.feeMinor,String(d.feeMinor));assert.equal(receipt.xp,d.xp);assert.equal((await f.service.execute(f.people.Owner,input)).keyId,receipt.keyId); + assert.equal((await f.db.first('SELECT balance_minor FROM pb_accounts WHERE id=?',[f.source.id])).balance_minor,before.balance_minor-d.feeMinor);assert.equal((await f.db.first('SELECT COUNT(*) n FROM pb_orders')).n,1); + await assert.rejects(f.service.execute(f.people.Owner,f.proposal(id)),/cooldown/i); + const response=f.reply(input.requestId),answer=await f.agreements.reply(f.people.Other,response);assert.equal((await f.agreements.reply(f.people.Other,response)).reference,answer.reference); + let item=(await f.agreements.read(f.people.Owner)).agreements[0];assert.equal(item.mode,'petition');assert.equal(item.state,'acknowledged');assert.equal(item.respondedAt,1000);assert.equal(item.endsAt,null);assert.equal(item.canReply,false); + await f.db.query("UPDATE political_office_terms SET outcome='ended'");f.setTime(1000+30*86400000);item=(await f.agreements.read(f.people.Owner)).agreements[0];assert.equal(item.state,'acknowledged');assert.equal((await f.agreements.read(f.people.Member)).agreements.length,0); + assert.equal((await f.db.first('SELECT COUNT(*) n FROM political_office_terms')).n,2);assert.equal((await f.db.first('SELECT COUNT(*) n FROM jarvis_entity_relations')).n,0);assert.equal((await f.db.first('SELECT COUNT(*) n FROM pb_orders')).n,1); + }finally{f.db.close();}} +}); +test('petitions reject expired recipients and forged prices, and never treat a revoked answer as acknowledgement',async()=>{ + const f=await diplomacyFixture('clan_delegate');try{ + await assert.rejects(f.service.execute(f.people.Owner,{...f.proposal('CLD-01'),feeMinor:0}),/Review and confirm/);assert.equal((await f.db.first('SELECT COUNT(*) n FROM pb_orders')).n,0); + const input=f.proposal('CLD-01');await f.service.execute(f.people.Owner,input);await f.db.query('UPDATE political_office_terms SET user_id=? WHERE id=?',[f.people.Member.id,f.targetTerm]);await assert.rejects(f.agreements.reply(f.people.Other,f.reply(input.requestId)),/expired/);await assert.rejects(f.agreements.reply(f.people.Member,f.reply(input.requestId)),/not addressed/); + await f.db.query('UPDATE political_office_terms SET user_id=? WHERE id=?',[f.people.Other.id,f.targetTerm]);const answer=await f.agreements.reply(f.people.Other,f.reply(input.requestId));await f.db.query('UPDATE organisation_keys SET revoked_at=1 WHERE id=?',[answer.reference]);const item=(await f.agreements.read(f.people.Owner)).agreements[0];assert.equal(item.state,'response-unavailable');assert.equal(item.canReply,false); + }finally{f.db.close();} +}); +test('petition refusal remains a historical signed response, while unanswered petitions expire',async()=>{ + const f=await diplomacyFixture('clan_delegate');try{const first=f.proposal('CLD-01'),second=f.proposal('CLD-03');await f.service.execute(f.people.Owner,first);await f.service.execute(f.people.Owner,second);await f.agreements.reply(f.people.Other,f.reply(first.requestId,'decline'));f.setTime(1000+72*3600000);const items=(await f.agreements.read(f.people.Owner)).agreements;assert.equal(items.find(i=>i.id===first.requestId).state,'declined');assert.equal(items.find(i=>i.id===second.requestId).state,'expired');await assert.rejects(f.agreements.reply(f.people.Other,f.reply(second.requestId)),/expired/);}finally{f.db.close();} +}); test('five diplomatic decisions deliver confidential proposals and require the original receiving mandate to consent',async()=>{ for(const [office,id]of [['atreides','ATR-05'],['corrino','COR-06'],['ordos','ORD-05'],['veiled_concord','BG-05'],['muad_dib','NF-05']]){const f=await diplomacyFixture(office);try{ const before=BigInt((await f.db.first('SELECT balance_minor FROM pb_accounts WHERE id=?',[f.source.id])).balance_minor),d=POLITICAL_DECISIONS.find(d=>d.id===id),input=f.proposal(id);assert((await f.service.read(f.people.Owner,id)).diplomacyTargets.some(o=>o.id===f.targetOffice));