{
  "about": "REFERRALS.md 2.0 test vectors: inputs and the exact outputs the referrals.md code returns. Rebuild with npm run vectors; a test checks this file against the code and against /referrals.mjs. Every input is made up. Formulas: https://referrals.md/scoring.md",
  "format_version": 2,
  "ids": {
    "canonical_json": {
      "input": {
        "b": [
          2,
          1
        ],
        "a": {
          "d": null,
          "c": "x"
        }
      },
      "output": "{\"a\":{\"c\":\"x\",\"d\":null},\"b\":[2,1]}"
    },
    "sha256_hex": {
      "input": "referrals",
      "output": "a6ba8d504c4b9320a03ba8cec1ae743153e8fec9ae7077d3b8c9717c5cbc29f5"
    },
    "referral_id": {
      "formula": "rp_ + the first 16 hex of sha256(canonical JSON of {need, from, to, date})",
      "input": {
        "need": {
          "category": "renovation",
          "summary": "kitchen remodel",
          "budget": {
            "min": 30000,
            "max": 60000
          },
          "where": "example-city",
          "by": "2027-01-31",
          "requirements": [
            "kitchen",
            "permits"
          ]
        },
        "from": "buyers-agent-mj",
        "to": "gc-bn",
        "date": "2026-10-23"
      },
      "output": "rp_30705f2449263459"
    },
    "message_id": {
      "formula": "rm_ + the first 16 hex of sha256(canonical JSON of the message without id)",
      "input": {
        "format_version": 2,
        "type": "ask",
        "from": "buyer-dk",
        "to": "buyers-agent-mj",
        "created": "2026-10-20T00:00:00Z",
        "body": {
          "need": {
            "category": "renovation",
            "where": "example-city",
            "requirements": [
              "kitchen",
              "permits"
            ],
            "privacy": "limited",
            "urgency": "low"
          },
          "reply_by": "2026-10-27"
        }
      },
      "output": "rm_dd5f542c6f153c45"
    },
    "profile_txt_record": {
      "input": "---\nreferrals: 2\nkind: profile\nupdated: 2026-10-22\n---\n\n## Profile\n- id: gc-bn\n- kind: org\n- disclosure: none\n",
      "output": "v=referrals2; sha256=49a8ee797fa0c0764eb2afe85359a74039edc29e5a1129b0a261bd6deba36c1b"
    }
  },
  "contact_hashes": [
    {
      "input": " Buyer.DK@Example.com ",
      "normalized": "buyer.dk@example.com",
      "output": "h:fabc5ac80882201834ffacc530ae6453533a54444548b251920774a1160cedbe",
      "via": "email",
      "email_hash": "h:fabc5ac80882201834ffacc530ae6453533a54444548b251920774a1160cedbe",
      "phone_hash": null
    },
    {
      "input": "+1 (555) 010-0199",
      "normalized": "+15550100199",
      "output": "h:82fea6c5f54083ef6e2302f364430f7ca4e0daa597c74c81d61db3aa7bef6436",
      "via": "phone",
      "email_hash": null,
      "phone_hash": "h:82fea6c5f54083ef6e2302f364430f7ca4e0daa597c74c81d61db3aa7bef6436"
    },
    {
      "input": "0044 20 7946 0958",
      "normalized": null,
      "output": null,
      "via": "phone",
      "email_hash": null,
      "phone_hash": null
    },
    {
      "input": "not a contact",
      "normalized": null,
      "output": null,
      "via": "phone",
      "email_hash": null,
      "phone_hash": null
    }
  ],
  "tie_strength": {
    "input": {
      "connections": [
        {
          "a": "buyers-agent-mj",
          "b": "inspector-tp",
          "context": "colleague",
          "since": "2021-05-10",
          "last": "2026-10-15",
          "interactions": 22,
          "initiated_by_a": 15,
          "initiated_by_b": 7
        },
        {
          "a": "architect-pf",
          "b": "gc-bn",
          "context": "partner",
          "since": "2020-01-15",
          "last": "2026-10-10",
          "interactions": 31
        },
        {
          "a": "buyers-agent-mj",
          "b": "gc-bn",
          "context": "met",
          "since": "2026-10-01",
          "last": "2026-10-16",
          "interactions": 3,
          "initiated_by_a": 1,
          "initiated_by_b": 2
        }
      ],
      "as_of": "2026-10-22"
    },
    "output": [
      {
        "a": "buyers-agent-mj",
        "b": "inspector-tp",
        "strength": 0.7673,
        "parts": {
          "recency": {
            "value": 0.9734,
            "weight": 0.3,
            "points": 0.292
          },
          "frequency": {
            "value": 0.6794,
            "weight": 0.25,
            "points": 0.1698
          },
          "duration": {
            "value": 0.5451,
            "weight": 0.15,
            "points": 0.0818
          },
          "reciprocity": {
            "value": 0.6364,
            "weight": 0.1,
            "points": 0.0636
          },
          "context": {
            "value": 0.8,
            "weight": 0.2,
            "points": 0.16
          }
        }
      },
      {
        "a": "architect-pf",
        "b": "gc-bn",
        "strength": 0.7557,
        "parts": {
          "recency": {
            "value": 0.9548,
            "weight": 0.3,
            "points": 0.2865
          },
          "frequency": {
            "value": 0.751,
            "weight": 0.25,
            "points": 0.1877
          },
          "duration": {
            "value": 0.6768,
            "weight": 0.15,
            "points": 0.1015
          },
          "reciprocity": {
            "value": 0,
            "weight": 0.1,
            "points": 0
          },
          "context": {
            "value": 0.9,
            "weight": 0.2,
            "points": 0.18
          }
        }
      },
      {
        "a": "buyers-agent-mj",
        "b": "gc-bn",
        "strength": 0.4958,
        "parts": {
          "recency": {
            "value": 0.9772,
            "weight": 0.3,
            "points": 0.2931
          },
          "frequency": {
            "value": 0.3004,
            "weight": 0.25,
            "points": 0.0751
          },
          "duration": {
            "value": 0.0057,
            "weight": 0.15,
            "points": 0.0009
          },
          "reciprocity": {
            "value": 0.6667,
            "weight": 0.1,
            "points": 0.0667
          },
          "context": {
            "value": 0.3,
            "weight": 0.2,
            "points": 0.06
          }
        }
      }
    ]
  },
  "path_strength": {
    "formula": "path_strength = the product of the tie strengths along the path, rounded to 4",
    "input": {
      "records": "the find_helpers input below"
    },
    "output": [
      {
        "path": [
          "buyer-dk",
          "buyers-agent-mj",
          "architect-pf",
          "gc-bn"
        ],
        "ties": [
          0.7119,
          0.8658,
          0.8525
        ],
        "path_strength": 0.5254
      },
      {
        "path": [
          "buyer-dk",
          "buyers-agent-mj",
          "gc-bn"
        ],
        "ties": [
          0.7119,
          0.4958
        ],
        "path_strength": 0.353
      },
      {
        "path": [
          "buyer-dk",
          "accountant-ra",
          "contractor-kc"
        ],
        "ties": [
          0.5915,
          0.8883
        ],
        "path_strength": 0.5254
      },
      {
        "path": [
          "buyer-dk",
          "remodeler-rm"
        ],
        "ties": [
          0.2847
        ],
        "path_strength": 0.2847
      }
    ]
  },
  "helper_ranking": {
    "input": {
      "need": {
        "id": "kitchen-dk",
        "by": "buyer-dk",
        "category": "renovation",
        "summary": "kitchen remodel",
        "budget": "30000-60000",
        "where": "example-city",
        "by_date": "2027-01-31",
        "requirements": "kitchen, permits"
      },
      "parties": [
        {
          "id": "buyer-dk",
          "kind": "person"
        },
        {
          "id": "buyers-agent-mj",
          "kind": "person"
        },
        {
          "id": "architect-pf",
          "kind": "person"
        },
        {
          "id": "accountant-ra",
          "kind": "person"
        },
        {
          "id": "gc-bn",
          "kind": "org"
        },
        {
          "id": "contractor-kc",
          "kind": "person"
        },
        {
          "id": "remodeler-rm",
          "kind": "person"
        },
        {
          "id": "gc-xy",
          "kind": "org",
          "do_not_refer": "yes"
        }
      ],
      "haves": [
        {
          "id": "reno-bn",
          "by": "gc-bn",
          "category": "renovation",
          "tags": "kitchen, permits",
          "areas": "example-city",
          "capacity": 3,
          "load": 2,
          "available": "yes",
          "budget": "20000-250000"
        },
        {
          "id": "reno-kc",
          "by": "contractor-kc",
          "category": "renovation",
          "tags": "kitchen",
          "areas": "example-city",
          "capacity": 4,
          "load": 2,
          "available": "yes",
          "budget": "15000-80000"
        },
        {
          "id": "reno-rm",
          "by": "remodeler-rm",
          "category": "renovation",
          "tags": "kitchen, permits",
          "areas": "example-city",
          "capacity": 4,
          "load": 3,
          "available": "limited",
          "budget": "25000-70000"
        },
        {
          "id": "reno-xy",
          "by": "gc-xy",
          "category": "renovation",
          "tags": "kitchen, permits",
          "areas": "example-city",
          "capacity": 5,
          "load": 1,
          "available": "yes"
        }
      ],
      "connections": [
        {
          "a": "buyer-dk",
          "b": "buyers-agent-mj",
          "context": "vendor",
          "since": "2026-08-01",
          "last": "2026-10-20",
          "interactions": 26,
          "initiated_by_a": 12,
          "initiated_by_b": 14
        },
        {
          "a": "buyers-agent-mj",
          "b": "architect-pf",
          "context": "friend",
          "since": "2012-04-01",
          "last": "2026-08-30",
          "interactions": 40,
          "initiated_by_a": 22,
          "initiated_by_b": 18
        },
        {
          "a": "architect-pf",
          "b": "gc-bn",
          "context": "partner",
          "since": "2020-01-15",
          "last": "2026-10-10",
          "interactions": 31,
          "initiated_by_a": 15,
          "initiated_by_b": 16,
          "vouches": "renovation"
        },
        {
          "a": "buyers-agent-mj",
          "b": "gc-bn",
          "context": "met",
          "since": "2026-10-01",
          "last": "2026-10-16",
          "interactions": 3,
          "initiated_by_a": 1,
          "initiated_by_b": 2
        },
        {
          "a": "buyer-dk",
          "b": "accountant-ra",
          "context": "vendor",
          "since": "2019-02-01",
          "last": "2026-04-15",
          "interactions": 9,
          "initiated_by_a": 3,
          "initiated_by_b": 6
        },
        {
          "a": "accountant-ra",
          "b": "contractor-kc",
          "context": "client",
          "since": "2017-03-01",
          "last": "2026-10-05",
          "interactions": 60,
          "initiated_by_a": 30,
          "initiated_by_b": 30
        },
        {
          "a": "buyer-dk",
          "b": "remodeler-rm",
          "context": "met",
          "since": "2026-06-14",
          "last": "2026-06-14",
          "interactions": 1,
          "initiated_by_a": 1,
          "initiated_by_b": 0
        },
        {
          "a": "buyer-dk",
          "b": "gc-xy",
          "context": "met",
          "since": "2026-05-02",
          "last": "2026-05-02",
          "interactions": 1,
          "initiated_by_a": 0,
          "initiated_by_b": 1
        }
      ],
      "needs": [
        {
          "id": "mortgage-dk",
          "by": "buyer-dk",
          "category": "mortgage-lending"
        },
        {
          "id": "inspection-dk",
          "by": "buyer-dk",
          "category": "home-inspection"
        },
        {
          "id": "addition-so",
          "by": "planner-so",
          "category": "renovation"
        },
        {
          "id": "books-kc",
          "by": "contractor-kc",
          "category": "bookkeeping"
        }
      ],
      "referrals": [
        {
          "id": "ref-mortgage-dk",
          "need": "mortgage-dk",
          "from": "buyers-agent-mj",
          "to": "lender-rs",
          "date": "2026-08-20",
          "status": "closed",
          "outcome": 5
        },
        {
          "id": "ref-inspection-dk",
          "need": "inspection-dk",
          "from": "buyers-agent-mj",
          "to": "inspector-tp",
          "date": "2026-10-14",
          "status": "completed",
          "outcome": 4
        },
        {
          "id": "ref-addition-so",
          "need": "addition-so",
          "from": "architect-pf",
          "to": "gc-bn",
          "date": "2026-03-10",
          "status": "completed",
          "outcome": 5
        },
        {
          "id": "ref-books-kc",
          "need": "books-kc",
          "from": "accountant-ra",
          "to": "bookkeeper-jt",
          "date": "2026-04-02",
          "status": "declined"
        }
      ],
      "as_of": "2026-10-22",
      "max_hops": 3
    },
    "output": {
      "results": [
        {
          "have": "reno-bn",
          "party": "gc-bn",
          "fit": 100,
          "fit_parts": {
            "category": 40,
            "requirements": 20,
            "area": 15,
            "room": 15,
            "budget": 10
          },
          "kind": "warm_path",
          "score": 43.58,
          "paths": [
            {
              "path": [
                "buyer-dk",
                "buyers-agent-mj",
                "architect-pf",
                "gc-bn"
              ],
              "path_strength": 0.5254,
              "referrer": {
                "party": "buyers-agent-mj",
                "score": 93.1,
                "confidence": 0.369,
                "factor": 0.8295
              },
              "route_score": 0.4358
            },
            {
              "path": [
                "buyer-dk",
                "buyers-agent-mj",
                "gc-bn"
              ],
              "path_strength": 0.353,
              "referrer": {
                "party": "buyers-agent-mj",
                "score": 93.1,
                "confidence": 0.369,
                "factor": 0.8295
              },
              "route_score": 0.2928
            }
          ]
        },
        {
          "have": "reno-kc",
          "party": "contractor-kc",
          "fit": 90,
          "fit_parts": {
            "category": 40,
            "requirements": 10,
            "area": 15,
            "room": 15,
            "budget": 10
          },
          "kind": "warm_path",
          "score": 33.9,
          "paths": [
            {
              "path": [
                "buyer-dk",
                "accountant-ra",
                "contractor-kc"
              ],
              "path_strength": 0.5254,
              "referrer": {
                "party": "accountant-ra",
                "score": 0,
                "confidence": 0.132,
                "factor": 0.717
              },
              "route_score": 0.3767
            }
          ]
        },
        {
          "have": "reno-rm",
          "party": "remodeler-rm",
          "fit": 92.5,
          "fit_parts": {
            "category": 40,
            "requirements": 20,
            "area": 15,
            "room": 7.5,
            "budget": 10
          },
          "kind": "direct",
          "score": 26.33,
          "paths": [
            {
              "path": [
                "buyer-dk",
                "remodeler-rm"
              ],
              "path_strength": 0.2847,
              "referrer": null,
              "route_score": 0.2847
            }
          ]
        }
      ],
      "excluded": [
        {
          "have": "reno-xy",
          "party": "gc-xy",
          "reason": "gc-xy asked not to be referred (do_not_refer)"
        }
      ]
    }
  },
  "referrer_score": {
    "input": {
      "referrals": [
        {
          "id": "ref-mortgage-dk",
          "need": "mortgage-dk",
          "from": "buyers-agent-mj",
          "to": "lender-rs",
          "date": "2026-08-20",
          "status": "closed",
          "outcome": 5
        },
        {
          "id": "ref-inspection-dk",
          "need": "inspection-dk",
          "from": "buyers-agent-mj",
          "to": "inspector-tp",
          "date": "2026-10-14",
          "status": "completed",
          "outcome": 4
        },
        {
          "id": "ref-addition-so",
          "need": "addition-so",
          "from": "architect-pf",
          "to": "gc-bn",
          "date": "2026-03-10",
          "status": "completed",
          "outcome": 5
        },
        {
          "id": "ref-books-kc",
          "need": "books-kc",
          "from": "accountant-ra",
          "to": "bookkeeper-jt",
          "date": "2026-04-02",
          "status": "declined"
        }
      ],
      "needs": [
        {
          "id": "mortgage-dk",
          "by": "buyer-dk",
          "category": "mortgage-lending"
        },
        {
          "id": "inspection-dk",
          "by": "buyer-dk",
          "category": "home-inspection"
        },
        {
          "id": "addition-so",
          "by": "planner-so",
          "category": "renovation"
        },
        {
          "id": "books-kc",
          "by": "contractor-kc",
          "category": "bookkeeping"
        }
      ],
      "party": "buyers-agent-mj",
      "as_of": "2026-10-22"
    },
    "output": {
      "score": 93.1,
      "band": "too_few",
      "confidence": 0.369,
      "n": 2,
      "n_effective": 1.754,
      "components": {
        "acceptance": {
          "rate": 1,
          "n": 2,
          "weight": 1
        },
        "completion": {
          "rate": 1,
          "n": 2,
          "weight": 1
        },
        "outcome": {
          "mean": 4.447,
          "scaled": 0.8618,
          "n": 2,
          "weight": 2
        }
      }
    }
  },
  "receiver_reliability": {
    "input": {
      "needs": [
        {
          "id": "kitchen-a",
          "by": "buyer-a",
          "category": "renovation"
        },
        {
          "id": "bath-b",
          "by": "owner-b",
          "category": "renovation"
        },
        {
          "id": "deck-c",
          "by": "owner-c",
          "category": "renovation"
        },
        {
          "id": "roof-d",
          "by": "owner-d",
          "category": "renovation"
        }
      ],
      "referrals": [
        {
          "id": "r1",
          "need": "kitchen-a",
          "from": "architect-pf",
          "to": "gc-bn",
          "date": "2026-04-01",
          "status": "completed",
          "outcome": 5
        },
        {
          "id": "r2",
          "need": "bath-b",
          "from": "architect-pf",
          "to": "gc-bn",
          "date": "2026-07-15",
          "status": "closed",
          "outcome": 4
        },
        {
          "id": "r3",
          "need": "deck-c",
          "from": "buyers-agent-mj",
          "to": "gc-bn",
          "date": "2026-09-01",
          "status": "declined"
        },
        {
          "id": "r4",
          "need": "roof-d",
          "from": "buyers-agent-mj",
          "to": "gc-bn",
          "date": "2026-10-20",
          "status": "introduced"
        }
      ],
      "party": "gc-bn",
      "as": "receiver",
      "as_of": "2026-10-22"
    },
    "output": {
      "score": 92.5,
      "band": "strong",
      "confidence": 0.395,
      "n": 3,
      "waiting": 1,
      "components": {
        "answer": {
          "rate": 1,
          "n": 3,
          "weight": 1
        },
        "completion": {
          "rate": 1,
          "n": 2,
          "weight": 1
        },
        "outcome": {
          "mean": 4.4,
          "scaled": 0.8501,
          "n": 2,
          "weight": 2
        }
      }
    }
  },
  "identity_strength": {
    "input": {
      "party": "firm-ak",
      "claims": [
        {
          "claim": "domain",
          "value": "example.net",
          "method": "dns",
          "by": "buyers-agent-mj",
          "on": "2026-10-16"
        },
        {
          "claim": "email",
          "value": "h:a4fdfd510b37caad84eadaad825d32dbdd66144d76cf60469e11cbd983ee9dc7",
          "method": "link",
          "by": "self",
          "on": "2026-09-01"
        },
        {
          "claim": "profile",
          "value": "https://example.net/team/ak",
          "method": "vouch",
          "by": "bookkeeper-jt",
          "on": "2024-03-01"
        }
      ],
      "as_of": "2026-10-22"
    },
    "output": {
      "score": 36.5,
      "level": "medium"
    }
  }
}
