717ae1031e
Zanzibar-style authorization graph engine (direct/chain/TTU/defeasible/ binary modes, condensed snapshots, value relations) with 39 rigor test campaigns. Includes fixes for snapshot binary writer/reader format mismatch (snapshot-of-snapshot corruption), possibility write-boundary validation, empty-graph snapshot serialization, relation lookup cache direction collision, config-redefinition cache invalidation, binary threshold semantics, defeasible compiled routing, and comparator reason whitelisting.
63 lines
1.9 KiB
JavaScript
63 lines
1.9 KiB
JavaScript
import { Arbiter } from '../../src/core/Arbiter.js';
|
|
import { describe, it, beforeEach } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
describe('Simple Defeasible Logic Debug', () => {
|
|
let arbiter;
|
|
|
|
beforeEach(() => {
|
|
arbiter = new Arbiter({ embeddingDimensions: 256 });
|
|
|
|
// Set up basic entities
|
|
arbiter.addNode('user:alice', 'user');
|
|
arbiter.addNode('doc:test', 'document');
|
|
|
|
// Set up basic relations
|
|
arbiter.setRelationConfig('can_access', { type: 'direct' });
|
|
arbiter.setRelationConfig('is_blocked', { type: 'direct' });
|
|
});
|
|
|
|
it('tests basic union logic', () => {
|
|
// Set up user access
|
|
arbiter.addRelation('user:alice', 'can_access', 'doc:test', {
|
|
value: 1.0,
|
|
possibility: 1.0,
|
|
changed_last_at: Date.now()
|
|
});
|
|
|
|
// Test simple union
|
|
arbiter.setRelationConfig('simple_union', {
|
|
union: [
|
|
{ type: 'direct', relation: 'can_access' }
|
|
]
|
|
});
|
|
|
|
const result = arbiter.authChecker.check('user:alice', 'simple_union', 'doc:test');
|
|
|
|
if (process.env.TEST_DEBUG === '1') console.log('Simple union result:', result);
|
|
assert.ok(result.possibility > 0, `Expected some possibility, got ${result.possibility}`);
|
|
});
|
|
|
|
it('tests basic intersection logic', () => {
|
|
// Set up user access
|
|
arbiter.addRelation('user:alice', 'can_access', 'doc:test', {
|
|
value: 1.0,
|
|
possibility: 1.0,
|
|
changed_last_at: Date.now()
|
|
});
|
|
|
|
// Test simple intersection
|
|
arbiter.setRelationConfig('simple_intersection', {
|
|
intersection: [
|
|
{ type: 'direct', relation: 'can_access' }
|
|
]
|
|
});
|
|
|
|
const result = arbiter.authChecker.check('user:alice', 'simple_intersection', 'doc:test');
|
|
|
|
if (process.env.TEST_DEBUG === '1') console.log('Simple intersection result:', result);
|
|
assert.ok(result.possibility > 0, `Expected some possibility, got ${result.possibility}`);
|
|
});
|
|
|
|
});
|