Merge pull request 'Convene funded Guild mediation in the existing political calendar' (#587) from dev/MC:feature/guild-mediation-calendar-20261125 into main
All checks were successful
DuneRealms Web CI / web (push) Successful in 3m0s

This commit is contained in:
unimatrix 2026-11-25 02:06:11 +00:00
commit 97109ba015
7 changed files with 84 additions and 6 deletions

View file

@ -10,5 +10,9 @@ const related={
'FRE-01':{adapter:'createNaibCouncil',gap:'The independent Council vote already enforces current sietch deed, one vote per sietch, 24 hours, quorum and tie rejection. The v2.2 1,000 DM fee and quest XP award are not enabled.'}
};
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'};
export const DECISION_AUDIT=Object.freeze(DECISION_CATALOGUE.map(d=>Object.freeze({id:d.id,office:d.office,status: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: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: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)?'Current office, Reputation, authorised office funding and successor-safe cooldown checked atomically; existing publication/profile consumers display the result.':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:!!houseFaithDecision(d.id)||!!clanFaithDecision(d.id)||!!tradeDecision(d.id)||!!politicalDecision(d.id)||d.id==='IMP-10'||!!faithBlessing(d.id)})));
function paidDecisionGap(id){
const kind=politicalDecision(id)?.kind,base='Current office, Reputation, authorised office funding and successor-safe cooldown checked atomically. ';
return base+(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: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: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: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:!!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;

View file

@ -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;
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('Audience 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 audience must finish before your mandate ends and last at most 24 hours. It appears in the existing House calendar.'));}
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.'));}
else if(d.kind==='guild-discount'){houseSelect=field('Native House','select');for(const w of TRADE_WORLDS){const o=el('option',w.name+' · '+w.house);o.value=w.house;houseSelect.append(o);}form.append(el('p',d.discountPercent+'% preferred Guild fare for '+d.durationMs/3600000+' hours. The strongest eligible discount applies; discounts do not stack. It does not grant new routes, alter boarding windows or override an embargo or Imperial Arrakis permission.'));}
else if(d.kind==='honour'){search=field('Find recipient by player name','input');search.maxLength=64;find=el('button','Find players');find.type='button';form.append(find);recipient=field('Recipient','select');citation=field('Citation','textarea');citation.maxLength=2000;citation.rows=4;form.append(el('p','Ceremonial profile recognition for '+d.durationMs/86400000+' days. No office, rank, vote or permission is granted. Renewing replaces the displayed recognition.'));}

View file

@ -14,6 +14,7 @@ export const MASTER_KEY_TEMPLATES=[
action('company.subsidiary','Subsidiary founding','company-subsidiary',[field('parentCompanyId','Mother company'),field('recipient','Recipient')]),
action('company.royal','Royal company charter','staff-company-royal',[field('companyId','Company'),reference])]},
{id:'politics',label:'POL & orders',actions:[
action('politics.guild-mediation','Convene Guild mediation','entity-state',[field('decisionId','Mediation decision','select',{options:['SG-06']}),field('sourceAccount','Authorised Guild funding account'),field('title','Session title'),field('description','Dispute and invitation','textarea'),field('startsAt','Start UTC timestamp','number'),field('endsAt','End UTC timestamp','number'),field('requestId','Request UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createPoliticalDecisions.execute / createRealmEventRecord',executionStatus:'current-guild-officeholder-calendar-consumer',effect:'Current Royal Guild holder, Reputation35,5,000 DM office fee and600 Reputation points. A72h successor-safe cooldown; schedule voluntary mediation for at most72h, entirely within the source mandate and at most30 days ahead. Reuse the political EVT calendar and its existing management rights. Fee, calendar history, Reputation and ordinary key commit atomically. No automatic peace, treaty, war, coalition or participant consent is fabricated; participants use the existing mutual agreement flows.'}),
action('politics.guild-preferred-fare','Guild preferred House fares','entity-state',[field('decisionId','Guild decision','select',{options:['SG-02','SG-07']}),field('sourceAccount','Authorised Guild funding account'),field('house','Native House','select',{options:['atreides','harkonnen','corrino','ordos','fremen']}),field('requestId','Request UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createPoliticalDecisions.execute / currentGuildDiscount / createGuildService',executionStatus:'current-guild-officeholder-preferred-fare-consumer',effect:'Priority Passage: Reputation 15, fixed 2,500 DM Guild fee, 250 Reputation, 25% preferred fare for72h and48h cooldown. Guild Favour: Reputation10, 5,000 DM fee, 200 Reputation,10% for7d and7d cooldown. Latest signed grant per decision replaces the earlier House; current source mandate and expiry required. Only the strongest eligible discount applies after any surcharge. No new routes, boarding priority, embargo override, Imperial Arrakis permission or smuggler rate. Confirmed ticket fares remain immutable and no grant activates by default.'}),
action('politics.guild-surcharge','Guild transport surcharge','entity-state',[field('decisionId','Guild decision','select',{options:['SG-05']}),field('sourceAccount','Authorised Guild funding account'),field('percent','Surcharge percentage','number',{min:0,max:5}),field('requestId','Request UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createPoliticalDecisions.execute / currentGuildSurcharge / createGuildService',executionStatus:'current-guild-officeholder-fare-consumer',effect:'Royal Guild office holder, Reputation 40, fixed 5,000 DM office fee and 750 Reputation points. Seven-day successor-safe cooldown and at most seven-day 0–5% tariff, ending with its source mandate; 0 repeals. The latest signed unrevoked record controls new quote/boarding fares. Stale quotes cannot reserve funds. Existing confirmed fares and identical ticket retries retain their original amount; no route, embargo, Arrakis or smuggler right changes. No client plugin rollout or default activation.'}),
action('faith.diplomatic-endorsement','Church diplomatic endorsement','entity-state',[field('decisionId','Faith decision','select',{options:['NF-07']}),field('sourceAccount','Authorised Church funding account'),field('recipientId','Other active player UUID'),field('citation','Diplomatic citation','textarea'),field('requestId','Request UUID')],{version:1,webIssue:false,recordOnly:true,domainAdapter:'createPoliticalDecisions.execute / politicalHonours',executionStatus:'current-church-officeholder-only',effect:'Current Royal Church office holder, Reputation 15, fixed 2,500 DM Church-account fee and 250 Reputation points. Seven-day ceremonial diplomatic endorsement on the recipient profile; one decision per 72 hours across succession. No self-award, faith conversion, clan membership, appointment, vote, rank, permissions or bonus. Payment, recognition and ordinary instrument commit once; expiry and key revocation remove the display.'}),

View file

@ -11,6 +11,7 @@ export const POLITICAL_DECISIONS=Object.freeze([
{id:'SG-05',office:'spacing_guild',title:'Transport Surcharge',kind:'tariff',level:40,xp:750,feeMinor:500000,cooldownMs:7*86400000,durationMs:7*86400000},
{id:'SG-02',office:'spacing_guild',title:'Priority Passage',kind:'guild-discount',level:15,xp:250,feeMinor:250000,cooldownMs:48*3600000,durationMs:72*3600000,discountPercent:25},
{id:'SG-07',office:'spacing_guild',title:'Guild’s Favour',kind:'guild-discount',level:10,xp:200,feeMinor:500000,cooldownMs:7*86400000,durationMs:7*86400000,discountPercent:10},
{id:'SG-06',office:'spacing_guild',title:'Guild Mediation',kind:'event',level:35,xp:600,feeMinor:500000,cooldownMs:72*3600000,maxEventMs:72*3600000,effect:'Convene voluntary dispute mediation for at most 72 hours in the existing Guild calendar. Any treaty, peace or coalition still requires its parties’ existing consent flow.'},
...[
['ATR-PROCLAIM','atreides','Ducal Proclamation','house:atreides'],
['HAR-PROCLAIM','harkonnen','Baronial Directive','house:harkonnen'],
@ -23,4 +24,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.feeMinor/100).toLocaleString('en-GB')+' / '+d.cooldownMs/3600000+'h',effect: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'?'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'})[d.office],cost:(d.feeMinor/100).toLocaleString('en-GB')+' / '+d.cooldownMs/3600000+'h',effect: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.'})));

View file

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"sourceHash": "1d2dcdd67c61b1b3ed995573d6fb2a89546c70aada749ef7858183ab4e003df9",
"sourceHash": "911ce9d8c1487b76c1dede16b14dd125d291430f403bfc20757e324b512804d5",
"actions": [
{
"id": "war.coalition-consent",
@ -431,6 +431,70 @@
"webIssue": false,
"recordOnly": false
},
{
"id": "politics.guild-mediation",
"label": "POL & orders · Convene Guild mediation",
"version": 1,
"keyType": "entity-state",
"fields": [
{
"name": "ticketId",
"label": "Ban / support ticket ID",
"type": "text",
"required": true,
"maxLength": 80
},
{
"name": "decisionId",
"label": "Mediation decision",
"type": "select",
"required": true,
"options": [
"SG-06"
]
},
{
"name": "sourceAccount",
"label": "Authorised Guild funding account",
"type": "text",
"required": true
},
{
"name": "title",
"label": "Session title",
"type": "text",
"required": true
},
{
"name": "description",
"label": "Dispute and invitation",
"type": "textarea",
"required": true
},
{
"name": "startsAt",
"label": "Start UTC timestamp",
"type": "number",
"required": true
},
{
"name": "endsAt",
"label": "End UTC timestamp",
"type": "number",
"required": true
},
{
"name": "requestId",
"label": "Request UUID",
"type": "text",
"required": true
}
],
"effect": "Current Royal Guild holder, Reputation35,5,000 DM office fee and600 Reputation points. A72h successor-safe cooldown; schedule voluntary mediation for at most72h, entirely within the source mandate and at most30 days ahead. Reuse the political EVT calendar and its existing management rights. Fee, calendar history, Reputation and ordinary key commit atomically. No automatic peace, treaty, war, coalition or participant consent is fabricated; participants use the existing mutual agreement flows.",
"fixedTargets": [],
"webIssue": false,
"recordOnly": true
},
{
"id": "politics.guild-preferred-fare",
"label": "POL & orders · Guild preferred House fares",

View file

@ -31,7 +31,7 @@ export function decisionInput(input){
const payload=d.kind==='proclamation'?{title:clean(input.title,3,120),body:clean(input.body,10,6000)}:d.kind==='event'?{title:clean(input.title,3,100),description:clean(input.description,10,2000),startsAt:input.startsAt,endsAt:input.endsAt}:d.kind==='guild-discount'?{house:input.house,percent:d.discountPercent}:d.kind==='tariff'?{percent:input.percent}:d.kind==='report'?{}:{recipientId:input.recipientId,citation:clean(input.citation,3,2000)};
if(d.kind==='guild-discount'&&!TRADE_WORLDS.some(w=>w.house===payload.house))fail('Choose a native House for the preferred fare.',400);
if(d.kind==='tariff'&&(!Number.isInteger(payload.percent)||payload.percent<0||payload.percent>5))fail('Choose a Guild surcharge from 0 to 5 percent.',400);
if(d.kind==='event'&&(!Number.isSafeInteger(payload.startsAt)||!Number.isSafeInteger(payload.endsAt)||payload.startsAt<0||payload.endsAt<=payload.startsAt||payload.endsAt-payload.startsAt>86400000))fail('Choose a future audience lasting at most 24 hours.',400);
if(d.kind==='event'&&(!Number.isSafeInteger(payload.startsAt)||!Number.isSafeInteger(payload.endsAt)||payload.startsAt<0||payload.endsAt<=payload.startsAt||payload.endsAt-payload.startsAt>(d.maxEventMs||86400000)))fail('Choose a future session lasting at most '+(d.maxEventMs||86400000)/3600000+' hours.',400);
if(d.kind==='honour'&&!validUuid(payload.recipientId))fail('Choose an eligible recipient.',400);
return{d,requestId:input.requestId.toLowerCase(),sourceAccount:input.sourceAccount,payload};
}
@ -70,7 +70,7 @@ export function createPoliticalDecisions(db,bank,keys,deps={}){
const now=clock(),holder=await officeAuthority(tx,d,actor,now,true);if(!holder)fail('The current elected office holder is required.',403);
const prior=await tx.first('SELECT * FROM jarvis_political_decisions WHERE request_id=? FOR UPDATE',[requestId]);if(prior){if(prior.actor_id!==actor.id||prior.input_hash!==digest)fail('Decision reference already used.');return{...JSON.parse(prior.receipt_json),replayed:true};}
const latest=await tx.first('SELECT created_at FROM jarvis_political_decisions WHERE decision_id=? ORDER BY created_at DESC,request_id DESC LIMIT 1',[d.id]);if(latest&&now<Number(latest.created_at)+d.cooldownMs)fail('This office decision is still on cooldown.');
if(d.kind==='event'){const term=await tx.first('SELECT expires_at FROM political_office_terms WHERE id=?',[holder.termId]);if(payload.startsAt<now+60000||payload.startsAt>now+30*86400000||!term||payload.endsAt>Number(term.expires_at))fail('Schedule the audience at least one minute ahead, within 30 days and before this mandate ends.');}
if(d.kind==='event'){const term=await tx.first('SELECT expires_at FROM political_office_terms WHERE id=?',[holder.termId]);if(payload.startsAt<now+60000||payload.startsAt>now+30*86400000||!term||payload.endsAt>Number(term.expires_at))fail('Schedule the session at least one minute ahead, within 30 days and before this mandate ends.');}
if(d.kind==='honour'){
// Lock both the account and its current House link before revalidating the target.
await tx.first('SELECT id FROM site_accounts WHERE id=? FOR UPDATE',[payload.recipientId]);

View file

@ -28,6 +28,14 @@ async function fixture(office='emperor',extra={}){
}
test('catalogue prices, Reputation requirements and XP agree with connected policy',()=>{for(const d of POLITICAL_DECISIONS){const row=DECISION_CATALOGUE.find(r=>r.id===d.id);assert.equal(row.level,d.level);assert.equal(row.xp,d.xp);const [dm,hours]=row.cost.replaceAll(',','').split(' / ');assert.equal(Number(dm)*100,d.feeMinor);assert.equal(Number(hours.replace('h',''))*3600000,d.cooldownMs);}});
test('Guild mediation reuses the political calendar with a bounded 72-hour session and no unilateral peace',async()=>{
const f=await fixture('spacing_guild');try{
await f.pol.query('UPDATE jarvis_progression_accounts SET total_xp=100000,effective_xp=100000');for(const sql of EVENT_SCHEMA)await f.db.query(sql);
const input={decisionId:'SG-06',requestId:randomUUID(),sourceAccount:String(f.source.id),title:'Trade mediation',description:'Voluntary mediation between the two named Houses.',startsAt:100000,endsAt:100000+72*3600000,confirmed:true};
await assert.rejects(f.service.execute(f.people.Owner,{...input,endsAt:input.endsAt+1}),/at most 72/);const result=await f.service.execute(f.people.Owner,input),event=await f.db.first('SELECT * FROM jarvis_events WHERE id=?',[result.eventId]);assert.equal(event.scope_id,'spacing_guild');assert.equal(event.ends_at-event.starts_at,72*3600000);assert.equal((await f.db.first('SELECT balance_minor FROM pb_accounts WHERE id=?',[f.source.id])).balance_minor,1500000);assert.equal((await f.service.execute(f.people.Owner,input)).eventId,result.eventId);assert.equal((await f.db.first('SELECT COUNT(*) n FROM jarvis_events')).n,1);
}finally{f.db.close();}
});
test('preferred Guild House fares are fixed, non-stacking and replaced rather than revived across grants',async()=>{
const f=await fixture('spacing_guild');try{
const input=id=>({decisionId:id,requestId:randomUUID(),sourceAccount:String(f.source.id),confirmed:true,house:'atreides'});await assert.rejects(f.service.execute(f.people.Owner,{...input('SG-02'),house:'company'}),/native House/);await assert.rejects(f.service.execute(f.people.Owner,{...input('SG-02'),percent:100}),/Review/);