{
  "name": "Protected Refund Agent — BiDigest",
  "nodes": [
    {
      "parameters": {},
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "When refund proposed",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "sample-amount",
              "name": "amount",
              "value": 5000,
              "type": "number"
            },
            {
              "id": "sample-client",
              "name": "clientId",
              "value": "client-acme",
              "type": "string"
            },
            {
              "id": "sample-op",
              "name": "operationType",
              "value": "forward",
              "type": "string"
            },
            {
              "id": "sample-comp",
              "name": "compensationVerifyComplete",
              "value": false,
              "type": "boolean"
            }
          ]
        },
        "options": {}
      },
      "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "name": "Sample refund (default → Need review)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://bidigest.com/api/v1/admissibility/verify",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "={{ $env.BIDIGEST_API_KEY || 'Bearer PASTE_YOUR_BIDIGEST_KEY' }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({\n  jurisdiction: { regionCode: 'us-fed', industrySector: 'financial' },\n  intent: {\n    agentId: 'agency-agent:' + $json.clientId,\n    actionType: 'refund_approval',\n    proposedPayload: {\n      action: 'refund_approval',\n      amount: $json.amount,\n      clientId: $json.clientId,\n      operationType: $json.operationType,\n      synthesizedClaims: [\n        'BiDigest Trustee program BDG-TRUSTEE-001 references the published governance framework.',\n      ],\n      shadowCitations: ['https://bidigest.com/governance'],\n    },\n  },\n  sessionContext: {\n    sessionId: 'session-' + $json.clientId + '-refund',\n    userId: 'agency_agent',\n    sessionStartTime: $now.toISO(),\n  },\n  groundTruthBinding: {\n    domain: 'bidigest.com',\n    regulatoryId: 'BDG-TRUSTEE-001',\n  },\n}) }}",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          }
        }
      },
      "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "name": "BiDigest verify",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        0
      ],
      "notesInFlow": true,
      "notes": "Auth: None + Send Headers. Set n8n variable BIDIGEST_API_KEY (Bearer bid_live_...) from bidigest.com/partners/ai-automation/recipes — or paste that full line into Authorization below. Save → Execute workflow."
    },
    {
      "parameters": {
        "jsCode": "const INDETERMINATE_REASON_CODES = new Set([\n  'VALIDATION_UNAVAILABLE',\n  'TIMEOUT',\n  'DEPENDENCY_UNAVAILABLE',\n  'DEPENDENCY_FAILURE',\n  'INTERNAL_ERROR',\n  'SIGNING_UNAVAILABLE',\n  'POLICY_EVAL_UNAVAILABLE',\n  'RATE_LIMITED',\n]);\n\nconst raw = $input.first().json;\nconst body = raw.legacy ?? raw.data ?? raw;\nconst errMsg = typeof raw.error === 'string' ? raw.error : (body?.error ?? '');\nconst statusCode = raw.statusCode ?? raw.status ?? null;\n\nif (statusCode === 401 || errMsg.includes('API key')) {\n  return {\n    verdict: 'REJECTED',\n    receipt_id: null,\n    retry_eligible: false,\n    recompute_required: false,\n    hitl_eligible: false,\n    auth_error: true,\n    setup_hint:\n      'Set n8n variable BIDIGEST_API_KEY to your full Bearer bid_live_... line (recipes page), OR paste it in BiDigest verify → Send Headers → Authorization. Then Save and Execute workflow.',\n    raw,\n  };\n}\n\nconst reason_code = body.reason_code ?? null;\nlet verdict = 'REJECTED';\nlet retry_eligible = false;\nlet recompute_required = false;\nlet hitl_eligible = false;\nlet setup_hint = null;\n\nif (body.reason_code === 'TENANT_NOT_PROVISIONED') {\n  setup_hint =\n    'Ground truth not provisioned on production. Re-import template JSON — verify must use bidigest.com + BDG-TRUSTEE-001 (not agency-automation-demo.bidigest.com).';\n}\n\nif (body.reason_code === '403_REBONDING_REQUIRED') {\n  verdict = 'REVIEW_REQUIRED';\n  hitl_eligible = true;\n} else if (body.admissibility_status === 'APPROVED') {\n  verdict = 'APPROVED';\n} else if (reason_code && INDETERMINATE_REASON_CODES.has(reason_code)) {\n  verdict = 'VALIDATION_UNAVAILABLE';\n  retry_eligible = true;\n  recompute_required = true;\n  hitl_eligible = false;\n} else {\n  verdict = 'REJECTED';\n}\n\nconst p = $('Sample refund (default → Need review)').first().json;\n// Agency policy: escalate only when verify already APPROVED\nif (verdict === 'APPROVED' && p.amount > 500) {\n  verdict = 'REVIEW_REQUIRED';\n  hitl_eligible = true;\n  retry_eligible = false;\n  recompute_required = false;\n}\n// Case C — compensation_reversal is a fresh verify boundary (not continuation)\nif (p.operationType === 'compensation_reversal' && !p.compensationVerifyComplete) {\n  verdict = 'REJECTED';\n  recompute_required = true;\n  retry_eligible = false;\n  hitl_eligible = false;\n}\nconst receipt_id = body.decision_receipt?.receipt_id ?? raw.merkleReceipt?.receiptId ?? null;\nconst verify_status = body.admissibility_status ?? null;\n\n// Continuity doctrine — replay harness cases A–E (distinct from retry_eligible)\nconst forward_receipt_authorizes_compensation = false;\nlet continuation_permitted = false;\nlet resume_without_fresh_verify = false;\nif (recompute_required || verdict === 'VALIDATION_UNAVAILABLE') {\n  continuation_permitted = false;\n  resume_without_fresh_verify = receipt_id != null;\n} else if (verdict === 'APPROVED' && !hitl_eligible) {\n  continuation_permitted = true;\n}\n\nconst branch =\n  verdict === 'APPROVED'\n    ? 'Continue'\n    : verdict === 'REVIEW_REQUIRED'\n      ? 'Human approval'\n      : verdict === 'VALIDATION_UNAVAILABLE'\n        ? 'Recompute · Not HITL'\n        : 'Hard stop';\nlet user_message = 'Execution blocked.';\nif (statusCode === 401 || errMsg.includes('API key')) {\n  user_message = setup_hint ?? 'Fix API key: set BIDIGEST_API_KEY or paste Bearer bid_live_… in Authorization.';\n} else if (setup_hint) {\n  user_message = setup_hint;\n} else if (verdict === 'REVIEW_REQUIRED') {\n  user_message =\n    'BiDigest authorized this attempt; agency policy requires human sign-off before payment.';\n} else if (verdict === 'APPROVED') {\n  user_message = 'Authorized — proceed to payment or ERP.';\n} else if (verdict === 'VALIDATION_UNAVAILABLE') {\n  user_message = 'Verify indeterminate — run fresh verify. Not a human-approval path.';\n} else if (p.operationType === 'compensation_reversal' && !p.compensationVerifyComplete) {\n  user_message =\n    'Compensation requires fresh verify boundary — forward receipt is evidence only.';\n} else {\n  user_message = `Blocked (${reason_code ?? 'DENIED'}). Hard stop — do not route to human review.`;\n}\nreturn {\n  verdict,\n  branch,\n  user_message,\n  verify_status,\n  receipt_id,\n  retry_eligible,\n  recompute_required,\n  hitl_eligible,\n  continuation_permitted,\n  forward_receipt_authorizes_compensation,\n  resume_without_fresh_verify,\n  reason_code,\n  setup_hint,\n  raw,\n};"
      },
      "id": "d4e5f6a7-b8c9-0123-def0-234567890123",
      "name": "Map to agency verdict",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        0
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.verdict }}",
                    "rightValue": "APPROVED",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Continue"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.verdict }}",
                    "rightValue": "REVIEW_REQUIRED",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Human approval"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.verdict }}",
                    "rightValue": "REJECTED",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Hard stop"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.verdict }}",
                    "rightValue": "VALIDATION_UNAVAILABLE",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Recompute · Not HITL"
            }
          ],
          "options": {
            "fallbackOutput": "extra"
          }
        }
      },
      "id": "e5f6a7b8-c9d0-1234-ef01-345678901234",
      "name": "Branch on verdict",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        880,
        0
      ]
    },
    {
      "parameters": {
        "content": "## READ FIRST — 3 steps\n1. **API key** from https://bidigest.com/partners/ai-automation/recipes\n2. n8n → Settings → Variables → **BIDIGEST_API_KEY** = `Bearer bid_live_…` (full line)\n   **OR** paste that line into BiDigest verify → Send Headers → Authorization\n3. **Save** → **Execute workflow** → open **Map to agency verdict**\n\n**Where you land:** Map output **branch** + **user_message** (from BiDigest verify + agency policy).\nSample amount/vendor do **not** pick the branch by themselves."
      },
      "id": "22222222-2222-2222-2222-222222222221",
      "name": "READ FIRST",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -320,
        -320
      ]
    },
    {
      "parameters": {
        "content": "## Setup details\n✓ BiDigest verify: Authentication = None + Send Headers (correct).\n✓ Ground truth: **bidigest.com** + **BDG-TRUSTEE-001** only.\n✗ **agency-automation-demo.bidigest.com** → TENANT_NOT_PROVISIONED → Hard stop.\n\n**One JSON file per workflow** — download from recipes; do not maintain duplicate imports in n8n.\n\nIf verify JSON fails to parse: re-download template (uses JSON.stringify)."
      },
      "id": "f5f6a7b8-c9d0-1234-ef01-345678901239",
      "name": "SETUP — API key",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -320,
        -120
      ]
    },
    {
      "parameters": {
        "content": "## APPROVED — Continue\nProcess refund in billing / Stripe.\nStore receipt_id: {{ $json.receipt_id }}"
      },
      "id": "f6a7b8c9-d0e1-2345-f012-456789012345",
      "name": "APPROVED — Continue",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1100,
        -120
      ]
    },
    {
      "parameters": {
        "content": "## REVIEW_REQUIRED — Human approval\nPause before payout — manager approves.\nReceipt: {{ $json.receipt_id }}"
      },
      "id": "a7b8c9d0-e1f2-3456-0123-567890123456",
      "name": "REVIEW_REQUIRED — Human approval",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1100,
        0
      ]
    },
    {
      "parameters": {
        "content": "## REJECTED — Hard stop\nStop. Log receipt. Do not route to human review.\n{{ $json.receipt_id }}"
      },
      "id": "b8c9d0e1-f2a3-4567-1234-678901234567",
      "name": "REJECTED — Hard stop",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1100,
        120
      ]
    },
    {
      "parameters": {
        "content": "## VALIDATION_UNAVAILABLE — Recompute — Not HITL\nAuthorization state indeterminate.\nFresh verify required before continuation.\nHuman approval cannot resume this execution.\nDo not approve, retry, or manually continue on this branch.\nrecompute_required: true\nReceipt: {{ $json.receipt_id }}"
      },
      "id": "c9d0e1f2-a3b4-4567-8901-234567890123",
      "name": "VALIDATION_UNAVAILABLE — Recompute — Not HITL",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1100,
        240
      ]
    },
    {
      "parameters": {
        "content": "## Try other branches (edit sample → Save → Execute)\nDefault **5000** + operationType **forward** → **Human approval** when verify APPROVED + amount > 500.\n\n| Target branch | Sample edits |\n|---------------|----------------|\n| Human approval (default) | amount 5000 |\n| Continue | amount 100 |\n| Hard stop | break API key once |\n| Compensation (Case C) | operationType = compensation_reversal |\n\nOpen **Map to agency verdict** → **branch** + continuity fields.\n\n**Execute boundary (M3 P2C):** Continue branch calls execute-boundary before **Refund demo**. Use **When resume blocked (demo)** to prove EXECUTE_BOUNDARY_BLOCKED."
      },
      "id": "d0e1f2a3-b4c5-6789-0123-456789012345",
      "name": "DEMO — three paths",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -320,
        80
      ]
    },
    {
      "parameters": {
        "content": "## COMPENSATION — fresh verify boundary\nRollback / reversal is **not** continuation of the forward receipt.\n\n| Field | Value |\n|-------|-------|\n| operationType | compensation_reversal |\n| compensationVerifyComplete | false (default) |\n\nMap output: recompute_required + resume_without_fresh_verify.\nforward_receipt_authorizes_compensation is always false.\nRun a **new** BiDigest verify for the compensation intent before payout."
      },
      "name": "COMPENSATION — fresh verify boundary",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1100,
        360
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://bidigest.com/api/v1/admissibility/execute-boundary/evaluate",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "={{ $env.BIDIGEST_API_KEY || 'Bearer PASTE_YOUR_BIDIGEST_KEY' }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({\n  pathId: 'n8n_refund',\n  executeBoundary: {\n    deliveryAttempt: 1,\n  },\n}) }}",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          }
        }
      },
      "id": "e1f2a3b4-c5d6-7890-1234-567890abcdef",
      "name": "BiDigest execute boundary",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1100,
        -120
      ],
      "notesInFlow": true,
      "notes": "M3 P2C — evaluate execute-boundary immediately before refund consequence."
    },
    {
      "parameters": {
        "jsCode": "const raw = $input.first().json;\nconst body = raw.legacy ?? raw.data ?? raw;\nconst errMsg = typeof raw.error === 'string' ? raw.error : (body?.error ?? '');\nconst statusCode = raw.statusCode ?? raw.status ?? null;\n\nif (statusCode === 401 || errMsg.includes('API key')) {\n  return {\n    allow_execute: false,\n    code: 'UNAUTHORIZED',\n    reason: 'api_key_required',\n    user_message: 'Set BIDIGEST_API_KEY before execute-boundary evaluate.',\n    raw,\n  };\n}\n\nconst allow_execute = body.allow_execute === true;\nreturn {\n  allow_execute,\n  code: body.code ?? (allow_execute ? 'EXECUTE_PERMITTED' : 'EXECUTE_BOUNDARY_BLOCKED'),\n  reason: body.reason ?? null,\n  fresh_verify_required: body.fresh_verify_required ?? false,\n  recompute_required: body.recompute_required ?? false,\n  user_message: allow_execute\n    ? 'Execute boundary passed — refund may proceed.'\n    : `Execute boundary blocked (${body.reason ?? body.code ?? 'denied'}). Do not refund.`,\n  raw,\n};"
      },
      "id": "f2a3b4c5-d6e7-8901-2345-67890abcdef0",
      "name": "Map execute boundary",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1320,
        -120
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.allow_execute }}",
                    "rightValue": true,
                    "operator": {
                      "type": "boolean",
                      "operation": "true"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Permitted"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.allow_execute }}",
                    "rightValue": false,
                    "operator": {
                      "type": "boolean",
                      "operation": "false"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Blocked"
            }
          ],
          "options": {
            "fallbackOutput": "extra"
          }
        }
      },
      "id": "a3b4c5d6-e7f8-9012-3456-7890abcdef01",
      "name": "Route execute boundary",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        1540,
        -120
      ]
    },
    {
      "parameters": {
        "jsCode": "const mapped = $('Map execute boundary').first().json;\nconst refund = $('Sample refund (default → Need review)').first().json;\nreturn {\n  consequence: 'refund_demo',\n  status: 'refunded',\n  amount: refund.amount,\n  clientId: refund.clientId,\n  execute_boundary_reason: mapped.reason,\n  message: 'Demo only — no real refund. Execute boundary enforced before this node.',\n};"
      },
      "id": "b4c5d6e7-f8a9-0123-4567-890abcdef012",
      "name": "Refund demo (consequence)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1760,
        -200
      ]
    },
    {
      "parameters": {
        "content": "## EXECUTE_BOUNDARY_BLOCKED\nRefund must not run.\nreason: {{ $json.reason }}\ncode: {{ $json.code }}"
      },
      "id": "c5d6e7f8-a9b0-1234-5678-90abcdef0123",
      "name": "EXECUTE_BOUNDARY blocked",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1760,
        -40
      ]
    },
    {
      "parameters": {},
      "id": "d6e7f8a9-b0c1-2345-6789-0abcdef01234",
      "name": "When resume blocked (demo)",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        260
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "resume-attempt",
              "name": "deliveryAttempt",
              "value": 2,
              "type": "number"
            },
            {
              "id": "resume-revoked",
              "name": "authorityRevoked",
              "value": true,
              "type": "boolean"
            },
            {
              "id": "resume-rec-id",
              "name": "priorReceiptId",
              "value": "rec_refund_demo",
              "type": "string"
            },
            {
              "id": "resume-rec-issued",
              "name": "priorIssuedAtMs",
              "value": "={{ $now.toMillis() - 60000 }}",
              "type": "number"
            },
            {
              "id": "resume-rec-fresh",
              "name": "priorFreshUntilMs",
              "value": "={{ $now.toMillis() + 3600000 }}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "e7f8a9b0-c1d2-3456-7890-abcdef012345",
      "name": "Resume blocked payload (demo)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        260
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://bidigest.com/api/v1/admissibility/execute-boundary/evaluate",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "={{ $env.BIDIGEST_API_KEY || 'Bearer PASTE_YOUR_BIDIGEST_KEY' }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({\n  pathId: 'n8n_refund',\n  executeBoundary: {\n    deliveryAttempt: $json.deliveryAttempt,\n    authorityRevoked: $json.authorityRevoked,\n    priorReceipt: {\n      receiptId: $json.priorReceiptId,\n      issuedAtMs: $json.priorIssuedAtMs,\n      authorizationFreshUntilMs: $json.priorFreshUntilMs,\n    },\n  },\n}) }}",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          }
        }
      },
      "id": "f8a9b0c1-d2e3-4567-8901-bcdef0123456",
      "name": "BiDigest execute boundary (resume demo)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "const raw = $input.first().json;\nconst body = raw.legacy ?? raw.data ?? raw;\nconst allow_execute = body.allow_execute === true;\nreturn {\n  allow_execute,\n  code: body.code ?? (allow_execute ? 'EXECUTE_PERMITTED' : 'EXECUTE_BOUNDARY_BLOCKED'),\n  reason: body.reason ?? null,\n  user_message: allow_execute\n    ? 'Resume permitted after fresh verify.'\n    : `Execute boundary blocked (${body.reason ?? 'denied'}).`,\n  raw,\n};"
      },
      "id": "a9b0c1d2-e3f4-5678-9012-cdef01234567",
      "name": "Map resume execute boundary",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        260
      ]
    }
  ],
  "connections": {
    "When refund proposed": {
      "main": [
        [
          {
            "node": "Sample refund (default → Need review)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample refund (default → Need review)": {
      "main": [
        [
          {
            "node": "BiDigest verify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BiDigest verify": {
      "main": [
        [
          {
            "node": "Map to agency verdict",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map to agency verdict": {
      "main": [
        [
          {
            "node": "Branch on verdict",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Branch on verdict": {
      "main": [
        [
          {
            "node": "BiDigest execute boundary",
            "type": "main",
            "index": 0
          }
        ],
        [],
        [],
        []
      ]
    },
    "BiDigest execute boundary": {
      "main": [
        [
          {
            "node": "Map execute boundary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map execute boundary": {
      "main": [
        [
          {
            "node": "Route execute boundary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route execute boundary": {
      "main": [
        [
          {
            "node": "Refund demo (consequence)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "EXECUTE_BOUNDARY blocked",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When resume blocked (demo)": {
      "main": [
        [
          {
            "node": "Resume blocked payload (demo)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Resume blocked payload (demo)": {
      "main": [
        [
          {
            "node": "BiDigest execute boundary (resume demo)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BiDigest execute boundary (resume demo)": {
      "main": [
        [
          {
            "node": "Map resume execute boundary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "bidigest-protected-refund-agent-v2"
  },
  "settings": {
    "executionOrder": "v1"
  }
}