AI agents are getting good at writing business logic. That's exactly the problem.
An agent generates a pricing rule that looks perfect: reads well, matches the
request, even passes a quick test. But nobody can verify it. Can you replay
yesterday's decision? Can you prove to an auditor why customer X got discount Y?
Can you be sure the rule that ran is the rule that was reviewed?
At SebaSOFT we kept hitting this failure mode while building AI-driven workflow
automation, so we built neuron-js β an
MIT-licensed TypeScript library where every rule set is pure JSON, validated
before execution, and explained after it. This post walks through why those
three properties matter for AI workflows and how the pieces fit together.
In neuron-js, a ruleset is an ExecutionScript: a JSON document containing
rules, and each rule contains conditions and actions. It serializes, diffs
cleanly in pull requests, versions in git, and moves between environments
without transpilation:
{
"id": "volume-discount",
"rules": [
{
"id": "discount-rule",
"type": "simple_rule",
"options": {},
"conditions": [
{
"id": "quantity-check",
"type": "compare_two_numbers",
"options": {},
"params": [
{ "id": "p1", "name": "op1", "type": "simple_number", "value": "${quantity}", "options": {} },
{ "id": "p2", "name": "comp", "type": "comparator", "value": ">", "options": {} },
{ "id": "p3", "name": "op2", "type": "simple_number", "value": "100", "options": {} }
]
}
],
"actions": [
{
"id": "apply-discount",
"type": "add_two_numbers",
"options": {},
"params": [
{ "id": "a1", "name": "op1", "type": "simple_number", "value": "${price}", "options": {} },
{ "id": "a2", "name": "op2", "type": "simple_number", "value": "-10", "options": {} }
]
}
]
}
]
}
Two components make this run:
Because logic lives in data, an AI agent can author rules β and because the
schema is strict, whatever the agent writes gets machine-validated before it
can touch anything real.
Every execution path validates first:
import { Neuron, Synapse, validateScript } from "@sebasoft/neuron-js";
const validation = validateScript(scriptJson);
if (!validation.ok) {
// exact errors, nothing executed β ever
console.error(validation.errors);
} else {
const result = new Synapse(new Neuron()).execute(scriptJson, context);
}
An invalid script never executes. It returns the exact validation errors
instead of a half-evaluated result. This is the property that makes
AI-generated rules auditable: the schema is the contract, and the contract
is enforced by the runtime, not by convention.
Every run can produce an ExecutionExplanation: which rules matched, which
conditions evaluated true or false, and in what order. For compliance and
debugging this changes the conversation from "trust the engine" to "here is
the trace of decision #4821."
Combined with determinism β same script, same context, same output, every
time β you get replayability: store script + context, replay any decision
exactly, prove the outcome matches the trace.
The piece that connects all of this to AI agents is the bundled
Claude Desktop, Cursor, or any MCP client can register three tools β
validate_script, execute_decision, explain_decision β and operate rule
sets without writing integration code:
{
"mcpServers": {
"neuron-js": {
"command": "node",
"args": ["/absolute/path/to/neuron-js/examples/mcp-server/run.ts"]
}
}
}
The server is read-only and deterministic. Every tool call validates its
inputs first (fail-closed again) and returns JSON. An agent can validate a
rule it just wrote before proposing it, execute it against test contexts,
and explain the result β the full authoring loop.
compares neuron-js against json-rules-engine, json-logic-js, node-rules and
hand-coded TypeScript across three scenarios (pricing, eligibility, routing)
and three input sizes. On Node 24, yarn benchmark reproduces every number:
The fairness gates and full methodology are in the repo. If a number looks
wrong, the harness prints it β file an issue.
Because the primary reader of this documentation is often an agent, the site
practices what it preaches: an llms.txt router with a full-text variant,
Markdown mirrors of every page served at the same URLs (rel="alternate"), MCP tools exposed on the site itself, and a
type="text/markdown"
robots.txt that explicitly welcomes AI crawlers and fetchers.
The result is a discovery loop that matches the product: an agent can find
neuron-js through a search, read its documentation in clean Markdown, register
its MCP server, validate a rule, execute it, and explain the outcome β
end-to-end without a human in the middle. The human shows up at the review
step, which is exactly where the schema guarantees your leverage.
Questions about the benchmark methodology, the MCP integration, or the
validation schema? Happy to go deeper in the comments.