From 73aa88b670340bcaf77bb9356502e25aea2c5d9e Mon Sep 17 00:00:00 2001 From: unimatrix Date: Tue, 17 Nov 2026 19:10:09 +0000 Subject: [PATCH] 1.0.1.1: shared Realm CP copies, JARVIS key families and Realm Nexus navigation --- docs/design/REALM-CP-1.0.1.1.md | 51 ++++++ website/control-panel/clan-key-receipts.mjs | 6 +- website/control-panel/clans.mjs | 2 + .../control-panel/company-cp-reference.mjs | 7 + website/control-panel/company-cp-shell.mjs | 2 +- .../control-panel/politics-cp-reference.mjs | 16 ++ website/control-panel/politics-cp-shell.mjs | 23 +-- .../public/codex-code-format.mjs | 4 +- .../public/cp-v2/cp-v2-claims.mjs | 3 +- .../public/cp-v2/cp-v2-code-redemption.mjs | 70 ++++---- .../public/cp-v2/cp-v2-code-type-icon.mjs | 2 +- .../public/cp-v2/cp-v2-company-reference.mjs | 41 +++++ .../public/cp-v2/cp-v2-company-shell.mjs | 43 +---- .../public/cp-v2/cp-v2-exchange-design.mjs | 4 +- .../public/cp-v2/cp-v2-organisation-shell.css | 1 + .../public/cp-v2/cp-v2-organisation-shell.mjs | 48 +++++ .../public/cp-v2/cp-v2-politics-reference.mjs | 50 ++++++ .../public/cp-v2/cp-v2-politics-shell.mjs | 52 +----- .../public/cp-v2/cp-v2-rewards.mjs | 78 ++++----- .../public/organisation-dashboard.mjs | 46 ++--- website/control-panel/server.mjs | 8 +- website/node/jarvis-recruitment-policy.mjs | 10 ++ website/node/menu-badges.mjs | 2 +- website/node/organisation-keys.mjs | 165 ++++++++++-------- website/node/politics-workspace.mjs | 15 ++ website/node/subhouse-keys.mjs | 13 ++ website/scripts/build.mjs | 101 +++++------ website/scripts/main-menu.mjs | 28 +-- website/scripts/menu-updates.mjs | 4 +- website/scripts/realm-switch.mjs | 7 + website/tests/central-exchange-menu.test.mjs | 6 +- .../tests/jarvis-recruitment-policy.test.mjs | 15 ++ website/tests/menu-badges.test.mjs | 4 +- website/tests/organisation-cp-clones.test.mjs | 5 + .../tests/organisation-key-families.test.mjs | 4 + website/tests/political-cp.test.mjs | 6 +- website/tests/realm-switch.test.mjs | 3 + website/tests/shop-menu-stability.test.mjs | 2 +- website/web/government-cp.js | 4 +- website/web/government.html | 2 +- website/web/realm-hub.css | 1 + website/web/realm-hub.html | 1 + website/web/release.json | 18 +- 43 files changed, 594 insertions(+), 379 deletions(-) create mode 100644 docs/design/REALM-CP-1.0.1.1.md create mode 100644 website/control-panel/company-cp-reference.mjs create mode 100644 website/control-panel/politics-cp-reference.mjs create mode 100644 website/control-panel/public/cp-v2/cp-v2-company-reference.mjs create mode 100644 website/control-panel/public/cp-v2/cp-v2-organisation-shell.css create mode 100644 website/control-panel/public/cp-v2/cp-v2-organisation-shell.mjs create mode 100644 website/control-panel/public/cp-v2/cp-v2-politics-reference.mjs create mode 100644 website/node/jarvis-recruitment-policy.mjs create mode 100644 website/node/politics-workspace.mjs create mode 100644 website/node/subhouse-keys.mjs create mode 100644 website/scripts/realm-switch.mjs create mode 100644 website/tests/jarvis-recruitment-policy.test.mjs create mode 100644 website/tests/organisation-cp-clones.test.mjs create mode 100644 website/tests/organisation-key-families.test.mjs create mode 100644 website/tests/realm-switch.test.mjs create mode 100644 website/web/realm-hub.css create mode 100644 website/web/realm-hub.html diff --git a/docs/design/REALM-CP-1.0.1.1.md b/docs/design/REALM-CP-1.0.1.1.md new file mode 100644 index 00000000..296dd70c --- /dev/null +++ b/docs/design/REALM-CP-1.0.1.1.md @@ -0,0 +1,51 @@ +# Realm CP 1.0.1.1 + +The Company and Politics CPs now use the existing clan dashboard and settings +presentation, through one shared organisation shell. Company records come only +from the authorised company register. Protected political House membership is a +read projection of unambiguous current office deeds; ordinary faction citizens +are not automatically members and personal clan membership is unchanged. +Membership is checked again on each request and expires with the office deed. + +The old authored CPs remain accessible at `/company-cp-reference` and +`/politics-cp-reference`, with preserved browser entrypoints and their original +navigation/style dependencies. They are reference implementations for the next +design sessions. Their underlying API permission gates remain in effect. + +The shared illustrated banner exposes three official-style switches only on the +Clan, Company and Politics surfaces. Forums and other pages have no CP switcher. +Realm Nexus links all three from the simplified shared main header. Main-header +and workspace highlights still use the existing menu manager and permission rules. + +Claim presentation reads the existing tariff catalogue: clan, company, protected. +The company/protected adapters show their own tariff references and do not load +another clan's live claims. Unconnected mutations and records stay explicitly +unavailable. No company or political claim balance/land ownership is fabricated. + +J.A.R.V.I.S. keeps existing CLAN and COM founding rights, with separate POL decision +keys. New POL-CLAN keys are scoped to a live, unambiguous office deed and its exact +expiry. CLAN-SUB / COM-SUB keys are parent-scoped, require a transactional authority +adapter and cannot consume independent founding rights. The clan issuer requires +a current Keyed/Royal mother deed; its private API checks game access and origin. +Actual subhouse creation, purchase, conquest and release still need their domain +handlers. The new key family does not itself transfer a deed or grant Royal rights. +Staff issuance/replacement is explicitly deferred until preparation for live launch. + +Recruitment quotes reuse the actual clan charter and member count. Basic is free; +Keyed/Royal cost 10 DM plus 0.25 DM per occupied member per advertised place. +The owner counts. Publishing must snapshot and recheck the quote and reserve +payment. Listing publication/payment and Board/Discord delivery remain disabled +until those adapters are implemented. The displayed quote does not debit money. + +Git/release version is 1.0.1.1. The user manages any saved header-version override. +No game services are restarted or updated by this web rollout. PR337 stays open. + +Next: separate cleanup PR, then design review. Later kit/item update integrates +tools, weapons and banners into clan equipment using existing generator code, +MK I-XIV metadata and native rarity. No equipment-stat effects are enabled here. + +Local governance and deed ownership are distinct for subordinated Houses. Their +local leadership retains access to Heir, Consort and specialist appointments; +local succession does not inherit the mother's deed or restore independent +political powers. The mother retains final deed authority. This remains a required +rule for the later relationship/transfer handlers, not a claimed completed feature. diff --git a/website/control-panel/clan-key-receipts.mjs b/website/control-panel/clan-key-receipts.mjs index 811aac40..d77093a4 100644 --- a/website/control-panel/clan-key-receipts.mjs +++ b/website/control-panel/clan-key-receipts.mjs @@ -1,3 +1,4 @@ +import {issueClanSubhouseKey} from '../node/subhouse-keys.mjs'; import {identity} from '../node/auth.mjs'; import {accessFor} from '../node/permissions.mjs'; import {ensureOriginalKeys} from '../node/organisation-key-service.mjs'; @@ -13,12 +14,13 @@ export function createClanKeyReceipts(db,{authenticate=r=>identity(r,db),access= if(!(await access(user)).nodes.includes('web.menu.game'))return reply({message:'Game account access required.'},403); if(!keys)return reply({message:'Founding codes are temporarily unavailable.'},503); let body;try{body=await request.json();}catch{return reply({message:'Invalid request.'},400);} + if(body?.action==='issue-subhouse'){if(body.confirmed!==true||Object.keys(body).some(k=>!['action','parentClanId','requestId','confirmed'].includes(k)))return reply({message:'Confirm the mother-deed key request.'},400);try{const result=await issueClanSubhouseKey(db,keys,user,body);return reply({ok:true,keyId:result.id,created:result.created});}catch(error){if(error instanceof TypeError)return reply({message:error.message},400);if(error instanceof OrganisationKeyError)return reply({message:error.message},409);throw error;}} if(!body||typeof body!=='object'||Object.keys(body).some(k=>!['code','clanId','version','requestId','confirmed'].includes(k)))return reply({message:'Invalid founding request.'},400); try{const result=await upgradeOriginalClan(db,keys,user,body);return reply({ok:true,charter:'original',clanId:result.targetId,replayed:result.replayed});} catch(error){if(error instanceof TypeError)return reply({message:error.message},400);if(error instanceof OrganisationKeyError)return reply({message:error.message},409);throw error;} } if(keys)await ensureOriginalKeys(keys,user.id); const secrets=keys?new Map((await keys.list(user.id)).map(r=>[r.id,r])):new Map(); - const {results}=await db.prepare("SELECT k.id,k.key_type,k.created_at,k.used_at,k.expires_at,k.revoked_at,k.target_id,c.name,c.tag,ch.charter_kind FROM organisation_keys k LEFT JOIN site_clans c ON c.id=k.target_id LEFT JOIN site_clan_charters ch ON ch.clan_id=c.id WHERE k.account_id=? AND k.key_type IN ('clan-founding','company-founding','political-appointment') ORDER BY k.created_at,k.id LIMIT 100").bind(user.id).all(); - return reply({keys:results.map(r=>({id:r.id,type:r.key_type==='clan-founding'?'clan':r.key_type==='company-founding'?'company':'politics',createdAt:Number(r.created_at),status:r.revoked_at!=null?'Revoked':r.used_at!=null?'Applied':r.expires_at!=null&&Number(r.expires_at)<=Date.now()?'Expired':keys?'Available':'Issued',clan:r.name||null,clanId:r.target_id,charter:r.charter_kind||null,code:secrets.get(r.id)?.code||null,edition:secrets.get(r.id)?.edition||null}))}); + const {results}=await db.prepare("SELECT k.id,k.key_type,k.created_at,k.used_at,k.expires_at,k.revoked_at,k.target_id,c.name,c.tag,ch.charter_kind FROM organisation_keys k LEFT JOIN site_clans c ON c.id=k.target_id LEFT JOIN site_clan_charters ch ON ch.clan_id=c.id WHERE k.account_id=? AND k.key_type IN ('clan-founding','company-founding','political-appointment','political-clan','clan-subhouse','company-subsidiary') ORDER BY k.created_at,k.id LIMIT 100").bind(user.id).all(); + return reply({keys:results.map(r=>({id:r.id,type:r.key_type==='clan-founding'?'clan':r.key_type==='company-founding'?'company':r.key_type==='political-clan'?'politics-clan':r.key_type==='clan-subhouse'?'subhouse':r.key_type==='company-subsidiary'?'subsidiary':'politics',createdAt:Number(r.created_at),status:r.revoked_at!=null?'Revoked':r.used_at!=null?'Applied':r.expires_at!=null&&Number(r.expires_at)<=Date.now()?'Expired':keys?'Available':'Issued',clan:r.name||null,clanId:r.target_id,charter:r.charter_kind||null,code:secrets.get(r.id)?.code||null,edition:secrets.get(r.id)?.edition||null}))}); };} diff --git a/website/control-panel/clans.mjs b/website/control-panel/clans.mjs index 0c99deea..29d53ca1 100644 --- a/website/control-panel/clans.mjs +++ b/website/control-panel/clans.mjs @@ -1,3 +1,4 @@ +import {clanRecruitmentQuote} from '../node/jarvis-recruitment-policy.mjs'; import {clanMemberLimit} from '../node/clan-membership-policy.mjs'; import {normalisePalette} from './public/organisation-palette-model.mjs'; import {initializeClanCharters} from '../node/clan-charters.mjs'; @@ -50,6 +51,7 @@ export function createClans(db,{origin='https://cp.dunerealms.com',authenticate= const emblem=await db.prepare('SELECT version,image_blob IS NOT NULL AS has_image FROM site_clan_emblems WHERE clan_id=?').bind(record.id).first();record.emblemVersion=Number(emblem?.version||0);record.hasEmblem=!!emblem?.has_image;record.emblem=clanEmblemUrl(record.id,record.emblemVersion); const authority=await clanDeedAuthority(db,user.id,record.id);record.charterKind=authority.deed?.kind||'basic';record.memberLimit=clanMemberLimit(record.charterKind,record.institution?.memberLimit??null);record.colors=authority.deed?.colors||normalisePalette(undefined,record.home_world);record.titles=clanTitles({...record,institution:record.institution});record.deed=authority.deed?publicDeed(authority.deed):null; const {results:members}=await db.prepare("SELECT a.username,m.clan_role,m.joined_at FROM site_clan_members m JOIN site_accounts a ON a.id=m.user_id WHERE m.clan_id=? ORDER BY CASE m.clan_role WHEN 'owner' THEN 0 WHEN 'officer' THEN 1 ELSE 2 END,a.username").bind(record.id).all(); + record.recruitment=clanRecruitmentQuote({charterKind:record.charterKind,memberCount:members.length,protectedInstitution:!!record.institution,institutionLimit:record.institution?.memberLimit??null}); const role=own?.clan_id===record.id?own.clan_role:null,canReview=linked&&!record.institution&&(['owner','officer'].includes(role)||authority.canManage); const requests=canReview?(await db.prepare("SELECT a.username,r.created_at FROM site_clan_requests r JOIN site_accounts a ON a.id=r.user_id WHERE r.clan_id=? AND r.status='pending' ORDER BY r.created_at,a.username").bind(record.id).all()).results:[]; record.motd=role?await readOrganisationMotd(db,'clan',record.id):null; diff --git a/website/control-panel/company-cp-reference.mjs b/website/control-panel/company-cp-reference.mjs new file mode 100644 index 00000000..fa3f4f8e --- /dev/null +++ b/website/control-panel/company-cp-reference.mjs @@ -0,0 +1,7 @@ +import {clanCPDocument} from './clan-cp-shell.mjs'; +export function companyCPReferenceDocument(source){return clanCPDocument(source) + .replace('DuneRealms · Clan CP','DuneRealms · Company CP Reference') + .replace('data-cp-mode="clan" class="clan-cp-shell"','data-cp-mode="company" class="clan-cp-shell company-cp-shell"') + .replace(/') + .replace('','') + .replace('','');} diff --git a/website/control-panel/company-cp-shell.mjs b/website/control-panel/company-cp-shell.mjs index 75b44a27..d85ba47c 100644 --- a/website/control-panel/company-cp-shell.mjs +++ b/website/control-panel/company-cp-shell.mjs @@ -4,4 +4,4 @@ export function companyCPDocument(source){return clanCPDocument(source) .replace('data-cp-mode="clan" class="clan-cp-shell"','data-cp-mode="company" class="clan-cp-shell company-cp-shell"') .replace(/') .replace('','') - .replace('','');} + .replace('','');} diff --git a/website/control-panel/politics-cp-reference.mjs b/website/control-panel/politics-cp-reference.mjs new file mode 100644 index 00000000..e9d1a6a7 --- /dev/null +++ b/website/control-panel/politics-cp-reference.mjs @@ -0,0 +1,16 @@ +// Use the same authored shell and layout as User/Dev CP. Only the palette, +// political navigation and public-page chrome differ on this surface. +export function politicsCPReferenceDocument(source){ + return source.replace('DuneRealms · Account Centre','DuneRealms · Politics CP Reference') + .replace(/
[\s\S]*?<\/header>/,'') + .replace(/