{
  "id": "PragmaticLoopReliabilityHarness2026",
  "name": "Test workflow reliability with deterministic fixtures",
  "nodes": [
    {
      "parameters": {
        "content": "# Reliability test harness\n\nRun five synthetic fixtures through validation, in-run duplicate detection, bounded retry planning, human-review routing, and seven fail-closed checks. This educational workflow uses no credentials, makes no network request, and performs no external action. It is not a production idempotency store.",
        "height": 220,
        "width": 1460,
        "color": 5
      },
      "id": "c38b6bd0-12dd-4fae-baaa-37f132aa0a01",
      "name": "Overview - Read first",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        180,
        80
      ]
    },
    {
      "parameters": {
        "content": "## 1. Run synthetic fixtures\n\nUse the manual trigger. The next node creates five local fixtures: success, duplicate, retryable, retry-exhausted, and invalid. No real customer or personal data is included.",
        "height": 220,
        "width": 500,
        "color": 3
      },
      "id": "c38b6bd0-12dd-4fae-baaa-37f132aa0a02",
      "name": "Step 1 - Synthetic fixtures",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        180,
        340
      ]
    },
    {
      "parameters": {
        "content": "## 2. Validate and route\n\nRequired fields are checked first. Duplicate detection is deliberately limited to this one execution. Retryable fixtures receive only a planned next attempt; exhausted or invalid fixtures go to review.",
        "height": 220,
        "width": 500,
        "color": 4
      },
      "id": "c38b6bd0-12dd-4fae-baaa-37f132aa0a03",
      "name": "Step 2 - Validate and route",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        700,
        340
      ]
    },
    {
      "parameters": {
        "content": "## 3. Verify before extending\n\nThe final nodes prove the expected 1 ready / 1 duplicate / 1 retry / 2 review distribution and zero side effects. Before adding a real integration, define authority, durable state, concurrency, retry limits, secrets, observability, and an accountable production owner.",
        "height": 220,
        "width": 500,
        "color": 2
      },
      "id": "c38b6bd0-12dd-4fae-baaa-37f132aa0a04",
      "name": "Step 3 - Verify before extending",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1220,
        340
      ]
    },
    {
      "parameters": {},
      "id": "0f10aa5d-59f0-43a8-b4b7-0fe5f4f7d101",
      "name": "Run Reliability Fixtures",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        260,
        660
      ]
    },
    {
      "parameters": {
        "jsCode": "return [\n  { json: { fixture: 'success', event_id: 'evt-100', idempotency_key: 'order-100', operation: 'sync_contact', simulate: 'success', attempt: 1, max_attempts: 3 } },\n  { json: { fixture: 'duplicate', event_id: 'evt-101', idempotency_key: 'order-100', operation: 'sync_contact', simulate: 'success', attempt: 1, max_attempts: 3 } },\n  { json: { fixture: 'retryable', event_id: 'evt-200', idempotency_key: 'order-200', operation: 'sync_contact', simulate: 'retryable', attempt: 1, max_attempts: 3 } },\n  { json: { fixture: 'retry_exhausted', event_id: 'evt-300', idempotency_key: 'order-300', operation: 'sync_contact', simulate: 'retryable', attempt: 3, max_attempts: 3 } },\n  { json: { fixture: 'invalid', event_id: 'evt-400', idempotency_key: 'order-400', operation: '', simulate: 'success', attempt: 1, max_attempts: 3 } }\n];"
      },
      "id": "f53bd75c-3c94-4fa1-a5c9-83ee84dad102",
      "name": "Seed Five Fixtures",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        520,
        660
      ]
    },
    {
      "parameters": {
        "jsCode": "const seen = new Set();\n\nreturn $input.all().map((item, index) => {\n  const input = { ...item.json };\n  const validationErrors = [];\n\n  if (typeof input.event_id !== 'string' || !input.event_id.trim()) validationErrors.push('event_id_required');\n  if (typeof input.operation !== 'string' || !input.operation.trim()) validationErrors.push('operation_required');\n  if (!Number.isInteger(input.attempt) || input.attempt < 1) validationErrors.push('attempt_invalid');\n  if (!Number.isInteger(input.max_attempts) || input.max_attempts < 1) validationErrors.push('max_attempts_invalid');\n\n  const key = input.idempotency_key || input.event_id || `invalid-${index}`;\n  const duplicate = seen.has(key);\n  if (!duplicate) seen.add(key);\n\n  let outcome = 'ready';\n  let outcomeReason = 'validated_first_attempt';\n\n  if (validationErrors.length > 0) {\n    outcome = 'review';\n    outcomeReason = 'validation_failed';\n  } else if (duplicate) {\n    outcome = 'duplicate';\n    outcomeReason = 'idempotency_key_seen';\n  } else if (input.simulate === 'retryable' && input.attempt < input.max_attempts) {\n    outcome = 'retry';\n    outcomeReason = 'bounded_retry_available';\n  } else if (input.simulate === 'retryable') {\n    outcome = 'review';\n    outcomeReason = 'retry_budget_exhausted';\n  }\n\n  return {\n    json: {\n      ...input,\n      idempotency_key: key,\n      duplicate,\n      validation_errors: validationErrors,\n      outcome,\n      outcome_reason: outcomeReason\n    }\n  };\n});"
      },
      "id": "f3856897-6e9a-4bb3-b0cf-e205f588d103",
      "name": "Validate Dedupe and Route",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        800,
        660
      ]
    },
    {
      "parameters": {
        "jsCode": "const actionMap = {\n  ready: 'would_write_to_client_system',\n  duplicate: 'suppress_duplicate',\n  retry: 'schedule_bounded_retry',\n  review: 'human_review'\n};\n\nreturn $input.all().map((item) => ({\n  json: {\n    ...item.json,\n    planned_action: actionMap[item.json.outcome],\n    next_attempt: item.json.outcome === 'retry' ? item.json.attempt + 1 : null,\n    side_effect_executed: false,\n    external_actions: 0,\n    execution_capability: 'none'\n  }\n}));"
      },
      "id": "af7e276d-12d7-460f-b32f-015658f9d104",
      "name": "Plan Safe Actions Only",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1080,
        660
      ]
    },
    {
      "parameters": {
        "jsCode": "const items = $input.all().map((item) => item.json);\nconst outcomeCounts = Object.fromEntries(['ready', 'duplicate', 'retry', 'review'].map((name) => [name, items.filter((item) => item.outcome === name).length]));\nconst sideEffectsExecuted = items.filter((item) => item.side_effect_executed).length;\nconst externalActions = items.reduce((total, item) => total + item.external_actions, 0);\nconst duplicateEffects = items.filter((item) => item.duplicate && item.side_effect_executed).length;\n\nconst checks = [\n  ['five_fixtures', items.length === 5],\n  ['one_ready', outcomeCounts.ready === 1],\n  ['one_duplicate', outcomeCounts.duplicate === 1],\n  ['one_retry', outcomeCounts.retry === 1],\n  ['two_review', outcomeCounts.review === 2],\n  ['zero_side_effects', sideEffectsExecuted === 0],\n  ['zero_external_actions', externalActions === 0 && duplicateEffects === 0]\n];\nconst failed = checks.filter(([, passed]) => !passed).map(([name]) => name);\nif (failed.length > 0) throw new Error(`Invariant failure: ${failed.join(', ')}`);\n\nreturn [{\n  json: {\n    workflow: 'Test workflow reliability with deterministic fixtures',\n    result: 'pass',\n    runtime: 'n8n',\n    fixture_count: items.length,\n    outcome_counts: outcomeCounts,\n    assertion_count: checks.length,\n    duplicate_effects: duplicateEffects,\n    side_effects_executed: sideEffectsExecuted,\n    external_actions: externalActions,\n    execution_capability: 'none'\n  }\n}];"
      },
      "id": "fd461f93-5479-4cc8-9a69-3769c111d105",
      "name": "Verify Seven Invariants",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1360,
        660
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "Run Reliability Fixtures": {
      "main": [
        [
          {
            "node": "Seed Five Fixtures",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Seed Five Fixtures": {
      "main": [
        [
          {
            "node": "Validate Dedupe and Route",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Dedupe and Route": {
      "main": [
        [
          {
            "node": "Plan Safe Actions Only",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Plan Safe Actions Only": {
      "main": [
        [
          {
            "node": "Verify Seven Invariants",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}
