// A decision that reads other records:
// each payment beside its customer's open invoices.
await ns.judgments.create({
from_starter: "payments.settles",
paths: {
kind: "attributes.kind",
payment_kind: "payment",
invoice_kind: "invoice",
status: "attributes.status",
unmatched: "unmatched",
open: "open",
block: "attributes.block",
payment_amount: "state.amount",
reference: "state.reference",
invoice_number: "state.number",
invoice_amount: "state.amount",
},
engine: { name: "jev", version: "current" },
freshness: { policy: "on_change" },
confirm: true,
});
# A decision that reads other records:
# each payment beside its customer's open invoices.
ns.judgments.create(
from_starter="payments.settles",
paths={
"kind": "attributes.kind",
"payment_kind": "payment",
"invoice_kind": "invoice",
"status": "attributes.status",
"unmatched": "unmatched",
"open": "open",
"block": "attributes.block",
"payment_amount": "state.amount",
"reference": "state.reference",
"invoice_number": "state.number",
"invoice_amount": "state.amount",
},
engine={"name": "jev", "version": "current"},
freshness={"policy": "on_change"},
confirm=True,
)
What Brussle didStep 1 of 5
settles v1created
readsopen invoices in the payment’s block
runswhenever something it read changes
// Write records as they change. Brussle maps
// which decisions read which records.
await ns.write({
upsert: [inv_1001, inv_1002, inv_1003, pay_1],
wait_for: ["settles"],
});
# Write records as they change. Brussle maps
# which decisions read which records.
ns.write(
upsert=[inv_1001, inv_1002, inv_1003, pay_1],
wait_for=["settles"],
)
What Brussle didStep 2 of 5
pay_1settles → inv_1002fresh
readinv_1001 · inv_1002 · inv_1003
// Record what happened. The outcome joins
// the answer it measures.
await ns.outcomes.append([
{
document_id: "pay_1",
judgment: "settles",
value: "inv_1002",
observed_at: new Date().toISOString(),
},
]);
# Record what happened. The outcome joins
# the answer it measures.
ns.outcomes.append([
{"document_id": "pay_1", "judgment": "settles", "value": "inv_1002", "observed_at": datetime.now(timezone.utc).isoformat()},
])
What Brussle didStep 3 of 5
pay_1outcome inv_1002 · joins settles v1
fitnightly, from 50 outcomes, 15 of each answer
// After 50 outcomes, each answer carries the
// corrected number beside the model's.
const doc = await ns.get("pay_7", { answers: ["settles"] });
const settles = doc.answers?.settles;
if (settles?.type === "choice" && settles.calibrated) {
console.log(settles.value); // the model's pick
console.log(settles.calibrated.value); // the corrected pick
console.log(settles.calibrated.dist, settles.calibrated.interval);
}
# After 50 outcomes, each answer carries the
# corrected number beside the model's.
doc = ns.get("pay_7", answers=["settles"])
a = doc.get("answers", {}).get("settles")
if a and a["type"] == "choice" and "calibrated" in a:
print(a.get("value")) # the model's pick
print(a["calibrated"]["value"]) # the corrected pick
print(a["calibrated"]["dist"], a["calibrated"]["interval"])
What Brussle didStep 4 of 5
pay_7settles → inv_2210fresh
model said0.91
corrected0.84 · stage full · 1,432 outcomes
// Mark one invoice paid. Only the payments
// that read it are decided again.
const paid = {
...inv_1002,
attributes: { ...inv_1002.attributes, status: "paid" },
};
await ns.write({ upsert: [paid] });
# Mark one invoice paid. Only the payments
# that read it are decided again.
paid: UpsertDocument = {
**inv_1002,
"attributes": {**inv_1002["attributes"], "status": "paid"},
}
ns.write(upsert=[paid])
What Brussle didStep 5 of 5
inv_1002changed
pay_1decided again · the fit applies on readpending
every other decisionuntouched