initial commit: @arbiter/core authorization engine with js-rigor hardening
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.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { DSLCompiler } from '../DSLCompiler.js';
|
||||
import { Arbiter } from '../../core/Arbiter.js';
|
||||
|
||||
/**
|
||||
* Test with simple evidence containing predicate calls
|
||||
*/
|
||||
export function runSimpleEvidenceTest() {
|
||||
console.log('=== Simple Evidence Test ===\n');
|
||||
|
||||
// Create arbiter instance
|
||||
const arbiter = new Arbiter();
|
||||
|
||||
// Create compiler
|
||||
const compiler = new DSLCompiler(arbiter);
|
||||
|
||||
// Simple evidence with predicate call
|
||||
const dsl = `
|
||||
definition User {
|
||||
name: string
|
||||
}
|
||||
|
||||
fact hasRole(user: User, role: string)
|
||||
|
||||
evidence canRead(user: User, doc: Document) {
|
||||
hasRole(user, 'admin')
|
||||
}
|
||||
`;
|
||||
|
||||
console.log('1. Compiling DSL with simple evidence...');
|
||||
try {
|
||||
const result = compiler.compile(dsl, 'simple-evidence');
|
||||
|
||||
console.log('Result:', result.success ? 'SUCCESS' : 'FAILED');
|
||||
console.log('Generated rules:', result.generatedRules.size);
|
||||
console.log('Program evidence:', result.program.evidence.length);
|
||||
|
||||
if (result.errors.length > 0) {
|
||||
console.log('Errors:', result.errors);
|
||||
}
|
||||
|
||||
if (result.warnings.length > 0) {
|
||||
console.log('Warnings:', result.warnings);
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('Compilation failed:', error.message);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
}
|
||||
|
||||
// Run the test
|
||||
runSimpleEvidenceTest();
|
||||
Reference in New Issue
Block a user