@anteriorai/srg-compiler
v0.5.1
Published
SRG v2 compiler - compiles .srg files to executable JSON
Readme
@anteriorai/srg-compiler
Compiles .srg files to executable JSON format compatible with the Python symbolic_reasoning runtime.
Public preview. This package is an early public release of Anterior's symbolic reasoning tooling. It is being published to support transparency, research discussion, and early experimentation while the broader open-source repository is prepared for release.
Future releases may be made available under updated licensing terms. Until then, use of this package is governed by the license included with this release.
This release should not be treated as a supported product, a stable API, or a complete reference implementation. It is provided "as is," without warranties of any kind. Users are responsible for evaluating correctness, security, compliance, and suitability for their own use case.
Installation
npm install @anteriorai/srg-compilerUsage
Programmatic API
import { compile, compileFile } from '@anteriorai/srg-compiler';
// Compile from string
const source = `
predicate is_adult: "Is patient 18 or older?"
outcome approved: "Approved"
is_adult => approved
`;
const json = await compile(source);
// Compile from file
const json2 = await compileFile('policy.srg');CLI
# Compile a .srg file
npx srg-compile policy.srg
# Specify output file
npx srg-compile policy.srg --output result.json
# Pretty print JSON
npx srg-compile policy.srg --prettyOutput Format
The compiler outputs JSON that matches the JSON schema SRG model exactly:
{
"edges": {...},
"nodes": {...},
"predicates": {...},
"aggregators": {...},
"outcomes": {...},
"policy_context": null
}This JSON can be directly loaded by Python:
from symbolic_reasoning.models import SRG
srg = SRG.model_validate_json(json_string)Development
Building from Source
# Install dependencies
npm install
# Build the compiler
npm run buildThe build process compiles TypeScript to dist/.
Dependencies
This package depends on:
@anteriorai/srg-parser: Parses.srgfiles to AST. Handles all syntax parsing and tree-sitter integration.@anteriorai/srg-types: Provides TypeScript types for the SRG JSON schema. The compiler imports these types directly (e.g.,import type * as SRG from '@anteriorai/srg-types')
