{"abstract":"The same user+org context built in a different order buckets differently.","category":"Feature flag rollout bucketing","checks":8,"contract":"contexts maps kind -> key. Empty input or any empty key -> None. A context containing only the kind \"user\" is keyed by the bare user key. Otherwise join, over kinds in sorted order, kind + \":\" + escaped key with \":\", where escaping replaces \"%\" by \"%25\" and then \":\" by \"%3A\".","contract_signature":"contexts","evaluation_group":"w2-feature-flag-rollout-bucketing-multi-context-key","failed_approach":"Sorting kinds by their key values changes order when the values change.","family":"w2-feature-flag-rollout-bucketing-multi-context-key-kind-ordering","id":"FA-74136","implementations":{"attempt":{"sha256":"a8b0057d7dc4b7e5911f23d3971b3dc185ed50c4a3ad4bd00bc6e865fb01a238","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(contexts):\n    def esc(s):\n        return s.replace('%', '%25').replace(':', '%3A')\n    if not contexts or any(k == '' for k in contexts.values()):\n        return None\n    if list(contexts) == ['user']:\n        return contexts['user']\n    return ':'.join(kind + ':' + esc(contexts[kind]) for kind in sorted(contexts, key=contexts.get))\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('percent is escaped before colon', [{'org': 'a:b', 'user': '50%'}], 'org:a%3Ab:user:50%25'),\n  ('already escaped text is escaped again', [{'org': 'x%3Ay', 'user': 'bob'}], 'org:x%253Ay:user:bob'),\n  ('kinds are sorted regardless of insertion', [{'user': 'bob', 'org': 'acme'}], 'org:acme:user:bob'),\n  ('single non-user kind is prefixed', [{'org': 'acme'}], 'org:acme'),\n  ('single user kind stays bare with colon', [{'user': 'a:b'}], 'a:b'),\n  ('three kinds', [{'device': 'd1', 'app': 'z', 'user': 'bob'}], 'app:z:device:d1:user:bob'),\n  ('context sample 1', [{'device': '50%', 'user': 'z', 'app': 'a:b'}], 'app:a%3Ab:device:50%25:user:z'),\n  ('context sample 2', [{'device': 'acme', 'user': 'z', 'org': 'z'}], 'device:acme:org:z:user:z')],\n [('already escaped text is escaped again', [{'org': 'x%3Ay', 'user': 'bob'}], 'org:x%253Ay:user:bob'),\n  ('kinds are sorted regardless of insertion', [{'user': 'bob', 'org': 'acme'}], 'org:acme:user:bob'),\n  ('single non-user kind is prefixed', [{'org': 'acme'}], 'org:acme'),\n  ('single user kind stays bare with colon', [{'user': 'a:b'}], 'a:b'),\n  ('empty key is invalid', [{'org': 'acme', 'user': ''}], None),\n  ('three kinds', [{'device': 'd1', 'app': 'z', 'user': 'bob'}], 'app:z:device:d1:user:bob'),\n  ('context sample 7', [{'org': 'a:b', 'device': 'a:b', 'user': 'z'}], 'device:a%3Ab:org:a%3Ab:user:z'),\n  ('context sample 11', [{'org': 'x%3Ay', 'app': 'a:b', 'device': 'z'}], 'app:a%3Ab:device:z:org:x%253Ay')],\n [('kinds are sorted regardless of insertion', [{'user': 'bob', 'org': 'acme'}], 'org:acme:user:bob'),\n  ('single non-user kind is prefixed', [{'org': 'acme'}], 'org:acme'),\n  ('single user kind stays bare with colon', [{'user': 'a:b'}], 'a:b'),\n  ('empty key is invalid', [{'org': 'acme', 'user': ''}], None),\n  ('empty mapping is invalid', [{}], None),\n  ('context sample 11', [{'org': 'x%3Ay', 'app': 'a:b', 'device': 'z'}], 'app:a%3Ab:device:z:org:x%253Ay'),\n  ('context sample 31', [{'org': '50%', 'device': 'k:1%'}], 'device:k%3A1%25:org:50%25'),\n  ('context sample 32', [{'org': 'z', 'user': 'z', 'app': 'x%3Ay'}], 'app:x%253Ay:org:z:user:z')],\n [('percent is escaped before colon', [{'org': 'a:b', 'user': '50%'}], 'org:a%3Ab:user:50%25'),\n  ('single non-user kind is prefixed', [{'org': 'acme'}], 'org:acme'),\n  ('single user kind stays bare with colon', [{'user': 'a:b'}], 'a:b'),\n  ('empty key is invalid', [{'org': 'acme', 'user': ''}], None),\n  ('empty mapping is invalid', [{}], None),\n  ('three kinds', [{'device': 'd1', 'app': 'z', 'user': 'bob'}], 'app:z:device:d1:user:bob'),\n  ('context sample 16', [{'org': 'x%3Ay', 'app': 'z'}], 'app:z:org:x%253Ay'),\n  ('context sample 60', [{'user': 'z', 'device': 'k:1%', 'app': 'acme'}], 'app:acme:device:k%3A1%25:user:z')],\n [('percent is escaped before colon', [{'org': 'a:b', 'user': '50%'}], 'org:a%3Ab:user:50%25'),\n  ('single user kind stays bare with colon', [{'user': 'a:b'}], 'a:b'),\n  ('empty key is invalid', [{'org': 'acme', 'user': ''}], None),\n  ('empty mapping is invalid', [{}], None),\n  ('three kinds', [{'device': 'd1', 'app': 'z', 'user': 'bob'}], 'app:z:device:d1:user:bob'),\n  ('context sample 7', [{'org': 'a:b', 'device': 'a:b', 'user': 'z'}], 'device:a%3Ab:org:a%3Ab:user:z'),\n  ('context sample 21', [{'org': 'x%3Ay', 'app': 'z'}], 'app:z:org:x%253Ay'),\n  ('context sample 22', [{'org': 'x%3Ay'}], 'org:x%253Ay')]]\nfor label, args, expected in fixtures[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"8275bdf65faf74e244d21500957b83ab7ec831986c0a213b8dd9287df57ea75d","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(contexts):\n    def esc(s):\n        return s.replace('%', '%25').replace(':', '%3A')\n    if not contexts or any(k == '' for k in contexts.values()):\n        return None\n    if list(contexts) == ['user']:\n        return contexts['user']\n    return ':'.join(kind + ':' + esc(contexts[kind]) for kind in contexts)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('percent is escaped before colon', [{'org': 'a:b', 'user': '50%'}], 'org:a%3Ab:user:50%25'),\n  ('already escaped text is escaped again', [{'org': 'x%3Ay', 'user': 'bob'}], 'org:x%253Ay:user:bob'),\n  ('kinds are sorted regardless of insertion', [{'user': 'bob', 'org': 'acme'}], 'org:acme:user:bob'),\n  ('single non-user kind is prefixed', [{'org': 'acme'}], 'org:acme'),\n  ('single user kind stays bare with colon', [{'user': 'a:b'}], 'a:b'),\n  ('three kinds', [{'device': 'd1', 'app': 'z', 'user': 'bob'}], 'app:z:device:d1:user:bob'),\n  ('context sample 1', [{'device': '50%', 'user': 'z', 'app': 'a:b'}], 'app:a%3Ab:device:50%25:user:z'),\n  ('context sample 2', [{'device': 'acme', 'user': 'z', 'org': 'z'}], 'device:acme:org:z:user:z')],\n [('already escaped text is escaped again', [{'org': 'x%3Ay', 'user': 'bob'}], 'org:x%253Ay:user:bob'),\n  ('kinds are sorted regardless of insertion', [{'user': 'bob', 'org': 'acme'}], 'org:acme:user:bob'),\n  ('single non-user kind is prefixed', [{'org': 'acme'}], 'org:acme'),\n  ('single user kind stays bare with colon', [{'user': 'a:b'}], 'a:b'),\n  ('empty key is invalid', [{'org': 'acme', 'user': ''}], None),\n  ('three kinds', [{'device': 'd1', 'app': 'z', 'user': 'bob'}], 'app:z:device:d1:user:bob'),\n  ('context sample 7', [{'org': 'a:b', 'device': 'a:b', 'user': 'z'}], 'device:a%3Ab:org:a%3Ab:user:z'),\n  ('context sample 11', [{'org': 'x%3Ay', 'app': 'a:b', 'device': 'z'}], 'app:a%3Ab:device:z:org:x%253Ay')],\n [('kinds are sorted regardless of insertion', [{'user': 'bob', 'org': 'acme'}], 'org:acme:user:bob'),\n  ('single non-user kind is prefixed', [{'org': 'acme'}], 'org:acme'),\n  ('single user kind stays bare with colon', [{'user': 'a:b'}], 'a:b'),\n  ('empty key is invalid', [{'org': 'acme', 'user': ''}], None),\n  ('empty mapping is invalid', [{}], None),\n  ('context sample 11', [{'org': 'x%3Ay', 'app': 'a:b', 'device': 'z'}], 'app:a%3Ab:device:z:org:x%253Ay'),\n  ('context sample 31', [{'org': '50%', 'device': 'k:1%'}], 'device:k%3A1%25:org:50%25'),\n  ('context sample 32', [{'org': 'z', 'user': 'z', 'app': 'x%3Ay'}], 'app:x%253Ay:org:z:user:z')],\n [('percent is escaped before colon', [{'org': 'a:b', 'user': '50%'}], 'org:a%3Ab:user:50%25'),\n  ('single non-user kind is prefixed', [{'org': 'acme'}], 'org:acme'),\n  ('single user kind stays bare with colon', [{'user': 'a:b'}], 'a:b'),\n  ('empty key is invalid', [{'org': 'acme', 'user': ''}], None),\n  ('empty mapping is invalid', [{}], None),\n  ('three kinds', [{'device': 'd1', 'app': 'z', 'user': 'bob'}], 'app:z:device:d1:user:bob'),\n  ('context sample 16', [{'org': 'x%3Ay', 'app': 'z'}], 'app:z:org:x%253Ay'),\n  ('context sample 60', [{'user': 'z', 'device': 'k:1%', 'app': 'acme'}], 'app:acme:device:k%3A1%25:user:z')],\n [('percent is escaped before colon', [{'org': 'a:b', 'user': '50%'}], 'org:a%3Ab:user:50%25'),\n  ('single user kind stays bare with colon', [{'user': 'a:b'}], 'a:b'),\n  ('empty key is invalid', [{'org': 'acme', 'user': ''}], None),\n  ('empty mapping is invalid', [{}], None),\n  ('three kinds', [{'device': 'd1', 'app': 'z', 'user': 'bob'}], 'app:z:device:d1:user:bob'),\n  ('context sample 7', [{'org': 'a:b', 'device': 'a:b', 'user': 'z'}], 'device:a%3Ab:org:a%3Ab:user:z'),\n  ('context sample 21', [{'org': 'x%3Ay', 'app': 'z'}], 'app:z:org:x%253Ay'),\n  ('context sample 22', [{'org': 'x%3Ay'}], 'org:x%253Ay')]]\nfor label, args, expected in fixtures[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"A deterministic toy flag-evaluation model with a stipulated contract; it does not reproduce any vendor SDK byte for byte. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-feature-flag-rollout-bucketing-multi-context-key-kind-ordering","generated_at":"2026-09-29T14:48:53.902012+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Canonical context keys feed bucketing and caches; two spellings of one context split its traffic.","root_cause":"Kinds are joined in dictionary insertion order.","sha256":"ed7634806faf9abf9346236d20ed5494b70bca5927b4198d480e5f6b2c9f15d0","title":"Multi-context canonical key: Context kinds follow insertion order · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":38.461,"exit_code":1,"observations":[{"actual":"user:50%25:org:a%3Ab","check":"percent is escaped before colon","expected":"org:a%3Ab:user:50%25","passed":false},{"actual":"user:bob:org:x%253Ay","check":"already escaped text is escaped again","expected":"org:x%253Ay:user:bob","passed":false},{"actual":"org:acme:user:bob","check":"kinds are sorted regardless of insertion","expected":"org:acme:user:bob","passed":true},{"actual":"org:acme","check":"single non-user kind is prefixed","expected":"org:acme","passed":true},{"actual":"a:b","check":"single user kind stays bare with colon","expected":"a:b","passed":true},{"actual":"user:bob:device:d1:app:z","check":"three kinds","expected":"app:z:device:d1:user:bob","passed":false},{"actual":"device:50%25:app:a%3Ab:user:z","check":"context sample 1","expected":"app:a%3Ab:device:50%25:user:z","passed":false},{"actual":"device:acme:user:z:org:z","check":"context sample 2","expected":"device:acme:org:z:user:z","passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"percent is escaped before colon\", \"actual\": \"user:50%25:org:a%3Ab\", \"expected\": \"org:a%3Ab:user:50%25\", \"passed\": false}, {\"check\": \"already escaped text is escaped again\", \"actual\": \"user:bob:org:x%253Ay\", \"expected\": \"org:x%253Ay:user:bob\", \"passed\": false}, {\"check\": \"kinds are sorted regardless of insertion\", \"actual\": \"org:acme:user:bob\", \"expected\": \"org:acme:user:bob\", \"passed\": true}, {\"check\": \"single non-user kind is prefixed\", \"actual\": \"org:acme\", \"expected\": \"org:acme\", \"passed\": true}, {\"check\": \"single user kind stays bare with colon\", \"actual\": \"a:b\", \"expected\": \"a:b\", \"passed\": true}, {\"check\": \"three kinds\", \"actual\": \"user:bob:device:d1:app:z\", \"expected\": \"app:z:device:d1:user:bob\", \"passed\": false}, {\"check\": \"context sample 1\", \"actual\": \"device:50%25:app:a%3Ab:user:z\", \"expected\": \"app:a%3Ab:device:50%25:user:z\", \"passed\": false}, {\"check\": \"context sample 2\", \"actual\": \"device:acme:user:z:org:z\", \"expected\": \"device:acme:org:z:user:z\", \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.112,"exit_code":1,"observations":[{"actual":"org:a%3Ab:user:50%25","check":"percent is escaped before colon","expected":"org:a%3Ab:user:50%25","passed":true},{"actual":"org:x%253Ay:user:bob","check":"already escaped text is escaped again","expected":"org:x%253Ay:user:bob","passed":true},{"actual":"user:bob:org:acme","check":"kinds are sorted regardless of insertion","expected":"org:acme:user:bob","passed":false},{"actual":"org:acme","check":"single non-user kind is prefixed","expected":"org:acme","passed":true},{"actual":"a:b","check":"single user kind stays bare with colon","expected":"a:b","passed":true},{"actual":"device:d1:app:z:user:bob","check":"three kinds","expected":"app:z:device:d1:user:bob","passed":false},{"actual":"device:50%25:user:z:app:a%3Ab","check":"context sample 1","expected":"app:a%3Ab:device:50%25:user:z","passed":false},{"actual":"device:acme:user:z:org:z","check":"context sample 2","expected":"device:acme:org:z:user:z","passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"percent is escaped before colon\", \"actual\": \"org:a%3Ab:user:50%25\", \"expected\": \"org:a%3Ab:user:50%25\", \"passed\": true}, {\"check\": \"already escaped text is escaped again\", \"actual\": \"org:x%253Ay:user:bob\", \"expected\": \"org:x%253Ay:user:bob\", \"passed\": true}, {\"check\": \"kinds are sorted regardless of insertion\", \"actual\": \"user:bob:org:acme\", \"expected\": \"org:acme:user:bob\", \"passed\": false}, {\"check\": \"single non-user kind is prefixed\", \"actual\": \"org:acme\", \"expected\": \"org:acme\", \"passed\": true}, {\"check\": \"single user kind stays bare with colon\", \"actual\": \"a:b\", \"expected\": \"a:b\", \"passed\": true}, {\"check\": \"three kinds\", \"actual\": \"device:d1:app:z:user:bob\", \"expected\": \"app:z:device:d1:user:bob\", \"passed\": false}, {\"check\": \"context sample 1\", \"actual\": \"device:50%25:user:z:app:a%3Ab\", \"expected\": \"app:a%3Ab:device:50%25:user:z\", \"passed\": false}, {\"check\": \"context sample 2\", \"actual\": \"device:acme:user:z:org:z\", \"expected\": \"device:acme:org:z:user:z\", \"passed\": false}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}