87 lines
3.8 KiB
JavaScript
87 lines
3.8 KiB
JavaScript
|
|
import { Arbiter } from '../../../src/index.js';
|
||
|
|
Arbiter.DEBUG = false;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Shared test graph setup for ChainRule tests.
|
||
|
|
* Creates a comprehensive organizational hierarchy with users, groups, projects,
|
||
|
|
* departments, budgets, facilities, and access levels.
|
||
|
|
*/
|
||
|
|
export function setupChainRuleTestGraph() {
|
||
|
|
const arbiter = new Arbiter({ embeddingDimensions: 256 });
|
||
|
|
|
||
|
|
// Configure basic relation types
|
||
|
|
arbiter.setRelationConfig('member_of', { type: 'direct' });
|
||
|
|
arbiter.setRelationConfig('parent', { type: 'direct' });
|
||
|
|
arbiter.setRelationConfig('can_edit', { type: 'direct' });
|
||
|
|
arbiter.setRelationConfig('has_budget', { type: 'direct' });
|
||
|
|
arbiter.setRelationConfig('has_cost', { type: 'direct' });
|
||
|
|
arbiter.setRelationConfig('belongs_to', { type: 'direct' });
|
||
|
|
arbiter.setRelationConfig('manages', { type: 'direct' });
|
||
|
|
arbiter.setRelationConfig('located_in', { type: 'direct' });
|
||
|
|
arbiter.setRelationConfig('has_access_level', { type: 'direct' });
|
||
|
|
|
||
|
|
// Create organizational hierarchy
|
||
|
|
arbiter.addNode('user:alice', 'user');
|
||
|
|
arbiter.addNode('user:bob', 'user');
|
||
|
|
arbiter.addNode('user:charlie', 'user');
|
||
|
|
arbiter.addNode('user:diana', 'user');
|
||
|
|
|
||
|
|
arbiter.addNode('group:engineering', 'group');
|
||
|
|
arbiter.addNode('group:qa', 'group');
|
||
|
|
arbiter.addNode('group:management', 'group');
|
||
|
|
|
||
|
|
arbiter.addNode('project:web-app', 'project');
|
||
|
|
arbiter.addNode('project:mobile-app', 'project');
|
||
|
|
arbiter.addNode('project:ai-platform', 'project');
|
||
|
|
|
||
|
|
arbiter.addNode('department:tech', 'department');
|
||
|
|
arbiter.addNode('department:ops', 'department');
|
||
|
|
|
||
|
|
arbiter.addNode('budget:tech-2024', 'budget');
|
||
|
|
arbiter.addNode('budget:ops-2024', 'budget');
|
||
|
|
|
||
|
|
arbiter.addNode('facility:hq', 'facility');
|
||
|
|
arbiter.addNode('facility:remote', 'facility');
|
||
|
|
|
||
|
|
arbiter.addNode('access:level-3', 'access_level');
|
||
|
|
arbiter.addNode('access:level-5', 'access_level');
|
||
|
|
|
||
|
|
// Set up membership relationships
|
||
|
|
arbiter.addRelation('user:alice', 'member_of', 'group:engineering');
|
||
|
|
arbiter.addRelation('user:bob', 'member_of', 'group:qa');
|
||
|
|
arbiter.addRelation('user:charlie', 'member_of', 'group:management');
|
||
|
|
arbiter.addRelation('user:diana', 'member_of', 'group:engineering');
|
||
|
|
|
||
|
|
// Set up group ownership of projects
|
||
|
|
arbiter.addRelation('group:engineering', 'manages', 'project:web-app');
|
||
|
|
arbiter.addRelation('group:engineering', 'manages', 'project:ai-platform');
|
||
|
|
arbiter.addRelation('group:qa', 'manages', 'project:mobile-app');
|
||
|
|
|
||
|
|
// Set up project budgets with values
|
||
|
|
arbiter.addRelation('project:web-app', 'has_budget', 'budget:tech-2024', { value: 500000 });
|
||
|
|
arbiter.addRelation('project:ai-platform', 'has_budget', 'budget:tech-2024', { value: 1200000 });
|
||
|
|
arbiter.addRelation('project:mobile-app', 'has_budget', 'budget:ops-2024', { value: 300000 });
|
||
|
|
|
||
|
|
// Set up project costs
|
||
|
|
arbiter.addRelation('project:web-app', 'has_cost', 'budget:tech-2024', { value: 450000 });
|
||
|
|
arbiter.addRelation('project:ai-platform', 'has_cost', 'budget:tech-2024', { value: 1100000 });
|
||
|
|
arbiter.addRelation('project:mobile-app', 'has_cost', 'budget:ops-2024', { value: 280000 });
|
||
|
|
|
||
|
|
// Set up hierarchical relationships
|
||
|
|
arbiter.addRelation('group:engineering', 'belongs_to', 'department:tech');
|
||
|
|
arbiter.addRelation('group:qa', 'belongs_to', 'department:ops');
|
||
|
|
arbiter.addRelation('group:management', 'belongs_to', 'department:tech');
|
||
|
|
|
||
|
|
// Set up access levels
|
||
|
|
arbiter.addRelation('department:tech', 'has_access_level', 'access:level-5');
|
||
|
|
arbiter.addRelation('department:ops', 'has_access_level', 'access:level-3');
|
||
|
|
|
||
|
|
// Set up physical locations
|
||
|
|
arbiter.addRelation('user:alice', 'located_in', 'facility:hq');
|
||
|
|
arbiter.addRelation('user:bob', 'located_in', 'facility:remote');
|
||
|
|
arbiter.addRelation('user:charlie', 'located_in', 'facility:hq');
|
||
|
|
arbiter.addRelation('user:diana', 'located_in', 'facility:remote');
|
||
|
|
|
||
|
|
return arbiter;
|
||
|
|
}
|