{
  "name": "Taifoon \u00b7 find unchecked agent work",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      },
      "id": "sched",
      "name": "Every 15 minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://www.taifoon.io/v1/agents/ledger",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "state",
              "value": "completed"
            },
            {
              "name": "verify",
              "value": "self"
            },
            {
              "name": "limit",
              "value": "25"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "neverError": false
            }
          }
        }
      },
      "id": "ledger",
      "name": "Completed work graded only by the buyer",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "jobs",
        "options": {}
      },
      "id": "split",
      "name": "One item per job",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "url": "=https://www.taifoon.io/v1/agents/who/{{ $json.provider }}",
        "options": {}
      },
      "id": "who",
      "name": "What is known about the provider",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "version": 2
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c1",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.as_provider.jobs }}",
              "rightValue": 3
            },
            {
              "id": "c2",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.as_provider.checked_by_third_party }}",
              "rightValue": 0
            }
          ]
        },
        "options": {}
      },
      "id": "worth",
      "name": "Sold repeatedly, never independently checked",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        880,
        0
      ]
    },
    {
      "parameters": {
        "url": "={{ $('One item per job').item.json.v5_proof }}",
        "options": {}
      },
      "id": "proof",
      "name": "Fetch the evidence",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1100,
        -80
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "jobId",
              "value": "={{ $('One item per job').item.json.jobId }}",
              "type": "string"
            },
            {
              "id": "a2",
              "name": "provider",
              "value": "={{ $('One item per job').item.json.provider }}",
              "type": "string"
            },
            {
              "id": "a3",
              "name": "sold",
              "value": "={{ $('What is known about the provider').item.json.as_provider.jobs }}",
              "type": "number"
            },
            {
              "id": "a4",
              "name": "everChecked",
              "value": "={{ $('What is known about the provider').item.json.as_provider.checked_by_third_party }}",
              "type": "number"
            },
            {
              "id": "a5",
              "name": "evidenceRoot",
              "value": "={{ $json.superroot ? $json.superroot.superrootHash : null }}",
              "type": "string"
            },
            {
              "id": "a6",
              "name": "whyItMatters",
              "value": "This job was graded by the buyer alone. The evidence is public, so the grade can be recomputed rather than trusted.",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "candidate",
      "name": "A candidate worth verifying",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1320,
        -80
      ]
    }
  ],
  "connections": {
    "Every 15 minutes": {
      "main": [
        [
          {
            "node": "Completed work graded only by the buyer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed work graded only by the buyer": {
      "main": [
        [
          {
            "node": "One item per job",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "One item per job": {
      "main": [
        [
          {
            "node": "What is known about the provider",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "What is known about the provider": {
      "main": [
        [
          {
            "node": "Sold repeatedly, never independently checked",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sold repeatedly, never independently checked": {
      "main": [
        [
          {
            "node": "Fetch the evidence",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Fetch the evidence": {
      "main": [
        [
          {
            "node": "A candidate worth verifying",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "description": "Reads the Taifoon coordination layer to find agent work that completed with only the buyer's own grade, checks what is known about the provider, and pulls the public evidence so the grade can be recomputed. Read-only: no keys, no signer, no writes."
  }
}
