Cookwala / حزمة التطوير والسيناريوهات / 046
A request for a recipe the hub does not hold is refused
A hub only cooks recipes it can fetch and hash. Ask for the catalog, then request a recipe id that is not in it and read the refusal.
اقرأ أولًا: /docs/CORE/ /docs/HUB/
الخطوات
The runner's hub holds the nine example recipes.
listRecipesRequest a recipe reference the hub cannot resolve. The refusal reason is missing_capability and the detail says the recipe is not in the catalog.
startExecution
النتيجة
You know a hub refuses what it cannot find rather than guessing. Next: scenario 047 covers a hash that does not match.
سطر الأوامر
cookwala hub --recipes examples --speed 200
curl -s http://localhost:7878/v1/tools/recipesالمخرجات المسجلة
الحالة: ok
[1] listRecipes: {"recipes": ["basbousa", "ful-medames", "kofta-oven", "koshari", "lentil-soup", "molokhia", "rice-vermicelli", "salata-baladi", "shakshuka"]}
[2] startExecution: {"core": "0.2.0", "kind": "ExecutionStatus", "id": "ex-046-unknown", "seq": 0, "state": "refused", "request": "ex-046-unknown", "updatedAt": "2026-10-07T00:54:31Z", "refusal": {"reason": "missing_capability", "detail": "recipe not found in this hub's catalog"}}الكود
التشغيل: python scenarios/out/046-refused-when-the-recipe-is-not-in-the-catalog/python.py
# Scenario 046: A request for a recipe the hub does not hold is refused
# A hub only cooks recipes it can fetch and hash. Ask for the catalog, then request a recipe id that is not in it and read the refusal.
# 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: The runner's hub holds the nine example recipes.
recipes = c.list_recipes()
assert pick(recipes, "recipes.length") == 9, pick(recipes, "recipes.length")
print("ok", "recipes.length", "=", 9)
assert pick(recipes, "recipes[8]") == "shakshuka", pick(recipes, "recipes[8]")
print("ok", "recipes[8]", "=", "shakshuka")
# Step 2: Request a recipe reference the hub cannot resolve. The refusal reason is missing_capability and the detail says the recipe is not in the catalog.
try:
refused = c.start_execution({"core": "0.2.0", "kind": "ExecuteRequest", "id": "ex-046-unknown", "recipe": "cw:cookwala.ai:example-nothing", "recipeHash": "sha256:2ea6fab93cc673fc6784f9bc9fe401d2387bb7779dc537df97286b73807c8841", "servings": 4, "requestedBy": "agent:planner-1", "idempotencyKey": "ex-046-unknown-a"}, "ex-046-unknown-key", True)
except CookwalaProblem as p:
refused = p.body # a refusal is a result, not a crash
print("refused:", p.refusal)
assert pick(refused, "state") == "refused", pick(refused, "state")
print("ok", "state", "=", "refused")
assert pick(refused, "refusal.reason") == "missing_capability", pick(refused, "refusal.reason")
print("ok", "refusal.reason", "=", "missing_capability")
assert pick(refused, "refusal.detail") == "recipe not found in this hub's catalog", pick(refused, "refusal.detail")
print("ok", "refusal.detail", "=", "recipe not found in this hub's catalog")
print("scenario complete")
scenarios/046-refused-when-the-recipe-is-not-in-the-catalog.json