{"abstract":"An org-only context collides with a user whose key equals the org key.","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":"Using the bare key whenever a user kind is present collapses multi-kind contexts.","family":"w2-feature-flag-rollout-bucketing-multi-context-key-single-kind-shortcut","id":"FA-74141","implementations":{"attempt":{"sha256":"2cbd7c77ad1f85ccad5a606b424b3a0ea0fc8ddf8325cc0082184a3f0b77ffeb","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 'user' in contexts:\n        return contexts['user']\n    return ':'.join(kind + ':' + esc(contexts[kind]) for kind in sorted(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 4', [{'user': 'z', 'org': 'a:b'}], 'org:a%3Ab:user:z'),\n  ('context sample 33', [{'org': 'x%3Ay'}], '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 49', [{'device': 'x%3Ay', 'user': 'x%3Ay'}], 'device:x%253Ay:user:x%253Ay'),\n  ('context sample 59', [{'org': 'z'}], 'org:z')],\n [('already escaped text is escaped again', [{'org': 'x%3Ay', 'user': 'bob'}], 'org:x%253Ay: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  ('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 28', [{'app': 'acme'}], 'app:acme')],\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 55', [{'app': 'bob'}], 'app:bob')]]\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":"f552ff35f62cd41c18b124db92723ccb83c5cc07f4022c5d9879e96fd1254632","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 len(contexts) == 1:\n        return next(iter(contexts.values()))\n    return ':'.join(kind + ':' + esc(contexts[kind]) for kind in sorted(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 4', [{'user': 'z', 'org': 'a:b'}], 'org:a%3Ab:user:z'),\n  ('context sample 33', [{'org': 'x%3Ay'}], '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 49', [{'device': 'x%3Ay', 'user': 'x%3Ay'}], 'device:x%253Ay:user:x%253Ay'),\n  ('context sample 59', [{'org': 'z'}], 'org:z')],\n [('already escaped text is escaped again', [{'org': 'x%3Ay', 'user': 'bob'}], 'org:x%253Ay: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  ('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 28', [{'app': 'acme'}], 'app:acme')],\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 55', [{'app': 'bob'}], 'app:bob')]]\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-single-kind-shortcut","generated_at":"2026-09-29T14:48:53.902157+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":"The bare-key shortcut applies to any single context rather than only to the user kind.","sha256":"f7f00f72f32454d1778c836e1f251466a6b05872fc975f150e04ab9702789a0a","title":"Multi-context canonical key: Any single-kind context uses a bare key · 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.137,"exit_code":1,"observations":[{"actual":"50%","check":"percent is escaped before colon","expected":"org:a%3Ab:user:50%25","passed":false},{"actual":"bob","check":"already escaped text is escaped again","expected":"org:x%253Ay:user:bob","passed":false},{"actual":"bob","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":"bob","check":"three kinds","expected":"app:z:device:d1:user:bob","passed":false},{"actual":"z","check":"context sample 1","expected":"app:a%3Ab:device:50%25:user:z","passed":false},{"actual":"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\": \"50%\", \"expected\": \"org:a%3Ab:user:50%25\", \"passed\": false}, {\"check\": \"already escaped text is escaped again\", \"actual\": \"bob\", \"expected\": \"org:x%253Ay:user:bob\", \"passed\": false}, {\"check\": \"kinds are sorted regardless of insertion\", \"actual\": \"bob\", \"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\": \"bob\", \"expected\": \"app:z:device:d1:user:bob\", \"passed\": false}, {\"check\": \"context sample 1\", \"actual\": \"z\", \"expected\": \"app:a%3Ab:device:50%25:user:z\", \"passed\": false}, {\"check\": \"context sample 2\", \"actual\": \"z\", \"expected\": \"device:acme:org:z:user:z\", \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.326,"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":"org:acme:user:bob","check":"kinds are sorted regardless of insertion","expected":"org:acme:user:bob","passed":true},{"actual":"acme","check":"single non-user kind is prefixed","expected":"org:acme","passed":false},{"actual":"a:b","check":"single user kind stays bare with colon","expected":"a:b","passed":true},{"actual":"app:z:device:d1:user:bob","check":"three kinds","expected":"app:z:device:d1:user:bob","passed":true},{"actual":"app:a%3Ab:device:50%25:user:z","check":"context sample 1","expected":"app:a%3Ab:device:50%25:user:z","passed":true},{"actual":"device:acme:org:z:user:z","check":"context sample 2","expected":"device:acme:org:z:user:z","passed":true}],"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\": \"org:acme:user:bob\", \"expected\": \"org:acme:user:bob\", \"passed\": true}, {\"check\": \"single non-user kind is prefixed\", \"actual\": \"acme\", \"expected\": \"org:acme\", \"passed\": false}, {\"check\": \"single user kind stays bare with colon\", \"actual\": \"a:b\", \"expected\": \"a:b\", \"passed\": true}, {\"check\": \"three kinds\", \"actual\": \"app:z:device:d1:user:bob\", \"expected\": \"app:z:device:d1:user:bob\", \"passed\": true}, {\"check\": \"context sample 1\", \"actual\": \"app:a%3Ab:device:50%25:user:z\", \"expected\": \"app:a%3Ab:device:50%25:user:z\", \"passed\": true}, {\"check\": \"context sample 2\", \"actual\": \"device:acme:org:z:user:z\", \"expected\": \"device:acme:org:z:user:z\", \"passed\": true}], \"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."}}