First Decision Rule ends with a rule that reads input.
Here you save that rule and its input as files and run them with Native lispex rule run.
The command writes the decision into a directory that you can inspect and replay later.
Install Native Lispex. The commands use Bash, including Git Bash on Windows. Start in a new directory.
Save the rule and its input
Save the rule from First Decision Rule as house-style.lspx.
(let ((lines-left (car input))
(chapter-heading? (car (cdr input))))
(if (and (>= lines-left 2) (not chapter-heading?))
"allow"
"deny"))Save the input as heading.json.
[2, false]The JSON array arrives as the list (2 #f). (car input) reads 2, the
number of lines left below a section heading. (car (cdr input)) reads #f, so
this is not a chapter heading.
Set the two limit files
lispex rule run reads two limit files. The preparation limits apply while
Native reads the rule and checks that it fits the decision evaluator. The
evaluation limits apply while the rule runs on one input and the result is
recorded. Each number is a maximum. For example, raw_source_bytes allows a
rule of up to 4,096 bytes, and eval_work allows up to 1,000,000 units of
evaluation work. Repeatable Results and Execution Limits
shows what a run reports when it reaches a limit.
Save the preparation limits as prepare-limits.json.
{
"raw_source_bytes": 4096,
"prepare_work": 1000000,
"logical_allocation": 1000000,
"syntax_depth": 64
}Save the evaluation limits as evaluation-limits.json.
{
"canonical_input_bytes": 4096,
"eval_work": 1000000,
"logical_allocation": 1000000,
"semantic_frames": 1000,
"traversal_depth": 256,
"output_bytes": 1000000,
"diagnostic_bytes": 1000000,
"transcript_bytes": 1000000,
"transcript_events": 100,
"result_bytes": 1000000
}Run the rule
lispex rule run --source house-style.lspx --input heading.json \
--prepare-limits prepare-limits.json \
--eval-limits evaluation-limits.json --out decisionThe command creates the decision directory, prints a JSON summary, and exits
with code 0. These fields come from the summary.
{
"category": "semantic-complete",
"code": "complete",
"decision": "allow"
}semantic-complete means the rule completed within the limits.
decision holds the string the rule returned.
The application supplies the line count and whether this is a chapter heading.
allow means the heading may stay. deny means move it to the next page.
Save each input in its own file and run it with a new output directory.
| Input | Decision | Reason |
|---|---|---|
[2, false] | allow | Two lines fit below the section heading |
[1, false] | deny | Too little room below the heading |
[5, true] | deny | A chapter heading starts on a new page |
If the output directory already exists, the command prints
lispex rule run: output already exists to standard error and exits with code 3.
Return the decision as a string
lispex rule run uses the decision evaluator. It reports a string result in
decision. A rule that returns a list, a number, or a boolean still completes,
and its decision is null.
The decision evaluator refuses a rule that uses define or quoted data before
running it. The command then prints a report with request-refusal and
draft-profile to standard error, creates no directory, and exits with code 3.
That is why this rule names its inputs with let and returns "allow" or "deny".
Find the five saved files
rule run writes the complete decision directory in one step. Keep the original
source alongside your input files.
| File | Contents |
|---|---|
prepared.lpxembed | Prepared rule in the prescribed executable format |
canonical-input.lpxvalue | Exact request value in its prescribed byte representation |
result.lpxembed | Result and its link to the request |
receipt-core.lpxreceipt | Portable core linking the rule, input, limits, evaluator, execution transcript, and result |
summary.json | The same JSON summary that rule run printed |
Check the saved decision
lispex rule inspect --dir decision
lispex rule verify --dir decision
lispex rule replay --dir decisionAll three commands exit with code 0, print JSON, and create no files. These are selected fields from their outputs.
| Command | Output fields |
|---|---|
rule inspect | "decision": "allow", "executed": false |
rule verify | "status": "verified", "executed": false |
rule replay | "status": "agreed", "fresh_instance": true |
rule inspect reads the saved data. rule verify checks the exact file set,
identifiers, hashes, and links between records. rule replay runs the request
in a new evaluator instance and compares both the result and portable core.
Malformed or altered records cause a refusal.
Sign the decision for a recipient
To sign this decision and let a printer check it, follow Sign and authenticate the decision in Typesetting Rule Workspace. It starts from the same four files.
Repeatable Results and Execution Limits · Run a Rule Within Set Limits