Rule-set builder
A web page for writing a customer's rule set for LMJTFY as a service without writing code. A rule set decides what Jev is asked about a request and what the answer leads to. The builder shows it as nested blocks and dropdowns, checks it as you edit, saves it to the rule-set service and lets you try it.
It has no format of its own. It edits the protobuf message jevrules.v1.RuleSet (../proto/jevrules/v1/rules.proto) and talks to the ConnectRPC RuleSetService, so whatever it saves the TypeScript library (../ts) and the Rhai library read, and the other way round.
Run it
npm install # also needs `npm install` once in ../ts (the generated types and library live there)
npm run build # writes dist/
npm test # type check, then the tests
The dev server (../examples/serve.rs) serves the service and dist/ on one port, so the page talks to the service on its own origin. Open that port in a browser. The "Service" field in the header can point the page at another origin (for npm run dev, for instance).
The page
- Header: start a new rule set, open an example (the four shared fixtures: support triage as text and as trees, parcel damage, the writer), import or export JSON, export as TypeScript (the library's
print). - Inputs: what a caller sends: name, kind (text, number, yes/no, picture), optional, description.
- Flow: one block per step, nested as the tree is. Every block has a name, a kind and an optional "runs only when" condition (the step's
when). The eleven kinds:- Series and parallel hold steps (add, reorder, delete).
- Ask Jev: state fields (each a value), questions in the order sent, pictures (name, image, optional
when) and an optional pinned model. A question is a fixed key or a key worked out at run time, written here (choice with ordered options, score with ordered levels, noul, box) or built at run time from an expression, with an optional "asked only when". A group asks the same questions for each item of a list. - Rules: ordered rules (name, condition, then-step) and an optional otherwise step. Finish edits output fields; refuse and hold take a reason.
- Draft with an LLM: the model, system prompt, what it is asked, pictures, tools (name, description, offered-only-when, typed arguments: text, number, yes/no, lists with limits and uniqueness, records), the call, token and temperature limits, and extra request fields as JSON.
- Value (
let), for each item of a list (the list, names for the item and its position, a body step that can read them) and note (add a value to an output list).
- Expressions are CEL. A value is picked as an input or a step, one of Jev's answers (ask, question, part: label, confidence, probability of a label, yes, box edges), a plain text, number or yes/no, or typed as CEL. A condition is a comparison (operators by type; a choice's own labels to compare with), a yes-or-no value, all of / any of / not (nested), or CEL. The pickers write CEL source text. What they cannot hold (a call, a macro, arithmetic) stays CEL text in a field of its own and is never rewritten. An expression you do not touch keeps the form it had in the file, source or syntax tree.
- Renames follow. Renaming an input, a step, a loop variable, a question key or a label rewrites the CEL that reads it, on the syntax tree.
- Problems: the library's
check()runs on every edit; each problem shows on the block its path points at (with the path), the field at fault turns red, and a list at the top jumps to it. "Check on server" asks the service the same way. - Save and versions: load by name (latest or a version), save (shows the new version or the problems), list versions.
- Try it: a form built from the inputs (a picture must be JPEG or PNG) runs the saved version and shows the outcome, notes, every answer and the trace. Shadow runs a live and a candidate version and says whether they agree.
Files
src/tree.ts: pure edits of the tree (every function returns a newRuleSet) and the checker's path strings.src/expressions.ts: the pickers' model of CEL (operands, conditions) read from a syntax tree and printed as CEL source.src/cel.ts,src/rename.ts,src/steps.ts: walking CEL trees, rename following, walking steps.src/problems.ts,src/time.ts,src/io.ts,src/examples.ts: problems by block, relative times, protobuf JSON, the four fixtures as examples.src/ui/: the Preact components.src/style.css: light and dark colours.test/: Vitest tests: the pure parts, every form driven through DOM events, and every shared fixture loaded, drawn and round-tripped.
← Previous: ts/ · Up: jev-rules · Next: Chapter 28: jev-rules-rhai →