2026-07-31 13:44:06 -07:00
|
|
|
import { describe, test } from 'node:test';
|
|
|
|
|
import assert from 'node:assert/strict';
|
2026-08-03 09:17:33 -07:00
|
|
|
import { validateDslText } from '@arbiter/evidence-dsl/validation/DSLValidation';
|
2026-07-31 13:44:06 -07:00
|
|
|
|
|
|
|
|
describe.skip('DSL injectable predicates (* prefix)', () => {
|
|
|
|
|
test('allows injectable predicates with * prefix in evidence bodies', () => {
|
|
|
|
|
const dsl = `
|
|
|
|
|
definition Doc { id: string }
|
|
|
|
|
definition Proof { issued_at: timestamp }
|
|
|
|
|
fact owns(user: User, doc: Doc)
|
|
|
|
|
source *mfa(user: User) PROVIDES Proof
|
|
|
|
|
source *webauthn(user: User) PROVIDES Proof
|
|
|
|
|
|
|
|
|
|
evidence can_delete(user: User, doc: Doc) {
|
|
|
|
|
owns(user, doc)
|
|
|
|
|
*mfa(user)
|
|
|
|
|
*webauthn(user)
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const result = validateDslText(dsl);
|
|
|
|
|
assert.equal(result.success, true, result.errors.join('\n'));
|
|
|
|
|
assert.equal(result.errors.length, 0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('injectable facts parse with * prefix', () => {
|
|
|
|
|
const dsl = `
|
|
|
|
|
definition Doc { id: string }
|
|
|
|
|
fact *device_link(user: User, device: string)
|
|
|
|
|
|
|
|
|
|
evidence is_trusted(user: User) {
|
|
|
|
|
*device_link(user, "trusted_device_01")
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const result = validateDslText(dsl);
|
|
|
|
|
assert.equal(result.success, true, result.errors.join('\n'));
|
|
|
|
|
assert.equal(result.errors.length, 0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('allows within constraints on injectable predicates', () => {
|
|
|
|
|
const dsl = `
|
|
|
|
|
definition Doc { id: string }
|
|
|
|
|
definition Proof { issued_at: timestamp }
|
|
|
|
|
fact owns(user: User, doc: Doc)
|
|
|
|
|
source *mfa(user: User) PROVIDES Proof within 10m
|
|
|
|
|
|
|
|
|
|
evidence can_delete(user: User, doc: Doc) {
|
|
|
|
|
owns(user, doc)
|
|
|
|
|
*mfa(user)
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const result = validateDslText(dsl);
|
|
|
|
|
assert.equal(result.success, true, result.errors.join('\n'));
|
|
|
|
|
assert.equal(result.errors.length, 0);
|
|
|
|
|
});
|
|
|
|
|
});
|