How-to guides: How to build a decision table app
// how-to guide · Build
How to build a decision table app
Write a prompt for a decision table app, check it, prove it with the gate and publish it.
Choose this pattern when its answer is the one your app gives. The rules are tried in order, and the first one that matches gives the answer. If none matches, the default answer applies. This is a DMN decision table with the FIRST hit policy.
The standard is OMG DMN 1.5, hit policy FIRST. The guide builds the Requantization clamp example; put your own rules in its place.
The data in this figure
| Step | What happens |
|---|---|
| 1. Write the prompt | start from Requantization clamp |
| 2. Check the prompt | node builder/cli.mjs check |
| 3. Build it and pass the gate | just vv in the locked SDK |
| 4. Publish it | GitHub Pages |
1. Write the prompt
Start from the Requantization clamp prompt, the decision table example with the fewest rules (2 rules). Keep pattern set to decisionTable. Replace the fields, answers, rules and examples of its app with your own.
1. Write the prompt 280 lines
{
"schema": "prism/prompt/1",
"pattern": "decisionTable",
"goal": "Sort how the MNIST network squeezes a 32-bit sum into an 8-bit value, so no value ever falls outside 0 to 255.",
"repository": "UOR-Foundation/MNIST",
"app": {
"name": "mnist-requant-clamp",
"title": "Requantization clamp",
"purpose": "Classify the scaled accumulator q of one requantized activation, from its sign and magnitude, as clamped to the floor 0, passed through unchanged, or clamped to the ceiling 255.",
"fields": [
{
"name": "sign",
"kind": "choice",
"values": [
"negative",
"nonnegative"
],
"means": "the sign of q = ((acc + bias) * M + 2^31 + Z * 2^32) quot 2^32"
},
{
"name": "q",
"kind": "number",
"min": 0,
"max": 2147483648,
"means": "the magnitude of q, bounded by the 32-bit fixed-point range"
}
],
"outcomes": [
"floor",
"passed",
"ceiling"
],
"meanings": {
"floor": "q is below 0 and the code is 0, the uint8 zero point",
"passed": "q is already a uint8 code and is kept",
"ceiling": "q is above 255 and the code is 255"
},
"rules": [
{
"when": [
{
"field": "sign",
"op": "is",
"value": "negative"
},
{
"field": "q",
"op": ">",
"value": 0
}
],
"then": "floor",
"why": "src/Mnist/Core.lex.tex requant: lo = if q < 0 then 0 else q"
},
{
"when": [
{
"field": "q",
"op": ">",
"value": 255
}
],
"then": "ceiling",
"why": "src/Mnist/Core.lex.tex requant: hi = if 255 < lo then 255 else lo"
}
],
"otherwise": "passed",
"otherwiseWhy": "src/Mnist/Core.lex.tex requant: a q in 0..255 is returned as the activation code; README.md: uint8 activations with zero point 0",
"properties": [
{
"kind": "never",
"when": [
{
"field": "sign",
"op": "is",
"value": "negative"
},
{
"field": "q",
"op": ">",
"value": 0
}
],
"then": "passed",
"why": "a negative accumulator never becomes a positive code"
},
{
"kind": "never",
"when": [
{
"field": "sign",
"op": "is",
"value": "nonnegative"
},
{
"field": "q",
"op": ">",
"value": 255
}
],
"then": "passed",
"why": "no activation exceeds 255"
},
{
"kind": "always",
"when": [
{
"field": "q",
"op": "<=",
"value": 255
},
{
"field": "sign",
"op": "is",
"value": "nonnegative"
}
],
"then": "passed",
"why": "an in-range code is never altered"
}
],
"examples": [
{
"request": "nonnegative 0",
"response": "passed"
},
{
"request": "nonnegative 7",
"response": "passed"
},
{
"request": "nonnegative 255",
"response": "passed"
},
{
"request": "nonnegative 256",
"response": "ceiling"
},
{
"request": "negative 1",
"response": "floor"
},
{
"request": "negative 0",
"response": "passed"
},
{
"request": "negative 4096",
"response": "floor"
}
]
},
"stakeholders": [
{
"name": "Model auditor",
"text": "Checks that the LexLean network computes exactly what mnist-12-int8.onnx computes, layer by layer.",
"concerns": [
"Correct answers",
"Proved guarantees"
]
},
{
"name": "Package integrator",
"text": "Embeds the certified rust-std mnist package and needs every activation to be a uint8 code.",
"concerns": [
"Proved guarantees",
"Refused malformed requests"
]
}
],
"components": [
{
"name": "onnxruntime",
"kind": "externalSystem",
"text": "onnxruntime 1.29.0, whose class on all 10,000 test images is the authority (MN-05)."
},
{
"name": "mnist package",
"kind": "releaseBinary",
"text": "The certified rust-std package in dist/ exporting run(Bytes)."
}
],
"threats": [
{
"name": "Activation wraps past 255",
"text": "A large accumulator is truncated to 8 bits instead of saturating, changing the class.",
"stride": "tampering",
"asset": "answer",
"likelihood": "medium",
"impact": "major",
"control": {
"name": "Saturating ceiling",
"text": "q above 255 is clamped to 255.",
"evidence": [
{
"kind": "proof",
"reference": "MnistRequantClampProofs::inv002Holds"
},
{
"kind": "gate",
"reference": "UOR-Foundation/MNIST MN-05: class equal to onnxruntime on 10,000 images"
}
]
}
},
{
"name": "Negative activation",
"text": "A negative accumulator passes as a large unsigned code.",
"stride": "tampering",
"asset": "answer",
"likelihood": "medium",
"impact": "major",
"control": {
"name": "Floor at the zero point",
"text": "Negative q is clamped to 0.",
"evidence": [
{
"kind": "proof",
"reference": "MnistRequantClampProofs::inv001Holds"
}
]
}
},
{
"name": "Accumulator overflow",
"text": "The accumulator itself overflows before requantization.",
"stride": "denialOfService",
"asset": "request",
"likelihood": "low",
"impact": "major",
"accepted": "README.md says so: that the accumulators never overflow is not a theorem; the overflow effect stays declared and checked at every operation."
}
],
"quality": [
{
"characteristic": "Functional suitability",
"subcharacteristic": "Functional correctness",
"requirement": "Codes fit uint8",
"text": "Every activation code lies in 0..255.",
"measure": "Largest activation code",
"measureText": "The largest code any request is answered with.",
"threshold": 255
},
{
"characteristic": "Functional suitability",
"subcharacteristic": "Functional appropriateness",
"requirement": "Class agrees with the authority",
"text": "The package returns onnxruntime's class on every test image, as MN-05 gates.",
"measure": "Class disagreements",
"measureText": "Test images whose class differs from onnxruntime 1.29.0.",
"threshold": 0
}
],
"journeys": [
{
"stakeholder": "Model auditor",
"steps": [
"REQ-001",
"REQ-002",
"otherwise",
"INV-003"
]
},
{
"stakeholder": "Package integrator",
"steps": [
"INV-001",
"INV-002",
"refuse"
]
}
],
"axioms": {
"inv001Holds": [
"Classical.choice",
"Quot.sound",
"propext"
]
}
}The prompt as raw JSON · Open it in the builder
It sets these members. Each meaning is quoted from the input schema of prism_prompt.
1. Write the prompt 21 rows
| Member | Presence | In this prompt | Meaning |
|---|---|---|---|
| pattern | optional | decisionTable | The pattern the behavior follows: decisionTable (OMG DMN 1.5, hit policy FIRST, the default), policyDecision (OASIS XACML 3.0: the answers are exactly permit, deny, not-applicable and indeterminate) or stateMachine (OMG UML 2.5.1: the answer is the next state, and machine is required). |
| goal | optional | text | The goal the app is built toward, in one sentence a developer would say. It becomes the spec purpose when app.purpose is left out. |
| repository | optional | UOR-Foundation/MNIST | owner/name of the repository the app will live in, for its page and links. |
| app | required | name, title, purpose, fields, outcomes, meanings, rules, otherwise, otherwiseWhy, properties, examples | The whole app as a prism/spec/1 spec, the input of prism-code's prism_spec. Its members are below. |
| app.name | optional | mnist-requant-clamp | Lower case and hyphens, such as loan-approval. |
| app.title | optional | Requantization clamp | |
| app.purpose | required | text | What the app decides, in one sentence. |
| app.fields | required | 2 entries | One request is these values in order, separated by spaces. |
| app.outcomes | required | 3 entries | Lower-case words; invalid is reserved. |
| app.meanings | optional | floor, passed, ceiling | What each answer means, such as {"review": "a person must decide"}. |
| app.rules | required | 2 entries | In order; the first that matches decides. |
| app.otherwise | required | passed | The answer when no rule matches. |
| app.otherwiseWhy | optional | text | Why, in a few words, such as "it enforces INV-001". |
| app.properties | optional | 3 entries | What must never or always happen; each becomes a theorem Lean proves. |
| app.examples | optional | 7 entries | Requests and their expected answers; each becomes an acceptance vector. |
| stakeholders | optional | 2 entries | Who the app is for. A Verifier, anyone who replays the holo before trusting it, is always added. |
| components | optional | 2 entries | Systems outside the app that send it requests or read its answers. |
| threats | optional | 3 entries | What can go wrong, beyond the threats every app has (an oversized or malformed request, a substituted holo or source, a granted capability, an answer a property rules out). |
| quality | optional | 2 entries | How good is good enough, as ISO/IEC 25010:2023 requirements with a measure and its threshold. |
| journeys | optional | 2 entries | Ordered steps a stakeholder takes. A step is a rule ID (REQ-001), a property ID (INV-001), otherwise or refuse. |
| axioms | optional | inv001Holds | The exact axiom set a verify observed for a generated declaration, by declaration name, as prism-code records it when LexLean reports LLV7005. `node builder/cli.mjs axioms` writes it from a verify log. |
2. Check the prompt
In a clone of prism-devrel, run the check on your prompt. It checks the prompt and prints what the app will claim, writing nothing.
git clone https://github.com/afflom/prism-devrel.git && cd prism-devrel
node builder/cli.mjs check examples/mnist-requant-clamp.prompt.jsonFor the Requantization clamp prompt it prints this.
Requantization clamp: Decision table (OMG DMN 1.5, hit policy FIRST), 82 files, 25 acceptance vectors
MR-01: The app never answers passed when sign is negative and q is above 0
MR-02: The app never answers passed when sign is nonnegative and q is above 255
MR-03: The app always answers passed when q is at most 255 and sign is nonnegative
MR-04: The architecture description declares every stakeholder, concern, component, edge, viewpoint and view it references
MR-05: The ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declared
MR-06: Every compliance obligation is numbered in order and names its evidenceExit codes: 0 done, 2 the prompt was refused (the reason is printed), 64 usage.
3. Build it and pass the gate
Save this script as verify.sh in the clone, with PROMPT set to your prompt. It is the pages workflow's own steps for an example.
3. Build it and pass the gate 36 lines
set -euo pipefail
PROMPT=examples/mnist-requant-clamp.prompt.json
RUNNER_TEMP=$(mktemp -d)
field() { node -e 'process.stdout.write(JSON.parse(require("fs").readFileSync("frame.lock", "utf8")).source[process.argv[1]])' "$1"; }
instance="$RUNNER_TEMP/instance"
git init -q "$instance"
git -C "$instance" fetch -q --depth 1 "https://github.com/$(field repository)" "$(field commit)"
git -C "$instance" checkout -q --detach FETCH_HEAD
test "$(git -C "$instance" rev-parse HEAD)" = "$(field commit)"
node builder/cli.mjs build "$PROMPT" --out "$instance"
image=$(sed -n 's/.*"sdk_image":"\([^"]*\)".*/\1/p' prismpm.lock)
if [[ ! $image =~ ^[a-z0-9.-]+(:[0-9]{1,5})?/[a-z0-9./_-]+@sha256:[0-9a-f]{64}$ ]]; then
printf '%s\n' 'prismpm.lock does not select an immutable SDK image' >&2
exit 64
fi
docker_config=$(mktemp -d)
# The SDK's /tmp is a private directory on the runner's own disk, so the
# build's scratch space is bounded by the disk the runner has, not by a
# fixed size; it is removed with the credentials when the step ends.
scratch=$(mktemp -d)
mkdir -p "$scratch/prismpm-home/.docker"
trap 'rm -rf "$docker_config" "$scratch"' EXIT
printf '{}\n' >"$docker_config/config.json"
docker run --rm \
--user "$(id -u):$(id -g)" \
--group-add "$(stat -c '%g' /var/run/docker.sock)" \
--volume "$scratch:/tmp" \
--volume "$instance:$instance" \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume "$docker_config:/tmp/prismpm-home/.docker:ro" \
--workdir "$instance" \
--env DOCKER_CONFIG=/tmp/prismpm-home/.docker \
--env BUILDX_CONFIG=/tmp/prismpm-buildx \
--env HOME=/tmp/prismpm-home \
--env PRISMPM_EPHEMERAL_HOME=1 \
"$image" just vvIt calls git, node and docker. Run it, and keep the log.
bash verify.sh 2>&1 | tee verify.logWhen it passes, the verified holo is in the instance the script made under RUNNER_TEMP, at "$instance"/app/.prism/build/*/*.holo.
4. Publish it
- How to publish an app on GitHub Pages: its own repository proves and serves it.
What the gate proves
The Decision table obligation of OMG DMN 1.5, hit policy FIRST names its evidence: MnistRequantClamp::judge.
Each property of the Requantization clamp prompt is a theorem the Lean kernel checks for every request.
| Property | Statement | Theorem |
|---|---|---|
| INV-001 | It never answers passed when sign is negative and q is above 0. | MnistRequantClampProofs::inv001Holds |
| INV-002 | It never answers passed when sign is nonnegative and q is above 255. | MnistRequantClampProofs::inv002Holds |
| INV-003 | It always answers passed when q is at most 255 and sign is nonnegative. | MnistRequantClampProofs::inv003Holds |
Every decision table example
Every decision table example 21 items
- Rule 30 cell. Find the next state of one Rule 30 cell from its neighbours, so every row of the pattern can be replayed and checked.
- Strike die. Roll one strike die in Karst: Zero Horizon, with cover and momentum. Then every roll in a fight can be replayed.
- Wise deferral. Decide if a CIRIS agent goes ahead, asks a Wise Authority first, or stops. Then each of its choices can be checked later.
- Current support. Tell if a PrismLegal matter is current. A legal strategy should only rest on support that is checked, grounded and up to date.
- Header work. Decide if a block header's hash meets its target, so any node can check the proof of work from the header alone.
- Plant attunement. Decide if a player's gesture in Verdant Resonance reaches the plant they face. The garden then answers the same walk the same way.
- Capability route. Decide how UORust records a Rust target by the effect it reaches. Every effect becomes a threat in the model, and nothing hides as pure.
- Publish gate. Decide if Prism-DevRel may publish its pages, so no reader ever sees a page that gets the model wrong.
- Proposal admission. Decide if a router's proposal joins the app. A stale, unclear or clashing proposal never becomes part of it.
- Compression admission. Decide if a new UORC archive replaces the best one so far. A smaller size must never come at the cost of lost data.
- Quorum commit. Decide if a round of votes commits a block. A validator commits only when enough others agree, and only once it holds the block itself.
- Address admission. Decide if a value gets a UOR-ADDR address. Two values that mean the same thing share one label, and a broken value gets none.
- Dataflow policy. Decide if a Prism dataflow script is accepted, rejected for breaking a policy, or an error. A script that leaks memory or personal data is never accepted.
- Draft admission. Decide if LexLean MCP takes a draft from an AI model. No file path leaves its folders, and no draft goes over the owner's limits.
- Coded matmul admission. Decide if a coded matrix request is computed, or which error it gets. The checks run in the order the LexLean Matmul protocol sets.
- UTQC row honesty. Decide if a row of the UOR Atlas UTQC dictionary passes the honesty check, so no row claims more than its source shows.
- Calculator protocol. Sort a Calculator request by the kind of answer it gets. A bad, unknown or too-large request never gets a number back.
- Requantization clamp. Sort how the MNIST network squeezes a 32-bit sum into an 8-bit value, so no value ever falls outside 0 to 255.
- JCS NFC admission. Give the one refusal code for a broken JSON document, or let it through. Then every tool refuses the same input with the same code.
- Two-seed bar. Decide if a two-seed UOR-R4 run beats its baselines, so a result inside the noise is never called a win.
- Docs sync. Decide what the nightly docs sync does to uor.foundation. The site must never swap its docs for an empty or unchecked release.
Other patterns
- How to build a policy decision app: The answer is one XACML 3.0 decision: permit, deny, not-applicable, indeterminate.
- How to build a state machine app: The answer is the next state, given the current state and an event.
Words on this page 10
- record
- One entry in a facet: a component, a threat, a measure or a journey step, with the place in the source it came from.
- LexLean
- The language Prism models are written in. It reads like LaTeX and compiles to Lean 4.
- Lean kernel
- The small checker at the heart of the Lean prover. It accepts a proof only if every step follows the rules.
- theorem
- A statement about the model that the Lean kernel has checked, so it holds for every input, not only the ones tested.
- holo
- The app Prism builds: one signed, verified file that a browser or a device runs.
- MCP
- Model Context Protocol: an open protocol through which AI agents call tools such as the Prism builder.
- UOR
- Universal Object Reference: the UOR Foundation's framework for naming any object by its content.
- decision table
- A table of rules, as in OMG DMN 1.5: each row says which inputs lead to which outcome.
- XACML
- OASIS eXtensible Access Control Markup Language 3.0: a policy decides permit, deny, not applicable or indeterminate.
- prompt
- One JSON document that describes an app. The builder turns it into every facet of a Prism model.