Skip to content
Talk to our solutions team

`out` — writing results

out is the result. What it holds when the execution finishes is the answer — there is no separate return step, and no rule needs to assemble a final envelope.

It is also readable, so a later rule can branch on what an earlier one produced. That makes out the way rules communicate, and it is why the scratch-memory family on in is no longer the answer.

rule ClassifyClosingDisclosure "identify the form" salience 100 {
when
bbox.Doc().Top(10).Has("Closing Disclosure")
then
out.Set("docType", "closing_disclosure");
Retract("ClassifyClosingDisclosure");
}

Writes a value at path.

ParameterTypeMeaning
pathstringWhere to write. Dotted paths nest, where path keys are enabled
vanyThe value — text, a number, a map, a list, or a document read

v may be a plain value or a document read. When it is a read that carries metadata — a confidence, the text that actually matched — those attributes travel with it, so you do not have to unpack the value to keep its provenance.

rule CaptureLoanAmount "read the loan amount and keep its confidence" {
when
bbox.Doc().Right("Loan Amount").Found()
then
out.Set("loanAmount", bbox.Doc().Right("Loan Amount").Currency());
}

out.Set for a value that is already typed.

ParameterTypeMeaning
pathstringWhere to write
vValueAn already-typed value

Removes the value at path.

ParameterTypeMeaning
pathstringWhat to remove

Useful where a later rule supersedes an earlier classification and the earlier key would otherwise remain alongside the correction.

Attaches one attribute to an already-written path.

ParameterTypeMeaning
pathstringThe path that already holds a value
namestringThe attribute name
vanyThe attribute value

This is the escape hatch for metadata the producing value could not supply. It should stay rare — validation reports its use — because a value that carries its own provenance is better than one annotated afterwards by a rule that happened to know something.

rule MarkManualReview "this amount came from a low-confidence read" {
when
out.Has("loanAmount") && out.AttrNum("loanAmount", "confidence", 1.0) < 0.7
then
out.Attr("loanAmount", "needsReview", true);
}

Every read takes the same shape as the in equivalents and never raises.

Reports whether anything is present at path.

ParameterTypeMeaning
pathstringThe path to test
rule ClassifyFallback "only classify if nothing else did" salience 1 {
when
!out.Has("docType")
then
out.Set("docType", "unknown");
}

The low salience plus the Has guard is the standard “nobody claimed this” idiom — it runs last, and only when it is still needed.

Reports whether path is absent or holds an empty value.

ParameterTypeMeaning
pathstringThe path to test

The first-class form of “has anything classified this page yet?”, which older rulesets express as a chain of map reads. Prefer it: Has is true for a key written as an empty string, and usually that is not what the rule meant.

Returns the raw value at path, or nil.

ParameterTypeMeaning
pathstringThe path to read

Returns the typed value at path, or Null.

ParameterTypeMeaning
pathstringThe path to read
ParameterTypeMeaning
pathstringThe path to read
defstringReturned when absent
ParameterTypeMeaning
pathstringThe path to read
defint64Returned when absent
ParameterTypeMeaning
pathstringThe path to read
deffloat64Returned when absent

Write the default with a decimal point — 0.0, not 0 — for the same type-dispatch reason as in.EqNum.

ParameterTypeMeaning
pathstringThe path to read
defboolReturned when absent

Returns the date at path, or the zero date.

ParameterTypeMeaning
pathstringThe path to read

Returns the map at path, or nil.

ParameterTypeMeaning
pathstringThe path to read

Attributes are opaque producer metadata recorded alongside a value — a confidence score, the text that matched, the page it came from. They ride along with out.Set and are readable afterwards.

Returns everything recorded for path, or nil.

ParameterTypeMeaning
pathstringThe path to inspect

Reports whether path carries the named attribute.

ParameterTypeMeaning
pathstringThe path to inspect
namestringThe attribute name

Returns the named numeric attribute, or def.

ParameterTypeMeaning
pathstringThe path to inspect
namestringThe attribute name
deffloat64Returned when the attribute is absent

The confidence gate is the usual use, and the default is load-bearing: pass 1.0 so a value carrying no confidence is treated as certain rather than as zero-confidence.

rule LowConfidenceExtraction "flag anything read below the threshold" {
when
out.Has("borrowerName") && out.AttrNum("borrowerName", "confidence", 1.0) < 0.85
then
findings.Warn("LowConfidenceExtraction", "extraction",
strings.Sprintf("Borrower name read at %s confidence",
to.Fixed(out.AttrNum("borrowerName", "confidence", 1.0), 2)));
}

Returns the named string attribute, or def.

ParameterTypeMeaning
pathstringThe path to inspect
namestringThe attribute name
defstringReturned when the attribute is absent

Returns everything collected so far.

Returns every path’s attributes, keyed by path.

Serialises the collected results.

Returns every write in order, with the rule that made it.

Returns the writes to one path.

History is the debugging tool for the question that otherwise takes a bisect: which rule set this, and did anything overwrite it? On a ruleset where several rules can claim the same key, that is the first thing to look at.

rule TraceDocType "record how many times the classification changed" salience 1 {
when
out.Has("docType")
then
log.Debug("classification history",
"writes", array.Len(to.List(out.HistoryFor("docType"))));
}

Still working, listed so you recognise them.

Older formWrite insteadWhy
out.GetStr(key)out.Str(path, def)Takes a default
out.GetInt(key)out.Int(path, def)Takes a default
out.GetFloat(key)out.Double(path, def)Takes a default
out.GetBool(key)out.Bool(path, def)Takes a default
out.GetMap(key)out.Map(path)Same shape, current name
out.Append(key, val)AttributesIt predates attributes; it was used to accumulate provenance by string concatenation
out.UnwrapColumn(...)delivery.ExplodeColumn(...)Moved to the delivery plugin
out.UnwrapColumnWithTemplate(...)delivery.ExplodeColumn(...)Moved to the delivery plugin

Three methods exist on the type and are the engine’s, not yours: BindInvalidator, SetCurrentRule and EnablePathKeys. The engine calls them once per execution — to wire cache invalidation, to attribute history, and to apply the deployment’s path-key setting. A rule has no reason to call any of them.