Count variances
Tolerance, recount, valuation and approval authority for count adjustments, including discovered stock and unusable costs.
Request with "decision": "variance" and one of these operations: controller_confirm, manager_approve.
Clauses applied
variance.tolerance: Both configured absolute quantity and percent tests must pass for a first count to be within tolerance; otherwise an independent recount and review are required.variance.found: Zero expected with found stock has null percent and requires independent review; missing/stale cost never becomes zero value.variance.manager: Discovery, identity change, reserved/owned stock, above-threshold value or exceptional cost requires independent Warehouse Manager.variance.cost: A usable cost and matching approval packet remain mandatory.variance.controller: Existing-stock correction within the USD threshold may use explicit ControllerConfirmation after any required independent recount/review and when usable cost and unreserved/unowned eligibility checks pass; the controller may confirm their own draft only on that path.
Evidence questions
discovered_stock@1
This is the reason given for a count adjustment at one location. Does it describe stock that was not on record there, such as found, unexpected or misplaced stock, or a change of item, lot or serial identity?
| Answer | Meaning |
|---|---|
true | The reason describes stock not on record at this location, such as found, unexpected or misplaced stock, or a change of item, lot or serial identity. |
false | The reason describes a correction to stock that was on record: a miscount, damage, loss, a missed pick or a unit-of-measure slip. |
cost_usable@1
This is the evidence offered for an item's unit cost when valuing a count adjustment. Does it establish that cost as current, from an accountable source such as a recent invoice, purchase order, price list or the finance team?
| Answer | Meaning |
|---|---|
true | The evidence establishes the cost as current, from an accountable source such as a recent invoice, purchase order, price list or the finance team. |
false | The cost is a guess, a placeholder, zero for lack of a cost, or older than the evidence admits. |
Examples
Found stock with no usable cost
{
"decision": "variance",
"proposal": {
"operation": "controller_confirm",
"by": "u-inv-07",
"drafted_by": "u-inv-07"
},
"today": "2026-10-02",
"policy": {
"tolerance_qty": "2",
"tolerance_pct": "5",
"value_threshold": "500",
"cost_max_age_days": 90
},
"count": {
"expected": "0",
"counted": "5",
"recounted": true
},
"reason": "Found a sealed case behind the reserve pallet, not on record for this bin."
}Response from the rules with no model loaded, so every question abstains.
{
"verdict": "review",
"next": {
"action": "obtain_cost",
"text": "No usable unit cost, so the controller path is closed. Missing or stale cost never becomes zero value.",
"role": "Warehouse Manager"
},
"questions": []
}Run this example in the consoleDownload the request
Call it from your code
Each snippet sends the first example above to the hosted API with the key in RACKSORT_API_KEY and prints the verdict and the next step. Create an account, then create a key. The quickstart walks through the first request.
curl
export RACKSORT_API_KEY="paste-your-key-here"
curl https://racksort.com/api/v1/decide \
-H "Authorization: Bearer $RACKSORT_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'EOF'
{
"decision": "variance",
"proposal": {
"operation": "controller_confirm",
"by": "u-inv-07",
"drafted_by": "u-inv-07"
},
"today": "2026-10-02",
"policy": {
"tolerance_qty": "2",
"tolerance_pct": "5",
"value_threshold": "500",
"cost_max_age_days": 90
},
"count": {
"expected": "0",
"counted": "5",
"recounted": true
},
"reason": "Found a sealed case behind the reserve pallet, not on record for this bin."
}
EOFPython
Python 3.8 or newer, standard library only. Keep the User-Agent header: requests with Python's default one are refused. With requests or httpx it is not needed.
import json
import os
import urllib.error
import urllib.request
request = {
"decision": "variance",
"proposal": {
"operation": "controller_confirm",
"by": "u-inv-07",
"drafted_by": "u-inv-07",
},
"today": "2026-10-02",
"policy": {
"tolerance_qty": "2",
"tolerance_pct": "5",
"value_threshold": "500",
"cost_max_age_days": 90,
},
"count": {
"expected": "0",
"counted": "5",
"recounted": True,
},
"reason": "Found a sealed case behind the reserve pallet, not on record for this bin.",
}
call = urllib.request.Request(
"https://racksort.com/api/v1/decide",
data=json.dumps(request).encode(),
headers={
"Authorization": f"Bearer {os.environ['RACKSORT_API_KEY']}",
"Content-Type": "application/json",
# Cloudflare refuses Python's default User-Agent, so name the client.
"User-Agent": "racksort-example/1.0",
},
)
try:
with urllib.request.urlopen(call, timeout=30) as response:
result = json.load(response)
except urllib.error.HTTPError as error:
raise SystemExit(json.load(error)["error"]["message"])
print(result["verdict"], "-", result["next"]["text"])TypeScript
Node.js 18 or newer. Save it as decide.mts and run npx tsx decide.mts.
type Verdict = "allow" | "replay" | "reject" | "review" | "reconcile";
interface Decision {
verdict: Verdict;
state?: string;
next: { action: string; text: string; role?: string };
}
const request = {
"decision": "variance",
"proposal": {
"operation": "controller_confirm",
"by": "u-inv-07",
"drafted_by": "u-inv-07"
},
"today": "2026-10-02",
"policy": {
"tolerance_qty": "2",
"tolerance_pct": "5",
"value_threshold": "500",
"cost_max_age_days": 90
},
"count": {
"expected": "0",
"counted": "5",
"recounted": true
},
"reason": "Found a sealed case behind the reserve pallet, not on record for this bin."
};
const response = await fetch("https://racksort.com/api/v1/decide", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RACKSORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(request),
});
const body = await response.json();
if (!response.ok) throw new Error(body.error.message);
const result = body as Decision;
console.log(result.verdict, "-", result.next.text);
Request schema
{
"type": "object",
"required": [
"decision",
"proposal",
"count",
"policy",
"today"
],
"additionalProperties": false,
"properties": {
"decision": {
"const": "variance"
},
"proposal": {
"type": "object",
"required": [
"operation",
"by"
],
"additionalProperties": false,
"properties": {
"operation": {
"type": "string",
"enum": [
"controller_confirm",
"manager_approve"
]
},
"by": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"drafted_by": {
"type": "string",
"minLength": 1,
"maxLength": 200
}
}
},
"count": {
"type": "object",
"required": [
"expected",
"counted"
],
"additionalProperties": false,
"properties": {
"expected": {
"type": "string",
"format": "decimal"
},
"counted": {
"type": "string",
"format": "decimal"
},
"recounted": {
"type": "boolean"
}
}
},
"policy": {
"type": "object",
"required": [
"tolerance_qty",
"tolerance_pct",
"value_threshold",
"cost_max_age_days"
],
"additionalProperties": false,
"properties": {
"tolerance_qty": {
"type": "string",
"format": "decimal"
},
"tolerance_pct": {
"type": "string",
"format": "decimal"
},
"value_threshold": {
"type": "string",
"format": "decimal"
},
"cost_max_age_days": {
"type": "integer",
"minimum": 0
}
}
},
"cost": {
"type": "object",
"required": [
"unit_cost"
],
"additionalProperties": false,
"properties": {
"unit_cost": {
"type": "string",
"format": "decimal"
},
"as_of": {
"type": "string",
"format": "date"
},
"source": {
"type": "string",
"minLength": 1,
"maxLength": 4000
}
}
},
"cost_evidence": {
"type": "string",
"minLength": 1,
"maxLength": 4000
},
"reason": {
"type": "string",
"minLength": 1,
"maxLength": 4000
},
"reserved_or_owned": {
"type": "boolean"
},
"identity_changed": {
"type": "boolean"
},
"today": {
"type": "string",
"format": "date"
}
}
}