{
  "name": "A small checkout, mapped by Arbor",
  "description": "Explore 32 functions across eight Python modules. Every connection shown comes from a captured Arbor engine run; the source and independent audit are included.",
  "provenance": {
    "capturedOn": "2026-09-23",
    "sourceKind": "authored sample repository",
    "sourceLanguage": "Python",
    "fixtureSha256": "1a0505f65a156ea5b65a1e71bb7d49746c00d62c4eb5adb3b78ed859a53d63ba",
    "fixtureHashMethod": "SHA-256 of sorted UTF-8 filenames + NUL + exact file bytes + NUL",
    "fixtureLocation": "docs/brand/final-experience-data/fixture",
    "engine": {
      "name": "Arbor",
      "packageVersion": "3.0.0",
      "build": "local development build with unreleased source repairs",
      "gitRevision": "79bb4a7298edb3d8c479fcf84b1909c585a1ef65",
      "uncommittedChanges": true,
      "trackedDiffSha256": "adefe61f3679a47c4e6d58c428864b5aee7cf052e68ac46fde8b869c2187f73a",
      "cliBinarySha256": "4159e8533471a43eff21b4a62ce89bae9c029410c290133b6fbd1bad702e0043",
      "reporterBinarySha256": "0013d041dbb63546f551d8bd29b9622fcce09231c459be648e08f08e5d842ba9"
    },
    "commands": [
      "accuracy_report <fixture> --out engine-report.txt --json engine-report.json",
      "arbor index <isolated fixture copy> --no-cache",
      "arbor refactor money_to_minor_units <isolated fixture copy> --json --depth 0",
      "arbor refactor reserve_stock <isolated fixture copy> --json --depth 0",
      "arbor refactor render_receipt <isolated fixture copy> --json --depth 0"
    ],
    "commandNote": "Paths are normalized here; exact local commands are retained in the provenance artifact.",
    "filesIndexed": 8,
    "symbolsIndexed": 32,
    "engineCallEdges": 41,
    "strongResolutionEdges": 41,
    "weakResolutionEdges": 0,
    "parseErrorCount": 0,
    "filtering": {
      "rule": "Retain every engine-reported calls edge and every indexed symbol; no relationship was fabricated or removed for presentation.",
      "excludedEngineSymbols": 0,
      "excludedEngineCallEdges": 0,
      "excludedNonCallEdges": 0,
      "outsideFixturePythonCallsites": 11,
      "outsideFixtureNote": "The independent AST audit excludes calls without a function definition in this fixture, including Python builtins and object operations. This is not an engine-wide unresolved-call metric."
    },
    "validation": {
      "method": "Independent Python AST import binding and shortest-path audit",
      "matchingCallEdges": 41,
      "missingCallEdges": 0,
      "extraCallEdges": 0,
      "impactScenariosChecked": 3,
      "upstreamDistancesChecked": 20
    },
    "pathSemantics": "Paths point from caller to called function and are independently reconstructed shortest paths over actual engine-reported edges. Their distances match Arbor CLI impact output.",
    "layoutSemantics": "Module labels and logical layers are authored presentation metadata, not engine output.",
    "limitations": [
      "This is a captured result from a deliberately small sample, not a live repository scan or a customer project.",
      "Relationships are static. They do not prove runtime execution, breakage, security impact or that a change is safe.",
      "The sample uses explicit Python imports and direct calls; it does not demonstrate dynamic dispatch, reflection, framework resolution or other languages.",
      "Strong resolution is a rule threshold, not a probability of correctness.",
      "The local engine build includes unreleased changes; this snapshot does not establish the behavior of a published package or deployed Cloud service.",
      "The source is a teaching fixture, not production checkout or payment software. Its payment and message records remain local and do not charge or send anything."
    ]
  },
  "groups": [
    {
      "id": "jobs",
      "title": "Background jobs",
      "layer": 0,
      "description": "Renewal, refund, recovery and receipt entry points."
    },
    {
      "id": "checkout",
      "title": "Checkout",
      "layer": 1,
      "description": "Preview, preparation, submission and retry paths."
    },
    {
      "id": "receipts",
      "title": "Receipts",
      "layer": 2,
      "description": "Build and render messages without sending them."
    },
    {
      "id": "orders",
      "title": "Order lifecycle",
      "layer": 3,
      "description": "Create, record, cancel and summarize an order."
    },
    {
      "id": "pricing",
      "title": "Pricing",
      "layer": 4,
      "description": "Line totals, discounts and quotes."
    },
    {
      "id": "payments",
      "title": "Payment records",
      "layer": 4,
      "description": "In-memory authorization, capture and refund records."
    },
    {
      "id": "inventory",
      "title": "Inventory",
      "layer": 4,
      "description": "Availability, reservation and release in a local stock ledger."
    },
    {
      "id": "money",
      "title": "Shared currency helpers",
      "layer": 5,
      "description": "Currency codes, unit conversion and display formatting."
    }
  ],
  "files": [
    {
      "path": "checkout.py",
      "language": "python",
      "code": "\"\"\"An executable local sample with no accounts, network calls, or storage.\"\"\"\nfrom inventory import check_availability, reserve_stock\nfrom orders import create_order, record_order\nfrom payments import authorize_payment\nfrom pricing import quote_order\nfrom receipts import send_receipt\n\n\ndef prepare_checkout(items, currency, stock, discount_percent=0):\n    return {\n        \"available\": check_availability(items, stock),\n        \"quote\": quote_order(items, currency, discount_percent),\n    }\n\n\ndef submit_checkout(items, currency, stock, discount_percent=0):\n    reservation = reserve_stock(items, stock)\n    order = create_order(items, currency, discount_percent)\n    authorization = authorize_payment(order)\n    saved = record_order(order, authorization)\n    return {\"order\": saved, \"reservation\": reservation, \"receipt\": send_receipt(saved)}\n\n\ndef retry_checkout(items, currency, stock, discount_percent=0):\n    return submit_checkout(items, currency, stock, discount_percent)\n\n\ndef preview_checkout(items, currency, stock, discount_percent=0):\n    return prepare_checkout(items, currency, stock, discount_percent)\n",
      "sha256": "778046e37c4d07eb610e686dc9d466ae19a505dedb0bd71c12b28bb8016b88ad"
    },
    {
      "path": "inventory.py",
      "language": "python",
      "code": "\"\"\"A deterministic stock ledger used only by this sample.\"\"\"\n\n\ndef available_units(stock, sku):\n    return stock.get(sku, 0)\n\n\ndef check_availability(items, stock):\n    return all(available_units(stock, item[\"sku\"]) >= item[\"quantity\"] for item in items)\n\n\ndef reserve_stock(items, stock):\n    if not check_availability(items, stock):\n        raise ValueError(\"Insufficient stock\")\n    reservation = {item[\"sku\"]: item[\"quantity\"] for item in items}\n    for sku, quantity in reservation.items():\n        stock[sku] -= quantity\n    return reservation\n\n\ndef release_stock(reservation, stock):\n    for sku, quantity in reservation.items():\n        stock[sku] = available_units(stock, sku) + quantity\n",
      "sha256": "cce0d41e791b7d835144128f38f906a1618baea7872291367d28d65dd01d950d"
    },
    {
      "path": "jobs.py",
      "language": "python",
      "code": "\"\"\"Batch entry points into the same sample workflow.\"\"\"\nfrom checkout import preview_checkout, submit_checkout\nfrom orders import cancel_order\nfrom receipts import send_receipt, send_refund_notice\n\n\ndef process_renewal(items, currency, stock):\n    return submit_checkout(items, currency, stock)\n\n\ndef process_refund(order, reservation, stock):\n    cancelled = cancel_order(order, reservation, stock)\n    return {\"order\": cancelled, \"notice\": send_refund_notice(cancelled)}\n\n\ndef process_abandoned_cart(items, currency, stock):\n    return preview_checkout(items, currency, stock)\n\n\ndef resend_receipt(order):\n    return send_receipt(order)\n",
      "sha256": "c06144f3dca763e4fe76f679ffd39407d6e3994c248f5d5553c4edaf4def8c6a"
    },
    {
      "path": "money.py",
      "language": "python",
      "code": "\"\"\"Currency helpers for an illustrative, in-memory order workflow.\"\"\"\n\n\ndef normalize_currency(currency):\n    return currency.strip().upper()\n\n\ndef minor_unit_scale(currency):\n    return 1 if normalize_currency(currency) == \"JPY\" else 100\n\n\ndef money_to_minor_units(amount, currency):\n    return round(amount * minor_unit_scale(currency))\n\n\ndef format_money(amount, currency):\n    code = normalize_currency(currency)\n    precision = 0 if minor_unit_scale(code) == 1 else 2\n    return f\"{code} {amount:.{precision}f}\"\n",
      "sha256": "82e68a5ea245acf9ac1a5f0781705c39c2c02de8b4d4d0031e1428978331ac8e"
    },
    {
      "path": "orders.py",
      "language": "python",
      "code": "\"\"\"Order construction, cancellation, and display.\"\"\"\nfrom inventory import release_stock\nfrom money import format_money, minor_unit_scale, normalize_currency\nfrom payments import capture_payment, refund_payment\nfrom pricing import calculate_order_total\n\n\ndef create_order(items, currency, discount_percent=0):\n    return {\n        \"items\": items,\n        \"currency\": normalize_currency(currency),\n        \"total_minor\": calculate_order_total(items, currency, discount_percent),\n    }\n\n\ndef record_order(order, authorization):\n    captured = capture_payment(authorization)\n    return {**order, **captured, \"status\": \"paid\"}\n\n\ndef cancel_order(order, reservation, stock):\n    release_stock(reservation, stock)\n    refund = refund_payment(order)\n    return {**order, **refund, \"status\": \"cancelled\"}\n\n\ndef order_summary(order):\n    amount = order[\"total_minor\"] / minor_unit_scale(order[\"currency\"])\n    return {\"total\": format_money(amount, order[\"currency\"]), \"items\": len(order[\"items\"])}\n",
      "sha256": "1dc65d827b6e0860a4b54f0ff72356f040bb2d62f6744e41819f852996bc64d7"
    },
    {
      "path": "payments.py",
      "language": "python",
      "code": "\"\"\"In-memory payment records. This module never contacts a payment provider.\"\"\"\nfrom money import minor_unit_scale, money_to_minor_units\n\n\ndef payment_payload(order):\n    return {\"amount\": order[\"total_minor\"], \"currency\": order[\"currency\"]}\n\n\ndef authorize_payment(order):\n    payload = payment_payload(order)\n    return {\"approved\": payload[\"amount\"] >= 0, \"payload\": payload}\n\n\ndef capture_payment(authorization):\n    if not authorization[\"approved\"]:\n        raise ValueError(\"Authorization was declined\")\n    return {\"captured_minor\": authorization[\"payload\"][\"amount\"]}\n\n\ndef refund_payment(order):\n    amount = order[\"total_minor\"] / minor_unit_scale(order[\"currency\"])\n    return {\"refund_minor\": money_to_minor_units(amount, order[\"currency\"])}\n",
      "sha256": "18f41860c5305346f567e74005c7a567eddbafd9d506a26f6be368604df7a503"
    },
    {
      "path": "pricing.py",
      "language": "python",
      "code": "\"\"\"Price a cart and produce a quote; no payment is performed.\"\"\"\nfrom money import format_money, minor_unit_scale, money_to_minor_units\n\n\ndef line_subtotal(item):\n    return item[\"price\"] * item[\"quantity\"]\n\n\ndef apply_discount(subtotal, discount_percent):\n    return subtotal * (1 - discount_percent / 100)\n\n\ndef calculate_order_total(items, currency, discount_percent=0):\n    subtotal = sum(line_subtotal(item) for item in items)\n    discounted = apply_discount(subtotal, discount_percent)\n    return money_to_minor_units(discounted, currency)\n\n\ndef quote_order(items, currency, discount_percent=0):\n    total = calculate_order_total(items, currency, discount_percent)\n    return format_money(total / minor_unit_scale(currency), currency)\n",
      "sha256": "39a919177500f8a21c60cd3715ad6703fa483a7f84e05fc1dcc97233ac6ec64a"
    },
    {
      "path": "receipts.py",
      "language": "python",
      "code": "\"\"\"Receipt text generation. Messages are returned, never sent.\"\"\"\nfrom orders import order_summary\n\n\ndef build_receipt(order):\n    summary = order_summary(order)\n    return {\"heading\": \"Order received\", \"body\": summary[\"total\"]}\n\n\ndef render_receipt(receipt):\n    return receipt[\"heading\"] + \"\\n\" + receipt[\"body\"]\n\n\ndef send_receipt(order):\n    return {\"message\": render_receipt(build_receipt(order)), \"delivered\": False}\n\n\ndef send_refund_notice(order):\n    summary = order_summary(order)\n    return {\"message\": \"Refund recorded: \" + summary[\"total\"], \"delivered\": False}\n",
      "sha256": "adb2dbb425c84333eff1fae7f13e53408d2f410ab3488b7f2ca9fdde96f006f3"
    }
  ],
  "nodes": [
    {
      "id": "checkout.prepare_checkout",
      "label": "prepare_checkout",
      "file": "checkout.py",
      "group": "checkout",
      "moduleTitle": "Checkout",
      "layer": 1,
      "line": 9,
      "endLine": 13,
      "loc": 5,
      "code": "def prepare_checkout(items, currency, stock, discount_percent=0):\n    return {\n        \"available\": check_availability(items, stock),\n        \"quote\": quote_order(items, currency, discount_percent),\n    }",
      "engineId": "350dbcee81f14885"
    },
    {
      "id": "checkout.preview_checkout",
      "label": "preview_checkout",
      "file": "checkout.py",
      "group": "checkout",
      "moduleTitle": "Checkout",
      "layer": 1,
      "line": 28,
      "endLine": 29,
      "loc": 2,
      "code": "def preview_checkout(items, currency, stock, discount_percent=0):\n    return prepare_checkout(items, currency, stock, discount_percent)",
      "engineId": "46caaac427319e5a"
    },
    {
      "id": "checkout.retry_checkout",
      "label": "retry_checkout",
      "file": "checkout.py",
      "group": "checkout",
      "moduleTitle": "Checkout",
      "layer": 1,
      "line": 24,
      "endLine": 25,
      "loc": 2,
      "code": "def retry_checkout(items, currency, stock, discount_percent=0):\n    return submit_checkout(items, currency, stock, discount_percent)",
      "engineId": "972d50963c6a0168"
    },
    {
      "id": "checkout.submit_checkout",
      "label": "submit_checkout",
      "file": "checkout.py",
      "group": "checkout",
      "moduleTitle": "Checkout",
      "layer": 1,
      "line": 16,
      "endLine": 21,
      "loc": 6,
      "code": "def submit_checkout(items, currency, stock, discount_percent=0):\n    reservation = reserve_stock(items, stock)\n    order = create_order(items, currency, discount_percent)\n    authorization = authorize_payment(order)\n    saved = record_order(order, authorization)\n    return {\"order\": saved, \"reservation\": reservation, \"receipt\": send_receipt(saved)}",
      "engineId": "62577d50be06b701"
    },
    {
      "id": "inventory.available_units",
      "label": "available_units",
      "file": "inventory.py",
      "group": "inventory",
      "moduleTitle": "Inventory",
      "layer": 4,
      "line": 4,
      "endLine": 5,
      "loc": 2,
      "code": "def available_units(stock, sku):\n    return stock.get(sku, 0)",
      "engineId": "193f3d7088c6013c"
    },
    {
      "id": "inventory.check_availability",
      "label": "check_availability",
      "file": "inventory.py",
      "group": "inventory",
      "moduleTitle": "Inventory",
      "layer": 4,
      "line": 8,
      "endLine": 9,
      "loc": 2,
      "code": "def check_availability(items, stock):\n    return all(available_units(stock, item[\"sku\"]) >= item[\"quantity\"] for item in items)",
      "engineId": "36e1a9ccb4f29147"
    },
    {
      "id": "inventory.release_stock",
      "label": "release_stock",
      "file": "inventory.py",
      "group": "inventory",
      "moduleTitle": "Inventory",
      "layer": 4,
      "line": 21,
      "endLine": 23,
      "loc": 3,
      "code": "def release_stock(reservation, stock):\n    for sku, quantity in reservation.items():\n        stock[sku] = available_units(stock, sku) + quantity",
      "engineId": "ffb040a21882105d"
    },
    {
      "id": "inventory.reserve_stock",
      "label": "reserve_stock",
      "file": "inventory.py",
      "group": "inventory",
      "moduleTitle": "Inventory",
      "layer": 4,
      "line": 12,
      "endLine": 18,
      "loc": 7,
      "code": "def reserve_stock(items, stock):\n    if not check_availability(items, stock):\n        raise ValueError(\"Insufficient stock\")\n    reservation = {item[\"sku\"]: item[\"quantity\"] for item in items}\n    for sku, quantity in reservation.items():\n        stock[sku] -= quantity\n    return reservation",
      "engineId": "f1ddc916b502e2ec"
    },
    {
      "id": "jobs.process_abandoned_cart",
      "label": "process_abandoned_cart",
      "file": "jobs.py",
      "group": "jobs",
      "moduleTitle": "Background jobs",
      "layer": 0,
      "line": 16,
      "endLine": 17,
      "loc": 2,
      "code": "def process_abandoned_cart(items, currency, stock):\n    return preview_checkout(items, currency, stock)",
      "engineId": "6ef585a1c638f946"
    },
    {
      "id": "jobs.process_refund",
      "label": "process_refund",
      "file": "jobs.py",
      "group": "jobs",
      "moduleTitle": "Background jobs",
      "layer": 0,
      "line": 11,
      "endLine": 13,
      "loc": 3,
      "code": "def process_refund(order, reservation, stock):\n    cancelled = cancel_order(order, reservation, stock)\n    return {\"order\": cancelled, \"notice\": send_refund_notice(cancelled)}",
      "engineId": "11d9519abfdb35a6"
    },
    {
      "id": "jobs.process_renewal",
      "label": "process_renewal",
      "file": "jobs.py",
      "group": "jobs",
      "moduleTitle": "Background jobs",
      "layer": 0,
      "line": 7,
      "endLine": 8,
      "loc": 2,
      "code": "def process_renewal(items, currency, stock):\n    return submit_checkout(items, currency, stock)",
      "engineId": "35294fd105db9fe4"
    },
    {
      "id": "jobs.resend_receipt",
      "label": "resend_receipt",
      "file": "jobs.py",
      "group": "jobs",
      "moduleTitle": "Background jobs",
      "layer": 0,
      "line": 20,
      "endLine": 21,
      "loc": 2,
      "code": "def resend_receipt(order):\n    return send_receipt(order)",
      "engineId": "bd596441118c5db5"
    },
    {
      "id": "money.format_money",
      "label": "format_money",
      "file": "money.py",
      "group": "money",
      "moduleTitle": "Shared currency helpers",
      "layer": 5,
      "line": 16,
      "endLine": 19,
      "loc": 4,
      "code": "def format_money(amount, currency):\n    code = normalize_currency(currency)\n    precision = 0 if minor_unit_scale(code) == 1 else 2\n    return f\"{code} {amount:.{precision}f}\"",
      "engineId": "6a3f0dd07dd36ba5"
    },
    {
      "id": "money.minor_unit_scale",
      "label": "minor_unit_scale",
      "file": "money.py",
      "group": "money",
      "moduleTitle": "Shared currency helpers",
      "layer": 5,
      "line": 8,
      "endLine": 9,
      "loc": 2,
      "code": "def minor_unit_scale(currency):\n    return 1 if normalize_currency(currency) == \"JPY\" else 100",
      "engineId": "0ec72801ba397d31"
    },
    {
      "id": "money.money_to_minor_units",
      "label": "money_to_minor_units",
      "file": "money.py",
      "group": "money",
      "moduleTitle": "Shared currency helpers",
      "layer": 5,
      "line": 12,
      "endLine": 13,
      "loc": 2,
      "code": "def money_to_minor_units(amount, currency):\n    return round(amount * minor_unit_scale(currency))",
      "engineId": "908bd44cec3a0db8"
    },
    {
      "id": "money.normalize_currency",
      "label": "normalize_currency",
      "file": "money.py",
      "group": "money",
      "moduleTitle": "Shared currency helpers",
      "layer": 5,
      "line": 4,
      "endLine": 5,
      "loc": 2,
      "code": "def normalize_currency(currency):\n    return currency.strip().upper()",
      "engineId": "2fe569f44e82af3c"
    },
    {
      "id": "orders.cancel_order",
      "label": "cancel_order",
      "file": "orders.py",
      "group": "orders",
      "moduleTitle": "Order lifecycle",
      "layer": 3,
      "line": 21,
      "endLine": 24,
      "loc": 4,
      "code": "def cancel_order(order, reservation, stock):\n    release_stock(reservation, stock)\n    refund = refund_payment(order)\n    return {**order, **refund, \"status\": \"cancelled\"}",
      "engineId": "80594f38e1eea21b"
    },
    {
      "id": "orders.create_order",
      "label": "create_order",
      "file": "orders.py",
      "group": "orders",
      "moduleTitle": "Order lifecycle",
      "layer": 3,
      "line": 8,
      "endLine": 13,
      "loc": 6,
      "code": "def create_order(items, currency, discount_percent=0):\n    return {\n        \"items\": items,\n        \"currency\": normalize_currency(currency),\n        \"total_minor\": calculate_order_total(items, currency, discount_percent),\n    }",
      "engineId": "3ffd402f3e3a4ead"
    },
    {
      "id": "orders.order_summary",
      "label": "order_summary",
      "file": "orders.py",
      "group": "orders",
      "moduleTitle": "Order lifecycle",
      "layer": 3,
      "line": 27,
      "endLine": 29,
      "loc": 3,
      "code": "def order_summary(order):\n    amount = order[\"total_minor\"] / minor_unit_scale(order[\"currency\"])\n    return {\"total\": format_money(amount, order[\"currency\"]), \"items\": len(order[\"items\"])}",
      "engineId": "cb18806c02568c93"
    },
    {
      "id": "orders.record_order",
      "label": "record_order",
      "file": "orders.py",
      "group": "orders",
      "moduleTitle": "Order lifecycle",
      "layer": 3,
      "line": 16,
      "endLine": 18,
      "loc": 3,
      "code": "def record_order(order, authorization):\n    captured = capture_payment(authorization)\n    return {**order, **captured, \"status\": \"paid\"}",
      "engineId": "b6554dbc2c08c8e8"
    },
    {
      "id": "payments.authorize_payment",
      "label": "authorize_payment",
      "file": "payments.py",
      "group": "payments",
      "moduleTitle": "Payment records",
      "layer": 4,
      "line": 9,
      "endLine": 11,
      "loc": 3,
      "code": "def authorize_payment(order):\n    payload = payment_payload(order)\n    return {\"approved\": payload[\"amount\"] >= 0, \"payload\": payload}",
      "engineId": "fd803612d772ac53"
    },
    {
      "id": "payments.capture_payment",
      "label": "capture_payment",
      "file": "payments.py",
      "group": "payments",
      "moduleTitle": "Payment records",
      "layer": 4,
      "line": 14,
      "endLine": 17,
      "loc": 4,
      "code": "def capture_payment(authorization):\n    if not authorization[\"approved\"]:\n        raise ValueError(\"Authorization was declined\")\n    return {\"captured_minor\": authorization[\"payload\"][\"amount\"]}",
      "engineId": "d60d4a5469685c70"
    },
    {
      "id": "payments.payment_payload",
      "label": "payment_payload",
      "file": "payments.py",
      "group": "payments",
      "moduleTitle": "Payment records",
      "layer": 4,
      "line": 5,
      "endLine": 6,
      "loc": 2,
      "code": "def payment_payload(order):\n    return {\"amount\": order[\"total_minor\"], \"currency\": order[\"currency\"]}",
      "engineId": "b9e52c8b2f8b50d5"
    },
    {
      "id": "payments.refund_payment",
      "label": "refund_payment",
      "file": "payments.py",
      "group": "payments",
      "moduleTitle": "Payment records",
      "layer": 4,
      "line": 20,
      "endLine": 22,
      "loc": 3,
      "code": "def refund_payment(order):\n    amount = order[\"total_minor\"] / minor_unit_scale(order[\"currency\"])\n    return {\"refund_minor\": money_to_minor_units(amount, order[\"currency\"])}",
      "engineId": "c296a49bb59795a5"
    },
    {
      "id": "pricing.apply_discount",
      "label": "apply_discount",
      "file": "pricing.py",
      "group": "pricing",
      "moduleTitle": "Pricing",
      "layer": 4,
      "line": 9,
      "endLine": 10,
      "loc": 2,
      "code": "def apply_discount(subtotal, discount_percent):\n    return subtotal * (1 - discount_percent / 100)",
      "engineId": "984fe1a5edcbc832"
    },
    {
      "id": "pricing.calculate_order_total",
      "label": "calculate_order_total",
      "file": "pricing.py",
      "group": "pricing",
      "moduleTitle": "Pricing",
      "layer": 4,
      "line": 13,
      "endLine": 16,
      "loc": 4,
      "code": "def calculate_order_total(items, currency, discount_percent=0):\n    subtotal = sum(line_subtotal(item) for item in items)\n    discounted = apply_discount(subtotal, discount_percent)\n    return money_to_minor_units(discounted, currency)",
      "engineId": "196e5b4c74bb2936"
    },
    {
      "id": "pricing.line_subtotal",
      "label": "line_subtotal",
      "file": "pricing.py",
      "group": "pricing",
      "moduleTitle": "Pricing",
      "layer": 4,
      "line": 5,
      "endLine": 6,
      "loc": 2,
      "code": "def line_subtotal(item):\n    return item[\"price\"] * item[\"quantity\"]",
      "engineId": "4e5d11bf6ab80357"
    },
    {
      "id": "pricing.quote_order",
      "label": "quote_order",
      "file": "pricing.py",
      "group": "pricing",
      "moduleTitle": "Pricing",
      "layer": 4,
      "line": 19,
      "endLine": 21,
      "loc": 3,
      "code": "def quote_order(items, currency, discount_percent=0):\n    total = calculate_order_total(items, currency, discount_percent)\n    return format_money(total / minor_unit_scale(currency), currency)",
      "engineId": "bea49bbb46670185"
    },
    {
      "id": "receipts.build_receipt",
      "label": "build_receipt",
      "file": "receipts.py",
      "group": "receipts",
      "moduleTitle": "Receipts",
      "layer": 2,
      "line": 5,
      "endLine": 7,
      "loc": 3,
      "code": "def build_receipt(order):\n    summary = order_summary(order)\n    return {\"heading\": \"Order received\", \"body\": summary[\"total\"]}",
      "engineId": "80eef7b90341f448"
    },
    {
      "id": "receipts.render_receipt",
      "label": "render_receipt",
      "file": "receipts.py",
      "group": "receipts",
      "moduleTitle": "Receipts",
      "layer": 2,
      "line": 10,
      "endLine": 11,
      "loc": 2,
      "code": "def render_receipt(receipt):\n    return receipt[\"heading\"] + \"\\n\" + receipt[\"body\"]",
      "engineId": "b1793c0a8de88369"
    },
    {
      "id": "receipts.send_receipt",
      "label": "send_receipt",
      "file": "receipts.py",
      "group": "receipts",
      "moduleTitle": "Receipts",
      "layer": 2,
      "line": 14,
      "endLine": 15,
      "loc": 2,
      "code": "def send_receipt(order):\n    return {\"message\": render_receipt(build_receipt(order)), \"delivered\": False}",
      "engineId": "e436462582d60c6d"
    },
    {
      "id": "receipts.send_refund_notice",
      "label": "send_refund_notice",
      "file": "receipts.py",
      "group": "receipts",
      "moduleTitle": "Receipts",
      "layer": 2,
      "line": 18,
      "endLine": 20,
      "loc": 3,
      "code": "def send_refund_notice(order):\n    summary = order_summary(order)\n    return {\"message\": \"Refund recorded: \" + summary[\"total\"], \"delivered\": False}",
      "engineId": "43a9babbe6e2b419"
    }
  ],
  "edges": [
    {
      "source": "checkout.prepare_checkout",
      "target": "inventory.check_availability",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "checkout.py",
          "line": 11,
          "code": "\"available\": check_availability(items, stock),"
        }
      ]
    },
    {
      "source": "checkout.prepare_checkout",
      "target": "pricing.quote_order",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "checkout.py",
          "line": 12,
          "code": "\"quote\": quote_order(items, currency, discount_percent),"
        }
      ]
    },
    {
      "source": "checkout.preview_checkout",
      "target": "checkout.prepare_checkout",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "checkout.py",
          "line": 29,
          "code": "return prepare_checkout(items, currency, stock, discount_percent)"
        }
      ]
    },
    {
      "source": "checkout.retry_checkout",
      "target": "checkout.submit_checkout",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "checkout.py",
          "line": 25,
          "code": "return submit_checkout(items, currency, stock, discount_percent)"
        }
      ]
    },
    {
      "source": "checkout.submit_checkout",
      "target": "inventory.reserve_stock",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "checkout.py",
          "line": 17,
          "code": "reservation = reserve_stock(items, stock)"
        }
      ]
    },
    {
      "source": "checkout.submit_checkout",
      "target": "orders.create_order",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "checkout.py",
          "line": 18,
          "code": "order = create_order(items, currency, discount_percent)"
        }
      ]
    },
    {
      "source": "checkout.submit_checkout",
      "target": "orders.record_order",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "checkout.py",
          "line": 20,
          "code": "saved = record_order(order, authorization)"
        }
      ]
    },
    {
      "source": "checkout.submit_checkout",
      "target": "payments.authorize_payment",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "checkout.py",
          "line": 19,
          "code": "authorization = authorize_payment(order)"
        }
      ]
    },
    {
      "source": "checkout.submit_checkout",
      "target": "receipts.send_receipt",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "checkout.py",
          "line": 21,
          "code": "return {\"order\": saved, \"reservation\": reservation, \"receipt\": send_receipt(saved)}"
        }
      ]
    },
    {
      "source": "inventory.check_availability",
      "target": "inventory.available_units",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "inventory.py",
          "line": 9,
          "code": "return all(available_units(stock, item[\"sku\"]) >= item[\"quantity\"] for item in items)"
        }
      ]
    },
    {
      "source": "inventory.release_stock",
      "target": "inventory.available_units",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "inventory.py",
          "line": 23,
          "code": "stock[sku] = available_units(stock, sku) + quantity"
        }
      ]
    },
    {
      "source": "inventory.reserve_stock",
      "target": "inventory.check_availability",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "inventory.py",
          "line": 13,
          "code": "if not check_availability(items, stock):"
        }
      ]
    },
    {
      "source": "jobs.process_abandoned_cart",
      "target": "checkout.preview_checkout",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "jobs.py",
          "line": 17,
          "code": "return preview_checkout(items, currency, stock)"
        }
      ]
    },
    {
      "source": "jobs.process_refund",
      "target": "orders.cancel_order",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "jobs.py",
          "line": 12,
          "code": "cancelled = cancel_order(order, reservation, stock)"
        }
      ]
    },
    {
      "source": "jobs.process_refund",
      "target": "receipts.send_refund_notice",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "jobs.py",
          "line": 13,
          "code": "return {\"order\": cancelled, \"notice\": send_refund_notice(cancelled)}"
        }
      ]
    },
    {
      "source": "jobs.process_renewal",
      "target": "checkout.submit_checkout",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "jobs.py",
          "line": 8,
          "code": "return submit_checkout(items, currency, stock)"
        }
      ]
    },
    {
      "source": "jobs.resend_receipt",
      "target": "receipts.send_receipt",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "jobs.py",
          "line": 21,
          "code": "return send_receipt(order)"
        }
      ]
    },
    {
      "source": "money.format_money",
      "target": "money.minor_unit_scale",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "money.py",
          "line": 18,
          "code": "precision = 0 if minor_unit_scale(code) == 1 else 2"
        }
      ]
    },
    {
      "source": "money.format_money",
      "target": "money.normalize_currency",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "money.py",
          "line": 17,
          "code": "code = normalize_currency(currency)"
        }
      ]
    },
    {
      "source": "money.minor_unit_scale",
      "target": "money.normalize_currency",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "money.py",
          "line": 9,
          "code": "return 1 if normalize_currency(currency) == \"JPY\" else 100"
        }
      ]
    },
    {
      "source": "money.money_to_minor_units",
      "target": "money.minor_unit_scale",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "money.py",
          "line": 13,
          "code": "return round(amount * minor_unit_scale(currency))"
        }
      ]
    },
    {
      "source": "orders.cancel_order",
      "target": "inventory.release_stock",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "orders.py",
          "line": 22,
          "code": "release_stock(reservation, stock)"
        }
      ]
    },
    {
      "source": "orders.cancel_order",
      "target": "payments.refund_payment",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "orders.py",
          "line": 23,
          "code": "refund = refund_payment(order)"
        }
      ]
    },
    {
      "source": "orders.create_order",
      "target": "money.normalize_currency",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "orders.py",
          "line": 11,
          "code": "\"currency\": normalize_currency(currency),"
        }
      ]
    },
    {
      "source": "orders.create_order",
      "target": "pricing.calculate_order_total",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "orders.py",
          "line": 12,
          "code": "\"total_minor\": calculate_order_total(items, currency, discount_percent),"
        }
      ]
    },
    {
      "source": "orders.order_summary",
      "target": "money.format_money",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "orders.py",
          "line": 29,
          "code": "return {\"total\": format_money(amount, order[\"currency\"]), \"items\": len(order[\"items\"])}"
        }
      ]
    },
    {
      "source": "orders.order_summary",
      "target": "money.minor_unit_scale",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "orders.py",
          "line": 28,
          "code": "amount = order[\"total_minor\"] / minor_unit_scale(order[\"currency\"])"
        }
      ]
    },
    {
      "source": "orders.record_order",
      "target": "payments.capture_payment",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "orders.py",
          "line": 17,
          "code": "captured = capture_payment(authorization)"
        }
      ]
    },
    {
      "source": "payments.authorize_payment",
      "target": "payments.payment_payload",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "payments.py",
          "line": 10,
          "code": "payload = payment_payload(order)"
        }
      ]
    },
    {
      "source": "payments.refund_payment",
      "target": "money.minor_unit_scale",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "payments.py",
          "line": 21,
          "code": "amount = order[\"total_minor\"] / minor_unit_scale(order[\"currency\"])"
        }
      ]
    },
    {
      "source": "payments.refund_payment",
      "target": "money.money_to_minor_units",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "payments.py",
          "line": 22,
          "code": "return {\"refund_minor\": money_to_minor_units(amount, order[\"currency\"])}"
        }
      ]
    },
    {
      "source": "pricing.calculate_order_total",
      "target": "money.money_to_minor_units",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "pricing.py",
          "line": 16,
          "code": "return money_to_minor_units(discounted, currency)"
        }
      ]
    },
    {
      "source": "pricing.calculate_order_total",
      "target": "pricing.apply_discount",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "pricing.py",
          "line": 15,
          "code": "discounted = apply_discount(subtotal, discount_percent)"
        }
      ]
    },
    {
      "source": "pricing.calculate_order_total",
      "target": "pricing.line_subtotal",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "pricing.py",
          "line": 14,
          "code": "subtotal = sum(line_subtotal(item) for item in items)"
        }
      ]
    },
    {
      "source": "pricing.quote_order",
      "target": "money.format_money",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "pricing.py",
          "line": 21,
          "code": "return format_money(total / minor_unit_scale(currency), currency)"
        }
      ]
    },
    {
      "source": "pricing.quote_order",
      "target": "money.minor_unit_scale",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "pricing.py",
          "line": 21,
          "code": "return format_money(total / minor_unit_scale(currency), currency)"
        }
      ]
    },
    {
      "source": "pricing.quote_order",
      "target": "pricing.calculate_order_total",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "pricing.py",
          "line": 20,
          "code": "total = calculate_order_total(items, currency, discount_percent)"
        }
      ]
    },
    {
      "source": "receipts.build_receipt",
      "target": "orders.order_summary",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "receipts.py",
          "line": 6,
          "code": "summary = order_summary(order)"
        }
      ]
    },
    {
      "source": "receipts.send_receipt",
      "target": "receipts.build_receipt",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "receipts.py",
          "line": 15,
          "code": "return {\"message\": render_receipt(build_receipt(order)), \"delivered\": False}"
        }
      ]
    },
    {
      "source": "receipts.send_receipt",
      "target": "receipts.render_receipt",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "receipts.py",
          "line": 15,
          "code": "return {\"message\": render_receipt(build_receipt(order)), \"delivered\": False}"
        }
      ]
    },
    {
      "source": "receipts.send_refund_notice",
      "target": "orders.order_summary",
      "kind": "calls",
      "sourceLocations": [
        {
          "file": "receipts.py",
          "line": 19,
          "code": "summary = order_summary(order)"
        }
      ]
    }
  ],
  "scenarios": [
    {
      "id": "currency-precision",
      "label": "Currency precision",
      "targetId": "money.money_to_minor_units",
      "description": "A shared amount conversion is called by both pricing and refunds. Follow the paths into checkout previews, completed orders and background jobs.",
      "question": "Where could a rounding change reach?",
      "focusCallerId": "jobs.process_abandoned_cart",
      "directCallerIds": [
        "payments.refund_payment",
        "pricing.calculate_order_total"
      ],
      "transitiveCallerIds": [
        "orders.cancel_order",
        "orders.create_order",
        "pricing.quote_order",
        "checkout.prepare_checkout",
        "checkout.submit_checkout",
        "jobs.process_refund",
        "checkout.preview_checkout",
        "checkout.retry_checkout",
        "jobs.process_renewal",
        "jobs.process_abandoned_cart"
      ],
      "upstreamIds": [
        "payments.refund_payment",
        "pricing.calculate_order_total",
        "orders.cancel_order",
        "orders.create_order",
        "pricing.quote_order",
        "checkout.prepare_checkout",
        "checkout.submit_checkout",
        "jobs.process_refund",
        "checkout.preview_checkout",
        "checkout.retry_checkout",
        "jobs.process_renewal",
        "jobs.process_abandoned_cart"
      ],
      "paths": [
        [
          "payments.refund_payment",
          "money.money_to_minor_units"
        ],
        [
          "pricing.calculate_order_total",
          "money.money_to_minor_units"
        ],
        [
          "orders.cancel_order",
          "payments.refund_payment",
          "money.money_to_minor_units"
        ],
        [
          "orders.create_order",
          "pricing.calculate_order_total",
          "money.money_to_minor_units"
        ],
        [
          "pricing.quote_order",
          "pricing.calculate_order_total",
          "money.money_to_minor_units"
        ],
        [
          "checkout.prepare_checkout",
          "pricing.quote_order",
          "pricing.calculate_order_total",
          "money.money_to_minor_units"
        ],
        [
          "checkout.submit_checkout",
          "orders.create_order",
          "pricing.calculate_order_total",
          "money.money_to_minor_units"
        ],
        [
          "jobs.process_refund",
          "orders.cancel_order",
          "payments.refund_payment",
          "money.money_to_minor_units"
        ],
        [
          "checkout.preview_checkout",
          "checkout.prepare_checkout",
          "pricing.quote_order",
          "pricing.calculate_order_total",
          "money.money_to_minor_units"
        ],
        [
          "checkout.retry_checkout",
          "checkout.submit_checkout",
          "orders.create_order",
          "pricing.calculate_order_total",
          "money.money_to_minor_units"
        ],
        [
          "jobs.process_renewal",
          "checkout.submit_checkout",
          "orders.create_order",
          "pricing.calculate_order_total",
          "money.money_to_minor_units"
        ],
        [
          "jobs.process_abandoned_cart",
          "checkout.preview_checkout",
          "checkout.prepare_checkout",
          "pricing.quote_order",
          "pricing.calculate_order_total",
          "money.money_to_minor_units"
        ]
      ],
      "focusPath": [
        "jobs.process_abandoned_cart",
        "checkout.preview_checkout",
        "checkout.prepare_checkout",
        "pricing.quote_order",
        "pricing.calculate_order_total",
        "money.money_to_minor_units"
      ],
      "unaffectedIds": [
        "inventory.available_units",
        "inventory.check_availability",
        "inventory.release_stock",
        "inventory.reserve_stock",
        "jobs.resend_receipt",
        "money.format_money",
        "money.minor_unit_scale",
        "money.normalize_currency",
        "orders.order_summary",
        "orders.record_order",
        "payments.authorize_payment",
        "payments.capture_payment",
        "payments.payment_payload",
        "pricing.apply_discount",
        "pricing.line_subtotal",
        "receipts.build_receipt",
        "receipts.render_receipt",
        "receipts.send_receipt",
        "receipts.send_refund_notice"
      ]
    },
    {
      "id": "stock-reservation",
      "label": "Stock reservation",
      "targetId": "inventory.reserve_stock",
      "description": "Stock is reserved on submission. Retry and renewal paths reach the same function; a checkout preview does not.",
      "question": "Which workflows reserve stock?",
      "focusCallerId": "jobs.process_renewal",
      "directCallerIds": [
        "checkout.submit_checkout"
      ],
      "transitiveCallerIds": [
        "checkout.retry_checkout",
        "jobs.process_renewal"
      ],
      "upstreamIds": [
        "checkout.submit_checkout",
        "checkout.retry_checkout",
        "jobs.process_renewal"
      ],
      "paths": [
        [
          "checkout.submit_checkout",
          "inventory.reserve_stock"
        ],
        [
          "checkout.retry_checkout",
          "checkout.submit_checkout",
          "inventory.reserve_stock"
        ],
        [
          "jobs.process_renewal",
          "checkout.submit_checkout",
          "inventory.reserve_stock"
        ]
      ],
      "focusPath": [
        "jobs.process_renewal",
        "checkout.submit_checkout",
        "inventory.reserve_stock"
      ],
      "unaffectedIds": [
        "checkout.prepare_checkout",
        "checkout.preview_checkout",
        "inventory.available_units",
        "inventory.check_availability",
        "inventory.release_stock",
        "jobs.process_abandoned_cart",
        "jobs.process_refund",
        "jobs.resend_receipt",
        "money.format_money",
        "money.minor_unit_scale",
        "money.money_to_minor_units",
        "money.normalize_currency",
        "orders.cancel_order",
        "orders.create_order",
        "orders.order_summary",
        "orders.record_order",
        "payments.authorize_payment",
        "payments.capture_payment",
        "payments.payment_payload",
        "payments.refund_payment",
        "pricing.apply_discount",
        "pricing.calculate_order_total",
        "pricing.line_subtotal",
        "pricing.quote_order",
        "receipts.build_receipt",
        "receipts.render_receipt",
        "receipts.send_receipt",
        "receipts.send_refund_notice"
      ]
    },
    {
      "id": "receipt-format",
      "label": "Receipt format",
      "targetId": "receipts.render_receipt",
      "description": "Receipt rendering is shared by checkout and receipt resends. Refund notices use a separate path.",
      "question": "Which messages share this renderer?",
      "focusCallerId": "jobs.resend_receipt",
      "directCallerIds": [
        "receipts.send_receipt"
      ],
      "transitiveCallerIds": [
        "checkout.submit_checkout",
        "jobs.resend_receipt",
        "checkout.retry_checkout",
        "jobs.process_renewal"
      ],
      "upstreamIds": [
        "receipts.send_receipt",
        "checkout.submit_checkout",
        "jobs.resend_receipt",
        "checkout.retry_checkout",
        "jobs.process_renewal"
      ],
      "paths": [
        [
          "receipts.send_receipt",
          "receipts.render_receipt"
        ],
        [
          "checkout.submit_checkout",
          "receipts.send_receipt",
          "receipts.render_receipt"
        ],
        [
          "jobs.resend_receipt",
          "receipts.send_receipt",
          "receipts.render_receipt"
        ],
        [
          "checkout.retry_checkout",
          "checkout.submit_checkout",
          "receipts.send_receipt",
          "receipts.render_receipt"
        ],
        [
          "jobs.process_renewal",
          "checkout.submit_checkout",
          "receipts.send_receipt",
          "receipts.render_receipt"
        ]
      ],
      "focusPath": [
        "jobs.resend_receipt",
        "receipts.send_receipt",
        "receipts.render_receipt"
      ],
      "unaffectedIds": [
        "checkout.prepare_checkout",
        "checkout.preview_checkout",
        "inventory.available_units",
        "inventory.check_availability",
        "inventory.release_stock",
        "inventory.reserve_stock",
        "jobs.process_abandoned_cart",
        "jobs.process_refund",
        "money.format_money",
        "money.minor_unit_scale",
        "money.money_to_minor_units",
        "money.normalize_currency",
        "orders.cancel_order",
        "orders.create_order",
        "orders.order_summary",
        "orders.record_order",
        "payments.authorize_payment",
        "payments.capture_payment",
        "payments.payment_payload",
        "payments.refund_payment",
        "pricing.apply_discount",
        "pricing.calculate_order_total",
        "pricing.line_subtotal",
        "pricing.quote_order",
        "receipts.build_receipt",
        "receipts.send_refund_notice"
      ]
    }
  ]
}