release v1: 65 held-out tasks, 78 bootstrap records, r2e_local adapter, manifest ae94c40b (part 2)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- heldout/RDFLib__rdflib-2be67dca9f5d/tests/test.sh +294 -0
- heldout/RDFLib__rdflib-2be67dca9f5d/tests/verifier.py +475 -0
- heldout/RDFLib__rdflib-49afac8c15ce/environment/Dockerfile +36 -0
- heldout/RDFLib__rdflib-49afac8c15ce/environment/docker-compose.yaml +16 -0
- heldout/RDFLib__rdflib-49afac8c15ce/instruction.md +12 -0
- heldout/RDFLib__rdflib-49afac8c15ce/solution/patch.diff +71 -0
- heldout/RDFLib__rdflib-49afac8c15ce/solution/solve.sh +6 -0
- heldout/RDFLib__rdflib-49afac8c15ce/task.toml +75 -0
- heldout/RDFLib__rdflib-49afac8c15ce/tests/f2p.json +4 -0
- heldout/RDFLib__rdflib-49afac8c15ce/tests/p2p.json +1 -0
- heldout/RDFLib__rdflib-49afac8c15ce/tests/test.sh +63 -0
- heldout/RDFLib__rdflib-49afac8c15ce/tests/verifier.py +475 -0
- heldout/RDFLib__rdflib-607e086b11a9/environment/Dockerfile +36 -0
- heldout/RDFLib__rdflib-607e086b11a9/environment/docker-compose.yaml +16 -0
- heldout/RDFLib__rdflib-607e086b11a9/instruction.md +10 -0
- heldout/RDFLib__rdflib-607e086b11a9/solution/patch.diff +109 -0
- heldout/RDFLib__rdflib-607e086b11a9/solution/solve.sh +6 -0
- heldout/RDFLib__rdflib-607e086b11a9/task.toml +78 -0
- heldout/RDFLib__rdflib-607e086b11a9/tests/f2p.json +7 -0
- heldout/RDFLib__rdflib-607e086b11a9/tests/p2p.json +1 -0
- heldout/RDFLib__rdflib-607e086b11a9/tests/test.sh +129 -0
- heldout/RDFLib__rdflib-607e086b11a9/tests/verifier.py +475 -0
- heldout/RDFLib__rdflib-72287e45ad1a/environment/Dockerfile +36 -0
- heldout/RDFLib__rdflib-72287e45ad1a/environment/docker-compose.yaml +16 -0
- heldout/RDFLib__rdflib-72287e45ad1a/instruction.md +14 -0
- heldout/RDFLib__rdflib-72287e45ad1a/solution/patch.diff +63 -0
- heldout/RDFLib__rdflib-72287e45ad1a/solution/solve.sh +6 -0
- heldout/RDFLib__rdflib-72287e45ad1a/task.toml +100 -0
- heldout/RDFLib__rdflib-72287e45ad1a/tests/f2p.json +4 -0
- heldout/RDFLib__rdflib-72287e45ad1a/tests/p2p.json +26 -0
- heldout/RDFLib__rdflib-72287e45ad1a/tests/test.sh +123 -0
- heldout/RDFLib__rdflib-72287e45ad1a/tests/verifier.py +475 -0
- heldout/RDFLib__rdflib-8685a85503c1/environment/Dockerfile +36 -0
- heldout/RDFLib__rdflib-8685a85503c1/environment/docker-compose.yaml +16 -0
- heldout/RDFLib__rdflib-8685a85503c1/instruction.md +10 -0
- heldout/RDFLib__rdflib-8685a85503c1/solution/patch.diff +13 -0
- heldout/RDFLib__rdflib-8685a85503c1/solution/solve.sh +6 -0
- heldout/RDFLib__rdflib-8685a85503c1/task.toml +77 -0
- heldout/RDFLib__rdflib-8685a85503c1/tests/f2p.json +3 -0
- heldout/RDFLib__rdflib-8685a85503c1/tests/p2p.json +4 -0
- heldout/RDFLib__rdflib-8685a85503c1/tests/test.sh +48 -0
- heldout/RDFLib__rdflib-8685a85503c1/tests/verifier.py +475 -0
- heldout/RDFLib__rdflib-b3e60e79c9b0/environment/Dockerfile +36 -0
- heldout/RDFLib__rdflib-b3e60e79c9b0/environment/docker-compose.yaml +16 -0
- heldout/RDFLib__rdflib-b3e60e79c9b0/instruction.md +10 -0
- heldout/RDFLib__rdflib-b3e60e79c9b0/solution/patch.diff +13 -0
- heldout/RDFLib__rdflib-b3e60e79c9b0/solution/solve.sh +6 -0
- heldout/RDFLib__rdflib-b3e60e79c9b0/task.toml +116 -0
- heldout/RDFLib__rdflib-b3e60e79c9b0/tests/f2p.json +7 -0
- heldout/RDFLib__rdflib-b3e60e79c9b0/tests/p2p.json +39 -0
heldout/RDFLib__rdflib-2be67dca9f5d/tests/test.sh
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -uxo pipefail
|
| 3 |
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
| 4 |
+
cd /workspace
|
| 5 |
+
git config --global --add safe.directory /workspace
|
| 6 |
+
mkdir -p /logs/verifier
|
| 7 |
+
git checkout 6539dfef42c5b853ccab41c046772a8e0c8e1658 -- test/test_sparql/test_expressions.py test/test_sparql/test_tsvresults.py || true
|
| 8 |
+
git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH'
|
| 9 |
+
diff --git a/test/test_sparql/test_expressions.py b/test/test_sparql/test_expressions.py
|
| 10 |
+
index 200c6854..cee2fb6e 100644
|
| 11 |
+
--- a/test/test_sparql/test_expressions.py
|
| 12 |
+
+++ b/test/test_sparql/test_expressions.py
|
| 13 |
+
@@ -26,119 +26,121 @@ def _translate(e):
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def test_regex():
|
| 17 |
+
- assert _eval(_translate(p.Expression.parseString('REGEX("zxcabczxc","abc")')[0]))
|
| 18 |
+
+ assert _eval(_translate(p.Expression.parse_string('REGEX("zxcabczxc","abc")')[0]))
|
| 19 |
+
|
| 20 |
+
eq(
|
| 21 |
+
- bool(_eval(_translate(p.Expression.parseString('REGEX("zxczxc","abc")')[0]))),
|
| 22 |
+
+ bool(_eval(_translate(p.Expression.parse_string('REGEX("zxczxc","abc")')[0]))),
|
| 23 |
+
False,
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
- assert _eval(_translate(p.Expression.parseString('REGEX("bbbaaaaabbb","ba*b")')[0]))
|
| 27 |
+
+ assert _eval(
|
| 28 |
+
+ _translate(p.Expression.parse_string('REGEX("bbbaaaaabbb","ba*b")')[0])
|
| 29 |
+
+ )
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def test_arithmetic():
|
| 33 |
+
- eq(_eval(_translate(p.Expression.parseString("2+3")[0])).value, 5)
|
| 34 |
+
- eq(_eval(_translate(p.Expression.parseString("3-2")[0])).value, 1)
|
| 35 |
+
+ eq(_eval(_translate(p.Expression.parse_string("2+3")[0])).value, 5)
|
| 36 |
+
+ eq(_eval(_translate(p.Expression.parse_string("3-2")[0])).value, 1)
|
| 37 |
+
|
| 38 |
+
- eq(_eval(_translate(p.Expression.parseString("2*3")[0])).value, 6)
|
| 39 |
+
- eq(_eval(_translate(p.Expression.parseString("4/2")[0])).value, 2)
|
| 40 |
+
+ eq(_eval(_translate(p.Expression.parse_string("2*3")[0])).value, 6)
|
| 41 |
+
+ eq(_eval(_translate(p.Expression.parse_string("4/2")[0])).value, 2)
|
| 42 |
+
|
| 43 |
+
- eq(_eval(_translate(p.Expression.parseString("2+2+2")[0])).value, 6)
|
| 44 |
+
- eq(_eval(_translate(p.Expression.parseString("2-2+2")[0])).value, 2)
|
| 45 |
+
- eq(_eval(_translate(p.Expression.parseString("(2-2)+2")[0])).value, 2)
|
| 46 |
+
- eq(_eval(_translate(p.Expression.parseString("2-(2+2)")[0])).value, -2)
|
| 47 |
+
+ eq(_eval(_translate(p.Expression.parse_string("2+2+2")[0])).value, 6)
|
| 48 |
+
+ eq(_eval(_translate(p.Expression.parse_string("2-2+2")[0])).value, 2)
|
| 49 |
+
+ eq(_eval(_translate(p.Expression.parse_string("(2-2)+2")[0])).value, 2)
|
| 50 |
+
+ eq(_eval(_translate(p.Expression.parse_string("2-(2+2)")[0])).value, -2)
|
| 51 |
+
|
| 52 |
+
- eq(_eval(_translate(p.Expression.parseString("2*2*2")[0])).value, 8)
|
| 53 |
+
- eq(_eval(_translate(p.Expression.parseString("4/2*2")[0])).value, 4)
|
| 54 |
+
- eq(_eval(_translate(p.Expression.parseString("8/4*2")[0])).value, 4)
|
| 55 |
+
- eq(_eval(_translate(p.Expression.parseString("8/(4*2)")[0])).value, 1)
|
| 56 |
+
- eq(_eval(_translate(p.Expression.parseString("(2/2)*2")[0])).value, 2)
|
| 57 |
+
- eq(_eval(_translate(p.Expression.parseString("4/(2*2)")[0])).value, 1)
|
| 58 |
+
+ eq(_eval(_translate(p.Expression.parse_string("2*2*2")[0])).value, 8)
|
| 59 |
+
+ eq(_eval(_translate(p.Expression.parse_string("4/2*2")[0])).value, 4)
|
| 60 |
+
+ eq(_eval(_translate(p.Expression.parse_string("8/4*2")[0])).value, 4)
|
| 61 |
+
+ eq(_eval(_translate(p.Expression.parse_string("8/(4*2)")[0])).value, 1)
|
| 62 |
+
+ eq(_eval(_translate(p.Expression.parse_string("(2/2)*2")[0])).value, 2)
|
| 63 |
+
+ eq(_eval(_translate(p.Expression.parse_string("4/(2*2)")[0])).value, 1)
|
| 64 |
+
|
| 65 |
+
- eq(_eval(_translate(p.Expression.parseString("2+3*2")[0])).value, 8)
|
| 66 |
+
- eq(_eval(_translate(p.Expression.parseString("(2+3)*2")[0])).value, 10)
|
| 67 |
+
- eq(_eval(_translate(p.Expression.parseString("2+4/2")[0])).value, 4)
|
| 68 |
+
- eq(_eval(_translate(p.Expression.parseString("(2+4)/2")[0])).value, 3)
|
| 69 |
+
+ eq(_eval(_translate(p.Expression.parse_string("2+3*2")[0])).value, 8)
|
| 70 |
+
+ eq(_eval(_translate(p.Expression.parse_string("(2+3)*2")[0])).value, 10)
|
| 71 |
+
+ eq(_eval(_translate(p.Expression.parse_string("2+4/2")[0])).value, 4)
|
| 72 |
+
+ eq(_eval(_translate(p.Expression.parse_string("(2+4)/2")[0])).value, 3)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def test_arithmetic_var():
|
| 76 |
+
ctx = QueryContext()
|
| 77 |
+
ctx[Variable("x")] = Literal(2)
|
| 78 |
+
|
| 79 |
+
- eq(_eval(_translate(p.Expression.parseString("2+?x")[0]), ctx).value, 4)
|
| 80 |
+
+ eq(_eval(_translate(p.Expression.parse_string("2+?x")[0]), ctx).value, 4)
|
| 81 |
+
|
| 82 |
+
- eq(_eval(_translate(p.Expression.parseString("?x+3")[0]), ctx).value, 5)
|
| 83 |
+
- eq(_eval(_translate(p.Expression.parseString("3-?x")[0]), ctx).value, 1)
|
| 84 |
+
+ eq(_eval(_translate(p.Expression.parse_string("?x+3")[0]), ctx).value, 5)
|
| 85 |
+
+ eq(_eval(_translate(p.Expression.parse_string("3-?x")[0]), ctx).value, 1)
|
| 86 |
+
|
| 87 |
+
- eq(_eval(_translate(p.Expression.parseString("?x*3")[0]), ctx).value, 6)
|
| 88 |
+
- eq(_eval(_translate(p.Expression.parseString("4/?x")[0]), ctx).value, 2)
|
| 89 |
+
+ eq(_eval(_translate(p.Expression.parse_string("?x*3")[0]), ctx).value, 6)
|
| 90 |
+
+ eq(_eval(_translate(p.Expression.parse_string("4/?x")[0]), ctx).value, 2)
|
| 91 |
+
|
| 92 |
+
- eq(_eval(_translate(p.Expression.parseString("?x+?x+?x")[0]), ctx).value, 6)
|
| 93 |
+
- eq(_eval(_translate(p.Expression.parseString("?x-?x+?x")[0]), ctx).value, 2)
|
| 94 |
+
- eq(_eval(_translate(p.Expression.parseString("(?x-?x)+?x")[0]), ctx).value, 2)
|
| 95 |
+
- eq(_eval(_translate(p.Expression.parseString("?x-(?x+?x)")[0]), ctx).value, -2)
|
| 96 |
+
+ eq(_eval(_translate(p.Expression.parse_string("?x+?x+?x")[0]), ctx).value, 6)
|
| 97 |
+
+ eq(_eval(_translate(p.Expression.parse_string("?x-?x+?x")[0]), ctx).value, 2)
|
| 98 |
+
+ eq(_eval(_translate(p.Expression.parse_string("(?x-?x)+?x")[0]), ctx).value, 2)
|
| 99 |
+
+ eq(_eval(_translate(p.Expression.parse_string("?x-(?x+?x)")[0]), ctx).value, -2)
|
| 100 |
+
|
| 101 |
+
- eq(_eval(_translate(p.Expression.parseString("?x*?x*?x")[0]), ctx).value, 8)
|
| 102 |
+
- eq(_eval(_translate(p.Expression.parseString("4/?x*?x")[0]), ctx).value, 4)
|
| 103 |
+
- eq(_eval(_translate(p.Expression.parseString("8/4*?x")[0]), ctx).value, 4)
|
| 104 |
+
- eq(_eval(_translate(p.Expression.parseString("8/(4*?x)")[0]), ctx).value, 1)
|
| 105 |
+
- eq(_eval(_translate(p.Expression.parseString("(?x/?x)*?x")[0]), ctx).value, 2)
|
| 106 |
+
- eq(_eval(_translate(p.Expression.parseString("4/(?x*?x)")[0]), ctx).value, 1)
|
| 107 |
+
+ eq(_eval(_translate(p.Expression.parse_string("?x*?x*?x")[0]), ctx).value, 8)
|
| 108 |
+
+ eq(_eval(_translate(p.Expression.parse_string("4/?x*?x")[0]), ctx).value, 4)
|
| 109 |
+
+ eq(_eval(_translate(p.Expression.parse_string("8/4*?x")[0]), ctx).value, 4)
|
| 110 |
+
+ eq(_eval(_translate(p.Expression.parse_string("8/(4*?x)")[0]), ctx).value, 1)
|
| 111 |
+
+ eq(_eval(_translate(p.Expression.parse_string("(?x/?x)*?x")[0]), ctx).value, 2)
|
| 112 |
+
+ eq(_eval(_translate(p.Expression.parse_string("4/(?x*?x)")[0]), ctx).value, 1)
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def test_comparisons():
|
| 116 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("2<3")[0]))), True)
|
| 117 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("2<3.0")[0]))), True)
|
| 118 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("2<3e0")[0]))), True)
|
| 119 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("2<3")[0]))), True)
|
| 120 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("2<3.0")[0]))), True)
|
| 121 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("2<3e0")[0]))), True)
|
| 122 |
+
|
| 123 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("4<3")[0]))), False)
|
| 124 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("4<3.0")[0]))), False)
|
| 125 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("4<3e0")[0]))), False)
|
| 126 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("4<3")[0]))), False)
|
| 127 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("4<3.0")[0]))), False)
|
| 128 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("4<3e0")[0]))), False)
|
| 129 |
+
|
| 130 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("2<2.1")[0]))), True)
|
| 131 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("2<21e-1")[0]))), True)
|
| 132 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("2<2.1")[0]))), True)
|
| 133 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("2<21e-1")[0]))), True)
|
| 134 |
+
|
| 135 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("2=2.0")[0]))), True)
|
| 136 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("2=2e0")[0]))), True)
|
| 137 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("2=2.0")[0]))), True)
|
| 138 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("2=2e0")[0]))), True)
|
| 139 |
+
|
| 140 |
+
- eq(bool(_eval(_translate(p.Expression.parseString('2="cake"')[0]))), False)
|
| 141 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string('2="cake"')[0]))), False)
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def test_comparisons_var():
|
| 145 |
+
ctx = QueryContext()
|
| 146 |
+
ctx[Variable("x")] = Literal(2)
|
| 147 |
+
|
| 148 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("?x<3")[0]), ctx)), True)
|
| 149 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("?x<3.0")[0]), ctx)), True)
|
| 150 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("?x<3e0")[0]), ctx)), True)
|
| 151 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("?x<3")[0]), ctx)), True)
|
| 152 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("?x<3.0")[0]), ctx)), True)
|
| 153 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("?x<3e0")[0]), ctx)), True)
|
| 154 |
+
|
| 155 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("?x<2.1")[0]), ctx)), True)
|
| 156 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("?x<21e-1")[0]), ctx)), True)
|
| 157 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("?x<2.1")[0]), ctx)), True)
|
| 158 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("?x<21e-1")[0]), ctx)), True)
|
| 159 |
+
|
| 160 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("?x=2.0")[0]), ctx)), True)
|
| 161 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("?x=2e0")[0]), ctx)), True)
|
| 162 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("?x=2.0")[0]), ctx)), True)
|
| 163 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("?x=2e0")[0]), ctx)), True)
|
| 164 |
+
|
| 165 |
+
- eq(bool(_eval(_translate(p.Expression.parseString('?x="cake"')[0]), ctx)), False)
|
| 166 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string('?x="cake"')[0]), ctx)), False)
|
| 167 |
+
|
| 168 |
+
ctx = QueryContext()
|
| 169 |
+
ctx[Variable("x")] = Literal(4)
|
| 170 |
+
|
| 171 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("?x<3")[0]), ctx)), False)
|
| 172 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("?x<3.0")[0]), ctx)), False)
|
| 173 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("?x<3e0")[0]), ctx)), False)
|
| 174 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("?x<3")[0]), ctx)), False)
|
| 175 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("?x<3.0")[0]), ctx)), False)
|
| 176 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("?x<3e0")[0]), ctx)), False)
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def test_and_or():
|
| 180 |
+
- eq(bool(_eval(_translate(p.Expression.parseString("3>2 && 3>1")[0]))), True)
|
| 181 |
+
+ eq(bool(_eval(_translate(p.Expression.parse_string("3>2 && 3>1")[0]))), True)
|
| 182 |
+
eq(
|
| 183 |
+
- bool(_eval(_translate(p.Expression.parseString("3>2 && 3>4 || 2>1")[0]))),
|
| 184 |
+
+ bool(_eval(_translate(p.Expression.parse_string("3>2 && 3>4 || 2>1")[0]))),
|
| 185 |
+
True,
|
| 186 |
+
)
|
| 187 |
+
eq(
|
| 188 |
+
- bool(_eval(_translate(p.Expression.parseString("2>1 || 3>2 && 3>4")[0]))),
|
| 189 |
+
+ bool(_eval(_translate(p.Expression.parse_string("2>1 || 3>2 && 3>4")[0]))),
|
| 190 |
+
True,
|
| 191 |
+
)
|
| 192 |
+
eq(
|
| 193 |
+
- bool(_eval(_translate(p.Expression.parseString("(2>1 || 3>2) && 3>4")[0]))),
|
| 194 |
+
+ bool(_eval(_translate(p.Expression.parse_string("(2>1 || 3>2) && 3>4")[0]))),
|
| 195 |
+
False,
|
| 196 |
+
)
|
| 197 |
+
diff --git a/test/test_sparql/test_tsvresults.py b/test/test_sparql/test_tsvresults.py
|
| 198 |
+
index c5e72d19..e4ad55d4 100644
|
| 199 |
+
--- a/test/test_sparql/test_tsvresults.py
|
| 200 |
+
+++ b/test/test_sparql/test_tsvresults.py
|
| 201 |
+
@@ -1,7 +1,11 @@
|
| 202 |
+
-from io import StringIO
|
| 203 |
+
+from io import BytesIO, StringIO
|
| 204 |
+
|
| 205 |
+
+import pytest
|
| 206 |
+
+
|
| 207 |
+
+from rdflib.plugins.sparql.parserutils import CompValue
|
| 208 |
+
from rdflib.plugins.sparql.results.tsvresults import TSVResultParser
|
| 209 |
+
from rdflib.query import ResultRow
|
| 210 |
+
+from rdflib.term import Literal, URIRef
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
def test_empty_tsvresults_bindings() -> None:
|
| 214 |
+
@@ -18,3 +22,65 @@ def test_empty_tsvresults_bindings() -> None:
|
| 215 |
+
for idx, row in enumerate(result):
|
| 216 |
+
assert isinstance(row, ResultRow)
|
| 217 |
+
assert row[idx] is None
|
| 218 |
+
+
|
| 219 |
+
+
|
| 220 |
+
+def test_dbpedia_style_optional_unbound_var() -> None:
|
| 221 |
+
+ source = (
|
| 222 |
+
+ "?person\t?deathDate\n"
|
| 223 |
+
+ '<http://dbpedia.org/resource/Albert_Einstein>\t"1955-04-18"^^<http://www.w3.org/2001/XMLSchema#date>\n'
|
| 224 |
+
+ "<http://dbpedia.org/resource/Barack_Obama>\t\n"
|
| 225 |
+
+ )
|
| 226 |
+
+
|
| 227 |
+
+ parser = TSVResultParser()
|
| 228 |
+
+ result = parser.parse(StringIO(source))
|
| 229 |
+
+ assert result.vars is not None
|
| 230 |
+
+ person, death_date = result.vars
|
| 231 |
+
+
|
| 232 |
+
+ assert len(result.bindings) == 2
|
| 233 |
+
+ assert result.bindings[0][person] == URIRef(
|
| 234 |
+
+ "http://dbpedia.org/resource/Albert_Einstein"
|
| 235 |
+
+ )
|
| 236 |
+
+ assert result.bindings[0][death_date] == Literal(
|
| 237 |
+
+ "1955-04-18", datatype=URIRef("http://www.w3.org/2001/XMLSchema#date")
|
| 238 |
+
+ )
|
| 239 |
+
+ assert result.bindings[1][person] == URIRef(
|
| 240 |
+
+ "http://dbpedia.org/resource/Barack_Obama"
|
| 241 |
+
+ )
|
| 242 |
+
+ assert death_date not in result.bindings[1]
|
| 243 |
+
+
|
| 244 |
+
+
|
| 245 |
+
+def test_dbpedia_style_all_projected_vars_unbound_row_is_preserved() -> None:
|
| 246 |
+
+ source = "?x\t?y\n\t\n"
|
| 247 |
+
+
|
| 248 |
+
+ parser = TSVResultParser()
|
| 249 |
+
+ result = parser.parse(StringIO(source))
|
| 250 |
+
+
|
| 251 |
+
+ # Parser should preserve fully-unbound solution rows as empty mappings.
|
| 252 |
+
+ assert len(result.bindings) == 1
|
| 253 |
+
+ assert result.bindings[0] == {}
|
| 254 |
+
+
|
| 255 |
+
+
|
| 256 |
+
+def test_parse_tsv_from_bytes_skips_blank_lines() -> None:
|
| 257 |
+
+ source = BytesIO(b"?x\n\n<urn:x1>\n")
|
| 258 |
+
+
|
| 259 |
+
+ parser = TSVResultParser()
|
| 260 |
+
+ result = parser.parse(source)
|
| 261 |
+
+ assert result.vars is not None
|
| 262 |
+
+ var_x = result.vars[0]
|
| 263 |
+
+
|
| 264 |
+
+ assert len(result.bindings) == 1
|
| 265 |
+
+ assert result.bindings[0][var_x] == URIRef("urn:x1")
|
| 266 |
+
+
|
| 267 |
+
+
|
| 268 |
+
+def test_convert_term_rejects_unknown_compvalue_name() -> None:
|
| 269 |
+
+ parser = TSVResultParser()
|
| 270 |
+
+
|
| 271 |
+
+ with pytest.raises(Exception, match="I dont know how to handle this"):
|
| 272 |
+
+ parser.convertTerm(CompValue("unknown", value="x"))
|
| 273 |
+
+
|
| 274 |
+
+
|
| 275 |
+
+def test_convert_term_rejects_unexpected_type() -> None:
|
| 276 |
+
+ parser = TSVResultParser()
|
| 277 |
+
+
|
| 278 |
+
+ with pytest.raises(ValueError, match="Unexpected type"):
|
| 279 |
+
+ parser.convertTerm("not-a-term")
|
| 280 |
+
|
| 281 |
+
EOF_R2E_TEST_PATCH
|
| 282 |
+
R2E_APPLY_RC=$?
|
| 283 |
+
if [ "$R2E_APPLY_RC" -ne 0 ]; then
|
| 284 |
+
echo "0.000000" > /logs/verifier/reward.txt
|
| 285 |
+
printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json
|
| 286 |
+
echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2
|
| 287 |
+
exit 0
|
| 288 |
+
fi
|
| 289 |
+
( python -m pytest -v test/test_sparql/test_expressions.py test/test_sparql/test_tsvresults.py ) > /logs/verifier/test_output.log 2>&1
|
| 290 |
+
TEST_EXIT_CODE=$?
|
| 291 |
+
cat /logs/verifier/test_output.log
|
| 292 |
+
python3 "$SCRIPT_DIR/verifier.py" --log /logs/verifier/test_output.log --f2p "$SCRIPT_DIR/f2p.json" --p2p "$SCRIPT_DIR/p2p.json" --test-cmds 'python -m pytest -v test/test_sparql/test_expressions.py test/test_sparql/test_tsvresults.py' --exit-code "$TEST_EXIT_CODE" --out-dir /logs/verifier || { [ "$TEST_EXIT_CODE" -eq 0 ] && echo "1.0" > /logs/verifier/reward.txt || echo "0.0" > /logs/verifier/reward.txt; }
|
| 293 |
+
git checkout 6539dfef42c5b853ccab41c046772a8e0c8e1658 -- test/test_sparql/test_expressions.py test/test_sparql/test_tsvresults.py || true
|
| 294 |
+
exit 0
|
heldout/RDFLib__rdflib-2be67dca9f5d/tests/verifier.py
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""In-container verifier for pr_runtime tasks (graded F2P/P2P reward).
|
| 2 |
+
|
| 3 |
+
This module is the **standalone verifier** that runs inside the task's
|
| 4 |
+
Docker container, NOT a helper used at generation time. It is read as
|
| 5 |
+
source at generation time, base64-encoded, and embedded into
|
| 6 |
+
``tests/test.sh``. At run time the container decodes it back to a file
|
| 7 |
+
and invokes it after the test suite has run.
|
| 8 |
+
|
| 9 |
+
Why a graded reward instead of binary pass/fail
|
| 10 |
+
------------------------------------------------
|
| 11 |
+
SWE-bench resolution is binary: a patch "resolves" the issue iff ALL
|
| 12 |
+
FAIL_TO_PASS tests pass AND ALL PASS_TO_PASS tests still pass. That's
|
| 13 |
+
the right signal for an eval leaderboard, but a terrible gradient for
|
| 14 |
+
RL training — an agent that fixes 4 of 5 failing tests scores the same
|
| 15 |
+
0.0 as one that fixes nothing.
|
| 16 |
+
|
| 17 |
+
So this verifier emits BOTH:
|
| 18 |
+
* /logs/verifier/reward.txt — the GRADED scalar (training signal,
|
| 19 |
+
which Harbor reads): reward = f2p_rate * p2p_factor
|
| 20 |
+
* /logs/verifier/reward-details.json — carries the strict SWE-bench
|
| 21 |
+
``resolved`` bool (eval signal) PLUS the full breakdown.
|
| 22 |
+
|
| 23 |
+
Refs: SWE-bench (F2P/P2P semantics), SWE-RL / SWE-Gym (dense reward for
|
| 24 |
+
RL), UTBoost (weak-test coverage lets wrong patches pass — hence we
|
| 25 |
+
record p2p_count so consumers can judge regression-guard strength).
|
| 26 |
+
|
| 27 |
+
Scoring
|
| 28 |
+
-------
|
| 29 |
+
Given the baked FAIL_TO_PASS / PASS_TO_PASS test-name lists (computed by
|
| 30 |
+
the generation-time two-stage validation) and the agent-run test log:
|
| 31 |
+
|
| 32 |
+
f2p_rate = (# F2P tests now PASSED) / (# F2P tests)
|
| 33 |
+
p2p_rate = (# P2P tests still PASSED) / (# P2P tests) [1.0 if no P2P]
|
| 34 |
+
p2p_factor = p2p_rate # regressions scale the reward down
|
| 35 |
+
reward = f2p_rate * p2p_factor
|
| 36 |
+
resolved = (all F2P pass) AND (all P2P pass) # strict SWE-bench
|
| 37 |
+
|
| 38 |
+
Oracle invariant: the gold patch flips every F2P and keeps every P2P,
|
| 39 |
+
so f2p_rate=1.0, p2p_rate=1.0 -> reward=1.0 and resolved=True. This is
|
| 40 |
+
what the T3 oracle gate (reward == 1.0) relies on.
|
| 41 |
+
|
| 42 |
+
Graceful degradation: if the log can't be parsed into per-test
|
| 43 |
+
statuses (unrecognized runner output), fall back to the exit-code
|
| 44 |
+
reward (1.0 if the suite exited 0, else 0.0) and stamp
|
| 45 |
+
``parse_status="fallback_exitcode"`` — never crash, never silently
|
| 46 |
+
zero out a real fix.
|
| 47 |
+
|
| 48 |
+
Pure stdlib — uses only ``argparse``, ``json``, ``os``, ``re``, ``sys``.
|
| 49 |
+
The 4 per-runner parsers are condensed ports of
|
| 50 |
+
``repo2rlenv.log_parsers.*`` kept in lockstep via the unit tests under
|
| 51 |
+
``tests/test_pr_runtime_verifier.py``.
|
| 52 |
+
"""
|
| 53 |
+
|
| 54 |
+
from __future__ import annotations
|
| 55 |
+
|
| 56 |
+
import argparse
|
| 57 |
+
import json
|
| 58 |
+
import os
|
| 59 |
+
import re
|
| 60 |
+
import sys
|
| 61 |
+
|
| 62 |
+
# Canonical statuses. (Plain strings — no typing.Literal so the baked
|
| 63 |
+
# module stays import-light when decoded standalone in the container.)
|
| 64 |
+
PASSED = "PASSED"
|
| 65 |
+
FAILED = "FAILED"
|
| 66 |
+
SKIPPED = "SKIPPED"
|
| 67 |
+
ERROR = "ERROR"
|
| 68 |
+
|
| 69 |
+
# ---------------------------------------------------------------------------
|
| 70 |
+
# Per-runner log parsers (condensed ports of repo2rlenv.log_parsers.*)
|
| 71 |
+
# ---------------------------------------------------------------------------
|
| 72 |
+
|
| 73 |
+
_PYTEST_STATUSES = (PASSED, FAILED, SKIPPED, ERROR)
|
| 74 |
+
# Keep these patterns in sync with log_parsers/pytest_parser.py. This module
|
| 75 |
+
# also runs standalone inside task containers, without a repo2rlenv install.
|
| 76 |
+
_PYTEST_PROGRESS = (
|
| 77 |
+
r"\[\s*\d+%\]|\[\s*\d+\s*/\s*\d+\s*\]"
|
| 78 |
+
r"|\d+(?:\.\d+)?(?:us|ms|s)|\d+m \d+s|\d+h \d+m"
|
| 79 |
+
)
|
| 80 |
+
_PYTEST_VERBOSE_RE = re.compile(
|
| 81 |
+
r"^(?P<name>.+?(?:\[.*?\])?)\s+(?P<status>PASSED|FAILED|SKIPPED|ERROR)"
|
| 82 |
+
rf"(?:\s+\(.*\))?(?:\s+(?:{_PYTEST_PROGRESS}))?$"
|
| 83 |
+
)
|
| 84 |
+
_PYTEST_SUMMARY_NAME_RE = re.compile(r"^(?P<name>.+?(?:\[.*?\])?)(?: - .*)?$")
|
| 85 |
+
# pytest-xdist worker label, e.g. `[gw1] [ 20%] PASSED tests/foo.py::test_x`.
|
| 86 |
+
_PYTEST_XDIST_PREFIX_RE = re.compile(rf"^\[gw\d+\]\s+(?:(?:{_PYTEST_PROGRESS})\s+)?")
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def parse_pytest(log: str) -> dict[str, str]:
|
| 90 |
+
"""{test_name -> status} from pytest output (verbose or summary)."""
|
| 91 |
+
out: dict[str, str] = {}
|
| 92 |
+
if not log:
|
| 93 |
+
return out
|
| 94 |
+
for raw in log.split("\n"):
|
| 95 |
+
line = raw.strip()
|
| 96 |
+
if not line:
|
| 97 |
+
continue
|
| 98 |
+
line = _PYTEST_XDIST_PREFIX_RE.sub("", line, count=1)
|
| 99 |
+
# Summary lines (STATUS first), preserving the full node ID.
|
| 100 |
+
leading = None
|
| 101 |
+
for st in _PYTEST_STATUSES:
|
| 102 |
+
if line.startswith(st + " ") or line == st:
|
| 103 |
+
leading = st
|
| 104 |
+
break
|
| 105 |
+
if leading is not None:
|
| 106 |
+
work = line[len(leading) :].strip()
|
| 107 |
+
if leading == SKIPPED and re.match(r"^\[\d+\](?:\s|$)", work):
|
| 108 |
+
# Folded skips report a file location, not a parametrized ID.
|
| 109 |
+
tokens = work.split(maxsplit=2)
|
| 110 |
+
if len(tokens) < 2:
|
| 111 |
+
continue
|
| 112 |
+
out[tokens[1]] = leading
|
| 113 |
+
elif m := _PYTEST_SUMMARY_NAME_RE.match(work):
|
| 114 |
+
out[m.group("name")] = leading
|
| 115 |
+
continue
|
| 116 |
+
# Verbose progress (NAME first, STATUS after)
|
| 117 |
+
# Filter non-test output before attempting the backtracking regex.
|
| 118 |
+
head = line.split(None, 1)[0]
|
| 119 |
+
if "::" not in head and not head.endswith(".py"):
|
| 120 |
+
continue
|
| 121 |
+
m = _PYTEST_VERBOSE_RE.match(line)
|
| 122 |
+
if m:
|
| 123 |
+
name = m.group("name")
|
| 124 |
+
if "::" in name or name.endswith(".py"):
|
| 125 |
+
out[name] = m.group("status")
|
| 126 |
+
return out
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
_GO_TEST_RE = re.compile(r"^\s*---\s+(?P<status>PASS|FAIL|SKIP):\s+(?P<name>\S+)")
|
| 130 |
+
_GO_STATUS = {"PASS": PASSED, "FAIL": FAILED, "SKIP": SKIPPED}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def parse_go_test(log: str) -> dict[str, str]:
|
| 134 |
+
"""{test_name -> status} from `go test -v` output."""
|
| 135 |
+
out: dict[str, str] = {}
|
| 136 |
+
if not log:
|
| 137 |
+
return out
|
| 138 |
+
for raw in log.split("\n"):
|
| 139 |
+
m = _GO_TEST_RE.match(raw)
|
| 140 |
+
if m:
|
| 141 |
+
out[m.group("name")] = _GO_STATUS[m.group("status")]
|
| 142 |
+
return out
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
# Keep these patterns in sync with log_parsers/cargo_parser.py.
|
| 146 |
+
_CARGO_TEST_RE = re.compile(r"^test\s+(?P<name>\S.*?) \.\.\. (?P<status>ok|FAILED|ignored)\b")
|
| 147 |
+
_CARGO_MODE_RE = re.compile(r" - (?:should panic|compile fail|compile)$")
|
| 148 |
+
_CARGO_DOCTEST_RE = re.compile(r"^(?P<file>\S+) - (?:(?P<item>.+?) )?\(line \d+\)$")
|
| 149 |
+
_CARGO_STATUS = {"ok": PASSED, "FAILED": FAILED, "ignored": SKIPPED}
|
| 150 |
+
_CARGO_DOCTEST_RANK = {SKIPPED: 0, PASSED: 1, FAILED: 2}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def parse_cargo_test(log: str) -> dict[str, str]:
|
| 154 |
+
"""{test_name -> status} from `cargo test` output.
|
| 155 |
+
|
| 156 |
+
Test modes (` - should panic`) are dropped from names, and doctests are
|
| 157 |
+
keyed without their `(line N)` so line shifts don't change identity; the
|
| 158 |
+
worst status among an item's doctests wins.
|
| 159 |
+
"""
|
| 160 |
+
out: dict[str, str] = {}
|
| 161 |
+
if not log:
|
| 162 |
+
return out
|
| 163 |
+
for raw in log.split("\n"):
|
| 164 |
+
m = _CARGO_TEST_RE.match(raw)
|
| 165 |
+
if not m:
|
| 166 |
+
continue
|
| 167 |
+
name = _CARGO_MODE_RE.sub("", m.group("name")).rstrip()
|
| 168 |
+
status = _CARGO_STATUS[m.group("status")]
|
| 169 |
+
doctest = _CARGO_DOCTEST_RE.match(name)
|
| 170 |
+
if doctest:
|
| 171 |
+
item = doctest.group("item")
|
| 172 |
+
name = f"{doctest.group('file')} - {item}" if item else doctest.group("file")
|
| 173 |
+
if name in out and _CARGO_DOCTEST_RANK[out[name]] > _CARGO_DOCTEST_RANK[status]:
|
| 174 |
+
continue
|
| 175 |
+
out[name] = status
|
| 176 |
+
return out
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
_JEST_FILE_RE = re.compile(r"^ ?(?:PASS|FAIL)\s+(?P<path>\S+\.(?:ts|tsx|js|jsx|mjs|cjs))\b")
|
| 180 |
+
_JEST_TEST_RE = re.compile(
|
| 181 |
+
r"^(?P<indent>\s*)(?P<glyph>✓|√|✕|×|✗|○|◯)\s+(?P<name>.+?)(?:\s+\(\d+(?:\.\d+)?\s*m?s\))?$"
|
| 182 |
+
)
|
| 183 |
+
_JEST_GLYPH = {
|
| 184 |
+
"✓": PASSED,
|
| 185 |
+
"√": PASSED,
|
| 186 |
+
"✕": FAILED,
|
| 187 |
+
"×": FAILED,
|
| 188 |
+
"✗": FAILED,
|
| 189 |
+
"○": SKIPPED,
|
| 190 |
+
"◯": SKIPPED,
|
| 191 |
+
}
|
| 192 |
+
# Keep these patterns in sync with log_parsers/jest_parser.py.
|
| 193 |
+
_ANSI_RE = re.compile(r"\x1b\[[0-9;?]*[A-Za-z]")
|
| 194 |
+
_VITEST_MARKER_RE = re.compile(r"^\s*(?:RUN\s+v\d+\.\d+|Test Files\s+\d)", re.MULTILINE)
|
| 195 |
+
_VITEST_TEST_RE = re.compile(
|
| 196 |
+
r"^\s*(?P<glyph>[✓×↓□]) (?:\|(?P<project>[^|]+)\| | (?P<label>\S+) )?"
|
| 197 |
+
r"(?P<name>\S+ > .+?)(?P<duration> \d{1,9}ms)?"
|
| 198 |
+
r"(?: \(retry x\d{1,9}\))?(?: \(repeat x\d{1,9}\))?(?: \d{1,9} MB heap used)?(?: \[[^\[\]]*\])?$"
|
| 199 |
+
)
|
| 200 |
+
_VITEST_STATUS = {"✓": PASSED, "×": FAILED, "↓": SKIPPED, "□": SKIPPED}
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def _parse_vitest(log: str) -> dict[str, str]:
|
| 204 |
+
"""{test_name -> status} from vitest `--reporter=verbose` lines only."""
|
| 205 |
+
out: dict[str, str] = {}
|
| 206 |
+
for raw in log.split("\n"):
|
| 207 |
+
m = _VITEST_TEST_RE.match(raw.rstrip())
|
| 208 |
+
if not m:
|
| 209 |
+
continue
|
| 210 |
+
glyph, name = m.group("glyph"), m.group("name")
|
| 211 |
+
if glyph in "↓□" and m.group("duration"):
|
| 212 |
+
name += m.group("duration")
|
| 213 |
+
project = m.group("project") or m.group("label")
|
| 214 |
+
out[f"|{project}| {name}" if project else name] = _VITEST_STATUS[glyph]
|
| 215 |
+
return out
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def parse_jest(log: str) -> dict[str, str]:
|
| 219 |
+
"""{test_name -> status} from Jest / Mocha / Vitest output."""
|
| 220 |
+
out: dict[str, str] = {}
|
| 221 |
+
if not log:
|
| 222 |
+
return out
|
| 223 |
+
log = _ANSI_RE.sub("", log)
|
| 224 |
+
if _VITEST_MARKER_RE.search(log):
|
| 225 |
+
return _parse_vitest(log)
|
| 226 |
+
current_file: str | None = None
|
| 227 |
+
describe_stack: list[tuple[int, str]] = []
|
| 228 |
+
last_test_indent: int | None = None
|
| 229 |
+
for raw in log.split("\n"):
|
| 230 |
+
line = raw.rstrip()
|
| 231 |
+
if not line:
|
| 232 |
+
continue
|
| 233 |
+
m = _JEST_FILE_RE.match(line)
|
| 234 |
+
if m:
|
| 235 |
+
current_file = m.group("path")
|
| 236 |
+
describe_stack = []
|
| 237 |
+
last_test_indent = None
|
| 238 |
+
continue
|
| 239 |
+
m = _JEST_TEST_RE.match(line)
|
| 240 |
+
if m:
|
| 241 |
+
indent = len(m.group("indent"))
|
| 242 |
+
name = re.sub(r"^(?:skipped|todo):\s*", "", m.group("name").strip())
|
| 243 |
+
describes = [d for ind, d in describe_stack if ind < indent]
|
| 244 |
+
parts = ([current_file] if current_file else []) + describes + [name]
|
| 245 |
+
out[" > ".join(parts)] = _JEST_GLYPH[m.group("glyph")]
|
| 246 |
+
last_test_indent = indent
|
| 247 |
+
continue
|
| 248 |
+
stripped = line.lstrip()
|
| 249 |
+
if not stripped or stripped.startswith(
|
| 250 |
+
("Tests:", "Test Suites:", "Snapshots:", "Time:", "Ran all", "●", "→", "✗:")
|
| 251 |
+
):
|
| 252 |
+
continue
|
| 253 |
+
indent_here = len(line) - len(stripped)
|
| 254 |
+
if current_file and (last_test_indent is None or indent_here < last_test_indent):
|
| 255 |
+
describe_stack = [(i, d) for i, d in describe_stack if i < indent_here]
|
| 256 |
+
describe_stack.append((indent_here, stripped))
|
| 257 |
+
return out
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
def _detect_runner(test_cmds: str) -> str:
|
| 261 |
+
joined = test_cmds.lower()
|
| 262 |
+
if "pytest" in joined:
|
| 263 |
+
return "pytest"
|
| 264 |
+
if re.search(r"\bgo\s+test\b", joined):
|
| 265 |
+
return "go"
|
| 266 |
+
if re.search(r"\bcargo\s+test\b", joined):
|
| 267 |
+
return "cargo"
|
| 268 |
+
if any(k in joined for k in ("jest", "mocha", "vitest", "npm test", "yarn test", "pnpm test")):
|
| 269 |
+
return "jest"
|
| 270 |
+
return "unknown"
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
def parse_logs(runner: str, log: str) -> dict[str, str]:
|
| 274 |
+
"""Dispatch to the right per-runner parser. Empty dict if unknown."""
|
| 275 |
+
if runner == "pytest":
|
| 276 |
+
return parse_pytest(log)
|
| 277 |
+
if runner == "go":
|
| 278 |
+
return parse_go_test(log)
|
| 279 |
+
if runner == "cargo":
|
| 280 |
+
return parse_cargo_test(log)
|
| 281 |
+
if runner == "jest":
|
| 282 |
+
return parse_jest(log)
|
| 283 |
+
return {}
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
# ---------------------------------------------------------------------------
|
| 287 |
+
# Grading
|
| 288 |
+
# ---------------------------------------------------------------------------
|
| 289 |
+
def _has_go_parent(name: str, status_map: dict[str, str]) -> bool:
|
| 290 |
+
"""Return True if a Go test has an ancestor represented in the status map."""
|
| 291 |
+
parts = name.split("/")
|
| 292 |
+
|
| 293 |
+
for i in range(1, len(parts)):
|
| 294 |
+
parent = "/".join(parts[:i])
|
| 295 |
+
if status_map.get(parent) == FAILED:
|
| 296 |
+
return True
|
| 297 |
+
|
| 298 |
+
return False
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def grade(
|
| 302 |
+
fail_to_pass: list[str],
|
| 303 |
+
pass_to_pass: list[str],
|
| 304 |
+
status_map: dict[str, str],
|
| 305 |
+
runner: str | None = None,
|
| 306 |
+
) -> dict:
|
| 307 |
+
"""Compute the graded reward + strict resolved bool from a status map.
|
| 308 |
+
|
| 309 |
+
f2p_rate = (# F2P now PASSED) / (# F2P)
|
| 310 |
+
p2p_rate = (# P2P still PASSED) / (# P2P) [1.0 when no P2P]
|
| 311 |
+
reward = f2p_rate * p2p_rate (dense training signal)
|
| 312 |
+
resolved = all F2P pass AND all P2P pass (SWE-bench TRACKED resolution —
|
| 313 |
+
the gold patch always satisfies this, preserving the oracle
|
| 314 |
+
invariant)
|
| 315 |
+
|
| 316 |
+
Two distinct EVAL signals (see the audit's "tracked vs command resolved"):
|
| 317 |
+
* `resolved` — tracked resolution (above). Gold patch -> True.
|
| 318 |
+
* `command_resolved` — stricter: tracked resolution AND the selected test
|
| 319 |
+
command had NO failures outside F2P/P2P AND exit
|
| 320 |
+
code 0. Computed in main() where the exit code is
|
| 321 |
+
known. A benchmark that wants "the whole command
|
| 322 |
+
passed cleanly" gates on this; SWE-bench-style
|
| 323 |
+
scoring uses `resolved`.
|
| 324 |
+
|
| 325 |
+
`untracked_failed` are FAILED tests in the run that are neither F2P nor
|
| 326 |
+
P2P (e.g. always-failing/flaky tests pulled in by running a whole test
|
| 327 |
+
file). They don't change the graded `reward` or tracked `resolved`, but
|
| 328 |
+
they block `command_resolved` and are recorded for transparency.
|
| 329 |
+
"""
|
| 330 |
+
f2p_total = len(fail_to_pass)
|
| 331 |
+
p2p_total = len(pass_to_pass)
|
| 332 |
+
f2p_set = set(fail_to_pass)
|
| 333 |
+
p2p_set = set(pass_to_pass)
|
| 334 |
+
f2p_passed = sum(1 for t in fail_to_pass if status_map.get(t) == PASSED)
|
| 335 |
+
p2p_passed = sum(1 for t in pass_to_pass if status_map.get(t) == PASSED)
|
| 336 |
+
# Tests that should have stayed green but regressed (PASS->not-pass).
|
| 337 |
+
regressions = [t for t in pass_to_pass if status_map.get(t) != PASSED]
|
| 338 |
+
|
| 339 |
+
# FAILED tests outside the tracked sets — the selected command isn't clean.
|
| 340 |
+
if runner == "go":
|
| 341 |
+
failed_tests = {
|
| 342 |
+
t
|
| 343 |
+
for t, s in status_map.items()
|
| 344 |
+
if s == FAILED and t not in f2p_set and t not in p2p_set
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
untracked_failed = sorted(t for t in failed_tests if not _has_go_parent(t, status_map))
|
| 348 |
+
else:
|
| 349 |
+
untracked_failed = sorted(
|
| 350 |
+
t
|
| 351 |
+
for t, s in status_map.items()
|
| 352 |
+
if s == FAILED and t not in f2p_set and t not in p2p_set
|
| 353 |
+
)
|
| 354 |
+
|
| 355 |
+
f2p_rate = (f2p_passed / f2p_total) if f2p_total else 0.0
|
| 356 |
+
p2p_rate = (p2p_passed / p2p_total) if p2p_total else 1.0
|
| 357 |
+
reward = f2p_rate * p2p_rate
|
| 358 |
+
resolved = f2p_total > 0 and f2p_passed == f2p_total and p2p_passed == p2p_total
|
| 359 |
+
|
| 360 |
+
return {
|
| 361 |
+
"reward": round(max(0.0, min(1.0, reward)), 6),
|
| 362 |
+
"resolved": resolved,
|
| 363 |
+
"f2p_total": f2p_total,
|
| 364 |
+
"f2p_passed": f2p_passed,
|
| 365 |
+
"f2p_rate": round(f2p_rate, 6),
|
| 366 |
+
"p2p_total": p2p_total,
|
| 367 |
+
"p2p_passed": p2p_passed,
|
| 368 |
+
"p2p_rate": round(p2p_rate, 6),
|
| 369 |
+
"regressions": sorted(regressions),
|
| 370 |
+
"untracked_failed_count": len(untracked_failed),
|
| 371 |
+
"untracked_failed": untracked_failed[:20], # cap the list
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
# ---------------------------------------------------------------------------
|
| 376 |
+
# Entry point (invoked by tests/test.sh inside the container)
|
| 377 |
+
# ---------------------------------------------------------------------------
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
def _read_json_list(path: str) -> list[str]:
|
| 381 |
+
try:
|
| 382 |
+
with open(path, encoding="utf-8") as f:
|
| 383 |
+
data = json.load(f)
|
| 384 |
+
return [str(x) for x in data] if isinstance(data, list) else []
|
| 385 |
+
except (OSError, ValueError):
|
| 386 |
+
return []
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
def _read_text(path: str) -> str:
|
| 390 |
+
try:
|
| 391 |
+
with open(path, encoding="utf-8") as f:
|
| 392 |
+
return f.read()
|
| 393 |
+
except (OSError, UnicodeDecodeError):
|
| 394 |
+
return ""
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
def main(argv: list[str] | None = None) -> int:
|
| 398 |
+
p = argparse.ArgumentParser(description="pr_runtime graded F2P/P2P verifier")
|
| 399 |
+
p.add_argument("--log", required=True, help="captured test-run log file")
|
| 400 |
+
p.add_argument("--f2p", required=True, help="JSON file: FAIL_TO_PASS test names")
|
| 401 |
+
p.add_argument("--p2p", required=True, help="JSON file: PASS_TO_PASS test names")
|
| 402 |
+
p.add_argument("--runner", default="", help="pytest|go|cargo|jest (else auto-detect)")
|
| 403 |
+
p.add_argument("--test-cmds", default="", help="test command string (runner auto-detect)")
|
| 404 |
+
p.add_argument("--exit-code", type=int, default=1, help="test suite exit code (fallback)")
|
| 405 |
+
p.add_argument("--out-dir", default="/logs/verifier", help="where to write reward.{txt,json}")
|
| 406 |
+
args = p.parse_args(argv)
|
| 407 |
+
|
| 408 |
+
log = _read_text(args.log)
|
| 409 |
+
f2p = _read_json_list(args.f2p)
|
| 410 |
+
p2p = _read_json_list(args.p2p)
|
| 411 |
+
runner = args.runner.strip() or _detect_runner(args.test_cmds)
|
| 412 |
+
|
| 413 |
+
status_map = parse_logs(runner, log)
|
| 414 |
+
|
| 415 |
+
if not status_map:
|
| 416 |
+
# Unparseable runner output → fall back to the binary exit-code reward
|
| 417 |
+
# (a coarse TRAINING signal) so we never silently zero a real fix on an
|
| 418 |
+
# unrecognized format. But `resolved` is the strict EVAL signal: without
|
| 419 |
+
# parsed per-test status we have NO evidence the declared FAIL_TO_PASS
|
| 420 |
+
# tests passed, so when an F2P oracle exists we must NOT claim resolved.
|
| 421 |
+
# (resolved stays exit-code-based only when there's no declared oracle,
|
| 422 |
+
# e.g. --skip-validation.)
|
| 423 |
+
reward = 1.0 if args.exit_code == 0 else 0.0
|
| 424 |
+
has_oracle = len(f2p) > 0
|
| 425 |
+
resolved = (args.exit_code == 0) and not has_oracle
|
| 426 |
+
breakdown = {
|
| 427 |
+
"reward": reward,
|
| 428 |
+
"resolved": resolved,
|
| 429 |
+
"command_resolved": bool(resolved and args.exit_code == 0),
|
| 430 |
+
"parse_status": "fallback_exitcode",
|
| 431 |
+
"eval_trustworthy": not has_oracle,
|
| 432 |
+
"runner": runner,
|
| 433 |
+
"f2p_total": len(f2p),
|
| 434 |
+
"p2p_total": len(p2p),
|
| 435 |
+
"exit_code": args.exit_code,
|
| 436 |
+
}
|
| 437 |
+
else:
|
| 438 |
+
breakdown = grade(f2p, p2p, status_map, runner)
|
| 439 |
+
breakdown["parse_status"] = "ok"
|
| 440 |
+
breakdown["runner"] = runner
|
| 441 |
+
breakdown["tests_parsed"] = len(status_map)
|
| 442 |
+
breakdown["exit_code"] = args.exit_code
|
| 443 |
+
# Strict eval signal: tracked resolution AND a clean command (no
|
| 444 |
+
# untracked failures, exit code 0). Benchmarks wanting "the whole test
|
| 445 |
+
# command passed" gate on this; SWE-bench-style scoring uses `resolved`.
|
| 446 |
+
breakdown["command_resolved"] = bool(
|
| 447 |
+
breakdown["resolved"]
|
| 448 |
+
and breakdown["untracked_failed_count"] == 0
|
| 449 |
+
and args.exit_code == 0
|
| 450 |
+
)
|
| 451 |
+
reward = breakdown["reward"]
|
| 452 |
+
|
| 453 |
+
os.makedirs(args.out_dir, exist_ok=True)
|
| 454 |
+
with open(os.path.join(args.out_dir, "reward.txt"), "w", encoding="utf-8") as f:
|
| 455 |
+
f.write(f"{reward:.6f}\n")
|
| 456 |
+
with open(os.path.join(args.out_dir, "reward-details.json"), "w", encoding="utf-8") as f:
|
| 457 |
+
json.dump(breakdown, f, indent=2)
|
| 458 |
+
|
| 459 |
+
print(json.dumps(breakdown, indent=2))
|
| 460 |
+
return 0
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
if __name__ == "__main__":
|
| 464 |
+
sys.exit(main())
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
__all__ = [
|
| 468 |
+
"grade",
|
| 469 |
+
"main",
|
| 470 |
+
"parse_cargo_test",
|
| 471 |
+
"parse_go_test",
|
| 472 |
+
"parse_jest",
|
| 473 |
+
"parse_logs",
|
| 474 |
+
"parse_pytest",
|
| 475 |
+
]
|
heldout/RDFLib__rdflib-49afac8c15ce/environment/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv pr_runtime
|
| 2 |
+
FROM local/RDFLib__rdflib
|
| 3 |
+
WORKDIR /workspace
|
| 4 |
+
# Defensive: ensure git is on PATH at build time. Bootstrap base
|
| 5 |
+
# images vary — some (Python slim) don't ship git; some agents
|
| 6 |
+
# install it; others don't. Re-installing is a no-op when already
|
| 7 |
+
# present. Tries apt-get first (Debian/Ubuntu), then apk (Alpine).
|
| 8 |
+
# Install git + ca-certificates. Minimal images (node:alpine) ship
|
| 9 |
+
# without CA certs, so HTTPS git fetch fails verification.
|
| 10 |
+
RUN (command -v git >/dev/null 2>&1 && [ -e /etc/ssl/certs/ca-certificates.crt ]) || \
|
| 11 |
+
(apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*) || \
|
| 13 |
+
(apk add --no-cache git ca-certificates && update-ca-certificates) || true
|
| 14 |
+
# Defensive: the graded F2P/P2P verifier is Python.
|
| 15 |
+
# Language-specific bootstrap images (Go/Rust/Node) may not
|
| 16 |
+
# ship python3 — install it so test.sh can score F2P/P2P. No-op when
|
| 17 |
+
# python3 is already present (every Python-repo image has it).
|
| 18 |
+
RUN command -v python3 >/dev/null 2>&1 || \
|
| 19 |
+
(apt-get update && apt-get install -y --no-install-recommends python3 \
|
| 20 |
+
&& rm -rf /var/lib/apt/lists/*) || \
|
| 21 |
+
apk add --no-cache python3 || true
|
| 22 |
+
# Position the working tree at the PR's base commit so subsequent
|
| 23 |
+
# model-patch applications align with the line context the patch
|
| 24 |
+
# was authored against. The fetch is a no-op if the commit is
|
| 25 |
+
# already in the shallow clone.
|
| 26 |
+
RUN git config --global --add safe.directory /workspace \
|
| 27 |
+
&& git fetch --depth 1 origin 1964642d472c4b44de6aba1a6fe3be6b9d7a8153 2>/dev/null \
|
| 28 |
+
|| git fetch --unshallow origin 2>/dev/null || true
|
| 29 |
+
RUN git reset --hard 1964642d472c4b44de6aba1a6fe3be6b9d7a8153 && git clean -fdx -e .venv -e venv -e __pycache__ -e .tox -e node_modules -e target -e vendor -e .gradle -e .next -e .pytest_cache
|
| 30 |
+
RUN git checkout -q -B base 1964642d472c4b44de6aba1a6fe3be6b9d7a8153 \
|
| 31 |
+
&& git remote remove origin 2>/dev/null || true
|
| 32 |
+
RUN for ref in $(git branch --format='%(refname:short)' | grep -vx base); do git branch -D "$ref" 2>/dev/null || true; done \
|
| 33 |
+
&& git tag -l | xargs -r git tag -d >/dev/null 2>&1 || true \
|
| 34 |
+
&& git for-each-ref --format='%(refname)' refs/remotes 2>/dev/null | xargs -r -n1 git update-ref -d 2>/dev/null || true \
|
| 35 |
+
&& git reflog expire --expire=now --all 2>/dev/null || true \
|
| 36 |
+
&& git gc --prune=now 2>/dev/null || true
|
heldout/RDFLib__rdflib-49afac8c15ce/environment/docker-compose.yaml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv: anti-contamination egress guard.
|
| 2 |
+
# Blackholes the hosts that serve this repo's published fix and hidden
|
| 3 |
+
# tests, so an agent cannot fetch the answer (pip download / git fetch /
|
| 4 |
+
# WebFetch against these fail). General internet stays up so the agent
|
| 5 |
+
# can install itself and reach its model API. See pipelines/_env_guard.py.
|
| 6 |
+
services:
|
| 7 |
+
main:
|
| 8 |
+
extra_hosts:
|
| 9 |
+
- "pypi.org:0.0.0.0"
|
| 10 |
+
- "pypi.python.org:0.0.0.0"
|
| 11 |
+
- "files.pythonhosted.org:0.0.0.0"
|
| 12 |
+
- "github.com:0.0.0.0"
|
| 13 |
+
- "api.github.com:0.0.0.0"
|
| 14 |
+
- "raw.githubusercontent.com:0.0.0.0"
|
| 15 |
+
- "codeload.github.com:0.0.0.0"
|
| 16 |
+
- "objects.githubusercontent.com:0.0.0.0"
|
heldout/RDFLib__rdflib-49afac8c15ce/instruction.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue
|
| 2 |
+
|
| 3 |
+
**Title:** Base namespace predicates generate unnecessary prefixes in Turtle/LongTurtle output
|
| 4 |
+
|
| 5 |
+
## Description
|
| 6 |
+
When serializing data into Turtle or LongTurtle formats, predicates that belong to the base namespace are incorrectly rendered with an explicit prefix. For example, a predicate that should appear as `myPredicate` might instead be output as `base:myPredicate` or `_base:myPredicate`. This is unexpected, as predicates in the base namespace should not require an explicit prefix.
|
| 7 |
+
|
| 8 |
+
Additionally, in LongTurtle format, pnames (prefixed names) containing bracket characters are not properly escaped, leading to malformed output.
|
| 9 |
+
|
| 10 |
+
## Task
|
| 11 |
+
|
| 12 |
+
Modify the repository so that the issue described above is resolved. The task's test suite verifies your patch by applying it on top of the base commit `1964642d472c` and running the modified tests.
|
heldout/RDFLib__rdflib-49afac8c15ce/solution/patch.diff
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/rdflib/plugins/serializers/longturtle.py b/rdflib/plugins/serializers/longturtle.py
|
| 2 |
+
index 2aaed36e..1e68e684 100644
|
| 3 |
+
--- a/rdflib/plugins/serializers/longturtle.py
|
| 4 |
+
+++ b/rdflib/plugins/serializers/longturtle.py
|
| 5 |
+
@@ -22,7 +22,7 @@ from typing import IO, Any, Optional
|
| 6 |
+
|
| 7 |
+
from rdflib.compare import to_canonical_graph
|
| 8 |
+
from rdflib.exceptions import Error
|
| 9 |
+
-from rdflib.graph import Graph
|
| 10 |
+
+from rdflib.graph import Graph, _TripleType
|
| 11 |
+
from rdflib.namespace import RDF
|
| 12 |
+
from rdflib.term import BNode, Literal, URIRef
|
| 13 |
+
|
| 14 |
+
@@ -149,11 +149,20 @@ class LongTurtleSerializer(RecursiveSerializer):
|
| 15 |
+
|
| 16 |
+
self.base = None
|
| 17 |
+
|
| 18 |
+
- def preprocessTriple(self, triple):
|
| 19 |
+
+ def preprocessTriple(self, triple: _TripleType) -> None:
|
| 20 |
+
super(LongTurtleSerializer, self).preprocessTriple(triple)
|
| 21 |
+
for i, node in enumerate(triple):
|
| 22 |
+
- if node in self.keywords:
|
| 23 |
+
- continue
|
| 24 |
+
+ if i == VERB:
|
| 25 |
+
+ if node in self.keywords:
|
| 26 |
+
+ # predicate is a keyword
|
| 27 |
+
+ continue
|
| 28 |
+
+ if (
|
| 29 |
+
+ self.base is not None
|
| 30 |
+
+ and isinstance(node, URIRef)
|
| 31 |
+
+ and node.startswith(self.base)
|
| 32 |
+
+ ):
|
| 33 |
+
+ # predicate corresponds to base namespace
|
| 34 |
+
+ continue
|
| 35 |
+
# Don't use generated prefixes for subjects and objects
|
| 36 |
+
self.getQName(node, gen_prefix=(i == VERB))
|
| 37 |
+
if isinstance(node, Literal) and node.datatype:
|
| 38 |
+
@@ -180,6 +189,8 @@ class LongTurtleSerializer(RecursiveSerializer):
|
| 39 |
+
|
| 40 |
+
prefix, namespace, local = parts
|
| 41 |
+
|
| 42 |
+
+ local = local.replace(r"(", r"\(").replace(r")", r"\)")
|
| 43 |
+
+
|
| 44 |
+
# QName cannot end with .
|
| 45 |
+
if local.endswith("."):
|
| 46 |
+
return None
|
| 47 |
+
diff --git a/rdflib/plugins/serializers/turtle.py b/rdflib/plugins/serializers/turtle.py
|
| 48 |
+
index d1dfcf4a..abee2e43 100644
|
| 49 |
+
--- a/rdflib/plugins/serializers/turtle.py
|
| 50 |
+
+++ b/rdflib/plugins/serializers/turtle.py
|
| 51 |
+
@@ -263,9 +263,17 @@ class TurtleSerializer(RecursiveSerializer):
|
| 52 |
+
def preprocessTriple(self, triple: _TripleType) -> None:
|
| 53 |
+
super(TurtleSerializer, self).preprocessTriple(triple)
|
| 54 |
+
for i, node in enumerate(triple):
|
| 55 |
+
- if i == VERB and node in self.keywords:
|
| 56 |
+
- # predicate is a keyword
|
| 57 |
+
- continue
|
| 58 |
+
+ if i == VERB:
|
| 59 |
+
+ if node in self.keywords:
|
| 60 |
+
+ # predicate is a keyword
|
| 61 |
+
+ continue
|
| 62 |
+
+ if (
|
| 63 |
+
+ self.base is not None
|
| 64 |
+
+ and isinstance(node, URIRef)
|
| 65 |
+
+ and node.startswith(self.base)
|
| 66 |
+
+ ):
|
| 67 |
+
+ # predicate corresponds to base namespace
|
| 68 |
+
+ continue
|
| 69 |
+
# Don't use generated prefixes for subjects and objects
|
| 70 |
+
self.getQName(node, gen_prefix=(i == VERB))
|
| 71 |
+
if isinstance(node, Literal) and node.datatype:
|
heldout/RDFLib__rdflib-49afac8c15ce/solution/solve.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euxo pipefail
|
| 3 |
+
cd /workspace
|
| 4 |
+
git config --global --add safe.directory /workspace
|
| 5 |
+
PATCH="$(dirname "$0")/patch.diff"
|
| 6 |
+
git apply --verbose --reject "$PATCH"
|
heldout/RDFLib__rdflib-49afac8c15ce/task.toml
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "commit-runtime/RDFLib__rdflib-49afac8c15ce"
|
| 5 |
+
description = "skip prefix generation for predicates corresponding to base namespace (#3244)"
|
| 6 |
+
|
| 7 |
+
[metadata]
|
| 8 |
+
difficulty = "medium"
|
| 9 |
+
category = "bugfix"
|
| 10 |
+
keywords = [
|
| 11 |
+
"rdflib",
|
| 12 |
+
"commit_runtime",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
[metadata.repo2env]
|
| 16 |
+
pipeline = "commit_runtime"
|
| 17 |
+
pipeline_version = "0.8.3"
|
| 18 |
+
repo = "RDFLib/rdflib"
|
| 19 |
+
ref = "1964642d472c4b44de6aba1a6fe3be6b9d7a8153"
|
| 20 |
+
reference = "https://github.com/RDFLib/rdflib/commit/49afac8c15ce345ca797bffa5d6fdc6f738c42a5"
|
| 21 |
+
source_access = "public"
|
| 22 |
+
built_at = "2026-09-24T13:24:14.483462+00:00"
|
| 23 |
+
synthesis_llm = "gemini/gemini-2.5-flash"
|
| 24 |
+
reward_kinds = [
|
| 25 |
+
"test_execution",
|
| 26 |
+
"diff_similarity",
|
| 27 |
+
]
|
| 28 |
+
spec_version = "0.2.0"
|
| 29 |
+
content_hash = "sha256:68f625717127fc833b3af3deb0bef9e2ab53810c8b6322a7bb22c1531effcc0f"
|
| 30 |
+
|
| 31 |
+
[metadata.repo2env.commit_runtime]
|
| 32 |
+
commit_sha = "49afac8c15ce345ca797bffa5d6fdc6f738c42a5"
|
| 33 |
+
parent_sha = "1964642d472c4b44de6aba1a6fe3be6b9d7a8153"
|
| 34 |
+
authored_at = "2025-09-30T15:42:28+10:00"
|
| 35 |
+
author_email = "37032744+edmondchuc@users.noreply.github.com"
|
| 36 |
+
subject = "fix: skip prefix generation for predicates corresponding to base namespace (#3244)"
|
| 37 |
+
fail_to_pass = [
|
| 38 |
+
"test/test_serializers/test_serializer_turtle_base_namespace.py::test_longturtle",
|
| 39 |
+
"test/test_serializers/test_serializer_turtle_base_namespace.py::test_turtle",
|
| 40 |
+
]
|
| 41 |
+
pass_to_pass = []
|
| 42 |
+
validation_status = "verified"
|
| 43 |
+
bootstrap_image = "local-venv:RDFLib__rdflib"
|
| 44 |
+
instruction_synthesized = true
|
| 45 |
+
llm_cost_usd = 0.024096
|
| 46 |
+
|
| 47 |
+
[metadata.repo2env.reward_calibration]
|
| 48 |
+
f2p_count = 2
|
| 49 |
+
p2p_count = 0
|
| 50 |
+
source_files = 2
|
| 51 |
+
loc_changed = 33
|
| 52 |
+
difficulty = "medium"
|
| 53 |
+
|
| 54 |
+
[metadata.repo2env.evaluation]
|
| 55 |
+
schema_version = "1"
|
| 56 |
+
status = "unverified"
|
| 57 |
+
stage = "generation"
|
| 58 |
+
reason_codes = [
|
| 59 |
+
"validation_not_run",
|
| 60 |
+
]
|
| 61 |
+
detail = "Generated task; validation has not been established."
|
| 62 |
+
provenance = "unknown"
|
| 63 |
+
evidence = []
|
| 64 |
+
|
| 65 |
+
[metadata.repo2env.reproducibility]
|
| 66 |
+
mode = "local_only"
|
| 67 |
+
image_ref = "local/RDFLib__rdflib"
|
| 68 |
+
image_tag = "local/RDFLib__rdflib"
|
| 69 |
+
image_visibility = "private"
|
| 70 |
+
|
| 71 |
+
[agent]
|
| 72 |
+
timeout_sec = 1800.0
|
| 73 |
+
|
| 74 |
+
[verifier]
|
| 75 |
+
timeout_sec = 300.0
|
heldout/RDFLib__rdflib-49afac8c15ce/tests/f2p.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"test/test_serializers/test_serializer_turtle_base_namespace.py::test_longturtle",
|
| 3 |
+
"test/test_serializers/test_serializer_turtle_base_namespace.py::test_turtle"
|
| 4 |
+
]
|
heldout/RDFLib__rdflib-49afac8c15ce/tests/p2p.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[]
|
heldout/RDFLib__rdflib-49afac8c15ce/tests/test.sh
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -uxo pipefail
|
| 3 |
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
| 4 |
+
cd /workspace
|
| 5 |
+
git config --global --add safe.directory /workspace
|
| 6 |
+
mkdir -p /logs/verifier
|
| 7 |
+
git checkout 1964642d472c4b44de6aba1a6fe3be6b9d7a8153 -- test/test_serializers/test_serializer_turtle_base_namespace.py || true
|
| 8 |
+
git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH'
|
| 9 |
+
diff --git a/test/test_serializers/test_serializer_turtle_base_namespace.py b/test/test_serializers/test_serializer_turtle_base_namespace.py
|
| 10 |
+
new file mode 100644
|
| 11 |
+
index 00000000..f0971611
|
| 12 |
+
--- /dev/null
|
| 13 |
+
+++ b/test/test_serializers/test_serializer_turtle_base_namespace.py
|
| 14 |
+
@@ -0,0 +1,34 @@
|
| 15 |
+
+from rdflib import Graph, Namespace, URIRef
|
| 16 |
+
+
|
| 17 |
+
+# https://github.com/RDFLib/rdflib/issues/3237
|
| 18 |
+
+# Test that the ns1 prefix is not generated when the base is set.
|
| 19 |
+
+mns = Namespace("http://my-namespace.net/")
|
| 20 |
+
+
|
| 21 |
+
+
|
| 22 |
+
+def test_turtle():
|
| 23 |
+
+ g = Graph(base="http://my-base.net/")
|
| 24 |
+
+ g.add((mns.foo, URIRef("http://my-base.net/my-predicate"), mns.bar))
|
| 25 |
+
+ result = g.serialize(format="text/turtle")
|
| 26 |
+
+ assert (
|
| 27 |
+
+ result
|
| 28 |
+
+ == """@base <http://my-base.net/> .
|
| 29 |
+
+
|
| 30 |
+
+<http://my-namespace.net/foo> <my-predicate> <http://my-namespace.net/bar> .
|
| 31 |
+
+
|
| 32 |
+
+"""
|
| 33 |
+
+ )
|
| 34 |
+
+
|
| 35 |
+
+
|
| 36 |
+
+def test_longturtle():
|
| 37 |
+
+ g = Graph(base="http://my-base.net/")
|
| 38 |
+
+ g.add((mns.foo, URIRef("http://my-base.net/my-predicate"), mns.bar))
|
| 39 |
+
+ result = g.serialize(format="longturtle", canon=True)
|
| 40 |
+
+ assert (
|
| 41 |
+
+ result
|
| 42 |
+
+ == """BASE <http://my-base.net/>
|
| 43 |
+
+
|
| 44 |
+
+<http://my-namespace.net/foo>
|
| 45 |
+
+ <my-predicate> <http://my-namespace.net/bar> ;
|
| 46 |
+
+.
|
| 47 |
+
+"""
|
| 48 |
+
+ ), print(result)
|
| 49 |
+
|
| 50 |
+
EOF_R2E_TEST_PATCH
|
| 51 |
+
R2E_APPLY_RC=$?
|
| 52 |
+
if [ "$R2E_APPLY_RC" -ne 0 ]; then
|
| 53 |
+
echo "0.000000" > /logs/verifier/reward.txt
|
| 54 |
+
printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json
|
| 55 |
+
echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2
|
| 56 |
+
exit 0
|
| 57 |
+
fi
|
| 58 |
+
( python -m pytest -v test/test_serializers/test_serializer_turtle_base_namespace.py ) > /logs/verifier/test_output.log 2>&1
|
| 59 |
+
TEST_EXIT_CODE=$?
|
| 60 |
+
cat /logs/verifier/test_output.log
|
| 61 |
+
python3 "$SCRIPT_DIR/verifier.py" --log /logs/verifier/test_output.log --f2p "$SCRIPT_DIR/f2p.json" --p2p "$SCRIPT_DIR/p2p.json" --test-cmds 'python -m pytest -v test/test_serializers/test_serializer_turtle_base_namespace.py' --exit-code "$TEST_EXIT_CODE" --out-dir /logs/verifier || { [ "$TEST_EXIT_CODE" -eq 0 ] && echo "1.0" > /logs/verifier/reward.txt || echo "0.0" > /logs/verifier/reward.txt; }
|
| 62 |
+
git checkout 1964642d472c4b44de6aba1a6fe3be6b9d7a8153 -- test/test_serializers/test_serializer_turtle_base_namespace.py || true
|
| 63 |
+
exit 0
|
heldout/RDFLib__rdflib-49afac8c15ce/tests/verifier.py
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""In-container verifier for pr_runtime tasks (graded F2P/P2P reward).
|
| 2 |
+
|
| 3 |
+
This module is the **standalone verifier** that runs inside the task's
|
| 4 |
+
Docker container, NOT a helper used at generation time. It is read as
|
| 5 |
+
source at generation time, base64-encoded, and embedded into
|
| 6 |
+
``tests/test.sh``. At run time the container decodes it back to a file
|
| 7 |
+
and invokes it after the test suite has run.
|
| 8 |
+
|
| 9 |
+
Why a graded reward instead of binary pass/fail
|
| 10 |
+
------------------------------------------------
|
| 11 |
+
SWE-bench resolution is binary: a patch "resolves" the issue iff ALL
|
| 12 |
+
FAIL_TO_PASS tests pass AND ALL PASS_TO_PASS tests still pass. That's
|
| 13 |
+
the right signal for an eval leaderboard, but a terrible gradient for
|
| 14 |
+
RL training — an agent that fixes 4 of 5 failing tests scores the same
|
| 15 |
+
0.0 as one that fixes nothing.
|
| 16 |
+
|
| 17 |
+
So this verifier emits BOTH:
|
| 18 |
+
* /logs/verifier/reward.txt — the GRADED scalar (training signal,
|
| 19 |
+
which Harbor reads): reward = f2p_rate * p2p_factor
|
| 20 |
+
* /logs/verifier/reward-details.json — carries the strict SWE-bench
|
| 21 |
+
``resolved`` bool (eval signal) PLUS the full breakdown.
|
| 22 |
+
|
| 23 |
+
Refs: SWE-bench (F2P/P2P semantics), SWE-RL / SWE-Gym (dense reward for
|
| 24 |
+
RL), UTBoost (weak-test coverage lets wrong patches pass — hence we
|
| 25 |
+
record p2p_count so consumers can judge regression-guard strength).
|
| 26 |
+
|
| 27 |
+
Scoring
|
| 28 |
+
-------
|
| 29 |
+
Given the baked FAIL_TO_PASS / PASS_TO_PASS test-name lists (computed by
|
| 30 |
+
the generation-time two-stage validation) and the agent-run test log:
|
| 31 |
+
|
| 32 |
+
f2p_rate = (# F2P tests now PASSED) / (# F2P tests)
|
| 33 |
+
p2p_rate = (# P2P tests still PASSED) / (# P2P tests) [1.0 if no P2P]
|
| 34 |
+
p2p_factor = p2p_rate # regressions scale the reward down
|
| 35 |
+
reward = f2p_rate * p2p_factor
|
| 36 |
+
resolved = (all F2P pass) AND (all P2P pass) # strict SWE-bench
|
| 37 |
+
|
| 38 |
+
Oracle invariant: the gold patch flips every F2P and keeps every P2P,
|
| 39 |
+
so f2p_rate=1.0, p2p_rate=1.0 -> reward=1.0 and resolved=True. This is
|
| 40 |
+
what the T3 oracle gate (reward == 1.0) relies on.
|
| 41 |
+
|
| 42 |
+
Graceful degradation: if the log can't be parsed into per-test
|
| 43 |
+
statuses (unrecognized runner output), fall back to the exit-code
|
| 44 |
+
reward (1.0 if the suite exited 0, else 0.0) and stamp
|
| 45 |
+
``parse_status="fallback_exitcode"`` — never crash, never silently
|
| 46 |
+
zero out a real fix.
|
| 47 |
+
|
| 48 |
+
Pure stdlib — uses only ``argparse``, ``json``, ``os``, ``re``, ``sys``.
|
| 49 |
+
The 4 per-runner parsers are condensed ports of
|
| 50 |
+
``repo2rlenv.log_parsers.*`` kept in lockstep via the unit tests under
|
| 51 |
+
``tests/test_pr_runtime_verifier.py``.
|
| 52 |
+
"""
|
| 53 |
+
|
| 54 |
+
from __future__ import annotations
|
| 55 |
+
|
| 56 |
+
import argparse
|
| 57 |
+
import json
|
| 58 |
+
import os
|
| 59 |
+
import re
|
| 60 |
+
import sys
|
| 61 |
+
|
| 62 |
+
# Canonical statuses. (Plain strings — no typing.Literal so the baked
|
| 63 |
+
# module stays import-light when decoded standalone in the container.)
|
| 64 |
+
PASSED = "PASSED"
|
| 65 |
+
FAILED = "FAILED"
|
| 66 |
+
SKIPPED = "SKIPPED"
|
| 67 |
+
ERROR = "ERROR"
|
| 68 |
+
|
| 69 |
+
# ---------------------------------------------------------------------------
|
| 70 |
+
# Per-runner log parsers (condensed ports of repo2rlenv.log_parsers.*)
|
| 71 |
+
# ---------------------------------------------------------------------------
|
| 72 |
+
|
| 73 |
+
_PYTEST_STATUSES = (PASSED, FAILED, SKIPPED, ERROR)
|
| 74 |
+
# Keep these patterns in sync with log_parsers/pytest_parser.py. This module
|
| 75 |
+
# also runs standalone inside task containers, without a repo2rlenv install.
|
| 76 |
+
_PYTEST_PROGRESS = (
|
| 77 |
+
r"\[\s*\d+%\]|\[\s*\d+\s*/\s*\d+\s*\]"
|
| 78 |
+
r"|\d+(?:\.\d+)?(?:us|ms|s)|\d+m \d+s|\d+h \d+m"
|
| 79 |
+
)
|
| 80 |
+
_PYTEST_VERBOSE_RE = re.compile(
|
| 81 |
+
r"^(?P<name>.+?(?:\[.*?\])?)\s+(?P<status>PASSED|FAILED|SKIPPED|ERROR)"
|
| 82 |
+
rf"(?:\s+\(.*\))?(?:\s+(?:{_PYTEST_PROGRESS}))?$"
|
| 83 |
+
)
|
| 84 |
+
_PYTEST_SUMMARY_NAME_RE = re.compile(r"^(?P<name>.+?(?:\[.*?\])?)(?: - .*)?$")
|
| 85 |
+
# pytest-xdist worker label, e.g. `[gw1] [ 20%] PASSED tests/foo.py::test_x`.
|
| 86 |
+
_PYTEST_XDIST_PREFIX_RE = re.compile(rf"^\[gw\d+\]\s+(?:(?:{_PYTEST_PROGRESS})\s+)?")
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def parse_pytest(log: str) -> dict[str, str]:
|
| 90 |
+
"""{test_name -> status} from pytest output (verbose or summary)."""
|
| 91 |
+
out: dict[str, str] = {}
|
| 92 |
+
if not log:
|
| 93 |
+
return out
|
| 94 |
+
for raw in log.split("\n"):
|
| 95 |
+
line = raw.strip()
|
| 96 |
+
if not line:
|
| 97 |
+
continue
|
| 98 |
+
line = _PYTEST_XDIST_PREFIX_RE.sub("", line, count=1)
|
| 99 |
+
# Summary lines (STATUS first), preserving the full node ID.
|
| 100 |
+
leading = None
|
| 101 |
+
for st in _PYTEST_STATUSES:
|
| 102 |
+
if line.startswith(st + " ") or line == st:
|
| 103 |
+
leading = st
|
| 104 |
+
break
|
| 105 |
+
if leading is not None:
|
| 106 |
+
work = line[len(leading) :].strip()
|
| 107 |
+
if leading == SKIPPED and re.match(r"^\[\d+\](?:\s|$)", work):
|
| 108 |
+
# Folded skips report a file location, not a parametrized ID.
|
| 109 |
+
tokens = work.split(maxsplit=2)
|
| 110 |
+
if len(tokens) < 2:
|
| 111 |
+
continue
|
| 112 |
+
out[tokens[1]] = leading
|
| 113 |
+
elif m := _PYTEST_SUMMARY_NAME_RE.match(work):
|
| 114 |
+
out[m.group("name")] = leading
|
| 115 |
+
continue
|
| 116 |
+
# Verbose progress (NAME first, STATUS after)
|
| 117 |
+
# Filter non-test output before attempting the backtracking regex.
|
| 118 |
+
head = line.split(None, 1)[0]
|
| 119 |
+
if "::" not in head and not head.endswith(".py"):
|
| 120 |
+
continue
|
| 121 |
+
m = _PYTEST_VERBOSE_RE.match(line)
|
| 122 |
+
if m:
|
| 123 |
+
name = m.group("name")
|
| 124 |
+
if "::" in name or name.endswith(".py"):
|
| 125 |
+
out[name] = m.group("status")
|
| 126 |
+
return out
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
_GO_TEST_RE = re.compile(r"^\s*---\s+(?P<status>PASS|FAIL|SKIP):\s+(?P<name>\S+)")
|
| 130 |
+
_GO_STATUS = {"PASS": PASSED, "FAIL": FAILED, "SKIP": SKIPPED}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def parse_go_test(log: str) -> dict[str, str]:
|
| 134 |
+
"""{test_name -> status} from `go test -v` output."""
|
| 135 |
+
out: dict[str, str] = {}
|
| 136 |
+
if not log:
|
| 137 |
+
return out
|
| 138 |
+
for raw in log.split("\n"):
|
| 139 |
+
m = _GO_TEST_RE.match(raw)
|
| 140 |
+
if m:
|
| 141 |
+
out[m.group("name")] = _GO_STATUS[m.group("status")]
|
| 142 |
+
return out
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
# Keep these patterns in sync with log_parsers/cargo_parser.py.
|
| 146 |
+
_CARGO_TEST_RE = re.compile(r"^test\s+(?P<name>\S.*?) \.\.\. (?P<status>ok|FAILED|ignored)\b")
|
| 147 |
+
_CARGO_MODE_RE = re.compile(r" - (?:should panic|compile fail|compile)$")
|
| 148 |
+
_CARGO_DOCTEST_RE = re.compile(r"^(?P<file>\S+) - (?:(?P<item>.+?) )?\(line \d+\)$")
|
| 149 |
+
_CARGO_STATUS = {"ok": PASSED, "FAILED": FAILED, "ignored": SKIPPED}
|
| 150 |
+
_CARGO_DOCTEST_RANK = {SKIPPED: 0, PASSED: 1, FAILED: 2}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def parse_cargo_test(log: str) -> dict[str, str]:
|
| 154 |
+
"""{test_name -> status} from `cargo test` output.
|
| 155 |
+
|
| 156 |
+
Test modes (` - should panic`) are dropped from names, and doctests are
|
| 157 |
+
keyed without their `(line N)` so line shifts don't change identity; the
|
| 158 |
+
worst status among an item's doctests wins.
|
| 159 |
+
"""
|
| 160 |
+
out: dict[str, str] = {}
|
| 161 |
+
if not log:
|
| 162 |
+
return out
|
| 163 |
+
for raw in log.split("\n"):
|
| 164 |
+
m = _CARGO_TEST_RE.match(raw)
|
| 165 |
+
if not m:
|
| 166 |
+
continue
|
| 167 |
+
name = _CARGO_MODE_RE.sub("", m.group("name")).rstrip()
|
| 168 |
+
status = _CARGO_STATUS[m.group("status")]
|
| 169 |
+
doctest = _CARGO_DOCTEST_RE.match(name)
|
| 170 |
+
if doctest:
|
| 171 |
+
item = doctest.group("item")
|
| 172 |
+
name = f"{doctest.group('file')} - {item}" if item else doctest.group("file")
|
| 173 |
+
if name in out and _CARGO_DOCTEST_RANK[out[name]] > _CARGO_DOCTEST_RANK[status]:
|
| 174 |
+
continue
|
| 175 |
+
out[name] = status
|
| 176 |
+
return out
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
_JEST_FILE_RE = re.compile(r"^ ?(?:PASS|FAIL)\s+(?P<path>\S+\.(?:ts|tsx|js|jsx|mjs|cjs))\b")
|
| 180 |
+
_JEST_TEST_RE = re.compile(
|
| 181 |
+
r"^(?P<indent>\s*)(?P<glyph>✓|√|✕|×|✗|○|◯)\s+(?P<name>.+?)(?:\s+\(\d+(?:\.\d+)?\s*m?s\))?$"
|
| 182 |
+
)
|
| 183 |
+
_JEST_GLYPH = {
|
| 184 |
+
"✓": PASSED,
|
| 185 |
+
"√": PASSED,
|
| 186 |
+
"✕": FAILED,
|
| 187 |
+
"×": FAILED,
|
| 188 |
+
"✗": FAILED,
|
| 189 |
+
"○": SKIPPED,
|
| 190 |
+
"◯": SKIPPED,
|
| 191 |
+
}
|
| 192 |
+
# Keep these patterns in sync with log_parsers/jest_parser.py.
|
| 193 |
+
_ANSI_RE = re.compile(r"\x1b\[[0-9;?]*[A-Za-z]")
|
| 194 |
+
_VITEST_MARKER_RE = re.compile(r"^\s*(?:RUN\s+v\d+\.\d+|Test Files\s+\d)", re.MULTILINE)
|
| 195 |
+
_VITEST_TEST_RE = re.compile(
|
| 196 |
+
r"^\s*(?P<glyph>[✓×↓□]) (?:\|(?P<project>[^|]+)\| | (?P<label>\S+) )?"
|
| 197 |
+
r"(?P<name>\S+ > .+?)(?P<duration> \d{1,9}ms)?"
|
| 198 |
+
r"(?: \(retry x\d{1,9}\))?(?: \(repeat x\d{1,9}\))?(?: \d{1,9} MB heap used)?(?: \[[^\[\]]*\])?$"
|
| 199 |
+
)
|
| 200 |
+
_VITEST_STATUS = {"✓": PASSED, "×": FAILED, "↓": SKIPPED, "□": SKIPPED}
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def _parse_vitest(log: str) -> dict[str, str]:
|
| 204 |
+
"""{test_name -> status} from vitest `--reporter=verbose` lines only."""
|
| 205 |
+
out: dict[str, str] = {}
|
| 206 |
+
for raw in log.split("\n"):
|
| 207 |
+
m = _VITEST_TEST_RE.match(raw.rstrip())
|
| 208 |
+
if not m:
|
| 209 |
+
continue
|
| 210 |
+
glyph, name = m.group("glyph"), m.group("name")
|
| 211 |
+
if glyph in "↓□" and m.group("duration"):
|
| 212 |
+
name += m.group("duration")
|
| 213 |
+
project = m.group("project") or m.group("label")
|
| 214 |
+
out[f"|{project}| {name}" if project else name] = _VITEST_STATUS[glyph]
|
| 215 |
+
return out
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def parse_jest(log: str) -> dict[str, str]:
|
| 219 |
+
"""{test_name -> status} from Jest / Mocha / Vitest output."""
|
| 220 |
+
out: dict[str, str] = {}
|
| 221 |
+
if not log:
|
| 222 |
+
return out
|
| 223 |
+
log = _ANSI_RE.sub("", log)
|
| 224 |
+
if _VITEST_MARKER_RE.search(log):
|
| 225 |
+
return _parse_vitest(log)
|
| 226 |
+
current_file: str | None = None
|
| 227 |
+
describe_stack: list[tuple[int, str]] = []
|
| 228 |
+
last_test_indent: int | None = None
|
| 229 |
+
for raw in log.split("\n"):
|
| 230 |
+
line = raw.rstrip()
|
| 231 |
+
if not line:
|
| 232 |
+
continue
|
| 233 |
+
m = _JEST_FILE_RE.match(line)
|
| 234 |
+
if m:
|
| 235 |
+
current_file = m.group("path")
|
| 236 |
+
describe_stack = []
|
| 237 |
+
last_test_indent = None
|
| 238 |
+
continue
|
| 239 |
+
m = _JEST_TEST_RE.match(line)
|
| 240 |
+
if m:
|
| 241 |
+
indent = len(m.group("indent"))
|
| 242 |
+
name = re.sub(r"^(?:skipped|todo):\s*", "", m.group("name").strip())
|
| 243 |
+
describes = [d for ind, d in describe_stack if ind < indent]
|
| 244 |
+
parts = ([current_file] if current_file else []) + describes + [name]
|
| 245 |
+
out[" > ".join(parts)] = _JEST_GLYPH[m.group("glyph")]
|
| 246 |
+
last_test_indent = indent
|
| 247 |
+
continue
|
| 248 |
+
stripped = line.lstrip()
|
| 249 |
+
if not stripped or stripped.startswith(
|
| 250 |
+
("Tests:", "Test Suites:", "Snapshots:", "Time:", "Ran all", "●", "→", "✗:")
|
| 251 |
+
):
|
| 252 |
+
continue
|
| 253 |
+
indent_here = len(line) - len(stripped)
|
| 254 |
+
if current_file and (last_test_indent is None or indent_here < last_test_indent):
|
| 255 |
+
describe_stack = [(i, d) for i, d in describe_stack if i < indent_here]
|
| 256 |
+
describe_stack.append((indent_here, stripped))
|
| 257 |
+
return out
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
def _detect_runner(test_cmds: str) -> str:
|
| 261 |
+
joined = test_cmds.lower()
|
| 262 |
+
if "pytest" in joined:
|
| 263 |
+
return "pytest"
|
| 264 |
+
if re.search(r"\bgo\s+test\b", joined):
|
| 265 |
+
return "go"
|
| 266 |
+
if re.search(r"\bcargo\s+test\b", joined):
|
| 267 |
+
return "cargo"
|
| 268 |
+
if any(k in joined for k in ("jest", "mocha", "vitest", "npm test", "yarn test", "pnpm test")):
|
| 269 |
+
return "jest"
|
| 270 |
+
return "unknown"
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
def parse_logs(runner: str, log: str) -> dict[str, str]:
|
| 274 |
+
"""Dispatch to the right per-runner parser. Empty dict if unknown."""
|
| 275 |
+
if runner == "pytest":
|
| 276 |
+
return parse_pytest(log)
|
| 277 |
+
if runner == "go":
|
| 278 |
+
return parse_go_test(log)
|
| 279 |
+
if runner == "cargo":
|
| 280 |
+
return parse_cargo_test(log)
|
| 281 |
+
if runner == "jest":
|
| 282 |
+
return parse_jest(log)
|
| 283 |
+
return {}
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
# ---------------------------------------------------------------------------
|
| 287 |
+
# Grading
|
| 288 |
+
# ---------------------------------------------------------------------------
|
| 289 |
+
def _has_go_parent(name: str, status_map: dict[str, str]) -> bool:
|
| 290 |
+
"""Return True if a Go test has an ancestor represented in the status map."""
|
| 291 |
+
parts = name.split("/")
|
| 292 |
+
|
| 293 |
+
for i in range(1, len(parts)):
|
| 294 |
+
parent = "/".join(parts[:i])
|
| 295 |
+
if status_map.get(parent) == FAILED:
|
| 296 |
+
return True
|
| 297 |
+
|
| 298 |
+
return False
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def grade(
|
| 302 |
+
fail_to_pass: list[str],
|
| 303 |
+
pass_to_pass: list[str],
|
| 304 |
+
status_map: dict[str, str],
|
| 305 |
+
runner: str | None = None,
|
| 306 |
+
) -> dict:
|
| 307 |
+
"""Compute the graded reward + strict resolved bool from a status map.
|
| 308 |
+
|
| 309 |
+
f2p_rate = (# F2P now PASSED) / (# F2P)
|
| 310 |
+
p2p_rate = (# P2P still PASSED) / (# P2P) [1.0 when no P2P]
|
| 311 |
+
reward = f2p_rate * p2p_rate (dense training signal)
|
| 312 |
+
resolved = all F2P pass AND all P2P pass (SWE-bench TRACKED resolution —
|
| 313 |
+
the gold patch always satisfies this, preserving the oracle
|
| 314 |
+
invariant)
|
| 315 |
+
|
| 316 |
+
Two distinct EVAL signals (see the audit's "tracked vs command resolved"):
|
| 317 |
+
* `resolved` — tracked resolution (above). Gold patch -> True.
|
| 318 |
+
* `command_resolved` — stricter: tracked resolution AND the selected test
|
| 319 |
+
command had NO failures outside F2P/P2P AND exit
|
| 320 |
+
code 0. Computed in main() where the exit code is
|
| 321 |
+
known. A benchmark that wants "the whole command
|
| 322 |
+
passed cleanly" gates on this; SWE-bench-style
|
| 323 |
+
scoring uses `resolved`.
|
| 324 |
+
|
| 325 |
+
`untracked_failed` are FAILED tests in the run that are neither F2P nor
|
| 326 |
+
P2P (e.g. always-failing/flaky tests pulled in by running a whole test
|
| 327 |
+
file). They don't change the graded `reward` or tracked `resolved`, but
|
| 328 |
+
they block `command_resolved` and are recorded for transparency.
|
| 329 |
+
"""
|
| 330 |
+
f2p_total = len(fail_to_pass)
|
| 331 |
+
p2p_total = len(pass_to_pass)
|
| 332 |
+
f2p_set = set(fail_to_pass)
|
| 333 |
+
p2p_set = set(pass_to_pass)
|
| 334 |
+
f2p_passed = sum(1 for t in fail_to_pass if status_map.get(t) == PASSED)
|
| 335 |
+
p2p_passed = sum(1 for t in pass_to_pass if status_map.get(t) == PASSED)
|
| 336 |
+
# Tests that should have stayed green but regressed (PASS->not-pass).
|
| 337 |
+
regressions = [t for t in pass_to_pass if status_map.get(t) != PASSED]
|
| 338 |
+
|
| 339 |
+
# FAILED tests outside the tracked sets — the selected command isn't clean.
|
| 340 |
+
if runner == "go":
|
| 341 |
+
failed_tests = {
|
| 342 |
+
t
|
| 343 |
+
for t, s in status_map.items()
|
| 344 |
+
if s == FAILED and t not in f2p_set and t not in p2p_set
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
untracked_failed = sorted(t for t in failed_tests if not _has_go_parent(t, status_map))
|
| 348 |
+
else:
|
| 349 |
+
untracked_failed = sorted(
|
| 350 |
+
t
|
| 351 |
+
for t, s in status_map.items()
|
| 352 |
+
if s == FAILED and t not in f2p_set and t not in p2p_set
|
| 353 |
+
)
|
| 354 |
+
|
| 355 |
+
f2p_rate = (f2p_passed / f2p_total) if f2p_total else 0.0
|
| 356 |
+
p2p_rate = (p2p_passed / p2p_total) if p2p_total else 1.0
|
| 357 |
+
reward = f2p_rate * p2p_rate
|
| 358 |
+
resolved = f2p_total > 0 and f2p_passed == f2p_total and p2p_passed == p2p_total
|
| 359 |
+
|
| 360 |
+
return {
|
| 361 |
+
"reward": round(max(0.0, min(1.0, reward)), 6),
|
| 362 |
+
"resolved": resolved,
|
| 363 |
+
"f2p_total": f2p_total,
|
| 364 |
+
"f2p_passed": f2p_passed,
|
| 365 |
+
"f2p_rate": round(f2p_rate, 6),
|
| 366 |
+
"p2p_total": p2p_total,
|
| 367 |
+
"p2p_passed": p2p_passed,
|
| 368 |
+
"p2p_rate": round(p2p_rate, 6),
|
| 369 |
+
"regressions": sorted(regressions),
|
| 370 |
+
"untracked_failed_count": len(untracked_failed),
|
| 371 |
+
"untracked_failed": untracked_failed[:20], # cap the list
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
# ---------------------------------------------------------------------------
|
| 376 |
+
# Entry point (invoked by tests/test.sh inside the container)
|
| 377 |
+
# ---------------------------------------------------------------------------
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
def _read_json_list(path: str) -> list[str]:
|
| 381 |
+
try:
|
| 382 |
+
with open(path, encoding="utf-8") as f:
|
| 383 |
+
data = json.load(f)
|
| 384 |
+
return [str(x) for x in data] if isinstance(data, list) else []
|
| 385 |
+
except (OSError, ValueError):
|
| 386 |
+
return []
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
def _read_text(path: str) -> str:
|
| 390 |
+
try:
|
| 391 |
+
with open(path, encoding="utf-8") as f:
|
| 392 |
+
return f.read()
|
| 393 |
+
except (OSError, UnicodeDecodeError):
|
| 394 |
+
return ""
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
def main(argv: list[str] | None = None) -> int:
|
| 398 |
+
p = argparse.ArgumentParser(description="pr_runtime graded F2P/P2P verifier")
|
| 399 |
+
p.add_argument("--log", required=True, help="captured test-run log file")
|
| 400 |
+
p.add_argument("--f2p", required=True, help="JSON file: FAIL_TO_PASS test names")
|
| 401 |
+
p.add_argument("--p2p", required=True, help="JSON file: PASS_TO_PASS test names")
|
| 402 |
+
p.add_argument("--runner", default="", help="pytest|go|cargo|jest (else auto-detect)")
|
| 403 |
+
p.add_argument("--test-cmds", default="", help="test command string (runner auto-detect)")
|
| 404 |
+
p.add_argument("--exit-code", type=int, default=1, help="test suite exit code (fallback)")
|
| 405 |
+
p.add_argument("--out-dir", default="/logs/verifier", help="where to write reward.{txt,json}")
|
| 406 |
+
args = p.parse_args(argv)
|
| 407 |
+
|
| 408 |
+
log = _read_text(args.log)
|
| 409 |
+
f2p = _read_json_list(args.f2p)
|
| 410 |
+
p2p = _read_json_list(args.p2p)
|
| 411 |
+
runner = args.runner.strip() or _detect_runner(args.test_cmds)
|
| 412 |
+
|
| 413 |
+
status_map = parse_logs(runner, log)
|
| 414 |
+
|
| 415 |
+
if not status_map:
|
| 416 |
+
# Unparseable runner output → fall back to the binary exit-code reward
|
| 417 |
+
# (a coarse TRAINING signal) so we never silently zero a real fix on an
|
| 418 |
+
# unrecognized format. But `resolved` is the strict EVAL signal: without
|
| 419 |
+
# parsed per-test status we have NO evidence the declared FAIL_TO_PASS
|
| 420 |
+
# tests passed, so when an F2P oracle exists we must NOT claim resolved.
|
| 421 |
+
# (resolved stays exit-code-based only when there's no declared oracle,
|
| 422 |
+
# e.g. --skip-validation.)
|
| 423 |
+
reward = 1.0 if args.exit_code == 0 else 0.0
|
| 424 |
+
has_oracle = len(f2p) > 0
|
| 425 |
+
resolved = (args.exit_code == 0) and not has_oracle
|
| 426 |
+
breakdown = {
|
| 427 |
+
"reward": reward,
|
| 428 |
+
"resolved": resolved,
|
| 429 |
+
"command_resolved": bool(resolved and args.exit_code == 0),
|
| 430 |
+
"parse_status": "fallback_exitcode",
|
| 431 |
+
"eval_trustworthy": not has_oracle,
|
| 432 |
+
"runner": runner,
|
| 433 |
+
"f2p_total": len(f2p),
|
| 434 |
+
"p2p_total": len(p2p),
|
| 435 |
+
"exit_code": args.exit_code,
|
| 436 |
+
}
|
| 437 |
+
else:
|
| 438 |
+
breakdown = grade(f2p, p2p, status_map, runner)
|
| 439 |
+
breakdown["parse_status"] = "ok"
|
| 440 |
+
breakdown["runner"] = runner
|
| 441 |
+
breakdown["tests_parsed"] = len(status_map)
|
| 442 |
+
breakdown["exit_code"] = args.exit_code
|
| 443 |
+
# Strict eval signal: tracked resolution AND a clean command (no
|
| 444 |
+
# untracked failures, exit code 0). Benchmarks wanting "the whole test
|
| 445 |
+
# command passed" gate on this; SWE-bench-style scoring uses `resolved`.
|
| 446 |
+
breakdown["command_resolved"] = bool(
|
| 447 |
+
breakdown["resolved"]
|
| 448 |
+
and breakdown["untracked_failed_count"] == 0
|
| 449 |
+
and args.exit_code == 0
|
| 450 |
+
)
|
| 451 |
+
reward = breakdown["reward"]
|
| 452 |
+
|
| 453 |
+
os.makedirs(args.out_dir, exist_ok=True)
|
| 454 |
+
with open(os.path.join(args.out_dir, "reward.txt"), "w", encoding="utf-8") as f:
|
| 455 |
+
f.write(f"{reward:.6f}\n")
|
| 456 |
+
with open(os.path.join(args.out_dir, "reward-details.json"), "w", encoding="utf-8") as f:
|
| 457 |
+
json.dump(breakdown, f, indent=2)
|
| 458 |
+
|
| 459 |
+
print(json.dumps(breakdown, indent=2))
|
| 460 |
+
return 0
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
if __name__ == "__main__":
|
| 464 |
+
sys.exit(main())
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
__all__ = [
|
| 468 |
+
"grade",
|
| 469 |
+
"main",
|
| 470 |
+
"parse_cargo_test",
|
| 471 |
+
"parse_go_test",
|
| 472 |
+
"parse_jest",
|
| 473 |
+
"parse_logs",
|
| 474 |
+
"parse_pytest",
|
| 475 |
+
]
|
heldout/RDFLib__rdflib-607e086b11a9/environment/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv pr_runtime
|
| 2 |
+
FROM local/RDFLib__rdflib
|
| 3 |
+
WORKDIR /workspace
|
| 4 |
+
# Defensive: ensure git is on PATH at build time. Bootstrap base
|
| 5 |
+
# images vary — some (Python slim) don't ship git; some agents
|
| 6 |
+
# install it; others don't. Re-installing is a no-op when already
|
| 7 |
+
# present. Tries apt-get first (Debian/Ubuntu), then apk (Alpine).
|
| 8 |
+
# Install git + ca-certificates. Minimal images (node:alpine) ship
|
| 9 |
+
# without CA certs, so HTTPS git fetch fails verification.
|
| 10 |
+
RUN (command -v git >/dev/null 2>&1 && [ -e /etc/ssl/certs/ca-certificates.crt ]) || \
|
| 11 |
+
(apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*) || \
|
| 13 |
+
(apk add --no-cache git ca-certificates && update-ca-certificates) || true
|
| 14 |
+
# Defensive: the graded F2P/P2P verifier is Python.
|
| 15 |
+
# Language-specific bootstrap images (Go/Rust/Node) may not
|
| 16 |
+
# ship python3 — install it so test.sh can score F2P/P2P. No-op when
|
| 17 |
+
# python3 is already present (every Python-repo image has it).
|
| 18 |
+
RUN command -v python3 >/dev/null 2>&1 || \
|
| 19 |
+
(apt-get update && apt-get install -y --no-install-recommends python3 \
|
| 20 |
+
&& rm -rf /var/lib/apt/lists/*) || \
|
| 21 |
+
apk add --no-cache python3 || true
|
| 22 |
+
# Position the working tree at the PR's base commit so subsequent
|
| 23 |
+
# model-patch applications align with the line context the patch
|
| 24 |
+
# was authored against. The fetch is a no-op if the commit is
|
| 25 |
+
# already in the shallow clone.
|
| 26 |
+
RUN git config --global --add safe.directory /workspace \
|
| 27 |
+
&& git fetch --depth 1 origin b459049af00b1cdd1453bf99344636b0cbc910df 2>/dev/null \
|
| 28 |
+
|| git fetch --unshallow origin 2>/dev/null || true
|
| 29 |
+
RUN git reset --hard b459049af00b1cdd1453bf99344636b0cbc910df && git clean -fdx -e .venv -e venv -e __pycache__ -e .tox -e node_modules -e target -e vendor -e .gradle -e .next -e .pytest_cache
|
| 30 |
+
RUN git checkout -q -B base b459049af00b1cdd1453bf99344636b0cbc910df \
|
| 31 |
+
&& git remote remove origin 2>/dev/null || true
|
| 32 |
+
RUN for ref in $(git branch --format='%(refname:short)' | grep -vx base); do git branch -D "$ref" 2>/dev/null || true; done \
|
| 33 |
+
&& git tag -l | xargs -r git tag -d >/dev/null 2>&1 || true \
|
| 34 |
+
&& git for-each-ref --format='%(refname)' refs/remotes 2>/dev/null | xargs -r -n1 git update-ref -d 2>/dev/null || true \
|
| 35 |
+
&& git reflog expire --expire=now --all 2>/dev/null || true \
|
| 36 |
+
&& git gc --prune=now 2>/dev/null || true
|
heldout/RDFLib__rdflib-607e086b11a9/environment/docker-compose.yaml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv: anti-contamination egress guard.
|
| 2 |
+
# Blackholes the hosts that serve this repo's published fix and hidden
|
| 3 |
+
# tests, so an agent cannot fetch the answer (pip download / git fetch /
|
| 4 |
+
# WebFetch against these fail). General internet stays up so the agent
|
| 5 |
+
# can install itself and reach its model API. See pipelines/_env_guard.py.
|
| 6 |
+
services:
|
| 7 |
+
main:
|
| 8 |
+
extra_hosts:
|
| 9 |
+
- "pypi.org:0.0.0.0"
|
| 10 |
+
- "pypi.python.org:0.0.0.0"
|
| 11 |
+
- "files.pythonhosted.org:0.0.0.0"
|
| 12 |
+
- "github.com:0.0.0.0"
|
| 13 |
+
- "api.github.com:0.0.0.0"
|
| 14 |
+
- "raw.githubusercontent.com:0.0.0.0"
|
| 15 |
+
- "codeload.github.com:0.0.0.0"
|
| 16 |
+
- "objects.githubusercontent.com:0.0.0.0"
|
heldout/RDFLib__rdflib-607e086b11a9/instruction.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue
|
| 2 |
+
|
| 3 |
+
**Title:** Internal ConjunctiveGraph warning displayed when processing JSON-LD
|
| 4 |
+
|
| 5 |
+
## Description
|
| 6 |
+
When processing JSON-LD data, an internal `ConjunctiveGraph` warning is unexpectedly displayed in the console or logs. This warning indicates the use of a deprecated component within the library. The expected behavior is that no such warning should appear, ensuring clean output and indicating up-to-date internal component usage.
|
| 7 |
+
|
| 8 |
+
## Task
|
| 9 |
+
|
| 10 |
+
Modify the repository so that the issue described above is resolved. The task's test suite verifies your patch by applying it on top of the base commit `b459049af00b` and running the modified tests.
|
heldout/RDFLib__rdflib-607e086b11a9/solution/patch.diff
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/rdflib/plugins/parsers/jsonld.py b/rdflib/plugins/parsers/jsonld.py
|
| 2 |
+
index fe9503b5..30339be6 100644
|
| 3 |
+
--- a/rdflib/plugins/parsers/jsonld.py
|
| 4 |
+
+++ b/rdflib/plugins/parsers/jsonld.py
|
| 5 |
+
@@ -38,7 +38,7 @@ import warnings
|
| 6 |
+
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Union
|
| 7 |
+
|
| 8 |
+
import rdflib.parser
|
| 9 |
+
-from rdflib.graph import ConjunctiveGraph, Graph
|
| 10 |
+
+from rdflib.graph import Dataset, Graph
|
| 11 |
+
from rdflib.namespace import RDF, XSD
|
| 12 |
+
from rdflib.parser import InputSource, URLInputSource
|
| 13 |
+
from rdflib.term import BNode, IdentifiedNode, Literal, Node, URIRef
|
| 14 |
+
@@ -77,6 +77,39 @@ TYPE_TERM = Term(str(RDF.type), TYPE, VOCAB) # type: ignore[call-arg]
|
| 15 |
+
ALLOW_LISTS_OF_LISTS = True # NOTE: Not allowed in JSON-LD 1.0
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
+class _ContextAwareGraph(Graph):
|
| 19 |
+
+ """Context-aware graph view used while parsing JSON-LD into a Graph sink."""
|
| 20 |
+
+
|
| 21 |
+
+ def __init__(self, sink: Graph):
|
| 22 |
+
+ super().__init__(store=sink.store, identifier=sink.identifier)
|
| 23 |
+
+ assert (
|
| 24 |
+
+ self.store.context_aware
|
| 25 |
+
+ ), "JSON-LD named graphs require a context-aware store."
|
| 26 |
+
+ self.context_aware = True
|
| 27 |
+
+ self.default_union = True
|
| 28 |
+
+ self._default_context = Graph(
|
| 29 |
+
+ store=self.store,
|
| 30 |
+
+ identifier=sink.identifier,
|
| 31 |
+
+ )
|
| 32 |
+
+
|
| 33 |
+
+ @property
|
| 34 |
+
+ def default_context(self) -> Graph:
|
| 35 |
+
+ return self._default_context
|
| 36 |
+
+
|
| 37 |
+
+ def get_context(
|
| 38 |
+
+ self,
|
| 39 |
+
+ identifier: Optional[Union[IdentifiedNode, str]],
|
| 40 |
+
+ quoted: bool = False,
|
| 41 |
+
+ base: Optional[str] = None,
|
| 42 |
+
+ ) -> Graph:
|
| 43 |
+
+ return Graph(
|
| 44 |
+
+ store=self.store,
|
| 45 |
+
+ identifier=identifier,
|
| 46 |
+
+ namespace_manager=self.namespace_manager,
|
| 47 |
+
+ base=base,
|
| 48 |
+
+ )
|
| 49 |
+
+
|
| 50 |
+
+
|
| 51 |
+
class JsonLDParser(rdflib.parser.Parser):
|
| 52 |
+
def __init__(self):
|
| 53 |
+
super(JsonLDParser, self).__init__()
|
| 54 |
+
@@ -151,18 +184,19 @@ class JsonLDParser(rdflib.parser.Parser):
|
| 55 |
+
if html_base is not None:
|
| 56 |
+
base = URIRef(html_base, base=base)
|
| 57 |
+
|
| 58 |
+
- # NOTE: A ConjunctiveGraph parses into a Graph sink, so no sink will be
|
| 59 |
+
- # context_aware. Keeping this check in case RDFLib is changed, or
|
| 60 |
+
- # someone passes something context_aware to this parser directly.
|
| 61 |
+
- conj_sink: Graph
|
| 62 |
+
+ # Graph.parse passes a non-context-aware Graph sink to parsers. JSON-LD
|
| 63 |
+
+ # needs a context-aware view to preserve named graphs, but Dataset would
|
| 64 |
+
+ # additionally require a graph-aware store. Use a minimal internal view
|
| 65 |
+
+ # that preserves the existing context-aware store contract.
|
| 66 |
+
+ context_sink: Graph
|
| 67 |
+
if not sink.context_aware:
|
| 68 |
+
- conj_sink = ConjunctiveGraph(store=sink.store, identifier=sink.identifier)
|
| 69 |
+
+ context_sink = _ContextAwareGraph(sink)
|
| 70 |
+
else:
|
| 71 |
+
- conj_sink = sink
|
| 72 |
+
+ context_sink = sink
|
| 73 |
+
|
| 74 |
+
to_rdf(
|
| 75 |
+
data,
|
| 76 |
+
- conj_sink,
|
| 77 |
+
+ context_sink,
|
| 78 |
+
base,
|
| 79 |
+
context_data,
|
| 80 |
+
version,
|
| 81 |
+
@@ -236,8 +270,13 @@ class Parser:
|
| 82 |
+
if term.id and term.id.endswith(VOCAB_DELIMS):
|
| 83 |
+
dataset.bind(name, term.id)
|
| 84 |
+
|
| 85 |
+
- # type error: "Graph" has no attribute "default_context"
|
| 86 |
+
- graph = dataset.default_context if dataset.context_aware else dataset # type: ignore[attr-defined]
|
| 87 |
+
+ if isinstance(dataset, Dataset):
|
| 88 |
+
+ graph = dataset.default_graph
|
| 89 |
+
+ elif dataset.context_aware:
|
| 90 |
+
+ # type error: "Graph" has no attribute "default_context"
|
| 91 |
+
+ graph = dataset.default_context # type: ignore[attr-defined]
|
| 92 |
+
+ else:
|
| 93 |
+
+ graph = dataset
|
| 94 |
+
|
| 95 |
+
for node in resources:
|
| 96 |
+
self._add_to_graph(dataset, graph, context, node, topcontext)
|
| 97 |
+
@@ -360,10 +399,8 @@ class Parser:
|
| 98 |
+
|
| 99 |
+
if GRAPH in (key, term_id):
|
| 100 |
+
if dataset.context_aware and not no_id:
|
| 101 |
+
- if TYPE_CHECKING:
|
| 102 |
+
- assert isinstance(dataset, ConjunctiveGraph)
|
| 103 |
+
- # type error: Argument 1 to "get_context" of "ConjunctiveGraph" has incompatible type "Node"; expected "Union[IdentifiedNode, str, None]"
|
| 104 |
+
- subgraph = dataset.get_context(subj) # type: ignore[arg-type]
|
| 105 |
+
+ # type error: "Graph" has no attribute "get_context"
|
| 106 |
+
+ subgraph = dataset.get_context(subj) # type: ignore[attr-defined]
|
| 107 |
+
else:
|
| 108 |
+
subgraph = graph
|
| 109 |
+
for onode in obj_nodes:
|
heldout/RDFLib__rdflib-607e086b11a9/solution/solve.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euxo pipefail
|
| 3 |
+
cd /workspace
|
| 4 |
+
git config --global --add safe.directory /workspace
|
| 5 |
+
PATCH="$(dirname "$0")/patch.diff"
|
| 6 |
+
git apply --verbose --reject "$PATCH"
|
heldout/RDFLib__rdflib-607e086b11a9/task.toml
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "commit-runtime/RDFLib__rdflib-607e086b11a9"
|
| 5 |
+
description = "Fix/jsonld internal conjunctivegraph warning (#3495)"
|
| 6 |
+
|
| 7 |
+
[metadata]
|
| 8 |
+
difficulty = "medium"
|
| 9 |
+
category = "bugfix"
|
| 10 |
+
keywords = [
|
| 11 |
+
"rdflib",
|
| 12 |
+
"commit_runtime",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
[metadata.repo2env]
|
| 16 |
+
pipeline = "commit_runtime"
|
| 17 |
+
pipeline_version = "0.8.3"
|
| 18 |
+
repo = "RDFLib/rdflib"
|
| 19 |
+
ref = "b459049af00b1cdd1453bf99344636b0cbc910df"
|
| 20 |
+
reference = "https://github.com/RDFLib/rdflib/commit/607e086b11a9d0b465fd034351445200c694f90d"
|
| 21 |
+
source_access = "public"
|
| 22 |
+
built_at = "2026-09-24T13:23:02.648537+00:00"
|
| 23 |
+
synthesis_llm = "gemini/gemini-2.5-flash"
|
| 24 |
+
reward_kinds = [
|
| 25 |
+
"test_execution",
|
| 26 |
+
"diff_similarity",
|
| 27 |
+
]
|
| 28 |
+
spec_version = "0.2.0"
|
| 29 |
+
content_hash = "sha256:10b97f0be0a8896202383cb8d3999e09f2b9b7331bb3b6589b00b954b337d95f"
|
| 30 |
+
|
| 31 |
+
[metadata.repo2env.commit_runtime]
|
| 32 |
+
commit_sha = "607e086b11a9d0b465fd034351445200c694f90d"
|
| 33 |
+
parent_sha = "b459049af00b1cdd1453bf99344636b0cbc910df"
|
| 34 |
+
authored_at = "2026-08-11T08:00:29+02:00"
|
| 35 |
+
author_email = "danielmolinero111@gmail.com"
|
| 36 |
+
subject = "Fix/jsonld internal conjunctivegraph warning (#3495)"
|
| 37 |
+
fail_to_pass = [
|
| 38 |
+
"test/jsonld/test_parser_deprecation_warnings.py::test_dataset_jsonld_parse_does_not_warn_about_conjunctive_graph",
|
| 39 |
+
"test/jsonld/test_parser_deprecation_warnings.py::test_graph_jsonld_parse_does_not_warn_about_conjunctive_graph",
|
| 40 |
+
"test/jsonld/test_parser_deprecation_warnings.py::test_graph_jsonld_parse_preserves_named_graphs",
|
| 41 |
+
"test/jsonld/test_parser_deprecation_warnings.py::test_graph_jsonld_parse_preserves_target_context",
|
| 42 |
+
"test/jsonld/test_parser_deprecation_warnings.py::test_graph_jsonld_parse_supports_context_aware_non_graph_aware_store",
|
| 43 |
+
]
|
| 44 |
+
pass_to_pass = []
|
| 45 |
+
validation_status = "verified"
|
| 46 |
+
bootstrap_image = "local-venv:RDFLib__rdflib"
|
| 47 |
+
instruction_synthesized = true
|
| 48 |
+
llm_cost_usd = 0.004753
|
| 49 |
+
|
| 50 |
+
[metadata.repo2env.reward_calibration]
|
| 51 |
+
f2p_count = 5
|
| 52 |
+
p2p_count = 0
|
| 53 |
+
source_files = 1
|
| 54 |
+
loc_changed = 65
|
| 55 |
+
difficulty = "medium"
|
| 56 |
+
|
| 57 |
+
[metadata.repo2env.evaluation]
|
| 58 |
+
schema_version = "1"
|
| 59 |
+
status = "unverified"
|
| 60 |
+
stage = "generation"
|
| 61 |
+
reason_codes = [
|
| 62 |
+
"validation_not_run",
|
| 63 |
+
]
|
| 64 |
+
detail = "Generated task; validation has not been established."
|
| 65 |
+
provenance = "unknown"
|
| 66 |
+
evidence = []
|
| 67 |
+
|
| 68 |
+
[metadata.repo2env.reproducibility]
|
| 69 |
+
mode = "local_only"
|
| 70 |
+
image_ref = "local/RDFLib__rdflib"
|
| 71 |
+
image_tag = "local/RDFLib__rdflib"
|
| 72 |
+
image_visibility = "private"
|
| 73 |
+
|
| 74 |
+
[agent]
|
| 75 |
+
timeout_sec = 1800.0
|
| 76 |
+
|
| 77 |
+
[verifier]
|
| 78 |
+
timeout_sec = 300.0
|
heldout/RDFLib__rdflib-607e086b11a9/tests/f2p.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"test/jsonld/test_parser_deprecation_warnings.py::test_dataset_jsonld_parse_does_not_warn_about_conjunctive_graph",
|
| 3 |
+
"test/jsonld/test_parser_deprecation_warnings.py::test_graph_jsonld_parse_does_not_warn_about_conjunctive_graph",
|
| 4 |
+
"test/jsonld/test_parser_deprecation_warnings.py::test_graph_jsonld_parse_preserves_named_graphs",
|
| 5 |
+
"test/jsonld/test_parser_deprecation_warnings.py::test_graph_jsonld_parse_preserves_target_context",
|
| 6 |
+
"test/jsonld/test_parser_deprecation_warnings.py::test_graph_jsonld_parse_supports_context_aware_non_graph_aware_store"
|
| 7 |
+
]
|
heldout/RDFLib__rdflib-607e086b11a9/tests/p2p.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[]
|
heldout/RDFLib__rdflib-607e086b11a9/tests/test.sh
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -uxo pipefail
|
| 3 |
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
| 4 |
+
cd /workspace
|
| 5 |
+
git config --global --add safe.directory /workspace
|
| 6 |
+
mkdir -p /logs/verifier
|
| 7 |
+
git checkout b459049af00b1cdd1453bf99344636b0cbc910df -- test/jsonld/test_parser_deprecation_warnings.py || true
|
| 8 |
+
git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH'
|
| 9 |
+
diff --git a/test/jsonld/test_parser_deprecation_warnings.py b/test/jsonld/test_parser_deprecation_warnings.py
|
| 10 |
+
new file mode 100644
|
| 11 |
+
index 00000000..cf519fd6
|
| 12 |
+
--- /dev/null
|
| 13 |
+
+++ b/test/jsonld/test_parser_deprecation_warnings.py
|
| 14 |
+
@@ -0,0 +1,100 @@
|
| 15 |
+
+from __future__ import annotations
|
| 16 |
+
+
|
| 17 |
+
+import warnings
|
| 18 |
+
+
|
| 19 |
+
+from rdflib import Dataset, Graph, URIRef
|
| 20 |
+
+from rdflib.plugins.stores.auditable import AuditableStore
|
| 21 |
+
+from rdflib.plugins.stores.memory import Memory
|
| 22 |
+
+
|
| 23 |
+
+CONJUNCTIVE_GRAPH_WARNING = r"ConjunctiveGraph is deprecated, use Dataset instead\."
|
| 24 |
+
+
|
| 25 |
+
+SUBJECT = URIRef("http://example.org/subject")
|
| 26 |
+
+PREDICATE = URIRef("http://example.org/predicate")
|
| 27 |
+
+OBJECT = URIRef("http://example.org/object")
|
| 28 |
+
+TRIPLE = (SUBJECT, PREDICATE, OBJECT)
|
| 29 |
+
+
|
| 30 |
+
+SIMPLE_JSONLD = """
|
| 31 |
+
+{
|
| 32 |
+
+ "@context": {"ex": "http://example.org/"},
|
| 33 |
+
+ "@id": "http://example.org/subject",
|
| 34 |
+
+ "ex:predicate": {"@id": "http://example.org/object"}
|
| 35 |
+
+}
|
| 36 |
+
+"""
|
| 37 |
+
+
|
| 38 |
+
+NAMED_GRAPH_ID = URIRef("http://example.org/named-graph")
|
| 39 |
+
+NAMED_GRAPH_JSONLD = """
|
| 40 |
+
+{
|
| 41 |
+
+ "@context": {"ex": "http://example.org/"},
|
| 42 |
+
+ "@id": "http://example.org/named-graph",
|
| 43 |
+
+ "@graph": {
|
| 44 |
+
+ "@id": "http://example.org/subject",
|
| 45 |
+
+ "ex:predicate": {"@id": "http://example.org/object"}
|
| 46 |
+
+ }
|
| 47 |
+
+}
|
| 48 |
+
+"""
|
| 49 |
+
+
|
| 50 |
+
+
|
| 51 |
+
+def parse_without_internal_conjunctive_graph_warning(graph: Graph, data: str) -> None:
|
| 52 |
+
+ """Fail if JSON-LD parsing constructs the deprecated internal adapter."""
|
| 53 |
+
+ with warnings.catch_warnings():
|
| 54 |
+
+ warnings.filterwarnings(
|
| 55 |
+
+ "error",
|
| 56 |
+
+ message=CONJUNCTIVE_GRAPH_WARNING,
|
| 57 |
+
+ category=DeprecationWarning,
|
| 58 |
+
+ )
|
| 59 |
+
+ graph.parse(data=data, format="json-ld")
|
| 60 |
+
+
|
| 61 |
+
+
|
| 62 |
+
+def test_graph_jsonld_parse_does_not_warn_about_conjunctive_graph() -> None:
|
| 63 |
+
+ """Graph.parse must not construct the deprecated ConjunctiveGraph adapter."""
|
| 64 |
+
+ graph = Graph()
|
| 65 |
+
+
|
| 66 |
+
+ parse_without_internal_conjunctive_graph_warning(graph, SIMPLE_JSONLD)
|
| 67 |
+
+
|
| 68 |
+
+ assert TRIPLE in graph
|
| 69 |
+
+
|
| 70 |
+
+
|
| 71 |
+
+def test_dataset_jsonld_parse_does_not_warn_about_conjunctive_graph() -> None:
|
| 72 |
+
+ """Direct Dataset parsing must use its default graph without the legacy warning."""
|
| 73 |
+
+ dataset = Dataset()
|
| 74 |
+
+
|
| 75 |
+
+ parse_without_internal_conjunctive_graph_warning(dataset, SIMPLE_JSONLD)
|
| 76 |
+
+
|
| 77 |
+
+ assert TRIPLE in dataset.default_graph
|
| 78 |
+
+
|
| 79 |
+
+
|
| 80 |
+
+def test_graph_jsonld_parse_preserves_target_context() -> None:
|
| 81 |
+
+ """The context adapter must keep the original Graph identifier as its target."""
|
| 82 |
+
+ identifier = URIRef("urn:test:target")
|
| 83 |
+
+ graph = Graph(identifier=identifier)
|
| 84 |
+
+
|
| 85 |
+
+ parse_without_internal_conjunctive_graph_warning(graph, SIMPLE_JSONLD)
|
| 86 |
+
+
|
| 87 |
+
+ assert TRIPLE in graph
|
| 88 |
+
+ assert TRIPLE not in Graph(
|
| 89 |
+
+ store=graph.store,
|
| 90 |
+
+ identifier=URIRef("urn:test:other"),
|
| 91 |
+
+ )
|
| 92 |
+
+
|
| 93 |
+
+
|
| 94 |
+
+def test_graph_jsonld_parse_preserves_named_graphs() -> None:
|
| 95 |
+
+ """JSON-LD @graph data must still be routed to its declared named graph."""
|
| 96 |
+
+ sink = Graph(identifier=URIRef("urn:test:target"))
|
| 97 |
+
+
|
| 98 |
+
+ parse_without_internal_conjunctive_graph_warning(sink, NAMED_GRAPH_JSONLD)
|
| 99 |
+
+
|
| 100 |
+
+ named_graph = Graph(store=sink.store, identifier=NAMED_GRAPH_ID)
|
| 101 |
+
+ assert TRIPLE in named_graph
|
| 102 |
+
+ assert TRIPLE not in sink
|
| 103 |
+
+
|
| 104 |
+
+
|
| 105 |
+
+def test_graph_jsonld_parse_supports_context_aware_non_graph_aware_store() -> None:
|
| 106 |
+
+ """Preserve stores supported by ConjunctiveGraph but rejected by Dataset."""
|
| 107 |
+
+ store = AuditableStore(Memory())
|
| 108 |
+
+ assert store.context_aware
|
| 109 |
+
+ assert not store.graph_aware
|
| 110 |
+
+ graph = Graph(store=store, identifier=URIRef("urn:test:auditable"))
|
| 111 |
+
+
|
| 112 |
+
+ parse_without_internal_conjunctive_graph_warning(graph, SIMPLE_JSONLD)
|
| 113 |
+
+
|
| 114 |
+
+ assert TRIPLE in graph
|
| 115 |
+
|
| 116 |
+
EOF_R2E_TEST_PATCH
|
| 117 |
+
R2E_APPLY_RC=$?
|
| 118 |
+
if [ "$R2E_APPLY_RC" -ne 0 ]; then
|
| 119 |
+
echo "0.000000" > /logs/verifier/reward.txt
|
| 120 |
+
printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json
|
| 121 |
+
echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2
|
| 122 |
+
exit 0
|
| 123 |
+
fi
|
| 124 |
+
( python -m pytest -v test/jsonld/test_parser_deprecation_warnings.py ) > /logs/verifier/test_output.log 2>&1
|
| 125 |
+
TEST_EXIT_CODE=$?
|
| 126 |
+
cat /logs/verifier/test_output.log
|
| 127 |
+
python3 "$SCRIPT_DIR/verifier.py" --log /logs/verifier/test_output.log --f2p "$SCRIPT_DIR/f2p.json" --p2p "$SCRIPT_DIR/p2p.json" --test-cmds 'python -m pytest -v test/jsonld/test_parser_deprecation_warnings.py' --exit-code "$TEST_EXIT_CODE" --out-dir /logs/verifier || { [ "$TEST_EXIT_CODE" -eq 0 ] && echo "1.0" > /logs/verifier/reward.txt || echo "0.0" > /logs/verifier/reward.txt; }
|
| 128 |
+
git checkout b459049af00b1cdd1453bf99344636b0cbc910df -- test/jsonld/test_parser_deprecation_warnings.py || true
|
| 129 |
+
exit 0
|
heldout/RDFLib__rdflib-607e086b11a9/tests/verifier.py
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""In-container verifier for pr_runtime tasks (graded F2P/P2P reward).
|
| 2 |
+
|
| 3 |
+
This module is the **standalone verifier** that runs inside the task's
|
| 4 |
+
Docker container, NOT a helper used at generation time. It is read as
|
| 5 |
+
source at generation time, base64-encoded, and embedded into
|
| 6 |
+
``tests/test.sh``. At run time the container decodes it back to a file
|
| 7 |
+
and invokes it after the test suite has run.
|
| 8 |
+
|
| 9 |
+
Why a graded reward instead of binary pass/fail
|
| 10 |
+
------------------------------------------------
|
| 11 |
+
SWE-bench resolution is binary: a patch "resolves" the issue iff ALL
|
| 12 |
+
FAIL_TO_PASS tests pass AND ALL PASS_TO_PASS tests still pass. That's
|
| 13 |
+
the right signal for an eval leaderboard, but a terrible gradient for
|
| 14 |
+
RL training — an agent that fixes 4 of 5 failing tests scores the same
|
| 15 |
+
0.0 as one that fixes nothing.
|
| 16 |
+
|
| 17 |
+
So this verifier emits BOTH:
|
| 18 |
+
* /logs/verifier/reward.txt — the GRADED scalar (training signal,
|
| 19 |
+
which Harbor reads): reward = f2p_rate * p2p_factor
|
| 20 |
+
* /logs/verifier/reward-details.json — carries the strict SWE-bench
|
| 21 |
+
``resolved`` bool (eval signal) PLUS the full breakdown.
|
| 22 |
+
|
| 23 |
+
Refs: SWE-bench (F2P/P2P semantics), SWE-RL / SWE-Gym (dense reward for
|
| 24 |
+
RL), UTBoost (weak-test coverage lets wrong patches pass — hence we
|
| 25 |
+
record p2p_count so consumers can judge regression-guard strength).
|
| 26 |
+
|
| 27 |
+
Scoring
|
| 28 |
+
-------
|
| 29 |
+
Given the baked FAIL_TO_PASS / PASS_TO_PASS test-name lists (computed by
|
| 30 |
+
the generation-time two-stage validation) and the agent-run test log:
|
| 31 |
+
|
| 32 |
+
f2p_rate = (# F2P tests now PASSED) / (# F2P tests)
|
| 33 |
+
p2p_rate = (# P2P tests still PASSED) / (# P2P tests) [1.0 if no P2P]
|
| 34 |
+
p2p_factor = p2p_rate # regressions scale the reward down
|
| 35 |
+
reward = f2p_rate * p2p_factor
|
| 36 |
+
resolved = (all F2P pass) AND (all P2P pass) # strict SWE-bench
|
| 37 |
+
|
| 38 |
+
Oracle invariant: the gold patch flips every F2P and keeps every P2P,
|
| 39 |
+
so f2p_rate=1.0, p2p_rate=1.0 -> reward=1.0 and resolved=True. This is
|
| 40 |
+
what the T3 oracle gate (reward == 1.0) relies on.
|
| 41 |
+
|
| 42 |
+
Graceful degradation: if the log can't be parsed into per-test
|
| 43 |
+
statuses (unrecognized runner output), fall back to the exit-code
|
| 44 |
+
reward (1.0 if the suite exited 0, else 0.0) and stamp
|
| 45 |
+
``parse_status="fallback_exitcode"`` — never crash, never silently
|
| 46 |
+
zero out a real fix.
|
| 47 |
+
|
| 48 |
+
Pure stdlib — uses only ``argparse``, ``json``, ``os``, ``re``, ``sys``.
|
| 49 |
+
The 4 per-runner parsers are condensed ports of
|
| 50 |
+
``repo2rlenv.log_parsers.*`` kept in lockstep via the unit tests under
|
| 51 |
+
``tests/test_pr_runtime_verifier.py``.
|
| 52 |
+
"""
|
| 53 |
+
|
| 54 |
+
from __future__ import annotations
|
| 55 |
+
|
| 56 |
+
import argparse
|
| 57 |
+
import json
|
| 58 |
+
import os
|
| 59 |
+
import re
|
| 60 |
+
import sys
|
| 61 |
+
|
| 62 |
+
# Canonical statuses. (Plain strings — no typing.Literal so the baked
|
| 63 |
+
# module stays import-light when decoded standalone in the container.)
|
| 64 |
+
PASSED = "PASSED"
|
| 65 |
+
FAILED = "FAILED"
|
| 66 |
+
SKIPPED = "SKIPPED"
|
| 67 |
+
ERROR = "ERROR"
|
| 68 |
+
|
| 69 |
+
# ---------------------------------------------------------------------------
|
| 70 |
+
# Per-runner log parsers (condensed ports of repo2rlenv.log_parsers.*)
|
| 71 |
+
# ---------------------------------------------------------------------------
|
| 72 |
+
|
| 73 |
+
_PYTEST_STATUSES = (PASSED, FAILED, SKIPPED, ERROR)
|
| 74 |
+
# Keep these patterns in sync with log_parsers/pytest_parser.py. This module
|
| 75 |
+
# also runs standalone inside task containers, without a repo2rlenv install.
|
| 76 |
+
_PYTEST_PROGRESS = (
|
| 77 |
+
r"\[\s*\d+%\]|\[\s*\d+\s*/\s*\d+\s*\]"
|
| 78 |
+
r"|\d+(?:\.\d+)?(?:us|ms|s)|\d+m \d+s|\d+h \d+m"
|
| 79 |
+
)
|
| 80 |
+
_PYTEST_VERBOSE_RE = re.compile(
|
| 81 |
+
r"^(?P<name>.+?(?:\[.*?\])?)\s+(?P<status>PASSED|FAILED|SKIPPED|ERROR)"
|
| 82 |
+
rf"(?:\s+\(.*\))?(?:\s+(?:{_PYTEST_PROGRESS}))?$"
|
| 83 |
+
)
|
| 84 |
+
_PYTEST_SUMMARY_NAME_RE = re.compile(r"^(?P<name>.+?(?:\[.*?\])?)(?: - .*)?$")
|
| 85 |
+
# pytest-xdist worker label, e.g. `[gw1] [ 20%] PASSED tests/foo.py::test_x`.
|
| 86 |
+
_PYTEST_XDIST_PREFIX_RE = re.compile(rf"^\[gw\d+\]\s+(?:(?:{_PYTEST_PROGRESS})\s+)?")
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def parse_pytest(log: str) -> dict[str, str]:
|
| 90 |
+
"""{test_name -> status} from pytest output (verbose or summary)."""
|
| 91 |
+
out: dict[str, str] = {}
|
| 92 |
+
if not log:
|
| 93 |
+
return out
|
| 94 |
+
for raw in log.split("\n"):
|
| 95 |
+
line = raw.strip()
|
| 96 |
+
if not line:
|
| 97 |
+
continue
|
| 98 |
+
line = _PYTEST_XDIST_PREFIX_RE.sub("", line, count=1)
|
| 99 |
+
# Summary lines (STATUS first), preserving the full node ID.
|
| 100 |
+
leading = None
|
| 101 |
+
for st in _PYTEST_STATUSES:
|
| 102 |
+
if line.startswith(st + " ") or line == st:
|
| 103 |
+
leading = st
|
| 104 |
+
break
|
| 105 |
+
if leading is not None:
|
| 106 |
+
work = line[len(leading) :].strip()
|
| 107 |
+
if leading == SKIPPED and re.match(r"^\[\d+\](?:\s|$)", work):
|
| 108 |
+
# Folded skips report a file location, not a parametrized ID.
|
| 109 |
+
tokens = work.split(maxsplit=2)
|
| 110 |
+
if len(tokens) < 2:
|
| 111 |
+
continue
|
| 112 |
+
out[tokens[1]] = leading
|
| 113 |
+
elif m := _PYTEST_SUMMARY_NAME_RE.match(work):
|
| 114 |
+
out[m.group("name")] = leading
|
| 115 |
+
continue
|
| 116 |
+
# Verbose progress (NAME first, STATUS after)
|
| 117 |
+
# Filter non-test output before attempting the backtracking regex.
|
| 118 |
+
head = line.split(None, 1)[0]
|
| 119 |
+
if "::" not in head and not head.endswith(".py"):
|
| 120 |
+
continue
|
| 121 |
+
m = _PYTEST_VERBOSE_RE.match(line)
|
| 122 |
+
if m:
|
| 123 |
+
name = m.group("name")
|
| 124 |
+
if "::" in name or name.endswith(".py"):
|
| 125 |
+
out[name] = m.group("status")
|
| 126 |
+
return out
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
_GO_TEST_RE = re.compile(r"^\s*---\s+(?P<status>PASS|FAIL|SKIP):\s+(?P<name>\S+)")
|
| 130 |
+
_GO_STATUS = {"PASS": PASSED, "FAIL": FAILED, "SKIP": SKIPPED}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def parse_go_test(log: str) -> dict[str, str]:
|
| 134 |
+
"""{test_name -> status} from `go test -v` output."""
|
| 135 |
+
out: dict[str, str] = {}
|
| 136 |
+
if not log:
|
| 137 |
+
return out
|
| 138 |
+
for raw in log.split("\n"):
|
| 139 |
+
m = _GO_TEST_RE.match(raw)
|
| 140 |
+
if m:
|
| 141 |
+
out[m.group("name")] = _GO_STATUS[m.group("status")]
|
| 142 |
+
return out
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
# Keep these patterns in sync with log_parsers/cargo_parser.py.
|
| 146 |
+
_CARGO_TEST_RE = re.compile(r"^test\s+(?P<name>\S.*?) \.\.\. (?P<status>ok|FAILED|ignored)\b")
|
| 147 |
+
_CARGO_MODE_RE = re.compile(r" - (?:should panic|compile fail|compile)$")
|
| 148 |
+
_CARGO_DOCTEST_RE = re.compile(r"^(?P<file>\S+) - (?:(?P<item>.+?) )?\(line \d+\)$")
|
| 149 |
+
_CARGO_STATUS = {"ok": PASSED, "FAILED": FAILED, "ignored": SKIPPED}
|
| 150 |
+
_CARGO_DOCTEST_RANK = {SKIPPED: 0, PASSED: 1, FAILED: 2}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def parse_cargo_test(log: str) -> dict[str, str]:
|
| 154 |
+
"""{test_name -> status} from `cargo test` output.
|
| 155 |
+
|
| 156 |
+
Test modes (` - should panic`) are dropped from names, and doctests are
|
| 157 |
+
keyed without their `(line N)` so line shifts don't change identity; the
|
| 158 |
+
worst status among an item's doctests wins.
|
| 159 |
+
"""
|
| 160 |
+
out: dict[str, str] = {}
|
| 161 |
+
if not log:
|
| 162 |
+
return out
|
| 163 |
+
for raw in log.split("\n"):
|
| 164 |
+
m = _CARGO_TEST_RE.match(raw)
|
| 165 |
+
if not m:
|
| 166 |
+
continue
|
| 167 |
+
name = _CARGO_MODE_RE.sub("", m.group("name")).rstrip()
|
| 168 |
+
status = _CARGO_STATUS[m.group("status")]
|
| 169 |
+
doctest = _CARGO_DOCTEST_RE.match(name)
|
| 170 |
+
if doctest:
|
| 171 |
+
item = doctest.group("item")
|
| 172 |
+
name = f"{doctest.group('file')} - {item}" if item else doctest.group("file")
|
| 173 |
+
if name in out and _CARGO_DOCTEST_RANK[out[name]] > _CARGO_DOCTEST_RANK[status]:
|
| 174 |
+
continue
|
| 175 |
+
out[name] = status
|
| 176 |
+
return out
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
_JEST_FILE_RE = re.compile(r"^ ?(?:PASS|FAIL)\s+(?P<path>\S+\.(?:ts|tsx|js|jsx|mjs|cjs))\b")
|
| 180 |
+
_JEST_TEST_RE = re.compile(
|
| 181 |
+
r"^(?P<indent>\s*)(?P<glyph>✓|√|✕|×|✗|○|◯)\s+(?P<name>.+?)(?:\s+\(\d+(?:\.\d+)?\s*m?s\))?$"
|
| 182 |
+
)
|
| 183 |
+
_JEST_GLYPH = {
|
| 184 |
+
"✓": PASSED,
|
| 185 |
+
"√": PASSED,
|
| 186 |
+
"✕": FAILED,
|
| 187 |
+
"×": FAILED,
|
| 188 |
+
"✗": FAILED,
|
| 189 |
+
"○": SKIPPED,
|
| 190 |
+
"◯": SKIPPED,
|
| 191 |
+
}
|
| 192 |
+
# Keep these patterns in sync with log_parsers/jest_parser.py.
|
| 193 |
+
_ANSI_RE = re.compile(r"\x1b\[[0-9;?]*[A-Za-z]")
|
| 194 |
+
_VITEST_MARKER_RE = re.compile(r"^\s*(?:RUN\s+v\d+\.\d+|Test Files\s+\d)", re.MULTILINE)
|
| 195 |
+
_VITEST_TEST_RE = re.compile(
|
| 196 |
+
r"^\s*(?P<glyph>[✓×↓□]) (?:\|(?P<project>[^|]+)\| | (?P<label>\S+) )?"
|
| 197 |
+
r"(?P<name>\S+ > .+?)(?P<duration> \d{1,9}ms)?"
|
| 198 |
+
r"(?: \(retry x\d{1,9}\))?(?: \(repeat x\d{1,9}\))?(?: \d{1,9} MB heap used)?(?: \[[^\[\]]*\])?$"
|
| 199 |
+
)
|
| 200 |
+
_VITEST_STATUS = {"✓": PASSED, "×": FAILED, "↓": SKIPPED, "□": SKIPPED}
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def _parse_vitest(log: str) -> dict[str, str]:
|
| 204 |
+
"""{test_name -> status} from vitest `--reporter=verbose` lines only."""
|
| 205 |
+
out: dict[str, str] = {}
|
| 206 |
+
for raw in log.split("\n"):
|
| 207 |
+
m = _VITEST_TEST_RE.match(raw.rstrip())
|
| 208 |
+
if not m:
|
| 209 |
+
continue
|
| 210 |
+
glyph, name = m.group("glyph"), m.group("name")
|
| 211 |
+
if glyph in "↓□" and m.group("duration"):
|
| 212 |
+
name += m.group("duration")
|
| 213 |
+
project = m.group("project") or m.group("label")
|
| 214 |
+
out[f"|{project}| {name}" if project else name] = _VITEST_STATUS[glyph]
|
| 215 |
+
return out
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def parse_jest(log: str) -> dict[str, str]:
|
| 219 |
+
"""{test_name -> status} from Jest / Mocha / Vitest output."""
|
| 220 |
+
out: dict[str, str] = {}
|
| 221 |
+
if not log:
|
| 222 |
+
return out
|
| 223 |
+
log = _ANSI_RE.sub("", log)
|
| 224 |
+
if _VITEST_MARKER_RE.search(log):
|
| 225 |
+
return _parse_vitest(log)
|
| 226 |
+
current_file: str | None = None
|
| 227 |
+
describe_stack: list[tuple[int, str]] = []
|
| 228 |
+
last_test_indent: int | None = None
|
| 229 |
+
for raw in log.split("\n"):
|
| 230 |
+
line = raw.rstrip()
|
| 231 |
+
if not line:
|
| 232 |
+
continue
|
| 233 |
+
m = _JEST_FILE_RE.match(line)
|
| 234 |
+
if m:
|
| 235 |
+
current_file = m.group("path")
|
| 236 |
+
describe_stack = []
|
| 237 |
+
last_test_indent = None
|
| 238 |
+
continue
|
| 239 |
+
m = _JEST_TEST_RE.match(line)
|
| 240 |
+
if m:
|
| 241 |
+
indent = len(m.group("indent"))
|
| 242 |
+
name = re.sub(r"^(?:skipped|todo):\s*", "", m.group("name").strip())
|
| 243 |
+
describes = [d for ind, d in describe_stack if ind < indent]
|
| 244 |
+
parts = ([current_file] if current_file else []) + describes + [name]
|
| 245 |
+
out[" > ".join(parts)] = _JEST_GLYPH[m.group("glyph")]
|
| 246 |
+
last_test_indent = indent
|
| 247 |
+
continue
|
| 248 |
+
stripped = line.lstrip()
|
| 249 |
+
if not stripped or stripped.startswith(
|
| 250 |
+
("Tests:", "Test Suites:", "Snapshots:", "Time:", "Ran all", "●", "→", "✗:")
|
| 251 |
+
):
|
| 252 |
+
continue
|
| 253 |
+
indent_here = len(line) - len(stripped)
|
| 254 |
+
if current_file and (last_test_indent is None or indent_here < last_test_indent):
|
| 255 |
+
describe_stack = [(i, d) for i, d in describe_stack if i < indent_here]
|
| 256 |
+
describe_stack.append((indent_here, stripped))
|
| 257 |
+
return out
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
def _detect_runner(test_cmds: str) -> str:
|
| 261 |
+
joined = test_cmds.lower()
|
| 262 |
+
if "pytest" in joined:
|
| 263 |
+
return "pytest"
|
| 264 |
+
if re.search(r"\bgo\s+test\b", joined):
|
| 265 |
+
return "go"
|
| 266 |
+
if re.search(r"\bcargo\s+test\b", joined):
|
| 267 |
+
return "cargo"
|
| 268 |
+
if any(k in joined for k in ("jest", "mocha", "vitest", "npm test", "yarn test", "pnpm test")):
|
| 269 |
+
return "jest"
|
| 270 |
+
return "unknown"
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
def parse_logs(runner: str, log: str) -> dict[str, str]:
|
| 274 |
+
"""Dispatch to the right per-runner parser. Empty dict if unknown."""
|
| 275 |
+
if runner == "pytest":
|
| 276 |
+
return parse_pytest(log)
|
| 277 |
+
if runner == "go":
|
| 278 |
+
return parse_go_test(log)
|
| 279 |
+
if runner == "cargo":
|
| 280 |
+
return parse_cargo_test(log)
|
| 281 |
+
if runner == "jest":
|
| 282 |
+
return parse_jest(log)
|
| 283 |
+
return {}
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
# ---------------------------------------------------------------------------
|
| 287 |
+
# Grading
|
| 288 |
+
# ---------------------------------------------------------------------------
|
| 289 |
+
def _has_go_parent(name: str, status_map: dict[str, str]) -> bool:
|
| 290 |
+
"""Return True if a Go test has an ancestor represented in the status map."""
|
| 291 |
+
parts = name.split("/")
|
| 292 |
+
|
| 293 |
+
for i in range(1, len(parts)):
|
| 294 |
+
parent = "/".join(parts[:i])
|
| 295 |
+
if status_map.get(parent) == FAILED:
|
| 296 |
+
return True
|
| 297 |
+
|
| 298 |
+
return False
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def grade(
|
| 302 |
+
fail_to_pass: list[str],
|
| 303 |
+
pass_to_pass: list[str],
|
| 304 |
+
status_map: dict[str, str],
|
| 305 |
+
runner: str | None = None,
|
| 306 |
+
) -> dict:
|
| 307 |
+
"""Compute the graded reward + strict resolved bool from a status map.
|
| 308 |
+
|
| 309 |
+
f2p_rate = (# F2P now PASSED) / (# F2P)
|
| 310 |
+
p2p_rate = (# P2P still PASSED) / (# P2P) [1.0 when no P2P]
|
| 311 |
+
reward = f2p_rate * p2p_rate (dense training signal)
|
| 312 |
+
resolved = all F2P pass AND all P2P pass (SWE-bench TRACKED resolution —
|
| 313 |
+
the gold patch always satisfies this, preserving the oracle
|
| 314 |
+
invariant)
|
| 315 |
+
|
| 316 |
+
Two distinct EVAL signals (see the audit's "tracked vs command resolved"):
|
| 317 |
+
* `resolved` — tracked resolution (above). Gold patch -> True.
|
| 318 |
+
* `command_resolved` — stricter: tracked resolution AND the selected test
|
| 319 |
+
command had NO failures outside F2P/P2P AND exit
|
| 320 |
+
code 0. Computed in main() where the exit code is
|
| 321 |
+
known. A benchmark that wants "the whole command
|
| 322 |
+
passed cleanly" gates on this; SWE-bench-style
|
| 323 |
+
scoring uses `resolved`.
|
| 324 |
+
|
| 325 |
+
`untracked_failed` are FAILED tests in the run that are neither F2P nor
|
| 326 |
+
P2P (e.g. always-failing/flaky tests pulled in by running a whole test
|
| 327 |
+
file). They don't change the graded `reward` or tracked `resolved`, but
|
| 328 |
+
they block `command_resolved` and are recorded for transparency.
|
| 329 |
+
"""
|
| 330 |
+
f2p_total = len(fail_to_pass)
|
| 331 |
+
p2p_total = len(pass_to_pass)
|
| 332 |
+
f2p_set = set(fail_to_pass)
|
| 333 |
+
p2p_set = set(pass_to_pass)
|
| 334 |
+
f2p_passed = sum(1 for t in fail_to_pass if status_map.get(t) == PASSED)
|
| 335 |
+
p2p_passed = sum(1 for t in pass_to_pass if status_map.get(t) == PASSED)
|
| 336 |
+
# Tests that should have stayed green but regressed (PASS->not-pass).
|
| 337 |
+
regressions = [t for t in pass_to_pass if status_map.get(t) != PASSED]
|
| 338 |
+
|
| 339 |
+
# FAILED tests outside the tracked sets — the selected command isn't clean.
|
| 340 |
+
if runner == "go":
|
| 341 |
+
failed_tests = {
|
| 342 |
+
t
|
| 343 |
+
for t, s in status_map.items()
|
| 344 |
+
if s == FAILED and t not in f2p_set and t not in p2p_set
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
untracked_failed = sorted(t for t in failed_tests if not _has_go_parent(t, status_map))
|
| 348 |
+
else:
|
| 349 |
+
untracked_failed = sorted(
|
| 350 |
+
t
|
| 351 |
+
for t, s in status_map.items()
|
| 352 |
+
if s == FAILED and t not in f2p_set and t not in p2p_set
|
| 353 |
+
)
|
| 354 |
+
|
| 355 |
+
f2p_rate = (f2p_passed / f2p_total) if f2p_total else 0.0
|
| 356 |
+
p2p_rate = (p2p_passed / p2p_total) if p2p_total else 1.0
|
| 357 |
+
reward = f2p_rate * p2p_rate
|
| 358 |
+
resolved = f2p_total > 0 and f2p_passed == f2p_total and p2p_passed == p2p_total
|
| 359 |
+
|
| 360 |
+
return {
|
| 361 |
+
"reward": round(max(0.0, min(1.0, reward)), 6),
|
| 362 |
+
"resolved": resolved,
|
| 363 |
+
"f2p_total": f2p_total,
|
| 364 |
+
"f2p_passed": f2p_passed,
|
| 365 |
+
"f2p_rate": round(f2p_rate, 6),
|
| 366 |
+
"p2p_total": p2p_total,
|
| 367 |
+
"p2p_passed": p2p_passed,
|
| 368 |
+
"p2p_rate": round(p2p_rate, 6),
|
| 369 |
+
"regressions": sorted(regressions),
|
| 370 |
+
"untracked_failed_count": len(untracked_failed),
|
| 371 |
+
"untracked_failed": untracked_failed[:20], # cap the list
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
# ---------------------------------------------------------------------------
|
| 376 |
+
# Entry point (invoked by tests/test.sh inside the container)
|
| 377 |
+
# ---------------------------------------------------------------------------
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
def _read_json_list(path: str) -> list[str]:
|
| 381 |
+
try:
|
| 382 |
+
with open(path, encoding="utf-8") as f:
|
| 383 |
+
data = json.load(f)
|
| 384 |
+
return [str(x) for x in data] if isinstance(data, list) else []
|
| 385 |
+
except (OSError, ValueError):
|
| 386 |
+
return []
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
def _read_text(path: str) -> str:
|
| 390 |
+
try:
|
| 391 |
+
with open(path, encoding="utf-8") as f:
|
| 392 |
+
return f.read()
|
| 393 |
+
except (OSError, UnicodeDecodeError):
|
| 394 |
+
return ""
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
def main(argv: list[str] | None = None) -> int:
|
| 398 |
+
p = argparse.ArgumentParser(description="pr_runtime graded F2P/P2P verifier")
|
| 399 |
+
p.add_argument("--log", required=True, help="captured test-run log file")
|
| 400 |
+
p.add_argument("--f2p", required=True, help="JSON file: FAIL_TO_PASS test names")
|
| 401 |
+
p.add_argument("--p2p", required=True, help="JSON file: PASS_TO_PASS test names")
|
| 402 |
+
p.add_argument("--runner", default="", help="pytest|go|cargo|jest (else auto-detect)")
|
| 403 |
+
p.add_argument("--test-cmds", default="", help="test command string (runner auto-detect)")
|
| 404 |
+
p.add_argument("--exit-code", type=int, default=1, help="test suite exit code (fallback)")
|
| 405 |
+
p.add_argument("--out-dir", default="/logs/verifier", help="where to write reward.{txt,json}")
|
| 406 |
+
args = p.parse_args(argv)
|
| 407 |
+
|
| 408 |
+
log = _read_text(args.log)
|
| 409 |
+
f2p = _read_json_list(args.f2p)
|
| 410 |
+
p2p = _read_json_list(args.p2p)
|
| 411 |
+
runner = args.runner.strip() or _detect_runner(args.test_cmds)
|
| 412 |
+
|
| 413 |
+
status_map = parse_logs(runner, log)
|
| 414 |
+
|
| 415 |
+
if not status_map:
|
| 416 |
+
# Unparseable runner output → fall back to the binary exit-code reward
|
| 417 |
+
# (a coarse TRAINING signal) so we never silently zero a real fix on an
|
| 418 |
+
# unrecognized format. But `resolved` is the strict EVAL signal: without
|
| 419 |
+
# parsed per-test status we have NO evidence the declared FAIL_TO_PASS
|
| 420 |
+
# tests passed, so when an F2P oracle exists we must NOT claim resolved.
|
| 421 |
+
# (resolved stays exit-code-based only when there's no declared oracle,
|
| 422 |
+
# e.g. --skip-validation.)
|
| 423 |
+
reward = 1.0 if args.exit_code == 0 else 0.0
|
| 424 |
+
has_oracle = len(f2p) > 0
|
| 425 |
+
resolved = (args.exit_code == 0) and not has_oracle
|
| 426 |
+
breakdown = {
|
| 427 |
+
"reward": reward,
|
| 428 |
+
"resolved": resolved,
|
| 429 |
+
"command_resolved": bool(resolved and args.exit_code == 0),
|
| 430 |
+
"parse_status": "fallback_exitcode",
|
| 431 |
+
"eval_trustworthy": not has_oracle,
|
| 432 |
+
"runner": runner,
|
| 433 |
+
"f2p_total": len(f2p),
|
| 434 |
+
"p2p_total": len(p2p),
|
| 435 |
+
"exit_code": args.exit_code,
|
| 436 |
+
}
|
| 437 |
+
else:
|
| 438 |
+
breakdown = grade(f2p, p2p, status_map, runner)
|
| 439 |
+
breakdown["parse_status"] = "ok"
|
| 440 |
+
breakdown["runner"] = runner
|
| 441 |
+
breakdown["tests_parsed"] = len(status_map)
|
| 442 |
+
breakdown["exit_code"] = args.exit_code
|
| 443 |
+
# Strict eval signal: tracked resolution AND a clean command (no
|
| 444 |
+
# untracked failures, exit code 0). Benchmarks wanting "the whole test
|
| 445 |
+
# command passed" gate on this; SWE-bench-style scoring uses `resolved`.
|
| 446 |
+
breakdown["command_resolved"] = bool(
|
| 447 |
+
breakdown["resolved"]
|
| 448 |
+
and breakdown["untracked_failed_count"] == 0
|
| 449 |
+
and args.exit_code == 0
|
| 450 |
+
)
|
| 451 |
+
reward = breakdown["reward"]
|
| 452 |
+
|
| 453 |
+
os.makedirs(args.out_dir, exist_ok=True)
|
| 454 |
+
with open(os.path.join(args.out_dir, "reward.txt"), "w", encoding="utf-8") as f:
|
| 455 |
+
f.write(f"{reward:.6f}\n")
|
| 456 |
+
with open(os.path.join(args.out_dir, "reward-details.json"), "w", encoding="utf-8") as f:
|
| 457 |
+
json.dump(breakdown, f, indent=2)
|
| 458 |
+
|
| 459 |
+
print(json.dumps(breakdown, indent=2))
|
| 460 |
+
return 0
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
if __name__ == "__main__":
|
| 464 |
+
sys.exit(main())
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
__all__ = [
|
| 468 |
+
"grade",
|
| 469 |
+
"main",
|
| 470 |
+
"parse_cargo_test",
|
| 471 |
+
"parse_go_test",
|
| 472 |
+
"parse_jest",
|
| 473 |
+
"parse_logs",
|
| 474 |
+
"parse_pytest",
|
| 475 |
+
]
|
heldout/RDFLib__rdflib-72287e45ad1a/environment/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv pr_runtime
|
| 2 |
+
FROM local/RDFLib__rdflib
|
| 3 |
+
WORKDIR /workspace
|
| 4 |
+
# Defensive: ensure git is on PATH at build time. Bootstrap base
|
| 5 |
+
# images vary — some (Python slim) don't ship git; some agents
|
| 6 |
+
# install it; others don't. Re-installing is a no-op when already
|
| 7 |
+
# present. Tries apt-get first (Debian/Ubuntu), then apk (Alpine).
|
| 8 |
+
# Install git + ca-certificates. Minimal images (node:alpine) ship
|
| 9 |
+
# without CA certs, so HTTPS git fetch fails verification.
|
| 10 |
+
RUN (command -v git >/dev/null 2>&1 && [ -e /etc/ssl/certs/ca-certificates.crt ]) || \
|
| 11 |
+
(apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*) || \
|
| 13 |
+
(apk add --no-cache git ca-certificates && update-ca-certificates) || true
|
| 14 |
+
# Defensive: the graded F2P/P2P verifier is Python.
|
| 15 |
+
# Language-specific bootstrap images (Go/Rust/Node) may not
|
| 16 |
+
# ship python3 — install it so test.sh can score F2P/P2P. No-op when
|
| 17 |
+
# python3 is already present (every Python-repo image has it).
|
| 18 |
+
RUN command -v python3 >/dev/null 2>&1 || \
|
| 19 |
+
(apt-get update && apt-get install -y --no-install-recommends python3 \
|
| 20 |
+
&& rm -rf /var/lib/apt/lists/*) || \
|
| 21 |
+
apk add --no-cache python3 || true
|
| 22 |
+
# Position the working tree at the PR's base commit so subsequent
|
| 23 |
+
# model-patch applications align with the line context the patch
|
| 24 |
+
# was authored against. The fetch is a no-op if the commit is
|
| 25 |
+
# already in the shallow clone.
|
| 26 |
+
RUN git config --global --add safe.directory /workspace \
|
| 27 |
+
&& git fetch --depth 1 origin 2a902e512123d1b9a8035fa1652aa3d0a0a918a4 2>/dev/null \
|
| 28 |
+
|| git fetch --unshallow origin 2>/dev/null || true
|
| 29 |
+
RUN git reset --hard 2a902e512123d1b9a8035fa1652aa3d0a0a918a4 && git clean -fdx -e .venv -e venv -e __pycache__ -e .tox -e node_modules -e target -e vendor -e .gradle -e .next -e .pytest_cache
|
| 30 |
+
RUN git checkout -q -B base 2a902e512123d1b9a8035fa1652aa3d0a0a918a4 \
|
| 31 |
+
&& git remote remove origin 2>/dev/null || true
|
| 32 |
+
RUN for ref in $(git branch --format='%(refname:short)' | grep -vx base); do git branch -D "$ref" 2>/dev/null || true; done \
|
| 33 |
+
&& git tag -l | xargs -r git tag -d >/dev/null 2>&1 || true \
|
| 34 |
+
&& git for-each-ref --format='%(refname)' refs/remotes 2>/dev/null | xargs -r -n1 git update-ref -d 2>/dev/null || true \
|
| 35 |
+
&& git reflog expire --expire=now --all 2>/dev/null || true \
|
| 36 |
+
&& git gc --prune=now 2>/dev/null || true
|
heldout/RDFLib__rdflib-72287e45ad1a/environment/docker-compose.yaml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv: anti-contamination egress guard.
|
| 2 |
+
# Blackholes the hosts that serve this repo's published fix and hidden
|
| 3 |
+
# tests, so an agent cannot fetch the answer (pip download / git fetch /
|
| 4 |
+
# WebFetch against these fail). General internet stays up so the agent
|
| 5 |
+
# can install itself and reach its model API. See pipelines/_env_guard.py.
|
| 6 |
+
services:
|
| 7 |
+
main:
|
| 8 |
+
extra_hosts:
|
| 9 |
+
- "pypi.org:0.0.0.0"
|
| 10 |
+
- "pypi.python.org:0.0.0.0"
|
| 11 |
+
- "files.pythonhosted.org:0.0.0.0"
|
| 12 |
+
- "github.com:0.0.0.0"
|
| 13 |
+
- "api.github.com:0.0.0.0"
|
| 14 |
+
- "raw.githubusercontent.com:0.0.0.0"
|
| 15 |
+
- "codeload.github.com:0.0.0.0"
|
| 16 |
+
- "objects.githubusercontent.com:0.0.0.0"
|
heldout/RDFLib__rdflib-72287e45ad1a/instruction.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue
|
| 2 |
+
|
| 3 |
+
**Title:** Turtle/N3 serializers output undeclared prefixes for predicates matching the base URI
|
| 4 |
+
|
| 5 |
+
## Description
|
| 6 |
+
When serializing an RDF graph to Turtle, Long Turtle, or N3 format, if a base URI is set and a predicate URI contains that base URI as a substring (e.g., the predicate starts with the base URI), the serializer incorrectly outputs an undeclared prefix for that predicate.
|
| 7 |
+
|
| 8 |
+
For example, if the base URI is `http://example.org/base/` and a predicate is `http://example.org/base/something`, the output might contain `base:something` without `base` being declared as a prefix. This results in invalid Turtle/N3 output.
|
| 9 |
+
|
| 10 |
+
The expected behavior
|
| 11 |
+
|
| 12 |
+
## Task
|
| 13 |
+
|
| 14 |
+
Modify the repository so that the issue described above is resolved. The task's test suite verifies your patch by applying it on top of the base commit `2a902e512123` and running the modified tests.
|
heldout/RDFLib__rdflib-72287e45ad1a/solution/patch.diff
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/rdflib/plugins/serializers/longturtle.py b/rdflib/plugins/serializers/longturtle.py
|
| 2 |
+
index 1e68e684..1cb2fa73 100644
|
| 3 |
+
--- a/rdflib/plugins/serializers/longturtle.py
|
| 4 |
+
+++ b/rdflib/plugins/serializers/longturtle.py
|
| 5 |
+
@@ -160,6 +160,8 @@ class LongTurtleSerializer(RecursiveSerializer):
|
| 6 |
+
self.base is not None
|
| 7 |
+
and isinstance(node, URIRef)
|
| 8 |
+
and node.startswith(self.base)
|
| 9 |
+
+ and "#" not in node.replace(self.base, "")
|
| 10 |
+
+ and "/" not in node.replace(self.base, "")
|
| 11 |
+
):
|
| 12 |
+
# predicate corresponds to base namespace
|
| 13 |
+
continue
|
| 14 |
+
diff --git a/rdflib/plugins/serializers/turtle.py b/rdflib/plugins/serializers/turtle.py
|
| 15 |
+
index abee2e43..a6d2b631 100644
|
| 16 |
+
--- a/rdflib/plugins/serializers/turtle.py
|
| 17 |
+
+++ b/rdflib/plugins/serializers/turtle.py
|
| 18 |
+
@@ -17,6 +17,8 @@ from typing import (
|
| 19 |
+
Optional,
|
| 20 |
+
Sequence,
|
| 21 |
+
Tuple,
|
| 22 |
+
+ TypeVar,
|
| 23 |
+
+ Union,
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
from rdflib.exceptions import Error
|
| 27 |
+
@@ -25,6 +27,8 @@ from rdflib.namespace import RDF, RDFS
|
| 28 |
+
from rdflib.serializer import Serializer
|
| 29 |
+
from rdflib.term import BNode, Literal, Node, URIRef
|
| 30 |
+
|
| 31 |
+
+_StrT = TypeVar("_StrT", bound=str)
|
| 32 |
+
+
|
| 33 |
+
if TYPE_CHECKING:
|
| 34 |
+
from rdflib.graph import _PredicateType, _SubjectType, _TripleType
|
| 35 |
+
|
| 36 |
+
@@ -169,6 +173,18 @@ class RecursiveSerializer(Serializer):
|
| 37 |
+
# type error: Item "None" of "Optional[IO[bytes]]" has no attribute "write"
|
| 38 |
+
self.stream.write(text.encode(self.encoding, "replace")) # type: ignore[union-attr]
|
| 39 |
+
|
| 40 |
+
+ def relativize(self, uri: _StrT) -> Union[_StrT, URIRef]:
|
| 41 |
+
+ base = self.base
|
| 42 |
+
+ if (
|
| 43 |
+
+ base is not None
|
| 44 |
+
+ and uri.startswith(base)
|
| 45 |
+
+ and "#" not in uri.replace(base, "")
|
| 46 |
+
+ and "/" not in uri.replace(base, "")
|
| 47 |
+
+ ):
|
| 48 |
+
+ # type error: Incompatible types in assignment (expression has type "str", variable has type "Node")
|
| 49 |
+
+ uri = URIRef(uri.replace(base, "", 1)) # type: ignore[assignment]
|
| 50 |
+
+ return uri
|
| 51 |
+
+
|
| 52 |
+
|
| 53 |
+
SUBJECT = 0
|
| 54 |
+
VERB = 1
|
| 55 |
+
@@ -271,6 +287,8 @@ class TurtleSerializer(RecursiveSerializer):
|
| 56 |
+
self.base is not None
|
| 57 |
+
and isinstance(node, URIRef)
|
| 58 |
+
and node.startswith(self.base)
|
| 59 |
+
+ and "#" not in node.replace(self.base, "")
|
| 60 |
+
+ and "/" not in node.replace(self.base, "")
|
| 61 |
+
):
|
| 62 |
+
# predicate corresponds to base namespace
|
| 63 |
+
continue
|
heldout/RDFLib__rdflib-72287e45ad1a/solution/solve.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euxo pipefail
|
| 3 |
+
cd /workspace
|
| 4 |
+
git config --global --add safe.directory /workspace
|
| 5 |
+
PATCH="$(dirname "$0")/patch.diff"
|
| 6 |
+
git apply --verbose --reject "$PATCH"
|
heldout/RDFLib__rdflib-72287e45ad1a/task.toml
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "commit-runtime/RDFLib__rdflib-72287e45ad1a"
|
| 5 |
+
description = "RecursiveSerializer- outputs undeclared prefix for predicates that contains the base as a substring (#3267)"
|
| 6 |
+
|
| 7 |
+
[metadata]
|
| 8 |
+
difficulty = "small"
|
| 9 |
+
category = "bugfix"
|
| 10 |
+
keywords = [
|
| 11 |
+
"rdflib",
|
| 12 |
+
"commit_runtime",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
[metadata.repo2env]
|
| 16 |
+
pipeline = "commit_runtime"
|
| 17 |
+
pipeline_version = "0.8.3"
|
| 18 |
+
repo = "RDFLib/rdflib"
|
| 19 |
+
ref = "2a902e512123d1b9a8035fa1652aa3d0a0a918a4"
|
| 20 |
+
reference = "https://github.com/RDFLib/rdflib/commit/72287e45ad1a9801a85d262f20657c23e8831209"
|
| 21 |
+
source_access = "public"
|
| 22 |
+
built_at = "2026-09-24T13:23:39.021912+00:00"
|
| 23 |
+
synthesis_llm = "gemini/gemini-2.5-flash"
|
| 24 |
+
reward_kinds = [
|
| 25 |
+
"test_execution",
|
| 26 |
+
"diff_similarity",
|
| 27 |
+
]
|
| 28 |
+
spec_version = "0.2.0"
|
| 29 |
+
content_hash = "sha256:903413a22393fee519c76fd4d35848688c41663dc64ce31fef6cd34cbb82432d"
|
| 30 |
+
|
| 31 |
+
[metadata.repo2env.commit_runtime]
|
| 32 |
+
commit_sha = "72287e45ad1a9801a85d262f20657c23e8831209"
|
| 33 |
+
parent_sha = "2a902e512123d1b9a8035fa1652aa3d0a0a918a4"
|
| 34 |
+
authored_at = "2025-10-24T14:10:32+10:00"
|
| 35 |
+
author_email = "37032744+edmondchuc@users.noreply.github.com"
|
| 36 |
+
subject = "fix: RecursiveSerializer- outputs undeclared prefix for predicates that contains the base as a substring (#3267)"
|
| 37 |
+
fail_to_pass = [
|
| 38 |
+
"test/test_serializers/test_serializer_longturtle.py::test_longturtle_undeclared_prefix_when_using_base",
|
| 39 |
+
"test/test_serializers/test_serializer_turtle.py::test_turtle_undeclared_prefix_when_using_base",
|
| 40 |
+
]
|
| 41 |
+
pass_to_pass = [
|
| 42 |
+
"test/test_n3.py::TestN3Case::test_base_cumulative",
|
| 43 |
+
"test/test_n3.py::TestN3Case::test_base_explicit",
|
| 44 |
+
"test/test_n3.py::TestN3Case::test_base_serialize",
|
| 45 |
+
"test/test_n3.py::TestN3Case::test_dot_in_prefix",
|
| 46 |
+
"test/test_n3.py::TestN3Case::test_empty_prefix",
|
| 47 |
+
"test/test_n3.py::TestN3Case::test_float_no_norm[False-expected_result1]",
|
| 48 |
+
"test/test_n3.py::TestN3Case::test_float_no_norm[True-expected_result0]",
|
| 49 |
+
"test/test_n3.py::TestN3Case::test_issue156",
|
| 50 |
+
"test/test_n3.py::TestN3Case::test_issue23",
|
| 51 |
+
"test/test_n3.py::TestN3Case::test_issue29",
|
| 52 |
+
"test/test_n3.py::TestN3Case::test_issue68",
|
| 53 |
+
"test/test_n3.py::TestN3Case::test_issue999",
|
| 54 |
+
"test/test_n3.py::TestN3Case::test_model",
|
| 55 |
+
"test/test_n3.py::TestN3Case::test_parse",
|
| 56 |
+
"test/test_n3.py::TestN3Case::test_quoted_serialization",
|
| 57 |
+
"test/test_n3.py::TestN3Case::test_single_quoted_literals",
|
| 58 |
+
"test/test_n3.py::TestRegularExpressions::test_exponents",
|
| 59 |
+
"test/test_n3.py::TestRegularExpressions::test_invalid_exponents",
|
| 60 |
+
"test/test_serializers/test_serializer_longturtle.py::test_longturtle",
|
| 61 |
+
"test/test_serializers/test_serializer_turtle.py::test_turtle_bool_list",
|
| 62 |
+
"test/test_serializers/test_serializer_turtle.py::test_turtle_final_dot",
|
| 63 |
+
"test/test_serializers/test_serializer_turtle.py::test_turtle_namespace",
|
| 64 |
+
"test/test_serializers/test_serializer_turtle.py::test_turtle_valid_list",
|
| 65 |
+
"test/test_serializers/test_serializer_turtle.py::test_unicode_escaping",
|
| 66 |
+
]
|
| 67 |
+
validation_status = "verified"
|
| 68 |
+
bootstrap_image = "local-venv:RDFLib__rdflib"
|
| 69 |
+
instruction_synthesized = true
|
| 70 |
+
llm_cost_usd = 0.013674
|
| 71 |
+
|
| 72 |
+
[metadata.repo2env.reward_calibration]
|
| 73 |
+
f2p_count = 2
|
| 74 |
+
p2p_count = 24
|
| 75 |
+
source_files = 2
|
| 76 |
+
loc_changed = 20
|
| 77 |
+
difficulty = "small"
|
| 78 |
+
|
| 79 |
+
[metadata.repo2env.evaluation]
|
| 80 |
+
schema_version = "1"
|
| 81 |
+
status = "unverified"
|
| 82 |
+
stage = "generation"
|
| 83 |
+
reason_codes = [
|
| 84 |
+
"validation_not_run",
|
| 85 |
+
]
|
| 86 |
+
detail = "Generated task; validation has not been established."
|
| 87 |
+
provenance = "unknown"
|
| 88 |
+
evidence = []
|
| 89 |
+
|
| 90 |
+
[metadata.repo2env.reproducibility]
|
| 91 |
+
mode = "local_only"
|
| 92 |
+
image_ref = "local/RDFLib__rdflib"
|
| 93 |
+
image_tag = "local/RDFLib__rdflib"
|
| 94 |
+
image_visibility = "private"
|
| 95 |
+
|
| 96 |
+
[agent]
|
| 97 |
+
timeout_sec = 1800.0
|
| 98 |
+
|
| 99 |
+
[verifier]
|
| 100 |
+
timeout_sec = 300.0
|
heldout/RDFLib__rdflib-72287e45ad1a/tests/f2p.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"test/test_serializers/test_serializer_longturtle.py::test_longturtle_undeclared_prefix_when_using_base",
|
| 3 |
+
"test/test_serializers/test_serializer_turtle.py::test_turtle_undeclared_prefix_when_using_base"
|
| 4 |
+
]
|
heldout/RDFLib__rdflib-72287e45ad1a/tests/p2p.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"test/test_n3.py::TestN3Case::test_base_cumulative",
|
| 3 |
+
"test/test_n3.py::TestN3Case::test_base_explicit",
|
| 4 |
+
"test/test_n3.py::TestN3Case::test_base_serialize",
|
| 5 |
+
"test/test_n3.py::TestN3Case::test_dot_in_prefix",
|
| 6 |
+
"test/test_n3.py::TestN3Case::test_empty_prefix",
|
| 7 |
+
"test/test_n3.py::TestN3Case::test_float_no_norm[False-expected_result1]",
|
| 8 |
+
"test/test_n3.py::TestN3Case::test_float_no_norm[True-expected_result0]",
|
| 9 |
+
"test/test_n3.py::TestN3Case::test_issue156",
|
| 10 |
+
"test/test_n3.py::TestN3Case::test_issue23",
|
| 11 |
+
"test/test_n3.py::TestN3Case::test_issue29",
|
| 12 |
+
"test/test_n3.py::TestN3Case::test_issue68",
|
| 13 |
+
"test/test_n3.py::TestN3Case::test_issue999",
|
| 14 |
+
"test/test_n3.py::TestN3Case::test_model",
|
| 15 |
+
"test/test_n3.py::TestN3Case::test_parse",
|
| 16 |
+
"test/test_n3.py::TestN3Case::test_quoted_serialization",
|
| 17 |
+
"test/test_n3.py::TestN3Case::test_single_quoted_literals",
|
| 18 |
+
"test/test_n3.py::TestRegularExpressions::test_exponents",
|
| 19 |
+
"test/test_n3.py::TestRegularExpressions::test_invalid_exponents",
|
| 20 |
+
"test/test_serializers/test_serializer_longturtle.py::test_longturtle",
|
| 21 |
+
"test/test_serializers/test_serializer_turtle.py::test_turtle_bool_list",
|
| 22 |
+
"test/test_serializers/test_serializer_turtle.py::test_turtle_final_dot",
|
| 23 |
+
"test/test_serializers/test_serializer_turtle.py::test_turtle_namespace",
|
| 24 |
+
"test/test_serializers/test_serializer_turtle.py::test_turtle_valid_list",
|
| 25 |
+
"test/test_serializers/test_serializer_turtle.py::test_unicode_escaping"
|
| 26 |
+
]
|
heldout/RDFLib__rdflib-72287e45ad1a/tests/test.sh
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -uxo pipefail
|
| 3 |
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
| 4 |
+
cd /workspace
|
| 5 |
+
git config --global --add safe.directory /workspace
|
| 6 |
+
mkdir -p /logs/verifier
|
| 7 |
+
git checkout 2a902e512123d1b9a8035fa1652aa3d0a0a918a4 -- test/test_n3.py test/test_serializers/test_serializer_longturtle.py test/test_serializers/test_serializer_turtle.py || true
|
| 8 |
+
git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH'
|
| 9 |
+
diff --git a/test/test_n3.py b/test/test_n3.py
|
| 10 |
+
index 40f87186..c713f357 100644
|
| 11 |
+
--- a/test/test_n3.py
|
| 12 |
+
+++ b/test/test_n3.py
|
| 13 |
+
@@ -123,8 +123,10 @@ class TestN3Case:
|
| 14 |
+
URIRef("http://example.com/people/Linda"),
|
| 15 |
+
)
|
| 16 |
+
)
|
| 17 |
+
- s = g.serialize(base="http://example.com/", format="n3", encoding="latin-1")
|
| 18 |
+
- assert b"<people/Bob>" in s
|
| 19 |
+
+ s = g.serialize(
|
| 20 |
+
+ base="http://example.com/people/", format="n3", encoding="latin-1"
|
| 21 |
+
+ )
|
| 22 |
+
+ assert b"<Bob>" in s
|
| 23 |
+
g2 = Dataset()
|
| 24 |
+
g2.parse(data=s, format="n3")
|
| 25 |
+
assert list(g) == list(g2.triples((None, None, None)))
|
| 26 |
+
diff --git a/test/test_serializers/test_serializer_longturtle.py b/test/test_serializers/test_serializer_longturtle.py
|
| 27 |
+
index 65821784..b1540097 100644
|
| 28 |
+
--- a/test/test_serializers/test_serializer_longturtle.py
|
| 29 |
+
+++ b/test/test_serializers/test_serializer_longturtle.py
|
| 30 |
+
@@ -1,5 +1,6 @@
|
| 31 |
+
import difflib
|
| 32 |
+
from pathlib import Path
|
| 33 |
+
+from textwrap import dedent
|
| 34 |
+
|
| 35 |
+
from rdflib import Graph, Namespace
|
| 36 |
+
from rdflib.namespace import GEO, SDO
|
| 37 |
+
@@ -181,3 +182,31 @@ def test_longturtle():
|
| 38 |
+
diff = "\n".join(list(difflib.unified_diff(target.split("\n"), output.split("\n"))))
|
| 39 |
+
|
| 40 |
+
assert not diff, diff
|
| 41 |
+
+
|
| 42 |
+
+
|
| 43 |
+
+def test_longturtle_undeclared_prefix_when_using_base():
|
| 44 |
+
+ """
|
| 45 |
+
+ See https://github.com/RDFLib/rdflib/issues/3160
|
| 46 |
+
+ """
|
| 47 |
+
+ from rdflib import Graph, Literal, URIRef
|
| 48 |
+
+
|
| 49 |
+
+ g = Graph()
|
| 50 |
+
+ g.add(
|
| 51 |
+
+ (
|
| 52 |
+
+ URIRef("https://example.com/subject"),
|
| 53 |
+
+ URIRef("https://example.com/p/predicate"),
|
| 54 |
+
+ Literal("object"),
|
| 55 |
+
+ )
|
| 56 |
+
+ )
|
| 57 |
+
+ output = g.serialize(format="longturtle", base="https://example.com/")
|
| 58 |
+
+ expected = dedent(
|
| 59 |
+
+ """
|
| 60 |
+
+ BASE <https://example.com/>
|
| 61 |
+
+ PREFIX ns1: <https://example.com/p/>
|
| 62 |
+
+
|
| 63 |
+
+ <subject>
|
| 64 |
+
+ ns1:predicate "object" ;
|
| 65 |
+
+ .
|
| 66 |
+
+ """
|
| 67 |
+
+ )
|
| 68 |
+
+ assert output.strip() == expected.strip()
|
| 69 |
+
diff --git a/test/test_serializers/test_serializer_turtle.py b/test/test_serializers/test_serializer_turtle.py
|
| 70 |
+
index c9145982..737701d2 100644
|
| 71 |
+
--- a/test/test_serializers/test_serializer_turtle.py
|
| 72 |
+
+++ b/test/test_serializers/test_serializer_turtle.py
|
| 73 |
+
@@ -1,3 +1,5 @@
|
| 74 |
+
+from textwrap import dedent
|
| 75 |
+
+
|
| 76 |
+
from rdflib import RDF, RDFS, BNode, Graph, Literal, Namespace, URIRef
|
| 77 |
+
from rdflib.collection import Collection
|
| 78 |
+
from rdflib.plugins.serializers.turtle import TurtleSerializer
|
| 79 |
+
@@ -113,3 +115,29 @@ def test_turtle_namespace():
|
| 80 |
+
assert "GENO:0000385" in output
|
| 81 |
+
assert "SERIAL:0167-6423" in output
|
| 82 |
+
assert r"EX:name_with_\(parenthesis\)" in output
|
| 83 |
+
+
|
| 84 |
+
+
|
| 85 |
+
+def test_turtle_undeclared_prefix_when_using_base():
|
| 86 |
+
+ """
|
| 87 |
+
+ See https://github.com/RDFLib/rdflib/issues/3160
|
| 88 |
+
+ """
|
| 89 |
+
+ from rdflib import Graph, Literal, URIRef
|
| 90 |
+
+
|
| 91 |
+
+ g = Graph()
|
| 92 |
+
+ g.add(
|
| 93 |
+
+ (
|
| 94 |
+
+ URIRef("https://example.com/subject"),
|
| 95 |
+
+ URIRef("https://example.com/p/predicate"),
|
| 96 |
+
+ Literal("object"),
|
| 97 |
+
+ )
|
| 98 |
+
+ )
|
| 99 |
+
+ output = g.serialize(format="turtle", base="https://example.com/")
|
| 100 |
+
+ expected = dedent(
|
| 101 |
+
+ """
|
| 102 |
+
+ @base <https://example.com/> .
|
| 103 |
+
+ @prefix ns1: <https://example.com/p/> .
|
| 104 |
+
+
|
| 105 |
+
+ <subject> ns1:predicate "object" .
|
| 106 |
+
+ """
|
| 107 |
+
+ )
|
| 108 |
+
+ assert output.strip() == expected.strip()
|
| 109 |
+
|
| 110 |
+
EOF_R2E_TEST_PATCH
|
| 111 |
+
R2E_APPLY_RC=$?
|
| 112 |
+
if [ "$R2E_APPLY_RC" -ne 0 ]; then
|
| 113 |
+
echo "0.000000" > /logs/verifier/reward.txt
|
| 114 |
+
printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json
|
| 115 |
+
echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2
|
| 116 |
+
exit 0
|
| 117 |
+
fi
|
| 118 |
+
( python -m pytest -v test/test_n3.py test/test_serializers/test_serializer_longturtle.py test/test_serializers/test_serializer_turtle.py ) > /logs/verifier/test_output.log 2>&1
|
| 119 |
+
TEST_EXIT_CODE=$?
|
| 120 |
+
cat /logs/verifier/test_output.log
|
| 121 |
+
python3 "$SCRIPT_DIR/verifier.py" --log /logs/verifier/test_output.log --f2p "$SCRIPT_DIR/f2p.json" --p2p "$SCRIPT_DIR/p2p.json" --test-cmds 'python -m pytest -v test/test_n3.py test/test_serializers/test_serializer_longturtle.py test/test_serializers/test_serializer_turtle.py' --exit-code "$TEST_EXIT_CODE" --out-dir /logs/verifier || { [ "$TEST_EXIT_CODE" -eq 0 ] && echo "1.0" > /logs/verifier/reward.txt || echo "0.0" > /logs/verifier/reward.txt; }
|
| 122 |
+
git checkout 2a902e512123d1b9a8035fa1652aa3d0a0a918a4 -- test/test_n3.py test/test_serializers/test_serializer_longturtle.py test/test_serializers/test_serializer_turtle.py || true
|
| 123 |
+
exit 0
|
heldout/RDFLib__rdflib-72287e45ad1a/tests/verifier.py
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""In-container verifier for pr_runtime tasks (graded F2P/P2P reward).
|
| 2 |
+
|
| 3 |
+
This module is the **standalone verifier** that runs inside the task's
|
| 4 |
+
Docker container, NOT a helper used at generation time. It is read as
|
| 5 |
+
source at generation time, base64-encoded, and embedded into
|
| 6 |
+
``tests/test.sh``. At run time the container decodes it back to a file
|
| 7 |
+
and invokes it after the test suite has run.
|
| 8 |
+
|
| 9 |
+
Why a graded reward instead of binary pass/fail
|
| 10 |
+
------------------------------------------------
|
| 11 |
+
SWE-bench resolution is binary: a patch "resolves" the issue iff ALL
|
| 12 |
+
FAIL_TO_PASS tests pass AND ALL PASS_TO_PASS tests still pass. That's
|
| 13 |
+
the right signal for an eval leaderboard, but a terrible gradient for
|
| 14 |
+
RL training — an agent that fixes 4 of 5 failing tests scores the same
|
| 15 |
+
0.0 as one that fixes nothing.
|
| 16 |
+
|
| 17 |
+
So this verifier emits BOTH:
|
| 18 |
+
* /logs/verifier/reward.txt — the GRADED scalar (training signal,
|
| 19 |
+
which Harbor reads): reward = f2p_rate * p2p_factor
|
| 20 |
+
* /logs/verifier/reward-details.json — carries the strict SWE-bench
|
| 21 |
+
``resolved`` bool (eval signal) PLUS the full breakdown.
|
| 22 |
+
|
| 23 |
+
Refs: SWE-bench (F2P/P2P semantics), SWE-RL / SWE-Gym (dense reward for
|
| 24 |
+
RL), UTBoost (weak-test coverage lets wrong patches pass — hence we
|
| 25 |
+
record p2p_count so consumers can judge regression-guard strength).
|
| 26 |
+
|
| 27 |
+
Scoring
|
| 28 |
+
-------
|
| 29 |
+
Given the baked FAIL_TO_PASS / PASS_TO_PASS test-name lists (computed by
|
| 30 |
+
the generation-time two-stage validation) and the agent-run test log:
|
| 31 |
+
|
| 32 |
+
f2p_rate = (# F2P tests now PASSED) / (# F2P tests)
|
| 33 |
+
p2p_rate = (# P2P tests still PASSED) / (# P2P tests) [1.0 if no P2P]
|
| 34 |
+
p2p_factor = p2p_rate # regressions scale the reward down
|
| 35 |
+
reward = f2p_rate * p2p_factor
|
| 36 |
+
resolved = (all F2P pass) AND (all P2P pass) # strict SWE-bench
|
| 37 |
+
|
| 38 |
+
Oracle invariant: the gold patch flips every F2P and keeps every P2P,
|
| 39 |
+
so f2p_rate=1.0, p2p_rate=1.0 -> reward=1.0 and resolved=True. This is
|
| 40 |
+
what the T3 oracle gate (reward == 1.0) relies on.
|
| 41 |
+
|
| 42 |
+
Graceful degradation: if the log can't be parsed into per-test
|
| 43 |
+
statuses (unrecognized runner output), fall back to the exit-code
|
| 44 |
+
reward (1.0 if the suite exited 0, else 0.0) and stamp
|
| 45 |
+
``parse_status="fallback_exitcode"`` — never crash, never silently
|
| 46 |
+
zero out a real fix.
|
| 47 |
+
|
| 48 |
+
Pure stdlib — uses only ``argparse``, ``json``, ``os``, ``re``, ``sys``.
|
| 49 |
+
The 4 per-runner parsers are condensed ports of
|
| 50 |
+
``repo2rlenv.log_parsers.*`` kept in lockstep via the unit tests under
|
| 51 |
+
``tests/test_pr_runtime_verifier.py``.
|
| 52 |
+
"""
|
| 53 |
+
|
| 54 |
+
from __future__ import annotations
|
| 55 |
+
|
| 56 |
+
import argparse
|
| 57 |
+
import json
|
| 58 |
+
import os
|
| 59 |
+
import re
|
| 60 |
+
import sys
|
| 61 |
+
|
| 62 |
+
# Canonical statuses. (Plain strings — no typing.Literal so the baked
|
| 63 |
+
# module stays import-light when decoded standalone in the container.)
|
| 64 |
+
PASSED = "PASSED"
|
| 65 |
+
FAILED = "FAILED"
|
| 66 |
+
SKIPPED = "SKIPPED"
|
| 67 |
+
ERROR = "ERROR"
|
| 68 |
+
|
| 69 |
+
# ---------------------------------------------------------------------------
|
| 70 |
+
# Per-runner log parsers (condensed ports of repo2rlenv.log_parsers.*)
|
| 71 |
+
# ---------------------------------------------------------------------------
|
| 72 |
+
|
| 73 |
+
_PYTEST_STATUSES = (PASSED, FAILED, SKIPPED, ERROR)
|
| 74 |
+
# Keep these patterns in sync with log_parsers/pytest_parser.py. This module
|
| 75 |
+
# also runs standalone inside task containers, without a repo2rlenv install.
|
| 76 |
+
_PYTEST_PROGRESS = (
|
| 77 |
+
r"\[\s*\d+%\]|\[\s*\d+\s*/\s*\d+\s*\]"
|
| 78 |
+
r"|\d+(?:\.\d+)?(?:us|ms|s)|\d+m \d+s|\d+h \d+m"
|
| 79 |
+
)
|
| 80 |
+
_PYTEST_VERBOSE_RE = re.compile(
|
| 81 |
+
r"^(?P<name>.+?(?:\[.*?\])?)\s+(?P<status>PASSED|FAILED|SKIPPED|ERROR)"
|
| 82 |
+
rf"(?:\s+\(.*\))?(?:\s+(?:{_PYTEST_PROGRESS}))?$"
|
| 83 |
+
)
|
| 84 |
+
_PYTEST_SUMMARY_NAME_RE = re.compile(r"^(?P<name>.+?(?:\[.*?\])?)(?: - .*)?$")
|
| 85 |
+
# pytest-xdist worker label, e.g. `[gw1] [ 20%] PASSED tests/foo.py::test_x`.
|
| 86 |
+
_PYTEST_XDIST_PREFIX_RE = re.compile(rf"^\[gw\d+\]\s+(?:(?:{_PYTEST_PROGRESS})\s+)?")
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def parse_pytest(log: str) -> dict[str, str]:
|
| 90 |
+
"""{test_name -> status} from pytest output (verbose or summary)."""
|
| 91 |
+
out: dict[str, str] = {}
|
| 92 |
+
if not log:
|
| 93 |
+
return out
|
| 94 |
+
for raw in log.split("\n"):
|
| 95 |
+
line = raw.strip()
|
| 96 |
+
if not line:
|
| 97 |
+
continue
|
| 98 |
+
line = _PYTEST_XDIST_PREFIX_RE.sub("", line, count=1)
|
| 99 |
+
# Summary lines (STATUS first), preserving the full node ID.
|
| 100 |
+
leading = None
|
| 101 |
+
for st in _PYTEST_STATUSES:
|
| 102 |
+
if line.startswith(st + " ") or line == st:
|
| 103 |
+
leading = st
|
| 104 |
+
break
|
| 105 |
+
if leading is not None:
|
| 106 |
+
work = line[len(leading) :].strip()
|
| 107 |
+
if leading == SKIPPED and re.match(r"^\[\d+\](?:\s|$)", work):
|
| 108 |
+
# Folded skips report a file location, not a parametrized ID.
|
| 109 |
+
tokens = work.split(maxsplit=2)
|
| 110 |
+
if len(tokens) < 2:
|
| 111 |
+
continue
|
| 112 |
+
out[tokens[1]] = leading
|
| 113 |
+
elif m := _PYTEST_SUMMARY_NAME_RE.match(work):
|
| 114 |
+
out[m.group("name")] = leading
|
| 115 |
+
continue
|
| 116 |
+
# Verbose progress (NAME first, STATUS after)
|
| 117 |
+
# Filter non-test output before attempting the backtracking regex.
|
| 118 |
+
head = line.split(None, 1)[0]
|
| 119 |
+
if "::" not in head and not head.endswith(".py"):
|
| 120 |
+
continue
|
| 121 |
+
m = _PYTEST_VERBOSE_RE.match(line)
|
| 122 |
+
if m:
|
| 123 |
+
name = m.group("name")
|
| 124 |
+
if "::" in name or name.endswith(".py"):
|
| 125 |
+
out[name] = m.group("status")
|
| 126 |
+
return out
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
_GO_TEST_RE = re.compile(r"^\s*---\s+(?P<status>PASS|FAIL|SKIP):\s+(?P<name>\S+)")
|
| 130 |
+
_GO_STATUS = {"PASS": PASSED, "FAIL": FAILED, "SKIP": SKIPPED}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def parse_go_test(log: str) -> dict[str, str]:
|
| 134 |
+
"""{test_name -> status} from `go test -v` output."""
|
| 135 |
+
out: dict[str, str] = {}
|
| 136 |
+
if not log:
|
| 137 |
+
return out
|
| 138 |
+
for raw in log.split("\n"):
|
| 139 |
+
m = _GO_TEST_RE.match(raw)
|
| 140 |
+
if m:
|
| 141 |
+
out[m.group("name")] = _GO_STATUS[m.group("status")]
|
| 142 |
+
return out
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
# Keep these patterns in sync with log_parsers/cargo_parser.py.
|
| 146 |
+
_CARGO_TEST_RE = re.compile(r"^test\s+(?P<name>\S.*?) \.\.\. (?P<status>ok|FAILED|ignored)\b")
|
| 147 |
+
_CARGO_MODE_RE = re.compile(r" - (?:should panic|compile fail|compile)$")
|
| 148 |
+
_CARGO_DOCTEST_RE = re.compile(r"^(?P<file>\S+) - (?:(?P<item>.+?) )?\(line \d+\)$")
|
| 149 |
+
_CARGO_STATUS = {"ok": PASSED, "FAILED": FAILED, "ignored": SKIPPED}
|
| 150 |
+
_CARGO_DOCTEST_RANK = {SKIPPED: 0, PASSED: 1, FAILED: 2}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def parse_cargo_test(log: str) -> dict[str, str]:
|
| 154 |
+
"""{test_name -> status} from `cargo test` output.
|
| 155 |
+
|
| 156 |
+
Test modes (` - should panic`) are dropped from names, and doctests are
|
| 157 |
+
keyed without their `(line N)` so line shifts don't change identity; the
|
| 158 |
+
worst status among an item's doctests wins.
|
| 159 |
+
"""
|
| 160 |
+
out: dict[str, str] = {}
|
| 161 |
+
if not log:
|
| 162 |
+
return out
|
| 163 |
+
for raw in log.split("\n"):
|
| 164 |
+
m = _CARGO_TEST_RE.match(raw)
|
| 165 |
+
if not m:
|
| 166 |
+
continue
|
| 167 |
+
name = _CARGO_MODE_RE.sub("", m.group("name")).rstrip()
|
| 168 |
+
status = _CARGO_STATUS[m.group("status")]
|
| 169 |
+
doctest = _CARGO_DOCTEST_RE.match(name)
|
| 170 |
+
if doctest:
|
| 171 |
+
item = doctest.group("item")
|
| 172 |
+
name = f"{doctest.group('file')} - {item}" if item else doctest.group("file")
|
| 173 |
+
if name in out and _CARGO_DOCTEST_RANK[out[name]] > _CARGO_DOCTEST_RANK[status]:
|
| 174 |
+
continue
|
| 175 |
+
out[name] = status
|
| 176 |
+
return out
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
_JEST_FILE_RE = re.compile(r"^ ?(?:PASS|FAIL)\s+(?P<path>\S+\.(?:ts|tsx|js|jsx|mjs|cjs))\b")
|
| 180 |
+
_JEST_TEST_RE = re.compile(
|
| 181 |
+
r"^(?P<indent>\s*)(?P<glyph>✓|√|✕|×|✗|○|◯)\s+(?P<name>.+?)(?:\s+\(\d+(?:\.\d+)?\s*m?s\))?$"
|
| 182 |
+
)
|
| 183 |
+
_JEST_GLYPH = {
|
| 184 |
+
"✓": PASSED,
|
| 185 |
+
"√": PASSED,
|
| 186 |
+
"✕": FAILED,
|
| 187 |
+
"×": FAILED,
|
| 188 |
+
"✗": FAILED,
|
| 189 |
+
"○": SKIPPED,
|
| 190 |
+
"◯": SKIPPED,
|
| 191 |
+
}
|
| 192 |
+
# Keep these patterns in sync with log_parsers/jest_parser.py.
|
| 193 |
+
_ANSI_RE = re.compile(r"\x1b\[[0-9;?]*[A-Za-z]")
|
| 194 |
+
_VITEST_MARKER_RE = re.compile(r"^\s*(?:RUN\s+v\d+\.\d+|Test Files\s+\d)", re.MULTILINE)
|
| 195 |
+
_VITEST_TEST_RE = re.compile(
|
| 196 |
+
r"^\s*(?P<glyph>[✓×↓□]) (?:\|(?P<project>[^|]+)\| | (?P<label>\S+) )?"
|
| 197 |
+
r"(?P<name>\S+ > .+?)(?P<duration> \d{1,9}ms)?"
|
| 198 |
+
r"(?: \(retry x\d{1,9}\))?(?: \(repeat x\d{1,9}\))?(?: \d{1,9} MB heap used)?(?: \[[^\[\]]*\])?$"
|
| 199 |
+
)
|
| 200 |
+
_VITEST_STATUS = {"✓": PASSED, "×": FAILED, "↓": SKIPPED, "□": SKIPPED}
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def _parse_vitest(log: str) -> dict[str, str]:
|
| 204 |
+
"""{test_name -> status} from vitest `--reporter=verbose` lines only."""
|
| 205 |
+
out: dict[str, str] = {}
|
| 206 |
+
for raw in log.split("\n"):
|
| 207 |
+
m = _VITEST_TEST_RE.match(raw.rstrip())
|
| 208 |
+
if not m:
|
| 209 |
+
continue
|
| 210 |
+
glyph, name = m.group("glyph"), m.group("name")
|
| 211 |
+
if glyph in "↓□" and m.group("duration"):
|
| 212 |
+
name += m.group("duration")
|
| 213 |
+
project = m.group("project") or m.group("label")
|
| 214 |
+
out[f"|{project}| {name}" if project else name] = _VITEST_STATUS[glyph]
|
| 215 |
+
return out
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def parse_jest(log: str) -> dict[str, str]:
|
| 219 |
+
"""{test_name -> status} from Jest / Mocha / Vitest output."""
|
| 220 |
+
out: dict[str, str] = {}
|
| 221 |
+
if not log:
|
| 222 |
+
return out
|
| 223 |
+
log = _ANSI_RE.sub("", log)
|
| 224 |
+
if _VITEST_MARKER_RE.search(log):
|
| 225 |
+
return _parse_vitest(log)
|
| 226 |
+
current_file: str | None = None
|
| 227 |
+
describe_stack: list[tuple[int, str]] = []
|
| 228 |
+
last_test_indent: int | None = None
|
| 229 |
+
for raw in log.split("\n"):
|
| 230 |
+
line = raw.rstrip()
|
| 231 |
+
if not line:
|
| 232 |
+
continue
|
| 233 |
+
m = _JEST_FILE_RE.match(line)
|
| 234 |
+
if m:
|
| 235 |
+
current_file = m.group("path")
|
| 236 |
+
describe_stack = []
|
| 237 |
+
last_test_indent = None
|
| 238 |
+
continue
|
| 239 |
+
m = _JEST_TEST_RE.match(line)
|
| 240 |
+
if m:
|
| 241 |
+
indent = len(m.group("indent"))
|
| 242 |
+
name = re.sub(r"^(?:skipped|todo):\s*", "", m.group("name").strip())
|
| 243 |
+
describes = [d for ind, d in describe_stack if ind < indent]
|
| 244 |
+
parts = ([current_file] if current_file else []) + describes + [name]
|
| 245 |
+
out[" > ".join(parts)] = _JEST_GLYPH[m.group("glyph")]
|
| 246 |
+
last_test_indent = indent
|
| 247 |
+
continue
|
| 248 |
+
stripped = line.lstrip()
|
| 249 |
+
if not stripped or stripped.startswith(
|
| 250 |
+
("Tests:", "Test Suites:", "Snapshots:", "Time:", "Ran all", "●", "→", "✗:")
|
| 251 |
+
):
|
| 252 |
+
continue
|
| 253 |
+
indent_here = len(line) - len(stripped)
|
| 254 |
+
if current_file and (last_test_indent is None or indent_here < last_test_indent):
|
| 255 |
+
describe_stack = [(i, d) for i, d in describe_stack if i < indent_here]
|
| 256 |
+
describe_stack.append((indent_here, stripped))
|
| 257 |
+
return out
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
def _detect_runner(test_cmds: str) -> str:
|
| 261 |
+
joined = test_cmds.lower()
|
| 262 |
+
if "pytest" in joined:
|
| 263 |
+
return "pytest"
|
| 264 |
+
if re.search(r"\bgo\s+test\b", joined):
|
| 265 |
+
return "go"
|
| 266 |
+
if re.search(r"\bcargo\s+test\b", joined):
|
| 267 |
+
return "cargo"
|
| 268 |
+
if any(k in joined for k in ("jest", "mocha", "vitest", "npm test", "yarn test", "pnpm test")):
|
| 269 |
+
return "jest"
|
| 270 |
+
return "unknown"
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
def parse_logs(runner: str, log: str) -> dict[str, str]:
|
| 274 |
+
"""Dispatch to the right per-runner parser. Empty dict if unknown."""
|
| 275 |
+
if runner == "pytest":
|
| 276 |
+
return parse_pytest(log)
|
| 277 |
+
if runner == "go":
|
| 278 |
+
return parse_go_test(log)
|
| 279 |
+
if runner == "cargo":
|
| 280 |
+
return parse_cargo_test(log)
|
| 281 |
+
if runner == "jest":
|
| 282 |
+
return parse_jest(log)
|
| 283 |
+
return {}
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
# ---------------------------------------------------------------------------
|
| 287 |
+
# Grading
|
| 288 |
+
# ---------------------------------------------------------------------------
|
| 289 |
+
def _has_go_parent(name: str, status_map: dict[str, str]) -> bool:
|
| 290 |
+
"""Return True if a Go test has an ancestor represented in the status map."""
|
| 291 |
+
parts = name.split("/")
|
| 292 |
+
|
| 293 |
+
for i in range(1, len(parts)):
|
| 294 |
+
parent = "/".join(parts[:i])
|
| 295 |
+
if status_map.get(parent) == FAILED:
|
| 296 |
+
return True
|
| 297 |
+
|
| 298 |
+
return False
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def grade(
|
| 302 |
+
fail_to_pass: list[str],
|
| 303 |
+
pass_to_pass: list[str],
|
| 304 |
+
status_map: dict[str, str],
|
| 305 |
+
runner: str | None = None,
|
| 306 |
+
) -> dict:
|
| 307 |
+
"""Compute the graded reward + strict resolved bool from a status map.
|
| 308 |
+
|
| 309 |
+
f2p_rate = (# F2P now PASSED) / (# F2P)
|
| 310 |
+
p2p_rate = (# P2P still PASSED) / (# P2P) [1.0 when no P2P]
|
| 311 |
+
reward = f2p_rate * p2p_rate (dense training signal)
|
| 312 |
+
resolved = all F2P pass AND all P2P pass (SWE-bench TRACKED resolution —
|
| 313 |
+
the gold patch always satisfies this, preserving the oracle
|
| 314 |
+
invariant)
|
| 315 |
+
|
| 316 |
+
Two distinct EVAL signals (see the audit's "tracked vs command resolved"):
|
| 317 |
+
* `resolved` — tracked resolution (above). Gold patch -> True.
|
| 318 |
+
* `command_resolved` — stricter: tracked resolution AND the selected test
|
| 319 |
+
command had NO failures outside F2P/P2P AND exit
|
| 320 |
+
code 0. Computed in main() where the exit code is
|
| 321 |
+
known. A benchmark that wants "the whole command
|
| 322 |
+
passed cleanly" gates on this; SWE-bench-style
|
| 323 |
+
scoring uses `resolved`.
|
| 324 |
+
|
| 325 |
+
`untracked_failed` are FAILED tests in the run that are neither F2P nor
|
| 326 |
+
P2P (e.g. always-failing/flaky tests pulled in by running a whole test
|
| 327 |
+
file). They don't change the graded `reward` or tracked `resolved`, but
|
| 328 |
+
they block `command_resolved` and are recorded for transparency.
|
| 329 |
+
"""
|
| 330 |
+
f2p_total = len(fail_to_pass)
|
| 331 |
+
p2p_total = len(pass_to_pass)
|
| 332 |
+
f2p_set = set(fail_to_pass)
|
| 333 |
+
p2p_set = set(pass_to_pass)
|
| 334 |
+
f2p_passed = sum(1 for t in fail_to_pass if status_map.get(t) == PASSED)
|
| 335 |
+
p2p_passed = sum(1 for t in pass_to_pass if status_map.get(t) == PASSED)
|
| 336 |
+
# Tests that should have stayed green but regressed (PASS->not-pass).
|
| 337 |
+
regressions = [t for t in pass_to_pass if status_map.get(t) != PASSED]
|
| 338 |
+
|
| 339 |
+
# FAILED tests outside the tracked sets — the selected command isn't clean.
|
| 340 |
+
if runner == "go":
|
| 341 |
+
failed_tests = {
|
| 342 |
+
t
|
| 343 |
+
for t, s in status_map.items()
|
| 344 |
+
if s == FAILED and t not in f2p_set and t not in p2p_set
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
untracked_failed = sorted(t for t in failed_tests if not _has_go_parent(t, status_map))
|
| 348 |
+
else:
|
| 349 |
+
untracked_failed = sorted(
|
| 350 |
+
t
|
| 351 |
+
for t, s in status_map.items()
|
| 352 |
+
if s == FAILED and t not in f2p_set and t not in p2p_set
|
| 353 |
+
)
|
| 354 |
+
|
| 355 |
+
f2p_rate = (f2p_passed / f2p_total) if f2p_total else 0.0
|
| 356 |
+
p2p_rate = (p2p_passed / p2p_total) if p2p_total else 1.0
|
| 357 |
+
reward = f2p_rate * p2p_rate
|
| 358 |
+
resolved = f2p_total > 0 and f2p_passed == f2p_total and p2p_passed == p2p_total
|
| 359 |
+
|
| 360 |
+
return {
|
| 361 |
+
"reward": round(max(0.0, min(1.0, reward)), 6),
|
| 362 |
+
"resolved": resolved,
|
| 363 |
+
"f2p_total": f2p_total,
|
| 364 |
+
"f2p_passed": f2p_passed,
|
| 365 |
+
"f2p_rate": round(f2p_rate, 6),
|
| 366 |
+
"p2p_total": p2p_total,
|
| 367 |
+
"p2p_passed": p2p_passed,
|
| 368 |
+
"p2p_rate": round(p2p_rate, 6),
|
| 369 |
+
"regressions": sorted(regressions),
|
| 370 |
+
"untracked_failed_count": len(untracked_failed),
|
| 371 |
+
"untracked_failed": untracked_failed[:20], # cap the list
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
# ---------------------------------------------------------------------------
|
| 376 |
+
# Entry point (invoked by tests/test.sh inside the container)
|
| 377 |
+
# ---------------------------------------------------------------------------
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
def _read_json_list(path: str) -> list[str]:
|
| 381 |
+
try:
|
| 382 |
+
with open(path, encoding="utf-8") as f:
|
| 383 |
+
data = json.load(f)
|
| 384 |
+
return [str(x) for x in data] if isinstance(data, list) else []
|
| 385 |
+
except (OSError, ValueError):
|
| 386 |
+
return []
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
def _read_text(path: str) -> str:
|
| 390 |
+
try:
|
| 391 |
+
with open(path, encoding="utf-8") as f:
|
| 392 |
+
return f.read()
|
| 393 |
+
except (OSError, UnicodeDecodeError):
|
| 394 |
+
return ""
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
def main(argv: list[str] | None = None) -> int:
|
| 398 |
+
p = argparse.ArgumentParser(description="pr_runtime graded F2P/P2P verifier")
|
| 399 |
+
p.add_argument("--log", required=True, help="captured test-run log file")
|
| 400 |
+
p.add_argument("--f2p", required=True, help="JSON file: FAIL_TO_PASS test names")
|
| 401 |
+
p.add_argument("--p2p", required=True, help="JSON file: PASS_TO_PASS test names")
|
| 402 |
+
p.add_argument("--runner", default="", help="pytest|go|cargo|jest (else auto-detect)")
|
| 403 |
+
p.add_argument("--test-cmds", default="", help="test command string (runner auto-detect)")
|
| 404 |
+
p.add_argument("--exit-code", type=int, default=1, help="test suite exit code (fallback)")
|
| 405 |
+
p.add_argument("--out-dir", default="/logs/verifier", help="where to write reward.{txt,json}")
|
| 406 |
+
args = p.parse_args(argv)
|
| 407 |
+
|
| 408 |
+
log = _read_text(args.log)
|
| 409 |
+
f2p = _read_json_list(args.f2p)
|
| 410 |
+
p2p = _read_json_list(args.p2p)
|
| 411 |
+
runner = args.runner.strip() or _detect_runner(args.test_cmds)
|
| 412 |
+
|
| 413 |
+
status_map = parse_logs(runner, log)
|
| 414 |
+
|
| 415 |
+
if not status_map:
|
| 416 |
+
# Unparseable runner output → fall back to the binary exit-code reward
|
| 417 |
+
# (a coarse TRAINING signal) so we never silently zero a real fix on an
|
| 418 |
+
# unrecognized format. But `resolved` is the strict EVAL signal: without
|
| 419 |
+
# parsed per-test status we have NO evidence the declared FAIL_TO_PASS
|
| 420 |
+
# tests passed, so when an F2P oracle exists we must NOT claim resolved.
|
| 421 |
+
# (resolved stays exit-code-based only when there's no declared oracle,
|
| 422 |
+
# e.g. --skip-validation.)
|
| 423 |
+
reward = 1.0 if args.exit_code == 0 else 0.0
|
| 424 |
+
has_oracle = len(f2p) > 0
|
| 425 |
+
resolved = (args.exit_code == 0) and not has_oracle
|
| 426 |
+
breakdown = {
|
| 427 |
+
"reward": reward,
|
| 428 |
+
"resolved": resolved,
|
| 429 |
+
"command_resolved": bool(resolved and args.exit_code == 0),
|
| 430 |
+
"parse_status": "fallback_exitcode",
|
| 431 |
+
"eval_trustworthy": not has_oracle,
|
| 432 |
+
"runner": runner,
|
| 433 |
+
"f2p_total": len(f2p),
|
| 434 |
+
"p2p_total": len(p2p),
|
| 435 |
+
"exit_code": args.exit_code,
|
| 436 |
+
}
|
| 437 |
+
else:
|
| 438 |
+
breakdown = grade(f2p, p2p, status_map, runner)
|
| 439 |
+
breakdown["parse_status"] = "ok"
|
| 440 |
+
breakdown["runner"] = runner
|
| 441 |
+
breakdown["tests_parsed"] = len(status_map)
|
| 442 |
+
breakdown["exit_code"] = args.exit_code
|
| 443 |
+
# Strict eval signal: tracked resolution AND a clean command (no
|
| 444 |
+
# untracked failures, exit code 0). Benchmarks wanting "the whole test
|
| 445 |
+
# command passed" gate on this; SWE-bench-style scoring uses `resolved`.
|
| 446 |
+
breakdown["command_resolved"] = bool(
|
| 447 |
+
breakdown["resolved"]
|
| 448 |
+
and breakdown["untracked_failed_count"] == 0
|
| 449 |
+
and args.exit_code == 0
|
| 450 |
+
)
|
| 451 |
+
reward = breakdown["reward"]
|
| 452 |
+
|
| 453 |
+
os.makedirs(args.out_dir, exist_ok=True)
|
| 454 |
+
with open(os.path.join(args.out_dir, "reward.txt"), "w", encoding="utf-8") as f:
|
| 455 |
+
f.write(f"{reward:.6f}\n")
|
| 456 |
+
with open(os.path.join(args.out_dir, "reward-details.json"), "w", encoding="utf-8") as f:
|
| 457 |
+
json.dump(breakdown, f, indent=2)
|
| 458 |
+
|
| 459 |
+
print(json.dumps(breakdown, indent=2))
|
| 460 |
+
return 0
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
if __name__ == "__main__":
|
| 464 |
+
sys.exit(main())
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
__all__ = [
|
| 468 |
+
"grade",
|
| 469 |
+
"main",
|
| 470 |
+
"parse_cargo_test",
|
| 471 |
+
"parse_go_test",
|
| 472 |
+
"parse_jest",
|
| 473 |
+
"parse_logs",
|
| 474 |
+
"parse_pytest",
|
| 475 |
+
]
|
heldout/RDFLib__rdflib-8685a85503c1/environment/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv pr_runtime
|
| 2 |
+
FROM local/RDFLib__rdflib
|
| 3 |
+
WORKDIR /workspace
|
| 4 |
+
# Defensive: ensure git is on PATH at build time. Bootstrap base
|
| 5 |
+
# images vary — some (Python slim) don't ship git; some agents
|
| 6 |
+
# install it; others don't. Re-installing is a no-op when already
|
| 7 |
+
# present. Tries apt-get first (Debian/Ubuntu), then apk (Alpine).
|
| 8 |
+
# Install git + ca-certificates. Minimal images (node:alpine) ship
|
| 9 |
+
# without CA certs, so HTTPS git fetch fails verification.
|
| 10 |
+
RUN (command -v git >/dev/null 2>&1 && [ -e /etc/ssl/certs/ca-certificates.crt ]) || \
|
| 11 |
+
(apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*) || \
|
| 13 |
+
(apk add --no-cache git ca-certificates && update-ca-certificates) || true
|
| 14 |
+
# Defensive: the graded F2P/P2P verifier is Python.
|
| 15 |
+
# Language-specific bootstrap images (Go/Rust/Node) may not
|
| 16 |
+
# ship python3 — install it so test.sh can score F2P/P2P. No-op when
|
| 17 |
+
# python3 is already present (every Python-repo image has it).
|
| 18 |
+
RUN command -v python3 >/dev/null 2>&1 || \
|
| 19 |
+
(apt-get update && apt-get install -y --no-install-recommends python3 \
|
| 20 |
+
&& rm -rf /var/lib/apt/lists/*) || \
|
| 21 |
+
apk add --no-cache python3 || true
|
| 22 |
+
# Position the working tree at the PR's base commit so subsequent
|
| 23 |
+
# model-patch applications align with the line context the patch
|
| 24 |
+
# was authored against. The fetch is a no-op if the commit is
|
| 25 |
+
# already in the shallow clone.
|
| 26 |
+
RUN git config --global --add safe.directory /workspace \
|
| 27 |
+
&& git fetch --depth 1 origin 9b14b8f97994222b3744aa3c7710ecab240c9042 2>/dev/null \
|
| 28 |
+
|| git fetch --unshallow origin 2>/dev/null || true
|
| 29 |
+
RUN git reset --hard 9b14b8f97994222b3744aa3c7710ecab240c9042 && git clean -fdx -e .venv -e venv -e __pycache__ -e .tox -e node_modules -e target -e vendor -e .gradle -e .next -e .pytest_cache
|
| 30 |
+
RUN git checkout -q -B base 9b14b8f97994222b3744aa3c7710ecab240c9042 \
|
| 31 |
+
&& git remote remove origin 2>/dev/null || true
|
| 32 |
+
RUN for ref in $(git branch --format='%(refname:short)' | grep -vx base); do git branch -D "$ref" 2>/dev/null || true; done \
|
| 33 |
+
&& git tag -l | xargs -r git tag -d >/dev/null 2>&1 || true \
|
| 34 |
+
&& git for-each-ref --format='%(refname)' refs/remotes 2>/dev/null | xargs -r -n1 git update-ref -d 2>/dev/null || true \
|
| 35 |
+
&& git reflog expire --expire=now --all 2>/dev/null || true \
|
| 36 |
+
&& git gc --prune=now 2>/dev/null || true
|
heldout/RDFLib__rdflib-8685a85503c1/environment/docker-compose.yaml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv: anti-contamination egress guard.
|
| 2 |
+
# Blackholes the hosts that serve this repo's published fix and hidden
|
| 3 |
+
# tests, so an agent cannot fetch the answer (pip download / git fetch /
|
| 4 |
+
# WebFetch against these fail). General internet stays up so the agent
|
| 5 |
+
# can install itself and reach its model API. See pipelines/_env_guard.py.
|
| 6 |
+
services:
|
| 7 |
+
main:
|
| 8 |
+
extra_hosts:
|
| 9 |
+
- "pypi.org:0.0.0.0"
|
| 10 |
+
- "pypi.python.org:0.0.0.0"
|
| 11 |
+
- "files.pythonhosted.org:0.0.0.0"
|
| 12 |
+
- "github.com:0.0.0.0"
|
| 13 |
+
- "api.github.com:0.0.0.0"
|
| 14 |
+
- "raw.githubusercontent.com:0.0.0.0"
|
| 15 |
+
- "codeload.github.com:0.0.0.0"
|
| 16 |
+
- "objects.githubusercontent.com:0.0.0.0"
|
heldout/RDFLib__rdflib-8685a85503c1/instruction.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue
|
| 2 |
+
|
| 3 |
+
**Title:** Incorrect "changed size" reported or unstable iteration when processing store graphs
|
| 4 |
+
|
| 5 |
+
## Description
|
| 6 |
+
When iterating through the graphs within the store, the "changed size" metric is not being updated or reported accurately. Additionally, the iteration process itself appears unstable, potentially leading to inconsistent results or missed items. Expected behavior is that iterating over the store's graphs should reliably and accurately reflect the "changed size" and provide a stable, consistent traversal of all graphs.
|
| 7 |
+
|
| 8 |
+
## Task
|
| 9 |
+
|
| 10 |
+
Modify the repository so that the issue described above is resolved. The task's test suite verifies your patch by applying it on top of the base commit `9b14b8f97994` and running the modified tests.
|
heldout/RDFLib__rdflib-8685a85503c1/solution/patch.diff
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/rdflib/plugins/stores/memory.py b/rdflib/plugins/stores/memory.py
|
| 2 |
+
index bd73e0d1..a474c5ca 100644
|
| 3 |
+
--- a/rdflib/plugins/stores/memory.py
|
| 4 |
+
+++ b/rdflib/plugins/stores/memory.py
|
| 5 |
+
@@ -556,7 +556,7 @@ class Memory(Store):
|
| 6 |
+
self, triple: Optional[_TripleType] = None
|
| 7 |
+
) -> Generator[_ContextType, None, None]:
|
| 8 |
+
if triple is None or triple == (None, None, None):
|
| 9 |
+
- return (context for context in self.__all_contexts)
|
| 10 |
+
+ return (context for context in list(self.__all_contexts))
|
| 11 |
+
|
| 12 |
+
subj, pred, obj = triple
|
| 13 |
+
try:
|
heldout/RDFLib__rdflib-8685a85503c1/solution/solve.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euxo pipefail
|
| 3 |
+
cd /workspace
|
| 4 |
+
git config --global --add safe.directory /workspace
|
| 5 |
+
PATCH="$(dirname "$0")/patch.diff"
|
| 6 |
+
git apply --verbose --reject "$PATCH"
|
heldout/RDFLib__rdflib-8685a85503c1/task.toml
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "commit-runtime/RDFLib__rdflib-8685a85503c1"
|
| 5 |
+
description = "set changed size when iterating the store's graphs (#3281)"
|
| 6 |
+
|
| 7 |
+
[metadata]
|
| 8 |
+
difficulty = "trivial"
|
| 9 |
+
category = "bugfix"
|
| 10 |
+
keywords = [
|
| 11 |
+
"rdflib",
|
| 12 |
+
"commit_runtime",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
[metadata.repo2env]
|
| 16 |
+
pipeline = "commit_runtime"
|
| 17 |
+
pipeline_version = "0.8.3"
|
| 18 |
+
repo = "RDFLib/rdflib"
|
| 19 |
+
ref = "9b14b8f97994222b3744aa3c7710ecab240c9042"
|
| 20 |
+
reference = "https://github.com/RDFLib/rdflib/commit/8685a85503c1385e5d34cc6f37b1d3700fb260cf"
|
| 21 |
+
source_access = "public"
|
| 22 |
+
built_at = "2026-09-24T13:23:31.060294+00:00"
|
| 23 |
+
synthesis_llm = "gemini/gemini-2.5-flash"
|
| 24 |
+
reward_kinds = [
|
| 25 |
+
"test_execution",
|
| 26 |
+
"diff_similarity",
|
| 27 |
+
]
|
| 28 |
+
spec_version = "0.2.0"
|
| 29 |
+
content_hash = "sha256:8e50190b7faf0596cd3e0988da181629f0baa9ec78108db3cc6c8a2ae278f2d0"
|
| 30 |
+
|
| 31 |
+
[metadata.repo2env.commit_runtime]
|
| 32 |
+
commit_sha = "8685a85503c1385e5d34cc6f37b1d3700fb260cf"
|
| 33 |
+
parent_sha = "9b14b8f97994222b3744aa3c7710ecab240c9042"
|
| 34 |
+
authored_at = "2025-10-30T12:47:51+10:00"
|
| 35 |
+
author_email = "37032744+edmondchuc@users.noreply.github.com"
|
| 36 |
+
subject = "fix: set changed size when iterating the store's graphs (#3281)"
|
| 37 |
+
fail_to_pass = [
|
| 38 |
+
"test/test_store/test_store_memorystore.py::test_sparql_bindings_creating_new_graph",
|
| 39 |
+
]
|
| 40 |
+
pass_to_pass = [
|
| 41 |
+
"test/test_store/test_store_memorystore.py::test_memory_store[Memory]",
|
| 42 |
+
"test/test_store/test_store_memorystore.py::test_memory_store[SimpleMemory]",
|
| 43 |
+
]
|
| 44 |
+
validation_status = "verified"
|
| 45 |
+
bootstrap_image = "local-venv:RDFLib__rdflib"
|
| 46 |
+
instruction_synthesized = true
|
| 47 |
+
llm_cost_usd = 0.012444
|
| 48 |
+
|
| 49 |
+
[metadata.repo2env.reward_calibration]
|
| 50 |
+
f2p_count = 1
|
| 51 |
+
p2p_count = 2
|
| 52 |
+
source_files = 1
|
| 53 |
+
loc_changed = 2
|
| 54 |
+
difficulty = "trivial"
|
| 55 |
+
|
| 56 |
+
[metadata.repo2env.evaluation]
|
| 57 |
+
schema_version = "1"
|
| 58 |
+
status = "unverified"
|
| 59 |
+
stage = "generation"
|
| 60 |
+
reason_codes = [
|
| 61 |
+
"validation_not_run",
|
| 62 |
+
]
|
| 63 |
+
detail = "Generated task; validation has not been established."
|
| 64 |
+
provenance = "unknown"
|
| 65 |
+
evidence = []
|
| 66 |
+
|
| 67 |
+
[metadata.repo2env.reproducibility]
|
| 68 |
+
mode = "local_only"
|
| 69 |
+
image_ref = "local/RDFLib__rdflib"
|
| 70 |
+
image_tag = "local/RDFLib__rdflib"
|
| 71 |
+
image_visibility = "private"
|
| 72 |
+
|
| 73 |
+
[agent]
|
| 74 |
+
timeout_sec = 1800.0
|
| 75 |
+
|
| 76 |
+
[verifier]
|
| 77 |
+
timeout_sec = 300.0
|
heldout/RDFLib__rdflib-8685a85503c1/tests/f2p.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"test/test_store/test_store_memorystore.py::test_sparql_bindings_creating_new_graph"
|
| 3 |
+
]
|
heldout/RDFLib__rdflib-8685a85503c1/tests/p2p.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"test/test_store/test_store_memorystore.py::test_memory_store[Memory]",
|
| 3 |
+
"test/test_store/test_store_memorystore.py::test_memory_store[SimpleMemory]"
|
| 4 |
+
]
|
heldout/RDFLib__rdflib-8685a85503c1/tests/test.sh
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -uxo pipefail
|
| 3 |
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
| 4 |
+
cd /workspace
|
| 5 |
+
git config --global --add safe.directory /workspace
|
| 6 |
+
mkdir -p /logs/verifier
|
| 7 |
+
git checkout 9b14b8f97994222b3744aa3c7710ecab240c9042 -- test/test_store/test_store_memorystore.py || true
|
| 8 |
+
git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH'
|
| 9 |
+
diff --git a/test/test_store/test_store_memorystore.py b/test/test_store/test_store_memorystore.py
|
| 10 |
+
index 905dc58b..df51e3bf 100644
|
| 11 |
+
--- a/test/test_store/test_store_memorystore.py
|
| 12 |
+
+++ b/test/test_store/test_store_memorystore.py
|
| 13 |
+
@@ -29,3 +29,20 @@ def test_memory_store(get_graph):
|
| 14 |
+
g.remove(triple1)
|
| 15 |
+
assert len(g) == 1
|
| 16 |
+
assert len(g.serialize()) > 0
|
| 17 |
+
+
|
| 18 |
+
+
|
| 19 |
+
+def test_sparql_bindings_creating_new_graph():
|
| 20 |
+
+ # Test for https://github.com/RDFLib/rdflib/issues/3102
|
| 21 |
+
+ dataset = rdflib.Dataset()
|
| 22 |
+
+ # Create a graph
|
| 23 |
+
+ dataset.graph(identifier="urn:example:graph")
|
| 24 |
+
+ sparql_query = """
|
| 25 |
+
+ SELECT *
|
| 26 |
+
+ WHERE {
|
| 27 |
+
+ GRAPH ?g_1 { }
|
| 28 |
+
+ GRAPH ?g_2 { }
|
| 29 |
+
+ }"""
|
| 30 |
+
+
|
| 31 |
+
+ # Ensure it doesn't raise RuntimeError: Set changed size during iteration
|
| 32 |
+
+ results = dataset.query(sparql_query)
|
| 33 |
+
+ assert len(results) == 1
|
| 34 |
+
|
| 35 |
+
EOF_R2E_TEST_PATCH
|
| 36 |
+
R2E_APPLY_RC=$?
|
| 37 |
+
if [ "$R2E_APPLY_RC" -ne 0 ]; then
|
| 38 |
+
echo "0.000000" > /logs/verifier/reward.txt
|
| 39 |
+
printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json
|
| 40 |
+
echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2
|
| 41 |
+
exit 0
|
| 42 |
+
fi
|
| 43 |
+
( python -m pytest -v test/test_store/test_store_memorystore.py ) > /logs/verifier/test_output.log 2>&1
|
| 44 |
+
TEST_EXIT_CODE=$?
|
| 45 |
+
cat /logs/verifier/test_output.log
|
| 46 |
+
python3 "$SCRIPT_DIR/verifier.py" --log /logs/verifier/test_output.log --f2p "$SCRIPT_DIR/f2p.json" --p2p "$SCRIPT_DIR/p2p.json" --test-cmds 'python -m pytest -v test/test_store/test_store_memorystore.py' --exit-code "$TEST_EXIT_CODE" --out-dir /logs/verifier || { [ "$TEST_EXIT_CODE" -eq 0 ] && echo "1.0" > /logs/verifier/reward.txt || echo "0.0" > /logs/verifier/reward.txt; }
|
| 47 |
+
git checkout 9b14b8f97994222b3744aa3c7710ecab240c9042 -- test/test_store/test_store_memorystore.py || true
|
| 48 |
+
exit 0
|
heldout/RDFLib__rdflib-8685a85503c1/tests/verifier.py
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""In-container verifier for pr_runtime tasks (graded F2P/P2P reward).
|
| 2 |
+
|
| 3 |
+
This module is the **standalone verifier** that runs inside the task's
|
| 4 |
+
Docker container, NOT a helper used at generation time. It is read as
|
| 5 |
+
source at generation time, base64-encoded, and embedded into
|
| 6 |
+
``tests/test.sh``. At run time the container decodes it back to a file
|
| 7 |
+
and invokes it after the test suite has run.
|
| 8 |
+
|
| 9 |
+
Why a graded reward instead of binary pass/fail
|
| 10 |
+
------------------------------------------------
|
| 11 |
+
SWE-bench resolution is binary: a patch "resolves" the issue iff ALL
|
| 12 |
+
FAIL_TO_PASS tests pass AND ALL PASS_TO_PASS tests still pass. That's
|
| 13 |
+
the right signal for an eval leaderboard, but a terrible gradient for
|
| 14 |
+
RL training — an agent that fixes 4 of 5 failing tests scores the same
|
| 15 |
+
0.0 as one that fixes nothing.
|
| 16 |
+
|
| 17 |
+
So this verifier emits BOTH:
|
| 18 |
+
* /logs/verifier/reward.txt — the GRADED scalar (training signal,
|
| 19 |
+
which Harbor reads): reward = f2p_rate * p2p_factor
|
| 20 |
+
* /logs/verifier/reward-details.json — carries the strict SWE-bench
|
| 21 |
+
``resolved`` bool (eval signal) PLUS the full breakdown.
|
| 22 |
+
|
| 23 |
+
Refs: SWE-bench (F2P/P2P semantics), SWE-RL / SWE-Gym (dense reward for
|
| 24 |
+
RL), UTBoost (weak-test coverage lets wrong patches pass — hence we
|
| 25 |
+
record p2p_count so consumers can judge regression-guard strength).
|
| 26 |
+
|
| 27 |
+
Scoring
|
| 28 |
+
-------
|
| 29 |
+
Given the baked FAIL_TO_PASS / PASS_TO_PASS test-name lists (computed by
|
| 30 |
+
the generation-time two-stage validation) and the agent-run test log:
|
| 31 |
+
|
| 32 |
+
f2p_rate = (# F2P tests now PASSED) / (# F2P tests)
|
| 33 |
+
p2p_rate = (# P2P tests still PASSED) / (# P2P tests) [1.0 if no P2P]
|
| 34 |
+
p2p_factor = p2p_rate # regressions scale the reward down
|
| 35 |
+
reward = f2p_rate * p2p_factor
|
| 36 |
+
resolved = (all F2P pass) AND (all P2P pass) # strict SWE-bench
|
| 37 |
+
|
| 38 |
+
Oracle invariant: the gold patch flips every F2P and keeps every P2P,
|
| 39 |
+
so f2p_rate=1.0, p2p_rate=1.0 -> reward=1.0 and resolved=True. This is
|
| 40 |
+
what the T3 oracle gate (reward == 1.0) relies on.
|
| 41 |
+
|
| 42 |
+
Graceful degradation: if the log can't be parsed into per-test
|
| 43 |
+
statuses (unrecognized runner output), fall back to the exit-code
|
| 44 |
+
reward (1.0 if the suite exited 0, else 0.0) and stamp
|
| 45 |
+
``parse_status="fallback_exitcode"`` — never crash, never silently
|
| 46 |
+
zero out a real fix.
|
| 47 |
+
|
| 48 |
+
Pure stdlib — uses only ``argparse``, ``json``, ``os``, ``re``, ``sys``.
|
| 49 |
+
The 4 per-runner parsers are condensed ports of
|
| 50 |
+
``repo2rlenv.log_parsers.*`` kept in lockstep via the unit tests under
|
| 51 |
+
``tests/test_pr_runtime_verifier.py``.
|
| 52 |
+
"""
|
| 53 |
+
|
| 54 |
+
from __future__ import annotations
|
| 55 |
+
|
| 56 |
+
import argparse
|
| 57 |
+
import json
|
| 58 |
+
import os
|
| 59 |
+
import re
|
| 60 |
+
import sys
|
| 61 |
+
|
| 62 |
+
# Canonical statuses. (Plain strings — no typing.Literal so the baked
|
| 63 |
+
# module stays import-light when decoded standalone in the container.)
|
| 64 |
+
PASSED = "PASSED"
|
| 65 |
+
FAILED = "FAILED"
|
| 66 |
+
SKIPPED = "SKIPPED"
|
| 67 |
+
ERROR = "ERROR"
|
| 68 |
+
|
| 69 |
+
# ---------------------------------------------------------------------------
|
| 70 |
+
# Per-runner log parsers (condensed ports of repo2rlenv.log_parsers.*)
|
| 71 |
+
# ---------------------------------------------------------------------------
|
| 72 |
+
|
| 73 |
+
_PYTEST_STATUSES = (PASSED, FAILED, SKIPPED, ERROR)
|
| 74 |
+
# Keep these patterns in sync with log_parsers/pytest_parser.py. This module
|
| 75 |
+
# also runs standalone inside task containers, without a repo2rlenv install.
|
| 76 |
+
_PYTEST_PROGRESS = (
|
| 77 |
+
r"\[\s*\d+%\]|\[\s*\d+\s*/\s*\d+\s*\]"
|
| 78 |
+
r"|\d+(?:\.\d+)?(?:us|ms|s)|\d+m \d+s|\d+h \d+m"
|
| 79 |
+
)
|
| 80 |
+
_PYTEST_VERBOSE_RE = re.compile(
|
| 81 |
+
r"^(?P<name>.+?(?:\[.*?\])?)\s+(?P<status>PASSED|FAILED|SKIPPED|ERROR)"
|
| 82 |
+
rf"(?:\s+\(.*\))?(?:\s+(?:{_PYTEST_PROGRESS}))?$"
|
| 83 |
+
)
|
| 84 |
+
_PYTEST_SUMMARY_NAME_RE = re.compile(r"^(?P<name>.+?(?:\[.*?\])?)(?: - .*)?$")
|
| 85 |
+
# pytest-xdist worker label, e.g. `[gw1] [ 20%] PASSED tests/foo.py::test_x`.
|
| 86 |
+
_PYTEST_XDIST_PREFIX_RE = re.compile(rf"^\[gw\d+\]\s+(?:(?:{_PYTEST_PROGRESS})\s+)?")
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def parse_pytest(log: str) -> dict[str, str]:
|
| 90 |
+
"""{test_name -> status} from pytest output (verbose or summary)."""
|
| 91 |
+
out: dict[str, str] = {}
|
| 92 |
+
if not log:
|
| 93 |
+
return out
|
| 94 |
+
for raw in log.split("\n"):
|
| 95 |
+
line = raw.strip()
|
| 96 |
+
if not line:
|
| 97 |
+
continue
|
| 98 |
+
line = _PYTEST_XDIST_PREFIX_RE.sub("", line, count=1)
|
| 99 |
+
# Summary lines (STATUS first), preserving the full node ID.
|
| 100 |
+
leading = None
|
| 101 |
+
for st in _PYTEST_STATUSES:
|
| 102 |
+
if line.startswith(st + " ") or line == st:
|
| 103 |
+
leading = st
|
| 104 |
+
break
|
| 105 |
+
if leading is not None:
|
| 106 |
+
work = line[len(leading) :].strip()
|
| 107 |
+
if leading == SKIPPED and re.match(r"^\[\d+\](?:\s|$)", work):
|
| 108 |
+
# Folded skips report a file location, not a parametrized ID.
|
| 109 |
+
tokens = work.split(maxsplit=2)
|
| 110 |
+
if len(tokens) < 2:
|
| 111 |
+
continue
|
| 112 |
+
out[tokens[1]] = leading
|
| 113 |
+
elif m := _PYTEST_SUMMARY_NAME_RE.match(work):
|
| 114 |
+
out[m.group("name")] = leading
|
| 115 |
+
continue
|
| 116 |
+
# Verbose progress (NAME first, STATUS after)
|
| 117 |
+
# Filter non-test output before attempting the backtracking regex.
|
| 118 |
+
head = line.split(None, 1)[0]
|
| 119 |
+
if "::" not in head and not head.endswith(".py"):
|
| 120 |
+
continue
|
| 121 |
+
m = _PYTEST_VERBOSE_RE.match(line)
|
| 122 |
+
if m:
|
| 123 |
+
name = m.group("name")
|
| 124 |
+
if "::" in name or name.endswith(".py"):
|
| 125 |
+
out[name] = m.group("status")
|
| 126 |
+
return out
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
_GO_TEST_RE = re.compile(r"^\s*---\s+(?P<status>PASS|FAIL|SKIP):\s+(?P<name>\S+)")
|
| 130 |
+
_GO_STATUS = {"PASS": PASSED, "FAIL": FAILED, "SKIP": SKIPPED}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def parse_go_test(log: str) -> dict[str, str]:
|
| 134 |
+
"""{test_name -> status} from `go test -v` output."""
|
| 135 |
+
out: dict[str, str] = {}
|
| 136 |
+
if not log:
|
| 137 |
+
return out
|
| 138 |
+
for raw in log.split("\n"):
|
| 139 |
+
m = _GO_TEST_RE.match(raw)
|
| 140 |
+
if m:
|
| 141 |
+
out[m.group("name")] = _GO_STATUS[m.group("status")]
|
| 142 |
+
return out
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
# Keep these patterns in sync with log_parsers/cargo_parser.py.
|
| 146 |
+
_CARGO_TEST_RE = re.compile(r"^test\s+(?P<name>\S.*?) \.\.\. (?P<status>ok|FAILED|ignored)\b")
|
| 147 |
+
_CARGO_MODE_RE = re.compile(r" - (?:should panic|compile fail|compile)$")
|
| 148 |
+
_CARGO_DOCTEST_RE = re.compile(r"^(?P<file>\S+) - (?:(?P<item>.+?) )?\(line \d+\)$")
|
| 149 |
+
_CARGO_STATUS = {"ok": PASSED, "FAILED": FAILED, "ignored": SKIPPED}
|
| 150 |
+
_CARGO_DOCTEST_RANK = {SKIPPED: 0, PASSED: 1, FAILED: 2}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def parse_cargo_test(log: str) -> dict[str, str]:
|
| 154 |
+
"""{test_name -> status} from `cargo test` output.
|
| 155 |
+
|
| 156 |
+
Test modes (` - should panic`) are dropped from names, and doctests are
|
| 157 |
+
keyed without their `(line N)` so line shifts don't change identity; the
|
| 158 |
+
worst status among an item's doctests wins.
|
| 159 |
+
"""
|
| 160 |
+
out: dict[str, str] = {}
|
| 161 |
+
if not log:
|
| 162 |
+
return out
|
| 163 |
+
for raw in log.split("\n"):
|
| 164 |
+
m = _CARGO_TEST_RE.match(raw)
|
| 165 |
+
if not m:
|
| 166 |
+
continue
|
| 167 |
+
name = _CARGO_MODE_RE.sub("", m.group("name")).rstrip()
|
| 168 |
+
status = _CARGO_STATUS[m.group("status")]
|
| 169 |
+
doctest = _CARGO_DOCTEST_RE.match(name)
|
| 170 |
+
if doctest:
|
| 171 |
+
item = doctest.group("item")
|
| 172 |
+
name = f"{doctest.group('file')} - {item}" if item else doctest.group("file")
|
| 173 |
+
if name in out and _CARGO_DOCTEST_RANK[out[name]] > _CARGO_DOCTEST_RANK[status]:
|
| 174 |
+
continue
|
| 175 |
+
out[name] = status
|
| 176 |
+
return out
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
_JEST_FILE_RE = re.compile(r"^ ?(?:PASS|FAIL)\s+(?P<path>\S+\.(?:ts|tsx|js|jsx|mjs|cjs))\b")
|
| 180 |
+
_JEST_TEST_RE = re.compile(
|
| 181 |
+
r"^(?P<indent>\s*)(?P<glyph>✓|√|✕|×|✗|○|◯)\s+(?P<name>.+?)(?:\s+\(\d+(?:\.\d+)?\s*m?s\))?$"
|
| 182 |
+
)
|
| 183 |
+
_JEST_GLYPH = {
|
| 184 |
+
"✓": PASSED,
|
| 185 |
+
"√": PASSED,
|
| 186 |
+
"✕": FAILED,
|
| 187 |
+
"×": FAILED,
|
| 188 |
+
"✗": FAILED,
|
| 189 |
+
"○": SKIPPED,
|
| 190 |
+
"◯": SKIPPED,
|
| 191 |
+
}
|
| 192 |
+
# Keep these patterns in sync with log_parsers/jest_parser.py.
|
| 193 |
+
_ANSI_RE = re.compile(r"\x1b\[[0-9;?]*[A-Za-z]")
|
| 194 |
+
_VITEST_MARKER_RE = re.compile(r"^\s*(?:RUN\s+v\d+\.\d+|Test Files\s+\d)", re.MULTILINE)
|
| 195 |
+
_VITEST_TEST_RE = re.compile(
|
| 196 |
+
r"^\s*(?P<glyph>[✓×↓□]) (?:\|(?P<project>[^|]+)\| | (?P<label>\S+) )?"
|
| 197 |
+
r"(?P<name>\S+ > .+?)(?P<duration> \d{1,9}ms)?"
|
| 198 |
+
r"(?: \(retry x\d{1,9}\))?(?: \(repeat x\d{1,9}\))?(?: \d{1,9} MB heap used)?(?: \[[^\[\]]*\])?$"
|
| 199 |
+
)
|
| 200 |
+
_VITEST_STATUS = {"✓": PASSED, "×": FAILED, "↓": SKIPPED, "□": SKIPPED}
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def _parse_vitest(log: str) -> dict[str, str]:
|
| 204 |
+
"""{test_name -> status} from vitest `--reporter=verbose` lines only."""
|
| 205 |
+
out: dict[str, str] = {}
|
| 206 |
+
for raw in log.split("\n"):
|
| 207 |
+
m = _VITEST_TEST_RE.match(raw.rstrip())
|
| 208 |
+
if not m:
|
| 209 |
+
continue
|
| 210 |
+
glyph, name = m.group("glyph"), m.group("name")
|
| 211 |
+
if glyph in "↓□" and m.group("duration"):
|
| 212 |
+
name += m.group("duration")
|
| 213 |
+
project = m.group("project") or m.group("label")
|
| 214 |
+
out[f"|{project}| {name}" if project else name] = _VITEST_STATUS[glyph]
|
| 215 |
+
return out
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def parse_jest(log: str) -> dict[str, str]:
|
| 219 |
+
"""{test_name -> status} from Jest / Mocha / Vitest output."""
|
| 220 |
+
out: dict[str, str] = {}
|
| 221 |
+
if not log:
|
| 222 |
+
return out
|
| 223 |
+
log = _ANSI_RE.sub("", log)
|
| 224 |
+
if _VITEST_MARKER_RE.search(log):
|
| 225 |
+
return _parse_vitest(log)
|
| 226 |
+
current_file: str | None = None
|
| 227 |
+
describe_stack: list[tuple[int, str]] = []
|
| 228 |
+
last_test_indent: int | None = None
|
| 229 |
+
for raw in log.split("\n"):
|
| 230 |
+
line = raw.rstrip()
|
| 231 |
+
if not line:
|
| 232 |
+
continue
|
| 233 |
+
m = _JEST_FILE_RE.match(line)
|
| 234 |
+
if m:
|
| 235 |
+
current_file = m.group("path")
|
| 236 |
+
describe_stack = []
|
| 237 |
+
last_test_indent = None
|
| 238 |
+
continue
|
| 239 |
+
m = _JEST_TEST_RE.match(line)
|
| 240 |
+
if m:
|
| 241 |
+
indent = len(m.group("indent"))
|
| 242 |
+
name = re.sub(r"^(?:skipped|todo):\s*", "", m.group("name").strip())
|
| 243 |
+
describes = [d for ind, d in describe_stack if ind < indent]
|
| 244 |
+
parts = ([current_file] if current_file else []) + describes + [name]
|
| 245 |
+
out[" > ".join(parts)] = _JEST_GLYPH[m.group("glyph")]
|
| 246 |
+
last_test_indent = indent
|
| 247 |
+
continue
|
| 248 |
+
stripped = line.lstrip()
|
| 249 |
+
if not stripped or stripped.startswith(
|
| 250 |
+
("Tests:", "Test Suites:", "Snapshots:", "Time:", "Ran all", "●", "→", "✗:")
|
| 251 |
+
):
|
| 252 |
+
continue
|
| 253 |
+
indent_here = len(line) - len(stripped)
|
| 254 |
+
if current_file and (last_test_indent is None or indent_here < last_test_indent):
|
| 255 |
+
describe_stack = [(i, d) for i, d in describe_stack if i < indent_here]
|
| 256 |
+
describe_stack.append((indent_here, stripped))
|
| 257 |
+
return out
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
def _detect_runner(test_cmds: str) -> str:
|
| 261 |
+
joined = test_cmds.lower()
|
| 262 |
+
if "pytest" in joined:
|
| 263 |
+
return "pytest"
|
| 264 |
+
if re.search(r"\bgo\s+test\b", joined):
|
| 265 |
+
return "go"
|
| 266 |
+
if re.search(r"\bcargo\s+test\b", joined):
|
| 267 |
+
return "cargo"
|
| 268 |
+
if any(k in joined for k in ("jest", "mocha", "vitest", "npm test", "yarn test", "pnpm test")):
|
| 269 |
+
return "jest"
|
| 270 |
+
return "unknown"
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
def parse_logs(runner: str, log: str) -> dict[str, str]:
|
| 274 |
+
"""Dispatch to the right per-runner parser. Empty dict if unknown."""
|
| 275 |
+
if runner == "pytest":
|
| 276 |
+
return parse_pytest(log)
|
| 277 |
+
if runner == "go":
|
| 278 |
+
return parse_go_test(log)
|
| 279 |
+
if runner == "cargo":
|
| 280 |
+
return parse_cargo_test(log)
|
| 281 |
+
if runner == "jest":
|
| 282 |
+
return parse_jest(log)
|
| 283 |
+
return {}
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
# ---------------------------------------------------------------------------
|
| 287 |
+
# Grading
|
| 288 |
+
# ---------------------------------------------------------------------------
|
| 289 |
+
def _has_go_parent(name: str, status_map: dict[str, str]) -> bool:
|
| 290 |
+
"""Return True if a Go test has an ancestor represented in the status map."""
|
| 291 |
+
parts = name.split("/")
|
| 292 |
+
|
| 293 |
+
for i in range(1, len(parts)):
|
| 294 |
+
parent = "/".join(parts[:i])
|
| 295 |
+
if status_map.get(parent) == FAILED:
|
| 296 |
+
return True
|
| 297 |
+
|
| 298 |
+
return False
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def grade(
|
| 302 |
+
fail_to_pass: list[str],
|
| 303 |
+
pass_to_pass: list[str],
|
| 304 |
+
status_map: dict[str, str],
|
| 305 |
+
runner: str | None = None,
|
| 306 |
+
) -> dict:
|
| 307 |
+
"""Compute the graded reward + strict resolved bool from a status map.
|
| 308 |
+
|
| 309 |
+
f2p_rate = (# F2P now PASSED) / (# F2P)
|
| 310 |
+
p2p_rate = (# P2P still PASSED) / (# P2P) [1.0 when no P2P]
|
| 311 |
+
reward = f2p_rate * p2p_rate (dense training signal)
|
| 312 |
+
resolved = all F2P pass AND all P2P pass (SWE-bench TRACKED resolution —
|
| 313 |
+
the gold patch always satisfies this, preserving the oracle
|
| 314 |
+
invariant)
|
| 315 |
+
|
| 316 |
+
Two distinct EVAL signals (see the audit's "tracked vs command resolved"):
|
| 317 |
+
* `resolved` — tracked resolution (above). Gold patch -> True.
|
| 318 |
+
* `command_resolved` — stricter: tracked resolution AND the selected test
|
| 319 |
+
command had NO failures outside F2P/P2P AND exit
|
| 320 |
+
code 0. Computed in main() where the exit code is
|
| 321 |
+
known. A benchmark that wants "the whole command
|
| 322 |
+
passed cleanly" gates on this; SWE-bench-style
|
| 323 |
+
scoring uses `resolved`.
|
| 324 |
+
|
| 325 |
+
`untracked_failed` are FAILED tests in the run that are neither F2P nor
|
| 326 |
+
P2P (e.g. always-failing/flaky tests pulled in by running a whole test
|
| 327 |
+
file). They don't change the graded `reward` or tracked `resolved`, but
|
| 328 |
+
they block `command_resolved` and are recorded for transparency.
|
| 329 |
+
"""
|
| 330 |
+
f2p_total = len(fail_to_pass)
|
| 331 |
+
p2p_total = len(pass_to_pass)
|
| 332 |
+
f2p_set = set(fail_to_pass)
|
| 333 |
+
p2p_set = set(pass_to_pass)
|
| 334 |
+
f2p_passed = sum(1 for t in fail_to_pass if status_map.get(t) == PASSED)
|
| 335 |
+
p2p_passed = sum(1 for t in pass_to_pass if status_map.get(t) == PASSED)
|
| 336 |
+
# Tests that should have stayed green but regressed (PASS->not-pass).
|
| 337 |
+
regressions = [t for t in pass_to_pass if status_map.get(t) != PASSED]
|
| 338 |
+
|
| 339 |
+
# FAILED tests outside the tracked sets — the selected command isn't clean.
|
| 340 |
+
if runner == "go":
|
| 341 |
+
failed_tests = {
|
| 342 |
+
t
|
| 343 |
+
for t, s in status_map.items()
|
| 344 |
+
if s == FAILED and t not in f2p_set and t not in p2p_set
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
untracked_failed = sorted(t for t in failed_tests if not _has_go_parent(t, status_map))
|
| 348 |
+
else:
|
| 349 |
+
untracked_failed = sorted(
|
| 350 |
+
t
|
| 351 |
+
for t, s in status_map.items()
|
| 352 |
+
if s == FAILED and t not in f2p_set and t not in p2p_set
|
| 353 |
+
)
|
| 354 |
+
|
| 355 |
+
f2p_rate = (f2p_passed / f2p_total) if f2p_total else 0.0
|
| 356 |
+
p2p_rate = (p2p_passed / p2p_total) if p2p_total else 1.0
|
| 357 |
+
reward = f2p_rate * p2p_rate
|
| 358 |
+
resolved = f2p_total > 0 and f2p_passed == f2p_total and p2p_passed == p2p_total
|
| 359 |
+
|
| 360 |
+
return {
|
| 361 |
+
"reward": round(max(0.0, min(1.0, reward)), 6),
|
| 362 |
+
"resolved": resolved,
|
| 363 |
+
"f2p_total": f2p_total,
|
| 364 |
+
"f2p_passed": f2p_passed,
|
| 365 |
+
"f2p_rate": round(f2p_rate, 6),
|
| 366 |
+
"p2p_total": p2p_total,
|
| 367 |
+
"p2p_passed": p2p_passed,
|
| 368 |
+
"p2p_rate": round(p2p_rate, 6),
|
| 369 |
+
"regressions": sorted(regressions),
|
| 370 |
+
"untracked_failed_count": len(untracked_failed),
|
| 371 |
+
"untracked_failed": untracked_failed[:20], # cap the list
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
# ---------------------------------------------------------------------------
|
| 376 |
+
# Entry point (invoked by tests/test.sh inside the container)
|
| 377 |
+
# ---------------------------------------------------------------------------
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
def _read_json_list(path: str) -> list[str]:
|
| 381 |
+
try:
|
| 382 |
+
with open(path, encoding="utf-8") as f:
|
| 383 |
+
data = json.load(f)
|
| 384 |
+
return [str(x) for x in data] if isinstance(data, list) else []
|
| 385 |
+
except (OSError, ValueError):
|
| 386 |
+
return []
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
def _read_text(path: str) -> str:
|
| 390 |
+
try:
|
| 391 |
+
with open(path, encoding="utf-8") as f:
|
| 392 |
+
return f.read()
|
| 393 |
+
except (OSError, UnicodeDecodeError):
|
| 394 |
+
return ""
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
def main(argv: list[str] | None = None) -> int:
|
| 398 |
+
p = argparse.ArgumentParser(description="pr_runtime graded F2P/P2P verifier")
|
| 399 |
+
p.add_argument("--log", required=True, help="captured test-run log file")
|
| 400 |
+
p.add_argument("--f2p", required=True, help="JSON file: FAIL_TO_PASS test names")
|
| 401 |
+
p.add_argument("--p2p", required=True, help="JSON file: PASS_TO_PASS test names")
|
| 402 |
+
p.add_argument("--runner", default="", help="pytest|go|cargo|jest (else auto-detect)")
|
| 403 |
+
p.add_argument("--test-cmds", default="", help="test command string (runner auto-detect)")
|
| 404 |
+
p.add_argument("--exit-code", type=int, default=1, help="test suite exit code (fallback)")
|
| 405 |
+
p.add_argument("--out-dir", default="/logs/verifier", help="where to write reward.{txt,json}")
|
| 406 |
+
args = p.parse_args(argv)
|
| 407 |
+
|
| 408 |
+
log = _read_text(args.log)
|
| 409 |
+
f2p = _read_json_list(args.f2p)
|
| 410 |
+
p2p = _read_json_list(args.p2p)
|
| 411 |
+
runner = args.runner.strip() or _detect_runner(args.test_cmds)
|
| 412 |
+
|
| 413 |
+
status_map = parse_logs(runner, log)
|
| 414 |
+
|
| 415 |
+
if not status_map:
|
| 416 |
+
# Unparseable runner output → fall back to the binary exit-code reward
|
| 417 |
+
# (a coarse TRAINING signal) so we never silently zero a real fix on an
|
| 418 |
+
# unrecognized format. But `resolved` is the strict EVAL signal: without
|
| 419 |
+
# parsed per-test status we have NO evidence the declared FAIL_TO_PASS
|
| 420 |
+
# tests passed, so when an F2P oracle exists we must NOT claim resolved.
|
| 421 |
+
# (resolved stays exit-code-based only when there's no declared oracle,
|
| 422 |
+
# e.g. --skip-validation.)
|
| 423 |
+
reward = 1.0 if args.exit_code == 0 else 0.0
|
| 424 |
+
has_oracle = len(f2p) > 0
|
| 425 |
+
resolved = (args.exit_code == 0) and not has_oracle
|
| 426 |
+
breakdown = {
|
| 427 |
+
"reward": reward,
|
| 428 |
+
"resolved": resolved,
|
| 429 |
+
"command_resolved": bool(resolved and args.exit_code == 0),
|
| 430 |
+
"parse_status": "fallback_exitcode",
|
| 431 |
+
"eval_trustworthy": not has_oracle,
|
| 432 |
+
"runner": runner,
|
| 433 |
+
"f2p_total": len(f2p),
|
| 434 |
+
"p2p_total": len(p2p),
|
| 435 |
+
"exit_code": args.exit_code,
|
| 436 |
+
}
|
| 437 |
+
else:
|
| 438 |
+
breakdown = grade(f2p, p2p, status_map, runner)
|
| 439 |
+
breakdown["parse_status"] = "ok"
|
| 440 |
+
breakdown["runner"] = runner
|
| 441 |
+
breakdown["tests_parsed"] = len(status_map)
|
| 442 |
+
breakdown["exit_code"] = args.exit_code
|
| 443 |
+
# Strict eval signal: tracked resolution AND a clean command (no
|
| 444 |
+
# untracked failures, exit code 0). Benchmarks wanting "the whole test
|
| 445 |
+
# command passed" gate on this; SWE-bench-style scoring uses `resolved`.
|
| 446 |
+
breakdown["command_resolved"] = bool(
|
| 447 |
+
breakdown["resolved"]
|
| 448 |
+
and breakdown["untracked_failed_count"] == 0
|
| 449 |
+
and args.exit_code == 0
|
| 450 |
+
)
|
| 451 |
+
reward = breakdown["reward"]
|
| 452 |
+
|
| 453 |
+
os.makedirs(args.out_dir, exist_ok=True)
|
| 454 |
+
with open(os.path.join(args.out_dir, "reward.txt"), "w", encoding="utf-8") as f:
|
| 455 |
+
f.write(f"{reward:.6f}\n")
|
| 456 |
+
with open(os.path.join(args.out_dir, "reward-details.json"), "w", encoding="utf-8") as f:
|
| 457 |
+
json.dump(breakdown, f, indent=2)
|
| 458 |
+
|
| 459 |
+
print(json.dumps(breakdown, indent=2))
|
| 460 |
+
return 0
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
if __name__ == "__main__":
|
| 464 |
+
sys.exit(main())
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
__all__ = [
|
| 468 |
+
"grade",
|
| 469 |
+
"main",
|
| 470 |
+
"parse_cargo_test",
|
| 471 |
+
"parse_go_test",
|
| 472 |
+
"parse_jest",
|
| 473 |
+
"parse_logs",
|
| 474 |
+
"parse_pytest",
|
| 475 |
+
]
|
heldout/RDFLib__rdflib-b3e60e79c9b0/environment/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv pr_runtime
|
| 2 |
+
FROM local/RDFLib__rdflib
|
| 3 |
+
WORKDIR /workspace
|
| 4 |
+
# Defensive: ensure git is on PATH at build time. Bootstrap base
|
| 5 |
+
# images vary — some (Python slim) don't ship git; some agents
|
| 6 |
+
# install it; others don't. Re-installing is a no-op when already
|
| 7 |
+
# present. Tries apt-get first (Debian/Ubuntu), then apk (Alpine).
|
| 8 |
+
# Install git + ca-certificates. Minimal images (node:alpine) ship
|
| 9 |
+
# without CA certs, so HTTPS git fetch fails verification.
|
| 10 |
+
RUN (command -v git >/dev/null 2>&1 && [ -e /etc/ssl/certs/ca-certificates.crt ]) || \
|
| 11 |
+
(apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*) || \
|
| 13 |
+
(apk add --no-cache git ca-certificates && update-ca-certificates) || true
|
| 14 |
+
# Defensive: the graded F2P/P2P verifier is Python.
|
| 15 |
+
# Language-specific bootstrap images (Go/Rust/Node) may not
|
| 16 |
+
# ship python3 — install it so test.sh can score F2P/P2P. No-op when
|
| 17 |
+
# python3 is already present (every Python-repo image has it).
|
| 18 |
+
RUN command -v python3 >/dev/null 2>&1 || \
|
| 19 |
+
(apt-get update && apt-get install -y --no-install-recommends python3 \
|
| 20 |
+
&& rm -rf /var/lib/apt/lists/*) || \
|
| 21 |
+
apk add --no-cache python3 || true
|
| 22 |
+
# Position the working tree at the PR's base commit so subsequent
|
| 23 |
+
# model-patch applications align with the line context the patch
|
| 24 |
+
# was authored against. The fetch is a no-op if the commit is
|
| 25 |
+
# already in the shallow clone.
|
| 26 |
+
RUN git config --global --add safe.directory /workspace \
|
| 27 |
+
&& git fetch --depth 1 origin 695f864a67636ef8e5610483dacf2442423c3254 2>/dev/null \
|
| 28 |
+
|| git fetch --unshallow origin 2>/dev/null || true
|
| 29 |
+
RUN git reset --hard 695f864a67636ef8e5610483dacf2442423c3254 && git clean -fdx -e .venv -e venv -e __pycache__ -e .tox -e node_modules -e target -e vendor -e .gradle -e .next -e .pytest_cache
|
| 30 |
+
RUN git checkout -q -B base 695f864a67636ef8e5610483dacf2442423c3254 \
|
| 31 |
+
&& git remote remove origin 2>/dev/null || true
|
| 32 |
+
RUN for ref in $(git branch --format='%(refname:short)' | grep -vx base); do git branch -D "$ref" 2>/dev/null || true; done \
|
| 33 |
+
&& git tag -l | xargs -r git tag -d >/dev/null 2>&1 || true \
|
| 34 |
+
&& git for-each-ref --format='%(refname)' refs/remotes 2>/dev/null | xargs -r -n1 git update-ref -d 2>/dev/null || true \
|
| 35 |
+
&& git reflog expire --expire=now --all 2>/dev/null || true \
|
| 36 |
+
&& git gc --prune=now 2>/dev/null || true
|
heldout/RDFLib__rdflib-b3e60e79c9b0/environment/docker-compose.yaml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv: anti-contamination egress guard.
|
| 2 |
+
# Blackholes the hosts that serve this repo's published fix and hidden
|
| 3 |
+
# tests, so an agent cannot fetch the answer (pip download / git fetch /
|
| 4 |
+
# WebFetch against these fail). General internet stays up so the agent
|
| 5 |
+
# can install itself and reach its model API. See pipelines/_env_guard.py.
|
| 6 |
+
services:
|
| 7 |
+
main:
|
| 8 |
+
extra_hosts:
|
| 9 |
+
- "pypi.org:0.0.0.0"
|
| 10 |
+
- "pypi.python.org:0.0.0.0"
|
| 11 |
+
- "files.pythonhosted.org:0.0.0.0"
|
| 12 |
+
- "github.com:0.0.0.0"
|
| 13 |
+
- "api.github.com:0.0.0.0"
|
| 14 |
+
- "raw.githubusercontent.com:0.0.0.0"
|
| 15 |
+
- "codeload.github.com:0.0.0.0"
|
| 16 |
+
- "objects.githubusercontent.com:0.0.0.0"
|
heldout/RDFLib__rdflib-b3e60e79c9b0/instruction.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue
|
| 2 |
+
|
| 3 |
+
**Title:** WGS namespace IRI mismatch leads to incorrect Turtle serialization prefixes
|
| 4 |
+
|
| 5 |
+
## Description
|
| 6 |
+
When serializing data containing WGS (W3C Basic Geo) vocabulary to Turtle, the system currently uses an `https://` namespace IRI. This `https://` IRI does not align with the standard `http://www.w3.org/2003/01/geo/wgs84_pos#` IRI found in published W3C data. As a result, the Turtle serialization invents an incorrect `wgs1:` prefix for the WGS vocabulary. The expected behavior is for the system to use the official `http://` WGS namespace IRI, allowing for correct and consistent prefixes like `geo:` or `wgs:` in Turtle output.
|
| 7 |
+
|
| 8 |
+
## Task
|
| 9 |
+
|
| 10 |
+
Modify the repository so that the issue described above is resolved. The task's test suite verifies your patch by applying it on top of the base commit `695f864a6763` and running the modified tests.
|
heldout/RDFLib__rdflib-b3e60e79c9b0/solution/patch.diff
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/rdflib/namespace/_WGS.py b/rdflib/namespace/_WGS.py
|
| 2 |
+
index 1416154c..a9b3af90 100644
|
| 3 |
+
--- a/rdflib/namespace/_WGS.py
|
| 4 |
+
+++ b/rdflib/namespace/_WGS.py
|
| 5 |
+
@@ -10,7 +10,7 @@ class WGS(DefinedNamespace):
|
| 6 |
+
here <https://www.w3.org/2003/01/geo/>.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
- _NS = Namespace("https://www.w3.org/2003/01/geo/wgs84_pos#")
|
| 10 |
+
+ _NS = Namespace("http://www.w3.org/2003/01/geo/wgs84_pos#")
|
| 11 |
+
|
| 12 |
+
# http://www.w3.org/2000/01/rdf-schema#Class
|
| 13 |
+
SpatialThing: URIRef
|
heldout/RDFLib__rdflib-b3e60e79c9b0/solution/solve.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euxo pipefail
|
| 3 |
+
cd /workspace
|
| 4 |
+
git config --global --add safe.directory /workspace
|
| 5 |
+
PATCH="$(dirname "$0")/patch.diff"
|
| 6 |
+
git apply --verbose --reject "$PATCH"
|
heldout/RDFLib__rdflib-b3e60e79c9b0/task.toml
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "commit-runtime/RDFLib__rdflib-b3e60e79c9b0"
|
| 5 |
+
description = "use the W3C Basic Geo http namespace IRI for WGS (#3550)"
|
| 6 |
+
|
| 7 |
+
[metadata]
|
| 8 |
+
difficulty = "small"
|
| 9 |
+
category = "bugfix"
|
| 10 |
+
keywords = [
|
| 11 |
+
"rdflib",
|
| 12 |
+
"commit_runtime",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
[metadata.repo2env]
|
| 16 |
+
pipeline = "commit_runtime"
|
| 17 |
+
pipeline_version = "0.8.3"
|
| 18 |
+
repo = "RDFLib/rdflib"
|
| 19 |
+
ref = "695f864a67636ef8e5610483dacf2442423c3254"
|
| 20 |
+
reference = "https://github.com/RDFLib/rdflib/commit/b3e60e79c9b0b85d760832fb7bd4d0da3392bb76"
|
| 21 |
+
source_access = "public"
|
| 22 |
+
built_at = "2026-09-24T13:22:35.902760+00:00"
|
| 23 |
+
synthesis_llm = "gemini/gemini-2.5-flash"
|
| 24 |
+
reward_kinds = [
|
| 25 |
+
"test_execution",
|
| 26 |
+
"diff_similarity",
|
| 27 |
+
]
|
| 28 |
+
spec_version = "0.2.0"
|
| 29 |
+
content_hash = "sha256:91dd5ce620187a750816ddfdd8e77f46fa5d7283eed128e4ae281c1e739f3dcd"
|
| 30 |
+
|
| 31 |
+
[metadata.repo2env.commit_runtime]
|
| 32 |
+
commit_sha = "b3e60e79c9b0b85d760832fb7bd4d0da3392bb76"
|
| 33 |
+
parent_sha = "695f864a67636ef8e5610483dacf2442423c3254"
|
| 34 |
+
authored_at = "2026-09-15T04:11:20+01:00"
|
| 35 |
+
author_email = "christopher.pruijsen@gmail.com"
|
| 36 |
+
subject = "fix: use the W3C Basic Geo http namespace IRI for WGS (#3550)"
|
| 37 |
+
fail_to_pass = [
|
| 38 |
+
"test/test_issues/test_issue3529.py::test_wgs_matches_published_data",
|
| 39 |
+
"test/test_issues/test_issue3529.py::test_wgs_namespace_iri_is_http",
|
| 40 |
+
"test/test_issues/test_issue3529.py::test_wgs_prefix_used_on_serialize",
|
| 41 |
+
"test/test_namespace/test_namespacemanager.py::test_bound_namespaces_subset[None-expected_bindings0]",
|
| 42 |
+
"test/test_namespace/test_namespacemanager.py::test_bound_namespaces_subset[rdflib-expected_bindings1]",
|
| 43 |
+
]
|
| 44 |
+
pass_to_pass = [
|
| 45 |
+
"test/test_namespace/test_namespacemanager.py::test_bound_namespaces_subset[core-expected_bindings2]",
|
| 46 |
+
"test/test_namespace/test_namespacemanager.py::test_cc_prefixes_bound",
|
| 47 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname[http://example.org/here#-True-none-None-None-None-expected_result3]",
|
| 48 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname[http://example.org/here#-True-none-None-None-store_prefixes2-expected_result2]",
|
| 49 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname[http://example.org/here#-True-none-None-graph_prefixes1-None-expected_result1]",
|
| 50 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname[http://example.org/here#-True-none-manager_prefixes0-None-None-expected_result0]",
|
| 51 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname_no_generate",
|
| 52 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname_strict[http://example.org/here#-True-none-None-expected_result1]",
|
| 53 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname_strict[http://example.org/here#-True-none-additional_prefixes0-expected_result0]",
|
| 54 |
+
"test/test_namespace/test_namespacemanager.py::test_core_prefixes_bound",
|
| 55 |
+
"test/test_namespace/test_namespacemanager.py::test_expand_curie[:foo-http://example.org/foo]",
|
| 56 |
+
"test/test_namespace/test_namespacemanager.py::test_expand_curie[egdo:bar-expected_result3]",
|
| 57 |
+
"test/test_namespace/test_namespacemanager.py::test_expand_curie[rdf:type-http://www.w3.org/1999/02/22-rdf-syntax-ns#type]",
|
| 58 |
+
"test/test_namespace/test_namespacemanager.py::test_expand_curie[too_small-expected_result2]",
|
| 59 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[-None-expected_result7]",
|
| 60 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.com/-None-expected_result8]",
|
| 61 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.com/a#chair-False-expected_result4]",
|
| 62 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.com/a#chair-None-ns1:chair]",
|
| 63 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.com/a#chair-True-ns1:chair]",
|
| 64 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.com/b#chair-None-ns1:chair]",
|
| 65 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.com/c-None-ns1:c]",
|
| 66 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.org/foo-None-:foo]",
|
| 67 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://www.w3.org/1999/02/22-rdf-syntax-ns#type-None-rdf:type]",
|
| 68 |
+
"test/test_namespace/test_namespacemanager.py::test_graph_bind_namespaces[None-ValueError]",
|
| 69 |
+
"test/test_namespace/test_namespacemanager.py::test_graph_bind_namespaces[core-expected_result2]",
|
| 70 |
+
"test/test_namespace/test_namespacemanager.py::test_graph_bind_namespaces[invalid-ValueError]",
|
| 71 |
+
"test/test_namespace/test_namespacemanager.py::test_graph_bind_namespaces[none-expected_result4]",
|
| 72 |
+
"test/test_namespace/test_namespacemanager.py::test_graph_bind_namespaces[rdflib-expected_result3]",
|
| 73 |
+
"test/test_namespace/test_namespacemanager.py::test_invalid_selector",
|
| 74 |
+
"test/test_namespace/test_namespacemanager.py::test_nman_bind_namespaces[None-ValueError]",
|
| 75 |
+
"test/test_namespace/test_namespacemanager.py::test_nman_bind_namespaces[core-expected_result2]",
|
| 76 |
+
"test/test_namespace/test_namespacemanager.py::test_nman_bind_namespaces[invalid-ValueError]",
|
| 77 |
+
"test/test_namespace/test_namespacemanager.py::test_nman_bind_namespaces[none-expected_result4]",
|
| 78 |
+
"test/test_namespace/test_namespacemanager.py::test_nman_bind_namespaces[rdflib-expected_result3]",
|
| 79 |
+
"test/test_namespace/test_namespacemanager.py::test_rdflib_prefixes_bound",
|
| 80 |
+
"test/test_namespace/test_namespacemanager.py::test_rebinding",
|
| 81 |
+
"test/test_namespace/test_namespacemanager.py::test_replace",
|
| 82 |
+
]
|
| 83 |
+
validation_status = "verified"
|
| 84 |
+
bootstrap_image = "local-venv:RDFLib__rdflib"
|
| 85 |
+
instruction_synthesized = true
|
| 86 |
+
llm_cost_usd = 0.0
|
| 87 |
+
|
| 88 |
+
[metadata.repo2env.reward_calibration]
|
| 89 |
+
f2p_count = 5
|
| 90 |
+
p2p_count = 37
|
| 91 |
+
source_files = 1
|
| 92 |
+
loc_changed = 2
|
| 93 |
+
difficulty = "small"
|
| 94 |
+
|
| 95 |
+
[metadata.repo2env.evaluation]
|
| 96 |
+
schema_version = "1"
|
| 97 |
+
status = "unverified"
|
| 98 |
+
stage = "generation"
|
| 99 |
+
reason_codes = [
|
| 100 |
+
"validation_not_run",
|
| 101 |
+
]
|
| 102 |
+
detail = "Generated task; validation has not been established."
|
| 103 |
+
provenance = "unknown"
|
| 104 |
+
evidence = []
|
| 105 |
+
|
| 106 |
+
[metadata.repo2env.reproducibility]
|
| 107 |
+
mode = "local_only"
|
| 108 |
+
image_ref = "local/RDFLib__rdflib"
|
| 109 |
+
image_tag = "local/RDFLib__rdflib"
|
| 110 |
+
image_visibility = "private"
|
| 111 |
+
|
| 112 |
+
[agent]
|
| 113 |
+
timeout_sec = 1800.0
|
| 114 |
+
|
| 115 |
+
[verifier]
|
| 116 |
+
timeout_sec = 300.0
|
heldout/RDFLib__rdflib-b3e60e79c9b0/tests/f2p.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"test/test_issues/test_issue3529.py::test_wgs_matches_published_data",
|
| 3 |
+
"test/test_issues/test_issue3529.py::test_wgs_namespace_iri_is_http",
|
| 4 |
+
"test/test_issues/test_issue3529.py::test_wgs_prefix_used_on_serialize",
|
| 5 |
+
"test/test_namespace/test_namespacemanager.py::test_bound_namespaces_subset[None-expected_bindings0]",
|
| 6 |
+
"test/test_namespace/test_namespacemanager.py::test_bound_namespaces_subset[rdflib-expected_bindings1]"
|
| 7 |
+
]
|
heldout/RDFLib__rdflib-b3e60e79c9b0/tests/p2p.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"test/test_namespace/test_namespacemanager.py::test_bound_namespaces_subset[core-expected_bindings2]",
|
| 3 |
+
"test/test_namespace/test_namespacemanager.py::test_cc_prefixes_bound",
|
| 4 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname[http://example.org/here#-True-none-None-None-None-expected_result3]",
|
| 5 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname[http://example.org/here#-True-none-None-None-store_prefixes2-expected_result2]",
|
| 6 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname[http://example.org/here#-True-none-None-graph_prefixes1-None-expected_result1]",
|
| 7 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname[http://example.org/here#-True-none-manager_prefixes0-None-None-expected_result0]",
|
| 8 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname_no_generate",
|
| 9 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname_strict[http://example.org/here#-True-none-None-expected_result1]",
|
| 10 |
+
"test/test_namespace/test_namespacemanager.py::test_compute_qname_strict[http://example.org/here#-True-none-additional_prefixes0-expected_result0]",
|
| 11 |
+
"test/test_namespace/test_namespacemanager.py::test_core_prefixes_bound",
|
| 12 |
+
"test/test_namespace/test_namespacemanager.py::test_expand_curie[:foo-http://example.org/foo]",
|
| 13 |
+
"test/test_namespace/test_namespacemanager.py::test_expand_curie[egdo:bar-expected_result3]",
|
| 14 |
+
"test/test_namespace/test_namespacemanager.py::test_expand_curie[rdf:type-http://www.w3.org/1999/02/22-rdf-syntax-ns#type]",
|
| 15 |
+
"test/test_namespace/test_namespacemanager.py::test_expand_curie[too_small-expected_result2]",
|
| 16 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[-None-expected_result7]",
|
| 17 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.com/-None-expected_result8]",
|
| 18 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.com/a#chair-False-expected_result4]",
|
| 19 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.com/a#chair-None-ns1:chair]",
|
| 20 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.com/a#chair-True-ns1:chair]",
|
| 21 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.com/b#chair-None-ns1:chair]",
|
| 22 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.com/c-None-ns1:c]",
|
| 23 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://example.org/foo-None-:foo]",
|
| 24 |
+
"test/test_namespace/test_namespacemanager.py::test_generate_curie[http://www.w3.org/1999/02/22-rdf-syntax-ns#type-None-rdf:type]",
|
| 25 |
+
"test/test_namespace/test_namespacemanager.py::test_graph_bind_namespaces[None-ValueError]",
|
| 26 |
+
"test/test_namespace/test_namespacemanager.py::test_graph_bind_namespaces[core-expected_result2]",
|
| 27 |
+
"test/test_namespace/test_namespacemanager.py::test_graph_bind_namespaces[invalid-ValueError]",
|
| 28 |
+
"test/test_namespace/test_namespacemanager.py::test_graph_bind_namespaces[none-expected_result4]",
|
| 29 |
+
"test/test_namespace/test_namespacemanager.py::test_graph_bind_namespaces[rdflib-expected_result3]",
|
| 30 |
+
"test/test_namespace/test_namespacemanager.py::test_invalid_selector",
|
| 31 |
+
"test/test_namespace/test_namespacemanager.py::test_nman_bind_namespaces[None-ValueError]",
|
| 32 |
+
"test/test_namespace/test_namespacemanager.py::test_nman_bind_namespaces[core-expected_result2]",
|
| 33 |
+
"test/test_namespace/test_namespacemanager.py::test_nman_bind_namespaces[invalid-ValueError]",
|
| 34 |
+
"test/test_namespace/test_namespacemanager.py::test_nman_bind_namespaces[none-expected_result4]",
|
| 35 |
+
"test/test_namespace/test_namespacemanager.py::test_nman_bind_namespaces[rdflib-expected_result3]",
|
| 36 |
+
"test/test_namespace/test_namespacemanager.py::test_rdflib_prefixes_bound",
|
| 37 |
+
"test/test_namespace/test_namespacemanager.py::test_rebinding",
|
| 38 |
+
"test/test_namespace/test_namespacemanager.py::test_replace"
|
| 39 |
+
]
|