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,44 @@
|
||||
import fs from 'node:fs';
|
||||
import { CondensedGraph } from '../src/core/CondensedGraph.js';
|
||||
import { ShardedSnapshotBuilder } from '../src/core/shards/ShardedSnapshotBuilder.js';
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = new Map();
|
||||
for (let i = 2; i < argv.length; i++) {
|
||||
const value = argv[i];
|
||||
if (!value.startsWith('--')) continue;
|
||||
const [key, inline] = value.slice(2).split('=');
|
||||
if (inline !== undefined) {
|
||||
args.set(key, inline);
|
||||
continue;
|
||||
}
|
||||
const next = argv[i + 1];
|
||||
if (next && !next.startsWith('--')) {
|
||||
args.set(key, next);
|
||||
i++;
|
||||
} else {
|
||||
args.set(key, true);
|
||||
}
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
const args = parseArgs(process.argv);
|
||||
const input = args.get('input');
|
||||
const output = args.get('output') || 'tmp/shards';
|
||||
const bucketSize = Number(args.get('bucket') || 4096);
|
||||
const directions = args.get('directions')
|
||||
? String(args.get('directions')).split(',')
|
||||
: ['out', 'in'];
|
||||
|
||||
if (!input) {
|
||||
console.error('Usage: node new-eval/sharded-snapshot-build.js --input <condensed.bin> --output <dir> [--bucket 4096] [--directions out,in]');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const buffer = fs.readFileSync(input);
|
||||
const graph = CondensedGraph.fromBinary(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength));
|
||||
const builder = new ShardedSnapshotBuilder({ bucketSize, includeDirections: directions });
|
||||
const manifest = builder.build(graph, output);
|
||||
console.log(`Shards written to ${output}`);
|
||||
console.log(`Manifest shards: ${manifest.shards.length}`);
|
||||
Reference in New Issue
Block a user