{"task": {"agent_timeout": 3000, "task": "codegen__prometheus__prometheus-6555", "verifier_timeout": 3000, "instruction": "This is a code generation task. You are expected to write working code that solves the described problem.\n<issue>\n      ## Bug Report\n**What did you do?**\n\nRun this test case with `promtool test rules`.  This test case is isolated from a series that failed in our production Prometheus instance.\n\n```yaml\nevaluation_interval: 1m\ntests:\n  - interval: 1s\n    input_series:\n      - series: 'node_namespace_pod:kube_pod_info:{namespace=\"observability\",node=\"gke-search-infra-custom-96-253440-fli-d135b119-jx00\",pod=\"node-exporter-l454v\"}'\n        values: '1'\n      - series: 'node_cpu_seconds_total{cpu=\"10\",endpoint=\"https\",instance=\"10.253.57.87:9100\",job=\"node-exporter\",mode=\"idle\",namespace=\"observability\",pod=\"node-exporter-l454v\",service=\"node-exporter\"}'\n        values: '449'\n      - series: 'node_cpu_seconds_total{cpu=\"35\",endpoint=\"https\",instance=\"10.253.57.87:9100\",job=\"node-exporter\",mode=\"idle\",namespace=\"observability\",pod=\"node-exporter-l454v\",service=\"node-exporter\"}'\n        values: '449'\n      - series: 'node_cpu_seconds_total{cpu=\"89\",endpoint=\"https\",instance=\"10.253.57.87:9100\",job=\"node-exporter\",mode=\"idle\",namespace=\"observability\",pod=\"node-exporter-l454v\",service=\"node-exporter\"}'\n        values: '449'\n    promql_expr_test:\n      - expr: count by(namespace, pod, cpu) (node_cpu_seconds_total{cpu=~\".*\",job=\"node-exporter\",mode=\"idle\",namespace=\"observability\",pod=\"node-exporter-l454v\"}) * on(namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:{namespace=\"observability\",pod=\"node-exporter-l454v\"}\n        eval_time: 4s\n        exp_samples:\n          - labels: '{cpu=\"10\",namespace=\"observability\",node=\"gke-search-infra-custom-96-253440-fli-d135b119-jx00\",pod=\"node-exporter-l454v\"}'\n            value: 1\n          - labels: '{cpu=\"35\",namespace=\"observability\",node=\"gke-search-infra-custom-96-253440-fli-d135b119-jx00\",pod=\"node-exporter-l454v\"}'\n            value: 1\n          - labels: '{cpu=\"89\",namespace=\"observability\",node=\"gke-search-infra-custom-96-253440-fli-d135b119-jx00\",pod=\"node-exporter-l454v\"}'\n            value: 1\n```\n\n**What did you expect to see?**\n\nA success message, with the three output series correctly calculated.\n\n**What did you see instead? Under which circumstances?**\n\nA test failure:\n```\n  FAILED:\n    expr:'count by(namespace, pod, cpu) (node_cpu_seconds_total{cpu=~\".*\",job=\"node-exporter\",mode=\"idle\",namespace=\"observability\",pod=\"node-exporter-l454v\"}) * on(namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:{namespace=\"observability\",pod=\"node-exporter-l454v\"}', time:4s, err:multiple matches for labels: grouping labels must ensure unique matches\n```\n\n**Investigation**\n\nThis failure is due to a hash collision in the VectorBinop code in `engine.go`, discovered by @cristi- .  Specifically, combining the hashes of the LHS and RHS at [L1550](https://github.com/prometheus/prometheus/blob/851131b0740be7291b98f295567a97f32fffc655/promql/engine.go#L1550) results in a collision between two of the series in the test file, `cpu=\"35\"` and `cpu=\"89\"`.  Because the hashes collide there, the result metric is incorrectly reused for two series that are not identical, leading to VectorBinop incorrectly reporting non-unique matches.\n\nYou can see the hash-mixing function `(lh ^ rh) + lh` collide in isolation with this code ([playground](https://play.golang.org/p/YKRBZru5XHA)):\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n)\n\nfunc h(l, r uint64) uint64 {\n    return (l ^ r) + l\n}\n\nfunc main() {\n    fmt.Println(h(4717575973110797488, 6876917458372880354))\n    fmt.Println(h(9462489420336518194, 6876917458372880354))\n}\n```\n\nThis would be fixed with a different function for mixing hashes that better preserves entropy, or not combining hashes at all and using the calculated result hash throughout.\n\n**Environment**\n\n* System information: Linux 5.1.0-1.el7.elrepo.x86_64 x86_64\n* Prometheus version: reproduced on v2.8.1 and master (851131b0740be7291b98f295567a97f32fffc655)\n* Alertmanager version: n/a\n* Prometheus configuration file: n/a\n* Alertmanager configuration file: n/a\n* Logs: n/a\n\n</issue>\nFocus on implementing the required functionality correctly and efficiently. Treat this as a programming challenge.\nYou are not allowed to read git history.\n", "memory": "8192m", "runnable": false, "difficulty": "hard", "language": "", "cpus": "", "instruction_truncated": false, "category": "code-generation", "compose": false, "has_solution": true, "oracle": null, "docker_image": "", "taskset": "devopsgym", "tags": ["code-generation", "devops-bench"]}, "runs": []}