{
  "description": "Test vectors for edge-policy resolution via ResolveOptions.edgeResults",
  "bundle": "bundle_edge_policies.json",
  "entityWeights": "entity_weights.json",
  "testCases": [
    {
      "name": "entity_specific_weights",
      "comment": "prod-42 has entity-specific weights [0.7, 0.3]; seed hash random=0.3698 < 0.7 selects index 0 (variant_a)",
      "context": {
        "userId": "user-abc",
        "productId": "prod-42"
      },
      "defaults": {
        "ui.color": "#000000",
        "pricing.discount": 0,
        "selected.index": -1
      },
      "edgeResults": [
        {
          "policyId": "policy_edge_fixed",
          "allocationIndex": 0,
          "entityId": "prod-42"
        }
      ],
      "expectedAssignments": {
        "ui.color": "#0000FF",
        "pricing.discount": 10,
        "selected.index": -1
      },
      "expectedLayers": [
        {
          "layerId": "layer_standard",
          "bucket": 81,
          "policyId": "policy_standard",
          "allocationId": "alloc_control",
          "allocationName": "control"
        },
        {
          "layerId": "layer_edge_fixed",
          "bucket": 281,
          "policyId": "policy_edge_fixed",
          "allocationId": "alloc_variant_a",
          "allocationName": "variant_a"
        },
        {
          "layerId": "layer_edge_dynamic",
          "bucket": 302
        }
      ]
    },
    {
      "name": "entity_specific_prod99",
      "comment": "prod-99 has entity-specific weights [0.2, 0.8]; seed hash random=0.1233 < 0.2 selects index 0 (variant_a)",
      "context": {
        "userId": "user-abc",
        "productId": "prod-99"
      },
      "defaults": {
        "ui.color": "#000000",
        "pricing.discount": 0,
        "selected.index": -1
      },
      "edgeResults": [
        {
          "policyId": "policy_edge_fixed",
          "allocationIndex": 0,
          "entityId": "prod-99"
        }
      ],
      "expectedAssignments": {
        "ui.color": "#0000FF",
        "pricing.discount": 10,
        "selected.index": -1
      },
      "expectedLayers": [
        {
          "layerId": "layer_standard",
          "bucket": 81,
          "policyId": "policy_standard",
          "allocationId": "alloc_control",
          "allocationName": "control"
        },
        {
          "layerId": "layer_edge_fixed",
          "bucket": 281,
          "policyId": "policy_edge_fixed",
          "allocationId": "alloc_variant_a",
          "allocationName": "variant_a"
        },
        {
          "layerId": "layer_edge_dynamic",
          "bucket": 302
        }
      ]
    },
    {
      "name": "global_fallback_weights",
      "comment": "prod-new not in entities; uses global weights [0.5, 0.5]; seed hash random=0.3514 < 0.5 selects index 0 (variant_a)",
      "context": {
        "userId": "user-xyz",
        "productId": "prod-new"
      },
      "defaults": {
        "ui.color": "#000000",
        "pricing.discount": 0,
        "selected.index": -1
      },
      "edgeResults": [
        {
          "policyId": "policy_edge_fixed",
          "allocationIndex": 0,
          "entityId": "prod-new"
        }
      ],
      "expectedAssignments": {
        "ui.color": "#FF0000",
        "pricing.discount": 10,
        "selected.index": -1
      },
      "expectedLayers": [
        {
          "layerId": "layer_standard",
          "bucket": 688,
          "policyId": "policy_standard",
          "allocationId": "alloc_treatment",
          "allocationName": "treatment"
        },
        {
          "layerId": "layer_edge_fixed",
          "bucket": 314,
          "policyId": "policy_edge_fixed",
          "allocationId": "alloc_variant_a",
          "allocationName": "variant_a"
        },
        {
          "layerId": "layer_edge_dynamic",
          "bucket": 694
        }
      ]
    },
    {
      "name": "missing_entity_weights_uniform",
      "comment": "No entity weights in KV at all; uniform weights [0.5, 0.5]; seed hash for prod-42:user-123 random=0.0303 < 0.5 selects index 0 (variant_a)",
      "context": {
        "userId": "user-123",
        "productId": "prod-42"
      },
      "defaults": {
        "ui.color": "#000000",
        "pricing.discount": 0,
        "selected.index": -1
      },
      "edgeResults": [
        {
          "policyId": "policy_edge_fixed",
          "allocationIndex": 0,
          "entityId": "prod-42"
        }
      ],
      "expectedAssignments": {
        "ui.color": "#0000FF",
        "pricing.discount": 10,
        "selected.index": -1
      },
      "expectedLayers": [
        {
          "layerId": "layer_standard",
          "bucket": 287,
          "policyId": "policy_standard",
          "allocationId": "alloc_control",
          "allocationName": "control"
        },
        {
          "layerId": "layer_edge_fixed",
          "bucket": 1,
          "policyId": "policy_edge_fixed",
          "allocationId": "alloc_variant_a",
          "allocationName": "variant_a"
        },
        {
          "layerId": "layer_edge_dynamic",
          "bucket": 197
        }
      ]
    },
    {
      "name": "dynamic_allocation",
      "comment": "numVariants=4 triggers dynamic allocation; global weights [0.25x4]; seed hash random=0.0738 < 0.25 selects index 0",
      "context": {
        "userId": "user-abc",
        "productId": "prod-42",
        "numVariants": 4
      },
      "defaults": {
        "ui.color": "#000000",
        "pricing.discount": 0,
        "selected.index": -1
      },
      "edgeResults": [
        {
          "policyId": "policy_edge_fixed",
          "allocationIndex": 0,
          "entityId": "prod-42"
        },
        {
          "policyId": "policy_edge_dynamic",
          "allocationIndex": 0,
          "entityId": "prod-42"
        }
      ],
      "expectedAssignments": {
        "ui.color": "#0000FF",
        "pricing.discount": 10,
        "selected.index": -1
      },
      "expectedLayers": [
        {
          "layerId": "layer_standard",
          "bucket": 81,
          "policyId": "policy_standard",
          "allocationId": "alloc_control",
          "allocationName": "control"
        },
        {
          "layerId": "layer_edge_fixed",
          "bucket": 281,
          "policyId": "policy_edge_fixed",
          "allocationId": "alloc_variant_a",
          "allocationName": "variant_a"
        },
        {
          "layerId": "layer_edge_dynamic",
          "bucket": 302,
          "policyId": "policy_edge_dynamic",
          "allocationId": "policy_edge_dynamic_dynamic_0",
          "allocationName": "0"
        }
      ]
    },
    {
      "name": "mixed_standard_and_edge",
      "comment": "All three layers resolve; user-xyz in standard treatment (bucket 688), edge fixed variant_a (global weights), dynamic skipped (no numVariants)",
      "context": {
        "userId": "user-xyz",
        "productId": "prod-new"
      },
      "defaults": {
        "ui.color": "#000000",
        "pricing.discount": 0,
        "selected.index": -1
      },
      "edgeResults": [
        {
          "policyId": "policy_edge_fixed",
          "allocationIndex": 0,
          "entityId": "prod-new"
        }
      ],
      "expectedAssignments": {
        "ui.color": "#FF0000",
        "pricing.discount": 10,
        "selected.index": -1
      },
      "expectedLayers": [
        {
          "layerId": "layer_standard",
          "bucket": 688,
          "policyId": "policy_standard",
          "allocationId": "alloc_treatment",
          "allocationName": "treatment"
        },
        {
          "layerId": "layer_edge_fixed",
          "bucket": 314,
          "policyId": "policy_edge_fixed",
          "allocationId": "alloc_variant_a",
          "allocationName": "variant_a"
        },
        {
          "layerId": "layer_edge_dynamic",
          "bucket": 694
        }
      ]
    },
    {
      "name": "filtered_parameters_subset",
      "comment": "Only ui.color requested; edge policies still resolve in layer metadata but only standard override applied",
      "context": {
        "userId": "user-abc",
        "productId": "prod-42"
      },
      "defaults": {
        "ui.color": "#000000"
      },
      "edgeResults": [
        {
          "policyId": "policy_edge_fixed",
          "allocationIndex": 0,
          "entityId": "prod-42"
        }
      ],
      "expectedAssignments": {
        "ui.color": "#0000FF"
      },
      "expectedLayers": [
        {
          "layerId": "layer_standard",
          "bucket": 81,
          "policyId": "policy_standard",
          "allocationId": "alloc_control",
          "allocationName": "control"
        },
        {
          "layerId": "layer_edge_fixed",
          "bucket": 281,
          "policyId": "policy_edge_fixed",
          "allocationId": "alloc_variant_a",
          "allocationName": "variant_a",
          "attributionOnly": true
        },
        {
          "layerId": "layer_edge_dynamic",
          "bucket": 302,
          "attributionOnly": true
        }
      ]
    },
    {
      "name": "missing_entity_context_graceful_skip",
      "comment": "No productId in context; edge policies skipped, only standard layer resolves",
      "context": {
        "userId": "user-abc"
      },
      "defaults": {
        "ui.color": "#000000",
        "pricing.discount": 0,
        "selected.index": -1
      },
      "edgeResults": [],
      "expectedAssignments": {
        "ui.color": "#0000FF",
        "pricing.discount": 0,
        "selected.index": -1
      },
      "expectedLayers": [
        {
          "layerId": "layer_standard",
          "bucket": 81,
          "policyId": "policy_standard",
          "allocationId": "alloc_control",
          "allocationName": "control"
        },
        {
          "layerId": "layer_edge_fixed",
          "bucket": 281
        },
        {
          "layerId": "layer_edge_dynamic",
          "bucket": 302
        }
      ]
    }
  ]
}
