f446750ff3
The Evidence DSL (ADR-000) compiles a natural DSL into core rule configurations — it is a separate concern from the engine. The AST had zero runtime coupling to the core (DSLCompiler takes the arbiter as a duck-typed argument; ip-utils were the only shared code, now local to the DSL package). This extraction removes the DSL surface from the core artifact entirely: - src/ast/ (748K, ~60 files) moved to @arbiter/evidence-dsl@1.0.0 - ip-utils moved with it (only the DSL consumed them) - generate-parser script + peggy devDep moved to the DSL package - the 8 DSL-consuming tests now import from @arbiter/evidence-dsl (deep-path exports: DSLCompiler, parser/*, generator/*, validation/*, interpreter/*) - package.json gains the devDependency, drops build:ast/generate:parser Tarball: AST-free. Rigor 251/251, full suite 838/776/0.
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
import { describe, test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { validateDslText } from '@arbiter/evidence-dsl/validation/DSLValidation';
|
|
|
|
describe('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);
|
|
});
|
|
});
|