forked from unimatrix/web
Attach the protected Crysknife Order to the Emperor through a scoped JARVIS parent instrument
This commit is contained in:
parent
7fddf78351
commit
95c875d570
5 changed files with 53 additions and 5 deletions
|
|
@ -21,6 +21,7 @@ import {createElectionCampaignAPI} from '../node/election-campaign-api.mjs';
|
|||
import {VALIDATION_CASE_SCHEMA,createKeyValidation} from '../node/jarvis-key-validation.mjs';
|
||||
import {ensureJarvisIdentity} from '../node/jarvis-identity-provision.mjs';
|
||||
import {reconcileCrysknifeCompany} from '../node/crysknife-company.mjs';
|
||||
import {attachCrysknifeToEmperor} from '../node/crysknife-parent.mjs';
|
||||
import {createRealmEvents} from '../node/jarvis-events.mjs';
|
||||
import {createRihlaAPI,ensureRihlaAccount,provisionRihlaAccounts} from '../node/rihla.mjs';
|
||||
import {NETWORK_LAYOUT_SCHEMA,createNetworkLayoutAPI} from '../node/organisation-network.mjs';
|
||||
|
|
@ -432,7 +433,7 @@ export async function startPanel(settings=process.env){
|
|||
inventoryPool.on('error',()=>console.error('Inventory database connection unavailable.'));
|
||||
}
|
||||
const bankDatabase=await openPostbankDatabase(settings);
|
||||
const db=await openDatabase(settings);await db.query(ECONOMIC_SNAPSHOT_SCHEMA);await initializeCodexEquipment(db);await initializeFirstLogin(db);await db.prepare(accountSchema).run();await initializeProclamations(db);await initializeCharters(db);await initializeApplications(db);await initializeRounds(db);await initializeBallots(db);await initializeOfficeLedger(db);await initializeContactEmails(db);await initializeBanEvidence(db);await initializeClans(db);await db.prepare(CHARACTER_PREFERENCE_SCHEMA+' ENGINE=InnoDB DEFAULT CHARSET=utf8mb4').run();await db.prepare(CHARACTER_SCHEMA+' ENGINE=InnoDB DEFAULT CHARSET=utf8mb4').run();await applyRoyalClanRollout(db);const organisationKeys=await openOrganisationKeyService(db,settings);await ensurePoliticalOfficeCharters(db,organisationKeys);const keyGrants=await grantCurrentAccountKeys(db,organisationKeys);console.log('Original founding key grants reconciled',JSON.stringify(keyGrants));await resetOwnerTestClaims(db,bankDatabase);await initializeClanShop(db);await initializeMailIdentities(db);await initializeGitIdentities(db);await initializeRanks(db);await initializeHonours(db);await initializeStaffBureau(db);await initializeOrganisation(db);await initializeLifeStatus(db);await initializeBadges(db);await initializeSealEntitlements(db);await initializeSealCatalog(db);await initializeCompanyRegistry(db);await initializeCompanyDeeds(db);await applyUnicorpRoyalMailbox(db,organisationKeys,{apply:true}).catch(error=>console.error('Unicorp Royal mailbox rollout pending:',error.message));await initializeShareLedger(db);await initializeNews(db);await initializeCommunityAccess(db);await initializeQuestAccess(db);await initializeBankAccess(db);await initializeGameRanks(db);await db.query(NETWORK_LAYOUT_SCHEMA);db.networkLayoutsEnabled=true;await ensureJarvisIdentity(db);await db.query(VALIDATION_CASE_SCHEMA);await reconcileCrysknifeCompany(db,organisationKeys);await provisionRihlaAccounts(db,bankDatabase);await initializeOfficeAuctionRuntime(db,bankDatabase);for(const sql of [...POLITICAL_JOB_SCHEMA,...NAIB_COUNCIL_SCHEMA])await db.query(sql);db.naibCouncilEnabled=true;await initializeProgression(db);await initializeServerProjects(db);if(bankDatabase)await bankDatabase.query(PROJECT_BANK_SCHEMA);await db.query(GAZETTE_SCHEMA);await ensureProgressionPolicy(db,organisationKeys);const progressionRuntime=createProgressionRuntime(db,bankDatabase,organisationKeys);const officeAuctionRuntime=createOfficeAuctionRuntime(db,bankDatabase);const promotionDelivery=bankDatabase?await configurePromotionDelivery(db,bankDatabase,settings):null;const handle=createPanel(db,settings,{inventoryPool,bankDatabase,organisationKeys,officeAuctionRuntime,promotionDelivery,progressionRuntime}),origin=settings.CP_ORIGIN||'https://cp.dunerealms.com';
|
||||
const db=await openDatabase(settings);await db.query(ECONOMIC_SNAPSHOT_SCHEMA);await initializeCodexEquipment(db);await initializeFirstLogin(db);await db.prepare(accountSchema).run();await initializeProclamations(db);await initializeCharters(db);await initializeApplications(db);await initializeRounds(db);await initializeBallots(db);await initializeOfficeLedger(db);await initializeContactEmails(db);await initializeBanEvidence(db);await initializeClans(db);await db.prepare(CHARACTER_PREFERENCE_SCHEMA+' ENGINE=InnoDB DEFAULT CHARSET=utf8mb4').run();await db.prepare(CHARACTER_SCHEMA+' ENGINE=InnoDB DEFAULT CHARSET=utf8mb4').run();await applyRoyalClanRollout(db);const organisationKeys=await openOrganisationKeyService(db,settings);await ensurePoliticalOfficeCharters(db,organisationKeys);const keyGrants=await grantCurrentAccountKeys(db,organisationKeys);console.log('Original founding key grants reconciled',JSON.stringify(keyGrants));await resetOwnerTestClaims(db,bankDatabase);await initializeClanShop(db);await initializeMailIdentities(db);await initializeGitIdentities(db);await initializeRanks(db);await initializeHonours(db);await initializeStaffBureau(db);await initializeOrganisation(db);await initializeLifeStatus(db);await initializeBadges(db);await initializeSealEntitlements(db);await initializeSealCatalog(db);await initializeCompanyRegistry(db);await initializeCompanyDeeds(db);await applyUnicorpRoyalMailbox(db,organisationKeys,{apply:true}).catch(error=>console.error('Unicorp Royal mailbox rollout pending:',error.message));await initializeShareLedger(db);await initializeNews(db);await initializeCommunityAccess(db);await initializeQuestAccess(db);await initializeBankAccess(db);await initializeGameRanks(db);await db.query(NETWORK_LAYOUT_SCHEMA);db.networkLayoutsEnabled=true;await ensureJarvisIdentity(db);await db.query(VALIDATION_CASE_SCHEMA);if((await reconcileCrysknifeCompany(db,organisationKeys)).state==='ready')await attachCrysknifeToEmperor(db,organisationKeys).catch(error=>console.error('Protected Order parent reconciliation pending:',error.message));await provisionRihlaAccounts(db,bankDatabase);await initializeOfficeAuctionRuntime(db,bankDatabase);for(const sql of [...POLITICAL_JOB_SCHEMA,...NAIB_COUNCIL_SCHEMA])await db.query(sql);db.naibCouncilEnabled=true;await initializeProgression(db);await initializeServerProjects(db);if(bankDatabase)await bankDatabase.query(PROJECT_BANK_SCHEMA);await db.query(GAZETTE_SCHEMA);await ensureProgressionPolicy(db,organisationKeys);const progressionRuntime=createProgressionRuntime(db,bankDatabase,organisationKeys);const officeAuctionRuntime=createOfficeAuctionRuntime(db,bankDatabase);const promotionDelivery=bankDatabase?await configurePromotionDelivery(db,bankDatabase,settings):null;const handle=createPanel(db,settings,{inventoryPool,bankDatabase,organisationKeys,officeAuctionRuntime,promotionDelivery,progressionRuntime}),origin=settings.CP_ORIGIN||'https://cp.dunerealms.com';
|
||||
await initializeInternalMailAccess(db);const stopElectionClock=startElectionClock(db);const stopOfficeLedger=startOfficeLedger(db);
|
||||
const stopBanSync=startModerationSync(db,settings),stopInternalMail=startInternalMailSync(db,{jarvisStore:bankDatabase}),stopCentralScheduler=startCentralScheduler(db,bankDatabase,settings,{extraTasks:bankDatabase?[{key:'server_projects',slot:now=>Math.floor(now/60000)*60000,run:()=>createServerProjectRuntime(db,bankDatabase,organisationKeys).drain()},{key:'progression_completion',slot:now=>Math.floor(now/60000)*60000,run:async()=>{const completed=await progressionRuntime.quests.processCompletions();const news=await progressionRuntime.announcements.drain();return {completed,news};}},{key:'naib_council',slot:now=>Math.floor(now/60000)*60000,run:async()=>{await reconcileNaibChairs(db);return createNaibCouncil(db).reconcile();}},{key:'jarvis_promotions',slot:now=>Math.floor(now/15000)*15000,run:()=>promotionDelivery.drain()},{key:'political_jobs',slot:now=>Math.floor(now/60000)*60000,run:async()=>{await createPoliticalJobs(db,bankDatabase).reconcile();return drainPoliticalJobNotifications(db,{broker:internalMailBroker,eligible:internalMailEligible});}},{key:'order_membership',slot:now=>Math.floor(now/60000)*60000,run:()=>reconcileCrysknifeCompany(db,organisationKeys)},{key:'office_auctions',slot:now=>Math.floor(now/60000)*60000,run:()=>officeAuctionRuntime.process()},{key:'jarvis_settlement',slot:now=>standardCycle(now).cutoff,async run(cutoff){const payments=createJarvisPayments(bankDatabase,createPostbankAuthority(db,{bank:bankDatabase}));for(let i=0;i<40;i++){const result=await payments.settle(cutoff);if(result.failed)return result;if(result.attempted<100)return result;}return {failed:1};}}]:[]});
|
||||
const security={'X-Robots-Tag':'noindex, nofollow, noarchive','X-Content-Type-Options':'nosniff','Referrer-Policy':'no-referrer','Cache-Control':'no-store','Content-Security-Policy':"default-src 'self'; script-src 'self' https://www.dunerealms.com; style-src 'self' https://www.dunerealms.com https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; connect-src 'self' https://www.dunerealms.com; img-src 'self' data: https://www.dunerealms.com https://support.dunerealms.com; frame-src 'self' https://luckperms.net https://www.dunerealms.com https://support.dunerealms.com https://forums.dunerealms.com https://clans.dunerealms.com https://corp.dunerealms.com https://wiki.dunerealms.com; object-src 'none'; base-uri 'none'; form-action 'self'; frame-ancestors 'self' https://www.dunerealms.com https://dunerealms.com https://clans.dunerealms.com"};
|
||||
|
|
|
|||
23
website/node/crysknife-parent.mjs
Normal file
23
website/node/crysknife-parent.mjs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import {STAFF_OFFICE_ACCOUNT_ID} from './organisation-keys.mjs';
|
||||
import {entityParent,setEntityParent} from './entity-relations.mjs';
|
||||
import {CRYSKNIFE_COMPANY_ID} from './crysknife-company.mjs';
|
||||
const REQUEST_ID='bd5cc574-f474-4df4-bc66-c659e5c49f32';
|
||||
const SCOPE='protected:order-crysknife:emperor:v1';
|
||||
// Fixed institutional relocation approved for this Order; not a general transfer endpoint.
|
||||
export async function attachCrysknifeToEmperor(db,keys,{clock=Date.now}={}){
|
||||
const verify=async tx=>{
|
||||
const row=await tx.first("SELECT d.owner_account_id FROM site_company_institutions i JOIN site_company_deeds d ON d.company_id=i.company_id JOIN site_memorials m ON m.user_id=d.owner_account_id AND m.slug='patrick-stewart' JOIN corrino_companies c ON c.id=i.company_id AND c.status='active' WHERE i.company_id=? AND i.institution_key='order-crysknife'",[CRYSKNIFE_COMPANY_ID]);
|
||||
if(!row)throw Error('Protected Order deed requires review');
|
||||
const parent=await entityParent(tx,'company',CRYSKNIFE_COMPANY_ID);
|
||||
if(parent&&(parent.parent_kind!=='politics'||parent.parent_id!=='emperor'))throw Error('Protected Order parent changed; review required');
|
||||
};
|
||||
const issued=await keys.issue({accountId:STAFF_OFFICE_ACCOUNT_ID,keyType:'staff-parent-link',scopeId:SCOPE,authorize:verify});
|
||||
const key=(await keys.list(STAFF_OFFICE_ACCOUNT_ID)).find(k=>k.id===issued.id);
|
||||
if(key?.status==='used')return {state:'linked',replayed:true};
|
||||
if(key?.status!=='available')throw Error('Protected Order parent instrument unavailable');
|
||||
return keys.consume({accountId:STAFF_OFFICE_ACCOUNT_ID,keyType:'staff-parent-link',code:key.code,targetId:CRYSKNIFE_COMPANY_ID,requestId:REQUEST_ID,apply:async(tx,{keyId,scopeId})=>{
|
||||
if(scopeId!==SCOPE)throw Error('Protected Order instrument scope mismatch');
|
||||
await verify(tx);
|
||||
await setEntityParent(tx,{childKind:'company',childId:CRYSKNIFE_COMPANY_ID,parentKind:'politics',parentId:'emperor',origin:'staff',keyId,requestId:REQUEST_ID,actorId:STAFF_OFFICE_ACCOUNT_ID,now:clock()});
|
||||
}});
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ function rootOf(rows,id){const map=new Map(rows.map(r=>[r.id,r])),seen=new Set()
|
|||
// Common ownership is an alliance projection, never a bank mandate or rank.
|
||||
export function projectOwnershipNetwork({clans,companies,owner,offices=[],layout=null}){
|
||||
const person='person:'+owner.username,nodes=[{id:person,kind:'person',name:owner.display_name||owner.username,url:'https://www.dunerealms.com/people/'+encodeURIComponent(owner.username),image:'https://cp.dunerealms.com/api/avatars/face/roster/'+encodeURIComponent(owner.username)}],edges=[];
|
||||
for(const [kind,rows]of [['clan',clans],['company',companies]])for(const row of rows){const root=rootOf(rows,row.id);if(root.owner_id!==owner.id)continue;const id=kind+':'+row.id;nodes.push({id,kind,name:row.name,url:'https://www.dunerealms.com/'+(kind==='clan'?'clans/':'companies/')+encodeURIComponent(kind==='clan'?row.tag:row.slug),image:'https://cp.dunerealms.com/api/'+(kind==='clan'?'clan-emblems/':'company-emblems/')+encodeURIComponent(row.id)});edges.push({from:row.parent_id?kind+':'+row.parent_id:person,to:id,kind:row.parent_id?'subsidiary':'ownership'});}
|
||||
for(const [kind,rows]of [['clan',clans],['company',companies]])for(const row of rows){const root=rootOf(rows,row.id);const office= root.parent_office&&offices.find(o=>o.key===root.parent_office&&o.holder?.username.toLowerCase()===owner.username.toLowerCase());if(root.owner_id!==owner.id&&!office)continue;const id=kind+':'+row.id;nodes.push({id,kind,name:row.name,url:'https://www.dunerealms.com/'+(kind==='clan'?'clans/':'companies/')+encodeURIComponent(kind==='clan'?row.tag:row.slug),image:'https://cp.dunerealms.com/api/'+(kind==='clan'?'clan-emblems/':'company-emblems/')+encodeURIComponent(row.id)});edges.push({from:row.parent_id?kind+':'+row.parent_id:office?'office:'+office.key:person,to:id,kind:row.parent_id?'subsidiary':'ownership'});}
|
||||
for(const office of offices.filter(o=>o.holder?.username.toLowerCase()===owner.username.toLowerCase())){const id='office:'+office.key;nodes.push({id,kind:'office',name:office.name,url:'https://www.dunerealms.com/political-houses/'+office.key,image:'https://www.dunerealms.com/assets/seals/'+office.art,expiresAt:office.term.expiresAt});edges.push({from:person,to:id,kind:'office-term'});}
|
||||
const known=new Set(nodes.map(n=>n.id)),positions={};for(const [key,value]of Object.entries(layout||{}))if(known.has(key)&&Number.isInteger(value.column)&&value.column>=0&&value.column<=2&&Number.isInteger(value.row)&&value.row>=0&&value.row<=100)positions[key]=value;
|
||||
return {owner:owner.username,nodes,edges,positions};
|
||||
|
|
@ -13,10 +13,11 @@ export function projectOwnershipNetwork({clans,companies,owner,offices=[],layout
|
|||
export async function readOrganisationNetwork(central,{kind,id,ownerId=null,clock=Date.now}){
|
||||
if(kind&&!validKind(kind))throw Error('Choose an ownership network');
|
||||
const clans=(await central.prepare('SELECT c.id,c.name,c.tag,c.owner_id,d.parent_clan_id AS parent_id FROM site_clans c LEFT JOIN site_clan_deeds d ON d.clan_id=c.id WHERE c.active=1 ORDER BY c.id LIMIT 1001').all()).results;
|
||||
const companies=(await central.prepare("SELECT c.id,c.name,c.slug,d.owner_account_id AS owner_id,r.parent_company_id AS parent_id FROM corrino_companies c JOIN site_company_deeds d ON d.company_id=c.id LEFT JOIN site_company_relations r ON r.company_id=c.id WHERE c.status='active' ORDER BY c.id LIMIT 1001").all()).results;
|
||||
const companies=(await central.prepare("SELECT c.id,c.name,c.slug,d.owner_account_id AS owner_id,r.parent_company_id AS parent_id,e.parent_id AS parent_office FROM corrino_companies c JOIN site_company_deeds d ON d.company_id=c.id LEFT JOIN site_company_relations r ON r.company_id=c.id LEFT JOIN jarvis_entity_relations e ON e.child_kind='company' AND e.child_id=c.id AND e.parent_kind='politics' WHERE c.status='active' ORDER BY c.id LIMIT 1001").all()).results;
|
||||
if(clans.length>1000||companies.length>1000)throw Error('Ownership network needs paginated reconciliation');
|
||||
const selected=kind?rootOf(kind==='clan'?clans:companies,id):null,owner=await central.prepare("SELECT id,username,display_name FROM site_accounts WHERE id=? AND password_hash NOT LIKE '!%'").bind(ownerId||selected?.owner_id||'').first();if(!owner)throw Error('Ownership network unavailable');
|
||||
const layout=await central.prepare('SELECT revision,positions_json FROM site_network_layouts WHERE owner_id=?').bind(owner.id).first(),network=projectOwnershipNetwork({clans,companies,owner,offices:await readGovernmentOffices(central,clock()),layout:layout?JSON.parse(layout.positions_json):null});
|
||||
const offices=await readGovernmentOffices(central,clock());
|
||||
const selected=kind?rootOf(kind==='clan'?clans:companies,id):null,officeHolder=selected?.parent_office&&offices.find(o=>o.key===selected.parent_office)?.holder,officeOwner=officeHolder?await central.prepare('SELECT id FROM site_accounts WHERE LOWER(username)=LOWER(?)').bind(officeHolder.username).first():null,owner=await central.prepare("SELECT id,username,display_name FROM site_accounts WHERE id=? AND password_hash NOT LIKE '!%'").bind(ownerId||officeOwner?.id||selected?.owner_id||'').first();if(!owner)throw Error('Ownership network unavailable');
|
||||
const layout=await central.prepare('SELECT revision,positions_json FROM site_network_layouts WHERE owner_id=?').bind(owner.id).first(),network=projectOwnershipNetwork({clans,companies,owner,offices,layout:layout?JSON.parse(layout.positions_json):null});
|
||||
return {network:{...network,revision:Number(layout?.revision||0)},ownerId:owner.id};
|
||||
}
|
||||
export function createNetworkLayoutAPI(central,{clock=Date.now,authenticate=r=>identity(r,central),origins=['https://cp.dunerealms.com','https://www.dunerealms.com']}={}){
|
||||
|
|
|
|||
15
website/tests/crysknife-parent.test.mjs
Normal file
15
website/tests/crysknife-parent.test.mjs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import test from 'node:test';import assert from 'node:assert/strict';import {companyFixture} from './company-deed-fixture.mjs';import {reconcileCrysknifeCompany,CRYSKNIFE_COMPANY_ID} from '../node/crysknife-company.mjs';import {attachCrysknifeToEmperor} from '../node/crysknife-parent.mjs';import {entityControllers} from '../node/entity-relations.mjs';
|
||||
test('protected parent instrument moves only the honorary Order, preserves owner and members, and follows Emperor succession',async()=>{
|
||||
const f=await companyFixture();try{
|
||||
f.db.sqlite.exec("CREATE TABLE cp_account_ranks(user_id TEXT,rank_key TEXT);CREATE TABLE account_audit(id TEXT PRIMARY KEY,actor_id TEXT,action TEXT,details TEXT,created_at INT);ALTER TABLE political_office_terms ADD COLUMN id TEXT;ALTER TABLE political_office_terms ADD COLUMN kind TEXT;");
|
||||
const parent=await f.create(),now=Date.now();await f.db.query("UPDATE corrino_companies SET slug='uni' WHERE id=?",[parent]);await f.db.query("UPDATE site_company_deeds SET charter_kind='royal' WHERE company_id=?",[parent]);await f.db.query("UPDATE site_accounts SET username='unimatrix999' WHERE id=?",[f.people.Owner.id]);await f.db.query("INSERT INTO site_memorials(slug,user_id) VALUES('patrick-stewart',?)",[f.people.Ceo.id]);await f.db.query("INSERT INTO cp_account_ranks VALUES(?,'crysknife')",[f.people.Member.id]);
|
||||
await reconcileCrysknifeCompany(f.db,f.keys);await attachCrysknifeToEmperor(f.db,f.keys);assert.equal((await attachCrysknifeToEmperor(f.db,f.keys)).replayed,true);
|
||||
const relation=await f.db.first('SELECT * FROM jarvis_entity_relations WHERE child_id=?',[CRYSKNIFE_COMPANY_ID]);assert.equal(relation.parent_kind,'politics');assert.equal(relation.parent_id,'emperor');assert.equal((await f.db.first('SELECT COUNT(*) n FROM site_company_relations WHERE company_id=?',[CRYSKNIFE_COMPANY_ID])).n,0);
|
||||
assert.equal((await f.db.first('SELECT owner_account_id FROM site_company_deeds WHERE company_id=?',[CRYSKNIFE_COMPANY_ID])).owner_account_id,f.people.Ceo.id);
|
||||
assert.equal((await f.db.first('SELECT COUNT(*) n FROM site_company_members WHERE company_id=?',[CRYSKNIFE_COMPANY_ID])).n,2);
|
||||
await f.db.query("INSERT INTO political_office_terms(id,kind,user_id,office,faction,starts_at,expires_at,outcome) VALUES('term','imperial',?,'emperor','imperium',?,?,'winner')",[f.people.Owner.id,now-1000,now+60000]);assert.deepEqual(await entityControllers(f.db,'company',CRYSKNIFE_COMPANY_ID),[f.people.Owner.id]);
|
||||
await f.db.query('UPDATE political_office_terms SET user_id=?',[f.people.Other.id]);assert.deepEqual(await entityControllers(f.db,'company',CRYSKNIFE_COMPANY_ID),[f.people.Other.id]);
|
||||
await f.db.query('UPDATE political_office_terms SET expires_at=?',[now-1]);assert.deepEqual(await entityControllers(f.db,'company',CRYSKNIFE_COMPANY_ID),[]);
|
||||
await f.db.query("UPDATE site_company_deeds SET charter_kind='basic' WHERE company_id=?",[parent]);await f.db.query('DELETE FROM cp_account_ranks');await reconcileCrysknifeCompany(f.db,f.keys);assert.equal((await f.db.first('SELECT COUNT(*) n FROM site_company_members WHERE company_id=?',[CRYSKNIFE_COMPANY_ID])).n,1);
|
||||
}finally{f.db.close();}
|
||||
});
|
||||
|
|
@ -4,3 +4,11 @@ const owner={id:'owner',username:'Citizen',display_name:'Citizen Name'},clans=[{
|
|||
test('all owned and acquired entities share the owner network; identity and permissions stay separate',()=>{const n=projectOwnershipNetwork({owner,clans,companies});assert.deepEqual(n.nodes.map(x=>x.id),['person:Citizen','clan:mother','clan:child','company:company']);assert.deepEqual(n.edges.find(e=>e.to==='clan:child'),{from:'clan:mother',to:'clan:child',kind:'subsidiary'});assert.ok(!JSON.stringify(n).includes('owner_id'));assert.ok(n.nodes.every(x=>!('permissions' in x)));});
|
||||
test('office associations follow the current holder while saved positions cannot introduce foreign entities',()=>{const office={key:'emperor',name:'Emperor',art:'emperor-v1.png',holder:{username:'Citizen'},term:{expiresAt:100}};let n=projectOwnershipNetwork({owner,clans,companies,offices:[office],layout:{'office:emperor':{column:2,row:1},'clan:other':{column:0,row:0}}});assert.equal(n.nodes.at(-1).id,'office:emperor');assert.deepEqual(n.positions,{'office:emperor':{column:2,row:1}});n=projectOwnershipNetwork({owner,clans,companies,offices:[{...office,holder:{username:'Successor'}}],layout:n.positions});assert.equal(n.nodes.some(n=>n.kind==='office'),false);assert.deepEqual(n.positions,{});});
|
||||
test('cycles fail closed rather than assign a false network owner',()=>{assert.throws(()=>projectOwnershipNetwork({owner,companies:[],clans:[{id:'one',owner_id:'owner',parent_id:'two'},{id:'two',owner_id:'owner',parent_id:'one'}]}),/cycle/);});
|
||||
test('an institution follows its political parent into the current officeholder network',()=>{
|
||||
const order={id:'order',name:'Order',slug:'order',owner_id:'memorial',parent_id:null,parent_office:'emperor'};
|
||||
const office={key:'emperor',name:'Emperor',art:'emperor.png',holder:{username:'Citizen'},term:{expiresAt:100}};
|
||||
let n=projectOwnershipNetwork({owner,clans:[],companies:[order],offices:[office]});
|
||||
assert.ok(n.nodes.some(n=>n.id==='company:order'));
|
||||
assert.deepEqual(n.edges.find(e=>e.to==='company:order'),{from:'office:emperor',to:'company:order',kind:'ownership'});
|
||||
n=projectOwnershipNetwork({owner,clans:[],companies:[order],offices:[{...office,holder:{username:'Successor'}}]});assert.equal(n.nodes.some(n=>n.id==='company:order'),false);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff