{"abstract":"A per-source limit lets one source contribute too many chunks.","category":"RAG context assembly","checks":6,"contract":"Chunks are [source,text]. Return rank-ordered chunks with no more than cap entries per source.","contract_signature":"chunks, cap","evaluation_group":"ragctx-source-cap","failed_approach":"A global row cap prevents overrepresented sources but underfills results when several sources qualify.","family":"w3-rag-context-assembly-per-source-cap","id":"FA-99546","implementations":{"attempt":{"sha256":"835b53dad29fcefea7ad3ef1feb8b377c55be06902b18bcd0fed5ec81dabee4c","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(chunks, cap):\n    out=[]; seen={}\n    for row in chunks:\n        if len(out)<cap: out.append(row)\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\na='A'+str(N); b='B'+str(N)\ncheck('interleaved sources', solve([[a,'1'],[a,'2'],[b,'3'],[a,'4']],1), [[a,'1'],[b,'3']])\ncheck('cap two', solve([[a,'1'],[a,'2'],[a,'3'],[b,'4']],2), [[a,'1'],[a,'2'],[b,'4']])\ncheck('zero cap', solve([[a,'x']],0), [])\ncheck('empty', solve([],N), [])\ncheck('distinct sources', solve([[a,'x'],[b,'y']],1), [[a,'x'],[b,'y']])\ncheck('one source below cap', solve([[a,'x']],3), [[a,'x']])\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":"527ff364fe4fa67e76c109702da2d1d3c8ced77efd0f08750f006b91ea00d86a","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(chunks, cap):\n    return chunks\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\na='A'+str(N); b='B'+str(N)\ncheck('interleaved sources', solve([[a,'1'],[a,'2'],[b,'3'],[a,'4']],1), [[a,'1'],[b,'3']])\ncheck('cap two', solve([[a,'1'],[a,'2'],[a,'3'],[b,'4']],2), [[a,'1'],[a,'2'],[b,'4']])\ncheck('zero cap', solve([[a,'x']],0), [])\ncheck('empty', solve([],N), [])\ncheck('distinct sources', solve([[a,'x'],[b,'y']],1), [[a,'x'],[b,'y']])\ncheck('one source below cap', solve([[a,'x']],3), [[a,'x']])\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":"Toy inputs and token counts only; this does not claim compatibility with a tokenizer, prompt format, or production retrieval system. 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":"w3-rag-context-assembly-per-source-cap","generated_at":"2026-09-30T16:48:25.348415+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"A small deterministic evidence assembly model makes context budgeting behavior inspectable.","root_cause":"The assembler applies no per-source quota and returns every candidate.","sha256":"e0af9f404571a60f4161d9dc384f2368f9ffc0a6ff8535ad6af69fe60344178e","title":"A per-source limit lets one source contribute too many chunks · case 01","variant":1,"variant_policy":"The fixture code references N, supplied as 1 through 5. Fixed boundary checks may repeat. These records share one mechanism and must remain together in evaluation splits.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":28.083,"exit_code":1,"observations":[{"actual":[["A1","1"]],"check":"interleaved sources","expected":[["A1","1"],["B1","3"]],"passed":false},{"actual":[["A1","1"],["A1","2"]],"check":"cap two","expected":[["A1","1"],["A1","2"],["B1","4"]],"passed":false},{"actual":[],"check":"zero cap","expected":[],"passed":true},{"actual":[],"check":"empty","expected":[],"passed":true},{"actual":[["A1","x"]],"check":"distinct sources","expected":[["A1","x"],["B1","y"]],"passed":false},{"actual":[["A1","x"]],"check":"one source below cap","expected":[["A1","x"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"interleaved sources\", \"actual\": [[\"A1\", \"1\"]], \"expected\": [[\"A1\", \"1\"], [\"B1\", \"3\"]], \"passed\": false}, {\"check\": \"cap two\", \"actual\": [[\"A1\", \"1\"], [\"A1\", \"2\"]], \"expected\": [[\"A1\", \"1\"], [\"A1\", \"2\"], [\"B1\", \"4\"]], \"passed\": false}, {\"check\": \"zero cap\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"empty\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"distinct sources\", \"actual\": [[\"A1\", \"x\"]], \"expected\": [[\"A1\", \"x\"], [\"B1\", \"y\"]], \"passed\": false}, {\"check\": \"one source below cap\", \"actual\": [[\"A1\", \"x\"]], \"expected\": [[\"A1\", \"x\"]], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":25.239,"exit_code":1,"observations":[{"actual":[["A1","1"],["A1","2"],["B1","3"],["A1","4"]],"check":"interleaved sources","expected":[["A1","1"],["B1","3"]],"passed":false},{"actual":[["A1","1"],["A1","2"],["A1","3"],["B1","4"]],"check":"cap two","expected":[["A1","1"],["A1","2"],["B1","4"]],"passed":false},{"actual":[["A1","x"]],"check":"zero cap","expected":[],"passed":false},{"actual":[],"check":"empty","expected":[],"passed":true},{"actual":[["A1","x"],["B1","y"]],"check":"distinct sources","expected":[["A1","x"],["B1","y"]],"passed":true},{"actual":[["A1","x"]],"check":"one source below cap","expected":[["A1","x"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"interleaved sources\", \"actual\": [[\"A1\", \"1\"], [\"A1\", \"2\"], [\"B1\", \"3\"], [\"A1\", \"4\"]], \"expected\": [[\"A1\", \"1\"], [\"B1\", \"3\"]], \"passed\": false}, {\"check\": \"cap two\", \"actual\": [[\"A1\", \"1\"], [\"A1\", \"2\"], [\"A1\", \"3\"], [\"B1\", \"4\"]], \"expected\": [[\"A1\", \"1\"], [\"A1\", \"2\"], [\"B1\", \"4\"]], \"passed\": false}, {\"check\": \"zero cap\", \"actual\": [[\"A1\", \"x\"]], \"expected\": [], \"passed\": false}, {\"check\": \"empty\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"distinct sources\", \"actual\": [[\"A1\", \"x\"], [\"B1\", \"y\"]], \"expected\": [[\"A1\", \"x\"], [\"B1\", \"y\"]], \"passed\": true}, {\"check\": \"one source below cap\", \"actual\": [[\"A1\", \"x\"]], \"expected\": [[\"A1\", \"x\"]], \"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."}}