Skip to main content
A relation lets a judgment read the other records it needs, so relations are a capability of an AI column’s inputs: the open invoices a payment could settle, the contract an amendment changes, the answers of a contract’s clauses. Brussle records which answers read which documents, runs exactly the affected answers again when one of those documents changes, and keeps the counts from them as features that the fit on your outcomes weighs. A relation makes the right question possible, but it does not make the engine more accurate. Ask a narrow question about one document with the right other document beside it, keep counts as features, and measure the result with your outcomes. An answer that reads only its own document needs no relation.

How a relation connects documents

A relation is a key under related in the judgment’s context recipe (except previous, which is its own key). Documents connect, in the judged document’s namespace, through an ordinary attribute that you write, such as attributes.contract_id. A relation never searches for similar text, so a payment reads the invoices that share its key and no others. Finding your relations shows which of your attributes hold the ids of other documents. The policy, queue, linked-accounts and hierarchy guides each start from a starter (moderation.under_policy, triage.against_queue, linked_accounts.risk, hierarchy.inherits_risk) and an editor preset in the dashboard. Groups and tenant summaries also report over many documents, but they are not relations. The heavy border in each diagram marks the judged document.

Candidates that share a key

A block is the set of documents that share a key value, from one or more attributes you choose. The judgment makes one engine call for each judged document, not one for each pair. Here the key is the counterparty and the currency, and one choice picks the invoice the payment settles, or none. A document reads the newest documents of its block by default, in a window. With "relative": "before" (or "after"), it reads the last_n documents created just before (or after) it instead, such as the ten messages before it in its thread, and a change re-judges only the documents whose last_n it changed. See records in sequence.

Documents a matcher linked

Use a link when the connection is itself a judgment, since no attribute says which invoice a payment settles until settles picks one. A judgment on each invoice can then read the payments that settles linked to it. The invoice’s judgment declares {"theirs": "answers.settles.value", "mine": "id", "when": {"below": "unmatched"}}, which selects the payments whose current pick is this invoice, below the unmatched threshold of settles.
  • A link follows the matcher’s current answer, so when settles picks another invoice, or the payment leaves the relation’s match, Brussle judges both invoices again. The relation can read the payments’ other answers too, and it adds one level.
  • A judgment on the payment’s side reads the one invoice settles picked. See the document a match picked.
  • To know only whether a payment matched, count the matches of a matcher instead.

The document as the judgment last saw it

Use previous when the question is about a change. The judgment reads a contract section as it is now beside the revision its last answer saw (or the revision last approved) and answers whether it changed in a way that matters. An edit to a field it does not read costs nothing. See change detection.

The document it points at

Use this when a record must agree with one record it names. An order line, for example, holds its product’s id in attributes.product_id and is judged with that product. When the product changes in a way the lines read, Brussle judges each line in scope again, which is a fan-out. The attribute can also hold a named list of up to 254 ids (the invoices a remittance advice names, or a folder’s ancestors), read in list order up to last_n. See name several documents.

Documents that point at the judged one

Use this when the answer depends on the records that point at it, as text, counts or both, such as a contract with its amendments (each holds the contract’s id in attributes.contract_id) or an invoice with its payments. The contract reads its newest amendments, and a new or changed one makes it pending until Brussle judges it again. An order keeps the documents a field ranks first instead (the invoices due soonest, say), sorted within the newest 1,000, and range_full: true says when more matched. Where a window starts. A window, such as 90 days, counts back from the later of the newest write to the judged document and the newest creation among its related documents, never from today. You cannot set the time of a write, so after you import existing data, a window of 365 days holds nothing created more than 365 days before the import. To read imported history, use last_n, which reads the newest by created_at. See newest created first. A relation can read the outcomes you posted for related documents, to ask, for example, “were this customer’s last orders refunded?”
  • The newest outcome, as posted. outcomes.<judgment>.value is the outcome with the latest observed_at (on a tie, the one posted last), shown exactly as posted and never as a band.
  • Documents with no outcome are still selected and counted in count, but they show nothing under the path and match no count_where on it. labelled counts the documents that have one.
  • Use it in fields, count_where, latest and match. In match, {"exists": true} selects only documents with an outcome, and the relation’s stats say when it found fewer than asked. A feature can name count_where, labelled, or the latest of a bool or score outcome.
  • Stable. An outcome is never judged again and has no noise, so what the relation shows changes only when a newer outcome arrives or a document enters or leaves the selection. Outcomes add no level.
  • The current life, the current type. A document deleted and created again never reads an outcome about its earlier life, and an outcome posted before its document exists is read once the document is created. After you rename an option, count_where and match on the new name do not match outcomes posted under the old one.
  • The judgment it reads stays readable. Brussle refuses a change to its answer type, or its deletion, with conflict, naming the readers.
  • A posted outcome re-judges the readers. They read pending until then. The re-judges count against each reader’s rolling limit, so a large upload can leave some stale (limit_reached) for a while.

Answers of other judgments

Use this when the related documents already have a judgment. A contract, for example, reads the one_sided answer of each clause rather than the clause text, and Brussle judges it again when an answer changes what it reads (a clause crossing the threshold, say). Show each answer as a band, or count it against a cut. See roll-ups. A relation reads decision columns only: a path into a text, json or embedding judgment’s answer is refused at the create with invalid_request and details.path. Select by topic, not by verdict. When a match selects related documents by another judgment’s answer (Brussle warns at create), ask that judgment about the topic (“Is this section about exclusivity, including a change to it or its removal?”) instead of the verdict (“Does this section contain exclusivity?”). An amendment that deletes the clause is about exclusivity but does not contain it, so a selection by verdict never reads it. A selection by topic reads more, and its raw numbers can run high, so let the correction on your outcomes make them true. To compare the two, name the topic selection as an alternative, whose row is scored on today’s related documents (as_of: now).

Numbers from relations: features

Keep a count, a sum or the latest value from a relation as a feature: add "render": false to the relation’s aggregate so the engine does not read it, and name it in features. The fit on your outcomes then weighs it beside the engine’s answer. The engine does not forecast, so for a question about what will happen, the counts and the fit carry the number. Your own numbers as features covers how the fit uses them, the other sources and the limit of 12. This judgment counts each contract’s clauses, and the clauses whose one_sided answer crossed its threshold:
Both numbers sit beside each answer, and the many_one_sided threshold reads count_where with no engine.

The aggregates a feature can name

  • sum and avg over another judgment’s numbers are features only, refused unless named in features (tickets.avg(answers.urgent.p), for example). A child whose newest answer failed adds its last good value (counted in the stats’ last_good), while a child with no answer is left out. With no documents, sum is 0 and avg is null.
  • min and max over p or score are the raw extremes, whatever band the context shows.
  • latest of a threshold or a bool outcome is 1 or 0, and of a score outcome its level. Brussle refuses latest of a choice’s value, of a choice outcome and of an image (invalid_request, with details.path naming it, such as images.photo), because none is a number.
  • Exact. Features are 64-bit, so whole numbers (amounts in cents, say) are exact up to 2^53, and thresholds and filters compare the stored value exactly.
  • As fresh as the answer. A feature is computed with the answer, so it follows the related documents after the judgment’s debounce (10 minutes by default with relations and features). Its window ends at the judged document’s newest activity, not today (where a window starts).

Numbers about each candidate

A choice among candidates can keep numbers about each candidate, such as candidates.each(state.open_amount), and candidates.count (how many invoices the payment could settle). The fit can then change which candidate is picked, but Brussle never applies it when it picks worse than the engine on your held-out outcomes. A candidate feature cannot read a candidate’s answers. See features on a choice among candidates.

What the engine reads, and what changes the bill

The engine reads a relation’s aggregates by default, and "render": false keeps them out (except latest). When a change moves only what the engine does not read, Brussle keeps the engine’s answer with the new features and makes no engine call (a reuse). A reuse is an evaluation (naming the one it reused in engine_answer_from) and is not billed, but it is still a new answer that thresholds, filters and subscriptions see and that counts against the rolling limit. render is part of the version, so a new version with "render": false starts without the previous version’s fit.

Which numbers move with noise

An engine’s numbers can vary from call to call (Jev’s do), and the tradeoffs say what that means for a threshold.
  • A sum or avg over children’s p moves each time any child is judged again, so a threshold over it near its cut can flip back and forth (there is no hysteresis).
  • A count_where on a named threshold moves only when a child crosses the cut.
  • Counts and sums over your own fields move only when your data does.
  • Any answer judged again can cross a threshold near its cut with nothing changed, and a policy simulation measures this as noise.

At most three levels, never a loop

Each read of another judgment’s answers is one level. A chain has at most three levels, so at most four judgments. “Clause, contract, counterparty, portfolio” is the longest: Brussle refuses at create a chain that would be longer, or that comes back to a judgment already in it, and names the chain. A chain runs over judgments rather than kinds of document, so a payment judgment can read a merchant judgment that reads the payments’ fields. See three levels. Before a relation can read a judgment’s answers, that judgment must:
  • be active and on_change, in the same namespace or template;
  • answer each document the relation selects;
  • not be a composite with parts;
  • if it reads a document it points at, or a block, have a fan-out scope with no bound, so that no document keeps an answer nothing judges again.
A judgment that chooses among candidates (options.from) can be read only through a link, or in a count_where that compares its value with none_of_the_above (equal, or {"not": ...}). Brussle refuses any other read, since its value is only a document id. While a judgment has readers, Brussle refuses a change that would break them, with conflict, naming the readers. Along a chain:
  • Each level adds a debounce, and GET on a judgment lists each chain under upstream, with the sum of the debounces.
  • Each evaluation’s upstream says whether a judgment it read was behind at the time: child_pending (it will catch up by itself) or child_out_of_scope (it will not).
  • freshness.wait_for_children: true waits while an answer it reads is pending, then judges once, so a load of related documents costs one evaluation instead of two. It waits at most max_wait_ms, or 10 minutes with no ceiling. See freshness policies.

Bands keep answers stable

Brussle judges a document again only when its compiled context changes, so if you show a number from another document as a band (low, medium or high, say), a move inside a band changes nothing: no evaluation, no fan-out, no bill. Show another judgment’s probability or score as a band, or count it against a cut, and never sum or average it in the context, where it moves a little each time that judgment runs. A sum or an average is fine as a feature. See bands.

No routine action waits for a person

You confirm two numbers once, when you create or change a definition: the replay estimate of what the judgment costs each month and, for a judgment with a relation, its rolling limit, the most its re-judges can cost in any 30 days (300,000 documents by default). After that, every re-judge that a change to another document causes runs without a person. Brussle defers work past the limit and never declines it, so its answers read stale with stale_reason limit_reached until there is room. See control what a change re-judges.

What every kind shares

  • Limits. A judgment has at most 4 relations. See limits.
  • Reference indexes. Each key attribute, in each direction, needs a reference index, which a reference_index job builds when a judgment first uses it (or again for another match). A namespace has at most 8, counting group keys.
  • Only what is shown counts. A write that changes nothing a relation shows, including an edit past a field’s max_chars, judges nothing again and is not billed.
  • An exact audit. Each answer records watermark (how far into the namespace’s writes its context had read) and answers_generation (how far it had read other answers and blocks), and its evaluation lists every document it read in related_documents. See evaluations.
  • Freshness says why. A change through a relation makes an answer pending, or stale with a cause when nothing will judge it yet. See freshness.
  • A change to a relation is a new version, with its own fit, and answers from the earlier one read stale (older_version) after you activate it. Fan-out settings are not part of a version.
The API reference calls a judgment with relations an entity judgment, and its replay estimate counts the documents it applies to as entities.