release v1: 65 held-out tasks, 78 bootstrap records, r2e_local adapter, manifest ae94c40b (part 4)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- heldout/mirumee__google-i18n-address-311eb0f1a0fa/tests/test.sh +86 -0
- heldout/mirumee__google-i18n-address-311eb0f1a0fa/tests/verifier.py +475 -0
- heldout/osantana__prettyconf-16570d889998/environment/Dockerfile +36 -0
- heldout/osantana__prettyconf-16570d889998/environment/docker-compose.yaml +16 -0
- heldout/osantana__prettyconf-16570d889998/instruction.md +10 -0
- heldout/osantana__prettyconf-16570d889998/solution/patch.diff +26 -0
- heldout/osantana__prettyconf-16570d889998/solution/solve.sh +6 -0
- heldout/osantana__prettyconf-16570d889998/task.toml +82 -0
- heldout/osantana__prettyconf-16570d889998/tests/f2p.json +3 -0
- heldout/osantana__prettyconf-16570d889998/tests/p2p.json +9 -0
- heldout/osantana__prettyconf-16570d889998/tests/test.sh +44 -0
- heldout/osantana__prettyconf-16570d889998/tests/verifier.py +475 -0
- heldout/sloria__environs-1a47a3658bf7/environment/Dockerfile +36 -0
- heldout/sloria__environs-1a47a3658bf7/environment/docker-compose.yaml +16 -0
- heldout/sloria__environs-1a47a3658bf7/instruction.md +16 -0
- heldout/sloria__environs-1a47a3658bf7/solution/patch.diff +29 -0
- heldout/sloria__environs-1a47a3658bf7/solution/solve.sh +6 -0
- heldout/sloria__environs-1a47a3658bf7/task.toml +125 -0
- heldout/sloria__environs-1a47a3658bf7/tests/f2p.json +3 -0
- heldout/sloria__environs-1a47a3658bf7/tests/p2p.json +52 -0
- heldout/sloria__environs-1a47a3658bf7/tests/test.sh +44 -0
- heldout/sloria__environs-1a47a3658bf7/tests/verifier.py +475 -0
- heldout/sloria__environs-9c51c66940a1/environment/Dockerfile +36 -0
- heldout/sloria__environs-9c51c66940a1/environment/docker-compose.yaml +16 -0
- heldout/sloria__environs-9c51c66940a1/instruction.md +19 -0
- heldout/sloria__environs-9c51c66940a1/solution/patch.diff +42 -0
- heldout/sloria__environs-9c51c66940a1/solution/solve.sh +6 -0
- heldout/sloria__environs-9c51c66940a1/task.toml +126 -0
- heldout/sloria__environs-9c51c66940a1/tests/f2p.json +4 -0
- heldout/sloria__environs-9c51c66940a1/tests/p2p.json +52 -0
- heldout/sloria__environs-9c51c66940a1/tests/test.sh +50 -0
- heldout/sloria__environs-9c51c66940a1/tests/verifier.py +475 -0
- heldout/sloria__environs-9d1ff82555e0/environment/Dockerfile +36 -0
- heldout/sloria__environs-9d1ff82555e0/environment/docker-compose.yaml +16 -0
- heldout/sloria__environs-9d1ff82555e0/instruction.md +10 -0
- heldout/sloria__environs-9d1ff82555e0/solution/patch.diff +49 -0
- heldout/sloria__environs-9d1ff82555e0/solution/solve.sh +6 -0
- heldout/sloria__environs-9d1ff82555e0/task.toml +126 -0
- heldout/sloria__environs-9d1ff82555e0/tests/f2p.json +4 -0
- heldout/sloria__environs-9d1ff82555e0/tests/p2p.json +52 -0
- heldout/sloria__environs-9d1ff82555e0/tests/test.sh +61 -0
- heldout/sloria__environs-9d1ff82555e0/tests/verifier.py +475 -0
- heldout/sloria__environs-aa99f02fb39d/environment/Dockerfile +36 -0
- heldout/sloria__environs-aa99f02fb39d/environment/docker-compose.yaml +16 -0
- heldout/sloria__environs-aa99f02fb39d/instruction.md +10 -0
- heldout/sloria__environs-aa99f02fb39d/solution/patch.diff +83 -0
- heldout/sloria__environs-aa99f02fb39d/solution/solve.sh +6 -0
- heldout/sloria__environs-aa99f02fb39d/task.toml +125 -0
- heldout/sloria__environs-aa99f02fb39d/tests/f2p.json +3 -0
- heldout/sloria__environs-aa99f02fb39d/tests/p2p.json +52 -0
heldout/mirumee__google-i18n-address-311eb0f1a0fa/tests/test.sh
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 21693704723afbe9a9fadffa206caaa41bf217e2 -- tests/test_i18naddress.py tests/test_normalization.py || true
|
| 8 |
+
git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH'
|
| 9 |
+
diff --git a/tests/test_i18naddress.py b/tests/test_i18naddress.py
|
| 10 |
+
index 95a722b..8dbfb56 100644
|
| 11 |
+
--- a/tests/test_i18naddress.py
|
| 12 |
+
+++ b/tests/test_i18naddress.py
|
| 13 |
+
@@ -20,6 +20,31 @@ def test_dictionary_access():
|
| 14 |
+
assert state['name'] == 'Nevada'
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
+def test_validation_rules_canada():
|
| 18 |
+
+ validation_data = get_validation_rules({'country_code': 'CA'})
|
| 19 |
+
+ assert validation_data.country_area_choices == [
|
| 20 |
+
+ ('AB', 'Alberta'),
|
| 21 |
+
+ ('BC', 'British Columbia'),
|
| 22 |
+
+ ('BC', 'Colombie-Britannique'),
|
| 23 |
+
+ ('MB', 'Manitoba'),
|
| 24 |
+
+ ('NB', 'New Brunswick'),
|
| 25 |
+
+ ('NB', 'Nouveau-Brunswick'),
|
| 26 |
+
+ ('NL', 'Newfoundland and Labrador'),
|
| 27 |
+
+ ('NL', 'Terre-Neuve-et-Labrador'),
|
| 28 |
+
+ ('NT', 'Northwest Territories'),
|
| 29 |
+
+ ('NT', 'Territoires du Nord-Ouest'),
|
| 30 |
+
+ ('NS', 'Nouvelle-Écosse'),
|
| 31 |
+
+ ('NS', 'Nova Scotia'),
|
| 32 |
+
+ ('NU', 'Nunavut'),
|
| 33 |
+
+ ('ON', 'Ontario'),
|
| 34 |
+
+ ('PE', 'Prince Edward Island'),
|
| 35 |
+
+ ('PE', 'Île-du-Prince-Édouard'),
|
| 36 |
+
+ ('QC', 'Quebec'),
|
| 37 |
+
+ ('QC', 'Québec'),
|
| 38 |
+
+ ('SK', 'Saskatchewan'),
|
| 39 |
+
+ ('YT', 'Yukon')]
|
| 40 |
+
+
|
| 41 |
+
+
|
| 42 |
+
def test_validation_rules_switzerland():
|
| 43 |
+
validation_data = get_validation_rules({'country_code': 'CH'})
|
| 44 |
+
assert validation_data.allowed_fields == {
|
| 45 |
+
diff --git a/tests/test_normalization.py b/tests/test_normalization.py
|
| 46 |
+
index bc43fd5..77a551b 100644
|
| 47 |
+
--- a/tests/test_normalization.py
|
| 48 |
+
+++ b/tests/test_normalization.py
|
| 49 |
+
@@ -149,6 +149,22 @@ def test_address_latinization():
|
| 50 |
+
'street_address': '1600 Charleston Rd.'}
|
| 51 |
+
address = latinize_address(address)
|
| 52 |
+
assert address['country_area'] == 'California'
|
| 53 |
+
+ address = {
|
| 54 |
+
+ 'country_code': 'CN',
|
| 55 |
+
+ 'country_area': '云南省',
|
| 56 |
+
+ 'postal_code': '677400',
|
| 57 |
+
+ 'city': '临沧市',
|
| 58 |
+
+ 'city_area': '凤庆县',
|
| 59 |
+
+ 'street_address': '中关村东路1号'}
|
| 60 |
+
+ address = latinize_address(address)
|
| 61 |
+
+ assert address == {
|
| 62 |
+
+ 'country_code': 'CN',
|
| 63 |
+
+ 'country_area': 'Yunnan Sheng',
|
| 64 |
+
+ 'postal_code': '677400',
|
| 65 |
+
+ 'city': 'Lincang Shi',
|
| 66 |
+
+ 'city_area': 'Fengqing Xian',
|
| 67 |
+
+ 'street_address': '中关村东路1号',
|
| 68 |
+
+ 'sorting_code': ''}
|
| 69 |
+
address = {
|
| 70 |
+
'name': 'Zhang San',
|
| 71 |
+
'company_name': 'Beijing Kid Toy Company',
|
| 72 |
+
|
| 73 |
+
EOF_R2E_TEST_PATCH
|
| 74 |
+
R2E_APPLY_RC=$?
|
| 75 |
+
if [ "$R2E_APPLY_RC" -ne 0 ]; then
|
| 76 |
+
echo "0.000000" > /logs/verifier/reward.txt
|
| 77 |
+
printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json
|
| 78 |
+
echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2
|
| 79 |
+
exit 0
|
| 80 |
+
fi
|
| 81 |
+
( python -m pytest -v tests/test_i18naddress.py tests/test_normalization.py ) > /logs/verifier/test_output.log 2>&1
|
| 82 |
+
TEST_EXIT_CODE=$?
|
| 83 |
+
cat /logs/verifier/test_output.log
|
| 84 |
+
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 tests/test_i18naddress.py tests/test_normalization.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; }
|
| 85 |
+
git checkout 21693704723afbe9a9fadffa206caaa41bf217e2 -- tests/test_i18naddress.py tests/test_normalization.py || true
|
| 86 |
+
exit 0
|
heldout/mirumee__google-i18n-address-311eb0f1a0fa/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/osantana__prettyconf-16570d889998/environment/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv pr_runtime
|
| 2 |
+
FROM local/osantana__prettyconf
|
| 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 4572e2897fd8172cb47a26ac159734eef1ba669e 2>/dev/null \
|
| 28 |
+
|| git fetch --unshallow origin 2>/dev/null || true
|
| 29 |
+
RUN git reset --hard 4572e2897fd8172cb47a26ac159734eef1ba669e && 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 4572e2897fd8172cb47a26ac159734eef1ba669e \
|
| 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/osantana__prettyconf-16570d889998/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/osantana__prettyconf-16570d889998/instruction.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue
|
| 2 |
+
|
| 3 |
+
**Title:** `config.eval` fails due to incorrect type casting
|
| 4 |
+
|
| 5 |
+
## Description
|
| 6 |
+
When attempting to use `config.eval`, the operation fails because of an incorrect type cast. This prevents the configuration from being evaluated successfully and blocks further progress. The expected behavior is for `config.eval` to correctly handle all necessary type conversions and complete its evaluation without errors.
|
| 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 `4572e2897fd8` and running the modified tests.
|
heldout/osantana__prettyconf-16570d889998/solution/patch.diff
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/CHANGES.txt b/CHANGES.txt
|
| 2 |
+
index 2b9229c..a29d240 100644
|
| 3 |
+
--- a/CHANGES.txt
|
| 4 |
+
+++ b/CHANGES.txt
|
| 5 |
+
@@ -1,3 +1,8 @@
|
| 6 |
+
+1.2.3
|
| 7 |
+
+=====
|
| 8 |
+
+
|
| 9 |
+
+ - Fix a blocker issue with ``config.eval`` cast and add a test to prevent regressions
|
| 10 |
+
+
|
| 11 |
+
1.2.2
|
| 12 |
+
=====
|
| 13 |
+
|
| 14 |
+
diff --git a/prettyconf/configuration.py b/prettyconf/configuration.py
|
| 15 |
+
index 3409546..c167fd6 100644
|
| 16 |
+
--- a/prettyconf/configuration.py
|
| 17 |
+
+++ b/prettyconf/configuration.py
|
| 18 |
+
@@ -77,7 +77,7 @@ class Configuration(object):
|
| 19 |
+
list = List()
|
| 20 |
+
tuple = Tuple()
|
| 21 |
+
option = Option
|
| 22 |
+
- eval = ast.literal_eval
|
| 23 |
+
+ eval = staticmethod(ast.literal_eval)
|
| 24 |
+
|
| 25 |
+
def __init__(self, configs=None, starting_path=None, root_path="/"):
|
| 26 |
+
if configs is None:
|
heldout/osantana__prettyconf-16570d889998/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/osantana__prettyconf-16570d889998/task.toml
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "commit-runtime/osantana__prettyconf-16570d889998"
|
| 5 |
+
description = "Fix a blocker issue with config.eval cast and add a test to prevent regressions"
|
| 6 |
+
|
| 7 |
+
[metadata]
|
| 8 |
+
difficulty = "small"
|
| 9 |
+
category = "bugfix"
|
| 10 |
+
keywords = [
|
| 11 |
+
"prettyconf",
|
| 12 |
+
"commit_runtime",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
[metadata.repo2env]
|
| 16 |
+
pipeline = "commit_runtime"
|
| 17 |
+
pipeline_version = "0.8.3"
|
| 18 |
+
repo = "osantana/prettyconf"
|
| 19 |
+
ref = "4572e2897fd8172cb47a26ac159734eef1ba669e"
|
| 20 |
+
reference = "https://github.com/osantana/prettyconf/commit/16570d889998f3e83c5230a03daf8ad60bff64e6"
|
| 21 |
+
source_access = "public"
|
| 22 |
+
built_at = "2026-09-24T13:12:11.425066+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:1200e462d7db36b2690b03bf1249663c13632fc22ba0d556112405537c608d1b"
|
| 30 |
+
|
| 31 |
+
[metadata.repo2env.commit_runtime]
|
| 32 |
+
commit_sha = "16570d889998f3e83c5230a03daf8ad60bff64e6"
|
| 33 |
+
parent_sha = "4572e2897fd8172cb47a26ac159734eef1ba669e"
|
| 34 |
+
authored_at = "2016-02-16T13:09:42-02:00"
|
| 35 |
+
author_email = "github@osantana.me"
|
| 36 |
+
subject = "Fix a blocker issue with config.eval cast and add a test to prevent regressions"
|
| 37 |
+
fail_to_pass = [
|
| 38 |
+
"tests/test_casts.py::EvalCastTestCase::test_if_cast_is_unbounded",
|
| 39 |
+
]
|
| 40 |
+
pass_to_pass = [
|
| 41 |
+
"tests/test_casts.py::BooleanCastTestCase::test_basic_boolean_cast",
|
| 42 |
+
"tests/test_casts.py::BooleanCastTestCase::test_fail_invalid_boolean_cast",
|
| 43 |
+
"tests/test_casts.py::BooleanCastTestCase::test_more_valid_boolean_values",
|
| 44 |
+
"tests/test_casts.py::OptionCastTestCase::test_fail_invalid_option_config",
|
| 45 |
+
"tests/test_casts.py::OptionCastTestCase::test_options",
|
| 46 |
+
"tests/test_casts.py::SequenceCastTestCase::test_basic_list_cast",
|
| 47 |
+
"tests/test_casts.py::SequenceCastTestCase::test_basic_tuple_cast",
|
| 48 |
+
]
|
| 49 |
+
validation_status = "verified"
|
| 50 |
+
bootstrap_image = "local-venv:osantana__prettyconf"
|
| 51 |
+
instruction_synthesized = true
|
| 52 |
+
llm_cost_usd = 0.0
|
| 53 |
+
|
| 54 |
+
[metadata.repo2env.reward_calibration]
|
| 55 |
+
f2p_count = 1
|
| 56 |
+
p2p_count = 7
|
| 57 |
+
source_files = 2
|
| 58 |
+
loc_changed = 7
|
| 59 |
+
difficulty = "small"
|
| 60 |
+
|
| 61 |
+
[metadata.repo2env.evaluation]
|
| 62 |
+
schema_version = "1"
|
| 63 |
+
status = "unverified"
|
| 64 |
+
stage = "generation"
|
| 65 |
+
reason_codes = [
|
| 66 |
+
"validation_not_run",
|
| 67 |
+
]
|
| 68 |
+
detail = "Generated task; validation has not been established."
|
| 69 |
+
provenance = "unknown"
|
| 70 |
+
evidence = []
|
| 71 |
+
|
| 72 |
+
[metadata.repo2env.reproducibility]
|
| 73 |
+
mode = "local_only"
|
| 74 |
+
image_ref = "local/osantana__prettyconf"
|
| 75 |
+
image_tag = "local/osantana__prettyconf"
|
| 76 |
+
image_visibility = "private"
|
| 77 |
+
|
| 78 |
+
[agent]
|
| 79 |
+
timeout_sec = 1800.0
|
| 80 |
+
|
| 81 |
+
[verifier]
|
| 82 |
+
timeout_sec = 300.0
|
heldout/osantana__prettyconf-16570d889998/tests/f2p.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"tests/test_casts.py::EvalCastTestCase::test_if_cast_is_unbounded"
|
| 3 |
+
]
|
heldout/osantana__prettyconf-16570d889998/tests/p2p.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"tests/test_casts.py::BooleanCastTestCase::test_basic_boolean_cast",
|
| 3 |
+
"tests/test_casts.py::BooleanCastTestCase::test_fail_invalid_boolean_cast",
|
| 4 |
+
"tests/test_casts.py::BooleanCastTestCase::test_more_valid_boolean_values",
|
| 5 |
+
"tests/test_casts.py::OptionCastTestCase::test_fail_invalid_option_config",
|
| 6 |
+
"tests/test_casts.py::OptionCastTestCase::test_options",
|
| 7 |
+
"tests/test_casts.py::SequenceCastTestCase::test_basic_list_cast",
|
| 8 |
+
"tests/test_casts.py::SequenceCastTestCase::test_basic_tuple_cast"
|
| 9 |
+
]
|
heldout/osantana__prettyconf-16570d889998/tests/test.sh
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 4572e2897fd8172cb47a26ac159734eef1ba669e -- tests/test_casts.py || true
|
| 8 |
+
git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH'
|
| 9 |
+
diff --git a/tests/test_casts.py b/tests/test_casts.py
|
| 10 |
+
index 0bdb4b8..0a5f68f 100644
|
| 11 |
+
--- a/tests/test_casts.py
|
| 12 |
+
+++ b/tests/test_casts.py
|
| 13 |
+
@@ -4,6 +4,7 @@
|
| 14 |
+
from unittest import TestCase
|
| 15 |
+
|
| 16 |
+
from prettyconf.casts import Boolean, Option, InvalidConfiguration, List, Tuple
|
| 17 |
+
+from prettyconf import config
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class BooleanCastTestCase(TestCase):
|
| 21 |
+
@@ -81,3 +82,8 @@ class OptionCastTestCase(TestCase):
|
| 22 |
+
|
| 23 |
+
with self.assertRaises(InvalidConfiguration):
|
| 24 |
+
option("unknown")
|
| 25 |
+
+
|
| 26 |
+
+
|
| 27 |
+
+class EvalCastTestCase(TestCase):
|
| 28 |
+
+ def test_if_cast_is_unbounded(self):
|
| 29 |
+
+ self.assertIsNone(config.eval("None"))
|
| 30 |
+
|
| 31 |
+
EOF_R2E_TEST_PATCH
|
| 32 |
+
R2E_APPLY_RC=$?
|
| 33 |
+
if [ "$R2E_APPLY_RC" -ne 0 ]; then
|
| 34 |
+
echo "0.000000" > /logs/verifier/reward.txt
|
| 35 |
+
printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json
|
| 36 |
+
echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2
|
| 37 |
+
exit 0
|
| 38 |
+
fi
|
| 39 |
+
( python -m pytest -v tests/test_casts.py ) > /logs/verifier/test_output.log 2>&1
|
| 40 |
+
TEST_EXIT_CODE=$?
|
| 41 |
+
cat /logs/verifier/test_output.log
|
| 42 |
+
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 tests/test_casts.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; }
|
| 43 |
+
git checkout 4572e2897fd8172cb47a26ac159734eef1ba669e -- tests/test_casts.py || true
|
| 44 |
+
exit 0
|
heldout/osantana__prettyconf-16570d889998/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/sloria__environs-1a47a3658bf7/environment/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv pr_runtime
|
| 2 |
+
FROM local/sloria__environs
|
| 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 f678dabd2ebb32a22a90f439d8518f8c2ddcb60c 2>/dev/null \
|
| 28 |
+
|| git fetch --unshallow origin 2>/dev/null || true
|
| 29 |
+
RUN git reset --hard f678dabd2ebb32a22a90f439d8518f8c2ddcb60c && 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 f678dabd2ebb32a22a90f439d8518f8c2ddcb60c \
|
| 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/sloria__environs-1a47a3658bf7/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/sloria__environs-1a47a3658bf7/instruction.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue
|
| 2 |
+
|
| 3 |
+
**Title:** Variable expansion incorrectly discards trailing string content
|
| 4 |
+
|
| 5 |
+
## Description
|
| 6 |
+
When processing a string with variable expansion enabled (e.g., `expand_vars=True`), if the string begins with a variable reference like `${VAR}` but includes additional characters or content afterwards, the entire trailing portion of the string is unexpectedly discarded.
|
| 7 |
+
|
| 8 |
+
**Reproduction:**
|
| 9 |
+
Given a variable `A="foo"`, processing the string `"${A};Val_B;"` with variable expansion enabled.
|
| 10 |
+
|
| 11 |
+
**Actual Result:** The output is `"foo"`.
|
| 12 |
+
**Expected Result:** The output should be `"foo;Val_B;"`.
|
| 13 |
+
|
| 14 |
+
## Task
|
| 15 |
+
|
| 16 |
+
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 `f678dabd2ebb` and running the modified tests.
|
heldout/sloria__environs-1a47a3658bf7/solution/patch.diff
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
|
| 2 |
+
index 31b7f06..79e79e0 100644
|
| 3 |
+
--- a/CHANGELOG.md
|
| 4 |
+
+++ b/CHANGELOG.md
|
| 5 |
+
@@ -2,6 +2,11 @@
|
| 6 |
+
|
| 7 |
+
## next
|
| 8 |
+
|
| 9 |
+
+Bug fixes:
|
| 10 |
+
+
|
| 11 |
+
+- Fix variable expansion with other characters ([#359](https://github.com/sloria/environs/issues/359)).
|
| 12 |
+
+ Thanks [flymanzhao](https://github.com/flymanzhao) for reporting and [veeceey](https://github.com/veeceey) for the PR.
|
| 13 |
+
+
|
| 14 |
+
Other changes:
|
| 15 |
+
|
| 16 |
+
- Update lowest supported marshmallow version to 3.26.2 ([#448](https://github.com/sloria/environs/pull/448)).
|
| 17 |
+
diff --git a/src/environs/__init__.py b/src/environs/__init__.py
|
| 18 |
+
index f418392..dfd647e 100644
|
| 19 |
+
--- a/src/environs/__init__.py
|
| 20 |
+
+++ b/src/environs/__init__.py
|
| 21 |
+
@@ -523,7 +523,7 @@ class Env:
|
| 22 |
+
env_key = self._get_key(key, omit_prefix=proxied)
|
| 23 |
+
value = self._get_value(env_key, default)
|
| 24 |
+
if hasattr(value, "strip"):
|
| 25 |
+
- expand_match = self.expand_vars and _EXPANDED_VAR_PATTERN.match(value)
|
| 26 |
+
+ expand_match = self.expand_vars and _EXPANDED_VAR_PATTERN.fullmatch(value)
|
| 27 |
+
if expand_match: # Full match expand_vars - special case keep default
|
| 28 |
+
proxied_key: _StrType = expand_match.groups()[0]
|
| 29 |
+
subs_default: _StrType | None = expand_match.groups()[1]
|
heldout/sloria__environs-1a47a3658bf7/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/sloria__environs-1a47a3658bf7/task.toml
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "commit-runtime/sloria__environs-1a47a3658bf7"
|
| 5 |
+
description = "use fullmatch for expand_vars single-variable detection (#450)"
|
| 6 |
+
|
| 7 |
+
[metadata]
|
| 8 |
+
difficulty = "small"
|
| 9 |
+
category = "bugfix"
|
| 10 |
+
keywords = [
|
| 11 |
+
"environs",
|
| 12 |
+
"commit_runtime",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
[metadata.repo2env]
|
| 16 |
+
pipeline = "commit_runtime"
|
| 17 |
+
pipeline_version = "0.8.3"
|
| 18 |
+
repo = "sloria/environs"
|
| 19 |
+
ref = "f678dabd2ebb32a22a90f439d8518f8c2ddcb60c"
|
| 20 |
+
reference = "https://github.com/sloria/environs/commit/1a47a3658bf705e6270cb685efc38c22264c9110"
|
| 21 |
+
source_access = "public"
|
| 22 |
+
built_at = "2026-09-24T13:07:49.771316+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:696c2b9120b71a40eb51e7e88a6096337c1d0a3f1bd306939d6d002e5e4a1347"
|
| 30 |
+
|
| 31 |
+
[metadata.repo2env.commit_runtime]
|
| 32 |
+
commit_sha = "1a47a3658bf705e6270cb685efc38c22264c9110"
|
| 33 |
+
parent_sha = "f678dabd2ebb32a22a90f439d8518f8c2ddcb60c"
|
| 34 |
+
authored_at = "2026-02-19T19:59:13-08:00"
|
| 35 |
+
author_email = "34209028+veeceey@users.noreply.github.com"
|
| 36 |
+
subject = "fix: use fullmatch for expand_vars single-variable detection (#450)"
|
| 37 |
+
fail_to_pass = [
|
| 38 |
+
"tests/test_environs.py::TestExpandVars::test_expand_var_at_start_with_trailing_content",
|
| 39 |
+
]
|
| 40 |
+
pass_to_pass = [
|
| 41 |
+
"tests/test_environs.py::TestCasting::test_basic",
|
| 42 |
+
"tests/test_environs.py::TestCasting::test_bool",
|
| 43 |
+
"tests/test_environs.py::TestCasting::test_call",
|
| 44 |
+
"tests/test_environs.py::TestCasting::test_call_with_default",
|
| 45 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_keys_values",
|
| 46 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_list",
|
| 47 |
+
"tests/test_environs.py::TestCasting::test_date_cast",
|
| 48 |
+
"tests/test_environs.py::TestCasting::test_datetime_cast",
|
| 49 |
+
"tests/test_environs.py::TestCasting::test_decimal_cast",
|
| 50 |
+
"tests/test_environs.py::TestCasting::test_default_set",
|
| 51 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[date]",
|
| 52 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[datetime]",
|
| 53 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[time]",
|
| 54 |
+
"tests/test_environs.py::TestCasting::test_dict",
|
| 55 |
+
"tests/test_environs.py::TestCasting::test_dict_with_colon_key_value_delimiter",
|
| 56 |
+
"tests/test_environs.py::TestCasting::test_dict_with_dict_default",
|
| 57 |
+
"tests/test_environs.py::TestCasting::test_dict_with_equal",
|
| 58 |
+
"tests/test_environs.py::TestCasting::test_dict_with_spaces_as_delimiter",
|
| 59 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_keys",
|
| 60 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_values",
|
| 61 |
+
"tests/test_environs.py::TestCasting::test_dict_without_subcast_keys",
|
| 62 |
+
"tests/test_environs.py::TestCasting::test_empty_str",
|
| 63 |
+
"tests/test_environs.py::TestCasting::test_enum_by_value_field",
|
| 64 |
+
"tests/test_environs.py::TestCasting::test_enum_by_value_true",
|
| 65 |
+
"tests/test_environs.py::TestCasting::test_enum_cast",
|
| 66 |
+
"tests/test_environs.py::TestCasting::test_enum_default",
|
| 67 |
+
"tests/test_environs.py::TestCasting::test_float_cast",
|
| 68 |
+
"tests/test_environs.py::TestCasting::test_int_cast",
|
| 69 |
+
"tests/test_environs.py::TestCasting::test_invalid_enum",
|
| 70 |
+
"tests/test_environs.py::TestCasting::test_invalid_int",
|
| 71 |
+
"tests/test_environs.py::TestCasting::test_invalid_json_raises_error",
|
| 72 |
+
"tests/test_environs.py::TestCasting::test_invalid_log_level",
|
| 73 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[42]",
|
| 74 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo@bar]",
|
| 75 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo]",
|
| 76 |
+
"tests/test_environs.py::TestCasting::test_json_cast",
|
| 77 |
+
"tests/test_environs.py::TestCasting::test_json_default",
|
| 78 |
+
"tests/test_environs.py::TestCasting::test_list_cast",
|
| 79 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_from_list",
|
| 80 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_list_and_subcast",
|
| 81 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_none",
|
| 82 |
+
"tests/test_environs.py::TestCasting::test_list_with_empty_env_and_subcast",
|
| 83 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces",
|
| 84 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces_as_delimiter",
|
| 85 |
+
"tests/test_environs.py::TestCasting::test_list_with_subcast",
|
| 86 |
+
"tests/test_environs.py::TestCasting::test_log_level_cast",
|
| 87 |
+
"tests/test_environs.py::TestCasting::test_missing_raises_error",
|
| 88 |
+
"tests/test_environs.py::TestCasting::test_path_cast",
|
| 89 |
+
"tests/test_environs.py::TestCasting::test_path_default_value",
|
| 90 |
+
"tests/test_environs.py::TestCasting::test_time_cast",
|
| 91 |
+
]
|
| 92 |
+
validation_status = "verified"
|
| 93 |
+
bootstrap_image = "local-venv:sloria__environs"
|
| 94 |
+
instruction_synthesized = true
|
| 95 |
+
llm_cost_usd = 0.001491
|
| 96 |
+
|
| 97 |
+
[metadata.repo2env.reward_calibration]
|
| 98 |
+
f2p_count = 1
|
| 99 |
+
p2p_count = 50
|
| 100 |
+
source_files = 2
|
| 101 |
+
loc_changed = 7
|
| 102 |
+
difficulty = "small"
|
| 103 |
+
|
| 104 |
+
[metadata.repo2env.evaluation]
|
| 105 |
+
schema_version = "1"
|
| 106 |
+
status = "unverified"
|
| 107 |
+
stage = "generation"
|
| 108 |
+
reason_codes = [
|
| 109 |
+
"validation_not_run",
|
| 110 |
+
]
|
| 111 |
+
detail = "Generated task; validation has not been established."
|
| 112 |
+
provenance = "unknown"
|
| 113 |
+
evidence = []
|
| 114 |
+
|
| 115 |
+
[metadata.repo2env.reproducibility]
|
| 116 |
+
mode = "local_only"
|
| 117 |
+
image_ref = "local/sloria__environs"
|
| 118 |
+
image_tag = "local/sloria__environs"
|
| 119 |
+
image_visibility = "private"
|
| 120 |
+
|
| 121 |
+
[agent]
|
| 122 |
+
timeout_sec = 1800.0
|
| 123 |
+
|
| 124 |
+
[verifier]
|
| 125 |
+
timeout_sec = 300.0
|
heldout/sloria__environs-1a47a3658bf7/tests/f2p.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"tests/test_environs.py::TestExpandVars::test_expand_var_at_start_with_trailing_content"
|
| 3 |
+
]
|
heldout/sloria__environs-1a47a3658bf7/tests/p2p.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"tests/test_environs.py::TestCasting::test_basic",
|
| 3 |
+
"tests/test_environs.py::TestCasting::test_bool",
|
| 4 |
+
"tests/test_environs.py::TestCasting::test_call",
|
| 5 |
+
"tests/test_environs.py::TestCasting::test_call_with_default",
|
| 6 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_keys_values",
|
| 7 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_list",
|
| 8 |
+
"tests/test_environs.py::TestCasting::test_date_cast",
|
| 9 |
+
"tests/test_environs.py::TestCasting::test_datetime_cast",
|
| 10 |
+
"tests/test_environs.py::TestCasting::test_decimal_cast",
|
| 11 |
+
"tests/test_environs.py::TestCasting::test_default_set",
|
| 12 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[date]",
|
| 13 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[datetime]",
|
| 14 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[time]",
|
| 15 |
+
"tests/test_environs.py::TestCasting::test_dict",
|
| 16 |
+
"tests/test_environs.py::TestCasting::test_dict_with_colon_key_value_delimiter",
|
| 17 |
+
"tests/test_environs.py::TestCasting::test_dict_with_dict_default",
|
| 18 |
+
"tests/test_environs.py::TestCasting::test_dict_with_equal",
|
| 19 |
+
"tests/test_environs.py::TestCasting::test_dict_with_spaces_as_delimiter",
|
| 20 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_keys",
|
| 21 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_values",
|
| 22 |
+
"tests/test_environs.py::TestCasting::test_dict_without_subcast_keys",
|
| 23 |
+
"tests/test_environs.py::TestCasting::test_empty_str",
|
| 24 |
+
"tests/test_environs.py::TestCasting::test_enum_by_value_field",
|
| 25 |
+
"tests/test_environs.py::TestCasting::test_enum_by_value_true",
|
| 26 |
+
"tests/test_environs.py::TestCasting::test_enum_cast",
|
| 27 |
+
"tests/test_environs.py::TestCasting::test_enum_default",
|
| 28 |
+
"tests/test_environs.py::TestCasting::test_float_cast",
|
| 29 |
+
"tests/test_environs.py::TestCasting::test_int_cast",
|
| 30 |
+
"tests/test_environs.py::TestCasting::test_invalid_enum",
|
| 31 |
+
"tests/test_environs.py::TestCasting::test_invalid_int",
|
| 32 |
+
"tests/test_environs.py::TestCasting::test_invalid_json_raises_error",
|
| 33 |
+
"tests/test_environs.py::TestCasting::test_invalid_log_level",
|
| 34 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[42]",
|
| 35 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo@bar]",
|
| 36 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo]",
|
| 37 |
+
"tests/test_environs.py::TestCasting::test_json_cast",
|
| 38 |
+
"tests/test_environs.py::TestCasting::test_json_default",
|
| 39 |
+
"tests/test_environs.py::TestCasting::test_list_cast",
|
| 40 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_from_list",
|
| 41 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_list_and_subcast",
|
| 42 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_none",
|
| 43 |
+
"tests/test_environs.py::TestCasting::test_list_with_empty_env_and_subcast",
|
| 44 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces",
|
| 45 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces_as_delimiter",
|
| 46 |
+
"tests/test_environs.py::TestCasting::test_list_with_subcast",
|
| 47 |
+
"tests/test_environs.py::TestCasting::test_log_level_cast",
|
| 48 |
+
"tests/test_environs.py::TestCasting::test_missing_raises_error",
|
| 49 |
+
"tests/test_environs.py::TestCasting::test_path_cast",
|
| 50 |
+
"tests/test_environs.py::TestCasting::test_path_default_value",
|
| 51 |
+
"tests/test_environs.py::TestCasting::test_time_cast"
|
| 52 |
+
]
|
heldout/sloria__environs-1a47a3658bf7/tests/test.sh
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 f678dabd2ebb32a22a90f439d8518f8c2ddcb60c -- tests/test_environs.py || true
|
| 8 |
+
git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH'
|
| 9 |
+
diff --git a/tests/test_environs.py b/tests/test_environs.py
|
| 10 |
+
index f8c1053..420475c 100644
|
| 11 |
+
--- a/tests/test_environs.py
|
| 12 |
+
+++ b/tests/test_environs.py
|
| 13 |
+
@@ -1099,6 +1099,16 @@ class TestExpandVars:
|
| 14 |
+
"wget_params": '--header="Referer: https://radiocut.fm/"',
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
+ def test_expand_var_at_start_with_trailing_content(self, env: environs.Env, set_env):
|
| 18 |
+
+ """Regression test for https://github.com/sloria/environs/issues/359"""
|
| 19 |
+
+ set_env(
|
| 20 |
+
+ {
|
| 21 |
+
+ "A": "Val_A",
|
| 22 |
+
+ "B": "${A};Val_B;",
|
| 23 |
+
+ },
|
| 24 |
+
+ )
|
| 25 |
+
+ assert env.str("B") == "Val_A;Val_B;"
|
| 26 |
+
+
|
| 27 |
+
|
| 28 |
+
class TestFileAwareEnv:
|
| 29 |
+
@pytest.fixture
|
| 30 |
+
|
| 31 |
+
EOF_R2E_TEST_PATCH
|
| 32 |
+
R2E_APPLY_RC=$?
|
| 33 |
+
if [ "$R2E_APPLY_RC" -ne 0 ]; then
|
| 34 |
+
echo "0.000000" > /logs/verifier/reward.txt
|
| 35 |
+
printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json
|
| 36 |
+
echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2
|
| 37 |
+
exit 0
|
| 38 |
+
fi
|
| 39 |
+
( python -m pytest -v tests/test_environs.py ) > /logs/verifier/test_output.log 2>&1
|
| 40 |
+
TEST_EXIT_CODE=$?
|
| 41 |
+
cat /logs/verifier/test_output.log
|
| 42 |
+
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 tests/test_environs.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; }
|
| 43 |
+
git checkout f678dabd2ebb32a22a90f439d8518f8c2ddcb60c -- tests/test_environs.py || true
|
| 44 |
+
exit 0
|
heldout/sloria__environs-1a47a3658bf7/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/sloria__environs-9c51c66940a1/environment/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv pr_runtime
|
| 2 |
+
FROM local/sloria__environs
|
| 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 4654e60b62aae63638533c6aa8d4605680d2e3f1 2>/dev/null \
|
| 28 |
+
|| git fetch --unshallow origin 2>/dev/null || true
|
| 29 |
+
RUN git reset --hard 4654e60b62aae63638533c6aa8d4605680d2e3f1 && 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 4654e60b62aae63638533c6aa8d4605680d2e3f1 \
|
| 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/sloria__environs-9c51c66940a1/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/sloria__environs-9c51c66940a1/instruction.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue
|
| 2 |
+
|
| 3 |
+
**Title:** Environment variables from `os.environ` are overridden by `.env` files
|
| 4 |
+
|
| 5 |
+
## Description
|
| 6 |
+
When an environment variable is already set in the system's `os.environ` (e.g., from the shell or system-wide configuration), and the same variable is also defined within a `.env` file, the value from the `.env` file incorrectly takes precedence.
|
| 7 |
+
|
| 8 |
+
**Reproduction:**
|
| 9 |
+
1. Set an environment variable in your shell: `export MY_VAR=from_shell`
|
| 10 |
+
2. Create a `.env` file with the same variable: `echo "MY_VAR=from_dot_env" > .env`
|
| 11 |
+
3. Load environment variables (e.g., using a library that processes `.env` files).
|
| 12 |
+
4. Check the value of `MY_VAR`.
|
| 13 |
+
|
| 14 |
+
**Actual Behavior:** The application reads `MY_VAR` as `from_dot_env`.
|
| 15 |
+
**Expected Behavior:** The application should read `MY_VAR` as `from_shell`, respecting the precedence of `os.environ` over `.env` files.
|
| 16 |
+
|
| 17 |
+
## Task
|
| 18 |
+
|
| 19 |
+
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 `4654e60b62aa` and running the modified tests.
|
heldout/sloria__environs-9c51c66940a1/solution/patch.diff
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
|
| 2 |
+
index c94fb52..e8be1f4 100644
|
| 3 |
+
--- a/CHANGELOG.md
|
| 4 |
+
+++ b/CHANGELOG.md
|
| 5 |
+
@@ -1,5 +1,12 @@
|
| 6 |
+
# Changelog
|
| 7 |
+
|
| 8 |
+
+## unreleased
|
| 9 |
+
+
|
| 10 |
+
+Bug fixes:
|
| 11 |
+
+
|
| 12 |
+
+- Exported environment variables take precedence over `.env` files (regression from 15.0.0) ([#464](https://github.com/sloria/environs/issues/464)).
|
| 13 |
+
+ Thanks [DougEdey-Slice](https://github.com/DougEdey-Slice) for reporting.
|
| 14 |
+
+
|
| 15 |
+
## 15.0.0 (2026-03-31)
|
| 16 |
+
|
| 17 |
+
Features:
|
| 18 |
+
diff --git a/src/environs/__init__.py b/src/environs/__init__.py
|
| 19 |
+
index 66432c8..8168cec 100644
|
| 20 |
+
--- a/src/environs/__init__.py
|
| 21 |
+
+++ b/src/environs/__init__.py
|
| 22 |
+
@@ -595,9 +595,9 @@ class Env:
|
| 23 |
+
|
| 24 |
+
def _get_value(self, env_key: _StrType, default: typing.Any) -> typing.Any:
|
| 25 |
+
try:
|
| 26 |
+
- return self._environ[env_key]
|
| 27 |
+
+ return os.environ[env_key]
|
| 28 |
+
except KeyError:
|
| 29 |
+
- return os.environ.get(env_key, default)
|
| 30 |
+
+ return self._environ.get(env_key, default)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class FileAwareEnv(Env):
|
| 34 |
+
@@ -619,7 +619,7 @@ class FileAwareEnv(Env):
|
| 35 |
+
def _get_value(self, env_key: _StrType, default: typing.Any) -> typing.Any:
|
| 36 |
+
"""Return the contents of the file referenced in key <env_key>_FILE, if present."""
|
| 37 |
+
file_key = f"{env_key}{self.file_suffix}"
|
| 38 |
+
- if file_path := self._environ.get(file_key) or os.environ.get(file_key):
|
| 39 |
+
+ if file_path := os.environ.get(file_key) or self._environ.get(file_key):
|
| 40 |
+
try:
|
| 41 |
+
value: _StrType = Path(file_path).read_text()
|
| 42 |
+
return value.strip() if self.strip_whitespace else value
|
heldout/sloria__environs-9c51c66940a1/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/sloria__environs-9c51c66940a1/task.toml
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "commit-runtime/sloria__environs-9c51c66940a1"
|
| 5 |
+
description = "Fix precedence of os.environ over .env (#465)"
|
| 6 |
+
|
| 7 |
+
[metadata]
|
| 8 |
+
difficulty = "small"
|
| 9 |
+
category = "bugfix"
|
| 10 |
+
keywords = [
|
| 11 |
+
"environs",
|
| 12 |
+
"commit_runtime",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
[metadata.repo2env]
|
| 16 |
+
pipeline = "commit_runtime"
|
| 17 |
+
pipeline_version = "0.8.3"
|
| 18 |
+
repo = "sloria/environs"
|
| 19 |
+
ref = "4654e60b62aae63638533c6aa8d4605680d2e3f1"
|
| 20 |
+
reference = "https://github.com/sloria/environs/commit/9c51c66940a1fb0fb9c4623c5c2dbd3987eeeb39"
|
| 21 |
+
source_access = "public"
|
| 22 |
+
built_at = "2026-09-24T13:07:42.520074+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:ee6ad05e460704b9b341bae1c4524b7c90284f80d5d748b70604620d3f1e878b"
|
| 30 |
+
|
| 31 |
+
[metadata.repo2env.commit_runtime]
|
| 32 |
+
commit_sha = "9c51c66940a1fb0fb9c4623c5c2dbd3987eeeb39"
|
| 33 |
+
parent_sha = "4654e60b62aae63638533c6aa8d4605680d2e3f1"
|
| 34 |
+
authored_at = "2026-04-06T10:09:25-04:00"
|
| 35 |
+
author_email = "git@stevenloria.com"
|
| 36 |
+
subject = "Fix precedence of os.environ over .env (#465)"
|
| 37 |
+
fail_to_pass = [
|
| 38 |
+
"tests/test_environs.py::TestEnvFileReading::test_read_env_os_environ_takes_precedence",
|
| 39 |
+
"tests/test_environs.py::TestEnvFileReading::test_read_env_os_environ_takes_precedence_with_override",
|
| 40 |
+
]
|
| 41 |
+
pass_to_pass = [
|
| 42 |
+
"tests/test_environs.py::TestCasting::test_basic",
|
| 43 |
+
"tests/test_environs.py::TestCasting::test_bool",
|
| 44 |
+
"tests/test_environs.py::TestCasting::test_call",
|
| 45 |
+
"tests/test_environs.py::TestCasting::test_call_with_default",
|
| 46 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_keys_values",
|
| 47 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_list",
|
| 48 |
+
"tests/test_environs.py::TestCasting::test_date_cast",
|
| 49 |
+
"tests/test_environs.py::TestCasting::test_datetime_cast",
|
| 50 |
+
"tests/test_environs.py::TestCasting::test_decimal_cast",
|
| 51 |
+
"tests/test_environs.py::TestCasting::test_default_set",
|
| 52 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[date]",
|
| 53 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[datetime]",
|
| 54 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[time]",
|
| 55 |
+
"tests/test_environs.py::TestCasting::test_dict",
|
| 56 |
+
"tests/test_environs.py::TestCasting::test_dict_with_colon_key_value_delimiter",
|
| 57 |
+
"tests/test_environs.py::TestCasting::test_dict_with_dict_default",
|
| 58 |
+
"tests/test_environs.py::TestCasting::test_dict_with_equal",
|
| 59 |
+
"tests/test_environs.py::TestCasting::test_dict_with_spaces_as_delimiter",
|
| 60 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_keys",
|
| 61 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_values",
|
| 62 |
+
"tests/test_environs.py::TestCasting::test_dict_without_subcast_keys",
|
| 63 |
+
"tests/test_environs.py::TestCasting::test_empty_str",
|
| 64 |
+
"tests/test_environs.py::TestCasting::test_enum_by_value_field",
|
| 65 |
+
"tests/test_environs.py::TestCasting::test_enum_by_value_true",
|
| 66 |
+
"tests/test_environs.py::TestCasting::test_enum_cast",
|
| 67 |
+
"tests/test_environs.py::TestCasting::test_enum_default",
|
| 68 |
+
"tests/test_environs.py::TestCasting::test_float_cast",
|
| 69 |
+
"tests/test_environs.py::TestCasting::test_int_cast",
|
| 70 |
+
"tests/test_environs.py::TestCasting::test_invalid_enum",
|
| 71 |
+
"tests/test_environs.py::TestCasting::test_invalid_int",
|
| 72 |
+
"tests/test_environs.py::TestCasting::test_invalid_json_raises_error",
|
| 73 |
+
"tests/test_environs.py::TestCasting::test_invalid_log_level",
|
| 74 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[42]",
|
| 75 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo@bar]",
|
| 76 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo]",
|
| 77 |
+
"tests/test_environs.py::TestCasting::test_json_cast",
|
| 78 |
+
"tests/test_environs.py::TestCasting::test_json_default",
|
| 79 |
+
"tests/test_environs.py::TestCasting::test_list_cast",
|
| 80 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_from_list",
|
| 81 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_list_and_subcast",
|
| 82 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_none",
|
| 83 |
+
"tests/test_environs.py::TestCasting::test_list_with_empty_env_and_subcast",
|
| 84 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces",
|
| 85 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces_as_delimiter",
|
| 86 |
+
"tests/test_environs.py::TestCasting::test_list_with_subcast",
|
| 87 |
+
"tests/test_environs.py::TestCasting::test_log_level_cast",
|
| 88 |
+
"tests/test_environs.py::TestCasting::test_missing_raises_error",
|
| 89 |
+
"tests/test_environs.py::TestCasting::test_none_default_unchanged",
|
| 90 |
+
"tests/test_environs.py::TestCasting::test_path_cast",
|
| 91 |
+
"tests/test_environs.py::TestCasting::test_path_default_value",
|
| 92 |
+
]
|
| 93 |
+
validation_status = "verified"
|
| 94 |
+
bootstrap_image = "local-venv:sloria__environs"
|
| 95 |
+
instruction_synthesized = true
|
| 96 |
+
llm_cost_usd = 0.0
|
| 97 |
+
|
| 98 |
+
[metadata.repo2env.reward_calibration]
|
| 99 |
+
f2p_count = 2
|
| 100 |
+
p2p_count = 50
|
| 101 |
+
source_files = 2
|
| 102 |
+
loc_changed = 13
|
| 103 |
+
difficulty = "small"
|
| 104 |
+
|
| 105 |
+
[metadata.repo2env.evaluation]
|
| 106 |
+
schema_version = "1"
|
| 107 |
+
status = "unverified"
|
| 108 |
+
stage = "generation"
|
| 109 |
+
reason_codes = [
|
| 110 |
+
"validation_not_run",
|
| 111 |
+
]
|
| 112 |
+
detail = "Generated task; validation has not been established."
|
| 113 |
+
provenance = "unknown"
|
| 114 |
+
evidence = []
|
| 115 |
+
|
| 116 |
+
[metadata.repo2env.reproducibility]
|
| 117 |
+
mode = "local_only"
|
| 118 |
+
image_ref = "local/sloria__environs"
|
| 119 |
+
image_tag = "local/sloria__environs"
|
| 120 |
+
image_visibility = "private"
|
| 121 |
+
|
| 122 |
+
[agent]
|
| 123 |
+
timeout_sec = 1800.0
|
| 124 |
+
|
| 125 |
+
[verifier]
|
| 126 |
+
timeout_sec = 300.0
|
heldout/sloria__environs-9c51c66940a1/tests/f2p.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"tests/test_environs.py::TestEnvFileReading::test_read_env_os_environ_takes_precedence",
|
| 3 |
+
"tests/test_environs.py::TestEnvFileReading::test_read_env_os_environ_takes_precedence_with_override"
|
| 4 |
+
]
|
heldout/sloria__environs-9c51c66940a1/tests/p2p.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"tests/test_environs.py::TestCasting::test_basic",
|
| 3 |
+
"tests/test_environs.py::TestCasting::test_bool",
|
| 4 |
+
"tests/test_environs.py::TestCasting::test_call",
|
| 5 |
+
"tests/test_environs.py::TestCasting::test_call_with_default",
|
| 6 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_keys_values",
|
| 7 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_list",
|
| 8 |
+
"tests/test_environs.py::TestCasting::test_date_cast",
|
| 9 |
+
"tests/test_environs.py::TestCasting::test_datetime_cast",
|
| 10 |
+
"tests/test_environs.py::TestCasting::test_decimal_cast",
|
| 11 |
+
"tests/test_environs.py::TestCasting::test_default_set",
|
| 12 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[date]",
|
| 13 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[datetime]",
|
| 14 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[time]",
|
| 15 |
+
"tests/test_environs.py::TestCasting::test_dict",
|
| 16 |
+
"tests/test_environs.py::TestCasting::test_dict_with_colon_key_value_delimiter",
|
| 17 |
+
"tests/test_environs.py::TestCasting::test_dict_with_dict_default",
|
| 18 |
+
"tests/test_environs.py::TestCasting::test_dict_with_equal",
|
| 19 |
+
"tests/test_environs.py::TestCasting::test_dict_with_spaces_as_delimiter",
|
| 20 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_keys",
|
| 21 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_values",
|
| 22 |
+
"tests/test_environs.py::TestCasting::test_dict_without_subcast_keys",
|
| 23 |
+
"tests/test_environs.py::TestCasting::test_empty_str",
|
| 24 |
+
"tests/test_environs.py::TestCasting::test_enum_by_value_field",
|
| 25 |
+
"tests/test_environs.py::TestCasting::test_enum_by_value_true",
|
| 26 |
+
"tests/test_environs.py::TestCasting::test_enum_cast",
|
| 27 |
+
"tests/test_environs.py::TestCasting::test_enum_default",
|
| 28 |
+
"tests/test_environs.py::TestCasting::test_float_cast",
|
| 29 |
+
"tests/test_environs.py::TestCasting::test_int_cast",
|
| 30 |
+
"tests/test_environs.py::TestCasting::test_invalid_enum",
|
| 31 |
+
"tests/test_environs.py::TestCasting::test_invalid_int",
|
| 32 |
+
"tests/test_environs.py::TestCasting::test_invalid_json_raises_error",
|
| 33 |
+
"tests/test_environs.py::TestCasting::test_invalid_log_level",
|
| 34 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[42]",
|
| 35 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo@bar]",
|
| 36 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo]",
|
| 37 |
+
"tests/test_environs.py::TestCasting::test_json_cast",
|
| 38 |
+
"tests/test_environs.py::TestCasting::test_json_default",
|
| 39 |
+
"tests/test_environs.py::TestCasting::test_list_cast",
|
| 40 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_from_list",
|
| 41 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_list_and_subcast",
|
| 42 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_none",
|
| 43 |
+
"tests/test_environs.py::TestCasting::test_list_with_empty_env_and_subcast",
|
| 44 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces",
|
| 45 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces_as_delimiter",
|
| 46 |
+
"tests/test_environs.py::TestCasting::test_list_with_subcast",
|
| 47 |
+
"tests/test_environs.py::TestCasting::test_log_level_cast",
|
| 48 |
+
"tests/test_environs.py::TestCasting::test_missing_raises_error",
|
| 49 |
+
"tests/test_environs.py::TestCasting::test_none_default_unchanged",
|
| 50 |
+
"tests/test_environs.py::TestCasting::test_path_cast",
|
| 51 |
+
"tests/test_environs.py::TestCasting::test_path_default_value"
|
| 52 |
+
]
|
heldout/sloria__environs-9c51c66940a1/tests/test.sh
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 4654e60b62aae63638533c6aa8d4605680d2e3f1 -- tests/test_environs.py || true
|
| 8 |
+
git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH'
|
| 9 |
+
diff --git a/tests/test_environs.py b/tests/test_environs.py
|
| 10 |
+
index 756223b..dfef7e5 100644
|
| 11 |
+
--- a/tests/test_environs.py
|
| 12 |
+
+++ b/tests/test_environs.py
|
| 13 |
+
@@ -547,6 +547,22 @@ class TestEnvFileReading:
|
| 14 |
+
assert env("STRING") == "foo"
|
| 15 |
+
assert "STRING" not in os.environ
|
| 16 |
+
|
| 17 |
+
+ def test_read_env_os_environ_takes_precedence(self, env: environs.Env, monkeypatch):
|
| 18 |
+
+ monkeypatch.setenv("STRING", "from_os")
|
| 19 |
+
+ env.read_env()
|
| 20 |
+
+ assert env("STRING") == "from_os"
|
| 21 |
+
+
|
| 22 |
+
+ def test_read_env_os_environ_takes_precedence_with_override(
|
| 23 |
+
+ self, tmp_path, monkeypatch
|
| 24 |
+
+ ):
|
| 25 |
+
+ monkeypatch.setenv("A", "from_os")
|
| 26 |
+
+ (tmp_path / "first.env").write_text("A=first\n")
|
| 27 |
+
+ (tmp_path / "second.env").write_text("A=second\n")
|
| 28 |
+
+ env = environs.Env()
|
| 29 |
+
+ env.read_env(tmp_path / "first.env")
|
| 30 |
+
+ env.read_env(tmp_path / "second.env", override=True)
|
| 31 |
+
+ assert env("A") == "from_os"
|
| 32 |
+
+
|
| 33 |
+
def test_read_env_override(self, tmp_path):
|
| 34 |
+
(tmp_path / "first.env").write_text("A=first\n")
|
| 35 |
+
(tmp_path / "second.env").write_text("A=second\n")
|
| 36 |
+
|
| 37 |
+
EOF_R2E_TEST_PATCH
|
| 38 |
+
R2E_APPLY_RC=$?
|
| 39 |
+
if [ "$R2E_APPLY_RC" -ne 0 ]; then
|
| 40 |
+
echo "0.000000" > /logs/verifier/reward.txt
|
| 41 |
+
printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json
|
| 42 |
+
echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2
|
| 43 |
+
exit 0
|
| 44 |
+
fi
|
| 45 |
+
( python -m pytest -v tests/test_environs.py ) > /logs/verifier/test_output.log 2>&1
|
| 46 |
+
TEST_EXIT_CODE=$?
|
| 47 |
+
cat /logs/verifier/test_output.log
|
| 48 |
+
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 tests/test_environs.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; }
|
| 49 |
+
git checkout 4654e60b62aae63638533c6aa8d4605680d2e3f1 -- tests/test_environs.py || true
|
| 50 |
+
exit 0
|
heldout/sloria__environs-9c51c66940a1/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/sloria__environs-9d1ff82555e0/environment/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv pr_runtime
|
| 2 |
+
FROM local/sloria__environs
|
| 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 a873df3460939554806834390a6c82dac194b2ad 2>/dev/null \
|
| 28 |
+
|| git fetch --unshallow origin 2>/dev/null || true
|
| 29 |
+
RUN git reset --hard a873df3460939554806834390a6c82dac194b2ad && 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 a873df3460939554806834390a6c82dac194b2ad \
|
| 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/sloria__environs-9d1ff82555e0/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/sloria__environs-9d1ff82555e0/instruction.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue
|
| 2 |
+
|
| 3 |
+
**Title:** `read_env` always searches recursively and can raise `UnboundLocalError`
|
| 4 |
+
|
| 5 |
+
## Description
|
| 6 |
+
The `read_env` function exhibits an "always recursive" behavior, meaning it searches parent directories for `.env` files even when not explicitly intended, potentially leading to unexpected file loading. Furthermore, under specific conditions, calling `read_env` can result in an `UnboundLocalError`. When `return_path=True` and no `.env` file is located, the function should return `None` but currently does not.
|
| 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 `a873df346093` and running the modified tests.
|
heldout/sloria__environs-9d1ff82555e0/solution/patch.diff
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
|
| 2 |
+
index eb26dd6..96c2563 100644
|
| 3 |
+
--- a/CHANGELOG.md
|
| 4 |
+
+++ b/CHANGELOG.md
|
| 5 |
+
@@ -1,5 +1,13 @@
|
| 6 |
+
# Changelog
|
| 7 |
+
|
| 8 |
+
+## 11.2.1 (unreleased)
|
| 9 |
+
+
|
| 10 |
+
+Bug fixes:
|
| 11 |
+
+
|
| 12 |
+
+- Fix `Env.read_env(recurse=True)` so that it returns as soon as a `.env`
|
| 13 |
+
+ file is found ([#370](https://github.com/sloria/environs/pull/370)).
|
| 14 |
+
+ Thanks [senese](https://github.com/senese) for the PR.
|
| 15 |
+
+
|
| 16 |
+
## 11.2.0 (2024-11-14)
|
| 17 |
+
|
| 18 |
+
Features:
|
| 19 |
+
diff --git a/src/environs/__init__.py b/src/environs/__init__.py
|
| 20 |
+
index 8014260..2fb8e40 100644
|
| 21 |
+
--- a/src/environs/__init__.py
|
| 22 |
+
+++ b/src/environs/__init__.py
|
| 23 |
+
@@ -454,7 +454,7 @@ class Env:
|
| 24 |
+
verbose: _BoolType = False,
|
| 25 |
+
override: _BoolType = False,
|
| 26 |
+
return_path: _BoolType = False,
|
| 27 |
+
- ) -> typing.Union[_BoolType, _StrType]:
|
| 28 |
+
+ ) -> typing.Union[_BoolType, typing.Optional[_StrType]]:
|
| 29 |
+
"""Read a .env file into os.environ.
|
| 30 |
+
|
| 31 |
+
If .env is not found in the directory from which this method is called,
|
| 32 |
+
@@ -462,7 +462,7 @@ class Env:
|
| 33 |
+
file is found. If you do not wish to recurse up the tree, you may pass
|
| 34 |
+
False as a second positional argument.
|
| 35 |
+
"""
|
| 36 |
+
-
|
| 37 |
+
+ env_path = None
|
| 38 |
+
is_env_loaded = False
|
| 39 |
+
if path is None:
|
| 40 |
+
# By default, start search from the same directory this function is called
|
| 41 |
+
@@ -488,6 +488,8 @@ class Env:
|
| 42 |
+
check_path, verbose=verbose, override=override
|
| 43 |
+
)
|
| 44 |
+
env_path = str(check_path)
|
| 45 |
+
+ break
|
| 46 |
+
+
|
| 47 |
+
else:
|
| 48 |
+
is_env_loaded = load_dotenv(str(start), verbose=verbose, override=override)
|
| 49 |
+
env_path = str(start)
|
heldout/sloria__environs-9d1ff82555e0/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/sloria__environs-9d1ff82555e0/task.toml
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "commit-runtime/sloria__environs-9d1ff82555e0"
|
| 5 |
+
description = "Fix read_env recursive bug (#370)"
|
| 6 |
+
|
| 7 |
+
[metadata]
|
| 8 |
+
difficulty = "small"
|
| 9 |
+
category = "bugfix"
|
| 10 |
+
keywords = [
|
| 11 |
+
"environs",
|
| 12 |
+
"commit_runtime",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
[metadata.repo2env]
|
| 16 |
+
pipeline = "commit_runtime"
|
| 17 |
+
pipeline_version = "0.8.3"
|
| 18 |
+
repo = "sloria/environs"
|
| 19 |
+
ref = "a873df3460939554806834390a6c82dac194b2ad"
|
| 20 |
+
reference = "https://github.com/sloria/environs/commit/9d1ff82555e053990dc8c3bfbdf268015f3502bc"
|
| 21 |
+
source_access = "public"
|
| 22 |
+
built_at = "2026-09-24T13:07:59.861100+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:1f4fe7e9bb123e887810eeaf2697c3ae748769a679d903b453544fe404944ee6"
|
| 30 |
+
|
| 31 |
+
[metadata.repo2env.commit_runtime]
|
| 32 |
+
commit_sha = "9d1ff82555e053990dc8c3bfbdf268015f3502bc"
|
| 33 |
+
parent_sha = "a873df3460939554806834390a6c82dac194b2ad"
|
| 34 |
+
authored_at = "2024-11-20T14:30:32-03:00"
|
| 35 |
+
author_email = "30537409+senese@users.noreply.github.com"
|
| 36 |
+
subject = "Fix read_env recursive bug (#370)"
|
| 37 |
+
fail_to_pass = [
|
| 38 |
+
"tests/test_environs.py::TestEnvFileReading::test_read_env_return_path_if_env_not_found",
|
| 39 |
+
"tests/test_environs.py::TestEnvFileReading::test_read_env_return_path_with_dotenv_in_working_dir",
|
| 40 |
+
]
|
| 41 |
+
pass_to_pass = [
|
| 42 |
+
"tests/test_environs.py::TestCasting::test_basic",
|
| 43 |
+
"tests/test_environs.py::TestCasting::test_bool",
|
| 44 |
+
"tests/test_environs.py::TestCasting::test_call",
|
| 45 |
+
"tests/test_environs.py::TestCasting::test_call_with_default",
|
| 46 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_keys_values",
|
| 47 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_list",
|
| 48 |
+
"tests/test_environs.py::TestCasting::test_date_cast",
|
| 49 |
+
"tests/test_environs.py::TestCasting::test_datetime_cast",
|
| 50 |
+
"tests/test_environs.py::TestCasting::test_decimal_cast",
|
| 51 |
+
"tests/test_environs.py::TestCasting::test_dict",
|
| 52 |
+
"tests/test_environs.py::TestCasting::test_dict_with_default_from_dict",
|
| 53 |
+
"tests/test_environs.py::TestCasting::test_dict_with_default_from_string",
|
| 54 |
+
"tests/test_environs.py::TestCasting::test_dict_with_equal",
|
| 55 |
+
"tests/test_environs.py::TestCasting::test_dict_with_spaces_as_delimiter",
|
| 56 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_keys",
|
| 57 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_values",
|
| 58 |
+
"tests/test_environs.py::TestCasting::test_dict_without_subcast_keys",
|
| 59 |
+
"tests/test_environs.py::TestCasting::test_empty_str",
|
| 60 |
+
"tests/test_environs.py::TestCasting::test_enum_cast",
|
| 61 |
+
"tests/test_environs.py::TestCasting::test_enum_cast_ignore_case",
|
| 62 |
+
"tests/test_environs.py::TestCasting::test_float_cast",
|
| 63 |
+
"tests/test_environs.py::TestCasting::test_int_cast",
|
| 64 |
+
"tests/test_environs.py::TestCasting::test_invalid_enum",
|
| 65 |
+
"tests/test_environs.py::TestCasting::test_invalid_enum_ignore_case",
|
| 66 |
+
"tests/test_environs.py::TestCasting::test_invalid_int",
|
| 67 |
+
"tests/test_environs.py::TestCasting::test_invalid_json_raises_error",
|
| 68 |
+
"tests/test_environs.py::TestCasting::test_invalid_log_level",
|
| 69 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[42]",
|
| 70 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo@bar]",
|
| 71 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo]",
|
| 72 |
+
"tests/test_environs.py::TestCasting::test_json_cast",
|
| 73 |
+
"tests/test_environs.py::TestCasting::test_json_default",
|
| 74 |
+
"tests/test_environs.py::TestCasting::test_list_cast",
|
| 75 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_from_list",
|
| 76 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_from_string",
|
| 77 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_none",
|
| 78 |
+
"tests/test_environs.py::TestCasting::test_list_with_empty_env_and_subcast",
|
| 79 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces",
|
| 80 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces_as_delimiter",
|
| 81 |
+
"tests/test_environs.py::TestCasting::test_list_with_subcast",
|
| 82 |
+
"tests/test_environs.py::TestCasting::test_log_level_cast",
|
| 83 |
+
"tests/test_environs.py::TestCasting::test_missing_raises_error",
|
| 84 |
+
"tests/test_environs.py::TestCasting::test_path_cast",
|
| 85 |
+
"tests/test_environs.py::TestCasting::test_path_default_value",
|
| 86 |
+
"tests/test_environs.py::TestCasting::test_time_cast",
|
| 87 |
+
"tests/test_environs.py::TestCasting::test_url_cast",
|
| 88 |
+
"tests/test_environs.py::TestCasting::test_url_db_cast",
|
| 89 |
+
"tests/test_environs.py::TestCasting::test_uuid_cast",
|
| 90 |
+
"tests/test_environs.py::TestCustomTypes::test_add_parser",
|
| 91 |
+
"tests/test_environs.py::TestCustomTypes::test_add_parser_from_field",
|
| 92 |
+
]
|
| 93 |
+
validation_status = "verified"
|
| 94 |
+
bootstrap_image = "local-venv:sloria__environs"
|
| 95 |
+
instruction_synthesized = true
|
| 96 |
+
llm_cost_usd = 0.004334
|
| 97 |
+
|
| 98 |
+
[metadata.repo2env.reward_calibration]
|
| 99 |
+
f2p_count = 2
|
| 100 |
+
p2p_count = 50
|
| 101 |
+
source_files = 2
|
| 102 |
+
loc_changed = 14
|
| 103 |
+
difficulty = "small"
|
| 104 |
+
|
| 105 |
+
[metadata.repo2env.evaluation]
|
| 106 |
+
schema_version = "1"
|
| 107 |
+
status = "unverified"
|
| 108 |
+
stage = "generation"
|
| 109 |
+
reason_codes = [
|
| 110 |
+
"validation_not_run",
|
| 111 |
+
]
|
| 112 |
+
detail = "Generated task; validation has not been established."
|
| 113 |
+
provenance = "unknown"
|
| 114 |
+
evidence = []
|
| 115 |
+
|
| 116 |
+
[metadata.repo2env.reproducibility]
|
| 117 |
+
mode = "local_only"
|
| 118 |
+
image_ref = "local/sloria__environs"
|
| 119 |
+
image_tag = "local/sloria__environs"
|
| 120 |
+
image_visibility = "private"
|
| 121 |
+
|
| 122 |
+
[agent]
|
| 123 |
+
timeout_sec = 1800.0
|
| 124 |
+
|
| 125 |
+
[verifier]
|
| 126 |
+
timeout_sec = 300.0
|
heldout/sloria__environs-9d1ff82555e0/tests/f2p.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"tests/test_environs.py::TestEnvFileReading::test_read_env_return_path_if_env_not_found",
|
| 3 |
+
"tests/test_environs.py::TestEnvFileReading::test_read_env_return_path_with_dotenv_in_working_dir"
|
| 4 |
+
]
|
heldout/sloria__environs-9d1ff82555e0/tests/p2p.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"tests/test_environs.py::TestCasting::test_basic",
|
| 3 |
+
"tests/test_environs.py::TestCasting::test_bool",
|
| 4 |
+
"tests/test_environs.py::TestCasting::test_call",
|
| 5 |
+
"tests/test_environs.py::TestCasting::test_call_with_default",
|
| 6 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_keys_values",
|
| 7 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_list",
|
| 8 |
+
"tests/test_environs.py::TestCasting::test_date_cast",
|
| 9 |
+
"tests/test_environs.py::TestCasting::test_datetime_cast",
|
| 10 |
+
"tests/test_environs.py::TestCasting::test_decimal_cast",
|
| 11 |
+
"tests/test_environs.py::TestCasting::test_dict",
|
| 12 |
+
"tests/test_environs.py::TestCasting::test_dict_with_default_from_dict",
|
| 13 |
+
"tests/test_environs.py::TestCasting::test_dict_with_default_from_string",
|
| 14 |
+
"tests/test_environs.py::TestCasting::test_dict_with_equal",
|
| 15 |
+
"tests/test_environs.py::TestCasting::test_dict_with_spaces_as_delimiter",
|
| 16 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_keys",
|
| 17 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_values",
|
| 18 |
+
"tests/test_environs.py::TestCasting::test_dict_without_subcast_keys",
|
| 19 |
+
"tests/test_environs.py::TestCasting::test_empty_str",
|
| 20 |
+
"tests/test_environs.py::TestCasting::test_enum_cast",
|
| 21 |
+
"tests/test_environs.py::TestCasting::test_enum_cast_ignore_case",
|
| 22 |
+
"tests/test_environs.py::TestCasting::test_float_cast",
|
| 23 |
+
"tests/test_environs.py::TestCasting::test_int_cast",
|
| 24 |
+
"tests/test_environs.py::TestCasting::test_invalid_enum",
|
| 25 |
+
"tests/test_environs.py::TestCasting::test_invalid_enum_ignore_case",
|
| 26 |
+
"tests/test_environs.py::TestCasting::test_invalid_int",
|
| 27 |
+
"tests/test_environs.py::TestCasting::test_invalid_json_raises_error",
|
| 28 |
+
"tests/test_environs.py::TestCasting::test_invalid_log_level",
|
| 29 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[42]",
|
| 30 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo@bar]",
|
| 31 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo]",
|
| 32 |
+
"tests/test_environs.py::TestCasting::test_json_cast",
|
| 33 |
+
"tests/test_environs.py::TestCasting::test_json_default",
|
| 34 |
+
"tests/test_environs.py::TestCasting::test_list_cast",
|
| 35 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_from_list",
|
| 36 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_from_string",
|
| 37 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_none",
|
| 38 |
+
"tests/test_environs.py::TestCasting::test_list_with_empty_env_and_subcast",
|
| 39 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces",
|
| 40 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces_as_delimiter",
|
| 41 |
+
"tests/test_environs.py::TestCasting::test_list_with_subcast",
|
| 42 |
+
"tests/test_environs.py::TestCasting::test_log_level_cast",
|
| 43 |
+
"tests/test_environs.py::TestCasting::test_missing_raises_error",
|
| 44 |
+
"tests/test_environs.py::TestCasting::test_path_cast",
|
| 45 |
+
"tests/test_environs.py::TestCasting::test_path_default_value",
|
| 46 |
+
"tests/test_environs.py::TestCasting::test_time_cast",
|
| 47 |
+
"tests/test_environs.py::TestCasting::test_url_cast",
|
| 48 |
+
"tests/test_environs.py::TestCasting::test_url_db_cast",
|
| 49 |
+
"tests/test_environs.py::TestCasting::test_uuid_cast",
|
| 50 |
+
"tests/test_environs.py::TestCustomTypes::test_add_parser",
|
| 51 |
+
"tests/test_environs.py::TestCustomTypes::test_add_parser_from_field"
|
| 52 |
+
]
|
heldout/sloria__environs-9d1ff82555e0/tests/test.sh
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 a873df3460939554806834390a6c82dac194b2ad -- tests/test_environs.py || true
|
| 8 |
+
git apply --verbose --reject - <<'EOF_R2E_TEST_PATCH'
|
| 9 |
+
diff --git a/tests/test_environs.py b/tests/test_environs.py
|
| 10 |
+
index 1920c52..102e0b8 100644
|
| 11 |
+
--- a/tests/test_environs.py
|
| 12 |
+
+++ b/tests/test_environs.py
|
| 13 |
+
@@ -407,6 +407,33 @@ class TestEnvFileReading:
|
| 14 |
+
env_path = str(HERE / ".env")
|
| 15 |
+
assert path == env_path
|
| 16 |
+
|
| 17 |
+
+ def test_read_env_return_path_with_dotenv_in_working_dir(self, env):
|
| 18 |
+
+ working_dir = pathlib.Path(os.getcwd())
|
| 19 |
+
+ temp_env = working_dir / ".env"
|
| 20 |
+
+ try:
|
| 21 |
+
+ # Create an empty .env file in working dir
|
| 22 |
+
+ temp_env.touch()
|
| 23 |
+
+ path = env.read_env(return_path=True)
|
| 24 |
+
+ finally:
|
| 25 |
+
+ if temp_env.exists():
|
| 26 |
+
+ temp_env.unlink()
|
| 27 |
+
+
|
| 28 |
+
+ env_path = str(HERE / ".env")
|
| 29 |
+
+ assert path == env_path
|
| 30 |
+
+
|
| 31 |
+
+ def test_read_env_return_path_if_env_not_found(self, env, tmp_path):
|
| 32 |
+
+ # Move .env file to temp location
|
| 33 |
+
+ env_path = HERE / ".env"
|
| 34 |
+
+ temp_env = tmp_path / ".env"
|
| 35 |
+
+ try:
|
| 36 |
+
+ env_path.rename(temp_env)
|
| 37 |
+
+ path = env.read_env(return_path=True)
|
| 38 |
+
+ assert path is None
|
| 39 |
+
+ finally:
|
| 40 |
+
+ # Restore .env file
|
| 41 |
+
+ if temp_env.exists():
|
| 42 |
+
+ temp_env.rename(env_path)
|
| 43 |
+
+
|
| 44 |
+
|
| 45 |
+
def always_fail(value):
|
| 46 |
+
raise environs.EnvError("something went wrong")
|
| 47 |
+
|
| 48 |
+
EOF_R2E_TEST_PATCH
|
| 49 |
+
R2E_APPLY_RC=$?
|
| 50 |
+
if [ "$R2E_APPLY_RC" -ne 0 ]; then
|
| 51 |
+
echo "0.000000" > /logs/verifier/reward.txt
|
| 52 |
+
printf '%s' '{"reward": 0.0, "resolved": false, "parse_status": "test_patch_apply_failed"}' > /logs/verifier/reward-details.json
|
| 53 |
+
echo "R2E: test_patch failed to apply (rc=$R2E_APPLY_RC) — failing closed" >&2
|
| 54 |
+
exit 0
|
| 55 |
+
fi
|
| 56 |
+
( python -m pytest -v tests/test_environs.py ) > /logs/verifier/test_output.log 2>&1
|
| 57 |
+
TEST_EXIT_CODE=$?
|
| 58 |
+
cat /logs/verifier/test_output.log
|
| 59 |
+
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 tests/test_environs.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; }
|
| 60 |
+
git checkout a873df3460939554806834390a6c82dac194b2ad -- tests/test_environs.py || true
|
| 61 |
+
exit 0
|
heldout/sloria__environs-9d1ff82555e0/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/sloria__environs-aa99f02fb39d/environment/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto-generated by Repo2RLEnv pr_runtime
|
| 2 |
+
FROM local/sloria__environs
|
| 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 7ed9ec4cf3fc27c83efd8fe8d29a442a09a457d0 2>/dev/null \
|
| 28 |
+
|| git fetch --unshallow origin 2>/dev/null || true
|
| 29 |
+
RUN git reset --hard 7ed9ec4cf3fc27c83efd8fe8d29a442a09a457d0 && 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 7ed9ec4cf3fc27c83efd8fe8d29a442a09a457d0 \
|
| 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/sloria__environs-aa99f02fb39d/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/sloria__environs-aa99f02fb39d/instruction.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Issue
|
| 2 |
+
|
| 3 |
+
**Title:** Values read from files include trailing newlines
|
| 4 |
+
|
| 5 |
+
## Description
|
| 6 |
+
When reading a value from a file, any trailing newline characters are retained as part of the retrieved value. For instance, if a file named `config.txt` contains `my_setting\n`, the value obtained will be `"my_setting\n"`. The expected behavior is that trailing newlines should be automatically stripped, returning `"my_setting"` instead.
|
| 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 `7ed9ec4cf3fc` and running the modified tests.
|
heldout/sloria__environs-aa99f02fb39d/solution/patch.diff
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
|
| 2 |
+
index 08025d9..d8e45a6 100644
|
| 3 |
+
--- a/CHANGELOG.md
|
| 4 |
+
+++ b/CHANGELOG.md
|
| 5 |
+
@@ -1,5 +1,12 @@
|
| 6 |
+
# Changelog
|
| 7 |
+
|
| 8 |
+
+## unreleased
|
| 9 |
+
+
|
| 10 |
+
+Features:
|
| 11 |
+
+
|
| 12 |
+
+- Add `strip_whitespace` param to `FileAwareEnv` ([#431](https://github.com/sloria/environs/issues/431)).
|
| 13 |
+
+ Thanks [eandersons](https://github.com/eandersons) for the suggestion and PR.
|
| 14 |
+
+
|
| 15 |
+
## 14.4.0 (2025-10-29)
|
| 16 |
+
|
| 17 |
+
Features:
|
| 18 |
+
diff --git a/README.md b/README.md
|
| 19 |
+
index a8d31e4..d5cb72e 100644
|
| 20 |
+
--- a/README.md
|
| 21 |
+
+++ b/README.md
|
| 22 |
+
@@ -350,7 +350,7 @@ file is found, its contents will be read and returned.
|
| 23 |
+
```python
|
| 24 |
+
from environs import FileAwareEnv
|
| 25 |
+
|
| 26 |
+
-# echo 'my secret password' > /run/secrets/password
|
| 27 |
+
+# printf 'my secret password' >/run/secrets/password
|
| 28 |
+
# export PASSWORD_FILE=/run/secrets/password
|
| 29 |
+
|
| 30 |
+
env = FileAwareEnv()
|
| 31 |
+
@@ -362,13 +362,25 @@ It's also possible to set a different suffix for the variable names:
|
| 32 |
+
```python
|
| 33 |
+
from environs import FileAwareEnv
|
| 34 |
+
|
| 35 |
+
-# echo 'my secret password' > /run/secrets/password
|
| 36 |
+
+# printf 'my secret password' >/run/secrets/password
|
| 37 |
+
# export PASSWORD_SECRET=/run/secrets/password
|
| 38 |
+
|
| 39 |
+
env = FileAwareEnv(file_suffix="_SECRET")
|
| 40 |
+
password = env.str("PASSWORD") # => 'my secret password'
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
+To strip leading and trailing whitespaces from the value:
|
| 44 |
+
+
|
| 45 |
+
+```python
|
| 46 |
+
+from environs import FileAwareEnv
|
| 47 |
+
+
|
| 48 |
+
+# printf ' value with leading and trailing whitespaces \n' >/run/secrets/password
|
| 49 |
+
+# export PASSWORD_SECRET=/run/secrets/password
|
| 50 |
+
+
|
| 51 |
+
+env: FileAwareEnv = FileAwareEnv(strip_whitespace=True)
|
| 52 |
+
+password: str = env.str("PASSWORD") # => `value with leading and trailing whitespaces`
|
| 53 |
+
+```
|
| 54 |
+
+
|
| 55 |
+
## Defining custom parser behavior
|
| 56 |
+
|
| 57 |
+
```python
|
| 58 |
+
diff --git a/src/environs/__init__.py b/src/environs/__init__.py
|
| 59 |
+
index f3ff8ba..555c763 100644
|
| 60 |
+
--- a/src/environs/__init__.py
|
| 61 |
+
+++ b/src/environs/__init__.py
|
| 62 |
+
@@ -584,8 +584,10 @@ class FileAwareEnv(Env):
|
| 63 |
+
eager: _BoolType = True,
|
| 64 |
+
expand_vars: _BoolType = False,
|
| 65 |
+
prefix: _StrType | None = None,
|
| 66 |
+
+ strip_whitespace: _BoolType = False,
|
| 67 |
+
):
|
| 68 |
+
- self.file_suffix = file_suffix
|
| 69 |
+
+ self.file_suffix: _StrType = file_suffix
|
| 70 |
+
+ self.strip_whitespace: _BoolType = strip_whitespace
|
| 71 |
+
super().__init__(eager=eager, expand_vars=expand_vars, prefix=prefix)
|
| 72 |
+
|
| 73 |
+
def _get_value(self, env_key: _StrType, default: typing.Any) -> typing.Any:
|
| 74 |
+
@@ -593,7 +595,8 @@ class FileAwareEnv(Env):
|
| 75 |
+
file_key = f"{env_key}{self.file_suffix}"
|
| 76 |
+
if file_path := os.environ.get(file_key, None):
|
| 77 |
+
try:
|
| 78 |
+
- return Path(file_path).read_text()
|
| 79 |
+
+ value: _StrType = Path(file_path).read_text()
|
| 80 |
+
+ return value.strip() if self.strip_whitespace else value
|
| 81 |
+
except (FileNotFoundError, IsADirectoryError, PermissionError) as err:
|
| 82 |
+
raise ValueError(
|
| 83 |
+
f"The value of {file_key} must be a readable file path."
|
heldout/sloria__environs-aa99f02fb39d/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/sloria__environs-aa99f02fb39d/task.toml
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "commit-runtime/sloria__environs-aa99f02fb39d"
|
| 5 |
+
description = "Strip newlines from values retrieved from files (#436)"
|
| 6 |
+
|
| 7 |
+
[metadata]
|
| 8 |
+
difficulty = "medium"
|
| 9 |
+
category = "bugfix"
|
| 10 |
+
keywords = [
|
| 11 |
+
"environs",
|
| 12 |
+
"commit_runtime",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
[metadata.repo2env]
|
| 16 |
+
pipeline = "commit_runtime"
|
| 17 |
+
pipeline_version = "0.8.3"
|
| 18 |
+
repo = "sloria/environs"
|
| 19 |
+
ref = "7ed9ec4cf3fc27c83efd8fe8d29a442a09a457d0"
|
| 20 |
+
reference = "https://github.com/sloria/environs/commit/aa99f02fb39dda419d6ce27e2e635a948239659c"
|
| 21 |
+
source_access = "public"
|
| 22 |
+
built_at = "2026-09-24T13:07:54.382003+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:1842f3d765b39504e653896b76a9542904b05a9030f6b3d2f05983c12a264620"
|
| 30 |
+
|
| 31 |
+
[metadata.repo2env.commit_runtime]
|
| 32 |
+
commit_sha = "aa99f02fb39dda419d6ce27e2e635a948239659c"
|
| 33 |
+
parent_sha = "7ed9ec4cf3fc27c83efd8fe8d29a442a09a457d0"
|
| 34 |
+
authored_at = "2025-11-02T23:21:26+02:00"
|
| 35 |
+
author_email = "eandersons@users.noreply.github.com"
|
| 36 |
+
subject = "Strip newlines from values retrieved from files (#436)"
|
| 37 |
+
fail_to_pass = [
|
| 38 |
+
"tests/test_environs.py::TestFileAwareEnv::test_read_from_file[STRIP_WHITESPACE-\\n value from file with leading and trailing whitespaces \\n-kwargs2-value from file with leading and trailing whitespaces]",
|
| 39 |
+
]
|
| 40 |
+
pass_to_pass = [
|
| 41 |
+
"tests/test_environs.py::TestCasting::test_basic",
|
| 42 |
+
"tests/test_environs.py::TestCasting::test_bool",
|
| 43 |
+
"tests/test_environs.py::TestCasting::test_call",
|
| 44 |
+
"tests/test_environs.py::TestCasting::test_call_with_default",
|
| 45 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_keys_values",
|
| 46 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_list",
|
| 47 |
+
"tests/test_environs.py::TestCasting::test_date_cast",
|
| 48 |
+
"tests/test_environs.py::TestCasting::test_datetime_cast",
|
| 49 |
+
"tests/test_environs.py::TestCasting::test_decimal_cast",
|
| 50 |
+
"tests/test_environs.py::TestCasting::test_default_set",
|
| 51 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[date]",
|
| 52 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[datetime]",
|
| 53 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[time]",
|
| 54 |
+
"tests/test_environs.py::TestCasting::test_dict",
|
| 55 |
+
"tests/test_environs.py::TestCasting::test_dict_with_colon_key_value_delimiter",
|
| 56 |
+
"tests/test_environs.py::TestCasting::test_dict_with_dict_default",
|
| 57 |
+
"tests/test_environs.py::TestCasting::test_dict_with_equal",
|
| 58 |
+
"tests/test_environs.py::TestCasting::test_dict_with_spaces_as_delimiter",
|
| 59 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_keys",
|
| 60 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_values",
|
| 61 |
+
"tests/test_environs.py::TestCasting::test_dict_without_subcast_keys",
|
| 62 |
+
"tests/test_environs.py::TestCasting::test_empty_str",
|
| 63 |
+
"tests/test_environs.py::TestCasting::test_enum_by_value_field",
|
| 64 |
+
"tests/test_environs.py::TestCasting::test_enum_by_value_true",
|
| 65 |
+
"tests/test_environs.py::TestCasting::test_enum_cast",
|
| 66 |
+
"tests/test_environs.py::TestCasting::test_enum_default",
|
| 67 |
+
"tests/test_environs.py::TestCasting::test_float_cast",
|
| 68 |
+
"tests/test_environs.py::TestCasting::test_int_cast",
|
| 69 |
+
"tests/test_environs.py::TestCasting::test_invalid_enum",
|
| 70 |
+
"tests/test_environs.py::TestCasting::test_invalid_int",
|
| 71 |
+
"tests/test_environs.py::TestCasting::test_invalid_json_raises_error",
|
| 72 |
+
"tests/test_environs.py::TestCasting::test_invalid_log_level",
|
| 73 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[42]",
|
| 74 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo@bar]",
|
| 75 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo]",
|
| 76 |
+
"tests/test_environs.py::TestCasting::test_json_cast",
|
| 77 |
+
"tests/test_environs.py::TestCasting::test_json_default",
|
| 78 |
+
"tests/test_environs.py::TestCasting::test_list_cast",
|
| 79 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_from_list",
|
| 80 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_list_and_subcast",
|
| 81 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_none",
|
| 82 |
+
"tests/test_environs.py::TestCasting::test_list_with_empty_env_and_subcast",
|
| 83 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces",
|
| 84 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces_as_delimiter",
|
| 85 |
+
"tests/test_environs.py::TestCasting::test_list_with_subcast",
|
| 86 |
+
"tests/test_environs.py::TestCasting::test_log_level_cast",
|
| 87 |
+
"tests/test_environs.py::TestCasting::test_missing_raises_error",
|
| 88 |
+
"tests/test_environs.py::TestCasting::test_path_cast",
|
| 89 |
+
"tests/test_environs.py::TestCasting::test_path_default_value",
|
| 90 |
+
"tests/test_environs.py::TestCasting::test_time_cast",
|
| 91 |
+
]
|
| 92 |
+
validation_status = "verified"
|
| 93 |
+
bootstrap_image = "local-venv:sloria__environs"
|
| 94 |
+
instruction_synthesized = true
|
| 95 |
+
llm_cost_usd = 0.002652
|
| 96 |
+
|
| 97 |
+
[metadata.repo2env.reward_calibration]
|
| 98 |
+
f2p_count = 1
|
| 99 |
+
p2p_count = 50
|
| 100 |
+
source_files = 3
|
| 101 |
+
loc_changed = 30
|
| 102 |
+
difficulty = "medium"
|
| 103 |
+
|
| 104 |
+
[metadata.repo2env.evaluation]
|
| 105 |
+
schema_version = "1"
|
| 106 |
+
status = "unverified"
|
| 107 |
+
stage = "generation"
|
| 108 |
+
reason_codes = [
|
| 109 |
+
"validation_not_run",
|
| 110 |
+
]
|
| 111 |
+
detail = "Generated task; validation has not been established."
|
| 112 |
+
provenance = "unknown"
|
| 113 |
+
evidence = []
|
| 114 |
+
|
| 115 |
+
[metadata.repo2env.reproducibility]
|
| 116 |
+
mode = "local_only"
|
| 117 |
+
image_ref = "local/sloria__environs"
|
| 118 |
+
image_tag = "local/sloria__environs"
|
| 119 |
+
image_visibility = "private"
|
| 120 |
+
|
| 121 |
+
[agent]
|
| 122 |
+
timeout_sec = 1800.0
|
| 123 |
+
|
| 124 |
+
[verifier]
|
| 125 |
+
timeout_sec = 300.0
|
heldout/sloria__environs-aa99f02fb39d/tests/f2p.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"tests/test_environs.py::TestFileAwareEnv::test_read_from_file[STRIP_WHITESPACE-\\n value from file with leading and trailing whitespaces \\n-kwargs2-value from file with leading and trailing whitespaces]"
|
| 3 |
+
]
|
heldout/sloria__environs-aa99f02fb39d/tests/p2p.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"tests/test_environs.py::TestCasting::test_basic",
|
| 3 |
+
"tests/test_environs.py::TestCasting::test_bool",
|
| 4 |
+
"tests/test_environs.py::TestCasting::test_call",
|
| 5 |
+
"tests/test_environs.py::TestCasting::test_call_with_default",
|
| 6 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_keys_values",
|
| 7 |
+
"tests/test_environs.py::TestCasting::test_custom_subcast_list",
|
| 8 |
+
"tests/test_environs.py::TestCasting::test_date_cast",
|
| 9 |
+
"tests/test_environs.py::TestCasting::test_datetime_cast",
|
| 10 |
+
"tests/test_environs.py::TestCasting::test_decimal_cast",
|
| 11 |
+
"tests/test_environs.py::TestCasting::test_default_set",
|
| 12 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[date]",
|
| 13 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[datetime]",
|
| 14 |
+
"tests/test_environs.py::TestCasting::test_default_set_to_internal_type[time]",
|
| 15 |
+
"tests/test_environs.py::TestCasting::test_dict",
|
| 16 |
+
"tests/test_environs.py::TestCasting::test_dict_with_colon_key_value_delimiter",
|
| 17 |
+
"tests/test_environs.py::TestCasting::test_dict_with_dict_default",
|
| 18 |
+
"tests/test_environs.py::TestCasting::test_dict_with_equal",
|
| 19 |
+
"tests/test_environs.py::TestCasting::test_dict_with_spaces_as_delimiter",
|
| 20 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_keys",
|
| 21 |
+
"tests/test_environs.py::TestCasting::test_dict_with_subcast_values",
|
| 22 |
+
"tests/test_environs.py::TestCasting::test_dict_without_subcast_keys",
|
| 23 |
+
"tests/test_environs.py::TestCasting::test_empty_str",
|
| 24 |
+
"tests/test_environs.py::TestCasting::test_enum_by_value_field",
|
| 25 |
+
"tests/test_environs.py::TestCasting::test_enum_by_value_true",
|
| 26 |
+
"tests/test_environs.py::TestCasting::test_enum_cast",
|
| 27 |
+
"tests/test_environs.py::TestCasting::test_enum_default",
|
| 28 |
+
"tests/test_environs.py::TestCasting::test_float_cast",
|
| 29 |
+
"tests/test_environs.py::TestCasting::test_int_cast",
|
| 30 |
+
"tests/test_environs.py::TestCasting::test_invalid_enum",
|
| 31 |
+
"tests/test_environs.py::TestCasting::test_invalid_int",
|
| 32 |
+
"tests/test_environs.py::TestCasting::test_invalid_json_raises_error",
|
| 33 |
+
"tests/test_environs.py::TestCasting::test_invalid_log_level",
|
| 34 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[42]",
|
| 35 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo@bar]",
|
| 36 |
+
"tests/test_environs.py::TestCasting::test_invalid_url[foo]",
|
| 37 |
+
"tests/test_environs.py::TestCasting::test_json_cast",
|
| 38 |
+
"tests/test_environs.py::TestCasting::test_json_default",
|
| 39 |
+
"tests/test_environs.py::TestCasting::test_list_cast",
|
| 40 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_from_list",
|
| 41 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_list_and_subcast",
|
| 42 |
+
"tests/test_environs.py::TestCasting::test_list_with_default_none",
|
| 43 |
+
"tests/test_environs.py::TestCasting::test_list_with_empty_env_and_subcast",
|
| 44 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces",
|
| 45 |
+
"tests/test_environs.py::TestCasting::test_list_with_spaces_as_delimiter",
|
| 46 |
+
"tests/test_environs.py::TestCasting::test_list_with_subcast",
|
| 47 |
+
"tests/test_environs.py::TestCasting::test_log_level_cast",
|
| 48 |
+
"tests/test_environs.py::TestCasting::test_missing_raises_error",
|
| 49 |
+
"tests/test_environs.py::TestCasting::test_path_cast",
|
| 50 |
+
"tests/test_environs.py::TestCasting::test_path_default_value",
|
| 51 |
+
"tests/test_environs.py::TestCasting::test_time_cast"
|
| 52 |
+
]
|