Cookwala / حزمة التطوير والسيناريوهات / 095
Validate a relief kitchen and its production run
A Kitchen document describes stations, capacity and rule packs; a ProductionRun records recipes, assignments, critical control points and an outcome (here 710 meals produced, 650 served, one CCP failure). Both examples are illustrative; no real kitchen is described. Validate and hash them.
اقرأ أولًا: /docs/KITCHENS-AND-FLEETS/ /docs/HUMANITARIAN-PROFILE/
الخطوات
Validate the example Kitchen (disaster type, 350 meals per hour, five stations). The reference hub's validate checks the document against the schema file's root; this schema keeps its kinds under $defs, so today this call reports ok for any document, and `cookwala validate` (the CLI line) is the real check.
validateValidate the example ProductionRun (lentil soup and rice with vermicelli for a relief program, halal, peanuts blocked).
validateHash the run: the hash is what a Humanitarian Distribution or an audit refers to.
hash
النتيجة
You know the documents a kitchen keeps and how a run links to Core executions and to a Distribution. Fleet dispatch stays with Open-RMF or a vendor. Next: 096 shows the agent rule on recipe text.
سطر الأوامر
cookwala validate
cookwala hash examples/fleet/production-run-disaster.json
jq '.outcome | {mealsProduced, mealsServed, ccpFailures, kgRescuedUsed}' examples/fleet/production-run-disaster.jsonالمخرجات المسجلة
الحالة: ok
[1] validate: {"ok": true, "errors": []}
[2] validate: {"ok": true, "errors": []}
[3] hash: {"hash": "sha256:98733ccff20c4ffc3f0b330434aaf81c6e512c88492512394cacc5a7fe384567"}الكود
التشغيل: python scenarios/out/095-validate-kitchen-and-production-run/python.py
# Scenario 095: Validate a relief kitchen and its production run
# A Kitchen document describes stations, capacity and rule packs; a ProductionRun records recipes, assignments, critical control points and an outcome (here 710 meals produced, 650 served, one CCP failure). Both examples are illustrative; no real kitchen is described. Validate and hash them.
# Run a hub first: python hub/cookwala_hub.py --recipes examples
import json, os
from cookwala.client import CookwalaClient, CookwalaProblem
def load(path):
with open(path, encoding="utf-8") as f:
return json.load(f)
def pick(obj, path):
for part in path.replace("]", "").replace("[", ".").split("."):
obj = obj[int(part)] if part.isdigit() else (len(obj) if part == "length" else obj.get(part))
return obj
c = CookwalaClient(os.environ.get("COOKWALA_HUB", "http://localhost:7878"))
# Step 1: Validate the example Kitchen (disaster type, 350 meals per hour, five stations). The reference hub's validate checks the document against the schema file's root; this schema keeps its kinds under $defs, so today this call reports ok for any document, and `cookwala validate` (the CLI line) is the real check.
kitchen = c.validate("fleet", load("examples/fleet/kitchen-disaster.json"))
assert pick(kitchen, "ok") == True, pick(kitchen, "ok")
print("ok", "ok", "=", True)
# Step 2: Validate the example ProductionRun (lentil soup and rice with vermicelli for a relief program, halal, peanuts blocked).
run = c.validate("fleet", load("examples/fleet/production-run-disaster.json"))
assert pick(run, "ok") == True, pick(run, "ok")
print("ok", "ok", "=", True)
# Step 3: Hash the run: the hash is what a Humanitarian Distribution or an audit refers to.
h = c.hash(load("examples/fleet/production-run-disaster.json"))
assert pick(h, "hash") == "sha256:98733ccff20c4ffc3f0b330434aaf81c6e512c88492512394cacc5a7fe384567", pick(h, "hash")
print("ok", "hash", "=", "sha256:98733ccff20c4ffc3f0b330434aaf81c6e512c88492512394cacc5a7fe384567")
print("scenario complete")